From ddd8ff21807586d2b850c8abe9fd91cca2f4cf51 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Sun, 19 Sep 2021 12:27:48 +0200 Subject: [PATCH 001/465] ptme handling wip --- bsp_q7s/core/ObjectFactory.cpp | 30 +- common/config/commonClassIds.h | 1 + common/config/commonConfig.h.in | 7 + common/config/commonObjects.h | 5 + .../tmtc}/CCSDSIPCoreBridge.cpp | 2 +- .../{obc => archive/tmtc}/CCSDSIPCoreBridge.h | 0 linux/fsfwconfig/OBSWConfig.h.in | 1 + linux/obc/CMakeLists.txt | 3 +- linux/obc/PapbVcInterface.cpp | 104 +++ linux/obc/PapbVcInterface.h | 106 +++ linux/obc/Ptme.cpp | 68 ++ linux/obc/Ptme.h | 84 +++ linux/obc/PtmeConfig.h | 26 + linux/obc/PtmeIF.h | 28 + linux/obc/VcInterfaceIF.h | 26 + mission/tmtc/CCSDSHandler.cpp | 605 ++++++++++++++++++ mission/tmtc/CCSDSHandler.h | 215 +++++++ mission/utility/TmFunnel.cpp | 7 + 18 files changed, 1312 insertions(+), 6 deletions(-) rename linux/{obc => archive/tmtc}/CCSDSIPCoreBridge.cpp (98%) rename linux/{obc => archive/tmtc}/CCSDSIPCoreBridge.h (100%) create mode 100644 linux/obc/PapbVcInterface.cpp create mode 100644 linux/obc/PapbVcInterface.h create mode 100644 linux/obc/Ptme.cpp create mode 100644 linux/obc/Ptme.h create mode 100644 linux/obc/PtmeConfig.h create mode 100644 linux/obc/PtmeIF.h create mode 100644 linux/obc/VcInterfaceIF.h create mode 100644 mission/tmtc/CCSDSHandler.cpp create mode 100644 mission/tmtc/CCSDSHandler.h diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index bdad3dac..ba98991c 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -1,3 +1,4 @@ +#include #include "ObjectFactory.h" #include "OBSWConfig.h" #include "devConf.h" @@ -23,8 +24,6 @@ #include "linux/devices/SusHandler.h" #include "linux/csp/CspCookie.h" #include "linux/csp/CspComIF.h" -#include "linux/obc/CCSDSIPCoreBridge.h" - #include "mission/core/GenericFactory.h" #include "mission/devices/PDU1Handler.h" #include "mission/devices/PDU2Handler.h" @@ -83,6 +82,9 @@ #include "linux/boardtest/LibgpiodTest.h" #endif +#include +#include + ResetArgs resetArgsGnss0; ResetArgs resetArgsGnss1; @@ -171,6 +173,26 @@ void ObjectFactory::produce(void* args){ #endif /* TE7020 != 0 */ +#if OBSW_USE_PTME_IP_CORE == 1 + GpioCookie* gpioCookiePtmeIp = new GpioCookie; + GpiodRegular* vc0PapbBusyN = new GpiodRegular(std::string("gpiochip0"), 0, std::string("PAPBBusy_N")); + gpioCookiePtmeIp->addGpio(gpioIds::PAPB_BUSY_N, papbBusyN); + GpiodRegular* vc0PapbEmpty = new GpiodRegular(st_d::string("gpiochip0"), 1, + std::string("PAPBEmpty_VC0")); + gpioCookiePtmeIp->addGpio(gpioIds::PAPB_EMPTY, papbEmpty); + gpioComIF->addGpios(gpioCookiePtmeIp); + PapbVcInterface* vc0 = new PapbVcInterface(objects::PAPB_VC0, gpioComIF, ) + Ptme* ptme = new Ptme(objects::PTME); + ptme->addVcInterface(0, vc0); + ptme->addVcInterface(1, vc1); + ptme->addVcInterface(2, vc2); + ptme->addVcInterface(3, vc3); + + new CCSDSIPCoreBridge(objects::CCSDS_IP_CORE_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR, + objects::TM_STORE, objects::TC_STORE, gpioComIF, std::string("/dev/uio0"), + gpioIds::PAPB_BUSY_N, gpioIds::PAPB_EMPTY); +#endif /* OBSW_USE_TMTC_IP_CORE_BRIDGE == 1 */ + #if OBSW_USE_TMTC_TCP_BRIDGE == 0 auto udpBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); @@ -846,10 +868,10 @@ void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) { #if BOARD_TE0720 == 1 && OBSW_TEST_CCSDS_BRIDGE == 1 GpioCookie* gpioCookieCcsdsIp = new GpioCookie; - GpiodRegular* papbBusyN = new GpiodRegular(std::string("gpiochip0"), 0, std::string("PAPBBusy_N")); + GpiodRegular* papbBusyN = new GpiodRegular(std::string("gpiochip0"), 0, std::string("PAPBBusy_VC0")); gpioCookieCcsdsIp->addGpio(gpioIds::PAPB_BUSY_N, papbBusyN); GpiodRegular* papbEmpty = new GpiodRegular(std::string("gpiochip0"), 1, - std::string("Chip Select Sus Sensor")); + std::string("PAPBEmpty_VC0")); gpioCookieCcsdsIp->addGpio(gpioIds::PAPB_EMPTY, papbEmpty); gpioComIF->addGpios(gpioCookieCcsdsIp); diff --git a/common/config/commonClassIds.h b/common/config/commonClassIds.h index 793cb1ba..71a7d312 100644 --- a/common/config/commonClassIds.h +++ b/common/config/commonClassIds.h @@ -19,6 +19,7 @@ enum commonClassIds: uint8_t { PLOC_SUPERVISOR_HANDLER, //PLSV SUS_HANDLER, //SUSS CCSDS_IP_CORE_BRIDGE, //IPCI + PTME, //PTME PLOC_UPDATER, //PLUD GOM_SPACE_HANDLER, //GOMS PLOC_MEMORY_DUMPER, //PLMEMDUMP diff --git a/common/config/commonConfig.h.in b/common/config/commonConfig.h.in index 52b5dd45..55af54e3 100644 --- a/common/config/commonConfig.h.in +++ b/common/config/commonConfig.h.in @@ -6,5 +6,12 @@ // Use TCP instead of UDP for the TMTC bridge. This allows using the TMTC client locally // because UDP packets are not allowed in the VPN #define OBSW_USE_TMTC_TCP_BRIDGE 1 +// This will cause the OBSW to initialize the TMTC bridge responsible for exchanging data with the +// CCSDS IP Cores. +#define OBSW_USE_TMTC_IP_CORE_BRIDGE 0 +// Set to 1 if all telemetry should be sent to the PTME IP Core +#define OBSW_TM_TO_PTME 0 +// Set to 1 if telecommands are received via the PDEC IP Core +#define OBSW_TC_FROM_PDEC 0 #endif /* COMMON_CONFIG_COMMONCONFIG_H_ */ diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index e44e0a1a..5fc61bd4 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -11,6 +11,11 @@ enum commonObjects: uint32_t { TMTC_BRIDGE = 0x50000300, TMTC_POLLING_TASK = 0x50000400, FILE_SYSTEM_HANDLER = 0x50000500, + PTME = 0x50000600, + PAPB_VC0 = 0x50000700, + PAPB_VC0 = 0x500007001, + PAPB_VC0 = 0x500007002, + PAPB_VC0 = 0x500007003, /* 0x43 ('C') for Controllers */ THERMAL_CONTROLLER = 0x43400001, diff --git a/linux/obc/CCSDSIPCoreBridge.cpp b/linux/archive/tmtc/CCSDSIPCoreBridge.cpp similarity index 98% rename from linux/obc/CCSDSIPCoreBridge.cpp rename to linux/archive/tmtc/CCSDSIPCoreBridge.cpp index fe5a7007..982f7fc2 100644 --- a/linux/obc/CCSDSIPCoreBridge.cpp +++ b/linux/archive/tmtc/CCSDSIPCoreBridge.cpp @@ -1,7 +1,7 @@ #include #include -#include +#include CCSDSIPCoreBridge::CCSDSIPCoreBridge(object_id_t objectId, object_id_t tcDestination, object_id_t tmStoreId, object_id_t tcStoreId, LinuxLibgpioIF* gpioComIF, diff --git a/linux/obc/CCSDSIPCoreBridge.h b/linux/archive/tmtc/CCSDSIPCoreBridge.h similarity index 100% rename from linux/obc/CCSDSIPCoreBridge.h rename to linux/archive/tmtc/CCSDSIPCoreBridge.h diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index dc397635..83564c0c 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -96,6 +96,7 @@ namespace config { /* Add mission configuration flags here */ static constexpr uint32_t OBSW_FILESYSTEM_HANDLER_QUEUE_SIZE = 50; static constexpr uint32_t PLOC_UPDATER_QUEUE_SIZE = 50; +static constexpr uint8_t NUMBER_OF_VIRTUAL_CHANNELS = 4; #ifdef __cplusplus } diff --git a/linux/obc/CMakeLists.txt b/linux/obc/CMakeLists.txt index 79d9ba9b..315a0d33 100644 --- a/linux/obc/CMakeLists.txt +++ b/linux/obc/CMakeLists.txt @@ -1,5 +1,6 @@ target_sources(${TARGET_NAME} PUBLIC - CCSDSIPCoreBridge.cpp + PapbVcInterface.cpp + Ptme.cpp ) diff --git a/linux/obc/PapbVcInterface.cpp b/linux/obc/PapbVcInterface.cpp new file mode 100644 index 00000000..736c8b24 --- /dev/null +++ b/linux/obc/PapbVcInterface.cpp @@ -0,0 +1,104 @@ +#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), uioVcInterface(uioVcInterface), papbBusyId( + papbBusyId), papbEmptyId(papbEmptyId), vcOffset(vcOffset) { +} + +PapbVcInterface::~PapbVcInterface() { +} + + +void PapbVcInterface::setRegisterAddress(uint32_t* ptmeBaseAddress) { + vcBaseReg = ptmeBaseAddress + vcOffset; +} + +ReturnValue_t PapbVcInterface::write(const uint8_t * data, size_t dataLen) { + + if(pollPapbBusySignal() == RETURN_OK) { + startPacketTransfer(); + } + + for(size_t idx = 0; idx < dataLen; idx++) { + if(pollPapbBusySignal() == RETURN_OK) { + *(vcBaseReg + DATA_REG_OFFSET) = static_cast(*(data + idx)); + } + else { + sif::warning << "PapbVcInterface::sendTm: Only written " << idx - 1 << " of " + << dataLen << " data" << std::endl; + return RETURN_FAILED; + } + } + + if(pollPapbBusySignal() == RETURN_OK) { + endPacketTransfer(); + } + return RETURN_OK; +} + +void PapbVcInterface::startPacketTransfer() { + *vcBaseReg = CONFIG_START; +} + +void PapbVcInterface::endPacketTransfer() { + *vcBaseReg = CONFIG_END; +} + +ReturnValue_t PapbVcInterface::pollPapbBusySignal() { + 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::debug << "PapbVcInterface::pollPapbBusySignal: Failed to read papb busy signal" + << std::endl; + return RETURN_FAILED; + } + if (!papbBusyState) { + sif::debug << "PapbVcInterface::pollPapbBusySignal: PAPB busy" << std::endl; + return PAPB_BUSY; + } + + return RETURN_OK; +} + +void PapbVcInterface::isVcInterfaceBufferEmpty() { + ReturnValue_t result = RETURN_OK; + int papbEmptyState = 1; + + result = gpioComIF->readGpio(papbEmptyId, &papbEmptyState); + + if (result != RETURN_OK) { + sif::debug << "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]; + + /** Fill one test packet */ + for(int idx = 0; idx < 1105; idx++) { + testPacket[idx] = static_cast(idx & 0xFF); + } + + ReturnValue_t result = sendTm(testPacket, 1105); + if(result != RETURN_OK) { + return result; + } + + return RETURN_OK; +} diff --git a/linux/obc/PapbVcInterface.h b/linux/obc/PapbVcInterface.h new file mode 100644 index 00000000..05947ac6 --- /dev/null +++ b/linux/obc/PapbVcInterface.h @@ -0,0 +1,106 @@ +#ifndef LINUX_OBC_PAPBVCINTERFACE_H_ +#define LINUX_OBC_PAPBVCINTERFACE_H_ + +#include "OBSWConfig.h" +#include "linux/obc/VcInterfaceIF.h" +#include +#include +#include +#include "fsfw/returnvalues/HasReturnvaluesIF.h" + +/** + * @brief This class handles the transmission of data to a virtual channel of the PTME IP Core + * via the PAPB interface. + * + * @author J. Meier + */ +class PapbVcInterface : VcInterfaceIF, 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. + * @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). + */ + PapbVcInterface(object_id_t objectId, LinuxLibgpioIF* gpioComIF, gpioId_t papbBusyId, + gpioId_t papbEmptyId, uint32_t vcOffset); + virtual ~PapbVcInterface(); + +private: + + static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_IP_CORE_BRIDGE; + + static const ReturnValue_t PAPB_BUSY = MAKE_RETURN_CODE(0xA0); + + /** + * Configuration bits: + * bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00 + * bit[2]: Set this bit to 1 to abort a transfered packet + * bit[3]: Signals to VcInterface the start of a new telemetry packet + */ + static const uint32_t CONFIG_START = 0x8; + + /** + * Writing this word to the VcInterface base address signals to the virtual channel interface + * that a complete tm packet has been transferred. + */ + static const uint32_t CONFIG_END = 0x0; + + /** + * Writing to this offset within the memory space of a virtual channel will insert data for + * encoding to the external buffer memory of the PTME IP Core. + * The address offset is 0x400 (= 4 * 256) + */ + static const int DATA_REG_OFFSET = 256; + + LinuxLibgpioIF* gpioComIF = nullptr; + + /** Pulled to low when virtual channel not ready to receive data */ + gpioId_t papbBusyId = gpio::NO_GPIO; + /** High when external buffer memory of virtual channel is empty */ + gpioId_t papbEmptyId = gpio::NO_GPIO; + + uint32_t* vcBaseReg = nullptr; + + uint32_t vcOffset = 0; + + /** + * @brief This function sends the config byte to the virtual channel of the PTME IP Core + * to initiate a packet transfer. + */ + void startPacketTransfer(); + + /** + * @brief This function sends the config byte to the virtual channel interface of the PTME + * IP Core to signal the end of a packet transfer. + */ + void endPacketTransfer(); + + /** + * @brief This function reads the papb busy signal indicating whether the virtual channel + * interface is ready to receive more data or not. PAPB is ready when + * PAPB_Busy_N == '1'. + * + * @return RETURN_OK when ready to receive data else PAPB_BUSY. + */ + ReturnValue_t pollPapbBusySignal(); + + /** + * @brief This function can be used for debugging to check whether there are packets in + * the packet buffer of the virtual channel or not. + */ + void isVcInterfaceBufferEmpty(); + + /** + * @brief This function sends a complete telemetry transfer frame data field (1105 bytes) + * to the papb interface of the PTME IP Core. Can be used to test the implementation. + */ + ReturnValue_t sendTestFrame(); +}; + +#endif /* LINUX_OBC_PAPBVCINTERFACE_H_ */ diff --git a/linux/obc/Ptme.cpp b/linux/obc/Ptme.cpp new file mode 100644 index 00000000..480b5836 --- /dev/null +++ b/linux/obc/Ptme.cpp @@ -0,0 +1,68 @@ +#include +#include + +#include +#include "fsfw/serviceinterface/ServiceInterface.h" + +Ptme::Ptme(object_id_t objectId) : + SystemObject(objectId) { +} + +Ptme::~Ptme() { +} + +ReturnValue_t Ptme::initialize() { + ReturnValue_t result = TmTcBridge::initialize(); + + 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)); + + if (ptmeBaseAddress == MAP_FAILED) { + sif::error << "Ptme::initialize: Failed to map uio address" << std::endl; + return RETURN_FAILED; + } + + return result; +} + +ReturnValue_t Ptme::writeToVc(uint8_t vcId, const uint8_t * data, size_t dataLen) { + ReturnValue_t result = RETURN_OK; + VcInterfaceMapIter vcInterfaceMapIter = vcInterfaceMap.find(vcId); + if (vcInterfaceMapIter == vcInterfaceMap.end()) { + sif::warning << "Ptme::writeToVc: No virtual channel interface found for the virtual " + "channel with id " << static_cast(vcId) << std::endl; + return UNKNOWN_VC_ID; + } + result = vcInterfaceMapIter->second.write(data, size); + return result; +} + +void Ptme::addVcInterface(VcId_t vcId, VcInterfaceIF* vc) { + + if (vcId > config::MAX_VIRTUAL_CHANNEL_ID) { + sif::warning << "Ptme::addVcInterface: Invalid virtual channel ID" << std::endl; + return; + } + + if (vc == nullptr) { + sif::warning << "Ptme::addVcInterface: Invalid virtual channel interface" << std::endl; + return; + } + + auto status = vcInterfaceMap.emplace(vcId, vc); + if (status.second == false) { + sif::warning << "Ptme::addVcInterface: Failed to add virtual channel interface to " + "virtual channel map" << std::endl; + return; + } +} diff --git a/linux/obc/Ptme.h b/linux/obc/Ptme.h new file mode 100644 index 00000000..6ef118ab --- /dev/null +++ b/linux/obc/Ptme.h @@ -0,0 +1,84 @@ +#ifndef LINUX_OBC_PTME_H_ +#define LINUX_OBC_PTME_H_ + +#include "OBSWConfig.h" +#include "linux/obc/PtmeIF.h" +#include "linux/obc/VcInterfaceIF.h" +#include +#include +#include "fsfw/returnvalues/HasReturnvaluesIF.h" + +#include +#include + +/** + * @brief This class handles the interfacing to the telemetry (PTME) IP core responsible for the + * encoding of telemetry packets according to the CCSDS standards CCSDS 131.0-B-3 (TM Synchro- + * nization and channel coding) and CCSDS 132.0-B-2 (TM Space Data Link Protocoll). + * The IP cores are implemented on the programmable logic and are accessible through the + * linux UIO driver. + */ +class Ptme : PtmeIF, SystemObject, HasReturnvaluesIF { +public: + /** + * @brief Constructor + * + * @param objectId + */ + Ptme(object_id_t objectId); + virtual ~Ptme(); + + ReturnValue_t initialize() override; + ReturnValue_t writeToVc(uint8_t vcId, uint8_t* data, size_t size) override; + + /** + * @brief This function adds the reference to a virtual channel interface to the vcInterface + * map. + */ + void addVcInterface(VcId_t vcId, VcInterfaceIF* vc); + +private: + + static const uint8_t INTERFACE_ID = CLASS_ID::PTME; + + static const ReturnValue_t UNKNOWN_VC_ID = MAKE_RETURN_CODE(0xA0); + + + /** Size of mapped address space */ + static const int MAP_SIZE = 0x40000; + + /** + * Configuration bits: + * bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00 + * bit[2]: Set this bit to 1 to abort a transfered packet + * bit[3]: Signals to PTME the start of a new telemetry packet + */ + static const uint32_t PTME_CONFIG_START = 0x8; + + /** + * Writing this word to the ptme base address signals to the PTME that a complete tm packet has + * been transferred. + */ + static const uint32_t PTME_CONFIG_END = 0x0; + + /** + * Writing to this offset within the PTME memory space will insert data for encoding to the + * PTME IP core. + * The address offset is 0x400 (= 4 * 256) + */ + static const int PTME_DATA_REG_OFFSET = 256; + + /** The file descriptor of the UIO driver */ + int fd; + + uint32_t* ptmeBaseAddress = nullptr; + + using VcId_t = uint8_t; + + using VcInterfaceMap = std::unordered_map; + using VcInterfaceMapIter = VcInterfaceMap::iterator; + + VcInterfaceMap vcInterfaceMap; +}; + +#endif /* LINUX_OBC_PTME_H_ */ diff --git a/linux/obc/PtmeConfig.h b/linux/obc/PtmeConfig.h new file mode 100644 index 00000000..34fd8876 --- /dev/null +++ b/linux/obc/PtmeConfig.h @@ -0,0 +1,26 @@ +#ifndef LINUX_OBC_PTMECONFIG_H_ +#define LINUX_OBC_PTMECONFIG_H_ + +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include + + +/** + * @brief Configuration parameters derived from FPGA design and device tree. + * + * @author J. Meier + */ +namespace PtmeConfig { + /** + * Offset of virtual channels mapped into address space + * 0x10000 = (0x4000 * 4) + */ + static const uint32_t VC0_OFFSETT = 0; + static const uint32_t VC1_OFFSETT = 0x4000; + static const uint32_t VC2_OFFSETT = 0x8000; + static const uint32_t VC3_OFFSETT = 0xC000; + + static const std::string UIO_DEVICE_FILE = "/dev/uio0"; +}; + +#endif /* LINUX_OBC_PTMECONFIG_H_ */ diff --git a/linux/obc/PtmeIF.h b/linux/obc/PtmeIF.h new file mode 100644 index 00000000..c89d25f0 --- /dev/null +++ b/linux/obc/PtmeIF.h @@ -0,0 +1,28 @@ +#ifndef LINUX_OBC_PTMEIF_H_ +#define LINUX_OBC_PTMEIF_H_ + +#include "fsfw/returnvalues/HasReturnvaluesIF.h" + + +/** + * @brief Interface class for managing the PTME IP Core implemented in the programmable logic. + * + * @details PTME IP Core: https://www.esa.int/Enabling_Support/Space_Engineering_Technology/ + * Microelectronics/PTME + * @author J. Meier + */ +class PtmeIF { +public: + virtual ~PtmeIF(){}; + + /** + * @brief Implements to function to write to a specific virtual channel. + * + * @param vcId Virtual channel to write to + * @param data Pointer to buffer holding the data to write + * @param size Number of bytes to write + */ + virtual ReturnValue_t writeToVc(uint8_t vcId, uint8_t* data, size_t size) = 0; +}; + +#endif /* LINUX_OBC_PTMEIF_H_ */ diff --git a/linux/obc/VcInterfaceIF.h b/linux/obc/VcInterfaceIF.h new file mode 100644 index 00000000..ce643b48 --- /dev/null +++ b/linux/obc/VcInterfaceIF.h @@ -0,0 +1,26 @@ +#ifndef LINUX_OBC_VCINTERFACEIF_H_ +#define LINUX_OBC_VCINTERFACEIF_H_ + +#include "fsfw/returnvalues/HasReturnvaluesIF.h" + +/** + * @brief Interface class for managing different virtual channels of the PTME IP core implemented + * in the programmable logic. + * + * @author J. Meier + */ +class VcInterfaceIF { +public: + virtual ~VcInterfaceIF(){}; + + /** + * @brief Implememts the functionality to write data in the virtual channel of the PTME IP + * Core. + * + * @param data Pointer to buffer holding the data to write + * @param size Number of bytes to write + */ + virtual ReturnValue_t write(uint8_t* data, size_t size) = 0; +}; + +#endif /* LINUX_OBC_VCINTERFACEIF_H_ */ diff --git a/mission/tmtc/CCSDSHandler.cpp b/mission/tmtc/CCSDSHandler.cpp new file mode 100644 index 00000000..38428c14 --- /dev/null +++ b/mission/tmtc/CCSDSHandler.cpp @@ -0,0 +1,605 @@ +/******************************* + * FLP Flight Software Framework (FSFW) + * (c) 2016 IRS, Uni Stuttgart + *******************************/ +/* + * CCSDSHandler.cpp + * + * Created on: Feb 9, 2012 + * Author: baetz + */ +#include +#include +#include +#include +#include +#include +#include +#include + +const float CCSDSHandler::DEFAULT_RATES[BoardHandler::USED_VIRTUAL_CHANNELS_PER_BOARD] = + { CCSDSHandler::DEFAULT_BYTES_PER_SECOND, CCSDSHandler::DEFAULT_BYTES_PER_SECOND, + CCSDSHandler::DEFAULT_BYTES_PER_SECOND, CCSDSHandler::DEFAULT_BYTES_PER_SECOND }; + +CCSDSHandler::CCSDSHandler(object_id_t setObjectId, uint8_t setSwitchId1, + uint8_t setSwitchId2, object_id_t setChannel, uint16_t setSCID, + BoardHandler::DataPoolIds setPool) : + SystemObject(setObjectId), tmPartHealth(setObjectId + 1, 0), commandQueue(), state( + STATE_IDLE), commState(SEND_WRITE), mode(MODE_OFF), submode( + SUBMODE_NONE), boardHandler((uint8_t*) frameBuffer, + sizeof(frameBuffer), setSCID, setPool), dataLinkLayer( + this->frameBuffer, boardHandler.getClcw(), 0, setSCID), frameLength( + 0), channelId(setChannel), memoryHelper(this, &commandQueue), pendingWrite( + false), pendingRead(false), modeHelper(this), healthHelper(this, + setObjectId), parameterHelper(this), powerSwitcher(setSwitchId1, + setSwitchId2), switchOffWasReported(false), fdir(setObjectId, + setChannel) { + memset(this->frameBuffer, 0, sizeof(frameBuffer)); + DataSet mySet; + PoolVector rateRatio( + datapool::DATA_RATE_ASSIGN, &mySet, PoolVariableIF::VAR_WRITE); + for (uint8_t i = 0; i < BoardHandler::USED_VIRTUAL_CHANNELS_PER_BOARD; + ++i) { + virtualChannels[i] = new VCGeneration(i, + BoardHandler::TM_PACKETS_PER_CALL_PER_CHANNEL); + rateLimitOverload[i] = 0; + rateRatio[i] = DEFAULT_RATES[i]; + } + mySet.commit(PoolVariableIF::VALID); + //Set real-time channel to high responsiveness. + virtualChannels[0]->setIdlePacketIntervalMs( + VCGeneration::IDLE_INTERVAL_RT_CHANNEL); +} + +CCSDSHandler::~CCSDSHandler() { + for (uint8_t i = 0; i < BoardHandler::USED_VIRTUAL_CHANNELS_PER_BOARD; + ++i) { + delete virtualChannels[i]; + } +} + +void CCSDSHandler::printFrameBuffer(void) { + debug << "frame_buffer contains: " << std::endl; + for (uint32_t i = 0; i < this->frameLength; ++i) { + debug << "frame_buffer[" << std::dec << i << "]: " << std::hex + << std::showbase << (uint16_t) this->frameBuffer[i] << std::dec + << std::endl; + } +} + +ReturnValue_t CCSDSHandler::packetProcessing(void) { + rateSet.read(); + const float* usedRateRatios = NULL; + if (rateSet.dataRates.isValid()) { + usedRateRatios = rateSet.dataRates.value; + } else { + usedRateRatios = DEFAULT_RATES; + } + for (uint8_t i = 0; i < BoardHandler::USED_VIRTUAL_CHANNELS_PER_BOARD; + ++i) { + //Set current cycle Limit first + uint32_t newLimit = (usedRateRatios[i]) / SENDS_PER_SECOND; + if (newLimit <= rateLimitOverload[i]) { + //Calculate new overload. + rateLimitOverload[i] -= newLimit; + //Use newLimit as current rate, VC is utilized to its current limit. + rateSet.dataRate[i] = usedRateRatios[i]; //equal to newLimit * SENDS_PER_SECOND + //Don't send anything new. + continue; + } + newLimit -= rateLimitOverload[i]; + virtualChannels[i]->tmSendLimitPerCycle = newLimit; + //Send new packets. + uint32_t tempRate = virtualChannels[i]->packetProcessing(); + if (tempRate > virtualChannels[i]->tmSendLimitPerCycle) { + rateLimitOverload[i] = tempRate - virtualChannels[i]->tmSendLimitPerCycle; + //VC is fully utilized, but not more. Overload will be accounted for in next cycles. + rateSet.dataRate[i] = virtualChannels[i]->tmSendLimitPerCycle * SENDS_PER_SECOND; + } else { + //Data rate extended to a Bytes/s range. Filtering is performed in controller. + rateSet.dataRate[i] = tempRate * SENDS_PER_SECOND; + rateLimitOverload[i] = 0; + } + } + rateSet.commit(PoolVariableIF::VALID); + return RETURN_OK; +} + +ReturnValue_t CCSDSHandler::packetProcessingCheck(void) { + ReturnValue_t status = RETURN_FAILED; + for (uint8_t vc = 0; vc < BoardHandler::USED_VIRTUAL_CHANNELS_PER_BOARD; + ++vc) { + status = this->virtualChannels[vc]->packetProcessingCheck(); + if (status != RETURN_OK) { + error << "CCSDSHandler " << std::hex << this->getObjectId() + << " ::packetProcessingCheck: Error on VC " << (uint16_t) vc + << ". Error code: " << status << std::dec << std::endl; + } + } + return RETURN_OK; +} + +ReturnValue_t CCSDSHandler::performOperation(void) { + readCommandQueue(); + return RETURN_OK; +} + +void CCSDSHandler::searchFrame() { + frameLength = this->boardHandler.findFrame(); + while (frameLength != 0) { + ReturnValue_t frame_status = this->dataLinkLayer.processFrame( + frameLength); + if (frame_status != RETURN_OK) { + triggerEvent(DataLinkLayer::FRAME_PROCESSING_FAILED, frame_status, + 0); + } + boardHandler.resetFrameBuffer(); + frameLength = boardHandler.findFrame(); + } +} + +ReturnValue_t CCSDSHandler::initialize() { + PtmeIF *ptme = objectManager->get(ptmeId); + if (ptme == nullptr) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } + status = boardHandler.initialize(channel); + if (status != RETURN_OK) { + return status; + } + status = modeHelper.initialize(); + if (status != RETURN_OK) { + return status; + } + status = healthHelper.initialize(); + if (status != HasReturnvaluesIF::RETURN_OK) { + return status; + } + status = memoryHelper.initialize(); + if (status != HasReturnvaluesIF::RETURN_OK) { + return status; + } + status = parameterHelper.initialize(); + if (status != HasReturnvaluesIF::RETURN_OK) { + return status; + } + status = powerSwitcher.initialize(objects::PCDU_HANDLER); + if (status != HasReturnvaluesIF::RETURN_OK) { + return status; + } + StorageManagerIF* tmStore = objectManager->get( + objects::TM_STORE); + status = dataLinkLayer.initialize(); + if ((tmStore != NULL) && status == RETURN_OK) { + status = RETURN_OK; + for (uint8_t i = 0; i < BoardHandler::USED_VIRTUAL_CHANNELS_PER_BOARD; + ++i) { +// this->virtualChannels[i] = objectManager->get( +// objects::CCSDS_VC_BASE + i); + if (this->virtualChannels[i] != NULL) { + this->virtualChannels[i]->setPacketStore(tmStore); + this->virtualChannels[i]->setBoardHandler(&this->boardHandler); + } else { + status = RETURN_FAILED; + } + } + } else { + status = RETURN_FAILED; + error << "CCSDSHandler " << std::hex << this->getObjectId() << std::dec + << " ::CCSDSHandler: Configuration failed." << std::endl; + } + status = fdir.initialize(); + if (status != HasReturnvaluesIF::RETURN_OK) { + return status; + } + return status; +} + +void CCSDSHandler::readCommandQueue(void) { + CommandMessage commandMessage; + ReturnValue_t result = RETURN_FAILED; + while (commandQueue.receiveMessage(&commandMessage) == RETURN_OK) { + + result = parameterHelper.handleParameterMessage(&commandMessage); + if (result == RETURN_OK) { + return; + } + CommandMessage reply; + reply.setReplyRejected(CommandMessage::UNKNOW_COMMAND, + commandMessage.getCommand()); + commandQueue.reply(&reply); + } +} + +MessageQueueId_t CCSDSHandler::getCommandQueue() const { + return commandQueue.getId(); +} + +void CCSDSHandler::flushTmChannels() { + for (uint8_t i = 0; i < BoardHandler::USED_VIRTUAL_CHANNELS_PER_BOARD; + ++i) { + virtualChannels[i]->flush(); + } +} + +ReturnValue_t CCSDSHandler::handleMemoryLoad(uint32_t address, + const uint8_t* data, uint32_t size, uint8_t** dataPointer) { + if (size != 4) { + return INVALID_SIZE; + } + ReturnValue_t result = boardHandler.manualWriteToRegister(address, data); + if (result == RETURN_OK) { + pendingWrite = true; + return DO_IT_MYSELF; + } + return result; +} + +ReturnValue_t CCSDSHandler::handleMemoryDump(uint32_t address, uint32_t size, + uint8_t** dataPointer, uint8_t* dumpTarget) { + if (size != 4) { + return INVALID_SIZE; + } + ReturnValue_t result = boardHandler.sendRegisterReadCommand(address); + if (result == RETURN_OK) { + pendingRead = true; + return DO_IT_MYSELF; + } + return result; +} + +ReturnValue_t CCSDSHandler::checkModeCommand(Mode_t commandedMode, + Submode_t commandedSubmode, uint32_t* msToReachTheMode) { + if (state != STATE_IDLE) { + return IN_TRANSITION; + } + switch (commandedMode) { + case MODE_ON: + if ((commandedSubmode == SUBMODE_ACTIVE) + || (commandedSubmode == SUBMODE_PASSIVE)) { + return RETURN_OK; + } else { + return INVALID_SUBMODE; + } + break; + case MODE_OFF: + if (commandedSubmode == SUBMODE_NONE) { + return RETURN_OK; + } else { + return INVALID_SUBMODE; + } + default: + return INVALID_MODE; + } +} + +void CCSDSHandler::startTransition(Mode_t commandedMode, + Submode_t commandedSubmode) { + if (commandedMode == mode) { + if (mode == MODE_ON) { + state = STATE_SELECT_SUBMODE; + } else { + //Turn off switch again anyway + state = STATE_TURN_OFF; + } + } else { + switch (commandedMode) { + case MODE_ON: + state = STATE_TURN_ON; + break; + case MODE_OFF: + state = STATE_TURN_OFF; + break; + default: + //Error case. Cannot happen? + error << "CCSDSHandler::startTransition: Invalid commanded mode: " + << commandedMode << std::endl; + return; + } + } + triggerEvent(CHANGING_MODE, commandedMode, commandedSubmode); +} + +void CCSDSHandler::getMode(Mode_t* modeReturn, Submode_t* submodeReturn) { + *modeReturn = mode; + *submodeReturn = submode; +} + +void CCSDSHandler::setToExternalControl() { + healthHelper.setHealth(EXTERNAL_CONTROL); +} + +void CCSDSHandler::announceMode(bool recursive) { + triggerEvent(MODE_INFO, mode, submode); +} + +void CCSDSHandler::setParentQueue(MessageQueueId_t parentQueueId) { + modeHelper.setParentQueue(parentQueueId); + healthHelper.setParentQeueue(parentQueueId); + tmPartHealth.setParentQueue(parentQueueId); +} + +void CCSDSHandler::doStateMachine() { + ReturnValue_t status = RETURN_FAILED; + powerSwitcher.doStateMachine(); + switch (state) { + case STATE_IDLE: + //Do nothing? Do perform operation stuff? + break; + case STATE_TURN_ON: + powerSwitcher.turnOn(); + modeHelper.startTimer(powerSwitcher.getSwitchDelay()); + state = STATE_WAIT_ON; + break; + case STATE_WAIT_ON: + if (powerSwitcher.checkSwitchState() == RETURN_OK) { + modeHelper.startTimer(LINK_UP_DELAY_MS); + state = STATE_WAIT_LINK; + } + if (boardHandler.checkChannel() == RETURN_OK) { + boardHandler.startStateTranstion(); + state = STATE_INITIALIZE_BOARD; + } else { + if (modeHelper.isTimedOut()) { + triggerEvent(MODE_TRANSITION_FAILED, + PowerSwitchIF::SWITCH_TIMEOUT, state); + setMode(MODE_OFF, SUBMODE_NONE); + } + } + break; + case STATE_WAIT_LINK: + if (boardHandler.checkAndResetChannel() == RETURN_OK) { + boardHandler.startStateTranstion(); + state = STATE_INITIALIZE_BOARD; + } else { + if (modeHelper.isTimedOut()) { + triggerEvent(MODE_TRANSITION_FAILED, DeviceHandlerIF::TIMEOUT, + state); + setMode(MODE_OFF, SUBMODE_NONE); + } + } + break; + case STATE_INITIALIZE_BOARD: + status = boardHandler.initializeBoard(); + switch (status) { + case RETURN_OK: + state = STATE_SELECT_SUBMODE; + break; + case BoardHandler::IN_TRANSITION: + //cannot last forever, so just wait. + break; + default: + triggerEvent(MODE_TRANSITION_FAILED, status, state); + state = STATE_TURN_OFF; + break; + } + break; + case STATE_SELECT_SUBMODE: + boardHandler.startStateTranstion(); + if (modeHelper.commandedSubmode == SUBMODE_PASSIVE) { + state = STATE_WAIT_SUBMODE_PASSIVE; + } else { + state = STATE_WAIT_SUBMODE_ACTIVE; + } + break; + case STATE_WAIT_SUBMODE_PASSIVE: + //Just one wait cycle to get rid of pending TM. + state = STATE_DO_PASSIVATE; + break; + case STATE_DO_PASSIVATE: + status = boardHandler.tmPassivate(); + switch (status) { + case RETURN_OK: + setMode(MODE_ON, SUBMODE_PASSIVE); + break; + case BoardHandler::IN_TRANSITION: + //cannot last forever, so just wait. + break; + default: + //If it comes here and fails then, there might be something wrong with the board. + triggerEvent(MODE_TRANSITION_FAILED, status, state); + state = STATE_TURN_OFF; + break; + } + break; + case STATE_WAIT_SUBMODE_ACTIVE: + status = boardHandler.tmActivate(); + switch (status) { + case RETURN_OK: + setMode(MODE_ON, SUBMODE_ACTIVE); + break; + case BoardHandler::IN_TRANSITION: + //cannot last forever, so just wait. + break; + default: + //If it comes here and fails then, there might be something wrong with the board. + triggerEvent(MODE_TRANSITION_FAILED, status, state); + state = STATE_TURN_OFF; + break; + } + break; + case STATE_TURN_OFF: + //Passivate first. Mainly optimization for System Testbed. + boardHandler.startStateTranstion(); + state = STATE_DO_PASSIVATE_OFF; + //No break + case STATE_DO_PASSIVATE_OFF: + status = boardHandler.tmPassivate(); + switch (status) { + case RETURN_OK: + state = STATE_TURN_SWITCH_OFF; + break; + case BoardHandler::IN_TRANSITION: + //cannot last forever, so just wait. + break; + default: + //If it comes here and fails then, there might be something wrong with the board. + //Just turn it off. + state = STATE_TURN_SWITCH_OFF; + break; + } + break; + case STATE_TURN_SWITCH_OFF: + powerSwitcher.turnOff(); + modeHelper.startTimer(powerSwitcher.getSwitchDelay()); + state = STATE_WAIT_OFF; + break; + case STATE_WAIT_OFF: + if ((boardHandler.checkAndResetChannel() == RMAPChannelIF::LINK_DOWN) + || (powerSwitcher.checkSwitchState() == RETURN_OK)) { + setMode(MODE_OFF, SUBMODE_NONE); + state = STATE_IDLE; + } else { + if (modeHelper.isTimedOut()) { + triggerEvent(MODE_TRANSITION_FAILED, status, state); + setMode(mode, submode); + } + } + break; + default: + break; + } +} + +ReturnValue_t CCSDSHandler::addVirtualChannel(uint8_t virtualChannelId, + VirtualChannelReceptionIF* object) { + return this->dataLinkLayer.addVirtualChannel(virtualChannelId, object); +} + +void CCSDSHandler::setMode(Mode_t newMode, Submode_t newSubmode) { + triggerEvent(MODE_INFO, newMode, newSubmode); + if (newMode == MODE_OFF) { + boardHandler.setDataPoolVaraiblesInvalid(); + } + modeHelper.modeChanged(newMode, newSubmode); + state = STATE_IDLE; + mode = newMode; + submode = newSubmode; +} + +Mode_t CCSDSHandler::getMode() const { + return mode; +} + +Submode_t CCSDSHandler::getSubmode() const { + return submode; +} + +MessageQueueId_t CCSDSHandler::getReportReceptionQueue(uint8_t virtualChannel) { + if (virtualChannel < Ptme::NUM_OF_VIRTUAL_CHANNELS) { + return virtualChannels[virtualChannel]->getReportReceptionQueue(); + } else { + sif::debug << "CCSDSHandler::getReportReceptionQueue: Invalid virtual channel requested"; + } +} + +void CCSDSHandler::executeAllWriteCommands() { + ReturnValue_t returnValue = boardHandler.sendWriteCommands(); + if (returnValue != RETURN_OK) { + triggerEvent(DeviceHandlerIF::DEVICE_SENDING_COMMAND_FAILED, + returnValue, 0); + } + if (submode == SUBMODE_ACTIVE) { + returnValue = this->packetProcessing(); + if (returnValue != RETURN_OK) { + triggerEvent(DeviceHandlerIF::DEVICE_SENDING_COMMAND_FAILED, + returnValue, 1); + } + } +} + +void CCSDSHandler::handleAllWriteReplies() { + ReturnValue_t returnValue = boardHandler.getWriteReplys(); + if (returnValue != RETURN_OK) { + triggerEvent(DeviceHandlerIF::DEVICE_SENDING_COMMAND_FAILED, + returnValue, 0); + } + if (pendingWrite) { + memoryHelper.completeLoad(returnValue); + pendingWrite = false; + } + if (submode == SUBMODE_ACTIVE) { + returnValue = packetProcessingCheck(); + } else { + this->flushTmChannels(); + } +} + +void CCSDSHandler::executeAllReadCommands() { + ReturnValue_t returnValue = boardHandler.sendReadCommands(); + if (returnValue != RETURN_OK) { + triggerEvent(DeviceHandlerIF::DEVICE_REQUESTING_REPLY_FAILED, + returnValue, 0); + } +} + +void CCSDSHandler::handleAllReadReplies() { + if ((mode == MODE_ON) && (state == STATE_IDLE)) { + ReturnValue_t returnValue = boardHandler.getReadReplys(); + if (returnValue == RETURN_OK) { + searchFrame(); + } else { + triggerEvent(DeviceHandlerIF::DEVICE_REQUESTING_REPLY_FAILED, + returnValue, 0); + //do nothing. + } + if (pendingRead) { + uint8_t* tempBuffer; + returnValue = boardHandler.getRegisterReadReply(&tempBuffer); + memoryHelper.completeDump(returnValue, tempBuffer, + BoardHandler::REGISTER_LENGTH); + pendingRead = false; + } + } +} + +ReturnValue_t CCSDSHandler::getParameter(uint8_t domainId, uint16_t parameterId, + ParameterWrapper* parameterWrapper, const ParameterWrapper* newValues, + uint16_t startAtIndex) { + ReturnValue_t result = fdir.getParameter(domainId, parameterId, + parameterWrapper, newValues, startAtIndex); + if (result != INVALID_DOMAIN_ID) { + return result; + } + if (domainId != DOMAIN_ID_BASE) { + return INVALID_DOMAIN_ID; + } + switch (parameterId) { + case 0: + parameterWrapper->set(boardHandler.tmPhysicalLayerRegisterValue); + break; + case 1: + parameterWrapper->set(boardHandler.tmCodingSublayerRegisterValue); + break; + default: + return INVALID_MATRIX_ID; + } + return RETURN_OK; +} + +ReturnValue_t CCSDSHandler::setHealth(HealthState health) { + healthHelper.setHealth(health); + return RETURN_OK; +} + +HasHealthIF::HealthState CCSDSHandler::getHealth() { + return healthHelper.getHealth(); +} + +CCSDSHandler::DataRateSet::DataRateSet() : + ControllerSet(), dataRate(datapool::VC_DATA_RATE_RAW, this, + PoolVariableIF::VAR_WRITE), dataRates( + datapool::DATA_RATE_ASSIGN, this, PoolVariableIF::VAR_READ) { +} + +CCSDSHandler::DataRateSet::~DataRateSet() { +} + +void CCSDSHandler::DataRateSet::setToDefault() { + dataRate.value = {0.0, 0.0, 0.0, 0.0}; +} + +void CCSDSHandler::triggerEvent(Event event, uint32_t parameter1, + uint32_t parameter2) { + fdir.triggerEvent(event, parameter1, parameter2); +} diff --git a/mission/tmtc/CCSDSHandler.h b/mission/tmtc/CCSDSHandler.h new file mode 100644 index 00000000..77c8b2c1 --- /dev/null +++ b/mission/tmtc/CCSDSHandler.h @@ -0,0 +1,215 @@ +#ifndef CCSDSHANDLER_H_ +#define CCSDSHANDLER_H_ + +#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface/serviceInterfaceDefintions.h" +#include "fsfw/objectmanager/SystemObject.h" +#include "fsfw/tasks/ExecutableObjectIF.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/parameters/ParameterHelper.h" + +/** + * @brief This class handles the data exchange with the CCSDS IP cores implemented in the + * programmable logic of the Q7S. + * + * @author J. Meier + */ +class CCSDSHandler: public SystemObject, + public ExecutableObjectIF, + public HasModesIF, + public AcceptsTelemetryIF, + public HasReturnvaluesIF, + public ReceivesParameterMessagesIF { +public: + static const uint32_t LINK_UP_DELAY_MS = 2000; //!< The maximum time it takes to reconfigure the CCSDS Board. + static const uint32_t MAX_FRAME_SIZE = 1024; + static const Submode_t SUBMODE_ACTIVE = 1; //!< Submode where the TM part of the board is on. + static const Submode_t SUBMODE_PASSIVE = 0; //!< Submode where the TM part of the board is off. + + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CCSDS_BOARD; + static const Event CCSDS_BOARD_RESET_FAILED = MAKE_EVENT(0, SEVERITY::LOW); //!> Resetting the communication channel failed. Severity LOW, par1: returnCode, par2: 0 + static const Event CCSDS_BOARD_SWITCHED = MAKE_EVENT(1, SEVERITY::INFO); //!> Switched active CCSDS-Board. Par1: objectId of now active board, Par2: objectId of now passive board. + + static const ActionId_t SET_DATA_RATE_RATIO = 1; + static const float SENDS_PER_SECOND = 2.5; + static const uint32_t MINIMUM_BYTES_PER_SECOND = + (VCGeneration::IDLE_PACKET_SIZE + / (VCGeneration::DEFAULT_IDLE_INTERVAL / 1000)) + 1; //!< +1 to be on the safe side. + static const float DEFAULT_RATES[BoardHandler::USED_VIRTUAL_CHANNELS_PER_BOARD]; + static const uint32_t DEFAULT_BYTES_PER_SECOND = 1300; + + HealthDevice tmPartHealth; //!< A helper device to dedicatetly set the telemetry part to not healthy. + /** + * Main Constructor of the class. + * Initializes all attributes with default values. Sets the frame buffer to zero. + * Creates all TM Virtual Channels (with \c new). Initialization of communication partners + * is done in the #initialize routine. + * @param setObjectId Object identifier of the class. + * @param setSwitchId1 Switch id of the first switch of the board. + * @param setSwitchId2 Switch id of the second switch of the board. + * @param set_channel RMAP channel identifier. This is forwarded to the #boardHandler class. + * @param set_scid Configured SpaceCraft Identifier. Is forwarded to #boardHandler and #dataLinkLayer class. + */ + CCSDSHandler(object_id_t setObjectId, uint8_t setSwitchId1, + uint8_t setSwitchId2, object_id_t setChannel, uint16_t setSCID, + BoardHandler::DataPoolIds setPool); + /** + * The destructor deletes all TM Virtual Channels. + */ + ~CCSDSHandler(); + /** + * Main executing method of the CCSDS Board handling. + * The method coordinates reading and writing of buffers and registers on the CCSDS Board + * as well as checking communication states and looking for frames. The state machine is + * executed here as well. To ensure a smooth communication without much delay, the last read + * and write calls are checked in the beginning and new requests as well as the state machine + * are issued in the end. + * @return Always returns #RETURN_OK. + */ + ReturnValue_t performOperation(void); + + ReturnValue_t handleMemoryLoad(uint32_t address, const uint8_t* data, + uint32_t size, uint8_t** dataPointer); + ReturnValue_t handleMemoryDump(uint32_t address, uint32_t size, + uint8_t** dataPointer, uint8_t* dumpTarget); + /** + * Initialization routine of the class. + * It initializes connections to the power unit and to the Telemetry store which is set for + * every TM Virtual Channel. + * @return + */ + ReturnValue_t initialize(); + MessageQueueId_t getCommandQueue() const; + /** + * Method to configure the TC Virtual Channels in the TC Data Link Layer. + * The call is forwarded to the #dataLinkLayer class. + * @param virtualChannelId VCID to add. + * @param object Pointer to the Virtual Channel object that is added. + * @return See the #dataLinkLayer class. + */ + ReturnValue_t addVirtualChannel(uint8_t virtualChannelId, + VirtualChannelReceptionIF* object); + + Mode_t getMode() const; + Submode_t getSubmode() const; + void setParentQueue(MessageQueueId_t parentQueueId); + MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0); + ReturnValue_t setHealth(HealthState health); + HasHealthIF::HealthState getHealth(); + ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId, + ParameterWrapper *parameterWrapper, + const ParameterWrapper *newValues, uint16_t startAtIndex); + void triggerEvent(Event event, uint32_t parameter1 = 0, + uint32_t parameter2 = 0); +protected: + MessageQueue commandQueue; //!< Queue to receive control commands. + VCGeneration* virtualChannels[BoardHandler::USED_VIRTUAL_CHANNELS_PER_BOARD];//!< An array of VCGeneration classes which each manage on TM Virtual Channel. + uint32_t rateLimitOverload[BoardHandler::USED_VIRTUAL_CHANNELS_PER_BOARD];//!< Used to smooth data rate in case large packets are sent. + /** + * This method reads the command queue and initializes a state transition if a command of this type was found. + */ + void readCommandQueue(void); + + /** + * This method flushes all pending messages in the TM queue by calling the \c flush method of + * all #virtualChannels. + * This is necessary to avoid doubled TM packets if the TM sender issues its messages to both the + * nominal and redundant CCSDS Board. + */ + void flushTmChannels(); + /** + * This is a helper method to print the current content of the frame buffers. + */ + void printFrameBuffer(void); + /** + * This is an important method which triggers searching for and handling found frames. + * It first calls the boardHandler method to find a frame in the received data. If a + * well-formed frame was found it calls the #dataLinkLayer class to process the frame + */ + void searchFrame(); + /** + * Calls the packet processing routine of each TM Virtual Channel. + * This triggers reception of incoming packets from the OBSW and forwarding to the CCSDS Board. + * There are different sending strategies for forwarding the packets to the board. + * @return Returns #RETURN_OK or the status of the failed virtual channel method. + */ + ReturnValue_t packetProcessing(void); + /** + * With this method the successful forwarding of Telemetry to the TM Virtual Channels is checked. + * The method calls the check routine of each virtual channel. + * @return Returns #RETURN_OK or the status of the failed virtual channel method. + */ + ReturnValue_t packetProcessingCheck(void); + + ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t *msToReachTheMode); + void startTransition(Mode_t mode, Submode_t submode); + void getMode(Mode_t *mode, Submode_t *submode); + void setToExternalControl(); + void announceMode(bool recursive); +private: + enum CcsdsState_t { + STATE_IDLE, + STATE_TURN_ON, + STATE_TURN_OFF, + STATE_DO_PASSIVATE_OFF, + STATE_TURN_SWITCH_OFF, + STATE_WAIT_ON, + STATE_WAIT_LINK, + STATE_WAIT_OFF, + STATE_INITIALIZE_BOARD, + STATE_SELECT_SUBMODE, + STATE_WAIT_SUBMODE_ACTIVE, + STATE_DO_PASSIVATE, + STATE_WAIT_SUBMODE_PASSIVE, + STATE_HANDLE_STARTUP, + }; + CcsdsState_t state; + enum CommState { + SEND_WRITE, GET_WRITE, SEND_READ, GET_READ + }; + CommState commState; + Mode_t mode; + Submode_t submode; + BoardHandler boardHandler;//!< The class that handles the low-level communication with the board. + DataLinkLayer dataLinkLayer;//!< The class that manages the TC Data Link Layer protocols. + uint8_t frameBuffer[MAX_FRAME_SIZE]; //!< The main buffer to store single frames in. + uint16_t frameLength; //!< Indicates the current length of the found frame. + object_id_t channelId; //!< Defines the id of the RMAP Channel to use. + MemoryHelper memoryHelper; //!< Helps handling memory messages. + + bool pendingWrite; //!< Attribute to manage remote Memory write. + + bool pendingRead; //!< Attribute to manage remote Memory read. + + ModeHelper modeHelper; //!< Helps handling mode messages. + HealthHelper healthHelper; //!< Helps setting the health information correctly. + ParameterHelper parameterHelper; + PowerSwitcher powerSwitcher; //!< Helps switching switches on and off. + + bool switchOffWasReported; //!< To avoid reporting SWITCH_WENT_OFF multiple times. + + CCSDSBoardFailureIsolation fdir; + class DataRateSet: public ControllerSet { + public: + DataRateSet(); + virtual ~DataRateSet(); + void setToDefault(); + PoolVector dataRate; + PoolVector dataRates; + }; + DataRateSet rateSet; + void setMode(Mode_t newMode, Submode_t newSubmode); //!< Method to safely setMode and inform everyone interested about it. + /** + * State machine of the Handler. + * Is responsible for handling mode transitions and for informing the modeHelper. + * In addition, it watches the SpW link and changes the Mode in case a link down or a link up is detected. + */ + void doStateMachine(); + void executeAllWriteCommands(); + void handleAllWriteReplies(); + void executeAllReadCommands(); + void handleAllReadReplies(); +}; + +#endif /* CCSDSHANDLER_H_ */ diff --git a/mission/utility/TmFunnel.cpp b/mission/utility/TmFunnel.cpp index c52fa6f9..e5de3ef7 100644 --- a/mission/utility/TmFunnel.cpp +++ b/mission/utility/TmFunnel.cpp @@ -1,3 +1,4 @@ +#include "OBSWConfig.h" #include #include #include @@ -97,7 +98,13 @@ ReturnValue_t TmFunnel::initialize() { "properly and implements AcceptsTelemetryIF" << std::endl; return ObjectManagerIF::CHILD_INIT_FAILED; } + +#if OBSW_USE_PTME_IP_CORE == 1 + // Live TM will be sent via the virtual channel 0 + tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue(0)); +#else tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue()); +#endif /* OBSW_USE_CCSDS_IP_CORES == 1 */ // Storage destination is optional. if(storageDestination == objects::NO_OBJECT) { From d54e2276d6735c3db1aadfa1ab6c230558bd9303 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Wed, 22 Sep 2021 16:54:55 +0200 Subject: [PATCH 002/465] ccsds handler wip --- bsp_q7s/boardconfig/busConf.h | 10 ++ bsp_q7s/core/ObjectFactory.cpp | 66 ++++++++---- common/config/commonConfig.h.in | 2 +- common/config/commonObjects.h | 6 +- linux/fsfwconfig/devices/gpioIds.h | 11 +- linux/obc/PapbVcInterface.cpp | 6 +- mission/tmtc/CCSDSHandler.cpp | 167 +++++++---------------------- mission/tmtc/CCSDSHandler.h | 93 ++++------------ mission/tmtc/VirtualChannel.cpp | 80 ++++++++++++++ mission/tmtc/VirtualChannel.h | 110 +++++++++++++++++++ mission/utility/TmFunnel.cpp | 10 +- mission/utility/TmFunnel.h | 2 +- 12 files changed, 327 insertions(+), 236 deletions(-) create mode 100644 mission/tmtc/VirtualChannel.cpp create mode 100644 mission/tmtc/VirtualChannel.h diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index f5b4a860..5bec55a2 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -90,6 +90,16 @@ static constexpr uint32_t SPI_MUX_BIT_5 = 17; static constexpr uint32_t SPI_MUX_BIT_6 = 9; static constexpr uint32_t EN_RW_CS = 17; +static constexpr char GPIO_VC_STATUS_SIGNALS_LABEL[] = "/amba_pl/gpio@81200000"; +static constexpr uint32_t VC0_PAPB_EMPTY_LINE = 0; +static constexpr uint32_t VC0_PAPB_BUSY_LINE = 1; +static constexpr uint32_t VC1_PAPB_EMPTY_LINE = 2; +static constexpr uint32_t VC1_PAPB_BUSY_LINE = 3; +static constexpr uint32_t VC2_PAPB_EMPTY_LINE = 4; +static constexpr uint32_t VC2_PAPB_BUSY_LINE = 5; +static constexpr uint32_t VC3_PAPB_EMPTY_LINE = 6; +static constexpr uint32_t VC3_PAPB_BUSY_LINE = 7; + } #endif /* BSP_Q7S_BOARDCONFIG_BUSCONF_H_ */ diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 024be8dd..0fcaff62 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -173,25 +173,55 @@ void ObjectFactory::produce(void* args) { #endif /* TE7020 != 0 */ -#if OBSW_USE_PTME_IP_CORE == 1 - GpioCookie* gpioCookiePtmeIp = new GpioCookie; - GpiodRegular* vc0PapbBusyN = new GpiodRegular(std::string("gpiochip0"), 0, std::string("PAPBBusy_N")); - gpioCookiePtmeIp->addGpio(gpioIds::PAPB_BUSY_N, papbBusyN); - GpiodRegular* vc0PapbEmpty = new GpiodRegular(st_d::string("gpiochip0"), 1, - std::string("PAPBEmpty_VC0")); - gpioCookiePtmeIp->addGpio(gpioIds::PAPB_EMPTY, papbEmpty); - gpioComIF->addGpios(gpioCookiePtmeIp); - PapbVcInterface* vc0 = new PapbVcInterface(objects::PAPB_VC0, gpioComIF, ) - Ptme* ptme = new Ptme(objects::PTME); - ptme->addVcInterface(0, vc0); - ptme->addVcInterface(1, vc1); - ptme->addVcInterface(2, vc2); - ptme->addVcInterface(3, vc3); +#if OBSW_USE_CCSDS_IP_CORE == 1 - new CCSDSIPCoreBridge(objects::CCSDS_IP_CORE_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR, - objects::TM_STORE, objects::TC_STORE, gpioComIF, std::string("/dev/uio0"), - gpioIds::PAPB_BUSY_N, gpioIds::PAPB_EMPTY); -#endif /* OBSW_USE_TMTC_IP_CORE_BRIDGE == 1 */ + // GPIO definitions of signals connected to the virtual channel interfaces of the PTME IP Core + GpioCookie* gpioCookiePtmeIp = new GpioCookie; + GpiodRegular* vcSignal = new GpiodRegular("PAPB VC0 Busy Signal", + q7s::GPIO_VC_STATUS_SIGNALS_LABEL, q7s::VC0_PAPB_BUSY_LINE); + gpioCookiePtmeIp->addGpio(gpioIds::VC0_PAPB_BUSY, vcSignal); + vcSignal = new GpiodRegular("PAPB VC0 Empty Signal", q7s::GPIO_VC_STATUS_SIGNALS_LABEL, + q7s::VC0_PAPB_EMPTY_LINE); + gpioCookiePtmeIp->addGpio(gpioIds::VC0_PAPB_EMPTY, vcSignal); + vcSignal = new GpiodRegular("PAPB VC1 Busy Signal", q7s::GPIO_VC_STATUS_SIGNALS_LABEL, + q7s::VC1_PAPB_BUSY_LINE); + gpioCookiePtmeIp->addGpio(gpioIds::VC1_PAPB_BUSY, vcSignal); + vcSignal = new GpiodRegular("PAPB VC1 Empty Signal", q7s::GPIO_VC_STATUS_SIGNALS_LABEL, + q7s::VC1_PAPB_EMPTY_LINE); + gpioCookiePtmeIp->addGpio(gpioIds::VC1_PAPB_EMPTY, vcSignal); + vcSignal = new GpiodRegular("PAPB VC2 Busy Signal", q7s::GPIO_VC_STATUS_SIGNALS_LABEL, + q7s::VC2_PAPB_BUSY_LINE); + gpioCookiePtmeIp->addGpio(gpioIds::VC2_PAPB_BUSY, vcSignal); + vcSignal = new GpiodRegular("PAPB VC2 Empty Signal", q7s::GPIO_VC_STATUS_SIGNALS_LABEL, + q7s::VC2_PAPB_EMPTY_LINE); + gpioCookiePtmeIp->addGpio(gpioIds::VC2_PAPB_EMPTY, vcSignal); + vcSignal = new GpiodRegular("PAPB VC3 Busy Signal", q7s::GPIO_VC_STATUS_SIGNALS_LABEL, + q7s::VC3_PAPB_BUSY_LINE); + gpioCookiePtmeIp->addGpio(gpioIds::VC3_PAPB_BUSY, vcSignal); + vcSignal = new GpiodRegular("PAPB VC3 Empty Signal", q7s::GPIO_VC_STATUS_SIGNALS_LABEL, + q7s::VC3_PAPB_EMPTY_LINE); + gpioCookiePtmeIp->addGpio(gpioIds::VC3_PAPB_EMPTY, vcSignal); + + gpioComIF->addGpios(gpioCookiePtmeIp); + + // Creating virtual channel interfaces + PapbVcInterface* vc = new PapbVcInterface(objects::PAPB_VC0, gpioComIF, gpioIds::VC0_PAPB_BUSY, + gpioIds::VC0_PAPB_EMPTY); + PapbVcInterface* vc = new PapbVcInterface(objects::PAPB_VC1, gpioComIF, gpioIds::VC1_PAPB_BUSY, + gpioIds::VC1_PAPB_EMPTY); + PapbVcInterface* vc = new PapbVcInterface(objects::PAPB_VC2, gpioComIF, gpioIds::VC2_PAPB_BUSY, + gpioIds::VC2_PAPB_EMPTY); + PapbVcInterface* vc = new PapbVcInterface(objects::PAPB_VC3, gpioComIF, gpioIds::VC3_PAPB_BUSY, + gpioIds::VC3_PAPB_EMPTY); + + // Creating ptme object and adding virtual channel interfaces + Ptme* ptme = new Ptme(objects::PTME); + ptme->addVcInterface(0, vc); + ptme->addVcInterface(1, vc); + ptme->addVcInterface(2, vc); + ptme->addVcInterface(3, vc); + +#endif /* OBSW_USE_CCSDS_IP_CORE == 1 */ #if OBSW_USE_TMTC_TCP_BRIDGE == 0 auto udpBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); diff --git a/common/config/commonConfig.h.in b/common/config/commonConfig.h.in index 55af54e3..c089c575 100644 --- a/common/config/commonConfig.h.in +++ b/common/config/commonConfig.h.in @@ -8,7 +8,7 @@ #define OBSW_USE_TMTC_TCP_BRIDGE 1 // This will cause the OBSW to initialize the TMTC bridge responsible for exchanging data with the // CCSDS IP Cores. -#define OBSW_USE_TMTC_IP_CORE_BRIDGE 0 +#define OBSW_USE_CCSDS_IP_CORE 1 // Set to 1 if all telemetry should be sent to the PTME IP Core #define OBSW_TM_TO_PTME 0 // Set to 1 if telecommands are received via the PDEC IP Core diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index 5fc61bd4..0a66cd9a 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -13,9 +13,9 @@ enum commonObjects: uint32_t { FILE_SYSTEM_HANDLER = 0x50000500, PTME = 0x50000600, PAPB_VC0 = 0x50000700, - PAPB_VC0 = 0x500007001, - PAPB_VC0 = 0x500007002, - PAPB_VC0 = 0x500007003, + PAPB_VC1 = 0x500007001, + PAPB_VC2 = 0x500007002, + PAPB_VC3 = 0x500007003, /* 0x43 ('C') for Controllers */ THERMAL_CONTROLLER = 0x43400001, diff --git a/linux/fsfwconfig/devices/gpioIds.h b/linux/fsfwconfig/devices/gpioIds.h index b450bf8b..2016245d 100644 --- a/linux/fsfwconfig/devices/gpioIds.h +++ b/linux/fsfwconfig/devices/gpioIds.h @@ -89,7 +89,16 @@ enum gpioId_t { EN_RW_CS, - SPI_MUX + SPI_MUX, + + VC0_PAPB_EMPTY, + VC0_PAPB_BUSY, + VC1_PAPB_EMPTY, + VC1_PAPB_BUSY, + VC2_PAPB_EMPTY, + VC2_PAPB_BUSY, + VC3_PAPB_EMPTY, + VC3_PAPB_BUSY }; } diff --git a/linux/obc/PapbVcInterface.cpp b/linux/obc/PapbVcInterface.cpp index 736c8b24..0c3c759a 100644 --- a/linux/obc/PapbVcInterface.cpp +++ b/linux/obc/PapbVcInterface.cpp @@ -53,12 +53,12 @@ ReturnValue_t PapbVcInterface::pollPapbBusySignal() { /** Check if PAPB interface is ready to receive data */ result = gpioComIF->readGpio(papbBusyId, &papbBusyState); if (result != RETURN_OK) { - sif::debug << "PapbVcInterface::pollPapbBusySignal: Failed to read papb busy signal" + sif::warning << "PapbVcInterface::pollPapbBusySignal: Failed to read papb busy signal" << std::endl; return RETURN_FAILED; } if (!papbBusyState) { - sif::debug << "PapbVcInterface::pollPapbBusySignal: PAPB busy" << std::endl; + sif::warning << "PapbVcInterface::pollPapbBusySignal: PAPB busy" << std::endl; return PAPB_BUSY; } @@ -72,7 +72,7 @@ void PapbVcInterface::isVcInterfaceBufferEmpty() { result = gpioComIF->readGpio(papbEmptyId, &papbEmptyState); if (result != RETURN_OK) { - sif::debug << "PapbVcInterface::isVcInterfaceBufferEmpty: Failed to read papb empty signal" + sif::warning << "PapbVcInterface::isVcInterfaceBufferEmpty: Failed to read papb empty signal" << std::endl; return; } diff --git a/mission/tmtc/CCSDSHandler.cpp b/mission/tmtc/CCSDSHandler.cpp index 38428c14..b17af452 100644 --- a/mission/tmtc/CCSDSHandler.cpp +++ b/mission/tmtc/CCSDSHandler.cpp @@ -1,13 +1,3 @@ -/******************************* - * FLP Flight Software Framework (FSFW) - * (c) 2016 IRS, Uni Stuttgart - *******************************/ -/* - * CCSDSHandler.cpp - * - * Created on: Feb 9, 2012 - * Author: baetz - */ #include #include #include @@ -121,9 +111,30 @@ ReturnValue_t CCSDSHandler::packetProcessingCheck(void) { ReturnValue_t CCSDSHandler::performOperation(void) { readCommandQueue(); + handleTelemetry(); + handleTelecommands(); return RETURN_OK; } +void CCSDSHandler::addVirtualChannel(VcId_t virtualChannelId, VirtualChannel* virtualChannel) { + auto status = virtualChannelMap.emplace(virtualChannelId, virtualChannel); + if (status.second == false) { + sif::warning << "CCSDSHandler::addVcInterface: Failed to add virtual channel with virtual " + << "channel id " << static_cast(virtualChannelId) << std::endl; + } +} + +void CCSDSHandler::handleTelemetry() { + VirtualChannelMapIter iter; + for (iter = virtualChannelMap.begin(); iter != VirtualChannelMap.end(); iter++) { + iter->second.virtualChannel->performOperation(); + } +} + +void CCSDSHandler::handleTelecommands() { + +} + void CCSDSHandler::searchFrame() { frameLength = this->boardHandler.findFrame(); while (frameLength != 0) { @@ -198,17 +209,18 @@ ReturnValue_t CCSDSHandler::initialize() { void CCSDSHandler::readCommandQueue(void) { CommandMessage commandMessage; ReturnValue_t result = RETURN_FAILED; - while (commandQueue.receiveMessage(&commandMessage) == RETURN_OK) { - result = parameterHelper.handleParameterMessage(&commandMessage); - if (result == RETURN_OK) { - return; - } - CommandMessage reply; - reply.setReplyRejected(CommandMessage::UNKNOW_COMMAND, - commandMessage.getCommand()); - commandQueue.reply(&reply); - } + result = commandQueue.receiveMessage(&commandMessage); + if (result == RETURN_OK) { + result = parameterHelper.handleParameterMessage(&commandMessage); + if (result == RETURN_OK) { + return; + } + CommandMessage reply; + reply.setReplyRejected(CommandMessage::UNKNOW_COMMAND, + commandMessage.getCommand()); + commandQueue.reply(&reply); + } } MessageQueueId_t CCSDSHandler::getCommandQueue() const { @@ -486,120 +498,15 @@ Submode_t CCSDSHandler::getSubmode() const { } MessageQueueId_t CCSDSHandler::getReportReceptionQueue(uint8_t virtualChannel) { - if (virtualChannel < Ptme::NUM_OF_VIRTUAL_CHANNELS) { + if (virtualChannel < config::NUMBER_OF_VIRTUAL_CHANNELS) { return virtualChannels[virtualChannel]->getReportReceptionQueue(); } else { sif::debug << "CCSDSHandler::getReportReceptionQueue: Invalid virtual channel requested"; } } -void CCSDSHandler::executeAllWriteCommands() { - ReturnValue_t returnValue = boardHandler.sendWriteCommands(); - if (returnValue != RETURN_OK) { - triggerEvent(DeviceHandlerIF::DEVICE_SENDING_COMMAND_FAILED, - returnValue, 0); - } - if (submode == SUBMODE_ACTIVE) { - returnValue = this->packetProcessing(); - if (returnValue != RETURN_OK) { - triggerEvent(DeviceHandlerIF::DEVICE_SENDING_COMMAND_FAILED, - returnValue, 1); - } - } -} - -void CCSDSHandler::handleAllWriteReplies() { - ReturnValue_t returnValue = boardHandler.getWriteReplys(); - if (returnValue != RETURN_OK) { - triggerEvent(DeviceHandlerIF::DEVICE_SENDING_COMMAND_FAILED, - returnValue, 0); - } - if (pendingWrite) { - memoryHelper.completeLoad(returnValue); - pendingWrite = false; - } - if (submode == SUBMODE_ACTIVE) { - returnValue = packetProcessingCheck(); - } else { - this->flushTmChannels(); - } -} - -void CCSDSHandler::executeAllReadCommands() { - ReturnValue_t returnValue = boardHandler.sendReadCommands(); - if (returnValue != RETURN_OK) { - triggerEvent(DeviceHandlerIF::DEVICE_REQUESTING_REPLY_FAILED, - returnValue, 0); - } -} - -void CCSDSHandler::handleAllReadReplies() { - if ((mode == MODE_ON) && (state == STATE_IDLE)) { - ReturnValue_t returnValue = boardHandler.getReadReplys(); - if (returnValue == RETURN_OK) { - searchFrame(); - } else { - triggerEvent(DeviceHandlerIF::DEVICE_REQUESTING_REPLY_FAILED, - returnValue, 0); - //do nothing. - } - if (pendingRead) { - uint8_t* tempBuffer; - returnValue = boardHandler.getRegisterReadReply(&tempBuffer); - memoryHelper.completeDump(returnValue, tempBuffer, - BoardHandler::REGISTER_LENGTH); - pendingRead = false; - } - } -} - -ReturnValue_t CCSDSHandler::getParameter(uint8_t domainId, uint16_t parameterId, - ParameterWrapper* parameterWrapper, const ParameterWrapper* newValues, - uint16_t startAtIndex) { - ReturnValue_t result = fdir.getParameter(domainId, parameterId, - parameterWrapper, newValues, startAtIndex); - if (result != INVALID_DOMAIN_ID) { - return result; - } - if (domainId != DOMAIN_ID_BASE) { - return INVALID_DOMAIN_ID; - } - switch (parameterId) { - case 0: - parameterWrapper->set(boardHandler.tmPhysicalLayerRegisterValue); - break; - case 1: - parameterWrapper->set(boardHandler.tmCodingSublayerRegisterValue); - break; - default: - return INVALID_MATRIX_ID; - } - return RETURN_OK; -} - -ReturnValue_t CCSDSHandler::setHealth(HealthState health) { - healthHelper.setHealth(health); - return RETURN_OK; -} - -HasHealthIF::HealthState CCSDSHandler::getHealth() { - return healthHelper.getHealth(); -} - -CCSDSHandler::DataRateSet::DataRateSet() : - ControllerSet(), dataRate(datapool::VC_DATA_RATE_RAW, this, - PoolVariableIF::VAR_WRITE), dataRates( - datapool::DATA_RATE_ASSIGN, this, PoolVariableIF::VAR_READ) { -} - -CCSDSHandler::DataRateSet::~DataRateSet() { -} - -void CCSDSHandler::DataRateSet::setToDefault() { - dataRate.value = {0.0, 0.0, 0.0, 0.0}; -} - -void CCSDSHandler::triggerEvent(Event event, uint32_t parameter1, - uint32_t parameter2) { - fdir.triggerEvent(event, parameter1, parameter2); +ReturnValue_t CCSDSHandler::getParameter(uint8_t domainId, uint8_t uniqueIdentifier, + ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues, + uint16_t startAtIndex) { + return RETURN_OK; } diff --git a/mission/tmtc/CCSDSHandler.h b/mission/tmtc/CCSDSHandler.h index 77c8b2c1..8780b4e8 100644 --- a/mission/tmtc/CCSDSHandler.h +++ b/mission/tmtc/CCSDSHandler.h @@ -16,7 +16,6 @@ */ class CCSDSHandler: public SystemObject, public ExecutableObjectIF, - public HasModesIF, public AcceptsTelemetryIF, public HasReturnvaluesIF, public ReceivesParameterMessagesIF { @@ -80,27 +79,26 @@ public: */ ReturnValue_t initialize(); MessageQueueId_t getCommandQueue() const; + /** - * Method to configure the TC Virtual Channels in the TC Data Link Layer. - * The call is forwarded to the #dataLinkLayer class. - * @param virtualChannelId VCID to add. - * @param object Pointer to the Virtual Channel object that is added. - * @return See the #dataLinkLayer class. + * @brief Function to add a virtual channel + * + * @param virtualChannelId ID of the virtual channel to add + * @param virtualChannel Pointer to virtual channel object + * + * @return RETURN_OK if successful, otherwise RETURN_FAILED */ - ReturnValue_t addVirtualChannel(uint8_t virtualChannelId, - VirtualChannelReceptionIF* object); + void addVirtualChannel(VcId_t virtualChannelId, VirtualChannel* virtualChannel); Mode_t getMode() const; Submode_t getSubmode() const; void setParentQueue(MessageQueueId_t parentQueueId); MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0); - ReturnValue_t setHealth(HealthState health); - HasHealthIF::HealthState getHealth(); - ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId, - ParameterWrapper *parameterWrapper, - const ParameterWrapper *newValues, uint16_t startAtIndex); - void triggerEvent(Event event, uint32_t parameter1 = 0, - uint32_t parameter2 = 0); + + ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueIdentifier, + ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues, + uint16_t startAtIndex); + protected: MessageQueue commandQueue; //!< Queue to receive control commands. VCGeneration* virtualChannels[BoardHandler::USED_VIRTUAL_CHANNELS_PER_BOARD];//!< An array of VCGeneration classes which each manage on TM Virtual Channel. @@ -148,68 +146,15 @@ protected: void setToExternalControl(); void announceMode(bool recursive); private: - enum CcsdsState_t { - STATE_IDLE, - STATE_TURN_ON, - STATE_TURN_OFF, - STATE_DO_PASSIVATE_OFF, - STATE_TURN_SWITCH_OFF, - STATE_WAIT_ON, - STATE_WAIT_LINK, - STATE_WAIT_OFF, - STATE_INITIALIZE_BOARD, - STATE_SELECT_SUBMODE, - STATE_WAIT_SUBMODE_ACTIVE, - STATE_DO_PASSIVATE, - STATE_WAIT_SUBMODE_PASSIVE, - STATE_HANDLE_STARTUP, - }; - CcsdsState_t state; - enum CommState { - SEND_WRITE, GET_WRITE, SEND_READ, GET_READ - }; - CommState commState; - Mode_t mode; - Submode_t submode; - BoardHandler boardHandler;//!< The class that handles the low-level communication with the board. - DataLinkLayer dataLinkLayer;//!< The class that manages the TC Data Link Layer protocols. - uint8_t frameBuffer[MAX_FRAME_SIZE]; //!< The main buffer to store single frames in. - uint16_t frameLength; //!< Indicates the current length of the found frame. - object_id_t channelId; //!< Defines the id of the RMAP Channel to use. - MemoryHelper memoryHelper; //!< Helps handling memory messages. - bool pendingWrite; //!< Attribute to manage remote Memory write. + using VcId_t = uint8_t; + using VirtualChannelMap = std::unordered_map; + using VirtualChannelMapIter = VirtualChannelMap::iterator; - bool pendingRead; //!< Attribute to manage remote Memory read. + VirtualChannelMap virtualChannelMap; - ModeHelper modeHelper; //!< Helps handling mode messages. - HealthHelper healthHelper; //!< Helps setting the health information correctly. - ParameterHelper parameterHelper; - PowerSwitcher powerSwitcher; //!< Helps switching switches on and off. - - bool switchOffWasReported; //!< To avoid reporting SWITCH_WENT_OFF multiple times. - - CCSDSBoardFailureIsolation fdir; - class DataRateSet: public ControllerSet { - public: - DataRateSet(); - virtual ~DataRateSet(); - void setToDefault(); - PoolVector dataRate; - PoolVector dataRates; - }; - DataRateSet rateSet; - void setMode(Mode_t newMode, Submode_t newSubmode); //!< Method to safely setMode and inform everyone interested about it. - /** - * State machine of the Handler. - * Is responsible for handling mode transitions and for informing the modeHelper. - * In addition, it watches the SpW link and changes the Mode in case a link down or a link up is detected. - */ - void doStateMachine(); - void executeAllWriteCommands(); - void handleAllWriteReplies(); - void executeAllReadCommands(); - void handleAllReadReplies(); + void handleTelemetry(); + void handleTelecommands(); }; #endif /* CCSDSHANDLER_H_ */ diff --git a/mission/tmtc/VirtualChannel.cpp b/mission/tmtc/VirtualChannel.cpp new file mode 100644 index 00000000..8e106de1 --- /dev/null +++ b/mission/tmtc/VirtualChannel.cpp @@ -0,0 +1,80 @@ +#include "CCSDSHandler.h" +#include "OBSWConfig.h" + +#include "fsfw/serviceinterface/ServiceInterfaceStream.h" +#include "fsfw/objectmanager/ObjectManager.h" + + +#include + +#include + + +VirtualChannel::VirtualChannel(uint8_t vcId, uint32_t tmQueueDepth) : + vcId(vcId) { + tmQueue = QueueFactory::instance()->createMessageQueue(tmQueueDepth, + MessageQueueMessage::MAX_MESSAGE_SIZE); +} + +ReturnValue_t VirtualChannel::initialize() { + tmStore = ObjectManager::instance()->get(objects::TM_STORE); + if(tmStore == nullptr) { + sif::error << "VirtualChannel::initialize: Failed to get tm store" << std::endl; + return RETURN_FAILED; + } +} + +ReturnValue_t VirtualChannel::performOperation() { + ReturnValue_t status = RETURN_OK; + TmTcMessage message; + + while(tmQueue->receiveMessage(&message) == RETURN_OK) { + store_address_t storeId = message.getStorageId(); + const uint8_t* data = nullptr; + size_t size = 0; + result = tmStore->getData(storeId, &data, &size); + if (result != RETURN_OK) { + sif::warning << "VirtualChannel::performOperation: Failed to read data from IPC store" + << std::endl; + tmStore->deleteData(storeId); + return result; + } + + if (linkIsUp) { + result = ptme->writeToVc(virtualChannleId, data, size); + } + + tmStore->deleteData(storeId); + + if (result != RETURN_OK) { + return result; + } + } + return result; +} + +MessageQueueId_t VirtualChannel::getReportReceptionQueue(uint8_t virtualChannel) { + return tmQueue.getId(); +} + +void VirtualChannel::setPtmeObject(PtmeIF* ptme) { + if (ptme == nullptr) { + sif::warning << "VirtualChannel::setPtmeObject: Invalid ptme object" << std::endl; + } + ptme = ptme; +} + +void VirtualChannel::setIdlePacketIntervalMs(uint32_t idlePacketIntervalMs) { + timer.timeout = idlePacketIntervalMs; +} + +ReturnValue_t VirtualChannel::flush() { + TmTcMessage message; + ReturnValue_t status = RETURN_FAILED; + for (status = tmQueue.receiveMessage(&message); status == RETURN_OK; + status = tmQueue.receiveMessage(&message)) { + packetStore->deleteData(message.getStorageId()); + } + boardHandler->resetVC(virtualChannelId); + return status; +} diff --git a/mission/tmtc/VirtualChannel.h b/mission/tmtc/VirtualChannel.h new file mode 100644 index 00000000..cba4b0b4 --- /dev/null +++ b/mission/tmtc/VirtualChannel.h @@ -0,0 +1,110 @@ +#ifndef VIRTUALCHANNEL_H_ +#define VIRTUALCHANNEL_H_ + +#include "fsfw/tmtcservices/AcceptsTelemetryIF.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * @brief This class represents a virtual channel in the software. + * + * @author J. Meier + */ +class VirtualChannel: public AcceptsTelemetryIF, public HasReturnvaluesIF { + public: + + uint32_t tmSendLimitPerCycle; //!< Current maximum bytes per cycle. + + static const uint32_t IDLE_INTERVAL_RT_CHANNEL = 2000; //!< Real Time channel (VC 0) idle interval. + + static const uint16_t IDLE_PACKET_SIZE = 1015; //!< Size of generated idle packets. + + static const uint32_t DEFAULT_IDLE_INTERVAL = 20000; //!< Default if too lazy to set. + + /** + * @brief Constructor + * + * @param vcId The virtual channel id assigned to this object + * @param tmQueueDepth Queue depth of queue receiving telemetry from other objects + */ + VirtualChannel(uint8_t vcId, uint32_t tmQueueDepth); + + ReturnValue_t initialize(); + + /** + * One of the main public methods. + * Checks the tmQueue, calls #handlePacket if packets were found and keeps track of the number of sent bytes, + * to stop transmission before a buffer overflow occurs. If no packets were sent, an idle packet is generated. + * @return Number of sent bytes. 0 if an error occurred. + */ + uint32_t packetProcessing(void); + /** + * Another important method to check successful forwarding of packets. + * Checks how many packets have been forwarded to the CCSDS Board and tries to get as many + * RMAP write replys. The pending messages are deleted here. + * @return @c RETURN_OK on success, or one of many error codes, mainly coming from @c receiveVCAcknowledge. + */ + ReturnValue_t packetProcessingCheck(void); + /** + * Setter. + * @param setStore Sets the #packetStore used. + */ + void setPacketStore(StorageManagerIF* setStore); + MessageQueueId_t getReportReceptionQueue(); + + ReturnValue_t performOperation(); + + /** + * @brief Sets the PTME object which handles access to the PTME IP Core. + * + * @param ptme Pointer to ptme object + */ + void setPtmeObject(Ptme* ptme); + +private: + + PtmeIF* ptme = nullptr; + MessageQueueIF* tmQueue = nullptr; + uint8_t virtualChannelId; + bool linkIsUp; + StorageManagerIF* tmStore = nullptr; + + + BoardHandler* boardHandler; //!< A reference to the "hardware part" of handling the packets. + store_address_t pendingTm[BoardHandler::TM_PACKETS_PER_CALL_PER_CHANNEL]; //!< List of packets sent to the board. Is used to check if all Space Packets sent received the CCSDS Board. + uint16_t sendCount; //!< Counter to identify how many packets have been sent coming in to the board (without Idle Packets). + Countdown timer; + SpacePacket idlePacket; + uint32_t accumulatedByteCount; + + store_address_t pendingPacket; + + static const uint32_t TM_SEND_LIMIT_PER_CYCLE = 1300; //!< The maximum number of bytes to send to the CCSDS Board VC per cycle. + + /** + * Helper method to send an idle packet. + * @return @c RETURN_OK on success, @c RETURN_FAILED otherwise. + */ + ReturnValue_t sendIdlePacket(uint32_t size); + /** + * A helper method to handle incoming packets. + * Reads a packet from #packetStore and tries to forward it to the CCSDS BoardHandler class. + * Calls the hardware layer with @c writeToVc. Depending on what the "hardware" layer does, + * it stores the sent packet id's to find out if they were all received by the CCSDS Board. + * @param store_id ID of a packet in the #packetStore. + * @return @c RETURN_OK on success, the return code of @c writeToVc otherwise. + */ + ReturnValue_t handlePacket(store_address_t storeId); +}; + +#endif /* VIRTUALCHANNEL_H_ */ diff --git a/mission/utility/TmFunnel.cpp b/mission/utility/TmFunnel.cpp index e5de3ef7..d718f6cf 100644 --- a/mission/utility/TmFunnel.cpp +++ b/mission/utility/TmFunnel.cpp @@ -46,7 +46,7 @@ ReturnValue_t TmFunnel::performOperation(uint8_t operationCode) { ReturnValue_t TmFunnel::handlePacket(TmTcMessage* message) { uint8_t* packetData = nullptr; size_t size = 0; - ReturnValue_t result = tmPool->modifyData(message->getStorageId(), + ReturnValue_t result = tmStore->modifyData(message->getStorageId(), &packetData, &size); if(result != HasReturnvaluesIF::RETURN_OK){ return result; @@ -60,7 +60,7 @@ ReturnValue_t TmFunnel::handlePacket(TmTcMessage* message) { result = tmQueue->sendToDefault(message); if(result != HasReturnvaluesIF::RETURN_OK){ - tmPool->deleteData(message->getStorageId()); + tmStore->deleteData(message->getStorageId()); sif::error << "TmFunnel::handlePacket: Error sending to downlink " "handler" << std::endl; return result; @@ -69,7 +69,7 @@ ReturnValue_t TmFunnel::handlePacket(TmTcMessage* message) { if(storageDestination != objects::NO_OBJECT) { result = storageQueue->sendToDefault(message); if(result != HasReturnvaluesIF::RETURN_OK){ - tmPool->deleteData(message->getStorageId()); + tmStore->deleteData(message->getStorageId()); sif::error << "TmFunnel::handlePacket: Error sending to storage " "handler" << std::endl; return result; @@ -80,8 +80,8 @@ ReturnValue_t TmFunnel::handlePacket(TmTcMessage* message) { ReturnValue_t TmFunnel::initialize() { - tmPool = ObjectManager::instance()->get(objects::TM_STORE); - if(tmPool == nullptr) { + tmStore = ObjectManager::instance()->get(objects::TM_STORE); + if(tmStore == nullptr) { sif::error << "TmFunnel::initialize: TM store not set." << std::endl; sif::error << "Make sure the tm store is set up properly" diff --git a/mission/utility/TmFunnel.h b/mission/utility/TmFunnel.h index 2d4575a0..b85a09e0 100644 --- a/mission/utility/TmFunnel.h +++ b/mission/utility/TmFunnel.h @@ -41,7 +41,7 @@ private: MessageQueueIF* tmQueue = nullptr; MessageQueueIF* storageQueue = nullptr; - StorageManagerIF* tmPool = nullptr; + StorageManagerIF* tmStore = nullptr; uint32_t messageDepth = 0; ReturnValue_t handlePacket(TmTcMessage* message); From c035a2605176eef1f9e3892aa6168ee66cda87f5 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 23 Sep 2021 10:51:47 +0200 Subject: [PATCH 003/465] gpio open by line name test on te0720 --- bsp_q7s/core/ObjectFactory.cpp | 5 ++++- linux/fsfwconfig/OBSWConfig.h.in | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index a6d6dda3..873b1b32 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -835,9 +835,12 @@ void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) { #endif #if BOARD_TE0720 == 1 && OBSW_TEST_LIBGPIOD == 1 -#if OBSW_TEST_GPIO_LABEL == 1 +#if OBSW_TEST_GPIO_OPEN_BYLABEL == 1 /* Configure MIO0 as input */ GpiodRegular* testGpio = new GpiodRegular("MIO0", gpio::OUT, 0, "/amba_pl/gpio@41200000", 0); +#elif OBSW_TEST_GPIO_OPEN_BY_LINE_NAME + GpiodRegularByLineName* testGpio = new GpiodRegularByLineName("test-name", "gpio-test", + gpio::OUT, 0); #else /* Configure MIO0 as input */ GpiodRegular* testGpio = new GpiodRegular("gpiochip0", 0, "MIO0", gpio::IN, 0); diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index bf5c1405..4feb45e2 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -84,7 +84,8 @@ debugging. */ #define OBSW_TEST_CCSDS_BRIDGE 0 #define OBSW_TEST_CCSDS_PTME 0 #define OBSW_TEST_TE7020_HEATER 0 -#define OBSW_TEST_GPIO_LABEL 0 +#define OBSW_TEST_GPIO_OPEN_BY_LABEL 0 +#define OBSW_TEST_GPIO_OPEN_BY_LINE_NAME 0 #define OBSW_DEBUG_P60DOCK 0 #define OBSW_DEBUG_PDU1 0 From 0e68dbd86c49e3bfadf99f6ffd9d7b00b0cc260f Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 23 Sep 2021 17:13:17 +0200 Subject: [PATCH 004/465] open mgm 2 lis3 chip select by name --- bsp_q7s/core/ObjectFactory.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 873b1b32..5e264d30 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -412,9 +412,11 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI gpio = new GpiodRegularByLabel(q7s::GPIO_ACS_BOARD_DEFAULT_LABEL, q7s::GPIO_MGM_1_RM3100_CS, "CS_MGM_1_RM3100_A", gpio::OUT, gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); - auto gpioChip = new GpiodRegularByChip(q7s::GPIO_MGM2_LIS3_LABEL, q7s::GPIO_MGM_2_LIS3_CS, - "CS_MGM_2_LIS3_B", gpio::OUT, gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::MGM_2_LIS3_CS, gpioChip); +// auto gpioChip = new GpiodRegularByChip(q7s::GPIO_MGM2_LIS3_LABEL, q7s::GPIO_MGM_2_LIS3_CS, +// "CS_MGM_2_LIS3_B", gpio::OUT, gpio::HIGH); + auto gpioByLineName = new GpiodRegularByLineName("mgm_2_lis3_chip_select", "LIS3 Handler", gpio::OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::MGM_2_LIS3_CS, gpioByLineName); gpio = new GpiodRegularByLabel(q7s::GPIO_ACS_BOARD_DEFAULT_LABEL, q7s::GPIO_MGM_3_RM3100_CS, "CS_MGM_3_RM3100_B", gpio::OUT, gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); From ebb575d49080a10626bad45d1fdc85f1e8b0761d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 23 Sep 2021 17:22:30 +0200 Subject: [PATCH 005/465] updated subversion --- common/config/OBSWVersion.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/config/OBSWVersion.h b/common/config/OBSWVersion.h index 5e9b1b9c..39cb356a 100644 --- a/common/config/OBSWVersion.h +++ b/common/config/OBSWVersion.h @@ -4,7 +4,7 @@ const char* const SW_NAME = "eive"; #define SW_VERSION 1 -#define SW_SUBVERSION 7 +#define SW_SUBVERSION 8 #define SW_REVISION 0 #endif /* COMMON_CONFIG_OBSWVERSION_H_ */ From 0e43969b633e994a52005c802db9bedfb4c4aebb Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 23 Sep 2021 17:34:01 +0200 Subject: [PATCH 006/465] dont start empty PST --- bsp_q7s/core/InitMission.cpp | 8 ++++++-- fsfw | 2 +- .../pollingsequence/pollingSequenceFactory.cpp | 13 ++++++++++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index e7d8779b..bc9139fb 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -173,9 +173,13 @@ void initmission::createPstTasks(TaskFactory& factory, missedDeadlineFunc); result = pst::pstSpi(spiPst); if (result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; + if(result != FixedTimeslotTaskIF::SLOT_LIST_EMPTY) { + sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; + } + } + else { + taskVec.push_back(spiPst); } - taskVec.push_back(spiPst); #endif FixedTimeslotTaskIF* uartPst = factory.createFixedTimeslotTask( diff --git a/fsfw b/fsfw index e1a85b47..0987a160 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit e1a85b47c5018590e58b9b1130b1754b0079450f +Subproject commit 0987a160c9c200e1b7b72e992ae158d826147c30 diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 3b826119..17cdc206 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -536,9 +536,16 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { } #endif /* OBSW_ADD_ACS_BOARD == 1 */ - if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "SPI PST initialization failed" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t seqCheck = thisSequence->checkSequence(); + if (seqCheck != HasReturnvaluesIF::RETURN_OK) { + if(seqCheck == FixedTimeslotTaskIF::SLOT_LIST_EMPTY) { + sif::warning << "SPI PST is empty.." << std::endl; + } + else { + sif::error << "SPI PST initialization failed" << std::endl; + } + + return seqCheck; } return HasReturnvaluesIF::RETURN_OK; } From 5348f059b01f41822fe81519d0ff119a2e3eb1e1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 23 Sep 2021 17:34:45 +0200 Subject: [PATCH 007/465] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 0987a160..dd610f0d 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 0987a160c9c200e1b7b72e992ae158d826147c30 +Subproject commit dd610f0d7edb3a152bec304b9b8452d1b5ea1f49 From 11537f9988b0b19ae7ceac3c0ebc62355098d5a3 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Fri, 24 Sep 2021 09:42:20 +0200 Subject: [PATCH 008/465] mgm 2 lis3 chip select opened by name --- bsp_q7s/core/ObjectFactory.cpp | 8 ++++++-- fsfw | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 1fbf9a33..6d6358c3 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -1,3 +1,5 @@ +#include + #include "ObjectFactory.h" #include "OBSWConfig.h" #include "devConf.h" @@ -414,8 +416,10 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI gpioCookieAcsBoard->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); // auto gpioChip = new GpiodRegularByChip(q7s::GPIO_MGM2_LIS3_LABEL, q7s::GPIO_MGM_2_LIS3_CS, // "CS_MGM_2_LIS3_B", gpio::OUT, gpio::HIGH); - auto gpioByLineName = new GpiodRegularByLineName("mgm_2_lis3_chip_select", "LIS3 Handler", gpio::OUT, - gpio::HIGH); + std::stringstream consumer; + consumer << std::hex << objects::MGM_2_LIS3_HANDLER; + auto gpioByLineName = new GpiodRegularByLineName("mgm_2_lis3_chip_select", consumer.str(), + gpio::OUT, gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::MGM_2_LIS3_CS, gpioByLineName); gpio = new GpiodRegularByLabel(q7s::GPIO_ACS_BOARD_DEFAULT_LABEL, q7s::GPIO_MGM_3_RM3100_CS, "CS_MGM_3_RM3100_B", gpio::OUT, gpio::HIGH); diff --git a/fsfw b/fsfw index c9b343eb..e7df5207 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit c9b343ebcd92de1d214a9b1d7abafee4a7e79888 +Subproject commit e7df520780242f98f9a1189906c0ade1a8a99f29 From 9fd4c477f06084392f159ba94390c4015a8155d9 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Sat, 25 Sep 2021 10:49:03 +0200 Subject: [PATCH 009/465] changed all gpio configurations to open by line name --- bsp_q7s/boardconfig/busConf.h | 37 ++++ bsp_q7s/core/ObjectFactory.cpp | 208 +++++++++++------- bsp_q7s/gpio/gpioCallbacks.cpp | 25 +-- fsfw | 2 +- .../pollingSequenceFactory.cpp | 4 +- 5 files changed, 173 insertions(+), 103 deletions(-) diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index a86a6c79..c78125ea 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -95,6 +95,43 @@ static constexpr uint32_t SPI_MUX_BIT_5 = 17; static constexpr uint32_t SPI_MUX_BIT_6 = 9; static constexpr uint32_t EN_RW_CS = 17; +namespace gpioNames { + static constexpr char GYRO_0_ADIS_CS[] = "gyro_0_adis_chip_select"; + static constexpr char GYRO_1_L3G_CS[] = "gyro_1_l3g_chip_select"; + static constexpr char GYRO_2_ADIS_CS[] = "gyro_2_adis_chip_select"; + static constexpr char GYRO_3_L3G_CS[] = "gyro_3_l3g_chip_select"; + static constexpr char MGM_0_CS[] = "mgm_0_lis3_chip_select"; + static constexpr char MGM_1_CS[] = "mgm_1_rm3100_chip_select"; + static constexpr char MGM_2_CS[] = "mgm_2_lis3_chip_select"; + static constexpr char MGM_3_CS[] = "mgm_3_rm3100_chip_select"; + static constexpr char RESET_GNSS_0[] = "reset_gnss_0"; + static constexpr char RESET_GNSS_1[] = "reset_gnss_1"; + static constexpr char GYRO_0_ENABLE[] = "gyro_0_enable"; + static constexpr char GYRO_2_ENABLE[] = "gyro_2_enable"; + static constexpr char HEATER_0[] = "heater0"; + static constexpr char HEATER_1[] = "heater1"; + static constexpr char HEATER_2[] = "heater2"; + static constexpr char HEATER_3[] = "heater3"; + static constexpr char HEATER_4[] = "heater4"; + static constexpr char HEATER_5[] = "heater5"; + static constexpr char HEATER_6[] = "heater6"; + static constexpr char HEATER_7[] = "heater7"; + static constexpr char SA_DPL_PIN_0[] = "sa_dpl_0"; + static constexpr char SA_DPL_PIN_1[] = "sa_dpl_1"; + static constexpr char SPI_MUX_BIT_1_PIN[] = "spi_mux_bit_1"; + static constexpr char SPI_MUX_BIT_2_PIN[] = "spi_mux_bit_2"; + static constexpr char SPI_MUX_BIT_3_PIN[] = "spi_mux_bit_3"; + static constexpr char SPI_MUX_BIT_4_PIN[] = "spi_mux_bit_4"; + static constexpr char SPI_MUX_BIT_5_PIN[] = "spi_mux_bit_5"; + static constexpr char SPI_MUX_BIT_6_PIN[] = "spi_mux_bit_6"; + static constexpr char EN_RW_CS[] = "en_rw_cs"; + static constexpr char EN_RW_1[] = "enable_rw_1"; + static constexpr char EN_RW_2[] = "enable_rw_2"; + static constexpr char EN_RW_3[] = "enable_rw_3"; + static constexpr char EN_RW_4[] = "enable_rw_4"; + static constexpr char SPI_MUX_SELECT[] = "spi_mux_select"; + static constexpr char RAD_SENSOR_CHIP_SELECT[] = "rad_sensor_chip_select"; +} } #endif /* BSP_Q7S_BOARDCONFIG_BUSCONF_H_ */ diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 6d6358c3..44b27890 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -267,9 +267,11 @@ void ObjectFactory::createPcduComponents() { void ObjectFactory::createRadSensorComponent(LinuxLibgpioIF* gpioComIF) { GpioCookie* gpioCookieRadSensor = new GpioCookie; - auto chipSelectRadSensor = new GpiodRegularByLabel(q7s::GPIO_RAD_SENSOR_LABEL, - q7s::GPIO_RAD_SENSOR_CS, "Chip Select Radiation Sensor", gpio::OUT, gpio::HIGH); - gpioCookieRadSensor->addGpio(gpioIds::CS_RAD_SENSOR, chipSelectRadSensor); + std::stringstream consumer; + consumer << "0x" << std::hex << objects::RAD_SENSOR; + GpiodRegularByLineName* gpio = new GpiodRegularByLineName( + q7s::gpioNames::RAD_SENSOR_CHIP_SELECT, consumer.str(), gpio::OUT, gpio::HIGH); + gpioCookieRadSensor->addGpio(gpioIds::CS_RAD_SENSOR, gpio); gpioComIF->addGpios(gpioCookieRadSensor); SpiCookie* spiCookieRadSensor = new SpiCookie(addresses::RAD_SENSOR, gpioIds::CS_RAD_SENSOR, @@ -394,51 +396,79 @@ void ObjectFactory::createSunSensorComponents(LinuxLibgpioIF *gpioComIF, SpiComI void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComIF* uartComIF) { GpioCookie* gpioCookieAcsBoard = new GpioCookie(); - GpiodRegularByLabel* gpio = nullptr; - gpio = new GpiodRegularByLabel(q7s::GPIO_GYRO_ADIS_LABEL, q7s::GPIO_GYRO_0_ADIS_CS, - "CS_GYRO_0_ADIS", gpio::OUT, gpio::HIGH); + + std::stringstream consumer; + GpiodRegularByLineName* gpio = nullptr; + consumer << "0x" << std::hex << objects::GYRO_0_ADIS_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ADIS_CS, consumer.str(), gpio::OUT, gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); - gpio = new GpiodRegularByLabel(q7s::GPIO_ACS_BOARD_DEFAULT_LABEL, q7s::GPIO_GYRO_1_L3G_CS, - "CS_GYRO_1_L3G", gpio::OUT, gpio::HIGH); + + consumer.str(""); + consumer << "0x" << std::hex << objects::GYRO_1_L3G_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_1_L3G_CS, consumer.str(), gpio::OUT, + gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); - gpio = new GpiodRegularByLabel(q7s::GPIO_GYRO_ADIS_LABEL, q7s::GPIO_GYRO_2_ADIS_CS, - "CS_GYRO_2_ADIS", gpio::OUT, gpio::HIGH); + + consumer.str(""); + consumer << "0x" << std::hex << objects::GYRO_2_ADIS_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ADIS_CS, consumer.str(), gpio::OUT, + gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::GYRO_2_ADIS_CS, gpio); - gpio = new GpiodRegularByLabel(q7s::GPIO_ACS_BOARD_DEFAULT_LABEL, q7s::GPIO_GYRO_3_L3G_CS, - "CS_GYRO_3_L3G", gpio::OUT, gpio::HIGH); + + consumer.str(""); + consumer << "0x" << std::hex << objects::GYRO_3_L3G_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_3_L3G_CS, consumer.str(), gpio::OUT, + gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); - gpio = new GpiodRegularByLabel(q7s::GPIO_ACS_BOARD_DEFAULT_LABEL, q7s::GPIO_MGM_0_LIS3_CS, - "CS_MGM_0_LIS3_A", gpio::OUT, gpio::HIGH); + consumer.str(""); + consumer << "0x" << std::hex << objects::MGM_0_LIS3_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_0_CS, consumer.str(), gpio::OUT, + gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); - gpio = new GpiodRegularByLabel(q7s::GPIO_ACS_BOARD_DEFAULT_LABEL, q7s::GPIO_MGM_1_RM3100_CS, - "CS_MGM_1_RM3100_A", gpio::OUT, gpio::HIGH); + + consumer.str(""); + consumer << "0x" << std::hex << objects::MGM_1_RM3100_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, consumer.str(), gpio::OUT, + gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); -// auto gpioChip = new GpiodRegularByChip(q7s::GPIO_MGM2_LIS3_LABEL, q7s::GPIO_MGM_2_LIS3_CS, -// "CS_MGM_2_LIS3_B", gpio::OUT, gpio::HIGH); - std::stringstream consumer; - consumer << std::hex << objects::MGM_2_LIS3_HANDLER; - auto gpioByLineName = new GpiodRegularByLineName("mgm_2_lis3_chip_select", consumer.str(), + + consumer.str(""); + consumer << "0x" << std::hex << objects::MGM_2_LIS3_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_2_CS, consumer.str(), gpio::OUT, gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::MGM_2_LIS3_CS, gpioByLineName); - gpio = new GpiodRegularByLabel(q7s::GPIO_ACS_BOARD_DEFAULT_LABEL, q7s::GPIO_MGM_3_RM3100_CS, - "CS_MGM_3_RM3100_B", gpio::OUT, gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); + + consumer.str(""); + consumer << "0x" << std::hex << objects::MGM_3_RM3100_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_3_CS, consumer.str(), gpio::OUT, + gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GPS0_HANDLER; // GNSS reset pins are active low - gpio = new GpiodRegularByLabel(q7s::GPIO_ACS_BOARD_DEFAULT_LABEL, q7s::GPIO_RESET_GNSS_0, - "GNSS_0_NRESET", gpio::OUT, gpio::HIGH); + gpio = new GpiodRegularByLineName(q7s::gpioNames::RESET_GNSS_0, consumer.str(), gpio::OUT, + gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::GNSS_0_NRESET, gpio); - gpio = new GpiodRegularByLabel(q7s::GPIO_ACS_BOARD_DEFAULT_LABEL, q7s::GPIO_RESET_GNSS_1, - "GNSS_1_NRESET", gpio::OUT, gpio::HIGH); + + consumer.str(""); + consumer << "0x" << std::hex << objects::GPS1_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::RESET_GNSS_1, consumer.str(), gpio::OUT, + gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::GNSS_1_NRESET, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GYRO_0_ADIS_HANDLER; // Enable pins must be pulled low for regular operations - gpio = new GpiodRegularByLabel(q7s::GPIO_FLEX_OBC1F_B0, q7s::GPIO_GYRO_0_ENABLE, - "GYRO_0_ENABLE", gpio::OUT, gpio::LOW); + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, consumer.str(), + gpio::OUT, gpio::LOW); gpioCookieAcsBoard->addGpio(gpioIds::GYRO_0_ENABLE, gpio); - gpio = new GpiodRegularByLabel(q7s::GPIO_3V3_OBC1C, q7s::GPIO_GYRO_2_ENABLE, - "GYRO_2_ENABLE", gpio::OUT, gpio::LOW); + + consumer.str(""); + consumer << "0x" << std::hex << objects::GYRO_2_ADIS_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ENABLE, consumer.str(), gpio::OUT, + gpio::LOW); gpioCookieAcsBoard->addGpio(gpioIds::GYRO_2_ENABLE, gpio); // TODO: Add enable pins for GPS as soon as new interface board design is finished @@ -546,40 +576,43 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI void ObjectFactory::createHeaterComponents() { GpioCookie* heaterGpiosCookie = new GpioCookie; + GpiodRegularByLineName* gpio = nullptr; + std::stringstream consumer; + consumer << "0x" << std::hex << objects::HEATER_HANDLER; /* Pin H2-11 on stack connector */ - auto gpioConfigHeater0 = new GpiodRegularByLabel(q7s::GPIO_HEATER_LABEL, q7s::GPIO_HEATER_0_PIN, - "Heater0", gpio::OUT, gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_0, gpioConfigHeater0); + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_0, consumer.str(), gpio::OUT, + gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_0, gpio); /* Pin H2-12 on stack connector */ - auto gpioConfigHeater1 = new GpiodRegularByLabel(q7s::GPIO_HEATER_LABEL, q7s::GPIO_HEATER_1_PIN, - "Heater1", gpio::OUT, gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_1, gpioConfigHeater1); + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_1, consumer.str(), gpio::OUT, + gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_1, gpio); /* Pin H2-13 on stack connector */ - auto gpioConfigHeater2 = new GpiodRegularByLabel(q7s::GPIO_HEATER_LABEL, q7s::GPIO_HEATER_2_PIN, - "Heater2", gpio::OUT, gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_2, gpioConfigHeater2); + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_2, consumer.str(), gpio::OUT, + gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_2, gpio); - auto gpioConfigHeater3 = new GpiodRegularByLabel(q7s::GPIO_HEATER_LABEL, q7s::GPIO_HEATER_3_PIN, - "Heater3", gpio::OUT, gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_3, gpioConfigHeater3); + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_3, consumer.str(), + gpio::OUT, gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_3, gpio); - auto gpioConfigHeater4 = new GpiodRegularByLabel(q7s::GPIO_HEATER_LABEL, q7s::GPIO_HEATER_4_PIN, - "Heater4", gpio::OUT, gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_4, gpioConfigHeater4); + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_4, consumer.str(), + gpio::OUT, gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_4, gpio); - auto gpioConfigHeater5 = new GpiodRegularByLabel(q7s::GPIO_HEATER_LABEL, q7s::GPIO_HEATER_5_PIN, - "Heater5", gpio::OUT, gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_5, gpioConfigHeater5); + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_5, consumer.str(), + gpio::OUT, gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_5, gpio); - auto gpioConfigHeater6 = new GpiodRegularByLabel(q7s::GPIO_HEATER_LABEL, q7s::GPIO_HEATER_6_PIN, - "Heater6", gpio::OUT, gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_6, gpioConfigHeater6); + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_6, consumer.str(), + gpio::OUT, gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_6, gpio); - auto gpioConfigHeater7 = new GpiodRegularByLabel(q7s::GPIO_HEATER_LABEL, q7s::GPIO_HEATER_7_PIN, - "Heater7", gpio::OUT, gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_7, gpioConfigHeater7); + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_7, consumer.str(), + gpio::OUT, gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_7, gpio); new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, heaterGpiosCookie, objects::PCDU_HANDLER, pcduSwitches::TCS_BOARD_8V_HEATER_IN); @@ -587,13 +620,16 @@ void ObjectFactory::createHeaterComponents() { void ObjectFactory::createSolarArrayDeploymentComponents() { GpioCookie* solarArrayDeplCookie = new GpioCookie; + GpiodRegularByLineName* gpio = nullptr; - auto gpioConfigDeplSA0 = new GpiodRegularByLabel(q7s::GPIO_SOLAR_ARR_DEPL_LABEL, - q7s::GPIO_SOL_DEPL_SA_0_PIN, "DeplSA0", gpio::OUT, gpio::LOW); - solarArrayDeplCookie->addGpio(gpioIds::DEPLSA1, gpioConfigDeplSA0); - auto gpioConfigDeplSA1 = new GpiodRegularByLabel(q7s::GPIO_SOLAR_ARR_DEPL_LABEL, - q7s::GPIO_SOL_DEPL_SA_1_PIN, "DeplSA1", gpio::OUT, gpio::LOW); - solarArrayDeplCookie->addGpio(gpioIds::DEPLSA2, gpioConfigDeplSA1); + std::stringstream consumer; + consumer << "0x" << std::hex << objects::SOLAR_ARRAY_DEPL_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::SA_DPL_PIN_0, + consumer.str(), gpio::OUT, gpio::LOW); + solarArrayDeplCookie->addGpio(gpioIds::DEPLSA1, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::SA_DPL_PIN_1, consumer.str(), gpio::OUT, + gpio::LOW); + solarArrayDeplCookie->addGpio(gpioIds::DEPLSA2, gpio); //TODO: Find out burn time. For now set to 1000 ms. new SolarArrayDeploymentHandler(objects::SOLAR_ARRAY_DEPL_HANDLER, objects::GPIO_IF, @@ -772,35 +808,36 @@ void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF) { &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieRw->addGpio(gpioIds::CS_RW4, csRw4); -// GpiodRegular* enRw1 = new GpiodRegular("Enable reaction wheel 1", gpio::OUT, 0, -// q7s::GPIO_RW_DEFAULT_LABEL, q7s::GPIO_RW_0_CS); -// gpioCookieRw->addGpio(gpioIds::EN_RW1, enRw1); -// GpiodRegular* enRw2 = new GpiodRegular("Enable reaction wheel 2", gpio::OUT, 0, -// q7s::GPIO_RW_DEFAULT_LABEL, q7s::GPIO_RW_1_CS); -// gpioCookieRw->addGpio(gpioIds::EN_RW2, enRw2); -// GpiodRegular* enRw3 = new GpiodRegular(, gpio::OUT, 0, -// q7s::GPIO_RW_DEFAULT_LABEL, q7s::GPIO_RW_2_CS); - auto enRw1 = new GpiodRegularByLabel(q7s::GPIO_RW_DEFAULT_LABEL, q7s::GPIO_RW_0_CS, - "Enable reaction wheel 1", gpio::OUT, gpio::LOW); - gpioCookieRw->addGpio(gpioIds::EN_RW1, enRw1); - auto enRw2 = new GpiodRegularByLabel(q7s::GPIO_RW_DEFAULT_LABEL, q7s::GPIO_RW_1_CS, - "Enable reaction wheel 2", gpio::OUT, gpio::LOW); - gpioCookieRw->addGpio(gpioIds::EN_RW2, enRw2); - auto enRw3 = new GpiodRegularByLabel(q7s::GPIO_RW_DEFAULT_LABEL, q7s::GPIO_RW_2_CS, - "Enable reaction wheel 3", gpio::OUT, gpio::LOW); - gpioCookieRw->addGpio(gpioIds::EN_RW3, enRw3); - auto enRw4 = new GpiodRegularByLabel(q7s::GPIO_RW_DEFAULT_LABEL, q7s::GPIO_RW_3_CS, - "Enable reaction wheel 4", gpio::OUT, gpio::LOW); - gpioCookieRw->addGpio(gpioIds::EN_RW4, enRw4); + std::stringstream consumer; + GpiodRegularByLineName* gpio = nullptr; + consumer << "0x" << std::hex << objects::RW1; + gpio = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_1, consumer.str(), gpio::OUT, + gpio::LOW); + gpioCookieRw->addGpio(gpioIds::EN_RW1, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::RW2; + gpio = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_2, consumer.str(), gpio::OUT, + gpio::LOW); + gpioCookieRw->addGpio(gpioIds::EN_RW2, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::RW3; + gpio = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_3, consumer.str(), gpio::OUT, + gpio::LOW); + gpioCookieRw->addGpio(gpioIds::EN_RW3, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::RW4; + gpio = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_4, consumer.str(), gpio::OUT, + gpio::LOW); + gpioCookieRw->addGpio(gpioIds::EN_RW4, gpio); /** * This GPIO is only internally connected to the SPI MUX module and responsible to disconnect * the PS SPI peripheral from the SPI interface and route out the SPI lines of the AXI SPI core. * Per default the PS SPI is selected (EMIO = 0). */ - auto spiMux = new GpiodRegularByLabel(q7s::GPIO_RW_SPI_MUX_LABEL, - q7s::GPIO_RW_SPI_MUX_CS, "EMIO 0 SPI Mux", gpio::OUT, gpio::LOW); - gpioCookieRw->addGpio(gpioIds::SPI_MUX, spiMux); + gpio = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_SELECT, + "SPI Reaction Wheel Callback ", gpio::OUT, gpio::LOW); + gpioCookieRw->addGpio(gpioIds::SPI_MUX, gpio); gpioComIF->addGpios(gpioCookieRw); @@ -820,6 +857,7 @@ void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF) { auto rwHandler1 = new RwHandler(objects::RW1, objects::SPI_COM_IF, rw1SpiCookie, gpioComIF, gpioIds::EN_RW1); rw1SpiCookie->setCallbackArgs(rwHandler1); + rwHandler1->setStartUpImmediately(); auto rwHandler2 = new RwHandler(objects::RW2, objects::SPI_COM_IF, rw2SpiCookie, gpioComIF, gpioIds::EN_RW2); diff --git a/bsp_q7s/gpio/gpioCallbacks.cpp b/bsp_q7s/gpio/gpioCallbacks.cpp index da7c58e4..3787c829 100644 --- a/bsp_q7s/gpio/gpioCallbacks.cpp +++ b/bsp_q7s/gpio/gpioCallbacks.cpp @@ -24,31 +24,26 @@ void initSpiCsDecoder(GpioIF* gpioComIF) { GpioCookie* spiMuxGpios = new GpioCookie; - GpiodRegularByLabel* spiMuxBit = nullptr; + GpiodRegularByLineName* spiMuxBit = nullptr; /** Setting mux bit 1 to low will disable IC21 on the interface board */ - spiMuxBit = new GpiodRegularByLabel(q7s::GPIO_3V3_OBC1C, q7s::SPI_MUX_BIT_1, - "SPI Mux Bit 1", gpio::OUT, gpio::LOW); + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_1_PIN, "SPI Mux Bit 1", + gpio::OUT, gpio::LOW); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_1, spiMuxBit); /** Setting mux bit 2 to low disables IC1 on the TCS board */ - spiMuxBit = new GpiodRegularByLabel(q7s::GPIO_3V3_OBC1C, q7s::SPI_MUX_BIT_2, - "SPI Mux Bit 2", gpio::OUT, gpio::LOW); + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_2_PIN, "SPI Mux Bit 2", gpio::OUT, gpio::LOW); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_2, spiMuxBit); /** Setting mux bit 3 to low disables IC2 on the TCS board and IC22 on the interface board */ - spiMuxBit = new GpiodRegularByLabel(q7s::GPIO_3V3_OBC1C, q7s::SPI_MUX_BIT_3, - "SPI Mux Bit 3", gpio::OUT, gpio::LOW); + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_3_PIN, "SPI Mux Bit 3", gpio::OUT, gpio::LOW); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_3, spiMuxBit); /** The following gpios can take arbitrary initial values */ - spiMuxBit = new GpiodRegularByLabel(q7s::GPIO_3V3_OBC1C, q7s::SPI_MUX_BIT_4, - "SPI Mux Bit 4", gpio::OUT, gpio::LOW); + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_4_PIN, "SPI Mux Bit 4", gpio::OUT, gpio::LOW); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_4, spiMuxBit); - spiMuxBit = new GpiodRegularByLabel(q7s::GPIO_3V3_OBC1C, q7s::SPI_MUX_BIT_5, - "SPI Mux Bit 5", gpio::OUT, gpio::LOW); + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_5_PIN, "SPI Mux Bit 5", gpio::OUT, gpio::LOW); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_5, spiMuxBit); - spiMuxBit = new GpiodRegularByLabel(q7s::GPIO_3V3_OBC1C, q7s::SPI_MUX_BIT_6, - "SPI Mux Bit 6", gpio::OUT, gpio::LOW); + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_6_PIN, "SPI Mux Bit 6", gpio::OUT, gpio::LOW); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_6, spiMuxBit); - GpiodRegularByLabel* enRwDecoder = new GpiodRegularByLabel(q7s::GPIO_FLEX_OBC1F_B1, - q7s::EN_RW_CS, "EN_RW_CS", gpio::OUT, gpio::HIGH); + GpiodRegularByLineName* enRwDecoder = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_CS, + "EN_RW_CS", gpio::OUT, gpio::HIGH); spiMuxGpios->addGpio(gpioIds::EN_RW_CS, enRwDecoder); result = gpioComInterface->addGpios(spiMuxGpios); diff --git a/fsfw b/fsfw index e7df5207..16b125ef 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit e7df520780242f98f9a1189906c0ade1a8a99f29 +Subproject commit 16b125ef6cdfbe1349e5b21b783cd72c871372a8 diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 3b826119..642199da 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -439,8 +439,8 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { #endif #if OBSW_ADD_ACS_BOARD == 1 - bool enableAside = true; - bool enableBside = false; + bool enableAside = false; + bool enableBside = true; if(enableAside) { // A side thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0, From f0885fcb2ebbee0f9c168efc9a20a1a7f67f1104 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Sat, 25 Sep 2021 11:09:29 +0200 Subject: [PATCH 010/465] removed unused gpio definitions in busConf.h --- bsp_q7s/boardconfig/busConf.h | 79 -------------------------------- linux/boardtest/SpiTestClass.cpp | 46 ++++++++----------- linux/boardtest/SpiTestClass.h | 9 ---- 3 files changed, 20 insertions(+), 114 deletions(-) diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index c78125ea..1149a54e 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -16,85 +16,6 @@ static constexpr char UART_STAR_TRACKER_DEV[] = "/dev/ttyUL8"; static constexpr char UART_GNSS_0_DEV[] = "/dev/ttyUL0"; static constexpr char UART_GNSS_1_DEV[] = "/dev/ttyUL2"; -/**************************************************************/ -/** OBC1E */ -/**************************************************************/ -static constexpr char GPIO_MULTIPURPOSE_1V8_OBC1D[] = "/amba_pl/gpio@42020000"; -static const char* const GPIO_GYRO_ADIS_LABEL = GPIO_MULTIPURPOSE_1V8_OBC1D; -static constexpr uint32_t GPIO_GYRO_0_ADIS_CS = 0; // Package Pin: W20 -static constexpr uint32_t GPIO_GYRO_2_ADIS_CS = 2; // AA22 - -/**************************************************************/ -/** OBC1F B0 */ -/**************************************************************/ -static constexpr char GPIO_FLEX_OBC1F_B0[] = "/amba_pl/gpio@42030000"; -static constexpr uint32_t GPIO_FLEX_OBC1F_B0_WIDTH = 20; -static const char* const GPIO_ACS_BOARD_DEFAULT_LABEL = GPIO_FLEX_OBC1F_B0; -static const char* const GPIO_RW_DEFAULT_LABEL = GPIO_FLEX_OBC1F_B0; -static const char* const GPIO_RAD_SENSOR_LABEL = GPIO_FLEX_OBC1F_B0; - - -static constexpr uint32_t GPIO_RW_0_CS = 7; // B20 -static constexpr uint32_t GPIO_RW_1_CS = 3; // G22 -static constexpr uint32_t GPIO_RW_2_CS = 11; // E18 -static constexpr uint32_t GPIO_RW_3_CS = 6; // B19 - -static constexpr uint32_t GPIO_GYRO_1_L3G_CS = 18; // N22 -static constexpr uint32_t GPIO_GYRO_3_L3G_CS = 1; // M21 -static constexpr uint32_t GPIO_MGM_0_LIS3_CS = 5; // C18 -static constexpr uint32_t GPIO_MGM_1_RM3100_CS = 16; // A16 -static constexpr uint32_t GPIO_MGM_3_RM3100_CS = 10; // C17 - -// Active low enable pin (needs to be driven low for regular operations) -static constexpr uint32_t GPIO_GYRO_0_ENABLE = 2; // H22 - -// Active low reset pin (needs to be driven high for regular operations) -static constexpr uint32_t GPIO_RESET_GNSS_0 = 9; // C22 -static constexpr uint32_t GPIO_RESET_GNSS_1 = 12; // B21 - -static constexpr uint32_t GPIO_RAD_SENSOR_CS = 19; // R18 - -/**************************************************************/ -/** OBC1F B1 */ -/**************************************************************/ -static constexpr char GPIO_FLEX_OBC1F_B1[] = "/amba_pl/gpio@42030000"; -// Need to use chip name here for now because the label name is the name for -// gpiochip 5 and gpiochip6 -static constexpr char GPIO_FLEX_OBC1F_B1_CHIP[] = "gpiochip6"; -static const char* const GPIO_MGM2_LIS3_LABEL = GPIO_FLEX_OBC1F_B1_CHIP; -static constexpr uint32_t GPIO_MGM_2_LIS3_CS = 0; // D18 - -/**************************************************************/ -/** OBC1C */ -/**************************************************************/ -static constexpr char GPIO_3V3_OBC1C[] = "/amba_pl/gpio@42040000"; -static const char* const GPIO_HEATER_LABEL = GPIO_3V3_OBC1C; -static const char* const GPIO_SOLAR_ARR_DEPL_LABEL = GPIO_3V3_OBC1C; -static constexpr uint32_t GPIO_HEATER_0_PIN = 6; -static constexpr uint32_t GPIO_HEATER_1_PIN = 12; -static constexpr uint32_t GPIO_HEATER_2_PIN = 7; -static constexpr uint32_t GPIO_HEATER_3_PIN = 5; -static constexpr uint32_t GPIO_HEATER_4_PIN = 3; -static constexpr uint32_t GPIO_HEATER_5_PIN = 0; -static constexpr uint32_t GPIO_HEATER_6_PIN = 1; -static constexpr uint32_t GPIO_HEATER_7_PIN = 11; -static constexpr uint32_t GPIO_GYRO_2_ENABLE = 18; // F22 - -static constexpr uint32_t GPIO_SOL_DEPL_SA_0_PIN = 4; -static constexpr uint32_t GPIO_SOL_DEPL_SA_1_PIN = 2; - -static constexpr char GPIO_RW_SPI_MUX_LABEL[] = "zynq_gpio"; -// Uses EMIO interface to PL, starts at 54 -static constexpr uint32_t GPIO_RW_SPI_MUX_CS = 54; - -static constexpr uint32_t SPI_MUX_BIT_1 = 13; -static constexpr uint32_t SPI_MUX_BIT_2 = 14; -static constexpr uint32_t SPI_MUX_BIT_3 = 15; -static constexpr uint32_t SPI_MUX_BIT_4 = 16; -static constexpr uint32_t SPI_MUX_BIT_5 = 17; -static constexpr uint32_t SPI_MUX_BIT_6 = 9; -static constexpr uint32_t EN_RW_CS = 17; - namespace gpioNames { static constexpr char GYRO_0_ADIS_CS[] = "gyro_0_adis_chip_select"; static constexpr char GYRO_1_L3G_CS[] = "gyro_1_l3g_chip_select"; diff --git a/linux/boardtest/SpiTestClass.cpp b/linux/boardtest/SpiTestClass.cpp index 8a340ecb..5168ba95 100644 --- a/linux/boardtest/SpiTestClass.cpp +++ b/linux/boardtest/SpiTestClass.cpp @@ -206,12 +206,6 @@ void SpiTestClass::performL3gTest(uint8_t l3gId) { /* Configure all SPI chip selects and pull them high */ acsInit(); - l3gId = gyro1L3gd20ChipSelect; - - /* Adapt accordingly */ - if(l3gId != gyro1L3gd20ChipSelect and l3gId != gyro3L3gd20ChipSelect) { - sif::warning << "SpiTestClass::performLis3MdlTest: Invalid MGM ID!" << std::endl; - } gpioId_t currentGpioId = 0; uint8_t chipSelectPin = l3gId; uint8_t whoAmIReg = 0b0000'1111; @@ -330,39 +324,39 @@ void SpiTestClass::acsInit() { gpio::Direction::OUT, 1); gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); #elif defined(XIPHOS_Q7S) - GpiodRegularByLabel* gpio = nullptr; - gpio = new GpiodRegularByLabel(q7s::GPIO_ACS_BOARD_DEFAULT_LABEL, mgm0Lis3mdlChipSelect, - "MGM_0_LIS3", gpio::Direction::OUT, gpio::HIGH); + GpiodRegularByLineName* gpio = nullptr; + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_0_CS, "MGM_0_LIS3", gpio::Direction::OUT, + gpio::HIGH); gpioCookie->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); - gpio = new GpiodRegularByLabel(q7s::GPIO_ACS_BOARD_DEFAULT_LABEL, mgm1Rm3100ChipSelect, - "MGM_1_RM3100", gpio::Direction::OUT, gpio::HIGH); + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, "MGM_1_RM3100", gpio::Direction::OUT, + gpio::HIGH); gpioCookie->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); - gpio = new GpiodRegularByLabel(q7s::GPIO_MGM2_LIS3_LABEL, mgm2Lis3mdlChipSelect, - "MGM_2_LIS3", gpio::Direction::OUT, gpio::HIGH); + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_2_CS, "MGM_2_LIS3", gpio::Direction::OUT, + gpio::HIGH); gpioCookie->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); - gpio = new GpiodRegularByLabel(q7s::GPIO_ACS_BOARD_DEFAULT_LABEL, mgm3Rm3100ChipSelect, - "MGM_3_RM3100", gpio::Direction::OUT, gpio::HIGH); + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, "MGM_3_RM3100", gpio::Direction::OUT, + gpio::HIGH); gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); - gpio = new GpiodRegularByLabel(q7s::GPIO_GYRO_ADIS_LABEL, gyro0AdisChipSelect, - "GYRO_0_ADIS", gpio::Direction::OUT, gpio::HIGH); + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ADIS_CS, "GYRO_0_ADIS", + gpio::Direction::OUT, gpio::HIGH); gpioCookie->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); - gpio = new GpiodRegularByLabel(q7s::GPIO_ACS_BOARD_DEFAULT_LABEL, gyro1L3gd20ChipSelect, - "GYRO_1_L3G", gpio::Direction::OUT, gpio::HIGH); + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_1_L3G_CS, "GYRO_1_L3G", gpio::Direction::OUT, + gpio::HIGH); gpioCookie->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); - gpio = new GpiodRegularByLabel(q7s::GPIO_GYRO_ADIS_LABEL, gyro2AdisChipSelect, "GYRO_2_ADIS", + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ADIS_CS, "GYRO_2_ADIS", gpio::Direction::OUT, gpio::HIGH); gpioCookie->addGpio(gpioIds::GYRO_2_ADIS_CS, gpio); - gpio = new GpiodRegularByLabel(q7s::GPIO_ACS_BOARD_DEFAULT_LABEL, gyro3L3gd20ChipSelect, - "GYRO_3_L3G", gpio::Direction::OUT, gpio::HIGH); + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_3_L3G_CS, "GYRO_3_L3G", gpio::Direction::OUT, + gpio::HIGH); gpioCookie->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); // Enable pins must be pulled low for regular operations - gpio = new GpiodRegularByLabel(q7s::GPIO_FLEX_OBC1F_B0, q7s::GPIO_GYRO_0_ENABLE, - "GYRO_0_ENABLE", gpio::OUT, gpio::LOW); + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, "GYRO_0_ENABLE", gpio::OUT, + gpio::LOW); gpioCookie->addGpio(gpioIds::GYRO_0_ENABLE, gpio); - gpio = new GpiodRegularByLabel(q7s::GPIO_3V3_OBC1C, q7s::GPIO_GYRO_2_ENABLE, - "GYRO_2_ENABLE", gpio::OUT, gpio::LOW); + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, "GYRO_2_ENABLE", gpio::OUT, + gpio::LOW); gpioCookie->addGpio(gpioIds::GYRO_2_ENABLE, gpio); #endif if (gpioIF != nullptr) { diff --git a/linux/boardtest/SpiTestClass.h b/linux/boardtest/SpiTestClass.h index 45a7cdd8..ffd56dd1 100644 --- a/linux/boardtest/SpiTestClass.h +++ b/linux/boardtest/SpiTestClass.h @@ -54,15 +54,6 @@ private: uint8_t gyro1L3gd20ChipSelect = gpio::GYRO_1_BCM_PIN; uint8_t gyro2AdisChipSelect = gpio::GYRO_2_BCM_PIN; uint8_t gyro3L3gd20ChipSelect = gpio::GYRO_3_BCM_PIN; -#elif defined(XIPHOS_Q7S) - uint8_t mgm0Lis3mdlChipSelect = q7s::GPIO_MGM_0_LIS3_CS; - uint8_t mgm1Rm3100ChipSelect = q7s::GPIO_MGM_1_RM3100_CS; - uint8_t gyro0AdisChipSelect = q7s::GPIO_GYRO_0_ADIS_CS; - uint8_t gyro2AdisChipSelect = q7s::GPIO_GYRO_2_ADIS_CS; - uint8_t gyro1L3gd20ChipSelect = q7s::GPIO_GYRO_1_L3G_CS; - uint8_t gyro3L3gd20ChipSelect = q7s::GPIO_GYRO_3_L3G_CS; - uint8_t mgm2Lis3mdlChipSelect = q7s::GPIO_MGM_2_LIS3_CS; - uint8_t mgm3Rm3100ChipSelect = q7s::GPIO_MGM_3_RM3100_CS; #else uint8_t mgm0Lis3mdlChipSelect = 0; uint8_t mgm1Rm3100ChipSelect = 0; From c0dde1a0052dc364cb547cf8eebd7f2215aecaca Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 25 Sep 2021 16:38:39 +0200 Subject: [PATCH 011/465] define renamed --- fsfw | 2 +- linux/fsfwconfig/FSFWConfig.h.in | 2 +- mission/devices/GyroADIS16507Handler.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fsfw b/fsfw index dd610f0d..e0671a39 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit dd610f0d7edb3a152bec304b9b8452d1b5ea1f49 +Subproject commit e0671a395ebea9d2297b2096293db80a2e412f4a diff --git a/linux/fsfwconfig/FSFWConfig.h.in b/linux/fsfwconfig/FSFWConfig.h.in index 1b8251da..3b87078c 100644 --- a/linux/fsfwconfig/FSFWConfig.h.in +++ b/linux/fsfwconfig/FSFWConfig.h.in @@ -72,7 +72,7 @@ static constexpr size_t FSFW_MAX_TM_PACKET_SIZE = 2048; } -#define FSFW_HAL_LINUX_SPI_WIRETAPPING 0 +#define FSFW_HAL_SPI_WIRETAPPING 0 #define FSFW_DEV_HYPERION_GPS_CREATE_NMEA_CSV 0 #define FSFW_HAL_L3GD20_GYRO_DEBUG 0 diff --git a/mission/devices/GyroADIS16507Handler.cpp b/mission/devices/GyroADIS16507Handler.cpp index 02e69eaf..07e0d643 100644 --- a/mission/devices/GyroADIS16507Handler.cpp +++ b/mission/devices/GyroADIS16507Handler.cpp @@ -441,7 +441,7 @@ ReturnValue_t GyroADIS16507Handler::spiSendCallback(SpiComIF *comIf, SpiCookie * utility::handleIoctlError("SpiComIF::sendMessage: ioctl error."); result = SpiComIF::FULL_DUPLEX_TRANSFER_FAILED; } -#if FSFW_HAL_LINUX_SPI_WIRETAPPING == 1 +#if FSFW_HAL_SPI_WIRETAPPING == 1 comIf->performSpiWiretapping(cookie); #endif /* FSFW_LINUX_SPI_WIRETAPPING == 1 */ From 8dd58ed4fe3248393a5e09d453c0c5451333969f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 25 Sep 2021 16:42:58 +0200 Subject: [PATCH 012/465] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index e0671a39..2b6c9963 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit e0671a395ebea9d2297b2096293db80a2e412f4a +Subproject commit 2b6c996364be4aee65a1353bbe29d07604c4bdc8 From 5b26564058aba88f7160c9f0af19b0725b5261c5 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Sun, 26 Sep 2021 08:29:30 +0200 Subject: [PATCH 013/465] ptme ip core packet insertion --- bsp_q7s/boardconfig/busConf.h | 8 + bsp_q7s/core/ObjectFactory.cpp | 126 +++++--- bsp_q7s/core/ObjectFactory.h | 1 + common/config/ccsdsConfig.h | 15 + common/config/commonObjects.h | 7 +- linux/fsfwconfig/OBSWConfig.h.in | 5 + linux/obc/PapbVcInterface.cpp | 10 +- linux/obc/PapbVcInterface.h | 10 +- linux/obc/Ptme.cpp | 17 +- linux/obc/Ptme.h | 11 +- linux/obc/PtmeConfig.h | 2 +- linux/obc/PtmeIF.h | 2 +- linux/obc/VcInterfaceIF.h | 5 +- mission/CMakeLists.txt | 1 + mission/tmtc/CCSDSHandler.cpp | 500 ++++--------------------------- mission/tmtc/CCSDSHandler.h | 131 ++------ mission/tmtc/CMakeLists.txt | 6 + mission/tmtc/VirtualChannel.cpp | 30 +- mission/tmtc/VirtualChannel.h | 83 +---- mission/utility/TmFunnel.cpp | 4 +- 20 files changed, 252 insertions(+), 722 deletions(-) create mode 100644 common/config/ccsdsConfig.h create mode 100644 mission/tmtc/CMakeLists.txt diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index 1149a54e..4b64e775 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -52,6 +52,14 @@ namespace gpioNames { static constexpr char EN_RW_4[] = "enable_rw_4"; static constexpr char SPI_MUX_SELECT[] = "spi_mux_select"; static constexpr char RAD_SENSOR_CHIP_SELECT[] = "rad_sensor_chip_select"; + static constexpr char PAPB_BUSY_SIGNAL_VC0[] = "papb_busy_signal_vc0"; + static constexpr char PAPB_EMPTY_SIGNAL_VC0[] = "papb_empty_signal_vc0"; + static constexpr char PAPB_BUSY_SIGNAL_VC1[] = "papb_busy_signal_vc1"; + static constexpr char PAPB_EMPTY_SIGNAL_VC1[] = "papb_empty_signal_vc1"; + static constexpr char PAPB_BUSY_SIGNAL_VC2[] = "papb_busy_signal_vc2"; + static constexpr char PAPB_EMPTY_SIGNAL_VC2[] = "papb_empty_signal_vc2"; + static constexpr char PAPB_BUSY_SIGNAL_VC3[] = "papb_busy_signal_vc3"; + static constexpr char PAPB_EMPTY_SIGNAL_VC3[] = "papb_empty_signal_vc3"; } } diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index a5a76f8b..86709292 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -2,6 +2,7 @@ #include "ObjectFactory.h" #include "OBSWConfig.h" #include "devConf.h" +#include "ccsdsConfig.h" #include "busConf.h" #include "tmtc/apid.h" #include "devices/addresses.h" @@ -47,6 +48,8 @@ #include "mission/devices/devicedefinitions/RwDefinitions.h" #include "mission/devices/devicedefinitions/StarTrackerDefinitions.h" #include "mission/devices/GPSHyperionHandler.h" +#include "mission/tmtc/CCSDSHandler.h" +#include "mission/tmtc/VirtualChannel.h" #include "mission/utility/TmFunnel.h" #include "fsfw_hal/linux/uart/UartComIF.h" @@ -84,6 +87,7 @@ #include #include +#include ResetArgs resetArgsGnss0; ResetArgs resetArgsGnss1; @@ -101,7 +105,12 @@ void Factory::setStaticFrameworkObjectIds() { //DeviceHandlerBase::powerSwitcherId = objects::PCDU_HANDLER; DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT; + +#if OBSW_TM_TO_PTME == 1 + TmFunnel::downlinkDestination = objects::CCSDS_HANDLER; +#else TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; +#endif /* OBSW_TM_TO_PTME == 1 */ // No storage object for now. TmFunnel::storageDestination = objects::NO_OBJECT; @@ -174,53 +183,7 @@ void ObjectFactory::produce(void* args) { #endif /* TE7020 != 0 */ #if OBSW_USE_CCSDS_IP_CORE == 1 - - // GPIO definitions of signals connected to the virtual channel interfaces of the PTME IP Core - GpioCookie* gpioCookiePtmeIp = new GpioCookie; - GpiodRegular* vcSignal = new GpiodRegular("PAPB VC0 Busy Signal", - q7s::GPIO_VC_STATUS_SIGNALS_LABEL, q7s::VC0_PAPB_BUSY_LINE); - gpioCookiePtmeIp->addGpio(gpioIds::VC0_PAPB_BUSY, vcSignal); - vcSignal = new GpiodRegular("PAPB VC0 Empty Signal", q7s::GPIO_VC_STATUS_SIGNALS_LABEL, - q7s::VC0_PAPB_EMPTY_LINE); - gpioCookiePtmeIp->addGpio(gpioIds::VC0_PAPB_EMPTY, vcSignal); - vcSignal = new GpiodRegular("PAPB VC1 Busy Signal", q7s::GPIO_VC_STATUS_SIGNALS_LABEL, - q7s::VC1_PAPB_BUSY_LINE); - gpioCookiePtmeIp->addGpio(gpioIds::VC1_PAPB_BUSY, vcSignal); - vcSignal = new GpiodRegular("PAPB VC1 Empty Signal", q7s::GPIO_VC_STATUS_SIGNALS_LABEL, - q7s::VC1_PAPB_EMPTY_LINE); - gpioCookiePtmeIp->addGpio(gpioIds::VC1_PAPB_EMPTY, vcSignal); - vcSignal = new GpiodRegular("PAPB VC2 Busy Signal", q7s::GPIO_VC_STATUS_SIGNALS_LABEL, - q7s::VC2_PAPB_BUSY_LINE); - gpioCookiePtmeIp->addGpio(gpioIds::VC2_PAPB_BUSY, vcSignal); - vcSignal = new GpiodRegular("PAPB VC2 Empty Signal", q7s::GPIO_VC_STATUS_SIGNALS_LABEL, - q7s::VC2_PAPB_EMPTY_LINE); - gpioCookiePtmeIp->addGpio(gpioIds::VC2_PAPB_EMPTY, vcSignal); - vcSignal = new GpiodRegular("PAPB VC3 Busy Signal", q7s::GPIO_VC_STATUS_SIGNALS_LABEL, - q7s::VC3_PAPB_BUSY_LINE); - gpioCookiePtmeIp->addGpio(gpioIds::VC3_PAPB_BUSY, vcSignal); - vcSignal = new GpiodRegular("PAPB VC3 Empty Signal", q7s::GPIO_VC_STATUS_SIGNALS_LABEL, - q7s::VC3_PAPB_EMPTY_LINE); - gpioCookiePtmeIp->addGpio(gpioIds::VC3_PAPB_EMPTY, vcSignal); - - gpioComIF->addGpios(gpioCookiePtmeIp); - - // Creating virtual channel interfaces - PapbVcInterface* vc = new PapbVcInterface(objects::PAPB_VC0, gpioComIF, gpioIds::VC0_PAPB_BUSY, - gpioIds::VC0_PAPB_EMPTY); - PapbVcInterface* vc = new PapbVcInterface(objects::PAPB_VC1, gpioComIF, gpioIds::VC1_PAPB_BUSY, - gpioIds::VC1_PAPB_EMPTY); - PapbVcInterface* vc = new PapbVcInterface(objects::PAPB_VC2, gpioComIF, gpioIds::VC2_PAPB_BUSY, - gpioIds::VC2_PAPB_EMPTY); - PapbVcInterface* vc = new PapbVcInterface(objects::PAPB_VC3, gpioComIF, gpioIds::VC3_PAPB_BUSY, - gpioIds::VC3_PAPB_EMPTY); - - // Creating ptme object and adding virtual channel interfaces - Ptme* ptme = new Ptme(objects::PTME); - ptme->addVcInterface(0, vc); - ptme->addVcInterface(1, vc); - ptme->addVcInterface(2, vc); - ptme->addVcInterface(3, vc); - + createCcsdsComponents(gpioComIF); #endif /* OBSW_USE_CCSDS_IP_CORE == 1 */ #if OBSW_USE_TMTC_TCP_BRIDGE == 0 @@ -922,6 +885,75 @@ void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF) { rw4SpiCookie->setCallbackArgs(rwHandler4); } +void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF *gpioComIF) { + // GPIO definitions of signals connected to the virtual channel interfaces of the PTME IP Core + GpioCookie* gpioCookiePtmeIp = new GpioCookie; + GpiodRegularByLineName* gpio = nullptr; + std::stringstream consumer; + consumer << "0x" << std::hex << objects::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; + 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; + 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()); + gpioCookiePtmeIp->addGpio(gpioIds::VC1_PAPB_EMPTY, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::PAPB_VC2; + 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; + 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; + 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; + gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_EMPTY_SIGNAL_VC3, consumer.str()); + gpioCookiePtmeIp->addGpio(gpioIds::VC3_PAPB_EMPTY, gpio); + + 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); + + // Creating ptme object and adding virtual channel interfaces + Ptme* ptme = new Ptme(objects::PTME); + ptme->addVcInterface(ccsds::VC0, vc0); + ptme->addVcInterface(ccsds::VC1, vc1); + ptme->addVcInterface(ccsds::VC2, vc2); + ptme->addVcInterface(ccsds::VC3, vc3); + + CCSDSHandler* ccsdsHandler = new CCSDSHandler(objects::CCSDS_HANDLER, objects::PTME); + + VirtualChannel* vc = nullptr; + vc = new VirtualChannel(ccsds::VC0, config::VC0_QUEUE_SIZE); + ccsdsHandler->addVirtualChannel(ccsds::VC0, vc); + vc = new VirtualChannel(ccsds::VC1, config::VC1_QUEUE_SIZE); + ccsdsHandler->addVirtualChannel(ccsds::VC1, vc); + vc = new VirtualChannel(2, config::VC2_QUEUE_SIZE); + ccsdsHandler->addVirtualChannel(ccsds::VC2, vc); + vc = new VirtualChannel(3, config::VC3_QUEUE_SIZE); + ccsdsHandler->addVirtualChannel(ccsds::VC3, vc); +} + void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) { #if BOARD_TE0720 == 0 diff --git a/bsp_q7s/core/ObjectFactory.h b/bsp_q7s/core/ObjectFactory.h index ad9533a5..0e723142 100644 --- a/bsp_q7s/core/ObjectFactory.h +++ b/bsp_q7s/core/ObjectFactory.h @@ -22,6 +22,7 @@ void createSolarArrayDeploymentComponents(); void createSyrlinksComponents(); void createRtdComponents(LinuxLibgpioIF* gpioComIF); void createReactionWheelComponents(LinuxLibgpioIF* gpioComIF); +void createCcsdsComponents(LinuxLibgpioIF *gpioComIF); void createTestComponents(LinuxLibgpioIF* gpioComIF); }; diff --git a/common/config/ccsdsConfig.h b/common/config/ccsdsConfig.h new file mode 100644 index 00000000..8466a9fa --- /dev/null +++ b/common/config/ccsdsConfig.h @@ -0,0 +1,15 @@ +#ifndef COMMON_CONFIG_CCSDSCONFIG_H_ +#define COMMON_CONFIG_CCSDSCONFIG_H_ + +namespace ccsds { +enum { + VC0, + VC1, + VC2, + VC3 +}; +} + + + +#endif /* COMMON_CONFIG_CCSDSCONFIG_H_ */ diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index 0a66cd9a..43cd396c 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -13,9 +13,10 @@ enum commonObjects: uint32_t { FILE_SYSTEM_HANDLER = 0x50000500, PTME = 0x50000600, PAPB_VC0 = 0x50000700, - PAPB_VC1 = 0x500007001, - PAPB_VC2 = 0x500007002, - PAPB_VC3 = 0x500007003, + PAPB_VC1 = 0x50000701, + PAPB_VC2 = 0x50000702, + PAPB_VC3 = 0x50000703, + CCSDS_HANDLER = 0x50000800, /* 0x43 ('C') for Controllers */ THERMAL_CONTROLLER = 0x43400001, diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index f3d3fad6..afaed4a5 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -123,7 +123,12 @@ namespace config { /* Add mission configuration flags here */ static constexpr uint32_t OBSW_FILESYSTEM_HANDLER_QUEUE_SIZE = 50; static constexpr uint32_t PLOC_UPDATER_QUEUE_SIZE = 50; +static constexpr uint32_t CCSDS_HANDLER_QUEUE_SIZE = 50; static constexpr uint8_t NUMBER_OF_VIRTUAL_CHANNELS = 4; +static constexpr uint8_t VC0_QUEUE_SIZE = 50; +static constexpr uint8_t VC1_QUEUE_SIZE = 50; +static constexpr uint8_t VC2_QUEUE_SIZE = 50; +static constexpr uint8_t VC3_QUEUE_SIZE = 50; #ifdef __cplusplus } diff --git a/linux/obc/PapbVcInterface.cpp b/linux/obc/PapbVcInterface.cpp index 0c3c759a..6cbd81a3 100644 --- a/linux/obc/PapbVcInterface.cpp +++ b/linux/obc/PapbVcInterface.cpp @@ -3,7 +3,7 @@ PapbVcInterface::PapbVcInterface(object_id_t objectId, LinuxLibgpioIF* gpioComIF, gpioId_t papbBusyId, gpioId_t papbEmptyId, uint32_t vcOffset) : - SystemObject(objectId), gpioComIF(gpioComIF), uioVcInterface(uioVcInterface), papbBusyId( + SystemObject(objectId), gpioComIF(gpioComIF), papbBusyId( papbBusyId), papbEmptyId(papbEmptyId), vcOffset(vcOffset) { } @@ -15,19 +15,19 @@ void PapbVcInterface::setRegisterAddress(uint32_t* ptmeBaseAddress) { vcBaseReg = ptmeBaseAddress + vcOffset; } -ReturnValue_t PapbVcInterface::write(const uint8_t * data, size_t dataLen) { +ReturnValue_t PapbVcInterface::write(const uint8_t * data, size_t size) { if(pollPapbBusySignal() == RETURN_OK) { startPacketTransfer(); } - for(size_t idx = 0; idx < dataLen; idx++) { + for(size_t idx = 0; idx < size; idx++) { if(pollPapbBusySignal() == RETURN_OK) { *(vcBaseReg + DATA_REG_OFFSET) = static_cast(*(data + idx)); } else { sif::warning << "PapbVcInterface::sendTm: Only written " << idx - 1 << " of " - << dataLen << " data" << std::endl; + << size << " data" << std::endl; return RETURN_FAILED; } } @@ -95,7 +95,7 @@ ReturnValue_t PapbVcInterface::sendTestFrame() { testPacket[idx] = static_cast(idx & 0xFF); } - ReturnValue_t result = sendTm(testPacket, 1105); + ReturnValue_t result = write(testPacket, 1105); if(result != RETURN_OK) { return result; } diff --git a/linux/obc/PapbVcInterface.h b/linux/obc/PapbVcInterface.h index 05947ac6..937f4280 100644 --- a/linux/obc/PapbVcInterface.h +++ b/linux/obc/PapbVcInterface.h @@ -5,8 +5,8 @@ #include "linux/obc/VcInterfaceIF.h" #include #include -#include #include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/objectmanager/ObjectManager.h" /** * @brief This class handles the transmission of data to a virtual channel of the PTME IP Core @@ -14,7 +14,9 @@ * * @author J. Meier */ -class PapbVcInterface : VcInterfaceIF, HasReturnvaluesIF { +class PapbVcInterface: public SystemObject, + public VcInterfaceIF, + public HasReturnvaluesIF { public: /** * @brief Constructor @@ -31,6 +33,10 @@ public: gpioId_t papbEmptyId, uint32_t vcOffset); virtual ~PapbVcInterface(); + ReturnValue_t write(const uint8_t* data, size_t size) override; + + void setRegisterAddress(uint32_t* ptmeBaseAddress) override; + private: static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_IP_CORE_BRIDGE; diff --git a/linux/obc/Ptme.cpp b/linux/obc/Ptme.cpp index 480b5836..80f9945c 100644 --- a/linux/obc/Ptme.cpp +++ b/linux/obc/Ptme.cpp @@ -3,6 +3,7 @@ #include #include "fsfw/serviceinterface/ServiceInterface.h" +#include "PtmeConfig.h" Ptme::Ptme(object_id_t objectId) : SystemObject(objectId) { @@ -12,9 +13,8 @@ Ptme::~Ptme() { } ReturnValue_t Ptme::initialize() { - ReturnValue_t result = TmTcBridge::initialize(); - fd = open(PtmeConfig::UIO_DEVICE_FILE, O_RDWR); + 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; @@ -32,10 +32,15 @@ ReturnValue_t Ptme::initialize() { return RETURN_FAILED; } - return result; + VcInterfaceMapIter iter; + for (iter = vcInterfaceMap.begin(); iter != vcInterfaceMap.end(); iter++) { + iter->second->setRegisterAddress(ptmeBaseAddress); + } + + return RETURN_OK; } -ReturnValue_t Ptme::writeToVc(uint8_t vcId, const uint8_t * data, size_t dataLen) { +ReturnValue_t Ptme::writeToVc(uint8_t vcId, const uint8_t * data, size_t size) { ReturnValue_t result = RETURN_OK; VcInterfaceMapIter vcInterfaceMapIter = vcInterfaceMap.find(vcId); if (vcInterfaceMapIter == vcInterfaceMap.end()) { @@ -43,13 +48,13 @@ ReturnValue_t Ptme::writeToVc(uint8_t vcId, const uint8_t * data, size_t dataLen "channel with id " << static_cast(vcId) << std::endl; return UNKNOWN_VC_ID; } - result = vcInterfaceMapIter->second.write(data, size); + result = vcInterfaceMapIter->second->write(data, size); return result; } void Ptme::addVcInterface(VcId_t vcId, VcInterfaceIF* vc) { - if (vcId > config::MAX_VIRTUAL_CHANNEL_ID) { + if (vcId > config::NUMBER_OF_VIRTUAL_CHANNELS) { sif::warning << "Ptme::addVcInterface: Invalid virtual channel ID" << std::endl; return; } diff --git a/linux/obc/Ptme.h b/linux/obc/Ptme.h index 6ef118ab..aa131d9e 100644 --- a/linux/obc/Ptme.h +++ b/linux/obc/Ptme.h @@ -18,8 +18,13 @@ * The IP cores are implemented on the programmable logic and are accessible through the * linux UIO driver. */ -class Ptme : PtmeIF, SystemObject, HasReturnvaluesIF { +class Ptme : public PtmeIF, + public SystemObject, + public HasReturnvaluesIF { public: + + using VcId_t = uint8_t; + /** * @brief Constructor * @@ -29,7 +34,7 @@ public: virtual ~Ptme(); ReturnValue_t initialize() override; - ReturnValue_t writeToVc(uint8_t vcId, uint8_t* data, size_t size) override; + ReturnValue_t writeToVc(uint8_t vcId, const uint8_t* data, size_t size) override; /** * @brief This function adds the reference to a virtual channel interface to the vcInterface @@ -73,8 +78,6 @@ private: uint32_t* ptmeBaseAddress = nullptr; - using VcId_t = uint8_t; - using VcInterfaceMap = std::unordered_map; using VcInterfaceMapIter = VcInterfaceMap::iterator; diff --git a/linux/obc/PtmeConfig.h b/linux/obc/PtmeConfig.h index 34fd8876..f4468570 100644 --- a/linux/obc/PtmeConfig.h +++ b/linux/obc/PtmeConfig.h @@ -20,7 +20,7 @@ namespace PtmeConfig { static const uint32_t VC2_OFFSETT = 0x8000; static const uint32_t VC3_OFFSETT = 0xC000; - static const std::string UIO_DEVICE_FILE = "/dev/uio0"; + static const char UIO_DEVICE_FILE[] = "/dev/uio0"; }; #endif /* LINUX_OBC_PTMECONFIG_H_ */ diff --git a/linux/obc/PtmeIF.h b/linux/obc/PtmeIF.h index c89d25f0..53d9498b 100644 --- a/linux/obc/PtmeIF.h +++ b/linux/obc/PtmeIF.h @@ -22,7 +22,7 @@ public: * @param data Pointer to buffer holding the data to write * @param size Number of bytes to write */ - virtual ReturnValue_t writeToVc(uint8_t vcId, uint8_t* data, size_t size) = 0; + virtual ReturnValue_t writeToVc(uint8_t vcId, const uint8_t* data, size_t size) = 0; }; #endif /* LINUX_OBC_PTMEIF_H_ */ diff --git a/linux/obc/VcInterfaceIF.h b/linux/obc/VcInterfaceIF.h index ce643b48..28b8d1f1 100644 --- a/linux/obc/VcInterfaceIF.h +++ b/linux/obc/VcInterfaceIF.h @@ -1,6 +1,7 @@ #ifndef LINUX_OBC_VCINTERFACEIF_H_ #define LINUX_OBC_VCINTERFACEIF_H_ +#include #include "fsfw/returnvalues/HasReturnvaluesIF.h" /** @@ -20,7 +21,9 @@ public: * @param data Pointer to buffer holding the data to write * @param size Number of bytes to write */ - virtual ReturnValue_t write(uint8_t* data, size_t size) = 0; + virtual ReturnValue_t write(const uint8_t* data, size_t size) = 0; + + virtual void setRegisterAddress(uint32_t* ptmeBaseAddress) = 0; }; #endif /* LINUX_OBC_VCINTERFACEIF_H_ */ diff --git a/mission/CMakeLists.txt b/mission/CMakeLists.txt index 46f562a5..876201a8 100644 --- a/mission/CMakeLists.txt +++ b/mission/CMakeLists.txt @@ -2,3 +2,4 @@ add_subdirectory(core) add_subdirectory(devices) add_subdirectory(utility) add_subdirectory(memory) +add_subdirectory(tmtc) diff --git a/mission/tmtc/CCSDSHandler.cpp b/mission/tmtc/CCSDSHandler.cpp index b17af452..2a337d68 100644 --- a/mission/tmtc/CCSDSHandler.cpp +++ b/mission/tmtc/CCSDSHandler.cpp @@ -1,133 +1,29 @@ -#include -#include -#include -#include -#include -#include -#include -#include +#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface/serviceInterfaceDefintions.h" +#include "fsfw/objectmanager/ObjectManager.h" +#include "fsfw/ipc/QueueFactory.h" -const float CCSDSHandler::DEFAULT_RATES[BoardHandler::USED_VIRTUAL_CHANNELS_PER_BOARD] = - { CCSDSHandler::DEFAULT_BYTES_PER_SECOND, CCSDSHandler::DEFAULT_BYTES_PER_SECOND, - CCSDSHandler::DEFAULT_BYTES_PER_SECOND, CCSDSHandler::DEFAULT_BYTES_PER_SECOND }; +#include "CCSDSHandler.h" -CCSDSHandler::CCSDSHandler(object_id_t setObjectId, uint8_t setSwitchId1, - uint8_t setSwitchId2, object_id_t setChannel, uint16_t setSCID, - BoardHandler::DataPoolIds setPool) : - SystemObject(setObjectId), tmPartHealth(setObjectId + 1, 0), commandQueue(), state( - STATE_IDLE), commState(SEND_WRITE), mode(MODE_OFF), submode( - SUBMODE_NONE), boardHandler((uint8_t*) frameBuffer, - sizeof(frameBuffer), setSCID, setPool), dataLinkLayer( - this->frameBuffer, boardHandler.getClcw(), 0, setSCID), frameLength( - 0), channelId(setChannel), memoryHelper(this, &commandQueue), pendingWrite( - false), pendingRead(false), modeHelper(this), healthHelper(this, - setObjectId), parameterHelper(this), powerSwitcher(setSwitchId1, - setSwitchId2), switchOffWasReported(false), fdir(setObjectId, - setChannel) { - memset(this->frameBuffer, 0, sizeof(frameBuffer)); - DataSet mySet; - PoolVector rateRatio( - datapool::DATA_RATE_ASSIGN, &mySet, PoolVariableIF::VAR_WRITE); - for (uint8_t i = 0; i < BoardHandler::USED_VIRTUAL_CHANNELS_PER_BOARD; - ++i) { - virtualChannels[i] = new VCGeneration(i, - BoardHandler::TM_PACKETS_PER_CALL_PER_CHANNEL); - rateLimitOverload[i] = 0; - rateRatio[i] = DEFAULT_RATES[i]; - } - mySet.commit(PoolVariableIF::VALID); - //Set real-time channel to high responsiveness. - virtualChannels[0]->setIdlePacketIntervalMs( - VCGeneration::IDLE_INTERVAL_RT_CHANNEL); +CCSDSHandler::CCSDSHandler(object_id_t objectId, object_id_t ptmeId) : + SystemObject(objectId), ptmeId(ptmeId), parameterHelper(this) { + commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); } CCSDSHandler::~CCSDSHandler() { - for (uint8_t i = 0; i < BoardHandler::USED_VIRTUAL_CHANNELS_PER_BOARD; - ++i) { - delete virtualChannels[i]; - } } -void CCSDSHandler::printFrameBuffer(void) { - debug << "frame_buffer contains: " << std::endl; - for (uint32_t i = 0; i < this->frameLength; ++i) { - debug << "frame_buffer[" << std::dec << i << "]: " << std::hex - << std::showbase << (uint16_t) this->frameBuffer[i] << std::dec - << std::endl; - } -} - -ReturnValue_t CCSDSHandler::packetProcessing(void) { - rateSet.read(); - const float* usedRateRatios = NULL; - if (rateSet.dataRates.isValid()) { - usedRateRatios = rateSet.dataRates.value; - } else { - usedRateRatios = DEFAULT_RATES; - } - for (uint8_t i = 0; i < BoardHandler::USED_VIRTUAL_CHANNELS_PER_BOARD; - ++i) { - //Set current cycle Limit first - uint32_t newLimit = (usedRateRatios[i]) / SENDS_PER_SECOND; - if (newLimit <= rateLimitOverload[i]) { - //Calculate new overload. - rateLimitOverload[i] -= newLimit; - //Use newLimit as current rate, VC is utilized to its current limit. - rateSet.dataRate[i] = usedRateRatios[i]; //equal to newLimit * SENDS_PER_SECOND - //Don't send anything new. - continue; - } - newLimit -= rateLimitOverload[i]; - virtualChannels[i]->tmSendLimitPerCycle = newLimit; - //Send new packets. - uint32_t tempRate = virtualChannels[i]->packetProcessing(); - if (tempRate > virtualChannels[i]->tmSendLimitPerCycle) { - rateLimitOverload[i] = tempRate - virtualChannels[i]->tmSendLimitPerCycle; - //VC is fully utilized, but not more. Overload will be accounted for in next cycles. - rateSet.dataRate[i] = virtualChannels[i]->tmSendLimitPerCycle * SENDS_PER_SECOND; - } else { - //Data rate extended to a Bytes/s range. Filtering is performed in controller. - rateSet.dataRate[i] = tempRate * SENDS_PER_SECOND; - rateLimitOverload[i] = 0; - } - } - rateSet.commit(PoolVariableIF::VALID); - return RETURN_OK; -} - -ReturnValue_t CCSDSHandler::packetProcessingCheck(void) { - ReturnValue_t status = RETURN_FAILED; - for (uint8_t vc = 0; vc < BoardHandler::USED_VIRTUAL_CHANNELS_PER_BOARD; - ++vc) { - status = this->virtualChannels[vc]->packetProcessingCheck(); - if (status != RETURN_OK) { - error << "CCSDSHandler " << std::hex << this->getObjectId() - << " ::packetProcessingCheck: Error on VC " << (uint16_t) vc - << ". Error code: " << status << std::dec << std::endl; - } - } - return RETURN_OK; -} - -ReturnValue_t CCSDSHandler::performOperation(void) { +ReturnValue_t CCSDSHandler::performOperation(uint8_t operationCode) { readCommandQueue(); handleTelemetry(); handleTelecommands(); return RETURN_OK; } -void CCSDSHandler::addVirtualChannel(VcId_t virtualChannelId, VirtualChannel* virtualChannel) { - auto status = virtualChannelMap.emplace(virtualChannelId, virtualChannel); - if (status.second == false) { - sif::warning << "CCSDSHandler::addVcInterface: Failed to add virtual channel with virtual " - << "channel id " << static_cast(virtualChannelId) << std::endl; - } -} - void CCSDSHandler::handleTelemetry() { VirtualChannelMapIter iter; - for (iter = virtualChannelMap.begin(); iter != VirtualChannelMap.end(); iter++) { - iter->second.virtualChannel->performOperation(); + for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { + iter->second->performOperation(); } } @@ -135,374 +31,78 @@ void CCSDSHandler::handleTelecommands() { } -void CCSDSHandler::searchFrame() { - frameLength = this->boardHandler.findFrame(); - while (frameLength != 0) { - ReturnValue_t frame_status = this->dataLinkLayer.processFrame( - frameLength); - if (frame_status != RETURN_OK) { - triggerEvent(DataLinkLayer::FRAME_PROCESSING_FAILED, frame_status, - 0); - } - boardHandler.resetFrameBuffer(); - frameLength = boardHandler.findFrame(); - } -} - ReturnValue_t CCSDSHandler::initialize() { - PtmeIF *ptme = objectManager->get(ptmeId); + ReturnValue_t result = RETURN_OK; + PtmeIF* ptme = ObjectManager::instance()->get(ptmeId); if (ptme == nullptr) { + sif::warning << "Invalid PTME object" << std::endl; return ObjectManagerIF::CHILD_INIT_FAILED; } - status = boardHandler.initialize(channel); - if (status != RETURN_OK) { - return status; + + result = parameterHelper.initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; } - status = modeHelper.initialize(); - if (status != RETURN_OK) { - return status; - } - status = healthHelper.initialize(); - if (status != HasReturnvaluesIF::RETURN_OK) { - return status; - } - status = memoryHelper.initialize(); - if (status != HasReturnvaluesIF::RETURN_OK) { - return status; - } - status = parameterHelper.initialize(); - if (status != HasReturnvaluesIF::RETURN_OK) { - return status; - } - status = powerSwitcher.initialize(objects::PCDU_HANDLER); - if (status != HasReturnvaluesIF::RETURN_OK) { - return status; - } - StorageManagerIF* tmStore = objectManager->get( - objects::TM_STORE); - status = dataLinkLayer.initialize(); - if ((tmStore != NULL) && status == RETURN_OK) { - status = RETURN_OK; - for (uint8_t i = 0; i < BoardHandler::USED_VIRTUAL_CHANNELS_PER_BOARD; - ++i) { -// this->virtualChannels[i] = objectManager->get( -// objects::CCSDS_VC_BASE + i); - if (this->virtualChannels[i] != NULL) { - this->virtualChannels[i]->setPacketStore(tmStore); - this->virtualChannels[i]->setBoardHandler(&this->boardHandler); - } else { - status = RETURN_FAILED; - } - } - } else { - status = RETURN_FAILED; - error << "CCSDSHandler " << std::hex << this->getObjectId() << std::dec - << " ::CCSDSHandler: Configuration failed." << std::endl; - } - status = fdir.initialize(); - if (status != HasReturnvaluesIF::RETURN_OK) { - return status; - } - return status; + return result; } void CCSDSHandler::readCommandQueue(void) { CommandMessage commandMessage; ReturnValue_t result = RETURN_FAILED; - result = commandQueue.receiveMessage(&commandMessage); + result = commandQueue->receiveMessage(&commandMessage); if (result == RETURN_OK) { result = parameterHelper.handleParameterMessage(&commandMessage); if (result == RETURN_OK) { return; } CommandMessage reply; - reply.setReplyRejected(CommandMessage::UNKNOW_COMMAND, + reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND, commandMessage.getCommand()); - commandQueue.reply(&reply); + commandQueue->reply(&reply); } } MessageQueueId_t CCSDSHandler::getCommandQueue() const { - return commandQueue.getId(); + return commandQueue->getId(); } -void CCSDSHandler::flushTmChannels() { - for (uint8_t i = 0; i < BoardHandler::USED_VIRTUAL_CHANNELS_PER_BOARD; - ++i) { - virtualChannels[i]->flush(); - } -} +void CCSDSHandler::addVirtualChannel(VcId_t vcId, VirtualChannel* virtualChannel) { + if (vcId > config::NUMBER_OF_VIRTUAL_CHANNELS) { + sif::warning << "CCSDSHandler::addVirtualChannel: Invalid virtual channel ID" << std::endl; + return; + } -ReturnValue_t CCSDSHandler::handleMemoryLoad(uint32_t address, - const uint8_t* data, uint32_t size, uint8_t** dataPointer) { - if (size != 4) { - return INVALID_SIZE; - } - ReturnValue_t result = boardHandler.manualWriteToRegister(address, data); - if (result == RETURN_OK) { - pendingWrite = true; - return DO_IT_MYSELF; - } - return result; -} + if (virtualChannel == nullptr) { + sif::warning << "CCSDSHandler::addVirtualChannel: Invalid virtual channel interface" << std::endl; + return; + } -ReturnValue_t CCSDSHandler::handleMemoryDump(uint32_t address, uint32_t size, - uint8_t** dataPointer, uint8_t* dumpTarget) { - if (size != 4) { - return INVALID_SIZE; - } - ReturnValue_t result = boardHandler.sendRegisterReadCommand(address); - if (result == RETURN_OK) { - pendingRead = true; - return DO_IT_MYSELF; - } - return result; -} - -ReturnValue_t CCSDSHandler::checkModeCommand(Mode_t commandedMode, - Submode_t commandedSubmode, uint32_t* msToReachTheMode) { - if (state != STATE_IDLE) { - return IN_TRANSITION; - } - switch (commandedMode) { - case MODE_ON: - if ((commandedSubmode == SUBMODE_ACTIVE) - || (commandedSubmode == SUBMODE_PASSIVE)) { - return RETURN_OK; - } else { - return INVALID_SUBMODE; - } - break; - case MODE_OFF: - if (commandedSubmode == SUBMODE_NONE) { - return RETURN_OK; - } else { - return INVALID_SUBMODE; - } - default: - return INVALID_MODE; - } -} - -void CCSDSHandler::startTransition(Mode_t commandedMode, - Submode_t commandedSubmode) { - if (commandedMode == mode) { - if (mode == MODE_ON) { - state = STATE_SELECT_SUBMODE; - } else { - //Turn off switch again anyway - state = STATE_TURN_OFF; - } - } else { - switch (commandedMode) { - case MODE_ON: - state = STATE_TURN_ON; - break; - case MODE_OFF: - state = STATE_TURN_OFF; - break; - default: - //Error case. Cannot happen? - error << "CCSDSHandler::startTransition: Invalid commanded mode: " - << commandedMode << std::endl; - return; - } - } - triggerEvent(CHANGING_MODE, commandedMode, commandedSubmode); -} - -void CCSDSHandler::getMode(Mode_t* modeReturn, Submode_t* submodeReturn) { - *modeReturn = mode; - *submodeReturn = submode; -} - -void CCSDSHandler::setToExternalControl() { - healthHelper.setHealth(EXTERNAL_CONTROL); -} - -void CCSDSHandler::announceMode(bool recursive) { - triggerEvent(MODE_INFO, mode, submode); -} - -void CCSDSHandler::setParentQueue(MessageQueueId_t parentQueueId) { - modeHelper.setParentQueue(parentQueueId); - healthHelper.setParentQeueue(parentQueueId); - tmPartHealth.setParentQueue(parentQueueId); -} - -void CCSDSHandler::doStateMachine() { - ReturnValue_t status = RETURN_FAILED; - powerSwitcher.doStateMachine(); - switch (state) { - case STATE_IDLE: - //Do nothing? Do perform operation stuff? - break; - case STATE_TURN_ON: - powerSwitcher.turnOn(); - modeHelper.startTimer(powerSwitcher.getSwitchDelay()); - state = STATE_WAIT_ON; - break; - case STATE_WAIT_ON: - if (powerSwitcher.checkSwitchState() == RETURN_OK) { - modeHelper.startTimer(LINK_UP_DELAY_MS); - state = STATE_WAIT_LINK; - } - if (boardHandler.checkChannel() == RETURN_OK) { - boardHandler.startStateTranstion(); - state = STATE_INITIALIZE_BOARD; - } else { - if (modeHelper.isTimedOut()) { - triggerEvent(MODE_TRANSITION_FAILED, - PowerSwitchIF::SWITCH_TIMEOUT, state); - setMode(MODE_OFF, SUBMODE_NONE); - } - } - break; - case STATE_WAIT_LINK: - if (boardHandler.checkAndResetChannel() == RETURN_OK) { - boardHandler.startStateTranstion(); - state = STATE_INITIALIZE_BOARD; - } else { - if (modeHelper.isTimedOut()) { - triggerEvent(MODE_TRANSITION_FAILED, DeviceHandlerIF::TIMEOUT, - state); - setMode(MODE_OFF, SUBMODE_NONE); - } - } - break; - case STATE_INITIALIZE_BOARD: - status = boardHandler.initializeBoard(); - switch (status) { - case RETURN_OK: - state = STATE_SELECT_SUBMODE; - break; - case BoardHandler::IN_TRANSITION: - //cannot last forever, so just wait. - break; - default: - triggerEvent(MODE_TRANSITION_FAILED, status, state); - state = STATE_TURN_OFF; - break; - } - break; - case STATE_SELECT_SUBMODE: - boardHandler.startStateTranstion(); - if (modeHelper.commandedSubmode == SUBMODE_PASSIVE) { - state = STATE_WAIT_SUBMODE_PASSIVE; - } else { - state = STATE_WAIT_SUBMODE_ACTIVE; - } - break; - case STATE_WAIT_SUBMODE_PASSIVE: - //Just one wait cycle to get rid of pending TM. - state = STATE_DO_PASSIVATE; - break; - case STATE_DO_PASSIVATE: - status = boardHandler.tmPassivate(); - switch (status) { - case RETURN_OK: - setMode(MODE_ON, SUBMODE_PASSIVE); - break; - case BoardHandler::IN_TRANSITION: - //cannot last forever, so just wait. - break; - default: - //If it comes here and fails then, there might be something wrong with the board. - triggerEvent(MODE_TRANSITION_FAILED, status, state); - state = STATE_TURN_OFF; - break; - } - break; - case STATE_WAIT_SUBMODE_ACTIVE: - status = boardHandler.tmActivate(); - switch (status) { - case RETURN_OK: - setMode(MODE_ON, SUBMODE_ACTIVE); - break; - case BoardHandler::IN_TRANSITION: - //cannot last forever, so just wait. - break; - default: - //If it comes here and fails then, there might be something wrong with the board. - triggerEvent(MODE_TRANSITION_FAILED, status, state); - state = STATE_TURN_OFF; - break; - } - break; - case STATE_TURN_OFF: - //Passivate first. Mainly optimization for System Testbed. - boardHandler.startStateTranstion(); - state = STATE_DO_PASSIVATE_OFF; - //No break - case STATE_DO_PASSIVATE_OFF: - status = boardHandler.tmPassivate(); - switch (status) { - case RETURN_OK: - state = STATE_TURN_SWITCH_OFF; - break; - case BoardHandler::IN_TRANSITION: - //cannot last forever, so just wait. - break; - default: - //If it comes here and fails then, there might be something wrong with the board. - //Just turn it off. - state = STATE_TURN_SWITCH_OFF; - break; - } - break; - case STATE_TURN_SWITCH_OFF: - powerSwitcher.turnOff(); - modeHelper.startTimer(powerSwitcher.getSwitchDelay()); - state = STATE_WAIT_OFF; - break; - case STATE_WAIT_OFF: - if ((boardHandler.checkAndResetChannel() == RMAPChannelIF::LINK_DOWN) - || (powerSwitcher.checkSwitchState() == RETURN_OK)) { - setMode(MODE_OFF, SUBMODE_NONE); - state = STATE_IDLE; - } else { - if (modeHelper.isTimedOut()) { - triggerEvent(MODE_TRANSITION_FAILED, status, state); - setMode(mode, submode); - } - } - break; - default: - break; - } -} - -ReturnValue_t CCSDSHandler::addVirtualChannel(uint8_t virtualChannelId, - VirtualChannelReceptionIF* object) { - return this->dataLinkLayer.addVirtualChannel(virtualChannelId, object); -} - -void CCSDSHandler::setMode(Mode_t newMode, Submode_t newSubmode) { - triggerEvent(MODE_INFO, newMode, newSubmode); - if (newMode == MODE_OFF) { - boardHandler.setDataPoolVaraiblesInvalid(); - } - modeHelper.modeChanged(newMode, newSubmode); - state = STATE_IDLE; - mode = newMode; - submode = newSubmode; -} - -Mode_t CCSDSHandler::getMode() const { - return mode; -} - -Submode_t CCSDSHandler::getSubmode() const { - return submode; + auto status = virtualChannelMap.emplace(vcId, virtualChannel); + if (status.second == false) { + sif::warning << "CCSDSHandler::addVirtualChannel: Failed to add virtual channel to " + "virtual channel map" << std::endl; + return; + } } MessageQueueId_t CCSDSHandler::getReportReceptionQueue(uint8_t virtualChannel) { if (virtualChannel < config::NUMBER_OF_VIRTUAL_CHANNELS) { - return virtualChannels[virtualChannel]->getReportReceptionQueue(); + VirtualChannelMapIter iter = virtualChannelMap.find(virtualChannel); + if (iter != virtualChannelMap.end()) { + return iter->second->getReportReceptionQueue(); + } + else { + sif::warning << "CCSDSHandler::getReportReceptionQueue: Virtual channel with ID " + << static_cast(virtualChannel) << " not in virtual channel map" + << std::endl; + return MessageQueueIF::NO_QUEUE; + } } else { sif::debug << "CCSDSHandler::getReportReceptionQueue: Invalid virtual channel requested"; + } + return MessageQueueIF::NO_QUEUE; } ReturnValue_t CCSDSHandler::getParameter(uint8_t domainId, uint8_t uniqueIdentifier, diff --git a/mission/tmtc/CCSDSHandler.h b/mission/tmtc/CCSDSHandler.h index 8780b4e8..05693a38 100644 --- a/mission/tmtc/CCSDSHandler.h +++ b/mission/tmtc/CCSDSHandler.h @@ -1,12 +1,13 @@ #ifndef CCSDSHANDLER_H_ #define CCSDSHANDLER_H_ -#include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/serviceinterface/serviceInterfaceDefintions.h" +#include "OBSWConfig.h" #include "fsfw/objectmanager/SystemObject.h" #include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/parameters/ParameterHelper.h" +#include "VirtualChannel.h" +#include /** * @brief This class handles the data exchange with the CCSDS IP cores implemented in the @@ -20,63 +21,20 @@ class CCSDSHandler: public SystemObject, public HasReturnvaluesIF, public ReceivesParameterMessagesIF { public: - static const uint32_t LINK_UP_DELAY_MS = 2000; //!< The maximum time it takes to reconfigure the CCSDS Board. - static const uint32_t MAX_FRAME_SIZE = 1024; - static const Submode_t SUBMODE_ACTIVE = 1; //!< Submode where the TM part of the board is on. - static const Submode_t SUBMODE_PASSIVE = 0; //!< Submode where the TM part of the board is off. - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CCSDS_BOARD; - static const Event CCSDS_BOARD_RESET_FAILED = MAKE_EVENT(0, SEVERITY::LOW); //!> Resetting the communication channel failed. Severity LOW, par1: returnCode, par2: 0 - static const Event CCSDS_BOARD_SWITCHED = MAKE_EVENT(1, SEVERITY::INFO); //!> Switched active CCSDS-Board. Par1: objectId of now active board, Par2: objectId of now passive board. + using VcId_t = uint8_t; - static const ActionId_t SET_DATA_RATE_RATIO = 1; - static const float SENDS_PER_SECOND = 2.5; - static const uint32_t MINIMUM_BYTES_PER_SECOND = - (VCGeneration::IDLE_PACKET_SIZE - / (VCGeneration::DEFAULT_IDLE_INTERVAL / 1000)) + 1; //!< +1 to be on the safe side. - static const float DEFAULT_RATES[BoardHandler::USED_VIRTUAL_CHANNELS_PER_BOARD]; - static const uint32_t DEFAULT_BYTES_PER_SECOND = 1300; + /** + * @brief Constructor + * + * @param objectId Object ID of the CCSDS handler + * @param ptmeId Object ID of the PTME object providing access to the PTME IP Core. + */ + CCSDSHandler(object_id_t objectId, object_id_t ptmeId); - HealthDevice tmPartHealth; //!< A helper device to dedicatetly set the telemetry part to not healthy. - /** - * Main Constructor of the class. - * Initializes all attributes with default values. Sets the frame buffer to zero. - * Creates all TM Virtual Channels (with \c new). Initialization of communication partners - * is done in the #initialize routine. - * @param setObjectId Object identifier of the class. - * @param setSwitchId1 Switch id of the first switch of the board. - * @param setSwitchId2 Switch id of the second switch of the board. - * @param set_channel RMAP channel identifier. This is forwarded to the #boardHandler class. - * @param set_scid Configured SpaceCraft Identifier. Is forwarded to #boardHandler and #dataLinkLayer class. - */ - CCSDSHandler(object_id_t setObjectId, uint8_t setSwitchId1, - uint8_t setSwitchId2, object_id_t setChannel, uint16_t setSCID, - BoardHandler::DataPoolIds setPool); - /** - * The destructor deletes all TM Virtual Channels. - */ ~CCSDSHandler(); - /** - * Main executing method of the CCSDS Board handling. - * The method coordinates reading and writing of buffers and registers on the CCSDS Board - * as well as checking communication states and looking for frames. The state machine is - * executed here as well. To ensure a smooth communication without much delay, the last read - * and write calls are checked in the beginning and new requests as well as the state machine - * are issued in the end. - * @return Always returns #RETURN_OK. - */ - ReturnValue_t performOperation(void); - ReturnValue_t handleMemoryLoad(uint32_t address, const uint8_t* data, - uint32_t size, uint8_t** dataPointer); - ReturnValue_t handleMemoryDump(uint32_t address, uint32_t size, - uint8_t** dataPointer, uint8_t* dumpTarget); - /** - * Initialization routine of the class. - * It initializes connections to the power unit and to the Telemetry store which is set for - * every TM Virtual Channel. - * @return - */ + ReturnValue_t performOperation(uint8_t operationCode = 0) override; ReturnValue_t initialize(); MessageQueueId_t getCommandQueue() const; @@ -85,74 +43,31 @@ public: * * @param virtualChannelId ID of the virtual channel to add * @param virtualChannel Pointer to virtual channel object - * - * @return RETURN_OK if successful, otherwise RETURN_FAILED */ void addVirtualChannel(VcId_t virtualChannelId, VirtualChannel* virtualChannel); - Mode_t getMode() const; - Submode_t getSubmode() const; - void setParentQueue(MessageQueueId_t parentQueueId); MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0); - ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueIdentifier, ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues, uint16_t startAtIndex); -protected: - MessageQueue commandQueue; //!< Queue to receive control commands. - VCGeneration* virtualChannels[BoardHandler::USED_VIRTUAL_CHANNELS_PER_BOARD];//!< An array of VCGeneration classes which each manage on TM Virtual Channel. - uint32_t rateLimitOverload[BoardHandler::USED_VIRTUAL_CHANNELS_PER_BOARD];//!< Used to smooth data rate in case large packets are sent. - /** - * This method reads the command queue and initializes a state transition if a command of this type was found. - */ - void readCommandQueue(void); - - /** - * This method flushes all pending messages in the TM queue by calling the \c flush method of - * all #virtualChannels. - * This is necessary to avoid doubled TM packets if the TM sender issues its messages to both the - * nominal and redundant CCSDS Board. - */ - void flushTmChannels(); - /** - * This is a helper method to print the current content of the frame buffers. - */ - void printFrameBuffer(void); - /** - * This is an important method which triggers searching for and handling found frames. - * It first calls the boardHandler method to find a frame in the received data. If a - * well-formed frame was found it calls the #dataLinkLayer class to process the frame - */ - void searchFrame(); - /** - * Calls the packet processing routine of each TM Virtual Channel. - * This triggers reception of incoming packets from the OBSW and forwarding to the CCSDS Board. - * There are different sending strategies for forwarding the packets to the board. - * @return Returns #RETURN_OK or the status of the failed virtual channel method. - */ - ReturnValue_t packetProcessing(void); - /** - * With this method the successful forwarding of Telemetry to the TM Virtual Channels is checked. - * The method calls the check routine of each virtual channel. - * @return Returns #RETURN_OK or the status of the failed virtual channel method. - */ - ReturnValue_t packetProcessingCheck(void); - - ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, - uint32_t *msToReachTheMode); - void startTransition(Mode_t mode, Submode_t submode); - void getMode(Mode_t *mode, Submode_t *submode); - void setToExternalControl(); - void announceMode(bool recursive); private: - using VcId_t = uint8_t; - using VirtualChannelMap = std::unordered_map; + static const uint32_t QUEUE_SIZE = config::CCSDS_HANDLER_QUEUE_SIZE; + + using VirtualChannelMap = std::unordered_map; using VirtualChannelMapIter = VirtualChannelMap::iterator; VirtualChannelMap virtualChannelMap; + // Object ID of PTME object + object_id_t ptmeId; + + MessageQueueIF* commandQueue = nullptr; + + ParameterHelper parameterHelper; + + void readCommandQueue(void); void handleTelemetry(); void handleTelecommands(); }; diff --git a/mission/tmtc/CMakeLists.txt b/mission/tmtc/CMakeLists.txt new file mode 100644 index 00000000..7da87b6c --- /dev/null +++ b/mission/tmtc/CMakeLists.txt @@ -0,0 +1,6 @@ +target_sources(${TARGET_NAME} PUBLIC + CCSDSHandler.cpp + VirtualChannel.cpp +) + + diff --git a/mission/tmtc/VirtualChannel.cpp b/mission/tmtc/VirtualChannel.cpp index 8e106de1..1f8f5ffb 100644 --- a/mission/tmtc/VirtualChannel.cpp +++ b/mission/tmtc/VirtualChannel.cpp @@ -1,13 +1,11 @@ #include "CCSDSHandler.h" +#include "VirtualChannel.h" #include "OBSWConfig.h" #include "fsfw/serviceinterface/ServiceInterfaceStream.h" #include "fsfw/objectmanager/ObjectManager.h" - - -#include - -#include +#include "fsfw/tmtcservices/TmTcMessage.h" +#include "fsfw/ipc/QueueFactory.h" VirtualChannel::VirtualChannel(uint8_t vcId, uint32_t tmQueueDepth) : @@ -22,10 +20,11 @@ ReturnValue_t VirtualChannel::initialize() { sif::error << "VirtualChannel::initialize: Failed to get tm store" << std::endl; return RETURN_FAILED; } + return RETURN_OK; } ReturnValue_t VirtualChannel::performOperation() { - ReturnValue_t status = RETURN_OK; + ReturnValue_t result = RETURN_OK; TmTcMessage message; while(tmQueue->receiveMessage(&message) == RETURN_OK) { @@ -41,7 +40,7 @@ ReturnValue_t VirtualChannel::performOperation() { } if (linkIsUp) { - result = ptme->writeToVc(virtualChannleId, data, size); + result = ptme->writeToVc(vcId, data, size); } tmStore->deleteData(storeId); @@ -54,7 +53,7 @@ ReturnValue_t VirtualChannel::performOperation() { } MessageQueueId_t VirtualChannel::getReportReceptionQueue(uint8_t virtualChannel) { - return tmQueue.getId(); + return tmQueue->getId(); } void VirtualChannel::setPtmeObject(PtmeIF* ptme) { @@ -64,17 +63,6 @@ void VirtualChannel::setPtmeObject(PtmeIF* ptme) { ptme = ptme; } -void VirtualChannel::setIdlePacketIntervalMs(uint32_t idlePacketIntervalMs) { - timer.timeout = idlePacketIntervalMs; -} - -ReturnValue_t VirtualChannel::flush() { - TmTcMessage message; - ReturnValue_t status = RETURN_FAILED; - for (status = tmQueue.receiveMessage(&message); status == RETURN_OK; - status = tmQueue.receiveMessage(&message)) { - packetStore->deleteData(message.getStorageId()); - } - boardHandler->resetVC(virtualChannelId); - return status; +void VirtualChannel::setLinkState(bool linkIsUp) { + linkIsUp = linkIsUp; } diff --git a/mission/tmtc/VirtualChannel.h b/mission/tmtc/VirtualChannel.h index cba4b0b4..d897e2d6 100644 --- a/mission/tmtc/VirtualChannel.h +++ b/mission/tmtc/VirtualChannel.h @@ -4,33 +4,16 @@ #include "fsfw/tmtcservices/AcceptsTelemetryIF.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include - -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include /** - * @brief This class represents a virtual channel in the software. + * @brief This class represents a virtual channel. Sending a tm message to an object of this class + * will forward the tm packet to the respective virtual channel of the PTME IP Core. * * @author J. Meier */ class VirtualChannel: public AcceptsTelemetryIF, public HasReturnvaluesIF { public: - - uint32_t tmSendLimitPerCycle; //!< Current maximum bytes per cycle. - - static const uint32_t IDLE_INTERVAL_RT_CHANNEL = 2000; //!< Real Time channel (VC 0) idle interval. - - static const uint16_t IDLE_PACKET_SIZE = 1015; //!< Size of generated idle packets. - - static const uint32_t DEFAULT_IDLE_INTERVAL = 20000; //!< Default if too lazy to set. - /** * @brief Constructor * @@ -40,28 +23,7 @@ class VirtualChannel: public AcceptsTelemetryIF, public HasReturnvaluesIF { VirtualChannel(uint8_t vcId, uint32_t tmQueueDepth); ReturnValue_t initialize(); - - /** - * One of the main public methods. - * Checks the tmQueue, calls #handlePacket if packets were found and keeps track of the number of sent bytes, - * to stop transmission before a buffer overflow occurs. If no packets were sent, an idle packet is generated. - * @return Number of sent bytes. 0 if an error occurred. - */ - uint32_t packetProcessing(void); - /** - * Another important method to check successful forwarding of packets. - * Checks how many packets have been forwarded to the CCSDS Board and tries to get as many - * RMAP write replys. The pending messages are deleted here. - * @return @c RETURN_OK on success, or one of many error codes, mainly coming from @c receiveVCAcknowledge. - */ - ReturnValue_t packetProcessingCheck(void); - /** - * Setter. - * @param setStore Sets the #packetStore used. - */ - void setPacketStore(StorageManagerIF* setStore); - MessageQueueId_t getReportReceptionQueue(); - + MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) override; ReturnValue_t performOperation(); /** @@ -69,42 +31,21 @@ class VirtualChannel: public AcceptsTelemetryIF, public HasReturnvaluesIF { * * @param ptme Pointer to ptme object */ - void setPtmeObject(Ptme* ptme); + void setPtmeObject(PtmeIF* ptme); + + /** + * @brief Can be used by the owner to set the link state. Packets will be discarded if link + * to ground station is down. + */ + void setLinkState(bool linkIsUp); private: PtmeIF* ptme = nullptr; MessageQueueIF* tmQueue = nullptr; - uint8_t virtualChannelId; + uint8_t vcId; bool linkIsUp; StorageManagerIF* tmStore = nullptr; - - - BoardHandler* boardHandler; //!< A reference to the "hardware part" of handling the packets. - store_address_t pendingTm[BoardHandler::TM_PACKETS_PER_CALL_PER_CHANNEL]; //!< List of packets sent to the board. Is used to check if all Space Packets sent received the CCSDS Board. - uint16_t sendCount; //!< Counter to identify how many packets have been sent coming in to the board (without Idle Packets). - Countdown timer; - SpacePacket idlePacket; - uint32_t accumulatedByteCount; - - store_address_t pendingPacket; - - static const uint32_t TM_SEND_LIMIT_PER_CYCLE = 1300; //!< The maximum number of bytes to send to the CCSDS Board VC per cycle. - - /** - * Helper method to send an idle packet. - * @return @c RETURN_OK on success, @c RETURN_FAILED otherwise. - */ - ReturnValue_t sendIdlePacket(uint32_t size); - /** - * A helper method to handle incoming packets. - * Reads a packet from #packetStore and tries to forward it to the CCSDS BoardHandler class. - * Calls the hardware layer with @c writeToVc. Depending on what the "hardware" layer does, - * it stores the sent packet id's to find out if they were all received by the CCSDS Board. - * @param store_id ID of a packet in the #packetStore. - * @return @c RETURN_OK on success, the return code of @c writeToVc otherwise. - */ - ReturnValue_t handlePacket(store_address_t storeId); }; #endif /* VIRTUALCHANNEL_H_ */ diff --git a/mission/utility/TmFunnel.cpp b/mission/utility/TmFunnel.cpp index d718f6cf..5838ae75 100644 --- a/mission/utility/TmFunnel.cpp +++ b/mission/utility/TmFunnel.cpp @@ -99,12 +99,12 @@ ReturnValue_t TmFunnel::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } -#if OBSW_USE_PTME_IP_CORE == 1 +#if OBSW_TM_TO_PTME == 1 // Live TM will be sent via the virtual channel 0 tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue(0)); #else tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue()); -#endif /* OBSW_USE_CCSDS_IP_CORES == 1 */ +#endif /* OBSW_TM_TO_PTME == 1 */ // Storage destination is optional. if(storageDestination == objects::NO_OBJECT) { From 04d791824d26e3bf595387dd9b55737e97e5e4ab Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 26 Sep 2021 22:46:10 +0200 Subject: [PATCH 014/465] class IDs and subsystem IDs moved to framework --- common/config/commonClassIds.h | 2 -- common/config/commonSubsystemIds.h | 2 -- fsfw | 2 +- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/common/config/commonClassIds.h b/common/config/commonClassIds.h index 793cb1ba..5c8e263a 100644 --- a/common/config/commonClassIds.h +++ b/common/config/commonClassIds.h @@ -7,8 +7,6 @@ namespace CLASS_ID { enum commonClassIds: uint8_t { COMMON_CLASS_ID_START = FW_CLASS_ID_COUNT, - MGM_LIS3MDL, //MGMLIS3 - MGM_RM3100, //MGMRM3100 PCDU_HANDLER, //PCDU HEATER_HANDLER, //HEATER SYRLINKS_HANDLER, //SYRLINKS diff --git a/common/config/commonSubsystemIds.h b/common/config/commonSubsystemIds.h index 58ebac66..4cef8774 100644 --- a/common/config/commonSubsystemIds.h +++ b/common/config/commonSubsystemIds.h @@ -6,8 +6,6 @@ namespace SUBSYSTEM_ID { enum: uint8_t { COMMON_SUBSYSTEM_ID_START = FW_SUBSYSTEM_ID_RANGE, - MGM_LIS3MDL = 106, - MGM_RM3100 = 107, PCDU_HANDLER = 108, HEATER_HANDLER = 109, SA_DEPL_HANDLER = 110, diff --git a/fsfw b/fsfw index 2b6c9963..36607c87 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 2b6c996364be4aee65a1353bbe29d07604c4bdc8 +Subproject commit 36607c876422738aabe23fd5ab3e43ae58e41746 From a5f9d0c0d5f2198d329e4df29d6b66fe075fe7ca Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 27 Sep 2021 10:09:38 +0200 Subject: [PATCH 015/465] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 36607c87..e227b5de 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 36607c876422738aabe23fd5ab3e43ae58e41746 +Subproject commit e227b5dead43c292918fb9f140a1c7c4073c8081 From 3af5b8560d9efb4ae9afb414a0a69c2e97e90e10 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 27 Sep 2021 10:51:47 +0200 Subject: [PATCH 016/465] have to user proper types now --- bsp_q7s/core/ObjectFactory.cpp | 26 +++++++++++++------------- bsp_q7s/gpio/gpioCallbacks.cpp | 6 +++--- bsp_q7s/gpio/gpioCallbacks.h | 3 ++- fsfw | 2 +- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 828f6d33..e0cc084d 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -284,43 +284,43 @@ void ObjectFactory::createSunSensorComponents(LinuxLibgpioIF *gpioComIF, SpiComI GpioCookie* gpioCookieSus = new GpioCookie(); GpioCallback* susgpio = nullptr; - susgpio = new GpioCallback("Chip select SUS 1", gpio::OUT, 1, + susgpio = new GpioCallback("Chip select SUS 1", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_1, susgpio); - susgpio = new GpioCallback("Chip select SUS 2", gpio::OUT, 1, + susgpio = new GpioCallback("Chip select SUS 2", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_2, susgpio); - susgpio = new GpioCallback("Chip select SUS 3", gpio::OUT, 1, + susgpio = new GpioCallback("Chip select SUS 3", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_3, susgpio); - susgpio = new GpioCallback("Chip select SUS 4", gpio::OUT, 1, + susgpio = new GpioCallback("Chip select SUS 4", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_4, susgpio); - susgpio = new GpioCallback("Chip select SUS 5", gpio::OUT, 1, + susgpio = new GpioCallback("Chip select SUS 5", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_5, susgpio); - susgpio = new GpioCallback("Chip select SUS 6", gpio::OUT, 1, + susgpio = new GpioCallback("Chip select SUS 6", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_6, susgpio); - susgpio = new GpioCallback("Chip select SUS 7", gpio::OUT, 1, + susgpio = new GpioCallback("Chip select SUS 7", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_7, susgpio); - susgpio = new GpioCallback("Chip select SUS 8", gpio::OUT, 1, + susgpio = new GpioCallback("Chip select SUS 8", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_8, susgpio); - susgpio = new GpioCallback("Chip select SUS 9", gpio::OUT, 1, + susgpio = new GpioCallback("Chip select SUS 9", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_9, susgpio); - susgpio = new GpioCallback("Chip select SUS 10", gpio::OUT, 1, + susgpio = new GpioCallback("Chip select SUS 10", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_10, susgpio); - susgpio = new GpioCallback("Chip select SUS 11", gpio::OUT, 1, + susgpio = new GpioCallback("Chip select SUS 11", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_11, susgpio); - susgpio = new GpioCallback("Chip select SUS 12", gpio::OUT, 1, + susgpio = new GpioCallback("Chip select SUS 12", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_12, susgpio); - susgpio = new GpioCallback("Chip select SUS 13", gpio::OUT, 1, + susgpio = new GpioCallback("Chip select SUS 13", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_13, susgpio); diff --git a/bsp_q7s/gpio/gpioCallbacks.cpp b/bsp_q7s/gpio/gpioCallbacks.cpp index 3787c829..8280b1e9 100644 --- a/bsp_q7s/gpio/gpioCallbacks.cpp +++ b/bsp_q7s/gpio/gpioCallbacks.cpp @@ -53,7 +53,7 @@ void initSpiCsDecoder(GpioIF* gpioComIF) { } } -void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, int value, +void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, gpio::Levels value, void* args) { if (gpioComInterface == nullptr) { @@ -67,10 +67,10 @@ void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, int value return; } - if (value == 1) { + if (value == gpio::HIGH) { disableAllDecoder(); } - else if (value == 0) { + else if (value == gpio::LOW) { switch (gpioId) { case(gpioIds::RTD_IC3): { enableDecoderTcsIc1(); diff --git a/bsp_q7s/gpio/gpioCallbacks.h b/bsp_q7s/gpio/gpioCallbacks.h index eaf9a701..13a51df2 100644 --- a/bsp_q7s/gpio/gpioCallbacks.h +++ b/bsp_q7s/gpio/gpioCallbacks.h @@ -17,7 +17,8 @@ namespace gpioCallbacks { * @brief This function implements the decoding to multiply gpios by using the decoder * chips SN74LVC138APWR on the TCS board and the interface board. */ - void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, int value, void* args); + void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, + gpio::Levels value, void* args); /** * @brief This function sets mux bits 1-3 to a state which will only enable the decoder diff --git a/fsfw b/fsfw index e227b5de..a84c770d 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit e227b5dead43c292918fb9f140a1c7c4073c8081 +Subproject commit a84c770dfb8447325c263da42d5cecd99b38d1f0 From 2fd46871088a5913c4c7c9834d0eb2247ffd54d5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 27 Sep 2021 11:20:00 +0200 Subject: [PATCH 017/465] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index a84c770d..98deac1e 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit a84c770dfb8447325c263da42d5cecd99b38d1f0 +Subproject commit 98deac1ef1a5d100e9a29adc8bc9552a88e5dc62 From 55a274a6e317f861d98c59a8fd043844f404711f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 28 Sep 2021 10:59:09 +0200 Subject: [PATCH 018/465] fsfw and tmtc update --- fsfw | 2 +- tmtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsfw b/fsfw index 98deac1e..254aac51 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 98deac1ef1a5d100e9a29adc8bc9552a88e5dc62 +Subproject commit 254aac51ec1234b44eefafd7425b62e54f348958 diff --git a/tmtc b/tmtc index 53bf6508..82495ad7 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 53bf65083889af10f77c3899972b1153ea835f3c +Subproject commit 82495ad785c83440ee90846bce70be1659b66209 From 8acb0c3c0218d569f29c870a5ae980c34e85111f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 28 Sep 2021 11:34:43 +0200 Subject: [PATCH 019/465] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 254aac51..5fd7a8c9 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 254aac51ec1234b44eefafd7425b62e54f348958 +Subproject commit 5fd7a8c9b76bae2d7d019e0175b481083e7ba460 From e5d0dac65e14d60c278f1bfd47a3f9f05be44f0e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 28 Sep 2021 14:58:12 +0200 Subject: [PATCH 020/465] tcpip components refactoring --- bsp_q7s/core/InitMission.cpp | 12 +++++++--- bsp_q7s/core/ObjectFactory.cpp | 24 +------------------- common/config/CMakeLists.txt | 4 ++++ common/config/commonConfig.cpp | 5 +++++ common/config/commonConfig.h.in | 10 ++++++++- fsfw | 2 +- mission/core/GenericFactory.cpp | 39 +++++++++++++++++++++++++++++---- 7 files changed, 64 insertions(+), 32 deletions(-) create mode 100644 common/config/commonConfig.cpp diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index bc9139fb..deda0ed8 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -82,19 +82,21 @@ void initmission::initTasks() { initmission::printAddObjectError("TM_FUNNEL", objects::TM_FUNNEL); } - /* UDP bridge */ +#if OBSW_ADD_TCPIP_BRIDGE == 1 + // TMTC bridge PeriodicTaskIF* tmtcBridgeTask = factory->createPeriodicTask( - "UDP_UNIX_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + "TCPIP_TMTC_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); result = tmtcBridgeTask->addComponent(objects::TMTC_BRIDGE); if(result != HasReturnvaluesIF::RETURN_OK) { initmission::printAddObjectError("UDP_BRIDGE", objects::TMTC_BRIDGE); } PeriodicTaskIF* tmtcPollingTask = factory->createPeriodicTask( - "UDP_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + "TMTC_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); result = tmtcPollingTask->addComponent(objects::TMTC_POLLING_TASK); if(result != HasReturnvaluesIF::RETURN_OK) { initmission::printAddObjectError("UDP_POLLING", objects::TMTC_POLLING_TASK); } +#endif # if BOARD_TE0720 == 0 // FS task, task interval does not matter because it runs in permanent loop, priority low @@ -139,8 +141,12 @@ void initmission::initTasks() { sif::info << "Starting tasks.." << std::endl; tmTcDistributor->startTask(); + +#if OBSW_ADD_TCPIP_BRIDGE == 1 tmtcBridgeTask->startTask(); tmtcPollingTask->startTask(); +#endif + #if BOARD_TE0720 == 0 coreController->startTask(); #endif diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index e0cc084d..b916977a 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -69,16 +69,6 @@ #include "fsfw/tmtcservices/PusServiceBase.h" #include "fsfw/tmtcpacket/pus/tm.h" -#if OBSW_USE_TMTC_TCP_BRIDGE == 0 -// UDP server includes -#include "fsfw/osal/common/UdpTmTcBridge.h" -#include "fsfw/osal/common/UdpTcPollingTask.h" -#else -// TCP server includes -#include "fsfw/osal/common/TcpTmTcBridge.h" -#include "fsfw/osal/common/TcpTmTcServer.h" -#endif - #include "linux/boardtest/SpiTestClass.h" #if OBSW_TEST_LIBGPIOD == 1 @@ -114,6 +104,7 @@ void Factory::setStaticFrameworkObjectIds() { void ObjectFactory::produce(void* args) { ObjectFactory::setStatics(); ObjectFactory::produceGenericObjects(); + LinuxLibgpioIF* gpioComIF = nullptr; UartComIF* uartComIF = nullptr; SpiComIF* spiComIF = nullptr; @@ -173,19 +164,6 @@ void ObjectFactory::produce(void* args) { #endif /* TE7020 != 0 */ -#if OBSW_USE_TMTC_TCP_BRIDGE == 0 - auto udpBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); - sif::info << "Created UDP server for TMTC commanding with listener port " << - udpBridge->getUdpPort() << std::endl; -#else - auto tmtcBridge = new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - tmtcBridge->setMaxNumberOfPacketsStored(50); - auto tcpServer = new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); - sif::info << "Created TCP server for TMTC commanding with listener port " - << tcpServer->getTcpPort() << std::endl; -#endif /* OBSW_USE_TMTC_TCP_BRIDGE == 0 */ - /* Test Task */ #if OBSW_ADD_TEST_CODE == 1 createTestComponents(gpioComIF); diff --git a/common/config/CMakeLists.txt b/common/config/CMakeLists.txt index f38f2c50..5c4b4942 100644 --- a/common/config/CMakeLists.txt +++ b/common/config/CMakeLists.txt @@ -1,3 +1,7 @@ target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_sources(${TARGET_NAME} PRIVATE + commonConfig.cpp ) \ No newline at end of file diff --git a/common/config/commonConfig.cpp b/common/config/commonConfig.cpp new file mode 100644 index 00000000..b15a14c5 --- /dev/null +++ b/common/config/commonConfig.cpp @@ -0,0 +1,5 @@ +#include "commonConfig.h" +#include "tmtc/apid.h" +#include "fsfw/tmtcpacket/SpacePacket.h" + +const uint16_t common::TC_PACKET_ID = SpacePacket::getTcSpacePacketIdFromApid(apid::EIVE_OBSW); diff --git a/common/config/commonConfig.h.in b/common/config/commonConfig.h.in index 52b5dd45..055f86aa 100644 --- a/common/config/commonConfig.h.in +++ b/common/config/commonConfig.h.in @@ -1,10 +1,18 @@ #ifndef COMMON_CONFIG_COMMONCONFIG_H_ #define COMMON_CONFIG_COMMONCONFIG_H_ +#include + #define OBSW_ADD_LWGPS_TEST 0 +// Disable this for mission code. It allows exchanging TMTC packets via the Ethernet port +#define OBSW_ADD_TCPIP_BRIDGE 1 // Use TCP instead of UDP for the TMTC bridge. This allows using the TMTC client locally // because UDP packets are not allowed in the VPN -#define OBSW_USE_TMTC_TCP_BRIDGE 1 +#define OBSW_USE_TCP_BRIDGE 1 + +namespace common { +extern const uint16_t TC_PACKET_ID; +} #endif /* COMMON_CONFIG_COMMONCONFIG_H_ */ diff --git a/fsfw b/fsfw index 5fd7a8c9..c7ce568a 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 5fd7a8c9b76bae2d7d019e0175b481083e7ba460 +Subproject commit c7ce568a302538ef98e308add1bcae632563c48e diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index 4ee1ff70..df15025b 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -23,12 +23,24 @@ #include #include +#if OBSW_ADD_TCPIP_BRIDGE == 1 +#if OBSW_USE_TCP_BRIDGE == 0 +// UDP server includes +#include "fsfw/osal/common/UdpTmTcBridge.h" +#include "fsfw/osal/common/UdpTcPollingTask.h" +#else +// TCP server includes +#include "fsfw/osal/common/TcpTmTcBridge.h" +#include "fsfw/osal/common/TcpTmTcServer.h" +#endif +#endif + #if OBSW_ADD_TEST_CODE == 1 - #include +#include #endif void ObjectFactory::produceGenericObjects() { - /* Framework objects */ + // Framework objects new EventManager(objects::EVENT_MANAGER); new HealthTable(objects::HEALTH_TABLE); new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER); @@ -61,10 +73,10 @@ void ObjectFactory::produceGenericObjects() { objects::CCSDS_PACKET_DISTRIBUTOR); - /* TMTC Reception via UDP socket */ + // Every TM packet goes through this funnel new TmFunnel(objects::TM_FUNNEL); - /* PUS stack */ + // PUS service stack new Service1TelecommandVerification(objects::PUS_SERVICE_1_VERIFICATION, apid::EIVE_OBSW, pus::PUS_SERVICE_1, objects::TM_FUNNEL, 20); new Service2DeviceAccess(objects::PUS_SERVICE_2_DEVICE_ACCESS, @@ -83,4 +95,23 @@ void ObjectFactory::produceGenericObjects() { pus::PUS_SERVICE_20); new CService200ModeCommanding(objects::PUS_SERVICE_200_MODE_MGMT, apid::EIVE_OBSW, pus::PUS_SERVICE_200); + + +#if OBSW_ADD_TCPIP_BRIDGE == 1 +#if OBSW_USE_TCP_BRIDGE == 0 + auto tmtcBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + tmtcBridge->setMaxNumberOfPacketsStored(50); + new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); + sif::info << "Created UDP server for TMTC commanding with listener port " << + udpBridge->getUdpPort() << std::endl; +#else + auto tmtcBridge = new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + tmtcBridge->setMaxNumberOfPacketsStored(50); + auto tcpServer = new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); + // TCP is stream based. Use packet ID as start marker when parsing for space packets + tcpServer->setSpacePacketParsingOptions({common::TC_PACKET_ID}); + sif::info << "Created TCP server for TMTC commanding with listener port " + << tcpServer->getTcpPort() << std::endl; +#endif /* OBSW_USE_TMTC_TCP_BRIDGE == 0 */ +#endif /* OBSW_ADD_TCPIP_BRIDGE == 1 */ } From 14dcd9eb5ffdb5c59939f90817306b603f1ff546 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 28 Sep 2021 15:13:05 +0200 Subject: [PATCH 021/465] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index c7ce568a..f2020b24 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit c7ce568a302538ef98e308add1bcae632563c48e +Subproject commit f2020b24923b77390ff5234e579a5aa9fc492f4e From 699ffd75df47b1aceb430a38413cfb932f6d8513 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 28 Sep 2021 15:33:46 +0200 Subject: [PATCH 022/465] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index f2020b24..be8623a4 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit f2020b24923b77390ff5234e579a5aa9fc492f4e +Subproject commit be8623a4f85d4445b218873bddd6bcf0ed24fb5f From 4db5944514feca6ccf8ea3230cb215ade08d4f41 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 28 Sep 2021 16:46:07 +0200 Subject: [PATCH 023/465] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index be8623a4..6881c6b6 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit be8623a4f85d4445b218873bddd6bcf0ed24fb5f +Subproject commit 6881c6b66a5a3d11756485f8f845928aea9a705e From 6a00fd309929e2dbee9c7f9d9169004b05503cc4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 28 Sep 2021 17:41:02 +0200 Subject: [PATCH 024/465] fsfw update and call fix --- common/config/commonConfig.cpp | 2 +- fsfw | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/config/commonConfig.cpp b/common/config/commonConfig.cpp index b15a14c5..b578f23b 100644 --- a/common/config/commonConfig.cpp +++ b/common/config/commonConfig.cpp @@ -2,4 +2,4 @@ #include "tmtc/apid.h" #include "fsfw/tmtcpacket/SpacePacket.h" -const uint16_t common::TC_PACKET_ID = SpacePacket::getTcSpacePacketIdFromApid(apid::EIVE_OBSW); +const uint16_t common::TC_PACKET_ID = getTcSpacePacketIdFromApid(apid::EIVE_OBSW); diff --git a/fsfw b/fsfw index 6881c6b6..69922e77 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 6881c6b66a5a3d11756485f8f845928aea9a705e +Subproject commit 69922e77c501ddaef84481c96e25801dc1889c11 From d903df55ceafafe4e182ccdd6a5c1eb0ed31ad48 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 28 Sep 2021 17:43:02 +0200 Subject: [PATCH 025/465] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 69922e77..5ee315f8 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 69922e77c501ddaef84481c96e25801dc1889c11 +Subproject commit 5ee315f8ca3b0bb27d5a368948ecd115c6a055c9 From 5b6f09185975abe962b101149970b488b5eb7a5b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 28 Sep 2021 17:43:18 +0200 Subject: [PATCH 026/465] function in namespace now --- common/config/commonConfig.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/config/commonConfig.cpp b/common/config/commonConfig.cpp index b578f23b..1c9ece8b 100644 --- a/common/config/commonConfig.cpp +++ b/common/config/commonConfig.cpp @@ -2,4 +2,4 @@ #include "tmtc/apid.h" #include "fsfw/tmtcpacket/SpacePacket.h" -const uint16_t common::TC_PACKET_ID = getTcSpacePacketIdFromApid(apid::EIVE_OBSW); +const uint16_t common::TC_PACKET_ID = spacepacket::getTcSpacePacketIdFromApid(apid::EIVE_OBSW); From c1fe5325eda4d05e7271b71df0938ae0f4df76f9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 29 Sep 2021 09:12:57 +0200 Subject: [PATCH 027/465] renaming options --- CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e9b1b68c..c8e345e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,8 @@ if(TGT_BSP MATCHES "arm/q7s") option(BUILD_Q7S_SIMPLE_MODE OFF "Simple mode with a minimal main function") endif() -option(ADD_ETL_LIB "Add ETL library" ON) +option(EIVE_BUILD_UNITTESTS "Build Catch2 unittests" OFF) +option(EIVE_ADD_ETL_LIB "Add ETL library" ON) option(ADD_JSON_LIB "Add JSON library" ON) option(EIVE_SYSROOT_MAGIC "Perform sysroot magic which might not be necessary" OFF) @@ -143,7 +144,7 @@ set(FSFW_ADDITIONAL_INC_PATHS # Add executable add_executable(${TARGET_NAME}) -if(ADD_ETL_LIB) +if(EIVE_ADD_ETL_LIB) add_subdirectory(${ETL_LIB_PATH}) endif() @@ -203,7 +204,7 @@ if(NOT EIVE_BUILD_WATCHDOG) endif() endif() -if(ADD_ETL_LIB) +if(EIVE_ADD_ETL_LIB) target_link_libraries(${TARGET_NAME} PRIVATE ${LIB_ETL_NAME} ) From cf04b83cdf743b588b015fac73a4cd3c8d726c90 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 29 Sep 2021 09:14:17 +0200 Subject: [PATCH 028/465] EIVE prefixes added --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c8e345e2..ed5c5409 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ endif() option(EIVE_BUILD_UNITTESTS "Build Catch2 unittests" OFF) option(EIVE_ADD_ETL_LIB "Add ETL library" ON) -option(ADD_JSON_LIB "Add JSON library" ON) +option(EIVE_ADD_JSON_LIB "Add JSON library" ON) option(EIVE_SYSROOT_MAGIC "Perform sysroot magic which might not be necessary" OFF) if(NOT FSFW_OSAL) @@ -148,7 +148,7 @@ if(EIVE_ADD_ETL_LIB) add_subdirectory(${ETL_LIB_PATH}) endif() -if(ADD_JSON_LIB) +if(EIVE_ADD_JSON_LIB) add_subdirectory(${LIB_JSON_PATH}) endif() @@ -210,7 +210,7 @@ if(EIVE_ADD_ETL_LIB) ) endif() -if(ADD_JSON_LIB) +if(EIVE_ADD_JSON_LIB) target_link_libraries(${TARGET_NAME} PRIVATE ${LIB_JSON_NAME} ) From 74fa4835e2e0a86b26794f52f14bf4210c4c1369 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 29 Sep 2021 09:15:02 +0200 Subject: [PATCH 029/465] added Catch2 repo --- .gitmodules | 3 +++ thirdparty/Catch2 | 1 + 2 files changed, 4 insertions(+) create mode 160000 thirdparty/Catch2 diff --git a/.gitmodules b/.gitmodules index 1f3dc6ec..1ca8bec5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -22,3 +22,6 @@ [submodule "thirdparty/json"] path = thirdparty/json url = https://github.com/nlohmann/json.git +[submodule "thirdparty/Catch2"] + path = thirdparty/Catch2 + url = https://github.com/catchorg/Catch2.git diff --git a/thirdparty/Catch2 b/thirdparty/Catch2 new file mode 160000 index 00000000..42695403 --- /dev/null +++ b/thirdparty/Catch2 @@ -0,0 +1 @@ +Subproject commit 426954032f263754d2fff4cffce8552e7371965e From ababb5c06220ffe60a94aaf2466a9b92b8fbbe2d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 29 Sep 2021 09:30:58 +0200 Subject: [PATCH 030/465] adding unittests for EIVE --- CMakeLists.txt | 45 +++++++---- fsfw | 2 +- unittest/CMakeLists.txt | 1 + unittest/testcfg/CMakeLists.txt | 9 +++ unittest/testcfg/FSFWConfig.h.in | 78 +++++++++++++++++++ unittest/testcfg/OBSWConfig.h.in | 8 ++ unittest/testcfg/TestsConfig.h.in | 21 +++++ unittest/testcfg/devices/logicalAddresses.cpp | 5 ++ unittest/testcfg/devices/logicalAddresses.h | 15 ++++ .../testcfg/devices/powerSwitcherList.cpp | 4 + unittest/testcfg/devices/powerSwitcherList.h | 12 +++ unittest/testcfg/events/subsystemIdRanges.h | 18 +++++ unittest/testcfg/ipc/MissionMessageTypes.cpp | 12 +++ unittest/testcfg/ipc/MissionMessageTypes.h | 22 ++++++ unittest/testcfg/objects/systemObjectList.h | 32 ++++++++ .../PollingSequenceFactory.cpp | 39 ++++++++++ .../pollingsequence/PollingSequenceFactory.h | 32 ++++++++ unittest/testcfg/returnvalues/classIds.h | 16 ++++ unittest/testcfg/tmtc/apid.h | 18 +++++ unittest/testcfg/tmtc/pusIds.h | 25 ++++++ unittest/unittest.mk | 0 21 files changed, 400 insertions(+), 14 deletions(-) create mode 100644 unittest/CMakeLists.txt create mode 100644 unittest/testcfg/CMakeLists.txt create mode 100644 unittest/testcfg/FSFWConfig.h.in create mode 100644 unittest/testcfg/OBSWConfig.h.in create mode 100644 unittest/testcfg/TestsConfig.h.in create mode 100644 unittest/testcfg/devices/logicalAddresses.cpp create mode 100644 unittest/testcfg/devices/logicalAddresses.h create mode 100644 unittest/testcfg/devices/powerSwitcherList.cpp create mode 100644 unittest/testcfg/devices/powerSwitcherList.h create mode 100644 unittest/testcfg/events/subsystemIdRanges.h create mode 100644 unittest/testcfg/ipc/MissionMessageTypes.cpp create mode 100644 unittest/testcfg/ipc/MissionMessageTypes.h create mode 100644 unittest/testcfg/objects/systemObjectList.h create mode 100644 unittest/testcfg/pollingsequence/PollingSequenceFactory.cpp create mode 100644 unittest/testcfg/pollingsequence/PollingSequenceFactory.h create mode 100644 unittest/testcfg/returnvalues/classIds.h create mode 100644 unittest/testcfg/tmtc/apid.h create mode 100644 unittest/testcfg/tmtc/pusIds.h delete mode 100644 unittest/unittest.mk diff --git a/CMakeLists.txt b/CMakeLists.txt index ed5c5409..54915f2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,26 +60,34 @@ set(LIB_LWGPS_NAME lwgps) set(LIB_ARCSEC wire) set(THIRD_PARTY_FOLDER thirdparty) set(LIB_CXX_FS -lstdc++fs) +set(LIB_CATCH2 Catch2) set(LIB_JSON_NAME nlohmann_json::nlohmann_json) # Set path names set(FSFW_PATH fsfw) set(MISSION_PATH mission) set(TEST_PATH test/testtasks) +set(UNITTEST_PATH unittest) set(LINUX_PATH linux) set(COMMON_PATH common) set(WATCHDOG_PATH watchdog) set(COMMON_CONFIG_PATH ${COMMON_PATH}/config) -set(FSFW_HAL_LIB_PATH fsfw_hal) -set(CSP_LIB_PATH ${THIRD_PARTY_FOLDER}/libcsp) -set(ETL_LIB_PATH ${THIRD_PARTY_FOLDER}/etl) -set(LWGPS_LIB_PATH ${THIRD_PARTY_FOLDER}/lwgps) -set(ARCSEC_LIB_PATH ${THIRD_PARTY_FOLDER}/arcsec_star_tracker) +set(LIB_CSP_PATH ${THIRD_PARTY_FOLDER}/libcsp) +set(LIB_ETL_PATH ${THIRD_PARTY_FOLDER}/etl) +set(LIB_CATCH2_PATH ${THIRD_PARTY_FOLDER}/Catch2) +set(LIB_LWGPS_PATH ${THIRD_PARTY_FOLDER}/lwgps) +set(LIB_ARCSEC_PATH ${THIRD_PARTY_FOLDER}/arcsec_star_tracker) set(LIB_JSON_PATH ${THIRD_PARTY_FOLDER}/json) set(FSFW_WARNING_SHADOW_LOCAL_GCC OFF) -set(ADD_LINUX_FILES False) +set(EIVE_ADD_LINUX_FILES False) + +if(FSFW_CUSTOM_UNITTEST_RUNNER OR FSFW_ADD_UNITTESTS) + set(CATCH2_TARGET Catch2) +else() + set(CATCH2_TARGET Catch2WithMain) +endif() # Analyse different OS and architecture/target options, determine BSP_PATH, # display information about compiler etc. @@ -92,7 +100,7 @@ if(TGT_BSP) ) set(FSFW_CONFIG_PATH "linux/fsfwconfig") if(NOT BUILD_Q7S_SIMPLE_MODE) - set(ADD_LINUX_FILES TRUE) + set(EIVE_ADD_LINUX_FILES TRUE) set(ADD_CSP_LIB TRUE) set(FSFW_HAL_ADD_LINUX ON) endif() @@ -145,7 +153,7 @@ set(FSFW_ADDITIONAL_INC_PATHS add_executable(${TARGET_NAME}) if(EIVE_ADD_ETL_LIB) - add_subdirectory(${ETL_LIB_PATH}) + add_subdirectory(${LIB_ETL_PATH}) endif() if(EIVE_ADD_JSON_LIB) @@ -153,22 +161,26 @@ if(EIVE_ADD_JSON_LIB) endif() if(NOT EIVE_BUILD_WATCHDOG) - if(ADD_LINUX_FILES) + if(EIVE_ADD_LINUX_FILES) add_subdirectory(${LINUX_PATH}) endif() add_subdirectory(${BSP_PATH}) add_subdirectory(${COMMON_PATH}) if(ADD_CSP_LIB) - add_subdirectory(${CSP_LIB_PATH}) + add_subdirectory(${LIB_CSP_PATH}) endif() endif() if((NOT BUILD_Q7S_SIMPLE_MODE) AND (NOT EIVE_BUILD_WATCHDOG)) - add_subdirectory(${LWGPS_LIB_PATH}) + add_subdirectory(${LIB_LWGPS_PATH}) add_subdirectory(${FSFW_PATH}) add_subdirectory(${MISSION_PATH}) add_subdirectory(${TEST_PATH}) - add_subdirectory(${ARCSEC_LIB_PATH}) + add_subdirectory(${LIB_ARCSEC_PATH}) +endif() + +if(EIVE_BUILD_UNITTEST) + add_subdirectory(${UNITTEST_PATH}) endif() if(EIVE_BUILD_WATCHDOG) @@ -196,6 +208,7 @@ if((NOT BUILD_Q7S_SIMPLE_MODE) AND (NOT EIVE_BUILD_WATCHDOG)) endif() endif() + if(NOT EIVE_BUILD_WATCHDOG) if(ADD_CSP_LIB) target_link_libraries(${TARGET_NAME} PRIVATE @@ -216,6 +229,12 @@ if(EIVE_ADD_JSON_LIB) ) endif() +if(EIVE_BUILD_UNITTEST) + target_link_libraries(${TARGET_NAME} PRIVATE + ${CATCH2_TARGET} + ) +endif() + target_link_libraries(${TARGET_NAME} PRIVATE ${LIB_CXX_FS} ) @@ -225,7 +244,7 @@ target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${FSFW_CONFIG_PATH} ${CMAKE_CURRENT_BINARY_DIR} - ${ARCSEC_LIB_PATH} + ${LIB_ARCSEC_PATH} ) if(TGT_BSP MATCHES "arm/q7s") diff --git a/fsfw b/fsfw index 5ee315f8..354e158c 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 5ee315f8ca3b0bb27d5a368948ecd115c6a055c9 +Subproject commit 354e158cc196d7deaf7de24ebcc96f5f6f5f20eb diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt new file mode 100644 index 00000000..ce562b28 --- /dev/null +++ b/unittest/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(testcfg) diff --git a/unittest/testcfg/CMakeLists.txt b/unittest/testcfg/CMakeLists.txt new file mode 100644 index 00000000..50d13663 --- /dev/null +++ b/unittest/testcfg/CMakeLists.txt @@ -0,0 +1,9 @@ +target_sources(${TARGET_NAME} PRIVATE + ipc/MissionMessageTypes.cpp + pollingsequence/PollingSequenceFactory.cpp +) + +# Add include paths for the executable +target_include_directories(${TARGET_NAME} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) diff --git a/unittest/testcfg/FSFWConfig.h.in b/unittest/testcfg/FSFWConfig.h.in new file mode 100644 index 00000000..d38f0648 --- /dev/null +++ b/unittest/testcfg/FSFWConfig.h.in @@ -0,0 +1,78 @@ +#ifndef CONFIG_FSFWCONFIG_H_ +#define CONFIG_FSFWCONFIG_H_ + +#include +#include + +//! Used to determine whether C++ ostreams are used which can increase +//! the binary size significantly. If this is disabled, +//! the C stdio functions can be used alternatively +#define FSFW_CPP_OSTREAM_ENABLED 0 + +//! More FSFW related printouts. Useful for development. +#define FSFW_ENHANCED_PRINTOUT 0 + +//! Can be used to completely disable printouts, even the C stdio ones. +//! By default, printouts will be disabled for the unit tests. +#if FSFW_CPP_OSTREAM_ENABLED == 0 && FSFW_ENHANCED_PRINTOUT == 0 + #ifndef FSFW_DISABLE_PRINTOUT + #define FSFW_DISABLE_PRINTOUT 1 + #endif +#endif + +//! Can be used to enable additional debugging printouts for developing the FSFW +#define FSFW_PRINT_VERBOSITY_LEVEL 0 + +//! Can be used to disable the ANSI color sequences for C stdio. +#define FSFW_COLORED_OUTPUT 0 + +//! If FSFW_OBJ_EVENT_TRANSLATION is set to one, +//! additional output which requires the translation files translateObjects +//! and translateEvents (and their compiled source files) +#define FSFW_OBJ_EVENT_TRANSLATION 0 + +#if FSFW_OBJ_EVENT_TRANSLATION == 1 +//! Specify whether info events are printed too. +#define FSFW_DEBUG_INFO 1 +#include "objects/translateObjects.h" +#include "events/translateEvents.h" +#else +#endif + +//! When using the newlib nano library, C99 support for stdio facilities +//! will not be provided. This define should be set to 1 if this is the case. +#define FSFW_NO_C99_IO 1 + +//! Specify whether a special mode store is used for Subsystem components. +#define FSFW_USE_MODESTORE 0 + +//! Defines if the real time scheduler for linux should be used. +//! If set to 0, this will also disable priority settings for linux +//! as most systems will not allow to set nice values without privileges +//! For embedded linux system set this to 1. +//! If set to 1 the binary needs "cap_sys_nice=eip" privileges to run +#define FSFW_USE_REALTIME_FOR_LINUX 1 + +namespace fsfwconfig { +//! Default timestamp size. The default timestamp will be an eight byte CDC +//! short timestamp. +static constexpr uint8_t FSFW_MISSION_TIMESTAMP_SIZE = 8; + +//! Configure the allocated pool sizes for the event manager. +static constexpr size_t FSFW_EVENTMGMR_MATCHTREE_NODES = 240; +static constexpr size_t FSFW_EVENTMGMT_EVENTIDMATCHERS = 120; +static constexpr size_t FSFW_EVENTMGMR_RANGEMATCHERS = 120; + +//! Defines the FIFO depth of each commanding service base which +//! also determines how many commands a CSB service can handle in one cycle +//! simulataneously. This will increase the required RAM for +//! each CSB service ! +static constexpr uint8_t FSFW_CSB_FIFO_DEPTH = 6; + +static constexpr size_t FSFW_PRINT_BUFFER_SIZE = 124; + +static constexpr size_t FSFW_MAX_TM_PACKET_SIZE = 1500; + +} + +#endif /* CONFIG_FSFWCONFIG_H_ */ diff --git a/unittest/testcfg/OBSWConfig.h.in b/unittest/testcfg/OBSWConfig.h.in new file mode 100644 index 00000000..34eda31f --- /dev/null +++ b/unittest/testcfg/OBSWConfig.h.in @@ -0,0 +1,8 @@ +#ifndef TESTCFG_OBSWCONFIG_H_ +#define TESTCFG_OBSWCONFIG_H_ + + + + + +#endif /* TESTCFG_OBSWCONFIG_H_ */ diff --git a/unittest/testcfg/TestsConfig.h.in b/unittest/testcfg/TestsConfig.h.in new file mode 100644 index 00000000..7d950070 --- /dev/null +++ b/unittest/testcfg/TestsConfig.h.in @@ -0,0 +1,21 @@ +#ifndef FSFW_UNITTEST_CONFIG_TESTSCONFIG_H_ +#define FSFW_UNITTEST_CONFIG_TESTSCONFIG_H_ + +#define FSFW_ADD_DEFAULT_FACTORY_FUNCTIONS 1 + +#ifdef __cplusplus + +#include "objects/systemObjectList.h" +#include "events/subsystemIdRanges.h" +#include "returnvalues/classIds.h" + +namespace config { +#endif + +/* Add mission configuration flags here */ + +#ifdef __cplusplus +} +#endif + +#endif /* FSFW_UNITTEST_CONFIG_TESTSCONFIG_H_ */ diff --git a/unittest/testcfg/devices/logicalAddresses.cpp b/unittest/testcfg/devices/logicalAddresses.cpp new file mode 100644 index 00000000..c7ce314d --- /dev/null +++ b/unittest/testcfg/devices/logicalAddresses.cpp @@ -0,0 +1,5 @@ +#include "logicalAddresses.h" + + + + diff --git a/unittest/testcfg/devices/logicalAddresses.h b/unittest/testcfg/devices/logicalAddresses.h new file mode 100644 index 00000000..cdf87025 --- /dev/null +++ b/unittest/testcfg/devices/logicalAddresses.h @@ -0,0 +1,15 @@ +#ifndef CONFIG_DEVICES_LOGICALADDRESSES_H_ +#define CONFIG_DEVICES_LOGICALADDRESSES_H_ + +#include +#include +#include + +namespace addresses { + /* Logical addresses have uint32_t datatype */ + enum logicalAddresses: address_t { + }; +} + + +#endif /* CONFIG_DEVICES_LOGICALADDRESSES_H_ */ diff --git a/unittest/testcfg/devices/powerSwitcherList.cpp b/unittest/testcfg/devices/powerSwitcherList.cpp new file mode 100644 index 00000000..343f78d0 --- /dev/null +++ b/unittest/testcfg/devices/powerSwitcherList.cpp @@ -0,0 +1,4 @@ +#include "powerSwitcherList.h" + + + diff --git a/unittest/testcfg/devices/powerSwitcherList.h b/unittest/testcfg/devices/powerSwitcherList.h new file mode 100644 index 00000000..86ddea57 --- /dev/null +++ b/unittest/testcfg/devices/powerSwitcherList.h @@ -0,0 +1,12 @@ +#ifndef CONFIG_DEVICES_POWERSWITCHERLIST_H_ +#define CONFIG_DEVICES_POWERSWITCHERLIST_H_ + +namespace switches { + /* Switches are uint8_t datatype and go from 0 to 255 */ + enum switcherList { + }; + +} + + +#endif /* CONFIG_DEVICES_POWERSWITCHERLIST_H_ */ diff --git a/unittest/testcfg/events/subsystemIdRanges.h b/unittest/testcfg/events/subsystemIdRanges.h new file mode 100644 index 00000000..24eee819 --- /dev/null +++ b/unittest/testcfg/events/subsystemIdRanges.h @@ -0,0 +1,18 @@ +#ifndef CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ +#define CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ + +#include +#include + +/** + * @brief Custom subsystem IDs can be added here + * @details + * Subsystem IDs are used to create unique events. + */ +namespace SUBSYSTEM_ID { +enum: uint8_t { + SUBSYSTEM_ID_START = FW_SUBSYSTEM_ID_RANGE, +}; +} + +#endif /* CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ */ diff --git a/unittest/testcfg/ipc/MissionMessageTypes.cpp b/unittest/testcfg/ipc/MissionMessageTypes.cpp new file mode 100644 index 00000000..d68cb58c --- /dev/null +++ b/unittest/testcfg/ipc/MissionMessageTypes.cpp @@ -0,0 +1,12 @@ +#include "MissionMessageTypes.h" + +#include + +void messagetypes::clearMissionMessage(CommandMessage* message) { + switch(message->getMessageType()) { + default: + break; + } +} + + diff --git a/unittest/testcfg/ipc/MissionMessageTypes.h b/unittest/testcfg/ipc/MissionMessageTypes.h new file mode 100644 index 00000000..832d8e58 --- /dev/null +++ b/unittest/testcfg/ipc/MissionMessageTypes.h @@ -0,0 +1,22 @@ +#ifndef CONFIG_IPC_MISSIONMESSAGETYPES_H_ +#define CONFIG_IPC_MISSIONMESSAGETYPES_H_ + +#include + +class CommandMessage; + +/** + * Custom command messages are specified here. + * Most messages needed to use FSFW are already located in + * + * @param message Generic Command Message + */ +namespace messagetypes{ +enum MESSAGE_TYPE { + MISSION_MESSAGE_TYPE_START = FW_MESSAGES_COUNT, +}; + +void clearMissionMessage(CommandMessage* message); +} + +#endif /* CONFIG_IPC_MISSIONMESSAGETYPES_H_ */ diff --git a/unittest/testcfg/objects/systemObjectList.h b/unittest/testcfg/objects/systemObjectList.h new file mode 100644 index 00000000..efd21e0d --- /dev/null +++ b/unittest/testcfg/objects/systemObjectList.h @@ -0,0 +1,32 @@ +#ifndef HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ +#define HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ + +#include +#include + +// The objects will be instantiated in the ID order +namespace objects { + enum sourceObjects: uint32_t { + /* All addresses between start and end are reserved for the FSFW */ + FSFW_CONFIG_RESERVED_START = PUS_SERVICE_1_VERIFICATION, + FSFW_CONFIG_RESERVED_END = TM_STORE, + + CCSDS_DISTRIBUTOR = 10, + PUS_DISTRIBUTOR = 11, + TM_FUNNEL = 12, + + UDP_BRIDGE = 15, + UDP_POLLING_TASK = 16, + + TEST_ECHO_COM_IF = 20, + TEST_DEVICE = 21, + + HK_RECEIVER_MOCK = 22, + TEST_LOCAL_POOL_OWNER_BASE = 25, + + SHARED_SET_ID = 26 + + }; +} + +#endif /* BSP_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ */ diff --git a/unittest/testcfg/pollingsequence/PollingSequenceFactory.cpp b/unittest/testcfg/pollingsequence/PollingSequenceFactory.cpp new file mode 100644 index 00000000..e3ee874a --- /dev/null +++ b/unittest/testcfg/pollingsequence/PollingSequenceFactory.cpp @@ -0,0 +1,39 @@ +#include "PollingSequenceFactory.h" + +#include + +#include +#include +#include + +ReturnValue_t pst::pollingSequenceInitDefault( + FixedTimeslotTaskIF *thisSequence) { + /* Length of a communication cycle */ + uint32_t length = thisSequence->getPeriodMs(); + + /* Add polling sequence table here */ + thisSequence->addSlot(objects::TEST_DEVICE, 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::TEST_DEVICE, 0.3, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::TEST_DEVICE, 0.45 * length, + DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::TEST_DEVICE, 0.6 * length, + DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::TEST_DEVICE, 0.8 * length, + DeviceHandlerIF::GET_READ); + + if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { + return HasReturnvaluesIF::RETURN_OK; + } + else { +#if FSFW_CPP_OSTREAM_ENABLED + sif::error << "pst::pollingSequenceInitDefault: Sequence invalid!" + << std::endl; +#else + sif::printError("pst::pollingSequenceInitDefault: Sequence invalid!"); +#endif + return HasReturnvaluesIF::RETURN_FAILED; + } +} + diff --git a/unittest/testcfg/pollingsequence/PollingSequenceFactory.h b/unittest/testcfg/pollingsequence/PollingSequenceFactory.h new file mode 100644 index 00000000..c5d41b7d --- /dev/null +++ b/unittest/testcfg/pollingsequence/PollingSequenceFactory.h @@ -0,0 +1,32 @@ +#ifndef POLLINGSEQUENCEFACTORY_H_ +#define POLLINGSEQUENCEFACTORY_H_ + +#include + +class FixedTimeslotTaskIF; + +/** + * All device handlers are scheduled by adding them into Polling Sequence Tables (PST) + * to satisfy stricter timing requirements of device communication, + * A device handler has four different communication steps: + * 1. DeviceHandlerIF::SEND_WRITE -> Send write via interface + * 2. DeviceHandlerIF::GET_WRITE -> Get confirmation for write + * 3. DeviceHandlerIF::SEND_READ -> Send read request + * 4. DeviceHandlerIF::GET_READ -> Read from interface + * The PST specifies precisely when the respective ComIF functions are called + * during the communication cycle time. + * The task is created using the FixedTimeslotTaskIF, + * which utilises the underlying Operating System Abstraction Layer (OSAL) + * + * @param thisSequence FixedTimeslotTaskIF * object is passed inside the Factory class when creating the PST + * @return + */ +namespace pst { + +/* Default PST */ +ReturnValue_t pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence); + + +} + +#endif /* POLLINGSEQUENCEINIT_H_ */ diff --git a/unittest/testcfg/returnvalues/classIds.h b/unittest/testcfg/returnvalues/classIds.h new file mode 100644 index 00000000..606cc60b --- /dev/null +++ b/unittest/testcfg/returnvalues/classIds.h @@ -0,0 +1,16 @@ +#ifndef CONFIG_RETURNVALUES_CLASSIDS_H_ +#define CONFIG_RETURNVALUES_CLASSIDS_H_ + +#include + +/** + * @brief CLASS_ID defintions which are required for custom returnvalues. + */ +namespace CLASS_ID { +enum { + MISSION_CLASS_ID_START = FW_CLASS_ID_COUNT, +}; +} + + +#endif /* CONFIG_RETURNVALUES_CLASSIDS_H_ */ diff --git a/unittest/testcfg/tmtc/apid.h b/unittest/testcfg/tmtc/apid.h new file mode 100644 index 00000000..c0231bca --- /dev/null +++ b/unittest/testcfg/tmtc/apid.h @@ -0,0 +1,18 @@ +#ifndef CONFIG_TMTC_APID_H_ +#define CONFIG_TMTC_APID_H_ + +#include + +/** + * Application Process Definition: entity, uniquely identified by an + * application process ID (APID), capable of generating telemetry source + * packets and receiving telecommand packets. + * + * Chose APID(s) for mission and define it here. + */ +namespace apid { + static const uint16_t DEFAULT_APID = 0x00; +} + + +#endif /* CONFIG_TMTC_APID_H_ */ diff --git a/unittest/testcfg/tmtc/pusIds.h b/unittest/testcfg/tmtc/pusIds.h new file mode 100644 index 00000000..821a9982 --- /dev/null +++ b/unittest/testcfg/tmtc/pusIds.h @@ -0,0 +1,25 @@ +#ifndef CONFIG_TMTC_PUSIDS_HPP_ +#define CONFIG_TMTC_PUSIDS_HPP_ + +#include + +namespace pus { +enum Ids: uint8_t { + PUS_SERVICE_1 = 1, + PUS_SERVICE_2 = 2, + PUS_SERVICE_3 = 3, + PUS_SERVICE_5 = 5, + PUS_SERVICE_6 = 6, + PUS_SERVICE_8 = 8, + PUS_SERVICE_9 = 9, + PUS_SERVICE_11 = 11, + PUS_SERVICE_17 = 17, + PUS_SERVICE_19 = 19, + PUS_SERVICE_20 = 20, + PUS_SERVICE_23 = 23, + PUS_SERVICE_200 = 200, + PUS_SERVICE_201 = 201, +}; +}; + +#endif /* CONFIG_TMTC_PUSIDS_HPP_ */ diff --git a/unittest/unittest.mk b/unittest/unittest.mk deleted file mode 100644 index e69de29b..00000000 From e4286d18d4289e2426a7096cf45813338609510b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 29 Sep 2021 09:37:29 +0200 Subject: [PATCH 031/465] only use unique name for EIVE OBSW --- CMakeLists.txt | 7 ++++++- bsp_hosted/ObjectFactory.cpp | 13 ------------- .../eclipse/Host/eive-linux-host-debug-cmake.launch | 2 +- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 54915f2c..2381568d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,12 @@ endif() include(${CMAKE_SCRIPT_PATH}/PreProjectConfig.cmake) pre_project_config() -set(PROJECT_NAME_TO_SET eive-obsw-$ENV{USERNAME}) +if(TGT_BSP MATCHES "arm/q7s") + set(PROJECT_NAME_TO_SET eive-obsw-$ENV{USERNAME}) +else() + set(PROJECT_NAME_TO_SET eive-obsw) +endif() + if(EIVE_BUILD_WATCHDOG) set(PROJECT_NAME_TO_SET eive-watchdog) endif() diff --git a/bsp_hosted/ObjectFactory.cpp b/bsp_hosted/ObjectFactory.cpp index d7878e46..6803ace4 100644 --- a/bsp_hosted/ObjectFactory.cpp +++ b/bsp_hosted/ObjectFactory.cpp @@ -44,18 +44,5 @@ void ObjectFactory::produce(void* args){ Factory::setStaticFrameworkObjectIds(); ObjectFactory::produceGenericObjects(); -#if OBSW_USE_TMTC_TCP_BRIDGE == 0 - sif::info << "Setting up UDP TMTC bridge with listener port " << - UdpTmTcBridge::DEFAULT_SERVER_PORT << std::endl; - new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); -#else - sif::info << "Setting up TCP TMTC bridge with listener port " << - TcpTmTcServer::DEFAULT_SERVER_PORT << std::endl; - new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); -#endif - new TestTask(objects::TEST_TASK); - } diff --git a/misc/eclipse/Host/eive-linux-host-debug-cmake.launch b/misc/eclipse/Host/eive-linux-host-debug-cmake.launch index 294772d8..d8cfc8c1 100644 --- a/misc/eclipse/Host/eive-linux-host-debug-cmake.launch +++ b/misc/eclipse/Host/eive-linux-host-debug-cmake.launch @@ -18,7 +18,7 @@ - + From f61d0e83f05b10ab178c63d8f0f9ad78a6131ab9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 29 Sep 2021 10:52:36 +0200 Subject: [PATCH 032/465] refactoring for added unittests --- CMakeLists.txt | 42 +++++++++---- common/config/devices/powerSwitcherList.h | 60 +++++++++++++++++++ .../fsfwconfig => common/config}/tmtc/apid.h | 0 fsfw | 2 +- .../Host/eive-linux-host-unittest.launch | 33 ++++++++++ mission/core/GenericFactory.cpp | 1 + unittest/CMakeLists.txt | 4 ++ unittest/main.cpp | 6 ++ unittest/testcfg/FSFWConfig.h.in | 5 +- unittest/testcfg/events/subsystemIdRanges.h | 1 + unittest/testcfg/objects/systemObjectList.h | 1 + unittest/testcfg/returnvalues/classIds.h | 1 + unittest/testcfg/tmtc/apid.h | 2 +- 13 files changed, 142 insertions(+), 16 deletions(-) create mode 100644 common/config/devices/powerSwitcherList.h rename {linux/fsfwconfig => common/config}/tmtc/apid.h (100%) create mode 100644 misc/eclipse/Host/eive-linux-host-unittest.launch create mode 100644 unittest/main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 2381568d..f57031cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,16 +35,16 @@ endif() include(${CMAKE_SCRIPT_PATH}/PreProjectConfig.cmake) pre_project_config() -if(TGT_BSP MATCHES "arm/q7s") +if(EIVE_BUILD_WATCHDOG) + set(PROJECT_NAME_TO_SET eive-watchdog) +elseif(EIVE_BUILD_UNITTESTS) + set(PROJECT_NAME_TO_SET eive-unittest) +elseif(TGT_BSP MATCHES "arm/q7s") set(PROJECT_NAME_TO_SET eive-obsw-$ENV{USERNAME}) else() set(PROJECT_NAME_TO_SET eive-obsw) endif() -if(EIVE_BUILD_WATCHDOG) - set(PROJECT_NAME_TO_SET eive-watchdog) -endif() - # Project Name project(${PROJECT_NAME_TO_SET} ASM C CXX) @@ -77,6 +77,7 @@ set(LINUX_PATH linux) set(COMMON_PATH common) set(WATCHDOG_PATH watchdog) set(COMMON_CONFIG_PATH ${COMMON_PATH}/config) +set(UNITTEST_CFG_PATH ${UNITTEST_PATH}/testcfg) set(LIB_CSP_PATH ${THIRD_PARTY_FOLDER}/libcsp) set(LIB_ETL_PATH ${THIRD_PARTY_FOLDER}/etl) @@ -88,6 +89,10 @@ set(LIB_JSON_PATH ${THIRD_PARTY_FOLDER}/json) set(FSFW_WARNING_SHADOW_LOCAL_GCC OFF) set(EIVE_ADD_LINUX_FILES False) +if(EIVE_BUILD_UNITTESTS) + option(FSFW_ADD_UNITTESTS "Build the FSFW unittests as well" ON) +endif() + if(FSFW_CUSTOM_UNITTEST_RUNNER OR FSFW_ADD_UNITTESTS) set(CATCH2_TARGET Catch2) else() @@ -131,6 +136,11 @@ else() set(FSFW_CONFIG_PATH "${BSP_PATH}/fsfwconfig") endif() +if(EIVE_BUILD_UNITTESTS) + configure_file(${UNITTEST_CFG_PATH}/TestsConfig.h.in TestsConfig.h) + set(FSFW_CONFIG_PATH ${UNITTEST_CFG_PATH}) +endif() + # Configuration files if(NOT EIVE_BUILD_WATCHDOG) configure_file(${COMMON_CONFIG_PATH}/commonConfig.h.in commonConfig.h) @@ -142,6 +152,9 @@ if(NOT EIVE_BUILD_WATCHDOG) configure_file(${BSP_PATH}/boardconfig/rpiConfig.h.in rpiConfig.h) endif() endif() + + + configure_file(${WATCHDOG_PATH}/watchdogConf.h.in watchdogConf.h) # Set common config path for FSFW @@ -166,14 +179,16 @@ if(EIVE_ADD_JSON_LIB) endif() if(NOT EIVE_BUILD_WATCHDOG) - if(EIVE_ADD_LINUX_FILES) - add_subdirectory(${LINUX_PATH}) + if(NOT EIVE_BUILD_UNITTESTS) + if(EIVE_ADD_LINUX_FILES) + add_subdirectory(${LINUX_PATH}) + endif() + add_subdirectory(${BSP_PATH}) + if(ADD_CSP_LIB) + add_subdirectory(${LIB_CSP_PATH}) + endif() endif() - add_subdirectory(${BSP_PATH}) add_subdirectory(${COMMON_PATH}) - if(ADD_CSP_LIB) - add_subdirectory(${LIB_CSP_PATH}) - endif() endif() if((NOT BUILD_Q7S_SIMPLE_MODE) AND (NOT EIVE_BUILD_WATCHDOG)) @@ -184,7 +199,8 @@ if((NOT BUILD_Q7S_SIMPLE_MODE) AND (NOT EIVE_BUILD_WATCHDOG)) add_subdirectory(${LIB_ARCSEC_PATH}) endif() -if(EIVE_BUILD_UNITTEST) +if(EIVE_BUILD_UNITTESTS) + add_subdirectory(${LIB_CATCH2_PATH}) add_subdirectory(${UNITTEST_PATH}) endif() @@ -234,7 +250,7 @@ if(EIVE_ADD_JSON_LIB) ) endif() -if(EIVE_BUILD_UNITTEST) +if(EIVE_BUILD_UNITTESTS) target_link_libraries(${TARGET_NAME} PRIVATE ${CATCH2_TARGET} ) diff --git a/common/config/devices/powerSwitcherList.h b/common/config/devices/powerSwitcherList.h new file mode 100644 index 00000000..45428a2e --- /dev/null +++ b/common/config/devices/powerSwitcherList.h @@ -0,0 +1,60 @@ +#ifndef FSFWCONFIG_DEVICES_POWERSWITCHERLIST_H_ +#define FSFWCONFIG_DEVICES_POWERSWITCHERLIST_H_ + +#include "OBSWConfig.h" + +#include + +namespace pcduSwitches { + /* Switches are uint8_t datatype and go from 0 to 255 */ + enum SwitcherList: uint8_t { + Q7S, + PAYLOAD_PCDU_CH1, + RW, + TCS_BOARD_8V_HEATER_IN, + SUS_REDUNDANT, + DEPLOYMENT_MECHANISM, + PAYLOAD_PCDU_CH6, + ACS_BOARD_SIDE_B, + PAYLOAD_CAMERA, + TCS_BOARD_3V3, + SYRLINKS, + STAR_TRACKER, + MGT, + SUS_NOMINAL, + SOLAR_CELL_EXP, + PLOC, + ACS_BOARD_SIDE_A, + NUMBER_OF_SWITCHES + }; + + static const uint8_t ON = 1; + static const uint8_t OFF = 0; + + /* Output states after reboot of the PDUs */ + static const uint8_t INIT_STATE_Q7S = ON; + static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH1 = OFF; + static const uint8_t INIT_STATE_RW = OFF; +#if BOARD_TE0720 == 1 + /* Because the TE0720 is not connected to the PCDU, this switch is always on */ + static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = ON; +#else + static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = OFF; +#endif + static const uint8_t INIT_STATE_SUS_REDUNDANT = OFF; + static const uint8_t INIT_STATE_DEPLOYMENT_MECHANISM = OFF; + static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH6 = OFF; + static const uint8_t INIT_STATE_ACS_BOARD_SIDE_B = OFF; + static const uint8_t INIT_STATE_PAYLOAD_CAMERA = OFF; + static const uint8_t INIT_STATE_TCS_BOARD_3V3 = OFF; + static const uint8_t INIT_STATE_SYRLINKS = OFF; + static const uint8_t INIT_STATE_STAR_TRACKER = OFF; + static const uint8_t INIT_STATE_MGT = OFF; + static const uint8_t INIT_STATE_SUS_NOMINAL = OFF; + static const uint8_t INIT_STATE_SOLAR_CELL_EXP = OFF; + static const uint8_t INIT_STATE_PLOC = OFF; + static const uint8_t INIT_STATE_ACS_BOARD_SIDE_A = OFF; +} + + +#endif /* FSFWCONFIG_DEVICES_POWERSWITCHERLIST_H_ */ diff --git a/linux/fsfwconfig/tmtc/apid.h b/common/config/tmtc/apid.h similarity index 100% rename from linux/fsfwconfig/tmtc/apid.h rename to common/config/tmtc/apid.h diff --git a/fsfw b/fsfw index 354e158c..04cb8e82 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 354e158cc196d7deaf7de24ebcc96f5f6f5f20eb +Subproject commit 04cb8e82f1aaae89e20985539c74c1e36bb85ae3 diff --git a/misc/eclipse/Host/eive-linux-host-unittest.launch b/misc/eclipse/Host/eive-linux-host-unittest.launch new file mode 100644 index 00000000..048b7f3d --- /dev/null +++ b/misc/eclipse/Host/eive-linux-host-unittest.launch @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index df15025b..a0939f1c 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -4,6 +4,7 @@ #include #include +#include "objects/systemObjectList.h" #include #include diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index ce562b28..0c799d45 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -1 +1,5 @@ add_subdirectory(testcfg) + +target_sources(${TARGET_NAME} PRIVATE + main.cpp +) \ No newline at end of file diff --git a/unittest/main.cpp b/unittest/main.cpp new file mode 100644 index 00000000..c76e214a --- /dev/null +++ b/unittest/main.cpp @@ -0,0 +1,6 @@ +#include "fsfw_tests/unit/CatchRunner.h" + +int main(int argc, char* argv[]) { + fsfwtest::customMain(argc, argv); +} + diff --git a/unittest/testcfg/FSFWConfig.h.in b/unittest/testcfg/FSFWConfig.h.in index d38f0648..d2ed901d 100644 --- a/unittest/testcfg/FSFWConfig.h.in +++ b/unittest/testcfg/FSFWConfig.h.in @@ -7,7 +7,7 @@ //! Used to determine whether C++ ostreams are used which can increase //! the binary size significantly. If this is disabled, //! the C stdio functions can be used alternatively -#define FSFW_CPP_OSTREAM_ENABLED 0 +#define FSFW_CPP_OSTREAM_ENABLED 1 //! More FSFW related printouts. Useful for development. #define FSFW_ENHANCED_PRINTOUT 0 @@ -20,6 +20,9 @@ #endif #endif +#define FSFW_USE_PUS_C_TELEMETRY 1 +#define FSFW_USE_PUS_C_TELECOMMANDS 1 + //! Can be used to enable additional debugging printouts for developing the FSFW #define FSFW_PRINT_VERBOSITY_LEVEL 0 diff --git a/unittest/testcfg/events/subsystemIdRanges.h b/unittest/testcfg/events/subsystemIdRanges.h index 24eee819..26af041e 100644 --- a/unittest/testcfg/events/subsystemIdRanges.h +++ b/unittest/testcfg/events/subsystemIdRanges.h @@ -2,6 +2,7 @@ #define CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ #include +#include "commonSubsystemIds.h" #include /** diff --git a/unittest/testcfg/objects/systemObjectList.h b/unittest/testcfg/objects/systemObjectList.h index efd21e0d..9ed43873 100644 --- a/unittest/testcfg/objects/systemObjectList.h +++ b/unittest/testcfg/objects/systemObjectList.h @@ -2,6 +2,7 @@ #define HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ #include +#include "commonObjects.h" #include // The objects will be instantiated in the ID order diff --git a/unittest/testcfg/returnvalues/classIds.h b/unittest/testcfg/returnvalues/classIds.h index 606cc60b..7a292708 100644 --- a/unittest/testcfg/returnvalues/classIds.h +++ b/unittest/testcfg/returnvalues/classIds.h @@ -1,6 +1,7 @@ #ifndef CONFIG_RETURNVALUES_CLASSIDS_H_ #define CONFIG_RETURNVALUES_CLASSIDS_H_ +#include "commonClassIds.h" #include /** diff --git a/unittest/testcfg/tmtc/apid.h b/unittest/testcfg/tmtc/apid.h index c0231bca..0172f6e3 100644 --- a/unittest/testcfg/tmtc/apid.h +++ b/unittest/testcfg/tmtc/apid.h @@ -11,7 +11,7 @@ * Chose APID(s) for mission and define it here. */ namespace apid { - static const uint16_t DEFAULT_APID = 0x00; + static const uint16_t EIVE_OBSW = 0x65; } From 825682c36d0e9e10e1d8878e8ad5ae7e739a1f62 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 29 Sep 2021 10:59:37 +0200 Subject: [PATCH 033/465] unittests working --- CMakeLists.txt | 2 + fsfw | 2 +- misc/eclipse/.cproject | 66 +++++++++++++++++++ misc/eclipse/.project | 2 +- .../Host/eive-linux-host-unittest.launch | 4 +- unittest/main.cpp | 1 + 6 files changed, 73 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f57031cf..656ee3ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,6 +91,8 @@ set(EIVE_ADD_LINUX_FILES False) if(EIVE_BUILD_UNITTESTS) option(FSFW_ADD_UNITTESTS "Build the FSFW unittests as well" ON) + # Use FSFW custom main for unittests + set(FSFW_CUSTOM_UNITTEST_RUNNER ON) endif() if(FSFW_CUSTOM_UNITTEST_RUNNER OR FSFW_ADD_UNITTESTS) diff --git a/fsfw b/fsfw index 04cb8e82..3d0ce199 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 04cb8e82f1aaae89e20985539c74c1e36bb85ae3 +Subproject commit 3d0ce1998114c5d7a43034233ee03a800c8821b0 diff --git a/misc/eclipse/.cproject b/misc/eclipse/.cproject index fe0208b8..7d7c4c09 100644 --- a/misc/eclipse/.cproject +++ b/misc/eclipse/.cproject @@ -1357,6 +1357,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1374,6 +1436,7 @@ + @@ -1385,6 +1448,9 @@ + + + diff --git a/misc/eclipse/.project b/misc/eclipse/.project index 86d98589..62145ff4 100644 --- a/misc/eclipse/.project +++ b/misc/eclipse/.project @@ -7,7 +7,7 @@ org.eclipse.cdt.managedbuilder.core.genmakebuilder - full,incremental, + clean,full,incremental, diff --git a/misc/eclipse/Host/eive-linux-host-unittest.launch b/misc/eclipse/Host/eive-linux-host-unittest.launch index 048b7f3d..85d54281 100644 --- a/misc/eclipse/Host/eive-linux-host-unittest.launch +++ b/misc/eclipse/Host/eive-linux-host-unittest.launch @@ -18,10 +18,10 @@ - + - + diff --git a/unittest/main.cpp b/unittest/main.cpp index c76e214a..cd4f4b77 100644 --- a/unittest/main.cpp +++ b/unittest/main.cpp @@ -1,3 +1,4 @@ +#include "fsfw/serviceinterface/ServiceInterfaceStream.h" #include "fsfw_tests/unit/CatchRunner.h" int main(int argc, char* argv[]) { From 8e23be665bcba8e53bf777d9f5b3ebb364615d5a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 29 Sep 2021 11:02:41 +0200 Subject: [PATCH 034/465] updated README --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index b12400e9..b6a18947 100644 --- a/README.md +++ b/README.md @@ -171,6 +171,26 @@ cmake -DTGT_BSP=arm/q7s -DFSFW_OSAL=linux -DEIVE_BUILD_WATCHDOG=ON -DCMAKE_BUILD cmake --build . -j ``` +### Hosted + +You can also replace `linux` by `host` for this command to build on Windows or for generic OSes + +```sh +mkdir build-Debug-Host && cd build-Debug-Host +cmake -DFSFW_OSAL=linux -DCMAKE_BUILD_TYPE=Debug .. +cmake --build . -j +``` + +### Unittests + +You can also replace `linux` by `host` for this command to build on Windows + +```sh +mkdir build-Debug-Unittest && cd build-Debug-Unittest +cmake -DFSFW_OSAL=linux -DEIVE_BUILD_UNITTESTS=ON .. +cmake --build . -j +``` + ## Connect to EIVE flatsat ### DNS From 0499fd03dadb3fc68c5f0db95d1934e12f0db934 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 29 Sep 2021 12:31:22 +0200 Subject: [PATCH 035/465] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 82495ad7..4bf23fb7 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 82495ad785c83440ee90846bce70be1659b66209 +Subproject commit 4bf23fb764e3d1eca752a9c928a3b95f2c4272c4 From 55d31d0dc259df379aa53738bb82f017ee48082b Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Wed, 29 Sep 2021 14:47:20 +0200 Subject: [PATCH 036/465] ccsds handler --- bsp_q7s/core/InitMission.cpp | 8 ++++++++ bsp_q7s/core/ObjectFactory.cpp | 4 ++-- linux/fsfwconfig/OBSWConfig.h.in | 1 + linux/obc/PapbVcInterface.cpp | 2 +- linux/obc/Ptme.h | 6 +++++- mission/tmtc/CCSDSHandler.cpp | 10 ++++++++++ mission/tmtc/VirtualChannel.cpp | 7 ++++--- mission/tmtc/VirtualChannel.h | 11 +++++++++-- tmtc | 2 +- 9 files changed, 41 insertions(+), 10 deletions(-) diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index e7d8779b..06cf5ca9 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -96,6 +96,13 @@ void initmission::initTasks() { initmission::printAddObjectError("UDP_POLLING", objects::TMTC_POLLING_TASK); } + PeriodicTaskIF* ccsdsHandlerTask = factory->createPeriodicTask( + "UDP_POLLING", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = ccsdsHandlerTask->addComponent(objects::CCSDS_HANDLER); + if(result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("CCSDS Handler", objects::CCSDS_HANDLER); + } + # if BOARD_TE0720 == 0 // FS task, task interval does not matter because it runs in permanent loop, priority low // because it is a non-essential background task @@ -141,6 +148,7 @@ void initmission::initTasks() { tmTcDistributor->startTask(); tmtcBridgeTask->startTask(); tmtcPollingTask->startTask(); + ccsdsHandlerTask->startTask(); #if BOARD_TE0720 == 0 coreController->startTask(); #endif diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 86709292..c36d05e1 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -948,9 +948,9 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF *gpioComIF) { ccsdsHandler->addVirtualChannel(ccsds::VC0, vc); vc = new VirtualChannel(ccsds::VC1, config::VC1_QUEUE_SIZE); ccsdsHandler->addVirtualChannel(ccsds::VC1, vc); - vc = new VirtualChannel(2, config::VC2_QUEUE_SIZE); + vc = new VirtualChannel(ccsds::VC2, config::VC2_QUEUE_SIZE); ccsdsHandler->addVirtualChannel(ccsds::VC2, vc); - vc = new VirtualChannel(3, config::VC3_QUEUE_SIZE); + vc = new VirtualChannel(ccsds::VC3, config::VC3_QUEUE_SIZE); ccsdsHandler->addVirtualChannel(ccsds::VC3, vc); } diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index afaed4a5..d54ab39a 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -86,6 +86,7 @@ debugging. */ #define OBSW_TEST_TE7020_HEATER 0 #define OBSW_TEST_GPIO_OPEN_BY_LABEL 0 #define OBSW_TEST_GPIO_OPEN_BY_LINE_NAME 0 +#define OBSW_LINK_IS_UP 0 #define OBSW_DEBUG_P60DOCK 0 #define OBSW_DEBUG_PDU1 0 diff --git a/linux/obc/PapbVcInterface.cpp b/linux/obc/PapbVcInterface.cpp index 6cbd81a3..5bb72066 100644 --- a/linux/obc/PapbVcInterface.cpp +++ b/linux/obc/PapbVcInterface.cpp @@ -26,7 +26,7 @@ ReturnValue_t PapbVcInterface::write(const uint8_t * data, size_t size) { *(vcBaseReg + DATA_REG_OFFSET) = static_cast(*(data + idx)); } else { - sif::warning << "PapbVcInterface::sendTm: Only written " << idx - 1 << " of " + sif::warning << "PapbVcInterface::write: Only written " << idx << " of " << size << " data" << std::endl; return RETURN_FAILED; } diff --git a/linux/obc/Ptme.h b/linux/obc/Ptme.h index aa131d9e..753cc08f 100644 --- a/linux/obc/Ptme.h +++ b/linux/obc/Ptme.h @@ -48,9 +48,13 @@ private: 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 = 0x1000; +#else /** Size of mapped address space */ static const int MAP_SIZE = 0x40000; +#endif /* BOARD_TE0720 == 1 */ /** * Configuration bits: diff --git a/mission/tmtc/CCSDSHandler.cpp b/mission/tmtc/CCSDSHandler.cpp index 2a337d68..95d557ee 100644 --- a/mission/tmtc/CCSDSHandler.cpp +++ b/mission/tmtc/CCSDSHandler.cpp @@ -43,6 +43,16 @@ ReturnValue_t CCSDSHandler::initialize() { if (result != HasReturnvaluesIF::RETURN_OK) { return result; } + + VirtualChannelMapIter iter; + for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { + result = iter->second->initialize(); + if (result != RETURN_OK) { + return result; + } + iter->second->setPtmeObject(ptme); + } + return result; } diff --git a/mission/tmtc/VirtualChannel.cpp b/mission/tmtc/VirtualChannel.cpp index 1f8f5ffb..3423692b 100644 --- a/mission/tmtc/VirtualChannel.cpp +++ b/mission/tmtc/VirtualChannel.cpp @@ -56,11 +56,12 @@ MessageQueueId_t VirtualChannel::getReportReceptionQueue(uint8_t virtualChannel) return tmQueue->getId(); } -void VirtualChannel::setPtmeObject(PtmeIF* ptme) { - if (ptme == nullptr) { +void VirtualChannel::setPtmeObject(PtmeIF* ptme_) { + if (ptme_ == nullptr) { sif::warning << "VirtualChannel::setPtmeObject: Invalid ptme object" << std::endl; + return; } - ptme = ptme; + ptme = ptme_; } void VirtualChannel::setLinkState(bool linkIsUp) { diff --git a/mission/tmtc/VirtualChannel.h b/mission/tmtc/VirtualChannel.h index d897e2d6..d7d95cb7 100644 --- a/mission/tmtc/VirtualChannel.h +++ b/mission/tmtc/VirtualChannel.h @@ -1,6 +1,7 @@ #ifndef VIRTUALCHANNEL_H_ #define VIRTUALCHANNEL_H_ +#include "OBSWConfig.h" #include "fsfw/tmtcservices/AcceptsTelemetryIF.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include @@ -31,7 +32,7 @@ class VirtualChannel: public AcceptsTelemetryIF, public HasReturnvaluesIF { * * @param ptme Pointer to ptme object */ - void setPtmeObject(PtmeIF* ptme); + void setPtmeObject(PtmeIF* ptme_); /** * @brief Can be used by the owner to set the link state. Packets will be discarded if link @@ -44,7 +45,13 @@ private: PtmeIF* ptme = nullptr; MessageQueueIF* tmQueue = nullptr; uint8_t vcId; - bool linkIsUp; + +#if OBSW_LINK_IS_UP == 1 + bool linkIsUp = true; +#else + bool linkIsUp = false; +#endif /* OBSW_LINK_IS_UP == 1 */ + StorageManagerIF* tmStore = nullptr; }; diff --git a/tmtc b/tmtc index 53bf6508..bad6a42a 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 53bf65083889af10f77c3899972b1153ea835f3c +Subproject commit bad6a42af715f62ddc2a593a5f1ce344fde96da7 From 3ca18a42adeac8721f8f1c312dba2de5c9fd801b Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 30 Sep 2021 09:34:01 +0200 Subject: [PATCH 037/465] live tm variable --- linux/fsfwconfig/OBSWConfig.h.in | 2 ++ linux/obc/Ptme.h | 2 +- mission/utility/TmFunnel.cpp | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index d54ab39a..a714e850 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -131,6 +131,8 @@ static constexpr uint8_t VC1_QUEUE_SIZE = 50; static constexpr uint8_t VC2_QUEUE_SIZE = 50; static constexpr uint8_t VC3_QUEUE_SIZE = 50; +static constexpr uint8_t LIVE_TM = 0; + #ifdef __cplusplus } #endif diff --git a/linux/obc/Ptme.h b/linux/obc/Ptme.h index 753cc08f..be687e17 100644 --- a/linux/obc/Ptme.h +++ b/linux/obc/Ptme.h @@ -50,7 +50,7 @@ private: #if BOARD_TE0720 == 1 /** Size of mapped address space */ - static const int MAP_SIZE = 0x1000; + static const int MAP_SIZE = 0x40000; #else /** Size of mapped address space */ static const int MAP_SIZE = 0x40000; diff --git a/mission/utility/TmFunnel.cpp b/mission/utility/TmFunnel.cpp index 5838ae75..4b9eebdf 100644 --- a/mission/utility/TmFunnel.cpp +++ b/mission/utility/TmFunnel.cpp @@ -101,7 +101,7 @@ ReturnValue_t TmFunnel::initialize() { #if OBSW_TM_TO_PTME == 1 // Live TM will be sent via the virtual channel 0 - tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue(0)); + tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue(config::LIVE_TM)); #else tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue()); #endif /* OBSW_TM_TO_PTME == 1 */ From 82b72e66ee286b8e7d2e29e184cf94607e348b75 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 4 Oct 2021 11:37:54 +0200 Subject: [PATCH 038/465] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 4bf23fb7..ba866a5f 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 4bf23fb764e3d1eca752a9c928a3b95f2c4272c4 +Subproject commit ba866a5f0aead78945323b5fe2bfa2a3d3e41f71 From 7ae02d43a7759ad71f83f92fc2ec5274ea5021a1 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 4 Oct 2021 14:47:32 +0200 Subject: [PATCH 039/465] added preprocessor defines to exclude CCSDS Handler --- bsp_q7s/core/InitMission.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index 06cf5ca9..e6e1e48f 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -96,12 +96,14 @@ void initmission::initTasks() { initmission::printAddObjectError("UDP_POLLING", objects::TMTC_POLLING_TASK); } +#if OBSW_USE_CCSDS_IP_CORE == 1 PeriodicTaskIF* ccsdsHandlerTask = factory->createPeriodicTask( "UDP_POLLING", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); result = ccsdsHandlerTask->addComponent(objects::CCSDS_HANDLER); if(result != HasReturnvaluesIF::RETURN_OK) { initmission::printAddObjectError("CCSDS Handler", objects::CCSDS_HANDLER); } +#endif /* OBSW_USE_CCSDS_IP_CORE == 1 */ # if BOARD_TE0720 == 0 // FS task, task interval does not matter because it runs in permanent loop, priority low @@ -148,7 +150,11 @@ void initmission::initTasks() { tmTcDistributor->startTask(); tmtcBridgeTask->startTask(); tmtcPollingTask->startTask(); + +#if OBSW_USE_CCSDS_IP_CORE == 1 ccsdsHandlerTask->startTask(); +#endif /* OBSW_USE_CCSDS_IP_CORE == 1 */ + #if BOARD_TE0720 == 0 coreController->startTask(); #endif From 47733a564894acbbaa726a4136a8d0de4cda91fa Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 5 Oct 2021 01:28:20 +0200 Subject: [PATCH 040/465] fsfw and tmtc update --- fsfw | 2 +- tmtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsfw b/fsfw index 3d0ce199..94bd4c7b 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 3d0ce1998114c5d7a43034233ee03a800c8821b0 +Subproject commit 94bd4c7b56f9f22cdec118df8e681ed30a2f47b3 diff --git a/tmtc b/tmtc index ba866a5f..706f79a1 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit ba866a5f0aead78945323b5fe2bfa2a3d3e41f71 +Subproject commit 706f79a1f2cc7c909fe995e8473ff148f2578083 From 350e494930017df9216d62411fc9b5c02edd1fb3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 5 Oct 2021 12:23:59 +0200 Subject: [PATCH 041/465] update tmtc --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 706f79a1..3b2caa73 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 706f79a1f2cc7c909fe995e8473ff148f2578083 +Subproject commit 3b2caa7326042b18ee921fdd96003acefb547b50 From 448ca372a97240dd65802ac0b057cca9514babbc Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 5 Oct 2021 13:49:10 +0200 Subject: [PATCH 042/465] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 94bd4c7b..db801a0e 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 94bd4c7b56f9f22cdec118df8e681ed30a2f47b3 +Subproject commit db801a0ecc7323f3bc552be0de383c6bb1b29fb7 From a2a6bf1b45f849f07c2c3c702f86ad63ec762f8e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 6 Oct 2021 18:02:05 +0200 Subject: [PATCH 043/465] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 3b2caa73..726935f7 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 3b2caa7326042b18ee921fdd96003acefb547b50 +Subproject commit 726935f77b6fdb8415932d545554f748b5ed1dbb From 1463bcae5242707d1de7777dfd5a2031a1f1e132 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 7 Oct 2021 10:14:35 +0200 Subject: [PATCH 044/465] update fsfw and tmtc --- fsfw | 2 +- tmtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsfw b/fsfw index a84c770d..2844c512 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit a84c770dfb8447325c263da42d5cecd99b38d1f0 +Subproject commit 2844c512b69a2a0089ee4b0f4fd57a75a42a3cb3 diff --git a/tmtc b/tmtc index bad6a42a..1a176582 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit bad6a42af715f62ddc2a593a5f1ce344fde96da7 +Subproject commit 1a176582883aed989870819e5e57e0ce0a78ecda From 18f7d3e3c96686d4581acfd384883031d4c7321a Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 7 Oct 2021 17:23:41 +0200 Subject: [PATCH 045/465] tm now sent over PTME --- common/config/commonConfig.h.in | 2 +- linux/fsfwconfig/OBSWConfig.h.in | 2 +- scripts/q7s-port.sh | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/common/config/commonConfig.h.in b/common/config/commonConfig.h.in index c089c575..88e25877 100644 --- a/common/config/commonConfig.h.in +++ b/common/config/commonConfig.h.in @@ -10,7 +10,7 @@ // CCSDS IP Cores. #define OBSW_USE_CCSDS_IP_CORE 1 // Set to 1 if all telemetry should be sent to the PTME IP Core -#define OBSW_TM_TO_PTME 0 +#define OBSW_TM_TO_PTME 1 // Set to 1 if telecommands are received via the PDEC IP Core #define OBSW_TC_FROM_PDEC 0 diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index a714e850..924026af 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -86,7 +86,7 @@ debugging. */ #define OBSW_TEST_TE7020_HEATER 0 #define OBSW_TEST_GPIO_OPEN_BY_LABEL 0 #define OBSW_TEST_GPIO_OPEN_BY_LINE_NAME 0 -#define OBSW_LINK_IS_UP 0 +#define OBSW_LINK_IS_UP 1 #define OBSW_DEBUG_P60DOCK 0 #define OBSW_DEBUG_PDU1 0 diff --git a/scripts/q7s-port.sh b/scripts/q7s-port.sh index e475e8b7..a4d2e718 100755 --- a/scripts/q7s-port.sh +++ b/scripts/q7s-port.sh @@ -7,5 +7,6 @@ echo "-L 1536:192.168.133.10:7301 for TMTC commanding" ssh -L 1534:192.168.133.10:1534 \ -L 1535:192.168.133.10:22 \ -L 1536:192.168.133.10:7301 \ + -L 1537:192.168.133.10:7100 \ eive@2001:7c0:2018:1099:babe:0:e1fe:f1a5 \ -t 'CONSOLE_PREFIX="[Q7S Tunnel]" /bin/bash' From 5da2a458817ca88ed30221691964cbdfa437d694 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Fri, 8 Oct 2021 14:15:33 +0200 Subject: [PATCH 046/465] gpios to enable rs485 tx clock and tx data --- bsp_q7s/boardconfig/busConf.h | 2 ++ bsp_q7s/core/ObjectFactory.cpp | 10 ++++++++++ fsfw | 2 +- linux/fsfwconfig/devices/gpioIds.h | 6 +++++- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index 4b64e775..8905a125 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -60,6 +60,8 @@ namespace gpioNames { static constexpr char PAPB_EMPTY_SIGNAL_VC2[] = "papb_empty_signal_vc2"; static constexpr char PAPB_BUSY_SIGNAL_VC3[] = "papb_busy_signal_vc3"; static constexpr char PAPB_EMPTY_SIGNAL_VC3[] = "papb_empty_signal_vc3"; + static constexpr char RS485_EN_TX_CLOCK[] = "tx_clock_enable_ltc2872"; + static constexpr char RS485_EN_TX_DATA[] = "tx_data_enable_ltc2872"; } } diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index e36bf12c..47b26a2a 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -943,6 +943,16 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF *gpioComIF) { ccsdsHandler->addVirtualChannel(ccsds::VC2, vc); vc = new VirtualChannel(ccsds::VC3, config::VC3_QUEUE_SIZE); ccsdsHandler->addVirtualChannel(ccsds::VC3, vc); + + GpioCookie* gpioRS485Chip = new GpioCookie; + gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_TX_CLOCK, "RS485 Transceiver", + gpio::Direction::OUT, gpio::HIGH); + gpioRS485Chip->addGpio(gpioIds::RS485_EN_TX_CLOCK, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_TX_DATA, "RS485 Transceiver", + gpio::Direction::OUT, gpio::HIGH); + gpioRS485Chip->addGpio(gpioIds::RS485_EN_TX_DATA, gpio); + + gpioComIF->addGpios(gpioRS485Chip); } void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) { diff --git a/fsfw b/fsfw index 2844c512..a578f039 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 2844c512b69a2a0089ee4b0f4fd57a75a42a3cb3 +Subproject commit a578f0390bce6c0a3d1d1e8d59764072f1075867 diff --git a/linux/fsfwconfig/devices/gpioIds.h b/linux/fsfwconfig/devices/gpioIds.h index 2016245d..5f09e5f6 100644 --- a/linux/fsfwconfig/devices/gpioIds.h +++ b/linux/fsfwconfig/devices/gpioIds.h @@ -98,7 +98,11 @@ enum gpioId_t { VC2_PAPB_EMPTY, VC2_PAPB_BUSY, VC3_PAPB_EMPTY, - VC3_PAPB_BUSY + VC3_PAPB_BUSY, + + + RS485_EN_TX_DATA, + RS485_EN_TX_CLOCK }; } From 2b609a413df7bb37c3bff90e424c07227dd5de82 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Fri, 8 Oct 2021 14:39:53 +0200 Subject: [PATCH 047/465] readme update --- README.md | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b6a18947..f117535d 100644 --- a/README.md +++ b/README.md @@ -11,13 +11,14 @@ 4. [Useful and Common Host Commands](#host-commands) 5. [Setting up Prerequisites](#set-up-prereq) 6. [Remote Debugging](#remote-debugging) -7. [Direct Debugging](#direct-debugging) -8. [Transfering Files to the Q7S](#file-transfer) -9. [Q7S OBC](#q7s) -10. [Static Code Analysis](#static-code-analysis) -11. [Eclipse](#eclipse) -12. [Running the OBSW on a Raspberry Pi](#rpi) -13. [FSFW](#fsfw) +7. [TMTC testing](#tmtc-testing) +8. [Direct Debugging](#direct-debugging) +9. [Transfering Files to the Q7S](#file-transfer) +10. [Q7S OBC](#q7s) +11. [Static Code Analysis](#static-code-analysis) +12. [Eclipse](#eclipse) +13. [Running the OBSW on a Raspberry Pi](#rpi) +14. [FSFW](#fsfw) # General information @@ -574,6 +575,13 @@ alias or shell script to do this quickly. Note: When now setting up a debug session in the Xilinx SDK or Eclipse, the host must be set to localhost instead of the IP address of the Q7S. +# TMTC testing +The OBSW supports sending PUS TM packets via TCP or the PDEC IP Core which transmits the data as CADU frames. To make the CADU frames receivabel by the [TMTC porgram](https://egit.irs.uni-stuttgart.de/eive/eive-tmtc), a python script is running as systemd service on the flatsat PC which forwards TCP commands to the TCP server of the OBC and reads CADU frames from a serial interface. The PUS packets transported with the CADU frames are extracted and forwared to the TMTC program's TCP client. The code of the TMTC bridge can be found [here](https://egit.irs.uni-stuttgart.de/eive/tmtc-bridge). To connect the TMTC program to the TMTC-bridge a port forwarding from a host must be set up with the following command: +```` +ssh -L 1537:127.0.0.1:7100 eive@2001:7c0:2018:1099:babe:0:e1fe:f1a5 -t bash +```` +Note: The encoding of the TM packets and conversion of CADU frames takes some time. Thus the replies are received with a larger delay compared to a direct TCP connection. + # Direct Debugging 1. Assign static IP address to Q7S From 1f981e7a603735464413f3da8ac99e0a9bde95c7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 11 Oct 2021 10:25:40 +0200 Subject: [PATCH 048/465] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 726935f7..7b49babb 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 726935f77b6fdb8415932d545554f748b5ed1dbb +Subproject commit 7b49babb1febb3959f0f817aa4b4ce4c32d6d21c From 271d133053e3af808d4f611c18395a15d5c6a136 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 11 Oct 2021 10:47:52 +0200 Subject: [PATCH 049/465] updated comment --- scripts/q7s-port.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/q7s-port.sh b/scripts/q7s-port.sh index 82152898..e350d4c2 100755 --- a/scripts/q7s-port.sh +++ b/scripts/q7s-port.sh @@ -2,7 +2,8 @@ echo "Setting up all Q7S ports" echo "-L 1534:192.168.133.10:1534 for connection to TCF agent" echo "-L 1535:192.168.133.10:22 for file transfers" -echo "-L 1536:192.168.133.10:7301 for TMTC commanding" +echo "-L 1536:192.168.133.10:7301 for TMTC commanding using the TCP/IP IF" +echo "-L 1537:127.0.0.1:7100 for TMTC commanding using the CCSDS IF" ssh -L 1534:192.168.133.10:1534 \ -L 1535:192.168.133.10:22 \ From 10f2a7a7b7725e1ef1c841094fa7282aba3e858d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 11 Oct 2021 11:06:12 +0200 Subject: [PATCH 050/465] more information about systemd service --- README.md | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f117535d..fa652ad4 100644 --- a/README.md +++ b/README.md @@ -576,11 +576,30 @@ Note: When now setting up a debug session in the Xilinx SDK or Eclipse, the host to localhost instead of the IP address of the Q7S. # TMTC testing -The OBSW supports sending PUS TM packets via TCP or the PDEC IP Core which transmits the data as CADU frames. To make the CADU frames receivabel by the [TMTC porgram](https://egit.irs.uni-stuttgart.de/eive/eive-tmtc), a python script is running as systemd service on the flatsat PC which forwards TCP commands to the TCP server of the OBC and reads CADU frames from a serial interface. The PUS packets transported with the CADU frames are extracted and forwared to the TMTC program's TCP client. The code of the TMTC bridge can be found [here](https://egit.irs.uni-stuttgart.de/eive/tmtc-bridge). To connect the TMTC program to the TMTC-bridge a port forwarding from a host must be set up with the following command: -```` +The OBSW supports sending PUS TM packets via TCP or the PDEC IP Core which transmits the data as +CADU frames. To make the CADU frames receivabel by the +[TMTC porgram](https://egit.irs.uni-stuttgart.de/eive/eive-tmtc), a python script is running as +`systemd` service named `tmtc_bridge` on the flatsat PC which forwards TCP commands to the TCP +server of the OBC and reads CADU frames from a serial interface. The PUS packets transported with +the CADU frames are extracted +and forwared to the TMTC program's TCP client. The code of the TMTC bridge can be found +[here](https://egit.irs.uni-stuttgart.de/eive/tmtc-bridge). To connect the TMTC program to the +TMTC-bridge a port forwarding from a host must be set up with the following command: + +```sh ssh -L 1537:127.0.0.1:7100 eive@2001:7c0:2018:1099:babe:0:e1fe:f1a5 -t bash -```` -Note: The encoding of the TM packets and conversion of CADU frames takes some time. Thus the replies are received with a larger delay compared to a direct TCP connection. +``` + +You can print the output of the `systemd` with + +```sh +journalctl -u tmtc_bridge +``` + +This can be helpful to determine whether any TCs arrive or TMs are coming back. + +Note: The encoding of the TM packets and conversion of CADU frames takes some time. +Thus the replies are received with a larger delay compared to a direct TCP connection. # Direct Debugging From 7d6022ab0948eb635c920ec189ea4ae09eb70948 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 11 Oct 2021 11:09:53 +0200 Subject: [PATCH 051/465] another helpful command added --- README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fa652ad4..f345f654 100644 --- a/README.md +++ b/README.md @@ -580,8 +580,15 @@ The OBSW supports sending PUS TM packets via TCP or the PDEC IP Core which trans CADU frames. To make the CADU frames receivabel by the [TMTC porgram](https://egit.irs.uni-stuttgart.de/eive/eive-tmtc), a python script is running as `systemd` service named `tmtc_bridge` on the flatsat PC which forwards TCP commands to the TCP -server of the OBC and reads CADU frames from a serial interface. The PUS packets transported with -the CADU frames are extracted +server of the OBC and reads CADU frames from a serial interface. + +You can check whether the service is running with + +```sh +systemctl status tmtc_bridge +``` + +The PUS packets transported with the CADU frames are extracted and forwared to the TMTC program's TCP client. The code of the TMTC bridge can be found [here](https://egit.irs.uni-stuttgart.de/eive/tmtc-bridge). To connect the TMTC program to the TMTC-bridge a port forwarding from a host must be set up with the following command: From f3f96e02a2512af4ae3c772835fee65477a4c7ed Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 11 Oct 2021 11:10:30 +0200 Subject: [PATCH 052/465] another minor update --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f345f654..7287d921 100644 --- a/README.md +++ b/README.md @@ -576,13 +576,14 @@ Note: When now setting up a debug session in the Xilinx SDK or Eclipse, the host to localhost instead of the IP address of the Q7S. # TMTC testing + The OBSW supports sending PUS TM packets via TCP or the PDEC IP Core which transmits the data as CADU frames. To make the CADU frames receivabel by the [TMTC porgram](https://egit.irs.uni-stuttgart.de/eive/eive-tmtc), a python script is running as `systemd` service named `tmtc_bridge` on the flatsat PC which forwards TCP commands to the TCP server of the OBC and reads CADU frames from a serial interface. -You can check whether the service is running with +You can check whether the service is running the following command on the flatsat PC ```sh systemctl status tmtc_bridge From 2e0606ff0ca5497ae57a07daaef7330803d5687c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 11 Oct 2021 11:13:02 +0200 Subject: [PATCH 053/465] README update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7287d921..ff2c359d 100644 --- a/README.md +++ b/README.md @@ -598,7 +598,7 @@ TMTC-bridge a port forwarding from a host must be set up with the following comm ssh -L 1537:127.0.0.1:7100 eive@2001:7c0:2018:1099:babe:0:e1fe:f1a5 -t bash ``` -You can print the output of the `systemd` with +You can print the output of the `systemd` service with ```sh journalctl -u tmtc_bridge From c85a7d6b9c86ec950ce49085106769378b9637fd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 11 Oct 2021 17:08:24 +0200 Subject: [PATCH 054/465] fsfw and tmtc update --- fsfw | 2 +- tmtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsfw b/fsfw index db801a0e..b985bf51 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit db801a0ecc7323f3bc552be0de383c6bb1b29fb7 +Subproject commit b985bf5167be74c0d43bd70c501eb5f9640bd99e diff --git a/tmtc b/tmtc index 726935f7..56717935 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 726935f77b6fdb8415932d545554f748b5ed1dbb +Subproject commit 56717935e6d90e8a501894f44cd250aec8d12d03 From 8d10dcbe1887de513cbdcf0895b1ca85c59d7beb Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 11 Oct 2021 17:09:04 +0200 Subject: [PATCH 055/465] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 7b49babb..4325b8cc 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 7b49babb1febb3959f0f817aa4b4ce4c32d6d21c +Subproject commit 4325b8ccaa0495eb8b23f4b6aeec3165c62e7bd1 From 221012f79005d17136d484ef5193f4c09d89f307 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 11 Oct 2021 19:34:34 +0200 Subject: [PATCH 056/465] hosted build compiling again --- bsp_hosted/fsfwconfig/OBSWConfig.h.in | 6 ++++++ bsp_hosted/fsfwconfig/fsfwconfig.mk | 7 ------- bsp_q7s/core/ObjectFactory.cpp | 8 ++++---- common/config/commonConfig.h.in | 14 +++++++++----- fsfw | 2 +- linux/fsfwconfig/OBSWConfig.h.in | 12 ++++++------ linux/obc/Ptme.cpp | 5 ++--- linux/obc/Ptme.h | 2 +- mission/tmtc/CCSDSHandler.cpp | 4 ++-- mission/tmtc/CCSDSHandler.h | 2 +- 10 files changed, 32 insertions(+), 30 deletions(-) delete mode 100644 bsp_hosted/fsfwconfig/fsfwconfig.mk diff --git a/bsp_hosted/fsfwconfig/OBSWConfig.h.in b/bsp_hosted/fsfwconfig/OBSWConfig.h.in index 5996e3a2..a2353947 100644 --- a/bsp_hosted/fsfwconfig/OBSWConfig.h.in +++ b/bsp_hosted/fsfwconfig/OBSWConfig.h.in @@ -14,6 +14,12 @@ debugging. */ #define OBSW_VEBOSE_LEVEL 1 +#define OBSW_USE_CCSDS_IP_CORE 0 +// Set to 1 if all telemetry should be sent to the PTME IP Core +#define OBSW_TM_TO_PTME 0 +// Set to 1 if telecommands are received via the PDEC IP Core +#define OBSW_TC_FROM_PDEC 0 + #ifdef __cplusplus #include "objects/systemObjectList.h" diff --git a/bsp_hosted/fsfwconfig/fsfwconfig.mk b/bsp_hosted/fsfwconfig/fsfwconfig.mk deleted file mode 100644 index 53cb0fc7..00000000 --- a/bsp_hosted/fsfwconfig/fsfwconfig.mk +++ /dev/null @@ -1,7 +0,0 @@ -CXXSRC += $(wildcard $(CURRENTPATH)/cdatapool/*.cpp) -CXXSRC += $(wildcard $(CURRENTPATH)/ipc/*.cpp) -CXXSRC += $(wildcard $(CURRENTPATH)/objects/*.cpp) -CXXSRC += $(wildcard $(CURRENTPATH)/pollingsequence/*.cpp) -CXXSRC += $(wildcard $(CURRENTPATH)/events/*.cpp) - -INCLUDES += $(CURRENTPATH) \ No newline at end of file diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 47b26a2a..16e3da95 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -935,13 +935,13 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF *gpioComIF) { CCSDSHandler* ccsdsHandler = new CCSDSHandler(objects::CCSDS_HANDLER, objects::PTME); VirtualChannel* vc = nullptr; - vc = new VirtualChannel(ccsds::VC0, config::VC0_QUEUE_SIZE); + vc = new VirtualChannel(ccsds::VC0, common::VC0_QUEUE_SIZE); ccsdsHandler->addVirtualChannel(ccsds::VC0, vc); - vc = new VirtualChannel(ccsds::VC1, config::VC1_QUEUE_SIZE); + vc = new VirtualChannel(ccsds::VC1, common::VC1_QUEUE_SIZE); ccsdsHandler->addVirtualChannel(ccsds::VC1, vc); - vc = new VirtualChannel(ccsds::VC2, config::VC2_QUEUE_SIZE); + vc = new VirtualChannel(ccsds::VC2, common::VC2_QUEUE_SIZE); ccsdsHandler->addVirtualChannel(ccsds::VC2, vc); - vc = new VirtualChannel(ccsds::VC3, config::VC3_QUEUE_SIZE); + vc = new VirtualChannel(ccsds::VC3, common::VC3_QUEUE_SIZE); ccsdsHandler->addVirtualChannel(ccsds::VC3, vc); GpioCookie* gpioRS485Chip = new GpioCookie; diff --git a/common/config/commonConfig.h.in b/common/config/commonConfig.h.in index c8607fae..6dad37d5 100644 --- a/common/config/commonConfig.h.in +++ b/common/config/commonConfig.h.in @@ -7,19 +7,23 @@ // Disable this for mission code. It allows exchanging TMTC packets via the Ethernet port #define OBSW_ADD_TCPIP_BRIDGE 1 + // Use TCP instead of UDP for the TMTC bridge. This allows using the TMTC client locally // because UDP packets are not allowed in the VPN // This will cause the OBSW to initialize the TMTC bridge responsible for exchanging data with the // CCSDS IP Cores. -#define OBSW_USE_CCSDS_IP_CORE 1 -// Set to 1 if all telemetry should be sent to the PTME IP Core -#define OBSW_TM_TO_PTME 1 -// Set to 1 if telecommands are received via the PDEC IP Core -#define OBSW_TC_FROM_PDEC 0 #define OBSW_USE_TCP_BRIDGE 1 namespace common { extern const uint16_t TC_PACKET_ID; + +static constexpr uint32_t CCSDS_HANDLER_QUEUE_SIZE = 50; +static constexpr uint8_t NUMBER_OF_VIRTUAL_CHANNELS = 4; +static constexpr uint8_t VC0_QUEUE_SIZE = 50; +static constexpr uint8_t VC1_QUEUE_SIZE = 50; +static constexpr uint8_t VC2_QUEUE_SIZE = 50; +static constexpr uint8_t VC3_QUEUE_SIZE = 50; + } #endif /* COMMON_CONFIG_COMMONCONFIG_H_ */ diff --git a/fsfw b/fsfw index b985bf51..ad68802f 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit b985bf5167be74c0d43bd70c501eb5f9640bd99e +Subproject commit ad68802fe4af9af554bd8221c607ba1f4d87185b diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index 924026af..6ccd6b6d 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -33,6 +33,12 @@ debugging. */ //! All of this should be enabled for mission code! #if defined XIPHOS_Q7S +#define OBSW_USE_CCSDS_IP_CORE 1 +// Set to 1 if all telemetry should be sent to the PTME IP Core +#define OBSW_TM_TO_PTME 1 +// Set to 1 if telecommands are received via the PDEC IP Core +#define OBSW_TC_FROM_PDEC 0 + #define OBSW_ENABLE_TIMERS 1 #define OBSW_ADD_STAR_TRACKER 0 #define OBSW_ADD_PLOC_SUPERVISOR 0 @@ -124,12 +130,6 @@ namespace config { /* Add mission configuration flags here */ static constexpr uint32_t OBSW_FILESYSTEM_HANDLER_QUEUE_SIZE = 50; static constexpr uint32_t PLOC_UPDATER_QUEUE_SIZE = 50; -static constexpr uint32_t CCSDS_HANDLER_QUEUE_SIZE = 50; -static constexpr uint8_t NUMBER_OF_VIRTUAL_CHANNELS = 4; -static constexpr uint8_t VC0_QUEUE_SIZE = 50; -static constexpr uint8_t VC1_QUEUE_SIZE = 50; -static constexpr uint8_t VC2_QUEUE_SIZE = 50; -static constexpr uint8_t VC3_QUEUE_SIZE = 50; static constexpr uint8_t LIVE_TM = 0; diff --git a/linux/obc/Ptme.cpp b/linux/obc/Ptme.cpp index 80f9945c..63af5d33 100644 --- a/linux/obc/Ptme.cpp +++ b/linux/obc/Ptme.cpp @@ -5,8 +5,7 @@ #include "fsfw/serviceinterface/ServiceInterface.h" #include "PtmeConfig.h" -Ptme::Ptme(object_id_t objectId) : - SystemObject(objectId) { +Ptme::Ptme(object_id_t objectId): SystemObject(objectId) { } Ptme::~Ptme() { @@ -54,7 +53,7 @@ ReturnValue_t Ptme::writeToVc(uint8_t vcId, const uint8_t * data, size_t size) { void Ptme::addVcInterface(VcId_t vcId, VcInterfaceIF* vc) { - if (vcId > config::NUMBER_OF_VIRTUAL_CHANNELS) { + if (vcId > common::NUMBER_OF_VIRTUAL_CHANNELS) { sif::warning << "Ptme::addVcInterface: Invalid virtual channel ID" << std::endl; return; } diff --git a/linux/obc/Ptme.h b/linux/obc/Ptme.h index be687e17..5364974f 100644 --- a/linux/obc/Ptme.h +++ b/linux/obc/Ptme.h @@ -78,7 +78,7 @@ private: static const int PTME_DATA_REG_OFFSET = 256; /** The file descriptor of the UIO driver */ - int fd; + int fd = 0; uint32_t* ptmeBaseAddress = nullptr; diff --git a/mission/tmtc/CCSDSHandler.cpp b/mission/tmtc/CCSDSHandler.cpp index 95d557ee..9b2912c1 100644 --- a/mission/tmtc/CCSDSHandler.cpp +++ b/mission/tmtc/CCSDSHandler.cpp @@ -78,7 +78,7 @@ MessageQueueId_t CCSDSHandler::getCommandQueue() const { } void CCSDSHandler::addVirtualChannel(VcId_t vcId, VirtualChannel* virtualChannel) { - if (vcId > config::NUMBER_OF_VIRTUAL_CHANNELS) { + if (vcId > common::NUMBER_OF_VIRTUAL_CHANNELS) { sif::warning << "CCSDSHandler::addVirtualChannel: Invalid virtual channel ID" << std::endl; return; } @@ -97,7 +97,7 @@ void CCSDSHandler::addVirtualChannel(VcId_t vcId, VirtualChannel* virtualChannel } MessageQueueId_t CCSDSHandler::getReportReceptionQueue(uint8_t virtualChannel) { - if (virtualChannel < config::NUMBER_OF_VIRTUAL_CHANNELS) { + if (virtualChannel < common::NUMBER_OF_VIRTUAL_CHANNELS) { VirtualChannelMapIter iter = virtualChannelMap.find(virtualChannel); if (iter != virtualChannelMap.end()) { return iter->second->getReportReceptionQueue(); diff --git a/mission/tmtc/CCSDSHandler.h b/mission/tmtc/CCSDSHandler.h index 05693a38..b53cb8cd 100644 --- a/mission/tmtc/CCSDSHandler.h +++ b/mission/tmtc/CCSDSHandler.h @@ -53,7 +53,7 @@ public: private: - static const uint32_t QUEUE_SIZE = config::CCSDS_HANDLER_QUEUE_SIZE; + static const uint32_t QUEUE_SIZE = common::CCSDS_HANDLER_QUEUE_SIZE; using VirtualChannelMap = std::unordered_map; using VirtualChannelMapIter = VirtualChannelMap::iterator; From 1bef032260bfbdb658079b454090c85edbf3ce1d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 11 Oct 2021 19:43:44 +0200 Subject: [PATCH 057/465] unittests were refactored --- .gitmodules | 3 - CMakeLists.txt | 12 +-- fsfw | 2 +- thirdparty/Catch2 | 1 - unittest/main.cpp | 2 +- unittest/testcfg/CMakeLists.txt | 9 --- unittest/testcfg/FSFWConfig.h.in | 81 ------------------- unittest/testcfg/OBSWConfig.h.in | 8 -- unittest/testcfg/TestsConfig.h.in | 21 ----- unittest/testcfg/devices/logicalAddresses.cpp | 5 -- unittest/testcfg/devices/logicalAddresses.h | 15 ---- .../testcfg/devices/powerSwitcherList.cpp | 4 - unittest/testcfg/devices/powerSwitcherList.h | 12 --- unittest/testcfg/events/subsystemIdRanges.h | 19 ----- unittest/testcfg/ipc/MissionMessageTypes.cpp | 12 --- unittest/testcfg/ipc/MissionMessageTypes.h | 22 ----- unittest/testcfg/objects/systemObjectList.h | 33 -------- .../PollingSequenceFactory.cpp | 39 --------- .../pollingsequence/PollingSequenceFactory.h | 32 -------- unittest/testcfg/returnvalues/classIds.h | 17 ---- unittest/testcfg/tmtc/apid.h | 18 ----- unittest/testcfg/tmtc/pusIds.h | 25 ------ 22 files changed, 5 insertions(+), 387 deletions(-) delete mode 160000 thirdparty/Catch2 delete mode 100644 unittest/testcfg/CMakeLists.txt delete mode 100644 unittest/testcfg/FSFWConfig.h.in delete mode 100644 unittest/testcfg/OBSWConfig.h.in delete mode 100644 unittest/testcfg/TestsConfig.h.in delete mode 100644 unittest/testcfg/devices/logicalAddresses.cpp delete mode 100644 unittest/testcfg/devices/logicalAddresses.h delete mode 100644 unittest/testcfg/devices/powerSwitcherList.cpp delete mode 100644 unittest/testcfg/devices/powerSwitcherList.h delete mode 100644 unittest/testcfg/events/subsystemIdRanges.h delete mode 100644 unittest/testcfg/ipc/MissionMessageTypes.cpp delete mode 100644 unittest/testcfg/ipc/MissionMessageTypes.h delete mode 100644 unittest/testcfg/objects/systemObjectList.h delete mode 100644 unittest/testcfg/pollingsequence/PollingSequenceFactory.cpp delete mode 100644 unittest/testcfg/pollingsequence/PollingSequenceFactory.h delete mode 100644 unittest/testcfg/returnvalues/classIds.h delete mode 100644 unittest/testcfg/tmtc/apid.h delete mode 100644 unittest/testcfg/tmtc/pusIds.h diff --git a/.gitmodules b/.gitmodules index 1ca8bec5..1f3dc6ec 100644 --- a/.gitmodules +++ b/.gitmodules @@ -22,6 +22,3 @@ [submodule "thirdparty/json"] path = thirdparty/json url = https://github.com/nlohmann/json.git -[submodule "thirdparty/Catch2"] - path = thirdparty/Catch2 - url = https://github.com/catchorg/Catch2.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 656ee3ee..fb944393 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,15 +90,10 @@ set(FSFW_WARNING_SHADOW_LOCAL_GCC OFF) set(EIVE_ADD_LINUX_FILES False) if(EIVE_BUILD_UNITTESTS) - option(FSFW_ADD_UNITTESTS "Build the FSFW unittests as well" ON) - # Use FSFW custom main for unittests - set(FSFW_CUSTOM_UNITTEST_RUNNER ON) endif() -if(FSFW_CUSTOM_UNITTEST_RUNNER OR FSFW_ADD_UNITTESTS) +if(FSFW_ADD_UNITTESTS) set(CATCH2_TARGET Catch2) -else() - set(CATCH2_TARGET Catch2WithMain) endif() # Analyse different OS and architecture/target options, determine BSP_PATH, @@ -139,8 +134,8 @@ else() endif() if(EIVE_BUILD_UNITTESTS) - configure_file(${UNITTEST_CFG_PATH}/TestsConfig.h.in TestsConfig.h) - set(FSFW_CONFIG_PATH ${UNITTEST_CFG_PATH}) + # configure_file(${UNITTEST_CFG_PATH}/TestsConfig.h.in TestsConfig.h) + # set(FSFW_CONFIG_PATH ${UNITTEST_CFG_PATH}) endif() # Configuration files @@ -156,7 +151,6 @@ if(NOT EIVE_BUILD_WATCHDOG) endif() - configure_file(${WATCHDOG_PATH}/watchdogConf.h.in watchdogConf.h) # Set common config path for FSFW diff --git a/fsfw b/fsfw index ad68802f..4130dd9e 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit ad68802fe4af9af554bd8221c607ba1f4d87185b +Subproject commit 4130dd9e32eb1d4a5b0e993408ae614952bdd005 diff --git a/thirdparty/Catch2 b/thirdparty/Catch2 deleted file mode 160000 index 42695403..00000000 --- a/thirdparty/Catch2 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 426954032f263754d2fff4cffce8552e7371965e diff --git a/unittest/main.cpp b/unittest/main.cpp index cd4f4b77..811df98e 100644 --- a/unittest/main.cpp +++ b/unittest/main.cpp @@ -2,6 +2,6 @@ #include "fsfw_tests/unit/CatchRunner.h" int main(int argc, char* argv[]) { - fsfwtest::customMain(argc, argv); + // fsfwtest::customMain(argc, argv); } diff --git a/unittest/testcfg/CMakeLists.txt b/unittest/testcfg/CMakeLists.txt deleted file mode 100644 index 50d13663..00000000 --- a/unittest/testcfg/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -target_sources(${TARGET_NAME} PRIVATE - ipc/MissionMessageTypes.cpp - pollingsequence/PollingSequenceFactory.cpp -) - -# Add include paths for the executable -target_include_directories(${TARGET_NAME} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} -) diff --git a/unittest/testcfg/FSFWConfig.h.in b/unittest/testcfg/FSFWConfig.h.in deleted file mode 100644 index d2ed901d..00000000 --- a/unittest/testcfg/FSFWConfig.h.in +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef CONFIG_FSFWCONFIG_H_ -#define CONFIG_FSFWCONFIG_H_ - -#include -#include - -//! Used to determine whether C++ ostreams are used which can increase -//! the binary size significantly. If this is disabled, -//! the C stdio functions can be used alternatively -#define FSFW_CPP_OSTREAM_ENABLED 1 - -//! More FSFW related printouts. Useful for development. -#define FSFW_ENHANCED_PRINTOUT 0 - -//! Can be used to completely disable printouts, even the C stdio ones. -//! By default, printouts will be disabled for the unit tests. -#if FSFW_CPP_OSTREAM_ENABLED == 0 && FSFW_ENHANCED_PRINTOUT == 0 - #ifndef FSFW_DISABLE_PRINTOUT - #define FSFW_DISABLE_PRINTOUT 1 - #endif -#endif - -#define FSFW_USE_PUS_C_TELEMETRY 1 -#define FSFW_USE_PUS_C_TELECOMMANDS 1 - -//! Can be used to enable additional debugging printouts for developing the FSFW -#define FSFW_PRINT_VERBOSITY_LEVEL 0 - -//! Can be used to disable the ANSI color sequences for C stdio. -#define FSFW_COLORED_OUTPUT 0 - -//! If FSFW_OBJ_EVENT_TRANSLATION is set to one, -//! additional output which requires the translation files translateObjects -//! and translateEvents (and their compiled source files) -#define FSFW_OBJ_EVENT_TRANSLATION 0 - -#if FSFW_OBJ_EVENT_TRANSLATION == 1 -//! Specify whether info events are printed too. -#define FSFW_DEBUG_INFO 1 -#include "objects/translateObjects.h" -#include "events/translateEvents.h" -#else -#endif - -//! When using the newlib nano library, C99 support for stdio facilities -//! will not be provided. This define should be set to 1 if this is the case. -#define FSFW_NO_C99_IO 1 - -//! Specify whether a special mode store is used for Subsystem components. -#define FSFW_USE_MODESTORE 0 - -//! Defines if the real time scheduler for linux should be used. -//! If set to 0, this will also disable priority settings for linux -//! as most systems will not allow to set nice values without privileges -//! For embedded linux system set this to 1. -//! If set to 1 the binary needs "cap_sys_nice=eip" privileges to run -#define FSFW_USE_REALTIME_FOR_LINUX 1 - -namespace fsfwconfig { -//! Default timestamp size. The default timestamp will be an eight byte CDC -//! short timestamp. -static constexpr uint8_t FSFW_MISSION_TIMESTAMP_SIZE = 8; - -//! Configure the allocated pool sizes for the event manager. -static constexpr size_t FSFW_EVENTMGMR_MATCHTREE_NODES = 240; -static constexpr size_t FSFW_EVENTMGMT_EVENTIDMATCHERS = 120; -static constexpr size_t FSFW_EVENTMGMR_RANGEMATCHERS = 120; - -//! Defines the FIFO depth of each commanding service base which -//! also determines how many commands a CSB service can handle in one cycle -//! simulataneously. This will increase the required RAM for -//! each CSB service ! -static constexpr uint8_t FSFW_CSB_FIFO_DEPTH = 6; - -static constexpr size_t FSFW_PRINT_BUFFER_SIZE = 124; - -static constexpr size_t FSFW_MAX_TM_PACKET_SIZE = 1500; - -} - -#endif /* CONFIG_FSFWCONFIG_H_ */ diff --git a/unittest/testcfg/OBSWConfig.h.in b/unittest/testcfg/OBSWConfig.h.in deleted file mode 100644 index 34eda31f..00000000 --- a/unittest/testcfg/OBSWConfig.h.in +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef TESTCFG_OBSWCONFIG_H_ -#define TESTCFG_OBSWCONFIG_H_ - - - - - -#endif /* TESTCFG_OBSWCONFIG_H_ */ diff --git a/unittest/testcfg/TestsConfig.h.in b/unittest/testcfg/TestsConfig.h.in deleted file mode 100644 index 7d950070..00000000 --- a/unittest/testcfg/TestsConfig.h.in +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef FSFW_UNITTEST_CONFIG_TESTSCONFIG_H_ -#define FSFW_UNITTEST_CONFIG_TESTSCONFIG_H_ - -#define FSFW_ADD_DEFAULT_FACTORY_FUNCTIONS 1 - -#ifdef __cplusplus - -#include "objects/systemObjectList.h" -#include "events/subsystemIdRanges.h" -#include "returnvalues/classIds.h" - -namespace config { -#endif - -/* Add mission configuration flags here */ - -#ifdef __cplusplus -} -#endif - -#endif /* FSFW_UNITTEST_CONFIG_TESTSCONFIG_H_ */ diff --git a/unittest/testcfg/devices/logicalAddresses.cpp b/unittest/testcfg/devices/logicalAddresses.cpp deleted file mode 100644 index c7ce314d..00000000 --- a/unittest/testcfg/devices/logicalAddresses.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "logicalAddresses.h" - - - - diff --git a/unittest/testcfg/devices/logicalAddresses.h b/unittest/testcfg/devices/logicalAddresses.h deleted file mode 100644 index cdf87025..00000000 --- a/unittest/testcfg/devices/logicalAddresses.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef CONFIG_DEVICES_LOGICALADDRESSES_H_ -#define CONFIG_DEVICES_LOGICALADDRESSES_H_ - -#include -#include -#include - -namespace addresses { - /* Logical addresses have uint32_t datatype */ - enum logicalAddresses: address_t { - }; -} - - -#endif /* CONFIG_DEVICES_LOGICALADDRESSES_H_ */ diff --git a/unittest/testcfg/devices/powerSwitcherList.cpp b/unittest/testcfg/devices/powerSwitcherList.cpp deleted file mode 100644 index 343f78d0..00000000 --- a/unittest/testcfg/devices/powerSwitcherList.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include "powerSwitcherList.h" - - - diff --git a/unittest/testcfg/devices/powerSwitcherList.h b/unittest/testcfg/devices/powerSwitcherList.h deleted file mode 100644 index 86ddea57..00000000 --- a/unittest/testcfg/devices/powerSwitcherList.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef CONFIG_DEVICES_POWERSWITCHERLIST_H_ -#define CONFIG_DEVICES_POWERSWITCHERLIST_H_ - -namespace switches { - /* Switches are uint8_t datatype and go from 0 to 255 */ - enum switcherList { - }; - -} - - -#endif /* CONFIG_DEVICES_POWERSWITCHERLIST_H_ */ diff --git a/unittest/testcfg/events/subsystemIdRanges.h b/unittest/testcfg/events/subsystemIdRanges.h deleted file mode 100644 index 26af041e..00000000 --- a/unittest/testcfg/events/subsystemIdRanges.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ -#define CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ - -#include -#include "commonSubsystemIds.h" -#include - -/** - * @brief Custom subsystem IDs can be added here - * @details - * Subsystem IDs are used to create unique events. - */ -namespace SUBSYSTEM_ID { -enum: uint8_t { - SUBSYSTEM_ID_START = FW_SUBSYSTEM_ID_RANGE, -}; -} - -#endif /* CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ */ diff --git a/unittest/testcfg/ipc/MissionMessageTypes.cpp b/unittest/testcfg/ipc/MissionMessageTypes.cpp deleted file mode 100644 index d68cb58c..00000000 --- a/unittest/testcfg/ipc/MissionMessageTypes.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "MissionMessageTypes.h" - -#include - -void messagetypes::clearMissionMessage(CommandMessage* message) { - switch(message->getMessageType()) { - default: - break; - } -} - - diff --git a/unittest/testcfg/ipc/MissionMessageTypes.h b/unittest/testcfg/ipc/MissionMessageTypes.h deleted file mode 100644 index 832d8e58..00000000 --- a/unittest/testcfg/ipc/MissionMessageTypes.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef CONFIG_IPC_MISSIONMESSAGETYPES_H_ -#define CONFIG_IPC_MISSIONMESSAGETYPES_H_ - -#include - -class CommandMessage; - -/** - * Custom command messages are specified here. - * Most messages needed to use FSFW are already located in - * - * @param message Generic Command Message - */ -namespace messagetypes{ -enum MESSAGE_TYPE { - MISSION_MESSAGE_TYPE_START = FW_MESSAGES_COUNT, -}; - -void clearMissionMessage(CommandMessage* message); -} - -#endif /* CONFIG_IPC_MISSIONMESSAGETYPES_H_ */ diff --git a/unittest/testcfg/objects/systemObjectList.h b/unittest/testcfg/objects/systemObjectList.h deleted file mode 100644 index 9ed43873..00000000 --- a/unittest/testcfg/objects/systemObjectList.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ -#define HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ - -#include -#include "commonObjects.h" -#include - -// The objects will be instantiated in the ID order -namespace objects { - enum sourceObjects: uint32_t { - /* All addresses between start and end are reserved for the FSFW */ - FSFW_CONFIG_RESERVED_START = PUS_SERVICE_1_VERIFICATION, - FSFW_CONFIG_RESERVED_END = TM_STORE, - - CCSDS_DISTRIBUTOR = 10, - PUS_DISTRIBUTOR = 11, - TM_FUNNEL = 12, - - UDP_BRIDGE = 15, - UDP_POLLING_TASK = 16, - - TEST_ECHO_COM_IF = 20, - TEST_DEVICE = 21, - - HK_RECEIVER_MOCK = 22, - TEST_LOCAL_POOL_OWNER_BASE = 25, - - SHARED_SET_ID = 26 - - }; -} - -#endif /* BSP_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ */ diff --git a/unittest/testcfg/pollingsequence/PollingSequenceFactory.cpp b/unittest/testcfg/pollingsequence/PollingSequenceFactory.cpp deleted file mode 100644 index e3ee874a..00000000 --- a/unittest/testcfg/pollingsequence/PollingSequenceFactory.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "PollingSequenceFactory.h" - -#include - -#include -#include -#include - -ReturnValue_t pst::pollingSequenceInitDefault( - FixedTimeslotTaskIF *thisSequence) { - /* Length of a communication cycle */ - uint32_t length = thisSequence->getPeriodMs(); - - /* Add polling sequence table here */ - thisSequence->addSlot(objects::TEST_DEVICE, 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::TEST_DEVICE, 0.3, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::TEST_DEVICE, 0.45 * length, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::TEST_DEVICE, 0.6 * length, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::TEST_DEVICE, 0.8 * length, - DeviceHandlerIF::GET_READ); - - if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { - return HasReturnvaluesIF::RETURN_OK; - } - else { -#if FSFW_CPP_OSTREAM_ENABLED - sif::error << "pst::pollingSequenceInitDefault: Sequence invalid!" - << std::endl; -#else - sif::printError("pst::pollingSequenceInitDefault: Sequence invalid!"); -#endif - return HasReturnvaluesIF::RETURN_FAILED; - } -} - diff --git a/unittest/testcfg/pollingsequence/PollingSequenceFactory.h b/unittest/testcfg/pollingsequence/PollingSequenceFactory.h deleted file mode 100644 index c5d41b7d..00000000 --- a/unittest/testcfg/pollingsequence/PollingSequenceFactory.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef POLLINGSEQUENCEFACTORY_H_ -#define POLLINGSEQUENCEFACTORY_H_ - -#include - -class FixedTimeslotTaskIF; - -/** - * All device handlers are scheduled by adding them into Polling Sequence Tables (PST) - * to satisfy stricter timing requirements of device communication, - * A device handler has four different communication steps: - * 1. DeviceHandlerIF::SEND_WRITE -> Send write via interface - * 2. DeviceHandlerIF::GET_WRITE -> Get confirmation for write - * 3. DeviceHandlerIF::SEND_READ -> Send read request - * 4. DeviceHandlerIF::GET_READ -> Read from interface - * The PST specifies precisely when the respective ComIF functions are called - * during the communication cycle time. - * The task is created using the FixedTimeslotTaskIF, - * which utilises the underlying Operating System Abstraction Layer (OSAL) - * - * @param thisSequence FixedTimeslotTaskIF * object is passed inside the Factory class when creating the PST - * @return - */ -namespace pst { - -/* Default PST */ -ReturnValue_t pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence); - - -} - -#endif /* POLLINGSEQUENCEINIT_H_ */ diff --git a/unittest/testcfg/returnvalues/classIds.h b/unittest/testcfg/returnvalues/classIds.h deleted file mode 100644 index 7a292708..00000000 --- a/unittest/testcfg/returnvalues/classIds.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef CONFIG_RETURNVALUES_CLASSIDS_H_ -#define CONFIG_RETURNVALUES_CLASSIDS_H_ - -#include "commonClassIds.h" -#include - -/** - * @brief CLASS_ID defintions which are required for custom returnvalues. - */ -namespace CLASS_ID { -enum { - MISSION_CLASS_ID_START = FW_CLASS_ID_COUNT, -}; -} - - -#endif /* CONFIG_RETURNVALUES_CLASSIDS_H_ */ diff --git a/unittest/testcfg/tmtc/apid.h b/unittest/testcfg/tmtc/apid.h deleted file mode 100644 index 0172f6e3..00000000 --- a/unittest/testcfg/tmtc/apid.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef CONFIG_TMTC_APID_H_ -#define CONFIG_TMTC_APID_H_ - -#include - -/** - * Application Process Definition: entity, uniquely identified by an - * application process ID (APID), capable of generating telemetry source - * packets and receiving telecommand packets. - * - * Chose APID(s) for mission and define it here. - */ -namespace apid { - static const uint16_t EIVE_OBSW = 0x65; -} - - -#endif /* CONFIG_TMTC_APID_H_ */ diff --git a/unittest/testcfg/tmtc/pusIds.h b/unittest/testcfg/tmtc/pusIds.h deleted file mode 100644 index 821a9982..00000000 --- a/unittest/testcfg/tmtc/pusIds.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef CONFIG_TMTC_PUSIDS_HPP_ -#define CONFIG_TMTC_PUSIDS_HPP_ - -#include - -namespace pus { -enum Ids: uint8_t { - PUS_SERVICE_1 = 1, - PUS_SERVICE_2 = 2, - PUS_SERVICE_3 = 3, - PUS_SERVICE_5 = 5, - PUS_SERVICE_6 = 6, - PUS_SERVICE_8 = 8, - PUS_SERVICE_9 = 9, - PUS_SERVICE_11 = 11, - PUS_SERVICE_17 = 17, - PUS_SERVICE_19 = 19, - PUS_SERVICE_20 = 20, - PUS_SERVICE_23 = 23, - PUS_SERVICE_200 = 200, - PUS_SERVICE_201 = 201, -}; -}; - -#endif /* CONFIG_TMTC_PUSIDS_HPP_ */ From 5e42618dfdc1bbbb91e1f241ecd6fd6396c3788c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 11 Oct 2021 19:44:58 +0200 Subject: [PATCH 058/465] removed references to removed module --- CMakeLists.txt | 2 +- bsp_q7s/core/CoreController.cpp | 1 - bsp_q7s/memory/SdCardManager.cpp | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb944393..8d76f2fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -196,7 +196,7 @@ if((NOT BUILD_Q7S_SIMPLE_MODE) AND (NOT EIVE_BUILD_WATCHDOG)) endif() if(EIVE_BUILD_UNITTESTS) - add_subdirectory(${LIB_CATCH2_PATH}) + # add_subdirectory(${LIB_CATCH2_PATH}) add_subdirectory(${UNITTEST_PATH}) endif() diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index b899e60f..d8149ccb 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -6,7 +6,6 @@ #include "fsfw/FSFWVersion.h" #include "fsfw/timemanager/Stopwatch.h" #include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/osal/linux/Timer.h" #if OBSW_USE_TMTC_TCP_BRIDGE == 0 #include "fsfw/osal/common/UdpTmTcBridge.h" #else diff --git a/bsp_q7s/memory/SdCardManager.cpp b/bsp_q7s/memory/SdCardManager.cpp index 873bb6a4..ebebf854 100644 --- a/bsp_q7s/memory/SdCardManager.cpp +++ b/bsp_q7s/memory/SdCardManager.cpp @@ -1,4 +1,3 @@ -#include #include "SdCardManager.h" #include "scratchApi.h" From 01e9ef64c9362204ae1ddd66f0ba5d9d0ebedd34 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 11 Oct 2021 20:05:59 +0200 Subject: [PATCH 059/465] moved command executor --- bsp_q7s/memory/SdCardManager.h | 2 +- fsfw | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bsp_q7s/memory/SdCardManager.h b/bsp_q7s/memory/SdCardManager.h index 1a86f711..6f03e7f1 100644 --- a/bsp_q7s/memory/SdCardManager.h +++ b/bsp_q7s/memory/SdCardManager.h @@ -1,7 +1,7 @@ #ifndef BSP_Q7S_MEMORY_SDCARDACCESSMANAGER_H_ #define BSP_Q7S_MEMORY_SDCARDACCESSMANAGER_H_ -#include +#include "fsfw_hal/linux/CommandExecutor.h" #include "definitions.h" #include "returnvalues/classIds.h" #include "events/subsystemIdRanges.h" diff --git a/fsfw b/fsfw index 4130dd9e..d6938171 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 4130dd9e32eb1d4a5b0e993408ae614952bdd005 +Subproject commit d693817158af209b34c49ea09c6863a7a2bc1fbe From 667a893d01d193a6d1efe2d2e5407c98f56a1c03 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 11 Oct 2021 20:06:18 +0200 Subject: [PATCH 060/465] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index d6938171..0dedd8f2 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit d693817158af209b34c49ea09c6863a7a2bc1fbe +Subproject commit 0dedd8f2a18b619f4b5003e701e7bb40c0ac4d61 From 7c673d6e7fd2d703ca64d7f5b7a0f5a1a459c3ed Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 12 Oct 2021 17:55:36 +0200 Subject: [PATCH 061/465] bugfixes in max31685, indexing adapted --- bsp_hosted/fsfwconfig/devices/gpioIds.h | 32 ++-- bsp_q7s/core/ObjectFactory.cpp | 178 +++++++++--------- bsp_q7s/gpio/gpioCallbacks.cpp | 32 ++-- common/config/commonObjects.h | 32 ++-- linux/fsfwconfig/devices/addresses.h | 32 ++-- linux/fsfwconfig/devices/gpioIds.h | 32 ++-- .../pollingSequenceFactory.cpp | 164 ++++++++-------- mission/devices/Max31865PT1000Handler.cpp | 64 ++++--- mission/devices/Max31865PT1000Handler.h | 13 +- tmtc | 2 +- 10 files changed, 294 insertions(+), 287 deletions(-) diff --git a/bsp_hosted/fsfwconfig/devices/gpioIds.h b/bsp_hosted/fsfwconfig/devices/gpioIds.h index df49c0b7..53a53677 100644 --- a/bsp_hosted/fsfwconfig/devices/gpioIds.h +++ b/bsp_hosted/fsfwconfig/devices/gpioIds.h @@ -27,22 +27,22 @@ namespace gpioIds { TEST_ID_0, TEST_ID_1, - RTD_IC3, - RTD_IC4, - RTD_IC5, - RTD_IC6, - RTD_IC7, - RTD_IC8, - RTD_IC9, - RTD_IC10, - RTD_IC11, - RTD_IC12, - RTD_IC13, - RTD_IC14, - RTD_IC15, - RTD_IC16, - RTD_IC17, - RTD_IC18, + RTD_IC_0, + RTD_IC_1, + RTD_IC_2, + RTD_IC_3, + RTD_IC_4, + RTD_IC_5, + RTD_IC_6, + RTD_IC_7, + RTD_IC_8, + RTD_IC_9, + RTD_IC_10, + RTD_IC_11, + RTD_IC_12, + RTD_IC_13, + RTD_IC_14, + RTD_IC_15, SPI_MUX_BIT_1, SPI_MUX_BIT_2, diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 16e3da95..c6062926 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -136,7 +136,7 @@ void ObjectFactory::produce(void* args) { #endif /* OBSW_ADD_SYRLINKS == 1 */ #if OBSW_ADD_RTD_DEVICES == 1 - createRtdComponents(); + createRtdComponents(gpioComIF); #endif /* OBSW_ADD_RTD_DEVICES == 1 */ I2cCookie* imtqI2cCookie = new I2cCookie(addresses::IMTQ, IMTQ::MAX_REPLY_SIZE, @@ -641,148 +641,152 @@ void ObjectFactory::createSyrlinksComponents() { void ObjectFactory::createRtdComponents(LinuxLibgpioIF *gpioComIF) { GpioCookie* rtdGpioCookie = new GpioCookie; + GpioCallback* gpioRtdIc0 = new GpioCallback("Chip select RTD IC0", gpio::OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_0, gpioRtdIc0); + GpioCallback* gpioRtdIc1 = new GpioCallback("Chip select RTD IC1", gpio::OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_1, gpioRtdIc1); + GpioCallback* gpioRtdIc2 = new GpioCallback("Chip select RTD IC2", gpio::OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_2, gpioRtdIc2); GpioCallback* gpioRtdIc3 = new GpioCallback("Chip select RTD IC3", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC3, gpioRtdIc3); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_3, gpioRtdIc3); GpioCallback* gpioRtdIc4 = new GpioCallback("Chip select RTD IC4", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC4, gpioRtdIc4); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_4, gpioRtdIc4); GpioCallback* gpioRtdIc5 = new GpioCallback("Chip select RTD IC5", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC5, gpioRtdIc5); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_5, gpioRtdIc5); GpioCallback* gpioRtdIc6 = new GpioCallback("Chip select RTD IC6", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC6, gpioRtdIc6); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_6, gpioRtdIc6); GpioCallback* gpioRtdIc7 = new GpioCallback("Chip select RTD IC7", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC7, gpioRtdIc7); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_7, gpioRtdIc7); GpioCallback* gpioRtdIc8 = new GpioCallback("Chip select RTD IC8", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC8, gpioRtdIc8); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_8, gpioRtdIc8); GpioCallback* gpioRtdIc9 = new GpioCallback("Chip select RTD IC9", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC9, gpioRtdIc9); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_9, gpioRtdIc9); GpioCallback* gpioRtdIc10 = new GpioCallback("Chip select RTD IC10", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC10, gpioRtdIc10); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_10, gpioRtdIc10); GpioCallback* gpioRtdIc11 = new GpioCallback("Chip select RTD IC11", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC11, gpioRtdIc11); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_11, gpioRtdIc11); GpioCallback* gpioRtdIc12 = new GpioCallback("Chip select RTD IC12", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC12, gpioRtdIc12); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_12, gpioRtdIc12); GpioCallback* gpioRtdIc13 = new GpioCallback("Chip select RTD IC13", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC13, gpioRtdIc13); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_13, gpioRtdIc13); GpioCallback* gpioRtdIc14 = new GpioCallback("Chip select RTD IC14", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC14, gpioRtdIc14); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_14, gpioRtdIc14); GpioCallback* gpioRtdIc15 = new GpioCallback("Chip select RTD IC15", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC15, gpioRtdIc15); - GpioCallback* gpioRtdIc16 = new GpioCallback("Chip select RTD IC16", gpio::OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC16, gpioRtdIc16); - GpioCallback* gpioRtdIc17 = new GpioCallback("Chip select RTD IC17", gpio::OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC17, gpioRtdIc17); - GpioCallback* gpioRtdIc18 = new GpioCallback("Chip select RTD IC18", gpio::OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC18, gpioRtdIc18); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_15, gpioRtdIc15); gpioComIF->addGpios(rtdGpioCookie); - SpiCookie* spiRtdIc3 = new SpiCookie(addresses::RTD_IC3, gpioIds::RTD_IC3, q7s::SPI_DEFAULT_DEV, + SpiCookie* spiRtdIc0 = new SpiCookie(addresses::RTD_IC_0, gpioIds::RTD_IC_0, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - SpiCookie* spiRtdIc4 = new SpiCookie(addresses::RTD_IC4, gpioIds::RTD_IC4, q7s::SPI_DEFAULT_DEV, + SpiCookie* spiRtdIc1 = new SpiCookie(addresses::RTD_IC_1, gpioIds::RTD_IC_1, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - SpiCookie* spiRtdIc5 = new SpiCookie(addresses::RTD_IC5, gpioIds::RTD_IC5, q7s::SPI_DEFAULT_DEV, + SpiCookie* spiRtdIc2 = new SpiCookie(addresses::RTD_IC_2, gpioIds::RTD_IC_2, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - SpiCookie* spiRtdIc6 = new SpiCookie(addresses::RTD_IC6, gpioIds::RTD_IC6, q7s::SPI_DEFAULT_DEV, + SpiCookie* spiRtdIc3 = new SpiCookie(addresses::RTD_IC_3, gpioIds::RTD_IC_3, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - SpiCookie* spiRtdIc7 = new SpiCookie(addresses::RTD_IC7, gpioIds::RTD_IC7, q7s::SPI_DEFAULT_DEV, + SpiCookie* spiRtdIc4 = new SpiCookie(addresses::RTD_IC_4, gpioIds::RTD_IC_4, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - SpiCookie* spiRtdIc8 = new SpiCookie(addresses::RTD_IC8, gpioIds::RTD_IC8, q7s::SPI_DEFAULT_DEV, + SpiCookie* spiRtdIc5 = new SpiCookie(addresses::RTD_IC_5, gpioIds::RTD_IC_5, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - SpiCookie* spiRtdIc9 = new SpiCookie(addresses::RTD_IC9, gpioIds::RTD_IC9, q7s::SPI_DEFAULT_DEV, + SpiCookie* spiRtdIc6 = new SpiCookie(addresses::RTD_IC_6, gpioIds::RTD_IC_6, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - SpiCookie* spiRtdIc10 = new SpiCookie(addresses::RTD_IC10, gpioIds::RTD_IC10, + SpiCookie* spiRtdIc7 = new SpiCookie(addresses::RTD_IC_7, gpioIds::RTD_IC_7, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - SpiCookie* spiRtdIc11 = new SpiCookie(addresses::RTD_IC11, gpioIds::RTD_IC11, + SpiCookie* spiRtdIc8 = new SpiCookie(addresses::RTD_IC_8, gpioIds::RTD_IC_8, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - SpiCookie* spiRtdIc12 = new SpiCookie(addresses::RTD_IC12, gpioIds::RTD_IC12, + SpiCookie* spiRtdIc9 = new SpiCookie(addresses::RTD_IC_9, gpioIds::RTD_IC_9, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - SpiCookie* spiRtdIc13 = new SpiCookie(addresses::RTD_IC13, gpioIds::RTD_IC13, + SpiCookie* spiRtdIc10 = new SpiCookie(addresses::RTD_IC_10, gpioIds::RTD_IC_10, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - SpiCookie* spiRtdIc14 = new SpiCookie(addresses::RTD_IC14, gpioIds::RTD_IC14, + SpiCookie* spiRtdIc11 = new SpiCookie(addresses::RTD_IC_11, gpioIds::RTD_IC_11, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - SpiCookie* spiRtdIc15 = new SpiCookie(addresses::RTD_IC15, gpioIds::RTD_IC15, + SpiCookie* spiRtdIc12 = new SpiCookie(addresses::RTD_IC_12, gpioIds::RTD_IC_12, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - SpiCookie* spiRtdIc16 = new SpiCookie(addresses::RTD_IC16, gpioIds::RTD_IC16, + SpiCookie* spiRtdIc13 = new SpiCookie(addresses::RTD_IC_13, gpioIds::RTD_IC_13, std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - SpiCookie* spiRtdIc17 = new SpiCookie(addresses::RTD_IC17, gpioIds::RTD_IC17, + SpiCookie* spiRtdIc14 = new SpiCookie(addresses::RTD_IC_14, gpioIds::RTD_IC_14, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - SpiCookie* spiRtdIc18 = new SpiCookie(addresses::RTD_IC18, gpioIds::RTD_IC18, + SpiCookie* spiRtdIc15 = new SpiCookie(addresses::RTD_IC_15, gpioIds::RTD_IC_15, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - Max31865PT1000Handler* rtdIc3 = new Max31865PT1000Handler(objects::RTD_IC3, objects::SPI_COM_IF, - spiRtdIc3, 0); // 0 is switchId - Max31865PT1000Handler* rtdIc4 = new Max31865PT1000Handler(objects::RTD_IC4, objects::SPI_COM_IF, - spiRtdIc4, 0); - Max31865PT1000Handler* rtdIc5 = new Max31865PT1000Handler(objects::RTD_IC5, objects::SPI_COM_IF, - spiRtdIc5, 0); - Max31865PT1000Handler* rtdIc6 = new Max31865PT1000Handler(objects::RTD_IC6, objects::SPI_COM_IF, - spiRtdIc6, 0); - Max31865PT1000Handler* rtdIc7 = new Max31865PT1000Handler(objects::RTD_IC7, objects::SPI_COM_IF, - spiRtdIc7, 0); - Max31865PT1000Handler* rtdIc8 = new Max31865PT1000Handler(objects::RTD_IC8, objects::SPI_COM_IF, - spiRtdIc8, 0); - Max31865PT1000Handler* rtdIc9 = new Max31865PT1000Handler(objects::RTD_IC9, objects::SPI_COM_IF, - spiRtdIc9, 0); - Max31865PT1000Handler* rtdIc10 = new Max31865PT1000Handler(objects::RTD_IC10, - objects::SPI_COM_IF, spiRtdIc10, 0); - Max31865PT1000Handler* rtdIc11 = new Max31865PT1000Handler(objects::RTD_IC11, - objects::SPI_COM_IF, spiRtdIc11, 0); - Max31865PT1000Handler* rtdIc12 = new Max31865PT1000Handler(objects::RTD_IC12, - objects::SPI_COM_IF, spiRtdIc12, 0); - Max31865PT1000Handler* rtdIc13 = new Max31865PT1000Handler(objects::RTD_IC13, - objects::SPI_COM_IF, spiRtdIc13, 0); - Max31865PT1000Handler* rtdIc14 = new Max31865PT1000Handler(objects::RTD_IC14, - objects::SPI_COM_IF, spiRtdIc14, 0); - Max31865PT1000Handler* rtdIc15 = new Max31865PT1000Handler(objects::RTD_IC15, - objects::SPI_COM_IF, spiRtdIc15, 0); - Max31865PT1000Handler* rtdIc16 = new Max31865PT1000Handler(objects::RTD_IC16, - objects::SPI_COM_IF, spiRtdIc16, 0); - Max31865PT1000Handler* rtdIc17 = new Max31865PT1000Handler(objects::RTD_IC17, - objects::SPI_COM_IF, spiRtdIc17, 0); - Max31865PT1000Handler* rtdIc18 = new Max31865PT1000Handler(objects::RTD_IC18, - objects::SPI_COM_IF, spiRtdIc18, 0); + Max31865PT1000Handler* rtdIc0 = new Max31865PT1000Handler(objects::RTD_IC_0, objects::SPI_COM_IF, + spiRtdIc0); + Max31865PT1000Handler* rtdIc1 = new Max31865PT1000Handler(objects::RTD_IC_1, objects::SPI_COM_IF, + spiRtdIc1); + Max31865PT1000Handler* rtdIc2 = new Max31865PT1000Handler(objects::RTD_IC_2, objects::SPI_COM_IF, + spiRtdIc2); + Max31865PT1000Handler* rtdIc3 = new Max31865PT1000Handler(objects::RTD_IC_3, objects::SPI_COM_IF, + spiRtdIc3); + Max31865PT1000Handler* rtdIc4 = new Max31865PT1000Handler(objects::RTD_IC_4, objects::SPI_COM_IF, + spiRtdIc4); + Max31865PT1000Handler* rtdIc5 = new Max31865PT1000Handler(objects::RTD_IC_5, objects::SPI_COM_IF, + spiRtdIc5); + Max31865PT1000Handler* rtdIc6 = new Max31865PT1000Handler(objects::RTD_IC_6, objects::SPI_COM_IF, + spiRtdIc6); + Max31865PT1000Handler* rtdIc7 = new Max31865PT1000Handler(objects::RTD_IC_7, + objects::SPI_COM_IF, spiRtdIc7); + Max31865PT1000Handler* rtdIc8 = new Max31865PT1000Handler(objects::RTD_IC_8, + objects::SPI_COM_IF, spiRtdIc8); + Max31865PT1000Handler* rtdIc9 = new Max31865PT1000Handler(objects::RTD_IC_9, + objects::SPI_COM_IF, spiRtdIc9); + Max31865PT1000Handler* rtdIc10 = new Max31865PT1000Handler(objects::RTD_IC_10, + objects::SPI_COM_IF, spiRtdIc10); + Max31865PT1000Handler* rtdIc11 = new Max31865PT1000Handler(objects::RTD_IC_11, + objects::SPI_COM_IF, spiRtdIc11); + Max31865PT1000Handler* rtdIc12 = new Max31865PT1000Handler(objects::RTD_IC_12, + objects::SPI_COM_IF, spiRtdIc12); + Max31865PT1000Handler* rtdIc13 = new Max31865PT1000Handler(objects::RTD_IC_13, + objects::SPI_COM_IF, spiRtdIc13); + Max31865PT1000Handler* rtdIc14 = new Max31865PT1000Handler(objects::RTD_IC_14, + objects::SPI_COM_IF, spiRtdIc14); + Max31865PT1000Handler* rtdIc15 = new Max31865PT1000Handler(objects::RTD_IC_15, + objects::SPI_COM_IF, spiRtdIc15); - (void) rtdIc3; - (void) rtdIc4; - (void) rtdIc5; - (void) rtdIc6; - (void) rtdIc7; - (void) rtdIc8; - (void) rtdIc9; - (void) rtdIc10; - (void) rtdIc11; - (void) rtdIc12; - (void) rtdIc13; - (void) rtdIc14; - (void) rtdIc15; - (void) rtdIc16; - (void) rtdIc17; - (void) rtdIc18; + rtdIc0->setStartUpImmediately(); + rtdIc1->setStartUpImmediately(); + rtdIc2->setStartUpImmediately(); + + static_cast(rtdIc0); + static_cast(rtdIc1); + static_cast(rtdIc2); + static_cast(rtdIc3); + static_cast(rtdIc4); + static_cast(rtdIc5); + static_cast(rtdIc6); + static_cast(rtdIc7); + static_cast(rtdIc8); + static_cast(rtdIc9); + static_cast(rtdIc10); + static_cast(rtdIc11); + static_cast(rtdIc12); + static_cast(rtdIc13); + static_cast(rtdIc14); + static_cast(rtdIc15); } void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF) { diff --git a/bsp_q7s/gpio/gpioCallbacks.cpp b/bsp_q7s/gpio/gpioCallbacks.cpp index 8280b1e9..27ae18d0 100644 --- a/bsp_q7s/gpio/gpioCallbacks.cpp +++ b/bsp_q7s/gpio/gpioCallbacks.cpp @@ -72,82 +72,82 @@ void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, gpio::Lev } else if (value == gpio::LOW) { switch (gpioId) { - case(gpioIds::RTD_IC3): { + case(gpioIds::RTD_IC_0): { enableDecoderTcsIc1(); selectY7(); break; } - case(gpioIds::RTD_IC4): { + case(gpioIds::RTD_IC_1): { enableDecoderTcsIc1(); selectY6(); break; } - case(gpioIds::RTD_IC5): { + case(gpioIds::RTD_IC_2): { enableDecoderTcsIc1(); selectY5(); break; } - case(gpioIds::RTD_IC6): { + case(gpioIds::RTD_IC_3): { enableDecoderTcsIc1(); selectY4(); break; } - case(gpioIds::RTD_IC7): { + case(gpioIds::RTD_IC_4): { enableDecoderTcsIc1(); selectY3(); break; } - case(gpioIds::RTD_IC8): { + case(gpioIds::RTD_IC_5): { enableDecoderTcsIc1(); selectY2(); break; } - case(gpioIds::RTD_IC9): { + case(gpioIds::RTD_IC_6): { enableDecoderTcsIc1(); selectY1(); break; } - case(gpioIds::RTD_IC10): { + case(gpioIds::RTD_IC_7): { enableDecoderTcsIc1(); selectY0(); break; } - case(gpioIds::RTD_IC11): { + case(gpioIds::RTD_IC_8): { enableDecoderTcsIc2(); selectY7(); break; } - case(gpioIds::RTD_IC12): { + case(gpioIds::RTD_IC_9): { enableDecoderTcsIc2(); selectY6(); break; } - case(gpioIds::RTD_IC13): { + case(gpioIds::RTD_IC_10): { enableDecoderTcsIc2(); selectY5(); break; } - case(gpioIds::RTD_IC14): { + case(gpioIds::RTD_IC_11): { enableDecoderTcsIc2(); selectY4(); break; } - case(gpioIds::RTD_IC15): { + case(gpioIds::RTD_IC_12): { enableDecoderTcsIc2(); selectY3(); break; } - case(gpioIds::RTD_IC16): { + case(gpioIds::RTD_IC_13): { enableDecoderTcsIc2(); selectY2(); break; } - case(gpioIds::RTD_IC17): { + case(gpioIds::RTD_IC_14): { enableDecoderTcsIc2(); selectY1(); break; } - case(gpioIds::RTD_IC18): { + case(gpioIds::RTD_IC_15): { enableDecoderTcsIc2(); selectY0(); break; diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index 43cd396c..9e4418d2 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -47,22 +47,22 @@ enum commonObjects: uint32_t { * Not yet specified which pt1000 will measure which device/location in the satellite. * Therefore object ids are named according to the IC naming of the RTDs in the schematic. */ - RTD_IC3 = 0x44420016, - RTD_IC4 = 0x44420017, - RTD_IC5 = 0x44420018, - RTD_IC6 = 0x44420019, - RTD_IC7 = 0x44420020, - RTD_IC8 = 0x44420021, - RTD_IC9 = 0x44420022, - RTD_IC10 = 0x44420023, - RTD_IC11 = 0x44420024, - RTD_IC12 = 0x44420025, - RTD_IC13 = 0x44420026, - RTD_IC14 = 0x44420027, - RTD_IC15 = 0x44420028, - RTD_IC16 = 0x44420029, - RTD_IC17 = 0x44420030, - RTD_IC18 = 0x44420031, + RTD_IC_0 = 0x44420016, + RTD_IC_1 = 0x44420017, + RTD_IC_2 = 0x44420018, + RTD_IC_3 = 0x44420019, + RTD_IC_4 = 0x44420020, + RTD_IC_5 = 0x44420021, + RTD_IC_6 = 0x44420022, + RTD_IC_7 = 0x44420023, + RTD_IC_8 = 0x44420024, + RTD_IC_9 = 0x44420025, + RTD_IC_10 = 0x44420026, + RTD_IC_11 = 0x44420027, + RTD_IC_12 = 0x44420028, + RTD_IC_13 = 0x44420029, + RTD_IC_14 = 0x44420030, + RTD_IC_15 = 0x44420031, SUS_1 = 0x44120032, SUS_2 = 0x44120033, diff --git a/linux/fsfwconfig/devices/addresses.h b/linux/fsfwconfig/devices/addresses.h index 9d620475..945c2eb7 100644 --- a/linux/fsfwconfig/devices/addresses.h +++ b/linux/fsfwconfig/devices/addresses.h @@ -49,22 +49,22 @@ namespace addresses { }; enum spiAddresses: address_t { - RTD_IC3, - RTD_IC4, - RTD_IC5, - RTD_IC6, - RTD_IC7, - RTD_IC8, - RTD_IC9, - RTD_IC10, - RTD_IC11, - RTD_IC12, - RTD_IC13, - RTD_IC14, - RTD_IC15, - RTD_IC16, - RTD_IC17, - RTD_IC18, + RTD_IC_0, + RTD_IC_1, + RTD_IC_2, + RTD_IC_3, + RTD_IC_4, + RTD_IC_5, + RTD_IC_6, + RTD_IC_7, + RTD_IC_8, + RTD_IC_9, + RTD_IC_10, + RTD_IC_11, + RTD_IC_12, + RTD_IC_13, + RTD_IC_14, + RTD_IC_15, RW1, RW2, RW3, diff --git a/linux/fsfwconfig/devices/gpioIds.h b/linux/fsfwconfig/devices/gpioIds.h index 5f09e5f6..62913d5a 100644 --- a/linux/fsfwconfig/devices/gpioIds.h +++ b/linux/fsfwconfig/devices/gpioIds.h @@ -34,22 +34,22 @@ enum gpioId_t { TEST_ID_0, TEST_ID_1, - RTD_IC3, - RTD_IC4, - RTD_IC5, - RTD_IC6, - RTD_IC7, - RTD_IC8, - RTD_IC9, - RTD_IC10, - RTD_IC11, - RTD_IC12, - RTD_IC13, - RTD_IC14, - RTD_IC15, - RTD_IC16, - RTD_IC17, - RTD_IC18, + RTD_IC_0, + RTD_IC_1, + RTD_IC_2, + RTD_IC_3, + RTD_IC_4, + RTD_IC_5, + RTD_IC_6, + RTD_IC_7, + RTD_IC_8, + RTD_IC_9, + RTD_IC_10, + RTD_IC_11, + RTD_IC_12, + RTD_IC_13, + RTD_IC_14, + RTD_IC_15, CS_SUS_1, CS_SUS_2, diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 96950006..887f0f5c 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -36,22 +36,22 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { DeviceHandlerIF::PERFORM_OPERATION); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC5, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC6, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC7, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC8, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC9, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC10, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC11, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC12, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC13, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC14, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC15, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC16, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC17, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC18, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_0, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_1, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_2, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_5, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_6, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_7, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_8, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_9, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_10, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_11, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_12, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_13, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_14, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_15, length * 0, DeviceHandlerIF::PERFORM_OPERATION); #endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_TMP_DEVICES == 1 @@ -59,22 +59,22 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.2, DeviceHandlerIF::SEND_WRITE); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC3, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC4, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC5, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC6, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC7, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC8, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC9, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC10, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC11, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC12, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC13, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC14, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC15, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC16, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC17, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC18, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_0, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_1, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_2, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_3, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_4, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_5, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_6, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_7, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_8, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_9, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_10, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_11, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_12, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_13, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_14, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_15, length * 0.2, DeviceHandlerIF::SEND_WRITE); #endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_TMP_DEVICES == 1 @@ -82,22 +82,22 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.4, DeviceHandlerIF::GET_WRITE); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC3, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC4, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC5, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC6, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC7, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC8, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC9, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC10, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC11, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC12, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC13, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC14, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC15, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC16, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC17, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC18, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_0, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_1, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_2, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_3, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_4, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_5, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_6, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_7, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_8, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_9, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_10, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_11, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_12, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_13, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_14, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_15, length * 0.4, DeviceHandlerIF::GET_WRITE); #endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_TMP_DEVICES == 1 @@ -105,22 +105,22 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.6, DeviceHandlerIF::SEND_READ); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC3, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC4, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC5, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC6, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC7, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC8, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC9, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC10, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC11, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC12, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC13, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC14, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC15, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC16, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC17, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC18, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_0, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_1, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_2, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_3, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_4, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_5, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_6, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_7, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_8, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_9, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_10, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_11, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_12, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_13, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_14, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_15, length * 0.6, DeviceHandlerIF::SEND_READ); #endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_TMP_DEVICES == 1 @@ -128,22 +128,22 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC3, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC4, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC5, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC6, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC7, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC8, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC9, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC10, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC11, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC12, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC13, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC14, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC15, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC16, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC17, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC18, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_0, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_1, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_2, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_3, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_4, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_5, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_6, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_7, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_8, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_9, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_10, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_11, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_12, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_13, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_14, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_15, length * 0.8, DeviceHandlerIF::GET_READ); #endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_RAD_SENSORS == 1 @@ -439,8 +439,8 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { #endif #if OBSW_ADD_ACS_BOARD == 1 - bool enableAside = false; - bool enableBside = true; + bool enableAside = true; + bool enableBside = false; if(enableAside) { // A side thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0, diff --git a/mission/devices/Max31865PT1000Handler.cpp b/mission/devices/Max31865PT1000Handler.cpp index ac33e01d..450d34f3 100644 --- a/mission/devices/Max31865PT1000Handler.cpp +++ b/mission/devices/Max31865PT1000Handler.cpp @@ -5,10 +5,10 @@ #include #include -Max31865PT1000Handler::Max31865PT1000Handler(object_id_t objectId, - object_id_t comIF, CookieIF *comCookie, uint8_t switchId): - DeviceHandlerBase(objectId, comIF, comCookie), switchId(switchId), - sensorDataset(this), sensorDatasetSid(sensorDataset.getSid()) { +Max31865PT1000Handler::Max31865PT1000Handler(object_id_t objectId, object_id_t comIF, + CookieIF *comCookie): + DeviceHandlerBase(objectId, comIF, comCookie), sensorDataset(this), + sensorDatasetSid(sensorDataset.getSid()) { #if OBSW_VERBOSE_LEVEL >= 1 debugDivider = new PeriodicOperationDivider(0); #endif @@ -33,8 +33,8 @@ void Max31865PT1000Handler::doStartUp() { if(internalState == InternalState::CONFIGURE) { if(commandExecuted) { - internalState = InternalState::REQUEST_CONFIG; commandExecuted = false; + internalState = InternalState::REQUEST_CONFIG; } } @@ -323,26 +323,32 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply( break; } case(Max31865Definitions::REQUEST_LOW_THRESHOLD): { - uint16_t readLowThreshold = packet[0] << 8 | packet[1]; + uint16_t readLowThreshold = packet[1] << 8 | packet[2]; if(readLowThreshold != LOW_THRESHOLD) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 && OBSW_DEBUG_RTD == 1 - sif::error - << "Max31865PT1000Handler::interpretDeviceReply: Missmatch between written " - << "and readback value of low threshold register" - << std::endl; +#if FSFW_VERBOSE_LEVEL >= 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Missmatch between " << + "written and readback value of low threshold register" << std::endl; +#else + sif::printWarning("Max31865PT1000Handler::interpretDeviceReply: Missmatch between " + "written and readback value of low threshold register\n"); +#endif #endif } commandExecuted = true; break; } case(Max31865Definitions::REQUEST_HIGH_THRESHOLD): { - uint16_t readHighThreshold = packet[0] << 8 | packet[1]; + uint16_t readHighThreshold = packet[1] << 8 | packet[2]; if(readHighThreshold != HIGH_THRESHOLD) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 && OBSW_DEBUG_RTD == 1 - sif::error - << "Max31865PT1000Handler::interpretDeviceReply: Missmatch between written " - << "and readback value of high threshold register" - << std::endl; +#if FSFW_VERBOSE_LEVEL >= 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Missmatch between " << + "written and readback value of high threshold register" << std::endl; +#else + sif::printWarning("Max31865PT1000Handler::interpretDeviceReply: Missmatch between " + "written and readback value of high threshold register\n"); +#endif #endif } commandExecuted = true; @@ -365,30 +371,28 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply( // calculate approximation float approxTemp = adcCode / 32.0 - 256.0; +#if OBSW_DEBUG_RTD == 1 #if OBSW_VERBOSE_LEVEL >= 1 if(debugDivider->checkAndIncrement()) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "Max31865PT1000Handler::interpretDeviceReply: Measured " - << "resistance is " << rtdValue << " Ohms." << std::endl; - sif::info << "Approximated temperature is " << approxTemp << " C" - << std::endl; + sif::info << "Max31865: Measured resistance is " << rtdValue << " Ohms." << std::endl; + sif::info << "Approximated temperature is " << approxTemp << " C" << std::endl; #else - sif::printInfo("Max31865PT1000Handler::interpretDeviceReply: Measured resistance is %f" - " Ohms.\n", rtdValue); + sif::printInfo("Max31685: Measured resistance is %f Ohms\n", rtdValue); sif::printInfo("Approximated temperature is %f C\n", approxTemp); #endif - sensorDataset.setChanged(true); } #endif - +#endif PoolReadGuard pg(&sensorDataset); if(pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) { // Configuration error #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "Max31865PT1000Handler::interpretDeviceReply: Error reading dataset!" + sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Error reading dataset!" << std::endl; #else - sif::printDebug("Max31865PT1000Handler::interpretDeviceReply: Error reading dataset!\n"); + sif::printWarning("Max31865PT1000Handler::interpretDeviceReply: " + "Error reading dataset!\n"); #endif return pg.getReadResult(); } @@ -407,10 +411,10 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply( faultByte = packet[1]; #if OBSW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "Max31865PT1000Handler::interpretDeviceReply: Fault byte" + sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Fault byte" " is: 0b" << std::bitset<8>(faultByte) << std::endl; #else - sif::printInfo("Max31865PT1000Handler::interpretDeviceReply: Fault byte" + sif::printWarning("Max31865PT1000Handler::interpretDeviceReply: Fault byte" " is: 0b" BYTE_TO_BINARY_PATTERN "\n", BYTE_TO_BINARY(faultByte)); #endif #endif @@ -459,7 +463,7 @@ void Max31865PT1000Handler::debugInterface(uint8_t positionTracker, uint32_t Max31865PT1000Handler::getTransitionDelayMs( Mode_t modeFrom, Mode_t modeTo) { - return 20000; + return 25000; } ReturnValue_t Max31865PT1000Handler::getSwitches( diff --git a/mission/devices/Max31865PT1000Handler.h b/mission/devices/Max31865PT1000Handler.h index f3240788..ad412ef1 100644 --- a/mission/devices/Max31865PT1000Handler.h +++ b/mission/devices/Max31865PT1000Handler.h @@ -30,8 +30,7 @@ */ class Max31865PT1000Handler: public DeviceHandlerBase { public: - Max31865PT1000Handler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie, uint8_t switchId); + Max31865PT1000Handler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); virtual~ Max31865PT1000Handler(); // Configuration in 8 digit code: @@ -47,15 +46,15 @@ public: static constexpr uint8_t DEFAULT_CONFIG = 0b11000001; /** - * Expected temperature range is -100°C and 100°C. + * Expected temperature range is -100 C and 100 C. * If there are temperatures beyond this range there must be a fault. * The threshold variables cause the MAX1385 to signal an error in case the measured resistance - * indicates a temperature higher than 100°C or lower than -100°C. + * indicates a temperature higher than 100 C or lower than -100 C. * Default settings of MAX13865 are 0xFFFF for the high threshold register and 0x0 for the * low threshold register. */ - static constexpr uint16_t HIGH_THRESHOLD = 11298; // = 100°C - static constexpr uint16_t LOW_THRESHOLD = 4902; // = -100°C + static constexpr uint16_t HIGH_THRESHOLD = 11298; // = 100 C + static constexpr uint16_t LOW_THRESHOLD = 4902; // = -100 C static constexpr float RTD_RREF_PT1000 = 4020.0; //!< Ohm static constexpr float RTD_RESISTANCE0_PT1000 = 1000.0; //!< Ohm @@ -85,7 +84,7 @@ protected: void modeChanged() override; private: - const uint8_t switchId; + uint8_t switchId = 0; enum class InternalState { NONE, diff --git a/tmtc b/tmtc index 4325b8cc..423f1fbb 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 4325b8ccaa0495eb8b23f4b6aeec3165c62e7bd1 +Subproject commit 423f1fbb2c9f93f6eb3f3ae8ecbbdbfa30002596 From dcdf0c98439e92e1ef3b9766db2d2eead2e06cdf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 12 Oct 2021 18:03:00 +0200 Subject: [PATCH 062/465] updated object translation file --- generators/bsp_q7s_objects.csv | 38 ++++---- generators/objects/translateObjects.cpp | 86 +++++++++++-------- generators/requirements.txt | 1 + linux/fsfwconfig/objects/translateObjects.cpp | 86 +++++++++++-------- 4 files changed, 127 insertions(+), 84 deletions(-) create mode 100644 generators/requirements.txt diff --git a/generators/bsp_q7s_objects.csv b/generators/bsp_q7s_objects.csv index 4930f7a0..24035373 100644 --- a/generators/bsp_q7s_objects.csv +++ b/generators/bsp_q7s_objects.csv @@ -45,22 +45,22 @@ 0x444100A4;HEATER_HANDLER 0x44420004;TMP1075_HANDLER_1 0x44420005;TMP1075_HANDLER_2 -0x44420016;RTD_IC3 -0x44420017;RTD_IC4 -0x44420018;RTD_IC5 -0x44420019;RTD_IC6 -0x44420020;RTD_IC7 -0x44420021;RTD_IC8 -0x44420022;RTD_IC9 -0x44420023;RTD_IC10 -0x44420024;RTD_IC11 -0x44420025;RTD_IC12 -0x44420026;RTD_IC13 -0x44420027;RTD_IC14 -0x44420028;RTD_IC15 -0x44420029;RTD_IC16 -0x44420030;RTD_IC17 -0x44420031;RTD_IC18 +0x44420016;RTD_IC_0 +0x44420017;RTD_IC_1 +0x44420018;RTD_IC_2 +0x44420019;RTD_IC_3 +0x44420020;RTD_IC_4 +0x44420021;RTD_IC_5 +0x44420022;RTD_IC_6 +0x44420023;RTD_IC_7 +0x44420024;RTD_IC_8 +0x44420025;RTD_IC_9 +0x44420026;RTD_IC_10 +0x44420027;RTD_IC_11 +0x44420028;RTD_IC_12 +0x44420029;RTD_IC_13 +0x44420030;RTD_IC_14 +0x44420031;RTD_IC_15 0x445300A3;SYRLINKS_HK_HANDLER 0x49000000;ARDUINO_COM_IF 0x49010005;GPIO_IF @@ -73,6 +73,12 @@ 0x50000300;TMTC_BRIDGE 0x50000400;TMTC_POLLING_TASK 0x50000500;FILE_SYSTEM_HANDLER +0x50000600;PTME +0x50000700;PAPB_VC0 +0x50000701;PAPB_VC1 +0x50000702;PAPB_VC2 +0x50000703;PAPB_VC3 +0x50000800;CCSDS_HANDLER 0x51000500;PUS_SERVICE_6 0x53000000;FSFW_OBJECTS_START 0x53000001;PUS_SERVICE_1_VERIFICATION diff --git a/generators/objects/translateObjects.cpp b/generators/objects/translateObjects.cpp index 23a232c8..4b256595 100644 --- a/generators/objects/translateObjects.cpp +++ b/generators/objects/translateObjects.cpp @@ -1,8 +1,8 @@ /** * @brief Auto-generated object translation file. * @details - * Contains 105 translations. - * Generated on: 2021-08-31 10:31:24 + * Contains 111 translations. + * Generated on: 2021-10-12 18:02:43 */ #include "translateObjects.h" @@ -53,22 +53,22 @@ const char *SOLAR_ARRAY_DEPL_HANDLER_STRING = "SOLAR_ARRAY_DEPL_HANDLER"; const char *HEATER_HANDLER_STRING = "HEATER_HANDLER"; const char *TMP1075_HANDLER_1_STRING = "TMP1075_HANDLER_1"; const char *TMP1075_HANDLER_2_STRING = "TMP1075_HANDLER_2"; -const char *RTD_IC3_STRING = "RTD_IC3"; -const char *RTD_IC4_STRING = "RTD_IC4"; -const char *RTD_IC5_STRING = "RTD_IC5"; -const char *RTD_IC6_STRING = "RTD_IC6"; -const char *RTD_IC7_STRING = "RTD_IC7"; -const char *RTD_IC8_STRING = "RTD_IC8"; -const char *RTD_IC9_STRING = "RTD_IC9"; -const char *RTD_IC10_STRING = "RTD_IC10"; -const char *RTD_IC11_STRING = "RTD_IC11"; -const char *RTD_IC12_STRING = "RTD_IC12"; -const char *RTD_IC13_STRING = "RTD_IC13"; -const char *RTD_IC14_STRING = "RTD_IC14"; -const char *RTD_IC15_STRING = "RTD_IC15"; -const char *RTD_IC16_STRING = "RTD_IC16"; -const char *RTD_IC17_STRING = "RTD_IC17"; -const char *RTD_IC18_STRING = "RTD_IC18"; +const char *RTD_IC_0_STRING = "RTD_IC_0"; +const char *RTD_IC_1_STRING = "RTD_IC_1"; +const char *RTD_IC_2_STRING = "RTD_IC_2"; +const char *RTD_IC_3_STRING = "RTD_IC_3"; +const char *RTD_IC_4_STRING = "RTD_IC_4"; +const char *RTD_IC_5_STRING = "RTD_IC_5"; +const char *RTD_IC_6_STRING = "RTD_IC_6"; +const char *RTD_IC_7_STRING = "RTD_IC_7"; +const char *RTD_IC_8_STRING = "RTD_IC_8"; +const char *RTD_IC_9_STRING = "RTD_IC_9"; +const char *RTD_IC_10_STRING = "RTD_IC_10"; +const char *RTD_IC_11_STRING = "RTD_IC_11"; +const char *RTD_IC_12_STRING = "RTD_IC_12"; +const char *RTD_IC_13_STRING = "RTD_IC_13"; +const char *RTD_IC_14_STRING = "RTD_IC_14"; +const char *RTD_IC_15_STRING = "RTD_IC_15"; const char *SYRLINKS_HK_HANDLER_STRING = "SYRLINKS_HK_HANDLER"; const char *ARDUINO_COM_IF_STRING = "ARDUINO_COM_IF"; const char *GPIO_IF_STRING = "GPIO_IF"; @@ -81,6 +81,12 @@ const char *PUS_PACKET_DISTRIBUTOR_STRING = "PUS_PACKET_DISTRIBUTOR"; const char *TMTC_BRIDGE_STRING = "TMTC_BRIDGE"; const char *TMTC_POLLING_TASK_STRING = "TMTC_POLLING_TASK"; const char *FILE_SYSTEM_HANDLER_STRING = "FILE_SYSTEM_HANDLER"; +const char *PTME_STRING = "PTME"; +const char *PAPB_VC0_STRING = "PAPB_VC0"; +const char *PAPB_VC1_STRING = "PAPB_VC1"; +const char *PAPB_VC2_STRING = "PAPB_VC2"; +const char *PAPB_VC3_STRING = "PAPB_VC3"; +const char *CCSDS_HANDLER_STRING = "CCSDS_HANDLER"; const char *PUS_SERVICE_6_STRING = "PUS_SERVICE_6"; const char *FSFW_OBJECTS_START_STRING = "FSFW_OBJECTS_START"; const char *PUS_SERVICE_1_VERIFICATION_STRING = "PUS_SERVICE_1_VERIFICATION"; @@ -209,37 +215,37 @@ const char* translateObject(object_id_t object) { case 0x44420005: return TMP1075_HANDLER_2_STRING; case 0x44420016: - return RTD_IC3_STRING; + return RTD_IC_0_STRING; case 0x44420017: - return RTD_IC4_STRING; + return RTD_IC_1_STRING; case 0x44420018: - return RTD_IC5_STRING; + return RTD_IC_2_STRING; case 0x44420019: - return RTD_IC6_STRING; + return RTD_IC_3_STRING; case 0x44420020: - return RTD_IC7_STRING; + return RTD_IC_4_STRING; case 0x44420021: - return RTD_IC8_STRING; + return RTD_IC_5_STRING; case 0x44420022: - return RTD_IC9_STRING; + return RTD_IC_6_STRING; case 0x44420023: - return RTD_IC10_STRING; + return RTD_IC_7_STRING; case 0x44420024: - return RTD_IC11_STRING; + return RTD_IC_8_STRING; case 0x44420025: - return RTD_IC12_STRING; + return RTD_IC_9_STRING; case 0x44420026: - return RTD_IC13_STRING; + return RTD_IC_10_STRING; case 0x44420027: - return RTD_IC14_STRING; + return RTD_IC_11_STRING; case 0x44420028: - return RTD_IC15_STRING; + return RTD_IC_12_STRING; case 0x44420029: - return RTD_IC16_STRING; + return RTD_IC_13_STRING; case 0x44420030: - return RTD_IC17_STRING; + return RTD_IC_14_STRING; case 0x44420031: - return RTD_IC18_STRING; + return RTD_IC_15_STRING; case 0x445300A3: return SYRLINKS_HK_HANDLER_STRING; case 0x49000000: @@ -264,6 +270,18 @@ const char* translateObject(object_id_t object) { return TMTC_POLLING_TASK_STRING; case 0x50000500: return FILE_SYSTEM_HANDLER_STRING; + case 0x50000600: + return PTME_STRING; + case 0x50000700: + return PAPB_VC0_STRING; + case 0x50000701: + return PAPB_VC1_STRING; + case 0x50000702: + return PAPB_VC2_STRING; + case 0x50000703: + return PAPB_VC3_STRING; + case 0x50000800: + return CCSDS_HANDLER_STRING; case 0x51000500: return PUS_SERVICE_6_STRING; case 0x53000000: diff --git a/generators/requirements.txt b/generators/requirements.txt new file mode 100644 index 00000000..0aa54598 --- /dev/null +++ b/generators/requirements.txt @@ -0,0 +1 @@ +colorlog>=5.0.0 diff --git a/linux/fsfwconfig/objects/translateObjects.cpp b/linux/fsfwconfig/objects/translateObjects.cpp index 23a232c8..4b256595 100644 --- a/linux/fsfwconfig/objects/translateObjects.cpp +++ b/linux/fsfwconfig/objects/translateObjects.cpp @@ -1,8 +1,8 @@ /** * @brief Auto-generated object translation file. * @details - * Contains 105 translations. - * Generated on: 2021-08-31 10:31:24 + * Contains 111 translations. + * Generated on: 2021-10-12 18:02:43 */ #include "translateObjects.h" @@ -53,22 +53,22 @@ const char *SOLAR_ARRAY_DEPL_HANDLER_STRING = "SOLAR_ARRAY_DEPL_HANDLER"; const char *HEATER_HANDLER_STRING = "HEATER_HANDLER"; const char *TMP1075_HANDLER_1_STRING = "TMP1075_HANDLER_1"; const char *TMP1075_HANDLER_2_STRING = "TMP1075_HANDLER_2"; -const char *RTD_IC3_STRING = "RTD_IC3"; -const char *RTD_IC4_STRING = "RTD_IC4"; -const char *RTD_IC5_STRING = "RTD_IC5"; -const char *RTD_IC6_STRING = "RTD_IC6"; -const char *RTD_IC7_STRING = "RTD_IC7"; -const char *RTD_IC8_STRING = "RTD_IC8"; -const char *RTD_IC9_STRING = "RTD_IC9"; -const char *RTD_IC10_STRING = "RTD_IC10"; -const char *RTD_IC11_STRING = "RTD_IC11"; -const char *RTD_IC12_STRING = "RTD_IC12"; -const char *RTD_IC13_STRING = "RTD_IC13"; -const char *RTD_IC14_STRING = "RTD_IC14"; -const char *RTD_IC15_STRING = "RTD_IC15"; -const char *RTD_IC16_STRING = "RTD_IC16"; -const char *RTD_IC17_STRING = "RTD_IC17"; -const char *RTD_IC18_STRING = "RTD_IC18"; +const char *RTD_IC_0_STRING = "RTD_IC_0"; +const char *RTD_IC_1_STRING = "RTD_IC_1"; +const char *RTD_IC_2_STRING = "RTD_IC_2"; +const char *RTD_IC_3_STRING = "RTD_IC_3"; +const char *RTD_IC_4_STRING = "RTD_IC_4"; +const char *RTD_IC_5_STRING = "RTD_IC_5"; +const char *RTD_IC_6_STRING = "RTD_IC_6"; +const char *RTD_IC_7_STRING = "RTD_IC_7"; +const char *RTD_IC_8_STRING = "RTD_IC_8"; +const char *RTD_IC_9_STRING = "RTD_IC_9"; +const char *RTD_IC_10_STRING = "RTD_IC_10"; +const char *RTD_IC_11_STRING = "RTD_IC_11"; +const char *RTD_IC_12_STRING = "RTD_IC_12"; +const char *RTD_IC_13_STRING = "RTD_IC_13"; +const char *RTD_IC_14_STRING = "RTD_IC_14"; +const char *RTD_IC_15_STRING = "RTD_IC_15"; const char *SYRLINKS_HK_HANDLER_STRING = "SYRLINKS_HK_HANDLER"; const char *ARDUINO_COM_IF_STRING = "ARDUINO_COM_IF"; const char *GPIO_IF_STRING = "GPIO_IF"; @@ -81,6 +81,12 @@ const char *PUS_PACKET_DISTRIBUTOR_STRING = "PUS_PACKET_DISTRIBUTOR"; const char *TMTC_BRIDGE_STRING = "TMTC_BRIDGE"; const char *TMTC_POLLING_TASK_STRING = "TMTC_POLLING_TASK"; const char *FILE_SYSTEM_HANDLER_STRING = "FILE_SYSTEM_HANDLER"; +const char *PTME_STRING = "PTME"; +const char *PAPB_VC0_STRING = "PAPB_VC0"; +const char *PAPB_VC1_STRING = "PAPB_VC1"; +const char *PAPB_VC2_STRING = "PAPB_VC2"; +const char *PAPB_VC3_STRING = "PAPB_VC3"; +const char *CCSDS_HANDLER_STRING = "CCSDS_HANDLER"; const char *PUS_SERVICE_6_STRING = "PUS_SERVICE_6"; const char *FSFW_OBJECTS_START_STRING = "FSFW_OBJECTS_START"; const char *PUS_SERVICE_1_VERIFICATION_STRING = "PUS_SERVICE_1_VERIFICATION"; @@ -209,37 +215,37 @@ const char* translateObject(object_id_t object) { case 0x44420005: return TMP1075_HANDLER_2_STRING; case 0x44420016: - return RTD_IC3_STRING; + return RTD_IC_0_STRING; case 0x44420017: - return RTD_IC4_STRING; + return RTD_IC_1_STRING; case 0x44420018: - return RTD_IC5_STRING; + return RTD_IC_2_STRING; case 0x44420019: - return RTD_IC6_STRING; + return RTD_IC_3_STRING; case 0x44420020: - return RTD_IC7_STRING; + return RTD_IC_4_STRING; case 0x44420021: - return RTD_IC8_STRING; + return RTD_IC_5_STRING; case 0x44420022: - return RTD_IC9_STRING; + return RTD_IC_6_STRING; case 0x44420023: - return RTD_IC10_STRING; + return RTD_IC_7_STRING; case 0x44420024: - return RTD_IC11_STRING; + return RTD_IC_8_STRING; case 0x44420025: - return RTD_IC12_STRING; + return RTD_IC_9_STRING; case 0x44420026: - return RTD_IC13_STRING; + return RTD_IC_10_STRING; case 0x44420027: - return RTD_IC14_STRING; + return RTD_IC_11_STRING; case 0x44420028: - return RTD_IC15_STRING; + return RTD_IC_12_STRING; case 0x44420029: - return RTD_IC16_STRING; + return RTD_IC_13_STRING; case 0x44420030: - return RTD_IC17_STRING; + return RTD_IC_14_STRING; case 0x44420031: - return RTD_IC18_STRING; + return RTD_IC_15_STRING; case 0x445300A3: return SYRLINKS_HK_HANDLER_STRING; case 0x49000000: @@ -264,6 +270,18 @@ const char* translateObject(object_id_t object) { return TMTC_POLLING_TASK_STRING; case 0x50000500: return FILE_SYSTEM_HANDLER_STRING; + case 0x50000600: + return PTME_STRING; + case 0x50000700: + return PAPB_VC0_STRING; + case 0x50000701: + return PAPB_VC1_STRING; + case 0x50000702: + return PAPB_VC2_STRING; + case 0x50000703: + return PAPB_VC3_STRING; + case 0x50000800: + return CCSDS_HANDLER_STRING; case 0x51000500: return PUS_SERVICE_6_STRING; case 0x53000000: From 30cf0c7aad9315d4b1135eeb33b39c41d1e3a9ca Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 12 Oct 2021 18:34:04 +0200 Subject: [PATCH 063/465] ADIS devices working now --- .../pollingSequenceFactory.cpp | 40 +++++++++---------- tmtc | 2 +- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 887f0f5c..225fffd8 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -465,16 +465,16 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); -// thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, -// DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.3, -// DeviceHandlerIF::SEND_WRITE); -// thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, -// DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.75, -// DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.85, -// DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.3, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, + DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.75, + DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.85, + DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); @@ -512,16 +512,16 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); -// thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0, -// DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.3, -// DeviceHandlerIF::SEND_WRITE); -// thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.6, -// DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.75, -// DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.85, -// DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.3, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.6, + DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.75, + DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.85, + DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); diff --git a/tmtc b/tmtc index 423f1fbb..5976e657 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 423f1fbb2c9f93f6eb3f3ae8ecbbdbfa30002596 +Subproject commit 5976e657353661587d26b1312d5fe099b7011273 From ccb3a236023eedf0b21020ecf60bc77e77eec016 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 13 Oct 2021 13:20:03 +0200 Subject: [PATCH 064/465] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 5976e657..b2cc2354 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 5976e657353661587d26b1312d5fe099b7011273 +Subproject commit b2cc2354d410b0bc0d80c481bfd37afc580e63cf From 0237a22ae99cbceae838c6b6b30b360c3b285b0f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 13 Oct 2021 15:42:55 +0200 Subject: [PATCH 065/465] using old names again --- bsp_hosted/fsfwconfig/devices/gpioIds.h | 8 +-- bsp_q7s/core/ObjectFactory.cpp | 96 ++++++++++++------------- bsp_q7s/gpio/gpioCallbacks.cpp | 60 ++++++++-------- common/config/commonObjects.h | 32 ++++----- linux/fsfwconfig/devices/addresses.h | 6 +- linux/fsfwconfig/devices/gpioIds.h | 6 +- 6 files changed, 104 insertions(+), 104 deletions(-) diff --git a/bsp_hosted/fsfwconfig/devices/gpioIds.h b/bsp_hosted/fsfwconfig/devices/gpioIds.h index 53a53677..1ab55d08 100644 --- a/bsp_hosted/fsfwconfig/devices/gpioIds.h +++ b/bsp_hosted/fsfwconfig/devices/gpioIds.h @@ -27,10 +27,7 @@ namespace gpioIds { TEST_ID_0, TEST_ID_1, - RTD_IC_0, - RTD_IC_1, - RTD_IC_2, - RTD_IC_3, + RTD_IC_3, RTD_IC_4, RTD_IC_5, RTD_IC_6, @@ -43,6 +40,9 @@ namespace gpioIds { RTD_IC_13, RTD_IC_14, RTD_IC_15, + RTD_IC_16, + RTD_IC_17, + RTD_IC_18, SPI_MUX_BIT_1, SPI_MUX_BIT_2, diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index c6062926..66357373 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -643,128 +643,128 @@ void ObjectFactory::createRtdComponents(LinuxLibgpioIF *gpioComIF) { GpioCallback* gpioRtdIc0 = new GpioCallback("Chip select RTD IC0", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_0, gpioRtdIc0); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_3, gpioRtdIc0); GpioCallback* gpioRtdIc1 = new GpioCallback("Chip select RTD IC1", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_1, gpioRtdIc1); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_4, gpioRtdIc1); GpioCallback* gpioRtdIc2 = new GpioCallback("Chip select RTD IC2", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_2, gpioRtdIc2); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_5, gpioRtdIc2); GpioCallback* gpioRtdIc3 = new GpioCallback("Chip select RTD IC3", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_3, gpioRtdIc3); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_6, gpioRtdIc3); GpioCallback* gpioRtdIc4 = new GpioCallback("Chip select RTD IC4", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_4, gpioRtdIc4); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_7, gpioRtdIc4); GpioCallback* gpioRtdIc5 = new GpioCallback("Chip select RTD IC5", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_5, gpioRtdIc5); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_8, gpioRtdIc5); GpioCallback* gpioRtdIc6 = new GpioCallback("Chip select RTD IC6", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_6, gpioRtdIc6); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_9, gpioRtdIc6); GpioCallback* gpioRtdIc7 = new GpioCallback("Chip select RTD IC7", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_7, gpioRtdIc7); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_10, gpioRtdIc7); GpioCallback* gpioRtdIc8 = new GpioCallback("Chip select RTD IC8", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_8, gpioRtdIc8); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_11, gpioRtdIc8); GpioCallback* gpioRtdIc9 = new GpioCallback("Chip select RTD IC9", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_9, gpioRtdIc9); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_12, gpioRtdIc9); GpioCallback* gpioRtdIc10 = new GpioCallback("Chip select RTD IC10", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_10, gpioRtdIc10); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_13, gpioRtdIc10); GpioCallback* gpioRtdIc11 = new GpioCallback("Chip select RTD IC11", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_11, gpioRtdIc11); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_14, gpioRtdIc11); GpioCallback* gpioRtdIc12 = new GpioCallback("Chip select RTD IC12", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_12, gpioRtdIc12); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_15, gpioRtdIc12); GpioCallback* gpioRtdIc13 = new GpioCallback("Chip select RTD IC13", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_13, gpioRtdIc13); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_16, gpioRtdIc13); GpioCallback* gpioRtdIc14 = new GpioCallback("Chip select RTD IC14", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_14, gpioRtdIc14); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_17, gpioRtdIc14); GpioCallback* gpioRtdIc15 = new GpioCallback("Chip select RTD IC15", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_15, gpioRtdIc15); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_18, gpioRtdIc15); gpioComIF->addGpios(rtdGpioCookie); - SpiCookie* spiRtdIc0 = new SpiCookie(addresses::RTD_IC_0, gpioIds::RTD_IC_0, q7s::SPI_DEFAULT_DEV, + SpiCookie* spiRtdIc0 = new SpiCookie(addresses::RTD_IC_3, gpioIds::RTD_IC_3, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - SpiCookie* spiRtdIc1 = new SpiCookie(addresses::RTD_IC_1, gpioIds::RTD_IC_1, q7s::SPI_DEFAULT_DEV, + SpiCookie* spiRtdIc1 = new SpiCookie(addresses::RTD_IC_4, gpioIds::RTD_IC_4, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - SpiCookie* spiRtdIc2 = new SpiCookie(addresses::RTD_IC_2, gpioIds::RTD_IC_2, q7s::SPI_DEFAULT_DEV, + SpiCookie* spiRtdIc2 = new SpiCookie(addresses::RTD_IC_5, gpioIds::RTD_IC_5, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - SpiCookie* spiRtdIc3 = new SpiCookie(addresses::RTD_IC_3, gpioIds::RTD_IC_3, q7s::SPI_DEFAULT_DEV, + SpiCookie* spiRtdIc3 = new SpiCookie(addresses::RTD_IC_6, gpioIds::RTD_IC_6, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - SpiCookie* spiRtdIc4 = new SpiCookie(addresses::RTD_IC_4, gpioIds::RTD_IC_4, q7s::SPI_DEFAULT_DEV, + SpiCookie* spiRtdIc4 = new SpiCookie(addresses::RTD_IC_7, gpioIds::RTD_IC_7, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - SpiCookie* spiRtdIc5 = new SpiCookie(addresses::RTD_IC_5, gpioIds::RTD_IC_5, q7s::SPI_DEFAULT_DEV, + SpiCookie* spiRtdIc5 = new SpiCookie(addresses::RTD_IC_8, gpioIds::RTD_IC_8, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - SpiCookie* spiRtdIc6 = new SpiCookie(addresses::RTD_IC_6, gpioIds::RTD_IC_6, q7s::SPI_DEFAULT_DEV, + SpiCookie* spiRtdIc6 = new SpiCookie(addresses::RTD_IC_9, gpioIds::RTD_IC_9, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - SpiCookie* spiRtdIc7 = new SpiCookie(addresses::RTD_IC_7, gpioIds::RTD_IC_7, + SpiCookie* spiRtdIc7 = new SpiCookie(addresses::RTD_IC_10, gpioIds::RTD_IC_10, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - SpiCookie* spiRtdIc8 = new SpiCookie(addresses::RTD_IC_8, gpioIds::RTD_IC_8, + SpiCookie* spiRtdIc8 = new SpiCookie(addresses::RTD_IC_11, gpioIds::RTD_IC_11, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - SpiCookie* spiRtdIc9 = new SpiCookie(addresses::RTD_IC_9, gpioIds::RTD_IC_9, + SpiCookie* spiRtdIc9 = new SpiCookie(addresses::RTD_IC_12, gpioIds::RTD_IC_12, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - SpiCookie* spiRtdIc10 = new SpiCookie(addresses::RTD_IC_10, gpioIds::RTD_IC_10, + SpiCookie* spiRtdIc10 = new SpiCookie(addresses::RTD_IC_13, gpioIds::RTD_IC_13, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - SpiCookie* spiRtdIc11 = new SpiCookie(addresses::RTD_IC_11, gpioIds::RTD_IC_11, + SpiCookie* spiRtdIc11 = new SpiCookie(addresses::RTD_IC_14, gpioIds::RTD_IC_14, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - SpiCookie* spiRtdIc12 = new SpiCookie(addresses::RTD_IC_12, gpioIds::RTD_IC_12, + SpiCookie* spiRtdIc12 = new SpiCookie(addresses::RTD_IC_15, gpioIds::RTD_IC_15, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - SpiCookie* spiRtdIc13 = new SpiCookie(addresses::RTD_IC_13, gpioIds::RTD_IC_13, + SpiCookie* spiRtdIc13 = new SpiCookie(addresses::RTD_IC_16, gpioIds::RTD_IC_16, std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - SpiCookie* spiRtdIc14 = new SpiCookie(addresses::RTD_IC_14, gpioIds::RTD_IC_14, + SpiCookie* spiRtdIc14 = new SpiCookie(addresses::RTD_IC_17, gpioIds::RTD_IC_17, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - SpiCookie* spiRtdIc15 = new SpiCookie(addresses::RTD_IC_15, gpioIds::RTD_IC_15, + SpiCookie* spiRtdIc15 = new SpiCookie(addresses::RTD_IC_18, gpioIds::RTD_IC_18, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - Max31865PT1000Handler* rtdIc0 = new Max31865PT1000Handler(objects::RTD_IC_0, objects::SPI_COM_IF, + Max31865PT1000Handler* rtdIc0 = new Max31865PT1000Handler(objects::RTD_IC_6, objects::SPI_COM_IF, spiRtdIc0); - Max31865PT1000Handler* rtdIc1 = new Max31865PT1000Handler(objects::RTD_IC_1, objects::SPI_COM_IF, + Max31865PT1000Handler* rtdIc1 = new Max31865PT1000Handler(objects::RTD_IC_4, objects::SPI_COM_IF, spiRtdIc1); - Max31865PT1000Handler* rtdIc2 = new Max31865PT1000Handler(objects::RTD_IC_2, objects::SPI_COM_IF, + Max31865PT1000Handler* rtdIc2 = new Max31865PT1000Handler(objects::RTD_IC_5, objects::SPI_COM_IF, spiRtdIc2); - Max31865PT1000Handler* rtdIc3 = new Max31865PT1000Handler(objects::RTD_IC_3, objects::SPI_COM_IF, + Max31865PT1000Handler* rtdIc3 = new Max31865PT1000Handler(objects::RTD_IC_6, objects::SPI_COM_IF, spiRtdIc3); - Max31865PT1000Handler* rtdIc4 = new Max31865PT1000Handler(objects::RTD_IC_4, objects::SPI_COM_IF, + Max31865PT1000Handler* rtdIc4 = new Max31865PT1000Handler(objects::RTD_IC_7, objects::SPI_COM_IF, spiRtdIc4); - Max31865PT1000Handler* rtdIc5 = new Max31865PT1000Handler(objects::RTD_IC_5, objects::SPI_COM_IF, + Max31865PT1000Handler* rtdIc5 = new Max31865PT1000Handler(objects::RTD_IC_8, objects::SPI_COM_IF, spiRtdIc5); - Max31865PT1000Handler* rtdIc6 = new Max31865PT1000Handler(objects::RTD_IC_6, objects::SPI_COM_IF, + Max31865PT1000Handler* rtdIc6 = new Max31865PT1000Handler(objects::RTD_IC_9, objects::SPI_COM_IF, spiRtdIc6); - Max31865PT1000Handler* rtdIc7 = new Max31865PT1000Handler(objects::RTD_IC_7, + Max31865PT1000Handler* rtdIc7 = new Max31865PT1000Handler(objects::RTD_IC_10, objects::SPI_COM_IF, spiRtdIc7); - Max31865PT1000Handler* rtdIc8 = new Max31865PT1000Handler(objects::RTD_IC_8, + Max31865PT1000Handler* rtdIc8 = new Max31865PT1000Handler(objects::RTD_IC_11, objects::SPI_COM_IF, spiRtdIc8); - Max31865PT1000Handler* rtdIc9 = new Max31865PT1000Handler(objects::RTD_IC_9, + Max31865PT1000Handler* rtdIc9 = new Max31865PT1000Handler(objects::RTD_IC_12, objects::SPI_COM_IF, spiRtdIc9); - Max31865PT1000Handler* rtdIc10 = new Max31865PT1000Handler(objects::RTD_IC_10, + Max31865PT1000Handler* rtdIc10 = new Max31865PT1000Handler(objects::RTD_IC_13, objects::SPI_COM_IF, spiRtdIc10); - Max31865PT1000Handler* rtdIc11 = new Max31865PT1000Handler(objects::RTD_IC_11, + Max31865PT1000Handler* rtdIc11 = new Max31865PT1000Handler(objects::RTD_IC_14, objects::SPI_COM_IF, spiRtdIc11); - Max31865PT1000Handler* rtdIc12 = new Max31865PT1000Handler(objects::RTD_IC_12, + Max31865PT1000Handler* rtdIc12 = new Max31865PT1000Handler(objects::RTD_IC_15, objects::SPI_COM_IF, spiRtdIc12); - Max31865PT1000Handler* rtdIc13 = new Max31865PT1000Handler(objects::RTD_IC_13, + Max31865PT1000Handler* rtdIc13 = new Max31865PT1000Handler(objects::RTD_IC_16, objects::SPI_COM_IF, spiRtdIc13); - Max31865PT1000Handler* rtdIc14 = new Max31865PT1000Handler(objects::RTD_IC_14, + Max31865PT1000Handler* rtdIc14 = new Max31865PT1000Handler(objects::RTD_IC_17, objects::SPI_COM_IF, spiRtdIc14); - Max31865PT1000Handler* rtdIc15 = new Max31865PT1000Handler(objects::RTD_IC_15, + Max31865PT1000Handler* rtdIc15 = new Max31865PT1000Handler(objects::RTD_IC_18, objects::SPI_COM_IF, spiRtdIc15); rtdIc0->setStartUpImmediately(); diff --git a/bsp_q7s/gpio/gpioCallbacks.cpp b/bsp_q7s/gpio/gpioCallbacks.cpp index 27ae18d0..b1eefac7 100644 --- a/bsp_q7s/gpio/gpioCallbacks.cpp +++ b/bsp_q7s/gpio/gpioCallbacks.cpp @@ -72,82 +72,82 @@ void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, gpio::Lev } else if (value == gpio::LOW) { switch (gpioId) { - case(gpioIds::RTD_IC_0): { - enableDecoderTcsIc1(); - selectY7(); - break; - } - case(gpioIds::RTD_IC_1): { - enableDecoderTcsIc1(); - selectY6(); - break; - } - case(gpioIds::RTD_IC_2): { - enableDecoderTcsIc1(); - selectY5(); - break; - } case(gpioIds::RTD_IC_3): { enableDecoderTcsIc1(); - selectY4(); + selectY7(); break; } case(gpioIds::RTD_IC_4): { enableDecoderTcsIc1(); - selectY3(); + selectY6(); break; } case(gpioIds::RTD_IC_5): { enableDecoderTcsIc1(); - selectY2(); + selectY5(); break; } case(gpioIds::RTD_IC_6): { enableDecoderTcsIc1(); - selectY1(); + selectY4(); break; } case(gpioIds::RTD_IC_7): { enableDecoderTcsIc1(); - selectY0(); + selectY3(); break; } case(gpioIds::RTD_IC_8): { - enableDecoderTcsIc2(); - selectY7(); + enableDecoderTcsIc1(); + selectY2(); break; } case(gpioIds::RTD_IC_9): { - enableDecoderTcsIc2(); - selectY6(); + enableDecoderTcsIc1(); + selectY1(); break; } case(gpioIds::RTD_IC_10): { - enableDecoderTcsIc2(); - selectY5(); + enableDecoderTcsIc1(); + selectY0(); break; } case(gpioIds::RTD_IC_11): { enableDecoderTcsIc2(); - selectY4(); + selectY7(); break; } case(gpioIds::RTD_IC_12): { enableDecoderTcsIc2(); - selectY3(); + selectY6(); break; } case(gpioIds::RTD_IC_13): { enableDecoderTcsIc2(); - selectY2(); + selectY5(); break; } case(gpioIds::RTD_IC_14): { enableDecoderTcsIc2(); - selectY1(); + selectY4(); break; } case(gpioIds::RTD_IC_15): { + enableDecoderTcsIc2(); + selectY3(); + break; + } + case(gpioIds::RTD_IC_16): { + enableDecoderTcsIc2(); + selectY2(); + break; + } + case(gpioIds::RTD_IC_17): { + enableDecoderTcsIc2(); + selectY1(); + break; + } + case(gpioIds::RTD_IC_18): { enableDecoderTcsIc2(); selectY0(); break; diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index 9e4418d2..dc18995e 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -47,22 +47,22 @@ enum commonObjects: uint32_t { * Not yet specified which pt1000 will measure which device/location in the satellite. * Therefore object ids are named according to the IC naming of the RTDs in the schematic. */ - RTD_IC_0 = 0x44420016, - RTD_IC_1 = 0x44420017, - RTD_IC_2 = 0x44420018, - RTD_IC_3 = 0x44420019, - RTD_IC_4 = 0x44420020, - RTD_IC_5 = 0x44420021, - RTD_IC_6 = 0x44420022, - RTD_IC_7 = 0x44420023, - RTD_IC_8 = 0x44420024, - RTD_IC_9 = 0x44420025, - RTD_IC_10 = 0x44420026, - RTD_IC_11 = 0x44420027, - RTD_IC_12 = 0x44420028, - RTD_IC_13 = 0x44420029, - RTD_IC_14 = 0x44420030, - RTD_IC_15 = 0x44420031, + RTD_IC_3 = 0x44420016, + RTD_IC_4 = 0x44420017, + RTD_IC_5 = 0x44420018, + RTD_IC_6 = 0x44420019, + RTD_IC_7 = 0x44420020, + RTD_IC_8 = 0x44420021, + RTD_IC_9 = 0x44420022, + RTD_IC_10 = 0x44420023, + RTD_IC_11 = 0x44420024, + RTD_IC_12 = 0x44420025, + RTD_IC_13 = 0x44420026, + RTD_IC_14 = 0x44420027, + RTD_IC_15 = 0x44420028, + RTD_IC_16 = 0x44420029, + RTD_IC_17 = 0x44420030, + RTD_IC_18 = 0x44420031, SUS_1 = 0x44120032, SUS_2 = 0x44120033, diff --git a/linux/fsfwconfig/devices/addresses.h b/linux/fsfwconfig/devices/addresses.h index 945c2eb7..94f22c54 100644 --- a/linux/fsfwconfig/devices/addresses.h +++ b/linux/fsfwconfig/devices/addresses.h @@ -49,9 +49,6 @@ namespace addresses { }; enum spiAddresses: address_t { - RTD_IC_0, - RTD_IC_1, - RTD_IC_2, RTD_IC_3, RTD_IC_4, RTD_IC_5, @@ -65,6 +62,9 @@ namespace addresses { RTD_IC_13, RTD_IC_14, RTD_IC_15, + RTD_IC_16, + RTD_IC_17, + RTD_IC_18, RW1, RW2, RW3, diff --git a/linux/fsfwconfig/devices/gpioIds.h b/linux/fsfwconfig/devices/gpioIds.h index 62913d5a..ebe8a3eb 100644 --- a/linux/fsfwconfig/devices/gpioIds.h +++ b/linux/fsfwconfig/devices/gpioIds.h @@ -34,9 +34,6 @@ enum gpioId_t { TEST_ID_0, TEST_ID_1, - RTD_IC_0, - RTD_IC_1, - RTD_IC_2, RTD_IC_3, RTD_IC_4, RTD_IC_5, @@ -50,6 +47,9 @@ enum gpioId_t { RTD_IC_13, RTD_IC_14, RTD_IC_15, + RTD_IC_16, + RTD_IC_17, + RTD_IC_18, CS_SUS_1, CS_SUS_2, From c56fc09da70c1483ea7d609206348a6d8a2964f1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 13 Oct 2021 15:52:22 +0200 Subject: [PATCH 066/465] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 0dedd8f2..eba2f87b 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 0dedd8f2a18b619f4b5003e701e7bb40c0ac4d61 +Subproject commit eba2f87b36429fc814f9d4768c68fd2827f4c410 From dac30684379935edef64b8638d01e57eb0a43a19 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 13 Oct 2021 15:54:30 +0200 Subject: [PATCH 067/465] updated object translations --- generators/bsp_q7s_objects.csv | 32 +++++++------- generators/objects/translateObjects.cpp | 44 +++++++++---------- linux/fsfwconfig/objects/translateObjects.cpp | 44 +++++++++---------- 3 files changed, 60 insertions(+), 60 deletions(-) diff --git a/generators/bsp_q7s_objects.csv b/generators/bsp_q7s_objects.csv index 24035373..3d8a4d40 100644 --- a/generators/bsp_q7s_objects.csv +++ b/generators/bsp_q7s_objects.csv @@ -45,22 +45,22 @@ 0x444100A4;HEATER_HANDLER 0x44420004;TMP1075_HANDLER_1 0x44420005;TMP1075_HANDLER_2 -0x44420016;RTD_IC_0 -0x44420017;RTD_IC_1 -0x44420018;RTD_IC_2 -0x44420019;RTD_IC_3 -0x44420020;RTD_IC_4 -0x44420021;RTD_IC_5 -0x44420022;RTD_IC_6 -0x44420023;RTD_IC_7 -0x44420024;RTD_IC_8 -0x44420025;RTD_IC_9 -0x44420026;RTD_IC_10 -0x44420027;RTD_IC_11 -0x44420028;RTD_IC_12 -0x44420029;RTD_IC_13 -0x44420030;RTD_IC_14 -0x44420031;RTD_IC_15 +0x44420016;RTD_IC_3 +0x44420017;RTD_IC_4 +0x44420018;RTD_IC_5 +0x44420019;RTD_IC_6 +0x44420020;RTD_IC_7 +0x44420021;RTD_IC_8 +0x44420022;RTD_IC_9 +0x44420023;RTD_IC_10 +0x44420024;RTD_IC_11 +0x44420025;RTD_IC_12 +0x44420026;RTD_IC_13 +0x44420027;RTD_IC_14 +0x44420028;RTD_IC_15 +0x44420029;RTD_IC_16 +0x44420030;RTD_IC_17 +0x44420031;RTD_IC_18 0x445300A3;SYRLINKS_HK_HANDLER 0x49000000;ARDUINO_COM_IF 0x49010005;GPIO_IF diff --git a/generators/objects/translateObjects.cpp b/generators/objects/translateObjects.cpp index 4b256595..15f82c2c 100644 --- a/generators/objects/translateObjects.cpp +++ b/generators/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 111 translations. - * Generated on: 2021-10-12 18:02:43 + * Generated on: 2021-10-13 15:54:21 */ #include "translateObjects.h" @@ -53,9 +53,6 @@ const char *SOLAR_ARRAY_DEPL_HANDLER_STRING = "SOLAR_ARRAY_DEPL_HANDLER"; const char *HEATER_HANDLER_STRING = "HEATER_HANDLER"; const char *TMP1075_HANDLER_1_STRING = "TMP1075_HANDLER_1"; const char *TMP1075_HANDLER_2_STRING = "TMP1075_HANDLER_2"; -const char *RTD_IC_0_STRING = "RTD_IC_0"; -const char *RTD_IC_1_STRING = "RTD_IC_1"; -const char *RTD_IC_2_STRING = "RTD_IC_2"; const char *RTD_IC_3_STRING = "RTD_IC_3"; const char *RTD_IC_4_STRING = "RTD_IC_4"; const char *RTD_IC_5_STRING = "RTD_IC_5"; @@ -69,6 +66,9 @@ const char *RTD_IC_12_STRING = "RTD_IC_12"; const char *RTD_IC_13_STRING = "RTD_IC_13"; const char *RTD_IC_14_STRING = "RTD_IC_14"; const char *RTD_IC_15_STRING = "RTD_IC_15"; +const char *RTD_IC_16_STRING = "RTD_IC_16"; +const char *RTD_IC_17_STRING = "RTD_IC_17"; +const char *RTD_IC_18_STRING = "RTD_IC_18"; const char *SYRLINKS_HK_HANDLER_STRING = "SYRLINKS_HK_HANDLER"; const char *ARDUINO_COM_IF_STRING = "ARDUINO_COM_IF"; const char *GPIO_IF_STRING = "GPIO_IF"; @@ -215,37 +215,37 @@ const char* translateObject(object_id_t object) { case 0x44420005: return TMP1075_HANDLER_2_STRING; case 0x44420016: - return RTD_IC_0_STRING; - case 0x44420017: - return RTD_IC_1_STRING; - case 0x44420018: - return RTD_IC_2_STRING; - case 0x44420019: return RTD_IC_3_STRING; - case 0x44420020: + case 0x44420017: return RTD_IC_4_STRING; - case 0x44420021: + case 0x44420018: return RTD_IC_5_STRING; - case 0x44420022: + case 0x44420019: return RTD_IC_6_STRING; - case 0x44420023: + case 0x44420020: return RTD_IC_7_STRING; - case 0x44420024: + case 0x44420021: return RTD_IC_8_STRING; - case 0x44420025: + case 0x44420022: return RTD_IC_9_STRING; - case 0x44420026: + case 0x44420023: return RTD_IC_10_STRING; - case 0x44420027: + case 0x44420024: return RTD_IC_11_STRING; - case 0x44420028: + case 0x44420025: return RTD_IC_12_STRING; - case 0x44420029: + case 0x44420026: return RTD_IC_13_STRING; - case 0x44420030: + case 0x44420027: return RTD_IC_14_STRING; - case 0x44420031: + case 0x44420028: return RTD_IC_15_STRING; + case 0x44420029: + return RTD_IC_16_STRING; + case 0x44420030: + return RTD_IC_17_STRING; + case 0x44420031: + return RTD_IC_18_STRING; case 0x445300A3: return SYRLINKS_HK_HANDLER_STRING; case 0x49000000: diff --git a/linux/fsfwconfig/objects/translateObjects.cpp b/linux/fsfwconfig/objects/translateObjects.cpp index 4b256595..15f82c2c 100644 --- a/linux/fsfwconfig/objects/translateObjects.cpp +++ b/linux/fsfwconfig/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 111 translations. - * Generated on: 2021-10-12 18:02:43 + * Generated on: 2021-10-13 15:54:21 */ #include "translateObjects.h" @@ -53,9 +53,6 @@ const char *SOLAR_ARRAY_DEPL_HANDLER_STRING = "SOLAR_ARRAY_DEPL_HANDLER"; const char *HEATER_HANDLER_STRING = "HEATER_HANDLER"; const char *TMP1075_HANDLER_1_STRING = "TMP1075_HANDLER_1"; const char *TMP1075_HANDLER_2_STRING = "TMP1075_HANDLER_2"; -const char *RTD_IC_0_STRING = "RTD_IC_0"; -const char *RTD_IC_1_STRING = "RTD_IC_1"; -const char *RTD_IC_2_STRING = "RTD_IC_2"; const char *RTD_IC_3_STRING = "RTD_IC_3"; const char *RTD_IC_4_STRING = "RTD_IC_4"; const char *RTD_IC_5_STRING = "RTD_IC_5"; @@ -69,6 +66,9 @@ const char *RTD_IC_12_STRING = "RTD_IC_12"; const char *RTD_IC_13_STRING = "RTD_IC_13"; const char *RTD_IC_14_STRING = "RTD_IC_14"; const char *RTD_IC_15_STRING = "RTD_IC_15"; +const char *RTD_IC_16_STRING = "RTD_IC_16"; +const char *RTD_IC_17_STRING = "RTD_IC_17"; +const char *RTD_IC_18_STRING = "RTD_IC_18"; const char *SYRLINKS_HK_HANDLER_STRING = "SYRLINKS_HK_HANDLER"; const char *ARDUINO_COM_IF_STRING = "ARDUINO_COM_IF"; const char *GPIO_IF_STRING = "GPIO_IF"; @@ -215,37 +215,37 @@ const char* translateObject(object_id_t object) { case 0x44420005: return TMP1075_HANDLER_2_STRING; case 0x44420016: - return RTD_IC_0_STRING; - case 0x44420017: - return RTD_IC_1_STRING; - case 0x44420018: - return RTD_IC_2_STRING; - case 0x44420019: return RTD_IC_3_STRING; - case 0x44420020: + case 0x44420017: return RTD_IC_4_STRING; - case 0x44420021: + case 0x44420018: return RTD_IC_5_STRING; - case 0x44420022: + case 0x44420019: return RTD_IC_6_STRING; - case 0x44420023: + case 0x44420020: return RTD_IC_7_STRING; - case 0x44420024: + case 0x44420021: return RTD_IC_8_STRING; - case 0x44420025: + case 0x44420022: return RTD_IC_9_STRING; - case 0x44420026: + case 0x44420023: return RTD_IC_10_STRING; - case 0x44420027: + case 0x44420024: return RTD_IC_11_STRING; - case 0x44420028: + case 0x44420025: return RTD_IC_12_STRING; - case 0x44420029: + case 0x44420026: return RTD_IC_13_STRING; - case 0x44420030: + case 0x44420027: return RTD_IC_14_STRING; - case 0x44420031: + case 0x44420028: return RTD_IC_15_STRING; + case 0x44420029: + return RTD_IC_16_STRING; + case 0x44420030: + return RTD_IC_17_STRING; + case 0x44420031: + return RTD_IC_18_STRING; case 0x445300A3: return SYRLINKS_HK_HANDLER_STRING; case 0x49000000: From f8d5546a03bd02c37fa31be543a5484403fd9143 Mon Sep 17 00:00:00 2001 From: Markus Koller Date: Thu, 14 Oct 2021 15:50:50 +0200 Subject: [PATCH 068/465] rw spi callback removed wrong continue --- bsp_q7s/callbacks/rwSpiCallback.cpp | 1 - bsp_q7s/core/ObjectFactory.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/bsp_q7s/callbacks/rwSpiCallback.cpp b/bsp_q7s/callbacks/rwSpiCallback.cpp index 73516fb4..ca214f77 100644 --- a/bsp_q7s/callbacks/rwSpiCallback.cpp +++ b/bsp_q7s/callbacks/rwSpiCallback.cpp @@ -188,7 +188,6 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sen else { *(rxBuf + decodedFrameLen) = byteRead; decodedFrameLen++; - continue; } /** diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 66357373..a86f072b 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -856,7 +856,6 @@ void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF) { rwHandler1->setStartUpImmediately(); #endif rw1SpiCookie->setCallbackArgs(rwHandler1); - rwHandler1->setStartUpImmediately(); auto rwHandler2 = new RwHandler(objects::RW2, objects::SPI_COM_IF, rw2SpiCookie, gpioComIF, gpioIds::EN_RW2); From 9ddea586ead7c498cc8faf1e5826f9c60c70b73f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Oct 2021 18:15:39 +0200 Subject: [PATCH 069/465] updated build scripts --- Justfile | 9 +++++++++ cmake/scripts/Host/make-debug-cfg.sh | 2 +- cmake/scripts/Host/make-release-cfg.sh | 2 +- cmake/scripts/Host/ninja-debug-cfg.sh | 2 +- cmake/scripts/Linux/make-debug-cfg.sh | 2 +- cmake/scripts/Linux/ninja-debug-cfg.sh | 2 +- cmake/scripts/Q7S/make-debug-cfg.sh | 4 +--- cmake/scripts/Q7S/make-release-cfg.sh | 4 +--- cmake/scripts/Q7S/ninja-debug-cfg.sh | 2 +- cmake/scripts/Q7S/ninja-release-cfg.sh | 2 +- cmake/scripts/RPi/make-debug-cfg.sh | 4 +--- cmake/scripts/RPi/ninja-debug-cfg.sh | 2 +- cmake/scripts/cmake-build-cfg.py | 14 ++++++++++++-- common/config/commonConfig.cpp | 2 +- fsfw | 2 +- mission/core/GenericFactory.cpp | 2 +- tmtc | 2 +- 17 files changed, 36 insertions(+), 23 deletions(-) create mode 100644 Justfile diff --git a/Justfile b/Justfile new file mode 100644 index 00000000..f9d9504b --- /dev/null +++ b/Justfile @@ -0,0 +1,9 @@ +python_script := './cmake/scripts/cmake-build-cfg.py' + +default: q7s-debug-make + +q7s-debug-make: + {{python_script}} -o linux -g make -b debug -t "arm/q7s" -l build-Debug-Q7S + +q7s-debug-ninja: + {{python_script}} -o linux -g ninja -b debug -t "arm/q7s" -l build-Debug-Q7S diff --git a/cmake/scripts/Host/make-debug-cfg.sh b/cmake/scripts/Host/make-debug-cfg.sh index 3bda2da2..de0487ea 100755 --- a/cmake/scripts/Host/make-debug-cfg.sh +++ b/cmake/scripts/Host/make-debug-cfg.sh @@ -15,7 +15,7 @@ if [ "${counter}" -ge 5 ];then exit 1 fi -build_generator="Unix Makefiles" +build_generator="make" os_fsfw="host" builddir="build-Debug-Host" if [ "${OS}" = "Windows_NT" ]; then diff --git a/cmake/scripts/Host/make-release-cfg.sh b/cmake/scripts/Host/make-release-cfg.sh index eb0a9f57..5114f490 100755 --- a/cmake/scripts/Host/make-release-cfg.sh +++ b/cmake/scripts/Host/make-release-cfg.sh @@ -15,7 +15,7 @@ if [ "${counter}" -ge 5 ];then exit 1 fi -build_generator="Unix Makefiles" +build_generator="make" os_fsfw="host" builddir="build-Release-Host" if [ "${OS}" = "Windows_NT" ]; then diff --git a/cmake/scripts/Host/ninja-debug-cfg.sh b/cmake/scripts/Host/ninja-debug-cfg.sh index d1627174..80a5687f 100755 --- a/cmake/scripts/Host/ninja-debug-cfg.sh +++ b/cmake/scripts/Host/ninja-debug-cfg.sh @@ -15,7 +15,7 @@ if [ "${counter}" -ge 5 ];then exit 1 fi -build_generator="Ninja" +build_generator="ninja" os_fsfw="host" builddir="build-Debug-Host" if [ "${OS}" = "Windows_NT" ]; then diff --git a/cmake/scripts/Linux/make-debug-cfg.sh b/cmake/scripts/Linux/make-debug-cfg.sh index e2130416..2207a2e8 100755 --- a/cmake/scripts/Linux/make-debug-cfg.sh +++ b/cmake/scripts/Linux/make-debug-cfg.sh @@ -15,7 +15,7 @@ if [ "${counter}" -ge 5 ];then exit 1 fi -build_generator="Unix Makefiles" +build_generator="make" os_fsfw="linux" builddir="build-Debug-Host" if [ "${OS}" = "Windows_NT" ]; then diff --git a/cmake/scripts/Linux/ninja-debug-cfg.sh b/cmake/scripts/Linux/ninja-debug-cfg.sh index 905612e0..23ebc25d 100755 --- a/cmake/scripts/Linux/ninja-debug-cfg.sh +++ b/cmake/scripts/Linux/ninja-debug-cfg.sh @@ -15,7 +15,7 @@ if [ "${counter}" -ge 5 ];then exit 1 fi -build_generator="Ninja" +build_generator="ninja" os_fsfw="linux" builddir="build-Debug-Host" if [ "${OS}" = "Windows_NT" ]; then diff --git a/cmake/scripts/Q7S/make-debug-cfg.sh b/cmake/scripts/Q7S/make-debug-cfg.sh index c0807320..f3cfd81c 100755 --- a/cmake/scripts/Q7S/make-debug-cfg.sh +++ b/cmake/scripts/Q7S/make-debug-cfg.sh @@ -18,13 +18,11 @@ fi os_fsfw="linux" tgt_bsp="arm/q7s" build_dir="build-Debug-Q7S" -build_generator="" +build_generator="make" if [ "${OS}" = "Windows_NT" ]; then - build_generator="MinGW Makefiles" python="py" # Could be other OS but this works for now. else - build_generator="Unix Makefiles" python="python3" fi diff --git a/cmake/scripts/Q7S/make-release-cfg.sh b/cmake/scripts/Q7S/make-release-cfg.sh index c421f336..d71dcc83 100755 --- a/cmake/scripts/Q7S/make-release-cfg.sh +++ b/cmake/scripts/Q7S/make-release-cfg.sh @@ -18,13 +18,11 @@ fi os_fsfw="linux" tgt_bsp="arm/q7s" build_dir="build-Debug-Q7S" -build_generator="" +build_generator="make" if [ "${OS}" = "Windows_NT" ]; then - build_generator="MinGW Makefiles" python="py" # Could be other OS but this works for now. else - build_generator="Unix Makefiles" python="python3" fi diff --git a/cmake/scripts/Q7S/ninja-debug-cfg.sh b/cmake/scripts/Q7S/ninja-debug-cfg.sh index 9a6b35c8..bd9ebb4e 100755 --- a/cmake/scripts/Q7S/ninja-debug-cfg.sh +++ b/cmake/scripts/Q7S/ninja-debug-cfg.sh @@ -18,7 +18,7 @@ fi os_fsfw="linux" tgt_bsp="arm/q7s" build_dir="build-Debug-Q7S" -build_generator="Ninja" +build_generator="ninja" if [ "${OS}" = "Windows_NT" ]; then python="py" # Could be other OS but this works for now. diff --git a/cmake/scripts/Q7S/ninja-release-cfg.sh b/cmake/scripts/Q7S/ninja-release-cfg.sh index a9c82d54..c9972c89 100755 --- a/cmake/scripts/Q7S/ninja-release-cfg.sh +++ b/cmake/scripts/Q7S/ninja-release-cfg.sh @@ -18,7 +18,7 @@ fi os_fsfw="linux" tgt_bsp="arm/q7s" build_dir="build-Release-Q7S" -build_generator="Ninja" +build_generator="ninja" if [ "${OS}" = "Windows_NT" ]; then python="py" # Could be other OS but this works for now. diff --git a/cmake/scripts/RPi/make-debug-cfg.sh b/cmake/scripts/RPi/make-debug-cfg.sh index 3b95ceee..f4d006c3 100755 --- a/cmake/scripts/RPi/make-debug-cfg.sh +++ b/cmake/scripts/RPi/make-debug-cfg.sh @@ -18,14 +18,12 @@ fi os_fsfw="linux" tgt_bsp="arm/raspberrypi" -build_generator="" +build_generator="make" build_dir="build-Debug-RPi" if [ "${OS}" = "Windows_NT" ]; then - build_generator="MinGW Makefiles" python="py" # Could be other OS but this works for now. else - build_generator="Unix Makefiles" python="python3" fi diff --git a/cmake/scripts/RPi/ninja-debug-cfg.sh b/cmake/scripts/RPi/ninja-debug-cfg.sh index 4cfb9854..13096fd6 100755 --- a/cmake/scripts/RPi/ninja-debug-cfg.sh +++ b/cmake/scripts/RPi/ninja-debug-cfg.sh @@ -17,7 +17,7 @@ fi os_fsfw="linux" tgt_bsp="arm/raspberrypi" -build_generator="Ninja" +build_generator="ninja" build_dir="build-Debug-RPi" if [ "${OS}" = "Windows_NT" ]; then python="py" diff --git a/cmake/scripts/cmake-build-cfg.py b/cmake/scripts/cmake-build-cfg.py index e3259fd4..5d1b1048 100755 --- a/cmake/scripts/cmake-build-cfg.py +++ b/cmake/scripts/cmake-build-cfg.py @@ -29,7 +29,9 @@ def main(): "Information)", default="debug" ) parser.add_argument("-l", "--builddir", type=str, help="Specify build directory.") - parser.add_argument("-g", "--generator", type=str, help="CMake Generator") + parser.add_argument( + "-g", "--generator", type=str, help="CMake Generator", choices=['make', 'ninja'] + ) parser.add_argument( "-d", "--defines", help="Additional custom defines passed to CMake (supply without -D prefix!)", @@ -56,7 +58,15 @@ def main(): if args.generator is None: generator_cmake_arg = "" else: - generator_cmake_arg = f"-G \"{args.generator}\"" + if args.generator == 'make': + if os.name == 'nt': + generator_cmake_arg = '-G "MinGW Makefiles"' + else: + generator_cmake_arg = '-G "Unix Makefiles"' + elif args.generator == 'ninja': + generator_cmake_arg = '-G Ninja' + else: + generator_cmake_arg = args.generator if args.buildtype == "debug": cmake_build_type = "Debug" diff --git a/common/config/commonConfig.cpp b/common/config/commonConfig.cpp index 1c9ece8b..97690e09 100644 --- a/common/config/commonConfig.cpp +++ b/common/config/commonConfig.cpp @@ -2,4 +2,4 @@ #include "tmtc/apid.h" #include "fsfw/tmtcpacket/SpacePacket.h" -const uint16_t common::TC_PACKET_ID = spacepacket::getTcSpacePacketIdFromApid(apid::EIVE_OBSW); +constexpr uint16_t common::PUS_PACKET_ID = spacepacket::getTcSpacePacketIdFromApid(apid::EIVE_OBSW); diff --git a/fsfw b/fsfw index eba2f87b..e29606a2 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit eba2f87b36429fc814f9d4768c68fd2827f4c410 +Subproject commit e29606a2d07ff2fcad77e99493ec3765816e646b diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index a0939f1c..58485b71 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -110,7 +110,7 @@ void ObjectFactory::produceGenericObjects() { tmtcBridge->setMaxNumberOfPacketsStored(50); auto tcpServer = new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); // TCP is stream based. Use packet ID as start marker when parsing for space packets - tcpServer->setSpacePacketParsingOptions({common::TC_PACKET_ID}); + tcpServer->setSpacePacketParsingOptions({common::PUS_PACKET_ID}); sif::info << "Created TCP server for TMTC commanding with listener port " << tcpServer->getTcpPort() << std::endl; #endif /* OBSW_USE_TMTC_TCP_BRIDGE == 0 */ diff --git a/tmtc b/tmtc index b2cc2354..edcaf2e9 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit b2cc2354d410b0bc0d80c481bfd37afc580e63cf +Subproject commit edcaf2e9c323cbda2ef331e93cc04985f44c6855 From 46dcc18ddbc67e1b2dfc84988066f16a500cd4ed Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Oct 2021 18:23:26 +0200 Subject: [PATCH 070/465] updated constants --- common/config/commonConfig.cpp | 2 +- common/config/commonConfig.h.in | 2 +- fsfw | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common/config/commonConfig.cpp b/common/config/commonConfig.cpp index 97690e09..31674512 100644 --- a/common/config/commonConfig.cpp +++ b/common/config/commonConfig.cpp @@ -2,4 +2,4 @@ #include "tmtc/apid.h" #include "fsfw/tmtcpacket/SpacePacket.h" -constexpr uint16_t common::PUS_PACKET_ID = spacepacket::getTcSpacePacketIdFromApid(apid::EIVE_OBSW); +const uint16_t common::PUS_PACKET_ID = spacepacket::getTcSpacePacketIdFromApid(apid::EIVE_OBSW); diff --git a/common/config/commonConfig.h.in b/common/config/commonConfig.h.in index 6dad37d5..c18d4bff 100644 --- a/common/config/commonConfig.h.in +++ b/common/config/commonConfig.h.in @@ -15,7 +15,7 @@ #define OBSW_USE_TCP_BRIDGE 1 namespace common { -extern const uint16_t TC_PACKET_ID; +extern const uint16_t PUS_PACKET_ID; static constexpr uint32_t CCSDS_HANDLER_QUEUE_SIZE = 50; static constexpr uint8_t NUMBER_OF_VIRTUAL_CHANNELS = 4; diff --git a/fsfw b/fsfw index e29606a2..15687f6f 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit e29606a2d07ff2fcad77e99493ec3765816e646b +Subproject commit 15687f6f6e0ca284dbe502f082ef3ab2f0b27b71 From 017e02e5138f84f092e32b7c48accd1928411599 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Fri, 29 Oct 2021 19:11:46 +0200 Subject: [PATCH 071/465] changes applied during flatsat debugging --- bsp_q7s/callbacks/rwSpiCallback.cpp | 22 ++++++------ .../pollingSequenceFactory.cpp | 34 +++++++++---------- mission/devices/Max31865PT1000Handler.cpp | 27 +++++++++------ mission/devices/Max31865PT1000Handler.h | 2 +- 4 files changed, 46 insertions(+), 39 deletions(-) diff --git a/bsp_q7s/callbacks/rwSpiCallback.cpp b/bsp_q7s/callbacks/rwSpiCallback.cpp index 73516fb4..620f63f7 100644 --- a/bsp_q7s/callbacks/rwSpiCallback.cpp +++ b/bsp_q7s/callbacks/rwSpiCallback.cpp @@ -23,6 +23,16 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sen uint8_t writeBuffer[2]; uint8_t writeSize = 0; + gpioId_t gpioId = cookie->getChipSelectPin(); + GpioIF* gpioIF = comIf->getGpioInterface(); + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; + uint32_t timeoutMs = 0; + MutexIF* mutex = comIf->getMutex(&timeoutType, &timeoutMs); + if(mutex == nullptr or gpioIF == nullptr) { + sif::debug << "rwSpiCallback::spiCallback: Mutex or GPIO interface invalid" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + int fileDescriptor = 0; std::string device = cookie->getSpiDevice(); UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "rwSpiCallback::spiCallback"); @@ -35,16 +45,6 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sen cookie->getSpiParameters(spiMode, spiSpeed, nullptr); comIf->setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); - gpioId_t gpioId = cookie->getChipSelectPin(); - GpioIF* gpioIF = comIf->getGpioInterface(); - MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; - uint32_t timeoutMs = 0; - MutexIF* mutex = comIf->getMutex(&timeoutType, &timeoutMs); - if(mutex == nullptr or gpioIF == nullptr) { - sif::debug << "rwSpiCallback::spiCallback: Mutex or GPIO interface invalid" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - result = mutex->lockMutex(timeoutType, timeoutMs); if (result != HasReturnvaluesIF::RETURN_OK) { sif::debug << "rwSpiCallback::spiCallback: Failed to lock mutex" << std::endl; @@ -119,7 +119,7 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sen size_t replyBufferSize = cookie->getMaxBufferSize(); - /** There must be a delay of 20 ms after sending the command */ + /** There must be a delay of at least 20 ms after sending the command */ usleep(RwDefinitions::SPI_REPLY_DELAY); /** diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 225fffd8..73a27116 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -36,9 +36,6 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { DeviceHandlerIF::PERFORM_OPERATION); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC_0, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_1, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_2, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::RTD_IC_3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::RTD_IC_4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::RTD_IC_5, length * 0, DeviceHandlerIF::PERFORM_OPERATION); @@ -52,6 +49,9 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::RTD_IC_13, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::RTD_IC_14, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::RTD_IC_15, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_16, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_17, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_18, length * 0, DeviceHandlerIF::PERFORM_OPERATION); #endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_TMP_DEVICES == 1 @@ -59,9 +59,6 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.2, DeviceHandlerIF::SEND_WRITE); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC_0, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_1, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_2, length * 0.2, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::RTD_IC_3, length * 0.2, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::RTD_IC_4, length * 0.2, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::RTD_IC_5, length * 0.2, DeviceHandlerIF::SEND_WRITE); @@ -75,6 +72,9 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::RTD_IC_13, length * 0.2, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::RTD_IC_14, length * 0.2, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::RTD_IC_15, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_16, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_17, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_18, length * 0.2, DeviceHandlerIF::SEND_WRITE); #endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_TMP_DEVICES == 1 @@ -82,9 +82,6 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.4, DeviceHandlerIF::GET_WRITE); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC_0, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_1, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_2, length * 0.4, DeviceHandlerIF::GET_WRITE); thisSequence->addSlot(objects::RTD_IC_3, length * 0.4, DeviceHandlerIF::GET_WRITE); thisSequence->addSlot(objects::RTD_IC_4, length * 0.4, DeviceHandlerIF::GET_WRITE); thisSequence->addSlot(objects::RTD_IC_5, length * 0.4, DeviceHandlerIF::GET_WRITE); @@ -98,6 +95,9 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::RTD_IC_13, length * 0.4, DeviceHandlerIF::GET_WRITE); thisSequence->addSlot(objects::RTD_IC_14, length * 0.4, DeviceHandlerIF::GET_WRITE); thisSequence->addSlot(objects::RTD_IC_15, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_16, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_17, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_18, length * 0.4, DeviceHandlerIF::GET_WRITE); #endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_TMP_DEVICES == 1 @@ -105,9 +105,6 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.6, DeviceHandlerIF::SEND_READ); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC_0, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_1, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_2, length * 0.6, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::RTD_IC_3, length * 0.6, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::RTD_IC_4, length * 0.6, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::RTD_IC_5, length * 0.6, DeviceHandlerIF::SEND_READ); @@ -121,6 +118,9 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::RTD_IC_13, length * 0.6, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::RTD_IC_14, length * 0.6, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::RTD_IC_15, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_16, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_17, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_18, length * 0.6, DeviceHandlerIF::SEND_READ); #endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_TMP_DEVICES == 1 @@ -128,9 +128,6 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC_0, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_1, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_2, length * 0.8, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::RTD_IC_3, length * 0.8, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::RTD_IC_4, length * 0.8, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::RTD_IC_5, length * 0.8, DeviceHandlerIF::GET_READ); @@ -144,6 +141,9 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::RTD_IC_13, length * 0.8, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::RTD_IC_14, length * 0.8, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::RTD_IC_15, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_16, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_17, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_18, length * 0.8, DeviceHandlerIF::GET_READ); #endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_RAD_SENSORS == 1 @@ -439,8 +439,8 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { #endif #if OBSW_ADD_ACS_BOARD == 1 - bool enableAside = true; - bool enableBside = false; + bool enableAside = false; + bool enableBside = true; if(enableAside) { // A side thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0, diff --git a/mission/devices/Max31865PT1000Handler.cpp b/mission/devices/Max31865PT1000Handler.cpp index 450d34f3..ba9c8e08 100644 --- a/mission/devices/Max31865PT1000Handler.cpp +++ b/mission/devices/Max31865PT1000Handler.cpp @@ -306,7 +306,8 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply( if(packet[1] != DEFAULT_CONFIG) { #if FSFW_CPP_OSTREAM_ENABLED == 1 // it propably would be better if we at least try one restart.. - sif::error << "Max31865PT1000Handler: Invalid configuration reply!" << std::endl; + sif::error << "Max31865PT1000Handler: Object ID: " << std::hex << this->getObjectId() + << ": Invalid configuration reply!" << std::endl; #else sif::printError("Max31865PT1000Handler: Invalid configuration reply!\n"); #endif @@ -327,7 +328,8 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply( if(readLowThreshold != LOW_THRESHOLD) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Missmatch between " << + sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << + std::hex << this->getObjectId() << ": Missmatch between " << "written and readback value of low threshold register" << std::endl; #else sif::printWarning("Max31865PT1000Handler::interpretDeviceReply: Missmatch between " @@ -343,7 +345,8 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply( if(readHighThreshold != HIGH_THRESHOLD) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Missmatch between " << + sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " + << std::hex << this->getObjectId() << ": Missmatch between " << "written and readback value of high threshold register" << std::endl; #else sif::printWarning("Max31865PT1000Handler::interpretDeviceReply: Missmatch between " @@ -375,7 +378,8 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply( #if OBSW_VERBOSE_LEVEL >= 1 if(debugDivider->checkAndIncrement()) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "Max31865: Measured resistance is " << rtdValue << " Ohms." << std::endl; + sif::info << "Max31865: Object ID: " << std::hex << this->getObjectId() + << ": Measured resistance is " << rtdValue << " Ohms." << std::endl; sif::info << "Approximated temperature is " << approxTemp << " C" << std::endl; #else sif::printInfo("Max31685: Measured resistance is %f Ohms\n", rtdValue); @@ -388,11 +392,12 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply( if(pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) { // Configuration error #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Error reading dataset!" + sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " + << std::hex << this->getObjectId() << ": Error reading dataset!" << std::endl; #else sif::printWarning("Max31865PT1000Handler::interpretDeviceReply: " - "Error reading dataset!\n"); + "Error reading dataset!\n"); #endif return pg.getReadResult(); } @@ -411,7 +416,8 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply( faultByte = packet[1]; #if OBSW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Fault byte" + sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " + << std::hex << this->getObjectId() << ": Fault byte" " is: 0b" << std::bitset<8>(faultByte) << std::endl; #else sif::printWarning("Max31865PT1000Handler::interpretDeviceReply: Fault byte" @@ -422,7 +428,8 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply( if(result != HasReturnvaluesIF::RETURN_OK) { // Configuration error #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "Max31865PT1000Handler::interpretDeviceReply: " + sif::debug << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex + << this->getObjectId() << ":" "Error reading dataset!" << std::endl; #else sif::printDebug("Max31865PT1000Handler::interpretDeviceReply: " @@ -440,8 +447,8 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply( if(result != HasReturnvaluesIF::RETURN_OK) { // Configuration error #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "Max31865PT1000Handler::interpretDeviceReply: " - "Error commiting dataset!" << std::endl; + sif::debug << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex + << this->getObjectId() << ": Error commiting dataset!" << std::endl; #else sif::printDebug("Max31865PT1000Handler::interpretDeviceReply: " "Error commiting dataset!\n"); diff --git a/mission/devices/Max31865PT1000Handler.h b/mission/devices/Max31865PT1000Handler.h index ad412ef1..b33ddbe0 100644 --- a/mission/devices/Max31865PT1000Handler.h +++ b/mission/devices/Max31865PT1000Handler.h @@ -37,7 +37,7 @@ public: // 1. 1 for V_BIAS enabled, 0 for disabled // 2. 1 for Auto-conversion, 0 for off // 3. 1 for 1-shot enabled, 0 for disabled (self-clearing bit) - // 4. 1 for 3-wire disabled, 0 for disabled + // 4. 1 for 3-wire enabled, 0 for disabled (two and four wired RTD) // 5./6. Fault detection: 00 for no action, 01 for automatic delay, 1 // 0 for run fault detection with manual delay, // 11 for finish fault detection with manual delay From ca8e3f685a312c85c3538cf70a4eae12e58e6cac Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Fri, 29 Oct 2021 19:13:48 +0200 Subject: [PATCH 072/465] improved chip select decoding --- bsp_q7s/gpio/gpioCallbacks.cpp | 258 +++++++++++++++++++++++++++------ bsp_q7s/gpio/gpioCallbacks.h | 6 + 2 files changed, 221 insertions(+), 43 deletions(-) diff --git a/bsp_q7s/gpio/gpioCallbacks.cpp b/bsp_q7s/gpio/gpioCallbacks.cpp index b1eefac7..38c5b46e 100644 --- a/bsp_q7s/gpio/gpioCallbacks.cpp +++ b/bsp_q7s/gpio/gpioCallbacks.cpp @@ -27,14 +27,25 @@ void initSpiCsDecoder(GpioIF* gpioComIF) { GpiodRegularByLineName* spiMuxBit = nullptr; /** Setting mux bit 1 to low will disable IC21 on the interface board */ spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_1_PIN, "SPI Mux Bit 1", - gpio::OUT, gpio::LOW); + gpio::OUT, gpio::HIGH); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_1, spiMuxBit); /** Setting mux bit 2 to low disables IC1 on the TCS board */ - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_2_PIN, "SPI Mux Bit 2", gpio::OUT, gpio::LOW); + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_2_PIN, "SPI Mux Bit 2", gpio::OUT, gpio::HIGH); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_2, spiMuxBit); /** Setting mux bit 3 to low disables IC2 on the TCS board and IC22 on the interface board */ spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_3_PIN, "SPI Mux Bit 3", gpio::OUT, gpio::LOW); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_3, spiMuxBit); + +// spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_1_PIN, "SPI Mux Bit 1", +// gpio::OUT, gpio::LOW); +// spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_1, spiMuxBit); +// /** Setting mux bit 2 to low disables IC1 on the TCS board */ +// spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_2_PIN, "SPI Mux Bit 2", gpio::OUT, gpio::HIGH); +// spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_2, spiMuxBit); +// /** Setting mux bit 3 to low disables IC2 on the TCS board and IC22 on the interface board */ +// spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_3_PIN, "SPI Mux Bit 3", gpio::OUT, gpio::LOW); +// spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_3, spiMuxBit); + /** The following gpios can take arbitrary initial values */ spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_4_PIN, "SPI Mux Bit 4", gpio::OUT, gpio::LOW); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_4, spiMuxBit); @@ -68,173 +79,308 @@ void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, gpio::Lev } if (value == gpio::HIGH) { - disableAllDecoder(); + switch (gpioId) { + case(gpioIds::RTD_IC_3): { + disableDecoderTcsIc1(); + break; + } + case(gpioIds::RTD_IC_4): { + disableDecoderTcsIc1(); + break; + } + case(gpioIds::RTD_IC_5): { + disableDecoderTcsIc1(); + break; + } + case(gpioIds::RTD_IC_6): { + disableDecoderTcsIc1(); + break; + } + case(gpioIds::RTD_IC_7): { + disableDecoderTcsIc1(); + break; + } + case(gpioIds::RTD_IC_8): { + disableDecoderTcsIc1(); + break; + } + case(gpioIds::RTD_IC_9): { + disableDecoderTcsIc1(); + break; + } + case(gpioIds::RTD_IC_10): { + disableDecoderTcsIc1(); + break; + } + case(gpioIds::RTD_IC_11): { + disableDecoderTcsIc2(); + break; + } + case(gpioIds::RTD_IC_12): { + disableDecoderTcsIc2(); + break; + } + case(gpioIds::RTD_IC_13): { + disableDecoderTcsIc2(); + break; + } + case(gpioIds::RTD_IC_14): { + disableDecoderTcsIc2(); + break; + } + case(gpioIds::RTD_IC_15): { + disableDecoderTcsIc2(); + break; + } + case(gpioIds::RTD_IC_16): { + disableDecoderTcsIc2(); + break; + } + case(gpioIds::RTD_IC_17): { + disableDecoderTcsIc2(); + break; + } + case(gpioIds::RTD_IC_18): { + disableDecoderTcsIc2(); + break; + } + case(gpioIds::CS_SUS_1): { + disableDecoderInterfaceBoardIc1(); + break; + } + case(gpioIds::CS_SUS_2): { + disableDecoderInterfaceBoardIc1(); + break; + } + case(gpioIds::CS_SUS_3): { + disableDecoderInterfaceBoardIc2(); + break; + } + case(gpioIds::CS_SUS_4): { + disableDecoderInterfaceBoardIc2(); + break; + } + case(gpioIds::CS_SUS_5): { + disableDecoderInterfaceBoardIc2(); + break; + } + case(gpioIds::CS_SUS_6): { + disableDecoderInterfaceBoardIc1(); + break; + } + case(gpioIds::CS_SUS_7): { + disableDecoderInterfaceBoardIc1(); + break; + } + case(gpioIds::CS_SUS_8): { + disableDecoderInterfaceBoardIc2(); + break; + } + case(gpioIds::CS_SUS_9): { + disableDecoderInterfaceBoardIc1(); + break; + } + case(gpioIds::CS_SUS_10): { + disableDecoderInterfaceBoardIc1(); + break; + } + case(gpioIds::CS_SUS_11): { + disableDecoderInterfaceBoardIc2(); + break; + } + case(gpioIds::CS_SUS_12): { + disableDecoderInterfaceBoardIc2(); + break; + } + case(gpioIds::CS_SUS_13): { + disableDecoderInterfaceBoardIc1(); + break; + } + case(gpioIds::CS_RW1): { + disableRwDecoder(); + break; + } + case(gpioIds::CS_RW2): { + disableRwDecoder(); + break; + } + case(gpioIds::CS_RW3): { + disableRwDecoder(); + break; + } + case(gpioIds::CS_RW4): { + disableRwDecoder(); + break; + } + default: + sif::debug << "spiCsDecoderCallback: Invalid gpio id " << gpioId << std::endl; + } } else if (value == gpio::LOW) { switch (gpioId) { case(gpioIds::RTD_IC_3): { + selectY7(); enableDecoderTcsIc1(); - selectY7(); break; } case(gpioIds::RTD_IC_4): { + selectY6(); enableDecoderTcsIc1(); - selectY6(); break; } case(gpioIds::RTD_IC_5): { + selectY5(); enableDecoderTcsIc1(); - selectY5(); break; } case(gpioIds::RTD_IC_6): { + selectY4(); enableDecoderTcsIc1(); - selectY4(); break; } case(gpioIds::RTD_IC_7): { + selectY3(); enableDecoderTcsIc1(); - selectY3(); break; } case(gpioIds::RTD_IC_8): { + selectY2(); enableDecoderTcsIc1(); - selectY2(); break; } case(gpioIds::RTD_IC_9): { + selectY1(); enableDecoderTcsIc1(); - selectY1(); break; } case(gpioIds::RTD_IC_10): { + selectY0(); enableDecoderTcsIc1(); - selectY0(); break; } case(gpioIds::RTD_IC_11): { + selectY7(); enableDecoderTcsIc2(); - selectY7(); break; } case(gpioIds::RTD_IC_12): { + selectY6(); enableDecoderTcsIc2(); - selectY6(); break; } case(gpioIds::RTD_IC_13): { + selectY5(); enableDecoderTcsIc2(); - selectY5(); break; } case(gpioIds::RTD_IC_14): { + selectY4(); enableDecoderTcsIc2(); - selectY4(); break; } case(gpioIds::RTD_IC_15): { + selectY3(); enableDecoderTcsIc2(); - selectY3(); break; } case(gpioIds::RTD_IC_16): { + selectY2(); enableDecoderTcsIc2(); - selectY2(); break; } case(gpioIds::RTD_IC_17): { + selectY1(); enableDecoderTcsIc2(); - selectY1(); break; } case(gpioIds::RTD_IC_18): { + selectY0(); enableDecoderTcsIc2(); - selectY0(); break; } case(gpioIds::CS_SUS_1): { + selectY0(); enableDecoderInterfaceBoardIc1(); - selectY0(); break; } case(gpioIds::CS_SUS_2): { + selectY1(); enableDecoderInterfaceBoardIc1(); - selectY1(); break; } case(gpioIds::CS_SUS_3): { + selectY0(); enableDecoderInterfaceBoardIc2(); - selectY0(); break; } case(gpioIds::CS_SUS_4): { + selectY1(); enableDecoderInterfaceBoardIc2(); - selectY1(); break; } case(gpioIds::CS_SUS_5): { + selectY2(); enableDecoderInterfaceBoardIc2(); - selectY2(); break; } case(gpioIds::CS_SUS_6): { + selectY2(); enableDecoderInterfaceBoardIc1(); - selectY2(); break; } case(gpioIds::CS_SUS_7): { + selectY3(); enableDecoderInterfaceBoardIc1(); - selectY3(); break; } case(gpioIds::CS_SUS_8): { + selectY3(); enableDecoderInterfaceBoardIc2(); - selectY3(); break; } case(gpioIds::CS_SUS_9): { + selectY4(); enableDecoderInterfaceBoardIc1(); - selectY4(); break; } case(gpioIds::CS_SUS_10): { + selectY5(); enableDecoderInterfaceBoardIc1(); - selectY5(); break; } case(gpioIds::CS_SUS_11): { + selectY4(); enableDecoderInterfaceBoardIc2(); - selectY4(); break; } case(gpioIds::CS_SUS_12): { + selectY5(); enableDecoderInterfaceBoardIc2(); - selectY5(); break; } case(gpioIds::CS_SUS_13): { + selectY6(); enableDecoderInterfaceBoardIc1(); - selectY6(); break; } case(gpioIds::CS_RW1): { + selectY0(); enableRwDecoder(); - selectY0(); break; } case(gpioIds::CS_RW2): { + selectY1(); enableRwDecoder(); - selectY1(); break; } case(gpioIds::CS_RW3): { + selectY2(); enableRwDecoder(); - selectY2(); break; } case(gpioIds::CS_RW4): { + selectY3(); enableRwDecoder(); - selectY3(); break; } default: @@ -253,9 +399,9 @@ void enableDecoderTcsIc1() { } void enableDecoderTcsIc2() { + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3); gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3); } void enableDecoderInterfaceBoardIc1() { @@ -266,15 +412,41 @@ void enableDecoderInterfaceBoardIc1() { void enableDecoderInterfaceBoardIc2() { gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); +} + +void disableDecoderTcsIc1() { + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); +} + +void disableDecoderTcsIc2() { + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); +} + +void disableDecoderInterfaceBoardIc1() { + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); +} + +void disableDecoderInterfaceBoardIc2() { + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); } void enableRwDecoder() { - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); - gpioComInterface->pullHigh(gpioIds::EN_RW_CS); + gpioComInterface->pullHigh(gpioIds::EN_RW_CS); +} + +void disableRwDecoder() { + gpioComInterface->pullLow(gpioIds::EN_RW_CS); } void selectY0() { @@ -326,9 +498,9 @@ void selectY7() { } void disableAllDecoder() { + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); gpioComInterface->pullLow(gpioIds::EN_RW_CS); } diff --git a/bsp_q7s/gpio/gpioCallbacks.h b/bsp_q7s/gpio/gpioCallbacks.h index 13a51df2..18adb52b 100644 --- a/bsp_q7s/gpio/gpioCallbacks.h +++ b/bsp_q7s/gpio/gpioCallbacks.h @@ -44,10 +44,16 @@ namespace gpioCallbacks { */ void enableDecoderInterfaceBoardIc2(); + void disableDecoderTcsIc1(); + void disableDecoderTcsIc2(); + void disableDecoderInterfaceBoardIc1(); + void disableDecoderInterfaceBoardIc2(); + /** * @brief Enables the reaction wheel chip select decoder (IC3). */ void enableRwDecoder(); + void disableRwDecoder(); /** * @brief This function disables all decoder. From b71ac25a77ca7fc2d6547a00d4ec84f5e44f8840 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Fri, 29 Oct 2021 19:15:14 +0200 Subject: [PATCH 073/465] changed spi of of RTDs --- common/config/devConf.h | 1 + 1 file changed, 1 insertion(+) diff --git a/common/config/devConf.h b/common/config/devConf.h index fbd9763b..3fbded81 100644 --- a/common/config/devConf.h +++ b/common/config/devConf.h @@ -33,6 +33,7 @@ static constexpr uint32_t RW_SPEED = 300'000; static constexpr spi::SpiModes RW_MODE = spi::SpiModes::MODE_0; static constexpr uint32_t RTD_SPEED = 2'000'000; +static constexpr spi::SpiModes RTD_MODE = spi::SpiModes::MODE_3; } From 556a3986c12ffdac61dfd0fa9afc32cb758f0942 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 1 Nov 2021 12:41:20 +0100 Subject: [PATCH 074/465] pdec handler --- bsp_q7s/boardconfig/busConf.h | 1 + bsp_q7s/core/InitMission.cpp | 13 +- bsp_q7s/core/ObjectFactory.cpp | 20 +- common/config/commonClassIds.h | 1 + common/config/commonObjects.h | 1 + common/config/commonSubsystemIds.h | 1 + generators/bsp_q7s_events.csv | 212 +++++------ generators/events/translateEvents.cpp | 2 +- linux/fsfwconfig/OBSWConfig.h.in | 1 + linux/fsfwconfig/devices/gpioIds.h | 2 + linux/fsfwconfig/events/translateEvents.cpp | 2 +- linux/obc/CMakeLists.txt | 1 + linux/obc/PdecConfig.h | 31 ++ linux/obc/PdecHandler.cpp | 379 ++++++++++++++++++++ linux/obc/PdecHandler.h | 298 +++++++++++++++ linux/obc/PtmeConfig.h | 10 +- mission/tmtc/CCSDSHandler.cpp | 24 +- mission/tmtc/CCSDSHandler.h | 13 +- 18 files changed, 895 insertions(+), 117 deletions(-) create mode 100644 linux/obc/PdecConfig.h create mode 100644 linux/obc/PdecHandler.cpp create mode 100644 linux/obc/PdecHandler.h diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index 8905a125..75d67b1a 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -62,6 +62,7 @@ namespace gpioNames { static constexpr char PAPB_EMPTY_SIGNAL_VC3[] = "papb_empty_signal_vc3"; static constexpr char RS485_EN_TX_CLOCK[] = "tx_clock_enable_ltc2872"; static constexpr char RS485_EN_TX_DATA[] = "tx_data_enable_ltc2872"; + static constexpr char PDEC_RESET[] = "pdec_reset"; } } diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index 1715cada..2c1179d9 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -100,11 +100,21 @@ void initmission::initTasks() { #if OBSW_USE_CCSDS_IP_CORE == 1 PeriodicTaskIF* ccsdsHandlerTask = factory->createPeriodicTask( - "UDP_POLLING", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + "CCSDS_HANDLER", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); result = ccsdsHandlerTask->addComponent(objects::CCSDS_HANDLER); if(result != HasReturnvaluesIF::RETURN_OK) { initmission::printAddObjectError("CCSDS Handler", objects::CCSDS_HANDLER); } + + // Minimal distance between two received TCs amounts to 0.6 seconds + // If a command has not been read before the next one arrives, the old command will be + // overwritten by the PDEC. + PeriodicTaskIF* pdecHandlerTask = factory->createPeriodicTask( + "PDEC_HANDLER", 10, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc); + result = pdecHandlerTask->addComponent(objects::PDEC_HANDLER); + if(result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PDEC Handler", objects::PDEC_HANDLER); + } #endif /* OBSW_USE_CCSDS_IP_CORE == 1 */ # if BOARD_TE0720 == 0 @@ -158,6 +168,7 @@ void initmission::initTasks() { #if OBSW_USE_CCSDS_IP_CORE == 1 ccsdsHandlerTask->startTask(); + pdecHandlerTask->startTask(); #endif /* OBSW_USE_CCSDS_IP_CORE == 1 */ #if BOARD_TE0720 == 0 diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 66357373..d297bb05 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -76,6 +76,7 @@ #endif #include +#include #include #include @@ -171,7 +172,7 @@ void ObjectFactory::produce(void* args) { new StarTrackerHandler(objects::START_TRACKER, objects::UART_COM_IF, starTrackerCookie); #endif /* OBSW_ADD_STAR_TRACKER == 1 */ -#endif /* TE7020 != 0 */ +#endif /* TE7020 == 0 */ #if OBSW_USE_CCSDS_IP_CORE == 1 createCcsdsComponents(gpioComIF); @@ -936,7 +937,8 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF *gpioComIF) { ptme->addVcInterface(ccsds::VC2, vc2); ptme->addVcInterface(ccsds::VC3, vc3); - CCSDSHandler* ccsdsHandler = new CCSDSHandler(objects::CCSDS_HANDLER, objects::PTME); + CCSDSHandler* ccsdsHandler = new CCSDSHandler(objects::CCSDS_HANDLER, objects::PTME, + objects::CCSDS_PACKET_DISTRIBUTOR); VirtualChannel* vc = nullptr; vc = new VirtualChannel(ccsds::VC0, common::VC0_QUEUE_SIZE); @@ -948,6 +950,19 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF *gpioComIF) { vc = new VirtualChannel(ccsds::VC3, common::VC3_QUEUE_SIZE); ccsdsHandler->addVirtualChannel(ccsds::VC3, vc); + GpioCookie* gpioCookiePdec = new GpioCookie; + consumer.str(""); + consumer << "0x" << std::hex << objects::PDEC_HANDLER; + // GPIO also low after linux boot (specified by device-tree) + gpio = new GpiodRegularByLineName(q7s::gpioNames::PDEC_RESET, consumer.str(), gpio::OUT, + gpio::LOW); + gpioCookiePdec->addGpio(gpioIds::PDEC_RESET, gpio); + + gpioComIF->addGpios(gpioCookiePdec); + + new PdecHandler(objects::PDEC_HANDLER, objects::CCSDS_HANDLER, gpioComIF, gpioIds::PDEC_RESET); + +#if BOARD_TE0720 == 0 GpioCookie* gpioRS485Chip = new GpioCookie; gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_TX_CLOCK, "RS485 Transceiver", gpio::Direction::OUT, gpio::HIGH); @@ -957,6 +972,7 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF *gpioComIF) { gpioRS485Chip->addGpio(gpioIds::RS485_EN_TX_DATA, gpio); gpioComIF->addGpios(gpioRS485Chip); +#endif /* BOARD_TE0720 == 0 */ } void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) { diff --git a/common/config/commonClassIds.h b/common/config/commonClassIds.h index bddea49a..605ace3b 100644 --- a/common/config/commonClassIds.h +++ b/common/config/commonClassIds.h @@ -21,6 +21,7 @@ enum commonClassIds: uint8_t { PLOC_UPDATER, //PLUD GOM_SPACE_HANDLER, //GOMS PLOC_MEMORY_DUMPER, //PLMEMDUMP + PDEC_HANDLER, //PDEC COMMON_CLASS_ID_END // [EXPORT] : [END] }; diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index dc18995e..8cf45e9a 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -16,6 +16,7 @@ enum commonObjects: uint32_t { PAPB_VC1 = 0x50000701, PAPB_VC2 = 0x50000702, PAPB_VC3 = 0x50000703, + PDEC_HANDLER = 0x50000704, CCSDS_HANDLER = 0x50000800, /* 0x43 ('C') for Controllers */ diff --git a/common/config/commonSubsystemIds.h b/common/config/commonSubsystemIds.h index 4cef8774..05fda61c 100644 --- a/common/config/commonSubsystemIds.h +++ b/common/config/commonSubsystemIds.h @@ -17,6 +17,7 @@ enum: uint8_t { FILE_SYSTEM = 116, PLOC_UPDATER = 117, PLOC_MEMORY_DUMPER = 118, + PDEC_HANDLER = 119, COMMON_SUBSYSTEM_ID_END }; } diff --git a/generators/bsp_q7s_events.csv b/generators/bsp_q7s_events.csv index a5bbcde4..165ad708 100644 --- a/generators/bsp_q7s_events.csv +++ b/generators/bsp_q7s_events.csv @@ -1,106 +1,106 @@ -2200;STORE_SEND_WRITE_FAILED;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2201;STORE_WRITE_FAILED;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2202;STORE_SEND_READ_FAILED;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2203;STORE_READ_FAILED;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2204;UNEXPECTED_MSG;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2205;STORING_FAILED;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2206;TM_DUMP_FAILED;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2207;STORE_INIT_FAILED;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2208;STORE_INIT_EMPTY;INFO;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2209;STORE_CONTENT_CORRUPTED;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2210;STORE_INITIALIZE;INFO;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2211;INIT_DONE;INFO;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2212;DUMP_FINISHED;INFO;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2213;DELETION_FINISHED;INFO;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2214;DELETION_FAILED;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2215;AUTO_CATALOGS_SENDING_FAILED;INFO;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2600;GET_DATA_FAILED;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/storagemanager/StorageManagerIF.h -2601;STORE_DATA_FAILED;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/storagemanager/StorageManagerIF.h -2800;DEVICE_BUILDING_COMMAND_FAILED;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2801;DEVICE_SENDING_COMMAND_FAILED;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2802;DEVICE_REQUESTING_REPLY_FAILED;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2803;DEVICE_READING_REPLY_FAILED;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2804;DEVICE_INTERPRETING_REPLY_FAILED;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2805;DEVICE_MISSED_REPLY;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2806;DEVICE_UNKNOWN_REPLY;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2807;DEVICE_UNREQUESTED_REPLY;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2808;INVALID_DEVICE_COMMAND;LOW;Indicates a SW bug in child class.;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2809;MONITORING_LIMIT_EXCEEDED;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2810;MONITORING_AMBIGUOUS;HIGH;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -4201;FUSE_CURRENT_HIGH;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/power/Fuse.h -4202;FUSE_WENT_OFF;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/power/Fuse.h -4204;POWER_ABOVE_HIGH_LIMIT;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/power/Fuse.h -4205;POWER_BELOW_LOW_LIMIT;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/power/Fuse.h -4300;SWITCH_WENT_OFF;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/power/PowerSwitchIF.h -5000;HEATER_ON;INFO;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/Heater.h -5001;HEATER_OFF;INFO;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/Heater.h -5002;HEATER_TIMEOUT;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/Heater.h -5003;HEATER_STAYED_ON;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/Heater.h -5004;HEATER_STAYED_OFF;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/Heater.h -5200;TEMP_SENSOR_HIGH;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/AbstractTemperatureSensor.h -5201;TEMP_SENSOR_LOW;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/AbstractTemperatureSensor.h -5202;TEMP_SENSOR_GRADIENT;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/AbstractTemperatureSensor.h -5901;COMPONENT_TEMP_LOW;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h -5902;COMPONENT_TEMP_HIGH;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h -5903;COMPONENT_TEMP_OOL_LOW;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h -5904;COMPONENT_TEMP_OOL_HIGH;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h -5905;TEMP_NOT_IN_OP_RANGE;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h -7101;FDIR_CHANGED_STATE;INFO;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/fdir/FailureIsolationBase.h -7102;FDIR_STARTS_RECOVERY;MEDIUM;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/fdir/FailureIsolationBase.h -7103;FDIR_TURNS_OFF_DEVICE;MEDIUM;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/fdir/FailureIsolationBase.h -7201;MONITOR_CHANGED_STATE;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h -7202;VALUE_BELOW_LOW_LIMIT;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h -7203;VALUE_ABOVE_HIGH_LIMIT;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h -7204;VALUE_OUT_OF_RANGE;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h -7301;SWITCHING_TM_FAILED;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/datapool/HkSwitchHelper.h -7400;CHANGING_MODE;INFO;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h -7401;MODE_INFO;INFO;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h -7402;FALLBACK_FAILED;HIGH;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h -7403;MODE_TRANSITION_FAILED;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h -7404;CANT_KEEP_MODE;HIGH;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h -7405;OBJECT_IN_INVALID_MODE;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h -7406;FORCING_MODE;MEDIUM;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h -7407;MODE_CMD_REJECTED;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h -7506;HEALTH_INFO;INFO;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h -7507;CHILD_CHANGED_HEALTH;INFO;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h -7508;CHILD_PROBLEMS;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h -7509;OVERWRITING_HEALTH;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h -7510;TRYING_RECOVERY;MEDIUM;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h -7511;RECOVERY_STEP;MEDIUM;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h -7512;RECOVERY_DONE;MEDIUM;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h -7900;RF_AVAILABLE;INFO;A RF available signal was detected. P1: raw RFA state, P2: 0;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h -7901;RF_LOST;INFO;A previously found RF available signal was lost. P1: raw RFA state, P2: 0;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h -7902;BIT_LOCK;INFO;A Bit Lock signal. Was detected. P1: raw BLO state, P2: 0;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h -7903;BIT_LOCK_LOST;INFO;A previously found Bit Lock signal was lost. P1: raw BLO state, P2: 0;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h -7905;FRAME_PROCESSING_FAILED;LOW;The CCSDS Board could not interpret a TC;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h -8900;CLOCK_SET;INFO;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/pus/Service9TimeManagement.h -8901;CLOCK_SET_FAILURE;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/pus/Service9TimeManagement.h -9700;TEST;INFO;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/pus/Service17Test.h -10600;CHANGE_OF_SETUP_PARAMETER;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/MGMHandlerLIS3MDL.h -11101;MEMORY_READ_RPT_CRC_FAILURE;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/PlocMPSoCHandler.h -11102;ACK_FAILURE;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/PlocMPSoCHandler.h -11103;EXE_FAILURE;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/PlocMPSoCHandler.h -11104;CRC_FAILURE_EVENT;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/PlocMPSoCHandler.h -11201;SELF_TEST_I2C_FAILURE;LOW;Get self test result returns I2C failure P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h -11202;SELF_TEST_SPI_FAILURE;LOW;Get self test result returns SPI failure. This concerns the MTM connectivity. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h -11203;SELF_TEST_ADC_FAILURE;LOW;Get self test result returns failure in measurement of current and temperature. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h -11204;SELF_TEST_PWM_FAILURE;LOW;Get self test result returns PWM failure which concerns the coil actuation. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h -11205;SELF_TEST_TC_FAILURE;LOW;Get self test result returns TC failure (system failure) P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h -11206;SELF_TEST_MTM_RANGE_FAILURE;LOW;Get self test result returns failure that MTM values were outside of the expected range. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h -11207;SELF_TEST_COIL_CURRENT_FAILURE;LOW;Get self test result returns failure indicating that the coil current was outside of the expected range P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h -11208;INVALID_ERROR_BYTE;LOW;Received invalid error byte. This indicates an error of the communication link between IMTQ and OBC.;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h -11301;ERROR_STATE;HIGH;Reaction wheel signals an error state;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/RwHandler.h -11501;SUPV_MEMORY_READ_RPT_CRC_FAILURE;LOW;PLOC supervisor crc failure in telemetry packet;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h -11502;SUPV_ACK_FAILURE;LOW;PLOC supervisor received acknowledgment failure report;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h -11503;SUPV_EXE_FAILURE;LOW;PLOC received execution failure report;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h -11504;SUPV_CRC_FAILURE_EVENT;LOW;PLOC supervisor reply has invalid crc;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h -11600;SANITIZATION_FAILED;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/memory/SdCardManager.h -11700;UPDATE_FILE_NOT_EXISTS;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h -11701;ACTION_COMMANDING_FAILED;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h -11702;UPDATE_AVAILABLE_FAILED;LOW;Supervisor handler replied action message indicating a command execution failure of the update available command;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h -11703;UPDATE_TRANSFER_FAILED;LOW;Supervisor handler failed to transfer an update space packet. P1: Parameter holds the number of update packets already sent (inclusive the failed packet);C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h -11704;UPDATE_VERIFY_FAILED;LOW;Supervisor failed to execute the update verify command.;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h -11705;UPDATE_FINISHED;INFO;MPSoC update successful completed;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h -11800;SEND_MRAM_DUMP_FAILED;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocMemoryDumper.h -11801;MRAM_DUMP_FAILED;LOW;Received completion failure report form PLOC supervisor handler P1: MRAM start address of failing dump command;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocMemoryDumper.h -11802;MRAM_DUMP_FINISHED;LOW;MRAM dump finished successfully;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocMemoryDumper.h +2200;STORE_SEND_WRITE_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2201;STORE_WRITE_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2202;STORE_SEND_READ_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2203;STORE_READ_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2204;UNEXPECTED_MSG;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2205;STORING_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2206;TM_DUMP_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2207;STORE_INIT_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2208;STORE_INIT_EMPTY;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2209;STORE_CONTENT_CORRUPTED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2210;STORE_INITIALIZE;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2211;INIT_DONE;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2212;DUMP_FINISHED;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2213;DELETION_FINISHED;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2214;DELETION_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2215;AUTO_CATALOGS_SENDING_FAILED;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2600;GET_DATA_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/storagemanager/StorageManagerIF.h +2601;STORE_DATA_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/storagemanager/StorageManagerIF.h +2800;DEVICE_BUILDING_COMMAND_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2801;DEVICE_SENDING_COMMAND_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2802;DEVICE_REQUESTING_REPLY_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2803;DEVICE_READING_REPLY_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2804;DEVICE_INTERPRETING_REPLY_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2805;DEVICE_MISSED_REPLY;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2806;DEVICE_UNKNOWN_REPLY;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2807;DEVICE_UNREQUESTED_REPLY;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2808;INVALID_DEVICE_COMMAND;LOW;Indicates a SW bug in child class.;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2809;MONITORING_LIMIT_EXCEEDED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2810;MONITORING_AMBIGUOUS;HIGH;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +4201;FUSE_CURRENT_HIGH;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/power/Fuse.h +4202;FUSE_WENT_OFF;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/power/Fuse.h +4204;POWER_ABOVE_HIGH_LIMIT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/power/Fuse.h +4205;POWER_BELOW_LOW_LIMIT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/power/Fuse.h +4300;SWITCH_WENT_OFF;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/power/PowerSwitchIF.h +5000;HEATER_ON;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/Heater.h +5001;HEATER_OFF;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/Heater.h +5002;HEATER_TIMEOUT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/Heater.h +5003;HEATER_STAYED_ON;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/Heater.h +5004;HEATER_STAYED_OFF;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/Heater.h +5200;TEMP_SENSOR_HIGH;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/AbstractTemperatureSensor.h +5201;TEMP_SENSOR_LOW;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/AbstractTemperatureSensor.h +5202;TEMP_SENSOR_GRADIENT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/AbstractTemperatureSensor.h +5901;COMPONENT_TEMP_LOW;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h +5902;COMPONENT_TEMP_HIGH;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h +5903;COMPONENT_TEMP_OOL_LOW;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h +5904;COMPONENT_TEMP_OOL_HIGH;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h +5905;TEMP_NOT_IN_OP_RANGE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h +7101;FDIR_CHANGED_STATE;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/fdir/FailureIsolationBase.h +7102;FDIR_STARTS_RECOVERY;MEDIUM;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/fdir/FailureIsolationBase.h +7103;FDIR_TURNS_OFF_DEVICE;MEDIUM;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/fdir/FailureIsolationBase.h +7201;MONITOR_CHANGED_STATE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h +7202;VALUE_BELOW_LOW_LIMIT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h +7203;VALUE_ABOVE_HIGH_LIMIT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h +7204;VALUE_OUT_OF_RANGE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h +7301;SWITCHING_TM_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/datapool/HkSwitchHelper.h +7400;CHANGING_MODE;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h +7401;MODE_INFO;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h +7402;FALLBACK_FAILED;HIGH;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h +7403;MODE_TRANSITION_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h +7404;CANT_KEEP_MODE;HIGH;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h +7405;OBJECT_IN_INVALID_MODE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h +7406;FORCING_MODE;MEDIUM;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h +7407;MODE_CMD_REJECTED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h +7506;HEALTH_INFO;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h +7507;CHILD_CHANGED_HEALTH;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h +7508;CHILD_PROBLEMS;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h +7509;OVERWRITING_HEALTH;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h +7510;TRYING_RECOVERY;MEDIUM;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h +7511;RECOVERY_STEP;MEDIUM;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h +7512;RECOVERY_DONE;MEDIUM;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h +7900;RF_AVAILABLE;INFO;A RF available signal was detected. P1: raw RFA state, P2: 0;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h +7901;RF_LOST;INFO;A previously found RF available signal was lost. P1: raw RFA state, P2: 0;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h +7902;BIT_LOCK;INFO;A Bit Lock signal. Was detected. P1: raw BLO state, P2: 0;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h +7903;BIT_LOCK_LOST;INFO;A previously found Bit Lock signal was lost. P1: raw BLO state, P2: 0;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h +7905;FRAME_PROCESSING_FAILED;LOW;The CCSDS Board could not interpret a TC;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h +8900;CLOCK_SET;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/pus/Service9TimeManagement.h +8901;CLOCK_SET_FAILURE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/pus/Service9TimeManagement.h +9700;TEST;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/pus/Service17Test.h +10600;CHANGE_OF_SETUP_PARAMETER;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h +11101;MEMORY_READ_RPT_CRC_FAILURE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/PlocMPSoCHandler.h +11102;ACK_FAILURE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/PlocMPSoCHandler.h +11103;EXE_FAILURE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/PlocMPSoCHandler.h +11104;CRC_FAILURE_EVENT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/PlocMPSoCHandler.h +11201;SELF_TEST_I2C_FAILURE;LOW;Get self test result returns I2C failure P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h +11202;SELF_TEST_SPI_FAILURE;LOW;Get self test result returns SPI failure. This concerns the MTM connectivity. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h +11203;SELF_TEST_ADC_FAILURE;LOW;Get self test result returns failure in measurement of current and temperature. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h +11204;SELF_TEST_PWM_FAILURE;LOW;Get self test result returns PWM failure which concerns the coil actuation. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h +11205;SELF_TEST_TC_FAILURE;LOW;Get self test result returns TC failure (system failure) P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h +11206;SELF_TEST_MTM_RANGE_FAILURE;LOW;Get self test result returns failure that MTM values were outside of the expected range. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h +11207;SELF_TEST_COIL_CURRENT_FAILURE;LOW;Get self test result returns failure indicating that the coil current was outside of the expected range P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h +11208;INVALID_ERROR_BYTE;LOW;Received invalid error byte. This indicates an error of the communication link between IMTQ and OBC.;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h +11301;ERROR_STATE;HIGH;Reaction wheel signals an error state;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/RwHandler.h +11501;SUPV_MEMORY_READ_RPT_CRC_FAILURE;LOW;PLOC supervisor crc failure in telemetry packet;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h +11502;SUPV_ACK_FAILURE;LOW;PLOC supervisor received acknowledgment failure report;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h +11503;SUPV_EXE_FAILURE;LOW;PLOC received execution failure report;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h +11504;SUPV_CRC_FAILURE_EVENT;LOW;PLOC supervisor reply has invalid crc;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h +11600;SANITIZATION_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/memory/SdCardManager.h +11700;UPDATE_FILE_NOT_EXISTS;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h +11701;ACTION_COMMANDING_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h +11702;UPDATE_AVAILABLE_FAILED;LOW;Supervisor handler replied action message indicating a command execution failure of the update available command;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h +11703;UPDATE_TRANSFER_FAILED;LOW;Supervisor handler failed to transfer an update space packet. P1: Parameter holds the number of update packets already sent (inclusive the failed packet);C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h +11704;UPDATE_VERIFY_FAILED;LOW;Supervisor failed to execute the update verify command.;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h +11705;UPDATE_FINISHED;INFO;MPSoC update successful completed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h +11800;SEND_MRAM_DUMP_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocMemoryDumper.h +11801;MRAM_DUMP_FAILED;LOW;Received completion failure report form PLOC supervisor handler P1: MRAM start address of failing dump command;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocMemoryDumper.h +11802;MRAM_DUMP_FINISHED;LOW;MRAM dump finished successfully;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocMemoryDumper.h diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp index 9d817651..18f6ba50 100644 --- a/generators/events/translateEvents.cpp +++ b/generators/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** * @brief Auto-generated event translation file. Contains 106 translations. * @details - * Generated on: 2021-08-31 10:50:10 + * Generated on: 2021-10-31 17:56:40 */ #include "translateEvents.h" diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index 6ccd6b6d..9dbc5428 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -109,6 +109,7 @@ debugging. */ #define OBSW_DEBUG_STARTRACKER 0 #define OBSW_DEBUG_PLOC_MPSOC 0 #define OBSW_DEBUG_PLOC_SUPERVISOR 0 +#define OBSW_DEBUG_PDEC_HANDLER 0 /*******************************************************************/ /** Hardcoded */ diff --git a/linux/fsfwconfig/devices/gpioIds.h b/linux/fsfwconfig/devices/gpioIds.h index ebe8a3eb..2fe715ea 100644 --- a/linux/fsfwconfig/devices/gpioIds.h +++ b/linux/fsfwconfig/devices/gpioIds.h @@ -100,6 +100,8 @@ enum gpioId_t { VC3_PAPB_EMPTY, VC3_PAPB_BUSY, + PDEC_RESET, + RS485_EN_TX_DATA, RS485_EN_TX_CLOCK diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index 9d817651..18f6ba50 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** * @brief Auto-generated event translation file. Contains 106 translations. * @details - * Generated on: 2021-08-31 10:50:10 + * Generated on: 2021-10-31 17:56:40 */ #include "translateEvents.h" diff --git a/linux/obc/CMakeLists.txt b/linux/obc/CMakeLists.txt index 315a0d33..220bd375 100644 --- a/linux/obc/CMakeLists.txt +++ b/linux/obc/CMakeLists.txt @@ -1,6 +1,7 @@ target_sources(${TARGET_NAME} PUBLIC PapbVcInterface.cpp Ptme.cpp + PdecHandler.cpp ) diff --git a/linux/obc/PdecConfig.h b/linux/obc/PdecConfig.h new file mode 100644 index 00000000..a661d5b4 --- /dev/null +++ b/linux/obc/PdecConfig.h @@ -0,0 +1,31 @@ +#ifndef LINUX_OBC_PDECCONFIG_H_ +#define LINUX_OBC_PDECCONFIG_H_ + +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include + +/** + * @brief PDEC specific configuration parameters. + * + * @author J. Meier + */ +namespace PdecConfig { + + // Access to register space of PDEC via the AXI to AHB bridge + static const char UIO_PDEC_REGISTERS[] = "/dev/uio0"; + // Direct access to memory area in DDR assigned to PDEC + static const char UIO_PDEC_MEMORY[] = "/dev/uio2"; + + // TC transfer frame configuration parameters + static const uint8_t VERSION_ID = 0; + static const uint8_t BYPASS_FLAG = 1; + static const uint8_t CONTROL_COMMAND_FLAG = 1; + static const uint8_t VIRTUAL_CHANNEL = 0; + static const uint8_t RESERVED_FIELD_A = 0; + static const uint16_t SPACECRAFT_ID = 0x274; + // Parameters to control the FARM for AD frames + static const uint8_t POSITIVE_WINDOW = 10; + static const uint8_t NEGATIVE_WINDOW = 151; +}; + +#endif /* LINUX_OBC_PDECCONFIG_H_ */ diff --git a/linux/obc/PdecHandler.cpp b/linux/obc/PdecHandler.cpp new file mode 100644 index 00000000..7e7278fa --- /dev/null +++ b/linux/obc/PdecHandler.cpp @@ -0,0 +1,379 @@ +#include + +#include +#include + +#include "PdecHandler.h" +#include "OBSWConfig.h" +#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/tmtcservices/TmTcMessage.h" +#include "fsfw/objectmanager/ObjectManager.h" + +PdecHandler::PdecHandler(object_id_t objectId, object_id_t tcDestinationId, LinuxLibgpioIF* gpioComIF, + gpioId_t pdecReset) : + SystemObject(objectId), tcDestinationId(tcDestinationId), gpioComIF(gpioComIF), pdecReset( + pdecReset) { + +} + +PdecHandler::~PdecHandler() { +} + +ReturnValue_t PdecHandler::initialize() { + + tcStore = ObjectManager::instance()->get(objects::TC_STORE); + if (tcStore == nullptr) { + sif::error << "PdecHandler::initialize: Invalid TC store" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } + + tcDestination = ObjectManager::instance()->get( + tcDestinationId); + + if (tcDestination == nullptr) { + sif::error << "PdecHandler::initialize: Invalid tc destination specified" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } + + ReturnValue_t result = RETURN_OK; + + result = getRegisterAddress(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } + + result = getMemoryBaseAddress(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } + + writePdecConfig(); + + result = releasePdec(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } + + return RETURN_OK; +} + +ReturnValue_t PdecHandler::getRegisterAddress() { + int fd = open(PdecConfig::UIO_PDEC_REGISTERS, 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::getMemoryBaseAddress() { + int fd = open(PdecConfig::UIO_PDEC_MEMORY, O_RDWR); + if (fd < 1) { + sif::warning << "PdecHandler::getMemoryBaseAddress: Invalid UIO device file" << std::endl; + return RETURN_FAILED; + } + + memoryBaseAddress = static_cast(mmap(NULL, MEMORY_MAP_SIZE, PROT_WRITE | PROT_READ, + MAP_SHARED, fd, 0)); + + if (memoryBaseAddress == MAP_FAILED) { + sif::error << "PdecHandler::getMemoryBaseAddress: Failed to map uio address" << std::endl; + return RETURN_FAILED; + } + + return RETURN_OK; +} + +void PdecHandler::writePdecConfig() { + PdecParams_t pdecParams; + pdecParams.versionId = 0; + pdecParams.bypassFlag = PdecConfig::BYPASS_FLAG; + pdecParams.controlCommandFlag = PdecConfig::CONTROL_COMMAND_FLAG; + pdecParams.reservedFieldA = 0; + pdecParams.spacecraftId = PdecConfig::SPACECRAFT_ID; + pdecParams.virtualChannelId = PdecConfig::VIRTUAL_CHANNEL; + pdecParams.dummy = 0; + pdecParams.positiveWindow = PdecConfig::POSITIVE_WINDOW; + pdecParams.negativeWindow = PdecConfig::NEGATIVE_WINDOW; + std::memcpy(memoryBaseAddress, &pdecParams, sizeof(pdecParams)); + + // Configure all MAP IDs as invalid + for (int idx = 0; idx <= MAX_MAP_ADDR; idx += 4) { + *(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + idx / 4) = NO_DESTINATION << 24 + | NO_DESTINATION << 16 | NO_DESTINATION << 8 | NO_DESTINATION; + + } + + // All TCs with MAP ID 7 will be routed to the PM module (can then be read from memory) + uint8_t routeToPm = calcMapAddrEntry(PM_BUFFER); + *(memoryBaseAddress + 1) = NO_DESTINATION << 24 | NO_DESTINATION << 16 | NO_DESTINATION << 8 + | routeToPm; +} + +ReturnValue_t PdecHandler::resetFarStatFlag() { + uint32_t pdecFar = *(registerBaseAddress + PDEC_FAR_OFFSET); + if (pdecFar != FAR_RESET) { + sif::warning << "PdecHandler::resetFarStatFlag: FAR register did not match expected value." + << " Read value:" << static_cast(pdecFar) << std::endl; + return RETURN_FAILED; + } +#if OBSW_DEBUG_PDEC_HANDLER == 1 + sif::debug << "PdecHandler::resetFarStatFlag: read FAR with value: 0x" << std::hex << pdecFar + << std::endl; +#endif /* OBSW_DEBUG_PDEC_HANDLER == 1 */ + return RETURN_OK; +} + +ReturnValue_t PdecHandler::releasePdec() { + ReturnValue_t result = RETURN_OK; + result = gpioComIF->pullHigh(pdecReset); + if (result != RETURN_OK) { + sif::error << "PdecHandler::releasePdec: Failed to release PDEC reset signal" << std::endl; + } + return result; +} + +ReturnValue_t PdecHandler::performOperation(uint8_t operationCode) { + + ReturnValue_t result = RETURN_OK; + + switch(state) { + case State::INIT: + resetFarStatFlag(); + if (result != RETURN_OK) { + // Requires reconfiguration and reinitialization of PDEC + triggerEvent(INVALID_FAR); + state = State::WAIT_FOR_RECOVERY; + return result; + } + state = State::RUNNING; + break; + case State::RUNNING: + if (newTcReceived()) { + handleNewTc(); + } + break; + case State::WAIT_FOR_RECOVERY: + break; + default: + sif::debug << "PdecHandler::performOperation: Invalid state" << std::endl; + break; + } + + return RETURN_OK; +} + +bool PdecHandler::newTcReceived() { + uint32_t pdecFar = *(registerBaseAddress + PDEC_FAR_OFFSET); + if (pdecFar >> STAT_POSITION != NEW_FAR_RECEIVED) { + return false; + } + if (!checkFrameAna(pdecFar)) { + return false; + } + return true; +} + +bool PdecHandler::checkFrameAna(uint32_t pdecFar) { + bool frameValid = false; + FrameAna_t frameAna = static_cast((pdecFar & FRAME_ANA_MASK) >> FRAME_ANA_POSITION); + switch(frameAna) { + case(FrameAna_t::ABANDONED_CLTU): { + triggerEvent(INVALID_TC_FRAME, ABANDONED_CLTU); + sif::debug << "PdecHandler::checkFrameAna: Abondoned CLTU" << std::endl; + break; + } + case(FrameAna_t::FRAME_DIRTY): { + triggerEvent(INVALID_TC_FRAME, FRAME_DIRTY); + sif::debug << "PdecHandler::checkFrameAna: Frame dirty" << std::endl; + break; + } + case(FrameAna_t::FRAME_ILLEGAL): { + sif::debug << "PdecHandler::checkFrameAna: Frame illegal for one reason" << std::endl; + handleIReason(pdecFar, FRAME_ILLEGAL_ONE_REASON); + break; + } + case(FrameAna_t::FRAME_ILLEGAL_MULTI_REASON): { + sif::debug << "PdecHandler::checkFrameAna: Frame illegal for multiple reasons" + << std::endl; + handleIReason(pdecFar, FRAME_ILLEGAL_MULTIPLE_REASONS); + break; + } + case(FrameAna_t::AD_DISCARDED_LOCKOUT): { + triggerEvent(INVALID_TC_FRAME, AD_DISCARDED_LOCKOUT); + sif::debug << "PdecHandler::checkFrameAna: AD frame discarded because of lockout" + << std::endl; + break; + } + case(FrameAna_t::AD_DISCARDED_WAIT): { + triggerEvent(INVALID_TC_FRAME, AD_DISCARDED_LOCKOUT); + sif::debug << "PdecHandler::checkFrameAna: AD frame discarded because of wait" + << std::endl; + break; + } + case(FrameAna_t::AD_DISCARDED_NS_VR): { + triggerEvent(INVALID_TC_FRAME, AD_DISCARDED_NS_VS); + sif::debug << "PdecHandler::checkFrameAna: AD frame discarded because N(S) or V(R)" + << std::endl; + break; + } + case(FrameAna_t::FRAME_ACCEPTED): { + sif::debug << "PdecHandler::checkFrameAna: Accepted TC frame" << std::endl; + frameValid = true; + break; + } + default: { + sif::debug << "PdecHandler::checkFrameAna: Invaid frame analysis report" << std::endl; + break; + } + } + return frameValid; +} + +void PdecHandler::handleIReason(uint32_t pdecFar, ReturnValue_t parameter1) { + IReason_t ireason = static_cast((pdecFar & IREASON_MASK) >> IREASON_POSITION); + switch(ireason) { + case(IReason_t::NO_REPORT): { + triggerEvent(INVALID_TC_FRAME, parameter1, NO_REPORT); + sif::debug << "PdecHandler::handleIReason: No illegal report" << std::endl; + break; + } + case(IReason_t::ERROR_VERSION_NUMBER): { + triggerEvent(INVALID_TC_FRAME, parameter1, ERROR_VERSION_NUMBER); + sif::debug << "PdecHandler::handleIReason: Error in version number and reserved A and B " + << "fields" << std::endl; + break; + } + case(IReason_t::ILLEGAL_COMBINATION): { + triggerEvent(INVALID_TC_FRAME, parameter1, ILLEGAL_COMBINATION); + sif::debug << "PdecHandler::handleIReason: Illegal combination (AC) of bypass and control " + << "command flags" << std::endl; + break; + } + case(IReason_t::INVALID_SC_ID): { + triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_SC_ID); + sif::debug << "PdecHandler::handleIReason: Invalid spacecraft identifier " << std::endl; + break; + } + case(IReason_t::INVALID_VC_ID_MSB): { + triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_VC_ID_MSB); + sif::debug << "PdecHandler::handleIReason: VC identifier bit 0 to 4 did not match " + << std::endl; + break; + } + case(IReason_t::INVALID_VC_ID_LSB): { + triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_VC_ID_LSB); + sif::debug << "PdecHandler::handleIReason: VC identifier bit 5 did not match " << std::endl; + break; + } + case(IReason_t::NS_NOT_ZERO): { + triggerEvent(INVALID_TC_FRAME, parameter1, NS_NOT_ZERO); + sif::debug << "PdecHandler::handleIReason: N(S) of BC or BD frame not set to all zeros" + << std::endl; + break; + } + case(IReason_t::INCORRECT_BC_CC): { + triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_BC_CC); + sif::debug << "PdecHandler::handleIReason: Invalid BC control command format" << std::endl; + break; + } + default: { + sif::debug << "PdecHandler::handleIReason: Invaid reason id" << std::endl; + break; + } + } +} + +void PdecHandler::handleNewTc() { + ReturnValue_t result = RETURN_OK; + + uint32_t tcLength = 0; + result = readTc(tcLength); + if (result != RETURN_OK) { + return; + } +#if OBSW_DEBUG_PDEC == 1 + unsigned int mapId = tcSegment[0] & MAP_ID_MASK; + sif::debug << "PdecHandler::handleNewTc: Received TC segment with map ID" << mapId + << std::endl; +#endif /* OBSW_DEBUG_PDEC */ + + store_address_t storeId; + result = tcStore->addData(&storeId, tcSegment + 1, tcLength - 1); + if (result != RETURN_OK) { + sif::warning << "PdecHandler::handleNewTc: Failed to add received space packet to store" + << std::endl; + return; + } + + TmTcMessage message(storeId); + + result = MessageQueueSenderIF::sendMessage(tcDestination->getRequestQueue(), &message); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "PdecHandler::handleNewTc: Failed to send message to TC destination" + << std::endl; + tcStore->deleteData(storeId); + return; + } + + return; +} + +ReturnValue_t PdecHandler::readTc(uint32_t& tcLength) { + uint32_t tcOffset = *(registerBaseAddress + PDEC_BPTR_OFFSET) - PHYSICAL_BASE_ADDRESS; + +#if OBSW_DEBUG_PDEC == 1 + sif::debug << "PdecHandler::readTc: TC offset: " << std::hex << tcOffset << std::endl; +#endif /* OBSW_DEBUG_PDEC */ + + uint32_t* tcPtr = reinterpret_cast(*(registerBaseAddress + tcOffset) / 4); + tcLength = *(registerBaseAddress + PDEC_SLEN_OFFSET); + +#if OBSW_DEBUG_PDEC == 1 + sif::debug << "PdecHandler::readTc: TC length: " << tcLength << std::endl; +#endif /* OBSW_DEBUG_PDEC */ + + if (tcLength > MAX_TC_SEGMENT_SIZE) { + sif::warning << "PdecHandler::handleNewTc: Read invalid TC length from PDEC register" + << std::endl; + return RETURN_FAILED; + } + + uint32_t idx = 0; + uint32_t tcData = 0; + for (idx = 0; idx < tcLength; idx = idx + 4) { + tcData = *(tcPtr + idx); + std::memcpy(tcSegment + idx, &tcData, sizeof(tcData)); + } + + // Backend buffer is handled back to PDEC3 + *(registerBaseAddress + PDEC_BFREE_OFFSET) = 0; + + return RETURN_OK; +} + +uint8_t PdecHandler::calcMapAddrEntry(uint8_t moduleId) { + uint8_t lutEntry = 0; + uint8_t parity = getOddParity(moduleId | (1 << VALID_POSITION)); + lutEntry = (parity << PARITY_POSITION) | (1 << VALID_POSITION) | moduleId; + return lutEntry; +} + +uint8_t PdecHandler::getOddParity(uint8_t number) { + uint8_t parityBit = 0; + uint8_t countBits = 0; + for (unsigned int idx = 0; idx < sizeof(number) * 8; idx++) { + countBits += (number >> idx) & 0x1; + } + parityBit = ~(countBits & 0x1) & 0x1; + return parityBit; +} diff --git a/linux/obc/PdecHandler.h b/linux/obc/PdecHandler.h new file mode 100644 index 00000000..033977e4 --- /dev/null +++ b/linux/obc/PdecHandler.h @@ -0,0 +1,298 @@ +#ifndef LINUX_OBC_PDECHANDLER_H_ +#define LINUX_OBC_PDECHANDLER_H_ + +#include "PdecConfig.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw_hal/common/gpio/gpioDefinitions.h" +#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" +#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" +#include "fsfw/storagemanager/StorageManagerIF.h" +#include "fsfw/objectmanager/SystemObject.h" +#include "fsfw/tasks/ExecutableObjectIF.h" + +/** + * @brief This class controls the PDEC IP Core implemented in the programmable logic of the + * Zynq-7020. All registers and memories of the PDEC IP Core are accessed via UIO + * drivers. + * + * @details The PDEC IP Core is responsible for processing data received in form of CLTUs from the + * S-Band transceiver. This comprises the BCH decoding of the CLTUs and reconstruction of + * telecommand transfer frames. Finally the PDEC stores the TC segment transported with + * the TC transfer frame in a register. As soon as a new TC has been received a new + * frame acceptance report (FAR) will be generated. If the FAR confirms the validity of + * a received TC segment, the data can be read out from the associated register. + * Currently, the ground software only supports transmissions of CLTUs containing one + * space packet. + * Link to datasheet of PDEC IP Core: https://eive-cloud.irs.uni-stuttgart.de/index.php/ + * apps/files/?dir=/EIVE_IRS/Arbeitsdaten/08_Used%20Components/CCSDS_IP_Cores&fileid=1108967 + * + * @author J. Meier + */ +class PdecHandler : public SystemObject, public ExecutableObjectIF, public HasReturnvaluesIF { + +public: + /** + * @brief Constructor + * @param objectId Object ID of PDEC handler system object + * @param tcDestinationId Object ID of object responsible for processing TCs. + * @param gpioComIF Pointer to GPIO interace responsible for driving GPIOs. + * @param pdecReset GPIO ID of GPIO connected to the reset signal of the PDEC. + */ + PdecHandler(object_id_t objectId, object_id_t tcDestinationId, LinuxLibgpioIF* gpioComIF, + gpioId_t pdecReset); + + virtual ~PdecHandler(); + + ReturnValue_t performOperation(uint8_t operationCode = 0); + + ReturnValue_t initialize() override; + +private: + + static const uint8_t INTERFACE_ID = CLASS_ID::PDEC_HANDLER; + + static const ReturnValue_t ABANDONED_CLTU = MAKE_RETURN_CODE(0xA0); + static const ReturnValue_t FRAME_DIRTY = MAKE_RETURN_CODE(0xA1); + static const ReturnValue_t FRAME_ILLEGAL_ONE_REASON = MAKE_RETURN_CODE(0xA2); + static const ReturnValue_t FRAME_ILLEGAL_MULTIPLE_REASONS = MAKE_RETURN_CODE(0xA2); + static const ReturnValue_t AD_DISCARDED_LOCKOUT = MAKE_RETURN_CODE(0xA3); + static const ReturnValue_t AD_DISCARDED_WAIT = MAKE_RETURN_CODE(0xA4); + static const ReturnValue_t AD_DISCARDED_NS_VS = MAKE_RETURN_CODE(0xA5); + + static const ReturnValue_t NO_REPORT = MAKE_RETURN_CODE(0xA6); + //! Error in version number and reserved A and B fields + static const ReturnValue_t ERROR_VERSION_NUMBER = MAKE_RETURN_CODE(0xA7); + //! Illegal combination of bypass and control command flag + static const ReturnValue_t ILLEGAL_COMBINATION = MAKE_RETURN_CODE(0xA8); + //! Spacecraft identifier did not match + static const ReturnValue_t INVALID_SC_ID = MAKE_RETURN_CODE(0xA9); + //! VC identifier bits 0 to 4 did not match + static const ReturnValue_t INVALID_VC_ID_MSB = MAKE_RETURN_CODE(0xAA); + //! VC identifier bit 5 did not match + static const ReturnValue_t INVALID_VC_ID_LSB = MAKE_RETURN_CODE(0xAB); + //! N(S) of BC or BD frame not set to all zeros + static const ReturnValue_t NS_NOT_ZERO = MAKE_RETURN_CODE(0xAC); + //! Invalid BC control command + static const ReturnValue_t INVALID_BC_CC = MAKE_RETURN_CODE(0xAE); + + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PDEC_HANDLER; + + //! [EXPORT] : [COMMENT] Frame acceptance report signals an invalid frame + //! P1: The frame analysis information (FrameAna field of PDEC_FAR register) + //! P2: When frame declared illegal this parameter this parameter gives information about the reason (IReason field of the PDEC_FAR register) + static const Event INVALID_TC_FRAME = MAKE_EVENT(1, severity::HIGH); + //! [EXPORT] : [COMMENT] Read invalid FAR from PDEC after startup + static const Event INVALID_FAR = MAKE_EVENT(2, severity::HIGH); + + static const uint8_t STAT_POSITION = 31; + static const uint8_t FRAME_ANA_POSITION = 28; + static const uint8_t IREASON_POSITION = 25; + + static const uint8_t NEW_FAR_RECEIVED = 0; + + static const uint32_t FRAME_ANA_MASK = 0x70000000; + static const uint32_t IREASON_MASK = 0x0E000000; + + /** + * UIO is 4 byte aligned. Thus offset is calculated with "true offset" / 4 + * Example: PDEC_FAR = 0x2840 => Offset in virtual address space is 0xA10 + */ + static const uint32_t PDEC_FAR_OFFSET = 0xA10; + static const uint32_t PDEC_BFREE_OFFSET = 0xA24; + static const uint32_t PDEC_BPTR_OFFSET = 0xA25; + static const uint32_t PDEC_SLEN_OFFSET = 0xA26; + + static const int MEMORY_MAP_SIZE = 0xF42400; + static const int REGISTER_MAP_SIZE = 0x10000; + + static const size_t MAX_TC_SEGMENT_SIZE = 1017; + static const uint8_t MAP_ID_MASK = 0x3F; + + static const uint32_t PHYSICAL_BASE_ADDRESS = 0x30000000; + static const uint32_t MAP_ADDR_LUT_OFFSET = 0xA0; + + static const uint8_t MAX_MAP_ADDR = 63; + // Writing this to the map address in the look up table will invalidate a MAP ID. + static const uint8_t NO_DESTINATION = 0; + static const uint8_t VALID_POSITION = 6; + static const uint8_t PARITY_POSITION = 7; + + // Expected value stored in FAR register after reset + static const uint32_t FAR_RESET = 0x7FE0; + + /** + * TCs with map addresses (also know as Map IDs) assigned to this channel will be stored in + * the PDEC memory. + */ + static const uint32_t PM_BUFFER = 7; + + enum class FrameAna_t: uint8_t { + ABANDONED_CLTU, + FRAME_DIRTY, + FRAME_ILLEGAL, + FRAME_ILLEGAL_MULTI_REASON, + AD_DISCARDED_LOCKOUT, + AD_DISCARDED_WAIT, + AD_DISCARDED_NS_VR, + FRAME_ACCEPTED + }; + + enum class IReason_t: uint8_t { + NO_REPORT, + ERROR_VERSION_NUMBER, + ILLEGAL_COMBINATION, + INVALID_SC_ID, + INVALID_VC_ID_LSB, + INVALID_VC_ID_MSB, + NS_NOT_ZERO, + INCORRECT_BC_CC + }; + + typedef struct PdecParams { + uint8_t versionId : 2 ; + uint8_t bypassFlag : 1; + uint8_t controlCommandFlag : 1; + uint8_t reservedFieldA : 2; + uint16_t spacecraftId : 10; + uint8_t virtualChannelId : 6; + uint8_t dummy : 2; + uint8_t positiveWindow; + uint8_t negativeWindow; + //Authentication unit not used for EIVE + uint8_t auMapIdPointer = 0; + // De-randomizing enabled + uint8_t derandomiserConfig = 1; + // Only used when AU is enabled. Enables the use of an external recovery lac counter. + // The AU requires a lac counter to generate the signature. + uint8_t recoveryLacConfig = 0; + } PdecParams_t; + + enum class State: uint8_t { + INIT, + RUNNING, + WAIT_FOR_RECOVERY + }; + + /** + * @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 getMemoryBaseAddress(); + + /** + * @brief This functions writes the configuration parameters to the configuration + * section of the PDEC. + */ + void writePdecConfig(); + + /** + * @brief Reading the FAR resets the set stat flag which signals a new TC. Without clearing + * this flag no new TC will be excepted. After start up the flag is set and needs + * to be reset. + * Stat flag 0 - new TC received + * Stat flag 1 - old TC (ready to receive next TC) + */ + ReturnValue_t resetFarStatFlag(); + + /** + * @brief Releases the PDEC from reset state. PDEC will start with loading the written + * configuration parameters. + */ + ReturnValue_t releasePdec(); + + /** + * @brief Reads the FAR register and checks if a new TC has been received. + */ + bool newTcReceived(); + + /** + * @brief Analyzes the FramAna field (frame analysis data) of a FAR report. + * + * @return True if frame valid, otherwise false. + */ + bool checkFrameAna(uint32_t pdecFar); + + /** + * @brief This function handles the IReason field of the frame analysis report. + * + * @details In case frame as been declared illegal for multiple reasons, the reason with the + * lowest value will be shown. + */ + void handleIReason(uint32_t pdecFar, ReturnValue_t parameter1); + + /** + * @brief Handles the reception of new TCs. Reads the pointer to the storage location of the + * new TC segment, extracts the PUS packet and forwards the data to the object + * responsible for processing the TC. + */ + void handleNewTc(); + + /** + * @brief Function reads the last received TC segment from the PDEC memory and copies + * the data to the tcSegement array. + * + * @param tcLength The length of the received TC. + * + */ + ReturnValue_t readTc(uint32_t& tcLength); + + /** + * @brief This function calculates the entry for the configuration of the MAP ID routing. + * + * @param mapAddr The MAP ID to configure + * @param moduleId The destination module where all TCs with the map id mapAddr will be routed + * to. + * + * @details The PDEC has different modules where the TCs can be routed to. A lookup table is + * used which links the MAP ID field to the destination module. The entry for this + * lookup table is created by this function and must be stored in the configuration + * memory region of the PDEC. The entry has a specific format + */ + uint8_t calcMapAddrEntry(uint8_t moduleId); + + /** + * @brief This functions calculates the odd parity of the bits in number. + * + * @param number The number from which to calculate the odd parity. + */ + uint8_t getOddParity(uint8_t number); + + object_id_t tcDestinationId; + + AcceptsTelecommandsIF* tcDestination = nullptr; + + LinuxLibgpioIF* gpioComIF = nullptr; + + StorageManagerIF* tcStore = nullptr; + + State state = State::INIT; + + /** + * Reset signal is required to hold PDEC in reset state until the configuration has been + * written to the appropriate memory space. + * Can also be used to reboot PDEC in case of erros. + */ + gpioId_t pdecReset = gpio::NO_GPIO; + + /** + * Pointer pointing to base address of the PDEC memory space. + * This address is equivalent with the base address of the section named configuration area in + * the PDEC datasheet. + */ + uint32_t* memoryBaseAddress = nullptr; + + // Pointer pointing to base address of register space + uint32_t* registerBaseAddress = nullptr; + + uint32_t pdecFar = 0; + + uint8_t tcSegment[1017]; +}; + +#endif /* LINUX_OBC_PDECHANDLER_H_ */ diff --git a/linux/obc/PtmeConfig.h b/linux/obc/PtmeConfig.h index f4468570..a3b17551 100644 --- a/linux/obc/PtmeConfig.h +++ b/linux/obc/PtmeConfig.h @@ -3,10 +3,10 @@ #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include - +#include "OBSWConfig.h" /** - * @brief Configuration parameters derived from FPGA design and device tree. + * @brief PTME specific configuration parameters derived from FPGA design and device tree. * * @author J. Meier */ @@ -19,8 +19,12 @@ namespace PtmeConfig { static const uint32_t VC1_OFFSETT = 0x4000; static const uint32_t VC2_OFFSETT = 0x8000; static const uint32_t VC3_OFFSETT = 0xC000; - +#if BOARD_TE0720 == 0 static const char UIO_DEVICE_FILE[] = "/dev/uio0"; +#else + static const char UIO_DEVICE_FILE[] = "/dev/uio1"; +#endif + }; #endif /* LINUX_OBC_PTMECONFIG_H_ */ diff --git a/mission/tmtc/CCSDSHandler.cpp b/mission/tmtc/CCSDSHandler.cpp index 9b2912c1..ad630044 100644 --- a/mission/tmtc/CCSDSHandler.cpp +++ b/mission/tmtc/CCSDSHandler.cpp @@ -5,8 +5,8 @@ #include "CCSDSHandler.h" -CCSDSHandler::CCSDSHandler(object_id_t objectId, object_id_t ptmeId) : - SystemObject(objectId), ptmeId(ptmeId), parameterHelper(this) { +CCSDSHandler::CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination) : + SystemObject(objectId), ptmeId(ptmeId), tcDestination(tcDestination), parameterHelper(this) { commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); } @@ -39,6 +39,17 @@ ReturnValue_t CCSDSHandler::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } + AcceptsTelecommandsIF* tcDistributor = + ObjectManager::instance()->get(tcDestination); + if (tcDistributor == nullptr) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::error << "CCSDSHandler::initialize: Invalid TC Distributor object" << std::endl; +#endif + return ObjectManagerIF::CHILD_INIT_FAILED; + } + + tcDistributorQueueId = tcDistributor->getRequestQueue(); + result = parameterHelper.initialize(); if (result != HasReturnvaluesIF::RETURN_OK) { return result; @@ -120,3 +131,12 @@ ReturnValue_t CCSDSHandler::getParameter(uint8_t domainId, uint8_t uniqueIdentif uint16_t startAtIndex) { return RETURN_OK; } + +uint16_t CCSDSHandler::getIdentifier() { + return 0; +} + +MessageQueueId_t CCSDSHandler::getRequestQueue() { + // Forward packets directly to TC distributor + return tcDistributorQueueId; +} diff --git a/mission/tmtc/CCSDSHandler.h b/mission/tmtc/CCSDSHandler.h index b53cb8cd..b1c3dd60 100644 --- a/mission/tmtc/CCSDSHandler.h +++ b/mission/tmtc/CCSDSHandler.h @@ -5,6 +5,8 @@ #include "fsfw/objectmanager/SystemObject.h" #include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/tmtcservices/AcceptsTelemetryIF.h" +#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" #include "fsfw/parameters/ParameterHelper.h" #include "VirtualChannel.h" #include @@ -18,6 +20,7 @@ class CCSDSHandler: public SystemObject, public ExecutableObjectIF, public AcceptsTelemetryIF, + public AcceptsTelecommandsIF, public HasReturnvaluesIF, public ReceivesParameterMessagesIF { public: @@ -29,8 +32,9 @@ public: * * @param objectId Object ID of the CCSDS handler * @param ptmeId Object ID of the PTME object providing access to the PTME IP Core. + * @param tcDestination Object ID of object handling received TC space packets */ - CCSDSHandler(object_id_t objectId, object_id_t ptmeId); + CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination); ~CCSDSHandler(); @@ -51,6 +55,9 @@ public: ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues, uint16_t startAtIndex); + uint16_t getIdentifier() override; + MessageQueueId_t getRequestQueue() override; + private: static const uint32_t QUEUE_SIZE = common::CCSDS_HANDLER_QUEUE_SIZE; @@ -63,10 +70,14 @@ private: // Object ID of PTME object object_id_t ptmeId; + object_id_t tcDestination; + MessageQueueIF* commandQueue = nullptr; ParameterHelper parameterHelper; + MessageQueueId_t tcDistributorQueueId; + void readCommandQueue(void); void handleTelemetry(); void handleTelecommands(); From 9191d1ec33eb9c478744b08bdc4b49ee1951b11c Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 1 Nov 2021 18:11:29 +0100 Subject: [PATCH 075/465] save before changing configuration writing --- linux/obc/PdecConfig.h | 6 ++++-- linux/obc/PdecHandler.cpp | 9 ++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/linux/obc/PdecConfig.h b/linux/obc/PdecConfig.h index a661d5b4..4c2306c8 100644 --- a/linux/obc/PdecConfig.h +++ b/linux/obc/PdecConfig.h @@ -18,8 +18,10 @@ namespace PdecConfig { // TC transfer frame configuration parameters static const uint8_t VERSION_ID = 0; - static const uint8_t BYPASS_FLAG = 1; - static const uint8_t CONTROL_COMMAND_FLAG = 1; +// static const uint8_t BYPASS_FLAG = 1; +// static const uint8_t CONTROL_COMMAND_FLAG = 1; + static const uint8_t BYPASS_FLAG = 0; + static const uint8_t CONTROL_COMMAND_FLAG = 0; static const uint8_t VIRTUAL_CHANNEL = 0; static const uint8_t RESERVED_FIELD_A = 0; static const uint16_t SPACECRAFT_ID = 0x274; diff --git a/linux/obc/PdecHandler.cpp b/linux/obc/PdecHandler.cpp index 7e7278fa..fb40c623 100644 --- a/linux/obc/PdecHandler.cpp +++ b/linux/obc/PdecHandler.cpp @@ -106,10 +106,13 @@ void PdecHandler::writePdecConfig() { pdecParams.negativeWindow = PdecConfig::NEGATIVE_WINDOW; std::memcpy(memoryBaseAddress, &pdecParams, sizeof(pdecParams)); +// uint8_t routeToPm = calcMapAddrEntry(PM_BUFFER); // Configure all MAP IDs as invalid for (int idx = 0; idx <= MAX_MAP_ADDR; idx += 4) { *(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + idx / 4) = NO_DESTINATION << 24 | NO_DESTINATION << 16 | NO_DESTINATION << 8 | NO_DESTINATION; +// *(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + idx / 4) = routeToPm << 24 +// | routeToPm << 16 | routeToPm << 8 | routeToPm; } @@ -123,7 +126,7 @@ ReturnValue_t PdecHandler::resetFarStatFlag() { uint32_t pdecFar = *(registerBaseAddress + PDEC_FAR_OFFSET); if (pdecFar != FAR_RESET) { sif::warning << "PdecHandler::resetFarStatFlag: FAR register did not match expected value." - << " Read value:" << static_cast(pdecFar) << std::endl; + << " Read value: 0x" << std::hex << static_cast(pdecFar) << std::endl; return RETURN_FAILED; } #if OBSW_DEBUG_PDEC_HANDLER == 1 @@ -174,6 +177,10 @@ ReturnValue_t PdecHandler::performOperation(uint8_t operationCode) { bool PdecHandler::newTcReceived() { uint32_t pdecFar = *(registerBaseAddress + PDEC_FAR_OFFSET); + + sif::debug << "PdecHandler::newTcReceived: pdecFar 0x" << std::hex + << static_cast(pdecFar) << std::endl; + if (pdecFar >> STAT_POSITION != NEW_FAR_RECEIVED) { return false; } From 3e2f4e7a109856e0df5c151d19fac66a2f8c7111 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 2 Nov 2021 11:11:38 +0100 Subject: [PATCH 076/465] class to generate pdec config words --- bsp_q7s/boardconfig/busConf.h | 3 +++ bsp_q7s/core/ObjectFactory.cpp | 3 ++- linux/obc/CMakeLists.txt | 1 + linux/obc/PdecConfig.cpp | 33 ++++++++++++++++++++++++++++++ linux/obc/PdecConfig.h | 35 +++++++++++++++++++++++--------- linux/obc/PdecHandler.cpp | 27 ++++++++++--------------- linux/obc/PdecHandler.h | 37 ++++++++++++---------------------- 7 files changed, 89 insertions(+), 50 deletions(-) create mode 100644 linux/obc/PdecConfig.cpp diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index 75d67b1a..75618e7a 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -16,6 +16,9 @@ static constexpr char UART_STAR_TRACKER_DEV[] = "/dev/ttyUL8"; static constexpr char UART_GNSS_0_DEV[] = "/dev/ttyUL0"; static constexpr char UART_GNSS_1_DEV[] = "/dev/ttyUL2"; +static constexpr char UIO_PDEC_REGISTERS[] = "/dev/uio0"; +static constexpr char UIO_PDEC_MEMORY[] = "/dev/uio2"; + namespace gpioNames { static constexpr char GYRO_0_ADIS_CS[] = "gyro_0_adis_chip_select"; static constexpr char GYRO_1_L3G_CS[] = "gyro_1_l3g_chip_select"; diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index d297bb05..b86b29f8 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -960,7 +960,8 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF *gpioComIF) { gpioComIF->addGpios(gpioCookiePdec); - new PdecHandler(objects::PDEC_HANDLER, objects::CCSDS_HANDLER, gpioComIF, gpioIds::PDEC_RESET); + new PdecHandler(objects::PDEC_HANDLER, objects::CCSDS_HANDLER, gpioComIF, gpioIds::PDEC_RESET, + std::string(q7s::UIO_PDEC_MEMORY), std::string(q7s::UIO_PDEC_REGISTERS)); #if BOARD_TE0720 == 0 GpioCookie* gpioRS485Chip = new GpioCookie; diff --git a/linux/obc/CMakeLists.txt b/linux/obc/CMakeLists.txt index 220bd375..371ea7cd 100644 --- a/linux/obc/CMakeLists.txt +++ b/linux/obc/CMakeLists.txt @@ -2,6 +2,7 @@ target_sources(${TARGET_NAME} PUBLIC PapbVcInterface.cpp Ptme.cpp PdecHandler.cpp + PdecConfig.cpp ) diff --git a/linux/obc/PdecConfig.cpp b/linux/obc/PdecConfig.cpp new file mode 100644 index 00000000..6e5e3a91 --- /dev/null +++ b/linux/obc/PdecConfig.cpp @@ -0,0 +1,33 @@ +#include "PdecConfig.h" +#include "fsfw/serviceinterface/ServiceInterface.h" + +PdecConfig::PdecConfig() { + initialize(); +} + +PdecConfig::~PdecConfig() { + +} + +void PdecConfig::initialize() { + uint32_t word = 0; + word |= (VERSION_ID << 30); + word |= (BYPASS_FLAG << 29); + word |= (CONTROL_COMMAND_FLAG << 28); + word |= (RESERVED_FIELD_A << 26); + word |= (SPACECRAFT_ID << 16); + word |= (VIRTUAL_CHANNEL << 10); + word |= (DUMMY_BITS << 8); + word |= POSITIVE_WINDOW; + configWords[0] = word; + word = 0; + word |= (NEGATIVE_WINDOW << 24); +} + +uint32_t PdecConfig::getConfigWord(uint8_t wordNo) { + if (wordNo >= CONFIG_WORDS_NUM) { + sif::error << "PdecConfig::getConfigWord: Invalid word number" << std::endl; + return 0; + } + return configWords[wordNo]; +} diff --git a/linux/obc/PdecConfig.h b/linux/obc/PdecConfig.h index 4c2306c8..d1159bf2 100644 --- a/linux/obc/PdecConfig.h +++ b/linux/obc/PdecConfig.h @@ -5,29 +5,46 @@ #include /** - * @brief PDEC specific configuration parameters. + * @brief This class generates the configuration words for the configuration memory of the PDEC + * IP Cores. + * + * @details Fields are initialized according to pecification in PDEC datasheet section 6.11.3.1 + * PROM usage. * * @author J. Meier */ -namespace PdecConfig { +class PdecConfig { - // Access to register space of PDEC via the AXI to AHB bridge - static const char UIO_PDEC_REGISTERS[] = "/dev/uio0"; - // Direct access to memory area in DDR assigned to PDEC - static const char UIO_PDEC_MEMORY[] = "/dev/uio2"; +public: + PdecConfig(); + virtual ~PdecConfig(); + /** + * @brief Returns the configuration word by specifying the position. + */ + uint32_t getConfigWord(uint8_t wordNo); + +private: // TC transfer frame configuration parameters static const uint8_t VERSION_ID = 0; -// static const uint8_t BYPASS_FLAG = 1; -// static const uint8_t CONTROL_COMMAND_FLAG = 1; - static const uint8_t BYPASS_FLAG = 0; + // BD Frames + static const uint8_t BYPASS_FLAG = 1; static const uint8_t CONTROL_COMMAND_FLAG = 0; + static const uint8_t VIRTUAL_CHANNEL = 0; static const uint8_t RESERVED_FIELD_A = 0; static const uint16_t SPACECRAFT_ID = 0x274; + static const uint16_t DUMMY_BITS = 0; // Parameters to control the FARM for AD frames + // Set here for future use static const uint8_t POSITIVE_WINDOW = 10; static const uint8_t NEGATIVE_WINDOW = 151; + + static const uint8_t CONFIG_WORDS_NUM = 2; + + uint32_t configWords[CONFIG_WORDS_NUM]; + + void initialize(); }; #endif /* LINUX_OBC_PDECCONFIG_H_ */ diff --git a/linux/obc/PdecHandler.cpp b/linux/obc/PdecHandler.cpp index fb40c623..df6e967f 100644 --- a/linux/obc/PdecHandler.cpp +++ b/linux/obc/PdecHandler.cpp @@ -9,10 +9,11 @@ #include "fsfw/tmtcservices/TmTcMessage.h" #include "fsfw/objectmanager/ObjectManager.h" -PdecHandler::PdecHandler(object_id_t objectId, object_id_t tcDestinationId, LinuxLibgpioIF* gpioComIF, - gpioId_t pdecReset) : +PdecHandler::PdecHandler(object_id_t objectId, object_id_t tcDestinationId, + LinuxLibgpioIF* gpioComIF, gpioId_t pdecReset, std::string uioMemory, + std::string uioRegisters) : SystemObject(objectId), tcDestinationId(tcDestinationId), gpioComIF(gpioComIF), pdecReset( - pdecReset) { + pdecReset), uioMemory(uioMemory), uioRegisters(uioRegisters) { } @@ -58,7 +59,7 @@ ReturnValue_t PdecHandler::initialize() { } ReturnValue_t PdecHandler::getRegisterAddress() { - int fd = open(PdecConfig::UIO_PDEC_REGISTERS, O_RDWR); + int fd = open(uioRegisters.c_str(), O_RDWR); if (fd < 1) { sif::warning << "PdecHandler::getRegisterAddress: Invalid UIO device file" << std::endl; return RETURN_FAILED; @@ -76,7 +77,7 @@ ReturnValue_t PdecHandler::getRegisterAddress() { } ReturnValue_t PdecHandler::getMemoryBaseAddress() { - int fd = open(PdecConfig::UIO_PDEC_MEMORY, O_RDWR); + int fd = open(uioMemory.c_str(), O_RDWR); if (fd < 1) { sif::warning << "PdecHandler::getMemoryBaseAddress: Invalid UIO device file" << std::endl; return RETURN_FAILED; @@ -94,17 +95,11 @@ ReturnValue_t PdecHandler::getMemoryBaseAddress() { } void PdecHandler::writePdecConfig() { - PdecParams_t pdecParams; - pdecParams.versionId = 0; - pdecParams.bypassFlag = PdecConfig::BYPASS_FLAG; - pdecParams.controlCommandFlag = PdecConfig::CONTROL_COMMAND_FLAG; - pdecParams.reservedFieldA = 0; - pdecParams.spacecraftId = PdecConfig::SPACECRAFT_ID; - pdecParams.virtualChannelId = PdecConfig::VIRTUAL_CHANNEL; - pdecParams.dummy = 0; - pdecParams.positiveWindow = PdecConfig::POSITIVE_WINDOW; - pdecParams.negativeWindow = PdecConfig::NEGATIVE_WINDOW; - std::memcpy(memoryBaseAddress, &pdecParams, sizeof(pdecParams)); + + PdecConfig pdecConfig; + + *memoryBaseAddress = pdecConfig.getConfigWord(0); + *(memoryBaseAddress + 1) = pdecConfig.getConfigWord(1); // uint8_t routeToPm = calcMapAddrEntry(PM_BUFFER); // Configure all MAP IDs as invalid diff --git a/linux/obc/PdecHandler.h b/linux/obc/PdecHandler.h index 033977e4..7f7d1420 100644 --- a/linux/obc/PdecHandler.h +++ b/linux/obc/PdecHandler.h @@ -37,9 +37,11 @@ public: * @param tcDestinationId Object ID of object responsible for processing TCs. * @param gpioComIF Pointer to GPIO interace responsible for driving GPIOs. * @param pdecReset GPIO ID of GPIO connected to the reset signal of the PDEC. + * @param uioMemory String of uio device file same mapped to the PDEC memory space + * @param uioregsiters String of uio device file same mapped to the PDEC register space */ PdecHandler(object_id_t objectId, object_id_t tcDestinationId, LinuxLibgpioIF* gpioComIF, - gpioId_t pdecReset); + gpioId_t pdecReset, std::string uioMemory, std::string uioRegisters); virtual ~PdecHandler(); @@ -148,25 +150,6 @@ private: INCORRECT_BC_CC }; - typedef struct PdecParams { - uint8_t versionId : 2 ; - uint8_t bypassFlag : 1; - uint8_t controlCommandFlag : 1; - uint8_t reservedFieldA : 2; - uint16_t spacecraftId : 10; - uint8_t virtualChannelId : 6; - uint8_t dummy : 2; - uint8_t positiveWindow; - uint8_t negativeWindow; - //Authentication unit not used for EIVE - uint8_t auMapIdPointer = 0; - // De-randomizing enabled - uint8_t derandomiserConfig = 1; - // Only used when AU is enabled. Enables the use of an external recovery lac counter. - // The AU requires a lac counter to generate the signature. - uint8_t recoveryLacConfig = 0; - } PdecParams_t; - enum class State: uint8_t { INIT, RUNNING, @@ -269,10 +252,6 @@ private: LinuxLibgpioIF* gpioComIF = nullptr; - StorageManagerIF* tcStore = nullptr; - - State state = State::INIT; - /** * Reset signal is required to hold PDEC in reset state until the configuration has been * written to the appropriate memory space. @@ -280,6 +259,16 @@ private: */ gpioId_t pdecReset = gpio::NO_GPIO; + // UIO device file giving access to the PDEC memory space + std::string uioMemory; + + // UIO device file giving access to the PDEC register space + std::string uioRegisters; + + StorageManagerIF* tcStore = nullptr; + + State state = State::INIT; + /** * Pointer pointing to base address of the PDEC memory space. * This address is equivalent with the base address of the section named configuration area in From 709661ff6730b4d4228acd4a145d5946b8bea03f Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Wed, 3 Nov 2021 18:19:36 +0100 Subject: [PATCH 077/465] pdec handler print tc --- bsp_q7s/boardconfig/busConf.h | 3 +- bsp_q7s/core/ObjectFactory.cpp | 3 +- linux/obc/PdecConfig.cpp | 3 + linux/obc/PdecConfig.h | 2 + linux/obc/PdecHandler.cpp | 117 ++++++++++++++++++++++++--------- linux/obc/PdecHandler.h | 47 ++++++++++--- 6 files changed, 132 insertions(+), 43 deletions(-) diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index 75618e7a..e68a1f19 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -17,7 +17,8 @@ static constexpr char UART_GNSS_0_DEV[] = "/dev/ttyUL0"; static constexpr char UART_GNSS_1_DEV[] = "/dev/ttyUL2"; static constexpr char UIO_PDEC_REGISTERS[] = "/dev/uio0"; -static constexpr char UIO_PDEC_MEMORY[] = "/dev/uio2"; +static constexpr char UIO_PDEC_CONFIG_MEMORY[] = "/dev/uio2"; +static constexpr char UIO_PDEC_RAM[] = "/dev/uio3"; 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 b86b29f8..a64a1493 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -961,7 +961,8 @@ 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_MEMORY), std::string(q7s::UIO_PDEC_REGISTERS)); + std::string(q7s::UIO_PDEC_CONFIG_MEMORY), std::string(q7s::UIO_PDEC_RAM), + std::string(q7s::UIO_PDEC_REGISTERS)); #if BOARD_TE0720 == 0 GpioCookie* gpioRS485Chip = new GpioCookie; diff --git a/linux/obc/PdecConfig.cpp b/linux/obc/PdecConfig.cpp index 6e5e3a91..bb2ffb13 100644 --- a/linux/obc/PdecConfig.cpp +++ b/linux/obc/PdecConfig.cpp @@ -22,6 +22,9 @@ void PdecConfig::initialize() { configWords[0] = word; word = 0; word |= (NEGATIVE_WINDOW << 24); + word |= (HIGH_AU_MAP_ID << 16); + word |= (ENABLE_DERANDOMIZER << 8); + configWords[1] = word; } uint32_t PdecConfig::getConfigWord(uint8_t wordNo) { diff --git a/linux/obc/PdecConfig.h b/linux/obc/PdecConfig.h index d1159bf2..46cd5097 100644 --- a/linux/obc/PdecConfig.h +++ b/linux/obc/PdecConfig.h @@ -39,6 +39,8 @@ private: // Set here for future use static const uint8_t POSITIVE_WINDOW = 10; static const uint8_t NEGATIVE_WINDOW = 151; + static const uint8_t HIGH_AU_MAP_ID = 0xF; + static const uint8_t ENABLE_DERANDOMIZER = 1; static const uint8_t CONFIG_WORDS_NUM = 2; diff --git a/linux/obc/PdecHandler.cpp b/linux/obc/PdecHandler.cpp index df6e967f..0a49f94a 100644 --- a/linux/obc/PdecHandler.cpp +++ b/linux/obc/PdecHandler.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -10,10 +11,11 @@ #include "fsfw/objectmanager/ObjectManager.h" PdecHandler::PdecHandler(object_id_t objectId, object_id_t tcDestinationId, - LinuxLibgpioIF* gpioComIF, gpioId_t pdecReset, std::string uioMemory, - std::string uioRegisters) : + LinuxLibgpioIF* gpioComIF, gpioId_t pdecReset, std::string uioConfigMemory, + std::string uioRamMemory, std::string uioRegisters) : SystemObject(objectId), tcDestinationId(tcDestinationId), gpioComIF(gpioComIF), pdecReset( - pdecReset), uioMemory(uioMemory), uioRegisters(uioRegisters) { + pdecReset), uioConfigMemory(uioConfigMemory), uioRamMemory(uioRamMemory), uioRegisters( + uioRegisters) { } @@ -43,7 +45,12 @@ ReturnValue_t PdecHandler::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } - result = getMemoryBaseAddress(); + result = getConfigMemoryBaseAddress(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } + + result = getRamBaseAddress(); if (result != RETURN_OK) { return ObjectManagerIF::CHILD_INIT_FAILED; } @@ -76,45 +83,62 @@ ReturnValue_t PdecHandler::getRegisterAddress() { return RETURN_OK; } -ReturnValue_t PdecHandler::getMemoryBaseAddress() { - int fd = open(uioMemory.c_str(), O_RDWR); +ReturnValue_t PdecHandler::getConfigMemoryBaseAddress() { + int fd = open(uioConfigMemory.c_str(), O_RDWR); if (fd < 1) { - sif::warning << "PdecHandler::getMemoryBaseAddress: Invalid UIO device file" << std::endl; + sif::warning << "PdecHandler::getConfigMemoryBaseAddress: Invalid UIO device file" << std::endl; return RETURN_FAILED; } - memoryBaseAddress = static_cast(mmap(NULL, MEMORY_MAP_SIZE, PROT_WRITE | PROT_READ, + memoryBaseAddress = static_cast(mmap(NULL, CONFIG_MEMORY_MAP_SIZE, PROT_WRITE | PROT_READ, MAP_SHARED, fd, 0)); if (memoryBaseAddress == MAP_FAILED) { - sif::error << "PdecHandler::getMemoryBaseAddress: Failed to map uio address" << std::endl; + 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; - *memoryBaseAddress = pdecConfig.getConfigWord(0); - *(memoryBaseAddress + 1) = pdecConfig.getConfigWord(1); + *(memoryBaseAddress + FRAME_HEADER_OFFSET)= pdecConfig.getConfigWord(0); + *(memoryBaseAddress + FRAME_HEADER_OFFSET + 1) = pdecConfig.getConfigWord(1); -// uint8_t routeToPm = calcMapAddrEntry(PM_BUFFER); // Configure all MAP IDs as invalid for (int idx = 0; idx <= MAX_MAP_ADDR; idx += 4) { - *(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + idx / 4) = NO_DESTINATION << 24 + *(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + idx + 1 / 4) = NO_DESTINATION << 24 | NO_DESTINATION << 16 | NO_DESTINATION << 8 | NO_DESTINATION; -// *(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + idx / 4) = routeToPm << 24 -// | routeToPm << 16 | routeToPm << 8 | routeToPm; } // All TCs with MAP ID 7 will be routed to the PM module (can then be read from memory) uint8_t routeToPm = calcMapAddrEntry(PM_BUFFER); - *(memoryBaseAddress + 1) = NO_DESTINATION << 24 | NO_DESTINATION << 16 | NO_DESTINATION << 8 + *(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + 1) = (NO_DESTINATION << 24) | (NO_DESTINATION << 16) | (NO_DESTINATION << 8) | routeToPm; + + // Write map id clock frequencies + for (int idx = 0; idx <= MAX_MAP_ADDR; idx += 4) { + *(memoryBaseAddress + MAP_CLK_FREQ_OFFSET + idx / 4) = MAP_CLK_FREQ << 24 + | MAP_CLK_FREQ << 16 | MAP_CLK_FREQ << 8 | MAP_CLK_FREQ; + + } } ReturnValue_t PdecHandler::resetFarStatFlag() { @@ -173,9 +197,6 @@ ReturnValue_t PdecHandler::performOperation(uint8_t operationCode) { bool PdecHandler::newTcReceived() { uint32_t pdecFar = *(registerBaseAddress + PDEC_FAR_OFFSET); - sif::debug << "PdecHandler::newTcReceived: pdecFar 0x" << std::hex - << static_cast(pdecFar) << std::endl; - if (pdecFar >> STAT_POSITION != NEW_FAR_RECEIVED) { return false; } @@ -303,11 +324,12 @@ void PdecHandler::handleNewTc() { if (result != RETURN_OK) { return; } -#if OBSW_DEBUG_PDEC == 1 +#if OBSW_DEBUG_PDEC_HANDLER == 1 unsigned int mapId = tcSegment[0] & MAP_ID_MASK; sif::debug << "PdecHandler::handleNewTc: Received TC segment with map ID" << mapId << std::endl; -#endif /* OBSW_DEBUG_PDEC */ + printTC(tcLength); +#endif /* OBSW_DEBUG_PDEC_HANDLER */ store_address_t storeId; result = tcStore->addData(&storeId, tcSegment + 1, tcLength - 1); @@ -331,18 +353,17 @@ void PdecHandler::handleNewTc() { } ReturnValue_t PdecHandler::readTc(uint32_t& tcLength) { - uint32_t tcOffset = *(registerBaseAddress + PDEC_BPTR_OFFSET) - PHYSICAL_BASE_ADDRESS; + uint32_t tcOffset = (*(registerBaseAddress + PDEC_BPTR_OFFSET) - PHYSICAL_RAM_BASE_ADDRESS) / 4; -#if OBSW_DEBUG_PDEC == 1 - sif::debug << "PdecHandler::readTc: TC offset: " << std::hex << tcOffset << std::endl; -#endif /* OBSW_DEBUG_PDEC */ +#if OBSW_DEBUG_PDEC_HANDLER == 1 + sif::debug << "PdecHandler::readTc: TC offset: 0x" << std::hex << tcOffset << std::endl; +#endif /* OBSW_DEBUG_PDEC_HANDLER */ - uint32_t* tcPtr = reinterpret_cast(*(registerBaseAddress + tcOffset) / 4); tcLength = *(registerBaseAddress + PDEC_SLEN_OFFSET); -#if OBSW_DEBUG_PDEC == 1 - sif::debug << "PdecHandler::readTc: TC length: " << tcLength << std::endl; -#endif /* OBSW_DEBUG_PDEC */ +#if OBSW_DEBUG_PDEC_HANDLER == 1 + sif::debug << "PdecHandler::readTc: TC segment length: " << std::dec << tcLength << std::endl; +#endif /* OBSW_DEBUG_PDEC_HANDLER */ if (tcLength > MAX_TC_SEGMENT_SIZE) { sif::warning << "PdecHandler::handleNewTc: Read invalid TC length from PDEC register" @@ -352,9 +373,31 @@ ReturnValue_t PdecHandler::readTc(uint32_t& tcLength) { uint32_t idx = 0; uint32_t tcData = 0; - for (idx = 0; idx < tcLength; idx = idx + 4) { - tcData = *(tcPtr + idx); - std::memcpy(tcSegment + idx, &tcData, sizeof(tcData)); + for (idx = 0; idx <= tcLength; idx = idx + 4) { + tcData = *(ramBaseAddress + tcOffset + idx / 4); + if (idx == 0) { + tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); + tcSegment[idx + 1] = static_cast((tcData >> 8) & 0xFF); + tcSegment[idx + 2] = static_cast(tcData & 0xFF); + } + else if (tcLength - idx + 1 == 3) { + tcSegment[idx - 1] = static_cast((tcData >> 16) & 0xFF); + tcSegment[idx] = static_cast((tcData >> 8) & 0xFF); + tcSegment[idx + 1] = static_cast(tcData & 0xFF); + } + else if (tcLength - idx + 1 == 2) { + tcSegment[idx - 1] = static_cast((tcData >> 8) & 0xFF); + tcSegment[idx + 1] = static_cast(tcData & 0xFF); + } + else if (tcLength - idx + 1 == 1) { + tcSegment[idx - 1] = static_cast(tcData & 0xFF); + } + else { + tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); + tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); + tcSegment[idx + 1] = static_cast((tcData >> 8) & 0xFF); + tcSegment[idx + 2] = static_cast(tcData & 0xFF); + } } // Backend buffer is handled back to PDEC3 @@ -363,6 +406,16 @@ ReturnValue_t PdecHandler::readTc(uint32_t& tcLength) { return RETURN_OK; } +void PdecHandler::printTC(uint32_t tcLength) { + std::stringstream tcSegmentStream; + tcSegmentStream << "TC segment data: 0x"; + for (uint32_t idx = 0; idx < tcLength; idx++) { + tcSegmentStream << std::setfill('0') << std::setw(2) << std::hex + << static_cast(tcSegment[idx]); + } + sif::debug << tcSegmentStream.str() << std::endl; +} + uint8_t PdecHandler::calcMapAddrEntry(uint8_t moduleId) { uint8_t lutEntry = 0; uint8_t parity = getOddParity(moduleId | (1 << VALID_POSITION)); diff --git a/linux/obc/PdecHandler.h b/linux/obc/PdecHandler.h index 7f7d1420..10e57afc 100644 --- a/linux/obc/PdecHandler.h +++ b/linux/obc/PdecHandler.h @@ -37,11 +37,12 @@ public: * @param tcDestinationId Object ID of object responsible for processing TCs. * @param gpioComIF Pointer to GPIO interace responsible for driving GPIOs. * @param pdecReset GPIO ID of GPIO connected to the reset signal of the PDEC. - * @param uioMemory String of uio device file same mapped to the PDEC memory space + * @param uioConfigMemory String of uio device file same mapped to the PDEC memory space * @param uioregsiters String of uio device file same mapped to the PDEC register space */ PdecHandler(object_id_t objectId, object_id_t tcDestinationId, LinuxLibgpioIF* gpioComIF, - gpioId_t pdecReset, std::string uioMemory, std::string uioRegisters); + gpioId_t pdecReset, std::string uioConfigMemory, std::string uioRamMemory, + std::string uioRegisters); virtual ~PdecHandler(); @@ -104,14 +105,19 @@ private: static const uint32_t PDEC_BPTR_OFFSET = 0xA25; static const uint32_t PDEC_SLEN_OFFSET = 0xA26; - static const int MEMORY_MAP_SIZE = 0xF42400; + static const int CONFIG_MEMORY_MAP_SIZE = 0x400; + static const int RAM_MAP_SIZE = 0x4000; static const int REGISTER_MAP_SIZE = 0x10000; + // 0x200 / 4 = 0x80 + static const uint32_t FRAME_HEADER_OFFSET = 0x80; + static const size_t MAX_TC_SEGMENT_SIZE = 1017; static const uint8_t MAP_ID_MASK = 0x3F; - static const uint32_t PHYSICAL_BASE_ADDRESS = 0x30000000; + static const uint32_t PHYSICAL_RAM_BASE_ADDRESS = 0x32000000; static const uint32_t MAP_ADDR_LUT_OFFSET = 0xA0; + static const uint32_t MAP_CLK_FREQ_OFFSET = 0x90; static const uint8_t MAX_MAP_ADDR = 63; // Writing this to the map address in the look up table will invalidate a MAP ID. @@ -122,11 +128,17 @@ private: // Expected value stored in FAR register after reset static const uint32_t FAR_RESET = 0x7FE0; + static const uint32_t TC_SEGMENT_LEN = 1017; + /** * TCs with map addresses (also know as Map IDs) assigned to this channel will be stored in * the PDEC memory. */ - static const uint32_t PM_BUFFER = 7; + static const uint8_t PM_BUFFER = 7; + + // MAP clock frequency. Must be a value between 1 and 13 otherwise the TC segment will be + // discarded + static const uint8_t MAP_CLK_FREQ = 2; enum class FrameAna_t: uint8_t { ABANDONED_CLTU, @@ -166,7 +178,14 @@ private: * @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 getMemoryBaseAddress(); + 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 @@ -225,6 +244,11 @@ private: */ ReturnValue_t readTc(uint32_t& tcLength); + /** + * @brief Prints the tc segment data + */ + void printTC(uint32_t tcLength); + /** * @brief This function calculates the entry for the configuration of the MAP ID routing. * @@ -259,8 +283,11 @@ private: */ gpioId_t pdecReset = gpio::NO_GPIO; - // UIO device file giving access to the PDEC memory space - std::string uioMemory; + // UIO device file giving access to the PDEC configuration memory section + std::string uioConfigMemory; + + // UIO device file giving access to the PDEC RAM section + std::string uioRamMemory; // UIO device file giving access to the PDEC register space std::string uioRegisters; @@ -276,12 +303,14 @@ private: */ uint32_t* memoryBaseAddress = nullptr; + uint32_t* ramBaseAddress = nullptr; + // Pointer pointing to base address of register space uint32_t* registerBaseAddress = nullptr; uint32_t pdecFar = 0; - uint8_t tcSegment[1017]; + uint8_t tcSegment[TC_SEGMENT_LEN]; }; #endif /* LINUX_OBC_PDECHANDLER_H_ */ From 6f85968f3cec3813e86333899042942fab38ecee Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Wed, 3 Nov 2021 19:49:41 +0100 Subject: [PATCH 078/465] clcw readout --- linux/obc/PdecHandler.cpp | 57 ++++++++++++++++++++++++++++++++++++++- linux/obc/PdecHandler.h | 6 +++++ 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/linux/obc/PdecHandler.cpp b/linux/obc/PdecHandler.cpp index 0a49f94a..e20cdb95 100644 --- a/linux/obc/PdecHandler.cpp +++ b/linux/obc/PdecHandler.cpp @@ -183,6 +183,7 @@ ReturnValue_t PdecHandler::performOperation(uint8_t operationCode) { if (newTcReceived()) { handleNewTc(); } + getClcw(); break; case State::WAIT_FOR_RECOVERY: break; @@ -326,7 +327,7 @@ void PdecHandler::handleNewTc() { } #if OBSW_DEBUG_PDEC_HANDLER == 1 unsigned int mapId = tcSegment[0] & MAP_ID_MASK; - sif::debug << "PdecHandler::handleNewTc: Received TC segment with map ID" << mapId + sif::debug << "PdecHandler::handleNewTc: Received TC segment with map ID " << mapId << std::endl; printTC(tcLength); #endif /* OBSW_DEBUG_PDEC_HANDLER */ @@ -432,3 +433,57 @@ uint8_t PdecHandler::getOddParity(uint8_t number) { parityBit = ~(countBits & 0x1) & 0x1; return parityBit; } + +void PdecHandler::getClcw() { + uint32_t clcw = *(registerBaseAddress + PDEC_CLCW_OFFSET); + +#if OBSW_DEBUG_PDEC_HANDLER == 1 + if (debugDivider == 5) { + printClcw(clcw); + debugDivider = 0; + return; + } + debugDivider++; +#endif /* OBSW_DEBUG_PDEC_HANDLER == 1 */ + +} + +void PdecHandler::printClcw(uint32_t clcw) { + uint8_t type = static_cast((clcw >> 31) & 0x1); + uint8_t versionNo = static_cast((clcw >> 29) & 0x3); + uint8_t status = static_cast((clcw >> 26) & 0x7); + uint8_t cop = static_cast((clcw >> 24) & 0x3); + uint8_t vcId = static_cast((clcw >> 18) & 0x3F); + uint8_t noRf = static_cast((clcw >> 15) & 0x1); + uint8_t noBitLock = static_cast((clcw >> 14) & 0x1); + uint8_t lockoutFlag = static_cast((clcw >> 13) & 0x1); + uint8_t waitFlag = static_cast((clcw >> 12) & 0x1); + uint8_t retransmitFlag = static_cast((clcw >> 11) & 0x1); + uint8_t farmBcnt = static_cast((clcw >> 9) & 0x3); + // Expected frame sequence number in te next AD frame + uint8_t repValue = static_cast(clcw & 0xFF); + sif::info << std::setw(30) << std::left << "CLCW type: " << std::hex + << "0x" << static_cast(type) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW version no: " << std::hex + << "0x" << static_cast(versionNo) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW status: " << std::hex + << "0x" << static_cast(status) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW COP: " << std::hex + << "0x" << static_cast(cop) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW virtual channel ID: " << std::hex + << "0x" << static_cast(vcId) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW no RF: " << std::hex + << "0x" << static_cast(noRf) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW no bit lock: " << std::hex + << "0x" << static_cast(noBitLock) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW lockout flag: " << std::hex + << "0x" << static_cast(lockoutFlag) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW wait flag: " << std::hex + << "0x" << static_cast(waitFlag) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW retransmit flag: " << std::hex + << "0x" << static_cast(retransmitFlag) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW FARM B count: " << std::hex + << "0x" << static_cast(farmBcnt) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW rep value: " << std::hex + << "0x" << static_cast(repValue) << std::endl; +} diff --git a/linux/obc/PdecHandler.h b/linux/obc/PdecHandler.h index 10e57afc..4e07ea43 100644 --- a/linux/obc/PdecHandler.h +++ b/linux/obc/PdecHandler.h @@ -101,6 +101,7 @@ private: * Example: PDEC_FAR = 0x2840 => Offset in virtual address space is 0xA10 */ static const uint32_t PDEC_FAR_OFFSET = 0xA10; + static const uint32_t PDEC_CLCW_OFFSET = 0xA12; static const uint32_t PDEC_BFREE_OFFSET = 0xA24; static const uint32_t PDEC_BPTR_OFFSET = 0xA25; static const uint32_t PDEC_SLEN_OFFSET = 0xA26; @@ -270,6 +271,9 @@ private: */ uint8_t getOddParity(uint8_t number); + void getClcw(); + void printClcw(uint32_t clcw); + object_id_t tcDestinationId; AcceptsTelecommandsIF* tcDestination = nullptr; @@ -311,6 +315,8 @@ private: uint32_t pdecFar = 0; uint8_t tcSegment[TC_SEGMENT_LEN]; + + uint8_t debugDivider = 0; }; #endif /* LINUX_OBC_PDECHANDLER_H_ */ From 08b369f667c8c233dd8d5cf5c1bf932a4ad64fa0 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Sat, 6 Nov 2021 20:28:33 +0100 Subject: [PATCH 079/465] fix in pdec tc reading --- linux/obc/PdecHandler.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/linux/obc/PdecHandler.cpp b/linux/obc/PdecHandler.cpp index e20cdb95..86493ce8 100644 --- a/linux/obc/PdecHandler.cpp +++ b/linux/obc/PdecHandler.cpp @@ -256,7 +256,7 @@ bool PdecHandler::checkFrameAna(uint32_t pdecFar) { break; } default: { - sif::debug << "PdecHandler::checkFrameAna: Invaid frame analysis report" << std::endl; + sif::debug << "PdecHandler::checkFrameAna: Invalid frame analysis report" << std::endl; break; } } @@ -311,7 +311,7 @@ void PdecHandler::handleIReason(uint32_t pdecFar, ReturnValue_t parameter1) { break; } default: { - sif::debug << "PdecHandler::handleIReason: Invaid reason id" << std::endl; + sif::debug << "PdecHandler::handleIReason: Invalid reason id" << std::endl; break; } } @@ -382,16 +382,16 @@ ReturnValue_t PdecHandler::readTc(uint32_t& tcLength) { tcSegment[idx + 2] = static_cast(tcData & 0xFF); } else if (tcLength - idx + 1 == 3) { - tcSegment[idx - 1] = static_cast((tcData >> 16) & 0xFF); - tcSegment[idx] = static_cast((tcData >> 8) & 0xFF); - tcSegment[idx + 1] = static_cast(tcData & 0xFF); + tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); + tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); + tcSegment[idx + 1] = static_cast((tcData >> 8) & 0xFF); } else if (tcLength - idx + 1 == 2) { - tcSegment[idx - 1] = static_cast((tcData >> 8) & 0xFF); - tcSegment[idx + 1] = static_cast(tcData & 0xFF); + tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); + tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); } else if (tcLength - idx + 1 == 1) { - tcSegment[idx - 1] = static_cast(tcData & 0xFF); + tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); } else { tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); From f75e7b20025737723f10aad3a77c59d167e466fa Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 8 Nov 2021 12:25:12 +0100 Subject: [PATCH 080/465] adaptions to q7s design --- linux/obc/PdecHandler.cpp | 2 +- linux/obc/PdecHandler.h | 7 +++++++ linux/obc/PtmeConfig.h | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/linux/obc/PdecHandler.cpp b/linux/obc/PdecHandler.cpp index 86493ce8..9f95860b 100644 --- a/linux/obc/PdecHandler.cpp +++ b/linux/obc/PdecHandler.cpp @@ -435,9 +435,9 @@ uint8_t PdecHandler::getOddParity(uint8_t number) { } void PdecHandler::getClcw() { - uint32_t clcw = *(registerBaseAddress + PDEC_CLCW_OFFSET); #if OBSW_DEBUG_PDEC_HANDLER == 1 + uint32_t clcw = *(registerBaseAddress + PDEC_CLCW_OFFSET); if (debugDivider == 5) { printClcw(clcw); debugDivider = 0; diff --git a/linux/obc/PdecHandler.h b/linux/obc/PdecHandler.h index 4e07ea43..d6b44c13 100644 --- a/linux/obc/PdecHandler.h +++ b/linux/obc/PdecHandler.h @@ -1,6 +1,7 @@ #ifndef LINUX_OBC_PDECHANDLER_H_ #define LINUX_OBC_PDECHANDLER_H_ +#include "OBSWConfig.h" #include "PdecConfig.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw_hal/common/gpio/gpioDefinitions.h" @@ -106,9 +107,15 @@ private: static const uint32_t PDEC_BPTR_OFFSET = 0xA25; static const uint32_t PDEC_SLEN_OFFSET = 0xA26; +#if BOARD_TE0720 == 1 static const int CONFIG_MEMORY_MAP_SIZE = 0x400; static const int RAM_MAP_SIZE = 0x4000; static const int REGISTER_MAP_SIZE = 0x10000; +#else + static const int CONFIG_MEMORY_MAP_SIZE = 0x400; + static const int RAM_MAP_SIZE = 0x4000; + static const int REGISTER_MAP_SIZE = 0x4000; +#endif /* BOARD_TE0720 == 1 */ // 0x200 / 4 = 0x80 static const uint32_t FRAME_HEADER_OFFSET = 0x80; diff --git a/linux/obc/PtmeConfig.h b/linux/obc/PtmeConfig.h index a3b17551..9ec9cfde 100644 --- a/linux/obc/PtmeConfig.h +++ b/linux/obc/PtmeConfig.h @@ -20,9 +20,9 @@ namespace PtmeConfig { static const uint32_t VC2_OFFSETT = 0x8000; static const uint32_t VC3_OFFSETT = 0xC000; #if BOARD_TE0720 == 0 - static const char UIO_DEVICE_FILE[] = "/dev/uio0"; -#else static const char UIO_DEVICE_FILE[] = "/dev/uio1"; +#else + static const char UIO_DEVICE_FILE[] = "/dev/uio0"; #endif }; From 9e9a19ebb086a80e8fc86ba5c82017cbd6a9e0eb Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Wed, 17 Nov 2021 11:27:29 +0100 Subject: [PATCH 081/465] changed ptme uio on te0720 --- linux/obc/PdecHandler.cpp | 2 +- linux/obc/PdecHandler.h | 1 + linux/obc/PtmeConfig.h | 2 +- mission/devices/StarTrackerHandler.cpp | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/linux/obc/PdecHandler.cpp b/linux/obc/PdecHandler.cpp index 9f95860b..3d80af8a 100644 --- a/linux/obc/PdecHandler.cpp +++ b/linux/obc/PdecHandler.cpp @@ -438,7 +438,7 @@ void PdecHandler::getClcw() { #if OBSW_DEBUG_PDEC_HANDLER == 1 uint32_t clcw = *(registerBaseAddress + PDEC_CLCW_OFFSET); - if (debugDivider == 5) { + if (debugDivider == 10) { printClcw(clcw); debugDivider = 0; return; diff --git a/linux/obc/PdecHandler.h b/linux/obc/PdecHandler.h index d6b44c13..7696a7a0 100644 --- a/linux/obc/PdecHandler.h +++ b/linux/obc/PdecHandler.h @@ -106,6 +106,7 @@ private: static const uint32_t PDEC_BFREE_OFFSET = 0xA24; static const uint32_t PDEC_BPTR_OFFSET = 0xA25; static const uint32_t PDEC_SLEN_OFFSET = 0xA26; + static const uint32_t PDEC_MON = 0xA27; #if BOARD_TE0720 == 1 static const int CONFIG_MEMORY_MAP_SIZE = 0x400; diff --git a/linux/obc/PtmeConfig.h b/linux/obc/PtmeConfig.h index 9ec9cfde..814dfeda 100644 --- a/linux/obc/PtmeConfig.h +++ b/linux/obc/PtmeConfig.h @@ -22,7 +22,7 @@ namespace PtmeConfig { #if BOARD_TE0720 == 0 static const char UIO_DEVICE_FILE[] = "/dev/uio1"; #else - static const char UIO_DEVICE_FILE[] = "/dev/uio0"; + static const char UIO_DEVICE_FILE[] = "/dev/uio1"; #endif }; diff --git a/mission/devices/StarTrackerHandler.cpp b/mission/devices/StarTrackerHandler.cpp index a695403f..c5718f02 100644 --- a/mission/devices/StarTrackerHandler.cpp +++ b/mission/devices/StarTrackerHandler.cpp @@ -86,7 +86,7 @@ ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t rema continue; } case ARC_DEC_ASYNC: { - sif::debug << "StarTrackerHandler::scanForReply: Received asychronous tm" << std::endl; + sif::debug << "StarTrackerHandler::scanForReply: Received asynchronous tm" << std::endl; /** No asynchronous replies are expected as of now */ return RETURN_FAILED; } From a2d5f872ad6b95b3da61ccbfbb2b6ec1e0b399bd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 18 Nov 2021 18:54:00 +0100 Subject: [PATCH 082/465] fsfw and tmtc update --- fsfw | 2 +- tmtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsfw b/fsfw index 15687f6f..190848d0 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 15687f6f6e0ca284dbe502f082ef3ab2f0b27b71 +Subproject commit 190848d00e32274eb844e0f930669b65ffe7eb4e diff --git a/tmtc b/tmtc index edcaf2e9..28082dca 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit edcaf2e9c323cbda2ef331e93cc04985f44c6855 +Subproject commit 28082dca885e35641fda85be765ff10c16c3ebe8 From c1be4a1e834ed302feeab57236a63c45c4795dcf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 19 Nov 2021 13:22:20 +0100 Subject: [PATCH 083/465] changes for updated fsfw --- bsp_q7s/boardtest/Q7STestTask.cpp | 12 ++++---- bsp_q7s/memory/FileSystemHandler.cpp | 28 +++++++++++++------ bsp_q7s/memory/FileSystemHandler.h | 18 ++++++------ fsfw | 2 +- .../Host/eive-linux-host-unittest.launch | 4 +-- test/testtasks/TestTask.cpp | 17 ++++++----- test/testtasks/TestTask.h | 15 ++++------ tmtc | 2 +- 8 files changed, 52 insertions(+), 46 deletions(-) diff --git a/bsp_q7s/boardtest/Q7STestTask.cpp b/bsp_q7s/boardtest/Q7STestTask.cpp index 18baf124..7681ef09 100644 --- a/bsp_q7s/boardtest/Q7STestTask.cpp +++ b/bsp_q7s/boardtest/Q7STestTask.cpp @@ -227,7 +227,7 @@ void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) { // Lambda for common code auto createNonEmptyTmpDir = [&]() { if(not std::filesystem::exists("/tmp/test")) { - result = fsHandler->createDirectory("/tmp/test", &cfg); + result = fsHandler->createDirectory("/tmp", "test", false, &cfg); if(result != HasReturnvaluesIF::RETURN_OK) { return result; } @@ -278,7 +278,7 @@ void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) { cfg.useMountPrefix = false; sif::info << "Creating empty file in /tmp folder" << std::endl; // Do not delete file, user can check existence in shell - ReturnValue_t result = fsHandler->createDirectory("/tmp/test", &cfg); + ReturnValue_t result = fsHandler->createDirectory("/tmp", "test", false, &cfg); if(result == HasReturnvaluesIF::RETURN_OK) { sif::info << "Directory created successfully" << std::endl; } @@ -291,13 +291,13 @@ void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) { // No mount prefix, cause file is created in tmp cfg.useMountPrefix = false; if(not std::filesystem::exists("/tmp/test")) { - result = fsHandler->createDirectory("/tmp/test", &cfg); + result = fsHandler->createDirectory("/tmp", "test", false, &cfg); } else { // Delete any leftover files to regular dir removal works std::remove("/tmp/test/*"); } - result = fsHandler->removeDirectory("/tmp/test", false, &cfg); + result = fsHandler->removeDirectory("/tmp", "test", false, &cfg); if(result == HasReturnvaluesIF::RETURN_OK) { sif::info << "Directory removed successfully" << std::endl; } @@ -311,7 +311,7 @@ void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) { if(result != HasReturnvaluesIF::RETURN_OK) { return; } - result = fsHandler->removeDirectory("/tmp/test", true, &cfg); + result = fsHandler->removeDirectory("/tmp", "test", true, &cfg); if(result == HasReturnvaluesIF::RETURN_OK) { sif::info << "Directory removed recursively successfully" << std::endl; } @@ -325,7 +325,7 @@ void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) { if(result != HasReturnvaluesIF::RETURN_OK) { return; } - result = fsHandler->removeDirectory("/tmp/test", false, &cfg); + result = fsHandler->removeDirectory("/tmp", "test", false, &cfg); if(result != HasReturnvaluesIF::RETURN_OK) { sif::info << "Directory removal attempt failed as expected" << std::endl; } diff --git a/bsp_q7s/memory/FileSystemHandler.cpp b/bsp_q7s/memory/FileSystemHandler.cpp index ad8ec137..2943875a 100644 --- a/bsp_q7s/memory/FileSystemHandler.cpp +++ b/bsp_q7s/memory/FileSystemHandler.cpp @@ -133,8 +133,9 @@ ReturnValue_t FileSystemHandler::initialize() { return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t FileSystemHandler::appendToFile(const char *repositoryPath, const char *filename, - const uint8_t *data, size_t size, uint16_t packetNumber, void *args) { +ReturnValue_t FileSystemHandler::appendToFile(const char* repositoryPath, + const char* filename, const uint8_t* data, size_t size, + uint16_t packetNumber, FileSystemArgsIF* args) { // A double slash between repo and filename should not be an issue, so add it in any case std::string fullPath = currentMountPrefix + std::string(repositoryPath) + "/" + std::string(filename); @@ -149,8 +150,8 @@ ReturnValue_t FileSystemHandler::appendToFile(const char *repositoryPath, const return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t FileSystemHandler::createFile(const char *repositoryPath, const char *filename, - const uint8_t *data, size_t size, void *args) { +ReturnValue_t FileSystemHandler::createFile(const char* repositoryPath, + const char* filename, const uint8_t* data, size_t size, FileSystemArgsIF* args) { std::string fullPath; bool useMountPrefix = true; parseCfg(reinterpret_cast(args), useMountPrefix); @@ -171,8 +172,8 @@ ReturnValue_t FileSystemHandler::createFile(const char *repositoryPath, const ch return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t FileSystemHandler::removeFile(const char *repositoryPath, const char *filename, - void *args) { +ReturnValue_t FileSystemHandler::removeFile(const char* repositoryPath, + const char* filename, FileSystemArgsIF* args) { std::string fullPath; bool useMountPrefix = true; parseCfg(reinterpret_cast(args), useMountPrefix); @@ -193,7 +194,8 @@ ReturnValue_t FileSystemHandler::removeFile(const char *repositoryPath, const ch return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t FileSystemHandler::createDirectory(const char *repositoryPath, void *args) { +ReturnValue_t FileSystemHandler:: createDirectory(const char* repositoryPath, const char* dirname, + bool createParentDirs, FileSystemArgsIF* args) { std::string fullPath; bool useMountPrefix = true; parseCfg(reinterpret_cast(args), useMountPrefix); @@ -202,6 +204,7 @@ ReturnValue_t FileSystemHandler::createDirectory(const char *repositoryPath, voi } fullPath += std::string(repositoryPath); + fullPath += "/" + std::string(dirname); if(std::filesystem::exists(fullPath)) { return DIRECTORY_ALREADY_EXISTS; } @@ -212,8 +215,8 @@ ReturnValue_t FileSystemHandler::createDirectory(const char *repositoryPath, voi return GENERIC_FILE_ERROR; } -ReturnValue_t FileSystemHandler::removeDirectory(const char *repositoryPath, - bool deleteRecurively, void *args) { +ReturnValue_t FileSystemHandler::removeDirectory(const char* repositoryPath, const char* dirname, + bool deleteRecurively, FileSystemArgsIF* args) { std::string fullPath; bool useMountPrefix = true; parseCfg(reinterpret_cast(args), useMountPrefix); @@ -222,6 +225,7 @@ ReturnValue_t FileSystemHandler::removeDirectory(const char *repositoryPath, } fullPath += std::string(repositoryPath); + fullPath += "/" + std::string(dirname); if(not std::filesystem::exists(fullPath)) { return DIRECTORY_DOES_NOT_EXIST; } @@ -268,3 +272,9 @@ void FileSystemHandler::parseCfg(FsCommandCfg *cfg, bool& useMountPrefix) { useMountPrefix = cfg->useMountPrefix; } } + +ReturnValue_t FileSystemHandler::renameFile(const char *repositoryPath, const char *oldFilename, + const char *newFilename, FileSystemArgsIF *args) { + // TODO: Implement + return HasReturnvaluesIF::RETURN_OK; +} diff --git a/bsp_q7s/memory/FileSystemHandler.h b/bsp_q7s/memory/FileSystemHandler.h index 1ff5d7c9..8fdebd05 100644 --- a/bsp_q7s/memory/FileSystemHandler.h +++ b/bsp_q7s/memory/FileSystemHandler.h @@ -17,7 +17,7 @@ class FileSystemHandler: public SystemObject, public ExecutableObjectIF, public HasFileSystemIF { public: - struct FsCommandCfg { + struct FsCommandCfg: public FileSystemArgsIF { // Can be used to automatically use mount prefix of active SD card. // Otherwise, the operator has to specify the full path to the mounted SD card as well. bool useMountPrefix = false; @@ -35,18 +35,20 @@ public: * @return MessageQueueId_t of the object */ MessageQueueId_t getCommandQueue() const override; - ReturnValue_t appendToFile(const char* repositoryPath, const char* filename, const uint8_t* data, size_t size, - uint16_t packetNumber, void* args = nullptr) override; + uint16_t packetNumber, FileSystemArgsIF* args = nullptr) override; ReturnValue_t createFile(const char* repositoryPath, const char* filename, const uint8_t* data = nullptr, - size_t size = 0, void* args = nullptr) override; + size_t size = 0, FileSystemArgsIF* args = nullptr) override; ReturnValue_t removeFile(const char* repositoryPath, - const char* filename, void* args = nullptr) override; - ReturnValue_t createDirectory(const char* repositoryPath, void* args = nullptr) override; - ReturnValue_t removeDirectory(const char* repositoryPath, bool deleteRecurively = false, - void* args = nullptr) override; + const char* filename, FileSystemArgsIF* args = nullptr) override; + ReturnValue_t createDirectory(const char* repositoryPath, const char* dirname, + bool createParentDirs, FileSystemArgsIF* args = nullptr) override; + ReturnValue_t removeDirectory(const char* repositoryPath, const char* dirname, + bool deleteRecurively = false, FileSystemArgsIF* args = nullptr) override; + ReturnValue_t renameFile(const char* repositoryPath, const char* oldFilename, + const char* newFilename, FileSystemArgsIF* args = nullptr) override; private: CoreController* coreCtrl = nullptr; diff --git a/fsfw b/fsfw index 190848d0..5d719d0a 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 190848d00e32274eb844e0f930669b65ffe7eb4e +Subproject commit 5d719d0aeb2d4e2089f5106a03c0bbf9caee4381 diff --git a/misc/eclipse/Host/eive-linux-host-unittest.launch b/misc/eclipse/Host/eive-linux-host-unittest.launch index 85d54281..68c1747f 100644 --- a/misc/eclipse/Host/eive-linux-host-unittest.launch +++ b/misc/eclipse/Host/eive-linux-host-unittest.launch @@ -18,10 +18,10 @@ - + - + diff --git a/test/testtasks/TestTask.cpp b/test/testtasks/TestTask.cpp index cb185b4a..6a90cc08 100644 --- a/test/testtasks/TestTask.cpp +++ b/test/testtasks/TestTask.cpp @@ -11,15 +11,14 @@ #include -TestTask::TestTask(object_id_t objectId_): -SystemObject(objectId_), testMode(testModes::A) { +EiveTestTask::EiveTestTask(object_id_t objectId_): TestTask(objectId_), testMode(testModes::A) { IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); } -TestTask::~TestTask() { +EiveTestTask::~EiveTestTask() { } -ReturnValue_t TestTask::performOperation(uint8_t operationCode) { +ReturnValue_t EiveTestTask::performOperation(uint8_t operationCode) { ReturnValue_t result = RETURN_OK; if(oneShotAction) { @@ -74,7 +73,7 @@ const char hyperion_gps_data[] = "" "$GNVTG,040.7,T,,M,000.0,N,000.0,K,A*10\r\n" "$GNZDA,173225.998892,27,02,2021,00,00*75\r\n"; -ReturnValue_t TestTask::performOneShotAction() { +ReturnValue_t EiveTestTask::performOneShotAction() { #if OBSW_ADD_TEST_CODE == 1 //performLwgpsTest(); #endif @@ -82,24 +81,24 @@ ReturnValue_t TestTask::performOneShotAction() { } -ReturnValue_t TestTask::performPeriodicAction() { +ReturnValue_t EiveTestTask::performPeriodicAction() { ReturnValue_t result = RETURN_OK; return result; } -ReturnValue_t TestTask::performActionA() { +ReturnValue_t EiveTestTask::performActionA() { ReturnValue_t result = RETURN_OK; /* Add periodically executed code here */ return result; } -ReturnValue_t TestTask::performActionB() { +ReturnValue_t EiveTestTask::performActionB() { ReturnValue_t result = RETURN_OK; /* Add periodically executed code here */ return result; } -void TestTask::performLwgpsTest() { +void EiveTestTask::performLwgpsTest() { /* Everything here will only be performed once. */ sif::info << "Processing sample GPS output.." << std::endl; diff --git a/test/testtasks/TestTask.h b/test/testtasks/TestTask.h index e2e8db48..c2b8c8ed 100644 --- a/test/testtasks/TestTask.h +++ b/test/testtasks/TestTask.h @@ -1,13 +1,10 @@ #ifndef TEST_TESTTASK_H_ #define TEST_TESTTASK_H_ -#include -#include -#include #include #include #include -#include +#include "fsfw_tests/integration/task/TestTask.h" #include @@ -18,13 +15,11 @@ * Should not be used for board specific * tests. Instead, a derived board test class should be used. */ -class TestTask : public SystemObject, - public ExecutableObjectIF, - public HasReturnvaluesIF { +class EiveTestTask : public TestTask { public: - TestTask(object_id_t objectId); - virtual ~TestTask(); - virtual ReturnValue_t performOperation(uint8_t operationCode = 0); + EiveTestTask(object_id_t objectId); + virtual ~EiveTestTask(); + virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; protected: virtual ReturnValue_t performOneShotAction(); diff --git a/tmtc b/tmtc index 28082dca..9068ebbf 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 28082dca885e35641fda85be765ff10c16c3ebe8 +Subproject commit 9068ebbfc07fe2d58d8c41eed133e758729ca9b6 From 4a01ff3537b5ae5ede5c036e5ccb969f984c4dc5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 19 Nov 2021 16:55:17 +0100 Subject: [PATCH 084/465] fsfw and tmtc update --- fsfw | 2 +- tmtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsfw b/fsfw index 5d719d0a..d8823f12 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 5d719d0aeb2d4e2089f5106a03c0bbf9caee4381 +Subproject commit d8823f12f1ff5ff7ffdf20f03199ace3807851b2 diff --git a/tmtc b/tmtc index 9068ebbf..46d7a15e 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 9068ebbfc07fe2d58d8c41eed133e758729ca9b6 +Subproject commit 46d7a15edf42b7f7e709c49ef9a162a18c45f56a From 67ac4060d72235d79d06026b6db870a494df63ae Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Sun, 21 Nov 2021 13:58:05 +0100 Subject: [PATCH 085/465] physical ram base adress for q7s --- linux/obc/PdecHandler.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/linux/obc/PdecHandler.h b/linux/obc/PdecHandler.h index 7696a7a0..6a8a6562 100644 --- a/linux/obc/PdecHandler.h +++ b/linux/obc/PdecHandler.h @@ -124,7 +124,12 @@ private: static const size_t MAX_TC_SEGMENT_SIZE = 1017; static const uint8_t MAP_ID_MASK = 0x3F; +#if BOARD_TE0720 == 1 static const uint32_t PHYSICAL_RAM_BASE_ADDRESS = 0x32000000; +#else + static const uint32_t PHYSICAL_RAM_BASE_ADDRESS = 0x26000000; +#endif + static const uint32_t MAP_ADDR_LUT_OFFSET = 0xA0; static const uint32_t MAP_CLK_FREQ_OFFSET = 0x90; From 63965e2f6836cb54bbe14baa3f74671fb5100f59 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Sun, 21 Nov 2021 13:59:18 +0100 Subject: [PATCH 086/465] enabled rx lines of syrlinks rs485 transceiver chips --- bsp_q7s/boardconfig/busConf.h | 3 +++ bsp_q7s/core/ObjectFactory.cpp | 23 ++++++++++++++++++++++- linux/fsfwconfig/devices/gpioIds.h | 6 +++++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index e68a1f19..af89d346 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -66,7 +66,10 @@ namespace gpioNames { static constexpr char PAPB_EMPTY_SIGNAL_VC3[] = "papb_empty_signal_vc3"; static constexpr char RS485_EN_TX_CLOCK[] = "tx_clock_enable_ltc2872"; 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"; } } diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index a64a1493..c7738679 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -79,6 +79,8 @@ #include #include #include +#include +#include ResetArgs resetArgsGnss0; ResetArgs resetArgsGnss1; @@ -937,8 +939,19 @@ 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::OUT, + gpio::LOW); + gpioCookieRateSetter->addGpio(gpioIds::BIT_RATE_SEL, gpio); + gpioComIF->addGpios(gpioCookieRateSetter); + + TxRateSetterIF* txRateSetterIF = new PtmeRateSetter(gpioIds::BIT_RATE_SEL, gpioComIF); + CCSDSHandler* ccsdsHandler = new CCSDSHandler(objects::CCSDS_HANDLER, objects::PTME, - objects::CCSDS_PACKET_DISTRIBUTOR); + objects::CCSDS_PACKET_DISTRIBUTOR, txRateSetterIF); VirtualChannel* vc = nullptr; vc = new VirtualChannel(ccsds::VC0, common::VC0_QUEUE_SIZE); @@ -973,6 +986,14 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF *gpioComIF) { gpio::Direction::OUT, gpio::HIGH); gpioRS485Chip->addGpio(gpioIds::RS485_EN_TX_DATA, gpio); + // Default configuration enables RX channels (RXEN = LOW) + gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_RX_CLOCK, "RS485 Transceiver", + gpio::Direction::OUT, gpio::LOW); + gpioRS485Chip->addGpio(gpioIds::RS485_EN_RX_CLOCK, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_RX_DATA, "RS485 Transceiver", + gpio::Direction::OUT, gpio::LOW); + gpioRS485Chip->addGpio(gpioIds::RS485_EN_RX_DATA, gpio); + gpioComIF->addGpios(gpioRS485Chip); #endif /* BOARD_TE0720 == 0 */ } diff --git a/linux/fsfwconfig/devices/gpioIds.h b/linux/fsfwconfig/devices/gpioIds.h index 2fe715ea..8d3f94ca 100644 --- a/linux/fsfwconfig/devices/gpioIds.h +++ b/linux/fsfwconfig/devices/gpioIds.h @@ -104,7 +104,11 @@ enum gpioId_t { RS485_EN_TX_DATA, - RS485_EN_TX_CLOCK + RS485_EN_TX_CLOCK, + RS485_EN_RX_DATA, + RS485_EN_RX_CLOCK, + + BIT_RATE_SEL }; } From dc0f435dbd420242953805b9e783b7a0119cc58f Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Sun, 21 Nov 2021 18:07:05 +0100 Subject: [PATCH 087/465] bit rate setter --- bsp_q7s/core/InitMission.cpp | 2 +- linux/obc/CMakeLists.txt | 1 + linux/obc/PtmeRateSetter.cpp | 27 +++++++++++++++++++++++ linux/obc/PtmeRateSetter.h | 40 +++++++++++++++++++++++++++++++++++ linux/obc/TxRateSetterIF.h | 25 ++++++++++++++++++++++ mission/tmtc/CCSDSHandler.cpp | 31 +++++++++++++++++++++++++-- mission/tmtc/CCSDSHandler.h | 26 +++++++++++++++++++++-- 7 files changed, 147 insertions(+), 5 deletions(-) create mode 100644 linux/obc/PtmeRateSetter.cpp create mode 100644 linux/obc/PtmeRateSetter.h create mode 100644 linux/obc/TxRateSetterIF.h diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index 2c1179d9..eab396c6 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -110,7 +110,7 @@ void initmission::initTasks() { // If a command has not been read before the next one arrives, the old command will be // overwritten by the PDEC. PeriodicTaskIF* pdecHandlerTask = factory->createPeriodicTask( - "PDEC_HANDLER", 10, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc); + "PDEC_HANDLER", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.6, missedDeadlineFunc); result = pdecHandlerTask->addComponent(objects::PDEC_HANDLER); if(result != HasReturnvaluesIF::RETURN_OK) { initmission::printAddObjectError("PDEC Handler", objects::PDEC_HANDLER); diff --git a/linux/obc/CMakeLists.txt b/linux/obc/CMakeLists.txt index 371ea7cd..4119624c 100644 --- a/linux/obc/CMakeLists.txt +++ b/linux/obc/CMakeLists.txt @@ -3,6 +3,7 @@ target_sources(${TARGET_NAME} PUBLIC Ptme.cpp PdecHandler.cpp PdecConfig.cpp + PtmeRateSetter.cpp ) diff --git a/linux/obc/PtmeRateSetter.cpp b/linux/obc/PtmeRateSetter.cpp new file mode 100644 index 00000000..92886623 --- /dev/null +++ b/linux/obc/PtmeRateSetter.cpp @@ -0,0 +1,27 @@ +#include "PtmeRateSetter.h" +#include "fsfw/serviceinterface/ServiceInterface.h" + +PtmeRateSetter::PtmeRateSetter(gpioId_t bitrateSel, GpioIF* gpioif) : + bitrateSel(bitrateSel), gpioif(gpioif) { +} + +PtmeRateSetter::~PtmeRateSetter() { +} + +ReturnValue_t PtmeRateSetter::setRate(BitRates rate) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + switch(rate) { + case RATE_2000KHZ: + result = gpioif->pullHigh(bitrateSel); + break; + case RATE_400KHZ: + result = gpioif->pullLow(bitrateSel); + break; + default: + sif::debug << "PtmeRateSetter::setRate: Invalid rate" << std::endl; + result = HasReturnvaluesIF::RETURN_FAILED; + break; + } + return result; +} + diff --git a/linux/obc/PtmeRateSetter.h b/linux/obc/PtmeRateSetter.h new file mode 100644 index 00000000..ece78e91 --- /dev/null +++ b/linux/obc/PtmeRateSetter.h @@ -0,0 +1,40 @@ +#ifndef LINUX_OBC_PTMERATESETTER_H_ +#define LINUX_OBC_PTMERATESETTER_H_ + +#include "TxRateSetterIF.h" +#include "fsfw_hal/common/gpio/gpioDefinitions.h" +#include "fsfw_hal/common/gpio/GpioIF.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" + +/** + * @brief Class to set the downlink bit rate by using the cadu_rate_switcher implemented in + * the programmable logic. + * + * @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). + * + * @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(); + + virtual ReturnValue_t setRate(BitRates rate); + +private: + + gpioId_t bitrateSel = gpio::NO_GPIO; + + GpioIF* gpioif = nullptr; +}; + +#endif /* LINUX_OBC_PTMERATESETTER_H_ */ diff --git a/linux/obc/TxRateSetterIF.h b/linux/obc/TxRateSetterIF.h new file mode 100644 index 00000000..c07106e4 --- /dev/null +++ b/linux/obc/TxRateSetterIF.h @@ -0,0 +1,25 @@ +#ifndef LINUX_OBC_TXRATESETTERIF_H_ +#define LINUX_OBC_TXRATESETTERIF_H_ + +#include "fsfw/returnvalues/HasReturnvaluesIF.h" + +enum BitRates : uint32_t { + RATE_2000KHZ, + RATE_400KHZ +}; + +/** + * @brief Abstract class for objects implementing the functionality to switch the + * downlink bit rate. + * + * @author J. Meier + */ +class TxRateSetterIF { +public: + TxRateSetterIF() {}; + virtual ~TxRateSetterIF() {}; + + virtual ReturnValue_t setRate(BitRates bitRate) = 0; +}; + +#endif /* LINUX_OBC_TXRATESETTERIF_H_ */ diff --git a/mission/tmtc/CCSDSHandler.cpp b/mission/tmtc/CCSDSHandler.cpp index ad630044..caf99515 100644 --- a/mission/tmtc/CCSDSHandler.cpp +++ b/mission/tmtc/CCSDSHandler.cpp @@ -5,8 +5,10 @@ #include "CCSDSHandler.h" -CCSDSHandler::CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination) : - SystemObject(objectId), ptmeId(ptmeId), tcDestination(tcDestination), parameterHelper(this) { +CCSDSHandler::CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination, + TxRateSetterIF* txRateSetterIF) : + SystemObject(objectId), ptmeId(ptmeId), tcDestination(tcDestination), parameterHelper(this), actionHelper( + this, nullptr), txRateSetterIF(txRateSetterIF) { commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); } @@ -55,6 +57,11 @@ ReturnValue_t CCSDSHandler::initialize() { return result; } + result = actionHelper.initialize(commandQueue); + if (result != RETURN_OK) { + return result; + } + VirtualChannelMapIter iter; for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { result = iter->second->initialize(); @@ -77,10 +84,15 @@ void CCSDSHandler::readCommandQueue(void) { if (result == RETURN_OK) { return; } + result = actionHelper.handleActionMessage(&commandMessage); + if (result == RETURN_OK) { + return; + } CommandMessage reply; reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND, commandMessage.getCommand()); commandQueue->reply(&reply); + return; } } @@ -140,3 +152,18 @@ MessageQueueId_t CCSDSHandler::getRequestQueue() { // Forward packets directly to TC distributor return tcDistributorQueueId; } + +ReturnValue_t CCSDSHandler::executeAction(ActionId_t actionId, + MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { + + switch(actionId) { + case SET_LOW_RATE: + txRateSetterIF->setRate(BitRates::RATE_400KHZ); + return EXECUTION_FINISHED; + case SET_HIGH_RATE: + txRateSetterIF->setRate(BitRates::RATE_2000KHZ); + return EXECUTION_FINISHED; + default: + return COMMAND_NOT_IMPLEMENTED; + } +} diff --git a/mission/tmtc/CCSDSHandler.h b/mission/tmtc/CCSDSHandler.h index b1c3dd60..6ed5abbe 100644 --- a/mission/tmtc/CCSDSHandler.h +++ b/mission/tmtc/CCSDSHandler.h @@ -8,6 +8,9 @@ #include "fsfw/tmtcservices/AcceptsTelemetryIF.h" #include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" #include "fsfw/parameters/ParameterHelper.h" +#include "fsfw/action/ActionHelper.h" +#include "fsfw/action/HasActionsIF.h" +#include "linux/obc/TxRateSetterIF.h" #include "VirtualChannel.h" #include @@ -22,7 +25,8 @@ class CCSDSHandler: public SystemObject, public AcceptsTelemetryIF, public AcceptsTelecommandsIF, public HasReturnvaluesIF, - public ReceivesParameterMessagesIF { + public ReceivesParameterMessagesIF, + public HasActionsIF { public: using VcId_t = uint8_t; @@ -33,8 +37,11 @@ public: * @param objectId Object ID of the CCSDS handler * @param ptmeId Object ID of the PTME object providing access to the PTME IP Core. * @param tcDestination Object ID of object handling received TC space packets + * @param txRateSetter Object providing the functionality to switch the input bitrate of + * the S-Band transceiver. */ - CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination); + CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination, + TxRateSetterIF* txRateSetterIF); ~CCSDSHandler(); @@ -58,10 +65,21 @@ public: uint16_t getIdentifier() override; MessageQueueId_t getRequestQueue() override; + virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size); + private: + static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_HANDLER; + static const uint32_t QUEUE_SIZE = common::CCSDS_HANDLER_QUEUE_SIZE; + static const ActionId_t SET_LOW_RATE = 0; + static const ActionId_t SET_HIGH_RATE = 1; + + //! [EXPORT] : [COMMENT] Received action message with unknown action id + static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xA0); + using VirtualChannelMap = std::unordered_map; using VirtualChannelMapIter = VirtualChannelMap::iterator; @@ -76,8 +94,12 @@ private: ParameterHelper parameterHelper; + ActionHelper actionHelper; + MessageQueueId_t tcDistributorQueueId; + TxRateSetterIF* txRateSetterIF = nullptr; + void readCommandQueue(void); void handleTelemetry(); void handleTelecommands(); From 283921cba189e2c988404b3a08792edead17cea2 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 22 Nov 2021 10:38:32 +0100 Subject: [PATCH 088/465] print clcw command --- linux/obc/PdecHandler.cpp | 65 +++++++++++++++++++++++++++++---------- linux/obc/PdecHandler.h | 44 ++++++++++++++++++++++---- 2 files changed, 87 insertions(+), 22 deletions(-) diff --git a/linux/obc/PdecHandler.cpp b/linux/obc/PdecHandler.cpp index 3d80af8a..d68f79a4 100644 --- a/linux/obc/PdecHandler.cpp +++ b/linux/obc/PdecHandler.cpp @@ -9,14 +9,16 @@ #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/tmtcservices/TmTcMessage.h" #include "fsfw/objectmanager/ObjectManager.h" +#include "fsfw/ipc/QueueFactory.h" + PdecHandler::PdecHandler(object_id_t objectId, object_id_t tcDestinationId, LinuxLibgpioIF* gpioComIF, gpioId_t pdecReset, std::string uioConfigMemory, std::string uioRamMemory, std::string uioRegisters) : SystemObject(objectId), tcDestinationId(tcDestinationId), gpioComIF(gpioComIF), pdecReset( pdecReset), uioConfigMemory(uioConfigMemory), uioRamMemory(uioRamMemory), uioRegisters( - uioRegisters) { - + uioRegisters), actionHelper(this, nullptr) { + commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); } PdecHandler::~PdecHandler() { @@ -62,9 +64,18 @@ ReturnValue_t PdecHandler::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } + result = actionHelper.initialize(commandQueue); + if (result != RETURN_OK) { + return result; + } + return RETURN_OK; } +MessageQueueId_t PdecHandler::getCommandQueue() const { + return commandQueue->getId(); +} + ReturnValue_t PdecHandler::getRegisterAddress() { int fd = open(uioRegisters.c_str(), O_RDWR); if (fd < 1) { @@ -168,6 +179,8 @@ ReturnValue_t PdecHandler::performOperation(uint8_t operationCode) { ReturnValue_t result = RETURN_OK; + readCommandQueue(); + switch(state) { case State::INIT: resetFarStatFlag(); @@ -183,7 +196,6 @@ ReturnValue_t PdecHandler::performOperation(uint8_t operationCode) { if (newTcReceived()) { handleNewTc(); } - getClcw(); break; case State::WAIT_FOR_RECOVERY: break; @@ -195,6 +207,24 @@ ReturnValue_t PdecHandler::performOperation(uint8_t operationCode) { return RETURN_OK; } +void PdecHandler::readCommandQueue(void) { + CommandMessage commandMessage; + ReturnValue_t result = RETURN_FAILED; + + result = commandQueue->receiveMessage(&commandMessage); + if (result == RETURN_OK) { + result = actionHelper.handleActionMessage(&commandMessage); + if (result == RETURN_OK) { + return; + } + CommandMessage reply; + reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND, + commandMessage.getCommand()); + commandQueue->reply(&reply); + return; + } +} + bool PdecHandler::newTcReceived() { uint32_t pdecFar = *(registerBaseAddress + PDEC_FAR_OFFSET); @@ -434,21 +464,12 @@ uint8_t PdecHandler::getOddParity(uint8_t number) { return parityBit; } -void PdecHandler::getClcw() { - -#if OBSW_DEBUG_PDEC_HANDLER == 1 - uint32_t clcw = *(registerBaseAddress + PDEC_CLCW_OFFSET); - if (debugDivider == 10) { - printClcw(clcw); - debugDivider = 0; - return; - } - debugDivider++; -#endif /* OBSW_DEBUG_PDEC_HANDLER == 1 */ - +uint32_t PdecHandler::getClcw() { + return *(registerBaseAddress + PDEC_CLCW_OFFSET); } -void PdecHandler::printClcw(uint32_t clcw) { +void PdecHandler::printClcw() { + uint32_t clcw = getClcw(); uint8_t type = static_cast((clcw >> 31) & 0x1); uint8_t versionNo = static_cast((clcw >> 29) & 0x3); uint8_t status = static_cast((clcw >> 26) & 0x7); @@ -487,3 +508,15 @@ void PdecHandler::printClcw(uint32_t clcw) { sif::info << std::setw(30) << std::left << "CLCW rep value: " << std::hex << "0x" << static_cast(repValue) << std::endl; } + + +ReturnValue_t PdecHandler::executeAction(ActionId_t actionId, + MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { + switch(actionId) { + case PRINT_CLCW: + printClcw(); + return EXECUTION_FINISHED; + default: + return COMMAND_NOT_IMPLEMENTED; + } +} diff --git a/linux/obc/PdecHandler.h b/linux/obc/PdecHandler.h index 6a8a6562..d7c7d236 100644 --- a/linux/obc/PdecHandler.h +++ b/linux/obc/PdecHandler.h @@ -10,6 +10,8 @@ #include "fsfw/storagemanager/StorageManagerIF.h" #include "fsfw/objectmanager/SystemObject.h" #include "fsfw/tasks/ExecutableObjectIF.h" +#include "fsfw/action/ActionHelper.h" +#include "fsfw/action/HasActionsIF.h" /** * @brief This class controls the PDEC IP Core implemented in the programmable logic of the @@ -29,7 +31,10 @@ * * @author J. Meier */ -class PdecHandler : public SystemObject, public ExecutableObjectIF, public HasReturnvaluesIF { +class PdecHandler : public SystemObject, + public ExecutableObjectIF, + public HasReturnvaluesIF, + public HasActionsIF { public: /** @@ -51,6 +56,21 @@ public: ReturnValue_t initialize() override; + MessageQueueId_t getCommandQueue() const; + + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) override; + + /** + * brief Returns the 32-bit wide communication link control word (CLCW) + */ + uint32_t getClcw(); + + /** + * @rief Reads and prints the CLCW. Can be useful for debugging. + */ + void printClcw(); + private: static const uint8_t INTERFACE_ID = CLASS_ID::PDEC_HANDLER; @@ -63,6 +83,9 @@ private: static const ReturnValue_t AD_DISCARDED_WAIT = MAKE_RETURN_CODE(0xA4); static const ReturnValue_t AD_DISCARDED_NS_VS = MAKE_RETURN_CODE(0xA5); + //! [EXPORT] : [COMMENT] Received action message with unknown action id + static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xB0); + static const ReturnValue_t NO_REPORT = MAKE_RETURN_CODE(0xA6); //! Error in version number and reserved A and B fields static const ReturnValue_t ERROR_VERSION_NUMBER = MAKE_RETURN_CODE(0xA7); @@ -88,6 +111,11 @@ private: //! [EXPORT] : [COMMENT] Read invalid FAR from PDEC after startup static const Event INVALID_FAR = MAKE_EVENT(2, severity::HIGH); + static const uint32_t QUEUE_SIZE = common::CCSDS_HANDLER_QUEUE_SIZE; + + // Action IDs + static const ActionId_t PRINT_CLCW = 0; + static const uint8_t STAT_POSITION = 31; static const uint8_t FRAME_ANA_POSITION = 28; static const uint8_t IREASON_POSITION = 25; @@ -182,6 +210,11 @@ private: WAIT_FOR_RECOVERY }; + /** + * @brief Reads and handles messages stored in the commandQueue + */ + 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. @@ -284,9 +317,6 @@ private: */ uint8_t getOddParity(uint8_t number); - void getClcw(); - void printClcw(uint32_t clcw); - object_id_t tcDestinationId; AcceptsTelecommandsIF* tcDestination = nullptr; @@ -309,8 +339,12 @@ private: // UIO device file giving access to the PDEC register space std::string uioRegisters; + ActionHelper actionHelper; + StorageManagerIF* tcStore = nullptr; + MessageQueueIF* commandQueue = nullptr; + State state = State::INIT; /** @@ -328,8 +362,6 @@ private: uint32_t pdecFar = 0; uint8_t tcSegment[TC_SEGMENT_LEN]; - - uint8_t debugDivider = 0; }; #endif /* LINUX_OBC_PDECHANDLER_H_ */ From 15b2f9a13e0ebe83b6efef48fd8434f16958125a Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 22 Nov 2021 17:55:40 +0100 Subject: [PATCH 089/465] run event parser --- generators/events/translateEvents.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp index 18f6ba50..b0a9ee6a 100644 --- a/generators/events/translateEvents.cpp +++ b/generators/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** * @brief Auto-generated event translation file. Contains 106 translations. * @details - * Generated on: 2021-10-31 17:56:40 + * Generated on: 2021-11-22 17:04:42 */ #include "translateEvents.h" From cb6db97fc1797137d7b00dd4c155f7032024f17e Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 22 Nov 2021 17:56:46 +0100 Subject: [PATCH 090/465] run object parser --- generators/objects/translateObjects.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/generators/objects/translateObjects.cpp b/generators/objects/translateObjects.cpp index 15f82c2c..48eb29e7 100644 --- a/generators/objects/translateObjects.cpp +++ b/generators/objects/translateObjects.cpp @@ -1,8 +1,8 @@ /** * @brief Auto-generated object translation file. * @details - * Contains 111 translations. - * Generated on: 2021-10-13 15:54:21 + * Contains 112 translations. + * Generated on: 2021-11-22 17:04:51 */ #include "translateObjects.h" @@ -86,6 +86,7 @@ const char *PAPB_VC0_STRING = "PAPB_VC0"; const char *PAPB_VC1_STRING = "PAPB_VC1"; const char *PAPB_VC2_STRING = "PAPB_VC2"; const char *PAPB_VC3_STRING = "PAPB_VC3"; +const char *PDEC_HANDLER_STRING = "PDEC_HANDLER"; const char *CCSDS_HANDLER_STRING = "CCSDS_HANDLER"; const char *PUS_SERVICE_6_STRING = "PUS_SERVICE_6"; const char *FSFW_OBJECTS_START_STRING = "FSFW_OBJECTS_START"; @@ -280,6 +281,8 @@ const char* translateObject(object_id_t object) { return PAPB_VC2_STRING; case 0x50000703: return PAPB_VC3_STRING; + case 0x50000704: + return PDEC_HANDLER_STRING; case 0x50000800: return CCSDS_HANDLER_STRING; case 0x51000500: From c2dbebe56be196f309118cebf2441c29f5f1c9e4 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 22 Nov 2021 17:57:33 +0100 Subject: [PATCH 091/465] gen events --- linux/fsfwconfig/events/translateEvents.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index 18f6ba50..b0a9ee6a 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** * @brief Auto-generated event translation file. Contains 106 translations. * @details - * Generated on: 2021-10-31 17:56:40 + * Generated on: 2021-11-22 17:04:42 */ #include "translateEvents.h" From ec7568337cbf082a240234eb657d0a40b8b2e9c4 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 22 Nov 2021 17:58:24 +0100 Subject: [PATCH 092/465] object parser --- linux/fsfwconfig/objects/translateObjects.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/linux/fsfwconfig/objects/translateObjects.cpp b/linux/fsfwconfig/objects/translateObjects.cpp index 15f82c2c..48eb29e7 100644 --- a/linux/fsfwconfig/objects/translateObjects.cpp +++ b/linux/fsfwconfig/objects/translateObjects.cpp @@ -1,8 +1,8 @@ /** * @brief Auto-generated object translation file. * @details - * Contains 111 translations. - * Generated on: 2021-10-13 15:54:21 + * Contains 112 translations. + * Generated on: 2021-11-22 17:04:51 */ #include "translateObjects.h" @@ -86,6 +86,7 @@ const char *PAPB_VC0_STRING = "PAPB_VC0"; const char *PAPB_VC1_STRING = "PAPB_VC1"; const char *PAPB_VC2_STRING = "PAPB_VC2"; const char *PAPB_VC3_STRING = "PAPB_VC3"; +const char *PDEC_HANDLER_STRING = "PDEC_HANDLER"; const char *CCSDS_HANDLER_STRING = "CCSDS_HANDLER"; const char *PUS_SERVICE_6_STRING = "PUS_SERVICE_6"; const char *FSFW_OBJECTS_START_STRING = "FSFW_OBJECTS_START"; @@ -280,6 +281,8 @@ const char* translateObject(object_id_t object) { return PAPB_VC2_STRING; case 0x50000703: return PAPB_VC3_STRING; + case 0x50000704: + return PDEC_HANDLER_STRING; case 0x50000800: return CCSDS_HANDLER_STRING; case 0x51000500: From 345ccf5392385a7f64f14cc89669cbe29bfd5a28 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 22 Nov 2021 18:01:16 +0100 Subject: [PATCH 093/465] transmit enable and timeout --- bsp_q7s/core/InitMission.cpp | 2 +- bsp_q7s/core/ObjectFactory.cpp | 3 +- generators/bsp_q7s_objects.csv | 1 + linux/fsfwconfig/OBSWConfig.h.in | 2 +- linux/obc/PdecHandler.cpp | 14 ++++ linux/obc/PdecHandler.h | 34 ++++++-- mission/tmtc/CCSDSHandler.cpp | 137 ++++++++++++++++++++++++++++++- mission/tmtc/CCSDSHandler.h | 58 ++++++++++++- 8 files changed, 234 insertions(+), 17 deletions(-) diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index eab396c6..bd70c1c0 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -110,7 +110,7 @@ void initmission::initTasks() { // If a command has not been read before the next one arrives, the old command will be // overwritten by the PDEC. PeriodicTaskIF* pdecHandlerTask = factory->createPeriodicTask( - "PDEC_HANDLER", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.6, missedDeadlineFunc); + "PDEC_HANDLER", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1, missedDeadlineFunc); result = pdecHandlerTask->addComponent(objects::PDEC_HANDLER); if(result != HasReturnvaluesIF::RETURN_OK) { initmission::printAddObjectError("PDEC Handler", objects::PDEC_HANDLER); diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index c7738679..ec0c085f 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -951,7 +951,8 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF *gpioComIF) { TxRateSetterIF* txRateSetterIF = new PtmeRateSetter(gpioIds::BIT_RATE_SEL, gpioComIF); CCSDSHandler* ccsdsHandler = new CCSDSHandler(objects::CCSDS_HANDLER, objects::PTME, - objects::CCSDS_PACKET_DISTRIBUTOR, txRateSetterIF); + objects::CCSDS_PACKET_DISTRIBUTOR, txRateSetterIF, gpioComIF, + gpioIds::RS485_EN_TX_CLOCK, gpioIds::RS485_EN_TX_DATA); VirtualChannel* vc = nullptr; vc = new VirtualChannel(ccsds::VC0, common::VC0_QUEUE_SIZE); diff --git a/generators/bsp_q7s_objects.csv b/generators/bsp_q7s_objects.csv index 3d8a4d40..fded183b 100644 --- a/generators/bsp_q7s_objects.csv +++ b/generators/bsp_q7s_objects.csv @@ -78,6 +78,7 @@ 0x50000701;PAPB_VC1 0x50000702;PAPB_VC2 0x50000703;PAPB_VC3 +0x50000704;PDEC_HANDLER 0x50000800;CCSDS_HANDLER 0x51000500;PUS_SERVICE_6 0x53000000;FSFW_OBJECTS_START diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index 9dbc5428..3e3bf5c3 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -37,7 +37,7 @@ debugging. */ // Set to 1 if all telemetry should be sent to the PTME IP Core #define OBSW_TM_TO_PTME 1 // Set to 1 if telecommands are received via the PDEC IP Core -#define OBSW_TC_FROM_PDEC 0 +#define OBSW_TC_FROM_PDEC 1 #define OBSW_ENABLE_TIMERS 1 #define OBSW_ADD_STAR_TRACKER 0 diff --git a/linux/obc/PdecHandler.cpp b/linux/obc/PdecHandler.cpp index d68f79a4..f99a1a30 100644 --- a/linux/obc/PdecHandler.cpp +++ b/linux/obc/PdecHandler.cpp @@ -196,6 +196,7 @@ ReturnValue_t PdecHandler::performOperation(uint8_t operationCode) { if (newTcReceived()) { handleNewTc(); } + checkLocks(); break; case State::WAIT_FOR_RECOVERY: break; @@ -237,6 +238,19 @@ bool PdecHandler::newTcReceived() { return true; } +void PdecHandler::checkLocks() { + uint32_t clcw = getClcw(); + if (!(clcw & NO_RF_MASK) && (lastClcw & NO_RF_MASK)) { + // Rf available changed from 0 to 1 + triggerEvent(CARRIER_LOCK); + } + if (!(clcw & NO_BITLOCK_MASK) && (lastClcw & NO_BITLOCK_MASK)) { + // Bit lock changed from 0 to 1 + triggerEvent(BIT_LOCK); + } + lastClcw = clcw; +} + bool PdecHandler::checkFrameAna(uint32_t pdecFar) { bool frameValid = false; FrameAna_t frameAna = static_cast((pdecFar & FRAME_ANA_MASK) >> FRAME_ANA_POSITION); diff --git a/linux/obc/PdecHandler.h b/linux/obc/PdecHandler.h index d7c7d236..83e4a253 100644 --- a/linux/obc/PdecHandler.h +++ b/linux/obc/PdecHandler.h @@ -71,6 +71,19 @@ public: */ void printClcw(); + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PDEC_HANDLER; + + //! [EXPORT] : [COMMENT] Frame acceptance report signals an invalid frame + //! P1: The frame analysis information (FrameAna field of PDEC_FAR register) + //! P2: When frame declared illegal this parameter this parameter gives information about the reason (IReason field of the PDEC_FAR register) + static const Event INVALID_TC_FRAME = MAKE_EVENT(1, severity::HIGH); + //! [EXPORT] : [COMMENT] Read invalid FAR from PDEC after startup + static const Event INVALID_FAR = MAKE_EVENT(2, severity::HIGH); + //! [EXPORT] : [COMMENT] Carrier lock detected + static const Event CARRIER_LOCK = MAKE_EVENT(3, severity::INFO); + //! [EXPORT] : [COMMENT] Bit lock detected (data valid) + static const Event BIT_LOCK = MAKE_EVENT(4, severity::INFO); + private: static const uint8_t INTERFACE_ID = CLASS_ID::PDEC_HANDLER; @@ -102,15 +115,6 @@ private: //! Invalid BC control command static const ReturnValue_t INVALID_BC_CC = MAKE_RETURN_CODE(0xAE); - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PDEC_HANDLER; - - //! [EXPORT] : [COMMENT] Frame acceptance report signals an invalid frame - //! P1: The frame analysis information (FrameAna field of PDEC_FAR register) - //! P2: When frame declared illegal this parameter this parameter gives information about the reason (IReason field of the PDEC_FAR register) - static const Event INVALID_TC_FRAME = MAKE_EVENT(1, severity::HIGH); - //! [EXPORT] : [COMMENT] Read invalid FAR from PDEC after startup - static const Event INVALID_FAR = MAKE_EVENT(2, severity::HIGH); - static const uint32_t QUEUE_SIZE = common::CCSDS_HANDLER_QUEUE_SIZE; // Action IDs @@ -172,6 +176,9 @@ private: static const uint32_t TC_SEGMENT_LEN = 1017; + static const uint32_t NO_RF_MASK = 0x8000; + static const uint32_t NO_BITLOCK_MASK = 0x4000; + /** * TCs with map addresses (also know as Map IDs) assigned to this channel will be stored in * the PDEC memory. @@ -260,6 +267,12 @@ private: */ bool newTcReceived(); + /** + * @brief Checks if carrier lock or bit lock has been detected and triggers appropriate + * event. + */ + void checkLocks(); + /** * @brief Analyzes the FramAna field (frame analysis data) of a FAR report. * @@ -362,6 +375,9 @@ private: uint32_t pdecFar = 0; uint8_t tcSegment[TC_SEGMENT_LEN]; + + // Used to check carrier and bit lock changes (default set to no rf and no bitlock) + uint32_t lastClcw = 0xC000; }; #endif /* LINUX_OBC_PDECHANDLER_H_ */ diff --git a/mission/tmtc/CCSDSHandler.cpp b/mission/tmtc/CCSDSHandler.cpp index caf99515..a9c6df27 100644 --- a/mission/tmtc/CCSDSHandler.cpp +++ b/mission/tmtc/CCSDSHandler.cpp @@ -1,24 +1,32 @@ +#include "OBSWConfig.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/serviceinterface/serviceInterfaceDefintions.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/ipc/QueueFactory.h" +#include "fsfw/events/EventManagerIF.h" + +#include #include "CCSDSHandler.h" CCSDSHandler::CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination, - TxRateSetterIF* txRateSetterIF) : + TxRateSetterIF* txRateSetterIF, GpioIF* gpioIF, gpioId_t enTxClock, gpioId_t enTxData) : SystemObject(objectId), ptmeId(ptmeId), tcDestination(tcDestination), parameterHelper(this), actionHelper( - this, nullptr), txRateSetterIF(txRateSetterIF) { + this, nullptr), txRateSetterIF(txRateSetterIF), gpioIF(gpioIF), enTxClock( + enTxClock), enTxData(enTxData) { commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); + eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 2); } CCSDSHandler::~CCSDSHandler() { } ReturnValue_t CCSDSHandler::performOperation(uint8_t operationCode) { + checkEvents(); readCommandQueue(); handleTelemetry(); handleTelecommands(); + checkTxTimer(); return RETURN_OK; } @@ -71,6 +79,27 @@ ReturnValue_t CCSDSHandler::initialize() { iter->second->setPtmeObject(ptme); } + EventManagerIF* manager = ObjectManager::instance()->get( + objects::EVENT_MANAGER); + if (manager == nullptr) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::error << "CCSDSHandler::initialize: Invalid event manager" << std::endl; +#endif + return RETURN_FAILED; + } + result = manager->registerListener(eventQueue->getId()); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = manager->subscribeToEventRange(eventQueue->getId(), + event::getEventId(PdecHandler::CARRIER_LOCK), event::getEventId(PdecHandler::BIT_LOCK)); + if (result != HasReturnvaluesIF::RETURN_OK) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::error << "CCSDSHandler::initialize: Failed to subscribe to events from PDEC " + "handler" << std::endl; +#endif + return result; + } return result; } @@ -157,13 +186,113 @@ ReturnValue_t CCSDSHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { switch(actionId) { - case SET_LOW_RATE: + case SET_LOW_RATE: { txRateSetterIF->setRate(BitRates::RATE_400KHZ); return EXECUTION_FINISHED; - case SET_HIGH_RATE: + } + case SET_HIGH_RATE: { txRateSetterIF->setRate(BitRates::RATE_2000KHZ); return EXECUTION_FINISHED; + } + case EN_TRANSMITTER: { + enableTransmit(); + return EXECUTION_FINISHED; + } + case DIS_TRANSMITTER: { + disableTransmit(); + return EXECUTION_FINISHED; + } default: return COMMAND_NOT_IMPLEMENTED; } } + +void CCSDSHandler::checkEvents() { + EventMessage event; + for (ReturnValue_t result = eventQueue->receiveMessage(&event); + result == RETURN_OK; result = eventQueue->receiveMessage(&event)) { + switch (event.getMessageId()) { + case EventMessage::EVENT_MESSAGE: + handleEvent(&event); + break; + default: + sif::debug << "CCSDSHandler::checkEvents: Did not subscribe to this event message" + << std::endl; + break; + } + } +} + + +void CCSDSHandler::handleEvent(EventMessage* eventMessage) { + Event event = eventMessage->getEvent(); + switch(event){ + case PdecHandler::BIT_LOCK: { + handleBitLockEvent(); + break; + } + case PdecHandler::CARRIER_LOCK: { + handleCarrierLockEvent(); + break; + } + default: + sif::debug << "CCSDSHandler::handleEvent: Did not subscribe to this event" + << std::endl; + break; + } +} + +void CCSDSHandler::handleBitLockEvent() { + if(transmitterCountdown.isBusy()) { + // Transmitter already enabled + return; + } + enableTransmit(); +} + +void CCSDSHandler::handleCarrierLockEvent() { + if (!enableTxWhenCarrierLock) { + return; + } + enableTransmit(); +} + +void CCSDSHandler::forwardLinkstate() { + VirtualChannelMapIter iter; + for(iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { + iter->second->setLinkState(linkState); + } +} + +void CCSDSHandler::enableTransmit() { + if(transmitterCountdown.isBusy()) { + // Transmitter already enabled + return; + } + transmitterCountdown.setTimeout(TRANSMITTER_TIMEOUT); +#if BOARD_TE0720 == 0 + gpioIF->pullLow(enTxClock); + gpioIF->pullLow(enTxData); +#endif /* BOARD_TE0720 == 0 */ + linkState = UP; + // Set link state of all virtual channels to link up + forwardLinkstate(); +} + +void CCSDSHandler::checkTxTimer() { + if(linkState == DOWN) { + return; + } + if (transmitterCountdown.hasTimedOut()) { + disableTransmit(); + } +} + +void CCSDSHandler::disableTransmit() { +#if BOARD_TE0720 == 0 + gpioIF->pullHigh(enTxClock); + gpioIF->pullHigh(enTxData); +#endif /* BOARD_TE0720 == 0 */ + linkState = DOWN; + forwardLinkstate(); +} diff --git a/mission/tmtc/CCSDSHandler.h b/mission/tmtc/CCSDSHandler.h index 6ed5abbe..cdab72e0 100644 --- a/mission/tmtc/CCSDSHandler.h +++ b/mission/tmtc/CCSDSHandler.h @@ -10,7 +10,11 @@ #include "fsfw/parameters/ParameterHelper.h" #include "fsfw/action/ActionHelper.h" #include "fsfw/action/HasActionsIF.h" +#include "fsfw/timemanager/Countdown.h" +#include "fsfw/events/EventMessage.h" #include "linux/obc/TxRateSetterIF.h" +#include "fsfw_hal/common/gpio/gpioDefinitions.h" +#include "fsfw_hal/common/gpio/GpioIF.h" #include "VirtualChannel.h" #include @@ -39,9 +43,12 @@ public: * @param tcDestination Object ID of object handling received TC space packets * @param txRateSetter Object providing the functionality to switch the input bitrate of * the S-Band transceiver. + * @param gpioIF Required to enable TX data and TX clock RS485 transceiver chips. + * @param enTxClock GPIO ID of RS485 tx clock enable + * @param enTxData GPIO ID of RS485 tx data enable */ CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination, - TxRateSetterIF* txRateSetterIF); + TxRateSetterIF* txRateSetterIF, GpioIF* gpioIF, gpioId_t enTxClock, gpioId_t enTxData); ~CCSDSHandler(); @@ -76,10 +83,19 @@ private: static const ActionId_t SET_LOW_RATE = 0; static const ActionId_t SET_HIGH_RATE = 1; + static const ActionId_t EN_TRANSMITTER = 2; + static const ActionId_t DIS_TRANSMITTER = 3; //! [EXPORT] : [COMMENT] Received action message with unknown action id static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xA0); + // syrlinks must not be transmitting more than 15 minutes (according to datasheet) +// static const uint32_t TRANSMITTER_TIMEOUT = 900000; //900000 ms = 15 min + static const uint32_t TRANSMITTER_TIMEOUT = 10000; //900000 ms = 15 min + + static const bool UP = true; + static const bool DOWN = false; + using VirtualChannelMap = std::unordered_map; using VirtualChannelMapIter = VirtualChannelMap::iterator; @@ -91,6 +107,7 @@ private: object_id_t tcDestination; MessageQueueIF* commandQueue = nullptr; + MessageQueueIF* eventQueue = nullptr; ParameterHelper parameterHelper; @@ -100,9 +117,48 @@ private: TxRateSetterIF* txRateSetterIF = nullptr; + GpioIF* gpioIF = nullptr; + gpioId_t enTxClock = gpio::NO_GPIO; + gpioId_t enTxData = gpio::NO_GPIO; + + // Countdown to disable transmitter after 15 minutes + Countdown transmitterCountdown; + + // When true transmitting is started as soon as carrier lock has been detected + bool enableTxWhenCarrierLock = false; + + bool linkState = DOWN; + void readCommandQueue(void); void handleTelemetry(); void handleTelecommands(); + void checkEvents(); + void handleEvent(EventMessage* eventMessage); + + void handleBitLockEvent(); + void handleCarrierLockEvent(); + + /** + * @brief Forward link state to virtual channels. + */ + void forwardLinkstate(); + + /** + * @brief Starts transmit timer and enables transmitter. + */ + void enableTransmit(); + + /** + * @brief Checks Tx timer for timeout and disables RS485 tx clock and tx data in case + * timer has expired. + */ + void checkTxTimer(); + + /** + * @brief Disables the transmitter by pulling the enable tx clock and tx data pin of the + * RS485 transceiver chips to high. + */ + void disableTransmit(); }; #endif /* CCSDSHANDLER_H_ */ From 542aa994b712c7c2cfaea36f8c14194a4a773f50 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Wed, 24 Nov 2021 15:55:25 +0100 Subject: [PATCH 094/465] link state now detected by bit and carrier lock flags --- bsp_q7s/core/InitMission.cpp | 2 +- bsp_q7s/core/ObjectFactory.cpp | 4 ++-- linux/fsfwconfig/OBSWConfig.h.in | 5 +++-- mission/tmtc/CCSDSHandler.cpp | 10 +++++----- mission/tmtc/CCSDSHandler.h | 8 ++++++-- mission/tmtc/VirtualChannel.cpp | 4 ++-- mission/tmtc/VirtualChannel.h | 6 +----- 7 files changed, 20 insertions(+), 19 deletions(-) diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index bd70c1c0..7923a2cd 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -110,7 +110,7 @@ void initmission::initTasks() { // If a command has not been read before the next one arrives, the old command will be // overwritten by the PDEC. PeriodicTaskIF* pdecHandlerTask = factory->createPeriodicTask( - "PDEC_HANDLER", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1, missedDeadlineFunc); + "PDEC_HANDLER", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc); result = pdecHandlerTask->addComponent(objects::PDEC_HANDLER); if(result != HasReturnvaluesIF::RETURN_OK) { initmission::printAddObjectError("PDEC Handler", objects::PDEC_HANDLER); diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index ec0c085f..bf8a2fba 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -981,10 +981,10 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF *gpioComIF) { #if BOARD_TE0720 == 0 GpioCookie* gpioRS485Chip = new GpioCookie; gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_TX_CLOCK, "RS485 Transceiver", - gpio::Direction::OUT, gpio::HIGH); + gpio::Direction::OUT, gpio::LOW); gpioRS485Chip->addGpio(gpioIds::RS485_EN_TX_CLOCK, gpio); gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_TX_DATA, "RS485 Transceiver", - gpio::Direction::OUT, gpio::HIGH); + gpio::Direction::OUT, gpio::LOW); gpioRS485Chip->addGpio(gpioIds::RS485_EN_TX_DATA, gpio); // Default configuration enables RX channels (RXEN = LOW) diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index 3e3bf5c3..0ca7bae2 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -39,6 +39,8 @@ 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 @@ -92,7 +94,6 @@ debugging. */ #define OBSW_TEST_TE7020_HEATER 0 #define OBSW_TEST_GPIO_OPEN_BY_LABEL 0 #define OBSW_TEST_GPIO_OPEN_BY_LINE_NAME 0 -#define OBSW_LINK_IS_UP 1 #define OBSW_DEBUG_P60DOCK 0 #define OBSW_DEBUG_PDU1 0 @@ -109,7 +110,7 @@ debugging. */ #define OBSW_DEBUG_STARTRACKER 0 #define OBSW_DEBUG_PLOC_MPSOC 0 #define OBSW_DEBUG_PLOC_SUPERVISOR 0 -#define OBSW_DEBUG_PDEC_HANDLER 0 +#define OBSW_DEBUG_PDEC_HANDLER 1 /*******************************************************************/ /** Hardcoded */ diff --git a/mission/tmtc/CCSDSHandler.cpp b/mission/tmtc/CCSDSHandler.cpp index a9c6df27..71307bd9 100644 --- a/mission/tmtc/CCSDSHandler.cpp +++ b/mission/tmtc/CCSDSHandler.cpp @@ -1,4 +1,3 @@ -#include "OBSWConfig.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/serviceinterface/serviceInterfaceDefintions.h" #include "fsfw/objectmanager/ObjectManager.h" @@ -271,8 +270,8 @@ void CCSDSHandler::enableTransmit() { } transmitterCountdown.setTimeout(TRANSMITTER_TIMEOUT); #if BOARD_TE0720 == 0 - gpioIF->pullLow(enTxClock); - gpioIF->pullLow(enTxData); + gpioIF->pullHigh(enTxClock); + gpioIF->pullHigh(enTxData); #endif /* BOARD_TE0720 == 0 */ linkState = UP; // Set link state of all virtual channels to link up @@ -290,9 +289,10 @@ void CCSDSHandler::checkTxTimer() { void CCSDSHandler::disableTransmit() { #if BOARD_TE0720 == 0 - gpioIF->pullHigh(enTxClock); - gpioIF->pullHigh(enTxData); + gpioIF->pullLow(enTxClock); + gpioIF->pullLow(enTxData); #endif /* BOARD_TE0720 == 0 */ linkState = DOWN; forwardLinkstate(); + transmitterCountdown.setTimeout(0); } diff --git a/mission/tmtc/CCSDSHandler.h b/mission/tmtc/CCSDSHandler.h index cdab72e0..6fb6168b 100644 --- a/mission/tmtc/CCSDSHandler.h +++ b/mission/tmtc/CCSDSHandler.h @@ -89,9 +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 == 0 // syrlinks must not be transmitting more than 15 minutes (according to datasheet) -// static const uint32_t TRANSMITTER_TIMEOUT = 900000; //900000 ms = 15 min - static const uint32_t TRANSMITTER_TIMEOUT = 10000; //900000 ms = 15 min + 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 */ static const bool UP = true; static const bool DOWN = false; diff --git a/mission/tmtc/VirtualChannel.cpp b/mission/tmtc/VirtualChannel.cpp index 3423692b..0273f5ce 100644 --- a/mission/tmtc/VirtualChannel.cpp +++ b/mission/tmtc/VirtualChannel.cpp @@ -64,6 +64,6 @@ void VirtualChannel::setPtmeObject(PtmeIF* ptme_) { ptme = ptme_; } -void VirtualChannel::setLinkState(bool linkIsUp) { - linkIsUp = linkIsUp; +void VirtualChannel::setLinkState(bool linkIsUp_) { + linkIsUp = linkIsUp_; } diff --git a/mission/tmtc/VirtualChannel.h b/mission/tmtc/VirtualChannel.h index d7d95cb7..c6e2eb6d 100644 --- a/mission/tmtc/VirtualChannel.h +++ b/mission/tmtc/VirtualChannel.h @@ -38,7 +38,7 @@ class VirtualChannel: public AcceptsTelemetryIF, public HasReturnvaluesIF { * @brief Can be used by the owner to set the link state. Packets will be discarded if link * to ground station is down. */ - void setLinkState(bool linkIsUp); + void setLinkState(bool linkIsUp_); private: @@ -46,11 +46,7 @@ private: MessageQueueIF* tmQueue = nullptr; uint8_t vcId; -#if OBSW_LINK_IS_UP == 1 - bool linkIsUp = true; -#else bool linkIsUp = false; -#endif /* OBSW_LINK_IS_UP == 1 */ StorageManagerIF* tmStore = nullptr; }; From 34897aceae14dc5dac2d71f4c40faa3e025d1154 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Wed, 24 Nov 2021 18:29:14 +0100 Subject: [PATCH 095/465] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index b2cc2354..aabbb129 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit b2cc2354d410b0bc0d80c481bfd37afc580e63cf +Subproject commit aabbb129a6df1d33cf10770a5ecb6336c698f0e6 From b4479d6a7da9cf3ad87fa12d137a6c6a58935f87 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Wed, 24 Nov 2021 18:29:34 +0100 Subject: [PATCH 096/465] ccsds handler class id --- common/config/commonClassIds.h | 1 + 1 file changed, 1 insertion(+) diff --git a/common/config/commonClassIds.h b/common/config/commonClassIds.h index 605ace3b..00b5ca25 100644 --- a/common/config/commonClassIds.h +++ b/common/config/commonClassIds.h @@ -22,6 +22,7 @@ enum commonClassIds: uint8_t { GOM_SPACE_HANDLER, //GOMS PLOC_MEMORY_DUMPER, //PLMEMDUMP PDEC_HANDLER, //PDEC + CCSDS_HANDLER, //PDEC COMMON_CLASS_ID_END // [EXPORT] : [END] }; From 1be7208f47cd87967295bba8fd568beedec0e186 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 24 Nov 2021 18:58:34 +0100 Subject: [PATCH 097/465] tmtc and fsfw update --- fsfw | 2 +- tmtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsfw b/fsfw index d8823f12..d8580074 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit d8823f12f1ff5ff7ffdf20f03199ace3807851b2 +Subproject commit d8580074c2730d861353ab47e659afeb707afe71 diff --git a/tmtc b/tmtc index 46d7a15e..1d374230 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 46d7a15edf42b7f7e709c49ef9a162a18c45f56a +Subproject commit 1d374230b34606d8b6aa4df1335befec316a1e35 From 23d9f56308e480fa1ef821506cfff382122058dc Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 25 Nov 2021 08:24:24 +0100 Subject: [PATCH 098/465] star tracker startup immediately --- bsp_q7s/core/ObjectFactory.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index bf8a2fba..83b59d08 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -171,7 +171,8 @@ void ObjectFactory::produce(void* args) { q7s::UART_STAR_TRACKER_DEV, UartModes::NON_CANONICAL, uart::STAR_TRACKER_BAUD, StarTracker::MAX_FRAME_SIZE* 2 + 2); starTrackerCookie->setNoFixedSizeReply(); - new StarTrackerHandler(objects::START_TRACKER, objects::UART_COM_IF, starTrackerCookie); + StarTrackerHandler* starTrackerHandler = new StarTrackerHandler(objects::START_TRACKER, objects::UART_COM_IF, starTrackerCookie); + starTrackerHandler->setStartUpImmediately(); #endif /* OBSW_ADD_STAR_TRACKER == 1 */ #endif /* TE7020 == 0 */ From be75332be7608bfc7380d28775ed933f0da61470 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 25 Nov 2021 14:03:21 +0100 Subject: [PATCH 099/465] update event list --- generators/bsp_q7s_events.csv | 212 ++++++++++---------- generators/events/translateEvents.cpp | 2 +- linux/fsfwconfig/OBSWConfig.h.in | 2 +- linux/fsfwconfig/events/translateEvents.cpp | 2 +- 4 files changed, 109 insertions(+), 109 deletions(-) diff --git a/generators/bsp_q7s_events.csv b/generators/bsp_q7s_events.csv index 165ad708..48e9705c 100644 --- a/generators/bsp_q7s_events.csv +++ b/generators/bsp_q7s_events.csv @@ -1,106 +1,106 @@ -2200;STORE_SEND_WRITE_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2201;STORE_WRITE_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2202;STORE_SEND_READ_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2203;STORE_READ_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2204;UNEXPECTED_MSG;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2205;STORING_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2206;TM_DUMP_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2207;STORE_INIT_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2208;STORE_INIT_EMPTY;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2209;STORE_CONTENT_CORRUPTED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2210;STORE_INITIALIZE;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2211;INIT_DONE;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2212;DUMP_FINISHED;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2213;DELETION_FINISHED;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2214;DELETION_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2215;AUTO_CATALOGS_SENDING_FAILED;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2600;GET_DATA_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/storagemanager/StorageManagerIF.h -2601;STORE_DATA_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/storagemanager/StorageManagerIF.h -2800;DEVICE_BUILDING_COMMAND_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2801;DEVICE_SENDING_COMMAND_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2802;DEVICE_REQUESTING_REPLY_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2803;DEVICE_READING_REPLY_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2804;DEVICE_INTERPRETING_REPLY_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2805;DEVICE_MISSED_REPLY;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2806;DEVICE_UNKNOWN_REPLY;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2807;DEVICE_UNREQUESTED_REPLY;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2808;INVALID_DEVICE_COMMAND;LOW;Indicates a SW bug in child class.;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2809;MONITORING_LIMIT_EXCEEDED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2810;MONITORING_AMBIGUOUS;HIGH;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -4201;FUSE_CURRENT_HIGH;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/power/Fuse.h -4202;FUSE_WENT_OFF;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/power/Fuse.h -4204;POWER_ABOVE_HIGH_LIMIT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/power/Fuse.h -4205;POWER_BELOW_LOW_LIMIT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/power/Fuse.h -4300;SWITCH_WENT_OFF;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/power/PowerSwitchIF.h -5000;HEATER_ON;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/Heater.h -5001;HEATER_OFF;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/Heater.h -5002;HEATER_TIMEOUT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/Heater.h -5003;HEATER_STAYED_ON;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/Heater.h -5004;HEATER_STAYED_OFF;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/Heater.h -5200;TEMP_SENSOR_HIGH;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/AbstractTemperatureSensor.h -5201;TEMP_SENSOR_LOW;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/AbstractTemperatureSensor.h -5202;TEMP_SENSOR_GRADIENT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/AbstractTemperatureSensor.h -5901;COMPONENT_TEMP_LOW;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h -5902;COMPONENT_TEMP_HIGH;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h -5903;COMPONENT_TEMP_OOL_LOW;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h -5904;COMPONENT_TEMP_OOL_HIGH;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h -5905;TEMP_NOT_IN_OP_RANGE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h -7101;FDIR_CHANGED_STATE;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/fdir/FailureIsolationBase.h -7102;FDIR_STARTS_RECOVERY;MEDIUM;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/fdir/FailureIsolationBase.h -7103;FDIR_TURNS_OFF_DEVICE;MEDIUM;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/fdir/FailureIsolationBase.h -7201;MONITOR_CHANGED_STATE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h -7202;VALUE_BELOW_LOW_LIMIT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h -7203;VALUE_ABOVE_HIGH_LIMIT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h -7204;VALUE_OUT_OF_RANGE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h -7301;SWITCHING_TM_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/datapool/HkSwitchHelper.h -7400;CHANGING_MODE;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h -7401;MODE_INFO;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h -7402;FALLBACK_FAILED;HIGH;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h -7403;MODE_TRANSITION_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h -7404;CANT_KEEP_MODE;HIGH;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h -7405;OBJECT_IN_INVALID_MODE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h -7406;FORCING_MODE;MEDIUM;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h -7407;MODE_CMD_REJECTED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h -7506;HEALTH_INFO;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h -7507;CHILD_CHANGED_HEALTH;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h -7508;CHILD_PROBLEMS;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h -7509;OVERWRITING_HEALTH;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h -7510;TRYING_RECOVERY;MEDIUM;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h -7511;RECOVERY_STEP;MEDIUM;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h -7512;RECOVERY_DONE;MEDIUM;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h -7900;RF_AVAILABLE;INFO;A RF available signal was detected. P1: raw RFA state, P2: 0;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h -7901;RF_LOST;INFO;A previously found RF available signal was lost. P1: raw RFA state, P2: 0;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h -7902;BIT_LOCK;INFO;A Bit Lock signal. Was detected. P1: raw BLO state, P2: 0;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h -7903;BIT_LOCK_LOST;INFO;A previously found Bit Lock signal was lost. P1: raw BLO state, P2: 0;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h -7905;FRAME_PROCESSING_FAILED;LOW;The CCSDS Board could not interpret a TC;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h -8900;CLOCK_SET;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/pus/Service9TimeManagement.h -8901;CLOCK_SET_FAILURE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/pus/Service9TimeManagement.h -9700;TEST;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/pus/Service17Test.h -10600;CHANGE_OF_SETUP_PARAMETER;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h -11101;MEMORY_READ_RPT_CRC_FAILURE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/PlocMPSoCHandler.h -11102;ACK_FAILURE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/PlocMPSoCHandler.h -11103;EXE_FAILURE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/PlocMPSoCHandler.h -11104;CRC_FAILURE_EVENT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/PlocMPSoCHandler.h -11201;SELF_TEST_I2C_FAILURE;LOW;Get self test result returns I2C failure P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h -11202;SELF_TEST_SPI_FAILURE;LOW;Get self test result returns SPI failure. This concerns the MTM connectivity. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h -11203;SELF_TEST_ADC_FAILURE;LOW;Get self test result returns failure in measurement of current and temperature. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h -11204;SELF_TEST_PWM_FAILURE;LOW;Get self test result returns PWM failure which concerns the coil actuation. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h -11205;SELF_TEST_TC_FAILURE;LOW;Get self test result returns TC failure (system failure) P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h -11206;SELF_TEST_MTM_RANGE_FAILURE;LOW;Get self test result returns failure that MTM values were outside of the expected range. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h -11207;SELF_TEST_COIL_CURRENT_FAILURE;LOW;Get self test result returns failure indicating that the coil current was outside of the expected range P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h -11208;INVALID_ERROR_BYTE;LOW;Received invalid error byte. This indicates an error of the communication link between IMTQ and OBC.;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h -11301;ERROR_STATE;HIGH;Reaction wheel signals an error state;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/RwHandler.h -11501;SUPV_MEMORY_READ_RPT_CRC_FAILURE;LOW;PLOC supervisor crc failure in telemetry packet;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h -11502;SUPV_ACK_FAILURE;LOW;PLOC supervisor received acknowledgment failure report;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h -11503;SUPV_EXE_FAILURE;LOW;PLOC received execution failure report;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h -11504;SUPV_CRC_FAILURE_EVENT;LOW;PLOC supervisor reply has invalid crc;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h -11600;SANITIZATION_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/memory/SdCardManager.h -11700;UPDATE_FILE_NOT_EXISTS;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h -11701;ACTION_COMMANDING_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h -11702;UPDATE_AVAILABLE_FAILED;LOW;Supervisor handler replied action message indicating a command execution failure of the update available command;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h -11703;UPDATE_TRANSFER_FAILED;LOW;Supervisor handler failed to transfer an update space packet. P1: Parameter holds the number of update packets already sent (inclusive the failed packet);C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h -11704;UPDATE_VERIFY_FAILED;LOW;Supervisor failed to execute the update verify command.;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h -11705;UPDATE_FINISHED;INFO;MPSoC update successful completed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h -11800;SEND_MRAM_DUMP_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocMemoryDumper.h -11801;MRAM_DUMP_FAILED;LOW;Received completion failure report form PLOC supervisor handler P1: MRAM start address of failing dump command;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocMemoryDumper.h -11802;MRAM_DUMP_FINISHED;LOW;MRAM dump finished successfully;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocMemoryDumper.h +2200;STORE_SEND_WRITE_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2201;STORE_WRITE_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2202;STORE_SEND_READ_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2203;STORE_READ_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2204;UNEXPECTED_MSG;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2205;STORING_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2206;TM_DUMP_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2207;STORE_INIT_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2208;STORE_INIT_EMPTY;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2209;STORE_CONTENT_CORRUPTED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2210;STORE_INITIALIZE;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2211;INIT_DONE;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2212;DUMP_FINISHED;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2213;DELETION_FINISHED;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2214;DELETION_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2215;AUTO_CATALOGS_SENDING_FAILED;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2600;GET_DATA_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/storagemanager/StorageManagerIF.h +2601;STORE_DATA_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/storagemanager/StorageManagerIF.h +2800;DEVICE_BUILDING_COMMAND_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2801;DEVICE_SENDING_COMMAND_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2802;DEVICE_REQUESTING_REPLY_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2803;DEVICE_READING_REPLY_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2804;DEVICE_INTERPRETING_REPLY_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2805;DEVICE_MISSED_REPLY;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2806;DEVICE_UNKNOWN_REPLY;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2807;DEVICE_UNREQUESTED_REPLY;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2808;INVALID_DEVICE_COMMAND;LOW;Indicates a SW bug in child class.;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2809;MONITORING_LIMIT_EXCEEDED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2810;MONITORING_AMBIGUOUS;HIGH;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +4201;FUSE_CURRENT_HIGH;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/power/Fuse.h +4202;FUSE_WENT_OFF;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/power/Fuse.h +4204;POWER_ABOVE_HIGH_LIMIT;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/power/Fuse.h +4205;POWER_BELOW_LOW_LIMIT;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/power/Fuse.h +4300;SWITCH_WENT_OFF;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/power/PowerSwitchIF.h +5000;HEATER_ON;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/thermal/Heater.h +5001;HEATER_OFF;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/thermal/Heater.h +5002;HEATER_TIMEOUT;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/thermal/Heater.h +5003;HEATER_STAYED_ON;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/thermal/Heater.h +5004;HEATER_STAYED_OFF;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/thermal/Heater.h +5200;TEMP_SENSOR_HIGH;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/thermal/AbstractTemperatureSensor.h +5201;TEMP_SENSOR_LOW;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/thermal/AbstractTemperatureSensor.h +5202;TEMP_SENSOR_GRADIENT;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/thermal/AbstractTemperatureSensor.h +5901;COMPONENT_TEMP_LOW;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h +5902;COMPONENT_TEMP_HIGH;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h +5903;COMPONENT_TEMP_OOL_LOW;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h +5904;COMPONENT_TEMP_OOL_HIGH;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h +5905;TEMP_NOT_IN_OP_RANGE;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h +7101;FDIR_CHANGED_STATE;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/fdir/FailureIsolationBase.h +7102;FDIR_STARTS_RECOVERY;MEDIUM;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/fdir/FailureIsolationBase.h +7103;FDIR_TURNS_OFF_DEVICE;MEDIUM;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/fdir/FailureIsolationBase.h +7201;MONITOR_CHANGED_STATE;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h +7202;VALUE_BELOW_LOW_LIMIT;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h +7203;VALUE_ABOVE_HIGH_LIMIT;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h +7204;VALUE_OUT_OF_RANGE;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h +7301;SWITCHING_TM_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/datapool/HkSwitchHelper.h +7400;CHANGING_MODE;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/modes/HasModesIF.h +7401;MODE_INFO;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/modes/HasModesIF.h +7402;FALLBACK_FAILED;HIGH;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/modes/HasModesIF.h +7403;MODE_TRANSITION_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/modes/HasModesIF.h +7404;CANT_KEEP_MODE;HIGH;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/modes/HasModesIF.h +7405;OBJECT_IN_INVALID_MODE;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/modes/HasModesIF.h +7406;FORCING_MODE;MEDIUM;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/modes/HasModesIF.h +7407;MODE_CMD_REJECTED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/modes/HasModesIF.h +7506;HEALTH_INFO;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/health/HasHealthIF.h +7507;CHILD_CHANGED_HEALTH;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/health/HasHealthIF.h +7508;CHILD_PROBLEMS;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/health/HasHealthIF.h +7509;OVERWRITING_HEALTH;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/health/HasHealthIF.h +7510;TRYING_RECOVERY;MEDIUM;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/health/HasHealthIF.h +7511;RECOVERY_STEP;MEDIUM;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/health/HasHealthIF.h +7512;RECOVERY_DONE;MEDIUM;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/health/HasHealthIF.h +7900;RF_AVAILABLE;INFO;A RF available signal was detected. P1: raw RFA state, P2: 0;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h +7901;RF_LOST;INFO;A previously found RF available signal was lost. P1: raw RFA state, P2: 0;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h +7902;BIT_LOCK;INFO;A Bit Lock signal. Was detected. P1: raw BLO state, P2: 0;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h +7903;BIT_LOCK_LOST;INFO;A previously found Bit Lock signal was lost. P1: raw BLO state, P2: 0;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h +7905;FRAME_PROCESSING_FAILED;LOW;The CCSDS Board could not interpret a TC;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h +8900;CLOCK_SET;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/pus/Service9TimeManagement.h +8901;CLOCK_SET_FAILURE;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/pus/Service9TimeManagement.h +9700;TEST;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/pus/Service17Test.h +10600;CHANGE_OF_SETUP_PARAMETER;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h +11101;MEMORY_READ_RPT_CRC_FAILURE;LOW;;/home/eive/EIVE/Robin/eive-obsw/mission/devices/PlocMPSoCHandler.h +11102;ACK_FAILURE;LOW;;/home/eive/EIVE/Robin/eive-obsw/mission/devices/PlocMPSoCHandler.h +11103;EXE_FAILURE;LOW;;/home/eive/EIVE/Robin/eive-obsw/mission/devices/PlocMPSoCHandler.h +11104;CRC_FAILURE_EVENT;LOW;;/home/eive/EIVE/Robin/eive-obsw/mission/devices/PlocMPSoCHandler.h +11201;SELF_TEST_I2C_FAILURE;LOW;Get self test result returns I2C failure P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;/home/eive/EIVE/Robin/eive-obsw/mission/devices/IMTQHandler.h +11202;SELF_TEST_SPI_FAILURE;LOW;Get self test result returns SPI failure. This concerns the MTM connectivity. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;/home/eive/EIVE/Robin/eive-obsw/mission/devices/IMTQHandler.h +11203;SELF_TEST_ADC_FAILURE;LOW;Get self test result returns failure in measurement of current and temperature. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;/home/eive/EIVE/Robin/eive-obsw/mission/devices/IMTQHandler.h +11204;SELF_TEST_PWM_FAILURE;LOW;Get self test result returns PWM failure which concerns the coil actuation. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;/home/eive/EIVE/Robin/eive-obsw/mission/devices/IMTQHandler.h +11205;SELF_TEST_TC_FAILURE;LOW;Get self test result returns TC failure (system failure) P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;/home/eive/EIVE/Robin/eive-obsw/mission/devices/IMTQHandler.h +11206;SELF_TEST_MTM_RANGE_FAILURE;LOW;Get self test result returns failure that MTM values were outside of the expected range. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;/home/eive/EIVE/Robin/eive-obsw/mission/devices/IMTQHandler.h +11207;SELF_TEST_COIL_CURRENT_FAILURE;LOW;Get self test result returns failure indicating that the coil current was outside of the expected range P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;/home/eive/EIVE/Robin/eive-obsw/mission/devices/IMTQHandler.h +11208;INVALID_ERROR_BYTE;LOW;Received invalid error byte. This indicates an error of the communication link between IMTQ and OBC.;/home/eive/EIVE/Robin/eive-obsw/mission/devices/IMTQHandler.h +11301;ERROR_STATE;HIGH;Reaction wheel signals an error state;/home/eive/EIVE/Robin/eive-obsw/mission/devices/RwHandler.h +11501;SUPV_MEMORY_READ_RPT_CRC_FAILURE;LOW;PLOC supervisor crc failure in telemetry packet;/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/devices/PlocSupervisorHandler.h +11502;SUPV_ACK_FAILURE;LOW;PLOC supervisor received acknowledgment failure report;/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/devices/PlocSupervisorHandler.h +11503;SUPV_EXE_FAILURE;LOW;PLOC received execution failure report;/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/devices/PlocSupervisorHandler.h +11504;SUPV_CRC_FAILURE_EVENT;LOW;PLOC supervisor reply has invalid crc;/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/devices/PlocSupervisorHandler.h +11600;SANITIZATION_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/memory/SdCardManager.h +11700;UPDATE_FILE_NOT_EXISTS;LOW;;/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/devices/PlocUpdater.h +11701;ACTION_COMMANDING_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/devices/PlocUpdater.h +11702;UPDATE_AVAILABLE_FAILED;LOW;Supervisor handler replied action message indicating a command execution failure of the update available command;/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/devices/PlocUpdater.h +11703;UPDATE_TRANSFER_FAILED;LOW;Supervisor handler failed to transfer an update space packet. P1: Parameter holds the number of update packets already sent (inclusive the failed packet);/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/devices/PlocUpdater.h +11704;UPDATE_VERIFY_FAILED;LOW;Supervisor failed to execute the update verify command.;/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/devices/PlocUpdater.h +11705;UPDATE_FINISHED;INFO;MPSoC update successful completed;/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/devices/PlocUpdater.h +11800;SEND_MRAM_DUMP_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/devices/PlocMemoryDumper.h +11801;MRAM_DUMP_FAILED;LOW;Received completion failure report form PLOC supervisor handler P1: MRAM start address of failing dump command;/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/devices/PlocMemoryDumper.h +11802;MRAM_DUMP_FINISHED;LOW;MRAM dump finished successfully;/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/devices/PlocMemoryDumper.h diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp index b0a9ee6a..ffb6f6b3 100644 --- a/generators/events/translateEvents.cpp +++ b/generators/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** * @brief Auto-generated event translation file. Contains 106 translations. * @details - * Generated on: 2021-11-22 17:04:42 + * Generated on: 2021-11-25 13:58:03 */ #include "translateEvents.h" diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index 0ca7bae2..663ef00b 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -110,7 +110,7 @@ debugging. */ #define OBSW_DEBUG_STARTRACKER 0 #define OBSW_DEBUG_PLOC_MPSOC 0 #define OBSW_DEBUG_PLOC_SUPERVISOR 0 -#define OBSW_DEBUG_PDEC_HANDLER 1 +#define OBSW_DEBUG_PDEC_HANDLER 0 /*******************************************************************/ /** Hardcoded */ diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index b0a9ee6a..ffb6f6b3 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** * @brief Auto-generated event translation file. Contains 106 translations. * @details - * Generated on: 2021-11-22 17:04:42 + * Generated on: 2021-11-25 13:58:03 */ #include "translateEvents.h" From fa89da4438e35001cae88c374ebe6ae8507d93a9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 25 Nov 2021 14:07:05 +0100 Subject: [PATCH 100/465] update event list --- generators/bsp_q7s_events.csv | 14 +++++++ generators/events/event_parser.py | 2 +- generators/events/translateEvents.cpp | 46 ++++++++++++++++++++- linux/fsfwconfig/events/translateEvents.cpp | 46 ++++++++++++++++++++- 4 files changed, 103 insertions(+), 5 deletions(-) diff --git a/generators/bsp_q7s_events.csv b/generators/bsp_q7s_events.csv index 48e9705c..7de6a92c 100644 --- a/generators/bsp_q7s_events.csv +++ b/generators/bsp_q7s_events.csv @@ -77,6 +77,16 @@ 8901;CLOCK_SET_FAILURE;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/pus/Service9TimeManagement.h 9700;TEST;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/pus/Service17Test.h 10600;CHANGE_OF_SETUP_PARAMETER;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h +10900;GPIO_PULL_HIGH_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/linux/devices/HeaterHandler.h +10901;GPIO_PULL_LOW_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/linux/devices/HeaterHandler.h +10902;SWITCH_ALREADY_ON;LOW;;/home/eive/EIVE/Robin/eive-obsw/linux/devices/HeaterHandler.h +10903;SWITCH_ALREADY_OFF;LOW;;/home/eive/EIVE/Robin/eive-obsw/linux/devices/HeaterHandler.h +10904;MAIN_SWITCH_TIMEOUT;LOW;;/home/eive/EIVE/Robin/eive-obsw/linux/devices/HeaterHandler.h +11000;MAIN_SWITCH_ON_TIMEOUT;LOW;;/home/eive/EIVE/Robin/eive-obsw/linux/devices/SolarArrayDeploymentHandler.h +11001;MAIN_SWITCH_OFF_TIMEOUT;LOW;;/home/eive/EIVE/Robin/eive-obsw/linux/devices/SolarArrayDeploymentHandler.h +11002;DEPLOYMENT_FAILED;HIGH;;/home/eive/EIVE/Robin/eive-obsw/linux/devices/SolarArrayDeploymentHandler.h +11003;DEPL_SA1_GPIO_SWTICH_ON_FAILED;HIGH;;/home/eive/EIVE/Robin/eive-obsw/linux/devices/SolarArrayDeploymentHandler.h +11004;DEPL_SA2_GPIO_SWTICH_ON_FAILED;HIGH;;/home/eive/EIVE/Robin/eive-obsw/linux/devices/SolarArrayDeploymentHandler.h 11101;MEMORY_READ_RPT_CRC_FAILURE;LOW;;/home/eive/EIVE/Robin/eive-obsw/mission/devices/PlocMPSoCHandler.h 11102;ACK_FAILURE;LOW;;/home/eive/EIVE/Robin/eive-obsw/mission/devices/PlocMPSoCHandler.h 11103;EXE_FAILURE;LOW;;/home/eive/EIVE/Robin/eive-obsw/mission/devices/PlocMPSoCHandler.h @@ -104,3 +114,7 @@ 11800;SEND_MRAM_DUMP_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/devices/PlocMemoryDumper.h 11801;MRAM_DUMP_FAILED;LOW;Received completion failure report form PLOC supervisor handler P1: MRAM start address of failing dump command;/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/devices/PlocMemoryDumper.h 11802;MRAM_DUMP_FINISHED;LOW;MRAM dump finished successfully;/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/devices/PlocMemoryDumper.h +11901;INVALID_TC_FRAME;HIGH;;/home/eive/EIVE/Robin/eive-obsw/linux/obc/PdecHandler.h +11902;INVALID_FAR;HIGH;Read invalid FAR from PDEC after startup;/home/eive/EIVE/Robin/eive-obsw/linux/obc/PdecHandler.h +11903;CARRIER_LOCK;INFO;Carrier lock detected;/home/eive/EIVE/Robin/eive-obsw/linux/obc/PdecHandler.h +11904;BIT_LOCK;INFO;Bit lock detected (data valid);/home/eive/EIVE/Robin/eive-obsw/linux/obc/PdecHandler.h diff --git a/generators/events/event_parser.py b/generators/events/event_parser.py index 62b26af4..2275aa04 100644 --- a/generators/events/event_parser.py +++ b/generators/events/event_parser.py @@ -51,7 +51,7 @@ SUBSYSTEM_DEFINITION_DESTINATIONS = [ ] HEADER_DEFINITION_DESTINATIONS = [ f"{OBSW_ROOT_DIR}/mission/", f"{OBSW_ROOT_DIR}/fsfw/", f"{FSFW_CONFIG_ROOT}", - f"{OBSW_ROOT_DIR}/test/", f"{OBSW_ROOT_DIR}/bsp_q7s" + f"{OBSW_ROOT_DIR}/test/", f"{OBSW_ROOT_DIR}/bsp_q7s", f"{OBSW_ROOT_DIR}/linux/" ] diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp index ffb6f6b3..4b8a407b 100644 --- a/generators/events/translateEvents.cpp +++ b/generators/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 106 translations. + * @brief Auto-generated event translation file. Contains 120 translations. * @details - * Generated on: 2021-11-25 13:58:03 + * Generated on: 2021-11-25 14:06:54 */ #include "translateEvents.h" @@ -84,6 +84,16 @@ const char *CLOCK_SET_STRING = "CLOCK_SET"; const char *CLOCK_SET_FAILURE_STRING = "CLOCK_SET_FAILURE"; const char *TEST_STRING = "TEST"; const char *CHANGE_OF_SETUP_PARAMETER_STRING = "CHANGE_OF_SETUP_PARAMETER"; +const char *GPIO_PULL_HIGH_FAILED_STRING = "GPIO_PULL_HIGH_FAILED"; +const char *GPIO_PULL_LOW_FAILED_STRING = "GPIO_PULL_LOW_FAILED"; +const char *SWITCH_ALREADY_ON_STRING = "SWITCH_ALREADY_ON"; +const char *SWITCH_ALREADY_OFF_STRING = "SWITCH_ALREADY_OFF"; +const char *MAIN_SWITCH_TIMEOUT_STRING = "MAIN_SWITCH_TIMEOUT"; +const char *MAIN_SWITCH_ON_TIMEOUT_STRING = "MAIN_SWITCH_ON_TIMEOUT"; +const char *MAIN_SWITCH_OFF_TIMEOUT_STRING = "MAIN_SWITCH_OFF_TIMEOUT"; +const char *DEPLOYMENT_FAILED_STRING = "DEPLOYMENT_FAILED"; +const char *DEPL_SA1_GPIO_SWTICH_ON_FAILED_STRING = "DEPL_SA1_GPIO_SWTICH_ON_FAILED"; +const char *DEPL_SA2_GPIO_SWTICH_ON_FAILED_STRING = "DEPL_SA2_GPIO_SWTICH_ON_FAILED"; const char *MEMORY_READ_RPT_CRC_FAILURE_STRING = "MEMORY_READ_RPT_CRC_FAILURE"; const char *ACK_FAILURE_STRING = "ACK_FAILURE"; const char *EXE_FAILURE_STRING = "EXE_FAILURE"; @@ -111,6 +121,10 @@ const char *UPDATE_FINISHED_STRING = "UPDATE_FINISHED"; const char *SEND_MRAM_DUMP_FAILED_STRING = "SEND_MRAM_DUMP_FAILED"; const char *MRAM_DUMP_FAILED_STRING = "MRAM_DUMP_FAILED"; const char *MRAM_DUMP_FINISHED_STRING = "MRAM_DUMP_FINISHED"; +const char *INVALID_TC_FRAME_STRING = "INVALID_TC_FRAME"; +const char *INVALID_FAR_STRING = "INVALID_FAR"; +const char *CARRIER_LOCK_STRING = "CARRIER_LOCK"; +const char *BIT_LOCK_STRING = "BIT_LOCK"; const char * translateEvents(Event event) { switch( (event & 0xffff) ) { @@ -272,6 +286,26 @@ const char * translateEvents(Event event) { return TEST_STRING; case(10600): return CHANGE_OF_SETUP_PARAMETER_STRING; + case(10900): + return GPIO_PULL_HIGH_FAILED_STRING; + case(10901): + return GPIO_PULL_LOW_FAILED_STRING; + case(10902): + return SWITCH_ALREADY_ON_STRING; + case(10903): + return SWITCH_ALREADY_OFF_STRING; + case(10904): + return MAIN_SWITCH_TIMEOUT_STRING; + case(11000): + return MAIN_SWITCH_ON_TIMEOUT_STRING; + case(11001): + return MAIN_SWITCH_OFF_TIMEOUT_STRING; + case(11002): + return DEPLOYMENT_FAILED_STRING; + case(11003): + return DEPL_SA1_GPIO_SWTICH_ON_FAILED_STRING; + case(11004): + return DEPL_SA2_GPIO_SWTICH_ON_FAILED_STRING; case(11101): return MEMORY_READ_RPT_CRC_FAILURE_STRING; case(11102): @@ -326,6 +360,14 @@ const char * translateEvents(Event event) { return MRAM_DUMP_FAILED_STRING; case(11802): return MRAM_DUMP_FINISHED_STRING; + case(11901): + return INVALID_TC_FRAME_STRING; + case(11902): + return INVALID_FAR_STRING; + case(11903): + return CARRIER_LOCK_STRING; + case(11904): + return BIT_LOCK_STRING; default: return "UNKNOWN_EVENT"; } diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index ffb6f6b3..4b8a407b 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 106 translations. + * @brief Auto-generated event translation file. Contains 120 translations. * @details - * Generated on: 2021-11-25 13:58:03 + * Generated on: 2021-11-25 14:06:54 */ #include "translateEvents.h" @@ -84,6 +84,16 @@ const char *CLOCK_SET_STRING = "CLOCK_SET"; const char *CLOCK_SET_FAILURE_STRING = "CLOCK_SET_FAILURE"; const char *TEST_STRING = "TEST"; const char *CHANGE_OF_SETUP_PARAMETER_STRING = "CHANGE_OF_SETUP_PARAMETER"; +const char *GPIO_PULL_HIGH_FAILED_STRING = "GPIO_PULL_HIGH_FAILED"; +const char *GPIO_PULL_LOW_FAILED_STRING = "GPIO_PULL_LOW_FAILED"; +const char *SWITCH_ALREADY_ON_STRING = "SWITCH_ALREADY_ON"; +const char *SWITCH_ALREADY_OFF_STRING = "SWITCH_ALREADY_OFF"; +const char *MAIN_SWITCH_TIMEOUT_STRING = "MAIN_SWITCH_TIMEOUT"; +const char *MAIN_SWITCH_ON_TIMEOUT_STRING = "MAIN_SWITCH_ON_TIMEOUT"; +const char *MAIN_SWITCH_OFF_TIMEOUT_STRING = "MAIN_SWITCH_OFF_TIMEOUT"; +const char *DEPLOYMENT_FAILED_STRING = "DEPLOYMENT_FAILED"; +const char *DEPL_SA1_GPIO_SWTICH_ON_FAILED_STRING = "DEPL_SA1_GPIO_SWTICH_ON_FAILED"; +const char *DEPL_SA2_GPIO_SWTICH_ON_FAILED_STRING = "DEPL_SA2_GPIO_SWTICH_ON_FAILED"; const char *MEMORY_READ_RPT_CRC_FAILURE_STRING = "MEMORY_READ_RPT_CRC_FAILURE"; const char *ACK_FAILURE_STRING = "ACK_FAILURE"; const char *EXE_FAILURE_STRING = "EXE_FAILURE"; @@ -111,6 +121,10 @@ const char *UPDATE_FINISHED_STRING = "UPDATE_FINISHED"; const char *SEND_MRAM_DUMP_FAILED_STRING = "SEND_MRAM_DUMP_FAILED"; const char *MRAM_DUMP_FAILED_STRING = "MRAM_DUMP_FAILED"; const char *MRAM_DUMP_FINISHED_STRING = "MRAM_DUMP_FINISHED"; +const char *INVALID_TC_FRAME_STRING = "INVALID_TC_FRAME"; +const char *INVALID_FAR_STRING = "INVALID_FAR"; +const char *CARRIER_LOCK_STRING = "CARRIER_LOCK"; +const char *BIT_LOCK_STRING = "BIT_LOCK"; const char * translateEvents(Event event) { switch( (event & 0xffff) ) { @@ -272,6 +286,26 @@ const char * translateEvents(Event event) { return TEST_STRING; case(10600): return CHANGE_OF_SETUP_PARAMETER_STRING; + case(10900): + return GPIO_PULL_HIGH_FAILED_STRING; + case(10901): + return GPIO_PULL_LOW_FAILED_STRING; + case(10902): + return SWITCH_ALREADY_ON_STRING; + case(10903): + return SWITCH_ALREADY_OFF_STRING; + case(10904): + return MAIN_SWITCH_TIMEOUT_STRING; + case(11000): + return MAIN_SWITCH_ON_TIMEOUT_STRING; + case(11001): + return MAIN_SWITCH_OFF_TIMEOUT_STRING; + case(11002): + return DEPLOYMENT_FAILED_STRING; + case(11003): + return DEPL_SA1_GPIO_SWTICH_ON_FAILED_STRING; + case(11004): + return DEPL_SA2_GPIO_SWTICH_ON_FAILED_STRING; case(11101): return MEMORY_READ_RPT_CRC_FAILURE_STRING; case(11102): @@ -326,6 +360,14 @@ const char * translateEvents(Event event) { return MRAM_DUMP_FAILED_STRING; case(11802): return MRAM_DUMP_FINISHED_STRING; + case(11901): + return INVALID_TC_FRAME_STRING; + case(11902): + return INVALID_FAR_STRING; + case(11903): + return CARRIER_LOCK_STRING; + case(11904): + return BIT_LOCK_STRING; default: return "UNKNOWN_EVENT"; } From 14ba11738b42a125dcc2aa2c995029409c5c07bb Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 25 Nov 2021 14:09:06 +0100 Subject: [PATCH 101/465] adapted event name --- generators/bsp_q7s_events.csv | 2 +- generators/events/translateEvents.cpp | 6 +++--- linux/fsfwconfig/events/translateEvents.cpp | 6 +++--- linux/obc/PdecHandler.cpp | 2 +- linux/obc/PdecHandler.h | 2 +- mission/tmtc/CCSDSHandler.cpp | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/generators/bsp_q7s_events.csv b/generators/bsp_q7s_events.csv index 7de6a92c..8dfa9e78 100644 --- a/generators/bsp_q7s_events.csv +++ b/generators/bsp_q7s_events.csv @@ -117,4 +117,4 @@ 11901;INVALID_TC_FRAME;HIGH;;/home/eive/EIVE/Robin/eive-obsw/linux/obc/PdecHandler.h 11902;INVALID_FAR;HIGH;Read invalid FAR from PDEC after startup;/home/eive/EIVE/Robin/eive-obsw/linux/obc/PdecHandler.h 11903;CARRIER_LOCK;INFO;Carrier lock detected;/home/eive/EIVE/Robin/eive-obsw/linux/obc/PdecHandler.h -11904;BIT_LOCK;INFO;Bit lock detected (data valid);/home/eive/EIVE/Robin/eive-obsw/linux/obc/PdecHandler.h +11904;BIT_LOCK_PDEC;INFO;Bit lock detected (data valid);/home/eive/EIVE/Robin/eive-obsw/linux/obc/PdecHandler.h diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp index 4b8a407b..943468c5 100644 --- a/generators/events/translateEvents.cpp +++ b/generators/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** * @brief Auto-generated event translation file. Contains 120 translations. * @details - * Generated on: 2021-11-25 14:06:54 + * Generated on: 2021-11-25 14:09:00 */ #include "translateEvents.h" @@ -124,7 +124,7 @@ const char *MRAM_DUMP_FINISHED_STRING = "MRAM_DUMP_FINISHED"; const char *INVALID_TC_FRAME_STRING = "INVALID_TC_FRAME"; const char *INVALID_FAR_STRING = "INVALID_FAR"; const char *CARRIER_LOCK_STRING = "CARRIER_LOCK"; -const char *BIT_LOCK_STRING = "BIT_LOCK"; +const char *BIT_LOCK_PDEC_STRING = "BIT_LOCK_PDEC"; const char * translateEvents(Event event) { switch( (event & 0xffff) ) { @@ -367,7 +367,7 @@ const char * translateEvents(Event event) { case(11903): return CARRIER_LOCK_STRING; case(11904): - return BIT_LOCK_STRING; + return BIT_LOCK_PDEC_STRING; default: return "UNKNOWN_EVENT"; } diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index 4b8a407b..943468c5 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** * @brief Auto-generated event translation file. Contains 120 translations. * @details - * Generated on: 2021-11-25 14:06:54 + * Generated on: 2021-11-25 14:09:00 */ #include "translateEvents.h" @@ -124,7 +124,7 @@ const char *MRAM_DUMP_FINISHED_STRING = "MRAM_DUMP_FINISHED"; const char *INVALID_TC_FRAME_STRING = "INVALID_TC_FRAME"; const char *INVALID_FAR_STRING = "INVALID_FAR"; const char *CARRIER_LOCK_STRING = "CARRIER_LOCK"; -const char *BIT_LOCK_STRING = "BIT_LOCK"; +const char *BIT_LOCK_PDEC_STRING = "BIT_LOCK_PDEC"; const char * translateEvents(Event event) { switch( (event & 0xffff) ) { @@ -367,7 +367,7 @@ const char * translateEvents(Event event) { case(11903): return CARRIER_LOCK_STRING; case(11904): - return BIT_LOCK_STRING; + return BIT_LOCK_PDEC_STRING; default: return "UNKNOWN_EVENT"; } diff --git a/linux/obc/PdecHandler.cpp b/linux/obc/PdecHandler.cpp index f99a1a30..027cac80 100644 --- a/linux/obc/PdecHandler.cpp +++ b/linux/obc/PdecHandler.cpp @@ -246,7 +246,7 @@ void PdecHandler::checkLocks() { } if (!(clcw & NO_BITLOCK_MASK) && (lastClcw & NO_BITLOCK_MASK)) { // Bit lock changed from 0 to 1 - triggerEvent(BIT_LOCK); + triggerEvent(BIT_LOCK_PDEC); } lastClcw = clcw; } diff --git a/linux/obc/PdecHandler.h b/linux/obc/PdecHandler.h index 83e4a253..8819df22 100644 --- a/linux/obc/PdecHandler.h +++ b/linux/obc/PdecHandler.h @@ -82,7 +82,7 @@ public: //! [EXPORT] : [COMMENT] Carrier lock detected static const Event CARRIER_LOCK = MAKE_EVENT(3, severity::INFO); //! [EXPORT] : [COMMENT] Bit lock detected (data valid) - static const Event BIT_LOCK = MAKE_EVENT(4, severity::INFO); + static const Event BIT_LOCK_PDEC = MAKE_EVENT(4, severity::INFO); private: diff --git a/mission/tmtc/CCSDSHandler.cpp b/mission/tmtc/CCSDSHandler.cpp index 71307bd9..01894cbc 100644 --- a/mission/tmtc/CCSDSHandler.cpp +++ b/mission/tmtc/CCSDSHandler.cpp @@ -226,7 +226,7 @@ void CCSDSHandler::checkEvents() { void CCSDSHandler::handleEvent(EventMessage* eventMessage) { Event event = eventMessage->getEvent(); switch(event){ - case PdecHandler::BIT_LOCK: { + case PdecHandler::BIT_LOCK_PDEC: { handleBitLockEvent(); break; } From 0f89282dae29700d9f9ce3d33be3e90ef1cbd36c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 25 Nov 2021 14:20:53 +0100 Subject: [PATCH 102/465] event name correction --- mission/tmtc/CCSDSHandler.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mission/tmtc/CCSDSHandler.cpp b/mission/tmtc/CCSDSHandler.cpp index 01894cbc..e0239d9a 100644 --- a/mission/tmtc/CCSDSHandler.cpp +++ b/mission/tmtc/CCSDSHandler.cpp @@ -91,7 +91,8 @@ ReturnValue_t CCSDSHandler::initialize() { return result; } result = manager->subscribeToEventRange(eventQueue->getId(), - event::getEventId(PdecHandler::CARRIER_LOCK), event::getEventId(PdecHandler::BIT_LOCK)); + event::getEventId(PdecHandler::CARRIER_LOCK), + event::getEventId(PdecHandler::BIT_LOCK_PDEC)); if (result != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "CCSDSHandler::initialize: Failed to subscribe to events from PDEC " From 5b412bf07269c847be6269c2c71c2deb3df5db3d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 25 Nov 2021 21:38:13 +0100 Subject: [PATCH 103/465] implemented rename function --- bsp_q7s/boardtest/Q7STestTask.cpp | 45 +++++++++++--- bsp_q7s/boardtest/Q7STestTask.h | 2 + bsp_q7s/memory/FileSystemHandler.cpp | 87 ++++++++++------------------ bsp_q7s/memory/FileSystemHandler.h | 2 + 4 files changed, 73 insertions(+), 63 deletions(-) diff --git a/bsp_q7s/boardtest/Q7STestTask.cpp b/bsp_q7s/boardtest/Q7STestTask.cpp index 7681ef09..965a6d63 100644 --- a/bsp_q7s/boardtest/Q7STestTask.cpp +++ b/bsp_q7s/boardtest/Q7STestTask.cpp @@ -26,8 +26,8 @@ ReturnValue_t Q7STestTask::performOneShotAction() { //testJsonLibDirect(); //testDummyParams(); //testProtHandler(); - //FsOpCodes opCode = FsOpCodes::ATTEMPT_DIR_REMOVAL_NON_EMPTY; - //testFileSystemHandlerDirect(opCode); + FsOpCodes opCode = FsOpCodes::APPEND_TO_FILE; + testFileSystemHandlerDirect(opCode); return TestTask::performOneShotAction(); } @@ -252,7 +252,7 @@ void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) { cfg.useMountPrefix = false; sif::info << "Creating empty file in /tmp folder" << std::endl; // Do not delete file, user can check existence in shell - fsHandler->createFile("/tmp", "test.txt", nullptr, 0, &cfg); + fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg); break; } case(FsOpCodes::REMOVE_TMP_FILE): { @@ -262,7 +262,7 @@ void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) { if(not std::filesystem::exists("/tmp/test.txt")) { // Creating sample file sif::info << "Creating sample file /tmp/test.txt to delete" << std::endl; - fsHandler->createFile("/tmp", "test.txt", nullptr, 0, &cfg); + fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg); } result = fsHandler->removeFile("/tmp", "test.txt", &cfg); if(result == HasReturnvaluesIF::RETURN_OK) { @@ -278,7 +278,7 @@ void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) { cfg.useMountPrefix = false; sif::info << "Creating empty file in /tmp folder" << std::endl; // Do not delete file, user can check existence in shell - ReturnValue_t result = fsHandler->createDirectory("/tmp", "test", false, &cfg); + ReturnValue_t result = fsHandler->createDirectory("/tmp/", "test", false, &cfg); if(result == HasReturnvaluesIF::RETURN_OK) { sif::info << "Directory created successfully" << std::endl; } @@ -297,7 +297,7 @@ void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) { // Delete any leftover files to regular dir removal works std::remove("/tmp/test/*"); } - result = fsHandler->removeDirectory("/tmp", "test", false, &cfg); + result = fsHandler->removeDirectory("/tmp/", "test", false, &cfg); if(result == HasReturnvaluesIF::RETURN_OK) { sif::info << "Directory removed successfully" << std::endl; } @@ -311,7 +311,7 @@ void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) { if(result != HasReturnvaluesIF::RETURN_OK) { return; } - result = fsHandler->removeDirectory("/tmp", "test", true, &cfg); + result = fsHandler->removeDirectory("/tmp/", "test", true, &cfg); if(result == HasReturnvaluesIF::RETURN_OK) { sif::info << "Directory removed recursively successfully" << std::endl; } @@ -325,13 +325,42 @@ void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) { if(result != HasReturnvaluesIF::RETURN_OK) { return; } - result = fsHandler->removeDirectory("/tmp", "test", false, &cfg); + result = fsHandler->removeDirectory("/tmp/", "test", false, &cfg); if(result != HasReturnvaluesIF::RETURN_OK) { sif::info << "Directory removal attempt failed as expected" << std::endl; } else { sif::warning << "Directory removal worked when it should not have!" << std::endl; } + break; + } + case(FsOpCodes::RENAME_FILE): { + // No mount prefix, cause file is created in tmp + cfg.useMountPrefix = false; + if(std::filesystem::exists("/tmp/test.txt")) { + fsHandler->removeDirectory("/tmp/", "test", false, &cfg); + } + sif::info << "Creating empty file /tmp/test.txt and rename to /tmp/test2.txt" << std::endl; + // Do not delete file, user can check existence in shell + fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg); + fsHandler->renameFile("/tmp/", "test.txt", "test2.txt", &cfg); + break; + } + case(FsOpCodes::APPEND_TO_FILE): { + // No mount prefix, cause file is created in tmp + cfg.useMountPrefix = false; + if(std::filesystem::exists("/tmp/test.txt")) { + fsHandler->removeDirectory("/tmp/", "test", false, &cfg); + } + if(std::filesystem::exists("/tmp/test.txt")) { + fsHandler->removeDirectory("/tmp/", "test", false, &cfg); + } + sif::info << "Creating empty file /tmp/test.txt and adding content" << std::endl; + std::string content = "Hello World\n"; + // Do not delete file, user can check existence in shell + fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg); + fsHandler->appendToFile("/tmp/", "test.txt", reinterpret_cast( + content.data()), content.size(), 0, &cfg); } } } diff --git a/bsp_q7s/boardtest/Q7STestTask.h b/bsp_q7s/boardtest/Q7STestTask.h index b0153ce9..5e11b374 100644 --- a/bsp_q7s/boardtest/Q7STestTask.h +++ b/bsp_q7s/boardtest/Q7STestTask.h @@ -27,6 +27,8 @@ private: REMOVE_EMPTY_DIR_IN_TMP, ATTEMPT_DIR_REMOVAL_NON_EMPTY, REMOVE_FILLED_DIR_IN_TMP, + RENAME_FILE, + APPEND_TO_FILE, }; void testFileSystemHandlerDirect(FsOpCodes opCode); }; diff --git a/bsp_q7s/memory/FileSystemHandler.cpp b/bsp_q7s/memory/FileSystemHandler.cpp index 2943875a..caad94a6 100644 --- a/bsp_q7s/memory/FileSystemHandler.cpp +++ b/bsp_q7s/memory/FileSystemHandler.cpp @@ -136,13 +136,11 @@ ReturnValue_t FileSystemHandler::initialize() { ReturnValue_t FileSystemHandler::appendToFile(const char* repositoryPath, const char* filename, const uint8_t* data, size_t size, uint16_t packetNumber, FileSystemArgsIF* args) { - // A double slash between repo and filename should not be an issue, so add it in any case - std::string fullPath = currentMountPrefix + std::string(repositoryPath) + "/" + - std::string(filename); - if(not std::filesystem::exists(fullPath)) { + auto path = getInitPath(args) / repositoryPath / filename; + if(not std::filesystem::exists(path)) { return FILE_DOES_NOT_EXIST; } - std::ofstream file(fullPath, std::ios_base::app|std::ios_base::out); + std::ofstream file(path, std::ios_base::app|std::ios_base::out); file.write(reinterpret_cast(data), size); if(not file.good()) { return GENERIC_FILE_ERROR; @@ -152,19 +150,11 @@ ReturnValue_t FileSystemHandler::appendToFile(const char* repositoryPath, ReturnValue_t FileSystemHandler::createFile(const char* repositoryPath, const char* filename, const uint8_t* data, size_t size, FileSystemArgsIF* args) { - std::string fullPath; - bool useMountPrefix = true; - parseCfg(reinterpret_cast(args), useMountPrefix); - if(useMountPrefix) { - fullPath += currentMountPrefix; - } - - // A double slash between repo and filename should not be an issue, so add it in any case - fullPath += std::string(repositoryPath) + "/" + std::string(filename); - if(std::filesystem::exists(fullPath)) { + auto path = getInitPath(args) / filename; + if(std::filesystem::exists(path)) { return FILE_ALREADY_EXISTS; } - std::ofstream file(fullPath); + std::ofstream file(path); file.write(reinterpret_cast(data), size); if(not file.good()) { return GENERIC_FILE_ERROR; @@ -174,19 +164,11 @@ ReturnValue_t FileSystemHandler::createFile(const char* repositoryPath, ReturnValue_t FileSystemHandler::removeFile(const char* repositoryPath, const char* filename, FileSystemArgsIF* args) { - std::string fullPath; - bool useMountPrefix = true; - parseCfg(reinterpret_cast(args), useMountPrefix); - if(useMountPrefix) { - fullPath += currentMountPrefix; - } - - // A double slash between repo and filename should not be an issue, so add it in any case - fullPath += std::string(repositoryPath) + "/" + std::string(filename); - if(not std::filesystem::exists(fullPath)) { + auto path = getInitPath(args) / repositoryPath / filename; + if(not std::filesystem::exists(path)) { return FILE_DOES_NOT_EXIST; } - int result = std::remove(fullPath.c_str()); + int result = std::remove(path.c_str()); if(result != 0) { sif::warning << "FileSystemHandler::deleteFile: Failed with code " << result << std::endl; return GENERIC_FILE_ERROR; @@ -196,42 +178,26 @@ ReturnValue_t FileSystemHandler::removeFile(const char* repositoryPath, ReturnValue_t FileSystemHandler:: createDirectory(const char* repositoryPath, const char* dirname, bool createParentDirs, FileSystemArgsIF* args) { - std::string fullPath; - bool useMountPrefix = true; - parseCfg(reinterpret_cast(args), useMountPrefix); - if(useMountPrefix) { - fullPath += currentMountPrefix; - } - - fullPath += std::string(repositoryPath); - fullPath += "/" + std::string(dirname); - if(std::filesystem::exists(fullPath)) { + auto path = getInitPath(args) / repositoryPath / dirname; + if(std::filesystem::exists(path)) { return DIRECTORY_ALREADY_EXISTS; } - if(std::filesystem::create_directory(fullPath)) { + if(std::filesystem::create_directory(path)) { return HasReturnvaluesIF::RETURN_OK; } - sif::warning << "Creating directory " << fullPath << " failed" << std::endl; + sif::warning << "Creating directory " << path << " failed" << std::endl; return GENERIC_FILE_ERROR; } ReturnValue_t FileSystemHandler::removeDirectory(const char* repositoryPath, const char* dirname, bool deleteRecurively, FileSystemArgsIF* args) { - std::string fullPath; - bool useMountPrefix = true; - parseCfg(reinterpret_cast(args), useMountPrefix); - if(useMountPrefix) { - fullPath += currentMountPrefix; - } - - fullPath += std::string(repositoryPath); - fullPath += "/" + std::string(dirname); - if(not std::filesystem::exists(fullPath)) { + auto path = getInitPath(args) / repositoryPath / dirname; + if(not std::filesystem::exists(path)) { return DIRECTORY_DOES_NOT_EXIST; } std::error_code err; if(not deleteRecurively) { - if(std::filesystem::remove(fullPath, err)) { + if(std::filesystem::remove(path, err)) { return HasReturnvaluesIF::RETURN_OK; } else { @@ -248,7 +214,7 @@ ReturnValue_t FileSystemHandler::removeDirectory(const char* repositoryPath, con } } else { - if(std::filesystem::remove_all(fullPath, err)) { + if(std::filesystem::remove_all(path, err)) { return HasReturnvaluesIF::RETURN_OK; } else { @@ -267,14 +233,25 @@ ReturnValue_t FileSystemHandler::removeDirectory(const char* repositoryPath, con return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t FileSystemHandler::renameFile(const char *repositoryPath, const char *oldFilename, + const char *newFilename, FileSystemArgsIF *args) { + auto basepath = getInitPath(args) / repositoryPath; + std::filesystem::rename(basepath / oldFilename, basepath / newFilename); + return HasReturnvaluesIF::RETURN_OK; +} + void FileSystemHandler::parseCfg(FsCommandCfg *cfg, bool& useMountPrefix) { if(cfg != nullptr) { useMountPrefix = cfg->useMountPrefix; } } -ReturnValue_t FileSystemHandler::renameFile(const char *repositoryPath, const char *oldFilename, - const char *newFilename, FileSystemArgsIF *args) { - // TODO: Implement - return HasReturnvaluesIF::RETURN_OK; +std::filesystem::path FileSystemHandler::getInitPath(FileSystemArgsIF* args) { + bool useMountPrefix = true; + parseCfg(reinterpret_cast(args), useMountPrefix); + std::string path; + if(useMountPrefix) { + path = currentMountPrefix; + } + return std::filesystem::path(path); } diff --git a/bsp_q7s/memory/FileSystemHandler.h b/bsp_q7s/memory/FileSystemHandler.h index 8fdebd05..35a0f533 100644 --- a/bsp_q7s/memory/FileSystemHandler.h +++ b/bsp_q7s/memory/FileSystemHandler.h @@ -10,6 +10,7 @@ #include "fsfw/memory/HasFileSystemIF.h" #include +#include class CoreController; @@ -61,6 +62,7 @@ private: void fileSystemHandlerLoop(); void fileSystemCheckup(); + std::filesystem::path getInitPath(FileSystemArgsIF* args); void parseCfg(FsCommandCfg* cfg, bool& useMountPrefix); }; From 0b7e8fa38bafa08b77b9f4f9e77778bf06127e4c Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Fri, 26 Nov 2021 09:14:41 +0100 Subject: [PATCH 104/465] star tracker ping command --- mission/devices/StarTrackerHandler.cpp | 37 +++++++++++++++++++ mission/devices/StarTrackerHandler.h | 14 ++++++- .../StarTrackerDefinitions.h | 1 + 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/mission/devices/StarTrackerHandler.cpp b/mission/devices/StarTrackerHandler.cpp index c5718f02..22a84973 100644 --- a/mission/devices/StarTrackerHandler.cpp +++ b/mission/devices/StarTrackerHandler.cpp @@ -6,6 +6,7 @@ extern "C" { #include + #include #include "common/misc.h" } @@ -55,6 +56,10 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi const uint8_t * commandData, size_t commandDataLen) { switch (deviceCommand) { + case (StarTracker::PING_REQUEST): { + preparePingRequest(); + return RETURN_OK; + } case (StarTracker::REQ_TEMPERATURE): { prepareTemperatureRequest(); return RETURN_OK; @@ -68,6 +73,8 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi void StarTrackerHandler::fillCommandAndReplyMap() { /** Reply lengths are unknown because of the slip encoding. Thus always maximum reply size * is specified */ + this->insertInCommandAndReplyMap(StarTracker::PING_REQUEST, 1, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(StarTracker::REQ_TEMPERATURE, 1, &temperatureSet, StarTracker::MAX_FRAME_SIZE * 2 + 2); } @@ -106,6 +113,11 @@ ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t rema } switch (decodedFrame[1]) { + case (static_cast(StarTracker::PING_REQUEST)): { + *foundLen = decodedLength; + *foundId = StarTracker::PING_REQUEST; + break; + } case (static_cast(StarTracker::REQ_TEMPERATURE)): { *foundLen = decodedLength; *foundId = StarTracker::REQ_TEMPERATURE; @@ -125,6 +137,10 @@ ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t rema ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { switch (id) { + case (StarTracker::PING_REQUEST): { + handlePingReply(); + break; + } case (StarTracker::REQ_TEMPERATURE): { handleTemperatureTm(); break; @@ -170,6 +186,16 @@ void StarTrackerHandler::slipInit() { slipInfo.prev_state = SLIP_COMPLETE; } +void StarTrackerHandler::preparePingRequest() { + uint32_t length = 0; + struct PingActionRequest pingRequest = {PING_ID}; + arc_pack_ping_action_req(&pingRequest, commandBuffer, &length); + uint32_t encLength = 0; + arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength); + rawPacket = encBuffer; + rawPacketLen = encLength; +} + void StarTrackerHandler::prepareTemperatureRequest() { uint32_t length = 0; arc_tm_pack_temperature_req(commandBuffer, &length); @@ -179,6 +205,17 @@ void StarTrackerHandler::prepareTemperatureRequest() { rawPacketLen = encLength; } +void StarTrackerHandler::handlePingReply() { + uint32_t pingId = 0; + size_t size = 0; + const uint8_t* buffer = decodedFrame; + SerializeAdapter::deSerialize(&pingId, &buffer, &size, SerializeIF::Endianness::BIG); +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 + sif::info << "Ping status "<< static_cast(*(decodedFrame + 2)) << std::endl; + sif::info << "Ping id "<< pingId << std::endl; +#endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ +} + void StarTrackerHandler::handleTemperatureTm() { PoolReadGuard rg(&temperatureSet); uint32_t offset = 1; diff --git a/mission/devices/StarTrackerHandler.h b/mission/devices/StarTrackerHandler.h index ee96e544..4d49064d 100644 --- a/mission/devices/StarTrackerHandler.h +++ b/mission/devices/StarTrackerHandler.h @@ -2,6 +2,7 @@ #define MISSION_DEVICES_STARTRACKERHANDLER_H_ #include +#include #include #include @@ -64,8 +65,11 @@ private: static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_HANDLER; //! [EXPORT] : [COMMENT] Result code of tm reply indicates an error + static const ReturnValue_t TM_REPLY_ERROR = MAKE_RETURN_CODE(0xA0); - //! P1: TM id + + // Ping request will reply ping with this ID (data field) + static const uint32_t PING_ID = 0x55; StarTracker::TemperatureSet temperatureSet; @@ -89,8 +93,16 @@ private: */ void slipInit(); + /** + * @brief Fills command buffer with data to ping the star tracker + */ + void preparePingRequest(); + /** + * @brief Fills command buffer with data to request temperature from star tracker + */ void prepareTemperatureRequest(); + void handlePingReply(); /** * @brief This function handles the telemetry reply of a temperature request. */ diff --git a/mission/devices/devicedefinitions/StarTrackerDefinitions.h b/mission/devices/devicedefinitions/StarTrackerDefinitions.h index 6c28219b..efde795e 100644 --- a/mission/devices/devicedefinitions/StarTrackerDefinitions.h +++ b/mission/devices/devicedefinitions/StarTrackerDefinitions.h @@ -21,6 +21,7 @@ enum PoolIds: lp_id_t { +static const DeviceCommandId_t PING_REQUEST = 0; static const DeviceCommandId_t REQ_TEMPERATURE = 25; static const uint32_t TEMPERATURE_SET_ID = REQ_TEMPERATURE; From 8b97528afb9a9975ad82fafa5d7c21cb750d4d9e Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Fri, 26 Nov 2021 13:16:05 +0100 Subject: [PATCH 105/465] star tracker ping and reboot command --- mission/devices/StarTrackerHandler.cpp | 90 ++++++++++++------- mission/devices/StarTrackerHandler.h | 18 ++-- .../StarTrackerDefinitions.h | 7 +- 3 files changed, 75 insertions(+), 40 deletions(-) diff --git a/mission/devices/StarTrackerHandler.cpp b/mission/devices/StarTrackerHandler.cpp index 22a84973..ebb23033 100644 --- a/mission/devices/StarTrackerHandler.cpp +++ b/mission/devices/StarTrackerHandler.cpp @@ -25,7 +25,8 @@ StarTrackerHandler::~StarTrackerHandler() { void StarTrackerHandler::doStartUp() { #if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 - setMode(MODE_NORMAL); +// setMode(MODE_NORMAL); + setMode(_MODE_TO_ON); #else setMode(_MODE_TO_ON); #endif @@ -60,6 +61,10 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi preparePingRequest(); return RETURN_OK; } + case (StarTracker::REBOOT): { + prepareRebootCommand(); + return RETURN_OK; + } case (StarTracker::REQ_TEMPERATURE): { prepareTemperatureRequest(); return RETURN_OK; @@ -75,6 +80,7 @@ void StarTrackerHandler::fillCommandAndReplyMap() { * is specified */ this->insertInCommandAndReplyMap(StarTracker::PING_REQUEST, 1, nullptr, StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandMap(StarTracker::REBOOT); this->insertInCommandAndReplyMap(StarTracker::REQ_TEMPERATURE, 1, &temperatureSet, StarTracker::MAX_FRAME_SIZE * 2 + 2); } @@ -136,9 +142,11 @@ ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t rema ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { + ReturnValue_t result = RETURN_OK; + switch (id) { case (StarTracker::PING_REQUEST): { - handlePingReply(); + result = handlePingReply(); break; } case (StarTracker::REQ_TEMPERATURE): { @@ -146,12 +154,13 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con break; } default: { - sif::debug << "StarTrackerHandler::interpretDeviceReply: Unknown device reply id" << std::endl; + sif::debug << "StarTrackerHandler::interpretDeviceReply: Unknown device reply id:" << id + << std::endl; return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; } } - return RETURN_OK; + return result; } void StarTrackerHandler::setNormalDatapoolEntriesInvalid() { @@ -165,7 +174,6 @@ uint32_t StarTrackerHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) { - localDataPoolMap.emplace(StarTracker::STATUS, new PoolEntry( { 0 })); localDataPoolMap.emplace(StarTracker::TICKS, new PoolEntry( { 0 })); localDataPoolMap.emplace(StarTracker::TIME, new PoolEntry( { 0 })); localDataPoolMap.emplace(StarTracker::MCU_TEMPERATURE, new PoolEntry( { 0 })); @@ -196,6 +204,16 @@ void StarTrackerHandler::preparePingRequest() { rawPacketLen = encLength; } +void StarTrackerHandler::prepareRebootCommand() { + uint32_t length = 0; + struct RebootActionRequest rebootReq; + arc_pack_reboot_action_req(&rebootReq, commandBuffer, &length); + uint32_t encLength = 0; + arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength); + rawPacket = encBuffer; + rawPacketLen = encLength; +} + void StarTrackerHandler::prepareTemperatureRequest() { uint32_t length = 0; arc_tm_pack_temperature_req(commandBuffer, &length); @@ -205,49 +223,59 @@ void StarTrackerHandler::prepareTemperatureRequest() { rawPacketLen = encLength; } -void StarTrackerHandler::handlePingReply() { +ReturnValue_t StarTrackerHandler::handlePingReply() { + ReturnValue_t result = RETURN_OK; uint32_t pingId = 0; - size_t size = 0; - const uint8_t* buffer = decodedFrame; - SerializeAdapter::deSerialize(&pingId, &buffer, &size, SerializeIF::Endianness::BIG); + uint8_t status = *(decodedFrame + 2); + const uint8_t* buffer = decodedFrame + 3; + size_t size = sizeof(pingId); + SerializeAdapter::deSerialize(&pingId, &buffer, &size, SerializeIF::Endianness::LITTLE); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - sif::info << "Ping status "<< static_cast(*(decodedFrame + 2)) << std::endl; - sif::info << "Ping id "<< pingId << std::endl; + sif::info << "Ping status: "<< static_cast(status) << std::endl; + sif::info << "Ping id: 0x"<< std::hex << pingId << std::endl; #endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ + if (status != StarTracker::STATUS_OK || pingId != PING_ID) { + result = PING_FAILED; + } + return result; } -void StarTrackerHandler::handleTemperatureTm() { +ReturnValue_t StarTrackerHandler::handleTemperatureTm() { + ReturnValue_t result = RETURN_OK; PoolReadGuard rg(&temperatureSet); - uint32_t offset = 1; - temperatureSet.status = *(decodedFrame + offset); + uint32_t offset = 2; + uint8_t status = *(decodedFrame + offset); offset += 1; - if(temperatureSet.status.value != 0) { + if(status != StarTracker::STATUS_OK) { sif::warning << "StarTrackerHandler::handleTemperatureTm: Reply error: " - << static_cast(temperatureSet.status.value) << std::endl; - triggerEvent(TM_REPLY_ERROR, temperatureSet.status.value); + << static_cast(status) << std::endl; + result = TEMPERATURE_REQUEST_FAILED; + return result; } - temperatureSet.ticks = *(decodedFrame + offset) << 24 - | *(decodedFrame + offset + 1) << 16 | *(decodedFrame + offset + 2) << 8 - | *(decodedFrame + offset + 3); - offset += 4; - temperatureSet.time = static_cast(*(decodedFrame + offset)) << 56 - | static_cast(*(decodedFrame + offset + 1)) << 48 - | static_cast(*(decodedFrame + offset + 2)) << 40 - | static_cast(*(decodedFrame + offset + 3)) << 32 - | *(decodedFrame + offset + 4) << 24 | *(decodedFrame + offset + 5) << 16 - | *(decodedFrame + offset + 6) << 8 | *(decodedFrame + offset + 7); - offset += 8; + const uint8_t* buffer = decodedFrame + offset; + size_t size = sizeof(temperatureSet.ticks); + SerializeAdapter::deSerialize(&temperatureSet.ticks, &buffer, &size, SerializeIF::Endianness::LITTLE); + offset += size; + buffer = decodedFrame + offset; + size = sizeof(temperatureSet.time); + SerializeAdapter::deSerialize(&temperatureSet.time, &buffer, &size, SerializeIF::Endianness::LITTLE); + offset += size; temperatureSet.mcuTemperature = *(decodedFrame + offset) << 24 | *(decodedFrame + offset + 1) << 16 | *(decodedFrame + offset + 2) << 8 | *(decodedFrame + offset + 3); - offset += 4; - temperatureSet.cmosTemperature = *(decodedFrame + offset) << 24 + offset += sizeof(temperatureSet.mcuTemperature); + temperatureSet.mcuTemperature = *(decodedFrame + offset) << 24 | *(decodedFrame + offset + 1) << 16 | *(decodedFrame + offset + 2) << 8 | *(decodedFrame + offset + 3); -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 + #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 + sif::info << "StarTrackerHandler::handleTemperatureTm: Ticks: " + << temperatureSet.ticks << std::endl; + sif::info << "StarTrackerHandler::handleTemperatureTm: Time: " + << temperatureSet.time << std::endl; sif::info << "StarTrackerHandler::handleTemperatureTm: MCU Temperature: " << temperatureSet.mcuTemperature << " °C" << std::endl; sif::info << "StarTrackerHandler::handleTemperatureTm: CMOS Temperature: " << temperatureSet.mcuTemperature << " °C" << std::endl; #endif + return result; } diff --git a/mission/devices/StarTrackerHandler.h b/mission/devices/StarTrackerHandler.h index 4d49064d..329536dd 100644 --- a/mission/devices/StarTrackerHandler.h +++ b/mission/devices/StarTrackerHandler.h @@ -12,7 +12,6 @@ * @details Datasheet: https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/EIVE_IRS/ * Arbeitsdaten/08_Used%20Components/ArcSec_KULeuven_Startracker/ * Sagitta%201.0%20Datapack&fileid=659181 - * * @author J. Meier */ class StarTrackerHandler: public DeviceHandlerBase { @@ -64,9 +63,10 @@ private: static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_HANDLER; - //! [EXPORT] : [COMMENT] Result code of tm reply indicates an error - - static const ReturnValue_t TM_REPLY_ERROR = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] Status in tm reply not ok + static const ReturnValue_t TEMPERATURE_REQUEST_FAILED = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] Ping command failed + static const ReturnValue_t PING_FAILED = MAKE_RETURN_CODE(0xA1); // Ping request will reply ping with this ID (data field) static const uint32_t PING_ID = 0x55; @@ -97,16 +97,22 @@ private: * @brief Fills command buffer with data to ping the star tracker */ void preparePingRequest(); + + /** + * @brief Fills command buffer with data to reboot star tracker. + */ + void prepareRebootCommand(); + /** * @brief Fills command buffer with data to request temperature from star tracker */ void prepareTemperatureRequest(); - void handlePingReply(); + ReturnValue_t handlePingReply(); /** * @brief This function handles the telemetry reply of a temperature request. */ - void handleTemperatureTm(); + ReturnValue_t handleTemperatureTm(); }; #endif /* MISSION_DEVICES_STARTRACKERHANDLER_H_ */ diff --git a/mission/devices/devicedefinitions/StarTrackerDefinitions.h b/mission/devices/devicedefinitions/StarTrackerDefinitions.h index efde795e..0b30b661 100644 --- a/mission/devices/devicedefinitions/StarTrackerDefinitions.h +++ b/mission/devices/devicedefinitions/StarTrackerDefinitions.h @@ -11,8 +11,9 @@ namespace StarTracker { /** This is the address of the star tracker */ static const uint8_t ADDRESS = 33; +static const uint8_t STATUS_OK = 0; + enum PoolIds: lp_id_t { - STATUS, TICKS, TIME, MCU_TEMPERATURE, @@ -22,6 +23,7 @@ enum PoolIds: lp_id_t { static const DeviceCommandId_t PING_REQUEST = 0; +static const DeviceCommandId_t REBOOT = 7; static const DeviceCommandId_t REQ_TEMPERATURE = 25; static const uint32_t TEMPERATURE_SET_ID = REQ_TEMPERATURE; @@ -46,8 +48,7 @@ public: StaticLocalDataSet(sid_t(objectId, TEMPERATURE_SET_ID)) { } - lp_var_t status = lp_var_t(sid.objectId, - PoolIds::STATUS, this); + // Ticks is time reference generated by interanl counter of the star tracker lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS, this); /** Unix time in microseconds */ From eb0e9c2a4193d871807257e64f1dd938b387ac72 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Fri, 26 Nov 2021 15:24:52 +0100 Subject: [PATCH 106/465] request version command --- mission/devices/StarTrackerHandler.cpp | 65 +++++++++++++++++-- mission/devices/StarTrackerHandler.h | 11 ++++ .../StarTrackerDefinitions.h | 49 ++++++++++++-- 3 files changed, 115 insertions(+), 10 deletions(-) diff --git a/mission/devices/StarTrackerHandler.cpp b/mission/devices/StarTrackerHandler.cpp index ebb23033..10805f7e 100644 --- a/mission/devices/StarTrackerHandler.cpp +++ b/mission/devices/StarTrackerHandler.cpp @@ -12,7 +12,7 @@ extern "C" { StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - DeviceHandlerBase(objectId, comIF, comCookie), temperatureSet(this) { + DeviceHandlerBase(objectId, comIF, comCookie), temperatureSet(this), versionSet(this) { if (comCookie == NULL) { sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl; } @@ -61,6 +61,10 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi preparePingRequest(); return RETURN_OK; } + case (StarTracker::REQ_VERSION): { + prepareVersionRequest(); + return RETURN_OK; + } case (StarTracker::REBOOT): { prepareRebootCommand(); return RETURN_OK; @@ -80,6 +84,8 @@ void StarTrackerHandler::fillCommandAndReplyMap() { * is specified */ this->insertInCommandAndReplyMap(StarTracker::PING_REQUEST, 1, nullptr, StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_VERSION, 1, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandMap(StarTracker::REBOOT); this->insertInCommandAndReplyMap(StarTracker::REQ_TEMPERATURE, 1, &temperatureSet, StarTracker::MAX_FRAME_SIZE * 2 + 2); @@ -124,6 +130,11 @@ ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t rema *foundId = StarTracker::PING_REQUEST; break; } + case (static_cast(StarTracker::REQ_VERSION)): { + *foundLen = decodedLength; + *foundId = StarTracker::PING_REQUEST; + break; + } case (static_cast(StarTracker::REQ_TEMPERATURE)): { *foundLen = decodedLength; *foundId = StarTracker::REQ_TEMPERATURE; @@ -149,6 +160,10 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con result = handlePingReply(); break; } + case (StarTracker::REQ_VERSION): { + result = handleVersionTm(); + break; + } case (StarTracker::REQ_TEMPERATURE): { handleTemperatureTm(); break; @@ -174,8 +189,13 @@ uint32_t StarTrackerHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) { - localDataPoolMap.emplace(StarTracker::TICKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_VERSION_SET, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TIME_VERSION_SET, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::PROGRAM, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::MAJOR, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::MINOR, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_TEMPERATURE_SET, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TIME_TEMPERATURE_SET, new PoolEntry( { 0 })); localDataPoolMap.emplace(StarTracker::MCU_TEMPERATURE, new PoolEntry( { 0 })); localDataPoolMap.emplace(StarTracker::CMOS_TEMPERATURE, new PoolEntry( { 0 })); @@ -204,6 +224,15 @@ void StarTrackerHandler::preparePingRequest() { rawPacketLen = encLength; } +void StarTrackerHandler::prepareVersionRequest() { + uint32_t length = 0; + arc_tm_pack_version_req(commandBuffer, &length); + uint32_t encLength = 0; + arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength); + rawPacket = encBuffer; + rawPacketLen = encLength; +} + void StarTrackerHandler::prepareRebootCommand() { uint32_t length = 0; struct RebootActionRequest rebootReq; @@ -240,6 +269,34 @@ ReturnValue_t StarTrackerHandler::handlePingReply() { return result; } +ReturnValue_t StarTrackerHandler::handleVersionTm() { + ReturnValue_t result = RETURN_OK; + PoolReadGuard rg(&versionSet); + uint32_t offset = 2; + uint8_t status = *(decodedFrame + offset); + offset += 1; + if(status != StarTracker::STATUS_OK) { + sif::warning << "StarTrackerHandler::handleTemperatureTm: Reply error: " + << static_cast(status) << std::endl; + result = TEMPERATURE_REQUEST_FAILED; + return result; + } + versionSet.program = (*decodedFrame + offset); + offset += 1; + versionSet.major = (*decodedFrame + offset); + offset += 1; + versionSet.minor = (*decodedFrame + offset); +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 + sif::info << "StarTrackerHandler::handleVersionTm: Program: " + << versionSet.program << std::endl; + sif::info << "StarTrackerHandler::handleVersionTm: Major: " + << versionSet.major << std::endl; + sif::info << "StarTrackerHandler::handleVersionTm: Minor: " + << versionSet.minor << std::endl; +#endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ + return result; +} + ReturnValue_t StarTrackerHandler::handleTemperatureTm() { ReturnValue_t result = RETURN_OK; PoolReadGuard rg(&temperatureSet); @@ -267,7 +324,7 @@ ReturnValue_t StarTrackerHandler::handleTemperatureTm() { temperatureSet.mcuTemperature = *(decodedFrame + offset) << 24 | *(decodedFrame + offset + 1) << 16 | *(decodedFrame + offset + 2) << 8 | *(decodedFrame + offset + 3); - #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 sif::info << "StarTrackerHandler::handleTemperatureTm: Ticks: " << temperatureSet.ticks << std::endl; sif::info << "StarTrackerHandler::handleTemperatureTm: Time: " diff --git a/mission/devices/StarTrackerHandler.h b/mission/devices/StarTrackerHandler.h index 329536dd..89bd7097 100644 --- a/mission/devices/StarTrackerHandler.h +++ b/mission/devices/StarTrackerHandler.h @@ -72,6 +72,7 @@ private: static const uint32_t PING_ID = 0x55; StarTracker::TemperatureSet temperatureSet; + StarTracker::VersionSet versionSet; uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE]; uint8_t rxBuffer[StarTracker::MAX_FRAME_SIZE]; @@ -98,6 +99,11 @@ private: */ void preparePingRequest(); + /** + * @brief Fills command buffer with data to request the version telemetry packet + */ + void prepareVersionRequest(); + /** * @brief Fills command buffer with data to reboot star tracker. */ @@ -113,6 +119,11 @@ private: * @brief This function handles the telemetry reply of a temperature request. */ ReturnValue_t handleTemperatureTm(); + + /** + * @brief This function handles the telemetry reply of a version request. + */ + ReturnValue_t handleVersionTm(); }; #endif /* MISSION_DEVICES_STARTRACKERHANDLER_H_ */ diff --git a/mission/devices/devicedefinitions/StarTrackerDefinitions.h b/mission/devices/devicedefinitions/StarTrackerDefinitions.h index 0b30b661..6772abfe 100644 --- a/mission/devices/devicedefinitions/StarTrackerDefinitions.h +++ b/mission/devices/devicedefinitions/StarTrackerDefinitions.h @@ -14,24 +14,32 @@ static const uint8_t ADDRESS = 33; static const uint8_t STATUS_OK = 0; enum PoolIds: lp_id_t { - TICKS, - TIME, + TICKS_VERSION_SET, + TIME_VERSION_SET, + TICKS_TEMPERATURE_SET, + TIME_TEMPERATURE_SET, MCU_TEMPERATURE, - CMOS_TEMPERATURE + CMOS_TEMPERATURE, + PROGRAM, + MAJOR, + MINOR }; static const DeviceCommandId_t PING_REQUEST = 0; +static const DeviceCommandId_t REQ_VERSION = 2; static const DeviceCommandId_t REBOOT = 7; static const DeviceCommandId_t REQ_TEMPERATURE = 25; +static const uint32_t VERSION_SET_ID = REQ_VERSION; static const uint32_t TEMPERATURE_SET_ID = REQ_TEMPERATURE; /** Max size of unencoded frame */ static const size_t MAX_FRAME_SIZE = 1200; -static const uint8_t TEMPERATURE_SET_ENTRIES = 5; +static const uint8_t TEMPERATURE_SET_ENTRIES = 4; +static const uint8_t VERSION_SET_ENTRIES = 3; /** * @brief This dataset can be used to store the temperature of a reaction wheel. @@ -50,16 +58,45 @@ public: // Ticks is time reference generated by interanl counter of the star tracker lp_var_t ticks = lp_var_t(sid.objectId, - PoolIds::TICKS, this); + PoolIds::TICKS_TEMPERATURE_SET, this); /** Unix time in microseconds */ lp_var_t time = lp_var_t(sid.objectId, - PoolIds::TIME, this); + PoolIds::TIME_TEMPERATURE_SET, this); lp_var_t mcuTemperature = lp_var_t(sid.objectId, PoolIds::MCU_TEMPERATURE, this); lp_var_t cmosTemperature = lp_var_t(sid.objectId, PoolIds::CMOS_TEMPERATURE, this); }; +/** + * @brief Package to store version parameters + */ +class VersionSet: + public StaticLocalDataSet { +public: + + VersionSet(HasLocalDataPoolIF* owner): + StaticLocalDataSet(owner, VERSION_SET_ID) { + } + + VersionSet(object_id_t objectId): + StaticLocalDataSet(sid_t(objectId, VERSION_SET_ID)) { + } + + // Ticks is time reference generated by interanl counter of the star tracker + lp_var_t ticks = lp_var_t(sid.objectId, + PoolIds::TICKS_VERSION_SET, this); + /** Unix time in microseconds */ + lp_var_t time = lp_var_t(sid.objectId, + PoolIds::TIME_VERSION_SET, this); + lp_var_t program = lp_var_t(sid.objectId, + PoolIds::PROGRAM, this); + lp_var_t major = lp_var_t(sid.objectId, + PoolIds::MAJOR, this); + lp_var_t minor = lp_var_t(sid.objectId, + PoolIds::MINOR, this); +}; + } #endif /* MISSION_STARTRACKER_DEFINITIONS_H_ */ From 5ea129d2529b11376544236ab4624c0975a6a7fa Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Sat, 27 Nov 2021 19:40:52 +0100 Subject: [PATCH 107/465] star tracker solution telemetry --- mission/devices/StarTrackerHandler.cpp | 734 ++++++++++++++++-- mission/devices/StarTrackerHandler.h | 123 ++- .../StarTrackerDefinitions.h | 355 ++++++++- 3 files changed, 1137 insertions(+), 75 deletions(-) diff --git a/mission/devices/StarTrackerHandler.cpp b/mission/devices/StarTrackerHandler.cpp index 10805f7e..ce69d41d 100644 --- a/mission/devices/StarTrackerHandler.cpp +++ b/mission/devices/StarTrackerHandler.cpp @@ -2,7 +2,6 @@ #include "OBSWConfig.h" #include -#include extern "C" { #include @@ -12,7 +11,8 @@ extern "C" { StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - DeviceHandlerBase(objectId, comIF, comCookie), temperatureSet(this), versionSet(this) { + DeviceHandlerBase(objectId, comIF, comCookie), temperatureSet(this), versionSet(this), powerSet( + this), interfaceSet(this), timeSet(this), solutionSet(this) { if (comCookie == NULL) { sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl; } @@ -61,14 +61,38 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi preparePingRequest(); return RETURN_OK; } + case (StarTracker::REQ_TIME): { + prepareTimeRequest(); + return RETURN_OK; + } + case (StarTracker::BOOT): { + prepareBootCommand(); + return RETURN_OK; + } case (StarTracker::REQ_VERSION): { prepareVersionRequest(); return RETURN_OK; } + case (StarTracker::REQ_INTERFACE): { + prepareInterfaceRequest(); + return RETURN_OK; + } + case (StarTracker::REQ_POWER): { + preparePowerRequest(); + return RETURN_OK; + } case (StarTracker::REBOOT): { prepareRebootCommand(); return RETURN_OK; } + case (StarTracker::SUBSCRIBE_TO_TM): { + prepareSubscriptionCommand(commandData); + return RETURN_OK; + } + case (StarTracker::REQ_SOLUTION): { + prepareSolutionRequest(); + return RETURN_OK; + } case (StarTracker::REQ_TEMPERATURE): { prepareTemperatureRequest(); return RETURN_OK; @@ -82,26 +106,44 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi void StarTrackerHandler::fillCommandAndReplyMap() { /** Reply lengths are unknown because of the slip encoding. Thus always maximum reply size * is specified */ - this->insertInCommandAndReplyMap(StarTracker::PING_REQUEST, 1, nullptr, + this->insertInCommandAndReplyMap(StarTracker::PING_REQUEST, 3, nullptr, StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_VERSION, 1, nullptr, + this->insertInCommandAndReplyMap(StarTracker::BOOT, 3, nullptr, StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_VERSION, 3, &versionSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_TIME, 3, &timeSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_POWER, 3, &powerSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_INTERFACE, 3, &interfaceSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + // Reboot has no reply. Star tracker reboots immediately this->insertInCommandMap(StarTracker::REBOOT); - this->insertInCommandAndReplyMap(StarTracker::REQ_TEMPERATURE, 1, &temperatureSet, + this->insertInCommandAndReplyMap(StarTracker::SUBSCRIBE_TO_TM, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_SOLUTION, 3, &solutionSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_TEMPERATURE, 3, &temperatureSet, StarTracker::MAX_FRAME_SIZE * 2 + 2); } ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { + ReturnValue_t result = RETURN_OK; uint32_t decodedLength = 0; - - for (size_t idx = 0; idx < remainingSize; idx++) { - enum arc_dec_result decResult = arc_transport_decode_body(*(start + idx), &slipInfo, + size_t bytePos = 0; + for (bytePos = 0; bytePos < remainingSize; bytePos++) { + enum arc_dec_result decResult = arc_transport_decode_body(*(start + bytePos), &slipInfo, decodedFrame, &decodedLength); switch (decResult) { case ARC_DEC_INPROGRESS: { + if (bytePos == remainingSize - 1) { + // second doSendread() required to read whole packet + return IGNORE_FULL_PACKET; + } continue; } case ARC_DEC_ASYNC: { @@ -124,31 +166,30 @@ ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t rema } } - switch (decodedFrame[1]) { - case (static_cast(StarTracker::PING_REQUEST)): { - *foundLen = decodedLength; - *foundId = StarTracker::PING_REQUEST; + switch (decodedFrame[0]) { + case TMTC_ACTIONREPLY: { + *foundLen = bytePos; + result = scanForActionReply(foundId); break; } - case (static_cast(StarTracker::REQ_VERSION)): { - *foundLen = decodedLength; - *foundId = StarTracker::PING_REQUEST; + case TMTC_SETPARAMREPLY: { + *foundLen = bytePos; + result = scanForSetParameterReply(foundId); break; } - case (static_cast(StarTracker::REQ_TEMPERATURE)): { - *foundLen = decodedLength; - *foundId = StarTracker::REQ_TEMPERATURE; + case TMTC_TELEMETRYREPLYA: + case TMTC_TELEMETRYREPLY: { + *foundLen = bytePos; + result = scanForTmReply(foundId); break; } default: { - sif::debug << "StarTrackerHandler::scanForReply: Reply contains invalid reply id" - << std::endl; - return RETURN_FAILED; - break; + sif::debug << "StarTrackerHandler::scanForReply: Reply has invalid type id" << std::endl; + result = RETURN_FAILED; } } - return RETURN_OK; + return result; } ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { @@ -156,14 +197,38 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con ReturnValue_t result = RETURN_OK; switch (id) { + case (StarTracker::SUBSCRIBE_TO_TM): { + result = handleSetParamReply(); + break; + } + case (StarTracker::REQ_TIME): { + result = handleTimeTm(); + break; + } case (StarTracker::PING_REQUEST): { result = handlePingReply(); break; } + case (StarTracker::BOOT): { + result = handleActionReply(); + break; + } case (StarTracker::REQ_VERSION): { result = handleVersionTm(); break; } + case (StarTracker::REQ_INTERFACE): { + result = handleInterfaceTm(); + break; + } + case (StarTracker::REQ_POWER): { + result = handlePowerTm(); + break; + } + case (StarTracker::REQ_SOLUTION): { + handleSolutionTm(); + break; + } case (StarTracker::REQ_TEMPERATURE): { handleTemperatureTm(); break; @@ -171,13 +236,14 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con default: { sif::debug << "StarTrackerHandler::interpretDeviceReply: Unknown device reply id:" << id << std::endl; - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; + result = DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; } } return result; } + void StarTrackerHandler::setNormalDatapoolEntriesInvalid() { } @@ -189,16 +255,78 @@ uint32_t StarTrackerHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) { + localDataPoolMap.emplace(StarTracker::TICKS_TIME_SET, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TIME_TIME_SET, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::RUN_TIME, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::UNIX_TIME, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_VERSION_SET, new PoolEntry( { 0 })); localDataPoolMap.emplace(StarTracker::TIME_VERSION_SET, new PoolEntry( { 0 })); localDataPoolMap.emplace(StarTracker::PROGRAM, new PoolEntry( { 0 })); localDataPoolMap.emplace(StarTracker::MAJOR, new PoolEntry( { 0 })); localDataPoolMap.emplace(StarTracker::MINOR, new PoolEntry( { 0 })); + + localDataPoolMap.emplace(StarTracker::TICKS_INTERFACE_SET, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TIME_INTERFACE_SET, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::FRAME_COUNT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CHECKSUM_ERROR_COUNT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::SET_PARAM_COUNT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::SET_PARAM_REPLY_COUNT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::PARAM_REQUEST_COUNT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::PARAM_REPLY_COUNT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::REQ_TM_COUNT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TM_REPLY_COUNT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::ACTION_REQ_COUNT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::ACTION_REPLY_COUNT, new PoolEntry( { 0 })); + + localDataPoolMap.emplace(StarTracker::TICKS_POWER_SET, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TIME_POWER_SET, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::MCU_CURRENT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::MCU_VOLTAGE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::FPGA_CORE_CURRENT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::FPGA_CORE_VOLTAGE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::FPGA_18_CURRENT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::FPGA_18_VOLTAGE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::FPGA_25_CURRENT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::FPGA_25_VOLTAGE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CMV_21_CURRENT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CMV_21_VOLTAGE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CMV_PIX_CURRENT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CMV_PIX_VOLTAGE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CMV_33_CURRENT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CMV_33_VOLTAGE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CMV_RES_CURRENT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CMV_RES_VOLTAGE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_TEMPERATURE_SET, new PoolEntry( { 0 })); localDataPoolMap.emplace(StarTracker::TIME_TEMPERATURE_SET, new PoolEntry( { 0 })); localDataPoolMap.emplace(StarTracker::MCU_TEMPERATURE, new PoolEntry( { 0 })); localDataPoolMap.emplace(StarTracker::CMOS_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_SOLUTION_SET, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TIME_SOLUTION_SET, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CALI_QW, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CALI_QX, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CALI_QY, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CALI_QZ, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TRACK_CONFIDENCE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TRACK_QW, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TRACK_QX, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TRACK_QY, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TRACK_QZ, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TRACK_REMOVED, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::STARS_CENTROIDED, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::STARS_MATCHED_DATABASE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::LISA_QW, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::LISA_QX, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::LISA_QY, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::LISA_QZ, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::LISA_PERC_CLOSE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::LISA_NR_CLOSE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TRUST_WORTHY, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::STABLE_COUNT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::SOLUTION_STRATEGY, new PoolEntry( { 0 })); + return RETURN_OK; } @@ -206,6 +334,74 @@ size_t StarTrackerHandler::getNextReplyLength(DeviceCommandId_t commandId){ return StarTracker::MAX_FRAME_SIZE; } +ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t *foundId) { + switch (decodedFrame[1]) { + case (StarTracker::ID::PING): { + *foundId = StarTracker::PING_REQUEST; + break; + } + case (StarTracker::ID::BOOT): { + *foundId = StarTracker::BOOT; + break; + } + default: + sif::debug << "StarTrackerHandler::scanForSetParameterReply: Unknown parameter reply id" + << std::endl; + return RETURN_FAILED; + } + return RETURN_OK; +} + +ReturnValue_t StarTrackerHandler::scanForSetParameterReply(DeviceCommandId_t *foundId) { + switch (decodedFrame[1]) { + case (StarTracker::ID::SUBSCRIBE): { + *foundId = StarTracker::SUBSCRIBE_TO_TM; + break; + } + default: + sif::debug << "StarTrackerHandler::scanForSetParameterReply: Unknown parameter reply id" + << std::endl; + return RETURN_FAILED; + } + return RETURN_OK; +} + +ReturnValue_t StarTrackerHandler::scanForTmReply(DeviceCommandId_t *foundId) { + switch (decodedFrame[1]) { + case (StarTracker::ID::VERSION): { + *foundId = StarTracker::REQ_VERSION; + break; + } + case (StarTracker::ID::INTERFACE): { + *foundId = StarTracker::REQ_INTERFACE; + break; + } + case (StarTracker::ID::POWER): { + *foundId = StarTracker::REQ_POWER; + break; + } + case (StarTracker::ID::TEMPERATURE): { + *foundId = StarTracker::REQ_TEMPERATURE; + break; + } + case (StarTracker::ID::TIME): { + *foundId = StarTracker::REQ_TIME; + break; + } + case (StarTracker::ID::SOLUTION): { + *foundId = StarTracker::REQ_SOLUTION; + break; + } + default: { + sif::debug << "StarTrackerHandler::scanForReply: Reply contains invalid reply id" + << std::endl; + return RETURN_FAILED; + break; + } + } + return RETURN_OK; +} + void StarTrackerHandler::slipInit() { slipInfo.buffer = rxBuffer; slipInfo.maxlength = StarTracker::MAX_FRAME_SIZE; @@ -214,6 +410,25 @@ void StarTrackerHandler::slipInit() { slipInfo.prev_state = SLIP_COMPLETE; } +void StarTrackerHandler::prepareBootCommand() { + uint32_t length = 0; + struct BootActionRequest bootRequest = {BOOT_REGION_ID}; + arc_pack_boot_action_req(&bootRequest, commandBuffer, &length); + uint32_t encLength = 0; + arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength); + rawPacket = encBuffer; + rawPacketLen = encLength; +} + +void StarTrackerHandler::prepareTimeRequest() { + uint32_t length = 0; + arc_tm_pack_time_req(commandBuffer, &length); + uint32_t encLength = 0; + arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength); + rawPacket = encBuffer; + rawPacketLen = encLength; +} + void StarTrackerHandler::preparePingRequest() { uint32_t length = 0; struct PingActionRequest pingRequest = {PING_ID}; @@ -233,6 +448,24 @@ void StarTrackerHandler::prepareVersionRequest() { rawPacketLen = encLength; } +void StarTrackerHandler::prepareInterfaceRequest() { + uint32_t length = 0; + arc_tm_pack_interface_req(commandBuffer, &length); + uint32_t encLength = 0; + arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength); + rawPacket = encBuffer; + rawPacketLen = encLength; +} + +void StarTrackerHandler::preparePowerRequest() { + uint32_t length = 0; + arc_tm_pack_power_req(commandBuffer, &length); + uint32_t encLength = 0; + arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength); + rawPacket = encBuffer; + rawPacketLen = encLength; +} + void StarTrackerHandler::prepareRebootCommand() { uint32_t length = 0; struct RebootActionRequest rebootReq; @@ -243,6 +476,42 @@ void StarTrackerHandler::prepareRebootCommand() { rawPacketLen = encLength; } +void StarTrackerHandler::prepareSubscriptionCommand(const uint8_t* tmId) { + uint32_t encLength = 0; + uint32_t length = 18; + commandBuffer[0] = TMTC_SETPARAMREQ; + commandBuffer[1] = StarTracker::ID::SUBSCRIBE; + // Fill all other fields with invalid tm id + commandBuffer[2] = *tmId; + commandBuffer[3] = 0; + commandBuffer[4] = 0; + commandBuffer[5] = 0; + commandBuffer[6] = 0; + commandBuffer[7] = 0; + commandBuffer[8] = 0; + commandBuffer[9] = 0; + commandBuffer[10] = 0; + commandBuffer[11] = 0; + commandBuffer[12] = 0; + commandBuffer[13] = 0; + commandBuffer[14] = 0; + commandBuffer[15] = 0; + commandBuffer[16] = 0; + commandBuffer[17] = 0; + arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength); + rawPacket = encBuffer; + rawPacketLen = encLength; +} + +void StarTrackerHandler::prepareSolutionRequest() { + uint32_t length = 0; + arc_tm_pack_solution_req(commandBuffer, &length); + uint32_t encLength = 0; + arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength); + rawPacket = encBuffer; + rawPacketLen = encLength; +} + void StarTrackerHandler::prepareTemperatureRequest() { uint32_t length = 0; arc_tm_pack_temperature_req(commandBuffer, &length); @@ -252,6 +521,29 @@ void StarTrackerHandler::prepareTemperatureRequest() { rawPacketLen = encLength; } +ReturnValue_t StarTrackerHandler::handleSetParamReply() { + uint8_t status = *(decodedFrame + STATUS_OFFSET); + if (status != StarTracker::STATUS_OK) { + sif::warning << "StarTrackerHandler::handleSetParamReply: Failed to execute parameter set " + " command with parameter ID" << + static_cast(*(decodedFrame + PARAMETER_ID_OFFSET)) << std::endl; + return SET_PARAM_FAILED; + } + return RETURN_OK; +} + +ReturnValue_t StarTrackerHandler::handleActionReply() { + uint8_t status = *(decodedFrame + STATUS_OFFSET); + if (status != StarTracker::STATUS_OK) { + sif::warning << "StarTrackerHandler::handleActionReply: Failed to execute action " + << " command with action ID " + << static_cast(*(decodedFrame + ACTION_ID_OFFSET)) + << " and status "<< static_cast(status) << std::endl; + return ACTION_FAILED; + } + return RETURN_OK; +} + ReturnValue_t StarTrackerHandler::handlePingReply() { ReturnValue_t result = RETURN_OK; uint32_t pingId = 0; @@ -269,70 +561,380 @@ ReturnValue_t StarTrackerHandler::handlePingReply() { return result; } +ReturnValue_t StarTrackerHandler::handleTimeTm() { + ReturnValue_t result = RETURN_OK; + PoolReadGuard rg(&timeSet); + uint32_t offset = TM_DATA_FIELD_OFFSET; + uint8_t status = 0; + uint32_t ticks = 0; + uint64_t time = 0; + getTmHeaderData(&status, &ticks, &time); + if(status != StarTracker::STATUS_OK) { + sif::warning << "StarTrackerHandler::handleVersionTm: Reply error: " + << static_cast(status) << std::endl; + result = VERSION_REQ_FAILED; + return result; + } + timeSet.ticks = ticks; + timeSet.time = time; + timeSet.runTime = deserializeUint32(decodedFrame + offset); + offset += sizeof(uint32_t); + timeSet.unixTime = deserializeUint64(decodedFrame + offset); +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 + sif::info << "StarTrackerHandler::handleTimeTm: Ticks: " + << timeSet.ticks << std::endl; + sif::info << "StarTrackerHandler::handleTimeTm: Time (time stamp): " + << timeSet.time << " us" << std::endl; + sif::info << "StarTrackerHandler::handleTimeTm: Run Time: " + << timeSet.runTime << " ms" << std::endl; + sif::info << "StarTrackerHandler::handleTimeTm: Unix Time: " + << timeSet.unixTime << " s" << std::endl; +#endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ + return result; +} + ReturnValue_t StarTrackerHandler::handleVersionTm() { ReturnValue_t result = RETURN_OK; PoolReadGuard rg(&versionSet); - uint32_t offset = 2; - uint8_t status = *(decodedFrame + offset); + uint32_t offset = TM_DATA_FIELD_OFFSET; + uint8_t status = 0; + uint32_t ticks = 0; + uint64_t time = 0; + getTmHeaderData(&status, &ticks, &time); + if(status != StarTracker::STATUS_OK) { + sif::warning << "StarTrackerHandler::handleVersionTm: Reply error: " + << static_cast(status) << std::endl; + result = VERSION_REQ_FAILED; + return result; + } + versionSet.ticks = ticks; + versionSet.time = time; + versionSet.program = *(decodedFrame + offset); offset += 1; + versionSet.major = *(decodedFrame + offset); + offset += 1; + versionSet.minor = *(decodedFrame + offset); +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 + sif::info << "StarTrackerHandler::handleVersionTm: Ticks: " + << versionSet.ticks << std::endl; + sif::info << "StarTrackerHandler::handleVersionTm: Unix Time: " + << versionSet.time << " us" << std::endl; + sif::info << "StarTrackerHandler::handleVersionTm: Program: " + << static_cast(versionSet.program.value) << std::endl; + sif::info << "StarTrackerHandler::handleVersionTm: Major: " + << static_cast(versionSet.major.value) << std::endl; + sif::info << "StarTrackerHandler::handleVersionTm: Minor: " + << static_cast(versionSet.minor.value) << std::endl; +#endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ + return result; +} + +ReturnValue_t StarTrackerHandler::handleInterfaceTm() { + ReturnValue_t result = RETURN_OK; + PoolReadGuard rg(&interfaceSet); + uint32_t offset = TM_DATA_FIELD_OFFSET; + uint8_t status = 0; + uint32_t ticks = 0; + uint64_t time = 0; + getTmHeaderData(&status, &ticks, &time); + if(status != StarTracker::STATUS_OK) { + sif::warning << "StarTrackerHandler::handleInterfaceTm: Reply error: " + << static_cast(status) << std::endl; + result = INTERFACE_REQ_FAILED; + return result; + } + interfaceSet.ticks = ticks; + interfaceSet.time = time; + size_t size = sizeof(uint32_t); + interfaceSet.frameCount = deserializeUint32(decodedFrame + offset); + offset += size; + interfaceSet.checksumerrorCount = deserializeUint32(decodedFrame + offset); + offset += size; + interfaceSet.setParamCount = deserializeUint32(decodedFrame + offset); + offset += size; + interfaceSet.setParamReplyCount = deserializeUint32(decodedFrame + offset); + offset += size; + interfaceSet.paramRequestCount = deserializeUint32(decodedFrame + offset); + offset += size; + interfaceSet.paramReplyCount = deserializeUint32(decodedFrame + offset); + offset += size; + interfaceSet.tmReplyCount = deserializeUint32(decodedFrame + offset); + offset += size; + interfaceSet.actionReqCount = deserializeUint32(decodedFrame + offset); + offset += size; + interfaceSet.actionReplyCount = deserializeUint32(decodedFrame + offset); + +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 + sif::info << "StarTrackerHandler::handleInterfaceTm: Ticks: " + << interfaceSet.ticks << std::endl; + sif::info << "StarTrackerHandler::handleInterfaceTm: Time: " + << interfaceSet.time << " us" << std::endl; + sif::info << "StarTrackerHandler::handleInterfaceTm: Frame Count: " + << interfaceSet.frameCount << std::endl; + sif::info << "StarTrackerHandler::handleInterfaceTm: Checksum Error Count: " + << interfaceSet.checksumerrorCount << std::endl; + sif::info << "StarTrackerHandler::handleInterfaceTm: Set Param Count: " + << interfaceSet.setParamCount << std::endl; + sif::info << "StarTrackerHandler::handleInterfaceTm: Set Param Reply Count: " + << interfaceSet.setParamReplyCount << std::endl; + sif::info << "StarTrackerHandler::handleInterfaceTm: Param Request Count: " + << interfaceSet.paramRequestCount << std::endl; + sif::info << "StarTrackerHandler::handleInterfaceTm: Param Reply Count: " + << interfaceSet.paramReplyCount << std::endl; + sif::info << "StarTrackerHandler::handleInterfaceTm: Req TM Count: " + << interfaceSet.reqTmCount << std::endl; + sif::info << "StarTrackerHandler::handleInterfaceTm: Telemetry Reply Count: " + << interfaceSet.tmReplyCount << std::endl; + sif::info << "StarTrackerHandler::handleInterfaceTm: Action Request Count: " + << interfaceSet.actionReqCount << std::endl; + sif::info << "StarTrackerHandler::handleInterfaceTm: Action Reply Count: " + << interfaceSet.actionReplyCount << std::endl; +#endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ + return result; +} + +ReturnValue_t StarTrackerHandler::handlePowerTm() { + ReturnValue_t result = RETURN_OK; + PoolReadGuard rg(&powerSet); + uint32_t offset = TM_DATA_FIELD_OFFSET; + uint8_t status = 0; + uint32_t ticks = 0; + uint64_t time = 0; + getTmHeaderData(&status, &ticks, &time); + if(status != StarTracker::STATUS_OK) { + sif::warning << "StarTrackerHandler::handlePowerTm: Reply error: " + << static_cast(status) << std::endl; + result = POWER_REQ_FAILED; + return result; + } + powerSet.ticks= ticks; + powerSet.time= time; + float value = 0; + std::memcpy(&value, decodedFrame + offset, sizeof(value)); + powerSet.mcuCurrent = value; + offset += 4; + std::memcpy(&value, decodedFrame + offset, sizeof(value)); + powerSet.mcuVoltage = value; + offset += 4; + std::memcpy(&value, decodedFrame + offset, sizeof(value)); + powerSet.fpgaCoreCurrent = value; + offset += 4; + std::memcpy(&value, decodedFrame + offset, sizeof(value)); + powerSet.fpgaCoreVoltage = value; + offset += 4; + std::memcpy(&value, decodedFrame + offset, sizeof(value)); + powerSet.fpga18Current = value; + offset += 4; + std::memcpy(&value, decodedFrame + offset, sizeof(value)); + powerSet.fpga18Voltage = value; + offset += 4; + std::memcpy(&value, decodedFrame + offset, sizeof(value)); + powerSet.fpga25Current = value; + offset += 4; + std::memcpy(&value, decodedFrame + offset, sizeof(value)); + powerSet.fpga25Voltage = value; + offset += 4; + std::memcpy(&value, decodedFrame + offset, sizeof(value)); + powerSet.cmv21Current = value; + offset += 4; + std::memcpy(&value, decodedFrame + offset, sizeof(value)); + powerSet.cmv21Voltage = value; + offset += 4; + std::memcpy(&value, decodedFrame + offset, sizeof(value)); + powerSet.cmvPixCurrent= value; + offset += 4; + std::memcpy(&value, decodedFrame + offset, sizeof(value)); + powerSet.cmvPixVoltage = value; + offset += 4; + std::memcpy(&value, decodedFrame + offset, sizeof(value)); + powerSet.cmv33Current= value; + offset += 4; + std::memcpy(&value, decodedFrame + offset, sizeof(value)); + powerSet.cmv33Voltage = value; + offset += 4; + std::memcpy(&value, decodedFrame + offset, sizeof(value)); + powerSet.cmvResCurrent= value; + offset += 4; + std::memcpy(&value, decodedFrame + offset, sizeof(value)); + powerSet.cmvResVoltage = value; +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 + sif::info << "StarTrackerHandler::handlePowerTm: Ticks: " + << powerSet.ticks << std::endl; + sif::info << "StarTrackerHandler::handlePowerTm: Time: " + << powerSet.time << " us" << std::endl; + sif::info << "StarTrackerHandler::handlePowerTm: MCU Current: " + << powerSet.mcuCurrent << " A" << std::endl; + sif::info << "StarTrackerHandler::handlePowerTm: MCU Voltage: " + << powerSet.mcuVoltage << " V" << std::endl; + sif::info << "StarTrackerHandler::handlePowerTm: FPGA Core current: " + << powerSet.fpgaCoreCurrent << " A" << std::endl; + sif::info << "StarTrackerHandler::handlePowerTm: FPGA Core voltage: " + << powerSet.fpgaCoreVoltage << " V" << std::endl; + sif::info << "StarTrackerHandler::handlePowerTm: FPGA 18 current: " + << powerSet.fpga18Current << " A" << std::endl; + sif::info << "StarTrackerHandler::handlePowerTm: FPGA 18 voltage: " + << powerSet.fpga18Voltage << " V" << std::endl; + sif::info << "StarTrackerHandler::handlePowerTm: FPGA 25 current: " + << powerSet.fpga25Current << " A" << std::endl; + sif::info << "StarTrackerHandler::handlePowerTm: FPGA 25 voltage: " + << powerSet.fpga25Voltage << " V" << std::endl; + sif::info << "StarTrackerHandler::handlePowerTm: CMV 21 current: " + << powerSet.cmv21Current << " A" << std::endl; + sif::info << "StarTrackerHandler::handlePowerTm: CMV 21 voltage: " + << powerSet.cmv21Voltage << " V" << std::endl; + sif::info << "StarTrackerHandler::handlePowerTm: CMV Pix current: " + << powerSet.cmvPixCurrent << " A" << std::endl; + sif::info << "StarTrackerHandler::handlePowerTm: CMV Pix voltage: " + << powerSet.cmvPixVoltage << " V" << std::endl; + sif::info << "StarTrackerHandler::handlePowerTm: CMV 33 current: " + << powerSet.cmv33Current << " A" << std::endl; + sif::info << "StarTrackerHandler::handlePowerTm: CMV 33 voltage: " + << powerSet.cmv33Voltage << " V" << std::endl; + sif::info << "StarTrackerHandler::handlePowerTm: CMV Res current: " + << powerSet.cmvResCurrent << " A" << std::endl; + sif::info << "StarTrackerHandler::handlePowerTm: CMV Res voltage: " + << powerSet.cmvResVoltage << " V" << std::endl; +#endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ + return result; +} + +ReturnValue_t StarTrackerHandler::handleSolutionTm() { + ReturnValue_t result = RETURN_OK; + result = solutionSet.read(MutexIF::TimeoutType::WAITING, 20); + if (result != RETURN_OK) { + return result; + } + uint32_t offset = TM_DATA_FIELD_OFFSET; + uint8_t status = 0; + uint32_t ticks = 0; + uint64_t time = 0; + getTmHeaderData(&status, &ticks, &time); if(status != StarTracker::STATUS_OK) { sif::warning << "StarTrackerHandler::handleTemperatureTm: Reply error: " << static_cast(status) << std::endl; - result = TEMPERATURE_REQUEST_FAILED; + result = TEMPERATURE_REQ_FAILED; + return result; + } + solutionSet.ticks= ticks; + solutionSet.time= time; + float word = 0; + std::memcpy(&word, decodedFrame + offset, sizeof(float)); + solutionSet.caliQw = word; + offset += sizeof(float); + std::memcpy(&word, decodedFrame + offset, sizeof(float)); + solutionSet.caliQx = word; + offset += sizeof(float); + std::memcpy(&word, decodedFrame + offset, sizeof(float)); + solutionSet.caliQy = word; + offset += sizeof(float); + std::memcpy(&word, decodedFrame + offset, sizeof(float)); + solutionSet.caliQz = word; + offset += sizeof(float); + std::memcpy(&word, decodedFrame + offset, sizeof(float)); + solutionSet.trackConfidence = word; + offset += sizeof(float); + std::memcpy(&word, decodedFrame + offset, sizeof(float)); + solutionSet.trackQw = word; + offset += sizeof(float); + std::memcpy(&word, decodedFrame + offset, sizeof(float)); + solutionSet.trackQx = word; + offset += sizeof(float); + std::memcpy(&word, decodedFrame + offset, sizeof(float)); + solutionSet.trackQy = word; + offset += sizeof(float); + std::memcpy(&word, decodedFrame + offset, sizeof(float)); + solutionSet.trackQz = word; + offset += sizeof(float); + solutionSet.trackRemoved = *(decodedFrame + offset); + offset += sizeof(uint8_t); + solutionSet.starsCentroided = *(decodedFrame + offset); + offset += sizeof(uint8_t); + solutionSet.starsMatchedDatabase = *(decodedFrame + offset); + offset += sizeof(float); + std::memcpy(&word, decodedFrame + offset, sizeof(float)); + solutionSet.lisaQw = word; + offset += sizeof(float); + std::memcpy(&word, decodedFrame + offset, sizeof(float)); + solutionSet.lisaQx = word; + offset += sizeof(float); + std::memcpy(&word, decodedFrame + offset, sizeof(float)); + solutionSet.lisaQy = word; + offset += sizeof(float); + std::memcpy(&word, decodedFrame + offset, sizeof(float)); + solutionSet.lisaQz = word; + offset += sizeof(float); + std::memcpy(&word, decodedFrame + offset, sizeof(float)); + solutionSet.lisaPercentageClose = word; + offset += sizeof(float); + solutionSet.lisaNrClose = *(decodedFrame + offset); + offset += sizeof(uint8_t); + solutionSet.isTrustWorthy = *(decodedFrame + offset); + offset += sizeof(uint8_t); + solutionSet.stableCount = *(decodedFrame + offset); + offset += sizeof(uint32_t); + solutionSet.stableCount = *(decodedFrame + offset); + result = solutionSet.commit(MutexIF::TimeoutType::WAITING, 20); + if (result != RETURN_OK) { return result; } - versionSet.program = (*decodedFrame + offset); - offset += 1; - versionSet.major = (*decodedFrame + offset); - offset += 1; - versionSet.minor = (*decodedFrame + offset); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - sif::info << "StarTrackerHandler::handleVersionTm: Program: " - << versionSet.program << std::endl; - sif::info << "StarTrackerHandler::handleVersionTm: Major: " - << versionSet.major << std::endl; - sif::info << "StarTrackerHandler::handleVersionTm: Minor: " - << versionSet.minor << std::endl; -#endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ + solutionSet.printSet(); +#endif return result; } ReturnValue_t StarTrackerHandler::handleTemperatureTm() { ReturnValue_t result = RETURN_OK; PoolReadGuard rg(&temperatureSet); - uint32_t offset = 2; - uint8_t status = *(decodedFrame + offset); - offset += 1; + uint32_t offset = TM_DATA_FIELD_OFFSET; + uint8_t status = 0; + uint32_t ticks = 0; + uint64_t time = 0; + getTmHeaderData(&status, &ticks, &time); if(status != StarTracker::STATUS_OK) { sif::warning << "StarTrackerHandler::handleTemperatureTm: Reply error: " << static_cast(status) << std::endl; - result = TEMPERATURE_REQUEST_FAILED; + result = TEMPERATURE_REQ_FAILED; return result; } - const uint8_t* buffer = decodedFrame + offset; - size_t size = sizeof(temperatureSet.ticks); - SerializeAdapter::deSerialize(&temperatureSet.ticks, &buffer, &size, SerializeIF::Endianness::LITTLE); - offset += size; - buffer = decodedFrame + offset; - size = sizeof(temperatureSet.time); - SerializeAdapter::deSerialize(&temperatureSet.time, &buffer, &size, SerializeIF::Endianness::LITTLE); - offset += size; - temperatureSet.mcuTemperature = *(decodedFrame + offset) << 24 - | *(decodedFrame + offset + 1) << 16 | *(decodedFrame + offset + 2) << 8 - | *(decodedFrame + offset + 3); - offset += sizeof(temperatureSet.mcuTemperature); - temperatureSet.mcuTemperature = *(decodedFrame + offset) << 24 - | *(decodedFrame + offset + 1) << 16 | *(decodedFrame + offset + 2) << 8 - | *(decodedFrame + offset + 3); + temperatureSet.ticks= ticks; + temperatureSet.time= time; + float temperature = 0; + std::memcpy(&temperature, decodedFrame + offset, sizeof(temperature)); + temperatureSet.mcuTemperature = temperature; + offset += sizeof(temperature); + std::memcpy(&temperature, decodedFrame + offset, sizeof(temperature)); + temperatureSet.cmosTemperature = temperature; #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - sif::info << "StarTrackerHandler::handleTemperatureTm: Ticks: " - << temperatureSet.ticks << std::endl; - sif::info << "StarTrackerHandler::handleTemperatureTm: Time: " - << temperatureSet.time << std::endl; - sif::info << "StarTrackerHandler::handleTemperatureTm: MCU Temperature: " - << temperatureSet.mcuTemperature << " °C" << std::endl; - sif::info << "StarTrackerHandler::handleTemperatureTm: CMOS Temperature: " - << temperatureSet.mcuTemperature << " °C" << std::endl; + solutionSet.printSet(); #endif return result; } + +void StarTrackerHandler::getTmHeaderData(uint8_t* status, uint32_t* ticks, uint64_t* time) { + *status = *(decodedFrame + STATUS_OFFSET); + *ticks = deserializeUint32(decodedFrame + TICKS_OFFSET); + *time = deserializeUint64(decodedFrame + TIME_OFFSET); +} + +uint32_t StarTrackerHandler::deserializeUint32(uint8_t* buffer) { + uint32_t word = 0; + word = *(buffer + 3) << 24 + | *(buffer + 2) << 16 + | *(buffer + 1) << 8 + | *(buffer); + return word; +} + +uint64_t StarTrackerHandler::deserializeUint64(uint8_t* buffer) { + uint64_t word = 0; + word = static_cast(*(buffer + 7)) << 56 + | static_cast(*(buffer + 6)) << 48 + | static_cast(*(buffer + 5)) << 40 + | static_cast(*(buffer + 4)) << 32 + | static_cast(*(buffer + 3)) << 24 + | static_cast(*(buffer + 2)) << 16 + | static_cast(*(buffer + 1)) << 8 + | static_cast(*(buffer)); + return word; +} diff --git a/mission/devices/StarTrackerHandler.h b/mission/devices/StarTrackerHandler.h index 89bd7097..a4389296 100644 --- a/mission/devices/StarTrackerHandler.h +++ b/mission/devices/StarTrackerHandler.h @@ -5,6 +5,7 @@ #include #include #include +#include /** * @brief This is the device handler for the star tracker from arcsec. @@ -63,16 +64,38 @@ private: static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_HANDLER; - //! [EXPORT] : [COMMENT] Status in tm reply not ok - static const ReturnValue_t TEMPERATURE_REQUEST_FAILED = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] Status in temperature reply signals error + static const ReturnValue_t TEMPERATURE_REQ_FAILED = MAKE_RETURN_CODE(0xA0); //! [EXPORT] : [COMMENT] Ping command failed static const ReturnValue_t PING_FAILED = MAKE_RETURN_CODE(0xA1); + //! [EXPORT] : [COMMENT] Status in version reply signals error + static const ReturnValue_t VERSION_REQ_FAILED = MAKE_RETURN_CODE(0xA3); + //! [EXPORT] : [COMMENT] Status in interface reply signals error + static const ReturnValue_t INTERFACE_REQ_FAILED = MAKE_RETURN_CODE(0xA4); + //! [EXPORT] : [COMMENT] Status in power reply signals error + static const ReturnValue_t POWER_REQ_FAILED = MAKE_RETURN_CODE(0xA5); + //! [EXPORT] : [COMMENT] Status of reply to parameter set command signals error + static const ReturnValue_t SET_PARAM_FAILED = MAKE_RETURN_CODE(0xA6); + //! [EXPORT] : [COMMENT] Status of reply to action command signals error + static const ReturnValue_t ACTION_FAILED = MAKE_RETURN_CODE(0xA7); + + static const uint8_t STATUS_OFFSET = 2; + static const uint8_t TICKS_OFFSET = 3; + static const uint8_t TIME_OFFSET = 7; + static const uint8_t TM_DATA_FIELD_OFFSET = 15; + static const uint8_t PARAMETER_ID_OFFSET = 1; + static const uint8_t ACTION_ID_OFFSET = 1; // Ping request will reply ping with this ID (data field) static const uint32_t PING_ID = 0x55; + static const uint32_t BOOT_REGION_ID = 1; StarTracker::TemperatureSet temperatureSet; StarTracker::VersionSet versionSet; + StarTracker::PowerSet powerSet; + StarTracker::InterfaceSet interfaceSet; + StarTracker::TimeSet timeSet; + StarTracker::SolutionSet solutionSet; uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE]; uint8_t rxBuffer[StarTracker::MAX_FRAME_SIZE]; @@ -94,27 +117,86 @@ private: */ void slipInit(); + ReturnValue_t scanForActionReply(DeviceCommandId_t *foundId); + ReturnValue_t scanForSetParameterReply(DeviceCommandId_t *foundId); + ReturnValue_t scanForTmReply(DeviceCommandId_t *foundId); + /** * @brief Fills command buffer with data to ping the star tracker */ void preparePingRequest(); + /** + * @brief Fills command buffer with data to request the time telemetry. + */ + void prepareTimeRequest(); + + /** + * @brief Fills command buffer with data to boot image (works only when star tracker is + * in bootloader mode). + */ + void prepareBootCommand(); + /** * @brief Fills command buffer with data to request the version telemetry packet */ void prepareVersionRequest(); + /** + * @brief Fills the command buffer with data to request the interface telemetry packet. + */ + void prepareInterfaceRequest(); + + /** + * @brief Fills the command buffer with data to request the power telemetry packet. + */ + void preparePowerRequest(); + /** * @brief Fills command buffer with data to reboot star tracker. */ void prepareRebootCommand(); + /** + * @brief Fills command buffer with data to subscribe to a telemetry packet. + * + * @param tmId The ID of the telemetry packet to subscribe to + */ + void prepareSubscriptionCommand(const uint8_t* tmId); + + /** + * @brief Fills command buffer with data to request solution telemtry packet (contains + * attitude information) + */ + void prepareSolutionRequest(); + /** * @brief Fills command buffer with data to request temperature from star tracker */ void prepareTemperatureRequest(); + /** + * @brief Default function to handle action replies + */ + ReturnValue_t handleActionReply(); + + /** + * @brief Handles all set parameter replies + */ + ReturnValue_t handleSetParamReply(); + ReturnValue_t handlePingReply(); + + /** + * @brief Fills the time set with the data of the time request reply. + */ + ReturnValue_t handleTimeTm(); + + /** + * @brief Handles reply data of solution request. + */ + ReturnValue_t handleSolutionTm(); + /** * @brief This function handles the telemetry reply of a temperature request. */ @@ -124,6 +206,43 @@ private: * @brief This function handles the telemetry reply of a version request. */ ReturnValue_t handleVersionTm(); + + /** + * @brief Handles reply to request interface telemetry command. + */ + ReturnValue_t handleInterfaceTm(); + + /** + * @brief Handles reply to request power telemetry command. + */ + ReturnValue_t handlePowerTm(); + + /** + * @brief Extracts the header data of a received telemetry frame + */ + void getTmHeaderData(uint8_t* status, uint32_t* ticks, uint64_t* time); + + /** + * @brief This function deserializes 8 bytes into a 32 bit unsigned integer. + * + * @param buffer Pointer to buffer holding the data to deserialize + * + * @return The 32-bit unsigned integer. + * + * @note Deserialization will be performed in little endian byte order + */ + uint32_t deserializeUint32(uint8_t* buffer); + + /** + * @brief This function deserializes 8 bytes into a 64 bit unsigned integer. + * + * @param buffer Pointer to buffer holding the data to deserialize + * + * @return The 64-bit unsigned integer. + * + * @note Deserialization will be performed in little endian byte order + */ + uint64_t deserializeUint64(uint8_t* buffer); }; #endif /* MISSION_DEVICES_STARTRACKERHANDLER_H_ */ diff --git a/mission/devices/devicedefinitions/StarTrackerDefinitions.h b/mission/devices/devicedefinitions/StarTrackerDefinitions.h index 6772abfe..ca671d8e 100644 --- a/mission/devices/devicedefinitions/StarTrackerDefinitions.h +++ b/mission/devices/devicedefinitions/StarTrackerDefinitions.h @@ -5,6 +5,7 @@ #include #include #include "objects/systemObjectList.h" +#include namespace StarTracker { @@ -14,32 +15,117 @@ static const uint8_t ADDRESS = 33; static const uint8_t STATUS_OK = 0; enum PoolIds: lp_id_t { + TICKS_TIME_SET, + TIME_TIME_SET, + RUN_TIME, + UNIX_TIME, TICKS_VERSION_SET, TIME_VERSION_SET, + PROGRAM, + MAJOR, + MINOR, + TICKS_INTERFACE_SET, + TIME_INTERFACE_SET, + FRAME_COUNT, + CHECKSUM_ERROR_COUNT, + SET_PARAM_COUNT, + SET_PARAM_REPLY_COUNT, + PARAM_REQUEST_COUNT, + PARAM_REPLY_COUNT, + REQ_TM_COUNT, + TM_REPLY_COUNT, + ACTION_REQ_COUNT, + ACTION_REPLY_COUNT, + TICKS_POWER_SET, + TIME_POWER_SET, + MCU_CURRENT, + MCU_VOLTAGE, + FPGA_CORE_CURRENT, + FPGA_CORE_VOLTAGE, + FPGA_18_CURRENT, + FPGA_18_VOLTAGE, + FPGA_25_CURRENT, + FPGA_25_VOLTAGE, + CMV_21_CURRENT, + CMV_21_VOLTAGE, + CMV_PIX_CURRENT, + CMV_PIX_VOLTAGE, + CMV_33_CURRENT, + CMV_33_VOLTAGE, + CMV_RES_CURRENT, + CMV_RES_VOLTAGE, TICKS_TEMPERATURE_SET, TIME_TEMPERATURE_SET, MCU_TEMPERATURE, CMOS_TEMPERATURE, - PROGRAM, - MAJOR, - MINOR + + TICKS_SOLUTION_SET, + TIME_SOLUTION_SET, + CALI_QW, + CALI_QX, + CALI_QY, + CALI_QZ, + TRACK_CONFIDENCE, + TRACK_QW, + TRACK_QX, + TRACK_QY, + TRACK_QZ, + TRACK_REMOVED, + STARS_CENTROIDED, + STARS_MATCHED_DATABASE, + LISA_QW, + LISA_QX, + LISA_QY, + LISA_QZ, + LISA_PERC_CLOSE, + LISA_NR_CLOSE, + TRUST_WORTHY, + STABLE_COUNT, + SOLUTION_STRATEGY }; - - static const DeviceCommandId_t PING_REQUEST = 0; +// Boots image (works only in bootloader mode) +static const DeviceCommandId_t BOOT = 1; static const DeviceCommandId_t REQ_VERSION = 2; +static const DeviceCommandId_t REQ_INTERFACE = 3; +static const DeviceCommandId_t REQ_TIME = 4; static const DeviceCommandId_t REBOOT = 7; +static const DeviceCommandId_t REQ_POWER = 11; +static const DeviceCommandId_t SUBSCRIBE_TO_TM = 18; +static const DeviceCommandId_t REQ_SOLUTION = 24; static const DeviceCommandId_t REQ_TEMPERATURE = 25; static const uint32_t VERSION_SET_ID = REQ_VERSION; +static const uint32_t INTERFACE_SET_ID = REQ_INTERFACE; +static const uint32_t POWER_SET_ID = REQ_POWER; static const uint32_t TEMPERATURE_SET_ID = REQ_TEMPERATURE; +static const uint32_t TIME_SET_ID = REQ_TIME; +static const uint32_t SOLUTION_SET_ID = REQ_SOLUTION; /** Max size of unencoded frame */ static const size_t MAX_FRAME_SIZE = 1200; static const uint8_t TEMPERATURE_SET_ENTRIES = 4; -static const uint8_t VERSION_SET_ENTRIES = 3; +static const uint8_t VERSION_SET_ENTRIES = 5; +static const uint8_t INTERFACE_SET_ENTRIES = 12; +static const uint8_t POWER_SET_ENTRIES = 18; +static const uint8_t TIME_SET_ENTRIES = 4; +static const uint8_t SOLUTION_SET_ENTRIES = 23; + +// Action, parameter and telemetry IDs +namespace ID { + static const uint8_t PING = 0; + static const uint8_t BOOT = 1; + static const uint8_t VERSION = 2; + static const uint8_t INTERFACE = 3; + static const uint8_t REBOOT = 7; + static const uint8_t POWER = 11; + static const uint8_t SUBSCRIBE = 18; + static const uint8_t SOLUTION = 24; + static const uint8_t TEMPERATURE = 25; + static const uint8_t TIME = 1; +} /** * @brief This dataset can be used to store the temperature of a reaction wheel. @@ -97,7 +183,262 @@ public: PoolIds::MINOR, this); }; +/** + * @brief Dataset to store the interface telemtry data. + */ +class InterfaceSet: + public StaticLocalDataSet { +public: + + InterfaceSet(HasLocalDataPoolIF* owner): + StaticLocalDataSet(owner, REQ_INTERFACE) { + } + + InterfaceSet(object_id_t objectId): + StaticLocalDataSet(sid_t(objectId, REQ_INTERFACE)) { + } + + // Ticks is time reference generated by interanl counter of the star tracker + lp_var_t ticks = lp_var_t(sid.objectId, + PoolIds::TICKS_INTERFACE_SET, this); + /** Unix time in microseconds */ + lp_var_t time = lp_var_t(sid.objectId, + PoolIds::TIME_INTERFACE_SET, this); + lp_var_t frameCount = lp_var_t(sid.objectId, + PoolIds::FRAME_COUNT, this); + lp_var_t checksumerrorCount = lp_var_t(sid.objectId, + PoolIds::CHECKSUM_ERROR_COUNT, this); + lp_var_t setParamCount = lp_var_t(sid.objectId, + PoolIds::SET_PARAM_COUNT, this); + lp_var_t setParamReplyCount = lp_var_t(sid.objectId, + PoolIds::SET_PARAM_REPLY_COUNT, this); + lp_var_t paramRequestCount = lp_var_t(sid.objectId, + PoolIds::PARAM_REQUEST_COUNT, this); + lp_var_t paramReplyCount = lp_var_t(sid.objectId, + PoolIds::PARAM_REPLY_COUNT, this); + lp_var_t reqTmCount = lp_var_t(sid.objectId, + PoolIds::REQ_TM_COUNT, this); + lp_var_t tmReplyCount = lp_var_t(sid.objectId, + PoolIds::TM_REPLY_COUNT, this); + lp_var_t actionReqCount = lp_var_t(sid.objectId, + PoolIds::ACTION_REQ_COUNT, this); + lp_var_t actionReplyCount = lp_var_t(sid.objectId, + PoolIds::ACTION_REPLY_COUNT, this); +}; + +/** + * @brief Dataset to store the data of the power telemetry reply. + */ +class PowerSet: + public StaticLocalDataSet { +public: + + PowerSet(HasLocalDataPoolIF* owner): + StaticLocalDataSet(owner, REQ_INTERFACE) { + } + + PowerSet(object_id_t objectId): + StaticLocalDataSet(sid_t(objectId, REQ_INTERFACE)) { + } + + // Ticks is time reference generated by interanl counter of the star tracker + lp_var_t ticks = lp_var_t(sid.objectId, + PoolIds::TICKS_POWER_SET, this); + /** Unix time in microseconds */ + lp_var_t time = lp_var_t(sid.objectId, + PoolIds::TIME_POWER_SET, this); + lp_var_t mcuCurrent = lp_var_t(sid.objectId, + PoolIds::MCU_CURRENT, this); + lp_var_t mcuVoltage = lp_var_t(sid.objectId, + PoolIds::MCU_VOLTAGE, this); + lp_var_t fpgaCoreCurrent = lp_var_t(sid.objectId, + PoolIds::FPGA_CORE_CURRENT, this); + lp_var_t fpgaCoreVoltage = lp_var_t(sid.objectId, + PoolIds::FPGA_CORE_VOLTAGE, this); + lp_var_t fpga18Current = lp_var_t(sid.objectId, + PoolIds::FPGA_18_CURRENT, this); + lp_var_t fpga18Voltage = lp_var_t(sid.objectId, + PoolIds::FPGA_18_VOLTAGE, this); + lp_var_t fpga25Current = lp_var_t(sid.objectId, + PoolIds::FPGA_25_CURRENT, this); + lp_var_t fpga25Voltage = lp_var_t(sid.objectId, + PoolIds::FPGA_25_VOLTAGE, this); + lp_var_t cmv21Current = lp_var_t(sid.objectId, + PoolIds::CMV_21_CURRENT, this); + lp_var_t cmv21Voltage = lp_var_t(sid.objectId, + PoolIds::CMV_21_VOLTAGE, this); + lp_var_t cmvPixCurrent = lp_var_t(sid.objectId, + PoolIds::CMV_PIX_CURRENT, this); + lp_var_t cmvPixVoltage = lp_var_t(sid.objectId, + PoolIds::CMV_PIX_VOLTAGE, this); + lp_var_t cmv33Current = lp_var_t(sid.objectId, + PoolIds::CMV_33_CURRENT, this); + lp_var_t cmv33Voltage = lp_var_t(sid.objectId, + PoolIds::CMV_33_VOLTAGE, this); + lp_var_t cmvResCurrent = lp_var_t(sid.objectId, + PoolIds::CMV_RES_CURRENT, this); + lp_var_t cmvResVoltage = lp_var_t(sid.objectId, + PoolIds::CMV_RES_VOLTAGE, this); +}; + +/** + * @brief Data set to store the time telemetry packet. + */ +class TimeSet: + public StaticLocalDataSet { +public: + + TimeSet(HasLocalDataPoolIF* owner): + StaticLocalDataSet(owner, TIME_SET_ID) { + } + + TimeSet(object_id_t objectId): + StaticLocalDataSet(sid_t(objectId, TIME_SET_ID)) { + } + + lp_var_t ticks = lp_var_t(sid.objectId, + PoolIds::TICKS_TIME_SET, this); + /** Unix time in microseconds */ + lp_var_t time = lp_var_t(sid.objectId, + PoolIds::TIME_TIME_SET, this); + // Number of milliseconds since processor start-up + lp_var_t runTime = lp_var_t(sid.objectId, + PoolIds::RUN_TIME, this); + // Unix time in seconds?? --> maybe typo in datasheet. Seems to be microseconds + lp_var_t unixTime = lp_var_t(sid.objectId, + PoolIds::UNIX_TIME, this); +}; + +/** + * @brief The solution dataset is the main dataset of the star tracker and contains the + * attitude information. + */ +class SolutionSet: + public StaticLocalDataSet { +public: + + SolutionSet(HasLocalDataPoolIF* owner): + StaticLocalDataSet(owner, SOLUTION_SET_ID) { + } + + SolutionSet(object_id_t objectId): + StaticLocalDataSet(sid_t(objectId, SOLUTION_SET_ID)) { + } + + // Ticks timestamp + lp_var_t ticks = lp_var_t(sid.objectId, + PoolIds::TICKS_SOLUTION_SET, this); + /// Unix time stamp + lp_var_t time = lp_var_t(sid.objectId, + PoolIds::TIME_SOLUTION_SET, this); + // Calibrated quaternion (takes into account the mounting quaternion), typically same as + // track q values + lp_var_t caliQw = lp_var_t(sid.objectId, + PoolIds::CALI_QW, this); + lp_var_t caliQx = lp_var_t(sid.objectId, + PoolIds::CALI_QX, this); + lp_var_t caliQy = lp_var_t(sid.objectId, + PoolIds::CALI_QY, this); + lp_var_t caliQz = lp_var_t(sid.objectId, + PoolIds::CALI_QZ, this); + // The lower this value the more confidence that the star tracker solution is correct + lp_var_t trackConfidence = lp_var_t(sid.objectId, + PoolIds::TRACK_CONFIDENCE, this); + // Estimated attitude of spacecraft + lp_var_t trackQw = lp_var_t(sid.objectId, + PoolIds::TRACK_QW, this); + lp_var_t trackQx = lp_var_t(sid.objectId, + PoolIds::TRACK_QX, this); + lp_var_t trackQy = lp_var_t(sid.objectId, + PoolIds::TRACK_QY, this); + lp_var_t trackQz = lp_var_t(sid.objectId, + PoolIds::TRACK_QZ, this); + // Number of stars removed from tracking solution + lp_var_t trackRemoved = lp_var_t(sid.objectId, + PoolIds::TRACK_REMOVED, this); + // Number of stars for which a valid centroid was found + lp_var_t starsCentroided = lp_var_t(sid.objectId, + PoolIds::STARS_CENTROIDED, this); + // Number of stars that matched to a database star + lp_var_t starsMatchedDatabase = lp_var_t(sid.objectId, + PoolIds::STARS_MATCHED_DATABASE, this); + // Result of LISA (lost in space algorithm), searches for stars without prior knowledge of + // attitude + lp_var_t lisaQw = lp_var_t(sid.objectId, + PoolIds::LISA_QW, this); + lp_var_t lisaQx = lp_var_t(sid.objectId, + PoolIds::LISA_QX, this); + lp_var_t lisaQy = lp_var_t(sid.objectId, + PoolIds::LISA_QY, this); + lp_var_t lisaQz = lp_var_t(sid.objectId, + PoolIds::LISA_QZ, this); + // Percentage of close stars in LISA solution + lp_var_t lisaPercentageClose = lp_var_t(sid.objectId, + PoolIds::LISA_PERC_CLOSE, this); + // Number of close stars in LISA solution + lp_var_t lisaNrClose = lp_var_t(sid.objectId, + PoolIds::LISA_NR_CLOSE, this); + // Gives a combined overview of the validation parameters (1 for valid solution, otherwise 0) + lp_var_t isTrustWorthy = lp_var_t(sid.objectId, + PoolIds::TRUST_WORTHY, this); + // Number of times the validation criteria was met + lp_var_t stableCount = lp_var_t(sid.objectId, + PoolIds::STABLE_COUNT, this); + // Shows the autonomous mode used to obtain the star tracker attitude + lp_var_t solutionStrategy = lp_var_t(sid.objectId, + PoolIds::SOLUTION_STRATEGY, this); + + void printSet() { + PoolReadGuard rg(this); + sif::info << "SolutionSet::printSet: Ticks: " + << this->ticks << std::endl; + sif::info << "SolutionSet::printSet: Time: " + << this->time << std::endl; + sif::info << "SolutionSet::printSet: Calibrated quaternion Qw: " + << this->caliQw << std::endl; + sif::info << "SolutionSet::printSet: Calibrated quaternion Qx: " + << this->caliQx << std::endl; + sif::info << "SolutionSet::printSet: Calibrated quaternion Qy: " + << this->caliQy << std::endl; + sif::info << "SolutionSet::printSet: Calibrated quaternion Qz: " + << this->caliQz << std::endl; + sif::info << "SolutionSet::printSet: Track confidence: " + << this->trackConfidence << std::endl; + sif::info << "SolutionSet::printSet: Track Qw: " + << this->trackQw << std::endl; + sif::info << "SolutionSet::printSet: Track Qx: " + << this->trackQx << std::endl; + sif::info << "SolutionSet::printSet: Track Qy: " + << this->trackQy << std::endl; + sif::info << "SolutionSet::printSet: Track Qz: " + << this->trackQz << std::endl; + sif::info << "SolutionSet::printSet: Track removed: " + << static_cast(this->trackRemoved) << std::endl; + sif::info << "SolutionSet::printSet: Number of stars centroided: " + << static_cast(this->starsCentroided) << std::endl; + sif::info << "SolutionSet::printSet: Number of stars matched database: " + << static_cast(this->starsMatchedDatabase) << std::endl; + sif::info << "SolutionSet::printSet: LISA Qw: " + << this->lisaQw << std::endl; + sif::info << "SolutionSet::printSet: LISA Qx: " + << this->lisaQx << std::endl; + sif::info << "SolutionSet::printSet: LISA Qy: " + << this->lisaQy << std::endl; + sif::info << "SolutionSet::printSet: LISA Qz: " + << this->lisaQz << std::endl; + sif::info << "SolutionSet::printSet: LISA Percentage close: " + << this->lisaPercentageClose << std::endl; + sif::info << "SolutionSet::printSet: LISA number of close stars: " + << static_cast(this->lisaNrClose) << std::endl; + sif::info << "SolutionSet::printSet: Is trust worthy: " + << static_cast(this->isTrustWorthy) << std::endl; + sif::info << "SolutionSet::printSet: Stable count: " + << this->stableCount << std::endl; + sif::info << "SolutionSet::printSet: Solution strategy: " + << static_cast(this->solutionStrategy) << std::endl; + } +}; + } #endif /* MISSION_STARTRACKER_DEFINITIONS_H_ */ - From b84bdcc0fcb7fed25c74b3ac80447ece2338cee3 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Sun, 28 Nov 2021 09:57:14 +0100 Subject: [PATCH 108/465] moved print set of temperature set and time set to dataset class --- mission/devices/StarTrackerHandler.cpp | 35 +++++++++++-------- mission/devices/StarTrackerHandler.h | 3 ++ .../StarTrackerDefinitions.h | 22 ++++++++++++ 3 files changed, 46 insertions(+), 14 deletions(-) diff --git a/mission/devices/StarTrackerHandler.cpp b/mission/devices/StarTrackerHandler.cpp index ce69d41d..f8c465e7 100644 --- a/mission/devices/StarTrackerHandler.cpp +++ b/mission/devices/StarTrackerHandler.cpp @@ -563,7 +563,10 @@ ReturnValue_t StarTrackerHandler::handlePingReply() { ReturnValue_t StarTrackerHandler::handleTimeTm() { ReturnValue_t result = RETURN_OK; - PoolReadGuard rg(&timeSet); + result = timeSet.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { + return result; + } uint32_t offset = TM_DATA_FIELD_OFFSET; uint8_t status = 0; uint32_t ticks = 0; @@ -580,15 +583,12 @@ ReturnValue_t StarTrackerHandler::handleTimeTm() { timeSet.runTime = deserializeUint32(decodedFrame + offset); offset += sizeof(uint32_t); timeSet.unixTime = deserializeUint64(decodedFrame + offset); + result = timeSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { + return result; + } #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - sif::info << "StarTrackerHandler::handleTimeTm: Ticks: " - << timeSet.ticks << std::endl; - sif::info << "StarTrackerHandler::handleTimeTm: Time (time stamp): " - << timeSet.time << " us" << std::endl; - sif::info << "StarTrackerHandler::handleTimeTm: Run Time: " - << timeSet.runTime << " ms" << std::endl; - sif::info << "StarTrackerHandler::handleTimeTm: Unix Time: " - << timeSet.unixTime << " s" << std::endl; + timeSet.printSet(); #endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ return result; } @@ -800,7 +800,7 @@ ReturnValue_t StarTrackerHandler::handlePowerTm() { ReturnValue_t StarTrackerHandler::handleSolutionTm() { ReturnValue_t result = RETURN_OK; - result = solutionSet.read(MutexIF::TimeoutType::WAITING, 20); + result = solutionSet.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); if (result != RETURN_OK) { return result; } @@ -810,7 +810,7 @@ ReturnValue_t StarTrackerHandler::handleSolutionTm() { uint64_t time = 0; getTmHeaderData(&status, &ticks, &time); if(status != StarTracker::STATUS_OK) { - sif::warning << "StarTrackerHandler::handleTemperatureTm: Reply error: " + sif::warning << "StarTrackerHandler::handleSolutioneTm: Reply error: " << static_cast(status) << std::endl; result = TEMPERATURE_REQ_FAILED; return result; @@ -873,7 +873,7 @@ ReturnValue_t StarTrackerHandler::handleSolutionTm() { solutionSet.stableCount = *(decodedFrame + offset); offset += sizeof(uint32_t); solutionSet.stableCount = *(decodedFrame + offset); - result = solutionSet.commit(MutexIF::TimeoutType::WAITING, 20); + result = solutionSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); if (result != RETURN_OK) { return result; } @@ -885,7 +885,6 @@ ReturnValue_t StarTrackerHandler::handleSolutionTm() { ReturnValue_t StarTrackerHandler::handleTemperatureTm() { ReturnValue_t result = RETURN_OK; - PoolReadGuard rg(&temperatureSet); uint32_t offset = TM_DATA_FIELD_OFFSET; uint8_t status = 0; uint32_t ticks = 0; @@ -897,6 +896,10 @@ ReturnValue_t StarTrackerHandler::handleTemperatureTm() { result = TEMPERATURE_REQ_FAILED; return result; } + result = temperatureSet.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { + return result; + } temperatureSet.ticks= ticks; temperatureSet.time= time; float temperature = 0; @@ -905,8 +908,12 @@ ReturnValue_t StarTrackerHandler::handleTemperatureTm() { offset += sizeof(temperature); std::memcpy(&temperature, decodedFrame + offset, sizeof(temperature)); temperatureSet.cmosTemperature = temperature; + result = temperatureSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { + return result; + } #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - solutionSet.printSet(); + temperatureSet.printSet(); #endif return result; } diff --git a/mission/devices/StarTrackerHandler.h b/mission/devices/StarTrackerHandler.h index a4389296..67b957de 100644 --- a/mission/devices/StarTrackerHandler.h +++ b/mission/devices/StarTrackerHandler.h @@ -90,6 +90,9 @@ private: static const uint32_t PING_ID = 0x55; static const uint32_t BOOT_REGION_ID = 1; + static const MutexIF::TimeoutType TIMEOUT_TYPE= MutexIF::TimeoutType::WAITING; + static const uint32_t MUTEX_TIMEOUT = 20; + StarTracker::TemperatureSet temperatureSet; StarTracker::VersionSet versionSet; StarTracker::PowerSet powerSet; diff --git a/mission/devices/devicedefinitions/StarTrackerDefinitions.h b/mission/devices/devicedefinitions/StarTrackerDefinitions.h index ca671d8e..8546f843 100644 --- a/mission/devices/devicedefinitions/StarTrackerDefinitions.h +++ b/mission/devices/devicedefinitions/StarTrackerDefinitions.h @@ -152,6 +152,17 @@ public: PoolIds::MCU_TEMPERATURE, this); lp_var_t cmosTemperature = lp_var_t(sid.objectId, PoolIds::CMOS_TEMPERATURE, this); + + void printSet() { + sif::info << "TemperatureSet::printSet: Ticks: " + << this->ticks << std::endl; + sif::info << "TemperatureSet::printSet: Time: " + << this->time << " us" << std::endl; + sif::info << "TemperatureSet::printSet: MCU Temperature: " + << this->mcuTemperature << " °C" << std::endl; + sif::info << "TemperatureSet::printSet: CMOS Temperature: " + << this->mcuTemperature << " °C" << std::endl; + } }; /** @@ -307,6 +318,17 @@ public: // Unix time in seconds?? --> maybe typo in datasheet. Seems to be microseconds lp_var_t unixTime = lp_var_t(sid.objectId, PoolIds::UNIX_TIME, this); + void printSet() { + PoolReadGuard rg(this); + sif::info << "TimeSet::printSet: Ticks: " + << this->ticks << std::endl; + sif::info << "TimeSet::printSet: Time (time stamp): " + << this->time << " us" << std::endl; + sif::info << "TimeSet::printSet: Run Time: " + << this->runTime << " ms" << std::endl; + sif::info << "TimeSet::printSet: Unix Time: " + << this->unixTime << " s" << std::endl; + } }; /** From 077913400fa2bca51ba8de5ddaf83578adad6547 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 29 Nov 2021 11:04:56 +0100 Subject: [PATCH 109/465] star tracker image helper --- bsp_q7s/core/ObjectFactory.cpp | 2 + bsp_q7s/devices/CMakeLists.txt | 1 + bsp_q7s/devices/PlocUpdater.cpp | 4 +- bsp_q7s/devices/StarTrackerImageHelper.cpp | 291 ++++++++++++++++++ bsp_q7s/devices/StarTrackerImageHelper.h | 150 +++++++++ common/config/commonClassIds.h | 1 + common/config/commonObjects.h | 3 +- common/config/commonSubsystemIds.h | 1 + linux/fsfwconfig/OBSWConfig.h.in | 3 +- .../pollingSequenceFactory.cpp | 1 + mission/devices/StarTrackerHandler.cpp | 173 +++++------ mission/devices/StarTrackerHandler.h | 27 +- .../StarTrackerDefinitions.h | 89 ++++-- 13 files changed, 632 insertions(+), 114 deletions(-) create mode 100644 bsp_q7s/devices/StarTrackerImageHelper.cpp create mode 100644 bsp_q7s/devices/StarTrackerImageHelper.h diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 83b59d08..44e4484b 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -16,6 +16,7 @@ #include "bsp_q7s/devices/PlocSupervisorHandler.h" #include "bsp_q7s/devices/PlocUpdater.h" #include "bsp_q7s/devices/PlocMemoryDumper.h" +#include "bsp_q7s/devices/StarTrackerImageHelper.h" #include "bsp_q7s/callbacks/rwSpiCallback.h" #include "bsp_q7s/callbacks/gnssCallback.h" @@ -173,6 +174,7 @@ void ObjectFactory::produce(void* args) { starTrackerCookie->setNoFixedSizeReply(); StarTrackerHandler* starTrackerHandler = new StarTrackerHandler(objects::START_TRACKER, objects::UART_COM_IF, starTrackerCookie); starTrackerHandler->setStartUpImmediately(); + new StarTrackerImageHelper(objects::STR_IMG_HELPER); #endif /* OBSW_ADD_STAR_TRACKER == 1 */ #endif /* TE7020 == 0 */ diff --git a/bsp_q7s/devices/CMakeLists.txt b/bsp_q7s/devices/CMakeLists.txt index 6347b5f8..ecc6bdc1 100644 --- a/bsp_q7s/devices/CMakeLists.txt +++ b/bsp_q7s/devices/CMakeLists.txt @@ -2,4 +2,5 @@ target_sources(${TARGET_NAME} PRIVATE PlocSupervisorHandler.cpp PlocUpdater.cpp PlocMemoryDumper.cpp + StarTrackerImageHelper.cpp ) \ No newline at end of file diff --git a/bsp_q7s/devices/PlocUpdater.cpp b/bsp_q7s/devices/PlocUpdater.cpp index 5a94495b..4771e14c 100644 --- a/bsp_q7s/devices/PlocUpdater.cpp +++ b/bsp_q7s/devices/PlocUpdater.cpp @@ -169,13 +169,13 @@ ReturnValue_t PlocUpdater::getImageLocation(const uint8_t* data, size_t size) { // Check if file is stored on SD card and if associated SD card is mounted if (std::string(reinterpret_cast(data), SD_PREFIX_LENGTH) == std::string(SdCardManager::SD_0_MOUNT_POINT)) { if (!isSdCardMounted(sd::SLOT_0)) { - sif::warning << "PlocUpdater::prepareNvm0AUpdate: SD card 0 not mounted" << std::endl; + sif::warning << "PlocUpdater::getImageLocation: SD card 0 not mounted" << std::endl; return SD_NOT_MOUNTED; } } else if (std::string(reinterpret_cast(data), SD_PREFIX_LENGTH) == std::string(SdCardManager::SD_1_MOUNT_POINT)) { if (!isSdCardMounted(sd::SLOT_0)) { - sif::warning << "PlocUpdater::prepareNvm0AUpdate: SD card 1 not mounted" << std::endl; + sif::warning << "PlocUpdater::getImageLocation: SD card 1 not mounted" << std::endl; return SD_NOT_MOUNTED; } } diff --git a/bsp_q7s/devices/StarTrackerImageHelper.cpp b/bsp_q7s/devices/StarTrackerImageHelper.cpp new file mode 100644 index 00000000..c225e3b9 --- /dev/null +++ b/bsp_q7s/devices/StarTrackerImageHelper.cpp @@ -0,0 +1,291 @@ +#include "fsfw/ipc/QueueFactory.h" +#include "StarTrackerImageHelper.h" + +#include +#include +#include + +StarTrackerImageHelper::StarTrackerImageHelper(object_id_t objectId) : + SystemObject(objectId), commandActionHelper(this), actionHelper(this, nullptr) { + commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); +} + +StarTrackerImageHelper::~StarTrackerImageHelper() { +} + +ReturnValue_t StarTrackerImageHelper::initialize() { + sdcMan = SdCardManager::instance(); + if (sdcMan == nullptr) { + sif::warning << "StarTrackerImageHelper::initialize: Invaldi SD Card Manager" << std::endl; + } + ReturnValue_t result = SystemObject::initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = commandActionHelper.initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = actionHelper.initialize(commandQueue); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t StarTrackerImageHelper::performOperation(uint8_t operationCode) { + readCommandQueue(); + doStateMachine(); + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t StarTrackerImageHelper::executeAction(ActionId_t actionId, + MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { + ReturnValue_t result = EXECUTION_FINISHED; + + if (state != State::IDLE) { + return IS_BUSY; + } + + if (size > MAX_STR_IMAGE_PATH) { + return NAME_TOO_LONG; + } + + switch (actionId) { + case UPLOAD_IMAGE: + result = prepareUploadCommand(data, size); + if (result == RETURN_OK) { + result = EXECUTION_FINISHED; + } + break; + case DOWNLOAD_IMAGE: + break; + default: + return INVALID_ACTION_ID; + } + + return result; +} + +MessageQueueId_t StarTrackerImageHelper::getCommandQueue() const { + return commandQueue->getId(); +} + +MessageQueueIF* StarTrackerImageHelper::getCommandQueuePtr() { + return commandQueue; +} + +void StarTrackerImageHelper::readCommandQueue() { + CommandMessage message; + ReturnValue_t result; + + for (result = commandQueue->receiveMessage(&message); result == HasReturnvaluesIF::RETURN_OK; + result = commandQueue->receiveMessage(&message)) { + if (result != RETURN_OK) { + continue; + } + result = actionHelper.handleActionMessage(&message); + if (result == HasReturnvaluesIF::RETURN_OK) { + continue; + } + + result = commandActionHelper.handleReply(&message); + if (result == HasReturnvaluesIF::RETURN_OK) { + continue; + } + + sif::debug << "StarTrackerImageHelper::readCommandQueue: Received inalid message" + << std::endl; + } +} + +void StarTrackerImageHelper::doStateMachine() { + switch (state) { + case State::IDLE: + break; + case State::SEND_NEXT_UPLOAD_CMD: + commandImageUpload(); + break; + case State::COMMAND_EXECUTING: + case State::UPLOAD_LAST: + break; + default: + sif::debug << "StarTrackerImageHelper::doStateMachine: Invalid state" << std::endl; + break; + } +} + +ReturnValue_t StarTrackerImageHelper::getImageLocation(const uint8_t* data, size_t size) { + + // Check if file is stored on SD card and if associated SD card is mounted + if (std::string(reinterpret_cast(data), SD_PREFIX_LENGTH) == std::string(SdCardManager::SD_0_MOUNT_POINT)) { + if (!isSdCardMounted(sd::SLOT_0)) { + sif::warning << "StarTrackerImageHelper::getImageLocation: SD card 0 not mounted" << std::endl; + return SD_NOT_MOUNTED; + } + } + else if (std::string(reinterpret_cast(data), SD_PREFIX_LENGTH) == std::string(SdCardManager::SD_1_MOUNT_POINT)) { + if (!isSdCardMounted(sd::SLOT_0)) { + sif::warning << "StarTrackerImageHelper::getImageLocation: SD card 1 not mounted" << std::endl; + return SD_NOT_MOUNTED; + } + } + else { + // Specified path in RAM filesystem + } + + imageFile = std::string(reinterpret_cast(data), size); + + // Check if file exists + if(not std::filesystem::exists(imageFile)) { + return FILE_NOT_EXISTS; + } + return RETURN_OK; +} + +bool StarTrackerImageHelper::isSdCardMounted(sd::SdCard sdCard) { + SdCardManager::SdStatePair active; + ReturnValue_t result = sdcMan->getSdCardActiveStatus(active); + if (result != RETURN_OK) { + sif::debug << "StarTrackerImageHelper::isSdCardMounted: Failed to get SD card active state"; + return false; + } + if (sdCard == sd::SLOT_0) { + if (active.first == sd::MOUNTED) { + return true; + } + else { + return false; + } + } + else if (sdCard == sd::SLOT_1) { + if (active.second == sd::MOUNTED) { + return true; + } + else { + return false; + } + } + else { + sif::debug << "StarTrackerImageHelper::isSdCardMounted: Unknown SD card specified" << std::endl; + } + return false; +} + +ReturnValue_t StarTrackerImageHelper::prepareUploadCommand(const uint8_t* data, size_t size) { + ReturnValue_t result = RETURN_OK; + result = getImageLocation(data, size); + if (result != RETURN_OK) { + return result; + } + imageSize = std::filesystem::file_size(imageFile); + remainingCommands = imageSize / SIZE_IMAGE_PART ; + if (imageSize % SIZE_IMAGE_PART) { + remainingCommands++; + } + commandsSent = 0; + state = State::SEND_NEXT_UPLOAD_CMD; + return result; +} + +void StarTrackerImageHelper::stepSuccessfulReceived(ActionId_t actionId, + uint8_t step) { +} + +void StarTrackerImageHelper::stepFailedReceived(ActionId_t actionId, uint8_t step, + ReturnValue_t returnCode) { +} + +void StarTrackerImageHelper::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) { + +} + +void StarTrackerImageHelper::completionSuccessfulReceived(ActionId_t actionId) { + switch (pendingCommand) { + case (StarTracker::UPLOAD_IMAGE): + if (state == State::UPLOAD_LAST) { + triggerEvent(IMAGE_UPLOAD_FINISHED); + pendingCommand = StarTracker::NONE; + state = State::IDLE; + } + else { + state = State::SEND_NEXT_UPLOAD_CMD; + } + break; + default: + sif::debug << "StarTrackerImageHelper::completionSuccessfulReceived: Invalid pending command" + << std::endl; + state = State::IDLE; + break; + } +} + +void StarTrackerImageHelper::completionFailedReceived(ActionId_t actionId, + ReturnValue_t returnCode) { + switch(pendingCommand) { + case(StarTracker::UPLOAD_IMAGE): { + triggerEvent(IMAGE_UPLOAD_FAILED); + break; + } + default: + sif::debug << "StarTrackerImageHelper::completionFailedReceived: Invalid pending command " + << std::endl; + break; + } + state = State::IDLE; +} + +void StarTrackerImageHelper::commandImageUpload() { + ReturnValue_t result = RETURN_OK; + uint16_t dataLen = 0; + uint8_t tmpCommandBuffer[UPLOAD_COMMAND_SIZE] = {0}; + uint32_t position = commandsSent * SIZE_IMAGE_PART; + + if (not std::filesystem::exists(imageFile)) { + triggerEvent(IMAGE_FILE_NOT_EXISTS, commandsSent); + state = State::IDLE; + return; + } + + std::ifstream file(imageFile, std::ifstream::binary); + file.seekg(position, file.beg); + + if (remainingCommands == 1) { + dataLen = imageSize - file.tellg(); + } + else { + dataLen = SIZE_IMAGE_PART; + } + + size_t size = 0; + size_t maxSize = sizeof(position); + uint8_t* commandBufferPtr = tmpCommandBuffer; + uint8_t** buffer = &commandBufferPtr; + SerializeAdapter::serialize(&position, buffer, &size, maxSize, + SerializeIF::Endianness::BIG); + file.read(reinterpret_cast(tmpCommandBuffer), dataLen); + file.close(); + + result = commandActionHelper.commandAction(objects::START_TRACKER, + StarTracker::UPLOAD_IMAGE, tmpCommandBuffer - size , UPLOAD_COMMAND_SIZE); + + if (result != RETURN_OK) { + sif::warning << "StarTrackerImageHelper::commandImageUpload: Failed to send image " + << "upload command" << std::endl; + triggerEvent(ACTION_COMMANDING_FAILED, result, StarTracker::UPLOAD_IMAGE); + state = State::IDLE; + return; + } + + remainingCommands--; + commandsSent++; + + if (remainingCommands == 0) { + state = State::UPLOAD_LAST; + } + else { + state = State::COMMAND_EXECUTING; + } + pendingCommand = StarTracker::UPLOAD_IMAGE; +} diff --git a/bsp_q7s/devices/StarTrackerImageHelper.h b/bsp_q7s/devices/StarTrackerImageHelper.h new file mode 100644 index 00000000..59dc7b83 --- /dev/null +++ b/bsp_q7s/devices/StarTrackerImageHelper.h @@ -0,0 +1,150 @@ +#ifndef MISSION_DEVICES_STARTRACKERIMAGEHELPER_H_ +#define MISSION_DEVICES_STARTRACKERIMAGEHELPER_H_ + +#include "OBSWConfig.h" +#include "mission/devices/devicedefinitions/StarTrackerDefinitions.h" +#include "fsfw/action/CommandActionHelper.h" +#include "fsfw/action/ActionHelper.h" +#include "fsfw/action/HasActionsIF.h" +#include "fsfw/action/CommandsActionsIF.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/tasks/ExecutableObjectIF.h" +#include "fsfw/objectmanager/SystemObject.h" +#include "bsp_q7s/memory/SdCardManager.h" +#include "linux/fsfwconfig/objects/systemObjectList.h" + + +/** + * @brief An object of this class helps to download and upload images from/to the star tracker. + * + * @details The star tracker can only receive upload image commands with maximum 1024 bytes of data. + * Thus this class is used to raed the image from the file system and split the upload + * procedure into multiple steps. + * The same applies to downloading images from the star tracker (max. 1024 bytes in image + * download reply). + * + * @author J. Meier + */ +class StarTrackerImageHelper : public SystemObject, + public HasActionsIF, + public ExecutableObjectIF, + public HasReturnvaluesIF, + public CommandsActionsIF { +public: + + static const ActionId_t UPLOAD_IMAGE = 0; + static const ActionId_t DOWNLOAD_IMAGE = 1; + + StarTrackerImageHelper(object_id_t objectId); + virtual ~StarTrackerImageHelper(); + + ReturnValue_t performOperation(uint8_t operationCode = 0) override; + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size); + MessageQueueId_t getCommandQueue() const; + ReturnValue_t initialize() override; + MessageQueueIF* getCommandQueuePtr() override; + void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) override; + void stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) override; + void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) override; + void completionSuccessfulReceived(ActionId_t actionId) override; + void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override; + +private: + + static const uint8_t INTERFACE_ID = CLASS_ID::STR_IMG_HELPER; + + //! [EXPORT] : [COMMENT] Image helper is already executing a command + static const ReturnValue_t IMAGE_HELPER_BUSY = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] Invalid path to image location + static const ReturnValue_t NAME_TOO_LONG = MAKE_RETURN_CODE(0xA1); + //! [EXPORT] : [COMMENT] SD card with image not mounted + static const ReturnValue_t SD_NOT_MOUNTED = MAKE_RETURN_CODE(0xA2); + //! [EXPORT] : [COMMENT] Specified image does not exist + static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xA3); + + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_IMAGE_HELPER; + + //! [EXPORT] : [COMMENT] Try to read image file to upload but the file does not exist. + //! P1: Refers to the upload step the reading fails + static const Event IMAGE_FILE_NOT_EXISTS = MAKE_EVENT(0, severity::LOW); + //! [EXPORT] : [COMMENT] Failed to send command to star tracker handler + //! P1: Return value of CommandActionHelper::commandAction + //! P2: Action ID of command to send + static const Event ACTION_COMMANDING_FAILED = MAKE_EVENT(1, severity::LOW); + //! [EXPORT] : [COMMENT] Star tracker handler replies with completion failure message to upload image command + //! P1: Upload step of the failed command execution + static const Event IMAGE_UPLOAD_FAILED = MAKE_EVENT(2, severity::LOW); + //! [EXPORT] : [COMMENT] Image upload was successful + static const Event IMAGE_UPLOAD_FINISHED = MAKE_EVENT(3, severity::LOW); + + + static const uint32_t QUEUE_SIZE = config::STR_IMG_HELPER_QUEUE_SIZE; + static const size_t MAX_STR_IMAGE_PATH = 50; + static const size_t SD_PREFIX_LENGTH = 8; + // Size of one image part which can be sent per action request + static const size_t SIZE_IMAGE_PART = 1024; + // Position (uint32_t) + image data (1024 bytes) + static const size_t UPLOAD_COMMAND_SIZE = 1028; + + MessageQueueIF* commandQueue = nullptr; + + SdCardManager* sdcMan = nullptr; + + CommandActionHelper commandActionHelper; + + ActionHelper actionHelper; + + enum class State: uint8_t { + IDLE, + SEND_NEXT_UPLOAD_CMD, + UPLOAD_LAST, + COMMAND_EXECUTING + }; + + State state = State::IDLE; + + ActionId_t pendingCommand = StarTracker::NONE; + + uint32_t commandsSent = 0; + uint32_t remainingCommands = 0; + + // Path and name of active image (either upload or download image) + std::string imageFile; + // In case of upload command this variable stores the size of the image to upload + std::uintmax_t imageSize; + + void readCommandQueue(); + void doStateMachine(); + + /** + * @brief Extracts the path and name form the received command. + * + * @param data Pointer to received command + * @param size Size of the received command + * + * @details This string defines the image to upload (must be previously written to the SD card). + * In case of the download image command, this string defines the location and name of + * the image file to create. + */ + ReturnValue_t getImageLocation(const uint8_t* data, size_t size); + + /** + * @brief Prepares properties for the upload image command and changes the state to initiate + * the execution of the upload image command. + */ + ReturnValue_t prepareUploadCommand(const uint8_t* data, size_t size); + + /** + * @brief Reads part of image from file and sends upload image command to star tracker + * handler. + */ + void commandImageUpload(); + + /** + * @brief Checks whether the SD card to read from is mounted or not. + */ + bool isSdCardMounted(sd::SdCard sdCard); +}; + +#endif /* MISSION_DEVICES_STARTRACKERIMAGEHELPER_H_ */ diff --git a/common/config/commonClassIds.h b/common/config/commonClassIds.h index 00b5ca25..b2885009 100644 --- a/common/config/commonClassIds.h +++ b/common/config/commonClassIds.h @@ -19,6 +19,7 @@ enum commonClassIds: uint8_t { CCSDS_IP_CORE_BRIDGE, //IPCI PTME, //PTME PLOC_UPDATER, //PLUD + STR_IMG_HELPER, //STRIMGH GOM_SPACE_HANDLER, //GOMS PLOC_MEMORY_DUMPER, //PLMEMDUMP PDEC_HANDLER, //PDEC diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index 8cf45e9a..19445dc1 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -90,7 +90,8 @@ enum commonObjects: uint32_t { START_TRACKER = 0x44130001, PLOC_UPDATER = 0x44330000, - PLOC_MEMORY_DUMPER = 0x44330001 + PLOC_MEMORY_DUMPER = 0x44330001, + STR_IMG_HELPER = 0x44330002 }; } diff --git a/common/config/commonSubsystemIds.h b/common/config/commonSubsystemIds.h index 05fda61c..a6a0466d 100644 --- a/common/config/commonSubsystemIds.h +++ b/common/config/commonSubsystemIds.h @@ -18,6 +18,7 @@ enum: uint8_t { PLOC_UPDATER = 117, PLOC_MEMORY_DUMPER = 118, PDEC_HANDLER = 119, + STR_IMAGE_HELPER = 120, COMMON_SUBSYSTEM_ID_END }; } diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index 663ef00b..9e2a103e 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -110,7 +110,7 @@ debugging. */ #define OBSW_DEBUG_STARTRACKER 0 #define OBSW_DEBUG_PLOC_MPSOC 0 #define OBSW_DEBUG_PLOC_SUPERVISOR 0 -#define OBSW_DEBUG_PDEC_HANDLER 0 +#define OBSW_DEBUG_PDEC_HANDLER 1 /*******************************************************************/ /** Hardcoded */ @@ -132,6 +132,7 @@ namespace config { /* Add mission configuration flags here */ static constexpr uint32_t OBSW_FILESYSTEM_HANDLER_QUEUE_SIZE = 50; static constexpr uint32_t PLOC_UPDATER_QUEUE_SIZE = 50; +static constexpr uint32_t STR_IMG_HELPER_QUEUE_SIZE = 50; static constexpr uint8_t LIVE_TM = 0; diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 73a27116..b32ceb5f 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -588,6 +588,7 @@ ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::PLOC_UPDATER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::PLOC_MEMORY_DUMPER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::STR_IMG_HELPER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); #if OBSW_ADD_PLOC_SUPERVISOR == 1 thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); diff --git a/mission/devices/StarTrackerHandler.cpp b/mission/devices/StarTrackerHandler.cpp index f8c465e7..0b2048c0 100644 --- a/mission/devices/StarTrackerHandler.cpp +++ b/mission/devices/StarTrackerHandler.cpp @@ -55,7 +55,7 @@ ReturnValue_t StarTrackerHandler::buildTransitionDeviceCommand(DeviceCommandId_t ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t * commandData, size_t commandDataLen) { - + ReturnValue_t result = RETURN_OK; switch (deviceCommand) { case (StarTracker::PING_REQUEST): { preparePingRequest(); @@ -77,6 +77,10 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi prepareInterfaceRequest(); return RETURN_OK; } + case (StarTracker::UPLOAD_IMAGE): { + result = prepareImageUploadCommand(commandData, commandDataLen); + return result; + } case (StarTracker::REQ_POWER): { preparePowerRequest(); return RETURN_OK; @@ -114,6 +118,8 @@ void StarTrackerHandler::fillCommandAndReplyMap() { StarTracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(StarTracker::REQ_TIME, 3, &timeSet, StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::UPLOAD_IMAGE, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(StarTracker::REQ_POWER, 3, &powerSet, StarTracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(StarTracker::REQ_INTERFACE, 3, &interfaceSet, @@ -221,6 +227,10 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con result = handleInterfaceTm(); break; } + case (StarTracker::UPLOAD_IMAGE): { + result = handleUploadImageReply(); + break; + } case (StarTracker::REQ_POWER): { result = handlePowerTm(); break; @@ -344,6 +354,10 @@ ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t *foundId) *foundId = StarTracker::BOOT; break; } + case (StarTracker::ID::UPLOAD_IMAGE): { + *foundId = StarTracker::UPLOAD_IMAGE; + break; + } default: sif::debug << "StarTrackerHandler::scanForSetParameterReply: Unknown parameter reply id" << std::endl; @@ -457,6 +471,28 @@ void StarTrackerHandler::prepareInterfaceRequest() { rawPacketLen = encLength; } +ReturnValue_t StarTrackerHandler::prepareImageUploadCommand(const uint8_t* commandData, + size_t commandDataLen) { + if (commandDataLen != UPLOAD_COMMAND_LEN) { + return INVALID_UPLOAD_COMMAND; + } + uint32_t length = 0; + uint32_t position = deserializeUint32(commandData); + if (position > MAX_POSITION) { + return MAX_POSITION; + } + rememberUploadPosition = position; + struct UploadActionRequest uploadRequest; + uploadRequest.position = position; + std::memcpy(uploadRequest.data, commandData + 4, commandDataLen - 4); + arc_pack_upload_action_req(&uploadRequest, commandBuffer, &length); + uint32_t encLength = 0; + arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength); + rawPacket = encBuffer; + rawPacketLen = encLength; + return RETURN_OK; +} + void StarTrackerHandler::preparePowerRequest() { uint32_t length = 0; arc_tm_pack_power_req(commandBuffer, &length); @@ -556,11 +592,27 @@ ReturnValue_t StarTrackerHandler::handlePingReply() { sif::info << "Ping id: 0x"<< std::hex << pingId << std::endl; #endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ if (status != StarTracker::STATUS_OK || pingId != PING_ID) { + sif::warning << "StarTrackerHandler::handlePingReply: Ping failed" << std::endl; result = PING_FAILED; } return result; } +ReturnValue_t StarTrackerHandler::handleUploadImageReply() { + ReturnValue_t result = RETURN_OK; + result = handleActionReply(); + if (result != RETURN_OK) { + return result; + } + uint32_t position = deserializeUint32(decodedFrame + ACTION_DATA_OFFSET); + if (position != rememberUploadPosition) { + sif::warning << "StarTrackerHandler::handleUploadImageReply: Invalid position" + << std::endl; + return UPLOAD_IMAGE_FAILED; + } + return result; +} + ReturnValue_t StarTrackerHandler::handleTimeTm() { ReturnValue_t result = RETURN_OK; result = timeSet.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); @@ -595,7 +647,6 @@ ReturnValue_t StarTrackerHandler::handleTimeTm() { ReturnValue_t StarTrackerHandler::handleVersionTm() { ReturnValue_t result = RETURN_OK; - PoolReadGuard rg(&versionSet); uint32_t offset = TM_DATA_FIELD_OFFSET; uint8_t status = 0; uint32_t ticks = 0; @@ -607,6 +658,10 @@ ReturnValue_t StarTrackerHandler::handleVersionTm() { result = VERSION_REQ_FAILED; return result; } + result = versionSet.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { + return result; + } versionSet.ticks = ticks; versionSet.time = time; versionSet.program = *(decodedFrame + offset); @@ -614,24 +669,18 @@ ReturnValue_t StarTrackerHandler::handleVersionTm() { versionSet.major = *(decodedFrame + offset); offset += 1; versionSet.minor = *(decodedFrame + offset); + result = versionSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { + return result; + } #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - sif::info << "StarTrackerHandler::handleVersionTm: Ticks: " - << versionSet.ticks << std::endl; - sif::info << "StarTrackerHandler::handleVersionTm: Unix Time: " - << versionSet.time << " us" << std::endl; - sif::info << "StarTrackerHandler::handleVersionTm: Program: " - << static_cast(versionSet.program.value) << std::endl; - sif::info << "StarTrackerHandler::handleVersionTm: Major: " - << static_cast(versionSet.major.value) << std::endl; - sif::info << "StarTrackerHandler::handleVersionTm: Minor: " - << static_cast(versionSet.minor.value) << std::endl; + versionSet.printSet(); #endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ return result; } ReturnValue_t StarTrackerHandler::handleInterfaceTm() { ReturnValue_t result = RETURN_OK; - PoolReadGuard rg(&interfaceSet); uint32_t offset = TM_DATA_FIELD_OFFSET; uint8_t status = 0; uint32_t ticks = 0; @@ -643,59 +692,28 @@ ReturnValue_t StarTrackerHandler::handleInterfaceTm() { result = INTERFACE_REQ_FAILED; return result; } + result = interfaceSet.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { + return result; + } interfaceSet.ticks = ticks; interfaceSet.time = time; size_t size = sizeof(uint32_t); interfaceSet.frameCount = deserializeUint32(decodedFrame + offset); offset += size; interfaceSet.checksumerrorCount = deserializeUint32(decodedFrame + offset); - offset += size; - interfaceSet.setParamCount = deserializeUint32(decodedFrame + offset); - offset += size; - interfaceSet.setParamReplyCount = deserializeUint32(decodedFrame + offset); - offset += size; - interfaceSet.paramRequestCount = deserializeUint32(decodedFrame + offset); - offset += size; - interfaceSet.paramReplyCount = deserializeUint32(decodedFrame + offset); - offset += size; - interfaceSet.tmReplyCount = deserializeUint32(decodedFrame + offset); - offset += size; - interfaceSet.actionReqCount = deserializeUint32(decodedFrame + offset); - offset += size; - interfaceSet.actionReplyCount = deserializeUint32(decodedFrame + offset); - + result = interfaceSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { + return result; + } #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - sif::info << "StarTrackerHandler::handleInterfaceTm: Ticks: " - << interfaceSet.ticks << std::endl; - sif::info << "StarTrackerHandler::handleInterfaceTm: Time: " - << interfaceSet.time << " us" << std::endl; - sif::info << "StarTrackerHandler::handleInterfaceTm: Frame Count: " - << interfaceSet.frameCount << std::endl; - sif::info << "StarTrackerHandler::handleInterfaceTm: Checksum Error Count: " - << interfaceSet.checksumerrorCount << std::endl; - sif::info << "StarTrackerHandler::handleInterfaceTm: Set Param Count: " - << interfaceSet.setParamCount << std::endl; - sif::info << "StarTrackerHandler::handleInterfaceTm: Set Param Reply Count: " - << interfaceSet.setParamReplyCount << std::endl; - sif::info << "StarTrackerHandler::handleInterfaceTm: Param Request Count: " - << interfaceSet.paramRequestCount << std::endl; - sif::info << "StarTrackerHandler::handleInterfaceTm: Param Reply Count: " - << interfaceSet.paramReplyCount << std::endl; - sif::info << "StarTrackerHandler::handleInterfaceTm: Req TM Count: " - << interfaceSet.reqTmCount << std::endl; - sif::info << "StarTrackerHandler::handleInterfaceTm: Telemetry Reply Count: " - << interfaceSet.tmReplyCount << std::endl; - sif::info << "StarTrackerHandler::handleInterfaceTm: Action Request Count: " - << interfaceSet.actionReqCount << std::endl; - sif::info << "StarTrackerHandler::handleInterfaceTm: Action Reply Count: " - << interfaceSet.actionReplyCount << std::endl; + interfaceSet.printSet(); #endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ return result; } ReturnValue_t StarTrackerHandler::handlePowerTm() { ReturnValue_t result = RETURN_OK; - PoolReadGuard rg(&powerSet); uint32_t offset = TM_DATA_FIELD_OFFSET; uint8_t status = 0; uint32_t ticks = 0; @@ -707,6 +725,10 @@ ReturnValue_t StarTrackerHandler::handlePowerTm() { result = POWER_REQ_FAILED; return result; } + result = powerSet.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { + return result; + } powerSet.ticks= ticks; powerSet.time= time; float value = 0; @@ -757,43 +779,12 @@ ReturnValue_t StarTrackerHandler::handlePowerTm() { offset += 4; std::memcpy(&value, decodedFrame + offset, sizeof(value)); powerSet.cmvResVoltage = value; + result = powerSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { + return result; + } #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - sif::info << "StarTrackerHandler::handlePowerTm: Ticks: " - << powerSet.ticks << std::endl; - sif::info << "StarTrackerHandler::handlePowerTm: Time: " - << powerSet.time << " us" << std::endl; - sif::info << "StarTrackerHandler::handlePowerTm: MCU Current: " - << powerSet.mcuCurrent << " A" << std::endl; - sif::info << "StarTrackerHandler::handlePowerTm: MCU Voltage: " - << powerSet.mcuVoltage << " V" << std::endl; - sif::info << "StarTrackerHandler::handlePowerTm: FPGA Core current: " - << powerSet.fpgaCoreCurrent << " A" << std::endl; - sif::info << "StarTrackerHandler::handlePowerTm: FPGA Core voltage: " - << powerSet.fpgaCoreVoltage << " V" << std::endl; - sif::info << "StarTrackerHandler::handlePowerTm: FPGA 18 current: " - << powerSet.fpga18Current << " A" << std::endl; - sif::info << "StarTrackerHandler::handlePowerTm: FPGA 18 voltage: " - << powerSet.fpga18Voltage << " V" << std::endl; - sif::info << "StarTrackerHandler::handlePowerTm: FPGA 25 current: " - << powerSet.fpga25Current << " A" << std::endl; - sif::info << "StarTrackerHandler::handlePowerTm: FPGA 25 voltage: " - << powerSet.fpga25Voltage << " V" << std::endl; - sif::info << "StarTrackerHandler::handlePowerTm: CMV 21 current: " - << powerSet.cmv21Current << " A" << std::endl; - sif::info << "StarTrackerHandler::handlePowerTm: CMV 21 voltage: " - << powerSet.cmv21Voltage << " V" << std::endl; - sif::info << "StarTrackerHandler::handlePowerTm: CMV Pix current: " - << powerSet.cmvPixCurrent << " A" << std::endl; - sif::info << "StarTrackerHandler::handlePowerTm: CMV Pix voltage: " - << powerSet.cmvPixVoltage << " V" << std::endl; - sif::info << "StarTrackerHandler::handlePowerTm: CMV 33 current: " - << powerSet.cmv33Current << " A" << std::endl; - sif::info << "StarTrackerHandler::handlePowerTm: CMV 33 voltage: " - << powerSet.cmv33Voltage << " V" << std::endl; - sif::info << "StarTrackerHandler::handlePowerTm: CMV Res current: " - << powerSet.cmvResCurrent << " A" << std::endl; - sif::info << "StarTrackerHandler::handlePowerTm: CMV Res voltage: " - << powerSet.cmvResVoltage << " V" << std::endl; + powerSet.printSet(); #endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ return result; } @@ -905,7 +896,7 @@ ReturnValue_t StarTrackerHandler::handleTemperatureTm() { float temperature = 0; std::memcpy(&temperature, decodedFrame + offset, sizeof(temperature)); temperatureSet.mcuTemperature = temperature; - offset += sizeof(temperature); + offset += sizeof(float); std::memcpy(&temperature, decodedFrame + offset, sizeof(temperature)); temperatureSet.cmosTemperature = temperature; result = temperatureSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); @@ -924,7 +915,7 @@ void StarTrackerHandler::getTmHeaderData(uint8_t* status, uint32_t* ticks, uint6 *time = deserializeUint64(decodedFrame + TIME_OFFSET); } -uint32_t StarTrackerHandler::deserializeUint32(uint8_t* buffer) { +uint32_t StarTrackerHandler::deserializeUint32(const uint8_t* buffer) { uint32_t word = 0; word = *(buffer + 3) << 24 | *(buffer + 2) << 16 diff --git a/mission/devices/StarTrackerHandler.h b/mission/devices/StarTrackerHandler.h index 67b957de..e082cf46 100644 --- a/mission/devices/StarTrackerHandler.h +++ b/mission/devices/StarTrackerHandler.h @@ -78,13 +78,26 @@ private: static const ReturnValue_t SET_PARAM_FAILED = MAKE_RETURN_CODE(0xA6); //! [EXPORT] : [COMMENT] Status of reply to action command signals error static const ReturnValue_t ACTION_FAILED = MAKE_RETURN_CODE(0xA7); + //! [EXPORT] : [COMMENT] Received upload image command with invalid length + static const ReturnValue_t UPLOAD_TOO_SHORT = MAKE_RETURN_CODE(0xA8); + //! [EXPORT] : [COMMENT] Received upload image command with invalid position field + static const ReturnValue_t UPLOAD_INVALID_POSITION = MAKE_RETURN_CODE(0xA8); + //! [EXPORT] : [COMMENT] Position value in upload image reply not matching sent position + static const ReturnValue_t UPLOAD_IMAGE_FAILED = MAKE_RETURN_CODE(0xA9); + //! [EXPORT] : [COMMENT] Received upload image command with invalid length + static const ReturnValue_t INVALID_UPLOAD_COMMAND = MAKE_RETURN_CODE(0xA9); + // position (uint32) + 1024 image data + static const size_t UPLOAD_COMMAND_LEN = 1028; + // Max valid position value in upload image command + static const uint16_t MAX_POSITION= 3071; static const uint8_t STATUS_OFFSET = 2; static const uint8_t TICKS_OFFSET = 3; static const uint8_t TIME_OFFSET = 7; static const uint8_t TM_DATA_FIELD_OFFSET = 15; static const uint8_t PARAMETER_ID_OFFSET = 1; static const uint8_t ACTION_ID_OFFSET = 1; + static const uint8_t ACTION_DATA_OFFSET = 3; // Ping request will reply ping with this ID (data field) static const uint32_t PING_ID = 0x55; @@ -115,6 +128,8 @@ private: InternalState internalState = InternalState::TEMPERATURE_REQUEST; + uint32_t rememberUploadPosition = 0; + /** * @brief This function initializes the serial link ip protocol struct slipInfo. */ @@ -150,6 +165,11 @@ private: */ void prepareInterfaceRequest(); + /** + * @brief Fills the command buffer with data to upload part of an image. + */ + ReturnValue_t prepareImageUploadCommand(const uint8_t* commandData, size_t commandDataLen); + /** * @brief Fills the command buffer with data to request the power telemetry packet. */ @@ -190,6 +210,11 @@ private: ReturnValue_t handlePingReply(); + /** + * @brief Handles reply to upload image command + */ + ReturnValue_t handleUploadImageReply(); + /** * @brief Fills the time set with the data of the time request reply. */ @@ -234,7 +259,7 @@ private: * * @note Deserialization will be performed in little endian byte order */ - uint32_t deserializeUint32(uint8_t* buffer); + uint32_t deserializeUint32(const uint8_t* buffer); /** * @brief This function deserializes 8 bytes into a 64 bit unsigned integer. diff --git a/mission/devices/devicedefinitions/StarTrackerDefinitions.h b/mission/devices/devicedefinitions/StarTrackerDefinitions.h index 8546f843..ef9182ff 100644 --- a/mission/devices/devicedefinitions/StarTrackerDefinitions.h +++ b/mission/devices/devicedefinitions/StarTrackerDefinitions.h @@ -91,10 +91,12 @@ static const DeviceCommandId_t REQ_VERSION = 2; static const DeviceCommandId_t REQ_INTERFACE = 3; static const DeviceCommandId_t REQ_TIME = 4; static const DeviceCommandId_t REBOOT = 7; +static const DeviceCommandId_t UPLOAD_IMAGE = 10; static const DeviceCommandId_t REQ_POWER = 11; static const DeviceCommandId_t SUBSCRIBE_TO_TM = 18; static const DeviceCommandId_t REQ_SOLUTION = 24; static const DeviceCommandId_t REQ_TEMPERATURE = 25; +static const DeviceCommandId_t NONE = 0xFFFFFFFF; static const uint32_t VERSION_SET_ID = REQ_VERSION; static const uint32_t INTERFACE_SET_ID = REQ_INTERFACE; @@ -108,7 +110,7 @@ static const size_t MAX_FRAME_SIZE = 1200; static const uint8_t TEMPERATURE_SET_ENTRIES = 4; static const uint8_t VERSION_SET_ENTRIES = 5; -static const uint8_t INTERFACE_SET_ENTRIES = 12; +static const uint8_t INTERFACE_SET_ENTRIES = 4; static const uint8_t POWER_SET_ENTRIES = 18; static const uint8_t TIME_SET_ENTRIES = 4; static const uint8_t SOLUTION_SET_ENTRIES = 23; @@ -120,6 +122,7 @@ namespace ID { static const uint8_t VERSION = 2; static const uint8_t INTERFACE = 3; static const uint8_t REBOOT = 7; + static const uint8_t UPLOAD_IMAGE = 10; static const uint8_t POWER = 11; static const uint8_t SUBSCRIBE = 18; static const uint8_t SOLUTION = 24; @@ -161,7 +164,7 @@ public: sif::info << "TemperatureSet::printSet: MCU Temperature: " << this->mcuTemperature << " °C" << std::endl; sif::info << "TemperatureSet::printSet: CMOS Temperature: " - << this->mcuTemperature << " °C" << std::endl; + << this->cmosTemperature << " °C" << std::endl; } }; @@ -192,6 +195,20 @@ public: PoolIds::MAJOR, this); lp_var_t minor = lp_var_t(sid.objectId, PoolIds::MINOR, this); + + void printSet() { + PoolReadGuard rg(this); + sif::info << "VersionSet::printSet: Ticks: " + << this->ticks << std::endl; + sif::info << "VersionSet::printSet: Unix Time: " + << this->time << " us" << std::endl; + sif::info << "VersionSet::printSet: Program: " + << static_cast(this->program.value) << std::endl; + sif::info << "VersionSet::printSet: Major: " + << static_cast(this->major.value) << std::endl; + sif::info << "VersionSet::printSet: Minor: " + << static_cast(this->minor.value) << std::endl; + } }; /** @@ -219,22 +236,18 @@ public: PoolIds::FRAME_COUNT, this); lp_var_t checksumerrorCount = lp_var_t(sid.objectId, PoolIds::CHECKSUM_ERROR_COUNT, this); - lp_var_t setParamCount = lp_var_t(sid.objectId, - PoolIds::SET_PARAM_COUNT, this); - lp_var_t setParamReplyCount = lp_var_t(sid.objectId, - PoolIds::SET_PARAM_REPLY_COUNT, this); - lp_var_t paramRequestCount = lp_var_t(sid.objectId, - PoolIds::PARAM_REQUEST_COUNT, this); - lp_var_t paramReplyCount = lp_var_t(sid.objectId, - PoolIds::PARAM_REPLY_COUNT, this); - lp_var_t reqTmCount = lp_var_t(sid.objectId, - PoolIds::REQ_TM_COUNT, this); - lp_var_t tmReplyCount = lp_var_t(sid.objectId, - PoolIds::TM_REPLY_COUNT, this); - lp_var_t actionReqCount = lp_var_t(sid.objectId, - PoolIds::ACTION_REQ_COUNT, this); - lp_var_t actionReplyCount = lp_var_t(sid.objectId, - PoolIds::ACTION_REPLY_COUNT, this); + + void printSet() { + PoolReadGuard rg(this); + sif::info << "InterfaceSet::printSet: Ticks: " + << this->ticks << std::endl; + sif::info << "InterfaceSet::printSet: Time: " + << this->time << " us" << std::endl; + sif::info << "InterfaceSet::printSet: Frame Count: " + << this->frameCount << std::endl; + sif::info << "InterfaceSet::printSet: Checksum Error Count: " + << this->checksumerrorCount << std::endl; + } }; /** @@ -290,6 +303,46 @@ public: PoolIds::CMV_RES_CURRENT, this); lp_var_t cmvResVoltage = lp_var_t(sid.objectId, PoolIds::CMV_RES_VOLTAGE, this); + + void printSet() { + PoolReadGuard rg(this); + sif::info << "PowerSet::printSet: Ticks: " + << this->ticks << std::endl; + sif::info << "PowerSet::printSet: Time: " + << this->time << " us" << std::endl; + sif::info << "PowerSet::printSet: MCU Current: " + << this->mcuCurrent << " A" << std::endl; + sif::info << "PowerSet::printSet: MCU Voltage: " + << this->mcuVoltage << " V" << std::endl; + sif::info << "PowerSet::printSet: FPGA Core current: " + << this->fpgaCoreCurrent << " A" << std::endl; + sif::info << "PowerSet::printSet: FPGA Core voltage: " + << this->fpgaCoreVoltage << " V" << std::endl; + sif::info << "PowerSet::printSet: FPGA 18 current: " + << this->fpga18Current << " A" << std::endl; + sif::info << "PowerSet::printSet: FPGA 18 voltage: " + << this->fpga18Voltage << " V" << std::endl; + sif::info << "PowerSet::printSet: FPGA 25 current: " + << this->fpga25Current << " A" << std::endl; + sif::info << "PowerSet::printSet: FPGA 25 voltage: " + << this->fpga25Voltage << " V" << std::endl; + sif::info << "PowerSet::printSet: CMV 21 current: " + << this->cmv21Current << " A" << std::endl; + sif::info << "PowerSet::printSet: CMV 21 voltage: " + << this->cmv21Voltage << " V" << std::endl; + sif::info << "PowerSet::printSet: CMV Pix current: " + << this->cmvPixCurrent << " A" << std::endl; + sif::info << "PowerSet::printSet: CMV Pix voltage: " + << this->cmvPixVoltage << " V" << std::endl; + sif::info << "PowerSet::printSet: CMV 33 current: " + << this->cmv33Current << " A" << std::endl; + sif::info << "PowerSet::printSet: CMV 33 voltage: " + << this->cmv33Voltage << " V" << std::endl; + sif::info << "PowerSet::printSet: CMV Res current: " + << this->cmvResCurrent << " A" << std::endl; + sif::info << "PowerSet::printSet: CMV Res voltage: " + << this->cmvResVoltage << " V" << std::endl; + } }; /** From 1affc1e1d3bd8d653ffd5a7c4e43cc33e6cdf68f Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 29 Nov 2021 15:02:14 +0100 Subject: [PATCH 110/465] str image helper, step failure handling --- bsp_q7s/devices/StarTrackerImageHelper.cpp | 26 +++++++++++++++++++--- bsp_q7s/devices/StarTrackerImageHelper.h | 9 +++++--- mission/devices/StarTrackerHandler.cpp | 13 ++++++----- mission/devices/StarTrackerHandler.h | 2 +- 4 files changed, 37 insertions(+), 13 deletions(-) diff --git a/bsp_q7s/devices/StarTrackerImageHelper.cpp b/bsp_q7s/devices/StarTrackerImageHelper.cpp index c225e3b9..3fb62b99 100644 --- a/bsp_q7s/devices/StarTrackerImageHelper.cpp +++ b/bsp_q7s/devices/StarTrackerImageHelper.cpp @@ -195,10 +195,30 @@ void StarTrackerImageHelper::stepSuccessfulReceived(ActionId_t actionId, void StarTrackerImageHelper::stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) { + switch (pendingCommand) { + case (StarTracker::UPLOAD_IMAGE): + if (retries < MAX_RETRIES) { + // Repeat sending last command + commandsSent--; + remainingCommands++; + commandImageUpload(); + retries++; + state = State::COMMAND_EXECUTING; + } + else { + triggerEvent(IMAGE_UPLOAD_FAILED, returnCode, commandsSent); + retries = 0; + state = State::IDLE; + } + break; + default: + sif::debug << "StarTrackerImageHelper::completionSuccessfulReceived: Invalid pending command" + << std::endl; + break; + } } void StarTrackerImageHelper::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) { - } void StarTrackerImageHelper::completionSuccessfulReceived(ActionId_t actionId) { @@ -225,7 +245,7 @@ void StarTrackerImageHelper::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) { switch(pendingCommand) { case(StarTracker::UPLOAD_IMAGE): { - triggerEvent(IMAGE_UPLOAD_FAILED); + triggerEvent(IMAGE_UPLOAD_FAILED, returnCode, commandsSent); break; } default: @@ -240,7 +260,7 @@ void StarTrackerImageHelper::commandImageUpload() { ReturnValue_t result = RETURN_OK; uint16_t dataLen = 0; uint8_t tmpCommandBuffer[UPLOAD_COMMAND_SIZE] = {0}; - uint32_t position = commandsSent * SIZE_IMAGE_PART; + uint32_t position = commandsSent; if (not std::filesystem::exists(imageFile)) { triggerEvent(IMAGE_FILE_NOT_EXISTS, commandsSent); diff --git a/bsp_q7s/devices/StarTrackerImageHelper.h b/bsp_q7s/devices/StarTrackerImageHelper.h index 59dc7b83..420721dc 100644 --- a/bsp_q7s/devices/StarTrackerImageHelper.h +++ b/bsp_q7s/devices/StarTrackerImageHelper.h @@ -72,13 +72,14 @@ private: //! P1: Return value of CommandActionHelper::commandAction //! P2: Action ID of command to send static const Event ACTION_COMMANDING_FAILED = MAKE_EVENT(1, severity::LOW); - //! [EXPORT] : [COMMENT] Star tracker handler replies with completion failure message to upload image command - //! P1: Upload step of the failed command execution + //! [EXPORT] : [COMMENT] Star tracker handler replies with completion or step failure message to upload image command + //!P1: Return code of execution/step failure message + //!P2: Failed upload step (equal to number of commands already sent) static const Event IMAGE_UPLOAD_FAILED = MAKE_EVENT(2, severity::LOW); //! [EXPORT] : [COMMENT] Image upload was successful static const Event IMAGE_UPLOAD_FINISHED = MAKE_EVENT(3, severity::LOW); - + static const uint8_t MAX_RETRIES = 3; static const uint32_t QUEUE_SIZE = config::STR_IMG_HELPER_QUEUE_SIZE; static const size_t MAX_STR_IMAGE_PATH = 50; static const size_t SD_PREFIX_LENGTH = 8; @@ -108,6 +109,8 @@ private: uint32_t commandsSent = 0; uint32_t remainingCommands = 0; + // Counts retries when command was rejected by star tracker + uint8_t retries = 0; // Path and name of active image (either upload or download image) std::string imageFile; diff --git a/mission/devices/StarTrackerHandler.cpp b/mission/devices/StarTrackerHandler.cpp index 0b2048c0..ed5f5e56 100644 --- a/mission/devices/StarTrackerHandler.cpp +++ b/mission/devices/StarTrackerHandler.cpp @@ -604,12 +604,13 @@ ReturnValue_t StarTrackerHandler::handleUploadImageReply() { if (result != RETURN_OK) { return result; } - uint32_t position = deserializeUint32(decodedFrame + ACTION_DATA_OFFSET); - if (position != rememberUploadPosition) { - sif::warning << "StarTrackerHandler::handleUploadImageReply: Invalid position" - << std::endl; - return UPLOAD_IMAGE_FAILED; - } + // Position seems to be always 0 (independent of sent position) +// uint32_t position = deserializeUint32(decodedFrame + ACTION_DATA_OFFSET); +// if (position != rememberUploadPosition) { +// sif::warning << "StarTrackerHandler::handleUploadImageReply: Invalid position" +// << std::endl; +// return UPLOAD_IMAGE_FAILED; +// } return result; } diff --git a/mission/devices/StarTrackerHandler.h b/mission/devices/StarTrackerHandler.h index e082cf46..cbf05242 100644 --- a/mission/devices/StarTrackerHandler.h +++ b/mission/devices/StarTrackerHandler.h @@ -90,7 +90,7 @@ private: // position (uint32) + 1024 image data static const size_t UPLOAD_COMMAND_LEN = 1028; // Max valid position value in upload image command - static const uint16_t MAX_POSITION= 3071; + static const uint16_t MAX_POSITION= 4095; static const uint8_t STATUS_OFFSET = 2; static const uint8_t TICKS_OFFSET = 3; static const uint8_t TIME_OFFSET = 7; From 667bbc918f5ab62430fb841b77678f8318ac3fa7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 30 Nov 2021 14:40:35 +0100 Subject: [PATCH 111/465] make some debug output optional --- linux/obc/PdecHandler.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/linux/obc/PdecHandler.cpp b/linux/obc/PdecHandler.cpp index 027cac80..0c2d207a 100644 --- a/linux/obc/PdecHandler.cpp +++ b/linux/obc/PdecHandler.cpp @@ -295,7 +295,9 @@ bool PdecHandler::checkFrameAna(uint32_t pdecFar) { break; } case(FrameAna_t::FRAME_ACCEPTED): { - sif::debug << "PdecHandler::checkFrameAna: Accepted TC frame" << std::endl; +#if OBSW_DEBUG_PDEC_HANDLER == 1 + sif::info << "PdecHandler::checkFrameAna: Accepted TC frame" << std::endl; +#endif frameValid = true; break; } From 8d284b3d2acc1875a1a1c24fce594b878c5c0211 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 30 Nov 2021 14:41:42 +0100 Subject: [PATCH 112/465] using warning insted of debug --- linux/obc/PdecHandler.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/linux/obc/PdecHandler.cpp b/linux/obc/PdecHandler.cpp index 0c2d207a..1ac83d44 100644 --- a/linux/obc/PdecHandler.cpp +++ b/linux/obc/PdecHandler.cpp @@ -257,7 +257,7 @@ bool PdecHandler::checkFrameAna(uint32_t pdecFar) { switch(frameAna) { case(FrameAna_t::ABANDONED_CLTU): { triggerEvent(INVALID_TC_FRAME, ABANDONED_CLTU); - sif::debug << "PdecHandler::checkFrameAna: Abondoned CLTU" << std::endl; + sif::warning << "PdecHandler::checkFrameAna: Abondoned CLTU" << std::endl; break; } case(FrameAna_t::FRAME_DIRTY): { @@ -266,31 +266,31 @@ bool PdecHandler::checkFrameAna(uint32_t pdecFar) { break; } case(FrameAna_t::FRAME_ILLEGAL): { - sif::debug << "PdecHandler::checkFrameAna: Frame illegal for one reason" << std::endl; + sif::warning << "PdecHandler::checkFrameAna: Frame illegal for one reason" << std::endl; handleIReason(pdecFar, FRAME_ILLEGAL_ONE_REASON); break; } case(FrameAna_t::FRAME_ILLEGAL_MULTI_REASON): { - sif::debug << "PdecHandler::checkFrameAna: Frame illegal for multiple reasons" + sif::warning << "PdecHandler::checkFrameAna: Frame illegal for multiple reasons" << std::endl; handleIReason(pdecFar, FRAME_ILLEGAL_MULTIPLE_REASONS); break; } case(FrameAna_t::AD_DISCARDED_LOCKOUT): { triggerEvent(INVALID_TC_FRAME, AD_DISCARDED_LOCKOUT); - sif::debug << "PdecHandler::checkFrameAna: AD frame discarded because of lockout" + sif::warning << "PdecHandler::checkFrameAna: AD frame discarded because of lockout" << std::endl; break; } case(FrameAna_t::AD_DISCARDED_WAIT): { triggerEvent(INVALID_TC_FRAME, AD_DISCARDED_LOCKOUT); - sif::debug << "PdecHandler::checkFrameAna: AD frame discarded because of wait" + sif::warning << "PdecHandler::checkFrameAna: AD frame discarded because of wait" << std::endl; break; } case(FrameAna_t::AD_DISCARDED_NS_VR): { triggerEvent(INVALID_TC_FRAME, AD_DISCARDED_NS_VS); - sif::debug << "PdecHandler::checkFrameAna: AD frame discarded because N(S) or V(R)" + sif::warning << "PdecHandler::checkFrameAna: AD frame discarded because N(S) or V(R)" << std::endl; break; } From d287aa80c11b517fe6c3719266944edc863acf76 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 30 Nov 2021 14:54:10 +0100 Subject: [PATCH 113/465] increase max number of stored packets in tmtcbridge --- fsfw | 2 +- mission/core/GenericFactory.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fsfw b/fsfw index d8580074..ceb87b5a 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit d8580074c2730d861353ab47e659afeb707afe71 +Subproject commit ceb87b5abb2992a18266328e0ea34d9af15db7af diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index 58485b71..14c8791a 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -101,18 +101,18 @@ void ObjectFactory::produceGenericObjects() { #if OBSW_ADD_TCPIP_BRIDGE == 1 #if OBSW_USE_TCP_BRIDGE == 0 auto tmtcBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - tmtcBridge->setMaxNumberOfPacketsStored(50); new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); sif::info << "Created UDP server for TMTC commanding with listener port " << udpBridge->getUdpPort() << std::endl; #else auto tmtcBridge = new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - tmtcBridge->setMaxNumberOfPacketsStored(50); auto tcpServer = new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); // TCP is stream based. Use packet ID as start marker when parsing for space packets tcpServer->setSpacePacketParsingOptions({common::PUS_PACKET_ID}); sif::info << "Created TCP server for TMTC commanding with listener port " << tcpServer->getTcpPort() << std::endl; #endif /* OBSW_USE_TMTC_TCP_BRIDGE == 0 */ + tmtcBridge->setMaxNumberOfPacketsStored(70); #endif /* OBSW_ADD_TCPIP_BRIDGE == 1 */ + } From 8c649b3e700aa1a1965b56a0588762669f779c60 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 30 Nov 2021 16:01:02 +0100 Subject: [PATCH 114/465] str image loader wip --- bsp_q7s/devices/PlocUpdater.cpp | 35 +----------- bsp_q7s/devices/PlocUpdater.h | 7 --- bsp_q7s/devices/StrImageLoader.cpp | 75 ++++++++++++++++++++++++++ bsp_q7s/devices/StrImageLoader.h | 56 +++++++++++++++++++ bsp_q7s/memory/SdCardManager.cpp | 30 +++++++++++ bsp_q7s/memory/SdCardManager.h | 9 ++++ common/config/commonClassIds.h | 2 +- mission/devices/StarTrackerHandler.cpp | 17 ++++-- mission/devices/StarTrackerHandler.h | 9 +++- 9 files changed, 195 insertions(+), 45 deletions(-) create mode 100644 bsp_q7s/devices/StrImageLoader.cpp create mode 100644 bsp_q7s/devices/StrImageLoader.h diff --git a/bsp_q7s/devices/PlocUpdater.cpp b/bsp_q7s/devices/PlocUpdater.cpp index 4771e14c..592a2c0d 100644 --- a/bsp_q7s/devices/PlocUpdater.cpp +++ b/bsp_q7s/devices/PlocUpdater.cpp @@ -168,13 +168,13 @@ ReturnValue_t PlocUpdater::getImageLocation(const uint8_t* data, size_t size) { #if BOARD_TE0720 == 0 // Check if file is stored on SD card and if associated SD card is mounted if (std::string(reinterpret_cast(data), SD_PREFIX_LENGTH) == std::string(SdCardManager::SD_0_MOUNT_POINT)) { - if (!isSdCardMounted(sd::SLOT_0)) { + if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { sif::warning << "PlocUpdater::getImageLocation: SD card 0 not mounted" << std::endl; return SD_NOT_MOUNTED; } } else if (std::string(reinterpret_cast(data), SD_PREFIX_LENGTH) == std::string(SdCardManager::SD_1_MOUNT_POINT)) { - if (!isSdCardMounted(sd::SLOT_0)) { + if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { sif::warning << "PlocUpdater::getImageLocation: SD card 1 not mounted" << std::endl; return SD_NOT_MOUNTED; } @@ -193,37 +193,6 @@ ReturnValue_t PlocUpdater::getImageLocation(const uint8_t* data, size_t size) { return RETURN_OK; } -#if BOARD_TE0720 == 0 -bool PlocUpdater::isSdCardMounted(sd::SdCard sdCard) { - SdCardManager::SdStatePair active; - ReturnValue_t result = sdcMan->getSdCardActiveStatus(active); - if (result != RETURN_OK) { - sif::debug << "PlocUpdater::isSdCardMounted: Failed to get SD card active state"; - return false; - } - if (sdCard == sd::SLOT_0) { - if (active.first == sd::MOUNTED) { - return true; - } - else { - return false; - } - } - else if (sdCard == sd::SLOT_1) { - if (active.second == sd::MOUNTED) { - return true; - } - else { - return false; - } - } - else { - sif::debug << "PlocUpdater::isSdCardMounted: Unknown SD card specified" << std::endl; - } - return false; -} -#endif /* #if BOARD_TE0720 == 0 */ - void PlocUpdater::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) { } diff --git a/bsp_q7s/devices/PlocUpdater.h b/bsp_q7s/devices/PlocUpdater.h index 50404d14..d016b9e5 100644 --- a/bsp_q7s/devices/PlocUpdater.h +++ b/bsp_q7s/devices/PlocUpdater.h @@ -174,13 +174,6 @@ private: */ void commandUpdateVerify(); -#if BOARD_TE0720 == 0 - /** - * @brief Checks whether the SD card to read from is mounted or not. - */ - bool isSdCardMounted(sd::SdCard sdCard); -#endif - void calcImageCrc(); void adjustSequenceFlags(PLOC_SPV::UpdatePacket& packet); diff --git a/bsp_q7s/devices/StrImageLoader.cpp b/bsp_q7s/devices/StrImageLoader.cpp new file mode 100644 index 00000000..803fb122 --- /dev/null +++ b/bsp_q7s/devices/StrImageLoader.cpp @@ -0,0 +1,75 @@ +#include "StrImageLoader.h" + +#include + +StrImageLoader::StrImageLoader(object_id_t objectId) { + +} + +StrImageLoader::~StrImageLoader() { +} + +ReturnValue_t StrImageLoader::initialize() { + sdcMan = SdCardManager::instance(); + if (sdcMan == nullptr) { + sif::warning << "StrImageLoader::initialize: Invalid SD Card Manager" << std::endl; + } +} + +ReturnValue_t StrImageLoader::performOperation(uint8_t operationCode) { + semaphore.acquire(); + while(true) { + switch(internalState) { + case InternalState::IDLE: + semaphore.acquire(); + break; + case InternalState::UPLOAD_IMAGE: + uploadImage(); + break; + case InternalState::DOWNLOAD_IMAGE: + break; + } + } +} + +void StrImageLoader::setComIF(DeviceCommunicationIF* communicationInterface_) { + communicationInterface = communicationInterface_; +} + +void StrImageLoader::setComCookie(CookieIF* comCookie_) { + comCookie = comCookie_; +} + +ReturnValue_t StrImageLoader::startImageUpload(std::string image) { + + //TODO: Use string part not data pointer + // Check if file is stored on SD card and if associated SD card is mounted + if (image.substr(0, sizeof(SdCardManager::SD_0_MOUNT_POINT)) + == std::string(SdCardManager::SD_0_MOUNT_POINT)) { + if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { + sif::warning << "StrImageLoader::getImageLocation: SD card 0 not mounted" << std::endl; + return SD_NOT_MOUNTED; + } + } else if (image.substr(0, sizeof(SdCardManager::SD_1_MOUNT_POINT)) + == std::string(SdCardManager::SD_1_MOUNT_POINT)) { + if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { + sif::warning << "StrImageLoader::getImageLocation: SD card 1 not mounted" << std::endl; + return SD_NOT_MOUNTED; + } + } + + uploadImage = image; + + if(not std::filesystem::exists(uploadImage)) { + return FILE_NOT_EXISTS; + } + + internalState = InternalState::UPLOAD_IMAGE; + + semaphore.release(); +} + +ReturnValue_t StrImageLoader::uploadImage() { + +} + diff --git a/bsp_q7s/devices/StrImageLoader.h b/bsp_q7s/devices/StrImageLoader.h new file mode 100644 index 00000000..39013fe6 --- /dev/null +++ b/bsp_q7s/devices/StrImageLoader.h @@ -0,0 +1,56 @@ +#ifndef BSP_Q7S_DEVICES_STRIMAGELOADER_H_ +#define BSP_Q7S_DEVICES_STRIMAGELOADER_H_ + +#include + +#include "fsfw/osal/linux/BinarySemaphore.h" +#include "bsp_q7s/memory/SdCardManager.h" + +/** + * @brief An object of this class runs in a separate task and is responsible for uploading and + * downloading images to/from the star tracker. This is required because uploading and + * downloading via the star tracker handler takes a lot of time because each upload or + * download packet can transport a maximum of 1024 bytes. + */ +class StrImageLoader: public SystemObject, public ExecutableObjectIF { +public: + StrImageLoader(object_id_t objectId); + virtual ~StrImageLoader(); + + ReturnValue_t performOperation(uint8_t operationCode = 0) override; + + void setComIF(DeviceCommunicationIF* communicationInterface_); + void setComCookie(CookieIF* comCookie_); + +private: + + static const uint8_t INTERFACE_ID = CLASS_ID::STR_IMG_LOADER; + + //! [EXPORT] : [COMMENT] SD card specified in 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); + + enum class InternalState { + IDLE, + UPLOAD_IMAGE, + DOWNLOAD_IMAGE + }; + + InternalState internalState = InternalState::IDLE; + + BinarySemaphore semaphore; + + // Absolute path and name to image to upload + std::string uploadImage; + + SdCardManager* sdcMan = nullptr; + + /** + * Communication object responsible for low level access of star tracker + * Must be set by star tracker handler + */ + DeviceCommunicationIF * communicationInterface = nullptr; +}; + +#endif /* BSP_Q7S_DEVICES_STRIMAGELOADER_H_ */ diff --git a/bsp_q7s/memory/SdCardManager.cpp b/bsp_q7s/memory/SdCardManager.cpp index ebebf854..ea16b672 100644 --- a/bsp_q7s/memory/SdCardManager.cpp +++ b/bsp_q7s/memory/SdCardManager.cpp @@ -455,3 +455,33 @@ void SdCardManager::setPrintCommandOutput(bool print) { } +bool SdCardManager::isSdCardMounted(sd::SdCard sdCard) { + SdCardManager::SdStatePair active; + ReturnValue_t result = sdcMan->getSdCardActiveStatus(active); + if (result != RETURN_OK) { + sif::debug << "SdCardManager::isSdCardMounted: Failed to get SD card active state"; + return false; + } + if (sdCard == sd::SLOT_0) { + if (active.first == sd::MOUNTED) { + return true; + } + else { + return false; + } + } + else if (sdCard == sd::SLOT_1) { + if (active.second == sd::MOUNTED) { + return true; + } + else { + return false; + } + } + else { + sif::debug << "SdCardManager::isSdCardMounted: Unknown SD card specified" << std::endl; + } + return false; +} + + diff --git a/bsp_q7s/memory/SdCardManager.h b/bsp_q7s/memory/SdCardManager.h index 6f03e7f1..6e4930da 100644 --- a/bsp_q7s/memory/SdCardManager.h +++ b/bsp_q7s/memory/SdCardManager.h @@ -195,6 +195,15 @@ public: void setBlocking(bool blocking); void setPrintCommandOutput(bool print); + + /** + * @brief Checks if an SD card is mounted + * + * @param sdCard The SD crad to check + * + * @return true if mounted, otherwise false + */ + bool isSdCardMounted(sd::SdCard sdCard); private: CommandExecutor cmdExecutor; Operations currentOp = Operations::IDLE; diff --git a/common/config/commonClassIds.h b/common/config/commonClassIds.h index b2885009..a47e97d1 100644 --- a/common/config/commonClassIds.h +++ b/common/config/commonClassIds.h @@ -19,7 +19,7 @@ enum commonClassIds: uint8_t { CCSDS_IP_CORE_BRIDGE, //IPCI PTME, //PTME PLOC_UPDATER, //PLUD - STR_IMG_HELPER, //STRIMGH + STR_IMG_LOADER, //STRIMGL GOM_SPACE_HANDLER, //GOMS PLOC_MEMORY_DUMPER, //PLMEMDUMP PDEC_HANDLER, //PDEC diff --git a/mission/devices/StarTrackerHandler.cpp b/mission/devices/StarTrackerHandler.cpp index ed5f5e56..f05dec71 100644 --- a/mission/devices/StarTrackerHandler.cpp +++ b/mission/devices/StarTrackerHandler.cpp @@ -10,16 +10,27 @@ extern "C" { } StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie) : + CookieIF * comCookie, StrImageLoader* strImageLoader) : DeviceHandlerBase(objectId, comIF, comCookie), temperatureSet(this), versionSet(this), powerSet( - this), interfaceSet(this), timeSet(this), solutionSet(this) { - if (comCookie == NULL) { + this), interfaceSet(this), timeSet(this), solutionSet(this), strImageLoader( + strImageLoader) { + if (comCookie == nullptr) { sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl; } + if (strImageLoader == nullptr) { + sif::error << "StarTrackerHandler: Invalid str image loader" << std::endl; + } slipInit(); } StarTrackerHandler::~StarTrackerHandler() { + DeviceHandlerBase::initialize(); + strImageLoader->setComIF(communicationInterface); + strImageLoader->setComCookie(comCookie); +} + +ReturnValue_t StarTrackerHandler::initialize() { + } void StarTrackerHandler::doStartUp() { diff --git a/mission/devices/StarTrackerHandler.h b/mission/devices/StarTrackerHandler.h index cbf05242..d74d6fd2 100644 --- a/mission/devices/StarTrackerHandler.h +++ b/mission/devices/StarTrackerHandler.h @@ -6,6 +6,7 @@ #include #include #include +#include /** * @brief This is the device handler for the star tracker from arcsec. @@ -28,9 +29,12 @@ public: * @param enablePin GPIO connected to the enable pin of the reaction wheels. Must be pulled * to high to enable the device. */ - StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); + StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie, + StrImageLoader* strImageLoader); virtual ~StarTrackerHandler(); + ReturnValue_t initialize() override; + protected: void doStartUp() override; void doShutDown() override; @@ -106,6 +110,9 @@ private: static const MutexIF::TimeoutType TIMEOUT_TYPE= MutexIF::TimeoutType::WAITING; static const uint32_t MUTEX_TIMEOUT = 20; + // Pointer to object responsible for uploading and downloading images to/from the star tracker + StrImageLoader* strImageLoader = nullptr; + StarTracker::TemperatureSet temperatureSet; StarTracker::VersionSet versionSet; StarTracker::PowerSet powerSet; From 77f6ac57e959698dfcf77ffbad643b93ee0a2c89 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 30 Nov 2021 16:45:33 +0100 Subject: [PATCH 115/465] some reaction wheel fixes --- bsp_q7s/callbacks/rwSpiCallback.cpp | 15 +++++++++++++-- bsp_q7s/callbacks/rwSpiCallback.h | 3 +++ bsp_q7s/core/InitMission.cpp | 2 +- mission/devices/RwHandler.h | 2 ++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/bsp_q7s/callbacks/rwSpiCallback.cpp b/bsp_q7s/callbacks/rwSpiCallback.cpp index 620f63f7..ad99d505 100644 --- a/bsp_q7s/callbacks/rwSpiCallback.cpp +++ b/bsp_q7s/callbacks/rwSpiCallback.cpp @@ -133,8 +133,15 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sen closeSpi(gpioId, gpioIF, mutex); return RwHandler::SPI_READ_FAILURE; } + if(idx == 0) { + if(byteRead != FLAG_BYTE) { + sif::error << "Invalid data, expected start marker" << std::endl; + closeSpi(gpioId, gpioIF, mutex); + return RwHandler::NO_START_MARKER; + } + } - if (byteRead != 0x7E) { + if (byteRead != FLAG_BYTE) { break; } @@ -145,6 +152,10 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sen } } +#if FSFW_HAL_SPI_WIRETAPPING == 1 + sif::info << "RW start marker detected" << std::endl; +#endif + size_t decodedFrameLen = 0; while(decodedFrameLen < replyBufferSize) { @@ -158,7 +169,7 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sen } } - if (byteRead == 0x7E) { + if (byteRead == FLAG_BYTE) { /** Reached end of frame */ break; } diff --git a/bsp_q7s/callbacks/rwSpiCallback.h b/bsp_q7s/callbacks/rwSpiCallback.h index cc7c6cbe..8952f873 100644 --- a/bsp_q7s/callbacks/rwSpiCallback.h +++ b/bsp_q7s/callbacks/rwSpiCallback.h @@ -8,6 +8,9 @@ namespace rwSpiCallback { +//! This is the end and start marker of the frame datalinklayer +static constexpr uint8_t FLAG_BYTE = 0x7E; + /** * @brief This is the callback function to send commands to the nano avionics reaction wheels and * receive the replies. diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index 7923a2cd..81d972b1 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -22,7 +22,7 @@ ServiceInterfaceStream sif::debug("DEBUG"); ServiceInterfaceStream sif::info("INFO"); ServiceInterfaceStream sif::warning("WARNING"); -ServiceInterfaceStream sif::error("ERROR", false, false, true); +ServiceInterfaceStream sif::error("ERROR"); #else ServiceInterfaceStream sif::debug("DEBUG", true); ServiceInterfaceStream sif::info("INFO", true); diff --git a/mission/devices/RwHandler.h b/mission/devices/RwHandler.h index cd753be0..57895ca6 100644 --- a/mission/devices/RwHandler.h +++ b/mission/devices/RwHandler.h @@ -46,6 +46,8 @@ public: static const ReturnValue_t MISSING_END_SIGN = MAKE_RETURN_CODE(0xB4); //! [EXPORT] : [COMMENT] Reaction wheel only responds with empty frames. static const ReturnValue_t NO_REPLY = MAKE_RETURN_CODE(0xB5); + //! [EXPORT] : [COMMENT] Expected a start marker as first byte + static const ReturnValue_t NO_START_MARKER = MAKE_RETURN_CODE(0xB6); protected: void doStartUp() override; From a7ab2bb93a0f5bd77fc794f4ab364b1769baebd7 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 2 Dec 2021 08:05:33 +0100 Subject: [PATCH 116/465] str img loader wip --- bsp_q7s/devices/ArcsecDatalinkLayer.cpp | 68 ++++ bsp_q7s/devices/ArcsecDatalinkLayer.h | 84 ++++ bsp_q7s/devices/StrImageLoader.cpp | 89 +++- bsp_q7s/devices/StrImageLoader.h | 49 ++- common/config/commonObjects.h | 2 +- common/config/commonSubsystemIds.h | 2 +- mission/devices/StarTrackerHandler.cpp | 381 ++++++++++-------- mission/devices/StarTrackerHandler.h | 52 +-- .../StarTrackerDefinitions.h | 1 + mission/tmtc/CCSDSHandler.cpp | 10 +- tmtc | 2 +- 11 files changed, 526 insertions(+), 214 deletions(-) create mode 100644 bsp_q7s/devices/ArcsecDatalinkLayer.cpp create mode 100644 bsp_q7s/devices/ArcsecDatalinkLayer.h diff --git a/bsp_q7s/devices/ArcsecDatalinkLayer.cpp b/bsp_q7s/devices/ArcsecDatalinkLayer.cpp new file mode 100644 index 00000000..1f436636 --- /dev/null +++ b/bsp_q7s/devices/ArcsecDatalinkLayer.cpp @@ -0,0 +1,68 @@ +#include "ArcsecDatalinkLayer.h" + +ArcsecDatalinkLayer::ArcsecDatalinkLayer() { + slipInit(); +} + +ArcsecDatalinkLayer::~ArcsecDatalinkLayer() { +} + +void ArcsecDatalinkLayer::slipInit() { + slipInfo.buffer = rxBuffer; + slipInfo.maxlength = StarTracker::MAX_FRAME_SIZE; + slipInfo.length = 0; + slipInfo.unescape_next = 0; + slipInfo.prev_state = SLIP_COMPLETE; +} + +ReturnValue_t ArcsecDatalinkLayer::decodeFrame(const uint8_t* rawData, size_t rawDataSize, + size_t* bytesLeft) { + size_t bytePos = 0; + for (bytePos = 0; bytePos < rawDataSize; bytePos++) { + enum arc_dec_result decResult = arc_transport_decode_body(*(rawData + bytePos), &slipInfo, + decodedFrame, &decFrameSize); + *bytesLeft = rawDataSize - bytePos; + switch (decResult) { + case ARC_DEC_INPROGRESS: { + if (bytePos == rawDataSize - 1) { + return DEC_IN_PROGRESS; + } + continue; + } + case ARC_DEC_ERROR_FRAME_SHORT: + return REPLY_TOO_SHORT; + case ARC_DEC_ERROR_CHECKSUM: + return CRC_FAILURE; + case ARC_DEC_ASYNC: + case ARC_DEC_SYNC: { + // Reset length of SLIP struct for next frame + slipInfo.length = 0; + RETURN_OK; + } + default: + sif::debug << "ArcsecDatalinkLayer::decodeFrame: Unknown result code" << std::endl; + break; + } + } +} + +uint8_t ArcsecDatalinkLayer::getReplyFrameType() { + return decodedFrame[0]; +} + +const uint8_t* ArcsecDatalinkLayer::getReply() { + return &decodedFrame[1]; +} + +void ArcsecDatalinkLayer::encodeFrame(const uint8_t* data, uint32_t length) { + arc_transport_encode_body(commandBuffer, length, encBuffer, &encFrameSize); +} + +uint8_t* ArcsecDatalinkLayer::getEncodedFrame() { + return encBuffer; +} + +uint32_t ArcsecDatalinkLayer::getEncodedLength() { + return encFrameSize; +} + diff --git a/bsp_q7s/devices/ArcsecDatalinkLayer.h b/bsp_q7s/devices/ArcsecDatalinkLayer.h new file mode 100644 index 00000000..bce1f619 --- /dev/null +++ b/bsp_q7s/devices/ArcsecDatalinkLayer.h @@ -0,0 +1,84 @@ +#ifndef BSP_Q7S_DEVICES_ARCSECDATALINKLAYER_H_ +#define BSP_Q7S_DEVICES_ARCSECDATALINKLAYER_H_ + +#include "mission/devices/devicedefinitions/StarTrackerDefinitions.h" +#include "fsfw/returnvalues/HasReturnValuesIF.h" + +extern "C" { + #include "common/misc.h" +} + +/** + * @brief Helper class to handle the datalinklayer of replies from the star tracker of arcsec. + */ +class ArcsecDatalinkLayer: public HasReturnvaluesIF { +public: + + static const uint8_t INTERFACE_ID = CLASS_ID::STR_HANDLER; + + //! [EXPORT] : [COMMENT] More data required to complete frame + static const ReturnValue_t DEC_IN_PROGRESS = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] Data too short to represent a valid frame + static const ReturnValue_t REPLY_TOO_SHORT = MAKE_RETURN_CODE(0xA1); + //! [EXPORT] : [COMMENT] Detected CRC failure in received frame + static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA2); + + ArcsecDatalinkLayer(); + virtual ~ArcsecDatalinkLayer(); + + /** + * @brief Applies decoding to data referenced by rawData pointer + * + * @param rawData Pointer to raw data received from star tracker + * @param rawDataSize Size of raw data stream + * @param remainingBytes Number of bytes left + */ + ReturnValue_t decodeFrame(const uint8_t* rawData, size_t rawDataSize, size_t* bytesLeft); + + /** + * @brief SLIP encodes data pointed to by data pointer. + * + * @param data Pointer to data to encode + * @param length Length of buffer to encode + */ + void encodeFrame(const uint8_t* data, uint32_t length); + + /** + * @brief Returns the frame type field of a decoded frame. + */ + uint8_t getReplyFrameType(); + + /** + * @brief Returns pointer to reply packet. + */ + const uint8_t* getReply(); + + /** + * @brief Returns size of encoded frame + */ + uint32_t getEncodedLength(); + + /** + * @brief Returns pointer to encoded frame + */ + uint8_t* getEncodedFrame(); + +private: + + // Used by arcsec slip decoding function process received data + uint8_t rxBuffer[StarTracker::MAX_FRAME_SIZE]; + // Decoded frame will be copied to this buffer + uint8_t decodedFrame[StarTracker::MAX_FRAME_SIZE]; + // Buffer where encoded frames will be stored + uint8_t encBuffer[StarTracker::MAX_FRAME_SIZE * 2 + 2]; + // Size of decoded frame + uint32_t decFrameSize = 0; + // Size of encoded frame + uint32_t encFrameSize = 0; + + slip_decode_state slipInfo; + + void slipInit(); +}; + +#endif /* BSP_Q7S_DEVICES_ARCSECDATALINKLAYER_H_ */ diff --git a/bsp_q7s/devices/StrImageLoader.cpp b/bsp_q7s/devices/StrImageLoader.cpp index 803fb122..7d4b64eb 100644 --- a/bsp_q7s/devices/StrImageLoader.cpp +++ b/bsp_q7s/devices/StrImageLoader.cpp @@ -17,15 +17,21 @@ ReturnValue_t StrImageLoader::initialize() { } ReturnValue_t StrImageLoader::performOperation(uint8_t operationCode) { + ReturnValue_t result = RETURN_OK; semaphore.acquire(); while(true) { switch(internalState) { - case InternalState::IDLE: + case InternalState::IDLE: { semaphore.acquire(); break; - case InternalState::UPLOAD_IMAGE: - uploadImage(); + } + case InternalState::UPLOAD_IMAGE: { + result = uploadImage(); + if (result == RETURN_OK){ + triggerEvent(IMAGE_UPLOAD_SUCCESSFUL); + } break; + } case InternalState::DOWNLOAD_IMAGE: break; } @@ -42,7 +48,6 @@ void StrImageLoader::setComCookie(CookieIF* comCookie_) { ReturnValue_t StrImageLoader::startImageUpload(std::string image) { - //TODO: Use string part not data pointer // Check if file is stored on SD card and if associated SD card is mounted if (image.substr(0, sizeof(SdCardManager::SD_0_MOUNT_POINT)) == std::string(SdCardManager::SD_0_MOUNT_POINT)) { @@ -70,6 +75,82 @@ ReturnValue_t StrImageLoader::startImageUpload(std::string image) { } ReturnValue_t StrImageLoader::uploadImage() { + ReturnValue_t result = RETURN_OK; + size_t receivedDataLen = 0; + uint8_t *receivedData = nullptr; + size_t bytesLeft = 0; + uint32_t readSize = 0; + uint32_t imageSize = 0; + struct UploadActionRequest uploadReq; + uploadReq.position = 0; + uploadReq.data = {0}; + if (not std::filesystem::exists(uploadImage)) { + triggerEvent(IMAGE_FILE_NOT_EXISTS, uploadReq.position); + state = State::IDLE; + return RETURN_FAILED; + } + + std::ifstream file(uploadImage, std::ifstream::binary); + file.seekg(0, file.end); + imageSize = file.tellg(); + file.seekg(uploadReq.position * SIZE_IMAGE_PART, file.beg); + + while(uploadReq.position * SIZE_IMAGE_PART < imageSize) { + result = + } + + uint32_t remainder = imageSize - uploadReq.position * SIZE_IMAGE_PART; + file.read(reinterpret_cast(uploadReq.data), remainder); + uploadReq.position++; + datalinkLayer.encodeFrame(uploadReq.data, remainder); + result = communicationInterface->sendMessage(comCookie, datalinkLayer.getEncodedFrame(), + datalinkLayer.getEncodedLength()); + if (result = RETURN_OK) { + sif::warning << "StrImageLoader::uploadImage: Failed to send upload packet" << std::endl; + triggerEvent(SENDING_UPLOAD_PACKET_FAILED, result, uploadReq.position); + return RETURN_FAILED; + } + result = ArcsecDatalinkLayer::DEC_IN_PROGRESS; + while(result == ArcsecDatalinkLayer::DEC_IN_PROGRESS) { + result = communicationInterface->requestReceiveMessage(comCookie, StarTracker::MAX_FRAME_SIZE* 2 + 2); + if (result != RETURN_OK) { + sif::warning << "StrImageLoader::uploadImage: Failed to request reply" << std::endl; + triggerEvent(UPLOAD_REQUESTING_MSG_FAILED, result, uploadReq.position); + return RETURN_FAILED; + } + result = communicationInterface->readReceivedMessage(comCookie, receivedData, + receivedDataLen); + if (result != RETURN_OK) { + sif::warning << "StrImageLoader::uploadImage: Failed to read received message" + << std::endl; + triggerEvent(UPLOAD_READING_REPLY_FAILED, result, uploadReq.position); + } + result = datalinkLayer.decodeFrame(receivedData, receivedDataLen, &bytesLeft); + if (bytesLeft != 0) { + // This should never happen + triggerEvent(UPLOAD_COM_ERROR, result, uploadReq.position); + return RETURN_FAILED; + } + } + + if (remainingCommands == 1) { + dataLen = imageSize - file.tellg(); + } + else { + dataLen = SIZE_IMAGE_PART; + } + + size_t size = 0; + size_t maxSize = sizeof(position); + uint8_t* commandBufferPtr = tmpCommandBuffer; + uint8_t** buffer = &commandBufferPtr; + SerializeAdapter::serialize(&position, buffer, &size, maxSize, + SerializeIF::Endianness::BIG); + file.read(reinterpret_cast(uploadReq.data), dataLen); + file.close(); + + arc_pack_upload_action_req() + communicationInterface->requestReceiveMessage(comCookie, ) } diff --git a/bsp_q7s/devices/StrImageLoader.h b/bsp_q7s/devices/StrImageLoader.h index 39013fe6..50cdc266 100644 --- a/bsp_q7s/devices/StrImageLoader.h +++ b/bsp_q7s/devices/StrImageLoader.h @@ -5,6 +5,8 @@ #include "fsfw/osal/linux/BinarySemaphore.h" #include "bsp_q7s/memory/SdCardManager.h" +#include "bsp_q7s/devices/ArcsecDatalinkLayer.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" /** * @brief An object of this class runs in a separate task and is responsible for uploading and @@ -12,8 +14,33 @@ * downloading via the star tracker handler takes a lot of time because each upload or * download packet can transport a maximum of 1024 bytes. */ -class StrImageLoader: public SystemObject, public ExecutableObjectIF { +class StrImageLoader: public SystemObject, public ExecutableObjectIF, public HasReturnvaluesIF { public: + + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_IMAGE_LOADER; + + //! [EXPORT] : [COMMENT] Try to upload image but specified image does not exist + static const Event IMAGE_FILE_NOT_EXISTS = MAKE_EVENT(0, severity::LOW); + //! [EXPORT] : [COMMENT] Sending image upload packet to star tracker failed + //!P1: Return code of communication interface sendMessage function + //!P2: Position of upload packet for which the transmission failed + static const Event SENDING_UPLOAD_PACKET_FAILED = MAKE_EVENT(1, severity::LOW); + //! [EXPORT] : [COMMENT] Communication interface requesting reply failed + //!P1: Return code of failed request + //!P1: Upload position for which the request failed + static const Event UPLOAD_REQUESTING_MSG_FAILED = MAKE_EVENT(2, severity::LOW); + //! [EXPORT] : [COMMENT] Uploading image to star tracker was successful + static const Event IMAGE_UPLOAD_SUCCESSFUL = MAKE_EVENT(3, severity::LOW); + //! [EXPORT] : [COMMENT] Failed to read communication interface reply data + //!P1: Return code of failed communication interface read call + //!P1: Upload position for which the read call failed + static const Event UPLOAD_READING_REPLY_FAILED = MAKE_EVENT(3, severity::LOW); + //! [EXPORT] : [COMMENT] Unexpected stop of decoding sequence + //!P1: Return code of failed communication interface read call + //!P1: Upload position for which the read call failed + static const Event UPLOAD_COM_ERROR = MAKE_EVENT(4, severity::LOW); + + StrImageLoader(object_id_t objectId); virtual ~StrImageLoader(); @@ -22,6 +49,14 @@ public: void setComIF(DeviceCommunicationIF* communicationInterface_); void setComCookie(CookieIF* comCookie_); + /** + * @brief Starts sequence to upload image to star tracker + * + * @param image Name including absolute path if to image to upload. Must be previously + * transferred to the OBC with the CFDP protocoll. + */ + ReturnValue_t startImageUpload(std::string image); + private: static const uint8_t INTERFACE_ID = CLASS_ID::STR_IMG_LOADER; @@ -31,6 +66,9 @@ private: //! [EXPORT] : [COMMENT] Specified file does not exist on filesystem static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xA1); + // Size of one image part which can be sent per action request + static const size_t SIZE_IMAGE_PART = 1024; + enum class InternalState { IDLE, UPLOAD_IMAGE, @@ -39,6 +77,8 @@ private: InternalState internalState = InternalState::IDLE; + ArcsecDatalinkLayer datalinkLayer; + BinarySemaphore semaphore; // Absolute path and name to image to upload @@ -51,6 +91,13 @@ private: * Must be set by star tracker handler */ DeviceCommunicationIF * communicationInterface = nullptr; + // Communication cookie. Must be set by the star tracker handler + CookieIF* comCookie = nullptr; + + /** + * @brief Performs image uploading + */ + ReturnValue_t uploadImage(); }; #endif /* BSP_Q7S_DEVICES_STRIMAGELOADER_H_ */ diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index 19445dc1..610052e4 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -91,7 +91,7 @@ enum commonObjects: uint32_t { PLOC_UPDATER = 0x44330000, PLOC_MEMORY_DUMPER = 0x44330001, - STR_IMG_HELPER = 0x44330002 + STR_IMG_LOADER = 0x44330002 }; } diff --git a/common/config/commonSubsystemIds.h b/common/config/commonSubsystemIds.h index a6a0466d..2bb216a5 100644 --- a/common/config/commonSubsystemIds.h +++ b/common/config/commonSubsystemIds.h @@ -18,7 +18,7 @@ enum: uint8_t { PLOC_UPDATER = 117, PLOC_MEMORY_DUMPER = 118, PDEC_HANDLER = 119, - STR_IMAGE_HELPER = 120, + STR_IMAGE_LOADER = 120, COMMON_SUBSYSTEM_ID_END }; } diff --git a/mission/devices/StarTrackerHandler.cpp b/mission/devices/StarTrackerHandler.cpp index f05dec71..dacb8617 100644 --- a/mission/devices/StarTrackerHandler.cpp +++ b/mission/devices/StarTrackerHandler.cpp @@ -20,17 +20,83 @@ StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, if (strImageLoader == nullptr) { sif::error << "StarTrackerHandler: Invalid str image loader" << std::endl; } + eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5); slipInit(); } StarTrackerHandler::~StarTrackerHandler() { - DeviceHandlerBase::initialize(); +} + +ReturnValue_t StarTrackerHandler::initialize() { + ReturnValue_t result = RETURN_OK; + result = DeviceHandlerBase::initialize(); + if (result != RETURN_OK) { + return result; + } + + EventManagerIF* manager = ObjectManager::instance()->get( + objects::EVENT_MANAGER); + if (manager == nullptr) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::error << "StarTrackerHandler::initialize: Invalid event manager" << std::endl; +#endif + return ObjectManagerIF::CHILD_INIT_FAILED;; + } + result = manager->registerListener(eventQueue->getId()); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = manager->subscribeToAllEventsFrom(eventQueue->getId(), objects::STR_IMG_LOADER); + if (result != RETURN_OK) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::warning << "StarTrackerHandler::initialize: Failed to subscribe to events form image" + " loader" << std::endl; +#endif + return ObjectManagerIF::CHILD_INIT_FAILED; + } + strImageLoader->setComIF(communicationInterface); strImageLoader->setComCookie(comCookie); } -ReturnValue_t StarTrackerHandler::initialize() { +ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) { + if (imageLoaderExecuting == true) { + return IMAGE_LOADER_EXECUTING; + } + // Intercept image loader commands which do not follow the common DHB communication flow + switch(actionId) { + case(StarTracker::UPLOAD_IMAGE): { + strImageLoader->startImageUpload(); + imageLoaderExecuting = true; + return EXECUTION_FINISHED; + } + case(StarTracker::DOWNLOAD_IMAGE): { + strImageLoader->startImageDownload(); + imageLoaderExecuting = true; + return EXECUTION_FINISHED; + } + default: + break; + } + return DeviceHandlerBase::executeAction(); +} + +void StarTrackerHandler::performOperationHook() { + EventMessage event; + for (ReturnValue_t result = eventQueue->receiveMessage(&event); + result == RETURN_OK; result = eventQueue->receiveMessage(&event)) { + switch (event.getMessageId()) { + case EventMessage::EVENT_MESSAGE: + handleEvent(&event); + break; + default: + sif::debug << "CCSDSHandler::checkEvents: Did not subscribe to this event message" + << std::endl; + break; + } + } } void StarTrackerHandler::doStartUp() { @@ -89,7 +155,9 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi return RETURN_OK; } case (StarTracker::UPLOAD_IMAGE): { - result = prepareImageUploadCommand(commandData, commandDataLen); + std::string uploadImage = std::string(reinterpret_cast(commandData), + commandDataLen); + strImageLoader->startImageUpload(uploadImage); return result; } case (StarTracker::REQ_POWER): { @@ -129,8 +197,7 @@ void StarTrackerHandler::fillCommandAndReplyMap() { StarTracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(StarTracker::REQ_TIME, 3, &timeSet, StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::UPLOAD_IMAGE, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandMap(StarTracker::UPLOAD_IMAGE); this->insertInCommandAndReplyMap(StarTracker::REQ_POWER, 3, &powerSet, StarTracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(StarTracker::REQ_INTERFACE, 3, &interfaceSet, @@ -151,52 +218,36 @@ ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t rema ReturnValue_t result = RETURN_OK; uint32_t decodedLength = 0; size_t bytePos = 0; - for (bytePos = 0; bytePos < remainingSize; bytePos++) { - enum arc_dec_result decResult = arc_transport_decode_body(*(start + bytePos), &slipInfo, - decodedFrame, &decodedLength); + size_t bytesLeft = 0; - switch (decResult) { - case ARC_DEC_INPROGRESS: { - if (bytePos == remainingSize - 1) { - // second doSendread() required to read whole packet - return IGNORE_FULL_PACKET; - } - continue; - } - case ARC_DEC_ASYNC: { - sif::debug << "StarTrackerHandler::scanForReply: Received asynchronous tm" << std::endl; - /** No asynchronous replies are expected as of now */ - return RETURN_FAILED; - } - case ARC_DEC_ERROR_FRAME_SHORT: - return REPLY_TOO_SHORT; - case ARC_DEC_ERROR_CHECKSUM: - return CRC_FAILURE; - case ARC_DEC_SYNC: { - /** Reset length of SLIP struct for next frame */ - slipInfo.length = 0; - break; - } - default: - sif::debug << "StarTrackerHandler::scanForReply: Unknown result code" << std::endl; - break; - } + result = dataLinkLayer.decodeFrame(start, remainingSize, &bytesLeft); + remainingSize = *bytesLeft; + switch(result) { + case ArcsecDatalinkLayer::DEC_IN_PROGRESS: { + // Need a second doSendRead pass to reaa in whole packet + return IGNORE_REPLY_DATA; + } + case RETURN_OK: { + break; + } + default: + return result; } - switch (decodedFrame[0]) { + switch (dataLinkLayer.getReplyFrameType()) { case TMTC_ACTIONREPLY: { - *foundLen = bytePos; + *foundLen = remainingsize - bytesLeft; result = scanForActionReply(foundId); break; } case TMTC_SETPARAMREPLY: { - *foundLen = bytePos; + *foundLen = remainingsize - bytesLeft; result = scanForSetParameterReply(foundId); break; } case TMTC_TELEMETRYREPLYA: case TMTC_TELEMETRYREPLY: { - *foundLen = bytePos; + *foundLen = remainingsize - bytesLeft; result = scanForTmReply(foundId); break; } @@ -238,10 +289,6 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con result = handleInterfaceTm(); break; } - case (StarTracker::UPLOAD_IMAGE): { - result = handleUploadImageReply(); - break; - } case (StarTracker::REQ_POWER): { result = handlePowerTm(); break; @@ -352,11 +399,17 @@ ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& l } size_t StarTrackerHandler::getNextReplyLength(DeviceCommandId_t commandId){ + // Prevent DHB from polling UART during upload command. Because UART is used by image loader + // task + if (commandId == StarTracker::UPLOAD_IMAGE) { + return 0; + } return StarTracker::MAX_FRAME_SIZE; } ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t *foundId) { - switch (decodedFrame[1]) { + const uint8_t* reply = dataLinkLayer.getReply(); + switch (*reply) { case (StarTracker::ID::PING): { *foundId = StarTracker::PING_REQUEST; break; @@ -378,7 +431,8 @@ ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t *foundId) } ReturnValue_t StarTrackerHandler::scanForSetParameterReply(DeviceCommandId_t *foundId) { - switch (decodedFrame[1]) { + const uint8_t* reply = dataLinkLayer.getReply(); + switch (*reply) { case (StarTracker::ID::SUBSCRIBE): { *foundId = StarTracker::SUBSCRIBE_TO_TM; break; @@ -392,7 +446,8 @@ ReturnValue_t StarTrackerHandler::scanForSetParameterReply(DeviceCommandId_t *fo } ReturnValue_t StarTrackerHandler::scanForTmReply(DeviceCommandId_t *foundId) { - switch (decodedFrame[1]) { + const uint8_t* reply = dataLinkLayer.getReply(); + switch (*reply) { case (StarTracker::ID::VERSION): { *foundId = StarTracker::REQ_VERSION; break; @@ -418,7 +473,7 @@ ReturnValue_t StarTrackerHandler::scanForTmReply(DeviceCommandId_t *foundId) { break; } default: { - sif::debug << "StarTrackerHandler::scanForReply: Reply contains invalid reply id" + sif::debug << "StarTrackerHandler::scanForTmReply: Reply contains invalid reply id" << std::endl; return RETURN_FAILED; break; @@ -427,31 +482,37 @@ ReturnValue_t StarTrackerHandler::scanForTmReply(DeviceCommandId_t *foundId) { return RETURN_OK; } -void StarTrackerHandler::slipInit() { - slipInfo.buffer = rxBuffer; - slipInfo.maxlength = StarTracker::MAX_FRAME_SIZE; - slipInfo.length = 0; - slipInfo.unescape_next = 0; - slipInfo.prev_state = SLIP_COMPLETE; +void StarTrackerHandler::handleEvent(EventMessage* eventMessage) { + object_id_t objectId = eventMessage->getReporter(); + switch(objectId){ + case objects::STR_IMG_LOADER: { + // All events from image loader signal either that the operation was successful or that it + // failed + imageLoaderExecuting = false; + break; + } + default: + sif::debug << "StarTrackerHandler::handleEvent: Did not subscribe to this event" + << std::endl; + break; + } } void StarTrackerHandler::prepareBootCommand() { uint32_t length = 0; struct BootActionRequest bootRequest = {BOOT_REGION_ID}; arc_pack_boot_action_req(&bootRequest, commandBuffer, &length); - uint32_t encLength = 0; - arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength); - rawPacket = encBuffer; - rawPacketLen = encLength; + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareTimeRequest() { uint32_t length = 0; arc_tm_pack_time_req(commandBuffer, &length); - uint32_t encLength = 0; - arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength); - rawPacket = encBuffer; - rawPacketLen = encLength; + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::preparePingRequest() { @@ -467,64 +528,37 @@ void StarTrackerHandler::preparePingRequest() { void StarTrackerHandler::prepareVersionRequest() { uint32_t length = 0; arc_tm_pack_version_req(commandBuffer, &length); - uint32_t encLength = 0; - arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength); - rawPacket = encBuffer; - rawPacketLen = encLength; + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareInterfaceRequest() { uint32_t length = 0; arc_tm_pack_interface_req(commandBuffer, &length); - uint32_t encLength = 0; - arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength); - rawPacket = encBuffer; - rawPacketLen = encLength; -} - -ReturnValue_t StarTrackerHandler::prepareImageUploadCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen != UPLOAD_COMMAND_LEN) { - return INVALID_UPLOAD_COMMAND; - } - uint32_t length = 0; - uint32_t position = deserializeUint32(commandData); - if (position > MAX_POSITION) { - return MAX_POSITION; - } - rememberUploadPosition = position; - struct UploadActionRequest uploadRequest; - uploadRequest.position = position; - std::memcpy(uploadRequest.data, commandData + 4, commandDataLen - 4); - arc_pack_upload_action_req(&uploadRequest, commandBuffer, &length); - uint32_t encLength = 0; - arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength); - rawPacket = encBuffer; - rawPacketLen = encLength; - return RETURN_OK; + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::preparePowerRequest() { uint32_t length = 0; arc_tm_pack_power_req(commandBuffer, &length); - uint32_t encLength = 0; - arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength); - rawPacket = encBuffer; - rawPacketLen = encLength; + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareRebootCommand() { uint32_t length = 0; struct RebootActionRequest rebootReq; arc_pack_reboot_action_req(&rebootReq, commandBuffer, &length); - uint32_t encLength = 0; - arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength); - rawPacket = encBuffer; - rawPacketLen = encLength; + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareSubscriptionCommand(const uint8_t* tmId) { - uint32_t encLength = 0; uint32_t length = 18; commandBuffer[0] = TMTC_SETPARAMREQ; commandBuffer[1] = StarTracker::ID::SUBSCRIBE; @@ -545,9 +579,9 @@ void StarTrackerHandler::prepareSubscriptionCommand(const uint8_t* tmId) { commandBuffer[15] = 0; commandBuffer[16] = 0; commandBuffer[17] = 0; - arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength); - rawPacket = encBuffer; - rawPacketLen = encLength; + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareSolutionRequest() { @@ -562,29 +596,30 @@ void StarTrackerHandler::prepareSolutionRequest() { void StarTrackerHandler::prepareTemperatureRequest() { uint32_t length = 0; arc_tm_pack_temperature_req(commandBuffer, &length); - uint32_t encLength = 0; - arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength); - rawPacket = encBuffer; - rawPacketLen = encLength; + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } ReturnValue_t StarTrackerHandler::handleSetParamReply() { - uint8_t status = *(decodedFrame + STATUS_OFFSET); + const uint8_t* reply = dataLinkLayer.getReply(); + uint8_t status = *(reply + STATUS_OFFSET); if (status != StarTracker::STATUS_OK) { sif::warning << "StarTrackerHandler::handleSetParamReply: Failed to execute parameter set " " command with parameter ID" << - static_cast(*(decodedFrame + PARAMETER_ID_OFFSET)) << std::endl; + static_cast(*(reply + PARAMETER_ID_OFFSET)) << std::endl; return SET_PARAM_FAILED; } return RETURN_OK; } ReturnValue_t StarTrackerHandler::handleActionReply() { - uint8_t status = *(decodedFrame + STATUS_OFFSET); + const uint8_t* reply = dataLinkLayer.getReply(); + uint8_t status = *(reply + STATUS_OFFSET); if (status != StarTracker::STATUS_OK) { sif::warning << "StarTrackerHandler::handleActionReply: Failed to execute action " << " command with action ID " - << static_cast(*(decodedFrame + ACTION_ID_OFFSET)) + << static_cast(*(reply + ACTION_ID_OFFSET)) << " and status "<< static_cast(status) << std::endl; return ACTION_FAILED; } @@ -594,8 +629,9 @@ ReturnValue_t StarTrackerHandler::handleActionReply() { ReturnValue_t StarTrackerHandler::handlePingReply() { ReturnValue_t result = RETURN_OK; uint32_t pingId = 0; - uint8_t status = *(decodedFrame + 2); - const uint8_t* buffer = decodedFrame + 3; + const uint8_t* reply = dataLinkLayer.getReply(); + uint8_t status = *(reply + 2); + const uint8_t* buffer = reply + 3; size_t size = sizeof(pingId); SerializeAdapter::deSerialize(&pingId, &buffer, &size, SerializeIF::Endianness::LITTLE); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 @@ -609,22 +645,6 @@ ReturnValue_t StarTrackerHandler::handlePingReply() { return result; } -ReturnValue_t StarTrackerHandler::handleUploadImageReply() { - ReturnValue_t result = RETURN_OK; - result = handleActionReply(); - if (result != RETURN_OK) { - return result; - } - // Position seems to be always 0 (independent of sent position) -// uint32_t position = deserializeUint32(decodedFrame + ACTION_DATA_OFFSET); -// if (position != rememberUploadPosition) { -// sif::warning << "StarTrackerHandler::handleUploadImageReply: Invalid position" -// << std::endl; -// return UPLOAD_IMAGE_FAILED; -// } - return result; -} - ReturnValue_t StarTrackerHandler::handleTimeTm() { ReturnValue_t result = RETURN_OK; result = timeSet.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); @@ -642,11 +662,12 @@ ReturnValue_t StarTrackerHandler::handleTimeTm() { result = VERSION_REQ_FAILED; return result; } + const uint8_t* reply = dataLinkLayer.getReply(); timeSet.ticks = ticks; timeSet.time = time; - timeSet.runTime = deserializeUint32(decodedFrame + offset); + timeSet.runTime = deserializeUint32(reply + offset); offset += sizeof(uint32_t); - timeSet.unixTime = deserializeUint64(decodedFrame + offset); + timeSet.unixTime = deserializeUint64(reply + offset); result = timeSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); if (result != RETURN_OK) { return result; @@ -674,13 +695,14 @@ ReturnValue_t StarTrackerHandler::handleVersionTm() { if (result != RETURN_OK) { return result; } + const uint8_t* reply = dataLinkLayer.getReply(); versionSet.ticks = ticks; versionSet.time = time; - versionSet.program = *(decodedFrame + offset); + versionSet.program = *(reply + offset); offset += 1; - versionSet.major = *(decodedFrame + offset); + versionSet.major = *(reply + offset); offset += 1; - versionSet.minor = *(decodedFrame + offset); + versionSet.minor = *(reply + offset); result = versionSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); if (result != RETURN_OK) { return result; @@ -708,12 +730,13 @@ ReturnValue_t StarTrackerHandler::handleInterfaceTm() { if (result != RETURN_OK) { return result; } + const uint8_t* reply = dataLinkLayer.getReply(); interfaceSet.ticks = ticks; interfaceSet.time = time; size_t size = sizeof(uint32_t); - interfaceSet.frameCount = deserializeUint32(decodedFrame + offset); + interfaceSet.frameCount = deserializeUint32(reply + offset); offset += size; - interfaceSet.checksumerrorCount = deserializeUint32(decodedFrame + offset); + interfaceSet.checksumerrorCount = deserializeUint32(reply + offset); result = interfaceSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); if (result != RETURN_OK) { return result; @@ -741,55 +764,56 @@ ReturnValue_t StarTrackerHandler::handlePowerTm() { if (result != RETURN_OK) { return result; } + const uint8_t* reply = dataLinkLayer.getReply(); powerSet.ticks= ticks; powerSet.time= time; float value = 0; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.mcuCurrent = value; offset += 4; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.mcuVoltage = value; offset += 4; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.fpgaCoreCurrent = value; offset += 4; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.fpgaCoreVoltage = value; offset += 4; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.fpga18Current = value; offset += 4; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.fpga18Voltage = value; offset += 4; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.fpga25Current = value; offset += 4; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.fpga25Voltage = value; offset += 4; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.cmv21Current = value; offset += 4; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.cmv21Voltage = value; offset += 4; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.cmvPixCurrent= value; offset += 4; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.cmvPixVoltage = value; offset += 4; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.cmv33Current= value; offset += 4; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.cmv33Voltage = value; offset += 4; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.cmvResCurrent= value; offset += 4; - std::memcpy(&value, decodedFrame + offset, sizeof(value)); + std::memcpy(&value, reply + offset, sizeof(value)); powerSet.cmvResVoltage = value; result = powerSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); if (result != RETURN_OK) { @@ -818,64 +842,65 @@ ReturnValue_t StarTrackerHandler::handleSolutionTm() { result = TEMPERATURE_REQ_FAILED; return result; } + const uint8_t* reply = dataLinkLayer.getReply(); solutionSet.ticks= ticks; solutionSet.time= time; float word = 0; - std::memcpy(&word, decodedFrame + offset, sizeof(float)); + std::memcpy(&word, reply + offset, sizeof(float)); solutionSet.caliQw = word; offset += sizeof(float); - std::memcpy(&word, decodedFrame + offset, sizeof(float)); + std::memcpy(&word, reply + offset, sizeof(float)); solutionSet.caliQx = word; offset += sizeof(float); - std::memcpy(&word, decodedFrame + offset, sizeof(float)); + std::memcpy(&word, reply + offset, sizeof(float)); solutionSet.caliQy = word; offset += sizeof(float); - std::memcpy(&word, decodedFrame + offset, sizeof(float)); + std::memcpy(&word, reply + offset, sizeof(float)); solutionSet.caliQz = word; offset += sizeof(float); - std::memcpy(&word, decodedFrame + offset, sizeof(float)); + std::memcpy(&word, reply + offset, sizeof(float)); solutionSet.trackConfidence = word; offset += sizeof(float); - std::memcpy(&word, decodedFrame + offset, sizeof(float)); + std::memcpy(&word, reply + offset, sizeof(float)); solutionSet.trackQw = word; offset += sizeof(float); - std::memcpy(&word, decodedFrame + offset, sizeof(float)); + std::memcpy(&word, reply + offset, sizeof(float)); solutionSet.trackQx = word; offset += sizeof(float); - std::memcpy(&word, decodedFrame + offset, sizeof(float)); + std::memcpy(&word, reply + offset, sizeof(float)); solutionSet.trackQy = word; offset += sizeof(float); - std::memcpy(&word, decodedFrame + offset, sizeof(float)); + std::memcpy(&word, reply + offset, sizeof(float)); solutionSet.trackQz = word; offset += sizeof(float); - solutionSet.trackRemoved = *(decodedFrame + offset); + solutionSet.trackRemoved = *(reply + offset); offset += sizeof(uint8_t); - solutionSet.starsCentroided = *(decodedFrame + offset); + solutionSet.starsCentroided = *(reply + offset); offset += sizeof(uint8_t); - solutionSet.starsMatchedDatabase = *(decodedFrame + offset); + solutionSet.starsMatchedDatabase = *(reply + offset); offset += sizeof(float); - std::memcpy(&word, decodedFrame + offset, sizeof(float)); + std::memcpy(&word, reply + offset, sizeof(float)); solutionSet.lisaQw = word; offset += sizeof(float); - std::memcpy(&word, decodedFrame + offset, sizeof(float)); + std::memcpy(&word, reply + offset, sizeof(float)); solutionSet.lisaQx = word; offset += sizeof(float); - std::memcpy(&word, decodedFrame + offset, sizeof(float)); + std::memcpy(&word, reply + offset, sizeof(float)); solutionSet.lisaQy = word; offset += sizeof(float); - std::memcpy(&word, decodedFrame + offset, sizeof(float)); + std::memcpy(&word, reply + offset, sizeof(float)); solutionSet.lisaQz = word; offset += sizeof(float); - std::memcpy(&word, decodedFrame + offset, sizeof(float)); + std::memcpy(&word, reply + offset, sizeof(float)); solutionSet.lisaPercentageClose = word; offset += sizeof(float); - solutionSet.lisaNrClose = *(decodedFrame + offset); + solutionSet.lisaNrClose = *(reply + offset); offset += sizeof(uint8_t); - solutionSet.isTrustWorthy = *(decodedFrame + offset); + solutionSet.isTrustWorthy = *(reply + offset); offset += sizeof(uint8_t); - solutionSet.stableCount = *(decodedFrame + offset); + solutionSet.stableCount = *(reply + offset); offset += sizeof(uint32_t); - solutionSet.stableCount = *(decodedFrame + offset); + solutionSet.stableCount = *(reply + offset); result = solutionSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); if (result != RETURN_OK) { return result; @@ -903,13 +928,14 @@ ReturnValue_t StarTrackerHandler::handleTemperatureTm() { if (result != RETURN_OK) { return result; } + const uint8_t* reply = dataLinkLayer.getReply(); temperatureSet.ticks= ticks; temperatureSet.time= time; float temperature = 0; - std::memcpy(&temperature, decodedFrame + offset, sizeof(temperature)); + std::memcpy(&temperature, reply + offset, sizeof(temperature)); temperatureSet.mcuTemperature = temperature; offset += sizeof(float); - std::memcpy(&temperature, decodedFrame + offset, sizeof(temperature)); + std::memcpy(&temperature, reply + offset, sizeof(temperature)); temperatureSet.cmosTemperature = temperature; result = temperatureSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); if (result != RETURN_OK) { @@ -922,9 +948,10 @@ ReturnValue_t StarTrackerHandler::handleTemperatureTm() { } void StarTrackerHandler::getTmHeaderData(uint8_t* status, uint32_t* ticks, uint64_t* time) { - *status = *(decodedFrame + STATUS_OFFSET); - *ticks = deserializeUint32(decodedFrame + TICKS_OFFSET); - *time = deserializeUint64(decodedFrame + TIME_OFFSET); + const uint8_t* reply = dataLinkLayer.getReply(); + *status = *(reply + STATUS_OFFSET); + *ticks = deserializeUint32(reply + TICKS_OFFSET); + *time = deserializeUint64(reply + TIME_OFFSET); } uint32_t StarTrackerHandler::deserializeUint32(const uint8_t* buffer) { diff --git a/mission/devices/StarTrackerHandler.h b/mission/devices/StarTrackerHandler.h index d74d6fd2..e8aef15a 100644 --- a/mission/devices/StarTrackerHandler.h +++ b/mission/devices/StarTrackerHandler.h @@ -7,6 +7,8 @@ #include #include #include +#include +#include /** * @brief This is the device handler for the star tracker from arcsec. @@ -35,6 +37,15 @@ public: ReturnValue_t initialize() override; + /** + * @brief Overwrite this function from DHB to handle commands executed by the str image + * loader task. + */ + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) override; + + void performOperationHook() override; + protected: void doStartUp() override; void doShutDown() override; @@ -64,7 +75,9 @@ private: //! [EXPORT] : [COMMENT] Received reply is too short static const ReturnValue_t REPLY_TOO_SHORT = MAKE_RETURN_CODE(0xB0); //! [EXPORT] : [COMMENT] Received reply with invalid CRC - static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xB0); + static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xB1); + //! [EXPORT] : [COMMENT] Image loader executing + static const ReturnValue_t IMAGE_LOADER_EXECUTING = MAKE_RETURN_CODE(0xB2); static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_HANDLER; @@ -95,13 +108,13 @@ private: static const size_t UPLOAD_COMMAND_LEN = 1028; // Max valid position value in upload image command static const uint16_t MAX_POSITION= 4095; - static const uint8_t STATUS_OFFSET = 2; - static const uint8_t TICKS_OFFSET = 3; - static const uint8_t TIME_OFFSET = 7; - static const uint8_t TM_DATA_FIELD_OFFSET = 15; - static const uint8_t PARAMETER_ID_OFFSET = 1; - static const uint8_t ACTION_ID_OFFSET = 1; - static const uint8_t ACTION_DATA_OFFSET = 3; + static const uint8_t STATUS_OFFSET = 1; + static const uint8_t TICKS_OFFSET = 2; + static const uint8_t TIME_OFFSET = 6; + static const uint8_t TM_DATA_FIELD_OFFSET = 14; + static const uint8_t PARAMETER_ID_OFFSET = 0; + static const uint8_t ACTION_ID_OFFSET = 0; + static const uint8_t ACTION_DATA_OFFSET = 2; // Ping request will reply ping with this ID (data field) static const uint32_t PING_ID = 0x55; @@ -113,6 +126,10 @@ private: // Pointer to object responsible for uploading and downloading images to/from the star tracker StrImageLoader* strImageLoader = nullptr; + MessageQueueIF* eventQueue = nullptr; + + ArcsecDatalinkLayer dataLinkLayer; + StarTracker::TemperatureSet temperatureSet; StarTracker::VersionSet versionSet; StarTracker::PowerSet powerSet; @@ -121,13 +138,6 @@ private: StarTracker::SolutionSet solutionSet; uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE]; - uint8_t rxBuffer[StarTracker::MAX_FRAME_SIZE]; - uint8_t decodedFrame[StarTracker::MAX_FRAME_SIZE]; - - /** Size of buffer derived from the egse source code */ - uint8_t encBuffer[StarTracker::MAX_FRAME_SIZE * 2 + 2]; - - slip_decode_state slipInfo; enum class InternalState { TEMPERATURE_REQUEST @@ -135,7 +145,7 @@ private: InternalState internalState = InternalState::TEMPERATURE_REQUEST; - uint32_t rememberUploadPosition = 0; + bool imageLoaderExecuting = false; /** * @brief This function initializes the serial link ip protocol struct slipInfo. @@ -172,11 +182,6 @@ private: */ void prepareInterfaceRequest(); - /** - * @brief Fills the command buffer with data to upload part of an image. - */ - ReturnValue_t prepareImageUploadCommand(const uint8_t* commandData, size_t commandDataLen); - /** * @brief Fills the command buffer with data to request the power telemetry packet. */ @@ -217,11 +222,6 @@ private: ReturnValue_t handlePingReply(); - /** - * @brief Handles reply to upload image command - */ - ReturnValue_t handleUploadImageReply(); - /** * @brief Fills the time set with the data of the time request reply. */ diff --git a/mission/devices/devicedefinitions/StarTrackerDefinitions.h b/mission/devices/devicedefinitions/StarTrackerDefinitions.h index ef9182ff..4721957b 100644 --- a/mission/devices/devicedefinitions/StarTrackerDefinitions.h +++ b/mission/devices/devicedefinitions/StarTrackerDefinitions.h @@ -91,6 +91,7 @@ static const DeviceCommandId_t REQ_VERSION = 2; static const DeviceCommandId_t REQ_INTERFACE = 3; static const DeviceCommandId_t REQ_TIME = 4; static const DeviceCommandId_t REBOOT = 7; +static const DeviceCommandId_t DOWNLOAD_IMAGE = 9; static const DeviceCommandId_t UPLOAD_IMAGE = 10; static const DeviceCommandId_t REQ_POWER = 11; static const DeviceCommandId_t SUBSCRIBE_TO_TM = 18; diff --git a/mission/tmtc/CCSDSHandler.cpp b/mission/tmtc/CCSDSHandler.cpp index e0239d9a..524fe4b8 100644 --- a/mission/tmtc/CCSDSHandler.cpp +++ b/mission/tmtc/CCSDSHandler.cpp @@ -80,15 +80,19 @@ ReturnValue_t CCSDSHandler::initialize() { EventManagerIF* manager = ObjectManager::instance()->get( objects::EVENT_MANAGER); - if (manager == nullptr) { + if (manager == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "CCSDSHandler::initialize: Invalid event manager" << std::endl; #endif - return RETURN_FAILED; + return ObjectManagerIF::CHILD_INIT_FAILED; } result = manager->registerListener(eventQueue->getId()); if (result != HasReturnvaluesIF::RETURN_OK) { - return result; +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::warning << "CCSDSHandler::initialize: Failed to register CCSDS handler as event " + "listener" << std::endl; +#endif + return ObjectManagerIF::CHILD_INIT_FAILED;; } result = manager->subscribeToEventRange(eventQueue->getId(), event::getEventId(PdecHandler::CARRIER_LOCK), diff --git a/tmtc b/tmtc index 1d374230..dedb2849 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 1d374230b34606d8b6aa4df1335befec316a1e35 +Subproject commit dedb28497f62314498034cd87d1e2a4361b92950 From 7cc0fc640faec86af7f89319ded8b04c72f31844 Mon Sep 17 00:00:00 2001 From: Markus Koller Date: Thu, 2 Dec 2021 11:51:22 +0100 Subject: [PATCH 117/465] pdec monitor register --- linux/obc/PdecHandler.cpp | 40 ++++++++++++++++++++++++++ linux/obc/PdecHandler.h | 59 +++++++++++++++++++++++++++++++-------- tmtc | 2 +- 3 files changed, 89 insertions(+), 12 deletions(-) diff --git a/linux/obc/PdecHandler.cpp b/linux/obc/PdecHandler.cpp index 1ac83d44..829377d0 100644 --- a/linux/obc/PdecHandler.cpp +++ b/linux/obc/PdecHandler.cpp @@ -484,6 +484,10 @@ uint32_t PdecHandler::getClcw() { return *(registerBaseAddress + PDEC_CLCW_OFFSET); } +uint32_t PdecHandler::getPdecMon() { + return *(registerBaseAddress + PDEC_MON_OFFSET); +} + void PdecHandler::printClcw() { uint32_t clcw = getClcw(); uint8_t type = static_cast((clcw >> 31) & 0x1); @@ -525,6 +529,39 @@ void PdecHandler::printClcw() { << "0x" << static_cast(repValue) << std::endl; } +void PdecHandler::printPdecMon() { + uint32_t pdecMon = getPdecMon(); + uint32_t tc0ChannelStatus = (pdecMon & TC0_STATUS_MASK) >> TC0_STATUS_POS; + uint32_t tc1ChannelStatus = (pdecMon & TC1_STATUS_MASK) >> TC1_STATUS_POS; + uint32_t tc2ChannelStatus = (pdecMon & TC2_STATUS_MASK) >> TC2_STATUS_POS; + uint32_t tc3ChannelStatus = (pdecMon & TC3_STATUS_MASK) >> TC3_STATUS_POS; + uint32_t tc4ChannelStatus = (pdecMon & TC4_STATUS_MASK) >> TC4_STATUS_POS; + uint32_t tc5ChannelStatus = (pdecMon & TC5_STATUS_MASK) >> TC5_STATUS_POS; + uint32_t lock = (pdecMon & LOCK_MASK) >> LOCK_POS; + sif::info << std::setw(30) << std::left << "TC0 status: " << getMonStatusString(tc0ChannelStatus) << std::endl; + sif::info << std::setw(30) << std::left << "TC1 status: " << getMonStatusString(tc1ChannelStatus) << std::endl; + sif::info << std::setw(30) << std::left << "TC2 status: " << getMonStatusString(tc2ChannelStatus) << std::endl; + sif::info << std::setw(30) << std::left << "TC3 status: " << getMonStatusString(tc3ChannelStatus) << std::endl; + sif::info << std::setw(30) << std::left << "TC4 status: " << getMonStatusString(tc4ChannelStatus) << std::endl; + sif::info << std::setw(30) << std::left << "TC5 status: " << getMonStatusString(tc5ChannelStatus) << std::endl; + sif::info << std::setw(30) << std::left << "Start sequence lock: " << lock << std::endl; +} + +std::string PdecHandler::getMonStatusString(uint32_t status) { + switch(status) { + case TC_CHANNEL_INACTIVE: + return std::string("inactive"); + case TC_CHANNEL_ACTIVE: + return std::string("active"); + case TC_CHANNEL_TIMEDOUT: + return std::string("timed out"); + default: + sif::warning << "PdecHandler::getMonStatusString: Invalid status" << std::endl; + return std::string(); + break; + } +} + ReturnValue_t PdecHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { @@ -532,6 +569,9 @@ ReturnValue_t PdecHandler::executeAction(ActionId_t actionId, case PRINT_CLCW: printClcw(); return EXECUTION_FINISHED; + case PRINT_PDEC_MON: + printPdecMon(); + return EXECUTION_FINISHED; default: return COMMAND_NOT_IMPLEMENTED; } diff --git a/linux/obc/PdecHandler.h b/linux/obc/PdecHandler.h index 8819df22..8c8e8d9b 100644 --- a/linux/obc/PdecHandler.h +++ b/linux/obc/PdecHandler.h @@ -61,16 +61,6 @@ public: ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, const uint8_t* data, size_t size) override; - /** - * brief Returns the 32-bit wide communication link control word (CLCW) - */ - uint32_t getClcw(); - - /** - * @rief Reads and prints the CLCW. Can be useful for debugging. - */ - void printClcw(); - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PDEC_HANDLER; //! [EXPORT] : [COMMENT] Frame acceptance report signals an invalid frame @@ -119,6 +109,8 @@ private: // Action IDs static const ActionId_t PRINT_CLCW = 0; + // Print PDEC monitor register + static const ActionId_t PRINT_PDEC_MON = 1; static const uint8_t STAT_POSITION = 31; static const uint8_t FRAME_ANA_POSITION = 28; @@ -129,6 +121,28 @@ private: static const uint32_t FRAME_ANA_MASK = 0x70000000; static const uint32_t IREASON_MASK = 0x0E000000; + static const uint32_t TC_CHANNEL_INACTIVE = 0x0; + static const uint32_t TC_CHANNEL_ACTIVE = 0x1; + static const uint32_t TC_CHANNEL_TIMEDOUT = 0x2; + + static const uint32_t TC0_STATUS_MASK = 0x3; + static const uint32_t TC1_STATUS_MASK = 0xC; + static const uint32_t TC2_STATUS_MASK = 0x300; + static const uint32_t TC3_STATUS_MASK = 0xC00; + static const uint32_t TC4_STATUS_MASK = 0x30000; + static const uint32_t TC5_STATUS_MASK = 0xc00000; + // Lock register set to 1 when start sequence has been found (CLTU is beeing processed) + static const uint32_t LOCK_MASK = 0xc00000; + + static const uint32_t TC0_STATUS_POS = 0; + static const uint32_t TC1_STATUS_POS = 2; + static const uint32_t TC2_STATUS_POS = 4; + static const uint32_t TC3_STATUS_POS = 6; + static const uint32_t TC4_STATUS_POS = 8; + static const uint32_t TC5_STATUS_POS = 10; + // Lock register set to 1 when start sequence has been found (CLTU is beeing processed) + static const uint32_t LOCK_POS = 12; + /** * UIO is 4 byte aligned. Thus offset is calculated with "true offset" / 4 * Example: PDEC_FAR = 0x2840 => Offset in virtual address space is 0xA10 @@ -138,7 +152,7 @@ private: static const uint32_t PDEC_BFREE_OFFSET = 0xA24; static const uint32_t PDEC_BPTR_OFFSET = 0xA25; static const uint32_t PDEC_SLEN_OFFSET = 0xA26; - static const uint32_t PDEC_MON = 0xA27; + static const uint32_t PDEC_MON_OFFSET = 0xA27; #if BOARD_TE0720 == 1 static const int CONFIG_MEMORY_MAP_SIZE = 0x400; @@ -330,6 +344,29 @@ private: */ uint8_t getOddParity(uint8_t number); + /** + * brief Returns the 32-bit wide communication link control word (CLCW) + */ + uint32_t getClcw(); + + /** + * @brief Returns the PDEC monitor register content + * + */ + uint32_t getPdecMon(); + + /** + * @brief Reads and prints the CLCW. Can be useful for debugging. + */ + void printClcw(); + + /** + * @brief Prints monitor register information to debug console. + */ + void printPdecMon(); + + std::string getMonStatusString(uint32_t status); + object_id_t tcDestinationId; AcceptsTelecommandsIF* tcDestination = nullptr; diff --git a/tmtc b/tmtc index 1d374230..bcec5df6 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 1d374230b34606d8b6aa4df1335befec316a1e35 +Subproject commit bcec5df6e2636e3751f7a7eb103b893dc4581c10 From fac6996a15106aa2930457ab20900dba5d0c7635 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 6 Dec 2021 19:36:21 +0100 Subject: [PATCH 118/465] star tracker limits setting --- bsp_q7s/core/InitMission.cpp | 8 + bsp_q7s/core/ObjectFactory.cpp | 15 +- bsp_q7s/devices/ArcsecDatalinkLayer.cpp | 16 +- bsp_q7s/devices/ArcsecDatalinkLayer.h | 20 +- bsp_q7s/devices/CMakeLists.txt | 4 +- .../devices/StarTrackerHandler.cpp | 119 +++++- .../devices/StarTrackerHandler.h | 30 +- bsp_q7s/devices/StarTrackerImageHelper.cpp | 311 ---------------- bsp_q7s/devices/StarTrackerImageHelper.h | 153 -------- bsp_q7s/devices/StrImageLoader.cpp | 185 ++++++---- bsp_q7s/devices/StrImageLoader.h | 56 ++- .../StarTrackerDefinitions.h | 32 +- .../StarTrackerJsonCommands.h | 343 ++++++++++++++++++ bsp_q7s/memory/SdCardManager.cpp | 4 +- common/config/commonClassIds.h | 3 +- common/config/commonObjects.h | 2 +- generators/bsp_q7s_events.csv | 250 +++++++------ generators/bsp_q7s_objects.csv | 3 +- generators/events/translateEvents.cpp | 34 +- generators/objects/translateObjects.cpp | 11 +- linux/fsfwconfig/events/translateEvents.cpp | 34 +- linux/fsfwconfig/objects/translateObjects.cpp | 11 +- .../pollingSequenceFactory.cpp | 11 +- linux/obc/PdecHandler.cpp | 24 +- mission/devices/CMakeLists.txt | 1 - tmtc | 2 +- 26 files changed, 949 insertions(+), 733 deletions(-) rename {mission => bsp_q7s}/devices/StarTrackerHandler.cpp (90%) rename {mission => bsp_q7s}/devices/StarTrackerHandler.h (92%) delete mode 100644 bsp_q7s/devices/StarTrackerImageHelper.cpp delete mode 100644 bsp_q7s/devices/StarTrackerImageHelper.h rename {mission => bsp_q7s}/devices/devicedefinitions/StarTrackerDefinitions.h (93%) create mode 100644 bsp_q7s/devices/devicedefinitions/StarTrackerJsonCommands.h diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index 7923a2cd..9e293969 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -126,6 +126,13 @@ void initmission::initTasks() { if(result != HasReturnvaluesIF::RETURN_OK) { initmission::printAddObjectError("FILE_SYSTEM_TASK", objects::FILE_SYSTEM_HANDLER); } + + PeriodicTaskIF* strImgLoaderTask = factory->createPeriodicTask( + "FILE_SYSTEM_TASK", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + result = strImgLoaderTask->addComponent(objects::STR_IMG_LOADER); + if(result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("FILE_SYSTEM_TASK", objects::STR_IMG_LOADER); + } #endif /* BOARD_TE0720 */ #if OBSW_TEST_CCSDS_BRIDGE == 1 @@ -187,6 +194,7 @@ void initmission::initTasks() { #if BOARD_TE0720 == 0 fsTask->startTask(); + strImgLoaderTask->startTask(); #endif sif::info << "Tasks started.." << std::endl; diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 44e4484b..f1d0dcf0 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -1,5 +1,7 @@ #include #include "ObjectFactory.h" + +#include "../devices/devicedefinitions/StarTrackerDefinitions.h" #include "OBSWConfig.h" #include "devConf.h" #include "ccsdsConfig.h" @@ -16,7 +18,8 @@ #include "bsp_q7s/devices/PlocSupervisorHandler.h" #include "bsp_q7s/devices/PlocUpdater.h" #include "bsp_q7s/devices/PlocMemoryDumper.h" -#include "bsp_q7s/devices/StarTrackerImageHelper.h" +#include "bsp_q7s/devices/StrImageLoader.h" +#include "bsp_q7s/devices/StarTrackerHandler.h" #include "bsp_q7s/callbacks/rwSpiCallback.h" #include "bsp_q7s/callbacks/gnssCallback.h" @@ -40,14 +43,12 @@ #include "mission/devices/PlocMPSoCHandler.h" #include "mission/devices/RadiationSensorHandler.h" #include "mission/devices/RwHandler.h" -#include "mission/devices/StarTrackerHandler.h" #include "mission/devices/devicedefinitions/GomspaceDefinitions.h" #include "mission/devices/devicedefinitions/SyrlinksDefinitions.h" #include "mission/devices/devicedefinitions/PlocMPSoCDefinitions.h" #include "mission/devices/devicedefinitions/RadSensorDefinitions.h" #include "mission/devices/devicedefinitions/Max31865Definitions.h" #include "mission/devices/devicedefinitions/RwDefinitions.h" -#include "mission/devices/devicedefinitions/StarTrackerDefinitions.h" #include "mission/devices/GPSHyperionHandler.h" #include "mission/tmtc/CCSDSHandler.h" #include "mission/tmtc/VirtualChannel.h" @@ -168,13 +169,15 @@ void ObjectFactory::produce(void* args) { new FileSystemHandler(objects::FILE_SYSTEM_HANDLER); #if OBSW_ADD_STAR_TRACKER == 1 - UartCookie* starTrackerCookie = new UartCookie(objects::START_TRACKER, + UartCookie* starTrackerCookie = new UartCookie(objects::STAR_TRACKER, q7s::UART_STAR_TRACKER_DEV, UartModes::NON_CANONICAL, uart::STAR_TRACKER_BAUD, StarTracker::MAX_FRAME_SIZE* 2 + 2); starTrackerCookie->setNoFixedSizeReply(); - StarTrackerHandler* starTrackerHandler = new StarTrackerHandler(objects::START_TRACKER, objects::UART_COM_IF, starTrackerCookie); + StrImageLoader* strImageLoader = new StrImageLoader(objects::STR_IMG_LOADER); + StarTrackerHandler* starTrackerHandler = new StarTrackerHandler(objects::STAR_TRACKER, + objects::UART_COM_IF, starTrackerCookie, strImageLoader); starTrackerHandler->setStartUpImmediately(); - new StarTrackerImageHelper(objects::STR_IMG_HELPER); + #endif /* OBSW_ADD_STAR_TRACKER == 1 */ #endif /* TE7020 == 0 */ diff --git a/bsp_q7s/devices/ArcsecDatalinkLayer.cpp b/bsp_q7s/devices/ArcsecDatalinkLayer.cpp index 1f436636..4e7c9458 100644 --- a/bsp_q7s/devices/ArcsecDatalinkLayer.cpp +++ b/bsp_q7s/devices/ArcsecDatalinkLayer.cpp @@ -21,7 +21,7 @@ ReturnValue_t ArcsecDatalinkLayer::decodeFrame(const uint8_t* rawData, size_t ra for (bytePos = 0; bytePos < rawDataSize; bytePos++) { enum arc_dec_result decResult = arc_transport_decode_body(*(rawData + bytePos), &slipInfo, decodedFrame, &decFrameSize); - *bytesLeft = rawDataSize - bytePos; + *bytesLeft = rawDataSize - bytePos - 1; switch (decResult) { case ARC_DEC_INPROGRESS: { if (bytePos == rawDataSize - 1) { @@ -37,13 +37,15 @@ ReturnValue_t ArcsecDatalinkLayer::decodeFrame(const uint8_t* rawData, size_t ra case ARC_DEC_SYNC: { // Reset length of SLIP struct for next frame slipInfo.length = 0; - RETURN_OK; + return RETURN_OK; } default: sif::debug << "ArcsecDatalinkLayer::decodeFrame: Unknown result code" << std::endl; break; + return RETURN_FAILED; } } + return RETURN_FAILED; } uint8_t ArcsecDatalinkLayer::getReplyFrameType() { @@ -55,7 +57,7 @@ const uint8_t* ArcsecDatalinkLayer::getReply() { } void ArcsecDatalinkLayer::encodeFrame(const uint8_t* data, uint32_t length) { - arc_transport_encode_body(commandBuffer, length, encBuffer, &encFrameSize); + arc_transport_encode_body(data, length, encBuffer, &encFrameSize); } uint8_t* ArcsecDatalinkLayer::getEncodedFrame() { @@ -66,3 +68,11 @@ uint32_t ArcsecDatalinkLayer::getEncodedLength() { return encFrameSize; } +uint8_t ArcsecDatalinkLayer::getStatusField() { + return *(decodedFrame + STATUS_OFFSET); +} + +uint8_t ArcsecDatalinkLayer::getId() { + return *(decodedFrame + ID_OFFSET); +} + diff --git a/bsp_q7s/devices/ArcsecDatalinkLayer.h b/bsp_q7s/devices/ArcsecDatalinkLayer.h index bce1f619..58acd4b3 100644 --- a/bsp_q7s/devices/ArcsecDatalinkLayer.h +++ b/bsp_q7s/devices/ArcsecDatalinkLayer.h @@ -1,7 +1,7 @@ #ifndef BSP_Q7S_DEVICES_ARCSECDATALINKLAYER_H_ #define BSP_Q7S_DEVICES_ARCSECDATALINKLAYER_H_ -#include "mission/devices/devicedefinitions/StarTrackerDefinitions.h" +#include "devicedefinitions/StarTrackerDefinitions.h" #include "fsfw/returnvalues/HasReturnValuesIF.h" extern "C" { @@ -23,6 +23,8 @@ public: //! [EXPORT] : [COMMENT] Detected CRC failure in received frame static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA2); + static const uint8_t STATUS_OK = 0; + ArcsecDatalinkLayer(); virtual ~ArcsecDatalinkLayer(); @@ -63,13 +65,27 @@ public: */ uint8_t* getEncodedFrame(); + /** + * @brief Returns status of reply + */ + uint8_t getStatusField(); + + /** + * @brief Returns ID of reply + */ + uint8_t getId(); + private: + static const uint8_t ID_OFFSET = 1; + static const uint8_t STATUS_OFFSET = 2; + // Used by arcsec slip decoding function process received data uint8_t rxBuffer[StarTracker::MAX_FRAME_SIZE]; // Decoded frame will be copied to this buffer uint8_t decodedFrame[StarTracker::MAX_FRAME_SIZE]; - // Buffer where encoded frames will be stored + // Buffer where encoded frames will be stored. First byte of encoded frame represents type of + // reply uint8_t encBuffer[StarTracker::MAX_FRAME_SIZE * 2 + 2]; // Size of decoded frame uint32_t decFrameSize = 0; diff --git a/bsp_q7s/devices/CMakeLists.txt b/bsp_q7s/devices/CMakeLists.txt index ecc6bdc1..edabfa96 100644 --- a/bsp_q7s/devices/CMakeLists.txt +++ b/bsp_q7s/devices/CMakeLists.txt @@ -2,5 +2,7 @@ target_sources(${TARGET_NAME} PRIVATE PlocSupervisorHandler.cpp PlocUpdater.cpp PlocMemoryDumper.cpp - StarTrackerImageHelper.cpp + StrImageLoader.cpp + ArcsecDatalinkLayer.cpp + StarTrackerHandler.cpp ) \ No newline at end of file diff --git a/mission/devices/StarTrackerHandler.cpp b/bsp_q7s/devices/StarTrackerHandler.cpp similarity index 90% rename from mission/devices/StarTrackerHandler.cpp rename to bsp_q7s/devices/StarTrackerHandler.cpp index dacb8617..1a8b4971 100644 --- a/mission/devices/StarTrackerHandler.cpp +++ b/bsp_q7s/devices/StarTrackerHandler.cpp @@ -1,7 +1,11 @@ +#include + #include "StarTrackerHandler.h" #include "OBSWConfig.h" +#include "devicedefinitions/StarTrackerJsonCommands.h" #include +#include extern "C" { #include @@ -21,7 +25,6 @@ StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, sif::error << "StarTrackerHandler: Invalid str image loader" << std::endl; } eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5); - slipInit(); } StarTrackerHandler::~StarTrackerHandler() { @@ -43,7 +46,7 @@ ReturnValue_t StarTrackerHandler::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED;; } result = manager->registerListener(eventQueue->getId()); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != RETURN_OK) { return result; } result = manager->subscribeToAllEventsFrom(eventQueue->getId(), objects::STR_IMG_LOADER); @@ -57,18 +60,28 @@ ReturnValue_t StarTrackerHandler::initialize() { strImageLoader->setComIF(communicationInterface); strImageLoader->setComCookie(comCookie); + return RETURN_OK; } ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { + ReturnValue_t result = RETURN_OK; + if (imageLoaderExecuting == true) { return IMAGE_LOADER_EXECUTING; } // Intercept image loader commands which do not follow the common DHB communication flow switch(actionId) { case(StarTracker::UPLOAD_IMAGE): { - strImageLoader->startImageUpload(); + if (size > MAX_PATH_SIZE) { + return FILE_PATH_TOO_LONG; + } + result = strImageLoader->startImageUpload( + std::string(reinterpret_cast(data), size)); + if (result != RETURN_OK) { + return result; + } imageLoaderExecuting = true; return EXECUTION_FINISHED; } @@ -80,7 +93,7 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu default: break; } - return DeviceHandlerBase::executeAction(); + return DeviceHandlerBase::executeAction(actionId, commandedBy, data, size); } void StarTrackerHandler::performOperationHook() { @@ -180,6 +193,14 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi prepareTemperatureRequest(); return RETURN_OK; } + case (StarTracker::LIMITS): { + result = prepareLimitsCommand(commandData, commandDataLen); + return result; + } + case (StarTracker::TRACKING): { + result = prepareTrackingCommand(commandData, commandDataLen); + return result; + } default: return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } @@ -210,20 +231,20 @@ void StarTrackerHandler::fillCommandAndReplyMap() { StarTracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(StarTracker::REQ_TEMPERATURE, 3, &temperatureSet, StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::LIMITS, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); } ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { ReturnValue_t result = RETURN_OK; - uint32_t decodedLength = 0; - size_t bytePos = 0; size_t bytesLeft = 0; result = dataLinkLayer.decodeFrame(start, remainingSize, &bytesLeft); - remainingSize = *bytesLeft; switch(result) { case ArcsecDatalinkLayer::DEC_IN_PROGRESS: { + remainingSize = bytesLeft; // Need a second doSendRead pass to reaa in whole packet return IGNORE_REPLY_DATA; } @@ -231,23 +252,24 @@ ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t rema break; } default: + remainingSize = bytesLeft; return result; } switch (dataLinkLayer.getReplyFrameType()) { case TMTC_ACTIONREPLY: { - *foundLen = remainingsize - bytesLeft; + *foundLen = remainingSize - bytesLeft; result = scanForActionReply(foundId); break; } case TMTC_SETPARAMREPLY: { - *foundLen = remainingsize - bytesLeft; + *foundLen = remainingSize - bytesLeft; result = scanForSetParameterReply(foundId); break; } case TMTC_TELEMETRYREPLYA: case TMTC_TELEMETRYREPLY: { - *foundLen = remainingsize - bytesLeft; + *foundLen = remainingSize - bytesLeft; result = scanForTmReply(foundId); break; } @@ -257,6 +279,8 @@ ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t rema } } + remainingSize = bytesLeft; + return result; } @@ -301,6 +325,10 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con handleTemperatureTm(); break; } + case (StarTracker::LIMITS): { + result = handleSetParamReply(); + break; + } default: { sif::debug << "StarTrackerHandler::interpretDeviceReply: Unknown device reply id:" << id << std::endl; @@ -407,6 +435,13 @@ size_t StarTrackerHandler::getNextReplyLength(DeviceCommandId_t commandId){ return StarTracker::MAX_FRAME_SIZE; } +ReturnValue_t StarTrackerHandler::doSendReadHook() { + if(imageLoaderExecuting) { + return RETURN_FAILED; + } + return RETURN_OK; +} + ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t *foundId) { const uint8_t* reply = dataLinkLayer.getReply(); switch (*reply) { @@ -423,7 +458,7 @@ ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t *foundId) break; } default: - sif::debug << "StarTrackerHandler::scanForSetParameterReply: Unknown parameter reply id" + sif::warning << "StarTrackerHandler::scanForSetParameterReply: Unknown parameter reply id" << std::endl; return RETURN_FAILED; } @@ -437,6 +472,10 @@ ReturnValue_t StarTrackerHandler::scanForSetParameterReply(DeviceCommandId_t *fo *foundId = StarTracker::SUBSCRIBE_TO_TM; break; } + case (StarTracker::ID::LIMITS): { + *foundId = StarTracker::LIMITS; + break; + } default: sif::debug << "StarTrackerHandler::scanForSetParameterReply: Unknown parameter reply id" << std::endl; @@ -519,10 +558,9 @@ void StarTrackerHandler::preparePingRequest() { uint32_t length = 0; struct PingActionRequest pingRequest = {PING_ID}; arc_pack_ping_action_req(&pingRequest, commandBuffer, &length); - uint32_t encLength = 0; - arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength); - rawPacket = encBuffer; - rawPacketLen = encLength; + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareVersionRequest() { @@ -587,10 +625,9 @@ void StarTrackerHandler::prepareSubscriptionCommand(const uint8_t* tmId) { void StarTrackerHandler::prepareSolutionRequest() { uint32_t length = 0; arc_tm_pack_solution_req(commandBuffer, &length); - uint32_t encLength = 0; - arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength); - rawPacket = encBuffer; - rawPacketLen = encLength; + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareTemperatureRequest() { @@ -601,6 +638,48 @@ void StarTrackerHandler::prepareTemperatureRequest() { rawPacketLen = dataLinkLayer.getEncodedLength(); } +ReturnValue_t StarTrackerHandler::prepareLimitsCommand(const uint8_t* commandData, + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + if (commandDataLen > MAX_PATH_SIZE) { + return FILE_PATH_TOO_LONG; + } + std::string fullName(reinterpret_cast(commandData), commandDataLen); + + Limits limits; + result = limits.create(fullName, commandBuffer); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareLimitsCommand: Failed to create limits command" + << std::endl; + return result; + } + dataLinkLayer.encodeFrame(commandBuffer, Limits::COMMAND_SIZE); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; +} + +ReturnValue_t StarTrackerHandler::prepareTrackingCommand(const uint8_t* commandData, + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + if (commandDataLen > MAX_PATH_SIZE) { + return FILE_PATH_TOO_LONG; + } + std::string fullName(reinterpret_cast(commandData), commandDataLen); + + Tracking tracking; + result = tracking.create(fullName, commandBuffer); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareTrackingCommand: Failed to create tracking " + " command" << std::endl; + return result; + } + dataLinkLayer.encodeFrame(commandBuffer, Tracking::COMMAND_SIZE); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; +} + ReturnValue_t StarTrackerHandler::handleSetParamReply() { const uint8_t* reply = dataLinkLayer.getReply(); uint8_t status = *(reply + STATUS_OFFSET); @@ -963,7 +1042,7 @@ uint32_t StarTrackerHandler::deserializeUint32(const uint8_t* buffer) { return word; } -uint64_t StarTrackerHandler::deserializeUint64(uint8_t* buffer) { +uint64_t StarTrackerHandler::deserializeUint64(const uint8_t* buffer) { uint64_t word = 0; word = static_cast(*(buffer + 7)) << 56 | static_cast(*(buffer + 6)) << 48 diff --git a/mission/devices/StarTrackerHandler.h b/bsp_q7s/devices/StarTrackerHandler.h similarity index 92% rename from mission/devices/StarTrackerHandler.h rename to bsp_q7s/devices/StarTrackerHandler.h index e8aef15a..27d14a3d 100644 --- a/mission/devices/StarTrackerHandler.h +++ b/bsp_q7s/devices/StarTrackerHandler.h @@ -3,12 +3,11 @@ #include #include -#include #include #include #include #include -#include +#include /** * @brief This is the device handler for the star tracker from arcsec. @@ -68,6 +67,8 @@ protected: */ virtual size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override; + virtual ReturnValue_t doSendReadHook() override; + private: static const uint8_t INTERFACE_ID = CLASS_ID::STR_HANDLER; @@ -102,7 +103,11 @@ private: //! [EXPORT] : [COMMENT] Position value in upload image reply not matching sent position static const ReturnValue_t UPLOAD_IMAGE_FAILED = MAKE_RETURN_CODE(0xA9); //! [EXPORT] : [COMMENT] Received upload image command with invalid length - static const ReturnValue_t INVALID_UPLOAD_COMMAND = MAKE_RETURN_CODE(0xA9); + static const ReturnValue_t INVALID_UPLOAD_COMMAND = MAKE_RETURN_CODE(0xAA); + //! [EXPORT] : [COMMENT] Received invalid path string. Exceeds allowed length + static const ReturnValue_t FILE_PATH_TOO_LONG = MAKE_RETURN_CODE(0xAB); + + static const size_t MAX_PATH_SIZE = 50; // position (uint32) + 1024 image data static const size_t UPLOAD_COMMAND_LEN = 1028; @@ -123,9 +128,6 @@ private: static const MutexIF::TimeoutType TIMEOUT_TYPE= MutexIF::TimeoutType::WAITING; static const uint32_t MUTEX_TIMEOUT = 20; - // Pointer to object responsible for uploading and downloading images to/from the star tracker - StrImageLoader* strImageLoader = nullptr; - MessageQueueIF* eventQueue = nullptr; ArcsecDatalinkLayer dataLinkLayer; @@ -137,6 +139,9 @@ private: StarTracker::TimeSet timeSet; StarTracker::SolutionSet solutionSet; + // Pointer to object responsible for uploading and downloading images to/from the star tracker + StrImageLoader* strImageLoader = nullptr; + uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE]; enum class InternalState { @@ -166,6 +171,11 @@ private: */ void prepareTimeRequest(); + /** + * @brief Handles all received event messages + */ + void handleEvent(EventMessage* eventMessage); + /** * @brief Fills command buffer with data to boot image (works only when star tracker is * in bootloader mode). @@ -210,6 +220,12 @@ private: */ void prepareTemperatureRequest(); + /** + * @brief Reads limit parameters from json file specified with commandData and prepares + * the command to apply the limits to the star tracker. + */ + ReturnValue_t prepareLimitsCommand(const uint8_t* commandData, size_t commandDataLen); + /** * @brief Default function to handle action replies */ @@ -277,7 +293,7 @@ private: * * @note Deserialization will be performed in little endian byte order */ - uint64_t deserializeUint64(uint8_t* buffer); + uint64_t deserializeUint64(const uint8_t* buffer); }; #endif /* MISSION_DEVICES_STARTRACKERHANDLER_H_ */ diff --git a/bsp_q7s/devices/StarTrackerImageHelper.cpp b/bsp_q7s/devices/StarTrackerImageHelper.cpp deleted file mode 100644 index 3fb62b99..00000000 --- a/bsp_q7s/devices/StarTrackerImageHelper.cpp +++ /dev/null @@ -1,311 +0,0 @@ -#include "fsfw/ipc/QueueFactory.h" -#include "StarTrackerImageHelper.h" - -#include -#include -#include - -StarTrackerImageHelper::StarTrackerImageHelper(object_id_t objectId) : - SystemObject(objectId), commandActionHelper(this), actionHelper(this, nullptr) { - commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); -} - -StarTrackerImageHelper::~StarTrackerImageHelper() { -} - -ReturnValue_t StarTrackerImageHelper::initialize() { - sdcMan = SdCardManager::instance(); - if (sdcMan == nullptr) { - sif::warning << "StarTrackerImageHelper::initialize: Invaldi SD Card Manager" << std::endl; - } - ReturnValue_t result = SystemObject::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - result = commandActionHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - result = actionHelper.initialize(commandQueue); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t StarTrackerImageHelper::performOperation(uint8_t operationCode) { - readCommandQueue(); - doStateMachine(); - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t StarTrackerImageHelper::executeAction(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { - ReturnValue_t result = EXECUTION_FINISHED; - - if (state != State::IDLE) { - return IS_BUSY; - } - - if (size > MAX_STR_IMAGE_PATH) { - return NAME_TOO_LONG; - } - - switch (actionId) { - case UPLOAD_IMAGE: - result = prepareUploadCommand(data, size); - if (result == RETURN_OK) { - result = EXECUTION_FINISHED; - } - break; - case DOWNLOAD_IMAGE: - break; - default: - return INVALID_ACTION_ID; - } - - return result; -} - -MessageQueueId_t StarTrackerImageHelper::getCommandQueue() const { - return commandQueue->getId(); -} - -MessageQueueIF* StarTrackerImageHelper::getCommandQueuePtr() { - return commandQueue; -} - -void StarTrackerImageHelper::readCommandQueue() { - CommandMessage message; - ReturnValue_t result; - - for (result = commandQueue->receiveMessage(&message); result == HasReturnvaluesIF::RETURN_OK; - result = commandQueue->receiveMessage(&message)) { - if (result != RETURN_OK) { - continue; - } - result = actionHelper.handleActionMessage(&message); - if (result == HasReturnvaluesIF::RETURN_OK) { - continue; - } - - result = commandActionHelper.handleReply(&message); - if (result == HasReturnvaluesIF::RETURN_OK) { - continue; - } - - sif::debug << "StarTrackerImageHelper::readCommandQueue: Received inalid message" - << std::endl; - } -} - -void StarTrackerImageHelper::doStateMachine() { - switch (state) { - case State::IDLE: - break; - case State::SEND_NEXT_UPLOAD_CMD: - commandImageUpload(); - break; - case State::COMMAND_EXECUTING: - case State::UPLOAD_LAST: - break; - default: - sif::debug << "StarTrackerImageHelper::doStateMachine: Invalid state" << std::endl; - break; - } -} - -ReturnValue_t StarTrackerImageHelper::getImageLocation(const uint8_t* data, size_t size) { - - // Check if file is stored on SD card and if associated SD card is mounted - if (std::string(reinterpret_cast(data), SD_PREFIX_LENGTH) == std::string(SdCardManager::SD_0_MOUNT_POINT)) { - if (!isSdCardMounted(sd::SLOT_0)) { - sif::warning << "StarTrackerImageHelper::getImageLocation: SD card 0 not mounted" << std::endl; - return SD_NOT_MOUNTED; - } - } - else if (std::string(reinterpret_cast(data), SD_PREFIX_LENGTH) == std::string(SdCardManager::SD_1_MOUNT_POINT)) { - if (!isSdCardMounted(sd::SLOT_0)) { - sif::warning << "StarTrackerImageHelper::getImageLocation: SD card 1 not mounted" << std::endl; - return SD_NOT_MOUNTED; - } - } - else { - // Specified path in RAM filesystem - } - - imageFile = std::string(reinterpret_cast(data), size); - - // Check if file exists - if(not std::filesystem::exists(imageFile)) { - return FILE_NOT_EXISTS; - } - return RETURN_OK; -} - -bool StarTrackerImageHelper::isSdCardMounted(sd::SdCard sdCard) { - SdCardManager::SdStatePair active; - ReturnValue_t result = sdcMan->getSdCardActiveStatus(active); - if (result != RETURN_OK) { - sif::debug << "StarTrackerImageHelper::isSdCardMounted: Failed to get SD card active state"; - return false; - } - if (sdCard == sd::SLOT_0) { - if (active.first == sd::MOUNTED) { - return true; - } - else { - return false; - } - } - else if (sdCard == sd::SLOT_1) { - if (active.second == sd::MOUNTED) { - return true; - } - else { - return false; - } - } - else { - sif::debug << "StarTrackerImageHelper::isSdCardMounted: Unknown SD card specified" << std::endl; - } - return false; -} - -ReturnValue_t StarTrackerImageHelper::prepareUploadCommand(const uint8_t* data, size_t size) { - ReturnValue_t result = RETURN_OK; - result = getImageLocation(data, size); - if (result != RETURN_OK) { - return result; - } - imageSize = std::filesystem::file_size(imageFile); - remainingCommands = imageSize / SIZE_IMAGE_PART ; - if (imageSize % SIZE_IMAGE_PART) { - remainingCommands++; - } - commandsSent = 0; - state = State::SEND_NEXT_UPLOAD_CMD; - return result; -} - -void StarTrackerImageHelper::stepSuccessfulReceived(ActionId_t actionId, - uint8_t step) { -} - -void StarTrackerImageHelper::stepFailedReceived(ActionId_t actionId, uint8_t step, - ReturnValue_t returnCode) { - switch (pendingCommand) { - case (StarTracker::UPLOAD_IMAGE): - if (retries < MAX_RETRIES) { - // Repeat sending last command - commandsSent--; - remainingCommands++; - commandImageUpload(); - retries++; - state = State::COMMAND_EXECUTING; - } - else { - triggerEvent(IMAGE_UPLOAD_FAILED, returnCode, commandsSent); - retries = 0; - state = State::IDLE; - } - break; - default: - sif::debug << "StarTrackerImageHelper::completionSuccessfulReceived: Invalid pending command" - << std::endl; - break; - } -} - -void StarTrackerImageHelper::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) { -} - -void StarTrackerImageHelper::completionSuccessfulReceived(ActionId_t actionId) { - switch (pendingCommand) { - case (StarTracker::UPLOAD_IMAGE): - if (state == State::UPLOAD_LAST) { - triggerEvent(IMAGE_UPLOAD_FINISHED); - pendingCommand = StarTracker::NONE; - state = State::IDLE; - } - else { - state = State::SEND_NEXT_UPLOAD_CMD; - } - break; - default: - sif::debug << "StarTrackerImageHelper::completionSuccessfulReceived: Invalid pending command" - << std::endl; - state = State::IDLE; - break; - } -} - -void StarTrackerImageHelper::completionFailedReceived(ActionId_t actionId, - ReturnValue_t returnCode) { - switch(pendingCommand) { - case(StarTracker::UPLOAD_IMAGE): { - triggerEvent(IMAGE_UPLOAD_FAILED, returnCode, commandsSent); - break; - } - default: - sif::debug << "StarTrackerImageHelper::completionFailedReceived: Invalid pending command " - << std::endl; - break; - } - state = State::IDLE; -} - -void StarTrackerImageHelper::commandImageUpload() { - ReturnValue_t result = RETURN_OK; - uint16_t dataLen = 0; - uint8_t tmpCommandBuffer[UPLOAD_COMMAND_SIZE] = {0}; - uint32_t position = commandsSent; - - if (not std::filesystem::exists(imageFile)) { - triggerEvent(IMAGE_FILE_NOT_EXISTS, commandsSent); - state = State::IDLE; - return; - } - - std::ifstream file(imageFile, std::ifstream::binary); - file.seekg(position, file.beg); - - if (remainingCommands == 1) { - dataLen = imageSize - file.tellg(); - } - else { - dataLen = SIZE_IMAGE_PART; - } - - size_t size = 0; - size_t maxSize = sizeof(position); - uint8_t* commandBufferPtr = tmpCommandBuffer; - uint8_t** buffer = &commandBufferPtr; - SerializeAdapter::serialize(&position, buffer, &size, maxSize, - SerializeIF::Endianness::BIG); - file.read(reinterpret_cast(tmpCommandBuffer), dataLen); - file.close(); - - result = commandActionHelper.commandAction(objects::START_TRACKER, - StarTracker::UPLOAD_IMAGE, tmpCommandBuffer - size , UPLOAD_COMMAND_SIZE); - - if (result != RETURN_OK) { - sif::warning << "StarTrackerImageHelper::commandImageUpload: Failed to send image " - << "upload command" << std::endl; - triggerEvent(ACTION_COMMANDING_FAILED, result, StarTracker::UPLOAD_IMAGE); - state = State::IDLE; - return; - } - - remainingCommands--; - commandsSent++; - - if (remainingCommands == 0) { - state = State::UPLOAD_LAST; - } - else { - state = State::COMMAND_EXECUTING; - } - pendingCommand = StarTracker::UPLOAD_IMAGE; -} diff --git a/bsp_q7s/devices/StarTrackerImageHelper.h b/bsp_q7s/devices/StarTrackerImageHelper.h deleted file mode 100644 index 420721dc..00000000 --- a/bsp_q7s/devices/StarTrackerImageHelper.h +++ /dev/null @@ -1,153 +0,0 @@ -#ifndef MISSION_DEVICES_STARTRACKERIMAGEHELPER_H_ -#define MISSION_DEVICES_STARTRACKERIMAGEHELPER_H_ - -#include "OBSWConfig.h" -#include "mission/devices/devicedefinitions/StarTrackerDefinitions.h" -#include "fsfw/action/CommandActionHelper.h" -#include "fsfw/action/ActionHelper.h" -#include "fsfw/action/HasActionsIF.h" -#include "fsfw/action/CommandsActionsIF.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" -#include "fsfw/tasks/ExecutableObjectIF.h" -#include "fsfw/objectmanager/SystemObject.h" -#include "bsp_q7s/memory/SdCardManager.h" -#include "linux/fsfwconfig/objects/systemObjectList.h" - - -/** - * @brief An object of this class helps to download and upload images from/to the star tracker. - * - * @details The star tracker can only receive upload image commands with maximum 1024 bytes of data. - * Thus this class is used to raed the image from the file system and split the upload - * procedure into multiple steps. - * The same applies to downloading images from the star tracker (max. 1024 bytes in image - * download reply). - * - * @author J. Meier - */ -class StarTrackerImageHelper : public SystemObject, - public HasActionsIF, - public ExecutableObjectIF, - public HasReturnvaluesIF, - public CommandsActionsIF { -public: - - static const ActionId_t UPLOAD_IMAGE = 0; - static const ActionId_t DOWNLOAD_IMAGE = 1; - - StarTrackerImageHelper(object_id_t objectId); - virtual ~StarTrackerImageHelper(); - - ReturnValue_t performOperation(uint8_t operationCode = 0) override; - ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size); - MessageQueueId_t getCommandQueue() const; - ReturnValue_t initialize() override; - MessageQueueIF* getCommandQueuePtr() override; - void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) override; - void stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) override; - void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) override; - void completionSuccessfulReceived(ActionId_t actionId) override; - void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override; - -private: - - static const uint8_t INTERFACE_ID = CLASS_ID::STR_IMG_HELPER; - - //! [EXPORT] : [COMMENT] Image helper is already executing a command - static const ReturnValue_t IMAGE_HELPER_BUSY = MAKE_RETURN_CODE(0xA0); - //! [EXPORT] : [COMMENT] Invalid path to image location - static const ReturnValue_t NAME_TOO_LONG = MAKE_RETURN_CODE(0xA1); - //! [EXPORT] : [COMMENT] SD card with image not mounted - static const ReturnValue_t SD_NOT_MOUNTED = MAKE_RETURN_CODE(0xA2); - //! [EXPORT] : [COMMENT] Specified image does not exist - static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xA3); - - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_IMAGE_HELPER; - - //! [EXPORT] : [COMMENT] Try to read image file to upload but the file does not exist. - //! P1: Refers to the upload step the reading fails - static const Event IMAGE_FILE_NOT_EXISTS = MAKE_EVENT(0, severity::LOW); - //! [EXPORT] : [COMMENT] Failed to send command to star tracker handler - //! P1: Return value of CommandActionHelper::commandAction - //! P2: Action ID of command to send - static const Event ACTION_COMMANDING_FAILED = MAKE_EVENT(1, severity::LOW); - //! [EXPORT] : [COMMENT] Star tracker handler replies with completion or step failure message to upload image command - //!P1: Return code of execution/step failure message - //!P2: Failed upload step (equal to number of commands already sent) - static const Event IMAGE_UPLOAD_FAILED = MAKE_EVENT(2, severity::LOW); - //! [EXPORT] : [COMMENT] Image upload was successful - static const Event IMAGE_UPLOAD_FINISHED = MAKE_EVENT(3, severity::LOW); - - static const uint8_t MAX_RETRIES = 3; - static const uint32_t QUEUE_SIZE = config::STR_IMG_HELPER_QUEUE_SIZE; - static const size_t MAX_STR_IMAGE_PATH = 50; - static const size_t SD_PREFIX_LENGTH = 8; - // Size of one image part which can be sent per action request - static const size_t SIZE_IMAGE_PART = 1024; - // Position (uint32_t) + image data (1024 bytes) - static const size_t UPLOAD_COMMAND_SIZE = 1028; - - MessageQueueIF* commandQueue = nullptr; - - SdCardManager* sdcMan = nullptr; - - CommandActionHelper commandActionHelper; - - ActionHelper actionHelper; - - enum class State: uint8_t { - IDLE, - SEND_NEXT_UPLOAD_CMD, - UPLOAD_LAST, - COMMAND_EXECUTING - }; - - State state = State::IDLE; - - ActionId_t pendingCommand = StarTracker::NONE; - - uint32_t commandsSent = 0; - uint32_t remainingCommands = 0; - // Counts retries when command was rejected by star tracker - uint8_t retries = 0; - - // Path and name of active image (either upload or download image) - std::string imageFile; - // In case of upload command this variable stores the size of the image to upload - std::uintmax_t imageSize; - - void readCommandQueue(); - void doStateMachine(); - - /** - * @brief Extracts the path and name form the received command. - * - * @param data Pointer to received command - * @param size Size of the received command - * - * @details This string defines the image to upload (must be previously written to the SD card). - * In case of the download image command, this string defines the location and name of - * the image file to create. - */ - ReturnValue_t getImageLocation(const uint8_t* data, size_t size); - - /** - * @brief Prepares properties for the upload image command and changes the state to initiate - * the execution of the upload image command. - */ - ReturnValue_t prepareUploadCommand(const uint8_t* data, size_t size); - - /** - * @brief Reads part of image from file and sends upload image command to star tracker - * handler. - */ - void commandImageUpload(); - - /** - * @brief Checks whether the SD card to read from is mounted or not. - */ - bool isSdCardMounted(sd::SdCard sdCard); -}; - -#endif /* MISSION_DEVICES_STARTRACKERIMAGEHELPER_H_ */ diff --git a/bsp_q7s/devices/StrImageLoader.cpp b/bsp_q7s/devices/StrImageLoader.cpp index 7d4b64eb..9d49d8bf 100644 --- a/bsp_q7s/devices/StrImageLoader.cpp +++ b/bsp_q7s/devices/StrImageLoader.cpp @@ -1,8 +1,9 @@ #include "StrImageLoader.h" +#include #include -StrImageLoader::StrImageLoader(object_id_t objectId) { +StrImageLoader::StrImageLoader(object_id_t objectId) : SystemObject(objectId){ } @@ -13,7 +14,9 @@ ReturnValue_t StrImageLoader::initialize() { sdcMan = SdCardManager::instance(); if (sdcMan == nullptr) { sif::warning << "StrImageLoader::initialize: Invalid SD Card Manager" << std::endl; + return RETURN_FAILED; } + return RETURN_OK; } ReturnValue_t StrImageLoader::performOperation(uint8_t operationCode) { @@ -26,10 +29,11 @@ ReturnValue_t StrImageLoader::performOperation(uint8_t operationCode) { break; } case InternalState::UPLOAD_IMAGE: { - result = uploadImage(); + result = performImageUpload(); if (result == RETURN_OK){ triggerEvent(IMAGE_UPLOAD_SUCCESSFUL); } + internalState = InternalState::IDLE; break; } case InternalState::DOWNLOAD_IMAGE: @@ -72,85 +76,138 @@ ReturnValue_t StrImageLoader::startImageUpload(std::string image) { internalState = InternalState::UPLOAD_IMAGE; semaphore.release(); + + return RETURN_OK; } -ReturnValue_t StrImageLoader::uploadImage() { +ReturnValue_t StrImageLoader::startImageDownload() { + return RETURN_OK; +} + +ReturnValue_t StrImageLoader::performImageUpload() { ReturnValue_t result = RETURN_OK; - size_t receivedDataLen = 0; - uint8_t *receivedData = nullptr; - size_t bytesLeft = 0; - uint32_t readSize = 0; uint32_t imageSize = 0; struct UploadActionRequest uploadReq; uploadReq.position = 0; - uploadReq.data = {0}; + std::memset(&uploadReq.data, 0, sizeof(uploadReq.data)); if (not std::filesystem::exists(uploadImage)) { triggerEvent(IMAGE_FILE_NOT_EXISTS, uploadReq.position); - state = State::IDLE; + internalState = InternalState::IDLE; return RETURN_FAILED; } - std::ifstream file(uploadImage, std::ifstream::binary); + // Set position of next character to end of file input stream file.seekg(0, file.end); + // tellg returns position of character in input stream imageSize = file.tellg(); - file.seekg(uploadReq.position * SIZE_IMAGE_PART, file.beg); - - while(uploadReq.position * SIZE_IMAGE_PART < imageSize) { - result = - } - - uint32_t remainder = imageSize - uploadReq.position * SIZE_IMAGE_PART; - file.read(reinterpret_cast(uploadReq.data), remainder); - uploadReq.position++; - datalinkLayer.encodeFrame(uploadReq.data, remainder); - result = communicationInterface->sendMessage(comCookie, datalinkLayer.getEncodedFrame(), - datalinkLayer.getEncodedLength()); - if (result = RETURN_OK) { - sif::warning << "StrImageLoader::uploadImage: Failed to send upload packet" << std::endl; - triggerEvent(SENDING_UPLOAD_PACKET_FAILED, result, uploadReq.position); - return RETURN_FAILED; - } - result = ArcsecDatalinkLayer::DEC_IN_PROGRESS; - while(result == ArcsecDatalinkLayer::DEC_IN_PROGRESS) { - result = communicationInterface->requestReceiveMessage(comCookie, StarTracker::MAX_FRAME_SIZE* 2 + 2); - if (result != RETURN_OK) { - sif::warning << "StrImageLoader::uploadImage: Failed to request reply" << std::endl; - triggerEvent(UPLOAD_REQUESTING_MSG_FAILED, result, uploadReq.position); - return RETURN_FAILED; - } - result = communicationInterface->readReceivedMessage(comCookie, receivedData, - receivedDataLen); - if (result != RETURN_OK) { - sif::warning << "StrImageLoader::uploadImage: Failed to read received message" - << std::endl; - triggerEvent(UPLOAD_READING_REPLY_FAILED, result, uploadReq.position); - } - result = datalinkLayer.decodeFrame(receivedData, receivedDataLen, &bytesLeft); - if (bytesLeft != 0) { - // This should never happen - triggerEvent(UPLOAD_COM_ERROR, result, uploadReq.position); - return RETURN_FAILED; - } - } - - if (remainingCommands == 1) { - dataLen = imageSize - file.tellg(); + // Set position of next character to beginning of file input stream + file.seekg(0, file.beg); + if (imageSize >= SIZE_IMAGE_PART) { + file.read(reinterpret_cast(uploadReq.data), SIZE_IMAGE_PART); } else { - dataLen = SIZE_IMAGE_PART; + file.read(reinterpret_cast(uploadReq.data), imageSize); } - - size_t size = 0; - size_t maxSize = sizeof(position); - uint8_t* commandBufferPtr = tmpCommandBuffer; - uint8_t** buffer = &commandBufferPtr; - SerializeAdapter::serialize(&position, buffer, &size, maxSize, - SerializeIF::Endianness::BIG); - file.read(reinterpret_cast(uploadReq.data), dataLen); + while(uploadReq.position * SIZE_IMAGE_PART < imageSize) { + result = uploadSendAndRead(&uploadReq); + if (result != RETURN_OK) { + return RETURN_FAILED; + } + result = checkUploadReply(); + if (result != RETURN_OK) { + return result; + } + uploadReq.position++; + file.seekg(uploadReq.position * SIZE_IMAGE_PART, file.beg); + } + std::memset(uploadReq.data, 0, sizeof(uploadReq.data)); + uint32_t remainder = imageSize - uploadReq.position * SIZE_IMAGE_PART; + file.read(reinterpret_cast(uploadReq.data), remainder); file.close(); - - arc_pack_upload_action_req() - communicationInterface->requestReceiveMessage(comCookie, ) + uploadReq.position++; + result = uploadSendAndRead(&uploadReq); + if (result != RETURN_OK) { + return RETURN_FAILED; + } + result = checkUploadReply(); + if (result != RETURN_OK) { + return result; + } + return RETURN_OK; } +ReturnValue_t StrImageLoader::uploadSendAndRead(struct UploadActionRequest* uploadReq) { + ReturnValue_t result = RETURN_OK; + ReturnValue_t decResult = RETURN_OK; + size_t receivedDataLen = 0; + uint8_t *receivedData = nullptr; + size_t bytesLeft = 0; + uint32_t size = 0; + uint32_t missedReplies = 0; + arc_pack_upload_action_req(uploadReq, commandBuffer, &size); + datalinkLayer.encodeFrame(commandBuffer, size); + result = communicationInterface->sendMessage(comCookie, datalinkLayer.getEncodedFrame(), + datalinkLayer.getEncodedLength()); + if (result != RETURN_OK) { + sif::warning << "StrImageLoader::uploadImage: Failed to send upload packet" << std::endl; + triggerEvent(SENDING_UPLOAD_PACKET_FAILED, result, uploadReq->position); + return RETURN_FAILED; + } + decResult = ArcsecDatalinkLayer::DEC_IN_PROGRESS; + while (decResult == ArcsecDatalinkLayer::DEC_IN_PROGRESS) { + result = communicationInterface->requestReceiveMessage(comCookie, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + if (result != RETURN_OK) { + sif::warning << "StrImageLoader::uploadImage: Failed to request reply" << std::endl; + triggerEvent(UPLOAD_REQUESTING_MSG_FAILED, result, uploadReq->position); + return RETURN_FAILED; + } + result = communicationInterface->readReceivedMessage(comCookie, &receivedData, &receivedDataLen); + if (result != RETURN_OK) { + sif::warning << "StrImageLoader::uploadImage: Failed to read received message" << std::endl; + triggerEvent(UPLOAD_READING_REPLY_FAILED, result, uploadReq->position); + return RETURN_FAILED; + } + if (receivedDataLen == 0 && missedReplies < MAX_POLLS) { + missedReplies++; + continue; + } + else if ((receivedDataLen == 0) && (missedReplies >= MAX_POLLS)) { + triggerEvent(NO_REPLY, uploadReq->position); + return RETURN_FAILED; + } + else { + missedReplies = 0; + } + decResult = datalinkLayer.decodeFrame(receivedData, receivedDataLen, &bytesLeft); + if (bytesLeft != 0) { + // This should never happen + sif::warning << "StrImageLoader::uploadSendAndRead: Bytes left after decoding" << std::endl; + triggerEvent(UPLOAD_COM_ERROR, result, uploadReq->position); + return RETURN_FAILED; + } + } + if (decResult != RETURN_OK) { + triggerEvent(DEC_ERROR, decResult, uploadReq->position); + return RETURN_FAILED; + } + return RETURN_OK; +} + +ReturnValue_t StrImageLoader::checkUploadReply() { + uint8_t type = datalinkLayer.getReplyFrameType(); + if (type != TMTC_ACTIONREPLY) { + sif::warning << "StrImageLoader::checkUploadReply: Received invalid upload reply" + << std::endl; + triggerEvent(INVALID_TYPE_ID); + return RETURN_FAILED; + } + uint8_t status = datalinkLayer.getStatusField(); + if (status != ArcsecDatalinkLayer::STATUS_OK) { + triggerEvent(STATUS_ERROR); + sif::warning << "StrImageLoader::checkUploadReply: Status failure" << std::endl; + return RETURN_FAILED; + } + return RETURN_OK; +} diff --git a/bsp_q7s/devices/StrImageLoader.h b/bsp_q7s/devices/StrImageLoader.h index 50cdc266..940001a4 100644 --- a/bsp_q7s/devices/StrImageLoader.h +++ b/bsp_q7s/devices/StrImageLoader.h @@ -7,6 +7,15 @@ #include "bsp_q7s/memory/SdCardManager.h" #include "bsp_q7s/devices/ArcsecDatalinkLayer.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/objectmanager/SystemObject.h" +#include "fsfw/tasks/ExecutableObjectIF.h" +#include "fsfw/devicehandlers/DeviceCommunicationIF.h" +#include "fsfw/devicehandlers/CookieIF.h" + +extern "C" { + #include "thirdparty/arcsec_star_tracker/common/generated/tmtcstructs.h" + #include "thirdparty/arcsec_star_tracker/client/generated/actionreq.h" +} /** * @brief An object of this class runs in a separate task and is responsible for uploading and @@ -34,16 +43,28 @@ public: //! [EXPORT] : [COMMENT] Failed to read communication interface reply data //!P1: Return code of failed communication interface read call //!P1: Upload position for which the read call failed - static const Event UPLOAD_READING_REPLY_FAILED = MAKE_EVENT(3, severity::LOW); + static const Event UPLOAD_READING_REPLY_FAILED = MAKE_EVENT(4, severity::LOW); //! [EXPORT] : [COMMENT] Unexpected stop of decoding sequence //!P1: Return code of failed communication interface read call //!P1: Upload position for which the read call failed - static const Event UPLOAD_COM_ERROR = MAKE_EVENT(4, severity::LOW); + static const Event UPLOAD_COM_ERROR = MAKE_EVENT(5, severity::LOW); + //! [EXPORT] : [COMMENT] Star tracker did not send replies (maybe device is powered off) + //!P1: Position of upload packet for which no reply was sent + static const Event NO_REPLY = MAKE_EVENT(6, severity::LOW); + //! [EXPORT] : [COMMENT] Received reply with invalid type ID + static const Event INVALID_TYPE_ID = MAKE_EVENT(7, severity::LOW); + //! [EXPORT] : [COMMENT] Status field in reply signals error + static const Event STATUS_ERROR = MAKE_EVENT(8, severity::LOW); + //! [EXPORT] : [COMMENT] Error during decoding of received reply occurred + //P1: Return value of decoding function + //P2: Position of upload packet for which reply decoding failed + static const Event DEC_ERROR = MAKE_EVENT(9, severity::LOW); StrImageLoader(object_id_t objectId); virtual ~StrImageLoader(); + ReturnValue_t initialize() override; ReturnValue_t performOperation(uint8_t operationCode = 0) override; void setComIF(DeviceCommunicationIF* communicationInterface_); @@ -57,6 +78,11 @@ public: */ ReturnValue_t startImageUpload(std::string image); + /** + * @brief Calling this function initiates the download of an image from the star tracker. + */ + ReturnValue_t startImageDownload(); + private: static const uint8_t INTERFACE_ID = CLASS_ID::STR_IMG_LOADER; @@ -69,6 +95,8 @@ private: // Size of one image part which can be sent per action request static const size_t SIZE_IMAGE_PART = 1024; + static const uint32_t MAX_POLLS = 10000; + enum class InternalState { IDLE, UPLOAD_IMAGE, @@ -86,6 +114,8 @@ private: SdCardManager* sdcMan = nullptr; + uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE]; + /** * Communication object responsible for low level access of star tracker * Must be set by star tracker handler @@ -94,10 +124,30 @@ private: // Communication cookie. Must be set by the star tracker handler CookieIF* comCookie = nullptr; + // Queue id of raw data receiver + MessageQueueId_t rawDataReceiver = MessageQueueIF::NO_QUEUE; + /** * @brief Performs image uploading */ - ReturnValue_t uploadImage(); + ReturnValue_t performImageUpload(); + + /** + * @brief Sends a upload image packet and receives the action reply. + * + * @param uploadReq Pointer to upload request structure to send + * + * @return RETURN_OK if successful, otherwise RETURN_FALIED + */ + ReturnValue_t uploadSendAndRead(struct UploadActionRequest* uploadReq); + + /** + * @brief Checks the reply to an upload action request + * + * @return RETURN_OK if reply confirms success of upload packet transfer, otherwise + * REUTRN_FAILED + */ + ReturnValue_t checkUploadReply(); }; #endif /* BSP_Q7S_DEVICES_STRIMAGELOADER_H_ */ diff --git a/mission/devices/devicedefinitions/StarTrackerDefinitions.h b/bsp_q7s/devices/devicedefinitions/StarTrackerDefinitions.h similarity index 93% rename from mission/devices/devicedefinitions/StarTrackerDefinitions.h rename to bsp_q7s/devices/devicedefinitions/StarTrackerDefinitions.h index 4721957b..49dd111f 100644 --- a/mission/devices/devicedefinitions/StarTrackerDefinitions.h +++ b/bsp_q7s/devices/devicedefinitions/StarTrackerDefinitions.h @@ -97,6 +97,16 @@ static const DeviceCommandId_t REQ_POWER = 11; static const DeviceCommandId_t SUBSCRIBE_TO_TM = 18; static const DeviceCommandId_t REQ_SOLUTION = 24; static const DeviceCommandId_t REQ_TEMPERATURE = 25; +static const DeviceCommandId_t LIMITS = 40; +static const DeviceCommandId_t MONTING = 41; +static const DeviceCommandId_t CAMERA = 42; +static const DeviceCommandId_t BLOB = 43; +static const DeviceCommandId_t CENTROIDING = 44; +static const DeviceCommandId_t LISA = 45; +static const DeviceCommandId_t MACTHING = 46; +static const DeviceCommandId_t TRACKING = 47; +static const DeviceCommandId_t VALIDATION = 48; +static const DeviceCommandId_t ALGO = 49; static const DeviceCommandId_t NONE = 0xFFFFFFFF; static const uint32_t VERSION_SET_ID = REQ_VERSION; @@ -122,6 +132,16 @@ namespace ID { static const uint8_t BOOT = 1; static const uint8_t VERSION = 2; static const uint8_t INTERFACE = 3; + static const uint8_t LIMITS = 5; + static const uint8_t MOUNTING = 6; + static const uint8_t CAMERA = 9; + static const uint8_t BLOB = 10; + static const uint8_t CENTROIDING = 11; + static const uint8_t LISA = 12; + static const uint8_t MATCHING = 13; + static const uint8_t TRACKING = 14; + static const uint8_t VALIDATION = 15; + static const uint8_t ALGO = 16; static const uint8_t REBOOT = 7; static const uint8_t UPLOAD_IMAGE = 10; static const uint8_t POWER = 11; @@ -489,11 +509,11 @@ public: sif::info << "SolutionSet::printSet: Track Qz: " << this->trackQz << std::endl; sif::info << "SolutionSet::printSet: Track removed: " - << static_cast(this->trackRemoved) << std::endl; + << static_cast(this->trackRemoved.value) << std::endl; sif::info << "SolutionSet::printSet: Number of stars centroided: " - << static_cast(this->starsCentroided) << std::endl; + << static_cast(this->starsCentroided.value) << std::endl; sif::info << "SolutionSet::printSet: Number of stars matched database: " - << static_cast(this->starsMatchedDatabase) << std::endl; + << static_cast(this->starsMatchedDatabase.value) << std::endl; sif::info << "SolutionSet::printSet: LISA Qw: " << this->lisaQw << std::endl; sif::info << "SolutionSet::printSet: LISA Qx: " @@ -505,13 +525,13 @@ public: sif::info << "SolutionSet::printSet: LISA Percentage close: " << this->lisaPercentageClose << std::endl; sif::info << "SolutionSet::printSet: LISA number of close stars: " - << static_cast(this->lisaNrClose) << std::endl; + << static_cast(this->lisaNrClose.value) << std::endl; sif::info << "SolutionSet::printSet: Is trust worthy: " - << static_cast(this->isTrustWorthy) << std::endl; + << static_cast(this->isTrustWorthy.value) << std::endl; sif::info << "SolutionSet::printSet: Stable count: " << this->stableCount << std::endl; sif::info << "SolutionSet::printSet: Solution strategy: " - << static_cast(this->solutionStrategy) << std::endl; + << static_cast(this->solutionStrategy.value) << std::endl; } }; diff --git a/bsp_q7s/devices/devicedefinitions/StarTrackerJsonCommands.h b/bsp_q7s/devices/devicedefinitions/StarTrackerJsonCommands.h new file mode 100644 index 00000000..c25e1586 --- /dev/null +++ b/bsp_q7s/devices/devicedefinitions/StarTrackerJsonCommands.h @@ -0,0 +1,343 @@ +#ifndef BSP_Q7S_DEVICES_DEVICEDEFINITIONS_STARTRACKERJSONCOMMANDS_H_ +#define BSP_Q7S_DEVICES_DEVICEDEFINITIONS_STARTRACKERJSONCOMMANDS_H_ + +#include +#include +#include +#include + +#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "bsp_q7s/devices/devicedefinitions/StarTrackerDefinitions.h" + +#include "thirdparty/arcsec_star_tracker/common/generated/tmtcstructs.h" + +using json = nlohmann::json; + +/** + * @brief This file defines a few helper classes to generate commands by means of the arcsec + * json files. + * @author J. Meier + */ + +namespace arcseckeys { + static const char PROPERTIES[] = "properties"; + static const char NAME[] = "name"; + static const char VALUE[] = "value"; + + static const char LIMITS[] = "limits"; + static const char ACTION[] = "action"; + static const char FPGA18CURRENT[] = "FPGA18Current"; + static const char FPGA25CURRENT[] = "FPGA25Current"; + static const char FPGA10CURRENT[] = "FPGA10Current"; + static const char MCUCURRENT[] = "MCUCurrent"; + static const char CMOS21CURRENT[] = "CMOS21Current"; + static const char CMOSPIXCURRENT[] = "CMOSPixCurrent"; + static const char CMOS33CURRENT[] = "CMOS33Current"; + static const char CMOSVRESCURRENT[] = "CMOSVResCurrent"; + static const char CMOS_TEMPERATURE[] = "CMOSTemperature"; + static const char MCU_TEMPERATURE[] = "MCUTemperature"; + + static const char TRACKING[] = "tracking"; + static const char THIN_LIMIT[] = "thinLimit"; + static const char OUTLIER_THRESHOLD[] = "outlierThreshold"; + static const char OUTLIER_THRESHOLD_QUEST[] = "outlierThresholdQUEST"; + static const char TRACKER_CHOICE[] = "trackerChoice"; +} + +class ArcsecJsonBase : public HasReturnvaluesIF { +public: + + static const uint8_t INTERFACE_ID = CLASS_ID::ARCSEC_JSON_BASE; + //! [EXPORT] : [COMMENT] Specified json file does not exist + static const ReturnValue_t JSON_FILE_NOT_EXISTS = MAKE_RETURN_CODE(1); + //! [EXPORT] : [COMMENT] Requested set does not exist in json file + static const ReturnValue_t SET_NOT_EXISTS = MAKE_RETURN_CODE(2); + //! [EXPORT] : [COMMENT] Requested parameter does not exist in json file + static const ReturnValue_t PARAM_NOT_EXISTS = MAKE_RETURN_CODE(3); + + /** + * @brief Constructor + * + * @param fullname Name with absolute path of json file containing the parameters to set. + */ + ArcsecJsonBase() {} + +protected: + + /** + * @brief Initializes the properties json object and the set json object + * + * @param fullname Name including absolute path to json file + * @param setName The name of the set to work on + * + * @param return JSON_FILE_NOT_EXISTS if specified file does not exist, otherwise + * RETURN_OK + */ + ReturnValue_t init(const std::string filename,std::string setName) { + ReturnValue_t result = RETURN_OK; + if(not std::filesystem::exists(filename)) { + sif::warning << "ArcsecJsonBase::init: JSON file " << filename << " does not exist" + << std::endl; + return JSON_FILE_NOT_EXISTS; + } + createJsonObject(filename); + result = initSet(setName); + if (result != RETURN_OK) { + return result; + } + return RETURN_OK; + } + + /** + * @brief Reads the value of a parameter from a json set + * + * @param name The name of the parameter + * @param value The string representation of the read value + * + * @return RETURN_OK if successful, otherwise PARAM_NOT_EXISTS + */ + ReturnValue_t getParam(const std::string name, std::string& value) { + for (json::iterator it = set.begin(); it != set.end(); ++it) { + if ((*it)[arcseckeys::NAME] == name) { + value = (*it)[arcseckeys::VALUE]; + return RETURN_OK; + } + } + return PARAM_NOT_EXISTS; + } + + /** + * @brief This function adds a float represented as string to a buffer + * + * @param value The float in string representation to add + * @param buffer Pointer to the buffer the float will be written to + */ + void addfloat(const std::string value, uint8_t* buffer) { + float param = std::stof(value); + std::memcpy(buffer, ¶m, sizeof(param)); + } + + /** + * @brief This function adds a uint8_t represented as string to a buffer + * + * @param value The uint8_t in string representation to add + * @param buffer Pointer to the buffer the uint8_t will be written to + */ + void adduint8(const std::string value, uint8_t* buffer) { + uint8_t param = std::stoi(value); + std::memcpy(buffer, ¶m, sizeof(param)); + } + + /** + * @brief This function adds a uint32_t represented as string to a buffer + * + * @param value The uint32_t in string representation to add + * @param buffer Pointer to the buffer the uint32_t will be written to + */ + void adduint32(const std::string value, uint8_t* buffer) { + uint32_t param = std::stoi(value); + std::memcpy(buffer, ¶m, sizeof(param)); + } + + void addSetParamHeader(uint8_t* buffer, uint8_t setId) { + *buffer = static_cast(TMTC_SETPARAMREQ); + *(buffer + 1) = setId; + } + +private: + + void createJsonObject(const std::string fullname) { + json j; + std::ifstream file(fullname); + file >> j; + file.close(); + properties = j[arcseckeys::PROPERTIES]; + } + + /** + * @brief Extracts the json set object form the json file + * + * @param setName The name of the set to create the json object from + */ + ReturnValue_t initSet(std::string setName) { + for (json::iterator it = properties.begin(); it != properties.end(); ++it) { + if ((*it)["name"] == setName) { + set = (*it)["fields"]; + return RETURN_OK; + } + } + return SET_NOT_EXISTS; + } + +json properties; +json set; +}; + +/** + * @brief Generates command to set the limit parameters + * + */ +class Limits : public ArcsecJsonBase { +public: + + static const size_t COMMAND_SIZE = 43; + + Limits() {} + + /** + * @brief Fills a buffer with the tracking parameters + * + * @param fullname The name including the absolute path of the json file containing the + * limits parameters to set. + * @param buffer Pointer to the buffer the command will be written to + */ + ReturnValue_t create(std::string fullname, uint8_t* buffer) { + ReturnValue_t result = RETURN_OK; + result = init(fullname, arcseckeys::LIMITS); + if (result != RETURN_OK) { + return result; + } + result = createCommand(buffer); + return result; + } + +private: + ReturnValue_t createCommand(uint8_t* buffer) { + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::LIMITS); + offset = 2; + result = getParam(arcseckeys::ACTION, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::FPGA18CURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FPGA25CURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FPGA10CURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MCUCURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CMOS21CURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CMOSPIXCURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CMOS33CURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CMOSVRESCURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CMOS_TEMPERATURE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MCU_TEMPERATURE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + return RETURN_OK; + } +}; + +/** + * @brief Generates the command to configure the tracking algorithm. + * + */ +class Tracking : public ArcsecJsonBase { +public: + + static const size_t COMMAND_SIZE = 15; + + Tracking() {} + /** + * @brief Fills a buffer with the tracking parameters + * + * @param fullname The name including the absolute path of the json file containing the + * tracking parameters to set. + * @param buffer Pointer to the buffer the command will be written to + */ + ReturnValue_t create(std::string fullname, uint8_t* buffer) { + ReturnValue_t result = RETURN_OK; + result = init(fullname, arcseckeys::TRACKING); + if (result != RETURN_OK) { + return result; + } + result = createCommand(buffer); + return result; + } + +private: + ReturnValue_t createCommand(uint8_t* buffer) { + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::TRACKING); + offset = 2; + result = getParam(arcseckeys::THIN_LIMIT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::OUTLIER_THRESHOLD, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::OUTLIER_THRESHOLD_QUEST, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::TRACKER_CHOICE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + return RETURN_OK; + } + +}; + +#endif /* BSP_Q7S_DEVICES_DEVICEDEFINITIONS_STARTRACKERJSONCOMMANDS_H_ */ diff --git a/bsp_q7s/memory/SdCardManager.cpp b/bsp_q7s/memory/SdCardManager.cpp index ea16b672..8a3d11f2 100644 --- a/bsp_q7s/memory/SdCardManager.cpp +++ b/bsp_q7s/memory/SdCardManager.cpp @@ -457,8 +457,8 @@ void SdCardManager::setPrintCommandOutput(bool print) { bool SdCardManager::isSdCardMounted(sd::SdCard sdCard) { SdCardManager::SdStatePair active; - ReturnValue_t result = sdcMan->getSdCardActiveStatus(active); - if (result != RETURN_OK) { + ReturnValue_t result = this->getSdCardActiveStatus(active); + if (result != HasReturnvaluesIF::RETURN_OK) { sif::debug << "SdCardManager::isSdCardMounted: Failed to get SD card active state"; return false; } diff --git a/common/config/commonClassIds.h b/common/config/commonClassIds.h index a47e97d1..fc2bffb2 100644 --- a/common/config/commonClassIds.h +++ b/common/config/commonClassIds.h @@ -23,7 +23,8 @@ enum commonClassIds: uint8_t { GOM_SPACE_HANDLER, //GOMS PLOC_MEMORY_DUMPER, //PLMEMDUMP PDEC_HANDLER, //PDEC - CCSDS_HANDLER, //PDEC + CCSDS_HANDLER, //CCSDS + ARCSEC_JSON_BASE, //JSONBASE COMMON_CLASS_ID_END // [EXPORT] : [END] }; diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index 610052e4..570dee84 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -87,7 +87,7 @@ enum commonObjects: uint32_t { RW3 = 0x44120249, RW4 = 0x44120350, - START_TRACKER = 0x44130001, + STAR_TRACKER = 0x44130001, PLOC_UPDATER = 0x44330000, PLOC_MEMORY_DUMPER = 0x44330001, diff --git a/generators/bsp_q7s_events.csv b/generators/bsp_q7s_events.csv index 8dfa9e78..fad7c714 100644 --- a/generators/bsp_q7s_events.csv +++ b/generators/bsp_q7s_events.csv @@ -1,120 +1,130 @@ -2200;STORE_SEND_WRITE_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2201;STORE_WRITE_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2202;STORE_SEND_READ_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2203;STORE_READ_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2204;UNEXPECTED_MSG;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2205;STORING_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2206;TM_DUMP_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2207;STORE_INIT_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2208;STORE_INIT_EMPTY;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2209;STORE_CONTENT_CORRUPTED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2210;STORE_INITIALIZE;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2211;INIT_DONE;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2212;DUMP_FINISHED;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2213;DELETION_FINISHED;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2214;DELETION_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2215;AUTO_CATALOGS_SENDING_FAILED;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2600;GET_DATA_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/storagemanager/StorageManagerIF.h -2601;STORE_DATA_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/storagemanager/StorageManagerIF.h -2800;DEVICE_BUILDING_COMMAND_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2801;DEVICE_SENDING_COMMAND_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2802;DEVICE_REQUESTING_REPLY_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2803;DEVICE_READING_REPLY_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2804;DEVICE_INTERPRETING_REPLY_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2805;DEVICE_MISSED_REPLY;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2806;DEVICE_UNKNOWN_REPLY;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2807;DEVICE_UNREQUESTED_REPLY;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2808;INVALID_DEVICE_COMMAND;LOW;Indicates a SW bug in child class.;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2809;MONITORING_LIMIT_EXCEEDED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2810;MONITORING_AMBIGUOUS;HIGH;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -4201;FUSE_CURRENT_HIGH;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/power/Fuse.h -4202;FUSE_WENT_OFF;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/power/Fuse.h -4204;POWER_ABOVE_HIGH_LIMIT;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/power/Fuse.h -4205;POWER_BELOW_LOW_LIMIT;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/power/Fuse.h -4300;SWITCH_WENT_OFF;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/power/PowerSwitchIF.h -5000;HEATER_ON;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/thermal/Heater.h -5001;HEATER_OFF;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/thermal/Heater.h -5002;HEATER_TIMEOUT;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/thermal/Heater.h -5003;HEATER_STAYED_ON;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/thermal/Heater.h -5004;HEATER_STAYED_OFF;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/thermal/Heater.h -5200;TEMP_SENSOR_HIGH;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/thermal/AbstractTemperatureSensor.h -5201;TEMP_SENSOR_LOW;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/thermal/AbstractTemperatureSensor.h -5202;TEMP_SENSOR_GRADIENT;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/thermal/AbstractTemperatureSensor.h -5901;COMPONENT_TEMP_LOW;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h -5902;COMPONENT_TEMP_HIGH;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h -5903;COMPONENT_TEMP_OOL_LOW;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h -5904;COMPONENT_TEMP_OOL_HIGH;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h -5905;TEMP_NOT_IN_OP_RANGE;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h -7101;FDIR_CHANGED_STATE;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/fdir/FailureIsolationBase.h -7102;FDIR_STARTS_RECOVERY;MEDIUM;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/fdir/FailureIsolationBase.h -7103;FDIR_TURNS_OFF_DEVICE;MEDIUM;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/fdir/FailureIsolationBase.h -7201;MONITOR_CHANGED_STATE;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h -7202;VALUE_BELOW_LOW_LIMIT;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h -7203;VALUE_ABOVE_HIGH_LIMIT;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h -7204;VALUE_OUT_OF_RANGE;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h -7301;SWITCHING_TM_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/datapool/HkSwitchHelper.h -7400;CHANGING_MODE;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/modes/HasModesIF.h -7401;MODE_INFO;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/modes/HasModesIF.h -7402;FALLBACK_FAILED;HIGH;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/modes/HasModesIF.h -7403;MODE_TRANSITION_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/modes/HasModesIF.h -7404;CANT_KEEP_MODE;HIGH;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/modes/HasModesIF.h -7405;OBJECT_IN_INVALID_MODE;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/modes/HasModesIF.h -7406;FORCING_MODE;MEDIUM;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/modes/HasModesIF.h -7407;MODE_CMD_REJECTED;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/modes/HasModesIF.h -7506;HEALTH_INFO;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/health/HasHealthIF.h -7507;CHILD_CHANGED_HEALTH;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/health/HasHealthIF.h -7508;CHILD_PROBLEMS;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/health/HasHealthIF.h -7509;OVERWRITING_HEALTH;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/health/HasHealthIF.h -7510;TRYING_RECOVERY;MEDIUM;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/health/HasHealthIF.h -7511;RECOVERY_STEP;MEDIUM;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/health/HasHealthIF.h -7512;RECOVERY_DONE;MEDIUM;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/health/HasHealthIF.h -7900;RF_AVAILABLE;INFO;A RF available signal was detected. P1: raw RFA state, P2: 0;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h -7901;RF_LOST;INFO;A previously found RF available signal was lost. P1: raw RFA state, P2: 0;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h -7902;BIT_LOCK;INFO;A Bit Lock signal. Was detected. P1: raw BLO state, P2: 0;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h -7903;BIT_LOCK_LOST;INFO;A previously found Bit Lock signal was lost. P1: raw BLO state, P2: 0;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h -7905;FRAME_PROCESSING_FAILED;LOW;The CCSDS Board could not interpret a TC;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h -8900;CLOCK_SET;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/pus/Service9TimeManagement.h -8901;CLOCK_SET_FAILURE;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/pus/Service9TimeManagement.h -9700;TEST;INFO;;/home/eive/EIVE/Robin/eive-obsw/fsfw/src/fsfw/pus/Service17Test.h -10600;CHANGE_OF_SETUP_PARAMETER;LOW;;/home/eive/EIVE/Robin/eive-obsw/fsfw/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h -10900;GPIO_PULL_HIGH_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/linux/devices/HeaterHandler.h -10901;GPIO_PULL_LOW_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/linux/devices/HeaterHandler.h -10902;SWITCH_ALREADY_ON;LOW;;/home/eive/EIVE/Robin/eive-obsw/linux/devices/HeaterHandler.h -10903;SWITCH_ALREADY_OFF;LOW;;/home/eive/EIVE/Robin/eive-obsw/linux/devices/HeaterHandler.h -10904;MAIN_SWITCH_TIMEOUT;LOW;;/home/eive/EIVE/Robin/eive-obsw/linux/devices/HeaterHandler.h -11000;MAIN_SWITCH_ON_TIMEOUT;LOW;;/home/eive/EIVE/Robin/eive-obsw/linux/devices/SolarArrayDeploymentHandler.h -11001;MAIN_SWITCH_OFF_TIMEOUT;LOW;;/home/eive/EIVE/Robin/eive-obsw/linux/devices/SolarArrayDeploymentHandler.h -11002;DEPLOYMENT_FAILED;HIGH;;/home/eive/EIVE/Robin/eive-obsw/linux/devices/SolarArrayDeploymentHandler.h -11003;DEPL_SA1_GPIO_SWTICH_ON_FAILED;HIGH;;/home/eive/EIVE/Robin/eive-obsw/linux/devices/SolarArrayDeploymentHandler.h -11004;DEPL_SA2_GPIO_SWTICH_ON_FAILED;HIGH;;/home/eive/EIVE/Robin/eive-obsw/linux/devices/SolarArrayDeploymentHandler.h -11101;MEMORY_READ_RPT_CRC_FAILURE;LOW;;/home/eive/EIVE/Robin/eive-obsw/mission/devices/PlocMPSoCHandler.h -11102;ACK_FAILURE;LOW;;/home/eive/EIVE/Robin/eive-obsw/mission/devices/PlocMPSoCHandler.h -11103;EXE_FAILURE;LOW;;/home/eive/EIVE/Robin/eive-obsw/mission/devices/PlocMPSoCHandler.h -11104;CRC_FAILURE_EVENT;LOW;;/home/eive/EIVE/Robin/eive-obsw/mission/devices/PlocMPSoCHandler.h -11201;SELF_TEST_I2C_FAILURE;LOW;Get self test result returns I2C failure P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;/home/eive/EIVE/Robin/eive-obsw/mission/devices/IMTQHandler.h -11202;SELF_TEST_SPI_FAILURE;LOW;Get self test result returns SPI failure. This concerns the MTM connectivity. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;/home/eive/EIVE/Robin/eive-obsw/mission/devices/IMTQHandler.h -11203;SELF_TEST_ADC_FAILURE;LOW;Get self test result returns failure in measurement of current and temperature. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;/home/eive/EIVE/Robin/eive-obsw/mission/devices/IMTQHandler.h -11204;SELF_TEST_PWM_FAILURE;LOW;Get self test result returns PWM failure which concerns the coil actuation. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;/home/eive/EIVE/Robin/eive-obsw/mission/devices/IMTQHandler.h -11205;SELF_TEST_TC_FAILURE;LOW;Get self test result returns TC failure (system failure) P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;/home/eive/EIVE/Robin/eive-obsw/mission/devices/IMTQHandler.h -11206;SELF_TEST_MTM_RANGE_FAILURE;LOW;Get self test result returns failure that MTM values were outside of the expected range. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;/home/eive/EIVE/Robin/eive-obsw/mission/devices/IMTQHandler.h -11207;SELF_TEST_COIL_CURRENT_FAILURE;LOW;Get self test result returns failure indicating that the coil current was outside of the expected range P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;/home/eive/EIVE/Robin/eive-obsw/mission/devices/IMTQHandler.h -11208;INVALID_ERROR_BYTE;LOW;Received invalid error byte. This indicates an error of the communication link between IMTQ and OBC.;/home/eive/EIVE/Robin/eive-obsw/mission/devices/IMTQHandler.h -11301;ERROR_STATE;HIGH;Reaction wheel signals an error state;/home/eive/EIVE/Robin/eive-obsw/mission/devices/RwHandler.h -11501;SUPV_MEMORY_READ_RPT_CRC_FAILURE;LOW;PLOC supervisor crc failure in telemetry packet;/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/devices/PlocSupervisorHandler.h -11502;SUPV_ACK_FAILURE;LOW;PLOC supervisor received acknowledgment failure report;/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/devices/PlocSupervisorHandler.h -11503;SUPV_EXE_FAILURE;LOW;PLOC received execution failure report;/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/devices/PlocSupervisorHandler.h -11504;SUPV_CRC_FAILURE_EVENT;LOW;PLOC supervisor reply has invalid crc;/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/devices/PlocSupervisorHandler.h -11600;SANITIZATION_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/memory/SdCardManager.h -11700;UPDATE_FILE_NOT_EXISTS;LOW;;/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/devices/PlocUpdater.h -11701;ACTION_COMMANDING_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/devices/PlocUpdater.h -11702;UPDATE_AVAILABLE_FAILED;LOW;Supervisor handler replied action message indicating a command execution failure of the update available command;/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/devices/PlocUpdater.h -11703;UPDATE_TRANSFER_FAILED;LOW;Supervisor handler failed to transfer an update space packet. P1: Parameter holds the number of update packets already sent (inclusive the failed packet);/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/devices/PlocUpdater.h -11704;UPDATE_VERIFY_FAILED;LOW;Supervisor failed to execute the update verify command.;/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/devices/PlocUpdater.h -11705;UPDATE_FINISHED;INFO;MPSoC update successful completed;/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/devices/PlocUpdater.h -11800;SEND_MRAM_DUMP_FAILED;LOW;;/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/devices/PlocMemoryDumper.h -11801;MRAM_DUMP_FAILED;LOW;Received completion failure report form PLOC supervisor handler P1: MRAM start address of failing dump command;/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/devices/PlocMemoryDumper.h -11802;MRAM_DUMP_FINISHED;LOW;MRAM dump finished successfully;/home/eive/EIVE/Robin/eive-obsw/bsp_q7s/devices/PlocMemoryDumper.h -11901;INVALID_TC_FRAME;HIGH;;/home/eive/EIVE/Robin/eive-obsw/linux/obc/PdecHandler.h -11902;INVALID_FAR;HIGH;Read invalid FAR from PDEC after startup;/home/eive/EIVE/Robin/eive-obsw/linux/obc/PdecHandler.h -11903;CARRIER_LOCK;INFO;Carrier lock detected;/home/eive/EIVE/Robin/eive-obsw/linux/obc/PdecHandler.h -11904;BIT_LOCK_PDEC;INFO;Bit lock detected (data valid);/home/eive/EIVE/Robin/eive-obsw/linux/obc/PdecHandler.h +2200;STORE_SEND_WRITE_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2201;STORE_WRITE_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2202;STORE_SEND_READ_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2203;STORE_READ_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2204;UNEXPECTED_MSG;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2205;STORING_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2206;TM_DUMP_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2207;STORE_INIT_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2208;STORE_INIT_EMPTY;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2209;STORE_CONTENT_CORRUPTED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2210;STORE_INITIALIZE;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2211;INIT_DONE;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2212;DUMP_FINISHED;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2213;DELETION_FINISHED;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2214;DELETION_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2215;AUTO_CATALOGS_SENDING_FAILED;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2600;GET_DATA_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/storagemanager/StorageManagerIF.h +2601;STORE_DATA_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/storagemanager/StorageManagerIF.h +2800;DEVICE_BUILDING_COMMAND_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2801;DEVICE_SENDING_COMMAND_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2802;DEVICE_REQUESTING_REPLY_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2803;DEVICE_READING_REPLY_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2804;DEVICE_INTERPRETING_REPLY_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2805;DEVICE_MISSED_REPLY;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2806;DEVICE_UNKNOWN_REPLY;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2807;DEVICE_UNREQUESTED_REPLY;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2808;INVALID_DEVICE_COMMAND;LOW;Indicates a SW bug in child class.;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2809;MONITORING_LIMIT_EXCEEDED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2810;MONITORING_AMBIGUOUS;HIGH;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +4201;FUSE_CURRENT_HIGH;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/power/Fuse.h +4202;FUSE_WENT_OFF;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/power/Fuse.h +4204;POWER_ABOVE_HIGH_LIMIT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/power/Fuse.h +4205;POWER_BELOW_LOW_LIMIT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/power/Fuse.h +4300;SWITCH_WENT_OFF;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/power/PowerSwitchIF.h +5000;HEATER_ON;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/Heater.h +5001;HEATER_OFF;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/Heater.h +5002;HEATER_TIMEOUT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/Heater.h +5003;HEATER_STAYED_ON;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/Heater.h +5004;HEATER_STAYED_OFF;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/Heater.h +5200;TEMP_SENSOR_HIGH;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/AbstractTemperatureSensor.h +5201;TEMP_SENSOR_LOW;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/AbstractTemperatureSensor.h +5202;TEMP_SENSOR_GRADIENT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/AbstractTemperatureSensor.h +5901;COMPONENT_TEMP_LOW;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h +5902;COMPONENT_TEMP_HIGH;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h +5903;COMPONENT_TEMP_OOL_LOW;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h +5904;COMPONENT_TEMP_OOL_HIGH;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h +5905;TEMP_NOT_IN_OP_RANGE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h +7101;FDIR_CHANGED_STATE;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/fdir/FailureIsolationBase.h +7102;FDIR_STARTS_RECOVERY;MEDIUM;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/fdir/FailureIsolationBase.h +7103;FDIR_TURNS_OFF_DEVICE;MEDIUM;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/fdir/FailureIsolationBase.h +7201;MONITOR_CHANGED_STATE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h +7202;VALUE_BELOW_LOW_LIMIT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h +7203;VALUE_ABOVE_HIGH_LIMIT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h +7204;VALUE_OUT_OF_RANGE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h +7301;SWITCHING_TM_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/datapool/HkSwitchHelper.h +7400;CHANGING_MODE;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h +7401;MODE_INFO;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h +7402;FALLBACK_FAILED;HIGH;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h +7403;MODE_TRANSITION_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h +7404;CANT_KEEP_MODE;HIGH;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h +7405;OBJECT_IN_INVALID_MODE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h +7406;FORCING_MODE;MEDIUM;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h +7407;MODE_CMD_REJECTED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h +7506;HEALTH_INFO;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h +7507;CHILD_CHANGED_HEALTH;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h +7508;CHILD_PROBLEMS;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h +7509;OVERWRITING_HEALTH;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h +7510;TRYING_RECOVERY;MEDIUM;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h +7511;RECOVERY_STEP;MEDIUM;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h +7512;RECOVERY_DONE;MEDIUM;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h +7900;RF_AVAILABLE;INFO;A RF available signal was detected. P1: raw RFA state, P2: 0;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h +7901;RF_LOST;INFO;A previously found RF available signal was lost. P1: raw RFA state, P2: 0;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h +7902;BIT_LOCK;INFO;A Bit Lock signal. Was detected. P1: raw BLO state, P2: 0;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h +7903;BIT_LOCK_LOST;INFO;A previously found Bit Lock signal was lost. P1: raw BLO state, P2: 0;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h +7905;FRAME_PROCESSING_FAILED;LOW;The CCSDS Board could not interpret a TC;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h +8900;CLOCK_SET;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/pus/Service9TimeManagement.h +8901;CLOCK_SET_FAILURE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/pus/Service9TimeManagement.h +9700;TEST;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/pus/Service17Test.h +10600;CHANGE_OF_SETUP_PARAMETER;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h +10900;GPIO_PULL_HIGH_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/devices/HeaterHandler.h +10901;GPIO_PULL_LOW_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/devices/HeaterHandler.h +10902;SWITCH_ALREADY_ON;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/devices/HeaterHandler.h +10903;SWITCH_ALREADY_OFF;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/devices/HeaterHandler.h +10904;MAIN_SWITCH_TIMEOUT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/devices/HeaterHandler.h +11000;MAIN_SWITCH_ON_TIMEOUT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/devices/SolarArrayDeploymentHandler.h +11001;MAIN_SWITCH_OFF_TIMEOUT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/devices/SolarArrayDeploymentHandler.h +11002;DEPLOYMENT_FAILED;HIGH;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/devices/SolarArrayDeploymentHandler.h +11003;DEPL_SA1_GPIO_SWTICH_ON_FAILED;HIGH;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/devices/SolarArrayDeploymentHandler.h +11004;DEPL_SA2_GPIO_SWTICH_ON_FAILED;HIGH;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/devices/SolarArrayDeploymentHandler.h +11101;MEMORY_READ_RPT_CRC_FAILURE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/PlocMPSoCHandler.h +11102;ACK_FAILURE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/PlocMPSoCHandler.h +11103;EXE_FAILURE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/PlocMPSoCHandler.h +11104;CRC_FAILURE_EVENT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/PlocMPSoCHandler.h +11201;SELF_TEST_I2C_FAILURE;LOW;Get self test result returns I2C failure P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h +11202;SELF_TEST_SPI_FAILURE;LOW;Get self test result returns SPI failure. This concerns the MTM connectivity. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h +11203;SELF_TEST_ADC_FAILURE;LOW;Get self test result returns failure in measurement of current and temperature. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h +11204;SELF_TEST_PWM_FAILURE;LOW;Get self test result returns PWM failure which concerns the coil actuation. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h +11205;SELF_TEST_TC_FAILURE;LOW;Get self test result returns TC failure (system failure) P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h +11206;SELF_TEST_MTM_RANGE_FAILURE;LOW;Get self test result returns failure that MTM values were outside of the expected range. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h +11207;SELF_TEST_COIL_CURRENT_FAILURE;LOW;Get self test result returns failure indicating that the coil current was outside of the expected range P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h +11208;INVALID_ERROR_BYTE;LOW;Received invalid error byte. This indicates an error of the communication link between IMTQ and OBC.;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h +11301;ERROR_STATE;HIGH;Reaction wheel signals an error state;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/RwHandler.h +11501;SUPV_MEMORY_READ_RPT_CRC_FAILURE;LOW;PLOC supervisor crc failure in telemetry packet;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h +11502;SUPV_ACK_FAILURE;LOW;PLOC supervisor received acknowledgment failure report;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h +11503;SUPV_EXE_FAILURE;LOW;PLOC received execution failure report;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h +11504;SUPV_CRC_FAILURE_EVENT;LOW;PLOC supervisor reply has invalid crc;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h +11600;SANITIZATION_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/memory/SdCardManager.h +11700;UPDATE_FILE_NOT_EXISTS;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h +11701;ACTION_COMMANDING_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h +11702;UPDATE_AVAILABLE_FAILED;LOW;Supervisor handler replied action message indicating a command execution failure of the update available command;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h +11703;UPDATE_TRANSFER_FAILED;LOW;Supervisor handler failed to transfer an update space packet. P1: Parameter holds the number of update packets already sent (inclusive the failed packet);C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h +11704;UPDATE_VERIFY_FAILED;LOW;Supervisor failed to execute the update verify command.;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h +11705;UPDATE_FINISHED;INFO;MPSoC update successful completed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h +11800;SEND_MRAM_DUMP_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocMemoryDumper.h +11801;MRAM_DUMP_FAILED;LOW;Received completion failure report form PLOC supervisor handler P1: MRAM start address of failing dump command;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocMemoryDumper.h +11802;MRAM_DUMP_FINISHED;LOW;MRAM dump finished successfully;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocMemoryDumper.h +11901;INVALID_TC_FRAME;HIGH;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/obc/PdecHandler.h +11902;INVALID_FAR;HIGH;Read invalid FAR from PDEC after startup;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/obc/PdecHandler.h +11903;CARRIER_LOCK;INFO;Carrier lock detected;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/obc/PdecHandler.h +11904;BIT_LOCK_PDEC;INFO;Bit lock detected (data valid);C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/obc/PdecHandler.h +12000;IMAGE_FILE_NOT_EXISTS;LOW;Try to upload image but specified image does not exist;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/StrImageLoader.h +12001;SENDING_UPLOAD_PACKET_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/StrImageLoader.h +12002;UPLOAD_REQUESTING_MSG_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/StrImageLoader.h +12003;IMAGE_UPLOAD_SUCCESSFUL;LOW;Uploading image to star tracker was successful;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/StrImageLoader.h +12004;UPLOAD_READING_REPLY_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/StrImageLoader.h +12005;UPLOAD_COM_ERROR;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/StrImageLoader.h +12006;NO_REPLY;LOW;Star tracker did not send replies (maybe device is powered off)P1: Position of upload packet for which no reply was sent;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/StrImageLoader.h +12007;INVALID_TYPE_ID;LOW;Received reply with invalid type ID;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/StrImageLoader.h +12008;STATUS_ERROR;LOW;Status field in reply signals error;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/StrImageLoader.h +12009;DEC_ERROR;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/StrImageLoader.h diff --git a/generators/bsp_q7s_objects.csv b/generators/bsp_q7s_objects.csv index fded183b..b0fe0658 100644 --- a/generators/bsp_q7s_objects.csv +++ b/generators/bsp_q7s_objects.csv @@ -27,7 +27,7 @@ 0x44120309;MGM_3_RM3100_HANDLER 0x44120313;GYRO_3_L3G_HANDLER 0x44120350;RW4 -0x44130001;START_TRACKER +0x44130001;STAR_TRACKER 0x44130045;GPS0_HANDLER 0x44130146;GPS1_HANDLER 0x44140014;IMTQ_HANDLER @@ -39,6 +39,7 @@ 0x443200A5;RAD_SENSOR 0x44330000;PLOC_UPDATER 0x44330001;PLOC_MEMORY_DUMPER +0x44330002;STR_IMG_LOADER 0x44330015;PLOC_MPSOC_HANDLER 0x44330016;PLOC_SUPERVISOR_HANDLER 0x444100A2;SOLAR_ARRAY_DEPL_HANDLER diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp index 943468c5..dea56991 100644 --- a/generators/events/translateEvents.cpp +++ b/generators/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 120 translations. + * @brief Auto-generated event translation file. Contains 130 translations. * @details - * Generated on: 2021-11-25 14:09:00 + * Generated on: 2021-12-04 11:03:12 */ #include "translateEvents.h" @@ -125,6 +125,16 @@ const char *INVALID_TC_FRAME_STRING = "INVALID_TC_FRAME"; const char *INVALID_FAR_STRING = "INVALID_FAR"; const char *CARRIER_LOCK_STRING = "CARRIER_LOCK"; const char *BIT_LOCK_PDEC_STRING = "BIT_LOCK_PDEC"; +const char *IMAGE_FILE_NOT_EXISTS_STRING = "IMAGE_FILE_NOT_EXISTS"; +const char *SENDING_UPLOAD_PACKET_FAILED_STRING = "SENDING_UPLOAD_PACKET_FAILED"; +const char *UPLOAD_REQUESTING_MSG_FAILED_STRING = "UPLOAD_REQUESTING_MSG_FAILED"; +const char *IMAGE_UPLOAD_SUCCESSFUL_STRING = "IMAGE_UPLOAD_SUCCESSFUL"; +const char *UPLOAD_READING_REPLY_FAILED_STRING = "UPLOAD_READING_REPLY_FAILED"; +const char *UPLOAD_COM_ERROR_STRING = "UPLOAD_COM_ERROR"; +const char *NO_REPLY_STRING = "NO_REPLY"; +const char *INVALID_TYPE_ID_STRING = "INVALID_TYPE_ID"; +const char *STATUS_ERROR_STRING = "STATUS_ERROR"; +const char *DEC_ERROR_STRING = "DEC_ERROR"; const char * translateEvents(Event event) { switch( (event & 0xffff) ) { @@ -368,6 +378,26 @@ const char * translateEvents(Event event) { return CARRIER_LOCK_STRING; case(11904): return BIT_LOCK_PDEC_STRING; + case(12000): + return IMAGE_FILE_NOT_EXISTS_STRING; + case(12001): + return SENDING_UPLOAD_PACKET_FAILED_STRING; + case(12002): + return UPLOAD_REQUESTING_MSG_FAILED_STRING; + case(12003): + return IMAGE_UPLOAD_SUCCESSFUL_STRING; + case(12004): + return UPLOAD_READING_REPLY_FAILED_STRING; + case(12005): + return UPLOAD_COM_ERROR_STRING; + case(12006): + return NO_REPLY_STRING; + case(12007): + return INVALID_TYPE_ID_STRING; + case(12008): + return STATUS_ERROR_STRING; + case(12009): + return DEC_ERROR_STRING; default: return "UNKNOWN_EVENT"; } diff --git a/generators/objects/translateObjects.cpp b/generators/objects/translateObjects.cpp index 48eb29e7..87e10da9 100644 --- a/generators/objects/translateObjects.cpp +++ b/generators/objects/translateObjects.cpp @@ -1,8 +1,8 @@ /** * @brief Auto-generated object translation file. * @details - * Contains 112 translations. - * Generated on: 2021-11-22 17:04:51 + * Contains 113 translations. + * Generated on: 2021-12-04 11:03:17 */ #include "translateObjects.h" @@ -35,7 +35,7 @@ const char *RW3_STRING = "RW3"; const char *MGM_3_RM3100_HANDLER_STRING = "MGM_3_RM3100_HANDLER"; const char *GYRO_3_L3G_HANDLER_STRING = "GYRO_3_L3G_HANDLER"; const char *RW4_STRING = "RW4"; -const char *START_TRACKER_STRING = "START_TRACKER"; +const char *STAR_TRACKER_STRING = "STAR_TRACKER"; const char *GPS0_HANDLER_STRING = "GPS0_HANDLER"; const char *GPS1_HANDLER_STRING = "GPS1_HANDLER"; const char *IMTQ_HANDLER_STRING = "IMTQ_HANDLER"; @@ -47,6 +47,7 @@ const char *ACU_HANDLER_STRING = "ACU_HANDLER"; const char *RAD_SENSOR_STRING = "RAD_SENSOR"; const char *PLOC_UPDATER_STRING = "PLOC_UPDATER"; const char *PLOC_MEMORY_DUMPER_STRING = "PLOC_MEMORY_DUMPER"; +const char *STR_IMG_LOADER_STRING = "STR_IMG_LOADER"; const char *PLOC_MPSOC_HANDLER_STRING = "PLOC_MPSOC_HANDLER"; const char *PLOC_SUPERVISOR_HANDLER_STRING = "PLOC_SUPERVISOR_HANDLER"; const char *SOLAR_ARRAY_DEPL_HANDLER_STRING = "SOLAR_ARRAY_DEPL_HANDLER"; @@ -180,7 +181,7 @@ const char* translateObject(object_id_t object) { case 0x44120350: return RW4_STRING; case 0x44130001: - return START_TRACKER_STRING; + return STAR_TRACKER_STRING; case 0x44130045: return GPS0_HANDLER_STRING; case 0x44130146: @@ -203,6 +204,8 @@ const char* translateObject(object_id_t object) { return PLOC_UPDATER_STRING; case 0x44330001: return PLOC_MEMORY_DUMPER_STRING; + case 0x44330002: + return STR_IMG_LOADER_STRING; case 0x44330015: return PLOC_MPSOC_HANDLER_STRING; case 0x44330016: diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index 943468c5..dea56991 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 120 translations. + * @brief Auto-generated event translation file. Contains 130 translations. * @details - * Generated on: 2021-11-25 14:09:00 + * Generated on: 2021-12-04 11:03:12 */ #include "translateEvents.h" @@ -125,6 +125,16 @@ const char *INVALID_TC_FRAME_STRING = "INVALID_TC_FRAME"; const char *INVALID_FAR_STRING = "INVALID_FAR"; const char *CARRIER_LOCK_STRING = "CARRIER_LOCK"; const char *BIT_LOCK_PDEC_STRING = "BIT_LOCK_PDEC"; +const char *IMAGE_FILE_NOT_EXISTS_STRING = "IMAGE_FILE_NOT_EXISTS"; +const char *SENDING_UPLOAD_PACKET_FAILED_STRING = "SENDING_UPLOAD_PACKET_FAILED"; +const char *UPLOAD_REQUESTING_MSG_FAILED_STRING = "UPLOAD_REQUESTING_MSG_FAILED"; +const char *IMAGE_UPLOAD_SUCCESSFUL_STRING = "IMAGE_UPLOAD_SUCCESSFUL"; +const char *UPLOAD_READING_REPLY_FAILED_STRING = "UPLOAD_READING_REPLY_FAILED"; +const char *UPLOAD_COM_ERROR_STRING = "UPLOAD_COM_ERROR"; +const char *NO_REPLY_STRING = "NO_REPLY"; +const char *INVALID_TYPE_ID_STRING = "INVALID_TYPE_ID"; +const char *STATUS_ERROR_STRING = "STATUS_ERROR"; +const char *DEC_ERROR_STRING = "DEC_ERROR"; const char * translateEvents(Event event) { switch( (event & 0xffff) ) { @@ -368,6 +378,26 @@ const char * translateEvents(Event event) { return CARRIER_LOCK_STRING; case(11904): return BIT_LOCK_PDEC_STRING; + case(12000): + return IMAGE_FILE_NOT_EXISTS_STRING; + case(12001): + return SENDING_UPLOAD_PACKET_FAILED_STRING; + case(12002): + return UPLOAD_REQUESTING_MSG_FAILED_STRING; + case(12003): + return IMAGE_UPLOAD_SUCCESSFUL_STRING; + case(12004): + return UPLOAD_READING_REPLY_FAILED_STRING; + case(12005): + return UPLOAD_COM_ERROR_STRING; + case(12006): + return NO_REPLY_STRING; + case(12007): + return INVALID_TYPE_ID_STRING; + case(12008): + return STATUS_ERROR_STRING; + case(12009): + return DEC_ERROR_STRING; default: return "UNKNOWN_EVENT"; } diff --git a/linux/fsfwconfig/objects/translateObjects.cpp b/linux/fsfwconfig/objects/translateObjects.cpp index 48eb29e7..87e10da9 100644 --- a/linux/fsfwconfig/objects/translateObjects.cpp +++ b/linux/fsfwconfig/objects/translateObjects.cpp @@ -1,8 +1,8 @@ /** * @brief Auto-generated object translation file. * @details - * Contains 112 translations. - * Generated on: 2021-11-22 17:04:51 + * Contains 113 translations. + * Generated on: 2021-12-04 11:03:17 */ #include "translateObjects.h" @@ -35,7 +35,7 @@ const char *RW3_STRING = "RW3"; const char *MGM_3_RM3100_HANDLER_STRING = "MGM_3_RM3100_HANDLER"; const char *GYRO_3_L3G_HANDLER_STRING = "GYRO_3_L3G_HANDLER"; const char *RW4_STRING = "RW4"; -const char *START_TRACKER_STRING = "START_TRACKER"; +const char *STAR_TRACKER_STRING = "STAR_TRACKER"; const char *GPS0_HANDLER_STRING = "GPS0_HANDLER"; const char *GPS1_HANDLER_STRING = "GPS1_HANDLER"; const char *IMTQ_HANDLER_STRING = "IMTQ_HANDLER"; @@ -47,6 +47,7 @@ const char *ACU_HANDLER_STRING = "ACU_HANDLER"; const char *RAD_SENSOR_STRING = "RAD_SENSOR"; const char *PLOC_UPDATER_STRING = "PLOC_UPDATER"; const char *PLOC_MEMORY_DUMPER_STRING = "PLOC_MEMORY_DUMPER"; +const char *STR_IMG_LOADER_STRING = "STR_IMG_LOADER"; const char *PLOC_MPSOC_HANDLER_STRING = "PLOC_MPSOC_HANDLER"; const char *PLOC_SUPERVISOR_HANDLER_STRING = "PLOC_SUPERVISOR_HANDLER"; const char *SOLAR_ARRAY_DEPL_HANDLER_STRING = "SOLAR_ARRAY_DEPL_HANDLER"; @@ -180,7 +181,7 @@ const char* translateObject(object_id_t object) { case 0x44120350: return RW4_STRING; case 0x44130001: - return START_TRACKER_STRING; + return STAR_TRACKER_STRING; case 0x44130045: return GPS0_HANDLER_STRING; case 0x44130146: @@ -203,6 +204,8 @@ const char* translateObject(object_id_t object) { return PLOC_UPDATER_STRING; case 0x44330001: return PLOC_MEMORY_DUMPER_STRING; + case 0x44330002: + return STR_IMG_LOADER_STRING; case 0x44330015: return PLOC_MPSOC_HANDLER_STRING; case 0x44330016: diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index b32ceb5f..6d020181 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -588,7 +588,6 @@ ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::PLOC_UPDATER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::PLOC_MEMORY_DUMPER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::STR_IMG_HELPER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); #if OBSW_ADD_PLOC_SUPERVISOR == 1 thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); @@ -650,11 +649,11 @@ ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) { #if OBSW_ADD_STAR_TRACKER == 1 uartPstEmpty = false; - thisSequence->addSlot(objects::START_TRACKER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::START_TRACKER, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::START_TRACKER, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::START_TRACKER, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::START_TRACKER, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::STAR_TRACKER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::STAR_TRACKER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::STAR_TRACKER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::STAR_TRACKER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::STAR_TRACKER, length * 0.8, DeviceHandlerIF::GET_READ); #endif if(uartPstEmpty) { diff --git a/linux/obc/PdecHandler.cpp b/linux/obc/PdecHandler.cpp index 829377d0..aa46c23c 100644 --- a/linux/obc/PdecHandler.cpp +++ b/linux/obc/PdecHandler.cpp @@ -262,7 +262,7 @@ bool PdecHandler::checkFrameAna(uint32_t pdecFar) { } case(FrameAna_t::FRAME_DIRTY): { triggerEvent(INVALID_TC_FRAME, FRAME_DIRTY); - sif::debug << "PdecHandler::checkFrameAna: Frame dirty" << std::endl; + sif::warning << "PdecHandler::checkFrameAna: Frame dirty" << std::endl; break; } case(FrameAna_t::FRAME_ILLEGAL): { @@ -314,50 +314,50 @@ void PdecHandler::handleIReason(uint32_t pdecFar, ReturnValue_t parameter1) { switch(ireason) { case(IReason_t::NO_REPORT): { triggerEvent(INVALID_TC_FRAME, parameter1, NO_REPORT); - sif::debug << "PdecHandler::handleIReason: No illegal report" << std::endl; + sif::info << "PdecHandler::handleIReason: No illegal report" << std::endl; break; } case(IReason_t::ERROR_VERSION_NUMBER): { triggerEvent(INVALID_TC_FRAME, parameter1, ERROR_VERSION_NUMBER); - sif::debug << "PdecHandler::handleIReason: Error in version number and reserved A and B " + sif::info << "PdecHandler::handleIReason: Error in version number and reserved A and B " << "fields" << std::endl; break; } case(IReason_t::ILLEGAL_COMBINATION): { triggerEvent(INVALID_TC_FRAME, parameter1, ILLEGAL_COMBINATION); - sif::debug << "PdecHandler::handleIReason: Illegal combination (AC) of bypass and control " + sif::info << "PdecHandler::handleIReason: Illegal combination (AC) of bypass and control " << "command flags" << std::endl; break; } case(IReason_t::INVALID_SC_ID): { triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_SC_ID); - sif::debug << "PdecHandler::handleIReason: Invalid spacecraft identifier " << std::endl; + sif::info << "PdecHandler::handleIReason: Invalid spacecraft identifier " << std::endl; break; } case(IReason_t::INVALID_VC_ID_MSB): { triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_VC_ID_MSB); - sif::debug << "PdecHandler::handleIReason: VC identifier bit 0 to 4 did not match " + sif::info << "PdecHandler::handleIReason: VC identifier bit 0 to 4 did not match " << std::endl; break; } case(IReason_t::INVALID_VC_ID_LSB): { triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_VC_ID_LSB); - sif::debug << "PdecHandler::handleIReason: VC identifier bit 5 did not match " << std::endl; + sif::info << "PdecHandler::handleIReason: VC identifier bit 5 did not match " << std::endl; break; } case(IReason_t::NS_NOT_ZERO): { triggerEvent(INVALID_TC_FRAME, parameter1, NS_NOT_ZERO); - sif::debug << "PdecHandler::handleIReason: N(S) of BC or BD frame not set to all zeros" + sif::info << "PdecHandler::handleIReason: N(S) of BC or BD frame not set to all zeros" << std::endl; break; } case(IReason_t::INCORRECT_BC_CC): { triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_BC_CC); - sif::debug << "PdecHandler::handleIReason: Invalid BC control command format" << std::endl; + sif::info << "PdecHandler::handleIReason: Invalid BC control command format" << std::endl; break; } default: { - sif::debug << "PdecHandler::handleIReason: Invalid reason id" << std::endl; + sif::info << "PdecHandler::handleIReason: Invalid reason id" << std::endl; break; } } @@ -373,7 +373,7 @@ void PdecHandler::handleNewTc() { } #if OBSW_DEBUG_PDEC_HANDLER == 1 unsigned int mapId = tcSegment[0] & MAP_ID_MASK; - sif::debug << "PdecHandler::handleNewTc: Received TC segment with map ID " << mapId + sif::info << "PdecHandler::handleNewTc: Received TC segment with map ID " << mapId << std::endl; printTC(tcLength); #endif /* OBSW_DEBUG_PDEC_HANDLER */ @@ -460,7 +460,7 @@ void PdecHandler::printTC(uint32_t tcLength) { tcSegmentStream << std::setfill('0') << std::setw(2) << std::hex << static_cast(tcSegment[idx]); } - sif::debug << tcSegmentStream.str() << std::endl; + sif::info << tcSegmentStream.str() << std::endl; } uint8_t PdecHandler::calcMapAddrEntry(uint8_t moduleId) { diff --git a/mission/devices/CMakeLists.txt b/mission/devices/CMakeLists.txt index dd17728c..ea3fdbea 100644 --- a/mission/devices/CMakeLists.txt +++ b/mission/devices/CMakeLists.txt @@ -14,7 +14,6 @@ target_sources(${TARGET_NAME} PUBLIC RadiationSensorHandler.cpp GyroADIS16507Handler.cpp RwHandler.cpp - StarTrackerHandler.cpp ) diff --git a/tmtc b/tmtc index bcec5df6..7b01165f 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit bcec5df6e2636e3751f7a7eb103b893dc4581c10 +Subproject commit 7b01165ff937e45e052caeb550e622a8b9df6ee2 From 58c40695aedee8c9caf11700929845497e2344cc Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 7 Dec 2021 16:30:17 +0100 Subject: [PATCH 119/465] star tracker commands, tracking, mounting, camera, blob --- bsp_q7s/core/ObjectFactory.cpp | 6 +- bsp_q7s/devices/CMakeLists.txt | 7 +- .../StarTrackerJsonCommands.h | 343 ----------- .../{ => startracker}/ArcsecDatalinkLayer.cpp | 0 .../{ => startracker}/ArcsecDatalinkLayer.h | 2 +- bsp_q7s/devices/startracker/ArcsecJsonKeys.h | 81 +++ .../startracker/ArcsecJsonParamBase.cpp | 87 +++ .../devices/startracker/ArcsecJsonParamBase.h | 144 +++++ bsp_q7s/devices/startracker/CMakeLists.txt | 7 + .../StarTrackerDefinitions.h | 4 +- .../{ => startracker}/StarTrackerHandler.cpp | 130 +++-- .../{ => startracker}/StarTrackerHandler.h | 28 +- .../startracker/StarTrackerJsonCommands.cpp | 535 ++++++++++++++++++ .../startracker/StarTrackerJsonCommands.h | 128 +++++ .../{ => startracker}/StrImageLoader.cpp | 0 .../{ => startracker}/StrImageLoader.h | 3 +- 16 files changed, 1104 insertions(+), 401 deletions(-) delete mode 100644 bsp_q7s/devices/devicedefinitions/StarTrackerJsonCommands.h rename bsp_q7s/devices/{ => startracker}/ArcsecDatalinkLayer.cpp (100%) rename bsp_q7s/devices/{ => startracker}/ArcsecDatalinkLayer.h (98%) create mode 100644 bsp_q7s/devices/startracker/ArcsecJsonKeys.h create mode 100644 bsp_q7s/devices/startracker/ArcsecJsonParamBase.cpp create mode 100644 bsp_q7s/devices/startracker/ArcsecJsonParamBase.h create mode 100644 bsp_q7s/devices/startracker/CMakeLists.txt rename bsp_q7s/devices/{devicedefinitions => startracker}/StarTrackerDefinitions.h (99%) rename bsp_q7s/devices/{ => startracker}/StarTrackerHandler.cpp (90%) rename bsp_q7s/devices/{ => startracker}/StarTrackerHandler.h (91%) create mode 100644 bsp_q7s/devices/startracker/StarTrackerJsonCommands.cpp create mode 100644 bsp_q7s/devices/startracker/StarTrackerJsonCommands.h rename bsp_q7s/devices/{ => startracker}/StrImageLoader.cpp (100%) rename bsp_q7s/devices/{ => startracker}/StrImageLoader.h (99%) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index f1d0dcf0..ccc2ea7a 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -1,7 +1,7 @@ #include #include "ObjectFactory.h" -#include "../devices/devicedefinitions/StarTrackerDefinitions.h" +#include "bsp_q7s/devices/startracker/StarTrackerDefinitions.h" #include "OBSWConfig.h" #include "devConf.h" #include "ccsdsConfig.h" @@ -18,8 +18,8 @@ #include "bsp_q7s/devices/PlocSupervisorHandler.h" #include "bsp_q7s/devices/PlocUpdater.h" #include "bsp_q7s/devices/PlocMemoryDumper.h" -#include "bsp_q7s/devices/StrImageLoader.h" -#include "bsp_q7s/devices/StarTrackerHandler.h" +#include "bsp_q7s/devices/startracker/StrImageLoader.h" +#include "bsp_q7s/devices/startracker/StarTrackerHandler.h" #include "bsp_q7s/callbacks/rwSpiCallback.h" #include "bsp_q7s/callbacks/gnssCallback.h" diff --git a/bsp_q7s/devices/CMakeLists.txt b/bsp_q7s/devices/CMakeLists.txt index edabfa96..70705e83 100644 --- a/bsp_q7s/devices/CMakeLists.txt +++ b/bsp_q7s/devices/CMakeLists.txt @@ -2,7 +2,6 @@ target_sources(${TARGET_NAME} PRIVATE PlocSupervisorHandler.cpp PlocUpdater.cpp PlocMemoryDumper.cpp - StrImageLoader.cpp - ArcsecDatalinkLayer.cpp - StarTrackerHandler.cpp -) \ No newline at end of file +) + +add_subdirectory(startracker) \ No newline at end of file diff --git a/bsp_q7s/devices/devicedefinitions/StarTrackerJsonCommands.h b/bsp_q7s/devices/devicedefinitions/StarTrackerJsonCommands.h deleted file mode 100644 index c25e1586..00000000 --- a/bsp_q7s/devices/devicedefinitions/StarTrackerJsonCommands.h +++ /dev/null @@ -1,343 +0,0 @@ -#ifndef BSP_Q7S_DEVICES_DEVICEDEFINITIONS_STARTRACKERJSONCOMMANDS_H_ -#define BSP_Q7S_DEVICES_DEVICEDEFINITIONS_STARTRACKERJSONCOMMANDS_H_ - -#include -#include -#include -#include - -#include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" -#include "bsp_q7s/devices/devicedefinitions/StarTrackerDefinitions.h" - -#include "thirdparty/arcsec_star_tracker/common/generated/tmtcstructs.h" - -using json = nlohmann::json; - -/** - * @brief This file defines a few helper classes to generate commands by means of the arcsec - * json files. - * @author J. Meier - */ - -namespace arcseckeys { - static const char PROPERTIES[] = "properties"; - static const char NAME[] = "name"; - static const char VALUE[] = "value"; - - static const char LIMITS[] = "limits"; - static const char ACTION[] = "action"; - static const char FPGA18CURRENT[] = "FPGA18Current"; - static const char FPGA25CURRENT[] = "FPGA25Current"; - static const char FPGA10CURRENT[] = "FPGA10Current"; - static const char MCUCURRENT[] = "MCUCurrent"; - static const char CMOS21CURRENT[] = "CMOS21Current"; - static const char CMOSPIXCURRENT[] = "CMOSPixCurrent"; - static const char CMOS33CURRENT[] = "CMOS33Current"; - static const char CMOSVRESCURRENT[] = "CMOSVResCurrent"; - static const char CMOS_TEMPERATURE[] = "CMOSTemperature"; - static const char MCU_TEMPERATURE[] = "MCUTemperature"; - - static const char TRACKING[] = "tracking"; - static const char THIN_LIMIT[] = "thinLimit"; - static const char OUTLIER_THRESHOLD[] = "outlierThreshold"; - static const char OUTLIER_THRESHOLD_QUEST[] = "outlierThresholdQUEST"; - static const char TRACKER_CHOICE[] = "trackerChoice"; -} - -class ArcsecJsonBase : public HasReturnvaluesIF { -public: - - static const uint8_t INTERFACE_ID = CLASS_ID::ARCSEC_JSON_BASE; - //! [EXPORT] : [COMMENT] Specified json file does not exist - static const ReturnValue_t JSON_FILE_NOT_EXISTS = MAKE_RETURN_CODE(1); - //! [EXPORT] : [COMMENT] Requested set does not exist in json file - static const ReturnValue_t SET_NOT_EXISTS = MAKE_RETURN_CODE(2); - //! [EXPORT] : [COMMENT] Requested parameter does not exist in json file - static const ReturnValue_t PARAM_NOT_EXISTS = MAKE_RETURN_CODE(3); - - /** - * @brief Constructor - * - * @param fullname Name with absolute path of json file containing the parameters to set. - */ - ArcsecJsonBase() {} - -protected: - - /** - * @brief Initializes the properties json object and the set json object - * - * @param fullname Name including absolute path to json file - * @param setName The name of the set to work on - * - * @param return JSON_FILE_NOT_EXISTS if specified file does not exist, otherwise - * RETURN_OK - */ - ReturnValue_t init(const std::string filename,std::string setName) { - ReturnValue_t result = RETURN_OK; - if(not std::filesystem::exists(filename)) { - sif::warning << "ArcsecJsonBase::init: JSON file " << filename << " does not exist" - << std::endl; - return JSON_FILE_NOT_EXISTS; - } - createJsonObject(filename); - result = initSet(setName); - if (result != RETURN_OK) { - return result; - } - return RETURN_OK; - } - - /** - * @brief Reads the value of a parameter from a json set - * - * @param name The name of the parameter - * @param value The string representation of the read value - * - * @return RETURN_OK if successful, otherwise PARAM_NOT_EXISTS - */ - ReturnValue_t getParam(const std::string name, std::string& value) { - for (json::iterator it = set.begin(); it != set.end(); ++it) { - if ((*it)[arcseckeys::NAME] == name) { - value = (*it)[arcseckeys::VALUE]; - return RETURN_OK; - } - } - return PARAM_NOT_EXISTS; - } - - /** - * @brief This function adds a float represented as string to a buffer - * - * @param value The float in string representation to add - * @param buffer Pointer to the buffer the float will be written to - */ - void addfloat(const std::string value, uint8_t* buffer) { - float param = std::stof(value); - std::memcpy(buffer, ¶m, sizeof(param)); - } - - /** - * @brief This function adds a uint8_t represented as string to a buffer - * - * @param value The uint8_t in string representation to add - * @param buffer Pointer to the buffer the uint8_t will be written to - */ - void adduint8(const std::string value, uint8_t* buffer) { - uint8_t param = std::stoi(value); - std::memcpy(buffer, ¶m, sizeof(param)); - } - - /** - * @brief This function adds a uint32_t represented as string to a buffer - * - * @param value The uint32_t in string representation to add - * @param buffer Pointer to the buffer the uint32_t will be written to - */ - void adduint32(const std::string value, uint8_t* buffer) { - uint32_t param = std::stoi(value); - std::memcpy(buffer, ¶m, sizeof(param)); - } - - void addSetParamHeader(uint8_t* buffer, uint8_t setId) { - *buffer = static_cast(TMTC_SETPARAMREQ); - *(buffer + 1) = setId; - } - -private: - - void createJsonObject(const std::string fullname) { - json j; - std::ifstream file(fullname); - file >> j; - file.close(); - properties = j[arcseckeys::PROPERTIES]; - } - - /** - * @brief Extracts the json set object form the json file - * - * @param setName The name of the set to create the json object from - */ - ReturnValue_t initSet(std::string setName) { - for (json::iterator it = properties.begin(); it != properties.end(); ++it) { - if ((*it)["name"] == setName) { - set = (*it)["fields"]; - return RETURN_OK; - } - } - return SET_NOT_EXISTS; - } - -json properties; -json set; -}; - -/** - * @brief Generates command to set the limit parameters - * - */ -class Limits : public ArcsecJsonBase { -public: - - static const size_t COMMAND_SIZE = 43; - - Limits() {} - - /** - * @brief Fills a buffer with the tracking parameters - * - * @param fullname The name including the absolute path of the json file containing the - * limits parameters to set. - * @param buffer Pointer to the buffer the command will be written to - */ - ReturnValue_t create(std::string fullname, uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - result = init(fullname, arcseckeys::LIMITS); - if (result != RETURN_OK) { - return result; - } - result = createCommand(buffer); - return result; - } - -private: - ReturnValue_t createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::LIMITS); - offset = 2; - result = getParam(arcseckeys::ACTION, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::FPGA18CURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::FPGA25CURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::FPGA10CURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MCUCURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::CMOS21CURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::CMOSPIXCURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::CMOS33CURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::CMOSVRESCURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::CMOS_TEMPERATURE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MCU_TEMPERATURE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - return RETURN_OK; - } -}; - -/** - * @brief Generates the command to configure the tracking algorithm. - * - */ -class Tracking : public ArcsecJsonBase { -public: - - static const size_t COMMAND_SIZE = 15; - - Tracking() {} - /** - * @brief Fills a buffer with the tracking parameters - * - * @param fullname The name including the absolute path of the json file containing the - * tracking parameters to set. - * @param buffer Pointer to the buffer the command will be written to - */ - ReturnValue_t create(std::string fullname, uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - result = init(fullname, arcseckeys::TRACKING); - if (result != RETURN_OK) { - return result; - } - result = createCommand(buffer); - return result; - } - -private: - ReturnValue_t createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::TRACKING); - offset = 2; - result = getParam(arcseckeys::THIN_LIMIT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::OUTLIER_THRESHOLD, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::OUTLIER_THRESHOLD_QUEST, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::TRACKER_CHOICE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - return RETURN_OK; - } - -}; - -#endif /* BSP_Q7S_DEVICES_DEVICEDEFINITIONS_STARTRACKERJSONCOMMANDS_H_ */ diff --git a/bsp_q7s/devices/ArcsecDatalinkLayer.cpp b/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.cpp similarity index 100% rename from bsp_q7s/devices/ArcsecDatalinkLayer.cpp rename to bsp_q7s/devices/startracker/ArcsecDatalinkLayer.cpp diff --git a/bsp_q7s/devices/ArcsecDatalinkLayer.h b/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.h similarity index 98% rename from bsp_q7s/devices/ArcsecDatalinkLayer.h rename to bsp_q7s/devices/startracker/ArcsecDatalinkLayer.h index 58acd4b3..eb5beecc 100644 --- a/bsp_q7s/devices/ArcsecDatalinkLayer.h +++ b/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.h @@ -1,7 +1,7 @@ #ifndef BSP_Q7S_DEVICES_ARCSECDATALINKLAYER_H_ #define BSP_Q7S_DEVICES_ARCSECDATALINKLAYER_H_ -#include "devicedefinitions/StarTrackerDefinitions.h" +#include "StarTrackerDefinitions.h" #include "fsfw/returnvalues/HasReturnValuesIF.h" extern "C" { diff --git a/bsp_q7s/devices/startracker/ArcsecJsonKeys.h b/bsp_q7s/devices/startracker/ArcsecJsonKeys.h new file mode 100644 index 00000000..58520968 --- /dev/null +++ b/bsp_q7s/devices/startracker/ArcsecJsonKeys.h @@ -0,0 +1,81 @@ +#ifndef BSP_Q7S_DEVICES_DEVICEDEFINITIONS_ARCSECJSONKEYS_H_ +#define BSP_Q7S_DEVICES_DEVICEDEFINITIONS_ARCSECJSONKEYS_H_ + +/** + * @brief Keys used in JSON file of ARCSEC. + */ +namespace arcseckeys { + static const char PROPERTIES[] = "properties"; + static const char NAME[] = "name"; + static const char VALUE[] = "value"; + + static const char LIMITS[] = "limits"; + static const char ACTION[] = "action"; + static const char FPGA18CURRENT[] = "FPGA18Current"; + static const char FPGA25CURRENT[] = "FPGA25Current"; + static const char FPGA10CURRENT[] = "FPGA10Current"; + static const char MCUCURRENT[] = "MCUCurrent"; + static const char CMOS21CURRENT[] = "CMOS21Current"; + static const char CMOSPIXCURRENT[] = "CMOSPixCurrent"; + static const char CMOS33CURRENT[] = "CMOS33Current"; + static const char CMOSVRESCURRENT[] = "CMOSVResCurrent"; + static const char CMOS_TEMPERATURE[] = "CMOSTemperature"; + static const char MCU_TEMPERATURE[] = "MCUTemperature"; + + static const char MOUNTING[] = "mounting"; + static const char qw[] = "qw"; + static const char qx[] = "qx"; + static const char qy[] = "qy"; + static const char qz[] = "qz"; + + static const char CAMERA[] = "camera"; + static const char MODE[] = "mode"; + static const char FOCALLENGTH[] = "focallength"; + static const char EXPOSURE[] = "exposure"; + static const char INTERVAL[] = "interval"; + static const char OFFSET[] = "offset"; + static const char PGAGAIN[] = "PGAGain"; + static const char ADCGAIN[] = "ADCGain"; + static const char REG_1[] = "reg1"; + static const char VAL_1[] = "val1"; + static const char REG_2[] = "reg2"; + static const char VAL_2[] = "val2"; + static const char REG_3[] = "reg3"; + static const char VAL_3[] = "val3"; + static const char REG_4[] = "reg4"; + static const char VAL_4[] = "val4"; + static const char REG_5[] = "reg5"; + static const char VAL_5[] = "val5"; + static const char REG_6[] = "reg6"; + static const char VAL_6[] = "val6"; + static const char REG_7[] = "reg7"; + static const char VAL_7[] = "val7"; + static const char REG_8[] = "reg8"; + static const char VAL_8[] = "val8"; + static const char FREQ_1[] = "freq1"; + static const char FREQ_2[] = "freq2"; + + static const char BLOB[] = "blob"; + static const char MIN_VALUE[] = "minValue"; + static const char MIN_DISTANCE[] = "minDistance"; + static const char NEIGHBOUR_DISTANCE[] = "neighbourDistance"; + static const char NEIGHBOUR_BRIGHT_PIXELS[] = "neighbourBrightPixels"; + static const char MIN_TOTAL_VALUE[] = "minTotalValue"; + static const char MAX_TOTAL_VALUE[] = "maxTotalValue"; + static const char MIN_BRIGHT_NEIGHBOURS[] = "minBrightNeighbours"; + static const char MAX_BRIGHT_NEIGHBOURS[] = "maxBrightNeighbours"; + static const char MAX_PIXEL_TO_CONSIDER[] = "maxPixelsToConsider"; + static const char SIGNAL_THRESHOLD[] = "signalThreshold"; + static const char DARK_THRESHOLD[] = "darkThreshold"; + static const char ENABLE_HISTOGRAM[] = "enableHistogram"; + static const char ENABLE_CONTRAST[] = "enableContrast"; + static const char BIN_MODE[] = "binMode"; + + static const char TRACKING[] = "tracking"; + static const char THIN_LIMIT[] = "thinLimit"; + static const char OUTLIER_THRESHOLD[] = "outlierThreshold"; + static const char OUTLIER_THRESHOLD_QUEST[] = "outlierThresholdQUEST"; + static const char TRACKER_CHOICE[] = "trackerChoice"; +} + +#endif /* BSP_Q7S_DEVICES_DEVICEDEFINITIONS_ARCSECJSONKEYS_H_ */ diff --git a/bsp_q7s/devices/startracker/ArcsecJsonParamBase.cpp b/bsp_q7s/devices/startracker/ArcsecJsonParamBase.cpp new file mode 100644 index 00000000..38040797 --- /dev/null +++ b/bsp_q7s/devices/startracker/ArcsecJsonParamBase.cpp @@ -0,0 +1,87 @@ +#include "ArcsecJsonParamBase.h" +#include "ArcsecJsonKeys.h" + +ArcsecJsonParamBase::ArcsecJsonParamBase(std::string setName) : setName(setName) {} + +ReturnValue_t ArcsecJsonParamBase::create(std::string fullname, uint8_t* buffer) { + ReturnValue_t result = RETURN_OK; + result = init(fullname); + if (result != RETURN_OK) { + return result; + } + result = createCommand(buffer); + return result; +} + +ReturnValue_t ArcsecJsonParamBase::getParam(const std::string name, std::string& value) { + for (json::iterator it = set.begin(); it != set.end(); ++it) { + if ((*it)[arcseckeys::NAME] == name) { + value = (*it)[arcseckeys::VALUE]; + return RETURN_OK; + } + } + return PARAM_NOT_EXISTS; +} + +void ArcsecJsonParamBase::addfloat(const std::string value, uint8_t* buffer) { + float param = std::stof(value); + std::memcpy(buffer, ¶m, sizeof(param)); +} + +void ArcsecJsonParamBase::adduint8(const std::string value, uint8_t* buffer) { + uint8_t param = std::stoi(value); + std::memcpy(buffer, ¶m, sizeof(param)); +} + +void ArcsecJsonParamBase::addint16(const std::string value, uint8_t* buffer) { + int16_t param = std::stoi(value); + std::memcpy(buffer, ¶m, sizeof(param)); +} + +void ArcsecJsonParamBase::adduint16(const std::string value, uint8_t* buffer) { + uint16_t param = std::stoi(value); + std::memcpy(buffer, ¶m, sizeof(param)); +} + +void ArcsecJsonParamBase::adduint32(const std::string value, uint8_t* buffer) { + uint32_t param = std::stoi(value); + std::memcpy(buffer, ¶m, sizeof(param)); +} + +void ArcsecJsonParamBase::addSetParamHeader(uint8_t* buffer, uint8_t setId) { + *buffer = static_cast(TMTC_SETPARAMREQ); + *(buffer + 1) = setId; +} + +ReturnValue_t ArcsecJsonParamBase::init(const std::string filename) { + ReturnValue_t result = RETURN_OK; + if (not std::filesystem::exists(filename)) { + sif::warning << "ArcsecJsonParamBase::init: JSON file " << filename << " does not exist" + << std::endl; + return JSON_FILE_NOT_EXISTS; + } + createJsonObject(filename); + result = initSet(); + if (result != RETURN_OK) { + return result; + } + return RETURN_OK; +} + +void ArcsecJsonParamBase::createJsonObject(const std::string fullname) { + json j; + std::ifstream file(fullname); + file >> j; + file.close(); + properties = j[arcseckeys::PROPERTIES]; +} + +ReturnValue_t ArcsecJsonParamBase::initSet() { + for (json::iterator it = properties.begin(); it != properties.end(); ++it) { + if ((*it)["name"] == setName) { + set = (*it)["fields"]; + return RETURN_OK; + } + } + return SET_NOT_EXISTS; +} diff --git a/bsp_q7s/devices/startracker/ArcsecJsonParamBase.h b/bsp_q7s/devices/startracker/ArcsecJsonParamBase.h new file mode 100644 index 00000000..dc59c6fc --- /dev/null +++ b/bsp_q7s/devices/startracker/ArcsecJsonParamBase.h @@ -0,0 +1,144 @@ +#ifndef BSP_Q7S_DEVICES_STARTRACKER_ARCSECJSONPARAMBASE_H_ +#define BSP_Q7S_DEVICES_STARTRACKER_ARCSECJSONPARAMBASE_H_ + +#include +#include +#include + +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "StarTrackerDefinitions.h" + +extern "C" { + #include "thirdparty/arcsec_star_tracker/common/generated/tmtcstructs.h" + #include "thirdparty/arcsec_star_tracker/common/genericstructs.h" +} + +using json = nlohmann::json; + +/** + * @brief Base class for creation of parameter configuration commands. Reads parameter set + * from a json file located on the filesystem and generates the appropriate command + * to apply the parameters to the star tracker software. + * + * @author J. Meier + */ +class ArcsecJsonParamBase : public HasReturnvaluesIF { +public: + + static const uint8_t INTERFACE_ID = CLASS_ID::ARCSEC_JSON_BASE; + //! [EXPORT] : [COMMENT] Specified json file does not exist + static const ReturnValue_t JSON_FILE_NOT_EXISTS = MAKE_RETURN_CODE(1); + //! [EXPORT] : [COMMENT] Requested set does not exist in json file + static const ReturnValue_t SET_NOT_EXISTS = MAKE_RETURN_CODE(2); + //! [EXPORT] : [COMMENT] Requested parameter does not exist in json file + static const ReturnValue_t PARAM_NOT_EXISTS = MAKE_RETURN_CODE(3); + + /** + * @brief Constructor + * + * @param fullname Name with absolute path of json file containing the parameters to set. + */ + ArcsecJsonParamBase(std::string setName); + + /** + * @brief Fills a buffer with a parameter set + * + * @param fullname The name including the absolute path of the json file containing the + * parameter set. + * @param buffer Pointer to the buffer the command will be written to + */ + ReturnValue_t create(std::string fullname, uint8_t* buffer); + + /** + * @brief Returns the size of the parameter command. + */ + virtual size_t getSize() = 0; + +protected: + + /** + * @brief Reads the value of a parameter from a json set + * + * @param name The name of the parameter + * @param value The string representation of the read value + * + * @return RETURN_OK if successful, otherwise PARAM_NOT_EXISTS + */ + ReturnValue_t getParam(const std::string name, std::string& value); + + /** + * @brief This function adds a float represented as string to a buffer + * + * @param value The float in string representation to add + * @param buffer Pointer to the buffer the float will be written to + */ + void addfloat(const std::string value, uint8_t* buffer); + + /** + * @brief This function adds a uint8_t represented as string to a buffer + * + * @param value The uint8_t in string representation to add + * @param buffer Pointer to the buffer the uint8_t will be written to + */ + void adduint8(const std::string value, uint8_t* buffer); + + /** + * @brief This function adds a int16_t represented as string to a buffer + * + * @param value The int16_t in string representation to add + * @param buffer Pointer to the buffer the int16_t will be written to + */ + void addint16(const std::string value, uint8_t* buffer); + + /** + * @brief This function adds a uint16_t represented as string to a buffer + * + * @param value The uint16_t in string representation to add + * @param buffer Pointer to the buffer the uint16_t will be written to + */ + void adduint16(const std::string value, uint8_t* buffer); + + /** + * @brief This function adds a uint32_t represented as string to a buffer + * + * @param value The uint32_t in string representation to add + * @param buffer Pointer to the buffer the uint32_t will be written to + */ + void adduint32(const std::string value, uint8_t* buffer); + + void addSetParamHeader(uint8_t* buffer, uint8_t setId); + +private: + + json properties; + json set; + std::string setName; + + /** + * @brief This function must be implemented by the derived class to define creation of a + * parameter command. + */ + virtual ReturnValue_t createCommand(uint8_t* buffer) = 0; + + /** + * @brief Initializes the properties json object and the set json object + * + * @param fullname Name including absolute path to json file + * @param setName The name of the set to work on + * + * @param return JSON_FILE_NOT_EXISTS if specified file does not exist, otherwise + * RETURN_OK + */ + ReturnValue_t init(const std::string filename); + + void createJsonObject(const std::string fullname); + + /** + * @brief Extracts the json set object form the json file + * + * @param setName The name of the set to create the json object from + */ + ReturnValue_t initSet(); +}; + +#endif /* BSP_Q7S_DEVICES_STARTRACKER_ARCSECJSONPARAMBASE_H_ */ diff --git a/bsp_q7s/devices/startracker/CMakeLists.txt b/bsp_q7s/devices/startracker/CMakeLists.txt new file mode 100644 index 00000000..81f0492f --- /dev/null +++ b/bsp_q7s/devices/startracker/CMakeLists.txt @@ -0,0 +1,7 @@ +target_sources(${TARGET_NAME} PRIVATE + StarTrackerHandler.cpp + StarTrackerJsonCommands.cpp + ArcsecDatalinkLayer.cpp + ArcsecJsonParamBase.cpp + StrImageLoader.cpp +) \ No newline at end of file diff --git a/bsp_q7s/devices/devicedefinitions/StarTrackerDefinitions.h b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h similarity index 99% rename from bsp_q7s/devices/devicedefinitions/StarTrackerDefinitions.h rename to bsp_q7s/devices/startracker/StarTrackerDefinitions.h index 49dd111f..6ea8d6f7 100644 --- a/bsp_q7s/devices/devicedefinitions/StarTrackerDefinitions.h +++ b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h @@ -98,12 +98,12 @@ static const DeviceCommandId_t SUBSCRIBE_TO_TM = 18; static const DeviceCommandId_t REQ_SOLUTION = 24; static const DeviceCommandId_t REQ_TEMPERATURE = 25; static const DeviceCommandId_t LIMITS = 40; -static const DeviceCommandId_t MONTING = 41; +static const DeviceCommandId_t MOUNTING = 41; static const DeviceCommandId_t CAMERA = 42; static const DeviceCommandId_t BLOB = 43; static const DeviceCommandId_t CENTROIDING = 44; static const DeviceCommandId_t LISA = 45; -static const DeviceCommandId_t MACTHING = 46; +static const DeviceCommandId_t MATCHING = 46; static const DeviceCommandId_t TRACKING = 47; static const DeviceCommandId_t VALIDATION = 48; static const DeviceCommandId_t ALGO = 49; diff --git a/bsp_q7s/devices/StarTrackerHandler.cpp b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp similarity index 90% rename from bsp_q7s/devices/StarTrackerHandler.cpp rename to bsp_q7s/devices/startracker/StarTrackerHandler.cpp index 1a8b4971..088bd798 100644 --- a/bsp_q7s/devices/StarTrackerHandler.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp @@ -2,7 +2,7 @@ #include "StarTrackerHandler.h" #include "OBSWConfig.h" -#include "devicedefinitions/StarTrackerJsonCommands.h" +#include "StarTrackerJsonCommands.h" #include #include @@ -194,11 +194,28 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi return RETURN_OK; } case (StarTracker::LIMITS): { - result = prepareLimitsCommand(commandData, commandDataLen); + Limits limits; + result = prepareParamCommand(commandData, commandDataLen, limits); + return result; + } + case (StarTracker::MOUNTING): { + Mounting mounting; + result = prepareParamCommand(commandData, commandDataLen, mounting); + return result; + } + case (StarTracker::CAMERA): { + Camera camera; + result = prepareParamCommand(commandData, commandDataLen, camera); + return result; + } + case (StarTracker::BLOB): { + Blob blob; + result = prepareParamCommand(commandData, commandDataLen, blob); return result; } case (StarTracker::TRACKING): { - result = prepareTrackingCommand(commandData, commandDataLen); + Tracking tracking; + result = prepareParamCommand(commandData, commandDataLen, tracking); return result; } default: @@ -233,6 +250,24 @@ void StarTrackerHandler::fillCommandAndReplyMap() { StarTracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(StarTracker::LIMITS, 3, nullptr, StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::MOUNTING, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::CAMERA, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::BLOB, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::CENTROIDING, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::LISA, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::MATCHING, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::TRACKING, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::VALIDATION, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::ALGO, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); } ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t remainingSize, @@ -264,7 +299,7 @@ ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t rema } case TMTC_SETPARAMREPLY: { *foundLen = remainingSize - bytesLeft; - result = scanForSetParameterReply(foundId); + result = scanForParameterReply(foundId); break; } case TMTC_TELEMETRYREPLYA: @@ -325,7 +360,16 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con handleTemperatureTm(); break; } - case (StarTracker::LIMITS): { + case (StarTracker::LIMITS): + case (StarTracker::MOUNTING): + case (StarTracker::CAMERA): + case (StarTracker::BLOB): + case (StarTracker::CENTROIDING): + case (StarTracker::LISA): + case (StarTracker::MATCHING): + case (StarTracker::TRACKING): + case (StarTracker::VALIDATION): + case (StarTracker::ALGO): { result = handleSetParamReply(); break; } @@ -458,14 +502,14 @@ ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t *foundId) break; } default: - sif::warning << "StarTrackerHandler::scanForSetParameterReply: Unknown parameter reply id" + sif::warning << "StarTrackerHandler::scanForParameterReply: Unknown parameter reply id" << std::endl; return RETURN_FAILED; } return RETURN_OK; } -ReturnValue_t StarTrackerHandler::scanForSetParameterReply(DeviceCommandId_t *foundId) { +ReturnValue_t StarTrackerHandler::scanForParameterReply(DeviceCommandId_t *foundId) { const uint8_t* reply = dataLinkLayer.getReply(); switch (*reply) { case (StarTracker::ID::SUBSCRIBE): { @@ -476,8 +520,44 @@ ReturnValue_t StarTrackerHandler::scanForSetParameterReply(DeviceCommandId_t *fo *foundId = StarTracker::LIMITS; break; } + case (StarTracker::ID::MOUNTING): { + *foundId = StarTracker::MOUNTING; + break; + } + case (StarTracker::ID::CAMERA): { + *foundId = StarTracker::CAMERA; + break; + } + case (StarTracker::ID::BLOB): { + *foundId = StarTracker::BLOB; + break; + } + case (StarTracker::ID::CENTROIDING): { + *foundId = StarTracker::CENTROIDING; + break; + } + case (StarTracker::ID::LISA): { + *foundId = StarTracker::LISA; + break; + } + case (StarTracker::ID::MATCHING): { + *foundId = StarTracker::MATCHING; + break; + } + case (StarTracker::ID::TRACKING): { + *foundId = StarTracker::TRACKING; + break; + } + case (StarTracker::ID::VALIDATION): { + *foundId = StarTracker::VALIDATION; + break; + } + case (StarTracker::ID::ALGO): { + *foundId = StarTracker::ALGO; + break; + } default: - sif::debug << "StarTrackerHandler::scanForSetParameterReply: Unknown parameter reply id" + sif::debug << "StarTrackerHandler::scanForParameterReply: Unknown parameter reply id" << std::endl; return RETURN_FAILED; } @@ -638,43 +718,21 @@ void StarTrackerHandler::prepareTemperatureRequest() { rawPacketLen = dataLinkLayer.getEncodedLength(); } -ReturnValue_t StarTrackerHandler::prepareLimitsCommand(const uint8_t* commandData, - size_t commandDataLen) { +ReturnValue_t StarTrackerHandler::prepareParamCommand(const uint8_t* commandData, + size_t commandDataLen, ArcsecJsonParamBase& paramSet) { ReturnValue_t result = RETURN_OK; if (commandDataLen > MAX_PATH_SIZE) { return FILE_PATH_TOO_LONG; } std::string fullName(reinterpret_cast(commandData), commandDataLen); - Limits limits; - result = limits.create(fullName, commandBuffer); + result = paramSet.create(fullName, commandBuffer); if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareLimitsCommand: Failed to create limits command" - << std::endl; + sif::warning << "StarTrackerHandler::prepareParamCommand: Failed to create parameter " + "command" << std::endl; return result; } - dataLinkLayer.encodeFrame(commandBuffer, Limits::COMMAND_SIZE); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; -} - -ReturnValue_t StarTrackerHandler::prepareTrackingCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - if (commandDataLen > MAX_PATH_SIZE) { - return FILE_PATH_TOO_LONG; - } - std::string fullName(reinterpret_cast(commandData), commandDataLen); - - Tracking tracking; - result = tracking.create(fullName, commandBuffer); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareTrackingCommand: Failed to create tracking " - " command" << std::endl; - return result; - } - dataLinkLayer.encodeFrame(commandBuffer, Tracking::COMMAND_SIZE); + dataLinkLayer.encodeFrame(commandBuffer, paramSet.getSize()); rawPacket = dataLinkLayer.getEncodedFrame(); rawPacketLen = dataLinkLayer.getEncodedLength(); return RETURN_OK; diff --git a/bsp_q7s/devices/StarTrackerHandler.h b/bsp_q7s/devices/startracker/StarTrackerHandler.h similarity index 91% rename from bsp_q7s/devices/StarTrackerHandler.h rename to bsp_q7s/devices/startracker/StarTrackerHandler.h index 27d14a3d..3f3c8197 100644 --- a/bsp_q7s/devices/StarTrackerHandler.h +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.h @@ -1,13 +1,14 @@ #ifndef MISSION_DEVICES_STARTRACKERHANDLER_H_ #define MISSION_DEVICES_STARTRACKERHANDLER_H_ -#include -#include -#include +#include "fsfw/devicehandlers/DeviceHandlerBase.h" +#include "fsfw/src/fsfw/serialize/SerializeAdapter.h" +#include "thirdparty/arcsec_star_tracker/common/SLIP.h" #include -#include -#include -#include +#include "StrImageLoader.h" +#include "ArcsecDataLinkLayer.h" +#include "StarTrackerDefinitions.h" +#include "ArcsecJsonParamBase.h" /** * @brief This is the device handler for the star tracker from arcsec. @@ -158,7 +159,7 @@ private: void slipInit(); ReturnValue_t scanForActionReply(DeviceCommandId_t *foundId); - ReturnValue_t scanForSetParameterReply(DeviceCommandId_t *foundId); + ReturnValue_t scanForParameterReply(DeviceCommandId_t *foundId); ReturnValue_t scanForTmReply(DeviceCommandId_t *foundId); /** @@ -221,10 +222,17 @@ private: void prepareTemperatureRequest(); /** - * @brief Reads limit parameters from json file specified with commandData and prepares - * the command to apply the limits to the star tracker. + * @brief Reads parameters from json file specified by string in commandData and + * prepares the command to apply the parameter set to the star tracker + * + * @param commandData Contains string with file name + * @param commandDataLen Length of command + * @param paramSet The object defining the command generation + * + * @return RETURN_OK if successful, otherwise error return Value */ - ReturnValue_t prepareLimitsCommand(const uint8_t* commandData, size_t commandDataLen); + ReturnValue_t prepareParamCommand(const uint8_t* commandData, size_t commandDataLen, + ArcsecJsonParamBase& paramSet); /** * @brief Default function to handle action replies diff --git a/bsp_q7s/devices/startracker/StarTrackerJsonCommands.cpp b/bsp_q7s/devices/startracker/StarTrackerJsonCommands.cpp new file mode 100644 index 00000000..dd91eddf --- /dev/null +++ b/bsp_q7s/devices/startracker/StarTrackerJsonCommands.cpp @@ -0,0 +1,535 @@ +#include "StarTrackerJsonCommands.h" +#include "ArcsecJsonKeys.h" + +Limits::Limits() : ArcsecJsonParamBase(arcseckeys::LIMITS) {} + +size_t Limits::getSize() { + return COMMAND_SIZE; +} + +ReturnValue_t Limits::createCommand(uint8_t* buffer) { + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::LIMITS); + offset = 2; + result = getParam(arcseckeys::ACTION, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::FPGA18CURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FPGA25CURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FPGA10CURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MCUCURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CMOS21CURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CMOSPIXCURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CMOS33CURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CMOSVRESCURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CMOS_TEMPERATURE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MCU_TEMPERATURE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + return RETURN_OK; +} + + +Tracking::Tracking() : ArcsecJsonParamBase(arcseckeys::TRACKING) {} + +size_t Tracking::getSize() { + return COMMAND_SIZE; +} + +ReturnValue_t Tracking::createCommand(uint8_t* buffer) { + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::TRACKING); + offset = 2; + result = getParam(arcseckeys::THIN_LIMIT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::OUTLIER_THRESHOLD, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::OUTLIER_THRESHOLD_QUEST, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::TRACKER_CHOICE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + return RETURN_OK; +} + + +Mounting::Mounting() : ArcsecJsonParamBase(arcseckeys::MOUNTING) {} + +size_t Mounting::getSize() { + return COMMAND_SIZE; +} + +ReturnValue_t Mounting::createCommand(uint8_t* buffer) { + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::MOUNTING); + offset = 2; + result = getParam(arcseckeys::qw, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::qx, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::qy, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::qz, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + return RETURN_OK; +} + + +Camera::Camera() : ArcsecJsonParamBase(arcseckeys::CAMERA) {} + +size_t Camera::getSize() { + return COMMAND_SIZE; +} + +ReturnValue_t Camera::createCommand(uint8_t* buffer) { + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::CAMERA); + offset = 2; + result = getParam(arcseckeys::MODE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::FOCALLENGTH, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::EXPOSURE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::INTERVAL, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::OFFSET, param); + if (result != RETURN_OK) { + return result; + } + addint16(param, buffer + offset); + offset += sizeof(int16_t); + result = getParam(arcseckeys::PGAGAIN, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::ADCGAIN, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_1, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_1, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_2, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_2, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_3, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_3, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_4, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_4, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_5, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_5, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_6, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_6, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_7, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_7, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_8, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_8, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::FREQ_1, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FREQ_2, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + return RETURN_OK; +} + +Blob::Blob() : ArcsecJsonParamBase(arcseckeys::BLOB) {} + +size_t Blob::getSize() { + return COMMAND_SIZE; +} + +ReturnValue_t Blob::createCommand(uint8_t* buffer) { + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::BLOB); + offset = 2; + result = getParam(arcseckeys::MODE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::MIN_VALUE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::MIN_DISTANCE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::NEIGHBOUR_DISTANCE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::NEIGHBOUR_BRIGHT_PIXELS, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::MIN_TOTAL_VALUE, param); + if (result != RETURN_OK) { + return result; + } + adduint16(param, buffer + offset); + offset += sizeof(uint16_t); + result = getParam(arcseckeys::MAX_TOTAL_VALUE, param); + if (result != RETURN_OK) { + return result; + } + adduint16(param, buffer + offset); + offset += sizeof(uint16_t); + result = getParam(arcseckeys::MIN_BRIGHT_NEIGHBOURS, param); + if (result != RETURN_OK) { + return result; + } + adduint16(param, buffer + offset); + offset += sizeof(uint16_t); + result = getParam(arcseckeys::MAX_BRIGHT_NEIGHBOURS, param); + if (result != RETURN_OK) { + return result; + } + adduint16(param, buffer + offset); + offset += sizeof(uint16_t); + result = getParam(arcseckeys::MAX_PIXEL_TO_CONSIDER, param); + if (result != RETURN_OK) { + return result; + } + adduint32(param, buffer + offset); + offset += sizeof(uint32_t); + result = getParam(arcseckeys::SIGNAL_THRESHOLD, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::DARK_THRESHOLD, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::ENABLE_HISTOGRAM, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::ENABLE_CONTRAST, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::BIN_MODE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + return RETURN_OK; +} + +Centroiding::Centroiding() : ArcsecJsonParamBase(arcseckeys::BLOB) {} + +size_t Centroiding::getSize() { + return COMMAND_SIZE; +} + +ReturnValue_t Centroiding::createCommand(uint8_t* buffer) { + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::BLOB); + offset = 2; + result = getParam(arcseckeys::MODE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::MIN_VALUE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::MIN_DISTANCE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::NEIGHBOUR_DISTANCE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::NEIGHBOUR_BRIGHT_PIXELS, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::MIN_TOTAL_VALUE, param); + if (result != RETURN_OK) { + return result; + } + adduint16(param, buffer + offset); + offset += sizeof(uint16_t); + result = getParam(arcseckeys::MAX_TOTAL_VALUE, param); + if (result != RETURN_OK) { + return result; + } + adduint16(param, buffer + offset); + offset += sizeof(uint16_t); + result = getParam(arcseckeys::MIN_BRIGHT_NEIGHBOURS, param); + if (result != RETURN_OK) { + return result; + } + adduint16(param, buffer + offset); + offset += sizeof(uint16_t); + result = getParam(arcseckeys::MAX_BRIGHT_NEIGHBOURS, param); + if (result != RETURN_OK) { + return result; + } + adduint16(param, buffer + offset); + offset += sizeof(uint16_t); + result = getParam(arcseckeys::MAX_PIXEL_TO_CONSIDER, param); + if (result != RETURN_OK) { + return result; + } + adduint32(param, buffer + offset); + offset += sizeof(uint32_t); + result = getParam(arcseckeys::SIGNAL_THRESHOLD, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::DARK_THRESHOLD, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::ENABLE_HISTOGRAM, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::ENABLE_CONTRAST, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::BIN_MODE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + return RETURN_OK; +} diff --git a/bsp_q7s/devices/startracker/StarTrackerJsonCommands.h b/bsp_q7s/devices/startracker/StarTrackerJsonCommands.h new file mode 100644 index 00000000..153ef8a7 --- /dev/null +++ b/bsp_q7s/devices/startracker/StarTrackerJsonCommands.h @@ -0,0 +1,128 @@ +#ifndef BSP_Q7S_DEVICES_DEVICEDEFINITIONS_STARTRACKERJSONCOMMANDS_H_ +#define BSP_Q7S_DEVICES_DEVICEDEFINITIONS_STARTRACKERJSONCOMMANDS_H_ + +/** + * @brief This file defines a few helper classes to generate commands by means of the parameters + * defined in the arcsec json files. + * @author J. Meier + */ + +#include + +#include "fsfw/serviceinterface/ServiceInterface.h" +#include "ArcsecJsonParamBase.h" + +/** + * @brief Generates command to set the limit parameters + * + */ +class Limits : public ArcsecJsonParamBase { +public: + + Limits(); + + size_t getSize(); + +private: + + static const size_t COMMAND_SIZE = 43; + + virtual ReturnValue_t createCommand(uint8_t* buffer) override; +}; + +/** + * @brief Generates the command to configure the tracking algorithm. + * + */ +class Tracking : public ArcsecJsonParamBase { +public: + + Tracking(); + + size_t getSize(); + +private: + + static const size_t COMMAND_SIZE = 15; + + ReturnValue_t createCommand(uint8_t* buffer) override; + +}; + +/** + * @brief Generates the command to set the mounting quaternion + * + */ +class Mounting : public ArcsecJsonParamBase { +public: + + Mounting(); + + size_t getSize(); + +private: + + static const size_t COMMAND_SIZE = 18; + + ReturnValue_t createCommand(uint8_t* buffer) override; + +}; + +/** + * @brief Generates the command to set the mounting quaternion + * + */ +class Camera : public ArcsecJsonParamBase { +public: + + Camera(); + + size_t getSize(); + +private: + + static const size_t COMMAND_SIZE = 43; + + ReturnValue_t createCommand(uint8_t* buffer) override; + +}; + +/** + * @brief Generates the command to configure the blob algorithm + * + */ +class Blob : public ArcsecJsonParamBase { +public: + + Blob(); + + size_t getSize(); + +private: + + static const size_t COMMAND_SIZE = 24; + + ReturnValue_t createCommand(uint8_t* buffer) override; + +}; + +/** + * @brief Generates the command to configure the centroiding algorithm + * + */ +class Centroiding : public ArcsecJsonParamBase { +public: + + Centroiding(); + + size_t getSize(); + +private: + + static const size_t COMMAND_SIZE = 24; + + ReturnValue_t createCommand(uint8_t* buffer) override; + +}; + +#endif /* BSP_Q7S_DEVICES_DEVICEDEFINITIONS_STARTRACKERJSONCOMMANDS_H_ */ diff --git a/bsp_q7s/devices/StrImageLoader.cpp b/bsp_q7s/devices/startracker/StrImageLoader.cpp similarity index 100% rename from bsp_q7s/devices/StrImageLoader.cpp rename to bsp_q7s/devices/startracker/StrImageLoader.cpp diff --git a/bsp_q7s/devices/StrImageLoader.h b/bsp_q7s/devices/startracker/StrImageLoader.h similarity index 99% rename from bsp_q7s/devices/StrImageLoader.h rename to bsp_q7s/devices/startracker/StrImageLoader.h index 940001a4..e53e57d1 100644 --- a/bsp_q7s/devices/StrImageLoader.h +++ b/bsp_q7s/devices/startracker/StrImageLoader.h @@ -2,10 +2,9 @@ #define BSP_Q7S_DEVICES_STRIMAGELOADER_H_ #include - +#include "ArcsecDatalinkLayer.h" #include "fsfw/osal/linux/BinarySemaphore.h" #include "bsp_q7s/memory/SdCardManager.h" -#include "bsp_q7s/devices/ArcsecDatalinkLayer.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/objectmanager/SystemObject.h" #include "fsfw/tasks/ExecutableObjectIF.h" From b691a1e75d3e67046566d627187b83dddba1f681 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Wed, 8 Dec 2021 12:50:55 +0100 Subject: [PATCH 120/465] parsing of arcsec json file complete --- bsp_q7s/devices/startracker/ArcsecJsonKeys.h | 45 +++ .../startracker/StarTrackerHandler.cpp | 25 ++ .../startracker/StarTrackerJsonCommands.cpp | 335 ++++++++++++++---- .../startracker/StarTrackerJsonCommands.h | 89 ++++- 4 files changed, 416 insertions(+), 78 deletions(-) diff --git a/bsp_q7s/devices/startracker/ArcsecJsonKeys.h b/bsp_q7s/devices/startracker/ArcsecJsonKeys.h index 58520968..2c598b43 100644 --- a/bsp_q7s/devices/startracker/ArcsecJsonKeys.h +++ b/bsp_q7s/devices/startracker/ArcsecJsonKeys.h @@ -71,11 +71,56 @@ namespace arcseckeys { static const char ENABLE_CONTRAST[] = "enableContrast"; static const char BIN_MODE[] = "binMode"; + static const char CENTROIDING[] = "centroiding"; + static const char ENABLE_FILTER[] = "enableFilter"; + static const char MAX_QUALITY[] = "maxquality"; + static const char MIN_QUALITY[] = "minquality"; + static const char MAX_INTENSITY[] = "maxintensity"; + static const char MIN_INTENSITY[] = "minintensity"; + static const char MAX_MAGNITUDE[] = "maxmagnitude"; + static const char GAUSSIAN_CMAX[] = "gaussianCmax"; + static const char GAUSSIAN_CMIN[] = "gaussianCmin"; + static const char TRANSMATRIX_00[] = "transmatrix00"; + static const char TRANSMATRIX_01[] = "transmatrix01"; + static const char TRANSMATRIX_10[] = "transmatrix10"; + static const char TRANSMATRIX_11[] = "transmatrix11"; + + static const char LISA[] = "lisa"; + static const char PREFILTER_DIST_THRESHOLD[] = "prefilterDistThreshold"; + static const char PREFILTER_ANGLE_THRESHOLD[] = "prefilterAngleThreshold"; + static const char FOV_WIDTH[] = "fov_width"; + static const char FOV_HEIGHT[] = "fov_height"; + static const char FLOAT_STAR_LIMIT[] = "float_star_limit"; + static const char CLOSE_STAR_LIMIT[] = "close_star_limit"; + static const char RATING_WEIGHT_CLOSE_STAR_COUNT[] = "rating_weight_close_star_count"; + static const char RATING_WEIGHT_FRACTION_CLOSE[] = "rating_weight_fraction_close"; + static const char RATING_WEIGHT_MEAN_SUM[] = "rating_weight_mean_sum"; + static const char RATING_WEIGHT_DB_STAR_COUNT[] = "rating_weight_db_star_count"; + static const char MAX_COMBINATIONS[] = "max_combinations"; + static const char NR_STARS_STOP[] = "nr_stars_stop"; + static const char FRACTION_CLOSE_STOP[] = "fraction_close_stop"; + + static const char MATCHING[] = "matching"; + static const char SQUARED_DISTANCE_LIMIT[] = "squaredDistanceLimit"; + static const char SQUARED_SHIFT_LIMIT[] = "squaredShiftLimit"; + + static const char VALIDATION[] = "validation"; + static const char STABLE_COUNT[] = "stable_count"; + static const char MAX_DIFFERENCE[] = "max_difference"; + static const char MIN_TRACKER_CONFIDENCE[] = "min_trackerConfidence"; + static const char MIN_MATCHED_STARS[] = "min_matchedStars"; + static const char TRACKING[] = "tracking"; static const char THIN_LIMIT[] = "thinLimit"; static const char OUTLIER_THRESHOLD[] = "outlierThreshold"; static const char OUTLIER_THRESHOLD_QUEST[] = "outlierThresholdQUEST"; static const char TRACKER_CHOICE[] = "trackerChoice"; + + static const char ALGO[] = "algo"; + static const char L2T_MIN_CONFIDENCE[] = "l2t_minConfidence"; + static const char L2T_MIN_MATCHED[] = "l2t_minConfidence"; + static const char T2L_MIN_CONFIDENCE[] = "t2l_minConfidence"; + static const char T2L_MIN_MATCHED[] = "t2l_minMatched"; } #endif /* BSP_Q7S_DEVICES_DEVICEDEFINITIONS_ARCSECJSONKEYS_H_ */ diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp index 088bd798..d0a926a0 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp @@ -213,6 +213,31 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi result = prepareParamCommand(commandData, commandDataLen, blob); return result; } + case (StarTracker::CENTROIDING): { + Centroiding centroiding; + result = prepareParamCommand(commandData, commandDataLen, centroiding); + return result; + } + case (StarTracker::LISA): { + Lisa lisa; + result = prepareParamCommand(commandData, commandDataLen, lisa); + return result; + } + case (StarTracker::MATCHING): { + Matching matching; + result = prepareParamCommand(commandData, commandDataLen, matching); + return result; + } + case (StarTracker::VALIDATION): { + Validation validation; + result = prepareParamCommand(commandData, commandDataLen, validation); + return result; + } + case (StarTracker::ALGO): { + Algo algo; + result = prepareParamCommand(commandData, commandDataLen, algo); + return result; + } case (StarTracker::TRACKING): { Tracking tracking; result = prepareParamCommand(commandData, commandDataLen, tracking); diff --git a/bsp_q7s/devices/startracker/StarTrackerJsonCommands.cpp b/bsp_q7s/devices/startracker/StarTrackerJsonCommands.cpp index dd91eddf..2c7bbf1d 100644 --- a/bsp_q7s/devices/startracker/StarTrackerJsonCommands.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerJsonCommands.cpp @@ -324,6 +324,7 @@ ReturnValue_t Camera::createCommand(uint8_t* buffer) { return RETURN_OK; } + Blob::Blob() : ArcsecJsonParamBase(arcseckeys::BLOB) {} size_t Blob::getSize() { @@ -429,7 +430,8 @@ ReturnValue_t Blob::createCommand(uint8_t* buffer) { return RETURN_OK; } -Centroiding::Centroiding() : ArcsecJsonParamBase(arcseckeys::BLOB) {} + +Centroiding::Centroiding() : ArcsecJsonParamBase(arcseckeys::CENTROIDING) {} size_t Centroiding::getSize() { return COMMAND_SIZE; @@ -439,7 +441,247 @@ ReturnValue_t Centroiding::createCommand(uint8_t* buffer) { ReturnValue_t result = RETURN_OK; uint8_t offset = 0; std::string param; - addSetParamHeader(buffer, StarTracker::ID::BLOB); + addSetParamHeader(buffer, StarTracker::ID::CENTROIDING); + offset = 2; + result = getParam(arcseckeys::ENABLE_FILTER, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::MAX_QUALITY, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MIN_QUALITY, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MAX_INTENSITY, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MIN_INTENSITY, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MAX_MAGNITUDE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::GAUSSIAN_CMAX, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::GAUSSIAN_CMIN, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::TRANSMATRIX_00, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::TRANSMATRIX_01, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::TRANSMATRIX_10, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::TRANSMATRIX_11, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + return RETURN_OK; +} + + +Lisa::Lisa() : ArcsecJsonParamBase(arcseckeys::LISA) {} + +size_t Lisa::getSize() { + return COMMAND_SIZE; +} + +ReturnValue_t Lisa::createCommand(uint8_t* buffer) { + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::LISA); + offset = 2; + result = getParam(arcseckeys::PREFILTER_DIST_THRESHOLD, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::PREFILTER_ANGLE_THRESHOLD, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FOV_WIDTH, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FOV_HEIGHT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FLOAT_STAR_LIMIT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CLOSE_STAR_LIMIT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::RATING_WEIGHT_CLOSE_STAR_COUNT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::RATING_WEIGHT_FRACTION_CLOSE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::RATING_WEIGHT_DB_STAR_COUNT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MAX_COMBINATIONS, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::NR_STARS_STOP, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::FRACTION_CLOSE_STOP, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + return RETURN_OK; +} + + +Matching::Matching() : ArcsecJsonParamBase(arcseckeys::MATCHING) {} + +size_t Matching::getSize() { + return COMMAND_SIZE; +} + +ReturnValue_t Matching::createCommand(uint8_t* buffer) { + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::MATCHING); + offset = 2; + result = getParam(arcseckeys::SQUARED_DISTANCE_LIMIT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::SQUARED_SHIFT_LIMIT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + return RETURN_OK; +} + + +Validation::Validation() : ArcsecJsonParamBase(arcseckeys::VALIDATION) {} + +size_t Validation::getSize() { + return COMMAND_SIZE; +} + +ReturnValue_t Validation::createCommand(uint8_t* buffer) { + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::MATCHING); + offset = 2; + result = getParam(arcseckeys::STABLE_COUNT, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::MAX_DIFFERENCE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MIN_TRACKER_CONFIDENCE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MIN_MATCHED_STARS, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + return RETURN_OK; +} + +Algo::Algo() : ArcsecJsonParamBase(arcseckeys::ALGO) {} + +size_t Algo::getSize() { + return COMMAND_SIZE; +} + +ReturnValue_t Algo::createCommand(uint8_t* buffer) { + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::ALGO); offset = 2; result = getParam(arcseckeys::MODE, param); if (result != RETURN_OK) { @@ -447,89 +689,28 @@ ReturnValue_t Centroiding::createCommand(uint8_t* buffer) { } adduint8(param, buffer + offset); offset += sizeof(uint8_t); - result = getParam(arcseckeys::MIN_VALUE, param); + result = getParam(arcseckeys::L2T_MIN_CONFIDENCE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::L2T_MIN_MATCHED, param); if (result != RETURN_OK) { return result; } adduint8(param, buffer + offset); offset += sizeof(uint8_t); - result = getParam(arcseckeys::MIN_DISTANCE, param); + result = getParam(arcseckeys::T2L_MIN_CONFIDENCE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::T2L_MIN_MATCHED, param); if (result != RETURN_OK) { return result; } adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::NEIGHBOUR_DISTANCE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::NEIGHBOUR_BRIGHT_PIXELS, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::MIN_TOTAL_VALUE, param); - if (result != RETURN_OK) { - return result; - } - adduint16(param, buffer + offset); - offset += sizeof(uint16_t); - result = getParam(arcseckeys::MAX_TOTAL_VALUE, param); - if (result != RETURN_OK) { - return result; - } - adduint16(param, buffer + offset); - offset += sizeof(uint16_t); - result = getParam(arcseckeys::MIN_BRIGHT_NEIGHBOURS, param); - if (result != RETURN_OK) { - return result; - } - adduint16(param, buffer + offset); - offset += sizeof(uint16_t); - result = getParam(arcseckeys::MAX_BRIGHT_NEIGHBOURS, param); - if (result != RETURN_OK) { - return result; - } - adduint16(param, buffer + offset); - offset += sizeof(uint16_t); - result = getParam(arcseckeys::MAX_PIXEL_TO_CONSIDER, param); - if (result != RETURN_OK) { - return result; - } - adduint32(param, buffer + offset); - offset += sizeof(uint32_t); - result = getParam(arcseckeys::SIGNAL_THRESHOLD, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::DARK_THRESHOLD, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::ENABLE_HISTOGRAM, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::ENABLE_CONTRAST, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::BIN_MODE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); return RETURN_OK; } diff --git a/bsp_q7s/devices/startracker/StarTrackerJsonCommands.h b/bsp_q7s/devices/startracker/StarTrackerJsonCommands.h index 153ef8a7..868c18ea 100644 --- a/bsp_q7s/devices/startracker/StarTrackerJsonCommands.h +++ b/bsp_q7s/devices/startracker/StarTrackerJsonCommands.h @@ -12,6 +12,7 @@ #include "fsfw/serviceinterface/ServiceInterface.h" #include "ArcsecJsonParamBase.h" + /** * @brief Generates command to set the limit parameters * @@ -30,6 +31,7 @@ private: virtual ReturnValue_t createCommand(uint8_t* buffer) override; }; + /** * @brief Generates the command to configure the tracking algorithm. * @@ -49,6 +51,7 @@ private: }; + /** * @brief Generates the command to set the mounting quaternion * @@ -68,6 +71,7 @@ private: }; + /** * @brief Generates the command to set the mounting quaternion * @@ -87,6 +91,7 @@ private: }; + /** * @brief Generates the command to configure the blob algorithm * @@ -106,6 +111,7 @@ private: }; + /** * @brief Generates the command to configure the centroiding algorithm * @@ -119,7 +125,88 @@ public: private: - static const size_t COMMAND_SIZE = 24; + static const size_t COMMAND_SIZE = 47; + + ReturnValue_t createCommand(uint8_t* buffer) override; + +}; + + +/** + * @brief Generates the command to configure the LISA (lost in space algorithm) + * + */ +class Lisa : public ArcsecJsonParamBase { +public: + + Lisa(); + + size_t getSize(); + +private: + + static const size_t COMMAND_SIZE = 48; + + ReturnValue_t createCommand(uint8_t* buffer) override; + +}; + + +/** + * @brief Generates the command to configure the matching algorithm + * + */ +class Matching : public ArcsecJsonParamBase { +public: + + Matching(); + + size_t getSize(); + +private: + + static const size_t COMMAND_SIZE = 10; + + ReturnValue_t createCommand(uint8_t* buffer) override; + +}; + + +/** + * @brief Generates the command to configure the validation parameters + * + */ +class Validation : public ArcsecJsonParamBase { +public: + + Validation(); + + size_t getSize(); + +private: + + static const size_t COMMAND_SIZE = 12; + + ReturnValue_t createCommand(uint8_t* buffer) override; + +}; + + +/** + * @brief Generates command to configure the mechanism of automatically switching between the + * LISA and other algorithms. + * + */ +class Algo : public ArcsecJsonParamBase { +public: + + Algo(); + + size_t getSize(); + +private: + + static const size_t COMMAND_SIZE = 13; ReturnValue_t createCommand(uint8_t* buffer) override; From 99c450933eb78d3a98070b7743bacedf69164e2d Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Wed, 8 Dec 2021 14:39:25 +0100 Subject: [PATCH 121/465] fix in validation command --- bsp_q7s/devices/startracker/StarTrackerJsonCommands.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsp_q7s/devices/startracker/StarTrackerJsonCommands.cpp b/bsp_q7s/devices/startracker/StarTrackerJsonCommands.cpp index 2c7bbf1d..9c33e1c9 100644 --- a/bsp_q7s/devices/startracker/StarTrackerJsonCommands.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerJsonCommands.cpp @@ -643,7 +643,7 @@ ReturnValue_t Validation::createCommand(uint8_t* buffer) { ReturnValue_t result = RETURN_OK; uint8_t offset = 0; std::string param; - addSetParamHeader(buffer, StarTracker::ID::MATCHING); + addSetParamHeader(buffer, StarTracker::ID::VALIDATION); offset = 2; result = getParam(arcseckeys::STABLE_COUNT, param); if (result != RETURN_OK) { From 11704ea908a13d2feaa524f303667a5bcd2e1713 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 8 Dec 2021 14:48:29 +0100 Subject: [PATCH 122/465] enabled ACS board A side --- .../pollingSequenceFactory.cpp | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 73a27116..69982156 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -439,8 +439,8 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { #endif #if OBSW_ADD_ACS_BOARD == 1 - bool enableAside = false; - bool enableBside = true; + bool enableAside = true; + bool enableBside = false; if(enableAside) { // A side thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0, @@ -465,16 +465,16 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.3, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.75, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); +// thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, +// DeviceHandlerIF::PERFORM_OPERATION); +// thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.3, +// DeviceHandlerIF::SEND_WRITE); +// thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, +// DeviceHandlerIF::GET_WRITE); +// thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.75, +// DeviceHandlerIF::SEND_READ); +// thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.85, +// DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); @@ -512,16 +512,16 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.3, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.75, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); +// thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0, +// DeviceHandlerIF::PERFORM_OPERATION); +// thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.3, +// DeviceHandlerIF::SEND_WRITE); +// thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.6, +// DeviceHandlerIF::GET_WRITE); +// thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.75, +// DeviceHandlerIF::SEND_READ); +// thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.85, +// DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); From 52d8ae5ffb94d72f43bcabd3e3776121f61f075c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 8 Dec 2021 17:23:35 +0100 Subject: [PATCH 123/465] compiling for windows again --- CMakeLists.txt | 2 +- fsfw | 2 +- linux/devices/CMakeLists.txt | 1 + {mission => linux}/devices/StarTrackerHandler.cpp | 0 {mission => linux}/devices/StarTrackerHandler.h | 0 .../devices/devicedefinitions/StarTrackerDefinitions.h | 0 misc/eclipse/.cproject | 5 ++++- misc/eclipse/Host/eive-mingw-debug-cmake.launch | 2 +- mission/devices/CMakeLists.txt | 1 - mission/devices/RwHandler.cpp | 4 ++-- mission/devices/devicedefinitions/RwDefinitions.h | 2 +- 11 files changed, 11 insertions(+), 8 deletions(-) rename {mission => linux}/devices/StarTrackerHandler.cpp (100%) rename {mission => linux}/devices/StarTrackerHandler.h (100%) rename {mission => linux}/devices/devicedefinitions/StarTrackerDefinitions.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d76f2fb..59d9d32d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -177,6 +177,7 @@ endif() if(NOT EIVE_BUILD_WATCHDOG) if(NOT EIVE_BUILD_UNITTESTS) if(EIVE_ADD_LINUX_FILES) + add_subdirectory(${LIB_ARCSEC_PATH}) add_subdirectory(${LINUX_PATH}) endif() add_subdirectory(${BSP_PATH}) @@ -192,7 +193,6 @@ if((NOT BUILD_Q7S_SIMPLE_MODE) AND (NOT EIVE_BUILD_WATCHDOG)) add_subdirectory(${FSFW_PATH}) add_subdirectory(${MISSION_PATH}) add_subdirectory(${TEST_PATH}) - add_subdirectory(${LIB_ARCSEC_PATH}) endif() if(EIVE_BUILD_UNITTESTS) diff --git a/fsfw b/fsfw index ceb87b5a..e4999fe0 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit ceb87b5abb2992a18266328e0ea34d9af15db7af +Subproject commit e4999fe01c0446f9820ceede55be3970aa22bbad diff --git a/linux/devices/CMakeLists.txt b/linux/devices/CMakeLists.txt index 3871a6a6..6c529d8e 100644 --- a/linux/devices/CMakeLists.txt +++ b/linux/devices/CMakeLists.txt @@ -2,4 +2,5 @@ target_sources(${TARGET_NAME} PRIVATE HeaterHandler.cpp SolarArrayDeploymentHandler.cpp SusHandler.cpp + StarTrackerHandler.cpp ) diff --git a/mission/devices/StarTrackerHandler.cpp b/linux/devices/StarTrackerHandler.cpp similarity index 100% rename from mission/devices/StarTrackerHandler.cpp rename to linux/devices/StarTrackerHandler.cpp diff --git a/mission/devices/StarTrackerHandler.h b/linux/devices/StarTrackerHandler.h similarity index 100% rename from mission/devices/StarTrackerHandler.h rename to linux/devices/StarTrackerHandler.h diff --git a/mission/devices/devicedefinitions/StarTrackerDefinitions.h b/linux/devices/devicedefinitions/StarTrackerDefinitions.h similarity index 100% rename from mission/devices/devicedefinitions/StarTrackerDefinitions.h rename to linux/devices/devicedefinitions/StarTrackerDefinitions.h diff --git a/misc/eclipse/.cproject b/misc/eclipse/.cproject index 7d7c4c09..3bab5367 100644 --- a/misc/eclipse/.cproject +++ b/misc/eclipse/.cproject @@ -19,7 +19,7 @@ - + diff --git a/misc/eclipse/Host/eive-mingw-debug-cmake.launch b/misc/eclipse/Host/eive-mingw-debug-cmake.launch index 0dddc60f..9109d83c 100644 --- a/misc/eclipse/Host/eive-mingw-debug-cmake.launch +++ b/misc/eclipse/Host/eive-mingw-debug-cmake.launch @@ -18,7 +18,7 @@ - + diff --git a/mission/devices/CMakeLists.txt b/mission/devices/CMakeLists.txt index dd17728c..ea3fdbea 100644 --- a/mission/devices/CMakeLists.txt +++ b/mission/devices/CMakeLists.txt @@ -14,7 +14,6 @@ target_sources(${TARGET_NAME} PUBLIC RadiationSensorHandler.cpp GyroADIS16507Handler.cpp RwHandler.cpp - StarTrackerHandler.cpp ) diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index 91188d87..c848c809 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -197,7 +197,7 @@ ReturnValue_t RwHandler::scanForReply(const uint8_t *start, size_t remainingSize ReturnValue_t RwHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { /** Check result code */ - if (*(packet + 1) == RwDefinitions::ERROR) { + if (*(packet + 1) == RwDefinitions::STATE_ERROR) { sif::error << "RwHandler::interpretDeviceReply: Command execution failed. Command id: " << id << std::endl; return EXECUTION_FAILED; @@ -369,7 +369,7 @@ void RwHandler::handleGetRwStatusReply(const uint8_t* packet) { offset += 1; statusSet.clcMode = *(packet + offset); - if (statusSet.state == RwDefinitions::ERROR) { + if (statusSet.state == RwDefinitions::STATE_ERROR) { /** * This requires the commanding of the init reaction wheel controller command to recover * form error state which must be handled by the FDIR instance. diff --git a/mission/devices/devicedefinitions/RwDefinitions.h b/mission/devices/devicedefinitions/RwDefinitions.h index 4b3eeee7..b8905002 100644 --- a/mission/devices/devicedefinitions/RwDefinitions.h +++ b/mission/devices/devicedefinitions/RwDefinitions.h @@ -46,7 +46,7 @@ enum PoolIds: lp_id_t { }; enum States: uint8_t { - ERROR, + STATE_ERROR, IDLE, COASTING, RUNNING_SPEED_STABLE, From 54e5fef8fd5235ffdaa812f8c770f8bff082082d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 9 Dec 2021 13:43:28 +0100 Subject: [PATCH 124/465] update to updated fsfw --- bsp_q7s/core/ObjectFactory.cpp | 148 +++++++++--------- bsp_q7s/gpio/gpioCallbacks.cpp | 19 ++- fsfw | 2 +- linux/boardtest/SpiTestClass.cpp | 34 ++-- linux/devices/StarTrackerHandler.h | 2 +- .../pollingSequenceFactory.cpp | 42 ++--- 6 files changed, 127 insertions(+), 120 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index bf8a2fba..bc428f05 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -20,11 +20,14 @@ #include "bsp_q7s/callbacks/gnssCallback.h" #include "linux/devices/HeaterHandler.h" +#include "linux/devices/StarTrackerHandler.h" #include "linux/devices/SolarArrayDeploymentHandler.h" #include "linux/devices/devicedefinitions/SusDefinitions.h" #include "linux/devices/SusHandler.h" #include "linux/csp/CspCookie.h" #include "linux/csp/CspComIF.h" +#include "linux/devices/devicedefinitions/StarTrackerDefinitions.h" + #include "mission/core/GenericFactory.h" #include "mission/devices/PDU1Handler.h" #include "mission/devices/PDU2Handler.h" @@ -39,14 +42,13 @@ #include "mission/devices/PlocMPSoCHandler.h" #include "mission/devices/RadiationSensorHandler.h" #include "mission/devices/RwHandler.h" -#include "mission/devices/StarTrackerHandler.h" #include "mission/devices/devicedefinitions/GomspaceDefinitions.h" #include "mission/devices/devicedefinitions/SyrlinksDefinitions.h" #include "mission/devices/devicedefinitions/PlocMPSoCDefinitions.h" #include "mission/devices/devicedefinitions/RadSensorDefinitions.h" #include "mission/devices/devicedefinitions/Max31865Definitions.h" #include "mission/devices/devicedefinitions/RwDefinitions.h" -#include "mission/devices/devicedefinitions/StarTrackerDefinitions.h" + #include "mission/devices/GPSHyperionHandler.h" #include "mission/tmtc/CCSDSHandler.h" #include "mission/tmtc/VirtualChannel.h" @@ -264,7 +266,7 @@ void ObjectFactory::createRadSensorComponent(LinuxLibgpioIF* gpioComIF) { std::stringstream consumer; consumer << "0x" << std::hex << objects::RAD_SENSOR; GpiodRegularByLineName* gpio = new GpiodRegularByLineName( - q7s::gpioNames::RAD_SENSOR_CHIP_SELECT, consumer.str(), gpio::OUT, gpio::HIGH); + q7s::gpioNames::RAD_SENSOR_CHIP_SELECT, consumer.str(), gpio::DIR_OUT, gpio::HIGH); gpioCookieRadSensor->addGpio(gpioIds::CS_RAD_SENSOR, gpio); gpioComIF->addGpios(gpioCookieRadSensor); @@ -278,43 +280,43 @@ void ObjectFactory::createSunSensorComponents(LinuxLibgpioIF *gpioComIF, SpiComI GpioCookie* gpioCookieSus = new GpioCookie(); GpioCallback* susgpio = nullptr; - susgpio = new GpioCallback("Chip select SUS 1", gpio::OUT, gpio::HIGH, + susgpio = new GpioCallback("Chip select SUS 1", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_1, susgpio); - susgpio = new GpioCallback("Chip select SUS 2", gpio::OUT, gpio::HIGH, + susgpio = new GpioCallback("Chip select SUS 2", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_2, susgpio); - susgpio = new GpioCallback("Chip select SUS 3", gpio::OUT, gpio::HIGH, + susgpio = new GpioCallback("Chip select SUS 3", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_3, susgpio); - susgpio = new GpioCallback("Chip select SUS 4", gpio::OUT, gpio::HIGH, + susgpio = new GpioCallback("Chip select SUS 4", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_4, susgpio); - susgpio = new GpioCallback("Chip select SUS 5", gpio::OUT, gpio::HIGH, + susgpio = new GpioCallback("Chip select SUS 5", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_5, susgpio); - susgpio = new GpioCallback("Chip select SUS 6", gpio::OUT, gpio::HIGH, + susgpio = new GpioCallback("Chip select SUS 6", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_6, susgpio); - susgpio = new GpioCallback("Chip select SUS 7", gpio::OUT, gpio::HIGH, + susgpio = new GpioCallback("Chip select SUS 7", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_7, susgpio); - susgpio = new GpioCallback("Chip select SUS 8", gpio::OUT, gpio::HIGH, + susgpio = new GpioCallback("Chip select SUS 8", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_8, susgpio); - susgpio = new GpioCallback("Chip select SUS 9", gpio::OUT, gpio::HIGH, + susgpio = new GpioCallback("Chip select SUS 9", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_9, susgpio); - susgpio = new GpioCallback("Chip select SUS 10", gpio::OUT, gpio::HIGH, + susgpio = new GpioCallback("Chip select SUS 10", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_10, susgpio); - susgpio = new GpioCallback("Chip select SUS 11", gpio::OUT, gpio::HIGH, + susgpio = new GpioCallback("Chip select SUS 11", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_11, susgpio); - susgpio = new GpioCallback("Chip select SUS 12", gpio::OUT, gpio::HIGH, + susgpio = new GpioCallback("Chip select SUS 12", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_12, susgpio); - susgpio = new GpioCallback("Chip select SUS 13", gpio::OUT, gpio::HIGH, + susgpio = new GpioCallback("Chip select SUS 13", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_13, susgpio); @@ -395,61 +397,61 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI GpiodRegularByLineName* gpio = nullptr; consumer << "0x" << std::hex << objects::GYRO_0_ADIS_HANDLER; gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ADIS_CS, consumer.str(), - gpio::OUT, gpio::HIGH); + gpio::DIR_OUT, gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); consumer.str(""); consumer << "0x" << std::hex << objects::GYRO_1_L3G_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_1_L3G_CS, consumer.str(), gpio::OUT, + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_1_L3G_CS, consumer.str(), gpio::DIR_OUT, gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); consumer.str(""); consumer << "0x" << std::hex << objects::GYRO_2_ADIS_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ADIS_CS, consumer.str(), gpio::OUT, + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ADIS_CS, consumer.str(), gpio::DIR_OUT, gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::GYRO_2_ADIS_CS, gpio); consumer.str(""); consumer << "0x" << std::hex << objects::GYRO_3_L3G_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_3_L3G_CS, consumer.str(), gpio::OUT, + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_3_L3G_CS, consumer.str(), gpio::DIR_OUT, gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); consumer.str(""); consumer << "0x" << std::hex << objects::MGM_0_LIS3_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_0_CS, consumer.str(), gpio::OUT, + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_0_CS, consumer.str(), gpio::DIR_OUT, gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); consumer.str(""); consumer << "0x" << std::hex << objects::MGM_1_RM3100_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, consumer.str(), gpio::OUT, + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, consumer.str(), gpio::DIR_OUT, gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); consumer.str(""); consumer << "0x" << std::hex << objects::MGM_2_LIS3_HANDLER; gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_2_CS, consumer.str(), - gpio::OUT, gpio::HIGH); + gpio::DIR_OUT, gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); consumer.str(""); consumer << "0x" << std::hex << objects::MGM_3_RM3100_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_3_CS, consumer.str(), gpio::OUT, + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_3_CS, consumer.str(), gpio::DIR_OUT, gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); consumer.str(""); consumer << "0x" << std::hex << objects::GPS0_HANDLER; // GNSS reset pins are active low - gpio = new GpiodRegularByLineName(q7s::gpioNames::RESET_GNSS_0, consumer.str(), gpio::OUT, + gpio = new GpiodRegularByLineName(q7s::gpioNames::RESET_GNSS_0, consumer.str(), gpio::DIR_OUT, gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::GNSS_0_NRESET, gpio); consumer.str(""); consumer << "0x" << std::hex << objects::GPS1_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::RESET_GNSS_1, consumer.str(), gpio::OUT, + gpio = new GpiodRegularByLineName(q7s::gpioNames::RESET_GNSS_1, consumer.str(), gpio::DIR_OUT, gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::GNSS_1_NRESET, gpio); @@ -457,12 +459,12 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI consumer << "0x" << std::hex << objects::GYRO_0_ADIS_HANDLER; // Enable pins must be pulled low for regular operations gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, consumer.str(), - gpio::OUT, gpio::LOW); + gpio::DIR_OUT, gpio::LOW); gpioCookieAcsBoard->addGpio(gpioIds::GYRO_0_ENABLE, gpio); consumer.str(""); consumer << "0x" << std::hex << objects::GYRO_2_ADIS_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ENABLE, consumer.str(), gpio::OUT, + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ENABLE, consumer.str(), gpio::DIR_OUT, gpio::LOW); gpioCookieAcsBoard->addGpio(gpioIds::GYRO_2_ENABLE, gpio); @@ -576,37 +578,37 @@ void ObjectFactory::createHeaterComponents() { std::stringstream consumer; consumer << "0x" << std::hex << objects::HEATER_HANDLER; /* Pin H2-11 on stack connector */ - gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_0, consumer.str(), gpio::OUT, + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_0, consumer.str(), gpio::DIR_OUT, gpio::LOW); heaterGpiosCookie->addGpio(gpioIds::HEATER_0, gpio); /* Pin H2-12 on stack connector */ - gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_1, consumer.str(), gpio::OUT, + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_1, consumer.str(), gpio::DIR_OUT, gpio::LOW); heaterGpiosCookie->addGpio(gpioIds::HEATER_1, gpio); /* Pin H2-13 on stack connector */ - gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_2, consumer.str(), gpio::OUT, + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_2, consumer.str(), gpio::DIR_OUT, gpio::LOW); heaterGpiosCookie->addGpio(gpioIds::HEATER_2, gpio); gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_3, consumer.str(), - gpio::OUT, gpio::LOW); + gpio::DIR_OUT, gpio::LOW); heaterGpiosCookie->addGpio(gpioIds::HEATER_3, gpio); gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_4, consumer.str(), - gpio::OUT, gpio::LOW); + gpio::DIR_OUT, gpio::LOW); heaterGpiosCookie->addGpio(gpioIds::HEATER_4, gpio); gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_5, consumer.str(), - gpio::OUT, gpio::LOW); + gpio::DIR_OUT, gpio::LOW); heaterGpiosCookie->addGpio(gpioIds::HEATER_5, gpio); gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_6, consumer.str(), - gpio::OUT, gpio::LOW); + gpio::DIR_OUT, gpio::LOW); heaterGpiosCookie->addGpio(gpioIds::HEATER_6, gpio); gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_7, consumer.str(), - gpio::OUT, gpio::LOW); + gpio::DIR_OUT, gpio::LOW); heaterGpiosCookie->addGpio(gpioIds::HEATER_7, gpio); new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, heaterGpiosCookie, @@ -620,9 +622,9 @@ void ObjectFactory::createSolarArrayDeploymentComponents() { std::stringstream consumer; consumer << "0x" << std::hex << objects::SOLAR_ARRAY_DEPL_HANDLER; gpio = new GpiodRegularByLineName(q7s::gpioNames::SA_DPL_PIN_0, - consumer.str(), gpio::OUT, gpio::LOW); + consumer.str(), gpio::DIR_OUT, gpio::LOW); solarArrayDeplCookie->addGpio(gpioIds::DEPLSA1, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::SA_DPL_PIN_1, consumer.str(), gpio::OUT, + gpio = new GpiodRegularByLineName(q7s::gpioNames::SA_DPL_PIN_1, consumer.str(), gpio::DIR_OUT, gpio::LOW); solarArrayDeplCookie->addGpio(gpioIds::DEPLSA2, gpio); @@ -644,52 +646,52 @@ void ObjectFactory::createSyrlinksComponents() { void ObjectFactory::createRtdComponents(LinuxLibgpioIF *gpioComIF) { GpioCookie* rtdGpioCookie = new GpioCookie; - GpioCallback* gpioRtdIc0 = new GpioCallback("Chip select RTD IC0", gpio::OUT, gpio::HIGH, + GpioCallback* gpioRtdIc0 = new GpioCallback("Chip select RTD IC0", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC_3, gpioRtdIc0); - GpioCallback* gpioRtdIc1 = new GpioCallback("Chip select RTD IC1", gpio::OUT, gpio::HIGH, + GpioCallback* gpioRtdIc1 = new GpioCallback("Chip select RTD IC1", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC_4, gpioRtdIc1); - GpioCallback* gpioRtdIc2 = new GpioCallback("Chip select RTD IC2", gpio::OUT, gpio::HIGH, + GpioCallback* gpioRtdIc2 = new GpioCallback("Chip select RTD IC2", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC_5, gpioRtdIc2); - GpioCallback* gpioRtdIc3 = new GpioCallback("Chip select RTD IC3", gpio::OUT, gpio::HIGH, + GpioCallback* gpioRtdIc3 = new GpioCallback("Chip select RTD IC3", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC_6, gpioRtdIc3); - GpioCallback* gpioRtdIc4 = new GpioCallback("Chip select RTD IC4", gpio::OUT, gpio::HIGH, + GpioCallback* gpioRtdIc4 = new GpioCallback("Chip select RTD IC4", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC_7, gpioRtdIc4); - GpioCallback* gpioRtdIc5 = new GpioCallback("Chip select RTD IC5", gpio::OUT, gpio::HIGH, + GpioCallback* gpioRtdIc5 = new GpioCallback("Chip select RTD IC5", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC_8, gpioRtdIc5); - GpioCallback* gpioRtdIc6 = new GpioCallback("Chip select RTD IC6", gpio::OUT, gpio::HIGH, + GpioCallback* gpioRtdIc6 = new GpioCallback("Chip select RTD IC6", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC_9, gpioRtdIc6); - GpioCallback* gpioRtdIc7 = new GpioCallback("Chip select RTD IC7", gpio::OUT, gpio::HIGH, + GpioCallback* gpioRtdIc7 = new GpioCallback("Chip select RTD IC7", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC_10, gpioRtdIc7); - GpioCallback* gpioRtdIc8 = new GpioCallback("Chip select RTD IC8", gpio::OUT, gpio::HIGH, + GpioCallback* gpioRtdIc8 = new GpioCallback("Chip select RTD IC8", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC_11, gpioRtdIc8); - GpioCallback* gpioRtdIc9 = new GpioCallback("Chip select RTD IC9", gpio::OUT, gpio::HIGH, + GpioCallback* gpioRtdIc9 = new GpioCallback("Chip select RTD IC9", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC_12, gpioRtdIc9); - GpioCallback* gpioRtdIc10 = new GpioCallback("Chip select RTD IC10", gpio::OUT, gpio::HIGH, + GpioCallback* gpioRtdIc10 = new GpioCallback("Chip select RTD IC10", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC_13, gpioRtdIc10); - GpioCallback* gpioRtdIc11 = new GpioCallback("Chip select RTD IC11", gpio::OUT, gpio::HIGH, + GpioCallback* gpioRtdIc11 = new GpioCallback("Chip select RTD IC11", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC_14, gpioRtdIc11); - GpioCallback* gpioRtdIc12 = new GpioCallback("Chip select RTD IC12", gpio::OUT, gpio::HIGH, + GpioCallback* gpioRtdIc12 = new GpioCallback("Chip select RTD IC12", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC_15, gpioRtdIc12); - GpioCallback* gpioRtdIc13 = new GpioCallback("Chip select RTD IC13", gpio::OUT, gpio::HIGH, + GpioCallback* gpioRtdIc13 = new GpioCallback("Chip select RTD IC13", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC_16, gpioRtdIc13); - GpioCallback* gpioRtdIc14 = new GpioCallback("Chip select RTD IC14", gpio::OUT, gpio::HIGH, + GpioCallback* gpioRtdIc14 = new GpioCallback("Chip select RTD IC14", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC_17, gpioRtdIc14); - GpioCallback* gpioRtdIc15 = new GpioCallback("Chip select RTD IC15", gpio::OUT, gpio::HIGH, + GpioCallback* gpioRtdIc15 = new GpioCallback("Chip select RTD IC15", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC_18, gpioRtdIc15); @@ -794,38 +796,38 @@ void ObjectFactory::createRtdComponents(LinuxLibgpioIF *gpioComIF) { void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF) { GpioCookie* gpioCookieRw = new GpioCookie; - GpioCallback* csRw1 = new GpioCallback("Chip select reaction wheel 1", gpio::OUT, gpio::HIGH, + GpioCallback* csRw1 = new GpioCallback("Chip select reaction wheel 1", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieRw->addGpio(gpioIds::CS_RW1, csRw1); - GpioCallback* csRw2 = new GpioCallback("Chip select reaction wheel 2", gpio::OUT, gpio::HIGH, + GpioCallback* csRw2 = new GpioCallback("Chip select reaction wheel 2", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieRw->addGpio(gpioIds::CS_RW2, csRw2); - GpioCallback* csRw3 = new GpioCallback("Chip select reaction wheel 3", gpio::OUT, gpio::HIGH, + GpioCallback* csRw3 = new GpioCallback("Chip select reaction wheel 3", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieRw->addGpio(gpioIds::CS_RW3, csRw3); - GpioCallback* csRw4 = new GpioCallback("Chip select reaction wheel 4", gpio::OUT, gpio::HIGH, + GpioCallback* csRw4 = new GpioCallback("Chip select reaction wheel 4", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieRw->addGpio(gpioIds::CS_RW4, csRw4); std::stringstream consumer; GpiodRegularByLineName* gpio = nullptr; consumer << "0x" << std::hex << objects::RW1; - gpio = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_1, consumer.str(), gpio::OUT, + gpio = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_1, consumer.str(), gpio::DIR_OUT, gpio::LOW); gpioCookieRw->addGpio(gpioIds::EN_RW1, gpio); consumer.str(""); consumer << "0x" << std::hex << objects::RW2; - gpio = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_2, consumer.str(), gpio::OUT, + gpio = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_2, consumer.str(), gpio::DIR_OUT, gpio::LOW); gpioCookieRw->addGpio(gpioIds::EN_RW2, gpio); consumer.str(""); consumer << "0x" << std::hex << objects::RW3; - gpio = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_3, consumer.str(), gpio::OUT, + gpio = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_3, consumer.str(), gpio::DIR_OUT, gpio::LOW); gpioCookieRw->addGpio(gpioIds::EN_RW3, gpio); consumer.str(""); consumer << "0x" << std::hex << objects::RW4; - gpio = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_4, consumer.str(), gpio::OUT, + gpio = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_4, consumer.str(), gpio::DIR_OUT, gpio::LOW); gpioCookieRw->addGpio(gpioIds::EN_RW4, gpio); @@ -835,7 +837,7 @@ void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF) { * Per default the PS SPI is selected (EMIO = 0). */ gpio = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_SELECT, - "SPI Reaction Wheel Callback ", gpio::OUT, gpio::LOW); + "SPI Reaction Wheel Callback ", gpio::DIR_OUT, gpio::LOW); gpioCookieRw->addGpio(gpioIds::SPI_MUX, gpio); gpioComIF->addGpios(gpioCookieRw); @@ -943,7 +945,7 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF *gpioComIF) { 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::OUT, + 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); @@ -968,7 +970,7 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF *gpioComIF) { consumer.str(""); consumer << "0x" << std::hex << objects::PDEC_HANDLER; // GPIO also low after linux boot (specified by device-tree) - gpio = new GpiodRegularByLineName(q7s::gpioNames::PDEC_RESET, consumer.str(), gpio::OUT, + gpio = new GpiodRegularByLineName(q7s::gpioNames::PDEC_RESET, consumer.str(), gpio::DIR_OUT, gpio::LOW); gpioCookiePdec->addGpio(gpioIds::PDEC_RESET, gpio); @@ -981,18 +983,18 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF *gpioComIF) { #if BOARD_TE0720 == 0 GpioCookie* gpioRS485Chip = new GpioCookie; gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_TX_CLOCK, "RS485 Transceiver", - gpio::Direction::OUT, gpio::LOW); + gpio::Direction::DIR_OUT, gpio::LOW); gpioRS485Chip->addGpio(gpioIds::RS485_EN_TX_CLOCK, gpio); gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_TX_DATA, "RS485 Transceiver", - gpio::Direction::OUT, gpio::LOW); + gpio::Direction::DIR_OUT, gpio::LOW); gpioRS485Chip->addGpio(gpioIds::RS485_EN_TX_DATA, gpio); // Default configuration enables RX channels (RXEN = LOW) gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_RX_CLOCK, "RS485 Transceiver", - gpio::Direction::OUT, gpio::LOW); + gpio::Direction::DIR_OUT, gpio::LOW); gpioRS485Chip->addGpio(gpioIds::RS485_EN_RX_CLOCK, gpio); gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_RX_DATA, "RS485 Transceiver", - gpio::Direction::OUT, gpio::LOW); + gpio::Direction::DIR_OUT, gpio::LOW); gpioRS485Chip->addGpio(gpioIds::RS485_EN_RX_DATA, gpio); gpioComIF->addGpios(gpioRS485Chip); @@ -1008,10 +1010,10 @@ void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) { #if BOARD_TE0720 == 1 && OBSW_TEST_LIBGPIOD == 1 #if OBSW_TEST_GPIO_OPEN_BYLABEL == 1 /* Configure MIO0 as input */ - GpiodRegular* testGpio = new GpiodRegular("MIO0", gpio::OUT, 0, "/amba_pl/gpio@41200000", 0); + GpiodRegular* testGpio = new GpiodRegular("MIO0", gpio::DIR_OUT, 0, "/amba_pl/gpio@41200000", 0); #elif OBSW_TEST_GPIO_OPEN_BY_LINE_NAME GpiodRegularByLineName* testGpio = new GpiodRegularByLineName("test-name", "gpio-test", - gpio::OUT, 0); + gpio::DIR_OUT, 0); #else /* Configure MIO0 as input */ GpiodRegular* testGpio = new GpiodRegular("gpiochip0", 0, "MIO0", gpio::IN, 0); @@ -1024,7 +1026,7 @@ void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) { #if BOARD_TE0720 == 1 && OBSW_TEST_SUS_HANDLER == 1 GpioCookie* gpioCookieSus = new GpioCookie; GpiodRegular* chipSelectSus = new GpiodRegular(std::string("gpiochip1"), 9, - std::string("Chip Select Sus Sensor"), gpio::OUT, 1); + std::string("Chip Select Sus Sensor"), gpio::DIR_OUT, 1); gpioCookieSus->addGpio(gpioIds::CS_SUS_1, chipSelectSus); gpioComIF->addGpios(gpioCookieSus); @@ -1052,7 +1054,7 @@ void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) { #if BOARD_TE0720 == 1 && OBSW_TEST_RADIATION_SENSOR_HANDLER == 1 GpioCookie* gpioCookieRadSensor = new GpioCookie; GpiodRegular* chipSelectRadSensor = new GpiodRegular(std::string("gpiochip1"), 0, - std::string("Chip select radiation sensor"), gpio::OUT, 1); + std::string("Chip select radiation sensor"), gpio::DIR_OUT, 1); gpioCookieRadSensor->addGpio(gpioIds::CS_RAD_SENSOR, chipSelectRadSensor); gpioComIF->addGpios(gpioCookieRadSensor); diff --git a/bsp_q7s/gpio/gpioCallbacks.cpp b/bsp_q7s/gpio/gpioCallbacks.cpp index 38c5b46e..2cbf3320 100644 --- a/bsp_q7s/gpio/gpioCallbacks.cpp +++ b/bsp_q7s/gpio/gpioCallbacks.cpp @@ -27,13 +27,15 @@ void initSpiCsDecoder(GpioIF* gpioComIF) { GpiodRegularByLineName* spiMuxBit = nullptr; /** Setting mux bit 1 to low will disable IC21 on the interface board */ spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_1_PIN, "SPI Mux Bit 1", - gpio::OUT, gpio::HIGH); + gpio::DIR_OUT, gpio::HIGH); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_1, spiMuxBit); /** Setting mux bit 2 to low disables IC1 on the TCS board */ - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_2_PIN, "SPI Mux Bit 2", gpio::OUT, gpio::HIGH); + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_2_PIN, "SPI Mux Bit 2", + gpio::DIR_OUT, gpio::HIGH); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_2, spiMuxBit); /** Setting mux bit 3 to low disables IC2 on the TCS board and IC22 on the interface board */ - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_3_PIN, "SPI Mux Bit 3", gpio::OUT, gpio::LOW); + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_3_PIN, "SPI Mux Bit 3", + gpio::DIR_OUT, gpio::LOW); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_3, spiMuxBit); // spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_1_PIN, "SPI Mux Bit 1", @@ -47,14 +49,17 @@ void initSpiCsDecoder(GpioIF* gpioComIF) { // spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_3, spiMuxBit); /** The following gpios can take arbitrary initial values */ - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_4_PIN, "SPI Mux Bit 4", gpio::OUT, gpio::LOW); + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_4_PIN, "SPI Mux Bit 4", + gpio::DIR_OUT, gpio::LOW); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_4, spiMuxBit); - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_5_PIN, "SPI Mux Bit 5", gpio::OUT, gpio::LOW); + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_5_PIN, "SPI Mux Bit 5", + gpio::DIR_OUT, gpio::LOW); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_5, spiMuxBit); - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_6_PIN, "SPI Mux Bit 6", gpio::OUT, gpio::LOW); + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_6_PIN, "SPI Mux Bit 6", + gpio::DIR_OUT, gpio::LOW); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_6, spiMuxBit); GpiodRegularByLineName* enRwDecoder = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_CS, - "EN_RW_CS", gpio::OUT, gpio::HIGH); + "EN_RW_CS", gpio::DIR_OUT, gpio::HIGH); spiMuxGpios->addGpio(gpioIds::EN_RW_CS, enRwDecoder); result = gpioComInterface->addGpios(spiMuxGpios); diff --git a/fsfw b/fsfw index e4999fe0..bda02b46 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit e4999fe01c0446f9820ceede55be3970aa22bbad +Subproject commit bda02b464a2ad00b1a8e373d4c6b80b0a7c8de95 diff --git a/linux/boardtest/SpiTestClass.cpp b/linux/boardtest/SpiTestClass.cpp index 5168ba95..b043b55d 100644 --- a/linux/boardtest/SpiTestClass.cpp +++ b/linux/boardtest/SpiTestClass.cpp @@ -297,65 +297,65 @@ void SpiTestClass::acsInit() { GpiodRegularByChip* gpio = nullptr; std::string rpiGpioName = "gpiochip0"; gpio = new GpiodRegularByChip(rpiGpioName, mgm0Lis3mdlChipSelect, "MGM_0_LIS3", - gpio::Direction::OUT, 1); + gpio::DIR_OUT, 1); gpioCookie->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); gpio = new GpiodRegularByChip(rpiGpioName, mgm1Rm3100ChipSelect, "MGM_1_RM3100", - gpio::Direction::OUT, 1); + gpio::DIR_OUT, 1); gpioCookie->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); gpio = new GpiodRegularByChip(rpiGpioName, gyro0AdisChipSelect, "GYRO_0_ADIS", - gpio::Direction::OUT, 1); + gpio::DIR_OUT, 1); gpioCookie->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); gpio = new GpiodRegularByChip(rpiGpioName, gyro1L3gd20ChipSelect, "GYRO_1_L3G", - gpio::Direction::OUT, 1); + gpio::DIR_OUT, 1); gpioCookie->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); gpio = new GpiodRegularByChip(rpiGpioName, gyro3L3gd20ChipSelect, "GYRO_2_L3G", - gpio::Direction::OUT, 1); + gpio::DIR_OUT, 1); gpioCookie->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); gpio = new GpiodRegularByChip(rpiGpioName, mgm2Lis3mdlChipSelect, "MGM_2_LIS3", - gpio::Direction::OUT, 1); + gpio::DIR_OUT, 1); gpioCookie->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); gpio = new GpiodRegularByChip(rpiGpioName, mgm3Rm3100ChipSelect, "MGM_3_RM3100", - gpio::Direction::OUT, 1); + gpio::DIR_OUT, 1); gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); #elif defined(XIPHOS_Q7S) GpiodRegularByLineName* gpio = nullptr; - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_0_CS, "MGM_0_LIS3", gpio::Direction::OUT, + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_0_CS, "MGM_0_LIS3", gpio::DIR_OUT, gpio::HIGH); gpioCookie->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, "MGM_1_RM3100", gpio::Direction::OUT, + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, "MGM_1_RM3100", gpio::DIR_OUT, gpio::HIGH); gpioCookie->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_2_CS, "MGM_2_LIS3", gpio::Direction::OUT, + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_2_CS, "MGM_2_LIS3", gpio::DIR_OUT, gpio::HIGH); gpioCookie->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, "MGM_3_RM3100", gpio::Direction::OUT, + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, "MGM_3_RM3100", gpio::DIR_OUT, gpio::HIGH); gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ADIS_CS, "GYRO_0_ADIS", - gpio::Direction::OUT, gpio::HIGH); + gpio::DIR_OUT, gpio::HIGH); gpioCookie->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_1_L3G_CS, "GYRO_1_L3G", gpio::Direction::OUT, + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_1_L3G_CS, "GYRO_1_L3G", gpio::DIR_OUT, gpio::HIGH); gpioCookie->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ADIS_CS, "GYRO_2_ADIS", - gpio::Direction::OUT, gpio::HIGH); + gpio::DIR_OUT, gpio::HIGH); gpioCookie->addGpio(gpioIds::GYRO_2_ADIS_CS, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_3_L3G_CS, "GYRO_3_L3G", gpio::Direction::OUT, + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_3_L3G_CS, "GYRO_3_L3G", gpio::DIR_OUT, gpio::HIGH); gpioCookie->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); // Enable pins must be pulled low for regular operations - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, "GYRO_0_ENABLE", gpio::OUT, + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, "GYRO_0_ENABLE", gpio::DIR_OUT, gpio::LOW); gpioCookie->addGpio(gpioIds::GYRO_0_ENABLE, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, "GYRO_2_ENABLE", gpio::OUT, + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, "GYRO_2_ENABLE", gpio::DIR_OUT, gpio::LOW); gpioCookie->addGpio(gpioIds::GYRO_2_ENABLE, gpio); #endif diff --git a/linux/devices/StarTrackerHandler.h b/linux/devices/StarTrackerHandler.h index ee96e544..d659b9a8 100644 --- a/linux/devices/StarTrackerHandler.h +++ b/linux/devices/StarTrackerHandler.h @@ -2,7 +2,7 @@ #define MISSION_DEVICES_STARTRACKERHANDLER_H_ #include -#include +#include #include /** diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 69982156..02f37438 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -440,7 +440,7 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { #if OBSW_ADD_ACS_BOARD == 1 bool enableAside = true; - bool enableBside = false; + bool enableBside = true; if(enableAside) { // A side thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0, @@ -465,16 +465,16 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); -// thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, -// DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.3, -// DeviceHandlerIF::SEND_WRITE); -// thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, -// DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.75, -// DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.85, -// DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.3, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, + DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.75, + DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.85, + DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); @@ -512,16 +512,16 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); -// thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0, -// DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.3, -// DeviceHandlerIF::SEND_WRITE); -// thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.6, -// DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.75, -// DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.85, -// DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.3, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.6, + DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.75, + DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.85, + DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); From e64a3fb6459843291309497fac3ebd4e4ec59185 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 9 Dec 2021 15:02:30 +0100 Subject: [PATCH 125/465] rerun generators --- generators/bsp_q7s_events.csv | 22 +++++++------ generators/events/translateEvents.cpp | 34 ++++++++++++--------- linux/fsfwconfig/events/translateEvents.cpp | 34 ++++++++++++--------- 3 files changed, 52 insertions(+), 38 deletions(-) diff --git a/generators/bsp_q7s_events.csv b/generators/bsp_q7s_events.csv index fad7c714..0153c3e6 100644 --- a/generators/bsp_q7s_events.csv +++ b/generators/bsp_q7s_events.csv @@ -118,13 +118,15 @@ 11902;INVALID_FAR;HIGH;Read invalid FAR from PDEC after startup;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/obc/PdecHandler.h 11903;CARRIER_LOCK;INFO;Carrier lock detected;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/obc/PdecHandler.h 11904;BIT_LOCK_PDEC;INFO;Bit lock detected (data valid);C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/obc/PdecHandler.h -12000;IMAGE_FILE_NOT_EXISTS;LOW;Try to upload image but specified image does not exist;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/StrImageLoader.h -12001;SENDING_UPLOAD_PACKET_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/StrImageLoader.h -12002;UPLOAD_REQUESTING_MSG_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/StrImageLoader.h -12003;IMAGE_UPLOAD_SUCCESSFUL;LOW;Uploading image to star tracker was successful;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/StrImageLoader.h -12004;UPLOAD_READING_REPLY_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/StrImageLoader.h -12005;UPLOAD_COM_ERROR;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/StrImageLoader.h -12006;NO_REPLY;LOW;Star tracker did not send replies (maybe device is powered off)P1: Position of upload packet for which no reply was sent;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/StrImageLoader.h -12007;INVALID_TYPE_ID;LOW;Received reply with invalid type ID;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/StrImageLoader.h -12008;STATUS_ERROR;LOW;Status field in reply signals error;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/StrImageLoader.h -12009;DEC_ERROR;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/StrImageLoader.h +12000;IMAGE_FILE_NOT_EXISTS;LOW;Try to upload image but specified image does not exist;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h +12001;IMG_LOADER_SENDING_PACKET_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h +12002;IMG_LOADER_REQUESTING_MSG_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h +12003;IMAGE_UPLOAD_SUCCESSFUL;LOW;Uploading image to star tracker was successful;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h +12004;IMG_LOADER_READING_REPLY_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h +12005;IMG_LOADER_COM_ERROR;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h +12006;IMG_LOADER_NO_REPLY;LOW;Star tracker did not send replies (maybe device is powered off)P1: Position of upload or download packet for which no reply was sent;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h +12007;INVALID_TYPE_ID;LOW;Received reply with invalid type ID;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h +12008;STATUS_ERROR;LOW;Status field in reply signals error;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h +12009;IMG_LOADER_DEC_ERROR;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h +12010;IMAGE_DOWNLOAD_SUCCESSFUL;LOW;Image download was successful;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h +12011;POSITION_MISMATCH;LOW;Position mismatch P1: The expected position and thus the position for which the image upload/download failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp index dea56991..35f4ad9b 100644 --- a/generators/events/translateEvents.cpp +++ b/generators/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 130 translations. + * @brief Auto-generated event translation file. Contains 132 translations. * @details - * Generated on: 2021-12-04 11:03:12 + * Generated on: 2021-12-09 11:10:38 */ #include "translateEvents.h" @@ -126,15 +126,17 @@ const char *INVALID_FAR_STRING = "INVALID_FAR"; const char *CARRIER_LOCK_STRING = "CARRIER_LOCK"; const char *BIT_LOCK_PDEC_STRING = "BIT_LOCK_PDEC"; const char *IMAGE_FILE_NOT_EXISTS_STRING = "IMAGE_FILE_NOT_EXISTS"; -const char *SENDING_UPLOAD_PACKET_FAILED_STRING = "SENDING_UPLOAD_PACKET_FAILED"; -const char *UPLOAD_REQUESTING_MSG_FAILED_STRING = "UPLOAD_REQUESTING_MSG_FAILED"; +const char *IMG_LOADER_SENDING_PACKET_FAILED_STRING = "IMG_LOADER_SENDING_PACKET_FAILED"; +const char *IMG_LOADER_REQUESTING_MSG_FAILED_STRING = "IMG_LOADER_REQUESTING_MSG_FAILED"; const char *IMAGE_UPLOAD_SUCCESSFUL_STRING = "IMAGE_UPLOAD_SUCCESSFUL"; -const char *UPLOAD_READING_REPLY_FAILED_STRING = "UPLOAD_READING_REPLY_FAILED"; -const char *UPLOAD_COM_ERROR_STRING = "UPLOAD_COM_ERROR"; -const char *NO_REPLY_STRING = "NO_REPLY"; +const char *IMG_LOADER_READING_REPLY_FAILED_STRING = "IMG_LOADER_READING_REPLY_FAILED"; +const char *IMG_LOADER_COM_ERROR_STRING = "IMG_LOADER_COM_ERROR"; +const char *IMG_LOADER_NO_REPLY_STRING = "IMG_LOADER_NO_REPLY"; const char *INVALID_TYPE_ID_STRING = "INVALID_TYPE_ID"; const char *STATUS_ERROR_STRING = "STATUS_ERROR"; -const char *DEC_ERROR_STRING = "DEC_ERROR"; +const char *IMG_LOADER_DEC_ERROR_STRING = "IMG_LOADER_DEC_ERROR"; +const char *IMAGE_DOWNLOAD_SUCCESSFUL_STRING = "IMAGE_DOWNLOAD_SUCCESSFUL"; +const char *POSITION_MISMATCH_STRING = "POSITION_MISMATCH"; const char * translateEvents(Event event) { switch( (event & 0xffff) ) { @@ -381,23 +383,27 @@ const char * translateEvents(Event event) { case(12000): return IMAGE_FILE_NOT_EXISTS_STRING; case(12001): - return SENDING_UPLOAD_PACKET_FAILED_STRING; + return IMG_LOADER_SENDING_PACKET_FAILED_STRING; case(12002): - return UPLOAD_REQUESTING_MSG_FAILED_STRING; + return IMG_LOADER_REQUESTING_MSG_FAILED_STRING; case(12003): return IMAGE_UPLOAD_SUCCESSFUL_STRING; case(12004): - return UPLOAD_READING_REPLY_FAILED_STRING; + return IMG_LOADER_READING_REPLY_FAILED_STRING; case(12005): - return UPLOAD_COM_ERROR_STRING; + return IMG_LOADER_COM_ERROR_STRING; case(12006): - return NO_REPLY_STRING; + return IMG_LOADER_NO_REPLY_STRING; case(12007): return INVALID_TYPE_ID_STRING; case(12008): return STATUS_ERROR_STRING; case(12009): - return DEC_ERROR_STRING; + return IMG_LOADER_DEC_ERROR_STRING; + case(12010): + return IMAGE_DOWNLOAD_SUCCESSFUL_STRING; + case(12011): + return POSITION_MISMATCH_STRING; default: return "UNKNOWN_EVENT"; } diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index dea56991..35f4ad9b 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 130 translations. + * @brief Auto-generated event translation file. Contains 132 translations. * @details - * Generated on: 2021-12-04 11:03:12 + * Generated on: 2021-12-09 11:10:38 */ #include "translateEvents.h" @@ -126,15 +126,17 @@ const char *INVALID_FAR_STRING = "INVALID_FAR"; const char *CARRIER_LOCK_STRING = "CARRIER_LOCK"; const char *BIT_LOCK_PDEC_STRING = "BIT_LOCK_PDEC"; const char *IMAGE_FILE_NOT_EXISTS_STRING = "IMAGE_FILE_NOT_EXISTS"; -const char *SENDING_UPLOAD_PACKET_FAILED_STRING = "SENDING_UPLOAD_PACKET_FAILED"; -const char *UPLOAD_REQUESTING_MSG_FAILED_STRING = "UPLOAD_REQUESTING_MSG_FAILED"; +const char *IMG_LOADER_SENDING_PACKET_FAILED_STRING = "IMG_LOADER_SENDING_PACKET_FAILED"; +const char *IMG_LOADER_REQUESTING_MSG_FAILED_STRING = "IMG_LOADER_REQUESTING_MSG_FAILED"; const char *IMAGE_UPLOAD_SUCCESSFUL_STRING = "IMAGE_UPLOAD_SUCCESSFUL"; -const char *UPLOAD_READING_REPLY_FAILED_STRING = "UPLOAD_READING_REPLY_FAILED"; -const char *UPLOAD_COM_ERROR_STRING = "UPLOAD_COM_ERROR"; -const char *NO_REPLY_STRING = "NO_REPLY"; +const char *IMG_LOADER_READING_REPLY_FAILED_STRING = "IMG_LOADER_READING_REPLY_FAILED"; +const char *IMG_LOADER_COM_ERROR_STRING = "IMG_LOADER_COM_ERROR"; +const char *IMG_LOADER_NO_REPLY_STRING = "IMG_LOADER_NO_REPLY"; const char *INVALID_TYPE_ID_STRING = "INVALID_TYPE_ID"; const char *STATUS_ERROR_STRING = "STATUS_ERROR"; -const char *DEC_ERROR_STRING = "DEC_ERROR"; +const char *IMG_LOADER_DEC_ERROR_STRING = "IMG_LOADER_DEC_ERROR"; +const char *IMAGE_DOWNLOAD_SUCCESSFUL_STRING = "IMAGE_DOWNLOAD_SUCCESSFUL"; +const char *POSITION_MISMATCH_STRING = "POSITION_MISMATCH"; const char * translateEvents(Event event) { switch( (event & 0xffff) ) { @@ -381,23 +383,27 @@ const char * translateEvents(Event event) { case(12000): return IMAGE_FILE_NOT_EXISTS_STRING; case(12001): - return SENDING_UPLOAD_PACKET_FAILED_STRING; + return IMG_LOADER_SENDING_PACKET_FAILED_STRING; case(12002): - return UPLOAD_REQUESTING_MSG_FAILED_STRING; + return IMG_LOADER_REQUESTING_MSG_FAILED_STRING; case(12003): return IMAGE_UPLOAD_SUCCESSFUL_STRING; case(12004): - return UPLOAD_READING_REPLY_FAILED_STRING; + return IMG_LOADER_READING_REPLY_FAILED_STRING; case(12005): - return UPLOAD_COM_ERROR_STRING; + return IMG_LOADER_COM_ERROR_STRING; case(12006): - return NO_REPLY_STRING; + return IMG_LOADER_NO_REPLY_STRING; case(12007): return INVALID_TYPE_ID_STRING; case(12008): return STATUS_ERROR_STRING; case(12009): - return DEC_ERROR_STRING; + return IMG_LOADER_DEC_ERROR_STRING; + case(12010): + return IMAGE_DOWNLOAD_SUCCESSFUL_STRING; + case(12011): + return POSITION_MISMATCH_STRING; default: return "UNKNOWN_EVENT"; } From 1895d7c3db2a5bbe823ebb5821b783968e159b71 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 9 Dec 2021 15:02:58 +0100 Subject: [PATCH 126/465] fix in image upload function --- .../startracker/StarTrackerDefinitions.h | 16 +++ .../startracker/StarTrackerHandler.cpp | 32 ++++-- .../devices/startracker/StarTrackerHandler.h | 5 + .../devices/startracker/StrImageLoader.cpp | 107 ++++++++++++------ bsp_q7s/devices/startracker/StrImageLoader.h | 75 ++++++++---- 5 files changed, 167 insertions(+), 68 deletions(-) diff --git a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h index 6ea8d6f7..e74d8a51 100644 --- a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h +++ b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h @@ -90,10 +90,15 @@ static const DeviceCommandId_t BOOT = 1; static const DeviceCommandId_t REQ_VERSION = 2; static const DeviceCommandId_t REQ_INTERFACE = 3; static const DeviceCommandId_t REQ_TIME = 4; +static const DeviceCommandId_t ERASE = 5; +static const DeviceCommandId_t UNLOCK = 6; static const DeviceCommandId_t REBOOT = 7; static const DeviceCommandId_t DOWNLOAD_IMAGE = 9; static const DeviceCommandId_t UPLOAD_IMAGE = 10; static const DeviceCommandId_t REQ_POWER = 11; +static const DeviceCommandId_t TAKE_IMAGE = 15; +static const DeviceCommandId_t DOWNLOAD_CENTROID = 16; +static const DeviceCommandId_t UPLOAD_CENTROID = 17; static const DeviceCommandId_t SUBSCRIBE_TO_TM = 18; static const DeviceCommandId_t REQ_SOLUTION = 24; static const DeviceCommandId_t REQ_TEMPERATURE = 25; @@ -107,6 +112,11 @@ static const DeviceCommandId_t MATCHING = 46; static const DeviceCommandId_t TRACKING = 47; static const DeviceCommandId_t VALIDATION = 48; static const DeviceCommandId_t ALGO = 49; +static const DeviceCommandId_t CHECKSUM = 50; +static const DeviceCommandId_t READ = 51; +static const DeviceCommandId_t WRITE = 52; +static const DeviceCommandId_t DOWNLOAD_MATCHED_STAR = 53; +static const DeviceCommandId_t DOWNLOAD_DB_IMAGE = 54; static const DeviceCommandId_t NONE = 0xFFFFFFFF; static const uint32_t VERSION_SET_ID = REQ_VERSION; @@ -149,6 +159,12 @@ namespace ID { static const uint8_t SOLUTION = 24; static const uint8_t TEMPERATURE = 25; static const uint8_t TIME = 1; + static const uint8_t WRITE = 2; + static const uint8_t READ = 3; + static const uint8_t CHECKSUM = 4; + static const uint8_t ERASE = 5; + static const uint8_t UNLOCK = 6; + static const uint8_t TAKE_IMAGE = 15; } /** diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp index d0a926a0..9244b967 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp @@ -86,7 +86,7 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu return EXECUTION_FINISHED; } case(StarTracker::DOWNLOAD_IMAGE): { - strImageLoader->startImageDownload(); + strImageLoader->startImageDownload(std::string(reinterpret_cast(data), size)); imageLoaderExecuting = true; return EXECUTION_FINISHED; } @@ -167,12 +167,6 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi prepareInterfaceRequest(); return RETURN_OK; } - case (StarTracker::UPLOAD_IMAGE): { - std::string uploadImage = std::string(reinterpret_cast(commandData), - commandDataLen); - strImageLoader->startImageUpload(uploadImage); - return result; - } case (StarTracker::REQ_POWER): { preparePowerRequest(); return RETURN_OK; @@ -181,6 +175,10 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi prepareRebootCommand(); return RETURN_OK; } + case (StarTracker::TAKE_IMAGE): { + prepareTakeImageCommand(); + return RETURN_OK; + } case (StarTracker::SUBSCRIBE_TO_TM): { prepareSubscriptionCommand(commandData); return RETURN_OK; @@ -261,6 +259,7 @@ void StarTrackerHandler::fillCommandAndReplyMap() { this->insertInCommandAndReplyMap(StarTracker::REQ_TIME, 3, &timeSet, StarTracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandMap(StarTracker::UPLOAD_IMAGE); + this->insertInCommandMap(StarTracker::DOWNLOAD_IMAGE); this->insertInCommandAndReplyMap(StarTracker::REQ_POWER, 3, &powerSet, StarTracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(StarTracker::REQ_INTERFACE, 3, &interfaceSet, @@ -293,6 +292,8 @@ void StarTrackerHandler::fillCommandAndReplyMap() { StarTracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(StarTracker::ALGO, 3, nullptr, StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::TAKE_IMAGE, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); } ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t remainingSize, @@ -365,6 +366,10 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con result = handleActionReply(); break; } + case (StarTracker::TAKE_IMAGE): { + result = handleActionReply(); + break; + } case (StarTracker::REQ_VERSION): { result = handleVersionTm(); break; @@ -522,6 +527,10 @@ ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t *foundId) *foundId = StarTracker::BOOT; break; } + case (StarTracker::ID::TAKE_IMAGE): { + *foundId = StarTracker::TAKE_IMAGE; + break; + } case (StarTracker::ID::UPLOAD_IMAGE): { *foundId = StarTracker::UPLOAD_IMAGE; break; @@ -701,6 +710,15 @@ void StarTrackerHandler::prepareRebootCommand() { rawPacketLen = dataLinkLayer.getEncodedLength(); } +void StarTrackerHandler::prepareTakeImageCommand() { + uint32_t length = 0; + struct CameraActionRequest camReq; + arc_pack_camera_action_req(&camReq, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); +} + void StarTrackerHandler::prepareSubscriptionCommand(const uint8_t* tmId) { uint32_t length = 18; commandBuffer[0] = TMTC_SETPARAMREQ; diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.h b/bsp_q7s/devices/startracker/StarTrackerHandler.h index 3f3c8197..5c7de4fa 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.h +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.h @@ -183,6 +183,11 @@ private: */ void prepareBootCommand(); + /** + * @brief Fills the command buffer with the command to take an image. + */ + void prepareTakeImageCommand(); + /** * @brief Fills command buffer with data to request the version telemetry packet */ diff --git a/bsp_q7s/devices/startracker/StrImageLoader.cpp b/bsp_q7s/devices/startracker/StrImageLoader.cpp index 9d49d8bf..998d3f1c 100644 --- a/bsp_q7s/devices/startracker/StrImageLoader.cpp +++ b/bsp_q7s/devices/startracker/StrImageLoader.cpp @@ -37,6 +37,11 @@ ReturnValue_t StrImageLoader::performOperation(uint8_t operationCode) { break; } case InternalState::DOWNLOAD_IMAGE: + result = performImageDownload(); + if (result == RETURN_OK){ + triggerEvent(IMAGE_DOWNLOAD_SUCCESSFUL); + } + internalState = InternalState::IDLE; break; } } @@ -51,7 +56,6 @@ void StrImageLoader::setComCookie(CookieIF* comCookie_) { } ReturnValue_t StrImageLoader::startImageUpload(std::string image) { - // Check if file is stored on SD card and if associated SD card is mounted if (image.substr(0, sizeof(SdCardManager::SD_0_MOUNT_POINT)) == std::string(SdCardManager::SD_0_MOUNT_POINT)) { @@ -66,31 +70,58 @@ ReturnValue_t StrImageLoader::startImageUpload(std::string image) { return SD_NOT_MOUNTED; } } - uploadImage = image; - if(not std::filesystem::exists(uploadImage)) { return FILE_NOT_EXISTS; } - internalState = InternalState::UPLOAD_IMAGE; - semaphore.release(); - return RETURN_OK; } -ReturnValue_t StrImageLoader::startImageDownload() { +void StrImageLoader::startImageDownload(std::string downloadImage_) { + downloadImage = downloadImage_; + internalState = InternalState::DOWNLOAD_IMAGE; + semaphore.release(); +} + +ReturnValue_t StrImageLoader::performImageDownload() { + ReturnValue_t result; + struct DownloadActionRequest downloadReq; + uint32_t size = 0; + std::ofstream file(downloadImage, std::ios_base::app | std::ios_base::out); + while(downloadReq.position < LAST_POSITION) { + arc_pack_download_action_req(&downloadReq, commandBuffer, &size); + result = sendAndRead(size, downloadReq.position); + if (result != RETURN_OK) { + file.close(); + return result; + } + result = checkReply(); + if (result != RETURN_OK) { + file.close(); + return result; + } + result = checkReplyPosition(downloadReq.position); + if (result != RETURN_OK) { + file.close(); + return result; + } + file.write(reinterpret_cast(datalinkLayer.getReply() + DATA_OFFSET), + IMAGE_DATA_SIZE); + downloadReq.position++; + } + file.close(); return RETURN_OK; } ReturnValue_t StrImageLoader::performImageUpload() { ReturnValue_t result = RETURN_OK; + uint32_t size = 0; uint32_t imageSize = 0; struct UploadActionRequest uploadReq; uploadReq.position = 0; std::memset(&uploadReq.data, 0, sizeof(uploadReq.data)); - if (not std::filesystem::exists(uploadImage)) { triggerEvent(IMAGE_FILE_NOT_EXISTS, uploadReq.position); internalState = InternalState::IDLE; @@ -101,57 +132,51 @@ ReturnValue_t StrImageLoader::performImageUpload() { file.seekg(0, file.end); // tellg returns position of character in input stream imageSize = file.tellg(); - // Set position of next character to beginning of file input stream - file.seekg(0, file.beg); - if (imageSize >= SIZE_IMAGE_PART) { + while((uploadReq.position + 1) * SIZE_IMAGE_PART < imageSize) { + file.seekg(uploadReq.position * SIZE_IMAGE_PART, file.beg); file.read(reinterpret_cast(uploadReq.data), SIZE_IMAGE_PART); - } - else { - file.read(reinterpret_cast(uploadReq.data), imageSize); - } - while(uploadReq.position * SIZE_IMAGE_PART < imageSize) { - result = uploadSendAndRead(&uploadReq); + arc_pack_upload_action_req(&uploadReq, commandBuffer, &size); + result = sendAndRead(size, uploadReq.position); if (result != RETURN_OK) { return RETURN_FAILED; } - result = checkUploadReply(); + result = checkReply(); if (result != RETURN_OK) { return result; } uploadReq.position++; - file.seekg(uploadReq.position * SIZE_IMAGE_PART, file.beg); } std::memset(uploadReq.data, 0, sizeof(uploadReq.data)); uint32_t remainder = imageSize - uploadReq.position * SIZE_IMAGE_PART; + file.seekg(uploadReq.position * SIZE_IMAGE_PART, file.beg); file.read(reinterpret_cast(uploadReq.data), remainder); file.close(); uploadReq.position++; - result = uploadSendAndRead(&uploadReq); + arc_pack_upload_action_req(&uploadReq, commandBuffer, &size); + result = sendAndRead(size, uploadReq.position); if (result != RETURN_OK) { return RETURN_FAILED; } - result = checkUploadReply(); + result = checkReply(); if (result != RETURN_OK) { return result; } return RETURN_OK; } -ReturnValue_t StrImageLoader::uploadSendAndRead(struct UploadActionRequest* uploadReq) { +ReturnValue_t StrImageLoader::sendAndRead(size_t size, uint32_t position) { ReturnValue_t result = RETURN_OK; ReturnValue_t decResult = RETURN_OK; size_t receivedDataLen = 0; uint8_t *receivedData = nullptr; size_t bytesLeft = 0; - uint32_t size = 0; uint32_t missedReplies = 0; - arc_pack_upload_action_req(uploadReq, commandBuffer, &size); datalinkLayer.encodeFrame(commandBuffer, size); result = communicationInterface->sendMessage(comCookie, datalinkLayer.getEncodedFrame(), datalinkLayer.getEncodedLength()); if (result != RETURN_OK) { - sif::warning << "StrImageLoader::uploadImage: Failed to send upload packet" << std::endl; - triggerEvent(SENDING_UPLOAD_PACKET_FAILED, result, uploadReq->position); + sif::warning << "StrImageLoader::sendAndRead: Failed to send packet" << std::endl; + triggerEvent(IMG_LOADER_SENDING_PACKET_FAILED, result, position); return RETURN_FAILED; } decResult = ArcsecDatalinkLayer::DEC_IN_PROGRESS; @@ -159,14 +184,14 @@ ReturnValue_t StrImageLoader::uploadSendAndRead(struct UploadActionRequest* uplo result = communicationInterface->requestReceiveMessage(comCookie, StarTracker::MAX_FRAME_SIZE * 2 + 2); if (result != RETURN_OK) { - sif::warning << "StrImageLoader::uploadImage: Failed to request reply" << std::endl; - triggerEvent(UPLOAD_REQUESTING_MSG_FAILED, result, uploadReq->position); + sif::warning << "StrImageLoader::sendAndRead: Failed to request reply" << std::endl; + triggerEvent(IMG_LOADER_REQUESTING_MSG_FAILED, result, position); return RETURN_FAILED; } result = communicationInterface->readReceivedMessage(comCookie, &receivedData, &receivedDataLen); if (result != RETURN_OK) { - sif::warning << "StrImageLoader::uploadImage: Failed to read received message" << std::endl; - triggerEvent(UPLOAD_READING_REPLY_FAILED, result, uploadReq->position); + sif::warning << "StrImageLoader::sendAndRead: Failed to read received message" << std::endl; + triggerEvent(IMG_LOADER_READING_REPLY_FAILED, result, position); return RETURN_FAILED; } if (receivedDataLen == 0 && missedReplies < MAX_POLLS) { @@ -174,7 +199,7 @@ ReturnValue_t StrImageLoader::uploadSendAndRead(struct UploadActionRequest* uplo continue; } else if ((receivedDataLen == 0) && (missedReplies >= MAX_POLLS)) { - triggerEvent(NO_REPLY, uploadReq->position); + triggerEvent(IMG_LOADER_NO_REPLY, position); return RETURN_FAILED; } else { @@ -183,22 +208,22 @@ ReturnValue_t StrImageLoader::uploadSendAndRead(struct UploadActionRequest* uplo decResult = datalinkLayer.decodeFrame(receivedData, receivedDataLen, &bytesLeft); if (bytesLeft != 0) { // This should never happen - sif::warning << "StrImageLoader::uploadSendAndRead: Bytes left after decoding" << std::endl; - triggerEvent(UPLOAD_COM_ERROR, result, uploadReq->position); + sif::warning << "StrImageLoader::sendAndRead: Bytes left after decoding" << std::endl; + triggerEvent(IMG_LOADER_COM_ERROR, result, position); return RETURN_FAILED; } } if (decResult != RETURN_OK) { - triggerEvent(DEC_ERROR, decResult, uploadReq->position); + triggerEvent(IMG_LOADER_DEC_ERROR, decResult, position); return RETURN_FAILED; } return RETURN_OK; } -ReturnValue_t StrImageLoader::checkUploadReply() { +ReturnValue_t StrImageLoader::checkReply() { uint8_t type = datalinkLayer.getReplyFrameType(); if (type != TMTC_ACTIONREPLY) { - sif::warning << "StrImageLoader::checkUploadReply: Received invalid upload reply" + sif::warning << "StrImageLoader::checkUploadReply: Received reply with invalid type ID" << std::endl; triggerEvent(INVALID_TYPE_ID); return RETURN_FAILED; @@ -211,3 +236,13 @@ ReturnValue_t StrImageLoader::checkUploadReply() { } return RETURN_OK; } + +ReturnValue_t StrImageLoader::checkReplyPosition(uint32_t expectedPosition) { + uint32_t receivedPosition = 0; + std::memcpy(&receivedPosition, datalinkLayer.getReply() + POS_OFFSET, sizeof(receivedPosition)); + if (receivedPosition != expectedPosition) { + triggerEvent(POSITION_MISMATCH, receivedPosition); + return RETURN_FAILED; + } + return RETURN_OK; +} diff --git a/bsp_q7s/devices/startracker/StrImageLoader.h b/bsp_q7s/devices/startracker/StrImageLoader.h index e53e57d1..2f486658 100644 --- a/bsp_q7s/devices/startracker/StrImageLoader.h +++ b/bsp_q7s/devices/startracker/StrImageLoader.h @@ -29,35 +29,40 @@ public: //! [EXPORT] : [COMMENT] Try to upload image but specified image does not exist static const Event IMAGE_FILE_NOT_EXISTS = MAKE_EVENT(0, severity::LOW); - //! [EXPORT] : [COMMENT] Sending image upload packet to star tracker failed + //! [EXPORT] : [COMMENT] Sending packet (download or upload) to star tracker failed //!P1: Return code of communication interface sendMessage function - //!P2: Position of upload packet for which the transmission failed - static const Event SENDING_UPLOAD_PACKET_FAILED = MAKE_EVENT(1, severity::LOW); + //!P2: Position of upload/download packet for which the transmission failed + static const Event IMG_LOADER_SENDING_PACKET_FAILED = MAKE_EVENT(1, severity::LOW); //! [EXPORT] : [COMMENT] Communication interface requesting reply failed //!P1: Return code of failed request - //!P1: Upload position for which the request failed - static const Event UPLOAD_REQUESTING_MSG_FAILED = MAKE_EVENT(2, severity::LOW); + //!P1: Upload/download position for which the request failed + static const Event IMG_LOADER_REQUESTING_MSG_FAILED = MAKE_EVENT(2, severity::LOW); //! [EXPORT] : [COMMENT] Uploading image to star tracker was successful static const Event IMAGE_UPLOAD_SUCCESSFUL = MAKE_EVENT(3, severity::LOW); //! [EXPORT] : [COMMENT] Failed to read communication interface reply data //!P1: Return code of failed communication interface read call - //!P1: Upload position for which the read call failed - static const Event UPLOAD_READING_REPLY_FAILED = MAKE_EVENT(4, severity::LOW); + //!P1: Upload/download position for which the read call failed + static const Event IMG_LOADER_READING_REPLY_FAILED = MAKE_EVENT(4, severity::LOW); //! [EXPORT] : [COMMENT] Unexpected stop of decoding sequence //!P1: Return code of failed communication interface read call - //!P1: Upload position for which the read call failed - static const Event UPLOAD_COM_ERROR = MAKE_EVENT(5, severity::LOW); + //!P1: Upload/download position for which the read call failed + static const Event IMG_LOADER_COM_ERROR = MAKE_EVENT(5, severity::LOW); //! [EXPORT] : [COMMENT] Star tracker did not send replies (maybe device is powered off) - //!P1: Position of upload packet for which no reply was sent - static const Event NO_REPLY = MAKE_EVENT(6, severity::LOW); + //!P1: Position of upload or download packet for which no reply was sent + static const Event IMG_LOADER_NO_REPLY = MAKE_EVENT(6, severity::LOW); //! [EXPORT] : [COMMENT] Received reply with invalid type ID static const Event INVALID_TYPE_ID = MAKE_EVENT(7, severity::LOW); //! [EXPORT] : [COMMENT] Status field in reply signals error static const Event STATUS_ERROR = MAKE_EVENT(8, severity::LOW); //! [EXPORT] : [COMMENT] Error during decoding of received reply occurred //P1: Return value of decoding function - //P2: Position of upload packet for which reply decoding failed - static const Event DEC_ERROR = MAKE_EVENT(9, severity::LOW); + //P2: Position of upload/download packet for which reply decoding failed + static const Event IMG_LOADER_DEC_ERROR = MAKE_EVENT(9, severity::LOW); + //! [EXPORT] : [COMMENT] Image download was successful + static const Event IMAGE_DOWNLOAD_SUCCESSFUL = MAKE_EVENT(10, severity::LOW); + //! [EXPORT] : [COMMENT] Position mismatch + //! P1: The expected position and thus the position for which the image upload/download failed + static const Event POSITION_MISMATCH = MAKE_EVENT(11, severity::LOW); StrImageLoader(object_id_t objectId); @@ -80,7 +85,7 @@ public: /** * @brief Calling this function initiates the download of an image from the star tracker. */ - ReturnValue_t startImageDownload(); + void startImageDownload(std::string downloadImage_); private: @@ -94,8 +99,14 @@ private: // Size of one image part which can be sent per action request static const size_t SIZE_IMAGE_PART = 1024; + static const uint32_t LAST_POSITION = 4095; + static const uint32_t MAX_POLLS = 10000; + static const uint8_t POS_OFFSET = 2; + static const uint8_t DATA_OFFSET = 5; + static const size_t IMAGE_DATA_SIZE = 1024; + enum class InternalState { IDLE, UPLOAD_IMAGE, @@ -108,8 +119,10 @@ private: BinarySemaphore semaphore; - // Absolute path and name to image to upload + // Name including absolute path of image to upload std::string uploadImage; + // Name including the absolute path of downloaded image + std::string downloadImage; SdCardManager* sdcMan = nullptr; @@ -132,21 +145,33 @@ private: ReturnValue_t performImageUpload(); /** - * @brief Sends a upload image packet and receives the action reply. - * - * @param uploadReq Pointer to upload request structure to send - * - * @return RETURN_OK if successful, otherwise RETURN_FALIED + * @bried Performs download of last taken image from the star tracker. */ - ReturnValue_t uploadSendAndRead(struct UploadActionRequest* uploadReq); + ReturnValue_t performImageDownload(); /** - * @brief Checks the reply to an upload action request + * @brief Sends packet to the star tracker and reads reply by using the communication + * interface * - * @return RETURN_OK if reply confirms success of upload packet transfer, otherwise - * REUTRN_FAILED + * @return RETURN_OK if successful, otherwise RETURN_FAILED */ - ReturnValue_t checkUploadReply(); + ReturnValue_t sendAndRead(size_t size, uint32_t position); + + /** + * @brief Checks the reply header (type id and status fields) + * + * @return RETURN_OK if reply confirms success of packet transfer, otherwise REUTRN_FAILED + */ + ReturnValue_t checkReply(); + + /** + * @brief Checks the position field in a star tracker reply. + * + * @param expectedPosition Value of expected position + * + * @return RETURN_OK if received position matches expected position, otherwise RETURN_FAILED + */ + ReturnValue_t checkReplyPosition(uint32_t expectedPosition); }; #endif /* BSP_Q7S_DEVICES_STRIMAGELOADER_H_ */ From f9581f3100a2e2827edee08fcbdf6979c45cf7df Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Fri, 10 Dec 2021 10:07:23 +0100 Subject: [PATCH 127/465] command to reset error signal --- .../startracker/StarTrackerDefinitions.h | 3 ++ .../startracker/StarTrackerHandler.cpp | 42 +++++++++++++-- .../devices/startracker/StarTrackerHandler.h | 7 ++- .../devices/startracker/StrImageLoader.cpp | 51 +++++++++++++++++-- bsp_q7s/devices/startracker/StrImageLoader.h | 49 +++++++++++------- generators/bsp_q7s_events.csv | 14 ++--- generators/events/translateEvents.cpp | 30 ++++++----- linux/fsfwconfig/events/translateEvents.cpp | 30 ++++++----- thirdparty/arcsec_star_tracker | 2 +- 9 files changed, 169 insertions(+), 59 deletions(-) diff --git a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h index e74d8a51..f854d2ee 100644 --- a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h +++ b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h @@ -117,6 +117,8 @@ static const DeviceCommandId_t READ = 51; static const DeviceCommandId_t WRITE = 52; static const DeviceCommandId_t DOWNLOAD_MATCHED_STAR = 53; static const DeviceCommandId_t DOWNLOAD_DB_IMAGE = 54; +static const DeviceCommandId_t STOP_IMAGE_LOADER = 55; +static const DeviceCommandId_t RESET_ERROR = 56; static const DeviceCommandId_t NONE = 0xFFFFFFFF; static const uint32_t VERSION_SET_ID = REQ_VERSION; @@ -165,6 +167,7 @@ namespace ID { static const uint8_t ERASE = 5; static const uint8_t UNLOCK = 6; static const uint8_t TAKE_IMAGE = 15; + static const uint8_t ERROR_RESET = 12; } /** diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp index 9244b967..c7687e1c 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp @@ -49,7 +49,9 @@ ReturnValue_t StarTrackerHandler::initialize() { if (result != RETURN_OK) { return result; } - result = manager->subscribeToAllEventsFrom(eventQueue->getId(), objects::STR_IMG_LOADER); + result = manager->subscribeToEventRange(eventQueue->getId(), + event::getEventId(StrImageLoader::IMAGE_UPLOAD_FAILED), + event::getEventId(StrImageLoader::IMAGE_DOWNLOAD_SUCCESSFUL)); if (result != RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "StarTrackerHandler::initialize: Failed to subscribe to events form image" @@ -58,7 +60,10 @@ ReturnValue_t StarTrackerHandler::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } - strImageLoader->setComIF(communicationInterface); + result = strImageLoader->setComIF(communicationInterface); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } strImageLoader->setComCookie(comCookie); return RETURN_OK; } @@ -68,6 +73,11 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu ReturnValue_t result = RETURN_OK; + if (actionId == StarTracker::STOP_IMAGE_LOADER) { + strImageLoader->stopProcess(); + return EXECUTION_FINISHED; + } + if (imageLoaderExecuting == true) { return IMAGE_LOADER_EXECUTING; } @@ -176,7 +186,7 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi return RETURN_OK; } case (StarTracker::TAKE_IMAGE): { - prepareTakeImageCommand(); + prepareTakeImageCommand(commandData); return RETURN_OK; } case (StarTracker::SUBSCRIBE_TO_TM): { @@ -191,6 +201,10 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi prepareTemperatureRequest(); return RETURN_OK; } + case (StarTracker::RESET_ERROR): { + prepareErrorResetRequest(); + return RETURN_OK; + } case (StarTracker::LIMITS): { Limits limits; result = prepareParamCommand(commandData, commandDataLen, limits); @@ -294,6 +308,8 @@ void StarTrackerHandler::fillCommandAndReplyMap() { StarTracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(StarTracker::TAKE_IMAGE, 3, nullptr, StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::RESET_ERROR, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); } ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t remainingSize, @@ -366,6 +382,10 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con result = handleActionReply(); break; } + case (StarTracker::RESET_ERROR): { + result = handleActionReply(); + break; + } case (StarTracker::TAKE_IMAGE): { result = handleActionReply(); break; @@ -535,6 +555,10 @@ ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t *foundId) *foundId = StarTracker::UPLOAD_IMAGE; break; } + case (StarTracker::ID::ERROR_RESET): { + *foundId = StarTracker::RESET_ERROR; + break; + } default: sif::warning << "StarTrackerHandler::scanForParameterReply: Unknown parameter reply id" << std::endl; @@ -710,9 +734,10 @@ void StarTrackerHandler::prepareRebootCommand() { rawPacketLen = dataLinkLayer.getEncodedLength(); } -void StarTrackerHandler::prepareTakeImageCommand() { +void StarTrackerHandler::prepareTakeImageCommand(const uint8_t* commandData) { uint32_t length = 0; struct CameraActionRequest camReq; + camReq.actionid = *commandData; arc_pack_camera_action_req(&camReq, commandBuffer, &length); dataLinkLayer.encodeFrame(commandBuffer, length); rawPacket = dataLinkLayer.getEncodedFrame(); @@ -761,6 +786,15 @@ void StarTrackerHandler::prepareTemperatureRequest() { rawPacketLen = dataLinkLayer.getEncodedLength(); } +void StarTrackerHandler::prepareErrorResetRequest() { + uint32_t length = 0; + struct ResetErrorSignalActionRequest req; + arc_pack_reseterrorsignal_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); +} + ReturnValue_t StarTrackerHandler::prepareParamCommand(const uint8_t* commandData, size_t commandDataLen, ArcsecJsonParamBase& paramSet) { ReturnValue_t result = RETURN_OK; diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.h b/bsp_q7s/devices/startracker/StarTrackerHandler.h index 5c7de4fa..d5bb7136 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.h +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.h @@ -186,7 +186,7 @@ private: /** * @brief Fills the command buffer with the command to take an image. */ - void prepareTakeImageCommand(); + void prepareTakeImageCommand(const uint8_t* commandData); /** * @brief Fills command buffer with data to request the version telemetry packet @@ -226,6 +226,11 @@ private: */ void prepareTemperatureRequest(); + /** + * @brief Fills command buffer with command to reset the error signal of the star tracker + */ + void prepareErrorResetRequest(); + /** * @brief Reads parameters from json file specified by string in commandData and * prepares the command to apply the parameter set to the star tracker diff --git a/bsp_q7s/devices/startracker/StrImageLoader.cpp b/bsp_q7s/devices/startracker/StrImageLoader.cpp index 998d3f1c..1b1c37d2 100644 --- a/bsp_q7s/devices/startracker/StrImageLoader.cpp +++ b/bsp_q7s/devices/startracker/StrImageLoader.cpp @@ -33,6 +33,9 @@ ReturnValue_t StrImageLoader::performOperation(uint8_t operationCode) { if (result == RETURN_OK){ triggerEvent(IMAGE_UPLOAD_SUCCESSFUL); } + else { + triggerEvent(IMAGE_UPLOAD_FAILED); + } internalState = InternalState::IDLE; break; } @@ -41,14 +44,22 @@ ReturnValue_t StrImageLoader::performOperation(uint8_t operationCode) { if (result == RETURN_OK){ triggerEvent(IMAGE_DOWNLOAD_SUCCESSFUL); } + else { + triggerEvent(IMAGE_DOWNLOAD_FAILED); + } internalState = InternalState::IDLE; break; } } } -void StrImageLoader::setComIF(DeviceCommunicationIF* communicationInterface_) { - communicationInterface = communicationInterface_; +ReturnValue_t StrImageLoader::setComIF(DeviceCommunicationIF* communicationInterface_) { + uartComIF = dynamic_cast(communicationInterface_); + if (uartComIF == nullptr) { + sif::warning << "StrImageLoader::initialize: Invalid uart com if" << std::endl; + return RETURN_FAILED; + } + return RETURN_OK; } void StrImageLoader::setComCookie(CookieIF* comCookie_) { @@ -76,40 +87,67 @@ ReturnValue_t StrImageLoader::startImageUpload(std::string image) { } internalState = InternalState::UPLOAD_IMAGE; semaphore.release(); + terminate = false; return RETURN_OK; } void StrImageLoader::startImageDownload(std::string downloadImage_) { downloadImage = downloadImage_; internalState = InternalState::DOWNLOAD_IMAGE; + terminate = false; semaphore.release(); } +void StrImageLoader::stopProcess() { + terminate = true; +} + ReturnValue_t StrImageLoader::performImageDownload() { ReturnValue_t result; struct DownloadActionRequest downloadReq; uint32_t size = 0; + uint32_t retries = 0; std::ofstream file(downloadImage, std::ios_base::app | std::ios_base::out); + downloadReq.position = 0; while(downloadReq.position < LAST_POSITION) { + if (terminate) { + return RETURN_OK; + } arc_pack_download_action_req(&downloadReq, commandBuffer, &size); result = sendAndRead(size, downloadReq.position); if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } file.close(); return result; } result = checkReply(); if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } file.close(); return result; } result = checkReplyPosition(downloadReq.position); if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } file.close(); return result; } file.write(reinterpret_cast(datalinkLayer.getReply() + DATA_OFFSET), IMAGE_DATA_SIZE); downloadReq.position++; + retries = 0; } file.close(); return RETURN_OK; @@ -133,6 +171,9 @@ ReturnValue_t StrImageLoader::performImageUpload() { // tellg returns position of character in input stream imageSize = file.tellg(); while((uploadReq.position + 1) * SIZE_IMAGE_PART < imageSize) { + if (terminate) { + return RETURN_OK; + } file.seekg(uploadReq.position * SIZE_IMAGE_PART, file.beg); file.read(reinterpret_cast(uploadReq.data), SIZE_IMAGE_PART); arc_pack_upload_action_req(&uploadReq, commandBuffer, &size); @@ -172,7 +213,7 @@ ReturnValue_t StrImageLoader::sendAndRead(size_t size, uint32_t position) { size_t bytesLeft = 0; uint32_t missedReplies = 0; datalinkLayer.encodeFrame(commandBuffer, size); - result = communicationInterface->sendMessage(comCookie, datalinkLayer.getEncodedFrame(), + result = uartComIF->sendMessage(comCookie, datalinkLayer.getEncodedFrame(), datalinkLayer.getEncodedLength()); if (result != RETURN_OK) { sif::warning << "StrImageLoader::sendAndRead: Failed to send packet" << std::endl; @@ -181,14 +222,14 @@ ReturnValue_t StrImageLoader::sendAndRead(size_t size, uint32_t position) { } decResult = ArcsecDatalinkLayer::DEC_IN_PROGRESS; while (decResult == ArcsecDatalinkLayer::DEC_IN_PROGRESS) { - result = communicationInterface->requestReceiveMessage(comCookie, + result = uartComIF->requestReceiveMessage(comCookie, StarTracker::MAX_FRAME_SIZE * 2 + 2); if (result != RETURN_OK) { sif::warning << "StrImageLoader::sendAndRead: Failed to request reply" << std::endl; triggerEvent(IMG_LOADER_REQUESTING_MSG_FAILED, result, position); return RETURN_FAILED; } - result = communicationInterface->readReceivedMessage(comCookie, &receivedData, &receivedDataLen); + result = uartComIF->readReceivedMessage(comCookie, &receivedData, &receivedDataLen); if (result != RETURN_OK) { sif::warning << "StrImageLoader::sendAndRead: Failed to read received message" << std::endl; triggerEvent(IMG_LOADER_READING_REPLY_FAILED, result, position); diff --git a/bsp_q7s/devices/startracker/StrImageLoader.h b/bsp_q7s/devices/startracker/StrImageLoader.h index 2f486658..48a47df8 100644 --- a/bsp_q7s/devices/startracker/StrImageLoader.h +++ b/bsp_q7s/devices/startracker/StrImageLoader.h @@ -8,7 +8,7 @@ #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/objectmanager/SystemObject.h" #include "fsfw/tasks/ExecutableObjectIF.h" -#include "fsfw/devicehandlers/DeviceCommunicationIF.h" +#include "fsfw_hal/linux/uart/UartComIF.h" #include "fsfw/devicehandlers/CookieIF.h" extern "C" { @@ -27,18 +27,14 @@ public: static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_IMAGE_LOADER; - //! [EXPORT] : [COMMENT] Try to upload image but specified image does not exist - static const Event IMAGE_FILE_NOT_EXISTS = MAKE_EVENT(0, severity::LOW); - //! [EXPORT] : [COMMENT] Sending packet (download or upload) to star tracker failed - //!P1: Return code of communication interface sendMessage function - //!P2: Position of upload/download packet for which the transmission failed - static const Event IMG_LOADER_SENDING_PACKET_FAILED = MAKE_EVENT(1, severity::LOW); - //! [EXPORT] : [COMMENT] Communication interface requesting reply failed - //!P1: Return code of failed request - //!P1: Upload/download position for which the request failed - static const Event IMG_LOADER_REQUESTING_MSG_FAILED = MAKE_EVENT(2, severity::LOW); + //! [EXPORT] : [COMMENT] Image upload failed + static const Event IMAGE_UPLOAD_FAILED = MAKE_EVENT(0, severity::LOW); + //! [EXPORT] : [COMMENT] Image download failed + static const Event IMAGE_DOWNLOAD_FAILED = MAKE_EVENT(1, severity::LOW); //! [EXPORT] : [COMMENT] Uploading image to star tracker was successful - static const Event IMAGE_UPLOAD_SUCCESSFUL = MAKE_EVENT(3, severity::LOW); + static const Event IMAGE_UPLOAD_SUCCESSFUL = MAKE_EVENT(2, severity::LOW); + //! [EXPORT] : [COMMENT] Image download was successful + static const Event IMAGE_DOWNLOAD_SUCCESSFUL = MAKE_EVENT(3, severity::LOW); //! [EXPORT] : [COMMENT] Failed to read communication interface reply data //!P1: Return code of failed communication interface read call //!P1: Upload/download position for which the read call failed @@ -58,11 +54,20 @@ public: //P1: Return value of decoding function //P2: Position of upload/download packet for which reply decoding failed static const Event IMG_LOADER_DEC_ERROR = MAKE_EVENT(9, severity::LOW); - //! [EXPORT] : [COMMENT] Image download was successful - static const Event IMAGE_DOWNLOAD_SUCCESSFUL = MAKE_EVENT(10, severity::LOW); //! [EXPORT] : [COMMENT] Position mismatch //! P1: The expected position and thus the position for which the image upload/download failed - static const Event POSITION_MISMATCH = MAKE_EVENT(11, severity::LOW); + static const Event POSITION_MISMATCH = MAKE_EVENT(10, severity::LOW); + //! [EXPORT] : [COMMENT] Try to upload image but specified image does not exist + static const Event IMAGE_FILE_NOT_EXISTS = MAKE_EVENT(11, severity::LOW); + //! [EXPORT] : [COMMENT] Sending packet (download or upload) to star tracker failed + //!P1: Return code of communication interface sendMessage function + //!P2: Position of upload/download packet for which the transmission failed + static const Event IMG_LOADER_SENDING_PACKET_FAILED = MAKE_EVENT(12, severity::LOW); + //! [EXPORT] : [COMMENT] Communication interface requesting reply failed + //!P1: Return code of failed request + //!P1: Upload/download position for which the request failed + static const Event IMG_LOADER_REQUESTING_MSG_FAILED = MAKE_EVENT(13, severity::LOW); + StrImageLoader(object_id_t objectId); @@ -71,7 +76,7 @@ public: ReturnValue_t initialize() override; ReturnValue_t performOperation(uint8_t operationCode = 0) override; - void setComIF(DeviceCommunicationIF* communicationInterface_); + ReturnValue_t setComIF(DeviceCommunicationIF* communicationInterface_); void setComCookie(CookieIF* comCookie_); /** @@ -87,6 +92,11 @@ public: */ void startImageDownload(std::string downloadImage_); + /** + * @brief Can be used to interrupt a running upload or download process. + */ + void stopProcess(); + private: static const uint8_t INTERFACE_ID = CLASS_ID::STR_IMG_LOADER; @@ -106,6 +116,7 @@ private: static const uint8_t POS_OFFSET = 2; static const uint8_t DATA_OFFSET = 5; static const size_t IMAGE_DATA_SIZE = 1024; + static const size_t CONFIG_MAX_DOWNLOAD_RETRIES = 3; enum class InternalState { IDLE, @@ -128,11 +139,13 @@ private: uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE]; + bool terminate = false; + /** - * Communication object responsible for low level access of star tracker + * UART communication object responsible for low level access of star tracker * Must be set by star tracker handler */ - DeviceCommunicationIF * communicationInterface = nullptr; + UartComIF* uartComIF = nullptr; // Communication cookie. Must be set by the star tracker handler CookieIF* comCookie = nullptr; diff --git a/generators/bsp_q7s_events.csv b/generators/bsp_q7s_events.csv index 0153c3e6..30956754 100644 --- a/generators/bsp_q7s_events.csv +++ b/generators/bsp_q7s_events.csv @@ -118,15 +118,17 @@ 11902;INVALID_FAR;HIGH;Read invalid FAR from PDEC after startup;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/obc/PdecHandler.h 11903;CARRIER_LOCK;INFO;Carrier lock detected;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/obc/PdecHandler.h 11904;BIT_LOCK_PDEC;INFO;Bit lock detected (data valid);C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/obc/PdecHandler.h -12000;IMAGE_FILE_NOT_EXISTS;LOW;Try to upload image but specified image does not exist;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h -12001;IMG_LOADER_SENDING_PACKET_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h -12002;IMG_LOADER_REQUESTING_MSG_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h -12003;IMAGE_UPLOAD_SUCCESSFUL;LOW;Uploading image to star tracker was successful;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h +12000;IMAGE_UPLOAD_FAILED;LOW;Image upload failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h +12001;IMAGE_DOWNLOAD_FAILED;LOW;Image download failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h +12002;IMAGE_UPLOAD_SUCCESSFUL;LOW;Uploading image to star tracker was successful;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h +12003;IMAGE_DOWNLOAD_SUCCESSFUL;LOW;Image download was successful;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h 12004;IMG_LOADER_READING_REPLY_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h 12005;IMG_LOADER_COM_ERROR;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h 12006;IMG_LOADER_NO_REPLY;LOW;Star tracker did not send replies (maybe device is powered off)P1: Position of upload or download packet for which no reply was sent;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h 12007;INVALID_TYPE_ID;LOW;Received reply with invalid type ID;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h 12008;STATUS_ERROR;LOW;Status field in reply signals error;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h 12009;IMG_LOADER_DEC_ERROR;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h -12010;IMAGE_DOWNLOAD_SUCCESSFUL;LOW;Image download was successful;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h -12011;POSITION_MISMATCH;LOW;Position mismatch P1: The expected position and thus the position for which the image upload/download failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h +12010;POSITION_MISMATCH;LOW;Position mismatch P1: The expected position and thus the position for which the image upload/download failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h +12011;IMAGE_FILE_NOT_EXISTS;LOW;Try to upload image but specified image does not exist;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h +12012;IMG_LOADER_SENDING_PACKET_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h +12013;IMG_LOADER_REQUESTING_MSG_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp index 35f4ad9b..e44c407d 100644 --- a/generators/events/translateEvents.cpp +++ b/generators/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 132 translations. + * @brief Auto-generated event translation file. Contains 134 translations. * @details - * Generated on: 2021-12-09 11:10:38 + * Generated on: 2021-12-09 16:40:42 */ #include "translateEvents.h" @@ -125,18 +125,20 @@ const char *INVALID_TC_FRAME_STRING = "INVALID_TC_FRAME"; const char *INVALID_FAR_STRING = "INVALID_FAR"; const char *CARRIER_LOCK_STRING = "CARRIER_LOCK"; const char *BIT_LOCK_PDEC_STRING = "BIT_LOCK_PDEC"; -const char *IMAGE_FILE_NOT_EXISTS_STRING = "IMAGE_FILE_NOT_EXISTS"; -const char *IMG_LOADER_SENDING_PACKET_FAILED_STRING = "IMG_LOADER_SENDING_PACKET_FAILED"; -const char *IMG_LOADER_REQUESTING_MSG_FAILED_STRING = "IMG_LOADER_REQUESTING_MSG_FAILED"; +const char *IMAGE_UPLOAD_FAILED_STRING = "IMAGE_UPLOAD_FAILED"; +const char *IMAGE_DOWNLOAD_FAILED_STRING = "IMAGE_DOWNLOAD_FAILED"; const char *IMAGE_UPLOAD_SUCCESSFUL_STRING = "IMAGE_UPLOAD_SUCCESSFUL"; +const char *IMAGE_DOWNLOAD_SUCCESSFUL_STRING = "IMAGE_DOWNLOAD_SUCCESSFUL"; const char *IMG_LOADER_READING_REPLY_FAILED_STRING = "IMG_LOADER_READING_REPLY_FAILED"; const char *IMG_LOADER_COM_ERROR_STRING = "IMG_LOADER_COM_ERROR"; const char *IMG_LOADER_NO_REPLY_STRING = "IMG_LOADER_NO_REPLY"; const char *INVALID_TYPE_ID_STRING = "INVALID_TYPE_ID"; const char *STATUS_ERROR_STRING = "STATUS_ERROR"; const char *IMG_LOADER_DEC_ERROR_STRING = "IMG_LOADER_DEC_ERROR"; -const char *IMAGE_DOWNLOAD_SUCCESSFUL_STRING = "IMAGE_DOWNLOAD_SUCCESSFUL"; const char *POSITION_MISMATCH_STRING = "POSITION_MISMATCH"; +const char *IMAGE_FILE_NOT_EXISTS_STRING = "IMAGE_FILE_NOT_EXISTS"; +const char *IMG_LOADER_SENDING_PACKET_FAILED_STRING = "IMG_LOADER_SENDING_PACKET_FAILED"; +const char *IMG_LOADER_REQUESTING_MSG_FAILED_STRING = "IMG_LOADER_REQUESTING_MSG_FAILED"; const char * translateEvents(Event event) { switch( (event & 0xffff) ) { @@ -381,13 +383,13 @@ const char * translateEvents(Event event) { case(11904): return BIT_LOCK_PDEC_STRING; case(12000): - return IMAGE_FILE_NOT_EXISTS_STRING; + return IMAGE_UPLOAD_FAILED_STRING; case(12001): - return IMG_LOADER_SENDING_PACKET_FAILED_STRING; + return IMAGE_DOWNLOAD_FAILED_STRING; case(12002): - return IMG_LOADER_REQUESTING_MSG_FAILED_STRING; - case(12003): return IMAGE_UPLOAD_SUCCESSFUL_STRING; + case(12003): + return IMAGE_DOWNLOAD_SUCCESSFUL_STRING; case(12004): return IMG_LOADER_READING_REPLY_FAILED_STRING; case(12005): @@ -401,9 +403,13 @@ const char * translateEvents(Event event) { case(12009): return IMG_LOADER_DEC_ERROR_STRING; case(12010): - return IMAGE_DOWNLOAD_SUCCESSFUL_STRING; - case(12011): return POSITION_MISMATCH_STRING; + case(12011): + return IMAGE_FILE_NOT_EXISTS_STRING; + case(12012): + return IMG_LOADER_SENDING_PACKET_FAILED_STRING; + case(12013): + return IMG_LOADER_REQUESTING_MSG_FAILED_STRING; default: return "UNKNOWN_EVENT"; } diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index 35f4ad9b..e44c407d 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 132 translations. + * @brief Auto-generated event translation file. Contains 134 translations. * @details - * Generated on: 2021-12-09 11:10:38 + * Generated on: 2021-12-09 16:40:42 */ #include "translateEvents.h" @@ -125,18 +125,20 @@ const char *INVALID_TC_FRAME_STRING = "INVALID_TC_FRAME"; const char *INVALID_FAR_STRING = "INVALID_FAR"; const char *CARRIER_LOCK_STRING = "CARRIER_LOCK"; const char *BIT_LOCK_PDEC_STRING = "BIT_LOCK_PDEC"; -const char *IMAGE_FILE_NOT_EXISTS_STRING = "IMAGE_FILE_NOT_EXISTS"; -const char *IMG_LOADER_SENDING_PACKET_FAILED_STRING = "IMG_LOADER_SENDING_PACKET_FAILED"; -const char *IMG_LOADER_REQUESTING_MSG_FAILED_STRING = "IMG_LOADER_REQUESTING_MSG_FAILED"; +const char *IMAGE_UPLOAD_FAILED_STRING = "IMAGE_UPLOAD_FAILED"; +const char *IMAGE_DOWNLOAD_FAILED_STRING = "IMAGE_DOWNLOAD_FAILED"; const char *IMAGE_UPLOAD_SUCCESSFUL_STRING = "IMAGE_UPLOAD_SUCCESSFUL"; +const char *IMAGE_DOWNLOAD_SUCCESSFUL_STRING = "IMAGE_DOWNLOAD_SUCCESSFUL"; const char *IMG_LOADER_READING_REPLY_FAILED_STRING = "IMG_LOADER_READING_REPLY_FAILED"; const char *IMG_LOADER_COM_ERROR_STRING = "IMG_LOADER_COM_ERROR"; const char *IMG_LOADER_NO_REPLY_STRING = "IMG_LOADER_NO_REPLY"; const char *INVALID_TYPE_ID_STRING = "INVALID_TYPE_ID"; const char *STATUS_ERROR_STRING = "STATUS_ERROR"; const char *IMG_LOADER_DEC_ERROR_STRING = "IMG_LOADER_DEC_ERROR"; -const char *IMAGE_DOWNLOAD_SUCCESSFUL_STRING = "IMAGE_DOWNLOAD_SUCCESSFUL"; const char *POSITION_MISMATCH_STRING = "POSITION_MISMATCH"; +const char *IMAGE_FILE_NOT_EXISTS_STRING = "IMAGE_FILE_NOT_EXISTS"; +const char *IMG_LOADER_SENDING_PACKET_FAILED_STRING = "IMG_LOADER_SENDING_PACKET_FAILED"; +const char *IMG_LOADER_REQUESTING_MSG_FAILED_STRING = "IMG_LOADER_REQUESTING_MSG_FAILED"; const char * translateEvents(Event event) { switch( (event & 0xffff) ) { @@ -381,13 +383,13 @@ const char * translateEvents(Event event) { case(11904): return BIT_LOCK_PDEC_STRING; case(12000): - return IMAGE_FILE_NOT_EXISTS_STRING; + return IMAGE_UPLOAD_FAILED_STRING; case(12001): - return IMG_LOADER_SENDING_PACKET_FAILED_STRING; + return IMAGE_DOWNLOAD_FAILED_STRING; case(12002): - return IMG_LOADER_REQUESTING_MSG_FAILED_STRING; - case(12003): return IMAGE_UPLOAD_SUCCESSFUL_STRING; + case(12003): + return IMAGE_DOWNLOAD_SUCCESSFUL_STRING; case(12004): return IMG_LOADER_READING_REPLY_FAILED_STRING; case(12005): @@ -401,9 +403,13 @@ const char * translateEvents(Event event) { case(12009): return IMG_LOADER_DEC_ERROR_STRING; case(12010): - return IMAGE_DOWNLOAD_SUCCESSFUL_STRING; - case(12011): return POSITION_MISMATCH_STRING; + case(12011): + return IMAGE_FILE_NOT_EXISTS_STRING; + case(12012): + return IMG_LOADER_SENDING_PACKET_FAILED_STRING; + case(12013): + return IMG_LOADER_REQUESTING_MSG_FAILED_STRING; default: return "UNKNOWN_EVENT"; } diff --git a/thirdparty/arcsec_star_tracker b/thirdparty/arcsec_star_tracker index 2d10c6b8..cdd25c4f 160000 --- a/thirdparty/arcsec_star_tracker +++ b/thirdparty/arcsec_star_tracker @@ -1 +1 @@ -Subproject commit 2d10c6b85ea4cab4f4baf1918c51d54eee4202c2 +Subproject commit cdd25c4fc7b963cebb58ade213a8546c2d435242 From af32941352b6d9144b8e393e96353fdc86810831 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 10 Dec 2021 17:46:52 +0100 Subject: [PATCH 128/465] ADIS device handler can now handle multiple types - Added handling for ADIS16507 and ADIS16505 type --- bsp_q7s/core/ObjectFactory.cpp | 14 +- linux/fsfwconfig/FSFWConfig.h.in | 2 +- .../pollingSequenceFactory.cpp | 2 +- mission/devices/CMakeLists.txt | 2 +- ...07Handler.cpp => GyroADIS1650XHandler.cpp} | 202 ++++++++++-------- ...S16507Handler.h => GyroADIS1650XHandler.h} | 12 +- ...finitions.h => GyroADIS1650XDefinitions.h} | 47 ++-- 7 files changed, 150 insertions(+), 131 deletions(-) rename mission/devices/{GyroADIS16507Handler.cpp => GyroADIS1650XHandler.cpp} (69%) rename mission/devices/{GyroADIS16507Handler.h => GyroADIS1650XHandler.h} (89%) rename mission/devices/devicedefinitions/{GyroADIS16507Definitions.h => GyroADIS1650XDefinitions.h} (80%) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index bc428f05..e3deba9d 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -36,7 +36,7 @@ #include "mission/devices/P60DockHandler.h" #include "mission/devices/Tmp1075Handler.h" #include "mission/devices/Max31865PT1000Handler.h" -#include "mission/devices/GyroADIS16507Handler.h" +#include "mission/devices/GyroADIS1650XHandler.h" #include "mission/devices/IMTQHandler.h" #include "mission/devices/SyrlinksHkHandler.h" #include "mission/devices/PlocMPSoCHandler.h" @@ -511,10 +511,10 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI // Commented until ACS board V2 in in clean room again // Gyro 0 Side A spiCookie = new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, spiDev, - ADIS16507::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, + ADIS1650X::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, spi::DEFAULT_ADIS16507_SPEED); - auto adisHandler = new GyroADIS16507Handler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, - spiCookie); + auto adisHandler = new GyroADIS1650XHandler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, + spiCookie, ADIS1650X::Type::ADIS16505); adisHandler->setStartUpImmediately(); // Gyro 1 Side A spiCookie = new SpiCookie(addresses::GYRO_1_L3G, gpioIds::GYRO_1_L3G_CS, spiDev, @@ -527,10 +527,10 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI #endif // Gyro 2 Side B spiCookie = new SpiCookie(addresses::GYRO_2_ADIS, gpioIds::GYRO_2_ADIS_CS, spiDev, - ADIS16507::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, + ADIS1650X::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, spi::DEFAULT_ADIS16507_SPEED); - adisHandler = new GyroADIS16507Handler(objects::GYRO_2_ADIS_HANDLER, objects::SPI_COM_IF, - spiCookie); + adisHandler = new GyroADIS1650XHandler(objects::GYRO_2_ADIS_HANDLER, objects::SPI_COM_IF, + spiCookie, ADIS1650X::Type::ADIS16505); adisHandler->setStartUpImmediately(); // Gyro 3 Side B spiCookie = new SpiCookie(addresses::GYRO_3_L3G, gpioIds::GYRO_3_L3G_CS, spiDev, diff --git a/linux/fsfwconfig/FSFWConfig.h.in b/linux/fsfwconfig/FSFWConfig.h.in index 3b87078c..9e8f2016 100644 --- a/linux/fsfwconfig/FSFWConfig.h.in +++ b/linux/fsfwconfig/FSFWConfig.h.in @@ -78,6 +78,6 @@ static constexpr size_t FSFW_MAX_TM_PACKET_SIZE = 2048; #define FSFW_HAL_L3GD20_GYRO_DEBUG 0 #define FSFW_HAL_RM3100_MGM_DEBUG 0 #define FSFW_HAL_LIS3MDL_MGM_DEBUG 0 -#define FSFW_HAL_ADIS16507_GYRO_DEBUG 0 +#define FSFW_HAL_ADIS1650X_GYRO_DEBUG 0 #endif /* CONFIG_FSFWCONFIG_H_ */ diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 02f37438..73a27116 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -439,7 +439,7 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { #endif #if OBSW_ADD_ACS_BOARD == 1 - bool enableAside = true; + bool enableAside = false; bool enableBside = true; if(enableAside) { // A side diff --git a/mission/devices/CMakeLists.txt b/mission/devices/CMakeLists.txt index ea3fdbea..cbfbe4a5 100644 --- a/mission/devices/CMakeLists.txt +++ b/mission/devices/CMakeLists.txt @@ -12,7 +12,7 @@ target_sources(${TARGET_NAME} PUBLIC IMTQHandler.cpp PlocMPSoCHandler.cpp RadiationSensorHandler.cpp - GyroADIS16507Handler.cpp + GyroADIS1650XHandler.cpp RwHandler.cpp ) diff --git a/mission/devices/GyroADIS16507Handler.cpp b/mission/devices/GyroADIS1650XHandler.cpp similarity index 69% rename from mission/devices/GyroADIS16507Handler.cpp rename to mission/devices/GyroADIS1650XHandler.cpp index 07e0d643..4acf9196 100644 --- a/mission/devices/GyroADIS16507Handler.cpp +++ b/mission/devices/GyroADIS1650XHandler.cpp @@ -1,8 +1,8 @@ -#include "GyroADIS16507Handler.h" +#include "GyroADIS1650XHandler.h" #include #include -#if OBSW_ADIS16507_LINUX_COM_IF == 1 +#if OBSW_ADIS1650X_LINUX_COM_IF == 1 #include "fsfw_hal/linux/utility.h" #include "fsfw_hal/linux/spi/SpiCookie.h" #include "fsfw_hal/linux/spi/SpiComIF.h" @@ -11,15 +11,15 @@ #include #endif -GyroADIS16507Handler::GyroADIS16507Handler(object_id_t objectId, - object_id_t deviceCommunication, CookieIF * comCookie): - DeviceHandlerBase(objectId, deviceCommunication, comCookie), primaryDataset(this), - configDataset(this), breakCountdown() { -#if FSFW_HAL_ADIS16507_GYRO_DEBUG == 1 +GyroADIS1650XHandler::GyroADIS1650XHandler(object_id_t objectId, + object_id_t deviceCommunication, CookieIF * comCookie, ADIS1650X::Type type): + DeviceHandlerBase(objectId, deviceCommunication, comCookie), adisType(type), + primaryDataset(this), configDataset(this), breakCountdown() { +#if FSFW_HAL_ADIS1650X_GYRO_DEBUG == 1 debugDivider = new PeriodicOperationDivider(5); #endif -#if OBSW_ADIS16507_LINUX_COM_IF == 1 +#if OBSW_ADIS1650X_LINUX_COM_IF == 1 SpiCookie* cookie = dynamic_cast(comCookie); if(cookie != nullptr) { cookie->setCallbackMode(&spiSendCallback, this); @@ -27,11 +27,11 @@ GyroADIS16507Handler::GyroADIS16507Handler(object_id_t objectId, #endif } -void GyroADIS16507Handler::doStartUp() { +void GyroADIS1650XHandler::doStartUp() { // Initial 310 ms start up time after power-up if(internalState == InternalState::STARTUP) { if(not commandExecuted) { - breakCountdown.setTimeout(ADIS16507::START_UP_TIME); + breakCountdown.setTimeout(ADIS1650X::START_UP_TIME); commandExecuted = true; } if(breakCountdown.hasTimedOut()) { @@ -54,20 +54,20 @@ void GyroADIS16507Handler::doStartUp() { } } -void GyroADIS16507Handler::doShutDown() { +void GyroADIS1650XHandler::doShutDown() { commandExecuted = false; setMode(_MODE_POWER_DOWN); } -ReturnValue_t GyroADIS16507Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { - *id = ADIS16507::READ_SENSOR_DATA; +ReturnValue_t GyroADIS1650XHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + *id = ADIS1650X::READ_SENSOR_DATA; return buildCommandFromCommand(*id, nullptr, 0); } -ReturnValue_t GyroADIS16507Handler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { +ReturnValue_t GyroADIS1650XHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { switch(internalState) { case(InternalState::CONFIG): { - *id = ADIS16507::READ_OUT_CONFIG; + *id = ADIS1650X::READ_OUT_CONFIG; buildCommandFromCommand(*id, nullptr, 0); break; } @@ -85,79 +85,79 @@ ReturnValue_t GyroADIS16507Handler::buildTransitionDeviceCommand(DeviceCommandId return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t GyroADIS16507Handler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, +ReturnValue_t GyroADIS1650XHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, size_t commandDataLen) { switch(deviceCommand) { - case(ADIS16507::READ_OUT_CONFIG): { - this->rawPacketLen = ADIS16507::CONFIG_READOUT_SIZE; + case(ADIS1650X::READ_OUT_CONFIG): { + this->rawPacketLen = ADIS1650X::CONFIG_READOUT_SIZE; uint8_t regList[5]; - regList[0] = ADIS16507::DIAG_STAT_REG; - regList[1] = ADIS16507::FILTER_CTRL_REG; - regList[2] = ADIS16507::MSC_CTRL_REG; - regList[3] = ADIS16507::DEC_RATE_REG; - regList[4] = ADIS16507::PROD_ID_REG; + regList[0] = ADIS1650X::DIAG_STAT_REG; + regList[1] = ADIS1650X::FILTER_CTRL_REG; + regList[2] = ADIS1650X::MSC_CTRL_REG; + regList[3] = ADIS1650X::DEC_RATE_REG; + regList[4] = ADIS1650X::PROD_ID_REG; prepareReadCommand(regList, sizeof(regList)); this->rawPacket = commandBuffer.data(); break; } - case(ADIS16507::READ_SENSOR_DATA): { + case(ADIS1650X::READ_SENSOR_DATA): { if(breakCountdown.isBusy()) { // A glob command is pending and sensor data can't be read currently return NO_REPLY_EXPECTED; } - std::memcpy(commandBuffer.data(), ADIS16507::BURST_READ_ENABLE.data(), - ADIS16507::BURST_READ_ENABLE.size()); + std::memcpy(commandBuffer.data(), ADIS1650X::BURST_READ_ENABLE.data(), + ADIS1650X::BURST_READ_ENABLE.size()); std::memset(commandBuffer.data() + 2, 0, 10 * 2); - this->rawPacketLen = ADIS16507::SENSOR_READOUT_SIZE; + this->rawPacketLen = ADIS1650X::SENSOR_READOUT_SIZE; this->rawPacket = commandBuffer.data(); break; } - case(ADIS16507::SELF_TEST_SENSORS): { + case(ADIS1650X::SELF_TEST_SENSORS): { if(breakCountdown.isBusy()) { // Another glob command is pending return HasActionsIF::IS_BUSY; } - prepareWriteCommand(ADIS16507::GLOB_CMD, ADIS16507::GlobCmds::SENSOR_SELF_TEST, 0x00); - breakCountdown.setTimeout(ADIS16507::SELF_TEST_BREAK); + prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::SENSOR_SELF_TEST, 0x00); + breakCountdown.setTimeout(ADIS1650X::SELF_TEST_BREAK); break; } - case(ADIS16507::SELF_TEST_MEMORY): { + case(ADIS1650X::SELF_TEST_MEMORY): { if(breakCountdown.isBusy()) { // Another glob command is pending return HasActionsIF::IS_BUSY; } - prepareWriteCommand(ADIS16507::GLOB_CMD, ADIS16507::GlobCmds::FLASH_MEMORY_TEST, 0x00); - breakCountdown.setTimeout(ADIS16507::FLASH_MEMORY_TEST_BREAK); + prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FLASH_MEMORY_TEST, 0x00); + breakCountdown.setTimeout(ADIS1650X::FLASH_MEMORY_TEST_BREAK); break; } - case(ADIS16507::UPDATE_NV_CONFIGURATION): { + case(ADIS1650X::UPDATE_NV_CONFIGURATION): { if(breakCountdown.isBusy()) { // Another glob command is pending return HasActionsIF::IS_BUSY; } - prepareWriteCommand(ADIS16507::GLOB_CMD, ADIS16507::GlobCmds::FLASH_MEMORY_UPDATE, 0x00); - breakCountdown.setTimeout(ADIS16507::FLASH_MEMORY_UPDATE_BREAK); + prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FLASH_MEMORY_UPDATE, 0x00); + breakCountdown.setTimeout(ADIS1650X::FLASH_MEMORY_UPDATE_BREAK); break; } - case(ADIS16507::RESET_SENSOR_CONFIGURATION): { + case(ADIS1650X::RESET_SENSOR_CONFIGURATION): { if(breakCountdown.isBusy()) { // Another glob command is pending return HasActionsIF::IS_BUSY; } - prepareWriteCommand(ADIS16507::GLOB_CMD, ADIS16507::GlobCmds::FACTORY_CALIBRATION, 0x00); - breakCountdown.setTimeout(ADIS16507::FACTORY_CALIBRATION_BREAK); + prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FACTORY_CALIBRATION, 0x00); + breakCountdown.setTimeout(ADIS1650X::FACTORY_CALIBRATION_BREAK); break; } - case(ADIS16507::SW_RESET): { + case(ADIS1650X::SW_RESET): { if(breakCountdown.isBusy()) { // Another glob command is pending return HasActionsIF::IS_BUSY; } - prepareWriteCommand(ADIS16507::GLOB_CMD, ADIS16507::GlobCmds::SOFTWARE_RESET, 0x00); - breakCountdown.setTimeout(ADIS16507::SW_RESET_BREAK); + prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::SOFTWARE_RESET, 0x00); + breakCountdown.setTimeout(ADIS1650X::SW_RESET_BREAK); break; } - case(ADIS16507::PRINT_CURRENT_CONFIGURATION): { + case(ADIS1650X::PRINT_CURRENT_CONFIGURATION): { #if OBSW_VERBOSE_LEVEL >= 1 PoolReadGuard pg(&configDataset); sif::info << "ADIS16507 Sensor configuration: DIAG_STAT: 0x" << std::hex << std::setw(4) << @@ -172,18 +172,18 @@ ReturnValue_t GyroADIS16507Handler::buildCommandFromCommand(DeviceCommandId_t de return HasReturnvaluesIF::RETURN_OK; } -void GyroADIS16507Handler::fillCommandAndReplyMap() { - insertInCommandAndReplyMap(ADIS16507::READ_SENSOR_DATA, 1, &primaryDataset); - insertInCommandAndReplyMap(ADIS16507::READ_OUT_CONFIG, 1, &configDataset); - insertInCommandAndReplyMap(ADIS16507::SELF_TEST_SENSORS, 1); - insertInCommandAndReplyMap(ADIS16507::SELF_TEST_MEMORY, 1); - insertInCommandAndReplyMap(ADIS16507::UPDATE_NV_CONFIGURATION, 1); - insertInCommandAndReplyMap(ADIS16507::RESET_SENSOR_CONFIGURATION, 1); - insertInCommandAndReplyMap(ADIS16507::SW_RESET, 1); - insertInCommandAndReplyMap(ADIS16507::PRINT_CURRENT_CONFIGURATION, 1); +void GyroADIS1650XHandler::fillCommandAndReplyMap() { + insertInCommandAndReplyMap(ADIS1650X::READ_SENSOR_DATA, 1, &primaryDataset); + insertInCommandAndReplyMap(ADIS1650X::READ_OUT_CONFIG, 1, &configDataset); + insertInCommandAndReplyMap(ADIS1650X::SELF_TEST_SENSORS, 1); + insertInCommandAndReplyMap(ADIS1650X::SELF_TEST_MEMORY, 1); + insertInCommandAndReplyMap(ADIS1650X::UPDATE_NV_CONFIGURATION, 1); + insertInCommandAndReplyMap(ADIS1650X::RESET_SENSOR_CONFIGURATION, 1); + insertInCommandAndReplyMap(ADIS1650X::SW_RESET, 1); + insertInCommandAndReplyMap(ADIS1650X::PRINT_CURRENT_CONFIGURATION, 1); } -ReturnValue_t GyroADIS16507Handler::scanForReply(const uint8_t *start, size_t remainingSize, +ReturnValue_t GyroADIS1650XHandler::scanForReply(const uint8_t *start, size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { /* For SPI, the ID will always be the one of the last sent command. */ *foundId = this->getPendingCommand(); @@ -192,16 +192,19 @@ ReturnValue_t GyroADIS16507Handler::scanForReply(const uint8_t *start, size_t re return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t GyroADIS16507Handler::interpretDeviceReply(DeviceCommandId_t id, +ReturnValue_t GyroADIS1650XHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { switch(id) { - case(ADIS16507::READ_OUT_CONFIG): { + case(ADIS1650X::READ_OUT_CONFIG): { PoolReadGuard rg(&configDataset); uint16_t readProdId = packet[10] << 8 | packet[11]; - if (readProdId != ADIS16507::PROD_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 - sif::warning << "GyroADIS16507Handler::interpretDeviceReply: Invalid product ID!" - << std::endl; + sif::warning << "GyroADIS16507Handler::interpretDeviceReply: Invalid product ID " + << readProdId << std::endl; #endif return HasReturnvaluesIF::RETURN_FAILED; } @@ -215,7 +218,7 @@ ReturnValue_t GyroADIS16507Handler::interpretDeviceReply(DeviceCommandId_t id, } break; } - case(ADIS16507::READ_SENSOR_DATA): { + case(ADIS1650X::READ_SENSOR_DATA): { return handleSensorData(packet); } @@ -224,7 +227,7 @@ ReturnValue_t GyroADIS16507Handler::interpretDeviceReply(DeviceCommandId_t id, } -ReturnValue_t GyroADIS16507Handler::handleSensorData(const uint8_t *packet) { +ReturnValue_t GyroADIS1650XHandler::handleSensorData(const uint8_t *packet) { BurstModes burstMode = getBurstMode(); switch(burstMode) { case(BurstModes::BURST_16_BURST_SEL_1): @@ -260,23 +263,32 @@ ReturnValue_t GyroADIS16507Handler::handleSensorData(const uint8_t *packet) { PoolReadGuard pg(&primaryDataset); int16_t angVelocXRaw = packet[4] << 8 | packet[5]; primaryDataset.angVelocX.value = static_cast(angVelocXRaw) / INT16_MAX * - ADIS16507::GYRO_RANGE; + ADIS1650X::GYRO_RANGE; int16_t angVelocYRaw = packet[6] << 8 | packet[7]; primaryDataset.angVelocY.value = static_cast(angVelocYRaw) / INT16_MAX * - ADIS16507::GYRO_RANGE; + ADIS1650X::GYRO_RANGE; int16_t angVelocZRaw = packet[8] << 8 | packet[9]; primaryDataset.angVelocZ.value = static_cast(angVelocZRaw) / INT16_MAX * - ADIS16507::GYRO_RANGE; + ADIS1650X::GYRO_RANGE; + float accelScaling = 0; + if(adisType == ADIS1650X::Type::ADIS16507) { + accelScaling = ADIS1650X::ACCELEROMETER_RANGE_16507; + } else if(adisType == ADIS1650X::Type::ADIS16505) { + accelScaling = ADIS1650X::ACCELEROMETER_RANGE_16505; + } else { + sif::warning << "GyroADIS16507Handler::handleSensorData: " + "Unknown ADIS type" << std::endl; + } int16_t accelXRaw = packet[10] << 8 | packet[11]; primaryDataset.accelX.value = static_cast(accelXRaw) / INT16_MAX * - ADIS16507::ACCELEROMETER_RANGE; + accelScaling; int16_t accelYRaw = packet[12] << 8 | packet[13]; primaryDataset.accelY.value = static_cast(accelYRaw) / INT16_MAX * - ADIS16507::ACCELEROMETER_RANGE; + accelScaling; int16_t accelZRaw = packet[14] << 8 | packet[15]; primaryDataset.accelZ.value = static_cast(accelZRaw) / INT16_MAX * - ADIS16507::ACCELEROMETER_RANGE; + accelScaling; int16_t temperatureRaw = packet[16] << 8 | packet[17]; primaryDataset.temperature.value = static_cast(temperatureRaw) * 0.1; @@ -284,7 +296,7 @@ ReturnValue_t GyroADIS16507Handler::handleSensorData(const uint8_t *packet) { primaryDataset.setValidity(true, true); } -#if FSFW_HAL_ADIS16507_GYRO_DEBUG == 1 +#if FSFW_HAL_ADIS1650X_GYRO_DEBUG == 1 if(debugDivider->checkAndIncrement()) { sif::info << "GyroADIS16507Handler: Angular velocities in deg / s" << std::endl; sif::info << "X: " << primaryDataset.angVelocX.value << std::endl; @@ -306,15 +318,15 @@ ReturnValue_t GyroADIS16507Handler::handleSensorData(const uint8_t *packet) { return HasReturnvaluesIF::RETURN_OK; } -uint32_t GyroADIS16507Handler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { +uint32_t GyroADIS1650XHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 5000; } -void GyroADIS16507Handler::prepareWriteCommand(uint8_t startReg, uint8_t valueOne, +void GyroADIS1650XHandler::prepareWriteCommand(uint8_t startReg, uint8_t valueOne, uint8_t valueTwo) { uint8_t secondReg = startReg + 1; - startReg |= ADIS16507::WRITE_MASK; - secondReg |= ADIS16507::WRITE_MASK; + startReg |= ADIS1650X::WRITE_MASK; + secondReg |= ADIS1650X::WRITE_MASK; commandBuffer[0] = startReg; commandBuffer[1] = valueOne; commandBuffer[2] = secondReg; @@ -323,7 +335,7 @@ void GyroADIS16507Handler::prepareWriteCommand(uint8_t startReg, uint8_t valueOn this->rawPacket = commandBuffer.data(); } -void GyroADIS16507Handler::prepareReadCommand(uint8_t *regList, size_t len) { +void GyroADIS1650XHandler::prepareReadCommand(uint8_t *regList, size_t len) { for(size_t idx = 0; idx < len; idx++) { commandBuffer[idx * 2] = regList[idx]; commandBuffer[idx * 2 + 1] = 0x00; @@ -332,29 +344,29 @@ void GyroADIS16507Handler::prepareReadCommand(uint8_t *regList, size_t len) { commandBuffer[len * 2 + 1] = 0x00; } -ReturnValue_t GyroADIS16507Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, +ReturnValue_t GyroADIS1650XHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { - localDataPoolMap.emplace(ADIS16507::ANG_VELOC_X, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS16507::ANG_VELOC_Y, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS16507::ANG_VELOC_Z, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS16507::ACCELERATION_X, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS16507::ACCELERATION_Y, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS16507::ACCELERATION_Z, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS16507::TEMPERATURE, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_X, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_Y, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_Z, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::ACCELERATION_X, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::ACCELERATION_Y, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::ACCELERATION_Z, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::TEMPERATURE, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS16507::DIAG_STAT_REGISTER, new PoolEntry()); - localDataPoolMap.emplace(ADIS16507::FILTER_SETTINGS, new PoolEntry()); - localDataPoolMap.emplace(ADIS16507::MSC_CTRL_REGISTER, new PoolEntry()); - localDataPoolMap.emplace(ADIS16507::DEC_RATE_REGISTER, new PoolEntry()); + localDataPoolMap.emplace(ADIS1650X::DIAG_STAT_REGISTER, new PoolEntry()); + localDataPoolMap.emplace(ADIS1650X::FILTER_SETTINGS, new PoolEntry()); + localDataPoolMap.emplace(ADIS1650X::MSC_CTRL_REGISTER, new PoolEntry()); + localDataPoolMap.emplace(ADIS1650X::DEC_RATE_REGISTER, new PoolEntry()); return HasReturnvaluesIF::RETURN_OK; } -GyroADIS16507Handler::BurstModes GyroADIS16507Handler::getBurstMode() { +GyroADIS1650XHandler::BurstModes GyroADIS1650XHandler::getBurstMode() { configDataset.mscCtrlReg.read(); uint16_t currentCtrlReg = configDataset.mscCtrlReg.value; configDataset.mscCtrlReg.commit(); - if((currentCtrlReg & ADIS16507::BURST_32_BIT) == ADIS16507::BURST_32_BIT) { - if((currentCtrlReg & ADIS16507::BURST_SEL_BIT) == ADIS16507::BURST_SEL_BIT) { + if((currentCtrlReg & ADIS1650X::BURST_32_BIT) == ADIS1650X::BURST_32_BIT) { + if((currentCtrlReg & ADIS1650X::BURST_SEL_BIT) == ADIS1650X::BURST_SEL_BIT) { return BurstModes::BURST_32_BURST_SEL_1; } else { @@ -362,7 +374,7 @@ GyroADIS16507Handler::BurstModes GyroADIS16507Handler::getBurstMode() { } } else { - if((currentCtrlReg & ADIS16507::BURST_SEL_BIT) == ADIS16507::BURST_SEL_BIT) { + if((currentCtrlReg & ADIS1650X::BURST_SEL_BIT) == ADIS1650X::BURST_SEL_BIT) { return BurstModes::BURST_16_BURST_SEL_1; } else { @@ -371,11 +383,11 @@ GyroADIS16507Handler::BurstModes GyroADIS16507Handler::getBurstMode() { } } -#if OBSW_ADIS16507_LINUX_COM_IF == 1 +#if OBSW_ADIS1650X_LINUX_COM_IF == 1 -ReturnValue_t GyroADIS16507Handler::spiSendCallback(SpiComIF *comIf, SpiCookie *cookie, +ReturnValue_t GyroADIS1650XHandler::spiSendCallback(SpiComIF *comIf, SpiCookie *cookie, const uint8_t *sendData, size_t sendLen, void *args) { - GyroADIS16507Handler* handler = reinterpret_cast(args); + GyroADIS1650XHandler* handler = reinterpret_cast(args); if(handler == nullptr) { sif::error << "GyroADIS16507Handler::spiSendCallback: Passed handler pointer is invalid!" << std::endl; @@ -383,10 +395,10 @@ ReturnValue_t GyroADIS16507Handler::spiSendCallback(SpiComIF *comIf, SpiCookie * } DeviceCommandId_t currentCommand = handler->getPendingCommand(); switch(currentCommand) { - case(ADIS16507::READ_SENSOR_DATA): { + case(ADIS1650X::READ_SENSOR_DATA): { return comIf->performRegularSendOperation(cookie, sendData, sendLen); } - case(ADIS16507::READ_OUT_CONFIG): + case(ADIS1650X::READ_OUT_CONFIG): default: { ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; int retval = 0; @@ -451,7 +463,7 @@ ReturnValue_t GyroADIS16507Handler::spiSendCallback(SpiComIF *comIf, SpiCookie * idx += 2; if(idx < sendLen) { - usleep(ADIS16507::STALL_TIME_MICROSECONDS); + usleep(ADIS1650X::STALL_TIME_MICROSECONDS); } spi_ioc_transfer* transferStruct = cookie->getTransferStructHandle(); transferStruct->tx_buf += 2; @@ -466,4 +478,4 @@ ReturnValue_t GyroADIS16507Handler::spiSendCallback(SpiComIF *comIf, SpiCookie * return HasReturnvaluesIF::RETURN_OK; } -#endif /* OBSW_ADIS16507_LINUX_COM_IF == 1 */ +#endif /* OBSW_ADIS1650X_LINUX_COM_IF == 1 */ diff --git a/mission/devices/GyroADIS16507Handler.h b/mission/devices/GyroADIS1650XHandler.h similarity index 89% rename from mission/devices/GyroADIS16507Handler.h rename to mission/devices/GyroADIS1650XHandler.h index 467e0906..60adeabe 100644 --- a/mission/devices/GyroADIS16507Handler.h +++ b/mission/devices/GyroADIS1650XHandler.h @@ -3,7 +3,7 @@ #include "OBSWConfig.h" #include "FSFWConfig.h" -#include "devicedefinitions/GyroADIS16507Definitions.h" +#include "devicedefinitions/GyroADIS1650XDefinitions.h" #include "fsfw/globalfunctions/PeriodicOperationDivider.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" @@ -19,10 +19,10 @@ class SpiCookie; * Flight manual: * https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/ADIS16507_Gyro */ -class GyroADIS16507Handler: public DeviceHandlerBase { +class GyroADIS1650XHandler: public DeviceHandlerBase { public: - GyroADIS16507Handler(object_id_t objectId, object_id_t deviceCommunication, - CookieIF * comCookie); + GyroADIS1650XHandler(object_id_t objectId, object_id_t deviceCommunication, + CookieIF* comCookie, ADIS1650X::Type type); /* DeviceHandlerBase abstract function implementation */ void doStartUp() override; @@ -42,7 +42,7 @@ public: private: std::array commandBuffer; - + ADIS1650X::Type adisType; AdisGyroPrimaryDataset primaryDataset; AdisGyroConfigDataset configDataset; @@ -71,7 +71,7 @@ private: const uint8_t *sendData, size_t sendLen, void* args); #endif -#if FSFW_HAL_ADIS16507_GYRO_DEBUG == 1 +#if FSFW_HAL_ADIS1650X_GYRO_DEBUG == 1 PeriodicOperationDivider* debugDivider; #endif Countdown breakCountdown; diff --git a/mission/devices/devicedefinitions/GyroADIS16507Definitions.h b/mission/devices/devicedefinitions/GyroADIS1650XDefinitions.h similarity index 80% rename from mission/devices/devicedefinitions/GyroADIS16507Definitions.h rename to mission/devices/devicedefinitions/GyroADIS1650XDefinitions.h index b83c984d..62744e3a 100644 --- a/mission/devices/devicedefinitions/GyroADIS16507Definitions.h +++ b/mission/devices/devicedefinitions/GyroADIS1650XDefinitions.h @@ -6,17 +6,24 @@ #include -namespace ADIS16507 { +namespace ADIS1650X { + +enum class Type { + ADIS16505, + ADIS16507 +}; static constexpr size_t MAXIMUM_REPLY_SIZE = 64; static constexpr uint8_t WRITE_MASK = 0b1000'0000; static constexpr uint32_t GYRO_RANGE = 125; -static constexpr uint32_t ACCELEROMETER_RANGE = 392; +static constexpr uint32_t ACCELEROMETER_RANGE_16507 = 392; +static constexpr float ACCELEROMETER_RANGE_16505 = 78.4; static constexpr uint32_t STALL_TIME_MICROSECONDS = 16; -static constexpr uint16_t PROD_ID = 16507; +static constexpr uint16_t PROD_ID_16507 = 16507; +static constexpr uint16_t PROD_ID_16505 = 16505; static constexpr std::array BURST_READ_ENABLE = {0x68, 0x00}; @@ -95,31 +102,31 @@ public: /** Constructor for data users like controllers */ AdisGyroPrimaryDataset(object_id_t adisId): - StaticLocalDataSet(sid_t(adisId, ADIS16507::ADIS_DATASET_ID)) { + StaticLocalDataSet(sid_t(adisId, ADIS1650X::ADIS_DATASET_ID)) { setAllVariablesReadOnly(); } /* Angular velocities in degrees per second (DPS) */ lp_var_t angVelocX = lp_var_t(sid.objectId, - ADIS16507::ANG_VELOC_X, this); + ADIS1650X::ANG_VELOC_X, this); lp_var_t angVelocY = lp_var_t(sid.objectId, - ADIS16507::ANG_VELOC_Y, this); + ADIS1650X::ANG_VELOC_Y, this); lp_var_t angVelocZ = lp_var_t(sid.objectId, - ADIS16507::ANG_VELOC_Z, this); + ADIS1650X::ANG_VELOC_Z, this); lp_var_t accelX = lp_var_t(sid.objectId, - ADIS16507::ACCELERATION_X, this); + ADIS1650X::ACCELERATION_X, this); lp_var_t accelY = lp_var_t(sid.objectId, - ADIS16507::ACCELERATION_Y, this); + ADIS1650X::ACCELERATION_Y, this); lp_var_t accelZ = lp_var_t(sid.objectId, - ADIS16507::ACCELERATION_Z, this); + ADIS1650X::ACCELERATION_Z, this); lp_var_t temperature = lp_var_t(sid.objectId, - ADIS16507::TEMPERATURE, this); + ADIS1650X::TEMPERATURE, this); private: - friend class GyroADIS16507Handler; + friend class GyroADIS1650XHandler; /** Constructor for the data creator */ AdisGyroPrimaryDataset(HasLocalDataPoolIF* hkOwner): - StaticLocalDataSet(hkOwner, ADIS16507::ADIS_DATASET_ID) {} + StaticLocalDataSet(hkOwner, ADIS1650X::ADIS_DATASET_ID) {} }; class AdisGyroConfigDataset: public StaticLocalDataSet<5> { @@ -127,20 +134,20 @@ public: /** Constructor for data users like controllers */ AdisGyroConfigDataset(object_id_t adisId): - StaticLocalDataSet(sid_t(adisId, ADIS16507::ADIS_CFG_DATASET_ID)) { + StaticLocalDataSet(sid_t(adisId, ADIS1650X::ADIS_CFG_DATASET_ID)) { setAllVariablesReadOnly(); } lp_var_t diagStatReg = lp_var_t(sid.objectId, - ADIS16507::DIAG_STAT_REGISTER); - lp_var_t filterSetting = lp_var_t(sid.objectId, ADIS16507::FILTER_SETTINGS); - lp_var_t mscCtrlReg = lp_var_t(sid.objectId, ADIS16507::MSC_CTRL_REGISTER); - lp_var_t decRateReg = lp_var_t(sid.objectId, ADIS16507::DEC_RATE_REGISTER); + ADIS1650X::DIAG_STAT_REGISTER); + lp_var_t filterSetting = lp_var_t(sid.objectId, ADIS1650X::FILTER_SETTINGS); + lp_var_t mscCtrlReg = lp_var_t(sid.objectId, ADIS1650X::MSC_CTRL_REGISTER); + lp_var_t decRateReg = lp_var_t(sid.objectId, ADIS1650X::DEC_RATE_REGISTER); private: - friend class GyroADIS16507Handler; + friend class GyroADIS1650XHandler; /** Constructor for the data creator */ AdisGyroConfigDataset(HasLocalDataPoolIF* hkOwner): - StaticLocalDataSet(hkOwner, ADIS16507::ADIS_CFG_DATASET_ID) {} + StaticLocalDataSet(hkOwner, ADIS1650X::ADIS_CFG_DATASET_ID) {} }; #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GYROADIS16507DEFINITIONS_H_ */ From 9c42b861f4c4f9447abb3a5d450a1a563dcc03b1 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Sat, 11 Dec 2021 11:56:47 +0100 Subject: [PATCH 129/465] timestamp for file creation --- .../startracker/StarTrackerDefinitions.h | 1 + .../startracker/StarTrackerHandler.cpp | 24 ++++++-- .../devices/startracker/StarTrackerHandler.h | 3 + .../devices/startracker/StrImageLoader.cpp | 61 +++++++++++++------ bsp_q7s/devices/startracker/StrImageLoader.h | 31 ++++++++-- mission/utility/CMakeLists.txt | 1 + mission/utility/Timestamp.cpp | 19 ++++++ mission/utility/Timestamp.h | 27 ++++++++ 8 files changed, 138 insertions(+), 29 deletions(-) create mode 100644 mission/utility/Timestamp.cpp create mode 100644 mission/utility/Timestamp.h diff --git a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h index f854d2ee..a9598142 100644 --- a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h +++ b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h @@ -119,6 +119,7 @@ static const DeviceCommandId_t DOWNLOAD_MATCHED_STAR = 53; static const DeviceCommandId_t DOWNLOAD_DB_IMAGE = 54; static const DeviceCommandId_t STOP_IMAGE_LOADER = 55; static const DeviceCommandId_t RESET_ERROR = 56; +static const DeviceCommandId_t CHANGE_DOWNLOAD_FILE = 57; static const DeviceCommandId_t NONE = 0xFFFFFFFF; static const uint32_t VERSION_SET_ID = REQ_VERSION; diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp index c7687e1c..3e18a6ba 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp @@ -96,10 +96,25 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu return EXECUTION_FINISHED; } case(StarTracker::DOWNLOAD_IMAGE): { - strImageLoader->startImageDownload(std::string(reinterpret_cast(data), size)); + if (size > MAX_PATH_SIZE) { + return FILE_PATH_TOO_LONG; + } + result = strImageLoader->startImageDownload( + std::string(reinterpret_cast(data), size)); + if (result != RETURN_OK) { + return result; + } imageLoaderExecuting = true; return EXECUTION_FINISHED; } + case(StarTracker::CHANGE_DOWNLOAD_FILE): { + if (size > MAX_FILE_NAME) { + return FILENAME_TOO_LONG; + } + strImageLoader->setDownloadImageName( + std::string(reinterpret_cast(data), size)); + return EXECUTION_FINISHED; + } default: break; } @@ -266,8 +281,7 @@ void StarTrackerHandler::fillCommandAndReplyMap() { * is specified */ this->insertInCommandAndReplyMap(StarTracker::PING_REQUEST, 3, nullptr, StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::BOOT, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandMap(StarTracker::BOOT); this->insertInCommandAndReplyMap(StarTracker::REQ_VERSION, 3, &versionSet, StarTracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(StarTracker::REQ_TIME, 3, &timeSet, @@ -844,8 +858,8 @@ ReturnValue_t StarTrackerHandler::handlePingReply() { ReturnValue_t result = RETURN_OK; uint32_t pingId = 0; const uint8_t* reply = dataLinkLayer.getReply(); - uint8_t status = *(reply + 2); - const uint8_t* buffer = reply + 3; + uint8_t status = dataLinkLayer.getStatusField(); + const uint8_t* buffer = reply + ACTION_DATA_OFFSET; size_t size = sizeof(pingId); SerializeAdapter::deSerialize(&pingId, &buffer, &size, SerializeIF::Endianness::LITTLE); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.h b/bsp_q7s/devices/startracker/StarTrackerHandler.h index d5bb7136..76ca6ea1 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.h +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.h @@ -107,8 +107,11 @@ private: static const ReturnValue_t INVALID_UPLOAD_COMMAND = MAKE_RETURN_CODE(0xAA); //! [EXPORT] : [COMMENT] Received invalid path string. Exceeds allowed length static const ReturnValue_t FILE_PATH_TOO_LONG = MAKE_RETURN_CODE(0xAB); + //! [EXPORT] : [COMMENT] Name of file received with command is too long + static const ReturnValue_t FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xAC); static const size_t MAX_PATH_SIZE = 50; + static const size_t MAX_FILE_NAME = 30; // position (uint32) + 1024 image data static const size_t UPLOAD_COMMAND_LEN = 1028; diff --git a/bsp_q7s/devices/startracker/StrImageLoader.cpp b/bsp_q7s/devices/startracker/StrImageLoader.cpp index 1b1c37d2..6f306684 100644 --- a/bsp_q7s/devices/startracker/StrImageLoader.cpp +++ b/bsp_q7s/devices/startracker/StrImageLoader.cpp @@ -1,4 +1,5 @@ #include "StrImageLoader.h" +#include "mission/utility/Timestamp.h" #include #include @@ -66,22 +67,12 @@ void StrImageLoader::setComCookie(CookieIF* comCookie_) { comCookie = comCookie_; } -ReturnValue_t StrImageLoader::startImageUpload(std::string image) { - // Check if file is stored on SD card and if associated SD card is mounted - if (image.substr(0, sizeof(SdCardManager::SD_0_MOUNT_POINT)) - == std::string(SdCardManager::SD_0_MOUNT_POINT)) { - if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { - sif::warning << "StrImageLoader::getImageLocation: SD card 0 not mounted" << std::endl; - return SD_NOT_MOUNTED; - } - } else if (image.substr(0, sizeof(SdCardManager::SD_1_MOUNT_POINT)) - == std::string(SdCardManager::SD_1_MOUNT_POINT)) { - if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { - sif::warning << "StrImageLoader::getImageLocation: SD card 1 not mounted" << std::endl; - return SD_NOT_MOUNTED; - } +ReturnValue_t StrImageLoader::startImageUpload(std::string uploadImage_) { + ReturnValue_t result = checkPath(uploadImage_); + if (result != RETURN_OK) { + return result; } - uploadImage = image; + uploadImage = uploadImage_; if(not std::filesystem::exists(uploadImage)) { return FILE_NOT_EXISTS; } @@ -91,23 +82,40 @@ ReturnValue_t StrImageLoader::startImageUpload(std::string image) { return RETURN_OK; } -void StrImageLoader::startImageDownload(std::string downloadImage_) { - downloadImage = downloadImage_; +ReturnValue_t StrImageLoader::startImageDownload(std::string downloadPath_) { + ReturnValue_t result = checkPath(downloadPath_); + if (result != RETURN_OK) { + return result; + } + if(not std::filesystem::exists(downloadPath_)) { + return PATH_NOT_EXISTS; + } + downloadPath = downloadPath_; internalState = InternalState::DOWNLOAD_IMAGE; terminate = false; semaphore.release(); + return RETURN_OK; } void StrImageLoader::stopProcess() { terminate = true; } +void StrImageLoader::setDownloadImageName(std::string image) { + downloadImage = image; +} + ReturnValue_t StrImageLoader::performImageDownload() { ReturnValue_t result; struct DownloadActionRequest downloadReq; uint32_t size = 0; uint32_t retries = 0; - std::ofstream file(downloadImage, std::ios_base::app | std::ios_base::out); + Timestamp timestamp; + std::string image = downloadPath + "/" + timestamp.str() + downloadImage ; + std::ofstream file(image, std::ios_base::app | std::ios_base::out); + if(not std::filesystem::exists(image)) { + return FILE_CREATION_FAILED; + } downloadReq.position = 0; while(downloadReq.position < LAST_POSITION) { if (terminate) { @@ -287,3 +295,20 @@ ReturnValue_t StrImageLoader::checkReplyPosition(uint32_t expectedPosition) { } return RETURN_OK; } + +ReturnValue_t StrImageLoader::checkPath(std::string name) { + if (name.substr(0, sizeof(SdCardManager::SD_0_MOUNT_POINT)) + == std::string(SdCardManager::SD_0_MOUNT_POINT)) { + if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { + sif::warning << "StrImageLoader::checkPath: SD card 0 not mounted" << std::endl; + return SD_NOT_MOUNTED; + } + } else if (name.substr(0, sizeof(SdCardManager::SD_1_MOUNT_POINT)) + == std::string(SdCardManager::SD_1_MOUNT_POINT)) { + if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { + sif::warning << "StrImageLoader::checkPath: SD card 1 not mounted" << std::endl; + return SD_NOT_MOUNTED; + } + } + return RETURN_OK; +} diff --git a/bsp_q7s/devices/startracker/StrImageLoader.h b/bsp_q7s/devices/startracker/StrImageLoader.h index 48a47df8..5945b7f5 100644 --- a/bsp_q7s/devices/startracker/StrImageLoader.h +++ b/bsp_q7s/devices/startracker/StrImageLoader.h @@ -68,8 +68,6 @@ public: //!P1: Upload/download position for which the request failed static const Event IMG_LOADER_REQUESTING_MSG_FAILED = MAKE_EVENT(13, severity::LOW); - - StrImageLoader(object_id_t objectId); virtual ~StrImageLoader(); @@ -85,18 +83,25 @@ public: * @param image Name including absolute path if to image to upload. Must be previously * transferred to the OBC with the CFDP protocoll. */ - ReturnValue_t startImageUpload(std::string image); + ReturnValue_t startImageUpload(std::string uploadImage_); /** * @brief Calling this function initiates the download of an image from the star tracker. + * + * @param Name of the image which will be created */ - void startImageDownload(std::string downloadImage_); + ReturnValue_t startImageDownload(std::string downloadPath_); /** * @brief Can be used to interrupt a running upload or download process. */ void stopProcess(); + /** + * @brief Changes the dafault name of downloaded images + */ + void setDownloadImageName(std::string image); + private: static const uint8_t INTERFACE_ID = CLASS_ID::STR_IMG_LOADER; @@ -105,6 +110,10 @@ private: 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] Specified path does not exist + static const ReturnValue_t PATH_NOT_EXISTS = MAKE_RETURN_CODE(0xA2); + //! [EXPORT] : [COMMENT] Failed to create download file + static const ReturnValue_t FILE_CREATION_FAILED = MAKE_RETURN_CODE(0xA3); // Size of one image part which can be sent per action request static const size_t SIZE_IMAGE_PART = 1024; @@ -132,8 +141,11 @@ private: // Name including absolute path of image to upload std::string uploadImage; - // Name including the absolute path of downloaded image - std::string downloadImage; + // Path where the downloaded image will be stored + std::string downloadPath; + + // Default name of downloaded image, can be changed via command + std::string downloadImage = "image"; SdCardManager* sdcMan = nullptr; @@ -185,6 +197,13 @@ private: * @return RETURN_OK if received position matches expected position, otherwise RETURN_FAILED */ ReturnValue_t checkReplyPosition(uint32_t expectedPosition); + + /** + * @brief Checks if a path points to an sd card and whether the SD card is monuted. + * + * @return SD_NOT_MOUNTED id SD card is not mounted, otherwise RETURN_OK + */ + ReturnValue_t checkPath(std::string name); }; #endif /* BSP_Q7S_DEVICES_STRIMAGELOADER_H_ */ diff --git a/mission/utility/CMakeLists.txt b/mission/utility/CMakeLists.txt index 4847dddd..50532596 100644 --- a/mission/utility/CMakeLists.txt +++ b/mission/utility/CMakeLists.txt @@ -1,5 +1,6 @@ target_sources(${TARGET_NAME} PUBLIC TmFunnel.cpp + Timestamp.cpp ) diff --git a/mission/utility/Timestamp.cpp b/mission/utility/Timestamp.cpp new file mode 100644 index 00000000..d63f6173 --- /dev/null +++ b/mission/utility/Timestamp.cpp @@ -0,0 +1,19 @@ +#include "Timestamp.h" +#include "fsfw/serviceinterface/ServiceInterfacestream.h" + +Timestamp::Timestamp() { + ReturnValue_t result = Clock::getDateAndTime(&time); + if (result != RETURN_OK) { + sif::warning << "Timestamp::Timestamp: Failed to get time" << std::endl; + } +} + +Timestamp::~Timestamp() { +} + +std::string Timestamp::str() { + return std::to_string(time.year) + "-" + std::to_string(time.month) + "-" + + std::to_string(time.day) + "--" + std::to_string(time.hour) + "-" + + std::to_string(time.minute) + "-" + std::to_string(time.second) + "-"; +} + diff --git a/mission/utility/Timestamp.h b/mission/utility/Timestamp.h new file mode 100644 index 00000000..05dae31f --- /dev/null +++ b/mission/utility/Timestamp.h @@ -0,0 +1,27 @@ +#ifndef MISSION_UTILITY_TIMESTAMP_H_ +#define MISSION_UTILITY_TIMESTAMP_H_ + +#include +#include "fsfw/timemanager/Clock.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" + +/** + * @brief This class generates timestamps for files. + * + * @author J. Meier + */ +class Timestamp : public HasReturnvaluesIF { +public: + Timestamp(); + virtual ~Timestamp(); + + /** + * @brief Returns the timestamp string + */ + std::string str(); + +private: + Clock::TimeOfDay_t time; +}; + +#endif /* MISSION_UTILITY_TIMESTAMP_H_ */ From 86581d81c98eae1fe5680f9154b54f55f63c931e Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 13 Dec 2021 09:40:37 +0100 Subject: [PATCH 130/465] interpretation of empty value strings in json --- bsp_q7s/devices/startracker/ArcsecJsonParamBase.cpp | 7 +++++++ bsp_q7s/devices/startracker/ArcsecJsonParamBase.h | 5 +++++ tmtc | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/bsp_q7s/devices/startracker/ArcsecJsonParamBase.cpp b/bsp_q7s/devices/startracker/ArcsecJsonParamBase.cpp index 38040797..339c3fe7 100644 --- a/bsp_q7s/devices/startracker/ArcsecJsonParamBase.cpp +++ b/bsp_q7s/devices/startracker/ArcsecJsonParamBase.cpp @@ -17,12 +17,19 @@ ReturnValue_t ArcsecJsonParamBase::getParam(const std::string name, std::string& for (json::iterator it = set.begin(); it != set.end(); ++it) { if ((*it)[arcseckeys::NAME] == name) { value = (*it)[arcseckeys::VALUE]; + convertEmpty(value); return RETURN_OK; } } return PARAM_NOT_EXISTS; } +void ArcsecJsonParamBase::convertEmpty(std::string& value) { + if (value == "") { + value = "0"; + } +} + void ArcsecJsonParamBase::addfloat(const std::string value, uint8_t* buffer) { float param = std::stof(value); std::memcpy(buffer, ¶m, sizeof(param)); diff --git a/bsp_q7s/devices/startracker/ArcsecJsonParamBase.h b/bsp_q7s/devices/startracker/ArcsecJsonParamBase.h index dc59c6fc..320eff53 100644 --- a/bsp_q7s/devices/startracker/ArcsecJsonParamBase.h +++ b/bsp_q7s/devices/startracker/ArcsecJsonParamBase.h @@ -66,6 +66,11 @@ protected: */ ReturnValue_t getParam(const std::string name, std::string& value); + /** + * @brief Converts empty string which is equal to define a value as zero. + */ + void convertEmpty(std::string& value); + /** * @brief This function adds a float represented as string to a buffer * diff --git a/tmtc b/tmtc index 7b01165f..bbae8284 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 7b01165ff937e45e052caeb550e622a8b9df6ee2 +Subproject commit bbae8284884ebfd49655e0a806e0d1288f4a7a70 From 985ef0f6bcafe7fb583af5358110544b81239ec9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Dec 2021 17:18:31 +0100 Subject: [PATCH 131/465] wrong object ID --- bsp_q7s/core/ObjectFactory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index e3deba9d..c490ef06 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -739,7 +739,7 @@ void ObjectFactory::createRtdComponents(LinuxLibgpioIF *gpioComIF) { q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); - Max31865PT1000Handler* rtdIc0 = new Max31865PT1000Handler(objects::RTD_IC_6, objects::SPI_COM_IF, + Max31865PT1000Handler* rtdIc0 = new Max31865PT1000Handler(objects::RTD_IC_3, objects::SPI_COM_IF, spiRtdIc0); Max31865PT1000Handler* rtdIc1 = new Max31865PT1000Handler(objects::RTD_IC_4, objects::SPI_COM_IF, spiRtdIc1); From 5fadb8f86de9fadf3a6563a1f64be8c5cd8ffcdb Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Dec 2021 17:35:21 +0100 Subject: [PATCH 132/465] moved heater handler --- bsp_hosted/fsfwconfig/devices/gpioIds.h | 2 -- .../fsfwconfig => common/config}/devices/heaterSwitcherList.h | 0 linux/devices/CMakeLists.txt | 1 - mission/devices/CMakeLists.txt | 1 + {linux => mission}/devices/HeaterHandler.cpp | 0 {linux => mission}/devices/HeaterHandler.h | 0 6 files changed, 1 insertion(+), 3 deletions(-) rename {linux/fsfwconfig => common/config}/devices/heaterSwitcherList.h (100%) rename {linux => mission}/devices/HeaterHandler.cpp (100%) rename {linux => mission}/devices/HeaterHandler.h (100%) diff --git a/bsp_hosted/fsfwconfig/devices/gpioIds.h b/bsp_hosted/fsfwconfig/devices/gpioIds.h index 1ab55d08..a4b4ac81 100644 --- a/bsp_hosted/fsfwconfig/devices/gpioIds.h +++ b/bsp_hosted/fsfwconfig/devices/gpioIds.h @@ -1,8 +1,6 @@ #ifndef FSFWCONFIG_DEVICES_GPIOIDS_H_ #define FSFWCONFIG_DEVICES_GPIOIDS_H_ -#include - namespace gpioIds { enum gpioId_t { HEATER_0, diff --git a/linux/fsfwconfig/devices/heaterSwitcherList.h b/common/config/devices/heaterSwitcherList.h similarity index 100% rename from linux/fsfwconfig/devices/heaterSwitcherList.h rename to common/config/devices/heaterSwitcherList.h diff --git a/linux/devices/CMakeLists.txt b/linux/devices/CMakeLists.txt index 6c529d8e..bf0a556e 100644 --- a/linux/devices/CMakeLists.txt +++ b/linux/devices/CMakeLists.txt @@ -1,5 +1,4 @@ target_sources(${TARGET_NAME} PRIVATE - HeaterHandler.cpp SolarArrayDeploymentHandler.cpp SusHandler.cpp StarTrackerHandler.cpp diff --git a/mission/devices/CMakeLists.txt b/mission/devices/CMakeLists.txt index cbfbe4a5..ed811ed3 100644 --- a/mission/devices/CMakeLists.txt +++ b/mission/devices/CMakeLists.txt @@ -10,6 +10,7 @@ target_sources(${TARGET_NAME} PUBLIC SyrlinksHkHandler.cpp Max31865PT1000Handler.cpp IMTQHandler.cpp + HeaterHandler.cpp PlocMPSoCHandler.cpp RadiationSensorHandler.cpp GyroADIS1650XHandler.cpp diff --git a/linux/devices/HeaterHandler.cpp b/mission/devices/HeaterHandler.cpp similarity index 100% rename from linux/devices/HeaterHandler.cpp rename to mission/devices/HeaterHandler.cpp diff --git a/linux/devices/HeaterHandler.h b/mission/devices/HeaterHandler.h similarity index 100% rename from linux/devices/HeaterHandler.h rename to mission/devices/HeaterHandler.h From 1f6dbd181c6d70bcc7b95531b522378f756e5e26 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Dec 2021 17:38:23 +0100 Subject: [PATCH 133/465] moved heater handler --- bsp_q7s/core/ObjectFactory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index c490ef06..3fb71db5 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -19,7 +19,6 @@ #include "bsp_q7s/callbacks/rwSpiCallback.h" #include "bsp_q7s/callbacks/gnssCallback.h" -#include "linux/devices/HeaterHandler.h" #include "linux/devices/StarTrackerHandler.h" #include "linux/devices/SolarArrayDeploymentHandler.h" #include "linux/devices/devicedefinitions/SusDefinitions.h" @@ -28,6 +27,7 @@ #include "linux/csp/CspComIF.h" #include "linux/devices/devicedefinitions/StarTrackerDefinitions.h" +#include "mission/devices/HeaterHandler.h" #include "mission/core/GenericFactory.h" #include "mission/devices/PDU1Handler.h" #include "mission/devices/PDU2Handler.h" From 74f52632f690c14bd5b904b4e1aae6a5d43406c0 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 14 Dec 2021 19:23:47 +0100 Subject: [PATCH 134/465] increased frequency of pst tasks --- bsp_q7s/core/InitMission.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index 9e293969..57db4a71 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -221,21 +221,21 @@ void initmission::createPstTasks(TaskFactory& factory, #endif FixedTimeslotTaskIF* uartPst = factory.createFixedTimeslotTask( - "UART_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 3.0, missedDeadlineFunc); + "UART_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc); result = pst::pstUart(uartPst); if (result != HasReturnvaluesIF::RETURN_OK) { sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; } taskVec.push_back(uartPst); FixedTimeslotTaskIF* gpioPst = factory.createFixedTimeslotTask( - "GPIO_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 3.0, missedDeadlineFunc); + "GPIO_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc); result = pst::pstGpio(gpioPst); if (result != HasReturnvaluesIF::RETURN_OK) { sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; } taskVec.push_back(gpioPst); FixedTimeslotTaskIF* i2cPst = factory.createFixedTimeslotTask( - "I2C_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 3.0, missedDeadlineFunc); + "I2C_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc); result = pst::pstI2c(i2cPst); if (result != HasReturnvaluesIF::RETURN_OK) { sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; From 717f2e21a097e76552bb10f237ddcb428750addc Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 14 Dec 2021 19:24:31 +0100 Subject: [PATCH 135/465] star tracker improvements --- .../startracker/StarTrackerDefinitions.h | 8 +- .../startracker/StarTrackerHandler.cpp | 224 ++++++++++++++++-- .../devices/startracker/StarTrackerHandler.h | 59 ++++- .../devices/startracker/StrImageLoader.cpp | 4 +- bsp_q7s/devices/startracker/StrImageLoader.h | 7 +- .../pollingSequenceFactory.cpp | 1 - 6 files changed, 278 insertions(+), 25 deletions(-) diff --git a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h index a9598142..8c87dcfc 100644 --- a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h +++ b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h @@ -92,7 +92,7 @@ static const DeviceCommandId_t REQ_INTERFACE = 3; static const DeviceCommandId_t REQ_TIME = 4; static const DeviceCommandId_t ERASE = 5; static const DeviceCommandId_t UNLOCK = 6; -static const DeviceCommandId_t REBOOT = 7; +static const DeviceCommandId_t SWITCH_TO_BOOTLOADER_PROGRAM = 7; static const DeviceCommandId_t DOWNLOAD_IMAGE = 9; static const DeviceCommandId_t UPLOAD_IMAGE = 10; static const DeviceCommandId_t REQ_POWER = 11; @@ -120,6 +120,7 @@ static const DeviceCommandId_t DOWNLOAD_DB_IMAGE = 54; static const DeviceCommandId_t STOP_IMAGE_LOADER = 55; static const DeviceCommandId_t RESET_ERROR = 56; static const DeviceCommandId_t CHANGE_DOWNLOAD_FILE = 57; +static const DeviceCommandId_t SET_JSON_FILE_NAME = 58; static const DeviceCommandId_t NONE = 0xFFFFFFFF; static const uint32_t VERSION_SET_ID = REQ_VERSION; @@ -171,6 +172,11 @@ namespace ID { static const uint8_t ERROR_RESET = 12; } +namespace Program { + static const uint8_t BOOTLOADER = 1; + static const uint8_t FIRMWARE = 2; +} + /** * @brief This dataset can be used to store the temperature of a reaction wheel. */ diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp index 3e18a6ba..f957f9fc 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp @@ -81,9 +81,19 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu if (imageLoaderExecuting == true) { return IMAGE_LOADER_EXECUTING; } + + result = checkMode(actionId); + if (result != RETURN_OK) { + return result; + } + // Intercept image loader commands which do not follow the common DHB communication flow switch(actionId) { case(StarTracker::UPLOAD_IMAGE): { + result = DeviceHandlerBase::acceptExternalDeviceCommands(); + if (result != RETURN_OK) { + return result; + } if (size > MAX_PATH_SIZE) { return FILE_PATH_TOO_LONG; } @@ -96,6 +106,10 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu return EXECUTION_FINISHED; } case(StarTracker::DOWNLOAD_IMAGE): { + result = DeviceHandlerBase::acceptExternalDeviceCommands(); + if (result != RETURN_OK) { + return result; + } if (size > MAX_PATH_SIZE) { return FILE_PATH_TOO_LONG; } @@ -138,19 +152,33 @@ void StarTrackerHandler::performOperationHook() { } void StarTrackerHandler::doStartUp() { - -#if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 -// setMode(MODE_NORMAL); + switch(startupState) { + case StartupState::IDLE: + startupState = StartupState::CHECK_BOOT_STATE; + return; + case StartupState::BOOT_DELAY: + if (bootCountdown.hasTimedOut()) { + startupState = StartupState::LIMITS; + } + return; + case StartupState::DONE: + break; + default: + return; + } setMode(_MODE_TO_ON); -#else - setMode(_MODE_TO_ON); -#endif } void StarTrackerHandler::doShutDown() { + // If star tracker is shutdown also stop all running processes in the image loader task + strImageLoader->stopProcess(); setMode(_MODE_POWER_DOWN); } +void StarTrackerHandler::doOffActivity() { + startupState = StartupState::IDLE; +} + ReturnValue_t StarTrackerHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) { switch (internalState) { case InternalState::TEMPERATURE_REQUEST: @@ -165,6 +193,72 @@ ReturnValue_t StarTrackerHandler::buildNormalDeviceCommand(DeviceCommandId_t * i } ReturnValue_t StarTrackerHandler::buildTransitionDeviceCommand(DeviceCommandId_t * id) { + if (mode != _MODE_START_UP) { + return NOTHING_TO_SEND; + } + switch (startupState) { + case StartupState::CHECK_BOOT_STATE: + *id = StarTracker::REQ_VERSION; + startupState = StartupState::WAIT_FOR_EXECUTION; + return buildCommandFromCommand(*id, nullptr, 0); + case StartupState::BOOT: + *id = StarTracker::BOOT; + bootCountdown.setTimeout(BOOT_TIMEOUT); + startupState = StartupState::BOOT_DELAY; + return buildCommandFromCommand(*id, nullptr, 0); + case StartupState::LIMITS: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::LIMITS; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::TRACKING: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::TRACKING; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::MOUNTING: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::MOUNTING; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::CAMERA: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::CAMERA; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::BLOB: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::BLOB; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::CENTROIDING: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::CENTROIDING; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::LISA: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::LISA; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::MATCHING: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::MATCHING; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::VALIDATION: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::VALIDATION; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::ALGO: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::ALGO; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + default: + break; + } return NOTHING_TO_SEND; } @@ -196,7 +290,7 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi preparePowerRequest(); return RETURN_OK; } - case (StarTracker::REBOOT): { + case (StarTracker::SWITCH_TO_BOOTLOADER_PROGRAM): { prepareRebootCommand(); return RETURN_OK; } @@ -293,7 +387,7 @@ void StarTrackerHandler::fillCommandAndReplyMap() { this->insertInCommandAndReplyMap(StarTracker::REQ_INTERFACE, 3, &interfaceSet, StarTracker::MAX_FRAME_SIZE * 2 + 2); // Reboot has no reply. Star tracker reboots immediately - this->insertInCommandMap(StarTracker::REBOOT); + this->insertInCommandMap(StarTracker::SWITCH_TO_BOOTLOADER_PROGRAM); this->insertInCommandAndReplyMap(StarTracker::SUBSCRIBE_TO_TM, 3, nullptr, StarTracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(StarTracker::REQ_SOLUTION, 3, &solutionSet, @@ -406,6 +500,13 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con } case (StarTracker::REQ_VERSION): { result = handleVersionTm(); + if (result != RETURN_OK) { + return result; + } + result = checkProgram(); + if (result != RETURN_OK) { + return result; + } break; } case (StarTracker::REQ_INTERFACE): { @@ -535,21 +636,29 @@ ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& l } size_t StarTrackerHandler::getNextReplyLength(DeviceCommandId_t commandId){ - // Prevent DHB from polling UART during upload command. Because UART is used by image loader - // task - if (commandId == StarTracker::UPLOAD_IMAGE) { - return 0; - } return StarTracker::MAX_FRAME_SIZE; } ReturnValue_t StarTrackerHandler::doSendReadHook() { + // Prevent DHB from polling UART during commands executed by the image loader task if(imageLoaderExecuting) { return RETURN_FAILED; } return RETURN_OK; } +ReturnValue_t StarTrackerHandler::checkMode(ActionId_t actionId) { + switch(actionId) { + case StarTracker::UPLOAD_IMAGE: + case StarTracker::DOWNLOAD_IMAGE: { + return DeviceHandlerBase::acceptExternalDeviceCommands(); + default: + break; + } + } + return RETURN_OK; +} + ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t *foundId) { const uint8_t* reply = dataLinkLayer.getReply(); switch (*reply) { @@ -836,8 +945,14 @@ ReturnValue_t StarTrackerHandler::handleSetParamReply() { sif::warning << "StarTrackerHandler::handleSetParamReply: Failed to execute parameter set " " command with parameter ID" << static_cast(*(reply + PARAMETER_ID_OFFSET)) << std::endl; + if (startupState != StartupState::IDLE) { + startupState = StartupState::IDLE; + } return SET_PARAM_FAILED; } + if (startupState != StartupState::IDLE) { + handleStartup(reply + PARAMETER_ID_OFFSET); + } return RETURN_OK; } @@ -863,13 +978,18 @@ ReturnValue_t StarTrackerHandler::handlePingReply() { size_t size = sizeof(pingId); SerializeAdapter::deSerialize(&pingId, &buffer, &size, SerializeIF::Endianness::LITTLE); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - sif::info << "Ping status: "<< static_cast(status) << std::endl; + sif::info << "StarTracker: Ping status: "<< static_cast(status) << std::endl; sif::info << "Ping id: 0x"<< std::hex << pingId << std::endl; #endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ if (status != StarTracker::STATUS_OK || pingId != PING_ID) { sif::warning << "StarTrackerHandler::handlePingReply: Ping failed" << std::endl; result = PING_FAILED; } + else { +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 + sif::info << "StarTracker: Ping successful" << std::endl; +#endif + } return result; } @@ -885,7 +1005,7 @@ ReturnValue_t StarTrackerHandler::handleTimeTm() { uint64_t time = 0; getTmHeaderData(&status, &ticks, &time); if(status != StarTracker::STATUS_OK) { - sif::warning << "StarTrackerHandler::handleVersionTm: Reply error: " + sif::warning << "StarTrackerHandler::handleTimeTm: Reply error: " << static_cast(status) << std::endl; result = VERSION_REQ_FAILED; return result; @@ -941,6 +1061,30 @@ ReturnValue_t StarTrackerHandler::handleVersionTm() { return result; } +ReturnValue_t StarTrackerHandler::checkProgram() { + PoolReadGuard pg(&versionSet); + switch(versionSet.program.value) { + case StarTracker::Program::BOOTLOADER: + // Star tracker currently in bootloader program. Need to send boot command to switch to + // firmware program + if (startupState != StartupState::IDLE) { + startupState = StartupState::BOOT; + } + break; + case StarTracker::Program::FIRMWARE: + // Firmware already booted + if (startupState != StartupState::IDLE) { + startupState = StartupState::LIMITS; + } + break; + default: + sif::warning << "StarTrackerHandler::checkProgram: Version set has invalid program ID" + << std::endl; + return INVALID_PROGRAM; + } + return RETURN_OK; +} + ReturnValue_t StarTrackerHandler::handleInterfaceTm() { ReturnValue_t result = RETURN_OK; uint32_t offset = TM_DATA_FIELD_OFFSET; @@ -1203,3 +1347,53 @@ uint64_t StarTrackerHandler::deserializeUint64(const uint8_t* buffer) { | static_cast(*(buffer)); return word; } + +void StarTrackerHandler::handleStartup(const uint8_t* parameterId) { + switch(*parameterId) { + case (StarTracker::ID::LIMITS): { + startupState = StartupState::TRACKING; + break; + } + case (StarTracker::ID::TRACKING): { + startupState = StartupState::MOUNTING; + break; + } + case (StarTracker::ID::MOUNTING): { + startupState = StartupState::CAMERA; + break; + } + case (StarTracker::ID::CAMERA): { + startupState = StartupState::BLOB; + break; + } + case (StarTracker::ID::BLOB): { + startupState = StartupState::CENTROIDING; + break; + } + case (StarTracker::ID::CENTROIDING): { + startupState = StartupState::LISA; + break; + } + case (StarTracker::ID::LISA): { + startupState = StartupState::MATCHING; + break; + } + case (StarTracker::ID::MATCHING): { + startupState = StartupState::VALIDATION; + break; + } + case (StarTracker::ID::VALIDATION): { + startupState = StartupState::ALGO; + break; + } + case (StarTracker::ID::ALGO): { + startupState = StartupState::DONE; + break; + } + default: { + sif::debug << "StarTrackerHandler::handleStartup: Received parameter reply with unexpected" + << " parameter ID" << std::endl; + break; + } + } +} diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.h b/bsp_q7s/devices/startracker/StarTrackerHandler.h index 76ca6ea1..e22ff739 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.h +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.h @@ -3,6 +3,7 @@ #include "fsfw/devicehandlers/DeviceHandlerBase.h" #include "fsfw/src/fsfw/serialize/SerializeAdapter.h" +#include "fsfw/timemanager/Countdown.h" #include "thirdparty/arcsec_star_tracker/common/SLIP.h" #include #include "StrImageLoader.h" @@ -49,6 +50,7 @@ public: protected: void doStartUp() override; void doShutDown() override; + void doOffActivity() override; ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override; void fillCommandAndReplyMap() override; @@ -62,12 +64,10 @@ protected: uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) override; - /** * @brief Overwritten here to always read all available data from the UartComIF. */ virtual size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override; - virtual ReturnValue_t doSendReadHook() override; private: @@ -109,6 +109,8 @@ private: static const ReturnValue_t FILE_PATH_TOO_LONG = MAKE_RETURN_CODE(0xAB); //! [EXPORT] : [COMMENT] Name of file received with command is too long static const ReturnValue_t FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xAC); + //! [EXPORT] : [COMMENT] Received version reply with invalid program ID + static const ReturnValue_t INVALID_PROGRAM = MAKE_RETURN_CODE(0xAD); static const size_t MAX_PATH_SIZE = 50; static const size_t MAX_FILE_NAME = 30; @@ -124,13 +126,12 @@ private: static const uint8_t PARAMETER_ID_OFFSET = 0; static const uint8_t ACTION_ID_OFFSET = 0; static const uint8_t ACTION_DATA_OFFSET = 2; - // Ping request will reply ping with this ID (data field) static const uint32_t PING_ID = 0x55; static const uint32_t BOOT_REGION_ID = 1; - - static const MutexIF::TimeoutType TIMEOUT_TYPE= MutexIF::TimeoutType::WAITING; + static const MutexIF::TimeoutType TIMEOUT_TYPE = MutexIF::TimeoutType::WAITING; static const uint32_t MUTEX_TIMEOUT = 20; + static const uint32_t BOOT_TIMEOUT = 1000; MessageQueueIF* eventQueue = nullptr; @@ -148,14 +149,52 @@ private: uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE]; + // Countdown to insert delay for star tracker to switch from bootloader to firmware program + Countdown bootCountdown; + + std::string paramJsonFile = "/mnt/sd0/startracker/full.json"; + enum class InternalState { TEMPERATURE_REQUEST }; InternalState internalState = InternalState::TEMPERATURE_REQUEST; + enum class StartupState { + IDLE, + CHECK_BOOT_STATE, + BOOT, + BOOT_DELAY, + LIMITS, + TRACKING, + MOUNTING, + CAMERA, + BLOB, + CENTROIDING, + LISA, + MATCHING, + VALIDATION, + ALGO, + WAIT_FOR_EXECUTION, + DONE + }; + + StartupState startupState = StartupState::IDLE; + bool imageLoaderExecuting = false; + /** + * @brief Handles internal state + */ + void handleInternalState(); + + /** + * @brief Checks mode for commands requiring MODE_ON of MODE_NORMAL for execution. + * + * @param actionId Action id of command to execute + */ + ReturnValue_t checkMode(ActionId_t actionId); + /** * @brief This function initializes the serial link ip protocol struct slipInfo. */ @@ -279,6 +318,11 @@ private: */ ReturnValue_t handleVersionTm(); + /** + * @brief Checks the loaded program by means of the version set + */ + ReturnValue_t checkProgram(); + /** * @brief Handles reply to request interface telemetry command. */ @@ -315,6 +359,11 @@ private: * @note Deserialization will be performed in little endian byte order */ uint64_t deserializeUint64(const uint8_t* buffer); + + /** + * @brief Handles the startup state machine + */ + void handleStartup(const uint8_t* parameterId); }; #endif /* MISSION_DEVICES_STARTRACKERHANDLER_H_ */ diff --git a/bsp_q7s/devices/startracker/StrImageLoader.cpp b/bsp_q7s/devices/startracker/StrImageLoader.cpp index 6f306684..495ec3a8 100644 --- a/bsp_q7s/devices/startracker/StrImageLoader.cpp +++ b/bsp_q7s/devices/startracker/StrImageLoader.cpp @@ -272,7 +272,7 @@ ReturnValue_t StrImageLoader::sendAndRead(size_t size, uint32_t position) { ReturnValue_t StrImageLoader::checkReply() { uint8_t type = datalinkLayer.getReplyFrameType(); if (type != TMTC_ACTIONREPLY) { - sif::warning << "StrImageLoader::checkUploadReply: Received reply with invalid type ID" + sif::warning << "StrImageLoader::checkReply: Received reply with invalid type ID" << std::endl; triggerEvent(INVALID_TYPE_ID); return RETURN_FAILED; @@ -280,7 +280,7 @@ ReturnValue_t StrImageLoader::checkReply() { uint8_t status = datalinkLayer.getStatusField(); if (status != ArcsecDatalinkLayer::STATUS_OK) { triggerEvent(STATUS_ERROR); - sif::warning << "StrImageLoader::checkUploadReply: Status failure" << std::endl; + sif::warning << "StrImageLoader::checkReply: Status failure" << std::endl; return RETURN_FAILED; } return RETURN_OK; diff --git a/bsp_q7s/devices/startracker/StrImageLoader.h b/bsp_q7s/devices/startracker/StrImageLoader.h index 5945b7f5..50fe3e92 100644 --- a/bsp_q7s/devices/startracker/StrImageLoader.h +++ b/bsp_q7s/devices/startracker/StrImageLoader.h @@ -170,7 +170,12 @@ private: ReturnValue_t performImageUpload(); /** - * @bried Performs download of last taken image from the star tracker. + * @brief Performs download of last taken image from the star tracker. + * + * @details Download is split over multiple packets transporting each a maximum of 1024 bytes. + * In case the download of one position fails, the same packet will be again + * requested. If the download of the packet fails CONFIG_MAX_DOWNLOAD_RETRIES times, + * the download will be stopped. */ ReturnValue_t performImageDownload(); diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 6d020181..22356d0e 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -568,7 +568,6 @@ ReturnValue_t pst::pstI2c(FixedTimeslotTaskIF *thisSequence) { ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) { // Length of a communication cycle uint32_t length = thisSequence->getPeriodMs(); - static_cast(length); bool uartPstEmpty = true; #if OBSW_ADD_PLOC_MPSOC == 1 From 58074f9bfd467338603119a096ad4ab48c4a9450 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 14 Dec 2021 19:33:26 +0100 Subject: [PATCH 136/465] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index bbae8284..3377243c 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit bbae8284884ebfd49655e0a806e0d1288f4a7a70 +Subproject commit 3377243c07ceb4c5d58d35468dedefb71e1c4aa5 From 774ffa835951cfc5ca293b997e2f32dfe233f8a1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Dec 2021 10:02:44 +0100 Subject: [PATCH 137/465] update fsfw and tmtc --- fsfw | 2 +- tmtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsfw b/fsfw index bda02b46..e428568a 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit bda02b464a2ad00b1a8e373d4c6b80b0a7c8de95 +Subproject commit e428568a00494c3e3ceb6d0b314baae97d4d8731 diff --git a/tmtc b/tmtc index 1d374230..f6a3f792 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 1d374230b34606d8b6aa4df1335befec316a1e35 +Subproject commit f6a3f792203bc1f00b10c9760b99a8e83ae2535c From 5ae6a61ec0bd3f2fd9fef0453387b83185cdf7df Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Dec 2021 10:15:06 +0100 Subject: [PATCH 138/465] fixes for gyro adis handler --- linux/fsfwconfig/OBSWConfig.h.in | 4 ++-- mission/devices/GyroADIS1650XHandler.cpp | 20 ++++++++++---------- mission/devices/GyroADIS1650XHandler.h | 6 +++--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index 663ef00b..a95bbfd5 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -115,8 +115,8 @@ debugging. */ /*******************************************************************/ /** Hardcoded */ /*******************************************************************/ -// Leave at one as the BSP is linux. Used by the ADIS16507 device handler -#define OBSW_ADIS16507_LINUX_COM_IF 1 +// Leave at one as the BSP is linux. Used by the ADIS1650X device handler +#define OBSW_ADIS1650X_LINUX_COM_IF 1 #include "OBSWVersion.h" diff --git a/mission/devices/GyroADIS1650XHandler.cpp b/mission/devices/GyroADIS1650XHandler.cpp index 4acf9196..6124fc10 100644 --- a/mission/devices/GyroADIS1650XHandler.cpp +++ b/mission/devices/GyroADIS1650XHandler.cpp @@ -185,7 +185,7 @@ void GyroADIS1650XHandler::fillCommandAndReplyMap() { ReturnValue_t GyroADIS1650XHandler::scanForReply(const uint8_t *start, size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { - /* For SPI, the ID will always be the one of the last sent command. */ + // For SPI, the ID will always be the one of the last sent command *foundId = this->getPendingCommand(); *foundLen = this->rawPacketLen; @@ -196,18 +196,19 @@ ReturnValue_t GyroADIS1650XHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { switch(id) { case(ADIS1650X::READ_OUT_CONFIG): { - PoolReadGuard rg(&configDataset); + uint16_t readProdId = packet[10] << 8 | packet[11]; 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 - sif::warning << "GyroADIS16507Handler::interpretDeviceReply: Invalid product ID " + sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Invalid product ID " << readProdId << std::endl; #endif return HasReturnvaluesIF::RETURN_FAILED; } + PoolReadGuard rg(&configDataset); configDataset.diagStatReg.value = packet[2] << 8 | packet[3]; configDataset.filterSetting.value = packet[4] << 8 | packet[5]; configDataset.mscCtrlReg.value = packet[6] << 8 | packet[7]; @@ -232,21 +233,20 @@ ReturnValue_t GyroADIS1650XHandler::handleSensorData(const uint8_t *packet) { switch(burstMode) { case(BurstModes::BURST_16_BURST_SEL_1): case(BurstModes::BURST_32_BURST_SEL_1): { - sif::warning << "GyroADIS16507Handler::interpretDeviceReply: Analysis with BURST_SEL1" + sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Analysis with BURST_SEL1" " not implemented!" << std::endl; return HasReturnvaluesIF::RETURN_OK; } case(BurstModes::BURST_16_BURST_SEL_0): { uint16_t checksum = packet[20] << 8 | packet[21]; - /* Now verify the read checksum with the expected checksum - according to datasheet p. 20 */ + // Now verify the read checksum with the expected checksum according to datasheet p. 20 uint16_t calcChecksum = 0; for(size_t idx = 2; idx < 20; idx ++) { calcChecksum += packet[idx]; } if(checksum != calcChecksum) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::warning << "GyroADIS16507Handler::interpretDeviceReply: " + sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: " "Invalid checksum detected!" << std::endl; #endif return HasReturnvaluesIF::RETURN_FAILED; @@ -277,7 +277,7 @@ ReturnValue_t GyroADIS1650XHandler::handleSensorData(const uint8_t *packet) { } else if(adisType == ADIS1650X::Type::ADIS16505) { accelScaling = ADIS1650X::ACCELEROMETER_RANGE_16505; } else { - sif::warning << "GyroADIS16507Handler::handleSensorData: " + sif::warning << "GyroADIS1650XHandler::handleSensorData: " "Unknown ADIS type" << std::endl; } int16_t accelXRaw = packet[10] << 8 | packet[11]; @@ -298,11 +298,11 @@ ReturnValue_t GyroADIS1650XHandler::handleSensorData(const uint8_t *packet) { #if FSFW_HAL_ADIS1650X_GYRO_DEBUG == 1 if(debugDivider->checkAndIncrement()) { - sif::info << "GyroADIS16507Handler: Angular velocities in deg / s" << std::endl; + sif::info << "GyroADIS1650XHandler: Angular velocities in deg / s" << std::endl; sif::info << "X: " << primaryDataset.angVelocX.value << std::endl; sif::info << "Y: " << primaryDataset.angVelocY.value << std::endl; sif::info << "Z: " << primaryDataset.angVelocZ.value << std::endl; - sif::info << "GyroADIS16507Handler: Accelerations in m / s^2: " << std::endl; + sif::info << "GyroADIS1650XHandler: Accelerations in m / s^2: " << std::endl; sif::info << "X: " << primaryDataset.accelX.value << std::endl; sif::info << "Y: " << primaryDataset.accelY.value << std::endl; sif::info << "Z: " << primaryDataset.accelZ.value << std::endl; diff --git a/mission/devices/GyroADIS1650XHandler.h b/mission/devices/GyroADIS1650XHandler.h index 60adeabe..b1ac50f5 100644 --- a/mission/devices/GyroADIS1650XHandler.h +++ b/mission/devices/GyroADIS1650XHandler.h @@ -8,7 +8,7 @@ #include "fsfw/globalfunctions/PeriodicOperationDivider.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" -#if OBSW_ADIS16507_LINUX_COM_IF == 1 +#if OBSW_ADIS1650X_LINUX_COM_IF == 1 class SpiComIF; class SpiCookie; #endif @@ -24,7 +24,7 @@ public: GyroADIS1650XHandler(object_id_t objectId, object_id_t deviceCommunication, CookieIF* comCookie, ADIS1650X::Type type); - /* DeviceHandlerBase abstract function implementation */ + // DeviceHandlerBase abstract function implementation void doStartUp() override; void doShutDown() override; ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; @@ -66,7 +66,7 @@ private: BurstModes getBurstMode(); -#if OBSW_ADIS16507_LINUX_COM_IF == 1 +#if OBSW_ADIS1650X_LINUX_COM_IF == 1 static ReturnValue_t spiSendCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sendData, size_t sendLen, void* args); #endif From 9e6ad8807a469d971b5b6dae2c2bc810f355a0db Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Dec 2021 11:20:28 +0100 Subject: [PATCH 139/465] clear fault bit for max31865 devies --- bsp_q7s/core/InitMission.cpp | 2 +- fsfw | 2 +- mission/devices/Max31865PT1000Handler.cpp | 24 ++++++++++++++++++- mission/devices/Max31865PT1000Handler.h | 4 +++- .../devicedefinitions/Max31865Definitions.h | 4 ++++ tmtc | 2 +- 6 files changed, 33 insertions(+), 5 deletions(-) diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index 81d972b1..411fbd8d 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -199,7 +199,7 @@ void initmission::createPstTasks(TaskFactory& factory, /* Polling Sequence Table Default */ #if OBSW_ADD_SPI_TEST_CODE == 0 FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask( - "PST_TASK_DEFAULT", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 3.0, + "PST_TASK_DEFAULT", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 2.0, missedDeadlineFunc); result = pst::pstSpi(spiPst); if (result != HasReturnvaluesIF::RETURN_OK) { diff --git a/fsfw b/fsfw index e428568a..54e56ec5 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit e428568a00494c3e3ceb6d0b314baae97d4d8731 +Subproject commit 54e56ec522f485525de7b17458b22132003c5047 diff --git a/mission/devices/Max31865PT1000Handler.cpp b/mission/devices/Max31865PT1000Handler.cpp index ba9c8e08..4cdc75b3 100644 --- a/mission/devices/Max31865PT1000Handler.cpp +++ b/mission/devices/Max31865PT1000Handler.cpp @@ -91,6 +91,10 @@ ReturnValue_t Max31865PT1000Handler::buildNormalDeviceCommand( *id = Max31865Definitions::REQUEST_FAULT_BYTE; return buildCommandFromCommand(*id, nullptr, 0); } + else if(internalState == InternalState::CLEAR_FAULT_BYTE) { + *id = Max31865Definitions::CLEAR_FAULT_BYTE; + return buildCommandFromCommand(*id, nullptr, 0); + } else { return DeviceHandlerBase::NOTHING_TO_SEND; } @@ -155,6 +159,13 @@ ReturnValue_t Max31865PT1000Handler::buildCommandFromCommand( return DeviceHandlerIF::NO_COMMAND_DATA; } } + case(Max31865Definitions::CLEAR_FAULT_BYTE): { + commandBuffer[0] = static_cast(Max31865Definitions::CONFIG_CMD); + commandBuffer[1] = Max31865Definitions::CLEAR_FAULT_BIT_VAL; + DeviceHandlerBase::rawPacketLen = 2; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; + } case(Max31865Definitions::REQUEST_CONFIG): { commandBuffer[0] = static_cast( Max31865Definitions::REQUEST_CONFIG); @@ -233,6 +244,7 @@ void Max31865PT1000Handler::fillCommandAndReplyMap() { insertInCommandAndReplyMap(Max31865Definitions::REQUEST_RTD, 3, &sensorDataset); insertInCommandAndReplyMap(Max31865Definitions::REQUEST_FAULT_BYTE, 3); + insertInCommandAndReplyMap(Max31865Definitions::CLEAR_FAULT_BYTE, 3); } ReturnValue_t Max31865PT1000Handler::scanForReply(const uint8_t *start, @@ -290,6 +302,11 @@ ReturnValue_t Max31865PT1000Handler::scanForReply(const uint8_t *start, *foundLen = 2; internalState = InternalState::RUNNING; } + else if(internalState == InternalState::CLEAR_FAULT_BYTE) { + *foundId = Max31865Definitions::CLEAR_FAULT_BYTE; + *foundLen = 2; + internalState = InternalState::RUNNING; + } else { *foundId = Max31865Definitions::REQUEST_CONFIG; *foundLen = configReplySize; @@ -360,9 +377,14 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply( case(Max31865Definitions::REQUEST_RTD): { // first bit of LSB reply byte is the fault bit uint8_t faultBit = packet[2] & 0b0000'0001; - if(faultBit == 1) { + if(resetFaultBit) { + internalState = InternalState::CLEAR_FAULT_BYTE; + resetFaultBit = false; + } + else if(faultBit == 1) { // Maybe we should attempt to restart it? internalState = InternalState::REQUEST_FAULT_BYTE; + resetFaultBit = true; } // RTD value consists of last seven bits of the LSB reply byte and diff --git a/mission/devices/Max31865PT1000Handler.h b/mission/devices/Max31865PT1000Handler.h index b33ddbe0..60fd2904 100644 --- a/mission/devices/Max31865PT1000Handler.h +++ b/mission/devices/Max31865PT1000Handler.h @@ -96,12 +96,14 @@ private: REQUEST_LOW_THRESHOLD, REQUEST_CONFIG, RUNNING, - REQUEST_FAULT_BYTE + REQUEST_FAULT_BYTE, + CLEAR_FAULT_BYTE }; InternalState internalState = InternalState::NONE; bool commandExecuted = false; + bool resetFaultBit = false; dur_millis_t startTime = 0; uint8_t faultByte = 0; std::array commandBuffer { 0 }; diff --git a/mission/devices/devicedefinitions/Max31865Definitions.h b/mission/devices/devicedefinitions/Max31865Definitions.h index 9b2aa3a2..c9c8255e 100644 --- a/mission/devices/devicedefinitions/Max31865Definitions.h +++ b/mission/devices/devicedefinitions/Max31865Definitions.h @@ -17,13 +17,17 @@ enum PoolIds: lp_id_t { static constexpr DeviceCommandId_t CONFIG_CMD = 0x80; static constexpr DeviceCommandId_t WRITE_HIGH_THRESHOLD = 0x83; static constexpr DeviceCommandId_t WRITE_LOW_THRESHOLD = 0x85; + static constexpr DeviceCommandId_t REQUEST_CONFIG = 0x00; static constexpr DeviceCommandId_t REQUEST_RTD = 0x01; static constexpr DeviceCommandId_t REQUEST_HIGH_THRESHOLD = 0x03; static constexpr DeviceCommandId_t REQUEST_LOW_THRESHOLD = 0x05; static constexpr DeviceCommandId_t REQUEST_FAULT_BYTE = 0x07; +static constexpr DeviceCommandId_t CLEAR_FAULT_BYTE = 0x08; + static constexpr uint32_t MAX31865_SET_ID = REQUEST_RTD; +static constexpr uint8_t CLEAR_FAULT_BIT_VAL = 0b0000'0010; static constexpr size_t MAX_REPLY_SIZE = 5; diff --git a/tmtc b/tmtc index f6a3f792..eca5bba1 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit f6a3f792203bc1f00b10c9760b99a8e83ae2535c +Subproject commit eca5bba1d8df6576a19547d356e676b0fb164d87 From 5a0563a7e8ef2a83f74a0cdd5e39b19af7edd8a3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Dec 2021 11:23:20 +0100 Subject: [PATCH 140/465] reverted pst freq --- bsp_q7s/core/InitMission.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index 411fbd8d..81d972b1 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -199,7 +199,7 @@ void initmission::createPstTasks(TaskFactory& factory, /* Polling Sequence Table Default */ #if OBSW_ADD_SPI_TEST_CODE == 0 FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask( - "PST_TASK_DEFAULT", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 2.0, + "PST_TASK_DEFAULT", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 3.0, missedDeadlineFunc); result = pst::pstSpi(spiPst); if (result != HasReturnvaluesIF::RETURN_OK) { From 481756b01430935b7b4ca422e6b9aff98b06fb7f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Dec 2021 11:49:50 +0100 Subject: [PATCH 141/465] fix script, experiment with timing --- cmake/scripts/Q7S/make-release-cfg.sh | 4 ++-- .../pollingsequence/pollingSequenceFactory.cpp | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmake/scripts/Q7S/make-release-cfg.sh b/cmake/scripts/Q7S/make-release-cfg.sh index d71dcc83..233bf263 100755 --- a/cmake/scripts/Q7S/make-release-cfg.sh +++ b/cmake/scripts/Q7S/make-release-cfg.sh @@ -17,7 +17,7 @@ fi os_fsfw="linux" tgt_bsp="arm/q7s" -build_dir="build-Debug-Q7S" +build_dir="build-Release-Q7S" build_generator="make" if [ "${OS}" = "Windows_NT" ]; then python="py" @@ -28,6 +28,6 @@ fi echo "Running command (without the leading +):" set -x # Print command -${python} ${cfg_script_name} -o "${os_fsfw}" -g "${build_generator}" -b "debug" -t "${tgt_bsp}" \ +${python} ${cfg_script_name} -o "${os_fsfw}" -g "${build_generator}" -b "release" -t "${tgt_bsp}" \ -l"${build_dir}" # set +x diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 73a27116..c4ce9c25 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -59,9 +59,9 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.2, DeviceHandlerIF::SEND_WRITE); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC_3, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_4, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_5, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_3, length * 0.15, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_4, length * 0.15, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_5, length * 0.15, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::RTD_IC_6, length * 0.2, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::RTD_IC_7, length * 0.2, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::RTD_IC_8, length * 0.2, DeviceHandlerIF::SEND_WRITE); @@ -439,8 +439,8 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { #endif #if OBSW_ADD_ACS_BOARD == 1 - bool enableAside = false; - bool enableBside = true; + bool enableAside = true; + bool enableBside = false; if(enableAside) { // A side thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0, From 64ab445f4ef9f04914ed4125f9992c45f1f74aee Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Dec 2021 11:55:47 +0100 Subject: [PATCH 142/465] initialize values --- bsp_q7s/core/CoreController.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index d8149ccb..271ec508 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -1094,8 +1094,8 @@ ReturnValue_t CoreController::handleProtInfoUpdateLine(std::string nextLine) { uint8_t wordIdx = 0; uint8_t arrayIdx = 0; istringstream iss(nextLine); - Chip currentChip; - Copy currentCopy; + Chip currentChip = Chip::CHIP_0; + Copy currentCopy = Copy::COPY_0; while(iss >> word) { if(wordIdx == 1) { currentChip = static_cast(stoi(word)); From 50154c944a695f7e2da5dc605eae2417cb566d00 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Dec 2021 13:27:01 +0100 Subject: [PATCH 143/465] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 54e56ec5..e428568a 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 54e56ec522f485525de7b17458b22132003c5047 +Subproject commit e428568a00494c3e3ceb6d0b314baae97d4d8731 From 4dee8658fd0f6131cb58e712ebcf71c18bbb0cda Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Wed, 15 Dec 2021 19:32:43 +0100 Subject: [PATCH 144/465] histogram and contrast telemetry set --- .../devices/startracker/ArcsecDatalinkLayer.h | 2 +- .../startracker/StarTrackerDefinitions.h | 354 ++++++++++++++++-- .../startracker/StarTrackerHandler.cpp | 147 +++++++- .../devices/startracker/StarTrackerHandler.h | 23 ++ fsfw | 2 +- 5 files changed, 482 insertions(+), 46 deletions(-) diff --git a/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.h b/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.h index eb5beecc..84b04426 100644 --- a/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.h +++ b/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.h @@ -51,7 +51,7 @@ public: uint8_t getReplyFrameType(); /** - * @brief Returns pointer to reply packet. + * @brief Returns pointer to reply packet (first entry normally action ID, telemetry ID etc.) */ const uint8_t* getReply(); diff --git a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h index 8c87dcfc..4ff30ec0 100644 --- a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h +++ b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h @@ -81,7 +81,85 @@ enum PoolIds: lp_id_t { LISA_NR_CLOSE, TRUST_WORTHY, STABLE_COUNT, - SOLUTION_STRATEGY + SOLUTION_STRATEGY, + + TICKS_HISTOGRAM_SET, + TIME_HISTOGRAM_SET, + HISTOGRAM_BINA0, + HISTOGRAM_BINA1, + HISTOGRAM_BINA2, + HISTOGRAM_BINA3, + HISTOGRAM_BINA4, + HISTOGRAM_BINA5, + HISTOGRAM_BINA6, + HISTOGRAM_BINA7, + HISTOGRAM_BINA8, + HISTOGRAM_BINB0, + HISTOGRAM_BINB1, + HISTOGRAM_BINB2, + HISTOGRAM_BINB3, + HISTOGRAM_BINB4, + HISTOGRAM_BINB5, + HISTOGRAM_BINB6, + HISTOGRAM_BINB7, + HISTOGRAM_BINB8, + HISTOGRAM_BINC0, + HISTOGRAM_BINC1, + HISTOGRAM_BINC2, + HISTOGRAM_BINC3, + HISTOGRAM_BINC4, + HISTOGRAM_BINC5, + HISTOGRAM_BINC6, + HISTOGRAM_BINC7, + HISTOGRAM_BINC8, + HISTOGRAM_BIND0, + HISTOGRAM_BIND1, + HISTOGRAM_BIND2, + HISTOGRAM_BIND3, + HISTOGRAM_BIND4, + HISTOGRAM_BIND5, + HISTOGRAM_BIND6, + HISTOGRAM_BIND7, + HISTOGRAM_BIND8, + + TICKS_CONTRAST_SET, + TIME_CONTRAST_SET, + CONTRAST_BINA0, + CONTRAST_BINA1, + CONTRAST_BINA2, + CONTRAST_BINA3, + CONTRAST_BINA4, + CONTRAST_BINA5, + CONTRAST_BINA6, + CONTRAST_BINA7, + CONTRAST_BINA8, + CONTRAST_BINB0, + CONTRAST_BINB1, + CONTRAST_BINB2, + CONTRAST_BINB3, + CONTRAST_BINB4, + CONTRAST_BINB5, + CONTRAST_BINB6, + CONTRAST_BINB7, + CONTRAST_BINB8, + CONTRAST_BINC0, + CONTRAST_BINC1, + CONTRAST_BINC2, + CONTRAST_BINC3, + CONTRAST_BINC4, + CONTRAST_BINC5, + CONTRAST_BINC6, + CONTRAST_BINC7, + CONTRAST_BINC8, + CONTRAST_BIND0, + CONTRAST_BIND1, + CONTRAST_BIND2, + CONTRAST_BIND3, + CONTRAST_BIND4, + CONTRAST_BIND5, + CONTRAST_BIND6, + CONTRAST_BIND7, + CONTRAST_BIND8 }; static const DeviceCommandId_t PING_REQUEST = 0; @@ -102,6 +180,8 @@ static const DeviceCommandId_t UPLOAD_CENTROID = 17; static const DeviceCommandId_t SUBSCRIBE_TO_TM = 18; static const DeviceCommandId_t REQ_SOLUTION = 24; static const DeviceCommandId_t REQ_TEMPERATURE = 25; +static const DeviceCommandId_t REQ_HISTOGRAM = 28; +static const DeviceCommandId_t REQ_CONTRAST = 29; static const DeviceCommandId_t LIMITS = 40; static const DeviceCommandId_t MOUNTING = 41; static const DeviceCommandId_t CAMERA = 42; @@ -129,6 +209,8 @@ static const uint32_t POWER_SET_ID = REQ_POWER; static const uint32_t TEMPERATURE_SET_ID = REQ_TEMPERATURE; static const uint32_t TIME_SET_ID = REQ_TIME; static const uint32_t SOLUTION_SET_ID = REQ_SOLUTION; +static const uint32_t HISTOGRAM_SET_ID = REQ_HISTOGRAM; +static const uint32_t CONTRAST_SET_ID = REQ_CONTRAST; /** Max size of unencoded frame */ static const size_t MAX_FRAME_SIZE = 1200; @@ -139,6 +221,8 @@ static const uint8_t INTERFACE_SET_ENTRIES = 4; static const uint8_t POWER_SET_ENTRIES = 18; static const uint8_t TIME_SET_ENTRIES = 4; static const uint8_t SOLUTION_SET_ENTRIES = 23; +static const uint8_t HISTOGRAM_SET_ENTRIES = 38; +static const uint8_t CONTRAST_SET_ENTRIES = 38; // Action, parameter and telemetry IDs namespace ID { @@ -162,6 +246,8 @@ namespace ID { static const uint8_t SUBSCRIBE = 18; static const uint8_t SOLUTION = 24; static const uint8_t TEMPERATURE = 25; + static const uint8_t HISTOGRAM = 28; + static const uint8_t CONTRAST = 29; static const uint8_t TIME = 1; static const uint8_t WRITE = 2; static const uint8_t READ = 3; @@ -455,60 +541,44 @@ public: PoolIds::TIME_SOLUTION_SET, this); // Calibrated quaternion (takes into account the mounting quaternion), typically same as // track q values - lp_var_t caliQw = lp_var_t(sid.objectId, - PoolIds::CALI_QW, this); - lp_var_t caliQx = lp_var_t(sid.objectId, - PoolIds::CALI_QX, this); - lp_var_t caliQy = lp_var_t(sid.objectId, - PoolIds::CALI_QY, this); - lp_var_t caliQz = lp_var_t(sid.objectId, - PoolIds::CALI_QZ, this); + lp_var_t caliQw = lp_var_t(sid.objectId, PoolIds::CALI_QW, this); + lp_var_t caliQx = lp_var_t(sid.objectId, PoolIds::CALI_QX, this); + lp_var_t caliQy = lp_var_t(sid.objectId, PoolIds::CALI_QY, this); + lp_var_t caliQz = lp_var_t(sid.objectId, PoolIds::CALI_QZ, this); // The lower this value the more confidence that the star tracker solution is correct - lp_var_t trackConfidence = lp_var_t(sid.objectId, - PoolIds::TRACK_CONFIDENCE, this); + lp_var_t trackConfidence = lp_var_t(sid.objectId, PoolIds::TRACK_CONFIDENCE, + this); // Estimated attitude of spacecraft - lp_var_t trackQw = lp_var_t(sid.objectId, - PoolIds::TRACK_QW, this); - lp_var_t trackQx = lp_var_t(sid.objectId, - PoolIds::TRACK_QX, this); - lp_var_t trackQy = lp_var_t(sid.objectId, - PoolIds::TRACK_QY, this); - lp_var_t trackQz = lp_var_t(sid.objectId, - PoolIds::TRACK_QZ, this); + lp_var_t trackQw = lp_var_t(sid.objectId, PoolIds::TRACK_QW, this); + lp_var_t trackQx = lp_var_t(sid.objectId, PoolIds::TRACK_QX, this); + lp_var_t trackQy = lp_var_t(sid.objectId, PoolIds::TRACK_QY, this); + lp_var_t trackQz = lp_var_t(sid.objectId, PoolIds::TRACK_QZ, this); // Number of stars removed from tracking solution - lp_var_t trackRemoved = lp_var_t(sid.objectId, - PoolIds::TRACK_REMOVED, this); + lp_var_t trackRemoved = lp_var_t(sid.objectId, PoolIds::TRACK_REMOVED, this); // Number of stars for which a valid centroid was found - lp_var_t starsCentroided = lp_var_t(sid.objectId, - PoolIds::STARS_CENTROIDED, this); + lp_var_t starsCentroided = lp_var_t(sid.objectId, PoolIds::STARS_CENTROIDED, + this); // Number of stars that matched to a database star lp_var_t starsMatchedDatabase = lp_var_t(sid.objectId, PoolIds::STARS_MATCHED_DATABASE, this); // Result of LISA (lost in space algorithm), searches for stars without prior knowledge of // attitude - lp_var_t lisaQw = lp_var_t(sid.objectId, - PoolIds::LISA_QW, this); - lp_var_t lisaQx = lp_var_t(sid.objectId, - PoolIds::LISA_QX, this); - lp_var_t lisaQy = lp_var_t(sid.objectId, - PoolIds::LISA_QY, this); - lp_var_t lisaQz = lp_var_t(sid.objectId, - PoolIds::LISA_QZ, this); + lp_var_t lisaQw = lp_var_t(sid.objectId, PoolIds::LISA_QW, this); + lp_var_t lisaQx = lp_var_t(sid.objectId, PoolIds::LISA_QX, this); + lp_var_t lisaQy = lp_var_t(sid.objectId, PoolIds::LISA_QY, this); + lp_var_t lisaQz = lp_var_t(sid.objectId, PoolIds::LISA_QZ, this); // Percentage of close stars in LISA solution - lp_var_t lisaPercentageClose = lp_var_t(sid.objectId, - PoolIds::LISA_PERC_CLOSE, this); + lp_var_t lisaPercentageClose = lp_var_t(sid.objectId, PoolIds::LISA_PERC_CLOSE, + this); // Number of close stars in LISA solution - lp_var_t lisaNrClose = lp_var_t(sid.objectId, - PoolIds::LISA_NR_CLOSE, this); + lp_var_t lisaNrClose = lp_var_t(sid.objectId, PoolIds::LISA_NR_CLOSE, this); // Gives a combined overview of the validation parameters (1 for valid solution, otherwise 0) - lp_var_t isTrustWorthy = lp_var_t(sid.objectId, - PoolIds::TRUST_WORTHY, this); + lp_var_t isTrustWorthy = lp_var_t(sid.objectId, PoolIds::TRUST_WORTHY, this); // Number of times the validation criteria was met - lp_var_t stableCount = lp_var_t(sid.objectId, - PoolIds::STABLE_COUNT, this); + lp_var_t stableCount = lp_var_t(sid.objectId, PoolIds::STABLE_COUNT, this); // Shows the autonomous mode used to obtain the star tracker attitude - lp_var_t solutionStrategy = lp_var_t(sid.objectId, - PoolIds::SOLUTION_STRATEGY, this); + lp_var_t solutionStrategy = lp_var_t(sid.objectId, PoolIds::SOLUTION_STRATEGY, + this); void printSet() { PoolReadGuard rg(this); @@ -561,6 +631,208 @@ public: } }; +/** + * @brief Dataset to store the histogram + */ +class HistogramSet: + public StaticLocalDataSet { +public: + + // Size of dataset + static const size_t SIZE = 154; + + HistogramSet(HasLocalDataPoolIF* owner): + StaticLocalDataSet(owner, HISTOGRAM_SET_ID) { + } + + HistogramSet(object_id_t objectId): + StaticLocalDataSet(sid_t(objectId, HISTOGRAM_SET_ID)) { + } + + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_HISTOGRAM_SET, this); + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_HISTOGRAM_SET, this); + lp_var_t binA0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA0, this); + lp_var_t binA1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA1, this); + lp_var_t binA2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA2, this); + lp_var_t binA3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA3, this); + lp_var_t binA4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA4, this); + lp_var_t binA5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA5, this); + lp_var_t binA6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA6, this); + lp_var_t binA7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA7, this); + lp_var_t binA8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA8, this); + lp_var_t binb0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB0, this); + lp_var_t binB1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB1, this); + lp_var_t binB2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB2, this); + lp_var_t binB3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB3, this); + lp_var_t binB4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB4, this); + lp_var_t binB5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB5, this); + lp_var_t binB6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB6, this); + lp_var_t binB7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB7, this); + lp_var_t binB8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB8, this); + lp_var_t binC0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC0, this); + lp_var_t binC1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC1, this); + lp_var_t binC2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC2, this); + lp_var_t binC3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC3, this); + lp_var_t binC4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC4, this); + lp_var_t binC5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC5, this); + lp_var_t binC6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC6, this); + lp_var_t binC7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC7, this); + lp_var_t binC8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC8, this); + lp_var_t binD0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND0, this); + lp_var_t binD1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND1, this); + lp_var_t binD2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND2, this); + lp_var_t binD3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND3, this); + lp_var_t binD4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND4, this); + lp_var_t binD5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND5, this); + lp_var_t binD6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND6, this); + lp_var_t binD7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND7, this); + lp_var_t binD8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND8, this); + + void printSet() { + PoolReadGuard rg(this); + sif::info << "HistogramSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "HistogramSet::printSet: Time (time stamp): " << this->time << " us" + << std::endl; + sif::info << "HistogramSet::printSet: BinA0: " << this->binA0 << std::endl; + sif::info << "HistogramSet::printSet: BinA1: " << this->binA1 << std::endl; + sif::info << "HistogramSet::printSet: BinA2: " << this->binA2 << std::endl; + sif::info << "HistogramSet::printSet: BinA3: " << this->binA3 << std::endl; + sif::info << "HistogramSet::printSet: BinA4: " << this->binA4 << std::endl; + sif::info << "HistogramSet::printSet: BinA5: " << this->binA5 << std::endl; + sif::info << "HistogramSet::printSet: BinA6: " << this->binA6 << std::endl; + sif::info << "HistogramSet::printSet: BinA7: " << this->binA7 << std::endl; + sif::info << "HistogramSet::printSet: BinA8: " << this->binA8 << std::endl; + sif::info << "HistogramSet::printSet: BinB0: " << this->binA0 << std::endl; + sif::info << "HistogramSet::printSet: BinB1: " << this->binB1 << std::endl; + sif::info << "HistogramSet::printSet: BinB2: " << this->binB2 << std::endl; + sif::info << "HistogramSet::printSet: BinB3: " << this->binB3 << std::endl; + sif::info << "HistogramSet::printSet: BinB4: " << this->binB4 << std::endl; + sif::info << "HistogramSet::printSet: BinB5: " << this->binB5 << std::endl; + sif::info << "HistogramSet::printSet: BinB6: " << this->binB6 << std::endl; + sif::info << "HistogramSet::printSet: BinB7: " << this->binB7 << std::endl; + sif::info << "HistogramSet::printSet: BinB8: " << this->binB8 << std::endl; + sif::info << "HistogramSet::printSet: BinC0: " << this->binC0 << std::endl; + sif::info << "HistogramSet::printSet: BinC1: " << this->binC1 << std::endl; + sif::info << "HistogramSet::printSet: BinC2: " << this->binC2 << std::endl; + sif::info << "HistogramSet::printSet: BinC3: " << this->binC3 << std::endl; + sif::info << "HistogramSet::printSet: BinC4: " << this->binC4 << std::endl; + sif::info << "HistogramSet::printSet: BinC5: " << this->binC5 << std::endl; + sif::info << "HistogramSet::printSet: BinC6: " << this->binC6 << std::endl; + sif::info << "HistogramSet::printSet: BinC7: " << this->binC7 << std::endl; + sif::info << "HistogramSet::printSet: BinC8: " << this->binC8 << std::endl; + sif::info << "HistogramSet::printSet: BinD0: " << this->binD0 << std::endl; + sif::info << "HistogramSet::printSet: BinD1: " << this->binD1 << std::endl; + sif::info << "HistogramSet::printSet: BinD2: " << this->binD2 << std::endl; + sif::info << "HistogramSet::printSet: BinD3: " << this->binD3 << std::endl; + sif::info << "HistogramSet::printSet: BinD4: " << this->binD4 << std::endl; + sif::info << "HistogramSet::printSet: BinD5: " << this->binD5 << std::endl; + sif::info << "HistogramSet::printSet: BinD6: " << this->binD6 << std::endl; + sif::info << "HistogramSet::printSet: BinD7: " << this->binD7 << std::endl; + sif::info << "HistogramSet::printSet: BinD8: " << this->binD8 << std::endl; + } +}; + +/** + * @brief Dataset to store the contrast telemetry data + */ +class ContrastSet: + public StaticLocalDataSet { +public: + + // Size of dataset + static const size_t SIZE = 154; + + ContrastSet(HasLocalDataPoolIF* owner): + StaticLocalDataSet(owner, CONTRAST_SET_ID) { + } + + ContrastSet(object_id_t objectId): + StaticLocalDataSet(sid_t(objectId, CONTRAST_SET_ID)) { + } + + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_CONTRAST_SET, this); + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_CONTRAST_SET, this); + lp_var_t binA0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA0, this); + lp_var_t binA1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA1, this); + lp_var_t binA2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA2, this); + lp_var_t binA3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA3, this); + lp_var_t binA4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA4, this); + lp_var_t binA5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA5, this); + lp_var_t binA6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA6, this); + lp_var_t binA7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA7, this); + lp_var_t binA8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA8, this); + lp_var_t binb0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB0, this); + lp_var_t binB1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB1, this); + lp_var_t binB2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB2, this); + lp_var_t binB3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB3, this); + lp_var_t binB4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB4, this); + lp_var_t binB5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB5, this); + lp_var_t binB6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB6, this); + lp_var_t binB7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB7, this); + lp_var_t binB8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB8, this); + lp_var_t binC0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC0, this); + lp_var_t binC1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC1, this); + lp_var_t binC2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC2, this); + lp_var_t binC3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC3, this); + lp_var_t binC4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC4, this); + lp_var_t binC5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC5, this); + lp_var_t binC6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC6, this); + lp_var_t binC7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC7, this); + lp_var_t binC8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC8, this); + lp_var_t binD0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND0, this); + lp_var_t binD1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND1, this); + lp_var_t binD2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND2, this); + lp_var_t binD3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND3, this); + lp_var_t binD4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND4, this); + lp_var_t binD5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND5, this); + lp_var_t binD6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND6, this); + lp_var_t binD7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND7, this); + lp_var_t binD8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND8, this); + + void printSet() { + PoolReadGuard rg(this); + sif::info << "ContrastSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "ContrastSet::printSet: Time (time stamp): " << this->time << " us" + << std::endl; + sif::info << "ContrastSet::printSet: BinA0: " << this->binA0 << std::endl; + sif::info << "ContrastSet::printSet: BinA1: " << this->binA1 << std::endl; + sif::info << "ContrastSet::printSet: BinA2: " << this->binA2 << std::endl; + sif::info << "ContrastSet::printSet: BinA3: " << this->binA3 << std::endl; + sif::info << "ContrastSet::printSet: BinA4: " << this->binA4 << std::endl; + sif::info << "ContrastSet::printSet: BinA5: " << this->binA5 << std::endl; + sif::info << "ContrastSet::printSet: BinA6: " << this->binA6 << std::endl; + sif::info << "ContrastSet::printSet: BinA7: " << this->binA7 << std::endl; + sif::info << "ContrastSet::printSet: BinA8: " << this->binA8 << std::endl; + sif::info << "ContrastSet::printSet: BinB0: " << this->binA0 << std::endl; + sif::info << "ContrastSet::printSet: BinB1: " << this->binB1 << std::endl; + sif::info << "ContrastSet::printSet: BinB2: " << this->binB2 << std::endl; + sif::info << "ContrastSet::printSet: BinB3: " << this->binB3 << std::endl; + sif::info << "ContrastSet::printSet: BinB4: " << this->binB4 << std::endl; + sif::info << "ContrastSet::printSet: BinB5: " << this->binB5 << std::endl; + sif::info << "ContrastSet::printSet: BinB6: " << this->binB6 << std::endl; + sif::info << "ContrastSet::printSet: BinB7: " << this->binB7 << std::endl; + sif::info << "ContrastSet::printSet: BinB8: " << this->binB8 << std::endl; + sif::info << "ContrastSet::printSet: BinC0: " << this->binC0 << std::endl; + sif::info << "ContrastSet::printSet: BinC1: " << this->binC1 << std::endl; + sif::info << "ContrastSet::printSet: BinC2: " << this->binC2 << std::endl; + sif::info << "ContrastSet::printSet: BinC3: " << this->binC3 << std::endl; + sif::info << "ContrastSet::printSet: BinC4: " << this->binC4 << std::endl; + sif::info << "ContrastSet::printSet: BinC5: " << this->binC5 << std::endl; + sif::info << "ContrastSet::printSet: BinC6: " << this->binC6 << std::endl; + sif::info << "ContrastSet::printSet: BinC7: " << this->binC7 << std::endl; + sif::info << "ContrastSet::printSet: BinC8: " << this->binC8 << std::endl; + sif::info << "ContrastSet::printSet: BinD0: " << this->binD0 << std::endl; + sif::info << "ContrastSet::printSet: BinD1: " << this->binD1 << std::endl; + sif::info << "ContrastSet::printSet: BinD2: " << this->binD2 << std::endl; + sif::info << "ContrastSet::printSet: BinD3: " << this->binD3 << std::endl; + sif::info << "ContrastSet::printSet: BinD4: " << this->binD4 << std::endl; + sif::info << "ContrastSet::printSet: BinD5: " << this->binD5 << std::endl; + sif::info << "ContrastSet::printSet: BinD6: " << this->binD6 << std::endl; + sif::info << "ContrastSet::printSet: BinD7: " << this->binD7 << std::endl; + sif::info << "ContrastSet::printSet: BinD8: " << this->binD8 << std::endl; + } +}; + } #endif /* MISSION_STARTRACKER_DEFINITIONS_H_ */ diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp index f957f9fc..f1e029dc 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp @@ -16,8 +16,8 @@ extern "C" { StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie, StrImageLoader* strImageLoader) : DeviceHandlerBase(objectId, comIF, comCookie), temperatureSet(this), versionSet(this), powerSet( - this), interfaceSet(this), timeSet(this), solutionSet(this), strImageLoader( - strImageLoader) { + this), interfaceSet(this), timeSet(this), solutionSet(this), histogramSet(this), + contrastSet(this), strImageLoader(strImageLoader) { if (comCookie == nullptr) { sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl; } @@ -310,6 +310,14 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi prepareTemperatureRequest(); return RETURN_OK; } + case (StarTracker::REQ_HISTOGRAM): { + prepareHistogramRequest(); + return RETURN_OK; + } + case (StarTracker::REQ_CONTRAST): { + prepareContrastRequest(); + return RETURN_OK; + } case (StarTracker::RESET_ERROR): { prepareErrorResetRequest(); return RETURN_OK; @@ -394,6 +402,10 @@ void StarTrackerHandler::fillCommandAndReplyMap() { StarTracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(StarTracker::REQ_TEMPERATURE, 3, &temperatureSet, StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_HISTOGRAM, 3, &histogramSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_CONTRAST, 3, &contrastSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(StarTracker::LIMITS, 3, nullptr, StarTracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(StarTracker::MOUNTING, 3, nullptr, @@ -525,6 +537,14 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con handleTemperatureTm(); break; } + case (StarTracker::REQ_HISTOGRAM): { + handleHistogramTm(); + break; + } + case (StarTracker::REQ_CONTRAST): { + handleContrastTm(); + break; + } case (StarTracker::LIMITS): case (StarTracker::MOUNTING): case (StarTracker::CAMERA): @@ -554,7 +574,7 @@ void StarTrackerHandler::setNormalDatapoolEntriesInvalid() { } uint32_t StarTrackerHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { - return 5000; + return 20000; } ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, @@ -632,6 +652,45 @@ ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& l localDataPoolMap.emplace(StarTracker::STABLE_COUNT, new PoolEntry( { 0 })); localDataPoolMap.emplace(StarTracker::SOLUTION_STRATEGY, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_HISTOGRAM_SET, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TIME_HISTOGRAM_SET, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA0, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA1, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA4, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA5, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA6, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB0, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB1, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB4, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB5, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB6, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC0, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC1, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC4, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC5, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC6, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND0, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND1, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND4, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND5, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND6, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND8, new PoolEntry( { 0 })); + return RETURN_OK; } @@ -764,6 +823,14 @@ ReturnValue_t StarTrackerHandler::scanForTmReply(DeviceCommandId_t *foundId) { *foundId = StarTracker::REQ_TEMPERATURE; break; } + case (StarTracker::ID::HISTOGRAM): { + *foundId = StarTracker::REQ_HISTOGRAM; + break; + } + case (StarTracker::ID::CONTRAST): { + *foundId = StarTracker::REQ_CONTRAST; + break; + } case (StarTracker::ID::TIME): { *foundId = StarTracker::REQ_TIME; break; @@ -909,6 +976,22 @@ void StarTrackerHandler::prepareTemperatureRequest() { rawPacketLen = dataLinkLayer.getEncodedLength(); } +void StarTrackerHandler::prepareHistogramRequest() { + uint32_t length = 0; + arc_tm_pack_histogram_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); +} + +void StarTrackerHandler::prepareContrastRequest() { + uint32_t length = 0; + arc_tm_pack_contrast_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); +} + void StarTrackerHandler::prepareErrorResetRequest() { uint32_t length = 0; struct ResetErrorSignalActionRequest req; @@ -1319,6 +1402,64 @@ ReturnValue_t StarTrackerHandler::handleTemperatureTm() { return result; } +ReturnValue_t StarTrackerHandler::handleHistogramTm() { + ReturnValue_t result = RETURN_OK; + uint8_t status = 0; + uint32_t ticks = 0; + uint64_t time = 0; + getTmHeaderData(&status, &ticks, &time); + if(status != StarTracker::STATUS_OK) { + sif::warning << "StarTrackerHandler::handleHistogramTm: Reply error: " + << static_cast(status) << std::endl; + result = HISTOGRAM_REQ_FAILED; + return result; + } + result = histogramSet.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { + return result; + } + const uint8_t* reply = dataLinkLayer.getReply() + TM_DATA_FIELD_OFFSET; + size_t size = StarTracker::HistogramSet::SIZE; + result = histogramSet.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::handleHistogramTm: Deserialization failed" + << std::endl; + } +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 + histogramSet.printSet(); +#endif + return result; +} + +ReturnValue_t StarTrackerHandler::handleContrastTm() { + ReturnValue_t result = RETURN_OK; + uint8_t status = 0; + uint32_t ticks = 0; + uint64_t time = 0; + getTmHeaderData(&status, &ticks, &time); + if(status != StarTracker::STATUS_OK) { + sif::warning << "StarTrackerHandler::handleContrastTm: Reply error: " + << static_cast(status) << std::endl; + result = CONTRAST_REQ_FAILED; + return result; + } + result = contrastSet.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { + return result; + } + const uint8_t* reply = dataLinkLayer.getReply() + TM_DATA_FIELD_OFFSET; + size_t size = StarTracker::ContrastSet::SIZE; + result = contrastSet.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::handleContrastTm: Deserialization failed" + << std::endl; + } +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 + contrastSet.printSet(); +#endif + return result; +} + void StarTrackerHandler::getTmHeaderData(uint8_t* status, uint32_t* ticks, uint64_t* time) { const uint8_t* reply = dataLinkLayer.getReply(); *status = *(reply + STATUS_OFFSET); diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.h b/bsp_q7s/devices/startracker/StarTrackerHandler.h index e22ff739..0fcf14d0 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.h +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.h @@ -111,6 +111,10 @@ private: static const ReturnValue_t FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xAC); //! [EXPORT] : [COMMENT] Received version reply with invalid program ID static const ReturnValue_t INVALID_PROGRAM = MAKE_RETURN_CODE(0xAD); + //! [EXPORT] : [COMMENT] Status field of histogram reply signals error + static const ReturnValue_t HISTOGRAM_REQ_FAILED = MAKE_RETURN_CODE(0xAE); + //! [EXPORT] : [COMMENT] Status field of contrast reply signals error + static const ReturnValue_t CONTRAST_REQ_FAILED = MAKE_RETURN_CODE(0xAE); static const size_t MAX_PATH_SIZE = 50; static const size_t MAX_FILE_NAME = 30; @@ -143,6 +147,8 @@ private: StarTracker::InterfaceSet interfaceSet; StarTracker::TimeSet timeSet; StarTracker::SolutionSet solutionSet; + StarTracker::HistogramSet histogramSet; + StarTracker::ContrastSet contrastSet; // Pointer to object responsible for uploading and downloading images to/from the star tracker StrImageLoader* strImageLoader = nullptr; @@ -268,6 +274,13 @@ private: */ void prepareTemperatureRequest(); + /** + * @brief Fills command buffer with data to request histogram + */ + void prepareHistogramRequest(); + + void prepareContrastRequest(); + /** * @brief Fills command buffer with command to reset the error signal of the star tracker */ @@ -313,6 +326,16 @@ private: */ ReturnValue_t handleTemperatureTm(); + /** + * @brief Checks histogram reply and deserializes data into histogram dataset + */ + ReturnValue_t handleHistogramTm(); + + /** + * @brief Checks contrast reply and deserializes data into contrast dataset + */ + ReturnValue_t handleContrastTm(); + /** * @brief This function handles the telemetry reply of a version request. */ diff --git a/fsfw b/fsfw index ceb87b5a..9a858eb5 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit ceb87b5abb2992a18266328e0ea34d9af15db7af +Subproject commit 9a858eb54c5603ccd3cbd2423cdaf87b20f0c0c4 From 6346da658a00080f6e0d9f36a8247d5a72d1b8d2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 16 Dec 2021 19:48:08 +0100 Subject: [PATCH 145/465] update submodules --- fsfw | 2 +- tmtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsfw b/fsfw index e428568a..a45fb1bb 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit e428568a00494c3e3ceb6d0b314baae97d4d8731 +Subproject commit a45fb1bb1ff839c487581e1b787db966a1cf80cb diff --git a/tmtc b/tmtc index eca5bba1..8cfc2892 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit eca5bba1d8df6576a19547d356e676b0fb164d87 +Subproject commit 8cfc2892dd95f959edb4b0ec1bbc8fc4aaa69ef2 From 2ed0bdf1323dae2d4320f50fcb84b6392b5f3867 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Fri, 17 Dec 2021 10:45:55 +0100 Subject: [PATCH 146/465] acu print stats --- .../startracker/StarTrackerDefinitions.h | 2 +- .../startracker/StarTrackerHandler.cpp | 7 +++- mission/devices/ACUHandler.cpp | 41 +++++++++++++++++++ mission/devices/ACUHandler.h | 10 +++++ mission/devices/GomspaceDeviceHandler.cpp | 6 ++- mission/devices/GomspaceDeviceHandler.h | 5 +++ .../devicedefinitions/GomspaceDefinitions.h | 5 ++- 7 files changed, 71 insertions(+), 5 deletions(-) diff --git a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h index 4ff30ec0..18fe38d7 100644 --- a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h +++ b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h @@ -639,7 +639,7 @@ class HistogramSet: public: // Size of dataset - static const size_t SIZE = 154; + static const size_t SIZE = 156; HistogramSet(HasLocalDataPoolIF* owner): StaticLocalDataSet(owner, HISTOGRAM_SET_ID) { diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp index f1e029dc..16960f76 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp @@ -1411,8 +1411,7 @@ ReturnValue_t StarTrackerHandler::handleHistogramTm() { if(status != StarTracker::STATUS_OK) { sif::warning << "StarTrackerHandler::handleHistogramTm: Reply error: " << static_cast(status) << std::endl; - result = HISTOGRAM_REQ_FAILED; - return result; + return HISTOGRAM_REQ_FAILED; } result = histogramSet.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); if (result != RETURN_OK) { @@ -1425,6 +1424,10 @@ ReturnValue_t StarTrackerHandler::handleHistogramTm() { sif::warning << "StarTrackerHandler::handleHistogramTm: Deserialization failed" << std::endl; } + result = histogramSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { + return result; + } #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 histogramSet.printSet(); #endif diff --git a/mission/devices/ACUHandler.cpp b/mission/devices/ACUHandler.cpp index 24bd52fe..a52e48ff 100644 --- a/mission/devices/ACUHandler.cpp +++ b/mission/devices/ACUHandler.cpp @@ -266,3 +266,44 @@ ReturnValue_t ACUHandler::initializeLocalDataPool( return HasReturnvaluesIF::RETURN_OK; } + +ReturnValue_t ACUHandler::deviceSpecificCommand(DeviceCommandId_t cmd) { + switch(cmd) { + case PRINT_CHANNEL_STATS: { + printChannelStats(); + return RETURN_OK; + } + default: { + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + } +} + +void ACUHandler::printChannelStats() { + PoolReadGuard pg(&acuHkTableDataset); + sif::info << "ACU Info: Stats, Current [mA], Voltage [mV]" << std::endl; + sif::info << std::setw(30) << std::left << "Ch0" << std::dec << "| " << + static_cast(acuHkTableDataset.currentInChannel0.value) << ", " << + std::setw(4) << std::right << acuHkTableDataset.voltageInChannel0.value << ", " + << std::setw(4) << std::endl; + sif::info << std::setw(30) << std::left << "Ch1" << std::dec << "| " << + static_cast(acuHkTableDataset.currentInChannel1.value) << ", " << + std::setw(4) << std::right << acuHkTableDataset.voltageInChannel1.value << ", " + << std::setw(4) << std::endl; + sif::info << std::setw(30) << std::left << "Ch2" << std::dec << "| " << + static_cast(acuHkTableDataset.currentInChannel2.value) << ", " << + std::setw(4) << std::right << acuHkTableDataset.voltageInChannel2.value << ", " + << std::setw(4) << std::endl; + sif::info << std::setw(30) << std::left << "Ch3" << std::dec << "| " << + static_cast(acuHkTableDataset.currentInChannel3.value) << ", " << + std::setw(4) << std::right << acuHkTableDataset.voltageInChannel3.value << ", " + << std::setw(4) << std::endl; + sif::info << std::setw(30) << std::left << "Ch4" << std::dec << "| " << + static_cast(acuHkTableDataset.currentInChannel4.value) << ", " << + std::setw(4) << std::right << acuHkTableDataset.voltageInChannel4.value << ", " + << std::setw(4) << std::endl; + sif::info << std::setw(30) << std::left << "Ch5" << std::dec << "| " << + static_cast(acuHkTableDataset.currentInChannel5.value) << ", " << + std::setw(4) << std::right << acuHkTableDataset.voltageInChannel5.value << ", " + << std::setw(4) << std::endl; +} diff --git a/mission/devices/ACUHandler.h b/mission/devices/ACUHandler.h index 8ab32a24..886faba7 100644 --- a/mission/devices/ACUHandler.h +++ b/mission/devices/ACUHandler.h @@ -3,6 +3,7 @@ #include "GomspaceDeviceHandler.h" #include +#include "fsfw/datapool/PoolReadGuard.h" /** * @brief Handler for the ACU from Gomspace. Monitors and controls the battery charging via @@ -25,8 +26,12 @@ protected: */ virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; + virtual ReturnValue_t deviceSpecificCommand(DeviceCommandId_t cmd) override; + private: + static const DeviceCommandId_t PRINT_CHANNEL_STATS = 51; + ACU::HkTableDataset acuHkTableDataset; /** @@ -34,6 +39,11 @@ private: * the values in the acuHkTableDataset. */ void parseHkTableReply(const uint8_t *packet); + + /** + * @brief Prints channel statistics (current and voltage) to console + */ + void printChannelStats(); }; #endif /* MISSION_DEVICES_ACUHANDLER_H_ */ diff --git a/mission/devices/GomspaceDeviceHandler.cpp b/mission/devices/GomspaceDeviceHandler.cpp index e5912969..95e35a5e 100644 --- a/mission/devices/GomspaceDeviceHandler.cpp +++ b/mission/devices/GomspaceDeviceHandler.cpp @@ -87,7 +87,7 @@ ReturnValue_t GomspaceDeviceHandler::buildCommandFromCommand( break; } default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + return deviceSpecificCommand(deviceCommand); } return HasReturnvaluesIF::RETURN_OK; } @@ -398,6 +398,10 @@ LocalPoolDataSetBase* GomspaceDeviceHandler::getDataSetHandle(sid_t sid) { } } +ReturnValue_t GomspaceDeviceHandler::deviceSpecificCommand(DeviceCommandId_t cmd) { + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; +} + void GomspaceDeviceHandler::setModeNormal() { mode = MODE_NORMAL; } diff --git a/mission/devices/GomspaceDeviceHandler.h b/mission/devices/GomspaceDeviceHandler.h index 78257b83..bb11ba0e 100644 --- a/mission/devices/GomspaceDeviceHandler.h +++ b/mission/devices/GomspaceDeviceHandler.h @@ -105,6 +105,11 @@ protected: virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + /** + * @brief Can be used by gomspace devices to implement device specific commands. + */ + virtual ReturnValue_t deviceSpecificCommand(DeviceCommandId_t cmd); + private: /** diff --git a/mission/devices/devicedefinitions/GomspaceDefinitions.h b/mission/devices/devicedefinitions/GomspaceDefinitions.h index bd509239..0fbbc5b0 100644 --- a/mission/devices/devicedefinitions/GomspaceDefinitions.h +++ b/mission/devices/devicedefinitions/GomspaceDefinitions.h @@ -25,7 +25,10 @@ static const uint8_t REBOOT_PORT = 4; static const uint8_t PARAM_PORT = 7; static const uint8_t P60_PORT_GNDWDT_RESET = 9; -/* Device commands are derived from the rparam.h of the gomspace lib */ +/** + * Device commands are derived from the rparam.h of the gomspace lib.. + * IDs above 50 are reserved for device specific commands. + */ static const DeviceCommandId_t PING = 1; //!< [EXPORT] : [COMMAND] static const DeviceCommandId_t NONE = 2; // Set when no command is pending static const DeviceCommandId_t REBOOT = 4; //!< [EXPORT] : [COMMAND] From e442a8c968efb6d09fc759ef577618e2eeb4c11b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 17 Dec 2021 14:20:22 +0100 Subject: [PATCH 147/465] ACS and TCS board working together now --- bsp_q7s/boardconfig/busConf.h | 4 +- bsp_q7s/core/InitMission.cpp | 2 +- bsp_q7s/core/ObjectFactory.cpp | 37 +++++++------- common/config/devConf.h | 6 +-- fsfw | 2 +- linux/fsfwconfig/OBSWConfig.h.in | 1 - .../pollingSequenceFactory.cpp | 30 ++++++------ mission/devices/GyroADIS1650XHandler.cpp | 2 +- mission/devices/Max31865PT1000Handler.cpp | 48 ++++++++++++++----- mission/devices/Max31865PT1000Handler.h | 4 +- tmtc | 2 +- 11 files changed, 84 insertions(+), 54 deletions(-) diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index af89d346..73605471 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -31,8 +31,8 @@ namespace gpioNames { static constexpr char MGM_3_CS[] = "mgm_3_rm3100_chip_select"; static constexpr char RESET_GNSS_0[] = "reset_gnss_0"; static constexpr char RESET_GNSS_1[] = "reset_gnss_1"; - static constexpr char GYRO_0_ENABLE[] = "gyro_0_enable"; - static constexpr char GYRO_2_ENABLE[] = "gyro_2_enable"; + static constexpr char GYRO_0_ENABLE[] = "enable_gyro_0"; + static constexpr char GYRO_2_ENABLE[] = "enable_gyro_2"; static constexpr char HEATER_0[] = "heater0"; static constexpr char HEATER_1[] = "heater1"; static constexpr char HEATER_2[] = "heater2"; diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index 81d972b1..80e95732 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -199,7 +199,7 @@ void initmission::createPstTasks(TaskFactory& factory, /* Polling Sequence Table Default */ #if OBSW_ADD_SPI_TEST_CODE == 0 FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask( - "PST_TASK_DEFAULT", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 3.0, + "PST_TASK_DEFAULT", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.5, missedDeadlineFunc); result = pst::pstSpi(spiPst); if (result != HasReturnvaluesIF::RETURN_OK) { diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 3fb71db5..558f23b1 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -698,45 +698,45 @@ void ObjectFactory::createRtdComponents(LinuxLibgpioIF *gpioComIF) { gpioComIF->addGpios(rtdGpioCookie); SpiCookie* spiRtdIc0 = new SpiCookie(addresses::RTD_IC_3, gpioIds::RTD_IC_3, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); SpiCookie* spiRtdIc1 = new SpiCookie(addresses::RTD_IC_4, gpioIds::RTD_IC_4, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); SpiCookie* spiRtdIc2 = new SpiCookie(addresses::RTD_IC_5, gpioIds::RTD_IC_5, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); SpiCookie* spiRtdIc3 = new SpiCookie(addresses::RTD_IC_6, gpioIds::RTD_IC_6, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); SpiCookie* spiRtdIc4 = new SpiCookie(addresses::RTD_IC_7, gpioIds::RTD_IC_7, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); SpiCookie* spiRtdIc5 = new SpiCookie(addresses::RTD_IC_8, gpioIds::RTD_IC_8, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); SpiCookie* spiRtdIc6 = new SpiCookie(addresses::RTD_IC_9, gpioIds::RTD_IC_9, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); SpiCookie* spiRtdIc7 = new SpiCookie(addresses::RTD_IC_10, gpioIds::RTD_IC_10, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); SpiCookie* spiRtdIc8 = new SpiCookie(addresses::RTD_IC_11, gpioIds::RTD_IC_11, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); SpiCookie* spiRtdIc9 = new SpiCookie(addresses::RTD_IC_12, gpioIds::RTD_IC_12, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); SpiCookie* spiRtdIc10 = new SpiCookie(addresses::RTD_IC_13, gpioIds::RTD_IC_13, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); SpiCookie* spiRtdIc11 = new SpiCookie(addresses::RTD_IC_14, gpioIds::RTD_IC_14, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); SpiCookie* spiRtdIc12 = new SpiCookie(addresses::RTD_IC_15, gpioIds::RTD_IC_15, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); SpiCookie* spiRtdIc13 = new SpiCookie(addresses::RTD_IC_16, gpioIds::RTD_IC_16, std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, - spi::SpiModes::MODE_1, spi::RTD_SPEED); + spi::RTD_MODE, spi::RTD_SPEED); SpiCookie* spiRtdIc14 = new SpiCookie(addresses::RTD_IC_17, gpioIds::RTD_IC_17, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); SpiCookie* spiRtdIc15 = new SpiCookie(addresses::RTD_IC_18, gpioIds::RTD_IC_18, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); Max31865PT1000Handler* rtdIc0 = new Max31865PT1000Handler(objects::RTD_IC_3, objects::SPI_COM_IF, @@ -775,6 +775,11 @@ void ObjectFactory::createRtdComponents(LinuxLibgpioIF *gpioComIF) { rtdIc0->setStartUpImmediately(); rtdIc1->setStartUpImmediately(); rtdIc2->setStartUpImmediately(); +#if OBSW_DEBUG_RTD == 1 + rtdIc0->setInstantNormal(true); + rtdIc1->setInstantNormal(true); + rtdIc2->setInstantNormal(true); +#endif static_cast(rtdIc0); static_cast(rtdIc1); diff --git a/common/config/devConf.h b/common/config/devConf.h index 3fbded81..78681ec7 100644 --- a/common/config/devConf.h +++ b/common/config/devConf.h @@ -12,15 +12,15 @@ namespace spi { // Default values, changing them is not supported for now static constexpr uint32_t DEFAULT_LIS3_SPEED = 976'000; -static constexpr uint32_t LIS3_TRANSITION_DELAY = 10000; +static constexpr uint32_t LIS3_TRANSITION_DELAY = 5000; static constexpr spi::SpiModes DEFAULT_LIS3_MODE = spi::SpiModes::MODE_3; static constexpr uint32_t DEFAULT_RM3100_SPEED = 976'000; -static constexpr uint32_t RM3100_TRANSITION_DELAY = 10000; +static constexpr uint32_t RM3100_TRANSITION_DELAY = 5000; static constexpr spi::SpiModes DEFAULT_RM3100_MODE = spi::SpiModes::MODE_3; static constexpr uint32_t DEFAULT_L3G_SPEED = 976'000; -static constexpr uint32_t L3G_TRANSITION_DELAY = 10000; +static constexpr uint32_t L3G_TRANSITION_DELAY = 5000; static constexpr spi::SpiModes DEFAULT_L3G_MODE = spi::SpiModes::MODE_3; static constexpr uint32_t DEFAULT_MAX_1227_SPEED = 3'900'000; diff --git a/fsfw b/fsfw index e428568a..e5b568bc 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit e428568a00494c3e3ceb6d0b314baae97d4d8731 +Subproject commit e5b568bc2b0b819bfb5c9dc90026d534852df4ff diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index a95bbfd5..1f12b579 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -102,7 +102,6 @@ debugging. */ #define OBSW_DEBUG_ACU 0 #define OBSW_DEBUG_SYRLINKS 0 #define OBSW_DEBUG_IMQT 0 -#define OBSW_DEBUG_ADIS16507 0 #define OBSW_DEBUG_RAD_SENSOR 0 #define OBSW_DEBUG_SUS 0 #define OBSW_DEBUG_RTD 0 diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index c4ce9c25..19d9b2de 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -59,9 +59,9 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.2, DeviceHandlerIF::SEND_WRITE); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC_3, length * 0.15, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_4, length * 0.15, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_5, length * 0.15, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_3, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_4, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_5, length * 0.2, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::RTD_IC_6, length * 0.2, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::RTD_IC_7, length * 0.2, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::RTD_IC_8, length * 0.2, DeviceHandlerIF::SEND_WRITE); @@ -415,27 +415,27 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { #if OBSW_ADD_RW == 1 thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::RW1, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW1, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW1, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW1, length * 0.5, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW1, length * 0.65, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::RW1, length * 0.8, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::RW2, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW2, length * 0.6, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW2, length * 0.7, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW2, length * 0.85, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW2, length * 0.5, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW2, length * 0.65, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW2, length * 0.8, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::RW3, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW3, length * 0.6, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW3, length * 0.7, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW3, length * 0.85, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW3, length * 0.5, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW3, length * 0.65, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW3, length * 0.8, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::RW4, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW4, length * 0.6, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW4, length * 0.7, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW4, length * 0.85, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW4, length * 0.5, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW4, length * 0.65, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW4, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_ACS_BOARD == 1 @@ -445,7 +445,7 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { // A side thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.2, + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.25, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); diff --git a/mission/devices/GyroADIS1650XHandler.cpp b/mission/devices/GyroADIS1650XHandler.cpp index 6124fc10..4820eefc 100644 --- a/mission/devices/GyroADIS1650XHandler.cpp +++ b/mission/devices/GyroADIS1650XHandler.cpp @@ -319,7 +319,7 @@ ReturnValue_t GyroADIS1650XHandler::handleSensorData(const uint8_t *packet) { } uint32_t GyroADIS1650XHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { - return 5000; + return 10000; } void GyroADIS1650XHandler::prepareWriteCommand(uint8_t startReg, uint8_t valueOne, diff --git a/mission/devices/Max31865PT1000Handler.cpp b/mission/devices/Max31865PT1000Handler.cpp index 4cdc75b3..750d56e5 100644 --- a/mission/devices/Max31865PT1000Handler.cpp +++ b/mission/devices/Max31865PT1000Handler.cpp @@ -7,10 +7,10 @@ Max31865PT1000Handler::Max31865PT1000Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie): - DeviceHandlerBase(objectId, comIF, comCookie), sensorDataset(this), - sensorDatasetSid(sensorDataset.getSid()) { + DeviceHandlerBase(objectId, comIF, comCookie), + sensorDataset(this), sensorDatasetSid(sensorDataset.getSid()) { #if OBSW_VERBOSE_LEVEL >= 1 - debugDivider = new PeriodicOperationDivider(0); + debugDivider = new PeriodicOperationDivider(10); #endif } @@ -68,12 +68,21 @@ void Max31865PT1000Handler::doStartUp() { if(internalState == InternalState::REQUEST_LOW_THRESHOLD) { if(commandExecuted) { - setMode(MODE_ON); - setMode(MODE_NORMAL); - internalState = InternalState::RUNNING; + internalState = InternalState::CLEAR_FAULT_BYTE; commandExecuted = false; } } + if(internalState == InternalState::CLEAR_FAULT_BYTE) { + if(commandExecuted) { + commandExecuted = false; + internalState = InternalState::RUNNING; + if(instantNormal) { + setMode(MODE_NORMAL); + } else { + setMode(_MODE_TO_ON); + } + } + } } void Max31865PT1000Handler::doShutDown() { @@ -132,6 +141,10 @@ ReturnValue_t Max31865PT1000Handler::buildTransitionDeviceCommand( *id = Max31865Definitions::REQUEST_LOW_THRESHOLD; return buildCommandFromCommand(*id, nullptr, 0); } + case(InternalState::CLEAR_FAULT_BYTE): { + *id = Max31865Definitions::CLEAR_FAULT_BYTE; + return buildCommandFromCommand(*id, nullptr, 0); + } default: #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -305,7 +318,11 @@ ReturnValue_t Max31865PT1000Handler::scanForReply(const uint8_t *start, else if(internalState == InternalState::CLEAR_FAULT_BYTE) { *foundId = Max31865Definitions::CLEAR_FAULT_BYTE; *foundLen = 2; - internalState = InternalState::RUNNING; + if(mode == _MODE_START_UP) { + commandExecuted = true; + } else { + internalState = InternalState::RUNNING; + } } else { *foundId = Max31865Definitions::REQUEST_CONFIG; @@ -323,10 +340,11 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply( if(packet[1] != DEFAULT_CONFIG) { #if FSFW_CPP_OSTREAM_ENABLED == 1 // it propably would be better if we at least try one restart.. - sif::error << "Max31865PT1000Handler: Object ID: " << std::hex << this->getObjectId() - << ": Invalid configuration reply!" << std::endl; + sif::error << "Max31865PT1000Handler: 0x" << std::hex << this->getObjectId() + << ": Invalid configuration reply" << std::endl; #else - sif::printError("Max31865PT1000Handler: Invalid configuration reply!\n"); + sif::printError("Max31865PT1000Handler: %04x: Invalid configuration reply!\n", + this->getObjectId()); #endif return HasReturnvaluesIF::RETURN_OK; } @@ -517,6 +535,12 @@ ReturnValue_t Max31865PT1000Handler::initializeLocalDataPool(localpool::DataPool return HasReturnvaluesIF::RETURN_OK; } -void Max31865PT1000Handler::modeChanged() { - internalState = InternalState::NONE; +void Max31865PT1000Handler::setInstantNormal(bool instantNormal) { + this->instantNormal = instantNormal; +} + +void Max31865PT1000Handler::modeChanged() { + if(mode == MODE_OFF) { + internalState = InternalState::NONE; + } } diff --git a/mission/devices/Max31865PT1000Handler.h b/mission/devices/Max31865PT1000Handler.h index 60fd2904..3be16150 100644 --- a/mission/devices/Max31865PT1000Handler.h +++ b/mission/devices/Max31865PT1000Handler.h @@ -45,6 +45,7 @@ public: // 8. 1 for 50 Hz filter, 0 for 60 Hz filter (noise rejection filter) static constexpr uint8_t DEFAULT_CONFIG = 0b11000001; + void setInstantNormal(bool instantNormal); /** * Expected temperature range is -100 C and 100 C. * If there are temperatures beyond this range there must be a fault. @@ -59,7 +60,7 @@ public: static constexpr float RTD_RREF_PT1000 = 4020.0; //!< Ohm static constexpr float RTD_RESISTANCE0_PT1000 = 1000.0; //!< Ohm protected: - /* DeviceHandlerBase abstract function implementation */ + // DeviceHandlerBase abstract function implementation void doStartUp() override; void doShutDown() override; ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; @@ -85,6 +86,7 @@ protected: private: uint8_t switchId = 0; + bool instantNormal = true; enum class InternalState { NONE, diff --git a/tmtc b/tmtc index eca5bba1..8cfc2892 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit eca5bba1d8df6576a19547d356e676b0fb164d87 +Subproject commit 8cfc2892dd95f959edb4b0ec1bbc8fc4aaa69ef2 From 2dd8fb4f4531270da10e61b9a2703c7c0ac9ace1 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Fri, 17 Dec 2021 15:08:33 +0100 Subject: [PATCH 148/465] acu command to print current and voltage of ACU channels --- mission/devices/ACUHandler.cpp | 37 ++++++++++++------------- mission/devices/ACUHandler.h | 2 ++ mission/devices/GomspaceDeviceHandler.h | 2 +- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/mission/devices/ACUHandler.cpp b/mission/devices/ACUHandler.cpp index a52e48ff..043942fe 100644 --- a/mission/devices/ACUHandler.cpp +++ b/mission/devices/ACUHandler.cpp @@ -16,6 +16,11 @@ ReturnValue_t ACUHandler::buildNormalDeviceCommand( return buildCommandFromCommand(*id, NULL, 0); } +void ACUHandler::fillCommandAndReplyMap() { + GomspaceDeviceHandler::fillCommandAndReplyMap(); + this->insertInCommandMap(PRINT_CHANNEL_STATS); +} + void ACUHandler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) { parseHkTableReply(packet); @@ -281,29 +286,23 @@ ReturnValue_t ACUHandler::deviceSpecificCommand(DeviceCommandId_t cmd) { void ACUHandler::printChannelStats() { PoolReadGuard pg(&acuHkTableDataset); - sif::info << "ACU Info: Stats, Current [mA], Voltage [mV]" << std::endl; - sif::info << std::setw(30) << std::left << "Ch0" << std::dec << "| " << + sif::info << "ACU Info: Current [mA], Voltage [mV]" << std::endl; + sif::info << std::setw(8) << std::left << "Ch0" << std::dec << "| " << static_cast(acuHkTableDataset.currentInChannel0.value) << ", " << - std::setw(4) << std::right << acuHkTableDataset.voltageInChannel0.value << ", " - << std::setw(4) << std::endl; - sif::info << std::setw(30) << std::left << "Ch1" << std::dec << "| " << + std::setw(13) << std::right << acuHkTableDataset.voltageInChannel0.value << std::endl; + sif::info << std::setw(8) << std::left << "Ch1" << std::dec << "| " << static_cast(acuHkTableDataset.currentInChannel1.value) << ", " << - std::setw(4) << std::right << acuHkTableDataset.voltageInChannel1.value << ", " - << std::setw(4) << std::endl; - sif::info << std::setw(30) << std::left << "Ch2" << std::dec << "| " << + std::setw(13) << std::right << acuHkTableDataset.voltageInChannel1.value << std::endl; + sif::info << std::setw(8) << std::left << "Ch2" << std::dec << "| " << static_cast(acuHkTableDataset.currentInChannel2.value) << ", " << - std::setw(4) << std::right << acuHkTableDataset.voltageInChannel2.value << ", " - << std::setw(4) << std::endl; - sif::info << std::setw(30) << std::left << "Ch3" << std::dec << "| " << + std::setw(13) << std::right << acuHkTableDataset.voltageInChannel2.value << std::endl; + sif::info << std::setw(8) << std::left << "Ch3" << std::dec << "| " << static_cast(acuHkTableDataset.currentInChannel3.value) << ", " << - std::setw(4) << std::right << acuHkTableDataset.voltageInChannel3.value << ", " - << std::setw(4) << std::endl; - sif::info << std::setw(30) << std::left << "Ch4" << std::dec << "| " << + std::setw(13) << std::right << acuHkTableDataset.voltageInChannel3.value << std::endl; + sif::info << std::setw(8) << std::left << "Ch4" << std::dec << "| " << static_cast(acuHkTableDataset.currentInChannel4.value) << ", " << - std::setw(4) << std::right << acuHkTableDataset.voltageInChannel4.value << ", " - << std::setw(4) << std::endl; - sif::info << std::setw(30) << std::left << "Ch5" << std::dec << "| " << + std::setw(13) << std::right << acuHkTableDataset.voltageInChannel4.value << std::endl; + sif::info << std::setw(8) << std::left << "Ch5" << std::dec << "| " << static_cast(acuHkTableDataset.currentInChannel5.value) << ", " << - std::setw(4) << std::right << acuHkTableDataset.voltageInChannel5.value << ", " - << std::setw(4) << std::endl; + std::setw(13) << std::right << acuHkTableDataset.voltageInChannel5.value << std::endl; } diff --git a/mission/devices/ACUHandler.h b/mission/devices/ACUHandler.h index 886faba7..2bb688e7 100644 --- a/mission/devices/ACUHandler.h +++ b/mission/devices/ACUHandler.h @@ -26,6 +26,8 @@ protected: */ virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; + virtual void fillCommandAndReplyMap() override; + virtual ReturnValue_t deviceSpecificCommand(DeviceCommandId_t cmd) override; private: diff --git a/mission/devices/GomspaceDeviceHandler.h b/mission/devices/GomspaceDeviceHandler.h index bb11ba0e..29156fce 100644 --- a/mission/devices/GomspaceDeviceHandler.h +++ b/mission/devices/GomspaceDeviceHandler.h @@ -73,7 +73,7 @@ protected: virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override; - void fillCommandAndReplyMap() override; + virtual 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, From 3163995d06093aeb4bd386ef97f5f09be14c2920 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Fri, 17 Dec 2021 15:24:23 +0100 Subject: [PATCH 149/465] improvements of printout --- mission/devices/ACUHandler.cpp | 24 ++++++++++++------------ tmtc | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/mission/devices/ACUHandler.cpp b/mission/devices/ACUHandler.cpp index 043942fe..955b1703 100644 --- a/mission/devices/ACUHandler.cpp +++ b/mission/devices/ACUHandler.cpp @@ -288,21 +288,21 @@ void ACUHandler::printChannelStats() { PoolReadGuard pg(&acuHkTableDataset); sif::info << "ACU Info: Current [mA], Voltage [mV]" << std::endl; sif::info << std::setw(8) << std::left << "Ch0" << std::dec << "| " << - static_cast(acuHkTableDataset.currentInChannel0.value) << ", " << - std::setw(13) << std::right << acuHkTableDataset.voltageInChannel0.value << std::endl; + static_cast(acuHkTableDataset.currentInChannel0.value) << + std::setw(15) << std::right << acuHkTableDataset.voltageInChannel0.value << std::endl; sif::info << std::setw(8) << std::left << "Ch1" << std::dec << "| " << - static_cast(acuHkTableDataset.currentInChannel1.value) << ", " << - std::setw(13) << std::right << acuHkTableDataset.voltageInChannel1.value << std::endl; + static_cast(acuHkTableDataset.currentInChannel1.value) << + std::setw(15) << std::right << acuHkTableDataset.voltageInChannel1.value << std::endl; sif::info << std::setw(8) << std::left << "Ch2" << std::dec << "| " << - static_cast(acuHkTableDataset.currentInChannel2.value) << ", " << - std::setw(13) << std::right << acuHkTableDataset.voltageInChannel2.value << std::endl; + static_cast(acuHkTableDataset.currentInChannel2.value) << + std::setw(15) << std::right << acuHkTableDataset.voltageInChannel2.value << std::endl; sif::info << std::setw(8) << std::left << "Ch3" << std::dec << "| " << - static_cast(acuHkTableDataset.currentInChannel3.value) << ", " << - std::setw(13) << std::right << acuHkTableDataset.voltageInChannel3.value << std::endl; + static_cast(acuHkTableDataset.currentInChannel3.value) << + std::setw(15) << std::right << acuHkTableDataset.voltageInChannel3.value << std::endl; sif::info << std::setw(8) << std::left << "Ch4" << std::dec << "| " << - static_cast(acuHkTableDataset.currentInChannel4.value) << ", " << - std::setw(13) << std::right << acuHkTableDataset.voltageInChannel4.value << std::endl; + static_cast(acuHkTableDataset.currentInChannel4.value) << + std::setw(15) << std::right << acuHkTableDataset.voltageInChannel4.value << std::endl; sif::info << std::setw(8) << std::left << "Ch5" << std::dec << "| " << - static_cast(acuHkTableDataset.currentInChannel5.value) << ", " << - std::setw(13) << std::right << acuHkTableDataset.voltageInChannel5.value << std::endl; + static_cast(acuHkTableDataset.currentInChannel5.value) << + std::setw(15) << std::right << acuHkTableDataset.voltageInChannel5.value << std::endl; } diff --git a/tmtc b/tmtc index 3377243c..f5613e5e 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 3377243c07ceb4c5d58d35468dedefb71e1c4aa5 +Subproject commit f5613e5e80013d2d0c33938a56a334ce2c7c9f5a From 654e75fec850a864b7777ef01020b5b5ffb9eac7 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Sat, 18 Dec 2021 11:33:29 +0100 Subject: [PATCH 150/465] histogram tm disabled validity buffer for deserialization --- bsp_q7s/devices/startracker/StarTrackerDefinitions.h | 4 ++-- bsp_q7s/devices/startracker/StarTrackerHandler.cpp | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h index 18fe38d7..9fdd4aca 100644 --- a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h +++ b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h @@ -660,7 +660,7 @@ public: lp_var_t binA6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA6, this); lp_var_t binA7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA7, this); lp_var_t binA8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA8, this); - lp_var_t binb0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB0, this); + lp_var_t binB0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB0, this); lp_var_t binB1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB1, this); lp_var_t binB2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB2, this); lp_var_t binB3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB3, this); @@ -702,7 +702,7 @@ public: sif::info << "HistogramSet::printSet: BinA6: " << this->binA6 << std::endl; sif::info << "HistogramSet::printSet: BinA7: " << this->binA7 << std::endl; sif::info << "HistogramSet::printSet: BinA8: " << this->binA8 << std::endl; - sif::info << "HistogramSet::printSet: BinB0: " << this->binA0 << std::endl; + sif::info << "HistogramSet::printSet: BinB0: " << this->binB0 << std::endl; sif::info << "HistogramSet::printSet: BinB1: " << this->binB1 << std::endl; sif::info << "HistogramSet::printSet: BinB2: " << this->binB2 << std::endl; sif::info << "HistogramSet::printSet: BinB3: " << this->binB3 << std::endl; diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp index 16960f76..cf02a2c7 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp @@ -1419,7 +1419,9 @@ ReturnValue_t StarTrackerHandler::handleHistogramTm() { } const uint8_t* reply = dataLinkLayer.getReply() + TM_DATA_FIELD_OFFSET; size_t size = StarTracker::HistogramSet::SIZE; + histogramSet.setValidityBufferGeneration(false); result = histogramSet.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE); + histogramSet.setValidityBufferGeneration(true); if (result != RETURN_OK) { sif::warning << "StarTrackerHandler::handleHistogramTm: Deserialization failed" << std::endl; From 72c0503ac175893b895c3456f61ef74465bfc0d9 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Sun, 19 Dec 2021 11:29:40 +0100 Subject: [PATCH 151/465] changed deserialization method for star tracker datasets --- .../startracker/StarTrackerDefinitions.h | 14 +- .../startracker/StarTrackerHandler.cpp | 445 +++--------------- .../devices/startracker/StarTrackerHandler.h | 81 +--- 3 files changed, 86 insertions(+), 454 deletions(-) diff --git a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h index 9fdd4aca..425c69d0 100644 --- a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h +++ b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h @@ -270,6 +270,8 @@ class TemperatureSet: public StaticLocalDataSet { public: + static const size_t SIZE = 20; + TemperatureSet(HasLocalDataPoolIF* owner): StaticLocalDataSet(owner, TEMPERATURE_SET_ID) { } @@ -308,6 +310,8 @@ class VersionSet: public StaticLocalDataSet { public: + static const size_t SIZE = 15; + VersionSet(HasLocalDataPoolIF* owner): StaticLocalDataSet(owner, VERSION_SET_ID) { } @@ -351,6 +355,8 @@ class InterfaceSet: public StaticLocalDataSet { public: + static const size_t SIZE = 20; + InterfaceSet(HasLocalDataPoolIF* owner): StaticLocalDataSet(owner, REQ_INTERFACE) { } @@ -390,6 +396,8 @@ class PowerSet: public StaticLocalDataSet { public: + static const size_t SIZE = 76; + PowerSet(HasLocalDataPoolIF* owner): StaticLocalDataSet(owner, REQ_INTERFACE) { } @@ -485,6 +493,8 @@ class TimeSet: public StaticLocalDataSet { public: + static const size_t SIZE = 24; + TimeSet(HasLocalDataPoolIF* owner): StaticLocalDataSet(owner, TIME_SET_ID) { } @@ -525,6 +535,8 @@ class SolutionSet: public StaticLocalDataSet { public: + static const size_t SIZE = 78; + SolutionSet(HasLocalDataPoolIF* owner): StaticLocalDataSet(owner, SOLUTION_SET_ID) { } @@ -740,7 +752,7 @@ class ContrastSet: public: // Size of dataset - static const size_t SIZE = 154; + static const size_t SIZE = 156; ContrastSet(HasLocalDataPoolIF* owner): StaticLocalDataSet(owner, CONTRAST_SET_ID) { diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp index cf02a2c7..35d6a58a 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp @@ -491,7 +491,7 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con break; } case (StarTracker::REQ_TIME): { - result = handleTimeTm(); + result = handleTm(timeSet, StarTracker::TimeSet::SIZE); break; } case (StarTracker::PING_REQUEST): { @@ -511,7 +511,7 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con break; } case (StarTracker::REQ_VERSION): { - result = handleVersionTm(); + result = handleTm(versionSet, StarTracker::VersionSet::SIZE); if (result != RETURN_OK) { return result; } @@ -522,27 +522,27 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con break; } case (StarTracker::REQ_INTERFACE): { - result = handleInterfaceTm(); + result = handleTm(interfaceSet, StarTracker::InterfaceSet::SIZE); break; } case (StarTracker::REQ_POWER): { - result = handlePowerTm(); + result = handleTm(powerSet, StarTracker::PowerSet::SIZE); break; } case (StarTracker::REQ_SOLUTION): { - handleSolutionTm(); + result = handleTm(solutionSet, StarTracker::SolutionSet::SIZE); break; } case (StarTracker::REQ_TEMPERATURE): { - handleTemperatureTm(); + result = handleTm(temperatureSet, StarTracker::TemperatureSet::SIZE); break; } case (StarTracker::REQ_HISTOGRAM): { - handleHistogramTm(); + result = handleTm(histogramSet, StarTracker::HistogramSet::SIZE); break; } case (StarTracker::REQ_CONTRAST): { - handleContrastTm(); + result = handleTm(contrastSet, StarTracker::ContrastSet::SIZE); break; } case (StarTracker::LIMITS): @@ -691,6 +691,46 @@ ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& l localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND7, new PoolEntry( { 0 })); localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_CONTRAST_SET, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TIME_CONTRAST_SET, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA0, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA1, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA4, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA5, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA6, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB0, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB1, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB4, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB5, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB6, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC0, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC1, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC4, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC5, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC6, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND0, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND1, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND4, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND5, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND6, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND8, new PoolEntry( { 0 })); + return RETURN_OK; } @@ -1076,74 +1116,6 @@ ReturnValue_t StarTrackerHandler::handlePingReply() { return result; } -ReturnValue_t StarTrackerHandler::handleTimeTm() { - ReturnValue_t result = RETURN_OK; - result = timeSet.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } - uint32_t offset = TM_DATA_FIELD_OFFSET; - uint8_t status = 0; - uint32_t ticks = 0; - uint64_t time = 0; - getTmHeaderData(&status, &ticks, &time); - if(status != StarTracker::STATUS_OK) { - sif::warning << "StarTrackerHandler::handleTimeTm: Reply error: " - << static_cast(status) << std::endl; - result = VERSION_REQ_FAILED; - return result; - } - const uint8_t* reply = dataLinkLayer.getReply(); - timeSet.ticks = ticks; - timeSet.time = time; - timeSet.runTime = deserializeUint32(reply + offset); - offset += sizeof(uint32_t); - timeSet.unixTime = deserializeUint64(reply + offset); - result = timeSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - timeSet.printSet(); -#endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ - return result; -} - -ReturnValue_t StarTrackerHandler::handleVersionTm() { - ReturnValue_t result = RETURN_OK; - uint32_t offset = TM_DATA_FIELD_OFFSET; - uint8_t status = 0; - uint32_t ticks = 0; - uint64_t time = 0; - getTmHeaderData(&status, &ticks, &time); - if(status != StarTracker::STATUS_OK) { - sif::warning << "StarTrackerHandler::handleVersionTm: Reply error: " - << static_cast(status) << std::endl; - result = VERSION_REQ_FAILED; - return result; - } - result = versionSet.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } - const uint8_t* reply = dataLinkLayer.getReply(); - versionSet.ticks = ticks; - versionSet.time = time; - versionSet.program = *(reply + offset); - offset += 1; - versionSet.major = *(reply + offset); - offset += 1; - versionSet.minor = *(reply + offset); - result = versionSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - versionSet.printSet(); -#endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ - return result; -} - ReturnValue_t StarTrackerHandler::checkProgram() { PoolReadGuard pg(&versionSet); switch(versionSet.program.value) { @@ -1168,332 +1140,37 @@ ReturnValue_t StarTrackerHandler::checkProgram() { return RETURN_OK; } -ReturnValue_t StarTrackerHandler::handleInterfaceTm() { +ReturnValue_t StarTrackerHandler::handleTm(LocalPoolDataSetBase& dataset, size_t size) { ReturnValue_t result = RETURN_OK; - uint32_t offset = TM_DATA_FIELD_OFFSET; - uint8_t status = 0; - uint32_t ticks = 0; - uint64_t time = 0; - getTmHeaderData(&status, &ticks, &time); + uint8_t status = *(dataLinkLayer.getReply() + STATUS_OFFSET); if(status != StarTracker::STATUS_OK) { - sif::warning << "StarTrackerHandler::handleInterfaceTm: Reply error: " + sif::warning << "StarTrackerHandler::handleTm: Reply error: " << static_cast(status) << std::endl; - result = INTERFACE_REQ_FAILED; - return result; + return TM_REPLY_ERROR; } - result = interfaceSet.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); + result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); if (result != RETURN_OK) { return result; } - const uint8_t* reply = dataLinkLayer.getReply(); - interfaceSet.ticks = ticks; - interfaceSet.time = time; - size_t size = sizeof(uint32_t); - interfaceSet.frameCount = deserializeUint32(reply + offset); - offset += size; - interfaceSet.checksumerrorCount = deserializeUint32(reply + offset); - result = interfaceSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); + const uint8_t* reply = dataLinkLayer.getReply() + TICKS_OFFSET; + dataset.setValidityBufferGeneration(false); + result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE); if (result != RETURN_OK) { - return result; - } -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - interfaceSet.printSet(); -#endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ - return result; -} - -ReturnValue_t StarTrackerHandler::handlePowerTm() { - ReturnValue_t result = RETURN_OK; - uint32_t offset = TM_DATA_FIELD_OFFSET; - uint8_t status = 0; - uint32_t ticks = 0; - uint64_t time = 0; - getTmHeaderData(&status, &ticks, &time); - if(status != StarTracker::STATUS_OK) { - sif::warning << "StarTrackerHandler::handlePowerTm: Reply error: " - << static_cast(status) << std::endl; - result = POWER_REQ_FAILED; - return result; - } - result = powerSet.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } - const uint8_t* reply = dataLinkLayer.getReply(); - powerSet.ticks= ticks; - powerSet.time= time; - float value = 0; - std::memcpy(&value, reply + offset, sizeof(value)); - powerSet.mcuCurrent = value; - offset += 4; - std::memcpy(&value, reply + offset, sizeof(value)); - powerSet.mcuVoltage = value; - offset += 4; - std::memcpy(&value, reply + offset, sizeof(value)); - powerSet.fpgaCoreCurrent = value; - offset += 4; - std::memcpy(&value, reply + offset, sizeof(value)); - powerSet.fpgaCoreVoltage = value; - offset += 4; - std::memcpy(&value, reply + offset, sizeof(value)); - powerSet.fpga18Current = value; - offset += 4; - std::memcpy(&value, reply + offset, sizeof(value)); - powerSet.fpga18Voltage = value; - offset += 4; - std::memcpy(&value, reply + offset, sizeof(value)); - powerSet.fpga25Current = value; - offset += 4; - std::memcpy(&value, reply + offset, sizeof(value)); - powerSet.fpga25Voltage = value; - offset += 4; - std::memcpy(&value, reply + offset, sizeof(value)); - powerSet.cmv21Current = value; - offset += 4; - std::memcpy(&value, reply + offset, sizeof(value)); - powerSet.cmv21Voltage = value; - offset += 4; - std::memcpy(&value, reply + offset, sizeof(value)); - powerSet.cmvPixCurrent= value; - offset += 4; - std::memcpy(&value, reply + offset, sizeof(value)); - powerSet.cmvPixVoltage = value; - offset += 4; - std::memcpy(&value, reply + offset, sizeof(value)); - powerSet.cmv33Current= value; - offset += 4; - std::memcpy(&value, reply + offset, sizeof(value)); - powerSet.cmv33Voltage = value; - offset += 4; - std::memcpy(&value, reply + offset, sizeof(value)); - powerSet.cmvResCurrent= value; - offset += 4; - std::memcpy(&value, reply + offset, sizeof(value)); - powerSet.cmvResVoltage = value; - result = powerSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - powerSet.printSet(); -#endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ - return result; -} - -ReturnValue_t StarTrackerHandler::handleSolutionTm() { - ReturnValue_t result = RETURN_OK; - result = solutionSet.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } - uint32_t offset = TM_DATA_FIELD_OFFSET; - uint8_t status = 0; - uint32_t ticks = 0; - uint64_t time = 0; - getTmHeaderData(&status, &ticks, &time); - if(status != StarTracker::STATUS_OK) { - sif::warning << "StarTrackerHandler::handleSolutioneTm: Reply error: " - << static_cast(status) << std::endl; - result = TEMPERATURE_REQ_FAILED; - return result; - } - const uint8_t* reply = dataLinkLayer.getReply(); - solutionSet.ticks= ticks; - solutionSet.time= time; - float word = 0; - std::memcpy(&word, reply + offset, sizeof(float)); - solutionSet.caliQw = word; - offset += sizeof(float); - std::memcpy(&word, reply + offset, sizeof(float)); - solutionSet.caliQx = word; - offset += sizeof(float); - std::memcpy(&word, reply + offset, sizeof(float)); - solutionSet.caliQy = word; - offset += sizeof(float); - std::memcpy(&word, reply + offset, sizeof(float)); - solutionSet.caliQz = word; - offset += sizeof(float); - std::memcpy(&word, reply + offset, sizeof(float)); - solutionSet.trackConfidence = word; - offset += sizeof(float); - std::memcpy(&word, reply + offset, sizeof(float)); - solutionSet.trackQw = word; - offset += sizeof(float); - std::memcpy(&word, reply + offset, sizeof(float)); - solutionSet.trackQx = word; - offset += sizeof(float); - std::memcpy(&word, reply + offset, sizeof(float)); - solutionSet.trackQy = word; - offset += sizeof(float); - std::memcpy(&word, reply + offset, sizeof(float)); - solutionSet.trackQz = word; - offset += sizeof(float); - solutionSet.trackRemoved = *(reply + offset); - offset += sizeof(uint8_t); - solutionSet.starsCentroided = *(reply + offset); - offset += sizeof(uint8_t); - solutionSet.starsMatchedDatabase = *(reply + offset); - offset += sizeof(float); - std::memcpy(&word, reply + offset, sizeof(float)); - solutionSet.lisaQw = word; - offset += sizeof(float); - std::memcpy(&word, reply + offset, sizeof(float)); - solutionSet.lisaQx = word; - offset += sizeof(float); - std::memcpy(&word, reply + offset, sizeof(float)); - solutionSet.lisaQy = word; - offset += sizeof(float); - std::memcpy(&word, reply + offset, sizeof(float)); - solutionSet.lisaQz = word; - offset += sizeof(float); - std::memcpy(&word, reply + offset, sizeof(float)); - solutionSet.lisaPercentageClose = word; - offset += sizeof(float); - solutionSet.lisaNrClose = *(reply + offset); - offset += sizeof(uint8_t); - solutionSet.isTrustWorthy = *(reply + offset); - offset += sizeof(uint8_t); - solutionSet.stableCount = *(reply + offset); - offset += sizeof(uint32_t); - solutionSet.stableCount = *(reply + offset); - result = solutionSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - solutionSet.printSet(); -#endif - return result; -} - -ReturnValue_t StarTrackerHandler::handleTemperatureTm() { - ReturnValue_t result = RETURN_OK; - uint32_t offset = TM_DATA_FIELD_OFFSET; - uint8_t status = 0; - uint32_t ticks = 0; - uint64_t time = 0; - getTmHeaderData(&status, &ticks, &time); - if(status != StarTracker::STATUS_OK) { - sif::warning << "StarTrackerHandler::handleTemperatureTm: Reply error: " - << static_cast(status) << std::endl; - result = TEMPERATURE_REQ_FAILED; - return result; - } - result = temperatureSet.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } - const uint8_t* reply = dataLinkLayer.getReply(); - temperatureSet.ticks= ticks; - temperatureSet.time= time; - float temperature = 0; - std::memcpy(&temperature, reply + offset, sizeof(temperature)); - temperatureSet.mcuTemperature = temperature; - offset += sizeof(float); - std::memcpy(&temperature, reply + offset, sizeof(temperature)); - temperatureSet.cmosTemperature = temperature; - result = temperatureSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - temperatureSet.printSet(); -#endif - return result; -} - -ReturnValue_t StarTrackerHandler::handleHistogramTm() { - ReturnValue_t result = RETURN_OK; - uint8_t status = 0; - uint32_t ticks = 0; - uint64_t time = 0; - getTmHeaderData(&status, &ticks, &time); - if(status != StarTracker::STATUS_OK) { - sif::warning << "StarTrackerHandler::handleHistogramTm: Reply error: " - << static_cast(status) << std::endl; - return HISTOGRAM_REQ_FAILED; - } - result = histogramSet.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } - const uint8_t* reply = dataLinkLayer.getReply() + TM_DATA_FIELD_OFFSET; - size_t size = StarTracker::HistogramSet::SIZE; - histogramSet.setValidityBufferGeneration(false); - result = histogramSet.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE); - histogramSet.setValidityBufferGeneration(true); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::handleHistogramTm: Deserialization failed" + sif::warning << "StarTrackerHandler::handleTm: Deserialization failed" << std::endl; } - result = histogramSet.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); + dataset.setValidityBufferGeneration(true); + dataset.setValidity(true, true); + result = dataset.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); if (result != RETURN_OK) { return result; } #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - histogramSet.printSet(); + dataset.printSet(); #endif return result; } -ReturnValue_t StarTrackerHandler::handleContrastTm() { - ReturnValue_t result = RETURN_OK; - uint8_t status = 0; - uint32_t ticks = 0; - uint64_t time = 0; - getTmHeaderData(&status, &ticks, &time); - if(status != StarTracker::STATUS_OK) { - sif::warning << "StarTrackerHandler::handleContrastTm: Reply error: " - << static_cast(status) << std::endl; - result = CONTRAST_REQ_FAILED; - return result; - } - result = contrastSet.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } - const uint8_t* reply = dataLinkLayer.getReply() + TM_DATA_FIELD_OFFSET; - size_t size = StarTracker::ContrastSet::SIZE; - result = contrastSet.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::handleContrastTm: Deserialization failed" - << std::endl; - } -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - contrastSet.printSet(); -#endif - return result; -} - -void StarTrackerHandler::getTmHeaderData(uint8_t* status, uint32_t* ticks, uint64_t* time) { - const uint8_t* reply = dataLinkLayer.getReply(); - *status = *(reply + STATUS_OFFSET); - *ticks = deserializeUint32(reply + TICKS_OFFSET); - *time = deserializeUint64(reply + TIME_OFFSET); -} - -uint32_t StarTrackerHandler::deserializeUint32(const uint8_t* buffer) { - uint32_t word = 0; - word = *(buffer + 3) << 24 - | *(buffer + 2) << 16 - | *(buffer + 1) << 8 - | *(buffer); - return word; -} - -uint64_t StarTrackerHandler::deserializeUint64(const uint8_t* buffer) { - uint64_t word = 0; - word = static_cast(*(buffer + 7)) << 56 - | static_cast(*(buffer + 6)) << 48 - | static_cast(*(buffer + 5)) << 40 - | static_cast(*(buffer + 4)) << 32 - | static_cast(*(buffer + 3)) << 24 - | static_cast(*(buffer + 2)) << 16 - | static_cast(*(buffer + 1)) << 8 - | static_cast(*(buffer)); - return word; -} - void StarTrackerHandler::handleStartup(const uint8_t* parameterId) { switch(*parameterId) { case (StarTracker::ID::LIMITS): { diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.h b/bsp_q7s/devices/startracker/StarTrackerHandler.h index 0fcf14d0..e534f590 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.h +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.h @@ -111,8 +111,8 @@ private: static const ReturnValue_t FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xAC); //! [EXPORT] : [COMMENT] Received version reply with invalid program ID static const ReturnValue_t INVALID_PROGRAM = MAKE_RETURN_CODE(0xAD); - //! [EXPORT] : [COMMENT] Status field of histogram reply signals error - static const ReturnValue_t HISTOGRAM_REQ_FAILED = MAKE_RETURN_CODE(0xAE); + //! [EXPORT] : [COMMENT] Status field of tm reply signals error + static const ReturnValue_t TM_REPLY_ERROR = MAKE_RETURN_CODE(0xAE); //! [EXPORT] : [COMMENT] Status field of contrast reply signals error static const ReturnValue_t CONTRAST_REQ_FAILED = MAKE_RETURN_CODE(0xAE); @@ -311,82 +311,25 @@ private: ReturnValue_t handlePingReply(); - /** - * @brief Fills the time set with the data of the time request reply. - */ - ReturnValue_t handleTimeTm(); - - /** - * @brief Handles reply data of solution request. - */ - ReturnValue_t handleSolutionTm(); - - /** - * @brief This function handles the telemetry reply of a temperature request. - */ - ReturnValue_t handleTemperatureTm(); - - /** - * @brief Checks histogram reply and deserializes data into histogram dataset - */ - ReturnValue_t handleHistogramTm(); - - /** - * @brief Checks contrast reply and deserializes data into contrast dataset - */ - ReturnValue_t handleContrastTm(); - - /** - * @brief This function handles the telemetry reply of a version request. - */ - ReturnValue_t handleVersionTm(); - /** * @brief Checks the loaded program by means of the version set */ ReturnValue_t checkProgram(); - /** - * @brief Handles reply to request interface telemetry command. - */ - ReturnValue_t handleInterfaceTm(); - - /** - * @brief Handles reply to request power telemetry command. - */ - ReturnValue_t handlePowerTm(); - - /** - * @brief Extracts the header data of a received telemetry frame - */ - void getTmHeaderData(uint8_t* status, uint32_t* ticks, uint64_t* time); - - /** - * @brief This function deserializes 8 bytes into a 32 bit unsigned integer. - * - * @param buffer Pointer to buffer holding the data to deserialize - * - * @return The 32-bit unsigned integer. - * - * @note Deserialization will be performed in little endian byte order - */ - uint32_t deserializeUint32(const uint8_t* buffer); - - /** - * @brief This function deserializes 8 bytes into a 64 bit unsigned integer. - * - * @param buffer Pointer to buffer holding the data to deserialize - * - * @return The 64-bit unsigned integer. - * - * @note Deserialization will be performed in little endian byte order - */ - uint64_t deserializeUint64(const uint8_t* buffer); - /** * @brief Handles the startup state machine */ void handleStartup(const uint8_t* parameterId); + + /** + * @brief Handles telemtry replies and fills the appropriate dataset + * + * @param dataset Dataset where reply data will be written to + * @param size Size of the dataset + * + * @return RETURN_OK if successful, otherwise error return value + */ + ReturnValue_t handleTm(LocalPoolDataSetBase& dataset, size_t size); }; #endif /* MISSION_DEVICES_STARTRACKERHANDLER_H_ */ From 8694a20c63c68e189d6a074d984eb14b225d9fbf Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Sun, 19 Dec 2021 11:35:55 +0100 Subject: [PATCH 152/465] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index f5613e5e..02b6304e 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit f5613e5e80013d2d0c33938a56a334ce2c7c9f5a +Subproject commit 02b6304eba009ee620bfe5f9684262acb0cc4bae From e3841d180e416eea5e637d0e7a3062293dba7c2c Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Sun, 19 Dec 2021 12:15:18 +0100 Subject: [PATCH 153/465] merged develop --- bsp_q7s/boardconfig/busConf.h | 4 +- bsp_q7s/core/CoreController.cpp | 4 +- bsp_q7s/core/InitMission.cpp | 2 +- bsp_q7s/core/ObjectFactory.cpp | 37 +++++----- .../startracker/StarTrackerHandler.cpp | 13 +++- cmake/scripts/Q7S/make-release-cfg.sh | 4 +- common/config/devConf.h | 6 +- fsfw | 2 +- linux/fsfwconfig/OBSWConfig.h.in | 5 +- .../pollingSequenceFactory.cpp | 28 ++++---- mission/devices/GyroADIS1650XHandler.cpp | 22 +++--- mission/devices/GyroADIS1650XHandler.h | 6 +- mission/devices/Max31865PT1000Handler.cpp | 70 +++++++++++++++---- mission/devices/Max31865PT1000Handler.h | 8 ++- .../devicedefinitions/Max31865Definitions.h | 4 ++ 15 files changed, 142 insertions(+), 73 deletions(-) diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index af89d346..73605471 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -31,8 +31,8 @@ namespace gpioNames { static constexpr char MGM_3_CS[] = "mgm_3_rm3100_chip_select"; static constexpr char RESET_GNSS_0[] = "reset_gnss_0"; static constexpr char RESET_GNSS_1[] = "reset_gnss_1"; - static constexpr char GYRO_0_ENABLE[] = "gyro_0_enable"; - static constexpr char GYRO_2_ENABLE[] = "gyro_2_enable"; + static constexpr char GYRO_0_ENABLE[] = "enable_gyro_0"; + static constexpr char GYRO_2_ENABLE[] = "enable_gyro_2"; static constexpr char HEATER_0[] = "heater0"; static constexpr char HEATER_1[] = "heater1"; static constexpr char HEATER_2[] = "heater2"; diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index d8149ccb..271ec508 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -1094,8 +1094,8 @@ ReturnValue_t CoreController::handleProtInfoUpdateLine(std::string nextLine) { uint8_t wordIdx = 0; uint8_t arrayIdx = 0; istringstream iss(nextLine); - Chip currentChip; - Copy currentCopy; + Chip currentChip = Chip::CHIP_0; + Copy currentCopy = Copy::COPY_0; while(iss >> word) { if(wordIdx == 1) { currentChip = static_cast(stoi(word)); diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index 8ba118bc..7da77135 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -207,7 +207,7 @@ void initmission::createPstTasks(TaskFactory& factory, /* Polling Sequence Table Default */ #if OBSW_ADD_SPI_TEST_CODE == 0 FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask( - "PST_TASK_DEFAULT", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 3.0, + "PST_TASK_DEFAULT", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.5, missedDeadlineFunc); result = pst::pstSpi(spiPst); if (result != HasReturnvaluesIF::RETURN_OK) { diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 0001d031..168f6de8 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -704,45 +704,45 @@ void ObjectFactory::createRtdComponents(LinuxLibgpioIF *gpioComIF) { gpioComIF->addGpios(rtdGpioCookie); SpiCookie* spiRtdIc0 = new SpiCookie(addresses::RTD_IC_3, gpioIds::RTD_IC_3, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); SpiCookie* spiRtdIc1 = new SpiCookie(addresses::RTD_IC_4, gpioIds::RTD_IC_4, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); SpiCookie* spiRtdIc2 = new SpiCookie(addresses::RTD_IC_5, gpioIds::RTD_IC_5, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); SpiCookie* spiRtdIc3 = new SpiCookie(addresses::RTD_IC_6, gpioIds::RTD_IC_6, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); SpiCookie* spiRtdIc4 = new SpiCookie(addresses::RTD_IC_7, gpioIds::RTD_IC_7, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); SpiCookie* spiRtdIc5 = new SpiCookie(addresses::RTD_IC_8, gpioIds::RTD_IC_8, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); SpiCookie* spiRtdIc6 = new SpiCookie(addresses::RTD_IC_9, gpioIds::RTD_IC_9, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, spi::RTD_SPEED); + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); SpiCookie* spiRtdIc7 = new SpiCookie(addresses::RTD_IC_10, gpioIds::RTD_IC_10, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); SpiCookie* spiRtdIc8 = new SpiCookie(addresses::RTD_IC_11, gpioIds::RTD_IC_11, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); SpiCookie* spiRtdIc9 = new SpiCookie(addresses::RTD_IC_12, gpioIds::RTD_IC_12, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); SpiCookie* spiRtdIc10 = new SpiCookie(addresses::RTD_IC_13, gpioIds::RTD_IC_13, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); SpiCookie* spiRtdIc11 = new SpiCookie(addresses::RTD_IC_14, gpioIds::RTD_IC_14, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); SpiCookie* spiRtdIc12 = new SpiCookie(addresses::RTD_IC_15, gpioIds::RTD_IC_15, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); SpiCookie* spiRtdIc13 = new SpiCookie(addresses::RTD_IC_16, gpioIds::RTD_IC_16, std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, - spi::SpiModes::MODE_1, spi::RTD_SPEED); + spi::RTD_MODE, spi::RTD_SPEED); SpiCookie* spiRtdIc14 = new SpiCookie(addresses::RTD_IC_17, gpioIds::RTD_IC_17, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); SpiCookie* spiRtdIc15 = new SpiCookie(addresses::RTD_IC_18, gpioIds::RTD_IC_18, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); Max31865PT1000Handler* rtdIc0 = new Max31865PT1000Handler(objects::RTD_IC_3, objects::SPI_COM_IF, @@ -781,6 +781,11 @@ void ObjectFactory::createRtdComponents(LinuxLibgpioIF *gpioComIF) { rtdIc0->setStartUpImmediately(); rtdIc1->setStartUpImmediately(); rtdIc2->setStartUpImmediately(); +#if OBSW_DEBUG_RTD == 1 + rtdIc0->setInstantNormal(true); + rtdIc1->setInstantNormal(true); + rtdIc2->setInstantNormal(true); +#endif static_cast(rtdIc0); static_cast(rtdIc1); diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp index 35d6a58a..087d2bfa 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp @@ -73,10 +73,21 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu ReturnValue_t result = RETURN_OK; - if (actionId == StarTracker::STOP_IMAGE_LOADER) { + switch(actionId) { + case(StarTracker::STOP_IMAGE_LOADER): { strImageLoader->stopProcess(); return EXECUTION_FINISHED; } + case(StarTracker::SET_JSON_FILE_NAME): { + if (size > MAX_PATH_SIZE) { + return FILE_PATH_TOO_LONG; + } + paramJsonFile = std::string(reinterpret_cast(data), size); + return EXECUTION_FINISHED; + } + default: + break; + } if (imageLoaderExecuting == true) { return IMAGE_LOADER_EXECUTING; diff --git a/cmake/scripts/Q7S/make-release-cfg.sh b/cmake/scripts/Q7S/make-release-cfg.sh index d71dcc83..233bf263 100755 --- a/cmake/scripts/Q7S/make-release-cfg.sh +++ b/cmake/scripts/Q7S/make-release-cfg.sh @@ -17,7 +17,7 @@ fi os_fsfw="linux" tgt_bsp="arm/q7s" -build_dir="build-Debug-Q7S" +build_dir="build-Release-Q7S" build_generator="make" if [ "${OS}" = "Windows_NT" ]; then python="py" @@ -28,6 +28,6 @@ fi echo "Running command (without the leading +):" set -x # Print command -${python} ${cfg_script_name} -o "${os_fsfw}" -g "${build_generator}" -b "debug" -t "${tgt_bsp}" \ +${python} ${cfg_script_name} -o "${os_fsfw}" -g "${build_generator}" -b "release" -t "${tgt_bsp}" \ -l"${build_dir}" # set +x diff --git a/common/config/devConf.h b/common/config/devConf.h index 3fbded81..78681ec7 100644 --- a/common/config/devConf.h +++ b/common/config/devConf.h @@ -12,15 +12,15 @@ namespace spi { // Default values, changing them is not supported for now static constexpr uint32_t DEFAULT_LIS3_SPEED = 976'000; -static constexpr uint32_t LIS3_TRANSITION_DELAY = 10000; +static constexpr uint32_t LIS3_TRANSITION_DELAY = 5000; static constexpr spi::SpiModes DEFAULT_LIS3_MODE = spi::SpiModes::MODE_3; static constexpr uint32_t DEFAULT_RM3100_SPEED = 976'000; -static constexpr uint32_t RM3100_TRANSITION_DELAY = 10000; +static constexpr uint32_t RM3100_TRANSITION_DELAY = 5000; static constexpr spi::SpiModes DEFAULT_RM3100_MODE = spi::SpiModes::MODE_3; static constexpr uint32_t DEFAULT_L3G_SPEED = 976'000; -static constexpr uint32_t L3G_TRANSITION_DELAY = 10000; +static constexpr uint32_t L3G_TRANSITION_DELAY = 5000; static constexpr spi::SpiModes DEFAULT_L3G_MODE = spi::SpiModes::MODE_3; static constexpr uint32_t DEFAULT_MAX_1227_SPEED = 3'900'000; diff --git a/fsfw b/fsfw index 9a858eb5..b98c85d3 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 9a858eb54c5603ccd3cbd2423cdaf87b20f0c0c4 +Subproject commit b98c85d33fd79853e674f75dadd0a082a962aee4 diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index 9e2a103e..4a7bca35 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -102,7 +102,6 @@ debugging. */ #define OBSW_DEBUG_ACU 0 #define OBSW_DEBUG_SYRLINKS 0 #define OBSW_DEBUG_IMQT 0 -#define OBSW_DEBUG_ADIS16507 0 #define OBSW_DEBUG_RAD_SENSOR 0 #define OBSW_DEBUG_SUS 0 #define OBSW_DEBUG_RTD 0 @@ -115,8 +114,8 @@ debugging. */ /*******************************************************************/ /** Hardcoded */ /*******************************************************************/ -// Leave at one as the BSP is linux. Used by the ADIS16507 device handler -#define OBSW_ADIS16507_LINUX_COM_IF 1 +// Leave at one as the BSP is linux. Used by the ADIS1650X device handler +#define OBSW_ADIS1650X_LINUX_COM_IF 1 #include "OBSWVersion.h" diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 22356d0e..07bc4a8f 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -415,37 +415,37 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { #if OBSW_ADD_RW == 1 thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::RW1, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW1, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW1, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW1, length * 0.5, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW1, length * 0.65, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::RW1, length * 0.8, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::RW2, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW2, length * 0.6, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW2, length * 0.7, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW2, length * 0.85, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW2, length * 0.5, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW2, length * 0.65, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW2, length * 0.8, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::RW3, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW3, length * 0.6, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW3, length * 0.7, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW3, length * 0.85, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW3, length * 0.5, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW3, length * 0.65, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW3, length * 0.8, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::RW4, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW4, length * 0.6, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW4, length * 0.7, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW4, length * 0.85, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW4, length * 0.5, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW4, length * 0.65, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW4, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_ACS_BOARD == 1 - bool enableAside = false; - bool enableBside = true; + bool enableAside = true; + bool enableBside = false; if(enableAside) { // A side thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.2, + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.25, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); diff --git a/mission/devices/GyroADIS1650XHandler.cpp b/mission/devices/GyroADIS1650XHandler.cpp index 4acf9196..4820eefc 100644 --- a/mission/devices/GyroADIS1650XHandler.cpp +++ b/mission/devices/GyroADIS1650XHandler.cpp @@ -185,7 +185,7 @@ void GyroADIS1650XHandler::fillCommandAndReplyMap() { ReturnValue_t GyroADIS1650XHandler::scanForReply(const uint8_t *start, size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { - /* For SPI, the ID will always be the one of the last sent command. */ + // For SPI, the ID will always be the one of the last sent command *foundId = this->getPendingCommand(); *foundLen = this->rawPacketLen; @@ -196,18 +196,19 @@ ReturnValue_t GyroADIS1650XHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { switch(id) { case(ADIS1650X::READ_OUT_CONFIG): { - PoolReadGuard rg(&configDataset); + uint16_t readProdId = packet[10] << 8 | packet[11]; 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 - sif::warning << "GyroADIS16507Handler::interpretDeviceReply: Invalid product ID " + sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Invalid product ID " << readProdId << std::endl; #endif return HasReturnvaluesIF::RETURN_FAILED; } + PoolReadGuard rg(&configDataset); configDataset.diagStatReg.value = packet[2] << 8 | packet[3]; configDataset.filterSetting.value = packet[4] << 8 | packet[5]; configDataset.mscCtrlReg.value = packet[6] << 8 | packet[7]; @@ -232,21 +233,20 @@ ReturnValue_t GyroADIS1650XHandler::handleSensorData(const uint8_t *packet) { switch(burstMode) { case(BurstModes::BURST_16_BURST_SEL_1): case(BurstModes::BURST_32_BURST_SEL_1): { - sif::warning << "GyroADIS16507Handler::interpretDeviceReply: Analysis with BURST_SEL1" + sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Analysis with BURST_SEL1" " not implemented!" << std::endl; return HasReturnvaluesIF::RETURN_OK; } case(BurstModes::BURST_16_BURST_SEL_0): { uint16_t checksum = packet[20] << 8 | packet[21]; - /* Now verify the read checksum with the expected checksum - according to datasheet p. 20 */ + // Now verify the read checksum with the expected checksum according to datasheet p. 20 uint16_t calcChecksum = 0; for(size_t idx = 2; idx < 20; idx ++) { calcChecksum += packet[idx]; } if(checksum != calcChecksum) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::warning << "GyroADIS16507Handler::interpretDeviceReply: " + sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: " "Invalid checksum detected!" << std::endl; #endif return HasReturnvaluesIF::RETURN_FAILED; @@ -277,7 +277,7 @@ ReturnValue_t GyroADIS1650XHandler::handleSensorData(const uint8_t *packet) { } else if(adisType == ADIS1650X::Type::ADIS16505) { accelScaling = ADIS1650X::ACCELEROMETER_RANGE_16505; } else { - sif::warning << "GyroADIS16507Handler::handleSensorData: " + sif::warning << "GyroADIS1650XHandler::handleSensorData: " "Unknown ADIS type" << std::endl; } int16_t accelXRaw = packet[10] << 8 | packet[11]; @@ -298,11 +298,11 @@ ReturnValue_t GyroADIS1650XHandler::handleSensorData(const uint8_t *packet) { #if FSFW_HAL_ADIS1650X_GYRO_DEBUG == 1 if(debugDivider->checkAndIncrement()) { - sif::info << "GyroADIS16507Handler: Angular velocities in deg / s" << std::endl; + sif::info << "GyroADIS1650XHandler: Angular velocities in deg / s" << std::endl; sif::info << "X: " << primaryDataset.angVelocX.value << std::endl; sif::info << "Y: " << primaryDataset.angVelocY.value << std::endl; sif::info << "Z: " << primaryDataset.angVelocZ.value << std::endl; - sif::info << "GyroADIS16507Handler: Accelerations in m / s^2: " << std::endl; + sif::info << "GyroADIS1650XHandler: Accelerations in m / s^2: " << std::endl; sif::info << "X: " << primaryDataset.accelX.value << std::endl; sif::info << "Y: " << primaryDataset.accelY.value << std::endl; sif::info << "Z: " << primaryDataset.accelZ.value << std::endl; @@ -319,7 +319,7 @@ ReturnValue_t GyroADIS1650XHandler::handleSensorData(const uint8_t *packet) { } uint32_t GyroADIS1650XHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { - return 5000; + return 10000; } void GyroADIS1650XHandler::prepareWriteCommand(uint8_t startReg, uint8_t valueOne, diff --git a/mission/devices/GyroADIS1650XHandler.h b/mission/devices/GyroADIS1650XHandler.h index 60adeabe..b1ac50f5 100644 --- a/mission/devices/GyroADIS1650XHandler.h +++ b/mission/devices/GyroADIS1650XHandler.h @@ -8,7 +8,7 @@ #include "fsfw/globalfunctions/PeriodicOperationDivider.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" -#if OBSW_ADIS16507_LINUX_COM_IF == 1 +#if OBSW_ADIS1650X_LINUX_COM_IF == 1 class SpiComIF; class SpiCookie; #endif @@ -24,7 +24,7 @@ public: GyroADIS1650XHandler(object_id_t objectId, object_id_t deviceCommunication, CookieIF* comCookie, ADIS1650X::Type type); - /* DeviceHandlerBase abstract function implementation */ + // DeviceHandlerBase abstract function implementation void doStartUp() override; void doShutDown() override; ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; @@ -66,7 +66,7 @@ private: BurstModes getBurstMode(); -#if OBSW_ADIS16507_LINUX_COM_IF == 1 +#if OBSW_ADIS1650X_LINUX_COM_IF == 1 static ReturnValue_t spiSendCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sendData, size_t sendLen, void* args); #endif diff --git a/mission/devices/Max31865PT1000Handler.cpp b/mission/devices/Max31865PT1000Handler.cpp index ba9c8e08..750d56e5 100644 --- a/mission/devices/Max31865PT1000Handler.cpp +++ b/mission/devices/Max31865PT1000Handler.cpp @@ -7,10 +7,10 @@ Max31865PT1000Handler::Max31865PT1000Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie): - DeviceHandlerBase(objectId, comIF, comCookie), sensorDataset(this), - sensorDatasetSid(sensorDataset.getSid()) { + DeviceHandlerBase(objectId, comIF, comCookie), + sensorDataset(this), sensorDatasetSid(sensorDataset.getSid()) { #if OBSW_VERBOSE_LEVEL >= 1 - debugDivider = new PeriodicOperationDivider(0); + debugDivider = new PeriodicOperationDivider(10); #endif } @@ -68,12 +68,21 @@ void Max31865PT1000Handler::doStartUp() { if(internalState == InternalState::REQUEST_LOW_THRESHOLD) { if(commandExecuted) { - setMode(MODE_ON); - setMode(MODE_NORMAL); - internalState = InternalState::RUNNING; + internalState = InternalState::CLEAR_FAULT_BYTE; commandExecuted = false; } } + if(internalState == InternalState::CLEAR_FAULT_BYTE) { + if(commandExecuted) { + commandExecuted = false; + internalState = InternalState::RUNNING; + if(instantNormal) { + setMode(MODE_NORMAL); + } else { + setMode(_MODE_TO_ON); + } + } + } } void Max31865PT1000Handler::doShutDown() { @@ -91,6 +100,10 @@ ReturnValue_t Max31865PT1000Handler::buildNormalDeviceCommand( *id = Max31865Definitions::REQUEST_FAULT_BYTE; return buildCommandFromCommand(*id, nullptr, 0); } + else if(internalState == InternalState::CLEAR_FAULT_BYTE) { + *id = Max31865Definitions::CLEAR_FAULT_BYTE; + return buildCommandFromCommand(*id, nullptr, 0); + } else { return DeviceHandlerBase::NOTHING_TO_SEND; } @@ -128,6 +141,10 @@ ReturnValue_t Max31865PT1000Handler::buildTransitionDeviceCommand( *id = Max31865Definitions::REQUEST_LOW_THRESHOLD; return buildCommandFromCommand(*id, nullptr, 0); } + case(InternalState::CLEAR_FAULT_BYTE): { + *id = Max31865Definitions::CLEAR_FAULT_BYTE; + return buildCommandFromCommand(*id, nullptr, 0); + } default: #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -155,6 +172,13 @@ ReturnValue_t Max31865PT1000Handler::buildCommandFromCommand( return DeviceHandlerIF::NO_COMMAND_DATA; } } + case(Max31865Definitions::CLEAR_FAULT_BYTE): { + commandBuffer[0] = static_cast(Max31865Definitions::CONFIG_CMD); + commandBuffer[1] = Max31865Definitions::CLEAR_FAULT_BIT_VAL; + DeviceHandlerBase::rawPacketLen = 2; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; + } case(Max31865Definitions::REQUEST_CONFIG): { commandBuffer[0] = static_cast( Max31865Definitions::REQUEST_CONFIG); @@ -233,6 +257,7 @@ void Max31865PT1000Handler::fillCommandAndReplyMap() { insertInCommandAndReplyMap(Max31865Definitions::REQUEST_RTD, 3, &sensorDataset); insertInCommandAndReplyMap(Max31865Definitions::REQUEST_FAULT_BYTE, 3); + insertInCommandAndReplyMap(Max31865Definitions::CLEAR_FAULT_BYTE, 3); } ReturnValue_t Max31865PT1000Handler::scanForReply(const uint8_t *start, @@ -290,6 +315,15 @@ ReturnValue_t Max31865PT1000Handler::scanForReply(const uint8_t *start, *foundLen = 2; internalState = InternalState::RUNNING; } + else if(internalState == InternalState::CLEAR_FAULT_BYTE) { + *foundId = Max31865Definitions::CLEAR_FAULT_BYTE; + *foundLen = 2; + if(mode == _MODE_START_UP) { + commandExecuted = true; + } else { + internalState = InternalState::RUNNING; + } + } else { *foundId = Max31865Definitions::REQUEST_CONFIG; *foundLen = configReplySize; @@ -306,10 +340,11 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply( if(packet[1] != DEFAULT_CONFIG) { #if FSFW_CPP_OSTREAM_ENABLED == 1 // it propably would be better if we at least try one restart.. - sif::error << "Max31865PT1000Handler: Object ID: " << std::hex << this->getObjectId() - << ": Invalid configuration reply!" << std::endl; + sif::error << "Max31865PT1000Handler: 0x" << std::hex << this->getObjectId() + << ": Invalid configuration reply" << std::endl; #else - sif::printError("Max31865PT1000Handler: Invalid configuration reply!\n"); + sif::printError("Max31865PT1000Handler: %04x: Invalid configuration reply!\n", + this->getObjectId()); #endif return HasReturnvaluesIF::RETURN_OK; } @@ -360,9 +395,14 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply( case(Max31865Definitions::REQUEST_RTD): { // first bit of LSB reply byte is the fault bit uint8_t faultBit = packet[2] & 0b0000'0001; - if(faultBit == 1) { + if(resetFaultBit) { + internalState = InternalState::CLEAR_FAULT_BYTE; + resetFaultBit = false; + } + else if(faultBit == 1) { // Maybe we should attempt to restart it? internalState = InternalState::REQUEST_FAULT_BYTE; + resetFaultBit = true; } // RTD value consists of last seven bits of the LSB reply byte and @@ -495,6 +535,12 @@ ReturnValue_t Max31865PT1000Handler::initializeLocalDataPool(localpool::DataPool return HasReturnvaluesIF::RETURN_OK; } -void Max31865PT1000Handler::modeChanged() { - internalState = InternalState::NONE; +void Max31865PT1000Handler::setInstantNormal(bool instantNormal) { + this->instantNormal = instantNormal; +} + +void Max31865PT1000Handler::modeChanged() { + if(mode == MODE_OFF) { + internalState = InternalState::NONE; + } } diff --git a/mission/devices/Max31865PT1000Handler.h b/mission/devices/Max31865PT1000Handler.h index b33ddbe0..3be16150 100644 --- a/mission/devices/Max31865PT1000Handler.h +++ b/mission/devices/Max31865PT1000Handler.h @@ -45,6 +45,7 @@ public: // 8. 1 for 50 Hz filter, 0 for 60 Hz filter (noise rejection filter) static constexpr uint8_t DEFAULT_CONFIG = 0b11000001; + void setInstantNormal(bool instantNormal); /** * Expected temperature range is -100 C and 100 C. * If there are temperatures beyond this range there must be a fault. @@ -59,7 +60,7 @@ public: static constexpr float RTD_RREF_PT1000 = 4020.0; //!< Ohm static constexpr float RTD_RESISTANCE0_PT1000 = 1000.0; //!< Ohm protected: - /* DeviceHandlerBase abstract function implementation */ + // DeviceHandlerBase abstract function implementation void doStartUp() override; void doShutDown() override; ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; @@ -85,6 +86,7 @@ protected: private: uint8_t switchId = 0; + bool instantNormal = true; enum class InternalState { NONE, @@ -96,12 +98,14 @@ private: REQUEST_LOW_THRESHOLD, REQUEST_CONFIG, RUNNING, - REQUEST_FAULT_BYTE + REQUEST_FAULT_BYTE, + CLEAR_FAULT_BYTE }; InternalState internalState = InternalState::NONE; bool commandExecuted = false; + bool resetFaultBit = false; dur_millis_t startTime = 0; uint8_t faultByte = 0; std::array commandBuffer { 0 }; diff --git a/mission/devices/devicedefinitions/Max31865Definitions.h b/mission/devices/devicedefinitions/Max31865Definitions.h index 9b2aa3a2..c9c8255e 100644 --- a/mission/devices/devicedefinitions/Max31865Definitions.h +++ b/mission/devices/devicedefinitions/Max31865Definitions.h @@ -17,13 +17,17 @@ enum PoolIds: lp_id_t { static constexpr DeviceCommandId_t CONFIG_CMD = 0x80; static constexpr DeviceCommandId_t WRITE_HIGH_THRESHOLD = 0x83; static constexpr DeviceCommandId_t WRITE_LOW_THRESHOLD = 0x85; + static constexpr DeviceCommandId_t REQUEST_CONFIG = 0x00; static constexpr DeviceCommandId_t REQUEST_RTD = 0x01; static constexpr DeviceCommandId_t REQUEST_HIGH_THRESHOLD = 0x03; static constexpr DeviceCommandId_t REQUEST_LOW_THRESHOLD = 0x05; static constexpr DeviceCommandId_t REQUEST_FAULT_BYTE = 0x07; +static constexpr DeviceCommandId_t CLEAR_FAULT_BYTE = 0x08; + static constexpr uint32_t MAX31865_SET_ID = REQUEST_RTD; +static constexpr uint8_t CLEAR_FAULT_BIT_VAL = 0b0000'0010; static constexpr size_t MAX_REPLY_SIZE = 5; From 636c1fdf26b474577ca0bd4c6051025d9f44687a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 20 Dec 2021 13:37:28 +0100 Subject: [PATCH 154/465] added GNSS enable pin handling --- bsp_q7s/boardconfig/busConf.h | 2 ++ bsp_q7s/core/ObjectFactory.cpp | 14 +++++++++++++- linux/fsfwconfig/devices/gpioIds.h | 2 ++ .../pollingsequence/pollingSequenceFactory.cpp | 4 ++-- tmtc | 2 +- 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index 73605471..e6f9ae54 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -31,6 +31,8 @@ namespace gpioNames { static constexpr char MGM_3_CS[] = "mgm_3_rm3100_chip_select"; static constexpr char RESET_GNSS_0[] = "reset_gnss_0"; static constexpr char RESET_GNSS_1[] = "reset_gnss_1"; + static constexpr char GNSS_0_ENABLE[] = "enable_gnss_0"; + static constexpr char GNSS_1_ENABLE[] = "enable_gnss_1"; static constexpr char GYRO_0_ENABLE[] = "enable_gyro_0"; static constexpr char GYRO_2_ENABLE[] = "enable_gyro_2"; static constexpr char HEATER_0[] = "heater0"; diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 558f23b1..3b35f89e 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -468,7 +468,19 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI gpio::LOW); gpioCookieAcsBoard->addGpio(gpioIds::GYRO_2_ENABLE, gpio); - // TODO: Add enable pins for GPS as soon as new interface board design is finished + // Enable pins for GNSS + consumer.str(""); + consumer << "0x" << std::hex << objects::GPS0_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GNSS_0_ENABLE, consumer.str(), + gpio::DIR_OUT, gpio::LOW); + gpioCookieAcsBoard->addGpio(gpioIds::GNSS_0_ENABLE, gpio); + + consumer.str(""); + consumer << "0x" << std::hex << objects::GPS1_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GNSS_1_ENABLE, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + gpioCookieAcsBoard->addGpio(gpioIds::GNSS_1_ENABLE, gpio); + gpioComIF->addGpios(gpioCookieAcsBoard); std::string spiDev = q7s::SPI_DEFAULT_DEV; diff --git a/linux/fsfwconfig/devices/gpioIds.h b/linux/fsfwconfig/devices/gpioIds.h index 8d3f94ca..e4b9f727 100644 --- a/linux/fsfwconfig/devices/gpioIds.h +++ b/linux/fsfwconfig/devices/gpioIds.h @@ -27,6 +27,8 @@ enum gpioId_t { GNSS_0_NRESET, GNSS_1_NRESET, + GNSS_0_ENABLE, + GNSS_1_ENABLE, GYRO_0_ENABLE, GYRO_2_ENABLE, diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 19d9b2de..be38fd89 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -439,8 +439,8 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { #endif #if OBSW_ADD_ACS_BOARD == 1 - bool enableAside = true; - bool enableBside = false; + bool enableAside = false; + bool enableBside = true; if(enableAside) { // A side thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0, diff --git a/tmtc b/tmtc index 8cfc2892..1c2f09ad 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 8cfc2892dd95f959edb4b0ec1bbc8fc4aaa69ef2 +Subproject commit 1c2f09adc8c775cf84cfab860da165a319a756af From 36d33711a7fe34fa32d9f1c0b32eeeff28e9a5c4 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 21 Dec 2021 15:46:09 +0100 Subject: [PATCH 155/465] flash write command --- bsp_q7s/core/ObjectFactory.cpp | 2 +- bsp_q7s/devices/startracker/CMakeLists.txt | 2 +- .../startracker/StarTrackerDefinitions.h | 2 +- .../startracker/StarTrackerHandler.cpp | 88 +++++++-- .../devices/startracker/StarTrackerHandler.h | 28 ++- .../{StrImageLoader.cpp => StrHelper.cpp} | 186 ++++++++++++++---- .../{StrImageLoader.h => StrHelper.h} | 121 +++++++++--- common/config/commonClassIds.h | 2 +- common/config/commonSubsystemIds.h | 2 +- tmtc | 2 +- 10 files changed, 339 insertions(+), 96 deletions(-) rename bsp_q7s/devices/startracker/{StrImageLoader.cpp => StrHelper.cpp} (57%) rename bsp_q7s/devices/startracker/{StrImageLoader.h => StrHelper.h} (57%) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 168f6de8..92600caf 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -1,6 +1,7 @@ #include #include "ObjectFactory.h" +#include "../devices/startracker/StrHelper.h" #include "bsp_q7s/devices/startracker/StarTrackerDefinitions.h" #include "OBSWConfig.h" #include "devConf.h" @@ -18,7 +19,6 @@ #include "bsp_q7s/devices/PlocSupervisorHandler.h" #include "bsp_q7s/devices/PlocUpdater.h" #include "bsp_q7s/devices/PlocMemoryDumper.h" -#include "bsp_q7s/devices/startracker/StrImageLoader.h" #include "bsp_q7s/devices/startracker/StarTrackerHandler.h" #include "bsp_q7s/callbacks/rwSpiCallback.h" #include "bsp_q7s/callbacks/gnssCallback.h" diff --git a/bsp_q7s/devices/startracker/CMakeLists.txt b/bsp_q7s/devices/startracker/CMakeLists.txt index 81f0492f..28704219 100644 --- a/bsp_q7s/devices/startracker/CMakeLists.txt +++ b/bsp_q7s/devices/startracker/CMakeLists.txt @@ -3,5 +3,5 @@ target_sources(${TARGET_NAME} PRIVATE StarTrackerJsonCommands.cpp ArcsecDatalinkLayer.cpp ArcsecJsonParamBase.cpp - StrImageLoader.cpp + StrHelper.cpp ) \ No newline at end of file diff --git a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h index 425c69d0..22214cb0 100644 --- a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h +++ b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h @@ -4,6 +4,7 @@ #include #include #include +#include #include "objects/systemObjectList.h" #include @@ -844,7 +845,6 @@ public: sif::info << "ContrastSet::printSet: BinD8: " << this->binD8 << std::endl; } }; - } #endif /* MISSION_STARTRACKER_DEFINITIONS_H_ */ diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp index 087d2bfa..6e0d54e0 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp @@ -14,14 +14,14 @@ extern "C" { } StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie, StrImageLoader* strImageLoader) : + CookieIF * comCookie, StrHelper* strHelper) : DeviceHandlerBase(objectId, comIF, comCookie), temperatureSet(this), versionSet(this), powerSet( this), interfaceSet(this), timeSet(this), solutionSet(this), histogramSet(this), - contrastSet(this), strImageLoader(strImageLoader) { + contrastSet(this), strHelper(strHelper) { if (comCookie == nullptr) { sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl; } - if (strImageLoader == nullptr) { + if (strHelper == nullptr) { sif::error << "StarTrackerHandler: Invalid str image loader" << std::endl; } eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5); @@ -50,21 +50,21 @@ ReturnValue_t StarTrackerHandler::initialize() { return result; } result = manager->subscribeToEventRange(eventQueue->getId(), - event::getEventId(StrImageLoader::IMAGE_UPLOAD_FAILED), - event::getEventId(StrImageLoader::IMAGE_DOWNLOAD_SUCCESSFUL)); + event::getEventId(StrHelper::IMAGE_UPLOAD_FAILED), + event::getEventId(StrHelper::FLASH_READ_FAILED)); if (result != RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "StarTrackerHandler::initialize: Failed to subscribe to events form image" - " loader" << std::endl; + sif::warning << "StarTrackerHandler::initialize: Failed to subscribe to events from " + " str helper" << std::endl; #endif return ObjectManagerIF::CHILD_INIT_FAILED; } - result = strImageLoader->setComIF(communicationInterface); + result = strHelper->setComIF(communicationInterface); if (result != RETURN_OK) { return ObjectManagerIF::CHILD_INIT_FAILED; } - strImageLoader->setComCookie(comCookie); + strHelper->setComCookie(comCookie); return RETURN_OK; } @@ -75,7 +75,7 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu switch(actionId) { case(StarTracker::STOP_IMAGE_LOADER): { - strImageLoader->stopProcess(); + strHelper->stopProcess(); return EXECUTION_FINISHED; } case(StarTracker::SET_JSON_FILE_NAME): { @@ -89,7 +89,7 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu break; } - if (imageLoaderExecuting == true) { + if (strHelperExecuting == true) { return IMAGE_LOADER_EXECUTING; } @@ -108,12 +108,12 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu if (size > MAX_PATH_SIZE) { return FILE_PATH_TOO_LONG; } - result = strImageLoader->startImageUpload( + result = strHelper->startImageUpload( std::string(reinterpret_cast(data), size)); if (result != RETURN_OK) { return result; } - imageLoaderExecuting = true; + strHelperExecuting = true; return EXECUTION_FINISHED; } case(StarTracker::DOWNLOAD_IMAGE): { @@ -124,19 +124,32 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu if (size > MAX_PATH_SIZE) { return FILE_PATH_TOO_LONG; } - result = strImageLoader->startImageDownload( + result = strHelper->startImageDownload( std::string(reinterpret_cast(data), size)); if (result != RETURN_OK) { return result; } - imageLoaderExecuting = true; + strHelperExecuting = true; + return EXECUTION_FINISHED; + } + case(StarTracker::WRITE): { + result = DeviceHandlerBase::acceptExternalDeviceCommands(); + if (result != RETURN_OK) { + return result; + } + result = executeWriteCommand(data, size); + if (result != RETURN_OK) { + return result; + } + + strHelperExecuting = true; return EXECUTION_FINISHED; } case(StarTracker::CHANGE_DOWNLOAD_FILE): { if (size > MAX_FILE_NAME) { return FILENAME_TOO_LONG; } - strImageLoader->setDownloadImageName( + strHelper->setDownloadImageName( std::string(reinterpret_cast(data), size)); return EXECUTION_FINISHED; } @@ -182,7 +195,7 @@ void StarTrackerHandler::doStartUp() { void StarTrackerHandler::doShutDown() { // If star tracker is shutdown also stop all running processes in the image loader task - strImageLoader->stopProcess(); + strHelper->stopProcess(); setMode(_MODE_POWER_DOWN); } @@ -751,7 +764,7 @@ size_t StarTrackerHandler::getNextReplyLength(DeviceCommandId_t commandId){ ReturnValue_t StarTrackerHandler::doSendReadHook() { // Prevent DHB from polling UART during commands executed by the image loader task - if(imageLoaderExecuting) { + if(strHelperExecuting) { return RETURN_FAILED; } return RETURN_OK; @@ -776,6 +789,10 @@ ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t *foundId) *foundId = StarTracker::PING_REQUEST; break; } + case (StarTracker::ID::WRITE): { + *foundId = StarTracker::WRITE; + break; + } case (StarTracker::ID::BOOT): { *foundId = StarTracker::BOOT; break; @@ -906,7 +923,7 @@ void StarTrackerHandler::handleEvent(EventMessage* eventMessage) { case objects::STR_IMG_LOADER: { // All events from image loader signal either that the operation was successful or that it // failed - imageLoaderExecuting = false; + strHelperExecuting = false; break; } default: @@ -916,6 +933,39 @@ void StarTrackerHandler::handleEvent(EventMessage* eventMessage) { } } +ReturnValue_t StarTrackerHandler::executeWriteCommand(const uint8_t* commandData, + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + if (commandDataLen < WriteCmd::MIN_LENGTH) { + sif::warning << "StarTrackerHandler::executeWriteCommand: Command too short" << std::endl; + return COMMAND_TOO_SHORT; + } + uint8_t region = *(commandData); + uint32_t address; + size_t size = sizeof(address); + const uint8_t* addressPtr = commandData + WriteCmd::ADDRESS_OFFSET; + result = SerializeAdapter::deSerialize(&address, addressPtr, &size, + SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of address failed" + << std::endl; + return result; + } + if (commandDataLen - sizeof(address) - sizeof(region) > MAX_PATH_SIZE) { + sif::warning << "StarTrackerHandler::executeWriteCommand: Received command with invalid" + << " path and filename" << std::endl; + return FILE_PATH_TOO_LONG; + } + const uint8_t* filePtr = commandData + WriteCmd::FILE_OFFSET; + std::string fullname = std::string(reinterpret_cast(filePtr), + commandDataLen - sizeof(address) - sizeof(region)); + result = strHelper->startFlashWrite(fullname, region, address); + if (result != RETURN_OK) { + return result; + } + return result; +} + void StarTrackerHandler::prepareBootCommand() { uint32_t length = 0; struct BootActionRequest bootRequest = {BOOT_REGION_ID}; diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.h b/bsp_q7s/devices/startracker/StarTrackerHandler.h index e534f590..8761f1ce 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.h +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.h @@ -6,10 +6,10 @@ #include "fsfw/timemanager/Countdown.h" #include "thirdparty/arcsec_star_tracker/common/SLIP.h" #include -#include "StrImageLoader.h" #include "ArcsecDataLinkLayer.h" #include "StarTrackerDefinitions.h" #include "ArcsecJsonParamBase.h" +#include "StrHelper.h" /** * @brief This is the device handler for the star tracker from arcsec. @@ -33,7 +33,7 @@ public: * to high to enable the device. */ StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie, - StrImageLoader* strImageLoader); + StrHelper* strHelper); virtual ~StarTrackerHandler(); ReturnValue_t initialize() override; @@ -115,6 +115,8 @@ private: static const ReturnValue_t TM_REPLY_ERROR = MAKE_RETURN_CODE(0xAE); //! [EXPORT] : [COMMENT] Status field of contrast reply signals error static const ReturnValue_t CONTRAST_REQ_FAILED = MAKE_RETURN_CODE(0xAE); + //! [EXPORT] : [COMMENT] Received command which is too short (some data is missing for proper execution) + static const ReturnValue_t COMMAND_TOO_SHORT = MAKE_RETURN_CODE(0xAF); static const size_t MAX_PATH_SIZE = 50; static const size_t MAX_FILE_NAME = 30; @@ -137,6 +139,14 @@ private: static const uint32_t MUTEX_TIMEOUT = 20; static const uint32_t BOOT_TIMEOUT = 1000; + class WriteCmd { + public: + static const uint8_t ADDRESS_OFFSET = 1; + static const uint8_t FILE_OFFSET = 5; + // Minimum length of a write command (region, address and filename) + static const size_t MIN_LENGTH = 7; + }; + MessageQueueIF* eventQueue = nullptr; ArcsecDatalinkLayer dataLinkLayer; @@ -151,7 +161,7 @@ private: StarTracker::ContrastSet contrastSet; // Pointer to object responsible for uploading and downloading images to/from the star tracker - StrImageLoader* strImageLoader = nullptr; + StrHelper* strHelper = nullptr; uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE]; @@ -187,7 +197,7 @@ private: StartupState startupState = StartupState::IDLE; - bool imageLoaderExecuting = false; + bool strHelperExecuting = false; /** * @brief Handles internal state @@ -225,6 +235,16 @@ private: */ void handleEvent(EventMessage* eventMessage); + /** + * @brief Executes the write command + * + * @param commandData Pointer to received command data + * @param commandDataLen Size of received command data + * + * @return RETURN_OK if start of execution was successful, otherwise error return value + */ + ReturnValue_t executeWriteCommand(const uint8_t* commandData, size_t commandDataLen); + /** * @brief Fills command buffer with data to boot image (works only when star tracker is * in bootloader mode). diff --git a/bsp_q7s/devices/startracker/StrImageLoader.cpp b/bsp_q7s/devices/startracker/StrHelper.cpp similarity index 57% rename from bsp_q7s/devices/startracker/StrImageLoader.cpp rename to bsp_q7s/devices/startracker/StrHelper.cpp index 495ec3a8..a3d28305 100644 --- a/bsp_q7s/devices/startracker/StrImageLoader.cpp +++ b/bsp_q7s/devices/startracker/StrHelper.cpp @@ -1,26 +1,27 @@ -#include "StrImageLoader.h" +#include "StrHelper.h" + #include "mission/utility/Timestamp.h" #include #include -StrImageLoader::StrImageLoader(object_id_t objectId) : SystemObject(objectId){ +StrHelper::StrHelper(object_id_t objectId) : SystemObject(objectId){ } -StrImageLoader::~StrImageLoader() { +StrHelper::~StrHelper() { } -ReturnValue_t StrImageLoader::initialize() { +ReturnValue_t StrHelper::initialize() { sdcMan = SdCardManager::instance(); if (sdcMan == nullptr) { - sif::warning << "StrImageLoader::initialize: Invalid SD Card Manager" << std::endl; + sif::warning << "StrHelper::initialize: Invalid SD Card Manager" << std::endl; return RETURN_FAILED; } return RETURN_OK; } -ReturnValue_t StrImageLoader::performOperation(uint8_t operationCode) { +ReturnValue_t StrHelper::performOperation(uint8_t operationCode) { ReturnValue_t result = RETURN_OK; semaphore.acquire(); while(true) { @@ -40,7 +41,7 @@ ReturnValue_t StrImageLoader::performOperation(uint8_t operationCode) { internalState = InternalState::IDLE; break; } - case InternalState::DOWNLOAD_IMAGE: + case InternalState::DOWNLOAD_IMAGE: { result = performImageDownload(); if (result == RETURN_OK){ triggerEvent(IMAGE_DOWNLOAD_SUCCESSFUL); @@ -51,23 +52,38 @@ ReturnValue_t StrImageLoader::performOperation(uint8_t operationCode) { internalState = InternalState::IDLE; break; } + case InternalState::FLASH_WRITE: { + result = performFlashWrite(); + if (result == RETURN_OK){ + triggerEvent(FLASH_WRITE_SUCCESSFUL); + } + else { + triggerEvent(FLASH_WRITE_FAILED); + } + internalState = InternalState::IDLE; + break; + } + default: + sif::debug << "StrHelper::performOperation: Invalid state" << std::endl; + break; + } } } -ReturnValue_t StrImageLoader::setComIF(DeviceCommunicationIF* communicationInterface_) { +ReturnValue_t StrHelper::setComIF(DeviceCommunicationIF* communicationInterface_) { uartComIF = dynamic_cast(communicationInterface_); if (uartComIF == nullptr) { - sif::warning << "StrImageLoader::initialize: Invalid uart com if" << std::endl; + sif::warning << "StrHelper::initialize: Invalid uart com if" << std::endl; return RETURN_FAILED; } return RETURN_OK; } -void StrImageLoader::setComCookie(CookieIF* comCookie_) { +void StrHelper::setComCookie(CookieIF* comCookie_) { comCookie = comCookie_; } -ReturnValue_t StrImageLoader::startImageUpload(std::string uploadImage_) { +ReturnValue_t StrHelper::startImageUpload(std::string uploadImage_) { ReturnValue_t result = checkPath(uploadImage_); if (result != RETURN_OK) { return result; @@ -82,7 +98,7 @@ ReturnValue_t StrImageLoader::startImageUpload(std::string uploadImage_) { return RETURN_OK; } -ReturnValue_t StrImageLoader::startImageDownload(std::string downloadPath_) { +ReturnValue_t StrHelper::startImageDownload(std::string downloadPath_) { ReturnValue_t result = checkPath(downloadPath_); if (result != RETURN_OK) { return result; @@ -97,15 +113,31 @@ ReturnValue_t StrImageLoader::startImageDownload(std::string downloadPath_) { return RETURN_OK; } -void StrImageLoader::stopProcess() { +void StrHelper::stopProcess() { terminate = true; } -void StrImageLoader::setDownloadImageName(std::string image) { +void StrHelper::setDownloadImageName(std::string image) { downloadImage = image; } -ReturnValue_t StrImageLoader::performImageDownload() { +ReturnValue_t StrHelper::startFlashWrite(std::string flashWriteFile_, uint8_t region, + uint32_t flashWriteAddress) { + ReturnValue_t result = checkPath(flashWriteFile_); + if (result != RETURN_OK) { + return result; + } + flashWriteFile = flashWriteFile_; + if(not std::filesystem::exists(flashWriteFile)) { + return FILE_NOT_EXISTS; + } + internalState = InternalState::FLASH_WRITE; + semaphore.release(); + terminate = false; + return RETURN_OK; +} + +ReturnValue_t StrHelper::performImageDownload() { ReturnValue_t result; struct DownloadActionRequest downloadReq; uint32_t size = 0; @@ -161,7 +193,7 @@ ReturnValue_t StrImageLoader::performImageDownload() { return RETURN_OK; } -ReturnValue_t StrImageLoader::performImageUpload() { +ReturnValue_t StrHelper::performImageUpload() { ReturnValue_t result = RETURN_OK; uint32_t size = 0; uint32_t imageSize = 0; @@ -169,7 +201,7 @@ ReturnValue_t StrImageLoader::performImageUpload() { uploadReq.position = 0; std::memset(&uploadReq.data, 0, sizeof(uploadReq.data)); if (not std::filesystem::exists(uploadImage)) { - triggerEvent(IMAGE_FILE_NOT_EXISTS, uploadReq.position); + triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast(internalState)); internalState = InternalState::IDLE; return RETURN_FAILED; } @@ -213,7 +245,57 @@ ReturnValue_t StrImageLoader::performImageUpload() { return RETURN_OK; } -ReturnValue_t StrImageLoader::sendAndRead(size_t size, uint32_t position) { +ReturnValue_t StrHelper::performFlashWrite() { + ReturnValue_t result = RETURN_OK; + uint32_t size = 0; + uint32_t remainingBytes = 0; + uint32_t fileSize = 0; + struct WriteActionRequest req; + if (not std::filesystem::exists(flashWriteFile)) { + triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast(internalState)); + internalState = InternalState::IDLE; + return RETURN_FAILED; + } + std::ifstream file(flashWriteFile, std::ifstream::binary); + file.seekg(0, file.end); + fileSize = file.tellg(); + remainingBytes = fileSize; + req.region = flashWriteRegion; + req.address = flashWriteAddress; + req.length = MAX_FLASH_DATA; + while(remainingBytes >= MAX_FLASH_DATA) { + if (terminate) { + return RETURN_OK; + } + file.seekg(fileSize - remainingBytes, file.beg); + file.read(reinterpret_cast(req.data), MAX_FLASH_DATA); + arc_pack_write_action_req(&req, commandBuffer, &size); + result = sendAndRead(size, req.address); + if (result != RETURN_OK) { + return RETURN_FAILED; + } + result = checkFlashWriteReply(req); + if (result != RETURN_OK) { + return result; + } + remainingBytes = remainingBytes - MAX_FLASH_DATA; + } + file.seekg(fileSize - remainingBytes, file.beg); + file.read(reinterpret_cast(req.data), remainingBytes); + file.close(); + arc_pack_write_action_req(&req, commandBuffer, &size); + result = sendAndRead(size, req.address); + if (result != RETURN_OK) { + return RETURN_FAILED; + } + result = checkFlashWriteReply(req); + if (result != RETURN_OK) { + return result; + } + return RETURN_OK; +} + +ReturnValue_t StrHelper::sendAndRead(size_t size, uint32_t parameter) { ReturnValue_t result = RETURN_OK; ReturnValue_t decResult = RETURN_OK; size_t receivedDataLen = 0; @@ -224,8 +306,8 @@ ReturnValue_t StrImageLoader::sendAndRead(size_t size, uint32_t position) { result = uartComIF->sendMessage(comCookie, datalinkLayer.getEncodedFrame(), datalinkLayer.getEncodedLength()); if (result != RETURN_OK) { - sif::warning << "StrImageLoader::sendAndRead: Failed to send packet" << std::endl; - triggerEvent(IMG_LOADER_SENDING_PACKET_FAILED, result, position); + sif::warning << "StrHelper::sendAndRead: Failed to send packet" << std::endl; + triggerEvent(STR_HELPER_SENDING_PACKET_FAILED, result, parameter); return RETURN_FAILED; } decResult = ArcsecDatalinkLayer::DEC_IN_PROGRESS; @@ -233,14 +315,14 @@ ReturnValue_t StrImageLoader::sendAndRead(size_t size, uint32_t position) { result = uartComIF->requestReceiveMessage(comCookie, StarTracker::MAX_FRAME_SIZE * 2 + 2); if (result != RETURN_OK) { - sif::warning << "StrImageLoader::sendAndRead: Failed to request reply" << std::endl; - triggerEvent(IMG_LOADER_REQUESTING_MSG_FAILED, result, position); + sif::warning << "StrHelper::sendAndRead: Failed to request reply" << std::endl; + triggerEvent(STR_HELPER_REQUESTING_MSG_FAILED, result, parameter); return RETURN_FAILED; } result = uartComIF->readReceivedMessage(comCookie, &receivedData, &receivedDataLen); if (result != RETURN_OK) { - sif::warning << "StrImageLoader::sendAndRead: Failed to read received message" << std::endl; - triggerEvent(IMG_LOADER_READING_REPLY_FAILED, result, position); + sif::warning << "StrHelper::sendAndRead: Failed to read received message" << std::endl; + triggerEvent(STR_HELPER_READING_REPLY_FAILED, result, parameter); return RETURN_FAILED; } if (receivedDataLen == 0 && missedReplies < MAX_POLLS) { @@ -248,7 +330,7 @@ ReturnValue_t StrImageLoader::sendAndRead(size_t size, uint32_t position) { continue; } else if ((receivedDataLen == 0) && (missedReplies >= MAX_POLLS)) { - triggerEvent(IMG_LOADER_NO_REPLY, position); + triggerEvent(STR_HELPER_NO_REPLY, parameter); return RETURN_FAILED; } else { @@ -257,22 +339,22 @@ ReturnValue_t StrImageLoader::sendAndRead(size_t size, uint32_t position) { decResult = datalinkLayer.decodeFrame(receivedData, receivedDataLen, &bytesLeft); if (bytesLeft != 0) { // This should never happen - sif::warning << "StrImageLoader::sendAndRead: Bytes left after decoding" << std::endl; - triggerEvent(IMG_LOADER_COM_ERROR, result, position); + sif::warning << "StrHelper::sendAndRead: Bytes left after decoding" << std::endl; + triggerEvent(STR_HELPER_COM_ERROR, result, parameter); return RETURN_FAILED; } } if (decResult != RETURN_OK) { - triggerEvent(IMG_LOADER_DEC_ERROR, decResult, position); + triggerEvent(STR_HELPER_DEC_ERROR, decResult, parameter); return RETURN_FAILED; } return RETURN_OK; } -ReturnValue_t StrImageLoader::checkReply() { +ReturnValue_t StrHelper::checkReply() { uint8_t type = datalinkLayer.getReplyFrameType(); if (type != TMTC_ACTIONREPLY) { - sif::warning << "StrImageLoader::checkReply: Received reply with invalid type ID" + sif::warning << "StrHelper::checkReply: Received reply with invalid type ID" << std::endl; triggerEvent(INVALID_TYPE_ID); return RETURN_FAILED; @@ -280,13 +362,13 @@ ReturnValue_t StrImageLoader::checkReply() { uint8_t status = datalinkLayer.getStatusField(); if (status != ArcsecDatalinkLayer::STATUS_OK) { triggerEvent(STATUS_ERROR); - sif::warning << "StrImageLoader::checkReply: Status failure" << std::endl; + sif::warning << "StrHelper::checkReply: Status failure" << std::endl; return RETURN_FAILED; } return RETURN_OK; } -ReturnValue_t StrImageLoader::checkReplyPosition(uint32_t expectedPosition) { +ReturnValue_t StrHelper::checkReplyPosition(uint32_t expectedPosition) { uint32_t receivedPosition = 0; std::memcpy(&receivedPosition, datalinkLayer.getReply() + POS_OFFSET, sizeof(receivedPosition)); if (receivedPosition != expectedPosition) { @@ -296,17 +378,51 @@ ReturnValue_t StrImageLoader::checkReplyPosition(uint32_t expectedPosition) { return RETURN_OK; } -ReturnValue_t StrImageLoader::checkPath(std::string name) { +ReturnValue_t StrHelper::checkFlashWriteReply(struct WriteActionRequest& req) { + ReturnValue_t result = RETURN_OK; + const uint8_t* data = datalinkLayer.getReply(); + uint8_t region = *(data + REGION_OFFSET); + uint32_t address; + const uint8_t* addressData = data + ADDRESS_OFFSET; + size_t size = sizeof(address); + result = SerializeAdapter::deSerialize(&address, &addressData, &size, + SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StrHelper::checkFlashWriteReply: Deserialization of address failed" + << std::endl; + } + uint16_t length; + size = sizeof(length); + const uint8_t* lengthData = data + LENGTH_OFFSET; + result = SerializeAdapter::deSerialize(&length, lengthData, &size, + SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StrHelper::checkFlashWriteReply: Deserialization of length failed" + << std::endl; + } + if (region != req.region) { + return REGION_MISMATCH; + } + if (address != req.address) { + return ADDRESS_MISMATCH; + } + if (region != req.length) { + return LENGTH_MISMATCH; + } + return RETURN_OK; +} + +ReturnValue_t StrHelper::checkPath(std::string name) { if (name.substr(0, sizeof(SdCardManager::SD_0_MOUNT_POINT)) == std::string(SdCardManager::SD_0_MOUNT_POINT)) { if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { - sif::warning << "StrImageLoader::checkPath: SD card 0 not mounted" << std::endl; + sif::warning << "StrHelper::checkPath: SD card 0 not mounted" << std::endl; return SD_NOT_MOUNTED; } } else if (name.substr(0, sizeof(SdCardManager::SD_1_MOUNT_POINT)) == std::string(SdCardManager::SD_1_MOUNT_POINT)) { if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { - sif::warning << "StrImageLoader::checkPath: SD card 1 not mounted" << std::endl; + sif::warning << "StrHelper::checkPath: SD card 1 not mounted" << std::endl; return SD_NOT_MOUNTED; } } diff --git a/bsp_q7s/devices/startracker/StrImageLoader.h b/bsp_q7s/devices/startracker/StrHelper.h similarity index 57% rename from bsp_q7s/devices/startracker/StrImageLoader.h rename to bsp_q7s/devices/startracker/StrHelper.h index 50fe3e92..f7a994b4 100644 --- a/bsp_q7s/devices/startracker/StrImageLoader.h +++ b/bsp_q7s/devices/startracker/StrHelper.h @@ -1,5 +1,5 @@ -#ifndef BSP_Q7S_DEVICES_STRIMAGELOADER_H_ -#define BSP_Q7S_DEVICES_STRIMAGELOADER_H_ +#ifndef BSP_Q7S_DEVICES_STRHELPER_H_ +#define BSP_Q7S_DEVICES_STRHELPER_H_ #include #include "ArcsecDatalinkLayer.h" @@ -17,15 +17,12 @@ extern "C" { } /** - * @brief An object of this class runs in a separate task and is responsible for uploading and - * downloading images to/from the star tracker. This is required because uploading and - * downloading via the star tracker handler takes a lot of time because each upload or - * download packet can transport a maximum of 1024 bytes. + * @brief Helper class for the star tracker handler to accelerate large data transfers. */ -class StrImageLoader: public SystemObject, public ExecutableObjectIF, public HasReturnvaluesIF { +class StrHelper: public SystemObject, public ExecutableObjectIF, public HasReturnvaluesIF { public: - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_IMAGE_LOADER; + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_HELPER; //! [EXPORT] : [COMMENT] Image upload failed static const Event IMAGE_UPLOAD_FAILED = MAKE_EVENT(0, severity::LOW); @@ -35,41 +32,50 @@ public: static const Event IMAGE_UPLOAD_SUCCESSFUL = MAKE_EVENT(2, severity::LOW); //! [EXPORT] : [COMMENT] Image download was successful static const Event IMAGE_DOWNLOAD_SUCCESSFUL = MAKE_EVENT(3, severity::LOW); + //! [EXPORT] : [COMMENT] Finished flash write procedure successfully + static const Event FLASH_WRITE_SUCCESSFUL = MAKE_EVENT(4, severity::LOW); + //! [EXPORT] : [COMMENT] Finished flash read procedure successfully + static const Event FLASH_READ_SUCCESSFUL = MAKE_EVENT(5, severity::LOW); + //! [EXPORT] : [COMMENT] Flash write procedure failed + static const Event FLASH_WRITE_FAILED = MAKE_EVENT(6, severity::LOW); + //! [EXPORT] : [COMMENT] Flash read procedure failed + static const Event FLASH_READ_FAILED = MAKE_EVENT(7, severity::LOW); //! [EXPORT] : [COMMENT] Failed to read communication interface reply data //!P1: Return code of failed communication interface read call //!P1: Upload/download position for which the read call failed - static const Event IMG_LOADER_READING_REPLY_FAILED = MAKE_EVENT(4, severity::LOW); + static const Event STR_HELPER_READING_REPLY_FAILED = MAKE_EVENT(8, severity::LOW); //! [EXPORT] : [COMMENT] Unexpected stop of decoding sequence //!P1: Return code of failed communication interface read call //!P1: Upload/download position for which the read call failed - static const Event IMG_LOADER_COM_ERROR = MAKE_EVENT(5, severity::LOW); + static const Event STR_HELPER_COM_ERROR = MAKE_EVENT(9, severity::LOW); //! [EXPORT] : [COMMENT] Star tracker did not send replies (maybe device is powered off) //!P1: Position of upload or download packet for which no reply was sent - static const Event IMG_LOADER_NO_REPLY = MAKE_EVENT(6, severity::LOW); + static const Event STR_HELPER_NO_REPLY = MAKE_EVENT(10, severity::LOW); //! [EXPORT] : [COMMENT] Received reply with invalid type ID - static const Event INVALID_TYPE_ID = MAKE_EVENT(7, severity::LOW); + static const Event INVALID_TYPE_ID = MAKE_EVENT(11, severity::LOW); //! [EXPORT] : [COMMENT] Status field in reply signals error - static const Event STATUS_ERROR = MAKE_EVENT(8, severity::LOW); + static const Event STATUS_ERROR = MAKE_EVENT(12, severity::LOW); //! [EXPORT] : [COMMENT] Error during decoding of received reply occurred //P1: Return value of decoding function - //P2: Position of upload/download packet for which reply decoding failed - static const Event IMG_LOADER_DEC_ERROR = MAKE_EVENT(9, severity::LOW); + //P2: Position of upload/download packet, or address of flash write/read request + static const Event STR_HELPER_DEC_ERROR = MAKE_EVENT(13, severity::LOW); //! [EXPORT] : [COMMENT] Position mismatch //! P1: The expected position and thus the position for which the image upload/download failed - static const Event POSITION_MISMATCH = MAKE_EVENT(10, severity::LOW); - //! [EXPORT] : [COMMENT] Try to upload image but specified image does not exist - static const Event IMAGE_FILE_NOT_EXISTS = MAKE_EVENT(11, severity::LOW); - //! [EXPORT] : [COMMENT] Sending packet (download or upload) to star tracker failed + static const Event POSITION_MISMATCH = MAKE_EVENT(14, severity::LOW); + //! [EXPORT] : [COMMENT] Specified file does not exist + //!P1: Internal state of str helper + static const Event STR_HELPER_FILE_NOT_EXISTS = MAKE_EVENT(15, severity::LOW); + //! [EXPORT] : [COMMENT] Sending packet to star tracker failed //!P1: Return code of communication interface sendMessage function - //!P2: Position of upload/download packet for which the transmission failed - static const Event IMG_LOADER_SENDING_PACKET_FAILED = MAKE_EVENT(12, severity::LOW); + //!P2: Position of upload/download packet, or address of flash write/read request for which sending failed + static const Event STR_HELPER_SENDING_PACKET_FAILED = MAKE_EVENT(16, severity::LOW); //! [EXPORT] : [COMMENT] Communication interface requesting reply failed //!P1: Return code of failed request - //!P1: Upload/download position for which the request failed - static const Event IMG_LOADER_REQUESTING_MSG_FAILED = MAKE_EVENT(13, severity::LOW); + //!P1: Upload/download position, or address of flash write/read request for which transmission failed + static const Event STR_HELPER_REQUESTING_MSG_FAILED = MAKE_EVENT(17, severity::LOW); - StrImageLoader(object_id_t objectId); - virtual ~StrImageLoader(); + StrHelper(object_id_t objectId); + virtual ~StrHelper(); ReturnValue_t initialize() override; ReturnValue_t performOperation(uint8_t operationCode = 0) override; @@ -93,7 +99,17 @@ public: ReturnValue_t startImageDownload(std::string downloadPath_); /** - * @brief Can be used to interrupt a running upload or download process. + * @brief Starts the flash write procedure + * + * @param flashWriteFile_ Full name including absolute path of file to write to flash + * @param region Region ID of flash region to write to + * @param flashWriteAddress Start address of flash write procedure + */ + ReturnValue_t startFlashWrite(std::string flashWriteFile_, uint8_t region, + uint32_t flashWriteAddress); + + /** + * @brief Can be used to interrupt a running data transfer. */ void stopProcess(); @@ -104,7 +120,7 @@ public: private: - static const uint8_t INTERFACE_ID = CLASS_ID::STR_IMG_LOADER; + static const uint8_t INTERFACE_ID = CLASS_ID::STR_HELPER; //! [EXPORT] : [COMMENT] SD card specified in path string not mounted static const ReturnValue_t SD_NOT_MOUNTED = MAKE_RETURN_CODE(0xA0); @@ -112,8 +128,14 @@ private: static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xA1); //! [EXPORT] : [COMMENT] Specified path does not exist static const ReturnValue_t PATH_NOT_EXISTS = MAKE_RETURN_CODE(0xA2); - //! [EXPORT] : [COMMENT] Failed to create download file + //! [EXPORT] : [COMMENT] Failed to create download image or read flash file static const ReturnValue_t FILE_CREATION_FAILED = MAKE_RETURN_CODE(0xA3); + //! [EXPORT] : [COMMENT] Region in flash write/read reply does not match expected region + static const ReturnValue_t REGION_MISMATCH = MAKE_RETURN_CODE(0xA4); + //! [EXPORT] : [COMMENT] Address in flash write/read reply does not match expected address + static const ReturnValue_t ADDRESS_MISMATCH = MAKE_RETURN_CODE(0xA5); + //! [EXPORT] : [COMMENT] Length in flash write/read reply does not match expected length + static const ReturnValue_t LENGTH_MISMATCH = MAKE_RETURN_CODE(0xA6); // Size of one image part which can be sent per action request static const size_t SIZE_IMAGE_PART = 1024; @@ -124,13 +146,19 @@ private: static const uint8_t POS_OFFSET = 2; static const uint8_t DATA_OFFSET = 5; + static const uint8_t REGION_OFFSET = 2; + static const uint8_t ADDRESS_OFFSET = 3; + static const uint8_t LENGTH_OFFSET = 7; static const size_t IMAGE_DATA_SIZE = 1024; + static const size_t MAX_FLASH_DATA = 1024; static const size_t CONFIG_MAX_DOWNLOAD_RETRIES = 3; enum class InternalState { IDLE, UPLOAD_IMAGE, - DOWNLOAD_IMAGE + DOWNLOAD_IMAGE, + FLASH_WRITE, + FLASH_READ }; InternalState internalState = InternalState::IDLE; @@ -143,9 +171,20 @@ private: std::string uploadImage; // Path where the downloaded image will be stored std::string downloadPath; + // File which contains data to write when executing the flash write command + std::string flashWriteFile; + // Path where the file containing the read data will be stored + std::string flashReadFilePath = ""; // Default name of downloaded image, can be changed via command std::string downloadImage = "image"; + // Default name of file containing the data read from flash, can be changed via command + std::string flashReadImage = "flashread"; + // Will be set with the flash write command + uint8_t flashWriteRegion = 0; + // Will be set with the flash write command and specifies the start address where to write the + // flash data to + uint32_t flashWriteAddress = 0; SdCardManager* sdcMan = nullptr; @@ -179,13 +218,23 @@ private: */ ReturnValue_t performImageDownload(); + /** + * @brief Handles flash write procedure + * + * @return RETURN_OK if successful, otherwise RETURN_FAILED + */ + ReturnValue_t performFlashWrite(); + /** * @brief Sends packet to the star tracker and reads reply by using the communication * interface * + * @param size Size of data beforehand written to the commandBuffer + * @param parameter Parameter 2 of trigger event function + * * @return RETURN_OK if successful, otherwise RETURN_FAILED */ - ReturnValue_t sendAndRead(size_t size, uint32_t position); + ReturnValue_t sendAndRead(size_t size, uint32_t parameter); /** * @brief Checks the reply header (type id and status fields) @@ -195,7 +244,7 @@ private: ReturnValue_t checkReply(); /** - * @brief Checks the position field in a star tracker reply. + * @brief Checks the position field in a star tracker upload/download reply. * * @param expectedPosition Value of expected position * @@ -203,6 +252,14 @@ private: */ ReturnValue_t checkReplyPosition(uint32_t expectedPosition); + /** + * @brief Checks the region, address and length value of a flash write reply. + * + * @return RETURN_OK if values match expected values, otherwise appropriate error return + * value. + */ + ReturnValue_t checkFlashWriteReply(struct WriteActionRequest& req); + /** * @brief Checks if a path points to an sd card and whether the SD card is monuted. * @@ -211,4 +268,4 @@ private: ReturnValue_t checkPath(std::string name); }; -#endif /* BSP_Q7S_DEVICES_STRIMAGELOADER_H_ */ +#endif /* BSP_Q7S_DEVICES_STRHELPER_H_ */ diff --git a/common/config/commonClassIds.h b/common/config/commonClassIds.h index fc2bffb2..4c769260 100644 --- a/common/config/commonClassIds.h +++ b/common/config/commonClassIds.h @@ -19,7 +19,7 @@ enum commonClassIds: uint8_t { CCSDS_IP_CORE_BRIDGE, //IPCI PTME, //PTME PLOC_UPDATER, //PLUD - STR_IMG_LOADER, //STRIMGL + STR_HELPER, //STRHLP GOM_SPACE_HANDLER, //GOMS PLOC_MEMORY_DUMPER, //PLMEMDUMP PDEC_HANDLER, //PDEC diff --git a/common/config/commonSubsystemIds.h b/common/config/commonSubsystemIds.h index 2bb216a5..55a4bed4 100644 --- a/common/config/commonSubsystemIds.h +++ b/common/config/commonSubsystemIds.h @@ -18,7 +18,7 @@ enum: uint8_t { PLOC_UPDATER = 117, PLOC_MEMORY_DUMPER = 118, PDEC_HANDLER = 119, - STR_IMAGE_LOADER = 120, + STR_HELPER = 120, COMMON_SUBSYSTEM_ID_END }; } diff --git a/tmtc b/tmtc index 02b6304e..8a235097 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 02b6304eba009ee620bfe5f9684262acb0cc4bae +Subproject commit 8a2350971db7a7edd491540820a763e30d2dda3c From 337a485fc1df89722978b187056866c8f8d13a47 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 21 Dec 2021 17:27:23 +0100 Subject: [PATCH 156/465] rerun generators --- generators/bsp_q7s_events.csv | 42 +++++++++------- generators/bsp_q7s_objects.csv | 2 +- generators/events/translateEvents.cpp | 50 ++++++++++++------- generators/objects/translateObjects.cpp | 6 +-- linux/fsfwconfig/events/translateEvents.cpp | 50 ++++++++++++------- linux/fsfwconfig/objects/translateObjects.cpp | 6 +-- 6 files changed, 92 insertions(+), 64 deletions(-) diff --git a/generators/bsp_q7s_events.csv b/generators/bsp_q7s_events.csv index 30956754..a2a4784a 100644 --- a/generators/bsp_q7s_events.csv +++ b/generators/bsp_q7s_events.csv @@ -77,11 +77,11 @@ 8901;CLOCK_SET_FAILURE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/pus/Service9TimeManagement.h 9700;TEST;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/pus/Service17Test.h 10600;CHANGE_OF_SETUP_PARAMETER;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h -10900;GPIO_PULL_HIGH_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/devices/HeaterHandler.h -10901;GPIO_PULL_LOW_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/devices/HeaterHandler.h -10902;SWITCH_ALREADY_ON;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/devices/HeaterHandler.h -10903;SWITCH_ALREADY_OFF;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/devices/HeaterHandler.h -10904;MAIN_SWITCH_TIMEOUT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/devices/HeaterHandler.h +10900;GPIO_PULL_HIGH_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/HeaterHandler.h +10901;GPIO_PULL_LOW_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/HeaterHandler.h +10902;SWITCH_ALREADY_ON;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/HeaterHandler.h +10903;SWITCH_ALREADY_OFF;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/HeaterHandler.h +10904;MAIN_SWITCH_TIMEOUT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/HeaterHandler.h 11000;MAIN_SWITCH_ON_TIMEOUT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/devices/SolarArrayDeploymentHandler.h 11001;MAIN_SWITCH_OFF_TIMEOUT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/devices/SolarArrayDeploymentHandler.h 11002;DEPLOYMENT_FAILED;HIGH;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/devices/SolarArrayDeploymentHandler.h @@ -118,17 +118,21 @@ 11902;INVALID_FAR;HIGH;Read invalid FAR from PDEC after startup;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/obc/PdecHandler.h 11903;CARRIER_LOCK;INFO;Carrier lock detected;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/obc/PdecHandler.h 11904;BIT_LOCK_PDEC;INFO;Bit lock detected (data valid);C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/obc/PdecHandler.h -12000;IMAGE_UPLOAD_FAILED;LOW;Image upload failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h -12001;IMAGE_DOWNLOAD_FAILED;LOW;Image download failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h -12002;IMAGE_UPLOAD_SUCCESSFUL;LOW;Uploading image to star tracker was successful;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h -12003;IMAGE_DOWNLOAD_SUCCESSFUL;LOW;Image download was successful;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h -12004;IMG_LOADER_READING_REPLY_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h -12005;IMG_LOADER_COM_ERROR;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h -12006;IMG_LOADER_NO_REPLY;LOW;Star tracker did not send replies (maybe device is powered off)P1: Position of upload or download packet for which no reply was sent;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h -12007;INVALID_TYPE_ID;LOW;Received reply with invalid type ID;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h -12008;STATUS_ERROR;LOW;Status field in reply signals error;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h -12009;IMG_LOADER_DEC_ERROR;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h -12010;POSITION_MISMATCH;LOW;Position mismatch P1: The expected position and thus the position for which the image upload/download failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h -12011;IMAGE_FILE_NOT_EXISTS;LOW;Try to upload image but specified image does not exist;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h -12012;IMG_LOADER_SENDING_PACKET_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h -12013;IMG_LOADER_REQUESTING_MSG_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrImageLoader.h +12000;IMAGE_UPLOAD_FAILED;LOW;Image upload failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12001;IMAGE_DOWNLOAD_FAILED;LOW;Image download failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12002;IMAGE_UPLOAD_SUCCESSFUL;LOW;Uploading image to star tracker was successful;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12003;IMAGE_DOWNLOAD_SUCCESSFUL;LOW;Image download was successful;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12004;FLASH_WRITE_SUCCESSFUL;LOW;Finished flash write procedure successfully;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12005;FLASH_READ_SUCCESSFUL;LOW;Finished flash read procedure successfully;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12006;FLASH_WRITE_FAILED;LOW;Flash write procedure failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12007;FLASH_READ_FAILED;LOW;Flash read procedure failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12008;STR_HELPER_READING_REPLY_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12009;STR_HELPER_COM_ERROR;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12010;STR_HELPER_NO_REPLY;LOW;Star tracker did not send replies (maybe device is powered off)P1: Position of upload or download packet for which no reply was sent;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12011;INVALID_TYPE_ID;LOW;Received reply with invalid type ID;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12012;STATUS_ERROR;LOW;Status field in reply signals error;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12013;STR_HELPER_DEC_ERROR;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12014;POSITION_MISMATCH;LOW;Position mismatch P1: The expected position and thus the position for which the image upload/download failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12015;STR_HELPER_FILE_NOT_EXISTS;LOW;Specified file does not existP1: Internal state of str helper;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12016;STR_HELPER_SENDING_PACKET_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12017;STR_HELPER_REQUESTING_MSG_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h diff --git a/generators/bsp_q7s_objects.csv b/generators/bsp_q7s_objects.csv index b0fe0658..af48751f 100644 --- a/generators/bsp_q7s_objects.csv +++ b/generators/bsp_q7s_objects.csv @@ -39,7 +39,7 @@ 0x443200A5;RAD_SENSOR 0x44330000;PLOC_UPDATER 0x44330001;PLOC_MEMORY_DUMPER -0x44330002;STR_IMG_LOADER +0x44330002;STR_HELPER 0x44330015;PLOC_MPSOC_HANDLER 0x44330016;PLOC_SUPERVISOR_HANDLER 0x444100A2;SOLAR_ARRAY_DEPL_HANDLER diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp index e44c407d..76159e0c 100644 --- a/generators/events/translateEvents.cpp +++ b/generators/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 134 translations. + * @brief Auto-generated event translation file. Contains 138 translations. * @details - * Generated on: 2021-12-09 16:40:42 + * Generated on: 2021-12-21 17:08:50 */ #include "translateEvents.h" @@ -129,16 +129,20 @@ const char *IMAGE_UPLOAD_FAILED_STRING = "IMAGE_UPLOAD_FAILED"; const char *IMAGE_DOWNLOAD_FAILED_STRING = "IMAGE_DOWNLOAD_FAILED"; const char *IMAGE_UPLOAD_SUCCESSFUL_STRING = "IMAGE_UPLOAD_SUCCESSFUL"; const char *IMAGE_DOWNLOAD_SUCCESSFUL_STRING = "IMAGE_DOWNLOAD_SUCCESSFUL"; -const char *IMG_LOADER_READING_REPLY_FAILED_STRING = "IMG_LOADER_READING_REPLY_FAILED"; -const char *IMG_LOADER_COM_ERROR_STRING = "IMG_LOADER_COM_ERROR"; -const char *IMG_LOADER_NO_REPLY_STRING = "IMG_LOADER_NO_REPLY"; +const char *FLASH_WRITE_SUCCESSFUL_STRING = "FLASH_WRITE_SUCCESSFUL"; +const char *FLASH_READ_SUCCESSFUL_STRING = "FLASH_READ_SUCCESSFUL"; +const char *FLASH_WRITE_FAILED_STRING = "FLASH_WRITE_FAILED"; +const char *FLASH_READ_FAILED_STRING = "FLASH_READ_FAILED"; +const char *STR_HELPER_READING_REPLY_FAILED_STRING = "STR_HELPER_READING_REPLY_FAILED"; +const char *STR_HELPER_COM_ERROR_STRING = "STR_HELPER_COM_ERROR"; +const char *STR_HELPER_NO_REPLY_STRING = "STR_HELPER_NO_REPLY"; const char *INVALID_TYPE_ID_STRING = "INVALID_TYPE_ID"; const char *STATUS_ERROR_STRING = "STATUS_ERROR"; -const char *IMG_LOADER_DEC_ERROR_STRING = "IMG_LOADER_DEC_ERROR"; +const char *STR_HELPER_DEC_ERROR_STRING = "STR_HELPER_DEC_ERROR"; const char *POSITION_MISMATCH_STRING = "POSITION_MISMATCH"; -const char *IMAGE_FILE_NOT_EXISTS_STRING = "IMAGE_FILE_NOT_EXISTS"; -const char *IMG_LOADER_SENDING_PACKET_FAILED_STRING = "IMG_LOADER_SENDING_PACKET_FAILED"; -const char *IMG_LOADER_REQUESTING_MSG_FAILED_STRING = "IMG_LOADER_REQUESTING_MSG_FAILED"; +const char *STR_HELPER_FILE_NOT_EXISTS_STRING = "STR_HELPER_FILE_NOT_EXISTS"; +const char *STR_HELPER_SENDING_PACKET_FAILED_STRING = "STR_HELPER_SENDING_PACKET_FAILED"; +const char *STR_HELPER_REQUESTING_MSG_FAILED_STRING = "STR_HELPER_REQUESTING_MSG_FAILED"; const char * translateEvents(Event event) { switch( (event & 0xffff) ) { @@ -391,25 +395,33 @@ const char * translateEvents(Event event) { case(12003): return IMAGE_DOWNLOAD_SUCCESSFUL_STRING; case(12004): - return IMG_LOADER_READING_REPLY_FAILED_STRING; + return FLASH_WRITE_SUCCESSFUL_STRING; case(12005): - return IMG_LOADER_COM_ERROR_STRING; + return FLASH_READ_SUCCESSFUL_STRING; case(12006): - return IMG_LOADER_NO_REPLY_STRING; + return FLASH_WRITE_FAILED_STRING; case(12007): - return INVALID_TYPE_ID_STRING; + return FLASH_READ_FAILED_STRING; case(12008): - return STATUS_ERROR_STRING; + return STR_HELPER_READING_REPLY_FAILED_STRING; case(12009): - return IMG_LOADER_DEC_ERROR_STRING; + return STR_HELPER_COM_ERROR_STRING; case(12010): - return POSITION_MISMATCH_STRING; + return STR_HELPER_NO_REPLY_STRING; case(12011): - return IMAGE_FILE_NOT_EXISTS_STRING; + return INVALID_TYPE_ID_STRING; case(12012): - return IMG_LOADER_SENDING_PACKET_FAILED_STRING; + return STATUS_ERROR_STRING; case(12013): - return IMG_LOADER_REQUESTING_MSG_FAILED_STRING; + return STR_HELPER_DEC_ERROR_STRING; + case(12014): + return POSITION_MISMATCH_STRING; + case(12015): + return STR_HELPER_FILE_NOT_EXISTS_STRING; + case(12016): + return STR_HELPER_SENDING_PACKET_FAILED_STRING; + case(12017): + return STR_HELPER_REQUESTING_MSG_FAILED_STRING; default: return "UNKNOWN_EVENT"; } diff --git a/generators/objects/translateObjects.cpp b/generators/objects/translateObjects.cpp index 87e10da9..49900a5d 100644 --- a/generators/objects/translateObjects.cpp +++ b/generators/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 113 translations. - * Generated on: 2021-12-04 11:03:17 + * Generated on: 2021-12-21 17:21:23 */ #include "translateObjects.h" @@ -47,7 +47,7 @@ const char *ACU_HANDLER_STRING = "ACU_HANDLER"; const char *RAD_SENSOR_STRING = "RAD_SENSOR"; const char *PLOC_UPDATER_STRING = "PLOC_UPDATER"; const char *PLOC_MEMORY_DUMPER_STRING = "PLOC_MEMORY_DUMPER"; -const char *STR_IMG_LOADER_STRING = "STR_IMG_LOADER"; +const char *STR_HELPER_STRING = "STR_HELPER"; const char *PLOC_MPSOC_HANDLER_STRING = "PLOC_MPSOC_HANDLER"; const char *PLOC_SUPERVISOR_HANDLER_STRING = "PLOC_SUPERVISOR_HANDLER"; const char *SOLAR_ARRAY_DEPL_HANDLER_STRING = "SOLAR_ARRAY_DEPL_HANDLER"; @@ -205,7 +205,7 @@ const char* translateObject(object_id_t object) { case 0x44330001: return PLOC_MEMORY_DUMPER_STRING; case 0x44330002: - return STR_IMG_LOADER_STRING; + return STR_HELPER_STRING; case 0x44330015: return PLOC_MPSOC_HANDLER_STRING; case 0x44330016: diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index e44c407d..76159e0c 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 134 translations. + * @brief Auto-generated event translation file. Contains 138 translations. * @details - * Generated on: 2021-12-09 16:40:42 + * Generated on: 2021-12-21 17:08:50 */ #include "translateEvents.h" @@ -129,16 +129,20 @@ const char *IMAGE_UPLOAD_FAILED_STRING = "IMAGE_UPLOAD_FAILED"; const char *IMAGE_DOWNLOAD_FAILED_STRING = "IMAGE_DOWNLOAD_FAILED"; const char *IMAGE_UPLOAD_SUCCESSFUL_STRING = "IMAGE_UPLOAD_SUCCESSFUL"; const char *IMAGE_DOWNLOAD_SUCCESSFUL_STRING = "IMAGE_DOWNLOAD_SUCCESSFUL"; -const char *IMG_LOADER_READING_REPLY_FAILED_STRING = "IMG_LOADER_READING_REPLY_FAILED"; -const char *IMG_LOADER_COM_ERROR_STRING = "IMG_LOADER_COM_ERROR"; -const char *IMG_LOADER_NO_REPLY_STRING = "IMG_LOADER_NO_REPLY"; +const char *FLASH_WRITE_SUCCESSFUL_STRING = "FLASH_WRITE_SUCCESSFUL"; +const char *FLASH_READ_SUCCESSFUL_STRING = "FLASH_READ_SUCCESSFUL"; +const char *FLASH_WRITE_FAILED_STRING = "FLASH_WRITE_FAILED"; +const char *FLASH_READ_FAILED_STRING = "FLASH_READ_FAILED"; +const char *STR_HELPER_READING_REPLY_FAILED_STRING = "STR_HELPER_READING_REPLY_FAILED"; +const char *STR_HELPER_COM_ERROR_STRING = "STR_HELPER_COM_ERROR"; +const char *STR_HELPER_NO_REPLY_STRING = "STR_HELPER_NO_REPLY"; const char *INVALID_TYPE_ID_STRING = "INVALID_TYPE_ID"; const char *STATUS_ERROR_STRING = "STATUS_ERROR"; -const char *IMG_LOADER_DEC_ERROR_STRING = "IMG_LOADER_DEC_ERROR"; +const char *STR_HELPER_DEC_ERROR_STRING = "STR_HELPER_DEC_ERROR"; const char *POSITION_MISMATCH_STRING = "POSITION_MISMATCH"; -const char *IMAGE_FILE_NOT_EXISTS_STRING = "IMAGE_FILE_NOT_EXISTS"; -const char *IMG_LOADER_SENDING_PACKET_FAILED_STRING = "IMG_LOADER_SENDING_PACKET_FAILED"; -const char *IMG_LOADER_REQUESTING_MSG_FAILED_STRING = "IMG_LOADER_REQUESTING_MSG_FAILED"; +const char *STR_HELPER_FILE_NOT_EXISTS_STRING = "STR_HELPER_FILE_NOT_EXISTS"; +const char *STR_HELPER_SENDING_PACKET_FAILED_STRING = "STR_HELPER_SENDING_PACKET_FAILED"; +const char *STR_HELPER_REQUESTING_MSG_FAILED_STRING = "STR_HELPER_REQUESTING_MSG_FAILED"; const char * translateEvents(Event event) { switch( (event & 0xffff) ) { @@ -391,25 +395,33 @@ const char * translateEvents(Event event) { case(12003): return IMAGE_DOWNLOAD_SUCCESSFUL_STRING; case(12004): - return IMG_LOADER_READING_REPLY_FAILED_STRING; + return FLASH_WRITE_SUCCESSFUL_STRING; case(12005): - return IMG_LOADER_COM_ERROR_STRING; + return FLASH_READ_SUCCESSFUL_STRING; case(12006): - return IMG_LOADER_NO_REPLY_STRING; + return FLASH_WRITE_FAILED_STRING; case(12007): - return INVALID_TYPE_ID_STRING; + return FLASH_READ_FAILED_STRING; case(12008): - return STATUS_ERROR_STRING; + return STR_HELPER_READING_REPLY_FAILED_STRING; case(12009): - return IMG_LOADER_DEC_ERROR_STRING; + return STR_HELPER_COM_ERROR_STRING; case(12010): - return POSITION_MISMATCH_STRING; + return STR_HELPER_NO_REPLY_STRING; case(12011): - return IMAGE_FILE_NOT_EXISTS_STRING; + return INVALID_TYPE_ID_STRING; case(12012): - return IMG_LOADER_SENDING_PACKET_FAILED_STRING; + return STATUS_ERROR_STRING; case(12013): - return IMG_LOADER_REQUESTING_MSG_FAILED_STRING; + return STR_HELPER_DEC_ERROR_STRING; + case(12014): + return POSITION_MISMATCH_STRING; + case(12015): + return STR_HELPER_FILE_NOT_EXISTS_STRING; + case(12016): + return STR_HELPER_SENDING_PACKET_FAILED_STRING; + case(12017): + return STR_HELPER_REQUESTING_MSG_FAILED_STRING; default: return "UNKNOWN_EVENT"; } diff --git a/linux/fsfwconfig/objects/translateObjects.cpp b/linux/fsfwconfig/objects/translateObjects.cpp index 87e10da9..49900a5d 100644 --- a/linux/fsfwconfig/objects/translateObjects.cpp +++ b/linux/fsfwconfig/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 113 translations. - * Generated on: 2021-12-04 11:03:17 + * Generated on: 2021-12-21 17:21:23 */ #include "translateObjects.h" @@ -47,7 +47,7 @@ const char *ACU_HANDLER_STRING = "ACU_HANDLER"; const char *RAD_SENSOR_STRING = "RAD_SENSOR"; const char *PLOC_UPDATER_STRING = "PLOC_UPDATER"; const char *PLOC_MEMORY_DUMPER_STRING = "PLOC_MEMORY_DUMPER"; -const char *STR_IMG_LOADER_STRING = "STR_IMG_LOADER"; +const char *STR_HELPER_STRING = "STR_HELPER"; const char *PLOC_MPSOC_HANDLER_STRING = "PLOC_MPSOC_HANDLER"; const char *PLOC_SUPERVISOR_HANDLER_STRING = "PLOC_SUPERVISOR_HANDLER"; const char *SOLAR_ARRAY_DEPL_HANDLER_STRING = "SOLAR_ARRAY_DEPL_HANDLER"; @@ -205,7 +205,7 @@ const char* translateObject(object_id_t object) { case 0x44330001: return PLOC_MEMORY_DUMPER_STRING; case 0x44330002: - return STR_IMG_LOADER_STRING; + return STR_HELPER_STRING; case 0x44330015: return PLOC_MPSOC_HANDLER_STRING; case 0x44330016: From 421866b7397ca201bd4f1a44af024e006c510d87 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 21 Dec 2021 17:28:24 +0100 Subject: [PATCH 157/465] str write command fix --- bsp_q7s/core/InitMission.cpp | 4 ++-- bsp_q7s/core/ObjectFactory.cpp | 6 +++--- bsp_q7s/devices/startracker/StarTrackerHandler.cpp | 2 +- common/config/commonObjects.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index 7da77135..803339a2 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -129,9 +129,9 @@ void initmission::initTasks() { PeriodicTaskIF* strImgLoaderTask = factory->createPeriodicTask( "FILE_SYSTEM_TASK", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - result = strImgLoaderTask->addComponent(objects::STR_IMG_LOADER); + result = strImgLoaderTask->addComponent(objects::STR_HELPER); if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("FILE_SYSTEM_TASK", objects::STR_IMG_LOADER); + initmission::printAddObjectError("FILE_SYSTEM_TASK", objects::STR_HELPER); } #endif /* BOARD_TE0720 */ diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 92600caf..fbe1bbfb 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -1,7 +1,7 @@ #include #include "ObjectFactory.h" -#include "../devices/startracker/StrHelper.h" +#include "bsp_q7s/devices/startracker/StrHelper.h" #include "bsp_q7s/devices/startracker/StarTrackerDefinitions.h" #include "OBSWConfig.h" #include "devConf.h" @@ -175,9 +175,9 @@ void ObjectFactory::produce(void* args) { q7s::UART_STAR_TRACKER_DEV, UartModes::NON_CANONICAL, uart::STAR_TRACKER_BAUD, StarTracker::MAX_FRAME_SIZE* 2 + 2); starTrackerCookie->setNoFixedSizeReply(); - StrImageLoader* strImageLoader = new StrImageLoader(objects::STR_IMG_LOADER); + StrHelper* strHelper = new StrHelper(objects::STR_HELPER); StarTrackerHandler* starTrackerHandler = new StarTrackerHandler(objects::STAR_TRACKER, - objects::UART_COM_IF, starTrackerCookie, strImageLoader); + objects::UART_COM_IF, starTrackerCookie, strHelper); starTrackerHandler->setStartUpImmediately(); #endif /* OBSW_ADD_STAR_TRACKER == 1 */ diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp index 6e0d54e0..bb9018be 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp @@ -920,7 +920,7 @@ ReturnValue_t StarTrackerHandler::scanForTmReply(DeviceCommandId_t *foundId) { void StarTrackerHandler::handleEvent(EventMessage* eventMessage) { object_id_t objectId = eventMessage->getReporter(); switch(objectId){ - case objects::STR_IMG_LOADER: { + case objects::STR_HELPER: { // All events from image loader signal either that the operation was successful or that it // failed strHelperExecuting = false; diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index 570dee84..cce3616f 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -91,7 +91,7 @@ enum commonObjects: uint32_t { PLOC_UPDATER = 0x44330000, PLOC_MEMORY_DUMPER = 0x44330001, - STR_IMG_LOADER = 0x44330002 + STR_HELPER = 0x44330002 }; } From 1b38d3495117aaf6fc6b1f379b1aec8e5c8850ea Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 21 Dec 2021 17:40:31 +0100 Subject: [PATCH 158/465] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 8a235097..3a71176c 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 8a2350971db7a7edd491540820a763e30d2dda3c +Subproject commit 3a71176c5666a5c8f46bc433f3c96124b49975ab From 861d92f3c2b18812650ebaf256f5e28eb5aee020 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 21 Dec 2021 18:13:20 +0100 Subject: [PATCH 159/465] update uart device names --- bsp_q7s/boardconfig/busConf.h | 12 +++++------- bsp_q7s/core/ObjectFactory.cpp | 10 +--------- .../pollingsequence/pollingSequenceFactory.cpp | 4 ++-- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index e6f9ae54..354dc263 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -8,13 +8,11 @@ static constexpr char SPI_RW_DEV[] = "/dev/spidev3.0"; static constexpr char I2C_DEFAULT_DEV[] = "/dev/i2c-1"; -static constexpr char UART_PLOC_MPSOC_DEV[] = "/dev/ttyUL3"; -static constexpr char UART_PLOC_SUPERVSIOR_DEV[] = "/dev/ttyUL4"; -static constexpr char UART_SYRLINKS_DEV[] = "/dev/ttyUL5"; -static constexpr char UART_STAR_TRACKER_DEV[] = "/dev/ttyUL8"; - -static constexpr char UART_GNSS_0_DEV[] = "/dev/ttyUL0"; -static constexpr char UART_GNSS_1_DEV[] = "/dev/ttyUL2"; +static constexpr char UART_GNSS_DEV[] = "/dev/ttyUL0"; +static constexpr char UART_PLOC_MPSOC_DEV[] = "/dev/ttyUL2"; +static constexpr char UART_PLOC_SUPERVSIOR_DEV[] = "/dev/ttyUL3"; +static constexpr char UART_SYRLINKS_DEV[] = "/dev/ttyUL4"; +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"; diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 3b35f89e..ddd82853 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -564,22 +564,14 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI resetArgsGnss0.gnss1 = false; resetArgsGnss0.gpioComIF = gpioComIF; resetArgsGnss0.waitPeriodMs = 100; - auto uartCookieGps0 = new UartCookie(objects::GPS0_HANDLER, q7s::UART_GNSS_0_DEV, + auto uartCookieGps0 = new UartCookie(objects::GPS0_HANDLER, q7s::UART_GNSS_DEV, UartModes::CANONICAL, uart::GNSS_BAUD, uart::HYPERION_GPS_REPLY_MAX_BUFFER); uartCookieGps0->setToFlushInput(true); uartCookieGps0->setReadCycles(6); - auto uartCookieGps1 = new UartCookie(objects::GPS1_HANDLER, q7s::UART_GNSS_1_DEV, - UartModes::CANONICAL, uart::GNSS_BAUD, uart::HYPERION_GPS_REPLY_MAX_BUFFER); - uartCookieGps1->setToFlushInput(true); - uartCookieGps1->setReadCycles(6); auto gpsHandler0 = new GPSHyperionHandler(objects::GPS0_HANDLER, objects::UART_COM_IF, uartCookieGps0, debugGps); gpsHandler0->setResetPinTriggerFunction(gps::triggerGpioResetPin, &resetArgsGnss0); gpsHandler0->setStartUpImmediately(); - auto gpsHandler1 = new GPSHyperionHandler(objects::GPS1_HANDLER, objects::UART_COM_IF, - uartCookieGps1, debugGps); - gpsHandler1->setResetPinTriggerFunction(gps::triggerGpioResetPin, &resetArgsGnss1); - gpsHandler1->setStartUpImmediately(); } void ObjectFactory::createHeaterComponents() { diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index be38fd89..19d9b2de 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -439,8 +439,8 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { #endif #if OBSW_ADD_ACS_BOARD == 1 - bool enableAside = false; - bool enableBside = true; + bool enableAside = true; + bool enableBside = false; if(enableAside) { // A side thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0, From 433947824aa5d2702aab651ba0d13d9bf3d19e4d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 21 Dec 2021 18:28:46 +0100 Subject: [PATCH 160/465] removed spi mux switching, not necessary anymore --- bsp_q7s/callbacks/rwSpiCallback.cpp | 10 ---------- bsp_q7s/core/ObjectFactory.cpp | 9 --------- 2 files changed, 19 deletions(-) diff --git a/bsp_q7s/callbacks/rwSpiCallback.cpp b/bsp_q7s/callbacks/rwSpiCallback.cpp index ad99d505..1e60e3c0 100644 --- a/bsp_q7s/callbacks/rwSpiCallback.cpp +++ b/bsp_q7s/callbacks/rwSpiCallback.cpp @@ -51,11 +51,6 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sen return result; } - /** Disconnect PS SPI peripheral and select AXI SPI core */ - if(gpioIF->pullHigh(gpioIds::SPI_MUX) != HasReturnvaluesIF::RETURN_OK) { - sif::error << "rwSpiCallback::spiCallback: Failed to pull spi mux gpio high" << std::endl; - } - /** Sending frame start sign */ writeBuffer[0] = 0x7E; writeSize = 1; @@ -239,10 +234,5 @@ void closeSpi (gpioId_t gpioId, GpioIF* gpioIF, MutexIF* mutex) { if(mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) { sif::error << "rwSpiCallback::closeSpi: Failed to unlock mutex" << std::endl;; } - - /** Route SPI interface again to PS SPI peripheral */ - if(gpioIF->pullLow(gpioIds::SPI_MUX) != HasReturnvaluesIF::RETURN_OK) { - sif::error << "rwSpiCallback::spiCallback: Failed to pull spi mux gpio low" << std::endl; - } } } diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index ddd82853..15416e1e 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -840,15 +840,6 @@ void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF) { gpio::LOW); gpioCookieRw->addGpio(gpioIds::EN_RW4, gpio); - /** - * This GPIO is only internally connected to the SPI MUX module and responsible to disconnect - * the PS SPI peripheral from the SPI interface and route out the SPI lines of the AXI SPI core. - * Per default the PS SPI is selected (EMIO = 0). - */ - gpio = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_SELECT, - "SPI Reaction Wheel Callback ", gpio::DIR_OUT, gpio::LOW); - gpioCookieRw->addGpio(gpioIds::SPI_MUX, gpio); - gpioComIF->addGpios(gpioCookieRw); auto rw1SpiCookie = new SpiCookie(addresses::RW1, gpioIds::CS_RW1, q7s::SPI_RW_DEV, From 433b2182271529b722d102ff64a089dcd3989547 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 21 Dec 2021 18:29:27 +0100 Subject: [PATCH 161/465] added new GNSS mux select pin --- bsp_q7s/boardconfig/busConf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index 354dc263..34516fa6 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -54,7 +54,7 @@ namespace gpioNames { static constexpr char EN_RW_2[] = "enable_rw_2"; static constexpr char EN_RW_3[] = "enable_rw_3"; static constexpr char EN_RW_4[] = "enable_rw_4"; - static constexpr char SPI_MUX_SELECT[] = "spi_mux_select"; + static constexpr char GNSS_MUX_SELECT[] = "gnss_mux_select"; static constexpr char RAD_SENSOR_CHIP_SELECT[] = "rad_sensor_chip_select"; static constexpr char PAPB_BUSY_SIGNAL_VC0[] = "papb_busy_signal_vc0"; static constexpr char PAPB_EMPTY_SIGNAL_VC0[] = "papb_empty_signal_vc0"; From d12027126c737b5dd80efa92a7da7e8fed88f90e Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 21 Dec 2021 20:52:45 +0100 Subject: [PATCH 162/465] arcsec lib update --- thirdparty/arcsec_star_tracker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/thirdparty/arcsec_star_tracker b/thirdparty/arcsec_star_tracker index cdd25c4f..f596c533 160000 --- a/thirdparty/arcsec_star_tracker +++ b/thirdparty/arcsec_star_tracker @@ -1 +1 @@ -Subproject commit cdd25c4fc7b963cebb58ade213a8546c2d435242 +Subproject commit f596c53315f1f81facb28faec3150612a5ad2ca0 From 38ad9f0da272f3bfbabe9981addb6bd87e5f6b4e Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Wed, 22 Dec 2021 11:14:27 +0100 Subject: [PATCH 163/465] flash read wip --- bsp_q7s/devices/startracker/StrHelper.cpp | 68 +++++++++++++++++++++++ bsp_q7s/devices/startracker/StrHelper.h | 11 +++- 2 files changed, 77 insertions(+), 2 deletions(-) diff --git a/bsp_q7s/devices/startracker/StrHelper.cpp b/bsp_q7s/devices/startracker/StrHelper.cpp index a3d28305..bc4e034f 100644 --- a/bsp_q7s/devices/startracker/StrHelper.cpp +++ b/bsp_q7s/devices/startracker/StrHelper.cpp @@ -295,6 +295,74 @@ ReturnValue_t StrHelper::performFlashWrite() { return RETURN_OK; } +ReturnValue_t StrHelper::performFlashRead() { + ReturnValue_t result; + struct ReadActionRequest req; + uint32_t bytesRead = 0; + uint32_t size = 0; + uint32_t retries = 0; + Timestamp timestamp; + std::string file = flashReadPath + "/" + timestamp.str() + flashReadFile ; + std::ofstream file(file, std::ios_base::app | std::ios_base::out); + if(not std::filesystem::exists(file)) { + return FILE_CREATION_FAILED; + } + req.region = flashReadRegion; + req.address = flashReadAddress; + while(bytesRead < flashReadSize) { + if (terminate) { + return RETURN_OK; + } + if ((flashReadSize - bytesRead) < MAX_FLASH_DATA) { + req.length = flashReadSize - bytesRead; + } + else { + req.length = MAX_FLASH_DATA; + } + arc_pack_read_action_req(&req, commandBuffer, static_cast(req.length)); + + + + + result = sendAndRead(size, downloadReq.position); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + result = checkReply(); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + result = checkReplyPosition(downloadReq.position); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + file.write(reinterpret_cast(datalinkLayer.getReply() + DATA_OFFSET), + IMAGE_DATA_SIZE); + downloadReq.position++; + retries = 0; + } + file.close(); + return RETURN_OK; +} + ReturnValue_t StrHelper::sendAndRead(size_t size, uint32_t parameter) { ReturnValue_t result = RETURN_OK; ReturnValue_t decResult = RETURN_OK; diff --git a/bsp_q7s/devices/startracker/StrHelper.h b/bsp_q7s/devices/startracker/StrHelper.h index f7a994b4..9fd74c7e 100644 --- a/bsp_q7s/devices/startracker/StrHelper.h +++ b/bsp_q7s/devices/startracker/StrHelper.h @@ -174,17 +174,24 @@ private: // File which contains data to write when executing the flash write command std::string flashWriteFile; // Path where the file containing the read data will be stored - std::string flashReadFilePath = ""; + std::string flashReadPath = ""; // Default name of downloaded image, can be changed via command std::string downloadImage = "image"; // Default name of file containing the data read from flash, can be changed via command - std::string flashReadImage = "flashread"; + std::string flashReadFile = "flashread"; // Will be set with the flash write command uint8_t flashWriteRegion = 0; // Will be set with the flash write command and specifies the start address where to write the // flash data to uint32_t flashWriteAddress = 0; + // Will be set with the flash read command + uint8_t flashReadRegion = 0; + // Will be set with the flash read command and specifies the start address of the flash section + // to read + uint32_t flashReadAddress = 0; + // Number of bytes to read from flash + uint32_t flashReadSize = 0; SdCardManager* sdcMan = nullptr; From 72cc08109837cc2933e0bf675c31aa75702b2739 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Wed, 22 Dec 2021 11:17:50 +0100 Subject: [PATCH 164/465] fixed header names --- bsp_q7s/devices/startracker/ArcsecDatalinkLayer.h | 2 +- bsp_q7s/devices/startracker/StarTrackerHandler.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.h b/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.h index 84b04426..a65881c7 100644 --- a/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.h +++ b/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.h @@ -2,7 +2,7 @@ #define BSP_Q7S_DEVICES_ARCSECDATALINKLAYER_H_ #include "StarTrackerDefinitions.h" -#include "fsfw/returnvalues/HasReturnValuesIF.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" extern "C" { #include "common/misc.h" diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.h b/bsp_q7s/devices/startracker/StarTrackerHandler.h index 8761f1ce..7d22592e 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.h +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.h @@ -6,7 +6,7 @@ #include "fsfw/timemanager/Countdown.h" #include "thirdparty/arcsec_star_tracker/common/SLIP.h" #include -#include "ArcsecDataLinkLayer.h" +#include "ArcsecDatalinkLayer.h" #include "StarTrackerDefinitions.h" #include "ArcsecJsonParamBase.h" #include "StrHelper.h" From c31ae5073bf25eb944946a4baeaff5641517ecb4 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Wed, 22 Dec 2021 11:20:05 +0100 Subject: [PATCH 165/465] fixed header name --- mission/utility/Timestamp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mission/utility/Timestamp.cpp b/mission/utility/Timestamp.cpp index d63f6173..36ddf4d8 100644 --- a/mission/utility/Timestamp.cpp +++ b/mission/utility/Timestamp.cpp @@ -1,5 +1,5 @@ #include "Timestamp.h" -#include "fsfw/serviceinterface/ServiceInterfacestream.h" +#include "fsfw/serviceinterface/ServiceInterfaceStream.h" Timestamp::Timestamp() { ReturnValue_t result = Clock::getDateAndTime(&time); From 27c011413a4b9d8553fd06b506aff6a6e495bed0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 22 Dec 2021 15:26:32 +0100 Subject: [PATCH 166/465] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index e5b568bc..2506af27 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit e5b568bc2b0b819bfb5c9dc90026d534852df4ff +Subproject commit 2506af27ed84585c64df2679b0c6a3c969f31941 From cdddc76a597b8829314814e9a858da7c6a4fcb2c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 22 Dec 2021 15:28:28 +0100 Subject: [PATCH 167/465] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 3a71176c..827738f6 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 3a71176c5666a5c8f46bc433f3c96124b49975ab +Subproject commit 827738f6efbfbcf32d56397e5c713f136dbd8556 From 1331c9e7e9a25aab19b4f654dba40991989d4056 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Wed, 22 Dec 2021 16:06:30 +0100 Subject: [PATCH 168/465] flash read request --- bsp_q7s/core/InitMission.cpp | 5 + .../startracker/StarTrackerDefinitions.h | 1 + .../startracker/StarTrackerHandler.cpp | 105 ++++++++++++++++-- .../devices/startracker/StarTrackerHandler.h | 30 +++++ bsp_q7s/devices/startracker/StrHelper.cpp | 85 ++++++++++---- bsp_q7s/devices/startracker/StrHelper.h | 33 +++++- 6 files changed, 221 insertions(+), 38 deletions(-) diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index 803339a2..7977deed 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -127,12 +127,15 @@ void initmission::initTasks() { initmission::printAddObjectError("FILE_SYSTEM_TASK", objects::FILE_SYSTEM_HANDLER); } +#if OBSW_ADD_STAR_TRACKER == 1 PeriodicTaskIF* strImgLoaderTask = factory->createPeriodicTask( "FILE_SYSTEM_TASK", 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); } +#endif /* OBSW_ADD_STAR_TRACKER == 1 */ + #endif /* BOARD_TE0720 */ #if OBSW_TEST_CCSDS_BRIDGE == 1 @@ -194,7 +197,9 @@ void initmission::initTasks() { #if BOARD_TE0720 == 0 fsTask->startTask(); +#if OBSW_ADD_STAR_TRACKER == 1 strImgLoaderTask->startTask(); +#endif /* OBSW_ADD_STAR_TRACKER == 1 */ #endif sif::info << "Tasks started.." << std::endl; diff --git a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h index 22214cb0..a66b16e7 100644 --- a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h +++ b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h @@ -202,6 +202,7 @@ static const DeviceCommandId_t STOP_IMAGE_LOADER = 55; static const DeviceCommandId_t RESET_ERROR = 56; static const DeviceCommandId_t CHANGE_DOWNLOAD_FILE = 57; static const DeviceCommandId_t SET_JSON_FILE_NAME = 58; +static const DeviceCommandId_t SET_READ_FILENAME = 59; static const DeviceCommandId_t NONE = 0xFFFFFFFF; static const uint32_t VERSION_SET_ID = REQ_VERSION; diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp index bb9018be..d55fb17a 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp @@ -145,6 +145,18 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu strHelperExecuting = true; return EXECUTION_FINISHED; } + case(StarTracker::READ): { + result = DeviceHandlerBase::acceptExternalDeviceCommands(); + if (result != RETURN_OK) { + return result; + } + result = executeReadCommand(data, size); + if (result != RETURN_OK) { + return result; + } + strHelperExecuting = true; + return EXECUTION_FINISHED; + } case(StarTracker::CHANGE_DOWNLOAD_FILE): { if (size > MAX_FILE_NAME) { return FILENAME_TOO_LONG; @@ -153,6 +165,14 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu std::string(reinterpret_cast(data), size)); return EXECUTION_FINISHED; } + case(StarTracker::SET_READ_FILENAME): { + if (size > MAX_FILE_NAME) { + return FILENAME_TOO_LONG; + } + strHelper->setDownloadImageName( + std::string(reinterpret_cast(data), size)); + return EXECUTION_FINISHED; + } default: break; } @@ -396,6 +416,10 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi result = prepareParamCommand(commandData, commandDataLen, tracking); return result; } + case (StarTracker::UNLOCK): { + result = prepareUnlockCommand(commandData, commandDataLen); + return result; + } default: return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } @@ -454,6 +478,8 @@ void StarTrackerHandler::fillCommandAndReplyMap() { StarTracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(StarTracker::RESET_ERROR, 3, nullptr, StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::UNLOCK, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); } ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t remainingSize, @@ -522,15 +548,10 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con result = handlePingReply(); break; } - case (StarTracker::BOOT): { - result = handleActionReply(); - break; - } - case (StarTracker::RESET_ERROR): { - result = handleActionReply(); - break; - } - case (StarTracker::TAKE_IMAGE): { + case (StarTracker::BOOT): + case (StarTracker::TAKE_IMAGE): + case (StarTracker::RESET_ERROR): + case (StarTracker::UNLOCK): { result = handleActionReply(); break; } @@ -809,6 +830,10 @@ ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t *foundId) *foundId = StarTracker::RESET_ERROR; break; } + case (StarTracker::ID::UNLOCK): { + *foundId = StarTracker::UNLOCK; + break; + } default: sif::warning << "StarTrackerHandler::scanForParameterReply: Unknown parameter reply id" << std::endl; @@ -966,6 +991,49 @@ ReturnValue_t StarTrackerHandler::executeWriteCommand(const uint8_t* commandData return result; } +ReturnValue_t StarTrackerHandler::executeReadCommand(const uint8_t* commandData, + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + if (commandDataLen < ReadCmd::MIN_LENGTH) { + sif::warning << "StarTrackerHandler::executeReadCommand: Command too short" << std::endl; + return COMMAND_TOO_SHORT; + } + uint8_t region = *(commandData); + uint32_t address; + size_t size = sizeof(address); + const uint8_t* addressPtr = commandData + ReadCmd::ADDRESS_OFFSET; + result = SerializeAdapter::deSerialize(&address, addressPtr, &size, + SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::executeReadCommand: Deserialization of address failed" + << std::endl; + return result; + } + uint16_t length; + size = sizeof(length); + const uint8_t* lengthPtr = commandData + ReadCmd::LENGTH_OFFSET; + result = SerializeAdapter::deSerialize(&address, lengthPtr, &size, + SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::executeReadCommand: Deserialization of length failed" + << std::endl; + return result; + } + if (commandDataLen - sizeof(address) - sizeof(region) - sizeof(length) > MAX_PATH_SIZE) { + sif::warning << "StarTrackerHandler::executeReadCommand: Received command with invalid" + << " path and filename" << std::endl; + return FILE_PATH_TOO_LONG; + } + const uint8_t* filePtr = commandData + ReadCmd::FILE_OFFSET; + std::string fullname = std::string(reinterpret_cast(filePtr), + commandDataLen - sizeof(address) - sizeof(region) - sizeof(length)); + result = strHelper->startFlashRead(fullname, region, address, length); + if (result != RETURN_OK) { + return result; + } + return result; +} + void StarTrackerHandler::prepareBootCommand() { uint32_t length = 0; struct BootActionRequest bootRequest = {BOOT_REGION_ID}; @@ -975,6 +1043,25 @@ void StarTrackerHandler::prepareBootCommand() { rawPacketLen = dataLinkLayer.getEncodedLength(); } +ReturnValue_t StarTrackerHandler::prepareUnlockCommand(const uint8_t* commandData, size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + uint32_t length = 0; + struct UnlockActionRequest req; + req.region = *commandData; + size_t size = sizeof(req.code); + const uint8_t* codePtr = commandData + UnlockCmd::CODE_OFFSET; + result = SerializeAdapter::deSerialize(&req.code, &codePtr, &size, + SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + return result; + } + arc_pack_unlock_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return result; +} + void StarTrackerHandler::prepareTimeRequest() { uint32_t length = 0; arc_tm_pack_time_req(commandBuffer, &length); diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.h b/bsp_q7s/devices/startracker/StarTrackerHandler.h index 7d22592e..791ead0f 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.h +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.h @@ -147,6 +147,20 @@ private: static const size_t MIN_LENGTH = 7; }; + class ReadCmd { + public: + static const uint8_t ADDRESS_OFFSET = 1; + static const uint8_t LENGTH_OFFSET = 5; + static const uint8_t FILE_OFFSET = 7; + // Minimum length of a read command (region, address, length and filename) + static const size_t MIN_LENGTH = 9; + }; + + class UnlockCmd { + public: + static const uint8_t CODE_OFFSET = 1; + }; + MessageQueueIF* eventQueue = nullptr; ArcsecDatalinkLayer dataLinkLayer; @@ -245,12 +259,28 @@ private: */ ReturnValue_t executeWriteCommand(const uint8_t* commandData, size_t commandDataLen); + /** + * @brief Extracts information for flash-read-command from TC data and starts execution of + * flash-read-procedure + * + * @param commandData Pointer to received command data + * @param commandDataLen Size of received command data + * + * @return RETURN_OK if start of execution was successful, otherwise error return value + */ + ReturnValue_t executeReadCommand(const uint8_t* commandData, size_t commandDataLen); + /** * @brief Fills command buffer with data to boot image (works only when star tracker is * in bootloader mode). */ void prepareBootCommand(); + /** + * @brief Fills command buffer with command to unlock flash region + */ + ReturnValue_t prepareUnlockCommand(const uint8_t* commandData, size_t commandDataLen); + /** * @brief Fills the command buffer with the command to take an image. */ diff --git a/bsp_q7s/devices/startracker/StrHelper.cpp b/bsp_q7s/devices/startracker/StrHelper.cpp index bc4e034f..4a6797f1 100644 --- a/bsp_q7s/devices/startracker/StrHelper.cpp +++ b/bsp_q7s/devices/startracker/StrHelper.cpp @@ -63,6 +63,17 @@ ReturnValue_t StrHelper::performOperation(uint8_t operationCode) { internalState = InternalState::IDLE; break; } + case InternalState::FLASH_READ: { + result = performFlashRead(); + if (result == RETURN_OK){ + triggerEvent(FLASH_READ_SUCCESSFUL); + } + else { + triggerEvent(FLASH_READ_FAILED); + } + internalState = InternalState::IDLE; + break; + } default: sif::debug << "StrHelper::performOperation: Invalid state" << std::endl; break; @@ -121,8 +132,12 @@ void StrHelper::setDownloadImageName(std::string image) { downloadImage = image; } +void StrHelper::setFlashReadFilename(std::string filename) { + flashReadFile = filename; +} + ReturnValue_t StrHelper::startFlashWrite(std::string flashWriteFile_, uint8_t region, - uint32_t flashWriteAddress) { + uint32_t address) { ReturnValue_t result = checkPath(flashWriteFile_); if (result != RETURN_OK) { return result; @@ -131,12 +146,33 @@ ReturnValue_t StrHelper::startFlashWrite(std::string flashWriteFile_, uint8_t re if(not std::filesystem::exists(flashWriteFile)) { return FILE_NOT_EXISTS; } + flashWriteAddress = address; + flashWriteRegion = region; internalState = InternalState::FLASH_WRITE; semaphore.release(); terminate = false; return RETURN_OK; } +ReturnValue_t StrHelper::startFlashRead(std::string flashReadFile_, uint8_t region, + uint32_t address, uint16_t length) { + ReturnValue_t result = checkPath(flashReadFile_); + if (result != RETURN_OK) { + return result; + } + flashReadFile = flashReadFile_; + if(not std::filesystem::exists(flashReadFile)) { + return FILE_NOT_EXISTS; + } + flashReadAddress = address; + flashReadRegion = region; + flashReadSize = length; + internalState = InternalState::FLASH_READ; + semaphore.release(); + terminate = false; + return RETURN_OK; +} + ReturnValue_t StrHelper::performImageDownload() { ReturnValue_t result; struct DownloadActionRequest downloadReq; @@ -184,7 +220,7 @@ ReturnValue_t StrHelper::performImageDownload() { file.close(); return result; } - file.write(reinterpret_cast(datalinkLayer.getReply() + DATA_OFFSET), + file.write(reinterpret_cast(datalinkLayer.getReply() + IMAGE_DATA_OFFSET), IMAGE_DATA_SIZE); downloadReq.position++; retries = 0; @@ -274,7 +310,7 @@ ReturnValue_t StrHelper::performFlashWrite() { if (result != RETURN_OK) { return RETURN_FAILED; } - result = checkFlashWriteReply(req); + result = checkFlashActionReply(req.region, req.address, req.length); if (result != RETURN_OK) { return result; } @@ -288,7 +324,7 @@ ReturnValue_t StrHelper::performFlashWrite() { if (result != RETURN_OK) { return RETURN_FAILED; } - result = checkFlashWriteReply(req); + result = checkFlashActionReply(req.region, req.address, req.length); if (result != RETURN_OK) { return result; } @@ -302,13 +338,12 @@ ReturnValue_t StrHelper::performFlashRead() { uint32_t size = 0; uint32_t retries = 0; Timestamp timestamp; - std::string file = flashReadPath + "/" + timestamp.str() + flashReadFile ; - std::ofstream file(file, std::ios_base::app | std::ios_base::out); - if(not std::filesystem::exists(file)) { + std::string fullname = flashReadPath + "/" + timestamp.str() + flashReadFile ; + std::ofstream file(fullname, std::ios_base::app | std::ios_base::out); + if (not std::filesystem::exists(fullname)) { return FILE_CREATION_FAILED; } req.region = flashReadRegion; - req.address = flashReadAddress; while(bytesRead < flashReadSize) { if (terminate) { return RETURN_OK; @@ -319,12 +354,9 @@ ReturnValue_t StrHelper::performFlashRead() { else { req.length = MAX_FLASH_DATA; } - arc_pack_read_action_req(&req, commandBuffer, static_cast(req.length)); - - - - - result = sendAndRead(size, downloadReq.position); + req.address = flashReadAddress + bytesRead; + arc_pack_read_action_req(&req, commandBuffer, &size); + result = sendAndRead(size, req.address); if (result != RETURN_OK) { if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { uartComIF->flushUartRxBuffer(comCookie); @@ -344,7 +376,7 @@ ReturnValue_t StrHelper::performFlashRead() { file.close(); return result; } - result = checkReplyPosition(downloadReq.position); + result = checkFlashActionReply(req.region, req.address, req.length); if (result != RETURN_OK) { if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { uartComIF->flushUartRxBuffer(comCookie); @@ -354,9 +386,9 @@ ReturnValue_t StrHelper::performFlashRead() { file.close(); return result; } - file.write(reinterpret_cast(datalinkLayer.getReply() + DATA_OFFSET), - IMAGE_DATA_SIZE); - downloadReq.position++; + file.write(reinterpret_cast(datalinkLayer.getReply() + FLASH_READ_DATA_OFFSET), + req.length); + bytesRead += req.length; retries = 0; } file.close(); @@ -446,8 +478,13 @@ ReturnValue_t StrHelper::checkReplyPosition(uint32_t expectedPosition) { return RETURN_OK; } -ReturnValue_t StrHelper::checkFlashWriteReply(struct WriteActionRequest& req) { +ReturnValue_t StrHelper::checkFlashActionReply(uint8_t region_, uint32_t address_, + uint16_t length_) { ReturnValue_t result = RETURN_OK; + result = checkReply(); + if (result != RETURN_OK) { + return result; + } const uint8_t* data = datalinkLayer.getReply(); uint8_t region = *(data + REGION_OFFSET); uint32_t address; @@ -456,7 +493,7 @@ ReturnValue_t StrHelper::checkFlashWriteReply(struct WriteActionRequest& req) { result = SerializeAdapter::deSerialize(&address, &addressData, &size, SerializeIF::Endianness::LITTLE); if (result != RETURN_OK) { - sif::warning << "StrHelper::checkFlashWriteReply: Deserialization of address failed" + sif::warning << "StrHelper::checkFlashActionReply: Deserialization of address failed" << std::endl; } uint16_t length; @@ -465,16 +502,16 @@ ReturnValue_t StrHelper::checkFlashWriteReply(struct WriteActionRequest& req) { result = SerializeAdapter::deSerialize(&length, lengthData, &size, SerializeIF::Endianness::LITTLE); if (result != RETURN_OK) { - sif::warning << "StrHelper::checkFlashWriteReply: Deserialization of length failed" + sif::warning << "StrHelper::checkFlashActionReply: Deserialization of length failed" << std::endl; } - if (region != req.region) { + if (region != region_) { return REGION_MISMATCH; } - if (address != req.address) { + if (address != address_) { return ADDRESS_MISMATCH; } - if (region != req.length) { + if (region != length_) { return LENGTH_MISMATCH; } return RETURN_OK; diff --git a/bsp_q7s/devices/startracker/StrHelper.h b/bsp_q7s/devices/startracker/StrHelper.h index 9fd74c7e..13742778 100644 --- a/bsp_q7s/devices/startracker/StrHelper.h +++ b/bsp_q7s/devices/startracker/StrHelper.h @@ -103,10 +103,21 @@ public: * * @param flashWriteFile_ Full name including absolute path of file to write to flash * @param region Region ID of flash region to write to - * @param flashWriteAddress Start address of flash write procedure + * @param address Start address of flash write procedure */ ReturnValue_t startFlashWrite(std::string flashWriteFile_, uint8_t region, - uint32_t flashWriteAddress); + uint32_t address); + + /** + * @brief Starts the flash read procedure + * + * @param flashWriteFile_ Full name including absolute path of file to write to flash + * @param region Region ID of flash region to read from + * @param flashWriteAddress Start address of flash section to read + * @param length Number of bytes to read from flash + */ + ReturnValue_t startFlashRead(std::string flashReadFile_, uint8_t region, + uint32_t address, uint16_t length); /** * @brief Can be used to interrupt a running data transfer. @@ -118,6 +129,11 @@ public: */ void setDownloadImageName(std::string image); + /** + * @brief Sets the name of the file which will be created to store the data read from flash + */ + void setFlashReadFilename(std::string filename); + private: static const uint8_t INTERFACE_ID = CLASS_ID::STR_HELPER; @@ -145,7 +161,8 @@ private: static const uint32_t MAX_POLLS = 10000; static const uint8_t POS_OFFSET = 2; - static const uint8_t DATA_OFFSET = 5; + static const uint8_t IMAGE_DATA_OFFSET = 5; + static const uint8_t FLASH_READ_DATA_OFFSET = 8; static const uint8_t REGION_OFFSET = 2; static const uint8_t ADDRESS_OFFSET = 3; static const uint8_t LENGTH_OFFSET = 7; @@ -232,6 +249,12 @@ private: */ ReturnValue_t performFlashWrite(); + /** + * @brief Sends a sequence of commands to the star tracker to read larger parts from the + * flash memory. + */ + ReturnValue_t performFlashRead(); + /** * @brief Sends packet to the star tracker and reads reply by using the communication * interface @@ -260,12 +283,12 @@ private: ReturnValue_t checkReplyPosition(uint32_t expectedPosition); /** - * @brief Checks the region, address and length value of a flash write reply. + * @brief Checks the region, address and length value of a flash write or read reply. * * @return RETURN_OK if values match expected values, otherwise appropriate error return * value. */ - ReturnValue_t checkFlashWriteReply(struct WriteActionRequest& req); + ReturnValue_t checkFlashActionReply(uint8_t region_, uint32_t address_, uint16_t length_); /** * @brief Checks if a path points to an sd card and whether the SD card is monuted. From 8cddbf86d9b2f11195c723c8afe0095472d35ea1 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 23 Dec 2021 11:07:19 +0100 Subject: [PATCH 169/465] flash read command --- .../startracker/StarTrackerHandler.cpp | 6 ++--- .../devices/startracker/StarTrackerHandler.h | 4 ++-- bsp_q7s/devices/startracker/StrHelper.cpp | 21 +++++++++--------- bsp_q7s/devices/startracker/StrHelper.h | 22 +++++++++---------- mission/utility/Timestamp.cpp | 15 ++++++++++--- mission/utility/Timestamp.h | 3 +++ 6 files changed, 41 insertions(+), 30 deletions(-) diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp index d55fb17a..9b97b422 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp @@ -1009,11 +1009,11 @@ ReturnValue_t StarTrackerHandler::executeReadCommand(const uint8_t* commandData, << std::endl; return result; } - uint16_t length; + uint32_t length; size = sizeof(length); const uint8_t* lengthPtr = commandData + ReadCmd::LENGTH_OFFSET; - result = SerializeAdapter::deSerialize(&address, lengthPtr, &size, - SerializeIF::Endianness::LITTLE); + result = SerializeAdapter::deSerialize(&length, lengthPtr, &size, + SerializeIF::Endianness::BIG); if (result != RETURN_OK) { sif::debug << "StarTrackerHandler::executeReadCommand: Deserialization of length failed" << std::endl; diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.h b/bsp_q7s/devices/startracker/StarTrackerHandler.h index 791ead0f..16b00d3b 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.h +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.h @@ -151,9 +151,9 @@ private: public: static const uint8_t ADDRESS_OFFSET = 1; static const uint8_t LENGTH_OFFSET = 5; - static const uint8_t FILE_OFFSET = 7; + static const uint8_t FILE_OFFSET = 9; // Minimum length of a read command (region, address, length and filename) - static const size_t MIN_LENGTH = 9; + static const size_t MIN_LENGTH = 11; }; class UnlockCmd { diff --git a/bsp_q7s/devices/startracker/StrHelper.cpp b/bsp_q7s/devices/startracker/StrHelper.cpp index 4a6797f1..fa7b510f 100644 --- a/bsp_q7s/devices/startracker/StrHelper.cpp +++ b/bsp_q7s/devices/startracker/StrHelper.cpp @@ -154,14 +154,14 @@ ReturnValue_t StrHelper::startFlashWrite(std::string flashWriteFile_, uint8_t re return RETURN_OK; } -ReturnValue_t StrHelper::startFlashRead(std::string flashReadFile_, uint8_t region, - uint32_t address, uint16_t length) { - ReturnValue_t result = checkPath(flashReadFile_); +ReturnValue_t StrHelper::startFlashRead(std::string flashReadPath_, uint8_t region, + uint32_t address, uint32_t length) { + ReturnValue_t result = checkPath(flashReadPath_); if (result != RETURN_OK) { return result; } - flashReadFile = flashReadFile_; - if(not std::filesystem::exists(flashReadFile)) { + flashReadPath = flashReadPath_; + if(not std::filesystem::exists(flashReadPath)) { return FILE_NOT_EXISTS; } flashReadAddress = address; @@ -456,14 +456,13 @@ ReturnValue_t StrHelper::checkReply() { if (type != TMTC_ACTIONREPLY) { sif::warning << "StrHelper::checkReply: Received reply with invalid type ID" << std::endl; - triggerEvent(INVALID_TYPE_ID); - return RETURN_FAILED; + return INVALID_TYPE_ID; } uint8_t status = datalinkLayer.getStatusField(); if (status != ArcsecDatalinkLayer::STATUS_OK) { - triggerEvent(STATUS_ERROR); - sif::warning << "StrHelper::checkReply: Status failure" << std::endl; - return RETURN_FAILED; + sif::warning << "StrHelper::checkReply: Status failure: " + << static_cast(status) << std::endl; + return STATUS_ERROR; } return RETURN_OK; } @@ -511,7 +510,7 @@ ReturnValue_t StrHelper::checkFlashActionReply(uint8_t region_, uint32_t address if (address != address_) { return ADDRESS_MISMATCH; } - if (region != length_) { + if (length != length_) { return LENGTH_MISMATCH; } return RETURN_OK; diff --git a/bsp_q7s/devices/startracker/StrHelper.h b/bsp_q7s/devices/startracker/StrHelper.h index 13742778..ff2f3ca6 100644 --- a/bsp_q7s/devices/startracker/StrHelper.h +++ b/bsp_q7s/devices/startracker/StrHelper.h @@ -51,28 +51,24 @@ public: //! [EXPORT] : [COMMENT] Star tracker did not send replies (maybe device is powered off) //!P1: Position of upload or download packet for which no reply was sent static const Event STR_HELPER_NO_REPLY = MAKE_EVENT(10, severity::LOW); - //! [EXPORT] : [COMMENT] Received reply with invalid type ID - static const Event INVALID_TYPE_ID = MAKE_EVENT(11, severity::LOW); - //! [EXPORT] : [COMMENT] Status field in reply signals error - static const Event STATUS_ERROR = MAKE_EVENT(12, severity::LOW); //! [EXPORT] : [COMMENT] Error during decoding of received reply occurred //P1: Return value of decoding function //P2: Position of upload/download packet, or address of flash write/read request - static const Event STR_HELPER_DEC_ERROR = MAKE_EVENT(13, severity::LOW); + static const Event STR_HELPER_DEC_ERROR = MAKE_EVENT(11, severity::LOW); //! [EXPORT] : [COMMENT] Position mismatch //! P1: The expected position and thus the position for which the image upload/download failed - static const Event POSITION_MISMATCH = MAKE_EVENT(14, severity::LOW); + static const Event POSITION_MISMATCH = MAKE_EVENT(12, severity::LOW); //! [EXPORT] : [COMMENT] Specified file does not exist //!P1: Internal state of str helper - static const Event STR_HELPER_FILE_NOT_EXISTS = MAKE_EVENT(15, severity::LOW); + static const Event STR_HELPER_FILE_NOT_EXISTS = MAKE_EVENT(13, severity::LOW); //! [EXPORT] : [COMMENT] Sending packet to star tracker failed //!P1: Return code of communication interface sendMessage function //!P2: Position of upload/download packet, or address of flash write/read request for which sending failed - static const Event STR_HELPER_SENDING_PACKET_FAILED = MAKE_EVENT(16, severity::LOW); + static const Event STR_HELPER_SENDING_PACKET_FAILED = MAKE_EVENT(14, severity::LOW); //! [EXPORT] : [COMMENT] Communication interface requesting reply failed //!P1: Return code of failed request //!P1: Upload/download position, or address of flash write/read request for which transmission failed - static const Event STR_HELPER_REQUESTING_MSG_FAILED = MAKE_EVENT(17, severity::LOW); + static const Event STR_HELPER_REQUESTING_MSG_FAILED = MAKE_EVENT(15, severity::LOW); StrHelper(object_id_t objectId); virtual ~StrHelper(); @@ -116,8 +112,8 @@ public: * @param flashWriteAddress Start address of flash section to read * @param length Number of bytes to read from flash */ - ReturnValue_t startFlashRead(std::string flashReadFile_, uint8_t region, - uint32_t address, uint16_t length); + ReturnValue_t startFlashRead(std::string flashReadPath_, uint8_t region, + uint32_t address, uint32_t length); /** * @brief Can be used to interrupt a running data transfer. @@ -152,6 +148,10 @@ private: static const ReturnValue_t ADDRESS_MISMATCH = MAKE_RETURN_CODE(0xA5); //! [EXPORT] : [COMMENT] Length in flash write/read reply does not match expected length static const ReturnValue_t LENGTH_MISMATCH = MAKE_RETURN_CODE(0xA6); + //! [EXPORT] : [COMMENT] Status field in reply signals error + static const ReturnValue_t STATUS_ERROR = MAKE_RETURN_CODE(0xA7); + //! [EXPORT] : [COMMENT] Reply has invalid type ID (should be of action reply type) + static const ReturnValue_t INVALID_TYPE_ID = MAKE_RETURN_CODE(0xA8); // Size of one image part which can be sent per action request static const size_t SIZE_IMAGE_PART = 1024; diff --git a/mission/utility/Timestamp.cpp b/mission/utility/Timestamp.cpp index 36ddf4d8..c0848a59 100644 --- a/mission/utility/Timestamp.cpp +++ b/mission/utility/Timestamp.cpp @@ -12,8 +12,17 @@ Timestamp::~Timestamp() { } std::string Timestamp::str() { - return std::to_string(time.year) + "-" + std::to_string(time.month) + "-" - + std::to_string(time.day) + "--" + std::to_string(time.hour) + "-" - + std::to_string(time.minute) + "-" + std::to_string(time.second) + "-"; + timestamp << std::to_string(time.year) << "-" + << std::setw(2) << std::setfill('0') + << std::to_string(time.month) << "-" + << std::setw(2) << std::setfill('0') + << std::to_string(time.day) << "--" + << std::setw(2) << std::setfill('0') + << std::to_string(time.hour) << "-" + << std::setw(2) << std::setfill('0') + << std::to_string(time.minute) << "-" + << std::setw(2) << std::setfill('0') + << std::to_string(time.second) << "--"; + return timestamp.str(); } diff --git a/mission/utility/Timestamp.h b/mission/utility/Timestamp.h index 05dae31f..7146de53 100644 --- a/mission/utility/Timestamp.h +++ b/mission/utility/Timestamp.h @@ -2,6 +2,8 @@ #define MISSION_UTILITY_TIMESTAMP_H_ #include +#include +#include #include "fsfw/timemanager/Clock.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" @@ -21,6 +23,7 @@ public: std::string str(); private: + std::stringstream timestamp; Clock::TimeOfDay_t time; }; From fa8cdb3241ad27b8d0a606a4da13a7752abe4d88 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 23 Dec 2021 18:33:06 +0100 Subject: [PATCH 170/465] changed star tracker uart --- bsp_q7s/boardconfig/busConf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index 73605471..bcd43ccf 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -11,7 +11,7 @@ static constexpr char I2C_DEFAULT_DEV[] = "/dev/i2c-1"; static constexpr char UART_PLOC_MPSOC_DEV[] = "/dev/ttyUL3"; static constexpr char UART_PLOC_SUPERVSIOR_DEV[] = "/dev/ttyUL4"; static constexpr char UART_SYRLINKS_DEV[] = "/dev/ttyUL5"; -static constexpr char UART_STAR_TRACKER_DEV[] = "/dev/ttyUL8"; +static constexpr char UART_STAR_TRACKER_DEV[] = "/dev/ttyUL7"; static constexpr char UART_GNSS_0_DEV[] = "/dev/ttyUL0"; static constexpr char UART_GNSS_1_DEV[] = "/dev/ttyUL2"; From 14dec1d7007ffd8ac787c34cfe5461cbefbf8015 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 23 Dec 2021 18:33:31 +0100 Subject: [PATCH 171/465] checksum command --- .../startracker/StarTrackerDefinitions.h | 73 +++++++++++++++++ .../startracker/StarTrackerHandler.cpp | 82 ++++++++++++++++++- .../devices/startracker/StarTrackerHandler.h | 32 ++++++++ bsp_q7s/devices/startracker/StrHelper.h | 4 +- 4 files changed, 187 insertions(+), 4 deletions(-) diff --git a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h index a66b16e7..1efa0bc7 100644 --- a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h +++ b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h @@ -846,6 +846,79 @@ public: sif::info << "ContrastSet::printSet: BinD8: " << this->binD8 << std::endl; } }; + +/** + * @brief Helper Class to extract information from bytestream. + */ +class ChecksumReply { +public: + + /** + * @brief Constructor + * + * @param datafield Pointer to datafield in reply buffer + * + */ + ChecksumReply(const uint8_t* datafield) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + region = *(datafield); + const uint8_t* addressData = datafield + ADDRESS_OFFSET; + size_t size = sizeof(address); + result = SerializeAdapter::deSerialize(&address, &addressData, &size, + SerializeIF::Endianness::LITTLE); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "ChecksumReply::ChecksumReply: Failed to deserialize address" + << std::endl; + } + const uint8_t* lengthData = datafield + LENGTH_OFFSET; + size = sizeof(length); + result = SerializeAdapter::deSerialize(&length, &lengthData, &size, + SerializeIF::Endianness::LITTLE); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "ChecksumReply::ChecksumReply: Failed to deserialize length" + << std::endl; + } + const uint8_t* checksumData = datafield + CHECKSUM_OFFSET; + size = sizeof(checksum); + result = SerializeAdapter::deSerialize(&checksum, &checksumData, &size, + SerializeIF::Endianness::LITTLE); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "ChecksumReply::ChecksumReply: Failed to deserialize checksum" + << std::endl; + } + } + + uint8_t getRegion() { + return region; + } + + uint32_t getAddress() { + return address; + } + + uint32_t getLength() { + return length; + } + + uint32_t getChecksum() { + return checksum; + } + + void printChecksum() { + sif::info << "ChecksumReply::printChecksum: 0x" << checksum << std::endl; + } + +private: + + static const uint8_t ADDRESS_OFFSET = 1; + static const uint8_t LENGTH_OFFSET = 5; + static const uint8_t CHECKSUM_OFFSET = 9; + + uint8_t region = 0; + uint32_t address = 0; + uint32_t length = 0; + uint32_t checksum = 0; +}; } #endif /* MISSION_STARTRACKER_DEFINITIONS_H_ */ diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp index 9b97b422..7ae5d72c 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp @@ -420,6 +420,10 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi result = prepareUnlockCommand(commandData, commandDataLen); return result; } + case (StarTracker::CHECKSUM): { + result = prepareChecksumCommand(commandData, commandDataLen); + return result; + } default: return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } @@ -480,6 +484,8 @@ void StarTrackerHandler::fillCommandAndReplyMap() { StarTracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(StarTracker::UNLOCK, 3, nullptr, StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::CHECKSUM, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); } ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t remainingSize, @@ -555,6 +561,10 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con result = handleActionReply(); break; } + case (StarTracker::CHECKSUM): { + result = handleChecksumReply(); + break; + } case (StarTracker::REQ_VERSION): { result = handleTm(versionSet, StarTracker::VersionSet::SIZE); if (result != RETURN_OK) { @@ -834,6 +844,10 @@ ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t *foundId) *foundId = StarTracker::UNLOCK; break; } + case (StarTracker::ID::CHECKSUM): { + *foundId = StarTracker::CHECKSUM; + break; + } default: sif::warning << "StarTrackerHandler::scanForParameterReply: Unknown parameter reply id" << std::endl; @@ -970,7 +984,7 @@ ReturnValue_t StarTrackerHandler::executeWriteCommand(const uint8_t* commandData size_t size = sizeof(address); const uint8_t* addressPtr = commandData + WriteCmd::ADDRESS_OFFSET; result = SerializeAdapter::deSerialize(&address, addressPtr, &size, - SerializeIF::Endianness::LITTLE); + SerializeIF::Endianness::BIG); if (result != RETURN_OK) { sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of address failed" << std::endl; @@ -1003,7 +1017,7 @@ ReturnValue_t StarTrackerHandler::executeReadCommand(const uint8_t* commandData, size_t size = sizeof(address); const uint8_t* addressPtr = commandData + ReadCmd::ADDRESS_OFFSET; result = SerializeAdapter::deSerialize(&address, addressPtr, &size, - SerializeIF::Endianness::LITTLE); + SerializeIF::Endianness::BIG); if (result != RETURN_OK) { sif::debug << "StarTrackerHandler::executeReadCommand: Deserialization of address failed" << std::endl; @@ -1062,6 +1076,44 @@ ReturnValue_t StarTrackerHandler::prepareUnlockCommand(const uint8_t* commandDat return result; } +ReturnValue_t StarTrackerHandler::prepareChecksumCommand(const uint8_t* commandData, + size_t commandDataLen) { + struct ChecksumActionRequest req; + ReturnValue_t result = RETURN_OK; + if (commandDataLen != ChecksumCmd::LENGTH) { + sif::warning << "StarTrackerHandler::prepareChecksumCommand: Invalid length" << std::endl; + return INVALID_LENGTH; + } + req.region = *(commandData); + size_t size = sizeof(req.address); + const uint8_t* addressPtr = commandData + ChecksumCmd::ADDRESS_OFFSET; + result = SerializeAdapter::deSerialize(&req.address, addressPtr, &size, + SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::prepareChecksumCommand: Deserialization of address " + << "failed" << std::endl; + return result; + } + size = sizeof(req.length); + const uint8_t* lengthPtr = commandData + ChecksumCmd::LENGTH_OFFSET; + result = SerializeAdapter::deSerialize(&req.length, lengthPtr, &size, + SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::prepareChecksumCommand: Deserialization of length failed" + << std::endl; + return result; + } + uint32_t rawCmdLength = 0; + arc_pack_checksum_action_req(&req, commandBuffer, &rawCmdLength); + dataLinkLayer.encodeFrame(commandBuffer, rawCmdLength); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + checksumCmd.rememberRegion = req.region; + checksumCmd.rememberAddress = req.address; + checksumCmd.rememberLength = req.length; + return result; +} + void StarTrackerHandler::prepareTimeRequest() { uint32_t length = 0; arc_tm_pack_time_req(commandBuffer, &length); @@ -1240,6 +1292,32 @@ ReturnValue_t StarTrackerHandler::handleActionReply() { return RETURN_OK; } +ReturnValue_t StarTrackerHandler::handleChecksumReply() { + ReturnValue_t result = RETURN_OK; + result = handleActionReply(); + if (result != RETURN_OK) { + return result; + } + const uint8_t* replyData = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; + StarTracker::ChecksumReply checksumReply(replyData); + if (checksumReply.getRegion() != checksumCmd.rememberRegion) { + sif::warning << "StarTrackerHandler::handleChecksumReply: Region mismatch" << std::endl; + return REGION_MISMATCH; + } + if (checksumReply.getAddress() != checksumCmd.rememberAddress) { + sif::warning << "StarTrackerHandler::handleChecksumReply: Address mismatch" << std::endl; + return ADDRESS_MISMATCH; + } + if (checksumReply.getLength() != checksumCmd.rememberLength) { + sif::warning << "StarTrackerHandler::handleChecksumReply: Length mismatch" << std::endl; + return LENGTH_MISSMATCH; + } +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 + checksumReply.printChecksum(); +#endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ + return RETURN_OK; +} + ReturnValue_t StarTrackerHandler::handlePingReply() { ReturnValue_t result = RETURN_OK; uint32_t pingId = 0; diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.h b/bsp_q7s/devices/startracker/StarTrackerHandler.h index 16b00d3b..095105b3 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.h +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.h @@ -117,6 +117,14 @@ private: static const ReturnValue_t CONTRAST_REQ_FAILED = MAKE_RETURN_CODE(0xAE); //! [EXPORT] : [COMMENT] Received command which is too short (some data is missing for proper execution) static const ReturnValue_t COMMAND_TOO_SHORT = MAKE_RETURN_CODE(0xAF); + //! [EXPORT] : [COMMENT] Received command with invalid length (too few or too many parameters) + static const ReturnValue_t INVALID_LENGTH = MAKE_RETURN_CODE(0xB0); + //! [EXPORT] : [COMMENT] Region mismatch between send and received data + static const ReturnValue_t REGION_MISMATCH = MAKE_RETURN_CODE(0xB1); + //! [EXPORT] : [COMMENT] Address mismatch between send and received data + static const ReturnValue_t ADDRESS_MISMATCH = MAKE_RETURN_CODE(0xB2); + //! [EXPORT] : [COMMENT] Length field mismatch between send and received data + static const ReturnValue_t lENGTH_MISMATCH = MAKE_RETURN_CODE(0xB3); static const size_t MAX_PATH_SIZE = 50; static const size_t MAX_FILE_NAME = 30; @@ -161,6 +169,20 @@ private: static const uint8_t CODE_OFFSET = 1; }; + class ChecksumCmd { + public: + static const uint8_t ADDRESS_OFFSET = 1; + static const uint8_t LENGTH_OFFSET = 5; + // Length of checksum command + static const size_t LENGTH = 9; + + uint8_t rememberRegion = 0; + uint32_t rememberAddress = 0; + uint32_t rememberLength = 0; + }; + + ChecksumCmd checksumCmd; + MessageQueueIF* eventQueue = nullptr; ArcsecDatalinkLayer dataLinkLayer; @@ -281,6 +303,11 @@ private: */ ReturnValue_t prepareUnlockCommand(const uint8_t* commandData, size_t commandDataLen); + /** + * @brief Fills command buffer with command to get the checksum of a flash part + */ + ReturnValue_t prepareChecksumCommand(const uint8_t* commandData, size_t commandDataLen); + /** * @brief Fills the command buffer with the command to take an image. */ @@ -354,6 +381,11 @@ private: */ ReturnValue_t handleActionReply(); + /** + * @brief Handles reply to checksum command + */ + ReturnValue_t handleChecksumReply(); + /** * @brief Handles all set parameter replies */ diff --git a/bsp_q7s/devices/startracker/StrHelper.h b/bsp_q7s/devices/startracker/StrHelper.h index ff2f3ca6..372c2abd 100644 --- a/bsp_q7s/devices/startracker/StrHelper.h +++ b/bsp_q7s/devices/startracker/StrHelper.h @@ -194,9 +194,9 @@ private: std::string flashReadPath = ""; // Default name of downloaded image, can be changed via command - std::string downloadImage = "image"; + std::string downloadImage = "image.bin"; // Default name of file containing the data read from flash, can be changed via command - std::string flashReadFile = "flashread"; + std::string flashReadFile = "flashread.bin"; // Will be set with the flash write command uint8_t flashWriteRegion = 0; // Will be set with the flash write command and specifies the start address where to write the From 2ea75d2a05a1f1a7b5fc6869143f5c6a0d2e29c6 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Fri, 24 Dec 2021 07:31:21 +0100 Subject: [PATCH 172/465] erase command --- .../startracker/StarTrackerDefinitions.h | 42 ++++++++++++-- .../startracker/StarTrackerHandler.cpp | 56 ++++++++++++++++++- .../devices/startracker/StarTrackerHandler.h | 20 ++++++- 3 files changed, 109 insertions(+), 9 deletions(-) diff --git a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h index 1efa0bc7..5b839164 100644 --- a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h +++ b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h @@ -59,7 +59,6 @@ enum PoolIds: lp_id_t { TIME_TEMPERATURE_SET, MCU_TEMPERATURE, CMOS_TEMPERATURE, - TICKS_SOLUTION_SET, TIME_SOLUTION_SET, CALI_QW, @@ -83,7 +82,6 @@ enum PoolIds: lp_id_t { TRUST_WORTHY, STABLE_COUNT, SOLUTION_STRATEGY, - TICKS_HISTOGRAM_SET, TIME_HISTOGRAM_SET, HISTOGRAM_BINA0, @@ -122,7 +120,6 @@ enum PoolIds: lp_id_t { HISTOGRAM_BIND6, HISTOGRAM_BIND7, HISTOGRAM_BIND8, - TICKS_CONTRAST_SET, TIME_CONTRAST_SET, CONTRAST_BINA0, @@ -160,7 +157,8 @@ enum PoolIds: lp_id_t { CONTRAST_BIND5, CONTRAST_BIND6, CONTRAST_BIND7, - CONTRAST_BIND8 + CONTRAST_BIND8, + CHKSUM }; static const DeviceCommandId_t PING_REQUEST = 0; @@ -213,6 +211,7 @@ static const uint32_t TIME_SET_ID = REQ_TIME; static const uint32_t SOLUTION_SET_ID = REQ_SOLUTION; static const uint32_t HISTOGRAM_SET_ID = REQ_HISTOGRAM; static const uint32_t CONTRAST_SET_ID = REQ_CONTRAST; +static const uint32_t CHECKSUM_SET_ID = CHECKSUM; /** Max size of unencoded frame */ static const size_t MAX_FRAME_SIZE = 1200; @@ -225,6 +224,7 @@ static const uint8_t TIME_SET_ENTRIES = 4; static const uint8_t SOLUTION_SET_ENTRIES = 23; static const uint8_t HISTOGRAM_SET_ENTRIES = 38; static const uint8_t CONTRAST_SET_ENTRIES = 38; +static const uint8_t CHECKSUM_SET_ENTRIES = 1; // Action, parameter and telemetry IDs namespace ID { @@ -905,7 +905,7 @@ public: } void printChecksum() { - sif::info << "ChecksumReply::printChecksum: 0x" << checksum << std::endl; + sif::info << "ChecksumReply::printChecksum: 0x" << std::hex << checksum << std::endl; } private: @@ -919,6 +919,38 @@ private: uint32_t length = 0; uint32_t checksum = 0; }; + +class EraseReply { +public: + EraseReply(const uint8_t* datafield) { + region = *datafield; + } + + uint8_t getRegion() { + return region; + } + +private: + uint8_t region = 0; +}; + +class ChecksumSet: + public StaticLocalDataSet { +public: + + // Size of dataset + static const size_t SIZE = 156; + + ChecksumSet(HasLocalDataPoolIF* owner): + StaticLocalDataSet(owner, CHECKSUM_SET_ID) { + } + + ChecksumSet(object_id_t objectId): + StaticLocalDataSet(sid_t(objectId, CHECKSUM_SET_ID)) { + } + + lp_var_t checksum = lp_var_t(sid.objectId, PoolIds::CHKSUM, this); +}; } #endif /* MISSION_STARTRACKER_DEFINITIONS_H_ */ diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp index 7ae5d72c..d2d793a1 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp @@ -17,7 +17,7 @@ StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie, StrHelper* strHelper) : DeviceHandlerBase(objectId, comIF, comCookie), temperatureSet(this), versionSet(this), powerSet( this), interfaceSet(this), timeSet(this), solutionSet(this), histogramSet(this), - contrastSet(this), strHelper(strHelper) { + contrastSet(this), checksumSet(this), strHelper(strHelper) { if (comCookie == nullptr) { sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl; } @@ -416,6 +416,10 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi result = prepareParamCommand(commandData, commandDataLen, tracking); return result; } + case (StarTracker::ERASE): { + result = prepareEraseCommand(commandData, commandDataLen); + return result; + } case (StarTracker::UNLOCK): { result = prepareUnlockCommand(commandData, commandDataLen); return result; @@ -482,6 +486,8 @@ void StarTrackerHandler::fillCommandAndReplyMap() { StarTracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(StarTracker::RESET_ERROR, 3, nullptr, StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::ERASE, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(StarTracker::UNLOCK, 3, nullptr, StarTracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(StarTracker::CHECKSUM, 3, nullptr, @@ -561,6 +567,10 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con result = handleActionReply(); break; } + case (StarTracker::ERASE): { + result = handleEraseReply(); + break; + } case (StarTracker::CHECKSUM): { result = handleChecksumReply(); break; @@ -785,7 +795,7 @@ ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& l localDataPoolMap.emplace(StarTracker::CONTRAST_BIND6, new PoolEntry( { 0 })); localDataPoolMap.emplace(StarTracker::CONTRAST_BIND7, new PoolEntry( { 0 })); localDataPoolMap.emplace(StarTracker::CONTRAST_BIND8, new PoolEntry( { 0 })); - + localDataPoolMap.emplace(StarTracker::CHKSUM, new PoolEntry( { 0 })); return RETURN_OK; } @@ -840,6 +850,10 @@ ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t *foundId) *foundId = StarTracker::RESET_ERROR; break; } + case (StarTracker::ID::ERASE): { + *foundId = StarTracker::ERASE; + break; + } case (StarTracker::ID::UNLOCK): { *foundId = StarTracker::UNLOCK; break; @@ -1057,7 +1071,25 @@ void StarTrackerHandler::prepareBootCommand() { rawPacketLen = dataLinkLayer.getEncodedLength(); } -ReturnValue_t StarTrackerHandler::prepareUnlockCommand(const uint8_t* commandData, size_t commandDataLen) { +ReturnValue_t StarTrackerHandler::prepareEraseCommand(const uint8_t* commandData, + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + if (commandDataLen != EraseCmd::LENGTH) { + return INVALID_LENGTH; + } + uint32_t length = 0; + struct EraseActionRequest req; + req.region = *commandData; + arc_pack_erase_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + eraseCmd.rememberRegion = req.region; + return result; +} + +ReturnValue_t StarTrackerHandler::prepareUnlockCommand(const uint8_t* commandData, + size_t commandDataLen) { ReturnValue_t result = RETURN_OK; uint32_t length = 0; struct UnlockActionRequest req; @@ -1292,6 +1324,21 @@ ReturnValue_t StarTrackerHandler::handleActionReply() { return RETURN_OK; } +ReturnValue_t StarTrackerHandler::handleEraseReply() { + ReturnValue_t result = RETURN_OK; + result = handleActionReply(); + if (result != RETURN_OK) { + return result; + } + const uint8_t* replyData = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; + StarTracker::EraseReply eraseReply(replyData); + if (eraseReply.getRegion() != eraseCmd.rememberRegion) { + sif::warning << "StarTrackerHandler::handleEraseReply: Region mismatch" << std::endl; + return REGION_MISMATCH; + } + return result; +} + ReturnValue_t StarTrackerHandler::handleChecksumReply() { ReturnValue_t result = RETURN_OK; result = handleActionReply(); @@ -1312,6 +1359,9 @@ ReturnValue_t StarTrackerHandler::handleChecksumReply() { sif::warning << "StarTrackerHandler::handleChecksumReply: Length mismatch" << std::endl; return LENGTH_MISSMATCH; } + PoolReadGuard rg(&checksumSet); + checksumSet.checksum = checksumReply.getChecksum(); + handleDeviceTM(&checksumSet, StarTracker::CHECKSUM); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 checksumReply.printChecksum(); #endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.h b/bsp_q7s/devices/startracker/StarTrackerHandler.h index 095105b3..3ed016ae 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.h +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.h @@ -164,6 +164,14 @@ private: static const size_t MIN_LENGTH = 11; }; + class EraseCmd { + public: + static const uint8_t LENGTH = 1; + uint8_t rememberRegion = 0; + }; + + EraseCmd eraseCmd; + class UnlockCmd { public: static const uint8_t CODE_OFFSET = 1; @@ -175,7 +183,6 @@ private: static const uint8_t LENGTH_OFFSET = 5; // Length of checksum command static const size_t LENGTH = 9; - uint8_t rememberRegion = 0; uint32_t rememberAddress = 0; uint32_t rememberLength = 0; @@ -195,6 +202,7 @@ private: StarTracker::SolutionSet solutionSet; StarTracker::HistogramSet histogramSet; StarTracker::ContrastSet contrastSet; + StarTracker::ChecksumSet checksumSet; // Pointer to object responsible for uploading and downloading images to/from the star tracker StrHelper* strHelper = nullptr; @@ -298,6 +306,11 @@ private: */ void prepareBootCommand(); + /** + * @brief Fills command buffer with command to erase a flash region + */ + ReturnValue_t prepareEraseCommand(const uint8_t* commandData, size_t commandDataLen); + /** * @brief Fills command buffer with command to unlock flash region */ @@ -381,6 +394,11 @@ private: */ ReturnValue_t handleActionReply(); + /** + * @brief Handles reply to erase command + */ + ReturnValue_t handleEraseReply(); + /** * @brief Handles reply to checksum command */ From 8d160572c7e18cd48beef336e16cf2eee14212c9 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Fri, 24 Dec 2021 07:51:13 +0100 Subject: [PATCH 173/465] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 827738f6..58ec3c66 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 827738f6efbfbcf32d56397e5c713f136dbd8556 +Subproject commit 58ec3c66409be1e8b9c403f73062f0e187fba021 From e26ffb6afd69e1077d262137eff233437c0b1e9b Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Wed, 29 Dec 2021 20:33:20 +0100 Subject: [PATCH 174/465] fpga download image command --- bsp_q7s/boardtest/Q7STestTask.cpp | 14 +- .../startracker/StarTrackerDefinitions.h | 257 ++++++++++- .../startracker/StarTrackerHandler.cpp | 418 +++++++++++++++++- .../devices/startracker/StarTrackerHandler.h | 104 ++++- bsp_q7s/devices/startracker/StrHelper.cpp | 132 +++++- bsp_q7s/devices/startracker/StrHelper.h | 85 +++- common/config/commonClassIds.h | 1 + generators/bsp_q7s_events.csv | 24 +- generators/events/translateEvents.cpp | 32 +- linux/fsfwconfig/events/translateEvents.cpp | 32 +- mission/memory/NVMParameterBase.h | 18 +- 11 files changed, 1031 insertions(+), 86 deletions(-) diff --git a/bsp_q7s/boardtest/Q7STestTask.cpp b/bsp_q7s/boardtest/Q7STestTask.cpp index 965a6d63..5cead3d5 100644 --- a/bsp_q7s/boardtest/Q7STestTask.cpp +++ b/bsp_q7s/boardtest/Q7STestTask.cpp @@ -127,8 +127,18 @@ void Q7STestTask::testDummyParams() { param.writeJsonFile(); param.print(); - int test = param.getValue(DummyParameter::DUMMY_KEY_PARAM_1); - std::string test2 = param.getValue(DummyParameter::DUMMY_KEY_PARAM_2); + int test = 0; + result = param.getValue(DummyParameter::DUMMY_KEY_PARAM_1, &test); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testDummyParams: Key " << DummyParameter::DUMMY_KEY_PARAM_1 + << " does not exist" << std::endl; + } + std::string test2; + result = param.getValue(DummyParameter::DUMMY_KEY_PARAM_2, &test2); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testDummyParams: Key " << DummyParameter::DUMMY_KEY_PARAM_1 + << " does not exist" << std::endl; + } sif::info << "Test value (3 expected): " << test << std::endl; sif::info << "Test value 2 (\"blirb\" expected): " << test2 << std::endl; } diff --git a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h index 5b839164..c03afa74 100644 --- a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h +++ b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h @@ -158,7 +158,45 @@ enum PoolIds: lp_id_t { CONTRAST_BIND6, CONTRAST_BIND7, CONTRAST_BIND8, - CHKSUM + CHKSUM, + DWL_ID, + DWL_PIXX, + DWL_PIXY, + DWL_X_UNCORRECTED, + DWL_Y_UNCORRECTED, + DWL_X_CORRECTED, + DWL_Y_CORRECTED, + DWL_MAGNITUDE, + DWL_CXA, + DWL_CYA, + DWL_QUALITY, + MATCHEDSTR_ID, + MATCHEDSTR_CAMFPX, + MATCHEDSTR_CAMFPY, + MATCHEDSTR_CAMCARTX, + MATCHEDSTR_CAMCARTY, + MATCHEDSTR_CAMCARTZ, + MATCHEDSTR_CAMMAGNITUDE, + MATCHEDSTR_DBFPX, + MATCHEDSTR_DBFPY, + MATCHEDSTR_DBCARTX, + MATCHEDSTR_DBCARTY, + MATCHEDSTR_DBCARTZ, + MATCHEDSTR_DBMAGNITUDE, + MATCHEDSTR_CATALOGID, + DBIMAGE_ID, + DBIMAGE_PIXX, + DBIMAGE_PIXY, + DBIMAGE_X, + DBIMAGE_Y, + DBIMAGE_MAGNITUDE, + BLOBPIX_ID, + BLOBPIX_X, + BLOBPIX_Y, + BLOBPIX_TOT_VAL, + BLOBPIX_IN_USE, + BLOBPIX_BRIGHT_NEIGHBOURS, + BLOBPIX_REGION }; static const DeviceCommandId_t PING_REQUEST = 0; @@ -195,12 +233,15 @@ static const DeviceCommandId_t CHECKSUM = 50; static const DeviceCommandId_t READ = 51; static const DeviceCommandId_t WRITE = 52; static const DeviceCommandId_t DOWNLOAD_MATCHED_STAR = 53; -static const DeviceCommandId_t DOWNLOAD_DB_IMAGE = 54; static const DeviceCommandId_t STOP_IMAGE_LOADER = 55; static const DeviceCommandId_t RESET_ERROR = 56; static const DeviceCommandId_t CHANGE_DOWNLOAD_FILE = 57; static const DeviceCommandId_t SET_JSON_FILE_NAME = 58; static const DeviceCommandId_t SET_READ_FILENAME = 59; +static const DeviceCommandId_t SET_TIME = 60; +static const DeviceCommandId_t DOWNLOAD_DBIMAGE = 61; +static const DeviceCommandId_t DOWNLOAD_BLOBPIXEL = 62; +static const DeviceCommandId_t DOWNLOAD_FPGA_IMAGE = 63; static const DeviceCommandId_t NONE = 0xFFFFFFFF; static const uint32_t VERSION_SET_ID = REQ_VERSION; @@ -212,6 +253,10 @@ static const uint32_t SOLUTION_SET_ID = REQ_SOLUTION; static const uint32_t HISTOGRAM_SET_ID = REQ_HISTOGRAM; static const uint32_t CONTRAST_SET_ID = REQ_CONTRAST; static const uint32_t CHECKSUM_SET_ID = CHECKSUM; +static const uint32_t DOWNLOADCENTROID_SET_ID = DOWNLOAD_CENTROID; +static const uint32_t DOWNLOAD_MATCHED_STAR_SET_ID = DOWNLOAD_MATCHED_STAR; +static const uint32_t DOWNLOAD_DBIMAGE_SET_ID = DOWNLOAD_DBIMAGE; +static const uint32_t DOWNLOAD_BLOBPIXEL_SET_ID = DOWNLOAD_BLOBPIXEL; /** Max size of unencoded frame */ static const size_t MAX_FRAME_SIZE = 1200; @@ -225,6 +270,10 @@ static const uint8_t SOLUTION_SET_ENTRIES = 23; static const uint8_t HISTOGRAM_SET_ENTRIES = 38; static const uint8_t CONTRAST_SET_ENTRIES = 38; static const uint8_t CHECKSUM_SET_ENTRIES = 1; +static const uint8_t DOWNLOAD_CENTROID_SET_ENTRIES = 11; +static const uint8_t DOWNLOAD_MATCHED_STAR_SET_ENTRIES = 14; +static const uint8_t DOWNLOAD_DBIMAGE_SET_ENTRIES = 6; +static const uint8_t DOWNLOAD_BLOBPIXEL_SET_ENTRIES = 7; // Action, parameter and telemetry IDs namespace ID { @@ -245,6 +294,7 @@ namespace ID { static const uint8_t REBOOT = 7; static const uint8_t UPLOAD_IMAGE = 10; static const uint8_t POWER = 11; + static const uint8_t SET_TIME = 14; static const uint8_t SUBSCRIBE = 18; static const uint8_t SOLUTION = 24; static const uint8_t TEMPERATURE = 25; @@ -258,6 +308,11 @@ namespace ID { static const uint8_t UNLOCK = 6; static const uint8_t TAKE_IMAGE = 15; static const uint8_t ERROR_RESET = 12; + static const uint8_t DOWNLOAD_CENTROID = 16; + static const uint8_t UPLOAD_CENTROID = 17; + static const uint8_t DOWNLOAD_MATCHED_STAR = 18; + static const uint8_t DOWNLOAD_DBIMAGE = 19; + static const uint8_t DOWNLOAD_BLOBPIXEL = 24; } namespace Program { @@ -951,6 +1006,202 @@ public: lp_var_t checksum = lp_var_t(sid.objectId, PoolIds::CHKSUM, this); }; -} +/** + * @brief Dataset to store download centroid response + */ +class DownloadCentroidSet: + public StaticLocalDataSet { +public: + + // Size of dataset + static const size_t SIZE = 34; + + DownloadCentroidSet(HasLocalDataPoolIF* owner): + StaticLocalDataSet(owner, DOWNLOADCENTROID_SET_ID) { + } + + DownloadCentroidSet(object_id_t objectId): + StaticLocalDataSet(sid_t(objectId, DOWNLOADCENTROID_SET_ID)) { + } + + lp_var_t id = lp_var_t(sid.objectId, PoolIds::DWL_ID, this); + lp_var_t pixx = lp_var_t(sid.objectId, PoolIds::DWL_PIXX, this); + lp_var_t pixy = lp_var_t(sid.objectId, PoolIds::DWL_PIXY, this); + lp_var_t xUncorrected = lp_var_t(sid.objectId, PoolIds::DWL_X_UNCORRECTED, this); + lp_var_t yUncorrected = lp_var_t(sid.objectId, PoolIds::DWL_Y_UNCORRECTED, this); + lp_var_t xCorrected = lp_var_t(sid.objectId, PoolIds::DWL_X_CORRECTED, this); + lp_var_t yCorrected = lp_var_t(sid.objectId, PoolIds::DWL_Y_CORRECTED, this); + lp_var_t magnitude = lp_var_t(sid.objectId, PoolIds::DWL_MAGNITUDE, this); + lp_var_t cxa = lp_var_t(sid.objectId, PoolIds::DWL_CXA, this); + lp_var_t cya = lp_var_t(sid.objectId, PoolIds::DWL_CYA, this); + lp_var_t quality = lp_var_t(sid.objectId, PoolIds::DWL_QUALITY, this); + + void printSet() { + PoolReadGuard rg(this); + sif::info << "ContrastSet::printSet: id: " << static_cast(this->id.value) + << std::endl; + sif::info << "ContrastSet::printSet: pixx: " << this->pixx << std::endl; + sif::info << "ContrastSet::printSet: pixy: " << this->pixy << std::endl; + sif::info << "ContrastSet::printSet: xUncorrected: " << this->xUncorrected << std::endl; + sif::info << "ContrastSet::printSet: yUncorrected: " << this->yUncorrected << std::endl; + sif::info << "ContrastSet::printSet: xCorrected: " << this->xCorrected << std::endl; + sif::info << "ContrastSet::printSet: yCorrected: " << this->yCorrected << std::endl; + sif::info << "ContrastSet::printSet: magnitude: " << this->magnitude << std::endl; + sif::info << "ContrastSet::printSet: cxa: " << this->cxa << std::endl; + sif::info << "ContrastSet::printSet: cya: " << this->cya << std::endl; + sif::info << "ContrastSet::printSet: quality: " << this->quality << std::endl; + } +}; + +namespace UploadCentroidKeys { + static const char id[] = "id"; + static const char pixx[] = "pixx"; + static const char pixy[] = "pixy"; + static const char x_uncorrected[] = "x_uncorrected"; + static const char y_uncorrected[] = "y_uncorrected"; + static const char x_corrected[] = "x_corrected"; + static const char y_corrected[] = "y_corrected"; + static const char magnitude[] = "magnitude"; + static const char cxa[] = "cxa"; + static const char cya[] = "cya"; + static const char quality[] = "quality"; +}; + +/** + * @brief Dataset to store matched star information + */ +class DownloadMatchedStar : + public StaticLocalDataSet { +public: + + // Size of dataset + static const size_t SIZE = 53; + + DownloadMatchedStar(HasLocalDataPoolIF* owner): + StaticLocalDataSet(owner, DOWNLOAD_MATCHED_STAR_SET_ID) { + } + + DownloadMatchedStar(object_id_t objectId): + StaticLocalDataSet(sid_t(objectId, DOWNLOAD_MATCHED_STAR_SET_ID)) { + } + + lp_var_t id = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_ID, this); + lp_var_t camfpx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMFPX, this); + lp_var_t camfpy = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMFPY, this); + lp_var_t camcartx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTX, this); + lp_var_t camcarty = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTY, this); + lp_var_t camcartz = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTZ, this); + lp_var_t cammagnitude = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMMAGNITUDE, + this); + lp_var_t dbfpx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBFPX, this); + lp_var_t dbfpy = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBFPY, this); + lp_var_t dbcartx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBCARTX, this); + lp_var_t dbcarty = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBCARTY, this); + lp_var_t dbcartz = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBCARTZ, this); + lp_var_t dbmagnitude = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBMAGNITUDE, + this); + lp_var_t catalogid = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CATALOGID, + this); + + void printSet() { + PoolReadGuard rg(this); + sif::info << "DownloadMatchedStar::printSet: id: " + << static_cast(this->id.value) << std::endl; + sif::info << "DownloadMatchedStar::printSet: camfpx: " << this->camfpx << std::endl; + sif::info << "DownloadMatchedStar::printSet: camfpy: " << this->camfpy << std::endl; + sif::info << "DownloadMatchedStar::printSet: camcartx: " << this->camcartx << std::endl; + sif::info << "DownloadMatchedStar::printSet: camcarty: " << this->camcarty << std::endl; + sif::info << "DownloadMatchedStar::printSet: camcartz: " << this->camcartz << std::endl; + sif::info << "DownloadMatchedStar::printSet: cammagnitude: " << this->cammagnitude + << std::endl; + sif::info << "DownloadMatchedStar::printSet: dbfpx: " << this->dbfpx << std::endl; + sif::info << "DownloadMatchedStar::printSet: dbfpy: " << this->dbfpy << std::endl; + sif::info << "DownloadMatchedStar::printSet: dbcartx: " << this->dbcartx << std::endl; + sif::info << "DownloadMatchedStar::printSet: dbcarty: " << this->dbcarty << std::endl; + sif::info << "DownloadMatchedStar::printSet: dbcartz: " << this->dbcartz << std::endl; + sif::info << "DownloadMatchedStar::printSet: dbmagnitude: " << this->dbmagnitude + << std::endl; + sif::info << "DownloadMatchedStar::printSet: catalogid: " << this->catalogid << std::endl; + } +}; + +/** + * @brief Dataset to store the response to the DownloadDBImage request + */ +class DownloadDBImage : + public StaticLocalDataSet { +public: + + // Size of dataset + static const size_t SIZE = 21; + + DownloadDBImage(HasLocalDataPoolIF* owner): + StaticLocalDataSet(owner, DOWNLOAD_DBIMAGE_SET_ID) { + } + + DownloadDBImage(object_id_t objectId): + StaticLocalDataSet(sid_t(objectId, DOWNLOAD_DBIMAGE_SET_ID)) { + } + + lp_var_t id = lp_var_t(sid.objectId, PoolIds::DBIMAGE_ID, this); + lp_var_t pixx = lp_var_t(sid.objectId, PoolIds::DBIMAGE_PIXX, this); + lp_var_t pixy = lp_var_t(sid.objectId, PoolIds::DBIMAGE_PIXY, this); + lp_var_t x = lp_var_t(sid.objectId, PoolIds::DBIMAGE_X, this); + lp_var_t y = lp_var_t(sid.objectId, PoolIds::DBIMAGE_Y, this); + lp_var_t magnitude = lp_var_t(sid.objectId, PoolIds::DBIMAGE_MAGNITUDE, this); + + void printSet() { + PoolReadGuard rg(this); + sif::info << "DownloadDBImage::printSet: id: " + << static_cast(this->id.value) << std::endl; + sif::info << "DownloadDBImage::printSet: pixx: " << this->pixx << std::endl; + sif::info << "DownloadDBImage::printSet: pixy: " << this->pixy << std::endl; + sif::info << "DownloadDBImage::printSet: x: " << this->x << std::endl; + sif::info << "DownloadDBImage::printSet: y: " << this->y << std::endl; + sif::info << "DownloadDBImage::printSet: magnitude: " << this->magnitude << std::endl; + } +}; + +/** + * @brief Dataset to store the response to the download blob pixel action request + */ +class DownloadBlobPixel: public StaticLocalDataSet { +public: + + // Size of dataset + static const size_t SIZE = 22; + + DownloadBlobPixel(HasLocalDataPoolIF* owner) : + StaticLocalDataSet(owner, DOWNLOAD_BLOBPIXEL_SET_ID) { + } + + DownloadBlobPixel(object_id_t objectId) : + StaticLocalDataSet(sid_t(objectId, DOWNLOAD_BLOBPIXEL_SET_ENTRIES)) { + } + + lp_var_t id = lp_var_t(sid.objectId, PoolIds::BLOBPIX_ID, this); + lp_var_t x = lp_var_t(sid.objectId, PoolIds::BLOBPIX_X, this); + lp_var_t y = lp_var_t(sid.objectId, PoolIds::BLOBPIX_Y, this); + lp_var_t totalValue = lp_var_t(sid.objectId, PoolIds::BLOBPIX_TOT_VAL, this); + lp_var_t inUse = lp_var_t(sid.objectId, PoolIds::BLOBPIX_IN_USE, this); + lp_var_t brightNeighbours = lp_var_t(sid.objectId, + PoolIds::BLOBPIX_BRIGHT_NEIGHBOURS, this); + lp_var_t region = lp_var_t(sid.objectId, PoolIds::BLOBPIX_REGION, this); + + void printSet() { + PoolReadGuard rg(this); + sif::info << "DownloadBlobPixel::printSet: id: " + << static_cast(this->id.value) << std::endl; + sif::info << "DownloadBlobPixel::printSet: x: " << this->x << std::endl; + sif::info << "DownloadBlobPixel::printSet: y: " << this->y << std::endl; + sif::info << "DownloadBlobPixel::printSet: totalValue: " << this->totalValue << std::endl; + sif::info << "DownloadBlobPixel::printSet: inUse: " + << static_cast(this->inUse.value) << std::endl; + sif::info << "DownloadBlobPixel::printSet: brightNeighbours: " << this->brightNeighbours + << std::endl; + sif::info << "DownloadBlobPixel::printSet: region: " << this->region << std::endl; + } +}; +} #endif /* MISSION_STARTRACKER_DEFINITIONS_H_ */ diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp index d2d793a1..57aa5dfc 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp @@ -1,23 +1,25 @@ #include - #include "StarTrackerHandler.h" #include "OBSWConfig.h" #include "StarTrackerJsonCommands.h" - #include #include - +#include extern "C" { #include #include #include "common/misc.h" } +using json = nlohmann::json; + StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie, StrHelper* strHelper) : DeviceHandlerBase(objectId, comIF, comCookie), temperatureSet(this), versionSet(this), powerSet( - this), interfaceSet(this), timeSet(this), solutionSet(this), histogramSet(this), - contrastSet(this), checksumSet(this), strHelper(strHelper) { + this), interfaceSet(this), timeSet(this), solutionSet(this), histogramSet(this), contrastSet( + this), checksumSet(this), downloadCentroidSet(this), downloadMatchedStar(this), + downloadDbImage(this), downloadBlobPixel(this), strHelper( + strHelper) { if (comCookie == nullptr) { sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl; } @@ -51,7 +53,7 @@ ReturnValue_t StarTrackerHandler::initialize() { } result = manager->subscribeToEventRange(eventQueue->getId(), event::getEventId(StrHelper::IMAGE_UPLOAD_FAILED), - event::getEventId(StrHelper::FLASH_READ_FAILED)); + event::getEventId(StrHelper::FPGA_UPLOAD_FAILED)); if (result != RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "StarTrackerHandler::initialize: Failed to subscribe to events from " @@ -173,6 +175,21 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu std::string(reinterpret_cast(data), size)); return EXECUTION_FINISHED; } + case(StarTracker::DOWNLOAD_FPGA_IMAGE): { + result = DeviceHandlerBase::acceptExternalDeviceCommands(); + if (result != RETURN_OK) { + return result; + } + if (size > MAX_PATH_SIZE) { + return FILE_PATH_TOO_LONG; + } + result = executeFpgaDownloadCommand(data, size); + if (result != RETURN_OK) { + return result; + } + strHelperExecuting = true; + return EXECUTION_FINISHED; + } default: break; } @@ -428,6 +445,30 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi result = prepareChecksumCommand(commandData, commandDataLen); return result; } + case (StarTracker::SET_TIME): { + result = prepareSetTimeCommand(commandData, commandDataLen); + return result; + } + case (StarTracker::DOWNLOAD_CENTROID): { + result = prepareDownloadCentroidCommand(commandData, commandDataLen); + return result; + } + case (StarTracker::UPLOAD_CENTROID): { + result = prepareUploadCentroidCommand(commandData, commandDataLen); + return result; + } + case (StarTracker::DOWNLOAD_MATCHED_STAR): { + result = prepareDownloadMatchedStarCommand(commandData, commandDataLen); + return result; + } + case (StarTracker::DOWNLOAD_DBIMAGE): { + result = prepareDownloadDbImageCommand(commandData, commandDataLen); + return result; + } + case (StarTracker::DOWNLOAD_BLOBPIXEL): { + result = prepareDownloadBlobPixelCommand(commandData, commandDataLen); + return result; + } default: return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } @@ -492,6 +533,18 @@ void StarTrackerHandler::fillCommandAndReplyMap() { StarTracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(StarTracker::CHECKSUM, 3, nullptr, StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::SET_TIME, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_CENTROID, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::UPLOAD_CENTROID, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_MATCHED_STAR, 3, &downloadMatchedStar, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_DBIMAGE, 3, &downloadDbImage, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_BLOBPIXEL, 3, &downloadBlobPixel, + StarTracker::MAX_FRAME_SIZE * 2 + 2); } ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t remainingSize, @@ -563,10 +616,31 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con case (StarTracker::BOOT): case (StarTracker::TAKE_IMAGE): case (StarTracker::RESET_ERROR): - case (StarTracker::UNLOCK): { + case (StarTracker::UNLOCK): + case (StarTracker::SET_TIME): { result = handleActionReply(); break; } + case (StarTracker::DOWNLOAD_CENTROID): { + result = handleActionReplySet(downloadCentroidSet, StarTracker::DownloadCentroidSet::SIZE); + break; + } + case (StarTracker::DOWNLOAD_MATCHED_STAR): { + result = handleActionReplySet(downloadMatchedStar, StarTracker::DownloadMatchedStar::SIZE); + break; + } + case (StarTracker::DOWNLOAD_DBIMAGE): { + result = handleActionReplySet(downloadDbImage, StarTracker::DownloadDBImage::SIZE); + break; + } + case (StarTracker::DOWNLOAD_BLOBPIXEL): { + result = handleActionReplySet(downloadBlobPixel, StarTracker::DownloadBlobPixel::SIZE); + break; + } + case (StarTracker::UPLOAD_CENTROID): { + result = handleUploadCentroidReply(); + break; + } case (StarTracker::ERASE): { result = handleEraseReply(); break; @@ -796,6 +870,41 @@ ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& l localDataPoolMap.emplace(StarTracker::CONTRAST_BIND7, new PoolEntry( { 0 })); localDataPoolMap.emplace(StarTracker::CONTRAST_BIND8, new PoolEntry( { 0 })); localDataPoolMap.emplace(StarTracker::CHKSUM, new PoolEntry( { 0 })); + + localDataPoolMap.emplace(StarTracker::DWL_ID, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::DWL_PIXX, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::DWL_PIXY, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::DWL_X_UNCORRECTED, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::DWL_Y_UNCORRECTED, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::DWL_X_CORRECTED, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::DWL_Y_CORRECTED, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::DWL_MAGNITUDE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::DWL_CXA, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::DWL_CYA, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::DWL_QUALITY, new PoolEntry( { 0 })); + + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_ID, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMFPX, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMFPY, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTX, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTY, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTZ, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMMAGNITUDE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBFPX, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBFPY, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTX, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTY, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTZ, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBMAGNITUDE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CATALOGID, new PoolEntry( { 0 })); + + localDataPoolMap.emplace(StarTracker::BLOBPIX_ID, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOBPIX_X, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOBPIX_Y, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOBPIX_TOT_VAL, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOBPIX_IN_USE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOBPIX_BRIGHT_NEIGHBOURS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOBPIX_REGION, new PoolEntry( { 0 })); return RETURN_OK; } @@ -862,6 +971,30 @@ ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t *foundId) *foundId = StarTracker::CHECKSUM; break; } + case (StarTracker::ID::SET_TIME): { + *foundId = StarTracker::SET_TIME; + break; + } + case (StarTracker::ID::DOWNLOAD_CENTROID): { + *foundId = StarTracker::DOWNLOAD_CENTROID; + break; + } + case (StarTracker::ID::UPLOAD_CENTROID): { + *foundId = StarTracker::UPLOAD_CENTROID; + break; + } + case (StarTracker::ID::DOWNLOAD_MATCHED_STAR): { + *foundId = StarTracker::DOWNLOAD_MATCHED_STAR; + break; + } + case (StarTracker::ID::DOWNLOAD_DBIMAGE): { + *foundId = StarTracker::DOWNLOAD_DBIMAGE; + break; + } + case (StarTracker::ID::DOWNLOAD_BLOBPIXEL): { + *foundId = StarTracker::DOWNLOAD_BLOBPIXEL; + break; + } default: sif::warning << "StarTrackerHandler::scanForParameterReply: Unknown parameter reply id" << std::endl; @@ -1019,6 +1152,46 @@ ReturnValue_t StarTrackerHandler::executeWriteCommand(const uint8_t* commandData return result; } +ReturnValue_t StarTrackerHandler::executeFpgaDownloadCommand(const uint8_t* commandData, + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + if (commandDataLen < FpgaDownloadCmd::MIN_LENGTH) { + sif::warning << "StarTrackerHandler::executeFpgaDownloadCommand: Command too short" + << std::endl; + return COMMAND_TOO_SHORT; + } + uint32_t position; + size_t size = sizeof(position); + result = SerializeAdapter::deSerialize(&position, &commandData, &size, + SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of position failed" + << std::endl; + return result; + } + uint32_t length; + size = sizeof(length); + result = SerializeAdapter::deSerialize(&length, &commandData, &size, + SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of length failed" + << std::endl; + return result; + } + if (commandDataLen - sizeof(position) - sizeof(length) > MAX_PATH_SIZE) { + sif::warning << "StarTrackerHandler::executeFpgaDownloadCommand: Received command with " + " invalid path and filename" << std::endl; + return FILE_PATH_TOO_LONG; + } + std::string fullname = std::string(reinterpret_cast(commandData), + commandDataLen - sizeof(position) - sizeof(length)); + result = strHelper->startFpgaDownload(fullname, position, length); + if (result != RETURN_OK) { + return result; + } + return result; +} + ReturnValue_t StarTrackerHandler::executeReadCommand(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t result = RETURN_OK; @@ -1146,6 +1319,140 @@ ReturnValue_t StarTrackerHandler::prepareChecksumCommand(const uint8_t* commandD return result; } + +ReturnValue_t StarTrackerHandler::prepareSetTimeCommand(const uint8_t* commandData, + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + struct SetTimeActionRequest req; + if (commandDataLen != SetTimeCmd::LENGTH) { + sif::warning << "StarTrackerHandler::prepareSetTimeCommand: Invalid length" << std::endl; + return INVALID_LENGTH; + } + size_t size = sizeof(req.unixTime); + result = SerializeAdapter::deSerialize(&req.unixTime, commandData, &size, + SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::prepareSetTimeCommand: Deserialization failed" + << std::endl; + return result; + } + uint32_t length = 0; + arc_pack_settime_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return result; +} + +ReturnValue_t StarTrackerHandler::prepareDownloadCentroidCommand(const uint8_t* commandData, + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + struct DownloadCentroidActionRequest req; + if (commandDataLen != DownloadCentroidCmd::LENGTH) { + sif::warning << "StarTrackerHandler::prepareDownloadCentroidCommand: Invalid length" + << std::endl; + return INVALID_LENGTH; + } + req.id = *commandData; + uint32_t length = 0; + arc_pack_downloadcentroid_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return result; +} + +ReturnValue_t StarTrackerHandler::prepareUploadCentroidCommand(const uint8_t* commandData, + size_t commandDataLen) { + if (commandDataLen > MAX_PATH_SIZE) { + return FILE_PATH_TOO_LONG; + } + ReturnValue_t result = RETURN_OK; + struct UploadCentroidActionRequest req; + std::string jsonFileName = std::string(reinterpret_cast(commandData), + commandDataLen); + NVMParameterBase j(jsonFileName); + result = j.readJsonFile(); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: " << jsonFileName + << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::id, &req.id); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::id << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::pixx, &req.pixx); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::pixx << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::pixy, &req.pixy); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::pixy << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::x_uncorrected, &req.x_uncorrected); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::x_uncorrected << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::y_uncorrected, &req.y_uncorrected); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::y_uncorrected << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::x_corrected, &req.x_corrected); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::x_corrected << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::y_corrected, &req.y_corrected); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::y_corrected << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::magnitude, &req.magnitude); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::magnitude << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::cxa, &req.cxa); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::cxa << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::cya, &req.cya); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::cya << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::quality, &req.quality); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::quality << " does not exist" << std::endl; + return result; + } + uint32_t length = 0; + arc_pack_uploadcentroid_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + uploadCentroid.rememberId = req.id; + return result; +} + void StarTrackerHandler::prepareTimeRequest() { uint32_t length = 0; arc_tm_pack_time_req(commandBuffer, &length); @@ -1293,6 +1600,55 @@ ReturnValue_t StarTrackerHandler::prepareParamCommand(const uint8_t* commandData return RETURN_OK; } +ReturnValue_t StarTrackerHandler::prepareDownloadMatchedStarCommand(const uint8_t* commandData, + size_t commandDataLen) { + if (commandDataLen != DownloadMatchedStarCmd::LENGTH) { + return INVALID_LENGTH; + } + struct DownloadMatchedStarActionRequest req; + req.id = *commandData; + uint32_t length = 0; + arc_pack_downloadmatchedstar_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; +} + +ReturnValue_t StarTrackerHandler::prepareDownloadDbImageCommand(const uint8_t* commandData, + size_t commandDataLen) { + if (commandDataLen != DownloadDbImageCmd::LENGTH) { + return INVALID_LENGTH; + } + struct DownloadDBImageActionRequest req; + req.id = *commandData; + uint32_t length = 0; + arc_pack_downloaddbimage_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; +} + +ReturnValue_t StarTrackerHandler::prepareDownloadBlobPixelCommand(const uint8_t* commandData, + size_t commandDataLen) { + if (commandDataLen != DownloadBlobPixCmd::LENGTH) { + return INVALID_LENGTH; + } + struct DownloadBlobPixelActionRequest req; + req.id = *commandData; + req.type = *(commandData + 1); + if ((req.type != DownloadBlobPixCmd::NORMAL) && (req.type != DownloadBlobPixCmd::FAST)) { + return INVALID_TYPE; + } + uint32_t length = 0; + arc_pack_downloadblobpixel_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; +} + ReturnValue_t StarTrackerHandler::handleSetParamReply() { const uint8_t* reply = dataLinkLayer.getReply(); uint8_t status = *(reply + STATUS_OFFSET); @@ -1316,7 +1672,7 @@ ReturnValue_t StarTrackerHandler::handleActionReply() { uint8_t status = *(reply + STATUS_OFFSET); if (status != StarTracker::STATUS_OK) { sif::warning << "StarTrackerHandler::handleActionReply: Failed to execute action " - << " command with action ID " + << "command with action ID " << static_cast(*(reply + ACTION_ID_OFFSET)) << " and status "<< static_cast(status) << std::endl; return ACTION_FAILED; @@ -1324,6 +1680,19 @@ ReturnValue_t StarTrackerHandler::handleActionReply() { return RETURN_OK; } +ReturnValue_t StarTrackerHandler::handleUploadCentroidReply() { + ReturnValue_t result = RETURN_OK; + result = handleActionReply(); + if (result != RETURN_OK) { + return result; + } + const uint8_t* reply = dataLinkLayer.getReply(); + if (*(reply + ACTION_DATA_OFFSET) != uploadCentroid.rememberId) { + return UPLOAD_CENTROID_ID_MISMATCH; + } + return RETURN_OK; +} + ReturnValue_t StarTrackerHandler::handleEraseReply() { ReturnValue_t result = RETURN_OK; result = handleActionReply(); @@ -1422,7 +1791,7 @@ ReturnValue_t StarTrackerHandler::handleTm(LocalPoolDataSetBase& dataset, size_t if(status != StarTracker::STATUS_OK) { sif::warning << "StarTrackerHandler::handleTm: Reply error: " << static_cast(status) << std::endl; - return TM_REPLY_ERROR; + return REPLY_ERROR; } result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); if (result != RETURN_OK) { @@ -1447,6 +1816,37 @@ ReturnValue_t StarTrackerHandler::handleTm(LocalPoolDataSetBase& dataset, size_t return result; } +ReturnValue_t StarTrackerHandler::handleActionReplySet(LocalPoolDataSetBase& dataset, size_t size) { + ReturnValue_t result = RETURN_OK; + uint8_t status = *(dataLinkLayer.getReply() + STATUS_OFFSET); + if(status != StarTracker::STATUS_OK) { + sif::warning << "StarTrackerHandler::handleActionReplySet: Reply error: " + << static_cast(status) << std::endl; + return REPLY_ERROR; + } + result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { + return result; + } + const uint8_t* reply = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; + dataset.setValidityBufferGeneration(false); + result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::handleActionReplySet Deserialization failed" + << std::endl; + } + dataset.setValidityBufferGeneration(true); + dataset.setValidity(true, true); + result = dataset.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { + return result; + } +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 + dataset.printSet(); +#endif + return result; +} + void StarTrackerHandler::handleStartup(const uint8_t* parameterId) { switch(*parameterId) { case (StarTracker::ID::LIMITS): { diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.h b/bsp_q7s/devices/startracker/StarTrackerHandler.h index 3ed016ae..d26c8aea 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.h +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.h @@ -111,8 +111,8 @@ private: static const ReturnValue_t FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xAC); //! [EXPORT] : [COMMENT] Received version reply with invalid program ID static const ReturnValue_t INVALID_PROGRAM = MAKE_RETURN_CODE(0xAD); - //! [EXPORT] : [COMMENT] Status field of tm reply signals error - static const ReturnValue_t TM_REPLY_ERROR = MAKE_RETURN_CODE(0xAE); + //! [EXPORT] : [COMMENT] Status field reply signals error + static const ReturnValue_t REPLY_ERROR = MAKE_RETURN_CODE(0xAE); //! [EXPORT] : [COMMENT] Status field of contrast reply signals error static const ReturnValue_t CONTRAST_REQ_FAILED = MAKE_RETURN_CODE(0xAE); //! [EXPORT] : [COMMENT] Received command which is too short (some data is missing for proper execution) @@ -125,6 +125,12 @@ private: static const ReturnValue_t ADDRESS_MISMATCH = MAKE_RETURN_CODE(0xB2); //! [EXPORT] : [COMMENT] Length field mismatch between send and received data static const ReturnValue_t lENGTH_MISMATCH = MAKE_RETURN_CODE(0xB3); + //! [EXPORT] : [COMMENT] Specified file does not exist + static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xB4); + //! [EXPORT] : [COMMENT] Reply to upload centroid does not match commanded centroid id + static const ReturnValue_t UPLOAD_CENTROID_ID_MISMATCH = MAKE_RETURN_CODE(0xB5); + //! [EXPORT] : [COMMENT] Download blob pixel command has invalid type field + static const ReturnValue_t INVALID_TYPE = MAKE_RETURN_CODE(0xB6); static const size_t MAX_PATH_SIZE = 50; static const size_t MAX_FILE_NAME = 30; @@ -190,6 +196,45 @@ private: ChecksumCmd checksumCmd; + class SetTimeCmd { + public: + static const uint8_t LENGTH = 8; + }; + + class DownloadCentroidCmd { + public: + static const uint8_t LENGTH = 1; + }; + + class UploadCentroid { + public: + uint8_t rememberId = 0; + }; + + UploadCentroid uploadCentroid; + + class DownloadMatchedStarCmd { + public: + static const uint8_t LENGTH = 1; + }; + + class DownloadDbImageCmd { + public: + static const uint8_t LENGTH = 1; + }; + + class DownloadBlobPixCmd { + public: + static const uint8_t LENGTH = 2; + static const uint8_t NORMAL = 0; + static const uint8_t FAST = 1; + }; + + class FpgaDownloadCmd { + public: + static const uint8_t MIN_LENGTH = 10; + }; + MessageQueueIF* eventQueue = nullptr; ArcsecDatalinkLayer dataLinkLayer; @@ -203,6 +248,10 @@ private: StarTracker::HistogramSet histogramSet; StarTracker::ContrastSet contrastSet; StarTracker::ChecksumSet checksumSet; + StarTracker::DownloadCentroidSet downloadCentroidSet; + StarTracker::DownloadMatchedStar downloadMatchedStar; + StarTracker::DownloadDBImage downloadDbImage; + StarTracker::DownloadBlobPixel downloadBlobPixel; // Pointer to object responsible for uploading and downloading images to/from the star tracker StrHelper* strHelper = nullptr; @@ -289,6 +338,14 @@ private: */ ReturnValue_t executeWriteCommand(const uint8_t* commandData, size_t commandDataLen); + /** + * @brief Starts the execution of the fpga download command + * + * @param commandData Pointer to buffer with command data + * @param commandDataLen Size of received command + */ + ReturnValue_t executeFpgaDownloadCommand(const uint8_t* commandData, size_t commandDataLen); + /** * @brief Extracts information for flash-read-command from TC data and starts execution of * flash-read-procedure @@ -321,6 +378,21 @@ private: */ ReturnValue_t prepareChecksumCommand(const uint8_t* commandData, size_t commandDataLen); + /** + * @brief Fills command buffer with command to set the unix time + */ + ReturnValue_t prepareSetTimeCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills command buffer with command to request a centroid + */ + ReturnValue_t prepareDownloadCentroidCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills command buffer with command to upload a centroid for testing purpose + */ + ReturnValue_t prepareUploadCentroidCommand(const uint8_t* commandData, size_t commandDataLen); + /** * @brief Fills the command buffer with the command to take an image. */ @@ -389,11 +461,39 @@ private: ReturnValue_t prepareParamCommand(const uint8_t* commandData, size_t commandDataLen, ArcsecJsonParamBase& paramSet); + /** + * @brief Fills command buffer with data to request matched star. + */ + ReturnValue_t prepareDownloadMatchedStarCommand(const uint8_t* commandData, + size_t commandDataLen); + + /** + * @brief Fills command buffer with data to request matched star coordinates. + */ + ReturnValue_t prepareDownloadDbImageCommand(const uint8_t* commandData, + size_t commandDataLen); + + /** + * @brief Fills command buffer with data to request output of the blob filter algorithm. + */ + ReturnValue_t prepareDownloadBlobPixelCommand(const uint8_t* commandData, + size_t commandDataLen); + + /** + * @brief Handles action replies with datasets. + */ + ReturnValue_t handleActionReplySet(LocalPoolDataSetBase& dataset, size_t size); + /** * @brief Default function to handle action replies */ ReturnValue_t handleActionReply(); + /** + * @brief Handles reply to upload centroid command + */ + ReturnValue_t handleUploadCentroidReply(); + /** * @brief Handles reply to erase command */ diff --git a/bsp_q7s/devices/startracker/StrHelper.cpp b/bsp_q7s/devices/startracker/StrHelper.cpp index fa7b510f..9ee2ce0e 100644 --- a/bsp_q7s/devices/startracker/StrHelper.cpp +++ b/bsp_q7s/devices/startracker/StrHelper.cpp @@ -74,6 +74,17 @@ ReturnValue_t StrHelper::performOperation(uint8_t operationCode) { internalState = InternalState::IDLE; break; } + case InternalState::DOWNLOAD_FPGA_IMAGE: { + result = performFpgaDownload(); + if (result == RETURN_OK){ + triggerEvent(FPGA_DOWNLOAD_SUCCESSFUL); + } + else { + triggerEvent(FPGA_DOWNLOAD_FAILED); + } + internalState = InternalState::IDLE; + break; + } default: sif::debug << "StrHelper::performOperation: Invalid state" << std::endl; break; @@ -109,15 +120,15 @@ ReturnValue_t StrHelper::startImageUpload(std::string uploadImage_) { return RETURN_OK; } -ReturnValue_t StrHelper::startImageDownload(std::string downloadPath_) { - ReturnValue_t result = checkPath(downloadPath_); +ReturnValue_t StrHelper::startImageDownload(std::string downloadImagePath_) { + ReturnValue_t result = checkPath(downloadImagePath_); if (result != RETURN_OK) { return result; } - if(not std::filesystem::exists(downloadPath_)) { + if(not std::filesystem::exists(downloadImagePath_)) { return PATH_NOT_EXISTS; } - downloadPath = downloadPath_; + downloadImagePath = downloadImagePath_; internalState = InternalState::DOWNLOAD_IMAGE; terminate = false; semaphore.release(); @@ -173,19 +184,30 @@ ReturnValue_t StrHelper::startFlashRead(std::string flashReadPath_, uint8_t regi return RETURN_OK; } +ReturnValue_t StrHelper::startFpgaDownload(std::string path, uint32_t startPosition, + uint32_t length) { + fpgaDownload.path = path; + fpgaDownload.startPosition = startPosition; + fpgaDownload.length = length; + internalState = InternalState::DOWNLOAD_FPGA_IMAGE; + semaphore.release(); + terminate = false; + return RETURN_OK; +} + ReturnValue_t StrHelper::performImageDownload() { ReturnValue_t result; struct DownloadActionRequest downloadReq; uint32_t size = 0; uint32_t retries = 0; Timestamp timestamp; - std::string image = downloadPath + "/" + timestamp.str() + downloadImage ; + std::string image = downloadImagePath + "/" + timestamp.str() + downloadImage ; std::ofstream file(image, std::ios_base::app | std::ios_base::out); if(not std::filesystem::exists(image)) { return FILE_CREATION_FAILED; } downloadReq.position = 0; - while(downloadReq.position < LAST_POSITION) { + while(downloadReq.position < ImageDownload::LAST_POSITION) { if (terminate) { return RETURN_OK; } @@ -200,7 +222,7 @@ ReturnValue_t StrHelper::performImageDownload() { file.close(); return result; } - result = checkReply(); + result = checkActionReply(); if (result != RETURN_OK) { if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { uartComIF->flushUartRxBuffer(comCookie); @@ -257,7 +279,7 @@ ReturnValue_t StrHelper::performImageUpload() { if (result != RETURN_OK) { return RETURN_FAILED; } - result = checkReply(); + result = checkActionReply(); if (result != RETURN_OK) { return result; } @@ -274,7 +296,7 @@ ReturnValue_t StrHelper::performImageUpload() { if (result != RETURN_OK) { return RETURN_FAILED; } - result = checkReply(); + result = checkActionReply(); if (result != RETURN_OK) { return result; } @@ -366,7 +388,7 @@ ReturnValue_t StrHelper::performFlashRead() { file.close(); return result; } - result = checkReply(); + result = checkActionReply(); if (result != RETURN_OK) { if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { uartComIF->flushUartRxBuffer(comCookie); @@ -395,6 +417,58 @@ ReturnValue_t StrHelper::performFlashRead() { return RETURN_OK; } +ReturnValue_t StrHelper::performFpgaDownload() { + ReturnValue_t result; + struct DownloadFPGAImageActionRequest req; + uint32_t size = 0; + uint32_t retries = 0; + Timestamp timestamp; + std::string image = fpgaDownload.path + "/" + timestamp.str() + fpgaDownload.fileName; + std::ofstream file(image, std::ios_base::app | std::ios_base::out); + if(not std::filesystem::exists(image)) { + return FILE_CREATION_FAILED; + } + req.pos = fpgaDownload.startPosition; + while(req.pos < fpgaDownload.length) { + if (terminate) { + return RETURN_OK; + } + if (fpgaDownload.length - req.pos >= FpgaDownload::MAX_DATA) { + req.length = FpgaDownload::MAX_DATA; + } + else { + req.length = fpgaDownload.length - req.pos; + } + arc_pack_downloadfpgaimage_action_req(&req, commandBuffer, &size); + result = sendAndRead(size, req.pos); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + result = checkFpgaDownloadReply(req.pos, req.length); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + file.write(reinterpret_cast(datalinkLayer.getReply() + FpgaDownload::DATA_OFFSET), + req.length); + req.pos += req.length; + retries = 0; + } + file.close(); + return RETURN_OK; +} + ReturnValue_t StrHelper::sendAndRead(size_t size, uint32_t parameter) { ReturnValue_t result = RETURN_OK; ReturnValue_t decResult = RETURN_OK; @@ -451,16 +525,16 @@ ReturnValue_t StrHelper::sendAndRead(size_t size, uint32_t parameter) { return RETURN_OK; } -ReturnValue_t StrHelper::checkReply() { +ReturnValue_t StrHelper::checkActionReply() { uint8_t type = datalinkLayer.getReplyFrameType(); if (type != TMTC_ACTIONREPLY) { - sif::warning << "StrHelper::checkReply: Received reply with invalid type ID" + sif::warning << "StrHelper::checkActionReply: Received reply with invalid type ID" << std::endl; return INVALID_TYPE_ID; } uint8_t status = datalinkLayer.getStatusField(); if (status != ArcsecDatalinkLayer::STATUS_OK) { - sif::warning << "StrHelper::checkReply: Status failure: " + sif::warning << "StrHelper::checkActionReply: Status failure: " << static_cast(status) << std::endl; return STATUS_ERROR; } @@ -480,7 +554,7 @@ ReturnValue_t StrHelper::checkReplyPosition(uint32_t expectedPosition) { ReturnValue_t StrHelper::checkFlashActionReply(uint8_t region_, uint32_t address_, uint16_t length_) { ReturnValue_t result = RETURN_OK; - result = checkReply(); + result = checkActionReply(); if (result != RETURN_OK) { return result; } @@ -494,6 +568,7 @@ ReturnValue_t StrHelper::checkFlashActionReply(uint8_t region_, uint32_t address if (result != RETURN_OK) { sif::warning << "StrHelper::checkFlashActionReply: Deserialization of address failed" << std::endl; + return result; } uint16_t length; size = sizeof(length); @@ -516,6 +591,35 @@ ReturnValue_t StrHelper::checkFlashActionReply(uint8_t region_, uint32_t address return RETURN_OK; } +ReturnValue_t StrHelper::checkFpgaDownloadReply(uint32_t expectedPosition, + uint32_t expectedLength) { + ReturnValue_t result = RETURN_OK; + result = checkActionReply(); + if (result != RETURN_OK) { + return result; + } + const uint8_t* data = datalinkLayer.getReply() + FpgaDownload::POSITION_OFFSET; + uint32_t position; + size_t size = sizeof(position); + result = SerializeAdapter::deSerialize(&position, &data, &size, + SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StrHelper::checkFpgaDownloadReply: Deserialization of position failed" + << std::endl; + return result; + } + uint32_t length; + size = sizeof(length); + result = SerializeAdapter::deSerialize(&length, &data, &size, + SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StrHelper::checkFpgaDownloadReply: Deserialization of length failed" + << std::endl; + return result; + } + return RETURN_OK; +} + ReturnValue_t StrHelper::checkPath(std::string name) { if (name.substr(0, sizeof(SdCardManager::SD_0_MOUNT_POINT)) == std::string(SdCardManager::SD_0_MOUNT_POINT)) { diff --git a/bsp_q7s/devices/startracker/StrHelper.h b/bsp_q7s/devices/startracker/StrHelper.h index 372c2abd..55c7a69b 100644 --- a/bsp_q7s/devices/startracker/StrHelper.h +++ b/bsp_q7s/devices/startracker/StrHelper.h @@ -28,7 +28,7 @@ public: static const Event IMAGE_UPLOAD_FAILED = MAKE_EVENT(0, severity::LOW); //! [EXPORT] : [COMMENT] Image download failed static const Event IMAGE_DOWNLOAD_FAILED = MAKE_EVENT(1, severity::LOW); - //! [EXPORT] : [COMMENT] Uploading image to star tracker was successful + //! [EXPORT] : [COMMENT] Uploading image to star tracker was successfulop static const Event IMAGE_UPLOAD_SUCCESSFUL = MAKE_EVENT(2, severity::LOW); //! [EXPORT] : [COMMENT] Image download was successful static const Event IMAGE_DOWNLOAD_SUCCESSFUL = MAKE_EVENT(3, severity::LOW); @@ -40,35 +40,43 @@ public: static const Event FLASH_WRITE_FAILED = MAKE_EVENT(6, severity::LOW); //! [EXPORT] : [COMMENT] Flash read procedure failed static const Event FLASH_READ_FAILED = MAKE_EVENT(7, severity::LOW); + //! [EXPORT] : [COMMENT] Download of FPGA image successful + static const Event FPGA_DOWNLOAD_SUCCESSFUL = MAKE_EVENT(8, severity::LOW); + //! [EXPORT] : [COMMENT] Download of FPGA image failed + static const Event FPGA_DOWNLOAD_FAILED = MAKE_EVENT(9, severity::LOW); + //! [EXPORT] : [COMMENT] Upload of FPGA image successful + static const Event FPGA_UPLOAD_SUCCESSFUL = MAKE_EVENT(10, severity::LOW); + //! [EXPORT] : [COMMENT] Upload of FPGA image failed + static const Event FPGA_UPLOAD_FAILED = MAKE_EVENT(11, severity::LOW); //! [EXPORT] : [COMMENT] Failed to read communication interface reply data //!P1: Return code of failed communication interface read call //!P1: Upload/download position for which the read call failed - static const Event STR_HELPER_READING_REPLY_FAILED = MAKE_EVENT(8, severity::LOW); + static const Event STR_HELPER_READING_REPLY_FAILED = MAKE_EVENT(12, severity::LOW); //! [EXPORT] : [COMMENT] Unexpected stop of decoding sequence //!P1: Return code of failed communication interface read call //!P1: Upload/download position for which the read call failed - static const Event STR_HELPER_COM_ERROR = MAKE_EVENT(9, severity::LOW); + static const Event STR_HELPER_COM_ERROR = MAKE_EVENT(13, severity::LOW); //! [EXPORT] : [COMMENT] Star tracker did not send replies (maybe device is powered off) //!P1: Position of upload or download packet for which no reply was sent - static const Event STR_HELPER_NO_REPLY = MAKE_EVENT(10, severity::LOW); + static const Event STR_HELPER_NO_REPLY = MAKE_EVENT(14, severity::LOW); //! [EXPORT] : [COMMENT] Error during decoding of received reply occurred //P1: Return value of decoding function //P2: Position of upload/download packet, or address of flash write/read request - static const Event STR_HELPER_DEC_ERROR = MAKE_EVENT(11, severity::LOW); + static const Event STR_HELPER_DEC_ERROR = MAKE_EVENT(15, severity::LOW); //! [EXPORT] : [COMMENT] Position mismatch //! P1: The expected position and thus the position for which the image upload/download failed - static const Event POSITION_MISMATCH = MAKE_EVENT(12, severity::LOW); + static const Event POSITION_MISMATCH = MAKE_EVENT(16, severity::LOW); //! [EXPORT] : [COMMENT] Specified file does not exist //!P1: Internal state of str helper - static const Event STR_HELPER_FILE_NOT_EXISTS = MAKE_EVENT(13, severity::LOW); + static const Event STR_HELPER_FILE_NOT_EXISTS = MAKE_EVENT(17, severity::LOW); //! [EXPORT] : [COMMENT] Sending packet to star tracker failed //!P1: Return code of communication interface sendMessage function //!P2: Position of upload/download packet, or address of flash write/read request for which sending failed - static const Event STR_HELPER_SENDING_PACKET_FAILED = MAKE_EVENT(14, severity::LOW); + static const Event STR_HELPER_SENDING_PACKET_FAILED = MAKE_EVENT(18, severity::LOW); //! [EXPORT] : [COMMENT] Communication interface requesting reply failed //!P1: Return code of failed request //!P1: Upload/download position, or address of flash write/read request for which transmission failed - static const Event STR_HELPER_REQUESTING_MSG_FAILED = MAKE_EVENT(15, severity::LOW); + static const Event STR_HELPER_REQUESTING_MSG_FAILED = MAKE_EVENT(19, severity::LOW); StrHelper(object_id_t objectId); virtual ~StrHelper(); @@ -92,7 +100,7 @@ public: * * @param Name of the image which will be created */ - ReturnValue_t startImageDownload(std::string downloadPath_); + ReturnValue_t startImageDownload(std::string downloadImagePath_); /** * @brief Starts the flash write procedure @@ -115,6 +123,16 @@ public: ReturnValue_t startFlashRead(std::string flashReadPath_, uint8_t region, uint32_t address, uint32_t length); + /** + * @brief Starts the download of the FPGA image + * + * @param path The path where the file with the downloaded data will be created + * @param startPosition Offset in fpga image to read from + * @param length Number of bytes to dwonload from the FPGA image + * + */ + ReturnValue_t startFpgaDownload(std::string path, uint32_t startPosition, uint32_t length); + /** * @brief Can be used to interrupt a running data transfer. */ @@ -156,7 +174,28 @@ private: // Size of one image part which can be sent per action request static const size_t SIZE_IMAGE_PART = 1024; - static const uint32_t LAST_POSITION = 4095; + class ImageDownload { + public: + static const uint32_t LAST_POSITION = 4095; + }; + + class FpgaDownload { + public: + static const uint16_t MAX_DATA = 1024; + static const uint8_t POSITION_OFFSET = 3; + static const uint8_t LENGTH_OFFSET = 7; + static const uint8_t DATA_OFFSET = 11; + // Start position of fpga image part to download + uint32_t startPosition = 0; + // Length of image part to download + uint32_t length = 0; + // Path where downloaded FPGA image will be stored + std::string path; + // Name of file containing downloaded FPGA image + std::string fileName = "fpgaimage.bin"; + }; + + FpgaDownload fpgaDownload; static const uint32_t MAX_POLLS = 10000; @@ -175,7 +214,9 @@ private: UPLOAD_IMAGE, DOWNLOAD_IMAGE, FLASH_WRITE, - FLASH_READ + FLASH_READ, + DOWNLOAD_FPGA_IMAGE, + UPLOAD_FPGA_IMAGE }; InternalState internalState = InternalState::IDLE; @@ -187,7 +228,7 @@ private: // Name including absolute path of image to upload std::string uploadImage; // Path where the downloaded image will be stored - std::string downloadPath; + std::string downloadImagePath; // File which contains data to write when executing the flash write command std::string flashWriteFile; // Path where the file containing the read data will be stored @@ -255,6 +296,12 @@ private: */ ReturnValue_t performFlashRead(); + /** + * @brief Performs the download of the FPGA image which requires to be slip over multiple + * action requests. + */ + ReturnValue_t performFpgaDownload(); + /** * @brief Sends packet to the star tracker and reads reply by using the communication * interface @@ -267,11 +314,11 @@ private: ReturnValue_t sendAndRead(size_t size, uint32_t parameter); /** - * @brief Checks the reply header (type id and status fields) + * @brief Checks the header (type id and status fields) of the action reply * * @return RETURN_OK if reply confirms success of packet transfer, otherwise REUTRN_FAILED */ - ReturnValue_t checkReply(); + ReturnValue_t checkActionReply(); /** * @brief Checks the position field in a star tracker upload/download reply. @@ -290,6 +337,14 @@ private: */ ReturnValue_t checkFlashActionReply(uint8_t region_, uint32_t address_, uint16_t length_); + /** + * @brief Checks the reply to the fpga download request + * + * @param expectedPosition The expected position value in the reply + * @param expectedLength The expected length field in the reply + */ + ReturnValue_t checkFpgaDownloadReply(uint32_t expectedPosition, uint32_t expectedLength); + /** * @brief Checks if a path points to an sd card and whether the SD card is monuted. * diff --git a/common/config/commonClassIds.h b/common/config/commonClassIds.h index 4c769260..cd90272d 100644 --- a/common/config/commonClassIds.h +++ b/common/config/commonClassIds.h @@ -25,6 +25,7 @@ enum commonClassIds: uint8_t { PDEC_HANDLER, //PDEC CCSDS_HANDLER, //CCSDS ARCSEC_JSON_BASE, //JSONBASE + NVM_PARAM_BASE, //NVMB COMMON_CLASS_ID_END // [EXPORT] : [END] }; diff --git a/generators/bsp_q7s_events.csv b/generators/bsp_q7s_events.csv index a2a4784a..cdf4d181 100644 --- a/generators/bsp_q7s_events.csv +++ b/generators/bsp_q7s_events.csv @@ -120,19 +120,21 @@ 11904;BIT_LOCK_PDEC;INFO;Bit lock detected (data valid);C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/obc/PdecHandler.h 12000;IMAGE_UPLOAD_FAILED;LOW;Image upload failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h 12001;IMAGE_DOWNLOAD_FAILED;LOW;Image download failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h -12002;IMAGE_UPLOAD_SUCCESSFUL;LOW;Uploading image to star tracker was successful;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12002;IMAGE_UPLOAD_SUCCESSFUL;LOW;Uploading image to star tracker was successfulop;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h 12003;IMAGE_DOWNLOAD_SUCCESSFUL;LOW;Image download was successful;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h 12004;FLASH_WRITE_SUCCESSFUL;LOW;Finished flash write procedure successfully;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h 12005;FLASH_READ_SUCCESSFUL;LOW;Finished flash read procedure successfully;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h 12006;FLASH_WRITE_FAILED;LOW;Flash write procedure failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h 12007;FLASH_READ_FAILED;LOW;Flash read procedure failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h -12008;STR_HELPER_READING_REPLY_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h -12009;STR_HELPER_COM_ERROR;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h -12010;STR_HELPER_NO_REPLY;LOW;Star tracker did not send replies (maybe device is powered off)P1: Position of upload or download packet for which no reply was sent;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h -12011;INVALID_TYPE_ID;LOW;Received reply with invalid type ID;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h -12012;STATUS_ERROR;LOW;Status field in reply signals error;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h -12013;STR_HELPER_DEC_ERROR;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h -12014;POSITION_MISMATCH;LOW;Position mismatch P1: The expected position and thus the position for which the image upload/download failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h -12015;STR_HELPER_FILE_NOT_EXISTS;LOW;Specified file does not existP1: Internal state of str helper;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h -12016;STR_HELPER_SENDING_PACKET_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h -12017;STR_HELPER_REQUESTING_MSG_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12008;FPGA_DOWNLOAD_SUCCESSFUL;LOW;Download of FPGA image successful;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12009;FPGA_DOWNLOAD_FAILED;LOW;Download of FPGA image failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12010;FPGA_UPLOAD_SUCCESSFUL;LOW;Upload of FPGA image successful;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12011;FPGA_UPLOAD_FAILED;LOW;Upload of FPGA image failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12012;STR_HELPER_READING_REPLY_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12013;STR_HELPER_COM_ERROR;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12014;STR_HELPER_NO_REPLY;LOW;Star tracker did not send replies (maybe device is powered off)P1: Position of upload or download packet for which no reply was sent;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12015;STR_HELPER_DEC_ERROR;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12016;POSITION_MISMATCH;LOW;Position mismatch P1: The expected position and thus the position for which the image upload/download failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12017;STR_HELPER_FILE_NOT_EXISTS;LOW;Specified file does not existP1: Internal state of str helper;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12018;STR_HELPER_SENDING_PACKET_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12019;STR_HELPER_REQUESTING_MSG_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp index 76159e0c..17150762 100644 --- a/generators/events/translateEvents.cpp +++ b/generators/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 138 translations. + * @brief Auto-generated event translation file. Contains 140 translations. * @details - * Generated on: 2021-12-21 17:08:50 + * Generated on: 2021-12-29 20:24:08 */ #include "translateEvents.h" @@ -133,11 +133,13 @@ const char *FLASH_WRITE_SUCCESSFUL_STRING = "FLASH_WRITE_SUCCESSFUL"; const char *FLASH_READ_SUCCESSFUL_STRING = "FLASH_READ_SUCCESSFUL"; const char *FLASH_WRITE_FAILED_STRING = "FLASH_WRITE_FAILED"; const char *FLASH_READ_FAILED_STRING = "FLASH_READ_FAILED"; +const char *FPGA_DOWNLOAD_SUCCESSFUL_STRING = "FPGA_DOWNLOAD_SUCCESSFUL"; +const char *FPGA_DOWNLOAD_FAILED_STRING = "FPGA_DOWNLOAD_FAILED"; +const char *FPGA_UPLOAD_SUCCESSFUL_STRING = "FPGA_UPLOAD_SUCCESSFUL"; +const char *FPGA_UPLOAD_FAILED_STRING = "FPGA_UPLOAD_FAILED"; const char *STR_HELPER_READING_REPLY_FAILED_STRING = "STR_HELPER_READING_REPLY_FAILED"; const char *STR_HELPER_COM_ERROR_STRING = "STR_HELPER_COM_ERROR"; const char *STR_HELPER_NO_REPLY_STRING = "STR_HELPER_NO_REPLY"; -const char *INVALID_TYPE_ID_STRING = "INVALID_TYPE_ID"; -const char *STATUS_ERROR_STRING = "STATUS_ERROR"; const char *STR_HELPER_DEC_ERROR_STRING = "STR_HELPER_DEC_ERROR"; const char *POSITION_MISMATCH_STRING = "POSITION_MISMATCH"; const char *STR_HELPER_FILE_NOT_EXISTS_STRING = "STR_HELPER_FILE_NOT_EXISTS"; @@ -403,24 +405,28 @@ const char * translateEvents(Event event) { case(12007): return FLASH_READ_FAILED_STRING; case(12008): - return STR_HELPER_READING_REPLY_FAILED_STRING; + return FPGA_DOWNLOAD_SUCCESSFUL_STRING; case(12009): - return STR_HELPER_COM_ERROR_STRING; + return FPGA_DOWNLOAD_FAILED_STRING; case(12010): - return STR_HELPER_NO_REPLY_STRING; + return FPGA_UPLOAD_SUCCESSFUL_STRING; case(12011): - return INVALID_TYPE_ID_STRING; + return FPGA_UPLOAD_FAILED_STRING; case(12012): - return STATUS_ERROR_STRING; + return STR_HELPER_READING_REPLY_FAILED_STRING; case(12013): - return STR_HELPER_DEC_ERROR_STRING; + return STR_HELPER_COM_ERROR_STRING; case(12014): - return POSITION_MISMATCH_STRING; + return STR_HELPER_NO_REPLY_STRING; case(12015): - return STR_HELPER_FILE_NOT_EXISTS_STRING; + return STR_HELPER_DEC_ERROR_STRING; case(12016): - return STR_HELPER_SENDING_PACKET_FAILED_STRING; + return POSITION_MISMATCH_STRING; case(12017): + return STR_HELPER_FILE_NOT_EXISTS_STRING; + case(12018): + return STR_HELPER_SENDING_PACKET_FAILED_STRING; + case(12019): return STR_HELPER_REQUESTING_MSG_FAILED_STRING; default: return "UNKNOWN_EVENT"; diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index 76159e0c..17150762 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 138 translations. + * @brief Auto-generated event translation file. Contains 140 translations. * @details - * Generated on: 2021-12-21 17:08:50 + * Generated on: 2021-12-29 20:24:08 */ #include "translateEvents.h" @@ -133,11 +133,13 @@ const char *FLASH_WRITE_SUCCESSFUL_STRING = "FLASH_WRITE_SUCCESSFUL"; const char *FLASH_READ_SUCCESSFUL_STRING = "FLASH_READ_SUCCESSFUL"; const char *FLASH_WRITE_FAILED_STRING = "FLASH_WRITE_FAILED"; const char *FLASH_READ_FAILED_STRING = "FLASH_READ_FAILED"; +const char *FPGA_DOWNLOAD_SUCCESSFUL_STRING = "FPGA_DOWNLOAD_SUCCESSFUL"; +const char *FPGA_DOWNLOAD_FAILED_STRING = "FPGA_DOWNLOAD_FAILED"; +const char *FPGA_UPLOAD_SUCCESSFUL_STRING = "FPGA_UPLOAD_SUCCESSFUL"; +const char *FPGA_UPLOAD_FAILED_STRING = "FPGA_UPLOAD_FAILED"; const char *STR_HELPER_READING_REPLY_FAILED_STRING = "STR_HELPER_READING_REPLY_FAILED"; const char *STR_HELPER_COM_ERROR_STRING = "STR_HELPER_COM_ERROR"; const char *STR_HELPER_NO_REPLY_STRING = "STR_HELPER_NO_REPLY"; -const char *INVALID_TYPE_ID_STRING = "INVALID_TYPE_ID"; -const char *STATUS_ERROR_STRING = "STATUS_ERROR"; const char *STR_HELPER_DEC_ERROR_STRING = "STR_HELPER_DEC_ERROR"; const char *POSITION_MISMATCH_STRING = "POSITION_MISMATCH"; const char *STR_HELPER_FILE_NOT_EXISTS_STRING = "STR_HELPER_FILE_NOT_EXISTS"; @@ -403,24 +405,28 @@ const char * translateEvents(Event event) { case(12007): return FLASH_READ_FAILED_STRING; case(12008): - return STR_HELPER_READING_REPLY_FAILED_STRING; + return FPGA_DOWNLOAD_SUCCESSFUL_STRING; case(12009): - return STR_HELPER_COM_ERROR_STRING; + return FPGA_DOWNLOAD_FAILED_STRING; case(12010): - return STR_HELPER_NO_REPLY_STRING; + return FPGA_UPLOAD_SUCCESSFUL_STRING; case(12011): - return INVALID_TYPE_ID_STRING; + return FPGA_UPLOAD_FAILED_STRING; case(12012): - return STATUS_ERROR_STRING; + return STR_HELPER_READING_REPLY_FAILED_STRING; case(12013): - return STR_HELPER_DEC_ERROR_STRING; + return STR_HELPER_COM_ERROR_STRING; case(12014): - return POSITION_MISMATCH_STRING; + return STR_HELPER_NO_REPLY_STRING; case(12015): - return STR_HELPER_FILE_NOT_EXISTS_STRING; + return STR_HELPER_DEC_ERROR_STRING; case(12016): - return STR_HELPER_SENDING_PACKET_FAILED_STRING; + return POSITION_MISMATCH_STRING; case(12017): + return STR_HELPER_FILE_NOT_EXISTS_STRING; + case(12018): + return STR_HELPER_SENDING_PACKET_FAILED_STRING; + case(12019): return STR_HELPER_REQUESTING_MSG_FAILED_STRING; default: return "UNKNOWN_EVENT"; diff --git a/mission/memory/NVMParameterBase.h b/mission/memory/NVMParameterBase.h index 4814acf4..f41f9e63 100644 --- a/mission/memory/NVMParameterBase.h +++ b/mission/memory/NVMParameterBase.h @@ -7,7 +7,7 @@ #include #include -class NVMParameterBase { +class NVMParameterBase : public HasReturnvaluesIF { public: virtual~ NVMParameterBase() {} @@ -34,12 +34,18 @@ public: ReturnValue_t setValue(std::string key, T value); template - T getValue(std::string key) const; + ReturnValue_t getValue(std::string key, T* value) const; void printKeys() const; void print() const; private: + + static const uint8_t INTERFACE_ID = CLASS_ID::NVM_PARAM_BASE; + + //! [EXPORT] : [COMMENT] Specified key does not exist in json file + static const ReturnValue_t KEY_NOT_EXISTS = MAKE_RETURN_CODE(0xA0); + nlohmann::json json; std::vector keys; std::string fullName; @@ -62,8 +68,12 @@ inline ReturnValue_t NVMParameterBase::setValue(std::string key, T value) { } template -inline T NVMParameterBase::getValue(std::string key) const { - return json[key]; +inline ReturnValue_t NVMParameterBase::getValue(std::string key, T* value) const { + if (!json.contains(key)) { + return KEY_NOT_EXISTS; + } + *value = json[key]; + return RETURN_OK; } #endif /* BSP_Q7S_CORE_NVMPARAMS_NVMPARAMIF_H_ */ From 3833b7a8757428cdb6d9b73f96a26d4aed1f1554 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Wed, 29 Dec 2021 20:34:12 +0100 Subject: [PATCH 175/465] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 58ec3c66..e3950bbb 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 58ec3c66409be1e8b9c403f73062f0e187fba021 +Subproject commit e3950bbbcca825b07c40b16658127210a9fe5fe2 From 29e7ac210af73daef3b252048dc557b444f33760 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 30 Dec 2021 12:52:08 +0100 Subject: [PATCH 176/465] upload fpga image command --- .../startracker/StarTrackerDefinitions.h | 4 + .../startracker/StarTrackerHandler.cpp | 55 ++++++++++++- .../devices/startracker/StarTrackerHandler.h | 13 ++++ bsp_q7s/devices/startracker/StrHelper.cpp | 78 +++++++++++++++++-- bsp_q7s/devices/startracker/StrHelper.h | 36 +++++++-- 5 files changed, 172 insertions(+), 14 deletions(-) diff --git a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h index c03afa74..29a1d800 100644 --- a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h +++ b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h @@ -242,6 +242,9 @@ static const DeviceCommandId_t SET_TIME = 60; static const DeviceCommandId_t DOWNLOAD_DBIMAGE = 61; static const DeviceCommandId_t DOWNLOAD_BLOBPIXEL = 62; static const DeviceCommandId_t DOWNLOAD_FPGA_IMAGE = 63; +static const DeviceCommandId_t CHANGE_FPGA_DOWNLOAD_FILE = 64; +static const DeviceCommandId_t UPLOAD_FPGA_IMAGE = 65; +static const DeviceCommandId_t FPGA_ACTION = 66; static const DeviceCommandId_t NONE = 0xFFFFFFFF; static const uint32_t VERSION_SET_ID = REQ_VERSION; @@ -313,6 +316,7 @@ namespace ID { static const uint8_t DOWNLOAD_MATCHED_STAR = 18; static const uint8_t DOWNLOAD_DBIMAGE = 19; static const uint8_t DOWNLOAD_BLOBPIXEL = 24; + static const uint8_t FPGA_ACTION = 22; } namespace Program { diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp index 57aa5dfc..9a504ffd 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp @@ -107,7 +107,7 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu if (result != RETURN_OK) { return result; } - if (size > MAX_PATH_SIZE) { + if (size > MAX_PATH_SIZE + MAX_FILE_NAME) { return FILE_PATH_TOO_LONG; } result = strHelper->startImageUpload( @@ -167,6 +167,13 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu std::string(reinterpret_cast(data), size)); return EXECUTION_FINISHED; } + case(StarTracker::CHANGE_FPGA_DOWNLOAD_FILE): { + if (size > MAX_FILE_NAME) { + return FILENAME_TOO_LONG; + } + strHelper->setDownloadFpgaImage(std::string(reinterpret_cast(data), size)); + return EXECUTION_FINISHED; + } case(StarTracker::SET_READ_FILENAME): { if (size > MAX_FILE_NAME) { return FILENAME_TOO_LONG; @@ -190,6 +197,21 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu strHelperExecuting = true; return EXECUTION_FINISHED; } + case(StarTracker::UPLOAD_FPGA_IMAGE): { + result = DeviceHandlerBase::acceptExternalDeviceCommands(); + if (result != RETURN_OK) { + return result; + } + if (size > MAX_PATH_SIZE + MAX_FILE_NAME) { + return FILE_PATH_TOO_LONG; + } + result = strHelper->startFpgaUpload(std::string(reinterpret_cast(data), size)); + if (result != RETURN_OK) { + return result; + } + strHelperExecuting = true; + return EXECUTION_FINISHED; + } default: break; } @@ -469,6 +491,10 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi result = prepareDownloadBlobPixelCommand(commandData, commandDataLen); return result; } + case (StarTracker::FPGA_ACTION): { + result = prepareFpgaActionCommand(commandData, commandDataLen); + return result; + } default: return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } @@ -545,6 +571,8 @@ void StarTrackerHandler::fillCommandAndReplyMap() { StarTracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_BLOBPIXEL, 3, &downloadBlobPixel, StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::FPGA_ACTION, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); } ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t remainingSize, @@ -617,7 +645,8 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con case (StarTracker::TAKE_IMAGE): case (StarTracker::RESET_ERROR): case (StarTracker::UNLOCK): - case (StarTracker::SET_TIME): { + case (StarTracker::SET_TIME): + case (StarTracker::FPGA_ACTION): { result = handleActionReply(); break; } @@ -995,6 +1024,10 @@ ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t *foundId) *foundId = StarTracker::DOWNLOAD_BLOBPIXEL; break; } + case (StarTracker::ID::FPGA_ACTION): { + *foundId = StarTracker::FPGA_ACTION; + break; + } default: sif::warning << "StarTrackerHandler::scanForParameterReply: Unknown parameter reply id" << std::endl; @@ -1649,6 +1682,24 @@ ReturnValue_t StarTrackerHandler::prepareDownloadBlobPixelCommand(const uint8_t* return RETURN_OK; } +ReturnValue_t StarTrackerHandler::prepareFpgaActionCommand(const uint8_t* commandData, + size_t commandDataLen) { + if (commandDataLen != FpgaActionCmd::LENGTH) { + return INVALID_LENGTH; + } + struct FPGAActionActionRequest req; + req.id = *commandData; + if (req.id != FpgaActionCmd::ID) { + return INVALID_ID; + } + uint32_t length = 0; + arc_pack_fpgaaction_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; +} + ReturnValue_t StarTrackerHandler::handleSetParamReply() { const uint8_t* reply = dataLinkLayer.getReply(); uint8_t status = *(reply + STATUS_OFFSET); diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.h b/bsp_q7s/devices/startracker/StarTrackerHandler.h index d26c8aea..65bd65b8 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.h +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.h @@ -131,6 +131,8 @@ private: static const ReturnValue_t UPLOAD_CENTROID_ID_MISMATCH = MAKE_RETURN_CODE(0xB5); //! [EXPORT] : [COMMENT] Download blob pixel command has invalid type field static const ReturnValue_t INVALID_TYPE = MAKE_RETURN_CODE(0xB6); + //! [EXPORT] : [COMMENT] Received FPGA action command with invalid ID + static const ReturnValue_t INVALID_ID = MAKE_RETURN_CODE(0xB7); static const size_t MAX_PATH_SIZE = 50; static const size_t MAX_FILE_NAME = 30; @@ -235,6 +237,12 @@ private: static const uint8_t MIN_LENGTH = 10; }; + class FpgaActionCmd { + public: + static const uint8_t LENGTH = 1; + static const uint8_t ID = 3; + }; + MessageQueueIF* eventQueue = nullptr; ArcsecDatalinkLayer dataLinkLayer; @@ -479,6 +487,11 @@ private: ReturnValue_t prepareDownloadBlobPixelCommand(const uint8_t* commandData, size_t commandDataLen); + /** + * @brief With this command the FPGA update will be applied to the star tracker + */ + ReturnValue_t prepareFpgaActionCommand(const uint8_t* commandData, size_t commandDataLen); + /** * @brief Handles action replies with datasets. */ diff --git a/bsp_q7s/devices/startracker/StrHelper.cpp b/bsp_q7s/devices/startracker/StrHelper.cpp index 9ee2ce0e..9da726c2 100644 --- a/bsp_q7s/devices/startracker/StrHelper.cpp +++ b/bsp_q7s/devices/startracker/StrHelper.cpp @@ -85,6 +85,17 @@ ReturnValue_t StrHelper::performOperation(uint8_t operationCode) { internalState = InternalState::IDLE; break; } + case InternalState::UPLOAD_FPGA_IMAGE: { + result = performFpgaUpload(); + if (result == RETURN_OK){ + triggerEvent(FPGA_UPLOAD_SUCCESSFUL); + } + else { + triggerEvent(FPGA_UPLOAD_FAILED); + } + internalState = InternalState::IDLE; + break; + } default: sif::debug << "StrHelper::performOperation: Invalid state" << std::endl; break; @@ -114,7 +125,7 @@ ReturnValue_t StrHelper::startImageUpload(std::string uploadImage_) { if(not std::filesystem::exists(uploadImage)) { return FILE_NOT_EXISTS; } - internalState = InternalState::UPLOAD_IMAGE; + internalState = InternalState::UPLOAD_FPGA_IMAGE; semaphore.release(); terminate = false; return RETURN_OK; @@ -147,6 +158,10 @@ void StrHelper::setFlashReadFilename(std::string filename) { flashReadFile = filename; } +void StrHelper::setDownloadFpgaImage(std::string filename) { + fpgaDownload.fileName = filename; +} + ReturnValue_t StrHelper::startFlashWrite(std::string flashWriteFile_, uint8_t region, uint32_t address) { ReturnValue_t result = checkPath(flashWriteFile_); @@ -195,6 +210,14 @@ ReturnValue_t StrHelper::startFpgaDownload(std::string path, uint32_t startPosit return RETURN_OK; } +ReturnValue_t StrHelper::startFpgaUpload(std::string uploadFile) { + fpgaUpload.uploadFile = uploadFile; + internalState = InternalState::UPLOAD_FPGA_IMAGE; + semaphore.release(); + terminate = false; + return RETURN_OK; +} + ReturnValue_t StrHelper::performImageDownload() { ReturnValue_t result; struct DownloadActionRequest downloadReq; @@ -450,7 +473,7 @@ ReturnValue_t StrHelper::performFpgaDownload() { file.close(); return result; } - result = checkFpgaDownloadReply(req.pos, req.length); + result = checkFpgaActionReply(req.pos, req.length); if (result != RETURN_OK) { if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { uartComIF->flushUartRxBuffer(comCookie); @@ -469,6 +492,47 @@ ReturnValue_t StrHelper::performFpgaDownload() { return RETURN_OK; } +ReturnValue_t StrHelper::performFpgaUpload() { + ReturnValue_t result = RETURN_OK; + uint32_t commandSize = 0; + uint32_t bytesUploaded = 0; + uint32_t fileSize = 0; + struct UploadFPGAImageActionRequest req; + if (not std::filesystem::exists(fpgaUpload.uploadFile)) { + triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast(internalState)); + internalState = InternalState::IDLE; + return RETURN_FAILED; + } + std::ifstream file(flashWriteFile, std::ifstream::binary); + file.seekg(0, file.end); + fileSize = file.tellg(); + req.pos = 0; + while(bytesUploaded <= fileSize) { + if (terminate) { + return RETURN_OK; + } + if (fileSize - bytesUploaded > FpgaUpload::MAX_DATA) { + req.length = FpgaUpload::MAX_DATA; + } + else { + req.length = fileSize - bytesUploaded; + } + file.seekg(bytesUploaded, file.beg); + file.read(reinterpret_cast(req.data), req.length); + arc_pack_uploadfpgaimage_action_req(&req, commandBuffer, &commandSize); + result = sendAndRead(commandSize, req.pos); + if (result != RETURN_OK) { + return RETURN_FAILED; + } + result = checkFpgaActionReply(req.pos, req.length); + if (result != RETURN_OK) { + return result; + } + bytesUploaded += req.length; + } + return RETURN_OK; +} + ReturnValue_t StrHelper::sendAndRead(size_t size, uint32_t parameter) { ReturnValue_t result = RETURN_OK; ReturnValue_t decResult = RETURN_OK; @@ -591,20 +655,20 @@ ReturnValue_t StrHelper::checkFlashActionReply(uint8_t region_, uint32_t address return RETURN_OK; } -ReturnValue_t StrHelper::checkFpgaDownloadReply(uint32_t expectedPosition, +ReturnValue_t StrHelper::checkFpgaActionReply(uint32_t expectedPosition, uint32_t expectedLength) { ReturnValue_t result = RETURN_OK; result = checkActionReply(); if (result != RETURN_OK) { return result; } - const uint8_t* data = datalinkLayer.getReply() + FpgaDownload::POSITION_OFFSET; + const uint8_t* data = datalinkLayer.getReply() + ACTION_DATA_OFFSET; uint32_t position; size_t size = sizeof(position); result = SerializeAdapter::deSerialize(&position, &data, &size, SerializeIF::Endianness::LITTLE); if (result != RETURN_OK) { - sif::warning << "StrHelper::checkFpgaDownloadReply: Deserialization of position failed" + sif::warning << "StrHelper::checkFpgaActionReply: Deserialization of position failed" << std::endl; return result; } @@ -613,11 +677,11 @@ ReturnValue_t StrHelper::checkFpgaDownloadReply(uint32_t expectedPosition, result = SerializeAdapter::deSerialize(&length, &data, &size, SerializeIF::Endianness::LITTLE); if (result != RETURN_OK) { - sif::warning << "StrHelper::checkFpgaDownloadReply: Deserialization of length failed" + sif::warning << "StrHelper::checkFpgaActionReply: Deserialization of length failed" << std::endl; return result; } - return RETURN_OK; + return result; } ReturnValue_t StrHelper::checkPath(std::string name) { diff --git a/bsp_q7s/devices/startracker/StrHelper.h b/bsp_q7s/devices/startracker/StrHelper.h index 55c7a69b..257b5ae7 100644 --- a/bsp_q7s/devices/startracker/StrHelper.h +++ b/bsp_q7s/devices/startracker/StrHelper.h @@ -133,6 +133,13 @@ public: */ ReturnValue_t startFpgaDownload(std::string path, uint32_t startPosition, uint32_t length); + /** + * @brief Starts upload of new image to FPGA + * + * @param uploadFile Full name of file containing FPGA image data + */ + ReturnValue_t startFpgaUpload(std::string uploadFile); + /** * @brief Can be used to interrupt a running data transfer. */ @@ -148,6 +155,11 @@ public: */ void setFlashReadFilename(std::string filename); + /** + * @brief Set download FPGA image name + */ + void setDownloadFpgaImage(std::string filename); + private: static const uint8_t INTERFACE_ID = CLASS_ID::STR_HELPER; @@ -182,9 +194,7 @@ private: class FpgaDownload { public: static const uint16_t MAX_DATA = 1024; - static const uint8_t POSITION_OFFSET = 3; - static const uint8_t LENGTH_OFFSET = 7; - static const uint8_t DATA_OFFSET = 11; + static const uint8_t DATA_OFFSET = 10; // Start position of fpga image part to download uint32_t startPosition = 0; // Length of image part to download @@ -197,8 +207,18 @@ private: FpgaDownload fpgaDownload; + class FpgaUpload { + public: + static const uint32_t MAX_DATA = 1024; + // Full name of file to upload + std::string uploadFile; + }; + + FpgaUpload fpgaUpload; + static const uint32_t MAX_POLLS = 10000; + static const uint8_t ACTION_DATA_OFFSET = 2; static const uint8_t POS_OFFSET = 2; static const uint8_t IMAGE_DATA_OFFSET = 5; static const uint8_t FLASH_READ_DATA_OFFSET = 8; @@ -302,6 +322,12 @@ private: */ ReturnValue_t performFpgaDownload(); + /** + * @brief Performs upload of new FPGA image. Upload sequence split over multiple commands + * because one command can only transport 1024 bytes of image data. + */ + ReturnValue_t performFpgaUpload(); + /** * @brief Sends packet to the star tracker and reads reply by using the communication * interface @@ -338,12 +364,12 @@ private: ReturnValue_t checkFlashActionReply(uint8_t region_, uint32_t address_, uint16_t length_); /** - * @brief Checks the reply to the fpga download request + * @brief Checks the reply to the fpga download and upload request * * @param expectedPosition The expected position value in the reply * @param expectedLength The expected length field in the reply */ - ReturnValue_t checkFpgaDownloadReply(uint32_t expectedPosition, uint32_t expectedLength); + ReturnValue_t checkFpgaActionReply(uint32_t expectedPosition, uint32_t expectedLength); /** * @brief Checks if a path points to an sd card and whether the SD card is monuted. From ac51ad7a4f53a642a1f1140eb7190e9e5d53dcaf Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 30 Dec 2021 13:31:34 +0100 Subject: [PATCH 177/465] some improvements --- bsp_q7s/devices/startracker/StrHelper.cpp | 76 +++++++++---------- bsp_q7s/devices/startracker/StrHelper.h | 91 +++++++++++++---------- tmtc | 2 +- 3 files changed, 92 insertions(+), 77 deletions(-) diff --git a/bsp_q7s/devices/startracker/StrHelper.cpp b/bsp_q7s/devices/startracker/StrHelper.cpp index 9da726c2..0be38ad7 100644 --- a/bsp_q7s/devices/startracker/StrHelper.cpp +++ b/bsp_q7s/devices/startracker/StrHelper.cpp @@ -116,13 +116,13 @@ void StrHelper::setComCookie(CookieIF* comCookie_) { comCookie = comCookie_; } -ReturnValue_t StrHelper::startImageUpload(std::string uploadImage_) { - ReturnValue_t result = checkPath(uploadImage_); +ReturnValue_t StrHelper::startImageUpload(std::string fullname) { + ReturnValue_t result = checkPath(fullname); if (result != RETURN_OK) { return result; } - uploadImage = uploadImage_; - if(not std::filesystem::exists(uploadImage)) { + uploadImage.uploadFile = fullname; + if(not std::filesystem::exists(fullname)) { return FILE_NOT_EXISTS; } internalState = InternalState::UPLOAD_FPGA_IMAGE; @@ -131,15 +131,15 @@ ReturnValue_t StrHelper::startImageUpload(std::string uploadImage_) { return RETURN_OK; } -ReturnValue_t StrHelper::startImageDownload(std::string downloadImagePath_) { - ReturnValue_t result = checkPath(downloadImagePath_); +ReturnValue_t StrHelper::startImageDownload(std::string path) { + ReturnValue_t result = checkPath(path); if (result != RETURN_OK) { return result; } - if(not std::filesystem::exists(downloadImagePath_)) { + if(not std::filesystem::exists(path)) { return PATH_NOT_EXISTS; } - downloadImagePath = downloadImagePath_; + downloadImage.path = path; internalState = InternalState::DOWNLOAD_IMAGE; terminate = false; semaphore.release(); @@ -150,49 +150,49 @@ void StrHelper::stopProcess() { terminate = true; } -void StrHelper::setDownloadImageName(std::string image) { - downloadImage = image; +void StrHelper::setDownloadImageName(std::string filename) { + downloadImage.filename = filename; } void StrHelper::setFlashReadFilename(std::string filename) { - flashReadFile = filename; + flashRead.filename = filename; } void StrHelper::setDownloadFpgaImage(std::string filename) { fpgaDownload.fileName = filename; } -ReturnValue_t StrHelper::startFlashWrite(std::string flashWriteFile_, uint8_t region, +ReturnValue_t StrHelper::startFlashWrite(std::string fullname, uint8_t region, uint32_t address) { - ReturnValue_t result = checkPath(flashWriteFile_); + ReturnValue_t result = checkPath(fullname); if (result != RETURN_OK) { return result; } - flashWriteFile = flashWriteFile_; - if(not std::filesystem::exists(flashWriteFile)) { + flashWrite.fullname = fullname; + if(not std::filesystem::exists(flashWrite.fullname)) { return FILE_NOT_EXISTS; } - flashWriteAddress = address; - flashWriteRegion = region; + flashWrite.address = address; + flashWrite.region = region; internalState = InternalState::FLASH_WRITE; semaphore.release(); terminate = false; return RETURN_OK; } -ReturnValue_t StrHelper::startFlashRead(std::string flashReadPath_, uint8_t region, +ReturnValue_t StrHelper::startFlashRead(std::string path, uint8_t region, uint32_t address, uint32_t length) { - ReturnValue_t result = checkPath(flashReadPath_); + ReturnValue_t result = checkPath(path); if (result != RETURN_OK) { return result; } - flashReadPath = flashReadPath_; - if(not std::filesystem::exists(flashReadPath)) { + flashRead.path = path; + if(not std::filesystem::exists(flashRead.path)) { return FILE_NOT_EXISTS; } - flashReadAddress = address; - flashReadRegion = region; - flashReadSize = length; + flashRead.address = address; + flashRead.region = region; + flashRead.size = length; internalState = InternalState::FLASH_READ; semaphore.release(); terminate = false; @@ -224,7 +224,7 @@ ReturnValue_t StrHelper::performImageDownload() { uint32_t size = 0; uint32_t retries = 0; Timestamp timestamp; - std::string image = downloadImagePath + "/" + timestamp.str() + downloadImage ; + std::string image = downloadImage.path + "/" + timestamp.str() + downloadImage.filename ; std::ofstream file(image, std::ios_base::app | std::ios_base::out); if(not std::filesystem::exists(image)) { return FILE_CREATION_FAILED; @@ -281,12 +281,12 @@ ReturnValue_t StrHelper::performImageUpload() { struct UploadActionRequest uploadReq; uploadReq.position = 0; std::memset(&uploadReq.data, 0, sizeof(uploadReq.data)); - if (not std::filesystem::exists(uploadImage)) { + if (not std::filesystem::exists(uploadImage.uploadFile)) { triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast(internalState)); internalState = InternalState::IDLE; return RETURN_FAILED; } - std::ifstream file(uploadImage, std::ifstream::binary); + std::ifstream file(uploadImage.uploadFile, std::ifstream::binary); // Set position of next character to end of file input stream file.seekg(0, file.end); // tellg returns position of character in input stream @@ -332,17 +332,17 @@ ReturnValue_t StrHelper::performFlashWrite() { uint32_t remainingBytes = 0; uint32_t fileSize = 0; struct WriteActionRequest req; - if (not std::filesystem::exists(flashWriteFile)) { + if (not std::filesystem::exists(flashWrite.fullname)) { triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast(internalState)); internalState = InternalState::IDLE; return RETURN_FAILED; } - std::ifstream file(flashWriteFile, std::ifstream::binary); + std::ifstream file(flashWrite.fullname, std::ifstream::binary); file.seekg(0, file.end); fileSize = file.tellg(); remainingBytes = fileSize; - req.region = flashWriteRegion; - req.address = flashWriteAddress; + req.region = flashWrite.region; + req.address = flashWrite.address; req.length = MAX_FLASH_DATA; while(remainingBytes >= MAX_FLASH_DATA) { if (terminate) { @@ -383,23 +383,23 @@ ReturnValue_t StrHelper::performFlashRead() { uint32_t size = 0; uint32_t retries = 0; Timestamp timestamp; - std::string fullname = flashReadPath + "/" + timestamp.str() + flashReadFile ; + std::string fullname = flashRead.path + "/" + timestamp.str() + flashRead.filename ; std::ofstream file(fullname, std::ios_base::app | std::ios_base::out); if (not std::filesystem::exists(fullname)) { return FILE_CREATION_FAILED; } - req.region = flashReadRegion; - while(bytesRead < flashReadSize) { + req.region = flashRead.region; + while(bytesRead < flashRead.size) { if (terminate) { return RETURN_OK; } - if ((flashReadSize - bytesRead) < MAX_FLASH_DATA) { - req.length = flashReadSize - bytesRead; + if ((flashRead.size - bytesRead) < MAX_FLASH_DATA) { + req.length = flashRead.size - bytesRead; } else { req.length = MAX_FLASH_DATA; } - req.address = flashReadAddress + bytesRead; + req.address = flashRead.address + bytesRead; arc_pack_read_action_req(&req, commandBuffer, &size); result = sendAndRead(size, req.address); if (result != RETURN_OK) { @@ -503,7 +503,7 @@ ReturnValue_t StrHelper::performFpgaUpload() { internalState = InternalState::IDLE; return RETURN_FAILED; } - std::ifstream file(flashWriteFile, std::ifstream::binary); + std::ifstream file(flashWrite.fullname, std::ifstream::binary); file.seekg(0, file.end); fileSize = file.tellg(); req.pos = 0; diff --git a/bsp_q7s/devices/startracker/StrHelper.h b/bsp_q7s/devices/startracker/StrHelper.h index 257b5ae7..e140a4d6 100644 --- a/bsp_q7s/devices/startracker/StrHelper.h +++ b/bsp_q7s/devices/startracker/StrHelper.h @@ -90,38 +90,37 @@ public: /** * @brief Starts sequence to upload image to star tracker * - * @param image Name including absolute path if to image to upload. Must be previously - * transferred to the OBC with the CFDP protocoll. + * @param uploadImage_ Name including absolute path of the image to upload. Must be previously + * transferred to the OBC with the CFDP protocol. */ ReturnValue_t startImageUpload(std::string uploadImage_); /** * @brief Calling this function initiates the download of an image from the star tracker. * - * @param Name of the image which will be created + * @param path Path where downloaded image will be stored */ - ReturnValue_t startImageDownload(std::string downloadImagePath_); + ReturnValue_t startImageDownload(std::string path); /** * @brief Starts the flash write procedure * - * @param flashWriteFile_ Full name including absolute path of file to write to flash + * @param fullname Full name including absolute path of file to write to flash * @param region Region ID of flash region to write to * @param address Start address of flash write procedure */ - ReturnValue_t startFlashWrite(std::string flashWriteFile_, uint8_t region, - uint32_t address); + ReturnValue_t startFlashWrite(std::string fullname, uint8_t region, uint32_t address); /** * @brief Starts the flash read procedure * - * @param flashWriteFile_ Full name including absolute path of file to write to flash + * @param path Path where file with read flash data will be created * @param region Region ID of flash region to read from - * @param flashWriteAddress Start address of flash section to read + * @param address Start address of flash section to read * @param length Number of bytes to read from flash */ - ReturnValue_t startFlashRead(std::string flashReadPath_, uint8_t region, - uint32_t address, uint32_t length); + ReturnValue_t startFlashRead(std::string path, uint8_t region, uint32_t address, + uint32_t length); /** * @brief Starts the download of the FPGA image @@ -148,7 +147,7 @@ public: /** * @brief Changes the dafault name of downloaded images */ - void setDownloadImageName(std::string image); + void setDownloadImageName(std::string filename); /** * @brief Sets the name of the file which will be created to store the data read from flash @@ -204,7 +203,6 @@ private: // Name of file containing downloaded FPGA image std::string fileName = "fpgaimage.bin"; }; - FpgaDownload fpgaDownload; class FpgaUpload { @@ -213,7 +211,6 @@ private: // Full name of file to upload std::string uploadFile; }; - FpgaUpload fpgaUpload; static const uint32_t MAX_POLLS = 10000; @@ -245,31 +242,49 @@ private: BinarySemaphore semaphore; - // Name including absolute path of image to upload - std::string uploadImage; - // Path where the downloaded image will be stored - std::string downloadImagePath; - // File which contains data to write when executing the flash write command - std::string flashWriteFile; - // Path where the file containing the read data will be stored - std::string flashReadPath = ""; + class UploadImage { + public: + // Name including absolute path of image to upload + std::string uploadFile; + }; + UploadImage uploadImage; - // Default name of downloaded image, can be changed via command - std::string downloadImage = "image.bin"; - // Default name of file containing the data read from flash, can be changed via command - std::string flashReadFile = "flashread.bin"; - // Will be set with the flash write command - uint8_t flashWriteRegion = 0; - // Will be set with the flash write command and specifies the start address where to write the - // flash data to - uint32_t flashWriteAddress = 0; - // Will be set with the flash read command - uint8_t flashReadRegion = 0; - // Will be set with the flash read command and specifies the start address of the flash section - // to read - uint32_t flashReadAddress = 0; - // Number of bytes to read from flash - uint32_t flashReadSize = 0; + class DownloadImage { + public: + // Path where the downloaded image will be stored + std::string path; + // Default name of downloaded image, can be changed via command + std::string filename = "image.bin"; + }; + DownloadImage downloadImage; + + class FlashWrite { + public: + // File which contains data to write when executing the flash write command + std::string fullname; + // Will be set with the flash write command + uint8_t region = 0; + // Will be set with the flash write command and specifies the start address where to write the + // flash data to + uint32_t address = 0; + }; + FlashWrite flashWrite; + + class FlashRead { + public: + // Path where the file containing the read data will be stored + std::string path = ""; + // Default name of file containing the data read from flash, can be changed via command + std::string filename = "flashread.bin"; + // Will be set with the flash read command + uint8_t region = 0; + // Will be set with the flash read command and specifies the start address of the flash section + // to read + uint32_t address = 0; + // Number of bytes to read from flash + uint32_t size = 0; + }; + FlashRead flashRead; SdCardManager* sdcMan = nullptr; diff --git a/tmtc b/tmtc index e3950bbb..418ecb81 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit e3950bbbcca825b07c40b16658127210a9fe5fe2 +Subproject commit 418ecb815b00d5d2081b8d55a480f4c13a0f7139 From 1aca0b4499a375fa68b860d9acec8c1bb47d36f9 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Sat, 1 Jan 2022 11:16:11 +0100 Subject: [PATCH 178/465] typo --- bsp_q7s/devices/startracker/StarTrackerDefinitions.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h index 29a1d800..f1f7b7d0 100644 --- a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h +++ b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h @@ -341,7 +341,7 @@ public: StaticLocalDataSet(sid_t(objectId, TEMPERATURE_SET_ID)) { } - // Ticks is time reference generated by interanl counter of the star tracker + // Ticks is time reference generated by internal counter of the star tracker lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_TEMPERATURE_SET, this); /** Unix time in microseconds */ @@ -381,7 +381,6 @@ public: StaticLocalDataSet(sid_t(objectId, VERSION_SET_ID)) { } - // Ticks is time reference generated by interanl counter of the star tracker lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_VERSION_SET, this); /** Unix time in microseconds */ From 3bbc7820c81a3465ddd422ef4d54c7f171886571 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Sat, 1 Jan 2022 11:19:19 +0100 Subject: [PATCH 179/465] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 418ecb81..734dc5ae 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 418ecb815b00d5d2081b8d55a480f4c13a0f7139 +Subproject commit 734dc5aef88d9fef4ad59817b6ea315db954205c From 8b8a1554a557f1a2223d7ede98c14248541a2ce8 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Sat, 1 Jan 2022 11:25:00 +0100 Subject: [PATCH 180/465] header fix issue with case sensitivity --- bsp_q7s/devices/startracker/StarTrackerHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp index 9a504ffd..de70037a 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp @@ -4,7 +4,7 @@ #include "StarTrackerJsonCommands.h" #include #include -#include +#include extern "C" { #include #include From b59abb55fec83d72808eee4bd59f425f53f22e01 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Sat, 1 Jan 2022 15:35:08 +0100 Subject: [PATCH 181/465] fixed device file number for mpsoc uart --- bsp_q7s/boardconfig/busConf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index bcd43ccf..3108e303 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -8,7 +8,7 @@ static constexpr char SPI_RW_DEV[] = "/dev/spidev3.0"; static constexpr char I2C_DEFAULT_DEV[] = "/dev/i2c-1"; -static constexpr char UART_PLOC_MPSOC_DEV[] = "/dev/ttyUL3"; +static constexpr char UART_PLOC_MPSOC_DEV[] = "/dev/ttyUL2"; static constexpr char UART_PLOC_SUPERVSIOR_DEV[] = "/dev/ttyUL4"; static constexpr char UART_SYRLINKS_DEV[] = "/dev/ttyUL5"; static constexpr char UART_STAR_TRACKER_DEV[] = "/dev/ttyUL7"; From 7e0510115ad229ccb700bf7748e834c479a4fae0 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Sat, 1 Jan 2022 15:53:44 +0100 Subject: [PATCH 182/465] adapted uart device files --- bsp_q7s/boardconfig/busConf.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index 3108e303..40989db5 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -9,12 +9,12 @@ static constexpr char SPI_RW_DEV[] = "/dev/spidev3.0"; static constexpr char I2C_DEFAULT_DEV[] = "/dev/i2c-1"; static constexpr char UART_PLOC_MPSOC_DEV[] = "/dev/ttyUL2"; -static constexpr char UART_PLOC_SUPERVSIOR_DEV[] = "/dev/ttyUL4"; -static constexpr char UART_SYRLINKS_DEV[] = "/dev/ttyUL5"; +static constexpr char UART_PLOC_SUPERVSIOR_DEV[] = "/dev/ttyUL3"; +static constexpr char UART_SYRLINKS_DEV[] = "/dev/ttyUL4"; static constexpr char UART_STAR_TRACKER_DEV[] = "/dev/ttyUL7"; static constexpr char UART_GNSS_0_DEV[] = "/dev/ttyUL0"; -static constexpr char UART_GNSS_1_DEV[] = "/dev/ttyUL2"; +static constexpr char UART_GNSS_1_DEV[] = "/dev/ttyUL0"; static constexpr char UIO_PDEC_REGISTERS[] = "/dev/uio0"; static constexpr char UIO_PDEC_CONFIG_MEMORY[] = "/dev/uio2"; From 24ee4cb7f5c50d6988b675ba60dce876e174beca Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 2 Jan 2022 10:39:40 +0100 Subject: [PATCH 183/465] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 2ecc4de0..242c0e48 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 2ecc4de0223f3772627a002a6486c356ab6f5cd2 +Subproject commit 242c0e48a9bbcb1039dec6a2b6abba52e826870e From 1f7ff062c127336cabea8af4a2c7d2b5a79aa445 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Fri, 7 Jan 2022 08:12:41 +0100 Subject: [PATCH 184/465] performing remote reset of Q7S --- README.md | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index ff2c359d..5ac8f6e6 100644 --- a/README.md +++ b/README.md @@ -11,14 +11,15 @@ 4. [Useful and Common Host Commands](#host-commands) 5. [Setting up Prerequisites](#set-up-prereq) 6. [Remote Debugging](#remote-debugging) -7. [TMTC testing](#tmtc-testing) -8. [Direct Debugging](#direct-debugging) -9. [Transfering Files to the Q7S](#file-transfer) -10. [Q7S OBC](#q7s) -11. [Static Code Analysis](#static-code-analysis) -12. [Eclipse](#eclipse) -13. [Running the OBSW on a Raspberry Pi](#rpi) -14. [FSFW](#fsfw) +6. [Remote Reset](#remote-reset) +8. [TMTC testing](#tmtc-testing) +9. [Direct Debugging](#direct-debugging) +10. [Transfering Files to the Q7S](#file-transfer) +11. [Q7S OBC](#q7s) +12. [Static Code Analysis](#static-code-analysis) +13. [Eclipse](#eclipse) +14. [Running the OBSW on a Raspberry Pi](#rpi) +15. [FSFW](#fsfw) # General information @@ -535,10 +536,10 @@ ssh root@192.168.133.10 ``` If this has not been done yet, you can access the serial -console of the Q7S like this to set it +console of the Q7S like this ```sh -picocom -b 115200 /dev/ttyUSB0 +picocom -b 115200 /dev/q7sSerial ``` The flatsat has the aliases and shell scripts `q7s_ssh` and `q7s_serial` for this task as well. @@ -575,6 +576,29 @@ alias or shell script to do this quickly. Note: When now setting up a debug session in the Xilinx SDK or Eclipse, the host must be set to localhost instead of the IP address of the Q7S. +# Remote Reset +1. Launch xilinx hardware server on flatsat with alias +```` +launch-hwserver-xilinx +```` +2. On host PC start xsc +3. In xsct console type the follwing command to connect to the hardware server (replace with the IP address of the flatsat PC. Can be found out with ifconfig) +```` +connect -url tcp::3121 +```` +4. The following command will list all available devices +```` +targets +```` +5. Connect to the APU of the Q7S +```` +target +```` +6. Perform reset +```` +rst +```` + # TMTC testing The OBSW supports sending PUS TM packets via TCP or the PDEC IP Core which transmits the data as From 1bed87bc202bf2e9780e504f6134ab7ad67ffbe8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 10 Jan 2022 10:07:19 +0100 Subject: [PATCH 185/465] README update --- README.md | 21 +-------------------- tmtc | 2 +- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index ff2c359d..04249cfa 100644 --- a/README.md +++ b/README.md @@ -1021,26 +1021,7 @@ cat file.bin | hexdump -v -n X ## Preparation of a fresh rootfs and SD card -This section summarizes important changes between a fresh rootfs and the current -EIVE implementation - -### rootfs - -- Mount point `/mnt/sd0` created for SD card 0. Created with `mkdir` -- Mount point `/mnt/sd1` created for SD card 1. Created with `mkdir` -- Folder `scripts` in `/home/root` folder. -- `scripts` folder currently contains a few shell helper scripts -- Folder `profile.d` in `/etc` folder which contains the `path-set.sh` script - which is sourced at software startup -- Library `libwire.so` in `/usr/lib` folder - -### SD Cards - -- Folder `bin` for binaries, for example the OBSW -- Folder `misc` for miscellaneous files. Contains `ls` for directory listings -- Folder `tc` for telecommands -- Folder `tm` for telemetry -- Folder `xdi` for XDI components (e.g. for firmware or device tree updates) +See [q7s-package repository README](https://egit.irs.uni-stuttgart.de/eive/q7s-package) # Running cppcheck on the Software diff --git a/tmtc b/tmtc index 2ecc4de0..77919df9 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 2ecc4de0223f3772627a002a6486c356ab6f5cd2 +Subproject commit 77919df9f2f05aede4ad4afd5ea56899ad994d32 From 7201fdf1521649a16442c01b5a1a48fc5b1134a2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 10 Jan 2022 14:02:58 +0100 Subject: [PATCH 186/465] justfile update --- Justfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Justfile b/Justfile index f9d9504b..278ace99 100644 --- a/Justfile +++ b/Justfile @@ -5,5 +5,8 @@ default: q7s-debug-make q7s-debug-make: {{python_script}} -o linux -g make -b debug -t "arm/q7s" -l build-Debug-Q7S +q7s-release-make: + {{python_script}} -o linux -g make -b release -t "arm/q7s" -l build-Release-Q7S + q7s-debug-ninja: {{python_script}} -o linux -g ninja -b debug -t "arm/q7s" -l build-Debug-Q7S From 1f5553b5712bdbe4720610d8121fdd20cb60a9ce Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 11 Jan 2022 10:16:26 +0100 Subject: [PATCH 187/465] convert gps handler base class - Is ExtendedControllerBase now --- bsp_q7s/core/ObjectFactory.cpp | 1 - mission/devices/GPSHyperionHandler.cpp | 219 +++++++++---------------- mission/devices/GPSHyperionHandler.h | 43 ++--- 3 files changed, 86 insertions(+), 177 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index ffc9693b..14f1b34b 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -577,7 +577,6 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI auto gpsHandler0 = new GPSHyperionHandler(objects::GPS0_HANDLER, objects::UART_COM_IF, uartCookieGps0, debugGps); gpsHandler0->setResetPinTriggerFunction(gps::triggerGpioResetPin, &resetArgsGnss0); - gpsHandler0->setStartUpImmediately(); } void ObjectFactory::createHeaterComponents() { diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index 8944d17a..58491332 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -4,8 +4,6 @@ #include "fsfw/datapool/PoolReadGuard.h" #include "fsfw/timemanager/Clock.h" -#include "lwgps/lwgps.h" - #if FSFW_DEV_HYPERION_GPS_CREATE_NMEA_CSV == 1 #include #include @@ -13,48 +11,88 @@ GPSHyperionHandler::GPSHyperionHandler(object_id_t objectId, object_id_t deviceCommunication, CookieIF *comCookie, bool debugHyperionGps): - DeviceHandlerBase(objectId, deviceCommunication, comCookie), gpsSet(this), + ExtendedControllerBase(objectId, objects::NO_OBJECT), gpsSet(this), debugHyperionGps(debugHyperionGps) { - lwgps_init(&gpsData); } GPSHyperionHandler::~GPSHyperionHandler() {} -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; - } - } +void GPSHyperionHandler::performControlOperation() { + // 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 } -void GPSHyperionHandler::doShutDown() { - internalState = InternalStates::NONE; - commandExecuted = false; - setMode(_MODE_POWER_DOWN); +LocalPoolDataSetBase* GPSHyperionHandler::getDataSetHandle(sid_t sid) { + return nullptr; } -ReturnValue_t GPSHyperionHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { - return NOTHING_TO_SEND; +ReturnValue_t GPSHyperionHandler::checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t *msToReachTheMode) { + return HasReturnvaluesIF::RETURN_OK; } -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) { +ReturnValue_t GPSHyperionHandler::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); @@ -69,99 +107,6 @@ ReturnValue_t GPSHyperionHandler::buildCommandFromCommand( 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})); @@ -180,35 +125,21 @@ ReturnValue_t GPSHyperionHandler::initializeLocalDataPool( 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 = DeviceHandlerBase::initialize(); + ReturnValue_t result = ExtendedControllerBase::initialize(); if(result != HasReturnvaluesIF::RETURN_OK) { return result; } - // Enable reply immediately for now - return updatePeriodicReply(true, GpsHyperion::GPS_REPLY); + return result; } -ReturnValue_t GPSHyperionHandler::acceptExternalDeviceCommands() { - return DeviceHandlerBase::acceptExternalDeviceCommands(); +ReturnValue_t GPSHyperionHandler::handleCommandMessage(CommandMessage *message) { + return ExtendedControllerBase::handleCommandMessage(message); } diff --git a/mission/devices/GPSHyperionHandler.h b/mission/devices/GPSHyperionHandler.h index e7c925be..62ec4d01 100644 --- a/mission/devices/GPSHyperionHandler.h +++ b/mission/devices/GPSHyperionHandler.h @@ -3,6 +3,7 @@ #include "fsfw/FSFW.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" +#include "fsfw/controller/ExtendedControllerBase.h" #include "devicedefinitions/GPSDefinitions.h" #include "lwgps/lwgps.h" @@ -12,7 +13,7 @@ * Flight manual: * https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/Hyperion_HT-GPS200 */ -class GPSHyperionHandler: public DeviceHandlerBase { +class GPSHyperionHandler: public ExtendedControllerBase { public: GPSHyperionHandler(object_id_t objectId, object_id_t deviceCommunication, @@ -22,46 +23,24 @@ public: using gpioResetFunction_t = ReturnValue_t (*) (void* args); void setResetPinTriggerFunction(gpioResetFunction_t resetCallback, void*args); - ReturnValue_t acceptExternalDeviceCommands() override; - + 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; - 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; bool debugHyperionGps = false; }; From d8ec051e13aecc6d29bbc7c8b857662f3dbcbc1a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 11 Jan 2022 10:55:26 +0100 Subject: [PATCH 188/465] stuff --- bsp_q7s/core/ObjectFactory.cpp | 8 ++------ linux/fsfwconfig/OBSWConfig.h.in | 2 +- mission/devices/GPSHyperionHandler.cpp | 4 ++-- mission/devices/GPSHyperionHandler.h | 4 ++-- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 14f1b34b..42665293 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -570,12 +570,8 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI resetArgsGnss0.gnss1 = false; resetArgsGnss0.gpioComIF = gpioComIF; resetArgsGnss0.waitPeriodMs = 100; - auto uartCookieGps0 = new UartCookie(objects::GPS0_HANDLER, q7s::UART_GNSS_DEV, - UartModes::CANONICAL, uart::GNSS_BAUD, uart::HYPERION_GPS_REPLY_MAX_BUFFER); - uartCookieGps0->setToFlushInput(true); - uartCookieGps0->setReadCycles(6); - auto gpsHandler0 = new GPSHyperionHandler(objects::GPS0_HANDLER, objects::UART_COM_IF, - uartCookieGps0, debugGps); + auto gpsHandler0 = new GPSHyperionHandler(objects::GPS0_HANDLER, objects::NO_OBJECT, + debugGps); gpsHandler0->setResetPinTriggerFunction(gps::triggerGpioResetPin, &resetArgsGnss0); } diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index 4a7bca35..51a04e16 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -109,7 +109,7 @@ debugging. */ #define OBSW_DEBUG_STARTRACKER 0 #define OBSW_DEBUG_PLOC_MPSOC 0 #define OBSW_DEBUG_PLOC_SUPERVISOR 0 -#define OBSW_DEBUG_PDEC_HANDLER 1 +#define OBSW_DEBUG_PDEC_HANDLER 0 /*******************************************************************/ /** Hardcoded */ diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index 58491332..3a2253e6 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -9,8 +9,8 @@ #include #endif -GPSHyperionHandler::GPSHyperionHandler(object_id_t objectId, object_id_t deviceCommunication, - CookieIF *comCookie, bool debugHyperionGps): +GPSHyperionHandler::GPSHyperionHandler(object_id_t objectId, object_id_t parentId, + bool debugHyperionGps): ExtendedControllerBase(objectId, objects::NO_OBJECT), gpsSet(this), debugHyperionGps(debugHyperionGps) { } diff --git a/mission/devices/GPSHyperionHandler.h b/mission/devices/GPSHyperionHandler.h index 62ec4d01..240fe480 100644 --- a/mission/devices/GPSHyperionHandler.h +++ b/mission/devices/GPSHyperionHandler.h @@ -16,8 +16,8 @@ class GPSHyperionHandler: public ExtendedControllerBase { public: - GPSHyperionHandler(object_id_t objectId, object_id_t deviceCommunication, - CookieIF* comCookie, bool debugHyperionGps = false); + GPSHyperionHandler(object_id_t objectId, object_id_t parentId, + bool debugHyperionGps = false); virtual ~GPSHyperionHandler(); using gpioResetFunction_t = ReturnValue_t (*) (void* args); From 64ac41d1feedc34916259a2645e040338d13b362 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 11 Jan 2022 11:04:23 +0100 Subject: [PATCH 189/465] initialize variable --- bsp_q7s/devices/startracker/StrHelper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsp_q7s/devices/startracker/StrHelper.cpp b/bsp_q7s/devices/startracker/StrHelper.cpp index 0be38ad7..59587317 100644 --- a/bsp_q7s/devices/startracker/StrHelper.cpp +++ b/bsp_q7s/devices/startracker/StrHelper.cpp @@ -634,7 +634,7 @@ ReturnValue_t StrHelper::checkFlashActionReply(uint8_t region_, uint32_t address << std::endl; return result; } - uint16_t length; + uint16_t length = 0; size = sizeof(length); const uint8_t* lengthData = data + LENGTH_OFFSET; result = SerializeAdapter::deSerialize(&length, lengthData, &size, From 9d48438faee734968f6179608b501b5db5852066 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 11 Jan 2022 14:45:16 +0100 Subject: [PATCH 190/465] fixes for RPi --- bsp_linux_board/ObjectFactory.cpp | 2 +- fsfw | 2 +- linux/boardtest/SpiTestClass.cpp | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bsp_linux_board/ObjectFactory.cpp b/bsp_linux_board/ObjectFactory.cpp index 5cd52c91..bb86ecce 100644 --- a/bsp_linux_board/ObjectFactory.cpp +++ b/bsp_linux_board/ObjectFactory.cpp @@ -14,7 +14,7 @@ #include "mission/core/GenericFactory.h" #include "mission/utility/TmFunnel.h" #include -#include "mission/devices/GyroADIS16507Handler.h" +#include "mission/devices/GyroADIS1650XHandler.h" #include "fsfw/datapoollocal/LocalDataPoolManager.h" #include "fsfw/tmtcservices/CommandingServiceBase.h" diff --git a/fsfw b/fsfw index 2506af27..5214f8a4 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 2506af27ed84585c64df2679b0c6a3c969f31941 +Subproject commit 5214f8a449d195ecfa69f978cc0fe001ef76130a diff --git a/linux/boardtest/SpiTestClass.cpp b/linux/boardtest/SpiTestClass.cpp index b043b55d..65f2ca9f 100644 --- a/linux/boardtest/SpiTestClass.cpp +++ b/linux/boardtest/SpiTestClass.cpp @@ -297,31 +297,31 @@ void SpiTestClass::acsInit() { GpiodRegularByChip* gpio = nullptr; std::string rpiGpioName = "gpiochip0"; gpio = new GpiodRegularByChip(rpiGpioName, mgm0Lis3mdlChipSelect, "MGM_0_LIS3", - gpio::DIR_OUT, 1); + gpio::DIR_OUT, gpio::HIGH); gpioCookie->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); gpio = new GpiodRegularByChip(rpiGpioName, mgm1Rm3100ChipSelect, "MGM_1_RM3100", - gpio::DIR_OUT, 1); + gpio::DIR_OUT, gpio::HIGH); gpioCookie->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); gpio = new GpiodRegularByChip(rpiGpioName, gyro0AdisChipSelect, "GYRO_0_ADIS", - gpio::DIR_OUT, 1); + gpio::DIR_OUT, gpio::HIGH); gpioCookie->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); gpio = new GpiodRegularByChip(rpiGpioName, gyro1L3gd20ChipSelect, "GYRO_1_L3G", - gpio::DIR_OUT, 1); + gpio::DIR_OUT, gpio::HIGH); gpioCookie->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); gpio = new GpiodRegularByChip(rpiGpioName, gyro3L3gd20ChipSelect, "GYRO_2_L3G", - gpio::DIR_OUT, 1); + gpio::DIR_OUT, gpio::HIGH); gpioCookie->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); gpio = new GpiodRegularByChip(rpiGpioName, mgm2Lis3mdlChipSelect, "MGM_2_LIS3", - gpio::DIR_OUT, 1); + gpio::DIR_OUT, gpio::HIGH); gpioCookie->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); gpio = new GpiodRegularByChip(rpiGpioName, mgm3Rm3100ChipSelect, "MGM_3_RM3100", - gpio::DIR_OUT, 1); + gpio::DIR_OUT, gpio::HIGH); gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); #elif defined(XIPHOS_Q7S) GpiodRegularByLineName* gpio = nullptr; From 2323fd0506f8064866335d453734fe36fc949faf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 11 Jan 2022 14:50:39 +0100 Subject: [PATCH 191/465] added rpi port script --- scripts/rpi-port.sh | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100755 scripts/rpi-port.sh diff --git a/scripts/rpi-port.sh b/scripts/rpi-port.sh new file mode 100755 index 00000000..5801fb50 --- /dev/null +++ b/scripts/rpi-port.sh @@ -0,0 +1,8 @@ +#!/bin/bash +echo "-L 1538:raspberrypi.local:1538 for Raspberry Pi connect with TCF agent" +echo "-L 1539:raspberrypi.local:22 for Raspberry Pi file transfers" + +ssh -L 1538:raspberrypi.local:1534 \ + -L 1539:raspberrypi.local:22 \ + eive@2001:7c0:2018:1099:babe:0:e1fe:f1a5 \ + -t 'CONSOLE_PREFIX="[RPi Tunnel]" /bin/bash' From a9824b71b7c6019694ebfc3ed7e213c6a1f5be9f Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Fri, 14 Jan 2022 10:14:45 +0100 Subject: [PATCH 192/465] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 734dc5ae..dfed6b7a 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 734dc5aef88d9fef4ad59817b6ea315db954205c +Subproject commit dfed6b7adf957ba46ff04e0885a5948ea080d59d From e1ddd19e31521c96a83d3820ec1d38930d1fc0d0 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Fri, 14 Jan 2022 10:16:03 +0100 Subject: [PATCH 193/465] crc fixes in syrlinks register write commands --- mission/devices/SyrlinksHkHandler.h | 6 +++--- mission/devices/devicedefinitions/SyrlinksDefinitions.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mission/devices/SyrlinksHkHandler.h b/mission/devices/SyrlinksHkHandler.h index c194fd18..bf8a489a 100644 --- a/mission/devices/SyrlinksHkHandler.h +++ b/mission/devices/SyrlinksHkHandler.h @@ -61,10 +61,10 @@ private: std::string resetCommand = ""; std::string readRxStatusRegCommand = ""; - std::string setTxModeStandby = ""; + std::string setTxModeStandby = ""; /** W - write, 04 - 4 bytes in data field, 01 - value, 40 register to write value */ - std::string setTxModeModulation = ""; - std::string setTxModeCw = ""; + std::string setTxModeModulation = ""; + std::string setTxModeCw = ""; std::string readTxStatus = ""; std::string readTxWaveform = ""; std::string readTxAgcValueHighByte = ""; diff --git a/mission/devices/devicedefinitions/SyrlinksDefinitions.h b/mission/devices/devicedefinitions/SyrlinksDefinitions.h index 7aa75b99..43ce16f2 100644 --- a/mission/devices/devicedefinitions/SyrlinksDefinitions.h +++ b/mission/devices/devicedefinitions/SyrlinksDefinitions.h @@ -21,7 +21,7 @@ namespace SYRLINKS { static const DeviceCommandId_t READ_TX_AGC_VALUE_LOW_BYTE = 0x0A; /** Size of a simple transmission success response */ - static const uint8_t ACK_SIZE = 11; + static const uint8_t ACK_SIZE = 12; static const uint8_t SIZE_CRC_AND_TERMINATION = 5; /** The size of the header with the message identifier and the payload size field */ static const uint8_t MESSAGE_HEADER_SIZE = 5; From 3421c6fcbf51adec4b407239e38735ec4a910c76 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Fri, 14 Jan 2022 10:20:21 +0100 Subject: [PATCH 194/465] adapted to develop --- bsp_q7s/callbacks/rwSpiCallback.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/bsp_q7s/callbacks/rwSpiCallback.cpp b/bsp_q7s/callbacks/rwSpiCallback.cpp index 701fc8dc..1e60e3c0 100644 --- a/bsp_q7s/callbacks/rwSpiCallback.cpp +++ b/bsp_q7s/callbacks/rwSpiCallback.cpp @@ -194,6 +194,7 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sen else { *(rxBuf + decodedFrameLen) = byteRead; decodedFrameLen++; + continue; } /** From e73dc2f19176db39923aa355685ea1592c32802d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 15 Jan 2022 13:05:11 +0100 Subject: [PATCH 195/465] gps test worked --- CMakeLists.txt | 2 ++ bsp_q7s/boardtest/Q7STestTask.cpp | 29 +++++++++++++++++++++++++++++ bsp_q7s/boardtest/Q7STestTask.h | 3 +++ fsfw | 2 +- 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 59d9d32d..17796924 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,7 @@ set(LIB_ARCSEC wire) set(THIRD_PARTY_FOLDER thirdparty) set(LIB_CXX_FS -lstdc++fs) set(LIB_CATCH2 Catch2) +set(LIB_GPS gps) set(LIB_JSON_NAME nlohmann_json::nlohmann_json) # Set path names @@ -221,6 +222,7 @@ if((NOT BUILD_Q7S_SIMPLE_MODE) AND (NOT EIVE_BUILD_WATCHDOG)) if(TGT_BSP MATCHES "arm/q7s") target_link_libraries(${TARGET_NAME} PRIVATE ${LIB_ARCSEC} + ${LIB_GPS} ) endif() endif() diff --git a/bsp_q7s/boardtest/Q7STestTask.cpp b/bsp_q7s/boardtest/Q7STestTask.cpp index 5cead3d5..77bd7e13 100644 --- a/bsp_q7s/boardtest/Q7STestTask.cpp +++ b/bsp_q7s/boardtest/Q7STestTask.cpp @@ -12,8 +12,12 @@ #include "test/DummyParameter.h" #include +#include +#include +#include #include +#include #include #include @@ -31,6 +35,11 @@ ReturnValue_t Q7STestTask::performOneShotAction() { return TestTask::performOneShotAction(); } +ReturnValue_t Q7STestTask::performPeriodicAction() { + testGpsDaemon(); + return TestTask::performPeriodicAction(); +} + void Q7STestTask::testSdCard() { using namespace std; Stopwatch stopwatch; @@ -224,6 +233,26 @@ void Q7STestTask::testProtHandler() { } } +void Q7STestTask::testGpsDaemon() { + gpsmm gpsmm(GPSD_SHARED_MEMORY, 0); + gps_data_t* gps; + gps = gpsmm.read(); + if(gps == nullptr) { + sif::warning << "Q7STestTask: Reading GPS data failed" << std::endl; + } + sif::info << "-- Q7STestTask: GPS shared memory read test --" << std::endl; + time_t timeRaw = gps->fix.time.tv_sec; + std::tm* time = gmtime(&timeRaw); + sif::info << "Time: " << std::put_time(time, "%c %Z") << std::endl; + sif::info << "Visible satellites: " << gps->satellites_visible << std::endl; + sif::info << "Satellites used: " << gps->satellites_used << std::endl; + sif::info << "Fix (0:Not Seen|1:No Fix|2:2D|3:3D): " << gps->fix.mode << std::endl; + sif::info << "Latitude: " << gps->fix.latitude << std::endl; + sif::info << "Longitude: " << gps->fix.longitude << std::endl; + sif::info << "Altitude(MSL): " << gps->fix.altMSL << std::endl; + sif::info << "Speed(m/s): " << gps->fix.speed << std::endl; +} + void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) { auto fsHandler = ObjectManager::instance()-> get(objects::FILE_SYSTEM_HANDLER); diff --git a/bsp_q7s/boardtest/Q7STestTask.h b/bsp_q7s/boardtest/Q7STestTask.h index 5e11b374..f6da9b7a 100644 --- a/bsp_q7s/boardtest/Q7STestTask.h +++ b/bsp_q7s/boardtest/Q7STestTask.h @@ -11,6 +11,9 @@ public: private: CoreController* coreController = nullptr; ReturnValue_t performOneShotAction() override; + ReturnValue_t performPeriodicAction() override; + + void testGpsDaemon(); void testSdCard(); void fileTests(); diff --git a/fsfw b/fsfw index 5214f8a4..c1e0bcee 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 5214f8a449d195ecfa69f978cc0fe001ef76130a +Subproject commit c1e0bcee6db652d6c474c87a4099e61ecf86b694 From a706f6d9bd382acf372d5c6cb90c62fc6571c139 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 15 Jan 2022 13:09:33 +0100 Subject: [PATCH 196/465] using test booleans --- bsp_q7s/boardtest/Q7STestTask.cpp | 15 ++++++++++++--- bsp_q7s/boardtest/Q7STestTask.h | 4 ++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/bsp_q7s/boardtest/Q7STestTask.cpp b/bsp_q7s/boardtest/Q7STestTask.cpp index 77bd7e13..dc87cd3b 100644 --- a/bsp_q7s/boardtest/Q7STestTask.cpp +++ b/bsp_q7s/boardtest/Q7STestTask.cpp @@ -22,11 +22,18 @@ #include Q7STestTask::Q7STestTask(object_id_t objectId): TestTask(objectId) { + doTestSdCard = false; + doTestScratchApi = false; + doTestGps = false; } ReturnValue_t Q7STestTask::performOneShotAction() { - //testSdCard(); - //testScratchApi(); + if (doTestSdCard) { + testSdCard(); + } + if (doTestScratchApi) { + testScratchApi(); + } //testJsonLibDirect(); //testDummyParams(); //testProtHandler(); @@ -36,7 +43,9 @@ ReturnValue_t Q7STestTask::performOneShotAction() { } ReturnValue_t Q7STestTask::performPeriodicAction() { - testGpsDaemon(); + if(doTestGps) { + testGpsDaemon(); + } return TestTask::performPeriodicAction(); } diff --git a/bsp_q7s/boardtest/Q7STestTask.h b/bsp_q7s/boardtest/Q7STestTask.h index f6da9b7a..91e8c3d6 100644 --- a/bsp_q7s/boardtest/Q7STestTask.h +++ b/bsp_q7s/boardtest/Q7STestTask.h @@ -9,6 +9,10 @@ public: ReturnValue_t initialize() override; private: + bool doTestSdCard = false; + bool doTestScratchApi = false; + bool doTestGps = false; + CoreController* coreController = nullptr; ReturnValue_t performOneShotAction() override; ReturnValue_t performPeriodicAction() override; From 806280ee4aee42f712a381179d45b95afc198bec Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 15 Jan 2022 13:18:52 +0100 Subject: [PATCH 197/465] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index c1e0bcee..2c871af7 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit c1e0bcee6db652d6c474c87a4099e61ecf86b694 +Subproject commit 2c871af7b98abc794cdf6072fae174c9dc3ac63b From 9b0906c06819899184114a3fdc078f581bb7002d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 15 Jan 2022 13:19:21 +0100 Subject: [PATCH 198/465] repoint fsfw --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 2c871af7..c1e0bcee 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 2c871af7b98abc794cdf6072fae174c9dc3ac63b +Subproject commit c1e0bcee6db652d6c474c87a4099e61ecf86b694 From 1aa8befe50f64794a0b579cd018f96a9b832b785 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 15 Jan 2022 13:21:46 +0100 Subject: [PATCH 199/465] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 77919df9..8ed7a4e9 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 77919df9f2f05aede4ad4afd5ea56899ad994d32 +Subproject commit 8ed7a4e90f392f4f60e63659fa0115a2fe6765e1 From 2fa8de41032853b2c41fce0b1152319f9833657f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 15 Jan 2022 13:39:49 +0100 Subject: [PATCH 200/465] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 77919df9..c86cd187 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 77919df9f2f05aede4ad4afd5ea56899ad994d32 +Subproject commit c86cd1874f605a89277e1b8fcf4496f9302c941e From 70ab48608130f48a568147bbd0eb73f42a828494 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 15 Jan 2022 13:50:21 +0100 Subject: [PATCH 201/465] removed GPS flags --- linux/fsfwconfig/OBSWConfig.h.in | 2 -- 1 file changed, 2 deletions(-) diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index 51a04e16..ea26425b 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -47,8 +47,6 @@ debugging. */ #define OBSW_ADD_PLOC_MPSOC 0 #define OBSW_ADD_SUN_SENSORS 0 #define OBSW_ADD_ACS_BOARD 0 -#define OBSW_ADD_GPS_0 0 -#define OBSW_ADD_GPS_1 0 #define OBSW_ADD_RW 0 #define OBSW_ADD_RTD_DEVICES 0 #define OBSW_ADD_TMP_DEVICES 0 From 3b9959b8b39e068a981cfc9ac743de20309d68a8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 15 Jan 2022 13:51:27 +0100 Subject: [PATCH 202/465] removed gps from pst --- .../pollingSequenceFactory.cpp | 32 ------------------- 1 file changed, 32 deletions(-) diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 07bc4a8f..82748821 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -614,38 +614,6 @@ ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) { DeviceHandlerIF::GET_READ); #endif -#if OBSW_ADD_ACS_BOARD == 1 - -#if OBSW_ADD_GPS_0 == 1 - uartPstEmpty = false; - thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.2, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.4, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.6, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.8, - DeviceHandlerIF::GET_READ); -#endif /* OBSW_ADD_GPS_0 == 1 */ - -#if OBSW_ADD_GPS_1 == 1 - uartPstEmpty = false; - thisSequence->addSlot(objects::GPS1_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GPS1_HANDLER, length * 0.2, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GPS1_HANDLER, length * 0.4, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GPS1_HANDLER, length * 0.6, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GPS1_HANDLER, length * 0.8, - DeviceHandlerIF::GET_READ); -#endif /* OBSW_ADD_GPS_1 == 1 */ - -#endif /* OBSW_ADD_ACS_BOARD == 1 */ - #if OBSW_ADD_STAR_TRACKER == 1 uartPstEmpty = false; thisSequence->addSlot(objects::STAR_TRACKER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); From 952dfde5b79f402dc876a28299b494492a645c0a Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 17 Jan 2022 08:40:56 +0100 Subject: [PATCH 203/465] bug fixes in star tracker handler --- bsp_q7s/core/obsw.cpp | 2 +- .../startracker/StarTrackerDefinitions.h | 26 +- bsp_q7s/devices/startracker/StrHelper.cpp | 2 +- fsfw | 2 +- generators/bsp_q7s_events.csv | 280 +++++++++--------- generators/events/translateEvents.cpp | 2 +- linux/fsfwconfig/events/translateEvents.cpp | 2 +- thirdparty/arcsec_star_tracker | 2 +- tmtc | 2 +- 9 files changed, 160 insertions(+), 160 deletions(-) diff --git a/bsp_q7s/core/obsw.cpp b/bsp_q7s/core/obsw.cpp index e55d5652..a332d67e 100644 --- a/bsp_q7s/core/obsw.cpp +++ b/bsp_q7s/core/obsw.cpp @@ -29,7 +29,7 @@ int obsw::obsw() { // or systemd service! if(std::filesystem::exists(watchdog::RUNNING_FILE_NAME)) { sif::warning << "File " << watchdog::RUNNING_FILE_NAME << " exists so the software might " - "already be running. Aborting.." << std::endl; + "already be running. Check if obsw systemd service has been stopped." << std::endl; return OBSW_ALREADY_RUNNING; } #endif diff --git a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h index f1f7b7d0..eec460e3 100644 --- a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h +++ b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h @@ -396,7 +396,7 @@ public: void printSet() { PoolReadGuard rg(this); sif::info << "VersionSet::printSet: Ticks: " - << this->ticks << std::endl; + << std::dec << this->ticks << std::endl; sif::info << "VersionSet::printSet: Unix Time: " << this->time << " us" << std::endl; sif::info << "VersionSet::printSet: Program: " @@ -1018,7 +1018,7 @@ class DownloadCentroidSet: public: // Size of dataset - static const size_t SIZE = 34; + static const size_t SIZE = 38; DownloadCentroidSet(HasLocalDataPoolIF* owner): StaticLocalDataSet(owner, DOWNLOADCENTROID_SET_ID) { @@ -1042,18 +1042,18 @@ public: void printSet() { PoolReadGuard rg(this); - sif::info << "ContrastSet::printSet: id: " << static_cast(this->id.value) + sif::info << "DownloadCentroidSet::printSet: id: " << static_cast(this->id.value) << std::endl; - sif::info << "ContrastSet::printSet: pixx: " << this->pixx << std::endl; - sif::info << "ContrastSet::printSet: pixy: " << this->pixy << std::endl; - sif::info << "ContrastSet::printSet: xUncorrected: " << this->xUncorrected << std::endl; - sif::info << "ContrastSet::printSet: yUncorrected: " << this->yUncorrected << std::endl; - sif::info << "ContrastSet::printSet: xCorrected: " << this->xCorrected << std::endl; - sif::info << "ContrastSet::printSet: yCorrected: " << this->yCorrected << std::endl; - sif::info << "ContrastSet::printSet: magnitude: " << this->magnitude << std::endl; - sif::info << "ContrastSet::printSet: cxa: " << this->cxa << std::endl; - sif::info << "ContrastSet::printSet: cya: " << this->cya << std::endl; - sif::info << "ContrastSet::printSet: quality: " << this->quality << std::endl; + sif::info << "DownloadCentroidSet::printSet: pixx: " << this->pixx << std::endl; + sif::info << "DownloadCentroidSet::printSet: pixy: " << this->pixy << std::endl; + sif::info << "DownloadCentroidSet::printSet: xUncorrected: " << this->xUncorrected << std::endl; + sif::info << "DownloadCentroidSet::printSet: yUncorrected: " << this->yUncorrected << std::endl; + sif::info << "DownloadCentroidSet::printSet: xCorrected: " << this->xCorrected << std::endl; + sif::info << "DownloadCentroidSet::printSet: yCorrected: " << this->yCorrected << std::endl; + sif::info << "DownloadCentroidSet::printSet: magnitude: " << this->magnitude << std::endl; + sif::info << "DownloadCentroidSet::printSet: cxa: " << this->cxa << std::endl; + sif::info << "DownloadCentroidSet::printSet: cya: " << this->cya << std::endl; + sif::info << "DownloadCentroidSet::printSet: quality: " << this->quality << std::endl; } }; diff --git a/bsp_q7s/devices/startracker/StrHelper.cpp b/bsp_q7s/devices/startracker/StrHelper.cpp index 0be38ad7..d9b23586 100644 --- a/bsp_q7s/devices/startracker/StrHelper.cpp +++ b/bsp_q7s/devices/startracker/StrHelper.cpp @@ -125,7 +125,7 @@ ReturnValue_t StrHelper::startImageUpload(std::string fullname) { if(not std::filesystem::exists(fullname)) { return FILE_NOT_EXISTS; } - internalState = InternalState::UPLOAD_FPGA_IMAGE; + internalState = InternalState::UPLOAD_IMAGE; semaphore.release(); terminate = false; return RETURN_OK; diff --git a/fsfw b/fsfw index b98c85d3..c1e0bcee 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit b98c85d33fd79853e674f75dadd0a082a962aee4 +Subproject commit c1e0bcee6db652d6c474c87a4099e61ecf86b694 diff --git a/generators/bsp_q7s_events.csv b/generators/bsp_q7s_events.csv index cdf4d181..040b2657 100644 --- a/generators/bsp_q7s_events.csv +++ b/generators/bsp_q7s_events.csv @@ -1,140 +1,140 @@ -2200;STORE_SEND_WRITE_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2201;STORE_WRITE_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2202;STORE_SEND_READ_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2203;STORE_READ_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2204;UNEXPECTED_MSG;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2205;STORING_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2206;TM_DUMP_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2207;STORE_INIT_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2208;STORE_INIT_EMPTY;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2209;STORE_CONTENT_CORRUPTED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2210;STORE_INITIALIZE;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2211;INIT_DONE;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2212;DUMP_FINISHED;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2213;DELETION_FINISHED;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2214;DELETION_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2215;AUTO_CATALOGS_SENDING_FAILED;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -2600;GET_DATA_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/storagemanager/StorageManagerIF.h -2601;STORE_DATA_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/storagemanager/StorageManagerIF.h -2800;DEVICE_BUILDING_COMMAND_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2801;DEVICE_SENDING_COMMAND_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2802;DEVICE_REQUESTING_REPLY_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2803;DEVICE_READING_REPLY_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2804;DEVICE_INTERPRETING_REPLY_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2805;DEVICE_MISSED_REPLY;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2806;DEVICE_UNKNOWN_REPLY;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2807;DEVICE_UNREQUESTED_REPLY;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2808;INVALID_DEVICE_COMMAND;LOW;Indicates a SW bug in child class.;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2809;MONITORING_LIMIT_EXCEEDED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -2810;MONITORING_AMBIGUOUS;HIGH;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -4201;FUSE_CURRENT_HIGH;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/power/Fuse.h -4202;FUSE_WENT_OFF;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/power/Fuse.h -4204;POWER_ABOVE_HIGH_LIMIT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/power/Fuse.h -4205;POWER_BELOW_LOW_LIMIT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/power/Fuse.h -4300;SWITCH_WENT_OFF;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/power/PowerSwitchIF.h -5000;HEATER_ON;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/Heater.h -5001;HEATER_OFF;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/Heater.h -5002;HEATER_TIMEOUT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/Heater.h -5003;HEATER_STAYED_ON;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/Heater.h -5004;HEATER_STAYED_OFF;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/Heater.h -5200;TEMP_SENSOR_HIGH;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/AbstractTemperatureSensor.h -5201;TEMP_SENSOR_LOW;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/AbstractTemperatureSensor.h -5202;TEMP_SENSOR_GRADIENT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/AbstractTemperatureSensor.h -5901;COMPONENT_TEMP_LOW;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h -5902;COMPONENT_TEMP_HIGH;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h -5903;COMPONENT_TEMP_OOL_LOW;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h -5904;COMPONENT_TEMP_OOL_HIGH;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h -5905;TEMP_NOT_IN_OP_RANGE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h -7101;FDIR_CHANGED_STATE;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/fdir/FailureIsolationBase.h -7102;FDIR_STARTS_RECOVERY;MEDIUM;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/fdir/FailureIsolationBase.h -7103;FDIR_TURNS_OFF_DEVICE;MEDIUM;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/fdir/FailureIsolationBase.h -7201;MONITOR_CHANGED_STATE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h -7202;VALUE_BELOW_LOW_LIMIT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h -7203;VALUE_ABOVE_HIGH_LIMIT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h -7204;VALUE_OUT_OF_RANGE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h -7301;SWITCHING_TM_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/datapool/HkSwitchHelper.h -7400;CHANGING_MODE;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h -7401;MODE_INFO;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h -7402;FALLBACK_FAILED;HIGH;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h -7403;MODE_TRANSITION_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h -7404;CANT_KEEP_MODE;HIGH;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h -7405;OBJECT_IN_INVALID_MODE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h -7406;FORCING_MODE;MEDIUM;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h -7407;MODE_CMD_REJECTED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h -7506;HEALTH_INFO;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h -7507;CHILD_CHANGED_HEALTH;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h -7508;CHILD_PROBLEMS;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h -7509;OVERWRITING_HEALTH;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h -7510;TRYING_RECOVERY;MEDIUM;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h -7511;RECOVERY_STEP;MEDIUM;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h -7512;RECOVERY_DONE;MEDIUM;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h -7900;RF_AVAILABLE;INFO;A RF available signal was detected. P1: raw RFA state, P2: 0;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h -7901;RF_LOST;INFO;A previously found RF available signal was lost. P1: raw RFA state, P2: 0;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h -7902;BIT_LOCK;INFO;A Bit Lock signal. Was detected. P1: raw BLO state, P2: 0;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h -7903;BIT_LOCK_LOST;INFO;A previously found Bit Lock signal was lost. P1: raw BLO state, P2: 0;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h -7905;FRAME_PROCESSING_FAILED;LOW;The CCSDS Board could not interpret a TC;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h -8900;CLOCK_SET;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/pus/Service9TimeManagement.h -8901;CLOCK_SET_FAILURE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/pus/Service9TimeManagement.h -9700;TEST;INFO;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/src/fsfw/pus/Service17Test.h -10600;CHANGE_OF_SETUP_PARAMETER;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/fsfw/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h -10900;GPIO_PULL_HIGH_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/HeaterHandler.h -10901;GPIO_PULL_LOW_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/HeaterHandler.h -10902;SWITCH_ALREADY_ON;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/HeaterHandler.h -10903;SWITCH_ALREADY_OFF;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/HeaterHandler.h -10904;MAIN_SWITCH_TIMEOUT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/HeaterHandler.h -11000;MAIN_SWITCH_ON_TIMEOUT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/devices/SolarArrayDeploymentHandler.h -11001;MAIN_SWITCH_OFF_TIMEOUT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/devices/SolarArrayDeploymentHandler.h -11002;DEPLOYMENT_FAILED;HIGH;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/devices/SolarArrayDeploymentHandler.h -11003;DEPL_SA1_GPIO_SWTICH_ON_FAILED;HIGH;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/devices/SolarArrayDeploymentHandler.h -11004;DEPL_SA2_GPIO_SWTICH_ON_FAILED;HIGH;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/devices/SolarArrayDeploymentHandler.h -11101;MEMORY_READ_RPT_CRC_FAILURE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/PlocMPSoCHandler.h -11102;ACK_FAILURE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/PlocMPSoCHandler.h -11103;EXE_FAILURE;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/PlocMPSoCHandler.h -11104;CRC_FAILURE_EVENT;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/PlocMPSoCHandler.h -11201;SELF_TEST_I2C_FAILURE;LOW;Get self test result returns I2C failure P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h -11202;SELF_TEST_SPI_FAILURE;LOW;Get self test result returns SPI failure. This concerns the MTM connectivity. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h -11203;SELF_TEST_ADC_FAILURE;LOW;Get self test result returns failure in measurement of current and temperature. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h -11204;SELF_TEST_PWM_FAILURE;LOW;Get self test result returns PWM failure which concerns the coil actuation. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h -11205;SELF_TEST_TC_FAILURE;LOW;Get self test result returns TC failure (system failure) P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h -11206;SELF_TEST_MTM_RANGE_FAILURE;LOW;Get self test result returns failure that MTM values were outside of the expected range. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h -11207;SELF_TEST_COIL_CURRENT_FAILURE;LOW;Get self test result returns failure indicating that the coil current was outside of the expected range P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h -11208;INVALID_ERROR_BYTE;LOW;Received invalid error byte. This indicates an error of the communication link between IMTQ and OBC.;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h -11301;ERROR_STATE;HIGH;Reaction wheel signals an error state;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/RwHandler.h -11501;SUPV_MEMORY_READ_RPT_CRC_FAILURE;LOW;PLOC supervisor crc failure in telemetry packet;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h -11502;SUPV_ACK_FAILURE;LOW;PLOC supervisor received acknowledgment failure report;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h -11503;SUPV_EXE_FAILURE;LOW;PLOC received execution failure report;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h -11504;SUPV_CRC_FAILURE_EVENT;LOW;PLOC supervisor reply has invalid crc;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h -11600;SANITIZATION_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/memory/SdCardManager.h -11700;UPDATE_FILE_NOT_EXISTS;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h -11701;ACTION_COMMANDING_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h -11702;UPDATE_AVAILABLE_FAILED;LOW;Supervisor handler replied action message indicating a command execution failure of the update available command;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h -11703;UPDATE_TRANSFER_FAILED;LOW;Supervisor handler failed to transfer an update space packet. P1: Parameter holds the number of update packets already sent (inclusive the failed packet);C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h -11704;UPDATE_VERIFY_FAILED;LOW;Supervisor failed to execute the update verify command.;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h -11705;UPDATE_FINISHED;INFO;MPSoC update successful completed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h -11800;SEND_MRAM_DUMP_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocMemoryDumper.h -11801;MRAM_DUMP_FAILED;LOW;Received completion failure report form PLOC supervisor handler P1: MRAM start address of failing dump command;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocMemoryDumper.h -11802;MRAM_DUMP_FINISHED;LOW;MRAM dump finished successfully;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocMemoryDumper.h -11901;INVALID_TC_FRAME;HIGH;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/obc/PdecHandler.h -11902;INVALID_FAR;HIGH;Read invalid FAR from PDEC after startup;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/obc/PdecHandler.h -11903;CARRIER_LOCK;INFO;Carrier lock detected;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/obc/PdecHandler.h -11904;BIT_LOCK_PDEC;INFO;Bit lock detected (data valid);C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/linux/obc/PdecHandler.h -12000;IMAGE_UPLOAD_FAILED;LOW;Image upload failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h -12001;IMAGE_DOWNLOAD_FAILED;LOW;Image download failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h -12002;IMAGE_UPLOAD_SUCCESSFUL;LOW;Uploading image to star tracker was successfulop;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h -12003;IMAGE_DOWNLOAD_SUCCESSFUL;LOW;Image download was successful;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h -12004;FLASH_WRITE_SUCCESSFUL;LOW;Finished flash write procedure successfully;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h -12005;FLASH_READ_SUCCESSFUL;LOW;Finished flash read procedure successfully;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h -12006;FLASH_WRITE_FAILED;LOW;Flash write procedure failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h -12007;FLASH_READ_FAILED;LOW;Flash read procedure failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h -12008;FPGA_DOWNLOAD_SUCCESSFUL;LOW;Download of FPGA image successful;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h -12009;FPGA_DOWNLOAD_FAILED;LOW;Download of FPGA image failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h -12010;FPGA_UPLOAD_SUCCESSFUL;LOW;Upload of FPGA image successful;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h -12011;FPGA_UPLOAD_FAILED;LOW;Upload of FPGA image failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h -12012;STR_HELPER_READING_REPLY_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h -12013;STR_HELPER_COM_ERROR;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h -12014;STR_HELPER_NO_REPLY;LOW;Star tracker did not send replies (maybe device is powered off)P1: Position of upload or download packet for which no reply was sent;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h -12015;STR_HELPER_DEC_ERROR;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h -12016;POSITION_MISMATCH;LOW;Position mismatch P1: The expected position and thus the position for which the image upload/download failed;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h -12017;STR_HELPER_FILE_NOT_EXISTS;LOW;Specified file does not existP1: Internal state of str helper;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h -12018;STR_HELPER_SENDING_PACKET_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h -12019;STR_HELPER_REQUESTING_MSG_FAILED;LOW;;C:\Users\jakob\OneDrive\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +2200;STORE_SEND_WRITE_FAILED;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2201;STORE_WRITE_FAILED;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2202;STORE_SEND_READ_FAILED;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2203;STORE_READ_FAILED;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2204;UNEXPECTED_MSG;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2205;STORING_FAILED;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2206;TM_DUMP_FAILED;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2207;STORE_INIT_FAILED;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2208;STORE_INIT_EMPTY;INFO;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2209;STORE_CONTENT_CORRUPTED;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2210;STORE_INITIALIZE;INFO;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2211;INIT_DONE;INFO;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2212;DUMP_FINISHED;INFO;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2213;DELETION_FINISHED;INFO;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2214;DELETION_FAILED;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2215;AUTO_CATALOGS_SENDING_FAILED;INFO;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +2600;GET_DATA_FAILED;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/storagemanager/StorageManagerIF.h +2601;STORE_DATA_FAILED;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/storagemanager/StorageManagerIF.h +2800;DEVICE_BUILDING_COMMAND_FAILED;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2801;DEVICE_SENDING_COMMAND_FAILED;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2802;DEVICE_REQUESTING_REPLY_FAILED;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2803;DEVICE_READING_REPLY_FAILED;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2804;DEVICE_INTERPRETING_REPLY_FAILED;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2805;DEVICE_MISSED_REPLY;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2806;DEVICE_UNKNOWN_REPLY;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2807;DEVICE_UNREQUESTED_REPLY;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2808;INVALID_DEVICE_COMMAND;LOW;Indicates a SW bug in child class.;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2809;MONITORING_LIMIT_EXCEEDED;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +2810;MONITORING_AMBIGUOUS;HIGH;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +4201;FUSE_CURRENT_HIGH;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/power/Fuse.h +4202;FUSE_WENT_OFF;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/power/Fuse.h +4204;POWER_ABOVE_HIGH_LIMIT;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/power/Fuse.h +4205;POWER_BELOW_LOW_LIMIT;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/power/Fuse.h +4300;SWITCH_WENT_OFF;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/power/PowerSwitchIF.h +5000;HEATER_ON;INFO;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/thermal/Heater.h +5001;HEATER_OFF;INFO;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/thermal/Heater.h +5002;HEATER_TIMEOUT;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/thermal/Heater.h +5003;HEATER_STAYED_ON;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/thermal/Heater.h +5004;HEATER_STAYED_OFF;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/thermal/Heater.h +5200;TEMP_SENSOR_HIGH;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/thermal/AbstractTemperatureSensor.h +5201;TEMP_SENSOR_LOW;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/thermal/AbstractTemperatureSensor.h +5202;TEMP_SENSOR_GRADIENT;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/thermal/AbstractTemperatureSensor.h +5901;COMPONENT_TEMP_LOW;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h +5902;COMPONENT_TEMP_HIGH;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h +5903;COMPONENT_TEMP_OOL_LOW;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h +5904;COMPONENT_TEMP_OOL_HIGH;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h +5905;TEMP_NOT_IN_OP_RANGE;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/thermal/ThermalComponentIF.h +7101;FDIR_CHANGED_STATE;INFO;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/fdir/FailureIsolationBase.h +7102;FDIR_STARTS_RECOVERY;MEDIUM;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/fdir/FailureIsolationBase.h +7103;FDIR_TURNS_OFF_DEVICE;MEDIUM;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/fdir/FailureIsolationBase.h +7201;MONITOR_CHANGED_STATE;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h +7202;VALUE_BELOW_LOW_LIMIT;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h +7203;VALUE_ABOVE_HIGH_LIMIT;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h +7204;VALUE_OUT_OF_RANGE;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/monitoring/MonitoringIF.h +7301;SWITCHING_TM_FAILED;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/datapool/HkSwitchHelper.h +7400;CHANGING_MODE;INFO;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h +7401;MODE_INFO;INFO;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h +7402;FALLBACK_FAILED;HIGH;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h +7403;MODE_TRANSITION_FAILED;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h +7404;CANT_KEEP_MODE;HIGH;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h +7405;OBJECT_IN_INVALID_MODE;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h +7406;FORCING_MODE;MEDIUM;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h +7407;MODE_CMD_REJECTED;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/modes/HasModesIF.h +7506;HEALTH_INFO;INFO;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h +7507;CHILD_CHANGED_HEALTH;INFO;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h +7508;CHILD_PROBLEMS;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h +7509;OVERWRITING_HEALTH;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h +7510;TRYING_RECOVERY;MEDIUM;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h +7511;RECOVERY_STEP;MEDIUM;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h +7512;RECOVERY_DONE;MEDIUM;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/health/HasHealthIF.h +7900;RF_AVAILABLE;INFO;A RF available signal was detected. P1: raw RFA state, P2: 0;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h +7901;RF_LOST;INFO;A previously found RF available signal was lost. P1: raw RFA state, P2: 0;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h +7902;BIT_LOCK;INFO;A Bit Lock signal. Was detected. P1: raw BLO state, P2: 0;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h +7903;BIT_LOCK_LOST;INFO;A previously found Bit Lock signal was lost. P1: raw BLO state, P2: 0;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h +7905;FRAME_PROCESSING_FAILED;LOW;The CCSDS Board could not interpret a TC;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/datalinklayer/DataLinkLayer.h +8900;CLOCK_SET;INFO;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/pus/Service9TimeManagement.h +8901;CLOCK_SET_FAILURE;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/pus/Service9TimeManagement.h +9700;TEST;INFO;;C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/pus/Service17Test.h +10600;CHANGE_OF_SETUP_PARAMETER;LOW;;C:\Users\jakob\eive-software\eive_obsw/fsfw/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h +10900;GPIO_PULL_HIGH_FAILED;LOW;;C:\Users\jakob\eive-software\eive_obsw/mission/devices/HeaterHandler.h +10901;GPIO_PULL_LOW_FAILED;LOW;;C:\Users\jakob\eive-software\eive_obsw/mission/devices/HeaterHandler.h +10902;SWITCH_ALREADY_ON;LOW;;C:\Users\jakob\eive-software\eive_obsw/mission/devices/HeaterHandler.h +10903;SWITCH_ALREADY_OFF;LOW;;C:\Users\jakob\eive-software\eive_obsw/mission/devices/HeaterHandler.h +10904;MAIN_SWITCH_TIMEOUT;LOW;;C:\Users\jakob\eive-software\eive_obsw/mission/devices/HeaterHandler.h +11000;MAIN_SWITCH_ON_TIMEOUT;LOW;;C:\Users\jakob\eive-software\eive_obsw/linux/devices/SolarArrayDeploymentHandler.h +11001;MAIN_SWITCH_OFF_TIMEOUT;LOW;;C:\Users\jakob\eive-software\eive_obsw/linux/devices/SolarArrayDeploymentHandler.h +11002;DEPLOYMENT_FAILED;HIGH;;C:\Users\jakob\eive-software\eive_obsw/linux/devices/SolarArrayDeploymentHandler.h +11003;DEPL_SA1_GPIO_SWTICH_ON_FAILED;HIGH;;C:\Users\jakob\eive-software\eive_obsw/linux/devices/SolarArrayDeploymentHandler.h +11004;DEPL_SA2_GPIO_SWTICH_ON_FAILED;HIGH;;C:\Users\jakob\eive-software\eive_obsw/linux/devices/SolarArrayDeploymentHandler.h +11101;MEMORY_READ_RPT_CRC_FAILURE;LOW;;C:\Users\jakob\eive-software\eive_obsw/mission/devices/PlocMPSoCHandler.h +11102;ACK_FAILURE;LOW;;C:\Users\jakob\eive-software\eive_obsw/mission/devices/PlocMPSoCHandler.h +11103;EXE_FAILURE;LOW;;C:\Users\jakob\eive-software\eive_obsw/mission/devices/PlocMPSoCHandler.h +11104;CRC_FAILURE_EVENT;LOW;;C:\Users\jakob\eive-software\eive_obsw/mission/devices/PlocMPSoCHandler.h +11201;SELF_TEST_I2C_FAILURE;LOW;Get self test result returns I2C failure P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\eive-software\eive_obsw/mission/devices/IMTQHandler.h +11202;SELF_TEST_SPI_FAILURE;LOW;Get self test result returns SPI failure. This concerns the MTM connectivity. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\eive-software\eive_obsw/mission/devices/IMTQHandler.h +11203;SELF_TEST_ADC_FAILURE;LOW;Get self test result returns failure in measurement of current and temperature. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\eive-software\eive_obsw/mission/devices/IMTQHandler.h +11204;SELF_TEST_PWM_FAILURE;LOW;Get self test result returns PWM failure which concerns the coil actuation. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\eive-software\eive_obsw/mission/devices/IMTQHandler.h +11205;SELF_TEST_TC_FAILURE;LOW;Get self test result returns TC failure (system failure) P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\eive-software\eive_obsw/mission/devices/IMTQHandler.h +11206;SELF_TEST_MTM_RANGE_FAILURE;LOW;Get self test result returns failure that MTM values were outside of the expected range. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\eive-software\eive_obsw/mission/devices/IMTQHandler.h +11207;SELF_TEST_COIL_CURRENT_FAILURE;LOW;Get self test result returns failure indicating that the coil current was outside of the expected range P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\eive-software\eive_obsw/mission/devices/IMTQHandler.h +11208;INVALID_ERROR_BYTE;LOW;Received invalid error byte. This indicates an error of the communication link between IMTQ and OBC.;C:\Users\jakob\eive-software\eive_obsw/mission/devices/IMTQHandler.h +11301;ERROR_STATE;HIGH;Reaction wheel signals an error state;C:\Users\jakob\eive-software\eive_obsw/mission/devices/RwHandler.h +11501;SUPV_MEMORY_READ_RPT_CRC_FAILURE;LOW;PLOC supervisor crc failure in telemetry packet;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h +11502;SUPV_ACK_FAILURE;LOW;PLOC supervisor received acknowledgment failure report;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h +11503;SUPV_EXE_FAILURE;LOW;PLOC received execution failure report;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h +11504;SUPV_CRC_FAILURE_EVENT;LOW;PLOC supervisor reply has invalid crc;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h +11600;SANITIZATION_FAILED;LOW;;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/memory/SdCardManager.h +11700;UPDATE_FILE_NOT_EXISTS;LOW;;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/PlocUpdater.h +11701;ACTION_COMMANDING_FAILED;LOW;;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/PlocUpdater.h +11702;UPDATE_AVAILABLE_FAILED;LOW;Supervisor handler replied action message indicating a command execution failure of the update available command;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/PlocUpdater.h +11703;UPDATE_TRANSFER_FAILED;LOW;Supervisor handler failed to transfer an update space packet. P1: Parameter holds the number of update packets already sent (inclusive the failed packet);C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/PlocUpdater.h +11704;UPDATE_VERIFY_FAILED;LOW;Supervisor failed to execute the update verify command.;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/PlocUpdater.h +11705;UPDATE_FINISHED;INFO;MPSoC update successful completed;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/PlocUpdater.h +11800;SEND_MRAM_DUMP_FAILED;LOW;;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/PlocMemoryDumper.h +11801;MRAM_DUMP_FAILED;LOW;Received completion failure report form PLOC supervisor handler P1: MRAM start address of failing dump command;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/PlocMemoryDumper.h +11802;MRAM_DUMP_FINISHED;LOW;MRAM dump finished successfully;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/PlocMemoryDumper.h +11901;INVALID_TC_FRAME;HIGH;;C:\Users\jakob\eive-software\eive_obsw/linux/obc/PdecHandler.h +11902;INVALID_FAR;HIGH;Read invalid FAR from PDEC after startup;C:\Users\jakob\eive-software\eive_obsw/linux/obc/PdecHandler.h +11903;CARRIER_LOCK;INFO;Carrier lock detected;C:\Users\jakob\eive-software\eive_obsw/linux/obc/PdecHandler.h +11904;BIT_LOCK_PDEC;INFO;Bit lock detected (data valid);C:\Users\jakob\eive-software\eive_obsw/linux/obc/PdecHandler.h +12000;IMAGE_UPLOAD_FAILED;LOW;Image upload failed;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12001;IMAGE_DOWNLOAD_FAILED;LOW;Image download failed;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12002;IMAGE_UPLOAD_SUCCESSFUL;LOW;Uploading image to star tracker was successfulop;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12003;IMAGE_DOWNLOAD_SUCCESSFUL;LOW;Image download was successful;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12004;FLASH_WRITE_SUCCESSFUL;LOW;Finished flash write procedure successfully;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12005;FLASH_READ_SUCCESSFUL;LOW;Finished flash read procedure successfully;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12006;FLASH_WRITE_FAILED;LOW;Flash write procedure failed;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12007;FLASH_READ_FAILED;LOW;Flash read procedure failed;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12008;FPGA_DOWNLOAD_SUCCESSFUL;LOW;Download of FPGA image successful;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12009;FPGA_DOWNLOAD_FAILED;LOW;Download of FPGA image failed;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12010;FPGA_UPLOAD_SUCCESSFUL;LOW;Upload of FPGA image successful;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12011;FPGA_UPLOAD_FAILED;LOW;Upload of FPGA image failed;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12012;STR_HELPER_READING_REPLY_FAILED;LOW;;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12013;STR_HELPER_COM_ERROR;LOW;;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12014;STR_HELPER_NO_REPLY;LOW;Star tracker did not send replies (maybe device is powered off)P1: Position of upload or download packet for which no reply was sent;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12015;STR_HELPER_DEC_ERROR;LOW;;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12016;POSITION_MISMATCH;LOW;Position mismatch P1: The expected position and thus the position for which the image upload/download failed;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12017;STR_HELPER_FILE_NOT_EXISTS;LOW;Specified file does not existP1: Internal state of str helper;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12018;STR_HELPER_SENDING_PACKET_FAILED;LOW;;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h +12019;STR_HELPER_REQUESTING_MSG_FAILED;LOW;;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/startracker/StrHelper.h diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp index 17150762..75fa2a5c 100644 --- a/generators/events/translateEvents.cpp +++ b/generators/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** * @brief Auto-generated event translation file. Contains 140 translations. * @details - * Generated on: 2021-12-29 20:24:08 + * Generated on: 2022-01-16 16:01:54 */ #include "translateEvents.h" diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index 17150762..75fa2a5c 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** * @brief Auto-generated event translation file. Contains 140 translations. * @details - * Generated on: 2021-12-29 20:24:08 + * Generated on: 2022-01-16 16:01:54 */ #include "translateEvents.h" diff --git a/thirdparty/arcsec_star_tracker b/thirdparty/arcsec_star_tracker index f596c533..2d10c6b8 160000 --- a/thirdparty/arcsec_star_tracker +++ b/thirdparty/arcsec_star_tracker @@ -1 +1 @@ -Subproject commit f596c53315f1f81facb28faec3150612a5ad2ca0 +Subproject commit 2d10c6b85ea4cab4f4baf1918c51d54eee4202c2 diff --git a/tmtc b/tmtc index 734dc5ae..6270d90f 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 734dc5aef88d9fef4ad59817b6ea315db954205c +Subproject commit 6270d90f98b4ec694b6d543ce9a9ddd49ba743f9 From 37ae508af5090be7d0baaa494be035214c75978b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 17 Jan 2022 11:31:50 +0100 Subject: [PATCH 204/465] finished GPS handler refactoring --- mission/devices/GPSHyperionHandler.cpp | 151 +++++++++++------- mission/devices/GPSHyperionHandler.h | 3 +- .../devicedefinitions/GPSDefinitions.h | 22 +-- tmtc | 2 +- 4 files changed, 106 insertions(+), 72 deletions(-) diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index 3a2253e6..d42421a0 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -4,6 +4,10 @@ #include "fsfw/datapool/PoolReadGuard.h" #include "fsfw/timemanager/Clock.h" +#include +#include +#include + #if FSFW_DEV_HYPERION_GPS_CREATE_NMEA_CSV == 1 #include #include @@ -18,67 +22,7 @@ GPSHyperionHandler::GPSHyperionHandler(object_id_t objectId, object_id_t parentI GPSHyperionHandler::~GPSHyperionHandler() {} void GPSHyperionHandler::performControlOperation() { - // 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 + readGpsDataFromGpsd(); } LocalPoolDataSetBase* GPSHyperionHandler::getDataSetHandle(sid_t sid) { @@ -143,3 +87,88 @@ ReturnValue_t GPSHyperionHandler::initialize() { ReturnValue_t GPSHyperionHandler::handleCommandMessage(CommandMessage *message) { return ExtendedControllerBase::handleCommandMessage(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); + gps_data_t* gps; + gps = gpsmm.read(); + if(gps == nullptr) { + sif::warning << "Q7STestTask: 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; +#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) { + 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; + } 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; + 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; + } +} diff --git a/mission/devices/GPSHyperionHandler.h b/mission/devices/GPSHyperionHandler.h index 240fe480..96d6089e 100644 --- a/mission/devices/GPSHyperionHandler.h +++ b/mission/devices/GPSHyperionHandler.h @@ -5,7 +5,6 @@ #include "fsfw/devicehandlers/DeviceHandlerBase.h" #include "fsfw/controller/ExtendedControllerBase.h" #include "devicedefinitions/GPSDefinitions.h" -#include "lwgps/lwgps.h" /** * @brief Device handler for the Hyperion HT-GPS200 device @@ -43,6 +42,8 @@ protected: private: GpsPrimaryDataset gpsSet; bool debugHyperionGps = false; + + void readGpsDataFromGpsd(); }; #endif /* MISSION_DEVICES_GPSHYPERIONHANDLER_H_ */ diff --git a/mission/devices/devicedefinitions/GPSDefinitions.h b/mission/devices/devicedefinitions/GPSDefinitions.h index 90fdb123..aea442a2 100644 --- a/mission/devices/devicedefinitions/GPSDefinitions.h +++ b/mission/devices/devicedefinitions/GPSDefinitions.h @@ -15,15 +15,17 @@ enum GpsPoolIds: lp_id_t { LATITUDE = 0, LONGITUDE = 1, ALTITUDE = 2, - FIX_MODE = 3, - SATS_IN_USE = 4, - UNIX_SECONDS = 5, - YEAR = 6, - MONTH = 7, - DAY = 8, - HOURS = 9, - MINUTES = 10, - SECONDS = 11 + SPEED = 3, + FIX_MODE = 4, + SATS_IN_USE = 5, + SATS_IN_VIEW = 6, + UNIX_SECONDS = 7, + YEAR = 8, + MONTH = 9, + DAY = 10, + HOURS = 11, + MINUTES = 12, + SECONDS = 13 }; enum GpsFixModes: uint8_t { @@ -47,8 +49,10 @@ public: lp_var_t longitude = lp_var_t(sid.objectId, GpsHyperion::LONGITUDE, this); lp_var_t altitude = lp_var_t(sid.objectId, GpsHyperion::ALTITUDE, this); + lp_var_t speed = lp_var_t(sid.objectId, GpsHyperion::SPEED, this); lp_var_t fixMode = lp_var_t(sid.objectId, GpsHyperion::FIX_MODE, this); lp_var_t satInUse = lp_var_t(sid.objectId, GpsHyperion::SATS_IN_USE, this); + lp_var_t satInView = lp_var_t(sid.objectId, GpsHyperion::SATS_IN_VIEW, this); lp_var_t year = lp_var_t(sid.objectId, GpsHyperion::YEAR, this); lp_var_t month = lp_var_t(sid.objectId, GpsHyperion::MONTH, this); lp_var_t day = lp_var_t(sid.objectId, GpsHyperion::DAY, this); diff --git a/tmtc b/tmtc index 8ed7a4e9..c86cd187 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 8ed7a4e90f392f4f60e63659fa0115a2fe6765e1 +Subproject commit c86cd1874f605a89277e1b8fcf4496f9302c941e From 969251d9fa637362db0e9c476c6aea875fbd422b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 17 Jan 2022 11:38:21 +0100 Subject: [PATCH 205/465] new ACS ctrl task --- bsp_q7s/core/InitMission.cpp | 9 +++++++++ bsp_q7s/core/ObjectFactory.cpp | 10 +++++----- common/config/commonObjects.h | 3 +-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index 7977deed..df857d59 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -117,6 +117,13 @@ void initmission::initTasks() { } #endif /* OBSW_USE_CCSDS_IP_CORE == 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); + } + # if BOARD_TE0720 == 0 // FS task, task interval does not matter because it runs in permanent loop, priority low // because it is a non-essential background task @@ -202,6 +209,8 @@ void initmission::initTasks() { #endif /* OBSW_ADD_STAR_TRACKER == 1 */ #endif + acsCtrl->startTask(); + sif::info << "Tasks started.." << std::endl; } diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 42665293..c93ed507 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -449,14 +449,14 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI gpioCookieAcsBoard->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); consumer.str(""); - consumer << "0x" << std::hex << objects::GPS0_HANDLER; + consumer << "0x" << std::hex << objects::GPS_CONTROLLER; // GNSS reset pins are active low gpio = new GpiodRegularByLineName(q7s::gpioNames::RESET_GNSS_0, consumer.str(), gpio::DIR_OUT, gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::GNSS_0_NRESET, gpio); consumer.str(""); - consumer << "0x" << std::hex << objects::GPS1_HANDLER; + consumer << "0x" << std::hex << objects::GPS_CONTROLLER; gpio = new GpiodRegularByLineName(q7s::gpioNames::RESET_GNSS_1, consumer.str(), gpio::DIR_OUT, gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::GNSS_1_NRESET, gpio); @@ -476,13 +476,13 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI // Enable pins for GNSS consumer.str(""); - consumer << "0x" << std::hex << objects::GPS0_HANDLER; + consumer << "0x" << std::hex << objects::GPS_CONTROLLER; gpio = new GpiodRegularByLineName(q7s::gpioNames::GNSS_0_ENABLE, consumer.str(), gpio::DIR_OUT, gpio::LOW); gpioCookieAcsBoard->addGpio(gpioIds::GNSS_0_ENABLE, gpio); consumer.str(""); - consumer << "0x" << std::hex << objects::GPS1_HANDLER; + consumer << "0x" << std::hex << objects::GPS_CONTROLLER; gpio = new GpiodRegularByLineName(q7s::gpioNames::GNSS_1_ENABLE, consumer.str(), gpio::DIR_OUT, gpio::LOW); gpioCookieAcsBoard->addGpio(gpioIds::GNSS_1_ENABLE, gpio); @@ -570,7 +570,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI resetArgsGnss0.gnss1 = false; resetArgsGnss0.gpioComIF = gpioComIF; resetArgsGnss0.waitPeriodMs = 100; - auto gpsHandler0 = new GPSHyperionHandler(objects::GPS0_HANDLER, objects::NO_OBJECT, + auto gpsHandler0 = new GPSHyperionHandler(objects::GPS_CONTROLLER, objects::NO_OBJECT, debugGps); gpsHandler0->setResetPinTriggerFunction(gps::triggerGpioResetPin, &resetArgsGnss0); } diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index cce3616f..135259d6 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -79,8 +79,7 @@ enum commonObjects: uint32_t { SUS_12 = 0x44120043, SUS_13 = 0x44120044, - GPS0_HANDLER = 0x44130045, - GPS1_HANDLER = 0x44130146, + GPS_CONTROLLER = 0x44130045, RW1 = 0x44120047, RW2 = 0x44120148, From 2207d060586b206cfe1c10e05e5adaa9f4aa6638 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 17 Jan 2022 13:12:33 +0100 Subject: [PATCH 206/465] added .clang format script --- .clang-format | 8 ++++++++ apply-clang-format.sh | 11 +++++++++++ 2 files changed, 19 insertions(+) create mode 100644 .clang-format create mode 100755 apply-clang-format.sh diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..ada61da2 --- /dev/null +++ b/.clang-format @@ -0,0 +1,8 @@ +--- +BasedOnStyle: Google +IndentWidth: 2 +--- +Language: Cpp +ColumnLimit: 100 +ReflowComments: true +--- diff --git a/apply-clang-format.sh b/apply-clang-format.sh new file mode 100755 index 00000000..6d77c6e9 --- /dev/null +++ b/apply-clang-format.sh @@ -0,0 +1,11 @@ +#!/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 From 0d03f66e9d0c5f7c1d0131f39209d2731a27c74f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 17 Jan 2022 13:14:14 +0100 Subject: [PATCH 207/465] moved clang format script --- scripts/apply-clang-format.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 scripts/apply-clang-format.sh diff --git a/scripts/apply-clang-format.sh b/scripts/apply-clang-format.sh new file mode 100755 index 00000000..6d77c6e9 --- /dev/null +++ b/scripts/apply-clang-format.sh @@ -0,0 +1,11 @@ +#!/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 From abfc12063356089a20a5c3387092029c6ed7821a Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 17 Jan 2022 13:15:18 +0100 Subject: [PATCH 208/465] command to request camera parameters --- .../startracker/StarTrackerDefinitions.h | 85 +++++++++++++++++- .../startracker/StarTrackerHandler.cpp | 89 ++++++++++++++++++- .../devices/startracker/StarTrackerHandler.h | 12 ++- 3 files changed, 181 insertions(+), 5 deletions(-) diff --git a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h index eec460e3..8a58149e 100644 --- a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h +++ b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h @@ -196,7 +196,22 @@ enum PoolIds: lp_id_t { BLOBPIX_TOT_VAL, BLOBPIX_IN_USE, BLOBPIX_BRIGHT_NEIGHBOURS, - BLOBPIX_REGION + BLOBPIX_REGION, + CAMERA_MODE, + FOCALLENGTH, + EXPOSURE, + INTERVAL, + CAMERA_OFFSET, + PGAGAIN, + ADCGAIN, + CAM_REG1, + CAM_VAL1, + CAM_REG2, + CAM_VAL2, + CAM_REG3, + CAM_VAL3, + CAM_REG4, + CAM_VAL4 }; static const DeviceCommandId_t PING_REQUEST = 0; @@ -245,6 +260,7 @@ static const DeviceCommandId_t DOWNLOAD_FPGA_IMAGE = 63; static const DeviceCommandId_t CHANGE_FPGA_DOWNLOAD_FILE = 64; static const DeviceCommandId_t UPLOAD_FPGA_IMAGE = 65; static const DeviceCommandId_t FPGA_ACTION = 66; +static const DeviceCommandId_t REQ_CAMERA_PARAMS = 67; static const DeviceCommandId_t NONE = 0xFFFFFFFF; static const uint32_t VERSION_SET_ID = REQ_VERSION; @@ -260,6 +276,7 @@ static const uint32_t DOWNLOADCENTROID_SET_ID = DOWNLOAD_CENTROID; static const uint32_t DOWNLOAD_MATCHED_STAR_SET_ID = DOWNLOAD_MATCHED_STAR; static const uint32_t DOWNLOAD_DBIMAGE_SET_ID = DOWNLOAD_DBIMAGE; static const uint32_t DOWNLOAD_BLOBPIXEL_SET_ID = DOWNLOAD_BLOBPIXEL; +static const uint32_t CAMERA_SET_ID = REQ_CAMERA_PARAMS; /** Max size of unencoded frame */ static const size_t MAX_FRAME_SIZE = 1200; @@ -277,6 +294,7 @@ static const uint8_t DOWNLOAD_CENTROID_SET_ENTRIES = 11; static const uint8_t DOWNLOAD_MATCHED_STAR_SET_ENTRIES = 14; static const uint8_t DOWNLOAD_DBIMAGE_SET_ENTRIES = 6; static const uint8_t DOWNLOAD_BLOBPIXEL_SET_ENTRIES = 7; +static const uint8_t CAMERA_SET_ENTRIES = 15; // Action, parameter and telemetry IDs namespace ID { @@ -1206,5 +1224,70 @@ public: sif::info << "DownloadBlobPixel::printSet: region: " << this->region << std::endl; } }; + +/** + * @brief Will store the camera parameters set in the star tracker which are retrieved with + * a get parameter request. + */ +class CameraSet: public StaticLocalDataSet { +public: + + // Size of dataset + static const size_t SIZE = 25; + + CameraSet(HasLocalDataPoolIF* owner) : + StaticLocalDataSet(owner, CAMERA_SET_ID) { + } + + CameraSet(object_id_t objectId) : + StaticLocalDataSet(sid_t(objectId, CAMERA_SET_ID)) { + } + + lp_var_t mode = lp_var_t(sid.objectId, PoolIds::CAMERA_MODE, this); + lp_var_t focallength = lp_var_t(sid.objectId, PoolIds::FOCALLENGTH, this); + lp_var_t exposure = lp_var_t(sid.objectId, PoolIds::EXPOSURE, this); + lp_var_t interval = lp_var_t(sid.objectId, PoolIds::INTERVAL, this); + lp_var_t offset = lp_var_t(sid.objectId, PoolIds::CAMERA_OFFSET, this); + lp_var_t pgagain = lp_var_t(sid.objectId, PoolIds::PGAGAIN, this); + lp_var_t adcgain = lp_var_t(sid.objectId, PoolIds::ADCGAIN, this); + lp_var_t reg1 = lp_var_t(sid.objectId, PoolIds::CAM_REG1, this); + lp_var_t val1 = lp_var_t(sid.objectId, PoolIds::CAM_VAL1, this); + lp_var_t reg2 = lp_var_t(sid.objectId, PoolIds::CAM_REG2, this); + lp_var_t val2 = lp_var_t(sid.objectId, PoolIds::CAM_VAL2, this); + lp_var_t reg3 = lp_var_t(sid.objectId, PoolIds::CAM_REG3, this); + lp_var_t val3 = lp_var_t(sid.objectId, PoolIds::CAM_VAL3, this); + lp_var_t reg4 = lp_var_t(sid.objectId, PoolIds::CAM_REG4, this); + lp_var_t val4 = lp_var_t(sid.objectId, PoolIds::CAM_VAL4, this); + + void printSet() { + PoolReadGuard rg(this); + sif::info << "CameraSet::printSet: mode: " << static_cast(this->mode.value) + << std::endl; + sif::info << "CameraSet::printSet: focallength: " << this->focallength << std::endl; + sif::info << "CameraSet::printSet: exposure: " << this->exposure << std::endl; + sif::info << "CameraSet::printSet: interval: " << this->interval << std::endl; + sif::info << "CameraSet::printSet: offset: " << this->offset << std::endl; + sif::info << "CameraSet::printSet: PGA gain: " + << static_cast(this->pgagain.value) << std::endl; + sif::info << "CameraSet::printSet: ADC gain: " + << static_cast(this->adcgain.value) << std::endl; + sif::info << "CameraSet::printSet: Reg 1: " + << static_cast(this->reg1.value) << std::endl; + sif::info << "CameraSet::printSet: Val 1: " + << static_cast(this->val1.value) << std::endl; + sif::info << "CameraSet::printSet: Reg 2: " + << static_cast(this->reg2.value) << std::endl; + sif::info << "CameraSet::printSet: Val 2: " + << static_cast(this->val2.value) << std::endl; + sif::info << "CameraSet::printSet: Reg 3: " + << static_cast(this->reg3.value) << std::endl; + sif::info << "CameraSet::printSet: Val 3: " + << static_cast(this->val3.value) << std::endl; + sif::info << "CameraSet::printSet: Reg 4: " + << static_cast(this->reg4.value) << std::endl; + sif::info << "CameraSet::printSet: Val 4: " + << static_cast(this->val4.value) << std::endl; + } +}; } #endif /* MISSION_STARTRACKER_DEFINITIONS_H_ */ diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp index de70037a..efb54ff8 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp @@ -8,6 +8,7 @@ extern "C" { #include #include + #include #include "common/misc.h" } @@ -18,7 +19,7 @@ StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, DeviceHandlerBase(objectId, comIF, comCookie), temperatureSet(this), versionSet(this), powerSet( this), interfaceSet(this), timeSet(this), solutionSet(this), histogramSet(this), contrastSet( this), checksumSet(this), downloadCentroidSet(this), downloadMatchedStar(this), - downloadDbImage(this), downloadBlobPixel(this), strHelper( + downloadDbImage(this), downloadBlobPixel(this), cameraSet(this), strHelper( strHelper) { if (comCookie == nullptr) { sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl; @@ -495,6 +496,10 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi result = prepareFpgaActionCommand(commandData, commandDataLen); return result; } + case (StarTracker::REQ_CAMERA_PARAMS): { + result = prepareRequestCameraParams(); + return result; + } default: return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } @@ -573,6 +578,8 @@ void StarTrackerHandler::fillCommandAndReplyMap() { StarTracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(StarTracker::FPGA_ACTION, 3, nullptr, StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_CAMERA_PARAMS, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); } ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t remainingSize, @@ -604,7 +611,12 @@ ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t rema } case TMTC_SETPARAMREPLY: { *foundLen = remainingSize - bytesLeft; - result = scanForParameterReply(foundId); + result = scanForSetParameterReply(foundId); + break; + } + case TMTC_PARAMREPLY: { + *foundLen = remainingSize - bytesLeft; + result = scanForGetParameterReply(foundId); break; } case TMTC_TELEMETRYREPLYA: @@ -726,6 +738,10 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con result = handleSetParamReply(); break; } + case (StarTracker::REQ_CAMERA_PARAMS): { + handleParamRequest(cameraSet, StarTracker::CameraSet::SIZE); + break; + } default: { sif::debug << "StarTrackerHandler::interpretDeviceReply: Unknown device reply id:" << id << std::endl; @@ -934,6 +950,22 @@ ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& l localDataPoolMap.emplace(StarTracker::BLOBPIX_IN_USE, new PoolEntry( { 0 })); localDataPoolMap.emplace(StarTracker::BLOBPIX_BRIGHT_NEIGHBOURS, new PoolEntry( { 0 })); localDataPoolMap.emplace(StarTracker::BLOBPIX_REGION, new PoolEntry( { 0 })); + + localDataPoolMap.emplace(StarTracker::CAMERA_MODE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::FOCALLENGTH, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::EXPOSURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::INTERVAL, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CAMERA_OFFSET, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::PGAGAIN, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::ADCGAIN, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CAM_REG1, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CAM_VAL1, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CAM_REG2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CAM_VAL2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CAM_REG3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CAM_VAL3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CAM_REG4, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CAM_VAL4, new PoolEntry( { 0 })); return RETURN_OK; } @@ -1036,7 +1068,7 @@ ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t *foundId) return RETURN_OK; } -ReturnValue_t StarTrackerHandler::scanForParameterReply(DeviceCommandId_t *foundId) { +ReturnValue_t StarTrackerHandler::scanForSetParameterReply(DeviceCommandId_t *foundId) { const uint8_t* reply = dataLinkLayer.getReply(); switch (*reply) { case (StarTracker::ID::SUBSCRIBE): { @@ -1091,6 +1123,22 @@ ReturnValue_t StarTrackerHandler::scanForParameterReply(DeviceCommandId_t *found return RETURN_OK; } +ReturnValue_t StarTrackerHandler::scanForGetParameterReply(DeviceCommandId_t *foundId) { + const uint8_t* reply = dataLinkLayer.getReply(); + switch (*reply) { + case (StarTracker::ID::CAMERA): { + *foundId = StarTracker::REQ_CAMERA_PARAMS; + break; + } + default: { + sif::warning << "tarTrackerHandler::scanForGetParameterReply: UnkNown ID" << std::endl; + return RETURN_FAILED; + break; + } + } + return RETURN_OK; +} + ReturnValue_t StarTrackerHandler::scanForTmReply(DeviceCommandId_t *foundId) { const uint8_t* reply = dataLinkLayer.getReply(); switch (*reply) { @@ -1700,6 +1748,16 @@ ReturnValue_t StarTrackerHandler::prepareFpgaActionCommand(const uint8_t* comman return RETURN_OK; } +ReturnValue_t StarTrackerHandler::prepareRequestCameraParams() { + struct Camera req; + uint32_t length = 0; + arc_pack_camera_parameter_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; +} + ReturnValue_t StarTrackerHandler::handleSetParamReply() { const uint8_t* reply = dataLinkLayer.getReply(); uint8_t status = *(reply + STATUS_OFFSET); @@ -1788,6 +1846,31 @@ ReturnValue_t StarTrackerHandler::handleChecksumReply() { return RETURN_OK; } +ReturnValue_t StarTrackerHandler::handleParamRequest(LocalPoolDataSetBase& dataset, size_t size) { + ReturnValue_t result = RETURN_OK; + result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { + return result; + } + const uint8_t* reply = dataLinkLayer.getReply() + PARAMS_OFFSET; + dataset.setValidityBufferGeneration(false); + result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::handleParamRequest Deserialization failed" + << std::endl; + } + dataset.setValidityBufferGeneration(true); + dataset.setValidity(true, true); + result = dataset.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { + return result; + } +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 + dataset.printSet(); +#endif + return result; +} + ReturnValue_t StarTrackerHandler::handlePingReply() { ReturnValue_t result = RETURN_OK; uint32_t pingId = 0; diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.h b/bsp_q7s/devices/startracker/StarTrackerHandler.h index 65bd65b8..0461af27 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.h +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.h @@ -142,6 +142,7 @@ private: // Max valid position value in upload image command static const uint16_t MAX_POSITION= 4095; static const uint8_t STATUS_OFFSET = 1; + static const uint8_t PARAMS_OFFSET = 1; static const uint8_t TICKS_OFFSET = 2; static const uint8_t TIME_OFFSET = 6; static const uint8_t TM_DATA_FIELD_OFFSET = 14; @@ -260,6 +261,7 @@ private: StarTracker::DownloadMatchedStar downloadMatchedStar; StarTracker::DownloadDBImage downloadDbImage; StarTracker::DownloadBlobPixel downloadBlobPixel; + StarTracker::CameraSet cameraSet; // Pointer to object responsible for uploading and downloading images to/from the star tracker StrHelper* strHelper = nullptr; @@ -318,7 +320,8 @@ private: void slipInit(); ReturnValue_t scanForActionReply(DeviceCommandId_t *foundId); - ReturnValue_t scanForParameterReply(DeviceCommandId_t *foundId); + ReturnValue_t scanForSetParameterReply(DeviceCommandId_t *foundId); + ReturnValue_t scanForGetParameterReply(DeviceCommandId_t *foundId); ReturnValue_t scanForTmReply(DeviceCommandId_t *foundId); /** @@ -492,6 +495,11 @@ private: */ ReturnValue_t prepareFpgaActionCommand(const uint8_t* commandData, size_t commandDataLen); + /** + * @brief Will fill the command buffer with the command to request the set camera parameters. + */ + ReturnValue_t prepareRequestCameraParams(); + /** * @brief Handles action replies with datasets. */ @@ -524,6 +532,8 @@ private: ReturnValue_t handlePingReply(); + ReturnValue_t handleParamRequest(LocalPoolDataSetBase& dataset, size_t size); + /** * @brief Checks the loaded program by means of the version set */ From e6d8d24cd53ed1bd99eca60cf527a1d05d980249 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 17 Jan 2022 13:48:55 +0100 Subject: [PATCH 209/465] applied clang formatting --- bsp_hosted/InitMission.cpp | 214 +- bsp_hosted/InitMission.h | 2 +- bsp_hosted/ObjectFactory.cpp | 41 +- bsp_hosted/ObjectFactory.h | 7 +- bsp_hosted/boardconfig/etl_profile.h | 4 +- bsp_hosted/boardconfig/gcov.h | 5 +- bsp_hosted/boardconfig/print.c | 14 +- bsp_hosted/comIF/ArduinoComIF.cpp | 539 ++- bsp_hosted/comIF/ArduinoComIF.h | 71 +- bsp_hosted/comIF/ArduinoCookie.cpp | 12 +- bsp_hosted/comIF/ArduinoCookie.h | 27 +- bsp_hosted/fsfwconfig/devices/gpioIds.h | 89 +- .../fsfwconfig/devices/powerSwitcherList.h | 89 +- .../fsfwconfig/events/subsystemIdRanges.h | 5 +- .../fsfwconfig/events/translateEvents.cpp | 344 +- .../fsfwconfig/events/translateEvents.h | 2 +- .../fsfwconfig/ipc/MissionMessageTypes.cpp | 11 +- .../fsfwconfig/ipc/MissionMessageTypes.h | 4 +- .../fsfwconfig/objects/systemObjectList.h | 33 +- .../fsfwconfig/objects/translateObjects.cpp | 138 +- bsp_hosted/fsfwconfig/returnvalues/classIds.h | 6 +- bsp_hosted/fsfwconfig/tmtc/apid.h | 3 +- bsp_hosted/fsfwconfig/tmtc/pusIds.h | 30 +- bsp_hosted/main.cpp | 32 +- bsp_linux_board/InitMission.cpp | 363 +- bsp_linux_board/InitMission.h | 17 +- bsp_linux_board/ObjectFactory.cpp | 319 +- bsp_linux_board/ObjectFactory.h | 9 +- bsp_linux_board/boardconfig/etl_profile.h | 4 +- bsp_linux_board/boardconfig/gcov.h | 5 +- bsp_linux_board/boardconfig/print.c | 14 +- bsp_linux_board/main.cpp | 32 +- bsp_q7s/boardconfig/busConf.h | 106 +- bsp_q7s/boardconfig/etl_profile.h | 4 +- bsp_q7s/boardconfig/gcov.h | 5 +- bsp_q7s/boardconfig/print.c | 14 +- bsp_q7s/boardtest/FileSystemTest.cpp | 35 +- bsp_q7s/boardtest/FileSystemTest.h | 11 +- bsp_q7s/boardtest/Q7STestTask.cpp | 685 ++-- bsp_q7s/boardtest/Q7STestTask.h | 60 +- bsp_q7s/callbacks/gnssCallback.cpp | 39 +- bsp_q7s/callbacks/gnssCallback.h | 8 +- bsp_q7s/callbacks/rwSpiCallback.cpp | 412 +- bsp_q7s/callbacks/rwSpiCallback.h | 9 +- bsp_q7s/core/CoreController.cpp | 1850 +++++---- bsp_q7s/core/CoreController.h | 274 +- bsp_q7s/core/InitMission.cpp | 538 ++- bsp_q7s/core/InitMission.h | 11 +- bsp_q7s/core/ObjectFactory.cpp | 1705 +++++---- bsp_q7s/core/ObjectFactory.h | 6 +- bsp_q7s/core/ParameterHandler.cpp | 7 +- bsp_q7s/core/ParameterHandler.h | 18 +- bsp_q7s/core/obsw.cpp | 57 +- bsp_q7s/devices/PlocMemoryDumper.cpp | 282 +- bsp_q7s/devices/PlocMemoryDumper.h | 145 +- bsp_q7s/devices/PlocSupervisorHandler.cpp | 2295 ++++++----- bsp_q7s/devices/PlocSupervisorHandler.h | 549 +-- bsp_q7s/devices/PlocUpdater.cpp | 582 ++- bsp_q7s/devices/PlocUpdater.h | 247 +- .../PlocMemDumpDefinitions.h | 41 +- .../PlocSupervisorDefinitions.h | 2261 ++++++----- .../startracker/ArcsecDatalinkLayer.cpp | 100 +- .../devices/startracker/ArcsecDatalinkLayer.h | 138 +- bsp_q7s/devices/startracker/ArcsecJsonKeys.h | 214 +- .../startracker/ArcsecJsonParamBase.cpp | 103 +- .../devices/startracker/ArcsecJsonParamBase.h | 215 +- .../startracker/StarTrackerDefinitions.h | 1786 ++++----- .../startracker/StarTrackerHandler.cpp | 2958 +++++++------- .../devices/startracker/StarTrackerHandler.h | 1053 +++-- .../startracker/StarTrackerJsonCommands.cpp | 1281 +++---- .../startracker/StarTrackerJsonCommands.h | 161 +- bsp_q7s/devices/startracker/StrHelper.cpp | 1164 +++--- bsp_q7s/devices/startracker/StrHelper.h | 662 ++-- bsp_q7s/gpio/gpioCallbacks.cpp | 858 +++-- bsp_q7s/gpio/gpioCallbacks.h | 111 +- bsp_q7s/main.cpp | 9 +- bsp_q7s/memory/FileSystemHandler.cpp | 418 +- bsp_q7s/memory/FileSystemHandler.h | 104 +- bsp_q7s/memory/SdCardManager.cpp | 773 ++-- bsp_q7s/memory/SdCardManager.h | 345 +- bsp_q7s/memory/definitions.h | 21 +- bsp_q7s/memory/scratchApi.cpp | 75 +- bsp_q7s/memory/scratchApi.h | 142 +- bsp_q7s/simple/simple.cpp | 10 +- bsp_q7s/spi/Q7sSpiComIF.cpp | 8 +- bsp_q7s/spi/Q7sSpiComIF.h | 23 +- linux/archive/gpio/GpioCookie.cpp | 44 +- linux/archive/gpio/GpioCookie.h | 34 +- linux/archive/gpio/GpioIF.h | 68 +- linux/archive/gpio/LinuxLibgpioIF.cpp | 459 ++- linux/archive/gpio/LinuxLibgpioIF.h | 98 +- linux/archive/gpio/gpioDefinitions.h | 89 +- linux/archive/tmtc/CCSDSIPCoreBridge.cpp | 180 +- linux/archive/tmtc/CCSDSIPCoreBridge.h | 186 +- linux/boardtest/I2cTestClass.cpp | 7 +- linux/boardtest/I2cTestClass.h | 12 +- linux/boardtest/LibgpiodTest.cpp | 208 +- linux/boardtest/LibgpiodTest.h | 33 +- linux/boardtest/SpiTestClass.cpp | 762 ++-- linux/boardtest/SpiTestClass.h | 117 +- linux/boardtest/UartTestClass.cpp | 163 +- linux/boardtest/UartTestClass.h | 30 +- linux/csp/CspComIF.cpp | 441 ++- linux/csp/CspComIF.h | 110 +- linux/csp/CspCookie.cpp | 16 +- linux/csp/CspCookie.h | 21 +- linux/devices/SolarArrayDeploymentHandler.cpp | 305 +- linux/devices/SolarArrayDeploymentHandler.h | 224 +- linux/devices/SusHandler.cpp | 368 +- linux/devices/SusHandler.h | 83 +- .../devicedefinitions/SusDefinitions.h | 140 +- linux/fsfwconfig/devices/addresses.cpp | 4 - linux/fsfwconfig/devices/addresses.h | 137 +- linux/fsfwconfig/devices/gpioIds.h | 180 +- linux/fsfwconfig/devices/powerSwitcherList.h | 89 +- linux/fsfwconfig/events/subsystemIdRanges.h | 10 +- linux/fsfwconfig/events/translateEvents.cpp | 572 +-- linux/fsfwconfig/events/translateEvents.h | 2 +- linux/fsfwconfig/ipc/MissionMessageTypes.cpp | 12 +- linux/fsfwconfig/ipc/MissionMessageTypes.h | 6 +- linux/fsfwconfig/objects/systemObjectList.h | 60 +- linux/fsfwconfig/objects/translateObjects.cpp | 464 +-- .../pollingSequenceFactory.cpp | 1254 +++--- .../pollingsequence/pollingSequenceFactory.h | 7 +- linux/fsfwconfig/returnvalues/classIds.h | 13 +- linux/fsfwconfig/tmtc/pusIds.h | 30 +- linux/obc/PapbVcInterface.cpp | 138 +- linux/obc/PapbVcInterface.h | 158 +- linux/obc/PdecConfig.cpp | 49 +- linux/obc/PdecConfig.h | 56 +- linux/obc/PdecHandler.cpp | 842 ++-- linux/obc/PdecHandler.h | 613 ++- linux/obc/Ptme.cpp | 103 +- linux/obc/Ptme.h | 116 +- linux/obc/PtmeConfig.h | 25 +- linux/obc/PtmeIF.h | 21 +- linux/obc/PtmeRateSetter.cpp | 32 +- linux/obc/PtmeRateSetter.h | 36 +- linux/obc/TxRateSetterIF.h | 13 +- linux/obc/VcInterfaceIF.h | 23 +- linux/utility/utility.cpp | 11 +- linux/utility/utility.h | 3 +- mission/controller/ThermalController.cpp | 67 +- mission/controller/ThermalController.h | 32 +- mission/core/GenericFactory.cpp | 126 +- mission/core/GenericFactory.h | 2 - mission/devices/ACUHandler.cpp | 503 +-- mission/devices/ACUHandler.h | 57 +- mission/devices/GPSHyperionHandler.cpp | 250 +- mission/devices/GPSHyperionHandler.h | 55 +- mission/devices/GomspaceDeviceHandler.cpp | 686 ++-- mission/devices/GomspaceDeviceHandler.h | 214 +- mission/devices/GyroADIS1650XHandler.cpp | 727 ++-- mission/devices/GyroADIS1650XHandler.h | 92 +- mission/devices/HeaterHandler.cpp | 577 ++- mission/devices/HeaterHandler.h | 244 +- mission/devices/IMTQHandler.cpp | 3387 +++++++++-------- mission/devices/IMTQHandler.h | 312 +- mission/devices/Max31865PT1000Handler.cpp | 819 ++-- mission/devices/Max31865PT1000Handler.h | 151 +- mission/devices/P60DockHandler.cpp | 860 +++-- mission/devices/P60DockHandler.h | 54 +- mission/devices/PCDUHandler.cpp | 804 ++-- mission/devices/PCDUHandler.h | 178 +- mission/devices/PDU1Handler.cpp | 709 ++-- mission/devices/PDU1Handler.h | 37 +- mission/devices/PDU2Handler.cpp | 697 ++-- mission/devices/PDU2Handler.h | 40 +- mission/devices/PlocMPSoCHandler.cpp | 726 ++-- mission/devices/PlocMPSoCHandler.h | 328 +- mission/devices/RadiationSensorHandler.cpp | 263 +- mission/devices/RadiationSensorHandler.h | 68 +- mission/devices/RwHandler.cpp | 727 ++-- mission/devices/RwHandler.h | 228 +- mission/devices/SyrlinksHkHandler.cpp | 731 ++-- mission/devices/SyrlinksHkHandler.h | 274 +- mission/devices/Tmp1075Handler.cpp | 211 +- mission/devices/Tmp1075Handler.h | 74 +- .../devicedefinitions/GPSDefinitions.h | 93 +- .../devicedefinitions/GomSpacePackets.h | 637 ++-- .../devicedefinitions/GomspaceDefinitions.h | 2001 +++++----- .../GyroADIS1650XDefinitions.h | 146 +- .../devicedefinitions/GyroL3GD20Definitions.h | 62 +- .../IMTQHandlerDefinitions.h | 1595 ++++---- .../devicedefinitions/Max31865Definitions.h | 52 +- .../devicedefinitions/PlocMPSoCDefinitions.h | 278 +- .../devicedefinitions/RadSensorDefinitions.h | 131 +- .../devices/devicedefinitions/RwDefinitions.h | 270 +- .../devicedefinitions/SyrlinksDefinitions.h | 149 +- .../devicedefinitions/Tmp1075Definitions.h | 51 +- mission/memory/NVMParameterBase.cpp | 56 +- mission/memory/NVMParameterBase.h | 95 +- mission/tmtc/CCSDSHandler.cpp | 406 +- mission/tmtc/CCSDSHandler.h | 230 +- mission/tmtc/VirtualChannel.cpp | 90 +- mission/tmtc/VirtualChannel.h | 66 +- mission/utility/InitMission.h | 12 +- mission/utility/Timestamp.cpp | 32 +- mission/utility/Timestamp.h | 27 +- mission/utility/TmFunnel.cpp | 174 +- mission/utility/TmFunnel.h | 44 +- scripts/apply-clang-format.sh | 2 +- test/DummyParameter.h | 28 +- test/testtasks/PusTcInjector.cpp | 66 +- test/testtasks/PusTcInjector.h | 113 +- test/testtasks/TestTask.cpp | 140 +- test/testtasks/TestTask.h | 53 +- 207 files changed, 28889 insertions(+), 30270 deletions(-) diff --git a/bsp_hosted/InitMission.cpp b/bsp_hosted/InitMission.cpp index ed6b8820..0ca59db5 100644 --- a/bsp_hosted/InitMission.cpp +++ b/bsp_hosted/InitMission.cpp @@ -1,20 +1,19 @@ #include "InitMission.h" -#include "ObjectFactory.h" #include - +#include #include #include #include -#include #include #include #include - #include #include +#include "ObjectFactory.h" + #ifdef LINUX ServiceInterfaceStream sif::debug("DEBUG"); ServiceInterfaceStream sif::info("INFO"); @@ -27,133 +26,132 @@ ServiceInterfaceStream sif::warning("WARNING", true); ServiceInterfaceStream sif::error("ERROR", true, false, true); #endif -ObjectManagerIF *objectManager = nullptr; +ObjectManagerIF* objectManager = nullptr; void initmission::initMission() { - sif::info << "Building global objects.." << std::endl; - /* Instantiate global object manager and also create all objects */ - ObjectManager::instance()->setObjectFactoryFunction(ObjectFactory::produce, nullptr); - sif::info << "Initializing all objects.." << std::endl; - ObjectManager::instance()->initialize(); + sif::info << "Building global objects.." << std::endl; + /* Instantiate global object manager and also create all objects */ + ObjectManager::instance()->setObjectFactoryFunction(ObjectFactory::produce, nullptr); + sif::info << "Initializing all objects.." << std::endl; + ObjectManager::instance()->initialize(); - /* This function creates and starts all tasks */ - initTasks(); + /* This function creates and starts all tasks */ + initTasks(); } void initmission::initTasks() { - TaskFactory* factory = TaskFactory::instance(); - if(factory == nullptr) { - /* Should never happen ! */ - return; - } + TaskFactory* factory = TaskFactory::instance(); + if (factory == nullptr) { + /* Should never happen ! */ + return; + } #if OBSW_PRINT_MISSED_DEADLINES == 1 - void (*missedDeadlineFunc) (void) = TaskFactory::printMissedDeadline; + void (*missedDeadlineFunc)(void) = TaskFactory::printMissedDeadline; #else - void (*missedDeadlineFunc) (void) = nullptr; + void (*missedDeadlineFunc)(void) = nullptr; #endif - /* TMTC Distribution */ - PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask( - "DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - ReturnValue_t result = tmTcDistributor->addComponent( - objects::CCSDS_PACKET_DISTRIBUTOR); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } - result = tmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } - result = tmTcDistributor->addComponent(objects::TM_FUNNEL); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Object add component failed" << std::endl; - } + /* TMTC Distribution */ + PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask( + "DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + ReturnValue_t result = tmTcDistributor->addComponent(objects::CCSDS_PACKET_DISTRIBUTOR); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } + result = tmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } + result = tmTcDistributor->addComponent(objects::TM_FUNNEL); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } - /* UDP bridge */ - PeriodicTaskIF* tmtcBridgeTask = factory->createPeriodicTask( - "TMTC_UNIX_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - result = tmtcBridgeTask->addComponent(objects::TMTC_BRIDGE); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Add component UDP Unix Bridge failed" << std::endl; - } - PeriodicTaskIF* tmtcPollingTask = factory->createPeriodicTask( - "UDP_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); - result = tmtcPollingTask->addComponent(objects::TMTC_POLLING_TASK); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Add component UDP Polling failed" << std::endl; - } + /* UDP bridge */ + PeriodicTaskIF* tmtcBridgeTask = factory->createPeriodicTask( + "TMTC_UNIX_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + result = tmtcBridgeTask->addComponent(objects::TMTC_BRIDGE); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Add component UDP Unix Bridge failed" << std::endl; + } + PeriodicTaskIF* tmtcPollingTask = factory->createPeriodicTask( + "UDP_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = tmtcPollingTask->addComponent(objects::TMTC_POLLING_TASK); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Add component UDP Polling failed" << std::endl; + } - /* PUS Services */ - PeriodicTaskIF* pusVerification = factory->createPeriodicTask( - "PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } + /* PUS Services */ + PeriodicTaskIF* pusVerification = factory->createPeriodicTask( + "PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } - PeriodicTaskIF* pusEvents = factory->createPeriodicTask( - "PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusVerification->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); - if(result != HasReturnvaluesIF::RETURN_OK){ - initmission::printAddObjectError("PUS5", objects::PUS_SERVICE_5_EVENT_REPORTING); - } + PeriodicTaskIF* pusEvents = factory->createPeriodicTask( + "PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusVerification->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS5", objects::PUS_SERVICE_5_EVENT_REPORTING); + } - PeriodicTaskIF* pusHighPrio = factory->createPeriodicTask( - "PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS2", objects::PUS_SERVICE_2_DEVICE_ACCESS); - } - result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS9", objects::PUS_SERVICE_9_TIME_MGMT); - } + PeriodicTaskIF* pusHighPrio = factory->createPeriodicTask( + "PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS2", objects::PUS_SERVICE_2_DEVICE_ACCESS); + } + result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS9", objects::PUS_SERVICE_9_TIME_MGMT); + } - PeriodicTaskIF* pusMedPrio = factory->createPeriodicTask( - "PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); - result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS8", objects::PUS_SERVICE_8_FUNCTION_MGMT); - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS200", objects::PUS_SERVICE_200_MODE_MGMT); - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS20", objects::PUS_SERVICE_20_PARAMETERS); - } + PeriodicTaskIF* pusMedPrio = factory->createPeriodicTask( + "PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); + result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS8", objects::PUS_SERVICE_8_FUNCTION_MGMT); + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS200", objects::PUS_SERVICE_200_MODE_MGMT); + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS20", objects::PUS_SERVICE_20_PARAMETERS); + } - PeriodicTaskIF* pusLowPrio = factory->createPeriodicTask( - "PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc); - result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS17", objects::PUS_SERVICE_17_TEST); - } + PeriodicTaskIF* pusLowPrio = factory->createPeriodicTask( + "PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc); + result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS17", objects::PUS_SERVICE_17_TEST); + } - PeriodicTaskIF* testTask = factory->createPeriodicTask( - "TEST_TASK", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + PeriodicTaskIF* testTask = factory->createPeriodicTask( + "TEST_TASK", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); #if OBSW_ADD_TEST_CODE == 1 - result = testTask->addComponent(objects::TEST_TASK); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK); - } + result = testTask->addComponent(objects::TEST_TASK); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK); + } #endif /* OBSW_ADD_TEST_CODE == 1 */ - sif::info << "Starting tasks.." << std::endl; - tmTcDistributor->startTask(); - tmtcBridgeTask->startTask(); - tmtcPollingTask->startTask(); + sif::info << "Starting tasks.." << std::endl; + tmTcDistributor->startTask(); + tmtcBridgeTask->startTask(); + tmtcPollingTask->startTask(); - pusVerification->startTask(); - pusEvents->startTask(); - pusHighPrio->startTask(); - pusMedPrio->startTask(); - pusLowPrio->startTask(); + pusVerification->startTask(); + pusEvents->startTask(); + pusHighPrio->startTask(); + pusMedPrio->startTask(); + pusLowPrio->startTask(); #if OBSW_ADD_TEST_CODE == 1 - testTask->startTask(); + testTask->startTask(); #endif /* OBSW_ADD_TEST_CODE == 1 */ - sif::info << "Tasks started.." << std::endl; + sif::info << "Tasks started.." << std::endl; } diff --git a/bsp_hosted/InitMission.h b/bsp_hosted/InitMission.h index 01c72008..507de592 100644 --- a/bsp_hosted/InitMission.h +++ b/bsp_hosted/InitMission.h @@ -4,6 +4,6 @@ namespace initmission { void initMission(); void initTasks(); -}; +}; // namespace initmission #endif /* BSP_LINUX_INITMISSION_H_ */ diff --git a/bsp_hosted/ObjectFactory.cpp b/bsp_hosted/ObjectFactory.cpp index 6803ace4..e1be7588 100644 --- a/bsp_hosted/ObjectFactory.cpp +++ b/bsp_hosted/ObjectFactory.cpp @@ -1,14 +1,14 @@ #include "ObjectFactory.h" -#include "OBSWConfig.h" + +#include +#include +#include +#include #include #include #include -#include -#include - -#include -#include +#include "OBSWConfig.h" #if OBSW_USE_TMTC_TCP_BRIDGE == 0 #include "fsfw/osal/common/UdpTcPollingTask.h" @@ -20,29 +20,28 @@ #include - #if OBSW_ADD_TEST_CODE == 1 #include #endif -void Factory::setStaticFrameworkObjectIds(){ - PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; - PusServiceBase::packetDestination = objects::TM_FUNNEL; +void Factory::setStaticFrameworkObjectIds() { + PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; + PusServiceBase::packetDestination = objects::TM_FUNNEL; - CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; - CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; + CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; + CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; - TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; - // No storage object for now. - TmFunnel::storageDestination = objects::NO_OBJECT; + TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; + // No storage object for now. + TmFunnel::storageDestination = objects::NO_OBJECT; - VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; - TmPacketBase::timeStamperId = objects::TIME_STAMPER; + VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; + TmPacketBase::timeStamperId = objects::TIME_STAMPER; } -void ObjectFactory::produce(void* args){ - Factory::setStaticFrameworkObjectIds(); - ObjectFactory::produceGenericObjects(); +void ObjectFactory::produce(void* args) { + Factory::setStaticFrameworkObjectIds(); + ObjectFactory::produceGenericObjects(); - new TestTask(objects::TEST_TASK); + new TestTask(objects::TEST_TASK); } diff --git a/bsp_hosted/ObjectFactory.h b/bsp_hosted/ObjectFactory.h index feaba70e..b042f9dc 100644 --- a/bsp_hosted/ObjectFactory.h +++ b/bsp_hosted/ObjectFactory.h @@ -1,10 +1,9 @@ #ifndef BSP_LINUX_OBJECTFACTORY_H_ #define BSP_LINUX_OBJECTFACTORY_H_ - namespace ObjectFactory { - void setStatics(); - void produce(void* args); -}; +void setStatics(); +void produce(void* args); +}; // namespace ObjectFactory #endif /* BSP_LINUX_OBJECTFACTORY_H_ */ diff --git a/bsp_hosted/boardconfig/etl_profile.h b/bsp_hosted/boardconfig/etl_profile.h index c35ffb46..54aca344 100644 --- a/bsp_hosted/boardconfig/etl_profile.h +++ b/bsp_hosted/boardconfig/etl_profile.h @@ -32,7 +32,7 @@ SOFTWARE. #define ETL_CHECK_PUSH_POP -#define ETL_CPP11_SUPPORTED 1 -#define ETL_NO_NULLPTR_SUPPORT 0 +#define ETL_CPP11_SUPPORTED 1 +#define ETL_NO_NULLPTR_SUPPORT 0 #endif diff --git a/bsp_hosted/boardconfig/gcov.h b/bsp_hosted/boardconfig/gcov.h index 491d24c6..80acdd86 100644 --- a/bsp_hosted/boardconfig/gcov.h +++ b/bsp_hosted/boardconfig/gcov.h @@ -6,8 +6,9 @@ extern "C" void __gcov_flush(); #else void __gcov_flush() { - sif::info << "GCC GCOV: Please supply GCOV=1 in Makefile if " - "coverage information is desired.\n" << std::flush; + sif::info << "GCC GCOV: Please supply GCOV=1 in Makefile if " + "coverage information is desired.\n" + << std::flush; } #endif diff --git a/bsp_hosted/boardconfig/print.c b/bsp_hosted/boardconfig/print.c index f35f9447..9653fe5f 100644 --- a/bsp_hosted/boardconfig/print.c +++ b/bsp_hosted/boardconfig/print.c @@ -3,13 +3,9 @@ #include void printChar(const char* character, bool errStream) { - if(errStream) { - putc(*character, stderr); - return; - } - putc(*character, stdout); + if (errStream) { + putc(*character, stderr); + return; + } + putc(*character, stdout); } - - - - diff --git a/bsp_hosted/comIF/ArduinoComIF.cpp b/bsp_hosted/comIF/ArduinoComIF.cpp index 2db293e6..be136e45 100644 --- a/bsp_hosted/comIF/ArduinoComIF.cpp +++ b/bsp_hosted/comIF/ArduinoComIF.cpp @@ -1,376 +1,351 @@ #include "ArduinoComIF.h" -#include "ArduinoCookie.h" -#include #include +#include #include +#include "ArduinoCookie.h" + // This only works on Linux #ifdef LINUX -#include #include +#include #include #elif WIN32 -#include #include +#include #endif #include -ArduinoComIF::ArduinoComIF(object_id_t setObjectId, bool promptComIF, - const char *serialDevice): - rxBuffer(MAX_PACKET_SIZE * MAX_NUMBER_OF_SPI_DEVICES*10, true), - SystemObject(setObjectId) { +ArduinoComIF::ArduinoComIF(object_id_t setObjectId, bool promptComIF, const char *serialDevice) + : rxBuffer(MAX_PACKET_SIZE * MAX_NUMBER_OF_SPI_DEVICES * 10, true), SystemObject(setObjectId) { #ifdef LINUX - initialized = false; - serialPort = ::open("/dev/ttyUSB0", O_RDWR); + initialized = false; + serialPort = ::open("/dev/ttyUSB0", O_RDWR); - if (serialPort < 0) { - //configuration error - printf("Error %i from open: %s\n", errno, strerror(errno)); - return; - } + if (serialPort < 0) { + // configuration error + printf("Error %i from open: %s\n", errno, strerror(errno)); + return; + } - struct termios tty; - memset(&tty, 0, sizeof tty); + struct termios tty; + memset(&tty, 0, sizeof tty); - // Read in existing settings, and handle any error - if (tcgetattr(serialPort, &tty) != 0) { - printf("Error %i from tcgetattr: %s\n", errno, strerror(errno)); - return; - } + // Read in existing settings, and handle any error + if (tcgetattr(serialPort, &tty) != 0) { + printf("Error %i from tcgetattr: %s\n", errno, strerror(errno)); + return; + } - tty.c_cflag &= ~PARENB; // Clear parity bit, disabling parity - tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication - tty.c_cflag |= CS8; // 8 bits per byte - tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control - tty.c_lflag &= ~ICANON; //Disable Canonical Mode - tty.c_oflag &= ~OPOST; // Prevent special interpretation of output bytes (e.g. newline chars) - tty.c_oflag &= ~ONLCR; // Prevent conversion of newline to carriage return/line feed - tty.c_cc[VTIME] = 0; // Non Blocking - tty.c_cc[VMIN] = 0; + tty.c_cflag &= ~PARENB; // Clear parity bit, disabling parity + tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication + tty.c_cflag |= CS8; // 8 bits per byte + tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control + tty.c_lflag &= ~ICANON; // Disable Canonical Mode + tty.c_oflag &= ~OPOST; // Prevent special interpretation of output bytes (e.g. newline chars) + tty.c_oflag &= ~ONLCR; // Prevent conversion of newline to carriage return/line feed + tty.c_cc[VTIME] = 0; // Non Blocking + tty.c_cc[VMIN] = 0; - cfsetispeed(&tty, B9600); //Baudrate + cfsetispeed(&tty, B9600); // Baudrate - if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { - //printf("Error %i from tcsetattr: %s\n", errno, strerror(errno)); - return; - } + if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { + // printf("Error %i from tcsetattr: %s\n", errno, strerror(errno)); + return; + } - initialized = true; + initialized = true; #elif WIN32 - DCB serialParams = { 0 }; + DCB serialParams = {0}; - // we need to ask the COM port from the user. - if(promptComIF) { - sif::info << "Please enter the COM port (c to cancel): " << std::flush; - std::string comPort; - while(hCom == INVALID_HANDLE_VALUE) { + // we need to ask the COM port from the user. + if (promptComIF) { + sif::info << "Please enter the COM port (c to cancel): " << std::flush; + std::string comPort; + while (hCom == INVALID_HANDLE_VALUE) { + std::getline(std::cin, comPort); + if (comPort[0] == 'c') { + break; + } + const TCHAR *pcCommPort = comPort.c_str(); + hCom = CreateFileA(pcCommPort, // port name + GENERIC_READ | GENERIC_WRITE, // Read/Write + 0, // No Sharing + NULL, // No Security + OPEN_EXISTING, // Open existing port only + 0, // Non Overlapped I/O + NULL); // Null for Comm Devices - std::getline(std::cin, comPort); - if(comPort[0] == 'c') { - break; - } - const TCHAR *pcCommPort = comPort.c_str(); - hCom = CreateFileA(pcCommPort, //port name - GENERIC_READ | GENERIC_WRITE, //Read/Write - 0, // No Sharing - NULL, // No Security - OPEN_EXISTING,// Open existing port only - 0, // Non Overlapped I/O - NULL); // Null for Comm Devices + if (hCom == INVALID_HANDLE_VALUE) { + if (GetLastError() == 2) { + sif::error << "COM Port does not found!" << std::endl; + } else { + TCHAR err[128]; + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), err, sizeof(err), NULL); + // Handle the error. + sif::info << "CreateFileA Error code: " << GetLastError() << std::endl; + sif::error << err << std::flush; + } + sif::info << "Please enter a valid COM port: " << std::flush; + } + } + } - if (hCom == INVALID_HANDLE_VALUE) - { - if(GetLastError() == 2) { - sif::error << "COM Port does not found!" << std::endl; - } - else { - TCHAR err[128]; - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - err, sizeof(err), NULL); - // Handle the error. - sif::info << "CreateFileA Error code: " << GetLastError() - << std::endl; - sif::error << err << std::flush; - } - sif::info << "Please enter a valid COM port: " << std::flush; - } - } + serialParams.DCBlength = sizeof(serialParams); + if (baudRate == 9600) { + serialParams.BaudRate = CBR_9600; + } + if (baudRate == 115200) { + serialParams.BaudRate = CBR_115200; + } else { + serialParams.BaudRate = baudRate; + } - } + serialParams.ByteSize = 8; + serialParams.Parity = NOPARITY; + serialParams.StopBits = ONESTOPBIT; + SetCommState(hCom, &serialParams); - - serialParams.DCBlength = sizeof(serialParams); - if(baudRate == 9600) { - serialParams.BaudRate = CBR_9600; - } - if(baudRate == 115200) { - serialParams.BaudRate = CBR_115200; - } - else { - serialParams.BaudRate = baudRate; - } - - serialParams.ByteSize = 8; - serialParams.Parity = NOPARITY; - serialParams.StopBits = ONESTOPBIT; - SetCommState(hCom, &serialParams); - - COMMTIMEOUTS timeout = { 0 }; - // This will set the read operation to be blocking until data is received - // and then read continuously until there is a gap of one millisecond. - timeout.ReadIntervalTimeout = 1; - timeout.ReadTotalTimeoutConstant = 0; - timeout.ReadTotalTimeoutMultiplier = 0; - timeout.WriteTotalTimeoutConstant = 0; - timeout.WriteTotalTimeoutMultiplier = 0; - SetCommTimeouts(hCom, &timeout); - // Serial port should now be read for operations. + COMMTIMEOUTS timeout = {0}; + // This will set the read operation to be blocking until data is received + // and then read continuously until there is a gap of one millisecond. + timeout.ReadIntervalTimeout = 1; + timeout.ReadTotalTimeoutConstant = 0; + timeout.ReadTotalTimeoutMultiplier = 0; + timeout.WriteTotalTimeoutConstant = 0; + timeout.WriteTotalTimeoutMultiplier = 0; + SetCommTimeouts(hCom, &timeout); + // Serial port should now be read for operations. #endif } ArduinoComIF::~ArduinoComIF() { #ifdef LINUX - ::close(serialPort); + ::close(serialPort); #elif WIN32 - CloseHandle(hCom); + CloseHandle(hCom); #endif } -ReturnValue_t ArduinoComIF::initializeInterface(CookieIF * cookie) { - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t ArduinoComIF::initializeInterface(CookieIF *cookie) { + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t ArduinoComIF::sendMessage(CookieIF *cookie, const uint8_t *data, - size_t len) { - ArduinoCookie *arduinoCookie = dynamic_cast(cookie); - if (arduinoCookie == nullptr) { - return INVALID_COOKIE_TYPE; - } +ReturnValue_t ArduinoComIF::sendMessage(CookieIF *cookie, const uint8_t *data, size_t len) { + ArduinoCookie *arduinoCookie = dynamic_cast(cookie); + if (arduinoCookie == nullptr) { + return INVALID_COOKIE_TYPE; + } - return sendMessage(arduinoCookie->command, arduinoCookie->address, data, - len); + return sendMessage(arduinoCookie->command, arduinoCookie->address, data, len); } -ReturnValue_t ArduinoComIF::getSendSuccess(CookieIF *cookie) { - return RETURN_OK; +ReturnValue_t ArduinoComIF::getSendSuccess(CookieIF *cookie) { return RETURN_OK; } + +ReturnValue_t ArduinoComIF::requestReceiveMessage(CookieIF *cookie, size_t requestLen) { + return RETURN_OK; } -ReturnValue_t ArduinoComIF::requestReceiveMessage(CookieIF *cookie, - size_t requestLen) { - return RETURN_OK; +ReturnValue_t ArduinoComIF::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, size_t *size) { + handleSerialPortRx(); + + ArduinoCookie *arduinoCookie = dynamic_cast(cookie); + if (arduinoCookie == nullptr) { + return INVALID_COOKIE_TYPE; + } + + *buffer = arduinoCookie->replyBuffer.data(); + *size = arduinoCookie->receivedDataLen; + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t ArduinoComIF::readReceivedMessage(CookieIF *cookie, - uint8_t **buffer, size_t *size) { +ReturnValue_t ArduinoComIF::sendMessage(uint8_t command, uint8_t address, const uint8_t *data, + size_t dataLen) { + if (dataLen > UINT16_MAX) { + return TOO_MUCH_DATA; + } - handleSerialPortRx(); + // being conservative here + uint8_t sendBuffer[(dataLen + 6) * 2 + 2]; - ArduinoCookie *arduinoCookie = dynamic_cast(cookie); - if (arduinoCookie == nullptr) { - return INVALID_COOKIE_TYPE; - } + sendBuffer[0] = DleEncoder::STX_CHAR; - *buffer = arduinoCookie->replyBuffer.data(); - *size = arduinoCookie->receivedDataLen; - return HasReturnvaluesIF::RETURN_OK; -} + uint8_t *currentPosition = sendBuffer + 1; + size_t remainingLen = sizeof(sendBuffer) - 1; + size_t encodedLen = 0; -ReturnValue_t ArduinoComIF::sendMessage(uint8_t command, - uint8_t address, const uint8_t *data, size_t dataLen) { - if (dataLen > UINT16_MAX) { - return TOO_MUCH_DATA; - } + ReturnValue_t result = + DleEncoder::encode(&command, 1, currentPosition, remainingLen, &encodedLen, false); + if (result != RETURN_OK) { + return result; + } + currentPosition += encodedLen; + remainingLen -= encodedLen; // DleEncoder will never return encodedLen > remainingLen - //being conservative here - uint8_t sendBuffer[(dataLen + 6) * 2 + 2]; + result = DleEncoder::encode(&address, 1, currentPosition, remainingLen, &encodedLen, false); + if (result != RETURN_OK) { + return result; + } + currentPosition += encodedLen; + remainingLen -= encodedLen; // DleEncoder will never return encodedLen > remainingLen - sendBuffer[0] = DleEncoder::STX_CHAR; + uint8_t temporaryBuffer[2]; - uint8_t *currentPosition = sendBuffer + 1; - size_t remainingLen = sizeof(sendBuffer) - 1; - size_t encodedLen = 0; + // note to Lukas: yes we _could_ use Serialize here, but for 16 bit it is a bit too much... + temporaryBuffer[0] = dataLen >> 8; // we checked dataLen above + temporaryBuffer[1] = dataLen; - ReturnValue_t result = DleEncoder::encode(&command, 1, currentPosition, - remainingLen, &encodedLen, false); - if (result != RETURN_OK) { - return result; - } - currentPosition += encodedLen; - remainingLen -= encodedLen; //DleEncoder will never return encodedLen > remainingLen + result = + DleEncoder::encode(temporaryBuffer, 2, currentPosition, remainingLen, &encodedLen, false); + if (result != RETURN_OK) { + return result; + } + currentPosition += encodedLen; + remainingLen -= encodedLen; // DleEncoder will never return encodedLen > remainingLen - result = DleEncoder::encode(&address, 1, currentPosition, remainingLen, - &encodedLen, false); - if (result != RETURN_OK) { - return result; - } - currentPosition += encodedLen; - remainingLen -= encodedLen; //DleEncoder will never return encodedLen > remainingLen + // encoding the actual data + result = DleEncoder::encode(data, dataLen, currentPosition, remainingLen, &encodedLen, false); + if (result != RETURN_OK) { + return result; + } + currentPosition += encodedLen; + remainingLen -= encodedLen; // DleEncoder will never return encodedLen > remainingLen - uint8_t temporaryBuffer[2]; + uint16_t crc = CRC::crc16ccitt(&command, 1); + crc = CRC::crc16ccitt(&address, 1, crc); + // fortunately the length is still there + crc = CRC::crc16ccitt(temporaryBuffer, 2, crc); + crc = CRC::crc16ccitt(data, dataLen, crc); - //note to Lukas: yes we _could_ use Serialize here, but for 16 bit it is a bit too much... - temporaryBuffer[0] = dataLen >> 8; //we checked dataLen above - temporaryBuffer[1] = dataLen; + temporaryBuffer[0] = crc >> 8; + temporaryBuffer[1] = crc; - result = DleEncoder::encode(temporaryBuffer, 2, currentPosition, - remainingLen, &encodedLen, false); - if (result != RETURN_OK) { - return result; - } - currentPosition += encodedLen; - remainingLen -= encodedLen; //DleEncoder will never return encodedLen > remainingLen + result = + DleEncoder::encode(temporaryBuffer, 2, currentPosition, remainingLen, &encodedLen, false); + if (result != RETURN_OK) { + return result; + } + currentPosition += encodedLen; + remainingLen -= encodedLen; // DleEncoder will never return encodedLen > remainingLen - //encoding the actual data - result = DleEncoder::encode(data, dataLen, currentPosition, remainingLen, - &encodedLen, false); - if (result != RETURN_OK) { - return result; - } - currentPosition += encodedLen; - remainingLen -= encodedLen; //DleEncoder will never return encodedLen > remainingLen + if (remainingLen > 0) { + *currentPosition = DleEncoder::ETX_CHAR; + } + remainingLen -= 1; - uint16_t crc = CRC::crc16ccitt(&command, 1); - crc = CRC::crc16ccitt(&address, 1, crc); - //fortunately the length is still there - crc = CRC::crc16ccitt(temporaryBuffer, 2, crc); - crc = CRC::crc16ccitt(data, dataLen, crc); - - temporaryBuffer[0] = crc >> 8; - temporaryBuffer[1] = crc; - - result = DleEncoder::encode(temporaryBuffer, 2, currentPosition, - remainingLen, &encodedLen, false); - if (result != RETURN_OK) { - return result; - } - currentPosition += encodedLen; - remainingLen -= encodedLen; //DleEncoder will never return encodedLen > remainingLen - - if (remainingLen > 0) { - *currentPosition = DleEncoder::ETX_CHAR; - } - remainingLen -= 1; - - encodedLen = sizeof(sendBuffer) - remainingLen; + encodedLen = sizeof(sendBuffer) - remainingLen; #ifdef LINUX - ssize_t writtenlen = ::write(serialPort, sendBuffer, encodedLen); - if (writtenlen < 0) { - //we could try to find out what happened... - return RETURN_FAILED; - } - if (writtenlen != encodedLen) { - //the OS failed us, we do not try to block until everything is written, as - //we can not block the whole system here - return RETURN_FAILED; - } - return RETURN_OK; + ssize_t writtenlen = ::write(serialPort, sendBuffer, encodedLen); + if (writtenlen < 0) { + // we could try to find out what happened... + return RETURN_FAILED; + } + if (writtenlen != encodedLen) { + // the OS failed us, we do not try to block until everything is written, as + // we can not block the whole system here + return RETURN_FAILED; + } + return RETURN_OK; #elif WIN32 - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; #endif } void ArduinoComIF::handleSerialPortRx() { #ifdef LINUX - uint32_t availableSpace = rxBuffer.availableWriteSpace(); + uint32_t availableSpace = rxBuffer.availableWriteSpace(); - uint8_t dataFromSerial[availableSpace]; + uint8_t dataFromSerial[availableSpace]; - ssize_t bytesRead = read(serialPort, dataFromSerial, - sizeof(dataFromSerial)); + ssize_t bytesRead = read(serialPort, dataFromSerial, sizeof(dataFromSerial)); - if (bytesRead < 0) { - return; - } + if (bytesRead < 0) { + return; + } - rxBuffer.writeData(dataFromSerial, bytesRead); + rxBuffer.writeData(dataFromSerial, bytesRead); - uint8_t dataReceivedSoFar[rxBuffer.getMaxSize()]; + uint8_t dataReceivedSoFar[rxBuffer.getMaxSize()]; - uint32_t dataLenReceivedSoFar = 0; + uint32_t dataLenReceivedSoFar = 0; - rxBuffer.readData(dataReceivedSoFar, sizeof(dataReceivedSoFar), true, - &dataLenReceivedSoFar); + rxBuffer.readData(dataReceivedSoFar, sizeof(dataReceivedSoFar), true, &dataLenReceivedSoFar); - //look for STX - size_t firstSTXinRawData = 0; - while ((firstSTXinRawData < dataLenReceivedSoFar) - && (dataReceivedSoFar[firstSTXinRawData] != DleEncoder::STX_CHAR)) { - firstSTXinRawData++; - } + // look for STX + size_t firstSTXinRawData = 0; + while ((firstSTXinRawData < dataLenReceivedSoFar) && + (dataReceivedSoFar[firstSTXinRawData] != DleEncoder::STX_CHAR)) { + firstSTXinRawData++; + } - if (dataReceivedSoFar[firstSTXinRawData] != DleEncoder::STX_CHAR) { - //there is no STX in our data, throw it away... - rxBuffer.deleteData(dataLenReceivedSoFar); - return; - } + if (dataReceivedSoFar[firstSTXinRawData] != DleEncoder::STX_CHAR) { + // there is no STX in our data, throw it away... + rxBuffer.deleteData(dataLenReceivedSoFar); + return; + } - uint8_t packet[MAX_PACKET_SIZE]; - size_t packetLen = 0; + uint8_t packet[MAX_PACKET_SIZE]; + size_t packetLen = 0; - size_t readSize = 0; + size_t readSize = 0; - ReturnValue_t result = DleEncoder::decode( - dataReceivedSoFar + firstSTXinRawData, - dataLenReceivedSoFar - firstSTXinRawData, &readSize, packet, - sizeof(packet), &packetLen); + ReturnValue_t result = DleEncoder::decode(dataReceivedSoFar + firstSTXinRawData, + dataLenReceivedSoFar - firstSTXinRawData, &readSize, + packet, sizeof(packet), &packetLen); - size_t toDelete = firstSTXinRawData; - if (result == HasReturnvaluesIF::RETURN_OK) { - handlePacket(packet, packetLen); + size_t toDelete = firstSTXinRawData; + if (result == HasReturnvaluesIF::RETURN_OK) { + handlePacket(packet, packetLen); - // after handling the packet, we can delete it from the raw stream, - // it has been copied to packet - toDelete += readSize; - } + // after handling the packet, we can delete it from the raw stream, + // it has been copied to packet + toDelete += readSize; + } - //remove Data which was processed - rxBuffer.deleteData(toDelete); + // remove Data which was processed + rxBuffer.deleteData(toDelete); #elif WIN32 #endif } -void ArduinoComIF::setBaudrate(uint32_t baudRate) { - this->baudRate = baudRate; -} +void ArduinoComIF::setBaudrate(uint32_t baudRate) { this->baudRate = baudRate; } void ArduinoComIF::handlePacket(uint8_t *packet, size_t packetLen) { - uint16_t crc = CRC::crc16ccitt(packet, packetLen); - if (crc != 0) { - //CRC error - return; - } + uint16_t crc = CRC::crc16ccitt(packet, packetLen); + if (crc != 0) { + // CRC error + return; + } - uint8_t command = packet[0]; - uint8_t address = packet[1]; + uint8_t command = packet[0]; + uint8_t address = packet[1]; - uint16_t size = (packet[2] << 8) + packet[3]; + uint16_t size = (packet[2] << 8) + packet[3]; - if (size != packetLen - 6) { - //Invalid Length - return; - } + if (size != packetLen - 6) { + // Invalid Length + return; + } - switch (command) { - case ArduinoCookie::SPI: { - //ArduinoCookie **itsComplicated; - auto findIter = spiMap.find(address); - if (findIter == spiMap.end()) { - //we do no know this address - return; - } - ArduinoCookie& cookie = findIter->second; - if (packetLen > cookie.maxReplySize + 6) { - packetLen = cookie.maxReplySize + 6; - } - std::memcpy(cookie.replyBuffer.data(), packet + 4, packetLen - 6); - cookie.receivedDataLen = packetLen - 6; - } - break; - default: - return; - } + switch (command) { + case ArduinoCookie::SPI: { + // ArduinoCookie **itsComplicated; + auto findIter = spiMap.find(address); + if (findIter == spiMap.end()) { + // we do no know this address + return; + } + ArduinoCookie &cookie = findIter->second; + if (packetLen > cookie.maxReplySize + 6) { + packetLen = cookie.maxReplySize + 6; + } + std::memcpy(cookie.replyBuffer.data(), packet + 4, packetLen - 6); + cookie.receivedDataLen = packetLen - 6; + } break; + default: + return; + } } diff --git a/bsp_hosted/comIF/ArduinoComIF.h b/bsp_hosted/comIF/ArduinoComIF.h index 84bd959d..8476b6b5 100644 --- a/bsp_hosted/comIF/ArduinoComIF.h +++ b/bsp_hosted/comIF/ArduinoComIF.h @@ -4,8 +4,8 @@ #include #include #include -#include #include +#include #include #include @@ -14,56 +14,53 @@ #include #endif -//Forward declaration, so users don't peek +// Forward declaration, so users don't peek class ArduinoCookie; -class ArduinoComIF: public SystemObject, - public DeviceCommunicationIF { -public: - static const uint8_t MAX_NUMBER_OF_SPI_DEVICES = 8; - static const uint8_t MAX_PACKET_SIZE = 64; +class ArduinoComIF : public SystemObject, public DeviceCommunicationIF { + public: + static const uint8_t MAX_NUMBER_OF_SPI_DEVICES = 8; + static const uint8_t MAX_PACKET_SIZE = 64; - static const uint8_t COMMAND_INVALID = -1; - static const uint8_t COMMAND_SPI = 1; + static const uint8_t COMMAND_INVALID = -1; + static const uint8_t COMMAND_SPI = 1; - ArduinoComIF(object_id_t setObjectId, bool promptComIF = false, - const char *serialDevice = nullptr); - void setBaudrate(uint32_t baudRate); + ArduinoComIF(object_id_t setObjectId, bool promptComIF = false, + const char *serialDevice = nullptr); + void setBaudrate(uint32_t baudRate); - virtual ~ArduinoComIF(); + virtual ~ArduinoComIF(); - /** DeviceCommunicationIF overrides */ - virtual ReturnValue_t initializeInterface(CookieIF * cookie) override; - virtual ReturnValue_t sendMessage(CookieIF *cookie, - const uint8_t * sendData, size_t sendLen) override; - virtual ReturnValue_t getSendSuccess(CookieIF *cookie) override; - virtual ReturnValue_t requestReceiveMessage(CookieIF *cookie, - size_t requestLen) override; - virtual ReturnValue_t readReceivedMessage(CookieIF *cookie, - uint8_t **buffer, size_t *size) override; + /** DeviceCommunicationIF overrides */ + virtual ReturnValue_t initializeInterface(CookieIF *cookie) override; + virtual ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t *sendData, + size_t sendLen) override; + virtual ReturnValue_t getSendSuccess(CookieIF *cookie) override; + virtual ReturnValue_t requestReceiveMessage(CookieIF *cookie, size_t requestLen) override; + virtual ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer, + size_t *size) override; -private: + private: #ifdef LINUX #elif WIN32 - HANDLE hCom = INVALID_HANDLE_VALUE; + HANDLE hCom = INVALID_HANDLE_VALUE; #endif - // remembering if the initialization in the ctor worked - // if not, all calls are disabled - bool initialized = false; - int serialPort = 0; - // Default baud rate is 9600 for now. - uint32_t baudRate = 9600; + // remembering if the initialization in the ctor worked + // if not, all calls are disabled + bool initialized = false; + int serialPort = 0; + // Default baud rate is 9600 for now. + uint32_t baudRate = 9600; - //used to know where to put the data if a reply is received - std::map spiMap; + // used to know where to put the data if a reply is received + std::map spiMap; - SimpleRingBuffer rxBuffer; + SimpleRingBuffer rxBuffer; - ReturnValue_t sendMessage(uint8_t command, uint8_t address, - const uint8_t *data, size_t dataLen); - void handleSerialPortRx(); + ReturnValue_t sendMessage(uint8_t command, uint8_t address, const uint8_t *data, size_t dataLen); + void handleSerialPortRx(); - void handlePacket(uint8_t *packet, size_t packetLen); + void handlePacket(uint8_t *packet, size_t packetLen); }; #endif /* MISSION_ARDUINOCOMMINTERFACE_H_ */ diff --git a/bsp_hosted/comIF/ArduinoCookie.cpp b/bsp_hosted/comIF/ArduinoCookie.cpp index bc698720..89cb1568 100644 --- a/bsp_hosted/comIF/ArduinoCookie.cpp +++ b/bsp_hosted/comIF/ArduinoCookie.cpp @@ -1,8 +1,8 @@ #include -ArduinoCookie::ArduinoCookie(Protocol_t protocol, uint8_t address, - const size_t maxReplySize) : - protocol(protocol), command(protocol), address(address), - maxReplySize(maxReplySize), replyBuffer(maxReplySize) { -} - +ArduinoCookie::ArduinoCookie(Protocol_t protocol, uint8_t address, const size_t maxReplySize) + : protocol(protocol), + command(protocol), + address(address), + maxReplySize(maxReplySize), + replyBuffer(maxReplySize) {} diff --git a/bsp_hosted/comIF/ArduinoCookie.h b/bsp_hosted/comIF/ArduinoCookie.h index a5f91f64..04d4bd83 100644 --- a/bsp_hosted/comIF/ArduinoCookie.h +++ b/bsp_hosted/comIF/ArduinoCookie.h @@ -2,26 +2,21 @@ #define MISSION_ARDUINO_ARDUINOCOOKIE_H_ #include + #include -class ArduinoCookie: public CookieIF { -public: - enum Protocol_t: uint8_t { - INVALID, - SPI, - I2C - }; +class ArduinoCookie : public CookieIF { + public: + enum Protocol_t : uint8_t { INVALID, SPI, I2C }; - ArduinoCookie(Protocol_t protocol, uint8_t address, - const size_t maxReplySize); - - Protocol_t protocol; - uint8_t command; - uint8_t address; - std::vector replyBuffer; - size_t receivedDataLen = 0; - size_t maxReplySize; + ArduinoCookie(Protocol_t protocol, uint8_t address, const size_t maxReplySize); + Protocol_t protocol; + uint8_t command; + uint8_t address; + std::vector replyBuffer; + size_t receivedDataLen = 0; + size_t maxReplySize; }; #endif /* MISSION_ARDUINO_ARDUINOCOOKIE_H_ */ diff --git a/bsp_hosted/fsfwconfig/devices/gpioIds.h b/bsp_hosted/fsfwconfig/devices/gpioIds.h index a4b4ac81..1ede0571 100644 --- a/bsp_hosted/fsfwconfig/devices/gpioIds.h +++ b/bsp_hosted/fsfwconfig/devices/gpioIds.h @@ -2,56 +2,53 @@ #define FSFWCONFIG_DEVICES_GPIOIDS_H_ namespace gpioIds { - enum gpioId_t { - HEATER_0, - HEATER_1, - HEATER_2, - HEATER_3, - HEATER_4, - HEATER_5, - HEATER_6, - HEATER_7, - DEPLSA1, - DEPLSA2, +enum gpioId_t { + HEATER_0, + HEATER_1, + HEATER_2, + HEATER_3, + HEATER_4, + HEATER_5, + HEATER_6, + HEATER_7, + DEPLSA1, + DEPLSA2, - MGM_0_LIS3_CS, - MGM_1_RM3100_CS, - GYRO_0_ADIS_CS, - GYRO_1_L3G_CS, - GYRO_2_L3G_CS, - MGM_2_LIS3_CS, - MGM_3_RM3100_CS, + MGM_0_LIS3_CS, + MGM_1_RM3100_CS, + GYRO_0_ADIS_CS, + GYRO_1_L3G_CS, + GYRO_2_L3G_CS, + MGM_2_LIS3_CS, + MGM_3_RM3100_CS, - TEST_ID_0, - TEST_ID_1, + TEST_ID_0, + TEST_ID_1, - RTD_IC_3, - RTD_IC_4, - RTD_IC_5, - RTD_IC_6, - RTD_IC_7, - RTD_IC_8, - RTD_IC_9, - RTD_IC_10, - RTD_IC_11, - RTD_IC_12, - RTD_IC_13, - RTD_IC_14, - RTD_IC_15, - RTD_IC_16, - RTD_IC_17, - RTD_IC_18, + RTD_IC_3, + RTD_IC_4, + RTD_IC_5, + RTD_IC_6, + RTD_IC_7, + RTD_IC_8, + RTD_IC_9, + RTD_IC_10, + RTD_IC_11, + RTD_IC_12, + RTD_IC_13, + RTD_IC_14, + RTD_IC_15, + RTD_IC_16, + RTD_IC_17, + RTD_IC_18, - SPI_MUX_BIT_1, - SPI_MUX_BIT_2, - SPI_MUX_BIT_3, - SPI_MUX_BIT_4, - SPI_MUX_BIT_5, - SPI_MUX_BIT_6 - }; + SPI_MUX_BIT_1, + SPI_MUX_BIT_2, + SPI_MUX_BIT_3, + SPI_MUX_BIT_4, + SPI_MUX_BIT_5, + SPI_MUX_BIT_6 +}; } - - - #endif /* FSFWCONFIG_DEVICES_GPIOIDS_H_ */ diff --git a/bsp_hosted/fsfwconfig/devices/powerSwitcherList.h b/bsp_hosted/fsfwconfig/devices/powerSwitcherList.h index c216c828..ae259374 100644 --- a/bsp_hosted/fsfwconfig/devices/powerSwitcherList.h +++ b/bsp_hosted/fsfwconfig/devices/powerSwitcherList.h @@ -4,55 +4,54 @@ #include namespace pcduSwitches { - /* Switches are uint8_t datatype and go from 0 to 255 */ - enum SwitcherList { - Q7S, - PAYLOAD_PCDU_CH1, - RW, - TCS_BOARD_8V_HEATER_IN, - SUS_REDUNDANT, - DEPLOYMENT_MECHANISM, - PAYLOAD_PCDU_CH6, - ACS_BOARD_SIDE_B, - PAYLOAD_CAMERA, - TCS_BOARD_3V3, - SYRLINKS, - STAR_TRACKER, - MGT, - SUS_NOMINAL, - SOLAR_CELL_EXP, - PLOC, - ACS_BOARD_SIDE_A, - NUMBER_OF_SWITCHES - }; +/* Switches are uint8_t datatype and go from 0 to 255 */ +enum SwitcherList { + Q7S, + PAYLOAD_PCDU_CH1, + RW, + TCS_BOARD_8V_HEATER_IN, + SUS_REDUNDANT, + DEPLOYMENT_MECHANISM, + PAYLOAD_PCDU_CH6, + ACS_BOARD_SIDE_B, + PAYLOAD_CAMERA, + TCS_BOARD_3V3, + SYRLINKS, + STAR_TRACKER, + MGT, + SUS_NOMINAL, + SOLAR_CELL_EXP, + PLOC, + ACS_BOARD_SIDE_A, + NUMBER_OF_SWITCHES +}; - static const uint8_t ON = 1; - static const uint8_t OFF = 0; +static const uint8_t ON = 1; +static const uint8_t OFF = 0; - /* Output states after reboot of the PDUs */ - static const uint8_t INIT_STATE_Q7S = ON; - static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH1 = OFF; - static const uint8_t INIT_STATE_RW = OFF; +/* Output states after reboot of the PDUs */ +static const uint8_t INIT_STATE_Q7S = ON; +static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH1 = OFF; +static const uint8_t INIT_STATE_RW = OFF; #if BOARD_TE0720 == 1 - /* Because the TE0720 is not connected to the PCDU, this switch is always on */ - static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = ON; +/* Because the TE0720 is not connected to the PCDU, this switch is always on */ +static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = ON; #else - static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = OFF; +static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = OFF; #endif - static const uint8_t INIT_STATE_SUS_REDUNDANT = OFF; - static const uint8_t INIT_STATE_DEPLOYMENT_MECHANISM = OFF; - static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH6 = OFF; - static const uint8_t INIT_STATE_ACS_BOARD_SIDE_B = OFF; - static const uint8_t INIT_STATE_PAYLOAD_CAMERA = OFF; - static const uint8_t INIT_STATE_TCS_BOARD_3V3 = OFF; - static const uint8_t INIT_STATE_SYRLINKS = OFF; - static const uint8_t INIT_STATE_STAR_TRACKER = OFF; - static const uint8_t INIT_STATE_MGT = OFF; - static const uint8_t INIT_STATE_SUS_NOMINAL = OFF; - static const uint8_t INIT_STATE_SOLAR_CELL_EXP = OFF; - static const uint8_t INIT_STATE_PLOC = OFF; - static const uint8_t INIT_STATE_ACS_BOARD_SIDE_A = OFF; -} - +static const uint8_t INIT_STATE_SUS_REDUNDANT = OFF; +static const uint8_t INIT_STATE_DEPLOYMENT_MECHANISM = OFF; +static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH6 = OFF; +static const uint8_t INIT_STATE_ACS_BOARD_SIDE_B = OFF; +static const uint8_t INIT_STATE_PAYLOAD_CAMERA = OFF; +static const uint8_t INIT_STATE_TCS_BOARD_3V3 = OFF; +static const uint8_t INIT_STATE_SYRLINKS = OFF; +static const uint8_t INIT_STATE_STAR_TRACKER = OFF; +static const uint8_t INIT_STATE_MGT = OFF; +static const uint8_t INIT_STATE_SUS_NOMINAL = OFF; +static const uint8_t INIT_STATE_SOLAR_CELL_EXP = OFF; +static const uint8_t INIT_STATE_PLOC = OFF; +static const uint8_t INIT_STATE_ACS_BOARD_SIDE_A = OFF; +} // namespace pcduSwitches #endif /* FSFWCONFIG_DEVICES_POWERSWITCHERLIST_H_ */ diff --git a/bsp_hosted/fsfwconfig/events/subsystemIdRanges.h b/bsp_hosted/fsfwconfig/events/subsystemIdRanges.h index 7335a804..9dc50c50 100644 --- a/bsp_hosted/fsfwconfig/events/subsystemIdRanges.h +++ b/bsp_hosted/fsfwconfig/events/subsystemIdRanges.h @@ -2,6 +2,7 @@ #define CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ #include + #include /** @@ -9,9 +10,7 @@ * Numbers 0-80 are reserved for FSFW Subsystem IDs (framework/events/) */ namespace SUBSYSTEM_ID { -enum: uint8_t { - SUBSYSTEM_ID_START = COMMON_SUBSYSTEM_ID_END -}; +enum : uint8_t { SUBSYSTEM_ID_START = COMMON_SUBSYSTEM_ID_END }; } #endif /* CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ */ diff --git a/bsp_hosted/fsfwconfig/events/translateEvents.cpp b/bsp_hosted/fsfwconfig/events/translateEvents.cpp index 7b9ce4b5..fb9e1bf4 100644 --- a/bsp_hosted/fsfwconfig/events/translateEvents.cpp +++ b/bsp_hosted/fsfwconfig/events/translateEvents.cpp @@ -89,176 +89,176 @@ const char *ACK_FAILURE_STRING = "ACK_FAILURE"; const char *EXE_FAILURE_STRING = "EXE_FAILURE"; const char *CRC_FAILURE_EVENT_STRING = "CRC_FAILURE_EVENT"; -const char * translateEvents(Event event) { - switch( (event & 0xffff) ) { - case(2200): - return STORE_SEND_WRITE_FAILED_STRING; - case(2201): - return STORE_WRITE_FAILED_STRING; - case(2202): - return STORE_SEND_READ_FAILED_STRING; - case(2203): - return STORE_READ_FAILED_STRING; - case(2204): - return UNEXPECTED_MSG_STRING; - case(2205): - return STORING_FAILED_STRING; - case(2206): - return TM_DUMP_FAILED_STRING; - case(2207): - return STORE_INIT_FAILED_STRING; - case(2208): - return STORE_INIT_EMPTY_STRING; - case(2209): - return STORE_CONTENT_CORRUPTED_STRING; - case(2210): - return STORE_INITIALIZE_STRING; - case(2211): - return INIT_DONE_STRING; - case(2212): - return DUMP_FINISHED_STRING; - case(2213): - return DELETION_FINISHED_STRING; - case(2214): - return DELETION_FAILED_STRING; - case(2215): - return AUTO_CATALOGS_SENDING_FAILED_STRING; - case(2600): - return GET_DATA_FAILED_STRING; - case(2601): - return STORE_DATA_FAILED_STRING; - case(2800): - return DEVICE_BUILDING_COMMAND_FAILED_STRING; - case(2801): - return DEVICE_SENDING_COMMAND_FAILED_STRING; - case(2802): - return DEVICE_REQUESTING_REPLY_FAILED_STRING; - case(2803): - return DEVICE_READING_REPLY_FAILED_STRING; - case(2804): - return DEVICE_INTERPRETING_REPLY_FAILED_STRING; - case(2805): - return DEVICE_MISSED_REPLY_STRING; - case(2806): - return DEVICE_UNKNOWN_REPLY_STRING; - case(2807): - return DEVICE_UNREQUESTED_REPLY_STRING; - case(2808): - return INVALID_DEVICE_COMMAND_STRING; - case(2809): - return MONITORING_LIMIT_EXCEEDED_STRING; - case(2810): - return MONITORING_AMBIGUOUS_STRING; - case(4201): - return FUSE_CURRENT_HIGH_STRING; - case(4202): - return FUSE_WENT_OFF_STRING; - case(4204): - return POWER_ABOVE_HIGH_LIMIT_STRING; - case(4205): - return POWER_BELOW_LOW_LIMIT_STRING; - case(4300): - return SWITCH_WENT_OFF_STRING; - case(5000): - return HEATER_ON_STRING; - case(5001): - return HEATER_OFF_STRING; - case(5002): - return HEATER_TIMEOUT_STRING; - case(5003): - return HEATER_STAYED_ON_STRING; - case(5004): - return HEATER_STAYED_OFF_STRING; - case(5200): - return TEMP_SENSOR_HIGH_STRING; - case(5201): - return TEMP_SENSOR_LOW_STRING; - case(5202): - return TEMP_SENSOR_GRADIENT_STRING; - case(5901): - return COMPONENT_TEMP_LOW_STRING; - case(5902): - return COMPONENT_TEMP_HIGH_STRING; - case(5903): - return COMPONENT_TEMP_OOL_LOW_STRING; - case(5904): - return COMPONENT_TEMP_OOL_HIGH_STRING; - case(5905): - return TEMP_NOT_IN_OP_RANGE_STRING; - case(7101): - return FDIR_CHANGED_STATE_STRING; - case(7102): - return FDIR_STARTS_RECOVERY_STRING; - case(7103): - return FDIR_TURNS_OFF_DEVICE_STRING; - case(7201): - return MONITOR_CHANGED_STATE_STRING; - case(7202): - return VALUE_BELOW_LOW_LIMIT_STRING; - case(7203): - return VALUE_ABOVE_HIGH_LIMIT_STRING; - case(7204): - return VALUE_OUT_OF_RANGE_STRING; - case(7301): - return SWITCHING_TM_FAILED_STRING; - case(7400): - return CHANGING_MODE_STRING; - case(7401): - return MODE_INFO_STRING; - case(7402): - return FALLBACK_FAILED_STRING; - case(7403): - return MODE_TRANSITION_FAILED_STRING; - case(7404): - return CANT_KEEP_MODE_STRING; - case(7405): - return OBJECT_IN_INVALID_MODE_STRING; - case(7406): - return FORCING_MODE_STRING; - case(7407): - return MODE_CMD_REJECTED_STRING; - case(7506): - return HEALTH_INFO_STRING; - case(7507): - return CHILD_CHANGED_HEALTH_STRING; - case(7508): - return CHILD_PROBLEMS_STRING; - case(7509): - return OVERWRITING_HEALTH_STRING; - case(7510): - return TRYING_RECOVERY_STRING; - case(7511): - return RECOVERY_STEP_STRING; - case(7512): - return RECOVERY_DONE_STRING; - case(7900): - return RF_AVAILABLE_STRING; - case(7901): - return RF_LOST_STRING; - case(7902): - return BIT_LOCK_STRING; - case(7903): - return BIT_LOCK_LOST_STRING; - case(7905): - return FRAME_PROCESSING_FAILED_STRING; - case(8900): - return CLOCK_SET_STRING; - case(8901): - return CLOCK_SET_FAILURE_STRING; - case(9700): - return TEST_STRING; - case(10600): - return CHANGE_OF_SETUP_PARAMETER_STRING; - case(11101): - return MEMORY_READ_RPT_CRC_FAILURE_STRING; - case(11102): - return ACK_FAILURE_STRING; - case(11103): - return EXE_FAILURE_STRING; - case(11104): - return CRC_FAILURE_EVENT_STRING; - default: - return "UNKNOWN_EVENT"; - } - return 0; +const char *translateEvents(Event event) { + switch ((event & 0xffff)) { + case (2200): + return STORE_SEND_WRITE_FAILED_STRING; + case (2201): + return STORE_WRITE_FAILED_STRING; + case (2202): + return STORE_SEND_READ_FAILED_STRING; + case (2203): + return STORE_READ_FAILED_STRING; + case (2204): + return UNEXPECTED_MSG_STRING; + case (2205): + return STORING_FAILED_STRING; + case (2206): + return TM_DUMP_FAILED_STRING; + case (2207): + return STORE_INIT_FAILED_STRING; + case (2208): + return STORE_INIT_EMPTY_STRING; + case (2209): + return STORE_CONTENT_CORRUPTED_STRING; + case (2210): + return STORE_INITIALIZE_STRING; + case (2211): + return INIT_DONE_STRING; + case (2212): + return DUMP_FINISHED_STRING; + case (2213): + return DELETION_FINISHED_STRING; + case (2214): + return DELETION_FAILED_STRING; + case (2215): + return AUTO_CATALOGS_SENDING_FAILED_STRING; + case (2600): + return GET_DATA_FAILED_STRING; + case (2601): + return STORE_DATA_FAILED_STRING; + case (2800): + return DEVICE_BUILDING_COMMAND_FAILED_STRING; + case (2801): + return DEVICE_SENDING_COMMAND_FAILED_STRING; + case (2802): + return DEVICE_REQUESTING_REPLY_FAILED_STRING; + case (2803): + return DEVICE_READING_REPLY_FAILED_STRING; + case (2804): + return DEVICE_INTERPRETING_REPLY_FAILED_STRING; + case (2805): + return DEVICE_MISSED_REPLY_STRING; + case (2806): + return DEVICE_UNKNOWN_REPLY_STRING; + case (2807): + return DEVICE_UNREQUESTED_REPLY_STRING; + case (2808): + return INVALID_DEVICE_COMMAND_STRING; + case (2809): + return MONITORING_LIMIT_EXCEEDED_STRING; + case (2810): + return MONITORING_AMBIGUOUS_STRING; + case (4201): + return FUSE_CURRENT_HIGH_STRING; + case (4202): + return FUSE_WENT_OFF_STRING; + case (4204): + return POWER_ABOVE_HIGH_LIMIT_STRING; + case (4205): + return POWER_BELOW_LOW_LIMIT_STRING; + case (4300): + return SWITCH_WENT_OFF_STRING; + case (5000): + return HEATER_ON_STRING; + case (5001): + return HEATER_OFF_STRING; + case (5002): + return HEATER_TIMEOUT_STRING; + case (5003): + return HEATER_STAYED_ON_STRING; + case (5004): + return HEATER_STAYED_OFF_STRING; + case (5200): + return TEMP_SENSOR_HIGH_STRING; + case (5201): + return TEMP_SENSOR_LOW_STRING; + case (5202): + return TEMP_SENSOR_GRADIENT_STRING; + case (5901): + return COMPONENT_TEMP_LOW_STRING; + case (5902): + return COMPONENT_TEMP_HIGH_STRING; + case (5903): + return COMPONENT_TEMP_OOL_LOW_STRING; + case (5904): + return COMPONENT_TEMP_OOL_HIGH_STRING; + case (5905): + return TEMP_NOT_IN_OP_RANGE_STRING; + case (7101): + return FDIR_CHANGED_STATE_STRING; + case (7102): + return FDIR_STARTS_RECOVERY_STRING; + case (7103): + return FDIR_TURNS_OFF_DEVICE_STRING; + case (7201): + return MONITOR_CHANGED_STATE_STRING; + case (7202): + return VALUE_BELOW_LOW_LIMIT_STRING; + case (7203): + return VALUE_ABOVE_HIGH_LIMIT_STRING; + case (7204): + return VALUE_OUT_OF_RANGE_STRING; + case (7301): + return SWITCHING_TM_FAILED_STRING; + case (7400): + return CHANGING_MODE_STRING; + case (7401): + return MODE_INFO_STRING; + case (7402): + return FALLBACK_FAILED_STRING; + case (7403): + return MODE_TRANSITION_FAILED_STRING; + case (7404): + return CANT_KEEP_MODE_STRING; + case (7405): + return OBJECT_IN_INVALID_MODE_STRING; + case (7406): + return FORCING_MODE_STRING; + case (7407): + return MODE_CMD_REJECTED_STRING; + case (7506): + return HEALTH_INFO_STRING; + case (7507): + return CHILD_CHANGED_HEALTH_STRING; + case (7508): + return CHILD_PROBLEMS_STRING; + case (7509): + return OVERWRITING_HEALTH_STRING; + case (7510): + return TRYING_RECOVERY_STRING; + case (7511): + return RECOVERY_STEP_STRING; + case (7512): + return RECOVERY_DONE_STRING; + case (7900): + return RF_AVAILABLE_STRING; + case (7901): + return RF_LOST_STRING; + case (7902): + return BIT_LOCK_STRING; + case (7903): + return BIT_LOCK_LOST_STRING; + case (7905): + return FRAME_PROCESSING_FAILED_STRING; + case (8900): + return CLOCK_SET_STRING; + case (8901): + return CLOCK_SET_FAILURE_STRING; + case (9700): + return TEST_STRING; + case (10600): + return CHANGE_OF_SETUP_PARAMETER_STRING; + case (11101): + return MEMORY_READ_RPT_CRC_FAILURE_STRING; + case (11102): + return ACK_FAILURE_STRING; + case (11103): + return EXE_FAILURE_STRING; + case (11104): + return CRC_FAILURE_EVENT_STRING; + default: + return "UNKNOWN_EVENT"; + } + return 0; } diff --git a/bsp_hosted/fsfwconfig/events/translateEvents.h b/bsp_hosted/fsfwconfig/events/translateEvents.h index 9034dcf2..a42d9b5a 100644 --- a/bsp_hosted/fsfwconfig/events/translateEvents.h +++ b/bsp_hosted/fsfwconfig/events/translateEvents.h @@ -3,6 +3,6 @@ #include -const char * translateEvents(Event event); +const char* translateEvents(Event event); #endif /* FSFWCONFIG_EVENTS_TRANSLATEEVENTS_H_ */ diff --git a/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.cpp b/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.cpp index 36ef1b73..fa1c4877 100644 --- a/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.cpp +++ b/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.cpp @@ -1,11 +1,10 @@ #include "MissionMessageTypes.h" + #include void messagetypes::clearMissionMessage(CommandMessage* message) { - switch(message->getMessageType()) { - default: - break; - } + switch (message->getMessageType()) { + default: + break; + } } - - diff --git a/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.h b/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.h index 7e3c448f..1d93ba21 100644 --- a/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.h +++ b/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.h @@ -13,10 +13,10 @@ class CommandMessage; */ namespace messagetypes { enum MESSAGE_TYPE { - MISSION_MESSAGE_TYPE_START = FW_MESSAGES_COUNT, + MISSION_MESSAGE_TYPE_START = FW_MESSAGES_COUNT, }; void clearMissionMessage(CommandMessage* message); -} +} // namespace messagetypes #endif /* CONFIG_IPC_MISSIONMESSAGETYPES_H_ */ diff --git a/bsp_hosted/fsfwconfig/objects/systemObjectList.h b/bsp_hosted/fsfwconfig/objects/systemObjectList.h index 21a5f939..91bd2bed 100644 --- a/bsp_hosted/fsfwconfig/objects/systemObjectList.h +++ b/bsp_hosted/fsfwconfig/objects/systemObjectList.h @@ -1,31 +1,32 @@ #ifndef HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ #define HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ -#include #include +#include + // The objects will be instantiated in the ID order namespace objects { - enum sourceObjects: uint32_t { +enum sourceObjects : uint32_t { - PUS_SERVICE_3 = 0x51000300, - PUS_SERVICE_5 = 0x51000400, - PUS_SERVICE_6 = 0x51000500, - PUS_SERVICE_8 = 0x51000800, - PUS_SERVICE_23 = 0x51002300, - PUS_SERVICE_201 = 0x51020100, + PUS_SERVICE_3 = 0x51000300, + PUS_SERVICE_5 = 0x51000400, + PUS_SERVICE_6 = 0x51000500, + PUS_SERVICE_8 = 0x51000800, + PUS_SERVICE_23 = 0x51002300, + PUS_SERVICE_201 = 0x51020100, - TM_FUNNEL = 0x52000002, + TM_FUNNEL = 0x52000002, - /* Test Task */ + /* Test Task */ - TEST_TASK = 0x42694269, - DUMMY_INTERFACE = 0xCAFECAFE, - DUMMY_HANDLER = 0x4400AFFE, + TEST_TASK = 0x42694269, + DUMMY_INTERFACE = 0xCAFECAFE, + DUMMY_HANDLER = 0x4400AFFE, - /* 0x49 ('I') for Communication Interfaces **/ - ARDUINO_COM_IF = 0x49000001 - }; + /* 0x49 ('I') for Communication Interfaces **/ + ARDUINO_COM_IF = 0x49000001 +}; } #endif /* BSP_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ */ diff --git a/bsp_hosted/fsfwconfig/objects/translateObjects.cpp b/bsp_hosted/fsfwconfig/objects/translateObjects.cpp index 9aac2b47..f29e4d65 100644 --- a/bsp_hosted/fsfwconfig/objects/translateObjects.cpp +++ b/bsp_hosted/fsfwconfig/objects/translateObjects.cpp @@ -1,4 +1,4 @@ -/** +/** * @brief Auto-generated object translation file. * @details * Contains 31 translations. @@ -38,72 +38,72 @@ const char *FSFW_OBJECTS_END_STRING = "FSFW_OBJECTS_END"; const char *DUMMY_INTERFACE_STRING = "DUMMY_INTERFACE"; const char *NO_OBJECT_STRING = "NO_OBJECT"; -const char* translateObject(object_id_t object) { - switch( (object & 0xFFFFFFFF) ) { - case 0x42694269: - return TEST_TASK_STRING; - case 0x4400AFFE: - return DUMMY_HANDLER_STRING; - case 0x49000001: - return ARDUINO_COM_IF_STRING; - case 0x51000300: - return PUS_SERVICE_3_STRING; - case 0x51000400: - return PUS_SERVICE_5_STRING; - case 0x51000500: - return PUS_SERVICE_6_STRING; - case 0x51000800: - return PUS_SERVICE_8_STRING; - case 0x51002300: - return PUS_SERVICE_23_STRING; - case 0x51020100: - return PUS_SERVICE_201_STRING; - case 0x52000002: - return TM_FUNNEL_STRING; - case 0x53000000: - return FSFW_OBJECTS_START_STRING; - case 0x53000001: - return PUS_SERVICE_1_VERIFICATION_STRING; - case 0x53000002: - return PUS_SERVICE_2_DEVICE_ACCESS_STRING; - case 0x53000003: - return PUS_SERVICE_3_HOUSEKEEPING_STRING; - case 0x53000005: - return PUS_SERVICE_5_EVENT_REPORTING_STRING; - case 0x53000008: - return PUS_SERVICE_8_FUNCTION_MGMT_STRING; - case 0x53000009: - return PUS_SERVICE_9_TIME_MGMT_STRING; - case 0x53000017: - return PUS_SERVICE_17_TEST_STRING; - case 0x53000020: - return PUS_SERVICE_20_PARAMETERS_STRING; - case 0x53000200: - return PUS_SERVICE_200_MODE_MGMT_STRING; - case 0x53010000: - return HEALTH_TABLE_STRING; - case 0x53010100: - return MODE_STORE_STRING; - case 0x53030000: - return EVENT_MANAGER_STRING; - case 0x53040000: - return INTERNAL_ERROR_REPORTER_STRING; - case 0x534f0100: - return TC_STORE_STRING; - case 0x534f0200: - return TM_STORE_STRING; - case 0x534f0300: - return IPC_STORE_STRING; - case 0x53500010: - return TIME_STAMPER_STRING; - case 0x53ffffff: - return FSFW_OBJECTS_END_STRING; - case 0xCAFECAFE: - return DUMMY_INTERFACE_STRING; - case 0xFFFFFFFF: - return NO_OBJECT_STRING; - default: - return "UNKNOWN_OBJECT"; - } - return 0; +const char *translateObject(object_id_t object) { + switch ((object & 0xFFFFFFFF)) { + case 0x42694269: + return TEST_TASK_STRING; + case 0x4400AFFE: + return DUMMY_HANDLER_STRING; + case 0x49000001: + return ARDUINO_COM_IF_STRING; + case 0x51000300: + return PUS_SERVICE_3_STRING; + case 0x51000400: + return PUS_SERVICE_5_STRING; + case 0x51000500: + return PUS_SERVICE_6_STRING; + case 0x51000800: + return PUS_SERVICE_8_STRING; + case 0x51002300: + return PUS_SERVICE_23_STRING; + case 0x51020100: + return PUS_SERVICE_201_STRING; + case 0x52000002: + return TM_FUNNEL_STRING; + case 0x53000000: + return FSFW_OBJECTS_START_STRING; + case 0x53000001: + return PUS_SERVICE_1_VERIFICATION_STRING; + case 0x53000002: + return PUS_SERVICE_2_DEVICE_ACCESS_STRING; + case 0x53000003: + return PUS_SERVICE_3_HOUSEKEEPING_STRING; + case 0x53000005: + return PUS_SERVICE_5_EVENT_REPORTING_STRING; + case 0x53000008: + return PUS_SERVICE_8_FUNCTION_MGMT_STRING; + case 0x53000009: + return PUS_SERVICE_9_TIME_MGMT_STRING; + case 0x53000017: + return PUS_SERVICE_17_TEST_STRING; + case 0x53000020: + return PUS_SERVICE_20_PARAMETERS_STRING; + case 0x53000200: + return PUS_SERVICE_200_MODE_MGMT_STRING; + case 0x53010000: + return HEALTH_TABLE_STRING; + case 0x53010100: + return MODE_STORE_STRING; + case 0x53030000: + return EVENT_MANAGER_STRING; + case 0x53040000: + return INTERNAL_ERROR_REPORTER_STRING; + case 0x534f0100: + return TC_STORE_STRING; + case 0x534f0200: + return TM_STORE_STRING; + case 0x534f0300: + return IPC_STORE_STRING; + case 0x53500010: + return TIME_STAMPER_STRING; + case 0x53ffffff: + return FSFW_OBJECTS_END_STRING; + case 0xCAFECAFE: + return DUMMY_INTERFACE_STRING; + case 0xFFFFFFFF: + return NO_OBJECT_STRING; + default: + return "UNKNOWN_OBJECT"; + } + return 0; } diff --git a/bsp_hosted/fsfwconfig/returnvalues/classIds.h b/bsp_hosted/fsfwconfig/returnvalues/classIds.h index cc159fec..b50e8ac0 100644 --- a/bsp_hosted/fsfwconfig/returnvalues/classIds.h +++ b/bsp_hosted/fsfwconfig/returnvalues/classIds.h @@ -1,9 +1,10 @@ #ifndef CONFIG_RETURNVALUES_CLASSIDS_H_ #define CONFIG_RETURNVALUES_CLASSIDS_H_ -#include "commonClassIds.h" #include +#include "commonClassIds.h" + /** * Source IDs starts at 73 for now * Framework IDs for ReturnValues run from 0 to 56 @@ -11,9 +12,8 @@ */ namespace CLASS_ID { enum { - CLASS_ID_START = COMMON_CLASS_ID_END, + CLASS_ID_START = COMMON_CLASS_ID_END, }; } - #endif /* CONFIG_RETURNVALUES_CLASSIDS_H_ */ diff --git a/bsp_hosted/fsfwconfig/tmtc/apid.h b/bsp_hosted/fsfwconfig/tmtc/apid.h index ee2fc7c4..9d5c9ed5 100644 --- a/bsp_hosted/fsfwconfig/tmtc/apid.h +++ b/bsp_hosted/fsfwconfig/tmtc/apid.h @@ -12,8 +12,7 @@ * APID is a 11 bit number */ namespace apid { - static const uint16_t EIVE_OBSW = 0x65; +static const uint16_t EIVE_OBSW = 0x65; } - #endif /* FSFWCONFIG_TMTC_APID_H_ */ diff --git a/bsp_hosted/fsfwconfig/tmtc/pusIds.h b/bsp_hosted/fsfwconfig/tmtc/pusIds.h index a2dd7575..37503786 100644 --- a/bsp_hosted/fsfwconfig/tmtc/pusIds.h +++ b/bsp_hosted/fsfwconfig/tmtc/pusIds.h @@ -2,21 +2,21 @@ #define CONFIG_TMTC_PUSIDS_HPP_ namespace pus { -enum Ids{ - PUS_SERVICE_1 = 1, - PUS_SERVICE_2 = 2, - PUS_SERVICE_3 = 3, - PUS_SERVICE_3_PSB = 3, - PUS_SERVICE_5 = 5, - PUS_SERVICE_6 = 6, - PUS_SERVICE_8 = 8, - PUS_SERVICE_9 = 9, - PUS_SERVICE_17 = 17, - PUS_SERVICE_19 = 19, - PUS_SERVICE_20 = 20, - PUS_SERVICE_23 = 23, - PUS_SERVICE_200 = 200, - PUS_SERVICE_201 = 201, +enum Ids { + PUS_SERVICE_1 = 1, + PUS_SERVICE_2 = 2, + PUS_SERVICE_3 = 3, + PUS_SERVICE_3_PSB = 3, + PUS_SERVICE_5 = 5, + PUS_SERVICE_6 = 6, + PUS_SERVICE_8 = 8, + PUS_SERVICE_9 = 9, + PUS_SERVICE_17 = 17, + PUS_SERVICE_19 = 19, + PUS_SERVICE_20 = 20, + PUS_SERVICE_23 = 23, + PUS_SERVICE_200 = 200, + PUS_SERVICE_201 = 201, }; }; diff --git a/bsp_hosted/main.cpp b/bsp_hosted/main.cpp index 153cc447..b7ebc422 100644 --- a/bsp_hosted/main.cpp +++ b/bsp_hosted/main.cpp @@ -1,10 +1,9 @@ +#include + #include "InitMission.h" #include "OBSWVersion.h" - #include "fsfw/FSFWVersion.h" #include "fsfw/tasks/TaskFactory.h" - -#include #ifdef WIN32 static const char* COMPILE_PRINTOUT = "Windows"; #elif LINUX @@ -17,21 +16,18 @@ static const char* COMPILE_PRINTOUT = "unknown OS"; * Linux and Windows. * @return */ -int main(void) -{ - std::cout << "-- EIVE OBSW --" << std::endl; - std::cout << "-- Compiled for " << COMPILE_PRINTOUT << " --" << std::endl; - std::cout << "-- OBSW " << SW_NAME << " v" << SW_VERSION << "." << SW_SUBVERSION << - "." << SW_REVISION << ", FSFW v" << FSFW_VERSION << "." << FSFW_SUBVERSION << "." << - FSFW_REVISION << "--" << std::endl; - std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; +int main(void) { + std::cout << "-- EIVE OBSW --" << std::endl; + std::cout << "-- Compiled for " << COMPILE_PRINTOUT << " --" << std::endl; + std::cout << "-- OBSW " << SW_NAME << " v" << SW_VERSION << "." << SW_SUBVERSION << "." + << SW_REVISION << ", FSFW v" << FSFW_VERSION << "." << FSFW_SUBVERSION << "." + << FSFW_REVISION << "--" << std::endl; + std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; - initmission::initMission(); + initmission::initMission(); - for(;;) { - // suspend main thread by sleeping it. - TaskFactory::delayTask(5000); - } + for (;;) { + // suspend main thread by sleeping it. + TaskFactory::delayTask(5000); + } } - - diff --git a/bsp_linux_board/InitMission.cpp b/bsp_linux_board/InitMission.cpp index d265fded..86d5fb4b 100644 --- a/bsp_linux_board/InitMission.cpp +++ b/bsp_linux_board/InitMission.cpp @@ -1,247 +1,244 @@ #include "InitMission.h" -#include "ObjectFactory.h" -#include "objects/systemObjectList.h" -#include "OBSWConfig.h" -#include "pollingsequence/pollingSequenceFactory.h" - -#include +#include #include #include #include -#include #include #include #include +#include #include +#include "OBSWConfig.h" +#include "ObjectFactory.h" +#include "objects/systemObjectList.h" +#include "pollingsequence/pollingSequenceFactory.h" + ServiceInterfaceStream sif::debug("DEBUG"); ServiceInterfaceStream sif::info("INFO"); ServiceInterfaceStream sif::warning("WARNING"); ServiceInterfaceStream sif::error("ERROR"); -ObjectManagerIF *objectManager = nullptr; +ObjectManagerIF* objectManager = nullptr; void initmission::initMission() { - sif::info << "Building global objects.." << std::endl; - /* Instantiate global object manager and also create all objects */ - ObjectManager::instance()->setObjectFactoryFunction(ObjectFactory::produce, nullptr); - sif::info << "Initializing all objects.." << std::endl; - ObjectManager::instance()->initialize(); + sif::info << "Building global objects.." << std::endl; + /* Instantiate global object manager and also create all objects */ + ObjectManager::instance()->setObjectFactoryFunction(ObjectFactory::produce, nullptr); + sif::info << "Initializing all objects.." << std::endl; + ObjectManager::instance()->initialize(); - /* This function creates and starts all tasks */ - initTasks(); + /* This function creates and starts all tasks */ + initTasks(); } void initmission::initTasks() { - TaskFactory* factory = TaskFactory::instance(); - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - if(factory == nullptr) { - /* Should never happen ! */ - return; - } + TaskFactory* factory = TaskFactory::instance(); + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + if (factory == nullptr) { + /* Should never happen ! */ + return; + } #if OBSW_PRINT_MISSED_DEADLINES == 1 - void (*missedDeadlineFunc) (void) = TaskFactory::printMissedDeadline; + void (*missedDeadlineFunc)(void) = TaskFactory::printMissedDeadline; #else - void (*missedDeadlineFunc) (void) = nullptr; + void (*missedDeadlineFunc)(void) = nullptr; #endif + /* TMTC Distribution */ + PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask( + "DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + result = tmTcDistributor->addComponent(objects::CCSDS_PACKET_DISTRIBUTOR); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } + result = tmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } + result = tmTcDistributor->addComponent(objects::TM_FUNNEL); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } - /* TMTC Distribution */ - PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask( - "DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - result = tmTcDistributor->addComponent(objects::CCSDS_PACKET_DISTRIBUTOR); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } - result = tmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } - result = tmTcDistributor->addComponent(objects::TM_FUNNEL); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Object add component failed" << std::endl; - } + /* UDP bridge */ + PeriodicTaskIF* udpBridgeTask = factory->createPeriodicTask( + "UDP_UNIX_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + result = udpBridgeTask->addComponent(objects::TMTC_BRIDGE); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Add component UDP Unix Bridge failed" << std::endl; + } + PeriodicTaskIF* udpPollingTask = factory->createPeriodicTask( + "UDP_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = udpPollingTask->addComponent(objects::TMTC_POLLING_TASK); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Add component UDP Polling failed" << std::endl; + } - /* UDP bridge */ - PeriodicTaskIF* udpBridgeTask = factory->createPeriodicTask( - "UDP_UNIX_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - result = udpBridgeTask->addComponent(objects::TMTC_BRIDGE); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Add component UDP Unix Bridge failed" << std::endl; - } - PeriodicTaskIF* udpPollingTask = factory->createPeriodicTask( - "UDP_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); - result = udpPollingTask->addComponent(objects::TMTC_POLLING_TASK); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Add component UDP Polling failed" << std::endl; - } + /* PUS Services */ + std::vector pusTasks; + createPusTasks(*factory, missedDeadlineFunc, pusTasks); - /* PUS Services */ - std::vector pusTasks; - createPusTasks(*factory, missedDeadlineFunc, pusTasks); - - std::vector pstTasks; - createPstTasks(*factory, missedDeadlineFunc, pstTasks); + std::vector pstTasks; + createPstTasks(*factory, missedDeadlineFunc, pstTasks); #if OBSW_ADD_TEST_CODE == 1 - std::vector testTasks; - createTestTasks(*factory, missedDeadlineFunc, pstTasks); + std::vector testTasks; + createTestTasks(*factory, missedDeadlineFunc, pstTasks); #endif /* OBSW_ADD_TEST_CODE == 1 */ - auto taskStarter = [](std::vector& taskVector, std::string name) { - for(const auto& task: taskVector) { - if(task != nullptr) { - task->startTask(); - } - else { - sif::error << "Task in vector " << name << " is invalid!" << std::endl; - } - } - }; + auto taskStarter = [](std::vector& taskVector, std::string name) { + for (const auto& task : taskVector) { + if (task != nullptr) { + task->startTask(); + } else { + sif::error << "Task in vector " << name << " is invalid!" << std::endl; + } + } + }; - sif::info << "Starting tasks.." << std::endl; - tmTcDistributor->startTask(); - udpBridgeTask->startTask(); - udpPollingTask->startTask(); + sif::info << "Starting tasks.." << std::endl; + tmTcDistributor->startTask(); + udpBridgeTask->startTask(); + udpPollingTask->startTask(); - taskStarter(pusTasks, "PUS Tasks"); + taskStarter(pusTasks, "PUS Tasks"); #if OBSW_ADD_TEST_CODE == 1 - taskStarter(testTasks, "Test Tasks"); + taskStarter(testTasks, "Test Tasks"); #endif /* OBSW_ADD_TEST_CODE == 1 */ - taskStarter(pstTasks, "PST Tasks"); + taskStarter(pstTasks, "PST Tasks"); #if OBSW_ADD_TEST_PST == 1 - if(startTestPst) { - pstTestTask->startTask(); - } + if (startTestPst) { + pstTestTask->startTask(); + } #endif /* RPI_TEST_ACS_BOARD == 1 */ - sif::info << "Tasks started.." << std::endl; + sif::info << "Tasks started.." << std::endl; } void initmission::createPusTasks(TaskFactory& factory, - TaskDeadlineMissedFunction missedDeadlineFunc, std::vector& taskVec) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - PeriodicTaskIF* pusVerification = factory.createPeriodicTask( - "PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } - taskVec.push_back(pusVerification); + TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + PeriodicTaskIF* pusVerification = factory.createPeriodicTask( + "PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } + taskVec.push_back(pusVerification); - PeriodicTaskIF* pusEvents = factory.createPeriodicTask( - "PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusEvents->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_EVENTS", objects::PUS_SERVICE_5_EVENT_REPORTING); - } - result = pusEvents->addComponent(objects::EVENT_MANAGER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_MGMT", objects::EVENT_MANAGER); - } - taskVec.push_back(pusEvents); + PeriodicTaskIF* pusEvents = factory.createPeriodicTask( + "PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusEvents->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_EVENTS", objects::PUS_SERVICE_5_EVENT_REPORTING); + } + result = pusEvents->addComponent(objects::EVENT_MANAGER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_MGMT", objects::EVENT_MANAGER); + } + taskVec.push_back(pusEvents); - PeriodicTaskIF* pusHighPrio = factory.createPeriodicTask( - "PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS2", objects::PUS_SERVICE_2_DEVICE_ACCESS); - } - result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS9", objects::PUS_SERVICE_9_TIME_MGMT); - } - taskVec.push_back(pusHighPrio); + PeriodicTaskIF* pusHighPrio = factory.createPeriodicTask( + "PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS2", objects::PUS_SERVICE_2_DEVICE_ACCESS); + } + result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS9", objects::PUS_SERVICE_9_TIME_MGMT); + } + taskVec.push_back(pusHighPrio); - PeriodicTaskIF* pusMedPrio = factory.createPeriodicTask( - "PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); - result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS8", objects::PUS_SERVICE_8_FUNCTION_MGMT); - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS200", objects::PUS_SERVICE_200_MODE_MGMT); - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS20", objects::PUS_SERVICE_20_PARAMETERS); - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_3_HOUSEKEEPING); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS3", objects::PUS_SERVICE_3_HOUSEKEEPING); - } - taskVec.push_back(pusMedPrio); + PeriodicTaskIF* pusMedPrio = factory.createPeriodicTask( + "PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); + result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS8", objects::PUS_SERVICE_8_FUNCTION_MGMT); + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS200", objects::PUS_SERVICE_200_MODE_MGMT); + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS20", objects::PUS_SERVICE_20_PARAMETERS); + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_3_HOUSEKEEPING); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS3", objects::PUS_SERVICE_3_HOUSEKEEPING); + } + taskVec.push_back(pusMedPrio); - PeriodicTaskIF* pusLowPrio = factory.createPeriodicTask( - "PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc); - result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS17", objects::PUS_SERVICE_17_TEST); - } - result = pusLowPrio->addComponent(objects::INTERNAL_ERROR_REPORTER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("INT_ERR_RPRT", - objects::INTERNAL_ERROR_REPORTER); - } - taskVec.push_back(pusLowPrio); + PeriodicTaskIF* pusLowPrio = factory.createPeriodicTask( + "PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc); + result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS17", objects::PUS_SERVICE_17_TEST); + } + result = pusLowPrio->addComponent(objects::INTERNAL_ERROR_REPORTER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("INT_ERR_RPRT", objects::INTERNAL_ERROR_REPORTER); + } + taskVec.push_back(pusLowPrio); } void initmission::createPstTasks(TaskFactory& factory, - TaskDeadlineMissedFunction missedDeadlineFunc, std::vector &taskVec) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; #if OBSW_ADD_SPI_TEST_CODE == 0 - FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask( - "SPI_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 3.0, - missedDeadlineFunc); - result = pst::pstSpi(spiPst); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; - } - taskVec.push_back(spiPst); + FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask( + "SPI_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 3.0, missedDeadlineFunc); + result = pst::pstSpi(spiPst); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; + } + taskVec.push_back(spiPst); #endif } void initmission::createTestTasks(TaskFactory& factory, - TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector &taskVec) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - PeriodicTaskIF* testTask = factory.createPeriodicTask( - "TEST_TASK", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); - result = testTask->addComponent(objects::TEST_TASK); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK); - } + TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + PeriodicTaskIF* testTask = factory.createPeriodicTask( + "TEST_TASK", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = testTask->addComponent(objects::TEST_TASK); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK); + } #if RPI_ADD_SPI_TEST == 1 - result = testTask->addComponent(objects::SPI_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("SPI_TEST", objects::SPI_TEST); - } + result = testTask->addComponent(objects::SPI_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("SPI_TEST", objects::SPI_TEST); + } #endif /* RPI_ADD_SPI_TEST == 1 */ #if RPI_ADD_GPIO_TEST == 1 - result = testTask->addComponent(objects::LIBGPIOD_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("GPIOD_TEST", objects::LIBGPIOD_TEST); - } + result = testTask->addComponent(objects::LIBGPIOD_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("GPIOD_TEST", objects::LIBGPIOD_TEST); + } #endif /* RPI_ADD_GPIO_TEST == 1 */ #if RPI_ADD_UART_TEST == 1 - result = testTask->addComponent(objects::UART_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("UART_TEST", objects::UART_TEST); - } + result = testTask->addComponent(objects::UART_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("UART_TEST", objects::UART_TEST); + } #endif /* RPI_ADD_GPIO_TEST == 1 */ - bool startTestPst = true; - static_cast(startTestPst); + bool startTestPst = true; + static_cast(startTestPst); #if OBSW_ADD_TEST_PST == 1 - FixedTimeslotTaskIF* pstTestTask = factory->createFixedTimeslotTask("TEST_PST", 50, - PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 2.0, missedDeadlineFunc); - result = pst::pstTest(pstTestTask); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::info << "initmission::initTasks: ACS PST empty or invalid" << std::endl; - startTestPst = false; - } + FixedTimeslotTaskIF* pstTestTask = factory->createFixedTimeslotTask( + "TEST_PST", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 2.0, missedDeadlineFunc); + result = pst::pstTest(pstTestTask); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::info << "initmission::initTasks: ACS PST empty or invalid" << std::endl; + startTestPst = false; + } #endif /* RPI_TEST_ACS_BOARD == 1 */ - } diff --git a/bsp_linux_board/InitMission.h b/bsp_linux_board/InitMission.h index f5da5855..f14135dd 100644 --- a/bsp_linux_board/InitMission.h +++ b/bsp_linux_board/InitMission.h @@ -1,9 +1,10 @@ #ifndef BSP_LINUX_INITMISSION_H_ #define BSP_LINUX_INITMISSION_H_ -#include "fsfw/tasks/Typedef.h" #include +#include "fsfw/tasks/Typedef.h" + class PeriodicTaskIF; class TaskFactory; @@ -11,14 +12,12 @@ namespace initmission { void initMission(); void initTasks(); -void createPstTasks(TaskFactory& factory, - TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector &taskVec); -void createTestTasks(TaskFactory& factory, - TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector &taskVec); +void createPstTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec); +void createTestTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec); void createPusTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector& taskVec); -}; + std::vector& taskVec); +}; // namespace initmission #endif /* BSP_LINUX_INITMISSION_H_ */ diff --git a/bsp_linux_board/ObjectFactory.cpp b/bsp_linux_board/ObjectFactory.cpp index bb86ecce..71966164 100644 --- a/bsp_linux_board/ObjectFactory.cpp +++ b/bsp_linux_board/ObjectFactory.cpp @@ -1,236 +1,241 @@ -#include #include "ObjectFactory.h" -#include "objects/systemObjectList.h" +#include +#include + +#include "OBSWConfig.h" #include "devices/addresses.h" #include "devices/gpioIds.h" -#include "OBSWConfig.h" -#include "tmtc/apid.h" -#include "tmtc/pusIds.h" +#include "fsfw/datapoollocal/LocalDataPoolManager.h" +#include "fsfw/tasks/TaskFactory.h" +#include "fsfw/tmtcpacket/pus/tm.h" +#include "fsfw/tmtcservices/CommandingServiceBase.h" +#include "fsfw/tmtcservices/PusServiceBase.h" #include "linux/boardtest/LibgpiodTest.h" #include "linux/boardtest/SpiTestClass.h" #include "linux/boardtest/UartTestClass.h" - #include "mission/core/GenericFactory.h" -#include "mission/utility/TmFunnel.h" -#include #include "mission/devices/GyroADIS1650XHandler.h" - -#include "fsfw/datapoollocal/LocalDataPoolManager.h" -#include "fsfw/tmtcservices/CommandingServiceBase.h" -#include "fsfw/tmtcservices/PusServiceBase.h" -#include "fsfw/tmtcpacket/pus/tm.h" -#include "fsfw/tasks/TaskFactory.h" +#include "mission/utility/TmFunnel.h" +#include "objects/systemObjectList.h" +#include "tmtc/apid.h" +#include "tmtc/pusIds.h" /* UDP server includes */ #if OBSW_USE_TMTC_TCP_BRIDGE == 1 #include #include #else -#include "fsfw/osal/common/UdpTmTcBridge.h" #include "fsfw/osal/common/UdpTcPollingTask.h" +#include "fsfw/osal/common/UdpTmTcBridge.h" #endif -#include "fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h" -#include "fsfw_hal/devicehandlers/MgmRM3100Handler.h" -#include "fsfw_hal/devicehandlers/GyroL3GD20Handler.h" -#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" -#include "fsfw_hal/linux/rpi/GpioRPi.h" -#include "fsfw_hal/common/gpio/GpioCookie.h" -#include "fsfw_hal/linux/spi/SpiCookie.h" -#include "fsfw_hal/linux/spi/SpiComIF.h" #include #include +#include "fsfw_hal/common/gpio/GpioCookie.h" +#include "fsfw_hal/devicehandlers/GyroL3GD20Handler.h" +#include "fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h" +#include "fsfw_hal/devicehandlers/MgmRM3100Handler.h" +#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" +#include "fsfw_hal/linux/rpi/GpioRPi.h" +#include "fsfw_hal/linux/spi/SpiComIF.h" +#include "fsfw_hal/linux/spi/SpiCookie.h" + void Factory::setStaticFrameworkObjectIds() { - PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; - PusServiceBase::packetDestination = objects::TM_FUNNEL; + PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; + PusServiceBase::packetDestination = objects::TM_FUNNEL; - CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; - CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; + CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; + CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; - TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; - // No storage object for now. - TmFunnel::storageDestination = objects::NO_OBJECT; + TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; + // No storage object for now. + TmFunnel::storageDestination = objects::NO_OBJECT; - VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; - TmPacketBase::timeStamperId = objects::TIME_STAMPER; + VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; + TmPacketBase::timeStamperId = objects::TIME_STAMPER; } - - -void ObjectFactory::produce(void* args){ - Factory::setStaticFrameworkObjectIds(); - ObjectFactory::produceGenericObjects(); +void ObjectFactory::produce(void* args) { + Factory::setStaticFrameworkObjectIds(); + ObjectFactory::produceGenericObjects(); #if OBSW_USE_TMTC_TCP_BRIDGE == 1 - auto tmtcBridge = new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - tmtcBridge->setMaxNumberOfPacketsStored(50); - new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); + auto tmtcBridge = new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + tmtcBridge->setMaxNumberOfPacketsStored(50); + new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); #else - auto tmtcBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - tmtcBridge->setMaxNumberOfPacketsStored(50); - new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); + auto tmtcBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + tmtcBridge->setMaxNumberOfPacketsStored(50); + new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); #endif - GpioIF* gpioIF = new LinuxLibgpioIF(objects::GPIO_IF); - GpioCookie* gpioCookie = nullptr; - static_cast(gpioCookie); + GpioIF* gpioIF = new LinuxLibgpioIF(objects::GPIO_IF); + GpioCookie* gpioCookie = nullptr; + static_cast(gpioCookie); - new SpiComIF(objects::SPI_COM_IF, gpioIF); + new SpiComIF(objects::SPI_COM_IF, gpioIF); - std::string spiDev; - SpiCookie* spiCookie = nullptr; - static_cast(spiCookie); + std::string spiDev; + SpiCookie* spiCookie = nullptr; + static_cast(spiCookie); #if OBSW_ADD_ACS_BOARD == 1 - if(gpioCookie == nullptr) { - gpioCookie = new GpioCookie(); - } - // TODO: Missing pin for Gyro 2 - gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_0_LIS3_CS, gpio::MGM_0_BCM_PIN, - "MGM_0_LIS3", gpio::Direction::OUT, 1); - gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_1_RM3100_CS, gpio::MGM_1_BCM_PIN, - "MGM_1_RM3100", gpio::Direction::OUT, 1); - gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_2_LIS3_CS, gpio::MGM_2_BCM_PIN, - "MGM_2_LIS3", gpio::Direction::OUT, 1); - gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_3_RM3100_CS, gpio::MGM_3_BCM_PIN, - "MGM_3_RM3100", gpio::Direction::OUT, 1); - gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_0_ADIS_CS, gpio::GYRO_0_BCM_PIN, - "GYRO_0_ADIS", gpio::Direction::OUT, 1); - gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_1_L3G_CS, gpio::GYRO_1_BCM_PIN, - "GYRO_1_L3G", gpio::Direction::OUT, 1); - gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_2_ADIS_CS, gpio::GYRO_2_BCM_PIN, - "GYRO_2_ADIS", gpio::Direction::OUT, 1); - gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_3_L3G_CS, gpio::GYRO_3_BCM_PIN, - "GYRO_3_L3G", gpio::Direction::OUT, 1); - gpioIF->addGpios(gpioCookie); + if (gpioCookie == nullptr) { + gpioCookie = new GpioCookie(); + } + // TODO: Missing pin for Gyro 2 + gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_0_LIS3_CS, gpio::MGM_0_BCM_PIN, "MGM_0_LIS3", + gpio::Direction::OUT, 1); + gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_1_RM3100_CS, gpio::MGM_1_BCM_PIN, + "MGM_1_RM3100", gpio::Direction::OUT, 1); + gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_2_LIS3_CS, gpio::MGM_2_BCM_PIN, "MGM_2_LIS3", + gpio::Direction::OUT, 1); + gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_3_RM3100_CS, gpio::MGM_3_BCM_PIN, + "MGM_3_RM3100", gpio::Direction::OUT, 1); + gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_0_ADIS_CS, gpio::GYRO_0_BCM_PIN, + "GYRO_0_ADIS", gpio::Direction::OUT, 1); + gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_1_L3G_CS, gpio::GYRO_1_BCM_PIN, "GYRO_1_L3G", + gpio::Direction::OUT, 1); + gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_2_ADIS_CS, gpio::GYRO_2_BCM_PIN, + "GYRO_2_ADIS", gpio::Direction::OUT, 1); + gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_3_L3G_CS, gpio::GYRO_3_BCM_PIN, "GYRO_3_L3G", + gpio::Direction::OUT, 1); + gpioIF->addGpios(gpioCookie); - spiDev = "/dev/spidev0.1"; - spiCookie = new SpiCookie(addresses::MGM_0_LIS3, gpioIds::MGM_0_LIS3_CS, spiDev, - MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); - auto mgmLis3Handler = new MgmLIS3MDLHandler(objects::MGM_0_LIS3_HANDLER, - objects::SPI_COM_IF, spiCookie, 0); - mgmLis3Handler->setStartUpImmediately(); + spiDev = "/dev/spidev0.1"; + spiCookie = + new SpiCookie(addresses::MGM_0_LIS3, gpioIds::MGM_0_LIS3_CS, spiDev, + MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); + auto mgmLis3Handler = + new MgmLIS3MDLHandler(objects::MGM_0_LIS3_HANDLER, objects::SPI_COM_IF, spiCookie, 0); + mgmLis3Handler->setStartUpImmediately(); #if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1 - mgmLis3Handler->setToGoToNormalMode(true); + mgmLis3Handler->setToGoToNormalMode(true); #endif - spiCookie = new SpiCookie(addresses::MGM_1_RM3100, gpioIds::MGM_1_RM3100_CS, spiDev, - RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); - auto mgmRm3100Handler = new MgmRM3100Handler(objects::MGM_1_RM3100_HANDLER, - objects::SPI_COM_IF, spiCookie, 0); - mgmRm3100Handler->setStartUpImmediately(); + spiCookie = + new SpiCookie(addresses::MGM_1_RM3100, gpioIds::MGM_1_RM3100_CS, spiDev, + RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); + auto mgmRm3100Handler = + new MgmRM3100Handler(objects::MGM_1_RM3100_HANDLER, objects::SPI_COM_IF, spiCookie, 0); + mgmRm3100Handler->setStartUpImmediately(); #if FSFW_HAL_RM3100_MGM_DEBUG == 1 - mgmRm3100Handler->setToGoToNormalMode(true); + mgmRm3100Handler->setToGoToNormalMode(true); #endif - spiCookie = new SpiCookie(addresses::MGM_2_LIS3, gpioIds::MGM_2_LIS3_CS, spiDev, - MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); - mgmLis3Handler = new MgmLIS3MDLHandler(objects::MGM_2_LIS3_HANDLER, - objects::SPI_COM_IF, spiCookie, 0); - mgmLis3Handler->setStartUpImmediately(); + spiCookie = + new SpiCookie(addresses::MGM_2_LIS3, gpioIds::MGM_2_LIS3_CS, spiDev, + MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); + mgmLis3Handler = + new MgmLIS3MDLHandler(objects::MGM_2_LIS3_HANDLER, objects::SPI_COM_IF, spiCookie, 0); + mgmLis3Handler->setStartUpImmediately(); #if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1 - mgmLis3Handler->setToGoToNormalMode(true); + mgmLis3Handler->setToGoToNormalMode(true); #endif - spiCookie = new SpiCookie(addresses::MGM_3_RM3100, gpioIds::MGM_3_RM3100_CS, spiDev, - RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); - mgmRm3100Handler = new MgmRM3100Handler(objects::MGM_3_RM3100_HANDLER, - objects::SPI_COM_IF, spiCookie, 0); - mgmRm3100Handler->setStartUpImmediately(); + spiCookie = + new SpiCookie(addresses::MGM_3_RM3100, gpioIds::MGM_3_RM3100_CS, spiDev, + RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); + mgmRm3100Handler = + new MgmRM3100Handler(objects::MGM_3_RM3100_HANDLER, objects::SPI_COM_IF, spiCookie, 0); + mgmRm3100Handler->setStartUpImmediately(); #if FSFW_HAL_RM3100_MGM_DEBUG == 1 - mgmRm3100Handler->setToGoToNormalMode(true); + mgmRm3100Handler->setToGoToNormalMode(true); #endif - spiCookie = new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, spiDev, - ADIS16507::MAXIMUM_REPLY_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); - auto adisHandler = new GyroADIS16507Handler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, - spiCookie); - adisHandler->setStartUpImmediately(); - spiCookie = new SpiCookie(addresses::GYRO_1_L3G, gpioIds::GYRO_1_L3G_CS, spiDev, - L3GD20H::MAX_BUFFER_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); - auto gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_1_L3G_HANDLER, objects::SPI_COM_IF, - spiCookie, 0); - gyroL3gHandler->setStartUpImmediately(); -#if FSFW_HAL_L3GD20_GYRO_DEBUG== 1 - gyroL3gHandler->setToGoToNormalMode(true); + spiCookie = + new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, spiDev, + ADIS16507::MAXIMUM_REPLY_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); + auto adisHandler = + new GyroADIS16507Handler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, spiCookie); + adisHandler->setStartUpImmediately(); + spiCookie = + new SpiCookie(addresses::GYRO_1_L3G, gpioIds::GYRO_1_L3G_CS, spiDev, L3GD20H::MAX_BUFFER_SIZE, + spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); + auto gyroL3gHandler = + new GyroHandlerL3GD20H(objects::GYRO_1_L3G_HANDLER, objects::SPI_COM_IF, spiCookie, 0); + gyroL3gHandler->setStartUpImmediately(); +#if FSFW_HAL_L3GD20_GYRO_DEBUG == 1 + gyroL3gHandler->setToGoToNormalMode(true); #endif - spiCookie = new SpiCookie(addresses::GYRO_2_ADIS, gpioIds::GYRO_2_ADIS_CS, spiDev, - ADIS16507::MAXIMUM_REPLY_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); - adisHandler = new GyroADIS16507Handler(objects::GYRO_2_ADIS_HANDLER, objects::SPI_COM_IF, - spiCookie); - adisHandler->setStartUpImmediately(); + spiCookie = + new SpiCookie(addresses::GYRO_2_ADIS, gpioIds::GYRO_2_ADIS_CS, spiDev, + ADIS16507::MAXIMUM_REPLY_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); + adisHandler = + new GyroADIS16507Handler(objects::GYRO_2_ADIS_HANDLER, objects::SPI_COM_IF, spiCookie); + adisHandler->setStartUpImmediately(); - spiCookie = new SpiCookie(addresses::GYRO_3_L3G, gpioIds::GYRO_3_L3G_CS, spiDev, - L3GD20H::MAX_BUFFER_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); - gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_3_L3G_HANDLER, objects::SPI_COM_IF, - spiCookie, 0); - gyroL3gHandler->setStartUpImmediately(); -#if FSFW_HAL_L3GD20_GYRO_DEBUG== 1 - gyroL3gHandler->setToGoToNormalMode(true); + spiCookie = + new SpiCookie(addresses::GYRO_3_L3G, gpioIds::GYRO_3_L3G_CS, spiDev, L3GD20H::MAX_BUFFER_SIZE, + spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); + gyroL3gHandler = + new GyroHandlerL3GD20H(objects::GYRO_3_L3G_HANDLER, objects::SPI_COM_IF, spiCookie, 0); + gyroL3gHandler->setStartUpImmediately(); +#if FSFW_HAL_L3GD20_GYRO_DEBUG == 1 + gyroL3gHandler->setToGoToNormalMode(true); #endif #endif /* RPI_TEST_ACS_BOARD == 1 */ #if OBSW_ADD_TEST_CODE == 1 - createTestTasks(); + createTestTasks(); #endif /* OBSW_ADD_TEST_CODE == 1 */ } void ObjectFactory::createTestTasks() { - - new TestTask(objects::TEST_TASK); + new TestTask(objects::TEST_TASK); #if RPI_ADD_SPI_TEST == 1 - new SpiTestClass(objects::SPI_TEST, gpioIF); + new SpiTestClass(objects::SPI_TEST, gpioIF); #endif #if RPI_ADD_UART_TEST == 1 - new UartTestClass(objects::UART_TEST); + new UartTestClass(objects::UART_TEST); #else - new UartComIF(objects::UART_COM_IF); + new UartComIF(objects::UART_COM_IF); #endif #if RPI_LOOPBACK_TEST_GPIO == 1 - GpioCookie* gpioCookieLoopback = new GpioCookie(); - /* Loopback pins. Adapt according to setup */ - gpioId_t gpioIdSender = gpioIds::TEST_ID_0; - int bcmPinSender = 26; - gpioId_t gpioIdReader = gpioIds::TEST_ID_1; - int bcmPinReader = 16; - gpio::createRpiGpioConfig(gpioCookieLoopback, gpioIdSender, bcmPinSender, "GPIO_LB_SENDER", - gpio::Direction::OUT, 0); - gpio::createRpiGpioConfig(gpioCookieLoopback, gpioIdReader, bcmPinReader, "GPIO_LB_READER", - gpio::Direction::IN, 0); - new LibgpiodTest(objects::LIBGPIOD_TEST, objects::GPIO_IF, gpioCookieLoopback); + GpioCookie* gpioCookieLoopback = new GpioCookie(); + /* Loopback pins. Adapt according to setup */ + gpioId_t gpioIdSender = gpioIds::TEST_ID_0; + int bcmPinSender = 26; + gpioId_t gpioIdReader = gpioIds::TEST_ID_1; + int bcmPinReader = 16; + gpio::createRpiGpioConfig(gpioCookieLoopback, gpioIdSender, bcmPinSender, "GPIO_LB_SENDER", + gpio::Direction::OUT, 0); + gpio::createRpiGpioConfig(gpioCookieLoopback, gpioIdReader, bcmPinReader, "GPIO_LB_READER", + gpio::Direction::IN, 0); + new LibgpiodTest(objects::LIBGPIOD_TEST, objects::GPIO_IF, gpioCookieLoopback); #endif /* RPI_LOOPBACK_TEST_GPIO == 1 */ #if RPI_TEST_ADIS16507 == 1 - if(gpioCookie == nullptr) { - gpioCookie = new GpioCookie(); - } - gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_0_ADIS_CS, gpio::GYRO_0_BCM_PIN, - "GYRO_0_ADIS", gpio::Direction::OUT, 1); - gpioIF->addGpios(gpioCookie); + if (gpioCookie == nullptr) { + gpioCookie = new GpioCookie(); + } + gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_0_ADIS_CS, gpio::GYRO_0_BCM_PIN, + "GYRO_0_ADIS", gpio::Direction::OUT, 1); + gpioIF->addGpios(gpioCookie); - spiDev = "/dev/spidev0.1"; - spiCookie = new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, spiDev, - ADIS16507::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, spi::DEFAULT_ADIS16507_SPEED, - nullptr, nullptr); - auto adisGyroHandler = new GyroADIS16507Handler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, spiCookie); - adisGyroHandler->setStartUpImmediately(); + spiDev = "/dev/spidev0.1"; + spiCookie = new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, spiDev, + ADIS16507::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, + spi::DEFAULT_ADIS16507_SPEED, nullptr, nullptr); + auto adisGyroHandler = + new GyroADIS16507Handler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, spiCookie); + adisGyroHandler->setStartUpImmediately(); #endif /* RPI_TEST_ADIS16507 == 1 */ #if RPI_TEST_GPS_HANDLER == 1 - UartCookie* uartCookie = new UartCookie(objects::GPS0_HANDLER, "/dev/serial0", - UartModes::CANONICAL, 9600, 1024); - uartCookie->setToFlushInput(true); - uartCookie->setReadCycles(6); - GPSHyperionHandler* gpsHandler = new GPSHyperionHandler(objects::GPS0_HANDLER, - objects::UART_COM_IF, uartCookie, false); - gpsHandler->setStartUpImmediately(); + UartCookie* uartCookie = + new UartCookie(objects::GPS0_HANDLER, "/dev/serial0", UartModes::CANONICAL, 9600, 1024); + uartCookie->setToFlushInput(true); + uartCookie->setReadCycles(6); + GPSHyperionHandler* gpsHandler = + new GPSHyperionHandler(objects::GPS0_HANDLER, objects::UART_COM_IF, uartCookie, false); + gpsHandler->setStartUpImmediately(); #endif - } diff --git a/bsp_linux_board/ObjectFactory.h b/bsp_linux_board/ObjectFactory.h index 3b9aca49..909baf06 100644 --- a/bsp_linux_board/ObjectFactory.h +++ b/bsp_linux_board/ObjectFactory.h @@ -1,12 +1,11 @@ #ifndef BSP_LINUX_OBJECTFACTORY_H_ #define BSP_LINUX_OBJECTFACTORY_H_ - namespace ObjectFactory { - void setStatics(); - void produce(void* args); +void setStatics(); +void produce(void* args); - void createTestTasks(); -}; +void createTestTasks(); +}; // namespace ObjectFactory #endif /* BSP_LINUX_OBJECTFACTORY_H_ */ diff --git a/bsp_linux_board/boardconfig/etl_profile.h b/bsp_linux_board/boardconfig/etl_profile.h index c35ffb46..54aca344 100644 --- a/bsp_linux_board/boardconfig/etl_profile.h +++ b/bsp_linux_board/boardconfig/etl_profile.h @@ -32,7 +32,7 @@ SOFTWARE. #define ETL_CHECK_PUSH_POP -#define ETL_CPP11_SUPPORTED 1 -#define ETL_NO_NULLPTR_SUPPORT 0 +#define ETL_CPP11_SUPPORTED 1 +#define ETL_NO_NULLPTR_SUPPORT 0 #endif diff --git a/bsp_linux_board/boardconfig/gcov.h b/bsp_linux_board/boardconfig/gcov.h index 491d24c6..80acdd86 100644 --- a/bsp_linux_board/boardconfig/gcov.h +++ b/bsp_linux_board/boardconfig/gcov.h @@ -6,8 +6,9 @@ extern "C" void __gcov_flush(); #else void __gcov_flush() { - sif::info << "GCC GCOV: Please supply GCOV=1 in Makefile if " - "coverage information is desired.\n" << std::flush; + sif::info << "GCC GCOV: Please supply GCOV=1 in Makefile if " + "coverage information is desired.\n" + << std::flush; } #endif diff --git a/bsp_linux_board/boardconfig/print.c b/bsp_linux_board/boardconfig/print.c index c501e0b7..3aba2d73 100644 --- a/bsp_linux_board/boardconfig/print.c +++ b/bsp_linux_board/boardconfig/print.c @@ -2,13 +2,9 @@ #include void printChar(const char* character, bool errStream) { - if(errStream) { - putc(*character, stderr); - return; - } - putc(*character, stdout); + if (errStream) { + putc(*character, stderr); + return; + } + putc(*character, stdout); } - - - - diff --git a/bsp_linux_board/main.cpp b/bsp_linux_board/main.cpp index a766f2a0..4e286f5d 100644 --- a/bsp_linux_board/main.cpp +++ b/bsp_linux_board/main.cpp @@ -1,12 +1,11 @@ +#include + #include "InitMission.h" #include "OBSWConfig.h" #include "OBSWVersion.h" - #include "fsfw/FSFWVersion.h" #include "fsfw/tasks/TaskFactory.h" -#include - #ifdef RASPBERRY_PI static const char* const BOARD_NAME = "Raspberry Pi"; #elif defined(BEAGLEBONEBLACK) @@ -19,21 +18,18 @@ static const char* const BOARD_NAME = "Unknown Board"; * @brief This is the main program and entry point for the Raspberry Pi. * @return */ -int main(void) -{ - std::cout << "-- EIVE OBSW --" << std::endl; - std::cout << "-- Compiled for Linux board " << BOARD_NAME << " --" << std::endl; - std::cout << "-- OBSW " << SW_NAME << " v" << SW_VERSION << "." << SW_SUBVERSION << - "." << SW_REVISION << ", FSFW v" << FSFW_VERSION << "." << FSFW_SUBVERSION << - FSFW_REVISION << "--" << std::endl; - std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; +int main(void) { + std::cout << "-- EIVE OBSW --" << std::endl; + std::cout << "-- Compiled for Linux board " << BOARD_NAME << " --" << std::endl; + std::cout << "-- OBSW " << SW_NAME << " v" << SW_VERSION << "." << SW_SUBVERSION << "." + << SW_REVISION << ", FSFW v" << FSFW_VERSION << "." << FSFW_SUBVERSION << FSFW_REVISION + << "--" << std::endl; + std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; - initmission::initMission(); + initmission::initMission(); - for(;;) { - /* Suspend main thread by sleeping it. */ - TaskFactory::delayTask(5000); - } + for (;;) { + /* Suspend main thread by sleeping it. */ + TaskFactory::delayTask(5000); + } } - - diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index 34516fa6..e41ed093 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -19,58 +19,58 @@ static constexpr char UIO_PDEC_CONFIG_MEMORY[] = "/dev/uio2"; static constexpr char UIO_PDEC_RAM[] = "/dev/uio3"; namespace gpioNames { - static constexpr char GYRO_0_ADIS_CS[] = "gyro_0_adis_chip_select"; - static constexpr char GYRO_1_L3G_CS[] = "gyro_1_l3g_chip_select"; - static constexpr char GYRO_2_ADIS_CS[] = "gyro_2_adis_chip_select"; - static constexpr char GYRO_3_L3G_CS[] = "gyro_3_l3g_chip_select"; - static constexpr char MGM_0_CS[] = "mgm_0_lis3_chip_select"; - static constexpr char MGM_1_CS[] = "mgm_1_rm3100_chip_select"; - static constexpr char MGM_2_CS[] = "mgm_2_lis3_chip_select"; - static constexpr char MGM_3_CS[] = "mgm_3_rm3100_chip_select"; - static constexpr char RESET_GNSS_0[] = "reset_gnss_0"; - static constexpr char RESET_GNSS_1[] = "reset_gnss_1"; - static constexpr char GNSS_0_ENABLE[] = "enable_gnss_0"; - static constexpr char GNSS_1_ENABLE[] = "enable_gnss_1"; - static constexpr char GYRO_0_ENABLE[] = "enable_gyro_0"; - static constexpr char GYRO_2_ENABLE[] = "enable_gyro_2"; - static constexpr char HEATER_0[] = "heater0"; - static constexpr char HEATER_1[] = "heater1"; - static constexpr char HEATER_2[] = "heater2"; - static constexpr char HEATER_3[] = "heater3"; - static constexpr char HEATER_4[] = "heater4"; - static constexpr char HEATER_5[] = "heater5"; - static constexpr char HEATER_6[] = "heater6"; - static constexpr char HEATER_7[] = "heater7"; - static constexpr char SA_DPL_PIN_0[] = "sa_dpl_0"; - static constexpr char SA_DPL_PIN_1[] = "sa_dpl_1"; - static constexpr char SPI_MUX_BIT_1_PIN[] = "spi_mux_bit_1"; - static constexpr char SPI_MUX_BIT_2_PIN[] = "spi_mux_bit_2"; - static constexpr char SPI_MUX_BIT_3_PIN[] = "spi_mux_bit_3"; - static constexpr char SPI_MUX_BIT_4_PIN[] = "spi_mux_bit_4"; - static constexpr char SPI_MUX_BIT_5_PIN[] = "spi_mux_bit_5"; - static constexpr char SPI_MUX_BIT_6_PIN[] = "spi_mux_bit_6"; - static constexpr char EN_RW_CS[] = "en_rw_cs"; - static constexpr char EN_RW_1[] = "enable_rw_1"; - static constexpr char EN_RW_2[] = "enable_rw_2"; - static constexpr char EN_RW_3[] = "enable_rw_3"; - static constexpr char EN_RW_4[] = "enable_rw_4"; - static constexpr char GNSS_MUX_SELECT[] = "gnss_mux_select"; - static constexpr char RAD_SENSOR_CHIP_SELECT[] = "rad_sensor_chip_select"; - static constexpr char PAPB_BUSY_SIGNAL_VC0[] = "papb_busy_signal_vc0"; - static constexpr char PAPB_EMPTY_SIGNAL_VC0[] = "papb_empty_signal_vc0"; - static constexpr char PAPB_BUSY_SIGNAL_VC1[] = "papb_busy_signal_vc1"; - static constexpr char PAPB_EMPTY_SIGNAL_VC1[] = "papb_empty_signal_vc1"; - static constexpr char PAPB_BUSY_SIGNAL_VC2[] = "papb_busy_signal_vc2"; - static constexpr char PAPB_EMPTY_SIGNAL_VC2[] = "papb_empty_signal_vc2"; - static constexpr char PAPB_BUSY_SIGNAL_VC3[] = "papb_busy_signal_vc3"; - static constexpr char PAPB_EMPTY_SIGNAL_VC3[] = "papb_empty_signal_vc3"; - static constexpr char RS485_EN_TX_CLOCK[] = "tx_clock_enable_ltc2872"; - 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"; -} -} +static constexpr char GYRO_0_ADIS_CS[] = "gyro_0_adis_chip_select"; +static constexpr char GYRO_1_L3G_CS[] = "gyro_1_l3g_chip_select"; +static constexpr char GYRO_2_ADIS_CS[] = "gyro_2_adis_chip_select"; +static constexpr char GYRO_3_L3G_CS[] = "gyro_3_l3g_chip_select"; +static constexpr char MGM_0_CS[] = "mgm_0_lis3_chip_select"; +static constexpr char MGM_1_CS[] = "mgm_1_rm3100_chip_select"; +static constexpr char MGM_2_CS[] = "mgm_2_lis3_chip_select"; +static constexpr char MGM_3_CS[] = "mgm_3_rm3100_chip_select"; +static constexpr char RESET_GNSS_0[] = "reset_gnss_0"; +static constexpr char RESET_GNSS_1[] = "reset_gnss_1"; +static constexpr char GNSS_0_ENABLE[] = "enable_gnss_0"; +static constexpr char GNSS_1_ENABLE[] = "enable_gnss_1"; +static constexpr char GYRO_0_ENABLE[] = "enable_gyro_0"; +static constexpr char GYRO_2_ENABLE[] = "enable_gyro_2"; +static constexpr char HEATER_0[] = "heater0"; +static constexpr char HEATER_1[] = "heater1"; +static constexpr char HEATER_2[] = "heater2"; +static constexpr char HEATER_3[] = "heater3"; +static constexpr char HEATER_4[] = "heater4"; +static constexpr char HEATER_5[] = "heater5"; +static constexpr char HEATER_6[] = "heater6"; +static constexpr char HEATER_7[] = "heater7"; +static constexpr char SA_DPL_PIN_0[] = "sa_dpl_0"; +static constexpr char SA_DPL_PIN_1[] = "sa_dpl_1"; +static constexpr char SPI_MUX_BIT_1_PIN[] = "spi_mux_bit_1"; +static constexpr char SPI_MUX_BIT_2_PIN[] = "spi_mux_bit_2"; +static constexpr char SPI_MUX_BIT_3_PIN[] = "spi_mux_bit_3"; +static constexpr char SPI_MUX_BIT_4_PIN[] = "spi_mux_bit_4"; +static constexpr char SPI_MUX_BIT_5_PIN[] = "spi_mux_bit_5"; +static constexpr char SPI_MUX_BIT_6_PIN[] = "spi_mux_bit_6"; +static constexpr char EN_RW_CS[] = "en_rw_cs"; +static constexpr char EN_RW_1[] = "enable_rw_1"; +static constexpr char EN_RW_2[] = "enable_rw_2"; +static constexpr char EN_RW_3[] = "enable_rw_3"; +static constexpr char EN_RW_4[] = "enable_rw_4"; +static constexpr char GNSS_MUX_SELECT[] = "gnss_mux_select"; +static constexpr char RAD_SENSOR_CHIP_SELECT[] = "rad_sensor_chip_select"; +static constexpr char PAPB_BUSY_SIGNAL_VC0[] = "papb_busy_signal_vc0"; +static constexpr char PAPB_EMPTY_SIGNAL_VC0[] = "papb_empty_signal_vc0"; +static constexpr char PAPB_BUSY_SIGNAL_VC1[] = "papb_busy_signal_vc1"; +static constexpr char PAPB_EMPTY_SIGNAL_VC1[] = "papb_empty_signal_vc1"; +static constexpr char PAPB_BUSY_SIGNAL_VC2[] = "papb_busy_signal_vc2"; +static constexpr char PAPB_EMPTY_SIGNAL_VC2[] = "papb_empty_signal_vc2"; +static constexpr char PAPB_BUSY_SIGNAL_VC3[] = "papb_busy_signal_vc3"; +static constexpr char PAPB_EMPTY_SIGNAL_VC3[] = "papb_empty_signal_vc3"; +static constexpr char RS485_EN_TX_CLOCK[] = "tx_clock_enable_ltc2872"; +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 #endif /* BSP_Q7S_BOARDCONFIG_BUSCONF_H_ */ diff --git a/bsp_q7s/boardconfig/etl_profile.h b/bsp_q7s/boardconfig/etl_profile.h index c35ffb46..54aca344 100644 --- a/bsp_q7s/boardconfig/etl_profile.h +++ b/bsp_q7s/boardconfig/etl_profile.h @@ -32,7 +32,7 @@ SOFTWARE. #define ETL_CHECK_PUSH_POP -#define ETL_CPP11_SUPPORTED 1 -#define ETL_NO_NULLPTR_SUPPORT 0 +#define ETL_CPP11_SUPPORTED 1 +#define ETL_NO_NULLPTR_SUPPORT 0 #endif diff --git a/bsp_q7s/boardconfig/gcov.h b/bsp_q7s/boardconfig/gcov.h index 491d24c6..80acdd86 100644 --- a/bsp_q7s/boardconfig/gcov.h +++ b/bsp_q7s/boardconfig/gcov.h @@ -6,8 +6,9 @@ extern "C" void __gcov_flush(); #else void __gcov_flush() { - sif::info << "GCC GCOV: Please supply GCOV=1 in Makefile if " - "coverage information is desired.\n" << std::flush; + sif::info << "GCC GCOV: Please supply GCOV=1 in Makefile if " + "coverage information is desired.\n" + << std::flush; } #endif diff --git a/bsp_q7s/boardconfig/print.c b/bsp_q7s/boardconfig/print.c index c501e0b7..3aba2d73 100644 --- a/bsp_q7s/boardconfig/print.c +++ b/bsp_q7s/boardconfig/print.c @@ -2,13 +2,9 @@ #include void printChar(const char* character, bool errStream) { - if(errStream) { - putc(*character, stderr); - return; - } - putc(*character, stdout); + if (errStream) { + putc(*character, stderr); + return; + } + putc(*character, stdout); } - - - - diff --git a/bsp_q7s/boardtest/FileSystemTest.cpp b/bsp_q7s/boardtest/FileSystemTest.cpp index 92c4cf3d..e1dd564d 100644 --- a/bsp_q7s/boardtest/FileSystemTest.cpp +++ b/bsp_q7s/boardtest/FileSystemTest.cpp @@ -1,26 +1,23 @@ #include "FileSystemTest.h" + +#include +#include + #include "fsfw/timemanager/Stopwatch.h" -#include -#include - -enum SdCard { - SDC0, - SDC1 -}; +enum SdCard { SDC0, SDC1 }; FileSystemTest::FileSystemTest() { - using namespace std; - SdCard sdCard = SdCard::SDC0; - cout << "SD Card Test for SD card " << static_cast(sdCard) << std::endl; - //Stopwatch stopwatch; - std::system("q7hw sd info all > /tmp/sd_status.txt"); - //stopwatch.stop(true); - std::system("q7hw sd set 0 on > /tmp/sd_set.txt"); - //stopwatch.stop(true); - std::system("q7hw sd set 0 off > /tmp/sd_set.txt"); - //stopwatch.stop(true); + using namespace std; + SdCard sdCard = SdCard::SDC0; + cout << "SD Card Test for SD card " << static_cast(sdCard) << std::endl; + // Stopwatch stopwatch; + std::system("q7hw sd info all > /tmp/sd_status.txt"); + // stopwatch.stop(true); + std::system("q7hw sd set 0 on > /tmp/sd_set.txt"); + // stopwatch.stop(true); + std::system("q7hw sd set 0 off > /tmp/sd_set.txt"); + // stopwatch.stop(true); } -FileSystemTest::~FileSystemTest() { -} +FileSystemTest::~FileSystemTest() {} diff --git a/bsp_q7s/boardtest/FileSystemTest.h b/bsp_q7s/boardtest/FileSystemTest.h index 256a0b36..bdb7989f 100644 --- a/bsp_q7s/boardtest/FileSystemTest.h +++ b/bsp_q7s/boardtest/FileSystemTest.h @@ -2,12 +2,11 @@ #define BSP_Q7S_BOARDTEST_FILESYSTEMTEST_H_ class FileSystemTest { -public: - FileSystemTest(); - virtual~ FileSystemTest(); -private: + public: + FileSystemTest(); + virtual ~FileSystemTest(); + + private: }; - - #endif /* BSP_Q7S_BOARDTEST_FILESYSTEMTEST_H_ */ diff --git a/bsp_q7s/boardtest/Q7STestTask.cpp b/bsp_q7s/boardtest/Q7STestTask.cpp index dc87cd3b..5d9042ac 100644 --- a/bsp_q7s/boardtest/Q7STestTask.cpp +++ b/bsp_q7s/boardtest/Q7STestTask.cpp @@ -1,414 +1,397 @@ +#include "Q7STestTask.h" + #include #include #include -#include "Q7STestTask.h" - -#include "bsp_q7s/memory/SdCardManager.h" -#include "bsp_q7s/memory/scratchApi.h" - -#include "fsfw/timemanager/Stopwatch.h" -#include "fsfw/tasks/TaskFactory.h" - -#include "test/DummyParameter.h" - -#include #include #include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include -Q7STestTask::Q7STestTask(object_id_t objectId): TestTask(objectId) { - doTestSdCard = false; - doTestScratchApi = false; - doTestGps = false; +#include "bsp_q7s/memory/SdCardManager.h" +#include "bsp_q7s/memory/scratchApi.h" +#include "fsfw/tasks/TaskFactory.h" +#include "fsfw/timemanager/Stopwatch.h" +#include "test/DummyParameter.h" + +Q7STestTask::Q7STestTask(object_id_t objectId) : TestTask(objectId) { + doTestSdCard = false; + doTestScratchApi = false; + doTestGps = false; } ReturnValue_t Q7STestTask::performOneShotAction() { - if (doTestSdCard) { - testSdCard(); - } - if (doTestScratchApi) { - testScratchApi(); - } - //testJsonLibDirect(); - //testDummyParams(); - //testProtHandler(); - FsOpCodes opCode = FsOpCodes::APPEND_TO_FILE; - testFileSystemHandlerDirect(opCode); - return TestTask::performOneShotAction(); + if (doTestSdCard) { + testSdCard(); + } + if (doTestScratchApi) { + testScratchApi(); + } + // testJsonLibDirect(); + // testDummyParams(); + // testProtHandler(); + FsOpCodes opCode = FsOpCodes::APPEND_TO_FILE; + testFileSystemHandlerDirect(opCode); + return TestTask::performOneShotAction(); } ReturnValue_t Q7STestTask::performPeriodicAction() { - if(doTestGps) { - testGpsDaemon(); - } - return TestTask::performPeriodicAction(); + if (doTestGps) { + testGpsDaemon(); + } + return TestTask::performPeriodicAction(); } void Q7STestTask::testSdCard() { - using namespace std; - Stopwatch stopwatch; - int result = std::system("q7hw sd info all > /tmp/sd_status.txt"); - if(result != 0) { - sif::debug << "system call failed with " << result << endl; + using namespace std; + Stopwatch stopwatch; + int result = std::system("q7hw sd info all > /tmp/sd_status.txt"); + if (result != 0) { + sif::debug << "system call failed with " << result << endl; + } + ifstream sdStatus("/tmp/sd_status.txt"); + string line; + uint8_t idx = 0; + while (std::getline(sdStatus, line)) { + std::istringstream iss(line); + string word; + while (iss >> word) { + if (word == "on") { + sif::info << "SD card " << static_cast(idx) << " is on" << endl; + } else if (word == "off") { + sif::info << "SD card " << static_cast(idx) << " is off" << endl; + } } - ifstream sdStatus("/tmp/sd_status.txt"); - string line; - uint8_t idx = 0; - while (std::getline(sdStatus, line)) { - std::istringstream iss(line); - string word; - while(iss >> word) { - if(word == "on") { - sif::info << "SD card " << static_cast(idx) << " is on" << endl; - } - else if(word == "off") { - sif::info << "SD card " << static_cast(idx) << " is off" << endl; - } - } - idx++; - } - std::remove("/tmp/sd_status.txt"); + idx++; + } + std::remove("/tmp/sd_status.txt"); } void Q7STestTask::fileTests() { - using namespace std; - ofstream testFile("/tmp/test.txt"); - testFile << "Hallo Welt" << endl; - testFile.close(); + using namespace std; + ofstream testFile("/tmp/test.txt"); + testFile << "Hallo Welt" << endl; + testFile.close(); - system("echo \"Hallo Welt\" > /tmp/test2.txt"); - system("echo \"Hallo Welt\""); + system("echo \"Hallo Welt\" > /tmp/test2.txt"); + system("echo \"Hallo Welt\""); } void Q7STestTask::testScratchApi() { - ReturnValue_t result = scratch::writeNumber("TEST", 1); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "Q7STestTask::scratchApiTest: Writing number failed" << std::endl; - } - int number = 0; - result = scratch::readNumber("TEST", number); - sif::info << "Q7STestTask::testScratchApi: Value for key \"TEST\": " << number << std::endl; - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "Q7STestTask::scratchApiTest: Reading number failed" << std::endl; - } + ReturnValue_t result = scratch::writeNumber("TEST", 1); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "Q7STestTask::scratchApiTest: Writing number failed" << std::endl; + } + int number = 0; + result = scratch::readNumber("TEST", number); + sif::info << "Q7STestTask::testScratchApi: Value for key \"TEST\": " << number << std::endl; + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "Q7STestTask::scratchApiTest: Reading number failed" << std::endl; + } - result = scratch::writeString("TEST2", "halloWelt"); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "Q7STestTask::scratchApiTest: Writing string failed" << std::endl; - } - std::string string; - result = scratch::readString("TEST2", string); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "Q7STestTask::scratchApiTest: Reading number failed" << std::endl; - } - sif::info << "Q7STestTask::testScratchApi: Value for key \"TEST2\": " << string << std::endl; + result = scratch::writeString("TEST2", "halloWelt"); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "Q7STestTask::scratchApiTest: Writing string failed" << std::endl; + } + std::string string; + result = scratch::readString("TEST2", string); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "Q7STestTask::scratchApiTest: Reading number failed" << std::endl; + } + sif::info << "Q7STestTask::testScratchApi: Value for key \"TEST2\": " << string << std::endl; - result = scratch::clearValue("TEST"); - result = scratch::clearValue("TEST2"); + result = scratch::clearValue("TEST"); + result = scratch::clearValue("TEST2"); } void Q7STestTask::testJsonLibDirect() { - Stopwatch stopwatch; - // for convenience - using json = nlohmann::json; - json helloTest; - // add a number that is stored as double (note the implicit conversion of j to an object) - helloTest["pi"] = 3.141; - std::string mntPrefix = SdCardManager::instance()->getCurrentMountPrefix(); - std::string fileName = mntPrefix + "/pretty.json"; - std::ofstream o(fileName); - o << std::setw(4) << helloTest << std::endl; + Stopwatch stopwatch; + // for convenience + using json = nlohmann::json; + json helloTest; + // add a number that is stored as double (note the implicit conversion of j to an object) + helloTest["pi"] = 3.141; + std::string mntPrefix = SdCardManager::instance()->getCurrentMountPrefix(); + std::string fileName = mntPrefix + "/pretty.json"; + std::ofstream o(fileName); + o << std::setw(4) << helloTest << std::endl; } void Q7STestTask::testDummyParams() { - std::string mntPrefix = SdCardManager::instance()->getCurrentMountPrefix(); - DummyParameter param(mntPrefix, "dummy_json.txt"); - param.printKeys(); - param.print(); - if(not param.getJsonFileExists()) { - param.writeJsonFile(); - } - - ReturnValue_t result = param.readJsonFile(); - if(result != HasReturnvaluesIF::RETURN_OK) { - - } - - param.setValue(DummyParameter::DUMMY_KEY_PARAM_1, 3); - param.setValue(DummyParameter::DUMMY_KEY_PARAM_2, "blirb"); - + std::string mntPrefix = SdCardManager::instance()->getCurrentMountPrefix(); + DummyParameter param(mntPrefix, "dummy_json.txt"); + param.printKeys(); + param.print(); + if (not param.getJsonFileExists()) { param.writeJsonFile(); - param.print(); + } - int test = 0; - result = param.getValue(DummyParameter::DUMMY_KEY_PARAM_1, &test); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Q7STestTask::testDummyParams: Key " << DummyParameter::DUMMY_KEY_PARAM_1 - << " does not exist" << std::endl; - } - std::string test2; - result = param.getValue(DummyParameter::DUMMY_KEY_PARAM_2, &test2); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Q7STestTask::testDummyParams: Key " << DummyParameter::DUMMY_KEY_PARAM_1 - << " does not exist" << std::endl; - } - sif::info << "Test value (3 expected): " << test << std::endl; - sif::info << "Test value 2 (\"blirb\" expected): " << test2 << std::endl; + ReturnValue_t result = param.readJsonFile(); + if (result != HasReturnvaluesIF::RETURN_OK) { + } + + param.setValue(DummyParameter::DUMMY_KEY_PARAM_1, 3); + param.setValue(DummyParameter::DUMMY_KEY_PARAM_2, "blirb"); + + param.writeJsonFile(); + param.print(); + + int test = 0; + result = param.getValue(DummyParameter::DUMMY_KEY_PARAM_1, &test); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testDummyParams: Key " << DummyParameter::DUMMY_KEY_PARAM_1 + << " does not exist" << std::endl; + } + std::string test2; + result = param.getValue(DummyParameter::DUMMY_KEY_PARAM_2, &test2); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testDummyParams: Key " << DummyParameter::DUMMY_KEY_PARAM_1 + << " does not exist" << std::endl; + } + sif::info << "Test value (3 expected): " << test << std::endl; + sif::info << "Test value 2 (\"blirb\" expected): " << test2 << std::endl; } ReturnValue_t Q7STestTask::initialize() { - coreController = ObjectManager::instance()->get(objects::CORE_CONTROLLER); - if(coreController == nullptr) { - sif::warning << "Q7STestTask::initialize: Could not retrieve CORE_CONTROLLER object" << - std::endl; - } - return TestTask::initialize(); + coreController = ObjectManager::instance()->get(objects::CORE_CONTROLLER); + if (coreController == nullptr) { + sif::warning << "Q7STestTask::initialize: Could not retrieve CORE_CONTROLLER object" + << std::endl; + } + return TestTask::initialize(); } void Q7STestTask::testProtHandler() { - bool opPerformed = false; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - // If any chips are unlocked, lock them here - result = coreController->setBootCopyProtection( - CoreController::Chip::ALL_CHIP, CoreController::Copy::ALL_COPY, true, - opPerformed, true); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; - } + bool opPerformed = false; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + // If any chips are unlocked, lock them here + result = coreController->setBootCopyProtection( + CoreController::Chip::ALL_CHIP, CoreController::Copy::ALL_COPY, true, opPerformed, true); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; + } - // unlock own copy - result = coreController->setBootCopyProtection( - CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, false, - opPerformed, true); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; - } - if(not opPerformed) { - sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; - } - int retval = std::system("print-chip-prot-status.sh"); - if(retval != 0) { - utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); - } + // unlock own copy + result = coreController->setBootCopyProtection( + CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, false, opPerformed, true); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; + } + if (not opPerformed) { + sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; + } + int retval = std::system("print-chip-prot-status.sh"); + if (retval != 0) { + utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); + } - // lock own copy - result = coreController->setBootCopyProtection( - CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, true, - opPerformed, true); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; - } - if(not opPerformed) { - sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; - } - retval = std::system("print-chip-prot-status.sh"); - if(retval != 0) { - utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); - } + // lock own copy + result = coreController->setBootCopyProtection( + CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, true, opPerformed, true); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; + } + if (not opPerformed) { + sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; + } + retval = std::system("print-chip-prot-status.sh"); + if (retval != 0) { + utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); + } - // unlock specific copy - result = coreController->setBootCopyProtection( - CoreController::Chip::CHIP_1, CoreController::Copy::COPY_1, false, - opPerformed, true); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; - } - if(not opPerformed) { - sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; - } - retval = std::system("print-chip-prot-status.sh"); - if(retval != 0) { - utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); - } + // unlock specific copy + result = coreController->setBootCopyProtection( + CoreController::Chip::CHIP_1, CoreController::Copy::COPY_1, false, opPerformed, true); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; + } + if (not opPerformed) { + sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; + } + retval = std::system("print-chip-prot-status.sh"); + if (retval != 0) { + utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); + } - // lock specific copy - result = coreController->setBootCopyProtection( - CoreController::Chip::CHIP_1, CoreController::Copy::COPY_1, true, - opPerformed, true); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; - } - if(not opPerformed) { - sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; - } - retval = std::system("print-chip-prot-status.sh"); - if(retval != 0) { - utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); - } + // lock specific copy + result = coreController->setBootCopyProtection( + CoreController::Chip::CHIP_1, CoreController::Copy::COPY_1, true, opPerformed, true); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; + } + if (not opPerformed) { + sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; + } + retval = std::system("print-chip-prot-status.sh"); + if (retval != 0) { + utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); + } } void Q7STestTask::testGpsDaemon() { - gpsmm gpsmm(GPSD_SHARED_MEMORY, 0); - gps_data_t* gps; - gps = gpsmm.read(); - if(gps == nullptr) { - sif::warning << "Q7STestTask: Reading GPS data failed" << std::endl; - } - sif::info << "-- Q7STestTask: GPS shared memory read test --" << std::endl; - time_t timeRaw = gps->fix.time.tv_sec; - std::tm* time = gmtime(&timeRaw); - sif::info << "Time: " << std::put_time(time, "%c %Z") << std::endl; - sif::info << "Visible satellites: " << gps->satellites_visible << std::endl; - sif::info << "Satellites used: " << gps->satellites_used << std::endl; - sif::info << "Fix (0:Not Seen|1:No Fix|2:2D|3:3D): " << gps->fix.mode << std::endl; - sif::info << "Latitude: " << gps->fix.latitude << std::endl; - sif::info << "Longitude: " << gps->fix.longitude << std::endl; - sif::info << "Altitude(MSL): " << gps->fix.altMSL << std::endl; - sif::info << "Speed(m/s): " << gps->fix.speed << std::endl; + gpsmm gpsmm(GPSD_SHARED_MEMORY, 0); + gps_data_t* gps; + gps = gpsmm.read(); + if (gps == nullptr) { + sif::warning << "Q7STestTask: Reading GPS data failed" << std::endl; + } + sif::info << "-- Q7STestTask: GPS shared memory read test --" << std::endl; + time_t timeRaw = gps->fix.time.tv_sec; + std::tm* time = gmtime(&timeRaw); + sif::info << "Time: " << std::put_time(time, "%c %Z") << std::endl; + sif::info << "Visible satellites: " << gps->satellites_visible << std::endl; + sif::info << "Satellites used: " << gps->satellites_used << std::endl; + sif::info << "Fix (0:Not Seen|1:No Fix|2:2D|3:3D): " << gps->fix.mode << std::endl; + sif::info << "Latitude: " << gps->fix.latitude << std::endl; + sif::info << "Longitude: " << gps->fix.longitude << std::endl; + sif::info << "Altitude(MSL): " << gps->fix.altMSL << std::endl; + sif::info << "Speed(m/s): " << gps->fix.speed << std::endl; } void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) { - auto fsHandler = ObjectManager::instance()-> - get(objects::FILE_SYSTEM_HANDLER); - if(fsHandler == nullptr) { - sif::warning << "Q7STestTask::testFileSystemHandlerDirect: No FS handler running.." - << std::endl; - } - FileSystemHandler::FsCommandCfg cfg = {}; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + auto fsHandler = ObjectManager::instance()->get(objects::FILE_SYSTEM_HANDLER); + if (fsHandler == nullptr) { + sif::warning << "Q7STestTask::testFileSystemHandlerDirect: No FS handler running.." + << std::endl; + } + FileSystemHandler::FsCommandCfg cfg = {}; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - // Lambda for common code - auto createNonEmptyTmpDir = [&]() { - if(not std::filesystem::exists("/tmp/test")) { - result = fsHandler->createDirectory("/tmp", "test", false, &cfg); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - } - // Creating sample files - sif::info << "Creating sample files in directory" << std::endl; - result = fsHandler->createFile("/tmp/test", "test1.txt", nullptr, 0, &cfg); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - result = fsHandler->createFile("/tmp/test", "test2.txt", nullptr, 0, &cfg); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + // Lambda for common code + auto createNonEmptyTmpDir = [&]() { + if (not std::filesystem::exists("/tmp/test")) { + result = fsHandler->createDirectory("/tmp", "test", false, &cfg); + if (result != HasReturnvaluesIF::RETURN_OK) { return result; - }; + } + } + // Creating sample files + sif::info << "Creating sample files in directory" << std::endl; + result = fsHandler->createFile("/tmp/test", "test1.txt", nullptr, 0, &cfg); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = fsHandler->createFile("/tmp/test", "test2.txt", nullptr, 0, &cfg); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + return result; + }; - - switch(opCode) { - case(FsOpCodes::CREATE_EMPTY_FILE_IN_TMP): { - // No mount prefix, cause file is created in tmp - cfg.useMountPrefix = false; - sif::info << "Creating empty file in /tmp folder" << std::endl; - // Do not delete file, user can check existence in shell + switch (opCode) { + case (FsOpCodes::CREATE_EMPTY_FILE_IN_TMP): { + // No mount prefix, cause file is created in tmp + cfg.useMountPrefix = false; + sif::info << "Creating empty file in /tmp folder" << std::endl; + // Do not delete file, user can check existence in shell + fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg); + break; + } + case (FsOpCodes::REMOVE_TMP_FILE): { + sif::info << "Deleting /tmp/test.txt sample file" << std::endl; + // No mount prefix, cause file is created in tmp + cfg.useMountPrefix = false; + if (not std::filesystem::exists("/tmp/test.txt")) { + // Creating sample file + sif::info << "Creating sample file /tmp/test.txt to delete" << std::endl; fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg); - break; + } + result = fsHandler->removeFile("/tmp", "test.txt", &cfg); + if (result == HasReturnvaluesIF::RETURN_OK) { + sif::info << "File removed successfully" << std::endl; + } else { + sif::warning << "File removal failed!" << std::endl; + } + break; } - case(FsOpCodes::REMOVE_TMP_FILE): { - sif::info << "Deleting /tmp/test.txt sample file" << std::endl; - // No mount prefix, cause file is created in tmp - cfg.useMountPrefix = false; - if(not std::filesystem::exists("/tmp/test.txt")) { - // Creating sample file - sif::info << "Creating sample file /tmp/test.txt to delete" << std::endl; - fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg); - } - result = fsHandler->removeFile("/tmp", "test.txt", &cfg); - if(result == HasReturnvaluesIF::RETURN_OK) { - sif::info << "File removed successfully" << std::endl; - } - else { - sif::warning << "File removal failed!" << std::endl; - } - break; + case (FsOpCodes::CREATE_DIR_IN_TMP): { + // No mount prefix, cause file is created in tmp + cfg.useMountPrefix = false; + sif::info << "Creating empty file in /tmp folder" << std::endl; + // Do not delete file, user can check existence in shell + ReturnValue_t result = fsHandler->createDirectory("/tmp/", "test", false, &cfg); + if (result == HasReturnvaluesIF::RETURN_OK) { + sif::info << "Directory created successfully" << std::endl; + } else { + sif::warning << "Directory creation failed!" << std::endl; + } + break; } - case(FsOpCodes::CREATE_DIR_IN_TMP): { - // No mount prefix, cause file is created in tmp - cfg.useMountPrefix = false; - sif::info << "Creating empty file in /tmp folder" << std::endl; - // Do not delete file, user can check existence in shell - ReturnValue_t result = fsHandler->createDirectory("/tmp/", "test", false, &cfg); - if(result == HasReturnvaluesIF::RETURN_OK) { - sif::info << "Directory created successfully" << std::endl; - } - else { - sif::warning << "Directory creation failed!" << std::endl; - } - break; + case (FsOpCodes::REMOVE_EMPTY_DIR_IN_TMP): { + // No mount prefix, cause file is created in tmp + cfg.useMountPrefix = false; + if (not std::filesystem::exists("/tmp/test")) { + result = fsHandler->createDirectory("/tmp", "test", false, &cfg); + } else { + // Delete any leftover files to regular dir removal works + std::remove("/tmp/test/*"); + } + result = fsHandler->removeDirectory("/tmp/", "test", false, &cfg); + if (result == HasReturnvaluesIF::RETURN_OK) { + sif::info << "Directory removed successfully" << std::endl; + } else { + sif::warning << "Directory removal failed!" << std::endl; + } + break; } - case(FsOpCodes::REMOVE_EMPTY_DIR_IN_TMP): { - // No mount prefix, cause file is created in tmp - cfg.useMountPrefix = false; - if(not std::filesystem::exists("/tmp/test")) { - result = fsHandler->createDirectory("/tmp", "test", false, &cfg); - } - else { - // Delete any leftover files to regular dir removal works - std::remove("/tmp/test/*"); - } - result = fsHandler->removeDirectory("/tmp/", "test", false, &cfg); - if(result == HasReturnvaluesIF::RETURN_OK) { - sif::info << "Directory removed successfully" << std::endl; - } - else { - sif::warning << "Directory removal failed!" << std::endl; - } - break; + case (FsOpCodes::REMOVE_FILLED_DIR_IN_TMP): { + result = createNonEmptyTmpDir(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return; + } + result = fsHandler->removeDirectory("/tmp/", "test", true, &cfg); + if (result == HasReturnvaluesIF::RETURN_OK) { + sif::info << "Directory removed recursively successfully" << std::endl; + } else { + sif::warning << "Recursive directory removal failed!" << std::endl; + } + break; } - case(FsOpCodes::REMOVE_FILLED_DIR_IN_TMP): { - result = createNonEmptyTmpDir(); - if(result != HasReturnvaluesIF::RETURN_OK) { - return; - } - result = fsHandler->removeDirectory("/tmp/", "test", true, &cfg); - if(result == HasReturnvaluesIF::RETURN_OK) { - sif::info << "Directory removed recursively successfully" << std::endl; - } - else { - sif::warning << "Recursive directory removal failed!" << std::endl; - } - break; + case (FsOpCodes::ATTEMPT_DIR_REMOVAL_NON_EMPTY): { + result = createNonEmptyTmpDir(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return; + } + result = fsHandler->removeDirectory("/tmp/", "test", false, &cfg); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::info << "Directory removal attempt failed as expected" << std::endl; + } else { + sif::warning << "Directory removal worked when it should not have!" << std::endl; + } + break; } - case(FsOpCodes::ATTEMPT_DIR_REMOVAL_NON_EMPTY): { - result = createNonEmptyTmpDir(); - if(result != HasReturnvaluesIF::RETURN_OK) { - return; - } - result = fsHandler->removeDirectory("/tmp/", "test", false, &cfg); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::info << "Directory removal attempt failed as expected" << std::endl; - } - else { - sif::warning << "Directory removal worked when it should not have!" << std::endl; - } - break; - } - case(FsOpCodes::RENAME_FILE): { - // No mount prefix, cause file is created in tmp - cfg.useMountPrefix = false; - if(std::filesystem::exists("/tmp/test.txt")) { - fsHandler->removeDirectory("/tmp/", "test", false, &cfg); - } - sif::info << "Creating empty file /tmp/test.txt and rename to /tmp/test2.txt" << std::endl; - // Do not delete file, user can check existence in shell - fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg); - fsHandler->renameFile("/tmp/", "test.txt", "test2.txt", &cfg); - break; - } - case(FsOpCodes::APPEND_TO_FILE): { - // No mount prefix, cause file is created in tmp - cfg.useMountPrefix = false; - if(std::filesystem::exists("/tmp/test.txt")) { - fsHandler->removeDirectory("/tmp/", "test", false, &cfg); - } - if(std::filesystem::exists("/tmp/test.txt")) { - fsHandler->removeDirectory("/tmp/", "test", false, &cfg); - } - sif::info << "Creating empty file /tmp/test.txt and adding content" << std::endl; - std::string content = "Hello World\n"; - // Do not delete file, user can check existence in shell - fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg); - fsHandler->appendToFile("/tmp/", "test.txt", reinterpret_cast( - content.data()), content.size(), 0, &cfg); + case (FsOpCodes::RENAME_FILE): { + // No mount prefix, cause file is created in tmp + cfg.useMountPrefix = false; + if (std::filesystem::exists("/tmp/test.txt")) { + fsHandler->removeDirectory("/tmp/", "test", false, &cfg); + } + sif::info << "Creating empty file /tmp/test.txt and rename to /tmp/test2.txt" << std::endl; + // Do not delete file, user can check existence in shell + fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg); + fsHandler->renameFile("/tmp/", "test.txt", "test2.txt", &cfg); + break; } + case (FsOpCodes::APPEND_TO_FILE): { + // No mount prefix, cause file is created in tmp + cfg.useMountPrefix = false; + if (std::filesystem::exists("/tmp/test.txt")) { + fsHandler->removeDirectory("/tmp/", "test", false, &cfg); + } + if (std::filesystem::exists("/tmp/test.txt")) { + fsHandler->removeDirectory("/tmp/", "test", false, &cfg); + } + sif::info << "Creating empty file /tmp/test.txt and adding content" << std::endl; + std::string content = "Hello World\n"; + // Do not delete file, user can check existence in shell + fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg); + fsHandler->appendToFile("/tmp/", "test.txt", reinterpret_cast(content.data()), + content.size(), 0, &cfg); } + } } diff --git a/bsp_q7s/boardtest/Q7STestTask.h b/bsp_q7s/boardtest/Q7STestTask.h index 91e8c3d6..ee26118c 100644 --- a/bsp_q7s/boardtest/Q7STestTask.h +++ b/bsp_q7s/boardtest/Q7STestTask.h @@ -3,42 +3,42 @@ #include "test/testtasks/TestTask.h" -class Q7STestTask: public TestTask { -public: - Q7STestTask(object_id_t objectId); +class Q7STestTask : public TestTask { + public: + Q7STestTask(object_id_t objectId); - ReturnValue_t initialize() override; -private: - bool doTestSdCard = false; - bool doTestScratchApi = false; - bool doTestGps = false; + ReturnValue_t initialize() override; - CoreController* coreController = nullptr; - ReturnValue_t performOneShotAction() override; - ReturnValue_t performPeriodicAction() override; + private: + bool doTestSdCard = false; + bool doTestScratchApi = false; + bool doTestGps = false; - void testGpsDaemon(); + CoreController* coreController = nullptr; + ReturnValue_t performOneShotAction() override; + ReturnValue_t performPeriodicAction() override; - void testSdCard(); - void fileTests(); + void testGpsDaemon(); - void testScratchApi(); - void testJsonLibDirect(); - void testDummyParams(); - void testProtHandler(); + void testSdCard(); + void fileTests(); - enum FsOpCodes { - CREATE_EMPTY_FILE_IN_TMP, - REMOVE_TMP_FILE, - CREATE_DIR_IN_TMP, - REMOVE_EMPTY_DIR_IN_TMP, - ATTEMPT_DIR_REMOVAL_NON_EMPTY, - REMOVE_FILLED_DIR_IN_TMP, - RENAME_FILE, - APPEND_TO_FILE, - }; - void testFileSystemHandlerDirect(FsOpCodes opCode); + void testScratchApi(); + void testJsonLibDirect(); + void testDummyParams(); + void testProtHandler(); + + enum FsOpCodes { + CREATE_EMPTY_FILE_IN_TMP, + REMOVE_TMP_FILE, + CREATE_DIR_IN_TMP, + REMOVE_EMPTY_DIR_IN_TMP, + ATTEMPT_DIR_REMOVAL_NON_EMPTY, + REMOVE_FILLED_DIR_IN_TMP, + RENAME_FILE, + APPEND_TO_FILE, + }; + void testFileSystemHandlerDirect(FsOpCodes opCode); }; - #endif /* BSP_Q7S_BOARDTEST_Q7STESTTASK_H_ */ diff --git a/bsp_q7s/callbacks/gnssCallback.cpp b/bsp_q7s/callbacks/gnssCallback.cpp index 479f4a2b..d5dbc3b0 100644 --- a/bsp_q7s/callbacks/gnssCallback.cpp +++ b/bsp_q7s/callbacks/gnssCallback.cpp @@ -1,26 +1,25 @@ #include "gnssCallback.h" -#include "devices/gpioIds.h" +#include "devices/gpioIds.h" #include "fsfw/tasks/TaskFactory.h" -ReturnValue_t gps::triggerGpioResetPin(void *args) { - ResetArgs* resetArgs = reinterpret_cast(args); - if(args == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; - } - if (resetArgs->gpioComIF == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; - } - gpioId_t gpioId; - if(resetArgs->gnss1) { - gpioId = gpioIds::GNSS_1_NRESET; +ReturnValue_t gps::triggerGpioResetPin(void* args) { + ResetArgs* resetArgs = reinterpret_cast(args); + if (args == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } + if (resetArgs->gpioComIF == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } + gpioId_t gpioId; + if (resetArgs->gnss1) { + gpioId = gpioIds::GNSS_1_NRESET; - } - else { - gpioId = gpioIds::GNSS_0_NRESET; - } - resetArgs->gpioComIF->pullLow(gpioId); - TaskFactory::delayTask(resetArgs->waitPeriodMs); - resetArgs->gpioComIF->pullHigh(gpioId); - return HasReturnvaluesIF::RETURN_OK; + } else { + gpioId = gpioIds::GNSS_0_NRESET; + } + resetArgs->gpioComIF->pullLow(gpioId); + TaskFactory::delayTask(resetArgs->waitPeriodMs); + resetArgs->gpioComIF->pullHigh(gpioId); + return HasReturnvaluesIF::RETURN_OK; } diff --git a/bsp_q7s/callbacks/gnssCallback.h b/bsp_q7s/callbacks/gnssCallback.h index 9cbb6669..3e769899 100644 --- a/bsp_q7s/callbacks/gnssCallback.h +++ b/bsp_q7s/callbacks/gnssCallback.h @@ -1,13 +1,13 @@ #ifndef BSP_Q7S_CALLBACKS_GNSSCALLBACK_H_ #define BSP_Q7S_CALLBACKS_GNSSCALLBACK_H_ -#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" struct ResetArgs { - bool gnss1 = false; - LinuxLibgpioIF* gpioComIF = nullptr; - uint32_t waitPeriodMs = 100; + bool gnss1 = false; + LinuxLibgpioIF* gpioComIF = nullptr; + uint32_t waitPeriodMs = 100; }; namespace gps { diff --git a/bsp_q7s/callbacks/rwSpiCallback.cpp b/bsp_q7s/callbacks/rwSpiCallback.cpp index 1e60e3c0..3ca3c181 100644 --- a/bsp_q7s/callbacks/rwSpiCallback.cpp +++ b/bsp_q7s/callbacks/rwSpiCallback.cpp @@ -1,238 +1,232 @@ #include "rwSpiCallback.h" -#include "devices/gpioIds.h" -#include "mission/devices/RwHandler.h" -#include "fsfw_hal/linux/spi/SpiCookie.h" -#include "fsfw_hal/linux/UnixFileGuard.h" +#include "devices/gpioIds.h" #include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw_hal/linux/UnixFileGuard.h" +#include "fsfw_hal/linux/spi/SpiCookie.h" +#include "mission/devices/RwHandler.h" namespace rwSpiCallback { -ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sendData, - size_t sendLen, void* args) { +ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sendData, + size_t sendLen, void* args) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + RwHandler* handler = reinterpret_cast(args); + if (handler == nullptr) { + sif::error << "rwSpiCallback::spiCallback: Pointer to handler is invalid" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } - RwHandler* handler = reinterpret_cast(args); - if(handler == nullptr) { - sif::error << "rwSpiCallback::spiCallback: Pointer to handler is invalid" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; + uint8_t writeBuffer[2]; + uint8_t writeSize = 0; + + gpioId_t gpioId = cookie->getChipSelectPin(); + GpioIF* gpioIF = comIf->getGpioInterface(); + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; + uint32_t timeoutMs = 0; + MutexIF* mutex = comIf->getMutex(&timeoutType, &timeoutMs); + if (mutex == nullptr or gpioIF == nullptr) { + sif::debug << "rwSpiCallback::spiCallback: Mutex or GPIO interface invalid" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + + int fileDescriptor = 0; + std::string device = cookie->getSpiDevice(); + UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "rwSpiCallback::spiCallback"); + if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "rwSpiCallback::spiCallback: Failed to open device file" << std::endl; + return SpiComIF::OPENING_FILE_FAILED; + } + spi::SpiModes spiMode = spi::SpiModes::MODE_0; + uint32_t spiSpeed = 0; + cookie->getSpiParameters(spiMode, spiSpeed, nullptr); + comIf->setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); + + result = mutex->lockMutex(timeoutType, timeoutMs); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "rwSpiCallback::spiCallback: Failed to lock mutex" << std::endl; + return result; + } + + /** Sending frame start sign */ + writeBuffer[0] = 0x7E; + writeSize = 1; + + // Pull SPI CS low. For now, no support for active high given + if (gpioId != gpio::NO_GPIO) { + if (gpioIF->pullLow(gpioId) != HasReturnvaluesIF::RETURN_OK) { + sif::error << "rwSpiCallback::spiCallback: Failed to pull chip select low" << std::endl; } + } - uint8_t writeBuffer[2]; - uint8_t writeSize = 0; + if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { + sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; + closeSpi(gpioId, gpioIF, mutex); + return RwHandler::SPI_WRITE_FAILURE; + } - gpioId_t gpioId = cookie->getChipSelectPin(); - GpioIF* gpioIF = comIf->getGpioInterface(); - MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; - uint32_t timeoutMs = 0; - MutexIF* mutex = comIf->getMutex(&timeoutType, &timeoutMs); - if(mutex == nullptr or gpioIF == nullptr) { - sif::debug << "rwSpiCallback::spiCallback: Mutex or GPIO interface invalid" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - - int fileDescriptor = 0; - std::string device = cookie->getSpiDevice(); - UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "rwSpiCallback::spiCallback"); - if(fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "rwSpiCallback::spiCallback: Failed to open device file" << std::endl; - return SpiComIF::OPENING_FILE_FAILED; + /** Encoding and sending command */ + size_t idx = 0; + while (idx < sendLen) { + switch (*(sendData + idx)) { + case 0x7E: + writeBuffer[0] = 0x7D; + writeBuffer[1] = 0x5E; + writeSize = 2; + break; + case 0x7D: + writeBuffer[0] = 0x7D; + writeBuffer[1] = 0x5D; + writeSize = 2; + break; + default: + writeBuffer[0] = *(sendData + idx); + writeSize = 1; + break; } - spi::SpiModes spiMode = spi::SpiModes::MODE_0; - uint32_t spiSpeed = 0; - cookie->getSpiParameters(spiMode, spiSpeed, nullptr); - comIf->setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); - - result = mutex->lockMutex(timeoutType, timeoutMs); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "rwSpiCallback::spiCallback: Failed to lock mutex" << std::endl; - return result; - } - - /** Sending frame start sign */ - writeBuffer[0] = 0x7E; - writeSize = 1; - - // Pull SPI CS low. For now, no support for active high given - if(gpioId != gpio::NO_GPIO) { - if(gpioIF->pullLow(gpioId) != HasReturnvaluesIF::RETURN_OK) { - sif::error << "rwSpiCallback::spiCallback: Failed to pull chip select low" << std::endl; - } - } - if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { - sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; + sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; + closeSpi(gpioId, gpioIF, mutex); + return RwHandler::SPI_WRITE_FAILURE; + } + idx++; + } + + /** Sending frame end sign */ + writeBuffer[0] = 0x7E; + writeSize = 1; + + if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { + sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; + closeSpi(gpioId, gpioIF, mutex); + return RwHandler::SPI_WRITE_FAILURE; + } + + uint8_t* rxBuf = nullptr; + result = comIf->getReadBuffer(cookie->getSpiAddress(), &rxBuf); + if (result != HasReturnvaluesIF::RETURN_OK) { + closeSpi(gpioId, gpioIF, mutex); + return result; + } + + size_t replyBufferSize = cookie->getMaxBufferSize(); + + /** There must be a delay of at least 20 ms after sending the command */ + usleep(RwDefinitions::SPI_REPLY_DELAY); + + /** + * The reaction wheel responds with empty frames while preparing the reply data. + * However, receiving more than 5 empty frames will be interpreted as an error. + */ + uint8_t byteRead = 0; + for (int idx = 0; idx < 10; idx++) { + if (read(fileDescriptor, &byteRead, 1) != 1) { + sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; + closeSpi(gpioId, gpioIF, mutex); + return RwHandler::SPI_READ_FAILURE; + } + if (idx == 0) { + if (byteRead != FLAG_BYTE) { + sif::error << "Invalid data, expected start marker" << std::endl; closeSpi(gpioId, gpioIF, mutex); - return RwHandler::SPI_WRITE_FAILURE; + return RwHandler::NO_START_MARKER; + } } - /** Encoding and sending command */ - size_t idx = 0; - while(idx < sendLen) { - switch(*(sendData + idx)) { - case 0x7E: - writeBuffer[0] = 0x7D; - writeBuffer[1] = 0x5E; - writeSize = 2; - break; - case 0x7D: - writeBuffer[0] = 0x7D; - writeBuffer[1] = 0x5D; - writeSize = 2; - break; - default: - writeBuffer[0] = *(sendData + idx); - writeSize = 1; - break; - } - if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { - sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; - closeSpi(gpioId, gpioIF, mutex); - return RwHandler::SPI_WRITE_FAILURE; - } - idx++; + if (byteRead != FLAG_BYTE) { + break; } - /** Sending frame end sign */ - writeBuffer[0] = 0x7E; - writeSize = 1; - - if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { - sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; - closeSpi(gpioId, gpioIF, mutex); - return RwHandler::SPI_WRITE_FAILURE; - } - - uint8_t* rxBuf = nullptr; - result = comIf->getReadBuffer(cookie->getSpiAddress(), &rxBuf); - if(result != HasReturnvaluesIF::RETURN_OK) { - closeSpi(gpioId, gpioIF, mutex); - return result; - } - - size_t replyBufferSize = cookie->getMaxBufferSize(); - - /** There must be a delay of at least 20 ms after sending the command */ - usleep(RwDefinitions::SPI_REPLY_DELAY); - - /** - * The reaction wheel responds with empty frames while preparing the reply data. - * However, receiving more than 5 empty frames will be interpreted as an error. - */ - uint8_t byteRead = 0; - for (int idx = 0; idx < 10; idx++) { - if(read(fileDescriptor, &byteRead, 1) != 1) { - sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; - closeSpi(gpioId, gpioIF, mutex); - return RwHandler::SPI_READ_FAILURE; - } - if(idx == 0) { - if(byteRead != FLAG_BYTE) { - sif::error << "Invalid data, expected start marker" << std::endl; - closeSpi(gpioId, gpioIF, mutex); - return RwHandler::NO_START_MARKER; - } - } - - if (byteRead != FLAG_BYTE) { - break; - } - - if (idx == 9) { - sif::error << "rwSpiCallback::spiCallback: Empty frame timeout" << std::endl; - closeSpi(gpioId, gpioIF, mutex); - return RwHandler::NO_REPLY; - } + if (idx == 9) { + sif::error << "rwSpiCallback::spiCallback: Empty frame timeout" << std::endl; + closeSpi(gpioId, gpioIF, mutex); + return RwHandler::NO_REPLY; } + } #if FSFW_HAL_SPI_WIRETAPPING == 1 - sif::info << "RW start marker detected" << std::endl; + sif::info << "RW start marker detected" << std::endl; #endif - size_t decodedFrameLen = 0; - while(decodedFrameLen < replyBufferSize) { - - /** First byte already read in */ - if (decodedFrameLen != 0) { - byteRead = 0; - if(read(fileDescriptor, &byteRead, 1) != 1) { - sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; - result = RwHandler::SPI_READ_FAILURE; - break; - } - } - - if (byteRead == FLAG_BYTE) { - /** Reached end of frame */ - break; - } - else if (byteRead == 0x7D) { - if(read(fileDescriptor, &byteRead, 1) != 1) { - sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; - result = RwHandler::SPI_READ_FAILURE; - break; - } - if (byteRead == 0x5E) { - *(rxBuf + decodedFrameLen) = 0x7E; - decodedFrameLen++; - continue; - } - else if (byteRead == 0x5D) { - *(rxBuf + decodedFrameLen) = 0x7D; - decodedFrameLen++; - continue; - } - else { - sif::error << "rwSpiCallback::spiCallback: Invalid substitute" << std::endl; - closeSpi(gpioId, gpioIF, mutex); - result = RwHandler::INVALID_SUBSTITUTE; - break; - } - } - else { - *(rxBuf + decodedFrameLen) = byteRead; - decodedFrameLen++; - continue; - } - - /** - * There might be the unlikely case that each byte in a get-telemetry reply has been - * replaced by its substitute. Than the next byte must correspond to the end sign 0x7E. - * Otherwise there might be something wrong. - */ - if (decodedFrameLen == replyBufferSize) { - if(read(fileDescriptor, &byteRead, 1) != 1) { - sif::error << "rwSpiCallback::spiCallback: Failed to read last byte" << std::endl; - result = RwHandler::SPI_READ_FAILURE; - break; - } - if (byteRead != 0x7E) { - sif::error << "rwSpiCallback::spiCallback: Missing end sign 0x7E" << std::endl; - decodedFrameLen--; - result = RwHandler::MISSING_END_SIGN; - break; - } - } - result = HasReturnvaluesIF::RETURN_OK; + size_t decodedFrameLen = 0; + while (decodedFrameLen < replyBufferSize) { + /** First byte already read in */ + if (decodedFrameLen != 0) { + byteRead = 0; + if (read(fileDescriptor, &byteRead, 1) != 1) { + sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; + result = RwHandler::SPI_READ_FAILURE; + break; + } } - cookie->setTransferSize(decodedFrameLen); - - closeSpi(gpioId, gpioIF, mutex); - - return result; -} - -void closeSpi (gpioId_t gpioId, GpioIF* gpioIF, MutexIF* mutex) { - if(gpioId != gpio::NO_GPIO) { - if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) { - sif::error << "closeSpi: Failed to pull chip select high" << std::endl; - } + if (byteRead == FLAG_BYTE) { + /** Reached end of frame */ + break; + } else if (byteRead == 0x7D) { + if (read(fileDescriptor, &byteRead, 1) != 1) { + sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; + result = RwHandler::SPI_READ_FAILURE; + break; + } + if (byteRead == 0x5E) { + *(rxBuf + decodedFrameLen) = 0x7E; + decodedFrameLen++; + continue; + } else if (byteRead == 0x5D) { + *(rxBuf + decodedFrameLen) = 0x7D; + decodedFrameLen++; + continue; + } else { + sif::error << "rwSpiCallback::spiCallback: Invalid substitute" << std::endl; + closeSpi(gpioId, gpioIF, mutex); + result = RwHandler::INVALID_SUBSTITUTE; + break; + } + } else { + *(rxBuf + decodedFrameLen) = byteRead; + decodedFrameLen++; + continue; } - if(mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "rwSpiCallback::closeSpi: Failed to unlock mutex" << std::endl;; + + /** + * There might be the unlikely case that each byte in a get-telemetry reply has been + * replaced by its substitute. Than the next byte must correspond to the end sign 0x7E. + * Otherwise there might be something wrong. + */ + if (decodedFrameLen == replyBufferSize) { + if (read(fileDescriptor, &byteRead, 1) != 1) { + sif::error << "rwSpiCallback::spiCallback: Failed to read last byte" << std::endl; + result = RwHandler::SPI_READ_FAILURE; + break; + } + if (byteRead != 0x7E) { + sif::error << "rwSpiCallback::spiCallback: Missing end sign 0x7E" << std::endl; + decodedFrameLen--; + result = RwHandler::MISSING_END_SIGN; + break; + } } + result = HasReturnvaluesIF::RETURN_OK; + } + + cookie->setTransferSize(decodedFrameLen); + + closeSpi(gpioId, gpioIF, mutex); + + return result; } + +void closeSpi(gpioId_t gpioId, GpioIF* gpioIF, MutexIF* mutex) { + if (gpioId != gpio::NO_GPIO) { + if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) { + sif::error << "closeSpi: Failed to pull chip select high" << std::endl; + } + } + if (mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "rwSpiCallback::closeSpi: Failed to unlock mutex" << std::endl; + ; + } } +} // namespace rwSpiCallback diff --git a/bsp_q7s/callbacks/rwSpiCallback.h b/bsp_q7s/callbacks/rwSpiCallback.h index 8952f873..843d5b80 100644 --- a/bsp_q7s/callbacks/rwSpiCallback.h +++ b/bsp_q7s/callbacks/rwSpiCallback.h @@ -2,9 +2,8 @@ #define BSP_Q7S_RW_SPI_CALLBACK_H_ #include "fsfw/returnvalues/HasReturnvaluesIF.h" -#include "fsfw_hal/linux/spi/SpiComIF.h" #include "fsfw_hal/common/gpio/GpioCookie.h" - +#include "fsfw_hal/linux/spi/SpiComIF.h" namespace rwSpiCallback { @@ -31,8 +30,8 @@ static constexpr uint8_t FLAG_BYTE = 0x7E; * To switch between the to SPI peripherals, an EMIO is used which will also be controlled * by this function. */ -ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sendData, - size_t sendLen, void* args); +ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sendData, + size_t sendLen, void* args); /** * @brief This function closes a spi session. Pulls the chip select to high an releases the @@ -43,5 +42,5 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sen */ void closeSpi(gpioId_t gpioId, GpioIF* gpioIF, MutexIF* mutex); -} +} // namespace rwSpiCallback #endif /* BSP_Q7S_RW_SPI_CALLBACK_H_ */ diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 271ec508..bdbd51cc 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -1,1171 +1,1103 @@ #include "CoreController.h" + #include "OBSWConfig.h" #include "OBSWVersion.h" -#include "watchdogConf.h" - #include "fsfw/FSFWVersion.h" -#include "fsfw/timemanager/Stopwatch.h" #include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/timemanager/Stopwatch.h" +#include "watchdogConf.h" #if OBSW_USE_TMTC_TCP_BRIDGE == 0 #include "fsfw/osal/common/UdpTmTcBridge.h" #else #include "fsfw/osal/common/TcpTmTcServer.h" #endif -#include "bsp_q7s/memory/scratchApi.h" -#include "bsp_q7s/memory/SdCardManager.h" - #include #include #include +#include "bsp_q7s/memory/SdCardManager.h" +#include "bsp_q7s/memory/scratchApi.h" + CoreController::Chip CoreController::CURRENT_CHIP = Chip::NO_CHIP; CoreController::Copy CoreController::CURRENT_COPY = Copy::NO_COPY; -CoreController::CoreController(object_id_t objectId): - ExtendedControllerBase(objectId, objects::NO_OBJECT, 5), opDivider(5) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - try { - result = initWatchdogFifo(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::CoreController: Watchdog FIFO init failed" << - std::endl; - } - sdcMan = SdCardManager::instance(); - if(sdcMan == nullptr) { - sif::error << "CoreController::CoreController: SD card manager invalid!" << std::endl; - } - - if(not BLOCKING_SD_INIT) { - sdcMan->setBlocking(false); - } - sdStateMachine(); - - result = initBootCopy(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::CoreController: Boot copy init" << std::endl; - } +CoreController::CoreController(object_id_t objectId) + : ExtendedControllerBase(objectId, objects::NO_OBJECT, 5), opDivider(5) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + try { + result = initWatchdogFifo(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::CoreController: Watchdog FIFO init failed" << std::endl; } - catch(const std::filesystem::filesystem_error& e) { - sif::error << "CoreController::CoreController: Failed with exception " << - e.what() << std::endl; + sdcMan = SdCardManager::instance(); + if (sdcMan == nullptr) { + sif::error << "CoreController::CoreController: SD card manager invalid!" << std::endl; } + + if (not BLOCKING_SD_INIT) { + sdcMan->setBlocking(false); + } + sdStateMachine(); + + result = initBootCopy(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::CoreController: Boot copy init" << std::endl; + } + } catch (const std::filesystem::filesystem_error &e) { + sif::error << "CoreController::CoreController: Failed with exception " << e.what() << std::endl; + } } ReturnValue_t CoreController::handleCommandMessage(CommandMessage *message) { - return ExtendedControllerBase::handleCommandMessage(message); + return ExtendedControllerBase::handleCommandMessage(message); } void CoreController::performControlOperation() { - performWatchdogControlOperation(); - sdStateMachine(); + performWatchdogControlOperation(); + sdStateMachine(); } ReturnValue_t CoreController::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) { - return HasReturnvaluesIF::RETURN_OK; + LocalDataPoolManager &poolManager) { + return HasReturnvaluesIF::RETURN_OK; } -LocalPoolDataSetBase* CoreController::getDataSetHandle(sid_t sid) { - return nullptr; -} +LocalPoolDataSetBase *CoreController::getDataSetHandle(sid_t sid) { return nullptr; } ReturnValue_t CoreController::initialize() { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - result = scratch::writeNumber(scratch::ALLOC_FAILURE_COUNT, 0); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::initialize: Setting up alloc failure " - "count failed" << std::endl; - } + result = scratch::writeNumber(scratch::ALLOC_FAILURE_COUNT, 0); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::initialize: Setting up alloc failure " + "count failed" + << std::endl; + } - sdStateMachine(); - return ExtendedControllerBase::initialize(); + sdStateMachine(); + return ExtendedControllerBase::initialize(); } ReturnValue_t CoreController::initializeAfterTaskCreation() { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - if(BLOCKING_SD_INIT) { - ReturnValue_t result = initSdCardBlocking(); - if(result != HasReturnvaluesIF::RETURN_OK and result != SdCardManager::ALREADY_MOUNTED) { - sif::warning << "CoreController::CoreController: SD card init failed" << std::endl; - } + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + if (BLOCKING_SD_INIT) { + ReturnValue_t result = initSdCardBlocking(); + if (result != HasReturnvaluesIF::RETURN_OK and result != SdCardManager::ALREADY_MOUNTED) { + sif::warning << "CoreController::CoreController: SD card init failed" << std::endl; } - sdStateMachine(); - result = initVersionFile(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::initialize: Version initialization failed" << std::endl; - } - // Add script folder to path - char* currentEnvPath = getenv("PATH"); - std::string updatedEnvPath = std::string(currentEnvPath) + ":/home/root/scripts"; - setenv("PATH", updatedEnvPath.c_str(), true); - updateProtInfo(); - initPrint(); - return result; + } + sdStateMachine(); + result = initVersionFile(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::initialize: Version initialization failed" << std::endl; + } + // Add script folder to path + char *currentEnvPath = getenv("PATH"); + std::string updatedEnvPath = std::string(currentEnvPath) + ":/home/root/scripts"; + setenv("PATH", updatedEnvPath.c_str(), true); + updateProtInfo(); + initPrint(); + return result; } ReturnValue_t CoreController::checkModeCommand(Mode_t mode, Submode_t submode, - uint32_t *msToReachTheMode) { - return HasReturnvaluesIF::RETURN_OK; + uint32_t *msToReachTheMode) { + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t CoreController::initSdCardBlocking() { - // Create update status file - ReturnValue_t result = sdcMan->updateSdCardStateFile(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::initialize: Updating SD card state file failed" - << std::endl; - } + // Create update status file + ReturnValue_t result = sdcMan->updateSdCardStateFile(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::initialize: Updating SD card state file failed" << std::endl; + } #if Q7S_SD_CARD_CONFIG == Q7S_SD_NONE - sif::info << "No SD card initialization will be performed" << std::endl; - return HasReturnvaluesIF::RETURN_OK; + sif::info << "No SD card initialization will be performed" << std::endl; + return HasReturnvaluesIF::RETURN_OK; #else - result = sdcMan->getSdCardActiveStatus(sdInfo.currentState); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Getting SD card activity status failed" << std::endl; - } + result = sdcMan->getSdCardActiveStatus(sdInfo.currentState); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Getting SD card activity status failed" << std::endl; + } #if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT - determinePreferredSdCard(); - updateSdInfoOther(); - sif::info << "Cold redundant SD card configuration, preferred SD card: " << - static_cast(sdInfo.pref) << std::endl; - result = sdColdRedundantBlockingInit(); - // Update status file - sdcMan->updateSdCardStateFile(); - return result; + determinePreferredSdCard(); + updateSdInfoOther(); + sif::info << "Cold redundant SD card configuration, preferred SD card: " + << static_cast(sdInfo.pref) << std::endl; + result = sdColdRedundantBlockingInit(); + // Update status file + sdcMan->updateSdCardStateFile(); + return result; #elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT - sif::info << "Hot redundant SD card configuration" << std::endl; - sdCardSetup(sd::SdCard::SLOT_0, sd::SdState::MOUNTED, "0", false); - sdCardSetup(sd::SdCard::SLOT_1, sd::SdState::MOUNTED, "1", false); - // Update status file - sdcMan->updateSdCardStateFile(); - return HasReturnvaluesIF::RETURN_OK; + sif::info << "Hot redundant SD card configuration" << std::endl; + sdCardSetup(sd::SdCard::SLOT_0, sd::SdState::MOUNTED, "0", false); + sdCardSetup(sd::SdCard::SLOT_1, sd::SdState::MOUNTED, "1", false); + // Update status file + sdcMan->updateSdCardStateFile(); + return HasReturnvaluesIF::RETURN_OK; #endif #endif /* Q7S_SD_CARD_CONFIG != Q7S_SD_NONE */ - } ReturnValue_t CoreController::sdStateMachine() { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - SdCardManager::Operations operation; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + SdCardManager::Operations operation; - if(sdInfo.state == SdStates::IDLE) { - // Nothing to do - return result; - } + if (sdInfo.state == SdStates::IDLE) { + // Nothing to do + return result; + } - if(sdInfo.state == SdStates::START) { - // Init will be performed by separate function - if(BLOCKING_SD_INIT) { - sdInfo.state = SdStates::IDLE; - sdInfo.initFinished = true; - return result; - } - else { - // Still update SD state file + if (sdInfo.state == SdStates::START) { + // Init will be performed by separate function + if (BLOCKING_SD_INIT) { + sdInfo.state = SdStates::IDLE; + sdInfo.initFinished = true; + return result; + } else { + // Still update SD state file #if Q7S_SD_CARD_CONFIG == Q7S_SD_NONE - sdInfo.state = SdStates::UPDATE_INFO; + sdInfo.state = SdStates::UPDATE_INFO; #else - sdInfo.cycleCount = 0; - sdInfo.commandExecuted = false; - sdInfo.state = SdStates::GET_INFO; + sdInfo.cycleCount = 0; + sdInfo.commandExecuted = false; + sdInfo.state = SdStates::GET_INFO; #endif - } } + } - // This lambda checks the non-blocking operation and assigns the new state on success. - // It returns true for an operation success and false otherwise - auto nonBlockingOpChecking = [&](SdStates newStateOnSuccess, - uint16_t maxCycleCount, std::string opPrintout) { - SdCardManager::OpStatus status = sdcMan->checkCurrentOp(operation); - if(status == SdCardManager::OpStatus::SUCCESS) { - sdInfo.state = newStateOnSuccess; - sdInfo.commandExecuted = false; - sdInfo.cycleCount = 0; - return true; - } - else if(sdInfo.cycleCount > 4) { - sif::warning << "CoreController::sdInitStateMachine: " << opPrintout << - " takes too long" << std::endl; - return false; - } - return false; - }; - - if(sdInfo.state == SdStates::GET_INFO) { - if(not sdInfo.commandExecuted) { - // Create update status file - result = sdcMan->updateSdCardStateFile(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::initialize: Updating SD card state file failed" - << std::endl; - } - sdInfo.commandExecuted = true; - } - else { - nonBlockingOpChecking(SdStates::SET_STATE_SELF, 4, "Updating SDC file"); - } + // This lambda checks the non-blocking operation and assigns the new state on success. + // It returns true for an operation success and false otherwise + auto nonBlockingOpChecking = [&](SdStates newStateOnSuccess, uint16_t maxCycleCount, + std::string opPrintout) { + SdCardManager::OpStatus status = sdcMan->checkCurrentOp(operation); + if (status == SdCardManager::OpStatus::SUCCESS) { + sdInfo.state = newStateOnSuccess; + sdInfo.commandExecuted = false; + sdInfo.cycleCount = 0; + return true; + } else if (sdInfo.cycleCount > 4) { + sif::warning << "CoreController::sdInitStateMachine: " << opPrintout << " takes too long" + << std::endl; + return false; } + return false; + }; - if(sdInfo.state == SdStates::SET_STATE_SELF) { - if(not sdInfo.commandExecuted) { - result = sdcMan->getSdCardActiveStatus(sdInfo.currentState); - determinePreferredSdCard(); - updateSdInfoOther(); - if(sdInfo.pref != sd::SdCard::SLOT_0 and sdInfo.pref != sd::SdCard::SLOT_1) { - sif::warning << "Preferred SD card invalid. Setting to card 0.." << std::endl; - sdInfo.pref = sd::SdCard::SLOT_0; - } - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Getting SD card activity status failed" << std::endl; - } + if (sdInfo.state == SdStates::GET_INFO) { + if (not sdInfo.commandExecuted) { + // Create update status file + result = sdcMan->updateSdCardStateFile(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::initialize: Updating SD card state file failed" + << std::endl; + } + sdInfo.commandExecuted = true; + } else { + nonBlockingOpChecking(SdStates::SET_STATE_SELF, 4, "Updating SDC file"); + } + } + + if (sdInfo.state == SdStates::SET_STATE_SELF) { + if (not sdInfo.commandExecuted) { + result = sdcMan->getSdCardActiveStatus(sdInfo.currentState); + determinePreferredSdCard(); + updateSdInfoOther(); + if (sdInfo.pref != sd::SdCard::SLOT_0 and sdInfo.pref != sd::SdCard::SLOT_1) { + sif::warning << "Preferred SD card invalid. Setting to card 0.." << std::endl; + sdInfo.pref = sd::SdCard::SLOT_0; + } + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Getting SD card activity status failed" << std::endl; + } #if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT - sif::info << "Cold redundant SD card configuration, preferred SD card: " << - static_cast(sdInfo.pref) << std::endl; + sif::info << "Cold redundant SD card configuration, preferred SD card: " + << static_cast(sdInfo.pref) << std::endl; #endif - if(sdInfo.prefState == sd::SdState::MOUNTED) { + if (sdInfo.prefState == sd::SdState::MOUNTED) { #if OBSW_VERBOSE_LEVEL >= 1 - std::string mountString; - if(sdInfo.pref == sd::SdCard::SLOT_0) { - mountString = SdCardManager::SD_0_MOUNT_POINT; - } - else { - mountString = SdCardManager::SD_1_MOUNT_POINT; - } - sif::info << "SD card " << sdInfo.prefChar << " already on and mounted at " << - mountString << std::endl; + std::string mountString; + if (sdInfo.pref == sd::SdCard::SLOT_0) { + mountString = SdCardManager::SD_0_MOUNT_POINT; + } else { + mountString = SdCardManager::SD_1_MOUNT_POINT; + } + sif::info << "SD card " << sdInfo.prefChar << " already on and mounted at " << mountString + << std::endl; #endif - sdInfo.state = SdStates::DETERMINE_OTHER; - } - else if(sdInfo.prefState == sd::SdState::OFF) { - sdCardSetup(sdInfo.pref, sd::SdState::ON, sdInfo.prefChar, false); - sdInfo.commandExecuted = true; - } - else if(sdInfo.prefState == sd::SdState::ON) { - sdInfo.state = SdStates::MOUNT_SELF; - } - } - else { - if(nonBlockingOpChecking(SdStates::MOUNT_SELF, 10, "Setting SDC state")) { - sdInfo.prefState = sd::SdState::ON; - currentStateSetter(sdInfo.pref, sd::SdState::ON); - } - } + sdInfo.state = SdStates::DETERMINE_OTHER; + } else if (sdInfo.prefState == sd::SdState::OFF) { + sdCardSetup(sdInfo.pref, sd::SdState::ON, sdInfo.prefChar, false); + sdInfo.commandExecuted = true; + } else if (sdInfo.prefState == sd::SdState::ON) { + sdInfo.state = SdStates::MOUNT_SELF; + } + } else { + if (nonBlockingOpChecking(SdStates::MOUNT_SELF, 10, "Setting SDC state")) { + sdInfo.prefState = sd::SdState::ON; + currentStateSetter(sdInfo.pref, sd::SdState::ON); + } } + } - if(sdInfo.state == SdStates::MOUNT_SELF) { - if(not sdInfo.commandExecuted) { - result = sdCardSetup(sdInfo.pref, sd::SdState::MOUNTED, sdInfo.prefChar); - sdInfo.commandExecuted = true; - } - else { - if(nonBlockingOpChecking(SdStates::DETERMINE_OTHER, 5, "Mounting SD card")) { - sdInfo.prefState = sd::SdState::MOUNTED; - currentStateSetter(sdInfo.pref, sd::SdState::MOUNTED); - } - } + if (sdInfo.state == SdStates::MOUNT_SELF) { + if (not sdInfo.commandExecuted) { + result = sdCardSetup(sdInfo.pref, sd::SdState::MOUNTED, sdInfo.prefChar); + sdInfo.commandExecuted = true; + } else { + if (nonBlockingOpChecking(SdStates::DETERMINE_OTHER, 5, "Mounting SD card")) { + sdInfo.prefState = sd::SdState::MOUNTED; + currentStateSetter(sdInfo.pref, sd::SdState::MOUNTED); + } } + } - if(sdInfo.state == SdStates::DETERMINE_OTHER) { - // Determine whether any additional operations have to be done for the other SD card - // 1. Cold redundant case: Other SD card needs to be unmounted and switched off - // 2. Hot redundant case: Other SD card needs to be mounted and switched on + if (sdInfo.state == SdStates::DETERMINE_OTHER) { + // Determine whether any additional operations have to be done for the other SD card + // 1. Cold redundant case: Other SD card needs to be unmounted and switched off + // 2. Hot redundant case: Other SD card needs to be mounted and switched on #if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT - if(sdInfo.otherState == sd::SdState::ON) { - sdInfo.state = SdStates::SET_STATE_OTHER; - } - else if(sdInfo.otherState == sd::SdState::MOUNTED) { - sdInfo.state = SdStates::MOUNT_UNMOUNT_OTHER; - } - else { - // Is already off, update info, but with a small delay - sdInfo.state = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE; - } -#elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT - if(sdInfo.otherState == sd::SdState::OFF) { - sdInfo.state = SdStates::SET_STATE_OTHER; - } - else if(sdInfo.otherState == sd::SdState::ON) { - sdInfo.state = SdStates::MOUNT_UNMOUNT_OTHER; - } - else { - // Is already on and mounted, update info - sdInfo.state = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE; - } -#endif + if (sdInfo.otherState == sd::SdState::ON) { + sdInfo.state = SdStates::SET_STATE_OTHER; + } else if (sdInfo.otherState == sd::SdState::MOUNTED) { + sdInfo.state = SdStates::MOUNT_UNMOUNT_OTHER; + } else { + // Is already off, update info, but with a small delay + sdInfo.state = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE; } +#elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT + if (sdInfo.otherState == sd::SdState::OFF) { + sdInfo.state = SdStates::SET_STATE_OTHER; + } else if (sdInfo.otherState == sd::SdState::ON) { + sdInfo.state = SdStates::MOUNT_UNMOUNT_OTHER; + } else { + // Is already on and mounted, update info + sdInfo.state = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE; + } +#endif + } - if(sdInfo.state == SdStates::SET_STATE_OTHER) { - // Set state of other SD card to ON or OFF, depending on redundancy mode + if (sdInfo.state == SdStates::SET_STATE_OTHER) { + // Set state of other SD card to ON or OFF, depending on redundancy mode #if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT - if(not sdInfo.commandExecuted) { - result = sdCardSetup(sdInfo.other, sd::SdState::OFF, sdInfo.otherChar, false); - sdInfo.commandExecuted = true; - } - else { - if(nonBlockingOpChecking(SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE, 10, - "Switching off other SD card")) { - sdInfo.otherState = sd::SdState::OFF; - currentStateSetter(sdInfo.other, sd::SdState::OFF); - } - } -#elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT - if(not sdInfo.commandExecuted) { - result = sdCardSetup(sdInfo.other, sd::SdState::ON, sdInfo.otherChar, false); - sdInfo.commandExecuted = true; - } - else { - if(nonBlockingOpChecking(SdStates::MOUNT_UNMOUNT_OTHER, 10, - "Switching on other SD card")) { - sdInfo.otherState = sd::SdState::ON; - currentStateSetter(sdInfo.other, sd::SdState::ON); - } - } -#endif + if (not sdInfo.commandExecuted) { + result = sdCardSetup(sdInfo.other, sd::SdState::OFF, sdInfo.otherChar, false); + sdInfo.commandExecuted = true; + } else { + if (nonBlockingOpChecking(SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE, 10, + "Switching off other SD card")) { + sdInfo.otherState = sd::SdState::OFF; + currentStateSetter(sdInfo.other, sd::SdState::OFF); + } } +#elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT + if (not sdInfo.commandExecuted) { + result = sdCardSetup(sdInfo.other, sd::SdState::ON, sdInfo.otherChar, false); + sdInfo.commandExecuted = true; + } else { + if (nonBlockingOpChecking(SdStates::MOUNT_UNMOUNT_OTHER, 10, "Switching on other SD card")) { + sdInfo.otherState = sd::SdState::ON; + currentStateSetter(sdInfo.other, sd::SdState::ON); + } + } +#endif + } - if(sdInfo.state == SdStates::MOUNT_UNMOUNT_OTHER) { - // Mount or unmount other SD card, depending on redundancy mode + if (sdInfo.state == SdStates::MOUNT_UNMOUNT_OTHER) { + // Mount or unmount other SD card, depending on redundancy mode #if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT - if(not sdInfo.commandExecuted) { - result = sdCardSetup(sdInfo.other, sd::SdState::ON, sdInfo.otherChar); - sdInfo.commandExecuted = true; - } - else { - if(nonBlockingOpChecking(SdStates::SET_STATE_OTHER, 10, "Unmounting other SD card")) { - sdInfo.otherState = sd::SdState::ON; - currentStateSetter(sdInfo.other, sd::SdState::ON); - } - } + if (not sdInfo.commandExecuted) { + result = sdCardSetup(sdInfo.other, sd::SdState::ON, sdInfo.otherChar); + sdInfo.commandExecuted = true; + } else { + if (nonBlockingOpChecking(SdStates::SET_STATE_OTHER, 10, "Unmounting other SD card")) { + sdInfo.otherState = sd::SdState::ON; + currentStateSetter(sdInfo.other, sd::SdState::ON); + } + } #elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT - if(not sdInfo.commandExecuted) { - result = sdCardSetup(sdInfo.other, sd::SdState::MOUNTED, sdInfo.otherChar); - sdInfo.commandExecuted = true; - } - else { - if(nonBlockingOpChecking(SdStates::UPDATE_INFO, 4, "Mounting other SD card")) { - sdInfo.otherState = sd::SdState::MOUNTED; - currentStateSetter(sdInfo.other, sd::SdState::MOUNTED); - } - } + if (not sdInfo.commandExecuted) { + result = sdCardSetup(sdInfo.other, sd::SdState::MOUNTED, sdInfo.otherChar); + sdInfo.commandExecuted = true; + } else { + if (nonBlockingOpChecking(SdStates::UPDATE_INFO, 4, "Mounting other SD card")) { + sdInfo.otherState = sd::SdState::MOUNTED; + currentStateSetter(sdInfo.other, sd::SdState::MOUNTED); + } + } #endif - } + } - if(sdInfo.state == SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE) { - sdInfo.state = SdStates::UPDATE_INFO; + if (sdInfo.state == SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE) { + sdInfo.state = SdStates::UPDATE_INFO; + } else if (sdInfo.state == SdStates::UPDATE_INFO) { + // It is assumed that all tasks are running by the point this section is reached. + // Therefore, perform this operation in blocking mode because it does not take long + // and the ready state of the SD card is available sooner + sdcMan->setBlocking(true); + // Update status file + result = sdcMan->updateSdCardStateFile(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::initialize: Updating SD card state file failed" << std::endl; } - else if(sdInfo.state == SdStates::UPDATE_INFO) { - // It is assumed that all tasks are running by the point this section is reached. - // Therefore, perform this operation in blocking mode because it does not take long - // and the ready state of the SD card is available sooner - sdcMan->setBlocking(true); - // Update status file - result = sdcMan->updateSdCardStateFile(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::initialize: Updating SD card state file failed" - << std::endl; - } - sdInfo.commandExecuted = false; - sdInfo.state = SdStates::IDLE; - sdInfo.cycleCount = 0; - sdcMan->setBlocking(false); - sdcMan->getSdCardActiveStatus(sdInfo.currentState); - if(not sdInfo.initFinished) { - updateSdInfoOther(); - sdInfo.initFinished = true; - sif::info << "SD card initialization finished" << std::endl; - } + sdInfo.commandExecuted = false; + sdInfo.state = SdStates::IDLE; + sdInfo.cycleCount = 0; + sdcMan->setBlocking(false); + sdcMan->getSdCardActiveStatus(sdInfo.currentState); + if (not sdInfo.initFinished) { + updateSdInfoOther(); + sdInfo.initFinished = true; + sif::info << "SD card initialization finished" << std::endl; } + } - if(sdInfo.state == SdStates::SET_STATE_FROM_COMMAND) { - if(not sdInfo.commandExecuted) { - executeNextExternalSdCommand(); - } - else { - checkExternalSdCommandStatus(); - } + if (sdInfo.state == SdStates::SET_STATE_FROM_COMMAND) { + if (not sdInfo.commandExecuted) { + executeNextExternalSdCommand(); + } else { + checkExternalSdCommandStatus(); } + } - sdInfo.cycleCount++; - return HasReturnvaluesIF::RETURN_OK; + sdInfo.cycleCount++; + return HasReturnvaluesIF::RETURN_OK; } void CoreController::executeNextExternalSdCommand() { - std::string sdChar; - sd::SdState currentStateOfCard = sd::SdState::OFF; - if(sdInfo.commandedCard == sd::SdCard::SLOT_0) { - sdChar = "0"; - currentStateOfCard = sdInfo.currentState.first; + std::string sdChar; + sd::SdState currentStateOfCard = sd::SdState::OFF; + if (sdInfo.commandedCard == sd::SdCard::SLOT_0) { + sdChar = "0"; + currentStateOfCard = sdInfo.currentState.first; + } else { + sdChar = "1"; + currentStateOfCard = sdInfo.currentState.second; + } + if (currentStateOfCard == sd::SdState::OFF) { + if (sdInfo.commandedState == sd::SdState::ON) { + sdInfo.currentlyCommandedState = sdInfo.commandedState; + } else if (sdInfo.commandedState == sd::SdState::MOUNTED) { + sdInfo.currentlyCommandedState = sd::SdState::ON; + } else { + // SD card is already on target state + sdInfo.commandFinished = true; + sdInfo.state = SdStates::IDLE; } - else { - sdChar = "1"; - currentStateOfCard = sdInfo.currentState.second; + } else if (currentStateOfCard == sd::SdState::ON) { + if (sdInfo.commandedState == sd::SdState::OFF or + sdInfo.commandedState == sd::SdState::MOUNTED) { + sdInfo.currentlyCommandedState = sdInfo.commandedState; + } else { + // Already on target state + sdInfo.commandFinished = true; + sdInfo.state = SdStates::IDLE; } - if(currentStateOfCard == sd::SdState::OFF) { - if(sdInfo.commandedState == sd::SdState::ON) { - sdInfo.currentlyCommandedState = sdInfo.commandedState; - } - else if(sdInfo.commandedState == sd::SdState::MOUNTED) { - sdInfo.currentlyCommandedState = sd::SdState::ON; - } - else { - // SD card is already on target state - sdInfo.commandFinished = true; - sdInfo.state = SdStates::IDLE; - } + } else if (currentStateOfCard == sd::SdState::MOUNTED) { + if (sdInfo.commandedState == sd::SdState::ON) { + sdInfo.currentlyCommandedState = sdInfo.commandedState; + } else if (sdInfo.commandedState == sd::SdState::OFF) { + // This causes an unmount in sdCardSetup + sdInfo.currentlyCommandedState = sd::SdState::ON; + } else { + sdInfo.commandFinished = true; } - else if(currentStateOfCard == sd::SdState::ON) { - if(sdInfo.commandedState == sd::SdState::OFF or - sdInfo.commandedState == sd::SdState::MOUNTED) { - sdInfo.currentlyCommandedState = sdInfo.commandedState; - } - else { - // Already on target state - sdInfo.commandFinished = true; - sdInfo.state = SdStates::IDLE; - } - } - else if(currentStateOfCard == sd::SdState::MOUNTED) { - if(sdInfo.commandedState == sd::SdState::ON) { - sdInfo.currentlyCommandedState = sdInfo.commandedState; - } - else if(sdInfo.commandedState == sd::SdState::OFF) { - // This causes an unmount in sdCardSetup - sdInfo.currentlyCommandedState = sd::SdState::ON; - } - else { - sdInfo.commandFinished = true; - } - } - sdCardSetup(sdInfo.commandedCard, sdInfo.commandedState, sdChar); - sdInfo.commandExecuted = true; + } + sdCardSetup(sdInfo.commandedCard, sdInfo.commandedState, sdChar); + sdInfo.commandExecuted = true; } void CoreController::checkExternalSdCommandStatus() { - SdCardManager::Operations operation; - SdCardManager::OpStatus status = sdcMan->checkCurrentOp(operation); - if(status == SdCardManager::OpStatus::SUCCESS) { - if(sdInfo.currentlyCommandedState == sdInfo.commandedState) { - sdInfo.state = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE; - sdInfo.commandFinished = true; - } - else { - // stay on same state machine state because the target state was not reached yet. - sdInfo.cycleCount = 0; - } - currentStateSetter(sdInfo.commandedCard, sdInfo.currentlyCommandedState); - sdInfo.commandExecuted = false; - } - else if(sdInfo.cycleCount > 4) { - sif::warning << "CoreController::sdStateMachine: Commanding SD state " - "takes too long" << std::endl; + SdCardManager::Operations operation; + SdCardManager::OpStatus status = sdcMan->checkCurrentOp(operation); + if (status == SdCardManager::OpStatus::SUCCESS) { + if (sdInfo.currentlyCommandedState == sdInfo.commandedState) { + sdInfo.state = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE; + sdInfo.commandFinished = true; + } else { + // stay on same state machine state because the target state was not reached yet. + sdInfo.cycleCount = 0; } + currentStateSetter(sdInfo.commandedCard, sdInfo.currentlyCommandedState); + sdInfo.commandExecuted = false; + } else if (sdInfo.cycleCount > 4) { + sif::warning << "CoreController::sdStateMachine: Commanding SD state " + "takes too long" + << std::endl; + } } void CoreController::currentStateSetter(sd::SdCard sdCard, sd::SdState newState) { - if(sdCard == sd::SdCard::SLOT_0) { - sdInfo.currentState.first = newState; - } - else { - sdInfo.currentState.second = newState; - } + if (sdCard == sd::SdCard::SLOT_0) { + sdInfo.currentState.first = newState; + } else { + sdInfo.currentState.second = newState; + } } ReturnValue_t CoreController::sdCardSetup(sd::SdCard sdCard, sd::SdState targetState, - std::string sdChar, bool printOutput) { - std::string mountString; - sdcMan->setPrintCommandOutput(printOutput); - if(sdCard == sd::SdCard::SLOT_0) { - mountString = SdCardManager::SD_0_MOUNT_POINT; - } - else { - mountString = SdCardManager::SD_1_MOUNT_POINT; - } + std::string sdChar, bool printOutput) { + std::string mountString; + sdcMan->setPrintCommandOutput(printOutput); + if (sdCard == sd::SdCard::SLOT_0) { + mountString = SdCardManager::SD_0_MOUNT_POINT; + } else { + mountString = SdCardManager::SD_1_MOUNT_POINT; + } - sd::SdState state = sd::SdState::OFF; - if(sdCard == sd::SdCard::SLOT_0) { - state = sdInfo.currentState.first; - } - else { - state = sdInfo.currentState.second; - } - if(state == sd::SdState::MOUNTED) { - if(targetState == sd::SdState::OFF) { - sif::info << "Switching off SD card " << sdChar << std::endl; - return sdcMan->switchOffSdCard(sdCard, true, &sdInfo.currentState); - } - else if(targetState == sd::SdState::ON) { - sif::info << "Unmounting SD card " << sdChar << std::endl; - return sdcMan->unmountSdCard(sdCard); - } - else { - if(std::filesystem::exists(mountString)) { - sif::info << "SD card " << sdChar << " already on and mounted at " << - mountString << std::endl; - return SdCardManager::ALREADY_MOUNTED; - } - sif::error << "SD card mounted but expected mount point " << - mountString << " not found!" << std::endl; - return SdCardManager::MOUNT_ERROR; - } + sd::SdState state = sd::SdState::OFF; + if (sdCard == sd::SdCard::SLOT_0) { + state = sdInfo.currentState.first; + } else { + state = sdInfo.currentState.second; + } + if (state == sd::SdState::MOUNTED) { + if (targetState == sd::SdState::OFF) { + sif::info << "Switching off SD card " << sdChar << std::endl; + return sdcMan->switchOffSdCard(sdCard, true, &sdInfo.currentState); + } else if (targetState == sd::SdState::ON) { + sif::info << "Unmounting SD card " << sdChar << std::endl; + return sdcMan->unmountSdCard(sdCard); + } else { + if (std::filesystem::exists(mountString)) { + sif::info << "SD card " << sdChar << " already on and mounted at " << mountString + << std::endl; + return SdCardManager::ALREADY_MOUNTED; + } + sif::error << "SD card mounted but expected mount point " << mountString << " not found!" + << std::endl; + return SdCardManager::MOUNT_ERROR; } + } - if(state == sd::SdState::OFF) { - if(targetState == sd::SdState::MOUNTED) { - sif::info << "Switching on and mounting SD card " << sdChar << " at " << - mountString << std::endl; - return sdcMan->switchOnSdCard(sdCard, true, &sdInfo.currentState); - } - else if(targetState == sd::SdState::ON) { - sif::info << "Switching on SD card " << sdChar << std::endl; - return sdcMan->switchOnSdCard(sdCard, false, &sdInfo.currentState); - } + if (state == sd::SdState::OFF) { + if (targetState == sd::SdState::MOUNTED) { + sif::info << "Switching on and mounting SD card " << sdChar << " at " << mountString + << std::endl; + return sdcMan->switchOnSdCard(sdCard, true, &sdInfo.currentState); + } else if (targetState == sd::SdState::ON) { + sif::info << "Switching on SD card " << sdChar << std::endl; + return sdcMan->switchOnSdCard(sdCard, false, &sdInfo.currentState); } + } - else if(state == sd::SdState::ON) { - if(targetState == sd::SdState::MOUNTED) { - sif::info << "Mounting SD card " << sdChar << " at " << mountString << std::endl; - return sdcMan->mountSdCard(sdCard); - } - else if(targetState == sd::SdState::OFF) { - sif::info << "Switching off SD card " << sdChar << std::endl; - return sdcMan->switchOffSdCard(sdCard, false, &sdInfo.currentState); - } + else if (state == sd::SdState::ON) { + if (targetState == sd::SdState::MOUNTED) { + sif::info << "Mounting SD card " << sdChar << " at " << mountString << std::endl; + return sdcMan->mountSdCard(sdCard); + } else if (targetState == sd::SdState::OFF) { + sif::info << "Switching off SD card " << sdChar << std::endl; + return sdcMan->switchOffSdCard(sdCard, false, &sdInfo.currentState); } - else { - sif::warning << "CoreController::sdCardSetup: Invalid state for this call" << std::endl; - } - return HasReturnvaluesIF::RETURN_OK; + } else { + sif::warning << "CoreController::sdCardSetup: Invalid state for this call" << std::endl; + } + return HasReturnvaluesIF::RETURN_OK; } - ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t *data, size_t size) { - switch(actionId) { - case(LIST_DIRECTORY_INTO_FILE): { - return actionListDirectoryIntoFile(actionId, commandedBy, data, size); + const uint8_t *data, size_t size) { + switch (actionId) { + case (LIST_DIRECTORY_INTO_FILE): { + return actionListDirectoryIntoFile(actionId, commandedBy, data, size); } - case(REBOOT_OBC): { - return actionPerformReboot(data, size); + case (REBOOT_OBC): { + return actionPerformReboot(data, size); } default: { - return HasActionsIF::INVALID_ACTION_ID; - } + return HasActionsIF::INVALID_ACTION_ID; } + } } ReturnValue_t CoreController::sdColdRedundantBlockingInit() { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - result = sdCardSetup(sdInfo.pref, sd::SdState::MOUNTED, sdInfo.prefChar); - if(result != SdCardManager::ALREADY_MOUNTED and result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Setting up preferred card " << sdInfo.otherChar << - " in cold redundant mode failed" << std::endl; - // Try other SD card and mark set up operation as failed - sdCardSetup(sdInfo.pref, sd::SdState::MOUNTED, sdInfo.prefChar); - result = HasReturnvaluesIF::RETURN_FAILED; - } + result = sdCardSetup(sdInfo.pref, sd::SdState::MOUNTED, sdInfo.prefChar); + if (result != SdCardManager::ALREADY_MOUNTED and result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Setting up preferred card " << sdInfo.otherChar + << " in cold redundant mode failed" << std::endl; + // Try other SD card and mark set up operation as failed + sdCardSetup(sdInfo.pref, sd::SdState::MOUNTED, sdInfo.prefChar); + result = HasReturnvaluesIF::RETURN_FAILED; + } - if(result != HasReturnvaluesIF::RETURN_FAILED and sdInfo.otherState != sd::SdState::OFF) { - sif::info << "Switching off secondary SD card " << sdInfo.otherChar << std::endl; - // Switch off other SD card in cold redundant mode if setting up preferred one worked - // without issues - ReturnValue_t result2 = sdcMan->switchOffSdCard(sdInfo.other, - sdInfo.otherState, &sdInfo.currentState); - if(result2 != HasReturnvaluesIF::RETURN_OK and result2 != SdCardManager::ALREADY_OFF) { - sif::warning << "Switching off secondary SD card " << sdInfo.otherChar << - " in cold redundant mode failed" << std::endl; - } + if (result != HasReturnvaluesIF::RETURN_FAILED and sdInfo.otherState != sd::SdState::OFF) { + sif::info << "Switching off secondary SD card " << sdInfo.otherChar << std::endl; + // Switch off other SD card in cold redundant mode if setting up preferred one worked + // without issues + ReturnValue_t result2 = + sdcMan->switchOffSdCard(sdInfo.other, sdInfo.otherState, &sdInfo.currentState); + if (result2 != HasReturnvaluesIF::RETURN_OK and result2 != SdCardManager::ALREADY_OFF) { + sif::warning << "Switching off secondary SD card " << sdInfo.otherChar + << " in cold redundant mode failed" << std::endl; } - return result; + } + return result; } ReturnValue_t CoreController::incrementAllocationFailureCount() { - uint32_t count = 0; - ReturnValue_t result = scratch::readNumber(scratch::ALLOC_FAILURE_COUNT, count); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - count++; - return scratch::writeNumber(scratch::ALLOC_FAILURE_COUNT, count); + uint32_t count = 0; + ReturnValue_t result = scratch::readNumber(scratch::ALLOC_FAILURE_COUNT, count); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + count++; + return scratch::writeNumber(scratch::ALLOC_FAILURE_COUNT, count); } ReturnValue_t CoreController::initVersionFile() { + std::string unameFileName = "/tmp/uname_version.txt"; + // TODO: No -v flag for now. If the kernel version is used, need to cut off first few letters + std::string unameCmd = "uname -mnrso > " + unameFileName; + int result = std::system(unameCmd.c_str()); + if (result != 0) { + utility::handleSystemError(result, "CoreController::versionFileInit"); + } + std::ifstream unameFile(unameFileName); + std::string unameLine; + if (not std::getline(unameFile, unameLine)) { + sif::warning << "CoreController::versionFileInit: Retrieving uname line failed" << std::endl; + } - std::string unameFileName = "/tmp/uname_version.txt"; - // TODO: No -v flag for now. If the kernel version is used, need to cut off first few letters - std::string unameCmd = "uname -mnrso > " + unameFileName; - int result = std::system(unameCmd.c_str()); - if(result != 0) { - utility::handleSystemError(result, "CoreController::versionFileInit"); - } - std::ifstream unameFile(unameFileName); - std::string unameLine; - if(not std::getline(unameFile, unameLine)) { - sif::warning << "CoreController::versionFileInit: Retrieving uname line failed" - << std::endl; - } - - std::string fullObswVersionString = "OBSW: v" + std::to_string(SW_VERSION) + "." + - std::to_string(SW_SUBVERSION) + "." + std::to_string(SW_REVISION); - std::string fullFsfwVersionString = "FSFW: v" + std::to_string(FSFW_VERSION) + "." + - std::to_string(FSFW_SUBVERSION) + "." + std::to_string(FSFW_REVISION); - std::string systemString = "System: " + unameLine; - std::string mountPrefix = SdCardManager::instance()->getCurrentMountPrefix(); - std::string versionFilePath = mountPrefix + VERSION_FILE; - std::fstream versionFile; - - if(not std::filesystem::exists(versionFilePath)) { - sif::info << "Writing version file " << versionFilePath << ".." << std::endl; - versionFile.open(versionFilePath, std::ios_base::out); - versionFile << fullObswVersionString << std::endl; - versionFile << fullFsfwVersionString << std::endl; - versionFile << systemString << std::endl; - return HasReturnvaluesIF::RETURN_OK; - } - - // Check whether any version has changed - bool createNewFile = false; - versionFile.open(versionFilePath); - std::string currentVersionString; - uint8_t idx = 0; - while(std::getline(versionFile, currentVersionString)) { - if(idx == 0) { - if(currentVersionString != fullObswVersionString) { - sif::info << "OBSW version changed" << std::endl; - sif::info << "From " << currentVersionString << " to " << - fullObswVersionString << std::endl; - createNewFile = true; - } - } - else if(idx == 1) { - if(currentVersionString != fullFsfwVersionString) { - sif::info << "FSFW version changed" << std::endl; - sif::info << "From " << currentVersionString << " to " << - fullFsfwVersionString << std::endl; - createNewFile = true; - } - } - else if(idx == 2) { - if(currentVersionString != systemString) { - sif::info << "System version changed" << std::endl; - sif::info << "Old: " << currentVersionString << std::endl; - sif::info << "New: " << systemString << std::endl; - createNewFile = true; - } - } - else { - sif::warning << "Invalid version file! Rewriting it.." << std::endl; - createNewFile = true; - } - idx++; - } - - // Overwrite file if necessary - if(createNewFile) { - sif::info << "Rewriting version.txt file with updated versions.." << std::endl; - versionFile.close(); - versionFile.open(versionFilePath, std::ios_base::out | std::ios_base::trunc); - versionFile << fullObswVersionString << std::endl; - versionFile << fullFsfwVersionString << std::endl; - versionFile << systemString << std::endl; - } + std::string fullObswVersionString = "OBSW: v" + std::to_string(SW_VERSION) + "." + + std::to_string(SW_SUBVERSION) + "." + + std::to_string(SW_REVISION); + std::string fullFsfwVersionString = "FSFW: v" + std::to_string(FSFW_VERSION) + "." + + std::to_string(FSFW_SUBVERSION) + "." + + std::to_string(FSFW_REVISION); + std::string systemString = "System: " + unameLine; + std::string mountPrefix = SdCardManager::instance()->getCurrentMountPrefix(); + std::string versionFilePath = mountPrefix + VERSION_FILE; + std::fstream versionFile; + if (not std::filesystem::exists(versionFilePath)) { + sif::info << "Writing version file " << versionFilePath << ".." << std::endl; + versionFile.open(versionFilePath, std::ios_base::out); + versionFile << fullObswVersionString << std::endl; + versionFile << fullFsfwVersionString << std::endl; + versionFile << systemString << std::endl; return HasReturnvaluesIF::RETURN_OK; + } + + // Check whether any version has changed + bool createNewFile = false; + versionFile.open(versionFilePath); + std::string currentVersionString; + uint8_t idx = 0; + while (std::getline(versionFile, currentVersionString)) { + if (idx == 0) { + if (currentVersionString != fullObswVersionString) { + sif::info << "OBSW version changed" << std::endl; + sif::info << "From " << currentVersionString << " to " << fullObswVersionString + << std::endl; + createNewFile = true; + } + } else if (idx == 1) { + if (currentVersionString != fullFsfwVersionString) { + sif::info << "FSFW version changed" << std::endl; + sif::info << "From " << currentVersionString << " to " << fullFsfwVersionString + << std::endl; + createNewFile = true; + } + } else if (idx == 2) { + if (currentVersionString != systemString) { + sif::info << "System version changed" << std::endl; + sif::info << "Old: " << currentVersionString << std::endl; + sif::info << "New: " << systemString << std::endl; + createNewFile = true; + } + } else { + sif::warning << "Invalid version file! Rewriting it.." << std::endl; + createNewFile = true; + } + idx++; + } + + // Overwrite file if necessary + if (createNewFile) { + sif::info << "Rewriting version.txt file with updated versions.." << std::endl; + versionFile.close(); + versionFile.open(versionFilePath, std::ios_base::out | std::ios_base::trunc); + versionFile << fullObswVersionString << std::endl; + versionFile << fullFsfwVersionString << std::endl; + versionFile << systemString << std::endl; + } + + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t CoreController::actionListDirectoryIntoFile(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t *data, size_t size) { - // TODO: Packet definition for clean deserialization - // 2 bytes for a and R flag, at least 5 bytes for minimum valid path /tmp with - // null termination, at least 7 bytes for minimum target file name /tmp/a with - // null termination. - if(size < 14) { - return HasActionsIF::INVALID_PARAMETERS; - } - // We could also make -l optional, but I can't think of a reason why to not use -l.. + MessageQueueId_t commandedBy, + const uint8_t *data, size_t size) { + // TODO: Packet definition for clean deserialization + // 2 bytes for a and R flag, at least 5 bytes for minimum valid path /tmp with + // null termination, at least 7 bytes for minimum target file name /tmp/a with + // null termination. + if (size < 14) { + return HasActionsIF::INVALID_PARAMETERS; + } + // We could also make -l optional, but I can't think of a reason why to not use -l.. - // This flag specifies to run ls with -a - bool aFlag = data[0]; - data += 1; - // This flag specifies to run ls with -R - bool RFlag = data[1]; - data += 1; + // This flag specifies to run ls with -a + bool aFlag = data[0]; + data += 1; + // This flag specifies to run ls with -R + bool RFlag = data[1]; + data += 1; - size_t remainingSize = size - 2; - // One larger for null termination, which prevents undefined behaviour if the sent - // strings are not 0 terminated properly - std::vector repoAndTargetFileBuffer(remainingSize + 1, 0); - std::memcpy(repoAndTargetFileBuffer.data(), data, remainingSize); - const char* currentCharPtr = reinterpret_cast(repoAndTargetFileBuffer.data()); - // Full target file name - std::string repoName(currentCharPtr); - size_t repoLength = repoName.length(); - // The other string needs to be at least one letter plus NULL termination to be valid at all - // The first string also needs to be NULL terminated, but the termination is not included - // in the string length, so this is subtracted from the remaining size as well - if(repoLength > remainingSize - 3) { - return HasActionsIF::INVALID_PARAMETERS; - } - // The file length will not include the NULL termination, so we skip it - currentCharPtr += repoLength + 1; - std::string targetFileName(currentCharPtr); - std::ostringstream oss; - oss << "ls -l"; - if(aFlag) { - oss << "a"; - } - if(RFlag) { - oss << "R"; - } + size_t remainingSize = size - 2; + // One larger for null termination, which prevents undefined behaviour if the sent + // strings are not 0 terminated properly + std::vector repoAndTargetFileBuffer(remainingSize + 1, 0); + std::memcpy(repoAndTargetFileBuffer.data(), data, remainingSize); + const char *currentCharPtr = reinterpret_cast(repoAndTargetFileBuffer.data()); + // Full target file name + std::string repoName(currentCharPtr); + size_t repoLength = repoName.length(); + // The other string needs to be at least one letter plus NULL termination to be valid at all + // The first string also needs to be NULL terminated, but the termination is not included + // in the string length, so this is subtracted from the remaining size as well + if (repoLength > remainingSize - 3) { + return HasActionsIF::INVALID_PARAMETERS; + } + // The file length will not include the NULL termination, so we skip it + currentCharPtr += repoLength + 1; + std::string targetFileName(currentCharPtr); + std::ostringstream oss; + oss << "ls -l"; + if (aFlag) { + oss << "a"; + } + if (RFlag) { + oss << "R"; + } - oss << " " << repoName << " > " << targetFileName; - int result = std::system(oss.str().c_str()); - if(result != 0) { - utility::handleSystemError(result, "CoreController::actionListDirectoryIntoFile"); - actionHelper.finish(false, commandedBy, actionId); - } - return HasReturnvaluesIF::RETURN_OK; + oss << " " << repoName << " > " << targetFileName; + int result = std::system(oss.str().c_str()); + if (result != 0) { + utility::handleSystemError(result, "CoreController::actionListDirectoryIntoFile"); + actionHelper.finish(false, commandedBy, actionId); + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t CoreController::initBootCopy() { - if(not std::filesystem::exists(CURR_COPY_FILE)) { - // Thils file is created by the systemd service eive-early-config so this should - // not happen normally - std::string cmd = "xsc_boot_copy > " + std::string(CURR_COPY_FILE); - int result = std::system(cmd.c_str()); - if(result != 0) { - utility::handleSystemError(result, "CoreController::initBootCopy"); - } + if (not std::filesystem::exists(CURR_COPY_FILE)) { + // Thils file is created by the systemd service eive-early-config so this should + // not happen normally + std::string cmd = "xsc_boot_copy > " + std::string(CURR_COPY_FILE); + int result = std::system(cmd.c_str()); + if (result != 0) { + utility::handleSystemError(result, "CoreController::initBootCopy"); } - std::ifstream file(CURR_COPY_FILE); - std::string line; - std::getline(file, line); - std::istringstream iss(line); - int value = 0; - iss >> value; - CURRENT_CHIP = static_cast(value); - iss >> value; - CURRENT_COPY = static_cast(value); - return HasReturnvaluesIF::RETURN_OK; + } + std::ifstream file(CURR_COPY_FILE); + std::string line; + std::getline(file, line); + std::istringstream iss(line); + int value = 0; + iss >> value; + CURRENT_CHIP = static_cast(value); + iss >> value; + CURRENT_COPY = static_cast(value); + return HasReturnvaluesIF::RETURN_OK; } void CoreController::getCurrentBootCopy(Chip &chip, Copy ©) { - // Not really thread-safe but it does not need to be - chip = CURRENT_CHIP; - copy = CURRENT_COPY; + // Not really thread-safe but it does not need to be + chip = CURRENT_CHIP; + copy = CURRENT_COPY; } ReturnValue_t CoreController::initWatchdogFifo() { - if(not std::filesystem::exists(watchdog::FIFO_NAME)) { - // Still return RETURN_OK for now - sif::info << "Watchdog FIFO " << watchdog::FIFO_NAME << " does not exist, can't initiate" << - " watchdog" << std::endl; - return HasReturnvaluesIF::RETURN_OK; - } - // Open FIFO write only and non-blocking to prevent SW from killing itself. - watchdogFifoFd = open(watchdog::FIFO_NAME.c_str(), O_WRONLY | O_NONBLOCK); - if(watchdogFifoFd < 0) { - if(errno == ENXIO) { - watchdogFifoFd = RETRY_FIFO_OPEN; - sif::info << "eive-watchdog not running. FIFO can not be opened" << std::endl; - } - else { - sif::error << "Opening pipe " << watchdog::FIFO_NAME << " write-only failed with " << - errno << ": " << strerror(errno) << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - } + if (not std::filesystem::exists(watchdog::FIFO_NAME)) { + // Still return RETURN_OK for now + sif::info << "Watchdog FIFO " << watchdog::FIFO_NAME << " does not exist, can't initiate" + << " watchdog" << std::endl; return HasReturnvaluesIF::RETURN_OK; + } + // Open FIFO write only and non-blocking to prevent SW from killing itself. + watchdogFifoFd = open(watchdog::FIFO_NAME.c_str(), O_WRONLY | O_NONBLOCK); + if (watchdogFifoFd < 0) { + if (errno == ENXIO) { + watchdogFifoFd = RETRY_FIFO_OPEN; + sif::info << "eive-watchdog not running. FIFO can not be opened" << std::endl; + } else { + sif::error << "Opening pipe " << watchdog::FIFO_NAME << " write-only failed with " << errno + << ": " << strerror(errno) << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + } + return HasReturnvaluesIF::RETURN_OK; } void CoreController::initPrint() { #if OBSW_VERBOSE_LEVEL >= 1 - if(watchdogFifoFd > 0) { - sif::info << "Opened watchdog FIFO successfully.." << std::endl; - } + if (watchdogFifoFd > 0) { + sif::info << "Opened watchdog FIFO successfully.." << std::endl; + } #endif } ReturnValue_t CoreController::actionPerformReboot(const uint8_t *data, size_t size) { - if(size < 1) { - return HasActionsIF::INVALID_PARAMETERS; - } - bool rebootSameBootCopy = data[0]; - bool protOpPerformed; - if(rebootSameBootCopy) { + if (size < 1) { + return HasActionsIF::INVALID_PARAMETERS; + } + bool rebootSameBootCopy = data[0]; + bool protOpPerformed; + if (rebootSameBootCopy) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::info << "CoreController::actionPerformReboot: Rebooting on current image" << std::endl; + sif::info << "CoreController::actionPerformReboot: Rebooting on current image" << std::endl; #endif - // Attempt graceful shutdown by unmounting and switching off SD cards - SdCardManager::instance()->switchOffSdCard(sd::SdCard::SLOT_0); - SdCardManager::instance()->switchOffSdCard(sd::SdCard::SLOT_1); - // If any boot copies are unprotected - ReturnValue_t retval = setBootCopyProtection(Chip::SELF_CHIP, Copy::SELF_COPY, - true, protOpPerformed, false); - if(retval == HasReturnvaluesIF::RETURN_OK and protOpPerformed) { - sif::info << "Running slot was writeprotected before reboot" << std::endl; - } - int result = std::system("xsc_boot_copy -r"); - if(result != 0) { - utility::handleSystemError(result, "CoreController::executeAction"); - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasActionsIF::EXECUTION_FINISHED; + // Attempt graceful shutdown by unmounting and switching off SD cards + SdCardManager::instance()->switchOffSdCard(sd::SdCard::SLOT_0); + SdCardManager::instance()->switchOffSdCard(sd::SdCard::SLOT_1); + // If any boot copies are unprotected + ReturnValue_t retval = + setBootCopyProtection(Chip::SELF_CHIP, Copy::SELF_COPY, true, protOpPerformed, false); + if (retval == HasReturnvaluesIF::RETURN_OK and protOpPerformed) { + sif::info << "Running slot was writeprotected before reboot" << std::endl; } - if(size < 3) { - return HasActionsIF::INVALID_PARAMETERS; - } -#if OBSW_VERBOSE_LEVEL >= 1 - sif::info << "CoreController::actionPerformReboot: Rebooting on " << - static_cast(data[1]) << " " << static_cast(data[2]) << std::endl; -#endif - - // Check that the target chip and copy is writeprotected first - generateChipStateFile(); - // If any boot copies are unprotected, protect them here - ReturnValue_t retval = setBootCopyProtection(static_cast(data[1]), - static_cast(data[2]), true, protOpPerformed, false); - if(retval == HasReturnvaluesIF::RETURN_OK and protOpPerformed) { - sif::info << "Target slot was writeprotected before reboot" << std::endl; - } - - // The second byte in data is the target chip, the third byte is the target copy - std::string cmdString = "xsc_boot_copy " + std::to_string(data[1]) + " " + - std::to_string(data[2]); - int result = std::system(cmdString.c_str()); - if(result != 0) { - utility::handleSystemError(result, "CoreController::executeAction"); - return HasReturnvaluesIF::RETURN_FAILED; + int result = std::system("xsc_boot_copy -r"); + if (result != 0) { + utility::handleSystemError(result, "CoreController::executeAction"); + return HasReturnvaluesIF::RETURN_FAILED; } return HasActionsIF::EXECUTION_FINISHED; + } + if (size < 3) { + return HasActionsIF::INVALID_PARAMETERS; + } +#if OBSW_VERBOSE_LEVEL >= 1 + sif::info << "CoreController::actionPerformReboot: Rebooting on " << static_cast(data[1]) + << " " << static_cast(data[2]) << std::endl; +#endif + + // Check that the target chip and copy is writeprotected first + generateChipStateFile(); + // If any boot copies are unprotected, protect them here + ReturnValue_t retval = setBootCopyProtection( + static_cast(data[1]), static_cast(data[2]), true, protOpPerformed, false); + if (retval == HasReturnvaluesIF::RETURN_OK and protOpPerformed) { + sif::info << "Target slot was writeprotected before reboot" << std::endl; + } + + // The second byte in data is the target chip, the third byte is the target copy + std::string cmdString = + "xsc_boot_copy " + std::to_string(data[1]) + " " + std::to_string(data[2]); + int result = std::system(cmdString.c_str()); + if (result != 0) { + utility::handleSystemError(result, "CoreController::executeAction"); + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasActionsIF::EXECUTION_FINISHED; } -CoreController::~CoreController() { -} +CoreController::~CoreController() {} void CoreController::determinePreferredSdCard() { - if(sdInfo.pref == sd::SdCard::NONE) { - ReturnValue_t result = sdcMan->getPreferredSdCard(sdInfo.pref); - if(result != HasReturnvaluesIF::RETURN_OK) { - if(result == scratch::KEY_NOT_FOUND) { - sif::warning << "CoreController::sdCardInit: " - "Preferred SD card not set. Setting to 0" << std::endl; - sdcMan->setPreferredSdCard(sd::SdCard::SLOT_0); - sdInfo.pref = sd::SdCard::SLOT_0; - } - else { - sif::warning << "CoreController::sdCardInit: Could not get preferred SD card" - "information from the scratch buffer" << std::endl; - } - } + if (sdInfo.pref == sd::SdCard::NONE) { + ReturnValue_t result = sdcMan->getPreferredSdCard(sdInfo.pref); + if (result != HasReturnvaluesIF::RETURN_OK) { + if (result == scratch::KEY_NOT_FOUND) { + sif::warning << "CoreController::sdCardInit: " + "Preferred SD card not set. Setting to 0" + << std::endl; + sdcMan->setPreferredSdCard(sd::SdCard::SLOT_0); + sdInfo.pref = sd::SdCard::SLOT_0; + } else { + sif::warning << "CoreController::sdCardInit: Could not get preferred SD card" + "information from the scratch buffer" + << std::endl; + } } + } } void CoreController::updateSdInfoOther() { - if(sdInfo.pref == sd::SdCard::SLOT_0) { - sdInfo.prefChar = "0"; - sdInfo.otherChar = "1"; - sdInfo.otherState = sdInfo.currentState.second; - sdInfo.prefState = sdInfo.currentState.first; - sdInfo.other = sd::SdCard::SLOT_1; + if (sdInfo.pref == sd::SdCard::SLOT_0) { + sdInfo.prefChar = "0"; + sdInfo.otherChar = "1"; + sdInfo.otherState = sdInfo.currentState.second; + sdInfo.prefState = sdInfo.currentState.first; + sdInfo.other = sd::SdCard::SLOT_1; - } - else if(sdInfo.pref == sd::SdCard::SLOT_1) { - sdInfo.prefChar = "1"; - sdInfo.otherChar = "0"; - sdInfo.otherState = sdInfo.currentState.first; - sdInfo.prefState = sdInfo.currentState.second; - sdInfo.other = sd::SdCard::SLOT_0; - } - else { - sif::warning << "CoreController::updateSdInfoOther: Invalid SD card passed" << std::endl; - } + } else if (sdInfo.pref == sd::SdCard::SLOT_1) { + sdInfo.prefChar = "1"; + sdInfo.otherChar = "0"; + sdInfo.otherState = sdInfo.currentState.first; + sdInfo.prefState = sdInfo.currentState.second; + sdInfo.other = sd::SdCard::SLOT_0; + } else { + sif::warning << "CoreController::updateSdInfoOther: Invalid SD card passed" << std::endl; + } } -bool CoreController::sdInitFinished() const { - return sdInfo.initFinished; -} +bool CoreController::sdInitFinished() const { return sdInfo.initFinished; } ReturnValue_t CoreController::generateChipStateFile() { - int result = std::system(CHIP_PROT_SCRIPT); - if(result != 0) { - utility::handleSystemError(result, "CoreController::generateChipStateFile"); - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + int result = std::system(CHIP_PROT_SCRIPT); + if (result != 0) { + utility::handleSystemError(result, "CoreController::generateChipStateFile"); + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t CoreController::setBootCopyProtection(Chip targetChip, Copy targetCopy, - bool protect, bool& protOperationPerformed, bool updateProtFile) { - bool allChips = false; - bool allCopies = false; - bool selfChip = false; - bool selfCopy = false; - protOperationPerformed = false; +ReturnValue_t CoreController::setBootCopyProtection(Chip targetChip, Copy targetCopy, bool protect, + bool &protOperationPerformed, + bool updateProtFile) { + bool allChips = false; + bool allCopies = false; + bool selfChip = false; + bool selfCopy = false; + protOperationPerformed = false; - switch(targetChip) { - case(Chip::ALL_CHIP): { - allChips = true; - break; + switch (targetChip) { + case (Chip::ALL_CHIP): { + allChips = true; + break; } - case(Chip::NO_CHIP): { - return HasReturnvaluesIF::RETURN_OK; + case (Chip::NO_CHIP): { + return HasReturnvaluesIF::RETURN_OK; } - case(Chip::SELF_CHIP): { - selfChip = true; - targetChip = CURRENT_CHIP; - break; + case (Chip::SELF_CHIP): { + selfChip = true; + targetChip = CURRENT_CHIP; + break; } default: { - break; + break; } + } + switch (targetCopy) { + case (Copy::ALL_COPY): { + allCopies = true; + break; } - switch(targetCopy) { - case(Copy::ALL_COPY): { - allCopies = true; - break; + case (Copy::NO_COPY): { + return HasReturnvaluesIF::RETURN_OK; } - case(Copy::NO_COPY): { - return HasReturnvaluesIF::RETURN_OK; - } - case(Copy::SELF_COPY): { - selfCopy = true; - targetCopy = CURRENT_COPY; - break; + case (Copy::SELF_COPY): { + selfCopy = true; + targetCopy = CURRENT_COPY; + break; } default: { - break; - } + break; } + } - for(uint8_t arrIdx = 0; arrIdx < protArray.size(); arrIdx++) { - int result = handleBootCopyProtAtIndex(targetChip, targetCopy, protect, - protOperationPerformed, selfChip, selfCopy, allChips, allCopies, arrIdx); - if(result != 0) { - break; - } + for (uint8_t arrIdx = 0; arrIdx < protArray.size(); arrIdx++) { + int result = handleBootCopyProtAtIndex(targetChip, targetCopy, protect, protOperationPerformed, + selfChip, selfCopy, allChips, allCopies, arrIdx); + if (result != 0) { + break; } - if(protOperationPerformed and updateProtFile) { - updateProtInfo(); - } - return HasReturnvaluesIF::RETURN_OK; + } + if (protOperationPerformed and updateProtFile) { + updateProtInfo(); + } + return HasReturnvaluesIF::RETURN_OK; } int CoreController::handleBootCopyProtAtIndex(Chip targetChip, Copy targetCopy, bool protect, - bool &protOperationPerformed, bool selfChip, bool selfCopy, bool allChips, - bool allCopies, uint8_t arrIdx) { - bool currentProt = protArray[arrIdx]; - std::ostringstream oss; - bool performOp = false; - if(protect == currentProt) { - return 0; - } - if(protOperationPerformed) { - if((selfChip and selfCopy) or (not allCopies and not allChips)) { - // No need to continue, only one operation was requested - return 1; - } - } - Chip currentChip; - Copy currentCopy; - oss << "writeprotect "; - if(arrIdx == 0 or arrIdx == 1) { - oss << "0 "; - currentChip = Chip::CHIP_0; - } - else { - oss << "1 "; - currentChip = Chip::CHIP_1; - } - if(arrIdx == 0 or arrIdx == 2) { - oss << "0 "; - currentCopy = Copy::COPY_0; - } - else { - oss << "1 "; - currentCopy = Copy::COPY_1; - } - if(protect) { - oss << "1"; - } - else { - oss << "0"; - } - - int result = 0; - if(allChips and allCopies) { - performOp = true; - } - else if(allChips) { - if((selfCopy and CURRENT_COPY == targetCopy) or - (currentCopy == targetCopy)) { - performOp = true; - } - } - else if(allCopies) { - if((selfChip and CURRENT_COPY == targetCopy) or - (currentChip == targetChip)) { - performOp = true; - } - } - else if(selfChip and (currentChip == targetChip)) { - if(selfCopy) { - if(currentCopy == targetCopy) { - performOp = true; - } - } - else { - performOp = true; - } - - } - else if(selfCopy and (currentCopy == targetCopy)) { - if(selfChip) { - if(currentChip == targetChip) { - performOp = true; - } - } - else { - performOp = true; - } - } - else if((targetChip == currentChip) and (targetCopy == currentCopy)) { - performOp = true; - } - if(result != 0) { - utility::handleSystemError(result, "CoreController::checkAndSetBootCopyProtection"); - } - if(performOp) { - // TODO: Lock operation take a long time. Use command executor? That would require a - // new state machine.. - protOperationPerformed = true; - sif::info << "Executing command: " << oss.str() << std::endl; - result = std::system(oss.str().c_str()); - } + bool &protOperationPerformed, bool selfChip, + bool selfCopy, bool allChips, bool allCopies, + uint8_t arrIdx) { + bool currentProt = protArray[arrIdx]; + std::ostringstream oss; + bool performOp = false; + if (protect == currentProt) { return 0; + } + if (protOperationPerformed) { + if ((selfChip and selfCopy) or (not allCopies and not allChips)) { + // No need to continue, only one operation was requested + return 1; + } + } + Chip currentChip; + Copy currentCopy; + oss << "writeprotect "; + if (arrIdx == 0 or arrIdx == 1) { + oss << "0 "; + currentChip = Chip::CHIP_0; + } else { + oss << "1 "; + currentChip = Chip::CHIP_1; + } + if (arrIdx == 0 or arrIdx == 2) { + oss << "0 "; + currentCopy = Copy::COPY_0; + } else { + oss << "1 "; + currentCopy = Copy::COPY_1; + } + if (protect) { + oss << "1"; + } else { + oss << "0"; + } + + int result = 0; + if (allChips and allCopies) { + performOp = true; + } else if (allChips) { + if ((selfCopy and CURRENT_COPY == targetCopy) or (currentCopy == targetCopy)) { + performOp = true; + } + } else if (allCopies) { + if ((selfChip and CURRENT_COPY == targetCopy) or (currentChip == targetChip)) { + performOp = true; + } + } else if (selfChip and (currentChip == targetChip)) { + if (selfCopy) { + if (currentCopy == targetCopy) { + performOp = true; + } + } else { + performOp = true; + } + + } else if (selfCopy and (currentCopy == targetCopy)) { + if (selfChip) { + if (currentChip == targetChip) { + performOp = true; + } + } else { + performOp = true; + } + } else if ((targetChip == currentChip) and (targetCopy == currentCopy)) { + performOp = true; + } + if (result != 0) { + utility::handleSystemError(result, "CoreController::checkAndSetBootCopyProtection"); + } + if (performOp) { + // TODO: Lock operation take a long time. Use command executor? That would require a + // new state machine.. + protOperationPerformed = true; + sif::info << "Executing command: " << oss.str() << std::endl; + result = std::system(oss.str().c_str()); + } + return 0; } ReturnValue_t CoreController::updateProtInfo(bool regenerateChipStateFile) { - using namespace std; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - if(regenerateChipStateFile) { - result = generateChipStateFile(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::updateProtInfo: Generating chip state file failed" << - std::endl; - return result; - } + using namespace std; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + if (regenerateChipStateFile) { + result = generateChipStateFile(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::updateProtInfo: Generating chip state file failed" + << std::endl; + return result; } - if(not filesystem::exists(CHIP_STATE_FILE)) { - return HasReturnvaluesIF::RETURN_FAILED; + } + if (not filesystem::exists(CHIP_STATE_FILE)) { + return HasReturnvaluesIF::RETURN_FAILED; + } + ifstream chipStateFile(CHIP_STATE_FILE); + if (not chipStateFile.good()) { + return HasReturnvaluesIF::RETURN_FAILED; + } + string nextLine; + uint8_t lineCounter = 0; + string word; + while (getline(chipStateFile, nextLine)) { + ReturnValue_t result = handleProtInfoUpdateLine(nextLine); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::updateProtInfo: Protection info update failed!" << std::endl; + return result; } - ifstream chipStateFile(CHIP_STATE_FILE); - if(not chipStateFile.good()) { - return HasReturnvaluesIF::RETURN_FAILED; + ++lineCounter; + if (lineCounter > 4) { + sif::warning << "CoreController::checkAndProtectBootCopy: " + "Line counter larger than 4" + << std::endl; } - string nextLine; - uint8_t lineCounter = 0; - string word; - while(getline(chipStateFile, nextLine)) { - ReturnValue_t result = handleProtInfoUpdateLine(nextLine); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::updateProtInfo: Protection info update failed!" << - std::endl; - return result; - } - ++lineCounter; - if(lineCounter > 4) { - sif::warning << "CoreController::checkAndProtectBootCopy: " - "Line counter larger than 4" << std::endl; - } - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t CoreController::handleProtInfoUpdateLine(std::string nextLine) { - using namespace std; - string word; - uint8_t wordIdx = 0; - uint8_t arrayIdx = 0; - istringstream iss(nextLine); - Chip currentChip = Chip::CHIP_0; - Copy currentCopy = Copy::COPY_0; - while(iss >> word) { - if(wordIdx == 1) { - currentChip = static_cast(stoi(word)); - } - if(wordIdx == 3) { - currentCopy = static_cast(stoi(word)); - } - - if(wordIdx == 3) { - if(currentChip == Chip::CHIP_0) { - if(currentCopy == Copy::COPY_0) { - arrayIdx = 0; - } - else if(currentCopy == Copy::COPY_1) { - arrayIdx = 1; - } - } - - else if(currentChip == Chip::CHIP_1) { - if(currentCopy == Copy::COPY_0) { - arrayIdx = 2; - } - else if(currentCopy == Copy::COPY_1) { - arrayIdx = 3; - } - } - } - if(wordIdx == 5) { - if(word == "unlocked.") { - protArray[arrayIdx] = false; - } - else { - protArray[arrayIdx] = true; - } - } - wordIdx++; + using namespace std; + string word; + uint8_t wordIdx = 0; + uint8_t arrayIdx = 0; + istringstream iss(nextLine); + Chip currentChip = Chip::CHIP_0; + Copy currentCopy = Copy::COPY_0; + while (iss >> word) { + if (wordIdx == 1) { + currentChip = static_cast(stoi(word)); } - return HasReturnvaluesIF::RETURN_OK; + if (wordIdx == 3) { + currentCopy = static_cast(stoi(word)); + } + + if (wordIdx == 3) { + if (currentChip == Chip::CHIP_0) { + if (currentCopy == Copy::COPY_0) { + arrayIdx = 0; + } else if (currentCopy == Copy::COPY_1) { + arrayIdx = 1; + } + } + + else if (currentChip == Chip::CHIP_1) { + if (currentCopy == Copy::COPY_0) { + arrayIdx = 2; + } else if (currentCopy == Copy::COPY_1) { + arrayIdx = 3; + } + } + } + if (wordIdx == 5) { + if (word == "unlocked.") { + protArray[arrayIdx] = false; + } else { + protArray[arrayIdx] = true; + } + } + wordIdx++; + } + return HasReturnvaluesIF::RETURN_OK; } void CoreController::performWatchdogControlOperation() { - // Only perform each fifth iteration - if(watchdogFifoFd != 0 and opDivider.checkAndIncrement()) { - if(watchdogFifoFd == RETRY_FIFO_OPEN) { - // Open FIFO write only and non-blocking - watchdogFifoFd = open(watchdog::FIFO_NAME.c_str(), O_WRONLY | O_NONBLOCK); - if(watchdogFifoFd < 0) { - if(errno == ENXIO) { - watchdogFifoFd = RETRY_FIFO_OPEN; - // No printout for now, would be spam - return; - } - else { - sif::error << "Opening pipe " << watchdog::FIFO_NAME << - " write-only failed with " << errno << ": " << - strerror(errno) << std::endl; - return; - } - } - sif::info << "Opened " << watchdog::FIFO_NAME << " successfully" << std::endl; - } - else if(watchdogFifoFd > 0) { - // Write to OBSW watchdog FIFO here - const char writeChar = 'a'; - ssize_t writtenBytes = write(watchdogFifoFd, &writeChar, 1); - if(writtenBytes < 0) { - sif::error << "Errors writing to watchdog FIFO, code " << errno << ": " << - strerror(errno) << std::endl; - } + // Only perform each fifth iteration + if (watchdogFifoFd != 0 and opDivider.checkAndIncrement()) { + if (watchdogFifoFd == RETRY_FIFO_OPEN) { + // Open FIFO write only and non-blocking + watchdogFifoFd = open(watchdog::FIFO_NAME.c_str(), O_WRONLY | O_NONBLOCK); + if (watchdogFifoFd < 0) { + if (errno == ENXIO) { + watchdogFifoFd = RETRY_FIFO_OPEN; + // No printout for now, would be spam + return; + } else { + sif::error << "Opening pipe " << watchdog::FIFO_NAME << " write-only failed with " + << errno << ": " << strerror(errno) << std::endl; + return; } + } + sif::info << "Opened " << watchdog::FIFO_NAME << " successfully" << std::endl; + } else if (watchdogFifoFd > 0) { + // Write to OBSW watchdog FIFO here + const char writeChar = 'a'; + ssize_t writtenBytes = write(watchdogFifoFd, &writeChar, 1); + if (writtenBytes < 0) { + sif::error << "Errors writing to watchdog FIFO, code " << errno << ": " << strerror(errno) + << std::endl; + } } - + } } diff --git a/bsp_q7s/core/CoreController.h b/bsp_q7s/core/CoreController.h index 74702441..5365000a 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -2,183 +2,167 @@ #define BSP_Q7S_CORE_CORECONTROLLER_H_ #include -#include "fsfw/controller/ExtendedControllerBase.h" + #include "bsp_q7s/memory/SdCardManager.h" - #include "events/subsystemIdRanges.h" - +#include "fsfw/controller/ExtendedControllerBase.h" class Timer; class SdCardManager; -class CoreController: public ExtendedControllerBase { -public: - enum Chip: uint8_t { - CHIP_0, - CHIP_1, - NO_CHIP, - SELF_CHIP, - ALL_CHIP - }; +class CoreController : public ExtendedControllerBase { + public: + enum Chip : uint8_t { CHIP_0, CHIP_1, NO_CHIP, SELF_CHIP, ALL_CHIP }; - enum Copy: uint8_t { - COPY_0, - COPY_1, - NO_COPY, - SELF_COPY, - ALL_COPY - }; + enum Copy : uint8_t { COPY_0, COPY_1, NO_COPY, SELF_COPY, ALL_COPY }; - static constexpr char CHIP_PROT_SCRIPT[] = "/home/root/scripts/get-chip-prot-status.sh"; - static constexpr char CHIP_STATE_FILE[] = "/tmp/chip_prot_status.txt"; - static constexpr char CURR_COPY_FILE[] = "/tmp/curr_copy.txt"; - static constexpr char VERSION_FILE[] = "/conf/sd_status"; + static constexpr char CHIP_PROT_SCRIPT[] = "/home/root/scripts/get-chip-prot-status.sh"; + static constexpr char CHIP_STATE_FILE[] = "/tmp/chip_prot_status.txt"; + static constexpr char CURR_COPY_FILE[] = "/tmp/curr_copy.txt"; + static constexpr char VERSION_FILE[] = "/conf/sd_status"; - static constexpr ActionId_t LIST_DIRECTORY_INTO_FILE = 0; - static constexpr ActionId_t REBOOT_OBC = 32; - static constexpr ActionId_t MOUNT_OTHER_COPY = 33; + static constexpr ActionId_t LIST_DIRECTORY_INTO_FILE = 0; + static constexpr ActionId_t REBOOT_OBC = 32; + static constexpr ActionId_t MOUNT_OTHER_COPY = 33; + static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CORE; - static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CORE; + static constexpr Event ALLOC_FAILURE = event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM); - static constexpr Event ALLOC_FAILURE = event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM); + CoreController(object_id_t objectId); + virtual ~CoreController(); + ReturnValue_t initialize() override; - CoreController(object_id_t objectId); - virtual~ CoreController(); + ReturnValue_t initializeAfterTaskCreation() override; - ReturnValue_t initialize() override; + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) override; - ReturnValue_t initializeAfterTaskCreation() override; + ReturnValue_t handleCommandMessage(CommandMessage* message) override; + void performControlOperation() override; - ReturnValue_t executeAction(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t *data, size_t size) override; + /** + * Generate a file containing the chip lock/unlock states inside /tmp/chip_prot_status.txt + * @return + */ + static ReturnValue_t generateChipStateFile(); + static ReturnValue_t incrementAllocationFailureCount(); + static void getCurrentBootCopy(Chip& chip, Copy& copy); - ReturnValue_t handleCommandMessage(CommandMessage *message) override; - void performControlOperation() override; + ReturnValue_t updateProtInfo(bool regenerateChipStateFile = true); - /** - * Generate a file containing the chip lock/unlock states inside /tmp/chip_prot_status.txt - * @return - */ - static ReturnValue_t generateChipStateFile(); - static ReturnValue_t incrementAllocationFailureCount(); - static void getCurrentBootCopy(Chip& chip, Copy& copy); + /** + * Checks whether the target chip and copy are write protected and protect set them to a target + * state where applicable. + * @param targetChip + * @param targetCopy + * @param protect Target state + * @param protOperationPerformed [out] Can be used to determine whether any operation + * was performed + * @param updateProtFile Specify whether the protection info file is updated + * @return + */ + ReturnValue_t setBootCopyProtection(Chip targetChip, Copy targetCopy, bool protect, + bool& protOperationPerformed, bool updateProtFile = true); - ReturnValue_t updateProtInfo(bool regenerateChipStateFile = true); + bool sdInitFinished() const; - /** - * Checks whether the target chip and copy are write protected and protect set them to a target - * state where applicable. - * @param targetChip - * @param targetCopy - * @param protect Target state - * @param protOperationPerformed [out] Can be used to determine whether any operation - * was performed - * @param updateProtFile Specify whether the protection info file is updated - * @return - */ - ReturnValue_t setBootCopyProtection(Chip targetChip, Copy targetCopy, - bool protect, bool& protOperationPerformed, bool updateProtFile = true); + private: + static Chip CURRENT_CHIP; + static Copy CURRENT_COPY; - bool sdInitFinished() const; + // Designated value for rechecking FIFO open + static constexpr int RETRY_FIFO_OPEN = -2; + int watchdogFifoFd = 0; -private: - static Chip CURRENT_CHIP; - static Copy CURRENT_COPY; + // States for SD state machine, which is used in non-blocking mode + enum class SdStates { + NONE, + START, + GET_INFO, + SET_STATE_SELF, + MOUNT_SELF, + // Determine operations for other SD card, depending on redundancy configuration + DETERMINE_OTHER, + SET_STATE_OTHER, + // Mount or unmount other + MOUNT_UNMOUNT_OTHER, + // Skip period because the shell command used to generate the info file sometimes is + // missing the last performed operation if executed too early + SKIP_CYCLE_BEFORE_INFO_UPDATE, + UPDATE_INFO, + // SD initialization done + IDLE, + // Used if SD switches or mount commands are issued via telecommand + SET_STATE_FROM_COMMAND, + }; + static constexpr bool BLOCKING_SD_INIT = false; - // Designated value for rechecking FIFO open - static constexpr int RETRY_FIFO_OPEN = -2; - int watchdogFifoFd = 0; + SdCardManager* sdcMan = nullptr; - // States for SD state machine, which is used in non-blocking mode - enum class SdStates { - NONE, - START, - GET_INFO, - SET_STATE_SELF, - MOUNT_SELF, - // Determine operations for other SD card, depending on redundancy configuration - DETERMINE_OTHER, - SET_STATE_OTHER, - // Mount or unmount other - MOUNT_UNMOUNT_OTHER, - // Skip period because the shell command used to generate the info file sometimes is - // missing the last performed operation if executed too early - SKIP_CYCLE_BEFORE_INFO_UPDATE, - UPDATE_INFO, - // SD initialization done - IDLE, - // Used if SD switches or mount commands are issued via telecommand - SET_STATE_FROM_COMMAND, - }; - static constexpr bool BLOCKING_SD_INIT = false; + struct SdInfo { + sd::SdCard pref = sd::SdCard::NONE; + sd::SdState prefState = sd::SdState::OFF; + sd::SdCard other = sd::SdCard::NONE; + sd::SdState otherState = sd::SdState::OFF; + std::string prefChar = "0"; + std::string otherChar = "1"; + SdStates state = SdStates::START; + // Used to track whether a command was executed + bool commandExecuted = true; + bool initFinished = false; + SdCardManager::SdStatePair currentState; + uint16_t cycleCount = 0; + // These two flags are related to external commanding + bool commandIssued = false; + bool commandFinished = false; + sd::SdState currentlyCommandedState = sd::SdState::OFF; + sd::SdCard commandedCard = sd::SdCard::NONE; + sd::SdState commandedState = sd::SdState::OFF; + }; + SdInfo sdInfo; - SdCardManager* sdcMan = nullptr; + /** + * Index 0: Chip 0 Copy 0 + * Index 1: Chip 0 Copy 1 + * Index 2: Chip 1 Copy 0 + * Index 3: Chip 1 Copy 1 + */ + std::array protArray; + PeriodicOperationDivider opDivider; - struct SdInfo { - sd::SdCard pref = sd::SdCard::NONE; - sd::SdState prefState = sd::SdState::OFF; - sd::SdCard other = sd::SdCard::NONE; - sd::SdState otherState = sd::SdState::OFF; - std::string prefChar = "0"; - std::string otherChar = "1"; - SdStates state = SdStates::START; - // Used to track whether a command was executed - bool commandExecuted = true; - bool initFinished = false; - SdCardManager::SdStatePair currentState; - uint16_t cycleCount = 0; - // These two flags are related to external commanding - bool commandIssued = false; - bool commandFinished = false; - sd::SdState currentlyCommandedState = sd::SdState::OFF; - sd::SdCard commandedCard = sd::SdCard::NONE; - sd::SdState commandedState = sd::SdState::OFF; - }; - SdInfo sdInfo; + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; + LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t* msToReachTheMode); - /** - * Index 0: Chip 0 Copy 0 - * Index 1: Chip 0 Copy 1 - * Index 2: Chip 1 Copy 0 - * Index 3: Chip 1 Copy 1 - */ - std::array protArray; - PeriodicOperationDivider opDivider; + ReturnValue_t initVersionFile(); + ReturnValue_t initBootCopy(); + ReturnValue_t initWatchdogFifo(); + ReturnValue_t initSdCardBlocking(); + void initPrint(); - ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; - LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; - ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, - uint32_t *msToReachTheMode); + ReturnValue_t sdStateMachine(); + void updateSdInfoOther(); + ReturnValue_t sdCardSetup(sd::SdCard sdCard, sd::SdState targetState, std::string sdChar, + bool printOutput = true); + ReturnValue_t sdColdRedundantBlockingInit(); + void currentStateSetter(sd::SdCard sdCard, sd::SdState newState); + void determinePreferredSdCard(); + void executeNextExternalSdCommand(); + void checkExternalSdCommandStatus(); - ReturnValue_t initVersionFile(); - ReturnValue_t initBootCopy(); - ReturnValue_t initWatchdogFifo(); - ReturnValue_t initSdCardBlocking(); - void initPrint(); + ReturnValue_t actionListDirectoryIntoFile(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size); + ReturnValue_t actionPerformReboot(const uint8_t* data, size_t size); - ReturnValue_t sdStateMachine(); - void updateSdInfoOther(); - ReturnValue_t sdCardSetup(sd::SdCard sdCard, sd::SdState targetState, std::string sdChar, - bool printOutput = true); - ReturnValue_t sdColdRedundantBlockingInit(); - void currentStateSetter(sd::SdCard sdCard, sd::SdState newState); - void determinePreferredSdCard(); - void executeNextExternalSdCommand(); - void checkExternalSdCommandStatus(); + void performWatchdogControlOperation(); - ReturnValue_t actionListDirectoryIntoFile(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t *data, size_t size); - ReturnValue_t actionPerformReboot(const uint8_t *data, size_t size); - - void performWatchdogControlOperation(); - - ReturnValue_t handleProtInfoUpdateLine(std::string nextLine); - int handleBootCopyProtAtIndex(Chip targetChip, Copy targetCopy, bool protect, - bool &protOperationPerformed, bool selfChip, bool selfCopy, bool allChips, - bool allCopies, uint8_t arrIdx); + ReturnValue_t handleProtInfoUpdateLine(std::string nextLine); + int handleBootCopyProtAtIndex(Chip targetChip, Copy targetCopy, bool protect, + bool& protOperationPerformed, bool selfChip, bool selfCopy, + bool allChips, bool allCopies, uint8_t arrIdx); }; #endif /* BSP_Q7S_CORE_CORECONTROLLER_H_ */ diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index df857d59..dce7f27e 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -1,22 +1,21 @@ #include "InitMission.h" -#include "ObjectFactory.h" -#include "OBSWConfig.h" -#include "pollingsequence/pollingSequenceFactory.h" - -#include "mission/utility/InitMission.h" - -#include "fsfw/platform.h" -#include "fsfw/objectmanager/ObjectManagerIF.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" -#include "fsfw/serviceinterface/ServiceInterfaceStream.h" -#include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/tasks/FixedTimeslotTaskIF.h" -#include "fsfw/tasks/PeriodicTaskIF.h" -#include "fsfw/tasks/TaskFactory.h" #include #include +#include "OBSWConfig.h" +#include "ObjectFactory.h" +#include "fsfw/objectmanager/ObjectManager.h" +#include "fsfw/objectmanager/ObjectManagerIF.h" +#include "fsfw/platform.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/serviceinterface/ServiceInterfaceStream.h" +#include "fsfw/tasks/FixedTimeslotTaskIF.h" +#include "fsfw/tasks/PeriodicTaskIF.h" +#include "fsfw/tasks/TaskFactory.h" +#include "mission/utility/InitMission.h" +#include "pollingsequence/pollingSequenceFactory.h" + /* This is configured for linux without CR */ #ifdef PLATFORM_UNIX ServiceInterfaceStream sif::debug("DEBUG"); @@ -30,344 +29,343 @@ ServiceInterfaceStream sif::warning("WARNING", true); ServiceInterfaceStream sif::error("ERROR", true, false, true); #endif -ObjectManagerIF *objectManager = nullptr; +ObjectManagerIF* objectManager = nullptr; void initmission::initMission() { + sif::info << "Building global objects.." << std::endl; + /* Instantiate global object manager and also create all objects */ + ObjectManager::instance()->setObjectFactoryFunction(ObjectFactory::produce, nullptr); + sif::info << "Initializing all objects.." << std::endl; + ObjectManager::instance()->initialize(); - sif::info << "Building global objects.." << std::endl; - /* Instantiate global object manager and also create all objects */ - ObjectManager::instance()->setObjectFactoryFunction(ObjectFactory::produce, nullptr); - sif::info << "Initializing all objects.." << std::endl; - ObjectManager::instance()->initialize(); - - /* This function creates and starts all tasks */ - initTasks(); + /* This function creates and starts all tasks */ + initTasks(); } void initmission::initTasks() { - TaskFactory* factory = TaskFactory::instance(); - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - if(factory == nullptr) { - /* Should never happen ! */ - return; - } + TaskFactory* factory = TaskFactory::instance(); + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + if (factory == nullptr) { + /* Should never happen ! */ + return; + } #if OBSW_PRINT_MISSED_DEADLINES == 1 - void (*missedDeadlineFunc) (void) = TaskFactory::printMissedDeadline; + void (*missedDeadlineFunc)(void) = TaskFactory::printMissedDeadline; #else - void (*missedDeadlineFunc) (void) = nullptr; + void (*missedDeadlineFunc)(void) = nullptr; #endif #if BOARD_TE0720 == 0 - PeriodicTaskIF* coreController = factory->createPeriodicTask( - "CORE_CTRL", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc); - result = coreController->addComponent(objects::CORE_CONTROLLER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("CORE_CTRL", objects::CORE_CONTROLLER); - } + PeriodicTaskIF* coreController = factory->createPeriodicTask( + "CORE_CTRL", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc); + result = coreController->addComponent(objects::CORE_CONTROLLER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("CORE_CTRL", objects::CORE_CONTROLLER); + } #endif - /* TMTC Distribution */ - PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask( - "DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - result = tmTcDistributor->addComponent(objects::CCSDS_PACKET_DISTRIBUTOR); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("CCSDS_DISTRIB", objects::CCSDS_PACKET_DISTRIBUTOR); - } - result = tmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_PACKET_DISTRIB", objects::PUS_PACKET_DISTRIBUTOR); - } - result = tmTcDistributor->addComponent(objects::TM_FUNNEL); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("TM_FUNNEL", objects::TM_FUNNEL); - } + /* TMTC Distribution */ + PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask( + "DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + result = tmTcDistributor->addComponent(objects::CCSDS_PACKET_DISTRIBUTOR); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("CCSDS_DISTRIB", objects::CCSDS_PACKET_DISTRIBUTOR); + } + result = tmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_PACKET_DISTRIB", objects::PUS_PACKET_DISTRIBUTOR); + } + result = tmTcDistributor->addComponent(objects::TM_FUNNEL); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("TM_FUNNEL", objects::TM_FUNNEL); + } #if OBSW_ADD_TCPIP_BRIDGE == 1 - // TMTC bridge - PeriodicTaskIF* tmtcBridgeTask = factory->createPeriodicTask( - "TCPIP_TMTC_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - result = tmtcBridgeTask->addComponent(objects::TMTC_BRIDGE); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("UDP_BRIDGE", objects::TMTC_BRIDGE); - } - PeriodicTaskIF* tmtcPollingTask = factory->createPeriodicTask( - "TMTC_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); - result = tmtcPollingTask->addComponent(objects::TMTC_POLLING_TASK); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("UDP_POLLING", objects::TMTC_POLLING_TASK); - } + // TMTC bridge + PeriodicTaskIF* tmtcBridgeTask = factory->createPeriodicTask( + "TCPIP_TMTC_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + result = tmtcBridgeTask->addComponent(objects::TMTC_BRIDGE); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("UDP_BRIDGE", objects::TMTC_BRIDGE); + } + PeriodicTaskIF* tmtcPollingTask = factory->createPeriodicTask( + "TMTC_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = tmtcPollingTask->addComponent(objects::TMTC_POLLING_TASK); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("UDP_POLLING", objects::TMTC_POLLING_TASK); + } #endif #if OBSW_USE_CCSDS_IP_CORE == 1 - PeriodicTaskIF* ccsdsHandlerTask = factory->createPeriodicTask( - "CCSDS_HANDLER", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); - result = ccsdsHandlerTask->addComponent(objects::CCSDS_HANDLER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("CCSDS Handler", objects::CCSDS_HANDLER); - } + PeriodicTaskIF* ccsdsHandlerTask = factory->createPeriodicTask( + "CCSDS_HANDLER", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = ccsdsHandlerTask->addComponent(objects::CCSDS_HANDLER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("CCSDS Handler", objects::CCSDS_HANDLER); + } - // Minimal distance between two received TCs amounts to 0.6 seconds - // If a command has not been read before the next one arrives, the old command will be - // overwritten by the PDEC. - PeriodicTaskIF* pdecHandlerTask = factory->createPeriodicTask( - "PDEC_HANDLER", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc); - result = pdecHandlerTask->addComponent(objects::PDEC_HANDLER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PDEC Handler", objects::PDEC_HANDLER); - } + // Minimal distance between two received TCs amounts to 0.6 seconds + // If a command has not been read before the next one arrives, the old command will be + // overwritten by the PDEC. + PeriodicTaskIF* pdecHandlerTask = factory->createPeriodicTask( + "PDEC_HANDLER", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc); + result = pdecHandlerTask->addComponent(objects::PDEC_HANDLER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PDEC Handler", objects::PDEC_HANDLER); + } #endif /* OBSW_USE_CCSDS_IP_CORE == 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); - } + 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); + } -# if BOARD_TE0720 == 0 - // FS task, task interval does not matter because it runs in permanent loop, priority low - // because it is a non-essential background task - PeriodicTaskIF* fsTask = factory->createPeriodicTask( - "FILE_SYSTEM_TASK", 25, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc); - result = fsTask->addComponent(objects::FILE_SYSTEM_HANDLER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("FILE_SYSTEM_TASK", objects::FILE_SYSTEM_HANDLER); - } +#if BOARD_TE0720 == 0 + // FS task, task interval does not matter because it runs in permanent loop, priority low + // because it is a non-essential background task + PeriodicTaskIF* fsTask = factory->createPeriodicTask( + "FILE_SYSTEM_TASK", 25, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc); + result = fsTask->addComponent(objects::FILE_SYSTEM_HANDLER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("FILE_SYSTEM_TASK", objects::FILE_SYSTEM_HANDLER); + } #if OBSW_ADD_STAR_TRACKER == 1 - PeriodicTaskIF* strImgLoaderTask = factory->createPeriodicTask( - "FILE_SYSTEM_TASK", 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); - } + PeriodicTaskIF* strImgLoaderTask = factory->createPeriodicTask( + "FILE_SYSTEM_TASK", 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); + } #endif /* OBSW_ADD_STAR_TRACKER == 1 */ #endif /* BOARD_TE0720 */ #if OBSW_TEST_CCSDS_BRIDGE == 1 - PeriodicTaskIF* ptmeTestTask = factory->createPeriodicTask( - "PTME_TEST", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); - result = ptmeTestTask->addComponent(objects::CCSDS_IP_CORE_BRIDGE); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PTME_TEST", objects::CCSDS_IP_CORE_BRIDGE); - } + PeriodicTaskIF* ptmeTestTask = factory->createPeriodicTask( + "PTME_TEST", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = ptmeTestTask->addComponent(objects::CCSDS_IP_CORE_BRIDGE); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PTME_TEST", objects::CCSDS_IP_CORE_BRIDGE); + } #endif - std::vector pusTasks; - createPusTasks(*factory, missedDeadlineFunc, pusTasks); - std::vector pstTasks; - createPstTasks(*factory, missedDeadlineFunc, pstTasks); + std::vector pusTasks; + createPusTasks(*factory, missedDeadlineFunc, pusTasks); + std::vector pstTasks; + createPstTasks(*factory, missedDeadlineFunc, pstTasks); #if OBSW_ADD_TEST_CODE == 1 - std::vector testTasks; - createTestTasks(*factory, missedDeadlineFunc, testTasks); + std::vector testTasks; + createTestTasks(*factory, missedDeadlineFunc, testTasks); #endif - auto taskStarter = [](std::vector& taskVector, std::string name) { - for(const auto& task: taskVector) { - if(task != nullptr) { - task->startTask(); - } - else { - sif::error << "Task in vector " << name << " is invalid!" << std::endl; - } - } - }; + auto taskStarter = [](std::vector& taskVector, std::string name) { + for (const auto& task : taskVector) { + if (task != nullptr) { + task->startTask(); + } else { + sif::error << "Task in vector " << name << " is invalid!" << std::endl; + } + } + }; - sif::info << "Starting tasks.." << std::endl; - tmTcDistributor->startTask(); + sif::info << "Starting tasks.." << std::endl; + tmTcDistributor->startTask(); #if OBSW_ADD_TCPIP_BRIDGE == 1 - tmtcBridgeTask->startTask(); - tmtcPollingTask->startTask(); + tmtcBridgeTask->startTask(); + tmtcPollingTask->startTask(); #endif #if OBSW_USE_CCSDS_IP_CORE == 1 - ccsdsHandlerTask->startTask(); - pdecHandlerTask->startTask(); + ccsdsHandlerTask->startTask(); + pdecHandlerTask->startTask(); #endif /* OBSW_USE_CCSDS_IP_CORE == 1 */ #if BOARD_TE0720 == 0 - coreController->startTask(); + coreController->startTask(); #endif - taskStarter(pstTasks, "PST task vector"); - taskStarter(pusTasks, "PUS task vector"); + taskStarter(pstTasks, "PST task vector"); + taskStarter(pusTasks, "PUS task vector"); #if OBSW_ADD_TEST_CODE == 1 - taskStarter(testTasks, "Test task vector"); + taskStarter(testTasks, "Test task vector"); #endif #if OBSW_TEST_CCSDS_BRIDGE == 1 - ptmeTestTask->startTask(); + ptmeTestTask->startTask(); #endif #if BOARD_TE0720 == 0 - fsTask->startTask(); + fsTask->startTask(); #if OBSW_ADD_STAR_TRACKER == 1 - strImgLoaderTask->startTask(); + strImgLoaderTask->startTask(); #endif /* OBSW_ADD_STAR_TRACKER == 1 */ #endif - acsCtrl->startTask(); + acsCtrl->startTask(); - sif::info << "Tasks started.." << std::endl; + sif::info << "Tasks started.." << std::endl; } void initmission::createPstTasks(TaskFactory& factory, - TaskDeadlineMissedFunction missedDeadlineFunc, std::vector &taskVec) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; #if BOARD_TE0720 == 0 - /* Polling Sequence Table Default */ + /* Polling Sequence Table Default */ #if OBSW_ADD_SPI_TEST_CODE == 0 - FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask( - "PST_TASK_DEFAULT", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.5, - missedDeadlineFunc); - result = pst::pstSpi(spiPst); - if (result != HasReturnvaluesIF::RETURN_OK) { - if(result != FixedTimeslotTaskIF::SLOT_LIST_EMPTY) { - sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; - } - } - else { - taskVec.push_back(spiPst); + FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask( + "PST_TASK_DEFAULT", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.5, missedDeadlineFunc); + result = pst::pstSpi(spiPst); + if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != FixedTimeslotTaskIF::SLOT_LIST_EMPTY) { + sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; } + } else { + taskVec.push_back(spiPst); + } #endif - FixedTimeslotTaskIF* uartPst = factory.createFixedTimeslotTask( - "UART_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc); - result = pst::pstUart(uartPst); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; - } - taskVec.push_back(uartPst); - FixedTimeslotTaskIF* gpioPst = factory.createFixedTimeslotTask( - "GPIO_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc); - result = pst::pstGpio(gpioPst); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; - } - taskVec.push_back(gpioPst); - FixedTimeslotTaskIF* i2cPst = factory.createFixedTimeslotTask( - "I2C_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc); - result = pst::pstI2c(i2cPst); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; - } + FixedTimeslotTaskIF* uartPst = factory.createFixedTimeslotTask( + "UART_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc); + result = pst::pstUart(uartPst); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; + } + taskVec.push_back(uartPst); + FixedTimeslotTaskIF* gpioPst = factory.createFixedTimeslotTask( + "GPIO_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc); + result = pst::pstGpio(gpioPst); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; + } + taskVec.push_back(gpioPst); + FixedTimeslotTaskIF* i2cPst = factory.createFixedTimeslotTask( + "I2C_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc); + result = pst::pstI2c(i2cPst); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; + } - FixedTimeslotTaskIF* gomSpacePstTask = factory.createFixedTimeslotTask( - "GS_PST_TASK", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 1.0, missedDeadlineFunc); - result = pst::pstGompaceCan(gomSpacePstTask); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "InitMission::initTasks: GomSpace PST initialization failed!" << std::endl; - } - taskVec.push_back(gomSpacePstTask); -#else /* BOARD_TE7020 == 0 */ - FixedTimeslotTaskIF * pollingSequenceTaskTE0720 = factory.createFixedTimeslotTask( - "PST_TASK_TE0720", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE * 8, 3.0, - missedDeadlineFunc); - result = pst::pollingSequenceTE0720(pollingSequenceTaskTE0720); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "InitMission::initTasks: Creating TE0720 PST failed!" << std::endl; - } - taskVec.push_back(pollingSequenceTaskTE0720); + FixedTimeslotTaskIF* gomSpacePstTask = factory.createFixedTimeslotTask( + "GS_PST_TASK", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 1.0, missedDeadlineFunc); + result = pst::pstGompaceCan(gomSpacePstTask); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "InitMission::initTasks: GomSpace PST initialization failed!" << std::endl; + } + taskVec.push_back(gomSpacePstTask); +#else /* BOARD_TE7020 == 0 */ + FixedTimeslotTaskIF* pollingSequenceTaskTE0720 = factory.createFixedTimeslotTask( + "PST_TASK_TE0720", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE * 8, 3.0, missedDeadlineFunc); + result = pst::pollingSequenceTE0720(pollingSequenceTaskTE0720); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "InitMission::initTasks: Creating TE0720 PST failed!" << std::endl; + } + taskVec.push_back(pollingSequenceTaskTE0720); #endif /* BOARD_TE7020 == 1 */ } -void initmission::createPusTasks(TaskFactory &factory, - TaskDeadlineMissedFunction missedDeadlineFunc, std::vector &taskVec) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - /* PUS Services */ - PeriodicTaskIF* pusVerification = factory.createPeriodicTask( - "PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_VERIF", objects::PUS_SERVICE_1_VERIFICATION); - } - taskVec.push_back(pusVerification); +void initmission::createPusTasks(TaskFactory& factory, + TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + /* PUS Services */ + PeriodicTaskIF* pusVerification = factory.createPeriodicTask( + "PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_VERIF", objects::PUS_SERVICE_1_VERIFICATION); + } + taskVec.push_back(pusVerification); - PeriodicTaskIF* pusEvents = factory.createPeriodicTask( - "PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusEvents->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_EVENTS", objects::PUS_SERVICE_5_EVENT_REPORTING); - } - result = pusEvents->addComponent(objects::EVENT_MANAGER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_MGMT", objects::EVENT_MANAGER); - } - taskVec.push_back(pusEvents); + PeriodicTaskIF* pusEvents = factory.createPeriodicTask( + "PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusEvents->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_EVENTS", objects::PUS_SERVICE_5_EVENT_REPORTING); + } + result = pusEvents->addComponent(objects::EVENT_MANAGER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_MGMT", objects::EVENT_MANAGER); + } + taskVec.push_back(pusEvents); - PeriodicTaskIF* pusHighPrio = factory.createPeriodicTask( - "PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_2", objects::PUS_SERVICE_2_DEVICE_ACCESS); - } - result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_9", objects::PUS_SERVICE_9_TIME_MGMT); - } - taskVec.push_back(pusHighPrio); + PeriodicTaskIF* pusHighPrio = factory.createPeriodicTask( + "PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_2", objects::PUS_SERVICE_2_DEVICE_ACCESS); + } + result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_9", objects::PUS_SERVICE_9_TIME_MGMT); + } + taskVec.push_back(pusHighPrio); - PeriodicTaskIF* pusMedPrio = factory.createPeriodicTask( - "PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); - result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_8", objects::PUS_SERVICE_8_FUNCTION_MGMT); - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_3_HOUSEKEEPING); - if(result!=HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_200", objects::PUS_SERVICE_200_MODE_MGMT); - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_20", objects::PUS_SERVICE_20_PARAMETERS); - } - taskVec.push_back(pusMedPrio); + PeriodicTaskIF* pusMedPrio = factory.createPeriodicTask( + "PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); + result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_8", objects::PUS_SERVICE_8_FUNCTION_MGMT); + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_3_HOUSEKEEPING); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_200", objects::PUS_SERVICE_200_MODE_MGMT); + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_20", objects::PUS_SERVICE_20_PARAMETERS); + } + taskVec.push_back(pusMedPrio); - PeriodicTaskIF* pusLowPrio = factory.createPeriodicTask( - "PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc); - result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_17", objects::PUS_SERVICE_17_TEST); - } - result = pusLowPrio->addComponent(objects::INTERNAL_ERROR_REPORTER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("ERROR_REPORTER", objects::INTERNAL_ERROR_REPORTER); - } - taskVec.push_back(pusLowPrio); + PeriodicTaskIF* pusLowPrio = factory.createPeriodicTask( + "PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc); + result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_17", objects::PUS_SERVICE_17_TEST); + } + result = pusLowPrio->addComponent(objects::INTERNAL_ERROR_REPORTER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("ERROR_REPORTER", objects::INTERNAL_ERROR_REPORTER); + } + taskVec.push_back(pusLowPrio); } -void initmission::createTestTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector& taskVec) { -#if OBSW_ADD_TEST_TASK == 1 || OBSW_ADD_SPI_TEST_CODE == 1 || (BOARD_TE0720 == 1 && OBSW_TEST_LIBGPIOD == 1) - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; +void initmission::createTestTasks(TaskFactory& factory, + TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec) { +#if OBSW_ADD_TEST_TASK == 1 || OBSW_ADD_SPI_TEST_CODE == 1 || \ + (BOARD_TE0720 == 1 && OBSW_TEST_LIBGPIOD == 1) + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; #endif - PeriodicTaskIF* testTask = factory.createPeriodicTask( - "TEST_TASK", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1, missedDeadlineFunc); + PeriodicTaskIF* testTask = factory.createPeriodicTask( + "TEST_TASK", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1, missedDeadlineFunc); #if OBSW_ADD_TEST_TASK == 1 - result = testTask->addComponent(objects::TEST_TASK); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK); - } + result = testTask->addComponent(objects::TEST_TASK); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK); + } #endif /* OBSW_ADD_TEST_TASK == 1 */ #if OBSW_ADD_SPI_TEST_CODE == 1 - result = testTask->addComponent(objects::SPI_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("SPI_TEST", objects::SPI_TEST); - } + result = testTask->addComponent(objects::SPI_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("SPI_TEST", objects::SPI_TEST); + } #endif #if BOARD_TE0720 == 1 && OBSW_TEST_LIBGPIOD == 1 - result = testTask->addComponent(objects::LIBGPIOD_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("GPIOD_TEST", objects::LIBGPIOD_TEST); - } + result = testTask->addComponent(objects::LIBGPIOD_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("GPIOD_TEST", objects::LIBGPIOD_TEST); + } #endif /* BOARD_TE0720 == 1 && OBSW_TEST_LIBGPIOD == 1 */ - taskVec.push_back(testTask); + taskVec.push_back(testTask); } diff --git a/bsp_q7s/core/InitMission.h b/bsp_q7s/core/InitMission.h index ffdfc11c..5c509b79 100644 --- a/bsp_q7s/core/InitMission.h +++ b/bsp_q7s/core/InitMission.h @@ -1,9 +1,10 @@ #ifndef BSP_Q7S_INITMISSION_H_ #define BSP_Q7S_INITMISSION_H_ -#include "fsfw/tasks/Typedef.h" #include +#include "fsfw/tasks/Typedef.h" + class PeriodicTaskIF; class TaskFactory; @@ -12,11 +13,11 @@ void initMission(); void initTasks(); void createPstTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector& taskVec); + std::vector& taskVec); void createPusTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector& taskVec); + std::vector& taskVec); void createTestTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector& taskVec); -}; + std::vector& taskVec); +}; // namespace initmission #endif /* BSP_Q7S_INITMISSION_H_ */ diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index c93ed507..69f6dfaf 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -1,87 +1,82 @@ -#include #include "ObjectFactory.h" -#include "bsp_q7s/devices/startracker/StrHelper.h" -#include "bsp_q7s/devices/startracker/StarTrackerDefinitions.h" +#include + #include "OBSWConfig.h" -#include "devConf.h" -#include "ccsdsConfig.h" -#include "busConf.h" -#include "tmtc/apid.h" -#include "devices/addresses.h" -#include "devices/gpioIds.h" -#include "tmtc/pusIds.h" -#include "devices/powerSwitcherList.h" -#include "bsp_q7s/gpio/gpioCallbacks.h" -#include "bsp_q7s/core/CoreController.h" #include "bsp_q7s/boardtest/Q7STestTask.h" -#include "bsp_q7s/memory/FileSystemHandler.h" +#include "bsp_q7s/callbacks/gnssCallback.h" +#include "bsp_q7s/callbacks/rwSpiCallback.h" +#include "bsp_q7s/core/CoreController.h" +#include "bsp_q7s/devices/PlocMemoryDumper.h" #include "bsp_q7s/devices/PlocSupervisorHandler.h" #include "bsp_q7s/devices/PlocUpdater.h" -#include "bsp_q7s/devices/PlocMemoryDumper.h" +#include "bsp_q7s/devices/startracker/StarTrackerDefinitions.h" #include "bsp_q7s/devices/startracker/StarTrackerHandler.h" -#include "bsp_q7s/callbacks/rwSpiCallback.h" -#include "bsp_q7s/callbacks/gnssCallback.h" - -#include "linux/devices/SolarArrayDeploymentHandler.h" -#include "linux/devices/devicedefinitions/SusDefinitions.h" -#include "linux/devices/SusHandler.h" -#include "linux/csp/CspCookie.h" +#include "bsp_q7s/devices/startracker/StrHelper.h" +#include "bsp_q7s/gpio/gpioCallbacks.h" +#include "bsp_q7s/memory/FileSystemHandler.h" +#include "busConf.h" +#include "ccsdsConfig.h" +#include "devConf.h" +#include "devices/addresses.h" +#include "devices/gpioIds.h" +#include "devices/powerSwitcherList.h" +#include "fsfw/datapoollocal/LocalDataPoolManager.h" +#include "fsfw/tmtcpacket/pus/tm.h" +#include "fsfw/tmtcservices/CommandingServiceBase.h" +#include "fsfw/tmtcservices/PusServiceBase.h" +#include "fsfw_hal/common/gpio/GpioCookie.h" +#include "fsfw_hal/devicehandlers/GyroL3GD20Handler.h" +#include "fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h" +#include "fsfw_hal/devicehandlers/MgmRM3100Handler.h" +#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" +#include "fsfw_hal/linux/i2c/I2cComIF.h" +#include "fsfw_hal/linux/i2c/I2cCookie.h" +#include "fsfw_hal/linux/spi/SpiComIF.h" +#include "fsfw_hal/linux/spi/SpiCookie.h" +#include "fsfw_hal/linux/uart/UartComIF.h" +#include "fsfw_hal/linux/uart/UartCookie.h" +#include "linux/boardtest/SpiTestClass.h" #include "linux/csp/CspComIF.h" - -#include "mission/devices/HeaterHandler.h" +#include "linux/csp/CspCookie.h" +#include "linux/devices/SolarArrayDeploymentHandler.h" +#include "linux/devices/SusHandler.h" +#include "linux/devices/devicedefinitions/SusDefinitions.h" #include "mission/core/GenericFactory.h" +#include "mission/devices/ACUHandler.h" +#include "mission/devices/GPSHyperionHandler.h" +#include "mission/devices/GyroADIS1650XHandler.h" +#include "mission/devices/HeaterHandler.h" +#include "mission/devices/IMTQHandler.h" +#include "mission/devices/Max31865PT1000Handler.h" +#include "mission/devices/P60DockHandler.h" +#include "mission/devices/PCDUHandler.h" #include "mission/devices/PDU1Handler.h" #include "mission/devices/PDU2Handler.h" -#include "mission/devices/ACUHandler.h" -#include "mission/devices/PCDUHandler.h" -#include "mission/devices/P60DockHandler.h" -#include "mission/devices/Tmp1075Handler.h" -#include "mission/devices/Max31865PT1000Handler.h" -#include "mission/devices/GyroADIS1650XHandler.h" -#include "mission/devices/IMTQHandler.h" -#include "mission/devices/SyrlinksHkHandler.h" #include "mission/devices/PlocMPSoCHandler.h" #include "mission/devices/RadiationSensorHandler.h" #include "mission/devices/RwHandler.h" +#include "mission/devices/SyrlinksHkHandler.h" +#include "mission/devices/Tmp1075Handler.h" #include "mission/devices/devicedefinitions/GomspaceDefinitions.h" -#include "mission/devices/devicedefinitions/SyrlinksDefinitions.h" +#include "mission/devices/devicedefinitions/Max31865Definitions.h" #include "mission/devices/devicedefinitions/PlocMPSoCDefinitions.h" #include "mission/devices/devicedefinitions/RadSensorDefinitions.h" -#include "mission/devices/devicedefinitions/Max31865Definitions.h" #include "mission/devices/devicedefinitions/RwDefinitions.h" - -#include "mission/devices/GPSHyperionHandler.h" +#include "mission/devices/devicedefinitions/SyrlinksDefinitions.h" #include "mission/tmtc/CCSDSHandler.h" #include "mission/tmtc/VirtualChannel.h" #include "mission/utility/TmFunnel.h" - -#include "fsfw_hal/linux/uart/UartComIF.h" -#include "fsfw_hal/linux/uart/UartCookie.h" -#include "fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h" -#include "fsfw_hal/devicehandlers/GyroL3GD20Handler.h" -#include "fsfw_hal/devicehandlers/MgmRM3100Handler.h" -#include "fsfw_hal/linux/i2c/I2cCookie.h" -#include "fsfw_hal/linux/i2c/I2cComIF.h" -#include "fsfw_hal/linux/spi/SpiCookie.h" -#include "fsfw_hal/linux/spi/SpiComIF.h" -#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" -#include "fsfw_hal/common/gpio/GpioCookie.h" - -#include "fsfw/datapoollocal/LocalDataPoolManager.h" -#include "fsfw/tmtcservices/CommandingServiceBase.h" -#include "fsfw/tmtcservices/PusServiceBase.h" -#include "fsfw/tmtcpacket/pus/tm.h" - -#include "linux/boardtest/SpiTestClass.h" +#include "tmtc/apid.h" +#include "tmtc/pusIds.h" #if OBSW_TEST_LIBGPIOD == 1 #include "linux/boardtest/LibgpiodTest.h" #endif -#include -#include #include +#include +#include #include #include #include @@ -89,1016 +84,1016 @@ ResetArgs resetArgsGnss0; ResetArgs resetArgsGnss1; -void ObjectFactory::setStatics() { - Factory::setStaticFrameworkObjectIds(); -} +void ObjectFactory::setStatics() { Factory::setStaticFrameworkObjectIds(); } void Factory::setStaticFrameworkObjectIds() { - PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; - PusServiceBase::packetDestination = objects::TM_FUNNEL; + PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; + PusServiceBase::packetDestination = objects::TM_FUNNEL; - CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; - CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; + CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; + CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; - //DeviceHandlerBase::powerSwitcherId = objects::PCDU_HANDLER; - DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT; + // DeviceHandlerBase::powerSwitcherId = objects::PCDU_HANDLER; + DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT; #if OBSW_TM_TO_PTME == 1 - TmFunnel::downlinkDestination = objects::CCSDS_HANDLER; + TmFunnel::downlinkDestination = objects::CCSDS_HANDLER; #else - TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; + TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; #endif /* OBSW_TM_TO_PTME == 1 */ - // No storage object for now. - TmFunnel::storageDestination = objects::NO_OBJECT; + // No storage object for now. + TmFunnel::storageDestination = objects::NO_OBJECT; - LocalDataPoolManager::defaultHkDestination = objects::PUS_SERVICE_3_HOUSEKEEPING; + LocalDataPoolManager::defaultHkDestination = objects::PUS_SERVICE_3_HOUSEKEEPING; - VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; - TmPacketBase::timeStamperId = objects::TIME_STAMPER; + VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; + TmPacketBase::timeStamperId = objects::TIME_STAMPER; } void ObjectFactory::produce(void* args) { - ObjectFactory::setStatics(); - ObjectFactory::produceGenericObjects(); + ObjectFactory::setStatics(); + ObjectFactory::produceGenericObjects(); - LinuxLibgpioIF* gpioComIF = nullptr; - UartComIF* uartComIF = nullptr; - SpiComIF* spiComIF = nullptr; - createCommunicationInterfaces(&gpioComIF, &uartComIF, &spiComIF); - createTmpComponents(); + LinuxLibgpioIF* gpioComIF = nullptr; + UartComIF* uartComIF = nullptr; + SpiComIF* spiComIF = nullptr; + createCommunicationInterfaces(&gpioComIF, &uartComIF, &spiComIF); + createTmpComponents(); #if BOARD_TE0720 == 0 - new CoreController(objects::CORE_CONTROLLER); + new CoreController(objects::CORE_CONTROLLER); - createPcduComponents(); - createRadSensorComponent(gpioComIF); - createSunSensorComponents(gpioComIF, spiComIF); + createPcduComponents(); + createRadSensorComponent(gpioComIF); + createSunSensorComponents(gpioComIF, spiComIF); #if OBSW_ADD_ACS_BOARD == 1 - createAcsBoardComponents(gpioComIF, uartComIF); + createAcsBoardComponents(gpioComIF, uartComIF); #endif /* OBSW_ADD_ACS_BOARD == 1 */ - createHeaterComponents(); - createSolarArrayDeploymentComponents(); + createHeaterComponents(); + createSolarArrayDeploymentComponents(); #if OBSW_ADD_SYRLINKS == 1 - createSyrlinksComponents(); + createSyrlinksComponents(); #endif /* OBSW_ADD_SYRLINKS == 1 */ #if OBSW_ADD_RTD_DEVICES == 1 - createRtdComponents(gpioComIF); + createRtdComponents(gpioComIF); #endif /* OBSW_ADD_RTD_DEVICES == 1 */ - I2cCookie* imtqI2cCookie = new I2cCookie(addresses::IMTQ, IMTQ::MAX_REPLY_SIZE, - q7s::I2C_DEFAULT_DEV); - new IMTQHandler(objects::IMTQ_HANDLER, objects::I2C_COM_IF, imtqI2cCookie); - createReactionWheelComponents(gpioComIF); + I2cCookie* imtqI2cCookie = + new I2cCookie(addresses::IMTQ, IMTQ::MAX_REPLY_SIZE, q7s::I2C_DEFAULT_DEV); + new IMTQHandler(objects::IMTQ_HANDLER, objects::I2C_COM_IF, imtqI2cCookie); + createReactionWheelComponents(gpioComIF); #if OBSW_ADD_PLOC_MPSOC == 1 - UartCookie* plocMpsocCookie = new UartCookie(objects::PLOC_MPSOC_HANDLER, - q7s::UART_PLOC_MPSOC_DEV, UartModes::NON_CANONICAL, uart::PLOC_MPSOC_BAUD, - PLOC_MPSOC::MAX_REPLY_SIZE); - new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, plocMpsocCookie); + UartCookie* plocMpsocCookie = + new UartCookie(objects::PLOC_MPSOC_HANDLER, q7s::UART_PLOC_MPSOC_DEV, + UartModes::NON_CANONICAL, uart::PLOC_MPSOC_BAUD, PLOC_MPSOC::MAX_REPLY_SIZE); + new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, plocMpsocCookie); #endif /* OBSW_ADD_PLOC_MPSOC == 1 */ #if OBSW_ADD_PLOC_SUPERVISOR == 1 - UartCookie* plocSupervisorCookie = new UartCookie(objects::PLOC_SUPERVISOR_HANDLER, - q7s::UART_PLOC_SUPERVSIOR_DEV, UartModes::NON_CANONICAL, uart::PLOC_SUPERVISOR_BAUD, - PLOC_SPV::MAX_PACKET_SIZE * 20); - plocSupervisorCookie->setNoFixedSizeReply(); - PlocSupervisorHandler* plocSupervisor = new PlocSupervisorHandler( - objects::PLOC_SUPERVISOR_HANDLER, objects::UART_COM_IF, plocSupervisorCookie); - plocSupervisor->setStartUpImmediately(); + UartCookie* plocSupervisorCookie = new UartCookie( + objects::PLOC_SUPERVISOR_HANDLER, q7s::UART_PLOC_SUPERVSIOR_DEV, UartModes::NON_CANONICAL, + uart::PLOC_SUPERVISOR_BAUD, PLOC_SPV::MAX_PACKET_SIZE * 20); + plocSupervisorCookie->setNoFixedSizeReply(); + PlocSupervisorHandler* plocSupervisor = new PlocSupervisorHandler( + objects::PLOC_SUPERVISOR_HANDLER, objects::UART_COM_IF, plocSupervisorCookie); + plocSupervisor->setStartUpImmediately(); #endif /* OBSW_ADD_PLOC_SUPERVISOR == 1 */ - new FileSystemHandler(objects::FILE_SYSTEM_HANDLER); + new FileSystemHandler(objects::FILE_SYSTEM_HANDLER); #if OBSW_ADD_STAR_TRACKER == 1 - UartCookie* starTrackerCookie = new UartCookie(objects::STAR_TRACKER, - q7s::UART_STAR_TRACKER_DEV, UartModes::NON_CANONICAL, uart::STAR_TRACKER_BAUD, - StarTracker::MAX_FRAME_SIZE* 2 + 2); - starTrackerCookie->setNoFixedSizeReply(); - StrHelper* strHelper = new StrHelper(objects::STR_HELPER); - StarTrackerHandler* starTrackerHandler = new StarTrackerHandler(objects::STAR_TRACKER, - objects::UART_COM_IF, starTrackerCookie, strHelper); - starTrackerHandler->setStartUpImmediately(); + UartCookie* starTrackerCookie = + new UartCookie(objects::STAR_TRACKER, q7s::UART_STAR_TRACKER_DEV, UartModes::NON_CANONICAL, + uart::STAR_TRACKER_BAUD, StarTracker::MAX_FRAME_SIZE * 2 + 2); + starTrackerCookie->setNoFixedSizeReply(); + StrHelper* strHelper = new StrHelper(objects::STR_HELPER); + StarTrackerHandler* starTrackerHandler = new StarTrackerHandler( + objects::STAR_TRACKER, objects::UART_COM_IF, starTrackerCookie, strHelper); + starTrackerHandler->setStartUpImmediately(); #endif /* OBSW_ADD_STAR_TRACKER == 1 */ #endif /* TE7020 == 0 */ #if OBSW_USE_CCSDS_IP_CORE == 1 - createCcsdsComponents(gpioComIF); + createCcsdsComponents(gpioComIF); #endif /* OBSW_USE_CCSDS_IP_CORE == 1 */ - /* Test Task */ + /* Test Task */ #if OBSW_ADD_TEST_CODE == 1 - createTestComponents(gpioComIF); + createTestComponents(gpioComIF); #endif /* OBSW_ADD_TEST_CODE == 1 */ - new PlocUpdater(objects::PLOC_UPDATER); - new PlocMemoryDumper(objects::PLOC_MEMORY_DUMPER); + new PlocUpdater(objects::PLOC_UPDATER); + new PlocMemoryDumper(objects::PLOC_MEMORY_DUMPER); } void ObjectFactory::createTmpComponents() { #if BOARD_TE0720 == 1 - I2cCookie* i2cCookieTmp1075tcs1 = new I2cCookie(addresses::TMP1075_TCS_1, - TMP1075::MAX_REPLY_LENGTH, std::string("/dev/i2c-0")); - I2cCookie* i2cCookieTmp1075tcs2 = new I2cCookie(addresses::TMP1075_TCS_2, - TMP1075::MAX_REPLY_LENGTH, std::string("/dev/i2c-0")); + I2cCookie* i2cCookieTmp1075tcs1 = + new I2cCookie(addresses::TMP1075_TCS_1, TMP1075::MAX_REPLY_LENGTH, std::string("/dev/i2c-0")); + I2cCookie* i2cCookieTmp1075tcs2 = + new I2cCookie(addresses::TMP1075_TCS_2, TMP1075::MAX_REPLY_LENGTH, std::string("/dev/i2c-0")); #else - I2cCookie* i2cCookieTmp1075tcs1 = new I2cCookie(addresses::TMP1075_TCS_1, - TMP1075::MAX_REPLY_LENGTH, q7s::I2C_DEFAULT_DEV); - I2cCookie* i2cCookieTmp1075tcs2 = new I2cCookie(addresses::TMP1075_TCS_2, - TMP1075::MAX_REPLY_LENGTH, q7s::I2C_DEFAULT_DEV); + I2cCookie* i2cCookieTmp1075tcs1 = + new I2cCookie(addresses::TMP1075_TCS_1, TMP1075::MAX_REPLY_LENGTH, q7s::I2C_DEFAULT_DEV); + I2cCookie* i2cCookieTmp1075tcs2 = + new I2cCookie(addresses::TMP1075_TCS_2, TMP1075::MAX_REPLY_LENGTH, q7s::I2C_DEFAULT_DEV); #endif - /* Temperature sensors */ - Tmp1075Handler* tmp1075Handler_1 = new Tmp1075Handler(objects::TMP1075_HANDLER_1, - objects::I2C_COM_IF, i2cCookieTmp1075tcs1); - (void) tmp1075Handler_1; - Tmp1075Handler* tmp1075Handler_2 = new Tmp1075Handler(objects::TMP1075_HANDLER_2, - objects::I2C_COM_IF, i2cCookieTmp1075tcs2); - (void) tmp1075Handler_2; + /* Temperature sensors */ + Tmp1075Handler* tmp1075Handler_1 = + new Tmp1075Handler(objects::TMP1075_HANDLER_1, objects::I2C_COM_IF, i2cCookieTmp1075tcs1); + (void)tmp1075Handler_1; + Tmp1075Handler* tmp1075Handler_2 = + new Tmp1075Handler(objects::TMP1075_HANDLER_2, objects::I2C_COM_IF, i2cCookieTmp1075tcs2); + (void)tmp1075Handler_2; } -void ObjectFactory::createCommunicationInterfaces(LinuxLibgpioIF **gpioComIF, UartComIF** uartComIF, - SpiComIF** spiComIF) { - if (gpioComIF == nullptr or uartComIF == nullptr or spiComIF == nullptr) { - sif::error << "ObjectFactory::createCommunicationInterfaces: Invalid passed ComIF pointer" - << std::endl; - } - *gpioComIF = new LinuxLibgpioIF(objects::GPIO_IF); +void ObjectFactory::createCommunicationInterfaces(LinuxLibgpioIF** gpioComIF, UartComIF** uartComIF, + SpiComIF** spiComIF) { + if (gpioComIF == nullptr or uartComIF == nullptr or spiComIF == nullptr) { + sif::error << "ObjectFactory::createCommunicationInterfaces: Invalid passed ComIF pointer" + << std::endl; + } + *gpioComIF = new LinuxLibgpioIF(objects::GPIO_IF); - /* Communication interfaces */ - new CspComIF(objects::CSP_COM_IF); - new I2cComIF(objects::I2C_COM_IF); - *uartComIF = new UartComIF(objects::UART_COM_IF); + /* Communication interfaces */ + new CspComIF(objects::CSP_COM_IF); + new I2cComIF(objects::I2C_COM_IF); + *uartComIF = new UartComIF(objects::UART_COM_IF); #if OBSW_ADD_SPI_TEST_CODE == 0 - *spiComIF = new SpiComIF(objects::SPI_COM_IF, *gpioComIF); + *spiComIF = new SpiComIF(objects::SPI_COM_IF, *gpioComIF); #endif /* Q7S_ADD_SPI_TEST_CODE == 0 */ #if BOARD_TE0720 == 0 - /* Adding gpios for chip select decoding to the gpioComIf */ - gpioCallbacks::initSpiCsDecoder(*gpioComIF); + /* Adding gpios for chip select decoding to the gpioComIf */ + gpioCallbacks::initSpiCsDecoder(*gpioComIF); #endif } void ObjectFactory::createPcduComponents() { - 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); - CspCookie* acuCspCookie = new CspCookie(ACU::MAX_REPLY_LENGTH, addresses::ACU); - /* Device Handler */ - P60DockHandler* p60dockhandler = new P60DockHandler(objects::P60DOCK_HANDLER, - objects::CSP_COM_IF, p60DockCspCookie); - PDU1Handler* pdu1handler = new PDU1Handler(objects::PDU1_HANDLER, objects::CSP_COM_IF, - pdu1CspCookie); - PDU2Handler* pdu2handler = new PDU2Handler(objects::PDU2_HANDLER, objects::CSP_COM_IF, - pdu2CspCookie); - ACUHandler* acuhandler = new ACUHandler(objects::ACU_HANDLER, objects::CSP_COM_IF, - acuCspCookie); - new PCDUHandler(objects::PCDU_HANDLER, 50); + 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); + CspCookie* acuCspCookie = new CspCookie(ACU::MAX_REPLY_LENGTH, addresses::ACU); + /* Device Handler */ + P60DockHandler* p60dockhandler = + new P60DockHandler(objects::P60DOCK_HANDLER, objects::CSP_COM_IF, p60DockCspCookie); + PDU1Handler* pdu1handler = + new PDU1Handler(objects::PDU1_HANDLER, objects::CSP_COM_IF, pdu1CspCookie); + PDU2Handler* pdu2handler = + new PDU2Handler(objects::PDU2_HANDLER, objects::CSP_COM_IF, pdu2CspCookie); + ACUHandler* acuhandler = new ACUHandler(objects::ACU_HANDLER, objects::CSP_COM_IF, acuCspCookie); + new PCDUHandler(objects::PCDU_HANDLER, 50); - /** - * Setting PCDU devices to mode normal immediately after start up because PCDU is always - * running. - */ - p60dockhandler->setModeNormal(); - pdu1handler->setModeNormal(); - pdu2handler->setModeNormal(); - acuhandler->setModeNormal(); + /** + * Setting PCDU devices to mode normal immediately after start up because PCDU is always + * running. + */ + p60dockhandler->setModeNormal(); + pdu1handler->setModeNormal(); + pdu2handler->setModeNormal(); + acuhandler->setModeNormal(); } void ObjectFactory::createRadSensorComponent(LinuxLibgpioIF* gpioComIF) { - GpioCookie* gpioCookieRadSensor = new GpioCookie; - std::stringstream consumer; - consumer << "0x" << std::hex << objects::RAD_SENSOR; - GpiodRegularByLineName* gpio = new GpiodRegularByLineName( - q7s::gpioNames::RAD_SENSOR_CHIP_SELECT, consumer.str(), gpio::DIR_OUT, gpio::HIGH); - gpioCookieRadSensor->addGpio(gpioIds::CS_RAD_SENSOR, gpio); - gpioComIF->addGpios(gpioCookieRadSensor); + GpioCookie* gpioCookieRadSensor = new GpioCookie; + std::stringstream consumer; + consumer << "0x" << std::hex << objects::RAD_SENSOR; + GpiodRegularByLineName* gpio = new GpiodRegularByLineName( + q7s::gpioNames::RAD_SENSOR_CHIP_SELECT, consumer.str(), gpio::DIR_OUT, gpio::HIGH); + gpioCookieRadSensor->addGpio(gpioIds::CS_RAD_SENSOR, gpio); + gpioComIF->addGpios(gpioCookieRadSensor); - SpiCookie* spiCookieRadSensor = new SpiCookie(addresses::RAD_SENSOR, gpioIds::CS_RAD_SENSOR, - std::string(q7s::SPI_DEFAULT_DEV), RAD_SENSOR::READ_SIZE, spi::DEFAULT_MAX_1227_MODE, - spi::DEFAULT_MAX_1227_SPEED); - new RadiationSensorHandler(objects::RAD_SENSOR, objects::SPI_COM_IF, spiCookieRadSensor); + SpiCookie* spiCookieRadSensor = new SpiCookie( + addresses::RAD_SENSOR, gpioIds::CS_RAD_SENSOR, std::string(q7s::SPI_DEFAULT_DEV), + RAD_SENSOR::READ_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED); + new RadiationSensorHandler(objects::RAD_SENSOR, objects::SPI_COM_IF, spiCookieRadSensor); } -void ObjectFactory::createSunSensorComponents(LinuxLibgpioIF *gpioComIF, SpiComIF* spiComIF) { - GpioCookie* gpioCookieSus = new GpioCookie(); - GpioCallback* susgpio = nullptr; +void ObjectFactory::createSunSensorComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* spiComIF) { + GpioCookie* gpioCookieSus = new GpioCookie(); + GpioCallback* susgpio = nullptr; - susgpio = new GpioCallback("Chip select SUS 1", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_1, susgpio); - susgpio = new GpioCallback("Chip select SUS 2", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_2, susgpio); - susgpio = new GpioCallback("Chip select SUS 3", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_3, susgpio); - susgpio = new GpioCallback("Chip select SUS 4", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_4, susgpio); - susgpio = new GpioCallback("Chip select SUS 5", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_5, susgpio); - susgpio = new GpioCallback("Chip select SUS 6", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_6, susgpio); - susgpio = new GpioCallback("Chip select SUS 7", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_7, susgpio); - susgpio = new GpioCallback("Chip select SUS 8", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_8, susgpio); - susgpio = new GpioCallback("Chip select SUS 9", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_9, susgpio); - susgpio = new GpioCallback("Chip select SUS 10", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_10, susgpio); - susgpio = new GpioCallback("Chip select SUS 11", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_11, susgpio); - susgpio = new GpioCallback("Chip select SUS 12", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_12, susgpio); - susgpio = new GpioCallback("Chip select SUS 13", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_13, susgpio); + susgpio = new GpioCallback("Chip select SUS 1", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_1, susgpio); + susgpio = new GpioCallback("Chip select SUS 2", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_2, susgpio); + susgpio = new GpioCallback("Chip select SUS 3", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_3, susgpio); + susgpio = new GpioCallback("Chip select SUS 4", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_4, susgpio); + susgpio = new GpioCallback("Chip select SUS 5", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_5, susgpio); + susgpio = new GpioCallback("Chip select SUS 6", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_6, susgpio); + susgpio = new GpioCallback("Chip select SUS 7", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_7, susgpio); + susgpio = new GpioCallback("Chip select SUS 8", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_8, susgpio); + susgpio = new GpioCallback("Chip select SUS 9", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_9, susgpio); + susgpio = new GpioCallback("Chip select SUS 10", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_10, susgpio); + susgpio = new GpioCallback("Chip select SUS 11", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_11, susgpio); + susgpio = new GpioCallback("Chip select SUS 12", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_12, susgpio); + susgpio = new GpioCallback("Chip select SUS 13", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_13, susgpio); - gpioComIF->addGpios(gpioCookieSus); + gpioComIF->addGpios(gpioCookieSus); - SpiCookie* spiCookieSus1 = new SpiCookie(addresses::SUS_1, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus2 = new SpiCookie(addresses::SUS_2, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus3 = new SpiCookie(addresses::SUS_3, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus4 = new SpiCookie(addresses::SUS_4, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus5 = new SpiCookie(addresses::SUS_5, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus6 = new SpiCookie(addresses::SUS_6, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus7 = new SpiCookie(addresses::SUS_7, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus8 = new SpiCookie(addresses::SUS_8, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus9 = new SpiCookie(addresses::SUS_9, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus10 = new SpiCookie(addresses::SUS_10, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus11 = new SpiCookie(addresses::SUS_11, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus12 = new SpiCookie(addresses::SUS_12, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus13 = new SpiCookie(addresses::SUS_13, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus1 = + new SpiCookie(addresses::SUS_1, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus2 = + new SpiCookie(addresses::SUS_2, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus3 = + new SpiCookie(addresses::SUS_3, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus4 = + new SpiCookie(addresses::SUS_4, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus5 = + new SpiCookie(addresses::SUS_5, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus6 = + new SpiCookie(addresses::SUS_6, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus7 = + new SpiCookie(addresses::SUS_7, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus8 = + new SpiCookie(addresses::SUS_8, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus9 = + new SpiCookie(addresses::SUS_9, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus10 = + new SpiCookie(addresses::SUS_10, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus11 = + new SpiCookie(addresses::SUS_11, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus12 = + new SpiCookie(addresses::SUS_12, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus13 = + new SpiCookie(addresses::SUS_13, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); - new SusHandler(objects::SUS_1, objects::SPI_COM_IF, spiCookieSus1, gpioComIF, - gpioIds::CS_SUS_1); - new SusHandler(objects::SUS_2, objects::SPI_COM_IF, spiCookieSus2, gpioComIF, - gpioIds::CS_SUS_2); - new SusHandler(objects::SUS_3, objects::SPI_COM_IF, spiCookieSus3, gpioComIF, - gpioIds::CS_SUS_3); - new SusHandler(objects::SUS_4, objects::SPI_COM_IF, spiCookieSus4, gpioComIF, - gpioIds::CS_SUS_4); - new SusHandler(objects::SUS_5, objects::SPI_COM_IF, spiCookieSus5, gpioComIF, - gpioIds::CS_SUS_5); - new SusHandler(objects::SUS_6, objects::SPI_COM_IF, spiCookieSus6, gpioComIF, - gpioIds::CS_SUS_6); - new SusHandler(objects::SUS_7, objects::SPI_COM_IF, spiCookieSus7, gpioComIF, - gpioIds::CS_SUS_7); - new SusHandler(objects::SUS_8, objects::SPI_COM_IF, spiCookieSus8, gpioComIF, - gpioIds::CS_SUS_8); - new SusHandler(objects::SUS_9, objects::SPI_COM_IF, spiCookieSus9, gpioComIF, - gpioIds::CS_SUS_9); - new SusHandler(objects::SUS_10, objects::SPI_COM_IF, spiCookieSus10, gpioComIF, - gpioIds::CS_SUS_10); - new SusHandler(objects::SUS_11, objects::SPI_COM_IF, spiCookieSus11, gpioComIF, - gpioIds::CS_SUS_11); - new SusHandler(objects::SUS_12, objects::SPI_COM_IF, spiCookieSus12, gpioComIF, - gpioIds::CS_SUS_12); - new SusHandler(objects::SUS_13, objects::SPI_COM_IF, spiCookieSus13, gpioComIF, - gpioIds::CS_SUS_13); + new SusHandler(objects::SUS_1, objects::SPI_COM_IF, spiCookieSus1, gpioComIF, gpioIds::CS_SUS_1); + new SusHandler(objects::SUS_2, objects::SPI_COM_IF, spiCookieSus2, gpioComIF, gpioIds::CS_SUS_2); + new SusHandler(objects::SUS_3, objects::SPI_COM_IF, spiCookieSus3, gpioComIF, gpioIds::CS_SUS_3); + new SusHandler(objects::SUS_4, objects::SPI_COM_IF, spiCookieSus4, gpioComIF, gpioIds::CS_SUS_4); + new SusHandler(objects::SUS_5, objects::SPI_COM_IF, spiCookieSus5, gpioComIF, gpioIds::CS_SUS_5); + new SusHandler(objects::SUS_6, objects::SPI_COM_IF, spiCookieSus6, gpioComIF, gpioIds::CS_SUS_6); + new SusHandler(objects::SUS_7, objects::SPI_COM_IF, spiCookieSus7, gpioComIF, gpioIds::CS_SUS_7); + new SusHandler(objects::SUS_8, objects::SPI_COM_IF, spiCookieSus8, gpioComIF, gpioIds::CS_SUS_8); + new SusHandler(objects::SUS_9, objects::SPI_COM_IF, spiCookieSus9, gpioComIF, gpioIds::CS_SUS_9); + new SusHandler(objects::SUS_10, objects::SPI_COM_IF, spiCookieSus10, gpioComIF, + gpioIds::CS_SUS_10); + new SusHandler(objects::SUS_11, objects::SPI_COM_IF, spiCookieSus11, gpioComIF, + gpioIds::CS_SUS_11); + new SusHandler(objects::SUS_12, objects::SPI_COM_IF, spiCookieSus12, gpioComIF, + gpioIds::CS_SUS_12); + new SusHandler(objects::SUS_13, objects::SPI_COM_IF, spiCookieSus13, gpioComIF, + gpioIds::CS_SUS_13); } -void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComIF* uartComIF) { - GpioCookie* gpioCookieAcsBoard = new GpioCookie(); +void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComIF* uartComIF) { + GpioCookie* gpioCookieAcsBoard = new GpioCookie(); - std::stringstream consumer; - GpiodRegularByLineName* gpio = nullptr; - consumer << "0x" << std::hex << objects::GYRO_0_ADIS_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ADIS_CS, consumer.str(), - gpio::DIR_OUT, gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); + std::stringstream consumer; + GpiodRegularByLineName* gpio = nullptr; + consumer << "0x" << std::hex << objects::GYRO_0_ADIS_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ADIS_CS, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GYRO_1_L3G_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_1_L3G_CS, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GYRO_1_L3G_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_1_L3G_CS, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GYRO_2_ADIS_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ADIS_CS, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::GYRO_2_ADIS_CS, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GYRO_2_ADIS_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ADIS_CS, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::GYRO_2_ADIS_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GYRO_3_L3G_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_3_L3G_CS, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GYRO_3_L3G_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_3_L3G_CS, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::MGM_0_LIS3_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_0_CS, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::MGM_0_LIS3_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_0_CS, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::MGM_1_RM3100_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::MGM_1_RM3100_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::MGM_2_LIS3_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_2_CS, consumer.str(), - gpio::DIR_OUT, gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::MGM_2_LIS3_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_2_CS, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::MGM_3_RM3100_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_3_CS, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::MGM_3_RM3100_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_3_CS, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GPS_CONTROLLER; - // GNSS reset pins are active low - gpio = new GpiodRegularByLineName(q7s::gpioNames::RESET_GNSS_0, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::GNSS_0_NRESET, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GPS_CONTROLLER; + // GNSS reset pins are active low + gpio = new GpiodRegularByLineName(q7s::gpioNames::RESET_GNSS_0, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::GNSS_0_NRESET, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GPS_CONTROLLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::RESET_GNSS_1, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::GNSS_1_NRESET, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GPS_CONTROLLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::RESET_GNSS_1, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::GNSS_1_NRESET, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GYRO_0_ADIS_HANDLER; - // Enable pins must be pulled low for regular operations - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, consumer.str(), - gpio::DIR_OUT, gpio::LOW); - gpioCookieAcsBoard->addGpio(gpioIds::GYRO_0_ENABLE, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GYRO_0_ADIS_HANDLER; + // Enable pins must be pulled low for regular operations + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + gpioCookieAcsBoard->addGpio(gpioIds::GYRO_0_ENABLE, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GYRO_2_ADIS_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ENABLE, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - gpioCookieAcsBoard->addGpio(gpioIds::GYRO_2_ENABLE, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GYRO_2_ADIS_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ENABLE, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + gpioCookieAcsBoard->addGpio(gpioIds::GYRO_2_ENABLE, gpio); - // Enable pins for GNSS - consumer.str(""); - consumer << "0x" << std::hex << objects::GPS_CONTROLLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::GNSS_0_ENABLE, consumer.str(), - gpio::DIR_OUT, gpio::LOW); - gpioCookieAcsBoard->addGpio(gpioIds::GNSS_0_ENABLE, gpio); + // Enable pins for GNSS + consumer.str(""); + consumer << "0x" << std::hex << objects::GPS_CONTROLLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GNSS_0_ENABLE, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + gpioCookieAcsBoard->addGpio(gpioIds::GNSS_0_ENABLE, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GPS_CONTROLLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::GNSS_1_ENABLE, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - gpioCookieAcsBoard->addGpio(gpioIds::GNSS_1_ENABLE, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GPS_CONTROLLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GNSS_1_ENABLE, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + gpioCookieAcsBoard->addGpio(gpioIds::GNSS_1_ENABLE, gpio); - gpioComIF->addGpios(gpioCookieAcsBoard); + gpioComIF->addGpios(gpioCookieAcsBoard); - std::string spiDev = q7s::SPI_DEFAULT_DEV; - SpiCookie* spiCookie = new SpiCookie(addresses::MGM_0_LIS3, gpioIds::MGM_0_LIS3_CS, spiDev, - MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); - auto mgmLis3Handler = new MgmLIS3MDLHandler(objects::MGM_0_LIS3_HANDLER, objects::SPI_COM_IF, - spiCookie, spi::LIS3_TRANSITION_DELAY); - mgmLis3Handler->setStartUpImmediately(); + std::string spiDev = q7s::SPI_DEFAULT_DEV; + SpiCookie* spiCookie = + new SpiCookie(addresses::MGM_0_LIS3, gpioIds::MGM_0_LIS3_CS, spiDev, + MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); + auto mgmLis3Handler = new MgmLIS3MDLHandler(objects::MGM_0_LIS3_HANDLER, objects::SPI_COM_IF, + spiCookie, spi::LIS3_TRANSITION_DELAY); + mgmLis3Handler->setStartUpImmediately(); #if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1 - mgmLis3Handler->setToGoToNormalMode(true); + mgmLis3Handler->setToGoToNormalMode(true); #endif - spiCookie = new SpiCookie(addresses::MGM_1_RM3100, gpioIds::MGM_1_RM3100_CS, spiDev, - RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); - auto mgmRm3100Handler = new MgmRM3100Handler(objects::MGM_1_RM3100_HANDLER, objects::SPI_COM_IF, - spiCookie, spi::RM3100_TRANSITION_DELAY); - mgmRm3100Handler->setStartUpImmediately(); + spiCookie = + new SpiCookie(addresses::MGM_1_RM3100, gpioIds::MGM_1_RM3100_CS, spiDev, + RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); + auto mgmRm3100Handler = new MgmRM3100Handler(objects::MGM_1_RM3100_HANDLER, objects::SPI_COM_IF, + spiCookie, spi::RM3100_TRANSITION_DELAY); + mgmRm3100Handler->setStartUpImmediately(); #if FSFW_HAL_RM3100_MGM_DEBUG == 1 - mgmRm3100Handler->setToGoToNormalMode(true); + mgmRm3100Handler->setToGoToNormalMode(true); #endif - spiCookie = new SpiCookie(addresses::MGM_2_LIS3, gpioIds::MGM_2_LIS3_CS, spiDev, - MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); - auto mgmLis3Handler2 = new MgmLIS3MDLHandler(objects::MGM_2_LIS3_HANDLER, objects::SPI_COM_IF, - spiCookie, spi::LIS3_TRANSITION_DELAY); - mgmLis3Handler2->setStartUpImmediately(); + spiCookie = + new SpiCookie(addresses::MGM_2_LIS3, gpioIds::MGM_2_LIS3_CS, spiDev, + MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); + auto mgmLis3Handler2 = new MgmLIS3MDLHandler(objects::MGM_2_LIS3_HANDLER, objects::SPI_COM_IF, + spiCookie, spi::LIS3_TRANSITION_DELAY); + mgmLis3Handler2->setStartUpImmediately(); #if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1 - mgmLis3Handler2->setToGoToNormalMode(true); + mgmLis3Handler2->setToGoToNormalMode(true); #endif - spiCookie = new SpiCookie(addresses::MGM_3_RM3100, gpioIds::MGM_3_RM3100_CS, spiDev, - RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); - mgmRm3100Handler = new MgmRM3100Handler(objects::MGM_3_RM3100_HANDLER, objects::SPI_COM_IF, - spiCookie, spi::RM3100_TRANSITION_DELAY); - mgmRm3100Handler->setStartUpImmediately(); + spiCookie = + new SpiCookie(addresses::MGM_3_RM3100, gpioIds::MGM_3_RM3100_CS, spiDev, + RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); + mgmRm3100Handler = new MgmRM3100Handler(objects::MGM_3_RM3100_HANDLER, objects::SPI_COM_IF, + spiCookie, spi::RM3100_TRANSITION_DELAY); + mgmRm3100Handler->setStartUpImmediately(); #if FSFW_HAL_RM3100_MGM_DEBUG == 1 - mgmRm3100Handler->setToGoToNormalMode(true); + mgmRm3100Handler->setToGoToNormalMode(true); #endif - // Commented until ACS board V2 in in clean room again - // Gyro 0 Side A - spiCookie = new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, spiDev, - ADIS1650X::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, - spi::DEFAULT_ADIS16507_SPEED); - auto adisHandler = new GyroADIS1650XHandler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, - spiCookie, ADIS1650X::Type::ADIS16505); - adisHandler->setStartUpImmediately(); - // Gyro 1 Side A - spiCookie = new SpiCookie(addresses::GYRO_1_L3G, gpioIds::GYRO_1_L3G_CS, spiDev, - L3GD20H::MAX_BUFFER_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); - auto gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_1_L3G_HANDLER, objects::SPI_COM_IF, - spiCookie, spi::L3G_TRANSITION_DELAY); - gyroL3gHandler->setStartUpImmediately(); + // Commented until ACS board V2 in in clean room again + // Gyro 0 Side A + spiCookie = new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, spiDev, + ADIS1650X::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, + spi::DEFAULT_ADIS16507_SPEED); + auto adisHandler = new GyroADIS1650XHandler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, + spiCookie, ADIS1650X::Type::ADIS16505); + adisHandler->setStartUpImmediately(); + // Gyro 1 Side A + spiCookie = + new SpiCookie(addresses::GYRO_1_L3G, gpioIds::GYRO_1_L3G_CS, spiDev, L3GD20H::MAX_BUFFER_SIZE, + spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); + auto gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_1_L3G_HANDLER, objects::SPI_COM_IF, + spiCookie, spi::L3G_TRANSITION_DELAY); + gyroL3gHandler->setStartUpImmediately(); #if FSFW_HAL_L3GD20_GYRO_DEBUG == 1 - gyroL3gHandler->setToGoToNormalMode(true); + gyroL3gHandler->setToGoToNormalMode(true); #endif - // Gyro 2 Side B - spiCookie = new SpiCookie(addresses::GYRO_2_ADIS, gpioIds::GYRO_2_ADIS_CS, spiDev, - ADIS1650X::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, - spi::DEFAULT_ADIS16507_SPEED); - adisHandler = new GyroADIS1650XHandler(objects::GYRO_2_ADIS_HANDLER, objects::SPI_COM_IF, - spiCookie, ADIS1650X::Type::ADIS16505); - adisHandler->setStartUpImmediately(); - // Gyro 3 Side B - spiCookie = new SpiCookie(addresses::GYRO_3_L3G, gpioIds::GYRO_3_L3G_CS, spiDev, - L3GD20H::MAX_BUFFER_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); - gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_3_L3G_HANDLER, objects::SPI_COM_IF, - spiCookie, spi::L3G_TRANSITION_DELAY); - gyroL3gHandler->setStartUpImmediately(); + // Gyro 2 Side B + spiCookie = new SpiCookie(addresses::GYRO_2_ADIS, gpioIds::GYRO_2_ADIS_CS, spiDev, + ADIS1650X::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, + spi::DEFAULT_ADIS16507_SPEED); + adisHandler = new GyroADIS1650XHandler(objects::GYRO_2_ADIS_HANDLER, objects::SPI_COM_IF, + spiCookie, ADIS1650X::Type::ADIS16505); + adisHandler->setStartUpImmediately(); + // Gyro 3 Side B + spiCookie = + new SpiCookie(addresses::GYRO_3_L3G, gpioIds::GYRO_3_L3G_CS, spiDev, L3GD20H::MAX_BUFFER_SIZE, + spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); + gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_3_L3G_HANDLER, objects::SPI_COM_IF, + spiCookie, spi::L3G_TRANSITION_DELAY); + gyroL3gHandler->setStartUpImmediately(); #if FSFW_HAL_L3GD20_GYRO_DEBUG == 1 - gyroL3gHandler->setToGoToNormalMode(true); + gyroL3gHandler->setToGoToNormalMode(true); #endif - bool debugGps = false; + bool debugGps = false; #if OBSW_DEBUG_GPS == 1 - debugGps = true; + debugGps = true; #endif - resetArgsGnss1.gnss1 = true; - resetArgsGnss1.gpioComIF = gpioComIF; - resetArgsGnss1.waitPeriodMs = 100; - resetArgsGnss0.gnss1 = false; - resetArgsGnss0.gpioComIF = gpioComIF; - resetArgsGnss0.waitPeriodMs = 100; - auto gpsHandler0 = new GPSHyperionHandler(objects::GPS_CONTROLLER, objects::NO_OBJECT, - debugGps); - gpsHandler0->setResetPinTriggerFunction(gps::triggerGpioResetPin, &resetArgsGnss0); + resetArgsGnss1.gnss1 = true; + resetArgsGnss1.gpioComIF = gpioComIF; + resetArgsGnss1.waitPeriodMs = 100; + resetArgsGnss0.gnss1 = false; + resetArgsGnss0.gpioComIF = gpioComIF; + resetArgsGnss0.waitPeriodMs = 100; + auto gpsHandler0 = new GPSHyperionHandler(objects::GPS_CONTROLLER, objects::NO_OBJECT, debugGps); + gpsHandler0->setResetPinTriggerFunction(gps::triggerGpioResetPin, &resetArgsGnss0); } void ObjectFactory::createHeaterComponents() { + GpioCookie* heaterGpiosCookie = new GpioCookie; + GpiodRegularByLineName* gpio = nullptr; - GpioCookie* heaterGpiosCookie = new GpioCookie; - GpiodRegularByLineName* gpio = nullptr; + std::stringstream consumer; + consumer << "0x" << std::hex << objects::HEATER_HANDLER; + /* Pin H2-11 on stack connector */ + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_0, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_0, gpio); + /* Pin H2-12 on stack connector */ + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_1, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_1, gpio); - std::stringstream consumer; - consumer << "0x" << std::hex << objects::HEATER_HANDLER; - /* Pin H2-11 on stack connector */ - gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_0, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_0, gpio); - /* Pin H2-12 on stack connector */ - gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_1, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_1, gpio); + /* Pin H2-13 on stack connector */ + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_2, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_2, gpio); - /* Pin H2-13 on stack connector */ - gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_2, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_2, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_3, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_3, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_3, consumer.str(), - gpio::DIR_OUT, gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_3, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_4, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_4, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_4, consumer.str(), - gpio::DIR_OUT, gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_4, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_5, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_5, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_5, consumer.str(), - gpio::DIR_OUT, gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_5, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_6, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_6, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_6, consumer.str(), - gpio::DIR_OUT, gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_6, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_7, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_7, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_7, consumer.str(), - gpio::DIR_OUT, gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_7, gpio); - - new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, heaterGpiosCookie, - objects::PCDU_HANDLER, pcduSwitches::TCS_BOARD_8V_HEATER_IN); + new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, heaterGpiosCookie, + objects::PCDU_HANDLER, pcduSwitches::TCS_BOARD_8V_HEATER_IN); } void ObjectFactory::createSolarArrayDeploymentComponents() { - GpioCookie* solarArrayDeplCookie = new GpioCookie; - GpiodRegularByLineName* gpio = nullptr; + GpioCookie* solarArrayDeplCookie = new GpioCookie; + GpiodRegularByLineName* gpio = nullptr; - std::stringstream consumer; - consumer << "0x" << std::hex << objects::SOLAR_ARRAY_DEPL_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::SA_DPL_PIN_0, - consumer.str(), gpio::DIR_OUT, gpio::LOW); - solarArrayDeplCookie->addGpio(gpioIds::DEPLSA1, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::SA_DPL_PIN_1, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - solarArrayDeplCookie->addGpio(gpioIds::DEPLSA2, gpio); + std::stringstream consumer; + consumer << "0x" << std::hex << objects::SOLAR_ARRAY_DEPL_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::SA_DPL_PIN_0, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + solarArrayDeplCookie->addGpio(gpioIds::DEPLSA1, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::SA_DPL_PIN_1, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + solarArrayDeplCookie->addGpio(gpioIds::DEPLSA2, gpio); - //TODO: Find out burn time. For now set to 1000 ms. - new SolarArrayDeploymentHandler(objects::SOLAR_ARRAY_DEPL_HANDLER, objects::GPIO_IF, - solarArrayDeplCookie, objects::PCDU_HANDLER, pcduSwitches::DEPLOYMENT_MECHANISM, - gpioIds::DEPLSA1, gpioIds::DEPLSA2, 1000); + // TODO: Find out burn time. For now set to 1000 ms. + new SolarArrayDeploymentHandler(objects::SOLAR_ARRAY_DEPL_HANDLER, objects::GPIO_IF, + solarArrayDeplCookie, objects::PCDU_HANDLER, + pcduSwitches::DEPLOYMENT_MECHANISM, gpioIds::DEPLSA1, + gpioIds::DEPLSA2, 1000); } void ObjectFactory::createSyrlinksComponents() { - UartCookie* syrlinksUartCookie = new UartCookie(objects::SYRLINKS_HK_HANDLER, - q7s::UART_SYRLINKS_DEV, UartModes::NON_CANONICAL, uart::SYRLINKS_BAUD, - SYRLINKS::MAX_REPLY_SIZE); - syrlinksUartCookie->setParityEven(); + UartCookie* syrlinksUartCookie = + new UartCookie(objects::SYRLINKS_HK_HANDLER, q7s::UART_SYRLINKS_DEV, UartModes::NON_CANONICAL, + uart::SYRLINKS_BAUD, SYRLINKS::MAX_REPLY_SIZE); + syrlinksUartCookie->setParityEven(); - new SyrlinksHkHandler(objects::SYRLINKS_HK_HANDLER, objects::UART_COM_IF, syrlinksUartCookie); + new SyrlinksHkHandler(objects::SYRLINKS_HK_HANDLER, objects::UART_COM_IF, syrlinksUartCookie); } -void ObjectFactory::createRtdComponents(LinuxLibgpioIF *gpioComIF) { - GpioCookie* rtdGpioCookie = new GpioCookie; +void ObjectFactory::createRtdComponents(LinuxLibgpioIF* gpioComIF) { + GpioCookie* rtdGpioCookie = new GpioCookie; - GpioCallback* gpioRtdIc0 = new GpioCallback("Chip select RTD IC0", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_3, gpioRtdIc0); - GpioCallback* gpioRtdIc1 = new GpioCallback("Chip select RTD IC1", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_4, gpioRtdIc1); - GpioCallback* gpioRtdIc2 = new GpioCallback("Chip select RTD IC2", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_5, gpioRtdIc2); - GpioCallback* gpioRtdIc3 = new GpioCallback("Chip select RTD IC3", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_6, gpioRtdIc3); - GpioCallback* gpioRtdIc4 = new GpioCallback("Chip select RTD IC4", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_7, gpioRtdIc4); - GpioCallback* gpioRtdIc5 = new GpioCallback("Chip select RTD IC5", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_8, gpioRtdIc5); - GpioCallback* gpioRtdIc6 = new GpioCallback("Chip select RTD IC6", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_9, gpioRtdIc6); - GpioCallback* gpioRtdIc7 = new GpioCallback("Chip select RTD IC7", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_10, gpioRtdIc7); - GpioCallback* gpioRtdIc8 = new GpioCallback("Chip select RTD IC8", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_11, gpioRtdIc8); - GpioCallback* gpioRtdIc9 = new GpioCallback("Chip select RTD IC9", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_12, gpioRtdIc9); - GpioCallback* gpioRtdIc10 = new GpioCallback("Chip select RTD IC10", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_13, gpioRtdIc10); - GpioCallback* gpioRtdIc11 = new GpioCallback("Chip select RTD IC11", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_14, gpioRtdIc11); - GpioCallback* gpioRtdIc12 = new GpioCallback("Chip select RTD IC12", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_15, gpioRtdIc12); - GpioCallback* gpioRtdIc13 = new GpioCallback("Chip select RTD IC13", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_16, gpioRtdIc13); - GpioCallback* gpioRtdIc14 = new GpioCallback("Chip select RTD IC14", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_17, gpioRtdIc14); - GpioCallback* gpioRtdIc15 = new GpioCallback("Chip select RTD IC15", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_18, gpioRtdIc15); + GpioCallback* gpioRtdIc0 = new GpioCallback("Chip select RTD IC0", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_3, gpioRtdIc0); + GpioCallback* gpioRtdIc1 = new GpioCallback("Chip select RTD IC1", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_4, gpioRtdIc1); + GpioCallback* gpioRtdIc2 = new GpioCallback("Chip select RTD IC2", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_5, gpioRtdIc2); + GpioCallback* gpioRtdIc3 = new GpioCallback("Chip select RTD IC3", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_6, gpioRtdIc3); + GpioCallback* gpioRtdIc4 = new GpioCallback("Chip select RTD IC4", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_7, gpioRtdIc4); + GpioCallback* gpioRtdIc5 = new GpioCallback("Chip select RTD IC5", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_8, gpioRtdIc5); + GpioCallback* gpioRtdIc6 = new GpioCallback("Chip select RTD IC6", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_9, gpioRtdIc6); + GpioCallback* gpioRtdIc7 = new GpioCallback("Chip select RTD IC7", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_10, gpioRtdIc7); + GpioCallback* gpioRtdIc8 = new GpioCallback("Chip select RTD IC8", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_11, gpioRtdIc8); + GpioCallback* gpioRtdIc9 = new GpioCallback("Chip select RTD IC9", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_12, gpioRtdIc9); + GpioCallback* gpioRtdIc10 = new GpioCallback("Chip select RTD IC10", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_13, gpioRtdIc10); + GpioCallback* gpioRtdIc11 = new GpioCallback("Chip select RTD IC11", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_14, gpioRtdIc11); + GpioCallback* gpioRtdIc12 = new GpioCallback("Chip select RTD IC12", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_15, gpioRtdIc12); + GpioCallback* gpioRtdIc13 = new GpioCallback("Chip select RTD IC13", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_16, gpioRtdIc13); + GpioCallback* gpioRtdIc14 = new GpioCallback("Chip select RTD IC14", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_17, gpioRtdIc14); + GpioCallback* gpioRtdIc15 = new GpioCallback("Chip select RTD IC15", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_18, gpioRtdIc15); - gpioComIF->addGpios(rtdGpioCookie); + gpioComIF->addGpios(rtdGpioCookie); - SpiCookie* spiRtdIc0 = new SpiCookie(addresses::RTD_IC_3, gpioIds::RTD_IC_3, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); - SpiCookie* spiRtdIc1 = new SpiCookie(addresses::RTD_IC_4, gpioIds::RTD_IC_4, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); - SpiCookie* spiRtdIc2 = new SpiCookie(addresses::RTD_IC_5, gpioIds::RTD_IC_5, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); - SpiCookie* spiRtdIc3 = new SpiCookie(addresses::RTD_IC_6, gpioIds::RTD_IC_6, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); - SpiCookie* spiRtdIc4 = new SpiCookie(addresses::RTD_IC_7, gpioIds::RTD_IC_7, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); - SpiCookie* spiRtdIc5 = new SpiCookie(addresses::RTD_IC_8, gpioIds::RTD_IC_8, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); - SpiCookie* spiRtdIc6 = new SpiCookie(addresses::RTD_IC_9, gpioIds::RTD_IC_9, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); - SpiCookie* spiRtdIc7 = new SpiCookie(addresses::RTD_IC_10, gpioIds::RTD_IC_10, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, - spi::RTD_SPEED); - SpiCookie* spiRtdIc8 = new SpiCookie(addresses::RTD_IC_11, gpioIds::RTD_IC_11, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, - spi::RTD_SPEED); - SpiCookie* spiRtdIc9 = new SpiCookie(addresses::RTD_IC_12, gpioIds::RTD_IC_12, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, - spi::RTD_SPEED); - SpiCookie* spiRtdIc10 = new SpiCookie(addresses::RTD_IC_13, gpioIds::RTD_IC_13, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, - spi::RTD_SPEED); - SpiCookie* spiRtdIc11 = new SpiCookie(addresses::RTD_IC_14, gpioIds::RTD_IC_14, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, - spi::RTD_SPEED); - SpiCookie* spiRtdIc12 = new SpiCookie(addresses::RTD_IC_15, gpioIds::RTD_IC_15, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, - spi::RTD_SPEED); - SpiCookie* spiRtdIc13 = new SpiCookie(addresses::RTD_IC_16, gpioIds::RTD_IC_16, - std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, - spi::RTD_MODE, spi::RTD_SPEED); - SpiCookie* spiRtdIc14 = new SpiCookie(addresses::RTD_IC_17, gpioIds::RTD_IC_17, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, - spi::RTD_SPEED); - SpiCookie* spiRtdIc15 = new SpiCookie(addresses::RTD_IC_18, gpioIds::RTD_IC_18, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, - spi::RTD_SPEED); + SpiCookie* spiRtdIc0 = + new SpiCookie(addresses::RTD_IC_3, gpioIds::RTD_IC_3, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc1 = + new SpiCookie(addresses::RTD_IC_4, gpioIds::RTD_IC_4, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc2 = + new SpiCookie(addresses::RTD_IC_5, gpioIds::RTD_IC_5, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc3 = + new SpiCookie(addresses::RTD_IC_6, gpioIds::RTD_IC_6, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc4 = + new SpiCookie(addresses::RTD_IC_7, gpioIds::RTD_IC_7, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc5 = + new SpiCookie(addresses::RTD_IC_8, gpioIds::RTD_IC_8, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc6 = + new SpiCookie(addresses::RTD_IC_9, gpioIds::RTD_IC_9, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc7 = + new SpiCookie(addresses::RTD_IC_10, gpioIds::RTD_IC_10, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc8 = + new SpiCookie(addresses::RTD_IC_11, gpioIds::RTD_IC_11, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc9 = + new SpiCookie(addresses::RTD_IC_12, gpioIds::RTD_IC_12, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc10 = + new SpiCookie(addresses::RTD_IC_13, gpioIds::RTD_IC_13, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc11 = + new SpiCookie(addresses::RTD_IC_14, gpioIds::RTD_IC_14, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc12 = + new SpiCookie(addresses::RTD_IC_15, gpioIds::RTD_IC_15, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc13 = + new SpiCookie(addresses::RTD_IC_16, gpioIds::RTD_IC_16, std::string(q7s::SPI_DEFAULT_DEV), + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc14 = + new SpiCookie(addresses::RTD_IC_17, gpioIds::RTD_IC_17, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc15 = + new SpiCookie(addresses::RTD_IC_18, gpioIds::RTD_IC_18, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); - Max31865PT1000Handler* rtdIc0 = new Max31865PT1000Handler(objects::RTD_IC_3, objects::SPI_COM_IF, - spiRtdIc0); - Max31865PT1000Handler* rtdIc1 = new Max31865PT1000Handler(objects::RTD_IC_4, objects::SPI_COM_IF, - spiRtdIc1); - Max31865PT1000Handler* rtdIc2 = new Max31865PT1000Handler(objects::RTD_IC_5, objects::SPI_COM_IF, - spiRtdIc2); - Max31865PT1000Handler* rtdIc3 = new Max31865PT1000Handler(objects::RTD_IC_6, objects::SPI_COM_IF, - spiRtdIc3); - Max31865PT1000Handler* rtdIc4 = new Max31865PT1000Handler(objects::RTD_IC_7, objects::SPI_COM_IF, - spiRtdIc4); - Max31865PT1000Handler* rtdIc5 = new Max31865PT1000Handler(objects::RTD_IC_8, objects::SPI_COM_IF, - spiRtdIc5); - Max31865PT1000Handler* rtdIc6 = new Max31865PT1000Handler(objects::RTD_IC_9, objects::SPI_COM_IF, - spiRtdIc6); - Max31865PT1000Handler* rtdIc7 = new Max31865PT1000Handler(objects::RTD_IC_10, - objects::SPI_COM_IF, spiRtdIc7); - Max31865PT1000Handler* rtdIc8 = new Max31865PT1000Handler(objects::RTD_IC_11, - objects::SPI_COM_IF, spiRtdIc8); - Max31865PT1000Handler* rtdIc9 = new Max31865PT1000Handler(objects::RTD_IC_12, - objects::SPI_COM_IF, spiRtdIc9); - Max31865PT1000Handler* rtdIc10 = new Max31865PT1000Handler(objects::RTD_IC_13, - objects::SPI_COM_IF, spiRtdIc10); - Max31865PT1000Handler* rtdIc11 = new Max31865PT1000Handler(objects::RTD_IC_14, - objects::SPI_COM_IF, spiRtdIc11); - Max31865PT1000Handler* rtdIc12 = new Max31865PT1000Handler(objects::RTD_IC_15, - objects::SPI_COM_IF, spiRtdIc12); - Max31865PT1000Handler* rtdIc13 = new Max31865PT1000Handler(objects::RTD_IC_16, - objects::SPI_COM_IF, spiRtdIc13); - Max31865PT1000Handler* rtdIc14 = new Max31865PT1000Handler(objects::RTD_IC_17, - objects::SPI_COM_IF, spiRtdIc14); - Max31865PT1000Handler* rtdIc15 = new Max31865PT1000Handler(objects::RTD_IC_18, - objects::SPI_COM_IF, spiRtdIc15); + Max31865PT1000Handler* rtdIc0 = + new Max31865PT1000Handler(objects::RTD_IC_3, objects::SPI_COM_IF, spiRtdIc0); + Max31865PT1000Handler* rtdIc1 = + new Max31865PT1000Handler(objects::RTD_IC_4, objects::SPI_COM_IF, spiRtdIc1); + Max31865PT1000Handler* rtdIc2 = + new Max31865PT1000Handler(objects::RTD_IC_5, objects::SPI_COM_IF, spiRtdIc2); + Max31865PT1000Handler* rtdIc3 = + new Max31865PT1000Handler(objects::RTD_IC_6, objects::SPI_COM_IF, spiRtdIc3); + Max31865PT1000Handler* rtdIc4 = + new Max31865PT1000Handler(objects::RTD_IC_7, objects::SPI_COM_IF, spiRtdIc4); + Max31865PT1000Handler* rtdIc5 = + new Max31865PT1000Handler(objects::RTD_IC_8, objects::SPI_COM_IF, spiRtdIc5); + Max31865PT1000Handler* rtdIc6 = + new Max31865PT1000Handler(objects::RTD_IC_9, objects::SPI_COM_IF, spiRtdIc6); + Max31865PT1000Handler* rtdIc7 = + new Max31865PT1000Handler(objects::RTD_IC_10, objects::SPI_COM_IF, spiRtdIc7); + Max31865PT1000Handler* rtdIc8 = + new Max31865PT1000Handler(objects::RTD_IC_11, objects::SPI_COM_IF, spiRtdIc8); + Max31865PT1000Handler* rtdIc9 = + new Max31865PT1000Handler(objects::RTD_IC_12, objects::SPI_COM_IF, spiRtdIc9); + Max31865PT1000Handler* rtdIc10 = + new Max31865PT1000Handler(objects::RTD_IC_13, objects::SPI_COM_IF, spiRtdIc10); + Max31865PT1000Handler* rtdIc11 = + new Max31865PT1000Handler(objects::RTD_IC_14, objects::SPI_COM_IF, spiRtdIc11); + Max31865PT1000Handler* rtdIc12 = + new Max31865PT1000Handler(objects::RTD_IC_15, objects::SPI_COM_IF, spiRtdIc12); + Max31865PT1000Handler* rtdIc13 = + new Max31865PT1000Handler(objects::RTD_IC_16, objects::SPI_COM_IF, spiRtdIc13); + Max31865PT1000Handler* rtdIc14 = + new Max31865PT1000Handler(objects::RTD_IC_17, objects::SPI_COM_IF, spiRtdIc14); + Max31865PT1000Handler* rtdIc15 = + new Max31865PT1000Handler(objects::RTD_IC_18, objects::SPI_COM_IF, spiRtdIc15); - rtdIc0->setStartUpImmediately(); - rtdIc1->setStartUpImmediately(); - rtdIc2->setStartUpImmediately(); + rtdIc0->setStartUpImmediately(); + rtdIc1->setStartUpImmediately(); + rtdIc2->setStartUpImmediately(); #if OBSW_DEBUG_RTD == 1 - rtdIc0->setInstantNormal(true); - rtdIc1->setInstantNormal(true); - rtdIc2->setInstantNormal(true); + rtdIc0->setInstantNormal(true); + rtdIc1->setInstantNormal(true); + rtdIc2->setInstantNormal(true); #endif - static_cast(rtdIc0); - static_cast(rtdIc1); - static_cast(rtdIc2); - static_cast(rtdIc3); - static_cast(rtdIc4); - static_cast(rtdIc5); - static_cast(rtdIc6); - static_cast(rtdIc7); - static_cast(rtdIc8); - static_cast(rtdIc9); - static_cast(rtdIc10); - static_cast(rtdIc11); - static_cast(rtdIc12); - static_cast(rtdIc13); - static_cast(rtdIc14); - static_cast(rtdIc15); + static_cast(rtdIc0); + static_cast(rtdIc1); + static_cast(rtdIc2); + static_cast(rtdIc3); + static_cast(rtdIc4); + static_cast(rtdIc5); + static_cast(rtdIc6); + static_cast(rtdIc7); + static_cast(rtdIc8); + static_cast(rtdIc9); + static_cast(rtdIc10); + static_cast(rtdIc11); + static_cast(rtdIc12); + static_cast(rtdIc13); + static_cast(rtdIc14); + static_cast(rtdIc15); } void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF) { - GpioCookie* gpioCookieRw = new GpioCookie; - GpioCallback* csRw1 = new GpioCallback("Chip select reaction wheel 1", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieRw->addGpio(gpioIds::CS_RW1, csRw1); - GpioCallback* csRw2 = new GpioCallback("Chip select reaction wheel 2", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieRw->addGpio(gpioIds::CS_RW2, csRw2); - GpioCallback* csRw3 = new GpioCallback("Chip select reaction wheel 3", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieRw->addGpio(gpioIds::CS_RW3, csRw3); - GpioCallback* csRw4 = new GpioCallback("Chip select reaction wheel 4", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieRw->addGpio(gpioIds::CS_RW4, csRw4); + GpioCookie* gpioCookieRw = new GpioCookie; + GpioCallback* csRw1 = new GpioCallback("Chip select reaction wheel 1", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieRw->addGpio(gpioIds::CS_RW1, csRw1); + GpioCallback* csRw2 = new GpioCallback("Chip select reaction wheel 2", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieRw->addGpio(gpioIds::CS_RW2, csRw2); + GpioCallback* csRw3 = new GpioCallback("Chip select reaction wheel 3", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieRw->addGpio(gpioIds::CS_RW3, csRw3); + GpioCallback* csRw4 = new GpioCallback("Chip select reaction wheel 4", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieRw->addGpio(gpioIds::CS_RW4, csRw4); - std::stringstream consumer; - GpiodRegularByLineName* gpio = nullptr; - consumer << "0x" << std::hex << objects::RW1; - gpio = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_1, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - gpioCookieRw->addGpio(gpioIds::EN_RW1, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::RW2; - gpio = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_2, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - gpioCookieRw->addGpio(gpioIds::EN_RW2, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::RW3; - gpio = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_3, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - gpioCookieRw->addGpio(gpioIds::EN_RW3, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::RW4; - gpio = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_4, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - gpioCookieRw->addGpio(gpioIds::EN_RW4, gpio); + std::stringstream consumer; + GpiodRegularByLineName* gpio = nullptr; + consumer << "0x" << std::hex << objects::RW1; + gpio = + new GpiodRegularByLineName(q7s::gpioNames::EN_RW_1, consumer.str(), gpio::DIR_OUT, gpio::LOW); + gpioCookieRw->addGpio(gpioIds::EN_RW1, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::RW2; + gpio = + new GpiodRegularByLineName(q7s::gpioNames::EN_RW_2, consumer.str(), gpio::DIR_OUT, gpio::LOW); + gpioCookieRw->addGpio(gpioIds::EN_RW2, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::RW3; + gpio = + new GpiodRegularByLineName(q7s::gpioNames::EN_RW_3, consumer.str(), gpio::DIR_OUT, gpio::LOW); + gpioCookieRw->addGpio(gpioIds::EN_RW3, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::RW4; + gpio = + new GpiodRegularByLineName(q7s::gpioNames::EN_RW_4, consumer.str(), gpio::DIR_OUT, gpio::LOW); + gpioCookieRw->addGpio(gpioIds::EN_RW4, gpio); - gpioComIF->addGpios(gpioCookieRw); + gpioComIF->addGpios(gpioCookieRw); - auto rw1SpiCookie = new SpiCookie(addresses::RW1, gpioIds::CS_RW1, q7s::SPI_RW_DEV, - RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, - nullptr); - auto rw2SpiCookie = new SpiCookie(addresses::RW2, gpioIds::CS_RW2, q7s::SPI_RW_DEV, - RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, - nullptr); - auto rw3SpiCookie = new SpiCookie(addresses::RW3, gpioIds::CS_RW3, q7s::SPI_RW_DEV, - RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, - nullptr); - auto rw4SpiCookie = new SpiCookie(addresses::RW4, gpioIds::CS_RW4, q7s::SPI_RW_DEV, - RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, - nullptr); + auto rw1SpiCookie = + new SpiCookie(addresses::RW1, gpioIds::CS_RW1, q7s::SPI_RW_DEV, RwDefinitions::MAX_REPLY_SIZE, + spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, nullptr); + auto rw2SpiCookie = + new SpiCookie(addresses::RW2, gpioIds::CS_RW2, q7s::SPI_RW_DEV, RwDefinitions::MAX_REPLY_SIZE, + spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, nullptr); + auto rw3SpiCookie = + new SpiCookie(addresses::RW3, gpioIds::CS_RW3, q7s::SPI_RW_DEV, RwDefinitions::MAX_REPLY_SIZE, + spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, nullptr); + auto rw4SpiCookie = + new SpiCookie(addresses::RW4, gpioIds::CS_RW4, q7s::SPI_RW_DEV, RwDefinitions::MAX_REPLY_SIZE, + spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, nullptr); - auto rwHandler1 = new RwHandler(objects::RW1, objects::SPI_COM_IF, rw1SpiCookie, gpioComIF, - gpioIds::EN_RW1); + auto rwHandler1 = + new RwHandler(objects::RW1, objects::SPI_COM_IF, rw1SpiCookie, gpioComIF, gpioIds::EN_RW1); #if OBSW_DEBUG_RW == 1 - rwHandler1->setStartUpImmediately(); + rwHandler1->setStartUpImmediately(); #endif - rw1SpiCookie->setCallbackArgs(rwHandler1); - rwHandler1->setStartUpImmediately(); + rw1SpiCookie->setCallbackArgs(rwHandler1); + rwHandler1->setStartUpImmediately(); - auto rwHandler2 = new RwHandler(objects::RW2, objects::SPI_COM_IF, rw2SpiCookie, gpioComIF, - gpioIds::EN_RW2); + auto rwHandler2 = + new RwHandler(objects::RW2, objects::SPI_COM_IF, rw2SpiCookie, gpioComIF, gpioIds::EN_RW2); #if OBSW_DEBUG_RW == 1 - rwHandler2->setStartUpImmediately(); + rwHandler2->setStartUpImmediately(); #endif - rw2SpiCookie->setCallbackArgs(rwHandler2); + rw2SpiCookie->setCallbackArgs(rwHandler2); - auto rwHandler3 = new RwHandler(objects::RW3, objects::SPI_COM_IF, rw3SpiCookie, gpioComIF, - gpioIds::EN_RW3); + auto rwHandler3 = + new RwHandler(objects::RW3, objects::SPI_COM_IF, rw3SpiCookie, gpioComIF, gpioIds::EN_RW3); #if OBSW_DEBUG_RW == 1 - rwHandler3->setStartUpImmediately(); + rwHandler3->setStartUpImmediately(); #endif - rw3SpiCookie->setCallbackArgs(rwHandler3); + rw3SpiCookie->setCallbackArgs(rwHandler3); - auto rwHandler4 = new RwHandler(objects::RW4, objects::SPI_COM_IF, rw4SpiCookie, gpioComIF, - gpioIds::EN_RW4); + auto rwHandler4 = + new RwHandler(objects::RW4, objects::SPI_COM_IF, rw4SpiCookie, gpioComIF, gpioIds::EN_RW4); #if OBSW_DEBUG_RW == 1 - rwHandler4->setStartUpImmediately(); + rwHandler4->setStartUpImmediately(); #endif - rw4SpiCookie->setCallbackArgs(rwHandler4); + rw4SpiCookie->setCallbackArgs(rwHandler4); } -void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF *gpioComIF) { - // GPIO definitions of signals connected to the virtual channel interfaces of the PTME IP Core - GpioCookie* gpioCookiePtmeIp = new GpioCookie; - GpiodRegularByLineName* gpio = nullptr; - std::stringstream consumer; - consumer << "0x" << std::hex << objects::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; - 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; - 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()); - gpioCookiePtmeIp->addGpio(gpioIds::VC1_PAPB_EMPTY, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::PAPB_VC2; - 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; - 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; - 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; - gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_EMPTY_SIGNAL_VC3, consumer.str()); - gpioCookiePtmeIp->addGpio(gpioIds::VC3_PAPB_EMPTY, gpio); +void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF* gpioComIF) { + // GPIO definitions of signals connected to the virtual channel interfaces of the PTME IP Core + GpioCookie* gpioCookiePtmeIp = new GpioCookie; + GpiodRegularByLineName* gpio = nullptr; + std::stringstream consumer; + consumer << "0x" << std::hex << objects::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; + 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; + 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()); + gpioCookiePtmeIp->addGpio(gpioIds::VC1_PAPB_EMPTY, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::PAPB_VC2; + 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; + 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; + 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; + gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_EMPTY_SIGNAL_VC3, consumer.str()); + gpioCookiePtmeIp->addGpio(gpioIds::VC3_PAPB_EMPTY, gpio); - gpioComIF->addGpios(gpioCookiePtmeIp); + 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); + // 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); - // Creating ptme object and adding virtual channel interfaces - Ptme* ptme = new Ptme(objects::PTME); - ptme->addVcInterface(ccsds::VC0, vc0); - ptme->addVcInterface(ccsds::VC1, vc1); - ptme->addVcInterface(ccsds::VC2, vc2); - ptme->addVcInterface(ccsds::VC3, vc3); + // Creating ptme object and adding virtual channel interfaces + Ptme* ptme = new Ptme(objects::PTME); + ptme->addVcInterface(ccsds::VC0, vc0); + ptme->addVcInterface(ccsds::VC1, vc1); + 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); + 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); + TxRateSetterIF* txRateSetterIF = new PtmeRateSetter(gpioIds::BIT_RATE_SEL, gpioComIF); - 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); + 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); - VirtualChannel* vc = nullptr; - vc = new VirtualChannel(ccsds::VC0, common::VC0_QUEUE_SIZE); - ccsdsHandler->addVirtualChannel(ccsds::VC0, vc); - vc = new VirtualChannel(ccsds::VC1, common::VC1_QUEUE_SIZE); - ccsdsHandler->addVirtualChannel(ccsds::VC1, vc); - vc = new VirtualChannel(ccsds::VC2, common::VC2_QUEUE_SIZE); - ccsdsHandler->addVirtualChannel(ccsds::VC2, vc); - vc = new VirtualChannel(ccsds::VC3, common::VC3_QUEUE_SIZE); - ccsdsHandler->addVirtualChannel(ccsds::VC3, vc); + VirtualChannel* vc = nullptr; + vc = new VirtualChannel(ccsds::VC0, common::VC0_QUEUE_SIZE); + ccsdsHandler->addVirtualChannel(ccsds::VC0, vc); + vc = new VirtualChannel(ccsds::VC1, common::VC1_QUEUE_SIZE); + ccsdsHandler->addVirtualChannel(ccsds::VC1, vc); + vc = new VirtualChannel(ccsds::VC2, common::VC2_QUEUE_SIZE); + ccsdsHandler->addVirtualChannel(ccsds::VC2, vc); + vc = new VirtualChannel(ccsds::VC3, common::VC3_QUEUE_SIZE); + ccsdsHandler->addVirtualChannel(ccsds::VC3, vc); - GpioCookie* gpioCookiePdec = new GpioCookie; - consumer.str(""); - consumer << "0x" << std::hex << objects::PDEC_HANDLER; - // GPIO also low after linux boot (specified by device-tree) - gpio = new GpiodRegularByLineName(q7s::gpioNames::PDEC_RESET, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - gpioCookiePdec->addGpio(gpioIds::PDEC_RESET, gpio); + GpioCookie* gpioCookiePdec = new GpioCookie; + consumer.str(""); + consumer << "0x" << std::hex << objects::PDEC_HANDLER; + // GPIO also low after linux boot (specified by device-tree) + gpio = new GpiodRegularByLineName(q7s::gpioNames::PDEC_RESET, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + gpioCookiePdec->addGpio(gpioIds::PDEC_RESET, gpio); - gpioComIF->addGpios(gpioCookiePdec); + 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)); + 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)); #if BOARD_TE0720 == 0 - GpioCookie* gpioRS485Chip = new GpioCookie; - gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_TX_CLOCK, "RS485 Transceiver", - gpio::Direction::DIR_OUT, gpio::LOW); - gpioRS485Chip->addGpio(gpioIds::RS485_EN_TX_CLOCK, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_TX_DATA, "RS485 Transceiver", - gpio::Direction::DIR_OUT, gpio::LOW); - gpioRS485Chip->addGpio(gpioIds::RS485_EN_TX_DATA, gpio); + GpioCookie* gpioRS485Chip = new GpioCookie; + gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_TX_CLOCK, "RS485 Transceiver", + gpio::Direction::DIR_OUT, gpio::LOW); + gpioRS485Chip->addGpio(gpioIds::RS485_EN_TX_CLOCK, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_TX_DATA, "RS485 Transceiver", + gpio::Direction::DIR_OUT, gpio::LOW); + gpioRS485Chip->addGpio(gpioIds::RS485_EN_TX_DATA, gpio); - // Default configuration enables RX channels (RXEN = LOW) - gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_RX_CLOCK, "RS485 Transceiver", - gpio::Direction::DIR_OUT, gpio::LOW); - gpioRS485Chip->addGpio(gpioIds::RS485_EN_RX_CLOCK, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_RX_DATA, "RS485 Transceiver", - gpio::Direction::DIR_OUT, gpio::LOW); - gpioRS485Chip->addGpio(gpioIds::RS485_EN_RX_DATA, gpio); + // Default configuration enables RX channels (RXEN = LOW) + gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_RX_CLOCK, "RS485 Transceiver", + gpio::Direction::DIR_OUT, gpio::LOW); + gpioRS485Chip->addGpio(gpioIds::RS485_EN_RX_CLOCK, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_RX_DATA, "RS485 Transceiver", + gpio::Direction::DIR_OUT, gpio::LOW); + gpioRS485Chip->addGpio(gpioIds::RS485_EN_RX_DATA, gpio); - gpioComIF->addGpios(gpioRS485Chip); + gpioComIF->addGpios(gpioRS485Chip); #endif /* BOARD_TE0720 == 0 */ } void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) { - #if BOARD_TE0720 == 0 - new Q7STestTask(objects::TEST_TASK); + new Q7STestTask(objects::TEST_TASK); #endif #if BOARD_TE0720 == 1 && OBSW_TEST_LIBGPIOD == 1 #if OBSW_TEST_GPIO_OPEN_BYLABEL == 1 - /* Configure MIO0 as input */ - GpiodRegular* testGpio = new GpiodRegular("MIO0", gpio::DIR_OUT, 0, "/amba_pl/gpio@41200000", 0); + /* Configure MIO0 as input */ + GpiodRegular* testGpio = new GpiodRegular("MIO0", gpio::DIR_OUT, 0, "/amba_pl/gpio@41200000", 0); #elif OBSW_TEST_GPIO_OPEN_BY_LINE_NAME - GpiodRegularByLineName* testGpio = new GpiodRegularByLineName("test-name", "gpio-test", - gpio::DIR_OUT, 0); + GpiodRegularByLineName* testGpio = + new GpiodRegularByLineName("test-name", "gpio-test", gpio::DIR_OUT, 0); #else - /* Configure MIO0 as input */ - GpiodRegular* testGpio = new GpiodRegular("gpiochip0", 0, "MIO0", gpio::IN, 0); + /* Configure MIO0 as input */ + GpiodRegular* testGpio = new GpiodRegular("gpiochip0", 0, "MIO0", gpio::IN, 0); #endif /* OBSW_TEST_GPIO_LABEL == 1 */ - GpioCookie* gpioCookie = new GpioCookie; - gpioCookie->addGpio(gpioIds::TEST_ID_0, testGpio); - new LibgpiodTest(objects::LIBGPIOD_TEST, objects::GPIO_IF, gpioCookie); + GpioCookie* gpioCookie = new GpioCookie; + gpioCookie->addGpio(gpioIds::TEST_ID_0, testGpio); + new LibgpiodTest(objects::LIBGPIOD_TEST, objects::GPIO_IF, gpioCookie); #endif #if BOARD_TE0720 == 1 && OBSW_TEST_SUS_HANDLER == 1 - GpioCookie* gpioCookieSus = new GpioCookie; - GpiodRegular* chipSelectSus = new GpiodRegular(std::string("gpiochip1"), 9, - std::string("Chip Select Sus Sensor"), gpio::DIR_OUT, 1); - gpioCookieSus->addGpio(gpioIds::CS_SUS_1, chipSelectSus); - gpioComIF->addGpios(gpioCookieSus); + GpioCookie* gpioCookieSus = new GpioCookie; + GpiodRegular* chipSelectSus = new GpiodRegular( + std::string("gpiochip1"), 9, std::string("Chip Select Sus Sensor"), gpio::DIR_OUT, 1); + gpioCookieSus->addGpio(gpioIds::CS_SUS_1, chipSelectSus); + gpioComIF->addGpios(gpioCookieSus); - SpiCookie* spiCookieSus = new SpiCookie(addresses::SUS_1, std::string("/dev/spidev1.0"), - SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED); + SpiCookie* spiCookieSus = + new SpiCookie(addresses::SUS_1, std::string("/dev/spidev1.0"), SUS::MAX_CMD_SIZE, + spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED); - new SusHandler(objects::SUS_1, objects::SPI_COM_IF, spiCookieSus, gpioComIF, - gpioIds::CS_SUS_1); + new SusHandler(objects::SUS_1, objects::SPI_COM_IF, spiCookieSus, gpioComIF, gpioIds::CS_SUS_1); #endif #if BOARD_TE0720 == 1 && OBSW_TEST_CCSDS_BRIDGE == 1 - GpioCookie* gpioCookieCcsdsIp = new GpioCookie; - GpiodRegular* papbBusyN = new GpiodRegular(std::string("gpiochip0"), 0, std::string("PAPBBusy_VC0")); - gpioCookieCcsdsIp->addGpio(gpioIds::PAPB_BUSY_N, papbBusyN); - GpiodRegular* papbEmpty = new GpiodRegular(std::string("gpiochip0"), 1, - std::string("PAPBEmpty_VC0")); - gpioCookieCcsdsIp->addGpio(gpioIds::PAPB_EMPTY, papbEmpty); - gpioComIF->addGpios(gpioCookieCcsdsIp); + GpioCookie* gpioCookieCcsdsIp = new GpioCookie; + GpiodRegular* papbBusyN = + new GpiodRegular(std::string("gpiochip0"), 0, std::string("PAPBBusy_VC0")); + gpioCookieCcsdsIp->addGpio(gpioIds::PAPB_BUSY_N, papbBusyN); + GpiodRegular* papbEmpty = + new GpiodRegular(std::string("gpiochip0"), 1, std::string("PAPBEmpty_VC0")); + gpioCookieCcsdsIp->addGpio(gpioIds::PAPB_EMPTY, papbEmpty); + gpioComIF->addGpios(gpioCookieCcsdsIp); - new CCSDSIPCoreBridge(objects::CCSDS_IP_CORE_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR, - objects::TM_STORE, objects::TC_STORE, gpioComIF, std::string("/dev/uio0"), - gpioIds::PAPB_BUSY_N, gpioIds::PAPB_EMPTY); + new CCSDSIPCoreBridge(objects::CCSDS_IP_CORE_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR, + objects::TM_STORE, objects::TC_STORE, gpioComIF, std::string("/dev/uio0"), + gpioIds::PAPB_BUSY_N, gpioIds::PAPB_EMPTY); #endif #if BOARD_TE0720 == 1 && OBSW_TEST_RADIATION_SENSOR_HANDLER == 1 - GpioCookie* gpioCookieRadSensor = new GpioCookie; - GpiodRegular* chipSelectRadSensor = new GpiodRegular(std::string("gpiochip1"), 0, - std::string("Chip select radiation sensor"), gpio::DIR_OUT, 1); - gpioCookieRadSensor->addGpio(gpioIds::CS_RAD_SENSOR, chipSelectRadSensor); - gpioComIF->addGpios(gpioCookieRadSensor); + GpioCookie* gpioCookieRadSensor = new GpioCookie; + GpiodRegular* chipSelectRadSensor = new GpiodRegular( + std::string("gpiochip1"), 0, std::string("Chip select radiation sensor"), gpio::DIR_OUT, 1); + gpioCookieRadSensor->addGpio(gpioIds::CS_RAD_SENSOR, chipSelectRadSensor); + gpioComIF->addGpios(gpioCookieRadSensor); - SpiCookie* spiCookieRadSensor = new SpiCookie(addresses::RAD_SENSOR, gpioIds::CS_RAD_SENSOR, - std::string("/dev/spidev1.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - spi::DEFAULT_MAX_1227_SPEED); + SpiCookie* spiCookieRadSensor = + new SpiCookie(addresses::RAD_SENSOR, gpioIds::CS_RAD_SENSOR, std::string("/dev/spidev1.0"), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED); - RadiationSensorHandler* radSensor = new RadiationSensorHandler(objects::RAD_SENSOR, - objects::SPI_COM_IF, spiCookieRadSensor); - radSensor->setStartUpImmediately(); + RadiationSensorHandler* radSensor = + new RadiationSensorHandler(objects::RAD_SENSOR, objects::SPI_COM_IF, spiCookieRadSensor); + radSensor->setStartUpImmediately(); #endif #if BOARD_TE0720 == 1 && OBSW_ADD_PLOC_MPSOC == 1 - UartCookie* plocUartCookie = new UartCookie(std::string("/dev/ttyPS1"), 115200, - PLOC_MPSOC::MAX_REPLY_SIZE); - /* Testing PlocMPSoCHandler on TE0720-03-1CFA */ - PlocMPSoCHandler* mpsocPlocHandler = new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, - plocUartCookie); - mpsocPlocHandler->setStartUpImmediately(); + UartCookie* plocUartCookie = + new UartCookie(std::string("/dev/ttyPS1"), 115200, PLOC_MPSOC::MAX_REPLY_SIZE); + /* Testing PlocMPSoCHandler on TE0720-03-1CFA */ + PlocMPSoCHandler* mpsocPlocHandler = + new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, plocUartCookie); + mpsocPlocHandler->setStartUpImmediately(); #endif #if BOARD_TE0720 == 1 && OBSW_TEST_TE7020_HEATER == 1 - /* Configuration for MIO0 on TE0720-03-1CFA */ - GpiodRegular* heaterGpio = new GpiodRegular(std::string("gpiochip0"), 0, std::string("MIO0"), gpio::IN, 0); - GpioCookie* gpioCookie = new GpioCookie; - gpioCookie->addGpio(gpioIds::HEATER_0, heaterGpio); - new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, gpioCookie, objects::PCDU_HANDLER, - pcduSwitches::TCS_BOARD_8V_HEATER_IN); + /* Configuration for MIO0 on TE0720-03-1CFA */ + GpiodRegular* heaterGpio = + new GpiodRegular(std::string("gpiochip0"), 0, std::string("MIO0"), gpio::IN, 0); + GpioCookie* gpioCookie = new GpioCookie; + gpioCookie->addGpio(gpioIds::HEATER_0, heaterGpio); + new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, gpioCookie, objects::PCDU_HANDLER, + pcduSwitches::TCS_BOARD_8V_HEATER_IN); #endif #if BOARD_TE0720 == 1 && OBSW_ADD_PLOC_SUPERVISOR == 1 - /* Configuration for MIO0 on TE0720-03-1CFA */ - UartCookie* plocSupervisorCookie = new UartCookie(objects::PLOC_SUPERVISOR_HANDLER, - std::string("/dev/ttyPS1"), UartModes::NON_CANONICAL, 115200, - PLOC_SPV::MAX_PACKET_SIZE * 20); - plocSupervisorCookie->setNoFixedSizeReply(); - PlocSupervisorHandler* plocSupervisor = new PlocSupervisorHandler( - objects::PLOC_SUPERVISOR_HANDLER, objects::UART_COM_IF, plocSupervisorCookie); - plocSupervisor->setStartUpImmediately(); + /* Configuration for MIO0 on TE0720-03-1CFA */ + UartCookie* plocSupervisorCookie = + new UartCookie(objects::PLOC_SUPERVISOR_HANDLER, std::string("/dev/ttyPS1"), + UartModes::NON_CANONICAL, 115200, PLOC_SPV::MAX_PACKET_SIZE * 20); + plocSupervisorCookie->setNoFixedSizeReply(); + PlocSupervisorHandler* plocSupervisor = new PlocSupervisorHandler( + objects::PLOC_SUPERVISOR_HANDLER, objects::UART_COM_IF, plocSupervisorCookie); + plocSupervisor->setStartUpImmediately(); #endif #if OBSW_ADD_SPI_TEST_CODE == 1 - new SpiTestClass(objects::SPI_TEST, gpioComIF); + new SpiTestClass(objects::SPI_TEST, gpioComIF); #endif - } diff --git a/bsp_q7s/core/ObjectFactory.h b/bsp_q7s/core/ObjectFactory.h index 0e723142..47e06e33 100644 --- a/bsp_q7s/core/ObjectFactory.h +++ b/bsp_q7s/core/ObjectFactory.h @@ -11,7 +11,7 @@ void setStatics(); void produce(void* args); void createCommunicationInterfaces(LinuxLibgpioIF** gpioComIF, UartComIF** uartComIF, - SpiComIF** spiComIF); + SpiComIF** spiComIF); void createTmpComponents(); void createPcduComponents(); void createRadSensorComponent(LinuxLibgpioIF* gpioComIF); @@ -22,9 +22,9 @@ void createSolarArrayDeploymentComponents(); void createSyrlinksComponents(); void createRtdComponents(LinuxLibgpioIF* gpioComIF); void createReactionWheelComponents(LinuxLibgpioIF* gpioComIF); -void createCcsdsComponents(LinuxLibgpioIF *gpioComIF); +void createCcsdsComponents(LinuxLibgpioIF* gpioComIF); void createTestComponents(LinuxLibgpioIF* gpioComIF); -}; +}; // namespace ObjectFactory #endif /* BSP_Q7S_OBJECTFACTORY_H_ */ diff --git a/bsp_q7s/core/ParameterHandler.cpp b/bsp_q7s/core/ParameterHandler.cpp index d6c8f34f..8cee046e 100644 --- a/bsp_q7s/core/ParameterHandler.cpp +++ b/bsp_q7s/core/ParameterHandler.cpp @@ -1,8 +1,5 @@ #include "ParameterHandler.h" -ParameterHandler::ParameterHandler(std::string mountPrefix): mountPrefix(mountPrefix) { -} +ParameterHandler::ParameterHandler(std::string mountPrefix) : mountPrefix(mountPrefix) {} -void ParameterHandler::setMountPrefix(std::string prefix) { - mountPrefix = prefix; -} +void ParameterHandler::setMountPrefix(std::string prefix) { mountPrefix = prefix; } diff --git a/bsp_q7s/core/ParameterHandler.h b/bsp_q7s/core/ParameterHandler.h index 81cbc099..4a108586 100644 --- a/bsp_q7s/core/ParameterHandler.h +++ b/bsp_q7s/core/ParameterHandler.h @@ -4,19 +4,17 @@ #include #include - - class ParameterHandler { -public: - ParameterHandler(std::string mountPrefix); + public: + ParameterHandler(std::string mountPrefix); - void setMountPrefix(std::string prefix); + void setMountPrefix(std::string prefix); - void setUpDummyParameter(); -private: - std::string mountPrefix; - DummyParameter dummyParam; + void setUpDummyParameter(); + + private: + std::string mountPrefix; + DummyParameter dummyParam; }; - #endif /* BSP_Q7S_CORE_PARAMETERHANDLER_H_ */ diff --git a/bsp_q7s/core/obsw.cpp b/bsp_q7s/core/obsw.cpp index e55d5652..a69e94a2 100644 --- a/bsp_q7s/core/obsw.cpp +++ b/bsp_q7s/core/obsw.cpp @@ -1,43 +1,44 @@ #include "obsw.h" -#include "OBSWVersion.h" -#include "OBSWConfig.h" -#include "InitMission.h" -#include "watchdogConf.h" -#include "fsfw/tasks/TaskFactory.h" -#include "fsfw/FSFWVersion.h" - -#include #include +#include + +#include "InitMission.h" +#include "OBSWConfig.h" +#include "OBSWVersion.h" +#include "fsfw/FSFWVersion.h" +#include "fsfw/tasks/TaskFactory.h" +#include "watchdogConf.h" static int OBSW_ALREADY_RUNNING = -2; int obsw::obsw() { - std::cout << "-- EIVE OBSW --" << std::endl; + std::cout << "-- EIVE OBSW --" << std::endl; #if BOARD_TE0720 == 0 - std::cout << "-- Compiled for Linux (Xiphos Q7S) --" << std::endl; + std::cout << "-- Compiled for Linux (Xiphos Q7S) --" << std::endl; #else - std::cout << "-- Compiled for Linux (TE0720) --" << std::endl; + std::cout << "-- Compiled for Linux (TE0720) --" << std::endl; #endif - std::cout << "-- OBSW v" << SW_VERSION << "." << SW_SUBVERSION << - "." << SW_REVISION << ", FSFW v" << FSFW_VERSION << "." << FSFW_SUBVERSION << "." << - FSFW_REVISION << "--" << std::endl; - std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; + std::cout << "-- OBSW v" << SW_VERSION << "." << SW_SUBVERSION << "." << SW_REVISION << ", FSFW v" + << FSFW_VERSION << "." << FSFW_SUBVERSION << "." << FSFW_REVISION << "--" << std::endl; + std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; #if Q7S_CHECK_FOR_ALREADY_RUNNING_IMG == 1 - // Check special file here. This file is created or deleted by the eive-watchdog application - // or systemd service! - if(std::filesystem::exists(watchdog::RUNNING_FILE_NAME)) { - sif::warning << "File " << watchdog::RUNNING_FILE_NAME << " exists so the software might " - "already be running. Aborting.." << std::endl; - return OBSW_ALREADY_RUNNING; - } + // Check special file here. This file is created or deleted by the eive-watchdog application + // or systemd service! + if (std::filesystem::exists(watchdog::RUNNING_FILE_NAME)) { + sif::warning << "File " << watchdog::RUNNING_FILE_NAME + << " exists so the software might " + "already be running. Aborting.." + << std::endl; + return OBSW_ALREADY_RUNNING; + } #endif - initmission::initMission(); + initmission::initMission(); - for(;;) { - /* Suspend main thread by sleeping it. */ - TaskFactory::delayTask(5000); - } - return 0; + for (;;) { + /* Suspend main thread by sleeping it. */ + TaskFactory::delayTask(5000); + } + return 0; } diff --git a/bsp_q7s/devices/PlocMemoryDumper.cpp b/bsp_q7s/devices/PlocMemoryDumper.cpp index cc4361bb..c7ba58bd 100644 --- a/bsp_q7s/devices/PlocMemoryDumper.cpp +++ b/bsp_q7s/devices/PlocMemoryDumper.cpp @@ -1,206 +1,192 @@ -#include -#include "fsfw/ipc/QueueFactory.h" #include "PlocMemoryDumper.h" -#include +#include + #include +#include #include -PlocMemoryDumper::PlocMemoryDumper(object_id_t objectId) : - SystemObject(objectId), commandActionHelper(this), actionHelper(this, nullptr) { - commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); +#include "fsfw/ipc/QueueFactory.h" + +PlocMemoryDumper::PlocMemoryDumper(object_id_t objectId) + : SystemObject(objectId), commandActionHelper(this), actionHelper(this, nullptr) { + commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); } -PlocMemoryDumper::~PlocMemoryDumper() { -} +PlocMemoryDumper::~PlocMemoryDumper() {} ReturnValue_t PlocMemoryDumper::initialize() { + ReturnValue_t result = SystemObject::initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = commandActionHelper.initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = actionHelper.initialize(commandQueue); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } - ReturnValue_t result = SystemObject::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - result = commandActionHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - result = actionHelper.initialize(commandQueue); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t PlocMemoryDumper::performOperation(uint8_t operationCode) { - readCommandQueue(); - doStateMachine(); - return HasReturnvaluesIF::RETURN_OK; + readCommandQueue(); + doStateMachine(); + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t PlocMemoryDumper::executeAction(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { +ReturnValue_t PlocMemoryDumper::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) { + if (state != State::IDLE) { + return IS_BUSY; + } - if (state != State::IDLE) { - return IS_BUSY; - } - - switch (actionId) { + switch (actionId) { case DUMP_MRAM: { - size_t deserializeSize = sizeof(mram.startAddress) + sizeof(mram.endAddress); - SerializeAdapter::deSerialize(&mram.startAddress, &data, &deserializeSize, - SerializeIF::Endianness::BIG); - SerializeAdapter::deSerialize(&mram.endAddress, &data, &deserializeSize, - SerializeIF::Endianness::BIG); - if (mram.endAddress > MAX_MRAM_ADDRESS) { - return MRAM_ADDRESS_TOO_HIGH; - } - if (mram.endAddress <= mram.startAddress) { - return MRAM_INVALID_ADDRESS_COMBINATION; - } - state = State::COMMAND_FIRST_MRAM_DUMP; - break; + size_t deserializeSize = sizeof(mram.startAddress) + sizeof(mram.endAddress); + SerializeAdapter::deSerialize(&mram.startAddress, &data, &deserializeSize, + SerializeIF::Endianness::BIG); + SerializeAdapter::deSerialize(&mram.endAddress, &data, &deserializeSize, + SerializeIF::Endianness::BIG); + if (mram.endAddress > MAX_MRAM_ADDRESS) { + return MRAM_ADDRESS_TOO_HIGH; + } + if (mram.endAddress <= mram.startAddress) { + return MRAM_INVALID_ADDRESS_COMBINATION; + } + state = State::COMMAND_FIRST_MRAM_DUMP; + break; } default: { - sif::warning << "PlocMemoryDumper::executeAction: Received command with invalid action id" - << std::endl; - return INVALID_ACTION_ID; - } + sif::warning << "PlocMemoryDumper::executeAction: Received command with invalid action id" + << std::endl; + return INVALID_ACTION_ID; } + } - return EXECUTION_FINISHED; + return EXECUTION_FINISHED; } -MessageQueueId_t PlocMemoryDumper::getCommandQueue() const { - return commandQueue->getId(); -} +MessageQueueId_t PlocMemoryDumper::getCommandQueue() const { return commandQueue->getId(); } -MessageQueueIF* PlocMemoryDumper::getCommandQueuePtr() { - return commandQueue; -} +MessageQueueIF* PlocMemoryDumper::getCommandQueuePtr() { return commandQueue; } void PlocMemoryDumper::readCommandQueue() { - CommandMessage message; - ReturnValue_t result; + CommandMessage message; + ReturnValue_t result; - for (result = commandQueue->receiveMessage(&message); result == HasReturnvaluesIF::RETURN_OK; - result = commandQueue->receiveMessage(&message)) { - if (result != RETURN_OK) { - continue; - } - result = actionHelper.handleActionMessage(&message); - if (result == HasReturnvaluesIF::RETURN_OK) { - continue; - } - - result = commandActionHelper.handleReply(&message); - if (result == HasReturnvaluesIF::RETURN_OK) { - continue; - } - - sif::debug << "PlocMemoryDumper::readCommandQueue: Received message with invalid format" - << std::endl; + for (result = commandQueue->receiveMessage(&message); result == HasReturnvaluesIF::RETURN_OK; + result = commandQueue->receiveMessage(&message)) { + if (result != RETURN_OK) { + continue; } + result = actionHelper.handleActionMessage(&message); + if (result == HasReturnvaluesIF::RETURN_OK) { + continue; + } + + result = commandActionHelper.handleReply(&message); + if (result == HasReturnvaluesIF::RETURN_OK) { + continue; + } + + sif::debug << "PlocMemoryDumper::readCommandQueue: Received message with invalid format" + << std::endl; + } } void PlocMemoryDumper::doStateMachine() { - switch (state) { + switch (state) { case State::IDLE: - break; + break; case State::COMMAND_FIRST_MRAM_DUMP: - commandNextMramDump(PLOC_SPV::FIRST_MRAM_DUMP); - break; + commandNextMramDump(PLOC_SPV::FIRST_MRAM_DUMP); + break; case State::COMMAND_CONSECUTIVE_MRAM_DUMP: - commandNextMramDump(PLOC_SPV::CONSECUTIVE_MRAM_DUMP); - break; + commandNextMramDump(PLOC_SPV::CONSECUTIVE_MRAM_DUMP); + break; case State::EXECUTING_MRAM_DUMP: - break; + break; default: - sif::debug << "PlocMemoryDumper::doStateMachine: Invalid state" << std::endl; - break; - } + sif::debug << "PlocMemoryDumper::doStateMachine: Invalid state" << std::endl; + break; + } } -void PlocMemoryDumper::stepSuccessfulReceived(ActionId_t actionId, - uint8_t step) { -} +void PlocMemoryDumper::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) {} void PlocMemoryDumper::stepFailedReceived(ActionId_t actionId, uint8_t step, - ReturnValue_t returnCode) { -} + ReturnValue_t returnCode) {} -void PlocMemoryDumper::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) { - -} +void PlocMemoryDumper::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) {} void PlocMemoryDumper::completionSuccessfulReceived(ActionId_t actionId) { - switch (pendingCommand) { + switch (pendingCommand) { case (PLOC_SPV::FIRST_MRAM_DUMP): case (PLOC_SPV::CONSECUTIVE_MRAM_DUMP): - if (mram.endAddress == mram.startAddress) { - triggerEvent(MRAM_DUMP_FINISHED); - state = State::IDLE; - } - else { - state = State::COMMAND_CONSECUTIVE_MRAM_DUMP; - } - break; - default: - sif::debug << "PlocMemoryDumper::completionSuccessfulReceived: Invalid pending command" - << std::endl; + if (mram.endAddress == mram.startAddress) { + triggerEvent(MRAM_DUMP_FINISHED); state = State::IDLE; - break; - } + } else { + state = State::COMMAND_CONSECUTIVE_MRAM_DUMP; + } + break; + default: + sif::debug << "PlocMemoryDumper::completionSuccessfulReceived: Invalid pending command" + << std::endl; + state = State::IDLE; + break; + } } -void PlocMemoryDumper::completionFailedReceived(ActionId_t actionId, - ReturnValue_t returnCode) { - switch(pendingCommand) { - case(PLOC_SPV::FIRST_MRAM_DUMP): - case(PLOC_SPV::CONSECUTIVE_MRAM_DUMP): - triggerEvent(MRAM_DUMP_FAILED, mram.lastStartAddress); - break; +void PlocMemoryDumper::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) { + switch (pendingCommand) { + case (PLOC_SPV::FIRST_MRAM_DUMP): + case (PLOC_SPV::CONSECUTIVE_MRAM_DUMP): + triggerEvent(MRAM_DUMP_FAILED, mram.lastStartAddress); + break; default: - sif::debug << "PlocMemoryDumper::completionFailedReceived: Invalid pending command " - << std::endl; - break; - } - state = State::IDLE; + sif::debug << "PlocMemoryDumper::completionFailedReceived: Invalid pending command " + << std::endl; + break; + } + state = State::IDLE; } void PlocMemoryDumper::commandNextMramDump(ActionId_t dumpCommand) { - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = RETURN_OK; - uint32_t tempStartAddress = 0; - uint32_t tempEndAddress = 0; + uint32_t tempStartAddress = 0; + uint32_t tempEndAddress = 0; - if (mram.endAddress - mram.startAddress > MAX_MRAM_DUMP_SIZE) { - tempStartAddress = mram.startAddress; - tempEndAddress = mram.startAddress + MAX_MRAM_DUMP_SIZE; - mram.startAddress += MAX_MRAM_DUMP_SIZE; - mram.lastStartAddress = tempStartAddress; - } - else { - tempStartAddress = mram.startAddress; - tempEndAddress = mram.endAddress; - mram.startAddress = mram.endAddress; - } + if (mram.endAddress - mram.startAddress > MAX_MRAM_DUMP_SIZE) { + tempStartAddress = mram.startAddress; + tempEndAddress = mram.startAddress + MAX_MRAM_DUMP_SIZE; + mram.startAddress += MAX_MRAM_DUMP_SIZE; + mram.lastStartAddress = tempStartAddress; + } else { + tempStartAddress = mram.startAddress; + tempEndAddress = mram.endAddress; + mram.startAddress = mram.endAddress; + } - MemoryParams params(tempStartAddress, tempEndAddress); + MemoryParams params(tempStartAddress, tempEndAddress); - result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, - dumpCommand, ¶ms); - if (result != RETURN_OK) { - sif::warning << "PlocMemoryDumper::commandNextMramDump: Failed to send mram dump command " - << "with start address " << tempStartAddress << " and end address " - << tempEndAddress << std::endl; - triggerEvent(SEND_MRAM_DUMP_FAILED, result, tempStartAddress); - state = State::IDLE; - pendingCommand = NONE; - return; - } - state = State::EXECUTING_MRAM_DUMP; - pendingCommand = dumpCommand; + result = + commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, dumpCommand, ¶ms); + if (result != RETURN_OK) { + sif::warning << "PlocMemoryDumper::commandNextMramDump: Failed to send mram dump command " + << "with start address " << tempStartAddress << " and end address " + << tempEndAddress << std::endl; + triggerEvent(SEND_MRAM_DUMP_FAILED, result, tempStartAddress); + state = State::IDLE; + pendingCommand = NONE; return; + } + state = State::EXECUTING_MRAM_DUMP; + pendingCommand = dumpCommand; + return; } - diff --git a/bsp_q7s/devices/PlocMemoryDumper.h b/bsp_q7s/devices/PlocMemoryDumper.h index 72b031ae..2ee26824 100644 --- a/bsp_q7s/devices/PlocMemoryDumper.h +++ b/bsp_q7s/devices/PlocMemoryDumper.h @@ -3,18 +3,18 @@ #include #include + #include "OBSWConfig.h" -#include "fsfw/action/CommandActionHelper.h" +#include "bsp_q7s/memory/SdCardManager.h" #include "fsfw/action/ActionHelper.h" -#include "fsfw/action/HasActionsIF.h" +#include "fsfw/action/CommandActionHelper.h" #include "fsfw/action/CommandsActionsIF.h" +#include "fsfw/action/HasActionsIF.h" +#include "fsfw/objectmanager/SystemObject.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/tasks/ExecutableObjectIF.h" -#include "fsfw/objectmanager/SystemObject.h" -#include "bsp_q7s/memory/SdCardManager.h" -#include "linux/fsfwconfig/objects/systemObjectList.h" #include "fsfw/tmtcpacket/SpacePacket.h" - +#include "linux/fsfwconfig/objects/systemObjectList.h" /** * @brief Because the buffer of the linux tty driver is limited to 2 x 65535 bytes, this class is @@ -25,91 +25,90 @@ * @author J. Meier */ class PlocMemoryDumper : public SystemObject, - public HasActionsIF, - public ExecutableObjectIF, - public HasReturnvaluesIF, - public CommandsActionsIF { -public: + public HasActionsIF, + public ExecutableObjectIF, + public HasReturnvaluesIF, + public CommandsActionsIF { + public: + static const ActionId_t NONE = 0; + static const ActionId_t DUMP_MRAM = 1; - static const ActionId_t NONE = 0; - static const ActionId_t DUMP_MRAM = 1; + PlocMemoryDumper(object_id_t objectId); + virtual ~PlocMemoryDumper(); - PlocMemoryDumper(object_id_t objectId); - virtual ~PlocMemoryDumper(); + ReturnValue_t performOperation(uint8_t operationCode = 0) override; + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size); + MessageQueueId_t getCommandQueue() const; + ReturnValue_t initialize() override; + MessageQueueIF* getCommandQueuePtr() override; + void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) override; + void stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) override; + void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) override; + void completionSuccessfulReceived(ActionId_t actionId) override; + void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override; - ReturnValue_t performOperation(uint8_t operationCode = 0) override; - ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size); - MessageQueueId_t getCommandQueue() const; - ReturnValue_t initialize() override; - MessageQueueIF* getCommandQueuePtr() override; - void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) override; - void stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) override; - void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) override; - void completionSuccessfulReceived(ActionId_t actionId) override; - void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override; + private: + static const uint32_t QUEUE_SIZE = 10; -private: + static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MEMORY_DUMPER; - static const uint32_t QUEUE_SIZE = 10; + //! [EXPORT] : [COMMENT] The capacity of the MRAM amounts to 512 kB. Thus the maximum address must + //! not be higher than 0x7d000. + static const ReturnValue_t MRAM_ADDRESS_TOO_HIGH = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] The specified end address is lower than the start address + static const ReturnValue_t MRAM_INVALID_ADDRESS_COMBINATION = MAKE_RETURN_CODE(0xA1); - static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MEMORY_DUMPER; + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MEMORY_DUMPER; - //! [EXPORT] : [COMMENT] The capacity of the MRAM amounts to 512 kB. Thus the maximum address must not be higher than 0x7d000. - static const ReturnValue_t MRAM_ADDRESS_TOO_HIGH = MAKE_RETURN_CODE(0xA0); - //! [EXPORT] : [COMMENT] The specified end address is lower than the start address - static const ReturnValue_t MRAM_INVALID_ADDRESS_COMBINATION = MAKE_RETURN_CODE(0xA1); + //! [EXPORT] : [COMMENT] Failed to send mram dump command to supervisor handler + //! P1: Return value of commandAction function + //! P2: Start address of MRAM to dump with this command + static const Event SEND_MRAM_DUMP_FAILED = MAKE_EVENT(0, severity::LOW); + //! [EXPORT] : [COMMENT] Received completion failure report form PLOC supervisor handler + //! P1: MRAM start address of failing dump command + static const Event MRAM_DUMP_FAILED = MAKE_EVENT(1, severity::LOW); + //! [EXPORT] : [COMMENT] MRAM dump finished successfully + static const Event MRAM_DUMP_FINISHED = MAKE_EVENT(2, severity::LOW); - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MEMORY_DUMPER; + // Maximum size of mram dump which can be retrieved with one command + static const uint32_t MAX_MRAM_DUMP_SIZE = 100000; + static const uint32_t MAX_MRAM_ADDRESS = 0x7d000; - //! [EXPORT] : [COMMENT] Failed to send mram dump command to supervisor handler - //! P1: Return value of commandAction function - //! P2: Start address of MRAM to dump with this command - static const Event SEND_MRAM_DUMP_FAILED = MAKE_EVENT(0, severity::LOW); - //! [EXPORT] : [COMMENT] Received completion failure report form PLOC supervisor handler - //! P1: MRAM start address of failing dump command - static const Event MRAM_DUMP_FAILED = MAKE_EVENT(1, severity::LOW); - //! [EXPORT] : [COMMENT] MRAM dump finished successfully - static const Event MRAM_DUMP_FINISHED = MAKE_EVENT(2, severity::LOW); + MessageQueueIF* commandQueue = nullptr; - // Maximum size of mram dump which can be retrieved with one command - static const uint32_t MAX_MRAM_DUMP_SIZE = 100000; - static const uint32_t MAX_MRAM_ADDRESS = 0x7d000; + CommandActionHelper commandActionHelper; - MessageQueueIF* commandQueue = nullptr; + ActionHelper actionHelper; - CommandActionHelper commandActionHelper; + enum class State : uint8_t { + IDLE, + COMMAND_FIRST_MRAM_DUMP, + COMMAND_CONSECUTIVE_MRAM_DUMP, + EXECUTING_MRAM_DUMP + }; - ActionHelper actionHelper; + State state = State::IDLE; - enum class State: uint8_t { - IDLE, - COMMAND_FIRST_MRAM_DUMP, - COMMAND_CONSECUTIVE_MRAM_DUMP, - EXECUTING_MRAM_DUMP - }; + ActionId_t pendingCommand = NONE; - State state = State::IDLE; + typedef struct MemoryInfo { + // Stores the start address of the next memory range to dump + uint32_t startAddress; + uint32_t endAddress; + // Stores the start address of the last sent dump command + uint32_t lastStartAddress; + } MemoryInfo_t; - ActionId_t pendingCommand = NONE; + MemoryInfo_t mram = {0, 0, 0}; - typedef struct MemoryInfo { - // Stores the start address of the next memory range to dump - uint32_t startAddress; - uint32_t endAddress; - // Stores the start address of the last sent dump command - uint32_t lastStartAddress; - } MemoryInfo_t; + void readCommandQueue(); + void doStateMachine(); - MemoryInfo_t mram = {0, 0, 0}; - - void readCommandQueue(); - void doStateMachine(); - - /** - * @brief Sends the next mram dump command to the PLOC supervisor handler. - */ - void commandNextMramDump(ActionId_t dumpCommand); + /** + * @brief Sends the next mram dump command to the PLOC supervisor handler. + */ + void commandNextMramDump(ActionId_t dumpCommand); }; #endif /* MISSION_DEVICES_PLOCMEMORYDUMPER_H_ */ diff --git a/bsp_q7s/devices/PlocSupervisorHandler.cpp b/bsp_q7s/devices/PlocSupervisorHandler.cpp index 30ea9572..a56c9e1c 100644 --- a/bsp_q7s/devices/PlocSupervisorHandler.cpp +++ b/bsp_q7s/devices/PlocSupervisorHandler.cpp @@ -1,540 +1,530 @@ -#include -#include -#include -#include - #include "PlocSupervisorHandler.h" -#include "OBSWConfig.h" -#include #include +#include #include +#include +#include +#include +#include + +#include "OBSWConfig.h" + PlocSupervisorHandler::PlocSupervisorHandler(object_id_t objectId, object_id_t uartComIFid, - CookieIF * comCookie) : - DeviceHandlerBase(objectId, uartComIFid, comCookie), hkset(this), bootStatusReport(this), latchupStatusReport( - this) { - if (comCookie == NULL) { - sif::error << "PlocSupervisorHandler: Invalid com cookie" << std::endl; - } + CookieIF* comCookie) + : DeviceHandlerBase(objectId, uartComIFid, comCookie), + hkset(this), + bootStatusReport(this), + latchupStatusReport(this) { + if (comCookie == NULL) { + sif::error << "PlocSupervisorHandler: Invalid com cookie" << std::endl; + } } -PlocSupervisorHandler::~PlocSupervisorHandler() { -} +PlocSupervisorHandler::~PlocSupervisorHandler() {} ReturnValue_t PlocSupervisorHandler::initialize() { - ReturnValue_t result = RETURN_OK; - result = DeviceHandlerBase::initialize(); - if (result != RETURN_OK) { - return result; - } - uartComIf = dynamic_cast(communicationInterface); - if (uartComIf == nullptr) { - sif::warning << "PlocSupervisorHandler::initialize: Invalid uart com if" << std::endl; - return INVALID_UART_COM_IF; - } + ReturnValue_t result = RETURN_OK; + result = DeviceHandlerBase::initialize(); + if (result != RETURN_OK) { + return result; + } + uartComIf = dynamic_cast(communicationInterface); + if (uartComIf == nullptr) { + sif::warning << "PlocSupervisorHandler::initialize: Invalid uart com if" << std::endl; + return INVALID_UART_COM_IF; + } #if BOARD_TE0720 == 0 - sdcMan = SdCardManager::instance(); + sdcMan = SdCardManager::instance(); #endif /* BOARD_TE0720 == 0 */ - return result; + return result; } - -void PlocSupervisorHandler::doStartUp(){ +void PlocSupervisorHandler::doStartUp() { #if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 - setMode(MODE_NORMAL); + setMode(MODE_NORMAL); #else - setMode(_MODE_TO_ON); + setMode(_MODE_TO_ON); #endif } -void PlocSupervisorHandler::doShutDown(){ - setMode(_MODE_POWER_DOWN); +void PlocSupervisorHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } + +ReturnValue_t PlocSupervisorHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + return NOTHING_TO_SEND; } -ReturnValue_t PlocSupervisorHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - return NOTHING_TO_SEND; +ReturnValue_t PlocSupervisorHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { + return NOTHING_TO_SEND; } -ReturnValue_t PlocSupervisorHandler::buildTransitionDeviceCommand( - DeviceCommandId_t * id){ - return NOTHING_TO_SEND; -} - -ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t * commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_FAILED; - switch(deviceCommand) { - case(PLOC_SPV::GET_HK_REPORT): { - prepareEmptyCmd(PLOC_SPV::APID_GET_HK_REPORT); - result = RETURN_OK; - break; - } - case(PLOC_SPV::RESTART_MPSOC): { - prepareEmptyCmd(PLOC_SPV::APID_RESTART_MPSOC); - result = RETURN_OK; - break; - } - case(PLOC_SPV::START_MPSOC): { - prepareEmptyCmd(PLOC_SPV::APID_START_MPSOC); - result = RETURN_OK; - break; - } - case(PLOC_SPV::SHUTDOWN_MPSOC): { - prepareEmptyCmd(PLOC_SPV::APID_SHUTWOWN_MPSOC); - result = RETURN_OK; - break; - } - case(PLOC_SPV::SEL_MPSOC_BOOT_IMAGE): { - prepareSelBootImageCmd(commandData); - result = RETURN_OK; - break; - } - case(PLOC_SPV::RESET_MPSOC): { - prepareEmptyCmd(PLOC_SPV::APID_RESET_MPSOC); - result = RETURN_OK; - break; +ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t* commandData, + size_t commandDataLen) { + ReturnValue_t result = RETURN_FAILED; + switch (deviceCommand) { + case (PLOC_SPV::GET_HK_REPORT): { + prepareEmptyCmd(PLOC_SPV::APID_GET_HK_REPORT); + result = RETURN_OK; + break; } - case(PLOC_SPV::SET_TIME_REF): { - result = prepareSetTimeRefCmd(); - break; - } - case(PLOC_SPV::SET_BOOT_TIMEOUT): { - prepareSetBootTimeoutCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::RESTART_MPSOC): { + prepareEmptyCmd(PLOC_SPV::APID_RESTART_MPSOC); + result = RETURN_OK; + break; } - case(PLOC_SPV::SET_MAX_RESTART_TRIES): { - prepareRestartTriesCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::START_MPSOC): { + prepareEmptyCmd(PLOC_SPV::APID_START_MPSOC); + result = RETURN_OK; + break; } - case(PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION): { - prepareDisableHk(); - result = RETURN_OK; - break; + case (PLOC_SPV::SHUTDOWN_MPSOC): { + prepareEmptyCmd(PLOC_SPV::APID_SHUTWOWN_MPSOC); + result = RETURN_OK; + break; } - case(PLOC_SPV::GET_BOOT_STATUS_REPORT): { - prepareEmptyCmd(PLOC_SPV::APID_GET_BOOT_STATUS_RPT); - result = RETURN_OK; - break; + case (PLOC_SPV::SEL_MPSOC_BOOT_IMAGE): { + prepareSelBootImageCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::WATCHDOGS_ENABLE): { - prepareWatchdogsEnableCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::RESET_MPSOC): { + prepareEmptyCmd(PLOC_SPV::APID_RESET_MPSOC); + result = RETURN_OK; + break; } - case(PLOC_SPV::WATCHDOGS_CONFIG_TIMEOUT): { - result = prepareWatchdogsConfigTimeoutCmd(commandData); - break; + case (PLOC_SPV::SET_TIME_REF): { + result = prepareSetTimeRefCmd(); + break; } - case(PLOC_SPV::ENABLE_LATCHUP_ALERT): { - result = prepareLatchupConfigCmd(commandData, deviceCommand); - break; + case (PLOC_SPV::SET_BOOT_TIMEOUT): { + prepareSetBootTimeoutCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::DISABLE_LATCHUP_ALERT): { - result = prepareLatchupConfigCmd(commandData, deviceCommand); - break; + case (PLOC_SPV::SET_MAX_RESTART_TRIES): { + prepareRestartTriesCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::AUTO_CALIBRATE_ALERT): { - result = prepareAutoCalibrateAlertCmd(commandData); - break; + case (PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION): { + prepareDisableHk(); + result = RETURN_OK; + break; } - case(PLOC_SPV::SET_ALERT_LIMIT): { - result = prepareSetAlertLimitCmd(commandData); - break; + case (PLOC_SPV::GET_BOOT_STATUS_REPORT): { + prepareEmptyCmd(PLOC_SPV::APID_GET_BOOT_STATUS_RPT); + result = RETURN_OK; + break; } - case(PLOC_SPV::SET_ALERT_IRQ_FILTER): { - result = prepareSetAlertIrqFilterCmd(commandData); - break; + case (PLOC_SPV::WATCHDOGS_ENABLE): { + prepareWatchdogsEnableCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::SET_ADC_SWEEP_PERIOD): { - result = prepareSetAdcSweetPeriodCmd(commandData); - break; + case (PLOC_SPV::WATCHDOGS_CONFIG_TIMEOUT): { + result = prepareWatchdogsConfigTimeoutCmd(commandData); + break; } - case(PLOC_SPV::SET_ADC_ENABLED_CHANNELS): { - prepareSetAdcEnabledChannelsCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::ENABLE_LATCHUP_ALERT): { + result = prepareLatchupConfigCmd(commandData, deviceCommand); + break; } - case(PLOC_SPV::SET_ADC_WINDOW_AND_STRIDE): { - prepareSetAdcWindowAndStrideCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::DISABLE_LATCHUP_ALERT): { + result = prepareLatchupConfigCmd(commandData, deviceCommand); + break; } - case(PLOC_SPV::SET_ADC_THRESHOLD): { - prepareSetAdcThresholdCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::AUTO_CALIBRATE_ALERT): { + result = prepareAutoCalibrateAlertCmd(commandData); + break; } - case(PLOC_SPV::GET_LATCHUP_STATUS_REPORT): { - prepareEmptyCmd(PLOC_SPV::APID_GET_LATCHUP_STATUS_REPORT); - result = RETURN_OK; - break; + case (PLOC_SPV::SET_ALERT_LIMIT): { + result = prepareSetAlertLimitCmd(commandData); + break; } - case(PLOC_SPV::COPY_ADC_DATA_TO_MRAM): { - prepareEmptyCmd(PLOC_SPV::APID_COPY_ADC_DATA_TO_MRAM); - result = RETURN_OK; - break; + case (PLOC_SPV::SET_ALERT_IRQ_FILTER): { + result = prepareSetAlertIrqFilterCmd(commandData); + break; } - case(PLOC_SPV::ENABLE_NVMS): { - prepareEnableNvmsCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::SET_ADC_SWEEP_PERIOD): { + result = prepareSetAdcSweetPeriodCmd(commandData); + break; } - case(PLOC_SPV::SELECT_NVM): { - prepareSelectNvmCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::SET_ADC_ENABLED_CHANNELS): { + prepareSetAdcEnabledChannelsCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::RUN_AUTO_EM_TESTS): { - result = prepareRunAutoEmTest(commandData); - break; + case (PLOC_SPV::SET_ADC_WINDOW_AND_STRIDE): { + prepareSetAdcWindowAndStrideCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::WIPE_MRAM): { - result = prepareWipeMramCmd(commandData); - break; + case (PLOC_SPV::SET_ADC_THRESHOLD): { + prepareSetAdcThresholdCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::FIRST_MRAM_DUMP): - case(PLOC_SPV::CONSECUTIVE_MRAM_DUMP): - result = prepareDumpMramCmd(commandData); - break; - case(PLOC_SPV::PRINT_CPU_STATS): { - preparePrintCpuStatsCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::GET_LATCHUP_STATUS_REPORT): { + prepareEmptyCmd(PLOC_SPV::APID_GET_LATCHUP_STATUS_REPORT); + result = RETURN_OK; + break; } - case(PLOC_SPV::SET_DBG_VERBOSITY): { - prepareSetDbgVerbosityCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::COPY_ADC_DATA_TO_MRAM): { + prepareEmptyCmd(PLOC_SPV::APID_COPY_ADC_DATA_TO_MRAM); + result = RETURN_OK; + break; } - case(PLOC_SPV::CAN_LOOPBACK_TEST): { - prepareEmptyCmd(PLOC_SPV::APID_CAN_LOOPBACK_TEST); - result = RETURN_OK; - break; + case (PLOC_SPV::ENABLE_NVMS): { + prepareEnableNvmsCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::SET_GPIO): { - prepareSetGpioCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::SELECT_NVM): { + prepareSelectNvmCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::READ_GPIO): { - prepareReadGpioCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::RUN_AUTO_EM_TESTS): { + result = prepareRunAutoEmTest(commandData); + break; } - case(PLOC_SPV::RESTART_SUPERVISOR): { - prepareEmptyCmd(PLOC_SPV::APID_RESTART_SUPERVISOR); - result = RETURN_OK; - break; - } - case(PLOC_SPV::FACTORY_RESET_CLEAR_ALL): { - PLOC_SPV::FactoryReset packet(PLOC_SPV::FactoryReset::Op::CLEAR_ALL); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - result = RETURN_OK; - break; - } - case(PLOC_SPV::FACTORY_RESET_CLEAR_MIRROR): { - PLOC_SPV::FactoryReset packet(PLOC_SPV::FactoryReset::Op::MIRROR_ENTRIES); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - result = RETURN_OK; - break; - } - case(PLOC_SPV::FACTORY_RESET_CLEAR_CIRCULAR): { - PLOC_SPV::FactoryReset packet(PLOC_SPV::FactoryReset::Op::CIRCULAR_ENTRIES); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - result = RETURN_OK; - break; - } - case(PLOC_SPV::UPDATE_AVAILABLE): - case(PLOC_SPV::UPDATE_IMAGE_DATA): - case(PLOC_SPV::UPDATE_VERIFY): - // Simply forward data from PLOC Updater to supervisor - std::memcpy(commandBuffer, commandData, commandDataLen); - rawPacket = commandBuffer; - rawPacketLen = commandDataLen; - nextReplyId = PLOC_SPV::ACK_REPORT; - result = RETURN_OK; - break; - default: - sif::debug << "PlocSupervisorHandler::buildCommandFromCommand: Command not implemented" - << std::endl; - result = DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - break; - } - - if (result == RETURN_OK) { - /** - * Flushing the receive buffer to make sure there are no data left from a faulty reply. - */ - uartComIf->flushUartRxBuffer(comCookie); - } - - return result; -} - -void PlocSupervisorHandler::fillCommandAndReplyMap() { - this->insertInCommandMap(PLOC_SPV::GET_HK_REPORT); - this->insertInCommandMap(PLOC_SPV::RESTART_MPSOC); - this->insertInCommandMap(PLOC_SPV::START_MPSOC); - this->insertInCommandMap(PLOC_SPV::SHUTDOWN_MPSOC); - this->insertInCommandMap(PLOC_SPV::SEL_MPSOC_BOOT_IMAGE); - this->insertInCommandMap(PLOC_SPV::SET_BOOT_TIMEOUT); - this->insertInCommandMap(PLOC_SPV::SET_MAX_RESTART_TRIES); - this->insertInCommandMap(PLOC_SPV::RESET_MPSOC); - this->insertInCommandMap(PLOC_SPV::SET_TIME_REF); - this->insertInCommandMap(PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION); - this->insertInCommandMap(PLOC_SPV::GET_BOOT_STATUS_REPORT); - this->insertInCommandMap(PLOC_SPV::UPDATE_AVAILABLE); - this->insertInCommandMap(PLOC_SPV::UPDATE_VERIFY); - this->insertInCommandMap(PLOC_SPV::UPDATE_IMAGE_DATA); - this->insertInCommandMap(PLOC_SPV::WATCHDOGS_ENABLE); - this->insertInCommandMap(PLOC_SPV::WATCHDOGS_CONFIG_TIMEOUT); - this->insertInCommandMap(PLOC_SPV::ENABLE_LATCHUP_ALERT); - this->insertInCommandMap(PLOC_SPV::DISABLE_LATCHUP_ALERT); - this->insertInCommandMap(PLOC_SPV::AUTO_CALIBRATE_ALERT); - this->insertInCommandMap(PLOC_SPV::SET_ALERT_LIMIT); - this->insertInCommandMap(PLOC_SPV::SET_ALERT_IRQ_FILTER); - this->insertInCommandMap(PLOC_SPV::SET_ADC_SWEEP_PERIOD); - this->insertInCommandMap(PLOC_SPV::SET_ADC_ENABLED_CHANNELS); - this->insertInCommandMap(PLOC_SPV::SET_ADC_WINDOW_AND_STRIDE); - this->insertInCommandMap(PLOC_SPV::SET_ADC_THRESHOLD); - this->insertInCommandMap(PLOC_SPV::GET_LATCHUP_STATUS_REPORT); - this->insertInCommandMap(PLOC_SPV::COPY_ADC_DATA_TO_MRAM); - this->insertInCommandMap(PLOC_SPV::ENABLE_NVMS); - this->insertInCommandMap(PLOC_SPV::SELECT_NVM); - this->insertInCommandMap(PLOC_SPV::RUN_AUTO_EM_TESTS); - this->insertInCommandMap(PLOC_SPV::WIPE_MRAM); - this->insertInCommandMap(PLOC_SPV::PRINT_CPU_STATS); - this->insertInCommandMap(PLOC_SPV::SET_DBG_VERBOSITY); - this->insertInCommandMap(PLOC_SPV::SET_GPIO); - this->insertInCommandMap(PLOC_SPV::READ_GPIO); - this->insertInCommandMap(PLOC_SPV::RESTART_SUPERVISOR); - this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_ALL); - this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_MIRROR); - this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_CIRCULAR); - this->insertInCommandMap(PLOC_SPV::CAN_LOOPBACK_TEST); - this->insertInCommandAndReplyMap(PLOC_SPV::FIRST_MRAM_DUMP, 3); - this->insertInCommandAndReplyMap(PLOC_SPV::CONSECUTIVE_MRAM_DUMP, 3); - this->insertInReplyMap(PLOC_SPV::ACK_REPORT, 3, nullptr, PLOC_SPV::SIZE_ACK_REPORT); - this->insertInReplyMap(PLOC_SPV::EXE_REPORT, 3, nullptr, PLOC_SPV::SIZE_EXE_REPORT); - this->insertInReplyMap(PLOC_SPV::HK_REPORT, 3, &hkset, PLOC_SPV::SIZE_HK_REPORT); - this->insertInReplyMap(PLOC_SPV::BOOT_STATUS_REPORT, 3, &bootStatusReport, - PLOC_SPV::SIZE_BOOT_STATUS_REPORT); - this->insertInReplyMap(PLOC_SPV::LATCHUP_REPORT, 3, &latchupStatusReport, - PLOC_SPV::SIZE_LATCHUP_STATUS_REPORT); -} - -ReturnValue_t PlocSupervisorHandler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { - - if (nextReplyId == PLOC_SPV::FIRST_MRAM_DUMP) { - *foundId = PLOC_SPV::FIRST_MRAM_DUMP; - return parseMramPackets(start, remainingSize, foundLen); - } - else if (nextReplyId == PLOC_SPV::CONSECUTIVE_MRAM_DUMP) { - *foundId = PLOC_SPV::CONSECUTIVE_MRAM_DUMP; - return parseMramPackets(start, remainingSize, foundLen); - } - - ReturnValue_t result = RETURN_OK; - - uint16_t apid = (*(start) << 8 | *(start + 1)) & APID_MASK; - - switch(apid) { - case(PLOC_SPV::APID_ACK_SUCCESS): - *foundLen = PLOC_SPV::SIZE_ACK_REPORT; - *foundId = PLOC_SPV::ACK_REPORT; - break; - case(PLOC_SPV::APID_ACK_FAILURE): - *foundLen = PLOC_SPV::SIZE_ACK_REPORT; - *foundId = PLOC_SPV::ACK_REPORT; - break; - case(PLOC_SPV::APID_HK_REPORT): - *foundLen = PLOC_SPV::SIZE_HK_REPORT; - *foundId = PLOC_SPV::HK_REPORT; - break; - case(PLOC_SPV::APID_BOOT_STATUS_REPORT): - *foundLen = PLOC_SPV::SIZE_BOOT_STATUS_REPORT; - *foundId = PLOC_SPV::BOOT_STATUS_REPORT; - break; - case(PLOC_SPV::APID_LATCHUP_STATUS_REPORT): - *foundLen = PLOC_SPV::SIZE_LATCHUP_STATUS_REPORT; - *foundId = PLOC_SPV::LATCHUP_REPORT; - break; - case(PLOC_SPV::APID_EXE_SUCCESS): - *foundLen = PLOC_SPV::SIZE_EXE_REPORT; - *foundId = PLOC_SPV::EXE_REPORT; - break; - case(PLOC_SPV::APID_EXE_FAILURE): - *foundLen = PLOC_SPV::SIZE_EXE_REPORT; - *foundId = PLOC_SPV::EXE_REPORT; - break; - default: { - sif::debug << "PlocSupervisorHandler::scanForReply: Reply has invalid apid" << std::endl; - *foundLen = remainingSize; - return INVALID_APID; - } - } - - return result; -} - -ReturnValue_t PlocSupervisorHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { - - ReturnValue_t result = RETURN_OK; - - switch (id) { - case PLOC_SPV::ACK_REPORT: { - result = handleAckReport(packet); - break; - } - case (PLOC_SPV::HK_REPORT): { - result = handleHkReport(packet); - break; - } - case (PLOC_SPV::BOOT_STATUS_REPORT): { - result = handleBootStatusReport(packet); - break; - } - case (PLOC_SPV::LATCHUP_REPORT): { - result = handleLatchupStatusReport(packet); - break; + case (PLOC_SPV::WIPE_MRAM): { + result = prepareWipeMramCmd(commandData); + break; } case (PLOC_SPV::FIRST_MRAM_DUMP): case (PLOC_SPV::CONSECUTIVE_MRAM_DUMP): - result = handleMramDumpPacket(id); - break; + result = prepareDumpMramCmd(commandData); + break; + case (PLOC_SPV::PRINT_CPU_STATS): { + preparePrintCpuStatsCmd(commandData); + result = RETURN_OK; + break; + } + case (PLOC_SPV::SET_DBG_VERBOSITY): { + prepareSetDbgVerbosityCmd(commandData); + result = RETURN_OK; + break; + } + case (PLOC_SPV::CAN_LOOPBACK_TEST): { + prepareEmptyCmd(PLOC_SPV::APID_CAN_LOOPBACK_TEST); + result = RETURN_OK; + break; + } + case (PLOC_SPV::SET_GPIO): { + prepareSetGpioCmd(commandData); + result = RETURN_OK; + break; + } + case (PLOC_SPV::READ_GPIO): { + prepareReadGpioCmd(commandData); + result = RETURN_OK; + break; + } + case (PLOC_SPV::RESTART_SUPERVISOR): { + prepareEmptyCmd(PLOC_SPV::APID_RESTART_SUPERVISOR); + result = RETURN_OK; + break; + } + case (PLOC_SPV::FACTORY_RESET_CLEAR_ALL): { + PLOC_SPV::FactoryReset packet(PLOC_SPV::FactoryReset::Op::CLEAR_ALL); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + result = RETURN_OK; + break; + } + case (PLOC_SPV::FACTORY_RESET_CLEAR_MIRROR): { + PLOC_SPV::FactoryReset packet(PLOC_SPV::FactoryReset::Op::MIRROR_ENTRIES); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + result = RETURN_OK; + break; + } + case (PLOC_SPV::FACTORY_RESET_CLEAR_CIRCULAR): { + PLOC_SPV::FactoryReset packet(PLOC_SPV::FactoryReset::Op::CIRCULAR_ENTRIES); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + result = RETURN_OK; + break; + } + case (PLOC_SPV::UPDATE_AVAILABLE): + case (PLOC_SPV::UPDATE_IMAGE_DATA): + case (PLOC_SPV::UPDATE_VERIFY): + // Simply forward data from PLOC Updater to supervisor + std::memcpy(commandBuffer, commandData, commandDataLen); + rawPacket = commandBuffer; + rawPacketLen = commandDataLen; + nextReplyId = PLOC_SPV::ACK_REPORT; + result = RETURN_OK; + break; + default: + sif::debug << "PlocSupervisorHandler::buildCommandFromCommand: Command not implemented" + << std::endl; + result = DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + break; + } + + if (result == RETURN_OK) { + /** + * Flushing the receive buffer to make sure there are no data left from a faulty reply. + */ + uartComIf->flushUartRxBuffer(comCookie); + } + + return result; +} + +void PlocSupervisorHandler::fillCommandAndReplyMap() { + this->insertInCommandMap(PLOC_SPV::GET_HK_REPORT); + this->insertInCommandMap(PLOC_SPV::RESTART_MPSOC); + this->insertInCommandMap(PLOC_SPV::START_MPSOC); + this->insertInCommandMap(PLOC_SPV::SHUTDOWN_MPSOC); + this->insertInCommandMap(PLOC_SPV::SEL_MPSOC_BOOT_IMAGE); + this->insertInCommandMap(PLOC_SPV::SET_BOOT_TIMEOUT); + this->insertInCommandMap(PLOC_SPV::SET_MAX_RESTART_TRIES); + this->insertInCommandMap(PLOC_SPV::RESET_MPSOC); + this->insertInCommandMap(PLOC_SPV::SET_TIME_REF); + this->insertInCommandMap(PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION); + this->insertInCommandMap(PLOC_SPV::GET_BOOT_STATUS_REPORT); + this->insertInCommandMap(PLOC_SPV::UPDATE_AVAILABLE); + this->insertInCommandMap(PLOC_SPV::UPDATE_VERIFY); + this->insertInCommandMap(PLOC_SPV::UPDATE_IMAGE_DATA); + this->insertInCommandMap(PLOC_SPV::WATCHDOGS_ENABLE); + this->insertInCommandMap(PLOC_SPV::WATCHDOGS_CONFIG_TIMEOUT); + this->insertInCommandMap(PLOC_SPV::ENABLE_LATCHUP_ALERT); + this->insertInCommandMap(PLOC_SPV::DISABLE_LATCHUP_ALERT); + this->insertInCommandMap(PLOC_SPV::AUTO_CALIBRATE_ALERT); + this->insertInCommandMap(PLOC_SPV::SET_ALERT_LIMIT); + this->insertInCommandMap(PLOC_SPV::SET_ALERT_IRQ_FILTER); + this->insertInCommandMap(PLOC_SPV::SET_ADC_SWEEP_PERIOD); + this->insertInCommandMap(PLOC_SPV::SET_ADC_ENABLED_CHANNELS); + this->insertInCommandMap(PLOC_SPV::SET_ADC_WINDOW_AND_STRIDE); + this->insertInCommandMap(PLOC_SPV::SET_ADC_THRESHOLD); + this->insertInCommandMap(PLOC_SPV::GET_LATCHUP_STATUS_REPORT); + this->insertInCommandMap(PLOC_SPV::COPY_ADC_DATA_TO_MRAM); + this->insertInCommandMap(PLOC_SPV::ENABLE_NVMS); + this->insertInCommandMap(PLOC_SPV::SELECT_NVM); + this->insertInCommandMap(PLOC_SPV::RUN_AUTO_EM_TESTS); + this->insertInCommandMap(PLOC_SPV::WIPE_MRAM); + this->insertInCommandMap(PLOC_SPV::PRINT_CPU_STATS); + this->insertInCommandMap(PLOC_SPV::SET_DBG_VERBOSITY); + this->insertInCommandMap(PLOC_SPV::SET_GPIO); + this->insertInCommandMap(PLOC_SPV::READ_GPIO); + this->insertInCommandMap(PLOC_SPV::RESTART_SUPERVISOR); + this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_ALL); + this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_MIRROR); + this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_CIRCULAR); + this->insertInCommandMap(PLOC_SPV::CAN_LOOPBACK_TEST); + this->insertInCommandAndReplyMap(PLOC_SPV::FIRST_MRAM_DUMP, 3); + this->insertInCommandAndReplyMap(PLOC_SPV::CONSECUTIVE_MRAM_DUMP, 3); + this->insertInReplyMap(PLOC_SPV::ACK_REPORT, 3, nullptr, PLOC_SPV::SIZE_ACK_REPORT); + this->insertInReplyMap(PLOC_SPV::EXE_REPORT, 3, nullptr, PLOC_SPV::SIZE_EXE_REPORT); + this->insertInReplyMap(PLOC_SPV::HK_REPORT, 3, &hkset, PLOC_SPV::SIZE_HK_REPORT); + this->insertInReplyMap(PLOC_SPV::BOOT_STATUS_REPORT, 3, &bootStatusReport, + PLOC_SPV::SIZE_BOOT_STATUS_REPORT); + this->insertInReplyMap(PLOC_SPV::LATCHUP_REPORT, 3, &latchupStatusReport, + PLOC_SPV::SIZE_LATCHUP_STATUS_REPORT); +} + +ReturnValue_t PlocSupervisorHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + if (nextReplyId == PLOC_SPV::FIRST_MRAM_DUMP) { + *foundId = PLOC_SPV::FIRST_MRAM_DUMP; + return parseMramPackets(start, remainingSize, foundLen); + } else if (nextReplyId == PLOC_SPV::CONSECUTIVE_MRAM_DUMP) { + *foundId = PLOC_SPV::CONSECUTIVE_MRAM_DUMP; + return parseMramPackets(start, remainingSize, foundLen); + } + + ReturnValue_t result = RETURN_OK; + + uint16_t apid = (*(start) << 8 | *(start + 1)) & APID_MASK; + + switch (apid) { + case (PLOC_SPV::APID_ACK_SUCCESS): + *foundLen = PLOC_SPV::SIZE_ACK_REPORT; + *foundId = PLOC_SPV::ACK_REPORT; + break; + case (PLOC_SPV::APID_ACK_FAILURE): + *foundLen = PLOC_SPV::SIZE_ACK_REPORT; + *foundId = PLOC_SPV::ACK_REPORT; + break; + case (PLOC_SPV::APID_HK_REPORT): + *foundLen = PLOC_SPV::SIZE_HK_REPORT; + *foundId = PLOC_SPV::HK_REPORT; + break; + case (PLOC_SPV::APID_BOOT_STATUS_REPORT): + *foundLen = PLOC_SPV::SIZE_BOOT_STATUS_REPORT; + *foundId = PLOC_SPV::BOOT_STATUS_REPORT; + break; + case (PLOC_SPV::APID_LATCHUP_STATUS_REPORT): + *foundLen = PLOC_SPV::SIZE_LATCHUP_STATUS_REPORT; + *foundId = PLOC_SPV::LATCHUP_REPORT; + break; + case (PLOC_SPV::APID_EXE_SUCCESS): + *foundLen = PLOC_SPV::SIZE_EXE_REPORT; + *foundId = PLOC_SPV::EXE_REPORT; + break; + case (PLOC_SPV::APID_EXE_FAILURE): + *foundLen = PLOC_SPV::SIZE_EXE_REPORT; + *foundId = PLOC_SPV::EXE_REPORT; + break; + default: { + sif::debug << "PlocSupervisorHandler::scanForReply: Reply has invalid apid" << std::endl; + *foundLen = remainingSize; + return INVALID_APID; + } + } + + return result; +} + +ReturnValue_t PlocSupervisorHandler::interpretDeviceReply(DeviceCommandId_t id, + const uint8_t* packet) { + ReturnValue_t result = RETURN_OK; + + switch (id) { + case PLOC_SPV::ACK_REPORT: { + result = handleAckReport(packet); + break; + } + case (PLOC_SPV::HK_REPORT): { + result = handleHkReport(packet); + break; + } + case (PLOC_SPV::BOOT_STATUS_REPORT): { + result = handleBootStatusReport(packet); + break; + } + case (PLOC_SPV::LATCHUP_REPORT): { + result = handleLatchupStatusReport(packet); + break; + } + case (PLOC_SPV::FIRST_MRAM_DUMP): + case (PLOC_SPV::CONSECUTIVE_MRAM_DUMP): + result = handleMramDumpPacket(id); + break; case (PLOC_SPV::EXE_REPORT): { - result = handleExecutionReport(packet); - break; + result = handleExecutionReport(packet); + break; } default: { - sif::debug << "PlocSupervisorHandler::interpretDeviceReply: Unknown device reply id" << std::endl; - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } + sif::debug << "PlocSupervisorHandler::interpretDeviceReply: Unknown device reply id" + << std::endl; + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; } + } - return result; + return result; } -void PlocSupervisorHandler::setNormalDatapoolEntriesInvalid(){ +void PlocSupervisorHandler::setNormalDatapoolEntriesInvalid() {} -} - -uint32_t PlocSupervisorHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){ - return 500; -} +uint32_t PlocSupervisorHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } ReturnValue_t PlocSupervisorHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { + LocalDataPoolManager& poolManager) { + localDataPoolMap.emplace(PLOC_SPV::NUM_TMS, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::TEMP_PS, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::TEMP_PL, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::SOC_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::NVM0_1_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::NVM3_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::MISSION_IO_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::FMC_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::NUM_TCS, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CPULOAD, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::AVAILABLEHEAP, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::NUM_TMS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::TEMP_PS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::TEMP_PL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::SOC_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::NVM0_1_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::NVM3_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::MISSION_IO_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::FMC_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::NUM_TCS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::UPTIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CPULOAD, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::AVAILABLEHEAP, new PoolEntry( { 0 })); + localDataPoolMap.emplace(PLOC_SPV::BOOT_SIGNAL, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::RESET_COUNTER, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::BOOT_AFTER_MS, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::BOOT_TIMEOUT_MS, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::ACTIVE_NVM, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::BP0_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::BP1_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::BP2_STATE, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::BOOT_SIGNAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::RESET_COUNTER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::BOOT_AFTER_MS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::BOOT_TIMEOUT_MS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::ACTIVE_NVM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::BP0_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::BP1_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::BP2_STATE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_ID, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CNT0, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CNT1, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CNT2, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CNT3, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CNT4, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CNT5, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CNT6, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_SEC, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MIN, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_HOUR, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_DAY, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MON, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_YEAR, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MSEC, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_IS_SET, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_ID, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CNT0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CNT1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CNT2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CNT3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CNT4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CNT5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CNT6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_SEC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MIN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_HOUR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_DAY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MON, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_YEAR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MSEC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_IS_SET, new PoolEntry( { 0 })); - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command, - uint8_t expectedReplies, bool useAlternateId, - DeviceCommandId_t alternateReplyID) { + uint8_t expectedReplies, + bool useAlternateId, + DeviceCommandId_t alternateReplyID) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + uint8_t enabledReplies = 0; - uint8_t enabledReplies = 0; - - switch (command->first) { + switch (command->first) { case PLOC_SPV::GET_HK_REPORT: { - enabledReplies = 3; - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::HK_REPORT); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::HK_REPORT << " not in replyMap" << std::endl; - } - break; + enabledReplies = 3; + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_SPV::HK_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " + << PLOC_SPV::HK_REPORT << " not in replyMap" << std::endl; + } + break; } case PLOC_SPV::GET_BOOT_STATUS_REPORT: { - enabledReplies = 3; - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::BOOT_STATUS_REPORT); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::BOOT_STATUS_REPORT << " not in replyMap" << std::endl; - } - break; + enabledReplies = 3; + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_SPV::BOOT_STATUS_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " + << PLOC_SPV::BOOT_STATUS_REPORT << " not in replyMap" << std::endl; + } + break; } case PLOC_SPV::GET_LATCHUP_STATUS_REPORT: { - enabledReplies = 3; - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::LATCHUP_REPORT); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::LATCHUP_REPORT << " not in replyMap" << std::endl; - } - break; + enabledReplies = 3; + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_SPV::LATCHUP_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " + << PLOC_SPV::LATCHUP_REPORT << " not in replyMap" << std::endl; + } + break; } case PLOC_SPV::FIRST_MRAM_DUMP: { - enabledReplies = 2; // expected replies will be increased in handleMramDumpPacket - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::FIRST_MRAM_DUMP); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::FIRST_MRAM_DUMP << " not in replyMap" << std::endl; - } - break; + enabledReplies = 2; // expected replies will be increased in handleMramDumpPacket + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_SPV::FIRST_MRAM_DUMP); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " + << PLOC_SPV::FIRST_MRAM_DUMP << " not in replyMap" << std::endl; + } + break; } case PLOC_SPV::CONSECUTIVE_MRAM_DUMP: { - enabledReplies = 2; // expected replies will be increased in handleMramDumpPacket - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::CONSECUTIVE_MRAM_DUMP); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::CONSECUTIVE_MRAM_DUMP << " not in replyMap" << std::endl; - } - break; + enabledReplies = 2; // expected replies will be increased in handleMramDumpPacket + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_SPV::CONSECUTIVE_MRAM_DUMP); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " + << PLOC_SPV::CONSECUTIVE_MRAM_DUMP << " not in replyMap" << std::endl; + } + break; } case PLOC_SPV::RESTART_MPSOC: case PLOC_SPV::START_MPSOC: @@ -574,957 +564,948 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite case PLOC_SPV::FACTORY_RESET_CLEAR_CIRCULAR: case PLOC_SPV::REQUEST_LOGGING_DATA: case PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION: - enabledReplies = 2; - break; + enabledReplies = 2; + break; default: - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Unknown command id" << std::endl; - break; - } + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Unknown command id" << std::endl; + break; + } - /** - * Every command causes at least one acknowledgment and one execution report. Therefore both - * replies will be enabled here. - */ - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::ACK_REPORT); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::ACK_REPORT << " not in replyMap" << std::endl; - } + /** + * Every command causes at least one acknowledgment and one execution report. Therefore both + * replies will be enabled here. + */ + result = + DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, PLOC_SPV::ACK_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " + << PLOC_SPV::ACK_REPORT << " not in replyMap" << std::endl; + } - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::EXE_REPORT); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::EXE_REPORT << " not in replyMap" << std::endl; - } + result = + DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, PLOC_SPV::EXE_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " + << PLOC_SPV::EXE_REPORT << " not in replyMap" << std::endl; + } - return RETURN_OK; + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::verifyPacket(const uint8_t* start, size_t foundLen) { + uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1); - uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1); + uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2); - uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2); + if (receivedCrc != recalculatedCrc) { + return CRC_FAILURE; + } - if (receivedCrc != recalculatedCrc) { - return CRC_FAILURE; - } - - return RETURN_OK; + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::handleAckReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_SPV::SIZE_ACK_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocSupervisorHandler::handleAckReport: CRC failure" << std::endl; + nextReplyId = PLOC_SPV::NONE; + replyRawReplyIfnotWiretapped(data, PLOC_SPV::SIZE_ACK_REPORT); + triggerEvent(SUPV_CRC_FAILURE_EVENT); + sendFailureReport(PLOC_SPV::ACK_REPORT, CRC_FAILURE); + disableAllReplies(); + return RETURN_OK; + } - result = verifyPacket(data, PLOC_SPV::SIZE_ACK_REPORT); - if(result == CRC_FAILURE) { - sif::error << "PlocSupervisorHandler::handleAckReport: CRC failure" << std::endl; - nextReplyId = PLOC_SPV::NONE; - replyRawReplyIfnotWiretapped(data, PLOC_SPV::SIZE_ACK_REPORT); - triggerEvent(SUPV_CRC_FAILURE_EVENT); - sendFailureReport(PLOC_SPV::ACK_REPORT, CRC_FAILURE); - disableAllReplies(); - return RETURN_OK; + uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; + + switch (apid) { + case PLOC_SPV::APID_ACK_FAILURE: { + // TODO: Interpretation of status field in acknowledgment report + sif::debug << "PlocSupervisorHandler::handleAckReport: Received Ack failure report" + << std::endl; + DeviceCommandId_t commandId = getPendingCommand(); + if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { + triggerEvent(SUPV_ACK_FAILURE, commandId); + } + sendFailureReport(PLOC_SPV::ACK_REPORT, RECEIVED_ACK_FAILURE); + disableAllReplies(); + nextReplyId = PLOC_SPV::NONE; + result = IGNORE_REPLY_DATA; + break; } + case PLOC_SPV::APID_ACK_SUCCESS: { + setNextReplyId(); + break; + } + default: { + sif::debug << "PlocSupervisorHandler::handleAckReport: Invalid APID in Ack report" + << std::endl; + result = RETURN_FAILED; + break; + } + } - uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; - - switch(apid) { - case PLOC_SPV::APID_ACK_FAILURE: { - //TODO: Interpretation of status field in acknowledgment report - sif::debug << "PlocSupervisorHandler::handleAckReport: Received Ack failure report" << std::endl; - DeviceCommandId_t commandId = getPendingCommand(); - if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { - triggerEvent(SUPV_ACK_FAILURE, commandId); - } - sendFailureReport(PLOC_SPV::ACK_REPORT, RECEIVED_ACK_FAILURE); - disableAllReplies(); - nextReplyId = PLOC_SPV::NONE; - result = IGNORE_REPLY_DATA; - break; - } - case PLOC_SPV::APID_ACK_SUCCESS: { - setNextReplyId(); - break; - } - default: { - sif::debug << "PlocSupervisorHandler::handleAckReport: Invalid APID in Ack report" << std::endl; - result = RETURN_FAILED; - break; - } - } - - return result; + return result; } ReturnValue_t PlocSupervisorHandler::handleExecutionReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_SPV::SIZE_EXE_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocSupervisorHandler::handleExecutionReport: CRC failure" << std::endl; + nextReplyId = PLOC_SPV::NONE; + return result; + } - result = verifyPacket(data, PLOC_SPV::SIZE_EXE_REPORT); - if(result == CRC_FAILURE) { - sif::error << "PlocSupervisorHandler::handleExecutionReport: CRC failure" << std::endl; - nextReplyId = PLOC_SPV::NONE; - return result; - } + uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; - uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; - - switch (apid) { + switch (apid) { case (PLOC_SPV::APID_EXE_SUCCESS): { - break; + break; } case (PLOC_SPV::APID_EXE_FAILURE): { - //TODO: Interpretation of status field in execution report - sif::error << "PlocSupervisorHandler::handleExecutionReport: Received execution failure report" - << std::endl; - DeviceCommandId_t commandId = getPendingCommand(); - if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { - triggerEvent(SUPV_EXE_FAILURE, commandId); - } - else { - sif::debug << "PlocSupervisorHandler::handleExecutionReport: Unknown command id" << std::endl; - } - sendFailureReport(PLOC_SPV::EXE_REPORT, RECEIVED_EXE_FAILURE); - disableExeReportReply(); - result = IGNORE_REPLY_DATA; - break; + // TODO: Interpretation of status field in execution report + sif::error + << "PlocSupervisorHandler::handleExecutionReport: Received execution failure report" + << std::endl; + DeviceCommandId_t commandId = getPendingCommand(); + if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { + triggerEvent(SUPV_EXE_FAILURE, commandId); + } else { + sif::debug << "PlocSupervisorHandler::handleExecutionReport: Unknown command id" + << std::endl; + } + sendFailureReport(PLOC_SPV::EXE_REPORT, RECEIVED_EXE_FAILURE); + disableExeReportReply(); + result = IGNORE_REPLY_DATA; + break; } default: { - sif::error << "PlocSupervisorHandler::handleExecutionReport: Unknown APID" << std::endl; - result = RETURN_FAILED; - break; - } + sif::error << "PlocSupervisorHandler::handleExecutionReport: Unknown APID" << std::endl; + result = RETURN_FAILED; + break; } + } - nextReplyId = PLOC_SPV::NONE; + nextReplyId = PLOC_SPV::NONE; - return result; + return result; } ReturnValue_t PlocSupervisorHandler::handleHkReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_SPV::SIZE_HK_REPORT); - result = verifyPacket(data, PLOC_SPV::SIZE_HK_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocSupervisorHandler::handleHkReport: Hk report has invalid crc" << std::endl; + } - if(result == CRC_FAILURE) { - sif::error << "PlocSupervisorHandler::handleHkReport: Hk report has invalid crc" - << std::endl; - } + uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET; + hkset.tempPs = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 | + *(data + offset + 3); + offset += 4; + hkset.tempPl = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 | + *(data + offset + 3); + offset += 4; + hkset.tempSup = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 | + *(data + offset + 3); + offset += 4; + hkset.uptime = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 | + *(data + offset + 3); + offset += 4; + hkset.cpuLoad = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 | + *(data + offset + 3); + offset += 4; + hkset.availableHeap = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + hkset.numTcs = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 | + *(data + offset + 3); + offset += 4; + hkset.numTms = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 | + *(data + offset + 3); + offset += 4; + hkset.socState = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 | + *(data + offset + 3); + offset += 4; + hkset.nvm0_1_state = *(data + offset); + offset += 1; + hkset.nvm3_state = *(data + offset); + offset += 1; + hkset.missionIoState = *(data + offset); + offset += 1; + hkset.fmcState = *(data + offset); + offset += 1; - uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET; - hkset.tempPs = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 - | *(data + offset + 3); - offset += 4; - hkset.tempPl = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 - | *(data + offset + 3); - offset += 4; - hkset.tempSup = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 - | *(data + offset + 3); - offset += 4; - hkset.uptime = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 - | *(data + offset + 3); - offset += 4; - hkset.cpuLoad = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 - | *(data + offset + 3); - offset += 4; - hkset.availableHeap = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 - | *(data + offset + 3); - offset += 4; - hkset.numTcs = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 - | *(data + offset + 3); - offset += 4; - hkset.numTms = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 - | *(data + offset + 3); - offset += 4; - hkset.socState = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 - | *(data + offset + 3); - offset += 4; - hkset.nvm0_1_state = *(data + offset); - offset += 1; - hkset.nvm3_state = *(data + offset); - offset += 1; - hkset.missionIoState = *(data + offset); - offset += 1; - hkset.fmcState = *(data + offset); - offset += 1; - - nextReplyId = PLOC_SPV::EXE_REPORT; + nextReplyId = PLOC_SPV::EXE_REPORT; #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PLOC_SUPERVISOR == 1 - sif::info << "PlocSupervisorHandler::handleHkReport: temp_ps: " << hkset.tempPs << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: temp_pl: " << hkset.tempPl << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: temp_sup: " << hkset.tempSup << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: uptime: " << hkset.uptime << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: cpu_load: " << hkset.cpuLoad << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: available_heap: " << hkset.availableHeap << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: num_tcs: " << hkset.numTcs << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: num_tms: " << hkset.numTms << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: soc_state: " << hkset.socState << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: nvm0_1_state: " + sif::info << "PlocSupervisorHandler::handleHkReport: temp_ps: " << hkset.tempPs << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: temp_pl: " << hkset.tempPl << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: temp_sup: " << hkset.tempSup << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: uptime: " << hkset.uptime << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: cpu_load: " << hkset.cpuLoad << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: available_heap: " << hkset.availableHeap + << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: num_tcs: " << hkset.numTcs << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: num_tms: " << hkset.numTms << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: soc_state: " << hkset.socState << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: nvm0_1_state: " << static_cast(hkset.nvm0_1_state.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: nvm3_state: " + sif::info << "PlocSupervisorHandler::handleHkReport: nvm3_state: " << static_cast(hkset.nvm3_state.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: missoin_io_state: " + sif::info << "PlocSupervisorHandler::handleHkReport: missoin_io_state: " << static_cast(hkset.missionIoState.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: fmc_state: " + sif::info << "PlocSupervisorHandler::handleHkReport: fmc_state: " << static_cast(hkset.fmcState.value) << std::endl; #endif - return result; + return result; } ReturnValue_t PlocSupervisorHandler::handleBootStatusReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_SPV::SIZE_BOOT_STATUS_REPORT); - result = verifyPacket(data, PLOC_SPV::SIZE_BOOT_STATUS_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocSupervisorHandler::handleBootStatusReport: Boot status report has invalid" + " crc" + << std::endl; + return result; + } - if(result == CRC_FAILURE) { - sif::error << "PlocSupervisorHandler::handleBootStatusReport: Boot status report has invalid" - " crc" << std::endl; - return result; - } + uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET; + bootStatusReport.bootSignal = *(data + offset); + offset += 1; + bootStatusReport.resetCounter = *(data + offset); + offset += 1; + bootStatusReport.bootAfterMs = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + bootStatusReport.bootTimeoutMs = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + bootStatusReport.activeNvm = *(data + offset); + offset += 1; + bootStatusReport.bp0State = *(data + offset); + offset += 1; + bootStatusReport.bp1State = *(data + offset); + offset += 1; + bootStatusReport.bp2State = *(data + offset); - uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET; - bootStatusReport.bootSignal = *(data + offset); - offset += 1; - bootStatusReport.resetCounter = *(data + offset); - offset += 1; - bootStatusReport.bootAfterMs = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - bootStatusReport.bootTimeoutMs = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - bootStatusReport.activeNvm = *(data + offset); - offset += 1; - bootStatusReport.bp0State = *(data + offset); - offset += 1; - bootStatusReport.bp1State = *(data + offset); - offset += 1; - bootStatusReport.bp2State = *(data + offset); - - nextReplyId = PLOC_SPV::EXE_REPORT; + nextReplyId = PLOC_SPV::EXE_REPORT; #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PLOC_SUPERVISOR == 1 - sif::info << "PlocSupervisorHandler::handleBootStatusReport: Boot signal: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: Boot signal: " << static_cast(bootStatusReport.bootSignal.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleBootStatusReport: Reset counter: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: Reset counter: " << static_cast(bootStatusReport.resetCounter.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleBootStatusReport: BootAfterMs: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: BootAfterMs: " << bootStatusReport.bootAfterMs << " ms" << std::endl; - sif::info << "PlocSupervisorHandler::handleBootStatusReport: BootTimeoutMs: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: BootTimeoutMs: " << bootStatusReport.bootTimeoutMs << " ms" << std::endl; - sif::info << "PlocSupervisorHandler::handleBootStatusReport: Active NVM: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: Active NVM: " << static_cast(bootStatusReport.activeNvm.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP0: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP0: " << static_cast(bootStatusReport.bp0State.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP1: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP1: " << static_cast(bootStatusReport.bp1State.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP2: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP2: " << static_cast(bootStatusReport.bp2State.value) << std::endl; #endif - return result; + return result; } ReturnValue_t PlocSupervisorHandler::handleLatchupStatusReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_SPV::SIZE_LATCHUP_STATUS_REPORT); - result = verifyPacket(data, PLOC_SPV::SIZE_LATCHUP_STATUS_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocSupervisorHandler::handleLatchupStatusReport: Latchup status report has " + << "invalid crc" << std::endl; + return result; + } - if(result == CRC_FAILURE) { - sif::error << "PlocSupervisorHandler::handleLatchupStatusReport: Latchup status report has " - << "invalid crc" << std::endl; - return result; - } + uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET; + latchupStatusReport.id = *(data + offset); + offset += 1; + latchupStatusReport.cnt0 = *(data + offset) << 8 | *(data + offset + 1); + offset += 2; + latchupStatusReport.cnt1 = *(data + offset) << 8 | *(data + offset + 1); + offset += 2; + latchupStatusReport.cnt2 = *(data + offset) << 8 | *(data + offset + 1); + offset += 2; + latchupStatusReport.cnt3 = *(data + offset) << 8 | *(data + offset + 1); + offset += 2; + latchupStatusReport.cnt4 = *(data + offset) << 8 | *(data + offset + 1); + offset += 2; + latchupStatusReport.cnt5 = *(data + offset) << 8 | *(data + offset + 1); + offset += 2; + latchupStatusReport.cnt6 = *(data + offset) << 8 | *(data + offset + 1); + offset += 2; + latchupStatusReport.timeSec = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + latchupStatusReport.timeMin = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + latchupStatusReport.timeHour = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + latchupStatusReport.timeDay = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + latchupStatusReport.timeMon = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + latchupStatusReport.timeYear = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + latchupStatusReport.timeMsec = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + latchupStatusReport.isSet = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; - uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET; - latchupStatusReport.id = *(data + offset); - offset += 1; - latchupStatusReport.cnt0 = *(data + offset) << 8 | *(data + offset + 1); - offset += 2; - latchupStatusReport.cnt1 = *(data + offset) << 8 | *(data + offset + 1); - offset += 2; - latchupStatusReport.cnt2 = *(data + offset) << 8 | *(data + offset + 1); - offset += 2; - latchupStatusReport.cnt3 = *(data + offset) << 8 | *(data + offset + 1); - offset += 2; - latchupStatusReport.cnt4 = *(data + offset) << 8 | *(data + offset + 1); - offset += 2; - latchupStatusReport.cnt5 = *(data + offset) << 8 | *(data + offset + 1); - offset += 2; - latchupStatusReport.cnt6 = *(data + offset) << 8 | *(data + offset + 1); - offset += 2; - latchupStatusReport.timeSec = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - latchupStatusReport.timeMin = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - latchupStatusReport.timeHour = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - latchupStatusReport.timeDay = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - latchupStatusReport.timeMon = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - latchupStatusReport.timeYear = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - latchupStatusReport.timeMsec = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - latchupStatusReport.isSet = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - - nextReplyId = PLOC_SPV::EXE_REPORT; + nextReplyId = PLOC_SPV::EXE_REPORT; #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PLOC_SUPERVISOR == 1 - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Latchup ID: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Latchup ID: " << static_cast(latchupStatusReport.id.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT0: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT0: " << latchupStatusReport.cnt0 << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT1: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT1: " << latchupStatusReport.cnt1 << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT2: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT2: " << latchupStatusReport.cnt2 << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT3: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT3: " << latchupStatusReport.cnt3 << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT4: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT4: " << latchupStatusReport.cnt4 << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT5: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT5: " << latchupStatusReport.cnt5 << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT6: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT6: " << latchupStatusReport.cnt6 << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Sec: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Sec: " << latchupStatusReport.timeSec << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Min: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Min: " << latchupStatusReport.timeMin << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Hour: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Hour: " << latchupStatusReport.timeHour << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Day: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Day: " << latchupStatusReport.timeDay << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Mon: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Mon: " << latchupStatusReport.timeMon << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Year: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Year: " << latchupStatusReport.timeYear << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Msec: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Msec: " << latchupStatusReport.timeMsec << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: isSet: 0x" - << std::hex << latchupStatusReport.timeMsec << std::dec << std::endl; + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: isSet: 0x" << std::hex + << latchupStatusReport.timeMsec << std::dec << std::endl; #endif - return result; + return result; } void PlocSupervisorHandler::setNextReplyId() { - switch(getPendingCommand()) { + switch (getPendingCommand()) { case PLOC_SPV::GET_HK_REPORT: - nextReplyId = PLOC_SPV::HK_REPORT; - break; + nextReplyId = PLOC_SPV::HK_REPORT; + break; case PLOC_SPV::GET_BOOT_STATUS_REPORT: - nextReplyId = PLOC_SPV::BOOT_STATUS_REPORT; - break; + nextReplyId = PLOC_SPV::BOOT_STATUS_REPORT; + break; case PLOC_SPV::GET_LATCHUP_STATUS_REPORT: - nextReplyId = PLOC_SPV::LATCHUP_REPORT; - break; + nextReplyId = PLOC_SPV::LATCHUP_REPORT; + break; case PLOC_SPV::FIRST_MRAM_DUMP: - nextReplyId = PLOC_SPV::FIRST_MRAM_DUMP; - break; + nextReplyId = PLOC_SPV::FIRST_MRAM_DUMP; + break; case PLOC_SPV::CONSECUTIVE_MRAM_DUMP: - nextReplyId = PLOC_SPV::CONSECUTIVE_MRAM_DUMP; - break; + nextReplyId = PLOC_SPV::CONSECUTIVE_MRAM_DUMP; + break; default: - /* If no telemetry is expected the next reply is always the execution report */ - nextReplyId = PLOC_SPV::EXE_REPORT; - break; - } + /* If no telemetry is expected the next reply is always the execution report */ + nextReplyId = PLOC_SPV::EXE_REPORT; + break; + } } -size_t PlocSupervisorHandler::getNextReplyLength(DeviceCommandId_t commandId){ - - size_t replyLen = 0; - - if (nextReplyId == PLOC_SPV::NONE) { - return replyLen; - } - - if (nextReplyId == PLOC_SPV::FIRST_MRAM_DUMP - || nextReplyId == PLOC_SPV::CONSECUTIVE_MRAM_DUMP) { - /** - * Try to read 20 MRAM packets. If reply is larger, the packets will be read with the - * next doSendRead call. The command will be as long active as the packet with the sequence - * count indicating the last packet has not been received. - */ - replyLen = PLOC_SPV::MAX_PACKET_SIZE * 20; - return replyLen; - } - - DeviceReplyIter iter = deviceReplyMap.find(nextReplyId); - if (iter != deviceReplyMap.end()) { - if (iter->second.delayCycles == 0) { - /* Reply inactive */ - return replyLen; - } - replyLen = iter->second.replyLen; - } - else { - sif::debug << "PlocSupervisorHandler::getNextReplyLength: No entry for reply with reply id " - << std::hex << nextReplyId << " in deviceReplyMap" << std::endl; - } +size_t PlocSupervisorHandler::getNextReplyLength(DeviceCommandId_t commandId) { + size_t replyLen = 0; + if (nextReplyId == PLOC_SPV::NONE) { return replyLen; + } + + if (nextReplyId == PLOC_SPV::FIRST_MRAM_DUMP || nextReplyId == PLOC_SPV::CONSECUTIVE_MRAM_DUMP) { + /** + * Try to read 20 MRAM packets. If reply is larger, the packets will be read with the + * next doSendRead call. The command will be as long active as the packet with the sequence + * count indicating the last packet has not been received. + */ + replyLen = PLOC_SPV::MAX_PACKET_SIZE * 20; + return replyLen; + } + + DeviceReplyIter iter = deviceReplyMap.find(nextReplyId); + if (iter != deviceReplyMap.end()) { + if (iter->second.delayCycles == 0) { + /* Reply inactive */ + return replyLen; + } + replyLen = iter->second.replyLen; + } else { + sif::debug << "PlocSupervisorHandler::getNextReplyLength: No entry for reply with reply id " + << std::hex << nextReplyId << " in deviceReplyMap" << std::endl; + } + + return replyLen; } -void PlocSupervisorHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId) { +void PlocSupervisorHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, + DeviceCommandId_t replyId) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + if (wiretappingMode == RAW) { + /* Data already sent in doGetRead() */ + return; + } - if (wiretappingMode == RAW) { - /* Data already sent in doGetRead() */ - return; - } + DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId); + if (iter == deviceReplyMap.end()) { + sif::debug << "PlocSupervisorHandler::handleDeviceTM: Unknown reply id" << std::endl; + return; + } + MessageQueueId_t queueId = iter->second.command->second.sendReplyTo; - DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId); - if (iter == deviceReplyMap.end()) { - sif::debug << "PlocSupervisorHandler::handleDeviceTM: Unknown reply id" << std::endl; - return; - } - MessageQueueId_t queueId = iter->second.command->second.sendReplyTo; + if (queueId == NO_COMMANDER) { + return; + } - if (queueId == NO_COMMANDER) { - return; - } - - result = actionHelper.reportData(queueId, replyId, data, dataSize); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::handleDeviceTM: Failed to report data" << std::endl; - } + result = actionHelper.reportData(queueId, replyId, data, dataSize); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::handleDeviceTM: Failed to report data" << std::endl; + } } void PlocSupervisorHandler::prepareEmptyCmd(uint16_t apid) { - PLOC_SPV::EmptyPacket packet(apid); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + PLOC_SPV::EmptyPacket packet(apid); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } -void PlocSupervisorHandler::prepareSelBootImageCmd(const uint8_t * commandData) { - PLOC_SPV::MPSoCBootSelect packet(*commandData, *(commandData + 1), *(commandData + 2), - *(commandData + 3)); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); +void PlocSupervisorHandler::prepareSelBootImageCmd(const uint8_t* commandData) { + PLOC_SPV::MPSoCBootSelect packet(*commandData, *(commandData + 1), *(commandData + 2), + *(commandData + 3)); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } ReturnValue_t PlocSupervisorHandler::prepareSetTimeRefCmd() { - Clock::TimeOfDay_t time; - ReturnValue_t result = Clock::getDateAndTime(&time); - if (result != RETURN_OK) { - sif::warning << "PlocSupervisorHandler::prepareSetTimeRefCmd: Failed to get current time" - << std::endl; - return GET_TIME_FAILURE; - } - PLOC_SPV::SetTimeRef packet(&time); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; + Clock::TimeOfDay_t time; + ReturnValue_t result = Clock::getDateAndTime(&time); + if (result != RETURN_OK) { + sif::warning << "PlocSupervisorHandler::prepareSetTimeRefCmd: Failed to get current time" + << std::endl; + return GET_TIME_FAILURE; + } + PLOC_SPV::SetTimeRef packet(&time); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } void PlocSupervisorHandler::prepareDisableHk() { - PLOC_SPV::DisablePeriodicHkTransmission packet; - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + PLOC_SPV::DisablePeriodicHkTransmission packet; + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } -void PlocSupervisorHandler::prepareSetBootTimeoutCmd(const uint8_t * commandData) { - uint32_t timeout = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 - | *(commandData + 3); - PLOC_SPV::SetBootTimeout packet(timeout); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); +void PlocSupervisorHandler::prepareSetBootTimeoutCmd(const uint8_t* commandData) { + uint32_t timeout = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 | + *(commandData + 3); + PLOC_SPV::SetBootTimeout packet(timeout); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } -void PlocSupervisorHandler::prepareRestartTriesCmd(const uint8_t * commandData) { - uint8_t restartTries = *(commandData); - PLOC_SPV::SetRestartTries packet(restartTries); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); +void PlocSupervisorHandler::prepareRestartTriesCmd(const uint8_t* commandData) { + uint8_t restartTries = *(commandData); + PLOC_SPV::SetRestartTries packet(restartTries); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } -void PlocSupervisorHandler::prepareWatchdogsEnableCmd(const uint8_t * commandData) { - uint8_t offset = 0; - uint8_t watchdogPs = *(commandData + offset); - offset += 1; - uint8_t watchdogPl = *(commandData + offset); - offset += 1; - uint8_t watchdogInt = *(commandData + offset); - PLOC_SPV::WatchdogsEnable packet(watchdogPs, watchdogPl, watchdogInt); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); +void PlocSupervisorHandler::prepareWatchdogsEnableCmd(const uint8_t* commandData) { + uint8_t offset = 0; + uint8_t watchdogPs = *(commandData + offset); + offset += 1; + uint8_t watchdogPl = *(commandData + offset); + offset += 1; + uint8_t watchdogInt = *(commandData + offset); + PLOC_SPV::WatchdogsEnable packet(watchdogPs, watchdogPl, watchdogInt); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } -ReturnValue_t PlocSupervisorHandler::prepareWatchdogsConfigTimeoutCmd(const uint8_t * commandData) { - uint8_t offset = 0; - uint8_t watchdog = *(commandData + offset); - offset += 1; - if (watchdog > 2) { - return INVALID_WATCHDOG; - } - uint32_t timeout = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16 - | *(commandData + offset + 2) << 8 | *(commandData + offset + 3); - if (timeout < 1000 || timeout > 360000) { - return INVALID_WATCHDOG_TIMEOUT; - } - PLOC_SPV::WatchdogsConfigTimeout packet(watchdog, timeout); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; +ReturnValue_t PlocSupervisorHandler::prepareWatchdogsConfigTimeoutCmd(const uint8_t* commandData) { + uint8_t offset = 0; + uint8_t watchdog = *(commandData + offset); + offset += 1; + if (watchdog > 2) { + return INVALID_WATCHDOG; + } + uint32_t timeout = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16 | + *(commandData + offset + 2) << 8 | *(commandData + offset + 3); + if (timeout < 1000 || timeout > 360000) { + return INVALID_WATCHDOG_TIMEOUT; + } + PLOC_SPV::WatchdogsConfigTimeout packet(watchdog, timeout); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::prepareLatchupConfigCmd(const uint8_t* commandData, - DeviceCommandId_t deviceCommand) { - ReturnValue_t result = RETURN_OK; - uint8_t latchupId = *commandData; - if (latchupId > 6) { - return INVALID_LATCHUP_ID; - } - switch (deviceCommand) { + DeviceCommandId_t deviceCommand) { + ReturnValue_t result = RETURN_OK; + uint8_t latchupId = *commandData; + if (latchupId > 6) { + return INVALID_LATCHUP_ID; + } + switch (deviceCommand) { case (PLOC_SPV::ENABLE_LATCHUP_ALERT): { - PLOC_SPV::LatchupAlert packet(true, latchupId); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - break; + PLOC_SPV::LatchupAlert packet(true, latchupId); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + break; } case (PLOC_SPV::DISABLE_LATCHUP_ALERT): { - PLOC_SPV::LatchupAlert packet(false, latchupId); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - break; + PLOC_SPV::LatchupAlert packet(false, latchupId); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + break; } default: { - sif::debug << "PlocSupervisorHandler::prepareLatchupConfigCmd: Invalid command id" - << std::endl; - result = RETURN_FAILED; - break; + sif::debug << "PlocSupervisorHandler::prepareLatchupConfigCmd: Invalid command id" + << std::endl; + result = RETURN_FAILED; + break; } - } - return result; + } + return result; } ReturnValue_t PlocSupervisorHandler::prepareAutoCalibrateAlertCmd(const uint8_t* commandData) { - uint8_t offset = 0; - uint8_t latchupId = *commandData; - offset += 1; - uint32_t mg = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16 - | *(commandData + offset + 2) << 8 | *(commandData + offset + 3); - if (latchupId > 6) { - return INVALID_LATCHUP_ID; - } - PLOC_SPV::AutoCalibrateAlert packet(latchupId, mg); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; + uint8_t offset = 0; + uint8_t latchupId = *commandData; + offset += 1; + uint32_t mg = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16 | + *(commandData + offset + 2) << 8 | *(commandData + offset + 3); + if (latchupId > 6) { + return INVALID_LATCHUP_ID; + } + PLOC_SPV::AutoCalibrateAlert packet(latchupId, mg); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::prepareSetAlertIrqFilterCmd(const uint8_t* commandData) { - uint8_t latchupId = *commandData; - uint8_t tp = *(commandData + 1); - uint8_t div = *(commandData + 2); - if (latchupId > 6) { - return INVALID_LATCHUP_ID; - } - PLOC_SPV::SetAlertIrqFilter packet(latchupId, tp, div); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; + uint8_t latchupId = *commandData; + uint8_t tp = *(commandData + 1); + uint8_t div = *(commandData + 2); + if (latchupId > 6) { + return INVALID_LATCHUP_ID; + } + PLOC_SPV::SetAlertIrqFilter packet(latchupId, tp, div); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::prepareSetAlertLimitCmd(const uint8_t* commandData) { - uint8_t offset = 0; - uint8_t latchupId = *commandData; - offset += 1; - uint32_t dutycycle = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16 - | *(commandData + offset + 2) << 8 | *(commandData + offset + 3); - if (latchupId > 6) { - return INVALID_LATCHUP_ID; - } - PLOC_SPV::SetAlertlimit packet(latchupId, dutycycle); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; + uint8_t offset = 0; + uint8_t latchupId = *commandData; + offset += 1; + uint32_t dutycycle = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16 | + *(commandData + offset + 2) << 8 | *(commandData + offset + 3); + if (latchupId > 6) { + return INVALID_LATCHUP_ID; + } + PLOC_SPV::SetAlertlimit packet(latchupId, dutycycle); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::prepareSetAdcSweetPeriodCmd(const uint8_t* commandData) { - uint32_t sweepPeriod = *(commandData) << 24 | *(commandData + 1) << 16 - | *(commandData + 2) << 8 | *(commandData + 3); - if (sweepPeriod < 21) { - return SWEEP_PERIOD_TOO_SMALL; - } - PLOC_SPV::SetAdcSweepPeriod packet(sweepPeriod); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; + uint32_t sweepPeriod = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 | + *(commandData + 3); + if (sweepPeriod < 21) { + return SWEEP_PERIOD_TOO_SMALL; + } + PLOC_SPV::SetAdcSweepPeriod packet(sweepPeriod); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } void PlocSupervisorHandler::prepareSetAdcEnabledChannelsCmd(const uint8_t* commandData) { - uint16_t ch = *(commandData) << 8 | *(commandData + 1); - PLOC_SPV::SetAdcEnabledChannels packet(ch); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint16_t ch = *(commandData) << 8 | *(commandData + 1); + PLOC_SPV::SetAdcEnabledChannels packet(ch); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareSetAdcWindowAndStrideCmd(const uint8_t* commandData) { - uint8_t offset = 0; - uint16_t windowSize = *(commandData + offset) << 8 | *(commandData + offset + 1); - offset += 2; - uint16_t stridingStepSize = *(commandData + offset) << 8 | *(commandData + offset + 1); - PLOC_SPV::SetAdcWindowAndStride packet(windowSize, stridingStepSize); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint8_t offset = 0; + uint16_t windowSize = *(commandData + offset) << 8 | *(commandData + offset + 1); + offset += 2; + uint16_t stridingStepSize = *(commandData + offset) << 8 | *(commandData + offset + 1); + PLOC_SPV::SetAdcWindowAndStride packet(windowSize, stridingStepSize); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareSetAdcThresholdCmd(const uint8_t* commandData) { - uint32_t threshold = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 - | *(commandData + 3); - PLOC_SPV::SetAdcThreshold packet(threshold); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint32_t threshold = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 | + *(commandData + 3); + PLOC_SPV::SetAdcThreshold packet(threshold); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareEnableNvmsCmd(const uint8_t* commandData) { - uint8_t n01 = *commandData; - uint8_t n3 = *(commandData + 1); - PLOC_SPV::EnableNvms packet(n01, n3); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint8_t n01 = *commandData; + uint8_t n3 = *(commandData + 1); + PLOC_SPV::EnableNvms packet(n01, n3); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareSelectNvmCmd(const uint8_t* commandData) { - uint8_t mem = *commandData; - PLOC_SPV::SelectNvm packet(mem); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint8_t mem = *commandData; + PLOC_SPV::SelectNvm packet(mem); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } ReturnValue_t PlocSupervisorHandler::prepareRunAutoEmTest(const uint8_t* commandData) { - uint8_t test = *commandData; - if (test != 1 && test != 2) { - return INVALID_TEST_PARAM; - } - PLOC_SPV::RunAutoEmTests packet(test); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; + uint8_t test = *commandData; + if (test != 1 && test != 2) { + return INVALID_TEST_PARAM; + } + PLOC_SPV::RunAutoEmTests packet(test); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::prepareWipeMramCmd(const uint8_t* commandData) { - uint32_t start = 0; - uint32_t stop = 0; - size_t size = sizeof(start) + sizeof(stop); - SerializeAdapter::deSerialize(&start, &commandData, &size, SerializeIF::Endianness::BIG); - SerializeAdapter::deSerialize(&stop, &commandData, &size, SerializeIF::Endianness::BIG); - if ((stop - start) <= 0) { - return INVALID_MRAM_ADDRESSES; - } - PLOC_SPV::MramCmd packet(start, stop, PLOC_SPV::MramCmd::MramAction::WIPE); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; + uint32_t start = 0; + uint32_t stop = 0; + size_t size = sizeof(start) + sizeof(stop); + SerializeAdapter::deSerialize(&start, &commandData, &size, SerializeIF::Endianness::BIG); + SerializeAdapter::deSerialize(&stop, &commandData, &size, SerializeIF::Endianness::BIG); + if ((stop - start) <= 0) { + return INVALID_MRAM_ADDRESSES; + } + PLOC_SPV::MramCmd packet(start, stop, PLOC_SPV::MramCmd::MramAction::WIPE); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::prepareDumpMramCmd(const uint8_t* commandData) { - uint32_t start = 0; - uint32_t stop = 0; - size_t size = sizeof(start) + sizeof(stop); - SerializeAdapter::deSerialize(&start, &commandData, &size, SerializeIF::Endianness::BIG); - SerializeAdapter::deSerialize(&stop, &commandData, &size, SerializeIF::Endianness::BIG); - PLOC_SPV::MramCmd packet(start, stop, PLOC_SPV::MramCmd::MramAction::DUMP); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - if ((stop - start) <= 0) { - return INVALID_MRAM_ADDRESSES; - } - expectedMramDumpPackets = (stop - start) / PLOC_SPV::MAX_DATA_CAPACITY; - if ((stop - start) % PLOC_SPV::MAX_DATA_CAPACITY) { - expectedMramDumpPackets++; - } - receivedMramDumpPackets = 0; - return RETURN_OK; + uint32_t start = 0; + uint32_t stop = 0; + size_t size = sizeof(start) + sizeof(stop); + SerializeAdapter::deSerialize(&start, &commandData, &size, SerializeIF::Endianness::BIG); + SerializeAdapter::deSerialize(&stop, &commandData, &size, SerializeIF::Endianness::BIG); + PLOC_SPV::MramCmd packet(start, stop, PLOC_SPV::MramCmd::MramAction::DUMP); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + if ((stop - start) <= 0) { + return INVALID_MRAM_ADDRESSES; + } + expectedMramDumpPackets = (stop - start) / PLOC_SPV::MAX_DATA_CAPACITY; + if ((stop - start) % PLOC_SPV::MAX_DATA_CAPACITY) { + expectedMramDumpPackets++; + } + receivedMramDumpPackets = 0; + return RETURN_OK; } void PlocSupervisorHandler::preparePrintCpuStatsCmd(const uint8_t* commandData) { - uint8_t en = *commandData; - PLOC_SPV::PrintCpuStats packet(en); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint8_t en = *commandData; + PLOC_SPV::PrintCpuStats packet(en); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareSetDbgVerbosityCmd(const uint8_t* commandData) { - uint8_t vb = *commandData; - PLOC_SPV::SetDbgVerbosity packet(vb); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint8_t vb = *commandData; + PLOC_SPV::SetDbgVerbosity packet(vb); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareSetGpioCmd(const uint8_t* commandData) { - uint8_t port = *commandData; - uint8_t pin = *(commandData + 1); - uint8_t val = *(commandData + 2); - PLOC_SPV::SetGpio packet(port, pin, val); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint8_t port = *commandData; + uint8_t pin = *(commandData + 1); + uint8_t val = *(commandData + 2); + PLOC_SPV::SetGpio packet(port, pin, val); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareReadGpioCmd(const uint8_t* commandData) { - uint8_t port = *commandData; - uint8_t pin = *(commandData + 1); - PLOC_SPV::ReadGpio packet(port, pin); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint8_t port = *commandData; + uint8_t pin = *(commandData + 1); + PLOC_SPV::ReadGpio packet(port, pin); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::packetToOutBuffer(uint8_t* packetData, size_t fullSize) { - memcpy(commandBuffer, packetData, fullSize); - rawPacket = commandBuffer; - rawPacketLen = fullSize; - nextReplyId = PLOC_SPV::ACK_REPORT; + memcpy(commandBuffer, packetData, fullSize); + rawPacket = commandBuffer; + rawPacketLen = fullSize; + nextReplyId = PLOC_SPV::ACK_REPORT; } void PlocSupervisorHandler::disableAllReplies() { + DeviceReplyMap::iterator iter; - DeviceReplyMap::iterator iter; + /* Disable ack reply */ + iter = deviceReplyMap.find(PLOC_SPV::ACK_REPORT); + DeviceReplyInfo* info = &(iter->second); + info->delayCycles = 0; + info->command = deviceCommandMap.end(); - /* Disable ack reply */ - iter = deviceReplyMap.find(PLOC_SPV::ACK_REPORT); - DeviceReplyInfo *info = &(iter->second); - info->delayCycles = 0; - info->command = deviceCommandMap.end(); + DeviceCommandId_t commandId = getPendingCommand(); - DeviceCommandId_t commandId = getPendingCommand(); - - /* If the command expects a telemetry packet the appropriate tm reply will be disabled here */ - switch (commandId) { + /* If the command expects a telemetry packet the appropriate tm reply will be disabled here */ + switch (commandId) { case PLOC_SPV::GET_HK_REPORT: { - iter = deviceReplyMap.find(PLOC_SPV::GET_HK_REPORT); - info = &(iter->second); - info->delayCycles = 0; - info->command = deviceCommandMap.end(); - break; + iter = deviceReplyMap.find(PLOC_SPV::GET_HK_REPORT); + info = &(iter->second); + info->delayCycles = 0; + info->command = deviceCommandMap.end(); + break; } default: { - break; - } + break; } + } - /* We must always disable the execution report reply here */ - disableExeReportReply(); + /* We must always disable the execution report reply here */ + disableExeReportReply(); } void PlocSupervisorHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status) { + DeviceReplyIter iter = deviceReplyMap.find(replyId); - DeviceReplyIter iter = deviceReplyMap.find(replyId); + if (iter == deviceReplyMap.end()) { + sif::debug << "PlocSupervisorHandler::sendFailureReport: Reply not in reply map" << std::endl; + return; + } - if (iter == deviceReplyMap.end()) { - sif::debug << "PlocSupervisorHandler::sendFailureReport: Reply not in reply map" << std::endl; - return; - } + DeviceCommandInfo* info = &(iter->second.command->second); - DeviceCommandInfo* info = &(iter->second.command->second); + if (info == nullptr) { + sif::debug << "PlocSupervisorHandler::sendFailureReport: Reply has no active command" + << std::endl; + return; + } - if (info == nullptr) { - sif::debug << "PlocSupervisorHandler::sendFailureReport: Reply has no active command" << std::endl; - return; - } - - if (info->sendReplyTo != NO_COMMANDER) { - actionHelper.finish(false, info->sendReplyTo, iter->first, status); - } - info->isExecuting = false; + if (info->sendReplyTo != NO_COMMANDER) { + actionHelper.finish(false, info->sendReplyTo, iter->first, status); + } + info->isExecuting = false; } void PlocSupervisorHandler::disableExeReportReply() { - DeviceReplyIter iter = deviceReplyMap.find(PLOC_SPV::EXE_REPORT); - DeviceReplyInfo *info = &(iter->second); - info->delayCycles = 0; - info->command = deviceCommandMap.end(); - /* Expected replies is set to one here. The value will set to 0 in replyToReply() */ - info->command->second.expectedReplies = 1; + DeviceReplyIter iter = deviceReplyMap.find(PLOC_SPV::EXE_REPORT); + DeviceReplyInfo* info = &(iter->second); + info->delayCycles = 0; + info->command = deviceCommandMap.end(); + /* Expected replies is set to one here. The value will set to 0 in replyToReply() */ + info->command->second.expectedReplies = 1; } -ReturnValue_t PlocSupervisorHandler::parseMramPackets(const uint8_t *packet, size_t remainingSize, - size_t* foundLen) { - ReturnValue_t result = IGNORE_FULL_PACKET; - uint16_t packetLen = 0; - *foundLen = 0; +ReturnValue_t PlocSupervisorHandler::parseMramPackets(const uint8_t* packet, size_t remainingSize, + size_t* foundLen) { + ReturnValue_t result = IGNORE_FULL_PACKET; + uint16_t packetLen = 0; + *foundLen = 0; - for (size_t idx = 0; idx < remainingSize; idx++) { - std::memcpy(spacePacketBuffer + bufferTop, packet + idx, 1); - bufferTop += 1; - *foundLen += 1; - if (bufferTop >= PLOC_SPV::SPACE_PACKET_HEADER_LENGTH) { - packetLen = readSpacePacketLength(spacePacketBuffer); - } - - if (bufferTop == PLOC_SPV::SPACE_PACKET_HEADER_LENGTH + packetLen + 1) { - packetInBuffer = true; - bufferTop = 0; - return checkMramPacketApid(); - } - - if (bufferTop == PLOC_SPV::MAX_PACKET_SIZE) { - *foundLen = remainingSize; - disableAllReplies(); - bufferTop = 0; - return MRAM_PACKET_PARSING_FAILURE; - } + for (size_t idx = 0; idx < remainingSize; idx++) { + std::memcpy(spacePacketBuffer + bufferTop, packet + idx, 1); + bufferTop += 1; + *foundLen += 1; + if (bufferTop >= PLOC_SPV::SPACE_PACKET_HEADER_LENGTH) { + packetLen = readSpacePacketLength(spacePacketBuffer); } - return result; + if (bufferTop == PLOC_SPV::SPACE_PACKET_HEADER_LENGTH + packetLen + 1) { + packetInBuffer = true; + bufferTop = 0; + return checkMramPacketApid(); + } + + if (bufferTop == PLOC_SPV::MAX_PACKET_SIZE) { + *foundLen = remainingSize; + disableAllReplies(); + bufferTop = 0; + return MRAM_PACKET_PARSING_FAILURE; + } + } + + return result; } ReturnValue_t PlocSupervisorHandler::handleMramDumpPacket(DeviceCommandId_t id) { + ReturnValue_t result = RETURN_FAILED; - ReturnValue_t result = RETURN_FAILED; - - // Prepare packet for downlink - if (packetInBuffer) { - uint16_t packetLen = readSpacePacketLength(spacePacketBuffer); - result = verifyPacket(spacePacketBuffer, PLOC_SPV::SPACE_PACKET_HEADER_LENGTH + packetLen + 1); - if (result != RETURN_OK) { - sif::warning << "PlocSupervisorHandler::handleMramDumpPacket: CRC failure" << std::endl; - return result; - } - handleMramDumpFile(id); - if (downlinkMramDump == true) { - handleDeviceTM(spacePacketBuffer + PLOC_SPV::SPACE_PACKET_HEADER_LENGTH, packetLen - 1, - id); - } - packetInBuffer = false; - receivedMramDumpPackets++; - if (expectedMramDumpPackets == receivedMramDumpPackets) { - nextReplyId = PLOC_SPV::EXE_REPORT; - } - increaseExpectedMramReplies(id); - return RETURN_OK; + // Prepare packet for downlink + if (packetInBuffer) { + uint16_t packetLen = readSpacePacketLength(spacePacketBuffer); + result = verifyPacket(spacePacketBuffer, PLOC_SPV::SPACE_PACKET_HEADER_LENGTH + packetLen + 1); + if (result != RETURN_OK) { + sif::warning << "PlocSupervisorHandler::handleMramDumpPacket: CRC failure" << std::endl; + return result; } - return result; + handleMramDumpFile(id); + if (downlinkMramDump == true) { + handleDeviceTM(spacePacketBuffer + PLOC_SPV::SPACE_PACKET_HEADER_LENGTH, packetLen - 1, id); + } + packetInBuffer = false; + receivedMramDumpPackets++; + if (expectedMramDumpPackets == receivedMramDumpPackets) { + nextReplyId = PLOC_SPV::EXE_REPORT; + } + increaseExpectedMramReplies(id); + return RETURN_OK; + } + return result; } void PlocSupervisorHandler::increaseExpectedMramReplies(DeviceCommandId_t id) { - DeviceReplyMap::iterator mramDumpIter = deviceReplyMap.find(id); - DeviceReplyMap::iterator exeReportIter = deviceReplyMap.find(PLOC_SPV::EXE_REPORT); - if (mramDumpIter == deviceReplyMap.end()) { - sif::debug << "PlocSupervisorHandler::increaseExpectedMramReplies: Dump MRAM reply not " - << "in reply map" << std::endl; - return; - } - if (exeReportIter == deviceReplyMap.end()) { - sif::debug << "PlocSupervisorHandler::increaseExpectedMramReplies: Execution report not " - << "in reply map" << std::endl; - return; - } - DeviceReplyInfo *mramReplyInfo = &(mramDumpIter->second); - if (mramReplyInfo == nullptr) { - sif::debug << "PlocSupervisorHandler::increaseExpectedReplies: MRAM reply info nullptr" - << std::endl; - return; - } - DeviceReplyInfo *exeReplyInfo = &(exeReportIter->second); - if (exeReplyInfo == nullptr) { - sif::debug << "PlocSupervisorHandler::increaseExpectedReplies: Execution reply info" - << " nullptr" << std::endl; - return; - } - DeviceCommandInfo* info = &(mramReplyInfo->command->second); - if (info == nullptr){ - sif::debug << "PlocSupervisorHandler::increaseExpectedReplies: Command info nullptr" - << std::endl; - return; - } - uint8_t sequenceFlags = spacePacketBuffer[2] >> 6; - if (sequenceFlags != static_cast(PLOC_SPV::SequenceFlags::LAST_PKT) - && (sequenceFlags != static_cast(PLOC_SPV::SequenceFlags::STANDALONE_PKT))) { - // Command expects at least one MRAM packet more and the execution report - info->expectedReplies = 2; - // Wait maximum of 2 cycles for next MRAM packet - mramReplyInfo->delayCycles = 2; - // Also adapting delay cycles for execution report - exeReplyInfo->delayCycles = 3; - } - else { - // Command expects the execution report - info->expectedReplies = 1; - mramReplyInfo->delayCycles = 0; - } + DeviceReplyMap::iterator mramDumpIter = deviceReplyMap.find(id); + DeviceReplyMap::iterator exeReportIter = deviceReplyMap.find(PLOC_SPV::EXE_REPORT); + if (mramDumpIter == deviceReplyMap.end()) { + sif::debug << "PlocSupervisorHandler::increaseExpectedMramReplies: Dump MRAM reply not " + << "in reply map" << std::endl; return; + } + if (exeReportIter == deviceReplyMap.end()) { + sif::debug << "PlocSupervisorHandler::increaseExpectedMramReplies: Execution report not " + << "in reply map" << std::endl; + return; + } + DeviceReplyInfo* mramReplyInfo = &(mramDumpIter->second); + if (mramReplyInfo == nullptr) { + sif::debug << "PlocSupervisorHandler::increaseExpectedReplies: MRAM reply info nullptr" + << std::endl; + return; + } + DeviceReplyInfo* exeReplyInfo = &(exeReportIter->second); + if (exeReplyInfo == nullptr) { + sif::debug << "PlocSupervisorHandler::increaseExpectedReplies: Execution reply info" + << " nullptr" << std::endl; + return; + } + DeviceCommandInfo* info = &(mramReplyInfo->command->second); + if (info == nullptr) { + sif::debug << "PlocSupervisorHandler::increaseExpectedReplies: Command info nullptr" + << std::endl; + return; + } + uint8_t sequenceFlags = spacePacketBuffer[2] >> 6; + if (sequenceFlags != static_cast(PLOC_SPV::SequenceFlags::LAST_PKT) && + (sequenceFlags != static_cast(PLOC_SPV::SequenceFlags::STANDALONE_PKT))) { + // Command expects at least one MRAM packet more and the execution report + info->expectedReplies = 2; + // Wait maximum of 2 cycles for next MRAM packet + mramReplyInfo->delayCycles = 2; + // Also adapting delay cycles for execution report + exeReplyInfo->delayCycles = 3; + } else { + // Command expects the execution report + info->expectedReplies = 1; + mramReplyInfo->delayCycles = 0; + } + return; } ReturnValue_t PlocSupervisorHandler::checkMramPacketApid() { - uint16_t apid = (spacePacketBuffer[0] << 8 | spacePacketBuffer[1]) & PLOC_SPV::APID_MASK; - if (apid != PLOC_SPV::APID_MRAM_DUMP_TM) { - return NO_MRAM_PACKET; - } - return APERIODIC_REPLY; + uint16_t apid = (spacePacketBuffer[0] << 8 | spacePacketBuffer[1]) & PLOC_SPV::APID_MASK; + if (apid != PLOC_SPV::APID_MRAM_DUMP_TM) { + return NO_MRAM_PACKET; + } + return APERIODIC_REPLY; } ReturnValue_t PlocSupervisorHandler::handleMramDumpFile(DeviceCommandId_t id) { - ReturnValue_t result = RETURN_OK; - uint16_t packetLen = readSpacePacketLength(spacePacketBuffer); - uint8_t sequenceFlags = readSequenceFlags(spacePacketBuffer); - if (id == PLOC_SPV::FIRST_MRAM_DUMP) { - if (sequenceFlags == static_cast(PLOC_SPV::SequenceFlags::FIRST_PKT) - || (sequenceFlags == static_cast(PLOC_SPV::SequenceFlags::STANDALONE_PKT))) { - result = createMramDumpFile(); - if (result != RETURN_OK) { - return result; - } - } + ReturnValue_t result = RETURN_OK; + uint16_t packetLen = readSpacePacketLength(spacePacketBuffer); + uint8_t sequenceFlags = readSequenceFlags(spacePacketBuffer); + if (id == PLOC_SPV::FIRST_MRAM_DUMP) { + if (sequenceFlags == static_cast(PLOC_SPV::SequenceFlags::FIRST_PKT) || + (sequenceFlags == static_cast(PLOC_SPV::SequenceFlags::STANDALONE_PKT))) { + result = createMramDumpFile(); + if (result != RETURN_OK) { + return result; + } } - if (not std::filesystem::exists(activeMramFile)) { - sif::warning << "PlocSupervisorHandler::handleMramDumpFile: MRAM file does not exist" - << std::endl; - return MRAM_FILE_NOT_EXISTS; - } - std::ofstream file(activeMramFile, std::ios_base::app | std::ios_base::out); - file.write( - reinterpret_cast(spacePacketBuffer + PLOC_SPV::SPACE_PACKET_HEADER_LENGTH), - packetLen - 1); - file.close(); - return RETURN_OK; + } + if (not std::filesystem::exists(activeMramFile)) { + sif::warning << "PlocSupervisorHandler::handleMramDumpFile: MRAM file does not exist" + << std::endl; + return MRAM_FILE_NOT_EXISTS; + } + std::ofstream file(activeMramFile, std::ios_base::app | std::ios_base::out); + file.write( + reinterpret_cast(spacePacketBuffer + PLOC_SPV::SPACE_PACKET_HEADER_LENGTH), + packetLen - 1); + file.close(); + return RETURN_OK; } uint16_t PlocSupervisorHandler::readSpacePacketLength(uint8_t* spacePacket) { - return spacePacket[4] << 8 | spacePacket[5]; + return spacePacket[4] << 8 | spacePacket[5]; } uint8_t PlocSupervisorHandler::readSequenceFlags(uint8_t* spacePacket) { - return spacePacketBuffer[2] >> 6; + return spacePacketBuffer[2] >> 6; } ReturnValue_t PlocSupervisorHandler::createMramDumpFile() { - ReturnValue_t result = RETURN_OK; - std::string timeStamp; - result = getTimeStampString(timeStamp); - if (result != RETURN_OK) { - return result; - } + ReturnValue_t result = RETURN_OK; + std::string timeStamp; + result = getTimeStampString(timeStamp); + if (result != RETURN_OK) { + return result; + } - std::string filename = "mram-dump--" + timeStamp + ".bin"; + std::string filename = "mram-dump--" + timeStamp + ".bin"; #if BOARD_TE0720 == 0 - std::string currentMountPrefix = sdcMan->getCurrentMountPrefix(); + std::string currentMountPrefix = sdcMan->getCurrentMountPrefix(); #else - std::string currentMountPrefix("/mnt/sd0"); + std::string currentMountPrefix("/mnt/sd0"); #endif /* BOARD_TE0720 == 0 */ - // Check if path to PLOC directory exists - if (not std::filesystem::exists(std::string(currentMountPrefix + "/" + plocFilePath))) { - sif::warning << "PlocSupervisorHandler::createMramDumpFile: Ploc path does not exist" - << std::endl; - return PATH_DOES_NOT_EXIST; - } - activeMramFile = currentMountPrefix + "/" + plocFilePath + "/" + filename; - // Create new file - std::ofstream file(activeMramFile, std::ios_base::out); - file.close(); + // Check if path to PLOC directory exists + if (not std::filesystem::exists(std::string(currentMountPrefix + "/" + plocFilePath))) { + sif::warning << "PlocSupervisorHandler::createMramDumpFile: Ploc path does not exist" + << std::endl; + return PATH_DOES_NOT_EXIST; + } + activeMramFile = currentMountPrefix + "/" + plocFilePath + "/" + filename; + // Create new file + std::ofstream file(activeMramFile, std::ios_base::out); + file.close(); - return RETURN_OK; + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::getTimeStampString(std::string& timeStamp) { - Clock::TimeOfDay_t time; - ReturnValue_t result = Clock::getDateAndTime(&time); - if (result != RETURN_OK) { - sif::warning << "PlocSupervisorHandler::createMramDumpFile: Failed to get current time" - << std::endl; - return GET_TIME_FAILURE; - } - timeStamp = std::to_string(time.year) + "-" + std::to_string(time.month) + "-" - + std::to_string(time.day) + "--" + std::to_string(time.hour) + "-" - + std::to_string(time.minute) + "-" + std::to_string(time.second); - return RETURN_OK; + Clock::TimeOfDay_t time; + ReturnValue_t result = Clock::getDateAndTime(&time); + if (result != RETURN_OK) { + sif::warning << "PlocSupervisorHandler::createMramDumpFile: Failed to get current time" + << std::endl; + return GET_TIME_FAILURE; + } + timeStamp = std::to_string(time.year) + "-" + std::to_string(time.month) + "-" + + std::to_string(time.day) + "--" + std::to_string(time.hour) + "-" + + std::to_string(time.minute) + "-" + std::to_string(time.second); + return RETURN_OK; } diff --git a/bsp_q7s/devices/PlocSupervisorHandler.h b/bsp_q7s/devices/PlocSupervisorHandler.h index f22c86b1..986e5bbb 100644 --- a/bsp_q7s/devices/PlocSupervisorHandler.h +++ b/bsp_q7s/devices/PlocSupervisorHandler.h @@ -1,12 +1,12 @@ #ifndef MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_ #define MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_ -#include "devicedefinitions/PlocSupervisorDefinitions.h" #include - #include #include +#include "devicedefinitions/PlocSupervisorDefinitions.h" + /** * @brief This is the device handler for the supervisor of the PLOC which is programmed by * Thales. @@ -19,324 +19,327 @@ * Arbeitsdaten/08_Used%20Components/PLOC&fileid=940960 * @author J. Meier */ -class PlocSupervisorHandler: public DeviceHandlerBase { -public: +class PlocSupervisorHandler : public DeviceHandlerBase { + 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 ~PlocSupervisorHandler(); + virtual ReturnValue_t initialize() override; - 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: - void doStartUp() override; - void doShutDown() override; - ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; - ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override; - void fillCommandAndReplyMap() override; - ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t * commandData,size_t commandDataLen) override; - ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize, - DeviceCommandId_t *foundId, size_t *foundLen) override; - ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) override; - void setNormalDatapoolEntriesInvalid() override; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; - ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator command, - uint8_t expectedReplies = 1, bool useAlternateId = false, - DeviceCommandId_t alternateReplyID = 0) override; - size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_SUPERVISOR_HANDLER; -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] Invalid communication interface specified + static const ReturnValue_t INVALID_UART_COM_IF = MAKE_RETURN_CODE(0xA5); + //! [EXPORT] : [COMMENT] Received command with invalid watchdog parameter. Valid watchdogs are 0 + //! for PS, 1 for PL and 2 for INT + static const ReturnValue_t INVALID_WATCHDOG = MAKE_RETURN_CODE(0xA6); + //! [EXPORT] : [COMMENT] Received watchdog timeout config command with invalid timeout. Valid + //! timeouts must be in the range between 1000 and 360000 ms. + static const ReturnValue_t INVALID_WATCHDOG_TIMEOUT = MAKE_RETURN_CODE(0xA7); + //! [EXPORT] : [COMMENT] Received latchup config command with invalid latchup ID + static const ReturnValue_t INVALID_LATCHUP_ID = MAKE_RETURN_CODE(0xA8); + //! [EXPORT] : [COMMENT] Received set adc sweep period command with invalid sweep period. Must be + //! larger than 21. + static const ReturnValue_t SWEEP_PERIOD_TOO_SMALL = MAKE_RETURN_CODE(0xA9); + //! [EXPORT] : [COMMENT] Receive auto EM test command with invalid test param. Valid params are 1 + //! and 2. + static const ReturnValue_t INVALID_TEST_PARAM = MAKE_RETURN_CODE(0xAA); + //! [EXPORT] : [COMMENT] Returned when scanning for MRAM dump packets failed. + static const ReturnValue_t MRAM_PACKET_PARSING_FAILURE = MAKE_RETURN_CODE(0xAB); + //! [EXPORT] : [COMMENT] Returned when the start and stop addresses of the MRAM dump or MRAM wipe + //! commands are invalid (e.g. start address bigger than stop address) + static const ReturnValue_t INVALID_MRAM_ADDRESSES = MAKE_RETURN_CODE(0xAC); + //! [EXPORT] : [COMMENT] Expect reception of an MRAM dump packet but received space packet with + //! other apid. + static const ReturnValue_t NO_MRAM_PACKET = MAKE_RETURN_CODE(0xAD); + //! [EXPORT] : [COMMENT] Path to PLOC directory on SD card does not exist + static const ReturnValue_t PATH_DOES_NOT_EXIST = MAKE_RETURN_CODE(0xAE); + //! [EXPORT] : [COMMENT] MRAM dump file does not exists. The file should actually already have + //! been created with the reception of the first dump packet. + static const ReturnValue_t MRAM_FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xAF); - static 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 - 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] Invalid communication interface specified - static const ReturnValue_t INVALID_UART_COM_IF = MAKE_RETURN_CODE(0xA5); - //! [EXPORT] : [COMMENT] Received command with invalid watchdog parameter. Valid watchdogs are 0 for PS, 1 for PL and 2 for INT - static const ReturnValue_t INVALID_WATCHDOG = MAKE_RETURN_CODE(0xA6); - //! [EXPORT] : [COMMENT] Received watchdog timeout config command with invalid timeout. Valid timeouts must be in the range between 1000 and 360000 ms. - static const ReturnValue_t INVALID_WATCHDOG_TIMEOUT = MAKE_RETURN_CODE(0xA7); - //! [EXPORT] : [COMMENT] Received latchup config command with invalid latchup ID - static const ReturnValue_t INVALID_LATCHUP_ID = MAKE_RETURN_CODE(0xA8); - //! [EXPORT] : [COMMENT] Received set adc sweep period command with invalid sweep period. Must be larger than 21. - static const ReturnValue_t SWEEP_PERIOD_TOO_SMALL = MAKE_RETURN_CODE(0xA9); - //! [EXPORT] : [COMMENT] Receive auto EM test command with invalid test param. Valid params are 1 and 2. - static const ReturnValue_t INVALID_TEST_PARAM = MAKE_RETURN_CODE(0xAA); - //! [EXPORT] : [COMMENT] Returned when scanning for MRAM dump packets failed. - static const ReturnValue_t MRAM_PACKET_PARSING_FAILURE = MAKE_RETURN_CODE(0xAB); - //! [EXPORT] : [COMMENT] Returned when the start and stop addresses of the MRAM dump or MRAM wipe commands are invalid (e.g. start address bigger than stop address) - static const ReturnValue_t INVALID_MRAM_ADDRESSES = MAKE_RETURN_CODE(0xAC); - //! [EXPORT] : [COMMENT] Expect reception of an MRAM dump packet but received space packet with other apid. - static const ReturnValue_t NO_MRAM_PACKET = MAKE_RETURN_CODE(0xAD); - //! [EXPORT] : [COMMENT] Path to PLOC directory on SD card does not exist - static const ReturnValue_t PATH_DOES_NOT_EXIST = MAKE_RETURN_CODE(0xAE); - //! [EXPORT] : [COMMENT] MRAM dump file does not exists. The file should actually already have been created with the reception of the first dump packet. - static const ReturnValue_t MRAM_FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xAF); + //! [EXPORT] : [COMMENT] PLOC supervisor crc failure in telemetry packet + static const Event SUPV_MEMORY_READ_RPT_CRC_FAILURE = MAKE_EVENT(1, severity::LOW); + //! [EXPORT] : [COMMENT] 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 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 - 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); + uint8_t commandBuffer[PLOC_SPV::MAX_COMMAND_SIZE]; - 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; - /** - * This variable is used to store the id of the next reply to receive. This is necessary - * because the PLOC sends as reply to each command at least one acknowledgment and execution - * report. - */ - DeviceCommandId_t nextReplyId = PLOC_SPV::NONE; + PLOC_SPV::HkSet hkset; + PLOC_SPV::BootStatusReport bootStatusReport; + PLOC_SPV::LatchupStatusReport latchupStatusReport; - 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; - PLOC_SPV::BootStatusReport bootStatusReport; - 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]; + /** This buffer is used to concatenate space packets received in two different read steps */ + uint8_t spacePacketBuffer[PLOC_SPV::MAX_PACKET_SIZE]; #if BOARD_TE0720 == 0 - SdCardManager* sdcMan = nullptr; + SdCardManager* sdcMan = nullptr; #endif /* BOARD_TE0720 == 0 */ - /** Path to PLOC specific files on SD card */ - std::string plocFilePath = "ploc"; - std::string activeMramFile; + /** Path to PLOC specific files on SD card */ + std::string plocFilePath = "ploc"; + std::string activeMramFile; - /** Setting this variable to true will enable direct downlink of MRAM packets */ - bool downlinkMramDump = false; + /** Setting this variable to true will enable direct downlink of MRAM packets */ + bool downlinkMramDump = false; - /** - * @brief This function checks the crc of the received PLOC reply. - * - * @param start Pointer to the first byte of the reply. - * @param foundLen Pointer to the length of the whole packet. - * - * @return RETURN_OK if CRC is ok, otherwise CRC_FAILURE. - */ - ReturnValue_t verifyPacket(const uint8_t* start, size_t foundLen); + /** + * @brief This function checks the crc of the received PLOC reply. + * + * @param start Pointer to the first byte of the reply. + * @param foundLen Pointer to the length of the whole packet. + * + * @return RETURN_OK if CRC is ok, otherwise CRC_FAILURE. + */ + ReturnValue_t verifyPacket(const uint8_t* start, size_t foundLen); - /** - * @brief This function handles the acknowledgment report. - * - * @param data Pointer to the data holding the acknowledgment report. - * - * @return RETURN_OK if successful, otherwise an error code. - */ - ReturnValue_t handleAckReport(const uint8_t* data); + /** + * @brief This function handles the acknowledgment report. + * + * @param data Pointer to the data holding the acknowledgment report. + * + * @return RETURN_OK if successful, otherwise an error code. + */ + ReturnValue_t handleAckReport(const uint8_t* data); - /** - * @brief This function handles the data of a execution report. - * - * @param data Pointer to the received data packet. - * - * @return RETURN_OK if successful, otherwise an error code. - */ - ReturnValue_t handleExecutionReport(const uint8_t* data); + /** + * @brief This function handles the data of a execution report. + * + * @param data Pointer to the received data packet. + * + * @return RETURN_OK if successful, otherwise an error code. + */ + ReturnValue_t handleExecutionReport(const uint8_t* data); - /** - * @brief This function handles the housekeeping report. This means verifying the CRC of the - * reply and filling the appropriate dataset. - * - * @param data Pointer to the data buffer holding the housekeeping read report. - * - * @return RETURN_OK if successful, otherwise an error code. - */ - ReturnValue_t handleHkReport(const uint8_t* data); + /** + * @brief This function handles the housekeeping report. This means verifying the CRC of the + * reply and filling the appropriate dataset. + * + * @param data Pointer to the data buffer holding the housekeeping read report. + * + * @return RETURN_OK if successful, otherwise an error code. + */ + ReturnValue_t handleHkReport(const uint8_t* data); - /** - * @brief 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. - */ - ReturnValue_t handleBootStatusReport(const uint8_t* data); + /** + * @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. + */ + 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 - * next reply after a successful acknowledgment report has been received. This is - * required by the function getNextReplyLength() to identify the length of the next - * reply to read. - */ - void setNextReplyId(); + /** + * @brief Depending on the current active command, this function sets the reply id of the + * next reply after a successful acknowledgment report has been received. This is + * required by the function getNextReplyLength() to identify the length of the next + * reply to read. + */ + void setNextReplyId(); - /** - * @brief This function handles action message replies in case the telemetry has been - * requested by another object. - * - * @param data Pointer to the telemetry data. - * @param dataSize Size of telemetry in bytes. - * @param replyId Id of the reply. This will be added to the ActionMessage. - */ - void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); + /** + * @brief This function handles action message replies in case the telemetry has been + * requested by another object. + * + * @param data Pointer to the telemetry data. + * @param dataSize Size of telemetry in bytes. + * @param replyId Id of the reply. This will be added to the ActionMessage. + */ + void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); - /** - * @brief This function prepares a space packet which does not transport any data in the - * packet data field apart from the crc. - */ - void prepareEmptyCmd(uint16_t apid); + /** + * @brief This function prepares a space packet which does not transport any data in the + * packet data field apart from the crc. + */ + void prepareEmptyCmd(uint16_t apid); - /** - * @brief This function initializes the space packet to select the boot image of the MPSoC. - */ - void prepareSelBootImageCmd(const uint8_t * commandData); + /** + * @brief This function initializes the space packet to select the boot image of the MPSoC. + */ + 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 - * PLOC supervisor. - */ - ReturnValue_t prepareSetTimeRefCmd(); + /** + * @brief This function fills the commandBuffer with the data to update the time of the + * PLOC supervisor. + */ + ReturnValue_t prepareSetTimeRefCmd(); - /** - * @brief This function fills the commandBuffer with the data to change the boot timeout - * value in the PLOC supervisor. - */ - void prepareSetBootTimeoutCmd(const uint8_t * commandData); + /** + * @brief This function fills the commandBuffer with the data to change the boot timeout + * value in the PLOC supervisor. + */ + 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 - * watchdogs on the PLOC. - */ - void prepareWatchdogsEnableCmd(const uint8_t * commandData); + /** + * @brief This function fills the command buffer with the packet to enable or disable the + * watchdogs on the PLOC. + */ + void prepareWatchdogsEnableCmd(const uint8_t* commandData); - /** - * @brief This function fills the command buffer with the packet to set the watchdog timer - * of one of the three watchdogs (PS, PL, INT). - */ - ReturnValue_t prepareWatchdogsConfigTimeoutCmd(const uint8_t * commandData); + /** + * @brief This function fills the command buffer with the packet to set the watchdog timer + * of one of the three watchdogs (PS, PL, INT). + */ + ReturnValue_t prepareWatchdogsConfigTimeoutCmd(const uint8_t* commandData); - ReturnValue_t prepareLatchupConfigCmd(const uint8_t* commandData, - DeviceCommandId_t deviceCommand); - ReturnValue_t prepareAutoCalibrateAlertCmd(const uint8_t* commandData); - ReturnValue_t prepareSetAlertLimitCmd(const uint8_t* commandData); - ReturnValue_t prepareSetAlertIrqFilterCmd(const uint8_t* commandData); - ReturnValue_t prepareSetAdcSweetPeriodCmd(const uint8_t* commandData); - void prepareSetAdcEnabledChannelsCmd(const uint8_t* commandData); - void prepareSetAdcWindowAndStrideCmd(const uint8_t* commandData); - void prepareSetAdcThresholdCmd(const uint8_t* commandData); - void prepareEnableNvmsCmd(const uint8_t* commandData); - void prepareSelectNvmCmd(const uint8_t* commandData); - ReturnValue_t prepareRunAutoEmTest(const uint8_t* commandData); - ReturnValue_t prepareWipeMramCmd(const uint8_t* commandData); - ReturnValue_t prepareDumpMramCmd(const uint8_t* commandData); - void preparePrintCpuStatsCmd(const uint8_t* commandData); - void prepareSetDbgVerbosityCmd(const uint8_t* commandData); - void prepareSetGpioCmd(const uint8_t* commandData); - void prepareReadGpioCmd(const uint8_t* commandData); + ReturnValue_t prepareLatchupConfigCmd(const uint8_t* commandData, + DeviceCommandId_t deviceCommand); + ReturnValue_t prepareAutoCalibrateAlertCmd(const uint8_t* commandData); + ReturnValue_t prepareSetAlertLimitCmd(const uint8_t* commandData); + ReturnValue_t prepareSetAlertIrqFilterCmd(const uint8_t* commandData); + ReturnValue_t prepareSetAdcSweetPeriodCmd(const uint8_t* commandData); + void prepareSetAdcEnabledChannelsCmd(const uint8_t* commandData); + void prepareSetAdcWindowAndStrideCmd(const uint8_t* commandData); + void prepareSetAdcThresholdCmd(const uint8_t* commandData); + void prepareEnableNvmsCmd(const uint8_t* commandData); + void prepareSelectNvmCmd(const uint8_t* commandData); + ReturnValue_t prepareRunAutoEmTest(const uint8_t* commandData); + ReturnValue_t prepareWipeMramCmd(const uint8_t* commandData); + ReturnValue_t prepareDumpMramCmd(const uint8_t* commandData); + void preparePrintCpuStatsCmd(const uint8_t* commandData); + void prepareSetDbgVerbosityCmd(const uint8_t* commandData); + void prepareSetGpioCmd(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. - */ - void packetToOutBuffer(uint8_t* packetData, size_t fullSize); + /** + * @brief In case an acknowledgment failure reply has been received this function disables + * all previously enabled commands and resets the exepected replies variable of an + * active command. + */ + void disableAllReplies(); - /** - * @brief In case an acknowledgment failure reply has been received this function disables - * all previously enabled commands and resets the exepected replies variable of an - * active command. - */ - void disableAllReplies(); + /** + * @brief This function sends a failure report if the active action was commanded by an other + * object. + * + * @param replyId The id of the reply which signals a failure. + * @param status A status byte which gives information about the failure type. + */ + void sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status); - /** - * @brief This function sends a failure report if the active action was commanded by an other - * object. - * - * @param replyId The id of the reply which signals a failure. - * @param status A status byte which gives information about the failure type. - */ - void sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status); + /** + * @brief This function disables the execution report reply. Within this function also the + * the variable expectedReplies of an active command will be set to 0. + */ + void disableExeReportReply(); - /** - * @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(); + /** + * @brief Function is called in scanForReply and fills the spacePacketBuffer with the read + * data until a full packet has been received. + */ + 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 - * data until a full packet has been received. - */ - 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. + */ + ReturnValue_t handleMramDumpPacket(DeviceCommandId_t id); - /** - * @brief This function generates the Service 8 packets for the MRAM dump data. - */ - ReturnValue_t handleMramDumpPacket(DeviceCommandId_t id); + /** + * @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 + * have been received. + */ + void increaseExpectedMramReplies(DeviceCommandId_t id); - /** - * @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 - * have been received. - */ - void increaseExpectedMramReplies(DeviceCommandId_t id); + /** + * @brief Function checks if the packet written to the space packet buffer is really a + * MRAM dump packet. + */ + ReturnValue_t checkMramPacketApid(); - /** - * @brief Function checks if the packet written to the space packet buffer is really a - * MRAM dump packet. - */ - ReturnValue_t checkMramPacketApid(); + /** + * @brief Writes the data of the MRAM dump to a file. The file will be created when receiving + * the first packet. + */ + ReturnValue_t handleMramDumpFile(DeviceCommandId_t id); - /** - * @brief Writes the data of the MRAM dump to a file. The file will be created when receiving - * the first packet. - */ - ReturnValue_t handleMramDumpFile(DeviceCommandId_t id); + /** + * @brief Extracts the length field of a spacePacket referenced by the spacePacket pointer. + * + * @param spacePacket Pointer to the buffer holding the space packet. + * + * @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. - * - * @param spacePacket Pointer to the buffer holding the space packet. - * - * @return The value stored in the length field of the data field. - */ - uint16_t readSpacePacketLength(uint8_t* spacePacket); + /** + * @brief Extracts the sequence flags from a space packet referenced by the spacePacket + * 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); - /** - * @brief Extracts the sequence flags from a space packet referenced by the spacePacket - * 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); + ReturnValue_t createMramDumpFile(); + ReturnValue_t getTimeStampString(std::string& timeStamp); }; #endif /* MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_ */ diff --git a/bsp_q7s/devices/PlocUpdater.cpp b/bsp_q7s/devices/PlocUpdater.cpp index 592a2c0d..1478fbb8 100644 --- a/bsp_q7s/devices/PlocUpdater.cpp +++ b/bsp_q7s/devices/PlocUpdater.cpp @@ -1,405 +1,393 @@ -#include "fsfw/ipc/QueueFactory.h" #include "PlocUpdater.h" -#include #include +#include #include -PlocUpdater::PlocUpdater(object_id_t objectId) : - SystemObject(objectId), commandActionHelper(this), actionHelper(this, nullptr) { - commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); +#include "fsfw/ipc/QueueFactory.h" + +PlocUpdater::PlocUpdater(object_id_t objectId) + : SystemObject(objectId), commandActionHelper(this), actionHelper(this, nullptr) { + commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); } -PlocUpdater::~PlocUpdater() { -} +PlocUpdater::~PlocUpdater() {} ReturnValue_t PlocUpdater::initialize() { #if BOARD_TE0720 == 0 - sdcMan = SdCardManager::instance(); + sdcMan = SdCardManager::instance(); #endif - ReturnValue_t result = SystemObject::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - result = commandActionHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - result = actionHelper.initialize(commandQueue); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + ReturnValue_t result = SystemObject::initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = commandActionHelper.initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = actionHelper.initialize(commandQueue); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t PlocUpdater::performOperation(uint8_t operationCode) { - readCommandQueue(); - doStateMachine(); - return HasReturnvaluesIF::RETURN_OK; + readCommandQueue(); + doStateMachine(); + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t PlocUpdater::executeAction(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { - ReturnValue_t result = RETURN_FAILED; +ReturnValue_t PlocUpdater::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) { + ReturnValue_t result = RETURN_FAILED; - if (state != State::IDLE) { - return IS_BUSY; - } + if (state != State::IDLE) { + return IS_BUSY; + } - if (size > MAX_PLOC_UPDATE_PATH) { - return NAME_TOO_LONG; - } + if (size > MAX_PLOC_UPDATE_PATH) { + return NAME_TOO_LONG; + } - switch (actionId) { + switch (actionId) { case UPDATE_A_UBOOT: - image = Image::A; - partition = Partition::UBOOT; - break; + image = Image::A; + partition = Partition::UBOOT; + break; case UPDATE_A_BITSTREAM: - image = Image::A; - partition = Partition::BITSTREAM; - break; + image = Image::A; + partition = Partition::BITSTREAM; + break; case UPDATE_A_LINUX: - image = Image::A; - partition = Partition::LINUX_OS; - break; + image = Image::A; + partition = Partition::LINUX_OS; + break; case UPDATE_A_APP_SW: - image = Image::A; - partition = Partition::APP_SW; - break; + image = Image::A; + partition = Partition::APP_SW; + break; case UPDATE_B_UBOOT: - image = Image::B; - partition = Partition::UBOOT; - break; + image = Image::B; + partition = Partition::UBOOT; + break; case UPDATE_B_BITSTREAM: - image = Image::B; - partition = Partition::BITSTREAM; - break; + image = Image::B; + partition = Partition::BITSTREAM; + break; case UPDATE_B_LINUX: - image = Image::B; - partition = Partition::LINUX_OS; - break; + image = Image::B; + partition = Partition::LINUX_OS; + break; case UPDATE_B_APP_SW: - image = Image::B; - partition = Partition::APP_SW; - break; + image = Image::B; + partition = Partition::APP_SW; + break; default: - return INVALID_ACTION_ID; - } + return INVALID_ACTION_ID; + } - result = getImageLocation(data, size); + result = getImageLocation(data, size); - if (result != RETURN_OK) { - return result; - } + if (result != RETURN_OK) { + return result; + } - state = State::UPDATE_AVAILABLE; + state = State::UPDATE_AVAILABLE; - return EXECUTION_FINISHED; + return EXECUTION_FINISHED; } -MessageQueueId_t PlocUpdater::getCommandQueue() const { - return commandQueue->getId(); -} +MessageQueueId_t PlocUpdater::getCommandQueue() const { return commandQueue->getId(); } -MessageQueueIF* PlocUpdater::getCommandQueuePtr() { - return commandQueue; -} +MessageQueueIF* PlocUpdater::getCommandQueuePtr() { return commandQueue; } void PlocUpdater::readCommandQueue() { - CommandMessage message; - ReturnValue_t result; + CommandMessage message; + ReturnValue_t result; - for (result = commandQueue->receiveMessage(&message); result == HasReturnvaluesIF::RETURN_OK; - result = commandQueue->receiveMessage(&message)) { - if (result != RETURN_OK) { - continue; - } - result = actionHelper.handleActionMessage(&message); - if (result == HasReturnvaluesIF::RETURN_OK) { - continue; - } - - result = commandActionHelper.handleReply(&message); - if (result == HasReturnvaluesIF::RETURN_OK) { - continue; - } - - sif::debug << "PlocUpdater::readCommandQueue: Received message with invalid format" - << std::endl; + for (result = commandQueue->receiveMessage(&message); result == HasReturnvaluesIF::RETURN_OK; + result = commandQueue->receiveMessage(&message)) { + if (result != RETURN_OK) { + continue; } + result = actionHelper.handleActionMessage(&message); + if (result == HasReturnvaluesIF::RETURN_OK) { + continue; + } + + result = commandActionHelper.handleReply(&message); + if (result == HasReturnvaluesIF::RETURN_OK) { + continue; + } + + sif::debug << "PlocUpdater::readCommandQueue: Received message with invalid format" + << std::endl; + } } void PlocUpdater::doStateMachine() { - switch (state) { + switch (state) { case State::IDLE: - break; + break; case State::UPDATE_AVAILABLE: - commandUpdateAvailable(); - break; + commandUpdateAvailable(); + break; case State::UPDATE_TRANSFER: - commandUpdatePacket(); - break; + commandUpdatePacket(); + break; case State::UPDATE_VERIFY: - commandUpdateVerify(); - break; + commandUpdateVerify(); + break; case State::COMMAND_EXECUTING: - break; + break; default: - sif::debug << "PlocUpdater::doStateMachine: Invalid state" << std::endl; - break; - } + sif::debug << "PlocUpdater::doStateMachine: Invalid state" << std::endl; + break; + } } ReturnValue_t PlocUpdater::checkNameLength(size_t size) { - if (size > MAX_PLOC_UPDATE_PATH) { - return NAME_TOO_LONG; - } - return RETURN_OK; + if (size > MAX_PLOC_UPDATE_PATH) { + return NAME_TOO_LONG; + } + return RETURN_OK; } ReturnValue_t PlocUpdater::getImageLocation(const uint8_t* data, size_t size) { - ReturnValue_t result = checkNameLength(size); - if (result != RETURN_OK) { - return result; - } + ReturnValue_t result = checkNameLength(size); + if (result != RETURN_OK) { + return result; + } #if BOARD_TE0720 == 0 - // Check if file is stored on SD card and if associated SD card is mounted - if (std::string(reinterpret_cast(data), SD_PREFIX_LENGTH) == std::string(SdCardManager::SD_0_MOUNT_POINT)) { - if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { - sif::warning << "PlocUpdater::getImageLocation: SD card 0 not mounted" << std::endl; - return SD_NOT_MOUNTED; - } + // Check if file is stored on SD card and if associated SD card is mounted + if (std::string(reinterpret_cast(data), SD_PREFIX_LENGTH) == + std::string(SdCardManager::SD_0_MOUNT_POINT)) { + if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { + sif::warning << "PlocUpdater::getImageLocation: SD card 0 not mounted" << std::endl; + return SD_NOT_MOUNTED; } - else if (std::string(reinterpret_cast(data), SD_PREFIX_LENGTH) == std::string(SdCardManager::SD_1_MOUNT_POINT)) { - if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { - sif::warning << "PlocUpdater::getImageLocation: SD card 1 not mounted" << std::endl; - return SD_NOT_MOUNTED; - } - } - else { - //update image not stored on SD card + } else if (std::string(reinterpret_cast(data), SD_PREFIX_LENGTH) == + std::string(SdCardManager::SD_1_MOUNT_POINT)) { + if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { + sif::warning << "PlocUpdater::getImageLocation: SD card 1 not mounted" << std::endl; + return SD_NOT_MOUNTED; } + } else { + // update image not stored on SD card + } #endif /* BOARD_TE0720 == 0 */ - updateFile = std::string(reinterpret_cast(data), size); + updateFile = std::string(reinterpret_cast(data), size); - // Check if file exists - if(not std::filesystem::exists(updateFile)) { - return FILE_NOT_EXISTS; - } - return RETURN_OK; + // Check if file exists + if (not std::filesystem::exists(updateFile)) { + return FILE_NOT_EXISTS; + } + return RETURN_OK; } -void PlocUpdater::stepSuccessfulReceived(ActionId_t actionId, - uint8_t step) { -} +void PlocUpdater::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) {} -void PlocUpdater::stepFailedReceived(ActionId_t actionId, uint8_t step, - ReturnValue_t returnCode) { -} +void PlocUpdater::stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) {} -void PlocUpdater::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) { - -} +void PlocUpdater::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) {} void PlocUpdater::completionSuccessfulReceived(ActionId_t actionId) { - switch (pendingCommand) { + switch (pendingCommand) { case (PLOC_SPV::UPDATE_AVAILABLE): - state = State::UPDATE_TRANSFER; - break; + state = State::UPDATE_TRANSFER; + break; case (PLOC_SPV::UPDATE_IMAGE_DATA): - if (remainingPackets == 0) { - packetsSent = 0; // Reset packets sent variable for next update sequence - state = State::UPDATE_VERIFY; - } - else { - state = State::UPDATE_TRANSFER; - } - break; + if (remainingPackets == 0) { + packetsSent = 0; // Reset packets sent variable for next update sequence + state = State::UPDATE_VERIFY; + } else { + state = State::UPDATE_TRANSFER; + } + break; case (PLOC_SPV::UPDATE_VERIFY): - triggerEvent(UPDATE_FINISHED); - state = State::IDLE; - pendingCommand = PLOC_SPV::NONE; - break; + triggerEvent(UPDATE_FINISHED); + state = State::IDLE; + pendingCommand = PLOC_SPV::NONE; + break; default: - sif::debug << "PlocUpdater::completionSuccessfulReceived: Invalid pending command" - << std::endl; - state = State::IDLE; - break; - } + sif::debug << "PlocUpdater::completionSuccessfulReceived: Invalid pending command" + << std::endl; + state = State::IDLE; + break; + } } -void PlocUpdater::completionFailedReceived(ActionId_t actionId, - ReturnValue_t returnCode) { - switch(pendingCommand) { - case(PLOC_SPV::UPDATE_AVAILABLE): { - triggerEvent(UPDATE_AVAILABLE_FAILED); - break; +void PlocUpdater::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) { + switch (pendingCommand) { + case (PLOC_SPV::UPDATE_AVAILABLE): { + triggerEvent(UPDATE_AVAILABLE_FAILED); + break; } - case(PLOC_SPV::UPDATE_IMAGE_DATA): { - triggerEvent(UPDATE_TRANSFER_FAILED, packetsSent); - break; + case (PLOC_SPV::UPDATE_IMAGE_DATA): { + triggerEvent(UPDATE_TRANSFER_FAILED, packetsSent); + break; } - case(PLOC_SPV::UPDATE_VERIFY): { - triggerEvent(UPDATE_VERIFY_FAILED); - break; + case (PLOC_SPV::UPDATE_VERIFY): { + triggerEvent(UPDATE_VERIFY_FAILED); + break; } default: - sif::debug << "PlocUpdater::completionFailedReceived: Invalid pending command " - << std::endl; - break; - } - state = State::IDLE; + sif::debug << "PlocUpdater::completionFailedReceived: Invalid pending command " << std::endl; + break; + } + state = State::IDLE; } void PlocUpdater::commandUpdateAvailable() { - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = RETURN_OK; - if (not std::filesystem::exists(updateFile)) { - triggerEvent(UPDATE_FILE_NOT_EXISTS, static_cast(state)); - state = State::IDLE; - return; - } - - std::ifstream file(updateFile, std::ifstream::binary); - file.seekg(0, file.end); - imageSize = static_cast(file.tellg()); - file.close(); - - numOfUpdatePackets = imageSize / MAX_SP_DATA ; - if (imageSize % MAX_SP_DATA) { - numOfUpdatePackets++; - } - - remainingPackets = numOfUpdatePackets; - packetsSent = 0; - - calcImageCrc(); - - PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_AVAILABLE, static_cast(image), - static_cast(partition), imageSize, imageCrc, numOfUpdatePackets); - - result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, - PLOC_SPV::UPDATE_AVAILABLE, packet.getWholeData(), packet.getFullSize()); - if (result != RETURN_OK) { - sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update available" - << " packet to supervisor handler" << std::endl; - triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_AVAILABLE); - state = State::IDLE; - pendingCommand = PLOC_SPV::NONE; - return; - } - - pendingCommand = PLOC_SPV::UPDATE_AVAILABLE; - state = State::COMMAND_EXECUTING; + if (not std::filesystem::exists(updateFile)) { + triggerEvent(UPDATE_FILE_NOT_EXISTS, static_cast(state)); + state = State::IDLE; return; + } + + std::ifstream file(updateFile, std::ifstream::binary); + file.seekg(0, file.end); + imageSize = static_cast(file.tellg()); + file.close(); + + numOfUpdatePackets = imageSize / MAX_SP_DATA; + if (imageSize % MAX_SP_DATA) { + numOfUpdatePackets++; + } + + remainingPackets = numOfUpdatePackets; + packetsSent = 0; + + calcImageCrc(); + + PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_AVAILABLE, static_cast(image), + static_cast(partition), imageSize, imageCrc, + numOfUpdatePackets); + + result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, + PLOC_SPV::UPDATE_AVAILABLE, packet.getWholeData(), + packet.getFullSize()); + if (result != RETURN_OK) { + sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update available" + << " packet to supervisor handler" << std::endl; + triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_AVAILABLE); + state = State::IDLE; + pendingCommand = PLOC_SPV::NONE; + return; + } + + pendingCommand = PLOC_SPV::UPDATE_AVAILABLE; + state = State::COMMAND_EXECUTING; + return; } void PlocUpdater::commandUpdatePacket() { - ReturnValue_t result = RETURN_OK; - uint16_t payloadLength = 0; + ReturnValue_t result = RETURN_OK; + uint16_t payloadLength = 0; - if (not std::filesystem::exists(updateFile)) { - triggerEvent(UPDATE_FILE_NOT_EXISTS, static_cast(state), packetsSent); - state = State::IDLE; - return; - } + if (not std::filesystem::exists(updateFile)) { + triggerEvent(UPDATE_FILE_NOT_EXISTS, static_cast(state), packetsSent); + state = State::IDLE; + return; + } - std::ifstream file(updateFile, std::ifstream::binary); - file.seekg(packetsSent * MAX_SP_DATA, file.beg); + std::ifstream file(updateFile, std::ifstream::binary); + file.seekg(packetsSent * MAX_SP_DATA, file.beg); - if (remainingPackets == 1) { - payloadLength = imageSize - static_cast(file.tellg()); - } - else { - payloadLength = MAX_SP_DATA; - } + if (remainingPackets == 1) { + payloadLength = imageSize - static_cast(file.tellg()); + } else { + payloadLength = MAX_SP_DATA; + } - PLOC_SPV::UpdatePacket packet(payloadLength); - file.read(reinterpret_cast(packet.getDataFieldPointer()), payloadLength); - file.close(); - // sequence count of first packet is 1 - packet.setPacketSequenceCount((packetsSent + 1) & PLOC_SPV::SEQUENCE_COUNT_MASK); - if (numOfUpdatePackets > 1) { - adjustSequenceFlags(packet); - } - packet.makeCrc(); + PLOC_SPV::UpdatePacket packet(payloadLength); + file.read(reinterpret_cast(packet.getDataFieldPointer()), payloadLength); + file.close(); + // sequence count of first packet is 1 + packet.setPacketSequenceCount((packetsSent + 1) & PLOC_SPV::SEQUENCE_COUNT_MASK); + if (numOfUpdatePackets > 1) { + adjustSequenceFlags(packet); + } + packet.makeCrc(); - result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, - PLOC_SPV::UPDATE_IMAGE_DATA, packet.getWholeData(), packet.getFullSize()); + result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, + PLOC_SPV::UPDATE_IMAGE_DATA, packet.getWholeData(), + packet.getFullSize()); - if (result != RETURN_OK) { - sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update" - << " packet to supervisor handler" << std::endl; - triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_IMAGE_DATA); - state = State::IDLE; - pendingCommand = PLOC_SPV::NONE; - return; - } + if (result != RETURN_OK) { + sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update" + << " packet to supervisor handler" << std::endl; + triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_IMAGE_DATA); + state = State::IDLE; + pendingCommand = PLOC_SPV::NONE; + return; + } - remainingPackets--; - packetsSent++; + remainingPackets--; + packetsSent++; - pendingCommand = PLOC_SPV::UPDATE_IMAGE_DATA; - state = State::COMMAND_EXECUTING; + pendingCommand = PLOC_SPV::UPDATE_IMAGE_DATA; + state = State::COMMAND_EXECUTING; } void PlocUpdater::commandUpdateVerify() { - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = RETURN_OK; - PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_VERIFY, static_cast(image), - static_cast(partition), imageSize, imageCrc, numOfUpdatePackets); + PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_VERIFY, static_cast(image), + static_cast(partition), imageSize, imageCrc, + numOfUpdatePackets); - result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, - PLOC_SPV::UPDATE_VERIFY, packet.getWholeData(), packet.getFullSize()); - if (result != RETURN_OK) { - sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update available" - << " packet to supervisor handler" << std::endl; - triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_VERIFY); - state = State::IDLE; - pendingCommand = PLOC_SPV::NONE; - return; - } - state = State::COMMAND_EXECUTING; - pendingCommand = PLOC_SPV::UPDATE_VERIFY; + result = + commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, PLOC_SPV::UPDATE_VERIFY, + packet.getWholeData(), packet.getFullSize()); + if (result != RETURN_OK) { + sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update available" + << " packet to supervisor handler" << std::endl; + triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_VERIFY); + state = State::IDLE; + pendingCommand = PLOC_SPV::NONE; return; + } + state = State::COMMAND_EXECUTING; + pendingCommand = PLOC_SPV::UPDATE_VERIFY; + return; } void PlocUpdater::calcImageCrc() { - std::ifstream file(updateFile, std::ifstream::binary); - file.seekg(0, file.end); - uint32_t count; - uint32_t bit; - uint32_t remainder = INITIAL_REMAINDER_32; - char input; - for (count = 0; count < imageSize; count++) { - file.seekg(count, file.beg); - file.read(&input, 1); - remainder ^= (input << 16); - for (bit = 8; bit > 0; --bit) { - if (remainder & TOPBIT_32) { - remainder = (remainder << 1) ^ POLYNOMIAL_32; - } else { - remainder = (remainder << 1); - } - } + std::ifstream file(updateFile, std::ifstream::binary); + file.seekg(0, file.end); + uint32_t count; + uint32_t bit; + uint32_t remainder = INITIAL_REMAINDER_32; + char input; + for (count = 0; count < imageSize; count++) { + file.seekg(count, file.beg); + file.read(&input, 1); + remainder ^= (input << 16); + for (bit = 8; bit > 0; --bit) { + if (remainder & TOPBIT_32) { + remainder = (remainder << 1) ^ POLYNOMIAL_32; + } else { + remainder = (remainder << 1); + } } - file.close(); - imageCrc = (remainder ^ FINAL_XOR_VALUE_32); + } + file.close(); + imageCrc = (remainder ^ FINAL_XOR_VALUE_32); } void PlocUpdater::adjustSequenceFlags(PLOC_SPV::UpdatePacket& packet) { - if (packetsSent == 0) { - packet.setSequenceFlags(static_cast(PLOC_SPV::SequenceFlags::FIRST_PKT)); - } - else if (remainingPackets == 1) { - packet.setSequenceFlags(static_cast(PLOC_SPV::SequenceFlags::LAST_PKT)); - } - else { - packet.setSequenceFlags(static_cast(PLOC_SPV::SequenceFlags::CONTINUED_PKT)); - } + if (packetsSent == 0) { + packet.setSequenceFlags(static_cast(PLOC_SPV::SequenceFlags::FIRST_PKT)); + } else if (remainingPackets == 1) { + packet.setSequenceFlags(static_cast(PLOC_SPV::SequenceFlags::LAST_PKT)); + } else { + packet.setSequenceFlags(static_cast(PLOC_SPV::SequenceFlags::CONTINUED_PKT)); + } } - diff --git a/bsp_q7s/devices/PlocUpdater.h b/bsp_q7s/devices/PlocUpdater.h index d016b9e5..bfd86995 100644 --- a/bsp_q7s/devices/PlocUpdater.h +++ b/bsp_q7s/devices/PlocUpdater.h @@ -2,181 +2,170 @@ #define MISSION_DEVICES_PLOCUPDATER_H_ #include "OBSWConfig.h" +#include "bsp_q7s/memory/SdCardManager.h" #include "devicedefinitions/PlocSupervisorDefinitions.h" - -#include "fsfw/action/CommandActionHelper.h" #include "fsfw/action/ActionHelper.h" -#include "fsfw/action/HasActionsIF.h" +#include "fsfw/action/CommandActionHelper.h" #include "fsfw/action/CommandsActionsIF.h" +#include "fsfw/action/HasActionsIF.h" +#include "fsfw/objectmanager/SystemObject.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/tasks/ExecutableObjectIF.h" -#include "fsfw/objectmanager/SystemObject.h" -#include "bsp_q7s/memory/SdCardManager.h" -#include "linux/fsfwconfig/objects/systemObjectList.h" #include "fsfw/tmtcpacket/SpacePacket.h" - +#include "linux/fsfwconfig/objects/systemObjectList.h" /** * @brief An object of this class can be used to perform the software updates of the PLOC. The * software update will be read from one of the SD cards, split into multiple space * packets and sent to the PlocSupervisorHandler. * - * @details The MPSoC has two boot memories (NVM0 and NVM1) where each stores two images (Partition A - * and Partition B) + * @details The MPSoC has two boot memories (NVM0 and NVM1) where each stores two images (Partition + * A and Partition B) * * @author J. Meier */ class PlocUpdater : public SystemObject, - public HasActionsIF, - public ExecutableObjectIF, - public HasReturnvaluesIF, - public CommandsActionsIF { -public: + public HasActionsIF, + public ExecutableObjectIF, + public HasReturnvaluesIF, + public CommandsActionsIF { + public: + static const ActionId_t UPDATE_A_UBOOT = 0; + static const ActionId_t UPDATE_A_BITSTREAM = 1; + static const ActionId_t UPDATE_A_LINUX = 2; + static const ActionId_t UPDATE_A_APP_SW = 3; + static const ActionId_t UPDATE_B_UBOOT = 4; + static const ActionId_t UPDATE_B_BITSTREAM = 5; + static const ActionId_t UPDATE_B_LINUX = 6; + static const ActionId_t UPDATE_B_APP_SW = 7; - static const ActionId_t UPDATE_A_UBOOT = 0; - static const ActionId_t UPDATE_A_BITSTREAM = 1; - static const ActionId_t UPDATE_A_LINUX = 2; - static const ActionId_t UPDATE_A_APP_SW = 3; - static const ActionId_t UPDATE_B_UBOOT = 4; - static const ActionId_t UPDATE_B_BITSTREAM = 5; - static const ActionId_t UPDATE_B_LINUX = 6; - static const ActionId_t UPDATE_B_APP_SW = 7; + PlocUpdater(object_id_t objectId); + virtual ~PlocUpdater(); - PlocUpdater(object_id_t objectId); - virtual ~PlocUpdater(); + ReturnValue_t performOperation(uint8_t operationCode = 0) override; + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size); + MessageQueueId_t getCommandQueue() const; + ReturnValue_t initialize() override; + MessageQueueIF* getCommandQueuePtr() override; + void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) override; + void stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) override; + void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) override; + void completionSuccessfulReceived(ActionId_t actionId) override; + void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override; - ReturnValue_t performOperation(uint8_t operationCode = 0) override; - ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size); - MessageQueueId_t getCommandQueue() const; - ReturnValue_t initialize() override; - MessageQueueIF* getCommandQueuePtr() override; - void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) override; - void stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) override; - void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) override; - void completionSuccessfulReceived(ActionId_t actionId) override; - void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_UPDATER; -private: + //! [EXPORT] : [COMMENT] Updater is already performing an update + static const ReturnValue_t UPDATER_BUSY = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] Received update command with invalid path string (too long). + static const ReturnValue_t NAME_TOO_LONG = MAKE_RETURN_CODE(0xA1); + //! [EXPORT] : [COMMENT] Received command to initiate update but SD card with update image not + //! mounted. + static const ReturnValue_t SD_NOT_MOUNTED = MAKE_RETURN_CODE(0xA2); + //! [EXPORT] : [COMMENT] Update file received with update command does not exist. + static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xA3); - static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_UPDATER; + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_UPDATER; - //! [EXPORT] : [COMMENT] Updater is already performing an update - static const ReturnValue_t UPDATER_BUSY = MAKE_RETURN_CODE(0xA0); - //! [EXPORT] : [COMMENT] Received update command with invalid path string (too long). - static const ReturnValue_t NAME_TOO_LONG = MAKE_RETURN_CODE(0xA1); - //! [EXPORT] : [COMMENT] Received command to initiate update but SD card with update image not mounted. - static const ReturnValue_t SD_NOT_MOUNTED = MAKE_RETURN_CODE(0xA2); - //! [EXPORT] : [COMMENT] Update file received with update command does not exist. - static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xA3); + //! [EXPORT] : [COMMENT] Try to read update file but the file does not exist. + //! P1: Indicates in which state the file read fails + //! P2: During the update transfer the second parameter gives information about the number of + //! already sent packets + static const Event UPDATE_FILE_NOT_EXISTS = MAKE_EVENT(0, severity::LOW); + //! [EXPORT] : [COMMENT] Failed to send command to supervisor handler + //! P1: Return value of CommandActionHelper::commandAction + //! P2: Action ID of command to send + static const Event ACTION_COMMANDING_FAILED = MAKE_EVENT(1, severity::LOW); + //! [EXPORT] : [COMMENT] Supervisor handler replied action message indicating a command execution + //! failure of the update available command + static const Event UPDATE_AVAILABLE_FAILED = MAKE_EVENT(2, severity::LOW); + //! [EXPORT] : [COMMENT] Supervisor handler failed to transfer an update space packet. + //! P1: Parameter holds the number of update packets already sent (inclusive the failed packet) + static const Event UPDATE_TRANSFER_FAILED = MAKE_EVENT(3, severity::LOW); + //! [EXPORT] : [COMMENT] Supervisor failed to execute the update verify command. + static const Event UPDATE_VERIFY_FAILED = MAKE_EVENT(4, severity::LOW); + //! [EXPORT] : [COMMENT] MPSoC update successful completed + static const Event UPDATE_FINISHED = MAKE_EVENT(5, severity::INFO); - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_UPDATER; + static const uint32_t QUEUE_SIZE = config::PLOC_UPDATER_QUEUE_SIZE; + static const size_t MAX_PLOC_UPDATE_PATH = 50; + static const size_t SD_PREFIX_LENGTH = 8; + // Maximum size of update payload data per space packet (max size of space packet is 1024 bytes) + static const size_t MAX_SP_DATA = 1016; - //! [EXPORT] : [COMMENT] Try to read update file but the file does not exist. - //! P1: Indicates in which state the file read fails - //! P2: During the update transfer the second parameter gives information about the number of already sent packets - static const Event UPDATE_FILE_NOT_EXISTS = MAKE_EVENT(0, severity::LOW); - //! [EXPORT] : [COMMENT] Failed to send command to supervisor handler - //! P1: Return value of CommandActionHelper::commandAction - //! P2: Action ID of command to send - static const Event ACTION_COMMANDING_FAILED = MAKE_EVENT(1, severity::LOW); - //! [EXPORT] : [COMMENT] Supervisor handler replied action message indicating a command execution failure of the update available command - static const Event UPDATE_AVAILABLE_FAILED = MAKE_EVENT(2, severity::LOW); - //! [EXPORT] : [COMMENT] Supervisor handler failed to transfer an update space packet. - //! P1: Parameter holds the number of update packets already sent (inclusive the failed packet) - static const Event UPDATE_TRANSFER_FAILED = MAKE_EVENT(3, severity::LOW); - //! [EXPORT] : [COMMENT] Supervisor failed to execute the update verify command. - static const Event UPDATE_VERIFY_FAILED = MAKE_EVENT(4, severity::LOW); - //! [EXPORT] : [COMMENT] MPSoC update successful completed - static const Event UPDATE_FINISHED = MAKE_EVENT(5, severity::INFO); + static const uint32_t TOPBIT_32 = (1 << 31); + static const uint32_t POLYNOMIAL_32 = 0x04C11DB7; + static const uint32_t INITIAL_REMAINDER_32 = 0xFFFFFFFF; + static const uint32_t FINAL_XOR_VALUE_32 = 0xFFFFFFFF; - static const uint32_t QUEUE_SIZE = config::PLOC_UPDATER_QUEUE_SIZE; - static const size_t MAX_PLOC_UPDATE_PATH = 50; - static const size_t SD_PREFIX_LENGTH = 8; - // Maximum size of update payload data per space packet (max size of space packet is 1024 bytes) - static const size_t MAX_SP_DATA = 1016; - - static const uint32_t TOPBIT_32 = (1 << 31); - static const uint32_t POLYNOMIAL_32 = 0x04C11DB7; - static const uint32_t INITIAL_REMAINDER_32 = 0xFFFFFFFF; - static const uint32_t FINAL_XOR_VALUE_32 = 0xFFFFFFFF; - - MessageQueueIF* commandQueue = nullptr; + MessageQueueIF* commandQueue = nullptr; #if BOARD_TE0720 == 0 - SdCardManager* sdcMan = nullptr; + SdCardManager* sdcMan = nullptr; #endif - CommandActionHelper commandActionHelper; + CommandActionHelper commandActionHelper; - ActionHelper actionHelper; + ActionHelper actionHelper; - enum class State: uint8_t { - IDLE, - UPDATE_AVAILABLE, - UPDATE_TRANSFER, - UPDATE_VERIFY, - COMMAND_EXECUTING - }; + enum class State : uint8_t { + IDLE, + UPDATE_AVAILABLE, + UPDATE_TRANSFER, + UPDATE_VERIFY, + COMMAND_EXECUTING + }; - State state = State::IDLE; + State state = State::IDLE; - ActionId_t pendingCommand = PLOC_SPV::NONE; + ActionId_t pendingCommand = PLOC_SPV::NONE; - enum class Image: uint8_t { - NONE, - A, - B - }; + enum class Image : uint8_t { NONE, A, B }; - Image image = Image::NONE; + Image image = Image::NONE; - enum class Partition: uint8_t { - NONE, - UBOOT, - BITSTREAM, - LINUX_OS, - APP_SW - }; + enum class Partition : uint8_t { NONE, UBOOT, BITSTREAM, LINUX_OS, APP_SW }; - Partition partition = Partition::NONE; + Partition partition = Partition::NONE; - uint32_t packetsSent = 0; - uint32_t remainingPackets = 0; - // Number of packets required to transfer the update image - uint32_t numOfUpdatePackets = 0; + uint32_t packetsSent = 0; + uint32_t remainingPackets = 0; + // Number of packets required to transfer the update image + uint32_t numOfUpdatePackets = 0; - std::string updateFile; - uint32_t imageSize = 0; - uint32_t imageCrc = 0; + std::string updateFile; + uint32_t imageSize = 0; + uint32_t imageCrc = 0; - void readCommandQueue(); - void doStateMachine(); + void readCommandQueue(); + void doStateMachine(); - /** - * @brief Extracts the path and name of the update image from the service 8 command data. - */ - ReturnValue_t getImageLocation(const uint8_t* data, size_t size); + /** + * @brief Extracts the path and name of the update image from the service 8 command data. + */ + ReturnValue_t getImageLocation(const uint8_t* data, size_t size); - ReturnValue_t checkNameLength(size_t size); + ReturnValue_t checkNameLength(size_t size); - /** - * @brief Prepares and sends update available command to PLOC supervisor handler. - */ - void commandUpdateAvailable(); + /** + * @brief Prepares and sends update available command to PLOC supervisor handler. + */ + void commandUpdateAvailable(); - /** - * @brief Prepares and sends and update packet to the PLOC supervisor handler. - */ - void commandUpdatePacket(); + /** + * @brief Prepares and sends and update packet to the PLOC supervisor handler. + */ + void commandUpdatePacket(); - /** - * @brief Prepares and sends the update verification packet to the PLOC supervisor handler. - */ - void commandUpdateVerify(); + /** + * @brief Prepares and sends the update verification packet to the PLOC supervisor handler. + */ + void commandUpdateVerify(); - void calcImageCrc(); + void calcImageCrc(); - void adjustSequenceFlags(PLOC_SPV::UpdatePacket& packet); + void adjustSequenceFlags(PLOC_SPV::UpdatePacket& packet); }; #endif /* MISSION_DEVICES_PLOCUPDATER_H_ */ diff --git a/bsp_q7s/devices/devicedefinitions/PlocMemDumpDefinitions.h b/bsp_q7s/devices/devicedefinitions/PlocMemDumpDefinitions.h index 6e44cf35..00dc9003 100644 --- a/bsp_q7s/devices/devicedefinitions/PlocMemDumpDefinitions.h +++ b/bsp_q7s/devices/devicedefinitions/PlocMemDumpDefinitions.h @@ -3,31 +3,26 @@ #include -class MemoryParams: public SerialLinkedListAdapter { -public: +class MemoryParams : public SerialLinkedListAdapter { + public: + /** + * @brief Constructor + * @param startAddress Start of address range to dump + * @param endAddress End of address range to dump + */ + MemoryParams(uint32_t startAddress, uint32_t endAddress) + : startAddress(startAddress), endAddress(endAddress) { + setLinks(); + } - /** - * @brief Constructor - * @param startAddress Start of address range to dump - * @param endAddress End of address range to dump - */ - MemoryParams(uint32_t startAddress, uint32_t endAddress) : - startAddress(startAddress), endAddress(endAddress) { - setLinks(); - } -private: - - void setLinks() { - setStart(&startAddress); - startAddress.setNext(&endAddress); - } - - SerializeElement startAddress; - SerializeElement endAddress; + private: + void setLinks() { + setStart(&startAddress); + startAddress.setNext(&endAddress); + } + SerializeElement startAddress; + SerializeElement endAddress; }; - - - #endif /* BSP_Q7S_DEVICES_DEVICEDEFINITIONS_PLOCMEMDUMPDEFINITIONS_H_ */ diff --git a/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h b/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h index 0235d281..3fc21441 100644 --- a/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h +++ b/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h @@ -1,12 +1,12 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_PLOCSVPDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_PLOCSVPDEFINITIONS_H_ -#include +#include +#include #include #include #include -#include -#include +#include namespace PLOC_SPV { @@ -143,7 +143,7 @@ static const uint8_t DATA_FIELD_OFFSET = 6; * Space packet length for fixed size packets. This is the size of the whole packet data * field. For the length field in the space packet this size will be substracted by one. */ -static const uint16_t LENGTH_EMPTY_TC = 2; // Only CRC will be transported with the data field +static const uint16_t LENGTH_EMPTY_TC = 2; // Only CRC will be transported with the data field /** This is the maximum length of a space packet as defined by the TAS ICD */ static const size_t MAX_COMMAND_SIZE = 1024; @@ -153,51 +153,53 @@ static const size_t MAX_PACKET_SIZE = 1024; static const uint8_t SPACE_PACKET_HEADER_LENGTH = 6; -enum class SequenceFlags: uint8_t { - CONTINUED_PKT = 0b00, FIRST_PKT = 0b01, LAST_PKT = 0b10, STANDALONE_PKT = 0b11 +enum class SequenceFlags : uint8_t { + CONTINUED_PKT = 0b00, + FIRST_PKT = 0b01, + LAST_PKT = 0b10, + STANDALONE_PKT = 0b11 }; -enum PoolIds - : lp_id_t { - NUM_TMS, - TEMP_PS, - TEMP_PL, - SOC_STATE, - NVM0_1_STATE, - NVM3_STATE, - MISSION_IO_STATE, - FMC_STATE, - NUM_TCS, - TEMP_SUP, - UPTIME, - CPULOAD, - AVAILABLEHEAP, - BOOT_SIGNAL, - RESET_COUNTER, - BOOT_AFTER_MS, - BOOT_TIMEOUT_MS, - ACTIVE_NVM, - BP0_STATE, - BP1_STATE, - BP2_STATE, +enum PoolIds : lp_id_t { + NUM_TMS, + TEMP_PS, + TEMP_PL, + SOC_STATE, + NVM0_1_STATE, + NVM3_STATE, + MISSION_IO_STATE, + FMC_STATE, + NUM_TCS, + TEMP_SUP, + UPTIME, + CPULOAD, + AVAILABLEHEAP, + BOOT_SIGNAL, + RESET_COUNTER, + BOOT_AFTER_MS, + BOOT_TIMEOUT_MS, + ACTIVE_NVM, + BP0_STATE, + BP1_STATE, + BP2_STATE, - LATCHUP_ID, - CNT0, - CNT1, - CNT2, - CNT3, - CNT4, - CNT5, - CNT6, - LATCHUP_RPT_TIME_SEC, - LATCHUP_RPT_TIME_MIN, - LATCHUP_RPT_TIME_HOUR, - LATCHUP_RPT_TIME_DAY, - LATCHUP_RPT_TIME_MON, - LATCHUP_RPT_TIME_YEAR, - LATCHUP_RPT_TIME_MSEC, - LATCHUP_RPT_TIME_USEC, - LATCHUP_RPT_TIME_IS_SET, + LATCHUP_ID, + CNT0, + CNT1, + CNT2, + CNT3, + CNT4, + CNT5, + CNT6, + LATCHUP_RPT_TIME_SEC, + LATCHUP_RPT_TIME_MIN, + LATCHUP_RPT_TIME_HOUR, + LATCHUP_RPT_TIME_DAY, + LATCHUP_RPT_TIME_MON, + LATCHUP_RPT_TIME_YEAR, + LATCHUP_RPT_TIME_MSEC, + LATCHUP_RPT_TIME_USEC, + LATCHUP_RPT_TIME_IS_SET, }; static const uint8_t HK_SET_ENTRIES = 13; @@ -211,285 +213,273 @@ static const uint32_t LATCHUP_RPT_ID = LATCHUP_REPORT; /** * @brief With this class a space packet can be created which does not contain any data. */ -class EmptyPacket: public SpacePacket { -public: +class EmptyPacket : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param apid The APID to set in the space packet. + * + * @note Sequence count of empty packet is always 1. + */ + EmptyPacket(uint16_t apid) : SpacePacket(LENGTH_EMPTY_TC - 1, true, apid, 1) { calcCrc(); } - /** - * @brief Constructor - * - * @param apid The APID to set in the space packet. - * - * @note Sequence count of empty packet is always 1. - */ - EmptyPacket(uint16_t apid) : - SpacePacket(LENGTH_EMPTY_TC - 1, true, apid, 1) { - calcCrc(); - } + private: + /** + * @brief CRC calculation which involves only the header in an empty packet + */ + void calcCrc() { + /* Calculate crc */ + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, sizeof(CCSDSPrimaryHeader)); -private: - - /** - * @brief CRC calculation which involves only the header in an empty packet - */ - void calcCrc() { - - /* Calculate crc */ - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, sizeof(CCSDSPrimaryHeader)); - - /* Add crc to packet data field of space packet */ - size_t serializedSize = 0; - uint8_t* crcPos = this->localData.fields.buffer; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + /* Add crc to packet data field of space packet */ + size_t serializedSize = 0; + uint8_t* crcPos = this->localData.fields.buffer; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class can be used to generate the space packet selecting the boot image of * of the MPSoC. */ -class MPSoCBootSelect: public SpacePacket { -public: +class MPSoCBootSelect : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param mem The memory to boot from: NVM0 (0), NVM1 (1) + * @param bp0 Partition pin 0 + * @param bp1 Partition pin 1 + * @param bp2 Partition pin 2 + */ + MPSoCBootSelect(uint8_t mem, uint8_t bp0, uint8_t bp1, uint8_t bp2) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SEL_MPSOC_BOOT_IMAGE, DEFAULT_SEQUENCE_COUNT), + mem(mem), + bp0(bp0), + bp1(bp1), + bp2(bp2) { + initPacket(); + } - /** - * @brief Constructor - * - * @param mem The memory to boot from: NVM0 (0), NVM1 (1) - * @param bp0 Partition pin 0 - * @param bp1 Partition pin 1 - * @param bp2 Partition pin 2 - */ - MPSoCBootSelect(uint8_t mem, uint8_t bp0, uint8_t bp1, uint8_t bp2) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SEL_MPSOC_BOOT_IMAGE, - DEFAULT_SEQUENCE_COUNT), mem(mem), bp0(bp0), bp1(bp1), bp2(bp2) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 6; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint8_t MEM_OFFSET = 0; + static const uint8_t BP0_OFFSET = 1; + static const uint8_t BP1_OFFSET = 2; + static const uint8_t BP2_OFFSET = 3; + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 6; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t mem = 0; + uint8_t bp0 = 0; + uint8_t bp1 = 0; + uint8_t bp2 = 0; - static const uint8_t MEM_OFFSET = 0; - static const uint8_t BP0_OFFSET = 1; - static const uint8_t BP1_OFFSET = 2; - static const uint8_t BP2_OFFSET = 3; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; + void initPacket() { + uint8_t* data_field_start = this->localData.fields.buffer; + std::memcpy(data_field_start + MEM_OFFSET, &mem, sizeof(mem)); + std::memcpy(data_field_start + BP0_OFFSET, &bp0, sizeof(bp0)); + std::memcpy(data_field_start + BP1_OFFSET, &bp1, sizeof(bp1)); + std::memcpy(data_field_start + BP2_OFFSET, &bp2, sizeof(bp2)); + /* Calculate crc */ + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t mem = 0; - uint8_t bp0 = 0; - uint8_t bp1 = 0; - uint8_t bp2 = 0; - - void initPacket() { - uint8_t* data_field_start = this->localData.fields.buffer; - std::memcpy(data_field_start + MEM_OFFSET, &mem, sizeof(mem)); - std::memcpy(data_field_start + BP0_OFFSET, &bp0, sizeof(bp0)); - std::memcpy(data_field_start + BP1_OFFSET, &bp1, sizeof(bp1)); - std::memcpy(data_field_start + BP2_OFFSET, &bp2, sizeof(bp2)); - /* Calculate crc */ - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - - /* Add crc to packet data field of space packet */ - size_t serializedSize = 0; - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + /* Add crc to packet data field of space packet */ + size_t serializedSize = 0; + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class generates the space packet to update the time of the PLOC supervisor. */ -class SetTimeRef: public SpacePacket { -public: +class SetTimeRef : public SpacePacket { + public: + SetTimeRef(Clock::TimeOfDay_t* time) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_TIME_REF, DEFAULT_SEQUENCE_COUNT) { + initPacket(time); + } - SetTimeRef(Clock::TimeOfDay_t* time) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_TIME_REF, DEFAULT_SEQUENCE_COUNT) { - initPacket(time); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 34; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; -private: - - static const uint16_t DATA_FIELD_LENGTH = 34; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - void initPacket(Clock::TimeOfDay_t* time) { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&time->second, &data_field_ptr, &serializedSize, - sizeof(time->second), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&time->minute, &data_field_ptr, &serializedSize, - sizeof(time->minute), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&time->hour, &data_field_ptr, &serializedSize, - sizeof(time->hour), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&time->day, &data_field_ptr, &serializedSize, - sizeof(time->day), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&time->month, &data_field_ptr, &serializedSize, - sizeof(time->month), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&time->year, &data_field_ptr, &serializedSize, - sizeof(time->year), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint32_t milliseconds = time->usecond / 1000; - SerializeAdapter::serialize(&milliseconds, &data_field_ptr, &serializedSize, - sizeof(milliseconds), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint32_t isSet = 0xFFFFFFFF; - SerializeAdapter::serialize(&isSet, &data_field_ptr, &serializedSize, - sizeof(isSet), SerializeIF::Endianness::BIG); - serializedSize = 0; - /* Calculate crc */ - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - SerializeAdapter::serialize(&crc, &data_field_ptr, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket(Clock::TimeOfDay_t* time) { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&time->second, &data_field_ptr, &serializedSize, + sizeof(time->second), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&time->minute, &data_field_ptr, &serializedSize, + sizeof(time->minute), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&time->hour, &data_field_ptr, &serializedSize, + sizeof(time->hour), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&time->day, &data_field_ptr, &serializedSize, + sizeof(time->day), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&time->month, &data_field_ptr, &serializedSize, + sizeof(time->month), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&time->year, &data_field_ptr, &serializedSize, + sizeof(time->year), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint32_t milliseconds = time->usecond / 1000; + SerializeAdapter::serialize(&milliseconds, &data_field_ptr, &serializedSize, + sizeof(milliseconds), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint32_t isSet = 0xFFFFFFFF; + SerializeAdapter::serialize(&isSet, &data_field_ptr, &serializedSize, sizeof(isSet), + SerializeIF::Endianness::BIG); + serializedSize = 0; + /* Calculate crc */ + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + SerializeAdapter::serialize(&crc, &data_field_ptr, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class can be used to generate the set boot timout command. */ -class SetBootTimeout: public SpacePacket { -public: +class SetBootTimeout : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param timeout The boot timeout in milliseconds. + */ + SetBootTimeout(uint32_t timeout) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_BOOT_TIMEOUT, 1), timeout(timeout) { + initPacket(); + } - /** - * @brief Constructor - * - * @param timeout The boot timeout in milliseconds. - */ - SetBootTimeout(uint32_t timeout) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_BOOT_TIMEOUT, 1), timeout(timeout) { - initPacket(); - } + private: + uint32_t timeout = 0; -private: + /** boot timeout value (uint32_t) and crc (uint16_t) */ + static const uint16_t DATA_FIELD_LENGTH = 6; - uint32_t timeout = 0; - - /** boot timeout value (uint32_t) and crc (uint16_t) */ - static const uint16_t DATA_FIELD_LENGTH = 6; - - void initPacket() { - - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&timeout, &data_field_ptr, &serializedSize, - sizeof(timeout), SerializeIF::Endianness::BIG); - /* Calculate crc */ - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - /* Add crc to packet data field of space packet */ - serializedSize = 0; - SerializeAdapter::serialize(&crc, &data_field_ptr, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&timeout, &data_field_ptr, &serializedSize, + sizeof(timeout), SerializeIF::Endianness::BIG); + /* Calculate crc */ + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + /* Add crc to packet data field of space packet */ + serializedSize = 0; + SerializeAdapter::serialize(&crc, &data_field_ptr, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class can be used to generate the space packet to set the maximum boot tries. */ -class SetRestartTries: public SpacePacket { -public: +class SetRestartTries : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param restartTries Maximum restart tries to set. + */ + SetRestartTries(uint8_t restartTries) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_MAX_RESTART_TRIES, 1), + restartTries(restartTries) { + initPacket(); + } - /** - * @brief Constructor - * - * @param restartTries Maximum restart tries to set. - */ - SetRestartTries(uint8_t restartTries) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_MAX_RESTART_TRIES, 1), restartTries( - restartTries) { - initPacket(); - } + private: + uint8_t restartTries = 0; -private: + /** Restart tries value (uint8_t) and crc (uint16_t) */ + static const uint16_t DATA_FIELD_LENGTH = 3; - uint8_t restartTries = 0; - - /** Restart tries value (uint8_t) and crc (uint16_t) */ - static const uint16_t DATA_FIELD_LENGTH = 3; - - void initPacket() { - uint8_t* data_field_ptr = this->localData.fields.buffer; - *data_field_ptr = restartTries; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - size_t serializedSize = 0; - uint8_t* crcPtr = data_field_ptr + 1; - SerializeAdapter::serialize(&crc, &crcPtr, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + uint8_t* data_field_ptr = this->localData.fields.buffer; + *data_field_ptr = restartTries; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + size_t serializedSize = 0; + uint8_t* crcPtr = data_field_ptr + 1; + SerializeAdapter::serialize(&crc, &crcPtr, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the command to notify the supervisor that a new update for the * MPSoC is available. */ -class UpdateAvailable: public SpacePacket { -public: +class UpdateAvailable : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param imageSelect + * @param imagePartition + * @param imageSize + * @param imageCrc + * @param numberOfPackets + */ + UpdateAvailable(uint8_t imageSelect, uint8_t imagePartition, uint32_t imageSize, + uint32_t imageCrc, uint32_t numberOfPackets) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_UPDATE_AVAILABLE, DEFAULT_SEQUENCE_COUNT), + imageSelect(imageSelect), + imagePartition(imagePartition), + imageSize(imageSize), + imageCrc(imageCrc), + numberOfPackets(numberOfPackets) { + initPacket(); + } - /** - * @brief Constructor - * - * @param imageSelect - * @param imagePartition - * @param imageSize - * @param imageCrc - * @param numberOfPackets - */ - UpdateAvailable(uint8_t imageSelect, uint8_t imagePartition, uint32_t imageSize, - uint32_t imageCrc, uint32_t numberOfPackets) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_UPDATE_AVAILABLE, - DEFAULT_SEQUENCE_COUNT), imageSelect(imageSelect), imagePartition( - imagePartition), imageSize(imageSize), imageCrc(imageCrc), numberOfPackets( - numberOfPackets) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 16; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 16; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t imageSelect = 0; + uint8_t imagePartition = 0; + uint32_t imageSize = 0; + uint32_t imageCrc = 0; + uint32_t numberOfPackets = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t imageSelect = 0; - uint8_t imagePartition = 0; - uint32_t imageSize = 0; - uint32_t imageCrc = 0; - uint32_t numberOfPackets = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&imageSelect, &data_field_ptr, &serializedSize, - sizeof(imageSelect), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&imagePartition, &data_field_ptr, &serializedSize, - sizeof(imagePartition), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&imageSize, &data_field_ptr, &serializedSize, - sizeof(imageSize), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&imageCrc, &data_field_ptr, &serializedSize, - sizeof(imageCrc), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&numberOfPackets, &data_field_ptr, &serializedSize, - sizeof(numberOfPackets), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&imageSelect, &data_field_ptr, &serializedSize, + sizeof(imageSelect), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&imagePartition, &data_field_ptr, &serializedSize, + sizeof(imagePartition), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&imageSize, &data_field_ptr, &serializedSize, + sizeof(imageSize), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&imageCrc, &data_field_ptr, &serializedSize, + sizeof(imageCrc), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&numberOfPackets, &data_field_ptr, &serializedSize, + sizeof(numberOfPackets), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** @@ -497,130 +487,126 @@ private: * of housekeeping data. Normally, this will be disabled by default. However, adding this * command can be useful for debugging. */ -class DisablePeriodicHkTransmission: public SpacePacket { -public: +class DisablePeriodicHkTransmission : public SpacePacket { + public: + /** + * @brief Constructor + */ + DisablePeriodicHkTransmission() : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_DISABLE_HK, 1) { + initPacket(); + } - /** - * @brief Constructor - */ - DisablePeriodicHkTransmission() : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_DISABLE_HK, 1) { - initPacket(); - } + private: + uint8_t disableHk = 0; -private: + /** Restart tries value (uint8_t) and crc (uint16_t) */ + static const uint16_t DATA_FIELD_LENGTH = 3; - uint8_t disableHk = 0; - - /** Restart tries value (uint8_t) and crc (uint16_t) */ - static const uint16_t DATA_FIELD_LENGTH = 3; - - void initPacket() { - uint8_t* data_field_ptr = this->localData.fields.buffer; - *data_field_ptr = disableHk; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - size_t serializedSize = 0; - uint8_t* crcPtr = data_field_ptr + 1; - SerializeAdapter::serialize(&crc, &crcPtr, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + uint8_t* data_field_ptr = this->localData.fields.buffer; + *data_field_ptr = disableHk; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + size_t serializedSize = 0; + uint8_t* crcPtr = data_field_ptr + 1; + SerializeAdapter::serialize(&crc, &crcPtr, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the command to enable the watchdogs of the PLOC. */ -class WatchdogsEnable: public SpacePacket { -public: +class WatchdogsEnable : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param watchdogPs Enables processing system watchdog + * @param watchdogPl Enables programmable logic wathdog + * @param watchdogInt + */ + WatchdogsEnable(uint8_t watchdogPs, uint8_t watchdogPl, uint8_t watchdogInt) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_WTD_ENABLE, DEFAULT_SEQUENCE_COUNT), + watchdogPs(watchdogPs), + watchdogPl(watchdogPl), + watchdogInt(watchdogInt) { + initPacket(); + } - /** - * @brief Constructor - * - * @param watchdogPs Enables processing system watchdog - * @param watchdogPl Enables programmable logic wathdog - * @param watchdogInt - */ - WatchdogsEnable(uint8_t watchdogPs, uint8_t watchdogPl, uint8_t watchdogInt) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_WTD_ENABLE, DEFAULT_SEQUENCE_COUNT), - watchdogPs(watchdogPs), watchdogPl(watchdogPl), watchdogInt(watchdogInt) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 5; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 5; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t watchdogPs = 0; + uint8_t watchdogPl = 0; + uint8_t watchdogInt = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t watchdogPs = 0; - uint8_t watchdogPl = 0; - uint8_t watchdogInt = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&watchdogPs, &data_field_ptr, &serializedSize, - sizeof(watchdogPs), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&watchdogPl, &data_field_ptr, &serializedSize, - sizeof(watchdogPl), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&watchdogInt, &data_field_ptr, &serializedSize, - sizeof(watchdogInt), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&watchdogPs, &data_field_ptr, &serializedSize, + sizeof(watchdogPs), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&watchdogPl, &data_field_ptr, &serializedSize, + sizeof(watchdogPl), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&watchdogInt, &data_field_ptr, &serializedSize, + sizeof(watchdogInt), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the command to set the timeout of one of the three watchdogs (PS, * PL, INT) */ -class WatchdogsConfigTimeout: public SpacePacket { -public: +class WatchdogsConfigTimeout : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param watchdogPs Selects the watchdog to configure (0 - PS, 1 - PL, 2 - INT) + * @param timeout The timeout to set + */ + WatchdogsConfigTimeout(uint8_t watchdog, uint32_t timeout) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_WTD_CONFIG_TIMEOUT, DEFAULT_SEQUENCE_COUNT), + watchdog(watchdog), + timeout(timeout) { + initPacket(); + } - /** - * @brief Constructor - * - * @param watchdogPs Selects the watchdog to configure (0 - PS, 1 - PL, 2 - INT) - * @param timeout The timeout to set - */ - WatchdogsConfigTimeout(uint8_t watchdog, uint32_t timeout) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_WTD_CONFIG_TIMEOUT, - DEFAULT_SEQUENCE_COUNT), watchdog(watchdog), timeout(timeout) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 7; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 7; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t watchdog = 0; + uint32_t timeout = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t watchdog = 0; - uint32_t timeout = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&watchdog, &data_field_ptr, &serializedSize, - sizeof(watchdog), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&timeout, &data_field_ptr, &serializedSize, - sizeof(timeout), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&watchdog, &data_field_ptr, &serializedSize, + sizeof(watchdog), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&timeout, &data_field_ptr, &serializedSize, + sizeof(timeout), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** @@ -628,723 +614,693 @@ private: * * @details There are 7 different latchup alerts. */ -class LatchupAlert: public SpacePacket { -public: - - /** - * @brief Constructor - * - * @param state true - enable, false - disable - * @param latchupId Identifies the latchup to enable/disable (0 - 0.85V, 1 - 1.8V, 2 - MISC, - * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) - */ - LatchupAlert(bool state, uint8_t latchupId) : - SpacePacket(DATA_FIELD_LENGTH - 1, true), latchupId(latchupId) { - if (state) { - this->setAPID(APID_ENABLE_LATCHUP_ALERT); - } else { - this->setAPID(APID_DISABLE_LATCHUP_ALERT); - } - this->setPacketSequenceCount(DEFAULT_SEQUENCE_COUNT); - initPacket(); +class LatchupAlert : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param state true - enable, false - disable + * @param latchupId Identifies the latchup to enable/disable (0 - 0.85V, 1 - 1.8V, 2 - MISC, + * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) + */ + LatchupAlert(bool state, uint8_t latchupId) + : SpacePacket(DATA_FIELD_LENGTH - 1, true), latchupId(latchupId) { + if (state) { + this->setAPID(APID_ENABLE_LATCHUP_ALERT); + } else { + this->setAPID(APID_DISABLE_LATCHUP_ALERT); } + this->setPacketSequenceCount(DEFAULT_SEQUENCE_COUNT); + initPacket(); + } -private: + private: + static const uint16_t DATA_FIELD_LENGTH = 3; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; - static const uint16_t DATA_FIELD_LENGTH = 3; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; + uint8_t latchupId = 0; - uint8_t latchupId = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, - sizeof(latchupId), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, + sizeof(latchupId), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the command to calibrate a certain latchup alert. */ -class AutoCalibrateAlert: public SpacePacket { -public: +class AutoCalibrateAlert : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param latchupId Identifies the latchup alert to calibrate (0 - 0.85V, 1 - 1.8V, 2 - MISC, + * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) + * @param mg + */ + AutoCalibrateAlert(uint8_t latchupId, uint32_t mg) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_AUTO_CALIBRATE_ALERT, DEFAULT_SEQUENCE_COUNT), + latchupId(latchupId), + mg(mg) { + initPacket(); + } - /** - * @brief Constructor - * - * @param latchupId Identifies the latchup alert to calibrate (0 - 0.85V, 1 - 1.8V, 2 - MISC, - * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) - * @param mg - */ - AutoCalibrateAlert(uint8_t latchupId, uint32_t mg) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_AUTO_CALIBRATE_ALERT, - DEFAULT_SEQUENCE_COUNT), latchupId(latchupId), mg(mg) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 7; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 7; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t latchupId = 0; + uint32_t mg = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t latchupId = 0; - uint32_t mg = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, - sizeof(latchupId), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&mg, &data_field_ptr, &serializedSize, - sizeof(mg), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, + sizeof(latchupId), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&mg, &data_field_ptr, &serializedSize, sizeof(mg), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; +class SetAlertlimit : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param latchupId Identifies the latchup alert to calibrate (0 - 0.85V, 1 - 1.8V, 2 - MISC, + * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) + * @param dutycycle + */ + SetAlertlimit(uint8_t latchupId, uint32_t dutycycle) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ALERT_LIMIT, DEFAULT_SEQUENCE_COUNT), + latchupId(latchupId), + dutycycle(dutycycle) { + initPacket(); + } -class SetAlertlimit: public SpacePacket { -public: + private: + static const uint16_t DATA_FIELD_LENGTH = 7; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; - /** - * @brief Constructor - * - * @param latchupId Identifies the latchup alert to calibrate (0 - 0.85V, 1 - 1.8V, 2 - MISC, - * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) - * @param dutycycle - */ - SetAlertlimit(uint8_t latchupId, uint32_t dutycycle) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ALERT_LIMIT, - DEFAULT_SEQUENCE_COUNT), latchupId(latchupId), dutycycle(dutycycle) { - initPacket(); - } + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; -private: + uint8_t latchupId = 0; + uint32_t dutycycle = 0; - static const uint16_t DATA_FIELD_LENGTH = 7; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; - - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t latchupId = 0; - uint32_t dutycycle = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, - sizeof(latchupId), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&dutycycle, &data_field_ptr, &serializedSize, - sizeof(dutycycle), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, + sizeof(latchupId), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&dutycycle, &data_field_ptr, &serializedSize, + sizeof(dutycycle), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; -class SetAlertIrqFilter: public SpacePacket { -public: +class SetAlertIrqFilter : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param latchupId Identifies the latchup alert to calibrate (0 - 0.85V, 1 - 1.8V, 2 - MISC, + * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) + * @param tp + * @param div + */ + SetAlertIrqFilter(uint8_t latchupId, uint8_t tp, uint8_t div) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ALERT_IRQ_FILTER, DEFAULT_SEQUENCE_COUNT), + tp(tp), + div(div) { + initPacket(); + } - /** - * @brief Constructor - * - * @param latchupId Identifies the latchup alert to calibrate (0 - 0.85V, 1 - 1.8V, 2 - MISC, - * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) - * @param tp - * @param div - */ - SetAlertIrqFilter(uint8_t latchupId, uint8_t tp, uint8_t div) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ALERT_IRQ_FILTER, - DEFAULT_SEQUENCE_COUNT), tp(tp), div(div) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 5; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 5; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t latchupId = 0; + uint8_t tp = 0; + uint8_t div = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t latchupId = 0; - uint8_t tp = 0; - uint8_t div = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, - sizeof(latchupId), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&tp, &data_field_ptr, &serializedSize, - sizeof(tp), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&div, &data_field_ptr, &serializedSize, - sizeof(div), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, + sizeof(latchupId), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&tp, &data_field_ptr, &serializedSize, sizeof(tp), + SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&div, &data_field_ptr, &serializedSize, sizeof(div), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; - /** * @brief This class packages the space packet to set the sweep period of the ADC. */ -class SetAdcSweepPeriod: public SpacePacket { -public: +class SetAdcSweepPeriod : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param sweepPeriod Sweep period in us. minimum is 21 us + */ + SetAdcSweepPeriod(uint32_t sweepPeriod) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_SWEEP_PERIOD, DEFAULT_SEQUENCE_COUNT), + sweepPeriod(sweepPeriod) { + initPacket(); + } - /** - * @brief Constructor - * - * @param sweepPeriod Sweep period in us. minimum is 21 us - */ - SetAdcSweepPeriod(uint32_t sweepPeriod) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_SWEEP_PERIOD, - DEFAULT_SEQUENCE_COUNT), sweepPeriod(sweepPeriod) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 6; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 6; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint32_t sweepPeriod = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint32_t sweepPeriod = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&sweepPeriod, &data_field_ptr, &serializedSize, - sizeof(sweepPeriod), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&sweepPeriod, &data_field_ptr, &serializedSize, + sizeof(sweepPeriod), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet to enable or disable ADC channels. */ -class SetAdcEnabledChannels: public SpacePacket { -public: +class SetAdcEnabledChannels : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param ch Defines channels to be enabled or disabled. + */ + SetAdcEnabledChannels(uint16_t ch) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_ENABLED_CHANNELS, + DEFAULT_SEQUENCE_COUNT), + ch(ch) { + initPacket(); + } - /** - * @brief Constructor - * - * @param ch Defines channels to be enabled or disabled. - */ - SetAdcEnabledChannels(uint16_t ch) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_ENABLED_CHANNELS, - DEFAULT_SEQUENCE_COUNT), ch(ch) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 4; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 4; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint16_t ch = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint16_t ch = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&ch, &data_field_ptr, &serializedSize, - sizeof(ch), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&ch, &data_field_ptr, &serializedSize, sizeof(ch), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet to configures the window size and striding step of * the moving average filter applied to the ADC readings. */ -class SetAdcWindowAndStride: public SpacePacket { -public: +class SetAdcWindowAndStride : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param windowSize + * @param stridingStepSize + */ + SetAdcWindowAndStride(uint16_t windowSize, uint16_t stridingStepSize) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_WINDOW_AND_STRIDE, + DEFAULT_SEQUENCE_COUNT), + windowSize(windowSize), + stridingStepSize(stridingStepSize) { + initPacket(); + } - /** - * @brief Constructor - * - * @param windowSize - * @param stridingStepSize - */ - SetAdcWindowAndStride(uint16_t windowSize, uint16_t stridingStepSize) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_WINDOW_AND_STRIDE, - DEFAULT_SEQUENCE_COUNT), windowSize(windowSize), stridingStepSize( - stridingStepSize) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 6; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 6; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint16_t windowSize = 0; + uint16_t stridingStepSize = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint16_t windowSize = 0; - uint16_t stridingStepSize = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&windowSize, &data_field_ptr, &serializedSize, - sizeof(windowSize), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&stridingStepSize, &data_field_ptr, &serializedSize, - sizeof(stridingStepSize), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&windowSize, &data_field_ptr, &serializedSize, + sizeof(windowSize), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&stridingStepSize, &data_field_ptr, &serializedSize, + sizeof(stridingStepSize), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet to set the ADC trigger threshold. */ -class SetAdcThreshold: public SpacePacket { -public: +class SetAdcThreshold : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param threshold + */ + SetAdcThreshold(uint32_t threshold) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_THRESHOLD, DEFAULT_SEQUENCE_COUNT), + threshold(threshold) { + initPacket(); + } - /** - * @brief Constructor - * - * @param threshold - */ - SetAdcThreshold(uint32_t threshold) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_THRESHOLD, - DEFAULT_SEQUENCE_COUNT), threshold(threshold) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 6; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 6; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint32_t threshold = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint32_t threshold = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&threshold, &data_field_ptr, &serializedSize, - sizeof(threshold), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&threshold, &data_field_ptr, &serializedSize, + sizeof(threshold), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet to select between NVM 0 and NVM 1. */ -class SelectNvm: public SpacePacket { -public: +class SelectNvm : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param mem 0 - select NVM0, 1 - select NVM1. + */ + SelectNvm(uint8_t mem) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SELECT_NVM, DEFAULT_SEQUENCE_COUNT), + mem(mem) { + initPacket(); + } - /** - * @brief Constructor - * - * @param mem 0 - select NVM0, 1 - select NVM1. - */ - SelectNvm(uint8_t mem) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SELECT_NVM, - DEFAULT_SEQUENCE_COUNT), mem(mem) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 3; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 3; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t mem = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t mem = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&mem, &data_field_ptr, &serializedSize, - sizeof(mem), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&mem, &data_field_ptr, &serializedSize, sizeof(mem), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet to power the NVMs on or off. */ -class EnableNvms: public SpacePacket { -public: +class EnableNvms : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param n01 Set to one to power NVM0 and NVM1 on. 0 powers off memory. + * @param n3 Set to one to power NVM3 on. 0 powers off the memory. + */ + EnableNvms(uint8_t n01, uint8_t n3) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_ENABLE_NVMS, DEFAULT_SEQUENCE_COUNT), + n01(n01), + n3(n3) { + initPacket(); + } - /** - * @brief Constructor - * - * @param n01 Set to one to power NVM0 and NVM1 on. 0 powers off memory. - * @param n3 Set to one to power NVM3 on. 0 powers off the memory. - */ - EnableNvms(uint8_t n01, uint8_t n3) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_ENABLE_NVMS, - DEFAULT_SEQUENCE_COUNT), n01(n01), n3(n3) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 4; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 4; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t n01 = 0; + uint8_t n3 = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t n01 = 0; - uint8_t n3 = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&n01, &data_field_ptr, &serializedSize, - sizeof(n01), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&n3, &data_field_ptr, &serializedSize, - sizeof(n3), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&n01, &data_field_ptr, &serializedSize, sizeof(n01), + SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&n3, &data_field_ptr, &serializedSize, sizeof(n3), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet to run auto EM tests. */ -class RunAutoEmTests: public SpacePacket { -public: +class RunAutoEmTests : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param test 1 - complete EM test, 2 - Short test (only memory readback NVM0,1,3) + */ + RunAutoEmTests(uint8_t test) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_RUN_AUTO_EM_TESTS, DEFAULT_SEQUENCE_COUNT), + test(test) { + initPacket(); + } - /** - * @brief Constructor - * - * @param test 1 - complete EM test, 2 - Short test (only memory readback NVM0,1,3) - */ - RunAutoEmTests(uint8_t test) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_RUN_AUTO_EM_TESTS, - DEFAULT_SEQUENCE_COUNT), test(test) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 3; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 3; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t test = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t test = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&test, &data_field_ptr, &serializedSize, - sizeof(test), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&test, &data_field_ptr, &serializedSize, sizeof(test), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet causing the supervisor to print the CPU load to * the debug output. */ -class PrintCpuStats: public SpacePacket { -public: +class PrintCpuStats : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param en Print is enabled if en != 0 + */ + PrintCpuStats(uint8_t en) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_PRINT_CPU_STATS, DEFAULT_SEQUENCE_COUNT), + en(en) { + initPacket(); + } - /** - * @brief Constructor - * - * @param en Print is enabled if en != 0 - */ - PrintCpuStats(uint8_t en) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_PRINT_CPU_STATS, - DEFAULT_SEQUENCE_COUNT), en(en) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 3; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 3; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t en = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t en = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&en, &data_field_ptr, &serializedSize, - sizeof(en), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&en, &data_field_ptr, &serializedSize, sizeof(en), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet to set the print verbosity in the supervisor * software. */ -class SetDbgVerbosity: public SpacePacket { -public: +class SetDbgVerbosity : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param vb 0: None, 1: Error, 2: Warn, 3: Info + */ + SetDbgVerbosity(uint8_t vb) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_DBG_VERBOSITY, DEFAULT_SEQUENCE_COUNT), + vb(vb) { + initPacket(); + } - /** - * @brief Constructor - * - * @param vb 0: None, 1: Error, 2: Warn, 3: Info - */ - SetDbgVerbosity(uint8_t vb) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_DBG_VERBOSITY, - DEFAULT_SEQUENCE_COUNT), vb(vb) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 3; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 3; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t vb = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t vb = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&vb, &data_field_ptr, &serializedSize, - sizeof(vb), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&vb, &data_field_ptr, &serializedSize, sizeof(vb), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; - /** * @brief This class packages the space packet to wipe or dump parts of the MRAM. */ -class MramCmd: public SpacePacket { -public: +class MramCmd : public SpacePacket { + public: + enum class MramAction { WIPE, DUMP }; - enum class MramAction { - WIPE, - DUMP - }; - - /** - * @brief Constructor - * - * @param start Start address of the MRAM section to wipe or dump - * @param stop End address of the MRAM section to wipe or dump - * @param action Dump or wipe MRAM - * - * @note The content at the stop address is excluded from the dump or wipe operation. - */ - MramCmd(uint32_t start, uint32_t stop, MramAction action) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_IDLE_PACKET, - DEFAULT_SEQUENCE_COUNT), start(start), stop(stop) { - if(action == MramAction::WIPE) { - this->setAPID(APID_WIPE_MRAM); - } - else if (action == MramAction::DUMP) { - this->setAPID(APID_DUMP_MRAM); - } - else { - sif::debug << "WipeMram: Invalid action specified"; - } - initPacket(); + /** + * @brief Constructor + * + * @param start Start address of the MRAM section to wipe or dump + * @param stop End address of the MRAM section to wipe or dump + * @param action Dump or wipe MRAM + * + * @note The content at the stop address is excluded from the dump or wipe operation. + */ + MramCmd(uint32_t start, uint32_t stop, MramAction action) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_IDLE_PACKET, DEFAULT_SEQUENCE_COUNT), + start(start), + stop(stop) { + if (action == MramAction::WIPE) { + this->setAPID(APID_WIPE_MRAM); + } else if (action == MramAction::DUMP) { + this->setAPID(APID_DUMP_MRAM); + } else { + sif::debug << "WipeMram: Invalid action specified"; } + initPacket(); + } -private: + private: + static const uint16_t DATA_FIELD_LENGTH = 8; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; - static const uint16_t DATA_FIELD_LENGTH = 8; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; + uint32_t start = 0; + uint32_t stop = 0; - uint32_t start = 0; - uint32_t stop = 0; - - void initPacket() { - uint8_t concatBuffer[6]; - concatBuffer[0] = static_cast(start >> 16); - concatBuffer[1] = static_cast(start >> 8); - concatBuffer[2] = static_cast(start); - concatBuffer[3] = static_cast(stop >> 16); - concatBuffer[4] = static_cast(stop >> 8); - concatBuffer[5] = static_cast(stop); - uint8_t* data_field_ptr = this->localData.fields.buffer; - std::memcpy(data_field_ptr, concatBuffer, sizeof(concatBuffer)); - size_t serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + uint8_t concatBuffer[6]; + concatBuffer[0] = static_cast(start >> 16); + concatBuffer[1] = static_cast(start >> 8); + concatBuffer[2] = static_cast(start); + concatBuffer[3] = static_cast(stop >> 16); + concatBuffer[4] = static_cast(stop >> 8); + concatBuffer[5] = static_cast(stop); + uint8_t* data_field_ptr = this->localData.fields.buffer; + std::memcpy(data_field_ptr, concatBuffer, sizeof(concatBuffer)); + size_t serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet change the state of a GPIO. This command is only * required for ground testing. */ -class SetGpio: public SpacePacket { -public: +class SetGpio : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param port + * @param pin + * @param val + */ + SetGpio(uint8_t port, uint8_t pin, uint8_t val) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_GPIO, DEFAULT_SEQUENCE_COUNT), + port(port), + pin(pin), + val(val) { + initPacket(); + } - /** - * @brief Constructor - * - * @param port - * @param pin - * @param val - */ - SetGpio(uint8_t port, uint8_t pin, uint8_t val) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_GPIO, - DEFAULT_SEQUENCE_COUNT), port(port), pin(pin), val(val) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 5; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 5; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t port = 0; + uint8_t pin = 0; + uint8_t val = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t port = 0; - uint8_t pin = 0; - uint8_t val = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&port, &data_field_ptr, &serializedSize, - sizeof(port), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&pin, &data_field_ptr, &serializedSize, - sizeof(pin), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&val, &data_field_ptr, &serializedSize, - sizeof(val), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&port, &data_field_ptr, &serializedSize, sizeof(port), + SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&pin, &data_field_ptr, &serializedSize, sizeof(pin), + SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&val, &data_field_ptr, &serializedSize, sizeof(val), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet causing the supervisor print the state of a GPIO * to the debug output. */ -class ReadGpio: public SpacePacket { -public: +class ReadGpio : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param port + * @param pin + */ + ReadGpio(uint8_t port, uint8_t pin) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_READ_GPIO, DEFAULT_SEQUENCE_COUNT), + port(port), + pin(pin) { + initPacket(); + } - /** - * @brief Constructor - * - * @param port - * @param pin - */ - ReadGpio(uint8_t port, uint8_t pin) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_READ_GPIO, - DEFAULT_SEQUENCE_COUNT), port(port), pin(pin) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 4; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 4; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t port = 0; + uint8_t pin = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t port = 0; - uint8_t pin = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&port, &data_field_ptr, &serializedSize, - sizeof(port), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&pin, &data_field_ptr, &serializedSize, - sizeof(pin), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&port, &data_field_ptr, &serializedSize, sizeof(port), + SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&pin, &data_field_ptr, &serializedSize, sizeof(pin), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** @@ -1355,255 +1311,236 @@ private: * OP = 0x01: Only the mirror entries will be wiped. * OP = 0x02: Only the circular entries will be wiped. */ -class FactoryReset: public SpacePacket { -public: +class FactoryReset : public SpacePacket { + public: + enum class Op { CLEAR_ALL, MIRROR_ENTRIES, CIRCULAR_ENTRIES }; - enum class Op { - CLEAR_ALL, - MIRROR_ENTRIES, - CIRCULAR_ENTRIES - }; + /** + * @brief Constructor + * + * @param op + */ + FactoryReset(Op op) : SpacePacket(0, true, APID_FACTORY_RESET, DEFAULT_SEQUENCE_COUNT), op(op) { + initPacket(); + } - /** - * @brief Constructor - * - * @param op - */ - FactoryReset(Op op) : - SpacePacket(0, true, APID_FACTORY_RESET, - DEFAULT_SEQUENCE_COUNT), op(op) { - initPacket(); - } - -private: - - uint16_t packetLen = 1; // only CRC in data field - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; - - uint8_t crcOffset = 0; - - Op op = Op::CLEAR_ALL; - - void initPacket() { - - uint8_t* data_field_ptr = this->localData.fields.buffer; - - switch(op) { - case Op::MIRROR_ENTRIES: - *data_field_ptr = 1; - packetLen = 2; - crcOffset = 1; - break; - case Op::CIRCULAR_ENTRIES: - *data_field_ptr = 2; - packetLen = 2; - crcOffset = 1; - break; - default: - break; - } - this->setPacketDataLength(packetLen); - size_t serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + packetLen - 1); - uint8_t* crcPos = this->localData.fields.buffer + crcOffset; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); + private: + uint16_t packetLen = 1; // only CRC in data field + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + + uint8_t crcOffset = 0; + + Op op = Op::CLEAR_ALL; + + void initPacket() { + uint8_t* data_field_ptr = this->localData.fields.buffer; + + switch (op) { + case Op::MIRROR_ENTRIES: + *data_field_ptr = 1; + packetLen = 2; + crcOffset = 1; + break; + case Op::CIRCULAR_ENTRIES: + *data_field_ptr = 2; + packetLen = 2; + crcOffset = 1; + break; + default: + break; } + this->setPacketDataLength(packetLen); + size_t serializedSize = 0; + uint16_t crc = + CRC::crc16ccitt(this->localData.byteStream, sizeof(CCSDSPrimaryHeader) + packetLen - 1); + uint8_t* crcPos = this->localData.fields.buffer + crcOffset; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; class SupvTcSpacePacket : public SpacePacket { -public: - SupvTcSpacePacket(size_t payloadDataLen, uint16_t apid) : - SpacePacket(payloadDataLen + 1, true, apid, - DEFAULT_SEQUENCE_COUNT), payloadDataLen(payloadDataLen) { - } + public: + SupvTcSpacePacket(size_t payloadDataLen, uint16_t apid) + : SpacePacket(payloadDataLen + 1, true, apid, DEFAULT_SEQUENCE_COUNT), + payloadDataLen(payloadDataLen) {} - void makeCrc() { - size_t serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + payloadDataLen); - uint8_t* crcPos = this->localData.fields.buffer + payloadDataLen; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void makeCrc() { + size_t serializedSize = 0; + uint16_t crc = + CRC::crc16ccitt(this->localData.byteStream, sizeof(CCSDSPrimaryHeader) + payloadDataLen); + uint8_t* crcPos = this->localData.fields.buffer + payloadDataLen; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } -private: - // The sequence count of most of the TC packets for the supervisor is 1. - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + private: + // The sequence count of most of the TC packets for the supervisor is 1. + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; - // The size of the payload data (data field without crc size) - size_t payloadDataLen = 0; + // The size of the payload data (data field without crc size) + size_t payloadDataLen = 0; }; /** * @brief This class can be used to package the update available or update verify command. */ -class UpdateInfo: public SupvTcSpacePacket { -public: +class UpdateInfo : public SupvTcSpacePacket { + public: + /** + * @brief Constructor + * + * @param apid Packet can be used to generate the update available and the update verify + * packet. Thus the APID must be specified here. + * @param image The image to update on a NVM (A - 0, B - 1) + * @param partition The partition to update. uboot - 1, bitstream - 2, linux - 3, + * application - 4 + * @param imageSize The size of the update image + * param numPackets The number of space packets required to transfer all data. + */ + UpdateInfo(uint16_t apid, uint8_t image, uint8_t partition, uint32_t imageSize, uint32_t imageCrc, + uint32_t numPackets) + : SupvTcSpacePacket(PAYLOAD_LENGTH, apid), + image(image), + partition(partition), + imageSize(imageSize), + imageCrc(imageCrc), + numPackets(numPackets) { + initPacket(); + makeCrc(); + } - /** - * @brief Constructor - * - * @param apid Packet can be used to generate the update available and the update verify - * packet. Thus the APID must be specified here. - * @param image The image to update on a NVM (A - 0, B - 1) - * @param partition The partition to update. uboot - 1, bitstream - 2, linux - 3, - * application - 4 - * @param imageSize The size of the update image - * param numPackets The number of space packets required to transfer all data. - */ - UpdateInfo(uint16_t apid, uint8_t image, uint8_t partition, uint32_t imageSize, - uint32_t imageCrc, uint32_t numPackets) : - SupvTcSpacePacket(PAYLOAD_LENGTH, apid), image(image), partition(partition), imageSize( - imageSize), imageCrc(imageCrc), numPackets(numPackets) { - initPacket(); - makeCrc(); - } + private: + static const uint16_t PAYLOAD_LENGTH = 14; // length without CRC field -private: + uint8_t image = 0; + uint8_t partition = 0; + uint32_t imageSize = 0; + uint32_t imageCrc = 0; + uint32_t numPackets = 0; - static const uint16_t PAYLOAD_LENGTH = 14; // length without CRC field - - uint8_t image = 0; - uint8_t partition = 0; - uint32_t imageSize = 0; - uint32_t imageCrc = 0; - uint32_t numPackets = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&image, &data_field_ptr, &serializedSize, - sizeof(image), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&partition, &data_field_ptr, &serializedSize, - sizeof(partition), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&imageSize, &data_field_ptr, &serializedSize, - sizeof(imageSize), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&imageCrc, &data_field_ptr, &serializedSize, - sizeof(imageCrc), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&numPackets, &data_field_ptr, &serializedSize, - sizeof(numPackets), SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&image, &data_field_ptr, &serializedSize, sizeof(image), + SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&partition, &data_field_ptr, &serializedSize, + sizeof(partition), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&imageSize, &data_field_ptr, &serializedSize, + sizeof(imageSize), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&imageCrc, &data_field_ptr, &serializedSize, + sizeof(imageCrc), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&numPackets, &data_field_ptr, &serializedSize, + sizeof(numPackets), SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet transporting a part of an MPSoC update. */ -class UpdatePacket: public SupvTcSpacePacket { -public: +class UpdatePacket : public SupvTcSpacePacket { + public: + /** + * @brief Constructor + * + * @param payloadLength Update data length (data field length without CRC) + */ + UpdatePacket(uint16_t payloadLength) : SupvTcSpacePacket(payloadLength, APID_UPDATE_IMAGE_DATA) {} - /** - * @brief Constructor - * - * @param payloadLength Update data length (data field length without CRC) - */ - UpdatePacket(uint16_t payloadLength) : - SupvTcSpacePacket(payloadLength, APID_UPDATE_IMAGE_DATA) { - } - - /** - * @brief Returns the pointer to the beginning of the data field. - */ - uint8_t* getDataFieldPointer() { - return this->localData.fields.buffer; - } + /** + * @brief Returns the pointer to the beginning of the data field. + */ + uint8_t* getDataFieldPointer() { return this->localData.fields.buffer; } }; /** * @brief This dataset stores the boot status report of the supervisor. */ -class BootStatusReport: public StaticLocalDataSet { -public: +class BootStatusReport : public StaticLocalDataSet { + public: + BootStatusReport(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, BOOT_REPORT_SET_ID) {} - BootStatusReport(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, BOOT_REPORT_SET_ID) { - } + BootStatusReport(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, BOOT_REPORT_SET_ID)) {} - BootStatusReport(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, BOOT_REPORT_SET_ID)) { - } - - /** Information about boot status of MPSoC */ - lp_var_t bootSignal = lp_var_t(sid.objectId, PoolIds::BOOT_SIGNAL, this); - lp_var_t resetCounter = lp_var_t(sid.objectId, PoolIds::RESET_COUNTER, this); - /** Time the MPSoC needs for last boot */ - lp_var_t bootAfterMs = lp_var_t(sid.objectId, PoolIds::BOOT_AFTER_MS, this); - /** The currently set boot timeout */ - lp_var_t bootTimeoutMs = lp_var_t(sid.objectId, PoolIds::BOOT_TIMEOUT_MS, this); - lp_var_t activeNvm = lp_var_t(sid.objectId, PoolIds::ACTIVE_NVM, this); - /** States of the boot partition pins */ - lp_var_t bp0State = lp_var_t(sid.objectId, PoolIds::BP0_STATE, this); - lp_var_t bp1State = lp_var_t(sid.objectId, PoolIds::BP1_STATE, this); - lp_var_t bp2State = lp_var_t(sid.objectId, PoolIds::BP2_STATE, this); + /** Information about boot status of MPSoC */ + lp_var_t bootSignal = lp_var_t(sid.objectId, PoolIds::BOOT_SIGNAL, this); + lp_var_t resetCounter = lp_var_t(sid.objectId, PoolIds::RESET_COUNTER, this); + /** Time the MPSoC needs for last boot */ + lp_var_t bootAfterMs = lp_var_t(sid.objectId, PoolIds::BOOT_AFTER_MS, this); + /** The currently set boot timeout */ + lp_var_t bootTimeoutMs = + lp_var_t(sid.objectId, PoolIds::BOOT_TIMEOUT_MS, this); + lp_var_t activeNvm = lp_var_t(sid.objectId, PoolIds::ACTIVE_NVM, this); + /** States of the boot partition pins */ + lp_var_t bp0State = lp_var_t(sid.objectId, PoolIds::BP0_STATE, this); + lp_var_t bp1State = lp_var_t(sid.objectId, PoolIds::BP1_STATE, this); + lp_var_t bp2State = lp_var_t(sid.objectId, PoolIds::BP2_STATE, this); }; /** * @brief This dataset stores the housekeeping data of the supervisor. */ -class HkSet: public StaticLocalDataSet { -public: +class HkSet : public StaticLocalDataSet { + public: + HkSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_SET_ID) {} - HkSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, HK_SET_ID) { - } + HkSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, HK_SET_ID)) {} - HkSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, HK_SET_ID)) { - } - - lp_var_t tempPs = lp_var_t(sid.objectId, PoolIds::TEMP_PS, this); - lp_var_t tempPl = lp_var_t(sid.objectId, PoolIds::TEMP_PS, this); - lp_var_t tempSup = lp_var_t(sid.objectId, PoolIds::TEMP_SUP, this); - lp_var_t uptime = lp_var_t(sid.objectId, PoolIds::UPTIME, this); - lp_var_t cpuLoad = lp_var_t(sid.objectId, PoolIds::CPULOAD, this); - lp_var_t availableHeap = lp_var_t(sid.objectId, PoolIds::AVAILABLEHEAP, - this); - lp_var_t numTcs = lp_var_t(sid.objectId, PoolIds::NUM_TCS, this); - lp_var_t numTms = lp_var_t(sid.objectId, PoolIds::NUM_TMS, this); - lp_var_t socState = lp_var_t(sid.objectId, PoolIds::SOC_STATE, this); - lp_var_t nvm0_1_state = lp_var_t(sid.objectId, PoolIds::NVM0_1_STATE, this); - lp_var_t nvm3_state = lp_var_t(sid.objectId, PoolIds::NVM3_STATE, this); - lp_var_t missionIoState = lp_var_t(sid.objectId, PoolIds::MISSION_IO_STATE, - this); - lp_var_t fmcState = lp_var_t(sid.objectId, PoolIds::FMC_STATE, this); + lp_var_t tempPs = lp_var_t(sid.objectId, PoolIds::TEMP_PS, this); + lp_var_t tempPl = lp_var_t(sid.objectId, PoolIds::TEMP_PS, this); + lp_var_t tempSup = lp_var_t(sid.objectId, PoolIds::TEMP_SUP, this); + lp_var_t uptime = lp_var_t(sid.objectId, PoolIds::UPTIME, this); + lp_var_t cpuLoad = lp_var_t(sid.objectId, PoolIds::CPULOAD, this); + lp_var_t availableHeap = lp_var_t(sid.objectId, PoolIds::AVAILABLEHEAP, this); + lp_var_t numTcs = lp_var_t(sid.objectId, PoolIds::NUM_TCS, this); + lp_var_t numTms = lp_var_t(sid.objectId, PoolIds::NUM_TMS, this); + lp_var_t socState = lp_var_t(sid.objectId, PoolIds::SOC_STATE, this); + lp_var_t nvm0_1_state = lp_var_t(sid.objectId, PoolIds::NVM0_1_STATE, this); + lp_var_t nvm3_state = lp_var_t(sid.objectId, PoolIds::NVM3_STATE, this); + lp_var_t missionIoState = + lp_var_t(sid.objectId, PoolIds::MISSION_IO_STATE, this); + lp_var_t fmcState = lp_var_t(sid.objectId, PoolIds::FMC_STATE, this); }; /** * @brief This dataset stores the last requested latchup status report. */ -class LatchupStatusReport: public StaticLocalDataSet { -public: +class LatchupStatusReport : public StaticLocalDataSet { + public: + LatchupStatusReport(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, LATCHUP_RPT_ID) {} - LatchupStatusReport(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, LATCHUP_RPT_ID) { - } + LatchupStatusReport(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, LATCHUP_RPT_ID)) {} - LatchupStatusReport(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, LATCHUP_RPT_ID)) { - } - - lp_var_t id = lp_var_t(sid.objectId, PoolIds::LATCHUP_ID, this); - lp_var_t cnt0 = lp_var_t(sid.objectId, PoolIds::CNT0, this); - lp_var_t cnt1 = lp_var_t(sid.objectId, PoolIds::CNT1, this); - lp_var_t cnt2 = lp_var_t(sid.objectId, PoolIds::CNT2, this); - lp_var_t cnt3 = lp_var_t(sid.objectId, PoolIds::CNT3, this); - lp_var_t cnt4 = lp_var_t(sid.objectId, PoolIds::CNT4, this); - lp_var_t cnt5 = lp_var_t(sid.objectId, PoolIds::CNT5, this); - lp_var_t cnt6 = lp_var_t(sid.objectId, PoolIds::CNT6, this); - lp_var_t timeSec = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_SEC, this); - lp_var_t timeMin = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MIN, this); - lp_var_t timeHour = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_HOUR, this); - lp_var_t timeDay = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_DAY, this); - lp_var_t timeMon = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MON, this); - lp_var_t timeYear = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_YEAR, this); - lp_var_t timeMsec = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MSEC, this); - lp_var_t isSet = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_IS_SET, this); + lp_var_t id = lp_var_t(sid.objectId, PoolIds::LATCHUP_ID, this); + lp_var_t cnt0 = lp_var_t(sid.objectId, PoolIds::CNT0, this); + lp_var_t cnt1 = lp_var_t(sid.objectId, PoolIds::CNT1, this); + lp_var_t cnt2 = lp_var_t(sid.objectId, PoolIds::CNT2, this); + lp_var_t cnt3 = lp_var_t(sid.objectId, PoolIds::CNT3, this); + lp_var_t cnt4 = lp_var_t(sid.objectId, PoolIds::CNT4, this); + lp_var_t cnt5 = lp_var_t(sid.objectId, PoolIds::CNT5, this); + lp_var_t cnt6 = lp_var_t(sid.objectId, PoolIds::CNT6, this); + lp_var_t timeSec = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_SEC, this); + lp_var_t timeMin = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MIN, this); + lp_var_t timeHour = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_HOUR, this); + lp_var_t timeDay = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_DAY, this); + lp_var_t timeMon = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MON, this); + lp_var_t timeYear = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_YEAR, this); + lp_var_t timeMsec = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MSEC, this); + lp_var_t isSet = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_IS_SET, this); }; -} +} // namespace PLOC_SPV #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCSVPDEFINITIONS_H_ */ diff --git a/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.cpp b/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.cpp index 4e7c9458..9d8d7bbf 100644 --- a/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.cpp +++ b/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.cpp @@ -1,78 +1,62 @@ #include "ArcsecDatalinkLayer.h" -ArcsecDatalinkLayer::ArcsecDatalinkLayer() { - slipInit(); -} +ArcsecDatalinkLayer::ArcsecDatalinkLayer() { slipInit(); } -ArcsecDatalinkLayer::~ArcsecDatalinkLayer() { -} +ArcsecDatalinkLayer::~ArcsecDatalinkLayer() {} void ArcsecDatalinkLayer::slipInit() { - slipInfo.buffer = rxBuffer; - slipInfo.maxlength = StarTracker::MAX_FRAME_SIZE; - slipInfo.length = 0; - slipInfo.unescape_next = 0; - slipInfo.prev_state = SLIP_COMPLETE; + slipInfo.buffer = rxBuffer; + slipInfo.maxlength = StarTracker::MAX_FRAME_SIZE; + slipInfo.length = 0; + slipInfo.unescape_next = 0; + slipInfo.prev_state = SLIP_COMPLETE; } ReturnValue_t ArcsecDatalinkLayer::decodeFrame(const uint8_t* rawData, size_t rawDataSize, - size_t* bytesLeft) { - size_t bytePos = 0; - for (bytePos = 0; bytePos < rawDataSize; bytePos++) { - enum arc_dec_result decResult = arc_transport_decode_body(*(rawData + bytePos), &slipInfo, - decodedFrame, &decFrameSize); - *bytesLeft = rawDataSize - bytePos - 1; - switch (decResult) { - case ARC_DEC_INPROGRESS: { - if (bytePos == rawDataSize - 1) { - return DEC_IN_PROGRESS; - } - continue; - } - case ARC_DEC_ERROR_FRAME_SHORT: - return REPLY_TOO_SHORT; - case ARC_DEC_ERROR_CHECKSUM: - return CRC_FAILURE; - case ARC_DEC_ASYNC: - case ARC_DEC_SYNC: { - // Reset length of SLIP struct for next frame - slipInfo.length = 0; - return RETURN_OK; - } - default: - sif::debug << "ArcsecDatalinkLayer::decodeFrame: Unknown result code" << std::endl; - break; - return RETURN_FAILED; + size_t* bytesLeft) { + size_t bytePos = 0; + for (bytePos = 0; bytePos < rawDataSize; bytePos++) { + enum arc_dec_result decResult = + arc_transport_decode_body(*(rawData + bytePos), &slipInfo, decodedFrame, &decFrameSize); + *bytesLeft = rawDataSize - bytePos - 1; + switch (decResult) { + case ARC_DEC_INPROGRESS: { + if (bytePos == rawDataSize - 1) { + return DEC_IN_PROGRESS; } + continue; + } + case ARC_DEC_ERROR_FRAME_SHORT: + return REPLY_TOO_SHORT; + case ARC_DEC_ERROR_CHECKSUM: + return CRC_FAILURE; + case ARC_DEC_ASYNC: + case ARC_DEC_SYNC: { + // Reset length of SLIP struct for next frame + slipInfo.length = 0; + return RETURN_OK; + } + default: + sif::debug << "ArcsecDatalinkLayer::decodeFrame: Unknown result code" << std::endl; + break; + return RETURN_FAILED; } - return RETURN_FAILED; + } + return RETURN_FAILED; } -uint8_t ArcsecDatalinkLayer::getReplyFrameType() { - return decodedFrame[0]; -} +uint8_t ArcsecDatalinkLayer::getReplyFrameType() { return decodedFrame[0]; } -const uint8_t* ArcsecDatalinkLayer::getReply() { - return &decodedFrame[1]; -} +const uint8_t* ArcsecDatalinkLayer::getReply() { return &decodedFrame[1]; } void ArcsecDatalinkLayer::encodeFrame(const uint8_t* data, uint32_t length) { - arc_transport_encode_body(data, length, encBuffer, &encFrameSize); + arc_transport_encode_body(data, length, encBuffer, &encFrameSize); } -uint8_t* ArcsecDatalinkLayer::getEncodedFrame() { - return encBuffer; -} +uint8_t* ArcsecDatalinkLayer::getEncodedFrame() { return encBuffer; } -uint32_t ArcsecDatalinkLayer::getEncodedLength() { - return encFrameSize; -} +uint32_t ArcsecDatalinkLayer::getEncodedLength() { return encFrameSize; } -uint8_t ArcsecDatalinkLayer::getStatusField() { - return *(decodedFrame + STATUS_OFFSET); -} - -uint8_t ArcsecDatalinkLayer::getId() { - return *(decodedFrame + ID_OFFSET); -} +uint8_t ArcsecDatalinkLayer::getStatusField() { return *(decodedFrame + STATUS_OFFSET); } +uint8_t ArcsecDatalinkLayer::getId() { return *(decodedFrame + ID_OFFSET); } diff --git a/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.h b/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.h index a65881c7..6b4d3095 100644 --- a/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.h +++ b/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.h @@ -5,96 +5,94 @@ #include "fsfw/returnvalues/HasReturnvaluesIF.h" extern "C" { - #include "common/misc.h" +#include "common/misc.h" } /** * @brief Helper class to handle the datalinklayer of replies from the star tracker of arcsec. */ -class ArcsecDatalinkLayer: public HasReturnvaluesIF { -public: +class ArcsecDatalinkLayer : public HasReturnvaluesIF { + public: + static const uint8_t INTERFACE_ID = CLASS_ID::STR_HANDLER; - static const uint8_t INTERFACE_ID = CLASS_ID::STR_HANDLER; + //! [EXPORT] : [COMMENT] More data required to complete frame + static const ReturnValue_t DEC_IN_PROGRESS = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] Data too short to represent a valid frame + static const ReturnValue_t REPLY_TOO_SHORT = MAKE_RETURN_CODE(0xA1); + //! [EXPORT] : [COMMENT] Detected CRC failure in received frame + static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA2); - //! [EXPORT] : [COMMENT] More data required to complete frame - static const ReturnValue_t DEC_IN_PROGRESS = MAKE_RETURN_CODE(0xA0); - //! [EXPORT] : [COMMENT] Data too short to represent a valid frame - static const ReturnValue_t REPLY_TOO_SHORT = MAKE_RETURN_CODE(0xA1); - //! [EXPORT] : [COMMENT] Detected CRC failure in received frame - static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA2); + static const uint8_t STATUS_OK = 0; - static const uint8_t STATUS_OK = 0; + ArcsecDatalinkLayer(); + virtual ~ArcsecDatalinkLayer(); - ArcsecDatalinkLayer(); - virtual ~ArcsecDatalinkLayer(); + /** + * @brief Applies decoding to data referenced by rawData pointer + * + * @param rawData Pointer to raw data received from star tracker + * @param rawDataSize Size of raw data stream + * @param remainingBytes Number of bytes left + */ + ReturnValue_t decodeFrame(const uint8_t* rawData, size_t rawDataSize, size_t* bytesLeft); - /** - * @brief Applies decoding to data referenced by rawData pointer - * - * @param rawData Pointer to raw data received from star tracker - * @param rawDataSize Size of raw data stream - * @param remainingBytes Number of bytes left - */ - ReturnValue_t decodeFrame(const uint8_t* rawData, size_t rawDataSize, size_t* bytesLeft); + /** + * @brief SLIP encodes data pointed to by data pointer. + * + * @param data Pointer to data to encode + * @param length Length of buffer to encode + */ + void encodeFrame(const uint8_t* data, uint32_t length); - /** - * @brief SLIP encodes data pointed to by data pointer. - * - * @param data Pointer to data to encode - * @param length Length of buffer to encode - */ - void encodeFrame(const uint8_t* data, uint32_t length); + /** + * @brief Returns the frame type field of a decoded frame. + */ + uint8_t getReplyFrameType(); - /** - * @brief Returns the frame type field of a decoded frame. - */ - uint8_t getReplyFrameType(); + /** + * @brief Returns pointer to reply packet (first entry normally action ID, telemetry ID etc.) + */ + const uint8_t* getReply(); - /** - * @brief Returns pointer to reply packet (first entry normally action ID, telemetry ID etc.) - */ - const uint8_t* getReply(); + /** + * @brief Returns size of encoded frame + */ + uint32_t getEncodedLength(); - /** - * @brief Returns size of encoded frame - */ - uint32_t getEncodedLength(); + /** + * @brief Returns pointer to encoded frame + */ + uint8_t* getEncodedFrame(); - /** - * @brief Returns pointer to encoded frame - */ - uint8_t* getEncodedFrame(); + /** + * @brief Returns status of reply + */ + uint8_t getStatusField(); - /** - * @brief Returns status of reply - */ - uint8_t getStatusField(); + /** + * @brief Returns ID of reply + */ + uint8_t getId(); - /** - * @brief Returns ID of reply - */ - uint8_t getId(); + private: + static const uint8_t ID_OFFSET = 1; + static const uint8_t STATUS_OFFSET = 2; -private: + // Used by arcsec slip decoding function process received data + uint8_t rxBuffer[StarTracker::MAX_FRAME_SIZE]; + // Decoded frame will be copied to this buffer + uint8_t decodedFrame[StarTracker::MAX_FRAME_SIZE]; + // Buffer where encoded frames will be stored. First byte of encoded frame represents type of + // reply + uint8_t encBuffer[StarTracker::MAX_FRAME_SIZE * 2 + 2]; + // Size of decoded frame + uint32_t decFrameSize = 0; + // Size of encoded frame + uint32_t encFrameSize = 0; - static const uint8_t ID_OFFSET = 1; - static const uint8_t STATUS_OFFSET = 2; + slip_decode_state slipInfo; - // Used by arcsec slip decoding function process received data - uint8_t rxBuffer[StarTracker::MAX_FRAME_SIZE]; - // Decoded frame will be copied to this buffer - uint8_t decodedFrame[StarTracker::MAX_FRAME_SIZE]; - // Buffer where encoded frames will be stored. First byte of encoded frame represents type of - // reply - uint8_t encBuffer[StarTracker::MAX_FRAME_SIZE * 2 + 2]; - // Size of decoded frame - uint32_t decFrameSize = 0; - // Size of encoded frame - uint32_t encFrameSize = 0; - - slip_decode_state slipInfo; - - void slipInit(); + void slipInit(); }; #endif /* BSP_Q7S_DEVICES_ARCSECDATALINKLAYER_H_ */ diff --git a/bsp_q7s/devices/startracker/ArcsecJsonKeys.h b/bsp_q7s/devices/startracker/ArcsecJsonKeys.h index 2c598b43..67a80b88 100644 --- a/bsp_q7s/devices/startracker/ArcsecJsonKeys.h +++ b/bsp_q7s/devices/startracker/ArcsecJsonKeys.h @@ -5,122 +5,122 @@ * @brief Keys used in JSON file of ARCSEC. */ namespace arcseckeys { - static const char PROPERTIES[] = "properties"; - static const char NAME[] = "name"; - static const char VALUE[] = "value"; +static const char PROPERTIES[] = "properties"; +static const char NAME[] = "name"; +static const char VALUE[] = "value"; - static const char LIMITS[] = "limits"; - static const char ACTION[] = "action"; - static const char FPGA18CURRENT[] = "FPGA18Current"; - static const char FPGA25CURRENT[] = "FPGA25Current"; - static const char FPGA10CURRENT[] = "FPGA10Current"; - static const char MCUCURRENT[] = "MCUCurrent"; - static const char CMOS21CURRENT[] = "CMOS21Current"; - static const char CMOSPIXCURRENT[] = "CMOSPixCurrent"; - static const char CMOS33CURRENT[] = "CMOS33Current"; - static const char CMOSVRESCURRENT[] = "CMOSVResCurrent"; - static const char CMOS_TEMPERATURE[] = "CMOSTemperature"; - static const char MCU_TEMPERATURE[] = "MCUTemperature"; +static const char LIMITS[] = "limits"; +static const char ACTION[] = "action"; +static const char FPGA18CURRENT[] = "FPGA18Current"; +static const char FPGA25CURRENT[] = "FPGA25Current"; +static const char FPGA10CURRENT[] = "FPGA10Current"; +static const char MCUCURRENT[] = "MCUCurrent"; +static const char CMOS21CURRENT[] = "CMOS21Current"; +static const char CMOSPIXCURRENT[] = "CMOSPixCurrent"; +static const char CMOS33CURRENT[] = "CMOS33Current"; +static const char CMOSVRESCURRENT[] = "CMOSVResCurrent"; +static const char CMOS_TEMPERATURE[] = "CMOSTemperature"; +static const char MCU_TEMPERATURE[] = "MCUTemperature"; - static const char MOUNTING[] = "mounting"; - static const char qw[] = "qw"; - static const char qx[] = "qx"; - static const char qy[] = "qy"; - static const char qz[] = "qz"; +static const char MOUNTING[] = "mounting"; +static const char qw[] = "qw"; +static const char qx[] = "qx"; +static const char qy[] = "qy"; +static const char qz[] = "qz"; - static const char CAMERA[] = "camera"; - static const char MODE[] = "mode"; - static const char FOCALLENGTH[] = "focallength"; - static const char EXPOSURE[] = "exposure"; - static const char INTERVAL[] = "interval"; - static const char OFFSET[] = "offset"; - static const char PGAGAIN[] = "PGAGain"; - static const char ADCGAIN[] = "ADCGain"; - static const char REG_1[] = "reg1"; - static const char VAL_1[] = "val1"; - static const char REG_2[] = "reg2"; - static const char VAL_2[] = "val2"; - static const char REG_3[] = "reg3"; - static const char VAL_3[] = "val3"; - static const char REG_4[] = "reg4"; - static const char VAL_4[] = "val4"; - static const char REG_5[] = "reg5"; - static const char VAL_5[] = "val5"; - static const char REG_6[] = "reg6"; - static const char VAL_6[] = "val6"; - static const char REG_7[] = "reg7"; - static const char VAL_7[] = "val7"; - static const char REG_8[] = "reg8"; - static const char VAL_8[] = "val8"; - static const char FREQ_1[] = "freq1"; - static const char FREQ_2[] = "freq2"; +static const char CAMERA[] = "camera"; +static const char MODE[] = "mode"; +static const char FOCALLENGTH[] = "focallength"; +static const char EXPOSURE[] = "exposure"; +static const char INTERVAL[] = "interval"; +static const char OFFSET[] = "offset"; +static const char PGAGAIN[] = "PGAGain"; +static const char ADCGAIN[] = "ADCGain"; +static const char REG_1[] = "reg1"; +static const char VAL_1[] = "val1"; +static const char REG_2[] = "reg2"; +static const char VAL_2[] = "val2"; +static const char REG_3[] = "reg3"; +static const char VAL_3[] = "val3"; +static const char REG_4[] = "reg4"; +static const char VAL_4[] = "val4"; +static const char REG_5[] = "reg5"; +static const char VAL_5[] = "val5"; +static const char REG_6[] = "reg6"; +static const char VAL_6[] = "val6"; +static const char REG_7[] = "reg7"; +static const char VAL_7[] = "val7"; +static const char REG_8[] = "reg8"; +static const char VAL_8[] = "val8"; +static const char FREQ_1[] = "freq1"; +static const char FREQ_2[] = "freq2"; - static const char BLOB[] = "blob"; - static const char MIN_VALUE[] = "minValue"; - static const char MIN_DISTANCE[] = "minDistance"; - static const char NEIGHBOUR_DISTANCE[] = "neighbourDistance"; - static const char NEIGHBOUR_BRIGHT_PIXELS[] = "neighbourBrightPixels"; - static const char MIN_TOTAL_VALUE[] = "minTotalValue"; - static const char MAX_TOTAL_VALUE[] = "maxTotalValue"; - static const char MIN_BRIGHT_NEIGHBOURS[] = "minBrightNeighbours"; - static const char MAX_BRIGHT_NEIGHBOURS[] = "maxBrightNeighbours"; - static const char MAX_PIXEL_TO_CONSIDER[] = "maxPixelsToConsider"; - static const char SIGNAL_THRESHOLD[] = "signalThreshold"; - static const char DARK_THRESHOLD[] = "darkThreshold"; - static const char ENABLE_HISTOGRAM[] = "enableHistogram"; - static const char ENABLE_CONTRAST[] = "enableContrast"; - static const char BIN_MODE[] = "binMode"; +static const char BLOB[] = "blob"; +static const char MIN_VALUE[] = "minValue"; +static const char MIN_DISTANCE[] = "minDistance"; +static const char NEIGHBOUR_DISTANCE[] = "neighbourDistance"; +static const char NEIGHBOUR_BRIGHT_PIXELS[] = "neighbourBrightPixels"; +static const char MIN_TOTAL_VALUE[] = "minTotalValue"; +static const char MAX_TOTAL_VALUE[] = "maxTotalValue"; +static const char MIN_BRIGHT_NEIGHBOURS[] = "minBrightNeighbours"; +static const char MAX_BRIGHT_NEIGHBOURS[] = "maxBrightNeighbours"; +static const char MAX_PIXEL_TO_CONSIDER[] = "maxPixelsToConsider"; +static const char SIGNAL_THRESHOLD[] = "signalThreshold"; +static const char DARK_THRESHOLD[] = "darkThreshold"; +static const char ENABLE_HISTOGRAM[] = "enableHistogram"; +static const char ENABLE_CONTRAST[] = "enableContrast"; +static const char BIN_MODE[] = "binMode"; - static const char CENTROIDING[] = "centroiding"; - static const char ENABLE_FILTER[] = "enableFilter"; - static const char MAX_QUALITY[] = "maxquality"; - static const char MIN_QUALITY[] = "minquality"; - static const char MAX_INTENSITY[] = "maxintensity"; - static const char MIN_INTENSITY[] = "minintensity"; - static const char MAX_MAGNITUDE[] = "maxmagnitude"; - static const char GAUSSIAN_CMAX[] = "gaussianCmax"; - static const char GAUSSIAN_CMIN[] = "gaussianCmin"; - static const char TRANSMATRIX_00[] = "transmatrix00"; - static const char TRANSMATRIX_01[] = "transmatrix01"; - static const char TRANSMATRIX_10[] = "transmatrix10"; - static const char TRANSMATRIX_11[] = "transmatrix11"; +static const char CENTROIDING[] = "centroiding"; +static const char ENABLE_FILTER[] = "enableFilter"; +static const char MAX_QUALITY[] = "maxquality"; +static const char MIN_QUALITY[] = "minquality"; +static const char MAX_INTENSITY[] = "maxintensity"; +static const char MIN_INTENSITY[] = "minintensity"; +static const char MAX_MAGNITUDE[] = "maxmagnitude"; +static const char GAUSSIAN_CMAX[] = "gaussianCmax"; +static const char GAUSSIAN_CMIN[] = "gaussianCmin"; +static const char TRANSMATRIX_00[] = "transmatrix00"; +static const char TRANSMATRIX_01[] = "transmatrix01"; +static const char TRANSMATRIX_10[] = "transmatrix10"; +static const char TRANSMATRIX_11[] = "transmatrix11"; - static const char LISA[] = "lisa"; - static const char PREFILTER_DIST_THRESHOLD[] = "prefilterDistThreshold"; - static const char PREFILTER_ANGLE_THRESHOLD[] = "prefilterAngleThreshold"; - static const char FOV_WIDTH[] = "fov_width"; - static const char FOV_HEIGHT[] = "fov_height"; - static const char FLOAT_STAR_LIMIT[] = "float_star_limit"; - static const char CLOSE_STAR_LIMIT[] = "close_star_limit"; - static const char RATING_WEIGHT_CLOSE_STAR_COUNT[] = "rating_weight_close_star_count"; - static const char RATING_WEIGHT_FRACTION_CLOSE[] = "rating_weight_fraction_close"; - static const char RATING_WEIGHT_MEAN_SUM[] = "rating_weight_mean_sum"; - static const char RATING_WEIGHT_DB_STAR_COUNT[] = "rating_weight_db_star_count"; - static const char MAX_COMBINATIONS[] = "max_combinations"; - static const char NR_STARS_STOP[] = "nr_stars_stop"; - static const char FRACTION_CLOSE_STOP[] = "fraction_close_stop"; +static const char LISA[] = "lisa"; +static const char PREFILTER_DIST_THRESHOLD[] = "prefilterDistThreshold"; +static const char PREFILTER_ANGLE_THRESHOLD[] = "prefilterAngleThreshold"; +static const char FOV_WIDTH[] = "fov_width"; +static const char FOV_HEIGHT[] = "fov_height"; +static const char FLOAT_STAR_LIMIT[] = "float_star_limit"; +static const char CLOSE_STAR_LIMIT[] = "close_star_limit"; +static const char RATING_WEIGHT_CLOSE_STAR_COUNT[] = "rating_weight_close_star_count"; +static const char RATING_WEIGHT_FRACTION_CLOSE[] = "rating_weight_fraction_close"; +static const char RATING_WEIGHT_MEAN_SUM[] = "rating_weight_mean_sum"; +static const char RATING_WEIGHT_DB_STAR_COUNT[] = "rating_weight_db_star_count"; +static const char MAX_COMBINATIONS[] = "max_combinations"; +static const char NR_STARS_STOP[] = "nr_stars_stop"; +static const char FRACTION_CLOSE_STOP[] = "fraction_close_stop"; - static const char MATCHING[] = "matching"; - static const char SQUARED_DISTANCE_LIMIT[] = "squaredDistanceLimit"; - static const char SQUARED_SHIFT_LIMIT[] = "squaredShiftLimit"; +static const char MATCHING[] = "matching"; +static const char SQUARED_DISTANCE_LIMIT[] = "squaredDistanceLimit"; +static const char SQUARED_SHIFT_LIMIT[] = "squaredShiftLimit"; - static const char VALIDATION[] = "validation"; - static const char STABLE_COUNT[] = "stable_count"; - static const char MAX_DIFFERENCE[] = "max_difference"; - static const char MIN_TRACKER_CONFIDENCE[] = "min_trackerConfidence"; - static const char MIN_MATCHED_STARS[] = "min_matchedStars"; +static const char VALIDATION[] = "validation"; +static const char STABLE_COUNT[] = "stable_count"; +static const char MAX_DIFFERENCE[] = "max_difference"; +static const char MIN_TRACKER_CONFIDENCE[] = "min_trackerConfidence"; +static const char MIN_MATCHED_STARS[] = "min_matchedStars"; - static const char TRACKING[] = "tracking"; - static const char THIN_LIMIT[] = "thinLimit"; - static const char OUTLIER_THRESHOLD[] = "outlierThreshold"; - static const char OUTLIER_THRESHOLD_QUEST[] = "outlierThresholdQUEST"; - static const char TRACKER_CHOICE[] = "trackerChoice"; +static const char TRACKING[] = "tracking"; +static const char THIN_LIMIT[] = "thinLimit"; +static const char OUTLIER_THRESHOLD[] = "outlierThreshold"; +static const char OUTLIER_THRESHOLD_QUEST[] = "outlierThresholdQUEST"; +static const char TRACKER_CHOICE[] = "trackerChoice"; - static const char ALGO[] = "algo"; - static const char L2T_MIN_CONFIDENCE[] = "l2t_minConfidence"; - static const char L2T_MIN_MATCHED[] = "l2t_minConfidence"; - static const char T2L_MIN_CONFIDENCE[] = "t2l_minConfidence"; - static const char T2L_MIN_MATCHED[] = "t2l_minMatched"; -} +static const char ALGO[] = "algo"; +static const char L2T_MIN_CONFIDENCE[] = "l2t_minConfidence"; +static const char L2T_MIN_MATCHED[] = "l2t_minConfidence"; +static const char T2L_MIN_CONFIDENCE[] = "t2l_minConfidence"; +static const char T2L_MIN_MATCHED[] = "t2l_minMatched"; +} // namespace arcseckeys #endif /* BSP_Q7S_DEVICES_DEVICEDEFINITIONS_ARCSECJSONKEYS_H_ */ diff --git a/bsp_q7s/devices/startracker/ArcsecJsonParamBase.cpp b/bsp_q7s/devices/startracker/ArcsecJsonParamBase.cpp index 339c3fe7..3ecd1d91 100644 --- a/bsp_q7s/devices/startracker/ArcsecJsonParamBase.cpp +++ b/bsp_q7s/devices/startracker/ArcsecJsonParamBase.cpp @@ -1,94 +1,95 @@ #include "ArcsecJsonParamBase.h" + #include "ArcsecJsonKeys.h" ArcsecJsonParamBase::ArcsecJsonParamBase(std::string setName) : setName(setName) {} ReturnValue_t ArcsecJsonParamBase::create(std::string fullname, uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - result = init(fullname); - if (result != RETURN_OK) { - return result; - } - result = createCommand(buffer); + ReturnValue_t result = RETURN_OK; + result = init(fullname); + if (result != RETURN_OK) { return result; + } + result = createCommand(buffer); + return result; } ReturnValue_t ArcsecJsonParamBase::getParam(const std::string name, std::string& value) { - for (json::iterator it = set.begin(); it != set.end(); ++it) { - if ((*it)[arcseckeys::NAME] == name) { - value = (*it)[arcseckeys::VALUE]; - convertEmpty(value); - return RETURN_OK; - } + for (json::iterator it = set.begin(); it != set.end(); ++it) { + if ((*it)[arcseckeys::NAME] == name) { + value = (*it)[arcseckeys::VALUE]; + convertEmpty(value); + return RETURN_OK; } - return PARAM_NOT_EXISTS; + } + return PARAM_NOT_EXISTS; } void ArcsecJsonParamBase::convertEmpty(std::string& value) { - if (value == "") { - value = "0"; - } + if (value == "") { + value = "0"; + } } void ArcsecJsonParamBase::addfloat(const std::string value, uint8_t* buffer) { - float param = std::stof(value); - std::memcpy(buffer, ¶m, sizeof(param)); + float param = std::stof(value); + std::memcpy(buffer, ¶m, sizeof(param)); } void ArcsecJsonParamBase::adduint8(const std::string value, uint8_t* buffer) { - uint8_t param = std::stoi(value); - std::memcpy(buffer, ¶m, sizeof(param)); + uint8_t param = std::stoi(value); + std::memcpy(buffer, ¶m, sizeof(param)); } void ArcsecJsonParamBase::addint16(const std::string value, uint8_t* buffer) { - int16_t param = std::stoi(value); - std::memcpy(buffer, ¶m, sizeof(param)); + int16_t param = std::stoi(value); + std::memcpy(buffer, ¶m, sizeof(param)); } void ArcsecJsonParamBase::adduint16(const std::string value, uint8_t* buffer) { - uint16_t param = std::stoi(value); - std::memcpy(buffer, ¶m, sizeof(param)); + uint16_t param = std::stoi(value); + std::memcpy(buffer, ¶m, sizeof(param)); } void ArcsecJsonParamBase::adduint32(const std::string value, uint8_t* buffer) { - uint32_t param = std::stoi(value); - std::memcpy(buffer, ¶m, sizeof(param)); + uint32_t param = std::stoi(value); + std::memcpy(buffer, ¶m, sizeof(param)); } void ArcsecJsonParamBase::addSetParamHeader(uint8_t* buffer, uint8_t setId) { - *buffer = static_cast(TMTC_SETPARAMREQ); - *(buffer + 1) = setId; + *buffer = static_cast(TMTC_SETPARAMREQ); + *(buffer + 1) = setId; } ReturnValue_t ArcsecJsonParamBase::init(const std::string filename) { - ReturnValue_t result = RETURN_OK; - if (not std::filesystem::exists(filename)) { - sif::warning << "ArcsecJsonParamBase::init: JSON file " << filename << " does not exist" - << std::endl; - return JSON_FILE_NOT_EXISTS; - } - createJsonObject(filename); - result = initSet(); - if (result != RETURN_OK) { - return result; - } - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + if (not std::filesystem::exists(filename)) { + sif::warning << "ArcsecJsonParamBase::init: JSON file " << filename << " does not exist" + << std::endl; + return JSON_FILE_NOT_EXISTS; + } + createJsonObject(filename); + result = initSet(); + if (result != RETURN_OK) { + return result; + } + return RETURN_OK; } void ArcsecJsonParamBase::createJsonObject(const std::string fullname) { - json j; - std::ifstream file(fullname); - file >> j; - file.close(); - properties = j[arcseckeys::PROPERTIES]; + json j; + std::ifstream file(fullname); + file >> j; + file.close(); + properties = j[arcseckeys::PROPERTIES]; } ReturnValue_t ArcsecJsonParamBase::initSet() { - for (json::iterator it = properties.begin(); it != properties.end(); ++it) { - if ((*it)["name"] == setName) { - set = (*it)["fields"]; - return RETURN_OK; - } + for (json::iterator it = properties.begin(); it != properties.end(); ++it) { + if ((*it)["name"] == setName) { + set = (*it)["fields"]; + return RETURN_OK; } - return SET_NOT_EXISTS; + } + return SET_NOT_EXISTS; } diff --git a/bsp_q7s/devices/startracker/ArcsecJsonParamBase.h b/bsp_q7s/devices/startracker/ArcsecJsonParamBase.h index 320eff53..a3e7528f 100644 --- a/bsp_q7s/devices/startracker/ArcsecJsonParamBase.h +++ b/bsp_q7s/devices/startracker/ArcsecJsonParamBase.h @@ -1,16 +1,16 @@ #ifndef BSP_Q7S_DEVICES_STARTRACKER_ARCSECJSONPARAMBASE_H_ #define BSP_Q7S_DEVICES_STARTRACKER_ARCSECJSONPARAMBASE_H_ -#include #include +#include #include -#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "StarTrackerDefinitions.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" extern "C" { - #include "thirdparty/arcsec_star_tracker/common/generated/tmtcstructs.h" - #include "thirdparty/arcsec_star_tracker/common/genericstructs.h" +#include "thirdparty/arcsec_star_tracker/common/generated/tmtcstructs.h" +#include "thirdparty/arcsec_star_tracker/common/genericstructs.h" } using json = nlohmann::json; @@ -23,127 +23,124 @@ using json = nlohmann::json; * @author J. Meier */ class ArcsecJsonParamBase : public HasReturnvaluesIF { -public: + public: + static const uint8_t INTERFACE_ID = CLASS_ID::ARCSEC_JSON_BASE; + //! [EXPORT] : [COMMENT] Specified json file does not exist + static const ReturnValue_t JSON_FILE_NOT_EXISTS = MAKE_RETURN_CODE(1); + //! [EXPORT] : [COMMENT] Requested set does not exist in json file + static const ReturnValue_t SET_NOT_EXISTS = MAKE_RETURN_CODE(2); + //! [EXPORT] : [COMMENT] Requested parameter does not exist in json file + static const ReturnValue_t PARAM_NOT_EXISTS = MAKE_RETURN_CODE(3); - static const uint8_t INTERFACE_ID = CLASS_ID::ARCSEC_JSON_BASE; - //! [EXPORT] : [COMMENT] Specified json file does not exist - static const ReturnValue_t JSON_FILE_NOT_EXISTS = MAKE_RETURN_CODE(1); - //! [EXPORT] : [COMMENT] Requested set does not exist in json file - static const ReturnValue_t SET_NOT_EXISTS = MAKE_RETURN_CODE(2); - //! [EXPORT] : [COMMENT] Requested parameter does not exist in json file - static const ReturnValue_t PARAM_NOT_EXISTS = MAKE_RETURN_CODE(3); + /** + * @brief Constructor + * + * @param fullname Name with absolute path of json file containing the parameters to set. + */ + ArcsecJsonParamBase(std::string setName); - /** - * @brief Constructor - * - * @param fullname Name with absolute path of json file containing the parameters to set. - */ - ArcsecJsonParamBase(std::string setName); + /** + * @brief Fills a buffer with a parameter set + * + * @param fullname The name including the absolute path of the json file containing the + * parameter set. + * @param buffer Pointer to the buffer the command will be written to + */ + ReturnValue_t create(std::string fullname, uint8_t* buffer); - /** - * @brief Fills a buffer with a parameter set - * - * @param fullname The name including the absolute path of the json file containing the - * parameter set. - * @param buffer Pointer to the buffer the command will be written to - */ - ReturnValue_t create(std::string fullname, uint8_t* buffer); + /** + * @brief Returns the size of the parameter command. + */ + virtual size_t getSize() = 0; - /** - * @brief Returns the size of the parameter command. - */ - virtual size_t getSize() = 0; + protected: + /** + * @brief Reads the value of a parameter from a json set + * + * @param name The name of the parameter + * @param value The string representation of the read value + * + * @return RETURN_OK if successful, otherwise PARAM_NOT_EXISTS + */ + ReturnValue_t getParam(const std::string name, std::string& value); -protected: + /** + * @brief Converts empty string which is equal to define a value as zero. + */ + void convertEmpty(std::string& value); - /** - * @brief Reads the value of a parameter from a json set - * - * @param name The name of the parameter - * @param value The string representation of the read value - * - * @return RETURN_OK if successful, otherwise PARAM_NOT_EXISTS - */ - ReturnValue_t getParam(const std::string name, std::string& value); + /** + * @brief This function adds a float represented as string to a buffer + * + * @param value The float in string representation to add + * @param buffer Pointer to the buffer the float will be written to + */ + void addfloat(const std::string value, uint8_t* buffer); - /** - * @brief Converts empty string which is equal to define a value as zero. - */ - void convertEmpty(std::string& value); + /** + * @brief This function adds a uint8_t represented as string to a buffer + * + * @param value The uint8_t in string representation to add + * @param buffer Pointer to the buffer the uint8_t will be written to + */ + void adduint8(const std::string value, uint8_t* buffer); - /** - * @brief This function adds a float represented as string to a buffer - * - * @param value The float in string representation to add - * @param buffer Pointer to the buffer the float will be written to - */ - void addfloat(const std::string value, uint8_t* buffer); + /** + * @brief This function adds a int16_t represented as string to a buffer + * + * @param value The int16_t in string representation to add + * @param buffer Pointer to the buffer the int16_t will be written to + */ + void addint16(const std::string value, uint8_t* buffer); - /** - * @brief This function adds a uint8_t represented as string to a buffer - * - * @param value The uint8_t in string representation to add - * @param buffer Pointer to the buffer the uint8_t will be written to - */ - void adduint8(const std::string value, uint8_t* buffer); + /** + * @brief This function adds a uint16_t represented as string to a buffer + * + * @param value The uint16_t in string representation to add + * @param buffer Pointer to the buffer the uint16_t will be written to + */ + void adduint16(const std::string value, uint8_t* buffer); - /** - * @brief This function adds a int16_t represented as string to a buffer - * - * @param value The int16_t in string representation to add - * @param buffer Pointer to the buffer the int16_t will be written to - */ - void addint16(const std::string value, uint8_t* buffer); + /** + * @brief This function adds a uint32_t represented as string to a buffer + * + * @param value The uint32_t in string representation to add + * @param buffer Pointer to the buffer the uint32_t will be written to + */ + void adduint32(const std::string value, uint8_t* buffer); - /** - * @brief This function adds a uint16_t represented as string to a buffer - * - * @param value The uint16_t in string representation to add - * @param buffer Pointer to the buffer the uint16_t will be written to - */ - void adduint16(const std::string value, uint8_t* buffer); + void addSetParamHeader(uint8_t* buffer, uint8_t setId); - /** - * @brief This function adds a uint32_t represented as string to a buffer - * - * @param value The uint32_t in string representation to add - * @param buffer Pointer to the buffer the uint32_t will be written to - */ - void adduint32(const std::string value, uint8_t* buffer); + private: + json properties; + json set; + std::string setName; - void addSetParamHeader(uint8_t* buffer, uint8_t setId); + /** + * @brief This function must be implemented by the derived class to define creation of a + * parameter command. + */ + virtual ReturnValue_t createCommand(uint8_t* buffer) = 0; -private: + /** + * @brief Initializes the properties json object and the set json object + * + * @param fullname Name including absolute path to json file + * @param setName The name of the set to work on + * + * @param return JSON_FILE_NOT_EXISTS if specified file does not exist, otherwise + * RETURN_OK + */ + ReturnValue_t init(const std::string filename); - json properties; - json set; - std::string setName; + void createJsonObject(const std::string fullname); - /** - * @brief This function must be implemented by the derived class to define creation of a - * parameter command. - */ - virtual ReturnValue_t createCommand(uint8_t* buffer) = 0; - - /** - * @brief Initializes the properties json object and the set json object - * - * @param fullname Name including absolute path to json file - * @param setName The name of the set to work on - * - * @param return JSON_FILE_NOT_EXISTS if specified file does not exist, otherwise - * RETURN_OK - */ - ReturnValue_t init(const std::string filename); - - void createJsonObject(const std::string fullname); - - /** - * @brief Extracts the json set object form the json file - * - * @param setName The name of the set to create the json object from - */ - ReturnValue_t initSet(); + /** + * @brief Extracts the json set object form the json file + * + * @param setName The name of the set to create the json object from + */ + ReturnValue_t initSet(); }; #endif /* BSP_Q7S_DEVICES_STARTRACKER_ARCSECJSONPARAMBASE_H_ */ diff --git a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h index f1f7b7d0..c8a45683 100644 --- a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h +++ b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h @@ -1,12 +1,13 @@ #ifndef MISSION_STARTRACKER_DEFINITIONS_H_ #define MISSION_STARTRACKER_DEFINITIONS_H_ -#include +#include #include +#include #include #include + #include "objects/systemObjectList.h" -#include namespace StarTracker { @@ -15,188 +16,188 @@ static const uint8_t ADDRESS = 33; static const uint8_t STATUS_OK = 0; -enum PoolIds: lp_id_t { - TICKS_TIME_SET, - TIME_TIME_SET, - RUN_TIME, - UNIX_TIME, - TICKS_VERSION_SET, - TIME_VERSION_SET, - PROGRAM, - MAJOR, - MINOR, - TICKS_INTERFACE_SET, - TIME_INTERFACE_SET, - FRAME_COUNT, - CHECKSUM_ERROR_COUNT, - SET_PARAM_COUNT, - SET_PARAM_REPLY_COUNT, - PARAM_REQUEST_COUNT, - PARAM_REPLY_COUNT, - REQ_TM_COUNT, - TM_REPLY_COUNT, - ACTION_REQ_COUNT, - ACTION_REPLY_COUNT, - TICKS_POWER_SET, - TIME_POWER_SET, - MCU_CURRENT, - MCU_VOLTAGE, - FPGA_CORE_CURRENT, - FPGA_CORE_VOLTAGE, - FPGA_18_CURRENT, - FPGA_18_VOLTAGE, - FPGA_25_CURRENT, - FPGA_25_VOLTAGE, - CMV_21_CURRENT, - CMV_21_VOLTAGE, - CMV_PIX_CURRENT, - CMV_PIX_VOLTAGE, - CMV_33_CURRENT, - CMV_33_VOLTAGE, - CMV_RES_CURRENT, - CMV_RES_VOLTAGE, - TICKS_TEMPERATURE_SET, - TIME_TEMPERATURE_SET, - MCU_TEMPERATURE, - CMOS_TEMPERATURE, - TICKS_SOLUTION_SET, - TIME_SOLUTION_SET, - CALI_QW, - CALI_QX, - CALI_QY, - CALI_QZ, - TRACK_CONFIDENCE, - TRACK_QW, - TRACK_QX, - TRACK_QY, - TRACK_QZ, - TRACK_REMOVED, - STARS_CENTROIDED, - STARS_MATCHED_DATABASE, - LISA_QW, - LISA_QX, - LISA_QY, - LISA_QZ, - LISA_PERC_CLOSE, - LISA_NR_CLOSE, - TRUST_WORTHY, - STABLE_COUNT, - SOLUTION_STRATEGY, - TICKS_HISTOGRAM_SET, - TIME_HISTOGRAM_SET, - HISTOGRAM_BINA0, - HISTOGRAM_BINA1, - HISTOGRAM_BINA2, - HISTOGRAM_BINA3, - HISTOGRAM_BINA4, - HISTOGRAM_BINA5, - HISTOGRAM_BINA6, - HISTOGRAM_BINA7, - HISTOGRAM_BINA8, - HISTOGRAM_BINB0, - HISTOGRAM_BINB1, - HISTOGRAM_BINB2, - HISTOGRAM_BINB3, - HISTOGRAM_BINB4, - HISTOGRAM_BINB5, - HISTOGRAM_BINB6, - HISTOGRAM_BINB7, - HISTOGRAM_BINB8, - HISTOGRAM_BINC0, - HISTOGRAM_BINC1, - HISTOGRAM_BINC2, - HISTOGRAM_BINC3, - HISTOGRAM_BINC4, - HISTOGRAM_BINC5, - HISTOGRAM_BINC6, - HISTOGRAM_BINC7, - HISTOGRAM_BINC8, - HISTOGRAM_BIND0, - HISTOGRAM_BIND1, - HISTOGRAM_BIND2, - HISTOGRAM_BIND3, - HISTOGRAM_BIND4, - HISTOGRAM_BIND5, - HISTOGRAM_BIND6, - HISTOGRAM_BIND7, - HISTOGRAM_BIND8, - TICKS_CONTRAST_SET, - TIME_CONTRAST_SET, - CONTRAST_BINA0, - CONTRAST_BINA1, - CONTRAST_BINA2, - CONTRAST_BINA3, - CONTRAST_BINA4, - CONTRAST_BINA5, - CONTRAST_BINA6, - CONTRAST_BINA7, - CONTRAST_BINA8, - CONTRAST_BINB0, - CONTRAST_BINB1, - CONTRAST_BINB2, - CONTRAST_BINB3, - CONTRAST_BINB4, - CONTRAST_BINB5, - CONTRAST_BINB6, - CONTRAST_BINB7, - CONTRAST_BINB8, - CONTRAST_BINC0, - CONTRAST_BINC1, - CONTRAST_BINC2, - CONTRAST_BINC3, - CONTRAST_BINC4, - CONTRAST_BINC5, - CONTRAST_BINC6, - CONTRAST_BINC7, - CONTRAST_BINC8, - CONTRAST_BIND0, - CONTRAST_BIND1, - CONTRAST_BIND2, - CONTRAST_BIND3, - CONTRAST_BIND4, - CONTRAST_BIND5, - CONTRAST_BIND6, - CONTRAST_BIND7, - CONTRAST_BIND8, - CHKSUM, - DWL_ID, - DWL_PIXX, - DWL_PIXY, - DWL_X_UNCORRECTED, - DWL_Y_UNCORRECTED, - DWL_X_CORRECTED, - DWL_Y_CORRECTED, - DWL_MAGNITUDE, - DWL_CXA, - DWL_CYA, - DWL_QUALITY, - MATCHEDSTR_ID, - MATCHEDSTR_CAMFPX, - MATCHEDSTR_CAMFPY, - MATCHEDSTR_CAMCARTX, - MATCHEDSTR_CAMCARTY, - MATCHEDSTR_CAMCARTZ, - MATCHEDSTR_CAMMAGNITUDE, - MATCHEDSTR_DBFPX, - MATCHEDSTR_DBFPY, - MATCHEDSTR_DBCARTX, - MATCHEDSTR_DBCARTY, - MATCHEDSTR_DBCARTZ, - MATCHEDSTR_DBMAGNITUDE, - MATCHEDSTR_CATALOGID, - DBIMAGE_ID, - DBIMAGE_PIXX, - DBIMAGE_PIXY, - DBIMAGE_X, - DBIMAGE_Y, - DBIMAGE_MAGNITUDE, - BLOBPIX_ID, - BLOBPIX_X, - BLOBPIX_Y, - BLOBPIX_TOT_VAL, - BLOBPIX_IN_USE, - BLOBPIX_BRIGHT_NEIGHBOURS, - BLOBPIX_REGION +enum PoolIds : lp_id_t { + TICKS_TIME_SET, + TIME_TIME_SET, + RUN_TIME, + UNIX_TIME, + TICKS_VERSION_SET, + TIME_VERSION_SET, + PROGRAM, + MAJOR, + MINOR, + TICKS_INTERFACE_SET, + TIME_INTERFACE_SET, + FRAME_COUNT, + CHECKSUM_ERROR_COUNT, + SET_PARAM_COUNT, + SET_PARAM_REPLY_COUNT, + PARAM_REQUEST_COUNT, + PARAM_REPLY_COUNT, + REQ_TM_COUNT, + TM_REPLY_COUNT, + ACTION_REQ_COUNT, + ACTION_REPLY_COUNT, + TICKS_POWER_SET, + TIME_POWER_SET, + MCU_CURRENT, + MCU_VOLTAGE, + FPGA_CORE_CURRENT, + FPGA_CORE_VOLTAGE, + FPGA_18_CURRENT, + FPGA_18_VOLTAGE, + FPGA_25_CURRENT, + FPGA_25_VOLTAGE, + CMV_21_CURRENT, + CMV_21_VOLTAGE, + CMV_PIX_CURRENT, + CMV_PIX_VOLTAGE, + CMV_33_CURRENT, + CMV_33_VOLTAGE, + CMV_RES_CURRENT, + CMV_RES_VOLTAGE, + TICKS_TEMPERATURE_SET, + TIME_TEMPERATURE_SET, + MCU_TEMPERATURE, + CMOS_TEMPERATURE, + TICKS_SOLUTION_SET, + TIME_SOLUTION_SET, + CALI_QW, + CALI_QX, + CALI_QY, + CALI_QZ, + TRACK_CONFIDENCE, + TRACK_QW, + TRACK_QX, + TRACK_QY, + TRACK_QZ, + TRACK_REMOVED, + STARS_CENTROIDED, + STARS_MATCHED_DATABASE, + LISA_QW, + LISA_QX, + LISA_QY, + LISA_QZ, + LISA_PERC_CLOSE, + LISA_NR_CLOSE, + TRUST_WORTHY, + STABLE_COUNT, + SOLUTION_STRATEGY, + TICKS_HISTOGRAM_SET, + TIME_HISTOGRAM_SET, + HISTOGRAM_BINA0, + HISTOGRAM_BINA1, + HISTOGRAM_BINA2, + HISTOGRAM_BINA3, + HISTOGRAM_BINA4, + HISTOGRAM_BINA5, + HISTOGRAM_BINA6, + HISTOGRAM_BINA7, + HISTOGRAM_BINA8, + HISTOGRAM_BINB0, + HISTOGRAM_BINB1, + HISTOGRAM_BINB2, + HISTOGRAM_BINB3, + HISTOGRAM_BINB4, + HISTOGRAM_BINB5, + HISTOGRAM_BINB6, + HISTOGRAM_BINB7, + HISTOGRAM_BINB8, + HISTOGRAM_BINC0, + HISTOGRAM_BINC1, + HISTOGRAM_BINC2, + HISTOGRAM_BINC3, + HISTOGRAM_BINC4, + HISTOGRAM_BINC5, + HISTOGRAM_BINC6, + HISTOGRAM_BINC7, + HISTOGRAM_BINC8, + HISTOGRAM_BIND0, + HISTOGRAM_BIND1, + HISTOGRAM_BIND2, + HISTOGRAM_BIND3, + HISTOGRAM_BIND4, + HISTOGRAM_BIND5, + HISTOGRAM_BIND6, + HISTOGRAM_BIND7, + HISTOGRAM_BIND8, + TICKS_CONTRAST_SET, + TIME_CONTRAST_SET, + CONTRAST_BINA0, + CONTRAST_BINA1, + CONTRAST_BINA2, + CONTRAST_BINA3, + CONTRAST_BINA4, + CONTRAST_BINA5, + CONTRAST_BINA6, + CONTRAST_BINA7, + CONTRAST_BINA8, + CONTRAST_BINB0, + CONTRAST_BINB1, + CONTRAST_BINB2, + CONTRAST_BINB3, + CONTRAST_BINB4, + CONTRAST_BINB5, + CONTRAST_BINB6, + CONTRAST_BINB7, + CONTRAST_BINB8, + CONTRAST_BINC0, + CONTRAST_BINC1, + CONTRAST_BINC2, + CONTRAST_BINC3, + CONTRAST_BINC4, + CONTRAST_BINC5, + CONTRAST_BINC6, + CONTRAST_BINC7, + CONTRAST_BINC8, + CONTRAST_BIND0, + CONTRAST_BIND1, + CONTRAST_BIND2, + CONTRAST_BIND3, + CONTRAST_BIND4, + CONTRAST_BIND5, + CONTRAST_BIND6, + CONTRAST_BIND7, + CONTRAST_BIND8, + CHKSUM, + DWL_ID, + DWL_PIXX, + DWL_PIXY, + DWL_X_UNCORRECTED, + DWL_Y_UNCORRECTED, + DWL_X_CORRECTED, + DWL_Y_CORRECTED, + DWL_MAGNITUDE, + DWL_CXA, + DWL_CYA, + DWL_QUALITY, + MATCHEDSTR_ID, + MATCHEDSTR_CAMFPX, + MATCHEDSTR_CAMFPY, + MATCHEDSTR_CAMCARTX, + MATCHEDSTR_CAMCARTY, + MATCHEDSTR_CAMCARTZ, + MATCHEDSTR_CAMMAGNITUDE, + MATCHEDSTR_DBFPX, + MATCHEDSTR_DBFPY, + MATCHEDSTR_DBCARTX, + MATCHEDSTR_DBCARTY, + MATCHEDSTR_DBCARTZ, + MATCHEDSTR_DBMAGNITUDE, + MATCHEDSTR_CATALOGID, + DBIMAGE_ID, + DBIMAGE_PIXX, + DBIMAGE_PIXY, + DBIMAGE_X, + DBIMAGE_Y, + DBIMAGE_MAGNITUDE, + BLOBPIX_ID, + BLOBPIX_X, + BLOBPIX_Y, + BLOBPIX_TOT_VAL, + BLOBPIX_IN_USE, + BLOBPIX_BRIGHT_NEIGHBOURS, + BLOBPIX_REGION }; static const DeviceCommandId_t PING_REQUEST = 0; @@ -280,931 +281,768 @@ static const uint8_t DOWNLOAD_BLOBPIXEL_SET_ENTRIES = 7; // Action, parameter and telemetry IDs namespace ID { - static const uint8_t PING = 0; - static const uint8_t BOOT = 1; - static const uint8_t VERSION = 2; - static const uint8_t INTERFACE = 3; - static const uint8_t LIMITS = 5; - static const uint8_t MOUNTING = 6; - static const uint8_t CAMERA = 9; - static const uint8_t BLOB = 10; - static const uint8_t CENTROIDING = 11; - static const uint8_t LISA = 12; - static const uint8_t MATCHING = 13; - static const uint8_t TRACKING = 14; - static const uint8_t VALIDATION = 15; - static const uint8_t ALGO = 16; - static const uint8_t REBOOT = 7; - static const uint8_t UPLOAD_IMAGE = 10; - static const uint8_t POWER = 11; - static const uint8_t SET_TIME = 14; - static const uint8_t SUBSCRIBE = 18; - static const uint8_t SOLUTION = 24; - static const uint8_t TEMPERATURE = 25; - static const uint8_t HISTOGRAM = 28; - static const uint8_t CONTRAST = 29; - static const uint8_t TIME = 1; - static const uint8_t WRITE = 2; - static const uint8_t READ = 3; - static const uint8_t CHECKSUM = 4; - static const uint8_t ERASE = 5; - static const uint8_t UNLOCK = 6; - static const uint8_t TAKE_IMAGE = 15; - static const uint8_t ERROR_RESET = 12; - static const uint8_t DOWNLOAD_CENTROID = 16; - static const uint8_t UPLOAD_CENTROID = 17; - static const uint8_t DOWNLOAD_MATCHED_STAR = 18; - static const uint8_t DOWNLOAD_DBIMAGE = 19; - static const uint8_t DOWNLOAD_BLOBPIXEL = 24; - static const uint8_t FPGA_ACTION = 22; -} +static const uint8_t PING = 0; +static const uint8_t BOOT = 1; +static const uint8_t VERSION = 2; +static const uint8_t INTERFACE = 3; +static const uint8_t LIMITS = 5; +static const uint8_t MOUNTING = 6; +static const uint8_t CAMERA = 9; +static const uint8_t BLOB = 10; +static const uint8_t CENTROIDING = 11; +static const uint8_t LISA = 12; +static const uint8_t MATCHING = 13; +static const uint8_t TRACKING = 14; +static const uint8_t VALIDATION = 15; +static const uint8_t ALGO = 16; +static const uint8_t REBOOT = 7; +static const uint8_t UPLOAD_IMAGE = 10; +static const uint8_t POWER = 11; +static const uint8_t SET_TIME = 14; +static const uint8_t SUBSCRIBE = 18; +static const uint8_t SOLUTION = 24; +static const uint8_t TEMPERATURE = 25; +static const uint8_t HISTOGRAM = 28; +static const uint8_t CONTRAST = 29; +static const uint8_t TIME = 1; +static const uint8_t WRITE = 2; +static const uint8_t READ = 3; +static const uint8_t CHECKSUM = 4; +static const uint8_t ERASE = 5; +static const uint8_t UNLOCK = 6; +static const uint8_t TAKE_IMAGE = 15; +static const uint8_t ERROR_RESET = 12; +static const uint8_t DOWNLOAD_CENTROID = 16; +static const uint8_t UPLOAD_CENTROID = 17; +static const uint8_t DOWNLOAD_MATCHED_STAR = 18; +static const uint8_t DOWNLOAD_DBIMAGE = 19; +static const uint8_t DOWNLOAD_BLOBPIXEL = 24; +static const uint8_t FPGA_ACTION = 22; +} // namespace ID namespace Program { - static const uint8_t BOOTLOADER = 1; - static const uint8_t FIRMWARE = 2; -} +static const uint8_t BOOTLOADER = 1; +static const uint8_t FIRMWARE = 2; +} // namespace Program /** * @brief This dataset can be used to store the temperature of a reaction wheel. */ -class TemperatureSet: - public StaticLocalDataSet { -public: +class TemperatureSet : public StaticLocalDataSet { + public: + static const size_t SIZE = 20; - static const size_t SIZE = 20; + TemperatureSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TEMPERATURE_SET_ID) {} - TemperatureSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, TEMPERATURE_SET_ID) { - } + TemperatureSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TEMPERATURE_SET_ID)) {} - TemperatureSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, TEMPERATURE_SET_ID)) { - } + // Ticks is time reference generated by internal counter of the star tracker + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_TEMPERATURE_SET, this); + /** Unix time in microseconds */ + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_TEMPERATURE_SET, this); + lp_var_t mcuTemperature = lp_var_t(sid.objectId, PoolIds::MCU_TEMPERATURE, this); + lp_var_t cmosTemperature = lp_var_t(sid.objectId, PoolIds::CMOS_TEMPERATURE, this); - // Ticks is time reference generated by internal counter of the star tracker - lp_var_t ticks = lp_var_t(sid.objectId, - PoolIds::TICKS_TEMPERATURE_SET, this); - /** Unix time in microseconds */ - lp_var_t time = lp_var_t(sid.objectId, - PoolIds::TIME_TEMPERATURE_SET, this); - lp_var_t mcuTemperature = lp_var_t(sid.objectId, - PoolIds::MCU_TEMPERATURE, this); - lp_var_t cmosTemperature = lp_var_t(sid.objectId, - PoolIds::CMOS_TEMPERATURE, this); - - void printSet() { - sif::info << "TemperatureSet::printSet: Ticks: " - << this->ticks << std::endl; - sif::info << "TemperatureSet::printSet: Time: " - << this->time << " us" << std::endl; - sif::info << "TemperatureSet::printSet: MCU Temperature: " - << this->mcuTemperature << " °C" << std::endl; - sif::info << "TemperatureSet::printSet: CMOS Temperature: " - << this->cmosTemperature << " °C" << std::endl; - } + void printSet() { + sif::info << "TemperatureSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "TemperatureSet::printSet: Time: " << this->time << " us" << std::endl; + sif::info << "TemperatureSet::printSet: MCU Temperature: " << this->mcuTemperature << " °C" + << std::endl; + sif::info << "TemperatureSet::printSet: CMOS Temperature: " << this->cmosTemperature << " °C" + << std::endl; + } }; /** * @brief Package to store version parameters */ -class VersionSet: - public StaticLocalDataSet { -public: +class VersionSet : public StaticLocalDataSet { + public: + static const size_t SIZE = 15; - static const size_t SIZE = 15; + VersionSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, VERSION_SET_ID) {} - VersionSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, VERSION_SET_ID) { - } + VersionSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, VERSION_SET_ID)) {} - VersionSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, VERSION_SET_ID)) { - } + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_VERSION_SET, this); + /** Unix time in microseconds */ + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_VERSION_SET, this); + lp_var_t program = lp_var_t(sid.objectId, PoolIds::PROGRAM, this); + lp_var_t major = lp_var_t(sid.objectId, PoolIds::MAJOR, this); + lp_var_t minor = lp_var_t(sid.objectId, PoolIds::MINOR, this); - lp_var_t ticks = lp_var_t(sid.objectId, - PoolIds::TICKS_VERSION_SET, this); - /** Unix time in microseconds */ - lp_var_t time = lp_var_t(sid.objectId, - PoolIds::TIME_VERSION_SET, this); - lp_var_t program = lp_var_t(sid.objectId, - PoolIds::PROGRAM, this); - lp_var_t major = lp_var_t(sid.objectId, - PoolIds::MAJOR, this); - lp_var_t minor = lp_var_t(sid.objectId, - PoolIds::MINOR, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "VersionSet::printSet: Ticks: " - << this->ticks << std::endl; - sif::info << "VersionSet::printSet: Unix Time: " - << this->time << " us" << std::endl; - sif::info << "VersionSet::printSet: Program: " - << static_cast(this->program.value) << std::endl; - sif::info << "VersionSet::printSet: Major: " - << static_cast(this->major.value) << std::endl; - sif::info << "VersionSet::printSet: Minor: " - << static_cast(this->minor.value) << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "VersionSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "VersionSet::printSet: Unix Time: " << this->time << " us" << std::endl; + sif::info << "VersionSet::printSet: Program: " << static_cast(this->program.value) + << std::endl; + sif::info << "VersionSet::printSet: Major: " << static_cast(this->major.value) + << std::endl; + sif::info << "VersionSet::printSet: Minor: " << static_cast(this->minor.value) + << std::endl; + } }; /** * @brief Dataset to store the interface telemtry data. */ -class InterfaceSet: - public StaticLocalDataSet { -public: +class InterfaceSet : public StaticLocalDataSet { + public: + static const size_t SIZE = 20; - static const size_t SIZE = 20; + InterfaceSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, REQ_INTERFACE) {} - InterfaceSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, REQ_INTERFACE) { - } + InterfaceSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, REQ_INTERFACE)) {} - InterfaceSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, REQ_INTERFACE)) { - } + // Ticks is time reference generated by interanl counter of the star tracker + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_INTERFACE_SET, this); + /** Unix time in microseconds */ + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_INTERFACE_SET, this); + lp_var_t frameCount = lp_var_t(sid.objectId, PoolIds::FRAME_COUNT, this); + lp_var_t checksumerrorCount = + lp_var_t(sid.objectId, PoolIds::CHECKSUM_ERROR_COUNT, this); - // Ticks is time reference generated by interanl counter of the star tracker - lp_var_t ticks = lp_var_t(sid.objectId, - PoolIds::TICKS_INTERFACE_SET, this); - /** Unix time in microseconds */ - lp_var_t time = lp_var_t(sid.objectId, - PoolIds::TIME_INTERFACE_SET, this); - lp_var_t frameCount = lp_var_t(sid.objectId, - PoolIds::FRAME_COUNT, this); - lp_var_t checksumerrorCount = lp_var_t(sid.objectId, - PoolIds::CHECKSUM_ERROR_COUNT, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "InterfaceSet::printSet: Ticks: " - << this->ticks << std::endl; - sif::info << "InterfaceSet::printSet: Time: " - << this->time << " us" << std::endl; - sif::info << "InterfaceSet::printSet: Frame Count: " - << this->frameCount << std::endl; - sif::info << "InterfaceSet::printSet: Checksum Error Count: " - << this->checksumerrorCount << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "InterfaceSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "InterfaceSet::printSet: Time: " << this->time << " us" << std::endl; + sif::info << "InterfaceSet::printSet: Frame Count: " << this->frameCount << std::endl; + sif::info << "InterfaceSet::printSet: Checksum Error Count: " << this->checksumerrorCount + << std::endl; + } }; /** * @brief Dataset to store the data of the power telemetry reply. */ -class PowerSet: - public StaticLocalDataSet { -public: +class PowerSet : public StaticLocalDataSet { + public: + static const size_t SIZE = 76; - static const size_t SIZE = 76; + PowerSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, REQ_INTERFACE) {} - PowerSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, REQ_INTERFACE) { - } + PowerSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, REQ_INTERFACE)) {} - PowerSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, REQ_INTERFACE)) { - } + // Ticks is time reference generated by interanl counter of the star tracker + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_POWER_SET, this); + /** Unix time in microseconds */ + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_POWER_SET, this); + lp_var_t mcuCurrent = lp_var_t(sid.objectId, PoolIds::MCU_CURRENT, this); + lp_var_t mcuVoltage = lp_var_t(sid.objectId, PoolIds::MCU_VOLTAGE, this); + lp_var_t fpgaCoreCurrent = lp_var_t(sid.objectId, PoolIds::FPGA_CORE_CURRENT, this); + lp_var_t fpgaCoreVoltage = lp_var_t(sid.objectId, PoolIds::FPGA_CORE_VOLTAGE, this); + lp_var_t fpga18Current = lp_var_t(sid.objectId, PoolIds::FPGA_18_CURRENT, this); + lp_var_t fpga18Voltage = lp_var_t(sid.objectId, PoolIds::FPGA_18_VOLTAGE, this); + lp_var_t fpga25Current = lp_var_t(sid.objectId, PoolIds::FPGA_25_CURRENT, this); + lp_var_t fpga25Voltage = lp_var_t(sid.objectId, PoolIds::FPGA_25_VOLTAGE, this); + lp_var_t cmv21Current = lp_var_t(sid.objectId, PoolIds::CMV_21_CURRENT, this); + lp_var_t cmv21Voltage = lp_var_t(sid.objectId, PoolIds::CMV_21_VOLTAGE, this); + lp_var_t cmvPixCurrent = lp_var_t(sid.objectId, PoolIds::CMV_PIX_CURRENT, this); + lp_var_t cmvPixVoltage = lp_var_t(sid.objectId, PoolIds::CMV_PIX_VOLTAGE, this); + lp_var_t cmv33Current = lp_var_t(sid.objectId, PoolIds::CMV_33_CURRENT, this); + lp_var_t cmv33Voltage = lp_var_t(sid.objectId, PoolIds::CMV_33_VOLTAGE, this); + lp_var_t cmvResCurrent = lp_var_t(sid.objectId, PoolIds::CMV_RES_CURRENT, this); + lp_var_t cmvResVoltage = lp_var_t(sid.objectId, PoolIds::CMV_RES_VOLTAGE, this); - // Ticks is time reference generated by interanl counter of the star tracker - lp_var_t ticks = lp_var_t(sid.objectId, - PoolIds::TICKS_POWER_SET, this); - /** Unix time in microseconds */ - lp_var_t time = lp_var_t(sid.objectId, - PoolIds::TIME_POWER_SET, this); - lp_var_t mcuCurrent = lp_var_t(sid.objectId, - PoolIds::MCU_CURRENT, this); - lp_var_t mcuVoltage = lp_var_t(sid.objectId, - PoolIds::MCU_VOLTAGE, this); - lp_var_t fpgaCoreCurrent = lp_var_t(sid.objectId, - PoolIds::FPGA_CORE_CURRENT, this); - lp_var_t fpgaCoreVoltage = lp_var_t(sid.objectId, - PoolIds::FPGA_CORE_VOLTAGE, this); - lp_var_t fpga18Current = lp_var_t(sid.objectId, - PoolIds::FPGA_18_CURRENT, this); - lp_var_t fpga18Voltage = lp_var_t(sid.objectId, - PoolIds::FPGA_18_VOLTAGE, this); - lp_var_t fpga25Current = lp_var_t(sid.objectId, - PoolIds::FPGA_25_CURRENT, this); - lp_var_t fpga25Voltage = lp_var_t(sid.objectId, - PoolIds::FPGA_25_VOLTAGE, this); - lp_var_t cmv21Current = lp_var_t(sid.objectId, - PoolIds::CMV_21_CURRENT, this); - lp_var_t cmv21Voltage = lp_var_t(sid.objectId, - PoolIds::CMV_21_VOLTAGE, this); - lp_var_t cmvPixCurrent = lp_var_t(sid.objectId, - PoolIds::CMV_PIX_CURRENT, this); - lp_var_t cmvPixVoltage = lp_var_t(sid.objectId, - PoolIds::CMV_PIX_VOLTAGE, this); - lp_var_t cmv33Current = lp_var_t(sid.objectId, - PoolIds::CMV_33_CURRENT, this); - lp_var_t cmv33Voltage = lp_var_t(sid.objectId, - PoolIds::CMV_33_VOLTAGE, this); - lp_var_t cmvResCurrent = lp_var_t(sid.objectId, - PoolIds::CMV_RES_CURRENT, this); - lp_var_t cmvResVoltage = lp_var_t(sid.objectId, - PoolIds::CMV_RES_VOLTAGE, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "PowerSet::printSet: Ticks: " - << this->ticks << std::endl; - sif::info << "PowerSet::printSet: Time: " - << this->time << " us" << std::endl; - sif::info << "PowerSet::printSet: MCU Current: " - << this->mcuCurrent << " A" << std::endl; - sif::info << "PowerSet::printSet: MCU Voltage: " - << this->mcuVoltage << " V" << std::endl; - sif::info << "PowerSet::printSet: FPGA Core current: " - << this->fpgaCoreCurrent << " A" << std::endl; - sif::info << "PowerSet::printSet: FPGA Core voltage: " - << this->fpgaCoreVoltage << " V" << std::endl; - sif::info << "PowerSet::printSet: FPGA 18 current: " - << this->fpga18Current << " A" << std::endl; - sif::info << "PowerSet::printSet: FPGA 18 voltage: " - << this->fpga18Voltage << " V" << std::endl; - sif::info << "PowerSet::printSet: FPGA 25 current: " - << this->fpga25Current << " A" << std::endl; - sif::info << "PowerSet::printSet: FPGA 25 voltage: " - << this->fpga25Voltage << " V" << std::endl; - sif::info << "PowerSet::printSet: CMV 21 current: " - << this->cmv21Current << " A" << std::endl; - sif::info << "PowerSet::printSet: CMV 21 voltage: " - << this->cmv21Voltage << " V" << std::endl; - sif::info << "PowerSet::printSet: CMV Pix current: " - << this->cmvPixCurrent << " A" << std::endl; - sif::info << "PowerSet::printSet: CMV Pix voltage: " - << this->cmvPixVoltage << " V" << std::endl; - sif::info << "PowerSet::printSet: CMV 33 current: " - << this->cmv33Current << " A" << std::endl; - sif::info << "PowerSet::printSet: CMV 33 voltage: " - << this->cmv33Voltage << " V" << std::endl; - sif::info << "PowerSet::printSet: CMV Res current: " - << this->cmvResCurrent << " A" << std::endl; - sif::info << "PowerSet::printSet: CMV Res voltage: " - << this->cmvResVoltage << " V" << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "PowerSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "PowerSet::printSet: Time: " << this->time << " us" << std::endl; + sif::info << "PowerSet::printSet: MCU Current: " << this->mcuCurrent << " A" << std::endl; + sif::info << "PowerSet::printSet: MCU Voltage: " << this->mcuVoltage << " V" << std::endl; + sif::info << "PowerSet::printSet: FPGA Core current: " << this->fpgaCoreCurrent << " A" + << std::endl; + sif::info << "PowerSet::printSet: FPGA Core voltage: " << this->fpgaCoreVoltage << " V" + << std::endl; + sif::info << "PowerSet::printSet: FPGA 18 current: " << this->fpga18Current << " A" + << std::endl; + sif::info << "PowerSet::printSet: FPGA 18 voltage: " << this->fpga18Voltage << " V" + << std::endl; + sif::info << "PowerSet::printSet: FPGA 25 current: " << this->fpga25Current << " A" + << std::endl; + sif::info << "PowerSet::printSet: FPGA 25 voltage: " << this->fpga25Voltage << " V" + << std::endl; + sif::info << "PowerSet::printSet: CMV 21 current: " << this->cmv21Current << " A" << std::endl; + sif::info << "PowerSet::printSet: CMV 21 voltage: " << this->cmv21Voltage << " V" << std::endl; + sif::info << "PowerSet::printSet: CMV Pix current: " << this->cmvPixCurrent << " A" + << std::endl; + sif::info << "PowerSet::printSet: CMV Pix voltage: " << this->cmvPixVoltage << " V" + << std::endl; + sif::info << "PowerSet::printSet: CMV 33 current: " << this->cmv33Current << " A" << std::endl; + sif::info << "PowerSet::printSet: CMV 33 voltage: " << this->cmv33Voltage << " V" << std::endl; + sif::info << "PowerSet::printSet: CMV Res current: " << this->cmvResCurrent << " A" + << std::endl; + sif::info << "PowerSet::printSet: CMV Res voltage: " << this->cmvResVoltage << " V" + << std::endl; + } }; /** * @brief Data set to store the time telemetry packet. */ -class TimeSet: - public StaticLocalDataSet { -public: +class TimeSet : public StaticLocalDataSet { + public: + static const size_t SIZE = 24; - static const size_t SIZE = 24; + TimeSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TIME_SET_ID) {} - TimeSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, TIME_SET_ID) { - } + TimeSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TIME_SET_ID)) {} - TimeSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, TIME_SET_ID)) { - } - - lp_var_t ticks = lp_var_t(sid.objectId, - PoolIds::TICKS_TIME_SET, this); - /** Unix time in microseconds */ - lp_var_t time = lp_var_t(sid.objectId, - PoolIds::TIME_TIME_SET, this); - // Number of milliseconds since processor start-up - lp_var_t runTime = lp_var_t(sid.objectId, - PoolIds::RUN_TIME, this); - // Unix time in seconds?? --> maybe typo in datasheet. Seems to be microseconds - lp_var_t unixTime = lp_var_t(sid.objectId, - PoolIds::UNIX_TIME, this); - void printSet() { - PoolReadGuard rg(this); - sif::info << "TimeSet::printSet: Ticks: " - << this->ticks << std::endl; - sif::info << "TimeSet::printSet: Time (time stamp): " - << this->time << " us" << std::endl; - sif::info << "TimeSet::printSet: Run Time: " - << this->runTime << " ms" << std::endl; - sif::info << "TimeSet::printSet: Unix Time: " - << this->unixTime << " s" << std::endl; - } + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_TIME_SET, this); + /** Unix time in microseconds */ + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_TIME_SET, this); + // Number of milliseconds since processor start-up + lp_var_t runTime = lp_var_t(sid.objectId, PoolIds::RUN_TIME, this); + // Unix time in seconds?? --> maybe typo in datasheet. Seems to be microseconds + lp_var_t unixTime = lp_var_t(sid.objectId, PoolIds::UNIX_TIME, this); + void printSet() { + PoolReadGuard rg(this); + sif::info << "TimeSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "TimeSet::printSet: Time (time stamp): " << this->time << " us" << std::endl; + sif::info << "TimeSet::printSet: Run Time: " << this->runTime << " ms" << std::endl; + sif::info << "TimeSet::printSet: Unix Time: " << this->unixTime << " s" << std::endl; + } }; /** * @brief The solution dataset is the main dataset of the star tracker and contains the * attitude information. */ -class SolutionSet: - public StaticLocalDataSet { -public: +class SolutionSet : public StaticLocalDataSet { + public: + static const size_t SIZE = 78; - static const size_t SIZE = 78; + SolutionSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, SOLUTION_SET_ID) {} - SolutionSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, SOLUTION_SET_ID) { - } + SolutionSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, SOLUTION_SET_ID)) {} - SolutionSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, SOLUTION_SET_ID)) { - } + // Ticks timestamp + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_SOLUTION_SET, this); + /// Unix time stamp + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_SOLUTION_SET, this); + // Calibrated quaternion (takes into account the mounting quaternion), typically same as + // track q values + lp_var_t caliQw = lp_var_t(sid.objectId, PoolIds::CALI_QW, this); + lp_var_t caliQx = lp_var_t(sid.objectId, PoolIds::CALI_QX, this); + lp_var_t caliQy = lp_var_t(sid.objectId, PoolIds::CALI_QY, this); + lp_var_t caliQz = lp_var_t(sid.objectId, PoolIds::CALI_QZ, this); + // The lower this value the more confidence that the star tracker solution is correct + lp_var_t trackConfidence = lp_var_t(sid.objectId, PoolIds::TRACK_CONFIDENCE, this); + // Estimated attitude of spacecraft + lp_var_t trackQw = lp_var_t(sid.objectId, PoolIds::TRACK_QW, this); + lp_var_t trackQx = lp_var_t(sid.objectId, PoolIds::TRACK_QX, this); + lp_var_t trackQy = lp_var_t(sid.objectId, PoolIds::TRACK_QY, this); + lp_var_t trackQz = lp_var_t(sid.objectId, PoolIds::TRACK_QZ, this); + // Number of stars removed from tracking solution + lp_var_t trackRemoved = lp_var_t(sid.objectId, PoolIds::TRACK_REMOVED, this); + // Number of stars for which a valid centroid was found + lp_var_t starsCentroided = + lp_var_t(sid.objectId, PoolIds::STARS_CENTROIDED, this); + // Number of stars that matched to a database star + lp_var_t starsMatchedDatabase = + lp_var_t(sid.objectId, PoolIds::STARS_MATCHED_DATABASE, this); + // Result of LISA (lost in space algorithm), searches for stars without prior knowledge of + // attitude + lp_var_t lisaQw = lp_var_t(sid.objectId, PoolIds::LISA_QW, this); + lp_var_t lisaQx = lp_var_t(sid.objectId, PoolIds::LISA_QX, this); + lp_var_t lisaQy = lp_var_t(sid.objectId, PoolIds::LISA_QY, this); + lp_var_t lisaQz = lp_var_t(sid.objectId, PoolIds::LISA_QZ, this); + // Percentage of close stars in LISA solution + lp_var_t lisaPercentageClose = + lp_var_t(sid.objectId, PoolIds::LISA_PERC_CLOSE, this); + // Number of close stars in LISA solution + lp_var_t lisaNrClose = lp_var_t(sid.objectId, PoolIds::LISA_NR_CLOSE, this); + // Gives a combined overview of the validation parameters (1 for valid solution, otherwise 0) + lp_var_t isTrustWorthy = lp_var_t(sid.objectId, PoolIds::TRUST_WORTHY, this); + // Number of times the validation criteria was met + lp_var_t stableCount = lp_var_t(sid.objectId, PoolIds::STABLE_COUNT, this); + // Shows the autonomous mode used to obtain the star tracker attitude + lp_var_t solutionStrategy = + lp_var_t(sid.objectId, PoolIds::SOLUTION_STRATEGY, this); - // Ticks timestamp - lp_var_t ticks = lp_var_t(sid.objectId, - PoolIds::TICKS_SOLUTION_SET, this); - /// Unix time stamp - lp_var_t time = lp_var_t(sid.objectId, - PoolIds::TIME_SOLUTION_SET, this); - // Calibrated quaternion (takes into account the mounting quaternion), typically same as - // track q values - lp_var_t caliQw = lp_var_t(sid.objectId, PoolIds::CALI_QW, this); - lp_var_t caliQx = lp_var_t(sid.objectId, PoolIds::CALI_QX, this); - lp_var_t caliQy = lp_var_t(sid.objectId, PoolIds::CALI_QY, this); - lp_var_t caliQz = lp_var_t(sid.objectId, PoolIds::CALI_QZ, this); - // The lower this value the more confidence that the star tracker solution is correct - lp_var_t trackConfidence = lp_var_t(sid.objectId, PoolIds::TRACK_CONFIDENCE, - this); - // Estimated attitude of spacecraft - lp_var_t trackQw = lp_var_t(sid.objectId, PoolIds::TRACK_QW, this); - lp_var_t trackQx = lp_var_t(sid.objectId, PoolIds::TRACK_QX, this); - lp_var_t trackQy = lp_var_t(sid.objectId, PoolIds::TRACK_QY, this); - lp_var_t trackQz = lp_var_t(sid.objectId, PoolIds::TRACK_QZ, this); - // Number of stars removed from tracking solution - lp_var_t trackRemoved = lp_var_t(sid.objectId, PoolIds::TRACK_REMOVED, this); - // Number of stars for which a valid centroid was found - lp_var_t starsCentroided = lp_var_t(sid.objectId, PoolIds::STARS_CENTROIDED, - this); - // Number of stars that matched to a database star - lp_var_t starsMatchedDatabase = lp_var_t(sid.objectId, - PoolIds::STARS_MATCHED_DATABASE, this); - // Result of LISA (lost in space algorithm), searches for stars without prior knowledge of - // attitude - lp_var_t lisaQw = lp_var_t(sid.objectId, PoolIds::LISA_QW, this); - lp_var_t lisaQx = lp_var_t(sid.objectId, PoolIds::LISA_QX, this); - lp_var_t lisaQy = lp_var_t(sid.objectId, PoolIds::LISA_QY, this); - lp_var_t lisaQz = lp_var_t(sid.objectId, PoolIds::LISA_QZ, this); - // Percentage of close stars in LISA solution - lp_var_t lisaPercentageClose = lp_var_t(sid.objectId, PoolIds::LISA_PERC_CLOSE, - this); - // Number of close stars in LISA solution - lp_var_t lisaNrClose = lp_var_t(sid.objectId, PoolIds::LISA_NR_CLOSE, this); - // Gives a combined overview of the validation parameters (1 for valid solution, otherwise 0) - lp_var_t isTrustWorthy = lp_var_t(sid.objectId, PoolIds::TRUST_WORTHY, this); - // Number of times the validation criteria was met - lp_var_t stableCount = lp_var_t(sid.objectId, PoolIds::STABLE_COUNT, this); - // Shows the autonomous mode used to obtain the star tracker attitude - lp_var_t solutionStrategy = lp_var_t(sid.objectId, PoolIds::SOLUTION_STRATEGY, - this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "SolutionSet::printSet: Ticks: " - << this->ticks << std::endl; - sif::info << "SolutionSet::printSet: Time: " - << this->time << std::endl; - sif::info << "SolutionSet::printSet: Calibrated quaternion Qw: " - << this->caliQw << std::endl; - sif::info << "SolutionSet::printSet: Calibrated quaternion Qx: " - << this->caliQx << std::endl; - sif::info << "SolutionSet::printSet: Calibrated quaternion Qy: " - << this->caliQy << std::endl; - sif::info << "SolutionSet::printSet: Calibrated quaternion Qz: " - << this->caliQz << std::endl; - sif::info << "SolutionSet::printSet: Track confidence: " - << this->trackConfidence << std::endl; - sif::info << "SolutionSet::printSet: Track Qw: " - << this->trackQw << std::endl; - sif::info << "SolutionSet::printSet: Track Qx: " - << this->trackQx << std::endl; - sif::info << "SolutionSet::printSet: Track Qy: " - << this->trackQy << std::endl; - sif::info << "SolutionSet::printSet: Track Qz: " - << this->trackQz << std::endl; - sif::info << "SolutionSet::printSet: Track removed: " - << static_cast(this->trackRemoved.value) << std::endl; - sif::info << "SolutionSet::printSet: Number of stars centroided: " - << static_cast(this->starsCentroided.value) << std::endl; - sif::info << "SolutionSet::printSet: Number of stars matched database: " - << static_cast(this->starsMatchedDatabase.value) << std::endl; - sif::info << "SolutionSet::printSet: LISA Qw: " - << this->lisaQw << std::endl; - sif::info << "SolutionSet::printSet: LISA Qx: " - << this->lisaQx << std::endl; - sif::info << "SolutionSet::printSet: LISA Qy: " - << this->lisaQy << std::endl; - sif::info << "SolutionSet::printSet: LISA Qz: " - << this->lisaQz << std::endl; - sif::info << "SolutionSet::printSet: LISA Percentage close: " - << this->lisaPercentageClose << std::endl; - sif::info << "SolutionSet::printSet: LISA number of close stars: " - << static_cast(this->lisaNrClose.value) << std::endl; - sif::info << "SolutionSet::printSet: Is trust worthy: " - << static_cast(this->isTrustWorthy.value) << std::endl; - sif::info << "SolutionSet::printSet: Stable count: " - << this->stableCount << std::endl; - sif::info << "SolutionSet::printSet: Solution strategy: " - << static_cast(this->solutionStrategy.value) << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "SolutionSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "SolutionSet::printSet: Time: " << this->time << std::endl; + sif::info << "SolutionSet::printSet: Calibrated quaternion Qw: " << this->caliQw << std::endl; + sif::info << "SolutionSet::printSet: Calibrated quaternion Qx: " << this->caliQx << std::endl; + sif::info << "SolutionSet::printSet: Calibrated quaternion Qy: " << this->caliQy << std::endl; + sif::info << "SolutionSet::printSet: Calibrated quaternion Qz: " << this->caliQz << std::endl; + sif::info << "SolutionSet::printSet: Track confidence: " << this->trackConfidence << std::endl; + sif::info << "SolutionSet::printSet: Track Qw: " << this->trackQw << std::endl; + sif::info << "SolutionSet::printSet: Track Qx: " << this->trackQx << std::endl; + sif::info << "SolutionSet::printSet: Track Qy: " << this->trackQy << std::endl; + sif::info << "SolutionSet::printSet: Track Qz: " << this->trackQz << std::endl; + sif::info << "SolutionSet::printSet: Track removed: " + << static_cast(this->trackRemoved.value) << std::endl; + sif::info << "SolutionSet::printSet: Number of stars centroided: " + << static_cast(this->starsCentroided.value) << std::endl; + sif::info << "SolutionSet::printSet: Number of stars matched database: " + << static_cast(this->starsMatchedDatabase.value) << std::endl; + sif::info << "SolutionSet::printSet: LISA Qw: " << this->lisaQw << std::endl; + sif::info << "SolutionSet::printSet: LISA Qx: " << this->lisaQx << std::endl; + sif::info << "SolutionSet::printSet: LISA Qy: " << this->lisaQy << std::endl; + sif::info << "SolutionSet::printSet: LISA Qz: " << this->lisaQz << std::endl; + sif::info << "SolutionSet::printSet: LISA Percentage close: " << this->lisaPercentageClose + << std::endl; + sif::info << "SolutionSet::printSet: LISA number of close stars: " + << static_cast(this->lisaNrClose.value) << std::endl; + sif::info << "SolutionSet::printSet: Is trust worthy: " + << static_cast(this->isTrustWorthy.value) << std::endl; + sif::info << "SolutionSet::printSet: Stable count: " << this->stableCount << std::endl; + sif::info << "SolutionSet::printSet: Solution strategy: " + << static_cast(this->solutionStrategy.value) << std::endl; + } }; /** * @brief Dataset to store the histogram */ -class HistogramSet: - public StaticLocalDataSet { -public: +class HistogramSet : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 156; - // Size of dataset - static const size_t SIZE = 156; + HistogramSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HISTOGRAM_SET_ID) {} - HistogramSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, HISTOGRAM_SET_ID) { - } + HistogramSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, HISTOGRAM_SET_ID)) {} - HistogramSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, HISTOGRAM_SET_ID)) { - } + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_HISTOGRAM_SET, this); + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_HISTOGRAM_SET, this); + lp_var_t binA0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA0, this); + lp_var_t binA1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA1, this); + lp_var_t binA2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA2, this); + lp_var_t binA3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA3, this); + lp_var_t binA4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA4, this); + lp_var_t binA5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA5, this); + lp_var_t binA6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA6, this); + lp_var_t binA7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA7, this); + lp_var_t binA8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA8, this); + lp_var_t binB0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB0, this); + lp_var_t binB1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB1, this); + lp_var_t binB2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB2, this); + lp_var_t binB3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB3, this); + lp_var_t binB4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB4, this); + lp_var_t binB5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB5, this); + lp_var_t binB6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB6, this); + lp_var_t binB7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB7, this); + lp_var_t binB8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB8, this); + lp_var_t binC0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC0, this); + lp_var_t binC1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC1, this); + lp_var_t binC2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC2, this); + lp_var_t binC3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC3, this); + lp_var_t binC4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC4, this); + lp_var_t binC5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC5, this); + lp_var_t binC6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC6, this); + lp_var_t binC7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC7, this); + lp_var_t binC8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC8, this); + lp_var_t binD0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND0, this); + lp_var_t binD1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND1, this); + lp_var_t binD2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND2, this); + lp_var_t binD3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND3, this); + lp_var_t binD4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND4, this); + lp_var_t binD5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND5, this); + lp_var_t binD6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND6, this); + lp_var_t binD7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND7, this); + lp_var_t binD8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND8, this); - lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_HISTOGRAM_SET, this); - lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_HISTOGRAM_SET, this); - lp_var_t binA0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA0, this); - lp_var_t binA1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA1, this); - lp_var_t binA2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA2, this); - lp_var_t binA3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA3, this); - lp_var_t binA4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA4, this); - lp_var_t binA5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA5, this); - lp_var_t binA6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA6, this); - lp_var_t binA7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA7, this); - lp_var_t binA8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA8, this); - lp_var_t binB0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB0, this); - lp_var_t binB1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB1, this); - lp_var_t binB2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB2, this); - lp_var_t binB3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB3, this); - lp_var_t binB4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB4, this); - lp_var_t binB5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB5, this); - lp_var_t binB6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB6, this); - lp_var_t binB7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB7, this); - lp_var_t binB8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB8, this); - lp_var_t binC0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC0, this); - lp_var_t binC1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC1, this); - lp_var_t binC2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC2, this); - lp_var_t binC3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC3, this); - lp_var_t binC4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC4, this); - lp_var_t binC5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC5, this); - lp_var_t binC6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC6, this); - lp_var_t binC7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC7, this); - lp_var_t binC8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC8, this); - lp_var_t binD0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND0, this); - lp_var_t binD1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND1, this); - lp_var_t binD2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND2, this); - lp_var_t binD3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND3, this); - lp_var_t binD4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND4, this); - lp_var_t binD5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND5, this); - lp_var_t binD6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND6, this); - lp_var_t binD7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND7, this); - lp_var_t binD8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND8, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "HistogramSet::printSet: Ticks: " << this->ticks << std::endl; - sif::info << "HistogramSet::printSet: Time (time stamp): " << this->time << " us" - << std::endl; - sif::info << "HistogramSet::printSet: BinA0: " << this->binA0 << std::endl; - sif::info << "HistogramSet::printSet: BinA1: " << this->binA1 << std::endl; - sif::info << "HistogramSet::printSet: BinA2: " << this->binA2 << std::endl; - sif::info << "HistogramSet::printSet: BinA3: " << this->binA3 << std::endl; - sif::info << "HistogramSet::printSet: BinA4: " << this->binA4 << std::endl; - sif::info << "HistogramSet::printSet: BinA5: " << this->binA5 << std::endl; - sif::info << "HistogramSet::printSet: BinA6: " << this->binA6 << std::endl; - sif::info << "HistogramSet::printSet: BinA7: " << this->binA7 << std::endl; - sif::info << "HistogramSet::printSet: BinA8: " << this->binA8 << std::endl; - sif::info << "HistogramSet::printSet: BinB0: " << this->binB0 << std::endl; - sif::info << "HistogramSet::printSet: BinB1: " << this->binB1 << std::endl; - sif::info << "HistogramSet::printSet: BinB2: " << this->binB2 << std::endl; - sif::info << "HistogramSet::printSet: BinB3: " << this->binB3 << std::endl; - sif::info << "HistogramSet::printSet: BinB4: " << this->binB4 << std::endl; - sif::info << "HistogramSet::printSet: BinB5: " << this->binB5 << std::endl; - sif::info << "HistogramSet::printSet: BinB6: " << this->binB6 << std::endl; - sif::info << "HistogramSet::printSet: BinB7: " << this->binB7 << std::endl; - sif::info << "HistogramSet::printSet: BinB8: " << this->binB8 << std::endl; - sif::info << "HistogramSet::printSet: BinC0: " << this->binC0 << std::endl; - sif::info << "HistogramSet::printSet: BinC1: " << this->binC1 << std::endl; - sif::info << "HistogramSet::printSet: BinC2: " << this->binC2 << std::endl; - sif::info << "HistogramSet::printSet: BinC3: " << this->binC3 << std::endl; - sif::info << "HistogramSet::printSet: BinC4: " << this->binC4 << std::endl; - sif::info << "HistogramSet::printSet: BinC5: " << this->binC5 << std::endl; - sif::info << "HistogramSet::printSet: BinC6: " << this->binC6 << std::endl; - sif::info << "HistogramSet::printSet: BinC7: " << this->binC7 << std::endl; - sif::info << "HistogramSet::printSet: BinC8: " << this->binC8 << std::endl; - sif::info << "HistogramSet::printSet: BinD0: " << this->binD0 << std::endl; - sif::info << "HistogramSet::printSet: BinD1: " << this->binD1 << std::endl; - sif::info << "HistogramSet::printSet: BinD2: " << this->binD2 << std::endl; - sif::info << "HistogramSet::printSet: BinD3: " << this->binD3 << std::endl; - sif::info << "HistogramSet::printSet: BinD4: " << this->binD4 << std::endl; - sif::info << "HistogramSet::printSet: BinD5: " << this->binD5 << std::endl; - sif::info << "HistogramSet::printSet: BinD6: " << this->binD6 << std::endl; - sif::info << "HistogramSet::printSet: BinD7: " << this->binD7 << std::endl; - sif::info << "HistogramSet::printSet: BinD8: " << this->binD8 << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "HistogramSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "HistogramSet::printSet: Time (time stamp): " << this->time << " us" << std::endl; + sif::info << "HistogramSet::printSet: BinA0: " << this->binA0 << std::endl; + sif::info << "HistogramSet::printSet: BinA1: " << this->binA1 << std::endl; + sif::info << "HistogramSet::printSet: BinA2: " << this->binA2 << std::endl; + sif::info << "HistogramSet::printSet: BinA3: " << this->binA3 << std::endl; + sif::info << "HistogramSet::printSet: BinA4: " << this->binA4 << std::endl; + sif::info << "HistogramSet::printSet: BinA5: " << this->binA5 << std::endl; + sif::info << "HistogramSet::printSet: BinA6: " << this->binA6 << std::endl; + sif::info << "HistogramSet::printSet: BinA7: " << this->binA7 << std::endl; + sif::info << "HistogramSet::printSet: BinA8: " << this->binA8 << std::endl; + sif::info << "HistogramSet::printSet: BinB0: " << this->binB0 << std::endl; + sif::info << "HistogramSet::printSet: BinB1: " << this->binB1 << std::endl; + sif::info << "HistogramSet::printSet: BinB2: " << this->binB2 << std::endl; + sif::info << "HistogramSet::printSet: BinB3: " << this->binB3 << std::endl; + sif::info << "HistogramSet::printSet: BinB4: " << this->binB4 << std::endl; + sif::info << "HistogramSet::printSet: BinB5: " << this->binB5 << std::endl; + sif::info << "HistogramSet::printSet: BinB6: " << this->binB6 << std::endl; + sif::info << "HistogramSet::printSet: BinB7: " << this->binB7 << std::endl; + sif::info << "HistogramSet::printSet: BinB8: " << this->binB8 << std::endl; + sif::info << "HistogramSet::printSet: BinC0: " << this->binC0 << std::endl; + sif::info << "HistogramSet::printSet: BinC1: " << this->binC1 << std::endl; + sif::info << "HistogramSet::printSet: BinC2: " << this->binC2 << std::endl; + sif::info << "HistogramSet::printSet: BinC3: " << this->binC3 << std::endl; + sif::info << "HistogramSet::printSet: BinC4: " << this->binC4 << std::endl; + sif::info << "HistogramSet::printSet: BinC5: " << this->binC5 << std::endl; + sif::info << "HistogramSet::printSet: BinC6: " << this->binC6 << std::endl; + sif::info << "HistogramSet::printSet: BinC7: " << this->binC7 << std::endl; + sif::info << "HistogramSet::printSet: BinC8: " << this->binC8 << std::endl; + sif::info << "HistogramSet::printSet: BinD0: " << this->binD0 << std::endl; + sif::info << "HistogramSet::printSet: BinD1: " << this->binD1 << std::endl; + sif::info << "HistogramSet::printSet: BinD2: " << this->binD2 << std::endl; + sif::info << "HistogramSet::printSet: BinD3: " << this->binD3 << std::endl; + sif::info << "HistogramSet::printSet: BinD4: " << this->binD4 << std::endl; + sif::info << "HistogramSet::printSet: BinD5: " << this->binD5 << std::endl; + sif::info << "HistogramSet::printSet: BinD6: " << this->binD6 << std::endl; + sif::info << "HistogramSet::printSet: BinD7: " << this->binD7 << std::endl; + sif::info << "HistogramSet::printSet: BinD8: " << this->binD8 << std::endl; + } }; /** * @brief Dataset to store the contrast telemetry data */ -class ContrastSet: - public StaticLocalDataSet { -public: +class ContrastSet : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 156; - // Size of dataset - static const size_t SIZE = 156; + ContrastSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, CONTRAST_SET_ID) {} - ContrastSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, CONTRAST_SET_ID) { - } + ContrastSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, CONTRAST_SET_ID)) {} - ContrastSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, CONTRAST_SET_ID)) { - } + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_CONTRAST_SET, this); + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_CONTRAST_SET, this); + lp_var_t binA0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA0, this); + lp_var_t binA1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA1, this); + lp_var_t binA2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA2, this); + lp_var_t binA3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA3, this); + lp_var_t binA4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA4, this); + lp_var_t binA5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA5, this); + lp_var_t binA6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA6, this); + lp_var_t binA7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA7, this); + lp_var_t binA8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA8, this); + lp_var_t binb0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB0, this); + lp_var_t binB1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB1, this); + lp_var_t binB2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB2, this); + lp_var_t binB3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB3, this); + lp_var_t binB4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB4, this); + lp_var_t binB5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB5, this); + lp_var_t binB6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB6, this); + lp_var_t binB7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB7, this); + lp_var_t binB8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB8, this); + lp_var_t binC0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC0, this); + lp_var_t binC1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC1, this); + lp_var_t binC2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC2, this); + lp_var_t binC3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC3, this); + lp_var_t binC4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC4, this); + lp_var_t binC5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC5, this); + lp_var_t binC6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC6, this); + lp_var_t binC7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC7, this); + lp_var_t binC8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC8, this); + lp_var_t binD0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND0, this); + lp_var_t binD1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND1, this); + lp_var_t binD2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND2, this); + lp_var_t binD3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND3, this); + lp_var_t binD4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND4, this); + lp_var_t binD5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND5, this); + lp_var_t binD6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND6, this); + lp_var_t binD7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND7, this); + lp_var_t binD8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND8, this); - lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_CONTRAST_SET, this); - lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_CONTRAST_SET, this); - lp_var_t binA0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA0, this); - lp_var_t binA1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA1, this); - lp_var_t binA2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA2, this); - lp_var_t binA3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA3, this); - lp_var_t binA4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA4, this); - lp_var_t binA5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA5, this); - lp_var_t binA6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA6, this); - lp_var_t binA7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA7, this); - lp_var_t binA8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA8, this); - lp_var_t binb0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB0, this); - lp_var_t binB1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB1, this); - lp_var_t binB2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB2, this); - lp_var_t binB3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB3, this); - lp_var_t binB4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB4, this); - lp_var_t binB5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB5, this); - lp_var_t binB6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB6, this); - lp_var_t binB7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB7, this); - lp_var_t binB8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB8, this); - lp_var_t binC0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC0, this); - lp_var_t binC1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC1, this); - lp_var_t binC2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC2, this); - lp_var_t binC3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC3, this); - lp_var_t binC4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC4, this); - lp_var_t binC5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC5, this); - lp_var_t binC6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC6, this); - lp_var_t binC7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC7, this); - lp_var_t binC8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC8, this); - lp_var_t binD0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND0, this); - lp_var_t binD1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND1, this); - lp_var_t binD2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND2, this); - lp_var_t binD3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND3, this); - lp_var_t binD4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND4, this); - lp_var_t binD5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND5, this); - lp_var_t binD6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND6, this); - lp_var_t binD7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND7, this); - lp_var_t binD8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND8, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "ContrastSet::printSet: Ticks: " << this->ticks << std::endl; - sif::info << "ContrastSet::printSet: Time (time stamp): " << this->time << " us" - << std::endl; - sif::info << "ContrastSet::printSet: BinA0: " << this->binA0 << std::endl; - sif::info << "ContrastSet::printSet: BinA1: " << this->binA1 << std::endl; - sif::info << "ContrastSet::printSet: BinA2: " << this->binA2 << std::endl; - sif::info << "ContrastSet::printSet: BinA3: " << this->binA3 << std::endl; - sif::info << "ContrastSet::printSet: BinA4: " << this->binA4 << std::endl; - sif::info << "ContrastSet::printSet: BinA5: " << this->binA5 << std::endl; - sif::info << "ContrastSet::printSet: BinA6: " << this->binA6 << std::endl; - sif::info << "ContrastSet::printSet: BinA7: " << this->binA7 << std::endl; - sif::info << "ContrastSet::printSet: BinA8: " << this->binA8 << std::endl; - sif::info << "ContrastSet::printSet: BinB0: " << this->binA0 << std::endl; - sif::info << "ContrastSet::printSet: BinB1: " << this->binB1 << std::endl; - sif::info << "ContrastSet::printSet: BinB2: " << this->binB2 << std::endl; - sif::info << "ContrastSet::printSet: BinB3: " << this->binB3 << std::endl; - sif::info << "ContrastSet::printSet: BinB4: " << this->binB4 << std::endl; - sif::info << "ContrastSet::printSet: BinB5: " << this->binB5 << std::endl; - sif::info << "ContrastSet::printSet: BinB6: " << this->binB6 << std::endl; - sif::info << "ContrastSet::printSet: BinB7: " << this->binB7 << std::endl; - sif::info << "ContrastSet::printSet: BinB8: " << this->binB8 << std::endl; - sif::info << "ContrastSet::printSet: BinC0: " << this->binC0 << std::endl; - sif::info << "ContrastSet::printSet: BinC1: " << this->binC1 << std::endl; - sif::info << "ContrastSet::printSet: BinC2: " << this->binC2 << std::endl; - sif::info << "ContrastSet::printSet: BinC3: " << this->binC3 << std::endl; - sif::info << "ContrastSet::printSet: BinC4: " << this->binC4 << std::endl; - sif::info << "ContrastSet::printSet: BinC5: " << this->binC5 << std::endl; - sif::info << "ContrastSet::printSet: BinC6: " << this->binC6 << std::endl; - sif::info << "ContrastSet::printSet: BinC7: " << this->binC7 << std::endl; - sif::info << "ContrastSet::printSet: BinC8: " << this->binC8 << std::endl; - sif::info << "ContrastSet::printSet: BinD0: " << this->binD0 << std::endl; - sif::info << "ContrastSet::printSet: BinD1: " << this->binD1 << std::endl; - sif::info << "ContrastSet::printSet: BinD2: " << this->binD2 << std::endl; - sif::info << "ContrastSet::printSet: BinD3: " << this->binD3 << std::endl; - sif::info << "ContrastSet::printSet: BinD4: " << this->binD4 << std::endl; - sif::info << "ContrastSet::printSet: BinD5: " << this->binD5 << std::endl; - sif::info << "ContrastSet::printSet: BinD6: " << this->binD6 << std::endl; - sif::info << "ContrastSet::printSet: BinD7: " << this->binD7 << std::endl; - sif::info << "ContrastSet::printSet: BinD8: " << this->binD8 << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "ContrastSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "ContrastSet::printSet: Time (time stamp): " << this->time << " us" << std::endl; + sif::info << "ContrastSet::printSet: BinA0: " << this->binA0 << std::endl; + sif::info << "ContrastSet::printSet: BinA1: " << this->binA1 << std::endl; + sif::info << "ContrastSet::printSet: BinA2: " << this->binA2 << std::endl; + sif::info << "ContrastSet::printSet: BinA3: " << this->binA3 << std::endl; + sif::info << "ContrastSet::printSet: BinA4: " << this->binA4 << std::endl; + sif::info << "ContrastSet::printSet: BinA5: " << this->binA5 << std::endl; + sif::info << "ContrastSet::printSet: BinA6: " << this->binA6 << std::endl; + sif::info << "ContrastSet::printSet: BinA7: " << this->binA7 << std::endl; + sif::info << "ContrastSet::printSet: BinA8: " << this->binA8 << std::endl; + sif::info << "ContrastSet::printSet: BinB0: " << this->binA0 << std::endl; + sif::info << "ContrastSet::printSet: BinB1: " << this->binB1 << std::endl; + sif::info << "ContrastSet::printSet: BinB2: " << this->binB2 << std::endl; + sif::info << "ContrastSet::printSet: BinB3: " << this->binB3 << std::endl; + sif::info << "ContrastSet::printSet: BinB4: " << this->binB4 << std::endl; + sif::info << "ContrastSet::printSet: BinB5: " << this->binB5 << std::endl; + sif::info << "ContrastSet::printSet: BinB6: " << this->binB6 << std::endl; + sif::info << "ContrastSet::printSet: BinB7: " << this->binB7 << std::endl; + sif::info << "ContrastSet::printSet: BinB8: " << this->binB8 << std::endl; + sif::info << "ContrastSet::printSet: BinC0: " << this->binC0 << std::endl; + sif::info << "ContrastSet::printSet: BinC1: " << this->binC1 << std::endl; + sif::info << "ContrastSet::printSet: BinC2: " << this->binC2 << std::endl; + sif::info << "ContrastSet::printSet: BinC3: " << this->binC3 << std::endl; + sif::info << "ContrastSet::printSet: BinC4: " << this->binC4 << std::endl; + sif::info << "ContrastSet::printSet: BinC5: " << this->binC5 << std::endl; + sif::info << "ContrastSet::printSet: BinC6: " << this->binC6 << std::endl; + sif::info << "ContrastSet::printSet: BinC7: " << this->binC7 << std::endl; + sif::info << "ContrastSet::printSet: BinC8: " << this->binC8 << std::endl; + sif::info << "ContrastSet::printSet: BinD0: " << this->binD0 << std::endl; + sif::info << "ContrastSet::printSet: BinD1: " << this->binD1 << std::endl; + sif::info << "ContrastSet::printSet: BinD2: " << this->binD2 << std::endl; + sif::info << "ContrastSet::printSet: BinD3: " << this->binD3 << std::endl; + sif::info << "ContrastSet::printSet: BinD4: " << this->binD4 << std::endl; + sif::info << "ContrastSet::printSet: BinD5: " << this->binD5 << std::endl; + sif::info << "ContrastSet::printSet: BinD6: " << this->binD6 << std::endl; + sif::info << "ContrastSet::printSet: BinD7: " << this->binD7 << std::endl; + sif::info << "ContrastSet::printSet: BinD8: " << this->binD8 << std::endl; + } }; /** * @brief Helper Class to extract information from bytestream. */ class ChecksumReply { -public: - - /** - * @brief Constructor - * - * @param datafield Pointer to datafield in reply buffer - * - */ - ChecksumReply(const uint8_t* datafield) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - region = *(datafield); - const uint8_t* addressData = datafield + ADDRESS_OFFSET; - size_t size = sizeof(address); - result = SerializeAdapter::deSerialize(&address, &addressData, &size, - SerializeIF::Endianness::LITTLE); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "ChecksumReply::ChecksumReply: Failed to deserialize address" - << std::endl; - } - const uint8_t* lengthData = datafield + LENGTH_OFFSET; - size = sizeof(length); - result = SerializeAdapter::deSerialize(&length, &lengthData, &size, - SerializeIF::Endianness::LITTLE); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "ChecksumReply::ChecksumReply: Failed to deserialize length" - << std::endl; - } - const uint8_t* checksumData = datafield + CHECKSUM_OFFSET; - size = sizeof(checksum); - result = SerializeAdapter::deSerialize(&checksum, &checksumData, &size, - SerializeIF::Endianness::LITTLE); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "ChecksumReply::ChecksumReply: Failed to deserialize checksum" - << std::endl; - } + public: + /** + * @brief Constructor + * + * @param datafield Pointer to datafield in reply buffer + * + */ + ChecksumReply(const uint8_t* datafield) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + region = *(datafield); + const uint8_t* addressData = datafield + ADDRESS_OFFSET; + size_t size = sizeof(address); + result = SerializeAdapter::deSerialize(&address, &addressData, &size, + SerializeIF::Endianness::LITTLE); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "ChecksumReply::ChecksumReply: Failed to deserialize address" << std::endl; } - - uint8_t getRegion() { - return region; + const uint8_t* lengthData = datafield + LENGTH_OFFSET; + size = sizeof(length); + result = + SerializeAdapter::deSerialize(&length, &lengthData, &size, SerializeIF::Endianness::LITTLE); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "ChecksumReply::ChecksumReply: Failed to deserialize length" << std::endl; } - - uint32_t getAddress() { - return address; + const uint8_t* checksumData = datafield + CHECKSUM_OFFSET; + size = sizeof(checksum); + result = SerializeAdapter::deSerialize(&checksum, &checksumData, &size, + SerializeIF::Endianness::LITTLE); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "ChecksumReply::ChecksumReply: Failed to deserialize checksum" << std::endl; } + } - uint32_t getLength() { - return length; - } + uint8_t getRegion() { return region; } - uint32_t getChecksum() { - return checksum; - } + uint32_t getAddress() { return address; } - void printChecksum() { - sif::info << "ChecksumReply::printChecksum: 0x" << std::hex << checksum << std::endl; - } + uint32_t getLength() { return length; } -private: + uint32_t getChecksum() { return checksum; } - static const uint8_t ADDRESS_OFFSET = 1; - static const uint8_t LENGTH_OFFSET = 5; - static const uint8_t CHECKSUM_OFFSET = 9; + void printChecksum() { + sif::info << "ChecksumReply::printChecksum: 0x" << std::hex << checksum << std::endl; + } - uint8_t region = 0; - uint32_t address = 0; - uint32_t length = 0; - uint32_t checksum = 0; + private: + static const uint8_t ADDRESS_OFFSET = 1; + static const uint8_t LENGTH_OFFSET = 5; + static const uint8_t CHECKSUM_OFFSET = 9; + + uint8_t region = 0; + uint32_t address = 0; + uint32_t length = 0; + uint32_t checksum = 0; }; class EraseReply { -public: - EraseReply(const uint8_t* datafield) { - region = *datafield; - } + public: + EraseReply(const uint8_t* datafield) { region = *datafield; } - uint8_t getRegion() { - return region; - } + uint8_t getRegion() { return region; } -private: - uint8_t region = 0; + private: + uint8_t region = 0; }; -class ChecksumSet: - public StaticLocalDataSet { -public: +class ChecksumSet : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 156; - // Size of dataset - static const size_t SIZE = 156; + ChecksumSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, CHECKSUM_SET_ID) {} - ChecksumSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, CHECKSUM_SET_ID) { - } + ChecksumSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, CHECKSUM_SET_ID)) {} - ChecksumSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, CHECKSUM_SET_ID)) { - } - - lp_var_t checksum = lp_var_t(sid.objectId, PoolIds::CHKSUM, this); + lp_var_t checksum = lp_var_t(sid.objectId, PoolIds::CHKSUM, this); }; /** * @brief Dataset to store download centroid response */ -class DownloadCentroidSet: - public StaticLocalDataSet { -public: +class DownloadCentroidSet : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 34; - // Size of dataset - static const size_t SIZE = 34; + DownloadCentroidSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, DOWNLOADCENTROID_SET_ID) {} - DownloadCentroidSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, DOWNLOADCENTROID_SET_ID) { - } + DownloadCentroidSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, DOWNLOADCENTROID_SET_ID)) {} - DownloadCentroidSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, DOWNLOADCENTROID_SET_ID)) { - } + lp_var_t id = lp_var_t(sid.objectId, PoolIds::DWL_ID, this); + lp_var_t pixx = lp_var_t(sid.objectId, PoolIds::DWL_PIXX, this); + lp_var_t pixy = lp_var_t(sid.objectId, PoolIds::DWL_PIXY, this); + lp_var_t xUncorrected = lp_var_t(sid.objectId, PoolIds::DWL_X_UNCORRECTED, this); + lp_var_t yUncorrected = lp_var_t(sid.objectId, PoolIds::DWL_Y_UNCORRECTED, this); + lp_var_t xCorrected = lp_var_t(sid.objectId, PoolIds::DWL_X_CORRECTED, this); + lp_var_t yCorrected = lp_var_t(sid.objectId, PoolIds::DWL_Y_CORRECTED, this); + lp_var_t magnitude = lp_var_t(sid.objectId, PoolIds::DWL_MAGNITUDE, this); + lp_var_t cxa = lp_var_t(sid.objectId, PoolIds::DWL_CXA, this); + lp_var_t cya = lp_var_t(sid.objectId, PoolIds::DWL_CYA, this); + lp_var_t quality = lp_var_t(sid.objectId, PoolIds::DWL_QUALITY, this); - lp_var_t id = lp_var_t(sid.objectId, PoolIds::DWL_ID, this); - lp_var_t pixx = lp_var_t(sid.objectId, PoolIds::DWL_PIXX, this); - lp_var_t pixy = lp_var_t(sid.objectId, PoolIds::DWL_PIXY, this); - lp_var_t xUncorrected = lp_var_t(sid.objectId, PoolIds::DWL_X_UNCORRECTED, this); - lp_var_t yUncorrected = lp_var_t(sid.objectId, PoolIds::DWL_Y_UNCORRECTED, this); - lp_var_t xCorrected = lp_var_t(sid.objectId, PoolIds::DWL_X_CORRECTED, this); - lp_var_t yCorrected = lp_var_t(sid.objectId, PoolIds::DWL_Y_CORRECTED, this); - lp_var_t magnitude = lp_var_t(sid.objectId, PoolIds::DWL_MAGNITUDE, this); - lp_var_t cxa = lp_var_t(sid.objectId, PoolIds::DWL_CXA, this); - lp_var_t cya = lp_var_t(sid.objectId, PoolIds::DWL_CYA, this); - lp_var_t quality = lp_var_t(sid.objectId, PoolIds::DWL_QUALITY, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "ContrastSet::printSet: id: " << static_cast(this->id.value) - << std::endl; - sif::info << "ContrastSet::printSet: pixx: " << this->pixx << std::endl; - sif::info << "ContrastSet::printSet: pixy: " << this->pixy << std::endl; - sif::info << "ContrastSet::printSet: xUncorrected: " << this->xUncorrected << std::endl; - sif::info << "ContrastSet::printSet: yUncorrected: " << this->yUncorrected << std::endl; - sif::info << "ContrastSet::printSet: xCorrected: " << this->xCorrected << std::endl; - sif::info << "ContrastSet::printSet: yCorrected: " << this->yCorrected << std::endl; - sif::info << "ContrastSet::printSet: magnitude: " << this->magnitude << std::endl; - sif::info << "ContrastSet::printSet: cxa: " << this->cxa << std::endl; - sif::info << "ContrastSet::printSet: cya: " << this->cya << std::endl; - sif::info << "ContrastSet::printSet: quality: " << this->quality << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "ContrastSet::printSet: id: " << static_cast(this->id.value) + << std::endl; + sif::info << "ContrastSet::printSet: pixx: " << this->pixx << std::endl; + sif::info << "ContrastSet::printSet: pixy: " << this->pixy << std::endl; + sif::info << "ContrastSet::printSet: xUncorrected: " << this->xUncorrected << std::endl; + sif::info << "ContrastSet::printSet: yUncorrected: " << this->yUncorrected << std::endl; + sif::info << "ContrastSet::printSet: xCorrected: " << this->xCorrected << std::endl; + sif::info << "ContrastSet::printSet: yCorrected: " << this->yCorrected << std::endl; + sif::info << "ContrastSet::printSet: magnitude: " << this->magnitude << std::endl; + sif::info << "ContrastSet::printSet: cxa: " << this->cxa << std::endl; + sif::info << "ContrastSet::printSet: cya: " << this->cya << std::endl; + sif::info << "ContrastSet::printSet: quality: " << this->quality << std::endl; + } }; namespace UploadCentroidKeys { - static const char id[] = "id"; - static const char pixx[] = "pixx"; - static const char pixy[] = "pixy"; - static const char x_uncorrected[] = "x_uncorrected"; - static const char y_uncorrected[] = "y_uncorrected"; - static const char x_corrected[] = "x_corrected"; - static const char y_corrected[] = "y_corrected"; - static const char magnitude[] = "magnitude"; - static const char cxa[] = "cxa"; - static const char cya[] = "cya"; - static const char quality[] = "quality"; -}; +static const char id[] = "id"; +static const char pixx[] = "pixx"; +static const char pixy[] = "pixy"; +static const char x_uncorrected[] = "x_uncorrected"; +static const char y_uncorrected[] = "y_uncorrected"; +static const char x_corrected[] = "x_corrected"; +static const char y_corrected[] = "y_corrected"; +static const char magnitude[] = "magnitude"; +static const char cxa[] = "cxa"; +static const char cya[] = "cya"; +static const char quality[] = "quality"; +}; // namespace UploadCentroidKeys /** * @brief Dataset to store matched star information */ -class DownloadMatchedStar : - public StaticLocalDataSet { -public: +class DownloadMatchedStar : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 53; - // Size of dataset - static const size_t SIZE = 53; + DownloadMatchedStar(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, DOWNLOAD_MATCHED_STAR_SET_ID) {} - DownloadMatchedStar(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, DOWNLOAD_MATCHED_STAR_SET_ID) { - } + DownloadMatchedStar(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, DOWNLOAD_MATCHED_STAR_SET_ID)) {} - DownloadMatchedStar(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, DOWNLOAD_MATCHED_STAR_SET_ID)) { - } + lp_var_t id = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_ID, this); + lp_var_t camfpx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMFPX, this); + lp_var_t camfpy = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMFPY, this); + lp_var_t camcartx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTX, this); + lp_var_t camcarty = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTY, this); + lp_var_t camcartz = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTZ, this); + lp_var_t cammagnitude = + lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMMAGNITUDE, this); + lp_var_t dbfpx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBFPX, this); + lp_var_t dbfpy = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBFPY, this); + lp_var_t dbcartx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBCARTX, this); + lp_var_t dbcarty = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBCARTY, this); + lp_var_t dbcartz = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBCARTZ, this); + lp_var_t dbmagnitude = + lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBMAGNITUDE, this); + lp_var_t catalogid = + lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CATALOGID, this); - lp_var_t id = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_ID, this); - lp_var_t camfpx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMFPX, this); - lp_var_t camfpy = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMFPY, this); - lp_var_t camcartx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTX, this); - lp_var_t camcarty = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTY, this); - lp_var_t camcartz = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTZ, this); - lp_var_t cammagnitude = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMMAGNITUDE, - this); - lp_var_t dbfpx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBFPX, this); - lp_var_t dbfpy = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBFPY, this); - lp_var_t dbcartx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBCARTX, this); - lp_var_t dbcarty = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBCARTY, this); - lp_var_t dbcartz = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBCARTZ, this); - lp_var_t dbmagnitude = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBMAGNITUDE, - this); - lp_var_t catalogid = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CATALOGID, - this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "DownloadMatchedStar::printSet: id: " - << static_cast(this->id.value) << std::endl; - sif::info << "DownloadMatchedStar::printSet: camfpx: " << this->camfpx << std::endl; - sif::info << "DownloadMatchedStar::printSet: camfpy: " << this->camfpy << std::endl; - sif::info << "DownloadMatchedStar::printSet: camcartx: " << this->camcartx << std::endl; - sif::info << "DownloadMatchedStar::printSet: camcarty: " << this->camcarty << std::endl; - sif::info << "DownloadMatchedStar::printSet: camcartz: " << this->camcartz << std::endl; - sif::info << "DownloadMatchedStar::printSet: cammagnitude: " << this->cammagnitude - << std::endl; - sif::info << "DownloadMatchedStar::printSet: dbfpx: " << this->dbfpx << std::endl; - sif::info << "DownloadMatchedStar::printSet: dbfpy: " << this->dbfpy << std::endl; - sif::info << "DownloadMatchedStar::printSet: dbcartx: " << this->dbcartx << std::endl; - sif::info << "DownloadMatchedStar::printSet: dbcarty: " << this->dbcarty << std::endl; - sif::info << "DownloadMatchedStar::printSet: dbcartz: " << this->dbcartz << std::endl; - sif::info << "DownloadMatchedStar::printSet: dbmagnitude: " << this->dbmagnitude - << std::endl; - sif::info << "DownloadMatchedStar::printSet: catalogid: " << this->catalogid << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "DownloadMatchedStar::printSet: id: " << static_cast(this->id.value) + << std::endl; + sif::info << "DownloadMatchedStar::printSet: camfpx: " << this->camfpx << std::endl; + sif::info << "DownloadMatchedStar::printSet: camfpy: " << this->camfpy << std::endl; + sif::info << "DownloadMatchedStar::printSet: camcartx: " << this->camcartx << std::endl; + sif::info << "DownloadMatchedStar::printSet: camcarty: " << this->camcarty << std::endl; + sif::info << "DownloadMatchedStar::printSet: camcartz: " << this->camcartz << std::endl; + sif::info << "DownloadMatchedStar::printSet: cammagnitude: " << this->cammagnitude << std::endl; + sif::info << "DownloadMatchedStar::printSet: dbfpx: " << this->dbfpx << std::endl; + sif::info << "DownloadMatchedStar::printSet: dbfpy: " << this->dbfpy << std::endl; + sif::info << "DownloadMatchedStar::printSet: dbcartx: " << this->dbcartx << std::endl; + sif::info << "DownloadMatchedStar::printSet: dbcarty: " << this->dbcarty << std::endl; + sif::info << "DownloadMatchedStar::printSet: dbcartz: " << this->dbcartz << std::endl; + sif::info << "DownloadMatchedStar::printSet: dbmagnitude: " << this->dbmagnitude << std::endl; + sif::info << "DownloadMatchedStar::printSet: catalogid: " << this->catalogid << std::endl; + } }; /** * @brief Dataset to store the response to the DownloadDBImage request */ -class DownloadDBImage : - public StaticLocalDataSet { -public: +class DownloadDBImage : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 21; - // Size of dataset - static const size_t SIZE = 21; + DownloadDBImage(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, DOWNLOAD_DBIMAGE_SET_ID) {} - DownloadDBImage(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, DOWNLOAD_DBIMAGE_SET_ID) { - } + DownloadDBImage(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, DOWNLOAD_DBIMAGE_SET_ID)) {} - DownloadDBImage(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, DOWNLOAD_DBIMAGE_SET_ID)) { - } + lp_var_t id = lp_var_t(sid.objectId, PoolIds::DBIMAGE_ID, this); + lp_var_t pixx = lp_var_t(sid.objectId, PoolIds::DBIMAGE_PIXX, this); + lp_var_t pixy = lp_var_t(sid.objectId, PoolIds::DBIMAGE_PIXY, this); + lp_var_t x = lp_var_t(sid.objectId, PoolIds::DBIMAGE_X, this); + lp_var_t y = lp_var_t(sid.objectId, PoolIds::DBIMAGE_Y, this); + lp_var_t magnitude = lp_var_t(sid.objectId, PoolIds::DBIMAGE_MAGNITUDE, this); - lp_var_t id = lp_var_t(sid.objectId, PoolIds::DBIMAGE_ID, this); - lp_var_t pixx = lp_var_t(sid.objectId, PoolIds::DBIMAGE_PIXX, this); - lp_var_t pixy = lp_var_t(sid.objectId, PoolIds::DBIMAGE_PIXY, this); - lp_var_t x = lp_var_t(sid.objectId, PoolIds::DBIMAGE_X, this); - lp_var_t y = lp_var_t(sid.objectId, PoolIds::DBIMAGE_Y, this); - lp_var_t magnitude = lp_var_t(sid.objectId, PoolIds::DBIMAGE_MAGNITUDE, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "DownloadDBImage::printSet: id: " - << static_cast(this->id.value) << std::endl; - sif::info << "DownloadDBImage::printSet: pixx: " << this->pixx << std::endl; - sif::info << "DownloadDBImage::printSet: pixy: " << this->pixy << std::endl; - sif::info << "DownloadDBImage::printSet: x: " << this->x << std::endl; - sif::info << "DownloadDBImage::printSet: y: " << this->y << std::endl; - sif::info << "DownloadDBImage::printSet: magnitude: " << this->magnitude << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "DownloadDBImage::printSet: id: " << static_cast(this->id.value) + << std::endl; + sif::info << "DownloadDBImage::printSet: pixx: " << this->pixx << std::endl; + sif::info << "DownloadDBImage::printSet: pixy: " << this->pixy << std::endl; + sif::info << "DownloadDBImage::printSet: x: " << this->x << std::endl; + sif::info << "DownloadDBImage::printSet: y: " << this->y << std::endl; + sif::info << "DownloadDBImage::printSet: magnitude: " << this->magnitude << std::endl; + } }; /** * @brief Dataset to store the response to the download blob pixel action request */ -class DownloadBlobPixel: public StaticLocalDataSet { -public: +class DownloadBlobPixel : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 22; - // Size of dataset - static const size_t SIZE = 22; + DownloadBlobPixel(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, DOWNLOAD_BLOBPIXEL_SET_ID) {} - DownloadBlobPixel(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, DOWNLOAD_BLOBPIXEL_SET_ID) { - } + DownloadBlobPixel(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, DOWNLOAD_BLOBPIXEL_SET_ENTRIES)) {} - DownloadBlobPixel(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, DOWNLOAD_BLOBPIXEL_SET_ENTRIES)) { - } + lp_var_t id = lp_var_t(sid.objectId, PoolIds::BLOBPIX_ID, this); + lp_var_t x = lp_var_t(sid.objectId, PoolIds::BLOBPIX_X, this); + lp_var_t y = lp_var_t(sid.objectId, PoolIds::BLOBPIX_Y, this); + lp_var_t totalValue = lp_var_t(sid.objectId, PoolIds::BLOBPIX_TOT_VAL, this); + lp_var_t inUse = lp_var_t(sid.objectId, PoolIds::BLOBPIX_IN_USE, this); + lp_var_t brightNeighbours = + lp_var_t(sid.objectId, PoolIds::BLOBPIX_BRIGHT_NEIGHBOURS, this); + lp_var_t region = lp_var_t(sid.objectId, PoolIds::BLOBPIX_REGION, this); - lp_var_t id = lp_var_t(sid.objectId, PoolIds::BLOBPIX_ID, this); - lp_var_t x = lp_var_t(sid.objectId, PoolIds::BLOBPIX_X, this); - lp_var_t y = lp_var_t(sid.objectId, PoolIds::BLOBPIX_Y, this); - lp_var_t totalValue = lp_var_t(sid.objectId, PoolIds::BLOBPIX_TOT_VAL, this); - lp_var_t inUse = lp_var_t(sid.objectId, PoolIds::BLOBPIX_IN_USE, this); - lp_var_t brightNeighbours = lp_var_t(sid.objectId, - PoolIds::BLOBPIX_BRIGHT_NEIGHBOURS, this); - lp_var_t region = lp_var_t(sid.objectId, PoolIds::BLOBPIX_REGION, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "DownloadBlobPixel::printSet: id: " - << static_cast(this->id.value) << std::endl; - sif::info << "DownloadBlobPixel::printSet: x: " << this->x << std::endl; - sif::info << "DownloadBlobPixel::printSet: y: " << this->y << std::endl; - sif::info << "DownloadBlobPixel::printSet: totalValue: " << this->totalValue << std::endl; - sif::info << "DownloadBlobPixel::printSet: inUse: " - << static_cast(this->inUse.value) << std::endl; - sif::info << "DownloadBlobPixel::printSet: brightNeighbours: " << this->brightNeighbours - << std::endl; - sif::info << "DownloadBlobPixel::printSet: region: " << this->region << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "DownloadBlobPixel::printSet: id: " << static_cast(this->id.value) + << std::endl; + sif::info << "DownloadBlobPixel::printSet: x: " << this->x << std::endl; + sif::info << "DownloadBlobPixel::printSet: y: " << this->y << std::endl; + sif::info << "DownloadBlobPixel::printSet: totalValue: " << this->totalValue << std::endl; + sif::info << "DownloadBlobPixel::printSet: inUse: " + << static_cast(this->inUse.value) << std::endl; + sif::info << "DownloadBlobPixel::printSet: brightNeighbours: " << this->brightNeighbours + << std::endl; + sif::info << "DownloadBlobPixel::printSet: region: " << this->region << std::endl; + } }; -} +} // namespace StarTracker #endif /* MISSION_STARTRACKER_DEFINITIONS_H_ */ diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp index de70037a..81fea5e7 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp @@ -1,645 +1,653 @@ -#include #include "StarTrackerHandler.h" -#include "OBSWConfig.h" -#include "StarTrackerJsonCommands.h" + #include #include #include + +#include + +#include "OBSWConfig.h" +#include "StarTrackerJsonCommands.h" extern "C" { - #include - #include - #include "common/misc.h" +#include +#include + +#include "common/misc.h" } using json = nlohmann::json; -StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie, StrHelper* strHelper) : - DeviceHandlerBase(objectId, comIF, comCookie), temperatureSet(this), versionSet(this), powerSet( - this), interfaceSet(this), timeSet(this), solutionSet(this), histogramSet(this), contrastSet( - this), checksumSet(this), downloadCentroidSet(this), downloadMatchedStar(this), - downloadDbImage(this), downloadBlobPixel(this), strHelper( - strHelper) { - if (comCookie == nullptr) { - sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl; - } - if (strHelper == nullptr) { - sif::error << "StarTrackerHandler: Invalid str image loader" << std::endl; - } - eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5); +StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, + StrHelper* strHelper) + : DeviceHandlerBase(objectId, comIF, comCookie), + temperatureSet(this), + versionSet(this), + powerSet(this), + interfaceSet(this), + timeSet(this), + solutionSet(this), + histogramSet(this), + contrastSet(this), + checksumSet(this), + downloadCentroidSet(this), + downloadMatchedStar(this), + downloadDbImage(this), + downloadBlobPixel(this), + strHelper(strHelper) { + if (comCookie == nullptr) { + sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl; + } + if (strHelper == nullptr) { + sif::error << "StarTrackerHandler: Invalid str image loader" << std::endl; + } + eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5); } -StarTrackerHandler::~StarTrackerHandler() { -} +StarTrackerHandler::~StarTrackerHandler() {} ReturnValue_t StarTrackerHandler::initialize() { - ReturnValue_t result = RETURN_OK; - result = DeviceHandlerBase::initialize(); - if (result != RETURN_OK) { - return result; - } + ReturnValue_t result = RETURN_OK; + result = DeviceHandlerBase::initialize(); + if (result != RETURN_OK) { + return result; + } - EventManagerIF* manager = ObjectManager::instance()->get( - objects::EVENT_MANAGER); - if (manager == nullptr) { + EventManagerIF* manager = ObjectManager::instance()->get(objects::EVENT_MANAGER); + if (manager == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "StarTrackerHandler::initialize: Invalid event manager" << std::endl; + sif::error << "StarTrackerHandler::initialize: Invalid event manager" << std::endl; #endif - return ObjectManagerIF::CHILD_INIT_FAILED;; - } - result = manager->registerListener(eventQueue->getId()); - if (result != RETURN_OK) { - return result; - } - result = manager->subscribeToEventRange(eventQueue->getId(), - event::getEventId(StrHelper::IMAGE_UPLOAD_FAILED), - event::getEventId(StrHelper::FPGA_UPLOAD_FAILED)); - if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + ; + } + result = manager->registerListener(eventQueue->getId()); + if (result != RETURN_OK) { + return result; + } + result = manager->subscribeToEventRange(eventQueue->getId(), + event::getEventId(StrHelper::IMAGE_UPLOAD_FAILED), + event::getEventId(StrHelper::FPGA_UPLOAD_FAILED)); + if (result != RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "StarTrackerHandler::initialize: Failed to subscribe to events from " - " str helper" << std::endl; + sif::warning << "StarTrackerHandler::initialize: Failed to subscribe to events from " + " str helper" + << std::endl; #endif - return ObjectManagerIF::CHILD_INIT_FAILED; - } + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = strHelper->setComIF(communicationInterface); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } - strHelper->setComCookie(comCookie); - return RETURN_OK; + result = strHelper->setComIF(communicationInterface); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } + strHelper->setComCookie(comCookie); + return RETURN_OK; } ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size) { + const uint8_t* data, size_t size) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; - - switch(actionId) { - case(StarTracker::STOP_IMAGE_LOADER): { - strHelper->stopProcess(); - return EXECUTION_FINISHED; + switch (actionId) { + case (StarTracker::STOP_IMAGE_LOADER): { + strHelper->stopProcess(); + return EXECUTION_FINISHED; } - case(StarTracker::SET_JSON_FILE_NAME): { - if (size > MAX_PATH_SIZE) { - return FILE_PATH_TOO_LONG; - } - paramJsonFile = std::string(reinterpret_cast(data), size); - return EXECUTION_FINISHED; + case (StarTracker::SET_JSON_FILE_NAME): { + if (size > MAX_PATH_SIZE) { + return FILE_PATH_TOO_LONG; + } + paramJsonFile = std::string(reinterpret_cast(data), size); + return EXECUTION_FINISHED; } default: - break; - } + break; + } - if (strHelperExecuting == true) { - return IMAGE_LOADER_EXECUTING; - } + if (strHelperExecuting == true) { + return IMAGE_LOADER_EXECUTING; + } - result = checkMode(actionId); - if (result != RETURN_OK) { + result = checkMode(actionId); + if (result != RETURN_OK) { + return result; + } + + // Intercept image loader commands which do not follow the common DHB communication flow + switch (actionId) { + case (StarTracker::UPLOAD_IMAGE): { + result = DeviceHandlerBase::acceptExternalDeviceCommands(); + if (result != RETURN_OK) { return result; + } + if (size > MAX_PATH_SIZE + MAX_FILE_NAME) { + return FILE_PATH_TOO_LONG; + } + result = strHelper->startImageUpload(std::string(reinterpret_cast(data), size)); + if (result != RETURN_OK) { + return result; + } + strHelperExecuting = true; + return EXECUTION_FINISHED; } + case (StarTracker::DOWNLOAD_IMAGE): { + result = DeviceHandlerBase::acceptExternalDeviceCommands(); + if (result != RETURN_OK) { + return result; + } + if (size > MAX_PATH_SIZE) { + return FILE_PATH_TOO_LONG; + } + result = + strHelper->startImageDownload(std::string(reinterpret_cast(data), size)); + if (result != RETURN_OK) { + return result; + } + strHelperExecuting = true; + return EXECUTION_FINISHED; + } + case (StarTracker::WRITE): { + result = DeviceHandlerBase::acceptExternalDeviceCommands(); + if (result != RETURN_OK) { + return result; + } + result = executeWriteCommand(data, size); + if (result != RETURN_OK) { + return result; + } - // Intercept image loader commands which do not follow the common DHB communication flow - switch(actionId) { - case(StarTracker::UPLOAD_IMAGE): { - result = DeviceHandlerBase::acceptExternalDeviceCommands(); - if (result != RETURN_OK) { - return result; - } - if (size > MAX_PATH_SIZE + MAX_FILE_NAME) { - return FILE_PATH_TOO_LONG; - } - result = strHelper->startImageUpload( - std::string(reinterpret_cast(data), size)); - if (result != RETURN_OK) { - return result; - } - strHelperExecuting = true; - return EXECUTION_FINISHED; + strHelperExecuting = true; + return EXECUTION_FINISHED; } - case(StarTracker::DOWNLOAD_IMAGE): { - result = DeviceHandlerBase::acceptExternalDeviceCommands(); - if (result != RETURN_OK) { - return result; - } - if (size > MAX_PATH_SIZE) { - return FILE_PATH_TOO_LONG; - } - result = strHelper->startImageDownload( - std::string(reinterpret_cast(data), size)); - if (result != RETURN_OK) { - return result; - } - strHelperExecuting = true; - return EXECUTION_FINISHED; + case (StarTracker::READ): { + result = DeviceHandlerBase::acceptExternalDeviceCommands(); + if (result != RETURN_OK) { + return result; + } + result = executeReadCommand(data, size); + if (result != RETURN_OK) { + return result; + } + strHelperExecuting = true; + return EXECUTION_FINISHED; } - case(StarTracker::WRITE): { - result = DeviceHandlerBase::acceptExternalDeviceCommands(); - if (result != RETURN_OK) { - return result; - } - result = executeWriteCommand(data, size); - if (result != RETURN_OK) { - return result; - } - - strHelperExecuting = true; - return EXECUTION_FINISHED; + case (StarTracker::CHANGE_DOWNLOAD_FILE): { + if (size > MAX_FILE_NAME) { + return FILENAME_TOO_LONG; + } + strHelper->setDownloadImageName(std::string(reinterpret_cast(data), size)); + return EXECUTION_FINISHED; } - case(StarTracker::READ): { - result = DeviceHandlerBase::acceptExternalDeviceCommands(); - if (result != RETURN_OK) { - return result; - } - result = executeReadCommand(data, size); - if (result != RETURN_OK) { - return result; - } - strHelperExecuting = true; - return EXECUTION_FINISHED; + case (StarTracker::CHANGE_FPGA_DOWNLOAD_FILE): { + if (size > MAX_FILE_NAME) { + return FILENAME_TOO_LONG; + } + strHelper->setDownloadFpgaImage(std::string(reinterpret_cast(data), size)); + return EXECUTION_FINISHED; } - case(StarTracker::CHANGE_DOWNLOAD_FILE): { - if (size > MAX_FILE_NAME) { - return FILENAME_TOO_LONG; - } - strHelper->setDownloadImageName( - std::string(reinterpret_cast(data), size)); - return EXECUTION_FINISHED; + case (StarTracker::SET_READ_FILENAME): { + if (size > MAX_FILE_NAME) { + return FILENAME_TOO_LONG; + } + strHelper->setDownloadImageName(std::string(reinterpret_cast(data), size)); + return EXECUTION_FINISHED; } - case(StarTracker::CHANGE_FPGA_DOWNLOAD_FILE): { - if (size > MAX_FILE_NAME) { - return FILENAME_TOO_LONG; - } - strHelper->setDownloadFpgaImage(std::string(reinterpret_cast(data), size)); - return EXECUTION_FINISHED; + case (StarTracker::DOWNLOAD_FPGA_IMAGE): { + result = DeviceHandlerBase::acceptExternalDeviceCommands(); + if (result != RETURN_OK) { + return result; + } + if (size > MAX_PATH_SIZE) { + return FILE_PATH_TOO_LONG; + } + result = executeFpgaDownloadCommand(data, size); + if (result != RETURN_OK) { + return result; + } + strHelperExecuting = true; + return EXECUTION_FINISHED; } - case(StarTracker::SET_READ_FILENAME): { - if (size > MAX_FILE_NAME) { - return FILENAME_TOO_LONG; - } - strHelper->setDownloadImageName( - std::string(reinterpret_cast(data), size)); - return EXECUTION_FINISHED; - } - case(StarTracker::DOWNLOAD_FPGA_IMAGE): { - result = DeviceHandlerBase::acceptExternalDeviceCommands(); - if (result != RETURN_OK) { - return result; - } - if (size > MAX_PATH_SIZE) { - return FILE_PATH_TOO_LONG; - } - result = executeFpgaDownloadCommand(data, size); - if (result != RETURN_OK) { - return result; - } - strHelperExecuting = true; - return EXECUTION_FINISHED; - } - case(StarTracker::UPLOAD_FPGA_IMAGE): { - result = DeviceHandlerBase::acceptExternalDeviceCommands(); - if (result != RETURN_OK) { - return result; - } - if (size > MAX_PATH_SIZE + MAX_FILE_NAME) { - return FILE_PATH_TOO_LONG; - } - result = strHelper->startFpgaUpload(std::string(reinterpret_cast(data), size)); - if (result != RETURN_OK) { - return result; - } - strHelperExecuting = true; - return EXECUTION_FINISHED; + case (StarTracker::UPLOAD_FPGA_IMAGE): { + result = DeviceHandlerBase::acceptExternalDeviceCommands(); + if (result != RETURN_OK) { + return result; + } + if (size > MAX_PATH_SIZE + MAX_FILE_NAME) { + return FILE_PATH_TOO_LONG; + } + result = strHelper->startFpgaUpload(std::string(reinterpret_cast(data), size)); + if (result != RETURN_OK) { + return result; + } + strHelperExecuting = true; + return EXECUTION_FINISHED; } default: - break; - } - return DeviceHandlerBase::executeAction(actionId, commandedBy, data, size); + break; + } + return DeviceHandlerBase::executeAction(actionId, commandedBy, data, size); } void StarTrackerHandler::performOperationHook() { - EventMessage event; - for (ReturnValue_t result = eventQueue->receiveMessage(&event); - result == RETURN_OK; result = eventQueue->receiveMessage(&event)) { - switch (event.getMessageId()) { - case EventMessage::EVENT_MESSAGE: - handleEvent(&event); - break; - default: - sif::debug << "CCSDSHandler::checkEvents: Did not subscribe to this event message" - << std::endl; - break; - } + EventMessage event; + for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == RETURN_OK; + result = eventQueue->receiveMessage(&event)) { + switch (event.getMessageId()) { + case EventMessage::EVENT_MESSAGE: + handleEvent(&event); + break; + default: + sif::debug << "CCSDSHandler::checkEvents: Did not subscribe to this event message" + << std::endl; + break; } + } } void StarTrackerHandler::doStartUp() { - switch(startupState) { + switch (startupState) { case StartupState::IDLE: - startupState = StartupState::CHECK_BOOT_STATE; - return; + startupState = StartupState::CHECK_BOOT_STATE; + return; case StartupState::BOOT_DELAY: - if (bootCountdown.hasTimedOut()) { - startupState = StartupState::LIMITS; - } - return; + if (bootCountdown.hasTimedOut()) { + startupState = StartupState::LIMITS; + } + return; case StartupState::DONE: - break; + break; default: - return; - } - setMode(_MODE_TO_ON); + return; + } + setMode(_MODE_TO_ON); } void StarTrackerHandler::doShutDown() { - // If star tracker is shutdown also stop all running processes in the image loader task - strHelper->stopProcess(); - setMode(_MODE_POWER_DOWN); + // If star tracker is shutdown also stop all running processes in the image loader task + strHelper->stopProcess(); + setMode(_MODE_POWER_DOWN); } -void StarTrackerHandler::doOffActivity() { - startupState = StartupState::IDLE; -} +void StarTrackerHandler::doOffActivity() { startupState = StartupState::IDLE; } -ReturnValue_t StarTrackerHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) { - switch (internalState) { +ReturnValue_t StarTrackerHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + switch (internalState) { case InternalState::TEMPERATURE_REQUEST: - *id = StarTracker::REQ_TEMPERATURE; - break; + *id = StarTracker::REQ_TEMPERATURE; + break; default: - sif::debug << "StarTrackerHandler::buildNormalDeviceCommand: Invalid internal step" - << std::endl; - break; - } - return buildCommandFromCommand(*id, NULL, 0); + sif::debug << "StarTrackerHandler::buildNormalDeviceCommand: Invalid internal step" + << std::endl; + break; + } + return buildCommandFromCommand(*id, NULL, 0); } -ReturnValue_t StarTrackerHandler::buildTransitionDeviceCommand(DeviceCommandId_t * id) { - if (mode != _MODE_START_UP) { - return NOTHING_TO_SEND; - } - switch (startupState) { - case StartupState::CHECK_BOOT_STATE: - *id = StarTracker::REQ_VERSION; - startupState = StartupState::WAIT_FOR_EXECUTION; - return buildCommandFromCommand(*id, nullptr, 0); - case StartupState::BOOT: - *id = StarTracker::BOOT; - bootCountdown.setTimeout(BOOT_TIMEOUT); - startupState = StartupState::BOOT_DELAY; - return buildCommandFromCommand(*id, nullptr, 0); - case StartupState::LIMITS: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::LIMITS; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::TRACKING: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::TRACKING; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::MOUNTING: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::MOUNTING; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::CAMERA: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::CAMERA; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::BLOB: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::BLOB; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::CENTROIDING: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::CENTROIDING; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::LISA: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::LISA; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::MATCHING: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::MATCHING; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::VALIDATION: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::VALIDATION; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::ALGO: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::ALGO; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - default: - break; - } +ReturnValue_t StarTrackerHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { + if (mode != _MODE_START_UP) { return NOTHING_TO_SEND; + } + switch (startupState) { + case StartupState::CHECK_BOOT_STATE: + *id = StarTracker::REQ_VERSION; + startupState = StartupState::WAIT_FOR_EXECUTION; + return buildCommandFromCommand(*id, nullptr, 0); + case StartupState::BOOT: + *id = StarTracker::BOOT; + bootCountdown.setTimeout(BOOT_TIMEOUT); + startupState = StartupState::BOOT_DELAY; + return buildCommandFromCommand(*id, nullptr, 0); + case StartupState::LIMITS: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::LIMITS; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::TRACKING: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::TRACKING; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::MOUNTING: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::MOUNTING; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::CAMERA: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::CAMERA; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::BLOB: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::BLOB; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::CENTROIDING: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::CENTROIDING; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::LISA: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::LISA; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::MATCHING: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::MATCHING; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::VALIDATION: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::VALIDATION; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::ALGO: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::ALGO; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + default: + break; + } + return NOTHING_TO_SEND; } ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t * commandData, size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - switch (deviceCommand) { + const uint8_t* commandData, + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + switch (deviceCommand) { case (StarTracker::PING_REQUEST): { - preparePingRequest(); - return RETURN_OK; + preparePingRequest(); + return RETURN_OK; } case (StarTracker::REQ_TIME): { - prepareTimeRequest(); - return RETURN_OK; + prepareTimeRequest(); + return RETURN_OK; } case (StarTracker::BOOT): { - prepareBootCommand(); - return RETURN_OK; + prepareBootCommand(); + return RETURN_OK; } case (StarTracker::REQ_VERSION): { - prepareVersionRequest(); - return RETURN_OK; + prepareVersionRequest(); + return RETURN_OK; } case (StarTracker::REQ_INTERFACE): { - prepareInterfaceRequest(); - return RETURN_OK; + prepareInterfaceRequest(); + return RETURN_OK; } case (StarTracker::REQ_POWER): { - preparePowerRequest(); - return RETURN_OK; + preparePowerRequest(); + return RETURN_OK; } case (StarTracker::SWITCH_TO_BOOTLOADER_PROGRAM): { - prepareRebootCommand(); - return RETURN_OK; + prepareRebootCommand(); + return RETURN_OK; } case (StarTracker::TAKE_IMAGE): { - prepareTakeImageCommand(commandData); - return RETURN_OK; + prepareTakeImageCommand(commandData); + return RETURN_OK; } case (StarTracker::SUBSCRIBE_TO_TM): { - prepareSubscriptionCommand(commandData); - return RETURN_OK; + prepareSubscriptionCommand(commandData); + return RETURN_OK; } case (StarTracker::REQ_SOLUTION): { - prepareSolutionRequest(); - return RETURN_OK; + prepareSolutionRequest(); + return RETURN_OK; } case (StarTracker::REQ_TEMPERATURE): { - prepareTemperatureRequest(); - return RETURN_OK; + prepareTemperatureRequest(); + return RETURN_OK; } case (StarTracker::REQ_HISTOGRAM): { - prepareHistogramRequest(); - return RETURN_OK; + prepareHistogramRequest(); + return RETURN_OK; } case (StarTracker::REQ_CONTRAST): { - prepareContrastRequest(); - return RETURN_OK; + prepareContrastRequest(); + return RETURN_OK; } case (StarTracker::RESET_ERROR): { - prepareErrorResetRequest(); - return RETURN_OK; + prepareErrorResetRequest(); + return RETURN_OK; } case (StarTracker::LIMITS): { - Limits limits; - result = prepareParamCommand(commandData, commandDataLen, limits); - return result; + Limits limits; + result = prepareParamCommand(commandData, commandDataLen, limits); + return result; } case (StarTracker::MOUNTING): { - Mounting mounting; - result = prepareParamCommand(commandData, commandDataLen, mounting); - return result; + Mounting mounting; + result = prepareParamCommand(commandData, commandDataLen, mounting); + return result; } case (StarTracker::CAMERA): { - Camera camera; - result = prepareParamCommand(commandData, commandDataLen, camera); - return result; + Camera camera; + result = prepareParamCommand(commandData, commandDataLen, camera); + return result; } case (StarTracker::BLOB): { - Blob blob; - result = prepareParamCommand(commandData, commandDataLen, blob); - return result; + Blob blob; + result = prepareParamCommand(commandData, commandDataLen, blob); + return result; } case (StarTracker::CENTROIDING): { - Centroiding centroiding; - result = prepareParamCommand(commandData, commandDataLen, centroiding); - return result; + Centroiding centroiding; + result = prepareParamCommand(commandData, commandDataLen, centroiding); + return result; } case (StarTracker::LISA): { - Lisa lisa; - result = prepareParamCommand(commandData, commandDataLen, lisa); - return result; + Lisa lisa; + result = prepareParamCommand(commandData, commandDataLen, lisa); + return result; } case (StarTracker::MATCHING): { - Matching matching; - result = prepareParamCommand(commandData, commandDataLen, matching); - return result; + Matching matching; + result = prepareParamCommand(commandData, commandDataLen, matching); + return result; } case (StarTracker::VALIDATION): { - Validation validation; - result = prepareParamCommand(commandData, commandDataLen, validation); - return result; + Validation validation; + result = prepareParamCommand(commandData, commandDataLen, validation); + return result; } case (StarTracker::ALGO): { - Algo algo; - result = prepareParamCommand(commandData, commandDataLen, algo); - return result; + Algo algo; + result = prepareParamCommand(commandData, commandDataLen, algo); + return result; } case (StarTracker::TRACKING): { - Tracking tracking; - result = prepareParamCommand(commandData, commandDataLen, tracking); - return result; + Tracking tracking; + result = prepareParamCommand(commandData, commandDataLen, tracking); + return result; } case (StarTracker::ERASE): { - result = prepareEraseCommand(commandData, commandDataLen); - return result; + result = prepareEraseCommand(commandData, commandDataLen); + return result; } case (StarTracker::UNLOCK): { - result = prepareUnlockCommand(commandData, commandDataLen); - return result; + result = prepareUnlockCommand(commandData, commandDataLen); + return result; } case (StarTracker::CHECKSUM): { - result = prepareChecksumCommand(commandData, commandDataLen); - return result; + result = prepareChecksumCommand(commandData, commandDataLen); + return result; } case (StarTracker::SET_TIME): { - result = prepareSetTimeCommand(commandData, commandDataLen); - return result; + result = prepareSetTimeCommand(commandData, commandDataLen); + return result; } case (StarTracker::DOWNLOAD_CENTROID): { - result = prepareDownloadCentroidCommand(commandData, commandDataLen); - return result; + result = prepareDownloadCentroidCommand(commandData, commandDataLen); + return result; } case (StarTracker::UPLOAD_CENTROID): { - result = prepareUploadCentroidCommand(commandData, commandDataLen); - return result; + result = prepareUploadCentroidCommand(commandData, commandDataLen); + return result; } case (StarTracker::DOWNLOAD_MATCHED_STAR): { - result = prepareDownloadMatchedStarCommand(commandData, commandDataLen); - return result; + result = prepareDownloadMatchedStarCommand(commandData, commandDataLen); + return result; } case (StarTracker::DOWNLOAD_DBIMAGE): { - result = prepareDownloadDbImageCommand(commandData, commandDataLen); - return result; + result = prepareDownloadDbImageCommand(commandData, commandDataLen); + return result; } case (StarTracker::DOWNLOAD_BLOBPIXEL): { - result = prepareDownloadBlobPixelCommand(commandData, commandDataLen); - return result; + result = prepareDownloadBlobPixelCommand(commandData, commandDataLen); + return result; } case (StarTracker::FPGA_ACTION): { - result = prepareFpgaActionCommand(commandData, commandDataLen); - return result; + result = prepareFpgaActionCommand(commandData, commandDataLen); + return result; } default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } void StarTrackerHandler::fillCommandAndReplyMap() { - /** Reply lengths are unknown because of the slip encoding. Thus always maximum reply size - * is specified */ - this->insertInCommandAndReplyMap(StarTracker::PING_REQUEST, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandMap(StarTracker::BOOT); - this->insertInCommandAndReplyMap(StarTracker::REQ_VERSION, 3, &versionSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_TIME, 3, &timeSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandMap(StarTracker::UPLOAD_IMAGE); - this->insertInCommandMap(StarTracker::DOWNLOAD_IMAGE); - this->insertInCommandAndReplyMap(StarTracker::REQ_POWER, 3, &powerSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_INTERFACE, 3, &interfaceSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - // Reboot has no reply. Star tracker reboots immediately - this->insertInCommandMap(StarTracker::SWITCH_TO_BOOTLOADER_PROGRAM); - this->insertInCommandAndReplyMap(StarTracker::SUBSCRIBE_TO_TM, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_SOLUTION, 3, &solutionSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_TEMPERATURE, 3, &temperatureSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_HISTOGRAM, 3, &histogramSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_CONTRAST, 3, &contrastSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::LIMITS, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::MOUNTING, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::CAMERA, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::BLOB, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::CENTROIDING, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::LISA, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::MATCHING, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::TRACKING, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::VALIDATION, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::ALGO, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::TAKE_IMAGE, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::RESET_ERROR, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::ERASE, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::UNLOCK, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::CHECKSUM, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::SET_TIME, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_CENTROID, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::UPLOAD_CENTROID, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_MATCHED_STAR, 3, &downloadMatchedStar, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_DBIMAGE, 3, &downloadDbImage, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_BLOBPIXEL, 3, &downloadBlobPixel, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::FPGA_ACTION, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); + /** Reply lengths are unknown because of the slip encoding. Thus always maximum reply size + * is specified */ + this->insertInCommandAndReplyMap(StarTracker::PING_REQUEST, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandMap(StarTracker::BOOT); + this->insertInCommandAndReplyMap(StarTracker::REQ_VERSION, 3, &versionSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_TIME, 3, &timeSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandMap(StarTracker::UPLOAD_IMAGE); + this->insertInCommandMap(StarTracker::DOWNLOAD_IMAGE); + this->insertInCommandAndReplyMap(StarTracker::REQ_POWER, 3, &powerSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_INTERFACE, 3, &interfaceSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + // Reboot has no reply. Star tracker reboots immediately + this->insertInCommandMap(StarTracker::SWITCH_TO_BOOTLOADER_PROGRAM); + this->insertInCommandAndReplyMap(StarTracker::SUBSCRIBE_TO_TM, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_SOLUTION, 3, &solutionSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_TEMPERATURE, 3, &temperatureSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_HISTOGRAM, 3, &histogramSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_CONTRAST, 3, &contrastSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::LIMITS, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::MOUNTING, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::CAMERA, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::BLOB, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::CENTROIDING, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::LISA, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::MATCHING, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::TRACKING, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::VALIDATION, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::ALGO, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::TAKE_IMAGE, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::RESET_ERROR, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::ERASE, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::UNLOCK, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::CHECKSUM, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::SET_TIME, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_CENTROID, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::UPLOAD_CENTROID, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_MATCHED_STAR, 3, &downloadMatchedStar, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_DBIMAGE, 3, &downloadDbImage, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_BLOBPIXEL, 3, &downloadBlobPixel, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::FPGA_ACTION, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); } -ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t remainingSize, - DeviceCommandId_t *foundId, size_t *foundLen) { +ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + ReturnValue_t result = RETURN_OK; + size_t bytesLeft = 0; - ReturnValue_t result = RETURN_OK; - size_t bytesLeft = 0; - - result = dataLinkLayer.decodeFrame(start, remainingSize, &bytesLeft); - switch(result) { + result = dataLinkLayer.decodeFrame(start, remainingSize, &bytesLeft); + switch (result) { case ArcsecDatalinkLayer::DEC_IN_PROGRESS: { - remainingSize = bytesLeft; - // Need a second doSendRead pass to reaa in whole packet - return IGNORE_REPLY_DATA; + remainingSize = bytesLeft; + // Need a second doSendRead pass to reaa in whole packet + return IGNORE_REPLY_DATA; } case RETURN_OK: { - break; + break; } default: - remainingSize = bytesLeft; - return result; - } + remainingSize = bytesLeft; + return result; + } - switch (dataLinkLayer.getReplyFrameType()) { + switch (dataLinkLayer.getReplyFrameType()) { case TMTC_ACTIONREPLY: { - *foundLen = remainingSize - bytesLeft; - result = scanForActionReply(foundId); - break; + *foundLen = remainingSize - bytesLeft; + result = scanForActionReply(foundId); + break; } case TMTC_SETPARAMREPLY: { - *foundLen = remainingSize - bytesLeft; - result = scanForParameterReply(foundId); - break; + *foundLen = remainingSize - bytesLeft; + result = scanForParameterReply(foundId); + break; } case TMTC_TELEMETRYREPLYA: case TMTC_TELEMETRYREPLY: { - *foundLen = remainingSize - bytesLeft; - result = scanForTmReply(foundId); - break; + *foundLen = remainingSize - bytesLeft; + result = scanForTmReply(foundId); + break; } default: { - sif::debug << "StarTrackerHandler::scanForReply: Reply has invalid type id" << std::endl; - result = RETURN_FAILED; - } + sif::debug << "StarTrackerHandler::scanForReply: Reply has invalid type id" << std::endl; + result = RETURN_FAILED; } + } - remainingSize = bytesLeft; + remainingSize = bytesLeft; - return result; + return result; } -ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { +ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, + const uint8_t* packet) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; - - switch (id) { + switch (id) { case (StarTracker::SUBSCRIBE_TO_TM): { - result = handleSetParamReply(); - break; + result = handleSetParamReply(); + break; } case (StarTracker::REQ_TIME): { - result = handleTm(timeSet, StarTracker::TimeSet::SIZE); - break; + result = handleTm(timeSet, StarTracker::TimeSet::SIZE); + break; } case (StarTracker::PING_REQUEST): { - result = handlePingReply(); - break; + result = handlePingReply(); + break; } case (StarTracker::BOOT): case (StarTracker::TAKE_IMAGE): @@ -647,71 +655,71 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con case (StarTracker::UNLOCK): case (StarTracker::SET_TIME): case (StarTracker::FPGA_ACTION): { - result = handleActionReply(); - break; + result = handleActionReply(); + break; } case (StarTracker::DOWNLOAD_CENTROID): { - result = handleActionReplySet(downloadCentroidSet, StarTracker::DownloadCentroidSet::SIZE); - break; + result = handleActionReplySet(downloadCentroidSet, StarTracker::DownloadCentroidSet::SIZE); + break; } case (StarTracker::DOWNLOAD_MATCHED_STAR): { - result = handleActionReplySet(downloadMatchedStar, StarTracker::DownloadMatchedStar::SIZE); - break; + result = handleActionReplySet(downloadMatchedStar, StarTracker::DownloadMatchedStar::SIZE); + break; } case (StarTracker::DOWNLOAD_DBIMAGE): { - result = handleActionReplySet(downloadDbImage, StarTracker::DownloadDBImage::SIZE); - break; + result = handleActionReplySet(downloadDbImage, StarTracker::DownloadDBImage::SIZE); + break; } case (StarTracker::DOWNLOAD_BLOBPIXEL): { - result = handleActionReplySet(downloadBlobPixel, StarTracker::DownloadBlobPixel::SIZE); - break; + result = handleActionReplySet(downloadBlobPixel, StarTracker::DownloadBlobPixel::SIZE); + break; } case (StarTracker::UPLOAD_CENTROID): { - result = handleUploadCentroidReply(); - break; + result = handleUploadCentroidReply(); + break; } case (StarTracker::ERASE): { - result = handleEraseReply(); - break; + result = handleEraseReply(); + break; } case (StarTracker::CHECKSUM): { - result = handleChecksumReply(); - break; + result = handleChecksumReply(); + break; } case (StarTracker::REQ_VERSION): { - result = handleTm(versionSet, StarTracker::VersionSet::SIZE); - if (result != RETURN_OK) { - return result; - } - result = checkProgram(); - if (result != RETURN_OK) { - return result; - } - break; + result = handleTm(versionSet, StarTracker::VersionSet::SIZE); + if (result != RETURN_OK) { + return result; + } + result = checkProgram(); + if (result != RETURN_OK) { + return result; + } + break; } case (StarTracker::REQ_INTERFACE): { - result = handleTm(interfaceSet, StarTracker::InterfaceSet::SIZE); - break; + result = handleTm(interfaceSet, StarTracker::InterfaceSet::SIZE); + break; } case (StarTracker::REQ_POWER): { - result = handleTm(powerSet, StarTracker::PowerSet::SIZE); - break; + result = handleTm(powerSet, StarTracker::PowerSet::SIZE); + break; } case (StarTracker::REQ_SOLUTION): { - result = handleTm(solutionSet, StarTracker::SolutionSet::SIZE); - break; + result = handleTm(solutionSet, StarTracker::SolutionSet::SIZE); + break; } case (StarTracker::REQ_TEMPERATURE): { - result = handleTm(temperatureSet, StarTracker::TemperatureSet::SIZE); - break; + result = handleTm(temperatureSet, StarTracker::TemperatureSet::SIZE); + break; } case (StarTracker::REQ_HISTOGRAM): { - result = handleTm(histogramSet, StarTracker::HistogramSet::SIZE); - break; + result = handleTm(histogramSet, StarTracker::HistogramSet::SIZE); + break; } case (StarTracker::REQ_CONTRAST): { - result = handleTm(contrastSet, StarTracker::ContrastSet::SIZE); - break; + result = handleTm(contrastSet, StarTracker::ContrastSet::SIZE); + break; } case (StarTracker::LIMITS): case (StarTracker::MOUNTING): @@ -723,1227 +731,1217 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con case (StarTracker::TRACKING): case (StarTracker::VALIDATION): case (StarTracker::ALGO): { - result = handleSetParamReply(); - break; + result = handleSetParamReply(); + break; } default: { - sif::debug << "StarTrackerHandler::interpretDeviceReply: Unknown device reply id:" << id - << std::endl; - result = DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } + sif::debug << "StarTrackerHandler::interpretDeviceReply: Unknown device reply id:" << id + << std::endl; + result = DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; } + } - return result; + return result; } +void StarTrackerHandler::setNormalDatapoolEntriesInvalid() {} -void StarTrackerHandler::setNormalDatapoolEntriesInvalid() { - -} - -uint32_t StarTrackerHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { - return 20000; -} +uint32_t StarTrackerHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 20000; } ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { + LocalDataPoolManager& poolManager) { + localDataPoolMap.emplace(StarTracker::TICKS_TIME_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_TIME_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::RUN_TIME, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::UNIX_TIME, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_TIME_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_TIME_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::RUN_TIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::UNIX_TIME, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_VERSION_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_VERSION_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::PROGRAM, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MAJOR, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MINOR, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_VERSION_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_VERSION_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::PROGRAM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MAJOR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MINOR, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_INTERFACE_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_INTERFACE_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::FRAME_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CHECKSUM_ERROR_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::SET_PARAM_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::SET_PARAM_REPLY_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::PARAM_REQUEST_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::PARAM_REPLY_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::REQ_TM_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TM_REPLY_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::ACTION_REQ_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::ACTION_REPLY_COUNT, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_INTERFACE_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_INTERFACE_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::FRAME_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CHECKSUM_ERROR_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::SET_PARAM_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::SET_PARAM_REPLY_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::PARAM_REQUEST_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::PARAM_REPLY_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::REQ_TM_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TM_REPLY_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::ACTION_REQ_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::ACTION_REPLY_COUNT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_POWER_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_POWER_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MCU_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MCU_VOLTAGE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::FPGA_CORE_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::FPGA_CORE_VOLTAGE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::FPGA_18_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::FPGA_18_VOLTAGE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::FPGA_25_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::FPGA_25_VOLTAGE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_21_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_21_VOLTAGE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_PIX_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_PIX_VOLTAGE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_33_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_33_VOLTAGE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_RES_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_RES_VOLTAGE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_POWER_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_POWER_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MCU_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MCU_VOLTAGE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::FPGA_CORE_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::FPGA_CORE_VOLTAGE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::FPGA_18_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::FPGA_18_VOLTAGE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::FPGA_25_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::FPGA_25_VOLTAGE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_21_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_21_VOLTAGE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_PIX_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_PIX_VOLTAGE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_33_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_33_VOLTAGE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_RES_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_RES_VOLTAGE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_TEMPERATURE_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_TEMPERATURE_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MCU_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMOS_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_TEMPERATURE_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_TEMPERATURE_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MCU_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMOS_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_SOLUTION_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_SOLUTION_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CALI_QW, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CALI_QX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CALI_QY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CALI_QZ, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TRACK_CONFIDENCE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TRACK_QW, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TRACK_QX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TRACK_QY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TRACK_QZ, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TRACK_REMOVED, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::STARS_CENTROIDED, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::STARS_MATCHED_DATABASE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LISA_QW, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LISA_QX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LISA_QY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LISA_QZ, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LISA_PERC_CLOSE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LISA_NR_CLOSE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TRUST_WORTHY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::STABLE_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::SOLUTION_STRATEGY, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_SOLUTION_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_SOLUTION_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CALI_QW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CALI_QX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CALI_QY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CALI_QZ, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TRACK_CONFIDENCE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TRACK_QW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TRACK_QX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TRACK_QY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TRACK_QZ, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TRACK_REMOVED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::STARS_CENTROIDED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::STARS_MATCHED_DATABASE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LISA_QW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LISA_QX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LISA_QY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LISA_QZ, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LISA_PERC_CLOSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LISA_NR_CLOSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TRUST_WORTHY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::STABLE_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::SOLUTION_STRATEGY, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_HISTOGRAM_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_HISTOGRAM_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND8, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_HISTOGRAM_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_HISTOGRAM_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_CONTRAST_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_CONTRAST_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CHKSUM, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_CONTRAST_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_CONTRAST_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CHKSUM, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::DWL_ID, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_PIXX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_PIXY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_X_UNCORRECTED, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_Y_UNCORRECTED, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_X_CORRECTED, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_Y_CORRECTED, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_MAGNITUDE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_CXA, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_CYA, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_QUALITY, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::DWL_ID, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_PIXX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_PIXY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_X_UNCORRECTED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_Y_UNCORRECTED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_X_CORRECTED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_Y_CORRECTED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_MAGNITUDE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_CXA, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_CYA, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_QUALITY, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_ID, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMFPX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMFPY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTZ, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMMAGNITUDE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBFPX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBFPY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTZ, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBMAGNITUDE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CATALOGID, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_ID, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMFPX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMFPY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTZ, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMMAGNITUDE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBFPX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBFPY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTZ, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBMAGNITUDE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CATALOGID, new PoolEntry( { 0 })); - - localDataPoolMap.emplace(StarTracker::BLOBPIX_ID, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOBPIX_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOBPIX_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOBPIX_TOT_VAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOBPIX_IN_USE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOBPIX_BRIGHT_NEIGHBOURS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOBPIX_REGION, new PoolEntry( { 0 })); - return RETURN_OK; + localDataPoolMap.emplace(StarTracker::BLOBPIX_ID, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOBPIX_X, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOBPIX_Y, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOBPIX_TOT_VAL, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOBPIX_IN_USE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOBPIX_BRIGHT_NEIGHBOURS, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOBPIX_REGION, new PoolEntry({0})); + return RETURN_OK; } -size_t StarTrackerHandler::getNextReplyLength(DeviceCommandId_t commandId){ - return StarTracker::MAX_FRAME_SIZE; +size_t StarTrackerHandler::getNextReplyLength(DeviceCommandId_t commandId) { + return StarTracker::MAX_FRAME_SIZE; } ReturnValue_t StarTrackerHandler::doSendReadHook() { - // Prevent DHB from polling UART during commands executed by the image loader task - if(strHelperExecuting) { - return RETURN_FAILED; - } - return RETURN_OK; + // Prevent DHB from polling UART during commands executed by the image loader task + if (strHelperExecuting) { + return RETURN_FAILED; + } + return RETURN_OK; } ReturnValue_t StarTrackerHandler::checkMode(ActionId_t actionId) { - switch(actionId) { + switch (actionId) { case StarTracker::UPLOAD_IMAGE: case StarTracker::DOWNLOAD_IMAGE: { - return DeviceHandlerBase::acceptExternalDeviceCommands(); - default: + return DeviceHandlerBase::acceptExternalDeviceCommands(); + default: break; } - } - return RETURN_OK; + } + return RETURN_OK; } -ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t *foundId) { - const uint8_t* reply = dataLinkLayer.getReply(); - switch (*reply) { +ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t* foundId) { + const uint8_t* reply = dataLinkLayer.getReply(); + switch (*reply) { case (StarTracker::ID::PING): { - *foundId = StarTracker::PING_REQUEST; - break; + *foundId = StarTracker::PING_REQUEST; + break; } case (StarTracker::ID::WRITE): { - *foundId = StarTracker::WRITE; - break; + *foundId = StarTracker::WRITE; + break; } case (StarTracker::ID::BOOT): { - *foundId = StarTracker::BOOT; - break; + *foundId = StarTracker::BOOT; + break; } case (StarTracker::ID::TAKE_IMAGE): { - *foundId = StarTracker::TAKE_IMAGE; - break; + *foundId = StarTracker::TAKE_IMAGE; + break; } case (StarTracker::ID::UPLOAD_IMAGE): { - *foundId = StarTracker::UPLOAD_IMAGE; - break; + *foundId = StarTracker::UPLOAD_IMAGE; + break; } case (StarTracker::ID::ERROR_RESET): { - *foundId = StarTracker::RESET_ERROR; - break; + *foundId = StarTracker::RESET_ERROR; + break; } case (StarTracker::ID::ERASE): { - *foundId = StarTracker::ERASE; - break; + *foundId = StarTracker::ERASE; + break; } case (StarTracker::ID::UNLOCK): { - *foundId = StarTracker::UNLOCK; - break; + *foundId = StarTracker::UNLOCK; + break; } case (StarTracker::ID::CHECKSUM): { - *foundId = StarTracker::CHECKSUM; - break; + *foundId = StarTracker::CHECKSUM; + break; } case (StarTracker::ID::SET_TIME): { - *foundId = StarTracker::SET_TIME; - break; + *foundId = StarTracker::SET_TIME; + break; } case (StarTracker::ID::DOWNLOAD_CENTROID): { - *foundId = StarTracker::DOWNLOAD_CENTROID; - break; + *foundId = StarTracker::DOWNLOAD_CENTROID; + break; } case (StarTracker::ID::UPLOAD_CENTROID): { - *foundId = StarTracker::UPLOAD_CENTROID; - break; + *foundId = StarTracker::UPLOAD_CENTROID; + break; } case (StarTracker::ID::DOWNLOAD_MATCHED_STAR): { - *foundId = StarTracker::DOWNLOAD_MATCHED_STAR; - break; + *foundId = StarTracker::DOWNLOAD_MATCHED_STAR; + break; } case (StarTracker::ID::DOWNLOAD_DBIMAGE): { - *foundId = StarTracker::DOWNLOAD_DBIMAGE; - break; + *foundId = StarTracker::DOWNLOAD_DBIMAGE; + break; } case (StarTracker::ID::DOWNLOAD_BLOBPIXEL): { - *foundId = StarTracker::DOWNLOAD_BLOBPIXEL; - break; + *foundId = StarTracker::DOWNLOAD_BLOBPIXEL; + break; } case (StarTracker::ID::FPGA_ACTION): { - *foundId = StarTracker::FPGA_ACTION; - break; + *foundId = StarTracker::FPGA_ACTION; + break; } default: - sif::warning << "StarTrackerHandler::scanForParameterReply: Unknown parameter reply id" - << std::endl; - return RETURN_FAILED; - } - return RETURN_OK; + sif::warning << "StarTrackerHandler::scanForParameterReply: Unknown parameter reply id" + << std::endl; + return RETURN_FAILED; + } + return RETURN_OK; } -ReturnValue_t StarTrackerHandler::scanForParameterReply(DeviceCommandId_t *foundId) { - const uint8_t* reply = dataLinkLayer.getReply(); - switch (*reply) { +ReturnValue_t StarTrackerHandler::scanForParameterReply(DeviceCommandId_t* foundId) { + const uint8_t* reply = dataLinkLayer.getReply(); + switch (*reply) { case (StarTracker::ID::SUBSCRIBE): { - *foundId = StarTracker::SUBSCRIBE_TO_TM; - break; + *foundId = StarTracker::SUBSCRIBE_TO_TM; + break; } case (StarTracker::ID::LIMITS): { - *foundId = StarTracker::LIMITS; - break; + *foundId = StarTracker::LIMITS; + break; } case (StarTracker::ID::MOUNTING): { - *foundId = StarTracker::MOUNTING; - break; + *foundId = StarTracker::MOUNTING; + break; } case (StarTracker::ID::CAMERA): { - *foundId = StarTracker::CAMERA; - break; + *foundId = StarTracker::CAMERA; + break; } case (StarTracker::ID::BLOB): { - *foundId = StarTracker::BLOB; - break; + *foundId = StarTracker::BLOB; + break; } case (StarTracker::ID::CENTROIDING): { - *foundId = StarTracker::CENTROIDING; - break; + *foundId = StarTracker::CENTROIDING; + break; } case (StarTracker::ID::LISA): { - *foundId = StarTracker::LISA; - break; + *foundId = StarTracker::LISA; + break; } case (StarTracker::ID::MATCHING): { - *foundId = StarTracker::MATCHING; - break; + *foundId = StarTracker::MATCHING; + break; } case (StarTracker::ID::TRACKING): { - *foundId = StarTracker::TRACKING; - break; + *foundId = StarTracker::TRACKING; + break; } case (StarTracker::ID::VALIDATION): { - *foundId = StarTracker::VALIDATION; - break; + *foundId = StarTracker::VALIDATION; + break; } case (StarTracker::ID::ALGO): { - *foundId = StarTracker::ALGO; - break; + *foundId = StarTracker::ALGO; + break; } default: - sif::debug << "StarTrackerHandler::scanForParameterReply: Unknown parameter reply id" - << std::endl; - return RETURN_FAILED; - } - return RETURN_OK; + sif::debug << "StarTrackerHandler::scanForParameterReply: Unknown parameter reply id" + << std::endl; + return RETURN_FAILED; + } + return RETURN_OK; } -ReturnValue_t StarTrackerHandler::scanForTmReply(DeviceCommandId_t *foundId) { - const uint8_t* reply = dataLinkLayer.getReply(); - switch (*reply) { - case (StarTracker::ID::VERSION): { - *foundId = StarTracker::REQ_VERSION; - break; - } - case (StarTracker::ID::INTERFACE): { - *foundId = StarTracker::REQ_INTERFACE; - break; - } - case (StarTracker::ID::POWER): { - *foundId = StarTracker::REQ_POWER; - break; - } - case (StarTracker::ID::TEMPERATURE): { - *foundId = StarTracker::REQ_TEMPERATURE; - break; - } - case (StarTracker::ID::HISTOGRAM): { - *foundId = StarTracker::REQ_HISTOGRAM; - break; - } - case (StarTracker::ID::CONTRAST): { - *foundId = StarTracker::REQ_CONTRAST; - break; - } - case (StarTracker::ID::TIME): { - *foundId = StarTracker::REQ_TIME; - break; - } - case (StarTracker::ID::SOLUTION): { - *foundId = StarTracker::REQ_SOLUTION; - break; - } - default: { - sif::debug << "StarTrackerHandler::scanForTmReply: Reply contains invalid reply id" - << std::endl; - return RETURN_FAILED; - break; - } +ReturnValue_t StarTrackerHandler::scanForTmReply(DeviceCommandId_t* foundId) { + const uint8_t* reply = dataLinkLayer.getReply(); + switch (*reply) { + case (StarTracker::ID::VERSION): { + *foundId = StarTracker::REQ_VERSION; + break; } - return RETURN_OK; + case (StarTracker::ID::INTERFACE): { + *foundId = StarTracker::REQ_INTERFACE; + break; + } + case (StarTracker::ID::POWER): { + *foundId = StarTracker::REQ_POWER; + break; + } + case (StarTracker::ID::TEMPERATURE): { + *foundId = StarTracker::REQ_TEMPERATURE; + break; + } + case (StarTracker::ID::HISTOGRAM): { + *foundId = StarTracker::REQ_HISTOGRAM; + break; + } + case (StarTracker::ID::CONTRAST): { + *foundId = StarTracker::REQ_CONTRAST; + break; + } + case (StarTracker::ID::TIME): { + *foundId = StarTracker::REQ_TIME; + break; + } + case (StarTracker::ID::SOLUTION): { + *foundId = StarTracker::REQ_SOLUTION; + break; + } + default: { + sif::debug << "StarTrackerHandler::scanForTmReply: Reply contains invalid reply id" + << std::endl; + return RETURN_FAILED; + break; + } + } + return RETURN_OK; } void StarTrackerHandler::handleEvent(EventMessage* eventMessage) { - object_id_t objectId = eventMessage->getReporter(); - switch(objectId){ + object_id_t objectId = eventMessage->getReporter(); + switch (objectId) { case objects::STR_HELPER: { - // All events from image loader signal either that the operation was successful or that it - // failed - strHelperExecuting = false; - break; + // All events from image loader signal either that the operation was successful or that it + // failed + strHelperExecuting = false; + break; } default: - sif::debug << "StarTrackerHandler::handleEvent: Did not subscribe to this event" - << std::endl; - break; - } + sif::debug << "StarTrackerHandler::handleEvent: Did not subscribe to this event" << std::endl; + break; + } } ReturnValue_t StarTrackerHandler::executeWriteCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - if (commandDataLen < WriteCmd::MIN_LENGTH) { - sif::warning << "StarTrackerHandler::executeWriteCommand: Command too short" << std::endl; - return COMMAND_TOO_SHORT; - } - uint8_t region = *(commandData); - uint32_t address; - size_t size = sizeof(address); - const uint8_t* addressPtr = commandData + WriteCmd::ADDRESS_OFFSET; - result = SerializeAdapter::deSerialize(&address, addressPtr, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of address failed" - << std::endl; - return result; - } - if (commandDataLen - sizeof(address) - sizeof(region) > MAX_PATH_SIZE) { - sif::warning << "StarTrackerHandler::executeWriteCommand: Received command with invalid" - << " path and filename" << std::endl; - return FILE_PATH_TOO_LONG; - } - const uint8_t* filePtr = commandData + WriteCmd::FILE_OFFSET; - std::string fullname = std::string(reinterpret_cast(filePtr), - commandDataLen - sizeof(address) - sizeof(region)); - result = strHelper->startFlashWrite(fullname, region, address); - if (result != RETURN_OK) { - return result; - } + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + if (commandDataLen < WriteCmd::MIN_LENGTH) { + sif::warning << "StarTrackerHandler::executeWriteCommand: Command too short" << std::endl; + return COMMAND_TOO_SHORT; + } + uint8_t region = *(commandData); + uint32_t address; + size_t size = sizeof(address); + const uint8_t* addressPtr = commandData + WriteCmd::ADDRESS_OFFSET; + result = SerializeAdapter::deSerialize(&address, addressPtr, &size, SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of address failed" + << std::endl; return result; + } + if (commandDataLen - sizeof(address) - sizeof(region) > MAX_PATH_SIZE) { + sif::warning << "StarTrackerHandler::executeWriteCommand: Received command with invalid" + << " path and filename" << std::endl; + return FILE_PATH_TOO_LONG; + } + const uint8_t* filePtr = commandData + WriteCmd::FILE_OFFSET; + std::string fullname = std::string(reinterpret_cast(filePtr), + commandDataLen - sizeof(address) - sizeof(region)); + result = strHelper->startFlashWrite(fullname, region, address); + if (result != RETURN_OK) { + return result; + } + return result; } ReturnValue_t StarTrackerHandler::executeFpgaDownloadCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - if (commandDataLen < FpgaDownloadCmd::MIN_LENGTH) { - sif::warning << "StarTrackerHandler::executeFpgaDownloadCommand: Command too short" - << std::endl; - return COMMAND_TOO_SHORT; - } - uint32_t position; - size_t size = sizeof(position); - result = SerializeAdapter::deSerialize(&position, &commandData, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of position failed" - << std::endl; - return result; - } - uint32_t length; - size = sizeof(length); - result = SerializeAdapter::deSerialize(&length, &commandData, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of length failed" - << std::endl; - return result; - } - if (commandDataLen - sizeof(position) - sizeof(length) > MAX_PATH_SIZE) { - sif::warning << "StarTrackerHandler::executeFpgaDownloadCommand: Received command with " - " invalid path and filename" << std::endl; - return FILE_PATH_TOO_LONG; - } - std::string fullname = std::string(reinterpret_cast(commandData), - commandDataLen - sizeof(position) - sizeof(length)); - result = strHelper->startFpgaDownload(fullname, position, length); - if (result != RETURN_OK) { - return result; - } + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + if (commandDataLen < FpgaDownloadCmd::MIN_LENGTH) { + sif::warning << "StarTrackerHandler::executeFpgaDownloadCommand: Command too short" + << std::endl; + return COMMAND_TOO_SHORT; + } + uint32_t position; + size_t size = sizeof(position); + result = + SerializeAdapter::deSerialize(&position, &commandData, &size, SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of position failed" + << std::endl; return result; + } + uint32_t length; + size = sizeof(length); + result = + SerializeAdapter::deSerialize(&length, &commandData, &size, SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of length failed" + << std::endl; + return result; + } + if (commandDataLen - sizeof(position) - sizeof(length) > MAX_PATH_SIZE) { + sif::warning << "StarTrackerHandler::executeFpgaDownloadCommand: Received command with " + " invalid path and filename" + << std::endl; + return FILE_PATH_TOO_LONG; + } + std::string fullname = std::string(reinterpret_cast(commandData), + commandDataLen - sizeof(position) - sizeof(length)); + result = strHelper->startFpgaDownload(fullname, position, length); + if (result != RETURN_OK) { + return result; + } + return result; } ReturnValue_t StarTrackerHandler::executeReadCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - if (commandDataLen < ReadCmd::MIN_LENGTH) { - sif::warning << "StarTrackerHandler::executeReadCommand: Command too short" << std::endl; - return COMMAND_TOO_SHORT; - } - uint8_t region = *(commandData); - uint32_t address; - size_t size = sizeof(address); - const uint8_t* addressPtr = commandData + ReadCmd::ADDRESS_OFFSET; - result = SerializeAdapter::deSerialize(&address, addressPtr, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::executeReadCommand: Deserialization of address failed" - << std::endl; - return result; - } - uint32_t length; - size = sizeof(length); - const uint8_t* lengthPtr = commandData + ReadCmd::LENGTH_OFFSET; - result = SerializeAdapter::deSerialize(&length, lengthPtr, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::executeReadCommand: Deserialization of length failed" - << std::endl; - return result; - } - if (commandDataLen - sizeof(address) - sizeof(region) - sizeof(length) > MAX_PATH_SIZE) { - sif::warning << "StarTrackerHandler::executeReadCommand: Received command with invalid" - << " path and filename" << std::endl; - return FILE_PATH_TOO_LONG; - } - const uint8_t* filePtr = commandData + ReadCmd::FILE_OFFSET; - std::string fullname = std::string(reinterpret_cast(filePtr), - commandDataLen - sizeof(address) - sizeof(region) - sizeof(length)); - result = strHelper->startFlashRead(fullname, region, address, length); - if (result != RETURN_OK) { - return result; - } + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + if (commandDataLen < ReadCmd::MIN_LENGTH) { + sif::warning << "StarTrackerHandler::executeReadCommand: Command too short" << std::endl; + return COMMAND_TOO_SHORT; + } + uint8_t region = *(commandData); + uint32_t address; + size_t size = sizeof(address); + const uint8_t* addressPtr = commandData + ReadCmd::ADDRESS_OFFSET; + result = SerializeAdapter::deSerialize(&address, addressPtr, &size, SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::executeReadCommand: Deserialization of address failed" + << std::endl; return result; + } + uint32_t length; + size = sizeof(length); + const uint8_t* lengthPtr = commandData + ReadCmd::LENGTH_OFFSET; + result = SerializeAdapter::deSerialize(&length, lengthPtr, &size, SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::executeReadCommand: Deserialization of length failed" + << std::endl; + return result; + } + if (commandDataLen - sizeof(address) - sizeof(region) - sizeof(length) > MAX_PATH_SIZE) { + sif::warning << "StarTrackerHandler::executeReadCommand: Received command with invalid" + << " path and filename" << std::endl; + return FILE_PATH_TOO_LONG; + } + const uint8_t* filePtr = commandData + ReadCmd::FILE_OFFSET; + std::string fullname = + std::string(reinterpret_cast(filePtr), + commandDataLen - sizeof(address) - sizeof(region) - sizeof(length)); + result = strHelper->startFlashRead(fullname, region, address, length); + if (result != RETURN_OK) { + return result; + } + return result; } void StarTrackerHandler::prepareBootCommand() { - uint32_t length = 0; - struct BootActionRequest bootRequest = {BOOT_REGION_ID}; - arc_pack_boot_action_req(&bootRequest, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + struct BootActionRequest bootRequest = {BOOT_REGION_ID}; + arc_pack_boot_action_req(&bootRequest, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } ReturnValue_t StarTrackerHandler::prepareEraseCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - if (commandDataLen != EraseCmd::LENGTH) { - return INVALID_LENGTH; - } - uint32_t length = 0; - struct EraseActionRequest req; - req.region = *commandData; - arc_pack_erase_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - eraseCmd.rememberRegion = req.region; - return result; + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + if (commandDataLen != EraseCmd::LENGTH) { + return INVALID_LENGTH; + } + uint32_t length = 0; + struct EraseActionRequest req; + req.region = *commandData; + arc_pack_erase_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + eraseCmd.rememberRegion = req.region; + return result; } ReturnValue_t StarTrackerHandler::prepareUnlockCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - uint32_t length = 0; - struct UnlockActionRequest req; - req.region = *commandData; - size_t size = sizeof(req.code); - const uint8_t* codePtr = commandData + UnlockCmd::CODE_OFFSET; - result = SerializeAdapter::deSerialize(&req.code, &codePtr, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - return result; - } - arc_pack_unlock_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + uint32_t length = 0; + struct UnlockActionRequest req; + req.region = *commandData; + size_t size = sizeof(req.code); + const uint8_t* codePtr = commandData + UnlockCmd::CODE_OFFSET; + result = SerializeAdapter::deSerialize(&req.code, &codePtr, &size, SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { return result; + } + arc_pack_unlock_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return result; } ReturnValue_t StarTrackerHandler::prepareChecksumCommand(const uint8_t* commandData, - size_t commandDataLen) { - struct ChecksumActionRequest req; - ReturnValue_t result = RETURN_OK; - if (commandDataLen != ChecksumCmd::LENGTH) { - sif::warning << "StarTrackerHandler::prepareChecksumCommand: Invalid length" << std::endl; - return INVALID_LENGTH; - } - req.region = *(commandData); - size_t size = sizeof(req.address); - const uint8_t* addressPtr = commandData + ChecksumCmd::ADDRESS_OFFSET; - result = SerializeAdapter::deSerialize(&req.address, addressPtr, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::prepareChecksumCommand: Deserialization of address " - << "failed" << std::endl; - return result; - } - size = sizeof(req.length); - const uint8_t* lengthPtr = commandData + ChecksumCmd::LENGTH_OFFSET; - result = SerializeAdapter::deSerialize(&req.length, lengthPtr, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::prepareChecksumCommand: Deserialization of length failed" - << std::endl; - return result; - } - uint32_t rawCmdLength = 0; - arc_pack_checksum_action_req(&req, commandBuffer, &rawCmdLength); - dataLinkLayer.encodeFrame(commandBuffer, rawCmdLength); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - checksumCmd.rememberRegion = req.region; - checksumCmd.rememberAddress = req.address; - checksumCmd.rememberLength = req.length; + size_t commandDataLen) { + struct ChecksumActionRequest req; + ReturnValue_t result = RETURN_OK; + if (commandDataLen != ChecksumCmd::LENGTH) { + sif::warning << "StarTrackerHandler::prepareChecksumCommand: Invalid length" << std::endl; + return INVALID_LENGTH; + } + req.region = *(commandData); + size_t size = sizeof(req.address); + const uint8_t* addressPtr = commandData + ChecksumCmd::ADDRESS_OFFSET; + result = + SerializeAdapter::deSerialize(&req.address, addressPtr, &size, SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::prepareChecksumCommand: Deserialization of address " + << "failed" << std::endl; return result; + } + size = sizeof(req.length); + const uint8_t* lengthPtr = commandData + ChecksumCmd::LENGTH_OFFSET; + result = + SerializeAdapter::deSerialize(&req.length, lengthPtr, &size, SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::prepareChecksumCommand: Deserialization of length failed" + << std::endl; + return result; + } + uint32_t rawCmdLength = 0; + arc_pack_checksum_action_req(&req, commandBuffer, &rawCmdLength); + dataLinkLayer.encodeFrame(commandBuffer, rawCmdLength); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + checksumCmd.rememberRegion = req.region; + checksumCmd.rememberAddress = req.address; + checksumCmd.rememberLength = req.length; + return result; } - ReturnValue_t StarTrackerHandler::prepareSetTimeCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - struct SetTimeActionRequest req; - if (commandDataLen != SetTimeCmd::LENGTH) { - sif::warning << "StarTrackerHandler::prepareSetTimeCommand: Invalid length" << std::endl; - return INVALID_LENGTH; - } - size_t size = sizeof(req.unixTime); - result = SerializeAdapter::deSerialize(&req.unixTime, commandData, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::prepareSetTimeCommand: Deserialization failed" - << std::endl; - return result; - } - uint32_t length = 0; - arc_pack_settime_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + struct SetTimeActionRequest req; + if (commandDataLen != SetTimeCmd::LENGTH) { + sif::warning << "StarTrackerHandler::prepareSetTimeCommand: Invalid length" << std::endl; + return INVALID_LENGTH; + } + size_t size = sizeof(req.unixTime); + result = SerializeAdapter::deSerialize(&req.unixTime, commandData, &size, + SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::prepareSetTimeCommand: Deserialization failed" << std::endl; return result; + } + uint32_t length = 0; + arc_pack_settime_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return result; } ReturnValue_t StarTrackerHandler::prepareDownloadCentroidCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - struct DownloadCentroidActionRequest req; - if (commandDataLen != DownloadCentroidCmd::LENGTH) { - sif::warning << "StarTrackerHandler::prepareDownloadCentroidCommand: Invalid length" - << std::endl; - return INVALID_LENGTH; - } - req.id = *commandData; - uint32_t length = 0; - arc_pack_downloadcentroid_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return result; + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + struct DownloadCentroidActionRequest req; + if (commandDataLen != DownloadCentroidCmd::LENGTH) { + sif::warning << "StarTrackerHandler::prepareDownloadCentroidCommand: Invalid length" + << std::endl; + return INVALID_LENGTH; + } + req.id = *commandData; + uint32_t length = 0; + arc_pack_downloadcentroid_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return result; } ReturnValue_t StarTrackerHandler::prepareUploadCentroidCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen > MAX_PATH_SIZE) { - return FILE_PATH_TOO_LONG; - } - ReturnValue_t result = RETURN_OK; - struct UploadCentroidActionRequest req; - std::string jsonFileName = std::string(reinterpret_cast(commandData), - commandDataLen); - NVMParameterBase j(jsonFileName); - result = j.readJsonFile(); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: " << jsonFileName - << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::id, &req.id); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::id << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::pixx, &req.pixx); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::pixx << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::pixy, &req.pixy); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::pixy << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::x_uncorrected, &req.x_uncorrected); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::x_uncorrected << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::y_uncorrected, &req.y_uncorrected); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::y_uncorrected << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::x_corrected, &req.x_corrected); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::x_corrected << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::y_corrected, &req.y_corrected); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::y_corrected << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::magnitude, &req.magnitude); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::magnitude << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::cxa, &req.cxa); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::cxa << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::cya, &req.cya); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::cya << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::quality, &req.quality); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::quality << " does not exist" << std::endl; - return result; - } - uint32_t length = 0; - arc_pack_uploadcentroid_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - uploadCentroid.rememberId = req.id; + size_t commandDataLen) { + if (commandDataLen > MAX_PATH_SIZE) { + return FILE_PATH_TOO_LONG; + } + ReturnValue_t result = RETURN_OK; + struct UploadCentroidActionRequest req; + std::string jsonFileName = + std::string(reinterpret_cast(commandData), commandDataLen); + NVMParameterBase j(jsonFileName); + result = j.readJsonFile(); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: " << jsonFileName + << " does not exist" << std::endl; return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::id, &req.id); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::id << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::pixx, &req.pixx); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::pixx << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::pixy, &req.pixy); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::pixy << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::x_uncorrected, &req.x_uncorrected); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::x_uncorrected << " does not exist" + << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::y_uncorrected, &req.y_uncorrected); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::y_uncorrected << " does not exist" + << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::x_corrected, &req.x_corrected); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::x_corrected << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::y_corrected, &req.y_corrected); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::y_corrected << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::magnitude, &req.magnitude); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::magnitude << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::cxa, &req.cxa); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::cxa << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::cya, &req.cya); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::cya << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::quality, &req.quality); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::quality << " does not exist" << std::endl; + return result; + } + uint32_t length = 0; + arc_pack_uploadcentroid_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + uploadCentroid.rememberId = req.id; + return result; } void StarTrackerHandler::prepareTimeRequest() { - uint32_t length = 0; - arc_tm_pack_time_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_time_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::preparePingRequest() { - uint32_t length = 0; - struct PingActionRequest pingRequest = {PING_ID}; - arc_pack_ping_action_req(&pingRequest, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + struct PingActionRequest pingRequest = {PING_ID}; + arc_pack_ping_action_req(&pingRequest, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareVersionRequest() { - uint32_t length = 0; - arc_tm_pack_version_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_version_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareInterfaceRequest() { - uint32_t length = 0; - arc_tm_pack_interface_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_interface_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::preparePowerRequest() { - uint32_t length = 0; - arc_tm_pack_power_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_power_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareRebootCommand() { - uint32_t length = 0; - struct RebootActionRequest rebootReq; - arc_pack_reboot_action_req(&rebootReq, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + struct RebootActionRequest rebootReq; + arc_pack_reboot_action_req(&rebootReq, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareTakeImageCommand(const uint8_t* commandData) { - uint32_t length = 0; - struct CameraActionRequest camReq; - camReq.actionid = *commandData; - arc_pack_camera_action_req(&camReq, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + struct CameraActionRequest camReq; + camReq.actionid = *commandData; + arc_pack_camera_action_req(&camReq, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareSubscriptionCommand(const uint8_t* tmId) { - uint32_t length = 18; - commandBuffer[0] = TMTC_SETPARAMREQ; - commandBuffer[1] = StarTracker::ID::SUBSCRIBE; - // Fill all other fields with invalid tm id - commandBuffer[2] = *tmId; - commandBuffer[3] = 0; - commandBuffer[4] = 0; - commandBuffer[5] = 0; - commandBuffer[6] = 0; - commandBuffer[7] = 0; - commandBuffer[8] = 0; - commandBuffer[9] = 0; - commandBuffer[10] = 0; - commandBuffer[11] = 0; - commandBuffer[12] = 0; - commandBuffer[13] = 0; - commandBuffer[14] = 0; - commandBuffer[15] = 0; - commandBuffer[16] = 0; - commandBuffer[17] = 0; - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 18; + commandBuffer[0] = TMTC_SETPARAMREQ; + commandBuffer[1] = StarTracker::ID::SUBSCRIBE; + // Fill all other fields with invalid tm id + commandBuffer[2] = *tmId; + commandBuffer[3] = 0; + commandBuffer[4] = 0; + commandBuffer[5] = 0; + commandBuffer[6] = 0; + commandBuffer[7] = 0; + commandBuffer[8] = 0; + commandBuffer[9] = 0; + commandBuffer[10] = 0; + commandBuffer[11] = 0; + commandBuffer[12] = 0; + commandBuffer[13] = 0; + commandBuffer[14] = 0; + commandBuffer[15] = 0; + commandBuffer[16] = 0; + commandBuffer[17] = 0; + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareSolutionRequest() { - uint32_t length = 0; - arc_tm_pack_solution_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_solution_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareTemperatureRequest() { - uint32_t length = 0; - arc_tm_pack_temperature_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_temperature_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareHistogramRequest() { - uint32_t length = 0; - arc_tm_pack_histogram_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_histogram_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareContrastRequest() { - uint32_t length = 0; - arc_tm_pack_contrast_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_contrast_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareErrorResetRequest() { - uint32_t length = 0; - struct ResetErrorSignalActionRequest req; - arc_pack_reseterrorsignal_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + struct ResetErrorSignalActionRequest req; + arc_pack_reseterrorsignal_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } ReturnValue_t StarTrackerHandler::prepareParamCommand(const uint8_t* commandData, - size_t commandDataLen, ArcsecJsonParamBase& paramSet) { - ReturnValue_t result = RETURN_OK; - if (commandDataLen > MAX_PATH_SIZE) { - return FILE_PATH_TOO_LONG; - } - std::string fullName(reinterpret_cast(commandData), commandDataLen); + size_t commandDataLen, + ArcsecJsonParamBase& paramSet) { + ReturnValue_t result = RETURN_OK; + if (commandDataLen > MAX_PATH_SIZE) { + return FILE_PATH_TOO_LONG; + } + std::string fullName(reinterpret_cast(commandData), commandDataLen); - result = paramSet.create(fullName, commandBuffer); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareParamCommand: Failed to create parameter " - "command" << std::endl; - return result; - } - dataLinkLayer.encodeFrame(commandBuffer, paramSet.getSize()); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; + result = paramSet.create(fullName, commandBuffer); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareParamCommand: Failed to create parameter " + "command" + << std::endl; + return result; + } + dataLinkLayer.encodeFrame(commandBuffer, paramSet.getSize()); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; } ReturnValue_t StarTrackerHandler::prepareDownloadMatchedStarCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen != DownloadMatchedStarCmd::LENGTH) { - return INVALID_LENGTH; - } - struct DownloadMatchedStarActionRequest req; - req.id = *commandData; - uint32_t length = 0; - arc_pack_downloadmatchedstar_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; + size_t commandDataLen) { + if (commandDataLen != DownloadMatchedStarCmd::LENGTH) { + return INVALID_LENGTH; + } + struct DownloadMatchedStarActionRequest req; + req.id = *commandData; + uint32_t length = 0; + arc_pack_downloadmatchedstar_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; } ReturnValue_t StarTrackerHandler::prepareDownloadDbImageCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen != DownloadDbImageCmd::LENGTH) { - return INVALID_LENGTH; - } - struct DownloadDBImageActionRequest req; - req.id = *commandData; - uint32_t length = 0; - arc_pack_downloaddbimage_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; + size_t commandDataLen) { + if (commandDataLen != DownloadDbImageCmd::LENGTH) { + return INVALID_LENGTH; + } + struct DownloadDBImageActionRequest req; + req.id = *commandData; + uint32_t length = 0; + arc_pack_downloaddbimage_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; } ReturnValue_t StarTrackerHandler::prepareDownloadBlobPixelCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen != DownloadBlobPixCmd::LENGTH) { - return INVALID_LENGTH; - } - struct DownloadBlobPixelActionRequest req; - req.id = *commandData; - req.type = *(commandData + 1); - if ((req.type != DownloadBlobPixCmd::NORMAL) && (req.type != DownloadBlobPixCmd::FAST)) { - return INVALID_TYPE; - } - uint32_t length = 0; - arc_pack_downloadblobpixel_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; + size_t commandDataLen) { + if (commandDataLen != DownloadBlobPixCmd::LENGTH) { + return INVALID_LENGTH; + } + struct DownloadBlobPixelActionRequest req; + req.id = *commandData; + req.type = *(commandData + 1); + if ((req.type != DownloadBlobPixCmd::NORMAL) && (req.type != DownloadBlobPixCmd::FAST)) { + return INVALID_TYPE; + } + uint32_t length = 0; + arc_pack_downloadblobpixel_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; } ReturnValue_t StarTrackerHandler::prepareFpgaActionCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen != FpgaActionCmd::LENGTH) { - return INVALID_LENGTH; - } - struct FPGAActionActionRequest req; - req.id = *commandData; - if (req.id != FpgaActionCmd::ID) { - return INVALID_ID; - } - uint32_t length = 0; - arc_pack_fpgaaction_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; + size_t commandDataLen) { + if (commandDataLen != FpgaActionCmd::LENGTH) { + return INVALID_LENGTH; + } + struct FPGAActionActionRequest req; + req.id = *commandData; + if (req.id != FpgaActionCmd::ID) { + return INVALID_ID; + } + uint32_t length = 0; + arc_pack_fpgaaction_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; } ReturnValue_t StarTrackerHandler::handleSetParamReply() { - const uint8_t* reply = dataLinkLayer.getReply(); - uint8_t status = *(reply + STATUS_OFFSET); - if (status != StarTracker::STATUS_OK) { - sif::warning << "StarTrackerHandler::handleSetParamReply: Failed to execute parameter set " - " command with parameter ID" << - static_cast(*(reply + PARAMETER_ID_OFFSET)) << std::endl; - if (startupState != StartupState::IDLE) { - startupState = StartupState::IDLE; - } - return SET_PARAM_FAILED; - } + const uint8_t* reply = dataLinkLayer.getReply(); + uint8_t status = *(reply + STATUS_OFFSET); + if (status != StarTracker::STATUS_OK) { + sif::warning << "StarTrackerHandler::handleSetParamReply: Failed to execute parameter set " + " command with parameter ID" + << static_cast(*(reply + PARAMETER_ID_OFFSET)) << std::endl; if (startupState != StartupState::IDLE) { - handleStartup(reply + PARAMETER_ID_OFFSET); + startupState = StartupState::IDLE; } - return RETURN_OK; + return SET_PARAM_FAILED; + } + if (startupState != StartupState::IDLE) { + handleStartup(reply + PARAMETER_ID_OFFSET); + } + return RETURN_OK; } ReturnValue_t StarTrackerHandler::handleActionReply() { - const uint8_t* reply = dataLinkLayer.getReply(); - uint8_t status = *(reply + STATUS_OFFSET); - if (status != StarTracker::STATUS_OK) { - sif::warning << "StarTrackerHandler::handleActionReply: Failed to execute action " - << "command with action ID " - << static_cast(*(reply + ACTION_ID_OFFSET)) - << " and status "<< static_cast(status) << std::endl; - return ACTION_FAILED; - } - return RETURN_OK; + const uint8_t* reply = dataLinkLayer.getReply(); + uint8_t status = *(reply + STATUS_OFFSET); + if (status != StarTracker::STATUS_OK) { + sif::warning << "StarTrackerHandler::handleActionReply: Failed to execute action " + << "command with action ID " + << static_cast(*(reply + ACTION_ID_OFFSET)) << " and status " + << static_cast(status) << std::endl; + return ACTION_FAILED; + } + return RETURN_OK; } ReturnValue_t StarTrackerHandler::handleUploadCentroidReply() { - ReturnValue_t result = RETURN_OK; - result = handleActionReply(); - if (result != RETURN_OK) { - return result; - } - const uint8_t* reply = dataLinkLayer.getReply(); - if (*(reply + ACTION_DATA_OFFSET) != uploadCentroid.rememberId) { - return UPLOAD_CENTROID_ID_MISMATCH; - } - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + result = handleActionReply(); + if (result != RETURN_OK) { + return result; + } + const uint8_t* reply = dataLinkLayer.getReply(); + if (*(reply + ACTION_DATA_OFFSET) != uploadCentroid.rememberId) { + return UPLOAD_CENTROID_ID_MISMATCH; + } + return RETURN_OK; } ReturnValue_t StarTrackerHandler::handleEraseReply() { - ReturnValue_t result = RETURN_OK; - result = handleActionReply(); - if (result != RETURN_OK) { - return result; - } - const uint8_t* replyData = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; - StarTracker::EraseReply eraseReply(replyData); - if (eraseReply.getRegion() != eraseCmd.rememberRegion) { - sif::warning << "StarTrackerHandler::handleEraseReply: Region mismatch" << std::endl; - return REGION_MISMATCH; - } + ReturnValue_t result = RETURN_OK; + result = handleActionReply(); + if (result != RETURN_OK) { return result; + } + const uint8_t* replyData = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; + StarTracker::EraseReply eraseReply(replyData); + if (eraseReply.getRegion() != eraseCmd.rememberRegion) { + sif::warning << "StarTrackerHandler::handleEraseReply: Region mismatch" << std::endl; + return REGION_MISMATCH; + } + return result; } ReturnValue_t StarTrackerHandler::handleChecksumReply() { - ReturnValue_t result = RETURN_OK; - result = handleActionReply(); - if (result != RETURN_OK) { - return result; - } - const uint8_t* replyData = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; - StarTracker::ChecksumReply checksumReply(replyData); - if (checksumReply.getRegion() != checksumCmd.rememberRegion) { - sif::warning << "StarTrackerHandler::handleChecksumReply: Region mismatch" << std::endl; - return REGION_MISMATCH; - } - if (checksumReply.getAddress() != checksumCmd.rememberAddress) { - sif::warning << "StarTrackerHandler::handleChecksumReply: Address mismatch" << std::endl; - return ADDRESS_MISMATCH; - } - if (checksumReply.getLength() != checksumCmd.rememberLength) { - sif::warning << "StarTrackerHandler::handleChecksumReply: Length mismatch" << std::endl; - return LENGTH_MISSMATCH; - } - PoolReadGuard rg(&checksumSet); - checksumSet.checksum = checksumReply.getChecksum(); - handleDeviceTM(&checksumSet, StarTracker::CHECKSUM); + ReturnValue_t result = RETURN_OK; + result = handleActionReply(); + if (result != RETURN_OK) { + return result; + } + const uint8_t* replyData = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; + StarTracker::ChecksumReply checksumReply(replyData); + if (checksumReply.getRegion() != checksumCmd.rememberRegion) { + sif::warning << "StarTrackerHandler::handleChecksumReply: Region mismatch" << std::endl; + return REGION_MISMATCH; + } + if (checksumReply.getAddress() != checksumCmd.rememberAddress) { + sif::warning << "StarTrackerHandler::handleChecksumReply: Address mismatch" << std::endl; + return ADDRESS_MISMATCH; + } + if (checksumReply.getLength() != checksumCmd.rememberLength) { + sif::warning << "StarTrackerHandler::handleChecksumReply: Length mismatch" << std::endl; + return LENGTH_MISSMATCH; + } + PoolReadGuard rg(&checksumSet); + checksumSet.checksum = checksumReply.getChecksum(); + handleDeviceTM(&checksumSet, StarTracker::CHECKSUM); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - checksumReply.printChecksum(); + checksumReply.printChecksum(); #endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ - return RETURN_OK; + return RETURN_OK; } ReturnValue_t StarTrackerHandler::handlePingReply() { - ReturnValue_t result = RETURN_OK; - uint32_t pingId = 0; - const uint8_t* reply = dataLinkLayer.getReply(); - uint8_t status = dataLinkLayer.getStatusField(); - const uint8_t* buffer = reply + ACTION_DATA_OFFSET; - size_t size = sizeof(pingId); - SerializeAdapter::deSerialize(&pingId, &buffer, &size, SerializeIF::Endianness::LITTLE); + ReturnValue_t result = RETURN_OK; + uint32_t pingId = 0; + const uint8_t* reply = dataLinkLayer.getReply(); + uint8_t status = dataLinkLayer.getStatusField(); + const uint8_t* buffer = reply + ACTION_DATA_OFFSET; + size_t size = sizeof(pingId); + SerializeAdapter::deSerialize(&pingId, &buffer, &size, SerializeIF::Endianness::LITTLE); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - sif::info << "StarTracker: Ping status: "<< static_cast(status) << std::endl; - sif::info << "Ping id: 0x"<< std::hex << pingId << std::endl; + sif::info << "StarTracker: Ping status: " << static_cast(status) << std::endl; + sif::info << "Ping id: 0x" << std::hex << pingId << std::endl; #endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ - if (status != StarTracker::STATUS_OK || pingId != PING_ID) { - sif::warning << "StarTrackerHandler::handlePingReply: Ping failed" << std::endl; - result = PING_FAILED; - } - else { + if (status != StarTracker::STATUS_OK || pingId != PING_ID) { + sif::warning << "StarTrackerHandler::handlePingReply: Ping failed" << std::endl; + result = PING_FAILED; + } else { #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - sif::info << "StarTracker: Ping successful" << std::endl; + sif::info << "StarTracker: Ping successful" << std::endl; #endif - } - return result; + } + return result; } ReturnValue_t StarTrackerHandler::checkProgram() { - PoolReadGuard pg(&versionSet); - switch(versionSet.program.value) { + PoolReadGuard pg(&versionSet); + switch (versionSet.program.value) { case StarTracker::Program::BOOTLOADER: - // Star tracker currently in bootloader program. Need to send boot command to switch to - // firmware program - if (startupState != StartupState::IDLE) { - startupState = StartupState::BOOT; - } - break; + // Star tracker currently in bootloader program. Need to send boot command to switch to + // firmware program + if (startupState != StartupState::IDLE) { + startupState = StartupState::BOOT; + } + break; case StarTracker::Program::FIRMWARE: - // Firmware already booted - if (startupState != StartupState::IDLE) { - startupState = StartupState::LIMITS; - } - break; + // Firmware already booted + if (startupState != StartupState::IDLE) { + startupState = StartupState::LIMITS; + } + break; default: - sif::warning << "StarTrackerHandler::checkProgram: Version set has invalid program ID" - << std::endl; - return INVALID_PROGRAM; - } - return RETURN_OK; + sif::warning << "StarTrackerHandler::checkProgram: Version set has invalid program ID" + << std::endl; + return INVALID_PROGRAM; + } + return RETURN_OK; } ReturnValue_t StarTrackerHandler::handleTm(LocalPoolDataSetBase& dataset, size_t size) { - ReturnValue_t result = RETURN_OK; - uint8_t status = *(dataLinkLayer.getReply() + STATUS_OFFSET); - if(status != StarTracker::STATUS_OK) { - sif::warning << "StarTrackerHandler::handleTm: Reply error: " - << static_cast(status) << std::endl; - return REPLY_ERROR; - } - result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } - const uint8_t* reply = dataLinkLayer.getReply() + TICKS_OFFSET; - dataset.setValidityBufferGeneration(false); - result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::handleTm: Deserialization failed" - << std::endl; - } - dataset.setValidityBufferGeneration(true); - dataset.setValidity(true, true); - result = dataset.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - dataset.printSet(); -#endif + ReturnValue_t result = RETURN_OK; + uint8_t status = *(dataLinkLayer.getReply() + STATUS_OFFSET); + if (status != StarTracker::STATUS_OK) { + sif::warning << "StarTrackerHandler::handleTm: Reply error: " + << static_cast(status) << std::endl; + return REPLY_ERROR; + } + result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { return result; + } + const uint8_t* reply = dataLinkLayer.getReply() + TICKS_OFFSET; + dataset.setValidityBufferGeneration(false); + result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::handleTm: Deserialization failed" << std::endl; + } + dataset.setValidityBufferGeneration(true); + dataset.setValidity(true, true); + result = dataset.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { + return result; + } +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 + dataset.printSet(); +#endif + return result; } ReturnValue_t StarTrackerHandler::handleActionReplySet(LocalPoolDataSetBase& dataset, size_t size) { - ReturnValue_t result = RETURN_OK; - uint8_t status = *(dataLinkLayer.getReply() + STATUS_OFFSET); - if(status != StarTracker::STATUS_OK) { - sif::warning << "StarTrackerHandler::handleActionReplySet: Reply error: " - << static_cast(status) << std::endl; - return REPLY_ERROR; - } - result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } - const uint8_t* reply = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; - dataset.setValidityBufferGeneration(false); - result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::handleActionReplySet Deserialization failed" - << std::endl; - } - dataset.setValidityBufferGeneration(true); - dataset.setValidity(true, true); - result = dataset.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - dataset.printSet(); -#endif + ReturnValue_t result = RETURN_OK; + uint8_t status = *(dataLinkLayer.getReply() + STATUS_OFFSET); + if (status != StarTracker::STATUS_OK) { + sif::warning << "StarTrackerHandler::handleActionReplySet: Reply error: " + << static_cast(status) << std::endl; + return REPLY_ERROR; + } + result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { return result; + } + const uint8_t* reply = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; + dataset.setValidityBufferGeneration(false); + result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::handleActionReplySet Deserialization failed" << std::endl; + } + dataset.setValidityBufferGeneration(true); + dataset.setValidity(true, true); + result = dataset.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { + return result; + } +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 + dataset.printSet(); +#endif + return result; } void StarTrackerHandler::handleStartup(const uint8_t* parameterId) { - switch(*parameterId) { + switch (*parameterId) { case (StarTracker::ID::LIMITS): { - startupState = StartupState::TRACKING; - break; + startupState = StartupState::TRACKING; + break; } case (StarTracker::ID::TRACKING): { - startupState = StartupState::MOUNTING; - break; + startupState = StartupState::MOUNTING; + break; } case (StarTracker::ID::MOUNTING): { - startupState = StartupState::CAMERA; - break; + startupState = StartupState::CAMERA; + break; } case (StarTracker::ID::CAMERA): { - startupState = StartupState::BLOB; - break; + startupState = StartupState::BLOB; + break; } case (StarTracker::ID::BLOB): { - startupState = StartupState::CENTROIDING; - break; + startupState = StartupState::CENTROIDING; + break; } case (StarTracker::ID::CENTROIDING): { - startupState = StartupState::LISA; - break; + startupState = StartupState::LISA; + break; } case (StarTracker::ID::LISA): { - startupState = StartupState::MATCHING; - break; + startupState = StartupState::MATCHING; + break; } case (StarTracker::ID::MATCHING): { - startupState = StartupState::VALIDATION; - break; + startupState = StartupState::VALIDATION; + break; } case (StarTracker::ID::VALIDATION): { - startupState = StartupState::ALGO; - break; + startupState = StartupState::ALGO; + break; } case (StarTracker::ID::ALGO): { - startupState = StartupState::DONE; - break; + startupState = StartupState::DONE; + break; } default: { - sif::debug << "StarTrackerHandler::handleStartup: Received parameter reply with unexpected" - << " parameter ID" << std::endl; - break; - } + sif::debug << "StarTrackerHandler::handleStartup: Received parameter reply with unexpected" + << " parameter ID" << std::endl; + break; } + } } diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.h b/bsp_q7s/devices/startracker/StarTrackerHandler.h index 65bd65b8..1d7efeb3 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.h +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.h @@ -1,15 +1,16 @@ #ifndef MISSION_DEVICES_STARTRACKERHANDLER_H_ #define MISSION_DEVICES_STARTRACKERHANDLER_H_ +#include + +#include "ArcsecDatalinkLayer.h" +#include "ArcsecJsonParamBase.h" +#include "StarTrackerDefinitions.h" +#include "StrHelper.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" #include "fsfw/src/fsfw/serialize/SerializeAdapter.h" #include "fsfw/timemanager/Countdown.h" #include "thirdparty/arcsec_star_tracker/common/SLIP.h" -#include -#include "ArcsecDatalinkLayer.h" -#include "StarTrackerDefinitions.h" -#include "ArcsecJsonParamBase.h" -#include "StrHelper.h" /** * @brief This is the device handler for the star tracker from arcsec. @@ -19,530 +20,524 @@ * Sagitta%201.0%20Datapack&fileid=659181 * @author J. Meier */ -class StarTrackerHandler: public DeviceHandlerBase { -public: - - /** - * @brief Constructor - * - * @param objectId - * @param comIF - * @param comCookie - * @param gpioComIF Pointer to gpio communication interface - * @param enablePin GPIO connected to the enable pin of the reaction wheels. Must be pulled - * to high to enable the device. - */ - StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie, - StrHelper* strHelper); - virtual ~StarTrackerHandler(); - - ReturnValue_t initialize() override; - - /** - * @brief Overwrite this function from DHB to handle commands executed by the str image - * loader task. - */ - ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size) override; - - void performOperationHook() override; - -protected: - void doStartUp() override; - void doShutDown() override; - void doOffActivity() 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; - /** - * @brief Overwritten here to always read all available data from the UartComIF. - */ - virtual size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override; - virtual ReturnValue_t doSendReadHook() override; - -private: - - static const uint8_t INTERFACE_ID = CLASS_ID::STR_HANDLER; - - //! [EXPORT] : [COMMENT] Received reply is too short - static const ReturnValue_t REPLY_TOO_SHORT = MAKE_RETURN_CODE(0xB0); - //! [EXPORT] : [COMMENT] Received reply with invalid CRC - static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xB1); - //! [EXPORT] : [COMMENT] Image loader executing - static const ReturnValue_t IMAGE_LOADER_EXECUTING = MAKE_RETURN_CODE(0xB2); - - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_HANDLER; - - //! [EXPORT] : [COMMENT] Status in temperature reply signals error - static const ReturnValue_t TEMPERATURE_REQ_FAILED = MAKE_RETURN_CODE(0xA0); - //! [EXPORT] : [COMMENT] Ping command failed - static const ReturnValue_t PING_FAILED = MAKE_RETURN_CODE(0xA1); - //! [EXPORT] : [COMMENT] Status in version reply signals error - static const ReturnValue_t VERSION_REQ_FAILED = MAKE_RETURN_CODE(0xA3); - //! [EXPORT] : [COMMENT] Status in interface reply signals error - static const ReturnValue_t INTERFACE_REQ_FAILED = MAKE_RETURN_CODE(0xA4); - //! [EXPORT] : [COMMENT] Status in power reply signals error - static const ReturnValue_t POWER_REQ_FAILED = MAKE_RETURN_CODE(0xA5); - //! [EXPORT] : [COMMENT] Status of reply to parameter set command signals error - static const ReturnValue_t SET_PARAM_FAILED = MAKE_RETURN_CODE(0xA6); - //! [EXPORT] : [COMMENT] Status of reply to action command signals error - static const ReturnValue_t ACTION_FAILED = MAKE_RETURN_CODE(0xA7); - //! [EXPORT] : [COMMENT] Received upload image command with invalid length - static const ReturnValue_t UPLOAD_TOO_SHORT = MAKE_RETURN_CODE(0xA8); - //! [EXPORT] : [COMMENT] Received upload image command with invalid position field - static const ReturnValue_t UPLOAD_INVALID_POSITION = MAKE_RETURN_CODE(0xA8); - //! [EXPORT] : [COMMENT] Position value in upload image reply not matching sent position - static const ReturnValue_t UPLOAD_IMAGE_FAILED = MAKE_RETURN_CODE(0xA9); - //! [EXPORT] : [COMMENT] Received upload image command with invalid length - static const ReturnValue_t INVALID_UPLOAD_COMMAND = MAKE_RETURN_CODE(0xAA); - //! [EXPORT] : [COMMENT] Received invalid path string. Exceeds allowed length - static const ReturnValue_t FILE_PATH_TOO_LONG = MAKE_RETURN_CODE(0xAB); - //! [EXPORT] : [COMMENT] Name of file received with command is too long - static const ReturnValue_t FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xAC); - //! [EXPORT] : [COMMENT] Received version reply with invalid program ID - static const ReturnValue_t INVALID_PROGRAM = MAKE_RETURN_CODE(0xAD); - //! [EXPORT] : [COMMENT] Status field reply signals error - static const ReturnValue_t REPLY_ERROR = MAKE_RETURN_CODE(0xAE); - //! [EXPORT] : [COMMENT] Status field of contrast reply signals error - static const ReturnValue_t CONTRAST_REQ_FAILED = MAKE_RETURN_CODE(0xAE); - //! [EXPORT] : [COMMENT] Received command which is too short (some data is missing for proper execution) - static const ReturnValue_t COMMAND_TOO_SHORT = MAKE_RETURN_CODE(0xAF); - //! [EXPORT] : [COMMENT] Received command with invalid length (too few or too many parameters) - static const ReturnValue_t INVALID_LENGTH = MAKE_RETURN_CODE(0xB0); - //! [EXPORT] : [COMMENT] Region mismatch between send and received data - static const ReturnValue_t REGION_MISMATCH = MAKE_RETURN_CODE(0xB1); - //! [EXPORT] : [COMMENT] Address mismatch between send and received data - static const ReturnValue_t ADDRESS_MISMATCH = MAKE_RETURN_CODE(0xB2); - //! [EXPORT] : [COMMENT] Length field mismatch between send and received data - static const ReturnValue_t lENGTH_MISMATCH = MAKE_RETURN_CODE(0xB3); - //! [EXPORT] : [COMMENT] Specified file does not exist - static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xB4); - //! [EXPORT] : [COMMENT] Reply to upload centroid does not match commanded centroid id - static const ReturnValue_t UPLOAD_CENTROID_ID_MISMATCH = MAKE_RETURN_CODE(0xB5); - //! [EXPORT] : [COMMENT] Download blob pixel command has invalid type field - static const ReturnValue_t INVALID_TYPE = MAKE_RETURN_CODE(0xB6); - //! [EXPORT] : [COMMENT] Received FPGA action command with invalid ID - static const ReturnValue_t INVALID_ID = MAKE_RETURN_CODE(0xB7); - - static const size_t MAX_PATH_SIZE = 50; - static const size_t MAX_FILE_NAME = 30; - - // position (uint32) + 1024 image data - static const size_t UPLOAD_COMMAND_LEN = 1028; - // Max valid position value in upload image command - static const uint16_t MAX_POSITION= 4095; - static const uint8_t STATUS_OFFSET = 1; - static const uint8_t TICKS_OFFSET = 2; - static const uint8_t TIME_OFFSET = 6; - static const uint8_t TM_DATA_FIELD_OFFSET = 14; - static const uint8_t PARAMETER_ID_OFFSET = 0; - static const uint8_t ACTION_ID_OFFSET = 0; - static const uint8_t ACTION_DATA_OFFSET = 2; - // Ping request will reply ping with this ID (data field) - static const uint32_t PING_ID = 0x55; - static const uint32_t BOOT_REGION_ID = 1; - static const MutexIF::TimeoutType TIMEOUT_TYPE = MutexIF::TimeoutType::WAITING; - static const uint32_t MUTEX_TIMEOUT = 20; - static const uint32_t BOOT_TIMEOUT = 1000; - - class WriteCmd { - public: - static const uint8_t ADDRESS_OFFSET = 1; - static const uint8_t FILE_OFFSET = 5; - // Minimum length of a write command (region, address and filename) - static const size_t MIN_LENGTH = 7; - }; - - class ReadCmd { - public: - static const uint8_t ADDRESS_OFFSET = 1; - static const uint8_t LENGTH_OFFSET = 5; - static const uint8_t FILE_OFFSET = 9; - // Minimum length of a read command (region, address, length and filename) - static const size_t MIN_LENGTH = 11; - }; - - class EraseCmd { - public: - static const uint8_t LENGTH = 1; - uint8_t rememberRegion = 0; - }; - - EraseCmd eraseCmd; - - class UnlockCmd { - public: - static const uint8_t CODE_OFFSET = 1; - }; - - class ChecksumCmd { - public: - static const uint8_t ADDRESS_OFFSET = 1; - static const uint8_t LENGTH_OFFSET = 5; - // Length of checksum command - static const size_t LENGTH = 9; - uint8_t rememberRegion = 0; - uint32_t rememberAddress = 0; - uint32_t rememberLength = 0; - }; - - ChecksumCmd checksumCmd; - - class SetTimeCmd { - public: - static const uint8_t LENGTH = 8; - }; - - class DownloadCentroidCmd { - public: - static const uint8_t LENGTH = 1; - }; - - class UploadCentroid { - public: - uint8_t rememberId = 0; - }; - - UploadCentroid uploadCentroid; - - class DownloadMatchedStarCmd { - public: - static const uint8_t LENGTH = 1; - }; - - class DownloadDbImageCmd { - public: - static const uint8_t LENGTH = 1; - }; - - class DownloadBlobPixCmd { - public: - static const uint8_t LENGTH = 2; - static const uint8_t NORMAL = 0; - static const uint8_t FAST = 1; - }; - - class FpgaDownloadCmd { - public: - static const uint8_t MIN_LENGTH = 10; - }; - - class FpgaActionCmd { - public: - static const uint8_t LENGTH = 1; - static const uint8_t ID = 3; - }; - - MessageQueueIF* eventQueue = nullptr; - - ArcsecDatalinkLayer dataLinkLayer; - - StarTracker::TemperatureSet temperatureSet; - StarTracker::VersionSet versionSet; - StarTracker::PowerSet powerSet; - StarTracker::InterfaceSet interfaceSet; - StarTracker::TimeSet timeSet; - StarTracker::SolutionSet solutionSet; - StarTracker::HistogramSet histogramSet; - StarTracker::ContrastSet contrastSet; - StarTracker::ChecksumSet checksumSet; - StarTracker::DownloadCentroidSet downloadCentroidSet; - StarTracker::DownloadMatchedStar downloadMatchedStar; - StarTracker::DownloadDBImage downloadDbImage; - StarTracker::DownloadBlobPixel downloadBlobPixel; - - // Pointer to object responsible for uploading and downloading images to/from the star tracker - StrHelper* strHelper = nullptr; - - uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE]; - - // Countdown to insert delay for star tracker to switch from bootloader to firmware program - Countdown bootCountdown; - - std::string paramJsonFile = "/mnt/sd0/startracker/full.json"; - - enum class InternalState { - TEMPERATURE_REQUEST - }; - - InternalState internalState = InternalState::TEMPERATURE_REQUEST; - - enum class StartupState { - IDLE, - CHECK_BOOT_STATE, - BOOT, - BOOT_DELAY, - LIMITS, - TRACKING, - MOUNTING, - CAMERA, - BLOB, - CENTROIDING, - LISA, - MATCHING, - VALIDATION, - ALGO, - WAIT_FOR_EXECUTION, - DONE - }; - - StartupState startupState = StartupState::IDLE; - - bool strHelperExecuting = false; - - /** - * @brief Handles internal state - */ - void handleInternalState(); - - /** - * @brief Checks mode for commands requiring MODE_ON of MODE_NORMAL for execution. - * - * @param actionId Action id of command to execute - */ - ReturnValue_t checkMode(ActionId_t actionId); - - /** - * @brief This function initializes the serial link ip protocol struct slipInfo. - */ - void slipInit(); - - ReturnValue_t scanForActionReply(DeviceCommandId_t *foundId); - ReturnValue_t scanForParameterReply(DeviceCommandId_t *foundId); - ReturnValue_t scanForTmReply(DeviceCommandId_t *foundId); - - /** - * @brief Fills command buffer with data to ping the star tracker - */ - void preparePingRequest(); - - /** - * @brief Fills command buffer with data to request the time telemetry. - */ - void prepareTimeRequest(); - - /** - * @brief Handles all received event messages - */ - void handleEvent(EventMessage* eventMessage); - - /** - * @brief Executes the write command - * - * @param commandData Pointer to received command data - * @param commandDataLen Size of received command data - * - * @return RETURN_OK if start of execution was successful, otherwise error return value - */ - ReturnValue_t executeWriteCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Starts the execution of the fpga download command - * - * @param commandData Pointer to buffer with command data - * @param commandDataLen Size of received command - */ - ReturnValue_t executeFpgaDownloadCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Extracts information for flash-read-command from TC data and starts execution of - * flash-read-procedure - * - * @param commandData Pointer to received command data - * @param commandDataLen Size of received command data - * - * @return RETURN_OK if start of execution was successful, otherwise error return value - */ - ReturnValue_t executeReadCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills command buffer with data to boot image (works only when star tracker is - * in bootloader mode). - */ - void prepareBootCommand(); - - /** - * @brief Fills command buffer with command to erase a flash region - */ - ReturnValue_t prepareEraseCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills command buffer with command to unlock flash region - */ - ReturnValue_t prepareUnlockCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills command buffer with command to get the checksum of a flash part - */ - ReturnValue_t prepareChecksumCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills command buffer with command to set the unix time - */ - ReturnValue_t prepareSetTimeCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills command buffer with command to request a centroid - */ - ReturnValue_t prepareDownloadCentroidCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills command buffer with command to upload a centroid for testing purpose - */ - ReturnValue_t prepareUploadCentroidCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills the command buffer with the command to take an image. - */ - void prepareTakeImageCommand(const uint8_t* commandData); - - /** - * @brief Fills command buffer with data to request the version telemetry packet - */ - void prepareVersionRequest(); - - /** - * @brief Fills the command buffer with data to request the interface telemetry packet. - */ - void prepareInterfaceRequest(); - - /** - * @brief Fills the command buffer with data to request the power telemetry packet. - */ - void preparePowerRequest(); - - /** - * @brief Fills command buffer with data to reboot star tracker. - */ - void prepareRebootCommand(); - - /** - * @brief Fills command buffer with data to subscribe to a telemetry packet. - * - * @param tmId The ID of the telemetry packet to subscribe to - */ - void prepareSubscriptionCommand(const uint8_t* tmId); - - /** - * @brief Fills command buffer with data to request solution telemtry packet (contains - * attitude information) - */ - void prepareSolutionRequest(); - - /** - * @brief Fills command buffer with data to request temperature from star tracker - */ - void prepareTemperatureRequest(); - - /** - * @brief Fills command buffer with data to request histogram - */ - void prepareHistogramRequest(); - - void prepareContrastRequest(); - - /** - * @brief Fills command buffer with command to reset the error signal of the star tracker - */ - void prepareErrorResetRequest(); - - /** - * @brief Reads parameters from json file specified by string in commandData and - * prepares the command to apply the parameter set to the star tracker - * - * @param commandData Contains string with file name - * @param commandDataLen Length of command - * @param paramSet The object defining the command generation - * - * @return RETURN_OK if successful, otherwise error return Value - */ - ReturnValue_t prepareParamCommand(const uint8_t* commandData, size_t commandDataLen, - ArcsecJsonParamBase& paramSet); - - /** - * @brief Fills command buffer with data to request matched star. - */ - ReturnValue_t prepareDownloadMatchedStarCommand(const uint8_t* commandData, - size_t commandDataLen); - - /** - * @brief Fills command buffer with data to request matched star coordinates. - */ - ReturnValue_t prepareDownloadDbImageCommand(const uint8_t* commandData, - size_t commandDataLen); - - /** - * @brief Fills command buffer with data to request output of the blob filter algorithm. - */ - ReturnValue_t prepareDownloadBlobPixelCommand(const uint8_t* commandData, - size_t commandDataLen); - - /** - * @brief With this command the FPGA update will be applied to the star tracker - */ - ReturnValue_t prepareFpgaActionCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Handles action replies with datasets. - */ - ReturnValue_t handleActionReplySet(LocalPoolDataSetBase& dataset, size_t size); - - /** - * @brief Default function to handle action replies - */ - ReturnValue_t handleActionReply(); - - /** - * @brief Handles reply to upload centroid command - */ - ReturnValue_t handleUploadCentroidReply(); - - /** - * @brief Handles reply to erase command - */ - ReturnValue_t handleEraseReply(); - - /** - * @brief Handles reply to checksum command - */ - ReturnValue_t handleChecksumReply(); - - /** - * @brief Handles all set parameter replies - */ - ReturnValue_t handleSetParamReply(); - - ReturnValue_t handlePingReply(); - - /** - * @brief Checks the loaded program by means of the version set - */ - ReturnValue_t checkProgram(); - - /** - * @brief Handles the startup state machine - */ - void handleStartup(const uint8_t* parameterId); - - /** - * @brief Handles telemtry replies and fills the appropriate dataset - * - * @param dataset Dataset where reply data will be written to - * @param size Size of the dataset - * - * @return RETURN_OK if successful, otherwise error return value - */ - ReturnValue_t handleTm(LocalPoolDataSetBase& dataset, size_t size); +class StarTrackerHandler : public DeviceHandlerBase { + public: + /** + * @brief Constructor + * + * @param objectId + * @param comIF + * @param comCookie + * @param gpioComIF Pointer to gpio communication interface + * @param enablePin GPIO connected to the enable pin of the reaction wheels. Must be pulled + * to high to enable the device. + */ + StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, + StrHelper* strHelper); + virtual ~StarTrackerHandler(); + + ReturnValue_t initialize() override; + + /** + * @brief Overwrite this function from DHB to handle commands executed by the str image + * loader task. + */ + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) override; + + void performOperationHook() override; + + protected: + void doStartUp() override; + void doShutDown() override; + void doOffActivity() 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; + /** + * @brief Overwritten here to always read all available data from the UartComIF. + */ + virtual size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override; + virtual ReturnValue_t doSendReadHook() override; + + private: + static const uint8_t INTERFACE_ID = CLASS_ID::STR_HANDLER; + + //! [EXPORT] : [COMMENT] Received reply is too short + static const ReturnValue_t REPLY_TOO_SHORT = MAKE_RETURN_CODE(0xB0); + //! [EXPORT] : [COMMENT] Received reply with invalid CRC + static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xB1); + //! [EXPORT] : [COMMENT] Image loader executing + static const ReturnValue_t IMAGE_LOADER_EXECUTING = MAKE_RETURN_CODE(0xB2); + + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_HANDLER; + + //! [EXPORT] : [COMMENT] Status in temperature reply signals error + static const ReturnValue_t TEMPERATURE_REQ_FAILED = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] Ping command failed + static const ReturnValue_t PING_FAILED = MAKE_RETURN_CODE(0xA1); + //! [EXPORT] : [COMMENT] Status in version reply signals error + static const ReturnValue_t VERSION_REQ_FAILED = MAKE_RETURN_CODE(0xA3); + //! [EXPORT] : [COMMENT] Status in interface reply signals error + static const ReturnValue_t INTERFACE_REQ_FAILED = MAKE_RETURN_CODE(0xA4); + //! [EXPORT] : [COMMENT] Status in power reply signals error + static const ReturnValue_t POWER_REQ_FAILED = MAKE_RETURN_CODE(0xA5); + //! [EXPORT] : [COMMENT] Status of reply to parameter set command signals error + static const ReturnValue_t SET_PARAM_FAILED = MAKE_RETURN_CODE(0xA6); + //! [EXPORT] : [COMMENT] Status of reply to action command signals error + static const ReturnValue_t ACTION_FAILED = MAKE_RETURN_CODE(0xA7); + //! [EXPORT] : [COMMENT] Received upload image command with invalid length + static const ReturnValue_t UPLOAD_TOO_SHORT = MAKE_RETURN_CODE(0xA8); + //! [EXPORT] : [COMMENT] Received upload image command with invalid position field + static const ReturnValue_t UPLOAD_INVALID_POSITION = MAKE_RETURN_CODE(0xA8); + //! [EXPORT] : [COMMENT] Position value in upload image reply not matching sent position + static const ReturnValue_t UPLOAD_IMAGE_FAILED = MAKE_RETURN_CODE(0xA9); + //! [EXPORT] : [COMMENT] Received upload image command with invalid length + static const ReturnValue_t INVALID_UPLOAD_COMMAND = MAKE_RETURN_CODE(0xAA); + //! [EXPORT] : [COMMENT] Received invalid path string. Exceeds allowed length + static const ReturnValue_t FILE_PATH_TOO_LONG = MAKE_RETURN_CODE(0xAB); + //! [EXPORT] : [COMMENT] Name of file received with command is too long + static const ReturnValue_t FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xAC); + //! [EXPORT] : [COMMENT] Received version reply with invalid program ID + static const ReturnValue_t INVALID_PROGRAM = MAKE_RETURN_CODE(0xAD); + //! [EXPORT] : [COMMENT] Status field reply signals error + static const ReturnValue_t REPLY_ERROR = MAKE_RETURN_CODE(0xAE); + //! [EXPORT] : [COMMENT] Status field of contrast reply signals error + static const ReturnValue_t CONTRAST_REQ_FAILED = MAKE_RETURN_CODE(0xAE); + //! [EXPORT] : [COMMENT] Received command which is too short (some data is missing for proper + //! execution) + static const ReturnValue_t COMMAND_TOO_SHORT = MAKE_RETURN_CODE(0xAF); + //! [EXPORT] : [COMMENT] Received command with invalid length (too few or too many parameters) + static const ReturnValue_t INVALID_LENGTH = MAKE_RETURN_CODE(0xB0); + //! [EXPORT] : [COMMENT] Region mismatch between send and received data + static const ReturnValue_t REGION_MISMATCH = MAKE_RETURN_CODE(0xB1); + //! [EXPORT] : [COMMENT] Address mismatch between send and received data + static const ReturnValue_t ADDRESS_MISMATCH = MAKE_RETURN_CODE(0xB2); + //! [EXPORT] : [COMMENT] Length field mismatch between send and received data + static const ReturnValue_t lENGTH_MISMATCH = MAKE_RETURN_CODE(0xB3); + //! [EXPORT] : [COMMENT] Specified file does not exist + static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xB4); + //! [EXPORT] : [COMMENT] Reply to upload centroid does not match commanded centroid id + static const ReturnValue_t UPLOAD_CENTROID_ID_MISMATCH = MAKE_RETURN_CODE(0xB5); + //! [EXPORT] : [COMMENT] Download blob pixel command has invalid type field + static const ReturnValue_t INVALID_TYPE = MAKE_RETURN_CODE(0xB6); + //! [EXPORT] : [COMMENT] Received FPGA action command with invalid ID + static const ReturnValue_t INVALID_ID = MAKE_RETURN_CODE(0xB7); + + static const size_t MAX_PATH_SIZE = 50; + static const size_t MAX_FILE_NAME = 30; + + // position (uint32) + 1024 image data + static const size_t UPLOAD_COMMAND_LEN = 1028; + // Max valid position value in upload image command + static const uint16_t MAX_POSITION = 4095; + static const uint8_t STATUS_OFFSET = 1; + static const uint8_t TICKS_OFFSET = 2; + static const uint8_t TIME_OFFSET = 6; + static const uint8_t TM_DATA_FIELD_OFFSET = 14; + static const uint8_t PARAMETER_ID_OFFSET = 0; + static const uint8_t ACTION_ID_OFFSET = 0; + static const uint8_t ACTION_DATA_OFFSET = 2; + // Ping request will reply ping with this ID (data field) + static const uint32_t PING_ID = 0x55; + static const uint32_t BOOT_REGION_ID = 1; + static const MutexIF::TimeoutType TIMEOUT_TYPE = MutexIF::TimeoutType::WAITING; + static const uint32_t MUTEX_TIMEOUT = 20; + static const uint32_t BOOT_TIMEOUT = 1000; + + class WriteCmd { + public: + static const uint8_t ADDRESS_OFFSET = 1; + static const uint8_t FILE_OFFSET = 5; + // Minimum length of a write command (region, address and filename) + static const size_t MIN_LENGTH = 7; + }; + + class ReadCmd { + public: + static const uint8_t ADDRESS_OFFSET = 1; + static const uint8_t LENGTH_OFFSET = 5; + static const uint8_t FILE_OFFSET = 9; + // Minimum length of a read command (region, address, length and filename) + static const size_t MIN_LENGTH = 11; + }; + + class EraseCmd { + public: + static const uint8_t LENGTH = 1; + uint8_t rememberRegion = 0; + }; + + EraseCmd eraseCmd; + + class UnlockCmd { + public: + static const uint8_t CODE_OFFSET = 1; + }; + + class ChecksumCmd { + public: + static const uint8_t ADDRESS_OFFSET = 1; + static const uint8_t LENGTH_OFFSET = 5; + // Length of checksum command + static const size_t LENGTH = 9; + uint8_t rememberRegion = 0; + uint32_t rememberAddress = 0; + uint32_t rememberLength = 0; + }; + + ChecksumCmd checksumCmd; + + class SetTimeCmd { + public: + static const uint8_t LENGTH = 8; + }; + + class DownloadCentroidCmd { + public: + static const uint8_t LENGTH = 1; + }; + + class UploadCentroid { + public: + uint8_t rememberId = 0; + }; + + UploadCentroid uploadCentroid; + + class DownloadMatchedStarCmd { + public: + static const uint8_t LENGTH = 1; + }; + + class DownloadDbImageCmd { + public: + static const uint8_t LENGTH = 1; + }; + + class DownloadBlobPixCmd { + public: + static const uint8_t LENGTH = 2; + static const uint8_t NORMAL = 0; + static const uint8_t FAST = 1; + }; + + class FpgaDownloadCmd { + public: + static const uint8_t MIN_LENGTH = 10; + }; + + class FpgaActionCmd { + public: + static const uint8_t LENGTH = 1; + static const uint8_t ID = 3; + }; + + MessageQueueIF* eventQueue = nullptr; + + ArcsecDatalinkLayer dataLinkLayer; + + StarTracker::TemperatureSet temperatureSet; + StarTracker::VersionSet versionSet; + StarTracker::PowerSet powerSet; + StarTracker::InterfaceSet interfaceSet; + StarTracker::TimeSet timeSet; + StarTracker::SolutionSet solutionSet; + StarTracker::HistogramSet histogramSet; + StarTracker::ContrastSet contrastSet; + StarTracker::ChecksumSet checksumSet; + StarTracker::DownloadCentroidSet downloadCentroidSet; + StarTracker::DownloadMatchedStar downloadMatchedStar; + StarTracker::DownloadDBImage downloadDbImage; + StarTracker::DownloadBlobPixel downloadBlobPixel; + + // Pointer to object responsible for uploading and downloading images to/from the star tracker + StrHelper* strHelper = nullptr; + + uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE]; + + // Countdown to insert delay for star tracker to switch from bootloader to firmware program + Countdown bootCountdown; + + std::string paramJsonFile = "/mnt/sd0/startracker/full.json"; + + enum class InternalState { TEMPERATURE_REQUEST }; + + InternalState internalState = InternalState::TEMPERATURE_REQUEST; + + enum class StartupState { + IDLE, + CHECK_BOOT_STATE, + BOOT, + BOOT_DELAY, + LIMITS, + TRACKING, + MOUNTING, + CAMERA, + BLOB, + CENTROIDING, + LISA, + MATCHING, + VALIDATION, + ALGO, + WAIT_FOR_EXECUTION, + DONE + }; + + StartupState startupState = StartupState::IDLE; + + bool strHelperExecuting = false; + + /** + * @brief Handles internal state + */ + void handleInternalState(); + + /** + * @brief Checks mode for commands requiring MODE_ON of MODE_NORMAL for execution. + * + * @param actionId Action id of command to execute + */ + ReturnValue_t checkMode(ActionId_t actionId); + + /** + * @brief This function initializes the serial link ip protocol struct slipInfo. + */ + void slipInit(); + + ReturnValue_t scanForActionReply(DeviceCommandId_t* foundId); + ReturnValue_t scanForParameterReply(DeviceCommandId_t* foundId); + ReturnValue_t scanForTmReply(DeviceCommandId_t* foundId); + + /** + * @brief Fills command buffer with data to ping the star tracker + */ + void preparePingRequest(); + + /** + * @brief Fills command buffer with data to request the time telemetry. + */ + void prepareTimeRequest(); + + /** + * @brief Handles all received event messages + */ + void handleEvent(EventMessage* eventMessage); + + /** + * @brief Executes the write command + * + * @param commandData Pointer to received command data + * @param commandDataLen Size of received command data + * + * @return RETURN_OK if start of execution was successful, otherwise error return value + */ + ReturnValue_t executeWriteCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Starts the execution of the fpga download command + * + * @param commandData Pointer to buffer with command data + * @param commandDataLen Size of received command + */ + ReturnValue_t executeFpgaDownloadCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Extracts information for flash-read-command from TC data and starts execution of + * flash-read-procedure + * + * @param commandData Pointer to received command data + * @param commandDataLen Size of received command data + * + * @return RETURN_OK if start of execution was successful, otherwise error return value + */ + ReturnValue_t executeReadCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills command buffer with data to boot image (works only when star tracker is + * in bootloader mode). + */ + void prepareBootCommand(); + + /** + * @brief Fills command buffer with command to erase a flash region + */ + ReturnValue_t prepareEraseCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills command buffer with command to unlock flash region + */ + ReturnValue_t prepareUnlockCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills command buffer with command to get the checksum of a flash part + */ + ReturnValue_t prepareChecksumCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills command buffer with command to set the unix time + */ + ReturnValue_t prepareSetTimeCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills command buffer with command to request a centroid + */ + ReturnValue_t prepareDownloadCentroidCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills command buffer with command to upload a centroid for testing purpose + */ + ReturnValue_t prepareUploadCentroidCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills the command buffer with the command to take an image. + */ + void prepareTakeImageCommand(const uint8_t* commandData); + + /** + * @brief Fills command buffer with data to request the version telemetry packet + */ + void prepareVersionRequest(); + + /** + * @brief Fills the command buffer with data to request the interface telemetry packet. + */ + void prepareInterfaceRequest(); + + /** + * @brief Fills the command buffer with data to request the power telemetry packet. + */ + void preparePowerRequest(); + + /** + * @brief Fills command buffer with data to reboot star tracker. + */ + void prepareRebootCommand(); + + /** + * @brief Fills command buffer with data to subscribe to a telemetry packet. + * + * @param tmId The ID of the telemetry packet to subscribe to + */ + void prepareSubscriptionCommand(const uint8_t* tmId); + + /** + * @brief Fills command buffer with data to request solution telemtry packet (contains + * attitude information) + */ + void prepareSolutionRequest(); + + /** + * @brief Fills command buffer with data to request temperature from star tracker + */ + void prepareTemperatureRequest(); + + /** + * @brief Fills command buffer with data to request histogram + */ + void prepareHistogramRequest(); + + void prepareContrastRequest(); + + /** + * @brief Fills command buffer with command to reset the error signal of the star tracker + */ + void prepareErrorResetRequest(); + + /** + * @brief Reads parameters from json file specified by string in commandData and + * prepares the command to apply the parameter set to the star tracker + * + * @param commandData Contains string with file name + * @param commandDataLen Length of command + * @param paramSet The object defining the command generation + * + * @return RETURN_OK if successful, otherwise error return Value + */ + ReturnValue_t prepareParamCommand(const uint8_t* commandData, size_t commandDataLen, + ArcsecJsonParamBase& paramSet); + + /** + * @brief Fills command buffer with data to request matched star. + */ + ReturnValue_t prepareDownloadMatchedStarCommand(const uint8_t* commandData, + size_t commandDataLen); + + /** + * @brief Fills command buffer with data to request matched star coordinates. + */ + ReturnValue_t prepareDownloadDbImageCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills command buffer with data to request output of the blob filter algorithm. + */ + ReturnValue_t prepareDownloadBlobPixelCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief With this command the FPGA update will be applied to the star tracker + */ + ReturnValue_t prepareFpgaActionCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Handles action replies with datasets. + */ + ReturnValue_t handleActionReplySet(LocalPoolDataSetBase& dataset, size_t size); + + /** + * @brief Default function to handle action replies + */ + ReturnValue_t handleActionReply(); + + /** + * @brief Handles reply to upload centroid command + */ + ReturnValue_t handleUploadCentroidReply(); + + /** + * @brief Handles reply to erase command + */ + ReturnValue_t handleEraseReply(); + + /** + * @brief Handles reply to checksum command + */ + ReturnValue_t handleChecksumReply(); + + /** + * @brief Handles all set parameter replies + */ + ReturnValue_t handleSetParamReply(); + + ReturnValue_t handlePingReply(); + + /** + * @brief Checks the loaded program by means of the version set + */ + ReturnValue_t checkProgram(); + + /** + * @brief Handles the startup state machine + */ + void handleStartup(const uint8_t* parameterId); + + /** + * @brief Handles telemtry replies and fills the appropriate dataset + * + * @param dataset Dataset where reply data will be written to + * @param size Size of the dataset + * + * @return RETURN_OK if successful, otherwise error return value + */ + ReturnValue_t handleTm(LocalPoolDataSetBase& dataset, size_t size); }; #endif /* MISSION_DEVICES_STARTRACKERHANDLER_H_ */ diff --git a/bsp_q7s/devices/startracker/StarTrackerJsonCommands.cpp b/bsp_q7s/devices/startracker/StarTrackerJsonCommands.cpp index 9c33e1c9..b912c03e 100644 --- a/bsp_q7s/devices/startracker/StarTrackerJsonCommands.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerJsonCommands.cpp @@ -1,716 +1,689 @@ #include "StarTrackerJsonCommands.h" + #include "ArcsecJsonKeys.h" Limits::Limits() : ArcsecJsonParamBase(arcseckeys::LIMITS) {} -size_t Limits::getSize() { - return COMMAND_SIZE; -} +size_t Limits::getSize() { return COMMAND_SIZE; } ReturnValue_t Limits::createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::LIMITS); - offset = 2; - result = getParam(arcseckeys::ACTION, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::FPGA18CURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::FPGA25CURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::FPGA10CURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MCUCURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::CMOS21CURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::CMOSPIXCURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::CMOS33CURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::CMOSVRESCURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::CMOS_TEMPERATURE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MCU_TEMPERATURE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::LIMITS); + offset = 2; + result = getParam(arcseckeys::ACTION, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::FPGA18CURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FPGA25CURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FPGA10CURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MCUCURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CMOS21CURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CMOSPIXCURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CMOS33CURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CMOSVRESCURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CMOS_TEMPERATURE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MCU_TEMPERATURE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + return RETURN_OK; } - Tracking::Tracking() : ArcsecJsonParamBase(arcseckeys::TRACKING) {} -size_t Tracking::getSize() { - return COMMAND_SIZE; -} +size_t Tracking::getSize() { return COMMAND_SIZE; } ReturnValue_t Tracking::createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::TRACKING); - offset = 2; - result = getParam(arcseckeys::THIN_LIMIT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::OUTLIER_THRESHOLD, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::OUTLIER_THRESHOLD_QUEST, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::TRACKER_CHOICE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::TRACKING); + offset = 2; + result = getParam(arcseckeys::THIN_LIMIT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::OUTLIER_THRESHOLD, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::OUTLIER_THRESHOLD_QUEST, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::TRACKER_CHOICE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + return RETURN_OK; } - Mounting::Mounting() : ArcsecJsonParamBase(arcseckeys::MOUNTING) {} -size_t Mounting::getSize() { - return COMMAND_SIZE; -} +size_t Mounting::getSize() { return COMMAND_SIZE; } ReturnValue_t Mounting::createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::MOUNTING); - offset = 2; - result = getParam(arcseckeys::qw, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::qx, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::qy, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::qz, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::MOUNTING); + offset = 2; + result = getParam(arcseckeys::qw, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::qx, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::qy, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::qz, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + return RETURN_OK; } - Camera::Camera() : ArcsecJsonParamBase(arcseckeys::CAMERA) {} -size_t Camera::getSize() { - return COMMAND_SIZE; -} +size_t Camera::getSize() { return COMMAND_SIZE; } ReturnValue_t Camera::createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::CAMERA); - offset = 2; - result = getParam(arcseckeys::MODE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::FOCALLENGTH, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::EXPOSURE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::INTERVAL, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::OFFSET, param); - if (result != RETURN_OK) { - return result; - } - addint16(param, buffer + offset); - offset += sizeof(int16_t); - result = getParam(arcseckeys::PGAGAIN, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::ADCGAIN, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_1, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_1, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_2, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_2, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_3, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_3, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_4, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_4, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_5, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_5, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_6, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_6, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_7, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_7, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_8, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_8, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::FREQ_1, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::FREQ_2, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::CAMERA); + offset = 2; + result = getParam(arcseckeys::MODE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::FOCALLENGTH, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::EXPOSURE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::INTERVAL, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::OFFSET, param); + if (result != RETURN_OK) { + return result; + } + addint16(param, buffer + offset); + offset += sizeof(int16_t); + result = getParam(arcseckeys::PGAGAIN, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::ADCGAIN, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_1, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_1, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_2, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_2, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_3, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_3, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_4, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_4, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_5, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_5, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_6, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_6, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_7, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_7, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_8, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_8, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::FREQ_1, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FREQ_2, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + return RETURN_OK; } - Blob::Blob() : ArcsecJsonParamBase(arcseckeys::BLOB) {} -size_t Blob::getSize() { - return COMMAND_SIZE; -} +size_t Blob::getSize() { return COMMAND_SIZE; } ReturnValue_t Blob::createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::BLOB); - offset = 2; - result = getParam(arcseckeys::MODE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::MIN_VALUE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::MIN_DISTANCE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::NEIGHBOUR_DISTANCE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::NEIGHBOUR_BRIGHT_PIXELS, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::MIN_TOTAL_VALUE, param); - if (result != RETURN_OK) { - return result; - } - adduint16(param, buffer + offset); - offset += sizeof(uint16_t); - result = getParam(arcseckeys::MAX_TOTAL_VALUE, param); - if (result != RETURN_OK) { - return result; - } - adduint16(param, buffer + offset); - offset += sizeof(uint16_t); - result = getParam(arcseckeys::MIN_BRIGHT_NEIGHBOURS, param); - if (result != RETURN_OK) { - return result; - } - adduint16(param, buffer + offset); - offset += sizeof(uint16_t); - result = getParam(arcseckeys::MAX_BRIGHT_NEIGHBOURS, param); - if (result != RETURN_OK) { - return result; - } - adduint16(param, buffer + offset); - offset += sizeof(uint16_t); - result = getParam(arcseckeys::MAX_PIXEL_TO_CONSIDER, param); - if (result != RETURN_OK) { - return result; - } - adduint32(param, buffer + offset); - offset += sizeof(uint32_t); - result = getParam(arcseckeys::SIGNAL_THRESHOLD, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::DARK_THRESHOLD, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::ENABLE_HISTOGRAM, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::ENABLE_CONTRAST, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::BIN_MODE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::BLOB); + offset = 2; + result = getParam(arcseckeys::MODE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::MIN_VALUE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::MIN_DISTANCE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::NEIGHBOUR_DISTANCE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::NEIGHBOUR_BRIGHT_PIXELS, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::MIN_TOTAL_VALUE, param); + if (result != RETURN_OK) { + return result; + } + adduint16(param, buffer + offset); + offset += sizeof(uint16_t); + result = getParam(arcseckeys::MAX_TOTAL_VALUE, param); + if (result != RETURN_OK) { + return result; + } + adduint16(param, buffer + offset); + offset += sizeof(uint16_t); + result = getParam(arcseckeys::MIN_BRIGHT_NEIGHBOURS, param); + if (result != RETURN_OK) { + return result; + } + adduint16(param, buffer + offset); + offset += sizeof(uint16_t); + result = getParam(arcseckeys::MAX_BRIGHT_NEIGHBOURS, param); + if (result != RETURN_OK) { + return result; + } + adduint16(param, buffer + offset); + offset += sizeof(uint16_t); + result = getParam(arcseckeys::MAX_PIXEL_TO_CONSIDER, param); + if (result != RETURN_OK) { + return result; + } + adduint32(param, buffer + offset); + offset += sizeof(uint32_t); + result = getParam(arcseckeys::SIGNAL_THRESHOLD, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::DARK_THRESHOLD, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::ENABLE_HISTOGRAM, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::ENABLE_CONTRAST, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::BIN_MODE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + return RETURN_OK; } - Centroiding::Centroiding() : ArcsecJsonParamBase(arcseckeys::CENTROIDING) {} -size_t Centroiding::getSize() { - return COMMAND_SIZE; -} +size_t Centroiding::getSize() { return COMMAND_SIZE; } ReturnValue_t Centroiding::createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::CENTROIDING); - offset = 2; - result = getParam(arcseckeys::ENABLE_FILTER, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::MAX_QUALITY, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MIN_QUALITY, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MAX_INTENSITY, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MIN_INTENSITY, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MAX_MAGNITUDE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::GAUSSIAN_CMAX, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::GAUSSIAN_CMIN, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::TRANSMATRIX_00, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::TRANSMATRIX_01, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::TRANSMATRIX_10, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::TRANSMATRIX_11, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::CENTROIDING); + offset = 2; + result = getParam(arcseckeys::ENABLE_FILTER, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::MAX_QUALITY, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MIN_QUALITY, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MAX_INTENSITY, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MIN_INTENSITY, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MAX_MAGNITUDE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::GAUSSIAN_CMAX, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::GAUSSIAN_CMIN, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::TRANSMATRIX_00, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::TRANSMATRIX_01, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::TRANSMATRIX_10, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::TRANSMATRIX_11, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + return RETURN_OK; } - Lisa::Lisa() : ArcsecJsonParamBase(arcseckeys::LISA) {} -size_t Lisa::getSize() { - return COMMAND_SIZE; -} +size_t Lisa::getSize() { return COMMAND_SIZE; } ReturnValue_t Lisa::createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::LISA); - offset = 2; - result = getParam(arcseckeys::PREFILTER_DIST_THRESHOLD, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::PREFILTER_ANGLE_THRESHOLD, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::FOV_WIDTH, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::FOV_HEIGHT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::FLOAT_STAR_LIMIT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::CLOSE_STAR_LIMIT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::RATING_WEIGHT_CLOSE_STAR_COUNT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::RATING_WEIGHT_FRACTION_CLOSE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::RATING_WEIGHT_DB_STAR_COUNT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MAX_COMBINATIONS, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::NR_STARS_STOP, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::FRACTION_CLOSE_STOP, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::LISA); + offset = 2; + result = getParam(arcseckeys::PREFILTER_DIST_THRESHOLD, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::PREFILTER_ANGLE_THRESHOLD, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FOV_WIDTH, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FOV_HEIGHT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FLOAT_STAR_LIMIT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CLOSE_STAR_LIMIT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::RATING_WEIGHT_CLOSE_STAR_COUNT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::RATING_WEIGHT_FRACTION_CLOSE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::RATING_WEIGHT_DB_STAR_COUNT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MAX_COMBINATIONS, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::NR_STARS_STOP, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::FRACTION_CLOSE_STOP, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + return RETURN_OK; } - Matching::Matching() : ArcsecJsonParamBase(arcseckeys::MATCHING) {} -size_t Matching::getSize() { - return COMMAND_SIZE; -} +size_t Matching::getSize() { return COMMAND_SIZE; } ReturnValue_t Matching::createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::MATCHING); - offset = 2; - result = getParam(arcseckeys::SQUARED_DISTANCE_LIMIT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::SQUARED_SHIFT_LIMIT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::MATCHING); + offset = 2; + result = getParam(arcseckeys::SQUARED_DISTANCE_LIMIT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::SQUARED_SHIFT_LIMIT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + return RETURN_OK; } - Validation::Validation() : ArcsecJsonParamBase(arcseckeys::VALIDATION) {} -size_t Validation::getSize() { - return COMMAND_SIZE; -} +size_t Validation::getSize() { return COMMAND_SIZE; } ReturnValue_t Validation::createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::VALIDATION); - offset = 2; - result = getParam(arcseckeys::STABLE_COUNT, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::MAX_DIFFERENCE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MIN_TRACKER_CONFIDENCE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MIN_MATCHED_STARS, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::VALIDATION); + offset = 2; + result = getParam(arcseckeys::STABLE_COUNT, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::MAX_DIFFERENCE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MIN_TRACKER_CONFIDENCE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MIN_MATCHED_STARS, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + return RETURN_OK; } Algo::Algo() : ArcsecJsonParamBase(arcseckeys::ALGO) {} -size_t Algo::getSize() { - return COMMAND_SIZE; -} +size_t Algo::getSize() { return COMMAND_SIZE; } ReturnValue_t Algo::createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::ALGO); - offset = 2; - result = getParam(arcseckeys::MODE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::L2T_MIN_CONFIDENCE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::L2T_MIN_MATCHED, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::T2L_MIN_CONFIDENCE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::T2L_MIN_MATCHED, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::ALGO); + offset = 2; + result = getParam(arcseckeys::MODE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::L2T_MIN_CONFIDENCE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::L2T_MIN_MATCHED, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::T2L_MIN_CONFIDENCE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::T2L_MIN_MATCHED, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + return RETURN_OK; } diff --git a/bsp_q7s/devices/startracker/StarTrackerJsonCommands.h b/bsp_q7s/devices/startracker/StarTrackerJsonCommands.h index 868c18ea..96c52fa2 100644 --- a/bsp_q7s/devices/startracker/StarTrackerJsonCommands.h +++ b/bsp_q7s/devices/startracker/StarTrackerJsonCommands.h @@ -9,207 +9,168 @@ #include -#include "fsfw/serviceinterface/ServiceInterface.h" #include "ArcsecJsonParamBase.h" - +#include "fsfw/serviceinterface/ServiceInterface.h" /** * @brief Generates command to set the limit parameters * */ class Limits : public ArcsecJsonParamBase { -public: + public: + Limits(); - Limits(); + size_t getSize(); - size_t getSize(); + private: + static const size_t COMMAND_SIZE = 43; -private: - - static const size_t COMMAND_SIZE = 43; - - virtual ReturnValue_t createCommand(uint8_t* buffer) override; + virtual ReturnValue_t createCommand(uint8_t* buffer) override; }; - /** * @brief Generates the command to configure the tracking algorithm. * */ class Tracking : public ArcsecJsonParamBase { -public: + public: + Tracking(); - Tracking(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 15; - - ReturnValue_t createCommand(uint8_t* buffer) override; + private: + static const size_t COMMAND_SIZE = 15; + ReturnValue_t createCommand(uint8_t* buffer) override; }; - /** * @brief Generates the command to set the mounting quaternion * */ class Mounting : public ArcsecJsonParamBase { -public: + public: + Mounting(); - Mounting(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 18; - - ReturnValue_t createCommand(uint8_t* buffer) override; + private: + static const size_t COMMAND_SIZE = 18; + ReturnValue_t createCommand(uint8_t* buffer) override; }; - /** * @brief Generates the command to set the mounting quaternion * */ class Camera : public ArcsecJsonParamBase { -public: + public: + Camera(); - Camera(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 43; - - ReturnValue_t createCommand(uint8_t* buffer) override; + private: + static const size_t COMMAND_SIZE = 43; + ReturnValue_t createCommand(uint8_t* buffer) override; }; - /** * @brief Generates the command to configure the blob algorithm * */ class Blob : public ArcsecJsonParamBase { -public: + public: + Blob(); - Blob(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 24; - - ReturnValue_t createCommand(uint8_t* buffer) override; + private: + static const size_t COMMAND_SIZE = 24; + ReturnValue_t createCommand(uint8_t* buffer) override; }; - /** * @brief Generates the command to configure the centroiding algorithm * */ class Centroiding : public ArcsecJsonParamBase { -public: + public: + Centroiding(); - Centroiding(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 47; - - ReturnValue_t createCommand(uint8_t* buffer) override; + private: + static const size_t COMMAND_SIZE = 47; + ReturnValue_t createCommand(uint8_t* buffer) override; }; - /** * @brief Generates the command to configure the LISA (lost in space algorithm) * */ class Lisa : public ArcsecJsonParamBase { -public: + public: + Lisa(); - Lisa(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 48; - - ReturnValue_t createCommand(uint8_t* buffer) override; + private: + static const size_t COMMAND_SIZE = 48; + ReturnValue_t createCommand(uint8_t* buffer) override; }; - /** * @brief Generates the command to configure the matching algorithm * */ class Matching : public ArcsecJsonParamBase { -public: + public: + Matching(); - Matching(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 10; - - ReturnValue_t createCommand(uint8_t* buffer) override; + private: + static const size_t COMMAND_SIZE = 10; + ReturnValue_t createCommand(uint8_t* buffer) override; }; - /** * @brief Generates the command to configure the validation parameters * */ class Validation : public ArcsecJsonParamBase { -public: + public: + Validation(); - Validation(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 12; - - ReturnValue_t createCommand(uint8_t* buffer) override; + private: + static const size_t COMMAND_SIZE = 12; + ReturnValue_t createCommand(uint8_t* buffer) override; }; - /** * @brief Generates command to configure the mechanism of automatically switching between the * LISA and other algorithms. * */ class Algo : public ArcsecJsonParamBase { -public: + public: + Algo(); - Algo(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 13; - - ReturnValue_t createCommand(uint8_t* buffer) override; + private: + static const size_t COMMAND_SIZE = 13; + ReturnValue_t createCommand(uint8_t* buffer) override; }; #endif /* BSP_Q7S_DEVICES_DEVICEDEFINITIONS_STARTRACKERJSONCOMMANDS_H_ */ diff --git a/bsp_q7s/devices/startracker/StrHelper.cpp b/bsp_q7s/devices/startracker/StrHelper.cpp index 59587317..00a651b3 100644 --- a/bsp_q7s/devices/startracker/StrHelper.cpp +++ b/bsp_q7s/devices/startracker/StrHelper.cpp @@ -1,702 +1,672 @@ #include "StrHelper.h" +#include +#include + #include "mission/utility/Timestamp.h" -#include -#include +StrHelper::StrHelper(object_id_t objectId) : SystemObject(objectId) {} -StrHelper::StrHelper(object_id_t objectId) : SystemObject(objectId){ - -} - -StrHelper::~StrHelper() { -} +StrHelper::~StrHelper() {} ReturnValue_t StrHelper::initialize() { - sdcMan = SdCardManager::instance(); - if (sdcMan == nullptr) { - sif::warning << "StrHelper::initialize: Invalid SD Card Manager" << std::endl; - return RETURN_FAILED; - } - return RETURN_OK; + sdcMan = SdCardManager::instance(); + if (sdcMan == nullptr) { + sif::warning << "StrHelper::initialize: Invalid SD Card Manager" << std::endl; + return RETURN_FAILED; + } + return RETURN_OK; } ReturnValue_t StrHelper::performOperation(uint8_t operationCode) { - ReturnValue_t result = RETURN_OK; - semaphore.acquire(); - while(true) { - switch(internalState) { - case InternalState::IDLE: { - semaphore.acquire(); - break; + ReturnValue_t result = RETURN_OK; + semaphore.acquire(); + while (true) { + switch (internalState) { + case InternalState::IDLE: { + semaphore.acquire(); + break; + } + case InternalState::UPLOAD_IMAGE: { + result = performImageUpload(); + if (result == RETURN_OK) { + triggerEvent(IMAGE_UPLOAD_SUCCESSFUL); + } else { + triggerEvent(IMAGE_UPLOAD_FAILED); } - case InternalState::UPLOAD_IMAGE: { - result = performImageUpload(); - if (result == RETURN_OK){ - triggerEvent(IMAGE_UPLOAD_SUCCESSFUL); - } - else { - triggerEvent(IMAGE_UPLOAD_FAILED); - } - internalState = InternalState::IDLE; - break; + internalState = InternalState::IDLE; + break; + } + case InternalState::DOWNLOAD_IMAGE: { + result = performImageDownload(); + if (result == RETURN_OK) { + triggerEvent(IMAGE_DOWNLOAD_SUCCESSFUL); + } else { + triggerEvent(IMAGE_DOWNLOAD_FAILED); } - case InternalState::DOWNLOAD_IMAGE: { - result = performImageDownload(); - if (result == RETURN_OK){ - triggerEvent(IMAGE_DOWNLOAD_SUCCESSFUL); - } - else { - triggerEvent(IMAGE_DOWNLOAD_FAILED); - } - internalState = InternalState::IDLE; - break; + internalState = InternalState::IDLE; + break; + } + case InternalState::FLASH_WRITE: { + result = performFlashWrite(); + if (result == RETURN_OK) { + triggerEvent(FLASH_WRITE_SUCCESSFUL); + } else { + triggerEvent(FLASH_WRITE_FAILED); } - case InternalState::FLASH_WRITE: { - result = performFlashWrite(); - if (result == RETURN_OK){ - triggerEvent(FLASH_WRITE_SUCCESSFUL); - } - else { - triggerEvent(FLASH_WRITE_FAILED); - } - internalState = InternalState::IDLE; - break; + internalState = InternalState::IDLE; + break; + } + case InternalState::FLASH_READ: { + result = performFlashRead(); + if (result == RETURN_OK) { + triggerEvent(FLASH_READ_SUCCESSFUL); + } else { + triggerEvent(FLASH_READ_FAILED); } - case InternalState::FLASH_READ: { - result = performFlashRead(); - if (result == RETURN_OK){ - triggerEvent(FLASH_READ_SUCCESSFUL); - } - else { - triggerEvent(FLASH_READ_FAILED); - } - internalState = InternalState::IDLE; - break; + internalState = InternalState::IDLE; + break; + } + case InternalState::DOWNLOAD_FPGA_IMAGE: { + result = performFpgaDownload(); + if (result == RETURN_OK) { + triggerEvent(FPGA_DOWNLOAD_SUCCESSFUL); + } else { + triggerEvent(FPGA_DOWNLOAD_FAILED); } - case InternalState::DOWNLOAD_FPGA_IMAGE: { - result = performFpgaDownload(); - if (result == RETURN_OK){ - triggerEvent(FPGA_DOWNLOAD_SUCCESSFUL); - } - else { - triggerEvent(FPGA_DOWNLOAD_FAILED); - } - internalState = InternalState::IDLE; - break; - } - case InternalState::UPLOAD_FPGA_IMAGE: { - result = performFpgaUpload(); - if (result == RETURN_OK){ - triggerEvent(FPGA_UPLOAD_SUCCESSFUL); - } - else { - triggerEvent(FPGA_UPLOAD_FAILED); - } - internalState = InternalState::IDLE; - break; - } - default: - sif::debug << "StrHelper::performOperation: Invalid state" << std::endl; - break; + internalState = InternalState::IDLE; + break; + } + case InternalState::UPLOAD_FPGA_IMAGE: { + result = performFpgaUpload(); + if (result == RETURN_OK) { + triggerEvent(FPGA_UPLOAD_SUCCESSFUL); + } else { + triggerEvent(FPGA_UPLOAD_FAILED); } + internalState = InternalState::IDLE; + break; + } + default: + sif::debug << "StrHelper::performOperation: Invalid state" << std::endl; + break; } + } } ReturnValue_t StrHelper::setComIF(DeviceCommunicationIF* communicationInterface_) { - uartComIF = dynamic_cast(communicationInterface_); - if (uartComIF == nullptr) { - sif::warning << "StrHelper::initialize: Invalid uart com if" << std::endl; - return RETURN_FAILED; - } - return RETURN_OK; + uartComIF = dynamic_cast(communicationInterface_); + if (uartComIF == nullptr) { + sif::warning << "StrHelper::initialize: Invalid uart com if" << std::endl; + return RETURN_FAILED; + } + return RETURN_OK; } -void StrHelper::setComCookie(CookieIF* comCookie_) { - comCookie = comCookie_; -} +void StrHelper::setComCookie(CookieIF* comCookie_) { comCookie = comCookie_; } ReturnValue_t StrHelper::startImageUpload(std::string fullname) { - ReturnValue_t result = checkPath(fullname); - if (result != RETURN_OK) { - return result; - } - uploadImage.uploadFile = fullname; - if(not std::filesystem::exists(fullname)) { - return FILE_NOT_EXISTS; - } - internalState = InternalState::UPLOAD_FPGA_IMAGE; - semaphore.release(); - terminate = false; - return RETURN_OK; + ReturnValue_t result = checkPath(fullname); + if (result != RETURN_OK) { + return result; + } + uploadImage.uploadFile = fullname; + if (not std::filesystem::exists(fullname)) { + return FILE_NOT_EXISTS; + } + internalState = InternalState::UPLOAD_FPGA_IMAGE; + semaphore.release(); + terminate = false; + return RETURN_OK; } ReturnValue_t StrHelper::startImageDownload(std::string path) { - ReturnValue_t result = checkPath(path); - if (result != RETURN_OK) { - return result; - } - if(not std::filesystem::exists(path)) { - return PATH_NOT_EXISTS; - } - downloadImage.path = path; - internalState = InternalState::DOWNLOAD_IMAGE; - terminate = false; - semaphore.release(); - return RETURN_OK; + ReturnValue_t result = checkPath(path); + if (result != RETURN_OK) { + return result; + } + if (not std::filesystem::exists(path)) { + return PATH_NOT_EXISTS; + } + downloadImage.path = path; + internalState = InternalState::DOWNLOAD_IMAGE; + terminate = false; + semaphore.release(); + return RETURN_OK; } -void StrHelper::stopProcess() { - terminate = true; +void StrHelper::stopProcess() { terminate = true; } + +void StrHelper::setDownloadImageName(std::string filename) { downloadImage.filename = filename; } + +void StrHelper::setFlashReadFilename(std::string filename) { flashRead.filename = filename; } + +void StrHelper::setDownloadFpgaImage(std::string filename) { fpgaDownload.fileName = filename; } + +ReturnValue_t StrHelper::startFlashWrite(std::string fullname, uint8_t region, uint32_t address) { + ReturnValue_t result = checkPath(fullname); + if (result != RETURN_OK) { + return result; + } + flashWrite.fullname = fullname; + if (not std::filesystem::exists(flashWrite.fullname)) { + return FILE_NOT_EXISTS; + } + flashWrite.address = address; + flashWrite.region = region; + internalState = InternalState::FLASH_WRITE; + semaphore.release(); + terminate = false; + return RETURN_OK; } -void StrHelper::setDownloadImageName(std::string filename) { - downloadImage.filename = filename; -} - -void StrHelper::setFlashReadFilename(std::string filename) { - flashRead.filename = filename; -} - -void StrHelper::setDownloadFpgaImage(std::string filename) { - fpgaDownload.fileName = filename; -} - -ReturnValue_t StrHelper::startFlashWrite(std::string fullname, uint8_t region, - uint32_t address) { - ReturnValue_t result = checkPath(fullname); - if (result != RETURN_OK) { - return result; - } - flashWrite.fullname = fullname; - if(not std::filesystem::exists(flashWrite.fullname)) { - return FILE_NOT_EXISTS; - } - flashWrite.address = address; - flashWrite.region = region; - internalState = InternalState::FLASH_WRITE; - semaphore.release(); - terminate = false; - return RETURN_OK; -} - -ReturnValue_t StrHelper::startFlashRead(std::string path, uint8_t region, - uint32_t address, uint32_t length) { - ReturnValue_t result = checkPath(path); - if (result != RETURN_OK) { - return result; - } - flashRead.path = path; - if(not std::filesystem::exists(flashRead.path)) { - return FILE_NOT_EXISTS; - } - flashRead.address = address; - flashRead.region = region; - flashRead.size = length; - internalState = InternalState::FLASH_READ; - semaphore.release(); - terminate = false; - return RETURN_OK; +ReturnValue_t StrHelper::startFlashRead(std::string path, uint8_t region, uint32_t address, + uint32_t length) { + ReturnValue_t result = checkPath(path); + if (result != RETURN_OK) { + return result; + } + flashRead.path = path; + if (not std::filesystem::exists(flashRead.path)) { + return FILE_NOT_EXISTS; + } + flashRead.address = address; + flashRead.region = region; + flashRead.size = length; + internalState = InternalState::FLASH_READ; + semaphore.release(); + terminate = false; + return RETURN_OK; } ReturnValue_t StrHelper::startFpgaDownload(std::string path, uint32_t startPosition, - uint32_t length) { - fpgaDownload.path = path; - fpgaDownload.startPosition = startPosition; - fpgaDownload.length = length; - internalState = InternalState::DOWNLOAD_FPGA_IMAGE; - semaphore.release(); - terminate = false; - return RETURN_OK; + uint32_t length) { + fpgaDownload.path = path; + fpgaDownload.startPosition = startPosition; + fpgaDownload.length = length; + internalState = InternalState::DOWNLOAD_FPGA_IMAGE; + semaphore.release(); + terminate = false; + return RETURN_OK; } ReturnValue_t StrHelper::startFpgaUpload(std::string uploadFile) { - fpgaUpload.uploadFile = uploadFile; - internalState = InternalState::UPLOAD_FPGA_IMAGE; - semaphore.release(); - terminate = false; - return RETURN_OK; + fpgaUpload.uploadFile = uploadFile; + internalState = InternalState::UPLOAD_FPGA_IMAGE; + semaphore.release(); + terminate = false; + return RETURN_OK; } ReturnValue_t StrHelper::performImageDownload() { - ReturnValue_t result; - struct DownloadActionRequest downloadReq; - uint32_t size = 0; - uint32_t retries = 0; - Timestamp timestamp; - std::string image = downloadImage.path + "/" + timestamp.str() + downloadImage.filename ; - std::ofstream file(image, std::ios_base::app | std::ios_base::out); - if(not std::filesystem::exists(image)) { - return FILE_CREATION_FAILED; + ReturnValue_t result; + struct DownloadActionRequest downloadReq; + uint32_t size = 0; + uint32_t retries = 0; + Timestamp timestamp; + std::string image = downloadImage.path + "/" + timestamp.str() + downloadImage.filename; + std::ofstream file(image, std::ios_base::app | std::ios_base::out); + if (not std::filesystem::exists(image)) { + return FILE_CREATION_FAILED; + } + downloadReq.position = 0; + while (downloadReq.position < ImageDownload::LAST_POSITION) { + if (terminate) { + return RETURN_OK; } - downloadReq.position = 0; - while(downloadReq.position < ImageDownload::LAST_POSITION) { - if (terminate) { - return RETURN_OK; - } - arc_pack_download_action_req(&downloadReq, commandBuffer, &size); - result = sendAndRead(size, downloadReq.position); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - result = checkActionReply(); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - result = checkReplyPosition(downloadReq.position); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - file.write(reinterpret_cast(datalinkLayer.getReply() + IMAGE_DATA_OFFSET), - IMAGE_DATA_SIZE); - downloadReq.position++; - retries = 0; + arc_pack_download_action_req(&downloadReq, commandBuffer, &size); + result = sendAndRead(size, downloadReq.position); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; } - file.close(); - return RETURN_OK; + result = checkActionReply(); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + result = checkReplyPosition(downloadReq.position); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + file.write(reinterpret_cast(datalinkLayer.getReply() + IMAGE_DATA_OFFSET), + IMAGE_DATA_SIZE); + downloadReq.position++; + retries = 0; + } + file.close(); + return RETURN_OK; } ReturnValue_t StrHelper::performImageUpload() { - ReturnValue_t result = RETURN_OK; - uint32_t size = 0; - uint32_t imageSize = 0; - struct UploadActionRequest uploadReq; - uploadReq.position = 0; - std::memset(&uploadReq.data, 0, sizeof(uploadReq.data)); - if (not std::filesystem::exists(uploadImage.uploadFile)) { - triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast(internalState)); - internalState = InternalState::IDLE; - return RETURN_FAILED; + ReturnValue_t result = RETURN_OK; + uint32_t size = 0; + uint32_t imageSize = 0; + struct UploadActionRequest uploadReq; + uploadReq.position = 0; + std::memset(&uploadReq.data, 0, sizeof(uploadReq.data)); + if (not std::filesystem::exists(uploadImage.uploadFile)) { + triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast(internalState)); + internalState = InternalState::IDLE; + return RETURN_FAILED; + } + std::ifstream file(uploadImage.uploadFile, std::ifstream::binary); + // Set position of next character to end of file input stream + file.seekg(0, file.end); + // tellg returns position of character in input stream + imageSize = file.tellg(); + while ((uploadReq.position + 1) * SIZE_IMAGE_PART < imageSize) { + if (terminate) { + return RETURN_OK; } - std::ifstream file(uploadImage.uploadFile, std::ifstream::binary); - // Set position of next character to end of file input stream - file.seekg(0, file.end); - // tellg returns position of character in input stream - imageSize = file.tellg(); - while((uploadReq.position + 1) * SIZE_IMAGE_PART < imageSize) { - if (terminate) { - return RETURN_OK; - } - file.seekg(uploadReq.position * SIZE_IMAGE_PART, file.beg); - file.read(reinterpret_cast(uploadReq.data), SIZE_IMAGE_PART); - arc_pack_upload_action_req(&uploadReq, commandBuffer, &size); - result = sendAndRead(size, uploadReq.position); - if (result != RETURN_OK) { - return RETURN_FAILED; - } - result = checkActionReply(); - if (result != RETURN_OK) { - return result; - } - uploadReq.position++; - } - std::memset(uploadReq.data, 0, sizeof(uploadReq.data)); - uint32_t remainder = imageSize - uploadReq.position * SIZE_IMAGE_PART; file.seekg(uploadReq.position * SIZE_IMAGE_PART, file.beg); - file.read(reinterpret_cast(uploadReq.data), remainder); - file.close(); - uploadReq.position++; + file.read(reinterpret_cast(uploadReq.data), SIZE_IMAGE_PART); arc_pack_upload_action_req(&uploadReq, commandBuffer, &size); result = sendAndRead(size, uploadReq.position); if (result != RETURN_OK) { - return RETURN_FAILED; + return RETURN_FAILED; } result = checkActionReply(); if (result != RETURN_OK) { - return result; + return result; } - return RETURN_OK; + uploadReq.position++; + } + std::memset(uploadReq.data, 0, sizeof(uploadReq.data)); + uint32_t remainder = imageSize - uploadReq.position * SIZE_IMAGE_PART; + file.seekg(uploadReq.position * SIZE_IMAGE_PART, file.beg); + file.read(reinterpret_cast(uploadReq.data), remainder); + file.close(); + uploadReq.position++; + arc_pack_upload_action_req(&uploadReq, commandBuffer, &size); + result = sendAndRead(size, uploadReq.position); + if (result != RETURN_OK) { + return RETURN_FAILED; + } + result = checkActionReply(); + if (result != RETURN_OK) { + return result; + } + return RETURN_OK; } ReturnValue_t StrHelper::performFlashWrite() { - ReturnValue_t result = RETURN_OK; - uint32_t size = 0; - uint32_t remainingBytes = 0; - uint32_t fileSize = 0; - struct WriteActionRequest req; - if (not std::filesystem::exists(flashWrite.fullname)) { - triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast(internalState)); - internalState = InternalState::IDLE; - return RETURN_FAILED; - } - std::ifstream file(flashWrite.fullname, std::ifstream::binary); - file.seekg(0, file.end); - fileSize = file.tellg(); - remainingBytes = fileSize; - req.region = flashWrite.region; - req.address = flashWrite.address; - req.length = MAX_FLASH_DATA; - while(remainingBytes >= MAX_FLASH_DATA) { - if (terminate) { - return RETURN_OK; - } - file.seekg(fileSize - remainingBytes, file.beg); - file.read(reinterpret_cast(req.data), MAX_FLASH_DATA); - arc_pack_write_action_req(&req, commandBuffer, &size); - result = sendAndRead(size, req.address); - if (result != RETURN_OK) { - return RETURN_FAILED; - } - result = checkFlashActionReply(req.region, req.address, req.length); - if (result != RETURN_OK) { - return result; - } - remainingBytes = remainingBytes - MAX_FLASH_DATA; + ReturnValue_t result = RETURN_OK; + uint32_t size = 0; + uint32_t remainingBytes = 0; + uint32_t fileSize = 0; + struct WriteActionRequest req; + if (not std::filesystem::exists(flashWrite.fullname)) { + triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast(internalState)); + internalState = InternalState::IDLE; + return RETURN_FAILED; + } + std::ifstream file(flashWrite.fullname, std::ifstream::binary); + file.seekg(0, file.end); + fileSize = file.tellg(); + remainingBytes = fileSize; + req.region = flashWrite.region; + req.address = flashWrite.address; + req.length = MAX_FLASH_DATA; + while (remainingBytes >= MAX_FLASH_DATA) { + if (terminate) { + return RETURN_OK; } file.seekg(fileSize - remainingBytes, file.beg); - file.read(reinterpret_cast(req.data), remainingBytes); - file.close(); + file.read(reinterpret_cast(req.data), MAX_FLASH_DATA); arc_pack_write_action_req(&req, commandBuffer, &size); result = sendAndRead(size, req.address); if (result != RETURN_OK) { - return RETURN_FAILED; + return RETURN_FAILED; } result = checkFlashActionReply(req.region, req.address, req.length); if (result != RETURN_OK) { - return result; + return result; } - return RETURN_OK; + remainingBytes = remainingBytes - MAX_FLASH_DATA; + } + file.seekg(fileSize - remainingBytes, file.beg); + file.read(reinterpret_cast(req.data), remainingBytes); + file.close(); + arc_pack_write_action_req(&req, commandBuffer, &size); + result = sendAndRead(size, req.address); + if (result != RETURN_OK) { + return RETURN_FAILED; + } + result = checkFlashActionReply(req.region, req.address, req.length); + if (result != RETURN_OK) { + return result; + } + return RETURN_OK; } ReturnValue_t StrHelper::performFlashRead() { - ReturnValue_t result; - struct ReadActionRequest req; - uint32_t bytesRead = 0; - uint32_t size = 0; - uint32_t retries = 0; - Timestamp timestamp; - std::string fullname = flashRead.path + "/" + timestamp.str() + flashRead.filename ; - std::ofstream file(fullname, std::ios_base::app | std::ios_base::out); - if (not std::filesystem::exists(fullname)) { - return FILE_CREATION_FAILED; + ReturnValue_t result; + struct ReadActionRequest req; + uint32_t bytesRead = 0; + uint32_t size = 0; + uint32_t retries = 0; + Timestamp timestamp; + std::string fullname = flashRead.path + "/" + timestamp.str() + flashRead.filename; + std::ofstream file(fullname, std::ios_base::app | std::ios_base::out); + if (not std::filesystem::exists(fullname)) { + return FILE_CREATION_FAILED; + } + req.region = flashRead.region; + while (bytesRead < flashRead.size) { + if (terminate) { + return RETURN_OK; } - req.region = flashRead.region; - while(bytesRead < flashRead.size) { - if (terminate) { - return RETURN_OK; - } - if ((flashRead.size - bytesRead) < MAX_FLASH_DATA) { - req.length = flashRead.size - bytesRead; - } - else { - req.length = MAX_FLASH_DATA; - } - req.address = flashRead.address + bytesRead; - arc_pack_read_action_req(&req, commandBuffer, &size); - result = sendAndRead(size, req.address); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - result = checkActionReply(); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - result = checkFlashActionReply(req.region, req.address, req.length); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - file.write(reinterpret_cast(datalinkLayer.getReply() + FLASH_READ_DATA_OFFSET), - req.length); - bytesRead += req.length; - retries = 0; + if ((flashRead.size - bytesRead) < MAX_FLASH_DATA) { + req.length = flashRead.size - bytesRead; + } else { + req.length = MAX_FLASH_DATA; } - file.close(); - return RETURN_OK; + req.address = flashRead.address + bytesRead; + arc_pack_read_action_req(&req, commandBuffer, &size); + result = sendAndRead(size, req.address); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + result = checkActionReply(); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + result = checkFlashActionReply(req.region, req.address, req.length); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + file.write(reinterpret_cast(datalinkLayer.getReply() + FLASH_READ_DATA_OFFSET), + req.length); + bytesRead += req.length; + retries = 0; + } + file.close(); + return RETURN_OK; } ReturnValue_t StrHelper::performFpgaDownload() { - ReturnValue_t result; - struct DownloadFPGAImageActionRequest req; - uint32_t size = 0; - uint32_t retries = 0; - Timestamp timestamp; - std::string image = fpgaDownload.path + "/" + timestamp.str() + fpgaDownload.fileName; - std::ofstream file(image, std::ios_base::app | std::ios_base::out); - if(not std::filesystem::exists(image)) { - return FILE_CREATION_FAILED; + ReturnValue_t result; + struct DownloadFPGAImageActionRequest req; + uint32_t size = 0; + uint32_t retries = 0; + Timestamp timestamp; + std::string image = fpgaDownload.path + "/" + timestamp.str() + fpgaDownload.fileName; + std::ofstream file(image, std::ios_base::app | std::ios_base::out); + if (not std::filesystem::exists(image)) { + return FILE_CREATION_FAILED; + } + req.pos = fpgaDownload.startPosition; + while (req.pos < fpgaDownload.length) { + if (terminate) { + return RETURN_OK; } - req.pos = fpgaDownload.startPosition; - while(req.pos < fpgaDownload.length) { - if (terminate) { - return RETURN_OK; - } - if (fpgaDownload.length - req.pos >= FpgaDownload::MAX_DATA) { - req.length = FpgaDownload::MAX_DATA; - } - else { - req.length = fpgaDownload.length - req.pos; - } - arc_pack_downloadfpgaimage_action_req(&req, commandBuffer, &size); - result = sendAndRead(size, req.pos); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - result = checkFpgaActionReply(req.pos, req.length); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - file.write(reinterpret_cast(datalinkLayer.getReply() + FpgaDownload::DATA_OFFSET), - req.length); - req.pos += req.length; - retries = 0; + if (fpgaDownload.length - req.pos >= FpgaDownload::MAX_DATA) { + req.length = FpgaDownload::MAX_DATA; + } else { + req.length = fpgaDownload.length - req.pos; } - file.close(); - return RETURN_OK; + arc_pack_downloadfpgaimage_action_req(&req, commandBuffer, &size); + result = sendAndRead(size, req.pos); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + result = checkFpgaActionReply(req.pos, req.length); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + file.write(reinterpret_cast(datalinkLayer.getReply() + FpgaDownload::DATA_OFFSET), + req.length); + req.pos += req.length; + retries = 0; + } + file.close(); + return RETURN_OK; } ReturnValue_t StrHelper::performFpgaUpload() { - ReturnValue_t result = RETURN_OK; - uint32_t commandSize = 0; - uint32_t bytesUploaded = 0; - uint32_t fileSize = 0; - struct UploadFPGAImageActionRequest req; - if (not std::filesystem::exists(fpgaUpload.uploadFile)) { - triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast(internalState)); - internalState = InternalState::IDLE; - return RETURN_FAILED; + ReturnValue_t result = RETURN_OK; + uint32_t commandSize = 0; + uint32_t bytesUploaded = 0; + uint32_t fileSize = 0; + struct UploadFPGAImageActionRequest req; + if (not std::filesystem::exists(fpgaUpload.uploadFile)) { + triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast(internalState)); + internalState = InternalState::IDLE; + return RETURN_FAILED; + } + std::ifstream file(flashWrite.fullname, std::ifstream::binary); + file.seekg(0, file.end); + fileSize = file.tellg(); + req.pos = 0; + while (bytesUploaded <= fileSize) { + if (terminate) { + return RETURN_OK; } - std::ifstream file(flashWrite.fullname, std::ifstream::binary); - file.seekg(0, file.end); - fileSize = file.tellg(); - req.pos = 0; - while(bytesUploaded <= fileSize) { - if (terminate) { - return RETURN_OK; - } - if (fileSize - bytesUploaded > FpgaUpload::MAX_DATA) { - req.length = FpgaUpload::MAX_DATA; - } - else { - req.length = fileSize - bytesUploaded; - } - file.seekg(bytesUploaded, file.beg); - file.read(reinterpret_cast(req.data), req.length); - arc_pack_uploadfpgaimage_action_req(&req, commandBuffer, &commandSize); - result = sendAndRead(commandSize, req.pos); - if (result != RETURN_OK) { - return RETURN_FAILED; - } - result = checkFpgaActionReply(req.pos, req.length); - if (result != RETURN_OK) { - return result; - } - bytesUploaded += req.length; + if (fileSize - bytesUploaded > FpgaUpload::MAX_DATA) { + req.length = FpgaUpload::MAX_DATA; + } else { + req.length = fileSize - bytesUploaded; } - return RETURN_OK; + file.seekg(bytesUploaded, file.beg); + file.read(reinterpret_cast(req.data), req.length); + arc_pack_uploadfpgaimage_action_req(&req, commandBuffer, &commandSize); + result = sendAndRead(commandSize, req.pos); + if (result != RETURN_OK) { + return RETURN_FAILED; + } + result = checkFpgaActionReply(req.pos, req.length); + if (result != RETURN_OK) { + return result; + } + bytesUploaded += req.length; + } + return RETURN_OK; } ReturnValue_t StrHelper::sendAndRead(size_t size, uint32_t parameter) { - ReturnValue_t result = RETURN_OK; - ReturnValue_t decResult = RETURN_OK; - size_t receivedDataLen = 0; - uint8_t *receivedData = nullptr; - size_t bytesLeft = 0; - uint32_t missedReplies = 0; - datalinkLayer.encodeFrame(commandBuffer, size); - result = uartComIF->sendMessage(comCookie, datalinkLayer.getEncodedFrame(), - datalinkLayer.getEncodedLength()); + ReturnValue_t result = RETURN_OK; + ReturnValue_t decResult = RETURN_OK; + size_t receivedDataLen = 0; + uint8_t* receivedData = nullptr; + size_t bytesLeft = 0; + uint32_t missedReplies = 0; + datalinkLayer.encodeFrame(commandBuffer, size); + result = uartComIF->sendMessage(comCookie, datalinkLayer.getEncodedFrame(), + datalinkLayer.getEncodedLength()); + if (result != RETURN_OK) { + sif::warning << "StrHelper::sendAndRead: Failed to send packet" << std::endl; + triggerEvent(STR_HELPER_SENDING_PACKET_FAILED, result, parameter); + return RETURN_FAILED; + } + decResult = ArcsecDatalinkLayer::DEC_IN_PROGRESS; + while (decResult == ArcsecDatalinkLayer::DEC_IN_PROGRESS) { + result = uartComIF->requestReceiveMessage(comCookie, StarTracker::MAX_FRAME_SIZE * 2 + 2); if (result != RETURN_OK) { - sif::warning << "StrHelper::sendAndRead: Failed to send packet" << std::endl; - triggerEvent(STR_HELPER_SENDING_PACKET_FAILED, result, parameter); - return RETURN_FAILED; + sif::warning << "StrHelper::sendAndRead: Failed to request reply" << std::endl; + triggerEvent(STR_HELPER_REQUESTING_MSG_FAILED, result, parameter); + return RETURN_FAILED; } - decResult = ArcsecDatalinkLayer::DEC_IN_PROGRESS; - while (decResult == ArcsecDatalinkLayer::DEC_IN_PROGRESS) { - result = uartComIF->requestReceiveMessage(comCookie, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - if (result != RETURN_OK) { - sif::warning << "StrHelper::sendAndRead: Failed to request reply" << std::endl; - triggerEvent(STR_HELPER_REQUESTING_MSG_FAILED, result, parameter); - return RETURN_FAILED; - } - result = uartComIF->readReceivedMessage(comCookie, &receivedData, &receivedDataLen); - if (result != RETURN_OK) { - sif::warning << "StrHelper::sendAndRead: Failed to read received message" << std::endl; - triggerEvent(STR_HELPER_READING_REPLY_FAILED, result, parameter); - return RETURN_FAILED; - } - if (receivedDataLen == 0 && missedReplies < MAX_POLLS) { - missedReplies++; - continue; - } - else if ((receivedDataLen == 0) && (missedReplies >= MAX_POLLS)) { - triggerEvent(STR_HELPER_NO_REPLY, parameter); - return RETURN_FAILED; - } - else { - missedReplies = 0; - } - decResult = datalinkLayer.decodeFrame(receivedData, receivedDataLen, &bytesLeft); - if (bytesLeft != 0) { - // This should never happen - sif::warning << "StrHelper::sendAndRead: Bytes left after decoding" << std::endl; - triggerEvent(STR_HELPER_COM_ERROR, result, parameter); - return RETURN_FAILED; - } + result = uartComIF->readReceivedMessage(comCookie, &receivedData, &receivedDataLen); + if (result != RETURN_OK) { + sif::warning << "StrHelper::sendAndRead: Failed to read received message" << std::endl; + triggerEvent(STR_HELPER_READING_REPLY_FAILED, result, parameter); + return RETURN_FAILED; } - if (decResult != RETURN_OK) { - triggerEvent(STR_HELPER_DEC_ERROR, decResult, parameter); - return RETURN_FAILED; + if (receivedDataLen == 0 && missedReplies < MAX_POLLS) { + missedReplies++; + continue; + } else if ((receivedDataLen == 0) && (missedReplies >= MAX_POLLS)) { + triggerEvent(STR_HELPER_NO_REPLY, parameter); + return RETURN_FAILED; + } else { + missedReplies = 0; } - return RETURN_OK; + decResult = datalinkLayer.decodeFrame(receivedData, receivedDataLen, &bytesLeft); + if (bytesLeft != 0) { + // This should never happen + sif::warning << "StrHelper::sendAndRead: Bytes left after decoding" << std::endl; + triggerEvent(STR_HELPER_COM_ERROR, result, parameter); + return RETURN_FAILED; + } + } + if (decResult != RETURN_OK) { + triggerEvent(STR_HELPER_DEC_ERROR, decResult, parameter); + return RETURN_FAILED; + } + return RETURN_OK; } ReturnValue_t StrHelper::checkActionReply() { - uint8_t type = datalinkLayer.getReplyFrameType(); - if (type != TMTC_ACTIONREPLY) { - sif::warning << "StrHelper::checkActionReply: Received reply with invalid type ID" - << std::endl; - return INVALID_TYPE_ID; - } - uint8_t status = datalinkLayer.getStatusField(); - if (status != ArcsecDatalinkLayer::STATUS_OK) { - sif::warning << "StrHelper::checkActionReply: Status failure: " - << static_cast(status) << std::endl; - return STATUS_ERROR; - } - return RETURN_OK; + uint8_t type = datalinkLayer.getReplyFrameType(); + if (type != TMTC_ACTIONREPLY) { + sif::warning << "StrHelper::checkActionReply: Received reply with invalid type ID" << std::endl; + return INVALID_TYPE_ID; + } + uint8_t status = datalinkLayer.getStatusField(); + if (status != ArcsecDatalinkLayer::STATUS_OK) { + sif::warning << "StrHelper::checkActionReply: Status failure: " + << static_cast(status) << std::endl; + return STATUS_ERROR; + } + return RETURN_OK; } ReturnValue_t StrHelper::checkReplyPosition(uint32_t expectedPosition) { - uint32_t receivedPosition = 0; - std::memcpy(&receivedPosition, datalinkLayer.getReply() + POS_OFFSET, sizeof(receivedPosition)); - if (receivedPosition != expectedPosition) { - triggerEvent(POSITION_MISMATCH, receivedPosition); - return RETURN_FAILED; - } - return RETURN_OK; + uint32_t receivedPosition = 0; + std::memcpy(&receivedPosition, datalinkLayer.getReply() + POS_OFFSET, sizeof(receivedPosition)); + if (receivedPosition != expectedPosition) { + triggerEvent(POSITION_MISMATCH, receivedPosition); + return RETURN_FAILED; + } + return RETURN_OK; } ReturnValue_t StrHelper::checkFlashActionReply(uint8_t region_, uint32_t address_, - uint16_t length_) { - ReturnValue_t result = RETURN_OK; - result = checkActionReply(); - if (result != RETURN_OK) { - return result; - } - const uint8_t* data = datalinkLayer.getReply(); - uint8_t region = *(data + REGION_OFFSET); - uint32_t address; - const uint8_t* addressData = data + ADDRESS_OFFSET; - size_t size = sizeof(address); - result = SerializeAdapter::deSerialize(&address, &addressData, &size, - SerializeIF::Endianness::LITTLE); - if (result != RETURN_OK) { - sif::warning << "StrHelper::checkFlashActionReply: Deserialization of address failed" - << std::endl; - return result; - } - uint16_t length = 0; - size = sizeof(length); - const uint8_t* lengthData = data + LENGTH_OFFSET; - result = SerializeAdapter::deSerialize(&length, lengthData, &size, - SerializeIF::Endianness::LITTLE); - if (result != RETURN_OK) { - sif::warning << "StrHelper::checkFlashActionReply: Deserialization of length failed" - << std::endl; - } - if (region != region_) { - return REGION_MISMATCH; - } - if (address != address_) { - return ADDRESS_MISMATCH; - } - if (length != length_) { - return LENGTH_MISMATCH; - } - return RETURN_OK; + uint16_t length_) { + ReturnValue_t result = RETURN_OK; + result = checkActionReply(); + if (result != RETURN_OK) { + return result; + } + const uint8_t* data = datalinkLayer.getReply(); + uint8_t region = *(data + REGION_OFFSET); + uint32_t address; + const uint8_t* addressData = data + ADDRESS_OFFSET; + size_t size = sizeof(address); + result = + SerializeAdapter::deSerialize(&address, &addressData, &size, SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StrHelper::checkFlashActionReply: Deserialization of address failed" + << std::endl; + return result; + } + uint16_t length = 0; + size = sizeof(length); + const uint8_t* lengthData = data + LENGTH_OFFSET; + result = + SerializeAdapter::deSerialize(&length, lengthData, &size, SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StrHelper::checkFlashActionReply: Deserialization of length failed" + << std::endl; + } + if (region != region_) { + return REGION_MISMATCH; + } + if (address != address_) { + return ADDRESS_MISMATCH; + } + if (length != length_) { + return LENGTH_MISMATCH; + } + return RETURN_OK; } -ReturnValue_t StrHelper::checkFpgaActionReply(uint32_t expectedPosition, - uint32_t expectedLength) { - ReturnValue_t result = RETURN_OK; - result = checkActionReply(); - if (result != RETURN_OK) { - return result; - } - const uint8_t* data = datalinkLayer.getReply() + ACTION_DATA_OFFSET; - uint32_t position; - size_t size = sizeof(position); - result = SerializeAdapter::deSerialize(&position, &data, &size, - SerializeIF::Endianness::LITTLE); - if (result != RETURN_OK) { - sif::warning << "StrHelper::checkFpgaActionReply: Deserialization of position failed" - << std::endl; - return result; - } - uint32_t length; - size = sizeof(length); - result = SerializeAdapter::deSerialize(&length, &data, &size, - SerializeIF::Endianness::LITTLE); - if (result != RETURN_OK) { - sif::warning << "StrHelper::checkFpgaActionReply: Deserialization of length failed" - << std::endl; - return result; - } +ReturnValue_t StrHelper::checkFpgaActionReply(uint32_t expectedPosition, uint32_t expectedLength) { + ReturnValue_t result = RETURN_OK; + result = checkActionReply(); + if (result != RETURN_OK) { return result; + } + const uint8_t* data = datalinkLayer.getReply() + ACTION_DATA_OFFSET; + uint32_t position; + size_t size = sizeof(position); + result = SerializeAdapter::deSerialize(&position, &data, &size, SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StrHelper::checkFpgaActionReply: Deserialization of position failed" + << std::endl; + return result; + } + uint32_t length; + size = sizeof(length); + result = SerializeAdapter::deSerialize(&length, &data, &size, SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StrHelper::checkFpgaActionReply: Deserialization of length failed" + << std::endl; + return result; + } + return result; } ReturnValue_t StrHelper::checkPath(std::string name) { - if (name.substr(0, sizeof(SdCardManager::SD_0_MOUNT_POINT)) - == std::string(SdCardManager::SD_0_MOUNT_POINT)) { - if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { - sif::warning << "StrHelper::checkPath: SD card 0 not mounted" << std::endl; - return SD_NOT_MOUNTED; - } - } else if (name.substr(0, sizeof(SdCardManager::SD_1_MOUNT_POINT)) - == std::string(SdCardManager::SD_1_MOUNT_POINT)) { - if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { - sif::warning << "StrHelper::checkPath: SD card 1 not mounted" << std::endl; - return SD_NOT_MOUNTED; - } + if (name.substr(0, sizeof(SdCardManager::SD_0_MOUNT_POINT)) == + std::string(SdCardManager::SD_0_MOUNT_POINT)) { + if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { + sif::warning << "StrHelper::checkPath: SD card 0 not mounted" << std::endl; + return SD_NOT_MOUNTED; } - return RETURN_OK; + } else if (name.substr(0, sizeof(SdCardManager::SD_1_MOUNT_POINT)) == + std::string(SdCardManager::SD_1_MOUNT_POINT)) { + if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { + sif::warning << "StrHelper::checkPath: SD card 1 not mounted" << std::endl; + return SD_NOT_MOUNTED; + } + } + return RETURN_OK; } diff --git a/bsp_q7s/devices/startracker/StrHelper.h b/bsp_q7s/devices/startracker/StrHelper.h index e140a4d6..c08aaae1 100644 --- a/bsp_q7s/devices/startracker/StrHelper.h +++ b/bsp_q7s/devices/startracker/StrHelper.h @@ -2,396 +2,396 @@ #define BSP_Q7S_DEVICES_STRHELPER_H_ #include + #include "ArcsecDatalinkLayer.h" -#include "fsfw/osal/linux/BinarySemaphore.h" #include "bsp_q7s/memory/SdCardManager.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/devicehandlers/CookieIF.h" #include "fsfw/objectmanager/SystemObject.h" +#include "fsfw/osal/linux/BinarySemaphore.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw_hal/linux/uart/UartComIF.h" -#include "fsfw/devicehandlers/CookieIF.h" extern "C" { - #include "thirdparty/arcsec_star_tracker/common/generated/tmtcstructs.h" - #include "thirdparty/arcsec_star_tracker/client/generated/actionreq.h" +#include "thirdparty/arcsec_star_tracker/client/generated/actionreq.h" +#include "thirdparty/arcsec_star_tracker/common/generated/tmtcstructs.h" } /** * @brief Helper class for the star tracker handler to accelerate large data transfers. */ -class StrHelper: public SystemObject, public ExecutableObjectIF, public HasReturnvaluesIF { -public: +class StrHelper : public SystemObject, public ExecutableObjectIF, public HasReturnvaluesIF { + public: + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_HELPER; - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_HELPER; + //! [EXPORT] : [COMMENT] Image upload failed + static const Event IMAGE_UPLOAD_FAILED = MAKE_EVENT(0, severity::LOW); + //! [EXPORT] : [COMMENT] Image download failed + static const Event IMAGE_DOWNLOAD_FAILED = MAKE_EVENT(1, severity::LOW); + //! [EXPORT] : [COMMENT] Uploading image to star tracker was successfulop + static const Event IMAGE_UPLOAD_SUCCESSFUL = MAKE_EVENT(2, severity::LOW); + //! [EXPORT] : [COMMENT] Image download was successful + static const Event IMAGE_DOWNLOAD_SUCCESSFUL = MAKE_EVENT(3, severity::LOW); + //! [EXPORT] : [COMMENT] Finished flash write procedure successfully + static const Event FLASH_WRITE_SUCCESSFUL = MAKE_EVENT(4, severity::LOW); + //! [EXPORT] : [COMMENT] Finished flash read procedure successfully + static const Event FLASH_READ_SUCCESSFUL = MAKE_EVENT(5, severity::LOW); + //! [EXPORT] : [COMMENT] Flash write procedure failed + static const Event FLASH_WRITE_FAILED = MAKE_EVENT(6, severity::LOW); + //! [EXPORT] : [COMMENT] Flash read procedure failed + static const Event FLASH_READ_FAILED = MAKE_EVENT(7, severity::LOW); + //! [EXPORT] : [COMMENT] Download of FPGA image successful + static const Event FPGA_DOWNLOAD_SUCCESSFUL = MAKE_EVENT(8, severity::LOW); + //! [EXPORT] : [COMMENT] Download of FPGA image failed + static const Event FPGA_DOWNLOAD_FAILED = MAKE_EVENT(9, severity::LOW); + //! [EXPORT] : [COMMENT] Upload of FPGA image successful + static const Event FPGA_UPLOAD_SUCCESSFUL = MAKE_EVENT(10, severity::LOW); + //! [EXPORT] : [COMMENT] Upload of FPGA image failed + static const Event FPGA_UPLOAD_FAILED = MAKE_EVENT(11, severity::LOW); + //! [EXPORT] : [COMMENT] Failed to read communication interface reply data + //! P1: Return code of failed communication interface read call + //! P1: Upload/download position for which the read call failed + static const Event STR_HELPER_READING_REPLY_FAILED = MAKE_EVENT(12, severity::LOW); + //! [EXPORT] : [COMMENT] Unexpected stop of decoding sequence + //! P1: Return code of failed communication interface read call + //! P1: Upload/download position for which the read call failed + static const Event STR_HELPER_COM_ERROR = MAKE_EVENT(13, severity::LOW); + //! [EXPORT] : [COMMENT] Star tracker did not send replies (maybe device is powered off) + //! P1: Position of upload or download packet for which no reply was sent + static const Event STR_HELPER_NO_REPLY = MAKE_EVENT(14, severity::LOW); + //! [EXPORT] : [COMMENT] Error during decoding of received reply occurred + // P1: Return value of decoding function + // P2: Position of upload/download packet, or address of flash write/read request + static const Event STR_HELPER_DEC_ERROR = MAKE_EVENT(15, severity::LOW); + //! [EXPORT] : [COMMENT] Position mismatch + //! P1: The expected position and thus the position for which the image upload/download failed + static const Event POSITION_MISMATCH = MAKE_EVENT(16, severity::LOW); + //! [EXPORT] : [COMMENT] Specified file does not exist + //! P1: Internal state of str helper + static const Event STR_HELPER_FILE_NOT_EXISTS = MAKE_EVENT(17, severity::LOW); + //! [EXPORT] : [COMMENT] Sending packet to star tracker failed + //! P1: Return code of communication interface sendMessage function + //! P2: Position of upload/download packet, or address of flash write/read request for which + //! sending failed + static const Event STR_HELPER_SENDING_PACKET_FAILED = MAKE_EVENT(18, severity::LOW); + //! [EXPORT] : [COMMENT] Communication interface requesting reply failed + //! P1: Return code of failed request + //! P1: Upload/download position, or address of flash write/read request for which transmission + //! failed + static const Event STR_HELPER_REQUESTING_MSG_FAILED = MAKE_EVENT(19, severity::LOW); - //! [EXPORT] : [COMMENT] Image upload failed - static const Event IMAGE_UPLOAD_FAILED = MAKE_EVENT(0, severity::LOW); - //! [EXPORT] : [COMMENT] Image download failed - static const Event IMAGE_DOWNLOAD_FAILED = MAKE_EVENT(1, severity::LOW); - //! [EXPORT] : [COMMENT] Uploading image to star tracker was successfulop - static const Event IMAGE_UPLOAD_SUCCESSFUL = MAKE_EVENT(2, severity::LOW); - //! [EXPORT] : [COMMENT] Image download was successful - static const Event IMAGE_DOWNLOAD_SUCCESSFUL = MAKE_EVENT(3, severity::LOW); - //! [EXPORT] : [COMMENT] Finished flash write procedure successfully - static const Event FLASH_WRITE_SUCCESSFUL = MAKE_EVENT(4, severity::LOW); - //! [EXPORT] : [COMMENT] Finished flash read procedure successfully - static const Event FLASH_READ_SUCCESSFUL = MAKE_EVENT(5, severity::LOW); - //! [EXPORT] : [COMMENT] Flash write procedure failed - static const Event FLASH_WRITE_FAILED = MAKE_EVENT(6, severity::LOW); - //! [EXPORT] : [COMMENT] Flash read procedure failed - static const Event FLASH_READ_FAILED = MAKE_EVENT(7, severity::LOW); - //! [EXPORT] : [COMMENT] Download of FPGA image successful - static const Event FPGA_DOWNLOAD_SUCCESSFUL = MAKE_EVENT(8, severity::LOW); - //! [EXPORT] : [COMMENT] Download of FPGA image failed - static const Event FPGA_DOWNLOAD_FAILED = MAKE_EVENT(9, severity::LOW); - //! [EXPORT] : [COMMENT] Upload of FPGA image successful - static const Event FPGA_UPLOAD_SUCCESSFUL = MAKE_EVENT(10, severity::LOW); - //! [EXPORT] : [COMMENT] Upload of FPGA image failed - static const Event FPGA_UPLOAD_FAILED = MAKE_EVENT(11, severity::LOW); - //! [EXPORT] : [COMMENT] Failed to read communication interface reply data - //!P1: Return code of failed communication interface read call - //!P1: Upload/download position for which the read call failed - static const Event STR_HELPER_READING_REPLY_FAILED = MAKE_EVENT(12, severity::LOW); - //! [EXPORT] : [COMMENT] Unexpected stop of decoding sequence - //!P1: Return code of failed communication interface read call - //!P1: Upload/download position for which the read call failed - static const Event STR_HELPER_COM_ERROR = MAKE_EVENT(13, severity::LOW); - //! [EXPORT] : [COMMENT] Star tracker did not send replies (maybe device is powered off) - //!P1: Position of upload or download packet for which no reply was sent - static const Event STR_HELPER_NO_REPLY = MAKE_EVENT(14, severity::LOW); - //! [EXPORT] : [COMMENT] Error during decoding of received reply occurred - //P1: Return value of decoding function - //P2: Position of upload/download packet, or address of flash write/read request - static const Event STR_HELPER_DEC_ERROR = MAKE_EVENT(15, severity::LOW); - //! [EXPORT] : [COMMENT] Position mismatch - //! P1: The expected position and thus the position for which the image upload/download failed - static const Event POSITION_MISMATCH = MAKE_EVENT(16, severity::LOW); - //! [EXPORT] : [COMMENT] Specified file does not exist - //!P1: Internal state of str helper - static const Event STR_HELPER_FILE_NOT_EXISTS = MAKE_EVENT(17, severity::LOW); - //! [EXPORT] : [COMMENT] Sending packet to star tracker failed - //!P1: Return code of communication interface sendMessage function - //!P2: Position of upload/download packet, or address of flash write/read request for which sending failed - static const Event STR_HELPER_SENDING_PACKET_FAILED = MAKE_EVENT(18, severity::LOW); - //! [EXPORT] : [COMMENT] Communication interface requesting reply failed - //!P1: Return code of failed request - //!P1: Upload/download position, or address of flash write/read request for which transmission failed - static const Event STR_HELPER_REQUESTING_MSG_FAILED = MAKE_EVENT(19, severity::LOW); + StrHelper(object_id_t objectId); + virtual ~StrHelper(); - StrHelper(object_id_t objectId); - virtual ~StrHelper(); + ReturnValue_t initialize() override; + ReturnValue_t performOperation(uint8_t operationCode = 0) override; - ReturnValue_t initialize() override; - ReturnValue_t performOperation(uint8_t operationCode = 0) override; + ReturnValue_t setComIF(DeviceCommunicationIF* communicationInterface_); + void setComCookie(CookieIF* comCookie_); - ReturnValue_t setComIF(DeviceCommunicationIF* communicationInterface_); - void setComCookie(CookieIF* comCookie_); + /** + * @brief Starts sequence to upload image to star tracker + * + * @param uploadImage_ Name including absolute path of the image to upload. Must be previously + * transferred to the OBC with the CFDP protocol. + */ + ReturnValue_t startImageUpload(std::string uploadImage_); - /** - * @brief Starts sequence to upload image to star tracker - * - * @param uploadImage_ Name including absolute path of the image to upload. Must be previously - * transferred to the OBC with the CFDP protocol. - */ - ReturnValue_t startImageUpload(std::string uploadImage_); + /** + * @brief Calling this function initiates the download of an image from the star tracker. + * + * @param path Path where downloaded image will be stored + */ + ReturnValue_t startImageDownload(std::string path); - /** - * @brief Calling this function initiates the download of an image from the star tracker. - * - * @param path Path where downloaded image will be stored - */ - ReturnValue_t startImageDownload(std::string path); + /** + * @brief Starts the flash write procedure + * + * @param fullname Full name including absolute path of file to write to flash + * @param region Region ID of flash region to write to + * @param address Start address of flash write procedure + */ + ReturnValue_t startFlashWrite(std::string fullname, uint8_t region, uint32_t address); - /** - * @brief Starts the flash write procedure - * - * @param fullname Full name including absolute path of file to write to flash - * @param region Region ID of flash region to write to - * @param address Start address of flash write procedure - */ - ReturnValue_t startFlashWrite(std::string fullname, uint8_t region, uint32_t address); + /** + * @brief Starts the flash read procedure + * + * @param path Path where file with read flash data will be created + * @param region Region ID of flash region to read from + * @param address Start address of flash section to read + * @param length Number of bytes to read from flash + */ + ReturnValue_t startFlashRead(std::string path, uint8_t region, uint32_t address, uint32_t length); - /** - * @brief Starts the flash read procedure - * - * @param path Path where file with read flash data will be created - * @param region Region ID of flash region to read from - * @param address Start address of flash section to read - * @param length Number of bytes to read from flash - */ - ReturnValue_t startFlashRead(std::string path, uint8_t region, uint32_t address, - uint32_t length); + /** + * @brief Starts the download of the FPGA image + * + * @param path The path where the file with the downloaded data will be created + * @param startPosition Offset in fpga image to read from + * @param length Number of bytes to dwonload from the FPGA image + * + */ + ReturnValue_t startFpgaDownload(std::string path, uint32_t startPosition, uint32_t length); - /** - * @brief Starts the download of the FPGA image - * - * @param path The path where the file with the downloaded data will be created - * @param startPosition Offset in fpga image to read from - * @param length Number of bytes to dwonload from the FPGA image - * - */ - ReturnValue_t startFpgaDownload(std::string path, uint32_t startPosition, uint32_t length); + /** + * @brief Starts upload of new image to FPGA + * + * @param uploadFile Full name of file containing FPGA image data + */ + ReturnValue_t startFpgaUpload(std::string uploadFile); - /** - * @brief Starts upload of new image to FPGA - * - * @param uploadFile Full name of file containing FPGA image data - */ - ReturnValue_t startFpgaUpload(std::string uploadFile); + /** + * @brief Can be used to interrupt a running data transfer. + */ + void stopProcess(); - /** - * @brief Can be used to interrupt a running data transfer. - */ - void stopProcess(); + /** + * @brief Changes the dafault name of downloaded images + */ + void setDownloadImageName(std::string filename); - /** - * @brief Changes the dafault name of downloaded images - */ - void setDownloadImageName(std::string filename); + /** + * @brief Sets the name of the file which will be created to store the data read from flash + */ + void setFlashReadFilename(std::string filename); - /** - * @brief Sets the name of the file which will be created to store the data read from flash - */ - void setFlashReadFilename(std::string filename); + /** + * @brief Set download FPGA image name + */ + void setDownloadFpgaImage(std::string filename); - /** - * @brief Set download FPGA image name - */ - void setDownloadFpgaImage(std::string filename); + private: + static const uint8_t INTERFACE_ID = CLASS_ID::STR_HELPER; -private: + //! [EXPORT] : [COMMENT] SD card specified in 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] Specified path does not exist + static const ReturnValue_t PATH_NOT_EXISTS = MAKE_RETURN_CODE(0xA2); + //! [EXPORT] : [COMMENT] Failed to create download image or read flash file + static const ReturnValue_t FILE_CREATION_FAILED = MAKE_RETURN_CODE(0xA3); + //! [EXPORT] : [COMMENT] Region in flash write/read reply does not match expected region + static const ReturnValue_t REGION_MISMATCH = MAKE_RETURN_CODE(0xA4); + //! [EXPORT] : [COMMENT] Address in flash write/read reply does not match expected address + static const ReturnValue_t ADDRESS_MISMATCH = MAKE_RETURN_CODE(0xA5); + //! [EXPORT] : [COMMENT] Length in flash write/read reply does not match expected length + static const ReturnValue_t LENGTH_MISMATCH = MAKE_RETURN_CODE(0xA6); + //! [EXPORT] : [COMMENT] Status field in reply signals error + static const ReturnValue_t STATUS_ERROR = MAKE_RETURN_CODE(0xA7); + //! [EXPORT] : [COMMENT] Reply has invalid type ID (should be of action reply type) + static const ReturnValue_t INVALID_TYPE_ID = MAKE_RETURN_CODE(0xA8); - static const uint8_t INTERFACE_ID = CLASS_ID::STR_HELPER; + // Size of one image part which can be sent per action request + static const size_t SIZE_IMAGE_PART = 1024; - //! [EXPORT] : [COMMENT] SD card specified in 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] Specified path does not exist - static const ReturnValue_t PATH_NOT_EXISTS = MAKE_RETURN_CODE(0xA2); - //! [EXPORT] : [COMMENT] Failed to create download image or read flash file - static const ReturnValue_t FILE_CREATION_FAILED = MAKE_RETURN_CODE(0xA3); - //! [EXPORT] : [COMMENT] Region in flash write/read reply does not match expected region - static const ReturnValue_t REGION_MISMATCH = MAKE_RETURN_CODE(0xA4); - //! [EXPORT] : [COMMENT] Address in flash write/read reply does not match expected address - static const ReturnValue_t ADDRESS_MISMATCH = MAKE_RETURN_CODE(0xA5); - //! [EXPORT] : [COMMENT] Length in flash write/read reply does not match expected length - static const ReturnValue_t LENGTH_MISMATCH = MAKE_RETURN_CODE(0xA6); - //! [EXPORT] : [COMMENT] Status field in reply signals error - static const ReturnValue_t STATUS_ERROR = MAKE_RETURN_CODE(0xA7); - //! [EXPORT] : [COMMENT] Reply has invalid type ID (should be of action reply type) - static const ReturnValue_t INVALID_TYPE_ID = MAKE_RETURN_CODE(0xA8); + class ImageDownload { + public: + static const uint32_t LAST_POSITION = 4095; + }; - // Size of one image part which can be sent per action request - static const size_t SIZE_IMAGE_PART = 1024; + class FpgaDownload { + public: + static const uint16_t MAX_DATA = 1024; + static const uint8_t DATA_OFFSET = 10; + // Start position of fpga image part to download + uint32_t startPosition = 0; + // Length of image part to download + uint32_t length = 0; + // Path where downloaded FPGA image will be stored + std::string path; + // Name of file containing downloaded FPGA image + std::string fileName = "fpgaimage.bin"; + }; + FpgaDownload fpgaDownload; - class ImageDownload { - public: - static const uint32_t LAST_POSITION = 4095; - }; + class FpgaUpload { + public: + static const uint32_t MAX_DATA = 1024; + // Full name of file to upload + std::string uploadFile; + }; + FpgaUpload fpgaUpload; - class FpgaDownload { - public: - static const uint16_t MAX_DATA = 1024; - static const uint8_t DATA_OFFSET = 10; - // Start position of fpga image part to download - uint32_t startPosition = 0; - // Length of image part to download - uint32_t length = 0; - // Path where downloaded FPGA image will be stored - std::string path; - // Name of file containing downloaded FPGA image - std::string fileName = "fpgaimage.bin"; - }; - FpgaDownload fpgaDownload; + static const uint32_t MAX_POLLS = 10000; - class FpgaUpload { - public: - static const uint32_t MAX_DATA = 1024; - // Full name of file to upload - std::string uploadFile; - }; - FpgaUpload fpgaUpload; + static const uint8_t ACTION_DATA_OFFSET = 2; + static const uint8_t POS_OFFSET = 2; + static const uint8_t IMAGE_DATA_OFFSET = 5; + static const uint8_t FLASH_READ_DATA_OFFSET = 8; + static const uint8_t REGION_OFFSET = 2; + static const uint8_t ADDRESS_OFFSET = 3; + static const uint8_t LENGTH_OFFSET = 7; + static const size_t IMAGE_DATA_SIZE = 1024; + static const size_t MAX_FLASH_DATA = 1024; + static const size_t CONFIG_MAX_DOWNLOAD_RETRIES = 3; - static const uint32_t MAX_POLLS = 10000; + enum class InternalState { + IDLE, + UPLOAD_IMAGE, + DOWNLOAD_IMAGE, + FLASH_WRITE, + FLASH_READ, + DOWNLOAD_FPGA_IMAGE, + UPLOAD_FPGA_IMAGE + }; - static const uint8_t ACTION_DATA_OFFSET = 2; - static const uint8_t POS_OFFSET = 2; - static const uint8_t IMAGE_DATA_OFFSET = 5; - static const uint8_t FLASH_READ_DATA_OFFSET = 8; - static const uint8_t REGION_OFFSET = 2; - static const uint8_t ADDRESS_OFFSET = 3; - static const uint8_t LENGTH_OFFSET = 7; - static const size_t IMAGE_DATA_SIZE = 1024; - static const size_t MAX_FLASH_DATA = 1024; - static const size_t CONFIG_MAX_DOWNLOAD_RETRIES = 3; + InternalState internalState = InternalState::IDLE; - enum class InternalState { - IDLE, - UPLOAD_IMAGE, - DOWNLOAD_IMAGE, - FLASH_WRITE, - FLASH_READ, - DOWNLOAD_FPGA_IMAGE, - UPLOAD_FPGA_IMAGE - }; + ArcsecDatalinkLayer datalinkLayer; - InternalState internalState = InternalState::IDLE; + BinarySemaphore semaphore; - ArcsecDatalinkLayer datalinkLayer; + class UploadImage { + public: + // Name including absolute path of image to upload + std::string uploadFile; + }; + UploadImage uploadImage; - BinarySemaphore semaphore; + class DownloadImage { + public: + // Path where the downloaded image will be stored + std::string path; + // Default name of downloaded image, can be changed via command + std::string filename = "image.bin"; + }; + DownloadImage downloadImage; - class UploadImage { - public: - // Name including absolute path of image to upload - std::string uploadFile; - }; - UploadImage uploadImage; + class FlashWrite { + public: + // File which contains data to write when executing the flash write command + std::string fullname; + // Will be set with the flash write command + uint8_t region = 0; + // Will be set with the flash write command and specifies the start address where to write the + // flash data to + uint32_t address = 0; + }; + FlashWrite flashWrite; - class DownloadImage { - public: - // Path where the downloaded image will be stored - std::string path; - // Default name of downloaded image, can be changed via command - std::string filename = "image.bin"; - }; - DownloadImage downloadImage; + class FlashRead { + public: + // Path where the file containing the read data will be stored + std::string path = ""; + // Default name of file containing the data read from flash, can be changed via command + std::string filename = "flashread.bin"; + // Will be set with the flash read command + uint8_t region = 0; + // Will be set with the flash read command and specifies the start address of the flash section + // to read + uint32_t address = 0; + // Number of bytes to read from flash + uint32_t size = 0; + }; + FlashRead flashRead; - class FlashWrite { - public: - // File which contains data to write when executing the flash write command - std::string fullname; - // Will be set with the flash write command - uint8_t region = 0; - // Will be set with the flash write command and specifies the start address where to write the - // flash data to - uint32_t address = 0; - }; - FlashWrite flashWrite; + SdCardManager* sdcMan = nullptr; - class FlashRead { - public: - // Path where the file containing the read data will be stored - std::string path = ""; - // Default name of file containing the data read from flash, can be changed via command - std::string filename = "flashread.bin"; - // Will be set with the flash read command - uint8_t region = 0; - // Will be set with the flash read command and specifies the start address of the flash section - // to read - uint32_t address = 0; - // Number of bytes to read from flash - uint32_t size = 0; - }; - FlashRead flashRead; + uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE]; - SdCardManager* sdcMan = nullptr; + bool terminate = false; - uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE]; + /** + * UART communication object responsible for low level access of star tracker + * Must be set by star tracker handler + */ + UartComIF* uartComIF = nullptr; + // Communication cookie. Must be set by the star tracker handler + CookieIF* comCookie = nullptr; - bool terminate = false; + // Queue id of raw data receiver + MessageQueueId_t rawDataReceiver = MessageQueueIF::NO_QUEUE; - /** - * UART communication object responsible for low level access of star tracker - * Must be set by star tracker handler - */ - UartComIF* uartComIF = nullptr; - // Communication cookie. Must be set by the star tracker handler - CookieIF* comCookie = nullptr; + /** + * @brief Performs image uploading + */ + ReturnValue_t performImageUpload(); - // Queue id of raw data receiver - MessageQueueId_t rawDataReceiver = MessageQueueIF::NO_QUEUE; + /** + * @brief Performs download of last taken image from the star tracker. + * + * @details Download is split over multiple packets transporting each a maximum of 1024 bytes. + * In case the download of one position fails, the same packet will be again + * requested. If the download of the packet fails CONFIG_MAX_DOWNLOAD_RETRIES times, + * the download will be stopped. + */ + ReturnValue_t performImageDownload(); - /** - * @brief Performs image uploading - */ - ReturnValue_t performImageUpload(); + /** + * @brief Handles flash write procedure + * + * @return RETURN_OK if successful, otherwise RETURN_FAILED + */ + ReturnValue_t performFlashWrite(); - /** - * @brief Performs download of last taken image from the star tracker. - * - * @details Download is split over multiple packets transporting each a maximum of 1024 bytes. - * In case the download of one position fails, the same packet will be again - * requested. If the download of the packet fails CONFIG_MAX_DOWNLOAD_RETRIES times, - * the download will be stopped. - */ - ReturnValue_t performImageDownload(); + /** + * @brief Sends a sequence of commands to the star tracker to read larger parts from the + * flash memory. + */ + ReturnValue_t performFlashRead(); - /** - * @brief Handles flash write procedure - * - * @return RETURN_OK if successful, otherwise RETURN_FAILED - */ - ReturnValue_t performFlashWrite(); + /** + * @brief Performs the download of the FPGA image which requires to be slip over multiple + * action requests. + */ + ReturnValue_t performFpgaDownload(); - /** - * @brief Sends a sequence of commands to the star tracker to read larger parts from the - * flash memory. - */ - ReturnValue_t performFlashRead(); + /** + * @brief Performs upload of new FPGA image. Upload sequence split over multiple commands + * because one command can only transport 1024 bytes of image data. + */ + ReturnValue_t performFpgaUpload(); - /** - * @brief Performs the download of the FPGA image which requires to be slip over multiple - * action requests. - */ - ReturnValue_t performFpgaDownload(); + /** + * @brief Sends packet to the star tracker and reads reply by using the communication + * interface + * + * @param size Size of data beforehand written to the commandBuffer + * @param parameter Parameter 2 of trigger event function + * + * @return RETURN_OK if successful, otherwise RETURN_FAILED + */ + ReturnValue_t sendAndRead(size_t size, uint32_t parameter); - /** - * @brief Performs upload of new FPGA image. Upload sequence split over multiple commands - * because one command can only transport 1024 bytes of image data. - */ - ReturnValue_t performFpgaUpload(); + /** + * @brief Checks the header (type id and status fields) of the action reply + * + * @return RETURN_OK if reply confirms success of packet transfer, otherwise REUTRN_FAILED + */ + ReturnValue_t checkActionReply(); - /** - * @brief Sends packet to the star tracker and reads reply by using the communication - * interface - * - * @param size Size of data beforehand written to the commandBuffer - * @param parameter Parameter 2 of trigger event function - * - * @return RETURN_OK if successful, otherwise RETURN_FAILED - */ - ReturnValue_t sendAndRead(size_t size, uint32_t parameter); + /** + * @brief Checks the position field in a star tracker upload/download reply. + * + * @param expectedPosition Value of expected position + * + * @return RETURN_OK if received position matches expected position, otherwise RETURN_FAILED + */ + ReturnValue_t checkReplyPosition(uint32_t expectedPosition); - /** - * @brief Checks the header (type id and status fields) of the action reply - * - * @return RETURN_OK if reply confirms success of packet transfer, otherwise REUTRN_FAILED - */ - ReturnValue_t checkActionReply(); + /** + * @brief Checks the region, address and length value of a flash write or read reply. + * + * @return RETURN_OK if values match expected values, otherwise appropriate error return + * value. + */ + ReturnValue_t checkFlashActionReply(uint8_t region_, uint32_t address_, uint16_t length_); - /** - * @brief Checks the position field in a star tracker upload/download reply. - * - * @param expectedPosition Value of expected position - * - * @return RETURN_OK if received position matches expected position, otherwise RETURN_FAILED - */ - ReturnValue_t checkReplyPosition(uint32_t expectedPosition); + /** + * @brief Checks the reply to the fpga download and upload request + * + * @param expectedPosition The expected position value in the reply + * @param expectedLength The expected length field in the reply + */ + ReturnValue_t checkFpgaActionReply(uint32_t expectedPosition, uint32_t expectedLength); - /** - * @brief Checks the region, address and length value of a flash write or read reply. - * - * @return RETURN_OK if values match expected values, otherwise appropriate error return - * value. - */ - ReturnValue_t checkFlashActionReply(uint8_t region_, uint32_t address_, uint16_t length_); - - /** - * @brief Checks the reply to the fpga download and upload request - * - * @param expectedPosition The expected position value in the reply - * @param expectedLength The expected length field in the reply - */ - ReturnValue_t checkFpgaActionReply(uint32_t expectedPosition, uint32_t expectedLength); - - /** - * @brief Checks if a path points to an sd card and whether the SD card is monuted. - * - * @return SD_NOT_MOUNTED id SD card is not mounted, otherwise RETURN_OK - */ - ReturnValue_t checkPath(std::string name); + /** + * @brief Checks if a path points to an sd card and whether the SD card is monuted. + * + * @return SD_NOT_MOUNTED id SD card is not mounted, otherwise RETURN_OK + */ + ReturnValue_t checkPath(std::string name); }; #endif /* BSP_Q7S_DEVICES_STRHELPER_H_ */ diff --git a/bsp_q7s/gpio/gpioCallbacks.cpp b/bsp_q7s/gpio/gpioCallbacks.cpp index 2cbf3320..e3033b7d 100644 --- a/bsp_q7s/gpio/gpioCallbacks.cpp +++ b/bsp_q7s/gpio/gpioCallbacks.cpp @@ -1,512 +1,504 @@ #include "gpioCallbacks.h" -#include "busConf.h" + #include - -#include -#include #include +#include +#include +#include "busConf.h" namespace gpioCallbacks { GpioIF* gpioComInterface; void initSpiCsDecoder(GpioIF* gpioComIF) { + ReturnValue_t result; - ReturnValue_t result; + if (gpioComIF == nullptr) { + sif::debug << "initSpiCsDecoder: Invalid gpioComIF" << std::endl; + return; + } - if (gpioComIF == nullptr) { - sif::debug << "initSpiCsDecoder: Invalid gpioComIF" << std::endl; - return; - } + gpioComInterface = gpioComIF; - gpioComInterface = gpioComIF; + GpioCookie* spiMuxGpios = new GpioCookie; - GpioCookie* spiMuxGpios = new GpioCookie; + GpiodRegularByLineName* spiMuxBit = nullptr; + /** Setting mux bit 1 to low will disable IC21 on the interface board */ + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_1_PIN, "SPI Mux Bit 1", + gpio::DIR_OUT, gpio::HIGH); + spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_1, spiMuxBit); + /** Setting mux bit 2 to low disables IC1 on the TCS board */ + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_2_PIN, "SPI Mux Bit 2", + gpio::DIR_OUT, gpio::HIGH); + spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_2, spiMuxBit); + /** Setting mux bit 3 to low disables IC2 on the TCS board and IC22 on the interface board */ + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_3_PIN, "SPI Mux Bit 3", + gpio::DIR_OUT, gpio::LOW); + spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_3, spiMuxBit); - GpiodRegularByLineName* spiMuxBit = nullptr; - /** Setting mux bit 1 to low will disable IC21 on the interface board */ - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_1_PIN, "SPI Mux Bit 1", - gpio::DIR_OUT, gpio::HIGH); - spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_1, spiMuxBit); - /** Setting mux bit 2 to low disables IC1 on the TCS board */ - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_2_PIN, "SPI Mux Bit 2", - gpio::DIR_OUT, gpio::HIGH); - spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_2, spiMuxBit); - /** Setting mux bit 3 to low disables IC2 on the TCS board and IC22 on the interface board */ - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_3_PIN, "SPI Mux Bit 3", - gpio::DIR_OUT, gpio::LOW); - spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_3, spiMuxBit); + // spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_1_PIN, "SPI Mux Bit 1", + // gpio::OUT, gpio::LOW); + // spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_1, spiMuxBit); + // /** Setting mux bit 2 to low disables IC1 on the TCS board */ + // spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_2_PIN, "SPI Mux Bit 2", + // gpio::OUT, gpio::HIGH); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_2, spiMuxBit); + // /** Setting mux bit 3 to low disables IC2 on the TCS board and IC22 on the interface board + // */ spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_3_PIN, "SPI Mux Bit + // 3", gpio::OUT, gpio::LOW); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_3, spiMuxBit); -// spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_1_PIN, "SPI Mux Bit 1", -// gpio::OUT, gpio::LOW); -// spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_1, spiMuxBit); -// /** Setting mux bit 2 to low disables IC1 on the TCS board */ -// spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_2_PIN, "SPI Mux Bit 2", gpio::OUT, gpio::HIGH); -// spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_2, spiMuxBit); -// /** Setting mux bit 3 to low disables IC2 on the TCS board and IC22 on the interface board */ -// spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_3_PIN, "SPI Mux Bit 3", gpio::OUT, gpio::LOW); -// spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_3, spiMuxBit); + /** The following gpios can take arbitrary initial values */ + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_4_PIN, "SPI Mux Bit 4", + gpio::DIR_OUT, gpio::LOW); + spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_4, spiMuxBit); + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_5_PIN, "SPI Mux Bit 5", + gpio::DIR_OUT, gpio::LOW); + spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_5, spiMuxBit); + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_6_PIN, "SPI Mux Bit 6", + gpio::DIR_OUT, gpio::LOW); + spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_6, spiMuxBit); + GpiodRegularByLineName* enRwDecoder = + new GpiodRegularByLineName(q7s::gpioNames::EN_RW_CS, "EN_RW_CS", gpio::DIR_OUT, gpio::HIGH); + spiMuxGpios->addGpio(gpioIds::EN_RW_CS, enRwDecoder); - /** The following gpios can take arbitrary initial values */ - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_4_PIN, "SPI Mux Bit 4", - gpio::DIR_OUT, gpio::LOW); - spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_4, spiMuxBit); - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_5_PIN, "SPI Mux Bit 5", - gpio::DIR_OUT, gpio::LOW); - spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_5, spiMuxBit); - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_6_PIN, "SPI Mux Bit 6", - gpio::DIR_OUT, gpio::LOW); - spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_6, spiMuxBit); - GpiodRegularByLineName* enRwDecoder = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_CS, - "EN_RW_CS", gpio::DIR_OUT, gpio::HIGH); - spiMuxGpios->addGpio(gpioIds::EN_RW_CS, enRwDecoder); - - result = gpioComInterface->addGpios(spiMuxGpios); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "initSpiCsDecoder: Failed to add mux bit gpios to gpioComIF" << std::endl; - return; - } + result = gpioComInterface->addGpios(spiMuxGpios); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "initSpiCsDecoder: Failed to add mux bit gpios to gpioComIF" << std::endl; + return; + } } void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, gpio::Levels value, - void* args) { + void* args) { + if (gpioComInterface == nullptr) { + sif::debug << "spiCsDecoderCallback: No gpioComIF specified. Call initSpiCsDecoder " + << "to specify gpioComIF" << std::endl; + return; + } - if (gpioComInterface == nullptr) { - sif::debug << "spiCsDecoderCallback: No gpioComIF specified. Call initSpiCsDecoder " - << "to specify gpioComIF" << std::endl; - return; - } + /* Reading is not supported by the callback function */ + if (gpioOp == gpio::GpioOperation::READ) { + return; + } - /* Reading is not supported by the callback function */ - if (gpioOp == gpio::GpioOperation::READ) { - return; + if (value == gpio::HIGH) { + switch (gpioId) { + case (gpioIds::RTD_IC_3): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_4): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_5): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_6): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_7): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_8): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_9): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_10): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_11): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_12): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_13): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_14): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_15): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_16): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_17): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_18): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::CS_SUS_1): { + disableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_2): { + disableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_3): { + disableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_4): { + disableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_5): { + disableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_6): { + disableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_7): { + disableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_8): { + disableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_9): { + disableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_10): { + disableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_11): { + disableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_12): { + disableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_13): { + disableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_RW1): { + disableRwDecoder(); + break; + } + case (gpioIds::CS_RW2): { + disableRwDecoder(); + break; + } + case (gpioIds::CS_RW3): { + disableRwDecoder(); + break; + } + case (gpioIds::CS_RW4): { + disableRwDecoder(); + break; + } + default: + sif::debug << "spiCsDecoderCallback: Invalid gpio id " << gpioId << std::endl; } - - if (value == gpio::HIGH) { - switch (gpioId) { - case(gpioIds::RTD_IC_3): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_4): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_5): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_6): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_7): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_8): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_9): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_10): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_11): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_12): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_13): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_14): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_15): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_16): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_17): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_18): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::CS_SUS_1): { - disableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_2): { - disableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_3): { - disableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_4): { - disableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_5): { - disableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_6): { - disableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_7): { - disableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_8): { - disableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_9): { - disableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_10): { - disableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_11): { - disableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_12): { - disableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_13): { - disableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_RW1): { - disableRwDecoder(); - break; - } - case(gpioIds::CS_RW2): { - disableRwDecoder(); - break; - } - case(gpioIds::CS_RW3): { - disableRwDecoder(); - break; - } - case(gpioIds::CS_RW4): { - disableRwDecoder(); - break; - } - default: - sif::debug << "spiCsDecoderCallback: Invalid gpio id " << gpioId << std::endl; - } - } - else if (value == gpio::LOW) { - switch (gpioId) { - case(gpioIds::RTD_IC_3): { - selectY7(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_4): { - selectY6(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_5): { - selectY5(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_6): { - selectY4(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_7): { - selectY3(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_8): { - selectY2(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_9): { - selectY1(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_10): { - selectY0(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_11): { - selectY7(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_12): { - selectY6(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_13): { - selectY5(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_14): { - selectY4(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_15): { - selectY3(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_16): { - selectY2(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_17): { - selectY1(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_18): { - selectY0(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::CS_SUS_1): { - selectY0(); - enableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_2): { - selectY1(); - enableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_3): { - selectY0(); - enableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_4): { - selectY1(); - enableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_5): { - selectY2(); - enableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_6): { - selectY2(); - enableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_7): { - selectY3(); - enableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_8): { - selectY3(); - enableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_9): { - selectY4(); - enableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_10): { - selectY5(); - enableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_11): { - selectY4(); - enableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_12): { - selectY5(); - enableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_13): { - selectY6(); - enableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_RW1): { - selectY0(); - enableRwDecoder(); - break; - } - case(gpioIds::CS_RW2): { - selectY1(); - enableRwDecoder(); - break; - } - case(gpioIds::CS_RW3): { - selectY2(); - enableRwDecoder(); - break; - } - case(gpioIds::CS_RW4): { - selectY3(); - enableRwDecoder(); - break; - } - default: - sif::debug << "spiCsDecoderCallback: Invalid gpio id " << gpioId << std::endl; - } - } - else { - sif::debug << "spiCsDecoderCallback: Invalid value. Must be 0 or 1" << std::endl; + } else if (value == gpio::LOW) { + switch (gpioId) { + case (gpioIds::RTD_IC_3): { + selectY7(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_4): { + selectY6(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_5): { + selectY5(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_6): { + selectY4(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_7): { + selectY3(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_8): { + selectY2(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_9): { + selectY1(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_10): { + selectY0(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_11): { + selectY7(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_12): { + selectY6(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_13): { + selectY5(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_14): { + selectY4(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_15): { + selectY3(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_16): { + selectY2(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_17): { + selectY1(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_18): { + selectY0(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::CS_SUS_1): { + selectY0(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_2): { + selectY1(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_3): { + selectY0(); + enableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_4): { + selectY1(); + enableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_5): { + selectY2(); + enableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_6): { + selectY2(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_7): { + selectY3(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_8): { + selectY3(); + enableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_9): { + selectY4(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_10): { + selectY5(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_11): { + selectY4(); + enableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_12): { + selectY5(); + enableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_13): { + selectY6(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_RW1): { + selectY0(); + enableRwDecoder(); + break; + } + case (gpioIds::CS_RW2): { + selectY1(); + enableRwDecoder(); + break; + } + case (gpioIds::CS_RW3): { + selectY2(); + enableRwDecoder(); + break; + } + case (gpioIds::CS_RW4): { + selectY3(); + enableRwDecoder(); + break; + } + default: + sif::debug << "spiCsDecoderCallback: Invalid gpio id " << gpioId << std::endl; } + } else { + sif::debug << "spiCsDecoderCallback: Invalid value. Must be 0 or 1" << std::endl; + } } void enableDecoderTcsIc1() { - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); } void enableDecoderTcsIc2() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); } void enableDecoderInterfaceBoardIc1() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); } void enableDecoderInterfaceBoardIc2() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); } void disableDecoderTcsIc1() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); } void disableDecoderTcsIc2() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); } void disableDecoderInterfaceBoardIc1() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); } void disableDecoderInterfaceBoardIc2() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); } -void enableRwDecoder() { - gpioComInterface->pullHigh(gpioIds::EN_RW_CS); -} +void enableRwDecoder() { gpioComInterface->pullHigh(gpioIds::EN_RW_CS); } -void disableRwDecoder() { - gpioComInterface->pullLow(gpioIds::EN_RW_CS); -} +void disableRwDecoder() { gpioComInterface->pullLow(gpioIds::EN_RW_CS); } void selectY0() { - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); } void selectY1() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); } void selectY2() { - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); } void selectY3() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); } void selectY4() { - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); } void selectY5() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); } void selectY6() { - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); } void selectY7() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); } void disableAllDecoder() { - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullLow(gpioIds::EN_RW_CS); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullLow(gpioIds::EN_RW_CS); } -} +} // namespace gpioCallbacks diff --git a/bsp_q7s/gpio/gpioCallbacks.h b/bsp_q7s/gpio/gpioCallbacks.h index 18adb52b..6b4e99bf 100644 --- a/bsp_q7s/gpio/gpioCallbacks.h +++ b/bsp_q7s/gpio/gpioCallbacks.h @@ -1,74 +1,73 @@ #ifndef LINUX_GPIO_GPIOCALLBACKS_H_ #define LINUX_GPIO_GPIOCALLBACKS_H_ -#include #include - +#include namespace gpioCallbacks { - /** - * @brief This function initializes the GPIOs used to control the SN74LVC138APWR decoders on - * the TCS Board and the interface board. - */ - void initSpiCsDecoder(GpioIF* gpioComIF); +/** + * @brief This function initializes the GPIOs used to control the SN74LVC138APWR decoders on + * the TCS Board and the interface board. + */ +void initSpiCsDecoder(GpioIF* gpioComIF); - /** - * @brief This function implements the decoding to multiply gpios by using the decoder - * chips SN74LVC138APWR on the TCS board and the interface board. - */ - void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, - gpio::Levels value, void* args); +/** + * @brief This function implements the decoding to multiply gpios by using the decoder + * chips SN74LVC138APWR on the TCS board and the interface board. + */ +void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, gpio::Levels value, + void* args); - /** - * @brief This function sets mux bits 1-3 to a state which will only enable the decoder - * on the TCS board which is named to IC1 in the schematic. - */ - void enableDecoderTcsIc1(); +/** + * @brief This function sets mux bits 1-3 to a state which will only enable the decoder + * on the TCS board which is named to IC1 in the schematic. + */ +void enableDecoderTcsIc1(); - /** - * @brief This function sets mux bits 1-3 to a state which will only enable the decoder - * on the TCS board which is named to IC2 in the schematic. - */ - void enableDecoderTcsIc2(); +/** + * @brief This function sets mux bits 1-3 to a state which will only enable the decoder + * on the TCS board which is named to IC2 in the schematic. + */ +void enableDecoderTcsIc2(); - /** - * @brief This function sets mux bits 1-3 to a state which will only enable the decoder - * on the inteface board board which is named to IC21 in the schematic. - */ - void enableDecoderInterfaceBoardIc1(); +/** + * @brief This function sets mux bits 1-3 to a state which will only enable the decoder + * on the inteface board board which is named to IC21 in the schematic. + */ +void enableDecoderInterfaceBoardIc1(); - /** - * @brief This function sets mux bits 1-3 to a state which will only enable the decoder - * on the inteface board board which is named to IC22 in the schematic. - */ - void enableDecoderInterfaceBoardIc2(); +/** + * @brief This function sets mux bits 1-3 to a state which will only enable the decoder + * on the inteface board board which is named to IC22 in the schematic. + */ +void enableDecoderInterfaceBoardIc2(); - void disableDecoderTcsIc1(); - void disableDecoderTcsIc2(); - void disableDecoderInterfaceBoardIc1(); - void disableDecoderInterfaceBoardIc2(); +void disableDecoderTcsIc1(); +void disableDecoderTcsIc2(); +void disableDecoderInterfaceBoardIc1(); +void disableDecoderInterfaceBoardIc2(); - /** - * @brief Enables the reaction wheel chip select decoder (IC3). - */ - void enableRwDecoder(); - void disableRwDecoder(); +/** + * @brief Enables the reaction wheel chip select decoder (IC3). + */ +void enableRwDecoder(); +void disableRwDecoder(); - /** - * @brief This function disables all decoder. - */ - void disableAllDecoder(); +/** + * @brief This function disables all decoder. + */ +void disableAllDecoder(); - /** The following functions enable the appropriate channel of the currently enabled decoder */ - void selectY0(); - void selectY1(); - void selectY2(); - void selectY3(); - void selectY4(); - void selectY5(); - void selectY6(); - void selectY7(); -} +/** The following functions enable the appropriate channel of the currently enabled decoder */ +void selectY0(); +void selectY1(); +void selectY2(); +void selectY3(); +void selectY4(); +void selectY5(); +void selectY6(); +void selectY7(); +} // namespace gpioCallbacks #endif /* LINUX_GPIO_GPIOCALLBACKS_H_ */ diff --git a/bsp_q7s/main.cpp b/bsp_q7s/main.cpp index 9ce0dca2..dfcaebf0 100644 --- a/bsp_q7s/main.cpp +++ b/bsp_q7s/main.cpp @@ -12,12 +12,11 @@ * @brief This is the main program for the target hardware. * @return */ -int main(void) -{ - using namespace std; +int main(void) { + using namespace std; #if Q7S_SIMPLE_MODE == 0 - return obsw::obsw(); + return obsw::obsw(); #else - return simple::simple(); + return simple::simple(); #endif } diff --git a/bsp_q7s/memory/FileSystemHandler.cpp b/bsp_q7s/memory/FileSystemHandler.cpp index caad94a6..8b5f85c2 100644 --- a/bsp_q7s/memory/FileSystemHandler.cpp +++ b/bsp_q7s/memory/FileSystemHandler.cpp @@ -1,257 +1,241 @@ #include "FileSystemHandler.h" -#include "bsp_q7s/core/CoreController.h" - -#include "fsfw/tasks/TaskFactory.h" -#include "fsfw/memory/GenericFileSystemMessage.h" -#include "fsfw/ipc/QueueFactory.h" - #include -#include #include +#include -FileSystemHandler::FileSystemHandler(object_id_t fileSystemHandler): - SystemObject(fileSystemHandler) { - mq = QueueFactory::instance()->createMessageQueue(FS_MAX_QUEUE_SIZE); +#include "bsp_q7s/core/CoreController.h" +#include "fsfw/ipc/QueueFactory.h" +#include "fsfw/memory/GenericFileSystemMessage.h" +#include "fsfw/tasks/TaskFactory.h" + +FileSystemHandler::FileSystemHandler(object_id_t fileSystemHandler) + : SystemObject(fileSystemHandler) { + mq = QueueFactory::instance()->createMessageQueue(FS_MAX_QUEUE_SIZE); } -FileSystemHandler::~FileSystemHandler() { - QueueFactory::instance()->deleteMessageQueue(mq); -} +FileSystemHandler::~FileSystemHandler() { QueueFactory::instance()->deleteMessageQueue(mq); } ReturnValue_t FileSystemHandler::performOperation(uint8_t unsignedChar) { - while(true) { - try { - fileSystemHandlerLoop(); - } - catch(std::bad_alloc& e) { - // Restart OBSW, hints at a memory leak - sif::error << "Allocation error in FileSystemHandler::performOperation" - << e.what() << std::endl; - // Set up an error file or a special flag in the scratch buffer for these cases - triggerEvent(CoreController::ALLOC_FAILURE, 0 , 0); - CoreController::incrementAllocationFailureCount(); - } + while (true) { + try { + fileSystemHandlerLoop(); + } catch (std::bad_alloc& e) { + // Restart OBSW, hints at a memory leak + sif::error << "Allocation error in FileSystemHandler::performOperation" << e.what() + << std::endl; + // Set up an error file or a special flag in the scratch buffer for these cases + triggerEvent(CoreController::ALLOC_FAILURE, 0, 0); + CoreController::incrementAllocationFailureCount(); } + } } - void FileSystemHandler::fileSystemHandlerLoop() { - CommandMessage filemsg; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - while(true) { - if(opCounter % 5 == 0) { - if(coreCtrl->sdInitFinished()) { - fileSystemCheckup(); - } - } - result = mq->receiveMessage(&filemsg); - if(result == MessageQueueIF::EMPTY) { - break; - } - else if(result != HasReturnvaluesIF::RETURN_FAILED) { - sif::warning << "FileSystemHandler::performOperation: Message reception failed!" - << std::endl; - break; - } - Command_t command = filemsg.getCommand(); - switch(command) { - case(GenericFileSystemMessage::CMD_CREATE_DIRECTORY): { - break; - } - case(GenericFileSystemMessage::CMD_CREATE_FILE): { - break; - } - } - opCounter++; + CommandMessage filemsg; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + while (true) { + if (opCounter % 5 == 0) { + if (coreCtrl->sdInitFinished()) { + fileSystemCheckup(); + } + } + result = mq->receiveMessage(&filemsg); + if (result == MessageQueueIF::EMPTY) { + break; + } else if (result != HasReturnvaluesIF::RETURN_FAILED) { + sif::warning << "FileSystemHandler::performOperation: Message reception failed!" << std::endl; + break; + } + Command_t command = filemsg.getCommand(); + switch (command) { + case (GenericFileSystemMessage::CMD_CREATE_DIRECTORY): { + break; + } + case (GenericFileSystemMessage::CMD_CREATE_FILE): { + break; + } } - - // This task will have a low priority and will run permanently in the background - // so we will just run in a permanent loop here and check file system - // messages permanently opCounter++; - TaskFactory::instance()->delayTask(1000); + } + + // This task will have a low priority and will run permanently in the background + // so we will just run in a permanent loop here and check file system + // messages permanently + opCounter++; + TaskFactory::instance()->delayTask(1000); } void FileSystemHandler::fileSystemCheckup() { - SdCardManager::SdStatePair statusPair; - sdcMan->getSdCardActiveStatus(statusPair); - sd::SdCard preferredSdCard; - sdcMan->getPreferredSdCard(preferredSdCard); - if((preferredSdCard == sd::SdCard::SLOT_0) and - (statusPair.first == sd::SdState::MOUNTED)) { - currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; + SdCardManager::SdStatePair statusPair; + sdcMan->getSdCardActiveStatus(statusPair); + sd::SdCard preferredSdCard; + sdcMan->getPreferredSdCard(preferredSdCard); + if ((preferredSdCard == sd::SdCard::SLOT_0) and (statusPair.first == sd::SdState::MOUNTED)) { + currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; + } else if ((preferredSdCard == sd::SdCard::SLOT_1) and + (statusPair.second == sd::SdState::MOUNTED)) { + currentMountPrefix = SdCardManager::SD_1_MOUNT_POINT; + } else { + std::string sdString; + if (preferredSdCard == sd::SdCard::SLOT_0) { + sdString = "0"; + } else { + sdString = "1"; } - else if((preferredSdCard == sd::SdCard::SLOT_1) and - (statusPair.second == sd::SdState::MOUNTED)) { - currentMountPrefix = SdCardManager::SD_1_MOUNT_POINT; - } - else { - std::string sdString; - if(preferredSdCard == sd::SdCard::SLOT_0) { - sdString = "0"; - } - else { - sdString = "1"; - } - sif::warning << "FileSystemHandler::performOperation: " - "Inconsistent state detected" << std::endl; - sif::warning << "Preferred SD card is " << sdString << - " but does not appear to be mounted. Attempting fix.." << std::endl; - // This function will appear to fix the inconsistent state - ReturnValue_t result = sdcMan->sanitizeState(&statusPair, preferredSdCard); - if(result != HasReturnvaluesIF::RETURN_OK) { - // Oh no. - triggerEvent(SdCardManager::SANITIZATION_FAILED, 0, 0); - sif::error << "FileSystemHandler::fileSystemCheckup: Sanitization failed" << std::endl; - } + sif::warning << "FileSystemHandler::performOperation: " + "Inconsistent state detected" + << std::endl; + sif::warning << "Preferred SD card is " << sdString + << " but does not appear to be mounted. Attempting fix.." << std::endl; + // This function will appear to fix the inconsistent state + ReturnValue_t result = sdcMan->sanitizeState(&statusPair, preferredSdCard); + if (result != HasReturnvaluesIF::RETURN_OK) { + // Oh no. + triggerEvent(SdCardManager::SANITIZATION_FAILED, 0, 0); + sif::error << "FileSystemHandler::fileSystemCheckup: Sanitization failed" << std::endl; } + } } -MessageQueueId_t FileSystemHandler::getCommandQueue() const { - return mq->getId(); -} +MessageQueueId_t FileSystemHandler::getCommandQueue() const { return mq->getId(); } ReturnValue_t FileSystemHandler::initialize() { - coreCtrl = ObjectManager::instance()->get(objects::CORE_CONTROLLER); - if(coreCtrl == nullptr) { - sif::error << "FileSystemHandler::initialize: Could not retrieve core controller handle" << - std::endl; - } - sdcMan = SdCardManager::instance(); - sd::SdCard preferredSdCard; - ReturnValue_t result = sdcMan->getPreferredSdCard(preferredSdCard); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - if(preferredSdCard == sd::SdCard::SLOT_0) { - currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; - } - else if(preferredSdCard == sd::SdCard::SLOT_1) { - currentMountPrefix = SdCardManager::SD_1_MOUNT_POINT; - } - return HasReturnvaluesIF::RETURN_OK; + coreCtrl = ObjectManager::instance()->get(objects::CORE_CONTROLLER); + if (coreCtrl == nullptr) { + sif::error << "FileSystemHandler::initialize: Could not retrieve core controller handle" + << std::endl; + } + sdcMan = SdCardManager::instance(); + sd::SdCard preferredSdCard; + ReturnValue_t result = sdcMan->getPreferredSdCard(preferredSdCard); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + if (preferredSdCard == sd::SdCard::SLOT_0) { + currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; + } else if (preferredSdCard == sd::SdCard::SLOT_1) { + currentMountPrefix = SdCardManager::SD_1_MOUNT_POINT; + } + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t FileSystemHandler::appendToFile(const char* repositoryPath, - const char* filename, const uint8_t* data, size_t size, - uint16_t packetNumber, FileSystemArgsIF* args) { - auto path = getInitPath(args) / repositoryPath / filename; - if(not std::filesystem::exists(path)) { - return FILE_DOES_NOT_EXIST; - } - std::ofstream file(path, std::ios_base::app|std::ios_base::out); - file.write(reinterpret_cast(data), size); - if(not file.good()) { - return GENERIC_FILE_ERROR; - } - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t FileSystemHandler::createFile(const char* repositoryPath, - const char* filename, const uint8_t* data, size_t size, FileSystemArgsIF* args) { - auto path = getInitPath(args) / filename; - if(std::filesystem::exists(path)) { - return FILE_ALREADY_EXISTS; - } - std::ofstream file(path); - file.write(reinterpret_cast(data), size); - if(not file.good()) { - return GENERIC_FILE_ERROR; - } - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t FileSystemHandler::removeFile(const char* repositoryPath, - const char* filename, FileSystemArgsIF* args) { - auto path = getInitPath(args) / repositoryPath / filename; - if(not std::filesystem::exists(path)) { - return FILE_DOES_NOT_EXIST; - } - int result = std::remove(path.c_str()); - if(result != 0) { - sif::warning << "FileSystemHandler::deleteFile: Failed with code " << result << std::endl; - return GENERIC_FILE_ERROR; - } - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t FileSystemHandler:: createDirectory(const char* repositoryPath, const char* dirname, - bool createParentDirs, FileSystemArgsIF* args) { - auto path = getInitPath(args) / repositoryPath / dirname; - if(std::filesystem::exists(path)) { - return DIRECTORY_ALREADY_EXISTS; - } - if(std::filesystem::create_directory(path)) { - return HasReturnvaluesIF::RETURN_OK; - } - sif::warning << "Creating directory " << path << " failed" << std::endl; +ReturnValue_t FileSystemHandler::appendToFile(const char* repositoryPath, const char* filename, + const uint8_t* data, size_t size, + uint16_t packetNumber, FileSystemArgsIF* args) { + auto path = getInitPath(args) / repositoryPath / filename; + if (not std::filesystem::exists(path)) { + return FILE_DOES_NOT_EXIST; + } + std::ofstream file(path, std::ios_base::app | std::ios_base::out); + file.write(reinterpret_cast(data), size); + if (not file.good()) { return GENERIC_FILE_ERROR; + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t FileSystemHandler::createFile(const char* repositoryPath, const char* filename, + const uint8_t* data, size_t size, + FileSystemArgsIF* args) { + auto path = getInitPath(args) / filename; + if (std::filesystem::exists(path)) { + return FILE_ALREADY_EXISTS; + } + std::ofstream file(path); + file.write(reinterpret_cast(data), size); + if (not file.good()) { + return GENERIC_FILE_ERROR; + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t FileSystemHandler::removeFile(const char* repositoryPath, const char* filename, + FileSystemArgsIF* args) { + auto path = getInitPath(args) / repositoryPath / filename; + if (not std::filesystem::exists(path)) { + return FILE_DOES_NOT_EXIST; + } + int result = std::remove(path.c_str()); + if (result != 0) { + sif::warning << "FileSystemHandler::deleteFile: Failed with code " << result << std::endl; + return GENERIC_FILE_ERROR; + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t FileSystemHandler::createDirectory(const char* repositoryPath, const char* dirname, + bool createParentDirs, FileSystemArgsIF* args) { + auto path = getInitPath(args) / repositoryPath / dirname; + if (std::filesystem::exists(path)) { + return DIRECTORY_ALREADY_EXISTS; + } + if (std::filesystem::create_directory(path)) { + return HasReturnvaluesIF::RETURN_OK; + } + sif::warning << "Creating directory " << path << " failed" << std::endl; + return GENERIC_FILE_ERROR; } ReturnValue_t FileSystemHandler::removeDirectory(const char* repositoryPath, const char* dirname, - bool deleteRecurively, FileSystemArgsIF* args) { - auto path = getInitPath(args) / repositoryPath / dirname; - if(not std::filesystem::exists(path)) { - return DIRECTORY_DOES_NOT_EXIST; + bool deleteRecurively, FileSystemArgsIF* args) { + auto path = getInitPath(args) / repositoryPath / dirname; + if (not std::filesystem::exists(path)) { + return DIRECTORY_DOES_NOT_EXIST; + } + std::error_code err; + if (not deleteRecurively) { + if (std::filesystem::remove(path, err)) { + return HasReturnvaluesIF::RETURN_OK; + } else { + // Check error code. Most probably denied permissions because folder is not empty + sif::warning << "FileSystemHandler::removeDirectory: Deleting directory failed with " + "code " + << err.value() << ": " << strerror(err.value()) << std::endl; + if (err.value() == ENOTEMPTY) { + return DIRECTORY_NOT_EMPTY; + } else { + return GENERIC_FILE_ERROR; + } } - std::error_code err; - if(not deleteRecurively) { - if(std::filesystem::remove(path, err)) { - return HasReturnvaluesIF::RETURN_OK; - } - else { - // Check error code. Most probably denied permissions because folder is not empty - sif::warning << "FileSystemHandler::removeDirectory: Deleting directory failed with " - "code " << err.value() << ": " << strerror(err.value()) << std::endl; - if(err.value() == ENOTEMPTY) { - return DIRECTORY_NOT_EMPTY; - } - else { - return GENERIC_FILE_ERROR; - } + } else { + if (std::filesystem::remove_all(path, err)) { + return HasReturnvaluesIF::RETURN_OK; + } else { + sif::warning << "FileSystemHandler::removeDirectory: Deleting directory failed with " + "code " + << err.value() << ": " << strerror(err.value()) << std::endl; + // Check error code + if (err.value() == ENOTEMPTY) { + return DIRECTORY_NOT_EMPTY; + } else { + return GENERIC_FILE_ERROR; + } + } + } - } - } - else { - if(std::filesystem::remove_all(path, err)) { - return HasReturnvaluesIF::RETURN_OK; - } - else { - sif::warning << "FileSystemHandler::removeDirectory: Deleting directory failed with " - "code " << err.value() << ": " << strerror(err.value()) << std::endl; - // Check error code - if(err.value() == ENOTEMPTY) { - return DIRECTORY_NOT_EMPTY; - } - else { - return GENERIC_FILE_ERROR; - } - } - } - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t FileSystemHandler::renameFile(const char *repositoryPath, const char *oldFilename, - const char *newFilename, FileSystemArgsIF *args) { - auto basepath = getInitPath(args) / repositoryPath; - std::filesystem::rename(basepath / oldFilename, basepath / newFilename); - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t FileSystemHandler::renameFile(const char* repositoryPath, const char* oldFilename, + const char* newFilename, FileSystemArgsIF* args) { + auto basepath = getInitPath(args) / repositoryPath; + std::filesystem::rename(basepath / oldFilename, basepath / newFilename); + return HasReturnvaluesIF::RETURN_OK; } -void FileSystemHandler::parseCfg(FsCommandCfg *cfg, bool& useMountPrefix) { - if(cfg != nullptr) { - useMountPrefix = cfg->useMountPrefix; - } +void FileSystemHandler::parseCfg(FsCommandCfg* cfg, bool& useMountPrefix) { + if (cfg != nullptr) { + useMountPrefix = cfg->useMountPrefix; + } } std::filesystem::path FileSystemHandler::getInitPath(FileSystemArgsIF* args) { - bool useMountPrefix = true; - parseCfg(reinterpret_cast(args), useMountPrefix); - std::string path; - if(useMountPrefix) { - path = currentMountPrefix; - } - return std::filesystem::path(path); + bool useMountPrefix = true; + parseCfg(reinterpret_cast(args), useMountPrefix); + std::string path; + if (useMountPrefix) { + path = currentMountPrefix; + } + return std::filesystem::path(path); } diff --git a/bsp_q7s/memory/FileSystemHandler.h b/bsp_q7s/memory/FileSystemHandler.h index 35a0f533..6973c3c8 100644 --- a/bsp_q7s/memory/FileSystemHandler.h +++ b/bsp_q7s/memory/FileSystemHandler.h @@ -1,71 +1,67 @@ #ifndef BSP_Q7S_MEMORY_FILESYSTEMHANDLER_H_ #define BSP_Q7S_MEMORY_FILESYSTEMHANDLER_H_ -#include "SdCardManager.h" -#include "OBSWConfig.h" - -#include "fsfw/ipc/MessageQueueIF.h" -#include "fsfw/tasks/ExecutableObjectIF.h" -#include "fsfw/objectmanager/SystemObject.h" -#include "fsfw/memory/HasFileSystemIF.h" - -#include #include +#include + +#include "OBSWConfig.h" +#include "SdCardManager.h" +#include "fsfw/ipc/MessageQueueIF.h" +#include "fsfw/memory/HasFileSystemIF.h" +#include "fsfw/objectmanager/SystemObject.h" +#include "fsfw/tasks/ExecutableObjectIF.h" class CoreController; -class FileSystemHandler: public SystemObject, - public ExecutableObjectIF, - public HasFileSystemIF { -public: - struct FsCommandCfg: public FileSystemArgsIF { - // Can be used to automatically use mount prefix of active SD card. - // Otherwise, the operator has to specify the full path to the mounted SD card as well. - bool useMountPrefix = false; - }; +class FileSystemHandler : public SystemObject, public ExecutableObjectIF, public HasFileSystemIF { + public: + struct FsCommandCfg : public FileSystemArgsIF { + // Can be used to automatically use mount prefix of active SD card. + // Otherwise, the operator has to specify the full path to the mounted SD card as well. + bool useMountPrefix = false; + }; - FileSystemHandler(object_id_t fileSystemHandler); - virtual~ FileSystemHandler(); + FileSystemHandler(object_id_t fileSystemHandler); + virtual ~FileSystemHandler(); - ReturnValue_t performOperation(uint8_t) override; + ReturnValue_t performOperation(uint8_t) override; - ReturnValue_t initialize() override; + ReturnValue_t initialize() override; - /** - * Function to get the MessageQueueId_t of the implementing object - * @return MessageQueueId_t of the object - */ - MessageQueueId_t getCommandQueue() const override; - ReturnValue_t appendToFile(const char* repositoryPath, - const char* filename, const uint8_t* data, size_t size, - uint16_t packetNumber, FileSystemArgsIF* args = nullptr) override; - ReturnValue_t createFile(const char* repositoryPath, - const char* filename, const uint8_t* data = nullptr, - size_t size = 0, FileSystemArgsIF* args = nullptr) override; - ReturnValue_t removeFile(const char* repositoryPath, - const char* filename, FileSystemArgsIF* args = nullptr) override; - ReturnValue_t createDirectory(const char* repositoryPath, const char* dirname, - bool createParentDirs, FileSystemArgsIF* args = nullptr) override; - ReturnValue_t removeDirectory(const char* repositoryPath, const char* dirname, - bool deleteRecurively = false, FileSystemArgsIF* args = nullptr) override; - ReturnValue_t renameFile(const char* repositoryPath, const char* oldFilename, - const char* newFilename, FileSystemArgsIF* args = nullptr) override; + /** + * Function to get the MessageQueueId_t of the implementing object + * @return MessageQueueId_t of the object + */ + MessageQueueId_t getCommandQueue() const override; + ReturnValue_t appendToFile(const char* repositoryPath, const char* filename, const uint8_t* data, + size_t size, uint16_t packetNumber, + FileSystemArgsIF* args = nullptr) override; + ReturnValue_t createFile(const char* repositoryPath, const char* filename, + const uint8_t* data = nullptr, size_t size = 0, + FileSystemArgsIF* args = nullptr) override; + ReturnValue_t removeFile(const char* repositoryPath, const char* filename, + FileSystemArgsIF* args = nullptr) override; + ReturnValue_t createDirectory(const char* repositoryPath, const char* dirname, + bool createParentDirs, FileSystemArgsIF* args = nullptr) override; + ReturnValue_t removeDirectory(const char* repositoryPath, const char* dirname, + bool deleteRecurively = false, + FileSystemArgsIF* args = nullptr) override; + ReturnValue_t renameFile(const char* repositoryPath, const char* oldFilename, + const char* newFilename, FileSystemArgsIF* args = nullptr) override; -private: - CoreController* coreCtrl = nullptr; - MessageQueueIF* mq = nullptr; - std::string currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; - static constexpr uint32_t FS_MAX_QUEUE_SIZE = config::OBSW_FILESYSTEM_HANDLER_QUEUE_SIZE; + private: + CoreController* coreCtrl = nullptr; + MessageQueueIF* mq = nullptr; + std::string currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; + static constexpr uint32_t FS_MAX_QUEUE_SIZE = config::OBSW_FILESYSTEM_HANDLER_QUEUE_SIZE; - SdCardManager* sdcMan = nullptr; - uint8_t opCounter = 0; + SdCardManager* sdcMan = nullptr; + uint8_t opCounter = 0; - void fileSystemHandlerLoop(); - void fileSystemCheckup(); - std::filesystem::path getInitPath(FileSystemArgsIF* args); - void parseCfg(FsCommandCfg* cfg, bool& useMountPrefix); + void fileSystemHandlerLoop(); + void fileSystemCheckup(); + std::filesystem::path getInitPath(FileSystemArgsIF* args); + void parseCfg(FsCommandCfg* cfg, bool& useMountPrefix); }; - - #endif /* BSP_Q7S_MEMORY_FILESYSTEMMANAGER_H_ */ diff --git a/bsp_q7s/memory/SdCardManager.cpp b/bsp_q7s/memory/SdCardManager.cpp index 8a3d11f2..3647ff7b 100644 --- a/bsp_q7s/memory/SdCardManager.cpp +++ b/bsp_q7s/memory/SdCardManager.cpp @@ -1,487 +1,462 @@ #include "SdCardManager.h" -#include "scratchApi.h" - -#include "linux/utility/utility.h" - -#include "fsfw/ipc/MutexFactory.h" -#include "fsfw/serviceinterface/ServiceInterface.h" #include +#include +#include #include #include -#include -#include + +#include "fsfw/ipc/MutexFactory.h" +#include "fsfw/serviceinterface/ServiceInterface.h" +#include "linux/utility/utility.h" +#include "scratchApi.h" SdCardManager* SdCardManager::factoryInstance = nullptr; -SdCardManager::SdCardManager(): cmdExecutor(256) { -} +SdCardManager::SdCardManager() : cmdExecutor(256) {} -SdCardManager::~SdCardManager() { -} +SdCardManager::~SdCardManager() {} void SdCardManager::create() { - if(factoryInstance == nullptr) { - factoryInstance = new SdCardManager(); - } + if (factoryInstance == nullptr) { + factoryInstance = new SdCardManager(); + } } SdCardManager* SdCardManager::instance() { - SdCardManager::create(); - return SdCardManager::factoryInstance; + SdCardManager::create(); + return SdCardManager::factoryInstance; } ReturnValue_t SdCardManager::switchOnSdCard(sd::SdCard sdCard, bool doMountSdCard, - SdStatePair* statusPair) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - if(doMountSdCard) { - if(not blocking) { - sif::warning << "SdCardManager::switchOnSdCard: Two-step command but manager is" - " not configured for blocking operation. " - "Forcing blocking mode.." << std::endl; - blocking = true; - } + SdStatePair* statusPair) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + if (doMountSdCard) { + if (not blocking) { + sif::warning << "SdCardManager::switchOnSdCard: Two-step command but manager is" + " not configured for blocking operation. " + "Forcing blocking mode.." + << std::endl; + blocking = true; } - std::unique_ptr sdStatusPtr; - if(statusPair == nullptr) { - sdStatusPtr = std::make_unique(); - statusPair = sdStatusPtr.get(); - result = getSdCardActiveStatus(*statusPair); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + } + std::unique_ptr sdStatusPtr; + if (statusPair == nullptr) { + sdStatusPtr = std::make_unique(); + statusPair = sdStatusPtr.get(); + result = getSdCardActiveStatus(*statusPair); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; } + } - // Not allowed, this function turns on one SD card - if(sdCard == sd::SdCard::BOTH) { - sif::warning << "SdCardManager::switchOffSdCard: API does not allow sd::SdStatus::BOTH" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } + // Not allowed, this function turns on one SD card + if (sdCard == sd::SdCard::BOTH) { + sif::warning << "SdCardManager::switchOffSdCard: API does not allow sd::SdStatus::BOTH" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } - sd::SdState currentState; - if(sdCard == sd::SdCard::SLOT_0) { - currentState = statusPair->first; - } - else if(sdCard == sd::SdCard::SLOT_1) { - currentState = statusPair->second; - } - else { - // Should not happen - currentState = sd::SdState::OFF; - } + sd::SdState currentState; + if (sdCard == sd::SdCard::SLOT_0) { + currentState = statusPair->first; + } else if (sdCard == sd::SdCard::SLOT_1) { + currentState = statusPair->second; + } else { + // Should not happen + currentState = sd::SdState::OFF; + } - if(currentState == sd::SdState::ON) { - if(not doMountSdCard) { - return ALREADY_ON; - } - else { - return mountSdCard(sdCard); - } - } - else if(currentState == sd::SdState::MOUNTED) { - result = ALREADY_MOUNTED; - } - else if(currentState == sd::SdState::OFF) { - result = setSdCardState(sdCard, true); - } - else { - result = HasReturnvaluesIF::RETURN_FAILED; + if (currentState == sd::SdState::ON) { + if (not doMountSdCard) { + return ALREADY_ON; + } else { + return mountSdCard(sdCard); } + } else if (currentState == sd::SdState::MOUNTED) { + result = ALREADY_MOUNTED; + } else if (currentState == sd::SdState::OFF) { + result = setSdCardState(sdCard, true); + } else { + result = HasReturnvaluesIF::RETURN_FAILED; + } - if(result != HasReturnvaluesIF::RETURN_OK or not doMountSdCard) { - return result; - } + if (result != HasReturnvaluesIF::RETURN_OK or not doMountSdCard) { + return result; + } - return mountSdCard(sdCard); + return mountSdCard(sdCard); } ReturnValue_t SdCardManager::switchOffSdCard(sd::SdCard sdCard, bool doUnmountSdCard, - SdStatePair* statusPair) { - std::pair active; - ReturnValue_t result = getSdCardActiveStatus(active); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; + SdStatePair* statusPair) { + std::pair active; + ReturnValue_t result = getSdCardActiveStatus(active); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + if (doUnmountSdCard) { + if (not blocking) { + sif::warning << "SdCardManager::switchOffSdCard: Two-step command but manager is" + " not configured for blocking operation. Forcing blocking mode.." + << std::endl; + blocking = true; } - if(doUnmountSdCard) { - if(not blocking) { - sif::warning << "SdCardManager::switchOffSdCard: Two-step command but manager is" - " not configured for blocking operation. Forcing blocking mode.." << std::endl; - blocking = true; - } + } + // Not allowed, this function turns off one SD card + if (sdCard == sd::SdCard::BOTH) { + sif::warning << "SdCardManager::switchOffSdCard: API does not allow sd::SdStatus::BOTH" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + if (sdCard == sd::SdCard::SLOT_0) { + if (active.first == sd::SdState::OFF) { + return ALREADY_OFF; } - // Not allowed, this function turns off one SD card - if(sdCard == sd::SdCard::BOTH) { - sif::warning << "SdCardManager::switchOffSdCard: API does not allow sd::SdStatus::BOTH" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - if(sdCard == sd::SdCard::SLOT_0) { - if(active.first == sd::SdState::OFF) { - return ALREADY_OFF; - } - } - else if(sdCard == sd::SdCard::SLOT_1) { - if(active.second == sd::SdState::OFF) { - return ALREADY_OFF; - } + } else if (sdCard == sd::SdCard::SLOT_1) { + if (active.second == sd::SdState::OFF) { + return ALREADY_OFF; } + } - if(doUnmountSdCard) { - result = unmountSdCard(sdCard); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + if (doUnmountSdCard) { + result = unmountSdCard(sdCard); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; } + } - return setSdCardState(sdCard, false); + return setSdCardState(sdCard, false); } ReturnValue_t SdCardManager::setSdCardState(sd::SdCard sdCard, bool on) { - using namespace std; - if(cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { - return CommandExecutor::COMMAND_PENDING; - } - string sdstring = ""; - string statestring = ""; - if(sdCard == sd::SdCard::SLOT_0) { - sdstring = "0"; - } - else if(sdCard == sd::SdCard::SLOT_1) { - sdstring = "1"; - } - if(on) { - currentOp = Operations::SWITCHING_ON; - statestring = "on"; - } - else { - currentOp = Operations::SWITCHING_OFF; - statestring = "off"; - } - ostringstream command; - command << "q7hw sd set " << sdstring << " " << statestring; - cmdExecutor.load(command.str(), blocking, printCmdOutput); - ReturnValue_t result = cmdExecutor.execute(); - if(blocking and result != HasReturnvaluesIF::RETURN_OK) { - utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::setSdCardState"); - } - return result; + using namespace std; + if (cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { + return CommandExecutor::COMMAND_PENDING; + } + string sdstring = ""; + string statestring = ""; + if (sdCard == sd::SdCard::SLOT_0) { + sdstring = "0"; + } else if (sdCard == sd::SdCard::SLOT_1) { + sdstring = "1"; + } + if (on) { + currentOp = Operations::SWITCHING_ON; + statestring = "on"; + } else { + currentOp = Operations::SWITCHING_OFF; + statestring = "off"; + } + ostringstream command; + command << "q7hw sd set " << sdstring << " " << statestring; + cmdExecutor.load(command.str(), blocking, printCmdOutput); + ReturnValue_t result = cmdExecutor.execute(); + if (blocking and result != HasReturnvaluesIF::RETURN_OK) { + utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::setSdCardState"); + } + return result; } ReturnValue_t SdCardManager::getSdCardActiveStatus(SdStatePair& active) { - using namespace std; - if(not filesystem::exists(SD_STATE_FILE)) { - return STATUS_FILE_NEXISTS; - } + using namespace std; + if (not filesystem::exists(SD_STATE_FILE)) { + return STATUS_FILE_NEXISTS; + } - // Now the file should exist in any case. Still check whether it exists. - fstream sdStatus(SD_STATE_FILE); - if (not sdStatus.good()) { - return STATUS_FILE_NEXISTS; - } - string line; - uint8_t idx = 0; - sd::SdCard currentSd = sd::SdCard::SLOT_0; - // Process status file line by line - while (std::getline(sdStatus, line)) { - processSdStatusLine(active, line, idx, currentSd); - } - return HasReturnvaluesIF::RETURN_OK; + // Now the file should exist in any case. Still check whether it exists. + fstream sdStatus(SD_STATE_FILE); + if (not sdStatus.good()) { + return STATUS_FILE_NEXISTS; + } + string line; + uint8_t idx = 0; + sd::SdCard currentSd = sd::SdCard::SLOT_0; + // Process status file line by line + while (std::getline(sdStatus, line)) { + processSdStatusLine(active, line, idx, currentSd); + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t SdCardManager::mountSdCard(sd::SdCard sdCard) { - using namespace std; - if(cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { - return CommandExecutor::COMMAND_PENDING; - } - if(sdCard == sd::SdCard::BOTH) { - sif::warning << "SdCardManager::mountSdCard: API does not allow sd::SdStatus::BOTH" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - string mountDev; - string mountPoint; - if(sdCard == sd::SdCard::SLOT_0) { - mountDev = SD_0_DEV_NAME; - mountPoint = SD_0_MOUNT_POINT; - } - else if(sdCard == sd::SdCard::SLOT_1) { - mountDev = SD_1_DEV_NAME; - mountPoint = SD_1_MOUNT_POINT; - } - if(not filesystem::exists(mountDev)) { - sif::warning << "SdCardManager::mountSdCard: Device file does not exists. Make sure to" - " turn on the SD card" << std::endl; - return MOUNT_ERROR; - } + using namespace std; + if (cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { + return CommandExecutor::COMMAND_PENDING; + } + if (sdCard == sd::SdCard::BOTH) { + sif::warning << "SdCardManager::mountSdCard: API does not allow sd::SdStatus::BOTH" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + string mountDev; + string mountPoint; + if (sdCard == sd::SdCard::SLOT_0) { + mountDev = SD_0_DEV_NAME; + mountPoint = SD_0_MOUNT_POINT; + } else if (sdCard == sd::SdCard::SLOT_1) { + mountDev = SD_1_DEV_NAME; + mountPoint = SD_1_MOUNT_POINT; + } + if (not filesystem::exists(mountDev)) { + sif::warning << "SdCardManager::mountSdCard: Device file does not exists. Make sure to" + " turn on the SD card" + << std::endl; + return MOUNT_ERROR; + } - if(not blocking) { - currentOp = Operations::MOUNTING; - } - string sdMountCommand = "mount " + mountDev + " " + mountPoint; - cmdExecutor.load(sdMountCommand, blocking, printCmdOutput); - ReturnValue_t result = cmdExecutor.execute(); - if(blocking and result != HasReturnvaluesIF::RETURN_OK) { - utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::mountSdCard"); - } - return result; + if (not blocking) { + currentOp = Operations::MOUNTING; + } + string sdMountCommand = "mount " + mountDev + " " + mountPoint; + cmdExecutor.load(sdMountCommand, blocking, printCmdOutput); + ReturnValue_t result = cmdExecutor.execute(); + if (blocking and result != HasReturnvaluesIF::RETURN_OK) { + utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::mountSdCard"); + } + return result; } ReturnValue_t SdCardManager::unmountSdCard(sd::SdCard sdCard) { - if(cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { - return CommandExecutor::COMMAND_PENDING; - } - using namespace std; - if(sdCard == sd::SdCard::BOTH) { - sif::warning << "SdCardManager::unmountSdCard: API does not allow sd::SdStatus::BOTH" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - string mountPoint; - if(sdCard == sd::SdCard::SLOT_0) { - mountPoint = SD_0_MOUNT_POINT; - } - else if(sdCard == sd::SdCard::SLOT_1) { - mountPoint = SD_1_MOUNT_POINT; - } - if(not filesystem::exists(mountPoint)) { - sif::error << "SdCardManager::unmountSdCard: Default mount point " << mountPoint << - "does not exist" << std::endl; - return UNMOUNT_ERROR; - } - if(filesystem::is_empty(mountPoint)) { - // The mount point will always exist, but if it is empty, that is strong hint that - // the SD card was not mounted properly. Still proceed with operation. - sif::warning << "SdCardManager::unmountSdCard: Mount point is empty!" << std::endl; - } - string sdUnmountCommand = "umount " + mountPoint; - if(not blocking) { - currentOp = Operations::UNMOUNTING; - } - cmdExecutor.load(sdUnmountCommand, blocking, printCmdOutput); - ReturnValue_t result = cmdExecutor.execute(); - if(blocking and result != HasReturnvaluesIF::RETURN_OK) { - utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::unmountSdCard"); - } - return result; + if (cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { + return CommandExecutor::COMMAND_PENDING; + } + using namespace std; + if (sdCard == sd::SdCard::BOTH) { + sif::warning << "SdCardManager::unmountSdCard: API does not allow sd::SdStatus::BOTH" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + string mountPoint; + if (sdCard == sd::SdCard::SLOT_0) { + mountPoint = SD_0_MOUNT_POINT; + } else if (sdCard == sd::SdCard::SLOT_1) { + mountPoint = SD_1_MOUNT_POINT; + } + if (not filesystem::exists(mountPoint)) { + sif::error << "SdCardManager::unmountSdCard: Default mount point " << mountPoint + << "does not exist" << std::endl; + return UNMOUNT_ERROR; + } + if (filesystem::is_empty(mountPoint)) { + // The mount point will always exist, but if it is empty, that is strong hint that + // the SD card was not mounted properly. Still proceed with operation. + sif::warning << "SdCardManager::unmountSdCard: Mount point is empty!" << std::endl; + } + string sdUnmountCommand = "umount " + mountPoint; + if (not blocking) { + currentOp = Operations::UNMOUNTING; + } + cmdExecutor.load(sdUnmountCommand, blocking, printCmdOutput); + ReturnValue_t result = cmdExecutor.execute(); + if (blocking and result != HasReturnvaluesIF::RETURN_OK) { + utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::unmountSdCard"); + } + return result; } ReturnValue_t SdCardManager::sanitizeState(SdStatePair* statusPair, sd::SdCard prefSdCard) { - std::unique_ptr sdStatusPtr; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - // Enforce blocking operation for now. Be careful to reset it when returning prematurely! - bool resetNonBlockingState = false; - if(not this->blocking) { - blocking = true; - resetNonBlockingState = true; - } - if(prefSdCard == sd::SdCard::NONE) { - result = getPreferredSdCard(prefSdCard); - if(result != HasReturnvaluesIF::RETURN_OK) {} - } - if(statusPair == nullptr) { - sdStatusPtr = std::make_unique(); - statusPair = sdStatusPtr.get(); - getSdCardActiveStatus(*statusPair); + std::unique_ptr sdStatusPtr; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + // Enforce blocking operation for now. Be careful to reset it when returning prematurely! + bool resetNonBlockingState = false; + if (not this->blocking) { + blocking = true; + resetNonBlockingState = true; + } + if (prefSdCard == sd::SdCard::NONE) { + result = getPreferredSdCard(prefSdCard); + if (result != HasReturnvaluesIF::RETURN_OK) { } + } + if (statusPair == nullptr) { + sdStatusPtr = std::make_unique(); + statusPair = sdStatusPtr.get(); + getSdCardActiveStatus(*statusPair); + } - if(statusPair->first == sd::SdState::ON) { - result = mountSdCard(prefSdCard); - } + if (statusPair->first == sd::SdState::ON) { + result = mountSdCard(prefSdCard); + } - result = switchOnSdCard(prefSdCard, true, statusPair); - if(resetNonBlockingState) { - blocking = false; - } - return result; + result = switchOnSdCard(prefSdCard, true, statusPair); + if (resetNonBlockingState) { + blocking = false; + } + return result; } void SdCardManager::resetState() { - cmdExecutor.reset(); - currentOp = Operations::IDLE; + cmdExecutor.reset(); + currentOp = Operations::IDLE; } -void SdCardManager::processSdStatusLine(std::pair &active, - std::string& line, uint8_t& idx, sd::SdCard& currentSd) { - using namespace std; - istringstream iss(line); - string word; - bool slotLine = false; - bool mountLine = false; - while(iss >> word) { - if (word == "Slot") { - slotLine = true; - } - if(word == "Mounted") { - mountLine = true; - } - - if(slotLine) { - if (word == "1:") { - currentSd = sd::SdCard::SLOT_1; - } - - if(word == "on") { - if(currentSd == sd::SdCard::SLOT_0) { - active.first = sd::SdState::ON; - } - else { - active.second = sd::SdState::ON; - } - } - else if (word == "off") { - if(currentSd == sd::SdCard::SLOT_0) { - active.first = sd::SdState::OFF; - } - else { - active.second = sd::SdState::OFF; - } - } - } - - if(mountLine) { - if(currentSd == sd::SdCard::SLOT_0) { - active.first = sd::SdState::MOUNTED; - } - else { - active.second = sd::SdState::MOUNTED; - } - } - - if(idx > 5) { - sif::warning << "SdCardManager::sdCardActive: /tmp/sd_status.txt has more than 6 " - "lines and might be invalid!" << std::endl; - } +void SdCardManager::processSdStatusLine(std::pair& active, + std::string& line, uint8_t& idx, sd::SdCard& currentSd) { + using namespace std; + istringstream iss(line); + string word; + bool slotLine = false; + bool mountLine = false; + while (iss >> word) { + if (word == "Slot") { + slotLine = true; } - idx++; + if (word == "Mounted") { + mountLine = true; + } + + if (slotLine) { + if (word == "1:") { + currentSd = sd::SdCard::SLOT_1; + } + + if (word == "on") { + if (currentSd == sd::SdCard::SLOT_0) { + active.first = sd::SdState::ON; + } else { + active.second = sd::SdState::ON; + } + } else if (word == "off") { + if (currentSd == sd::SdCard::SLOT_0) { + active.first = sd::SdState::OFF; + } else { + active.second = sd::SdState::OFF; + } + } + } + + if (mountLine) { + if (currentSd == sd::SdCard::SLOT_0) { + active.first = sd::SdState::MOUNTED; + } else { + active.second = sd::SdState::MOUNTED; + } + } + + if (idx > 5) { + sif::warning << "SdCardManager::sdCardActive: /tmp/sd_status.txt has more than 6 " + "lines and might be invalid!" + << std::endl; + } + } + idx++; } ReturnValue_t SdCardManager::getPreferredSdCard(sd::SdCard& sdCard) const { - uint8_t prefSdCard = 0; - ReturnValue_t result = scratch::readNumber(scratch::PREFERED_SDC_KEY, prefSdCard); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - sdCard = static_cast(prefSdCard); - return HasReturnvaluesIF::RETURN_OK; + uint8_t prefSdCard = 0; + ReturnValue_t result = scratch::readNumber(scratch::PREFERED_SDC_KEY, prefSdCard); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + sdCard = static_cast(prefSdCard); + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t SdCardManager::setPreferredSdCard(sd::SdCard sdCard) { - if(sdCard == sd::SdCard::BOTH) { - return HasReturnvaluesIF::RETURN_FAILED; - } - return scratch::writeNumber(scratch::PREFERED_SDC_KEY, static_cast(sdCard)); + if (sdCard == sd::SdCard::BOTH) { + return HasReturnvaluesIF::RETURN_FAILED; + } + return scratch::writeNumber(scratch::PREFERED_SDC_KEY, static_cast(sdCard)); } ReturnValue_t SdCardManager::updateSdCardStateFile() { - if(cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { - return CommandExecutor::COMMAND_PENDING; - } - // Use q7hw utility and pipe the command output into the state file - std::string updateCmd = "q7hw sd info all > " + std::string(SD_STATE_FILE); - cmdExecutor.load(updateCmd, blocking, printCmdOutput); - ReturnValue_t result = cmdExecutor.execute(); - if(blocking and result != HasReturnvaluesIF::RETURN_OK) { - utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::mountSdCard"); - } - return result; + if (cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { + return CommandExecutor::COMMAND_PENDING; + } + // Use q7hw utility and pipe the command output into the state file + std::string updateCmd = "q7hw sd info all > " + std::string(SD_STATE_FILE); + cmdExecutor.load(updateCmd, blocking, printCmdOutput); + ReturnValue_t result = cmdExecutor.execute(); + if (blocking and result != HasReturnvaluesIF::RETURN_OK) { + utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::mountSdCard"); + } + return result; } std::string SdCardManager::getCurrentMountPrefix(sd::SdCard prefSdCard) { - if(prefSdCard == sd::SdCard::NONE) { - ReturnValue_t result = getPreferredSdCard(prefSdCard); - if(result != HasReturnvaluesIF::RETURN_OK) { - return SD_0_MOUNT_POINT; - } - } - if(prefSdCard == sd::SdCard::SLOT_0) { - return SD_0_MOUNT_POINT; - } - else { - return SD_1_MOUNT_POINT; + if (prefSdCard == sd::SdCard::NONE) { + ReturnValue_t result = getPreferredSdCard(prefSdCard); + if (result != HasReturnvaluesIF::RETURN_OK) { + return SD_0_MOUNT_POINT; } + } + if (prefSdCard == sd::SdCard::SLOT_0) { + return SD_0_MOUNT_POINT; + } else { + return SD_1_MOUNT_POINT; + } } -SdCardManager::OpStatus SdCardManager::checkCurrentOp(Operations ¤tOp) { - CommandExecutor::States state = cmdExecutor.getCurrentState(); - if(state == CommandExecutor::States::IDLE or state == CommandExecutor::States::COMMAND_LOADED) { - return OpStatus::IDLE; - } - currentOp = this->currentOp; - bool bytesRead = false; +SdCardManager::OpStatus SdCardManager::checkCurrentOp(Operations& currentOp) { + CommandExecutor::States state = cmdExecutor.getCurrentState(); + if (state == CommandExecutor::States::IDLE or state == CommandExecutor::States::COMMAND_LOADED) { + return OpStatus::IDLE; + } + currentOp = this->currentOp; + bool bytesRead = false; #if OBSW_ENABLE_TIMERS == 1 - Timer timer; - timer.setTimer(100); - uint32_t remainingTimeMs = 0; + Timer timer; + timer.setTimer(100); + uint32_t remainingTimeMs = 0; #endif - while(true) { - ReturnValue_t result = cmdExecutor.check(bytesRead); - // This timer can prevent deadlocks due to missconfigurations + while (true) { + ReturnValue_t result = cmdExecutor.check(bytesRead); + // This timer can prevent deadlocks due to missconfigurations #if OBSW_ENABLE_TIMERS == 1 - timer.getTimer(&remainingTimeMs); - if(remainingTimeMs == 0) { - sif::error << "SdCardManager::checkCurrentOp: Timeout!" << std::endl; - return OpStatus::FAIL; - } -#endif - switch(result) { - case(CommandExecutor::BYTES_READ): { - continue; - } - case(CommandExecutor::EXECUTION_FINISHED): { - return OpStatus::SUCCESS; - } - case(HasReturnvaluesIF::RETURN_OK): { - return OpStatus::ONGOING; - } - case(HasReturnvaluesIF::RETURN_FAILED): { - return OpStatus::FAIL; - } - default: { - sif::warning << "SdCardManager::checkCurrentOp: Unhandled case" << std::endl; - } - } + timer.getTimer(&remainingTimeMs); + if (remainingTimeMs == 0) { + sif::error << "SdCardManager::checkCurrentOp: Timeout!" << std::endl; + return OpStatus::FAIL; } +#endif + switch (result) { + case (CommandExecutor::BYTES_READ): { + continue; + } + case (CommandExecutor::EXECUTION_FINISHED): { + return OpStatus::SUCCESS; + } + case (HasReturnvaluesIF::RETURN_OK): { + return OpStatus::ONGOING; + } + case (HasReturnvaluesIF::RETURN_FAILED): { + return OpStatus::FAIL; + } + default: { + sif::warning << "SdCardManager::checkCurrentOp: Unhandled case" << std::endl; + } + } + } } -void SdCardManager::setBlocking(bool blocking) { - this->blocking = blocking; -} +void SdCardManager::setBlocking(bool blocking) { this->blocking = blocking; } -void SdCardManager::setPrintCommandOutput(bool print) { - this->printCmdOutput = print; - -} +void SdCardManager::setPrintCommandOutput(bool print) { this->printCmdOutput = print; } bool SdCardManager::isSdCardMounted(sd::SdCard sdCard) { - SdCardManager::SdStatePair active; - ReturnValue_t result = this->getSdCardActiveStatus(active); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "SdCardManager::isSdCardMounted: Failed to get SD card active state"; - return false; - } - if (sdCard == sd::SLOT_0) { - if (active.first == sd::MOUNTED) { - return true; - } - else { - return false; - } - } - else if (sdCard == sd::SLOT_1) { - if (active.second == sd::MOUNTED) { - return true; - } - else { - return false; - } - } - else { - sif::debug << "SdCardManager::isSdCardMounted: Unknown SD card specified" << std::endl; - } + SdCardManager::SdStatePair active; + ReturnValue_t result = this->getSdCardActiveStatus(active); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "SdCardManager::isSdCardMounted: Failed to get SD card active state"; return false; + } + if (sdCard == sd::SLOT_0) { + if (active.first == sd::MOUNTED) { + return true; + } else { + return false; + } + } else if (sdCard == sd::SLOT_1) { + if (active.second == sd::MOUNTED) { + return true; + } else { + return false; + } + } else { + sif::debug << "SdCardManager::isSdCardMounted: Unknown SD card specified" << std::endl; + } + return false; } - - diff --git a/bsp_q7s/memory/SdCardManager.h b/bsp_q7s/memory/SdCardManager.h index 6e4930da..4446a102 100644 --- a/bsp_q7s/memory/SdCardManager.h +++ b/bsp_q7s/memory/SdCardManager.h @@ -1,21 +1,20 @@ #ifndef BSP_Q7S_MEMORY_SDCARDACCESSMANAGER_H_ #define BSP_Q7S_MEMORY_SDCARDACCESSMANAGER_H_ -#include "fsfw_hal/linux/CommandExecutor.h" -#include "definitions.h" -#include "returnvalues/classIds.h" -#include "events/subsystemIdRanges.h" - -#include "fsfw/events/Event.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" - #include -#include -#include -#include -#include #include +#include +#include +#include +#include + +#include "definitions.h" +#include "events/subsystemIdRanges.h" +#include "fsfw/events/Event.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw_hal/linux/CommandExecutor.h" +#include "returnvalues/classIds.h" class MutexIF; @@ -24,202 +23,188 @@ class MutexIF; * state */ class SdCardManager { - friend class SdCardAccess; -public: - enum class Operations { - SWITCHING_ON, - SWITCHING_OFF, - MOUNTING, - UNMOUNTING, - IDLE - }; + friend class SdCardAccess; - enum class OpStatus { - IDLE, - TIMEOUT, - ONGOING, - SUCCESS, - FAIL - }; + public: + enum class Operations { SWITCHING_ON, SWITCHING_OFF, MOUNTING, UNMOUNTING, IDLE }; - using SdStatePair = std::pair; + enum class OpStatus { IDLE, TIMEOUT, ONGOING, SUCCESS, FAIL }; - static constexpr uint8_t INTERFACE_ID = CLASS_ID::SD_CARD_MANAGER; + using SdStatePair = std::pair; - static constexpr ReturnValue_t OP_ONGOING = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 0); - static constexpr ReturnValue_t ALREADY_ON = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 1); - static constexpr ReturnValue_t ALREADY_MOUNTED = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 2); - static constexpr ReturnValue_t ALREADY_OFF = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 3); - static constexpr ReturnValue_t STATUS_FILE_NEXISTS = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 10); - static constexpr ReturnValue_t STATUS_FILE_FORMAT_INVALID = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 11); - static constexpr ReturnValue_t MOUNT_ERROR = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 12); - static constexpr ReturnValue_t UNMOUNT_ERROR = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 13); - static constexpr ReturnValue_t SYSTEM_CALL_ERROR = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 14); - static constexpr ReturnValue_t POPEN_CALL_ERROR = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 15); + static constexpr uint8_t INTERFACE_ID = CLASS_ID::SD_CARD_MANAGER; - static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::FILE_SYSTEM; + static constexpr ReturnValue_t OP_ONGOING = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 0); + static constexpr ReturnValue_t ALREADY_ON = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 1); + static constexpr ReturnValue_t ALREADY_MOUNTED = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 2); + static constexpr ReturnValue_t ALREADY_OFF = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 3); + static constexpr ReturnValue_t STATUS_FILE_NEXISTS = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 10); + static constexpr ReturnValue_t STATUS_FILE_FORMAT_INVALID = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 11); + static constexpr ReturnValue_t MOUNT_ERROR = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 12); + static constexpr ReturnValue_t UNMOUNT_ERROR = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 13); + static constexpr ReturnValue_t SYSTEM_CALL_ERROR = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 14); + static constexpr ReturnValue_t POPEN_CALL_ERROR = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 15); - static constexpr Event SANITIZATION_FAILED = event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW); + static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::FILE_SYSTEM; - // C++17 does not support constexpr std::string yet - static constexpr char SD_0_DEV_NAME[] = "/dev/mmcblk0p1"; - static constexpr char SD_1_DEV_NAME[] = "/dev/mmcblk1p1"; - static constexpr char SD_0_MOUNT_POINT[] = "/mnt/sd0"; - static constexpr char SD_1_MOUNT_POINT[] = "/mnt/sd1"; - static constexpr char SD_STATE_FILE[] = "/tmp/sd_status.txt"; + static constexpr Event SANITIZATION_FAILED = event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW); - virtual ~SdCardManager(); + // C++17 does not support constexpr std::string yet + static constexpr char SD_0_DEV_NAME[] = "/dev/mmcblk0p1"; + static constexpr char SD_1_DEV_NAME[] = "/dev/mmcblk1p1"; + static constexpr char SD_0_MOUNT_POINT[] = "/mnt/sd0"; + static constexpr char SD_1_MOUNT_POINT[] = "/mnt/sd1"; + static constexpr char SD_STATE_FILE[] = "/tmp/sd_status.txt"; - static void create(); + virtual ~SdCardManager(); - /** - * Returns the single instance of the SD card manager. - */ - static SdCardManager* instance(); + static void create(); - /** - * Set the preferred SD card which will determine which SD card will be used as the primary - * SD card in hot redundant and cold redundant mode. This function will not switch the - * SD cards which are currently on and mounted, this needs to be implemented by - * an upper layer by using #switchOffSdCard , #switchOnSdCard and #updateSdCardStateFile - * @param sdCard - * @return - */ - ReturnValue_t setPreferredSdCard(sd::SdCard sdCard); + /** + * Returns the single instance of the SD card manager. + */ + static SdCardManager* instance(); - /** - * Get the currently configured preferred SD card - * @param sdCard - * @return - */ - ReturnValue_t getPreferredSdCard(sd::SdCard& sdCard) const; + /** + * Set the preferred SD card which will determine which SD card will be used as the primary + * SD card in hot redundant and cold redundant mode. This function will not switch the + * SD cards which are currently on and mounted, this needs to be implemented by + * an upper layer by using #switchOffSdCard , #switchOnSdCard and #updateSdCardStateFile + * @param sdCard + * @return + */ + ReturnValue_t setPreferredSdCard(sd::SdCard sdCard); - /** - * Switch on the specified SD card. - * @param sdCard - * @param doMountSdCard Mount the SD card after switching it on, which is necessary - * to use it - * @param statusPair If the status pair is already available, it can be passed here - * @return - RETURN_OK on success, ALREADY_ON if it is already on, - * SYSTEM_CALL_ERROR on system error - */ - ReturnValue_t switchOnSdCard(sd::SdCard sdCard, bool doMountSdCard = true, - SdStatePair* statusPair = nullptr); + /** + * Get the currently configured preferred SD card + * @param sdCard + * @return + */ + ReturnValue_t getPreferredSdCard(sd::SdCard& sdCard) const; - /** - * Switch off the specified SD card. - * @param sdCard - * @param doUnmountSdCard Unmount the SD card before switching the card off, which makes - * the operation safer - * @param statusPair If the status pair is already available, it can be passed here - * @return - RETURN_OK on success, ALREADY_ON if it is already on, - * SYSTEM_CALL_ERROR on system error - */ - ReturnValue_t switchOffSdCard(sd::SdCard sdCard, bool doUnmountSdCard = true, - SdStatePair* statusPair = nullptr); + /** + * Switch on the specified SD card. + * @param sdCard + * @param doMountSdCard Mount the SD card after switching it on, which is necessary + * to use it + * @param statusPair If the status pair is already available, it can be passed here + * @return - RETURN_OK on success, ALREADY_ON if it is already on, + * SYSTEM_CALL_ERROR on system error + */ + ReturnValue_t switchOnSdCard(sd::SdCard sdCard, bool doMountSdCard = true, + SdStatePair* statusPair = nullptr); - /** - * Update the state file or creates one if it does not exist. You need to call this - * function before calling #sdCardActive - * @return - * - RETURN_OK if the state file was updated successfully - * - CommandExecutor::COMMAND_PENDING: Non-blocking command is pending - * - RETURN_FAILED: blocking command failed - */ - ReturnValue_t updateSdCardStateFile(); + /** + * Switch off the specified SD card. + * @param sdCard + * @param doUnmountSdCard Unmount the SD card before switching the card off, which makes + * the operation safer + * @param statusPair If the status pair is already available, it can be passed here + * @return - RETURN_OK on success, ALREADY_ON if it is already on, + * SYSTEM_CALL_ERROR on system error + */ + ReturnValue_t switchOffSdCard(sd::SdCard sdCard, bool doUnmountSdCard = true, + SdStatePair* statusPair = nullptr); - /** - * Get the state of the SD cards. If the state file does not exist, this function will - * take care of updating it. If it does not, the function will use the state file to get - * the status of the SD cards and set the field of the provided boolean pair. - * @param active Pair of booleans, where the first entry is the state of the first SD card - * and the second one the state of the second SD card - * @return - RETURN_OK if the state was read successfully - * - STATUS_FILE_FORMAT_INVALID if there was an issue with the state file. The user - * should call #updateSdCardStateFile again in that case - * - STATUS_FILE_NEXISTS if the status file does not exist - */ - ReturnValue_t getSdCardActiveStatus(SdStatePair& active); + /** + * Update the state file or creates one if it does not exist. You need to call this + * function before calling #sdCardActive + * @return + * - RETURN_OK if the state file was updated successfully + * - CommandExecutor::COMMAND_PENDING: Non-blocking command is pending + * - RETURN_FAILED: blocking command failed + */ + ReturnValue_t updateSdCardStateFile(); - /** - * Mount the specified SD card. This is necessary to use it. - * @param sdCard - * @return - */ - ReturnValue_t mountSdCard(sd::SdCard sdCard); - /** - * Unmount the specified SD card. This is recommended before switching it off. The SD card - * can't be used after it has been unmounted. - * @param sdCard - * @return - */ - ReturnValue_t unmountSdCard(sd::SdCard sdCard); + /** + * Get the state of the SD cards. If the state file does not exist, this function will + * take care of updating it. If it does not, the function will use the state file to get + * the status of the SD cards and set the field of the provided boolean pair. + * @param active Pair of booleans, where the first entry is the state of the first SD card + * and the second one the state of the second SD card + * @return - RETURN_OK if the state was read successfully + * - STATUS_FILE_FORMAT_INVALID if there was an issue with the state file. The user + * should call #updateSdCardStateFile again in that case + * - STATUS_FILE_NEXISTS if the status file does not exist + */ + ReturnValue_t getSdCardActiveStatus(SdStatePair& active); - /** - * In case that there is a discrepancy between the preferred SD card and the currently - * mounted one, this function will sanitize the state by attempting to mount the - * currently preferred SD card. If the caller already has state information, it can be - * passed into the function. For now, this operation will be enforced in blocking mode. - * @param statusPair Current SD card status capture with #getSdCardActiveStatus - * @param prefSdCard Preferred SD card captured with #getPreferredSdCard - * @throws std::bad_alloc if one of the two arguments was a nullptr and an allocation failed - * @return - */ - ReturnValue_t sanitizeState(SdStatePair* statusPair = nullptr, - sd::SdCard prefSdCard = sd::SdCard::NONE); + /** + * Mount the specified SD card. This is necessary to use it. + * @param sdCard + * @return + */ + ReturnValue_t mountSdCard(sd::SdCard sdCard); + /** + * Unmount the specified SD card. This is recommended before switching it off. The SD card + * can't be used after it has been unmounted. + * @param sdCard + * @return + */ + ReturnValue_t unmountSdCard(sd::SdCard sdCard); - /** - * If sd::SdCard::NONE is passed as an argument, this function will get the currently - * preferred SD card from the scratch buffer. - * @param prefSdCardPtr - * @return - */ - std::string getCurrentMountPrefix(sd::SdCard prefSdCardPtr = sd::SdCard::NONE); + /** + * In case that there is a discrepancy between the preferred SD card and the currently + * mounted one, this function will sanitize the state by attempting to mount the + * currently preferred SD card. If the caller already has state information, it can be + * passed into the function. For now, this operation will be enforced in blocking mode. + * @param statusPair Current SD card status capture with #getSdCardActiveStatus + * @param prefSdCard Preferred SD card captured with #getPreferredSdCard + * @throws std::bad_alloc if one of the two arguments was a nullptr and an allocation failed + * @return + */ + ReturnValue_t sanitizeState(SdStatePair* statusPair = nullptr, + sd::SdCard prefSdCard = sd::SdCard::NONE); - OpStatus checkCurrentOp(Operations& currentOp); + /** + * If sd::SdCard::NONE is passed as an argument, this function will get the currently + * preferred SD card from the scratch buffer. + * @param prefSdCardPtr + * @return + */ + std::string getCurrentMountPrefix(sd::SdCard prefSdCardPtr = sd::SdCard::NONE); - /** - * If there are issues with the state machine, it can be reset with this function - */ - void resetState(); + OpStatus checkCurrentOp(Operations& currentOp); - void setBlocking(bool blocking); - void setPrintCommandOutput(bool print); + /** + * If there are issues with the state machine, it can be reset with this function + */ + void resetState(); - /** - * @brief Checks if an SD card is mounted - * - * @param sdCard The SD crad to check - * - * @return true if mounted, otherwise false - */ - bool isSdCardMounted(sd::SdCard sdCard); -private: - CommandExecutor cmdExecutor; - Operations currentOp = Operations::IDLE; - bool blocking = false; - bool printCmdOutput = true; + void setBlocking(bool blocking); + void setPrintCommandOutput(bool print); - SdCardManager(); + /** + * @brief Checks if an SD card is mounted + * + * @param sdCard The SD crad to check + * + * @return true if mounted, otherwise false + */ + bool isSdCardMounted(sd::SdCard sdCard); - ReturnValue_t setSdCardState(sd::SdCard sdCard, bool on); + private: + CommandExecutor cmdExecutor; + Operations currentOp = Operations::IDLE; + bool blocking = false; + bool printCmdOutput = true; - void processSdStatusLine(SdStatePair& active, std::string& line, uint8_t& idx, - sd::SdCard& currentSd); + SdCardManager(); - std::string currentPrefix; + ReturnValue_t setSdCardState(sd::SdCard sdCard, bool on); - static SdCardManager* factoryInstance; + void processSdStatusLine(SdStatePair& active, std::string& line, uint8_t& idx, + sd::SdCard& currentSd); + + std::string currentPrefix; + + static SdCardManager* factoryInstance; }; #endif /* BSP_Q7S_MEMORY_SDCARDACCESSMANAGER_H_ */ diff --git a/bsp_q7s/memory/definitions.h b/bsp_q7s/memory/definitions.h index 9e0bca65..53184e4e 100644 --- a/bsp_q7s/memory/definitions.h +++ b/bsp_q7s/memory/definitions.h @@ -5,22 +5,15 @@ namespace sd { -enum SdState: uint8_t { - OFF = 0, - ON = 1, - // A mounted SD card is on as well - MOUNTED = 2 +enum SdState : uint8_t { + OFF = 0, + ON = 1, + // A mounted SD card is on as well + MOUNTED = 2 }; -enum SdCard: uint8_t { - SLOT_0 = 0, - SLOT_1 = 1, - BOTH, - NONE -}; - -} - +enum SdCard : uint8_t { SLOT_0 = 0, SLOT_1 = 1, BOTH, NONE }; +} // namespace sd #endif /* BSP_Q7S_MEMORY_DEFINITIONS_H_ */ diff --git a/bsp_q7s/memory/scratchApi.cpp b/bsp_q7s/memory/scratchApi.cpp index 08d59df1..83bc8239 100644 --- a/bsp_q7s/memory/scratchApi.cpp +++ b/bsp_q7s/memory/scratchApi.cpp @@ -1,49 +1,50 @@ #include "scratchApi.h" ReturnValue_t scratch::writeString(std::string name, std::string string) { - std::ostringstream oss; - oss << "xsc_scratch write " << name << " \"" << string << "\""; - int result = std::system(oss.str().c_str()); - if(result != 0) { - utility::handleSystemError(result, "scratch::writeString"); - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + std::ostringstream oss; + oss << "xsc_scratch write " << name << " \"" << string << "\""; + int result = std::system(oss.str().c_str()); + if (result != 0) { + utility::handleSystemError(result, "scratch::writeString"); + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t scratch::readString(std::string key, std::string &string) { - std::ifstream file; - std::string filename; - ReturnValue_t result = readToFile(key, file, filename); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + std::ifstream file; + std::string filename; + ReturnValue_t result = readToFile(key, file, filename); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } - std::string line; - if (not std::getline(file, line)) { - std::remove(filename.c_str()); - return HasReturnvaluesIF::RETURN_FAILED; - } + std::string line; + if (not std::getline(file, line)) { + std::remove(filename.c_str()); + return HasReturnvaluesIF::RETURN_FAILED; + } - size_t pos = line.find("="); - if(pos == std::string::npos) { - sif::warning << "scratch::readNumber: Output file format invalid, " - "no \"=\" found" << std::endl; - // Could not find value - std::remove(filename.c_str()); - return KEY_NOT_FOUND; - } - string = line.substr(pos + 1); - return HasReturnvaluesIF::RETURN_OK; + size_t pos = line.find("="); + if (pos == std::string::npos) { + sif::warning << "scratch::readNumber: Output file format invalid, " + "no \"=\" found" + << std::endl; + // Could not find value + std::remove(filename.c_str()); + return KEY_NOT_FOUND; + } + string = line.substr(pos + 1); + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t scratch::clearValue(std::string key) { - std::ostringstream oss; - oss << "xsc_scratch clear " << key; - int result = std::system(oss.str().c_str()); - if(result != 0) { - utility::handleSystemError(result, "scratch::clearValue"); - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + std::ostringstream oss; + oss << "xsc_scratch clear " << key; + int result = std::system(oss.str().c_str()); + if (result != 0) { + utility::handleSystemError(result, "scratch::clearValue"); + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } diff --git a/bsp_q7s/memory/scratchApi.h b/bsp_q7s/memory/scratchApi.h index ee19e084..babd26dc 100644 --- a/bsp_q7s/memory/scratchApi.h +++ b/bsp_q7s/memory/scratchApi.h @@ -1,17 +1,17 @@ #ifndef BSP_Q7S_MEMORY_SCRATCHAPI_H_ #define BSP_Q7S_MEMORY_SCRATCHAPI_H_ +#include +#include +#include +#include +#include + #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "linux/utility/utility.h" #include "returnvalues/classIds.h" -#include -#include -#include -#include -#include - /** * @brief API for the scratch buffer */ @@ -48,7 +48,7 @@ ReturnValue_t readString(std::string key, std::string& string); * @param num Number. Template allows to set signed, unsigned and floating point numbers * @return */ -template::value>::type> +template ::value>::type> inline ReturnValue_t writeNumber(std::string key, T num) noexcept; /** @@ -59,90 +59,88 @@ inline ReturnValue_t writeNumber(std::string key, T num) noexcept; * @param num * @return */ -template::value>::type> +template ::value>::type> inline ReturnValue_t readNumber(std::string key, T& num) noexcept; - // Anonymous namespace namespace { static uint8_t counter = 0; ReturnValue_t readToFile(std::string name, std::ifstream& file, std::string& filename) { - using namespace std; - filename = "/tmp/sro" + std::to_string(counter++); - ostringstream oss; - oss << "xsc_scratch read " << name << " > " << filename; + using namespace std; + filename = "/tmp/sro" + std::to_string(counter++); + ostringstream oss; + oss << "xsc_scratch read " << name << " > " << filename; - int result = std::system(oss.str().c_str()); - if(result != 0) { - if(result == 256) { - sif::warning << "scratch::readNumber: Key " << name << " does not exist" << std::endl; - // Could not find value - std::remove(filename.c_str()); - return KEY_NOT_FOUND; - } - else { - utility::handleSystemError(result, "scratch::readNumber"); - std::remove(filename.c_str()); - return HasReturnvaluesIF::RETURN_FAILED; - } + int result = std::system(oss.str().c_str()); + if (result != 0) { + if (result == 256) { + sif::warning << "scratch::readNumber: Key " << name << " does not exist" << std::endl; + // Could not find value + std::remove(filename.c_str()); + return KEY_NOT_FOUND; + } else { + utility::handleSystemError(result, "scratch::readNumber"); + std::remove(filename.c_str()); + return HasReturnvaluesIF::RETURN_FAILED; } - file.open(filename); - return HasReturnvaluesIF::RETURN_OK; + } + file.open(filename); + return HasReturnvaluesIF::RETURN_OK; } -} // End of anonymous namespace +} // End of anonymous namespace -template::value>::type> +template ::value>::type> inline ReturnValue_t writeNumber(std::string key, T num) noexcept { - std::ostringstream oss; - oss << "xsc_scratch write " << key << " " << std::to_string(num); - int result = std::system(oss.str().c_str()); - if(result != 0) { - utility::handleSystemError(result, "scratch::writeNumber"); - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + std::ostringstream oss; + oss << "xsc_scratch write " << key << " " << std::to_string(num); + int result = std::system(oss.str().c_str()); + if (result != 0) { + utility::handleSystemError(result, "scratch::writeNumber"); + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } -template::value>::type> +template ::value>::type> inline ReturnValue_t readNumber(std::string key, T& num) noexcept { - using namespace std; - ifstream file; - std::string filename; - ReturnValue_t result = readToFile(key, file, filename); - if(result != HasReturnvaluesIF::RETURN_OK) { - std::remove(filename.c_str()); - return result; - } - - string line; - if (not std::getline(file, line)) { - std::remove(filename.c_str()); - return HasReturnvaluesIF::RETURN_FAILED; - } - - size_t pos = line.find("="); - if(pos == string::npos) { - sif::warning << "scratch::readNumber: Output file format invalid, " - "no \"=\" found" << std::endl; - // Could not find value - std::remove(filename.c_str()); - return KEY_NOT_FOUND; - } - std::string valueAsString = line.substr(pos + 1); - try { - num = std::stoi(valueAsString); - } - catch(std::invalid_argument& e) { - sif::warning << "scratch::readNumber: stoi call failed with " << e.what() << std::endl; - } - + using namespace std; + ifstream file; + std::string filename; + ReturnValue_t result = readToFile(key, file, filename); + if (result != HasReturnvaluesIF::RETURN_OK) { std::remove(filename.c_str()); - return HasReturnvaluesIF::RETURN_OK; + return result; + } + + string line; + if (not std::getline(file, line)) { + std::remove(filename.c_str()); + return HasReturnvaluesIF::RETURN_FAILED; + } + + size_t pos = line.find("="); + if (pos == string::npos) { + sif::warning << "scratch::readNumber: Output file format invalid, " + "no \"=\" found" + << std::endl; + // Could not find value + std::remove(filename.c_str()); + return KEY_NOT_FOUND; + } + std::string valueAsString = line.substr(pos + 1); + try { + num = std::stoi(valueAsString); + } catch (std::invalid_argument& e) { + sif::warning << "scratch::readNumber: stoi call failed with " << e.what() << std::endl; + } + + std::remove(filename.c_str()); + return HasReturnvaluesIF::RETURN_OK; } -} +} // namespace scratch #endif /* BSP_Q7S_MEMORY_SCRATCHAPI_H_ */ diff --git a/bsp_q7s/simple/simple.cpp b/bsp_q7s/simple/simple.cpp index 960aa7db..b300e456 100644 --- a/bsp_q7s/simple/simple.cpp +++ b/bsp_q7s/simple/simple.cpp @@ -1,4 +1,5 @@ #include "simple.h" + #include "q7sConfig.h" #if Q7S_SIMPLE_ADD_FILE_SYSTEM_TEST == 1 @@ -6,16 +7,13 @@ #endif int simple::simple() { - cout << "-- Q7S Simple Application --" << endl; + cout << "-- Q7S Simple Application --" << endl; #if Q7S_SIMPLE_ADD_FILE_SYSTEM_TEST == 1 - { - FileSystemTest fileSystemTest; - } + { FileSystemTest fileSystemTest; } #endif #if TE0720_GPIO_TEST #endif - return 0; + return 0; } - diff --git a/bsp_q7s/spi/Q7sSpiComIF.cpp b/bsp_q7s/spi/Q7sSpiComIF.cpp index 23dbe551..84552503 100644 --- a/bsp_q7s/spi/Q7sSpiComIF.cpp +++ b/bsp_q7s/spi/Q7sSpiComIF.cpp @@ -1,9 +1,5 @@ #include -Q7sSpiComIF::Q7sSpiComIF(object_id_t objectId, GpioIF* gpioComIF) : - SpiComIF(objectId, gpioComIF) { -} - -Q7sSpiComIF::~Q7sSpiComIF() { -} +Q7sSpiComIF::Q7sSpiComIF(object_id_t objectId, GpioIF* gpioComIF) : SpiComIF(objectId, gpioComIF) {} +Q7sSpiComIF::~Q7sSpiComIF() {} diff --git a/bsp_q7s/spi/Q7sSpiComIF.h b/bsp_q7s/spi/Q7sSpiComIF.h index a10d63dd..def754ab 100644 --- a/bsp_q7s/spi/Q7sSpiComIF.h +++ b/bsp_q7s/spi/Q7sSpiComIF.h @@ -3,7 +3,6 @@ #include - /** * @brief This additional communication interface is required because the SPI busses behind the * devices "/dev/spi2.0" and "dev/spidev3.0" are multiplexed to one SPI interface. @@ -17,17 +16,17 @@ * the SPI interface. The multiplexing is performed via a GPIO connected to a VHDL * module responsible for switching between the to SPI peripherals. */ -class Q7sSpiComIF: public SpiComIF { -public: - /** - * @brief Constructor - * - * @param objectId - * @param gpioComIF - * @param gpioSwitchId The gpio ID of the GPIO connected to the SPI mux module in the PL. - */ - Q7sSpiComIF(object_id_t objectId, GpioIF* gpioComIF, gpioId_t gpioSwitchId); - virtual ~Q7sSpiComIF(); +class Q7sSpiComIF : public SpiComIF { + public: + /** + * @brief Constructor + * + * @param objectId + * @param gpioComIF + * @param gpioSwitchId The gpio ID of the GPIO connected to the SPI mux module in the PL. + */ + Q7sSpiComIF(object_id_t objectId, GpioIF* gpioComIF, gpioId_t gpioSwitchId); + virtual ~Q7sSpiComIF(); }; #endif /* BSP_Q7S_SPI_Q7SSPICOMIF_H_ */ diff --git a/linux/archive/gpio/GpioCookie.cpp b/linux/archive/gpio/GpioCookie.cpp index c729502b..b1bb2db4 100644 --- a/linux/archive/gpio/GpioCookie.cpp +++ b/linux/archive/gpio/GpioCookie.cpp @@ -1,34 +1,32 @@ #include "GpioCookie.h" + #include -GpioCookie::GpioCookie() { -} +GpioCookie::GpioCookie() {} -ReturnValue_t GpioCookie::addGpio(gpioId_t gpioId, GpioBase* gpioConfig){ - if (gpioConfig == nullptr) { - sif::debug << "GpioCookie::addGpio: gpioConfig is nullpointer" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; +ReturnValue_t GpioCookie::addGpio(gpioId_t gpioId, GpioBase* gpioConfig) { + if (gpioConfig == nullptr) { + sif::debug << "GpioCookie::addGpio: gpioConfig is nullpointer" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + auto gpioMapIter = gpioMap.find(gpioId); + if (gpioMapIter == gpioMap.end()) { + auto statusPair = gpioMap.emplace(gpioId, gpioConfig); + if (statusPair.second == false) { +#if FSFW_VERBOSE_LEVEL >= 1 + sif::error << "GpioCookie::addGpio: Failed to add GPIO " << gpioId << " to GPIO map" + << std::endl; +#endif + return HasReturnvaluesIF::RETURN_FAILED; } - auto gpioMapIter = gpioMap.find(gpioId); - if(gpioMapIter == gpioMap.end()) { - auto statusPair = gpioMap.emplace(gpioId, gpioConfig); - if (statusPair.second == false) { + return HasReturnvaluesIF::RETURN_OK; + } #if FSFW_VERBOSE_LEVEL >= 1 - sif::error << "GpioCookie::addGpio: Failed to add GPIO " << gpioId << - " to GPIO map" << std::endl; + sif::error << "GpioCookie::addGpio: GPIO already exists in GPIO map " << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; - } -#if FSFW_VERBOSE_LEVEL >= 1 - sif::error << "GpioCookie::addGpio: GPIO already exists in GPIO map " << std::endl; -#endif - return HasReturnvaluesIF::RETURN_FAILED; + return HasReturnvaluesIF::RETURN_FAILED; } -GpioMap GpioCookie::getGpioMap() const { - return gpioMap; -} +GpioMap GpioCookie::getGpioMap() const { return gpioMap; } GpioCookie::~GpioCookie() {} diff --git a/linux/archive/gpio/GpioCookie.h b/linux/archive/gpio/GpioCookie.h index 3f8531ee..9295a4ac 100644 --- a/linux/archive/gpio/GpioCookie.h +++ b/linux/archive/gpio/GpioCookie.h @@ -1,11 +1,12 @@ #ifndef LINUX_GPIO_GPIOCOOKIE_H_ #define LINUX_GPIO_GPIOCOOKIE_H_ -#include "GpioIF.h" -#include "gpioDefinitions.h" #include #include +#include "GpioIF.h" +#include "gpioDefinitions.h" + /** * @brief Cookie for the GpioIF. Allows the GpioIF to determine which * GPIOs to initialize and whether they should be configured as in- or @@ -16,24 +17,23 @@ * * @author J. Meier */ -class GpioCookie: public CookieIF { -public: +class GpioCookie : public CookieIF { + public: + GpioCookie(); - GpioCookie(); + virtual ~GpioCookie(); - virtual ~GpioCookie(); + ReturnValue_t addGpio(gpioId_t gpioId, GpioBase* gpioConfig); + /** + * @brief Get map with registered GPIOs. + */ + GpioMap getGpioMap() const; - ReturnValue_t addGpio(gpioId_t gpioId, GpioBase* gpioConfig); - /** - * @brief Get map with registered GPIOs. - */ - GpioMap getGpioMap() const; - -private: - /** - * Returns a copy of the internal GPIO map. - */ - GpioMap gpioMap; + private: + /** + * Returns a copy of the internal GPIO map. + */ + GpioMap gpioMap; }; #endif /* LINUX_GPIO_GPIOCOOKIE_H_ */ diff --git a/linux/archive/gpio/GpioIF.h b/linux/archive/gpio/GpioIF.h index 75feb3ce..045af556 100644 --- a/linux/archive/gpio/GpioIF.h +++ b/linux/archive/gpio/GpioIF.h @@ -1,9 +1,10 @@ #ifndef LINUX_GPIO_GPIOIF_H_ #define LINUX_GPIO_GPIOIF_H_ -#include "gpioDefinitions.h" -#include #include +#include + +#include "gpioDefinitions.h" class GpioCookie; @@ -13,42 +14,41 @@ class GpioCookie; * @author J. Meier */ class GpioIF : public HasReturnvaluesIF { -public: + public: + virtual ~GpioIF(){}; - virtual ~GpioIF() {}; + /** + * @brief Called by the GPIO using object. + * @param cookie Cookie specifying informations of the GPIOs required + * by a object. + */ + virtual ReturnValue_t addGpios(GpioCookie* cookie) = 0; - /** - * @brief Called by the GPIO using object. - * @param cookie Cookie specifying informations of the GPIOs required - * by a object. - */ - virtual ReturnValue_t addGpios(GpioCookie* cookie) = 0; + /** + * @brief By implementing this function a child must provide the + * functionality to pull a certain GPIO to high logic level. + * + * @param gpioId A unique number which specifies the GPIO to drive. + * @return Returns RETURN_OK for success. This should never return RETURN_FAILED. + */ + virtual ReturnValue_t pullHigh(gpioId_t gpioId) = 0; - /** - * @brief By implementing this function a child must provide the - * functionality to pull a certain GPIO to high logic level. - * - * @param gpioId A unique number which specifies the GPIO to drive. - * @return Returns RETURN_OK for success. This should never return RETURN_FAILED. - */ - virtual ReturnValue_t pullHigh(gpioId_t gpioId) = 0; + /** + * @brief By implementing this function a child must provide the + * functionality to pull a certain GPIO to low logic level. + * + * @param gpioId A unique number which specifies the GPIO to drive. + */ + virtual ReturnValue_t pullLow(gpioId_t gpioId) = 0; - /** - * @brief By implementing this function a child must provide the - * functionality to pull a certain GPIO to low logic level. - * - * @param gpioId A unique number which specifies the GPIO to drive. - */ - virtual ReturnValue_t pullLow(gpioId_t gpioId) = 0; - - /** - * @brief This function requires a child to implement the functionality to read the state of - * an ouput or input gpio. - * - * @param gpioId A unique number which specifies the GPIO to read. - * @param gpioState State of GPIO will be written to this pointer. - */ - virtual ReturnValue_t readGpio(gpioId_t gpioId, int* gpioState) = 0; + /** + * @brief This function requires a child to implement the functionality to read the state of + * an ouput or input gpio. + * + * @param gpioId A unique number which specifies the GPIO to read. + * @param gpioState State of GPIO will be written to this pointer. + */ + virtual ReturnValue_t readGpio(gpioId_t gpioId, int* gpioState) = 0; }; #endif /* LINUX_GPIO_GPIOIF_H_ */ diff --git a/linux/archive/gpio/LinuxLibgpioIF.cpp b/linux/archive/gpio/LinuxLibgpioIF.cpp index 92ffa63c..e5dcc1f2 100644 --- a/linux/archive/gpio/LinuxLibgpioIF.cpp +++ b/linux/archive/gpio/LinuxLibgpioIF.cpp @@ -1,302 +1,295 @@ #include "LinuxLibgpioIF.h" -#include "GpioCookie.h" #include +#include #include +#include #include -#include -#include +#include "GpioCookie.h" LinuxLibgpioIF::LinuxLibgpioIF(object_id_t objectId) : SystemObject(objectId) { - struct gpiod_chip* chip = gpiod_chip_open_by_label("/amba_pl/gpio@42030000"); + struct gpiod_chip* chip = gpiod_chip_open_by_label("/amba_pl/gpio@42030000"); - sif::debug << chip->name << std::endl; + sif::debug << chip->name << std::endl; } -LinuxLibgpioIF::~LinuxLibgpioIF() { -} +LinuxLibgpioIF::~LinuxLibgpioIF() {} ReturnValue_t LinuxLibgpioIF::addGpios(GpioCookie* gpioCookie) { - ReturnValue_t result; - if(gpioCookie == nullptr) { - sif::error << "LinuxLibgpioIF::initialize: Invalid cookie" << std::endl; - return RETURN_FAILED; - } + ReturnValue_t result; + if (gpioCookie == nullptr) { + sif::error << "LinuxLibgpioIF::initialize: Invalid cookie" << std::endl; + return RETURN_FAILED; + } - GpioMap mapToAdd = gpioCookie->getGpioMap(); + GpioMap mapToAdd = gpioCookie->getGpioMap(); - /* Check whether this ID already exists in the map and remove duplicates */ - result = checkForConflicts(mapToAdd); - if (result != RETURN_OK){ - return result; - } + /* Check whether this ID already exists in the map and remove duplicates */ + result = checkForConflicts(mapToAdd); + if (result != RETURN_OK) { + return result; + } - result = configureGpios(mapToAdd); - if (result != RETURN_OK) { - return RETURN_FAILED; - } + result = configureGpios(mapToAdd); + if (result != RETURN_OK) { + return RETURN_FAILED; + } - /* Register new GPIOs in gpioMap */ - gpioMap.insert(mapToAdd.begin(), mapToAdd.end()); + /* Register new GPIOs in gpioMap */ + gpioMap.insert(mapToAdd.begin(), mapToAdd.end()); - return RETURN_OK; + return RETURN_OK; } ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap& mapToAdd) { - for(auto& gpioConfig: mapToAdd) { - switch(gpioConfig.second->gpioType) { - case(gpio::GpioTypes::NONE): { - return GPIO_INVALID_INSTANCE; - } - case(gpio::GpioTypes::GPIOD_REGULAR): { - GpiodRegular* regularGpio = dynamic_cast(gpioConfig.second); - if(regularGpio == nullptr) { - return GPIO_INVALID_INSTANCE; - } - configureRegularGpio(gpioConfig.first, regularGpio); - break; - } - case(gpio::GpioTypes::CALLBACK): { - auto gpioCallback = dynamic_cast(gpioConfig.second); - if(gpioCallback->callback == nullptr) { - return GPIO_INVALID_INSTANCE; - } - gpioCallback->callback(gpioConfig.first, gpio::GpioOperation::WRITE, - gpioCallback->initValue, gpioCallback->callbackArgs); + for (auto& gpioConfig : mapToAdd) { + switch (gpioConfig.second->gpioType) { + case (gpio::GpioTypes::NONE): { + return GPIO_INVALID_INSTANCE; + } + case (gpio::GpioTypes::GPIOD_REGULAR): { + GpiodRegular* regularGpio = dynamic_cast(gpioConfig.second); + if (regularGpio == nullptr) { + return GPIO_INVALID_INSTANCE; } + configureRegularGpio(gpioConfig.first, regularGpio); + break; + } + case (gpio::GpioTypes::CALLBACK): { + auto gpioCallback = dynamic_cast(gpioConfig.second); + if (gpioCallback->callback == nullptr) { + return GPIO_INVALID_INSTANCE; } + gpioCallback->callback(gpioConfig.first, gpio::GpioOperation::WRITE, + gpioCallback->initValue, gpioCallback->callbackArgs); + } } - return RETURN_OK; + } + return RETURN_OK; } -ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, GpiodRegular *regularGpio) { - std::string chipname; - unsigned int lineNum; - struct gpiod_chip *chip; - gpio::Direction direction; - std::string consumer; - struct gpiod_line *lineHandle; - int result = 0; +ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, GpiodRegular* regularGpio) { + std::string chipname; + unsigned int lineNum; + struct gpiod_chip* chip; + gpio::Direction direction; + std::string consumer; + struct gpiod_line* lineHandle; + int result = 0; - chipname = regularGpio->chipname; - chip = gpiod_chip_open_by_name(chipname.c_str()); - if (!chip) { - sif::error << "LinuxLibgpioIF::configureGpios: Failed to open chip " - << chipname << ". Gpio ID: " << gpioId << std::endl; + chipname = regularGpio->chipname; + chip = gpiod_chip_open_by_name(chipname.c_str()); + if (!chip) { + sif::error << "LinuxLibgpioIF::configureGpios: Failed to open chip " << chipname + << ". Gpio ID: " << gpioId << std::endl; + return RETURN_FAILED; + } + + lineNum = regularGpio->lineNum; + lineHandle = gpiod_chip_get_line(chip, lineNum); + if (!lineHandle) { + sif::error << "LinuxLibgpioIF::configureGpios: Failed to open line for GPIO with id " << gpioId + << std::endl; + gpiod_chip_close(chip); + return RETURN_FAILED; + } + + direction = regularGpio->direction; + consumer = regularGpio->consumer; + /* Configure direction and add a description to the GPIO */ + switch (direction) { + case (gpio::OUT): { + result = gpiod_line_request_output(lineHandle, consumer.c_str(), regularGpio->initValue); + if (result < 0) { + sif::error << "LinuxLibgpioIF::configureGpios: Failed to request line " << lineNum + << " from GPIO instance with ID: " << gpioId << std::endl; + gpiod_line_release(lineHandle); return RETURN_FAILED; + } + break; } - - lineNum = regularGpio->lineNum; - lineHandle = gpiod_chip_get_line(chip, lineNum); - if (!lineHandle) { - sif::error << "LinuxLibgpioIF::configureGpios: Failed to open line for GPIO with id " - << gpioId << std::endl; - gpiod_chip_close(chip); + case (gpio::IN): { + result = gpiod_line_request_input(lineHandle, consumer.c_str()); + if (result < 0) { + sif::error << "LinuxLibgpioIF::configureGpios: Failed to request line " << lineNum + << " from GPIO instance with ID: " << gpioId << std::endl; + gpiod_line_release(lineHandle); return RETURN_FAILED; - } - - direction = regularGpio->direction; - consumer = regularGpio->consumer; - /* Configure direction and add a description to the GPIO */ - switch (direction) { - case(gpio::OUT): { - result = gpiod_line_request_output(lineHandle, consumer.c_str(), - regularGpio->initValue); - if (result < 0) { - sif::error << "LinuxLibgpioIF::configureGpios: Failed to request line " << lineNum << - " from GPIO instance with ID: " << gpioId << std::endl; - gpiod_line_release(lineHandle); - return RETURN_FAILED; - } - break; - } - case(gpio::IN): { - result = gpiod_line_request_input(lineHandle, consumer.c_str()); - if (result < 0) { - sif::error << "LinuxLibgpioIF::configureGpios: Failed to request line " - << lineNum << " from GPIO instance with ID: " << gpioId << std::endl; - gpiod_line_release(lineHandle); - return RETURN_FAILED; - } - break; + } + break; } default: { - sif::error << "LinuxLibgpioIF::configureGpios: Invalid direction specified" - << std::endl; - return GPIO_INVALID_INSTANCE; + sif::error << "LinuxLibgpioIF::configureGpios: Invalid direction specified" << std::endl; + return GPIO_INVALID_INSTANCE; } - - } - /** - * Write line handle to GPIO configuration instance so it can later be used to set or - * read states of GPIOs. - */ - regularGpio->lineHandle = lineHandle; - return RETURN_OK; + } + /** + * Write line handle to GPIO configuration instance so it can later be used to set or + * read states of GPIOs. + */ + regularGpio->lineHandle = lineHandle; + return RETURN_OK; } ReturnValue_t LinuxLibgpioIF::pullHigh(gpioId_t gpioId) { - gpioMapIter = gpioMap.find(gpioId); - if (gpioMapIter == gpioMap.end()) { - sif::warning << "LinuxLibgpioIF::driveGpio: Unknown GPIOD ID " << gpioId << std::endl; - return UNKNOWN_GPIO_ID; - } + gpioMapIter = gpioMap.find(gpioId); + if (gpioMapIter == gpioMap.end()) { + sif::warning << "LinuxLibgpioIF::driveGpio: Unknown GPIOD ID " << gpioId << std::endl; + return UNKNOWN_GPIO_ID; + } - if(gpioMapIter->second->gpioType == gpio::GpioTypes::GPIOD_REGULAR) { - return driveGpio(gpioId, dynamic_cast(gpioMapIter->second), 1); + if (gpioMapIter->second->gpioType == gpio::GpioTypes::GPIOD_REGULAR) { + return driveGpio(gpioId, dynamic_cast(gpioMapIter->second), 1); + } else { + auto gpioCallback = dynamic_cast(gpioMapIter->second); + if (gpioCallback->callback == nullptr) { + return GPIO_INVALID_INSTANCE; } - else { - auto gpioCallback = dynamic_cast(gpioMapIter->second); - if(gpioCallback->callback == nullptr) { - return GPIO_INVALID_INSTANCE; - } - gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::WRITE, - 1, gpioCallback->callbackArgs); - } - return GPIO_TYPE_FAILURE; + gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::WRITE, 1, + gpioCallback->callbackArgs); + } + return GPIO_TYPE_FAILURE; } ReturnValue_t LinuxLibgpioIF::pullLow(gpioId_t gpioId) { - gpioMapIter = gpioMap.find(gpioId); - if (gpioMapIter == gpioMap.end()) { - sif::warning << "LinuxLibgpioIF::driveGpio: Unknown GPIOD ID " << gpioId << std::endl; - return UNKNOWN_GPIO_ID; - } + gpioMapIter = gpioMap.find(gpioId); + if (gpioMapIter == gpioMap.end()) { + sif::warning << "LinuxLibgpioIF::driveGpio: Unknown GPIOD ID " << gpioId << std::endl; + return UNKNOWN_GPIO_ID; + } - if(gpioMapIter->second->gpioType == gpio::GpioTypes::GPIOD_REGULAR) { - return driveGpio(gpioId, dynamic_cast(gpioMapIter->second), 0); + if (gpioMapIter->second->gpioType == gpio::GpioTypes::GPIOD_REGULAR) { + return driveGpio(gpioId, dynamic_cast(gpioMapIter->second), 0); + } else { + auto gpioCallback = dynamic_cast(gpioMapIter->second); + if (gpioCallback->callback == nullptr) { + return GPIO_INVALID_INSTANCE; } - else { - auto gpioCallback = dynamic_cast(gpioMapIter->second); - if(gpioCallback->callback == nullptr) { - return GPIO_INVALID_INSTANCE; - } - gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::WRITE, - 0, gpioCallback->callbackArgs); - } - return GPIO_TYPE_FAILURE; + gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::WRITE, 0, + gpioCallback->callbackArgs); + } + return GPIO_TYPE_FAILURE; } -ReturnValue_t LinuxLibgpioIF::driveGpio(gpioId_t gpioId, - GpiodRegular* regularGpio, unsigned int logicLevel) { - if(regularGpio == nullptr) { - return GPIO_TYPE_FAILURE; - } +ReturnValue_t LinuxLibgpioIF::driveGpio(gpioId_t gpioId, GpiodRegular* regularGpio, + unsigned int logicLevel) { + if (regularGpio == nullptr) { + return GPIO_TYPE_FAILURE; + } - int result = gpiod_line_set_value(regularGpio->lineHandle, logicLevel); - if (result < 0) { - sif::warning << "LinuxLibgpioIF::driveGpio: Failed to pull GPIO with ID " << gpioId << - " to logic level " << logicLevel << std::endl; - return DRIVE_GPIO_FAILURE; - } + int result = gpiod_line_set_value(regularGpio->lineHandle, logicLevel); + if (result < 0) { + sif::warning << "LinuxLibgpioIF::driveGpio: Failed to pull GPIO with ID " << gpioId + << " to logic level " << logicLevel << std::endl; + return DRIVE_GPIO_FAILURE; + } - return RETURN_OK; + return RETURN_OK; } ReturnValue_t LinuxLibgpioIF::readGpio(gpioId_t gpioId, int* gpioState) { - gpioMapIter = gpioMap.find(gpioId); - if (gpioMapIter == gpioMap.end()){ - sif::warning << "LinuxLibgpioIF::readGpio: Unknown GPIOD ID " << gpioId << std::endl; - return UNKNOWN_GPIO_ID; + gpioMapIter = gpioMap.find(gpioId); + if (gpioMapIter == gpioMap.end()) { + sif::warning << "LinuxLibgpioIF::readGpio: Unknown GPIOD ID " << gpioId << std::endl; + return UNKNOWN_GPIO_ID; + } + + if (gpioMapIter->second->gpioType == gpio::GpioTypes::GPIOD_REGULAR) { + GpiodRegular* regularGpio = dynamic_cast(gpioMapIter->second); + if (regularGpio == nullptr) { + return GPIO_TYPE_FAILURE; } + *gpioState = gpiod_line_get_value(regularGpio->lineHandle); + } else { + } - if(gpioMapIter->second->gpioType == gpio::GpioTypes::GPIOD_REGULAR) { - GpiodRegular* regularGpio = dynamic_cast(gpioMapIter->second); - if(regularGpio == nullptr) { - return GPIO_TYPE_FAILURE; - } - *gpioState = gpiod_line_get_value(regularGpio->lineHandle); - } - else { - - } - - - return RETURN_OK; + return RETURN_OK; } -ReturnValue_t LinuxLibgpioIF::checkForConflicts(GpioMap& mapToAdd){ - ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - for(auto& gpioConfig: mapToAdd) { - switch(gpioConfig.second->gpioType) { - case(gpio::GpioTypes::GPIOD_REGULAR): { - auto regularGpio = dynamic_cast(gpioConfig.second); - if(regularGpio == nullptr) { - return GPIO_TYPE_FAILURE; - } - /* Check for conflicts and remove duplicates if necessary */ - result = checkForConflictsRegularGpio(gpioConfig.first, regularGpio, mapToAdd); - if(result != HasReturnvaluesIF::RETURN_OK) { - status = result; - } - break; +ReturnValue_t LinuxLibgpioIF::checkForConflicts(GpioMap& mapToAdd) { + ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + for (auto& gpioConfig : mapToAdd) { + switch (gpioConfig.second->gpioType) { + case (gpio::GpioTypes::GPIOD_REGULAR): { + auto regularGpio = dynamic_cast(gpioConfig.second); + if (regularGpio == nullptr) { + return GPIO_TYPE_FAILURE; } - case(gpio::GpioTypes::CALLBACK): { - auto callbackGpio = dynamic_cast(gpioConfig.second); - if(callbackGpio == nullptr) { - return GPIO_TYPE_FAILURE; - } - /* Check for conflicts and remove duplicates if necessary */ - result = checkForConflictsCallbackGpio(gpioConfig.first, callbackGpio, mapToAdd); - if(result != HasReturnvaluesIF::RETURN_OK) { - status = result; - } - break; + /* Check for conflicts and remove duplicates if necessary */ + result = checkForConflictsRegularGpio(gpioConfig.first, regularGpio, mapToAdd); + if (result != HasReturnvaluesIF::RETURN_OK) { + status = result; } - default: { - + break; + } + case (gpio::GpioTypes::CALLBACK): { + auto callbackGpio = dynamic_cast(gpioConfig.second); + if (callbackGpio == nullptr) { + return GPIO_TYPE_FAILURE; } + /* Check for conflicts and remove duplicates if necessary */ + result = checkForConflictsCallbackGpio(gpioConfig.first, callbackGpio, mapToAdd); + if (result != HasReturnvaluesIF::RETURN_OK) { + status = result; } + break; + } + default: { + } } - return status; + } + return status; } - ReturnValue_t LinuxLibgpioIF::checkForConflictsRegularGpio(gpioId_t gpioIdToCheck, - GpiodRegular* gpioToCheck, GpioMap& mapToAdd) { - /* Cross check with private map */ - gpioMapIter = gpioMap.find(gpioIdToCheck); - if(gpioMapIter != gpioMap.end()) { - if(gpioMapIter->second->gpioType != gpio::GpioTypes::GPIOD_REGULAR) { - sif::warning << "LinuxLibgpioIF::checkForConflicts: ID already exists for different " - "GPIO type" << gpioIdToCheck << ". Removing duplicate." << std::endl; - mapToAdd.erase(gpioIdToCheck); - return HasReturnvaluesIF::RETURN_OK; - } - auto ownRegularGpio = dynamic_cast(gpioMapIter->second); - if(ownRegularGpio == nullptr) { - return GPIO_TYPE_FAILURE; - } - - /* Remove element from map to add because a entry for this GPIO - already exists */ - sif::warning << "LinuxLibgpioIF::checkForConflictsRegularGpio: Duplicate GPIO definition" - << " detected. Duplicate will be removed from map to add." << std::endl; - mapToAdd.erase(gpioIdToCheck); + GpiodRegular* gpioToCheck, + GpioMap& mapToAdd) { + /* Cross check with private map */ + gpioMapIter = gpioMap.find(gpioIdToCheck); + if (gpioMapIter != gpioMap.end()) { + if (gpioMapIter->second->gpioType != gpio::GpioTypes::GPIOD_REGULAR) { + sif::warning << "LinuxLibgpioIF::checkForConflicts: ID already exists for different " + "GPIO type" + << gpioIdToCheck << ". Removing duplicate." << std::endl; + mapToAdd.erase(gpioIdToCheck); + return HasReturnvaluesIF::RETURN_OK; } - return HasReturnvaluesIF::RETURN_OK; + auto ownRegularGpio = dynamic_cast(gpioMapIter->second); + if (ownRegularGpio == nullptr) { + return GPIO_TYPE_FAILURE; + } + + /* Remove element from map to add because a entry for this GPIO + already exists */ + sif::warning << "LinuxLibgpioIF::checkForConflictsRegularGpio: Duplicate GPIO definition" + << " detected. Duplicate will be removed from map to add." << std::endl; + mapToAdd.erase(gpioIdToCheck); + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t LinuxLibgpioIF::checkForConflictsCallbackGpio(gpioId_t gpioIdToCheck, - GpioCallback *callbackGpio, GpioMap& mapToAdd) { - /* Cross check with private map */ - gpioMapIter = gpioMap.find(gpioIdToCheck); - if(gpioMapIter != gpioMap.end()) { - if(gpioMapIter->second->gpioType != gpio::GpioTypes::CALLBACK) { - sif::warning << "LinuxLibgpioIF::checkForConflicts: ID already exists for different " - "GPIO type" << gpioIdToCheck << ". Removing duplicate." << std::endl; - mapToAdd.erase(gpioIdToCheck); - return HasReturnvaluesIF::RETURN_OK; - } - - /* Remove element from map to add because a entry for this GPIO - already exists */ - sif::warning << "LinuxLibgpioIF::checkForConflictsRegularGpio: Duplicate GPIO definition" - << " detected. Duplicate will be removed from map to add." << std::endl; - mapToAdd.erase(gpioIdToCheck); + GpioCallback* callbackGpio, + GpioMap& mapToAdd) { + /* Cross check with private map */ + gpioMapIter = gpioMap.find(gpioIdToCheck); + if (gpioMapIter != gpioMap.end()) { + if (gpioMapIter->second->gpioType != gpio::GpioTypes::CALLBACK) { + sif::warning << "LinuxLibgpioIF::checkForConflicts: ID already exists for different " + "GPIO type" + << gpioIdToCheck << ". Removing duplicate." << std::endl; + mapToAdd.erase(gpioIdToCheck); + return HasReturnvaluesIF::RETURN_OK; } - return HasReturnvaluesIF::RETURN_OK; + + /* Remove element from map to add because a entry for this GPIO + already exists */ + sif::warning << "LinuxLibgpioIF::checkForConflictsRegularGpio: Duplicate GPIO definition" + << " detected. Duplicate will be removed from map to add." << std::endl; + mapToAdd.erase(gpioIdToCheck); + } + return HasReturnvaluesIF::RETURN_OK; } diff --git a/linux/archive/gpio/LinuxLibgpioIF.h b/linux/archive/gpio/LinuxLibgpioIF.h index 9c444e50..1c974efb 100644 --- a/linux/archive/gpio/LinuxLibgpioIF.h +++ b/linux/archive/gpio/LinuxLibgpioIF.h @@ -1,9 +1,9 @@ #ifndef LINUX_GPIO_LINUXLIBGPIOIF_H_ #define LINUX_GPIO_LINUXLIBGPIOIF_H_ -#include -#include #include +#include +#include class GpioCookie; @@ -15,63 +15,61 @@ class GpioCookie; * 2019.1. */ class LinuxLibgpioIF : public GpioIF, public SystemObject { -public: + public: + static const uint8_t gpioRetvalId = CLASS_ID::LINUX_LIBGPIO_IF; - static const uint8_t gpioRetvalId = CLASS_ID::LINUX_LIBGPIO_IF; + static constexpr ReturnValue_t UNKNOWN_GPIO_ID = + HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 1); + static constexpr ReturnValue_t DRIVE_GPIO_FAILURE = + HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 2); + static constexpr ReturnValue_t GPIO_TYPE_FAILURE = + HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 3); + static constexpr ReturnValue_t GPIO_INVALID_INSTANCE = + HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 4); - static constexpr ReturnValue_t UNKNOWN_GPIO_ID = - HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 1); - static constexpr ReturnValue_t DRIVE_GPIO_FAILURE = - HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 2); - static constexpr ReturnValue_t GPIO_TYPE_FAILURE = - HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 3); - static constexpr ReturnValue_t GPIO_INVALID_INSTANCE = - HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 4); + LinuxLibgpioIF(object_id_t objectId); + virtual ~LinuxLibgpioIF(); - LinuxLibgpioIF(object_id_t objectId); - virtual ~LinuxLibgpioIF(); + ReturnValue_t addGpios(GpioCookie* gpioCookie) override; + ReturnValue_t pullHigh(gpioId_t gpioId) override; + ReturnValue_t pullLow(gpioId_t gpioId) override; + ReturnValue_t readGpio(gpioId_t gpioId, int* gpioState) override; - ReturnValue_t addGpios(GpioCookie* gpioCookie) override; - ReturnValue_t pullHigh(gpioId_t gpioId) override; - ReturnValue_t pullLow(gpioId_t gpioId) override; - ReturnValue_t readGpio(gpioId_t gpioId, int* gpioState) override; + private: + /* Holds the information and configuration of all used GPIOs */ + GpioMap gpioMap; + GpioMapIter gpioMapIter; -private: - /* Holds the information and configuration of all used GPIOs */ - GpioMap gpioMap; - GpioMapIter gpioMapIter; + /** + * @brief This functions drives line of a GPIO specified by the GPIO ID. + * + * @param gpioId The GPIO ID of the GPIO to drive. + * @param logiclevel The logic level to set. O or 1. + */ + ReturnValue_t driveGpio(gpioId_t gpioId, GpiodRegularBase& regularGpio, unsigned int logiclevel); - /** - * @brief This functions drives line of a GPIO specified by the GPIO ID. - * - * @param gpioId The GPIO ID of the GPIO to drive. - * @param logiclevel The logic level to set. O or 1. - */ - ReturnValue_t driveGpio(gpioId_t gpioId, GpiodRegularBase& regularGpio, unsigned int logiclevel); + ReturnValue_t configureRegularGpio(gpioId_t gpioId, GpiodRegularBase& regularGpio); - ReturnValue_t configureRegularGpio(gpioId_t gpioId, GpiodRegularBase& regularGpio); + /** + * @brief This function checks if GPIOs are already registered and whether + * there exists a conflict in the GPIO configuration. E.g. the + * direction. + * + * @param mapToAdd The GPIOs which shall be added to the gpioMap. + * + * @return RETURN_OK if successful, otherwise RETURN_FAILED + */ + ReturnValue_t checkForConflicts(GpioMap& mapToAdd); - /** - * @brief This function checks if GPIOs are already registered and whether - * there exists a conflict in the GPIO configuration. E.g. the - * direction. - * - * @param mapToAdd The GPIOs which shall be added to the gpioMap. - * - * @return RETURN_OK if successful, otherwise RETURN_FAILED - */ - ReturnValue_t checkForConflicts(GpioMap& mapToAdd); - - ReturnValue_t checkForConflictsRegularGpio(gpioId_t gpiodId, GpiodRegular* regularGpio, - GpioMap& mapToAdd); - ReturnValue_t checkForConflictsCallbackGpio(gpioId_t gpiodId, GpioCallback* regularGpio, - GpioMap& mapToAdd); - - /** - * @brief Performs the initial configuration of all GPIOs specified in the GpioMap mapToAdd. - */ - ReturnValue_t configureGpios(GpioMap& mapToAdd); + ReturnValue_t checkForConflictsRegularGpio(gpioId_t gpiodId, GpiodRegular* regularGpio, + GpioMap& mapToAdd); + ReturnValue_t checkForConflictsCallbackGpio(gpioId_t gpiodId, GpioCallback* regularGpio, + GpioMap& mapToAdd); + /** + * @brief Performs the initial configuration of all GPIOs specified in the GpioMap mapToAdd. + */ + ReturnValue_t configureGpios(GpioMap& mapToAdd); }; #endif /* LINUX_GPIO_LINUXLIBGPIOIF_H_ */ diff --git a/linux/archive/gpio/gpioDefinitions.h b/linux/archive/gpio/gpioDefinitions.h index 66c0b005..0db4db11 100644 --- a/linux/archive/gpio/gpioDefinitions.h +++ b/linux/archive/gpio/gpioDefinitions.h @@ -8,29 +8,16 @@ using gpioId_t = uint16_t; namespace gpio { -enum Levels { - LOW = 0, - HIGH = 1 -}; +enum Levels { LOW = 0, HIGH = 1 }; -enum Direction { - IN = 0, - OUT = 1 -}; +enum Direction { IN = 0, OUT = 1 }; -enum GpioOperation { - READ, - WRITE -}; +enum GpioOperation { READ, WRITE }; -enum GpioTypes { - NONE, - GPIOD_REGULAR, - CALLBACK -}; +enum GpioTypes { NONE, GPIOD_REGULAR, CALLBACK }; static constexpr gpioId_t NO_GPIO = -1; -} +} // namespace gpio /** * @brief Struct containing information about the GPIO to use. This is @@ -47,51 +34,49 @@ static constexpr gpioId_t NO_GPIO = -1; * pointer. */ class GpioBase { -public: + public: + GpioBase() = default; - GpioBase() = default; + GpioBase(gpio::GpioTypes gpioType, std::string consumer, gpio::Direction direction, int initValue) + : gpioType(gpioType), consumer(consumer), direction(direction), initValue(initValue) {} - GpioBase(gpio::GpioTypes gpioType, std::string consumer, gpio::Direction direction, - int initValue): - gpioType(gpioType), consumer(consumer),direction(direction), initValue(initValue) {} + virtual ~GpioBase(){}; - virtual~ GpioBase() {}; - - /* Can be used to cast GpioBase to a concrete child implementation */ - gpio::GpioTypes gpioType = gpio::GpioTypes::NONE; - std::string consumer; - gpio::Direction direction = gpio::Direction::IN; - int initValue = 0; + /* Can be used to cast GpioBase to a concrete child implementation */ + gpio::GpioTypes gpioType = gpio::GpioTypes::NONE; + std::string consumer; + gpio::Direction direction = gpio::Direction::IN; + int initValue = 0; }; -class GpiodRegular: public GpioBase { -public: - GpiodRegular(): GpioBase(gpio::GpioTypes::GPIOD_REGULAR, std::string(), - gpio::Direction::IN, 0) {}; +class GpiodRegular : public GpioBase { + public: + GpiodRegular() + : GpioBase(gpio::GpioTypes::GPIOD_REGULAR, std::string(), gpio::Direction::IN, 0){}; - GpiodRegular(std::string chipname_, int lineNum_, std::string consumer_, - gpio::Direction direction_, int initValue_): - GpioBase(gpio::GpioTypes::GPIOD_REGULAR, consumer_, direction_, initValue_), - chipname(chipname_), lineNum(lineNum_) {} - std::string chipname; - int lineNum = 0; - struct gpiod_line* lineHandle = nullptr; + GpiodRegular(std::string chipname_, int lineNum_, std::string consumer_, + gpio::Direction direction_, int initValue_) + : GpioBase(gpio::GpioTypes::GPIOD_REGULAR, consumer_, direction_, initValue_), + chipname(chipname_), + lineNum(lineNum_) {} + std::string chipname; + int lineNum = 0; + struct gpiod_line* lineHandle = nullptr; }; -class GpioCallback: public GpioBase { -public: - GpioCallback(std::string consumer, gpio::Direction direction_, int initValue_, - void (* callback) (gpioId_t gpioId, gpio::GpioOperation gpioOp, int value, void* args), - void* callbackArgs): - GpioBase(gpio::GpioTypes::CALLBACK, consumer, direction_, initValue_), - callback(callback), callbackArgs(callbackArgs) {} +class GpioCallback : public GpioBase { + public: + GpioCallback(std::string consumer, gpio::Direction direction_, int initValue_, + void (*callback)(gpioId_t gpioId, gpio::GpioOperation gpioOp, int value, void* args), + void* callbackArgs) + : GpioBase(gpio::GpioTypes::CALLBACK, consumer, direction_, initValue_), + callback(callback), + callbackArgs(callbackArgs) {} - void (* callback) (gpioId_t gpioId, gpio::GpioOperation gpioOp, - int value, void* args) = nullptr; - void* callbackArgs = nullptr; + void (*callback)(gpioId_t gpioId, gpio::GpioOperation gpioOp, int value, void* args) = nullptr; + void* callbackArgs = nullptr; }; - using GpioMap = std::unordered_map; using GpioMapIter = GpioMap::iterator; diff --git a/linux/archive/tmtc/CCSDSIPCoreBridge.cpp b/linux/archive/tmtc/CCSDSIPCoreBridge.cpp index 982f7fc2..607ccebd 100644 --- a/linux/archive/tmtc/CCSDSIPCoreBridge.cpp +++ b/linux/archive/tmtc/CCSDSIPCoreBridge.cpp @@ -1,136 +1,128 @@ -#include #include - #include +#include CCSDSIPCoreBridge::CCSDSIPCoreBridge(object_id_t objectId, object_id_t tcDestination, - object_id_t tmStoreId, object_id_t tcStoreId, LinuxLibgpioIF* gpioComIF, - std::string uioPtme, gpioId_t papbBusyId, gpioId_t papbEmptyId) : - TmTcBridge(objectId, tcDestination, tmStoreId, tcStoreId), gpioComIF(gpioComIF), uioPtme( - uioPtme), papbBusyId(papbBusyId), papbEmptyId(papbEmptyId) { -} + object_id_t tmStoreId, object_id_t tcStoreId, + LinuxLibgpioIF* gpioComIF, std::string uioPtme, + gpioId_t papbBusyId, gpioId_t papbEmptyId) + : TmTcBridge(objectId, tcDestination, tmStoreId, tcStoreId), + gpioComIF(gpioComIF), + uioPtme(uioPtme), + papbBusyId(papbBusyId), + papbEmptyId(papbEmptyId) {} -CCSDSIPCoreBridge::~CCSDSIPCoreBridge() { -} +CCSDSIPCoreBridge::~CCSDSIPCoreBridge() {} ReturnValue_t CCSDSIPCoreBridge::initialize() { - ReturnValue_t result = TmTcBridge::initialize(); + ReturnValue_t result = TmTcBridge::initialize(); - fd = open("/dev/uio0", O_RDWR); - if (fd < 1) { - sif::debug << "CCSDSIPCoreBridge::initialize: Invalid UIO device file" << std::endl; - return RETURN_FAILED; - } + fd = open("/dev/uio0", O_RDWR); + if (fd < 1) { + sif::debug << "CCSDSIPCoreBridge::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_READ | PROT_WRITE, - MAP_SHARED, fd, 0)); + /** + * Map uio device in virtual address space + * PROT_WRITE: Map uio device in writable only mode + */ + ptmeBaseAddress = + static_cast(mmap(NULL, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)); - if (ptmeBaseAddress == MAP_FAILED) { - sif::error << "CCSDSIPCoreBridge::initialize: Failed to map uio address" << std::endl; - return RETURN_FAILED; - } + if (ptmeBaseAddress == MAP_FAILED) { + sif::error << "CCSDSIPCoreBridge::initialize: Failed to map uio address" << std::endl; + return RETURN_FAILED; + } - return result; + return result; } ReturnValue_t CCSDSIPCoreBridge::handleTm() { - #if OBSW_TEST_CCSDS_PTME == 1 - return sendTestFrame(); + return sendTestFrame(); #else - return TmTcBridge::handleTm(); + return TmTcBridge::handleTm(); #endif - } -ReturnValue_t CCSDSIPCoreBridge::sendTm(const uint8_t * data, size_t dataLen) { +ReturnValue_t CCSDSIPCoreBridge::sendTm(const uint8_t* data, size_t dataLen) { + if (pollPapbBusySignal() == RETURN_OK) { + startPacketTransfer(); + } - if(pollPapbBusySignal() == RETURN_OK) { - startPacketTransfer(); + for (size_t idx = 0; idx < dataLen; idx++) { + if (pollPapbBusySignal() == RETURN_OK) { + *(ptmeBaseAddress + PTME_DATA_REG_OFFSET) = static_cast(*(data + idx)); + } else { + sif::debug << "CCSDSIPCoreBridge::sendTm: Only written " << idx - 1 << " of " << dataLen + << " data" << std::endl; + return RETURN_FAILED; } + } - for(size_t idx = 0; idx < dataLen; idx++) { - if(pollPapbBusySignal() == RETURN_OK) { - *(ptmeBaseAddress + PTME_DATA_REG_OFFSET) = static_cast(*(data + idx)); - } - else { - sif::debug << "CCSDSIPCoreBridge::sendTm: Only written " << idx - 1 << " of " << dataLen - << " data" << std::endl; - return RETURN_FAILED; - } - } - - if(pollPapbBusySignal() == RETURN_OK) { - endPacketTransfer(); - } - return RETURN_OK; + if (pollPapbBusySignal() == RETURN_OK) { + endPacketTransfer(); + } + return RETURN_OK; } -void CCSDSIPCoreBridge::startPacketTransfer() { - *ptmeBaseAddress = PTME_CONFIG_START; -} +void CCSDSIPCoreBridge::startPacketTransfer() { *ptmeBaseAddress = PTME_CONFIG_START; } -void CCSDSIPCoreBridge::endPacketTransfer() { - *ptmeBaseAddress = PTME_CONFIG_END; -} +void CCSDSIPCoreBridge::endPacketTransfer() { *ptmeBaseAddress = PTME_CONFIG_END; } ReturnValue_t CCSDSIPCoreBridge::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::debug << "CCSDSIPCoreBridge::pollPapbBusySignal: Failed to read papb busy signal" - << std::endl; - return RETURN_FAILED; - } - if (!papbBusyState) { - sif::debug << "CCSDSIPCoreBridge::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::debug << "CCSDSIPCoreBridge::pollPapbBusySignal: Failed to read papb busy signal" + << std::endl; + return RETURN_FAILED; + } + if (!papbBusyState) { + sif::debug << "CCSDSIPCoreBridge::pollPapbBusySignal: PAPB busy" << std::endl; + return PAPB_BUSY; + } - return RETURN_OK; + return RETURN_OK; } void CCSDSIPCoreBridge::isPtmeBufferEmpty() { - 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::debug << "CCSDSIPCoreBridge::isPtmeBufferEmpty: Failed to read papb empty signal" - << std::endl; - return; - } - - if (papbEmptyState == 1) { - sif::debug << "CCSDSIPCoreBridge::isPtmeBufferEmpty: Buffer is empty" << std::endl; - } - else { - sif::debug << "CCSDSIPCoreBridge::isPtmeBufferEmpty: Buffer is not empty" << std::endl; - } + if (result != RETURN_OK) { + sif::debug << "CCSDSIPCoreBridge::isPtmeBufferEmpty: Failed to read papb empty signal" + << std::endl; return; + } + + if (papbEmptyState == 1) { + sif::debug << "CCSDSIPCoreBridge::isPtmeBufferEmpty: Buffer is empty" << std::endl; + } else { + sif::debug << "CCSDSIPCoreBridge::isPtmeBufferEmpty: Buffer is not empty" << std::endl; + } + return; } ReturnValue_t CCSDSIPCoreBridge::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 = sendTm(testPacket, 1105); - if(result != RETURN_OK) { - return result; - } + ReturnValue_t result = sendTm(testPacket, 1105); + if (result != RETURN_OK) { + return result; + } - return RETURN_OK; + return RETURN_OK; } diff --git a/linux/archive/tmtc/CCSDSIPCoreBridge.h b/linux/archive/tmtc/CCSDSIPCoreBridge.h index 2ba68a3a..074769c4 100644 --- a/linux/archive/tmtc/CCSDSIPCoreBridge.h +++ b/linux/archive/tmtc/CCSDSIPCoreBridge.h @@ -1,131 +1,129 @@ #ifndef MISSION_OBC_CCSDSIPCOREBRIDGE_H_ #define MISSION_OBC_CCSDSIPCOREBRIDGE_H_ -#include "OBSWConfig.h" #include #include #include #include +#include "OBSWConfig.h" + /** * @brief This class handles the interfacing to the telemetry (PTME) and telecommand (PDEC) IP * cores responsible for the CCSDS encoding and decoding. The IP cores are implemented * on the programmable logic and are accessible through the linux UIO driver. */ -class CCSDSIPCoreBridge: public TmTcBridge { -public: - /** - * @brief Constructor - * - * @param objectId - * @param tcDestination - * @param tmStoreId - * @param tcStoreId - * @param uioPtme Name of the uio device file which provides access to the PTME IP Core. - * @param papbBusyId The ID of the GPIO which is connected to the PAPBBusy_N signal of the - * PTME IP Core. A low logic level indicates the PTME is not ready to - * receive more data. - * @param papbEmptyId The ID of the GPIO which is connected to the PAPBEmpty signal of the - * PTME IP Core. The signal is high when there are no packets in the - * external buffer memory (BRAM). - */ - CCSDSIPCoreBridge(object_id_t objectId, object_id_t tcDestination, object_id_t tmStoreId, - object_id_t tcStoreId, LinuxLibgpioIF* gpioComIF, std::string uioPtme, - gpioId_t papbBusyId, gpioId_t papbEmptyId); - virtual ~CCSDSIPCoreBridge(); +class CCSDSIPCoreBridge : public TmTcBridge { + public: + /** + * @brief Constructor + * + * @param objectId + * @param tcDestination + * @param tmStoreId + * @param tcStoreId + * @param uioPtme Name of the uio device file which provides access to the PTME IP Core. + * @param papbBusyId The ID of the GPIO which is connected to the PAPBBusy_N signal of the + * PTME IP Core. A low logic level indicates the PTME is not ready to + * receive more data. + * @param papbEmptyId The ID of the GPIO which is connected to the PAPBEmpty signal of the + * PTME IP Core. The signal is high when there are no packets in the + * external buffer memory (BRAM). + */ + CCSDSIPCoreBridge(object_id_t objectId, object_id_t tcDestination, object_id_t tmStoreId, + object_id_t tcStoreId, LinuxLibgpioIF* gpioComIF, std::string uioPtme, + gpioId_t papbBusyId, gpioId_t papbEmptyId); + virtual ~CCSDSIPCoreBridge(); - ReturnValue_t initialize() override; + ReturnValue_t initialize() override; -protected: + protected: + /** + * Overwriting this function to provide the capability of testing the PTME IP Core + * implementation. + */ + virtual ReturnValue_t handleTm() override; - /** - * Overwriting this function to provide the capability of testing the PTME IP Core - * implementation. - */ - virtual ReturnValue_t handleTm() override; + virtual ReturnValue_t sendTm(const uint8_t* data, size_t dataLen) override; - virtual ReturnValue_t sendTm(const uint8_t * data, size_t dataLen) override; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_IP_CORE_BRIDGE; -private: + static const ReturnValue_t PAPB_BUSY = MAKE_RETURN_CODE(0xA0); - static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_IP_CORE_BRIDGE; + /** Size of mapped address space. 4k (minimal size of pl device) */ + // static const int MAP_SIZE = 0xFA0; + static const int MAP_SIZE = 0x1000; - static const ReturnValue_t PAPB_BUSY = MAKE_RETURN_CODE(0xA0); + /** + * Configuration bits: + * bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00 + * bit[2]: Set this bit to 1 to abort a transfered packet + * bit[3]: Signals to PTME the start of a new telemetry packet + */ + static const uint32_t PTME_CONFIG_START = 0x8; + /** + * Writing this word to the ptme base address signals to the PTME that a complete tm packet has + * been transferred. + */ + static const uint32_t PTME_CONFIG_END = 0x0; - /** Size of mapped address space. 4k (minimal size of pl device) */ -// static const int MAP_SIZE = 0xFA0; - static const int MAP_SIZE = 0x1000; + /** + * Writing to this offset within the PTME memory space will insert data for encoding to the + * PTME IP core. + * The address offset is 0x400 (= 4 * 256) + */ + static const int PTME_DATA_REG_OFFSET = 256; - /** - * Configuration bits: - * bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00 - * bit[2]: Set this bit to 1 to abort a transfered packet - * bit[3]: Signals to PTME the start of a new telemetry packet - */ - static const uint32_t PTME_CONFIG_START = 0x8; + LinuxLibgpioIF* gpioComIF = nullptr; - /** - * Writing this word to the ptme base address signals to the PTME that a complete tm packet has - * been transferred. - */ - static const uint32_t PTME_CONFIG_END = 0x0; + /** The uio device file related to the PTME IP Core */ + std::string uioPtme; - /** - * Writing to this offset within the PTME memory space will insert data for encoding to the - * PTME IP core. - * The address offset is 0x400 (= 4 * 256) - */ - static const int PTME_DATA_REG_OFFSET = 256; + /** Pulled to low when PTME not ready to receive data */ + gpioId_t papbBusyId = gpio::NO_GPIO; - LinuxLibgpioIF* gpioComIF = nullptr; + /** High when externally buffer memory of PTME is empty */ + gpioId_t papbEmptyId = gpio::NO_GPIO; - /** The uio device file related to the PTME IP Core */ - std::string uioPtme; + /** The file descriptor of the UIO driver */ + int fd; - /** Pulled to low when PTME not ready to receive data */ - gpioId_t papbBusyId = gpio::NO_GPIO; + uint32_t* ptmeBaseAddress = nullptr; - /** High when externally buffer memory of PTME is empty */ - gpioId_t papbEmptyId = gpio::NO_GPIO; + /** + * @brief This function sends the config byte to the PTME IP Core to initiate a packet + * transfer. + */ + void startPacketTransfer(); - /** The file descriptor of the UIO driver */ - int fd; + /** + * @brief This function sends the config byte to the PTME IP Core to signal the end of a + * packet transfer. + */ + void endPacketTransfer(); - uint32_t* ptmeBaseAddress = nullptr; + /** + * @brief This function reads the papb busy signal indicating whether the PAPB interface is + * ready to receive more data or not. PAPB is ready when PAPB_Busy_N == '1'. + * + * @return RETURN_OK when ready to receive data else PAPB_BUSY. + */ + ReturnValue_t pollPapbBusySignal(); - /** - * @brief This function sends the config byte to the PTME IP Core to initiate a packet - * transfer. - */ - void startPacketTransfer(); + /** + * @brief This function can be used for debugging to check wheter there are packets in + * the packet buffer of the PTME or not. + */ + void isPtmeBufferEmpty(); - /** - * @brief This function sends the config byte to the PTME IP Core to signal the end of a - * packet transfer. - */ - void endPacketTransfer(); - - /** - * @brief This function reads the papb busy signal indicating whether the PAPB interface is - * ready to receive more data or not. PAPB is ready when PAPB_Busy_N == '1'. - * - * @return RETURN_OK when ready to receive data else PAPB_BUSY. - */ - ReturnValue_t pollPapbBusySignal(); - - /** - * @brief This function can be used for debugging to check wheter there are packets in - * the packet buffer of the PTME or not. - */ - void isPtmeBufferEmpty(); - - /** - * @brief This function sends a complete telemetry transfer frame data field (1105 bytes) - * to the input of the PTME IP Core. Can be used to test the implementation. - */ - ReturnValue_t sendTestFrame(); + /** + * @brief This function sends a complete telemetry transfer frame data field (1105 bytes) + * to the input of the PTME IP Core. Can be used to test the implementation. + */ + ReturnValue_t sendTestFrame(); }; #endif /* MISSION_OBC_CCSDSIPCOREBRIDGE_H_ */ diff --git a/linux/boardtest/I2cTestClass.cpp b/linux/boardtest/I2cTestClass.cpp index 66c16b33..090691e2 100644 --- a/linux/boardtest/I2cTestClass.cpp +++ b/linux/boardtest/I2cTestClass.cpp @@ -1,8 +1,5 @@ #include -I2cTestClass::I2cTestClass(object_id_t objectId): TestTask(objectId) { -} +I2cTestClass::I2cTestClass(object_id_t objectId) : TestTask(objectId) {} -ReturnValue_t I2cTestClass::performPeriodicAction() { - return HasReturnvaluesIF::RETURN_OK; -} +ReturnValue_t I2cTestClass::performPeriodicAction() { return HasReturnvaluesIF::RETURN_OK; } diff --git a/linux/boardtest/I2cTestClass.h b/linux/boardtest/I2cTestClass.h index 172a7f71..314f9dda 100644 --- a/linux/boardtest/I2cTestClass.h +++ b/linux/boardtest/I2cTestClass.h @@ -3,15 +3,13 @@ #include -class I2cTestClass: public TestTask { -public: - I2cTestClass(object_id_t objectId); +class I2cTestClass : public TestTask { + public: + I2cTestClass(object_id_t objectId); - ReturnValue_t performPeriodicAction() override; -private: + ReturnValue_t performPeriodicAction() override; + private: }; - - #endif /* LINUX_BOARDTEST_I2CTESTCLASS_H_ */ diff --git a/linux/boardtest/LibgpiodTest.cpp b/linux/boardtest/LibgpiodTest.cpp index 8eb9b536..0c5ebe2a 100644 --- a/linux/boardtest/LibgpiodTest.cpp +++ b/linux/boardtest/LibgpiodTest.cpp @@ -1,135 +1,127 @@ #include "LibgpiodTest.h" +#include +#include +#include + #include "devices/gpioIds.h" -#include -#include -#include - -LibgpiodTest::LibgpiodTest(object_id_t objectId, object_id_t gpioIfobjectId, - GpioCookie* gpioCookie): - TestTask(objectId) { - - gpioInterface = ObjectManager::instance()->get(gpioIfobjectId); - if (gpioInterface == nullptr) { - sif::error << "LibgpiodTest::LibgpiodTest: Invalid Gpio interface." << std::endl; - } - gpioInterface->addGpios(gpioCookie); - testCase = TestCases::BLINK; +LibgpiodTest::LibgpiodTest(object_id_t objectId, object_id_t gpioIfobjectId, GpioCookie* gpioCookie) + : TestTask(objectId) { + gpioInterface = ObjectManager::instance()->get(gpioIfobjectId); + if (gpioInterface == nullptr) { + sif::error << "LibgpiodTest::LibgpiodTest: Invalid Gpio interface." << std::endl; + } + gpioInterface->addGpios(gpioCookie); + testCase = TestCases::BLINK; } -LibgpiodTest::~LibgpiodTest() { -} +LibgpiodTest::~LibgpiodTest() {} ReturnValue_t LibgpiodTest::performPeriodicAction() { - int gpioState; - ReturnValue_t result; + int gpioState; + ReturnValue_t result; - switch(testCase) { - case(TestCases::READ): { - result = gpioInterface->readGpio(gpioIds::TEST_ID_0, &gpioState); - if (result != RETURN_OK) { - sif::warning << "LibgpiodTest::performPeriodicAction: Failed to read gpio " - << std::endl; - return RETURN_FAILED; - } - else { - sif::debug << "LibgpiodTest::performPeriodicAction: MIO 0 state = " << gpioState - << std::endl; - } - break; + switch (testCase) { + case (TestCases::READ): { + result = gpioInterface->readGpio(gpioIds::TEST_ID_0, &gpioState); + if (result != RETURN_OK) { + sif::warning << "LibgpiodTest::performPeriodicAction: Failed to read gpio " << std::endl; + return RETURN_FAILED; + } else { + sif::debug << "LibgpiodTest::performPeriodicAction: MIO 0 state = " << gpioState + << std::endl; + } + break; } - case(TestCases::LOOPBACK): { - break; + case (TestCases::LOOPBACK): { + break; } - case(TestCases::BLINK): { - result = gpioInterface->readGpio(gpioIds::TEST_ID_0, &gpioState); + case (TestCases::BLINK): { + result = gpioInterface->readGpio(gpioIds::TEST_ID_0, &gpioState); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "LibgpiodTest::performPeriodicAction: Failed to read gpio " << std::endl; + return RETURN_FAILED; + } + if (gpioState == 1) { + result = gpioInterface->pullLow(gpioIds::TEST_ID_0); if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "LibgpiodTest::performPeriodicAction: Failed to read gpio " - << std::endl; - return RETURN_FAILED; + sif::warning << "LibgpiodTest::performPeriodicAction: Could not pull GPIO low!" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; } - if (gpioState == 1) { - result = gpioInterface->pullLow(gpioIds::TEST_ID_0); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "LibgpiodTest::performPeriodicAction: Could not pull GPIO low!" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - } - else if (gpioState == 0) { - result = gpioInterface->pullHigh(gpioIds::TEST_ID_0); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "LibgpiodTest::performPeriodicAction: Could not pull GPIO high!" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - } - else { - sif::warning << "LibgpiodTest::performPeriodicAction: Invalid GPIO state" << std::endl; + } else if (gpioState == 0) { + result = gpioInterface->pullHigh(gpioIds::TEST_ID_0); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "LibgpiodTest::performPeriodicAction: Could not pull GPIO high!" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; } + } else { + sif::warning << "LibgpiodTest::performPeriodicAction: Invalid GPIO state" << std::endl; + } - break; + break; } default: - sif::debug << "LibgpiodTest::performPeriodicAction: Invalid test case" << std::endl; - break; - } + sif::debug << "LibgpiodTest::performPeriodicAction: Invalid test case" << std::endl; + break; + } - - return RETURN_OK; + return RETURN_OK; } ReturnValue_t LibgpiodTest::performOneShotAction() { - int gpioState; - ReturnValue_t result; + int gpioState; + ReturnValue_t result; - switch(testCase) { - case(TestCases::READ): { - break; + switch (testCase) { + case (TestCases::READ): { + break; } - case(TestCases::BLINK): { - break; + case (TestCases::BLINK): { + break; } - case(TestCases::LOOPBACK): { - result = gpioInterface->pullHigh(gpioIds::TEST_ID_0); - if(result == HasReturnvaluesIF::RETURN_OK) { - sif::info << "LibgpiodTest::performOneShotAction: " - "GPIO pulled high successfully for loopback test" << std::endl; - } - else { - sif::warning << "LibgpiodTest::performOneShotAction: Could not pull GPIO high!" - << std::endl; - return HasReturnvaluesIF::RETURN_OK; - } - result = gpioInterface->readGpio(gpioIds::TEST_ID_1, &gpioState); - if(result == HasReturnvaluesIF::RETURN_OK and gpioState == 1) { - sif::info << "LibgpiodTest::performOneShotAction: " - "GPIO state read successfully and is high" << std::endl; - } - else { - sif::warning << "LibgpiodTest::performOneShotAction: GPIO read and is not high!" - << std::endl; - return HasReturnvaluesIF::RETURN_OK; - } + case (TestCases::LOOPBACK): { + result = gpioInterface->pullHigh(gpioIds::TEST_ID_0); + if (result == HasReturnvaluesIF::RETURN_OK) { + sif::info << "LibgpiodTest::performOneShotAction: " + "GPIO pulled high successfully for loopback test" + << std::endl; + } else { + sif::warning << "LibgpiodTest::performOneShotAction: Could not pull GPIO high!" + << std::endl; + return HasReturnvaluesIF::RETURN_OK; + } + result = gpioInterface->readGpio(gpioIds::TEST_ID_1, &gpioState); + if (result == HasReturnvaluesIF::RETURN_OK and gpioState == 1) { + sif::info << "LibgpiodTest::performOneShotAction: " + "GPIO state read successfully and is high" + << std::endl; + } else { + sif::warning << "LibgpiodTest::performOneShotAction: GPIO read and is not high!" + << std::endl; + return HasReturnvaluesIF::RETURN_OK; + } - result = gpioInterface->pullLow(gpioIds::TEST_ID_0); - if(result == HasReturnvaluesIF::RETURN_OK) { - sif::info << "LibgpiodTest::performOneShotAction: " - "GPIO pulled low successfully for loopback test" << std::endl; - } - result = gpioInterface->readGpio(gpioIds::TEST_ID_1, &gpioState); - if(result == HasReturnvaluesIF::RETURN_OK and gpioState == 0) { - sif::info << "LibgpiodTest::performOneShotAction: " - "GPIO state read successfully and is low" << std::endl; - } - else { - sif::warning << "LibgpiodTest::performOneShotAction: GPIO read and is not low!" - << std::endl; - return HasReturnvaluesIF::RETURN_OK; - } - break; + result = gpioInterface->pullLow(gpioIds::TEST_ID_0); + if (result == HasReturnvaluesIF::RETURN_OK) { + sif::info << "LibgpiodTest::performOneShotAction: " + "GPIO pulled low successfully for loopback test" + << std::endl; + } + result = gpioInterface->readGpio(gpioIds::TEST_ID_1, &gpioState); + if (result == HasReturnvaluesIF::RETURN_OK and gpioState == 0) { + sif::info << "LibgpiodTest::performOneShotAction: " + "GPIO state read successfully and is low" + << std::endl; + } else { + sif::warning << "LibgpiodTest::performOneShotAction: GPIO read and is not low!" + << std::endl; + return HasReturnvaluesIF::RETURN_OK; + } + break; } - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } diff --git a/linux/boardtest/LibgpiodTest.h b/linux/boardtest/LibgpiodTest.h index 718d0209..4fcaffdf 100644 --- a/linux/boardtest/LibgpiodTest.h +++ b/linux/boardtest/LibgpiodTest.h @@ -1,34 +1,31 @@ #ifndef TEST_TESTTASKS_LIBGPIODTEST_H_ #define TEST_TESTTASKS_LIBGPIODTEST_H_ -#include "TestTask.h" -#include -#include #include +#include +#include + +#include "TestTask.h" /** * @brief Test for the GPIO read implementation of the LinuxLibgpioIF. * @author J. Meier */ -class LibgpiodTest: public TestTask { -public: - enum TestCases { - READ = 0, - LOOPBACK = 1, - BLINK - }; +class LibgpiodTest : public TestTask { + public: + enum TestCases { READ = 0, LOOPBACK = 1, BLINK }; - TestCases testCase; + TestCases testCase; - LibgpiodTest(object_id_t objectId, object_id_t gpioIfobjectId, GpioCookie* gpioCookie); - virtual ~LibgpiodTest(); + LibgpiodTest(object_id_t objectId, object_id_t gpioIfobjectId, GpioCookie* gpioCookie); + virtual ~LibgpiodTest(); -protected: - ReturnValue_t performOneShotAction() override; - ReturnValue_t performPeriodicAction() override; + protected: + ReturnValue_t performOneShotAction() override; + ReturnValue_t performPeriodicAction() override; -private: - GpioIF* gpioInterface; + private: + GpioIF* gpioInterface; }; #endif /* TEST_TESTTASKS_LIBGPIODTEST_H_ */ diff --git a/linux/boardtest/SpiTestClass.cpp b/linux/boardtest/SpiTestClass.cpp index 65f2ca9f..7ef76d95 100644 --- a/linux/boardtest/SpiTestClass.cpp +++ b/linux/boardtest/SpiTestClass.cpp @@ -1,503 +1,483 @@ #include "SpiTestClass.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + #include "devices/gpioIds.h" -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -SpiTestClass::SpiTestClass(object_id_t objectId, GpioIF* gpioIF): TestTask(objectId), -gpioIF(gpioIF) { - if(gpioIF == nullptr) { - sif::error << "SpiTestClass::SpiTestClass: Invalid GPIO ComIF!" << std::endl; - } - testMode = TestModes::MGM_LIS3MDL; - spiTransferStruct.rx_buf = reinterpret_cast<__u64>(recvBuffer.data()); - spiTransferStruct.tx_buf = reinterpret_cast<__u64>(sendBuffer.data()); +SpiTestClass::SpiTestClass(object_id_t objectId, GpioIF *gpioIF) + : TestTask(objectId), gpioIF(gpioIF) { + if (gpioIF == nullptr) { + sif::error << "SpiTestClass::SpiTestClass: Invalid GPIO ComIF!" << std::endl; + } + testMode = TestModes::MGM_LIS3MDL; + spiTransferStruct.rx_buf = reinterpret_cast<__u64>(recvBuffer.data()); + spiTransferStruct.tx_buf = reinterpret_cast<__u64>(sendBuffer.data()); } ReturnValue_t SpiTestClass::performOneShotAction() { - switch(testMode) { - case(TestModes::NONE): { - break; + switch (testMode) { + case (TestModes::NONE): { + break; } - case(TestModes::MGM_LIS3MDL): { - performLis3MdlTest(mgm0Lis3mdlChipSelect); - break; + case (TestModes::MGM_LIS3MDL): { + performLis3MdlTest(mgm0Lis3mdlChipSelect); + break; } - case(TestModes::MGM_RM3100): { - performRm3100Test(mgm1Rm3100ChipSelect); - break; + case (TestModes::MGM_RM3100): { + performRm3100Test(mgm1Rm3100ChipSelect); + break; } - case(TestModes::GYRO_L3GD20H): { - performL3gTest(gyro1L3gd20ChipSelect); - break; + case (TestModes::GYRO_L3GD20H): { + performL3gTest(gyro1L3gd20ChipSelect); + break; } - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t SpiTestClass::performPeriodicAction() { - return HasReturnvaluesIF::RETURN_OK; -} +ReturnValue_t SpiTestClass::performPeriodicAction() { return HasReturnvaluesIF::RETURN_OK; } void SpiTestClass::performRm3100Test(uint8_t mgmId) { - /* Configure all SPI chip selects and pull them high */ - acsInit(); + /* Configure all SPI chip selects and pull them high */ + acsInit(); - /* Adapt accordingly */ - if(mgmId != mgm1Rm3100ChipSelect and mgmId != mgm3Rm3100ChipSelect) { - sif::warning << "SpiTestClass::performRm3100Test: Invalid MGM ID!" << std::endl; - } - gpioId_t currentGpioId = 0; - uint8_t chipSelectPin = mgmId; - if(chipSelectPin == mgm1Rm3100ChipSelect) { - currentGpioId = gpioIds::MGM_1_RM3100_CS; - } - else { - currentGpioId = gpioIds::MGM_3_RM3100_CS; - } - uint32_t rm3100speed = 976'000; - uint8_t rm3100revidReg = 0x36; - spi::SpiModes rm3100mode = spi::SpiModes::MODE_3; + /* Adapt accordingly */ + if (mgmId != mgm1Rm3100ChipSelect and mgmId != mgm3Rm3100ChipSelect) { + sif::warning << "SpiTestClass::performRm3100Test: Invalid MGM ID!" << std::endl; + } + gpioId_t currentGpioId = 0; + uint8_t chipSelectPin = mgmId; + if (chipSelectPin == mgm1Rm3100ChipSelect) { + currentGpioId = gpioIds::MGM_1_RM3100_CS; + } else { + currentGpioId = gpioIds::MGM_3_RM3100_CS; + } + uint32_t rm3100speed = 976'000; + uint8_t rm3100revidReg = 0x36; + spi::SpiModes rm3100mode = spi::SpiModes::MODE_3; #ifdef RASPBERRY_PI - std::string deviceName = "/dev/spidev0.0"; + std::string deviceName = "/dev/spidev0.0"; #else - std::string deviceName = "/dev/spidev2.0"; + std::string deviceName = "/dev/spidev2.0"; #endif - int fileDescriptor = 0; + int fileDescriptor = 0; + UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR, "SpiComIF::initializeInterface"); + if (fileHelper.getOpenResult()) { + sif::error << "SpiTestClass::performRm3100Test: File descriptor could not be opened!" + << std::endl; + return; + } + setSpiSpeedAndMode(fileDescriptor, rm3100mode, rm3100speed); - UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR, - "SpiComIF::initializeInterface"); - if(fileHelper.getOpenResult()) { - sif::error << "SpiTestClass::performRm3100Test: File descriptor could not be opened!" - << std::endl; - return; - } - setSpiSpeedAndMode(fileDescriptor, rm3100mode, rm3100speed); + uint8_t revId = readRegister(fileDescriptor, currentGpioId, rm3100revidReg); + sif::info << "SpiTestClass::performRm3100Test: Revision ID 0b" << std::bitset<8>(revId) + << std::endl; - uint8_t revId = readRegister(fileDescriptor, currentGpioId, rm3100revidReg); - sif::info << "SpiTestClass::performRm3100Test: Revision ID 0b" << std::bitset<8>(revId) << - std::endl; + /* Write configuration to CMM register */ + writeRegister(fileDescriptor, currentGpioId, 0x01, 0x75); + uint8_t cmmRegister = readRm3100Register(fileDescriptor, currentGpioId, 0x01); + sif::info << "SpiTestClass::performRm3100Test: CMM register value: " << std::hex << "0x" + << static_cast(cmmRegister) << std::dec << std::endl; - /* Write configuration to CMM register */ - writeRegister(fileDescriptor, currentGpioId, 0x01, 0x75); - uint8_t cmmRegister = readRm3100Register(fileDescriptor , currentGpioId, 0x01); - sif::info << "SpiTestClass::performRm3100Test: CMM register value: " << - std::hex << "0x" << static_cast(cmmRegister) << std::dec << std::endl; + /* Read the cycle count registers */ + uint8_t cycleCountsRaw[6]; + readMultipleRegisters(fileDescriptor, currentGpioId, 0x04, cycleCountsRaw, 6); - /* Read the cycle count registers */ - uint8_t cycleCountsRaw[6]; - readMultipleRegisters(fileDescriptor, currentGpioId, 0x04, cycleCountsRaw, 6); + uint16_t cycleCountX = cycleCountsRaw[0] << 8 | cycleCountsRaw[1]; + uint16_t cycleCountY = cycleCountsRaw[2] << 8 | cycleCountsRaw[3]; + uint16_t cycleCountZ = cycleCountsRaw[4] << 8 | cycleCountsRaw[5]; - uint16_t cycleCountX = cycleCountsRaw[0] << 8 | cycleCountsRaw[1]; - uint16_t cycleCountY = cycleCountsRaw[2] << 8 | cycleCountsRaw[3]; - uint16_t cycleCountZ = cycleCountsRaw[4] << 8 | cycleCountsRaw[5]; + sif::info << "Cycle count X: " << cycleCountX << std::endl; + sif::info << "Cycle count Y: " << cycleCountY << std::endl; + sif::info << "Cycle count z: " << cycleCountZ << std::endl; - sif::info << "Cycle count X: " << cycleCountX << std::endl; - sif::info << "Cycle count Y: " << cycleCountY << std::endl; - sif::info << "Cycle count z: " << cycleCountZ << std::endl; - - writeRegister(fileDescriptor, currentGpioId, 0x0B, 0x96); - uint8_t tmrcReg = readRm3100Register(fileDescriptor, currentGpioId, 0x0B); - sif::info << "SpiTestClass::performRm3100Test: TMRC register value: " << - std::hex << "0x" << static_cast(tmrcReg) << std::dec << std::endl; + writeRegister(fileDescriptor, currentGpioId, 0x0B, 0x96); + uint8_t tmrcReg = readRm3100Register(fileDescriptor, currentGpioId, 0x0B); + sif::info << "SpiTestClass::performRm3100Test: TMRC register value: " << std::hex << "0x" + << static_cast(tmrcReg) << std::dec << std::endl; + TaskFactory::delayTask(10); + uint8_t statusReg = readRm3100Register(fileDescriptor, currentGpioId, 0x34); + sif::info << "SpiTestClass::performRm3100Test: Status Register 0b" << std::bitset<8>(statusReg) + << std::endl; + /* This means that data is not ready */ + if ((statusReg & 0b1000'0000) == 0) { + sif::warning << "SpiTestClass::performRm3100Test: Data not ready!" << std::endl; TaskFactory::delayTask(10); uint8_t statusReg = readRm3100Register(fileDescriptor, currentGpioId, 0x34); - sif::info << "SpiTestClass::performRm3100Test: Status Register 0b" << - std::bitset<8>(statusReg) << std::endl; - /* This means that data is not ready */ - if((statusReg & 0b1000'0000) == 0) { - sif::warning << "SpiTestClass::performRm3100Test: Data not ready!" << std::endl; - TaskFactory::delayTask(10); - uint8_t statusReg = readRm3100Register(fileDescriptor, currentGpioId, 0x34); - if((statusReg & 0b1000'0000) == 0) { - return; - } + if ((statusReg & 0b1000'0000) == 0) { + return; } + } - uint32_t rm3100DefaultCycleCout = 0xC8; - /* Gain scales lineary with cycle count and is 38 for cycle count 100 */ - float rm3100Gain = rm3100DefaultCycleCout / 100.0 * 38.0; - float scaleFactor = 1 / rm3100Gain; - uint8_t rawValues[9]; - readMultipleRegisters(fileDescriptor, currentGpioId, 0x24, rawValues, 9); + uint32_t rm3100DefaultCycleCout = 0xC8; + /* Gain scales lineary with cycle count and is 38 for cycle count 100 */ + float rm3100Gain = rm3100DefaultCycleCout / 100.0 * 38.0; + float scaleFactor = 1 / rm3100Gain; + uint8_t rawValues[9]; + readMultipleRegisters(fileDescriptor, currentGpioId, 0x24, rawValues, 9); - /* The sensor generates 24 bit signed values */ - int32_t rawX = ((rawValues[0] << 24) | (rawValues[1] << 16) | (rawValues[2] << 8)) >> 8; - int32_t rawY = ((rawValues[3] << 24) | (rawValues[4] << 16) | (rawValues[5] << 8)) >> 8; - int32_t rawZ = ((rawValues[6] << 24) | (rawValues[7] << 16) | (rawValues[8] << 8)) >> 8; + /* The sensor generates 24 bit signed values */ + int32_t rawX = ((rawValues[0] << 24) | (rawValues[1] << 16) | (rawValues[2] << 8)) >> 8; + int32_t rawY = ((rawValues[3] << 24) | (rawValues[4] << 16) | (rawValues[5] << 8)) >> 8; + int32_t rawZ = ((rawValues[6] << 24) | (rawValues[7] << 16) | (rawValues[8] << 8)) >> 8; - float fieldStrengthX = rawX * scaleFactor; - float fieldStrengthY = rawY * scaleFactor; - float fieldStrengthZ = rawZ * scaleFactor; + float fieldStrengthX = rawX * scaleFactor; + float fieldStrengthY = rawY * scaleFactor; + float fieldStrengthZ = rawZ * scaleFactor; - sif::info << "RM3100 measured field strengths in microtesla:" << std::endl; - sif::info << "Field Strength X: " << fieldStrengthX << " uT" << std::endl; - sif::info << "Field Strength Y: " << fieldStrengthY << " uT" << std::endl; - sif::info << "Field Strength Z: " << fieldStrengthZ << " uT" << std::endl; + sif::info << "RM3100 measured field strengths in microtesla:" << std::endl; + sif::info << "Field Strength X: " << fieldStrengthX << " uT" << std::endl; + sif::info << "Field Strength Y: " << fieldStrengthY << " uT" << std::endl; + sif::info << "Field Strength Z: " << fieldStrengthZ << " uT" << std::endl; } void SpiTestClass::performLis3MdlTest(uint8_t lis3Id) { - /* Configure all SPI chip selects and pull them high */ - acsInit(); + /* Configure all SPI chip selects and pull them high */ + acsInit(); - /* Adapt accordingly */ - if(lis3Id != mgm0Lis3mdlChipSelect and lis3Id != mgm2Lis3mdlChipSelect) { - sif::warning << "SpiTestClass::performLis3MdlTest: Invalid MGM ID!" << std::endl; - } - gpioId_t currentGpioId = 0; - uint8_t chipSelectPin = lis3Id; - uint8_t whoAmIReg = 0b0000'1111; - uint8_t whoAmIRegExpectedVal = 0b0011'1101; - if(chipSelectPin == mgm0Lis3mdlChipSelect) { - currentGpioId = gpioIds::MGM_0_LIS3_CS; - } - else { - currentGpioId = gpioIds::MGM_2_LIS3_CS; - } - uint32_t spiSpeed = 10'000'000; - spi::SpiModes spiMode = spi::SpiModes::MODE_0; + /* Adapt accordingly */ + if (lis3Id != mgm0Lis3mdlChipSelect and lis3Id != mgm2Lis3mdlChipSelect) { + sif::warning << "SpiTestClass::performLis3MdlTest: Invalid MGM ID!" << std::endl; + } + gpioId_t currentGpioId = 0; + uint8_t chipSelectPin = lis3Id; + uint8_t whoAmIReg = 0b0000'1111; + uint8_t whoAmIRegExpectedVal = 0b0011'1101; + if (chipSelectPin == mgm0Lis3mdlChipSelect) { + currentGpioId = gpioIds::MGM_0_LIS3_CS; + } else { + currentGpioId = gpioIds::MGM_2_LIS3_CS; + } + uint32_t spiSpeed = 10'000'000; + spi::SpiModes spiMode = spi::SpiModes::MODE_0; #ifdef RASPBERRY_PI - std::string deviceName = "/dev/spidev0.0"; + std::string deviceName = "/dev/spidev0.0"; #else - std::string deviceName = "/dev/spidev2.0"; + std::string deviceName = "/dev/spidev2.0"; #endif - int fileDescriptor = 0; + int fileDescriptor = 0; - UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR, - "SpiComIF::initializeInterface"); - if(fileHelper.getOpenResult()) { - sif::error << "SpiTestClass::performLis3Mdl3100Test: File descriptor could not be opened!" - << std::endl; - return; - } - setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); - spiTransferStruct.delay_usecs = 0; - - uint8_t whoAmIRegVal = readStmRegister(fileDescriptor, currentGpioId, whoAmIReg, false); - sif::info << "SpiTestClass::performLis3MdlTest: WHO AM I register 0b" << - std::bitset<8>(whoAmIRegVal) << std::endl; - if(whoAmIRegVal != whoAmIRegExpectedVal) { - sif::warning << "SpiTestClass::performLis3MdlTest: WHO AM I register invalid!" - << std::endl; - } + UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR, "SpiComIF::initializeInterface"); + if (fileHelper.getOpenResult()) { + sif::error << "SpiTestClass::performLis3Mdl3100Test: File descriptor could not be opened!" + << std::endl; + return; + } + setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); + spiTransferStruct.delay_usecs = 0; + uint8_t whoAmIRegVal = readStmRegister(fileDescriptor, currentGpioId, whoAmIReg, false); + sif::info << "SpiTestClass::performLis3MdlTest: WHO AM I register 0b" + << std::bitset<8>(whoAmIRegVal) << std::endl; + if (whoAmIRegVal != whoAmIRegExpectedVal) { + sif::warning << "SpiTestClass::performLis3MdlTest: WHO AM I register invalid!" << std::endl; + } } - void SpiTestClass::performL3gTest(uint8_t l3gId) { - /* Configure all SPI chip selects and pull them high */ - acsInit(); + /* Configure all SPI chip selects and pull them high */ + acsInit(); - gpioId_t currentGpioId = 0; - uint8_t chipSelectPin = l3gId; - uint8_t whoAmIReg = 0b0000'1111; - uint8_t whoAmIRegExpectedVal = 0b1101'0111; + gpioId_t currentGpioId = 0; + uint8_t chipSelectPin = l3gId; + uint8_t whoAmIReg = 0b0000'1111; + uint8_t whoAmIRegExpectedVal = 0b1101'0111; - if(chipSelectPin == gyro1L3gd20ChipSelect) { - currentGpioId = gpioIds::GYRO_1_L3G_CS; - } - else { - currentGpioId = gpioIds::GYRO_3_L3G_CS; - } - uint32_t spiSpeed = 3'900'000; - spi::SpiModes spiMode = spi::SpiModes::MODE_3; + if (chipSelectPin == gyro1L3gd20ChipSelect) { + currentGpioId = gpioIds::GYRO_1_L3G_CS; + } else { + currentGpioId = gpioIds::GYRO_3_L3G_CS; + } + uint32_t spiSpeed = 3'900'000; + spi::SpiModes spiMode = spi::SpiModes::MODE_3; #ifdef RASPBERRY_PI - std::string deviceName = "/dev/spidev0.0"; + std::string deviceName = "/dev/spidev0.0"; #else - std::string deviceName = "/dev/spidev2.0"; + std::string deviceName = "/dev/spidev2.0"; #endif - int fileDescriptor = 0; + int fileDescriptor = 0; - UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR, - "SpiComIF::initializeInterface"); - if(fileHelper.getOpenResult()) { - sif::error << "SpiTestClass::performLis3Mdl3100Test: File descriptor could not be opened!" - << std::endl; - return; - } - setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); - uint8_t whoAmIRegVal = readStmRegister(fileDescriptor, currentGpioId, whoAmIReg, false); - sif::info << "SpiTestClass::performLis3MdlTest: WHO AM I register 0b" << - std::bitset<8>(whoAmIRegVal) << std::endl; - if(whoAmIRegVal != whoAmIRegExpectedVal) { - sif::warning << "SpiTestClass::performL3gTest: Read WHO AM I register invalid!" << - std::endl; + UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR, "SpiComIF::initializeInterface"); + if (fileHelper.getOpenResult()) { + sif::error << "SpiTestClass::performLis3Mdl3100Test: File descriptor could not be opened!" + << std::endl; + return; + } + setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); + uint8_t whoAmIRegVal = readStmRegister(fileDescriptor, currentGpioId, whoAmIReg, false); + sif::info << "SpiTestClass::performLis3MdlTest: WHO AM I register 0b" + << std::bitset<8>(whoAmIRegVal) << std::endl; + if (whoAmIRegVal != whoAmIRegExpectedVal) { + sif::warning << "SpiTestClass::performL3gTest: Read WHO AM I register invalid!" << std::endl; + } + + uint8_t ctrlReg1Addr = 0b0010'0000; + { + uint8_t commandRegs[5]; + commandRegs[0] = 0b0000'1111; + commandRegs[1] = 0x0; + commandRegs[2] = 0x0; + /* Configure big endian data format */ + commandRegs[3] = 0b0100'0000; + commandRegs[4] = 0x0; + writeMultipleStmRegisters(fileDescriptor, currentGpioId, ctrlReg1Addr, commandRegs, + sizeof(commandRegs)); + uint8_t readRegs[5]; + readMultipleRegisters(fileDescriptor, currentGpioId, ctrlReg1Addr, readRegs, sizeof(readRegs)); + for (uint8_t idx = 0; idx < sizeof(readRegs); idx++) { + if (readRegs[idx] != commandRegs[0]) { + sif::warning << "SpiTestClass::performL3gTest: Read control register " + << static_cast(idx + 1) << " not equal to configured value" << std::endl; + } } + } - uint8_t ctrlReg1Addr = 0b0010'0000; - { - uint8_t commandRegs[5]; - commandRegs[0] = 0b0000'1111; - commandRegs[1] = 0x0; - commandRegs[2] = 0x0; - /* Configure big endian data format */ - commandRegs[3] = 0b0100'0000; - commandRegs[4] = 0x0; - writeMultipleStmRegisters(fileDescriptor, currentGpioId, ctrlReg1Addr, commandRegs, - sizeof(commandRegs)); - uint8_t readRegs[5]; - readMultipleRegisters(fileDescriptor, currentGpioId, ctrlReg1Addr, readRegs, - sizeof(readRegs)); - for(uint8_t idx = 0; idx < sizeof(readRegs); idx++) { - if(readRegs[idx] != commandRegs[0]) { - sif::warning << "SpiTestClass::performL3gTest: Read control register " << - static_cast(idx + 1) << " not equal to configured value" << std::endl; - } - } - } + uint8_t readOutBuffer[14]; + readMultipleStmRegisters(fileDescriptor, currentGpioId, ctrlReg1Addr, readOutBuffer, + sizeof(readOutBuffer)); - uint8_t readOutBuffer[14]; - readMultipleStmRegisters(fileDescriptor, currentGpioId, ctrlReg1Addr, readOutBuffer, - sizeof(readOutBuffer)); + uint8_t statusReg = readOutBuffer[7]; + sif::info << "SpiTestClass::performL3gTest: Status Register 0b" << std::bitset<8>(statusReg) + << std::endl; - uint8_t statusReg = readOutBuffer[7]; - sif::info << "SpiTestClass::performL3gTest: Status Register 0b" << - std::bitset<8>(statusReg) << std::endl; + uint16_t l3gRange = 245; + float scaleFactor = static_cast(l3gRange) / INT16_MAX; + /* The sensor spits out little endian */ + int16_t angVelocRawX = (readOutBuffer[8] << 8) | readOutBuffer[9]; + int16_t angVelocRawY = (readOutBuffer[10] << 8) | readOutBuffer[11]; + int16_t angVelocRawZ = (readOutBuffer[12] << 8) | readOutBuffer[13]; - uint16_t l3gRange = 245; - float scaleFactor = static_cast(l3gRange) / INT16_MAX; - /* The sensor spits out little endian */ - int16_t angVelocRawX = (readOutBuffer[8] << 8) | readOutBuffer[9]; - int16_t angVelocRawY = (readOutBuffer[10] << 8) | readOutBuffer[11]; - int16_t angVelocRawZ = (readOutBuffer[12] << 8) | readOutBuffer[13]; - - float angVelocX = scaleFactor * angVelocRawX; - float angVelocY = scaleFactor * angVelocRawY; - float angVelocZ = scaleFactor * angVelocRawZ; - - sif::info << "Angular velocities for the L3GD20H in degrees per second:" << std::endl; - sif::info << "X: " << angVelocX << std::endl; - sif::info << "Y: " << angVelocY << std::endl; - sif::info << "Z: " << angVelocZ << std::endl; + float angVelocX = scaleFactor * angVelocRawX; + float angVelocY = scaleFactor * angVelocRawY; + float angVelocZ = scaleFactor * angVelocRawZ; + sif::info << "Angular velocities for the L3GD20H in degrees per second:" << std::endl; + sif::info << "X: " << angVelocX << std::endl; + sif::info << "Y: " << angVelocY << std::endl; + sif::info << "Z: " << angVelocZ << std::endl; } void SpiTestClass::acsInit() { - GpioCookie* gpioCookie = new GpioCookie(); + GpioCookie *gpioCookie = new GpioCookie(); #ifdef RASPBERRY_PI - GpiodRegularByChip* gpio = nullptr; - std::string rpiGpioName = "gpiochip0"; - gpio = new GpiodRegularByChip(rpiGpioName, mgm0Lis3mdlChipSelect, "MGM_0_LIS3", - gpio::DIR_OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); + GpiodRegularByChip *gpio = nullptr; + std::string rpiGpioName = "gpiochip0"; + gpio = new GpiodRegularByChip(rpiGpioName, mgm0Lis3mdlChipSelect, "MGM_0_LIS3", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); - gpio = new GpiodRegularByChip(rpiGpioName, mgm1Rm3100ChipSelect, "MGM_1_RM3100", - gpio::DIR_OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); + gpio = new GpiodRegularByChip(rpiGpioName, mgm1Rm3100ChipSelect, "MGM_1_RM3100", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); - gpio = new GpiodRegularByChip(rpiGpioName, gyro0AdisChipSelect, "GYRO_0_ADIS", - gpio::DIR_OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); + gpio = new GpiodRegularByChip(rpiGpioName, gyro0AdisChipSelect, "GYRO_0_ADIS", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); - gpio = new GpiodRegularByChip(rpiGpioName, gyro1L3gd20ChipSelect, "GYRO_1_L3G", - gpio::DIR_OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); + gpio = new GpiodRegularByChip(rpiGpioName, gyro1L3gd20ChipSelect, "GYRO_1_L3G", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); - gpio = new GpiodRegularByChip(rpiGpioName, gyro3L3gd20ChipSelect, "GYRO_2_L3G", - gpio::DIR_OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); + gpio = new GpiodRegularByChip(rpiGpioName, gyro3L3gd20ChipSelect, "GYRO_2_L3G", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); - gpio = new GpiodRegularByChip(rpiGpioName, mgm2Lis3mdlChipSelect, "MGM_2_LIS3", - gpio::DIR_OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); + gpio = new GpiodRegularByChip(rpiGpioName, mgm2Lis3mdlChipSelect, "MGM_2_LIS3", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); - gpio = new GpiodRegularByChip(rpiGpioName, mgm3Rm3100ChipSelect, "MGM_3_RM3100", - gpio::DIR_OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); + gpio = new GpiodRegularByChip(rpiGpioName, mgm3Rm3100ChipSelect, "MGM_3_RM3100", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); #elif defined(XIPHOS_Q7S) - GpiodRegularByLineName* gpio = nullptr; - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_0_CS, "MGM_0_LIS3", gpio::DIR_OUT, - gpio::HIGH); - gpioCookie->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, "MGM_1_RM3100", gpio::DIR_OUT, - gpio::HIGH); - gpioCookie->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_2_CS, "MGM_2_LIS3", gpio::DIR_OUT, - gpio::HIGH); - gpioCookie->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, "MGM_3_RM3100", gpio::DIR_OUT, - gpio::HIGH); - gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); + GpiodRegularByLineName *gpio = nullptr; + gpio = + new GpiodRegularByLineName(q7s::gpioNames::MGM_0_CS, "MGM_0_LIS3", gpio::DIR_OUT, gpio::HIGH); + gpioCookie->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, "MGM_1_RM3100", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); + gpio = + new GpiodRegularByLineName(q7s::gpioNames::MGM_2_CS, "MGM_2_LIS3", gpio::DIR_OUT, gpio::HIGH); + gpioCookie->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, "MGM_3_RM3100", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ADIS_CS, "GYRO_0_ADIS", - gpio::DIR_OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_1_L3G_CS, "GYRO_1_L3G", gpio::DIR_OUT, - gpio::HIGH); - gpioCookie->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ADIS_CS, "GYRO_2_ADIS", - gpio::DIR_OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::GYRO_2_ADIS_CS, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_3_L3G_CS, "GYRO_3_L3G", gpio::DIR_OUT, - gpio::HIGH); - gpioCookie->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ADIS_CS, "GYRO_0_ADIS", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_1_L3G_CS, "GYRO_1_L3G", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ADIS_CS, "GYRO_2_ADIS", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::GYRO_2_ADIS_CS, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_3_L3G_CS, "GYRO_3_L3G", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); - // Enable pins must be pulled low for regular operations - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, "GYRO_0_ENABLE", gpio::DIR_OUT, - gpio::LOW); - gpioCookie->addGpio(gpioIds::GYRO_0_ENABLE, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, "GYRO_2_ENABLE", gpio::DIR_OUT, - gpio::LOW); - gpioCookie->addGpio(gpioIds::GYRO_2_ENABLE, gpio); + // Enable pins must be pulled low for regular operations + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, "GYRO_0_ENABLE", gpio::DIR_OUT, + gpio::LOW); + gpioCookie->addGpio(gpioIds::GYRO_0_ENABLE, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, "GYRO_2_ENABLE", gpio::DIR_OUT, + gpio::LOW); + gpioCookie->addGpio(gpioIds::GYRO_2_ENABLE, gpio); #endif - if (gpioIF != nullptr) { - gpioIF->addGpios(gpioCookie); - } + if (gpioIF != nullptr) { + gpioIF->addGpios(gpioCookie); + } } void SpiTestClass::setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed) { - int mode_test = SPI_MODE_3; - int retval = ioctl(spiFd, SPI_IOC_WR_MODE, &mode_test);//reinterpret_cast(&mode)); - if(retval != 0) { - utility::handleIoctlError("SpiTestClass::performRm3100Test: Setting SPI mode failed!"); - } + int mode_test = SPI_MODE_3; + int retval = ioctl(spiFd, SPI_IOC_WR_MODE, &mode_test); // reinterpret_cast(&mode)); + if (retval != 0) { + utility::handleIoctlError("SpiTestClass::performRm3100Test: Setting SPI mode failed!"); + } - retval = ioctl(spiFd, SPI_IOC_WR_MAX_SPEED_HZ, &speed); - if(retval != 0) { - utility::handleIoctlError("SpiTestClass::performRm3100Test: Setting SPI speed failed!"); - } + retval = ioctl(spiFd, SPI_IOC_WR_MAX_SPEED_HZ, &speed); + if (retval != 0) { + utility::handleIoctlError("SpiTestClass::performRm3100Test: Setting SPI speed failed!"); + } } void SpiTestClass::writeRegister(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t value) { - spiTransferStruct.len = 2; - sendBuffer[0] = reg; - sendBuffer[1] = value; + spiTransferStruct.len = 2; + sendBuffer[0] = reg; + sendBuffer[1] = value; - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullLow(chipSelect); - } - int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); - if(retval < 0) { - utility::handleIoctlError("SpiTestClass::writeRegister: Write failed"); - } - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullHigh(chipSelect); - } + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullLow(chipSelect); + } + int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); + if (retval < 0) { + utility::handleIoctlError("SpiTestClass::writeRegister: Write failed"); + } + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullHigh(chipSelect); + } } void SpiTestClass::writeStmRegister(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t value, - bool autoIncrement) { - if(autoIncrement) { - reg |= STM_AUTO_INCR_MASK; - } - writeRegister(fd, chipSelect, reg, value); + bool autoIncrement) { + if (autoIncrement) { + reg |= STM_AUTO_INCR_MASK; + } + writeRegister(fd, chipSelect, reg, value); } void SpiTestClass::writeMultipleStmRegisters(int fd, gpioId_t chipSelect, uint8_t reg, - uint8_t *values, size_t len) { - if(values == nullptr) { - return; - } - - reg |= STM_AUTO_INCR_MASK; - /* Clear read mask */ - reg &= ~STM_READ_MASK; - writeMultipleRegisters(fd, chipSelect, reg, values, len); + uint8_t *values, size_t len) { + if (values == nullptr) { + return; + } + reg |= STM_AUTO_INCR_MASK; + /* Clear read mask */ + reg &= ~STM_READ_MASK; + writeMultipleRegisters(fd, chipSelect, reg, values, len); } -void SpiTestClass::writeMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg, - uint8_t *values, size_t len) { - if(values == nullptr) { - return; - } +void SpiTestClass::writeMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t *values, + size_t len) { + if (values == nullptr) { + return; + } - sendBuffer[0] = reg; - std::memcpy(sendBuffer.data() + 1, values, len); - spiTransferStruct.len = len + 1; + sendBuffer[0] = reg; + std::memcpy(sendBuffer.data() + 1, values, len); + spiTransferStruct.len = len + 1; - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullLow(chipSelect); - } - int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); - if(retval < 0) { - utility::handleIoctlError("SpiTestClass::readRegister: Read failed"); - } - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullHigh(chipSelect); - } + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullLow(chipSelect); + } + int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); + if (retval < 0) { + utility::handleIoctlError("SpiTestClass::readRegister: Read failed"); + } + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullHigh(chipSelect); + } } uint8_t SpiTestClass::readRm3100Register(int fd, gpioId_t chipSelect, uint8_t reg) { - return readStmRegister(fd, chipSelect, reg, false); + return readStmRegister(fd, chipSelect, reg, false); } - -void SpiTestClass::readMultipleStmRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t *reply, - size_t len) { - reg |= STM_AUTO_INCR_MASK; - readMultipleRegisters(fd, chipSelect, reg, reply, len); +void SpiTestClass::readMultipleStmRegisters(int fd, gpioId_t chipSelect, uint8_t reg, + uint8_t *reply, size_t len) { + reg |= STM_AUTO_INCR_MASK; + readMultipleRegisters(fd, chipSelect, reg, reply, len); } void SpiTestClass::readMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t *reply, - size_t len) { - if(reply == nullptr) { - return; - } + size_t len) { + if (reply == nullptr) { + return; + } - spiTransferStruct.len = len + 1; - sendBuffer[0] = reg | STM_READ_MASK; + spiTransferStruct.len = len + 1; + sendBuffer[0] = reg | STM_READ_MASK; - for(uint8_t idx = 0; idx < len ; idx ++) { - sendBuffer[idx + 1] = 0; - } + for (uint8_t idx = 0; idx < len; idx++) { + sendBuffer[idx + 1] = 0; + } - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullLow(chipSelect); - } - int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); - if(retval < 0) { - utility::handleIoctlError("SpiTestClass::readRegister: Read failed"); - } - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullHigh(chipSelect); - } - std::memcpy(reply, recvBuffer.data() + 1, len); + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullLow(chipSelect); + } + int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); + if (retval < 0) { + utility::handleIoctlError("SpiTestClass::readRegister: Read failed"); + } + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullHigh(chipSelect); + } + std::memcpy(reply, recvBuffer.data() + 1, len); } uint8_t SpiTestClass::readStmRegister(int fd, gpioId_t chipSelect, uint8_t reg, - bool autoIncrement) { - reg |= STM_READ_MASK; - if(autoIncrement) { - reg |= STM_AUTO_INCR_MASK; - } - return readRegister(fd, chipSelect, reg); + bool autoIncrement) { + reg |= STM_READ_MASK; + if (autoIncrement) { + reg |= STM_AUTO_INCR_MASK; + } + return readRegister(fd, chipSelect, reg); } - uint8_t SpiTestClass::readRegister(int fd, gpioId_t chipSelect, uint8_t reg) { - spiTransferStruct.len = 2; - sendBuffer[0] = reg; - sendBuffer[1] = 0; + spiTransferStruct.len = 2; + sendBuffer[0] = reg; + sendBuffer[1] = 0; - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullLow(chipSelect); - } - int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); - if(retval < 0) { - utility::handleIoctlError("SpiTestClass::readRegister: Read failed"); - } - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullHigh(chipSelect); - } - return recvBuffer[1]; + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullLow(chipSelect); + } + int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); + if (retval < 0) { + utility::handleIoctlError("SpiTestClass::readRegister: Read failed"); + } + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullHigh(chipSelect); + } + return recvBuffer[1]; } diff --git a/linux/boardtest/SpiTestClass.h b/linux/boardtest/SpiTestClass.h index ffd56dd1..5df8cafb 100644 --- a/linux/boardtest/SpiTestClass.h +++ b/linux/boardtest/SpiTestClass.h @@ -13,83 +13,78 @@ #include -class SpiTestClass: public TestTask { -public: - enum TestModes { - NONE, - MGM_LIS3MDL, - MGM_RM3100, - GYRO_L3GD20H, - }; +class SpiTestClass : public TestTask { + public: + enum TestModes { + NONE, + MGM_LIS3MDL, + MGM_RM3100, + GYRO_L3GD20H, + }; - TestModes testMode; + TestModes testMode; - SpiTestClass(object_id_t objectId, GpioIF* gpioIF); + SpiTestClass(object_id_t objectId, GpioIF* gpioIF); - ReturnValue_t performOneShotAction() override; - ReturnValue_t performPeriodicAction() override; -private: + ReturnValue_t performOneShotAction() override; + ReturnValue_t performPeriodicAction() override; - GpioIF* gpioIF; + private: + GpioIF* gpioIF; - std::array recvBuffer; - std::array sendBuffer; - struct spi_ioc_transfer spiTransferStruct = {}; + std::array recvBuffer; + std::array sendBuffer; + struct spi_ioc_transfer spiTransferStruct = {}; - void performRm3100Test(uint8_t mgmId); - void performLis3MdlTest(uint8_t lis3Id); - void performL3gTest(uint8_t l3gId); + void performRm3100Test(uint8_t mgmId); + void performLis3MdlTest(uint8_t lis3Id); + void performL3gTest(uint8_t l3gId); - /* ACS board specific code which pulls all GPIOs high */ - void acsInit(); + /* ACS board specific code which pulls all GPIOs high */ + void acsInit(); - /* ACS board specific variables */ + /* ACS board specific variables */ #ifdef RASPBERRY_PI - uint8_t mgm0Lis3mdlChipSelect = gpio::MGM_0_BCM_PIN; - uint8_t mgm1Rm3100ChipSelect = gpio::MGM_1_BCM_PIN; - uint8_t mgm2Lis3mdlChipSelect = gpio::MGM_2_BCM_PIN; - uint8_t mgm3Rm3100ChipSelect = gpio::MGM_3_BCM_PIN; + uint8_t mgm0Lis3mdlChipSelect = gpio::MGM_0_BCM_PIN; + uint8_t mgm1Rm3100ChipSelect = gpio::MGM_1_BCM_PIN; + uint8_t mgm2Lis3mdlChipSelect = gpio::MGM_2_BCM_PIN; + uint8_t mgm3Rm3100ChipSelect = gpio::MGM_3_BCM_PIN; - uint8_t gyro0AdisChipSelect = gpio::GYRO_0_BCM_PIN; - uint8_t gyro1L3gd20ChipSelect = gpio::GYRO_1_BCM_PIN; - uint8_t gyro2AdisChipSelect = gpio::GYRO_2_BCM_PIN; - uint8_t gyro3L3gd20ChipSelect = gpio::GYRO_3_BCM_PIN; + uint8_t gyro0AdisChipSelect = gpio::GYRO_0_BCM_PIN; + uint8_t gyro1L3gd20ChipSelect = gpio::GYRO_1_BCM_PIN; + uint8_t gyro2AdisChipSelect = gpio::GYRO_2_BCM_PIN; + uint8_t gyro3L3gd20ChipSelect = gpio::GYRO_3_BCM_PIN; #else - uint8_t mgm0Lis3mdlChipSelect = 0; - uint8_t mgm1Rm3100ChipSelect = 0; - uint8_t gyro0AdisResetLine = 0; - uint8_t gyro0AdisChipSelect = 0; - uint8_t gyro1L3gd20ChipSelect = 0; - uint8_t gyro2L3gd20ChipSelect = 0; - uint8_t mgm2Lis3mdlChipSelect = 0; - uint8_t mgm3Rm3100ChipSelect = 0; + uint8_t mgm0Lis3mdlChipSelect = 0; + uint8_t mgm1Rm3100ChipSelect = 0; + uint8_t gyro0AdisResetLine = 0; + uint8_t gyro0AdisChipSelect = 0; + uint8_t gyro1L3gd20ChipSelect = 0; + uint8_t gyro2L3gd20ChipSelect = 0; + uint8_t mgm2Lis3mdlChipSelect = 0; + uint8_t mgm3Rm3100ChipSelect = 0; #endif - static constexpr uint8_t STM_READ_MASK = 0b1000'0000; - static constexpr uint8_t RM3100_READ_MASK = STM_READ_MASK; - static constexpr uint8_t STM_AUTO_INCR_MASK = 0b0100'0000; + static constexpr uint8_t STM_READ_MASK = 0b1000'0000; + static constexpr uint8_t RM3100_READ_MASK = STM_READ_MASK; + static constexpr uint8_t STM_AUTO_INCR_MASK = 0b0100'0000; - void setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed); + void setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed); - void writeStmRegister(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t value, - bool autoIncrement); - void writeMultipleStmRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t* values, - size_t len); - void writeMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t *values, - size_t len); - void writeRegister(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t value); - - uint8_t readRm3100Register(int fd, gpioId_t chipSelect, uint8_t reg); - uint8_t readStmRegister(int fd, gpioId_t chipSelect, uint8_t reg, bool autoIncrement); - uint8_t readRegister(int fd, gpioId_t chipSelect, uint8_t reg); - void readMultipleStmRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t *reply, - size_t len); - void readMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg, - uint8_t* reply, size_t len); + void writeStmRegister(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t value, + bool autoIncrement); + void writeMultipleStmRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t* values, + size_t len); + void writeMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t* values, + size_t len); + void writeRegister(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t value); + uint8_t readRm3100Register(int fd, gpioId_t chipSelect, uint8_t reg); + uint8_t readStmRegister(int fd, gpioId_t chipSelect, uint8_t reg, bool autoIncrement); + uint8_t readRegister(int fd, gpioId_t chipSelect, uint8_t reg); + void readMultipleStmRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t* reply, + size_t len); + void readMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t* reply, size_t len); }; - - - #endif /* LINUX_BOARDTEST_SPITESTCLASS_H_ */ diff --git a/linux/boardtest/UartTestClass.cpp b/linux/boardtest/UartTestClass.cpp index e69f0e5f..9b20ad13 100644 --- a/linux/boardtest/UartTestClass.cpp +++ b/linux/boardtest/UartTestClass.cpp @@ -5,110 +5,107 @@ #include "q7sConfig.h" #endif -#include "fsfw/serviceinterface/ServiceInterface.h" +#include // Error integer and strerror() function +#include // Contains file controls like O_RDWR +#include // write(), read(), close() +#include "fsfw/serviceinterface/ServiceInterface.h" #include "lwgps/lwgps.h" -#include // Contains file controls like O_RDWR -#include // Error integer and strerror() function -#include // write(), read(), close() +#define GPS_REPLY_WIRETAPPING 0 -#define GPS_REPLY_WIRETAPPING 0 - -UartTestClass::UartTestClass(object_id_t objectId): TestTask(objectId) { -} +UartTestClass::UartTestClass(object_id_t objectId) : TestTask(objectId) {} ReturnValue_t UartTestClass::initialize() { #if RPI_TEST_GPS_DEVICE == 1 - int result = lwgps_init(&gpsData); - if(result == 0) { - sif::warning << "lwgps_init error: " << result << std::endl; - } + int result = lwgps_init(&gpsData); + if (result == 0) { + sif::warning << "lwgps_init error: " << result << std::endl; + } - /* Get file descriptor */ - serialPort = open("/dev/serial0", O_RDWR); - if(serialPort < 0) { - sif::warning << "open call failed with error [" << errno << ", " << strerror(errno) - << std::endl; - } - /* Setting up UART parameters */ - tty.c_cflag &= ~PARENB; // Clear parity bit - tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication - tty.c_cflag &= ~CSIZE; // Clear all the size bits - tty.c_cflag |= CS8; // 8 bits per byte - tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control - tty.c_cflag |= CREAD | CLOCAL; // Turn on READ & ignore ctrl lines (CLOCAL = 1) - // Use canonical mode for GPS device - tty.c_lflag |= ICANON; - tty.c_lflag &= ~ECHO; // Disable echo - tty.c_lflag &= ~ECHOE; // Disable erasure - tty.c_lflag &= ~ECHONL; // Disable new-line echo - tty.c_lflag &= ~ISIG; // Disable interpretation of INTR, QUIT and SUSP - tty.c_iflag &= ~(IXON | IXOFF | IXANY); // Turn off s/w flow ctrl - tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL); // Disable any special handling of received bytes - tty.c_oflag &= ~OPOST; // Prevent special interpretation of output bytes (e.g. newline chars) - tty.c_oflag &= ~ONLCR; // Prevent conversion of newline to carriage return/line feed + /* Get file descriptor */ + serialPort = open("/dev/serial0", O_RDWR); + if (serialPort < 0) { + sif::warning << "open call failed with error [" << errno << ", " << strerror(errno) + << std::endl; + } + /* Setting up UART parameters */ + tty.c_cflag &= ~PARENB; // Clear parity bit + tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication + tty.c_cflag &= ~CSIZE; // Clear all the size bits + tty.c_cflag |= CS8; // 8 bits per byte + tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control + tty.c_cflag |= CREAD | CLOCAL; // Turn on READ & ignore ctrl lines (CLOCAL = 1) + // Use canonical mode for GPS device + tty.c_lflag |= ICANON; + tty.c_lflag &= ~ECHO; // Disable echo + tty.c_lflag &= ~ECHOE; // Disable erasure + tty.c_lflag &= ~ECHONL; // Disable new-line echo + tty.c_lflag &= ~ISIG; // Disable interpretation of INTR, QUIT and SUSP + tty.c_iflag &= ~(IXON | IXOFF | IXANY); // Turn off s/w flow ctrl + tty.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | + ICRNL); // Disable any special handling of received bytes + tty.c_oflag &= ~OPOST; // Prevent special interpretation of output bytes (e.g. newline chars) + tty.c_oflag &= ~ONLCR; // Prevent conversion of newline to carriage return/line feed - // Non-blocking mode - tty.c_cc[VTIME] = 0; - tty.c_cc[VMIN] = 0; + // Non-blocking mode + tty.c_cc[VTIME] = 0; + tty.c_cc[VMIN] = 0; - cfsetispeed(&tty, B9600); - cfsetospeed(&tty, B9600); - if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { - sif::warning << "tcsetattr call failed with error [" << errno << ", " << - strerror(errno) << std::endl;; - } - // Flush received and unread data. Those are old NMEA strings which are not relevant anymore - tcflush(serialPort, TCIFLUSH); + cfsetispeed(&tty, B9600); + cfsetospeed(&tty, B9600); + if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { + sif::warning << "tcsetattr call failed with error [" << errno << ", " << strerror(errno) + << std::endl; + ; + } + // Flush received and unread data. Those are old NMEA strings which are not relevant anymore + tcflush(serialPort, TCIFLUSH); #endif - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t UartTestClass::performOneShotAction() { #if RPI_TEST_GPS_DEVICE == 1 #endif - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t UartTestClass::performPeriodicAction() { #if RPI_TEST_GPS_DEVICE == 1 - int bytesRead = 0; - do { - bytesRead = read(serialPort, - reinterpret_cast(recBuf.data()), - static_cast(recBuf.size())); - if(bytesRead < 0) { - sif::warning << "UartTestClass::performPeriodicAction: read call failed with error [" << - errno << ", " << strerror(errno) << "]" << std::endl; - break; - } - else if(bytesRead >= static_cast(recBuf.size())) { - sif::debug << "UartTestClass::performPeriodicAction: " - "recv buffer might not be large enough" << std::endl; - } - else if(bytesRead > 0) { - // pass data to lwgps for processing + int bytesRead = 0; + do { + bytesRead = read(serialPort, reinterpret_cast(recBuf.data()), + static_cast(recBuf.size())); + if (bytesRead < 0) { + sif::warning << "UartTestClass::performPeriodicAction: read call failed with error [" << errno + << ", " << strerror(errno) << "]" << std::endl; + break; + } else if (bytesRead >= static_cast(recBuf.size())) { + sif::debug << "UartTestClass::performPeriodicAction: " + "recv buffer might not be large enough" + << std::endl; + } else if (bytesRead > 0) { + // pass data to lwgps for processing #if GPS_REPLY_WIRETAPPING == 1 - sif::info << recBuf.data() << std::endl; + sif::info << recBuf.data() << std::endl; #endif - int result = lwgps_process(&gpsData, recBuf.data(), bytesRead); - if(result == 0) { - sif::warning << "UartTestClass::performPeriodicAction: lwgps_process error" - << std::endl; - } - recvCnt++; - if(recvCnt == 6) { - recvCnt = 0; - sif::info << "GPS Data" << std::endl; - // Print messages - 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); - } - } - } while(bytesRead > 0); + int result = lwgps_process(&gpsData, recBuf.data(), bytesRead); + if (result == 0) { + sif::warning << "UartTestClass::performPeriodicAction: lwgps_process error" << std::endl; + } + recvCnt++; + if (recvCnt == 6) { + recvCnt = 0; + sif::info << "GPS Data" << std::endl; + // Print messages + 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); + } + } + } while (bytesRead > 0); #endif - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } diff --git a/linux/boardtest/UartTestClass.h b/linux/boardtest/UartTestClass.h index aeb2c396..f32d909d 100644 --- a/linux/boardtest/UartTestClass.h +++ b/linux/boardtest/UartTestClass.h @@ -1,27 +1,27 @@ #ifndef LINUX_BOARDTEST_UARTTESTCLASS_H_ #define LINUX_BOARDTEST_UARTTESTCLASS_H_ -#include "test/testtasks/TestTask.h" -#include "lwgps/lwgps.h" +#include // Contains POSIX terminal control definitions #include -#include // Contains POSIX terminal control definitions -class UartTestClass: public TestTask { -public: - UartTestClass(object_id_t objectId); +#include "lwgps/lwgps.h" +#include "test/testtasks/TestTask.h" - ReturnValue_t initialize() override; - ReturnValue_t performOneShotAction() override; - ReturnValue_t performPeriodicAction() override; -private: +class UartTestClass : public TestTask { + public: + UartTestClass(object_id_t objectId); - lwgps_t gpsData = {}; - struct termios tty = {}; - int serialPort = 0; - std::array recBuf; - uint8_t recvCnt = 0; + ReturnValue_t initialize() override; + ReturnValue_t performOneShotAction() override; + ReturnValue_t performPeriodicAction() override; + private: + lwgps_t gpsData = {}; + struct termios tty = {}; + int serialPort = 0; + std::array recBuf; + uint8_t recvCnt = 0; }; #endif /* LINUX_BOARDTEST_UARTTESTCLASS_H_ */ diff --git a/linux/csp/CspComIF.cpp b/linux/csp/CspComIF.cpp index 07fe63d3..fa372d4d 100644 --- a/linux/csp/CspComIF.cpp +++ b/linux/csp/CspComIF.cpp @@ -1,259 +1,246 @@ #include "CspComIF.h" -#include "CspCookie.h" -#include #include #include +#include -CspComIF::CspComIF(object_id_t objectId) : - SystemObject(objectId) { -} +#include "CspCookie.h" -CspComIF::~CspComIF() { -} +CspComIF::CspComIF(object_id_t objectId) : SystemObject(objectId) {} -ReturnValue_t CspComIF::initializeInterface(CookieIF *cookie) { - if(cookie == nullptr) { - return NULLPOINTER; - } +CspComIF::~CspComIF() {} - CspCookie* cspCookie = dynamic_cast(cookie); - if(cspCookie == nullptr) { - return NULLPOINTER; - } +ReturnValue_t CspComIF::initializeInterface(CookieIF* cookie) { + if (cookie == nullptr) { + return NULLPOINTER; + } - /* Perform CAN and CSP initialization only once */ - if(cspDeviceMap.empty()){ - sif::info << "Performing " << canInterface << " initialization.." << std::endl; + CspCookie* cspCookie = dynamic_cast(cookie); + if (cspCookie == nullptr) { + return NULLPOINTER; + } - /* Define the memory to allocate for the CSP stack */ - int buf_count = 10; - int buf_size = 300; - /* Init CSP and CSP buffer system */ - if (csp_init(cspOwnAddress) != CSP_ERR_NONE - || csp_buffer_init(buf_count, buf_size) != CSP_ERR_NONE) { - sif::error << "Failed to init CSP\r\n" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } + /* Perform CAN and CSP initialization only once */ + if (cspDeviceMap.empty()) { + sif::info << "Performing " << canInterface << " initialization.." << std::endl; - int promisc = 0; // Set filter mode on - csp_iface_t *csp_if_ptr = &csp_if; - csp_if_ptr = csp_can_socketcan_init(canInterface, bitrate, promisc); - - /* Set default route and start router */ - uint8_t address = CSP_DEFAULT_ROUTE; - uint8_t netmask = 0; - uint8_t mac = CSP_NODE_MAC; - int result = csp_rtable_set(address, netmask, csp_if_ptr, mac); - if(result != CSP_ERR_NONE){ - sif::error << "Failed to add can interface to router table" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - - /* Start the route task */ - unsigned int task_stack_size = 500; - unsigned int priority = 0; - result = csp_route_start_task(task_stack_size, priority); - if(result != CSP_ERR_NONE){ - sif::error << "Failed to start csp route task" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - sif::info << canInterface << " initialized successfully" << std::endl; - } - - uint8_t cspAddress = cspCookie->getCspAddress(); - uint16_t maxReplyLength = cspCookie->getMaxReplyLength(); - if(cspDeviceMap.find(cspAddress) == cspDeviceMap.end()){ - /* Insert device information in CSP map */ - cspDeviceMap.emplace(cspAddress, vectorBuffer(maxReplyLength)); - } - - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t CspComIF::sendMessage(CookieIF *cookie, - const uint8_t * sendData, size_t sendLen) { - int result; - if(cookie == NULL){ - return HasReturnvaluesIF::RETURN_FAILED; - } - CspCookie* cspCookie = dynamic_cast (cookie); - if(cspCookie == NULL){ - return HasReturnvaluesIF::RETURN_FAILED; - } - - /* Extract csp port and bytes to query from command buffer */ - uint8_t cspPort; - uint16_t querySize = 0; - result = getPortAndQuerySize(&sendData, &sendLen, &cspPort, &querySize); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - uint8_t cspAddress = cspCookie->getCspAddress(); - switch(cspPort) { - case(Ports::CSP_PING): { - initiatePingRequest(cspAddress, querySize); - break; - } - case(Ports::CSP_REBOOT): { - csp_reboot(cspAddress); - break; - } - case(Ports::P60_PORT_GNDWDT_RESET): - case(Ports::P60_PORT_RPARAM): { - /* No CSP fixed port was selected. Send data to the specified port and - * wait for querySize number of bytes */ - result = cspTransfer(cspAddress, cspPort, sendData, sendLen, - querySize); - if(result != HasReturnvaluesIF::RETURN_OK){ - return HasReturnvaluesIF::RETURN_FAILED; - } - replySize = querySize; - break; - } - default: - sif::error << "CspComIF: Invalid port specified" << std::endl; - break; - } - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t CspComIF::getSendSuccess(CookieIF *cookie) { - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t CspComIF::requestReceiveMessage(CookieIF *cookie, - size_t requestLen) { - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t CspComIF::readReceivedMessage(CookieIF *cookie, - uint8_t** buffer, size_t* size) { - if(cookie == NULL){ - return HasReturnvaluesIF::RETURN_FAILED; - } - CspCookie* cspCookie = dynamic_cast (cookie); - if(cspCookie == NULL){ - return HasReturnvaluesIF::RETURN_FAILED; - } - - uint8_t cspAddress = cspCookie->getCspAddress(); - - *buffer = cspDeviceMap[cspAddress].data(); - *size = replySize; - - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t CspComIF::cspTransfer(uint8_t cspAddress, uint8_t cspPort, - const uint8_t* cmdBuffer, int cmdLen, uint16_t querySize) { - - uint32_t timeout_ms = 1000; - uint16_t bytesRead = 0; - int32_t expectedSize = (int32_t)querySize; - vectorBufferIter iter = cspDeviceMap.find(cspAddress); - if(iter == cspDeviceMap.end()){ - sif::error << "CSP device with address " << cspAddress << " no found in" - << " device map" << std::endl; - } - uint8_t* replyBuffer = iter->second.data(); - - csp_conn_t * conn = csp_connect(CSP_PRIO_HIGH, cspAddress, cspPort, 0, - CSP_O_NONE); - - csp_packet_t* commandPacket = (csp_packet_t*)csp_buffer_get(cmdLen); - if (commandPacket == NULL) { - sif::error << "CspComIF::cspTransfer: Failed to get memory for a csp packet from the csp " - << "stack" << std::endl; - csp_close(conn); - return RETURN_FAILED; + /* Define the memory to allocate for the CSP stack */ + int buf_count = 10; + int buf_size = 300; + /* Init CSP and CSP buffer system */ + if (csp_init(cspOwnAddress) != CSP_ERR_NONE || + csp_buffer_init(buf_count, buf_size) != CSP_ERR_NONE) { + sif::error << "Failed to init CSP\r\n" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; } - memcpy(commandPacket->data, cmdBuffer, cmdLen); - commandPacket->length = cmdLen; + int promisc = 0; // Set filter mode on + csp_iface_t* csp_if_ptr = &csp_if; + csp_if_ptr = csp_can_socketcan_init(canInterface, bitrate, promisc); - if (!csp_send(conn, commandPacket, timeout_ms)) { - csp_buffer_free(commandPacket); - sif::error << "CspComIF::cspTransfer: Failed to send csp packet" << std::endl; - csp_close(conn); - return RETURN_FAILED; + /* Set default route and start router */ + uint8_t address = CSP_DEFAULT_ROUTE; + uint8_t netmask = 0; + uint8_t mac = CSP_NODE_MAC; + int result = csp_rtable_set(address, netmask, csp_if_ptr, mac); + if (result != CSP_ERR_NONE) { + sif::error << "Failed to add can interface to router table" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; } - /* Return when no reply is expected */ - if (expectedSize == 0) { - return RETURN_OK; + /* Start the route task */ + unsigned int task_stack_size = 500; + unsigned int priority = 0; + result = csp_route_start_task(task_stack_size, priority); + if (result != CSP_ERR_NONE) { + sif::error << "Failed to start csp route task" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; } + sif::info << canInterface << " initialized successfully" << std::endl; + } - csp_packet_t * reply; + uint8_t cspAddress = cspCookie->getCspAddress(); + uint16_t maxReplyLength = cspCookie->getMaxReplyLength(); + if (cspDeviceMap.find(cspAddress) == cspDeviceMap.end()) { + /* Insert device information in CSP map */ + cspDeviceMap.emplace(cspAddress, vectorBuffer(maxReplyLength)); + } + + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t CspComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) { + int result; + if (cookie == NULL) { + return HasReturnvaluesIF::RETURN_FAILED; + } + CspCookie* cspCookie = dynamic_cast(cookie); + if (cspCookie == NULL) { + return HasReturnvaluesIF::RETURN_FAILED; + } + + /* Extract csp port and bytes to query from command buffer */ + uint8_t cspPort; + uint16_t querySize = 0; + result = getPortAndQuerySize(&sendData, &sendLen, &cspPort, &querySize); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + uint8_t cspAddress = cspCookie->getCspAddress(); + switch (cspPort) { + case (Ports::CSP_PING): { + initiatePingRequest(cspAddress, querySize); + break; + } + case (Ports::CSP_REBOOT): { + csp_reboot(cspAddress); + break; + } + case (Ports::P60_PORT_GNDWDT_RESET): + case (Ports::P60_PORT_RPARAM): { + /* No CSP fixed port was selected. Send data to the specified port and + * wait for querySize number of bytes */ + result = cspTransfer(cspAddress, cspPort, sendData, sendLen, querySize); + if (result != HasReturnvaluesIF::RETURN_OK) { + return HasReturnvaluesIF::RETURN_FAILED; + } + replySize = querySize; + break; + } + default: + sif::error << "CspComIF: Invalid port specified" << std::endl; + break; + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t CspComIF::getSendSuccess(CookieIF* cookie) { return HasReturnvaluesIF::RETURN_OK; } + +ReturnValue_t CspComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLen) { + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t CspComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) { + if (cookie == NULL) { + return HasReturnvaluesIF::RETURN_FAILED; + } + CspCookie* cspCookie = dynamic_cast(cookie); + if (cspCookie == NULL) { + return HasReturnvaluesIF::RETURN_FAILED; + } + + uint8_t cspAddress = cspCookie->getCspAddress(); + + *buffer = cspDeviceMap[cspAddress].data(); + *size = replySize; + + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t CspComIF::cspTransfer(uint8_t cspAddress, uint8_t cspPort, const uint8_t* cmdBuffer, + int cmdLen, uint16_t querySize) { + uint32_t timeout_ms = 1000; + uint16_t bytesRead = 0; + int32_t expectedSize = (int32_t)querySize; + vectorBufferIter iter = cspDeviceMap.find(cspAddress); + if (iter == cspDeviceMap.end()) { + sif::error << "CSP device with address " << cspAddress << " no found in" + << " device map" << std::endl; + } + uint8_t* replyBuffer = iter->second.data(); + + csp_conn_t* conn = csp_connect(CSP_PRIO_HIGH, cspAddress, cspPort, 0, CSP_O_NONE); + + csp_packet_t* commandPacket = (csp_packet_t*)csp_buffer_get(cmdLen); + if (commandPacket == NULL) { + sif::error << "CspComIF::cspTransfer: Failed to get memory for a csp packet from the csp " + << "stack" << std::endl; + csp_close(conn); + return RETURN_FAILED; + } + + memcpy(commandPacket->data, cmdBuffer, cmdLen); + commandPacket->length = cmdLen; + + if (!csp_send(conn, commandPacket, timeout_ms)) { + csp_buffer_free(commandPacket); + sif::error << "CspComIF::cspTransfer: Failed to send csp packet" << std::endl; + csp_close(conn); + return RETURN_FAILED; + } + + /* Return when no reply is expected */ + if (expectedSize == 0) { + return RETURN_OK; + } + + csp_packet_t* reply; + reply = csp_read(conn, timeout_ms); + if (reply == NULL) { + sif::error << "CspComIF::cspTransfer: Failed to read csp packet" << std::endl; + csp_close(conn); + return RETURN_FAILED; + } + memcpy(replyBuffer, reply->data, reply->length); + expectedSize = expectedSize - reply->length; + bytesRead += reply->length; + csp_buffer_free(reply); + while (expectedSize > 0) { reply = csp_read(conn, timeout_ms); if (reply == NULL) { - sif::error << "CspComIF::cspTransfer: Failed to read csp packet" << std::endl; - csp_close(conn); - return RETURN_FAILED; + sif::error << "CspComIF::cspTransfer: Failed to read csp packet" << std::endl; + csp_close(conn); + return RETURN_FAILED; } - memcpy(replyBuffer, reply->data, reply->length); + if ((reply->length + bytesRead) > iter->second.size()) { + sif::error << "CspComIF::cspTransfer: Reply buffer to short" << std::endl; + csp_buffer_free(reply); + csp_close(conn); + return RETURN_FAILED; + } + memcpy(replyBuffer + bytesRead, reply->data, reply->length); expectedSize = expectedSize - reply->length; bytesRead += reply->length; csp_buffer_free(reply); - while (expectedSize > 0) { - reply = csp_read(conn, timeout_ms); - if (reply == NULL) { - sif::error << "CspComIF::cspTransfer: Failed to read csp packet" << std::endl; - csp_close(conn); - return RETURN_FAILED; - } - if ((reply->length + bytesRead) > iter->second.size()) { - sif::error << "CspComIF::cspTransfer: Reply buffer to short" << std::endl; - csp_buffer_free(reply); - csp_close(conn); - return RETURN_FAILED; - } - memcpy(replyBuffer + bytesRead, reply->data, reply->length); - expectedSize = expectedSize - reply->length; - bytesRead += reply->length; - csp_buffer_free(reply); - } + } - if(expectedSize != 0){ - sif::error << "CspComIF::cspTransfer: Received more bytes than requested" << std::endl; - sif::debug << "CspComIF::cspTransfer: Received bytes: " << bytesRead << std::endl; - csp_close(conn); - return RETURN_FAILED; - } + if (expectedSize != 0) { + sif::error << "CspComIF::cspTransfer: Received more bytes than requested" << std::endl; + sif::debug << "CspComIF::cspTransfer: Received bytes: " << bytesRead << std::endl; + csp_close(conn); + return RETURN_FAILED; + } - csp_close(conn); + csp_close(conn); - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t CspComIF::getPortAndQuerySize(const uint8_t** sendData, - size_t* sendLen, uint8_t* cspPort, uint16_t* querySize) { - ReturnValue_t result = SerializeAdapter::deSerialize(cspPort, sendData, - sendLen, SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "CspComIF: Failed to deserialize CSP port from command " - << "buffer" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - SerializeAdapter::deSerialize(querySize, sendData, sendLen, - SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "CspComIF: Failed to deserialize querySize from command " - << "buffer" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t CspComIF::getPortAndQuerySize(const uint8_t** sendData, size_t* sendLen, + uint8_t* cspPort, uint16_t* querySize) { + ReturnValue_t result = + SerializeAdapter::deSerialize(cspPort, sendData, sendLen, SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "CspComIF: Failed to deserialize CSP port from command " + << "buffer" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + SerializeAdapter::deSerialize(querySize, sendData, sendLen, SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "CspComIF: Failed to deserialize querySize from command " + << "buffer" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } -void CspComIF::initiatePingRequest(uint8_t cspAddress, uint16_t querySize){ - uint32_t timeout_ms = 500; - uint32_t replyTime = csp_ping(cspAddress, timeout_ms, querySize, - CSP_O_NONE); - sif::info << "Ping address: " << cspAddress << ", reply after " - << replyTime << " ms" << std::endl; - /* Store reply time in reply buffer * */ - uint8_t* replyBuffer = cspDeviceMap[cspAddress].data(); - memcpy(replyBuffer, &replyTime, sizeof(replyTime)); - replySize = sizeof(replyTime); +void CspComIF::initiatePingRequest(uint8_t cspAddress, uint16_t querySize) { + uint32_t timeout_ms = 500; + uint32_t replyTime = csp_ping(cspAddress, timeout_ms, querySize, CSP_O_NONE); + sif::info << "Ping address: " << cspAddress << ", reply after " << replyTime << " ms" + << std::endl; + /* Store reply time in reply buffer * */ + uint8_t* replyBuffer = cspDeviceMap[cspAddress].data(); + memcpy(replyBuffer, &replyTime, sizeof(replyTime)); + replySize = sizeof(replyTime); } diff --git a/linux/csp/CspComIF.h b/linux/csp/CspComIF.h index 4b8d323b..d36bbf4f 100644 --- a/linux/csp/CspComIF.h +++ b/linux/csp/CspComIF.h @@ -1,13 +1,13 @@ #ifndef LINUX_CSP_CSPCOMIF_H_ #define LINUX_CSP_CSPCOMIF_H_ +#include #include #include #include -#include -#include #include +#include /** * @brief This class serves as the communication interface to devices @@ -15,75 +15,65 @@ * in this implementation. * @author J. Meier */ -class CspComIF: public DeviceCommunicationIF, public SystemObject { -public: - CspComIF(object_id_t objectId); - virtual ~CspComIF(); +class CspComIF : public DeviceCommunicationIF, public SystemObject { + public: + CspComIF(object_id_t objectId); + virtual ~CspComIF(); - ReturnValue_t initializeInterface(CookieIF * cookie) override; - ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t * sendData, - size_t sendLen) override; - ReturnValue_t getSendSuccess(CookieIF *cookie) override; - ReturnValue_t requestReceiveMessage(CookieIF *cookie, - size_t requestLen) override; - ReturnValue_t readReceivedMessage(CookieIF *cookie, - uint8_t **readData, size_t *readLen) override; + ReturnValue_t initializeInterface(CookieIF *cookie) override; + ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t *sendData, size_t sendLen) override; + ReturnValue_t getSendSuccess(CookieIF *cookie) override; + ReturnValue_t requestReceiveMessage(CookieIF *cookie, size_t requestLen) override; + ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **readData, size_t *readLen) override; -private: + private: + /** + * @brief This function initiates the CSP transfer. + * + * @param cspAddress The CSP address of the target device. + * @param cspPort The port of the target device. + * @param timeout The timeout to wait for csp_send and csp_read + * functions. Specifies how long the functions wait + * for a successful operation. + * @param cmdBuffer The data to send. + * @param cmdLen The number of bytes to send. + * @param querySize The size of the requested message. + */ + ReturnValue_t cspTransfer(uint8_t cspAddress, uint8_t cspPort, const uint8_t *cmdBuffer, + int cmdLen, uint16_t querySize); - /** - * @brief This function initiates the CSP transfer. - * - * @param cspAddress The CSP address of the target device. - * @param cspPort The port of the target device. - * @param timeout The timeout to wait for csp_send and csp_read - * functions. Specifies how long the functions wait - * for a successful operation. - * @param cmdBuffer The data to send. - * @param cmdLen The number of bytes to send. - * @param querySize The size of the requested message. - */ - ReturnValue_t cspTransfer(uint8_t cspAddress, uint8_t cspPort, - const uint8_t* cmdBuffer, int cmdLen, uint16_t querySize); + enum Ports { CSP_PING = 1, CSP_REBOOT = 4, P60_PORT_RPARAM = 7, P60_PORT_GNDWDT_RESET = 9 }; - enum Ports { - CSP_PING = 1, - CSP_REBOOT = 4, - P60_PORT_RPARAM = 7, - P60_PORT_GNDWDT_RESET = 9 - }; + typedef uint8_t node_t; + using vectorBuffer = std::vector; + using VectorBufferMap = std::unordered_map; + using vectorBufferIter = VectorBufferMap::iterator; + /* In this map assigns reply buffers to a CSP device */ + VectorBufferMap cspDeviceMap; - typedef uint8_t node_t; - using vectorBuffer = std::vector; - using VectorBufferMap = std::unordered_map; - using vectorBufferIter = VectorBufferMap::iterator; + uint16_t replySize = 0; - /* In this map assigns reply buffers to a CSP device */ - VectorBufferMap cspDeviceMap; + /* This is the CSP address of the OBC. */ + node_t cspOwnAddress = 1; - uint16_t replySize = 0; + /* Interface struct for csp protocol stack */ + csp_iface_t csp_if; - /* This is the CSP address of the OBC. */ - node_t cspOwnAddress = 1; + char canInterface[5] = "can0"; + int bitrate = 1000; - /* Interface struct for csp protocol stack */ - csp_iface_t csp_if; + /** + * @brief Function to extract the csp port and the query size from the + * command buffer. + */ + ReturnValue_t getPortAndQuerySize(const uint8_t **sendData, size_t *sendLen, uint8_t *cspPort, + uint16_t *querySize); - char canInterface[5] = "can0"; - int bitrate = 1000; - - /** - * @brief Function to extract the csp port and the query size from the - * command buffer. - */ - ReturnValue_t getPortAndQuerySize(const uint8_t** sendData, size_t* sendLen, - uint8_t* cspPort, uint16_t* querySize); - - /** - * @brief This function initiates the ping request. - */ - void initiatePingRequest(uint8_t cspAddress, uint16_t querySize); + /** + * @brief This function initiates the ping request. + */ + void initiatePingRequest(uint8_t cspAddress, uint16_t querySize); }; #endif /* LINUX_CSP_CSPCOMIF_H_ */ diff --git a/linux/csp/CspCookie.cpp b/linux/csp/CspCookie.cpp index 18cfabd2..39274908 100644 --- a/linux/csp/CspCookie.cpp +++ b/linux/csp/CspCookie.cpp @@ -1,16 +1,10 @@ #include "CspCookie.h" -CspCookie::CspCookie(uint16_t maxReplyLength_, uint8_t cspAddress_) : - maxReplyLength(maxReplyLength_), cspAddress(cspAddress_) { -} +CspCookie::CspCookie(uint16_t maxReplyLength_, uint8_t cspAddress_) + : maxReplyLength(maxReplyLength_), cspAddress(cspAddress_) {} -CspCookie::~CspCookie() { -} +CspCookie::~CspCookie() {} -uint16_t CspCookie::getMaxReplyLength(){ - return maxReplyLength; -} +uint16_t CspCookie::getMaxReplyLength() { return maxReplyLength; } -uint8_t CspCookie::getCspAddress(){ - return cspAddress; -} +uint8_t CspCookie::getCspAddress() { return cspAddress; } diff --git a/linux/csp/CspCookie.h b/linux/csp/CspCookie.h index 4514c257..e59f3d35 100644 --- a/linux/csp/CspCookie.h +++ b/linux/csp/CspCookie.h @@ -2,6 +2,7 @@ #define LINUX_CSP_CSPCOOKIE_H_ #include + #include /** @@ -9,19 +10,17 @@ * Protocol). * @author J. Meier */ -class CspCookie: public CookieIF { -public: +class CspCookie : public CookieIF { + public: + CspCookie(uint16_t maxReplyLength_, uint8_t cspAddress_); + virtual ~CspCookie(); - CspCookie(uint16_t maxReplyLength_, uint8_t cspAddress_); - virtual ~CspCookie(); + uint16_t getMaxReplyLength(); + uint8_t getCspAddress(); - uint16_t getMaxReplyLength(); - uint8_t getCspAddress(); - -private: - - uint16_t maxReplyLength; - uint8_t cspAddress; + private: + uint16_t maxReplyLength; + uint8_t cspAddress; }; #endif /* LINUX_CSP_CSPCOOKIE_H_ */ diff --git a/linux/devices/SolarArrayDeploymentHandler.cpp b/linux/devices/SolarArrayDeploymentHandler.cpp index eea546f6..fed3992b 100644 --- a/linux/devices/SolarArrayDeploymentHandler.cpp +++ b/linux/devices/SolarArrayDeploymentHandler.cpp @@ -1,202 +1,209 @@ #include "SolarArrayDeploymentHandler.h" -#include #include - -#include +#include #include #include - +#include SolarArrayDeploymentHandler::SolarArrayDeploymentHandler(object_id_t setObjectId_, - object_id_t gpioDriverId_, CookieIF * gpioCookie_, object_id_t mainLineSwitcherObjectId_, - uint8_t mainLineSwitch_, gpioId_t deplSA1, gpioId_t deplSA2, uint32_t burnTimeMs) : - SystemObject(setObjectId_), gpioDriverId(gpioDriverId_), gpioCookie(gpioCookie_), - mainLineSwitcherObjectId(mainLineSwitcherObjectId_), mainLineSwitch(mainLineSwitch_), - deplSA1(deplSA1), deplSA2(deplSA2), burnTimeMs(burnTimeMs), actionHelper(this, nullptr) { - commandQueue = QueueFactory::instance()->createMessageQueue(cmdQueueSize, - MessageQueueMessage::MAX_MESSAGE_SIZE); + object_id_t gpioDriverId_, + CookieIF* gpioCookie_, + object_id_t mainLineSwitcherObjectId_, + uint8_t mainLineSwitch_, gpioId_t deplSA1, + gpioId_t deplSA2, uint32_t burnTimeMs) + : SystemObject(setObjectId_), + gpioDriverId(gpioDriverId_), + gpioCookie(gpioCookie_), + mainLineSwitcherObjectId(mainLineSwitcherObjectId_), + mainLineSwitch(mainLineSwitch_), + deplSA1(deplSA1), + deplSA2(deplSA2), + burnTimeMs(burnTimeMs), + actionHelper(this, nullptr) { + commandQueue = QueueFactory::instance()->createMessageQueue( + cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE); } -SolarArrayDeploymentHandler::~SolarArrayDeploymentHandler() { -} +SolarArrayDeploymentHandler::~SolarArrayDeploymentHandler() {} ReturnValue_t SolarArrayDeploymentHandler::performOperation(uint8_t operationCode) { - - if (operationCode == DeviceHandlerIF::PERFORM_OPERATION) { - handleStateMachine(); - return RETURN_OK; - } + if (operationCode == DeviceHandlerIF::PERFORM_OPERATION) { + handleStateMachine(); return RETURN_OK; + } + return RETURN_OK; } ReturnValue_t SolarArrayDeploymentHandler::initialize() { - ReturnValue_t result = SystemObject::initialize(); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + ReturnValue_t result = SystemObject::initialize(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - gpioInterface = ObjectManager::instance()->get(gpioDriverId); - if (gpioInterface == nullptr) { - sif::error << "SolarArrayDeploymentHandler::initialize: Invalid Gpio interface." - << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + gpioInterface = ObjectManager::instance()->get(gpioDriverId); + if (gpioInterface == nullptr) { + sif::error << "SolarArrayDeploymentHandler::initialize: Invalid Gpio interface." << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = gpioInterface->addGpios(dynamic_cast(gpioCookie)); - if (result != RETURN_OK) { - sif::error << "SolarArrayDeploymentHandler::initialize: Failed to initialize Gpio interface" - << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = gpioInterface->addGpios(dynamic_cast(gpioCookie)); + if (result != RETURN_OK) { + sif::error << "SolarArrayDeploymentHandler::initialize: Failed to initialize Gpio interface" + << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - if (mainLineSwitcherObjectId != objects::NO_OBJECT) { - mainLineSwitcher = ObjectManager::instance()->get(mainLineSwitcherObjectId); - if (mainLineSwitcher == nullptr) { - sif::error - << "SolarArrayDeploymentHandler::initialize: Main line switcher failed to fetch object" - << "from object ID." << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + if (mainLineSwitcherObjectId != objects::NO_OBJECT) { + mainLineSwitcher = ObjectManager::instance()->get(mainLineSwitcherObjectId); + if (mainLineSwitcher == nullptr) { + sif::error + << "SolarArrayDeploymentHandler::initialize: Main line switcher failed to fetch object" + << "from object ID." << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; } + } - result = actionHelper.initialize(commandQueue); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = actionHelper.initialize(commandQueue); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - return RETURN_OK; + return RETURN_OK; } void SolarArrayDeploymentHandler::handleStateMachine() { - switch (stateMachine) { + switch (stateMachine) { case WAIT_ON_DELOYMENT_COMMAND: - readCommandQueue(); - break; + readCommandQueue(); + break; case SWITCH_8V_ON: - mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_ON); - mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs()); - stateMachine = WAIT_ON_8V_SWITCH; - break; + mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_ON); + mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs()); + stateMachine = WAIT_ON_8V_SWITCH; + break; case WAIT_ON_8V_SWITCH: - performWaitOn8VActions(); - break; + performWaitOn8VActions(); + break; case SWITCH_DEPL_GPIOS: - switchDeploymentTransistors(); - break; + switchDeploymentTransistors(); + break; case WAIT_ON_DEPLOYMENT_FINISH: - handleDeploymentFinish(); - break; + handleDeploymentFinish(); + break; case WAIT_FOR_MAIN_SWITCH_OFF: - if (mainLineSwitcher->getSwitchState(mainLineSwitch) == PowerSwitchIF::SWITCH_OFF) { - stateMachine = WAIT_ON_DELOYMENT_COMMAND; - } else if (mainSwitchCountdown.hasTimedOut()) { - triggerEvent(MAIN_SWITCH_OFF_TIMEOUT); - sif::error << "SolarArrayDeploymentHandler::handleStateMachine: Failed to switch main" - << " switch off" << std::endl; - stateMachine = WAIT_ON_DELOYMENT_COMMAND; - } - break; + if (mainLineSwitcher->getSwitchState(mainLineSwitch) == PowerSwitchIF::SWITCH_OFF) { + stateMachine = WAIT_ON_DELOYMENT_COMMAND; + } else if (mainSwitchCountdown.hasTimedOut()) { + triggerEvent(MAIN_SWITCH_OFF_TIMEOUT); + sif::error << "SolarArrayDeploymentHandler::handleStateMachine: Failed to switch main" + << " switch off" << std::endl; + stateMachine = WAIT_ON_DELOYMENT_COMMAND; + } + break; default: - sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Invalid state" << std::endl; - break; - } + sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Invalid state" << std::endl; + break; + } } void SolarArrayDeploymentHandler::performWaitOn8VActions() { - if (mainLineSwitcher->getSwitchState(mainLineSwitch) == PowerSwitchIF::SWITCH_ON) { - stateMachine = SWITCH_DEPL_GPIOS; - } else { - if (mainSwitchCountdown.hasTimedOut()) { - triggerEvent(MAIN_SWITCH_ON_TIMEOUT); - actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, - MAIN_SWITCH_TIMEOUT_FAILURE); - stateMachine = WAIT_ON_DELOYMENT_COMMAND; - } + if (mainLineSwitcher->getSwitchState(mainLineSwitch) == PowerSwitchIF::SWITCH_ON) { + stateMachine = SWITCH_DEPL_GPIOS; + } else { + if (mainSwitchCountdown.hasTimedOut()) { + triggerEvent(MAIN_SWITCH_ON_TIMEOUT); + actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, + MAIN_SWITCH_TIMEOUT_FAILURE); + stateMachine = WAIT_ON_DELOYMENT_COMMAND; } + } } void SolarArrayDeploymentHandler::switchDeploymentTransistors() { - ReturnValue_t result = RETURN_OK; - result = gpioInterface->pullHigh(deplSA1); - if (result != RETURN_OK) { - sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" - " array deployment switch 1 high " << std::endl; - /* If gpio switch high failed, state machine is reset to wait for a command reinitiating - * the deployment sequence. */ - stateMachine = WAIT_ON_DELOYMENT_COMMAND; - triggerEvent(DEPL_SA1_GPIO_SWTICH_ON_FAILED); - actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, - SWITCHING_DEPL_SA2_FAILED); - mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); - } - result = gpioInterface->pullHigh(deplSA2); - if (result != RETURN_OK) { - sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" - " array deployment switch 2 high " << std::endl; - stateMachine = WAIT_ON_DELOYMENT_COMMAND; - triggerEvent(DEPL_SA2_GPIO_SWTICH_ON_FAILED); - actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, - SWITCHING_DEPL_SA2_FAILED); - mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); - } - deploymentCountdown.setTimeout(burnTimeMs); - stateMachine = WAIT_ON_DEPLOYMENT_FINISH; + ReturnValue_t result = RETURN_OK; + result = gpioInterface->pullHigh(deplSA1); + if (result != RETURN_OK) { + sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" + " array deployment switch 1 high " + << std::endl; + /* If gpio switch high failed, state machine is reset to wait for a command reinitiating + * the deployment sequence. */ + stateMachine = WAIT_ON_DELOYMENT_COMMAND; + triggerEvent(DEPL_SA1_GPIO_SWTICH_ON_FAILED); + actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, SWITCHING_DEPL_SA2_FAILED); + mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); + } + result = gpioInterface->pullHigh(deplSA2); + if (result != RETURN_OK) { + sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" + " array deployment switch 2 high " + << std::endl; + stateMachine = WAIT_ON_DELOYMENT_COMMAND; + triggerEvent(DEPL_SA2_GPIO_SWTICH_ON_FAILED); + actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, SWITCHING_DEPL_SA2_FAILED); + mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); + } + deploymentCountdown.setTimeout(burnTimeMs); + stateMachine = WAIT_ON_DEPLOYMENT_FINISH; } void SolarArrayDeploymentHandler::handleDeploymentFinish() { - ReturnValue_t result = RETURN_OK; - if (deploymentCountdown.hasTimedOut()) { - actionHelper.finish(true, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, RETURN_OK); - result = gpioInterface->pullLow(deplSA1); - if (result != RETURN_OK) { - sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" - " array deployment switch 1 low " << std::endl; - } - result = gpioInterface->pullLow(deplSA2); - if (result != RETURN_OK) { - sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" - " array deployment switch 2 low " << std::endl; - } - mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); - mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs()); - stateMachine = WAIT_FOR_MAIN_SWITCH_OFF; + ReturnValue_t result = RETURN_OK; + if (deploymentCountdown.hasTimedOut()) { + actionHelper.finish(true, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, RETURN_OK); + result = gpioInterface->pullLow(deplSA1); + if (result != RETURN_OK) { + sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" + " array deployment switch 1 low " + << std::endl; } + result = gpioInterface->pullLow(deplSA2); + if (result != RETURN_OK) { + sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" + " array deployment switch 2 low " + << std::endl; + } + mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); + mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs()); + stateMachine = WAIT_FOR_MAIN_SWITCH_OFF; + } } void SolarArrayDeploymentHandler::readCommandQueue() { - CommandMessage command; - ReturnValue_t result = commandQueue->receiveMessage(&command); - if (result != RETURN_OK) { - return; - } + CommandMessage command; + ReturnValue_t result = commandQueue->receiveMessage(&command); + if (result != RETURN_OK) { + return; + } - result = actionHelper.handleActionMessage(&command); - if (result == RETURN_OK) { - return; - } + result = actionHelper.handleActionMessage(&command); + if (result == RETURN_OK) { + return; + } } ReturnValue_t SolarArrayDeploymentHandler::executeAction(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { - ReturnValue_t result; - if (stateMachine != WAIT_ON_DELOYMENT_COMMAND) { - sif::error << "SolarArrayDeploymentHandler::executeAction: Received command while not in" - << "waiting-on-command-state" << std::endl; - return DEPLOYMENT_ALREADY_EXECUTING; - } - if (actionId != DEPLOY_SOLAR_ARRAYS) { - sif::error << "SolarArrayDeploymentHandler::executeAction: Received invalid command" - << std::endl; - result = COMMAND_NOT_SUPPORTED; - } else { - stateMachine = SWITCH_8V_ON; - rememberCommanderId = commandedBy; - result = RETURN_OK; - } - return result; + MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) { + ReturnValue_t result; + if (stateMachine != WAIT_ON_DELOYMENT_COMMAND) { + sif::error << "SolarArrayDeploymentHandler::executeAction: Received command while not in" + << "waiting-on-command-state" << std::endl; + return DEPLOYMENT_ALREADY_EXECUTING; + } + if (actionId != DEPLOY_SOLAR_ARRAYS) { + sif::error << "SolarArrayDeploymentHandler::executeAction: Received invalid command" + << std::endl; + result = COMMAND_NOT_SUPPORTED; + } else { + stateMachine = SWITCH_8V_ON; + rememberCommanderId = commandedBy; + result = RETURN_OK; + } + return result; } MessageQueueId_t SolarArrayDeploymentHandler::getCommandQueue() const { - return commandQueue->getId(); + return commandQueue->getId(); } diff --git a/linux/devices/SolarArrayDeploymentHandler.h b/linux/devices/SolarArrayDeploymentHandler.h index 5e573128..90380ae2 100644 --- a/linux/devices/SolarArrayDeploymentHandler.h +++ b/linux/devices/SolarArrayDeploymentHandler.h @@ -1,15 +1,16 @@ #ifndef MISSION_DEVICES_SOLARARRAYDEPLOYMENT_H_ #define MISSION_DEVICES_SOLARARRAYDEPLOYMENT_H_ -#include -#include -#include #include -#include #include #include +#include +#include +#include +#include #include #include + #include /** @@ -17,142 +18,139 @@ * * @author J. Meier */ -class SolarArrayDeploymentHandler: public ExecutableObjectIF, - public SystemObject, - public HasReturnvaluesIF, - public HasActionsIF { -public: +class SolarArrayDeploymentHandler : public ExecutableObjectIF, + public SystemObject, + public HasReturnvaluesIF, + public HasActionsIF { + public: + static const DeviceCommandId_t DEPLOY_SOLAR_ARRAYS = 0x5; - static const DeviceCommandId_t DEPLOY_SOLAR_ARRAYS = 0x5; + /** + * @brief constructor + * + * @param setObjectId The object id of the SolarArrayDeploymentHandler. + * @param gpioDriverId The id of the gpio com if. + * @param gpioCookie GpioCookie holding information about the gpios used to switch the + * transistors. + * @param mainLineSwitcherObjectId The object id of the object responsible for switching + * the 8V power source. This is normally the PCDU. + * @param mainLineSwitch The id of the main line switch. This is defined in + * powerSwitcherList.h. + * @param deplSA1 gpioId of the GPIO controlling the deployment 1 transistor. + * @param deplSA2 gpioId of the GPIO controlling the deployment 2 transistor. + * @param burnTimeMs Time duration the power will be applied to the burn wires. + */ + SolarArrayDeploymentHandler(object_id_t setObjectId, object_id_t gpioDriverId, + CookieIF* gpioCookie, object_id_t mainLineSwitcherObjectId, + uint8_t mainLineSwitch, gpioId_t deplSA1, gpioId_t deplSA2, + uint32_t burnTimeMs); - /** - * @brief constructor - * - * @param setObjectId The object id of the SolarArrayDeploymentHandler. - * @param gpioDriverId The id of the gpio com if. - * @param gpioCookie GpioCookie holding information about the gpios used to switch the - * transistors. - * @param mainLineSwitcherObjectId The object id of the object responsible for switching - * the 8V power source. This is normally the PCDU. - * @param mainLineSwitch The id of the main line switch. This is defined in - * powerSwitcherList.h. - * @param deplSA1 gpioId of the GPIO controlling the deployment 1 transistor. - * @param deplSA2 gpioId of the GPIO controlling the deployment 2 transistor. - * @param burnTimeMs Time duration the power will be applied to the burn wires. - */ - SolarArrayDeploymentHandler(object_id_t setObjectId, object_id_t gpioDriverId, - CookieIF * gpioCookie, object_id_t mainLineSwitcherObjectId, uint8_t mainLineSwitch, - gpioId_t deplSA1, gpioId_t deplSA2, uint32_t burnTimeMs); + virtual ~SolarArrayDeploymentHandler(); - virtual ~SolarArrayDeploymentHandler(); + virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; - virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; + virtual MessageQueueId_t getCommandQueue() const override; + virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) override; + virtual ReturnValue_t initialize() override; - virtual MessageQueueId_t getCommandQueue() const override; - virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size) override; - virtual ReturnValue_t initialize() override; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::SA_DEPL_HANDLER; + static const ReturnValue_t COMMAND_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA0); + static const ReturnValue_t DEPLOYMENT_ALREADY_EXECUTING = MAKE_RETURN_CODE(0xA1); + static const ReturnValue_t MAIN_SWITCH_TIMEOUT_FAILURE = MAKE_RETURN_CODE(0xA2); + static const ReturnValue_t SWITCHING_DEPL_SA1_FAILED = MAKE_RETURN_CODE(0xA3); + static const ReturnValue_t SWITCHING_DEPL_SA2_FAILED = MAKE_RETURN_CODE(0xA4); -private: + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SA_DEPL_HANDLER; + static const Event MAIN_SWITCH_ON_TIMEOUT = MAKE_EVENT(0, severity::LOW); + static const Event MAIN_SWITCH_OFF_TIMEOUT = MAKE_EVENT(1, severity::LOW); + static const Event DEPLOYMENT_FAILED = MAKE_EVENT(2, severity::HIGH); + static const Event DEPL_SA1_GPIO_SWTICH_ON_FAILED = MAKE_EVENT(3, severity::HIGH); + static const Event DEPL_SA2_GPIO_SWTICH_ON_FAILED = MAKE_EVENT(4, severity::HIGH); - static const uint8_t INTERFACE_ID = CLASS_ID::SA_DEPL_HANDLER; - static const ReturnValue_t COMMAND_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA0); - static const ReturnValue_t DEPLOYMENT_ALREADY_EXECUTING = MAKE_RETURN_CODE(0xA1); - static const ReturnValue_t MAIN_SWITCH_TIMEOUT_FAILURE = MAKE_RETURN_CODE(0xA2); - static const ReturnValue_t SWITCHING_DEPL_SA1_FAILED = MAKE_RETURN_CODE(0xA3); - static const ReturnValue_t SWITCHING_DEPL_SA2_FAILED = MAKE_RETURN_CODE(0xA4); + enum StateMachine { + WAIT_ON_DELOYMENT_COMMAND, + SWITCH_8V_ON, + WAIT_ON_8V_SWITCH, + SWITCH_DEPL_GPIOS, + WAIT_ON_DEPLOYMENT_FINISH, + WAIT_FOR_MAIN_SWITCH_OFF + }; - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SA_DEPL_HANDLER; - static const Event MAIN_SWITCH_ON_TIMEOUT = MAKE_EVENT(0, severity::LOW); - static const Event MAIN_SWITCH_OFF_TIMEOUT = MAKE_EVENT(1, severity::LOW); - static const Event DEPLOYMENT_FAILED = MAKE_EVENT(2, severity::HIGH); - static const Event DEPL_SA1_GPIO_SWTICH_ON_FAILED = MAKE_EVENT(3, severity::HIGH); - static const Event DEPL_SA2_GPIO_SWTICH_ON_FAILED = MAKE_EVENT(4, severity::HIGH); + StateMachine stateMachine = WAIT_ON_DELOYMENT_COMMAND; + /** + * This countdown is used to check if the PCDU sets the 8V line on in the intended time. + */ + Countdown mainSwitchCountdown; - enum StateMachine { - WAIT_ON_DELOYMENT_COMMAND, - SWITCH_8V_ON, - WAIT_ON_8V_SWITCH, - SWITCH_DEPL_GPIOS, - WAIT_ON_DEPLOYMENT_FINISH, - WAIT_FOR_MAIN_SWITCH_OFF - }; + /** + * This countdown is used to wait for the burn wire being successful cut. + */ + Countdown deploymentCountdown; - StateMachine stateMachine = WAIT_ON_DELOYMENT_COMMAND; + /** + * The message queue id of the component commanding an action will be stored in this variable. + * This is necessary to send later the action finish replies. + */ + MessageQueueId_t rememberCommanderId = 0; - /** - * This countdown is used to check if the PCDU sets the 8V line on in the intended time. - */ - Countdown mainSwitchCountdown; + /** Size of command queue */ + size_t cmdQueueSize = 20; - /** - * This countdown is used to wait for the burn wire being successful cut. - */ - Countdown deploymentCountdown; + /** The object ID of the GPIO driver which switches the deployment transistors */ + object_id_t gpioDriverId; + CookieIF* gpioCookie; - /** - * The message queue id of the component commanding an action will be stored in this variable. - * This is necessary to send later the action finish replies. - */ - MessageQueueId_t rememberCommanderId = 0; + /** Object id of the object responsible to switch the 8V power input. Typically the PCDU. */ + object_id_t mainLineSwitcherObjectId; - /** Size of command queue */ - size_t cmdQueueSize = 20; + /** Switch number of the 8V power switch */ + uint8_t mainLineSwitch; - /** The object ID of the GPIO driver which switches the deployment transistors */ - object_id_t gpioDriverId; + gpioId_t deplSA1; + gpioId_t deplSA2; - CookieIF * gpioCookie; + GpioIF* gpioInterface = nullptr; - /** Object id of the object responsible to switch the 8V power input. Typically the PCDU. */ - object_id_t mainLineSwitcherObjectId; + /** Time duration switches are active to cut the burn wire */ + uint32_t burnTimeMs; - /** Switch number of the 8V power switch */ - uint8_t mainLineSwitch; + /** Queue to receive messages from other objects. */ + MessageQueueIF* commandQueue = nullptr; - gpioId_t deplSA1; - gpioId_t deplSA2; + /** + * After initialization this pointer will hold the reference to the main line switcher object. + */ + PowerSwitchIF* mainLineSwitcher = nullptr; - GpioIF* gpioInterface = nullptr; + ActionHelper actionHelper; - /** Time duration switches are active to cut the burn wire */ - uint32_t burnTimeMs; + void readCommandQueue(); - /** Queue to receive messages from other objects. */ - MessageQueueIF* commandQueue = nullptr; + /** + * @brief This function performs actions dependent on the current state. + */ + void handleStateMachine(); - /** - * After initialization this pointer will hold the reference to the main line switcher object. - */ - PowerSwitchIF *mainLineSwitcher = nullptr; + /** + * @brief This function polls the 8V switch state and changes the state machine when the + * switch has been enabled. + */ + void performWaitOn8VActions(); - ActionHelper actionHelper; + /** + * @brief This functions handles the switching of the solar array deployment transistors. + */ + void switchDeploymentTransistors(); - void readCommandQueue(); - - /** - * @brief This function performs actions dependent on the current state. - */ - void handleStateMachine(); - - /** - * @brief This function polls the 8V switch state and changes the state machine when the - * switch has been enabled. - */ - void performWaitOn8VActions(); - - /** - * @brief This functions handles the switching of the solar array deployment transistors. - */ - void switchDeploymentTransistors(); - - /** - * @brief This function performs actions to finish the deployment. Essentially switches - * are turned of after the burn time has expired. - */ - void handleDeploymentFinish(); + /** + * @brief This function performs actions to finish the deployment. Essentially switches + * are turned of after the burn time has expired. + */ + void handleDeploymentFinish(); }; #endif /* MISSION_DEVICES_SOLARARRAYDEPLOYMENT_H_ */ diff --git a/linux/devices/SusHandler.cpp b/linux/devices/SusHandler.cpp index 67263756..44755f41 100644 --- a/linux/devices/SusHandler.cpp +++ b/linux/devices/SusHandler.cpp @@ -1,230 +1,214 @@ #include "SusHandler.h" -#include "OBSWConfig.h" #include #include -SusHandler::SusHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie, - LinuxLibgpioIF* gpioComIF, gpioId_t chipSelectId) : - DeviceHandlerBase(objectId, comIF, comCookie), gpioComIF(gpioComIF), chipSelectId( - chipSelectId), dataset(this) { - if (comCookie == NULL) { - sif::error << "SusHandler: Invalid com cookie" << std::endl; - } - if (gpioComIF == NULL) { - sif::error << "SusHandler: Invalid GpioComIF" << std::endl; - } +#include "OBSWConfig.h" + +SusHandler::SusHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie, + LinuxLibgpioIF *gpioComIF, gpioId_t chipSelectId) + : DeviceHandlerBase(objectId, comIF, comCookie), + gpioComIF(gpioComIF), + chipSelectId(chipSelectId), + dataset(this) { + if (comCookie == NULL) { + sif::error << "SusHandler: Invalid com cookie" << std::endl; + } + if (gpioComIF == NULL) { + sif::error << "SusHandler: Invalid GpioComIF" << std::endl; + } } -SusHandler::~SusHandler() { -} +SusHandler::~SusHandler() {} ReturnValue_t SusHandler::performOperation(uint8_t counter) { - - if (counter != FIRST_WRITE) { - DeviceHandlerBase::performOperation(counter); - return RETURN_OK; - } - - if (mode != MODE_NORMAL) { - DeviceHandlerBase::performOperation(DeviceHandlerIF::SEND_WRITE); - return RETURN_OK; - } - - /* If device is in normale mode the communication sequence is initiated here */ - if (communicationStep == CommunicationStep::IDLE) { - communicationStep = CommunicationStep::WRITE_SETUP; - } - - DeviceHandlerBase::performOperation(DeviceHandlerIF::SEND_WRITE); - + if (counter != FIRST_WRITE) { + DeviceHandlerBase::performOperation(counter); return RETURN_OK; + } + + if (mode != MODE_NORMAL) { + DeviceHandlerBase::performOperation(DeviceHandlerIF::SEND_WRITE); + return RETURN_OK; + } + + /* If device is in normale mode the communication sequence is initiated here */ + if (communicationStep == CommunicationStep::IDLE) { + communicationStep = CommunicationStep::WRITE_SETUP; + } + + DeviceHandlerBase::performOperation(DeviceHandlerIF::SEND_WRITE); + + return RETURN_OK; } ReturnValue_t SusHandler::initialize() { - ReturnValue_t result = RETURN_OK; - result = DeviceHandlerBase::initialize(); - if (result != RETURN_OK) { - return result; - } - auto spiComIF = dynamic_cast(communicationInterface); - if (spiComIF == nullptr) { - sif::debug << "SusHandler::initialize: Invalid communication interface" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } - spiMutex = spiComIF->getMutex(); - if (spiMutex == nullptr) { - sif::debug << "SusHandler::initialize: Failed to get spi mutex" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + result = DeviceHandlerBase::initialize(); + if (result != RETURN_OK) { + return result; + } + auto spiComIF = dynamic_cast(communicationInterface); + if (spiComIF == nullptr) { + sif::debug << "SusHandler::initialize: Invalid communication interface" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } + spiMutex = spiComIF->getMutex(); + if (spiMutex == nullptr) { + sif::debug << "SusHandler::initialize: Failed to get spi mutex" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } + return RETURN_OK; } -void SusHandler::doStartUp(){ +void SusHandler::doStartUp() { #if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 - setMode(MODE_NORMAL); + setMode(MODE_NORMAL); #else - setMode(_MODE_TO_ON); + setMode(_MODE_TO_ON); #endif } -void SusHandler::doShutDown(){ - setMode(_MODE_POWER_DOWN); +void SusHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } + +ReturnValue_t SusHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + if (communicationStep == CommunicationStep::IDLE) { + return NOTHING_TO_SEND; + } + + if (communicationStep == CommunicationStep::WRITE_SETUP) { + *id = SUS::WRITE_SETUP; + communicationStep = CommunicationStep::START_CONVERSIONS; + } else if (communicationStep == CommunicationStep::START_CONVERSIONS) { + *id = SUS::START_CONVERSIONS; + communicationStep = CommunicationStep::READ_CONVERSIONS; + } else if (communicationStep == CommunicationStep::READ_CONVERSIONS) { + *id = SUS::READ_CONVERSIONS; + communicationStep = CommunicationStep::IDLE; + } + return buildCommandFromCommand(*id, nullptr, 0); } -ReturnValue_t SusHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - - if (communicationStep == CommunicationStep::IDLE) { - return NOTHING_TO_SEND; - } - - if (communicationStep == CommunicationStep::WRITE_SETUP) { - *id = SUS::WRITE_SETUP; - communicationStep = CommunicationStep::START_CONVERSIONS; - } - else if (communicationStep == CommunicationStep::START_CONVERSIONS) { - *id = SUS::START_CONVERSIONS; - communicationStep = CommunicationStep::READ_CONVERSIONS; - } - else if (communicationStep == CommunicationStep::READ_CONVERSIONS) { - *id = SUS::READ_CONVERSIONS; - communicationStep = CommunicationStep::IDLE; - } - return buildCommandFromCommand(*id, nullptr, 0); +ReturnValue_t SusHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t SusHandler::buildTransitionDeviceCommand( - DeviceCommandId_t * id){ - return HasReturnvaluesIF::RETURN_OK; -} +ReturnValue_t SusHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, + size_t commandDataLen) { + switch (deviceCommand) { + case (SUS::WRITE_SETUP): { + /** + * The sun sensor ADC is shutdown when CS is pulled high, so each time requesting a + * measurement the setup has to be rewritten. There must also be a little delay between + * the transmission of the setup byte and the first conversion. Thus the conversion + * will be performed in an extra step. + * Because the chip select is driven manually by the SusHandler the SPI bus must be + * protected with a mutex here. + */ + ReturnValue_t result = spiMutex->lockMutex(timeoutType, timeoutMs); + if (result == MutexIF::MUTEX_TIMEOUT) { + sif::error << "SusHandler::buildCommandFromCommand: Mutex timeout" << std::endl; + return ERROR_LOCK_MUTEX; + } else if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "SusHandler::buildCommandFromCommand: Failed to lock spi mutex" << std::endl; + return ERROR_LOCK_MUTEX; + } -ReturnValue_t SusHandler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t * commandData, - size_t commandDataLen) { - switch(deviceCommand) { - case(SUS::WRITE_SETUP): { - /** - * The sun sensor ADC is shutdown when CS is pulled high, so each time requesting a - * measurement the setup has to be rewritten. There must also be a little delay between - * the transmission of the setup byte and the first conversion. Thus the conversion - * will be performed in an extra step. - * Because the chip select is driven manually by the SusHandler the SPI bus must be - * protected with a mutex here. - */ - ReturnValue_t result = spiMutex->lockMutex(timeoutType, timeoutMs); - if(result == MutexIF::MUTEX_TIMEOUT) { - sif::error << "SusHandler::buildCommandFromCommand: Mutex timeout" << std::endl; - return ERROR_LOCK_MUTEX; - } - else if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "SusHandler::buildCommandFromCommand: Failed to lock spi mutex" - << std::endl; - return ERROR_LOCK_MUTEX; - } - - gpioComIF->pullLow(chipSelectId); - cmdBuffer[0] = SUS::SETUP; - rawPacket = cmdBuffer; - rawPacketLen = 1; - return RETURN_OK; - } - case(SUS::START_CONVERSIONS): { - std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); - cmdBuffer[0] = SUS::CONVERSION; - rawPacket = cmdBuffer; - rawPacketLen = 2; - return RETURN_OK; - } - case(SUS::READ_CONVERSIONS): { - std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); - rawPacket = cmdBuffer; - rawPacketLen = SUS::SIZE_READ_CONVERSIONS; - return RETURN_OK; - } - default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; + gpioComIF->pullLow(chipSelectId); + cmdBuffer[0] = SUS::SETUP; + rawPacket = cmdBuffer; + rawPacketLen = 1; + return RETURN_OK; + } + case (SUS::START_CONVERSIONS): { + std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); + cmdBuffer[0] = SUS::CONVERSION; + rawPacket = cmdBuffer; + rawPacketLen = 2; + return RETURN_OK; + } + case (SUS::READ_CONVERSIONS): { + std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); + rawPacket = cmdBuffer; + rawPacketLen = SUS::SIZE_READ_CONVERSIONS; + return RETURN_OK; + } + default: + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } void SusHandler::fillCommandAndReplyMap() { - this->insertInCommandMap(SUS::WRITE_SETUP); - this->insertInCommandMap(SUS::START_CONVERSIONS); - this->insertInCommandAndReplyMap(SUS::READ_CONVERSIONS, 1, &dataset, SUS::SIZE_READ_CONVERSIONS); + this->insertInCommandMap(SUS::WRITE_SETUP); + this->insertInCommandMap(SUS::START_CONVERSIONS); + this->insertInCommandAndReplyMap(SUS::READ_CONVERSIONS, 1, &dataset, SUS::SIZE_READ_CONVERSIONS); } -ReturnValue_t SusHandler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { - *foundId = this->getPendingCommand(); - *foundLen = remainingSize; - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t SusHandler::scanForReply(const uint8_t *start, size_t remainingSize, + DeviceCommandId_t *foundId, size_t *foundLen) { + *foundId = this->getPendingCommand(); + *foundLen = remainingSize; + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t SusHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { - switch (id) { - case SUS::READ_CONVERSIONS: { - PoolReadGuard readSet(&dataset); - dataset.temperatureCelcius = (*(packet) << 8 | *(packet + 1)) * 0.125; - dataset.ain0 = (*(packet + 2) << 8 | *(packet + 3)); - dataset.ain1 = (*(packet + 4) << 8 | *(packet + 5)); - dataset.ain2 = (*(packet + 6) << 8 | *(packet + 7)); - dataset.ain3 = (*(packet + 8) << 8 | *(packet + 9)); - dataset.ain4 = (*(packet + 10) << 8 | *(packet + 11)); - dataset.ain5 = (*(packet + 12) << 8 | *(packet + 13)); +ReturnValue_t SusHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { + switch (id) { + case SUS::READ_CONVERSIONS: { + PoolReadGuard readSet(&dataset); + dataset.temperatureCelcius = (*(packet) << 8 | *(packet + 1)) * 0.125; + dataset.ain0 = (*(packet + 2) << 8 | *(packet + 3)); + dataset.ain1 = (*(packet + 4) << 8 | *(packet + 5)); + dataset.ain2 = (*(packet + 6) << 8 | *(packet + 7)); + dataset.ain3 = (*(packet + 8) << 8 | *(packet + 9)); + dataset.ain4 = (*(packet + 10) << 8 | *(packet + 11)); + dataset.ain5 = (*(packet + 12) << 8 | *(packet + 13)); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SUS - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", Temperature: " - << dataset.temperatureCelcius << " °C" << std::endl; - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN0: " - << std::dec << dataset.ain0 << std::endl; - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN1: " - << std::dec << dataset.ain1 << std::endl; - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN2: " - << std::dec << dataset.ain2 << std::endl; - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN3: " - << std::dec << dataset.ain3 << std::endl; - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN4: " - << std::dec << dataset.ain4 << std::endl; - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN5: " - << std::dec << dataset.ain5 << std::endl; + sif::info << "SUS object id 0x" << std::hex << this->getObjectId() + << ", Temperature: " << dataset.temperatureCelcius << " °C" << std::endl; + sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN0: " << std::dec + << dataset.ain0 << std::endl; + sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN1: " << std::dec + << dataset.ain1 << std::endl; + sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN2: " << std::dec + << dataset.ain2 << std::endl; + sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN3: " << std::dec + << dataset.ain3 << std::endl; + sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN4: " << std::dec + << dataset.ain4 << std::endl; + sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN5: " << std::dec + << dataset.ain5 << std::endl; #endif - /** SUS can now be shutdown and thus the SPI bus released again */ - gpioComIF->pullHigh(chipSelectId); - ReturnValue_t result = spiMutex->unlockMutex(); - if (result != RETURN_OK) { - sif::error << "SusHandler::interpretDeviceReply: Failed to unlock spi mutex" - << std::endl; - return ERROR_UNLOCK_MUTEX; - } - break; - } - default: { - sif::debug << "SusHandler::interpretDeviceReply: Unknown reply id" << std::endl; - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } - - } - return HasReturnvaluesIF::RETURN_OK; + /** SUS can now be shutdown and thus the SPI bus released again */ + gpioComIF->pullHigh(chipSelectId); + ReturnValue_t result = spiMutex->unlockMutex(); + if (result != RETURN_OK) { + sif::error << "SusHandler::interpretDeviceReply: Failed to unlock spi mutex" << std::endl; + return ERROR_UNLOCK_MUTEX; + } + break; + } + default: { + sif::debug << "SusHandler::interpretDeviceReply: Unknown reply id" << std::endl; + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; + } + } + return HasReturnvaluesIF::RETURN_OK; } -void SusHandler::setNormalDatapoolEntriesInvalid(){ +void SusHandler::setNormalDatapoolEntriesInvalid() {} +uint32_t SusHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 1000; } + +ReturnValue_t SusHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(SUS::TEMPERATURE_C, new PoolEntry({0.0})); + localDataPoolMap.emplace(SUS::AIN0, new PoolEntry({0})); + localDataPoolMap.emplace(SUS::AIN1, new PoolEntry({0})); + localDataPoolMap.emplace(SUS::AIN2, new PoolEntry({0})); + localDataPoolMap.emplace(SUS::AIN3, new PoolEntry({0})); + localDataPoolMap.emplace(SUS::AIN4, new PoolEntry({0})); + localDataPoolMap.emplace(SUS::AIN5, new PoolEntry({0})); + return HasReturnvaluesIF::RETURN_OK; } - -uint32_t SusHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){ - return 1000; -} - -ReturnValue_t SusHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { - localDataPoolMap.emplace(SUS::TEMPERATURE_C, new PoolEntry( { 0.0 })); - localDataPoolMap.emplace(SUS::AIN0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SUS::AIN1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SUS::AIN2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SUS::AIN3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SUS::AIN4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SUS::AIN5, new PoolEntry( { 0 })); - return HasReturnvaluesIF::RETURN_OK; -} - diff --git a/linux/devices/SusHandler.h b/linux/devices/SusHandler.h index ca9a5c45..0eab5fd0 100644 --- a/linux/devices/SusHandler.h +++ b/linux/devices/SusHandler.h @@ -1,10 +1,11 @@ #ifndef MISSION_DEVICES_SUSHANDLER_H_ #define MISSION_DEVICES_SUSHANDLER_H_ -#include "devicedefinitions/SusDefinitions.h" #include #include +#include "devicedefinitions/SusDefinitions.h" + /** * @brief This is the device handler class for the SUS sensor. The sensor is * based on the MAX1227 ADC. Details about the SUS electronic can be found at @@ -18,63 +19,55 @@ * * @author J. Meier */ -class SusHandler: public DeviceHandlerBase { -public: +class SusHandler : public DeviceHandlerBase { + public: + static const uint8_t FIRST_WRITE = 7; - static const uint8_t FIRST_WRITE = 7; + SusHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, + LinuxLibgpioIF* gpioComIF, gpioId_t chipSelectId); + virtual ~SusHandler(); - SusHandler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie, LinuxLibgpioIF* gpioComIF, gpioId_t chipSelectId); - virtual ~SusHandler(); + virtual ReturnValue_t performOperation(uint8_t counter) override; - virtual ReturnValue_t performOperation(uint8_t counter) override; + virtual ReturnValue_t initialize() override; - 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; -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; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::SUS_HANDLER; -private: + static const ReturnValue_t ERROR_UNLOCK_MUTEX = MAKE_RETURN_CODE(0xA0); + static const ReturnValue_t ERROR_LOCK_MUTEX = MAKE_RETURN_CODE(0xA1); - static const uint8_t INTERFACE_ID = CLASS_ID::SUS_HANDLER; + enum class CommunicationStep { IDLE, WRITE_SETUP, START_CONVERSIONS, READ_CONVERSIONS }; - static const ReturnValue_t ERROR_UNLOCK_MUTEX = MAKE_RETURN_CODE(0xA0); - static const ReturnValue_t ERROR_LOCK_MUTEX = MAKE_RETURN_CODE(0xA1); + LinuxLibgpioIF* gpioComIF = nullptr; - enum class CommunicationStep { - IDLE, - WRITE_SETUP, - START_CONVERSIONS, - READ_CONVERSIONS - }; + gpioId_t chipSelectId = gpio::NO_GPIO; - LinuxLibgpioIF* gpioComIF = nullptr; + SUS::SusDataset dataset; - gpioId_t chipSelectId = gpio::NO_GPIO; + uint8_t cmdBuffer[SUS::MAX_CMD_SIZE]; + CommunicationStep communicationStep = CommunicationStep::IDLE; - SUS::SusDataset dataset; + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; + uint32_t timeoutMs = 20; - uint8_t cmdBuffer[SUS::MAX_CMD_SIZE]; - CommunicationStep communicationStep = CommunicationStep::IDLE; - - MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; - uint32_t timeoutMs = 20; - - MutexIF* spiMutex = nullptr; + MutexIF* spiMutex = nullptr; }; #endif /* MISSION_DEVICES_SUSHANDLER_H_ */ diff --git a/linux/devices/devicedefinitions/SusDefinitions.h b/linux/devices/devicedefinitions/SusDefinitions.h index ba56ec07..2a45ebc5 100644 --- a/linux/devices/devicedefinitions/SusDefinitions.h +++ b/linux/devices/devicedefinitions/SusDefinitions.h @@ -3,93 +3,87 @@ #include #include -#include +#include namespace SUS { - /** - * Some MAX1227 could not be reached with frequencies around 4 MHz. Maybe this is caused by - * the decoder and buffer circuits. Thus frequency is here defined to 1 MHz. - */ - static const uint32_t MAX1227_SPI_FREQ = 1000000; +/** + * Some MAX1227 could not be reached with frequencies around 4 MHz. Maybe this is caused by + * the decoder and buffer circuits. Thus frequency is here defined to 1 MHz. + */ +static const uint32_t MAX1227_SPI_FREQ = 1000000; - static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending +static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending - static const DeviceCommandId_t WRITE_SETUP = 0x1; - /** - * This command initiates the ADC conversion for all channels including the internal - * temperature sensor. - */ - static const DeviceCommandId_t START_CONVERSIONS = 0x2; - /** - * This command reads the internal fifo which holds the temperature and the channel - * conversions. - */ - static const DeviceCommandId_t READ_CONVERSIONS = 0x3; +static const DeviceCommandId_t WRITE_SETUP = 0x1; +/** + * This command initiates the ADC conversion for all channels including the internal + * temperature sensor. + */ +static const DeviceCommandId_t START_CONVERSIONS = 0x2; +/** + * This command reads the internal fifo which holds the temperature and the channel + * conversions. + */ +static const DeviceCommandId_t READ_CONVERSIONS = 0x3; - /** - * @brief This is the configuration byte which will be written to the setup register after - * power on. - * - * @note Bit1 (DIFFSEL1) - Bit0 (DIFFSEL0): 0b00, No byte is following the setup byte - * Bit3 (REFSEL1) - Bit2 (REFSEL0): 0b10, Internal reference, no wake-up delay - * Bit5 (CLKSEL1) - Bit4 (CLKSEL0): 0b10, Internally clocked - * Bit7 - Bit6: 0b01, Tells MAX1227 that this byte should be - * written to the setup register - * - */ - static const uint8_t SETUP = 0b01101000; +/** + * @brief This is the configuration byte which will be written to the setup register after + * power on. + * + * @note Bit1 (DIFFSEL1) - Bit0 (DIFFSEL0): 0b00, No byte is following the setup byte + * Bit3 (REFSEL1) - Bit2 (REFSEL0): 0b10, Internal reference, no wake-up delay + * Bit5 (CLKSEL1) - Bit4 (CLKSEL0): 0b10, Internally clocked + * Bit7 - Bit6: 0b01, Tells MAX1227 that this byte should be + * written to the setup register + * + */ +static const uint8_t SETUP = 0b01101000; - /** - * @brief This values will always be written to the ADC conversion register to specify the - * conversions to perform. - * @details Bit0: 1 - Enables temperature conversion - * Bit2 (SCAN1) and Bit1 (SCAN0): 0b00, Scans channels 0 through N - * Bit6 - Bit3 defines N: 0b0101 (N = 5) - * Bit7: Always 1. Tells the ADC that this is the conversion register. - */ - static const uint8_t CONVERSION = 0b10101001; +/** + * @brief This values will always be written to the ADC conversion register to specify the + * conversions to perform. + * @details Bit0: 1 - Enables temperature conversion + * Bit2 (SCAN1) and Bit1 (SCAN0): 0b00, Scans channels 0 through N + * Bit6 - Bit3 defines N: 0b0101 (N = 5) + * Bit7: Always 1. Tells the ADC that this is the conversion register. + */ +static const uint8_t CONVERSION = 0b10101001; - static const uint8_t SUS_DATA_SET_ID = READ_CONVERSIONS; +static const uint8_t SUS_DATA_SET_ID = READ_CONVERSIONS; - /** Size of data replies. Temperature and 6 channel convesions (AIN0 - AIN5) */ - static const uint8_t SIZE_READ_CONVERSIONS = 14; +/** Size of data replies. Temperature and 6 channel convesions (AIN0 - AIN5) */ +static const uint8_t SIZE_READ_CONVERSIONS = 14; - static const uint8_t MAX_CMD_SIZE = SIZE_READ_CONVERSIONS; +static const uint8_t MAX_CMD_SIZE = SIZE_READ_CONVERSIONS; - static const uint8_t POOL_ENTRIES = 7; +static const uint8_t POOL_ENTRIES = 7; - enum Max1227PoolIds: lp_id_t { - TEMPERATURE_C, - AIN0, - AIN1, - AIN2, - AIN3, - AIN4, - AIN5, - }; - -class SusDataset: public StaticLocalDataSet { -public: - - SusDataset(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, SUS_DATA_SET_ID) { - } - - SusDataset(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, SUS_DATA_SET_ID)) { - } - - lp_var_t temperatureCelcius = lp_var_t(sid.objectId, TEMPERATURE_C, this); - lp_var_t ain0 = lp_var_t(sid.objectId, AIN0, this); - lp_var_t ain1 = lp_var_t(sid.objectId, AIN1, this); - lp_var_t ain2 = lp_var_t(sid.objectId, AIN2, this); - lp_var_t ain3 = lp_var_t(sid.objectId, AIN3, this); - lp_var_t ain4 = lp_var_t(sid.objectId, AIN4, this); - lp_var_t ain5 = lp_var_t(sid.objectId, AIN5, this); +enum Max1227PoolIds : lp_id_t { + TEMPERATURE_C, + AIN0, + AIN1, + AIN2, + AIN3, + AIN4, + AIN5, }; -} +class SusDataset : public StaticLocalDataSet { + public: + SusDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, SUS_DATA_SET_ID) {} + + SusDataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, SUS_DATA_SET_ID)) {} + + lp_var_t temperatureCelcius = lp_var_t(sid.objectId, TEMPERATURE_C, this); + lp_var_t ain0 = lp_var_t(sid.objectId, AIN0, this); + lp_var_t ain1 = lp_var_t(sid.objectId, AIN1, this); + lp_var_t ain2 = lp_var_t(sid.objectId, AIN2, this); + lp_var_t ain3 = lp_var_t(sid.objectId, AIN3, this); + lp_var_t ain4 = lp_var_t(sid.objectId, AIN4, this); + lp_var_t ain5 = lp_var_t(sid.objectId, AIN5, this); +}; +} // namespace SUS #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_SUS_H_ */ diff --git a/linux/fsfwconfig/devices/addresses.cpp b/linux/fsfwconfig/devices/addresses.cpp index 38877737..60b1370b 100644 --- a/linux/fsfwconfig/devices/addresses.cpp +++ b/linux/fsfwconfig/devices/addresses.cpp @@ -5,7 +5,3 @@ */ #include "addresses.h" - - - - diff --git a/linux/fsfwconfig/devices/addresses.h b/linux/fsfwconfig/devices/addresses.h index 94f22c54..5ef82788 100644 --- a/linux/fsfwconfig/devices/addresses.h +++ b/linux/fsfwconfig/devices/addresses.h @@ -2,84 +2,85 @@ #define FSFWCONFIG_DEVICES_ADDRESSES_H_ #include -#include "objects/systemObjectList.h" + #include +#include "objects/systemObjectList.h" + namespace addresses { - /* Logical addresses have uint32_t datatype */ - enum logicalAddresses: address_t { - PCDU, +/* Logical addresses have uint32_t datatype */ +enum logicalAddresses : address_t { + PCDU, - MGM_0_LIS3 = objects::MGM_0_LIS3_HANDLER, - MGM_1_RM3100 = objects::MGM_1_RM3100_HANDLER, - MGM_2_LIS3 = objects::MGM_2_LIS3_HANDLER, - MGM_3_RM3100 = objects::MGM_3_RM3100_HANDLER, + MGM_0_LIS3 = objects::MGM_0_LIS3_HANDLER, + MGM_1_RM3100 = objects::MGM_1_RM3100_HANDLER, + MGM_2_LIS3 = objects::MGM_2_LIS3_HANDLER, + MGM_3_RM3100 = objects::MGM_3_RM3100_HANDLER, - GYRO_0_ADIS = objects::GYRO_0_ADIS_HANDLER, - GYRO_1_L3G = objects::GYRO_1_L3G_HANDLER, - GYRO_2_ADIS = objects::GYRO_2_ADIS_HANDLER, - GYRO_3_L3G = objects::GYRO_3_L3G_HANDLER, + GYRO_0_ADIS = objects::GYRO_0_ADIS_HANDLER, + GYRO_1_L3G = objects::GYRO_1_L3G_HANDLER, + GYRO_2_ADIS = objects::GYRO_2_ADIS_HANDLER, + GYRO_3_L3G = objects::GYRO_3_L3G_HANDLER, - RAD_SENSOR = objects::RAD_SENSOR, + RAD_SENSOR = objects::RAD_SENSOR, - SUS_1 = objects::SUS_1, - SUS_2 = objects::SUS_2, - SUS_3 = objects::SUS_3, - SUS_4 = objects::SUS_4, - SUS_5 = objects::SUS_5, - SUS_6 = objects::SUS_6, - SUS_7 = objects::SUS_7, - SUS_8 = objects::SUS_8, - SUS_9 = objects::SUS_9, - SUS_10 = objects::SUS_10, - SUS_11 = objects::SUS_11, - SUS_12 = objects::SUS_12, - SUS_13 = objects::SUS_13, + SUS_1 = objects::SUS_1, + SUS_2 = objects::SUS_2, + SUS_3 = objects::SUS_3, + SUS_4 = objects::SUS_4, + SUS_5 = objects::SUS_5, + SUS_6 = objects::SUS_6, + SUS_7 = objects::SUS_7, + SUS_8 = objects::SUS_8, + SUS_9 = objects::SUS_9, + SUS_10 = objects::SUS_10, + SUS_11 = objects::SUS_11, + SUS_12 = objects::SUS_12, + SUS_13 = objects::SUS_13, - /* Dummy and Test Addresses */ - DUMMY_ECHO = 129, - DUMMY_GPS0 = 130, - DUMMY_GPS1 = 131, - }; + /* Dummy and Test Addresses */ + DUMMY_ECHO = 129, + DUMMY_GPS0 = 130, + DUMMY_GPS1 = 131, +}; - enum i2cAddresses: address_t { - IMTQ = 16, - TMP1075_TCS_1 = 72, - TMP1075_TCS_2 = 73, - }; +enum i2cAddresses : address_t { + IMTQ = 16, + TMP1075_TCS_1 = 72, + TMP1075_TCS_2 = 73, +}; - enum spiAddresses: address_t { - RTD_IC_3, - RTD_IC_4, - RTD_IC_5, - RTD_IC_6, - RTD_IC_7, - RTD_IC_8, - RTD_IC_9, - RTD_IC_10, - RTD_IC_11, - RTD_IC_12, - RTD_IC_13, - RTD_IC_14, - RTD_IC_15, - RTD_IC_16, - RTD_IC_17, - RTD_IC_18, - RW1, - RW2, - RW3, - RW4 - }; - - /* Addresses of devices supporting the CSP protocol */ - enum cspAddresses: uint8_t { - P60DOCK = 4, - ACU = 2, - PDU1 = 3, - /* PDU2 occupies X4 slot of P60Dock */ - PDU2 = 6 - }; -} +enum spiAddresses : address_t { + RTD_IC_3, + RTD_IC_4, + RTD_IC_5, + RTD_IC_6, + RTD_IC_7, + RTD_IC_8, + RTD_IC_9, + RTD_IC_10, + RTD_IC_11, + RTD_IC_12, + RTD_IC_13, + RTD_IC_14, + RTD_IC_15, + RTD_IC_16, + RTD_IC_17, + RTD_IC_18, + RW1, + RW2, + RW3, + RW4 +}; +/* Addresses of devices supporting the CSP protocol */ +enum cspAddresses : uint8_t { + P60DOCK = 4, + ACU = 2, + PDU1 = 3, + /* PDU2 occupies X4 slot of P60Dock */ + PDU2 = 6 +}; +} // namespace addresses #endif /* FSFWCONFIG_DEVICES_ADDRESSES_H_ */ diff --git a/linux/fsfwconfig/devices/gpioIds.h b/linux/fsfwconfig/devices/gpioIds.h index e4b9f727..bb753a30 100644 --- a/linux/fsfwconfig/devices/gpioIds.h +++ b/linux/fsfwconfig/devices/gpioIds.h @@ -5,116 +5,112 @@ namespace gpioIds { enum gpioId_t { - HEATER_0, - HEATER_1, - HEATER_2, - HEATER_3, - HEATER_4, - HEATER_5, - HEATER_6, - HEATER_7, - DEPLSA1, - DEPLSA2, + HEATER_0, + HEATER_1, + HEATER_2, + HEATER_3, + HEATER_4, + HEATER_5, + HEATER_6, + HEATER_7, + DEPLSA1, + DEPLSA2, - MGM_0_LIS3_CS, - MGM_1_RM3100_CS, - GYRO_0_ADIS_CS, - GYRO_1_L3G_CS, - GYRO_2_ADIS_CS, - GYRO_3_L3G_CS, - MGM_2_LIS3_CS, - MGM_3_RM3100_CS, + MGM_0_LIS3_CS, + MGM_1_RM3100_CS, + GYRO_0_ADIS_CS, + GYRO_1_L3G_CS, + GYRO_2_ADIS_CS, + GYRO_3_L3G_CS, + MGM_2_LIS3_CS, + MGM_3_RM3100_CS, - GNSS_0_NRESET, - GNSS_1_NRESET, - GNSS_0_ENABLE, - GNSS_1_ENABLE, + GNSS_0_NRESET, + GNSS_1_NRESET, + GNSS_0_ENABLE, + GNSS_1_ENABLE, - GYRO_0_ENABLE, - GYRO_2_ENABLE, + GYRO_0_ENABLE, + GYRO_2_ENABLE, - TEST_ID_0, - TEST_ID_1, + TEST_ID_0, + TEST_ID_1, - RTD_IC_3, - RTD_IC_4, - RTD_IC_5, - RTD_IC_6, - RTD_IC_7, - RTD_IC_8, - RTD_IC_9, - RTD_IC_10, - RTD_IC_11, - RTD_IC_12, - RTD_IC_13, - RTD_IC_14, - RTD_IC_15, - RTD_IC_16, - RTD_IC_17, - RTD_IC_18, + RTD_IC_3, + RTD_IC_4, + RTD_IC_5, + RTD_IC_6, + RTD_IC_7, + RTD_IC_8, + RTD_IC_9, + RTD_IC_10, + RTD_IC_11, + RTD_IC_12, + RTD_IC_13, + RTD_IC_14, + RTD_IC_15, + RTD_IC_16, + RTD_IC_17, + RTD_IC_18, - CS_SUS_1, - CS_SUS_2, - CS_SUS_3, - CS_SUS_4, - CS_SUS_5, - CS_SUS_6, - CS_SUS_7, - CS_SUS_8, - CS_SUS_9, - CS_SUS_10, - CS_SUS_11, - CS_SUS_12, - CS_SUS_13, + CS_SUS_1, + CS_SUS_2, + CS_SUS_3, + CS_SUS_4, + CS_SUS_5, + CS_SUS_6, + CS_SUS_7, + CS_SUS_8, + CS_SUS_9, + CS_SUS_10, + CS_SUS_11, + CS_SUS_12, + CS_SUS_13, - SPI_MUX_BIT_1, - SPI_MUX_BIT_2, - SPI_MUX_BIT_3, - SPI_MUX_BIT_4, - SPI_MUX_BIT_5, - SPI_MUX_BIT_6, + SPI_MUX_BIT_1, + SPI_MUX_BIT_2, + SPI_MUX_BIT_3, + SPI_MUX_BIT_4, + SPI_MUX_BIT_5, + SPI_MUX_BIT_6, - CS_RAD_SENSOR, + CS_RAD_SENSOR, - PAPB_BUSY_N, - PAPB_EMPTY, + PAPB_BUSY_N, + PAPB_EMPTY, - EN_RW1, - EN_RW2, - EN_RW3, - EN_RW4, + EN_RW1, + EN_RW2, + EN_RW3, + EN_RW4, - CS_RW1, - CS_RW2, - CS_RW3, - CS_RW4, + CS_RW1, + CS_RW2, + CS_RW3, + CS_RW4, - EN_RW_CS, + EN_RW_CS, - SPI_MUX, + SPI_MUX, - VC0_PAPB_EMPTY, - VC0_PAPB_BUSY, - VC1_PAPB_EMPTY, - VC1_PAPB_BUSY, - VC2_PAPB_EMPTY, - VC2_PAPB_BUSY, - VC3_PAPB_EMPTY, - VC3_PAPB_BUSY, + VC0_PAPB_EMPTY, + VC0_PAPB_BUSY, + VC1_PAPB_EMPTY, + VC1_PAPB_BUSY, + VC2_PAPB_EMPTY, + VC2_PAPB_BUSY, + VC3_PAPB_EMPTY, + VC3_PAPB_BUSY, - PDEC_RESET, + PDEC_RESET, + RS485_EN_TX_DATA, + RS485_EN_TX_CLOCK, + RS485_EN_RX_DATA, + RS485_EN_RX_CLOCK, - RS485_EN_TX_DATA, - RS485_EN_TX_CLOCK, - RS485_EN_RX_DATA, - RS485_EN_RX_CLOCK, - - BIT_RATE_SEL + BIT_RATE_SEL }; } - - - #endif /* FSFWCONFIG_DEVICES_GPIOIDS_H_ */ diff --git a/linux/fsfwconfig/devices/powerSwitcherList.h b/linux/fsfwconfig/devices/powerSwitcherList.h index bc5731fd..cc6bc141 100644 --- a/linux/fsfwconfig/devices/powerSwitcherList.h +++ b/linux/fsfwconfig/devices/powerSwitcherList.h @@ -4,55 +4,54 @@ #include "OBSWConfig.h" namespace pcduSwitches { - /* Switches are uint8_t datatype and go from 0 to 255 */ - enum SwitcherList: uint8_t { - Q7S, - PAYLOAD_PCDU_CH1, - RW, - TCS_BOARD_8V_HEATER_IN, - SUS_REDUNDANT, - DEPLOYMENT_MECHANISM, - PAYLOAD_PCDU_CH6, - ACS_BOARD_SIDE_B, - PAYLOAD_CAMERA, - TCS_BOARD_3V3, - SYRLINKS, - STAR_TRACKER, - MGT, - SUS_NOMINAL, - SOLAR_CELL_EXP, - PLOC, - ACS_BOARD_SIDE_A, - NUMBER_OF_SWITCHES - }; +/* Switches are uint8_t datatype and go from 0 to 255 */ +enum SwitcherList : uint8_t { + Q7S, + PAYLOAD_PCDU_CH1, + RW, + TCS_BOARD_8V_HEATER_IN, + SUS_REDUNDANT, + DEPLOYMENT_MECHANISM, + PAYLOAD_PCDU_CH6, + ACS_BOARD_SIDE_B, + PAYLOAD_CAMERA, + TCS_BOARD_3V3, + SYRLINKS, + STAR_TRACKER, + MGT, + SUS_NOMINAL, + SOLAR_CELL_EXP, + PLOC, + ACS_BOARD_SIDE_A, + NUMBER_OF_SWITCHES +}; - static const uint8_t ON = 1; - static const uint8_t OFF = 0; +static const uint8_t ON = 1; +static const uint8_t OFF = 0; - /* Output states after reboot of the PDUs */ - static const uint8_t INIT_STATE_Q7S = ON; - static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH1 = OFF; - static const uint8_t INIT_STATE_RW = OFF; +/* Output states after reboot of the PDUs */ +static const uint8_t INIT_STATE_Q7S = ON; +static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH1 = OFF; +static const uint8_t INIT_STATE_RW = OFF; #if BOARD_TE0720 == 1 - /* Because the TE0720 is not connected to the PCDU, this switch is always on */ - static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = ON; +/* Because the TE0720 is not connected to the PCDU, this switch is always on */ +static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = ON; #else - static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = OFF; +static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = OFF; #endif - static const uint8_t INIT_STATE_SUS_REDUNDANT = OFF; - static const uint8_t INIT_STATE_DEPLOYMENT_MECHANISM = OFF; - static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH6 = OFF; - static const uint8_t INIT_STATE_ACS_BOARD_SIDE_B = OFF; - static const uint8_t INIT_STATE_PAYLOAD_CAMERA = OFF; - static const uint8_t INIT_STATE_TCS_BOARD_3V3 = OFF; - static const uint8_t INIT_STATE_SYRLINKS = OFF; - static const uint8_t INIT_STATE_STAR_TRACKER = OFF; - static const uint8_t INIT_STATE_MGT = OFF; - static const uint8_t INIT_STATE_SUS_NOMINAL = OFF; - static const uint8_t INIT_STATE_SOLAR_CELL_EXP = OFF; - static const uint8_t INIT_STATE_PLOC = OFF; - static const uint8_t INIT_STATE_ACS_BOARD_SIDE_A = OFF; -} - +static const uint8_t INIT_STATE_SUS_REDUNDANT = OFF; +static const uint8_t INIT_STATE_DEPLOYMENT_MECHANISM = OFF; +static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH6 = OFF; +static const uint8_t INIT_STATE_ACS_BOARD_SIDE_B = OFF; +static const uint8_t INIT_STATE_PAYLOAD_CAMERA = OFF; +static const uint8_t INIT_STATE_TCS_BOARD_3V3 = OFF; +static const uint8_t INIT_STATE_SYRLINKS = OFF; +static const uint8_t INIT_STATE_STAR_TRACKER = OFF; +static const uint8_t INIT_STATE_MGT = OFF; +static const uint8_t INIT_STATE_SUS_NOMINAL = OFF; +static const uint8_t INIT_STATE_SOLAR_CELL_EXP = OFF; +static const uint8_t INIT_STATE_PLOC = OFF; +static const uint8_t INIT_STATE_ACS_BOARD_SIDE_A = OFF; +} // namespace pcduSwitches #endif /* FSFWCONFIG_DEVICES_POWERSWITCHERLIST_H_ */ diff --git a/linux/fsfwconfig/events/subsystemIdRanges.h b/linux/fsfwconfig/events/subsystemIdRanges.h index 4894be16..33ef1a09 100644 --- a/linux/fsfwconfig/events/subsystemIdRanges.h +++ b/linux/fsfwconfig/events/subsystemIdRanges.h @@ -1,19 +1,19 @@ #ifndef FSFWCONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ #define FSFWCONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ +#include + #include "common/config/commonSubsystemIds.h" #include "fsfw/events/fwSubsystemIdRanges.h" -#include - /** * These IDs are part of the ID for an event thrown by a subsystem. * Numbers 0-80 are reserved for FSFW Subsystem IDs (framework/events/) */ namespace SUBSYSTEM_ID { -enum: uint8_t { - SUBSYSTEM_ID_START = COMMON_SUBSYSTEM_ID_END, - CORE = 116, +enum : uint8_t { + SUBSYSTEM_ID_START = COMMON_SUBSYSTEM_ID_END, + CORE = 116, }; } diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index 17150762..2d028fdd 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -146,290 +146,290 @@ const char *STR_HELPER_FILE_NOT_EXISTS_STRING = "STR_HELPER_FILE_NOT_EXISTS"; const char *STR_HELPER_SENDING_PACKET_FAILED_STRING = "STR_HELPER_SENDING_PACKET_FAILED"; const char *STR_HELPER_REQUESTING_MSG_FAILED_STRING = "STR_HELPER_REQUESTING_MSG_FAILED"; -const char * translateEvents(Event event) { - switch( (event & 0xffff) ) { - case(2200): - return STORE_SEND_WRITE_FAILED_STRING; - case(2201): - return STORE_WRITE_FAILED_STRING; - case(2202): - return STORE_SEND_READ_FAILED_STRING; - case(2203): - return STORE_READ_FAILED_STRING; - case(2204): - return UNEXPECTED_MSG_STRING; - case(2205): - return STORING_FAILED_STRING; - case(2206): - return TM_DUMP_FAILED_STRING; - case(2207): - return STORE_INIT_FAILED_STRING; - case(2208): - return STORE_INIT_EMPTY_STRING; - case(2209): - return STORE_CONTENT_CORRUPTED_STRING; - case(2210): - return STORE_INITIALIZE_STRING; - case(2211): - return INIT_DONE_STRING; - case(2212): - return DUMP_FINISHED_STRING; - case(2213): - return DELETION_FINISHED_STRING; - case(2214): - return DELETION_FAILED_STRING; - case(2215): - return AUTO_CATALOGS_SENDING_FAILED_STRING; - case(2600): - return GET_DATA_FAILED_STRING; - case(2601): - return STORE_DATA_FAILED_STRING; - case(2800): - return DEVICE_BUILDING_COMMAND_FAILED_STRING; - case(2801): - return DEVICE_SENDING_COMMAND_FAILED_STRING; - case(2802): - return DEVICE_REQUESTING_REPLY_FAILED_STRING; - case(2803): - return DEVICE_READING_REPLY_FAILED_STRING; - case(2804): - return DEVICE_INTERPRETING_REPLY_FAILED_STRING; - case(2805): - return DEVICE_MISSED_REPLY_STRING; - case(2806): - return DEVICE_UNKNOWN_REPLY_STRING; - case(2807): - return DEVICE_UNREQUESTED_REPLY_STRING; - case(2808): - return INVALID_DEVICE_COMMAND_STRING; - case(2809): - return MONITORING_LIMIT_EXCEEDED_STRING; - case(2810): - return MONITORING_AMBIGUOUS_STRING; - case(4201): - return FUSE_CURRENT_HIGH_STRING; - case(4202): - return FUSE_WENT_OFF_STRING; - case(4204): - return POWER_ABOVE_HIGH_LIMIT_STRING; - case(4205): - return POWER_BELOW_LOW_LIMIT_STRING; - case(4300): - return SWITCH_WENT_OFF_STRING; - case(5000): - return HEATER_ON_STRING; - case(5001): - return HEATER_OFF_STRING; - case(5002): - return HEATER_TIMEOUT_STRING; - case(5003): - return HEATER_STAYED_ON_STRING; - case(5004): - return HEATER_STAYED_OFF_STRING; - case(5200): - return TEMP_SENSOR_HIGH_STRING; - case(5201): - return TEMP_SENSOR_LOW_STRING; - case(5202): - return TEMP_SENSOR_GRADIENT_STRING; - case(5901): - return COMPONENT_TEMP_LOW_STRING; - case(5902): - return COMPONENT_TEMP_HIGH_STRING; - case(5903): - return COMPONENT_TEMP_OOL_LOW_STRING; - case(5904): - return COMPONENT_TEMP_OOL_HIGH_STRING; - case(5905): - return TEMP_NOT_IN_OP_RANGE_STRING; - case(7101): - return FDIR_CHANGED_STATE_STRING; - case(7102): - return FDIR_STARTS_RECOVERY_STRING; - case(7103): - return FDIR_TURNS_OFF_DEVICE_STRING; - case(7201): - return MONITOR_CHANGED_STATE_STRING; - case(7202): - return VALUE_BELOW_LOW_LIMIT_STRING; - case(7203): - return VALUE_ABOVE_HIGH_LIMIT_STRING; - case(7204): - return VALUE_OUT_OF_RANGE_STRING; - case(7301): - return SWITCHING_TM_FAILED_STRING; - case(7400): - return CHANGING_MODE_STRING; - case(7401): - return MODE_INFO_STRING; - case(7402): - return FALLBACK_FAILED_STRING; - case(7403): - return MODE_TRANSITION_FAILED_STRING; - case(7404): - return CANT_KEEP_MODE_STRING; - case(7405): - return OBJECT_IN_INVALID_MODE_STRING; - case(7406): - return FORCING_MODE_STRING; - case(7407): - return MODE_CMD_REJECTED_STRING; - case(7506): - return HEALTH_INFO_STRING; - case(7507): - return CHILD_CHANGED_HEALTH_STRING; - case(7508): - return CHILD_PROBLEMS_STRING; - case(7509): - return OVERWRITING_HEALTH_STRING; - case(7510): - return TRYING_RECOVERY_STRING; - case(7511): - return RECOVERY_STEP_STRING; - case(7512): - return RECOVERY_DONE_STRING; - case(7900): - return RF_AVAILABLE_STRING; - case(7901): - return RF_LOST_STRING; - case(7902): - return BIT_LOCK_STRING; - case(7903): - return BIT_LOCK_LOST_STRING; - case(7905): - return FRAME_PROCESSING_FAILED_STRING; - case(8900): - return CLOCK_SET_STRING; - case(8901): - return CLOCK_SET_FAILURE_STRING; - case(9700): - return TEST_STRING; - case(10600): - return CHANGE_OF_SETUP_PARAMETER_STRING; - case(10900): - return GPIO_PULL_HIGH_FAILED_STRING; - case(10901): - return GPIO_PULL_LOW_FAILED_STRING; - case(10902): - return SWITCH_ALREADY_ON_STRING; - case(10903): - return SWITCH_ALREADY_OFF_STRING; - case(10904): - return MAIN_SWITCH_TIMEOUT_STRING; - case(11000): - return MAIN_SWITCH_ON_TIMEOUT_STRING; - case(11001): - return MAIN_SWITCH_OFF_TIMEOUT_STRING; - case(11002): - return DEPLOYMENT_FAILED_STRING; - case(11003): - return DEPL_SA1_GPIO_SWTICH_ON_FAILED_STRING; - case(11004): - return DEPL_SA2_GPIO_SWTICH_ON_FAILED_STRING; - case(11101): - return MEMORY_READ_RPT_CRC_FAILURE_STRING; - case(11102): - return ACK_FAILURE_STRING; - case(11103): - return EXE_FAILURE_STRING; - case(11104): - return CRC_FAILURE_EVENT_STRING; - case(11201): - return SELF_TEST_I2C_FAILURE_STRING; - case(11202): - return SELF_TEST_SPI_FAILURE_STRING; - case(11203): - return SELF_TEST_ADC_FAILURE_STRING; - case(11204): - return SELF_TEST_PWM_FAILURE_STRING; - case(11205): - return SELF_TEST_TC_FAILURE_STRING; - case(11206): - return SELF_TEST_MTM_RANGE_FAILURE_STRING; - case(11207): - return SELF_TEST_COIL_CURRENT_FAILURE_STRING; - case(11208): - return INVALID_ERROR_BYTE_STRING; - case(11301): - return ERROR_STATE_STRING; - case(11501): - return SUPV_MEMORY_READ_RPT_CRC_FAILURE_STRING; - case(11502): - return SUPV_ACK_FAILURE_STRING; - case(11503): - return SUPV_EXE_FAILURE_STRING; - case(11504): - return SUPV_CRC_FAILURE_EVENT_STRING; - case(11600): - return SANITIZATION_FAILED_STRING; - case(11700): - return UPDATE_FILE_NOT_EXISTS_STRING; - case(11701): - return ACTION_COMMANDING_FAILED_STRING; - case(11702): - return UPDATE_AVAILABLE_FAILED_STRING; - case(11703): - return UPDATE_TRANSFER_FAILED_STRING; - case(11704): - return UPDATE_VERIFY_FAILED_STRING; - case(11705): - return UPDATE_FINISHED_STRING; - case(11800): - return SEND_MRAM_DUMP_FAILED_STRING; - case(11801): - return MRAM_DUMP_FAILED_STRING; - case(11802): - return MRAM_DUMP_FINISHED_STRING; - case(11901): - return INVALID_TC_FRAME_STRING; - case(11902): - return INVALID_FAR_STRING; - case(11903): - return CARRIER_LOCK_STRING; - case(11904): - return BIT_LOCK_PDEC_STRING; - case(12000): - return IMAGE_UPLOAD_FAILED_STRING; - case(12001): - return IMAGE_DOWNLOAD_FAILED_STRING; - case(12002): - return IMAGE_UPLOAD_SUCCESSFUL_STRING; - case(12003): - return IMAGE_DOWNLOAD_SUCCESSFUL_STRING; - case(12004): - return FLASH_WRITE_SUCCESSFUL_STRING; - case(12005): - return FLASH_READ_SUCCESSFUL_STRING; - case(12006): - return FLASH_WRITE_FAILED_STRING; - case(12007): - return FLASH_READ_FAILED_STRING; - case(12008): - return FPGA_DOWNLOAD_SUCCESSFUL_STRING; - case(12009): - return FPGA_DOWNLOAD_FAILED_STRING; - case(12010): - return FPGA_UPLOAD_SUCCESSFUL_STRING; - case(12011): - return FPGA_UPLOAD_FAILED_STRING; - case(12012): - return STR_HELPER_READING_REPLY_FAILED_STRING; - case(12013): - return STR_HELPER_COM_ERROR_STRING; - case(12014): - return STR_HELPER_NO_REPLY_STRING; - case(12015): - return STR_HELPER_DEC_ERROR_STRING; - case(12016): - return POSITION_MISMATCH_STRING; - case(12017): - return STR_HELPER_FILE_NOT_EXISTS_STRING; - case(12018): - return STR_HELPER_SENDING_PACKET_FAILED_STRING; - case(12019): - return STR_HELPER_REQUESTING_MSG_FAILED_STRING; - default: - return "UNKNOWN_EVENT"; - } - return 0; +const char *translateEvents(Event event) { + switch ((event & 0xffff)) { + case (2200): + return STORE_SEND_WRITE_FAILED_STRING; + case (2201): + return STORE_WRITE_FAILED_STRING; + case (2202): + return STORE_SEND_READ_FAILED_STRING; + case (2203): + return STORE_READ_FAILED_STRING; + case (2204): + return UNEXPECTED_MSG_STRING; + case (2205): + return STORING_FAILED_STRING; + case (2206): + return TM_DUMP_FAILED_STRING; + case (2207): + return STORE_INIT_FAILED_STRING; + case (2208): + return STORE_INIT_EMPTY_STRING; + case (2209): + return STORE_CONTENT_CORRUPTED_STRING; + case (2210): + return STORE_INITIALIZE_STRING; + case (2211): + return INIT_DONE_STRING; + case (2212): + return DUMP_FINISHED_STRING; + case (2213): + return DELETION_FINISHED_STRING; + case (2214): + return DELETION_FAILED_STRING; + case (2215): + return AUTO_CATALOGS_SENDING_FAILED_STRING; + case (2600): + return GET_DATA_FAILED_STRING; + case (2601): + return STORE_DATA_FAILED_STRING; + case (2800): + return DEVICE_BUILDING_COMMAND_FAILED_STRING; + case (2801): + return DEVICE_SENDING_COMMAND_FAILED_STRING; + case (2802): + return DEVICE_REQUESTING_REPLY_FAILED_STRING; + case (2803): + return DEVICE_READING_REPLY_FAILED_STRING; + case (2804): + return DEVICE_INTERPRETING_REPLY_FAILED_STRING; + case (2805): + return DEVICE_MISSED_REPLY_STRING; + case (2806): + return DEVICE_UNKNOWN_REPLY_STRING; + case (2807): + return DEVICE_UNREQUESTED_REPLY_STRING; + case (2808): + return INVALID_DEVICE_COMMAND_STRING; + case (2809): + return MONITORING_LIMIT_EXCEEDED_STRING; + case (2810): + return MONITORING_AMBIGUOUS_STRING; + case (4201): + return FUSE_CURRENT_HIGH_STRING; + case (4202): + return FUSE_WENT_OFF_STRING; + case (4204): + return POWER_ABOVE_HIGH_LIMIT_STRING; + case (4205): + return POWER_BELOW_LOW_LIMIT_STRING; + case (4300): + return SWITCH_WENT_OFF_STRING; + case (5000): + return HEATER_ON_STRING; + case (5001): + return HEATER_OFF_STRING; + case (5002): + return HEATER_TIMEOUT_STRING; + case (5003): + return HEATER_STAYED_ON_STRING; + case (5004): + return HEATER_STAYED_OFF_STRING; + case (5200): + return TEMP_SENSOR_HIGH_STRING; + case (5201): + return TEMP_SENSOR_LOW_STRING; + case (5202): + return TEMP_SENSOR_GRADIENT_STRING; + case (5901): + return COMPONENT_TEMP_LOW_STRING; + case (5902): + return COMPONENT_TEMP_HIGH_STRING; + case (5903): + return COMPONENT_TEMP_OOL_LOW_STRING; + case (5904): + return COMPONENT_TEMP_OOL_HIGH_STRING; + case (5905): + return TEMP_NOT_IN_OP_RANGE_STRING; + case (7101): + return FDIR_CHANGED_STATE_STRING; + case (7102): + return FDIR_STARTS_RECOVERY_STRING; + case (7103): + return FDIR_TURNS_OFF_DEVICE_STRING; + case (7201): + return MONITOR_CHANGED_STATE_STRING; + case (7202): + return VALUE_BELOW_LOW_LIMIT_STRING; + case (7203): + return VALUE_ABOVE_HIGH_LIMIT_STRING; + case (7204): + return VALUE_OUT_OF_RANGE_STRING; + case (7301): + return SWITCHING_TM_FAILED_STRING; + case (7400): + return CHANGING_MODE_STRING; + case (7401): + return MODE_INFO_STRING; + case (7402): + return FALLBACK_FAILED_STRING; + case (7403): + return MODE_TRANSITION_FAILED_STRING; + case (7404): + return CANT_KEEP_MODE_STRING; + case (7405): + return OBJECT_IN_INVALID_MODE_STRING; + case (7406): + return FORCING_MODE_STRING; + case (7407): + return MODE_CMD_REJECTED_STRING; + case (7506): + return HEALTH_INFO_STRING; + case (7507): + return CHILD_CHANGED_HEALTH_STRING; + case (7508): + return CHILD_PROBLEMS_STRING; + case (7509): + return OVERWRITING_HEALTH_STRING; + case (7510): + return TRYING_RECOVERY_STRING; + case (7511): + return RECOVERY_STEP_STRING; + case (7512): + return RECOVERY_DONE_STRING; + case (7900): + return RF_AVAILABLE_STRING; + case (7901): + return RF_LOST_STRING; + case (7902): + return BIT_LOCK_STRING; + case (7903): + return BIT_LOCK_LOST_STRING; + case (7905): + return FRAME_PROCESSING_FAILED_STRING; + case (8900): + return CLOCK_SET_STRING; + case (8901): + return CLOCK_SET_FAILURE_STRING; + case (9700): + return TEST_STRING; + case (10600): + return CHANGE_OF_SETUP_PARAMETER_STRING; + case (10900): + return GPIO_PULL_HIGH_FAILED_STRING; + case (10901): + return GPIO_PULL_LOW_FAILED_STRING; + case (10902): + return SWITCH_ALREADY_ON_STRING; + case (10903): + return SWITCH_ALREADY_OFF_STRING; + case (10904): + return MAIN_SWITCH_TIMEOUT_STRING; + case (11000): + return MAIN_SWITCH_ON_TIMEOUT_STRING; + case (11001): + return MAIN_SWITCH_OFF_TIMEOUT_STRING; + case (11002): + return DEPLOYMENT_FAILED_STRING; + case (11003): + return DEPL_SA1_GPIO_SWTICH_ON_FAILED_STRING; + case (11004): + return DEPL_SA2_GPIO_SWTICH_ON_FAILED_STRING; + case (11101): + return MEMORY_READ_RPT_CRC_FAILURE_STRING; + case (11102): + return ACK_FAILURE_STRING; + case (11103): + return EXE_FAILURE_STRING; + case (11104): + return CRC_FAILURE_EVENT_STRING; + case (11201): + return SELF_TEST_I2C_FAILURE_STRING; + case (11202): + return SELF_TEST_SPI_FAILURE_STRING; + case (11203): + return SELF_TEST_ADC_FAILURE_STRING; + case (11204): + return SELF_TEST_PWM_FAILURE_STRING; + case (11205): + return SELF_TEST_TC_FAILURE_STRING; + case (11206): + return SELF_TEST_MTM_RANGE_FAILURE_STRING; + case (11207): + return SELF_TEST_COIL_CURRENT_FAILURE_STRING; + case (11208): + return INVALID_ERROR_BYTE_STRING; + case (11301): + return ERROR_STATE_STRING; + case (11501): + return SUPV_MEMORY_READ_RPT_CRC_FAILURE_STRING; + case (11502): + return SUPV_ACK_FAILURE_STRING; + case (11503): + return SUPV_EXE_FAILURE_STRING; + case (11504): + return SUPV_CRC_FAILURE_EVENT_STRING; + case (11600): + return SANITIZATION_FAILED_STRING; + case (11700): + return UPDATE_FILE_NOT_EXISTS_STRING; + case (11701): + return ACTION_COMMANDING_FAILED_STRING; + case (11702): + return UPDATE_AVAILABLE_FAILED_STRING; + case (11703): + return UPDATE_TRANSFER_FAILED_STRING; + case (11704): + return UPDATE_VERIFY_FAILED_STRING; + case (11705): + return UPDATE_FINISHED_STRING; + case (11800): + return SEND_MRAM_DUMP_FAILED_STRING; + case (11801): + return MRAM_DUMP_FAILED_STRING; + case (11802): + return MRAM_DUMP_FINISHED_STRING; + case (11901): + return INVALID_TC_FRAME_STRING; + case (11902): + return INVALID_FAR_STRING; + case (11903): + return CARRIER_LOCK_STRING; + case (11904): + return BIT_LOCK_PDEC_STRING; + case (12000): + return IMAGE_UPLOAD_FAILED_STRING; + case (12001): + return IMAGE_DOWNLOAD_FAILED_STRING; + case (12002): + return IMAGE_UPLOAD_SUCCESSFUL_STRING; + case (12003): + return IMAGE_DOWNLOAD_SUCCESSFUL_STRING; + case (12004): + return FLASH_WRITE_SUCCESSFUL_STRING; + case (12005): + return FLASH_READ_SUCCESSFUL_STRING; + case (12006): + return FLASH_WRITE_FAILED_STRING; + case (12007): + return FLASH_READ_FAILED_STRING; + case (12008): + return FPGA_DOWNLOAD_SUCCESSFUL_STRING; + case (12009): + return FPGA_DOWNLOAD_FAILED_STRING; + case (12010): + return FPGA_UPLOAD_SUCCESSFUL_STRING; + case (12011): + return FPGA_UPLOAD_FAILED_STRING; + case (12012): + return STR_HELPER_READING_REPLY_FAILED_STRING; + case (12013): + return STR_HELPER_COM_ERROR_STRING; + case (12014): + return STR_HELPER_NO_REPLY_STRING; + case (12015): + return STR_HELPER_DEC_ERROR_STRING; + case (12016): + return POSITION_MISMATCH_STRING; + case (12017): + return STR_HELPER_FILE_NOT_EXISTS_STRING; + case (12018): + return STR_HELPER_SENDING_PACKET_FAILED_STRING; + case (12019): + return STR_HELPER_REQUESTING_MSG_FAILED_STRING; + default: + return "UNKNOWN_EVENT"; + } + return 0; } diff --git a/linux/fsfwconfig/events/translateEvents.h b/linux/fsfwconfig/events/translateEvents.h index bdabb21b..1b8a8831 100644 --- a/linux/fsfwconfig/events/translateEvents.h +++ b/linux/fsfwconfig/events/translateEvents.h @@ -3,6 +3,6 @@ #include "fsfw/events/Event.h" -const char * translateEvents(Event event); +const char* translateEvents(Event event); #endif /* FSFWCONFIG_EVENTS_TRANSLATEEVENTS_H_ */ diff --git a/linux/fsfwconfig/ipc/MissionMessageTypes.cpp b/linux/fsfwconfig/ipc/MissionMessageTypes.cpp index 9ac6f0f4..fa1c4877 100644 --- a/linux/fsfwconfig/ipc/MissionMessageTypes.cpp +++ b/linux/fsfwconfig/ipc/MissionMessageTypes.cpp @@ -1,12 +1,10 @@ #include "MissionMessageTypes.h" + #include - void messagetypes::clearMissionMessage(CommandMessage* message) { - switch(message->getMessageType()) { - default: - break; - } + switch (message->getMessageType()) { + default: + break; + } } - - diff --git a/linux/fsfwconfig/ipc/MissionMessageTypes.h b/linux/fsfwconfig/ipc/MissionMessageTypes.h index ab2a84b5..78b0d343 100644 --- a/linux/fsfwconfig/ipc/MissionMessageTypes.h +++ b/linux/fsfwconfig/ipc/MissionMessageTypes.h @@ -11,12 +11,12 @@ class CommandMessage; * * @param message Generic Command Message */ -namespace messagetypes{ +namespace messagetypes { enum MESSAGE_TYPE { - MISSION_MESSAGE_TYPE_START = FW_MESSAGES_COUNT, + MISSION_MESSAGE_TYPE_START = FW_MESSAGES_COUNT, }; void clearMissionMessage(CommandMessage* message); -} +} // namespace messagetypes #endif /* FSFWCONFIG_IPC_MISSIONMESSAGETYPES_H_ */ diff --git a/linux/fsfwconfig/objects/systemObjectList.h b/linux/fsfwconfig/objects/systemObjectList.h index a8929187..c868730b 100644 --- a/linux/fsfwconfig/objects/systemObjectList.h +++ b/linux/fsfwconfig/objects/systemObjectList.h @@ -1,10 +1,12 @@ #ifndef HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ #define HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ -#include "commonObjects.h" #include + #include +#include "commonObjects.h" + // The objects will be instantiated in the ID order // For naming scheme see flight manual /* @@ -31,38 +33,38 @@ Fourth byte is a unique counter. */ namespace objects { -enum sourceObjects: uint32_t { - /* 0x53 reserved for FSFW */ - FW_ADDRESS_START = PUS_SERVICE_1_VERIFICATION, - FW_ADDRESS_END = TIME_STAMPER, - PUS_SERVICE_6 = 0x51000500, +enum sourceObjects : uint32_t { + /* 0x53 reserved for FSFW */ + FW_ADDRESS_START = PUS_SERVICE_1_VERIFICATION, + FW_ADDRESS_END = TIME_STAMPER, + PUS_SERVICE_6 = 0x51000500, - CCSDS_IP_CORE_BRIDGE = 0x73500000, - TM_FUNNEL = 0x73000100, + CCSDS_IP_CORE_BRIDGE = 0x73500000, + TM_FUNNEL = 0x73000100, - /* 0x49 ('I') for Communication Interfaces **/ - ARDUINO_COM_IF = 0x49000000, - CSP_COM_IF = 0x49050001, - I2C_COM_IF = 0x49040002, - UART_COM_IF = 0x49030003, - SPI_COM_IF = 0x49020004, - GPIO_IF = 0x49010005, + /* 0x49 ('I') for Communication Interfaces **/ + ARDUINO_COM_IF = 0x49000000, + CSP_COM_IF = 0x49050001, + I2C_COM_IF = 0x49040002, + UART_COM_IF = 0x49030003, + SPI_COM_IF = 0x49020004, + GPIO_IF = 0x49010005, - /* Custom device handler */ - PCDU_HANDLER = 0x442000A1, - SOLAR_ARRAY_DEPL_HANDLER = 0x444100A2, - SYRLINKS_HK_HANDLER = 0x445300A3, - HEATER_HANDLER = 0x444100A4, - RAD_SENSOR = 0x443200A5, + /* Custom device handler */ + PCDU_HANDLER = 0x442000A1, + SOLAR_ARRAY_DEPL_HANDLER = 0x444100A2, + SYRLINKS_HK_HANDLER = 0x445300A3, + HEATER_HANDLER = 0x444100A4, + RAD_SENSOR = 0x443200A5, - /* 0x54 ('T') for test handlers */ - TEST_TASK = 0x54694269, - LIBGPIOD_TEST = 0x54123456, - SPI_TEST = 0x54000010, - UART_TEST = 0x54000020, - DUMMY_INTERFACE = 0x5400CAFE, - DUMMY_HANDLER = 0x5400AFFE, - P60DOCK_TEST_TASK = 0x00005060, + /* 0x54 ('T') for test handlers */ + TEST_TASK = 0x54694269, + LIBGPIOD_TEST = 0x54123456, + SPI_TEST = 0x54000010, + UART_TEST = 0x54000020, + DUMMY_INTERFACE = 0x5400CAFE, + DUMMY_HANDLER = 0x5400AFFE, + P60DOCK_TEST_TASK = 0x00005060, }; } diff --git a/linux/fsfwconfig/objects/translateObjects.cpp b/linux/fsfwconfig/objects/translateObjects.cpp index 49900a5d..56cbc575 100644 --- a/linux/fsfwconfig/objects/translateObjects.cpp +++ b/linux/fsfwconfig/objects/translateObjects.cpp @@ -120,236 +120,236 @@ const char *TM_FUNNEL_STRING = "TM_FUNNEL"; const char *CCSDS_IP_CORE_BRIDGE_STRING = "CCSDS_IP_CORE_BRIDGE"; const char *NO_OBJECT_STRING = "NO_OBJECT"; -const char* translateObject(object_id_t object) { - switch( (object & 0xFFFFFFFF) ) { - case 0x00005060: - return P60DOCK_TEST_TASK_STRING; - case 0x43000003: - return CORE_CONTROLLER_STRING; - case 0x43100002: - return ACS_CONTROLLER_STRING; - case 0x43400001: - return THERMAL_CONTROLLER_STRING; - case 0x44120006: - return MGM_0_LIS3_HANDLER_STRING; - case 0x44120010: - return GYRO_0_ADIS_HANDLER_STRING; - case 0x44120032: - return SUS_1_STRING; - case 0x44120033: - return SUS_2_STRING; - case 0x44120034: - return SUS_3_STRING; - case 0x44120035: - return SUS_4_STRING; - case 0x44120036: - return SUS_5_STRING; - case 0x44120037: - return SUS_6_STRING; - case 0x44120038: - return SUS_7_STRING; - case 0x44120039: - return SUS_8_STRING; - case 0x44120040: - return SUS_9_STRING; - case 0x44120041: - return SUS_10_STRING; - case 0x44120042: - return SUS_11_STRING; - case 0x44120043: - return SUS_12_STRING; - case 0x44120044: - return SUS_13_STRING; - case 0x44120047: - return RW1_STRING; - case 0x44120107: - return MGM_1_RM3100_HANDLER_STRING; - case 0x44120111: - return GYRO_1_L3G_HANDLER_STRING; - case 0x44120148: - return RW2_STRING; - case 0x44120208: - return MGM_2_LIS3_HANDLER_STRING; - case 0x44120212: - return GYRO_2_ADIS_HANDLER_STRING; - case 0x44120249: - return RW3_STRING; - case 0x44120309: - return MGM_3_RM3100_HANDLER_STRING; - case 0x44120313: - return GYRO_3_L3G_HANDLER_STRING; - case 0x44120350: - return RW4_STRING; - case 0x44130001: - return STAR_TRACKER_STRING; - case 0x44130045: - return GPS0_HANDLER_STRING; - case 0x44130146: - return GPS1_HANDLER_STRING; - case 0x44140014: - return IMTQ_HANDLER_STRING; - case 0x442000A1: - return PCDU_HANDLER_STRING; - case 0x44250000: - return P60DOCK_HANDLER_STRING; - case 0x44250001: - return PDU1_HANDLER_STRING; - case 0x44250002: - return PDU2_HANDLER_STRING; - case 0x44250003: - return ACU_HANDLER_STRING; - case 0x443200A5: - return RAD_SENSOR_STRING; - case 0x44330000: - return PLOC_UPDATER_STRING; - case 0x44330001: - return PLOC_MEMORY_DUMPER_STRING; - case 0x44330002: - return STR_HELPER_STRING; - case 0x44330015: - return PLOC_MPSOC_HANDLER_STRING; - case 0x44330016: - return PLOC_SUPERVISOR_HANDLER_STRING; - case 0x444100A2: - return SOLAR_ARRAY_DEPL_HANDLER_STRING; - case 0x444100A4: - return HEATER_HANDLER_STRING; - case 0x44420004: - return TMP1075_HANDLER_1_STRING; - case 0x44420005: - return TMP1075_HANDLER_2_STRING; - case 0x44420016: - return RTD_IC_3_STRING; - case 0x44420017: - return RTD_IC_4_STRING; - case 0x44420018: - return RTD_IC_5_STRING; - case 0x44420019: - return RTD_IC_6_STRING; - case 0x44420020: - return RTD_IC_7_STRING; - case 0x44420021: - return RTD_IC_8_STRING; - case 0x44420022: - return RTD_IC_9_STRING; - case 0x44420023: - return RTD_IC_10_STRING; - case 0x44420024: - return RTD_IC_11_STRING; - case 0x44420025: - return RTD_IC_12_STRING; - case 0x44420026: - return RTD_IC_13_STRING; - case 0x44420027: - return RTD_IC_14_STRING; - case 0x44420028: - return RTD_IC_15_STRING; - case 0x44420029: - return RTD_IC_16_STRING; - case 0x44420030: - return RTD_IC_17_STRING; - case 0x44420031: - return RTD_IC_18_STRING; - case 0x445300A3: - return SYRLINKS_HK_HANDLER_STRING; - case 0x49000000: - return ARDUINO_COM_IF_STRING; - case 0x49010005: - return GPIO_IF_STRING; - case 0x49020004: - return SPI_COM_IF_STRING; - case 0x49030003: - return UART_COM_IF_STRING; - case 0x49040002: - return I2C_COM_IF_STRING; - case 0x49050001: - return CSP_COM_IF_STRING; - case 0x50000100: - return CCSDS_PACKET_DISTRIBUTOR_STRING; - case 0x50000200: - return PUS_PACKET_DISTRIBUTOR_STRING; - case 0x50000300: - return TMTC_BRIDGE_STRING; - case 0x50000400: - return TMTC_POLLING_TASK_STRING; - case 0x50000500: - return FILE_SYSTEM_HANDLER_STRING; - case 0x50000600: - return PTME_STRING; - case 0x50000700: - return PAPB_VC0_STRING; - case 0x50000701: - return PAPB_VC1_STRING; - case 0x50000702: - return PAPB_VC2_STRING; - case 0x50000703: - return PAPB_VC3_STRING; - case 0x50000704: - return PDEC_HANDLER_STRING; - case 0x50000800: - return CCSDS_HANDLER_STRING; - case 0x51000500: - return PUS_SERVICE_6_STRING; - case 0x53000000: - return FSFW_OBJECTS_START_STRING; - case 0x53000001: - return PUS_SERVICE_1_VERIFICATION_STRING; - case 0x53000002: - return PUS_SERVICE_2_DEVICE_ACCESS_STRING; - case 0x53000003: - return PUS_SERVICE_3_HOUSEKEEPING_STRING; - case 0x53000005: - return PUS_SERVICE_5_EVENT_REPORTING_STRING; - case 0x53000008: - return PUS_SERVICE_8_FUNCTION_MGMT_STRING; - case 0x53000009: - return PUS_SERVICE_9_TIME_MGMT_STRING; - case 0x53000017: - return PUS_SERVICE_17_TEST_STRING; - case 0x53000020: - return PUS_SERVICE_20_PARAMETERS_STRING; - case 0x53000200: - return PUS_SERVICE_200_MODE_MGMT_STRING; - case 0x53000201: - return PUS_SERVICE_201_HEALTH_STRING; - case 0x53010000: - return HEALTH_TABLE_STRING; - case 0x53010100: - return MODE_STORE_STRING; - case 0x53030000: - return EVENT_MANAGER_STRING; - case 0x53040000: - return INTERNAL_ERROR_REPORTER_STRING; - case 0x534f0100: - return TC_STORE_STRING; - case 0x534f0200: - return TM_STORE_STRING; - case 0x534f0300: - return IPC_STORE_STRING; - case 0x53500010: - return TIME_STAMPER_STRING; - case 0x53ffffff: - return FSFW_OBJECTS_END_STRING; - case 0x54000010: - return SPI_TEST_STRING; - case 0x54000020: - return UART_TEST_STRING; - case 0x5400AFFE: - return DUMMY_HANDLER_STRING; - case 0x5400CAFE: - return DUMMY_INTERFACE_STRING; - case 0x54123456: - return LIBGPIOD_TEST_STRING; - case 0x54694269: - return TEST_TASK_STRING; - case 0x73000100: - return TM_FUNNEL_STRING; - case 0x73500000: - return CCSDS_IP_CORE_BRIDGE_STRING; - case 0xFFFFFFFF: - return NO_OBJECT_STRING; - default: - return "UNKNOWN_OBJECT"; - } - return 0; +const char *translateObject(object_id_t object) { + switch ((object & 0xFFFFFFFF)) { + case 0x00005060: + return P60DOCK_TEST_TASK_STRING; + case 0x43000003: + return CORE_CONTROLLER_STRING; + case 0x43100002: + return ACS_CONTROLLER_STRING; + case 0x43400001: + return THERMAL_CONTROLLER_STRING; + case 0x44120006: + return MGM_0_LIS3_HANDLER_STRING; + case 0x44120010: + return GYRO_0_ADIS_HANDLER_STRING; + case 0x44120032: + return SUS_1_STRING; + case 0x44120033: + return SUS_2_STRING; + case 0x44120034: + return SUS_3_STRING; + case 0x44120035: + return SUS_4_STRING; + case 0x44120036: + return SUS_5_STRING; + case 0x44120037: + return SUS_6_STRING; + case 0x44120038: + return SUS_7_STRING; + case 0x44120039: + return SUS_8_STRING; + case 0x44120040: + return SUS_9_STRING; + case 0x44120041: + return SUS_10_STRING; + case 0x44120042: + return SUS_11_STRING; + case 0x44120043: + return SUS_12_STRING; + case 0x44120044: + return SUS_13_STRING; + case 0x44120047: + return RW1_STRING; + case 0x44120107: + return MGM_1_RM3100_HANDLER_STRING; + case 0x44120111: + return GYRO_1_L3G_HANDLER_STRING; + case 0x44120148: + return RW2_STRING; + case 0x44120208: + return MGM_2_LIS3_HANDLER_STRING; + case 0x44120212: + return GYRO_2_ADIS_HANDLER_STRING; + case 0x44120249: + return RW3_STRING; + case 0x44120309: + return MGM_3_RM3100_HANDLER_STRING; + case 0x44120313: + return GYRO_3_L3G_HANDLER_STRING; + case 0x44120350: + return RW4_STRING; + case 0x44130001: + return STAR_TRACKER_STRING; + case 0x44130045: + return GPS0_HANDLER_STRING; + case 0x44130146: + return GPS1_HANDLER_STRING; + case 0x44140014: + return IMTQ_HANDLER_STRING; + case 0x442000A1: + return PCDU_HANDLER_STRING; + case 0x44250000: + return P60DOCK_HANDLER_STRING; + case 0x44250001: + return PDU1_HANDLER_STRING; + case 0x44250002: + return PDU2_HANDLER_STRING; + case 0x44250003: + return ACU_HANDLER_STRING; + case 0x443200A5: + return RAD_SENSOR_STRING; + case 0x44330000: + return PLOC_UPDATER_STRING; + case 0x44330001: + return PLOC_MEMORY_DUMPER_STRING; + case 0x44330002: + return STR_HELPER_STRING; + case 0x44330015: + return PLOC_MPSOC_HANDLER_STRING; + case 0x44330016: + return PLOC_SUPERVISOR_HANDLER_STRING; + case 0x444100A2: + return SOLAR_ARRAY_DEPL_HANDLER_STRING; + case 0x444100A4: + return HEATER_HANDLER_STRING; + case 0x44420004: + return TMP1075_HANDLER_1_STRING; + case 0x44420005: + return TMP1075_HANDLER_2_STRING; + case 0x44420016: + return RTD_IC_3_STRING; + case 0x44420017: + return RTD_IC_4_STRING; + case 0x44420018: + return RTD_IC_5_STRING; + case 0x44420019: + return RTD_IC_6_STRING; + case 0x44420020: + return RTD_IC_7_STRING; + case 0x44420021: + return RTD_IC_8_STRING; + case 0x44420022: + return RTD_IC_9_STRING; + case 0x44420023: + return RTD_IC_10_STRING; + case 0x44420024: + return RTD_IC_11_STRING; + case 0x44420025: + return RTD_IC_12_STRING; + case 0x44420026: + return RTD_IC_13_STRING; + case 0x44420027: + return RTD_IC_14_STRING; + case 0x44420028: + return RTD_IC_15_STRING; + case 0x44420029: + return RTD_IC_16_STRING; + case 0x44420030: + return RTD_IC_17_STRING; + case 0x44420031: + return RTD_IC_18_STRING; + case 0x445300A3: + return SYRLINKS_HK_HANDLER_STRING; + case 0x49000000: + return ARDUINO_COM_IF_STRING; + case 0x49010005: + return GPIO_IF_STRING; + case 0x49020004: + return SPI_COM_IF_STRING; + case 0x49030003: + return UART_COM_IF_STRING; + case 0x49040002: + return I2C_COM_IF_STRING; + case 0x49050001: + return CSP_COM_IF_STRING; + case 0x50000100: + return CCSDS_PACKET_DISTRIBUTOR_STRING; + case 0x50000200: + return PUS_PACKET_DISTRIBUTOR_STRING; + case 0x50000300: + return TMTC_BRIDGE_STRING; + case 0x50000400: + return TMTC_POLLING_TASK_STRING; + case 0x50000500: + return FILE_SYSTEM_HANDLER_STRING; + case 0x50000600: + return PTME_STRING; + case 0x50000700: + return PAPB_VC0_STRING; + case 0x50000701: + return PAPB_VC1_STRING; + case 0x50000702: + return PAPB_VC2_STRING; + case 0x50000703: + return PAPB_VC3_STRING; + case 0x50000704: + return PDEC_HANDLER_STRING; + case 0x50000800: + return CCSDS_HANDLER_STRING; + case 0x51000500: + return PUS_SERVICE_6_STRING; + case 0x53000000: + return FSFW_OBJECTS_START_STRING; + case 0x53000001: + return PUS_SERVICE_1_VERIFICATION_STRING; + case 0x53000002: + return PUS_SERVICE_2_DEVICE_ACCESS_STRING; + case 0x53000003: + return PUS_SERVICE_3_HOUSEKEEPING_STRING; + case 0x53000005: + return PUS_SERVICE_5_EVENT_REPORTING_STRING; + case 0x53000008: + return PUS_SERVICE_8_FUNCTION_MGMT_STRING; + case 0x53000009: + return PUS_SERVICE_9_TIME_MGMT_STRING; + case 0x53000017: + return PUS_SERVICE_17_TEST_STRING; + case 0x53000020: + return PUS_SERVICE_20_PARAMETERS_STRING; + case 0x53000200: + return PUS_SERVICE_200_MODE_MGMT_STRING; + case 0x53000201: + return PUS_SERVICE_201_HEALTH_STRING; + case 0x53010000: + return HEALTH_TABLE_STRING; + case 0x53010100: + return MODE_STORE_STRING; + case 0x53030000: + return EVENT_MANAGER_STRING; + case 0x53040000: + return INTERNAL_ERROR_REPORTER_STRING; + case 0x534f0100: + return TC_STORE_STRING; + case 0x534f0200: + return TM_STORE_STRING; + case 0x534f0300: + return IPC_STORE_STRING; + case 0x53500010: + return TIME_STAMPER_STRING; + case 0x53ffffff: + return FSFW_OBJECTS_END_STRING; + case 0x54000010: + return SPI_TEST_STRING; + case 0x54000020: + return UART_TEST_STRING; + case 0x5400AFFE: + return DUMMY_HANDLER_STRING; + case 0x5400CAFE: + return DUMMY_INTERFACE_STRING; + case 0x54123456: + return LIBGPIOD_TEST_STRING; + case 0x54694269: + return TEST_TASK_STRING; + case 0x73000100: + return TM_FUNNEL_STRING; + case 0x73500000: + return CCSDS_IP_CORE_BRIDGE_STRING; + case 0xFFFFFFFF: + return NO_OBJECT_STRING; + default: + return "UNKNOWN_OBJECT"; + } + return 0; } diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 82748821..814e5c2d 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -1,792 +1,730 @@ #include "pollingSequenceFactory.h" -#include "linux/devices/SusHandler.h" -#include "OBSWConfig.h" +#include #include #include -#include #include + +#include "OBSWConfig.h" +#include "linux/devices/SusHandler.h" #include "objects/systemObjectList.h" +ReturnValue_t pst::pstGpio(FixedTimeslotTaskIF *thisSequence) { + // Length of a communication cycle + uint32_t length = thisSequence->getPeriodMs(); -ReturnValue_t pst::pstGpio(FixedTimeslotTaskIF *thisSequence) -{ - // Length of a communication cycle - uint32_t length = thisSequence->getPeriodMs(); + thisSequence->addSlot(objects::HEATER_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SOLAR_ARRAY_DEPL_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::HEATER_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SOLAR_ARRAY_DEPL_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); + if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { + return HasReturnvaluesIF::RETURN_OK; + } - if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { - return HasReturnvaluesIF::RETURN_OK; - } - - sif::error << "PollingSequence::initialize has errors!" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; + sif::error << "PollingSequence::initialize has errors!" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; } ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { - uint32_t length = thisSequence->getPeriodMs(); - static_cast(length); + uint32_t length = thisSequence->getPeriodMs(); + static_cast(length); #if OBSW_ADD_TMP_DEVICES == 1 - thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0, DeviceHandlerIF::PERFORM_OPERATION); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC_3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_5, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_6, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_7, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_8, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_9, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_10, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_11, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_12, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_13, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_14, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_15, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_16, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_17, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_18, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_5, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_6, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_7, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_8, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_9, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_10, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_11, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_12, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_13, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_14, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_15, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_16, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_17, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_18, length * 0, DeviceHandlerIF::PERFORM_OPERATION); #endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_TMP_DEVICES == 1 - thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.2, DeviceHandlerIF::SEND_WRITE); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC_3, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_4, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_5, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_6, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_7, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_8, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_9, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_10, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_11, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_12, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_13, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_14, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_15, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_16, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_17, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_18, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_3, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_4, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_5, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_6, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_7, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_8, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_9, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_10, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_11, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_12, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_13, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_14, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_15, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_16, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_17, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_18, length * 0.2, DeviceHandlerIF::SEND_WRITE); #endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_TMP_DEVICES == 1 - thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.4, DeviceHandlerIF::GET_WRITE); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC_3, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_4, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_5, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_6, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_7, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_8, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_9, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_10, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_11, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_12, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_13, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_14, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_15, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_16, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_17, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_18, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_3, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_4, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_5, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_6, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_7, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_8, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_9, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_10, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_11, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_12, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_13, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_14, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_15, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_16, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_17, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_18, length * 0.4, DeviceHandlerIF::GET_WRITE); #endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_TMP_DEVICES == 1 - thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.6, DeviceHandlerIF::SEND_READ); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC_3, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_4, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_5, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_6, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_7, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_8, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_9, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_10, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_11, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_12, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_13, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_14, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_15, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_16, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_17, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_18, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_3, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_4, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_5, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_6, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_7, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_8, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_9, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_10, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_11, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_12, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_13, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_14, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_15, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_16, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_17, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_18, length * 0.6, DeviceHandlerIF::SEND_READ); #endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_TMP_DEVICES == 1 - thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC_3, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_4, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_5, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_6, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_7, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_8, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_9, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_10, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_11, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_12, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_13, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_14, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_15, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_16, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_17, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_18, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_3, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_4, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_5, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_6, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_7, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_8, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_9, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_10, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_11, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_12, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_13, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_14, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_15, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_16, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_17, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_18, length * 0.8, DeviceHandlerIF::GET_READ); #endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_RAD_SENSORS == 1 - /* Radiation sensor */ - thisSequence->addSlot(objects::RAD_SENSOR, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.8, DeviceHandlerIF::GET_READ); + /* Radiation sensor */ + thisSequence->addSlot(objects::RAD_SENSOR, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_SUN_SENSORS == 1 - /** - * The sun sensor will be shutdown as soon as the chip select is pulled high. Thus all - * requests to a sun sensor must be performed consecutively. Another reason for calling multiple - * device handler cycles is that the ADC conversions take some time. Thus first the ADC - * conversions are initiated and in a next step the results can be read from the internal FIFO. - * One sun sensor communication sequence also blocks the SPI bus. So other devices can not be - * inserted between the device handler cycles of one SUS. - */ - /* Write setup */ - thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_1, length * 0.9, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_1, length * 0.901, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_1, length * 0.902, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::GET_READ); + /** + * The sun sensor will be shutdown as soon as the chip select is pulled high. Thus all + * requests to a sun sensor must be performed consecutively. Another reason for calling multiple + * device handler cycles is that the ADC conversions take some time. Thus first the ADC + * conversions are initiated and in a next step the results can be read from the internal FIFO. + * One sun sensor communication sequence also blocks the SPI bus. So other devices can not be + * inserted between the device handler cycles of one SUS. + */ + /* Write setup */ + thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_1, length * 0.9, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_1, length * 0.901, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_1, length * 0.902, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_2, length * 0.903, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_2, length * 0.904, SusHandler::SEND_WRITE); - thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_2, length * 0.905, SusHandler::SEND_WRITE); - thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_2, length * 0.903, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_2, length * 0.904, SusHandler::SEND_WRITE); + thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_2, length * 0.905, SusHandler::SEND_WRITE); + thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_3, length * 0.8, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_3, length * 0.91, SusHandler::SEND_WRITE); - thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_3, length * 0.93, SusHandler::SEND_WRITE); - thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_3, length * 0.8, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_3, length * 0.91, SusHandler::SEND_WRITE); + thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_3, length * 0.93, SusHandler::SEND_WRITE); + thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_4, length * 0.909, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_4, length * 0.91, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_4, length * 0.911, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_4, length * 0.909, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_4, length * 0.91, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_4, length * 0.911, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_5, length * 0.912, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_5, length * 0.913, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_5, length * 0.914, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_5, length * 0.912, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_5, length * 0.913, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_5, length * 0.914, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_6, length * 0.915, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::GET_READ); - /* Read ADC conversions from inernal FIFO */ - thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_6, length * 0.915, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::GET_READ); + /* Read ADC conversions from inernal FIFO */ + thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_7, length * 0.918, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::GET_READ); - /* Read ADC conversions from inernal FIFO */ - thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_7, length * 0.918, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::GET_READ); + /* Read ADC conversions from inernal FIFO */ + thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_8, length * 0.921, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::GET_READ); - /* Read ADC conversions from inernal FIFO */ - thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_8, length * 0.921, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::GET_READ); + /* Read ADC conversions from inernal FIFO */ + thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_9, length * 0.924, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::GET_READ); - /* Read ADC conversions */ - thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_9, length * 0.924, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::GET_READ); + /* Read ADC conversions */ + thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_10, length * 0.927, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::GET_READ); - /* Read ADC conversions */ - thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_10, length * 0.927, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::GET_READ); + /* Read ADC conversions */ + thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_11, length * 0.93, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::GET_READ); - /* Read ADC conversions */ - thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_11, length * 0.93, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::GET_READ); + /* Read ADC conversions */ + thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_12, length * 0.933, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::GET_READ); - /* Read ADC conversions */ - thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_12, length * 0.933, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::GET_READ); + /* Read ADC conversions */ + thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_13, length * 0.936, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::GET_READ); - /* Read ADC conversions */ - thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_13, length * 0.936, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::GET_READ); + /* Read ADC conversions */ + thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_RW == 1 - thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RW1, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW1, length * 0.5, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW1, length * 0.65, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW1, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW1, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW1, length * 0.5, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW1, length * 0.65, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW1, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RW2, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW2, length * 0.5, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW2, length * 0.65, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW2, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW2, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW2, length * 0.5, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW2, length * 0.65, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW2, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RW3, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW3, length * 0.5, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW3, length * 0.65, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW3, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW3, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW3, length * 0.5, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW3, length * 0.65, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW3, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RW4, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW4, length * 0.5, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW4, length * 0.65, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW4, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW4, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW4, length * 0.5, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW4, length * 0.65, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW4, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_ACS_BOARD == 1 - bool enableAside = true; - bool enableBside = false; - if(enableAside) { - // A side - thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.25, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.7, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); + bool enableAside = true; + bool enableBside = false; + if (enableAside) { + // A side + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.25, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.7, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.25, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.75, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.25, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.3, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.75, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.3, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.35, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.75, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); - } + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.35, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); + } - if(enableBside) { - // B side - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.2, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.7, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); + if (enableBside) { + // B side + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.7, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.25, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.75, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.25, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.3, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.75, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.3, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.35, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - 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); - } + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.35, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + 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 */ - ReturnValue_t seqCheck = thisSequence->checkSequence(); - if (seqCheck != HasReturnvaluesIF::RETURN_OK) { - if(seqCheck == FixedTimeslotTaskIF::SLOT_LIST_EMPTY) { - sif::warning << "SPI PST is empty.." << std::endl; - } - else { - sif::error << "SPI PST initialization failed" << std::endl; - } - - return seqCheck; + ReturnValue_t seqCheck = thisSequence->checkSequence(); + if (seqCheck != HasReturnvaluesIF::RETURN_OK) { + if (seqCheck == FixedTimeslotTaskIF::SLOT_LIST_EMPTY) { + sif::warning << "SPI PST is empty.." << std::endl; + } else { + sif::error << "SPI PST initialization failed" << std::endl; } - return HasReturnvaluesIF::RETURN_OK; + + return seqCheck; + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t pst::pstI2c(FixedTimeslotTaskIF *thisSequence) { - // Length of a communication cycle - uint32_t length = thisSequence->getPeriodMs(); - thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); - if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "I2C PST initialization failed" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + // Length of a communication cycle + uint32_t length = thisSequence->getPeriodMs(); + thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); + if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "I2C PST initialization failed" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) { - // Length of a communication cycle - uint32_t length = thisSequence->getPeriodMs(); - bool uartPstEmpty = true; + // Length of a communication cycle + uint32_t length = thisSequence->getPeriodMs(); + bool uartPstEmpty = true; #if OBSW_ADD_PLOC_MPSOC == 1 - uartPstEmpty = false; - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.2, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.4, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.6, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.8, - DeviceHandlerIF::GET_READ); + uartPstEmpty = false; + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif - thisSequence->addSlot(objects::PLOC_UPDATER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PLOC_MEMORY_DUMPER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_UPDATER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_MEMORY_DUMPER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); #if OBSW_ADD_PLOC_SUPERVISOR == 1 - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.2, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.4, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.6, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.8, - DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.2, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_SYRLINKS == 1 - uartPstEmpty = false; - thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.2, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.4, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.6, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.8, - DeviceHandlerIF::GET_READ); + uartPstEmpty = false; + thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_STAR_TRACKER == 1 - uartPstEmpty = false; - thisSequence->addSlot(objects::STAR_TRACKER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::STAR_TRACKER, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::STAR_TRACKER, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::STAR_TRACKER, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::STAR_TRACKER, length * 0.8, DeviceHandlerIF::GET_READ); + uartPstEmpty = false; + thisSequence->addSlot(objects::STAR_TRACKER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::STAR_TRACKER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::STAR_TRACKER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::STAR_TRACKER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::STAR_TRACKER, length * 0.8, DeviceHandlerIF::GET_READ); #endif - if(uartPstEmpty) { - return HasReturnvaluesIF::RETURN_OK; - } - if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "UART PST initialization failed" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } + if (uartPstEmpty) { return HasReturnvaluesIF::RETURN_OK; + } + if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "UART PST initialization failed" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t pst::pstGompaceCan(FixedTimeslotTaskIF *thisSequence){ - uint32_t length = thisSequence->getPeriodMs(); +ReturnValue_t pst::pstGompaceCan(FixedTimeslotTaskIF *thisSequence) { + uint32_t length = thisSequence->getPeriodMs(); - // PCDU handlers receives two messages and both must be handled - thisSequence->addSlot(objects::PCDU_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PCDU_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + // PCDU handlers receives two messages and both must be handled + thisSequence->addSlot(objects::PCDU_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PCDU_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::P60DOCK_HANDLER, - length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PDU1_HANDLER, - length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PDU2_HANDLER, - length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::ACU_HANDLER, - length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PDU1_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PDU2_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::ACU_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::P60DOCK_HANDLER, - length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::PDU1_HANDLER, - length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::PDU2_HANDLER, - length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::ACU_HANDLER, - length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::ACU_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::P60DOCK_HANDLER, - length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::PDU1_HANDLER, - length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::PDU2_HANDLER, - length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::ACU_HANDLER, - length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::ACU_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::P60DOCK_HANDLER, - length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::PDU1_HANDLER, - length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::PDU2_HANDLER, - length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::ACU_HANDLER, - length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::ACU_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::P60DOCK_HANDLER, - length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::PDU1_HANDLER, - length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::PDU2_HANDLER, - length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::ACU_HANDLER, - length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::ACU_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); - if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "GomSpace PST initialization failed" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomSpace PST initialization failed" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t pst::pstTest(FixedTimeslotTaskIF* thisSequence) { - /* Length of a communication cycle */ - uint32_t length = thisSequence->getPeriodMs(); - bool notEmpty = false; +ReturnValue_t pst::pstTest(FixedTimeslotTaskIF *thisSequence) { + /* Length of a communication cycle */ + uint32_t length = thisSequence->getPeriodMs(); + bool notEmpty = false; #if RPI_TEST_ADIS16507 == 1 - notEmpty = true; - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); + notEmpty = true; + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if RPI_TEST_GPS_HANDLER == 1 - notEmpty = true; - thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + notEmpty = true; + thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.5, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.5, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.5, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.5, DeviceHandlerIF::GET_READ); #endif - static_cast(length); - if(not notEmpty) { - return HasReturnvaluesIF::RETURN_FAILED; - } - if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Test PST initialization failed" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + static_cast(length); + if (not notEmpty) { + return HasReturnvaluesIF::RETURN_FAILED; + } + if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Test PST initialization failed" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } #if BOARD_TE0720 == 1 ReturnValue_t pst::pollingSequenceTE0720(FixedTimeslotTaskIF *thisSequence) { - uint32_t length = thisSequence->getPeriodMs(); + uint32_t length = thisSequence->getPeriodMs(); #if TEST_PLOC_MPSOC_HANDLER == 1 - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_TEST_RADIATION_SENSOR_HANDLER == 1 - thisSequence->addSlot(objects::RAD_SENSOR, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_TEST_SUS_HANDLER == 1 - /* Write setup */ - thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_1, length * 0.902, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.903, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.904, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_1, length * 0.905, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_1, length * 0.902, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.903, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.904, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_1, length * 0.905, DeviceHandlerIF::GET_READ); - /* Start conversion*/ - thisSequence->addSlot(objects::SUS_1, length * 0.906, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_1, length * 0.907, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.908, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.909, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_1, length * 0.91, DeviceHandlerIF::GET_READ); + /* Start conversion*/ + thisSequence->addSlot(objects::SUS_1, length * 0.906, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_1, length * 0.907, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.908, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.909, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_1, length * 0.91, DeviceHandlerIF::GET_READ); - /* Read conversions */ - thisSequence->addSlot(objects::SUS_1, length * 0.911, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_1, length * 0.912, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.913, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.914, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_1, length * 0.915, DeviceHandlerIF::GET_READ); + /* Read conversions */ + thisSequence->addSlot(objects::SUS_1, length * 0.911, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_1, length * 0.912, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.913, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.914, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_1, length * 0.915, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_PLOC_SUPERVISOR == 1 - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.7, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.2, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.7, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif - thisSequence->addSlot(objects::PLOC_UPDATER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PLOC_MEMORY_DUMPER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_UPDATER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_MEMORY_DUMPER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); - if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Initialization of TE0720 PST failed" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Initialization of TE0720 PST failed" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } #endif /* BOARD_TE0720 == 1 */ diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h index 5bb5ff2a..36b86ba8 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h @@ -32,7 +32,7 @@ class FixedTimeslotTaskIF; namespace pst { /* 0.4 second period init*/ -ReturnValue_t pstGpio(FixedTimeslotTaskIF *thisSequence); +ReturnValue_t pstGpio(FixedTimeslotTaskIF* thisSequence); /** * @brief This function creates the PST for all gomspace devices. @@ -40,7 +40,7 @@ ReturnValue_t pstGpio(FixedTimeslotTaskIF *thisSequence); * Scheduled in a separate PST because the gomspace library uses blocking calls when requesting * data from devices. */ -ReturnValue_t pstGompaceCan(FixedTimeslotTaskIF *thisSequence); +ReturnValue_t pstGompaceCan(FixedTimeslotTaskIF* thisSequence); ReturnValue_t pstUart(FixedTimeslotTaskIF* thisSequence); @@ -62,7 +62,6 @@ ReturnValue_t pstTest(FixedTimeslotTaskIF* thisSequence); ReturnValue_t pollingSequenceTE0720(FixedTimeslotTaskIF* thisSequence); #endif -} - +} // namespace pst #endif /* POLLINGSEQUENCEINIT_H_ */ diff --git a/linux/fsfwconfig/returnvalues/classIds.h b/linux/fsfwconfig/returnvalues/classIds.h index b98801e2..86edb85f 100644 --- a/linux/fsfwconfig/returnvalues/classIds.h +++ b/linux/fsfwconfig/returnvalues/classIds.h @@ -1,8 +1,8 @@ #ifndef FSFWCONFIG_RETURNVALUES_CLASSIDS_H_ #define FSFWCONFIG_RETURNVALUES_CLASSIDS_H_ -#include #include +#include /** * Source IDs starts at 73 for now @@ -11,13 +11,12 @@ */ namespace CLASS_ID { enum { - CLASS_ID_START = COMMON_CLASS_ID_END, - SA_DEPL_HANDLER, //SADPL - SD_CARD_MANAGER, //SDMA - SCRATCH_BUFFER, //SCBU - CLASS_ID_END // [EXPORT] : [END] + CLASS_ID_START = COMMON_CLASS_ID_END, + SA_DEPL_HANDLER, // SADPL + SD_CARD_MANAGER, // SDMA + SCRATCH_BUFFER, // SCBU + CLASS_ID_END // [EXPORT] : [END] }; } - #endif /* FSFWCONFIG_RETURNVALUES_CLASSIDS_H_ */ diff --git a/linux/fsfwconfig/tmtc/pusIds.h b/linux/fsfwconfig/tmtc/pusIds.h index a2dd7575..37503786 100644 --- a/linux/fsfwconfig/tmtc/pusIds.h +++ b/linux/fsfwconfig/tmtc/pusIds.h @@ -2,21 +2,21 @@ #define CONFIG_TMTC_PUSIDS_HPP_ namespace pus { -enum Ids{ - PUS_SERVICE_1 = 1, - PUS_SERVICE_2 = 2, - PUS_SERVICE_3 = 3, - PUS_SERVICE_3_PSB = 3, - PUS_SERVICE_5 = 5, - PUS_SERVICE_6 = 6, - PUS_SERVICE_8 = 8, - PUS_SERVICE_9 = 9, - PUS_SERVICE_17 = 17, - PUS_SERVICE_19 = 19, - PUS_SERVICE_20 = 20, - PUS_SERVICE_23 = 23, - PUS_SERVICE_200 = 200, - PUS_SERVICE_201 = 201, +enum Ids { + PUS_SERVICE_1 = 1, + PUS_SERVICE_2 = 2, + PUS_SERVICE_3 = 3, + PUS_SERVICE_3_PSB = 3, + PUS_SERVICE_5 = 5, + PUS_SERVICE_6 = 6, + PUS_SERVICE_8 = 8, + PUS_SERVICE_9 = 9, + PUS_SERVICE_17 = 17, + PUS_SERVICE_19 = 19, + PUS_SERVICE_20 = 20, + PUS_SERVICE_23 = 23, + PUS_SERVICE_200 = 200, + PUS_SERVICE_201 = 201, }; }; diff --git a/linux/obc/PapbVcInterface.cpp b/linux/obc/PapbVcInterface.cpp index 5bb72066..f144306c 100644 --- a/linux/obc/PapbVcInterface.cpp +++ b/linux/obc/PapbVcInterface.cpp @@ -1,104 +1,98 @@ #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) { -} - -PapbVcInterface::~PapbVcInterface() { -} + gpioId_t papbBusyId, gpioId_t papbEmptyId, uint32_t vcOffset) + : SystemObject(objectId), + gpioComIF(gpioComIF), + papbBusyId(papbBusyId), + papbEmptyId(papbEmptyId), + vcOffset(vcOffset) {} +PapbVcInterface::~PapbVcInterface() {} void PapbVcInterface::setRegisterAddress(uint32_t* ptmeBaseAddress) { - vcBaseReg = ptmeBaseAddress + vcOffset; + vcBaseReg = ptmeBaseAddress + vcOffset; } -ReturnValue_t PapbVcInterface::write(const uint8_t * data, size_t size) { +ReturnValue_t PapbVcInterface::write(const uint8_t* data, size_t size) { + if (pollPapbBusySignal() == RETURN_OK) { + startPacketTransfer(); + } - 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; } + } - 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 937f4280..e7d03a70 100644 --- a/linux/obc/PapbVcInterface.h +++ b/linux/obc/PapbVcInterface.h @@ -1,12 +1,13 @@ #ifndef LINUX_OBC_PAPBVCINTERFACE_H_ #define LINUX_OBC_PAPBVCINTERFACE_H_ -#include "OBSWConfig.h" -#include "linux/obc/VcInterfaceIF.h" #include #include -#include "fsfw/returnvalues/HasReturnvaluesIF.h" + +#include "OBSWConfig.h" #include "fsfw/objectmanager/ObjectManager.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "linux/obc/VcInterfaceIF.h" /** * @brief This class handles the transmission of data to a virtual channel of the PTME IP Core @@ -14,99 +15,96 @@ * * @author J. Meier */ -class PapbVcInterface: public SystemObject, - 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. - * @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). - */ - PapbVcInterface(object_id_t objectId, LinuxLibgpioIF* gpioComIF, gpioId_t papbBusyId, - gpioId_t papbEmptyId, uint32_t vcOffset); - virtual ~PapbVcInterface(); +class PapbVcInterface : public SystemObject, 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. + * @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). + */ + PapbVcInterface(object_id_t objectId, LinuxLibgpioIF* gpioComIF, gpioId_t papbBusyId, + gpioId_t papbEmptyId, uint32_t vcOffset); + virtual ~PapbVcInterface(); - ReturnValue_t write(const uint8_t* data, size_t size) override; + ReturnValue_t write(const uint8_t* data, size_t size) override; - void setRegisterAddress(uint32_t* ptmeBaseAddress) override; + void setRegisterAddress(uint32_t* ptmeBaseAddress) override; -private: + private: + static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_IP_CORE_BRIDGE; - static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_IP_CORE_BRIDGE; + static const ReturnValue_t PAPB_BUSY = MAKE_RETURN_CODE(0xA0); - static const ReturnValue_t PAPB_BUSY = MAKE_RETURN_CODE(0xA0); + /** + * Configuration bits: + * bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00 + * bit[2]: Set this bit to 1 to abort a transfered packet + * bit[3]: Signals to VcInterface the start of a new telemetry packet + */ + static const uint32_t CONFIG_START = 0x8; - /** - * Configuration bits: - * bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00 - * bit[2]: Set this bit to 1 to abort a transfered packet - * bit[3]: Signals to VcInterface the start of a new telemetry packet - */ - static const uint32_t CONFIG_START = 0x8; + /** + * Writing this word to the VcInterface base address signals to the virtual channel interface + * that a complete tm packet has been transferred. + */ + static const uint32_t CONFIG_END = 0x0; - /** - * Writing this word to the VcInterface base address signals to the virtual channel interface - * that a complete tm packet has been transferred. - */ - static const uint32_t CONFIG_END = 0x0; + /** + * Writing to this offset within the memory space of a virtual channel will insert data for + * encoding to the external buffer memory of the PTME IP Core. + * The address offset is 0x400 (= 4 * 256) + */ + static const int DATA_REG_OFFSET = 256; - /** - * Writing to this offset within the memory space of a virtual channel will insert data for - * encoding to the external buffer memory of the PTME IP Core. - * The address offset is 0x400 (= 4 * 256) - */ - static const int DATA_REG_OFFSET = 256; + LinuxLibgpioIF* gpioComIF = nullptr; - LinuxLibgpioIF* gpioComIF = nullptr; + /** Pulled to low when virtual channel not ready to receive data */ + gpioId_t papbBusyId = gpio::NO_GPIO; + /** High when external buffer memory of virtual channel is empty */ + gpioId_t papbEmptyId = gpio::NO_GPIO; - /** Pulled to low when virtual channel not ready to receive data */ - gpioId_t papbBusyId = gpio::NO_GPIO; - /** High when external buffer memory of virtual channel is empty */ - gpioId_t papbEmptyId = gpio::NO_GPIO; + uint32_t* vcBaseReg = nullptr; - uint32_t* vcBaseReg = nullptr; + uint32_t vcOffset = 0; - uint32_t vcOffset = 0; + /** + * @brief This function sends the config byte to the virtual channel of the PTME IP Core + * to initiate a packet transfer. + */ + void startPacketTransfer(); - /** - * @brief This function sends the config byte to the virtual channel of the PTME IP Core - * to initiate a packet transfer. - */ - void startPacketTransfer(); + /** + * @brief This function sends the config byte to the virtual channel interface of the PTME + * IP Core to signal the end of a packet transfer. + */ + void endPacketTransfer(); - /** - * @brief This function sends the config byte to the virtual channel interface of the PTME - * IP Core to signal the end of a packet transfer. - */ - void endPacketTransfer(); + /** + * @brief This function reads the papb busy signal indicating whether the virtual channel + * interface is ready to receive more data or not. PAPB is ready when + * PAPB_Busy_N == '1'. + * + * @return RETURN_OK when ready to receive data else PAPB_BUSY. + */ + ReturnValue_t pollPapbBusySignal(); - /** - * @brief This function reads the papb busy signal indicating whether the virtual channel - * interface is ready to receive more data or not. PAPB is ready when - * PAPB_Busy_N == '1'. - * - * @return RETURN_OK when ready to receive data else PAPB_BUSY. - */ - ReturnValue_t pollPapbBusySignal(); + /** + * @brief This function can be used for debugging to check whether there are packets in + * the packet buffer of the virtual channel or not. + */ + void isVcInterfaceBufferEmpty(); - /** - * @brief This function can be used for debugging to check whether there are packets in - * the packet buffer of the virtual channel or not. - */ - void isVcInterfaceBufferEmpty(); - - /** - * @brief This function sends a complete telemetry transfer frame data field (1105 bytes) - * to the papb interface of the PTME IP Core. Can be used to test the implementation. - */ - ReturnValue_t sendTestFrame(); + /** + * @brief This function sends a complete telemetry transfer frame data field (1105 bytes) + * to the papb interface of the PTME IP Core. Can be used to test the implementation. + */ + ReturnValue_t sendTestFrame(); }; #endif /* LINUX_OBC_PAPBVCINTERFACE_H_ */ diff --git a/linux/obc/PdecConfig.cpp b/linux/obc/PdecConfig.cpp index bb2ffb13..ac762a6c 100644 --- a/linux/obc/PdecConfig.cpp +++ b/linux/obc/PdecConfig.cpp @@ -1,36 +1,33 @@ #include "PdecConfig.h" + #include "fsfw/serviceinterface/ServiceInterface.h" -PdecConfig::PdecConfig() { - initialize(); -} +PdecConfig::PdecConfig() { initialize(); } -PdecConfig::~PdecConfig() { - -} +PdecConfig::~PdecConfig() {} void PdecConfig::initialize() { - uint32_t word = 0; - word |= (VERSION_ID << 30); - word |= (BYPASS_FLAG << 29); - word |= (CONTROL_COMMAND_FLAG << 28); - word |= (RESERVED_FIELD_A << 26); - word |= (SPACECRAFT_ID << 16); - word |= (VIRTUAL_CHANNEL << 10); - word |= (DUMMY_BITS << 8); - word |= POSITIVE_WINDOW; - configWords[0] = word; - word = 0; - word |= (NEGATIVE_WINDOW << 24); - word |= (HIGH_AU_MAP_ID << 16); - word |= (ENABLE_DERANDOMIZER << 8); - configWords[1] = word; + uint32_t word = 0; + word |= (VERSION_ID << 30); + word |= (BYPASS_FLAG << 29); + word |= (CONTROL_COMMAND_FLAG << 28); + word |= (RESERVED_FIELD_A << 26); + word |= (SPACECRAFT_ID << 16); + word |= (VIRTUAL_CHANNEL << 10); + word |= (DUMMY_BITS << 8); + word |= POSITIVE_WINDOW; + configWords[0] = word; + word = 0; + word |= (NEGATIVE_WINDOW << 24); + word |= (HIGH_AU_MAP_ID << 16); + word |= (ENABLE_DERANDOMIZER << 8); + configWords[1] = word; } uint32_t PdecConfig::getConfigWord(uint8_t wordNo) { - if (wordNo >= CONFIG_WORDS_NUM) { - sif::error << "PdecConfig::getConfigWord: Invalid word number" << std::endl; - return 0; - } - return configWords[wordNo]; + if (wordNo >= CONFIG_WORDS_NUM) { + sif::error << "PdecConfig::getConfigWord: Invalid word number" << std::endl; + return 0; + } + return configWords[wordNo]; } diff --git a/linux/obc/PdecConfig.h b/linux/obc/PdecConfig.h index 46cd5097..37dab151 100644 --- a/linux/obc/PdecConfig.h +++ b/linux/obc/PdecConfig.h @@ -1,9 +1,10 @@ #ifndef LINUX_OBC_PDECCONFIG_H_ #define LINUX_OBC_PDECCONFIG_H_ -#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include +#include "fsfw/returnvalues/HasReturnvaluesIF.h" + /** * @brief This class generates the configuration words for the configuration memory of the PDEC * IP Cores. @@ -14,39 +15,38 @@ * @author J. Meier */ class PdecConfig { + public: + PdecConfig(); + virtual ~PdecConfig(); -public: - PdecConfig(); - virtual ~PdecConfig(); + /** + * @brief Returns the configuration word by specifying the position. + */ + uint32_t getConfigWord(uint8_t wordNo); - /** - * @brief Returns the configuration word by specifying the position. - */ - uint32_t getConfigWord(uint8_t wordNo); + private: + // TC transfer frame configuration parameters + static const uint8_t VERSION_ID = 0; + // BD Frames + static const uint8_t BYPASS_FLAG = 1; + static const uint8_t CONTROL_COMMAND_FLAG = 0; -private: - // TC transfer frame configuration parameters - static const uint8_t VERSION_ID = 0; - // BD Frames - static const uint8_t BYPASS_FLAG = 1; - static const uint8_t CONTROL_COMMAND_FLAG = 0; + static const uint8_t VIRTUAL_CHANNEL = 0; + static const uint8_t RESERVED_FIELD_A = 0; + static const uint16_t SPACECRAFT_ID = 0x274; + static const uint16_t DUMMY_BITS = 0; + // Parameters to control the FARM for AD frames + // Set here for future use + static const uint8_t POSITIVE_WINDOW = 10; + static const uint8_t NEGATIVE_WINDOW = 151; + static const uint8_t HIGH_AU_MAP_ID = 0xF; + static const uint8_t ENABLE_DERANDOMIZER = 1; - static const uint8_t VIRTUAL_CHANNEL = 0; - static const uint8_t RESERVED_FIELD_A = 0; - static const uint16_t SPACECRAFT_ID = 0x274; - static const uint16_t DUMMY_BITS = 0; - // Parameters to control the FARM for AD frames - // Set here for future use - static const uint8_t POSITIVE_WINDOW = 10; - static const uint8_t NEGATIVE_WINDOW = 151; - static const uint8_t HIGH_AU_MAP_ID = 0xF; - static const uint8_t ENABLE_DERANDOMIZER = 1; + static const uint8_t CONFIG_WORDS_NUM = 2; - static const uint8_t CONFIG_WORDS_NUM = 2; + uint32_t configWords[CONFIG_WORDS_NUM]; - uint32_t configWords[CONFIG_WORDS_NUM]; - - void initialize(); + void initialize(); }; #endif /* LINUX_OBC_PDECCONFIG_H_ */ diff --git a/linux/obc/PdecHandler.cpp b/linux/obc/PdecHandler.cpp index aa46c23c..a5ee98d6 100644 --- a/linux/obc/PdecHandler.cpp +++ b/linux/obc/PdecHandler.cpp @@ -1,578 +1,568 @@ +#include "PdecHandler.h" + +#include +#include + #include #include -#include -#include - -#include "PdecHandler.h" #include "OBSWConfig.h" +#include "fsfw/ipc/QueueFactory.h" +#include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/tmtcservices/TmTcMessage.h" -#include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/ipc/QueueFactory.h" - PdecHandler::PdecHandler(object_id_t objectId, object_id_t tcDestinationId, - LinuxLibgpioIF* gpioComIF, gpioId_t pdecReset, std::string uioConfigMemory, - std::string uioRamMemory, std::string uioRegisters) : - SystemObject(objectId), tcDestinationId(tcDestinationId), gpioComIF(gpioComIF), pdecReset( - pdecReset), uioConfigMemory(uioConfigMemory), uioRamMemory(uioRamMemory), uioRegisters( - uioRegisters), actionHelper(this, nullptr) { - commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); + LinuxLibgpioIF* gpioComIF, gpioId_t pdecReset, std::string uioConfigMemory, + std::string uioRamMemory, std::string uioRegisters) + : SystemObject(objectId), + tcDestinationId(tcDestinationId), + gpioComIF(gpioComIF), + pdecReset(pdecReset), + uioConfigMemory(uioConfigMemory), + uioRamMemory(uioRamMemory), + uioRegisters(uioRegisters), + actionHelper(this, nullptr) { + commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); } -PdecHandler::~PdecHandler() { -} +PdecHandler::~PdecHandler() {} ReturnValue_t PdecHandler::initialize() { + tcStore = ObjectManager::instance()->get(objects::TC_STORE); + if (tcStore == nullptr) { + sif::error << "PdecHandler::initialize: Invalid TC store" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - tcStore = ObjectManager::instance()->get(objects::TC_STORE); - if (tcStore == nullptr) { - sif::error << "PdecHandler::initialize: Invalid TC store" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + tcDestination = ObjectManager::instance()->get(tcDestinationId); - tcDestination = ObjectManager::instance()->get( - tcDestinationId); + if (tcDestination == nullptr) { + sif::error << "PdecHandler::initialize: Invalid tc destination specified" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - if (tcDestination == nullptr) { - sif::error << "PdecHandler::initialize: Invalid tc destination specified" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = getRegisterAddress(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = getRegisterAddress(); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = getConfigMemoryBaseAddress(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = getConfigMemoryBaseAddress(); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = getRamBaseAddress(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = getRamBaseAddress(); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + writePdecConfig(); - writePdecConfig(); + result = releasePdec(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = releasePdec(); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = actionHelper.initialize(commandQueue); + if (result != RETURN_OK) { + return result; + } - result = actionHelper.initialize(commandQueue); - if (result != RETURN_OK) { - return result; - } - - return RETURN_OK; + return RETURN_OK; } -MessageQueueId_t PdecHandler::getCommandQueue() const { - return commandQueue->getId(); -} +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; - } + 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)); + 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; - } + if (registerBaseAddress == MAP_FAILED) { + sif::error << "PdecHandler::getRegisterAddress: Failed to map uio address" << std::endl; + return RETURN_FAILED; + } - return RETURN_OK; + 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; - } + 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)); + 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; - } + if (memoryBaseAddress == MAP_FAILED) { + sif::error << "PdecHandler::getConfigMemoryBaseAddress: Failed to map uio address" << std::endl; + return RETURN_FAILED; + } - return RETURN_OK; + return RETURN_OK; } ReturnValue_t PdecHandler::getRamBaseAddress() { - int fd = open(uioRamMemory.c_str(), O_RDWR); + int fd = open(uioRamMemory.c_str(), O_RDWR); - ramBaseAddress = static_cast(mmap(NULL, RAM_MAP_SIZE, PROT_WRITE | PROT_READ, - MAP_SHARED, fd, 0)); + 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; + 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() { +void PdecHandler::writePdecConfig() { + PdecConfig pdecConfig; - PdecConfig pdecConfig; + *(memoryBaseAddress + FRAME_HEADER_OFFSET) = pdecConfig.getConfigWord(0); + *(memoryBaseAddress + FRAME_HEADER_OFFSET + 1) = pdecConfig.getConfigWord(1); - *(memoryBaseAddress + FRAME_HEADER_OFFSET)= pdecConfig.getConfigWord(0); - *(memoryBaseAddress + FRAME_HEADER_OFFSET + 1) = pdecConfig.getConfigWord(1); + // Configure all MAP IDs as invalid + for (int idx = 0; idx <= MAX_MAP_ADDR; idx += 4) { + *(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + idx + 1 / 4) = + NO_DESTINATION << 24 | NO_DESTINATION << 16 | NO_DESTINATION << 8 | NO_DESTINATION; + } - // Configure all MAP IDs as invalid - for (int idx = 0; idx <= MAX_MAP_ADDR; idx += 4) { - *(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + idx + 1 / 4) = NO_DESTINATION << 24 - | NO_DESTINATION << 16 | NO_DESTINATION << 8 | NO_DESTINATION; + // All TCs with MAP ID 7 will be routed to the PM module (can then be read from memory) + uint8_t routeToPm = calcMapAddrEntry(PM_BUFFER); + *(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + 1) = + (NO_DESTINATION << 24) | (NO_DESTINATION << 16) | (NO_DESTINATION << 8) | routeToPm; - } - - // All TCs with MAP ID 7 will be routed to the PM module (can then be read from memory) - uint8_t routeToPm = calcMapAddrEntry(PM_BUFFER); - *(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + 1) = (NO_DESTINATION << 24) | (NO_DESTINATION << 16) | (NO_DESTINATION << 8) - | routeToPm; - - // Write map id clock frequencies - for (int idx = 0; idx <= MAX_MAP_ADDR; idx += 4) { - *(memoryBaseAddress + MAP_CLK_FREQ_OFFSET + idx / 4) = MAP_CLK_FREQ << 24 - | MAP_CLK_FREQ << 16 | MAP_CLK_FREQ << 8 | MAP_CLK_FREQ; - - } + // Write map id clock frequencies + for (int idx = 0; idx <= MAX_MAP_ADDR; idx += 4) { + *(memoryBaseAddress + MAP_CLK_FREQ_OFFSET + idx / 4) = + MAP_CLK_FREQ << 24 | MAP_CLK_FREQ << 16 | MAP_CLK_FREQ << 8 | MAP_CLK_FREQ; + } } ReturnValue_t PdecHandler::resetFarStatFlag() { - uint32_t pdecFar = *(registerBaseAddress + PDEC_FAR_OFFSET); - if (pdecFar != FAR_RESET) { - sif::warning << "PdecHandler::resetFarStatFlag: FAR register did not match expected value." - << " Read value: 0x" << std::hex << static_cast(pdecFar) << std::endl; - return RETURN_FAILED; - } + uint32_t pdecFar = *(registerBaseAddress + PDEC_FAR_OFFSET); + if (pdecFar != FAR_RESET) { + sif::warning << "PdecHandler::resetFarStatFlag: FAR register did not match expected value." + << " Read value: 0x" << std::hex << static_cast(pdecFar) + << std::endl; + return RETURN_FAILED; + } #if OBSW_DEBUG_PDEC_HANDLER == 1 - sif::debug << "PdecHandler::resetFarStatFlag: read FAR with value: 0x" << std::hex << pdecFar - << std::endl; + sif::debug << "PdecHandler::resetFarStatFlag: read FAR with value: 0x" << std::hex << pdecFar + << std::endl; #endif /* OBSW_DEBUG_PDEC_HANDLER == 1 */ - return RETURN_OK; + return RETURN_OK; } -ReturnValue_t PdecHandler::releasePdec() { - ReturnValue_t result = RETURN_OK; - result = gpioComIF->pullHigh(pdecReset); - if (result != RETURN_OK) { - sif::error << "PdecHandler::releasePdec: Failed to release PDEC reset signal" << std::endl; - } - return result; +ReturnValue_t PdecHandler::releasePdec() { + ReturnValue_t result = RETURN_OK; + result = gpioComIF->pullHigh(pdecReset); + if (result != RETURN_OK) { + sif::error << "PdecHandler::releasePdec: Failed to release PDEC reset signal" << std::endl; + } + return result; } ReturnValue_t PdecHandler::performOperation(uint8_t operationCode) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + readCommandQueue(); - readCommandQueue(); - - switch(state) { + switch (state) { case State::INIT: - resetFarStatFlag(); - if (result != RETURN_OK) { - // Requires reconfiguration and reinitialization of PDEC - triggerEvent(INVALID_FAR); - state = State::WAIT_FOR_RECOVERY; - return result; - } - state = State::RUNNING; - break; + resetFarStatFlag(); + if (result != RETURN_OK) { + // Requires reconfiguration and reinitialization of PDEC + triggerEvent(INVALID_FAR); + state = State::WAIT_FOR_RECOVERY; + return result; + } + state = State::RUNNING; + break; case State::RUNNING: - if (newTcReceived()) { - handleNewTc(); - } - checkLocks(); - break; + if (newTcReceived()) { + handleNewTc(); + } + checkLocks(); + break; case State::WAIT_FOR_RECOVERY: - break; + break; default: - sif::debug << "PdecHandler::performOperation: Invalid state" << std::endl; - break; - } + sif::debug << "PdecHandler::performOperation: Invalid state" << std::endl; + break; + } - return RETURN_OK; + return RETURN_OK; } void PdecHandler::readCommandQueue(void) { - CommandMessage commandMessage; - ReturnValue_t result = RETURN_FAILED; + CommandMessage commandMessage; + ReturnValue_t result = RETURN_FAILED; - result = commandQueue->receiveMessage(&commandMessage); + result = commandQueue->receiveMessage(&commandMessage); + if (result == RETURN_OK) { + result = actionHelper.handleActionMessage(&commandMessage); if (result == RETURN_OK) { - result = actionHelper.handleActionMessage(&commandMessage); - if (result == RETURN_OK) { - return; - } - CommandMessage reply; - reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND, - commandMessage.getCommand()); - commandQueue->reply(&reply); - return; + return; } + CommandMessage reply; + reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND, commandMessage.getCommand()); + commandQueue->reply(&reply); + return; + } } bool PdecHandler::newTcReceived() { - uint32_t pdecFar = *(registerBaseAddress + PDEC_FAR_OFFSET); + uint32_t pdecFar = *(registerBaseAddress + PDEC_FAR_OFFSET); - if (pdecFar >> STAT_POSITION != NEW_FAR_RECEIVED) { - return false; - } - if (!checkFrameAna(pdecFar)) { - return false; - } - return true; + if (pdecFar >> STAT_POSITION != NEW_FAR_RECEIVED) { + return false; + } + if (!checkFrameAna(pdecFar)) { + return false; + } + return true; } void PdecHandler::checkLocks() { - uint32_t clcw = getClcw(); - if (!(clcw & NO_RF_MASK) && (lastClcw & NO_RF_MASK)) { - // Rf available changed from 0 to 1 - triggerEvent(CARRIER_LOCK); - } - if (!(clcw & NO_BITLOCK_MASK) && (lastClcw & NO_BITLOCK_MASK)) { - // Bit lock changed from 0 to 1 - triggerEvent(BIT_LOCK_PDEC); - } - lastClcw = clcw; + uint32_t clcw = getClcw(); + if (!(clcw & NO_RF_MASK) && (lastClcw & NO_RF_MASK)) { + // Rf available changed from 0 to 1 + triggerEvent(CARRIER_LOCK); + } + if (!(clcw & NO_BITLOCK_MASK) && (lastClcw & NO_BITLOCK_MASK)) { + // Bit lock changed from 0 to 1 + triggerEvent(BIT_LOCK_PDEC); + } + lastClcw = clcw; } bool PdecHandler::checkFrameAna(uint32_t pdecFar) { - bool frameValid = false; - FrameAna_t frameAna = static_cast((pdecFar & FRAME_ANA_MASK) >> FRAME_ANA_POSITION); - switch(frameAna) { - case(FrameAna_t::ABANDONED_CLTU): { - triggerEvent(INVALID_TC_FRAME, ABANDONED_CLTU); - sif::warning << "PdecHandler::checkFrameAna: Abondoned CLTU" << std::endl; - break; + bool frameValid = false; + FrameAna_t frameAna = static_cast((pdecFar & FRAME_ANA_MASK) >> FRAME_ANA_POSITION); + switch (frameAna) { + case (FrameAna_t::ABANDONED_CLTU): { + triggerEvent(INVALID_TC_FRAME, ABANDONED_CLTU); + sif::warning << "PdecHandler::checkFrameAna: Abondoned CLTU" << std::endl; + break; } - case(FrameAna_t::FRAME_DIRTY): { - triggerEvent(INVALID_TC_FRAME, FRAME_DIRTY); - sif::warning << "PdecHandler::checkFrameAna: Frame dirty" << std::endl; - break; + case (FrameAna_t::FRAME_DIRTY): { + triggerEvent(INVALID_TC_FRAME, FRAME_DIRTY); + sif::warning << "PdecHandler::checkFrameAna: Frame dirty" << std::endl; + break; } - case(FrameAna_t::FRAME_ILLEGAL): { - sif::warning << "PdecHandler::checkFrameAna: Frame illegal for one reason" << std::endl; - handleIReason(pdecFar, FRAME_ILLEGAL_ONE_REASON); - break; + case (FrameAna_t::FRAME_ILLEGAL): { + sif::warning << "PdecHandler::checkFrameAna: Frame illegal for one reason" << std::endl; + handleIReason(pdecFar, FRAME_ILLEGAL_ONE_REASON); + break; } - case(FrameAna_t::FRAME_ILLEGAL_MULTI_REASON): { - sif::warning << "PdecHandler::checkFrameAna: Frame illegal for multiple reasons" - << std::endl; - handleIReason(pdecFar, FRAME_ILLEGAL_MULTIPLE_REASONS); - break; + case (FrameAna_t::FRAME_ILLEGAL_MULTI_REASON): { + sif::warning << "PdecHandler::checkFrameAna: Frame illegal for multiple reasons" << std::endl; + handleIReason(pdecFar, FRAME_ILLEGAL_MULTIPLE_REASONS); + break; } - case(FrameAna_t::AD_DISCARDED_LOCKOUT): { - triggerEvent(INVALID_TC_FRAME, AD_DISCARDED_LOCKOUT); - sif::warning << "PdecHandler::checkFrameAna: AD frame discarded because of lockout" - << std::endl; - break; + case (FrameAna_t::AD_DISCARDED_LOCKOUT): { + triggerEvent(INVALID_TC_FRAME, AD_DISCARDED_LOCKOUT); + sif::warning << "PdecHandler::checkFrameAna: AD frame discarded because of lockout" + << std::endl; + break; } - case(FrameAna_t::AD_DISCARDED_WAIT): { - triggerEvent(INVALID_TC_FRAME, AD_DISCARDED_LOCKOUT); - sif::warning << "PdecHandler::checkFrameAna: AD frame discarded because of wait" - << std::endl; - break; + case (FrameAna_t::AD_DISCARDED_WAIT): { + triggerEvent(INVALID_TC_FRAME, AD_DISCARDED_LOCKOUT); + sif::warning << "PdecHandler::checkFrameAna: AD frame discarded because of wait" << std::endl; + break; } - case(FrameAna_t::AD_DISCARDED_NS_VR): { - triggerEvent(INVALID_TC_FRAME, AD_DISCARDED_NS_VS); - sif::warning << "PdecHandler::checkFrameAna: AD frame discarded because N(S) or V(R)" - << std::endl; - break; + case (FrameAna_t::AD_DISCARDED_NS_VR): { + triggerEvent(INVALID_TC_FRAME, AD_DISCARDED_NS_VS); + sif::warning << "PdecHandler::checkFrameAna: AD frame discarded because N(S) or V(R)" + << std::endl; + break; } - case(FrameAna_t::FRAME_ACCEPTED): { + case (FrameAna_t::FRAME_ACCEPTED): { #if OBSW_DEBUG_PDEC_HANDLER == 1 - sif::info << "PdecHandler::checkFrameAna: Accepted TC frame" << std::endl; + sif::info << "PdecHandler::checkFrameAna: Accepted TC frame" << std::endl; #endif - frameValid = true; - break; + frameValid = true; + break; } default: { - sif::debug << "PdecHandler::checkFrameAna: Invalid frame analysis report" << std::endl; - break; + sif::debug << "PdecHandler::checkFrameAna: Invalid frame analysis report" << std::endl; + break; } - } - return frameValid; + } + return frameValid; } void PdecHandler::handleIReason(uint32_t pdecFar, ReturnValue_t parameter1) { - IReason_t ireason = static_cast((pdecFar & IREASON_MASK) >> IREASON_POSITION); - switch(ireason) { - case(IReason_t::NO_REPORT): { - triggerEvent(INVALID_TC_FRAME, parameter1, NO_REPORT); - sif::info << "PdecHandler::handleIReason: No illegal report" << std::endl; - break; + IReason_t ireason = static_cast((pdecFar & IREASON_MASK) >> IREASON_POSITION); + switch (ireason) { + case (IReason_t::NO_REPORT): { + triggerEvent(INVALID_TC_FRAME, parameter1, NO_REPORT); + sif::info << "PdecHandler::handleIReason: No illegal report" << std::endl; + break; } - case(IReason_t::ERROR_VERSION_NUMBER): { - triggerEvent(INVALID_TC_FRAME, parameter1, ERROR_VERSION_NUMBER); - sif::info << "PdecHandler::handleIReason: Error in version number and reserved A and B " + case (IReason_t::ERROR_VERSION_NUMBER): { + triggerEvent(INVALID_TC_FRAME, parameter1, ERROR_VERSION_NUMBER); + sif::info << "PdecHandler::handleIReason: Error in version number and reserved A and B " << "fields" << std::endl; - break; + break; } - case(IReason_t::ILLEGAL_COMBINATION): { - triggerEvent(INVALID_TC_FRAME, parameter1, ILLEGAL_COMBINATION); - sif::info << "PdecHandler::handleIReason: Illegal combination (AC) of bypass and control " + case (IReason_t::ILLEGAL_COMBINATION): { + triggerEvent(INVALID_TC_FRAME, parameter1, ILLEGAL_COMBINATION); + sif::info << "PdecHandler::handleIReason: Illegal combination (AC) of bypass and control " << "command flags" << std::endl; - break; + break; } - case(IReason_t::INVALID_SC_ID): { - triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_SC_ID); - sif::info << "PdecHandler::handleIReason: Invalid spacecraft identifier " << std::endl; - break; + case (IReason_t::INVALID_SC_ID): { + triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_SC_ID); + sif::info << "PdecHandler::handleIReason: Invalid spacecraft identifier " << std::endl; + break; } - case(IReason_t::INVALID_VC_ID_MSB): { - triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_VC_ID_MSB); - sif::info << "PdecHandler::handleIReason: VC identifier bit 0 to 4 did not match " + case (IReason_t::INVALID_VC_ID_MSB): { + triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_VC_ID_MSB); + sif::info << "PdecHandler::handleIReason: VC identifier bit 0 to 4 did not match " << std::endl; - break; + break; } - case(IReason_t::INVALID_VC_ID_LSB): { - triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_VC_ID_LSB); - sif::info << "PdecHandler::handleIReason: VC identifier bit 5 did not match " << std::endl; - break; + case (IReason_t::INVALID_VC_ID_LSB): { + triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_VC_ID_LSB); + sif::info << "PdecHandler::handleIReason: VC identifier bit 5 did not match " << std::endl; + break; } - case(IReason_t::NS_NOT_ZERO): { - triggerEvent(INVALID_TC_FRAME, parameter1, NS_NOT_ZERO); - sif::info << "PdecHandler::handleIReason: N(S) of BC or BD frame not set to all zeros" + case (IReason_t::NS_NOT_ZERO): { + triggerEvent(INVALID_TC_FRAME, parameter1, NS_NOT_ZERO); + sif::info << "PdecHandler::handleIReason: N(S) of BC or BD frame not set to all zeros" << std::endl; - break; + break; } - case(IReason_t::INCORRECT_BC_CC): { - triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_BC_CC); - sif::info << "PdecHandler::handleIReason: Invalid BC control command format" << std::endl; - break; + case (IReason_t::INCORRECT_BC_CC): { + triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_BC_CC); + sif::info << "PdecHandler::handleIReason: Invalid BC control command format" << std::endl; + break; } default: { - sif::info << "PdecHandler::handleIReason: Invalid reason id" << std::endl; - break; - } + sif::info << "PdecHandler::handleIReason: Invalid reason id" << std::endl; + break; } + } } void PdecHandler::handleNewTc() { - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = RETURN_OK; - uint32_t tcLength = 0; - result = readTc(tcLength); - if (result != RETURN_OK) { - return; - } + uint32_t tcLength = 0; + result = readTc(tcLength); + if (result != RETURN_OK) { + return; + } #if OBSW_DEBUG_PDEC_HANDLER == 1 - unsigned int mapId = tcSegment[0] & MAP_ID_MASK; - sif::info << "PdecHandler::handleNewTc: Received TC segment with map ID " << mapId - << std::endl; - printTC(tcLength); + unsigned int mapId = tcSegment[0] & MAP_ID_MASK; + sif::info << "PdecHandler::handleNewTc: Received TC segment with map ID " << mapId << std::endl; + printTC(tcLength); #endif /* OBSW_DEBUG_PDEC_HANDLER */ - store_address_t storeId; - result = tcStore->addData(&storeId, tcSegment + 1, tcLength - 1); - if (result != RETURN_OK) { - sif::warning << "PdecHandler::handleNewTc: Failed to add received space packet to store" - << std::endl; - return; - } - - TmTcMessage message(storeId); - - result = MessageQueueSenderIF::sendMessage(tcDestination->getRequestQueue(), &message); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "PdecHandler::handleNewTc: Failed to send message to TC destination" - << std::endl; - tcStore->deleteData(storeId); - return; - } - + store_address_t storeId; + result = tcStore->addData(&storeId, tcSegment + 1, tcLength - 1); + if (result != RETURN_OK) { + sif::warning << "PdecHandler::handleNewTc: Failed to add received space packet to store" + << std::endl; return; + } + + TmTcMessage message(storeId); + + result = MessageQueueSenderIF::sendMessage(tcDestination->getRequestQueue(), &message); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "PdecHandler::handleNewTc: Failed to send message to TC destination" + << std::endl; + tcStore->deleteData(storeId); + return; + } + + return; } ReturnValue_t PdecHandler::readTc(uint32_t& tcLength) { - uint32_t tcOffset = (*(registerBaseAddress + PDEC_BPTR_OFFSET) - PHYSICAL_RAM_BASE_ADDRESS) / 4; + uint32_t tcOffset = (*(registerBaseAddress + PDEC_BPTR_OFFSET) - PHYSICAL_RAM_BASE_ADDRESS) / 4; #if OBSW_DEBUG_PDEC_HANDLER == 1 - sif::debug << "PdecHandler::readTc: TC offset: 0x" << std::hex << tcOffset << std::endl; + sif::debug << "PdecHandler::readTc: TC offset: 0x" << std::hex << tcOffset << std::endl; #endif /* OBSW_DEBUG_PDEC_HANDLER */ - tcLength = *(registerBaseAddress + PDEC_SLEN_OFFSET); + tcLength = *(registerBaseAddress + PDEC_SLEN_OFFSET); #if OBSW_DEBUG_PDEC_HANDLER == 1 - sif::debug << "PdecHandler::readTc: TC segment length: " << std::dec << tcLength << std::endl; + sif::debug << "PdecHandler::readTc: TC segment length: " << std::dec << tcLength << std::endl; #endif /* OBSW_DEBUG_PDEC_HANDLER */ - if (tcLength > MAX_TC_SEGMENT_SIZE) { - sif::warning << "PdecHandler::handleNewTc: Read invalid TC length from PDEC register" - << std::endl; - return RETURN_FAILED; + if (tcLength > MAX_TC_SEGMENT_SIZE) { + sif::warning << "PdecHandler::handleNewTc: Read invalid TC length from PDEC register" + << std::endl; + return RETURN_FAILED; + } + + uint32_t idx = 0; + uint32_t tcData = 0; + for (idx = 0; idx <= tcLength; idx = idx + 4) { + tcData = *(ramBaseAddress + tcOffset + idx / 4); + if (idx == 0) { + tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); + tcSegment[idx + 1] = static_cast((tcData >> 8) & 0xFF); + tcSegment[idx + 2] = static_cast(tcData & 0xFF); + } else if (tcLength - idx + 1 == 3) { + tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); + tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); + tcSegment[idx + 1] = static_cast((tcData >> 8) & 0xFF); + } else if (tcLength - idx + 1 == 2) { + tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); + tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); + } else if (tcLength - idx + 1 == 1) { + tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); + } else { + tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); + tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); + tcSegment[idx + 1] = static_cast((tcData >> 8) & 0xFF); + tcSegment[idx + 2] = static_cast(tcData & 0xFF); } + } - uint32_t idx = 0; - uint32_t tcData = 0; - for (idx = 0; idx <= tcLength; idx = idx + 4) { - tcData = *(ramBaseAddress + tcOffset + idx / 4); - if (idx == 0) { - tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); - tcSegment[idx + 1] = static_cast((tcData >> 8) & 0xFF); - tcSegment[idx + 2] = static_cast(tcData & 0xFF); - } - else if (tcLength - idx + 1 == 3) { - tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); - tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); - tcSegment[idx + 1] = static_cast((tcData >> 8) & 0xFF); - } - else if (tcLength - idx + 1 == 2) { - tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); - tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); - } - else if (tcLength - idx + 1 == 1) { - tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); - } - else { - tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); - tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); - tcSegment[idx + 1] = static_cast((tcData >> 8) & 0xFF); - tcSegment[idx + 2] = static_cast(tcData & 0xFF); - } - } + // Backend buffer is handled back to PDEC3 + *(registerBaseAddress + PDEC_BFREE_OFFSET) = 0; - // Backend buffer is handled back to PDEC3 - *(registerBaseAddress + PDEC_BFREE_OFFSET) = 0; - - return RETURN_OK; + return RETURN_OK; } void PdecHandler::printTC(uint32_t tcLength) { - std::stringstream tcSegmentStream; - tcSegmentStream << "TC segment data: 0x"; - for (uint32_t idx = 0; idx < tcLength; idx++) { - tcSegmentStream << std::setfill('0') << std::setw(2) << std::hex - << static_cast(tcSegment[idx]); - } - sif::info << tcSegmentStream.str() << std::endl; + std::stringstream tcSegmentStream; + tcSegmentStream << "TC segment data: 0x"; + for (uint32_t idx = 0; idx < tcLength; idx++) { + tcSegmentStream << std::setfill('0') << std::setw(2) << std::hex + << static_cast(tcSegment[idx]); + } + sif::info << tcSegmentStream.str() << std::endl; } uint8_t PdecHandler::calcMapAddrEntry(uint8_t moduleId) { - uint8_t lutEntry = 0; - uint8_t parity = getOddParity(moduleId | (1 << VALID_POSITION)); - lutEntry = (parity << PARITY_POSITION) | (1 << VALID_POSITION) | moduleId; - return lutEntry; + uint8_t lutEntry = 0; + uint8_t parity = getOddParity(moduleId | (1 << VALID_POSITION)); + lutEntry = (parity << PARITY_POSITION) | (1 << VALID_POSITION) | moduleId; + return lutEntry; } uint8_t PdecHandler::getOddParity(uint8_t number) { - uint8_t parityBit = 0; - uint8_t countBits = 0; - for (unsigned int idx = 0; idx < sizeof(number) * 8; idx++) { - countBits += (number >> idx) & 0x1; - } - parityBit = ~(countBits & 0x1) & 0x1; - return parityBit; + uint8_t parityBit = 0; + uint8_t countBits = 0; + for (unsigned int idx = 0; idx < sizeof(number) * 8; idx++) { + countBits += (number >> idx) & 0x1; + } + parityBit = ~(countBits & 0x1) & 0x1; + return parityBit; } -uint32_t PdecHandler::getClcw() { - return *(registerBaseAddress + PDEC_CLCW_OFFSET); -} +uint32_t PdecHandler::getClcw() { return *(registerBaseAddress + PDEC_CLCW_OFFSET); } -uint32_t PdecHandler::getPdecMon() { - return *(registerBaseAddress + PDEC_MON_OFFSET); -} +uint32_t PdecHandler::getPdecMon() { return *(registerBaseAddress + PDEC_MON_OFFSET); } void PdecHandler::printClcw() { - uint32_t clcw = getClcw(); - uint8_t type = static_cast((clcw >> 31) & 0x1); - uint8_t versionNo = static_cast((clcw >> 29) & 0x3); - uint8_t status = static_cast((clcw >> 26) & 0x7); - uint8_t cop = static_cast((clcw >> 24) & 0x3); - uint8_t vcId = static_cast((clcw >> 18) & 0x3F); - uint8_t noRf = static_cast((clcw >> 15) & 0x1); - uint8_t noBitLock = static_cast((clcw >> 14) & 0x1); - uint8_t lockoutFlag = static_cast((clcw >> 13) & 0x1); - uint8_t waitFlag = static_cast((clcw >> 12) & 0x1); - uint8_t retransmitFlag = static_cast((clcw >> 11) & 0x1); - uint8_t farmBcnt = static_cast((clcw >> 9) & 0x3); - // Expected frame sequence number in te next AD frame - uint8_t repValue = static_cast(clcw & 0xFF); - sif::info << std::setw(30) << std::left << "CLCW type: " << std::hex - << "0x" << static_cast(type) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW version no: " << std::hex - << "0x" << static_cast(versionNo) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW status: " << std::hex - << "0x" << static_cast(status) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW COP: " << std::hex - << "0x" << static_cast(cop) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW virtual channel ID: " << std::hex - << "0x" << static_cast(vcId) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW no RF: " << std::hex - << "0x" << static_cast(noRf) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW no bit lock: " << std::hex - << "0x" << static_cast(noBitLock) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW lockout flag: " << std::hex - << "0x" << static_cast(lockoutFlag) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW wait flag: " << std::hex - << "0x" << static_cast(waitFlag) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW retransmit flag: " << std::hex - << "0x" << static_cast(retransmitFlag) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW FARM B count: " << std::hex - << "0x" << static_cast(farmBcnt) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW rep value: " << std::hex - << "0x" << static_cast(repValue) << std::endl; + uint32_t clcw = getClcw(); + uint8_t type = static_cast((clcw >> 31) & 0x1); + uint8_t versionNo = static_cast((clcw >> 29) & 0x3); + uint8_t status = static_cast((clcw >> 26) & 0x7); + uint8_t cop = static_cast((clcw >> 24) & 0x3); + uint8_t vcId = static_cast((clcw >> 18) & 0x3F); + uint8_t noRf = static_cast((clcw >> 15) & 0x1); + uint8_t noBitLock = static_cast((clcw >> 14) & 0x1); + uint8_t lockoutFlag = static_cast((clcw >> 13) & 0x1); + uint8_t waitFlag = static_cast((clcw >> 12) & 0x1); + uint8_t retransmitFlag = static_cast((clcw >> 11) & 0x1); + uint8_t farmBcnt = static_cast((clcw >> 9) & 0x3); + // Expected frame sequence number in te next AD frame + uint8_t repValue = static_cast(clcw & 0xFF); + sif::info << std::setw(30) << std::left << "CLCW type: " << std::hex << "0x" + << static_cast(type) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW version no: " << std::hex << "0x" + << static_cast(versionNo) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW status: " << std::hex << "0x" + << static_cast(status) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW COP: " << std::hex << "0x" + << static_cast(cop) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW virtual channel ID: " << std::hex << "0x" + << static_cast(vcId) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW no RF: " << std::hex << "0x" + << static_cast(noRf) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW no bit lock: " << std::hex << "0x" + << static_cast(noBitLock) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW lockout flag: " << std::hex << "0x" + << static_cast(lockoutFlag) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW wait flag: " << std::hex << "0x" + << static_cast(waitFlag) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW retransmit flag: " << std::hex << "0x" + << static_cast(retransmitFlag) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW FARM B count: " << std::hex << "0x" + << static_cast(farmBcnt) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW rep value: " << std::hex << "0x" + << static_cast(repValue) << std::endl; } void PdecHandler::printPdecMon() { - uint32_t pdecMon = getPdecMon(); - uint32_t tc0ChannelStatus = (pdecMon & TC0_STATUS_MASK) >> TC0_STATUS_POS; - uint32_t tc1ChannelStatus = (pdecMon & TC1_STATUS_MASK) >> TC1_STATUS_POS; - uint32_t tc2ChannelStatus = (pdecMon & TC2_STATUS_MASK) >> TC2_STATUS_POS; - uint32_t tc3ChannelStatus = (pdecMon & TC3_STATUS_MASK) >> TC3_STATUS_POS; - uint32_t tc4ChannelStatus = (pdecMon & TC4_STATUS_MASK) >> TC4_STATUS_POS; - uint32_t tc5ChannelStatus = (pdecMon & TC5_STATUS_MASK) >> TC5_STATUS_POS; - uint32_t lock = (pdecMon & LOCK_MASK) >> LOCK_POS; - sif::info << std::setw(30) << std::left << "TC0 status: " << getMonStatusString(tc0ChannelStatus) << std::endl; - sif::info << std::setw(30) << std::left << "TC1 status: " << getMonStatusString(tc1ChannelStatus) << std::endl; - sif::info << std::setw(30) << std::left << "TC2 status: " << getMonStatusString(tc2ChannelStatus) << std::endl; - sif::info << std::setw(30) << std::left << "TC3 status: " << getMonStatusString(tc3ChannelStatus) << std::endl; - sif::info << std::setw(30) << std::left << "TC4 status: " << getMonStatusString(tc4ChannelStatus) << std::endl; - sif::info << std::setw(30) << std::left << "TC5 status: " << getMonStatusString(tc5ChannelStatus) << std::endl; - sif::info << std::setw(30) << std::left << "Start sequence lock: " << lock << std::endl; + uint32_t pdecMon = getPdecMon(); + uint32_t tc0ChannelStatus = (pdecMon & TC0_STATUS_MASK) >> TC0_STATUS_POS; + uint32_t tc1ChannelStatus = (pdecMon & TC1_STATUS_MASK) >> TC1_STATUS_POS; + uint32_t tc2ChannelStatus = (pdecMon & TC2_STATUS_MASK) >> TC2_STATUS_POS; + uint32_t tc3ChannelStatus = (pdecMon & TC3_STATUS_MASK) >> TC3_STATUS_POS; + uint32_t tc4ChannelStatus = (pdecMon & TC4_STATUS_MASK) >> TC4_STATUS_POS; + uint32_t tc5ChannelStatus = (pdecMon & TC5_STATUS_MASK) >> TC5_STATUS_POS; + uint32_t lock = (pdecMon & LOCK_MASK) >> LOCK_POS; + sif::info << std::setw(30) << std::left << "TC0 status: " << getMonStatusString(tc0ChannelStatus) + << std::endl; + sif::info << std::setw(30) << std::left << "TC1 status: " << getMonStatusString(tc1ChannelStatus) + << std::endl; + sif::info << std::setw(30) << std::left << "TC2 status: " << getMonStatusString(tc2ChannelStatus) + << std::endl; + sif::info << std::setw(30) << std::left << "TC3 status: " << getMonStatusString(tc3ChannelStatus) + << std::endl; + sif::info << std::setw(30) << std::left << "TC4 status: " << getMonStatusString(tc4ChannelStatus) + << std::endl; + sif::info << std::setw(30) << std::left << "TC5 status: " << getMonStatusString(tc5ChannelStatus) + << std::endl; + sif::info << std::setw(30) << std::left << "Start sequence lock: " << lock << std::endl; } std::string PdecHandler::getMonStatusString(uint32_t status) { - switch(status) { - case TC_CHANNEL_INACTIVE: - return std::string("inactive"); - case TC_CHANNEL_ACTIVE: - return std::string("active"); - case TC_CHANNEL_TIMEDOUT: - return std::string("timed out"); - default: - sif::warning << "PdecHandler::getMonStatusString: Invalid status" << std::endl; - return std::string(); - break; - } -} - - -ReturnValue_t PdecHandler::executeAction(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { - switch(actionId) { - case PRINT_CLCW: - printClcw(); - return EXECUTION_FINISHED; - case PRINT_PDEC_MON: - printPdecMon(); - return EXECUTION_FINISHED; + switch (status) { + case TC_CHANNEL_INACTIVE: + return std::string("inactive"); + case TC_CHANNEL_ACTIVE: + return std::string("active"); + case TC_CHANNEL_TIMEDOUT: + return std::string("timed out"); default: - return COMMAND_NOT_IMPLEMENTED; - } + sif::warning << "PdecHandler::getMonStatusString: Invalid status" << std::endl; + return std::string(); + break; + } +} + +ReturnValue_t PdecHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) { + switch (actionId) { + case PRINT_CLCW: + printClcw(); + return EXECUTION_FINISHED; + case PRINT_PDEC_MON: + printPdecMon(); + return EXECUTION_FINISHED; + default: + return COMMAND_NOT_IMPLEMENTED; + } } diff --git a/linux/obc/PdecHandler.h b/linux/obc/PdecHandler.h index 8c8e8d9b..2125800f 100644 --- a/linux/obc/PdecHandler.h +++ b/linux/obc/PdecHandler.h @@ -3,15 +3,15 @@ #include "OBSWConfig.h" #include "PdecConfig.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" -#include "fsfw_hal/common/gpio/gpioDefinitions.h" -#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" -#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" -#include "fsfw/storagemanager/StorageManagerIF.h" -#include "fsfw/objectmanager/SystemObject.h" -#include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw/action/ActionHelper.h" #include "fsfw/action/HasActionsIF.h" +#include "fsfw/objectmanager/SystemObject.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/storagemanager/StorageManagerIF.h" +#include "fsfw/tasks/ExecutableObjectIF.h" +#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" +#include "fsfw_hal/common/gpio/gpioDefinitions.h" +#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" /** * @brief This class controls the PDEC IP Core implemented in the programmable logic of the @@ -35,386 +35,381 @@ class PdecHandler : public SystemObject, public ExecutableObjectIF, public HasReturnvaluesIF, public HasActionsIF { + public: + /** + * @brief Constructor + * @param objectId Object ID of PDEC handler system object + * @param tcDestinationId Object ID of object responsible for processing TCs. + * @param gpioComIF Pointer to GPIO interace responsible for driving GPIOs. + * @param pdecReset GPIO ID of GPIO connected to the reset signal of the PDEC. + * @param uioConfigMemory String of uio device file same mapped to the PDEC memory space + * @param uioregsiters String of uio device file same mapped to the PDEC register space + */ + PdecHandler(object_id_t objectId, object_id_t tcDestinationId, LinuxLibgpioIF* gpioComIF, + gpioId_t pdecReset, std::string uioConfigMemory, std::string uioRamMemory, + std::string uioRegisters); -public: - /** - * @brief Constructor - * @param objectId Object ID of PDEC handler system object - * @param tcDestinationId Object ID of object responsible for processing TCs. - * @param gpioComIF Pointer to GPIO interace responsible for driving GPIOs. - * @param pdecReset GPIO ID of GPIO connected to the reset signal of the PDEC. - * @param uioConfigMemory String of uio device file same mapped to the PDEC memory space - * @param uioregsiters String of uio device file same mapped to the PDEC register space - */ - PdecHandler(object_id_t objectId, object_id_t tcDestinationId, LinuxLibgpioIF* gpioComIF, - gpioId_t pdecReset, std::string uioConfigMemory, std::string uioRamMemory, - std::string uioRegisters); + virtual ~PdecHandler(); - virtual ~PdecHandler(); + ReturnValue_t performOperation(uint8_t operationCode = 0); - ReturnValue_t performOperation(uint8_t operationCode = 0); + ReturnValue_t initialize() override; - ReturnValue_t initialize() override; + MessageQueueId_t getCommandQueue() const; - MessageQueueId_t getCommandQueue() const; + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) override; - ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size) override; + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PDEC_HANDLER; - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PDEC_HANDLER; + //! [EXPORT] : [COMMENT] Frame acceptance report signals an invalid frame + //! P1: The frame analysis information (FrameAna field of PDEC_FAR register) + //! P2: When frame declared illegal this parameter this parameter gives information about the + //! reason (IReason field of the PDEC_FAR register) + static const Event INVALID_TC_FRAME = MAKE_EVENT(1, severity::HIGH); + //! [EXPORT] : [COMMENT] Read invalid FAR from PDEC after startup + static const Event INVALID_FAR = MAKE_EVENT(2, severity::HIGH); + //! [EXPORT] : [COMMENT] Carrier lock detected + static const Event CARRIER_LOCK = MAKE_EVENT(3, severity::INFO); + //! [EXPORT] : [COMMENT] Bit lock detected (data valid) + static const Event BIT_LOCK_PDEC = MAKE_EVENT(4, severity::INFO); - //! [EXPORT] : [COMMENT] Frame acceptance report signals an invalid frame - //! P1: The frame analysis information (FrameAna field of PDEC_FAR register) - //! P2: When frame declared illegal this parameter this parameter gives information about the reason (IReason field of the PDEC_FAR register) - static const Event INVALID_TC_FRAME = MAKE_EVENT(1, severity::HIGH); - //! [EXPORT] : [COMMENT] Read invalid FAR from PDEC after startup - static const Event INVALID_FAR = MAKE_EVENT(2, severity::HIGH); - //! [EXPORT] : [COMMENT] Carrier lock detected - static const Event CARRIER_LOCK = MAKE_EVENT(3, severity::INFO); - //! [EXPORT] : [COMMENT] Bit lock detected (data valid) - static const Event BIT_LOCK_PDEC = MAKE_EVENT(4, severity::INFO); + private: + static const uint8_t INTERFACE_ID = CLASS_ID::PDEC_HANDLER; -private: + static const ReturnValue_t ABANDONED_CLTU = MAKE_RETURN_CODE(0xA0); + static const ReturnValue_t FRAME_DIRTY = MAKE_RETURN_CODE(0xA1); + static const ReturnValue_t FRAME_ILLEGAL_ONE_REASON = MAKE_RETURN_CODE(0xA2); + static const ReturnValue_t FRAME_ILLEGAL_MULTIPLE_REASONS = MAKE_RETURN_CODE(0xA2); + static const ReturnValue_t AD_DISCARDED_LOCKOUT = MAKE_RETURN_CODE(0xA3); + static const ReturnValue_t AD_DISCARDED_WAIT = MAKE_RETURN_CODE(0xA4); + static const ReturnValue_t AD_DISCARDED_NS_VS = MAKE_RETURN_CODE(0xA5); - static const uint8_t INTERFACE_ID = CLASS_ID::PDEC_HANDLER; + //! [EXPORT] : [COMMENT] Received action message with unknown action id + static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xB0); - static const ReturnValue_t ABANDONED_CLTU = MAKE_RETURN_CODE(0xA0); - static const ReturnValue_t FRAME_DIRTY = MAKE_RETURN_CODE(0xA1); - static const ReturnValue_t FRAME_ILLEGAL_ONE_REASON = MAKE_RETURN_CODE(0xA2); - static const ReturnValue_t FRAME_ILLEGAL_MULTIPLE_REASONS = MAKE_RETURN_CODE(0xA2); - static const ReturnValue_t AD_DISCARDED_LOCKOUT = MAKE_RETURN_CODE(0xA3); - static const ReturnValue_t AD_DISCARDED_WAIT = MAKE_RETURN_CODE(0xA4); - static const ReturnValue_t AD_DISCARDED_NS_VS = MAKE_RETURN_CODE(0xA5); + static const ReturnValue_t NO_REPORT = MAKE_RETURN_CODE(0xA6); + //! Error in version number and reserved A and B fields + static const ReturnValue_t ERROR_VERSION_NUMBER = MAKE_RETURN_CODE(0xA7); + //! Illegal combination of bypass and control command flag + static const ReturnValue_t ILLEGAL_COMBINATION = MAKE_RETURN_CODE(0xA8); + //! Spacecraft identifier did not match + static const ReturnValue_t INVALID_SC_ID = MAKE_RETURN_CODE(0xA9); + //! VC identifier bits 0 to 4 did not match + static const ReturnValue_t INVALID_VC_ID_MSB = MAKE_RETURN_CODE(0xAA); + //! VC identifier bit 5 did not match + static const ReturnValue_t INVALID_VC_ID_LSB = MAKE_RETURN_CODE(0xAB); + //! N(S) of BC or BD frame not set to all zeros + static const ReturnValue_t NS_NOT_ZERO = MAKE_RETURN_CODE(0xAC); + //! Invalid BC control command + static const ReturnValue_t INVALID_BC_CC = MAKE_RETURN_CODE(0xAE); - //! [EXPORT] : [COMMENT] Received action message with unknown action id - static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xB0); + static const uint32_t QUEUE_SIZE = common::CCSDS_HANDLER_QUEUE_SIZE; - static const ReturnValue_t NO_REPORT = MAKE_RETURN_CODE(0xA6); - //! Error in version number and reserved A and B fields - static const ReturnValue_t ERROR_VERSION_NUMBER = MAKE_RETURN_CODE(0xA7); - //! Illegal combination of bypass and control command flag - static const ReturnValue_t ILLEGAL_COMBINATION = MAKE_RETURN_CODE(0xA8); - //! Spacecraft identifier did not match - static const ReturnValue_t INVALID_SC_ID = MAKE_RETURN_CODE(0xA9); - //! VC identifier bits 0 to 4 did not match - static const ReturnValue_t INVALID_VC_ID_MSB = MAKE_RETURN_CODE(0xAA); - //! VC identifier bit 5 did not match - static const ReturnValue_t INVALID_VC_ID_LSB = MAKE_RETURN_CODE(0xAB); - //! N(S) of BC or BD frame not set to all zeros - static const ReturnValue_t NS_NOT_ZERO = MAKE_RETURN_CODE(0xAC); - //! Invalid BC control command - static const ReturnValue_t INVALID_BC_CC = MAKE_RETURN_CODE(0xAE); + // Action IDs + static const ActionId_t PRINT_CLCW = 0; + // Print PDEC monitor register + static const ActionId_t PRINT_PDEC_MON = 1; - static const uint32_t QUEUE_SIZE = common::CCSDS_HANDLER_QUEUE_SIZE; + static const uint8_t STAT_POSITION = 31; + static const uint8_t FRAME_ANA_POSITION = 28; + static const uint8_t IREASON_POSITION = 25; - // Action IDs - static const ActionId_t PRINT_CLCW = 0; - // Print PDEC monitor register - static const ActionId_t PRINT_PDEC_MON = 1; + static const uint8_t NEW_FAR_RECEIVED = 0; - static const uint8_t STAT_POSITION = 31; - static const uint8_t FRAME_ANA_POSITION = 28; - static const uint8_t IREASON_POSITION = 25; + static const uint32_t FRAME_ANA_MASK = 0x70000000; + static const uint32_t IREASON_MASK = 0x0E000000; - static const uint8_t NEW_FAR_RECEIVED = 0; + static const uint32_t TC_CHANNEL_INACTIVE = 0x0; + static const uint32_t TC_CHANNEL_ACTIVE = 0x1; + static const uint32_t TC_CHANNEL_TIMEDOUT = 0x2; - static const uint32_t FRAME_ANA_MASK = 0x70000000; - static const uint32_t IREASON_MASK = 0x0E000000; + static const uint32_t TC0_STATUS_MASK = 0x3; + static const uint32_t TC1_STATUS_MASK = 0xC; + static const uint32_t TC2_STATUS_MASK = 0x300; + static const uint32_t TC3_STATUS_MASK = 0xC00; + static const uint32_t TC4_STATUS_MASK = 0x30000; + static const uint32_t TC5_STATUS_MASK = 0xc00000; + // Lock register set to 1 when start sequence has been found (CLTU is beeing processed) + static const uint32_t LOCK_MASK = 0xc00000; - static const uint32_t TC_CHANNEL_INACTIVE = 0x0; - static const uint32_t TC_CHANNEL_ACTIVE = 0x1; - static const uint32_t TC_CHANNEL_TIMEDOUT = 0x2; + static const uint32_t TC0_STATUS_POS = 0; + static const uint32_t TC1_STATUS_POS = 2; + static const uint32_t TC2_STATUS_POS = 4; + static const uint32_t TC3_STATUS_POS = 6; + static const uint32_t TC4_STATUS_POS = 8; + static const uint32_t TC5_STATUS_POS = 10; + // Lock register set to 1 when start sequence has been found (CLTU is beeing processed) + static const uint32_t LOCK_POS = 12; - static const uint32_t TC0_STATUS_MASK = 0x3; - static const uint32_t TC1_STATUS_MASK = 0xC; - static const uint32_t TC2_STATUS_MASK = 0x300; - static const uint32_t TC3_STATUS_MASK = 0xC00; - static const uint32_t TC4_STATUS_MASK = 0x30000; - static const uint32_t TC5_STATUS_MASK = 0xc00000; - // Lock register set to 1 when start sequence has been found (CLTU is beeing processed) - static const uint32_t LOCK_MASK = 0xc00000; - - static const uint32_t TC0_STATUS_POS = 0; - static const uint32_t TC1_STATUS_POS = 2; - static const uint32_t TC2_STATUS_POS = 4; - static const uint32_t TC3_STATUS_POS = 6; - static const uint32_t TC4_STATUS_POS = 8; - static const uint32_t TC5_STATUS_POS = 10; - // Lock register set to 1 when start sequence has been found (CLTU is beeing processed) - static const uint32_t LOCK_POS = 12; - - /** - * UIO is 4 byte aligned. Thus offset is calculated with "true offset" / 4 - * Example: PDEC_FAR = 0x2840 => Offset in virtual address space is 0xA10 - */ - static const uint32_t PDEC_FAR_OFFSET = 0xA10; - static const uint32_t PDEC_CLCW_OFFSET = 0xA12; - static const uint32_t PDEC_BFREE_OFFSET = 0xA24; - static const uint32_t PDEC_BPTR_OFFSET = 0xA25; - static const uint32_t PDEC_SLEN_OFFSET = 0xA26; - static const uint32_t PDEC_MON_OFFSET = 0xA27; + /** + * UIO is 4 byte aligned. Thus offset is calculated with "true offset" / 4 + * Example: PDEC_FAR = 0x2840 => Offset in virtual address space is 0xA10 + */ + static const uint32_t PDEC_FAR_OFFSET = 0xA10; + static const uint32_t PDEC_CLCW_OFFSET = 0xA12; + static const uint32_t PDEC_BFREE_OFFSET = 0xA24; + static const uint32_t PDEC_BPTR_OFFSET = 0xA25; + static const uint32_t PDEC_SLEN_OFFSET = 0xA26; + static const uint32_t PDEC_MON_OFFSET = 0xA27; #if BOARD_TE0720 == 1 - static const int CONFIG_MEMORY_MAP_SIZE = 0x400; - static const int RAM_MAP_SIZE = 0x4000; - static const int REGISTER_MAP_SIZE = 0x10000; + static const int CONFIG_MEMORY_MAP_SIZE = 0x400; + static const int RAM_MAP_SIZE = 0x4000; + static const int REGISTER_MAP_SIZE = 0x10000; #else - static const int CONFIG_MEMORY_MAP_SIZE = 0x400; - static const int RAM_MAP_SIZE = 0x4000; - static const int REGISTER_MAP_SIZE = 0x4000; + static const int CONFIG_MEMORY_MAP_SIZE = 0x400; + static const int RAM_MAP_SIZE = 0x4000; + static const int REGISTER_MAP_SIZE = 0x4000; #endif /* BOARD_TE0720 == 1 */ - // 0x200 / 4 = 0x80 - static const uint32_t FRAME_HEADER_OFFSET = 0x80; + // 0x200 / 4 = 0x80 + static const uint32_t FRAME_HEADER_OFFSET = 0x80; - static const size_t MAX_TC_SEGMENT_SIZE = 1017; - static const uint8_t MAP_ID_MASK = 0x3F; + static const size_t MAX_TC_SEGMENT_SIZE = 1017; + static const uint8_t MAP_ID_MASK = 0x3F; #if BOARD_TE0720 == 1 - static const uint32_t PHYSICAL_RAM_BASE_ADDRESS = 0x32000000; + static const uint32_t PHYSICAL_RAM_BASE_ADDRESS = 0x32000000; #else - static const uint32_t PHYSICAL_RAM_BASE_ADDRESS = 0x26000000; + static const uint32_t PHYSICAL_RAM_BASE_ADDRESS = 0x26000000; #endif - static const uint32_t MAP_ADDR_LUT_OFFSET = 0xA0; - static const uint32_t MAP_CLK_FREQ_OFFSET = 0x90; + static const uint32_t MAP_ADDR_LUT_OFFSET = 0xA0; + static const uint32_t MAP_CLK_FREQ_OFFSET = 0x90; - static const uint8_t MAX_MAP_ADDR = 63; - // Writing this to the map address in the look up table will invalidate a MAP ID. - static const uint8_t NO_DESTINATION = 0; - static const uint8_t VALID_POSITION = 6; - static const uint8_t PARITY_POSITION = 7; + static const uint8_t MAX_MAP_ADDR = 63; + // Writing this to the map address in the look up table will invalidate a MAP ID. + static const uint8_t NO_DESTINATION = 0; + static const uint8_t VALID_POSITION = 6; + static const uint8_t PARITY_POSITION = 7; - // Expected value stored in FAR register after reset - static const uint32_t FAR_RESET = 0x7FE0; + // Expected value stored in FAR register after reset + static const uint32_t FAR_RESET = 0x7FE0; - static const uint32_t TC_SEGMENT_LEN = 1017; + static const uint32_t TC_SEGMENT_LEN = 1017; - static const uint32_t NO_RF_MASK = 0x8000; - static const uint32_t NO_BITLOCK_MASK = 0x4000; + static const uint32_t NO_RF_MASK = 0x8000; + static const uint32_t NO_BITLOCK_MASK = 0x4000; - /** - * TCs with map addresses (also know as Map IDs) assigned to this channel will be stored in - * the PDEC memory. - */ - static const uint8_t PM_BUFFER = 7; + /** + * TCs with map addresses (also know as Map IDs) assigned to this channel will be stored in + * the PDEC memory. + */ + static const uint8_t PM_BUFFER = 7; - // MAP clock frequency. Must be a value between 1 and 13 otherwise the TC segment will be - // discarded - static const uint8_t MAP_CLK_FREQ = 2; + // MAP clock frequency. Must be a value between 1 and 13 otherwise the TC segment will be + // discarded + static const uint8_t MAP_CLK_FREQ = 2; - enum class FrameAna_t: uint8_t { - ABANDONED_CLTU, - FRAME_DIRTY, - FRAME_ILLEGAL, - FRAME_ILLEGAL_MULTI_REASON, - AD_DISCARDED_LOCKOUT, - AD_DISCARDED_WAIT, - AD_DISCARDED_NS_VR, - FRAME_ACCEPTED - }; + enum class FrameAna_t : uint8_t { + ABANDONED_CLTU, + FRAME_DIRTY, + FRAME_ILLEGAL, + FRAME_ILLEGAL_MULTI_REASON, + AD_DISCARDED_LOCKOUT, + AD_DISCARDED_WAIT, + AD_DISCARDED_NS_VR, + FRAME_ACCEPTED + }; - enum class IReason_t: uint8_t { - NO_REPORT, - ERROR_VERSION_NUMBER, - ILLEGAL_COMBINATION, - INVALID_SC_ID, - INVALID_VC_ID_LSB, - INVALID_VC_ID_MSB, - NS_NOT_ZERO, - INCORRECT_BC_CC - }; + enum class IReason_t : uint8_t { + NO_REPORT, + ERROR_VERSION_NUMBER, + ILLEGAL_COMBINATION, + INVALID_SC_ID, + INVALID_VC_ID_LSB, + INVALID_VC_ID_MSB, + NS_NOT_ZERO, + INCORRECT_BC_CC + }; - enum class State: uint8_t { - INIT, - RUNNING, - WAIT_FOR_RECOVERY - }; + enum class State : uint8_t { INIT, RUNNING, WAIT_FOR_RECOVERY }; - /** - * @brief Reads and handles messages stored in the commandQueue - */ - void readCommandQueue(void); + /** + * @brief Reads and handles messages stored in the commandQueue + */ + 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 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 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 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. - */ - void writePdecConfig(); + /** + * @brief This functions writes the configuration parameters to the configuration + * section of the PDEC. + */ + void writePdecConfig(); - /** - * @brief Reading the FAR resets the set stat flag which signals a new TC. Without clearing - * this flag no new TC will be excepted. After start up the flag is set and needs - * to be reset. - * Stat flag 0 - new TC received - * Stat flag 1 - old TC (ready to receive next TC) - */ - ReturnValue_t resetFarStatFlag(); + /** + * @brief Reading the FAR resets the set stat flag which signals a new TC. Without clearing + * this flag no new TC will be excepted. After start up the flag is set and needs + * to be reset. + * Stat flag 0 - new TC received + * Stat flag 1 - old TC (ready to receive next TC) + */ + ReturnValue_t resetFarStatFlag(); - /** - * @brief Releases the PDEC from reset state. PDEC will start with loading the written - * configuration parameters. - */ - ReturnValue_t releasePdec(); + /** + * @brief Releases the PDEC from reset state. PDEC will start with loading the written + * configuration parameters. + */ + ReturnValue_t releasePdec(); - /** - * @brief Reads the FAR register and checks if a new TC has been received. - */ - bool newTcReceived(); + /** + * @brief Reads the FAR register and checks if a new TC has been received. + */ + bool newTcReceived(); - /** - * @brief Checks if carrier lock or bit lock has been detected and triggers appropriate - * event. - */ - void checkLocks(); + /** + * @brief Checks if carrier lock or bit lock has been detected and triggers appropriate + * event. + */ + void checkLocks(); - /** - * @brief Analyzes the FramAna field (frame analysis data) of a FAR report. - * - * @return True if frame valid, otherwise false. - */ - bool checkFrameAna(uint32_t pdecFar); + /** + * @brief Analyzes the FramAna field (frame analysis data) of a FAR report. + * + * @return True if frame valid, otherwise false. + */ + bool checkFrameAna(uint32_t pdecFar); - /** - * @brief This function handles the IReason field of the frame analysis report. - * - * @details In case frame as been declared illegal for multiple reasons, the reason with the - * lowest value will be shown. - */ - void handleIReason(uint32_t pdecFar, ReturnValue_t parameter1); + /** + * @brief This function handles the IReason field of the frame analysis report. + * + * @details In case frame as been declared illegal for multiple reasons, the reason with the + * lowest value will be shown. + */ + void handleIReason(uint32_t pdecFar, ReturnValue_t parameter1); - /** - * @brief Handles the reception of new TCs. Reads the pointer to the storage location of the - * new TC segment, extracts the PUS packet and forwards the data to the object - * responsible for processing the TC. - */ - void handleNewTc(); + /** + * @brief Handles the reception of new TCs. Reads the pointer to the storage location of the + * new TC segment, extracts the PUS packet and forwards the data to the object + * responsible for processing the TC. + */ + void handleNewTc(); - /** - * @brief Function reads the last received TC segment from the PDEC memory and copies - * the data to the tcSegement array. - * - * @param tcLength The length of the received TC. - * - */ - ReturnValue_t readTc(uint32_t& tcLength); + /** + * @brief Function reads the last received TC segment from the PDEC memory and copies + * the data to the tcSegement array. + * + * @param tcLength The length of the received TC. + * + */ + ReturnValue_t readTc(uint32_t& tcLength); - /** - * @brief Prints the tc segment data - */ - void printTC(uint32_t tcLength); + /** + * @brief Prints the tc segment data + */ + void printTC(uint32_t tcLength); - /** - * @brief This function calculates the entry for the configuration of the MAP ID routing. - * - * @param mapAddr The MAP ID to configure - * @param moduleId The destination module where all TCs with the map id mapAddr will be routed - * to. - * - * @details The PDEC has different modules where the TCs can be routed to. A lookup table is - * used which links the MAP ID field to the destination module. The entry for this - * lookup table is created by this function and must be stored in the configuration - * memory region of the PDEC. The entry has a specific format - */ - uint8_t calcMapAddrEntry(uint8_t moduleId); + /** + * @brief This function calculates the entry for the configuration of the MAP ID routing. + * + * @param mapAddr The MAP ID to configure + * @param moduleId The destination module where all TCs with the map id mapAddr will be routed + * to. + * + * @details The PDEC has different modules where the TCs can be routed to. A lookup table is + * used which links the MAP ID field to the destination module. The entry for this + * lookup table is created by this function and must be stored in the configuration + * memory region of the PDEC. The entry has a specific format + */ + uint8_t calcMapAddrEntry(uint8_t moduleId); - /** - * @brief This functions calculates the odd parity of the bits in number. - * - * @param number The number from which to calculate the odd parity. - */ - uint8_t getOddParity(uint8_t number); + /** + * @brief This functions calculates the odd parity of the bits in number. + * + * @param number The number from which to calculate the odd parity. + */ + uint8_t getOddParity(uint8_t number); - /** - * brief Returns the 32-bit wide communication link control word (CLCW) - */ - uint32_t getClcw(); + /** + * brief Returns the 32-bit wide communication link control word (CLCW) + */ + uint32_t getClcw(); - /** - * @brief Returns the PDEC monitor register content - * - */ - uint32_t getPdecMon(); + /** + * @brief Returns the PDEC monitor register content + * + */ + uint32_t getPdecMon(); - /** - * @brief Reads and prints the CLCW. Can be useful for debugging. - */ - void printClcw(); + /** + * @brief Reads and prints the CLCW. Can be useful for debugging. + */ + void printClcw(); - /** - * @brief Prints monitor register information to debug console. - */ - void printPdecMon(); + /** + * @brief Prints monitor register information to debug console. + */ + void printPdecMon(); - std::string getMonStatusString(uint32_t status); + std::string getMonStatusString(uint32_t status); - object_id_t tcDestinationId; + object_id_t tcDestinationId; - AcceptsTelecommandsIF* tcDestination = nullptr; + AcceptsTelecommandsIF* tcDestination = nullptr; - LinuxLibgpioIF* gpioComIF = nullptr; + LinuxLibgpioIF* gpioComIF = nullptr; - /** - * Reset signal is required to hold PDEC in reset state until the configuration has been - * written to the appropriate memory space. - * Can also be used to reboot PDEC in case of erros. - */ - gpioId_t pdecReset = gpio::NO_GPIO; + /** + * Reset signal is required to hold PDEC in reset state until the configuration has been + * written to the appropriate memory space. + * Can also be used to reboot PDEC in case of erros. + */ + gpioId_t pdecReset = gpio::NO_GPIO; - // UIO device file giving access to the PDEC configuration memory section - std::string uioConfigMemory; + // UIO device file giving access to the PDEC configuration memory section + std::string uioConfigMemory; - // UIO device file giving access to the PDEC RAM section - std::string uioRamMemory; + // UIO device file giving access to the PDEC RAM section + std::string uioRamMemory; - // UIO device file giving access to the PDEC register space - std::string uioRegisters; + // UIO device file giving access to the PDEC register space + std::string uioRegisters; - ActionHelper actionHelper; + ActionHelper actionHelper; - StorageManagerIF* tcStore = nullptr; + StorageManagerIF* tcStore = nullptr; - MessageQueueIF* commandQueue = nullptr; + MessageQueueIF* commandQueue = nullptr; - State state = State::INIT; + State state = State::INIT; - /** - * Pointer pointing to base address of the PDEC memory space. - * This address is equivalent with the base address of the section named configuration area in - * the PDEC datasheet. - */ - uint32_t* memoryBaseAddress = nullptr; + /** + * Pointer pointing to base address of the PDEC memory space. + * This address is equivalent with the base address of the section named configuration area in + * the PDEC datasheet. + */ + uint32_t* memoryBaseAddress = nullptr; - uint32_t* ramBaseAddress = nullptr; + uint32_t* ramBaseAddress = nullptr; - // Pointer pointing to base address of register space - uint32_t* registerBaseAddress = nullptr; + // Pointer pointing to base address of register space + uint32_t* registerBaseAddress = nullptr; - uint32_t pdecFar = 0; + uint32_t pdecFar = 0; - uint8_t tcSegment[TC_SEGMENT_LEN]; + uint8_t tcSegment[TC_SEGMENT_LEN]; - // Used to check carrier and bit lock changes (default set to no rf and no bitlock) - uint32_t lastClcw = 0xC000; + // Used to check carrier and bit lock changes (default set to no rf and no bitlock) + uint32_t lastClcw = 0xC000; }; #endif /* LINUX_OBC_PDECHANDLER_H_ */ diff --git a/linux/obc/Ptme.cpp b/linux/obc/Ptme.cpp index 63af5d33..237e66ab 100644 --- a/linux/obc/Ptme.cpp +++ b/linux/obc/Ptme.cpp @@ -1,72 +1,69 @@ -#include #include - #include -#include "fsfw/serviceinterface/ServiceInterface.h" +#include + #include "PtmeConfig.h" +#include "fsfw/serviceinterface/ServiceInterface.h" -Ptme::Ptme(object_id_t objectId): SystemObject(objectId) { -} +Ptme::Ptme(object_id_t objectId) : SystemObject(objectId) {} -Ptme::~Ptme() { -} +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; + } - 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)); - /** - * 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)); + if (ptmeBaseAddress == MAP_FAILED) { + sif::error << "Ptme::initialize: Failed to map uio address" << std::endl; + return RETURN_FAILED; + } - 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->setRegisterAddress(ptmeBaseAddress); + } - VcInterfaceMapIter iter; - for (iter = vcInterfaceMap.begin(); iter != vcInterfaceMap.end(); iter++) { - iter->second->setRegisterAddress(ptmeBaseAddress); - } - - return RETURN_OK; + return RETURN_OK; } -ReturnValue_t Ptme::writeToVc(uint8_t vcId, const uint8_t * data, size_t size) { - ReturnValue_t result = RETURN_OK; - VcInterfaceMapIter vcInterfaceMapIter = vcInterfaceMap.find(vcId); - if (vcInterfaceMapIter == vcInterfaceMap.end()) { - sif::warning << "Ptme::writeToVc: No virtual channel interface found for the virtual " - "channel with id " << static_cast(vcId) << std::endl; - return UNKNOWN_VC_ID; - } - result = vcInterfaceMapIter->second->write(data, size); - return result; +ReturnValue_t Ptme::writeToVc(uint8_t vcId, const uint8_t* data, size_t size) { + ReturnValue_t result = RETURN_OK; + VcInterfaceMapIter vcInterfaceMapIter = vcInterfaceMap.find(vcId); + if (vcInterfaceMapIter == vcInterfaceMap.end()) { + sif::warning << "Ptme::writeToVc: No virtual channel interface found for the virtual " + "channel with id " + << static_cast(vcId) << std::endl; + return UNKNOWN_VC_ID; + } + result = vcInterfaceMapIter->second->write(data, size); + return result; } void Ptme::addVcInterface(VcId_t vcId, VcInterfaceIF* vc) { + if (vcId > common::NUMBER_OF_VIRTUAL_CHANNELS) { + sif::warning << "Ptme::addVcInterface: Invalid virtual channel ID" << std::endl; + return; + } - if (vcId > common::NUMBER_OF_VIRTUAL_CHANNELS) { - sif::warning << "Ptme::addVcInterface: Invalid virtual channel ID" << std::endl; - return; - } + if (vc == nullptr) { + sif::warning << "Ptme::addVcInterface: Invalid virtual channel interface" << std::endl; + return; + } - if (vc == nullptr) { - sif::warning << "Ptme::addVcInterface: Invalid virtual channel interface" << std::endl; - return; - } - - auto status = vcInterfaceMap.emplace(vcId, vc); - if (status.second == false) { - sif::warning << "Ptme::addVcInterface: Failed to add virtual channel interface to " - "virtual channel map" << std::endl; - return; - } + auto status = vcInterfaceMap.emplace(vcId, vc); + if (status.second == false) { + sif::warning << "Ptme::addVcInterface: Failed to add virtual channel interface to " + "virtual channel map" + << std::endl; + return; + } } diff --git a/linux/obc/Ptme.h b/linux/obc/Ptme.h index 5364974f..d85885bc 100644 --- a/linux/obc/Ptme.h +++ b/linux/obc/Ptme.h @@ -1,91 +1,87 @@ #ifndef LINUX_OBC_PTME_H_ #define LINUX_OBC_PTME_H_ -#include "OBSWConfig.h" -#include "linux/obc/PtmeIF.h" -#include "linux/obc/VcInterfaceIF.h" #include #include -#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include #include +#include "OBSWConfig.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "linux/obc/PtmeIF.h" +#include "linux/obc/VcInterfaceIF.h" + /** * @brief This class handles the interfacing to the telemetry (PTME) IP core responsible for the - * encoding of telemetry packets according to the CCSDS standards CCSDS 131.0-B-3 (TM Synchro- - * nization and channel coding) and CCSDS 132.0-B-2 (TM Space Data Link Protocoll). - * The IP cores are implemented on the programmable logic and are accessible through the - * linux UIO driver. + * encoding of telemetry packets according to the CCSDS standards CCSDS 131.0-B-3 (TM + * Synchro- nization and channel coding) and CCSDS 132.0-B-2 (TM Space Data Link Protocoll). The IP + * cores are implemented on the programmable logic and are accessible through the linux UIO driver. */ -class Ptme : public PtmeIF, - public SystemObject, - public HasReturnvaluesIF { -public: +class Ptme : public PtmeIF, public SystemObject, public HasReturnvaluesIF { + public: + using VcId_t = uint8_t; - using VcId_t = uint8_t; + /** + * @brief Constructor + * + * @param objectId + */ + Ptme(object_id_t objectId); + virtual ~Ptme(); - /** - * @brief Constructor - * - * @param objectId - */ - Ptme(object_id_t objectId); - virtual ~Ptme(); + ReturnValue_t initialize() override; + ReturnValue_t writeToVc(uint8_t vcId, const uint8_t* data, size_t size) override; - ReturnValue_t initialize() override; - ReturnValue_t writeToVc(uint8_t vcId, const uint8_t* data, size_t size) override; + /** + * @brief This function adds the reference to a virtual channel interface to the vcInterface + * map. + */ + void addVcInterface(VcId_t vcId, VcInterfaceIF* vc); - /** - * @brief This function adds the reference to a virtual channel interface to the vcInterface - * map. - */ - void addVcInterface(VcId_t vcId, VcInterfaceIF* vc); + private: + static const uint8_t INTERFACE_ID = CLASS_ID::PTME; -private: - - static const uint8_t INTERFACE_ID = CLASS_ID::PTME; - - static const ReturnValue_t UNKNOWN_VC_ID = MAKE_RETURN_CODE(0xA0); + 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; + /** Size of mapped address space */ + static const int MAP_SIZE = 0x40000; #else - /** Size of mapped address space */ - static const int MAP_SIZE = 0x40000; + /** Size of mapped address space */ + static const int MAP_SIZE = 0x40000; #endif /* BOARD_TE0720 == 1 */ - /** - * Configuration bits: - * bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00 - * bit[2]: Set this bit to 1 to abort a transfered packet - * bit[3]: Signals to PTME the start of a new telemetry packet - */ - static const uint32_t PTME_CONFIG_START = 0x8; + /** + * Configuration bits: + * bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00 + * bit[2]: Set this bit to 1 to abort a transfered packet + * bit[3]: Signals to PTME the start of a new telemetry packet + */ + static const uint32_t PTME_CONFIG_START = 0x8; - /** - * Writing this word to the ptme base address signals to the PTME that a complete tm packet has - * been transferred. - */ - static const uint32_t PTME_CONFIG_END = 0x0; + /** + * Writing this word to the ptme base address signals to the PTME that a complete tm packet has + * been transferred. + */ + static const uint32_t PTME_CONFIG_END = 0x0; - /** - * Writing to this offset within the PTME memory space will insert data for encoding to the - * PTME IP core. - * The address offset is 0x400 (= 4 * 256) - */ - static const int PTME_DATA_REG_OFFSET = 256; + /** + * Writing to this offset within the PTME memory space will insert data for encoding to the + * PTME IP core. + * The address offset is 0x400 (= 4 * 256) + */ + static const int PTME_DATA_REG_OFFSET = 256; - /** The file descriptor of the UIO driver */ - int fd = 0; + /** The file descriptor of the UIO driver */ + int fd = 0; - uint32_t* ptmeBaseAddress = nullptr; + uint32_t* ptmeBaseAddress = nullptr; - using VcInterfaceMap = std::unordered_map; - using VcInterfaceMapIter = VcInterfaceMap::iterator; + using VcInterfaceMap = std::unordered_map; + using VcInterfaceMapIter = VcInterfaceMap::iterator; - VcInterfaceMap vcInterfaceMap; + VcInterfaceMap vcInterfaceMap; }; #endif /* LINUX_OBC_PTME_H_ */ diff --git a/linux/obc/PtmeConfig.h b/linux/obc/PtmeConfig.h index 814dfeda..b5b722ac 100644 --- a/linux/obc/PtmeConfig.h +++ b/linux/obc/PtmeConfig.h @@ -1,9 +1,10 @@ #ifndef LINUX_OBC_PTMECONFIG_H_ #define LINUX_OBC_PTMECONFIG_H_ -#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include + #include "OBSWConfig.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" /** * @brief PTME specific configuration parameters derived from FPGA design and device tree. @@ -11,20 +12,20 @@ * @author J. Meier */ namespace PtmeConfig { - /** - * Offset of virtual channels mapped into address space - * 0x10000 = (0x4000 * 4) - */ - static const uint32_t VC0_OFFSETT = 0; - static const uint32_t VC1_OFFSETT = 0x4000; - static const uint32_t VC2_OFFSETT = 0x8000; - static const uint32_t VC3_OFFSETT = 0xC000; +/** + * Offset of virtual channels mapped into address space + * 0x10000 = (0x4000 * 4) + */ +static const uint32_t VC0_OFFSETT = 0; +static const uint32_t VC1_OFFSETT = 0x4000; +static const uint32_t VC2_OFFSETT = 0x8000; +static const uint32_t VC3_OFFSETT = 0xC000; #if BOARD_TE0720 == 0 - static const char UIO_DEVICE_FILE[] = "/dev/uio1"; +static const char UIO_DEVICE_FILE[] = "/dev/uio1"; #else - static const char UIO_DEVICE_FILE[] = "/dev/uio1"; +static const char UIO_DEVICE_FILE[] = "/dev/uio1"; #endif -}; +}; // namespace PtmeConfig #endif /* LINUX_OBC_PTMECONFIG_H_ */ diff --git a/linux/obc/PtmeIF.h b/linux/obc/PtmeIF.h index 53d9498b..7108df05 100644 --- a/linux/obc/PtmeIF.h +++ b/linux/obc/PtmeIF.h @@ -3,7 +3,6 @@ #include "fsfw/returnvalues/HasReturnvaluesIF.h" - /** * @brief Interface class for managing the PTME IP Core implemented in the programmable logic. * @@ -12,17 +11,17 @@ * @author J. Meier */ class PtmeIF { -public: - virtual ~PtmeIF(){}; + public: + virtual ~PtmeIF(){}; - /** - * @brief Implements to function to write to a specific virtual channel. - * - * @param vcId Virtual channel to write to - * @param data Pointer to buffer holding the data to write - * @param size Number of bytes to write - */ - virtual ReturnValue_t writeToVc(uint8_t vcId, const uint8_t* data, size_t size) = 0; + /** + * @brief Implements to function to write to a specific virtual channel. + * + * @param vcId Virtual channel to write to + * @param data Pointer to buffer holding the data to write + * @param size Number of bytes to write + */ + virtual ReturnValue_t writeToVc(uint8_t vcId, const uint8_t* data, size_t size) = 0; }; #endif /* LINUX_OBC_PTMEIF_H_ */ diff --git a/linux/obc/PtmeRateSetter.cpp b/linux/obc/PtmeRateSetter.cpp index 92886623..b5a6ee1c 100644 --- a/linux/obc/PtmeRateSetter.cpp +++ b/linux/obc/PtmeRateSetter.cpp @@ -1,27 +1,25 @@ #include "PtmeRateSetter.h" + #include "fsfw/serviceinterface/ServiceInterface.h" -PtmeRateSetter::PtmeRateSetter(gpioId_t bitrateSel, GpioIF* gpioif) : - bitrateSel(bitrateSel), gpioif(gpioif) { -} +PtmeRateSetter::PtmeRateSetter(gpioId_t bitrateSel, GpioIF* gpioif) + : bitrateSel(bitrateSel), gpioif(gpioif) {} -PtmeRateSetter::~PtmeRateSetter() { -} +PtmeRateSetter::~PtmeRateSetter() {} ReturnValue_t PtmeRateSetter::setRate(BitRates rate) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - switch(rate) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + switch (rate) { case RATE_2000KHZ: - result = gpioif->pullHigh(bitrateSel); - break; + result = gpioif->pullHigh(bitrateSel); + break; case RATE_400KHZ: - result = gpioif->pullLow(bitrateSel); - break; + result = gpioif->pullLow(bitrateSel); + break; default: - sif::debug << "PtmeRateSetter::setRate: Invalid rate" << std::endl; - result = HasReturnvaluesIF::RETURN_FAILED; - break; - } - return result; + sif::debug << "PtmeRateSetter::setRate: Invalid rate" << std::endl; + result = HasReturnvaluesIF::RETURN_FAILED; + break; + } + return result; } - diff --git a/linux/obc/PtmeRateSetter.h b/linux/obc/PtmeRateSetter.h index ece78e91..14dfec4b 100644 --- a/linux/obc/PtmeRateSetter.h +++ b/linux/obc/PtmeRateSetter.h @@ -2,9 +2,9 @@ #define LINUX_OBC_PTMERATESETTER_H_ #include "TxRateSetterIF.h" -#include "fsfw_hal/common/gpio/gpioDefinitions.h" -#include "fsfw_hal/common/gpio/GpioIF.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw_hal/common/gpio/GpioIF.h" +#include "fsfw_hal/common/gpio/gpioDefinitions.h" /** * @brief Class to set the downlink bit rate by using the cadu_rate_switcher implemented in @@ -15,26 +15,24 @@ * * @author J. Meier */ -class PtmeRateSetter: public TxRateSetterIF { -public: +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(); - /** - * @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(); + virtual ReturnValue_t setRate(BitRates rate); - virtual ReturnValue_t setRate(BitRates rate); + private: + gpioId_t bitrateSel = gpio::NO_GPIO; -private: - - gpioId_t bitrateSel = gpio::NO_GPIO; - - GpioIF* gpioif = nullptr; + GpioIF* gpioif = nullptr; }; #endif /* LINUX_OBC_PTMERATESETTER_H_ */ diff --git a/linux/obc/TxRateSetterIF.h b/linux/obc/TxRateSetterIF.h index c07106e4..1eaded33 100644 --- a/linux/obc/TxRateSetterIF.h +++ b/linux/obc/TxRateSetterIF.h @@ -3,10 +3,7 @@ #include "fsfw/returnvalues/HasReturnvaluesIF.h" -enum BitRates : uint32_t { - RATE_2000KHZ, - RATE_400KHZ -}; +enum BitRates : uint32_t { RATE_2000KHZ, RATE_400KHZ }; /** * @brief Abstract class for objects implementing the functionality to switch the @@ -15,11 +12,11 @@ enum BitRates : uint32_t { * @author J. Meier */ class TxRateSetterIF { -public: - TxRateSetterIF() {}; - virtual ~TxRateSetterIF() {}; + public: + TxRateSetterIF(){}; + virtual ~TxRateSetterIF(){}; - virtual ReturnValue_t setRate(BitRates bitRate) = 0; + virtual ReturnValue_t setRate(BitRates bitRate) = 0; }; #endif /* LINUX_OBC_TXRATESETTERIF_H_ */ diff --git a/linux/obc/VcInterfaceIF.h b/linux/obc/VcInterfaceIF.h index 28b8d1f1..0aa95691 100644 --- a/linux/obc/VcInterfaceIF.h +++ b/linux/obc/VcInterfaceIF.h @@ -2,6 +2,7 @@ #define LINUX_OBC_VCINTERFACEIF_H_ #include + #include "fsfw/returnvalues/HasReturnvaluesIF.h" /** @@ -11,19 +12,19 @@ * @author J. Meier */ class VcInterfaceIF { -public: - virtual ~VcInterfaceIF(){}; + public: + virtual ~VcInterfaceIF(){}; - /** - * @brief Implememts the functionality to write data in the virtual channel of the PTME IP - * Core. - * - * @param data Pointer to buffer holding the data to write - * @param size Number of bytes to write - */ - virtual ReturnValue_t write(const uint8_t* data, size_t size) = 0; + /** + * @brief Implememts the functionality to write data in the virtual channel of the PTME IP + * Core. + * + * @param data Pointer to buffer holding the data to write + * @param size Number of bytes to write + */ + virtual ReturnValue_t write(const uint8_t* data, size_t size) = 0; - virtual void setRegisterAddress(uint32_t* ptmeBaseAddress) = 0; + virtual void setRegisterAddress(uint32_t* ptmeBaseAddress) = 0; }; #endif /* LINUX_OBC_VCINTERFACEIF_H_ */ diff --git a/linux/utility/utility.cpp b/linux/utility/utility.cpp index 1d6ec5c0..cd0d47ef 100644 --- a/linux/utility/utility.cpp +++ b/linux/utility/utility.cpp @@ -1,13 +1,14 @@ -#include "OBSWConfig.h" -#include "FSFWConfig.h" #include "utility.h" -#include "fsfw/serviceinterface/ServiceInterface.h" #include +#include "FSFWConfig.h" +#include "OBSWConfig.h" +#include "fsfw/serviceinterface/ServiceInterface.h" + void utility::handleSystemError(int retcode, std::string function) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::warning << function << ": System call failed with code " << retcode << ": " << - strerror(retcode) << std::endl; + sif::warning << function << ": System call failed with code " << retcode << ": " + << strerror(retcode) << std::endl; #endif } diff --git a/linux/utility/utility.h b/linux/utility/utility.h index 3eb17a9b..8f7df04f 100644 --- a/linux/utility/utility.h +++ b/linux/utility/utility.h @@ -1,9 +1,10 @@ #ifndef LINUX_UTILITY_UTILITY_H_ #define LINUX_UTILITY_UTILITY_H_ -#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include +#include "fsfw/returnvalues/HasReturnvaluesIF.h" + namespace utility { void handleSystemError(int retcode, std::string function); diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 538e63f3..cd8c8b22 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1,49 +1,42 @@ #include "ThermalController.h" + #include -ThermalController::ThermalController(object_id_t objectId): - ExtendedControllerBase(objectId, objects::NO_OBJECT), - thermalControllerSet(objectId) { +ThermalController::ThermalController(object_id_t objectId) + : ExtendedControllerBase(objectId, objects::NO_OBJECT), thermalControllerSet(objectId) {} + +ReturnValue_t ThermalController::handleCommandMessage(CommandMessage *message) { + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t ThermalController::handleCommandMessage( - CommandMessage *message) { - return HasReturnvaluesIF::RETURN_OK; -} +void ThermalController::performControlOperation() {} -void ThermalController::performControlOperation() { - -} - -void ThermalController::handleChangedDataset(sid_t sid, - store_address_t storeId) { - if(sid == sid_t(TSensorDefinitions::ObjIds::TEST_HKB_HANDLER, - TSensorDefinitions::THERMAL_SENSOR_SET_ID)) { - sif::info << "Update registered!" << std::endl; - } +void ThermalController::handleChangedDataset(sid_t sid, store_address_t storeId) { + if (sid == sid_t(TSensorDefinitions::ObjIds::TEST_HKB_HANDLER, + TSensorDefinitions::THERMAL_SENSOR_SET_ID)) { + sif::info << "Update registered!" << std::endl; + } } ReturnValue_t ThermalController::initializeAfterTaskCreation() { - ReturnValue_t result = - ExtendedControllerBase::initializeAfterTaskCreation(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "ThermalController::initializeAfterTaskCreation: Base" - << " class initialization failed!" << std::endl; - } - HasLocalDataPoolIF* testHkbHandler = ObjectManager::instance()->get( - TSensorDefinitions::ObjIds::TEST_HKB_HANDLER); - if(testHkbHandler == nullptr) { - sif::warning << "ThermalController::initializeAfterTaskCreation: Test" - << " HKB Handler invalid!" << std::endl; - } - // Test normal notifications without data packet first. - testHkbHandler->getHkManagerHandle()->subscribeForSetUpdateMessages( - TSensorDefinitions::THERMAL_SENSOR_SET_ID, - this->getObjectId(), commandQueue->getId(), false); - return result; + ReturnValue_t result = ExtendedControllerBase::initializeAfterTaskCreation(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "ThermalController::initializeAfterTaskCreation: Base" + << " class initialization failed!" << std::endl; + } + HasLocalDataPoolIF *testHkbHandler = ObjectManager::instance()->get( + TSensorDefinitions::ObjIds::TEST_HKB_HANDLER); + if (testHkbHandler == nullptr) { + sif::warning << "ThermalController::initializeAfterTaskCreation: Test" + << " HKB Handler invalid!" << std::endl; + } + // Test normal notifications without data packet first. + testHkbHandler->getHkManagerHandle()->subscribeForSetUpdateMessages( + TSensorDefinitions::THERMAL_SENSOR_SET_ID, this->getObjectId(), commandQueue->getId(), false); + return result; } -ReturnValue_t ThermalController::checkModeCommand(Mode_t mode, - Submode_t submode, uint32_t *msToReachTheMode) { - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t ThermalController::checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t *msToReachTheMode) { + return HasReturnvaluesIF::RETURN_OK; } diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 67c5b24a..2d76ce8d 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -2,32 +2,30 @@ #define MISSION_CONTROLLER_THERMALCONTROLLER_H_ #include + #include "ctrldefinitions/ThermalCtrlPackets.h" +class ThermalController : public ExtendedControllerBase { + public: + ThermalController(object_id_t objectId); -class ThermalController: public ExtendedControllerBase { -public: - ThermalController(object_id_t objectId); -private: + private: + // TODO: Add stubs for thermal components. Each device / assembly with one + // or multiple redundant sensors will have a thermal component. - // TODO: Add stubs for thermal components. Each device / assembly with one - // or multiple redundant sensors will have a thermal component. + /** ExtendedControllerBase overrides */ + virtual ReturnValue_t handleCommandMessage(CommandMessage *message) override; - /** ExtendedControllerBase overrides */ - virtual ReturnValue_t handleCommandMessage( - CommandMessage *message) override; + virtual void performControlOperation() override; - virtual void performControlOperation() override; + virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t *msToReachTheMode) override; - virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, - uint32_t *msToReachTheMode) override; + ReturnValue_t initializeAfterTaskCreation() override; - ReturnValue_t initializeAfterTaskCreation() override; + void handleChangedDataset(sid_t sid, store_address_t storeId) override; - void handleChangedDataset(sid_t sid, store_address_t storeId) override; - - ThermalCtrl::ThermalControllerTemperatureSet thermalControllerSet; + ThermalCtrl::ThermalControllerTemperatureSet thermalControllerSet; }; - #endif /* MISSION_CONTROLLER_THERMALCONTROLLER_H_ */ diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index 14c8791a..b17812e6 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -1,11 +1,6 @@ #include "GenericFactory.h" #include - -#include -#include -#include "objects/systemObjectList.h" - #include #include #include @@ -13,8 +8,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -23,12 +18,16 @@ #include #include #include +#include +#include + +#include "objects/systemObjectList.h" #if OBSW_ADD_TCPIP_BRIDGE == 1 #if OBSW_USE_TCP_BRIDGE == 0 // UDP server includes -#include "fsfw/osal/common/UdpTmTcBridge.h" #include "fsfw/osal/common/UdpTcPollingTask.h" +#include "fsfw/osal/common/UdpTmTcBridge.h" #else // TCP server includes #include "fsfw/osal/common/TcpTmTcBridge.h" @@ -41,78 +40,69 @@ #endif void ObjectFactory::produceGenericObjects() { - // Framework objects - new EventManager(objects::EVENT_MANAGER); - new HealthTable(objects::HEALTH_TABLE); - new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER); - new TimeStamper(objects::TIME_STAMPER); + // Framework objects + new EventManager(objects::EVENT_MANAGER); + new HealthTable(objects::HEALTH_TABLE); + new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER); + new TimeStamper(objects::TIME_STAMPER); - { - PoolManager::LocalPoolConfig poolCfg = { - {300, 16}, {300, 32}, {200, 64}, {200, 128}, {100, 1024}, {10, 2048} - }; - new PoolManager(objects::TC_STORE, poolCfg); - } + { + PoolManager::LocalPoolConfig poolCfg = {{300, 16}, {300, 32}, {200, 64}, + {200, 128}, {100, 1024}, {10, 2048}}; + new PoolManager(objects::TC_STORE, poolCfg); + } - { - PoolManager::LocalPoolConfig poolCfg = { - {300, 16}, {300, 32}, {100, 64}, {100, 128}, {100, 1024}, {10, 2048} - }; - new PoolManager(objects::TM_STORE, poolCfg); - } + { + PoolManager::LocalPoolConfig poolCfg = {{300, 16}, {300, 32}, {100, 64}, + {100, 128}, {100, 1024}, {10, 2048}}; + new PoolManager(objects::TM_STORE, poolCfg); + } - { - PoolManager::LocalPoolConfig poolCfg = { - { 300, 16 }, { 200, 32 }, { 150, 64 }, - { 150, 128 }, { 100, 256 }, { 50, 512 }, { 50, 1024 }, { 10, 2048 } - }; - new PoolManager(objects::IPC_STORE, poolCfg); - } + { + PoolManager::LocalPoolConfig poolCfg = {{300, 16}, {200, 32}, {150, 64}, {150, 128}, + {100, 256}, {50, 512}, {50, 1024}, {10, 2048}}; + new PoolManager(objects::IPC_STORE, poolCfg); + } - new CCSDSDistributor(apid::EIVE_OBSW, objects::CCSDS_PACKET_DISTRIBUTOR); - new PUSDistributor(apid::EIVE_OBSW, objects::PUS_PACKET_DISTRIBUTOR, - objects::CCSDS_PACKET_DISTRIBUTOR); + new CCSDSDistributor(apid::EIVE_OBSW, objects::CCSDS_PACKET_DISTRIBUTOR); + new PUSDistributor(apid::EIVE_OBSW, objects::PUS_PACKET_DISTRIBUTOR, + objects::CCSDS_PACKET_DISTRIBUTOR); + // Every TM packet goes through this funnel + new TmFunnel(objects::TM_FUNNEL); - // Every TM packet goes through this funnel - new TmFunnel(objects::TM_FUNNEL); - - // PUS service stack - new Service1TelecommandVerification(objects::PUS_SERVICE_1_VERIFICATION, - apid::EIVE_OBSW, pus::PUS_SERVICE_1, objects::TM_FUNNEL, 20); - new Service2DeviceAccess(objects::PUS_SERVICE_2_DEVICE_ACCESS, - apid::EIVE_OBSW, pus::PUS_SERVICE_2, 3, 10); - new Service3Housekeeping(objects::PUS_SERVICE_3_HOUSEKEEPING, - apid::EIVE_OBSW, pus::PUS_SERVICE_3); - new Service5EventReporting(objects::PUS_SERVICE_5_EVENT_REPORTING, - apid::EIVE_OBSW, pus::PUS_SERVICE_5, 50); - new Service8FunctionManagement(objects::PUS_SERVICE_8_FUNCTION_MGMT, - apid::EIVE_OBSW, pus::PUS_SERVICE_8, 3, 60); - new Service9TimeManagement(objects::PUS_SERVICE_9_TIME_MGMT, - apid::EIVE_OBSW, pus::PUS_SERVICE_9); - new Service17Test(objects::PUS_SERVICE_17_TEST, apid::EIVE_OBSW, - pus::PUS_SERVICE_17); - new Service20ParameterManagement(objects::PUS_SERVICE_20_PARAMETERS, apid::EIVE_OBSW, - pus::PUS_SERVICE_20); - new CService200ModeCommanding(objects::PUS_SERVICE_200_MODE_MGMT, - apid::EIVE_OBSW, pus::PUS_SERVICE_200); - + // PUS service stack + new Service1TelecommandVerification(objects::PUS_SERVICE_1_VERIFICATION, apid::EIVE_OBSW, + pus::PUS_SERVICE_1, objects::TM_FUNNEL, 20); + new Service2DeviceAccess(objects::PUS_SERVICE_2_DEVICE_ACCESS, apid::EIVE_OBSW, + pus::PUS_SERVICE_2, 3, 10); + new Service3Housekeeping(objects::PUS_SERVICE_3_HOUSEKEEPING, apid::EIVE_OBSW, + pus::PUS_SERVICE_3); + new Service5EventReporting(objects::PUS_SERVICE_5_EVENT_REPORTING, apid::EIVE_OBSW, + pus::PUS_SERVICE_5, 50); + new Service8FunctionManagement(objects::PUS_SERVICE_8_FUNCTION_MGMT, apid::EIVE_OBSW, + pus::PUS_SERVICE_8, 3, 60); + new Service9TimeManagement(objects::PUS_SERVICE_9_TIME_MGMT, apid::EIVE_OBSW, pus::PUS_SERVICE_9); + new Service17Test(objects::PUS_SERVICE_17_TEST, apid::EIVE_OBSW, pus::PUS_SERVICE_17); + new Service20ParameterManagement(objects::PUS_SERVICE_20_PARAMETERS, apid::EIVE_OBSW, + pus::PUS_SERVICE_20); + new CService200ModeCommanding(objects::PUS_SERVICE_200_MODE_MGMT, apid::EIVE_OBSW, + pus::PUS_SERVICE_200); #if OBSW_ADD_TCPIP_BRIDGE == 1 #if OBSW_USE_TCP_BRIDGE == 0 - auto tmtcBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); - sif::info << "Created UDP server for TMTC commanding with listener port " << - udpBridge->getUdpPort() << std::endl; + auto tmtcBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); + sif::info << "Created UDP server for TMTC commanding with listener port " + << udpBridge->getUdpPort() << std::endl; #else - auto tmtcBridge = new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - auto tcpServer = new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); - // TCP is stream based. Use packet ID as start marker when parsing for space packets - tcpServer->setSpacePacketParsingOptions({common::PUS_PACKET_ID}); - sif::info << "Created TCP server for TMTC commanding with listener port " + auto tmtcBridge = new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + auto tcpServer = new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); + // TCP is stream based. Use packet ID as start marker when parsing for space packets + tcpServer->setSpacePacketParsingOptions({common::PUS_PACKET_ID}); + sif::info << "Created TCP server for TMTC commanding with listener port " << tcpServer->getTcpPort() << std::endl; #endif /* OBSW_USE_TMTC_TCP_BRIDGE == 0 */ - tmtcBridge->setMaxNumberOfPacketsStored(70); + tmtcBridge->setMaxNumberOfPacketsStored(70); #endif /* OBSW_ADD_TCPIP_BRIDGE == 1 */ - } diff --git a/mission/core/GenericFactory.h b/mission/core/GenericFactory.h index c96c7818..1a3b1300 100644 --- a/mission/core/GenericFactory.h +++ b/mission/core/GenericFactory.h @@ -5,8 +5,6 @@ namespace ObjectFactory { void produceGenericObjects(); - } - #endif /* MISSION_CORE_GENERICFACTORY_H_ */ diff --git a/mission/devices/ACUHandler.cpp b/mission/devices/ACUHandler.cpp index 955b1703..239a0c7a 100644 --- a/mission/devices/ACUHandler.cpp +++ b/mission/devices/ACUHandler.cpp @@ -1,308 +1,309 @@ #include "ACUHandler.h" + #include "OBSWConfig.h" -ACUHandler::ACUHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - GomspaceDeviceHandler(objectId, comIF, comCookie, ACU::MAX_CONFIGTABLE_ADDRESS, - ACU::MAX_HKTABLE_ADDRESS, ACU::HK_TABLE_REPLY_SIZE, &acuHkTableDataset), acuHkTableDataset( - this) { -} +ACUHandler::ACUHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie) + : GomspaceDeviceHandler(objectId, comIF, comCookie, ACU::MAX_CONFIGTABLE_ADDRESS, + ACU::MAX_HKTABLE_ADDRESS, ACU::HK_TABLE_REPLY_SIZE, &acuHkTableDataset), + acuHkTableDataset(this) {} -ACUHandler::~ACUHandler() { -} +ACUHandler::~ACUHandler() {} -ReturnValue_t ACUHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - *id = GOMSPACE::REQUEST_HK_TABLE; - return buildCommandFromCommand(*id, NULL, 0); +ReturnValue_t ACUHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + *id = GOMSPACE::REQUEST_HK_TABLE; + return buildCommandFromCommand(*id, NULL, 0); } void ACUHandler::fillCommandAndReplyMap() { - GomspaceDeviceHandler::fillCommandAndReplyMap(); - this->insertInCommandMap(PRINT_CHANNEL_STATS); + GomspaceDeviceHandler::fillCommandAndReplyMap(); + this->insertInCommandMap(PRINT_CHANNEL_STATS); } void ACUHandler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) { - - parseHkTableReply(packet); - handleDeviceTM(&acuHkTableDataset, id, true); + parseHkTableReply(packet); + handleDeviceTM(&acuHkTableDataset, id, true); #if OBSW_ENHANCED_PRINTOUT == 1 && OBSW_DEBUG_ACU == 1 - acuHkTableDataset.read(); - float temperatureC_1 = acuHkTableDataset.temperature1.value * 0.1; - float temperatureC_2 = acuHkTableDataset.temperature2.value * 0.1; - float temperatureC_3 = acuHkTableDataset.temperature3.value * 0.1; - sif::info << "ACU: Temperature 1: " << temperatureC_1 << " °C" << std::endl; - sif::info << "ACU: Temperature 2: " << temperatureC_2 << " °C" << std::endl; - sif::info << "ACU: Temperature 3: " << temperatureC_3 << " °C" << std::endl; - sif::info << "ACU: Ground Watchdog Timer Count: " - << acuHkTableDataset.wdtCntGnd.value << std::endl; - sif::info << "ACU: Ground watchdog timer, seconds left before reboot: " - << acuHkTableDataset.wdtGndLeft.value << std::endl; - acuHkTableDataset.commit(); + acuHkTableDataset.read(); + float temperatureC_1 = acuHkTableDataset.temperature1.value * 0.1; + float temperatureC_2 = acuHkTableDataset.temperature2.value * 0.1; + float temperatureC_3 = acuHkTableDataset.temperature3.value * 0.1; + sif::info << "ACU: Temperature 1: " << temperatureC_1 << " °C" << std::endl; + sif::info << "ACU: Temperature 2: " << temperatureC_2 << " °C" << std::endl; + sif::info << "ACU: Temperature 3: " << temperatureC_3 << " °C" << std::endl; + sif::info << "ACU: Ground Watchdog Timer Count: " << acuHkTableDataset.wdtCntGnd.value + << std::endl; + sif::info << "ACU: Ground watchdog timer, seconds left before reboot: " + << acuHkTableDataset.wdtGndLeft.value << std::endl; + acuHkTableDataset.commit(); #endif } void ACUHandler::parseHkTableReply(const uint8_t *packet) { - uint16_t dataOffset = 0; - acuHkTableDataset.read(); - dataOffset += 12; - acuHkTableDataset.currentInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.currentInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.currentInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.currentInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.currentInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.currentInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + uint16_t dataOffset = 0; + acuHkTableDataset.read(); + dataOffset += 12; + acuHkTableDataset.currentInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.currentInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.currentInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.currentInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.currentInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.currentInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.voltageInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.voltageInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.voltageInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.voltageInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.voltageInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.voltageInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + acuHkTableDataset.voltageInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.voltageInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.voltageInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.voltageInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.voltageInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.voltageInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + acuHkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.temperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.temperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.temperature3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + acuHkTableDataset.temperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.temperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.temperature3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.mpptMode = *(packet + dataOffset); - dataOffset += 3; + acuHkTableDataset.mpptMode = *(packet + dataOffset); + dataOffset += 3; - acuHkTableDataset.vboostInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.vboostInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.vboostInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.vboostInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.vboostInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.vboostInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + acuHkTableDataset.vboostInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.vboostInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.vboostInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.vboostInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.vboostInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.vboostInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.powerInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.powerInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.powerInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.powerInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.powerInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.powerInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + acuHkTableDataset.powerInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.powerInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.powerInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.powerInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.powerInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.powerInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.dac0Enable = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.dac1Enable = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.dac2Enable = *(packet + dataOffset); - dataOffset += 3; + acuHkTableDataset.dac0Enable = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.dac1Enable = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.dac2Enable = *(packet + dataOffset); + dataOffset += 3; - acuHkTableDataset.dacRawChannelVal0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.dacRawChannelVal1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.dacRawChannelVal2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.dacRawChannelVal3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.dacRawChannelVal4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.dacRawChannelVal5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + acuHkTableDataset.dacRawChannelVal0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.dacRawChannelVal1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.dacRawChannelVal2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.dacRawChannelVal3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.dacRawChannelVal4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.dacRawChannelVal5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.bootCause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - acuHkTableDataset.bootcnt = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - acuHkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - acuHkTableDataset.resetCause = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.mpptTime = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - /* +12 because here starts the second csp packet */ - dataOffset += 2 + 12; + acuHkTableDataset.bootCause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + acuHkTableDataset.bootcnt = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + acuHkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + acuHkTableDataset.resetCause = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.mpptTime = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + /* +12 because here starts the second csp packet */ + dataOffset += 2 + 12; - acuHkTableDataset.mpptPeriod = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + acuHkTableDataset.mpptPeriod = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.device0 = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device1 = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device2 = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device3 = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device4 = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device5 = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device6 = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device7 = *(packet + dataOffset); - dataOffset += 3; + acuHkTableDataset.device0 = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device1 = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device2 = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device3 = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device4 = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device5 = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device6 = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device7 = *(packet + dataOffset); + dataOffset += 3; - acuHkTableDataset.device0Status = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device1Status = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device2Status = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device3Status = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device4Status = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device5Status = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device6Status = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device7Status = *(packet + dataOffset); - dataOffset += 3; + acuHkTableDataset.device0Status = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device1Status = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device2Status = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device3Status = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device4Status = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device5Status = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device6Status = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device7Status = *(packet + dataOffset); + dataOffset += 3; - acuHkTableDataset.wdtCntGnd = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - acuHkTableDataset.wdtGndLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; + acuHkTableDataset.wdtCntGnd = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + acuHkTableDataset.wdtGndLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; - acuHkTableDataset.commit(); + acuHkTableDataset.commit(); } -ReturnValue_t ACUHandler::initializeLocalDataPool( - localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { +ReturnValue_t ACUHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL5, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL5, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL5, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL5, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VBAT, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VBAT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_TEMPERATURE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_TEMPERATURE_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_TEMPERATURE_3, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_TEMPERATURE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_TEMPERATURE_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_TEMPERATURE_3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_MPPT_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_MPPT_MODE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL5, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL5, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL5, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL5, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_DAC_EN_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DAC_EN_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DAC_EN_2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_DAC_EN_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DAC_EN_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DAC_EN_2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_DAC_RAW_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DAC_RAW_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DAC_RAW_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DAC_RAW_3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DAC_RAW_4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DAC_RAW_5, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_DAC_RAW_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DAC_RAW_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DAC_RAW_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DAC_RAW_3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DAC_RAW_4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DAC_RAW_5, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_BOOTCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_BOOTCNT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_RESET_CAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_MPPT_TIME, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_MPPT_PERIOD, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_BOOTCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_BOOTCNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_UPTIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_RESET_CAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_MPPT_TIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_MPPT_PERIOD, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_DEVICE_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_5, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_7, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_DEVICE_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_DEVICE_0_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_1_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_2_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_3_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_4_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_5_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_6_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_7_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_DEVICE_0_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_1_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_2_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_3_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_4_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_5_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_6_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_7_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_WDT_CNT_GND, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_WDT_GND_LEFT, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_WDT_CNT_GND, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_WDT_GND_LEFT, new PoolEntry( { 0 })); - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t ACUHandler::deviceSpecificCommand(DeviceCommandId_t cmd) { - switch(cmd) { + switch (cmd) { case PRINT_CHANNEL_STATS: { - printChannelStats(); - return RETURN_OK; + printChannelStats(); + return RETURN_OK; } default: { - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } + } } void ACUHandler::printChannelStats() { - PoolReadGuard pg(&acuHkTableDataset); - sif::info << "ACU Info: Current [mA], Voltage [mV]" << std::endl; - sif::info << std::setw(8) << std::left << "Ch0" << std::dec << "| " << - static_cast(acuHkTableDataset.currentInChannel0.value) << - std::setw(15) << std::right << acuHkTableDataset.voltageInChannel0.value << std::endl; - sif::info << std::setw(8) << std::left << "Ch1" << std::dec << "| " << - static_cast(acuHkTableDataset.currentInChannel1.value) << - std::setw(15) << std::right << acuHkTableDataset.voltageInChannel1.value << std::endl; - sif::info << std::setw(8) << std::left << "Ch2" << std::dec << "| " << - static_cast(acuHkTableDataset.currentInChannel2.value) << - std::setw(15) << std::right << acuHkTableDataset.voltageInChannel2.value << std::endl; - sif::info << std::setw(8) << std::left << "Ch3" << std::dec << "| " << - static_cast(acuHkTableDataset.currentInChannel3.value) << - std::setw(15) << std::right << acuHkTableDataset.voltageInChannel3.value << std::endl; - sif::info << std::setw(8) << std::left << "Ch4" << std::dec << "| " << - static_cast(acuHkTableDataset.currentInChannel4.value) << - std::setw(15) << std::right << acuHkTableDataset.voltageInChannel4.value << std::endl; - sif::info << std::setw(8) << std::left << "Ch5" << std::dec << "| " << - static_cast(acuHkTableDataset.currentInChannel5.value) << - std::setw(15) << std::right << acuHkTableDataset.voltageInChannel5.value << std::endl; + PoolReadGuard pg(&acuHkTableDataset); + sif::info << "ACU Info: Current [mA], Voltage [mV]" << std::endl; + sif::info << std::setw(8) << std::left << "Ch0" << std::dec << "| " + << static_cast(acuHkTableDataset.currentInChannel0.value) << std::setw(15) + << std::right << acuHkTableDataset.voltageInChannel0.value << std::endl; + sif::info << std::setw(8) << std::left << "Ch1" << std::dec << "| " + << static_cast(acuHkTableDataset.currentInChannel1.value) << std::setw(15) + << std::right << acuHkTableDataset.voltageInChannel1.value << std::endl; + sif::info << std::setw(8) << std::left << "Ch2" << std::dec << "| " + << static_cast(acuHkTableDataset.currentInChannel2.value) << std::setw(15) + << std::right << acuHkTableDataset.voltageInChannel2.value << std::endl; + sif::info << std::setw(8) << std::left << "Ch3" << std::dec << "| " + << static_cast(acuHkTableDataset.currentInChannel3.value) << std::setw(15) + << std::right << acuHkTableDataset.voltageInChannel3.value << std::endl; + sif::info << std::setw(8) << std::left << "Ch4" << std::dec << "| " + << static_cast(acuHkTableDataset.currentInChannel4.value) << std::setw(15) + << std::right << acuHkTableDataset.voltageInChannel4.value << std::endl; + sif::info << std::setw(8) << std::left << "Ch5" << std::dec << "| " + << static_cast(acuHkTableDataset.currentInChannel5.value) << std::setw(15) + << std::right << acuHkTableDataset.voltageInChannel5.value << std::endl; } diff --git a/mission/devices/ACUHandler.h b/mission/devices/ACUHandler.h index 2bb688e7..0d93c5fe 100644 --- a/mission/devices/ACUHandler.h +++ b/mission/devices/ACUHandler.h @@ -1,51 +1,50 @@ #ifndef MISSION_DEVICES_ACUHANDLER_H_ #define MISSION_DEVICES_ACUHANDLER_H_ -#include "GomspaceDeviceHandler.h" #include + +#include "GomspaceDeviceHandler.h" #include "fsfw/datapool/PoolReadGuard.h" /** * @brief Handler for the ACU from Gomspace. Monitors and controls the battery charging via * the solar panels. */ -class ACUHandler: public GomspaceDeviceHandler { -public: - ACUHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); - virtual ~ACUHandler(); +class ACUHandler : public GomspaceDeviceHandler { + public: + ACUHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + virtual ~ACUHandler(); - virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; + virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; -protected: + protected: + virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t* packet) override; - virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) override; + /** + * @brief As soon as the device is in MODE_NORMAL, this function is executed periodically. + */ + virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override; - /** - * @brief As soon as the device is in MODE_NORMAL, this function is executed periodically. - */ - virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; + virtual void fillCommandAndReplyMap() override; - virtual void fillCommandAndReplyMap() override; + virtual ReturnValue_t deviceSpecificCommand(DeviceCommandId_t cmd) override; - virtual ReturnValue_t deviceSpecificCommand(DeviceCommandId_t cmd) override; + private: + static const DeviceCommandId_t PRINT_CHANNEL_STATS = 51; -private: + ACU::HkTableDataset acuHkTableDataset; - static const DeviceCommandId_t PRINT_CHANNEL_STATS = 51; + /** + * @brief Function extracts the hk table information from the received csp packet and stores + * the values in the acuHkTableDataset. + */ + void parseHkTableReply(const uint8_t* packet); - ACU::HkTableDataset acuHkTableDataset; - - /** - * @brief Function extracts the hk table information from the received csp packet and stores - * the values in the acuHkTableDataset. - */ - void parseHkTableReply(const uint8_t *packet); - - /** - * @brief Prints channel statistics (current and voltage) to console - */ - void printChannelStats(); + /** + * @brief Prints channel statistics (current and voltage) to console + */ + void printChannelStats(); }; #endif /* MISSION_DEVICES_ACUHANDLER_H_ */ diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index d42421a0..5b2a2a95 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -1,174 +1,168 @@ #include "GPSHyperionHandler.h" -#include "devicedefinitions/GPSDefinitions.h" - -#include "fsfw/datapool/PoolReadGuard.h" -#include "fsfw/timemanager/Clock.h" #include #include + #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 GPSHyperionHandler::GPSHyperionHandler(object_id_t objectId, object_id_t parentId, - bool debugHyperionGps): - ExtendedControllerBase(objectId, objects::NO_OBJECT), gpsSet(this), - debugHyperionGps(debugHyperionGps) { -} + bool debugHyperionGps) + : ExtendedControllerBase(objectId, objects::NO_OBJECT), + gpsSet(this), + debugHyperionGps(debugHyperionGps) {} GPSHyperionHandler::~GPSHyperionHandler() {} -void GPSHyperionHandler::performControlOperation() { - readGpsDataFromGpsd(); -} +void GPSHyperionHandler::performControlOperation() { readGpsDataFromGpsd(); } -LocalPoolDataSetBase* GPSHyperionHandler::getDataSetHandle(sid_t sid) { - return nullptr; -} +LocalPoolDataSetBase *GPSHyperionHandler::getDataSetHandle(sid_t sid) { return nullptr; } ReturnValue_t GPSHyperionHandler::checkModeCommand(Mode_t mode, Submode_t submode, - uint32_t *msToReachTheMode) { - return HasReturnvaluesIF::RETURN_OK; + uint32_t *msToReachTheMode) { + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t GPSHyperionHandler::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; + 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; + } + return HasReturnvaluesIF::RETURN_OK; } -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::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::FIX_MODE, new PoolEntry()); - poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), true, 2.0, false); - return HasReturnvaluesIF::RETURN_OK; +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::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::FIX_MODE, new PoolEntry()); + poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), true, 2.0, false); + return HasReturnvaluesIF::RETURN_OK; } -void GPSHyperionHandler::setResetPinTriggerFunction(gpioResetFunction_t resetCallback, - void *args) { - this->resetCallback = resetCallback; - resetCallbackArgs = args; +void GPSHyperionHandler::setResetPinTriggerFunction(gpioResetFunction_t resetCallback, void *args) { + this->resetCallback = resetCallback; + resetCallbackArgs = args; } - ReturnValue_t GPSHyperionHandler::initialize() { - ReturnValue_t result = ExtendedControllerBase::initialize(); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + ReturnValue_t result = ExtendedControllerBase::initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { return result; + } + return result; } ReturnValue_t GPSHyperionHandler::handleCommandMessage(CommandMessage *message) { - return ExtendedControllerBase::handleCommandMessage(message); + return ExtendedControllerBase::handleCommandMessage(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); - gps_data_t* gps; - gps = gpsmm.read(); - if(gps == nullptr) { - sif::warning << "Q7STestTask: Reading GPS data failed" << std::endl; - } - PoolReadGuard pg(&gpsSet); - if(pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) { + // 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); + gps_data_t *gps; + gps = gpsmm.read(); + if (gps == nullptr) { + sif::warning << "Q7STestTask: 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::scanForReply: 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; - } + } + // Print messages + if ((gps->set & MODE_SET) != MODE_SET) { + // Could not even set mode + gpsSet.setValidity(false, true); + return; + } - if(gps->satellites_used > 0) { - gpsSet.setValidity(true, true); - } + if (gps->satellites_used > 0) { + gpsSet.setValidity(true, true); + } - gpsSet.satInUse.value = gps->satellites_used; - gpsSet.satInView.value = gps->satellites_visible; + 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; - } else { - gpsSet.latitude.setValid(false); - } + // 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; + } 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.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.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); - } + 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; - 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; - } + 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; + 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; + } } diff --git a/mission/devices/GPSHyperionHandler.h b/mission/devices/GPSHyperionHandler.h index 96d6089e..026e1779 100644 --- a/mission/devices/GPSHyperionHandler.h +++ b/mission/devices/GPSHyperionHandler.h @@ -1,10 +1,10 @@ #ifndef MISSION_DEVICES_GPSHYPERIONHANDLER_H_ #define MISSION_DEVICES_GPSHYPERIONHANDLER_H_ -#include "fsfw/FSFW.h" -#include "fsfw/devicehandlers/DeviceHandlerBase.h" -#include "fsfw/controller/ExtendedControllerBase.h" #include "devicedefinitions/GPSDefinitions.h" +#include "fsfw/FSFW.h" +#include "fsfw/controller/ExtendedControllerBase.h" +#include "fsfw/devicehandlers/DeviceHandlerBase.h" /** * @brief Device handler for the Hyperion HT-GPS200 device @@ -12,38 +12,35 @@ * Flight manual: * https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/Hyperion_HT-GPS200 */ -class GPSHyperionHandler: public ExtendedControllerBase { -public: +class GPSHyperionHandler : public ExtendedControllerBase { + public: + GPSHyperionHandler(object_id_t objectId, object_id_t parentId, bool debugHyperionGps = false); + virtual ~GPSHyperionHandler(); - GPSHyperionHandler(object_id_t objectId, object_id_t parentId, - 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 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; - 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: + protected: + gpioResetFunction_t resetCallback = nullptr; + void* resetCallbackArgs = nullptr; - gpioResetFunction_t resetCallback = nullptr; - void* resetCallbackArgs = nullptr; + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) override; + private: + GpsPrimaryDataset gpsSet; + bool debugHyperionGps = false; -private: - GpsPrimaryDataset gpsSet; - bool debugHyperionGps = false; - - void readGpsDataFromGpsd(); + void readGpsDataFromGpsd(); }; #endif /* MISSION_DEVICES_GPSHYPERIONHANDLER_H_ */ diff --git a/mission/devices/GomspaceDeviceHandler.cpp b/mission/devices/GomspaceDeviceHandler.cpp index 95e35a5e..eea1368a 100644 --- a/mission/devices/GomspaceDeviceHandler.cpp +++ b/mission/devices/GomspaceDeviceHandler.cpp @@ -2,411 +2,397 @@ #include GomspaceDeviceHandler::GomspaceDeviceHandler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie, uint16_t maxConfigTableAddress, uint16_t maxHkTableAddress, - uint16_t hkTableReplySize, LocalPoolDataSetBase* hkTableDataset) : - DeviceHandlerBase(objectId, comIF, comCookie), maxConfigTableAddress(maxConfigTableAddress), - maxHkTableAddress(maxHkTableAddress), hkTableReplySize(hkTableReplySize), - hkTableDataset(hkTableDataset) { - if (comCookie == nullptr) { - sif::error << "GomspaceDeviceHandler::GomspaceDeviceHandler: Invalid com cookie" - << std::endl; - } - if (hkTableDataset == nullptr) { - sif::error << "GomspaceDeviceHandler::GomspaceDeviceHandler: Invalid hk table data set" - << std::endl; - } + CookieIF* comCookie, uint16_t maxConfigTableAddress, + uint16_t maxHkTableAddress, uint16_t hkTableReplySize, + LocalPoolDataSetBase* hkTableDataset) + : DeviceHandlerBase(objectId, comIF, comCookie), + maxConfigTableAddress(maxConfigTableAddress), + maxHkTableAddress(maxHkTableAddress), + hkTableReplySize(hkTableReplySize), + hkTableDataset(hkTableDataset) { + if (comCookie == nullptr) { + sif::error << "GomspaceDeviceHandler::GomspaceDeviceHandler: Invalid com cookie" << std::endl; + } + if (hkTableDataset == nullptr) { + sif::error << "GomspaceDeviceHandler::GomspaceDeviceHandler: Invalid hk table data set" + << std::endl; + } } -GomspaceDeviceHandler::~GomspaceDeviceHandler() { +GomspaceDeviceHandler::~GomspaceDeviceHandler() {} + +void GomspaceDeviceHandler::doStartUp() {} + +void GomspaceDeviceHandler::doShutDown() {} + +ReturnValue_t GomspaceDeviceHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + return HasReturnvaluesIF::RETURN_OK; } - -void GomspaceDeviceHandler::doStartUp(){ +ReturnValue_t GomspaceDeviceHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { + return HasReturnvaluesIF::RETURN_OK; } -void GomspaceDeviceHandler::doShutDown(){ - -} - -ReturnValue_t GomspaceDeviceHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t GomspaceDeviceHandler::buildTransitionDeviceCommand( - DeviceCommandId_t * id){ - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t GomspaceDeviceHandler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t * commandData, - size_t commandDataLen) { - ReturnValue_t result; - switch(deviceCommand) { - case(GOMSPACE::PING): { - result = generatePingCommand(commandData, commandDataLen); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - break; +ReturnValue_t GomspaceDeviceHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t* commandData, + size_t commandDataLen) { + ReturnValue_t result; + switch (deviceCommand) { + case (GOMSPACE::PING): { + result = generatePingCommand(commandData, commandDataLen); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + break; } - case(GOMSPACE::REBOOT): { - generateRebootCommand(); - break; + case (GOMSPACE::REBOOT): { + generateRebootCommand(); + break; } - case(GOMSPACE::PARAM_SET):{ - result = generateSetParamCommand(commandData, commandDataLen); - if(result != HasReturnvaluesIF::RETURN_OK){ - return result; - } - break; + case (GOMSPACE::PARAM_SET): { + result = generateSetParamCommand(commandData, commandDataLen); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + break; } - case(GOMSPACE::PARAM_GET):{ - result = generateGetParamCommand(commandData, commandDataLen); - if(result != HasReturnvaluesIF::RETURN_OK){ - return result; - } - break; + case (GOMSPACE::PARAM_GET): { + result = generateGetParamCommand(commandData, commandDataLen); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + break; } - case(GOMSPACE::GNDWDT_RESET): { - result = generateResetWatchdogCmd(); - if(result != HasReturnvaluesIF::RETURN_OK){ - return result; - } - break; + case (GOMSPACE::GNDWDT_RESET): { + result = generateResetWatchdogCmd(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + break; } - case(GOMSPACE::PRINT_SWITCH_V_I): { - result = printStatus(deviceCommand); - break; + case (GOMSPACE::PRINT_SWITCH_V_I): { + result = printStatus(deviceCommand); + break; } - case(GOMSPACE::REQUEST_HK_TABLE): { - result = generateRequestFullHkTableCmd(hkTableReplySize); - if(result != HasReturnvaluesIF::RETURN_OK){ - return result; - } - break; + case (GOMSPACE::REQUEST_HK_TABLE): { + result = generateRequestFullHkTableCmd(hkTableReplySize); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + break; } default: - return deviceSpecificCommand(deviceCommand); - } - return HasReturnvaluesIF::RETURN_OK; + return deviceSpecificCommand(deviceCommand); + } + return HasReturnvaluesIF::RETURN_OK; } -void GomspaceDeviceHandler::fillCommandAndReplyMap(){ - this->insertInCommandAndReplyMap(GOMSPACE::PING, 3); - this->insertInCommandMap(GOMSPACE::REBOOT); - this->insertInCommandAndReplyMap(GOMSPACE::PARAM_SET, 3); - this->insertInCommandAndReplyMap(GOMSPACE::PARAM_GET, 3); - this->insertInCommandAndReplyMap(GOMSPACE::REQUEST_HK_TABLE, 3); - this->insertInCommandMap(GOMSPACE::GNDWDT_RESET); - this->insertInCommandMap(GOMSPACE::PRINT_SWITCH_V_I); +void GomspaceDeviceHandler::fillCommandAndReplyMap() { + this->insertInCommandAndReplyMap(GOMSPACE::PING, 3); + this->insertInCommandMap(GOMSPACE::REBOOT); + this->insertInCommandAndReplyMap(GOMSPACE::PARAM_SET, 3); + this->insertInCommandAndReplyMap(GOMSPACE::PARAM_GET, 3); + this->insertInCommandAndReplyMap(GOMSPACE::REQUEST_HK_TABLE, 3); + this->insertInCommandMap(GOMSPACE::GNDWDT_RESET); + this->insertInCommandMap(GOMSPACE::PRINT_SWITCH_V_I); } -ReturnValue_t GomspaceDeviceHandler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { - switch(rememberCommandId) { - case(GOMSPACE::PING): - *foundId = GOMSPACE::PING; - *foundLen = PING_REPLY_SIZE; - rememberCommandId = GOMSPACE::NONE; - break; - case(GOMSPACE::PARAM_GET): { - *foundId = GOMSPACE::PARAM_GET; - *foundLen = rememberRequestedSize + GOMSPACE::GS_HDR_LENGTH; - rememberCommandId = GOMSPACE::NONE; - break; +ReturnValue_t GomspaceDeviceHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + switch (rememberCommandId) { + case (GOMSPACE::PING): + *foundId = GOMSPACE::PING; + *foundLen = PING_REPLY_SIZE; + rememberCommandId = GOMSPACE::NONE; + break; + case (GOMSPACE::PARAM_GET): { + *foundId = GOMSPACE::PARAM_GET; + *foundLen = rememberRequestedSize + GOMSPACE::GS_HDR_LENGTH; + rememberCommandId = GOMSPACE::NONE; + break; } - case(GOMSPACE::PARAM_SET): { - *foundId = GOMSPACE::PARAM_SET; - *foundLen = rememberRequestedSize; - rememberCommandId = GOMSPACE::NONE; - break; + case (GOMSPACE::PARAM_SET): { + *foundId = GOMSPACE::PARAM_SET; + *foundLen = rememberRequestedSize; + rememberCommandId = GOMSPACE::NONE; + break; } - case(GOMSPACE::REQUEST_HK_TABLE): { - *foundId = GOMSPACE::REQUEST_HK_TABLE; - *foundLen = rememberRequestedSize + GOMSPACE::GS_HDR_LENGTH; - rememberCommandId = GOMSPACE::NONE; - break; + case (GOMSPACE::REQUEST_HK_TABLE): { + *foundId = GOMSPACE::REQUEST_HK_TABLE; + *foundLen = rememberRequestedSize + GOMSPACE::GS_HDR_LENGTH; + rememberCommandId = GOMSPACE::NONE; + break; } default: - return IGNORE_REPLY_DATA; - } - return HasReturnvaluesIF::RETURN_OK; + return IGNORE_REPLY_DATA; + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t GomspaceDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { - switch(id) { - case(GOMSPACE::PING): { - SerializeElement replyTime = *packet; - handleDeviceTM(&replyTime, id, true); - break; + const uint8_t* packet) { + switch (id) { + case (GOMSPACE::PING): { + SerializeElement replyTime = *packet; + handleDeviceTM(&replyTime, id, true); + break; } - case(GOMSPACE::PARAM_GET): { - // -2 to subtract address size from gomspace parameter reply packet - uint16_t payloadLength = (*(packet + 2) << 8 | *(packet + 3)) - 2; - if(payloadLength > sizeof(uint32_t)){ - sif::error << "GomspaceDeviceHandler: PARAM_GET: Invalid payload " - << "size in reply" << std::endl; - return INVALID_PAYLOAD_SIZE; - } - uint8_t tempPayloadBuffer[payloadLength]; - /* Extract information from received data */ - CspGetParamReply cspGetParamReply(tempPayloadBuffer, payloadLength); - size_t size = GOMSPACE::GS_HDR_LENGTH + payloadLength; - ReturnValue_t result = cspGetParamReply.deSerialize(&packet, &size, - SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "GomspaceDeviceHandler: Failed to deserialize get parameter" - << "reply" << std::endl; - return result; - } - uint8_t action = cspGetParamReply.getAction(); - uint8_t tableId = cspGetParamReply.getTableId(); - uint16_t address = cspGetParamReply.getAddress(); - /* Pack relevant information into a tm packet */ - ParamReply paramReply(action, tableId, address, payloadLength, - tempPayloadBuffer); - handleDeviceTM(¶mReply, id, true); - break; + case (GOMSPACE::PARAM_GET): { + // -2 to subtract address size from gomspace parameter reply packet + uint16_t payloadLength = (*(packet + 2) << 8 | *(packet + 3)) - 2; + if (payloadLength > sizeof(uint32_t)) { + sif::error << "GomspaceDeviceHandler: PARAM_GET: Invalid payload " + << "size in reply" << std::endl; + return INVALID_PAYLOAD_SIZE; + } + uint8_t tempPayloadBuffer[payloadLength]; + /* Extract information from received data */ + CspGetParamReply cspGetParamReply(tempPayloadBuffer, payloadLength); + size_t size = GOMSPACE::GS_HDR_LENGTH + payloadLength; + ReturnValue_t result = + cspGetParamReply.deSerialize(&packet, &size, SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomspaceDeviceHandler: Failed to deserialize get parameter" + << "reply" << std::endl; + return result; + } + uint8_t action = cspGetParamReply.getAction(); + uint8_t tableId = cspGetParamReply.getTableId(); + uint16_t address = cspGetParamReply.getAddress(); + /* Pack relevant information into a tm packet */ + ParamReply paramReply(action, tableId, address, payloadLength, tempPayloadBuffer); + handleDeviceTM(¶mReply, id, true); + break; } - case(GOMSPACE::PARAM_SET): { - /* When setting a parameter, the p60dock sends back the state of the - * operation */ - if(*packet != PARAM_SET_OK){ - return HasReturnvaluesIF::RETURN_FAILED; - } - break; + case (GOMSPACE::PARAM_SET): { + /* When setting a parameter, the p60dock sends back the state of the + * operation */ + if (*packet != PARAM_SET_OK) { + return HasReturnvaluesIF::RETURN_FAILED; + } + break; } - case(GOMSPACE::REQUEST_HK_TABLE): { - letChildHandleHkReply(id, packet); - break; + case (GOMSPACE::REQUEST_HK_TABLE): { + letChildHandleHkReply(id, packet); + break; } default: - break; - } - return HasReturnvaluesIF::RETURN_OK; + break; + } + return HasReturnvaluesIF::RETURN_OK; } -void GomspaceDeviceHandler::setNormalDatapoolEntriesInvalid(){ +void GomspaceDeviceHandler::setNormalDatapoolEntriesInvalid() {} +ReturnValue_t GomspaceDeviceHandler::generateSetParamCommand(const uint8_t* commandData, + size_t commandDataLen) { + SetParamMessageUnpacker setParamMessageUnpacker; + ReturnValue_t result = setParamMessageUnpacker.deSerialize(&commandData, &commandDataLen, + SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomspaceDeviceHandler: Failed to deserialize set parameter " + "message" + << std::endl; + return result; + } + /* Get and check address */ + uint16_t address = setParamMessageUnpacker.getAddress(); + if (address > maxConfigTableAddress) { + sif::error << "GomspaceDeviceHandler: Invalid address for set parameter " + << "action" << std::endl; + return INVALID_ADDRESS; + } + uint16_t checksum = GOMSPACE::IGNORE_CHECKSUM; + uint16_t seq = 0; + 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(); + uint16_t payloadlength = sizeof(address) + parameterSize; + + /* Generate command for CspComIF */ + CspSetParamCommand setParamCmd(querySize, payloadlength, checksum, seq, total, address, + parameterPtr, parameterSize); + size_t cspPacketLen = 0; + uint8_t* buffer = cspPacket; + result = setParamCmd.serialize(&buffer, &cspPacketLen, sizeof(cspPacket), + SerializeIF::Endianness::BIG); + + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomspaceDeviceHandler: Failed to serialize command for " + << "CspComIF" << std::endl; + return result; + } + if (cspPacketLen > MAX_PACKET_LEN) { + sif::error << "GomspaceDeviceHandler: Invalid length of set parameter " + "command" + << std::endl; + return PACKET_TOO_LONG; + } + rawPacket = cspPacket; + rawPacketLen = cspPacketLen; + rememberRequestedSize = querySize; + rememberCommandId = GOMSPACE::PARAM_SET; + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t GomspaceDeviceHandler::generateSetParamCommand( - const uint8_t * commandData, size_t commandDataLen) { - SetParamMessageUnpacker setParamMessageUnpacker; - ReturnValue_t result = setParamMessageUnpacker.deSerialize(&commandData, - &commandDataLen, SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "GomspaceDeviceHandler: Failed to deserialize set parameter " - "message" << std::endl; - return result; - } - /* Get and check address */ - uint16_t address = setParamMessageUnpacker.getAddress(); - if(address > maxConfigTableAddress){ - sif::error << "GomspaceDeviceHandler: Invalid address for set parameter " - << "action" << std::endl; - return INVALID_ADDRESS; - } - uint16_t checksum = GOMSPACE::IGNORE_CHECKSUM; - uint16_t seq = 0; - 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(); - uint16_t payloadlength = sizeof(address) + parameterSize; +ReturnValue_t GomspaceDeviceHandler::generateGetParamCommand(const uint8_t* commandData, + size_t commandDataLen) { + ReturnValue_t result; + /* Unpack the received action message */ + GetParamMessageUnpacker getParamMessage; + result = getParamMessage.deSerialize(&commandData, &commandDataLen, SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Failed to deserialize message to extract information " + "from get parameter message" + << std::endl; + return result; + } + /* Get an check table id to read from */ + uint8_t tableId = getParamMessage.getTableId(); + if (tableId != CONFIG_TABLE_ID && tableId != HK_TABLE_ID) { + sif::error << "GomspaceDeviceHandler: Invalid table id in get parameter" + " message" + << std::endl; + return INVALID_TABLE_ID; + } + /* Get and check address */ + uint16_t address = getParamMessage.getAddress(); + if (address > maxHkTableAddress && tableId == HK_TABLE_ID) { + sif::error << "GomspaceDeviceHandler: Invalid address to get parameter from " + << "housekeeping table" << std::endl; + return INVALID_ADDRESS; + } + if (address > maxConfigTableAddress && tableId == CONFIG_TABLE_ID) { + sif::error << "GomspaceDeviceHandler: Invalid address to get parameter from " + << "configuration table" << std::endl; + return INVALID_ADDRESS; + } + uint16_t length = sizeof(address); + uint16_t checksum = GOMSPACE::IGNORE_CHECKSUM; + uint16_t seq = 0; + uint16_t total = 0; + uint8_t parameterSize = getParamMessage.getParameterSize(); + if (parameterSize > sizeof(uint32_t)) { + sif::error << "GomspaceDeviceHandler: GET_PARAM: Invalid parameter " + << "size" << std::endl; + return INVALID_PARAM_SIZE; + } + uint16_t querySize = parameterSize + GOMSPACE::GS_HDR_LENGTH; - /* Generate command for CspComIF */ - CspSetParamCommand setParamCmd(querySize, payloadlength, checksum, seq, - total, address, parameterPtr, parameterSize); - size_t cspPacketLen = 0; - uint8_t* buffer = cspPacket; - result = setParamCmd.serialize(&buffer, &cspPacketLen, sizeof(cspPacket), - SerializeIF::Endianness::BIG); - - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "GomspaceDeviceHandler: Failed to serialize command for " - << "CspComIF" << std::endl; - return result; - } - if(cspPacketLen > MAX_PACKET_LEN){ - sif::error << "GomspaceDeviceHandler: Invalid length of set parameter " - "command" << std::endl; - return PACKET_TOO_LONG; - } - rawPacket = cspPacket; - rawPacketLen = cspPacketLen; - rememberRequestedSize = querySize; - rememberCommandId = GOMSPACE::PARAM_SET; - return HasReturnvaluesIF::RETURN_OK; + /* Generate the CSP command to send to the P60 Dock */ + CspGetParamCommand getParamCmd(querySize, tableId, length, checksum, seq, total, address); + size_t cspPacketLen = 0; + uint8_t* buffer = cspPacket; + result = getParamCmd.serialize(&buffer, &cspPacketLen, sizeof(cspPacket), + SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomspaceDeviceHandler: Failed to serialize command to " + << "get parameter" << std::endl; + } + if (cspPacketLen > MAX_PACKET_LEN) { + sif::error << "GomspaceDeviceHandler: Received invalid get parameter " + "command" + << std::endl; + return PACKET_TOO_LONG; + } + rawPacket = cspPacket; + rawPacketLen = cspPacketLen; + rememberRequestedSize = querySize; + rememberCommandId = GOMSPACE::PARAM_GET; + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t GomspaceDeviceHandler::generateGetParamCommand( - const uint8_t * commandData, size_t commandDataLen){ - ReturnValue_t result; - /* Unpack the received action message */ - GetParamMessageUnpacker getParamMessage; - result = getParamMessage.deSerialize(&commandData, &commandDataLen, - SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Failed to deserialize message to extract information " - "from get parameter message" << std::endl; - return result; - } - /* Get an check table id to read from */ - uint8_t tableId = getParamMessage.getTableId(); - if(tableId != CONFIG_TABLE_ID && tableId != HK_TABLE_ID){ - sif::error << "GomspaceDeviceHandler: Invalid table id in get parameter" - " message" << std::endl; - return INVALID_TABLE_ID; - } - /* Get and check address */ - uint16_t address = getParamMessage.getAddress(); - if(address > maxHkTableAddress && tableId == HK_TABLE_ID){ - sif::error << "GomspaceDeviceHandler: Invalid address to get parameter from " - << "housekeeping table" << std::endl; - return INVALID_ADDRESS; - } - if(address > maxConfigTableAddress && tableId == CONFIG_TABLE_ID){ - sif::error << "GomspaceDeviceHandler: Invalid address to get parameter from " - << "configuration table" << std::endl; - return INVALID_ADDRESS; - } - uint16_t length = sizeof(address); - uint16_t checksum = GOMSPACE::IGNORE_CHECKSUM; - uint16_t seq = 0; - uint16_t total = 0; - uint8_t parameterSize = getParamMessage.getParameterSize(); - if(parameterSize > sizeof(uint32_t)) { - sif::error << "GomspaceDeviceHandler: GET_PARAM: Invalid parameter " - << "size" << std::endl; - return INVALID_PARAM_SIZE; - } - uint16_t querySize = parameterSize + GOMSPACE::GS_HDR_LENGTH; - - /* Generate the CSP command to send to the P60 Dock */ - CspGetParamCommand getParamCmd(querySize, tableId, length, - checksum, seq, total, address); - size_t cspPacketLen = 0; - uint8_t* buffer = cspPacket; - result = getParamCmd.serialize(&buffer, &cspPacketLen, sizeof(cspPacket), - SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "GomspaceDeviceHandler: Failed to serialize command to " - << "get parameter" << std::endl; - } - if(cspPacketLen > MAX_PACKET_LEN){ - sif::error << "GomspaceDeviceHandler: Received invalid get parameter " - "command" << std::endl; - return PACKET_TOO_LONG; - } - rawPacket = cspPacket; - rawPacketLen = cspPacketLen; - rememberRequestedSize = querySize; - rememberCommandId = GOMSPACE::PARAM_GET; - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t GomspaceDeviceHandler::generatePingCommand(const uint8_t* commandData, + size_t commandDataLen) { + CspPingCommand cspPingCommand(commandData, commandDataLen); + size_t cspPacketLen = 0; + uint8_t* buffer = cspPacket; + ReturnValue_t result = cspPingCommand.serialize(&buffer, &cspPacketLen, sizeof(cspPacket), + SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomspaceDeviceHandler: Failed to serialize ping command" << std::endl; + return result; + } + if (cspPacketLen > MAX_PACKET_LEN) { + sif::error << "GomspaceDeviceHandler: Received invalid ping message" << std::endl; + return PACKET_TOO_LONG; + } + rawPacket = cspPacket; + rawPacketLen = cspPacketLen; + rememberCommandId = GOMSPACE::PING; + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t GomspaceDeviceHandler::generatePingCommand( - const uint8_t * commandData, size_t commandDataLen) { - CspPingCommand cspPingCommand(commandData, commandDataLen); - size_t cspPacketLen = 0; - uint8_t* buffer = cspPacket; - ReturnValue_t result = cspPingCommand.serialize(&buffer, &cspPacketLen, - sizeof(cspPacket), - SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "GomspaceDeviceHandler: Failed to serialize ping command" - << std::endl; - return result; - } - if(cspPacketLen > MAX_PACKET_LEN){ - sif::error << "GomspaceDeviceHandler: Received invalid ping message" - << std::endl; - return PACKET_TOO_LONG; - } - rawPacket = cspPacket; - rawPacketLen = cspPacketLen; - rememberCommandId = GOMSPACE::PING; - return HasReturnvaluesIF::RETURN_OK; +void GomspaceDeviceHandler::generateRebootCommand() { + uint8_t cspPort = GOMSPACE::REBOOT_PORT; + uint16_t querySize = 0; + *cspPacket = GOMSPACE::REBOOT_PORT; + *(cspPacket + 1) = querySize; + size_t cspPacketLen = sizeof(cspPort) + sizeof(cspPacketLen); + rawPacket = cspPacket; + rawPacketLen = cspPacketLen; } -void GomspaceDeviceHandler::generateRebootCommand(){ - uint8_t cspPort = GOMSPACE::REBOOT_PORT; - uint16_t querySize = 0; - *cspPacket = GOMSPACE::REBOOT_PORT; - *(cspPacket + 1) = querySize; - size_t cspPacketLen = sizeof(cspPort) + sizeof(cspPacketLen); - rawPacket = cspPacket; - rawPacketLen = cspPacketLen; -} - -ReturnValue_t GomspaceDeviceHandler::generateResetWatchdogCmd(){ - WatchdogResetCommand watchdogResetCommand; - size_t cspPacketLen = 0; - uint8_t* buffer = cspPacket; - ReturnValue_t result = watchdogResetCommand.serialize(&buffer, - &cspPacketLen, sizeof(cspPacket), SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "GomspaceDeviceHandler: Failed to serialize watchdog reset " - << "command" << std::endl; - return result; - } - rawPacket = cspPacket; - rawPacketLen = cspPacketLen; - rememberRequestedSize = 0; // No bytes will be queried with the ground - // watchdog command. - rememberCommandId = GOMSPACE::GNDWDT_RESET; - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t GomspaceDeviceHandler::generateResetWatchdogCmd() { + WatchdogResetCommand watchdogResetCommand; + size_t cspPacketLen = 0; + uint8_t* buffer = cspPacket; + ReturnValue_t result = watchdogResetCommand.serialize(&buffer, &cspPacketLen, sizeof(cspPacket), + SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomspaceDeviceHandler: Failed to serialize watchdog reset " + << "command" << std::endl; + return result; + } + rawPacket = cspPacket; + rawPacketLen = cspPacketLen; + rememberRequestedSize = 0; // No bytes will be queried with the ground + // watchdog command. + rememberCommandId = GOMSPACE::GNDWDT_RESET; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t GomspaceDeviceHandler::generateRequestFullHkTableCmd(uint16_t hkTableReplySize) { + uint16_t querySize = hkTableReplySize; + uint8_t tableId = HK_TABLE_ID; + RequestFullTableCommand requestFullTableCommand(querySize, tableId); - uint16_t querySize = hkTableReplySize; - uint8_t tableId = HK_TABLE_ID; - RequestFullTableCommand requestFullTableCommand(querySize, tableId); - - size_t cspPacketLen = 0; - uint8_t* buffer = cspPacket; - ReturnValue_t result = requestFullTableCommand.serialize(&buffer, - &cspPacketLen, sizeof(cspPacket), SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "GomspaceDeviceHandler::generateRequestFullHkTableCmd Failed to serialize " - "full table request command " << std::endl; - return result; - } - rawPacket = cspPacket; - rawPacketLen = cspPacketLen; - rememberRequestedSize = querySize; - rememberCommandId = GOMSPACE::REQUEST_HK_TABLE; - return RETURN_OK; + size_t cspPacketLen = 0; + uint8_t* buffer = cspPacket; + ReturnValue_t result = requestFullTableCommand.serialize( + &buffer, &cspPacketLen, sizeof(cspPacket), SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomspaceDeviceHandler::generateRequestFullHkTableCmd Failed to serialize " + "full table request command " + << std::endl; + return result; + } + rawPacket = cspPacket; + rawPacketLen = cspPacketLen; + rememberRequestedSize = querySize; + rememberCommandId = GOMSPACE::REQUEST_HK_TABLE; + return RETURN_OK; } -uint32_t GomspaceDeviceHandler::getTransitionDelayMs(Mode_t modeFrom, - Mode_t modeTo) { - return 0; -} +uint32_t GomspaceDeviceHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 0; } LocalPoolDataSetBase* GomspaceDeviceHandler::getDataSetHandle(sid_t sid) { - if(sid == hkTableDataset->getSid()) { - return hkTableDataset; - } - else { - return nullptr; - } + if (sid == hkTableDataset->getSid()) { + return hkTableDataset; + } else { + return nullptr; + } } ReturnValue_t GomspaceDeviceHandler::deviceSpecificCommand(DeviceCommandId_t cmd) { - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } -void GomspaceDeviceHandler::setModeNormal() { - mode = MODE_NORMAL; -} +void GomspaceDeviceHandler::setModeNormal() { mode = MODE_NORMAL; } ReturnValue_t GomspaceDeviceHandler::printStatus(DeviceCommandId_t cmd) { - sif::info << "No printHkTable implementation given.." << std::endl; - return HasReturnvaluesIF::RETURN_OK; + sif::info << "No printHkTable implementation given.." << std::endl; + return HasReturnvaluesIF::RETURN_OK; } diff --git a/mission/devices/GomspaceDeviceHandler.h b/mission/devices/GomspaceDeviceHandler.h index 29156fce..c9c08609 100644 --- a/mission/devices/GomspaceDeviceHandler.h +++ b/mission/devices/GomspaceDeviceHandler.h @@ -16,135 +16,125 @@ * Flight manual: * https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/Gomspace_PCDU_P60_System */ -class GomspaceDeviceHandler: public DeviceHandlerBase { -public: +class GomspaceDeviceHandler : public DeviceHandlerBase { + public: + static constexpr uint8_t CLASS_ID = CLASS_ID::GOM_SPACE_HANDLER; + static const ReturnValue_t PACKET_TOO_LONG = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 0); + static const ReturnValue_t INVALID_TABLE_ID = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 1); + static const ReturnValue_t INVALID_ADDRESS = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 2); + static const ReturnValue_t INVALID_PARAM_SIZE = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 3); + static const ReturnValue_t INVALID_PAYLOAD_SIZE = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 4); + static const ReturnValue_t UNKNOWN_REPLY_ID = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 5); - static constexpr uint8_t CLASS_ID = CLASS_ID::GOM_SPACE_HANDLER; - static const ReturnValue_t PACKET_TOO_LONG = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 0); - static const ReturnValue_t INVALID_TABLE_ID = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 1); - static const ReturnValue_t INVALID_ADDRESS = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 2); - static const ReturnValue_t INVALID_PARAM_SIZE = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 3); - static const ReturnValue_t INVALID_PAYLOAD_SIZE = - HasReturnvaluesIF::makeReturnCode(CLASS_ID, 4); - static const ReturnValue_t UNKNOWN_REPLY_ID = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 5); + /** + * @brief Constructor + * + * @param maxConfigTableAddress The maximum memory address of the configu- + * ration table of a gomspace device. + * @param maxHkTableAddress The maximum memory address of a value in the + * houskeeping (telemetry) table of a gomspace + * device. + */ + GomspaceDeviceHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie, + uint16_t maxConfigTableAddress, uint16_t maxHkTableAddress, + uint16_t hkTableReplySize, LocalPoolDataSetBase *hkTableDataset); + virtual ~GomspaceDeviceHandler(); - /** - * @brief Constructor - * - * @param maxConfigTableAddress The maximum memory address of the configu- - * ration table of a gomspace device. - * @param maxHkTableAddress The maximum memory address of a value in the - * houskeeping (telemetry) table of a gomspace - * device. - */ - GomspaceDeviceHandler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie, uint16_t maxConfigTableAddress, uint16_t maxHkTableAddress, - uint16_t hkTableReplySize, LocalPoolDataSetBase* hkTableDataset); - virtual ~GomspaceDeviceHandler(); + /** + * @brief This function can be used to set a gomspace device to normal mode immediately after + * object creation. + */ + void setModeNormal(); - /** - * @brief This function can be used to set a gomspace device to normal mode immediately after - * object creation. - */ - void setModeNormal(); + protected: + static const uint8_t MAX_PACKET_LEN = 36; + static const uint8_t PARAM_SET_OK = 1; + static const uint8_t PING_REPLY_SIZE = 2; + static const uint8_t CONFIG_TABLE_ID = 1; + static const uint8_t HK_TABLE_ID = 4; -protected: + uint8_t rememberRequestedSize = 0; + uint8_t rememberCommandId = GOMSPACE::NONE; + uint8_t cspPacket[MAX_PACKET_LEN]; - static const uint8_t MAX_PACKET_LEN = 36; - static const uint8_t PARAM_SET_OK = 1; - static const uint8_t PING_REPLY_SIZE = 2; - static const uint8_t CONFIG_TABLE_ID = 1; - static const uint8_t HK_TABLE_ID = 4; + uint16_t maxConfigTableAddress; + uint16_t maxHkTableAddress; - uint8_t rememberRequestedSize = 0; - uint8_t rememberCommandId = GOMSPACE::NONE; - uint8_t cspPacket[MAX_PACKET_LEN]; + /** The size of the reply following a full hk table request.*/ + uint16_t hkTableReplySize; - uint16_t maxConfigTableAddress; - uint16_t maxHkTableAddress; + LocalPoolDataSetBase *hkTableDataset = nullptr; - /** The size of the reply following a full hk table request.*/ - uint16_t hkTableReplySize; + void doStartUp() override; + void doShutDown() override; + virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; + virtual 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; + /** + * @brief The command to generate a request to receive the full housekeeping table is device + * specific. Thus the child has to build this command. + */ + virtual ReturnValue_t generateRequestFullHkTableCmd(uint16_t hkTableSize); - LocalPoolDataSetBase* hkTableDataset = nullptr; + /** + * This command handles printing the HK table to the console. This is useful for debugging + * purposes + * @return + */ + virtual ReturnValue_t printStatus(DeviceCommandId_t cmd); - void doStartUp() override; - void doShutDown() override; - virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) - override; - ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override; - virtual 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; - /** - * @brief The command to generate a request to receive the full housekeeping table is device - * specific. Thus the child has to build this command. - */ - virtual ReturnValue_t generateRequestFullHkTableCmd(uint16_t hkTableSize); + /** + * @brief Because housekeeping tables are device specific the handling of the reply is + * given to the child class. + * @param id The id of the command which initiates the full table request. + * @param packet Pointer to the reply containing the hk table. + */ + virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) = 0; - /** - * This command handles printing the HK table to the console. This is useful for debugging - * purposes - * @return - */ - virtual ReturnValue_t printStatus(DeviceCommandId_t cmd); + virtual LocalPoolDataSetBase *getDataSetHandle(sid_t sid) override; - /** - * @brief Because housekeeping tables are device specific the handling of the reply is - * given to the child class. - * @param id The id of the command which initiates the full table request. - * @param packet Pointer to the reply containing the hk table. - */ - virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) = 0; + /** + * @brief Can be used by gomspace devices to implement device specific commands. + */ + virtual ReturnValue_t deviceSpecificCommand(DeviceCommandId_t cmd); - virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + private: + /** + * @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); - /** - * @brief Can be used by gomspace devices to implement device specific commands. - */ - virtual ReturnValue_t deviceSpecificCommand(DeviceCommandId_t cmd); + /** + * @brief Function to generate the command to get a parameter from a + * gomspace device. Command will be sent to the ComIF over the + * rawPacket buffer. + */ + ReturnValue_t generateGetParamCommand(const uint8_t *commandData, size_t commandDataLen); -private: + /** + * @brief Function to generate the ping command for the ComIF. + */ + ReturnValue_t generatePingCommand(const uint8_t *commandData, size_t commandDataLen); - /** - * @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); - - /** - * @brief Function to generate the command to get a parameter from a - * gomspace device. Command will be sent to the ComIF over the - * rawPacket buffer. - */ - ReturnValue_t generateGetParamCommand(const uint8_t * commandData, - size_t commandDataLen); - - /** - * @brief Function to generate the ping command for the ComIF. - */ - ReturnValue_t generatePingCommand(const uint8_t * commandData, - size_t commandDataLen); - - /** - * @brief Function to generate the command to reboot a gomspace device - * via the ComIF. - */ - void generateRebootCommand(); - - /** - * @brief Function to generate the command to force a ground watchdog - * reset in a gomspace device. - */ - ReturnValue_t generateResetWatchdogCmd(); + /** + * @brief Function to generate the command to reboot a gomspace device + * via the ComIF. + */ + void generateRebootCommand(); + /** + * @brief Function to generate the command to force a ground watchdog + * reset in a gomspace device. + */ + ReturnValue_t generateResetWatchdogCmd(); }; #endif /* MISSION_DEVICES_GOMSPACEDEVICEHANDLER_H_ */ diff --git a/mission/devices/GyroADIS1650XHandler.cpp b/mission/devices/GyroADIS1650XHandler.cpp index 4820eefc..7ea76758 100644 --- a/mission/devices/GyroADIS1650XHandler.cpp +++ b/mission/devices/GyroADIS1650XHandler.cpp @@ -1,481 +1,482 @@ #include "GyroADIS1650XHandler.h" + #include #include #if OBSW_ADIS1650X_LINUX_COM_IF == 1 -#include "fsfw_hal/linux/utility.h" -#include "fsfw_hal/linux/spi/SpiCookie.h" -#include "fsfw_hal/linux/spi/SpiComIF.h" -#include "fsfw_hal/linux/UnixFileGuard.h" #include #include + +#include "fsfw_hal/linux/UnixFileGuard.h" +#include "fsfw_hal/linux/spi/SpiComIF.h" +#include "fsfw_hal/linux/spi/SpiCookie.h" +#include "fsfw_hal/linux/utility.h" #endif -GyroADIS1650XHandler::GyroADIS1650XHandler(object_id_t objectId, - object_id_t deviceCommunication, CookieIF * comCookie, ADIS1650X::Type type): - DeviceHandlerBase(objectId, deviceCommunication, comCookie), adisType(type), - primaryDataset(this), configDataset(this), breakCountdown() { +GyroADIS1650XHandler::GyroADIS1650XHandler(object_id_t objectId, object_id_t deviceCommunication, + CookieIF *comCookie, ADIS1650X::Type type) + : DeviceHandlerBase(objectId, deviceCommunication, comCookie), + adisType(type), + primaryDataset(this), + configDataset(this), + breakCountdown() { #if FSFW_HAL_ADIS1650X_GYRO_DEBUG == 1 - debugDivider = new PeriodicOperationDivider(5); + debugDivider = new PeriodicOperationDivider(5); #endif #if OBSW_ADIS1650X_LINUX_COM_IF == 1 - SpiCookie* cookie = dynamic_cast(comCookie); - if(cookie != nullptr) { - cookie->setCallbackMode(&spiSendCallback, this); - } + SpiCookie *cookie = dynamic_cast(comCookie); + if (cookie != nullptr) { + cookie->setCallbackMode(&spiSendCallback, this); + } #endif } void GyroADIS1650XHandler::doStartUp() { - // Initial 310 ms start up time after power-up - if(internalState == InternalState::STARTUP) { - if(not commandExecuted) { - breakCountdown.setTimeout(ADIS1650X::START_UP_TIME); - commandExecuted = true; - } - if(breakCountdown.hasTimedOut()) { - internalState = InternalState::CONFIG; - commandExecuted = false; - } + // Initial 310 ms start up time after power-up + if (internalState == InternalState::STARTUP) { + if (not commandExecuted) { + breakCountdown.setTimeout(ADIS1650X::START_UP_TIME); + commandExecuted = true; } + if (breakCountdown.hasTimedOut()) { + internalState = InternalState::CONFIG; + commandExecuted = false; + } + } - // Read all configuration registers first - if(internalState == InternalState::CONFIG) { - if(commandExecuted) { - commandExecuted = false; - internalState = InternalState::IDLE; - } + // Read all configuration registers first + if (internalState == InternalState::CONFIG) { + if (commandExecuted) { + commandExecuted = false; + internalState = InternalState::IDLE; } + } - if(internalState == InternalState::IDLE) { - setMode(MODE_NORMAL); - // setMode(MODE_ON); - } + if (internalState == InternalState::IDLE) { + setMode(MODE_NORMAL); + // setMode(MODE_ON); + } } void GyroADIS1650XHandler::doShutDown() { - commandExecuted = false; - setMode(_MODE_POWER_DOWN); + commandExecuted = false; + setMode(_MODE_POWER_DOWN); } ReturnValue_t GyroADIS1650XHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { - *id = ADIS1650X::READ_SENSOR_DATA; - return buildCommandFromCommand(*id, nullptr, 0); + *id = ADIS1650X::READ_SENSOR_DATA; + return buildCommandFromCommand(*id, nullptr, 0); } ReturnValue_t GyroADIS1650XHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { - switch(internalState) { - case(InternalState::CONFIG): { - *id = ADIS1650X::READ_OUT_CONFIG; - buildCommandFromCommand(*id, nullptr, 0); - break; + switch (internalState) { + case (InternalState::CONFIG): { + *id = ADIS1650X::READ_OUT_CONFIG; + buildCommandFromCommand(*id, nullptr, 0); + break; } - case(InternalState::STARTUP): { - return NOTHING_TO_SEND; - break; + case (InternalState::STARTUP): { + return NOTHING_TO_SEND; + break; } default: { - /* Might be a configuration error. */ - sif::debug << "GyroADIS16507Handler::buildTransitionDeviceCommand: " - "Unknown internal state!" << std::endl; - return HasReturnvaluesIF::RETURN_OK; + /* Might be a configuration error. */ + sif::debug << "GyroADIS16507Handler::buildTransitionDeviceCommand: " + "Unknown internal state!" + << std::endl; + return HasReturnvaluesIF::RETURN_OK; } - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t GyroADIS1650XHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t *commandData, size_t commandDataLen) { - switch(deviceCommand) { - case(ADIS1650X::READ_OUT_CONFIG): { - this->rawPacketLen = ADIS1650X::CONFIG_READOUT_SIZE; - uint8_t regList[5]; - regList[0] = ADIS1650X::DIAG_STAT_REG; - regList[1] = ADIS1650X::FILTER_CTRL_REG; - regList[2] = ADIS1650X::MSC_CTRL_REG; - regList[3] = ADIS1650X::DEC_RATE_REG; - regList[4] = ADIS1650X::PROD_ID_REG; - prepareReadCommand(regList, sizeof(regList)); - this->rawPacket = commandBuffer.data(); - break; + const uint8_t *commandData, + size_t commandDataLen) { + switch (deviceCommand) { + case (ADIS1650X::READ_OUT_CONFIG): { + this->rawPacketLen = ADIS1650X::CONFIG_READOUT_SIZE; + uint8_t regList[5]; + regList[0] = ADIS1650X::DIAG_STAT_REG; + regList[1] = ADIS1650X::FILTER_CTRL_REG; + regList[2] = ADIS1650X::MSC_CTRL_REG; + regList[3] = ADIS1650X::DEC_RATE_REG; + regList[4] = ADIS1650X::PROD_ID_REG; + prepareReadCommand(regList, sizeof(regList)); + this->rawPacket = commandBuffer.data(); + break; } - case(ADIS1650X::READ_SENSOR_DATA): { - if(breakCountdown.isBusy()) { - // A glob command is pending and sensor data can't be read currently - return NO_REPLY_EXPECTED; - } - std::memcpy(commandBuffer.data(), ADIS1650X::BURST_READ_ENABLE.data(), - ADIS1650X::BURST_READ_ENABLE.size()); - std::memset(commandBuffer.data() + 2, 0, 10 * 2); - this->rawPacketLen = ADIS1650X::SENSOR_READOUT_SIZE; - this->rawPacket = commandBuffer.data(); - break; + case (ADIS1650X::READ_SENSOR_DATA): { + if (breakCountdown.isBusy()) { + // A glob command is pending and sensor data can't be read currently + return NO_REPLY_EXPECTED; + } + std::memcpy(commandBuffer.data(), ADIS1650X::BURST_READ_ENABLE.data(), + ADIS1650X::BURST_READ_ENABLE.size()); + std::memset(commandBuffer.data() + 2, 0, 10 * 2); + this->rawPacketLen = ADIS1650X::SENSOR_READOUT_SIZE; + this->rawPacket = commandBuffer.data(); + break; } - case(ADIS1650X::SELF_TEST_SENSORS): { - if(breakCountdown.isBusy()) { - // Another glob command is pending - return HasActionsIF::IS_BUSY; - } - prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::SENSOR_SELF_TEST, 0x00); - breakCountdown.setTimeout(ADIS1650X::SELF_TEST_BREAK); - break; + case (ADIS1650X::SELF_TEST_SENSORS): { + if (breakCountdown.isBusy()) { + // Another glob command is pending + return HasActionsIF::IS_BUSY; + } + prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::SENSOR_SELF_TEST, 0x00); + breakCountdown.setTimeout(ADIS1650X::SELF_TEST_BREAK); + break; } - case(ADIS1650X::SELF_TEST_MEMORY): { - if(breakCountdown.isBusy()) { - // Another glob command is pending - return HasActionsIF::IS_BUSY; - } - prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FLASH_MEMORY_TEST, 0x00); - breakCountdown.setTimeout(ADIS1650X::FLASH_MEMORY_TEST_BREAK); - break; + case (ADIS1650X::SELF_TEST_MEMORY): { + if (breakCountdown.isBusy()) { + // Another glob command is pending + return HasActionsIF::IS_BUSY; + } + prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FLASH_MEMORY_TEST, 0x00); + breakCountdown.setTimeout(ADIS1650X::FLASH_MEMORY_TEST_BREAK); + break; } - case(ADIS1650X::UPDATE_NV_CONFIGURATION): { - if(breakCountdown.isBusy()) { - // Another glob command is pending - return HasActionsIF::IS_BUSY; - } - prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FLASH_MEMORY_UPDATE, 0x00); - breakCountdown.setTimeout(ADIS1650X::FLASH_MEMORY_UPDATE_BREAK); - break; + case (ADIS1650X::UPDATE_NV_CONFIGURATION): { + if (breakCountdown.isBusy()) { + // Another glob command is pending + return HasActionsIF::IS_BUSY; + } + prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FLASH_MEMORY_UPDATE, 0x00); + breakCountdown.setTimeout(ADIS1650X::FLASH_MEMORY_UPDATE_BREAK); + break; } - case(ADIS1650X::RESET_SENSOR_CONFIGURATION): { - if(breakCountdown.isBusy()) { - // Another glob command is pending - return HasActionsIF::IS_BUSY; - } - prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FACTORY_CALIBRATION, 0x00); - breakCountdown.setTimeout(ADIS1650X::FACTORY_CALIBRATION_BREAK); - break; + case (ADIS1650X::RESET_SENSOR_CONFIGURATION): { + if (breakCountdown.isBusy()) { + // Another glob command is pending + return HasActionsIF::IS_BUSY; + } + prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FACTORY_CALIBRATION, 0x00); + breakCountdown.setTimeout(ADIS1650X::FACTORY_CALIBRATION_BREAK); + break; } - case(ADIS1650X::SW_RESET): { - if(breakCountdown.isBusy()) { - // Another glob command is pending - return HasActionsIF::IS_BUSY; - } - prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::SOFTWARE_RESET, 0x00); - breakCountdown.setTimeout(ADIS1650X::SW_RESET_BREAK); - break; + case (ADIS1650X::SW_RESET): { + if (breakCountdown.isBusy()) { + // Another glob command is pending + return HasActionsIF::IS_BUSY; + } + prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::SOFTWARE_RESET, 0x00); + breakCountdown.setTimeout(ADIS1650X::SW_RESET_BREAK); + break; } - case(ADIS1650X::PRINT_CURRENT_CONFIGURATION): { + case (ADIS1650X::PRINT_CURRENT_CONFIGURATION): { #if OBSW_VERBOSE_LEVEL >= 1 - PoolReadGuard pg(&configDataset); - sif::info << "ADIS16507 Sensor configuration: DIAG_STAT: 0x" << std::hex << std::setw(4) << - std::setfill('0') << "0x" << configDataset.diagStatReg.value << std::endl; - sif::info << "MSC_CTRL: " << std::hex << std::setw(4) << "0x" << - configDataset.mscCtrlReg.value << " | FILT_CTRL: 0x" << - configDataset.filterSetting.value << " | DEC_RATE: 0x" << - configDataset.decRateReg.value << std::setfill(' ') << std::endl; + PoolReadGuard pg(&configDataset); + sif::info << "ADIS16507 Sensor configuration: DIAG_STAT: 0x" << std::hex << std::setw(4) + << std::setfill('0') << "0x" << configDataset.diagStatReg.value << std::endl; + sif::info << "MSC_CTRL: " << std::hex << std::setw(4) << "0x" + << configDataset.mscCtrlReg.value << " | FILT_CTRL: 0x" + << configDataset.filterSetting.value << " | DEC_RATE: 0x" + << configDataset.decRateReg.value << std::setfill(' ') << std::endl; #endif /* OBSW_VERBOSE_LEVEL >= 1 */ } - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } void GyroADIS1650XHandler::fillCommandAndReplyMap() { - insertInCommandAndReplyMap(ADIS1650X::READ_SENSOR_DATA, 1, &primaryDataset); - insertInCommandAndReplyMap(ADIS1650X::READ_OUT_CONFIG, 1, &configDataset); - insertInCommandAndReplyMap(ADIS1650X::SELF_TEST_SENSORS, 1); - insertInCommandAndReplyMap(ADIS1650X::SELF_TEST_MEMORY, 1); - insertInCommandAndReplyMap(ADIS1650X::UPDATE_NV_CONFIGURATION, 1); - insertInCommandAndReplyMap(ADIS1650X::RESET_SENSOR_CONFIGURATION, 1); - insertInCommandAndReplyMap(ADIS1650X::SW_RESET, 1); - insertInCommandAndReplyMap(ADIS1650X::PRINT_CURRENT_CONFIGURATION, 1); + insertInCommandAndReplyMap(ADIS1650X::READ_SENSOR_DATA, 1, &primaryDataset); + insertInCommandAndReplyMap(ADIS1650X::READ_OUT_CONFIG, 1, &configDataset); + insertInCommandAndReplyMap(ADIS1650X::SELF_TEST_SENSORS, 1); + insertInCommandAndReplyMap(ADIS1650X::SELF_TEST_MEMORY, 1); + insertInCommandAndReplyMap(ADIS1650X::UPDATE_NV_CONFIGURATION, 1); + insertInCommandAndReplyMap(ADIS1650X::RESET_SENSOR_CONFIGURATION, 1); + insertInCommandAndReplyMap(ADIS1650X::SW_RESET, 1); + insertInCommandAndReplyMap(ADIS1650X::PRINT_CURRENT_CONFIGURATION, 1); } ReturnValue_t GyroADIS1650XHandler::scanForReply(const uint8_t *start, size_t remainingSize, - DeviceCommandId_t *foundId, size_t *foundLen) { - // For SPI, the ID will always be the one of the last sent command - *foundId = this->getPendingCommand(); - *foundLen = this->rawPacketLen; + DeviceCommandId_t *foundId, size_t *foundLen) { + // For SPI, the ID will always be the one of the last sent command + *foundId = this->getPendingCommand(); + *foundLen = this->rawPacketLen; - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t GyroADIS1650XHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { - switch(id) { - case(ADIS1650X::READ_OUT_CONFIG): { - - uint16_t readProdId = packet[10] << 8 | packet[11]; - if(((adisType == ADIS1650X::Type::ADIS16507) and - (readProdId != ADIS1650X::PROD_ID_16507)) or - ((adisType == ADIS1650X::Type::ADIS16505) and - (readProdId != ADIS1650X::PROD_ID_16505))) { + const uint8_t *packet) { + switch (id) { + case (ADIS1650X::READ_OUT_CONFIG): { + uint16_t readProdId = packet[10] << 8 | packet[11]; + 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 - sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Invalid product ID " - << readProdId << std::endl; + sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Invalid product ID " + << readProdId << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; - } - PoolReadGuard rg(&configDataset); - configDataset.diagStatReg.value = packet[2] << 8 | packet[3]; - configDataset.filterSetting.value = packet[4] << 8 | packet[5]; - configDataset.mscCtrlReg.value = packet[6] << 8 | packet[7]; - configDataset.decRateReg.value = packet[8] << 8 | packet[9]; - configDataset.setValidity(true, true); - if(internalState == InternalState::CONFIG) { - commandExecuted = true; - } - break; + return HasReturnvaluesIF::RETURN_FAILED; + } + PoolReadGuard rg(&configDataset); + configDataset.diagStatReg.value = packet[2] << 8 | packet[3]; + configDataset.filterSetting.value = packet[4] << 8 | packet[5]; + configDataset.mscCtrlReg.value = packet[6] << 8 | packet[7]; + configDataset.decRateReg.value = packet[8] << 8 | packet[9]; + configDataset.setValidity(true, true); + if (internalState == InternalState::CONFIG) { + commandExecuted = true; + } + break; } - case(ADIS1650X::READ_SENSOR_DATA): { - return handleSensorData(packet); + case (ADIS1650X::READ_SENSOR_DATA): { + return handleSensorData(packet); } - - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } - ReturnValue_t GyroADIS1650XHandler::handleSensorData(const uint8_t *packet) { - BurstModes burstMode = getBurstMode(); - switch(burstMode) { - case(BurstModes::BURST_16_BURST_SEL_1): - case(BurstModes::BURST_32_BURST_SEL_1): { - sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Analysis with BURST_SEL1" - " not implemented!" << std::endl; - return HasReturnvaluesIF::RETURN_OK; + BurstModes burstMode = getBurstMode(); + switch (burstMode) { + case (BurstModes::BURST_16_BURST_SEL_1): + case (BurstModes::BURST_32_BURST_SEL_1): { + sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Analysis with BURST_SEL1" + " not implemented!" + << std::endl; + return HasReturnvaluesIF::RETURN_OK; } - case(BurstModes::BURST_16_BURST_SEL_0): { - uint16_t checksum = packet[20] << 8 | packet[21]; - // Now verify the read checksum with the expected checksum according to datasheet p. 20 - uint16_t calcChecksum = 0; - for(size_t idx = 2; idx < 20; idx ++) { - calcChecksum += packet[idx]; - } - if(checksum != calcChecksum) { + case (BurstModes::BURST_16_BURST_SEL_0): { + uint16_t checksum = packet[20] << 8 | packet[21]; + // Now verify the read checksum with the expected checksum according to datasheet p. 20 + uint16_t calcChecksum = 0; + for (size_t idx = 2; idx < 20; idx++) { + calcChecksum += packet[idx]; + } + if (checksum != calcChecksum) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: " - "Invalid checksum detected!" << std::endl; + sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: " + "Invalid checksum detected!" + << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return HasReturnvaluesIF::RETURN_FAILED; + } + + ReturnValue_t result = configDataset.diagStatReg.read(); + if (result == HasReturnvaluesIF::RETURN_OK) { + configDataset.diagStatReg.value = packet[2] << 8 | packet[3]; + configDataset.diagStatReg.setValid(true); + } + configDataset.diagStatReg.commit(); + + { + PoolReadGuard pg(&primaryDataset); + int16_t angVelocXRaw = packet[4] << 8 | packet[5]; + primaryDataset.angVelocX.value = + static_cast(angVelocXRaw) / INT16_MAX * ADIS1650X::GYRO_RANGE; + int16_t angVelocYRaw = packet[6] << 8 | packet[7]; + primaryDataset.angVelocY.value = + static_cast(angVelocYRaw) / INT16_MAX * ADIS1650X::GYRO_RANGE; + int16_t angVelocZRaw = packet[8] << 8 | packet[9]; + primaryDataset.angVelocZ.value = + static_cast(angVelocZRaw) / INT16_MAX * ADIS1650X::GYRO_RANGE; + + float accelScaling = 0; + if (adisType == ADIS1650X::Type::ADIS16507) { + accelScaling = ADIS1650X::ACCELEROMETER_RANGE_16507; + } else if (adisType == ADIS1650X::Type::ADIS16505) { + accelScaling = ADIS1650X::ACCELEROMETER_RANGE_16505; + } else { + sif::warning << "GyroADIS1650XHandler::handleSensorData: " + "Unknown ADIS type" + << std::endl; } + int16_t accelXRaw = packet[10] << 8 | packet[11]; + primaryDataset.accelX.value = static_cast(accelXRaw) / INT16_MAX * accelScaling; + int16_t accelYRaw = packet[12] << 8 | packet[13]; + primaryDataset.accelY.value = static_cast(accelYRaw) / INT16_MAX * accelScaling; + int16_t accelZRaw = packet[14] << 8 | packet[15]; + primaryDataset.accelZ.value = static_cast(accelZRaw) / INT16_MAX * accelScaling; - ReturnValue_t result = configDataset.diagStatReg.read(); - if(result == HasReturnvaluesIF::RETURN_OK) { - configDataset.diagStatReg.value = packet[2] << 8 | packet[3]; - configDataset.diagStatReg.setValid(true); - } - configDataset.diagStatReg.commit(); - - { - PoolReadGuard pg(&primaryDataset); - int16_t angVelocXRaw = packet[4] << 8 | packet[5]; - primaryDataset.angVelocX.value = static_cast(angVelocXRaw) / INT16_MAX * - ADIS1650X::GYRO_RANGE; - int16_t angVelocYRaw = packet[6] << 8 | packet[7]; - primaryDataset.angVelocY.value = static_cast(angVelocYRaw) / INT16_MAX * - ADIS1650X::GYRO_RANGE; - int16_t angVelocZRaw = packet[8] << 8 | packet[9]; - primaryDataset.angVelocZ.value = static_cast(angVelocZRaw) / INT16_MAX * - ADIS1650X::GYRO_RANGE; - - float accelScaling = 0; - if(adisType == ADIS1650X::Type::ADIS16507) { - accelScaling = ADIS1650X::ACCELEROMETER_RANGE_16507; - } else if(adisType == ADIS1650X::Type::ADIS16505) { - accelScaling = ADIS1650X::ACCELEROMETER_RANGE_16505; - } else { - sif::warning << "GyroADIS1650XHandler::handleSensorData: " - "Unknown ADIS type" << std::endl; - } - int16_t accelXRaw = packet[10] << 8 | packet[11]; - primaryDataset.accelX.value = static_cast(accelXRaw) / INT16_MAX * - accelScaling; - int16_t accelYRaw = packet[12] << 8 | packet[13]; - primaryDataset.accelY.value = static_cast(accelYRaw) / INT16_MAX * - accelScaling; - int16_t accelZRaw = packet[14] << 8 | packet[15]; - primaryDataset.accelZ.value = static_cast(accelZRaw) / INT16_MAX * - accelScaling; - - int16_t temperatureRaw = packet[16] << 8 | packet[17]; - primaryDataset.temperature.value = static_cast(temperatureRaw) * 0.1; - // Ignore data counter for now - primaryDataset.setValidity(true, true); - } + int16_t temperatureRaw = packet[16] << 8 | packet[17]; + primaryDataset.temperature.value = static_cast(temperatureRaw) * 0.1; + // Ignore data counter for now + primaryDataset.setValidity(true, true); + } #if FSFW_HAL_ADIS1650X_GYRO_DEBUG == 1 - if(debugDivider->checkAndIncrement()) { - sif::info << "GyroADIS1650XHandler: Angular velocities in deg / s" << std::endl; - sif::info << "X: " << primaryDataset.angVelocX.value << std::endl; - sif::info << "Y: " << primaryDataset.angVelocY.value << std::endl; - sif::info << "Z: " << primaryDataset.angVelocZ.value << std::endl; - sif::info << "GyroADIS1650XHandler: Accelerations in m / s^2: " << std::endl; - sif::info << "X: " << primaryDataset.accelX.value << std::endl; - sif::info << "Y: " << primaryDataset.accelY.value << std::endl; - sif::info << "Z: " << primaryDataset.accelZ.value << std::endl; - } + if (debugDivider->checkAndIncrement()) { + sif::info << "GyroADIS1650XHandler: Angular velocities in deg / s" << std::endl; + sif::info << "X: " << primaryDataset.angVelocX.value << std::endl; + sif::info << "Y: " << primaryDataset.angVelocY.value << std::endl; + sif::info << "Z: " << primaryDataset.angVelocZ.value << std::endl; + sif::info << "GyroADIS1650XHandler: Accelerations in m / s^2: " << std::endl; + sif::info << "X: " << primaryDataset.accelX.value << std::endl; + sif::info << "Y: " << primaryDataset.accelY.value << std::endl; + sif::info << "Z: " << primaryDataset.accelZ.value << std::endl; + } #endif - break; + break; } - case(BurstModes::BURST_32_BURST_SEL_0): { - break; + case (BurstModes::BURST_32_BURST_SEL_0): { + break; } - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } uint32_t GyroADIS1650XHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { - return 10000; + return 10000; } void GyroADIS1650XHandler::prepareWriteCommand(uint8_t startReg, uint8_t valueOne, - uint8_t valueTwo) { - uint8_t secondReg = startReg + 1; - startReg |= ADIS1650X::WRITE_MASK; - secondReg |= ADIS1650X::WRITE_MASK; - commandBuffer[0] = startReg; - commandBuffer[1] = valueOne; - commandBuffer[2] = secondReg; - commandBuffer[3] = valueTwo; - this->rawPacketLen = 4; - this->rawPacket = commandBuffer.data(); + uint8_t valueTwo) { + uint8_t secondReg = startReg + 1; + startReg |= ADIS1650X::WRITE_MASK; + secondReg |= ADIS1650X::WRITE_MASK; + commandBuffer[0] = startReg; + commandBuffer[1] = valueOne; + commandBuffer[2] = secondReg; + commandBuffer[3] = valueTwo; + this->rawPacketLen = 4; + this->rawPacket = commandBuffer.data(); } void GyroADIS1650XHandler::prepareReadCommand(uint8_t *regList, size_t len) { - for(size_t idx = 0; idx < len; idx++) { - commandBuffer[idx * 2] = regList[idx]; - commandBuffer[idx * 2 + 1] = 0x00; - } - commandBuffer[len * 2] = 0x00; - commandBuffer[len * 2 + 1] = 0x00; + for (size_t idx = 0; idx < len; idx++) { + commandBuffer[idx * 2] = regList[idx]; + commandBuffer[idx * 2 + 1] = 0x00; + } + commandBuffer[len * 2] = 0x00; + commandBuffer[len * 2 + 1] = 0x00; } ReturnValue_t GyroADIS1650XHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) { - localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_X, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_Y, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_Z, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS1650X::ACCELERATION_X, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS1650X::ACCELERATION_Y, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS1650X::ACCELERATION_Z, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS1650X::TEMPERATURE, new PoolEntry({0.0})); + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_X, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_Y, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_Z, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::ACCELERATION_X, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::ACCELERATION_Y, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::ACCELERATION_Z, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::TEMPERATURE, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS1650X::DIAG_STAT_REGISTER, new PoolEntry()); - localDataPoolMap.emplace(ADIS1650X::FILTER_SETTINGS, new PoolEntry()); - localDataPoolMap.emplace(ADIS1650X::MSC_CTRL_REGISTER, new PoolEntry()); - localDataPoolMap.emplace(ADIS1650X::DEC_RATE_REGISTER, new PoolEntry()); - return HasReturnvaluesIF::RETURN_OK; + localDataPoolMap.emplace(ADIS1650X::DIAG_STAT_REGISTER, new PoolEntry()); + localDataPoolMap.emplace(ADIS1650X::FILTER_SETTINGS, new PoolEntry()); + localDataPoolMap.emplace(ADIS1650X::MSC_CTRL_REGISTER, new PoolEntry()); + localDataPoolMap.emplace(ADIS1650X::DEC_RATE_REGISTER, new PoolEntry()); + return HasReturnvaluesIF::RETURN_OK; } GyroADIS1650XHandler::BurstModes GyroADIS1650XHandler::getBurstMode() { - configDataset.mscCtrlReg.read(); - uint16_t currentCtrlReg = configDataset.mscCtrlReg.value; - configDataset.mscCtrlReg.commit(); - if((currentCtrlReg & ADIS1650X::BURST_32_BIT) == ADIS1650X::BURST_32_BIT) { - if((currentCtrlReg & ADIS1650X::BURST_SEL_BIT) == ADIS1650X::BURST_SEL_BIT) { - return BurstModes::BURST_32_BURST_SEL_1; - } - else { - return BurstModes::BURST_32_BURST_SEL_0; - } + configDataset.mscCtrlReg.read(); + uint16_t currentCtrlReg = configDataset.mscCtrlReg.value; + configDataset.mscCtrlReg.commit(); + if ((currentCtrlReg & ADIS1650X::BURST_32_BIT) == ADIS1650X::BURST_32_BIT) { + if ((currentCtrlReg & ADIS1650X::BURST_SEL_BIT) == ADIS1650X::BURST_SEL_BIT) { + return BurstModes::BURST_32_BURST_SEL_1; + } else { + return BurstModes::BURST_32_BURST_SEL_0; } - else { - if((currentCtrlReg & ADIS1650X::BURST_SEL_BIT) == ADIS1650X::BURST_SEL_BIT) { - return BurstModes::BURST_16_BURST_SEL_1; - } - else { - return BurstModes::BURST_16_BURST_SEL_0; - } + } else { + if ((currentCtrlReg & ADIS1650X::BURST_SEL_BIT) == ADIS1650X::BURST_SEL_BIT) { + return BurstModes::BURST_16_BURST_SEL_1; + } else { + return BurstModes::BURST_16_BURST_SEL_0; } + } } #if OBSW_ADIS1650X_LINUX_COM_IF == 1 ReturnValue_t GyroADIS1650XHandler::spiSendCallback(SpiComIF *comIf, SpiCookie *cookie, - const uint8_t *sendData, size_t sendLen, void *args) { - GyroADIS1650XHandler* handler = reinterpret_cast(args); - if(handler == nullptr) { - sif::error << "GyroADIS16507Handler::spiSendCallback: Passed handler pointer is invalid!" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; + const uint8_t *sendData, size_t sendLen, + void *args) { + GyroADIS1650XHandler *handler = reinterpret_cast(args); + if (handler == nullptr) { + sif::error << "GyroADIS16507Handler::spiSendCallback: Passed handler pointer is invalid!" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + DeviceCommandId_t currentCommand = handler->getPendingCommand(); + switch (currentCommand) { + case (ADIS1650X::READ_SENSOR_DATA): { + return comIf->performRegularSendOperation(cookie, sendData, sendLen); } - DeviceCommandId_t currentCommand = handler->getPendingCommand(); - switch(currentCommand) { - case(ADIS1650X::READ_SENSOR_DATA): { - return comIf->performRegularSendOperation(cookie, sendData, sendLen); - } - case(ADIS1650X::READ_OUT_CONFIG): + case (ADIS1650X::READ_OUT_CONFIG): default: { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - int retval = 0; - // Prepare transfer - int fileDescriptor = 0; - std::string device = cookie->getSpiDevice(); - UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "SpiComIF::sendMessage"); - if(fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { - return SpiComIF::OPENING_FILE_FAILED; - } - spi::SpiModes spiMode = spi::SpiModes::MODE_0; - uint32_t spiSpeed = 0; - cookie->getSpiParameters(spiMode, spiSpeed, nullptr); - comIf->setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); - cookie->assignWriteBuffer(sendData); - cookie->setTransferSize(2); + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + int retval = 0; + // Prepare transfer + int fileDescriptor = 0; + std::string device = cookie->getSpiDevice(); + UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "SpiComIF::sendMessage"); + if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { + return SpiComIF::OPENING_FILE_FAILED; + } + spi::SpiModes spiMode = spi::SpiModes::MODE_0; + uint32_t spiSpeed = 0; + cookie->getSpiParameters(spiMode, spiSpeed, nullptr); + comIf->setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); + cookie->assignWriteBuffer(sendData); + cookie->setTransferSize(2); - gpioId_t gpioId = cookie->getChipSelectPin(); - GpioIF* gpioIF = comIf->getGpioInterface(); - MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; - uint32_t timeoutMs = 0; - MutexIF* mutex = comIf->getMutex(&timeoutType, &timeoutMs); - if(mutex == nullptr or gpioIF == nullptr) { + gpioId_t gpioId = cookie->getChipSelectPin(); + GpioIF *gpioIF = comIf->getGpioInterface(); + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; + uint32_t timeoutMs = 0; + MutexIF *mutex = comIf->getMutex(&timeoutType, &timeoutMs); + if (mutex == nullptr or gpioIF == nullptr) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::warning << "GyroADIS16507Handler::spiSendCallback: " - "Mutex or GPIO interface invalid" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; + sif::warning << "GyroADIS16507Handler::spiSendCallback: " + "Mutex or GPIO interface invalid" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; #endif - } + } - if(gpioId != gpio::NO_GPIO) { - result = mutex->lockMutex(timeoutType, timeoutMs); - if (result != RETURN_OK) { + if (gpioId != gpio::NO_GPIO) { + result = mutex->lockMutex(timeoutType, timeoutMs); + if (result != RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "SpiComIF::sendMessage: Failed to lock mutex" << std::endl; + sif::error << "SpiComIF::sendMessage: Failed to lock mutex" << std::endl; #endif - return result; - } + return result; + } + } + + size_t idx = 0; + while (idx < sendLen) { + // Pull SPI CS low. For now, no support for active high given + if (gpioId != gpio::NO_GPIO) { + gpioIF->pullLow(gpioId); } - size_t idx = 0; - while(idx < sendLen) { - // Pull SPI CS low. For now, no support for active high given - if(gpioId != gpio::NO_GPIO) { - gpioIF->pullLow(gpioId); - } - - // Execute transfer - // Initiate a full duplex SPI transfer. - retval = ioctl(fileDescriptor, SPI_IOC_MESSAGE(1), cookie->getTransferStructHandle()); - if(retval < 0) { - utility::handleIoctlError("SpiComIF::sendMessage: ioctl error."); - result = SpiComIF::FULL_DUPLEX_TRANSFER_FAILED; - } + // Execute transfer + // Initiate a full duplex SPI transfer. + retval = ioctl(fileDescriptor, SPI_IOC_MESSAGE(1), cookie->getTransferStructHandle()); + if (retval < 0) { + utility::handleIoctlError("SpiComIF::sendMessage: ioctl error."); + result = SpiComIF::FULL_DUPLEX_TRANSFER_FAILED; + } #if FSFW_HAL_SPI_WIRETAPPING == 1 - comIf->performSpiWiretapping(cookie); + comIf->performSpiWiretapping(cookie); #endif /* FSFW_LINUX_SPI_WIRETAPPING == 1 */ - if(gpioId != gpio::NO_GPIO) { - gpioIF->pullHigh(gpioId); - } - - idx += 2; - if(idx < sendLen) { - usleep(ADIS1650X::STALL_TIME_MICROSECONDS); - } - spi_ioc_transfer* transferStruct = cookie->getTransferStructHandle(); - transferStruct->tx_buf += 2; - transferStruct->rx_buf += 2; + if (gpioId != gpio::NO_GPIO) { + gpioIF->pullHigh(gpioId); } - if(gpioId != gpio::NO_GPIO) { - mutex->unlockMutex(); + idx += 2; + if (idx < sendLen) { + usleep(ADIS1650X::STALL_TIME_MICROSECONDS); } + spi_ioc_transfer *transferStruct = cookie->getTransferStructHandle(); + transferStruct->tx_buf += 2; + transferStruct->rx_buf += 2; + } + + if (gpioId != gpio::NO_GPIO) { + mutex->unlockMutex(); + } } - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } #endif /* OBSW_ADIS1650X_LINUX_COM_IF == 1 */ diff --git a/mission/devices/GyroADIS1650XHandler.h b/mission/devices/GyroADIS1650XHandler.h index b1ac50f5..c1f9ae98 100644 --- a/mission/devices/GyroADIS1650XHandler.h +++ b/mission/devices/GyroADIS1650XHandler.h @@ -1,12 +1,11 @@ #ifndef MISSION_DEVICES_GYROADIS16507HANDLER_H_ #define MISSION_DEVICES_GYROADIS16507HANDLER_H_ -#include "OBSWConfig.h" #include "FSFWConfig.h" +#include "OBSWConfig.h" #include "devicedefinitions/GyroADIS1650XDefinitions.h" - -#include "fsfw/globalfunctions/PeriodicOperationDivider.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" +#include "fsfw/globalfunctions/PeriodicOperationDivider.h" #if OBSW_ADIS1650X_LINUX_COM_IF == 1 class SpiComIF; @@ -19,67 +18,60 @@ class SpiCookie; * Flight manual: * https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/ADIS16507_Gyro */ -class GyroADIS1650XHandler: public DeviceHandlerBase { -public: - GyroADIS1650XHandler(object_id_t objectId, object_id_t deviceCommunication, - CookieIF* comCookie, ADIS1650X::Type type); +class GyroADIS1650XHandler : public DeviceHandlerBase { + public: + GyroADIS1650XHandler(object_id_t objectId, object_id_t deviceCommunication, CookieIF *comCookie, + ADIS1650X::Type type); - // DeviceHandlerBase abstract function implementation - void doStartUp() override; - void doShutDown() override; - ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; - ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override; - ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t * commandData, size_t commandDataLen) override; - void fillCommandAndReplyMap() 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; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) override; + // DeviceHandlerBase abstract function implementation + void doStartUp() override; + void doShutDown() override; + ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, + size_t commandDataLen) override; + void fillCommandAndReplyMap() 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; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) override; -private: - std::array commandBuffer; - ADIS1650X::Type adisType; - AdisGyroPrimaryDataset primaryDataset; - AdisGyroConfigDataset configDataset; + private: + std::array commandBuffer; + ADIS1650X::Type adisType; + AdisGyroPrimaryDataset primaryDataset; + AdisGyroConfigDataset configDataset; - enum class InternalState { - STARTUP, - CONFIG, - IDLE - }; + enum class InternalState { STARTUP, CONFIG, IDLE }; - enum class BurstModes { - BURST_16_BURST_SEL_0, - BURST_16_BURST_SEL_1, - BURST_32_BURST_SEL_0, - BURST_32_BURST_SEL_1 - }; + enum class BurstModes { + BURST_16_BURST_SEL_0, + BURST_16_BURST_SEL_1, + BURST_32_BURST_SEL_0, + BURST_32_BURST_SEL_1 + }; - InternalState internalState = InternalState::STARTUP; - bool commandExecuted = false; + InternalState internalState = InternalState::STARTUP; + bool commandExecuted = false; - void prepareReadCommand(uint8_t* regList, size_t len); + void prepareReadCommand(uint8_t *regList, size_t len); - BurstModes getBurstMode(); + BurstModes getBurstMode(); #if OBSW_ADIS1650X_LINUX_COM_IF == 1 - static ReturnValue_t spiSendCallback(SpiComIF* comIf, SpiCookie *cookie, - const uint8_t *sendData, size_t sendLen, void* args); + static ReturnValue_t spiSendCallback(SpiComIF *comIf, SpiCookie *cookie, const uint8_t *sendData, + size_t sendLen, void *args); #endif #if FSFW_HAL_ADIS1650X_GYRO_DEBUG == 1 - PeriodicOperationDivider* debugDivider; + PeriodicOperationDivider *debugDivider; #endif - Countdown breakCountdown; - void prepareWriteCommand(uint8_t startReg, uint8_t valueOne, uint8_t valueTwo); + Countdown breakCountdown; + void prepareWriteCommand(uint8_t startReg, uint8_t valueOne, uint8_t valueTwo); - ReturnValue_t handleSensorData(const uint8_t* packet); + ReturnValue_t handleSensorData(const uint8_t *packet); }; - - #endif /* MISSION_DEVICES_GYROADIS16507HANDLER_H_ */ diff --git a/mission/devices/HeaterHandler.cpp b/mission/devices/HeaterHandler.cpp index 60a60328..572810bd 100644 --- a/mission/devices/HeaterHandler.cpp +++ b/mission/devices/HeaterHandler.cpp @@ -1,373 +1,346 @@ #include "HeaterHandler.h" + +#include +#include +#include + #include "devices/gpioIds.h" #include "devices/powerSwitcherList.h" -#include -#include -#include - HeaterHandler::HeaterHandler(object_id_t setObjectId_, object_id_t gpioDriverId_, - CookieIF * gpioCookie_, object_id_t mainLineSwitcherObjectId_, uint8_t mainLineSwitch_) : - SystemObject(setObjectId_), gpioDriverId(gpioDriverId_), gpioCookie(gpioCookie_), - mainLineSwitcherObjectId(mainLineSwitcherObjectId_), mainLineSwitch(mainLineSwitch_), - actionHelper(this, nullptr) { - commandQueue = QueueFactory::instance()->createMessageQueue(cmdQueueSize, - MessageQueueMessage::MAX_MESSAGE_SIZE); + CookieIF* gpioCookie_, object_id_t mainLineSwitcherObjectId_, + uint8_t mainLineSwitch_) + : SystemObject(setObjectId_), + gpioDriverId(gpioDriverId_), + gpioCookie(gpioCookie_), + mainLineSwitcherObjectId(mainLineSwitcherObjectId_), + mainLineSwitch(mainLineSwitch_), + actionHelper(this, nullptr) { + commandQueue = QueueFactory::instance()->createMessageQueue( + cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE); } -HeaterHandler::~HeaterHandler() { -} +HeaterHandler::~HeaterHandler() {} ReturnValue_t HeaterHandler::performOperation(uint8_t operationCode) { - - if (operationCode == DeviceHandlerIF::PERFORM_OPERATION) { - readCommandQueue(); - handleActiveCommands(); - return RETURN_OK; - } - return RETURN_OK; + if (operationCode == DeviceHandlerIF::PERFORM_OPERATION) { + readCommandQueue(); + handleActiveCommands(); + return RETURN_OK; + } + return RETURN_OK; } ReturnValue_t HeaterHandler::initialize() { - ReturnValue_t result = SystemObject::initialize(); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + ReturnValue_t result = SystemObject::initialize(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = initializeHeaterMap(); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = initializeHeaterMap(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - gpioInterface = ObjectManager::instance()->get(gpioDriverId); - if (gpioInterface == nullptr) { - sif::error << "HeaterHandler::initialize: Invalid Gpio interface." << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + gpioInterface = ObjectManager::instance()->get(gpioDriverId); + if (gpioInterface == nullptr) { + sif::error << "HeaterHandler::initialize: Invalid Gpio interface." << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = gpioInterface->addGpios(dynamic_cast(gpioCookie)); - if (result != RETURN_OK) { - sif::error << "HeaterHandler::initialize: Failed to initialize Gpio interface" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = gpioInterface->addGpios(dynamic_cast(gpioCookie)); + if (result != RETURN_OK) { + sif::error << "HeaterHandler::initialize: Failed to initialize Gpio interface" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); - if (IPCStore == nullptr) { - sif::error << "HeaterHandler::initialize: IPC store not set up in factory." << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); + if (IPCStore == nullptr) { + sif::error << "HeaterHandler::initialize: IPC store not set up in factory." << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - if(mainLineSwitcherObjectId != objects::NO_OBJECT) { - mainLineSwitcher = ObjectManager::instance()->get(mainLineSwitcherObjectId); - if (mainLineSwitcher == nullptr) { - sif::error - << "HeaterHandler::initialize: Failed to get main line switcher. Make sure " - << "main line switcher object is initialized." << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } - } + if (mainLineSwitcherObjectId != objects::NO_OBJECT) { + mainLineSwitcher = ObjectManager::instance()->get(mainLineSwitcherObjectId); + if (mainLineSwitcher == nullptr) { + sif::error << "HeaterHandler::initialize: Failed to get main line switcher. Make sure " + << "main line switcher object is initialized." << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } + } - result = actionHelper.initialize(commandQueue); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = actionHelper.initialize(commandQueue); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - return RETURN_OK; + return RETURN_OK; } -ReturnValue_t HeaterHandler::initializeHeaterMap(){ - HeaterCommandInfo_t heaterCommandInfo; - for(switchNr_t switchNr = 0; switchNr < heaterSwitches::NUMBER_OF_SWITCHES; switchNr++) { - std::pair status = heaterMap.emplace(switchNr, heaterCommandInfo); - if (status.second == false) { - sif::error << "HeaterHandler::initializeHeaterMap: Failed to initialize heater map" - << std::endl; - return RETURN_FAILED; - } - } - return RETURN_OK; +ReturnValue_t HeaterHandler::initializeHeaterMap() { + HeaterCommandInfo_t heaterCommandInfo; + for (switchNr_t switchNr = 0; switchNr < heaterSwitches::NUMBER_OF_SWITCHES; switchNr++) { + std::pair status = heaterMap.emplace(switchNr, heaterCommandInfo); + if (status.second == false) { + sif::error << "HeaterHandler::initializeHeaterMap: Failed to initialize heater map" + << std::endl; + return RETURN_FAILED; + } + } + return RETURN_OK; } void HeaterHandler::setInitialSwitchStates() { - for (switchNr_t switchNr = 0; switchNr < heaterSwitches::NUMBER_OF_SWITCHES; switchNr++) { - switchStates[switchNr] = OFF; - } + for (switchNr_t switchNr = 0; switchNr < heaterSwitches::NUMBER_OF_SWITCHES; switchNr++) { + switchStates[switchNr] = OFF; + } } void HeaterHandler::readCommandQueue() { - CommandMessage command; - ReturnValue_t result = commandQueue->receiveMessage(&command); - if (result != RETURN_OK) { - return; - } + CommandMessage command; + ReturnValue_t result = commandQueue->receiveMessage(&command); + if (result != RETURN_OK) { + return; + } - result = actionHelper.handleActionMessage(&command); - if (result == RETURN_OK) { - return; - } + result = actionHelper.handleActionMessage(&command); + if (result == RETURN_OK) { + return; + } } -ReturnValue_t HeaterHandler::executeAction(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { - ReturnValue_t result; - if (actionId != SWITCH_HEATER) { - result = COMMAND_NOT_SUPPORTED; - } else { - switchNr_t switchNr = *data; - HeaterMapIter heaterMapIter = heaterMap.find(switchNr); - if (heaterMapIter != heaterMap.end()) { - if (heaterMapIter->second.active) { - return COMMAND_ALREADY_WAITING; - } - heaterMapIter->second.action = *(data + 1); - heaterMapIter->second.active = true; - heaterMapIter->second.replyQueue = commandedBy; - } - else { - sif::error << "HeaterHandler::executeAction: Invalid switchNr" << std::endl; - return INVALID_SWITCH_NR; - } - result = RETURN_OK; - } - return result; +ReturnValue_t HeaterHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) { + ReturnValue_t result; + if (actionId != SWITCH_HEATER) { + result = COMMAND_NOT_SUPPORTED; + } else { + switchNr_t switchNr = *data; + HeaterMapIter heaterMapIter = heaterMap.find(switchNr); + if (heaterMapIter != heaterMap.end()) { + if (heaterMapIter->second.active) { + return COMMAND_ALREADY_WAITING; + } + heaterMapIter->second.action = *(data + 1); + heaterMapIter->second.active = true; + heaterMapIter->second.replyQueue = commandedBy; + } else { + sif::error << "HeaterHandler::executeAction: Invalid switchNr" << std::endl; + return INVALID_SWITCH_NR; + } + result = RETURN_OK; + } + return result; } +void HeaterHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const { + ReturnValue_t result; + store_address_t storeAddress; + uint8_t commandData[2]; -void HeaterHandler::sendSwitchCommand(uint8_t switchNr, - ReturnValue_t onOff) const { + switch (onOff) { + case PowerSwitchIF::SWITCH_ON: + commandData[0] = switchNr; + commandData[1] = SET_SWITCH_ON; + break; + case PowerSwitchIF::SWITCH_OFF: + commandData[0] = switchNr; + commandData[1] = SET_SWITCH_OFF; + break; + default: + sif::error << "HeaterHandler::sendSwitchCommand: Invalid switch request" << std::endl; + break; + } - ReturnValue_t result; - store_address_t storeAddress; - uint8_t commandData[2]; - - switch(onOff) { - case PowerSwitchIF::SWITCH_ON: - commandData[0] = switchNr; - commandData[1] = SET_SWITCH_ON; - break; - case PowerSwitchIF::SWITCH_OFF: - commandData[0] = switchNr; - commandData[1] = SET_SWITCH_OFF; - break; - default: - sif::error << "HeaterHandler::sendSwitchCommand: Invalid switch request" - << std::endl; - break; - } - - result = IPCStore->addData(&storeAddress, commandData, sizeof(commandData)); - if (result == RETURN_OK) { - CommandMessage message; - ActionMessage::setCommand(&message, SWITCH_HEATER, storeAddress); - /* Send heater command to own command queue */ - result = commandQueue->sendMessage(commandQueue->getId(), &message, 0); - if (result != RETURN_OK) { - sif::debug << "HeaterHandler::sendSwitchCommand: Failed to send switch" - << "message" << std::endl; - } - } + result = IPCStore->addData(&storeAddress, commandData, sizeof(commandData)); + if (result == RETURN_OK) { + CommandMessage message; + ActionMessage::setCommand(&message, SWITCH_HEATER, storeAddress); + /* Send heater command to own command queue */ + result = commandQueue->sendMessage(commandQueue->getId(), &message, 0); + if (result != RETURN_OK) { + sif::debug << "HeaterHandler::sendSwitchCommand: Failed to send switch" + << "message" << std::endl; + } + } } -void HeaterHandler::handleActiveCommands(){ - - HeaterMapIter heaterMapIter = heaterMap.begin(); - for (; heaterMapIter != heaterMap.end(); heaterMapIter++) { - if (heaterMapIter->second.active) { - switch(heaterMapIter->second.action) { - case SET_SWITCH_ON: - handleSwitchOnCommand(heaterMapIter); - break; - case SET_SWITCH_OFF: - handleSwitchOffCommand(heaterMapIter); - break; - default: - sif::error << "HeaterHandler::handleActiveCommands: Invalid action commanded" - << std::endl; - break; - } - } - } +void HeaterHandler::handleActiveCommands() { + HeaterMapIter heaterMapIter = heaterMap.begin(); + for (; heaterMapIter != heaterMap.end(); heaterMapIter++) { + if (heaterMapIter->second.active) { + switch (heaterMapIter->second.action) { + case SET_SWITCH_ON: + handleSwitchOnCommand(heaterMapIter); + break; + case SET_SWITCH_OFF: + handleSwitchOffCommand(heaterMapIter); + break; + default: + sif::error << "HeaterHandler::handleActiveCommands: Invalid action commanded" + << std::endl; + break; + } + } + } } void HeaterHandler::handleSwitchOnCommand(HeaterMapIter heaterMapIter) { + ReturnValue_t result = RETURN_OK; + switchNr_t switchNr; - ReturnValue_t result = RETURN_OK; - switchNr_t switchNr; + /* Check if command waits for main switch being set on and whether the timeout has expired */ + if (heaterMapIter->second.waitMainSwitchOn && + heaterMapIter->second.mainSwitchCountdown.hasTimedOut()) { + // TODO - This requires the initiation of an FDIR procedure + triggerEvent(MAIN_SWITCH_TIMEOUT); + sif::error << "HeaterHandler::handleSwitchOnCommand: Main switch setting on timeout" + << std::endl; + heaterMapIter->second.active = false; + heaterMapIter->second.waitMainSwitchOn = false; + if (heaterMapIter->second.replyQueue != commandQueue->getId()) { + actionHelper.finish(false, heaterMapIter->second.replyQueue, heaterMapIter->second.action, + MAIN_SWITCH_SET_TIMEOUT); + } + return; + } - /* Check if command waits for main switch being set on and whether the timeout has expired */ - if (heaterMapIter->second.waitMainSwitchOn - && heaterMapIter->second.mainSwitchCountdown.hasTimedOut()) { - //TODO - This requires the initiation of an FDIR procedure - triggerEvent(MAIN_SWITCH_TIMEOUT); - sif::error << "HeaterHandler::handleSwitchOnCommand: Main switch setting on timeout" - << std::endl; - heaterMapIter->second.active = false; - heaterMapIter->second.waitMainSwitchOn = false; - if (heaterMapIter->second.replyQueue != commandQueue->getId()) { - actionHelper.finish(false, heaterMapIter->second.replyQueue, - heaterMapIter->second.action, MAIN_SWITCH_SET_TIMEOUT ); - } - return; + switchNr = heaterMapIter->first; + /* Check state of main line switch */ + ReturnValue_t mainSwitchState = mainLineSwitcher->getSwitchState(mainLineSwitch); + if (mainSwitchState == PowerSwitchIF::SWITCH_ON) { + if (!checkSwitchState(switchNr)) { + gpioId_t gpioId = getGpioIdFromSwitchNr(switchNr); + result = gpioInterface->pullHigh(gpioId); + if (result != RETURN_OK) { + sif::error << "HeaterHandler::handleSwitchOnCommand: Failed to pull gpio with id " << gpioId + << " high" << std::endl; + triggerEvent(GPIO_PULL_HIGH_FAILED, result); + } else { + switchStates[switchNr] = ON; + } + } else { + triggerEvent(SWITCH_ALREADY_ON, switchNr); } - - switchNr = heaterMapIter->first; - /* Check state of main line switch */ - ReturnValue_t mainSwitchState = mainLineSwitcher->getSwitchState(mainLineSwitch); - if (mainSwitchState == PowerSwitchIF::SWITCH_ON) { - if (!checkSwitchState(switchNr)) { - gpioId_t gpioId = getGpioIdFromSwitchNr(switchNr); - result = gpioInterface->pullHigh(gpioId); - if (result != RETURN_OK) { - sif::error << "HeaterHandler::handleSwitchOnCommand: Failed to pull gpio with id " - << gpioId << " high" << std::endl; - triggerEvent(GPIO_PULL_HIGH_FAILED, result); - } - else { - switchStates[switchNr] = ON; - } - } - else { - triggerEvent(SWITCH_ALREADY_ON, switchNr); - } - /* There is no need to send action finish replies if the sender was the - * HeaterHandler itself. */ - if (heaterMapIter->second.replyQueue != commandQueue->getId()) { - if(result == RETURN_OK) { - actionHelper.finish(true, heaterMapIter->second.replyQueue, - heaterMapIter->second.action, result); - } - else { - actionHelper.finish(false, heaterMapIter->second.replyQueue, - heaterMapIter->second.action, result); - } - - } - heaterMapIter->second.active = false; - heaterMapIter->second.waitMainSwitchOn = false; + /* There is no need to send action finish replies if the sender was the + * HeaterHandler itself. */ + if (heaterMapIter->second.replyQueue != commandQueue->getId()) { + if (result == RETURN_OK) { + actionHelper.finish(true, heaterMapIter->second.replyQueue, heaterMapIter->second.action, + result); + } else { + actionHelper.finish(false, heaterMapIter->second.replyQueue, heaterMapIter->second.action, + result); + } } - else if (mainSwitchState == PowerSwitchIF::SWITCH_OFF - && heaterMapIter->second.waitMainSwitchOn) { - /* Just waiting for the main switch being set on */ - return; - } - else if (mainSwitchState == PowerSwitchIF::SWITCH_OFF) { - mainLineSwitcher->sendSwitchCommand(mainLineSwitch, - PowerSwitchIF::SWITCH_ON); - heaterMapIter->second.mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs()); - heaterMapIter->second.waitMainSwitchOn = true; - } - else { - sif::debug << "HeaterHandler::handleActiveCommands: Failed to get state of" - << " main line switch" << std::endl; - if (heaterMapIter->second.replyQueue != commandQueue->getId()) { - actionHelper.finish(false, heaterMapIter->second.replyQueue, - heaterMapIter->second.action, mainSwitchState); - } - heaterMapIter->second.active = false; + heaterMapIter->second.active = false; + heaterMapIter->second.waitMainSwitchOn = false; + } else if (mainSwitchState == PowerSwitchIF::SWITCH_OFF && + heaterMapIter->second.waitMainSwitchOn) { + /* Just waiting for the main switch being set on */ + return; + } else if (mainSwitchState == PowerSwitchIF::SWITCH_OFF) { + mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_ON); + heaterMapIter->second.mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs()); + heaterMapIter->second.waitMainSwitchOn = true; + } else { + sif::debug << "HeaterHandler::handleActiveCommands: Failed to get state of" + << " main line switch" << std::endl; + if (heaterMapIter->second.replyQueue != commandQueue->getId()) { + actionHelper.finish(false, heaterMapIter->second.replyQueue, heaterMapIter->second.action, + mainSwitchState); } + heaterMapIter->second.active = false; + } } void HeaterHandler::handleSwitchOffCommand(HeaterMapIter heaterMapIter) { - ReturnValue_t result = RETURN_OK; - switchNr_t switchNr = heaterMapIter->first; - /* Check whether switch is already off */ - if (checkSwitchState(switchNr)) { - gpioId_t gpioId = getGpioIdFromSwitchNr(switchNr); - result = gpioInterface->pullLow(gpioId); - if (result != RETURN_OK) { - sif::error << "HeaterHandler::handleSwitchOffCommand: Failed to pull gpio with id" - << gpioId << " low" << std::endl; - triggerEvent(GPIO_PULL_LOW_FAILED, result); - } - else { - switchStates[switchNr] = OFF; - /* When all switches are off, also main line switch will be turned off */ - if (allSwitchesOff()) { - mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); - } - } + ReturnValue_t result = RETURN_OK; + switchNr_t switchNr = heaterMapIter->first; + /* Check whether switch is already off */ + if (checkSwitchState(switchNr)) { + gpioId_t gpioId = getGpioIdFromSwitchNr(switchNr); + result = gpioInterface->pullLow(gpioId); + if (result != RETURN_OK) { + sif::error << "HeaterHandler::handleSwitchOffCommand: Failed to pull gpio with id" << gpioId + << " low" << std::endl; + triggerEvent(GPIO_PULL_LOW_FAILED, result); + } else { + switchStates[switchNr] = OFF; + /* When all switches are off, also main line switch will be turned off */ + if (allSwitchesOff()) { + mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); + } } - else { - sif::info << "HeaterHandler::handleSwitchOffCommand: Switch already off" << std::endl; - triggerEvent(SWITCH_ALREADY_OFF, switchNr); + } else { + sif::info << "HeaterHandler::handleSwitchOffCommand: Switch already off" << std::endl; + triggerEvent(SWITCH_ALREADY_OFF, switchNr); + } + if (heaterMapIter->second.replyQueue != NO_COMMANDER) { + /* Report back switch command reply if necessary */ + if (result == HasReturnvaluesIF::RETURN_OK) { + actionHelper.finish(true, heaterMapIter->second.replyQueue, heaterMapIter->second.action, + result); + } else { + actionHelper.finish(false, heaterMapIter->second.replyQueue, heaterMapIter->second.action, + result); } - if (heaterMapIter->second.replyQueue != NO_COMMANDER) { - /* Report back switch command reply if necessary */ - if(result == HasReturnvaluesIF::RETURN_OK) { - actionHelper.finish(true, heaterMapIter->second.replyQueue, - heaterMapIter->second.action, result); - } - else { - actionHelper.finish(false, heaterMapIter->second.replyQueue, - heaterMapIter->second.action, result); - } - } - heaterMapIter->second.active = false; + } + heaterMapIter->second.active = false; } -bool HeaterHandler::checkSwitchState(int switchNr) { - return switchStates[switchNr]; -} +bool HeaterHandler::checkSwitchState(int switchNr) { return switchStates[switchNr]; } bool HeaterHandler::allSwitchesOff() { - bool allSwitchesOrd = false; - /* Or all switches. As soon one switch is on, allSwitchesOrd will be true */ - for (switchNr_t switchNr = 0; switchNr < heaterSwitches::NUMBER_OF_SWITCHES; switchNr++) { - allSwitchesOrd = allSwitchesOrd || switchStates[switchNr]; - } - return !allSwitchesOrd; + bool allSwitchesOrd = false; + /* Or all switches. As soon one switch is on, allSwitchesOrd will be true */ + for (switchNr_t switchNr = 0; switchNr < heaterSwitches::NUMBER_OF_SWITCHES; switchNr++) { + allSwitchesOrd = allSwitchesOrd || switchStates[switchNr]; + } + return !allSwitchesOrd; } gpioId_t HeaterHandler::getGpioIdFromSwitchNr(int switchNr) { - gpioId_t gpioId = 0xFFFF; - switch(switchNr) { + gpioId_t gpioId = 0xFFFF; + switch (switchNr) { case heaterSwitches::HEATER_0: - gpioId = gpioIds::HEATER_0; - break; + gpioId = gpioIds::HEATER_0; + break; case heaterSwitches::HEATER_1: - gpioId = gpioIds::HEATER_1; - break; + gpioId = gpioIds::HEATER_1; + break; case heaterSwitches::HEATER_2: - gpioId = gpioIds::HEATER_2; - break; + gpioId = gpioIds::HEATER_2; + break; case heaterSwitches::HEATER_3: - gpioId = gpioIds::HEATER_3; - break; + gpioId = gpioIds::HEATER_3; + break; case heaterSwitches::HEATER_4: - gpioId = gpioIds::HEATER_4; - break; + gpioId = gpioIds::HEATER_4; + break; case heaterSwitches::HEATER_5: - gpioId = gpioIds::HEATER_5; - break; + gpioId = gpioIds::HEATER_5; + break; case heaterSwitches::HEATER_6: - gpioId = gpioIds::HEATER_6; - break; + gpioId = gpioIds::HEATER_6; + break; case heaterSwitches::HEATER_7: - gpioId = gpioIds::HEATER_7; - break; + gpioId = gpioIds::HEATER_7; + break; default: - sif::error << "HeaterHandler::getGpioIdFromSwitchNr: Unknown heater switch number" - << std::endl; - break; - } - return gpioId; + sif::error << "HeaterHandler::getGpioIdFromSwitchNr: Unknown heater switch number" + << std::endl; + break; + } + return gpioId; } -MessageQueueId_t HeaterHandler::getCommandQueue() const { - return commandQueue->getId(); -} +MessageQueueId_t HeaterHandler::getCommandQueue() const { return commandQueue->getId(); } -void HeaterHandler::sendFuseOnCommand(uint8_t fuseNr) const { -} +void HeaterHandler::sendFuseOnCommand(uint8_t fuseNr) const {} -ReturnValue_t HeaterHandler::getSwitchState( uint8_t switchNr ) const { - return 0; -} +ReturnValue_t HeaterHandler::getSwitchState(uint8_t switchNr) const { return 0; } -ReturnValue_t HeaterHandler::getFuseState( uint8_t fuseNr ) const { - return 0; -} +ReturnValue_t HeaterHandler::getFuseState(uint8_t fuseNr) const { return 0; } -uint32_t HeaterHandler::getSwitchDelayMs(void) const { - return 0; -} +uint32_t HeaterHandler::getSwitchDelayMs(void) const { return 0; } diff --git a/mission/devices/HeaterHandler.h b/mission/devices/HeaterHandler.h index b52e22d4..2a8ce555 100644 --- a/mission/devices/HeaterHandler.h +++ b/mission/devices/HeaterHandler.h @@ -1,177 +1,169 @@ #ifndef MISSION_DEVICES_HEATERHANDLER_H_ #define MISSION_DEVICES_HEATERHANDLER_H_ -#include "devices/heaterSwitcherList.h" - -#include -#include -#include #include -#include -#include #include +#include +#include +#include +#include +#include #include #include + #include +#include "devices/heaterSwitcherList.h" + /** * @brief This class intends the control of heaters. * * @author J. Meier */ -class HeaterHandler: public ExecutableObjectIF, - public PowerSwitchIF, - public SystemObject, - public HasActionsIF { -public: - static const uint8_t INTERFACE_ID = CLASS_ID::HEATER_HANDLER; +class HeaterHandler : public ExecutableObjectIF, + public PowerSwitchIF, + public SystemObject, + public HasActionsIF { + public: + static const uint8_t INTERFACE_ID = CLASS_ID::HEATER_HANDLER; - static const ReturnValue_t COMMAND_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA1); - static const ReturnValue_t INIT_FAILED = MAKE_RETURN_CODE(0xA2); - static const ReturnValue_t INVALID_SWITCH_NR = MAKE_RETURN_CODE(0xA3); - static const ReturnValue_t MAIN_SWITCH_SET_TIMEOUT = MAKE_RETURN_CODE(0xA4); - static const ReturnValue_t COMMAND_ALREADY_WAITING = MAKE_RETURN_CODE(0xA5); + static const ReturnValue_t COMMAND_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA1); + static const ReturnValue_t INIT_FAILED = MAKE_RETURN_CODE(0xA2); + static const ReturnValue_t INVALID_SWITCH_NR = MAKE_RETURN_CODE(0xA3); + static const ReturnValue_t MAIN_SWITCH_SET_TIMEOUT = MAKE_RETURN_CODE(0xA4); + static const ReturnValue_t COMMAND_ALREADY_WAITING = MAKE_RETURN_CODE(0xA5); - /** Device command IDs */ - static const DeviceCommandId_t SWITCH_HEATER = 0x0; + /** Device command IDs */ + static const DeviceCommandId_t SWITCH_HEATER = 0x0; - HeaterHandler(object_id_t setObjectId, object_id_t gpioDriverId, CookieIF * gpioCookie, - object_id_t mainLineSwitcherObjectId, uint8_t mainLineSwitch); + HeaterHandler(object_id_t setObjectId, object_id_t gpioDriverId, CookieIF* gpioCookie, + object_id_t mainLineSwitcherObjectId, uint8_t mainLineSwitch); - virtual ~HeaterHandler(); + virtual ~HeaterHandler(); - virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; + virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; - virtual void sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const override; - virtual void sendFuseOnCommand(uint8_t fuseNr) const override; - /** - * @brief This function will be called from the Heater object to check - * the current switch state. - */ - virtual ReturnValue_t getSwitchState( uint8_t switchNr ) const override; - virtual ReturnValue_t getFuseState( uint8_t fuseNr ) const override; - virtual uint32_t getSwitchDelayMs(void) const override; + virtual void sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const override; + virtual void sendFuseOnCommand(uint8_t fuseNr) const override; + /** + * @brief This function will be called from the Heater object to check + * the current switch state. + */ + virtual ReturnValue_t getSwitchState(uint8_t switchNr) const override; + virtual ReturnValue_t getFuseState(uint8_t fuseNr) const override; + virtual uint32_t getSwitchDelayMs(void) const override; - virtual MessageQueueId_t getCommandQueue() const override; - virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size) override; - virtual ReturnValue_t initialize() override; + virtual MessageQueueId_t getCommandQueue() const override; + virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) override; + virtual ReturnValue_t initialize() override; -private: + private: + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::HEATER_HANDLER; + static const Event GPIO_PULL_HIGH_FAILED = MAKE_EVENT(0, severity::LOW); + static const Event GPIO_PULL_LOW_FAILED = MAKE_EVENT(1, severity::LOW); + static const Event SWITCH_ALREADY_ON = MAKE_EVENT(2, severity::LOW); + static const Event SWITCH_ALREADY_OFF = MAKE_EVENT(3, severity::LOW); + static const Event MAIN_SWITCH_TIMEOUT = MAKE_EVENT(4, severity::LOW); - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::HEATER_HANDLER; - static const Event GPIO_PULL_HIGH_FAILED = MAKE_EVENT(0, severity::LOW); - static const Event GPIO_PULL_LOW_FAILED = MAKE_EVENT(1, severity::LOW); - static const Event SWITCH_ALREADY_ON = MAKE_EVENT(2, severity::LOW); - static const Event SWITCH_ALREADY_OFF = MAKE_EVENT(3, severity::LOW); - static const Event MAIN_SWITCH_TIMEOUT = MAKE_EVENT(4, severity::LOW); + static const MessageQueueId_t NO_COMMANDER = 0; - static const MessageQueueId_t NO_COMMANDER = 0; + enum SwitchState : bool { ON = true, OFF = false }; - enum SwitchState : bool { - ON = true, - OFF = false - }; + /** + * @brief Struct holding information about a heater command to execute. + * + * @param action The action to perform. + * @param replyQueue The queue of the commander to which status replies + * will be sent. + * @param active True if command is waiting for execution, otherwise false. + * @param waitSwitchOn True if the command is waiting for the main switch being set on. + * @param mainSwitchCountdown Sets timeout to wait for main switch being set on. + */ + typedef struct HeaterCommandInfo { + uint8_t action; + MessageQueueId_t replyQueue; + bool active = false; + bool waitMainSwitchOn = false; + Countdown mainSwitchCountdown; + } HeaterCommandInfo_t; + enum SwitchAction { SET_SWITCH_OFF, SET_SWITCH_ON }; - /** - * @brief Struct holding information about a heater command to execute. - * - * @param action The action to perform. - * @param replyQueue The queue of the commander to which status replies - * will be sent. - * @param active True if command is waiting for execution, otherwise false. - * @param waitSwitchOn True if the command is waiting for the main switch being set on. - * @param mainSwitchCountdown Sets timeout to wait for main switch being set on. - */ - typedef struct HeaterCommandInfo { - uint8_t action; - MessageQueueId_t replyQueue; - bool active = false; - bool waitMainSwitchOn = false; - Countdown mainSwitchCountdown; - } HeaterCommandInfo_t; + using switchNr_t = uint8_t; + using HeaterMap = std::unordered_map; + using HeaterMapIter = HeaterMap::iterator; - enum SwitchAction { - SET_SWITCH_OFF, - SET_SWITCH_ON - }; + HeaterMap heaterMap; - using switchNr_t = uint8_t; - using HeaterMap = std::unordered_map; - using HeaterMapIter = HeaterMap::iterator; + bool switchStates[heaterSwitches::NUMBER_OF_SWITCHES]; - HeaterMap heaterMap; + /** Size of command queue */ + size_t cmdQueueSize = 20; - bool switchStates[heaterSwitches::NUMBER_OF_SWITCHES]; + /** + * The object ID of the GPIO driver which enables and disables the + * heaters. + */ + object_id_t gpioDriverId; - /** Size of command queue */ - size_t cmdQueueSize = 20; + CookieIF* gpioCookie; - /** - * The object ID of the GPIO driver which enables and disables the - * heaters. - */ - object_id_t gpioDriverId; + GpioIF* gpioInterface = nullptr; - CookieIF * gpioCookie; + /** Queue to receive messages from other objects. */ + MessageQueueIF* commandQueue = nullptr; - GpioIF* gpioInterface = nullptr; + object_id_t mainLineSwitcherObjectId; - /** Queue to receive messages from other objects. */ - MessageQueueIF* commandQueue = nullptr; + /** Switch number of the heater power supply switch */ + uint8_t mainLineSwitch; - object_id_t mainLineSwitcherObjectId; + /** + * Power switcher object which controls the 8V main line of the heater + * logic on the TCS board. + */ + PowerSwitchIF* mainLineSwitcher = nullptr; - /** Switch number of the heater power supply switch */ - uint8_t mainLineSwitch; + ActionHelper actionHelper; - /** - * Power switcher object which controls the 8V main line of the heater - * logic on the TCS board. - */ - PowerSwitchIF *mainLineSwitcher = nullptr; + StorageManagerIF* IPCStore = nullptr; - ActionHelper actionHelper; + void readCommandQueue(); - StorageManagerIF *IPCStore = nullptr; + /** + * @brief Returns the state of a switch (ON - true, or OFF - false). + * @param switchNr The number of the switch to check. + */ + bool checkSwitchState(int switchNr); - void readCommandQueue(); + /** + * @brief Returns the ID of the GPIO related to a heater identified by the switch number + * which is defined in the heaterSwitches list. + */ + gpioId_t getGpioIdFromSwitchNr(int switchNr); - /** - * @brief Returns the state of a switch (ON - true, or OFF - false). - * @param switchNr The number of the switch to check. - */ - bool checkSwitchState(int switchNr); + /** + * @brief This function runs commands waiting for execution. + */ + void handleActiveCommands(); - /** - * @brief Returns the ID of the GPIO related to a heater identified by the switch number - * which is defined in the heaterSwitches list. - */ - gpioId_t getGpioIdFromSwitchNr(int switchNr); + ReturnValue_t initializeHeaterMap(); - /** - * @brief This function runs commands waiting for execution. - */ - void handleActiveCommands(); + /** + * @brief Sets all switches to OFF. + */ + void setInitialSwitchStates(); - ReturnValue_t initializeHeaterMap(); + void handleSwitchOnCommand(HeaterMapIter heaterMapIter); - /** - * @brief Sets all switches to OFF. - */ - void setInitialSwitchStates(); - - void handleSwitchOnCommand(HeaterMapIter heaterMapIter); - - void handleSwitchOffCommand(HeaterMapIter heaterMapIter); - - /** - * @brief Checks if all switches are off. - * @return True if all switches are off, otherwise false. - */ - bool allSwitchesOff(); + void handleSwitchOffCommand(HeaterMapIter heaterMapIter); + /** + * @brief Checks if all switches are off. + * @return True if all switches are off, otherwise false. + */ + bool allSwitchesOff(); }; #endif /* MISSION_DEVICES_HEATERHANDLER_H_ */ diff --git a/mission/devices/IMTQHandler.cpp b/mission/devices/IMTQHandler.cpp index 125040d7..499b4d6e 100644 --- a/mission/devices/IMTQHandler.cpp +++ b/mission/devices/IMTQHandler.cpp @@ -1,248 +1,249 @@ #include "IMTQHandler.h" -#include "OBSWConfig.h" -#include #include +#include #include -IMTQHandler::IMTQHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - DeviceHandlerBase(objectId, comIF, comCookie), engHkDataset(this), calMtmMeasurementSet( - this), rawMtmMeasurementSet(this), posXselfTestDataset(this), negXselfTestDataset( - this), posYselfTestDataset(this), negYselfTestDataset(this), posZselfTestDataset( - this), negZselfTestDataset(this) { - if (comCookie == NULL) { - sif::error << "IMTQHandler: Invalid com cookie" << std::endl; - } +#include "OBSWConfig.h" + +IMTQHandler::IMTQHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie) + : DeviceHandlerBase(objectId, comIF, comCookie), + engHkDataset(this), + calMtmMeasurementSet(this), + rawMtmMeasurementSet(this), + posXselfTestDataset(this), + negXselfTestDataset(this), + posYselfTestDataset(this), + negYselfTestDataset(this), + posZselfTestDataset(this), + negZselfTestDataset(this) { + if (comCookie == NULL) { + sif::error << "IMTQHandler: Invalid com cookie" << std::endl; + } } -IMTQHandler::~IMTQHandler() { -} +IMTQHandler::~IMTQHandler() {} void IMTQHandler::doStartUp() { #if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 - setMode(MODE_NORMAL); + setMode(MODE_NORMAL); #else - setMode(_MODE_TO_ON); + setMode(_MODE_TO_ON); #endif } -void IMTQHandler::doShutDown() { - setMode(_MODE_POWER_DOWN); -} +void IMTQHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } -ReturnValue_t IMTQHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) { - switch (communicationStep) { +ReturnValue_t IMTQHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + switch (communicationStep) { case CommunicationStep::GET_ENG_HK_DATA: - *id = IMTQ::GET_ENG_HK_DATA; - communicationStep = CommunicationStep::START_MTM_MEASUREMENT; - break; + *id = IMTQ::GET_ENG_HK_DATA; + communicationStep = CommunicationStep::START_MTM_MEASUREMENT; + break; case CommunicationStep::START_MTM_MEASUREMENT: - *id = IMTQ::START_MTM_MEASUREMENT; - communicationStep = CommunicationStep::GET_CAL_MTM_MEASUREMENT; - break; + *id = IMTQ::START_MTM_MEASUREMENT; + communicationStep = CommunicationStep::GET_CAL_MTM_MEASUREMENT; + break; case CommunicationStep::GET_CAL_MTM_MEASUREMENT: - *id = IMTQ::GET_CAL_MTM_MEASUREMENT; - communicationStep = CommunicationStep::GET_RAW_MTM_MEASUREMENT; - break; + *id = IMTQ::GET_CAL_MTM_MEASUREMENT; + communicationStep = CommunicationStep::GET_RAW_MTM_MEASUREMENT; + break; case CommunicationStep::GET_RAW_MTM_MEASUREMENT: - *id = IMTQ::GET_RAW_MTM_MEASUREMENT; - communicationStep = CommunicationStep::GET_ENG_HK_DATA; - break; + *id = IMTQ::GET_RAW_MTM_MEASUREMENT; + communicationStep = CommunicationStep::GET_ENG_HK_DATA; + break; default: - sif::debug << "IMTQHandler::buildNormalDeviceCommand: Invalid communication step" - << std::endl; - break; - } - return buildCommandFromCommand(*id, NULL, 0); + sif::debug << "IMTQHandler::buildNormalDeviceCommand: Invalid communication step" + << std::endl; + break; + } + return buildCommandFromCommand(*id, NULL, 0); } -ReturnValue_t IMTQHandler::buildTransitionDeviceCommand(DeviceCommandId_t * id) { - return RETURN_OK; -} +ReturnValue_t IMTQHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { return RETURN_OK; } ReturnValue_t IMTQHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t * commandData, size_t commandDataLen) { - switch (deviceCommand) { + const uint8_t* commandData, + size_t commandDataLen) { + switch (deviceCommand) { case (IMTQ::POS_X_SELF_TEST): { - commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; - commandBuffer[1] = IMTQ::SELF_TEST_AXIS::X_POSITIVE; - rawPacket = commandBuffer; - rawPacketLen = 2; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; + commandBuffer[1] = IMTQ::SELF_TEST_AXIS::X_POSITIVE; + rawPacket = commandBuffer; + rawPacketLen = 2; + return RETURN_OK; } case (IMTQ::NEG_X_SELF_TEST): { - commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; - commandBuffer[1] = IMTQ::SELF_TEST_AXIS::X_NEGATIVE; - rawPacket = commandBuffer; - rawPacketLen = 2; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; + commandBuffer[1] = IMTQ::SELF_TEST_AXIS::X_NEGATIVE; + rawPacket = commandBuffer; + rawPacketLen = 2; + return RETURN_OK; } case (IMTQ::POS_Y_SELF_TEST): { - commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; - commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Y_POSITIVE; - rawPacket = commandBuffer; - rawPacketLen = 2; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; + commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Y_POSITIVE; + rawPacket = commandBuffer; + rawPacketLen = 2; + return RETURN_OK; } case (IMTQ::NEG_Y_SELF_TEST): { - commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; - commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Y_NEGATIVE; - rawPacket = commandBuffer; - rawPacketLen = 2; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; + commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Y_NEGATIVE; + rawPacket = commandBuffer; + rawPacketLen = 2; + return RETURN_OK; } case (IMTQ::POS_Z_SELF_TEST): { - commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; - commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Z_POSITIVE; - rawPacket = commandBuffer; - rawPacketLen = 2; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; + commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Z_POSITIVE; + rawPacket = commandBuffer; + rawPacketLen = 2; + return RETURN_OK; } case (IMTQ::NEG_Z_SELF_TEST): { - commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; - commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Z_NEGATIVE; - rawPacket = commandBuffer; - rawPacketLen = 2; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; + commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Z_NEGATIVE; + rawPacket = commandBuffer; + rawPacketLen = 2; + return RETURN_OK; } case (IMTQ::GET_SELF_TEST_RESULT): { - commandBuffer[0] = IMTQ::CC::GET_SELF_TEST_RESULT; - rawPacket = commandBuffer; - rawPacketLen = 1; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::GET_SELF_TEST_RESULT; + rawPacket = commandBuffer; + rawPacketLen = 1; + return RETURN_OK; } case (IMTQ::START_ACTUATION_DIPOLE): { - /* IMTQ expects low byte first */ - commandBuffer[0] = IMTQ::CC::START_ACTUATION_DIPOLE; - commandBuffer[1] = *(commandData + 1); - commandBuffer[2] = *(commandData); - commandBuffer[3] = *(commandData + 3); - commandBuffer[4] = *(commandData + 2); - commandBuffer[5] = *(commandData + 5); - commandBuffer[6] = *(commandData + 4); - commandBuffer[7] = *(commandData + 7); - commandBuffer[8] = *(commandData + 6); - rawPacket = commandBuffer; - rawPacketLen = 9; - return RETURN_OK; + /* IMTQ expects low byte first */ + commandBuffer[0] = IMTQ::CC::START_ACTUATION_DIPOLE; + commandBuffer[1] = *(commandData + 1); + commandBuffer[2] = *(commandData); + commandBuffer[3] = *(commandData + 3); + commandBuffer[4] = *(commandData + 2); + commandBuffer[5] = *(commandData + 5); + commandBuffer[6] = *(commandData + 4); + commandBuffer[7] = *(commandData + 7); + commandBuffer[8] = *(commandData + 6); + rawPacket = commandBuffer; + rawPacketLen = 9; + return RETURN_OK; } case (IMTQ::GET_ENG_HK_DATA): { - commandBuffer[0] = IMTQ::CC::GET_ENG_HK_DATA; - rawPacket = commandBuffer; - rawPacketLen = 1; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::GET_ENG_HK_DATA; + rawPacket = commandBuffer; + rawPacketLen = 1; + return RETURN_OK; } case (IMTQ::GET_COMMANDED_DIPOLE): { - commandBuffer[0] = IMTQ::CC::GET_COMMANDED_DIPOLE; - rawPacket = commandBuffer; - rawPacketLen = 1; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::GET_COMMANDED_DIPOLE; + rawPacket = commandBuffer; + rawPacketLen = 1; + return RETURN_OK; } case (IMTQ::START_MTM_MEASUREMENT): { - commandBuffer[0] = IMTQ::CC::START_MTM_MEASUREMENT; - rawPacket = commandBuffer; - rawPacketLen = 1; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::START_MTM_MEASUREMENT; + rawPacket = commandBuffer; + rawPacketLen = 1; + return RETURN_OK; } case (IMTQ::GET_CAL_MTM_MEASUREMENT): { - commandBuffer[0] = IMTQ::CC::GET_CAL_MTM_MEASUREMENT; - rawPacket = commandBuffer; - rawPacketLen = 1; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::GET_CAL_MTM_MEASUREMENT; + rawPacket = commandBuffer; + rawPacketLen = 1; + return RETURN_OK; } case (IMTQ::GET_RAW_MTM_MEASUREMENT): { - commandBuffer[0] = IMTQ::CC::GET_RAW_MTM_MEASUREMENT; - rawPacket = commandBuffer; - rawPacketLen = 1; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::GET_RAW_MTM_MEASUREMENT; + rawPacket = commandBuffer; + rawPacketLen = 1; + return RETURN_OK; } default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } void IMTQHandler::fillCommandAndReplyMap() { - this->insertInCommandAndReplyMap(IMTQ::POS_X_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::NEG_X_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::POS_Y_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::NEG_Y_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::POS_Z_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::NEG_Z_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::GET_SELF_TEST_RESULT, 1, nullptr, - IMTQ::SIZE_SELF_TEST_RESULTS); - this->insertInCommandAndReplyMap(IMTQ::START_ACTUATION_DIPOLE, 1, nullptr, - IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::GET_ENG_HK_DATA, 1, &engHkDataset, - IMTQ::SIZE_ENG_HK_DATA_REPLY); - this->insertInCommandAndReplyMap(IMTQ::GET_COMMANDED_DIPOLE, 1, nullptr, - IMTQ::SIZE_GET_COMMANDED_DIPOLE_REPLY); - this->insertInCommandAndReplyMap(IMTQ::START_MTM_MEASUREMENT, 1, nullptr, - IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::GET_CAL_MTM_MEASUREMENT, 1, &calMtmMeasurementSet, - IMTQ::SIZE_GET_CAL_MTM_MEASUREMENT); - this->insertInCommandAndReplyMap(IMTQ::GET_RAW_MTM_MEASUREMENT, 1, &rawMtmMeasurementSet, - IMTQ::SIZE_GET_RAW_MTM_MEASUREMENT); + this->insertInCommandAndReplyMap(IMTQ::POS_X_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::NEG_X_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::POS_Y_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::NEG_Y_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::POS_Z_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::NEG_Z_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::GET_SELF_TEST_RESULT, 1, nullptr, + IMTQ::SIZE_SELF_TEST_RESULTS); + this->insertInCommandAndReplyMap(IMTQ::START_ACTUATION_DIPOLE, 1, nullptr, + IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::GET_ENG_HK_DATA, 1, &engHkDataset, + IMTQ::SIZE_ENG_HK_DATA_REPLY); + this->insertInCommandAndReplyMap(IMTQ::GET_COMMANDED_DIPOLE, 1, nullptr, + IMTQ::SIZE_GET_COMMANDED_DIPOLE_REPLY); + this->insertInCommandAndReplyMap(IMTQ::START_MTM_MEASUREMENT, 1, nullptr, + IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::GET_CAL_MTM_MEASUREMENT, 1, &calMtmMeasurementSet, + IMTQ::SIZE_GET_CAL_MTM_MEASUREMENT); + this->insertInCommandAndReplyMap(IMTQ::GET_RAW_MTM_MEASUREMENT, 1, &rawMtmMeasurementSet, + IMTQ::SIZE_GET_RAW_MTM_MEASUREMENT); } -ReturnValue_t IMTQHandler::scanForReply(const uint8_t *start, size_t remainingSize, - DeviceCommandId_t *foundId, size_t *foundLen) { +ReturnValue_t IMTQHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; - - switch (*start) { + switch (*start) { case (IMTQ::CC::START_ACTUATION_DIPOLE): - *foundLen = IMTQ::SIZE_STATUS_REPLY; - *foundId = IMTQ::START_ACTUATION_DIPOLE; - break; + *foundLen = IMTQ::SIZE_STATUS_REPLY; + *foundId = IMTQ::START_ACTUATION_DIPOLE; + break; case (IMTQ::CC::START_MTM_MEASUREMENT): - *foundLen = IMTQ::SIZE_STATUS_REPLY; - *foundId = IMTQ::START_MTM_MEASUREMENT; - break; + *foundLen = IMTQ::SIZE_STATUS_REPLY; + *foundId = IMTQ::START_MTM_MEASUREMENT; + break; case (IMTQ::CC::GET_ENG_HK_DATA): - *foundLen = IMTQ::SIZE_ENG_HK_DATA_REPLY; - *foundId = IMTQ::GET_ENG_HK_DATA; - break; + *foundLen = IMTQ::SIZE_ENG_HK_DATA_REPLY; + *foundId = IMTQ::GET_ENG_HK_DATA; + break; case (IMTQ::CC::GET_COMMANDED_DIPOLE): - *foundLen = IMTQ::SIZE_GET_COMMANDED_DIPOLE_REPLY; - *foundId = IMTQ::GET_COMMANDED_DIPOLE; - break; + *foundLen = IMTQ::SIZE_GET_COMMANDED_DIPOLE_REPLY; + *foundId = IMTQ::GET_COMMANDED_DIPOLE; + break; case (IMTQ::CC::GET_CAL_MTM_MEASUREMENT): - *foundLen = IMTQ::SIZE_GET_CAL_MTM_MEASUREMENT; - *foundId = IMTQ::GET_CAL_MTM_MEASUREMENT; - break; + *foundLen = IMTQ::SIZE_GET_CAL_MTM_MEASUREMENT; + *foundId = IMTQ::GET_CAL_MTM_MEASUREMENT; + break; case (IMTQ::CC::GET_RAW_MTM_MEASUREMENT): - *foundLen = IMTQ::SIZE_GET_RAW_MTM_MEASUREMENT; - *foundId = IMTQ::GET_RAW_MTM_MEASUREMENT; - break; + *foundLen = IMTQ::SIZE_GET_RAW_MTM_MEASUREMENT; + *foundId = IMTQ::GET_RAW_MTM_MEASUREMENT; + break; case (IMTQ::CC::SELF_TEST_CMD): - *foundLen = IMTQ::SIZE_STATUS_REPLY; - result = getSelfTestCommandId(foundId); - break; + *foundLen = IMTQ::SIZE_STATUS_REPLY; + result = getSelfTestCommandId(foundId); + break; case (IMTQ::CC::GET_SELF_TEST_RESULT): - *foundLen = IMTQ::SIZE_SELF_TEST_RESULTS; - *foundId = IMTQ::GET_SELF_TEST_RESULT; - break; + *foundLen = IMTQ::SIZE_SELF_TEST_RESULTS; + *foundId = IMTQ::GET_SELF_TEST_RESULT; + break; default: - sif::debug << "IMTQHandler::scanForReply: Reply contains invalid command code" << std::endl; - result = IGNORE_REPLY_DATA; - break; - } + sif::debug << "IMTQHandler::scanForReply: Reply contains invalid command code" << std::endl; + result = IGNORE_REPLY_DATA; + break; + } - return result; + return result; } -ReturnValue_t IMTQHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { +ReturnValue_t IMTQHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = parseStatusByte(packet); - result = parseStatusByte(packet); + if (result != RETURN_OK) { + return result; + } - if (result != RETURN_OK) { - return result; - } - - switch (id) { + switch (id) { case (IMTQ::POS_X_SELF_TEST): case (IMTQ::NEG_X_SELF_TEST): case (IMTQ::POS_Y_SELF_TEST): @@ -251,1879 +252,1923 @@ ReturnValue_t IMTQHandler::interpretDeviceReply(DeviceCommandId_t id, const uint case (IMTQ::NEG_Z_SELF_TEST): case (IMTQ::START_ACTUATION_DIPOLE): case (IMTQ::START_MTM_MEASUREMENT): - /* Replies only the status byte which is already handled with parseStatusByte */ - break; + /* Replies only the status byte which is already handled with parseStatusByte */ + break; case (IMTQ::GET_ENG_HK_DATA): - fillEngHkDataset(packet); - break; + fillEngHkDataset(packet); + break; case (IMTQ::GET_COMMANDED_DIPOLE): - handleGetCommandedDipoleReply(packet); - break; + handleGetCommandedDipoleReply(packet); + break; case (IMTQ::GET_CAL_MTM_MEASUREMENT): - fillCalibratedMtmDataset(packet); - break; + fillCalibratedMtmDataset(packet); + break; case (IMTQ::GET_RAW_MTM_MEASUREMENT): - fillRawMtmDataset(packet); - break; + fillRawMtmDataset(packet); + break; case (IMTQ::GET_SELF_TEST_RESULT): - handleSelfTestReply(packet); - break; + handleSelfTestReply(packet); + break; default: { - sif::debug << "IMTQHandler::interpretDeviceReply: Unknown device reply id" << std::endl; - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } + sif::debug << "IMTQHandler::interpretDeviceReply: Unknown device reply id" << std::endl; + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; } + } - return RETURN_OK; + return RETURN_OK; } -void IMTQHandler::setNormalDatapoolEntriesInvalid() { - -} +void IMTQHandler::setNormalDatapoolEntriesInvalid() {} LocalPoolDataSetBase* IMTQHandler::getDataSetHandle(sid_t sid) { - if (sid == engHkDataset.getSid()) { - return &engHkDataset; - } else if (sid == calMtmMeasurementSet.getSid()) { - return &calMtmMeasurementSet; - } else if (sid == rawMtmMeasurementSet.getSid()) { - return &rawMtmMeasurementSet; - } else if (sid == posXselfTestDataset.getSid()) { - return &posXselfTestDataset; - } else if (sid == negXselfTestDataset.getSid()) { - return &negXselfTestDataset; - } else if (sid == posYselfTestDataset.getSid()) { - return &posYselfTestDataset; - } else if (sid == negYselfTestDataset.getSid()) { - return &negYselfTestDataset; - } else if (sid == posZselfTestDataset.getSid()) { - return &posZselfTestDataset; - } else if (sid == negZselfTestDataset.getSid()) { - return &negZselfTestDataset; - } else { - sif::error << "IMTQHandler::getDataSetHandle: Invalid sid" << std::endl; - return nullptr; - } + if (sid == engHkDataset.getSid()) { + return &engHkDataset; + } else if (sid == calMtmMeasurementSet.getSid()) { + return &calMtmMeasurementSet; + } else if (sid == rawMtmMeasurementSet.getSid()) { + return &rawMtmMeasurementSet; + } else if (sid == posXselfTestDataset.getSid()) { + return &posXselfTestDataset; + } else if (sid == negXselfTestDataset.getSid()) { + return &negXselfTestDataset; + } else if (sid == posYselfTestDataset.getSid()) { + return &posYselfTestDataset; + } else if (sid == negYselfTestDataset.getSid()) { + return &negYselfTestDataset; + } else if (sid == posZselfTestDataset.getSid()) { + return &posZselfTestDataset; + } else if (sid == negZselfTestDataset.getSid()) { + return &negZselfTestDataset; + } else { + sif::error << "IMTQHandler::getDataSetHandle: Invalid sid" << std::endl; + return nullptr; + } } -uint32_t IMTQHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { - return 5000; -} +uint32_t IMTQHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 5000; } ReturnValue_t IMTQHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { + LocalDataPoolManager& poolManager) { + /** Entries of engineering housekeeping dataset */ + localDataPoolMap.emplace(IMTQ::DIGITAL_VOLTAGE_MV, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::ANALOG_VOLTAGE_MV, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::DIGITAL_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::ANALOG_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::COIL_Z_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::MCU_TEMPERATURE, new PoolEntry({0})); - /** Entries of engineering housekeeping dataset */ - localDataPoolMap.emplace(IMTQ::DIGITAL_VOLTAGE_MV, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::ANALOG_VOLTAGE_MV, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::DIGITAL_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::ANALOG_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::MCU_TEMPERATURE, new PoolEntry( { 0 })); + /** Entries of calibrated MTM measurement dataset */ + localDataPoolMap.emplace(IMTQ::MTM_CAL_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::MTM_CAL_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::MTM_CAL_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::ACTUATION_CAL_STATUS, new PoolEntry({0})); - /** Entries of calibrated MTM measurement dataset */ - localDataPoolMap.emplace(IMTQ::MTM_CAL_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::MTM_CAL_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::MTM_CAL_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::ACTUATION_CAL_STATUS, new PoolEntry( { 0 })); + /** Entries of raw MTM measurement dataset */ + localDataPoolMap.emplace(IMTQ::MTM_RAW_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::MTM_RAW_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::MTM_RAW_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::ACTUATION_RAW_STATUS, new PoolEntry({0})); - /** Entries of raw MTM measurement dataset */ - localDataPoolMap.emplace(IMTQ::MTM_RAW_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::MTM_RAW_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::MTM_RAW_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::ACTUATION_RAW_STATUS, new PoolEntry( { 0 })); + /** INIT measurements for positive X axis test */ + localDataPoolMap.emplace(IMTQ::INIT_POS_X_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** INIT measurements for positive X axis test */ - localDataPoolMap.emplace(IMTQ::INIT_POS_X_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** INIT measurements for negative X axis test */ + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** INIT measurements for negative X axis test */ - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** INIT measurements for positive Y axis test */ + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** INIT measurements for positive Y axis test */ - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** INIT measurements for negative Y axis test */ + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** INIT measurements for negative Y axis test */ - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** INIT measurements for positive Z axis test */ + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** INIT measurements for positive Z axis test */ - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** INIT measurements for negative Z axis test */ + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** INIT measurements for negative Z axis test */ - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(IMTQ::POS_X_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_COIL_Z_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(IMTQ::POS_X_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(IMTQ::NEG_X_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Z_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(IMTQ::NEG_X_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(IMTQ::POS_Y_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Z_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(IMTQ::POS_Y_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(IMTQ::NEG_Y_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Z_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(IMTQ::NEG_Y_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(IMTQ::POS_Z_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Z_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(IMTQ::POS_Z_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(IMTQ::NEG_Z_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Z_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(IMTQ::NEG_Z_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** FINA measurements for positive X axis test */ + localDataPoolMap.emplace(IMTQ::FINA_POS_X_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** FINA measurements for positive X axis test */ - localDataPoolMap.emplace(IMTQ::FINA_POS_X_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** FINA measurements for negative X axis test */ + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** FINA measurements for negative X axis test */ - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** FINA measurements for positive Y axis test */ + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** FINA measurements for positive Y axis test */ - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** FINA measurements for negative Y axis test */ + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** FINA measurements for negative Y axis test */ - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** FINA measurements for positive Z axis test */ + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** FINA measurements for positive Z axis test */ - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** FINA measurements for negative Z axis test */ + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** FINA measurements for negative Z axis test */ - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t IMTQHandler::getSelfTestCommandId(DeviceCommandId_t* id) { - DeviceCommandId_t commandId = getPendingCommand(); - switch (commandId) { + DeviceCommandId_t commandId = getPendingCommand(); + switch (commandId) { case IMTQ::POS_X_SELF_TEST: case IMTQ::NEG_X_SELF_TEST: case IMTQ::POS_Y_SELF_TEST: case IMTQ::NEG_Y_SELF_TEST: case IMTQ::POS_Z_SELF_TEST: case IMTQ::NEG_Z_SELF_TEST: - *id = commandId; - break; + *id = commandId; + break; default: - sif::error << "IMTQHandler::getSelfTestCommandId: Reply does not match to pending " - << "command" << std::endl; - return UNEXPECTED_SELF_TEST_REPLY; - } - return RETURN_OK; + sif::error << "IMTQHandler::getSelfTestCommandId: Reply does not match to pending " + << "command" << std::endl; + return UNEXPECTED_SELF_TEST_REPLY; + } + return RETURN_OK; } ReturnValue_t IMTQHandler::parseStatusByte(const uint8_t* packet) { - uint8_t cmdErrorField = *(packet + 1) & 0xF; - switch (cmdErrorField) { + uint8_t cmdErrorField = *(packet + 1) & 0xF; + switch (cmdErrorField) { case 0: - return RETURN_OK; + return RETURN_OK; case 1: - sif::error << "IMTQHandler::parseStatusByte: Command rejected without reason" << std::endl; - return REJECTED_WITHOUT_REASON; + sif::error << "IMTQHandler::parseStatusByte: Command rejected without reason" << std::endl; + return REJECTED_WITHOUT_REASON; case 2: - sif::error << "IMTQHandler::parseStatusByte: Command has invalid command code" << std::endl; - return INVALID_COMMAND_CODE; + sif::error << "IMTQHandler::parseStatusByte: Command has invalid command code" << std::endl; + return INVALID_COMMAND_CODE; case 3: - sif::error << "IMTQHandler::parseStatusByte: Command has missing parameter" << std::endl; - return PARAMETER_MISSING; + sif::error << "IMTQHandler::parseStatusByte: Command has missing parameter" << std::endl; + return PARAMETER_MISSING; case 4: - sif::error << "IMTQHandler::parseStatusByte: Command has invalid parameter" << std::endl; - return PARAMETER_INVALID; + sif::error << "IMTQHandler::parseStatusByte: Command has invalid parameter" << std::endl; + return PARAMETER_INVALID; case 5: - sif::error << "IMTQHandler::parseStatusByte: CC unavailable" << std::endl; - return CC_UNAVAILABLE; + sif::error << "IMTQHandler::parseStatusByte: CC unavailable" << std::endl; + return CC_UNAVAILABLE; case 7: - sif::error << "IMTQHandler::parseStatusByte: IMQT replied internal processing error" - << std::endl; - return INTERNAL_PROCESSING_ERROR; + sif::error << "IMTQHandler::parseStatusByte: IMQT replied internal processing error" + << std::endl; + return INTERNAL_PROCESSING_ERROR; default: - sif::error << "IMTQHandler::parseStatusByte: CMD Error field contains unknown error code " - << cmdErrorField << std::endl; - return CMD_ERR_UNKNOWN; - } + sif::error << "IMTQHandler::parseStatusByte: CMD Error field contains unknown error code " + << cmdErrorField << std::endl; + return CMD_ERR_UNKNOWN; + } } void IMTQHandler::fillEngHkDataset(const uint8_t* packet) { - PoolReadGuard rg(&engHkDataset); - uint8_t offset = 2; - engHkDataset.digitalVoltageMv = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - engHkDataset.analogVoltageMv = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - engHkDataset.digitalCurrentmA = (*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; - offset += 2; - engHkDataset.analogCurrentmA = (*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; - offset += 2; - engHkDataset.coilXCurrentmA = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - engHkDataset.coilYCurrentmA = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - engHkDataset.coilZCurrentmA = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - engHkDataset.coilXTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); - offset += 2; - engHkDataset.coilYTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); - offset += 2; - engHkDataset.coilZTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); - offset += 2; - engHkDataset.mcuTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); + PoolReadGuard rg(&engHkDataset); + uint8_t offset = 2; + engHkDataset.digitalVoltageMv = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + engHkDataset.analogVoltageMv = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + engHkDataset.digitalCurrentmA = (*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + engHkDataset.analogCurrentmA = (*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + engHkDataset.coilXCurrentmA = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + engHkDataset.coilYCurrentmA = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + engHkDataset.coilZCurrentmA = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + engHkDataset.coilXTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); + offset += 2; + engHkDataset.coilYTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); + offset += 2; + engHkDataset.coilZTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); + offset += 2; + engHkDataset.mcuTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ digital voltage: " << engHkDataset.digitalVoltageMv << " mV" << std::endl; - sif::info << "IMTQ analog voltage: " << engHkDataset.analogVoltageMv << " mV" << std::endl; - sif::info << "IMTQ digital current: " << engHkDataset.digitalCurrentmA << " mA" << std::endl; - sif::info << "IMTQ analog current: " << engHkDataset.analogCurrentmA << " mA" << std::endl; - sif::info << "IMTQ coil X current: " << engHkDataset.coilXCurrentmA << " mA" << std::endl; - sif::info << "IMTQ coil Y current: " << engHkDataset.coilYCurrentmA << " mA" << std::endl; - sif::info << "IMTQ coil Z current: " << engHkDataset.coilZCurrentmA << " mA" << std::endl; - sif::info << "IMTQ coil X temperature: " << engHkDataset.coilXTemperature << " °C" - << std::endl; - sif::info << "IMTQ coil Y temperature: " << engHkDataset.coilYTemperature << " °C" - << std::endl; - sif::info << "IMTQ coil Z temperature: " << engHkDataset.coilZTemperature << " °C" - << std::endl; - sif::info << "IMTQ coil MCU temperature: " << engHkDataset.mcuTemperature << " °C" - << std::endl; +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ digital voltage: " << engHkDataset.digitalVoltageMv << " mV" << std::endl; + sif::info << "IMTQ analog voltage: " << engHkDataset.analogVoltageMv << " mV" << std::endl; + sif::info << "IMTQ digital current: " << engHkDataset.digitalCurrentmA << " mA" << std::endl; + sif::info << "IMTQ analog current: " << engHkDataset.analogCurrentmA << " mA" << std::endl; + sif::info << "IMTQ coil X current: " << engHkDataset.coilXCurrentmA << " mA" << std::endl; + sif::info << "IMTQ coil Y current: " << engHkDataset.coilYCurrentmA << " mA" << std::endl; + sif::info << "IMTQ coil Z current: " << engHkDataset.coilZCurrentmA << " mA" << std::endl; + sif::info << "IMTQ coil X temperature: " << engHkDataset.coilXTemperature << " °C" << std::endl; + sif::info << "IMTQ coil Y temperature: " << engHkDataset.coilYTemperature << " °C" << std::endl; + sif::info << "IMTQ coil Z temperature: " << engHkDataset.coilZTemperature << " °C" << std::endl; + sif::info << "IMTQ coil MCU temperature: " << engHkDataset.mcuTemperature << " °C" << std::endl; #endif } -void IMTQHandler::setModeNormal() { - mode = MODE_NORMAL; -} +void IMTQHandler::setModeNormal() { mode = MODE_NORMAL; } void IMTQHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId) { + if (wiretappingMode == RAW) { + /* Data already sent in doGetRead() */ + return; + } - if (wiretappingMode == RAW) { - /* Data already sent in doGetRead() */ - return; - } + DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId); + if (iter == deviceReplyMap.end()) { + sif::debug << "IMTQHandler::handleDeviceTM: Unknown reply id" << std::endl; + return; + } + MessageQueueId_t queueId = iter->second.command->second.sendReplyTo; - DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId); - if (iter == deviceReplyMap.end()) { - sif::debug << "IMTQHandler::handleDeviceTM: Unknown reply id" << std::endl; - return; - } - MessageQueueId_t queueId = iter->second.command->second.sendReplyTo; + if (queueId == NO_COMMANDER) { + return; + } - if (queueId == NO_COMMANDER) { - return; - } - - ReturnValue_t result = actionHelper.reportData(queueId, replyId, data, dataSize); - if (result != RETURN_OK) { - sif::debug << "IMTQHandler::handleDeviceTM: Failed to report data" << std::endl; - return; - } + ReturnValue_t result = actionHelper.reportData(queueId, replyId, data, dataSize); + if (result != RETURN_OK) { + sif::debug << "IMTQHandler::handleDeviceTM: Failed to report data" << std::endl; + return; + } } void IMTQHandler::handleGetCommandedDipoleReply(const uint8_t* packet) { - uint8_t tmData[6]; - /* Switching endianess of received dipole values */ - tmData[0] = *(packet + 3); - tmData[1] = *(packet + 2); - tmData[2] = *(packet + 5); - tmData[3] = *(packet + 4); - tmData[4] = *(packet + 7); - tmData[5] = *(packet + 6); - handleDeviceTM(tmData, sizeof(tmData), IMTQ::GET_COMMANDED_DIPOLE); + uint8_t tmData[6]; + /* Switching endianess of received dipole values */ + tmData[0] = *(packet + 3); + tmData[1] = *(packet + 2); + tmData[2] = *(packet + 5); + tmData[3] = *(packet + 4); + tmData[4] = *(packet + 7); + tmData[5] = *(packet + 6); + handleDeviceTM(tmData, sizeof(tmData), IMTQ::GET_COMMANDED_DIPOLE); } void IMTQHandler::fillCalibratedMtmDataset(const uint8_t* packet) { - PoolReadGuard rg(&calMtmMeasurementSet); - int8_t offset = 2; - calMtmMeasurementSet.mtmXnT = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - calMtmMeasurementSet.mtmYnT = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - calMtmMeasurementSet.mtmZnT = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - calMtmMeasurementSet.coilActuationStatus = (*(packet + offset + 3) << 24) - | (*(packet + offset + 2) << 16) | (*(packet + offset + 1) << 8) | (*(packet + offset)); -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ calibrated MTM measurement X: " << calMtmMeasurementSet.mtmXnT << " nT" + PoolReadGuard rg(&calMtmMeasurementSet); + int8_t offset = 2; + calMtmMeasurementSet.mtmXnT = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + calMtmMeasurementSet.mtmYnT = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + calMtmMeasurementSet.mtmZnT = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + calMtmMeasurementSet.coilActuationStatus = (*(packet + offset + 3) << 24) | + (*(packet + offset + 2) << 16) | + (*(packet + offset + 1) << 8) | (*(packet + offset)); +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ calibrated MTM measurement X: " << calMtmMeasurementSet.mtmXnT << " nT" << std::endl; - sif::info << "IMTQ calibrated MTM measurement Y: " << calMtmMeasurementSet.mtmYnT << " nT" + sif::info << "IMTQ calibrated MTM measurement Y: " << calMtmMeasurementSet.mtmYnT << " nT" << std::endl; - sif::info << "IMTQ calibrated MTM measurement Z: " << calMtmMeasurementSet.mtmZnT << " nT" + sif::info << "IMTQ calibrated MTM measurement Z: " << calMtmMeasurementSet.mtmZnT << " nT" << std::endl; - sif::info << "IMTQ coil actuation status during MTM measurement: " - << (unsigned int) calMtmMeasurementSet.coilActuationStatus.value << std::endl; + sif::info << "IMTQ coil actuation status during MTM measurement: " + << (unsigned int)calMtmMeasurementSet.coilActuationStatus.value << std::endl; #endif } void IMTQHandler::fillRawMtmDataset(const uint8_t* packet) { - PoolReadGuard rg(&rawMtmMeasurementSet); - int8_t offset = 2; - rawMtmMeasurementSet.mtmXnT = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - rawMtmMeasurementSet.mtmYnT = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - rawMtmMeasurementSet.mtmZnT = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - rawMtmMeasurementSet.coilActuationStatus = (*(packet + offset + 3) << 24) - | (*(packet + offset + 2) << 16) | (*(packet + offset + 1) << 8) | (*(packet + offset)); -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ raw MTM measurement X: " << rawMtmMeasurementSet.mtmXnT << " nT" - << std::endl; - sif::info << "IMTQ raw MTM measurement Y: " << rawMtmMeasurementSet.mtmYnT << " nT" - << std::endl; - sif::info << "IMTQ raw MTM measurement Z: " << rawMtmMeasurementSet.mtmZnT << " nT" - << std::endl; - sif::info << "IMTQ coil actuation status during MTM measurement: " - << (unsigned int) rawMtmMeasurementSet.coilActuationStatus.value << std::endl; + PoolReadGuard rg(&rawMtmMeasurementSet); + int8_t offset = 2; + rawMtmMeasurementSet.mtmXnT = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + rawMtmMeasurementSet.mtmYnT = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + rawMtmMeasurementSet.mtmZnT = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + rawMtmMeasurementSet.coilActuationStatus = (*(packet + offset + 3) << 24) | + (*(packet + offset + 2) << 16) | + (*(packet + offset + 1) << 8) | (*(packet + offset)); +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ raw MTM measurement X: " << rawMtmMeasurementSet.mtmXnT << " nT" << std::endl; + sif::info << "IMTQ raw MTM measurement Y: " << rawMtmMeasurementSet.mtmYnT << " nT" << std::endl; + sif::info << "IMTQ raw MTM measurement Z: " << rawMtmMeasurementSet.mtmZnT << " nT" << std::endl; + sif::info << "IMTQ coil actuation status during MTM measurement: " + << (unsigned int)rawMtmMeasurementSet.coilActuationStatus.value << std::endl; #endif } void IMTQHandler::handleSelfTestReply(const uint8_t* packet) { - uint16_t offset = 2; - checkErrorByte(*(packet + offset), *(packet + offset + 1)); + uint16_t offset = 2; + checkErrorByte(*(packet + offset), *(packet + offset + 1)); - switch (*(packet + IMTQ::MAIN_STEP_OFFSET)) { + switch (*(packet + IMTQ::MAIN_STEP_OFFSET)) { case IMTQ::SELF_TEST_STEPS::X_POSITIVE: { - handlePositiveXSelfTestReply(packet); - break; + handlePositiveXSelfTestReply(packet); + break; } case IMTQ::SELF_TEST_STEPS::X_NEGATIVE: { - handleNegativeXSelfTestReply(packet); - break; + handleNegativeXSelfTestReply(packet); + break; } case IMTQ::SELF_TEST_STEPS::Y_POSITIVE: { - handlePositiveYSelfTestReply(packet); - break; + handlePositiveYSelfTestReply(packet); + break; } case IMTQ::SELF_TEST_STEPS::Y_NEGATIVE: { - handleNegativeYSelfTestReply(packet); - break; + handleNegativeYSelfTestReply(packet); + break; } case IMTQ::SELF_TEST_STEPS::Z_POSITIVE: { - handlePositiveZSelfTestReply(packet); - break; + handlePositiveZSelfTestReply(packet); + break; } case IMTQ::SELF_TEST_STEPS::Z_NEGATIVE: { - handleNegativeZSelfTestReply(packet); - break; + handleNegativeZSelfTestReply(packet); + break; } default: - break; - } + break; + } } void IMTQHandler::handlePositiveXSelfTestReply(const uint8_t* packet) { - PoolReadGuard rg(&posXselfTestDataset); + PoolReadGuard rg(&posXselfTestDataset); - uint16_t offset = 2; - /** Init measurements */ - posXselfTestDataset.initErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - posXselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.initCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.initCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.initCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posXselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posXselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + uint16_t offset = 2; + /** Init measurements */ + posXselfTestDataset.initErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + posXselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.initCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.initCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.initCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posXselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posXselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** +X measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - posXselfTestDataset.err = *(packet + offset); - offset += 2; // STEP byte will not be stored - posXselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.coilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.coilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.coilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posXselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posXselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** +X measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + posXselfTestDataset.err = *(packet + offset); + offset += 2; // STEP byte will not be stored + posXselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.coilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.coilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.coilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posXselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posXselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** FINA measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - posXselfTestDataset.finaErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - posXselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.finaCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.finaCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.finaCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posXselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posXselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** FINA measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + posXselfTestDataset.finaErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + posXselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.finaCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.finaCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.finaCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posXselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posXselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ self test (INIT) err: " +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ self test (INIT) err: " << static_cast(posXselfTestDataset.initErr.value) << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field X: " << posXselfTestDataset.initRawMagX + sif::info << "IMTQ self test (INIT) raw magnetic field X: " << posXselfTestDataset.initRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << posXselfTestDataset.initRawMagY + sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << posXselfTestDataset.initRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << posXselfTestDataset.initRawMagZ + sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << posXselfTestDataset.initRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " << posXselfTestDataset.initCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " << posXselfTestDataset.initCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " << posXselfTestDataset.initCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) coil X current: " << posXselfTestDataset.initCoilXCurrent + sif::info << "IMTQ self test (INIT) coil X current: " << posXselfTestDataset.initCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y current: " << posXselfTestDataset.initCoilYCurrent + sif::info << "IMTQ self test (INIT) coil Y current: " << posXselfTestDataset.initCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z current: " << posXselfTestDataset.initCoilZCurrent + sif::info << "IMTQ self test (INIT) coil Z current: " << posXselfTestDataset.initCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil X temperature: " + sif::info << "IMTQ self test (INIT) coil X temperature: " << posXselfTestDataset.initCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y temperature: " + sif::info << "IMTQ self test (INIT) coil Y temperature: " << posXselfTestDataset.initCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z temperature: " + sif::info << "IMTQ self test (INIT) coil Z temperature: " << posXselfTestDataset.initCoilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+X) err: " + sif::info << "IMTQ self test (+X) err: " << static_cast(posXselfTestDataset.err.value) << std::endl; - sif::info << "IMTQ self test (+X) raw magnetic field X: " << posXselfTestDataset.rawMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (+X) raw magnetic field Y: " << posXselfTestDataset.rawMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (+X) raw magnetic field Z: " << posXselfTestDataset.rawMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (+X) calibrated magnetic field X: " << posXselfTestDataset.calMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (+X) calibrated magnetic field Y: " << posXselfTestDataset.calMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (+X) calibrated magnetic field Z: " << posXselfTestDataset.calMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (+X) coil X current: " << posXselfTestDataset.coilXCurrent << " mA" + sif::info << "IMTQ self test (+X) raw magnetic field X: " << posXselfTestDataset.rawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (+X) coil Y current: " << posXselfTestDataset.coilYCurrent << " mA" + sif::info << "IMTQ self test (+X) raw magnetic field Y: " << posXselfTestDataset.rawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (+X) coil Z current: " << posXselfTestDataset.coilZCurrent << " mA" + sif::info << "IMTQ self test (+X) raw magnetic field Z: " << posXselfTestDataset.rawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (+X) coil X temperature: " << posXselfTestDataset.coilXTemperature + sif::info << "IMTQ self test (+X) calibrated magnetic field X: " << posXselfTestDataset.calMagX + << " nT" << std::endl; + sif::info << "IMTQ self test (+X) calibrated magnetic field Y: " << posXselfTestDataset.calMagY + << " nT" << std::endl; + sif::info << "IMTQ self test (+X) calibrated magnetic field Z: " << posXselfTestDataset.calMagZ + << " nT" << std::endl; + sif::info << "IMTQ self test (+X) coil X current: " << posXselfTestDataset.coilXCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+X) coil Y current: " << posXselfTestDataset.coilYCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+X) coil Z current: " << posXselfTestDataset.coilZCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+X) coil X temperature: " << posXselfTestDataset.coilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+X) coil Y temperature: " << posXselfTestDataset.coilYTemperature + sif::info << "IMTQ self test (+X) coil Y temperature: " << posXselfTestDataset.coilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+X) coil Z temperature: " << posXselfTestDataset.coilZTemperature + sif::info << "IMTQ self test (+X) coil Z temperature: " << posXselfTestDataset.coilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) err: " + sif::info << "IMTQ self test (FINA) err: " << static_cast(posXselfTestDataset.finaErr.value) << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field X: " << posXselfTestDataset.finaRawMagX + sif::info << "IMTQ self test (FINA) raw magnetic field X: " << posXselfTestDataset.finaRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << posXselfTestDataset.finaRawMagY + sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << posXselfTestDataset.finaRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << posXselfTestDataset.finaRawMagZ + sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << posXselfTestDataset.finaRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " << posXselfTestDataset.finaCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " << posXselfTestDataset.finaCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " << posXselfTestDataset.finaCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) coil X current: " << posXselfTestDataset.finaCoilXCurrent + sif::info << "IMTQ self test (FINA) coil X current: " << posXselfTestDataset.finaCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y current: " << posXselfTestDataset.finaCoilYCurrent + sif::info << "IMTQ self test (FINA) coil Y current: " << posXselfTestDataset.finaCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z current: " << posXselfTestDataset.finaCoilZCurrent + sif::info << "IMTQ self test (FINA) coil Z current: " << posXselfTestDataset.finaCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil X temperature: " + sif::info << "IMTQ self test (FINA) coil X temperature: " << posXselfTestDataset.finaCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y temperature: " + sif::info << "IMTQ self test (FINA) coil Y temperature: " << posXselfTestDataset.finaCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z temperature: " + sif::info << "IMTQ self test (FINA) coil Z temperature: " << posXselfTestDataset.finaCoilZTemperature << " °C" << std::endl; #endif } void IMTQHandler::handleNegativeXSelfTestReply(const uint8_t* packet) { - PoolReadGuard rg(&posXselfTestDataset); + PoolReadGuard rg(&posXselfTestDataset); - uint16_t offset = 2; - /** Init measurements */ - negXselfTestDataset.initErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - negXselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.initCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.initCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.initCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negXselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negXselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + uint16_t offset = 2; + /** Init measurements */ + negXselfTestDataset.initErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + negXselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.initCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.initCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.initCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negXselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negXselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** +X measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - negXselfTestDataset.err = *(packet + offset); - offset += 2; // STEP byte will not be stored - negXselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.coilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.coilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.coilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negXselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negXselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** +X measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + negXselfTestDataset.err = *(packet + offset); + offset += 2; // STEP byte will not be stored + negXselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.coilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.coilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.coilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negXselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negXselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** FINA measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - negXselfTestDataset.finaErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - negXselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.finaCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.finaCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.finaCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negXselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negXselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** FINA measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + negXselfTestDataset.finaErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + negXselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.finaCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.finaCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.finaCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negXselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negXselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ self test (INIT) err: " +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ self test (INIT) err: " << static_cast(negXselfTestDataset.initErr.value) << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field X: " << negXselfTestDataset.initRawMagX + sif::info << "IMTQ self test (INIT) raw magnetic field X: " << negXselfTestDataset.initRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << negXselfTestDataset.initRawMagY + sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << negXselfTestDataset.initRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << negXselfTestDataset.initRawMagZ + sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << negXselfTestDataset.initRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " << negXselfTestDataset.initCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " << negXselfTestDataset.initCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " << negXselfTestDataset.initCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) coil X current: " << negXselfTestDataset.initCoilXCurrent + sif::info << "IMTQ self test (INIT) coil X current: " << negXselfTestDataset.initCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y current: " << negXselfTestDataset.initCoilYCurrent + sif::info << "IMTQ self test (INIT) coil Y current: " << negXselfTestDataset.initCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z current: " << negXselfTestDataset.initCoilZCurrent + sif::info << "IMTQ self test (INIT) coil Z current: " << negXselfTestDataset.initCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil X temperature: " + sif::info << "IMTQ self test (INIT) coil X temperature: " << negXselfTestDataset.initCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y temperature: " + sif::info << "IMTQ self test (INIT) coil Y temperature: " << negXselfTestDataset.initCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z temperature: " + sif::info << "IMTQ self test (INIT) coil Z temperature: " << negXselfTestDataset.initCoilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-X) err: " + sif::info << "IMTQ self test (-X) err: " << static_cast(negXselfTestDataset.err.value) << std::endl; - sif::info << "IMTQ self test (-X) raw magnetic field X: " << negXselfTestDataset.rawMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (-X) raw magnetic field Y: " << negXselfTestDataset.rawMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (-X) raw magnetic field Z: " << negXselfTestDataset.rawMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (-X) calibrated magnetic field X: " << negXselfTestDataset.calMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (-X) calibrated magnetic field Y: " << negXselfTestDataset.calMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (-X) calibrated magnetic field Z: " << negXselfTestDataset.calMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (-X) coil X current: " << negXselfTestDataset.coilXCurrent << " mA" + sif::info << "IMTQ self test (-X) raw magnetic field X: " << negXselfTestDataset.rawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (-X) coil Y current: " << negXselfTestDataset.coilYCurrent << " mA" + sif::info << "IMTQ self test (-X) raw magnetic field Y: " << negXselfTestDataset.rawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (-X) coil Z current: " << negXselfTestDataset.coilZCurrent << " mA" + sif::info << "IMTQ self test (-X) raw magnetic field Z: " << negXselfTestDataset.rawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (-X) coil X temperature: " << negXselfTestDataset.coilXTemperature + sif::info << "IMTQ self test (-X) calibrated magnetic field X: " << negXselfTestDataset.calMagX + << " nT" << std::endl; + sif::info << "IMTQ self test (-X) calibrated magnetic field Y: " << negXselfTestDataset.calMagY + << " nT" << std::endl; + sif::info << "IMTQ self test (-X) calibrated magnetic field Z: " << negXselfTestDataset.calMagZ + << " nT" << std::endl; + sif::info << "IMTQ self test (-X) coil X current: " << negXselfTestDataset.coilXCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-X) coil Y current: " << negXselfTestDataset.coilYCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-X) coil Z current: " << negXselfTestDataset.coilZCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-X) coil X temperature: " << negXselfTestDataset.coilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-X) coil Y temperature: " << negXselfTestDataset.coilYTemperature + sif::info << "IMTQ self test (-X) coil Y temperature: " << negXselfTestDataset.coilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-X) coil Z temperature: " << negXselfTestDataset.coilZTemperature + sif::info << "IMTQ self test (-X) coil Z temperature: " << negXselfTestDataset.coilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) err: " + sif::info << "IMTQ self test (FINA) err: " << static_cast(negXselfTestDataset.finaErr.value) << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field X: " << negXselfTestDataset.finaRawMagX + sif::info << "IMTQ self test (FINA) raw magnetic field X: " << negXselfTestDataset.finaRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << negXselfTestDataset.finaRawMagY + sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << negXselfTestDataset.finaRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << negXselfTestDataset.finaRawMagZ + sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << negXselfTestDataset.finaRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " << negXselfTestDataset.finaCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " << negXselfTestDataset.finaCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " << negXselfTestDataset.finaCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) coil X current: " << negXselfTestDataset.finaCoilXCurrent + sif::info << "IMTQ self test (FINA) coil X current: " << negXselfTestDataset.finaCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y current: " << negXselfTestDataset.finaCoilYCurrent + sif::info << "IMTQ self test (FINA) coil Y current: " << negXselfTestDataset.finaCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z current: " << negXselfTestDataset.finaCoilZCurrent + sif::info << "IMTQ self test (FINA) coil Z current: " << negXselfTestDataset.finaCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil X temperature: " + sif::info << "IMTQ self test (FINA) coil X temperature: " << negXselfTestDataset.finaCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y temperature: " + sif::info << "IMTQ self test (FINA) coil Y temperature: " << negXselfTestDataset.finaCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z temperature: " + sif::info << "IMTQ self test (FINA) coil Z temperature: " << negXselfTestDataset.finaCoilZTemperature << " °C" << std::endl; #endif } void IMTQHandler::handlePositiveYSelfTestReply(const uint8_t* packet) { - PoolReadGuard rg(&posXselfTestDataset); + PoolReadGuard rg(&posXselfTestDataset); - uint16_t offset = 2; - /** Init measurements */ - posYselfTestDataset.initErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - posYselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.initCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.initCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.initCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posYselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posYselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + uint16_t offset = 2; + /** Init measurements */ + posYselfTestDataset.initErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + posYselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.initCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.initCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.initCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posYselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posYselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** +X measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - posYselfTestDataset.err = *(packet + offset); - offset += 2; // STEP byte will not be stored - posYselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.coilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.coilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.coilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posYselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posYselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** +X measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + posYselfTestDataset.err = *(packet + offset); + offset += 2; // STEP byte will not be stored + posYselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.coilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.coilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.coilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posYselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posYselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** FINA measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - posYselfTestDataset.finaErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - posYselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.finaCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.finaCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.finaCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posYselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posYselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** FINA measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + posYselfTestDataset.finaErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + posYselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.finaCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.finaCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.finaCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posYselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posYselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ self test (INIT) err: " +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ self test (INIT) err: " << static_cast(posYselfTestDataset.initErr.value) << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field X: " << posYselfTestDataset.initRawMagX + sif::info << "IMTQ self test (INIT) raw magnetic field X: " << posYselfTestDataset.initRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << posYselfTestDataset.initRawMagY + sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << posYselfTestDataset.initRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << posYselfTestDataset.initRawMagZ + sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << posYselfTestDataset.initRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " << posYselfTestDataset.initCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " << posYselfTestDataset.initCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " << posYselfTestDataset.initCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) coil X current: " << posYselfTestDataset.initCoilXCurrent + sif::info << "IMTQ self test (INIT) coil X current: " << posYselfTestDataset.initCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y current: " << posYselfTestDataset.initCoilYCurrent + sif::info << "IMTQ self test (INIT) coil Y current: " << posYselfTestDataset.initCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z current: " << posYselfTestDataset.initCoilZCurrent + sif::info << "IMTQ self test (INIT) coil Z current: " << posYselfTestDataset.initCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil X temperature: " + sif::info << "IMTQ self test (INIT) coil X temperature: " << posYselfTestDataset.initCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y temperature: " + sif::info << "IMTQ self test (INIT) coil Y temperature: " << posYselfTestDataset.initCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z temperature: " + sif::info << "IMTQ self test (INIT) coil Z temperature: " << posYselfTestDataset.initCoilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+Y) err: " + sif::info << "IMTQ self test (+Y) err: " << static_cast(posYselfTestDataset.err.value) << std::endl; - sif::info << "IMTQ self test (+Y) raw magnetic field X: " << posYselfTestDataset.rawMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) raw magnetic field Y: " << posYselfTestDataset.rawMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) raw magnetic field Z: " << posYselfTestDataset.rawMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) calibrated magnetic field X: " << posYselfTestDataset.calMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) calibrated magnetic field Y: " << posYselfTestDataset.calMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) calibrated magnetic field Z: " << posYselfTestDataset.calMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) coil X current: " << posYselfTestDataset.coilXCurrent << " mA" + sif::info << "IMTQ self test (+Y) raw magnetic field X: " << posYselfTestDataset.rawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) coil Y current: " << posYselfTestDataset.coilYCurrent << " mA" + sif::info << "IMTQ self test (+Y) raw magnetic field Y: " << posYselfTestDataset.rawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) coil Z current: " << posYselfTestDataset.coilZCurrent << " mA" + sif::info << "IMTQ self test (+Y) raw magnetic field Z: " << posYselfTestDataset.rawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) coil X temperature: " << posYselfTestDataset.coilXTemperature + sif::info << "IMTQ self test (+Y) calibrated magnetic field X: " << posYselfTestDataset.calMagX + << " nT" << std::endl; + sif::info << "IMTQ self test (+Y) calibrated magnetic field Y: " << posYselfTestDataset.calMagY + << " nT" << std::endl; + sif::info << "IMTQ self test (+Y) calibrated magnetic field Z: " << posYselfTestDataset.calMagZ + << " nT" << std::endl; + sif::info << "IMTQ self test (+Y) coil X current: " << posYselfTestDataset.coilXCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+Y) coil Y current: " << posYselfTestDataset.coilYCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+Y) coil Z current: " << posYselfTestDataset.coilZCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+Y) coil X temperature: " << posYselfTestDataset.coilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+Y) coil Y temperature: " << posYselfTestDataset.coilYTemperature + sif::info << "IMTQ self test (+Y) coil Y temperature: " << posYselfTestDataset.coilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+Y) coil Z temperature: " << posYselfTestDataset.coilZTemperature + sif::info << "IMTQ self test (+Y) coil Z temperature: " << posYselfTestDataset.coilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) err: " + sif::info << "IMTQ self test (FINA) err: " << static_cast(posYselfTestDataset.finaErr.value) << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field X: " << posYselfTestDataset.finaRawMagX + sif::info << "IMTQ self test (FINA) raw magnetic field X: " << posYselfTestDataset.finaRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << posYselfTestDataset.finaRawMagY + sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << posYselfTestDataset.finaRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << posYselfTestDataset.finaRawMagZ + sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << posYselfTestDataset.finaRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " << posYselfTestDataset.finaCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " << posYselfTestDataset.finaCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " << posYselfTestDataset.finaCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) coil X current: " << posYselfTestDataset.finaCoilXCurrent + sif::info << "IMTQ self test (FINA) coil X current: " << posYselfTestDataset.finaCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y current: " << posYselfTestDataset.finaCoilYCurrent + sif::info << "IMTQ self test (FINA) coil Y current: " << posYselfTestDataset.finaCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z current: " << posYselfTestDataset.finaCoilZCurrent + sif::info << "IMTQ self test (FINA) coil Z current: " << posYselfTestDataset.finaCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil X temperature: " + sif::info << "IMTQ self test (FINA) coil X temperature: " << posYselfTestDataset.finaCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y temperature: " + sif::info << "IMTQ self test (FINA) coil Y temperature: " << posYselfTestDataset.finaCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z temperature: " + sif::info << "IMTQ self test (FINA) coil Z temperature: " << posYselfTestDataset.finaCoilZTemperature << " °C" << std::endl; #endif } void IMTQHandler::handleNegativeYSelfTestReply(const uint8_t* packet) { - PoolReadGuard rg(&posXselfTestDataset); + PoolReadGuard rg(&posXselfTestDataset); - uint16_t offset = 2; - /** Init measurements */ - posZselfTestDataset.initErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - negYselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.initCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.initCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.initCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negYselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negYselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + uint16_t offset = 2; + /** Init measurements */ + posZselfTestDataset.initErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + negYselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.initCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.initCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.initCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negYselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negYselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** +X measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - negYselfTestDataset.err = *(packet + offset); - offset += 2; // STEP byte will not be stored - negYselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.coilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.coilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.coilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negYselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negYselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** +X measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + negYselfTestDataset.err = *(packet + offset); + offset += 2; // STEP byte will not be stored + negYselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.coilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.coilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.coilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negYselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negYselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** FINA measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - negYselfTestDataset.finaErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - negYselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.finaCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.finaCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.finaCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negYselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negYselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** FINA measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + negYselfTestDataset.finaErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + negYselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.finaCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.finaCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.finaCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negYselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negYselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ self test (INIT) err: " +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ self test (INIT) err: " << static_cast(negYselfTestDataset.initErr.value) << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field X: " << negYselfTestDataset.initRawMagX + sif::info << "IMTQ self test (INIT) raw magnetic field X: " << negYselfTestDataset.initRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << negYselfTestDataset.initRawMagY + sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << negYselfTestDataset.initRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << negYselfTestDataset.initRawMagZ + sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << negYselfTestDataset.initRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " << negYselfTestDataset.initCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " << negYselfTestDataset.initCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " << negYselfTestDataset.initCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) coil X current: " << negYselfTestDataset.initCoilXCurrent + sif::info << "IMTQ self test (INIT) coil X current: " << negYselfTestDataset.initCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y current: " << negYselfTestDataset.initCoilYCurrent + sif::info << "IMTQ self test (INIT) coil Y current: " << negYselfTestDataset.initCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z current: " << negYselfTestDataset.initCoilZCurrent + sif::info << "IMTQ self test (INIT) coil Z current: " << negYselfTestDataset.initCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil X temperature: " + sif::info << "IMTQ self test (INIT) coil X temperature: " << negYselfTestDataset.initCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y temperature: " + sif::info << "IMTQ self test (INIT) coil Y temperature: " << negYselfTestDataset.initCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z temperature: " + sif::info << "IMTQ self test (INIT) coil Z temperature: " << negYselfTestDataset.initCoilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-Y) err: " + sif::info << "IMTQ self test (-Y) err: " << static_cast(negYselfTestDataset.err.value) << std::endl; - sif::info << "IMTQ self test (-Y) raw magnetic field X: " << negYselfTestDataset.rawMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) raw magnetic field Y: " << negYselfTestDataset.rawMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) raw magnetic field Z: " << negYselfTestDataset.rawMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) calibrated magnetic field X: " << negYselfTestDataset.calMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) calibrated magnetic field Y: " << negYselfTestDataset.calMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) calibrated magnetic field Z: " << negYselfTestDataset.calMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) coil X current: " << negYselfTestDataset.coilXCurrent << " mA" + sif::info << "IMTQ self test (-Y) raw magnetic field X: " << negYselfTestDataset.rawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) coil Y current: " << negYselfTestDataset.coilYCurrent << " mA" + sif::info << "IMTQ self test (-Y) raw magnetic field Y: " << negYselfTestDataset.rawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) coil Z current: " << negYselfTestDataset.coilZCurrent << " mA" + sif::info << "IMTQ self test (-Y) raw magnetic field Z: " << negYselfTestDataset.rawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) coil X temperature: " << negYselfTestDataset.coilXTemperature + sif::info << "IMTQ self test (-Y) calibrated magnetic field X: " << negYselfTestDataset.calMagX + << " nT" << std::endl; + sif::info << "IMTQ self test (-Y) calibrated magnetic field Y: " << negYselfTestDataset.calMagY + << " nT" << std::endl; + sif::info << "IMTQ self test (-Y) calibrated magnetic field Z: " << negYselfTestDataset.calMagZ + << " nT" << std::endl; + sif::info << "IMTQ self test (-Y) coil X current: " << negYselfTestDataset.coilXCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-Y) coil Y current: " << negYselfTestDataset.coilYCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-Y) coil Z current: " << negYselfTestDataset.coilZCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-Y) coil X temperature: " << negYselfTestDataset.coilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-Y) coil Y temperature: " << negYselfTestDataset.coilYTemperature + sif::info << "IMTQ self test (-Y) coil Y temperature: " << negYselfTestDataset.coilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-Y) coil Z temperature: " << negYselfTestDataset.coilZTemperature + sif::info << "IMTQ self test (-Y) coil Z temperature: " << negYselfTestDataset.coilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) err: " + sif::info << "IMTQ self test (FINA) err: " << static_cast(negYselfTestDataset.finaErr.value) << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field X: " << negYselfTestDataset.finaRawMagX + sif::info << "IMTQ self test (FINA) raw magnetic field X: " << negYselfTestDataset.finaRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << negYselfTestDataset.finaRawMagY + sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << negYselfTestDataset.finaRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << negYselfTestDataset.finaRawMagZ + sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << negYselfTestDataset.finaRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " << negYselfTestDataset.finaCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " << negYselfTestDataset.finaCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " << negYselfTestDataset.finaCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) coil X current: " << negYselfTestDataset.finaCoilXCurrent + sif::info << "IMTQ self test (FINA) coil X current: " << negYselfTestDataset.finaCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y current: " << negYselfTestDataset.finaCoilYCurrent + sif::info << "IMTQ self test (FINA) coil Y current: " << negYselfTestDataset.finaCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z current: " << negYselfTestDataset.finaCoilZCurrent + sif::info << "IMTQ self test (FINA) coil Z current: " << negYselfTestDataset.finaCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil X temperature: " + sif::info << "IMTQ self test (FINA) coil X temperature: " << negYselfTestDataset.finaCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y temperature: " + sif::info << "IMTQ self test (FINA) coil Y temperature: " << negYselfTestDataset.finaCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z temperature: " + sif::info << "IMTQ self test (FINA) coil Z temperature: " << negYselfTestDataset.finaCoilZTemperature << " °C" << std::endl; #endif } void IMTQHandler::handlePositiveZSelfTestReply(const uint8_t* packet) { - PoolReadGuard rg(&posXselfTestDataset); + PoolReadGuard rg(&posXselfTestDataset); - uint16_t offset = 2; - /** Init measurements */ - posZselfTestDataset.initErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - posZselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.initCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.initCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.initCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posZselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posZselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + uint16_t offset = 2; + /** Init measurements */ + posZselfTestDataset.initErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + posZselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.initCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.initCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.initCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posZselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posZselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** +X measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - posZselfTestDataset.err = *(packet + offset); - offset += 2; // STEP byte will not be stored - posZselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.coilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.coilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.coilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posZselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posZselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** +X measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + posZselfTestDataset.err = *(packet + offset); + offset += 2; // STEP byte will not be stored + posZselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.coilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.coilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.coilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posZselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posZselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** FINA measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - posZselfTestDataset.finaErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - posZselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.finaCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.finaCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.finaCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posZselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posZselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** FINA measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + posZselfTestDataset.finaErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + posZselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.finaCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.finaCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.finaCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posZselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posZselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ self test (INIT) err: " +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ self test (INIT) err: " << static_cast(posZselfTestDataset.initErr.value) << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field X: " << posZselfTestDataset.initRawMagX + sif::info << "IMTQ self test (INIT) raw magnetic field X: " << posZselfTestDataset.initRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << posZselfTestDataset.initRawMagY + sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << posZselfTestDataset.initRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << posZselfTestDataset.initRawMagZ + sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << posZselfTestDataset.initRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " << posZselfTestDataset.initCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " << posZselfTestDataset.initCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " << posZselfTestDataset.initCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) coil X current: " << posZselfTestDataset.initCoilXCurrent + sif::info << "IMTQ self test (INIT) coil X current: " << posZselfTestDataset.initCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y current: " << posZselfTestDataset.initCoilYCurrent + sif::info << "IMTQ self test (INIT) coil Y current: " << posZselfTestDataset.initCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z current: " << posZselfTestDataset.initCoilZCurrent + sif::info << "IMTQ self test (INIT) coil Z current: " << posZselfTestDataset.initCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil X temperature: " + sif::info << "IMTQ self test (INIT) coil X temperature: " << posZselfTestDataset.initCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y temperature: " + sif::info << "IMTQ self test (INIT) coil Y temperature: " << posZselfTestDataset.initCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z temperature: " + sif::info << "IMTQ self test (INIT) coil Z temperature: " << posZselfTestDataset.initCoilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+Z) err: " + sif::info << "IMTQ self test (+Z) err: " << static_cast(posZselfTestDataset.err.value) << std::endl; - sif::info << "IMTQ self test (+Z) raw magnetic field X: " << posZselfTestDataset.rawMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) raw magnetic field Y: " << posZselfTestDataset.rawMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) raw magnetic field Z: " << posZselfTestDataset.rawMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) calibrated magnetic field X: " << posZselfTestDataset.calMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) calibrated magnetic field Y: " << posZselfTestDataset.calMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) calibrated magnetic field Z: " << posZselfTestDataset.calMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) coil X current: " << posZselfTestDataset.coilXCurrent << " mA" + sif::info << "IMTQ self test (+Z) raw magnetic field X: " << posZselfTestDataset.rawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) coil Y current: " << posZselfTestDataset.coilYCurrent << " mA" + sif::info << "IMTQ self test (+Z) raw magnetic field Y: " << posZselfTestDataset.rawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) coil Z current: " << posZselfTestDataset.coilZCurrent << " mA" + sif::info << "IMTQ self test (+Z) raw magnetic field Z: " << posZselfTestDataset.rawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) coil X temperature: " << posZselfTestDataset.coilXTemperature + sif::info << "IMTQ self test (+Z) calibrated magnetic field X: " << posZselfTestDataset.calMagX + << " nT" << std::endl; + sif::info << "IMTQ self test (+Z) calibrated magnetic field Y: " << posZselfTestDataset.calMagY + << " nT" << std::endl; + sif::info << "IMTQ self test (+Z) calibrated magnetic field Z: " << posZselfTestDataset.calMagZ + << " nT" << std::endl; + sif::info << "IMTQ self test (+Z) coil X current: " << posZselfTestDataset.coilXCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+Z) coil Y current: " << posZselfTestDataset.coilYCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+Z) coil Z current: " << posZselfTestDataset.coilZCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+Z) coil X temperature: " << posZselfTestDataset.coilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+Z) coil Y temperature: " << posZselfTestDataset.coilYTemperature + sif::info << "IMTQ self test (+Z) coil Y temperature: " << posZselfTestDataset.coilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+Z) coil Z temperature: " << negYselfTestDataset.coilZTemperature + sif::info << "IMTQ self test (+Z) coil Z temperature: " << negYselfTestDataset.coilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) err: " + sif::info << "IMTQ self test (FINA) err: " << static_cast(posZselfTestDataset.finaErr.value) << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field X: " << posZselfTestDataset.finaRawMagX + sif::info << "IMTQ self test (FINA) raw magnetic field X: " << posZselfTestDataset.finaRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << posZselfTestDataset.finaRawMagY + sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << posZselfTestDataset.finaRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << posZselfTestDataset.finaRawMagZ + sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << posZselfTestDataset.finaRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " << posZselfTestDataset.finaCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " << posZselfTestDataset.finaCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " << posZselfTestDataset.finaCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) coil X current: " << posZselfTestDataset.finaCoilXCurrent + sif::info << "IMTQ self test (FINA) coil X current: " << posZselfTestDataset.finaCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y current: " << posZselfTestDataset.finaCoilYCurrent + sif::info << "IMTQ self test (FINA) coil Y current: " << posZselfTestDataset.finaCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z current: " << posZselfTestDataset.finaCoilZCurrent + sif::info << "IMTQ self test (FINA) coil Z current: " << posZselfTestDataset.finaCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil X temperature: " + sif::info << "IMTQ self test (FINA) coil X temperature: " << posZselfTestDataset.finaCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y temperature: " + sif::info << "IMTQ self test (FINA) coil Y temperature: " << posZselfTestDataset.finaCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z temperature: " + sif::info << "IMTQ self test (FINA) coil Z temperature: " << posZselfTestDataset.finaCoilZTemperature << " °C" << std::endl; #endif } void IMTQHandler::handleNegativeZSelfTestReply(const uint8_t* packet) { - PoolReadGuard rg(&posXselfTestDataset); + PoolReadGuard rg(&posXselfTestDataset); - uint16_t offset = 2; - /** Init measurements */ - negZselfTestDataset.initErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - negZselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.initCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.initCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.initCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negZselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negZselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + uint16_t offset = 2; + /** Init measurements */ + negZselfTestDataset.initErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + negZselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.initCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.initCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.initCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negZselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negZselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** +X measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - negZselfTestDataset.err = *(packet + offset); - offset += 2; // STEP byte will not be stored - negZselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.coilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.coilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.coilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negZselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negZselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** +X measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + negZselfTestDataset.err = *(packet + offset); + offset += 2; // STEP byte will not be stored + negZselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.coilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.coilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.coilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negZselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negZselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** FINA measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - negZselfTestDataset.finaErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - negZselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.finaCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.finaCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.finaCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negZselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negZselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** FINA measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + negZselfTestDataset.finaErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + negZselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.finaCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.finaCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.finaCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negZselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negZselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ self test (INIT) err: " +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ self test (INIT) err: " << static_cast(negZselfTestDataset.initErr.value) << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field X: " << negZselfTestDataset.initRawMagX + sif::info << "IMTQ self test (INIT) raw magnetic field X: " << negZselfTestDataset.initRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << negZselfTestDataset.initRawMagY + sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << negZselfTestDataset.initRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << negZselfTestDataset.initRawMagZ + sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << negZselfTestDataset.initRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " << negZselfTestDataset.initCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " << negZselfTestDataset.initCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " << negZselfTestDataset.initCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) coil X current: " << negZselfTestDataset.initCoilXCurrent + sif::info << "IMTQ self test (INIT) coil X current: " << negZselfTestDataset.initCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y current: " << negZselfTestDataset.initCoilYCurrent + sif::info << "IMTQ self test (INIT) coil Y current: " << negZselfTestDataset.initCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z current: " << negZselfTestDataset.initCoilZCurrent + sif::info << "IMTQ self test (INIT) coil Z current: " << negZselfTestDataset.initCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil X temperature: " + sif::info << "IMTQ self test (INIT) coil X temperature: " << negZselfTestDataset.initCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y temperature: " + sif::info << "IMTQ self test (INIT) coil Y temperature: " << negZselfTestDataset.initCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z temperature: " + sif::info << "IMTQ self test (INIT) coil Z temperature: " << negZselfTestDataset.initCoilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-Z) err: " + sif::info << "IMTQ self test (-Z) err: " << static_cast(negZselfTestDataset.err.value) << std::endl; - sif::info << "IMTQ self test (-Z) raw magnetic field X: " << negZselfTestDataset.rawMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) raw magnetic field Y: " << negZselfTestDataset.rawMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) raw magnetic field Z: " << negZselfTestDataset.rawMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) calibrated magnetic field X: " << negZselfTestDataset.calMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) calibrated magnetic field Y: " << negZselfTestDataset.calMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) calibrated magnetic field Z: " << negZselfTestDataset.calMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) coil X current: " << negZselfTestDataset.coilXCurrent << " mA" + sif::info << "IMTQ self test (-Z) raw magnetic field X: " << negZselfTestDataset.rawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) coil Y current: " << negZselfTestDataset.coilYCurrent << " mA" + sif::info << "IMTQ self test (-Z) raw magnetic field Y: " << negZselfTestDataset.rawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) coil Z current: " << negZselfTestDataset.coilZCurrent << " mA" + sif::info << "IMTQ self test (-Z) raw magnetic field Z: " << negZselfTestDataset.rawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) coil X temperature: " << negZselfTestDataset.coilXTemperature + sif::info << "IMTQ self test (-Z) calibrated magnetic field X: " << negZselfTestDataset.calMagX + << " nT" << std::endl; + sif::info << "IMTQ self test (-Z) calibrated magnetic field Y: " << negZselfTestDataset.calMagY + << " nT" << std::endl; + sif::info << "IMTQ self test (-Z) calibrated magnetic field Z: " << negZselfTestDataset.calMagZ + << " nT" << std::endl; + sif::info << "IMTQ self test (-Z) coil X current: " << negZselfTestDataset.coilXCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-Z) coil Y current: " << negZselfTestDataset.coilYCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-Z) coil Z current: " << negZselfTestDataset.coilZCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-Z) coil X temperature: " << negZselfTestDataset.coilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-Z) coil Y temperature: " << negZselfTestDataset.coilYTemperature + sif::info << "IMTQ self test (-Z) coil Y temperature: " << negZselfTestDataset.coilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-Z) coil Z temperature: " << negYselfTestDataset.coilZTemperature + sif::info << "IMTQ self test (-Z) coil Z temperature: " << negYselfTestDataset.coilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) err: " + sif::info << "IMTQ self test (FINA) err: " << static_cast(negZselfTestDataset.finaErr.value) << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field X: " << negZselfTestDataset.finaRawMagX + sif::info << "IMTQ self test (FINA) raw magnetic field X: " << negZselfTestDataset.finaRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << negZselfTestDataset.finaRawMagY + sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << negZselfTestDataset.finaRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << negZselfTestDataset.finaRawMagZ + sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << negZselfTestDataset.finaRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " << negZselfTestDataset.finaCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " << negZselfTestDataset.finaCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " << negZselfTestDataset.finaCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) coil X current: " << negZselfTestDataset.finaCoilXCurrent + sif::info << "IMTQ self test (FINA) coil X current: " << negZselfTestDataset.finaCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y current: " << negZselfTestDataset.finaCoilYCurrent + sif::info << "IMTQ self test (FINA) coil Y current: " << negZselfTestDataset.finaCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z current: " << negZselfTestDataset.finaCoilZCurrent + sif::info << "IMTQ self test (FINA) coil Z current: " << negZselfTestDataset.finaCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil X temperature: " + sif::info << "IMTQ self test (FINA) coil X temperature: " << negZselfTestDataset.finaCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y temperature: " + sif::info << "IMTQ self test (FINA) coil Y temperature: " << negZselfTestDataset.finaCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z temperature: " + sif::info << "IMTQ self test (FINA) coil Z temperature: " << negZselfTestDataset.finaCoilZTemperature << " °C" << std::endl; #endif } void IMTQHandler::checkErrorByte(const uint8_t errorByte, const uint8_t step) { - std::string stepString(""); - if (step < 8) { - stepString = makeStepString(step); - } else { - /** This should normally never happen */ - sif::debug << "IMTQHandler::checkErrorByte: Invalid step" << std::endl; - return; - } + std::string stepString(""); + if (step < 8) { + stepString = makeStepString(step); + } else { + /** This should normally never happen */ + sif::debug << "IMTQHandler::checkErrorByte: Invalid step" << std::endl; + return; + } - if (errorByte == 0) { - return; - } + if (errorByte == 0) { + return; + } - if (errorByte & IMTQ::I2C_FAILURE_MASK) { - triggerEvent(SELF_TEST_I2C_FAILURE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test I2C failure for step " << stepString - << std::endl; - } - if (errorByte & IMTQ::SPI_FAILURE_MASK) { - triggerEvent(SELF_TEST_SPI_FAILURE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test SPI failure for step " << stepString - << std::endl; - } - if (errorByte & IMTQ::ADC_FAILURE_MASK) { - triggerEvent(SELF_TEST_ADC_FAILURE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test ADC failure for step " << stepString - << std::endl; - } - if (errorByte & IMTQ::PWM_FAILURE_MASK) { - triggerEvent(SELF_TEST_PWM_FAILURE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test PWM failure for step " << stepString - << std::endl; - } - if (errorByte & IMTQ::TC_FAILURE_MASK) { - triggerEvent(SELF_TEST_TC_FAILURE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test TC failure (system failure) for step " - << stepString << std::endl; - } - if (errorByte & IMTQ::MTM_RANGE_FAILURE_MASK) { - triggerEvent(SELF_TEST_TC_FAILURE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test MTM range failure for step " - << stepString << std::endl; - } - if (errorByte & IMTQ::COIL_CURRENT_FAILURE_MASK) { - triggerEvent(SELF_TEST_COIL_CURRENT_FAILURE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test coil current outside of expected " - "range for step " << stepString << std::endl; - } + if (errorByte & IMTQ::I2C_FAILURE_MASK) { + triggerEvent(SELF_TEST_I2C_FAILURE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test I2C failure for step " << stepString + << std::endl; + } + if (errorByte & IMTQ::SPI_FAILURE_MASK) { + triggerEvent(SELF_TEST_SPI_FAILURE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test SPI failure for step " << stepString + << std::endl; + } + if (errorByte & IMTQ::ADC_FAILURE_MASK) { + triggerEvent(SELF_TEST_ADC_FAILURE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test ADC failure for step " << stepString + << std::endl; + } + if (errorByte & IMTQ::PWM_FAILURE_MASK) { + triggerEvent(SELF_TEST_PWM_FAILURE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test PWM failure for step " << stepString + << std::endl; + } + if (errorByte & IMTQ::TC_FAILURE_MASK) { + triggerEvent(SELF_TEST_TC_FAILURE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test TC failure (system failure) for step " + << stepString << std::endl; + } + if (errorByte & IMTQ::MTM_RANGE_FAILURE_MASK) { + triggerEvent(SELF_TEST_TC_FAILURE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test MTM range failure for step " << stepString + << std::endl; + } + if (errorByte & IMTQ::COIL_CURRENT_FAILURE_MASK) { + triggerEvent(SELF_TEST_COIL_CURRENT_FAILURE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test coil current outside of expected " + "range for step " + << stepString << std::endl; + } - if (errorByte & IMTQ::INVALID_ERROR_BYTE) { - triggerEvent(INVALID_ERROR_BYTE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test result of step " << stepString - << " has invalid error byte" << std::endl; - } + if (errorByte & IMTQ::INVALID_ERROR_BYTE) { + triggerEvent(INVALID_ERROR_BYTE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test result of step " << stepString + << " has invalid error byte" << std::endl; + } } std::string IMTQHandler::makeStepString(const uint8_t step) { - std::string stepString(""); - switch (step) { + std::string stepString(""); + switch (step) { case IMTQ::SELF_TEST_STEPS::INIT: - stepString = std::string("INIT"); - break; + stepString = std::string("INIT"); + break; case IMTQ::SELF_TEST_STEPS::X_POSITIVE: - stepString = std::string("+X"); - break; + stepString = std::string("+X"); + break; case IMTQ::SELF_TEST_STEPS::X_NEGATIVE: - stepString = std::string("-X"); - break; + stepString = std::string("-X"); + break; case IMTQ::SELF_TEST_STEPS::Y_POSITIVE: - stepString = std::string("+Y"); - break; + stepString = std::string("+Y"); + break; case IMTQ::SELF_TEST_STEPS::Y_NEGATIVE: - stepString = std::string("-Y"); - break; + stepString = std::string("-Y"); + break; case IMTQ::SELF_TEST_STEPS::Z_POSITIVE: - stepString = std::string("+Z"); - break; + stepString = std::string("+Z"); + break; case IMTQ::SELF_TEST_STEPS::Z_NEGATIVE: - stepString = std::string("-Z"); - break; + stepString = std::string("-Z"); + break; case IMTQ::SELF_TEST_STEPS::FINA: - stepString = std::string("FINA"); - break; + stepString = std::string("FINA"); + break; default: - sif::error << "IMTQHandler::checkErrorByte: Received packet with invalid step information" - << std::endl; - break; - } - return stepString; + sif::error << "IMTQHandler::checkErrorByte: Received packet with invalid step information" + << std::endl; + break; + } + return stepString; } - diff --git a/mission/devices/IMTQHandler.h b/mission/devices/IMTQHandler.h index ce9e45e0..b12cdf97 100644 --- a/mission/devices/IMTQHandler.h +++ b/mission/devices/IMTQHandler.h @@ -10,186 +10,188 @@ * * @author J. Meier */ -class IMTQHandler: public DeviceHandlerBase { -public: +class IMTQHandler : public DeviceHandlerBase { + public: + IMTQHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + virtual ~IMTQHandler(); - IMTQHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); - virtual ~IMTQHandler(); + /** + * @brief Sets mode to MODE_NORMAL. Can be used for debugging. + */ + void setModeNormal(); - /** - * @brief Sets mode to MODE_NORMAL. Can be used for debugging. - */ - void setModeNormal(); + 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; + virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) 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; - virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::IMTQ_HANDLER; -private: + static const ReturnValue_t INVALID_COMMAND_CODE = MAKE_RETURN_CODE(0xA0); + static const ReturnValue_t PARAMETER_MISSING = MAKE_RETURN_CODE(0xA1); + static const ReturnValue_t PARAMETER_INVALID = MAKE_RETURN_CODE(0xA2); + static const ReturnValue_t CC_UNAVAILABLE = MAKE_RETURN_CODE(0xA3); + static const ReturnValue_t INTERNAL_PROCESSING_ERROR = MAKE_RETURN_CODE(0xA4); + static const ReturnValue_t REJECTED_WITHOUT_REASON = MAKE_RETURN_CODE(0xA5); + static const ReturnValue_t CMD_ERR_UNKNOWN = MAKE_RETURN_CODE(0xA6); + //! [EXPORT] : [COMMENT] The status reply to a self test command was received but no self test + //! command has been sent. This should normally never happen. + static const ReturnValue_t UNEXPECTED_SELF_TEST_REPLY = MAKE_RETURN_CODE(0xA7); - static const uint8_t INTERFACE_ID = CLASS_ID::IMTQ_HANDLER; + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::IMTQ_HANDLER; - static const ReturnValue_t INVALID_COMMAND_CODE = MAKE_RETURN_CODE(0xA0); - static const ReturnValue_t PARAMETER_MISSING = MAKE_RETURN_CODE(0xA1); - static const ReturnValue_t PARAMETER_INVALID = MAKE_RETURN_CODE(0xA2); - static const ReturnValue_t CC_UNAVAILABLE = MAKE_RETURN_CODE(0xA3); - static const ReturnValue_t INTERNAL_PROCESSING_ERROR = MAKE_RETURN_CODE(0xA4); - static const ReturnValue_t REJECTED_WITHOUT_REASON = MAKE_RETURN_CODE(0xA5); - static const ReturnValue_t CMD_ERR_UNKNOWN = MAKE_RETURN_CODE(0xA6); - //! [EXPORT] : [COMMENT] The status reply to a self test command was received but no self test command has been sent. This should normally never happen. - static const ReturnValue_t UNEXPECTED_SELF_TEST_REPLY = MAKE_RETURN_CODE(0xA7); + //! [EXPORT] : [COMMENT] Get self test result returns I2C failure + //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> + //! -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA + static const Event SELF_TEST_I2C_FAILURE = MAKE_EVENT(1, severity::LOW); + //! [EXPORT] : [COMMENT] Get self test result returns SPI failure. This concerns the MTM + //! connectivity. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 + //! -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA + static const Event SELF_TEST_SPI_FAILURE = MAKE_EVENT(2, severity::LOW); + //! [EXPORT] : [COMMENT] Get self test result returns failure in measurement of current and + //! temperature. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 + //! -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA + static const Event SELF_TEST_ADC_FAILURE = MAKE_EVENT(3, severity::LOW); + //! [EXPORT] : [COMMENT] Get self test result returns PWM failure which concerns the coil + //! actuation. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> + //! +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA + static const Event SELF_TEST_PWM_FAILURE = MAKE_EVENT(4, severity::LOW); + //! [EXPORT] : [COMMENT] Get self test result returns TC failure (system failure) + //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> + //! -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA + static const Event SELF_TEST_TC_FAILURE = MAKE_EVENT(5, severity::LOW); + //! [EXPORT] : [COMMENT] Get self test result returns failure that MTM values were outside of the + //! expected range. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, + //! 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA + static const Event SELF_TEST_MTM_RANGE_FAILURE = MAKE_EVENT(6, severity::LOW); + //! [EXPORT] : [COMMENT] Get self test result returns failure indicating that the coil current was + //! outside of the expected range P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 + //! -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA + static const Event SELF_TEST_COIL_CURRENT_FAILURE = MAKE_EVENT(7, severity::LOW); + //! [EXPORT] : [COMMENT] Received invalid error byte. This indicates an error of the communication + //! link between IMTQ and OBC. + static const Event INVALID_ERROR_BYTE = MAKE_EVENT(8, severity::LOW); - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::IMTQ_HANDLER; + IMTQ::EngHkDataset engHkDataset; + IMTQ::CalibratedMtmMeasurementSet calMtmMeasurementSet; + IMTQ::RawMtmMeasurementSet rawMtmMeasurementSet; + IMTQ::PosXSelfTestSet posXselfTestDataset; + IMTQ::NegXSelfTestSet negXselfTestDataset; + IMTQ::PosYSelfTestSet posYselfTestDataset; + IMTQ::NegYSelfTestSet negYselfTestDataset; + IMTQ::PosZSelfTestSet posZselfTestDataset; + IMTQ::NegZSelfTestSet negZselfTestDataset; - //! [EXPORT] : [COMMENT] Get self test result returns I2C failure - //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA - static const Event SELF_TEST_I2C_FAILURE = MAKE_EVENT(1, severity::LOW); - //! [EXPORT] : [COMMENT] Get self test result returns SPI failure. This concerns the MTM connectivity. - //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA - static const Event SELF_TEST_SPI_FAILURE = MAKE_EVENT(2, severity::LOW); - //! [EXPORT] : [COMMENT] Get self test result returns failure in measurement of current and temperature. - //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA - static const Event SELF_TEST_ADC_FAILURE = MAKE_EVENT(3, severity::LOW); - //! [EXPORT] : [COMMENT] Get self test result returns PWM failure which concerns the coil actuation. - //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA - static const Event SELF_TEST_PWM_FAILURE = MAKE_EVENT(4, severity::LOW); - //! [EXPORT] : [COMMENT] Get self test result returns TC failure (system failure) - //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA - static const Event SELF_TEST_TC_FAILURE = MAKE_EVENT(5, severity::LOW); - //! [EXPORT] : [COMMENT] Get self test result returns failure that MTM values were outside of the expected range. - //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA - static const Event SELF_TEST_MTM_RANGE_FAILURE = MAKE_EVENT(6, severity::LOW); - //! [EXPORT] : [COMMENT] Get self test result returns failure indicating that the coil current was outside of the expected range - //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA - static const Event SELF_TEST_COIL_CURRENT_FAILURE = MAKE_EVENT(7, severity::LOW); - //! [EXPORT] : [COMMENT] Received invalid error byte. This indicates an error of the communication link between IMTQ and OBC. - static const Event INVALID_ERROR_BYTE = MAKE_EVENT(8, severity::LOW); + uint8_t commandBuffer[IMTQ::MAX_COMMAND_SIZE]; - IMTQ::EngHkDataset engHkDataset; - IMTQ::CalibratedMtmMeasurementSet calMtmMeasurementSet; - IMTQ::RawMtmMeasurementSet rawMtmMeasurementSet; - IMTQ::PosXSelfTestSet posXselfTestDataset; - IMTQ::NegXSelfTestSet negXselfTestDataset; - IMTQ::PosYSelfTestSet posYselfTestDataset; - IMTQ::NegYSelfTestSet negYselfTestDataset; - IMTQ::PosZSelfTestSet posZselfTestDataset; - IMTQ::NegZSelfTestSet negZselfTestDataset; + enum class CommunicationStep { + GET_ENG_HK_DATA, + START_MTM_MEASUREMENT, + GET_CAL_MTM_MEASUREMENT, + GET_RAW_MTM_MEASUREMENT + }; - uint8_t commandBuffer[IMTQ::MAX_COMMAND_SIZE]; + CommunicationStep communicationStep = CommunicationStep::GET_ENG_HK_DATA; - enum class CommunicationStep { - GET_ENG_HK_DATA, - START_MTM_MEASUREMENT, - GET_CAL_MTM_MEASUREMENT, - GET_RAW_MTM_MEASUREMENT - }; + enum class StartupStep { NONE, COMMAND_SELF_TEST, GET_SELF_TEST_RESULT }; - CommunicationStep communicationStep = CommunicationStep::GET_ENG_HK_DATA; + StartupStep startupStep = StartupStep::COMMAND_SELF_TEST; - enum class StartupStep { - NONE, - COMMAND_SELF_TEST, - GET_SELF_TEST_RESULT - }; + bool selfTestPerformed = false; - StartupStep startupStep = StartupStep::COMMAND_SELF_TEST; + /** + * @brief In case of a status reply to a single axis self test command, this function + * searches for the actual pending command. + */ + ReturnValue_t getSelfTestCommandId(DeviceCommandId_t* id); - bool selfTestPerformed = false; + /** + * @brief Each reply contains a status byte giving information about a request. This function + * parses this byte and returns the associated failure message. + * + * @param packet Pointer to the received message containing the status byte. + * + * @return The return code derived from the received status byte. + */ + ReturnValue_t parseStatusByte(const uint8_t* packet); - /** - * @brief In case of a status reply to a single axis self test command, this function - * searches for the actual pending command. - */ - ReturnValue_t getSelfTestCommandId(DeviceCommandId_t* id); + /** + * @brief This function fills the engineering housekeeping dataset with the received data. - /** - * @brief Each reply contains a status byte giving information about a request. This function - * parses this byte and returns the associated failure message. - * - * @param packet Pointer to the received message containing the status byte. - * - * @return The return code derived from the received status byte. - */ - ReturnValue_t parseStatusByte(const uint8_t* packet); + * @param packet Pointer to the received data. + * + */ + void fillEngHkDataset(const uint8_t* packet); - /** - * @brief This function fills the engineering housekeeping dataset with the received data. + /** + * @brief This function sends a command reply to the requesting queue. + * + * @param data Pointer to the data to send. + * @param dataSize Size of the data to send. + * @param relplyId Reply id which will be inserted at the beginning of the action message. + */ + void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); - * @param packet Pointer to the received data. - * - */ - void fillEngHkDataset(const uint8_t* packet); + /** + * @brief This function handles the reply containing the commanded dipole. + * + * @param packet Pointer to the reply data. + */ + void handleGetCommandedDipoleReply(const uint8_t* packet); - /** - * @brief This function sends a command reply to the requesting queue. - * - * @param data Pointer to the data to send. - * @param dataSize Size of the data to send. - * @param relplyId Reply id which will be inserted at the beginning of the action message. - */ - void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); + /** + * @brief This function parses the reply containing the calibrated MTM measurement and writes + * the values to the appropriate dataset. + * @param packet Pointer to the reply data. + */ + void fillCalibratedMtmDataset(const uint8_t* packet); - /** - * @brief This function handles the reply containing the commanded dipole. - * - * @param packet Pointer to the reply data. - */ - void handleGetCommandedDipoleReply(const uint8_t* packet); + /** + * @brief This function copies the raw MTM measurements to the MTM raw dataset. + * @param packet Pointer to the reply data requested with the GET_RAW_MTM_MEASUREMENTS + * command. + */ + void fillRawMtmDataset(const uint8_t* packet); - /** - * @brief This function parses the reply containing the calibrated MTM measurement and writes - * the values to the appropriate dataset. - * @param packet Pointer to the reply data. - */ - void fillCalibratedMtmDataset(const uint8_t* packet); + /** + * @brief This function handles all self test results. This comprises parsing the error byte + * and step byte and calling the function to fill the respective dataset. + */ + void handleSelfTestReply(const uint8_t* packet); - /** - * @brief This function copies the raw MTM measurements to the MTM raw dataset. - * @param packet Pointer to the reply data requested with the GET_RAW_MTM_MEASUREMENTS - * command. - */ - void fillRawMtmDataset(const uint8_t* packet); + /** + * @brief The following functions fill the respective dataset of the single axis self tests. + * @param packet Pointer to the reply data holding the self test result. + */ + void handlePositiveXSelfTestReply(const uint8_t* packet); + void handleNegativeXSelfTestReply(const uint8_t* packet); + void handlePositiveYSelfTestReply(const uint8_t* packet); + void handleNegativeYSelfTestReply(const uint8_t* packet); + void handlePositiveZSelfTestReply(const uint8_t* packet); + void handleNegativeZSelfTestReply(const uint8_t* packet); - /** - * @brief This function handles all self test results. This comprises parsing the error byte - * and step byte and calling the function to fill the respective dataset. - */ - void handleSelfTestReply(const uint8_t* packet); + /** + * @brief This function checks the error byte of a self test measurement. + * + * @param errorByte The received error byte to check + * @param step The step of the error byte. + */ + void checkErrorByte(const uint8_t errorByte, const uint8_t step); - /** - * @brief The following functions fill the respective dataset of the single axis self tests. - * @param packet Pointer to the reply data holding the self test result. - */ - void handlePositiveXSelfTestReply(const uint8_t* packet); - void handleNegativeXSelfTestReply(const uint8_t* packet); - void handlePositiveYSelfTestReply(const uint8_t* packet); - void handleNegativeYSelfTestReply(const uint8_t* packet); - void handlePositiveZSelfTestReply(const uint8_t* packet); - void handleNegativeZSelfTestReply(const uint8_t* packet); - - /** - * @brief This function checks the error byte of a self test measurement. - * - * @param errorByte The received error byte to check - * @param step The step of the error byte. - */ - void checkErrorByte(const uint8_t errorByte, const uint8_t step); - - std::string makeStepString(const uint8_t step); + std::string makeStepString(const uint8_t step); }; #endif /* MISSION_DEVICES_IMTQHANDLER_H_ */ diff --git a/mission/devices/Max31865PT1000Handler.cpp b/mission/devices/Max31865PT1000Handler.cpp index 750d56e5..809e669b 100644 --- a/mission/devices/Max31865PT1000Handler.cpp +++ b/mission/devices/Max31865PT1000Handler.cpp @@ -1,546 +1,531 @@ #include "Max31865PT1000Handler.h" -#include "fsfw/datapool/PoolReadGuard.h" - #include #include +#include "fsfw/datapool/PoolReadGuard.h" + Max31865PT1000Handler::Max31865PT1000Handler(object_id_t objectId, object_id_t comIF, - CookieIF *comCookie): - DeviceHandlerBase(objectId, comIF, comCookie), - sensorDataset(this), sensorDatasetSid(sensorDataset.getSid()) { + CookieIF *comCookie) + : DeviceHandlerBase(objectId, comIF, comCookie), + sensorDataset(this), + sensorDatasetSid(sensorDataset.getSid()) { #if OBSW_VERBOSE_LEVEL >= 1 - debugDivider = new PeriodicOperationDivider(10); + debugDivider = new PeriodicOperationDivider(10); #endif } -Max31865PT1000Handler::~Max31865PT1000Handler() { -} +Max31865PT1000Handler::~Max31865PT1000Handler() {} void Max31865PT1000Handler::doStartUp() { - if(internalState == InternalState::NONE) { - internalState = InternalState::WARMUP; - Clock::getUptime(&startTime); - } + if (internalState == InternalState::NONE) { + internalState = InternalState::WARMUP; + Clock::getUptime(&startTime); + } - if(internalState == InternalState::WARMUP) { - dur_millis_t timeNow = 0; - Clock::getUptime(&timeNow); - if(timeNow - startTime >= 100) { - internalState = InternalState::CONFIGURE; - } + if (internalState == InternalState::WARMUP) { + dur_millis_t timeNow = 0; + Clock::getUptime(&timeNow); + if (timeNow - startTime >= 100) { + internalState = InternalState::CONFIGURE; } + } - if(internalState == InternalState::CONFIGURE) { - if(commandExecuted) { - commandExecuted = false; - internalState = InternalState::REQUEST_CONFIG; - } + if (internalState == InternalState::CONFIGURE) { + if (commandExecuted) { + commandExecuted = false; + internalState = InternalState::REQUEST_CONFIG; } + } - if(internalState == InternalState::REQUEST_CONFIG) { - if (commandExecuted) { - commandExecuted = false; - internalState = InternalState::CONFIG_HIGH_THRESHOLD; - } + if (internalState == InternalState::REQUEST_CONFIG) { + if (commandExecuted) { + commandExecuted = false; + internalState = InternalState::CONFIG_HIGH_THRESHOLD; } + } - if(internalState == InternalState::CONFIG_HIGH_THRESHOLD) { - if(commandExecuted) { - internalState = InternalState::REQUEST_HIGH_THRESHOLD; - commandExecuted = false; - } + if (internalState == InternalState::CONFIG_HIGH_THRESHOLD) { + if (commandExecuted) { + internalState = InternalState::REQUEST_HIGH_THRESHOLD; + commandExecuted = false; } + } - if(internalState == InternalState::REQUEST_HIGH_THRESHOLD) { - if(commandExecuted) { - internalState = InternalState::CONFIG_LOW_THRESHOLD; - commandExecuted = false; - } + if (internalState == InternalState::REQUEST_HIGH_THRESHOLD) { + if (commandExecuted) { + internalState = InternalState::CONFIG_LOW_THRESHOLD; + commandExecuted = false; } + } - if(internalState == InternalState::CONFIG_LOW_THRESHOLD) { - if(commandExecuted) { - internalState = InternalState::REQUEST_LOW_THRESHOLD; - commandExecuted = false; - } + if (internalState == InternalState::CONFIG_LOW_THRESHOLD) { + if (commandExecuted) { + internalState = InternalState::REQUEST_LOW_THRESHOLD; + commandExecuted = false; } + } - if(internalState == InternalState::REQUEST_LOW_THRESHOLD) { - if(commandExecuted) { - internalState = InternalState::CLEAR_FAULT_BYTE; - commandExecuted = false; - } + if (internalState == InternalState::REQUEST_LOW_THRESHOLD) { + if (commandExecuted) { + internalState = InternalState::CLEAR_FAULT_BYTE; + commandExecuted = false; } - if(internalState == InternalState::CLEAR_FAULT_BYTE) { - if(commandExecuted) { - commandExecuted = false; - internalState = InternalState::RUNNING; - if(instantNormal) { - setMode(MODE_NORMAL); - } else { - setMode(_MODE_TO_ON); - } - } + } + if (internalState == InternalState::CLEAR_FAULT_BYTE) { + if (commandExecuted) { + commandExecuted = false; + internalState = InternalState::RUNNING; + if (instantNormal) { + setMode(MODE_NORMAL); + } else { + setMode(_MODE_TO_ON); + } } + } } void Max31865PT1000Handler::doShutDown() { - commandExecuted = false; - setMode(_MODE_POWER_DOWN); + commandExecuted = false; + setMode(_MODE_POWER_DOWN); } -ReturnValue_t Max31865PT1000Handler::buildNormalDeviceCommand( - DeviceCommandId_t *id) { - if(internalState == InternalState::RUNNING) { - *id = Max31865Definitions::REQUEST_RTD; - return buildCommandFromCommand(*id, nullptr, 0); - } - else if(internalState == InternalState::REQUEST_FAULT_BYTE) { - *id = Max31865Definitions::REQUEST_FAULT_BYTE; - return buildCommandFromCommand(*id, nullptr, 0); - } - else if(internalState == InternalState::CLEAR_FAULT_BYTE) { - *id = Max31865Definitions::CLEAR_FAULT_BYTE; - return buildCommandFromCommand(*id, nullptr, 0); - } - else { - return DeviceHandlerBase::NOTHING_TO_SEND; - } -} - -ReturnValue_t Max31865PT1000Handler::buildTransitionDeviceCommand( - DeviceCommandId_t *id) { - switch(internalState) { - case(InternalState::NONE): - case(InternalState::WARMUP): - case(InternalState::RUNNING): +ReturnValue_t Max31865PT1000Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + if (internalState == InternalState::RUNNING) { + *id = Max31865Definitions::REQUEST_RTD; + return buildCommandFromCommand(*id, nullptr, 0); + } else if (internalState == InternalState::REQUEST_FAULT_BYTE) { + *id = Max31865Definitions::REQUEST_FAULT_BYTE; + return buildCommandFromCommand(*id, nullptr, 0); + } else if (internalState == InternalState::CLEAR_FAULT_BYTE) { + *id = Max31865Definitions::CLEAR_FAULT_BYTE; + return buildCommandFromCommand(*id, nullptr, 0); + } else { return DeviceHandlerBase::NOTHING_TO_SEND; - case(InternalState::CONFIGURE): { - *id = Max31865Definitions::CONFIG_CMD; - uint8_t config[1] = {DEFAULT_CONFIG}; - return buildCommandFromCommand(*id, config, 1); + } +} + +ReturnValue_t Max31865PT1000Handler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { + switch (internalState) { + case (InternalState::NONE): + case (InternalState::WARMUP): + case (InternalState::RUNNING): + return DeviceHandlerBase::NOTHING_TO_SEND; + case (InternalState::CONFIGURE): { + *id = Max31865Definitions::CONFIG_CMD; + uint8_t config[1] = {DEFAULT_CONFIG}; + return buildCommandFromCommand(*id, config, 1); } - case(InternalState::REQUEST_CONFIG): { - *id = Max31865Definitions::REQUEST_CONFIG; - return buildCommandFromCommand(*id, nullptr, 0); + case (InternalState::REQUEST_CONFIG): { + *id = Max31865Definitions::REQUEST_CONFIG; + return buildCommandFromCommand(*id, nullptr, 0); } - case(InternalState::CONFIG_HIGH_THRESHOLD): { - *id = Max31865Definitions::WRITE_HIGH_THRESHOLD; - return buildCommandFromCommand(*id, nullptr, 0); + case (InternalState::CONFIG_HIGH_THRESHOLD): { + *id = Max31865Definitions::WRITE_HIGH_THRESHOLD; + return buildCommandFromCommand(*id, nullptr, 0); } - case(InternalState::REQUEST_HIGH_THRESHOLD): { - *id = Max31865Definitions::REQUEST_HIGH_THRESHOLD; - return buildCommandFromCommand(*id, nullptr, 0); + case (InternalState::REQUEST_HIGH_THRESHOLD): { + *id = Max31865Definitions::REQUEST_HIGH_THRESHOLD; + return buildCommandFromCommand(*id, nullptr, 0); } - case(InternalState::CONFIG_LOW_THRESHOLD): { - *id = Max31865Definitions::WRITE_LOW_THRESHOLD; - return buildCommandFromCommand(*id, nullptr, 0); + case (InternalState::CONFIG_LOW_THRESHOLD): { + *id = Max31865Definitions::WRITE_LOW_THRESHOLD; + return buildCommandFromCommand(*id, nullptr, 0); } - case(InternalState::REQUEST_LOW_THRESHOLD): { - *id = Max31865Definitions::REQUEST_LOW_THRESHOLD; - return buildCommandFromCommand(*id, nullptr, 0); + case (InternalState::REQUEST_LOW_THRESHOLD): { + *id = Max31865Definitions::REQUEST_LOW_THRESHOLD; + return buildCommandFromCommand(*id, nullptr, 0); } - case(InternalState::CLEAR_FAULT_BYTE): { - *id = Max31865Definitions::CLEAR_FAULT_BYTE; - return buildCommandFromCommand(*id, nullptr, 0); + case (InternalState::CLEAR_FAULT_BYTE): { + *id = Max31865Definitions::CLEAR_FAULT_BYTE; + return buildCommandFromCommand(*id, nullptr, 0); } default: #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Max31865PT1000Handler: Invalid internal state" << std::endl; + sif::error << "Max31865PT1000Handler: Invalid internal state" << std::endl; #else - sif::printError("Max31865PT1000Handler: Invalid internal state\n"); + sif::printError("Max31865PT1000Handler: Invalid internal state\n"); #endif - return HasReturnvaluesIF::RETURN_FAILED; - } + return HasReturnvaluesIF::RETURN_FAILED; + } } -ReturnValue_t Max31865PT1000Handler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t *commandData, - size_t commandDataLen) { - switch(deviceCommand) { - case(Max31865Definitions::CONFIG_CMD) : { - commandBuffer[0] = static_cast(Max31865Definitions::CONFIG_CMD); - if(commandDataLen == 1) { - commandBuffer[1] = commandData[0]; - DeviceHandlerBase::rawPacketLen = 2; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; - } - else { - return DeviceHandlerIF::NO_COMMAND_DATA; - } - } - case(Max31865Definitions::CLEAR_FAULT_BYTE): { - commandBuffer[0] = static_cast(Max31865Definitions::CONFIG_CMD); - commandBuffer[1] = Max31865Definitions::CLEAR_FAULT_BIT_VAL; +ReturnValue_t Max31865PT1000Handler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, + size_t commandDataLen) { + switch (deviceCommand) { + case (Max31865Definitions::CONFIG_CMD): { + commandBuffer[0] = static_cast(Max31865Definitions::CONFIG_CMD); + if (commandDataLen == 1) { + commandBuffer[1] = commandData[0]; DeviceHandlerBase::rawPacketLen = 2; DeviceHandlerBase::rawPacket = commandBuffer.data(); return HasReturnvaluesIF::RETURN_OK; + } else { + return DeviceHandlerIF::NO_COMMAND_DATA; + } } - case(Max31865Definitions::REQUEST_CONFIG): { - commandBuffer[0] = static_cast( - Max31865Definitions::REQUEST_CONFIG); - commandBuffer[1] = 0x00; // dummy byte - DeviceHandlerBase::rawPacketLen = 2; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; + case (Max31865Definitions::CLEAR_FAULT_BYTE): { + commandBuffer[0] = static_cast(Max31865Definitions::CONFIG_CMD); + commandBuffer[1] = Max31865Definitions::CLEAR_FAULT_BIT_VAL; + DeviceHandlerBase::rawPacketLen = 2; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; } - case(Max31865Definitions::WRITE_HIGH_THRESHOLD): { - commandBuffer[0] = static_cast( - Max31865Definitions::WRITE_HIGH_THRESHOLD); - commandBuffer[1] = static_cast(HIGH_THRESHOLD >> 8); - commandBuffer[2] = static_cast(HIGH_THRESHOLD & 0xFF); - DeviceHandlerBase::rawPacketLen = 3; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; + case (Max31865Definitions::REQUEST_CONFIG): { + commandBuffer[0] = static_cast(Max31865Definitions::REQUEST_CONFIG); + commandBuffer[1] = 0x00; // dummy byte + DeviceHandlerBase::rawPacketLen = 2; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; } - case(Max31865Definitions::REQUEST_HIGH_THRESHOLD): { - commandBuffer[0] = static_cast( - Max31865Definitions::REQUEST_HIGH_THRESHOLD); - commandBuffer[1] = 0x00; //dummy byte - commandBuffer[2] = 0x00; //dummy byte - DeviceHandlerBase::rawPacketLen = 3; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; + case (Max31865Definitions::WRITE_HIGH_THRESHOLD): { + commandBuffer[0] = static_cast(Max31865Definitions::WRITE_HIGH_THRESHOLD); + commandBuffer[1] = static_cast(HIGH_THRESHOLD >> 8); + commandBuffer[2] = static_cast(HIGH_THRESHOLD & 0xFF); + DeviceHandlerBase::rawPacketLen = 3; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; } - case(Max31865Definitions::WRITE_LOW_THRESHOLD): { - commandBuffer[0] = static_cast( - Max31865Definitions::WRITE_LOW_THRESHOLD); - commandBuffer[1] = static_cast(LOW_THRESHOLD >> 8); - commandBuffer[2] = static_cast(LOW_THRESHOLD & 0xFF); - DeviceHandlerBase::rawPacketLen = 3; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; + case (Max31865Definitions::REQUEST_HIGH_THRESHOLD): { + commandBuffer[0] = static_cast(Max31865Definitions::REQUEST_HIGH_THRESHOLD); + commandBuffer[1] = 0x00; // dummy byte + commandBuffer[2] = 0x00; // dummy byte + DeviceHandlerBase::rawPacketLen = 3; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; } - case(Max31865Definitions::REQUEST_LOW_THRESHOLD): { - commandBuffer[0] = static_cast( - Max31865Definitions::REQUEST_LOW_THRESHOLD); - commandBuffer[1] = 0x00; //dummy byte - commandBuffer[2] = 0x00; //dummy byte - DeviceHandlerBase::rawPacketLen = 3; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; + case (Max31865Definitions::WRITE_LOW_THRESHOLD): { + commandBuffer[0] = static_cast(Max31865Definitions::WRITE_LOW_THRESHOLD); + commandBuffer[1] = static_cast(LOW_THRESHOLD >> 8); + commandBuffer[2] = static_cast(LOW_THRESHOLD & 0xFF); + DeviceHandlerBase::rawPacketLen = 3; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; } - case(Max31865Definitions::REQUEST_RTD): { - commandBuffer[0] = static_cast( - Max31865Definitions::REQUEST_RTD); - // two dummy bytes - commandBuffer[1] = 0x00; - commandBuffer[2] = 0x00; - DeviceHandlerBase::rawPacketLen = 3; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; + case (Max31865Definitions::REQUEST_LOW_THRESHOLD): { + commandBuffer[0] = static_cast(Max31865Definitions::REQUEST_LOW_THRESHOLD); + commandBuffer[1] = 0x00; // dummy byte + commandBuffer[2] = 0x00; // dummy byte + DeviceHandlerBase::rawPacketLen = 3; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; } - case(Max31865Definitions::REQUEST_FAULT_BYTE): { - commandBuffer[0] = static_cast( - Max31865Definitions::REQUEST_FAULT_BYTE); - commandBuffer[1] = 0x00; - DeviceHandlerBase::rawPacketLen = 2; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; + case (Max31865Definitions::REQUEST_RTD): { + commandBuffer[0] = static_cast(Max31865Definitions::REQUEST_RTD); + // two dummy bytes + commandBuffer[1] = 0x00; + commandBuffer[2] = 0x00; + DeviceHandlerBase::rawPacketLen = 3; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; + } + case (Max31865Definitions::REQUEST_FAULT_BYTE): { + commandBuffer[0] = static_cast(Max31865Definitions::REQUEST_FAULT_BYTE); + commandBuffer[1] = 0x00; + DeviceHandlerBase::rawPacketLen = 2; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; } default: - //Unknown DeviceCommand - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } + // Unknown DeviceCommand + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } } void Max31865PT1000Handler::fillCommandAndReplyMap() { - insertInCommandAndReplyMap(Max31865Definitions::CONFIG_CMD, 3); - insertInCommandAndReplyMap(Max31865Definitions::REQUEST_CONFIG, 3); - insertInCommandAndReplyMap(Max31865Definitions::WRITE_LOW_THRESHOLD, 3); - insertInCommandAndReplyMap(Max31865Definitions::REQUEST_LOW_THRESHOLD, 3); - insertInCommandAndReplyMap(Max31865Definitions::WRITE_HIGH_THRESHOLD, 3); - insertInCommandAndReplyMap(Max31865Definitions::REQUEST_HIGH_THRESHOLD, 3); - insertInCommandAndReplyMap(Max31865Definitions::REQUEST_RTD, 3, - &sensorDataset); - insertInCommandAndReplyMap(Max31865Definitions::REQUEST_FAULT_BYTE, 3); - insertInCommandAndReplyMap(Max31865Definitions::CLEAR_FAULT_BYTE, 3); + insertInCommandAndReplyMap(Max31865Definitions::CONFIG_CMD, 3); + insertInCommandAndReplyMap(Max31865Definitions::REQUEST_CONFIG, 3); + insertInCommandAndReplyMap(Max31865Definitions::WRITE_LOW_THRESHOLD, 3); + insertInCommandAndReplyMap(Max31865Definitions::REQUEST_LOW_THRESHOLD, 3); + insertInCommandAndReplyMap(Max31865Definitions::WRITE_HIGH_THRESHOLD, 3); + insertInCommandAndReplyMap(Max31865Definitions::REQUEST_HIGH_THRESHOLD, 3); + insertInCommandAndReplyMap(Max31865Definitions::REQUEST_RTD, 3, &sensorDataset); + insertInCommandAndReplyMap(Max31865Definitions::REQUEST_FAULT_BYTE, 3); + insertInCommandAndReplyMap(Max31865Definitions::CLEAR_FAULT_BYTE, 3); } -ReturnValue_t Max31865PT1000Handler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { - size_t rtdReplySize = 3; - size_t configReplySize = 2; - - if(remainingSize == rtdReplySize and - internalState == InternalState::RUNNING) { - *foundId = Max31865Definitions::REQUEST_RTD; - *foundLen = rtdReplySize; - return RETURN_OK; - } - - if(remainingSize == 3) { - switch(internalState) { - case(InternalState::CONFIG_HIGH_THRESHOLD): { - *foundLen = 3; - *foundId = Max31865Definitions::WRITE_HIGH_THRESHOLD; - commandExecuted = true; - return RETURN_OK; - } - case(InternalState::REQUEST_HIGH_THRESHOLD): { - *foundLen = 3; - *foundId = Max31865Definitions::REQUEST_HIGH_THRESHOLD; - return RETURN_OK; - } - case(InternalState::CONFIG_LOW_THRESHOLD): { - *foundLen = 3; - *foundId = Max31865Definitions::WRITE_LOW_THRESHOLD; - commandExecuted = true; - return RETURN_OK; - } - case(InternalState::REQUEST_LOW_THRESHOLD): { - *foundLen = 3; - *foundId = Max31865Definitions::REQUEST_LOW_THRESHOLD; - return RETURN_OK; - } - default: { - sif::debug << "Max31865PT1000Handler::scanForReply: Unknown internal state" - << std::endl; - return RETURN_OK; - } - } - } - - if(remainingSize == configReplySize) { - if(internalState == InternalState::CONFIGURE) { - commandExecuted = true; - *foundLen = configReplySize; - *foundId = Max31865Definitions::CONFIG_CMD; - } - else if(internalState == InternalState::REQUEST_FAULT_BYTE) { - *foundId = Max31865Definitions::REQUEST_FAULT_BYTE; - *foundLen = 2; - internalState = InternalState::RUNNING; - } - else if(internalState == InternalState::CLEAR_FAULT_BYTE) { - *foundId = Max31865Definitions::CLEAR_FAULT_BYTE; - *foundLen = 2; - if(mode == _MODE_START_UP) { - commandExecuted = true; - } else { - internalState = InternalState::RUNNING; - } - } - else { - *foundId = Max31865Definitions::REQUEST_CONFIG; - *foundLen = configReplySize; - } - } +ReturnValue_t Max31865PT1000Handler::scanForReply(const uint8_t *start, size_t remainingSize, + DeviceCommandId_t *foundId, size_t *foundLen) { + size_t rtdReplySize = 3; + size_t configReplySize = 2; + if (remainingSize == rtdReplySize and internalState == InternalState::RUNNING) { + *foundId = Max31865Definitions::REQUEST_RTD; + *foundLen = rtdReplySize; return RETURN_OK; + } + + if (remainingSize == 3) { + switch (internalState) { + case (InternalState::CONFIG_HIGH_THRESHOLD): { + *foundLen = 3; + *foundId = Max31865Definitions::WRITE_HIGH_THRESHOLD; + commandExecuted = true; + return RETURN_OK; + } + case (InternalState::REQUEST_HIGH_THRESHOLD): { + *foundLen = 3; + *foundId = Max31865Definitions::REQUEST_HIGH_THRESHOLD; + return RETURN_OK; + } + case (InternalState::CONFIG_LOW_THRESHOLD): { + *foundLen = 3; + *foundId = Max31865Definitions::WRITE_LOW_THRESHOLD; + commandExecuted = true; + return RETURN_OK; + } + case (InternalState::REQUEST_LOW_THRESHOLD): { + *foundLen = 3; + *foundId = Max31865Definitions::REQUEST_LOW_THRESHOLD; + return RETURN_OK; + } + default: { + sif::debug << "Max31865PT1000Handler::scanForReply: Unknown internal state" << std::endl; + return RETURN_OK; + } + } + } + + if (remainingSize == configReplySize) { + if (internalState == InternalState::CONFIGURE) { + commandExecuted = true; + *foundLen = configReplySize; + *foundId = Max31865Definitions::CONFIG_CMD; + } else if (internalState == InternalState::REQUEST_FAULT_BYTE) { + *foundId = Max31865Definitions::REQUEST_FAULT_BYTE; + *foundLen = 2; + internalState = InternalState::RUNNING; + } else if (internalState == InternalState::CLEAR_FAULT_BYTE) { + *foundId = Max31865Definitions::CLEAR_FAULT_BYTE; + *foundLen = 2; + if (mode == _MODE_START_UP) { + commandExecuted = true; + } else { + internalState = InternalState::RUNNING; + } + } else { + *foundId = Max31865Definitions::REQUEST_CONFIG; + *foundLen = configReplySize; + } + } + + return RETURN_OK; } -ReturnValue_t Max31865PT1000Handler::interpretDeviceReply( - DeviceCommandId_t id, const uint8_t *packet) { - switch(id) { - case(Max31865Definitions::REQUEST_CONFIG): { - if(packet[1] != DEFAULT_CONFIG) { +ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(DeviceCommandId_t id, + const uint8_t *packet) { + switch (id) { + case (Max31865Definitions::REQUEST_CONFIG): { + if (packet[1] != DEFAULT_CONFIG) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - // it propably would be better if we at least try one restart.. - sif::error << "Max31865PT1000Handler: 0x" << std::hex << this->getObjectId() - << ": Invalid configuration reply" << std::endl; + // it propably would be better if we at least try one restart.. + sif::error << "Max31865PT1000Handler: 0x" << std::hex << this->getObjectId() + << ": Invalid configuration reply" << std::endl; #else - sif::printError("Max31865PT1000Handler: %04x: Invalid configuration reply!\n", - this->getObjectId()); + sif::printError("Max31865PT1000Handler: %04x: Invalid configuration reply!\n", + this->getObjectId()); #endif - return HasReturnvaluesIF::RETURN_OK; - } - // set to true for invalid configs too for now. - if(internalState == InternalState::REQUEST_CONFIG) { - commandExecuted = true; - } - else if(internalState == InternalState::RUNNING) { - // we should propably generate a telemetry with the config byte - // as payload here. - } - break; + return HasReturnvaluesIF::RETURN_OK; + } + // set to true for invalid configs too for now. + if (internalState == InternalState::REQUEST_CONFIG) { + commandExecuted = true; + } else if (internalState == InternalState::RUNNING) { + // we should propably generate a telemetry with the config byte + // as payload here. + } + break; } - case(Max31865Definitions::REQUEST_LOW_THRESHOLD): { - uint16_t readLowThreshold = packet[1] << 8 | packet[2]; - if(readLowThreshold != LOW_THRESHOLD) { + case (Max31865Definitions::REQUEST_LOW_THRESHOLD): { + uint16_t readLowThreshold = packet[1] << 8 | packet[2]; + if (readLowThreshold != LOW_THRESHOLD) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << - std::hex << this->getObjectId() << ": Missmatch between " << - "written and readback value of low threshold register" << std::endl; + sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex + << this->getObjectId() << ": Missmatch between " + << "written and readback value of low threshold register" << std::endl; #else - sif::printWarning("Max31865PT1000Handler::interpretDeviceReply: Missmatch between " - "written and readback value of low threshold register\n"); + sif::printWarning( + "Max31865PT1000Handler::interpretDeviceReply: Missmatch between " + "written and readback value of low threshold register\n"); #endif #endif - } - commandExecuted = true; - break; + } + commandExecuted = true; + break; } - case(Max31865Definitions::REQUEST_HIGH_THRESHOLD): { - uint16_t readHighThreshold = packet[1] << 8 | packet[2]; - if(readHighThreshold != HIGH_THRESHOLD) { + case (Max31865Definitions::REQUEST_HIGH_THRESHOLD): { + uint16_t readHighThreshold = packet[1] << 8 | packet[2]; + if (readHighThreshold != HIGH_THRESHOLD) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " - << std::hex << this->getObjectId() << ": Missmatch between " << - "written and readback value of high threshold register" << std::endl; + sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex + << this->getObjectId() << ": Missmatch between " + << "written and readback value of high threshold register" << std::endl; #else - sif::printWarning("Max31865PT1000Handler::interpretDeviceReply: Missmatch between " - "written and readback value of high threshold register\n"); + sif::printWarning( + "Max31865PT1000Handler::interpretDeviceReply: Missmatch between " + "written and readback value of high threshold register\n"); #endif #endif - } - commandExecuted = true; - break; + } + commandExecuted = true; + break; } - case(Max31865Definitions::REQUEST_RTD): { - // first bit of LSB reply byte is the fault bit - uint8_t faultBit = packet[2] & 0b0000'0001; - if(resetFaultBit) { - internalState = InternalState::CLEAR_FAULT_BYTE; - resetFaultBit = false; - } - else if(faultBit == 1) { - // Maybe we should attempt to restart it? - internalState = InternalState::REQUEST_FAULT_BYTE; - resetFaultBit = true; - } + case (Max31865Definitions::REQUEST_RTD): { + // first bit of LSB reply byte is the fault bit + uint8_t faultBit = packet[2] & 0b0000'0001; + if (resetFaultBit) { + internalState = InternalState::CLEAR_FAULT_BYTE; + resetFaultBit = false; + } else if (faultBit == 1) { + // Maybe we should attempt to restart it? + internalState = InternalState::REQUEST_FAULT_BYTE; + resetFaultBit = true; + } - // RTD value consists of last seven bits of the LSB reply byte and - // the MSB reply byte - uint16_t adcCode = ((packet[1] << 8) | packet[2]) >> 1; - // do something with rtd value, will propably be stored in - // dataset. - float rtdValue = adcCode * RTD_RREF_PT1000 / INT16_MAX; - // calculate approximation - float approxTemp = adcCode / 32.0 - 256.0; + // RTD value consists of last seven bits of the LSB reply byte and + // the MSB reply byte + uint16_t adcCode = ((packet[1] << 8) | packet[2]) >> 1; + // do something with rtd value, will propably be stored in + // dataset. + float rtdValue = adcCode * RTD_RREF_PT1000 / INT16_MAX; + // calculate approximation + float approxTemp = adcCode / 32.0 - 256.0; #if OBSW_DEBUG_RTD == 1 #if OBSW_VERBOSE_LEVEL >= 1 - if(debugDivider->checkAndIncrement()) { + if (debugDivider->checkAndIncrement()) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "Max31865: Object ID: " << std::hex << this->getObjectId() - << ": Measured resistance is " << rtdValue << " Ohms." << std::endl; - sif::info << "Approximated temperature is " << approxTemp << " C" << std::endl; + sif::info << "Max31865: Object ID: " << std::hex << this->getObjectId() + << ": Measured resistance is " << rtdValue << " Ohms." << std::endl; + sif::info << "Approximated temperature is " << approxTemp << " C" << std::endl; #else - sif::printInfo("Max31685: Measured resistance is %f Ohms\n", rtdValue); - sif::printInfo("Approximated temperature is %f C\n", approxTemp); + sif::printInfo("Max31685: Measured resistance is %f Ohms\n", rtdValue); + sif::printInfo("Approximated temperature is %f C\n", approxTemp); #endif - } + } #endif #endif - PoolReadGuard pg(&sensorDataset); - if(pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) { - // Configuration error + PoolReadGuard pg(&sensorDataset); + if (pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) { + // Configuration error #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " - << std::hex << this->getObjectId() << ": Error reading dataset!" - << std::endl; + sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex + << this->getObjectId() << ": Error reading dataset!" << std::endl; #else - sif::printWarning("Max31865PT1000Handler::interpretDeviceReply: " - "Error reading dataset!\n"); + sif::printWarning( + "Max31865PT1000Handler::interpretDeviceReply: " + "Error reading dataset!\n"); #endif - return pg.getReadResult(); - } + return pg.getReadResult(); + } - if(not sensorDataset.isValid()) { - sensorDataset.setValidity(true, false); - sensorDataset.rtdValue.setValid(true); - sensorDataset.temperatureCelcius.setValid(true); - } + if (not sensorDataset.isValid()) { + sensorDataset.setValidity(true, false); + sensorDataset.rtdValue.setValid(true); + sensorDataset.temperatureCelcius.setValid(true); + } - sensorDataset.rtdValue = rtdValue; - sensorDataset.temperatureCelcius = approxTemp; - break; + sensorDataset.rtdValue = rtdValue; + sensorDataset.temperatureCelcius = approxTemp; + break; } - case(Max31865Definitions::REQUEST_FAULT_BYTE): { - faultByte = packet[1]; + case (Max31865Definitions::REQUEST_FAULT_BYTE): { + faultByte = packet[1]; #if OBSW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " - << std::hex << this->getObjectId() << ": Fault byte" - " is: 0b" << std::bitset<8>(faultByte) << std::endl; + sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex + << this->getObjectId() + << ": Fault byte" + " is: 0b" + << std::bitset<8>(faultByte) << std::endl; #else - sif::printWarning("Max31865PT1000Handler::interpretDeviceReply: Fault byte" - " is: 0b" BYTE_TO_BINARY_PATTERN "\n", BYTE_TO_BINARY(faultByte)); + sif::printWarning( + "Max31865PT1000Handler::interpretDeviceReply: Fault byte" + " is: 0b" BYTE_TO_BINARY_PATTERN "\n", + BYTE_TO_BINARY(faultByte)); #endif #endif - ReturnValue_t result = sensorDataset.read(); - if(result != HasReturnvaluesIF::RETURN_OK) { - // Configuration error + ReturnValue_t result = sensorDataset.read(); + if (result != HasReturnvaluesIF::RETURN_OK) { + // Configuration error #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex - << this->getObjectId() << ":" - "Error reading dataset!" << std::endl; + sif::debug << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex + << this->getObjectId() + << ":" + "Error reading dataset!" + << std::endl; #else - sif::printDebug("Max31865PT1000Handler::interpretDeviceReply: " - "Error reading dataset!\n"); + sif::printDebug( + "Max31865PT1000Handler::interpretDeviceReply: " + "Error reading dataset!\n"); #endif - return result; - } - sensorDataset.errorByte.setValid(true); - sensorDataset.errorByte = faultByte; - if(faultByte != 0) { - sensorDataset.temperatureCelcius.setValid(false); - } + return result; + } + sensorDataset.errorByte.setValid(true); + sensorDataset.errorByte = faultByte; + if (faultByte != 0) { + sensorDataset.temperatureCelcius.setValid(false); + } - result = sensorDataset.commit(); - if(result != HasReturnvaluesIF::RETURN_OK) { - // Configuration error + result = sensorDataset.commit(); + if (result != HasReturnvaluesIF::RETURN_OK) { + // Configuration error #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex - << this->getObjectId() << ": Error commiting dataset!" << std::endl; + sif::debug << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex + << this->getObjectId() << ": Error commiting dataset!" << std::endl; #else - sif::printDebug("Max31865PT1000Handler::interpretDeviceReply: " - "Error commiting dataset!\n"); + sif::printDebug( + "Max31865PT1000Handler::interpretDeviceReply: " + "Error commiting dataset!\n"); #endif - return result; - } + return result; + } - break; + break; } default: - break; - } - return HasReturnvaluesIF::RETURN_OK; + break; + } + return HasReturnvaluesIF::RETURN_OK; } -void Max31865PT1000Handler::debugInterface(uint8_t positionTracker, - object_id_t objectId, uint32_t parameter) { +void Max31865PT1000Handler::debugInterface(uint8_t positionTracker, object_id_t objectId, + uint32_t parameter) {} + +uint32_t Max31865PT1000Handler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { + return 25000; } -uint32_t Max31865PT1000Handler::getTransitionDelayMs( - Mode_t modeFrom, Mode_t modeTo) { - return 25000; +ReturnValue_t Max31865PT1000Handler::getSwitches(const uint8_t **switches, + uint8_t *numberOfSwitches) { + return DeviceHandlerBase::NO_SWITCH; } -ReturnValue_t Max31865PT1000Handler::getSwitches( - const uint8_t **switches, uint8_t *numberOfSwitches) { - return DeviceHandlerBase::NO_SWITCH; +void Max31865PT1000Handler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { + DeviceHandlerBase::doTransition(modeFrom, subModeFrom); } -void Max31865PT1000Handler::doTransition(Mode_t modeFrom, - Submode_t subModeFrom) { - DeviceHandlerBase::doTransition(modeFrom, subModeFrom); -} - -ReturnValue_t Max31865PT1000Handler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { - localDataPoolMap.emplace(Max31865Definitions::PoolIds::RTD_VALUE, new PoolEntry({0})); - localDataPoolMap.emplace(Max31865Definitions::PoolIds::TEMPERATURE_C, - new PoolEntry({0}, 1, true)); - localDataPoolMap.emplace(Max31865Definitions::PoolIds::FAULT_BYTE, - new PoolEntry({0})); -// poolManager.subscribeForPeriodicPacket(sensorDatasetSid, -// false, 4.0, false); - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t Max31865PT1000Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(Max31865Definitions::PoolIds::RTD_VALUE, new PoolEntry({0})); + localDataPoolMap.emplace(Max31865Definitions::PoolIds::TEMPERATURE_C, + new PoolEntry({0}, 1, true)); + localDataPoolMap.emplace(Max31865Definitions::PoolIds::FAULT_BYTE, new PoolEntry({0})); + // poolManager.subscribeForPeriodicPacket(sensorDatasetSid, + // false, 4.0, false); + return HasReturnvaluesIF::RETURN_OK; } void Max31865PT1000Handler::setInstantNormal(bool instantNormal) { - this->instantNormal = instantNormal; + this->instantNormal = instantNormal; } void Max31865PT1000Handler::modeChanged() { - if(mode == MODE_OFF) { - internalState = InternalState::NONE; - } + if (mode == MODE_OFF) { + internalState = InternalState::NONE; + } } diff --git a/mission/devices/Max31865PT1000Handler.h b/mission/devices/Max31865PT1000Handler.h index 3be16150..44d7a2e7 100644 --- a/mission/devices/Max31865PT1000Handler.h +++ b/mission/devices/Max31865PT1000Handler.h @@ -2,12 +2,12 @@ #define MISSION_DEVICES_MAX31865PT1000HANDLER_H_ #include - #include #include #include #include + #include "devicedefinitions/Max31865Definitions.h" /** @@ -28,95 +28,92 @@ * @author R. Mueller * @ingroup devices */ -class Max31865PT1000Handler: public DeviceHandlerBase { -public: - Max31865PT1000Handler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); - virtual~ Max31865PT1000Handler(); +class Max31865PT1000Handler : public DeviceHandlerBase { + public: + Max31865PT1000Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie); + virtual ~Max31865PT1000Handler(); - // Configuration in 8 digit code: - // 1. 1 for V_BIAS enabled, 0 for disabled - // 2. 1 for Auto-conversion, 0 for off - // 3. 1 for 1-shot enabled, 0 for disabled (self-clearing bit) - // 4. 1 for 3-wire enabled, 0 for disabled (two and four wired RTD) - // 5./6. Fault detection: 00 for no action, 01 for automatic delay, 1 - // 0 for run fault detection with manual delay, - // 11 for finish fault detection with manual delay - // 7. Fault status: Write 1 to reset fault status register (Bit is self cleared afterwards) - // 8. 1 for 50 Hz filter, 0 for 60 Hz filter (noise rejection filter) - static constexpr uint8_t DEFAULT_CONFIG = 0b11000001; + // Configuration in 8 digit code: + // 1. 1 for V_BIAS enabled, 0 for disabled + // 2. 1 for Auto-conversion, 0 for off + // 3. 1 for 1-shot enabled, 0 for disabled (self-clearing bit) + // 4. 1 for 3-wire enabled, 0 for disabled (two and four wired RTD) + // 5./6. Fault detection: 00 for no action, 01 for automatic delay, 1 + // 0 for run fault detection with manual delay, + // 11 for finish fault detection with manual delay + // 7. Fault status: Write 1 to reset fault status register (Bit is self cleared afterwards) + // 8. 1 for 50 Hz filter, 0 for 60 Hz filter (noise rejection filter) + static constexpr uint8_t DEFAULT_CONFIG = 0b11000001; - void setInstantNormal(bool instantNormal); - /** - * Expected temperature range is -100 C and 100 C. - * If there are temperatures beyond this range there must be a fault. - * The threshold variables cause the MAX1385 to signal an error in case the measured resistance - * indicates a temperature higher than 100 C or lower than -100 C. - * Default settings of MAX13865 are 0xFFFF for the high threshold register and 0x0 for the - * low threshold register. - */ - static constexpr uint16_t HIGH_THRESHOLD = 11298; // = 100 C - static constexpr uint16_t LOW_THRESHOLD = 4902; // = -100 C + void setInstantNormal(bool instantNormal); + /** + * Expected temperature range is -100 C and 100 C. + * If there are temperatures beyond this range there must be a fault. + * The threshold variables cause the MAX1385 to signal an error in case the measured resistance + * indicates a temperature higher than 100 C or lower than -100 C. + * Default settings of MAX13865 are 0xFFFF for the high threshold register and 0x0 for the + * low threshold register. + */ + static constexpr uint16_t HIGH_THRESHOLD = 11298; // = 100 C + static constexpr uint16_t LOW_THRESHOLD = 4902; // = -100 C - static constexpr float RTD_RREF_PT1000 = 4020.0; //!< Ohm - static constexpr float RTD_RESISTANCE0_PT1000 = 1000.0; //!< Ohm -protected: - // DeviceHandlerBase abstract function implementation - void doStartUp() override; - void doShutDown() override; - ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; - ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override; - ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t * commandData, size_t commandDataLen) override; - void fillCommandAndReplyMap() 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; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; - ReturnValue_t getSwitches(const uint8_t **switches, - uint8_t *numberOfSwitches) override; + static constexpr float RTD_RREF_PT1000 = 4020.0; //!< Ohm + static constexpr float RTD_RESISTANCE0_PT1000 = 1000.0; //!< Ohm + protected: + // DeviceHandlerBase abstract function implementation + void doStartUp() override; + void doShutDown() override; + ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, + size_t commandDataLen) override; + void fillCommandAndReplyMap() 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; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t getSwitches(const uint8_t **switches, uint8_t *numberOfSwitches) override; - void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override; + void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override; - void debugInterface(uint8_t positionTracker = 0, - object_id_t objectId = 0, uint32_t parameter = 0) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; - void modeChanged() override; + void debugInterface(uint8_t positionTracker = 0, object_id_t objectId = 0, + uint32_t parameter = 0) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) override; + void modeChanged() override; -private: - uint8_t switchId = 0; - bool instantNormal = true; + private: + uint8_t switchId = 0; + bool instantNormal = true; - enum class InternalState { - NONE, - WARMUP, - CONFIGURE, - CONFIG_HIGH_THRESHOLD, - REQUEST_HIGH_THRESHOLD, - CONFIG_LOW_THRESHOLD, - REQUEST_LOW_THRESHOLD, - REQUEST_CONFIG, - RUNNING, - REQUEST_FAULT_BYTE, - CLEAR_FAULT_BYTE - }; + enum class InternalState { + NONE, + WARMUP, + CONFIGURE, + CONFIG_HIGH_THRESHOLD, + REQUEST_HIGH_THRESHOLD, + CONFIG_LOW_THRESHOLD, + REQUEST_LOW_THRESHOLD, + REQUEST_CONFIG, + RUNNING, + REQUEST_FAULT_BYTE, + CLEAR_FAULT_BYTE + }; - InternalState internalState = InternalState::NONE; - bool commandExecuted = false; + InternalState internalState = InternalState::NONE; + bool commandExecuted = false; - bool resetFaultBit = false; - dur_millis_t startTime = 0; - uint8_t faultByte = 0; - std::array commandBuffer { 0 }; + bool resetFaultBit = false; + dur_millis_t startTime = 0; + uint8_t faultByte = 0; + std::array commandBuffer{0}; - Max31865Definitions::Max31865Set sensorDataset; - sid_t sensorDatasetSid; + Max31865Definitions::Max31865Set sensorDataset; + sid_t sensorDatasetSid; #if OBSW_VERBOSE_LEVEL >= 1 - PeriodicOperationDivider* debugDivider; + PeriodicOperationDivider *debugDivider; #endif }; #endif /* MISSION_DEVICES_MAX31865PT1000HANDLER_H_ */ - diff --git a/mission/devices/P60DockHandler.cpp b/mission/devices/P60DockHandler.cpp index 4ade2a0b..a89debc6 100644 --- a/mission/devices/P60DockHandler.cpp +++ b/mission/devices/P60DockHandler.cpp @@ -1,480 +1,506 @@ -#include #include "P60DockHandler.h" + +#include + #include "OBSWConfig.h" -P60DockHandler::P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - GomspaceDeviceHandler(objectId, comIF, comCookie, P60Dock::MAX_CONFIGTABLE_ADDRESS, - P60Dock::MAX_HKTABLE_ADDRESS, P60Dock::HK_TABLE_REPLY_SIZE, &p60dockHkTableDataset), p60dockHkTableDataset( - this) { -} +P60DockHandler::P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie) + : GomspaceDeviceHandler(objectId, comIF, comCookie, P60Dock::MAX_CONFIGTABLE_ADDRESS, + P60Dock::MAX_HKTABLE_ADDRESS, P60Dock::HK_TABLE_REPLY_SIZE, + &p60dockHkTableDataset), + p60dockHkTableDataset(this) {} -P60DockHandler::~P60DockHandler() { -} +P60DockHandler::~P60DockHandler() {} -ReturnValue_t P60DockHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - *id = GOMSPACE::REQUEST_HK_TABLE; - return buildCommandFromCommand(*id, NULL, 0); +ReturnValue_t P60DockHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + *id = GOMSPACE::REQUEST_HK_TABLE; + return buildCommandFromCommand(*id, NULL, 0); } void P60DockHandler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) { - - parseHkTableReply(packet); - /** - * Hk table will be sent to the commander if hk table request was not triggered by the - * P60DockHandler itself. - */ - handleDeviceTM(&p60dockHkTableDataset, id, true); + parseHkTableReply(packet); + /** + * Hk table will be sent to the commander if hk table request was not triggered by the + * P60DockHandler itself. + */ + handleDeviceTM(&p60dockHkTableDataset, id, true); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_P60DOCK == 1 - p60dockHkTableDataset.read(); - sif::info << "P60 Dock: ACU VCC switch: " << - static_cast(p60dockHkTableDataset.outputEnableStateAcuVcc.value) << std::endl; - sif::info << "P60 Dock: PDU1 VCC switch: " << - static_cast(p60dockHkTableDataset.outputEnableStatePdu1Vcc.value) << std::endl; - sif::info << "P60 Dock: PDU2 VCC switch: " << - static_cast(p60dockHkTableDataset.outputEnableStatePdu2Vcc.value) << std::endl; - sif::info << "P60 Dock: ACU VBAT switch: " << - static_cast(p60dockHkTableDataset.outputEnableStateAcuVbat.value) << std::endl; - sif::info << "P60 Dock: PDU1 VBAT switch: " << - static_cast(p60dockHkTableDataset.outputEnableStatePdu1Vbat.value) << std::endl; - sif::info << "P60 Dock: PDU2 VBAT switch: " << - static_cast(p60dockHkTableDataset.outputEnableStatePdu2Vbat.value) << std::endl; - sif::info << "P60 Dock: Stack VBAT switch: " << - static_cast(p60dockHkTableDataset.outputEnableStateStackVbat.value) << std::endl; - sif::info << "P60 Dock: Stack 3V3 switch: " << - static_cast(p60dockHkTableDataset.outputEnableStateStack3V3.value) << std::endl; - sif::info << "P60 Dock: Stack 5V switch: " << - static_cast(p60dockHkTableDataset.outputEnableStateStack5V.value) << std::endl; + p60dockHkTableDataset.read(); + sif::info << "P60 Dock: ACU VCC switch: " + << static_cast(p60dockHkTableDataset.outputEnableStateAcuVcc.value) + << std::endl; + sif::info << "P60 Dock: PDU1 VCC switch: " + << static_cast(p60dockHkTableDataset.outputEnableStatePdu1Vcc.value) + << std::endl; + sif::info << "P60 Dock: PDU2 VCC switch: " + << static_cast(p60dockHkTableDataset.outputEnableStatePdu2Vcc.value) + << std::endl; + sif::info << "P60 Dock: ACU VBAT switch: " + << static_cast(p60dockHkTableDataset.outputEnableStateAcuVbat.value) + << std::endl; + sif::info << "P60 Dock: PDU1 VBAT switch: " + << static_cast(p60dockHkTableDataset.outputEnableStatePdu1Vbat.value) + << std::endl; + sif::info << "P60 Dock: PDU2 VBAT switch: " + << static_cast(p60dockHkTableDataset.outputEnableStatePdu2Vbat.value) + << std::endl; + sif::info << "P60 Dock: Stack VBAT switch: " + << static_cast(p60dockHkTableDataset.outputEnableStateStackVbat.value) + << std::endl; + sif::info << "P60 Dock: Stack 3V3 switch: " + << static_cast(p60dockHkTableDataset.outputEnableStateStack3V3.value) + << std::endl; + sif::info << "P60 Dock: Stack 5V switch: " + << static_cast(p60dockHkTableDataset.outputEnableStateStack5V.value) + << std::endl; - float temperatureC = p60dockHkTableDataset.temperature1.value * 0.1; - sif::info << "P60 Dock: Temperature 1: " << temperatureC << " °C" << std::endl; - temperatureC = p60dockHkTableDataset.temperature2.value * 0.1; - sif::info << "P60 Dock: Temperature 2: " << temperatureC << " °C" << std::endl; - sif::info << "P60 Dock: Watchdog Timer seconds left before reboot: " + float temperatureC = p60dockHkTableDataset.temperature1.value * 0.1; + sif::info << "P60 Dock: Temperature 1: " << temperatureC << " °C" << std::endl; + temperatureC = p60dockHkTableDataset.temperature2.value * 0.1; + sif::info << "P60 Dock: Temperature 2: " << temperatureC << " °C" << std::endl; + sif::info << "P60 Dock: Watchdog Timer seconds left before reboot: " << p60dockHkTableDataset.wdtGndLeft << " seconds" << std::endl; - sif::info << "P60 Dock: CSP 1, pings left before reboot: " - << (int) p60dockHkTableDataset.wdtCspLeft1.value << std::endl; - sif::info << "P60 Dock: CSP 2, pings left before reboot: " - << (int) p60dockHkTableDataset.wdtCspLeft1.value << std::endl; + sif::info << "P60 Dock: CSP 1, pings left before reboot: " + << (int)p60dockHkTableDataset.wdtCspLeft1.value << std::endl; + sif::info << "P60 Dock: CSP 2, pings left before reboot: " + << (int)p60dockHkTableDataset.wdtCspLeft1.value << std::endl; - p60dockHkTableDataset.commit(); + p60dockHkTableDataset.commit(); #endif - } void P60DockHandler::parseHkTableReply(const uint8_t *packet) { - uint16_t dataOffset = 0; - p60dockHkTableDataset.read(); - /** - * Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table - * address. - */ - dataOffset += 12; - p60dockHkTableDataset.currentAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentPdu1Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentX3IdleVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentPdu2Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentAcuVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentPdu1Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentX3IdleVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentPdu2Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentStackVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentStack3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentStack5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentGS3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentGS5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + uint16_t dataOffset = 0; + p60dockHkTableDataset.read(); + /** + * Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table + * address. + */ + dataOffset += 12; + p60dockHkTableDataset.currentAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentPdu1Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentX3IdleVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentPdu2Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentAcuVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentPdu1Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentX3IdleVbat = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentPdu2Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentStackVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentStack3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentStack5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentGS3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentGS5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - p60dockHkTableDataset.voltageAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltagePdu1Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageX3IdleVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltagePdu2Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageAcuVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltagePdu1Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageX3IdleVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltagePdu2Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageStackVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageStack3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageStack5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageGS3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + p60dockHkTableDataset.voltageAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltagePdu1Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageX3IdleVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltagePdu2Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageAcuVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltagePdu1Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageX3IdleVbat = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltagePdu2Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageStackVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageStack3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageStack5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageGS3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - p60dockHkTableDataset.outputEnableStateAcuVcc = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStatePdu1Vcc = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateX3IdleVcc = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStatePdu2Vcc = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateAcuVbat = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStatePdu1Vbat = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateX3IdleVbat = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStatePdu2Vbat = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateStackVbat = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateStack3V3 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateStack5V = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateGS3V3 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateGS5V = *(packet + dataOffset); - dataOffset += 3; + p60dockHkTableDataset.outputEnableStateAcuVcc = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStatePdu1Vcc = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateX3IdleVcc = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStatePdu2Vcc = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateAcuVbat = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStatePdu1Vbat = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateX3IdleVbat = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStatePdu2Vbat = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateStackVbat = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateStack3V3 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateStack5V = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateGS3V3 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateGS5V = *(packet + dataOffset); + dataOffset += 3; - p60dockHkTableDataset.temperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.temperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + p60dockHkTableDataset.temperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.temperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - p60dockHkTableDataset.bootcause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.bootCount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.resetcause = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.battMode = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.heaterOn = *(packet + dataOffset); - /* + 13 because here begins a new gomspace csp data field */ - dataOffset += 13; - p60dockHkTableDataset.converter5VStatus = *(packet + dataOffset); - dataOffset += 3; + p60dockHkTableDataset.bootcause = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.bootCount = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.resetcause = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.battMode = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.heaterOn = *(packet + dataOffset); + /* + 13 because here begins a new gomspace csp data field */ + dataOffset += 13; + p60dockHkTableDataset.converter5VStatus = *(packet + dataOffset); + dataOffset += 3; - p60dockHkTableDataset.latchupsAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsPdu1Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsX3IdleVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsPdu2Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsAcuVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsPdu1Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsX3IdleVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsPdu2Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsStackVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsStack3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsStack5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsGS3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + p60dockHkTableDataset.latchupsAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsPdu1Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsX3IdleVcc = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsPdu2Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsAcuVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsPdu1Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsX3IdleVbat = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsPdu2Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsStackVbat = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsStack3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsStack5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsGS3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - p60dockHkTableDataset.vbatVoltageValue = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.vccCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.batteryCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.batteryVoltage = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + p60dockHkTableDataset.vbatVoltageValue = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.vccCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.batteryCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.batteryVoltage = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - p60dockHkTableDataset.batteryTemperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.batteryTemperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + p60dockHkTableDataset.batteryTemperature1 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.batteryTemperature2 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - p60dockHkTableDataset.device0 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device1 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device2 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device3 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device4 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device5 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device6 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device7 = *(packet + dataOffset); - dataOffset += 3; + p60dockHkTableDataset.device0 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device1 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device2 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device3 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device4 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device5 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device6 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device7 = *(packet + dataOffset); + dataOffset += 3; - p60dockHkTableDataset.device0Status = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device1Status = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device2Status = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device3Status = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device4Status = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device5Status = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device6Status = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device7Status = *(packet + dataOffset); - dataOffset += 3; + p60dockHkTableDataset.device0Status = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device1Status = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device2Status = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device3Status = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device4Status = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device5Status = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device6Status = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device7Status = *(packet + dataOffset); + dataOffset += 3; - p60dockHkTableDataset.dearmStatus = *(packet + dataOffset); - dataOffset += 3; + p60dockHkTableDataset.dearmStatus = *(packet + dataOffset); + dataOffset += 3; - p60dockHkTableDataset.wdtCntGnd = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.wdtCntI2c = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.wdtCntCan = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.wdtCntCsp1 = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.wdtCntCsp2 = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; + p60dockHkTableDataset.wdtCntGnd = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.wdtCntI2c = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.wdtCntCan = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.wdtCntCsp1 = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.wdtCntCsp2 = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; - p60dockHkTableDataset.wdtGndLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.wdtI2cLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.wdtCanLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - /* +16 because here begins a new gomspace csp packet */ - dataOffset += 16; + p60dockHkTableDataset.wdtGndLeft = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.wdtI2cLeft = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.wdtCanLeft = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + /* +16 because here begins a new gomspace csp packet */ + dataOffset += 16; - p60dockHkTableDataset.wdtCspLeft1 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.wdtCspLeft2 = *(packet + dataOffset); - dataOffset += 3; + p60dockHkTableDataset.wdtCspLeft1 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.wdtCspLeft2 = *(packet + dataOffset); + dataOffset += 3; - p60dockHkTableDataset.batteryChargeCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.batteryDischargeCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.ant6Depl = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.ar6Depl = *(packet + dataOffset); + p60dockHkTableDataset.batteryChargeCurrent = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.batteryDischargeCurrent = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.ant6Depl = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.ar6Depl = *(packet + dataOffset); - p60dockHkTableDataset.commit(); + p60dockHkTableDataset.commit(); } -ReturnValue_t P60DockHandler::initializeLocalDataPool( - localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { +ReturnValue_t P60DockHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_ACU_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU1_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_X3_IDLE_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU2_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_ACU_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU1_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_X3_IDLE_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU2_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_5V, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_GS3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_GS5V, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_ACU_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU1_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_X3_IDLE_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU2_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_ACU_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU1_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_X3_IDLE_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU2_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_5V, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_GS3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_GS5V, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_ACU_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU1_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_X3_IDLE_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU2_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_ACU_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU1_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_X3_IDLE_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU2_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_5V, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_GS3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_GS5V, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_ACU_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU1_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_X3_IDLE_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU2_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_ACU_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU1_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_X3_IDLE_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU2_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_5V, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_GS3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_GS5V, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_ACU_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU1_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VCC, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU2_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_ACU_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU1_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VBAT, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU2_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_5V, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_GS3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_GS5V, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_ACU_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU1_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU2_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_ACU_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU1_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU2_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_5V, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_GS3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_GS5V, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_TEMPERATURE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_TEMPERATURE_2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_TEMPERATURE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_TEMPERATURE_2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_BOOT_CAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_BOOT_CNT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_RESETCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_BATT_MODE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_HEATER_ON, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CONV_5V_ENABLE_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_BOOT_CAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_BOOT_CNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_UPTIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_RESETCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_BATT_MODE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_HEATER_ON, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CONV_5V_ENABLE_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_ACU_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU1_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_X3_IDLE_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU2_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_ACU_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU1_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_X3_IDLE_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU2_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_5V, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_GS3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_GS5V, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_ACU_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU1_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_X3_IDLE_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU2_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_ACU_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU1_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_X3_IDLE_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU2_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_5V, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_GS3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_GS5V, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_VBAT_VALUE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VCC_CURRENT_VALUE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_VOLTAGE, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_VBAT_VALUE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VCC_CURRENT_VALUE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_VOLTAGE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_TEMPERATURE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_TEMPERATURE_2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_TEMPERATURE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_TEMPERATURE_2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_5, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_7, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_0_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_1_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_2_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_3_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_4_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_5_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_6_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_7_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_0_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_1_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_2_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_3_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_4_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_5_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_6_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_7_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_DEARM_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_DEARM_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_GND, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_I2C, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CAN, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CSP_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CSP_2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_GND, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_I2C, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CAN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CSP_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CSP_2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_GND_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_I2C_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CAN_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CSP_LEFT_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CSP_LEFT_2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_GND_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_I2C_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CAN_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CSP_LEFT_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CSP_LEFT_2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_BATT_CHARGE_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_BATT_DISCHARGE_CURRENT, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_BATT_CHARGE_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_BATT_DISCHARGE_CURRENT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_ANT6_DEPL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_AR6_DEPL, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_ANT6_DEPL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_AR6_DEPL, new PoolEntry( { 0 })); - - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } - ReturnValue_t P60DockHandler::printStatus(DeviceCommandId_t cmd) { - switch(cmd) { - case(GOMSPACE::PRINT_SWITCH_V_I): { - PoolReadGuard pg(&p60dockHkTableDataset); - ReturnValue_t readResult = pg.getReadResult(); - if(readResult != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Reading PDU1 HK table failed!" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - printHkTable(); - return HasReturnvaluesIF::RETURN_OK; + switch (cmd) { + case (GOMSPACE::PRINT_SWITCH_V_I): { + PoolReadGuard pg(&p60dockHkTableDataset); + ReturnValue_t readResult = pg.getReadResult(); + if (readResult != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Reading PDU1 HK table failed!" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + printHkTable(); + return HasReturnvaluesIF::RETURN_OK; } default: { - return HasReturnvaluesIF::RETURN_FAILED; - } + return HasReturnvaluesIF::RETURN_FAILED; } + } } void P60DockHandler::printHkTable() { - sif::info << "P60 Dock Info: SwitchState, Currents [mA], Voltages [mV]" << std::endl; + sif::info << "P60 Dock Info: SwitchState, Currents [mA], Voltages [mV]" << std::endl; - sif::info << std::setw(30) << std::left << "ACU VCC" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStateAcuVcc.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentAcuVcc.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltageAcuVcc.value << std::endl; - sif::info << std::setw(30) << std::left << "ACU VBAT" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStateAcuVbat.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentAcuVbat.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltageAcuVbat.value << std::endl; + sif::info << std::setw(30) << std::left << "ACU VCC" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStateAcuVcc.value) << ", " << std::setw(4) + << std::right << p60dockHkTableDataset.currentAcuVcc.value << ", " << std::setw(5) + << p60dockHkTableDataset.voltageAcuVcc.value << std::endl; + sif::info << std::setw(30) << std::left << "ACU VBAT" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStateAcuVbat.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentAcuVbat.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltageAcuVbat.value << std::endl; - sif::info << std::setw(30) << std::left << "PDU1 VCC" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStatePdu1Vcc.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentPdu1Vcc.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltagePdu1Vcc.value << std::endl; - sif::info << std::setw(30) << std::left << "PDU1 VBAT" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStatePdu1Vbat.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentPdu1Vbat.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltagePdu1Vbat.value << std::endl; + sif::info << std::setw(30) << std::left << "PDU1 VCC" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStatePdu1Vcc.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentPdu1Vcc.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltagePdu1Vcc.value << std::endl; + sif::info << std::setw(30) << std::left << "PDU1 VBAT" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStatePdu1Vbat.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentPdu1Vbat.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltagePdu1Vbat.value << std::endl; - sif::info << std::setw(30) << std::left << "PDU2 VCC" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStatePdu2Vcc.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentPdu2Vcc.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltagePdu2Vcc.value << std::endl; - sif::info << std::setw(30) << std::left << "PDU2 VBAT" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStatePdu2Vbat.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentPdu2Vbat.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltagePdu2Vbat.value << std::endl; + sif::info << std::setw(30) << std::left << "PDU2 VCC" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStatePdu2Vcc.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentPdu2Vcc.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltagePdu2Vcc.value << std::endl; + sif::info << std::setw(30) << std::left << "PDU2 VBAT" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStatePdu2Vbat.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentPdu2Vbat.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltagePdu2Vbat.value << std::endl; - sif::info << std::setw(30) << std::left << "Stack VBAT" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStateStackVbat.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentStackVbat.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltageStackVbat.value << std::endl; - sif::info << std::setw(30) << std::left << "Stack 3V3" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStateStack3V3.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentStack3V3.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltageStack3V3.value << std::endl; - sif::info << std::setw(30) << std::left << "Stack 5V" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStateStack5V.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentStack5V.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltageStack5V.value << std::endl; + sif::info << std::setw(30) << std::left << "Stack VBAT" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStateStackVbat.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentStackVbat.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltageStackVbat.value << std::endl; + sif::info << std::setw(30) << std::left << "Stack 3V3" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStateStack3V3.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentStack3V3.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltageStack3V3.value << std::endl; + sif::info << std::setw(30) << std::left << "Stack 5V" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStateStack5V.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentStack5V.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltageStack5V.value << std::endl; } - diff --git a/mission/devices/P60DockHandler.h b/mission/devices/P60DockHandler.h index cee0ecec..937ef122 100644 --- a/mission/devices/P60DockHandler.h +++ b/mission/devices/P60DockHandler.h @@ -1,47 +1,47 @@ #ifndef MISSION_DEVICES_P60DOCKHANDLER_H_ #define MISSION_DEVICES_P60DOCKHANDLER_H_ -#include "GomspaceDeviceHandler.h" #include +#include "GomspaceDeviceHandler.h" /** * @brief Device handler for the P60Dock. The P60Dock serves as carrier for the ACU, PDU1 and * PDU2. Via the P60Dock each of these modules can be turned on and off individually. */ -class P60DockHandler: public GomspaceDeviceHandler { -public: - P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); - virtual ~P60DockHandler(); +class P60DockHandler : public GomspaceDeviceHandler { + public: + P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + virtual ~P60DockHandler(); - virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; + virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; -protected: + protected: + /** + * @brief As soon as the device is in MODE_NORMAL, this function is executed periodically. + */ + virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override; - /** - * @brief As soon as the device is in MODE_NORMAL, this function is executed periodically. - */ - virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; + virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t* packet) override; - virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) override; + /** + * This command handles printing the HK table to the console. This is useful for debugging + * purposes + * @return + */ + ReturnValue_t printStatus(DeviceCommandId_t cmd) override; - /** - * This command handles printing the HK table to the console. This is useful for debugging - * purposes - * @return - */ - ReturnValue_t printStatus(DeviceCommandId_t cmd) override; + void printHkTable(); - void printHkTable(); -private: - P60Dock::HkTableDataset p60dockHkTableDataset; + private: + P60Dock::HkTableDataset p60dockHkTableDataset; - /** - * @brief Function extracts the hk table information from the received csp packet and stores - * the values in the p60dockHkTableDataset. - */ - void parseHkTableReply(const uint8_t *packet); + /** + * @brief Function extracts the hk table information from the received csp packet and stores + * the values in the p60dockHkTableDataset. + */ + void parseHkTableReply(const uint8_t* packet); }; #endif /* MISSION_DEVICES_P60DOCKHANDLER_H_ */ diff --git a/mission/devices/PCDUHandler.cpp b/mission/devices/PCDUHandler.cpp index fe7294ea..13bed074 100644 --- a/mission/devices/PCDUHandler.cpp +++ b/mission/devices/PCDUHandler.cpp @@ -1,506 +1,488 @@ #include "PCDUHandler.h" + #include +#include +#include +#include #include -#include - -#include -#include - - -PCDUHandler::PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize) : - SystemObject(setObjectId), poolManager(this, nullptr), pdu2HkTableDataset(this), pdu1HkTableDataset( - this), cmdQueueSize(cmdQueueSize) { - - commandQueue = QueueFactory::instance()->createMessageQueue(cmdQueueSize, - MessageQueueMessage::MAX_MESSAGE_SIZE); +PCDUHandler::PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize) + : SystemObject(setObjectId), + poolManager(this, nullptr), + pdu2HkTableDataset(this), + pdu1HkTableDataset(this), + cmdQueueSize(cmdQueueSize) { + commandQueue = QueueFactory::instance()->createMessageQueue( + cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE); } -PCDUHandler::~PCDUHandler() { -} +PCDUHandler::~PCDUHandler() {} ReturnValue_t PCDUHandler::performOperation(uint8_t counter) { - - if (counter == DeviceHandlerIF::PERFORM_OPERATION) { - readCommandQueue(); - return RETURN_OK; - } - + if (counter == DeviceHandlerIF::PERFORM_OPERATION) { + readCommandQueue(); return RETURN_OK; + } + + return RETURN_OK; } ReturnValue_t PCDUHandler::initialize() { + ReturnValue_t result; - ReturnValue_t result; + IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); + if (IPCStore == nullptr) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); - if (IPCStore == nullptr) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = poolManager.initialize(commandQueue); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } - result = poolManager.initialize(commandQueue); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + /* Subscribing for housekeeping table update messages of the PDU2 */ + HasLocalDataPoolIF* pdu2Handler = + ObjectManager::instance()->get(objects::PDU2_HANDLER); + if (pdu2Handler == nullptr) { + sif::error << "PCDUHandler::initialize: Invalid pdu2Handler" << std::endl; + return RETURN_FAILED; + } + result = pdu2Handler->getSubscriptionInterface()->subscribeForSetUpdateMessage( + PDU2::HK_TABLE_DATA_SET_ID, this->getObjectId(), commandQueue->getId(), true); + if (result != RETURN_OK) { + sif::error << "PCDUHandler::initialize: Failed to subscribe for set update messages from " + << "PDU2Handler" << std::endl; + return result; + } - /* Subscribing for housekeeping table update messages of the PDU2 */ - HasLocalDataPoolIF* pdu2Handler = ObjectManager::instance()->get( - objects::PDU2_HANDLER); - if(pdu2Handler == nullptr) { - sif::error << "PCDUHandler::initialize: Invalid pdu2Handler" << std::endl; - return RETURN_FAILED; - } - result = pdu2Handler->getSubscriptionInterface()->subscribeForSetUpdateMessage( - PDU2::HK_TABLE_DATA_SET_ID, this->getObjectId(), commandQueue->getId(), true); - if (result != RETURN_OK) { - sif::error << "PCDUHandler::initialize: Failed to subscribe for set update messages from " - << "PDU2Handler" << std::endl; - return result; - } + /* Subscribing for housekeeping table update messages of the PDU1 */ + HasLocalDataPoolIF* pdu1Handler = + ObjectManager::instance()->get(objects::PDU1_HANDLER); + if (pdu1Handler == nullptr) { + sif::error << "PCDUHandler::initialize: Invalid pdu1Handler" << std::endl; + return RETURN_FAILED; + } + result = pdu1Handler->getSubscriptionInterface()->subscribeForSetUpdateMessage( + PDU1::HK_TABLE_DATA_SET_ID, this->getObjectId(), commandQueue->getId(), true); + if (result != RETURN_OK) { + sif::error << "PCDUHandler::initialize: Failed to subscribe for set update messages from " + << "PDU1Handler" << std::endl; + return result; + } - /* Subscribing for housekeeping table update messages of the PDU1 */ - HasLocalDataPoolIF* pdu1Handler = ObjectManager::instance()->get( - objects::PDU1_HANDLER); - if(pdu1Handler == nullptr) { - sif::error << "PCDUHandler::initialize: Invalid pdu1Handler" << std::endl; - return RETURN_FAILED; - } - result = pdu1Handler->getSubscriptionInterface()->subscribeForSetUpdateMessage( - PDU1::HK_TABLE_DATA_SET_ID, this->getObjectId(), commandQueue->getId(), true); - if (result != RETURN_OK) { - sif::error << "PCDUHandler::initialize: Failed to subscribe for set update messages from " - << "PDU1Handler" << std::endl; - return result; - } - - return RETURN_OK; + return RETURN_OK; } void PCDUHandler::initializeSwitchStates() { - switchStates[pcduSwitches::Q7S] = pcduSwitches::INIT_STATE_Q7S; - switchStates[pcduSwitches::PAYLOAD_PCDU_CH1] = pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH1; - switchStates[pcduSwitches::RW] = pcduSwitches::INIT_STATE_RW; - switchStates[pcduSwitches::TCS_BOARD_8V_HEATER_IN] = pcduSwitches::INIT_STATE_TCS_BOARD_8V_HEATER_IN; - switchStates[pcduSwitches::SUS_REDUNDANT] = pcduSwitches::INIT_STATE_SUS_REDUNDANT; - switchStates[pcduSwitches::DEPLOYMENT_MECHANISM] = pcduSwitches::INIT_STATE_DEPLOYMENT_MECHANISM; - switchStates[pcduSwitches::PAYLOAD_PCDU_CH6] = pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH6; - switchStates[pcduSwitches::ACS_BOARD_SIDE_B] = pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_B; - switchStates[pcduSwitches::PAYLOAD_CAMERA] = pcduSwitches::INIT_STATE_PAYLOAD_CAMERA; - switchStates[pcduSwitches::TCS_BOARD_3V3] = pcduSwitches::INIT_STATE_TCS_BOARD_3V3; - switchStates[pcduSwitches::SYRLINKS] = pcduSwitches::INIT_STATE_SYRLINKS; - switchStates[pcduSwitches::STAR_TRACKER] = pcduSwitches::INIT_STATE_STAR_TRACKER; - switchStates[pcduSwitches::MGT] = pcduSwitches::INIT_STATE_MGT; - switchStates[pcduSwitches::SUS_NOMINAL] = pcduSwitches::INIT_STATE_SUS_NOMINAL; - switchStates[pcduSwitches::SOLAR_CELL_EXP] = pcduSwitches::INIT_STATE_SOLAR_CELL_EXP; - switchStates[pcduSwitches::PLOC] = pcduSwitches::INIT_STATE_PLOC; - switchStates[pcduSwitches::ACS_BOARD_SIDE_A] = pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_A; + switchStates[pcduSwitches::Q7S] = pcduSwitches::INIT_STATE_Q7S; + switchStates[pcduSwitches::PAYLOAD_PCDU_CH1] = pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH1; + switchStates[pcduSwitches::RW] = pcduSwitches::INIT_STATE_RW; + switchStates[pcduSwitches::TCS_BOARD_8V_HEATER_IN] = + pcduSwitches::INIT_STATE_TCS_BOARD_8V_HEATER_IN; + switchStates[pcduSwitches::SUS_REDUNDANT] = pcduSwitches::INIT_STATE_SUS_REDUNDANT; + switchStates[pcduSwitches::DEPLOYMENT_MECHANISM] = pcduSwitches::INIT_STATE_DEPLOYMENT_MECHANISM; + switchStates[pcduSwitches::PAYLOAD_PCDU_CH6] = pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH6; + switchStates[pcduSwitches::ACS_BOARD_SIDE_B] = pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_B; + switchStates[pcduSwitches::PAYLOAD_CAMERA] = pcduSwitches::INIT_STATE_PAYLOAD_CAMERA; + switchStates[pcduSwitches::TCS_BOARD_3V3] = pcduSwitches::INIT_STATE_TCS_BOARD_3V3; + switchStates[pcduSwitches::SYRLINKS] = pcduSwitches::INIT_STATE_SYRLINKS; + switchStates[pcduSwitches::STAR_TRACKER] = pcduSwitches::INIT_STATE_STAR_TRACKER; + switchStates[pcduSwitches::MGT] = pcduSwitches::INIT_STATE_MGT; + switchStates[pcduSwitches::SUS_NOMINAL] = pcduSwitches::INIT_STATE_SUS_NOMINAL; + switchStates[pcduSwitches::SOLAR_CELL_EXP] = pcduSwitches::INIT_STATE_SOLAR_CELL_EXP; + switchStates[pcduSwitches::PLOC] = pcduSwitches::INIT_STATE_PLOC; + switchStates[pcduSwitches::ACS_BOARD_SIDE_A] = pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_A; } void PCDUHandler::readCommandQueue() { - ReturnValue_t result; - CommandMessage command; + ReturnValue_t result; + CommandMessage command; - result = commandQueue->receiveMessage(&command); - if (result != RETURN_OK) { - return; - } + result = commandQueue->receiveMessage(&command); + if (result != RETURN_OK) { + return; + } - result = poolManager.handleHousekeepingMessage(&command); - if (result == RETURN_OK) { - return; - } + result = poolManager.handleHousekeepingMessage(&command); + if (result == RETURN_OK) { + return; + } } -MessageQueueId_t PCDUHandler::getCommandQueue() const { - return commandQueue->getId(); -} +MessageQueueId_t PCDUHandler::getCommandQueue() const { return commandQueue->getId(); } void PCDUHandler::handleChangedDataset(sid_t sid, store_address_t storeId) { - - if (sid == sid_t(objects::PDU2_HANDLER, PDU2::HK_TABLE_DATA_SET_ID)) { - updateHkTableDataset(storeId, &pdu2HkTableDataset, &timeStampPdu2HkDataset); - updatePdu2SwitchStates(); - } - else if (sid == sid_t(objects::PDU1_HANDLER, PDU1::HK_TABLE_DATA_SET_ID)) { - updateHkTableDataset(storeId, &pdu1HkTableDataset, &timeStampPdu1HkDataset); - updatePdu1SwitchStates(); - } - else { - sif::error << "PCDUHandler::handleChangedDataset: Invalid sid" << std::endl; - } + if (sid == sid_t(objects::PDU2_HANDLER, PDU2::HK_TABLE_DATA_SET_ID)) { + updateHkTableDataset(storeId, &pdu2HkTableDataset, &timeStampPdu2HkDataset); + updatePdu2SwitchStates(); + } else if (sid == sid_t(objects::PDU1_HANDLER, PDU1::HK_TABLE_DATA_SET_ID)) { + updateHkTableDataset(storeId, &pdu1HkTableDataset, &timeStampPdu1HkDataset); + updatePdu1SwitchStates(); + } else { + sif::error << "PCDUHandler::handleChangedDataset: Invalid sid" << std::endl; + } } -void PCDUHandler::updateHkTableDataset(store_address_t storeId, - LocalPoolDataSetBase* dataset, CCSDSTime::CDS_short* datasetTimeStamp) { - ReturnValue_t result; +void PCDUHandler::updateHkTableDataset(store_address_t storeId, LocalPoolDataSetBase* dataset, + CCSDSTime::CDS_short* datasetTimeStamp) { + ReturnValue_t result; - HousekeepingSnapshot packetUpdate(reinterpret_cast(datasetTimeStamp), - sizeof(CCSDSTime::CDS_short), dataset); - const uint8_t* packet_ptr = NULL; - size_t size; - result = IPCStore->getData(storeId, &packet_ptr, &size); - if (result != RETURN_OK) { - sif::error << "PCDUHandler::updateHkTableDataset: Failed to get data from IPCStore." - << std::endl; - } - dataset->read(); - result = packetUpdate.deSerialize(&packet_ptr, &size, SerializeIF::Endianness::MACHINE); - if (result != RETURN_OK) { - sif::error << "PCDUHandler::updateHkTableDataset: Failed to deserialize received packet " - "in hk table dataset"<< std::endl; - } - dataset->commit(); - result = IPCStore->deleteData(storeId); - if (result != RETURN_OK) { - sif::error << "PCDUHandler::updateHkTableDataset: Failed to delete data in IPCStore" - << std::endl; - } + HousekeepingSnapshot packetUpdate(reinterpret_cast(datasetTimeStamp), + sizeof(CCSDSTime::CDS_short), dataset); + const uint8_t* packet_ptr = NULL; + size_t size; + result = IPCStore->getData(storeId, &packet_ptr, &size); + if (result != RETURN_OK) { + sif::error << "PCDUHandler::updateHkTableDataset: Failed to get data from IPCStore." + << std::endl; + } + dataset->read(); + result = packetUpdate.deSerialize(&packet_ptr, &size, SerializeIF::Endianness::MACHINE); + if (result != RETURN_OK) { + sif::error << "PCDUHandler::updateHkTableDataset: Failed to deserialize received packet " + "in hk table dataset" + << std::endl; + } + dataset->commit(); + result = IPCStore->deleteData(storeId); + if (result != RETURN_OK) { + sif::error << "PCDUHandler::updateHkTableDataset: Failed to delete data in IPCStore" + << std::endl; + } } void PCDUHandler::updatePdu2SwitchStates() { - //TODO: pool read helper - if (pdu2HkTableDataset.read() == RETURN_OK) { - switchStates[pcduSwitches::Q7S] = pdu2HkTableDataset.outEnabledQ7S.value; - switchStates[pcduSwitches::PAYLOAD_PCDU_CH1] = pdu2HkTableDataset.outEnabledPlPCDUCh1.value; - switchStates[pcduSwitches::RW] = pdu2HkTableDataset.outEnabledReactionWheels.value; - switchStates[pcduSwitches::TCS_BOARD_8V_HEATER_IN] = pdu2HkTableDataset.outEnabledTCSBoardHeaterIn.value; - switchStates[pcduSwitches::SUS_REDUNDANT] = pdu2HkTableDataset.outEnabledSUSRedundant.value; - switchStates[pcduSwitches::DEPLOYMENT_MECHANISM] = pdu2HkTableDataset.outEnabledDeplMechanism.value; - switchStates[pcduSwitches::PAYLOAD_PCDU_CH6] = pdu2HkTableDataset.outEnabledPlPCDUCh6.value; - switchStates[pcduSwitches::ACS_BOARD_SIDE_B] = pdu2HkTableDataset.outEnabledAcsBoardSideB.value; - switchStates[pcduSwitches::PAYLOAD_CAMERA] = pdu2HkTableDataset.outEnabledPayloadCamera.value; - } - else { - sif::debug << "PCDUHandler::updatePdu2SwitchStates: Failed to read PDU2 Hk Dataset" - << std::endl; - } - pdu2HkTableDataset.commit(); + // TODO: pool read helper + if (pdu2HkTableDataset.read() == RETURN_OK) { + switchStates[pcduSwitches::Q7S] = pdu2HkTableDataset.outEnabledQ7S.value; + switchStates[pcduSwitches::PAYLOAD_PCDU_CH1] = pdu2HkTableDataset.outEnabledPlPCDUCh1.value; + switchStates[pcduSwitches::RW] = pdu2HkTableDataset.outEnabledReactionWheels.value; + switchStates[pcduSwitches::TCS_BOARD_8V_HEATER_IN] = + pdu2HkTableDataset.outEnabledTCSBoardHeaterIn.value; + switchStates[pcduSwitches::SUS_REDUNDANT] = pdu2HkTableDataset.outEnabledSUSRedundant.value; + switchStates[pcduSwitches::DEPLOYMENT_MECHANISM] = + pdu2HkTableDataset.outEnabledDeplMechanism.value; + switchStates[pcduSwitches::PAYLOAD_PCDU_CH6] = pdu2HkTableDataset.outEnabledPlPCDUCh6.value; + switchStates[pcduSwitches::ACS_BOARD_SIDE_B] = pdu2HkTableDataset.outEnabledAcsBoardSideB.value; + switchStates[pcduSwitches::PAYLOAD_CAMERA] = pdu2HkTableDataset.outEnabledPayloadCamera.value; + } else { + sif::debug << "PCDUHandler::updatePdu2SwitchStates: Failed to read PDU2 Hk Dataset" + << std::endl; + } + pdu2HkTableDataset.commit(); } void PCDUHandler::updatePdu1SwitchStates() { - if (pdu1HkTableDataset.read() == RETURN_OK) { - switchStates[pcduSwitches::TCS_BOARD_3V3] = pdu1HkTableDataset.voltageOutTCSBoard3V3.value; - switchStates[pcduSwitches::SYRLINKS] = pdu1HkTableDataset.voltageOutSyrlinks.value; - switchStates[pcduSwitches::STAR_TRACKER] = pdu1HkTableDataset.voltageOutStarTracker.value; - switchStates[pcduSwitches::MGT] = pdu1HkTableDataset.voltageOutMGT.value; - switchStates[pcduSwitches::SUS_NOMINAL] = pdu1HkTableDataset.voltageOutSUSNominal.value; - switchStates[pcduSwitches::SOLAR_CELL_EXP] = pdu1HkTableDataset.voltageOutSolarCellExp.value; - switchStates[pcduSwitches::PLOC] = pdu1HkTableDataset.voltageOutPLOC.value; - switchStates[pcduSwitches::ACS_BOARD_SIDE_A] = pdu1HkTableDataset.voltageOutACSBoardSideA.value; - } - else { - sif::debug << "PCDUHandler::updatePdu1SwitchStates: Failed to read dataset" << std::endl; - } - pdu1HkTableDataset.commit(); + if (pdu1HkTableDataset.read() == RETURN_OK) { + switchStates[pcduSwitches::TCS_BOARD_3V3] = pdu1HkTableDataset.voltageOutTCSBoard3V3.value; + switchStates[pcduSwitches::SYRLINKS] = pdu1HkTableDataset.voltageOutSyrlinks.value; + switchStates[pcduSwitches::STAR_TRACKER] = pdu1HkTableDataset.voltageOutStarTracker.value; + switchStates[pcduSwitches::MGT] = pdu1HkTableDataset.voltageOutMGT.value; + switchStates[pcduSwitches::SUS_NOMINAL] = pdu1HkTableDataset.voltageOutSUSNominal.value; + switchStates[pcduSwitches::SOLAR_CELL_EXP] = pdu1HkTableDataset.voltageOutSolarCellExp.value; + switchStates[pcduSwitches::PLOC] = pdu1HkTableDataset.voltageOutPLOC.value; + switchStates[pcduSwitches::ACS_BOARD_SIDE_A] = pdu1HkTableDataset.voltageOutACSBoardSideA.value; + } else { + sif::debug << "PCDUHandler::updatePdu1SwitchStates: Failed to read dataset" << std::endl; + } + pdu1HkTableDataset.commit(); } -LocalDataPoolManager* PCDUHandler::getHkManagerHandle() { - return &poolManager; -} +LocalDataPoolManager* PCDUHandler::getHkManagerHandle() { return &poolManager; } void PCDUHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const { + ReturnValue_t result; + uint16_t memoryAddress; + size_t parameterValueSize = sizeof(uint8_t); + uint8_t parameterValue; + GomspaceDeviceHandler* pdu; - ReturnValue_t result; - uint16_t memoryAddress; - size_t parameterValueSize = sizeof(uint8_t); - uint8_t parameterValue; - GomspaceDeviceHandler* pdu; - - switch (switchNr) { + switch (switchNr) { case pcduSwitches::TCS_BOARD_8V_HEATER_IN: - memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_TCS_BOARD_HEATER_IN; - pdu = ObjectManager::instance()->get(objects::PDU2_HANDLER); - break; + memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_TCS_BOARD_HEATER_IN; + pdu = ObjectManager::instance()->get(objects::PDU2_HANDLER); + break; case pcduSwitches::DEPLOYMENT_MECHANISM: - memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_DEPLOYMENT_MECHANISM; - pdu = ObjectManager::instance()->get(objects::PDU2_HANDLER); - break; + memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_DEPLOYMENT_MECHANISM; + pdu = ObjectManager::instance()->get(objects::PDU2_HANDLER); + break; default: - sif::error << "PCDUHandler::sendSwitchCommand: Invalid switch number " << std::endl; - return; - } + sif::error << "PCDUHandler::sendSwitchCommand: Invalid switch number " << std::endl; + return; + } - switch (onOff) { + switch (onOff) { case PowerSwitchIF::SWITCH_ON: - parameterValue = 1; - break; + parameterValue = 1; + break; case PowerSwitchIF::SWITCH_OFF: - parameterValue = 0; - break; + parameterValue = 0; + break; default: - sif::error << "PCDUHandler::sendSwitchCommand: Invalid state commanded" << std::endl; - return; - } + sif::error << "PCDUHandler::sendSwitchCommand: Invalid state commanded" << std::endl; + return; + } - GomspaceSetParamMessage setParamMessage(memoryAddress, ¶meterValue, parameterValueSize); + GomspaceSetParamMessage setParamMessage(memoryAddress, ¶meterValue, parameterValueSize); - size_t serializedLength = 0; - uint8_t command[4]; - uint8_t* commandPtr = command; - size_t maxSize = sizeof(command); - setParamMessage.serialize(&commandPtr, &serializedLength, maxSize, - SerializeIF::Endianness::BIG); + size_t serializedLength = 0; + uint8_t command[4]; + uint8_t* commandPtr = command; + size_t maxSize = sizeof(command); + setParamMessage.serialize(&commandPtr, &serializedLength, maxSize, SerializeIF::Endianness::BIG); - store_address_t storeAddress; - result = IPCStore->addData(&storeAddress, command,sizeof(command)); + store_address_t storeAddress; + result = IPCStore->addData(&storeAddress, command, sizeof(command)); - CommandMessage message; - ActionMessage::setCommand(&message, GOMSPACE::PARAM_SET, storeAddress); + CommandMessage message; + ActionMessage::setCommand(&message, GOMSPACE::PARAM_SET, storeAddress); - result = commandQueue->sendMessage(pdu->getCommandQueue(), &message, 0); - if (result != RETURN_OK) { - sif::debug << "PCDUHandler::sendSwitchCommand: Failed to send message to PDU Handler" - << std::endl; - } + result = commandQueue->sendMessage(pdu->getCommandQueue(), &message, 0); + if (result != RETURN_OK) { + sif::debug << "PCDUHandler::sendSwitchCommand: Failed to send message to PDU Handler" + << std::endl; + } } -void PCDUHandler::sendFuseOnCommand(uint8_t fuseNr) const { +void PCDUHandler::sendFuseOnCommand(uint8_t fuseNr) const {} +ReturnValue_t PCDUHandler::getSwitchState(uint8_t switchNr) const { + if (switchNr >= pcduSwitches::NUMBER_OF_SWITCHES) { + sif::debug << "PCDUHandler::getSwitchState: Invalid switch number" << std::endl; + return RETURN_FAILED; + } + if (switchStates[switchNr] == 1) { + return PowerSwitchIF::SWITCH_ON; + } else { + return PowerSwitchIF::SWITCH_OFF; + } } -ReturnValue_t PCDUHandler::getSwitchState( uint8_t switchNr ) const { - if (switchNr >= pcduSwitches::NUMBER_OF_SWITCHES) { - sif::debug << "PCDUHandler::getSwitchState: Invalid switch number" << std::endl; - return RETURN_FAILED; - } - if (switchStates[switchNr] == 1) { - return PowerSwitchIF::SWITCH_ON; - } - else { - return PowerSwitchIF::SWITCH_OFF; - } -} +ReturnValue_t PCDUHandler::getFuseState(uint8_t fuseNr) const { return RETURN_OK; } -ReturnValue_t PCDUHandler::getFuseState( uint8_t fuseNr ) const { - return RETURN_OK; -} +uint32_t PCDUHandler::getSwitchDelayMs(void) const { return 20000; } -uint32_t PCDUHandler::getSwitchDelayMs(void) const { - return 20000; -} +object_id_t PCDUHandler::getObjectId() const { return SystemObject::getObjectId(); } -object_id_t PCDUHandler::getObjectId() const { - return SystemObject::getObjectId(); -} +ReturnValue_t PCDUHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) { + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_Q7S, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_RW, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_SUS_REDUNDANT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, new PoolEntry({0})); -ReturnValue_t PCDUHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_Q7S, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_RW, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_Q7S, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_RW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_SUS_REDUNDANT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CONV_EN_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CONV_EN_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CONV_EN_3, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_Q7S, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_RW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, new PoolEntry( { 0 })); - - localDataPoolMap.emplace(P60System::PDU2_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CONV_EN_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CONV_EN_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CONV_EN_3, new PoolEntry( { 0 })); - - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_Q7S, new PoolEntry( { - pcduSwitches::INIT_STATE_Q7S })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, new PoolEntry( { - pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH1 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_RW, new PoolEntry( { - pcduSwitches::INIT_STATE_RW })); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_Q7S, + new PoolEntry({pcduSwitches::INIT_STATE_Q7S})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, + new PoolEntry({pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH1})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_RW, + new PoolEntry({pcduSwitches::INIT_STATE_RW})); #if BOARD_TE0720 == 1 - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry( { 1 })); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry({1})); #else - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry( {pcduSwitches::INIT_STATE_TCS_BOARD_8V_HEATER_IN})); + localDataPoolMap.emplace( + P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, + new PoolEntry({pcduSwitches::INIT_STATE_TCS_BOARD_8V_HEATER_IN})); #endif - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_SUS_REDUNDANT, new PoolEntry( { - pcduSwitches::INIT_STATE_SUS_REDUNDANT })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_DEPLOYMENT_MECHANISM, new PoolEntry( { - pcduSwitches::INIT_STATE_DEPLOYMENT_MECHANISM })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH6, new PoolEntry( { - pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH6 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_ACS_BOARD_SIDE_B, new PoolEntry( { - pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_B })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_CAMERA, new PoolEntry( { - pcduSwitches::INIT_STATE_PAYLOAD_CAMERA })); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_SUS_REDUNDANT, + new PoolEntry({pcduSwitches::INIT_STATE_SUS_REDUNDANT})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_DEPLOYMENT_MECHANISM, + new PoolEntry({pcduSwitches::INIT_STATE_DEPLOYMENT_MECHANISM})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH6, + new PoolEntry({pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH6})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_ACS_BOARD_SIDE_B, + new PoolEntry({pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_B})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_CAMERA, + new PoolEntry({pcduSwitches::INIT_STATE_PAYLOAD_CAMERA})); - localDataPoolMap.emplace(P60System::PDU2_BOOTCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_BOOTCNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_UPTIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_RESETCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_BATT_MODE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_BOOTCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_BOOTCNT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_RESETCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_BATT_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_Q7S, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_RW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_SUS_REDUNDANT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_DEPLOYMENT_MECHANISM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_ACS_BOARD_SIDE_B, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_CAMERA, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_Q7S, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_RW, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_SUS_REDUNDANT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_DEPLOYMENT_MECHANISM, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_ACS_BOARD_SIDE_B, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_CAMERA, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_5, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_7, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_0_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_1_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_2_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_3_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_4_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_5_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_6_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_7_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_0_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_1_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_2_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_3_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_4_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_5_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_6_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_7_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_GND, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_I2C, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CAN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_GND_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_I2C_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CAN_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_GND, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_I2C, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CAN, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_GND_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_I2C_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CAN_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CONV_EN_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CONV_EN_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CONV_EN_3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CONV_EN_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CONV_EN_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CONV_EN_3, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_ACS_BOARD_SIDE_A, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_BOOTCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_BOOTCNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_UPTIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_RESETCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_BATT_MODE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_BOOTCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_BOOTCNT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_RESETCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_BATT_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_ACS_BOARD_SIDE_A, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_5, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_7, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_0_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_1_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_2_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_3_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_4_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_5_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_6_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_7_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_0_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_1_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_2_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_3_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_4_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_5_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_6_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_7_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_GND, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_I2C, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CAN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_GND_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_I2C_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CAN_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_GND, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_I2C, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CAN, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_GND_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_I2C_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CAN_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT2, new PoolEntry({0})); - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t PCDUHandler::initializeAfterTaskCreation() { + if (executingTask != nullptr) { + pstIntervalMs = executingTask->getPeriodMs(); + } + this->poolManager.initializeAfterTaskCreation(); - if(executingTask != nullptr) { - pstIntervalMs = executingTask->getPeriodMs(); - } - this->poolManager.initializeAfterTaskCreation(); + initializeSwitchStates(); - initializeSwitchStates(); - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } -uint32_t PCDUHandler::getPeriodicOperationFrequency() const { - return pstIntervalMs; -} +uint32_t PCDUHandler::getPeriodicOperationFrequency() const { return pstIntervalMs; } -void PCDUHandler::setTaskIF(PeriodicTaskIF* task){ - executingTask = task; -} +void PCDUHandler::setTaskIF(PeriodicTaskIF* task) { executingTask = task; } LocalPoolDataSetBase* PCDUHandler::getDataSetHandle(sid_t sid) { - if (sid == pdu2HkTableDataset.getSid()) { - return &pdu2HkTableDataset; - } else { - sif::error << "PCDUHandler::getDataSetHandle: Invalid sid" << std::endl; - return nullptr; - } + if (sid == pdu2HkTableDataset.getSid()) { + return &pdu2HkTableDataset; + } else { + sif::error << "PCDUHandler::getDataSetHandle: Invalid sid" << std::endl; + return nullptr; + } } diff --git a/mission/devices/PCDUHandler.h b/mission/devices/PCDUHandler.h index 566e1d9c..c045ed03 100644 --- a/mission/devices/PCDUHandler.h +++ b/mission/devices/PCDUHandler.h @@ -2,120 +2,116 @@ #define MISSION_DEVICES_PCDUHANDLER_H_ #include -#include -#include -#include -#include #include #include +#include #include -#include - +#include +#include +#include /** * @brief The PCDUHandler provides a compact interface to handle all devices related to the - * control of power. This is necessary because the fsfw manages all power related - * functionalities via one power object. This includes for example the switch on and off - * of devices. + * control of power. This is necessary because the fsfw manages all power + * related functionalities via one power object. This includes for example the switch on and off of + * devices. */ -class PCDUHandler: public PowerSwitchIF, - public HasLocalDataPoolIF, - public SystemObject, - public ExecutableObjectIF { -public: +class PCDUHandler : public PowerSwitchIF, + public HasLocalDataPoolIF, + public SystemObject, + public ExecutableObjectIF { + public: + PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize = 20); + virtual ~PCDUHandler(); - PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize = 20); - virtual ~PCDUHandler(); + virtual ReturnValue_t initialize() override; + virtual ReturnValue_t performOperation(uint8_t counter) override; + virtual void handleChangedDataset(sid_t sid, + store_address_t storeId = storeId::INVALID_STORE_ADDRESS); - virtual ReturnValue_t initialize() override; - virtual ReturnValue_t performOperation(uint8_t counter) override; - virtual void handleChangedDataset(sid_t sid, store_address_t storeId = - storeId::INVALID_STORE_ADDRESS); + virtual void sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const override; + virtual void sendFuseOnCommand(uint8_t fuseNr) const override; + virtual ReturnValue_t getSwitchState(uint8_t switchNr) const override; + virtual ReturnValue_t getFuseState(uint8_t fuseNr) const override; + virtual uint32_t getSwitchDelayMs(void) const override; + virtual object_id_t getObjectId() const override; + virtual LocalDataPoolManager* getHkManagerHandle() override; - virtual void sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const override; - virtual void sendFuseOnCommand(uint8_t fuseNr) const override; - virtual ReturnValue_t getSwitchState( uint8_t switchNr ) const override; - virtual ReturnValue_t getFuseState( uint8_t fuseNr ) const override; - virtual uint32_t getSwitchDelayMs(void) const override; - virtual object_id_t getObjectId() const override; - virtual LocalDataPoolManager* getHkManagerHandle() override; + virtual MessageQueueId_t getCommandQueue() const override; + virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; + virtual uint32_t getPeriodicOperationFrequency() const override; + virtual ReturnValue_t initializeAfterTaskCreation() override; + virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + virtual void setTaskIF(PeriodicTaskIF* task_); - virtual MessageQueueId_t getCommandQueue() const override; - virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; - virtual uint32_t getPeriodicOperationFrequency() const override; - virtual ReturnValue_t initializeAfterTaskCreation() override; - virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; - virtual void setTaskIF(PeriodicTaskIF* task_); + private: + uint32_t pstIntervalMs = 0; -private: + /** Housekeeping manager. Handles updates of local pool variables. */ + LocalDataPoolManager poolManager; - uint32_t pstIntervalMs = 0; + /** + * The dataset holding the hk table of PDU2. This dataset is a copy of the PDU2 HK dataset + * of the PDU2Handler. Each time the PDU2Handler updates his HK dataset, a copy is sent + * to this object via a HousekeepingMessage. + */ + PDU2::PDU2HkTableDataset pdu2HkTableDataset; + /** The timeStamp of the current pdu2HkTableDataset */ + CCSDSTime::CDS_short timeStampPdu2HkDataset; - /** Housekeeping manager. Handles updates of local pool variables. */ - LocalDataPoolManager poolManager; + /** Hk table dataset of PDU1 */ + PDU1::PDU1HkTableDataset pdu1HkTableDataset; + /** The timeStamp of the current pdu1HkTableDataset */ + CCSDSTime::CDS_short timeStampPdu1HkDataset; - /** - * The dataset holding the hk table of PDU2. This dataset is a copy of the PDU2 HK dataset - * of the PDU2Handler. Each time the PDU2Handler updates his HK dataset, a copy is sent - * to this object via a HousekeepingMessage. - */ - PDU2::PDU2HkTableDataset pdu2HkTableDataset; - /** The timeStamp of the current pdu2HkTableDataset */ - CCSDSTime::CDS_short timeStampPdu2HkDataset; + uint8_t switchStates[pcduSwitches::NUMBER_OF_SWITCHES]; + /** + * Pointer to the IPCStore. + * This caches the pointer received from the objectManager in the constructor. + */ + StorageManagerIF* IPCStore = nullptr; - /** Hk table dataset of PDU1 */ - PDU1::PDU1HkTableDataset pdu1HkTableDataset; - /** The timeStamp of the current pdu1HkTableDataset */ - CCSDSTime::CDS_short timeStampPdu1HkDataset; + /** + * Message queue to communicate with other objetcs. Used for example to receive + * local pool messages from ACU, PDU1 and PDU2. + */ + MessageQueueIF* commandQueue = nullptr; - uint8_t switchStates[pcduSwitches::NUMBER_OF_SWITCHES]; - /** - * Pointer to the IPCStore. - * This caches the pointer received from the objectManager in the constructor. - */ - StorageManagerIF *IPCStore = nullptr; + size_t cmdQueueSize; - /** - * Message queue to communicate with other objetcs. Used for example to receive - * local pool messages from ACU, PDU1 and PDU2. - */ - MessageQueueIF* commandQueue = nullptr; + PeriodicTaskIF* executingTask = nullptr; - size_t cmdQueueSize; + void readCommandQueue(); - PeriodicTaskIF* executingTask = nullptr; + /** + * @brief This function sets all switchStates to the initial switch configuration of the + * two PDUs after reboot. + */ + void initializeSwitchStates(); - void readCommandQueue(); + /** + * @brief Updates all switchStates related to the PDU2. + * Function is called each time a new hk dataset has been received from the PDU2Handler. + */ + void updatePdu2SwitchStates(); - /** - * @brief This function sets all switchStates to the initial switch configuration of the - * two PDUs after reboot. - */ - void initializeSwitchStates(); + /** + * @brief Updates all switchStates related to the PDU1. Called each time the PDU1Handler + * sends a new hk dataset. + */ + void updatePdu1SwitchStates(); - /** - * @brief Updates all switchStates related to the PDU2. - * Function is called each time a new hk dataset has been received from the PDU2Handler. - */ - void updatePdu2SwitchStates(); - - /** - * @brief Updates all switchStates related to the PDU1. Called each time the PDU1Handler - * sends a new hk dataset. - */ - void updatePdu1SwitchStates(); - - /** - * @brief In case of an update snapshot message this function handles the update of the - * local dataset. - * @param storeId Storage id of updated dataset. - * @param dataset Pointer to the local dataset. - * @param datasetTimeStamp Pointer to a variable which will hold the timestamp of the updated - * dataset. - */ - void updateHkTableDataset(store_address_t storeId, LocalPoolDataSetBase* dataset, - CCSDSTime::CDS_short* datasetTimeStamp); + /** + * @brief In case of an update snapshot message this function handles the update of the + * local dataset. + * @param storeId Storage id of updated dataset. + * @param dataset Pointer to the local dataset. + * @param datasetTimeStamp Pointer to a variable which will hold the timestamp of the updated + * dataset. + */ + void updateHkTableDataset(store_address_t storeId, LocalPoolDataSetBase* dataset, + CCSDSTime::CDS_short* datasetTimeStamp); }; #endif /* MISSION_DEVICES_PCDUHANDLER_H_ */ diff --git a/mission/devices/PDU1Handler.cpp b/mission/devices/PDU1Handler.cpp index 1676e488..a1486588 100644 --- a/mission/devices/PDU1Handler.cpp +++ b/mission/devices/PDU1Handler.cpp @@ -1,402 +1,421 @@ -#include "OBSWConfig.h" #include "PDU1Handler.h" #include -PDU1Handler::PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - GomspaceDeviceHandler(objectId, comIF, comCookie, PDU::MAX_CONFIGTABLE_ADDRESS, - PDU::MAX_HKTABLE_ADDRESS, PDU::HK_TABLE_REPLY_SIZE, &pdu1HkTableDataset), - pdu1HkTableDataset(this) { -} +#include "OBSWConfig.h" -PDU1Handler::~PDU1Handler() { -} +PDU1Handler::PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie) + : GomspaceDeviceHandler(objectId, comIF, comCookie, PDU::MAX_CONFIGTABLE_ADDRESS, + PDU::MAX_HKTABLE_ADDRESS, PDU::HK_TABLE_REPLY_SIZE, + &pdu1HkTableDataset), + pdu1HkTableDataset(this) {} -ReturnValue_t PDU1Handler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - *id = GOMSPACE::REQUEST_HK_TABLE; - return buildCommandFromCommand(*id, NULL, 0); +PDU1Handler::~PDU1Handler() {} + +ReturnValue_t PDU1Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + *id = GOMSPACE::REQUEST_HK_TABLE; + return buildCommandFromCommand(*id, NULL, 0); } void PDU1Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) { - - parseHkTableReply(packet); - handleDeviceTM(&pdu1HkTableDataset, id, true); + parseHkTableReply(packet); + handleDeviceTM(&pdu1HkTableDataset, id, true); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PDU1 == 1 - pdu1HkTableDataset.read(); - sif::info << "PDU1 TCS Board voltage: " << pdu1HkTableDataset.voltageOutTCSBoard3V3 + pdu1HkTableDataset.read(); + sif::info << "PDU1 TCS Board voltage: " << pdu1HkTableDataset.voltageOutTCSBoard3V3 << std::endl; + sif::info << "PDU1 Syrlinks voltage: " << pdu1HkTableDataset.voltageOutSyrlinks << std::endl; + sif::info << "PDU1 star tracker voltage: " << pdu1HkTableDataset.voltageOutStarTracker << std::endl; - sif::info << "PDU1 Syrlinks voltage: " << pdu1HkTableDataset.voltageOutSyrlinks << std::endl; - sif::info << "PDU1 star tracker voltage: " << pdu1HkTableDataset.voltageOutStarTracker + sif::info << "PDU1 MGT voltage: " << pdu1HkTableDataset.voltageOutMGT << std::endl; + sif::info << "PDU1 SUS nominal voltage: " << pdu1HkTableDataset.voltageOutSUSNominal << std::endl; + sif::info << "PDU1 solar cell experiment voltage: " << pdu1HkTableDataset.voltageOutSolarCellExp << std::endl; - sif::info << "PDU1 MGT voltage: " << pdu1HkTableDataset.voltageOutMGT << std::endl; - sif::info << "PDU1 SUS nominal voltage: " << pdu1HkTableDataset.voltageOutSUSNominal + sif::info << "PDU1 PLOC voltage: " << pdu1HkTableDataset.voltageOutPLOC << std::endl; + sif::info << "PDU1 ACS Side A voltage: " << pdu1HkTableDataset.voltageOutACSBoardSideA << std::endl; - sif::info << "PDU1 solar cell experiment voltage: " << pdu1HkTableDataset.voltageOutSolarCellExp - << std::endl; - sif::info << "PDU1 PLOC voltage: " << pdu1HkTableDataset.voltageOutPLOC << std::endl; - sif::info << "PDU1 ACS Side A voltage: " << pdu1HkTableDataset.voltageOutACSBoardSideA - << std::endl; - sif::info << "PDU1 channel 8 voltage: " << pdu1HkTableDataset.voltageOutACSBoardSideA + sif::info << "PDU1 channel 8 voltage: " << pdu1HkTableDataset.voltageOutACSBoardSideA << std::endl; - sif::info << "PDU1 TCS Board current: " << pdu1HkTableDataset.currentOutTCSBoard3V3 + sif::info << "PDU1 TCS Board current: " << pdu1HkTableDataset.currentOutTCSBoard3V3 << std::endl; + sif::info << "PDU1 Syrlinks current: " << pdu1HkTableDataset.currentOutSyrlinks << std::endl; + sif::info << "PDU1 star tracker current: " << pdu1HkTableDataset.currentOutStarTracker << std::endl; - sif::info << "PDU1 Syrlinks current: " << pdu1HkTableDataset.currentOutSyrlinks << std::endl; - sif::info << "PDU1 star tracker current: " << pdu1HkTableDataset.currentOutStarTracker + sif::info << "PDU1 MGT current: " << pdu1HkTableDataset.currentOutMGT << std::endl; + sif::info << "PDU1 SUS nominal current: " << pdu1HkTableDataset.currentOutSUSNominal << std::endl; + sif::info << "PDU1 solar cell experiment current: " << pdu1HkTableDataset.currentOutSolarCellExp << std::endl; - sif::info << "PDU1 MGT current: " << pdu1HkTableDataset.currentOutMGT << std::endl; - sif::info << "PDU1 SUS nominal current: " << pdu1HkTableDataset.currentOutSUSNominal + sif::info << "PDU1 PLOC current: " << pdu1HkTableDataset.currentOutPLOC << std::endl; + sif::info << "PDU1 ACS Side A current: " << pdu1HkTableDataset.currentOutACSBoardSideA << std::endl; - sif::info << "PDU1 solar cell experiment current: " << pdu1HkTableDataset.currentOutSolarCellExp + sif::info << "PDU1 channel 8 current: " << pdu1HkTableDataset.currentOutChannel8 << std::endl; + printOutputSwitchStates(); + sif::info << "PDU1 battery mode: " << static_cast(pdu1HkTableDataset.battMode.value) << std::endl; - sif::info << "PDU1 PLOC current: " << pdu1HkTableDataset.currentOutPLOC << std::endl; - sif::info << "PDU1 ACS Side A current: " << pdu1HkTableDataset.currentOutACSBoardSideA + sif::info << "PDU1 VCC: " << pdu1HkTableDataset.vcc << " mV" << std::endl; + float vbat = pdu1HkTableDataset.vbat.value * 0.001; + sif::info << "PDU1 VBAT: " << vbat << "V" << std::endl; + float temperatureC = pdu1HkTableDataset.temperature.value * 0.1; + sif::info << "PDU1 Temperature: " << temperatureC << " °C" << std::endl; + sif::info << "PDU1 csp1 watchdog pings before reboot: " + << static_cast(pdu1HkTableDataset.csp1WatchdogPingsLeft.value) << std::endl; - sif::info << "PDU1 channel 8 current: " << pdu1HkTableDataset.currentOutChannel8 + sif::info << "PDU1 csp2 watchdog pings before reboot: " + << static_cast(pdu1HkTableDataset.csp2WatchdogPingsLeft.value) << std::endl; - printOutputSwitchStates(); - sif::info << "PDU1 battery mode: " << - static_cast(pdu1HkTableDataset.battMode.value) << std::endl; - sif::info << "PDU1 VCC: " << pdu1HkTableDataset.vcc << " mV" << std::endl; - float vbat = pdu1HkTableDataset.vbat.value * 0.001; - sif::info << "PDU1 VBAT: " << vbat << "V" << std::endl; - float temperatureC = pdu1HkTableDataset.temperature.value * 0.1; - sif::info << "PDU1 Temperature: " << temperatureC << " °C" << std::endl; - sif::info << "PDU1 csp1 watchdog pings before reboot: " - << static_cast(pdu1HkTableDataset.csp1WatchdogPingsLeft.value) << std::endl; - sif::info << "PDU1 csp2 watchdog pings before reboot: " - << static_cast(pdu1HkTableDataset.csp2WatchdogPingsLeft.value) << std::endl; - pdu1HkTableDataset.commit(); + pdu1HkTableDataset.commit(); #endif } void PDU1Handler::parseHkTableReply(const uint8_t *packet) { - uint16_t dataOffset = 0; - PoolReadGuard pg(&pdu1HkTableDataset); - ReturnValue_t readResult = pg.getReadResult(); - if(readResult != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Reading PDU1 HK table failed!" << std::endl; - return; - } - /* Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table - * address. */ - dataOffset += 12; - pdu1HkTableDataset.currentOutTCSBoard3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutStarTracker = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutMGT = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutSUSNominal = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutSolarCellExp = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutPLOC = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutACSBoardSideA = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + uint16_t dataOffset = 0; + PoolReadGuard pg(&pdu1HkTableDataset); + ReturnValue_t readResult = pg.getReadResult(); + if (readResult != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Reading PDU1 HK table failed!" << std::endl; + return; + } + /* Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table + * address. */ + dataOffset += 12; + pdu1HkTableDataset.currentOutTCSBoard3V3 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutStarTracker = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutMGT = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutSUSNominal = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutSolarCellExp = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutPLOC = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutACSBoardSideA = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu1HkTableDataset.voltageOutTCSBoard3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutStarTracker = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutMGT = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutSUSNominal = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutSolarCellExp = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutPLOC = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutACSBoardSideA = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + pdu1HkTableDataset.voltageOutTCSBoard3V3 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutStarTracker = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutMGT = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutSUSNominal = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutSolarCellExp = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutPLOC = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutACSBoardSideA = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu1HkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.temperature = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + pdu1HkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.temperature = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu1HkTableDataset.converterEnable1 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.converterEnable2 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.converterEnable3 = *(packet + dataOffset); - dataOffset += 3; + pdu1HkTableDataset.converterEnable1 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.converterEnable2 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.converterEnable3 = *(packet + dataOffset); + dataOffset += 3; - pdu1HkTableDataset.outEnabledTCSBoard3V3 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledSyrlinks = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledStarTracker = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledMGT = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledSUSNominal = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledSolarCellExp = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledPLOC = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledAcsBoardSideA = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledChannel8 = *(packet + dataOffset); - dataOffset += 3; + pdu1HkTableDataset.outEnabledTCSBoard3V3 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledSyrlinks = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledStarTracker = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledMGT = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledSUSNominal = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledSolarCellExp = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledPLOC = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledAcsBoardSideA = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledChannel8 = *(packet + dataOffset); + dataOffset += 3; - pdu1HkTableDataset.bootcause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.bootcount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.resetcause = *(packet + dataOffset + 1) << 8 | *(packet + dataOffset); - dataOffset += 4; - pdu1HkTableDataset.battMode = *(packet + dataOffset); - /* +10 because here begins the second gomspace csp packet */ - dataOffset += 3 + 10; + pdu1HkTableDataset.bootcause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.bootcount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.resetcause = *(packet + dataOffset + 1) << 8 | *(packet + dataOffset); + dataOffset += 4; + pdu1HkTableDataset.battMode = *(packet + dataOffset); + /* +10 because here begins the second gomspace csp packet */ + dataOffset += 3 + 10; - pdu1HkTableDataset.latchupsTcsBoard3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsStarTracker = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsMgt = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsSusNominal = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsSolarCellExp = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsPloc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsAcsBoardSideA = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + pdu1HkTableDataset.latchupsTcsBoard3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsStarTracker = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsMgt = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsSusNominal = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsSolarCellExp = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsPloc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsAcsBoardSideA = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu1HkTableDataset.device0 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device1 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device2 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device3 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device4 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device5 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device6 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device7 = *(packet + dataOffset); - dataOffset += 3; + pdu1HkTableDataset.device0 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device1 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device2 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device3 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device4 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device5 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device6 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device7 = *(packet + dataOffset); + dataOffset += 3; - pdu1HkTableDataset.device0Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device1Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device2Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device3Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device4Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device5Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device6Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device7Status = *(packet + dataOffset); - dataOffset += 3; + pdu1HkTableDataset.device0Status = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device1Status = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device2Status = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device3Status = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device4Status = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device5Status = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device6Status = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device7Status = *(packet + dataOffset); + dataOffset += 3; - pdu1HkTableDataset.gndWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.i2cWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.canWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.csp1WdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.csp2WdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.groundWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.i2cWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.canWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.csp1WatchdogPingsLeft = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.csp2WatchdogPingsLeft = *(packet + dataOffset); + pdu1HkTableDataset.gndWdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.i2cWdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.canWdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.csp1WdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.csp2WdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.groundWatchdogSecondsLeft = + *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.i2cWatchdogSecondsLeft = + *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.canWatchdogSecondsLeft = + *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.csp1WatchdogPingsLeft = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.csp2WatchdogPingsLeft = *(packet + dataOffset); - pdu1HkTableDataset.setChanged(true); - if(not pdu1HkTableDataset.isValid()) { - pdu1HkTableDataset.setValidity(true, true); - } + pdu1HkTableDataset.setChanged(true); + if (not pdu1HkTableDataset.isValid()) { + pdu1HkTableDataset.setValidity(true, true); + } } -ReturnValue_t PDU1Handler::initializeLocalDataPool( - localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { +ReturnValue_t PDU1Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CONV_EN_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CONV_EN_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CONV_EN_3, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CONV_EN_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CONV_EN_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CONV_EN_3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_ACS_BOARD_SIDE_A, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_BOOTCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_BOOTCNT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_RESETCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_BATT_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_BOOTCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_BOOTCNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_UPTIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_RESETCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_BATT_MODE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_ACS_BOARD_SIDE_A, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_5, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_7, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_0_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_1_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_2_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_3_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_4_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_5_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_6_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_7_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_0_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_1_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_2_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_3_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_4_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_5_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_6_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_7_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_GND, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_I2C, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CAN, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_GND_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_I2C_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CAN_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_GND, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_I2C, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CAN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_GND_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_I2C_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CAN_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT2, new PoolEntry( { 0 })); - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t PDU1Handler::printStatus(DeviceCommandId_t cmd) { - switch(cmd) { - case(GOMSPACE::PRINT_SWITCH_V_I): { - PoolReadGuard pg(&pdu1HkTableDataset); - ReturnValue_t readResult = pg.getReadResult(); - if(readResult != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Reading PDU1 HK table failed!" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - printHkTable(); - return HasReturnvaluesIF::RETURN_OK; + switch (cmd) { + case (GOMSPACE::PRINT_SWITCH_V_I): { + PoolReadGuard pg(&pdu1HkTableDataset); + ReturnValue_t readResult = pg.getReadResult(); + if (readResult != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Reading PDU1 HK table failed!" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + printHkTable(); + return HasReturnvaluesIF::RETURN_OK; } default: { - return HasReturnvaluesIF::RETURN_FAILED; - } + return HasReturnvaluesIF::RETURN_FAILED; } + } } void PDU1Handler::printHkTable() { - sif::info << "PDU1 Info: SwitchState, Currents [mA], Voltages [mV]" << std::endl; - sif::info << std::setw(30) << std::left << "TCS Board" << std::dec << "| " << - unsigned(pdu1HkTableDataset.outEnabledTCSBoard3V3.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutTCSBoard3V3.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutTCSBoard3V3.value << std::endl; - sif::info << std::setw(30) << std::left << "Syrlinks" << std::dec << "| " << - unsigned(pdu1HkTableDataset.outEnabledSyrlinks.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutSyrlinks.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutSyrlinks.value << std::endl; - sif::info << std::setw(30) << std::left << "Star Tracker" << std::dec << "| " << - static_cast(pdu1HkTableDataset.outEnabledStarTracker.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutStarTracker.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutStarTracker.value << std::endl; - sif::info << std::setw(30) << std::left << "MGT" << std::dec << "| " << - static_cast(pdu1HkTableDataset.outEnabledMGT.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutMGT.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutMGT.value << std::endl; - sif::info << std::setw(30) << std::left << "SuS nominal" << std::dec << "| " << - static_cast(pdu1HkTableDataset.outEnabledSUSNominal.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutSUSNominal.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutSUSNominal.value << std::endl; - sif::info << std::setw(30) << std::left << "Solar Cell Experiment" << std::dec << "| " << - static_cast(pdu1HkTableDataset.outEnabledSolarCellExp.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutSolarCellExp.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutSolarCellExp.value << std::endl; - sif::info << std::setw(30) << std::left << "PLOC" << std::dec << "| " << - static_cast(pdu1HkTableDataset.outEnabledPLOC.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutPLOC.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutPLOC.value << std::endl; - sif::info << std::setw(30) << std::left << "ACS Side A" << std::dec << "| " << - static_cast(pdu1HkTableDataset.outEnabledAcsBoardSideA.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutACSBoardSideA.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutACSBoardSideA.value << std::endl; - sif::info << std::setw(30) << std::left << "Channel 8" << std::dec << "| " << - static_cast(pdu1HkTableDataset.outEnabledChannel8.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutChannel8.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutChannel8.value << std::right << std::endl; + sif::info << "PDU1 Info: SwitchState, Currents [mA], Voltages [mV]" << std::endl; + sif::info << std::setw(30) << std::left << "TCS Board" << std::dec << "| " + << unsigned(pdu1HkTableDataset.outEnabledTCSBoard3V3.value) << ", " << std::setw(4) + << std::right << pdu1HkTableDataset.currentOutTCSBoard3V3.value << ", " << std::setw(4) + << pdu1HkTableDataset.voltageOutTCSBoard3V3.value << std::endl; + sif::info << std::setw(30) << std::left << "Syrlinks" << std::dec << "| " + << unsigned(pdu1HkTableDataset.outEnabledSyrlinks.value) << ", " << std::setw(4) + << std::right << pdu1HkTableDataset.currentOutSyrlinks.value << ", " << std::setw(4) + << pdu1HkTableDataset.voltageOutSyrlinks.value << std::endl; + sif::info << std::setw(30) << std::left << "Star Tracker" << std::dec << "| " + << static_cast(pdu1HkTableDataset.outEnabledStarTracker.value) << ", " + << std::setw(4) << std::right << pdu1HkTableDataset.currentOutStarTracker.value << ", " + << std::setw(4) << pdu1HkTableDataset.voltageOutStarTracker.value << std::endl; + sif::info << std::setw(30) << std::left << "MGT" << std::dec << "| " + << static_cast(pdu1HkTableDataset.outEnabledMGT.value) << ", " + << std::setw(4) << std::right << pdu1HkTableDataset.currentOutMGT.value << ", " + << std::setw(4) << pdu1HkTableDataset.voltageOutMGT.value << std::endl; + sif::info << std::setw(30) << std::left << "SuS nominal" << std::dec << "| " + << static_cast(pdu1HkTableDataset.outEnabledSUSNominal.value) << ", " + << std::setw(4) << std::right << pdu1HkTableDataset.currentOutSUSNominal.value << ", " + << std::setw(4) << pdu1HkTableDataset.voltageOutSUSNominal.value << std::endl; + sif::info << std::setw(30) << std::left << "Solar Cell Experiment" << std::dec << "| " + << static_cast(pdu1HkTableDataset.outEnabledSolarCellExp.value) << ", " + << std::setw(4) << std::right << pdu1HkTableDataset.currentOutSolarCellExp.value << ", " + << std::setw(4) << pdu1HkTableDataset.voltageOutSolarCellExp.value << std::endl; + sif::info << std::setw(30) << std::left << "PLOC" << std::dec << "| " + << static_cast(pdu1HkTableDataset.outEnabledPLOC.value) << ", " + << std::setw(4) << std::right << pdu1HkTableDataset.currentOutPLOC.value << ", " + << std::setw(4) << pdu1HkTableDataset.voltageOutPLOC.value << std::endl; + sif::info << std::setw(30) << std::left << "ACS Side A" << std::dec << "| " + << static_cast(pdu1HkTableDataset.outEnabledAcsBoardSideA.value) << ", " + << std::setw(4) << std::right << pdu1HkTableDataset.currentOutACSBoardSideA.value + << ", " << std::setw(4) << pdu1HkTableDataset.voltageOutACSBoardSideA.value + << std::endl; + sif::info << std::setw(30) << std::left << "Channel 8" << std::dec << "| " + << static_cast(pdu1HkTableDataset.outEnabledChannel8.value) << ", " + << std::setw(4) << std::right << pdu1HkTableDataset.currentOutChannel8.value << ", " + << std::setw(4) << pdu1HkTableDataset.voltageOutChannel8.value << std::right + << std::endl; } - diff --git a/mission/devices/PDU1Handler.h b/mission/devices/PDU1Handler.h index 3df99776..0715b078 100644 --- a/mission/devices/PDU1Handler.h +++ b/mission/devices/PDU1Handler.h @@ -19,27 +19,28 @@ * ACS 3.3V for Side A group, channel 7 * Unoccupied, 5V, channel 8 */ -class PDU1Handler: public GomspaceDeviceHandler { -public: - PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); - virtual ~PDU1Handler(); +class PDU1Handler : public GomspaceDeviceHandler { + public: + PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + virtual ~PDU1Handler(); - virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; -protected: - /** - * @brief In MODE_NORMAL, a command will be built periodically by this function. - */ - 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; + virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; -private: - /** Dataset for the housekeeping table of the PDU1 */ - PDU1::PDU1HkTableDataset pdu1HkTableDataset; + protected: + /** + * @brief In MODE_NORMAL, a command will be built periodically by this function. + */ + 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; - void printHkTable(); - void parseHkTableReply(const uint8_t *packet); + private: + /** Dataset for the housekeeping table of the PDU1 */ + PDU1::PDU1HkTableDataset pdu1HkTableDataset; + + void printHkTable(); + void parseHkTableReply(const uint8_t* packet); }; #endif /* MISSION_DEVICES_PDU1Handler_H_ */ diff --git a/mission/devices/PDU2Handler.cpp b/mission/devices/PDU2Handler.cpp index 287fdaf3..b5c34af6 100644 --- a/mission/devices/PDU2Handler.cpp +++ b/mission/devices/PDU2Handler.cpp @@ -1,378 +1,423 @@ -#include "OBSWConfig.h" #include "PDU2Handler.h" -#include #include +#include -PDU2Handler::PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - GomspaceDeviceHandler(objectId, comIF, comCookie, PDU::MAX_CONFIGTABLE_ADDRESS, - PDU::MAX_HKTABLE_ADDRESS, PDU::HK_TABLE_REPLY_SIZE, &pdu2HkTableDataset), - pdu2HkTableDataset(this) { -} +#include "OBSWConfig.h" -PDU2Handler::~PDU2Handler() { -} +PDU2Handler::PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie) + : GomspaceDeviceHandler(objectId, comIF, comCookie, PDU::MAX_CONFIGTABLE_ADDRESS, + PDU::MAX_HKTABLE_ADDRESS, PDU::HK_TABLE_REPLY_SIZE, + &pdu2HkTableDataset), + pdu2HkTableDataset(this) {} -ReturnValue_t PDU2Handler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - *id = GOMSPACE::REQUEST_HK_TABLE; - return buildCommandFromCommand(*id, NULL, 0); +PDU2Handler::~PDU2Handler() {} + +ReturnValue_t PDU2Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + *id = GOMSPACE::REQUEST_HK_TABLE; + return buildCommandFromCommand(*id, NULL, 0); } void PDU2Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) { - - parseHkTableReply(packet); - /** - * Hk table will be sent to the commander if hk table request was not triggered by the - * PDU2Handler itself. - */ - handleDeviceTM(&pdu2HkTableDataset, id, true); + parseHkTableReply(packet); + /** + * Hk table will be sent to the commander if hk table request was not triggered by the + * PDU2Handler itself. + */ + handleDeviceTM(&pdu2HkTableDataset, id, true); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PDU2 == 1 - pdu2HkTableDataset.read(); - sif::info << "PDU2 Q7S current voltage: " << pdu2HkTableDataset.voltageOutQ7S << " mV" << std::endl; - sif::info << "PDU2 VCC: " << pdu2HkTableDataset.vcc << " mV" << std::endl; - float vbat = pdu2HkTableDataset.vbat.value * 0.1; - sif::info << "PDU2 VBAT: " << vbat << std::endl; - float temperatureC = pdu2HkTableDataset.temperature.value * 0.1; - sif::info << "PDU2 Temperature: " << temperatureC << " °C" << std::endl; - printOutputSwitchStates(); - sif::info << "PDU2 uptime: " << pdu2HkTableDataset.uptime << " seconds" << std::endl; - sif::info << "PDU2 battery mode: " << unsigned(pdu2HkTableDataset.battMode.value) << std::endl; - sif::info << "PDU2 ground watchdog reboots: " << pdu2HkTableDataset.gndWdtReboots << std::endl; - sif::info << "PDU2 ground watchdog timer seconds left: " + pdu2HkTableDataset.read(); + sif::info << "PDU2 Q7S current voltage: " << pdu2HkTableDataset.voltageOutQ7S << " mV" + << std::endl; + sif::info << "PDU2 VCC: " << pdu2HkTableDataset.vcc << " mV" << std::endl; + float vbat = pdu2HkTableDataset.vbat.value * 0.1; + sif::info << "PDU2 VBAT: " << vbat << std::endl; + float temperatureC = pdu2HkTableDataset.temperature.value * 0.1; + sif::info << "PDU2 Temperature: " << temperatureC << " °C" << std::endl; + printOutputSwitchStates(); + sif::info << "PDU2 uptime: " << pdu2HkTableDataset.uptime << " seconds" << std::endl; + sif::info << "PDU2 battery mode: " << unsigned(pdu2HkTableDataset.battMode.value) << std::endl; + sif::info << "PDU2 ground watchdog reboots: " << pdu2HkTableDataset.gndWdtReboots << std::endl; + sif::info << "PDU2 ground watchdog timer seconds left: " << pdu2HkTableDataset.groundWatchdogSecondsLeft << " seconds" << std::endl; - sif::info << "PDU2 csp1 watchdog pings before reboot: " + sif::info << "PDU2 csp1 watchdog pings before reboot: " << unsigned(pdu2HkTableDataset.csp1WatchdogPingsLeft.value) << std::endl; - sif::info << "PDU2 csp2 watchdog pings before reboot: " + sif::info << "PDU2 csp2 watchdog pings before reboot: " << unsigned(pdu2HkTableDataset.csp2WatchdogPingsLeft.value) << std::endl; - pdu2HkTableDataset.commit(); + pdu2HkTableDataset.commit(); #endif } void PDU2Handler::parseHkTableReply(const uint8_t *packet) { - uint16_t dataOffset = 0; - pdu2HkTableDataset.read(); - /** - * Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table - * address. - */ - dataOffset += 12; - pdu2HkTableDataset.currentOutQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutPayloadPCDUCh1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutReactionWheels = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutTCSBoardHeaterIn = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutSUSRedundant = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutDeplMechanism = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutPayloadPCDUCh6 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutACSBoardSideB = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutPayloadCamera = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + uint16_t dataOffset = 0; + pdu2HkTableDataset.read(); + /** + * Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table + * address. + */ + dataOffset += 12; + pdu2HkTableDataset.currentOutQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutPayloadPCDUCh1 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutReactionWheels = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutTCSBoardHeaterIn = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutSUSRedundant = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutDeplMechanism = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutPayloadPCDUCh6 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutACSBoardSideB = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutPayloadCamera = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu2HkTableDataset.voltageOutQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutPayloadPCDUCh1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutReactionWheels = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutTCSBoardHeaterIn = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutSUSRedundant = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutDeplMechanism = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutPayloadPCDUCh6 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutACSBoardSideB = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutPayloadCamera = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + pdu2HkTableDataset.voltageOutQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutPayloadPCDUCh1 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutReactionWheels = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutTCSBoardHeaterIn = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutSUSRedundant = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutDeplMechanism = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutPayloadPCDUCh6 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutACSBoardSideB = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutPayloadCamera = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu2HkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.temperature = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + pdu2HkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.temperature = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu2HkTableDataset.converterEnable1 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.converterEnable2 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.converterEnable3 = *(packet + dataOffset); - dataOffset += 3; + pdu2HkTableDataset.converterEnable1 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.converterEnable2 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.converterEnable3 = *(packet + dataOffset); + dataOffset += 3; - pdu2HkTableDataset.outEnabledQ7S = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledPlPCDUCh1 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledReactionWheels = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledTCSBoardHeaterIn = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledSUSRedundant = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledDeplMechanism = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledPlPCDUCh6 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledAcsBoardSideB = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledPayloadCamera = *(packet + dataOffset); - dataOffset += 3; + pdu2HkTableDataset.outEnabledQ7S = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledPlPCDUCh1 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledReactionWheels = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledTCSBoardHeaterIn = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledSUSRedundant = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledDeplMechanism = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledPlPCDUCh6 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledAcsBoardSideB = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledPayloadCamera = *(packet + dataOffset); + dataOffset += 3; - pdu2HkTableDataset.bootcause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.bootcount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.resetcause = *(packet + dataOffset + 1) << 8 | *(packet + dataOffset); - dataOffset += 4; - pdu2HkTableDataset.battMode = *(packet + dataOffset); - /* +10 because here begins the second gomspace csp packet */ - dataOffset += 3 + 10; + pdu2HkTableDataset.bootcause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.bootcount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.resetcause = *(packet + dataOffset + 1) << 8 | *(packet + dataOffset); + dataOffset += 4; + pdu2HkTableDataset.battMode = *(packet + dataOffset); + /* +10 because here begins the second gomspace csp packet */ + dataOffset += 3 + 10; - pdu2HkTableDataset.latchupsQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsPayloadPcduCh1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsRw = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsTcsBoardHeaterIn = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsSusRedundant = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsDeplMenchanism = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsPayloadPcduCh6 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsAcsBoardSideB = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsPayloadCamera = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + pdu2HkTableDataset.latchupsQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsPayloadPcduCh1 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsRw = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsTcsBoardHeaterIn = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsSusRedundant = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsDeplMenchanism = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsPayloadPcduCh6 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsAcsBoardSideB = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsPayloadCamera = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu2HkTableDataset.device0 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device1 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device2 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device3 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device4 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device5 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device6 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device7 = *(packet + dataOffset); - dataOffset += 3; + pdu2HkTableDataset.device0 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device1 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device2 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device3 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device4 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device5 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device6 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device7 = *(packet + dataOffset); + dataOffset += 3; - pdu2HkTableDataset.device0Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device1Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device2Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device3Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device4Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device5Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device6Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device7Status = *(packet + dataOffset); - dataOffset += 3; + pdu2HkTableDataset.device0Status = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device1Status = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device2Status = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device3Status = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device4Status = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device5Status = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device6Status = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device7Status = *(packet + dataOffset); + dataOffset += 3; - pdu2HkTableDataset.gndWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.i2cWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.canWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.csp1WdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.csp2WdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.groundWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.i2cWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.canWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.csp1WatchdogPingsLeft = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.csp2WatchdogPingsLeft = *(packet + dataOffset); + pdu2HkTableDataset.gndWdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.i2cWdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.canWdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.csp1WdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.csp2WdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.groundWatchdogSecondsLeft = + *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.i2cWatchdogSecondsLeft = + *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.canWatchdogSecondsLeft = + *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.csp1WatchdogPingsLeft = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.csp2WatchdogPingsLeft = *(packet + dataOffset); - pdu2HkTableDataset.commit(); - pdu2HkTableDataset.setChanged(true); + pdu2HkTableDataset.commit(); + pdu2HkTableDataset.setChanged(true); } -ReturnValue_t PDU2Handler::initializeLocalDataPool( - localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { +ReturnValue_t PDU2Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_Q7S, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_RW, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_SUS_REDUNDANT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_Q7S, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_RW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_SUS_REDUNDANT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_Q7S, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_RW, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_Q7S, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_RW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CONV_EN_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CONV_EN_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CONV_EN_3, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CONV_EN_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CONV_EN_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CONV_EN_3, new PoolEntry( { 0 })); - - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_Q7S, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_RW, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_Q7S, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_RW, new PoolEntry({0})); #if BOARD_TE0720 == 1 - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry( { 1 })); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry({1})); #else - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry({0})); #endif - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_SUS_REDUNDANT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_DEPLOYMENT_MECHANISM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_ACS_BOARD_SIDE_B, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_CAMERA, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_SUS_REDUNDANT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_DEPLOYMENT_MECHANISM, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_ACS_BOARD_SIDE_B, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_CAMERA, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_BOOTCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_BOOTCNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_UPTIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_RESETCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_BATT_MODE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_BOOTCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_BOOTCNT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_RESETCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_BATT_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_Q7S, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_RW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_SUS_REDUNDANT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_DEPLOYMENT_MECHANISM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_ACS_BOARD_SIDE_B, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_CAMERA, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_Q7S, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_RW, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_SUS_REDUNDANT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_DEPLOYMENT_MECHANISM, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_ACS_BOARD_SIDE_B, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_CAMERA, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_5, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_7, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_0_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_1_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_2_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_3_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_4_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_5_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_6_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_7_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_0_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_1_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_2_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_3_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_4_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_5_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_6_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_7_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_GND, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_I2C, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CAN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_GND_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_I2C_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CAN_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_GND, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_I2C, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CAN, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_GND_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_I2C_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CAN_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT2, new PoolEntry({0})); - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t PDU2Handler::printStatus(DeviceCommandId_t cmd) { - switch(cmd) { - case(GOMSPACE::PRINT_SWITCH_V_I): { - PoolReadGuard pg(&pdu2HkTableDataset); - ReturnValue_t readResult = pg.getReadResult(); - if(readResult != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Reading PDU1 HK table failed!" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - printHkTable(); - return HasReturnvaluesIF::RETURN_OK; + switch (cmd) { + case (GOMSPACE::PRINT_SWITCH_V_I): { + PoolReadGuard pg(&pdu2HkTableDataset); + ReturnValue_t readResult = pg.getReadResult(); + if (readResult != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Reading PDU1 HK table failed!" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + printHkTable(); + return HasReturnvaluesIF::RETURN_OK; } default: { - return HasReturnvaluesIF::RETURN_FAILED; - } + return HasReturnvaluesIF::RETURN_FAILED; } + } } void PDU2Handler::printHkTable() { - sif::info << "PDU2 Info: SwitchState, Currents [mA], Voltages [mV]" << std::endl; - sif::info << std::setw(30) << std::left << "Q7S" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledQ7S.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutQ7S.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutQ7S.value << std::endl; - sif::info << std::setw(30) << std::left << "Payload PCDU Channel 1" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledPlPCDUCh1.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutPayloadPCDUCh1.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutPayloadPCDUCh1.value << std::endl; - sif::info << std::setw(30) << std::left << "Reaction Wheels" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledReactionWheels.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutReactionWheels.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutReactionWheels.value << std::endl; - sif::info << std::setw(30) << std::left << "TCS Board 8V heater input" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledTCSBoardHeaterIn.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutTCSBoardHeaterIn.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutTCSBoardHeaterIn.value << std::endl; - sif::info << std::setw(30) << std::left << "Redundant SUS group" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledSUSRedundant.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutSUSRedundant.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutSUSRedundant.value << std::endl; - sif::info << std::setw(30) << std::left << "Deployment mechanism" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledDeplMechanism.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutDeplMechanism.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutDeplMechanism.value << std::endl; - sif::info << std::setw(30) << std::left << "Payload PCDU Channel 6" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledPlPCDUCh6.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutPayloadPCDUCh6.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutPayloadPCDUCh6.value<< std::endl; - sif::info << std::setw(30) << std::left << "ACS Board Side B" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledAcsBoardSideB.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutACSBoardSideB.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutACSBoardSideB.value << std::endl; - sif::info << std::setw(30) << std::left << "Payload Camera enable state" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledPayloadCamera.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutPayloadCamera.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutPayloadCamera.value << std::right << std::endl; + sif::info << "PDU2 Info: SwitchState, Currents [mA], Voltages [mV]" << std::endl; + sif::info << std::setw(30) << std::left << "Q7S" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledQ7S.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutQ7S.value << ", " << std::setw(4) + << pdu2HkTableDataset.voltageOutQ7S.value << std::endl; + sif::info << std::setw(30) << std::left << "Payload PCDU Channel 1" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledPlPCDUCh1.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutPayloadPCDUCh1.value << ", " + << std::setw(4) << pdu2HkTableDataset.voltageOutPayloadPCDUCh1.value << std::endl; + sif::info << std::setw(30) << std::left << "Reaction Wheels" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledReactionWheels.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutReactionWheels.value << ", " + << std::setw(4) << pdu2HkTableDataset.voltageOutReactionWheels.value << std::endl; + sif::info << std::setw(30) << std::left << "TCS Board 8V heater input" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledTCSBoardHeaterIn.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutTCSBoardHeaterIn.value << ", " + << std::setw(4) << pdu2HkTableDataset.voltageOutTCSBoardHeaterIn.value << std::endl; + sif::info << std::setw(30) << std::left << "Redundant SUS group" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledSUSRedundant.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutSUSRedundant.value << ", " << std::setw(4) + << pdu2HkTableDataset.voltageOutSUSRedundant.value << std::endl; + sif::info << std::setw(30) << std::left << "Deployment mechanism" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledDeplMechanism.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutDeplMechanism.value << ", " + << std::setw(4) << pdu2HkTableDataset.voltageOutDeplMechanism.value << std::endl; + sif::info << std::setw(30) << std::left << "Payload PCDU Channel 6" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledPlPCDUCh6.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutPayloadPCDUCh6.value << ", " + << std::setw(4) << pdu2HkTableDataset.voltageOutPayloadPCDUCh6.value << std::endl; + sif::info << std::setw(30) << std::left << "ACS Board Side B" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledAcsBoardSideB.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutACSBoardSideB.value << ", " + << std::setw(4) << pdu2HkTableDataset.voltageOutACSBoardSideB.value << std::endl; + sif::info << std::setw(30) << std::left << "Payload Camera enable state" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledPayloadCamera.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutPayloadCamera.value << ", " + << std::setw(4) << pdu2HkTableDataset.voltageOutPayloadCamera.value << std::right + << std::endl; } diff --git a/mission/devices/PDU2Handler.h b/mission/devices/PDU2Handler.h index c44d1267..258b616d 100644 --- a/mission/devices/PDU2Handler.h +++ b/mission/devices/PDU2Handler.h @@ -1,9 +1,10 @@ #ifndef MISSION_DEVICES_PDU2HANDLER_H_ #define MISSION_DEVICES_PDU2HANDLER_H_ -#include "GomspaceDeviceHandler.h" #include +#include "GomspaceDeviceHandler.h" + /** * @brief This is the device handler for the PDU2. * @@ -18,30 +19,29 @@ * ACS Board (Gyro, MGMs, GPS), 3.3V channel 7 * Payload Camera, 8V, channel 8 */ -class PDU2Handler: public GomspaceDeviceHandler { -public: - PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); - virtual ~PDU2Handler(); +class PDU2Handler : public GomspaceDeviceHandler { + public: + PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + virtual ~PDU2Handler(); - virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; + virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; -protected: - /** - * @brief As soon as the device is in MODE_NORMAL, this function is executed periodically. - */ - 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; + protected: + /** + * @brief As soon as the device is in MODE_NORMAL, this function is executed periodically. + */ + 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; -private: + private: + /** Dataset for the housekeeping table of the PDU2 */ + PDU2::PDU2HkTableDataset pdu2HkTableDataset; - /** Dataset for the housekeeping table of the PDU2 */ - PDU2::PDU2HkTableDataset pdu2HkTableDataset; + void printHkTable(); - void printHkTable(); - - void parseHkTableReply(const uint8_t *packet); + void parseHkTableReply(const uint8_t* packet); }; #endif /* MISSION_DEVICES_PDU2HANDLER_H_ */ diff --git a/mission/devices/PlocMPSoCHandler.cpp b/mission/devices/PlocMPSoCHandler.cpp index dcc81ef7..07b9b0fa 100644 --- a/mission/devices/PlocMPSoCHandler.cpp +++ b/mission/devices/PlocMPSoCHandler.cpp @@ -1,497 +1,473 @@ #include "PlocMPSoCHandler.h" + +#include +#include + #include "OBSWConfig.h" -#include -#include +PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie) + : DeviceHandlerBase(objectId, comIF, comCookie) { + if (comCookie == NULL) { + sif::error << "PlocMPSoCHandler: Invalid com cookie" << std::endl; + } +} -PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - DeviceHandlerBase(objectId, comIF, comCookie) { - if (comCookie == NULL) { - sif::error << "PlocMPSoCHandler: Invalid com cookie" << std::endl; +PlocMPSoCHandler::~PlocMPSoCHandler() {} + +void PlocMPSoCHandler::doStartUp() { + if (mode == _MODE_START_UP) { + setMode(MODE_ON); + } +} + +void PlocMPSoCHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } + +ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + return RETURN_OK; +} + +ReturnValue_t PlocMPSoCHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t* commandData, + size_t commandDataLen) { + switch (deviceCommand) { + case (PLOC_MPSOC::TC_MEM_WRITE): { + return prepareTcMemWriteCommand(commandData, commandDataLen); } -} - -PlocMPSoCHandler::~PlocMPSoCHandler() { -} - - -void PlocMPSoCHandler::doStartUp(){ - if(mode == _MODE_START_UP){ - setMode(MODE_ON); - } -} - -void PlocMPSoCHandler::doShutDown(){ - setMode(_MODE_POWER_DOWN); -} - -ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - return RETURN_OK; -} - -ReturnValue_t PlocMPSoCHandler::buildTransitionDeviceCommand( - DeviceCommandId_t * id){ - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t * commandData, - size_t commandDataLen) { - switch(deviceCommand) { - case(PLOC_MPSOC::TC_MEM_WRITE): { - return prepareTcMemWriteCommand(commandData, commandDataLen); - } - case(PLOC_MPSOC::TC_MEM_READ): { - return prepareTcMemReadCommand(commandData, commandDataLen); - } - default: - sif::debug << "PlocMPSoCHandler::buildCommandFromCommand: Command not implemented" << std::endl; - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; + case (PLOC_MPSOC::TC_MEM_READ): { + return prepareTcMemReadCommand(commandData, commandDataLen); + } + default: + sif::debug << "PlocMPSoCHandler::buildCommandFromCommand: Command not implemented" + << std::endl; + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } void PlocMPSoCHandler::fillCommandAndReplyMap() { - this->insertInCommandMap(PLOC_MPSOC::TC_MEM_WRITE); - this->insertInCommandMap(PLOC_MPSOC::TC_MEM_READ); - this->insertInReplyMap(PLOC_MPSOC::ACK_REPORT, 1, nullptr, PLOC_MPSOC::SIZE_ACK_REPORT); - this->insertInReplyMap(PLOC_MPSOC::EXE_REPORT, 3, nullptr, PLOC_MPSOC::SIZE_EXE_REPORT); - this->insertInReplyMap(PLOC_MPSOC::TM_MEMORY_READ_REPORT, 2, nullptr, PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT); + this->insertInCommandMap(PLOC_MPSOC::TC_MEM_WRITE); + this->insertInCommandMap(PLOC_MPSOC::TC_MEM_READ); + this->insertInReplyMap(PLOC_MPSOC::ACK_REPORT, 1, nullptr, PLOC_MPSOC::SIZE_ACK_REPORT); + this->insertInReplyMap(PLOC_MPSOC::EXE_REPORT, 3, nullptr, PLOC_MPSOC::SIZE_EXE_REPORT); + this->insertInReplyMap(PLOC_MPSOC::TM_MEMORY_READ_REPORT, 2, nullptr, + PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT); } -ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { +ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + uint16_t apid = (*(start) << 8 | *(start + 1)) & APID_MASK; - uint16_t apid = (*(start) << 8 | *(start + 1)) & APID_MASK; + switch (apid) { + case (PLOC_MPSOC::APID_ACK_SUCCESS): + *foundLen = PLOC_MPSOC::SIZE_ACK_REPORT; + *foundId = PLOC_MPSOC::ACK_REPORT; + break; + case (PLOC_MPSOC::APID_ACK_FAILURE): + *foundLen = PLOC_MPSOC::SIZE_ACK_REPORT; + *foundId = PLOC_MPSOC::ACK_REPORT; + break; + case (PLOC_MPSOC::APID_TM_MEMORY_READ_REPORT): + *foundLen = PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT; + *foundId = PLOC_MPSOC::TM_MEMORY_READ_REPORT; + break; + case (PLOC_MPSOC::APID_EXE_SUCCESS): + *foundLen = PLOC_MPSOC::SIZE_EXE_REPORT; + *foundId = PLOC_MPSOC::EXE_REPORT; + break; + case (PLOC_MPSOC::APID_EXE_FAILURE): + *foundLen = PLOC_MPSOC::SIZE_EXE_REPORT; + *foundId = PLOC_MPSOC::EXE_REPORT; + break; + default: { + sif::debug << "PlocMPSoCHandler::scanForReply: Reply has invalid apid" << std::endl; + *foundLen = remainingSize; + return INVALID_APID; + } + } - switch(apid) { - case(PLOC_MPSOC::APID_ACK_SUCCESS): - *foundLen = PLOC_MPSOC::SIZE_ACK_REPORT; - *foundId = PLOC_MPSOC::ACK_REPORT; - break; - case(PLOC_MPSOC::APID_ACK_FAILURE): - *foundLen = PLOC_MPSOC::SIZE_ACK_REPORT; - *foundId = PLOC_MPSOC::ACK_REPORT; - break; - case(PLOC_MPSOC::APID_TM_MEMORY_READ_REPORT): - *foundLen = PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT; - *foundId = PLOC_MPSOC::TM_MEMORY_READ_REPORT; - break; - case(PLOC_MPSOC::APID_EXE_SUCCESS): - *foundLen = PLOC_MPSOC::SIZE_EXE_REPORT; - *foundId = PLOC_MPSOC::EXE_REPORT; - break; - case(PLOC_MPSOC::APID_EXE_FAILURE): - *foundLen = PLOC_MPSOC::SIZE_EXE_REPORT; - *foundId = PLOC_MPSOC::EXE_REPORT; - break; - default: { - sif::debug << "PlocMPSoCHandler::scanForReply: Reply has invalid apid" << std::endl; - *foundLen = remainingSize; - return INVALID_APID; - } - } + /** + * This should normally never fail. However, this function is also responsible for incrementing + * the packet sequence count why it is called here. + */ + result = checkPacketSequenceCount(start); - /** - * This should normally never fail. However, this function is also responsible for incrementing - * the packet sequence count why it is called here. - */ - result = checkPacketSequenceCount(start); - - return result; + return result; } -ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { +ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; - - switch (id) { + switch (id) { case PLOC_MPSOC::ACK_REPORT: { - result = handleAckReport(packet); - break; + result = handleAckReport(packet); + break; } case (PLOC_MPSOC::TM_MEMORY_READ_REPORT): { - result = handleMemoryReadReport(packet); - break; + result = handleMemoryReadReport(packet); + break; } case (PLOC_MPSOC::EXE_REPORT): { - result = handleExecutionReport(packet); - break; + result = handleExecutionReport(packet); + break; } default: { - sif::debug << "PlocMPSoCHandler::interpretDeviceReply: Unknown device reply id" << std::endl; - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } + sif::debug << "PlocMPSoCHandler::interpretDeviceReply: Unknown device reply id" << std::endl; + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; } + } - return result; + return result; } -void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid(){ +void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid() {} -} - -uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){ - return 500; -} +uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } ReturnValue_t PlocMPSoCHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { - - return HasReturnvaluesIF::RETURN_OK; + LocalDataPoolManager& poolManager) { + return HasReturnvaluesIF::RETURN_OK; } -void PlocMPSoCHandler::setModeNormal() { - mode = MODE_NORMAL; +void PlocMPSoCHandler::setModeNormal() { mode = MODE_NORMAL; } + +ReturnValue_t PlocMPSoCHandler::prepareTcMemWriteCommand(const uint8_t* commandData, + size_t commandDataLen) { + const uint32_t memoryAddress = *(commandData) << 24 | *(commandData + 1) << 16 | + *(commandData + 2) << 8 | *(commandData + 3); + const uint32_t memoryData = *(commandData + 4) << 24 | *(commandData + 5) << 16 | + *(commandData + 6) << 8 | *(commandData + 7); + packetSequenceCount = (packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK; + PLOC_MPSOC::TcMemWrite tcMemWrite(memoryAddress, memoryData, packetSequenceCount); + if (tcMemWrite.getFullSize() > PLOC_MPSOC::MAX_COMMAND_SIZE) { + sif::debug << "PlocMPSoCHandler::prepareTcMemWriteCommand: Command too big" << std::endl; + return RETURN_FAILED; + } + memcpy(commandBuffer, tcMemWrite.getWholeData(), tcMemWrite.getFullSize()); + rawPacket = commandBuffer; + rawPacketLen = tcMemWrite.getFullSize(); + nextReplyId = PLOC_MPSOC::ACK_REPORT; + return RETURN_OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcMemWriteCommand(const uint8_t * commandData, - size_t commandDataLen) { - const uint32_t memoryAddress = *(commandData) << 24 | *(commandData + 1) << 16 - | *(commandData + 2) << 8 | *(commandData + 3); - const uint32_t memoryData = *(commandData + 4) << 24 | *(commandData + 5) << 16 - | *(commandData + 6) << 8 | *(commandData + 7); - packetSequenceCount = (packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK; - PLOC_MPSOC::TcMemWrite tcMemWrite(memoryAddress, memoryData, packetSequenceCount); - if (tcMemWrite.getFullSize() > PLOC_MPSOC::MAX_COMMAND_SIZE) { - sif::debug << "PlocMPSoCHandler::prepareTcMemWriteCommand: Command too big" << std::endl; - return RETURN_FAILED; - } - memcpy(commandBuffer, tcMemWrite.getWholeData(), tcMemWrite.getFullSize()); - rawPacket = commandBuffer; - rawPacketLen = tcMemWrite.getFullSize(); - nextReplyId = PLOC_MPSOC::ACK_REPORT; - return RETURN_OK; -} +ReturnValue_t PlocMPSoCHandler::prepareTcMemReadCommand(const uint8_t* commandData, + size_t commandDataLen) { + const uint32_t memoryAddress = *(commandData) << 24 | *(commandData + 1) << 16 | + *(commandData + 2) << 8 | *(commandData + 3); + packetSequenceCount = (packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK; + PLOC_MPSOC::TcMemRead tcMemRead(memoryAddress, packetSequenceCount); + if (tcMemRead.getFullSize() > PLOC_MPSOC::MAX_COMMAND_SIZE) { + sif::debug << "PlocMPSoCHandler::prepareTcMemReadCommand: Command too big" << std::endl; + return RETURN_FAILED; + } + memcpy(commandBuffer, tcMemRead.getWholeData(), tcMemRead.getFullSize()); + rawPacket = commandBuffer; + rawPacketLen = tcMemRead.getFullSize(); + nextReplyId = PLOC_MPSOC::ACK_REPORT; -ReturnValue_t PlocMPSoCHandler::prepareTcMemReadCommand(const uint8_t * commandData, - size_t commandDataLen) { - const uint32_t memoryAddress = *(commandData) << 24 | *(commandData + 1) << 16 - | *(commandData + 2) << 8 | *(commandData + 3); - packetSequenceCount = (packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK; - PLOC_MPSOC::TcMemRead tcMemRead(memoryAddress, packetSequenceCount); - if (tcMemRead.getFullSize() > PLOC_MPSOC::MAX_COMMAND_SIZE) { - sif::debug << "PlocMPSoCHandler::prepareTcMemReadCommand: Command too big" << std::endl; - return RETURN_FAILED; - } - memcpy(commandBuffer, tcMemRead.getWholeData(), tcMemRead.getFullSize()); - rawPacket = commandBuffer; - rawPacketLen = tcMemRead.getFullSize(); - nextReplyId = PLOC_MPSOC::ACK_REPORT; - - return RETURN_OK; + return RETURN_OK; } ReturnValue_t PlocMPSoCHandler::verifyPacket(const uint8_t* start, size_t foundLen) { + uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1); - uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1); + uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2); - uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2); + if (receivedCrc != recalculatedCrc) { + return CRC_FAILURE; + } - if (receivedCrc != recalculatedCrc) { - return CRC_FAILURE; - } - - return RETURN_OK; + return RETURN_OK; } ReturnValue_t PlocMPSoCHandler::handleAckReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_MPSOC::SIZE_ACK_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocMPSoCHandler::handleAckReport: CRC failure" << std::endl; + nextReplyId = PLOC_MPSOC::NONE; + replyRawReplyIfnotWiretapped(data, PLOC_MPSOC::SIZE_ACK_REPORT); + triggerEvent(CRC_FAILURE_EVENT); + sendFailureReport(PLOC_MPSOC::ACK_REPORT, CRC_FAILURE); + disableAllReplies(); + return IGNORE_REPLY_DATA; + } - result = verifyPacket(data, PLOC_MPSOC::SIZE_ACK_REPORT); - if(result == CRC_FAILURE) { - sif::error << "PlocMPSoCHandler::handleAckReport: CRC failure" << std::endl; - nextReplyId = PLOC_MPSOC::NONE; - replyRawReplyIfnotWiretapped(data, PLOC_MPSOC::SIZE_ACK_REPORT); - triggerEvent(CRC_FAILURE_EVENT); - sendFailureReport(PLOC_MPSOC::ACK_REPORT, CRC_FAILURE); - disableAllReplies(); - return IGNORE_REPLY_DATA; + uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; + + switch (apid) { + case PLOC_MPSOC::APID_ACK_FAILURE: { + // TODO: Interpretation of status field in acknowledgment report + sif::debug << "PlocMPSoCHandler::handleAckReport: Received Ack failure report" << std::endl; + DeviceCommandId_t commandId = getPendingCommand(); + if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { + triggerEvent(ACK_FAILURE, commandId); + } + sendFailureReport(PLOC_MPSOC::ACK_REPORT, RECEIVED_ACK_FAILURE); + disableAllReplies(); + nextReplyId = PLOC_MPSOC::NONE; + result = IGNORE_REPLY_DATA; + break; } + case PLOC_MPSOC::APID_ACK_SUCCESS: { + setNextReplyId(); + break; + } + default: { + sif::debug << "PlocMPSoCHandler::handleAckReport: Invalid APID in Ack report" << std::endl; + result = RETURN_FAILED; + break; + } + } - uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; - - switch(apid) { - case PLOC_MPSOC::APID_ACK_FAILURE: { - //TODO: Interpretation of status field in acknowledgment report - sif::debug << "PlocMPSoCHandler::handleAckReport: Received Ack failure report" << std::endl; - DeviceCommandId_t commandId = getPendingCommand(); - if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { - triggerEvent(ACK_FAILURE, commandId); - } - sendFailureReport(PLOC_MPSOC::ACK_REPORT, RECEIVED_ACK_FAILURE); - disableAllReplies(); - nextReplyId = PLOC_MPSOC::NONE; - result = IGNORE_REPLY_DATA; - break; - } - case PLOC_MPSOC::APID_ACK_SUCCESS: { - setNextReplyId(); - break; - } - default: { - sif::debug << "PlocMPSoCHandler::handleAckReport: Invalid APID in Ack report" << std::endl; - result = RETURN_FAILED; - break; - } - } - - return result; + return result; } ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_MPSOC::SIZE_EXE_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocMPSoCHandler::handleExecutionReport: CRC failure" << std::endl; + nextReplyId = PLOC_MPSOC::NONE; + return result; + } - result = verifyPacket(data, PLOC_MPSOC::SIZE_EXE_REPORT); - if(result == CRC_FAILURE) { - sif::error << "PlocMPSoCHandler::handleExecutionReport: CRC failure" << std::endl; - nextReplyId = PLOC_MPSOC::NONE; - return result; - } + uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; - uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; - - switch (apid) { + switch (apid) { case (PLOC_MPSOC::APID_EXE_SUCCESS): { - break; + break; } case (PLOC_MPSOC::APID_EXE_FAILURE): { - //TODO: Interpretation of status field in execution report - sif::error << "PlocMPSoCHandler::handleExecutionReport: Received execution failure report" - << std::endl; - DeviceCommandId_t commandId = getPendingCommand(); - if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { - triggerEvent(EXE_FAILURE, commandId); - } - else { - sif::debug << "PlocMPSoCHandler::handleExecutionReport: Unknown command id" << std::endl; - } - sendFailureReport(PLOC_MPSOC::EXE_REPORT, RECEIVED_EXE_FAILURE); - disableExeReportReply(); - result = IGNORE_REPLY_DATA; - break; + // TODO: Interpretation of status field in execution report + sif::error << "PlocMPSoCHandler::handleExecutionReport: Received execution failure report" + << std::endl; + DeviceCommandId_t commandId = getPendingCommand(); + if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { + triggerEvent(EXE_FAILURE, commandId); + } else { + sif::debug << "PlocMPSoCHandler::handleExecutionReport: Unknown command id" << std::endl; + } + sendFailureReport(PLOC_MPSOC::EXE_REPORT, RECEIVED_EXE_FAILURE); + disableExeReportReply(); + result = IGNORE_REPLY_DATA; + break; } default: { - sif::error << "PlocMPSoCHandler::handleExecutionReport: Unknown APID" << std::endl; - result = RETURN_FAILED; - break; - } + sif::error << "PlocMPSoCHandler::handleExecutionReport: Unknown APID" << std::endl; + result = RETURN_FAILED; + break; } + } - nextReplyId = PLOC_MPSOC::NONE; + nextReplyId = PLOC_MPSOC::NONE; - return result; + return result; } ReturnValue_t PlocMPSoCHandler::handleMemoryReadReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT); - result = verifyPacket(data, PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocMPSoCHandler::handleMemoryReadReport: Memory read report has invalid crc" + << std::endl; + } + /** Send data to commanding queue */ + handleDeviceTM(data + PLOC_MPSOC::DATA_FIELD_OFFSET, PLOC_MPSOC::SIZE_MEM_READ_REPORT_DATA, + PLOC_MPSOC::TM_MEMORY_READ_REPORT); - if(result == CRC_FAILURE) { - sif::error << "PlocMPSoCHandler::handleMemoryReadReport: Memory read report has invalid crc" - << std::endl; - } - /** Send data to commanding queue */ - handleDeviceTM(data + PLOC_MPSOC::DATA_FIELD_OFFSET, PLOC_MPSOC::SIZE_MEM_READ_REPORT_DATA, - PLOC_MPSOC::TM_MEMORY_READ_REPORT); + nextReplyId = PLOC_MPSOC::EXE_REPORT; - nextReplyId = PLOC_MPSOC::EXE_REPORT; - - return result; + return result; } ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command, - uint8_t expectedReplies, bool useAlternateId, - DeviceCommandId_t alternateReplyID) { + uint8_t expectedReplies, bool useAlternateId, + DeviceCommandId_t alternateReplyID) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + uint8_t enabledReplies = 0; - uint8_t enabledReplies = 0; - - switch (command->first) { + switch (command->first) { case PLOC_MPSOC::TC_MEM_WRITE: - enabledReplies = 2; - break; + enabledReplies = 2; + break; case PLOC_MPSOC::TC_MEM_READ: { - enabledReplies = 3; - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_MPSOC::TM_MEMORY_READ_REPORT); - if (result != RETURN_OK) { - sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " - << PLOC_MPSOC::TM_MEMORY_READ_REPORT << " not in replyMap" << std::endl; - } - break; + enabledReplies = 3; + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_MPSOC::TM_MEMORY_READ_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " + << PLOC_MPSOC::TM_MEMORY_READ_REPORT << " not in replyMap" << std::endl; + } + break; } default: - sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Unknown command id" << std::endl; - break; - } + sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Unknown command id" << std::endl; + break; + } - /** - * Every command causes at least one acknowledgment and one execution report. Therefore both - * replies will be enabled here. - */ - result = DeviceHandlerBase::enableReplyInReplyMap(command, - enabledReplies, true, PLOC_MPSOC::ACK_REPORT); - if (result != RETURN_OK) { - sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " << PLOC_MPSOC::ACK_REPORT - << " not in replyMap" << std::endl; - } + /** + * Every command causes at least one acknowledgment and one execution report. Therefore both + * replies will be enabled here. + */ + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_MPSOC::ACK_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " + << PLOC_MPSOC::ACK_REPORT << " not in replyMap" << std::endl; + } - result = DeviceHandlerBase::enableReplyInReplyMap(command, - enabledReplies, true, PLOC_MPSOC::EXE_REPORT); - if (result != RETURN_OK) { - sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " << PLOC_MPSOC::EXE_REPORT - << " not in replyMap" << std::endl; - } + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_MPSOC::EXE_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " + << PLOC_MPSOC::EXE_REPORT << " not in replyMap" << std::endl; + } - return RETURN_OK; + return RETURN_OK; } void PlocMPSoCHandler::setNextReplyId() { - switch(getPendingCommand()) { + switch (getPendingCommand()) { case PLOC_MPSOC::TC_MEM_READ: - nextReplyId = PLOC_MPSOC::TM_MEMORY_READ_REPORT; - break; + nextReplyId = PLOC_MPSOC::TM_MEMORY_READ_REPORT; + break; default: - /* If no telemetry is expected the next reply is always the execution report */ - nextReplyId = PLOC_MPSOC::EXE_REPORT; - break; - } + /* If no telemetry is expected the next reply is always the execution report */ + nextReplyId = PLOC_MPSOC::EXE_REPORT; + break; + } } -size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId){ - - size_t replyLen = 0; - - if (nextReplyId == PLOC_MPSOC::NONE) { - return replyLen; - } - - DeviceReplyIter iter = deviceReplyMap.find(nextReplyId); - if (iter != deviceReplyMap.end()) { - if (iter->second.delayCycles == 0) { - /* Reply inactive */ - return replyLen; - } - replyLen = iter->second.replyLen; - } - else { - sif::debug << "PlocMPSoCHandler::getNextReplyLength: No entry for reply with reply id " - << std::hex << nextReplyId << " in deviceReplyMap" << std::endl; - } +size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) { + size_t replyLen = 0; + if (nextReplyId == PLOC_MPSOC::NONE) { return replyLen; + } + + DeviceReplyIter iter = deviceReplyMap.find(nextReplyId); + if (iter != deviceReplyMap.end()) { + if (iter->second.delayCycles == 0) { + /* Reply inactive */ + return replyLen; + } + replyLen = iter->second.replyLen; + } else { + sif::debug << "PlocMPSoCHandler::getNextReplyLength: No entry for reply with reply id " + << std::hex << nextReplyId << " in deviceReplyMap" << std::endl; + } + + return replyLen; } -void PlocMPSoCHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId) { +void PlocMPSoCHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, + DeviceCommandId_t replyId) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + if (wiretappingMode == RAW) { + /* Data already sent in doGetRead() */ + return; + } - if (wiretappingMode == RAW) { - /* Data already sent in doGetRead() */ - return; - } + DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId); + if (iter == deviceReplyMap.end()) { + sif::debug << "PlocMPSoCHandler::handleDeviceTM: Unknown reply id" << std::endl; + return; + } + MessageQueueId_t queueId = iter->second.command->second.sendReplyTo; - DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId); - if (iter == deviceReplyMap.end()) { - sif::debug << "PlocMPSoCHandler::handleDeviceTM: Unknown reply id" << std::endl; - return; - } - MessageQueueId_t queueId = iter->second.command->second.sendReplyTo; + if (queueId == NO_COMMANDER) { + return; + } - if (queueId == NO_COMMANDER) { - return; - } - - result = actionHelper.reportData(queueId, replyId, data, dataSize); - if (result != RETURN_OK) { - sif::debug << "PlocMPSoCHandler::handleDeviceTM: Failed to report data" << std::endl; - } + result = actionHelper.reportData(queueId, replyId, data, dataSize); + if (result != RETURN_OK) { + sif::debug << "PlocMPSoCHandler::handleDeviceTM: Failed to report data" << std::endl; + } } void PlocMPSoCHandler::disableAllReplies() { + DeviceReplyMap::iterator iter; - DeviceReplyMap::iterator iter; + /* Disable ack reply */ + iter = deviceReplyMap.find(PLOC_MPSOC::ACK_REPORT); + DeviceReplyInfo* info = &(iter->second); + info->delayCycles = 0; + info->command = deviceCommandMap.end(); - /* Disable ack reply */ - iter = deviceReplyMap.find(PLOC_MPSOC::ACK_REPORT); - DeviceReplyInfo *info = &(iter->second); - info->delayCycles = 0; - info->command = deviceCommandMap.end(); + DeviceCommandId_t commandId = getPendingCommand(); - DeviceCommandId_t commandId = getPendingCommand(); - - /* If the command expects a telemetry packet the appropriate tm reply will be disabled here */ - switch (commandId) { + /* If the command expects a telemetry packet the appropriate tm reply will be disabled here */ + switch (commandId) { case PLOC_MPSOC::TC_MEM_WRITE: - break; + break; case PLOC_MPSOC::TC_MEM_READ: { - iter = deviceReplyMap.find(PLOC_MPSOC::TM_MEMORY_READ_REPORT); - info = &(iter->second); - info->delayCycles = 0; - info->command = deviceCommandMap.end(); - break; + iter = deviceReplyMap.find(PLOC_MPSOC::TM_MEMORY_READ_REPORT); + info = &(iter->second); + info->delayCycles = 0; + info->command = deviceCommandMap.end(); + break; } default: { - sif::debug << "PlocMPSoCHandler::disableAllReplies: Unknown command id" << commandId - << std::endl; - break; - } + sif::debug << "PlocMPSoCHandler::disableAllReplies: Unknown command id" << commandId + << std::endl; + break; } + } - /* We must always disable the execution report reply here */ - disableExeReportReply(); + /* We must always disable the execution report reply here */ + disableExeReportReply(); } void PlocMPSoCHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status) { + DeviceReplyIter iter = deviceReplyMap.find(replyId); - DeviceReplyIter iter = deviceReplyMap.find(replyId); + if (iter == deviceReplyMap.end()) { + sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply not in reply map" << std::endl; + return; + } - if (iter == deviceReplyMap.end()) { - sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply not in reply map" << std::endl; - return; - } + DeviceCommandInfo* info = &(iter->second.command->second); - DeviceCommandInfo* info = &(iter->second.command->second); + if (info == nullptr) { + sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply has no active command" << std::endl; + return; + } - if (info == nullptr) { - sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply has no active command" << std::endl; - return; - } - - if (info->sendReplyTo != NO_COMMANDER) { - actionHelper.finish(false, info->sendReplyTo, iter->first, status); - } - info->isExecuting = false; + if (info->sendReplyTo != NO_COMMANDER) { + actionHelper.finish(false, info->sendReplyTo, iter->first, status); + } + info->isExecuting = false; } void PlocMPSoCHandler::disableExeReportReply() { - DeviceReplyIter iter = deviceReplyMap.find(PLOC_MPSOC::EXE_REPORT); - DeviceReplyInfo *info = &(iter->second); - info->delayCycles = 0; - info->command = deviceCommandMap.end(); - /* Expected replies is set to one here. The value will set to 0 in replyToReply() */ - info->command->second.expectedReplies = 0; + DeviceReplyIter iter = deviceReplyMap.find(PLOC_MPSOC::EXE_REPORT); + DeviceReplyInfo* info = &(iter->second); + info->delayCycles = 0; + info->command = deviceCommandMap.end(); + /* Expected replies is set to one here. The value will set to 0 in replyToReply() */ + info->command->second.expectedReplies = 0; } ReturnValue_t PlocMPSoCHandler::checkPacketSequenceCount(const uint8_t* data) { - uint16_t receivedSequenceCount = (*(data + 2) << 8 | *(data + 3)) & PACKET_SEQUENCE_COUNT_MASK; - uint16_t expectedPacketSequenceCount = ((packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK); - if (receivedSequenceCount != expectedPacketSequenceCount) { - sif::debug - << "PlocMPSoCHandler::checkPacketSequenceCount: Packet sequence count mismatch. " - << std::endl; - sif::debug << "Received sequence count: " << receivedSequenceCount << ". OBSW sequence " - << "count: " << expectedPacketSequenceCount << std::endl; - } - packetSequenceCount = receivedSequenceCount; - return RETURN_OK; + uint16_t receivedSequenceCount = (*(data + 2) << 8 | *(data + 3)) & PACKET_SEQUENCE_COUNT_MASK; + uint16_t expectedPacketSequenceCount = ((packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK); + if (receivedSequenceCount != expectedPacketSequenceCount) { + sif::debug << "PlocMPSoCHandler::checkPacketSequenceCount: Packet sequence count mismatch. " + << std::endl; + sif::debug << "Received sequence count: " << receivedSequenceCount << ". OBSW sequence " + << "count: " << expectedPacketSequenceCount << std::endl; + } + packetSequenceCount = receivedSequenceCount; + return RETURN_OK; } diff --git a/mission/devices/PlocMPSoCHandler.h b/mission/devices/PlocMPSoCHandler.h index 2b3f6a57..2b14424f 100644 --- a/mission/devices/PlocMPSoCHandler.h +++ b/mission/devices/PlocMPSoCHandler.h @@ -3,6 +3,7 @@ #include #include + #include /** @@ -18,189 +19,194 @@ * Arbeitsdaten/08_Used%20Components/PLOC&fileid=940960 * @author J. Meier */ -class PlocMPSoCHandler: public DeviceHandlerBase { -public: +class PlocMPSoCHandler : public DeviceHandlerBase { + public: + PlocMPSoCHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + virtual ~PlocMPSoCHandler(); - PlocMPSoCHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); - virtual ~PlocMPSoCHandler(); + /** + * @brief Sets mode to MODE_NORMAL. Can be used for debugging. + */ + void setModeNormal(); - /** - * @brief Sets mode to MODE_NORMAL. Can be used for debugging. - */ - void setModeNormal(); + 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: - void doStartUp() override; - void doShutDown() override; - ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; - ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override; - void fillCommandAndReplyMap() override; - ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t * commandData,size_t commandDataLen) override; - ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize, - DeviceCommandId_t *foundId, size_t *foundLen) override; - ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) override; - void setNormalDatapoolEntriesInvalid() override; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; - ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator command, - uint8_t expectedReplies = 1, bool useAlternateId = false, - DeviceCommandId_t alternateReplyID = 0) override; - size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MPSOC_HANDLER; -private: + static const ReturnValue_t CRC_FAILURE = + MAKE_RETURN_CODE(0xA0); //!> Space Packet received from PLOC has invalid CRC + static const ReturnValue_t RECEIVED_ACK_FAILURE = + MAKE_RETURN_CODE(0xA1); //!> Received ACK failure reply from PLOC + static const ReturnValue_t RECEIVED_EXE_FAILURE = + MAKE_RETURN_CODE(0xA2); //!> Received execution failure reply from PLOC + static const ReturnValue_t INVALID_APID = + MAKE_RETURN_CODE(0xA3); //!> Received space packet with invalid APID from PLOC - static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MPSOC_HANDLER; + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MPSOC_HANDLER; - static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0); //!> Space Packet received from PLOC has invalid CRC - static const ReturnValue_t RECEIVED_ACK_FAILURE = MAKE_RETURN_CODE(0xA1); //!> Received ACK failure reply from PLOC - static const ReturnValue_t RECEIVED_EXE_FAILURE = MAKE_RETURN_CODE(0xA2); //!> Received execution failure reply from PLOC - static const ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(0xA3); //!> Received space packet with invalid APID from PLOC + static const Event MEMORY_READ_RPT_CRC_FAILURE = + MAKE_EVENT(1, severity::LOW); //!> PLOC crc failure in telemetry packet + static const Event ACK_FAILURE = + MAKE_EVENT(2, severity::LOW); //!> PLOC receive acknowledgment failure report + static const Event EXE_FAILURE = + MAKE_EVENT(3, severity::LOW); //!> PLOC receive execution failure report + static const Event CRC_FAILURE_EVENT = + MAKE_EVENT(4, severity::LOW); //!> PLOC reply has invalid crc - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MPSOC_HANDLER; + static const uint16_t APID_MASK = 0x7FF; + static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF; - static const Event MEMORY_READ_RPT_CRC_FAILURE = MAKE_EVENT(1, severity::LOW); //!> PLOC crc failure in telemetry packet - static const Event ACK_FAILURE = MAKE_EVENT(2, severity::LOW); //!> PLOC receive acknowledgment failure report - static const Event EXE_FAILURE = MAKE_EVENT(3, severity::LOW); //!> PLOC receive execution failure report - static const Event CRC_FAILURE_EVENT = MAKE_EVENT(4, severity::LOW); //!> PLOC reply has invalid crc + uint8_t commandBuffer[PLOC_MPSOC::MAX_COMMAND_SIZE]; - static const uint16_t APID_MASK = 0x7FF; - static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF; + /** + * @brief This object is incremented each time a packet is sent or received. By checking the + * packet sequence count of a received packet, no packets can be lost without noticing + * it. Only the least significant 14 bits represent the packet sequence count in a + * space packet. Thus the maximum value amounts to 16383 (0x3FFF). + * @note Normally this should never happen because the PLOC replies are always sent in a + * fixed order. However, the PLOC software checks this value and will return an ACK + * failure report in case the sequence count is not incremented with each transferred + * space packet. + */ + uint16_t packetSequenceCount = 0x3FFF; - uint8_t commandBuffer[PLOC_MPSOC::MAX_COMMAND_SIZE]; + /** + * 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_MPSOC::NONE; - /** - * @brief This object is incremented each time a packet is sent or received. By checking the - * packet sequence count of a received packet, no packets can be lost without noticing - * it. Only the least significant 14 bits represent the packet sequence count in a - * space packet. Thus the maximum value amounts to 16383 (0x3FFF). - * @note Normally this should never happen because the PLOC replies are always sent in a - * fixed order. However, the PLOC software checks this value and will return an ACK - * failure report in case the sequence count is not incremented with each transferred - * space packet. - */ - uint16_t packetSequenceCount = 0x3FFF; + /** + * @brief This function fills the commandBuffer to initiate the write memory command. + * + * @param commandData Pointer to action command data. + * @param commanDataLen Size of command data in bytes. + * + * @return RETURN_OK if successful, else RETURN_FAILURE. + */ + ReturnValue_t prepareTcMemWriteCommand(const uint8_t* commandData, size_t commandDataLen); - /** - * 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_MPSOC::NONE; + /** + * @brief This function fills the commandBuffer to initiate the write reads command. + * + * @param commandData Pointer to action command data. + * @param commanDataLen Size of command data in bytes. + * + * @return RETURN_OK if successful, else RETURN_FAILURE. + */ + ReturnValue_t prepareTcMemReadCommand(const uint8_t* commandData, size_t commandDataLen); - /** - * @brief This function fills the commandBuffer to initiate the write memory command. - * - * @param commandData Pointer to action command data. - * @param commanDataLen Size of command data in bytes. - * - * @return RETURN_OK if successful, else RETURN_FAILURE. - */ - ReturnValue_t prepareTcMemWriteCommand(const uint8_t * commandData, size_t commandDataLen); + /** + * @brief This function checks the crc of the received PLOC reply. + * + * @param start Pointer to the first byte of the reply. + * @param foundLen Pointer to the length of the whole packet. + * + * @return RETURN_OK if CRC is ok, otherwise CRC_FAILURE. + */ + ReturnValue_t verifyPacket(const uint8_t* start, size_t foundLen); - /** - * @brief This function fills the commandBuffer to initiate the write reads command. - * - * @param commandData Pointer to action command data. - * @param commanDataLen Size of command data in bytes. - * - * @return RETURN_OK if successful, else RETURN_FAILURE. - */ - ReturnValue_t prepareTcMemReadCommand(const uint8_t * commandData, size_t commandDataLen); + /** + * @brief This function handles the acknowledgment report. + * + * @param data Pointer to the data holding the acknowledgment report. + * + * @return RETURN_OK if successful, otherwise an error code. + */ + ReturnValue_t handleAckReport(const uint8_t* data); - /** - * @brief This function checks the crc of the received PLOC reply. - * - * @param start Pointer to the first byte of the reply. - * @param foundLen Pointer to the length of the whole packet. - * - * @return RETURN_OK if CRC is ok, otherwise CRC_FAILURE. - */ - ReturnValue_t verifyPacket(const uint8_t* start, size_t foundLen); + /** + * @brief This function handles the data of a execution report. + * + * @param data Pointer to the received data packet. + * + * @return RETURN_OK if successful, otherwise an error code. + */ + ReturnValue_t handleExecutionReport(const uint8_t* data); - /** - * @brief This function handles the acknowledgment report. - * - * @param data Pointer to the data holding the acknowledgment report. - * - * @return RETURN_OK if successful, otherwise an error code. - */ - ReturnValue_t handleAckReport(const uint8_t* data); + /** + * @brief This function handles the memory read report. + * + * @param data Pointer to the data buffer holding the memory read report. + * + * @return RETURN_OK if successful, otherwise an error code. + */ + ReturnValue_t handleMemoryReadReport(const uint8_t* data); - /** - * @brief This function handles the data of a execution report. - * - * @param data Pointer to the received data packet. - * - * @return RETURN_OK if successful, otherwise an error code. - */ - ReturnValue_t handleExecutionReport(const uint8_t* data); + /** + * @brief Depending on the current active command, this function sets the reply id of the + * next reply after a successful acknowledgment report has been received. This is + * required by the function getNextReplyLength() to identify the length of the next + * reply to read. + */ + void setNextReplyId(); - /** - * @brief This function handles the memory read report. - * - * @param data Pointer to the data buffer holding the memory read report. - * - * @return RETURN_OK if successful, otherwise an error code. - */ - ReturnValue_t handleMemoryReadReport(const uint8_t* data); + /** + * @brief This function handles action message replies in case the telemetry has been + * requested by another object. + * + * @param data Pointer to the telemetry data. + * @param dataSize Size of telemetry in bytes. + * @param replyId Id of the reply. This will be added to the ActionMessage. + */ + void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); - /** - * @brief Depending on the current active command, this function sets the reply id of the - * next reply after a successful acknowledgment report has been received. This is - * required by the function getNextReplyLength() to identify the length of the next - * reply to read. - */ - void setNextReplyId(); + /** + * @brief In case an acknowledgment failure reply has been received this function disables + * all previously enabled commands and resets the exepected replies variable of an + * active command. + */ + void disableAllReplies(); - /** - * @brief This function handles action message replies in case the telemetry has been - * requested by another object. - * - * @param data Pointer to the telemetry data. - * @param dataSize Size of telemetry in bytes. - * @param replyId Id of the reply. This will be added to the ActionMessage. - */ - void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); + /** + * @brief This function sends a failure report if the active action was commanded by an other + * object. + * + * @param replyId The id of the reply which signals a failure. + * @param status A status byte which gives information about the failure type. + */ + void sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status); - /** - * @brief In case an acknowledgment failure reply has been received this function disables - * all previously enabled commands and resets the exepected replies variable of an - * active command. - */ - void disableAllReplies(); + /** + * @brief This function disables the execution report reply. Within this function also the + * the variable expectedReplies of an active command will be set to 0. + */ + void disableExeReportReply(); - /** - * @brief This function sends a failure report if the active action was commanded by an other - * object. - * - * @param replyId The id of the reply which signals a failure. - * @param status A status byte which gives information about the failure type. - */ - void sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status); - - /** - * @brief This function disables the execution report reply. Within this function also the - * the variable expectedReplies of an active command will be set to 0. - */ - void disableExeReportReply(); - - /** - * @brief This function checks and increments the packet sequence count of a received space - * packet. - * - * @param data Pointer to a space packet. - * - * @return RETURN_OK if successful - * - * @details There should be never a case in which a wrong packet sequence count is received - * because the communication scheme between PLOC and OBC always follows a strict - * procedure. Thus this function mainly serves for debugging purposes to detected an - * invalid handling of the packet sequence count. - */ - ReturnValue_t checkPacketSequenceCount(const uint8_t* data); + /** + * @brief This function checks and increments the packet sequence count of a received space + * packet. + * + * @param data Pointer to a space packet. + * + * @return RETURN_OK if successful + * + * @details There should be never a case in which a wrong packet sequence count is received + * because the communication scheme between PLOC and OBC always follows a strict + * procedure. Thus this function mainly serves for debugging purposes to detected an + * invalid handling of the packet sequence count. + */ + ReturnValue_t checkPacketSequenceCount(const uint8_t* data); }; #endif /* MISSION_DEVICES_PLOCMPSOCHANDLER_H_ */ diff --git a/mission/devices/RadiationSensorHandler.cpp b/mission/devices/RadiationSensorHandler.cpp index 95f045d8..83720b53 100644 --- a/mission/devices/RadiationSensorHandler.cpp +++ b/mission/devices/RadiationSensorHandler.cpp @@ -1,196 +1,177 @@ +#include #include #include -#include RadiationSensorHandler::RadiationSensorHandler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie) : - DeviceHandlerBase(objectId, comIF, comCookie), dataset( - this) { - if (comCookie == NULL) { - sif::error << "RadiationSensorHandler: Invalid com cookie" << std::endl; - } + CookieIF *comCookie) + : DeviceHandlerBase(objectId, comIF, comCookie), dataset(this) { + if (comCookie == NULL) { + sif::error << "RadiationSensorHandler: Invalid com cookie" << std::endl; + } } -RadiationSensorHandler::~RadiationSensorHandler() { -} +RadiationSensorHandler::~RadiationSensorHandler() {} - -void RadiationSensorHandler::doStartUp(){ - if (internalState == InternalState::CONFIGURED) { +void RadiationSensorHandler::doStartUp() { + if (internalState == InternalState::CONFIGURED) { #if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 - setMode(MODE_NORMAL); + setMode(MODE_NORMAL); #else - setMode(_MODE_TO_ON); + setMode(_MODE_TO_ON); #endif - } + } } -void RadiationSensorHandler::doShutDown(){ - setMode(_MODE_POWER_DOWN); -} +void RadiationSensorHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } -ReturnValue_t RadiationSensorHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - - switch (communicationStep) { +ReturnValue_t RadiationSensorHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + switch (communicationStep) { case CommunicationStep::START_CONVERSION: { - *id = RAD_SENSOR::START_CONVERSION; - communicationStep = CommunicationStep::READ_CONVERSIONS; - break; + *id = RAD_SENSOR::START_CONVERSION; + communicationStep = CommunicationStep::READ_CONVERSIONS; + break; } case CommunicationStep::READ_CONVERSIONS: { - *id = RAD_SENSOR::READ_CONVERSIONS; - communicationStep = CommunicationStep::START_CONVERSION; - break; + *id = RAD_SENSOR::READ_CONVERSIONS; + communicationStep = CommunicationStep::START_CONVERSION; + break; } default: { - sif::debug << "RadiationSensorHandler::buildNormalDeviceCommand: Unknown communication " - << "step" << std::endl; - return HasReturnvaluesIF::RETURN_OK; + sif::debug << "RadiationSensorHandler::buildNormalDeviceCommand: Unknown communication " + << "step" << std::endl; + return HasReturnvaluesIF::RETURN_OK; } - } - return buildCommandFromCommand(*id, nullptr, 0); + } + return buildCommandFromCommand(*id, nullptr, 0); } -ReturnValue_t RadiationSensorHandler::buildTransitionDeviceCommand( - DeviceCommandId_t * id){ - if (internalState == InternalState::SETUP) { - *id = RAD_SENSOR::WRITE_SETUP; - } - else { - return NOTHING_TO_SEND; - } - return buildCommandFromCommand(*id, nullptr, 0); +ReturnValue_t RadiationSensorHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { + if (internalState == InternalState::SETUP) { + *id = RAD_SENSOR::WRITE_SETUP; + } else { + return NOTHING_TO_SEND; + } + return buildCommandFromCommand(*id, nullptr, 0); } -ReturnValue_t RadiationSensorHandler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t * commandData, - size_t commandDataLen) { - switch(deviceCommand) { - case(RAD_SENSOR::WRITE_SETUP): { - cmdBuffer[0] = RAD_SENSOR::SETUP_DEFINITION; - rawPacket = cmdBuffer; - rawPacketLen = 1; - internalState = InternalState::CONFIGURED; - return RETURN_OK; +ReturnValue_t RadiationSensorHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, + size_t commandDataLen) { + switch (deviceCommand) { + case (RAD_SENSOR::WRITE_SETUP): { + cmdBuffer[0] = RAD_SENSOR::SETUP_DEFINITION; + rawPacket = cmdBuffer; + rawPacketLen = 1; + internalState = InternalState::CONFIGURED; + return RETURN_OK; } - case(RAD_SENSOR::START_CONVERSION): { - /* First the fifo will be reset here */ - cmdBuffer[0] = RAD_SENSOR::RESET_DEFINITION; - cmdBuffer[1] = RAD_SENSOR::CONVERSION_DEFINITION; - rawPacket = cmdBuffer; - rawPacketLen = 2; - return RETURN_OK; + case (RAD_SENSOR::START_CONVERSION): { + /* First the fifo will be reset here */ + cmdBuffer[0] = RAD_SENSOR::RESET_DEFINITION; + cmdBuffer[1] = RAD_SENSOR::CONVERSION_DEFINITION; + rawPacket = cmdBuffer; + rawPacketLen = 2; + return RETURN_OK; } - case(RAD_SENSOR::READ_CONVERSIONS): { - cmdBuffer[0] = RAD_SENSOR::DUMMY_BYTE; - std::memset(cmdBuffer, RAD_SENSOR::DUMMY_BYTE, RAD_SENSOR::READ_SIZE); - rawPacket = cmdBuffer; - rawPacketLen = RAD_SENSOR::READ_SIZE; - return RETURN_OK; + case (RAD_SENSOR::READ_CONVERSIONS): { + cmdBuffer[0] = RAD_SENSOR::DUMMY_BYTE; + std::memset(cmdBuffer, RAD_SENSOR::DUMMY_BYTE, RAD_SENSOR::READ_SIZE); + rawPacket = cmdBuffer; + rawPacketLen = RAD_SENSOR::READ_SIZE; + return RETURN_OK; } -// case(RAD_SENSOR::AIN0_AND_TMP_CONVERSION): { -// /* First the fifo will be reset here */ -// cmdBuffer[0] = RAD_SENSOR::RESET_DEFINITION; -// cmdBuffer[1] = RAD_SENSOR::CONVERSION_DEFINITION; -// rawPacket = cmdBuffer; -// rawPacketLen = 2; -// return RETURN_OK; -// } + // case(RAD_SENSOR::AIN0_AND_TMP_CONVERSION): { + // /* First the fifo will be reset here */ + // cmdBuffer[0] = RAD_SENSOR::RESET_DEFINITION; + // cmdBuffer[1] = RAD_SENSOR::CONVERSION_DEFINITION; + // rawPacket = cmdBuffer; + // rawPacketLen = 2; + // return RETURN_OK; + // } default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } void RadiationSensorHandler::fillCommandAndReplyMap() { - this->insertInCommandMap(RAD_SENSOR::WRITE_SETUP); - this->insertInCommandMap(RAD_SENSOR::START_CONVERSION); - this->insertInCommandAndReplyMap(RAD_SENSOR::READ_CONVERSIONS, 1, &dataset, - RAD_SENSOR::READ_SIZE); + this->insertInCommandMap(RAD_SENSOR::WRITE_SETUP); + this->insertInCommandMap(RAD_SENSOR::START_CONVERSION); + this->insertInCommandAndReplyMap(RAD_SENSOR::READ_CONVERSIONS, 1, &dataset, + RAD_SENSOR::READ_SIZE); } -ReturnValue_t RadiationSensorHandler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { - *foundId = this->getPendingCommand(); +ReturnValue_t RadiationSensorHandler::scanForReply(const uint8_t *start, size_t remainingSize, + DeviceCommandId_t *foundId, size_t *foundLen) { + *foundId = this->getPendingCommand(); - switch (*foundId) { + switch (*foundId) { case RAD_SENSOR::START_CONVERSION: case RAD_SENSOR::WRITE_SETUP: - return IGNORE_REPLY_DATA; + return IGNORE_REPLY_DATA; default: - break; - } + break; + } - *foundLen = remainingSize; + *foundLen = remainingSize; - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t RadiationSensorHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { - switch (id) { + const uint8_t *packet) { + switch (id) { case RAD_SENSOR::READ_CONVERSIONS: { - uint8_t offset = 0; - PoolReadGuard readSet(&dataset); - dataset.temperatureCelcius = (*(packet + offset) << 8 | *(packet + offset + 1)) * 0.125; - offset += 2; - dataset.ain0 = (*(packet + offset) << 8 | *(packet + offset +1)); - offset += 2; - dataset.ain1 = (*(packet + offset) << 8 | *(packet + offset + 1)); - offset += 6; - dataset.ain4 = (*(packet + offset) << 8 | *(packet + offset + 1)); - offset += 2; - dataset.ain5 = (*(packet + offset) << 8 | *(packet + offset + 1)); - offset += 2; - dataset.ain6 = (*(packet + offset) << 8 | *(packet + offset + 1)); - offset += 2; - dataset.ain7 = (*(packet + offset) << 8 | *(packet + offset + 1)); + uint8_t offset = 0; + PoolReadGuard readSet(&dataset); + dataset.temperatureCelcius = (*(packet + offset) << 8 | *(packet + offset + 1)) * 0.125; + offset += 2; + dataset.ain0 = (*(packet + offset) << 8 | *(packet + offset + 1)); + offset += 2; + dataset.ain1 = (*(packet + offset) << 8 | *(packet + offset + 1)); + offset += 6; + dataset.ain4 = (*(packet + offset) << 8 | *(packet + offset + 1)); + offset += 2; + dataset.ain5 = (*(packet + offset) << 8 | *(packet + offset + 1)); + offset += 2; + dataset.ain6 = (*(packet + offset) << 8 | *(packet + offset + 1)); + offset += 2; + dataset.ain7 = (*(packet + offset) << 8 | *(packet + offset + 1)); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RAD_SENSOR - sif::info << "Radiation sensor temperature: " << dataset.temperatureCelcius << " °C" - << std::endl; - sif::info << "Radiation sensor ADC value channel 0: " << dataset.ain0 - << std::endl; - sif::info << "Radiation sensor ADC value channel 1: " << dataset.ain1 - << std::endl; - sif::info << "Radiation sensor ADC value channel 4: " << dataset.ain4 - << std::endl; - sif::info << "Radiation sensor ADC value channel 5: " << dataset.ain5 - << std::endl; - sif::info << "Radiation sensor ADC value channel 6: " << dataset.ain6 - << std::endl; - sif::info << "Radiation sensor ADC value channel 7: " << dataset.ain7 + sif::info << "Radiation sensor temperature: " << dataset.temperatureCelcius << " °C" << std::endl; + sif::info << "Radiation sensor ADC value channel 0: " << dataset.ain0 << std::endl; + sif::info << "Radiation sensor ADC value channel 1: " << dataset.ain1 << std::endl; + sif::info << "Radiation sensor ADC value channel 4: " << dataset.ain4 << std::endl; + sif::info << "Radiation sensor ADC value channel 5: " << dataset.ain5 << std::endl; + sif::info << "Radiation sensor ADC value channel 6: " << dataset.ain6 << std::endl; + sif::info << "Radiation sensor ADC value channel 7: " << dataset.ain7 << std::endl; #endif - break; + break; } default: { - sif::debug << "RadiationSensorHandler::interpretDeviceReply: Unknown reply id" << std::endl; - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; + sif::debug << "RadiationSensorHandler::interpretDeviceReply: Unknown reply id" << std::endl; + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; } - - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } -void RadiationSensorHandler::setNormalDatapoolEntriesInvalid(){ +void RadiationSensorHandler::setNormalDatapoolEntriesInvalid() {} +uint32_t RadiationSensorHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { + return 5000; } -uint32_t RadiationSensorHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){ - return 5000; +ReturnValue_t RadiationSensorHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(RAD_SENSOR::TEMPERATURE_C, new PoolEntry({0.0})); + localDataPoolMap.emplace(RAD_SENSOR::AIN0, new PoolEntry({0})); + localDataPoolMap.emplace(RAD_SENSOR::AIN1, new PoolEntry({0})); + localDataPoolMap.emplace(RAD_SENSOR::AIN4, new PoolEntry({0})); + localDataPoolMap.emplace(RAD_SENSOR::AIN5, new PoolEntry({0})); + localDataPoolMap.emplace(RAD_SENSOR::AIN6, new PoolEntry({0})); + localDataPoolMap.emplace(RAD_SENSOR::AIN7, new PoolEntry({0})); + return HasReturnvaluesIF::RETURN_OK; } - -ReturnValue_t RadiationSensorHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { - localDataPoolMap.emplace(RAD_SENSOR::TEMPERATURE_C, new PoolEntry( { 0.0 })); - localDataPoolMap.emplace(RAD_SENSOR::AIN0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RAD_SENSOR::AIN1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RAD_SENSOR::AIN4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RAD_SENSOR::AIN5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RAD_SENSOR::AIN6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RAD_SENSOR::AIN7, new PoolEntry( { 0 })); - return HasReturnvaluesIF::RETURN_OK; -} - diff --git a/mission/devices/RadiationSensorHandler.h b/mission/devices/RadiationSensorHandler.h index 5612a1e0..fe4e4264 100644 --- a/mission/devices/RadiationSensorHandler.h +++ b/mission/devices/RadiationSensorHandler.h @@ -5,56 +5,46 @@ #include /** - * @brief This is the device handler class for radiation sensor on the OBC IF Board. The sensor - * is based on the MAX1227 ADC converter. + * @brief This is the device handler class for radiation sensor on the OBC IF Board. The + * sensor is based on the MAX1227 ADC converter. * * @details Datasheet of MAX1227: https://datasheets.maximintegrated.com/en/ds/MAX1227-MAX1231.pdf * * @author J. Meier */ -class RadiationSensorHandler: public DeviceHandlerBase { -public: +class RadiationSensorHandler : public DeviceHandlerBase { + public: + RadiationSensorHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie); + virtual ~RadiationSensorHandler(); - RadiationSensorHandler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie); - virtual ~RadiationSensorHandler(); + 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; -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; + private: + enum class CommunicationStep { START_CONVERSION, READ_CONVERSIONS }; -private: + enum class InternalState { SETUP, CONFIGURED }; - enum class CommunicationStep { - START_CONVERSION, - READ_CONVERSIONS - }; + RAD_SENSOR::RadSensorDataset dataset; - enum class InternalState { - SETUP, - CONFIGURED - }; + static const uint8_t MAX_CMD_LEN = RAD_SENSOR::READ_SIZE; - RAD_SENSOR::RadSensorDataset dataset; - - static const uint8_t MAX_CMD_LEN = RAD_SENSOR::READ_SIZE; - - uint8_t cmdBuffer[MAX_CMD_LEN]; - InternalState internalState = InternalState::SETUP; - CommunicationStep communicationStep = CommunicationStep::START_CONVERSION; + uint8_t cmdBuffer[MAX_CMD_LEN]; + InternalState internalState = InternalState::SETUP; + CommunicationStep communicationStep = CommunicationStep::START_CONVERSION; }; #endif /* MISSION_DEVICES_RADIATIONSENSORHANDLER_H_ */ diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index c848c809..f3cd0737 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -1,526 +1,523 @@ #include "RwHandler.h" + +#include +#include + #include "OBSWConfig.h" -#include -#include - -RwHandler::RwHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie, - LinuxLibgpioIF* gpioComIF, gpioId_t enableGpio) : - DeviceHandlerBase(objectId, comIF, comCookie), gpioComIF(gpioComIF), enableGpio(enableGpio), - temperatureSet(this), statusSet(this), lastResetStatusSet(this), tmDataset(this) { - if (comCookie == NULL) { - sif::error << "RwHandler: Invalid com cookie" << std::endl; - } - if (gpioComIF == NULL) { - sif::error << "RwHandler: Invalid gpio communication interface" << std::endl; - } +RwHandler::RwHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, + LinuxLibgpioIF* gpioComIF, gpioId_t enableGpio) + : DeviceHandlerBase(objectId, comIF, comCookie), + gpioComIF(gpioComIF), + enableGpio(enableGpio), + temperatureSet(this), + statusSet(this), + lastResetStatusSet(this), + tmDataset(this) { + if (comCookie == NULL) { + sif::error << "RwHandler: Invalid com cookie" << std::endl; + } + if (gpioComIF == NULL) { + sif::error << "RwHandler: Invalid gpio communication interface" << std::endl; + } } -RwHandler::~RwHandler() { -} +RwHandler::~RwHandler() {} void RwHandler::doStartUp() { + internalState = InternalState::GET_RESET_STATUS; - internalState = InternalState::GET_RESET_STATUS; - - if(gpioComIF->pullHigh(enableGpio) != RETURN_OK) { - sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to high"; - } + if (gpioComIF->pullHigh(enableGpio) != RETURN_OK) { + sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to high"; + } #if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 - setMode(MODE_NORMAL); + setMode(MODE_NORMAL); #else - setMode(_MODE_TO_ON); + setMode(_MODE_TO_ON); #endif } void RwHandler::doShutDown() { - if(gpioComIF->pullLow(enableGpio) != RETURN_OK) { - sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to low"; - } - setMode(_MODE_POWER_DOWN); + if (gpioComIF->pullLow(enableGpio) != RETURN_OK) { + sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to low"; + } + setMode(_MODE_POWER_DOWN); } -ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) { - switch (internalState) { +ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + switch (internalState) { case InternalState::GET_RESET_STATUS: - *id = RwDefinitions::GET_LAST_RESET_STATUS; - internalState = InternalState::READ_TEMPERATURE; - break; + *id = RwDefinitions::GET_LAST_RESET_STATUS; + internalState = InternalState::READ_TEMPERATURE; + break; case InternalState::CLEAR_RESET_STATUS: - *id = RwDefinitions::CLEAR_LAST_RESET_STATUS; - /** After reset status is cleared, reset status will be polled again for verification */ - internalState = InternalState::GET_RESET_STATUS; - break; + *id = RwDefinitions::CLEAR_LAST_RESET_STATUS; + /** After reset status is cleared, reset status will be polled again for verification */ + internalState = InternalState::GET_RESET_STATUS; + break; case InternalState::READ_TEMPERATURE: - *id = RwDefinitions::GET_TEMPERATURE; - internalState = InternalState::GET_RW_SATUS; - break; + *id = RwDefinitions::GET_TEMPERATURE; + internalState = InternalState::GET_RW_SATUS; + break; case InternalState::GET_RW_SATUS: - *id = RwDefinitions::GET_RW_STATUS; - internalState = InternalState::GET_RESET_STATUS; - break; + *id = RwDefinitions::GET_RW_STATUS; + internalState = InternalState::GET_RESET_STATUS; + break; default: - sif::debug << "RwHandler::buildNormalDeviceCommand: Invalid internal step" - << std::endl; - break; - } - return buildCommandFromCommand(*id, NULL, 0); + sif::debug << "RwHandler::buildNormalDeviceCommand: Invalid internal step" << std::endl; + break; + } + return buildCommandFromCommand(*id, NULL, 0); } -ReturnValue_t RwHandler::buildTransitionDeviceCommand(DeviceCommandId_t * id) { - return NOTHING_TO_SEND; +ReturnValue_t RwHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { + return NOTHING_TO_SEND; } ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t * commandData, size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; + const uint8_t* commandData, + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; - switch (deviceCommand) { + switch (deviceCommand) { case (RwDefinitions::RESET_MCU): { - prepareSimpleCommand(deviceCommand); - return RETURN_OK; + prepareSimpleCommand(deviceCommand); + return RETURN_OK; } case (RwDefinitions::GET_LAST_RESET_STATUS): { - prepareSimpleCommand(deviceCommand); - return RETURN_OK; + prepareSimpleCommand(deviceCommand); + return RETURN_OK; } case (RwDefinitions::CLEAR_LAST_RESET_STATUS): { - prepareSimpleCommand(deviceCommand); - return RETURN_OK; + prepareSimpleCommand(deviceCommand); + return RETURN_OK; } case (RwDefinitions::GET_RW_STATUS): { - prepareSimpleCommand(deviceCommand); - return RETURN_OK; + prepareSimpleCommand(deviceCommand); + return RETURN_OK; } case (RwDefinitions::INIT_RW_CONTROLLER): { - prepareSimpleCommand(deviceCommand); - return RETURN_OK; + prepareSimpleCommand(deviceCommand); + return RETURN_OK; } case (RwDefinitions::SET_SPEED): { - if (commandDataLen != 6) { - sif::error << "RwHandler::buildCommandFromCommand: Received set speed command with" - << " invalid length" << std::endl; - return SET_SPEED_COMMAND_INVALID_LENGTH; - } - result = checkSpeedAndRampTime(commandData, commandDataLen); - if (result != RETURN_OK) { - return result; - } - prepareSetSpeedCmd(commandData, commandDataLen); + if (commandDataLen != 6) { + sif::error << "RwHandler::buildCommandFromCommand: Received set speed command with" + << " invalid length" << std::endl; + return SET_SPEED_COMMAND_INVALID_LENGTH; + } + result = checkSpeedAndRampTime(commandData, commandDataLen); + if (result != RETURN_OK) { return result; + } + prepareSetSpeedCmd(commandData, commandDataLen); + return result; } case (RwDefinitions::GET_TEMPERATURE): { - prepareSimpleCommand(deviceCommand); - return RETURN_OK; + prepareSimpleCommand(deviceCommand); + return RETURN_OK; } case (RwDefinitions::GET_TM): { - prepareSimpleCommand(deviceCommand); - return RETURN_OK; + prepareSimpleCommand(deviceCommand); + return RETURN_OK; } default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } void RwHandler::fillCommandAndReplyMap() { - this->insertInCommandMap(RwDefinitions::RESET_MCU); - this->insertInCommandAndReplyMap(RwDefinitions::GET_LAST_RESET_STATUS, 1, &lastResetStatusSet, - RwDefinitions::SIZE_GET_RESET_STATUS); - this->insertInCommandAndReplyMap(RwDefinitions::CLEAR_LAST_RESET_STATUS, 1, nullptr, - RwDefinitions::SIZE_CLEAR_RESET_STATUS); - this->insertInCommandAndReplyMap(RwDefinitions::GET_RW_STATUS, 1, &statusSet, - RwDefinitions::SIZE_GET_RW_STATUS); - this->insertInCommandAndReplyMap(RwDefinitions::INIT_RW_CONTROLLER, 1, nullptr, - RwDefinitions::SIZE_INIT_RW); - this->insertInCommandAndReplyMap(RwDefinitions::GET_TEMPERATURE, 1, &temperatureSet, - RwDefinitions::SIZE_GET_TEMPERATURE_REPLY); - this->insertInCommandAndReplyMap(RwDefinitions::SET_SPEED, 1, nullptr, - RwDefinitions::SIZE_SET_SPEED_REPLY); - this->insertInCommandAndReplyMap(RwDefinitions::GET_TM, 1, &tmDataset, - RwDefinitions::SIZE_GET_TELEMETRY_REPLY); + this->insertInCommandMap(RwDefinitions::RESET_MCU); + this->insertInCommandAndReplyMap(RwDefinitions::GET_LAST_RESET_STATUS, 1, &lastResetStatusSet, + RwDefinitions::SIZE_GET_RESET_STATUS); + this->insertInCommandAndReplyMap(RwDefinitions::CLEAR_LAST_RESET_STATUS, 1, nullptr, + RwDefinitions::SIZE_CLEAR_RESET_STATUS); + this->insertInCommandAndReplyMap(RwDefinitions::GET_RW_STATUS, 1, &statusSet, + RwDefinitions::SIZE_GET_RW_STATUS); + this->insertInCommandAndReplyMap(RwDefinitions::INIT_RW_CONTROLLER, 1, nullptr, + RwDefinitions::SIZE_INIT_RW); + this->insertInCommandAndReplyMap(RwDefinitions::GET_TEMPERATURE, 1, &temperatureSet, + RwDefinitions::SIZE_GET_TEMPERATURE_REPLY); + this->insertInCommandAndReplyMap(RwDefinitions::SET_SPEED, 1, nullptr, + RwDefinitions::SIZE_SET_SPEED_REPLY); + this->insertInCommandAndReplyMap(RwDefinitions::GET_TM, 1, &tmDataset, + RwDefinitions::SIZE_GET_TELEMETRY_REPLY); } -ReturnValue_t RwHandler::scanForReply(const uint8_t *start, size_t remainingSize, - DeviceCommandId_t *foundId, size_t *foundLen) { - uint8_t replyByte = *start; - switch (replyByte) { +ReturnValue_t RwHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + uint8_t replyByte = *start; + switch (replyByte) { case (RwDefinitions::GET_LAST_RESET_STATUS): { - *foundLen = RwDefinitions::SIZE_GET_RESET_STATUS; - *foundId = RwDefinitions::GET_LAST_RESET_STATUS; - break; + *foundLen = RwDefinitions::SIZE_GET_RESET_STATUS; + *foundId = RwDefinitions::GET_LAST_RESET_STATUS; + break; } case (RwDefinitions::CLEAR_LAST_RESET_STATUS): { - *foundLen = RwDefinitions::SIZE_CLEAR_RESET_STATUS; - *foundId = RwDefinitions::CLEAR_LAST_RESET_STATUS; - break; + *foundLen = RwDefinitions::SIZE_CLEAR_RESET_STATUS; + *foundId = RwDefinitions::CLEAR_LAST_RESET_STATUS; + break; } case (RwDefinitions::GET_RW_STATUS): { - *foundLen = RwDefinitions::SIZE_GET_RW_STATUS; - *foundId = RwDefinitions::GET_RW_STATUS; - break; + *foundLen = RwDefinitions::SIZE_GET_RW_STATUS; + *foundId = RwDefinitions::GET_RW_STATUS; + break; } case (RwDefinitions::INIT_RW_CONTROLLER): { - *foundLen = RwDefinitions::SIZE_INIT_RW; - *foundId = RwDefinitions::INIT_RW_CONTROLLER; - break; + *foundLen = RwDefinitions::SIZE_INIT_RW; + *foundId = RwDefinitions::INIT_RW_CONTROLLER; + break; } case (RwDefinitions::SET_SPEED): { - *foundLen = RwDefinitions::SIZE_SET_SPEED_REPLY; - *foundId = RwDefinitions::SET_SPEED; - break; + *foundLen = RwDefinitions::SIZE_SET_SPEED_REPLY; + *foundId = RwDefinitions::SET_SPEED; + break; } case (RwDefinitions::GET_TEMPERATURE): { - *foundLen = RwDefinitions::SIZE_GET_TEMPERATURE_REPLY; - *foundId = RwDefinitions::GET_TEMPERATURE; - break; + *foundLen = RwDefinitions::SIZE_GET_TEMPERATURE_REPLY; + *foundId = RwDefinitions::GET_TEMPERATURE; + break; } case (RwDefinitions::GET_TM): { - *foundLen = RwDefinitions::SIZE_GET_TELEMETRY_REPLY; - *foundId = RwDefinitions::GET_TM; - break; + *foundLen = RwDefinitions::SIZE_GET_TELEMETRY_REPLY; + *foundId = RwDefinitions::GET_TM; + break; } default: { - sif::warning << "RwHandler::scanForReply: Reply contains invalid command code" << - std::endl; - *foundLen = remainingSize; - return RETURN_FAILED; - } + sif::warning << "RwHandler::scanForReply: Reply contains invalid command code" << std::endl; + *foundLen = remainingSize; + return RETURN_FAILED; } + } - sizeOfReply = *foundLen; + sizeOfReply = *foundLen; - return RETURN_OK; + return RETURN_OK; } -ReturnValue_t RwHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { +ReturnValue_t RwHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { + /** Check result code */ + if (*(packet + 1) == RwDefinitions::STATE_ERROR) { + sif::error << "RwHandler::interpretDeviceReply: Command execution failed. Command id: " << id + << std::endl; + return EXECUTION_FAILED; + } - /** Check result code */ - if (*(packet + 1) == RwDefinitions::STATE_ERROR) { - sif::error << "RwHandler::interpretDeviceReply: Command execution failed. Command id: " - << id << std::endl; - return EXECUTION_FAILED; - } + /** Received in little endian byte order */ + uint16_t replyCrc = *(packet + sizeOfReply - 1) << 8 | *(packet + sizeOfReply - 2); - /** Received in little endian byte order */ - uint16_t replyCrc = *(packet + sizeOfReply - 1) << 8 | *(packet + sizeOfReply - 2) ; + if (CRC::crc16ccitt(packet, sizeOfReply - 2, 0xFFFF) != replyCrc) { + sif::error << "RwHandler::interpretDeviceReply: cRC error" << std::endl; + return CRC_ERROR; + } - if (CRC::crc16ccitt(packet, sizeOfReply - 2, 0xFFFF) != replyCrc) { - sif::error << "RwHandler::interpretDeviceReply: cRC error" << std::endl; - return CRC_ERROR; - } - - switch (id) { + switch (id) { case (RwDefinitions::GET_LAST_RESET_STATUS): { - handleResetStatusReply(packet); - break; + handleResetStatusReply(packet); + break; } case (RwDefinitions::GET_RW_STATUS): { - handleGetRwStatusReply(packet); - break; + handleGetRwStatusReply(packet); + break; } case (RwDefinitions::CLEAR_LAST_RESET_STATUS): case (RwDefinitions::INIT_RW_CONTROLLER): case (RwDefinitions::SET_SPEED): - // no reply data expected - break; + // no reply data expected + break; case (RwDefinitions::GET_TEMPERATURE): { - handleTemperatureReply(packet); - break; + handleTemperatureReply(packet); + break; } case (RwDefinitions::GET_TM): { - handleGetTelemetryReply(packet); - break; + handleGetTelemetryReply(packet); + break; } default: { - sif::debug << "RwHandler::interpretDeviceReply: Unknown device reply id" << std::endl; - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } + sif::debug << "RwHandler::interpretDeviceReply: Unknown device reply id" << std::endl; + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; } + } - return RETURN_OK; + return RETURN_OK; } -void RwHandler::setNormalDatapoolEntriesInvalid() { +void RwHandler::setNormalDatapoolEntriesInvalid() {} -} - -uint32_t RwHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { - return 5000; -} +uint32_t RwHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 5000; } ReturnValue_t RwHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { + LocalDataPoolManager& poolManager) { + localDataPoolMap.emplace(RwDefinitions::TEMPERATURE_C, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::TEMPERATURE_C, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::CURR_SPEED, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::REFERENCE_SPEED, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::STATE, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::CLC_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::CURR_SPEED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::REFERENCE_SPEED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::CLC_MODE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::LAST_RESET_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::CURRRENT_RESET_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::LAST_RESET_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::CURRRENT_RESET_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::TM_LAST_RESET_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::TM_MCU_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::PRESSURE_SENSOR_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::PRESSURE, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::TM_RW_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::TM_CLC_MODE, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::TM_RW_CURR_SPEED, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::TM_RW_REF_SPEED, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::INVALID_CRC_PACKETS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::INVALID_LEN_PACKETS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::INVALID_CMD_PACKETS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::EXECUTED_REPLIES, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::COMMAND_REPLIES, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::UART_BYTES_WRITTEN, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::UART_BYTES_READ, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::UART_PARITY_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::UART_NOISE_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::UART_FRAME_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::UART_REG_OVERRUN_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::UART_TOTAL_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_WRITTEN, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_READ, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::SPI_REG_OVERRUN_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::SPI_TOTAL_ERRORS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::TM_LAST_RESET_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::TM_MCU_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::PRESSURE_SENSOR_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::PRESSURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::TM_RW_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::TM_CLC_MODE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::TM_RW_CURR_SPEED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::TM_RW_REF_SPEED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::INVALID_CRC_PACKETS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::INVALID_LEN_PACKETS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::INVALID_CMD_PACKETS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::EXECUTED_REPLIES, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::COMMAND_REPLIES, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::UART_BYTES_WRITTEN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::UART_BYTES_READ, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::UART_PARITY_ERRORS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::UART_NOISE_ERRORS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::UART_FRAME_ERRORS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::UART_REG_OVERRUN_ERRORS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::UART_TOTAL_ERRORS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_WRITTEN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_READ, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::SPI_REG_OVERRUN_ERRORS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::SPI_TOTAL_ERRORS, new PoolEntry( { 0 })); - - return RETURN_OK; + return RETURN_OK; } void RwHandler::prepareSimpleCommand(DeviceCommandId_t id) { - commandBuffer[0] = static_cast(id); - uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF); - commandBuffer[1] = static_cast(crc & 0xFF); - commandBuffer[2] = static_cast(crc >> 8 & 0xFF); - rawPacket = commandBuffer; - rawPacketLen = 3; + commandBuffer[0] = static_cast(id); + uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF); + commandBuffer[1] = static_cast(crc & 0xFF); + commandBuffer[2] = static_cast(crc >> 8 & 0xFF); + rawPacket = commandBuffer; + rawPacketLen = 3; } ReturnValue_t RwHandler::checkSpeedAndRampTime(const uint8_t* commandData, size_t commandDataLen) { - int32_t speed = *commandData << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 - | *(commandData + 3); + int32_t speed = + *commandData << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 | *(commandData + 3); - if ((speed < -65000 || speed > 65000 || (speed > -1000 && speed < 1000)) && (speed != 0)) { - sif::error << "RwHandler::checkSpeedAndRampTime: Command has invalid speed" << std::endl; - return INVALID_SPEED; - } + if ((speed < -65000 || speed > 65000 || (speed > -1000 && speed < 1000)) && (speed != 0)) { + sif::error << "RwHandler::checkSpeedAndRampTime: Command has invalid speed" << std::endl; + return INVALID_SPEED; + } - uint16_t rampTime = *(commandData + 4) << 8 | *(commandData + 5); + uint16_t rampTime = *(commandData + 4) << 8 | *(commandData + 5); - if (rampTime < 10 || rampTime > 10000) { - sif::error << "RwHandler::checkSpeedAndRampTime: Command has invalid ramp time" - << std::endl; - return INVALID_RAMP_TIME; - } + if (rampTime < 10 || rampTime > 10000) { + sif::error << "RwHandler::checkSpeedAndRampTime: Command has invalid ramp time" << std::endl; + return INVALID_RAMP_TIME; + } - return RETURN_OK; + return RETURN_OK; } -void RwHandler::prepareSetSpeedCmd(const uint8_t * commandData, size_t commandDataLen) { - commandBuffer[0] = static_cast(RwDefinitions::SET_SPEED); +void RwHandler::prepareSetSpeedCmd(const uint8_t* commandData, size_t commandDataLen) { + commandBuffer[0] = static_cast(RwDefinitions::SET_SPEED); - /** Speed (0.1 RPM) */ - commandBuffer[1] = *(commandData + 3); - commandBuffer[2] = *(commandData + 2); - commandBuffer[3] = *(commandData + 1); - commandBuffer[4] = *commandData; - /** Ramp time (ms) */ - commandBuffer[5] = *(commandData + 5); - commandBuffer[6] = *(commandData + 4); + /** Speed (0.1 RPM) */ + commandBuffer[1] = *(commandData + 3); + commandBuffer[2] = *(commandData + 2); + commandBuffer[3] = *(commandData + 1); + commandBuffer[4] = *commandData; + /** Ramp time (ms) */ + commandBuffer[5] = *(commandData + 5); + commandBuffer[6] = *(commandData + 4); - uint16_t crc = CRC::crc16ccitt(commandBuffer, 7, 0xFFFF); - commandBuffer[7] = static_cast(crc & 0xFF); - commandBuffer[8] = static_cast(crc >> 8 & 0xFF); - rawPacket = commandBuffer; - rawPacketLen = 9; + uint16_t crc = CRC::crc16ccitt(commandBuffer, 7, 0xFFFF); + commandBuffer[7] = static_cast(crc & 0xFF); + commandBuffer[8] = static_cast(crc >> 8 & 0xFF); + rawPacket = commandBuffer; + rawPacketLen = 9; } void RwHandler::handleResetStatusReply(const uint8_t* packet) { - PoolReadGuard rg(&lastResetStatusSet); - uint8_t offset = 2; - uint8_t resetStatus = *(packet + offset); - if (resetStatus != RwDefinitions::CLEARED) { - internalState = InternalState::CLEAR_RESET_STATUS; - lastResetStatusSet.lastResetStatus = resetStatus; - } - lastResetStatusSet.currentResetStatus = resetStatus; + PoolReadGuard rg(&lastResetStatusSet); + uint8_t offset = 2; + uint8_t resetStatus = *(packet + offset); + if (resetStatus != RwDefinitions::CLEARED) { + internalState = InternalState::CLEAR_RESET_STATUS; + lastResetStatusSet.lastResetStatus = resetStatus; + } + lastResetStatusSet.currentResetStatus = resetStatus; #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RW == 1 - sif::info << "RwHandler::handleResetStatusReply: Last reset status: " + sif::info << "RwHandler::handleResetStatusReply: Last reset status: " << static_cast(lastResetStatusSet.lastResetStatus.value) << std::endl; - sif::info << "RwHandler::handleResetStatusReply: Current reset status: " + sif::info << "RwHandler::handleResetStatusReply: Current reset status: " << static_cast(lastResetStatusSet.currentResetStatus.value) << std::endl; #endif } void RwHandler::handleGetRwStatusReply(const uint8_t* packet) { - PoolReadGuard rg(&statusSet); - uint8_t offset = 2; - statusSet.currSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - statusSet.referenceSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - statusSet.state = *(packet + offset); - offset += 1; - statusSet.clcMode = *(packet + offset); + PoolReadGuard rg(&statusSet); + uint8_t offset = 2; + statusSet.currSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + statusSet.referenceSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + statusSet.state = *(packet + offset); + offset += 1; + statusSet.clcMode = *(packet + offset); - if (statusSet.state == RwDefinitions::STATE_ERROR) { - /** - * This requires the commanding of the init reaction wheel controller command to recover - * form error state which must be handled by the FDIR instance. - */ - triggerEvent(ERROR_STATE); - sif::error << "RwHandler::handleGetRwStatusReply: Reaction wheel in error state" - << std::endl; - } + if (statusSet.state == RwDefinitions::STATE_ERROR) { + /** + * This requires the commanding of the init reaction wheel controller command to recover + * form error state which must be handled by the FDIR instance. + */ + triggerEvent(ERROR_STATE); + sif::error << "RwHandler::handleGetRwStatusReply: Reaction wheel in error state" << std::endl; + } #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RW == 1 - sif::info << "RwHandler::handleGetRwStatusReply: Current speed is: " << statusSet.currSpeed + sif::info << "RwHandler::handleGetRwStatusReply: Current speed is: " << statusSet.currSpeed << " * 0.1 RPM" << std::endl; - sif::info << "RwHandler::handleGetRwStatusReply: Reference speed is: " - << statusSet.referenceSpeed << " * 0.1 RPM" << std::endl; - sif::info << "RwHandler::handleGetRwStatusReply: State is: " - << (unsigned int) statusSet.state.value << std::endl; - sif::info << "RwHandler::handleGetRwStatusReply: clc mode is: " - << (unsigned int) statusSet.clcMode.value << std::endl; + sif::info << "RwHandler::handleGetRwStatusReply: Reference speed is: " << statusSet.referenceSpeed + << " * 0.1 RPM" << std::endl; + sif::info << "RwHandler::handleGetRwStatusReply: State is: " + << (unsigned int)statusSet.state.value << std::endl; + sif::info << "RwHandler::handleGetRwStatusReply: clc mode is: " + << (unsigned int)statusSet.clcMode.value << std::endl; #endif } void RwHandler::handleTemperatureReply(const uint8_t* packet) { - PoolReadGuard rg(&temperatureSet); - uint8_t offset = 2; - temperatureSet.temperatureCelcius = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); + PoolReadGuard rg(&temperatureSet); + uint8_t offset = 2; + temperatureSet.temperatureCelcius = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RW == 1 - sif::info << "RwHandler::handleTemperatureReply: Temperature: " + sif::info << "RwHandler::handleTemperatureReply: Temperature: " << temperatureSet.temperatureCelcius << " °C" << std::endl; #endif } void RwHandler::handleGetTelemetryReply(const uint8_t* packet) { - PoolReadGuard rg(&tmDataset); - uint8_t offset = 2; - tmDataset.lastResetStatus = *(packet + offset); - offset += 1; - tmDataset.mcuTemperature = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.pressureSensorTemperature = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.pressure = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.rwState = *(packet + offset); - offset += 1; - tmDataset.rwClcMode = *(packet + offset); - offset += 1; - tmDataset.rwCurrSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.rwRefSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.numOfInvalidCrcPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.numOfInvalidLenPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.numOfInvalidCmdPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.numOfCmdExecutedReplies = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.numOfCmdReplies = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.uartNumOfBytesWritten = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.uartNumOfBytesRead = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.uartNumOfParityErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.uartNumOfNoiseErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.uartNumOfFrameErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.uartNumOfRegisterOverrunErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.uartTotalNumOfErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.spiNumOfBytesWritten = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.spiNumOfBytesRead = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.spiNumOfRegisterOverrunErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.spiTotalNumOfErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); + PoolReadGuard rg(&tmDataset); + uint8_t offset = 2; + tmDataset.lastResetStatus = *(packet + offset); + offset += 1; + tmDataset.mcuTemperature = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.pressureSensorTemperature = *(packet + offset + 3) << 24 | + *(packet + offset + 2) << 16 | *(packet + offset + 1) << 8 | + *(packet + offset); + offset += 4; + tmDataset.pressure = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.rwState = *(packet + offset); + offset += 1; + tmDataset.rwClcMode = *(packet + offset); + offset += 1; + tmDataset.rwCurrSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.rwRefSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.numOfInvalidCrcPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.numOfInvalidLenPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.numOfInvalidCmdPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.numOfCmdExecutedReplies = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.numOfCmdReplies = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartNumOfBytesWritten = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartNumOfBytesRead = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartNumOfParityErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartNumOfNoiseErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartNumOfFrameErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartNumOfRegisterOverrunErrors = *(packet + offset + 3) << 24 | + *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartTotalNumOfErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.spiNumOfBytesWritten = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.spiNumOfBytesRead = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.spiNumOfRegisterOverrunErrors = *(packet + offset + 3) << 24 | + *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.spiTotalNumOfErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RW == 1 - sif::info << "RwHandler::handleTemperatureReply: Last reset status: " + sif::info << "RwHandler::handleTemperatureReply: Last reset status: " << static_cast(tmDataset.lastResetStatus.value) << std::endl; - sif::info << "RwHandler::handleTemperatureReply: MCU temperature: " << tmDataset.mcuTemperature + sif::info << "RwHandler::handleTemperatureReply: MCU temperature: " << tmDataset.mcuTemperature << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Pressure sensor temperature: " + sif::info << "RwHandler::handleTemperatureReply: Pressure sensor temperature: " << tmDataset.pressureSensorTemperature << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Pressure " - << tmDataset.pressure << std::endl; - sif::info << "RwHandler::handleTemperatureReply: State: " + sif::info << "RwHandler::handleTemperatureReply: Pressure " << tmDataset.pressure << std::endl; + sif::info << "RwHandler::handleTemperatureReply: State: " << static_cast(tmDataset.rwState.value) << std::endl; - sif::info << "RwHandler::handleTemperatureReply: CLC mode: " + sif::info << "RwHandler::handleTemperatureReply: CLC mode: " << static_cast(tmDataset.rwClcMode.value) << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Current speed: " << tmDataset.rwCurrSpeed + sif::info << "RwHandler::handleTemperatureReply: Current speed: " << tmDataset.rwCurrSpeed << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Reference speed: " << tmDataset.rwRefSpeed + sif::info << "RwHandler::handleTemperatureReply: Reference speed: " << tmDataset.rwRefSpeed << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Number of invalid CRC packets: " + sif::info << "RwHandler::handleTemperatureReply: Number of invalid CRC packets: " << tmDataset.numOfInvalidCrcPackets << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Number of invalid length packets: " + sif::info << "RwHandler::handleTemperatureReply: Number of invalid length packets: " << tmDataset.numOfInvalidLenPackets << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Number of invalid command packets: " + sif::info << "RwHandler::handleTemperatureReply: Number of invalid command packets: " << tmDataset.numOfInvalidCmdPackets << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Number of command executed replies: " + sif::info << "RwHandler::handleTemperatureReply: Number of command executed replies: " << tmDataset.numOfCmdExecutedReplies << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Number of command replies: " + sif::info << "RwHandler::handleTemperatureReply: Number of command replies: " << tmDataset.numOfCmdReplies << std::endl; - sif::info << "RwHandler::handleTemperatureReply: UART number of bytes written: " + sif::info << "RwHandler::handleTemperatureReply: UART number of bytes written: " << tmDataset.uartNumOfBytesWritten << std::endl; - sif::info << "RwHandler::handleTemperatureReply: UART number of bytes read: " + sif::info << "RwHandler::handleTemperatureReply: UART number of bytes read: " << tmDataset.uartNumOfBytesRead << std::endl; - sif::info << "RwHandler::handleTemperatureReply: UART number of parity errors: " + sif::info << "RwHandler::handleTemperatureReply: UART number of parity errors: " << tmDataset.uartNumOfParityErrors << std::endl; - sif::info << "RwHandler::handleTemperatureReply: UART number of noise errors: " + sif::info << "RwHandler::handleTemperatureReply: UART number of noise errors: " << tmDataset.uartNumOfNoiseErrors << std::endl; - sif::info << "RwHandler::handleTemperatureReply: UART number of frame errors: " + sif::info << "RwHandler::handleTemperatureReply: UART number of frame errors: " << tmDataset.uartNumOfFrameErrors << std::endl; - sif::info << "RwHandler::handleTemperatureReply: UART number of register overrun errors: " + sif::info << "RwHandler::handleTemperatureReply: UART number of register overrun errors: " << tmDataset.uartNumOfRegisterOverrunErrors << std::endl; - sif::info << "RwHandler::handleTemperatureReply: UART number of total errors: " + sif::info << "RwHandler::handleTemperatureReply: UART number of total errors: " << tmDataset.uartTotalNumOfErrors << std::endl; - sif::info << "RwHandler::handleTemperatureReply: SPI number of bytes written: " + sif::info << "RwHandler::handleTemperatureReply: SPI number of bytes written: " << tmDataset.spiNumOfBytesWritten << std::endl; - sif::info << "RwHandler::handleTemperatureReply: SPI number of bytes read: " + sif::info << "RwHandler::handleTemperatureReply: SPI number of bytes read: " << tmDataset.spiNumOfBytesRead << std::endl; - sif::info << "RwHandler::handleTemperatureReply: SPI number of register overrun errors: " + sif::info << "RwHandler::handleTemperatureReply: SPI number of register overrun errors: " << tmDataset.spiNumOfRegisterOverrunErrors << std::endl; - sif::info << "RwHandler::handleTemperatureReply: SPI number of register total errors: " + sif::info << "RwHandler::handleTemperatureReply: SPI number of register total errors: " << tmDataset.spiTotalNumOfErrors << std::endl; #endif } diff --git a/mission/devices/RwHandler.h b/mission/devices/RwHandler.h index 57895ca6..31b88e01 100644 --- a/mission/devices/RwHandler.h +++ b/mission/devices/RwHandler.h @@ -2,8 +2,8 @@ #define MISSION_DEVICES_RWHANDLER_H_ #include -#include #include +#include #include /** @@ -16,141 +16,135 @@ * * @author J. Meier */ -class RwHandler: public DeviceHandlerBase { -public: +class RwHandler : public DeviceHandlerBase { + public: + /** + * @brief Constructor + * + * @param objectId + * @param comIF + * @param comCookie + * @param gpioComIF Pointer to gpio communication interface + * @param enablePin GPIO connected to the enable pin of the reaction wheels. Must be pulled + * to high to enable the device. + */ + RwHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, LinuxLibgpioIF* gpioComIF, + gpioId_t enableGpio); + virtual ~RwHandler(); - /** - * @brief Constructor - * - * @param objectId - * @param comIF - * @param comCookie - * @param gpioComIF Pointer to gpio communication interface - * @param enablePin GPIO connected to the enable pin of the reaction wheels. Must be pulled - * to high to enable the device. - */ - RwHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie, - LinuxLibgpioIF* gpioComIF, gpioId_t enableGpio); - virtual ~RwHandler(); + static const uint8_t INTERFACE_ID = CLASS_ID::RW_HANDLER; - static const uint8_t INTERFACE_ID = CLASS_ID::RW_HANDLER; + static const ReturnValue_t SPI_WRITE_FAILURE = MAKE_RETURN_CODE(0xB0); + //! [EXPORT] : [COMMENT] Used by the spi send function to tell a failing read call + static const ReturnValue_t SPI_READ_FAILURE = MAKE_RETURN_CODE(0xB1); + //! [EXPORT] : [COMMENT] Can be used by the HDLC decoding mechanism to inform about a missing + //! start sign 0x7E + static const ReturnValue_t MISSING_START_SIGN = MAKE_RETURN_CODE(0xB2); + //! [EXPORT] : [COMMENT] Can be used by the HDLC decoding mechanism to inform about an invalid + //! substitution combination + static const ReturnValue_t INVALID_SUBSTITUTE = MAKE_RETURN_CODE(0xB3); + //! [EXPORT] : [COMMENT] HDLC decoding mechanism never receives the end sign 0x7E + static const ReturnValue_t MISSING_END_SIGN = MAKE_RETURN_CODE(0xB4); + //! [EXPORT] : [COMMENT] Reaction wheel only responds with empty frames. + static const ReturnValue_t NO_REPLY = MAKE_RETURN_CODE(0xB5); + //! [EXPORT] : [COMMENT] Expected a start marker as first byte + static const ReturnValue_t NO_START_MARKER = MAKE_RETURN_CODE(0xB6); - static const ReturnValue_t SPI_WRITE_FAILURE = MAKE_RETURN_CODE(0xB0); - //! [EXPORT] : [COMMENT] Used by the spi send function to tell a failing read call - static const ReturnValue_t SPI_READ_FAILURE = MAKE_RETURN_CODE(0xB1); - //! [EXPORT] : [COMMENT] Can be used by the HDLC decoding mechanism to inform about a missing start sign 0x7E - static const ReturnValue_t MISSING_START_SIGN = MAKE_RETURN_CODE(0xB2); - //! [EXPORT] : [COMMENT] Can be used by the HDLC decoding mechanism to inform about an invalid substitution combination - static const ReturnValue_t INVALID_SUBSTITUTE = MAKE_RETURN_CODE(0xB3); - //! [EXPORT] : [COMMENT] HDLC decoding mechanism never receives the end sign 0x7E - static const ReturnValue_t MISSING_END_SIGN = MAKE_RETURN_CODE(0xB4); - //! [EXPORT] : [COMMENT] Reaction wheel only responds with empty frames. - static const ReturnValue_t NO_REPLY = MAKE_RETURN_CODE(0xB5); - //! [EXPORT] : [COMMENT] Expected a start marker as first byte - static const ReturnValue_t NO_START_MARKER = MAKE_RETURN_CODE(0xB6); + 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; -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; + private: + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::RW_HANDLER; -private: + //! [EXPORT] : [COMMENT] Action Message with invalid speed was received. Valid speeds must be in + //! the range of [-65000; 1000] or [1000; 65000] + static const ReturnValue_t INVALID_SPEED = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] Action Message with invalid ramp time was received. + static const ReturnValue_t INVALID_RAMP_TIME = MAKE_RETURN_CODE(0xA1); + //! [EXPORT] : [COMMENT] Received set speed command has invalid length. Should be 6. + static const ReturnValue_t SET_SPEED_COMMAND_INVALID_LENGTH = MAKE_RETURN_CODE(0xA2); + //! [EXPORT] : [COMMENT] Command execution failed + static const ReturnValue_t EXECUTION_FAILED = MAKE_RETURN_CODE(0xA3); + //! [EXPORT] : [COMMENT] Reaction wheel reply has invalid crc + static const ReturnValue_t CRC_ERROR = MAKE_RETURN_CODE(0xA4); - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::RW_HANDLER; + //! [EXPORT] : [COMMENT] Reaction wheel signals an error state + static const Event ERROR_STATE = MAKE_EVENT(1, severity::HIGH); - //! [EXPORT] : [COMMENT] Action Message with invalid speed was received. Valid speeds must be in the range of [-65000; 1000] or [1000; 65000] - static const ReturnValue_t INVALID_SPEED = MAKE_RETURN_CODE(0xA0); - //! [EXPORT] : [COMMENT] Action Message with invalid ramp time was received. - static const ReturnValue_t INVALID_RAMP_TIME = MAKE_RETURN_CODE(0xA1); - //! [EXPORT] : [COMMENT] Received set speed command has invalid length. Should be 6. - static const ReturnValue_t SET_SPEED_COMMAND_INVALID_LENGTH = MAKE_RETURN_CODE(0xA2); - //! [EXPORT] : [COMMENT] Command execution failed - static const ReturnValue_t EXECUTION_FAILED = MAKE_RETURN_CODE(0xA3); - //! [EXPORT] : [COMMENT] Reaction wheel reply has invalid crc - static const ReturnValue_t CRC_ERROR = MAKE_RETURN_CODE(0xA4); + LinuxLibgpioIF* gpioComIF = nullptr; + gpioId_t enableGpio = gpio::NO_GPIO; - //! [EXPORT] : [COMMENT] Reaction wheel signals an error state - static const Event ERROR_STATE = MAKE_EVENT(1, severity::HIGH); + RwDefinitions::TemperatureSet temperatureSet; + RwDefinitions::StatusSet statusSet; + RwDefinitions::LastResetSatus lastResetStatusSet; + RwDefinitions::TmDataset tmDataset; - LinuxLibgpioIF* gpioComIF = nullptr; - gpioId_t enableGpio = gpio::NO_GPIO; + uint8_t commandBuffer[RwDefinitions::MAX_CMD_SIZE]; - RwDefinitions::TemperatureSet temperatureSet; - RwDefinitions::StatusSet statusSet; - RwDefinitions::LastResetSatus lastResetStatusSet; - RwDefinitions::TmDataset tmDataset; + enum class InternalState { GET_RESET_STATUS, CLEAR_RESET_STATUS, READ_TEMPERATURE, GET_RW_SATUS }; + InternalState internalState = InternalState::GET_RESET_STATUS; - uint8_t commandBuffer[RwDefinitions::MAX_CMD_SIZE]; + size_t sizeOfReply = 0; - enum class InternalState { - GET_RESET_STATUS, - CLEAR_RESET_STATUS, - READ_TEMPERATURE, - GET_RW_SATUS - }; + /** + * @brief This function can be used to build commands which do not contain any data apart + * from the command id and the CRC. + * @param commandId The command id of the command to build. + */ + void prepareSimpleCommand(DeviceCommandId_t id); - InternalState internalState = InternalState::GET_RESET_STATUS; + /** + * @brief This function checks if the receiced speed and ramp time to set are in a valid + * range. + * @return RETURN_OK if successful, otherwise error code. + */ + ReturnValue_t checkSpeedAndRampTime(const uint8_t* commandData, size_t commandDataLen); - size_t sizeOfReply = 0; + /** + * @brief This function prepares the set speed command from the commandData received with + * an action message. + */ + void prepareSetSpeedCmd(const uint8_t* commandData, size_t commandDataLen); - /** - * @brief This function can be used to build commands which do not contain any data apart - * from the command id and the CRC. - * @param commandId The command id of the command to build. - */ - void prepareSimpleCommand(DeviceCommandId_t id); + /** + * @brief This function writes the last reset status retrieved with the get last reset status + * command into the reset status dataset. + * + * @param packet Pointer to the buffer holding the reply data. + */ + void handleResetStatusReply(const uint8_t* packet); - /** - * @brief This function checks if the receiced speed and ramp time to set are in a valid - * range. - * @return RETURN_OK if successful, otherwise error code. - */ - ReturnValue_t checkSpeedAndRampTime(const uint8_t * commandData, size_t commandDataLen); + /** + * @brief This function handles the reply of the get temperature command. + * + * @param packet Pointer to the reply data + */ + void handleTemperatureReply(const uint8_t* packet); - /** - * @brief This function prepares the set speed command from the commandData received with - * an action message. - */ - void prepareSetSpeedCmd(const uint8_t * commandData, size_t commandDataLen); + /** + * @brief This function fills the status set with the data from the get-status-reply. + */ + void handleGetRwStatusReply(const uint8_t* packet); - /** - * @brief This function writes the last reset status retrieved with the get last reset status - * command into the reset status dataset. - * - * @param packet Pointer to the buffer holding the reply data. - */ - void handleResetStatusReply(const uint8_t* packet); - - /** - * @brief This function handles the reply of the get temperature command. - * - * @param packet Pointer to the reply data - */ - void handleTemperatureReply(const uint8_t* packet); - - /** - * @brief This function fills the status set with the data from the get-status-reply. - */ - void handleGetRwStatusReply(const uint8_t* packet); - - /** - * @brief This function fills the tmDataset with the reply data requested with get telemetry - * command. - */ - void handleGetTelemetryReply(const uint8_t* packet); + /** + * @brief This function fills the tmDataset with the reply data requested with get telemetry + * command. + */ + void handleGetTelemetryReply(const uint8_t* packet); }; #endif /* MISSION_DEVICES_RWHANDLER_H_ */ diff --git a/mission/devices/SyrlinksHkHandler.cpp b/mission/devices/SyrlinksHkHandler.cpp index 9f359bd1..8694f261 100644 --- a/mission/devices/SyrlinksHkHandler.cpp +++ b/mission/devices/SyrlinksHkHandler.cpp @@ -1,464 +1,451 @@ +#include +#include +#include + #include "OBSWConfig.h" -#include -#include -#include - - -SyrlinksHkHandler::SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - DeviceHandlerBase(objectId, comIF, comCookie), rxDataset(this), txDataset(this) { - if (comCookie == NULL) { - sif::error << "SyrlinksHkHandler: Invalid com cookie" << std::endl; - } +SyrlinksHkHandler::SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie) + : DeviceHandlerBase(objectId, comIF, comCookie), rxDataset(this), txDataset(this) { + if (comCookie == NULL) { + sif::error << "SyrlinksHkHandler: Invalid com cookie" << std::endl; + } } -SyrlinksHkHandler::~SyrlinksHkHandler() { +SyrlinksHkHandler::~SyrlinksHkHandler() {} + +void SyrlinksHkHandler::doStartUp() { + if (mode == _MODE_START_UP) { + setMode(MODE_ON); + } } +void SyrlinksHkHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } -void SyrlinksHkHandler::doStartUp(){ - if(mode == _MODE_START_UP){ - setMode(MODE_ON); - } -} - -void SyrlinksHkHandler::doShutDown(){ - setMode(_MODE_POWER_DOWN); -} - -ReturnValue_t SyrlinksHkHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - switch (nextCommand) { - case(SYRLINKS::READ_RX_STATUS_REGISTERS): - *id = SYRLINKS::READ_RX_STATUS_REGISTERS; - nextCommand = SYRLINKS::READ_TX_STATUS; - break; - case(SYRLINKS::READ_TX_STATUS): - *id = SYRLINKS::READ_TX_STATUS; - nextCommand = SYRLINKS::READ_TX_WAVEFORM; - break; - case(SYRLINKS::READ_TX_WAVEFORM): - *id = SYRLINKS::READ_TX_WAVEFORM; - nextCommand = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE; - break; - case(SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): - *id = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE; - nextCommand = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE; - break; - case(SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): - *id = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE; - nextCommand = SYRLINKS::READ_RX_STATUS_REGISTERS; - break; +ReturnValue_t SyrlinksHkHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + switch (nextCommand) { + case (SYRLINKS::READ_RX_STATUS_REGISTERS): + *id = SYRLINKS::READ_RX_STATUS_REGISTERS; + nextCommand = SYRLINKS::READ_TX_STATUS; + break; + case (SYRLINKS::READ_TX_STATUS): + *id = SYRLINKS::READ_TX_STATUS; + nextCommand = SYRLINKS::READ_TX_WAVEFORM; + break; + case (SYRLINKS::READ_TX_WAVEFORM): + *id = SYRLINKS::READ_TX_WAVEFORM; + nextCommand = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE; + break; + case (SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): + *id = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE; + nextCommand = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE; + break; + case (SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): + *id = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE; + nextCommand = SYRLINKS::READ_RX_STATUS_REGISTERS; + break; default: - sif::debug << "SyrlinksHkHandler::buildNormalDeviceCommand: rememberCommandId has invalid" - << "command id" << std::endl; - break; + sif::debug << "SyrlinksHkHandler::buildNormalDeviceCommand: rememberCommandId has invalid" + << "command id" << std::endl; + break; + } + return buildCommandFromCommand(*id, NULL, 0); +} + +ReturnValue_t SyrlinksHkHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t* commandData, + size_t commandDataLen) { + switch (deviceCommand) { + case (SYRLINKS::RESET_UNIT): { + resetCommand.copy(reinterpret_cast(commandBuffer), resetCommand.size(), 0); + rawPacketLen = resetCommand.size(); + rawPacket = commandBuffer; + return RETURN_OK; } - return buildCommandFromCommand(*id, NULL, 0); -} - -ReturnValue_t SyrlinksHkHandler::buildTransitionDeviceCommand( - DeviceCommandId_t * id){ - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t * commandData, - size_t commandDataLen) { - switch(deviceCommand) { - case(SYRLINKS::RESET_UNIT): { - resetCommand.copy(reinterpret_cast(commandBuffer), resetCommand.size(), 0); - rawPacketLen = resetCommand.size(); - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::SET_TX_MODE_STANDBY): { - setTxModeStandby.copy(reinterpret_cast(commandBuffer), setTxModeStandby.size(), 0); - rawPacketLen = setTxModeStandby.size(); - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::SET_TX_MODE_MODULATION): { - setTxModeModulation.copy(reinterpret_cast(commandBuffer), setTxModeModulation.size(), 0); - rawPacketLen = setTxModeModulation.size(); - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::SET_TX_MODE_CW): { - setTxModeCw.copy(reinterpret_cast(commandBuffer), setTxModeCw.size(), 0); - rawPacketLen = setTxModeCw.size(); - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::READ_RX_STATUS_REGISTERS): { - readRxStatusRegCommand.copy(reinterpret_cast(commandBuffer), readRxStatusRegCommand.size(), 0); - rawPacketLen = readRxStatusRegCommand.size(); - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::READ_TX_STATUS): { - readTxStatus.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); - rawPacketLen = readTxStatus.size(); - rememberCommandId = SYRLINKS::READ_TX_STATUS; - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::READ_TX_WAVEFORM): { - readTxWaveform.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); - rawPacketLen = readTxWaveform.size(); - rememberCommandId = SYRLINKS::READ_TX_WAVEFORM; - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): { - readTxAgcValueHighByte.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); - rawPacketLen = readTxAgcValueHighByte.size(); - rememberCommandId = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE; - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): { - readTxAgcValueLowByte.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); - rawPacketLen = readTxAgcValueLowByte.size(); - rememberCommandId = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE; - rawPacket = commandBuffer; - return RETURN_OK; - } - default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; + case (SYRLINKS::SET_TX_MODE_STANDBY): { + setTxModeStandby.copy(reinterpret_cast(commandBuffer), setTxModeStandby.size(), 0); + rawPacketLen = setTxModeStandby.size(); + rawPacket = commandBuffer; + return RETURN_OK; + } + case (SYRLINKS::SET_TX_MODE_MODULATION): { + setTxModeModulation.copy(reinterpret_cast(commandBuffer), setTxModeModulation.size(), + 0); + rawPacketLen = setTxModeModulation.size(); + rawPacket = commandBuffer; + return RETURN_OK; + } + case (SYRLINKS::SET_TX_MODE_CW): { + setTxModeCw.copy(reinterpret_cast(commandBuffer), setTxModeCw.size(), 0); + rawPacketLen = setTxModeCw.size(); + rawPacket = commandBuffer; + return RETURN_OK; + } + case (SYRLINKS::READ_RX_STATUS_REGISTERS): { + readRxStatusRegCommand.copy(reinterpret_cast(commandBuffer), + readRxStatusRegCommand.size(), 0); + rawPacketLen = readRxStatusRegCommand.size(); + rawPacket = commandBuffer; + return RETURN_OK; + } + case (SYRLINKS::READ_TX_STATUS): { + readTxStatus.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); + rawPacketLen = readTxStatus.size(); + rememberCommandId = SYRLINKS::READ_TX_STATUS; + rawPacket = commandBuffer; + return RETURN_OK; + } + case (SYRLINKS::READ_TX_WAVEFORM): { + readTxWaveform.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); + rawPacketLen = readTxWaveform.size(); + rememberCommandId = SYRLINKS::READ_TX_WAVEFORM; + rawPacket = commandBuffer; + return RETURN_OK; + } + case (SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): { + readTxAgcValueHighByte.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); + rawPacketLen = readTxAgcValueHighByte.size(); + rememberCommandId = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE; + rawPacket = commandBuffer; + return RETURN_OK; + } + case (SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): { + readTxAgcValueLowByte.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); + rawPacketLen = readTxAgcValueLowByte.size(); + rememberCommandId = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE; + rawPacket = commandBuffer; + return RETURN_OK; + } + default: + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } void SyrlinksHkHandler::fillCommandAndReplyMap() { - this->insertInCommandAndReplyMap(SYRLINKS::RESET_UNIT, 1, nullptr, SYRLINKS::ACK_SIZE, false, - true, SYRLINKS::ACK_REPLY); - this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_STANDBY, 1, nullptr, SYRLINKS::ACK_SIZE, - false, true, SYRLINKS::ACK_REPLY); - this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_MODULATION, 1, nullptr, - SYRLINKS::ACK_SIZE, false, true, SYRLINKS::ACK_REPLY); - this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_CW, 1, nullptr, SYRLINKS::ACK_SIZE, - false, true, SYRLINKS::ACK_REPLY); - this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_STATUS, 1, &txDataset, - SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_WAVEFORM, 1, &txDataset, - SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE, 1, &txDataset, - SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE, 1, &txDataset, - SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - this->insertInCommandAndReplyMap(SYRLINKS::READ_RX_STATUS_REGISTERS, 1, &rxDataset, - SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE); + this->insertInCommandAndReplyMap(SYRLINKS::RESET_UNIT, 1, nullptr, SYRLINKS::ACK_SIZE, false, + true, SYRLINKS::ACK_REPLY); + this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_STANDBY, 1, nullptr, SYRLINKS::ACK_SIZE, + false, true, SYRLINKS::ACK_REPLY); + this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_MODULATION, 1, nullptr, SYRLINKS::ACK_SIZE, + false, true, SYRLINKS::ACK_REPLY); + this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_CW, 1, nullptr, SYRLINKS::ACK_SIZE, false, + true, SYRLINKS::ACK_REPLY); + this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_STATUS, 1, &txDataset, + SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_WAVEFORM, 1, &txDataset, + SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE, 1, &txDataset, + SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE, 1, &txDataset, + SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + this->insertInCommandAndReplyMap(SYRLINKS::READ_RX_STATUS_REGISTERS, 1, &rxDataset, + SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE); } -ReturnValue_t SyrlinksHkHandler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { +ReturnValue_t SyrlinksHkHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + if (*start != '<') { + sif::error << "SyrlinksHkHandler::scanForReply: Missing start frame character" << std::endl; + return MISSING_START_FRAME_CHARACTER; + } - if(*start != '<') { - sif::error << "SyrlinksHkHandler::scanForReply: Missing start frame character" << std::endl; - return MISSING_START_FRAME_CHARACTER; - } + switch (*(start + 1)) { + case ('A'): + *foundLen = SYRLINKS::ACK_SIZE; + *foundId = SYRLINKS::ACK_REPLY; + break; + case ('E'): + *foundLen = SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE; + *foundId = SYRLINKS::READ_RX_STATUS_REGISTERS; + break; + case ('R'): + *foundId = rememberCommandId; + *foundLen = SYRLINKS::READ_ONE_REGISTER_REPLY_SIE; + break; + default: + sif::error << "SyrlinksHkHandler::scanForReply: Unknown reply identifier" << std::endl; + result = IGNORE_REPLY_DATA; + break; + } - switch(*(start + 1)) { - case('A'): - *foundLen = SYRLINKS::ACK_SIZE; - *foundId = SYRLINKS::ACK_REPLY; - break; - case('E'): - *foundLen = SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE; - *foundId = SYRLINKS::READ_RX_STATUS_REGISTERS; - break; - case('R'): - *foundId = rememberCommandId; - *foundLen = SYRLINKS::READ_ONE_REGISTER_REPLY_SIE; - break; - default: - sif::error << "SyrlinksHkHandler::scanForReply: Unknown reply identifier" << std::endl; - result = IGNORE_REPLY_DATA; - break; - } - - return result; + return result; } -ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { +ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { + ReturnValue_t result; - ReturnValue_t result; - - switch (id) { + switch (id) { case (SYRLINKS::ACK_REPLY): - result = verifyReply(packet, SYRLINKS::ACK_SIZE); - if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Acknowledgement reply has " - "invalid crc" << std::endl; - return CRC_FAILURE; - } - result = parseReplyStatus(reinterpret_cast(packet + SYRLINKS::MESSAGE_HEADER_SIZE)); - if (result != RETURN_OK) { - return result; - } - break; - case(SYRLINKS::READ_RX_STATUS_REGISTERS): - result = verifyReply(packet, SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE); - if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read rx status registers reply " - << "has invalid crc" << std::endl; - return CRC_FAILURE; - } - parseRxStatusRegistersReply(packet); - break; - case(SYRLINKS::READ_TX_STATUS): - result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx status reply " - << "has invalid crc" << std::endl; - return CRC_FAILURE; - } - parseTxStatusReply(packet); - break; - case(SYRLINKS::READ_TX_WAVEFORM): - result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx waveform reply " - << "has invalid crc" << std::endl; - return CRC_FAILURE; - } - parseTxWaveformReply(packet); - break; - case(SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): - result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx AGC high byte reply " - << "has invalid crc" << std::endl; - return CRC_FAILURE; - } - parseAgcHighByte(packet); - break; - case(SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): - result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx AGC low byte reply " - << "has invalid crc" << std::endl; - return CRC_FAILURE; - } - parseAgcLowByte(packet); - break; - default: { - sif::debug << "SyrlinksHkHandler::interpretDeviceReply: Unknown device reply id" - << std::endl; - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } - } + result = verifyReply(packet, SYRLINKS::ACK_SIZE); + if (result != RETURN_OK) { + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Acknowledgement reply has " + "invalid crc" + << std::endl; + return CRC_FAILURE; + } + result = + parseReplyStatus(reinterpret_cast(packet + SYRLINKS::MESSAGE_HEADER_SIZE)); + if (result != RETURN_OK) { + return result; + } + break; + case (SYRLINKS::READ_RX_STATUS_REGISTERS): + result = verifyReply(packet, SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE); + if (result != RETURN_OK) { + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read rx status registers reply " + << "has invalid crc" << std::endl; + return CRC_FAILURE; + } + parseRxStatusRegistersReply(packet); + break; + case (SYRLINKS::READ_TX_STATUS): + result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + if (result != RETURN_OK) { + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx status reply " + << "has invalid crc" << std::endl; + return CRC_FAILURE; + } + parseTxStatusReply(packet); + break; + case (SYRLINKS::READ_TX_WAVEFORM): + result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + if (result != RETURN_OK) { + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx waveform reply " + << "has invalid crc" << std::endl; + return CRC_FAILURE; + } + parseTxWaveformReply(packet); + break; + case (SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): + result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + if (result != RETURN_OK) { + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx AGC high byte reply " + << "has invalid crc" << std::endl; + return CRC_FAILURE; + } + parseAgcHighByte(packet); + break; + case (SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): + result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + if (result != RETURN_OK) { + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx AGC low byte reply " + << "has invalid crc" << std::endl; + return CRC_FAILURE; + } + parseAgcLowByte(packet); + break; + default: { + sif::debug << "SyrlinksHkHandler::interpretDeviceReply: Unknown device reply id" << std::endl; + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; + } + } - return RETURN_OK; + return RETURN_OK; } LocalPoolDataSetBase* SyrlinksHkHandler::getDataSetHandle(sid_t sid) { - if (sid == rxDataset.getSid()) { - return &rxDataset; - } - else if (sid== txDataset.getSid()) { - return &txDataset; - } - else { - sif::error << "SyrlinksHkHandler::getDataSetHandle: Invalid sid" << std::endl; - return nullptr; - } + if (sid == rxDataset.getSid()) { + return &rxDataset; + } else if (sid == txDataset.getSid()) { + return &txDataset; + } else { + sif::error << "SyrlinksHkHandler::getDataSetHandle: Invalid sid" << std::endl; + return nullptr; + } } std::string SyrlinksHkHandler::convertUint16ToHexString(uint16_t intValue) { - std::stringstream stream; - stream << std::setfill('0') << std::setw(4) << std::hex << std::uppercase << intValue; - return stream.str(); + std::stringstream stream; + stream << std::setfill('0') << std::setw(4) << std::hex << std::uppercase << intValue; + return stream.str(); } uint8_t SyrlinksHkHandler::convertHexStringToUint8(const char* twoChars) { - uint32_t value; - std::string hexString(twoChars, 2); - std::stringstream stream; - stream << std::hex << hexString; - stream >> value; - return static_cast(value); + uint32_t value; + std::string hexString(twoChars, 2); + std::stringstream stream; + stream << std::hex << hexString; + stream >> value; + return static_cast(value); } uint16_t SyrlinksHkHandler::convertHexStringToUint16(const char* fourChars) { - uint16_t value = 0; - value = convertHexStringToUint8(fourChars) << 8 | convertHexStringToUint8(fourChars+2); - return value; + uint16_t value = 0; + value = convertHexStringToUint8(fourChars) << 8 | convertHexStringToUint8(fourChars + 2); + return value; } -uint32_t SyrlinksHkHandler::convertHexStringToUint32(const char* characters, uint8_t numberOfChars) { +uint32_t SyrlinksHkHandler::convertHexStringToUint32(const char* characters, + uint8_t numberOfChars) { + uint32_t value = 0; - uint32_t value = 0; - - switch (numberOfChars) { + switch (numberOfChars) { case 6: - value = convertHexStringToUint8(characters) << 16 - | convertHexStringToUint8(characters + 2) << 8 - | convertHexStringToUint8(characters + 4); - return value; + value = convertHexStringToUint8(characters) << 16 | + convertHexStringToUint8(characters + 2) << 8 | + convertHexStringToUint8(characters + 4); + return value; case 8: - value = convertHexStringToUint8(characters) << 24 - | convertHexStringToUint8(characters + 2) << 16 - | convertHexStringToUint8(characters + 4) << 8 - | convertHexStringToUint8(characters + 4); - return value; + value = convertHexStringToUint8(characters) << 24 | + convertHexStringToUint8(characters + 2) << 16 | + convertHexStringToUint8(characters + 4) << 8 | + convertHexStringToUint8(characters + 4); + return value; default: - sif::debug << "SyrlinksHkHandler::convertHexStringToUint32: Invalid number of characters. " - << "Must be either 6 or 8" << std::endl; - return 0; - } + sif::debug << "SyrlinksHkHandler::convertHexStringToUint32: Invalid number of characters. " + << "Must be either 6 or 8" << std::endl; + return 0; + } } ReturnValue_t SyrlinksHkHandler::parseReplyStatus(const char* status) { - switch (*status) { + switch (*status) { case '0': - return RETURN_OK; + return RETURN_OK; case '1': - sif::debug << "SyrlinksHkHandler::parseReplyStatus: Uart faming or parity error" - << std::endl; - return UART_FRAMIN_OR_PARITY_ERROR_ACK; + sif::debug << "SyrlinksHkHandler::parseReplyStatus: Uart faming or parity error" << std::endl; + return UART_FRAMIN_OR_PARITY_ERROR_ACK; case '2': - sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad character detected" << std::endl; - return BAD_CHARACTER_ACK; + sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad character detected" << std::endl; + return BAD_CHARACTER_ACK; case '3': - sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad parameter value (unexpected value " - << "detected" << std::endl; - return BAD_PARAMETER_VALUE_ACK; + sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad parameter value (unexpected value " + << "detected" << std::endl; + return BAD_PARAMETER_VALUE_ACK; case '4': - sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad end of frame" << std::endl; - return BAD_END_OF_FRAME_ACK; + sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad end of frame" << std::endl; + return BAD_END_OF_FRAME_ACK; case '5': - sif::debug << "SyrlinksHkHandler::parseReplyStatus: Unknown command id or attempt to access" - << " a protected register" << std::endl; - return UNKNOWN_COMMAND_ID_ACK; + sif::debug << "SyrlinksHkHandler::parseReplyStatus: Unknown command id or attempt to access" + << " a protected register" << std::endl; + return UNKNOWN_COMMAND_ID_ACK; case '6': - sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad CRC" << std::endl; - return BAD_CRC_ACK; + sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad CRC" << std::endl; + return BAD_CRC_ACK; default: - sif::debug << "SyrlinksHkHandler::parseReplyStatus: Status reply contains an invalid " - << "status id" << std::endl; - return RETURN_FAILED; - } + sif::debug << "SyrlinksHkHandler::parseReplyStatus: Status reply contains an invalid " + << "status id" << std::endl; + return RETURN_FAILED; + } } ReturnValue_t SyrlinksHkHandler::verifyReply(const uint8_t* packet, uint8_t size) { - int result = 0; - /* Calculate crc from received packet */ - uint16_t crc = CRC::crc16ccitt(packet, size - SYRLINKS::SIZE_CRC_AND_TERMINATION, - CRC_INITIAL_VALUE); - std::string recalculatedCrc = convertUint16ToHexString(crc); + int result = 0; + /* Calculate crc from received packet */ + uint16_t crc = + CRC::crc16ccitt(packet, size - SYRLINKS::SIZE_CRC_AND_TERMINATION, CRC_INITIAL_VALUE); + std::string recalculatedCrc = convertUint16ToHexString(crc); - const char* startOfCrc = reinterpret_cast(packet + size - SYRLINKS::SIZE_CRC_AND_TERMINATION); - const char* endOfCrc = reinterpret_cast(packet + size - 1); + const char* startOfCrc = + reinterpret_cast(packet + size - SYRLINKS::SIZE_CRC_AND_TERMINATION); + const char* endOfCrc = reinterpret_cast(packet + size - 1); - std::string replyCrc(startOfCrc, endOfCrc); + std::string replyCrc(startOfCrc, endOfCrc); - result = recalculatedCrc.compare(replyCrc); - if (result != 0) { - return RETURN_FAILED; - } - return RETURN_OK; + result = recalculatedCrc.compare(replyCrc); + if (result != 0) { + return RETURN_FAILED; + } + return RETURN_OK; } void SyrlinksHkHandler::parseRxStatusRegistersReply(const uint8_t* packet) { - PoolReadGuard readHelper(&rxDataset); - uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; - rxDataset.rxStatus = convertHexStringToUint8(reinterpret_cast(packet + offset)); - offset += 2; - rxDataset.rxSensitivity = convertHexStringToUint32(reinterpret_cast(packet + offset), 6); - offset += 6; - rxDataset.rxFrequencyShift = convertHexStringToUint32(reinterpret_cast(packet + offset), 6); - offset += 6; - rxDataset.rxIqPower = convertHexStringToUint16(reinterpret_cast(packet + offset)); - offset += 4; - rxDataset.rxAgcValue = convertHexStringToUint16(reinterpret_cast(packet + offset)); - offset += 4; - offset += 2; // reserved register - rxDataset.rxDemodEb= convertHexStringToUint32(reinterpret_cast(packet + offset), 6); - offset += 6; - rxDataset.rxDemodN0= convertHexStringToUint32(reinterpret_cast(packet + offset), 6); - offset += 6; - rxDataset.rxDataRate = convertHexStringToUint8(reinterpret_cast(packet + offset)); + PoolReadGuard readHelper(&rxDataset); + uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; + rxDataset.rxStatus = convertHexStringToUint8(reinterpret_cast(packet + offset)); + offset += 2; + rxDataset.rxSensitivity = + convertHexStringToUint32(reinterpret_cast(packet + offset), 6); + offset += 6; + rxDataset.rxFrequencyShift = + convertHexStringToUint32(reinterpret_cast(packet + offset), 6); + offset += 6; + rxDataset.rxIqPower = convertHexStringToUint16(reinterpret_cast(packet + offset)); + offset += 4; + rxDataset.rxAgcValue = convertHexStringToUint16(reinterpret_cast(packet + offset)); + offset += 4; + offset += 2; // reserved register + rxDataset.rxDemodEb = convertHexStringToUint32(reinterpret_cast(packet + offset), 6); + offset += 6; + rxDataset.rxDemodN0 = convertHexStringToUint32(reinterpret_cast(packet + offset), 6); + offset += 6; + rxDataset.rxDataRate = convertHexStringToUint8(reinterpret_cast(packet + offset)); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1 - sif::info << "Syrlinks RX Status: 0x" << std::hex << (unsigned int)rxDataset.rxStatus.value << std::endl; - sif::info << "Syrlinks RX Sensitivity: " << std::dec << rxDataset.rxSensitivity << std::endl; - sif::info << "Syrlinks RX Frequency Shift: " << rxDataset.rxFrequencyShift << std::endl; - sif::info << "Syrlinks RX IQ Power: " << rxDataset.rxIqPower << std::endl; - sif::info << "Syrlinks RX AGC Value: " << rxDataset.rxAgcValue << std::endl; - sif::info << "Syrlinks RX Demod Eb: " << rxDataset.rxDemodEb << std::endl; - sif::info << "Syrlinks RX Demod N0: " << rxDataset.rxDemodN0 << std::endl; - sif::info << "Syrlinks RX Datarate: " << (unsigned int)rxDataset.rxDataRate.value << std::endl; + sif::info << "Syrlinks RX Status: 0x" << std::hex << (unsigned int)rxDataset.rxStatus.value + << std::endl; + sif::info << "Syrlinks RX Sensitivity: " << std::dec << rxDataset.rxSensitivity << std::endl; + sif::info << "Syrlinks RX Frequency Shift: " << rxDataset.rxFrequencyShift << std::endl; + sif::info << "Syrlinks RX IQ Power: " << rxDataset.rxIqPower << std::endl; + sif::info << "Syrlinks RX AGC Value: " << rxDataset.rxAgcValue << std::endl; + sif::info << "Syrlinks RX Demod Eb: " << rxDataset.rxDemodEb << std::endl; + sif::info << "Syrlinks RX Demod N0: " << rxDataset.rxDemodN0 << std::endl; + sif::info << "Syrlinks RX Datarate: " << (unsigned int)rxDataset.rxDataRate.value << std::endl; #endif } void SyrlinksHkHandler::parseTxStatusReply(const uint8_t* packet) { - PoolReadGuard readHelper(&txDataset); - uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; - txDataset.txStatus = convertHexStringToUint8(reinterpret_cast(packet + offset)); + PoolReadGuard readHelper(&txDataset); + uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; + txDataset.txStatus = convertHexStringToUint8(reinterpret_cast(packet + offset)); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1 - sif::info << "Syrlinks TX Status: 0x" << std::hex << (unsigned int) txDataset.txStatus.value + sif::info << "Syrlinks TX Status: 0x" << std::hex << (unsigned int)txDataset.txStatus.value << std::endl; #endif } void SyrlinksHkHandler::parseTxWaveformReply(const uint8_t* packet) { - PoolReadGuard readHelper(&txDataset); - uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; - txDataset.txWaveform = convertHexStringToUint8(reinterpret_cast(packet + offset)); + PoolReadGuard readHelper(&txDataset); + uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; + txDataset.txWaveform = convertHexStringToUint8(reinterpret_cast(packet + offset)); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1 - sif::info << "Syrlinks TX Waveform: 0x" << std::hex << (unsigned int) txDataset.txWaveform.value + sif::info << "Syrlinks TX Waveform: 0x" << std::hex << (unsigned int)txDataset.txWaveform.value << std::endl; #endif } void SyrlinksHkHandler::parseAgcLowByte(const uint8_t* packet) { - PoolReadGuard readHelper(&txDataset); - uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; - txDataset.txAgcValue = agcValueHighByte << 8 | convertHexStringToUint8(reinterpret_cast(packet + offset)); + PoolReadGuard readHelper(&txDataset); + uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; + txDataset.txAgcValue = agcValueHighByte << 8 | + convertHexStringToUint8(reinterpret_cast(packet + offset)); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1 - sif::info << "Syrlinks TX AGC Value: " << txDataset.txAgcValue << std::endl; + sif::info << "Syrlinks TX AGC Value: " << txDataset.txAgcValue << std::endl; #endif } void SyrlinksHkHandler::parseAgcHighByte(const uint8_t* packet) { - PoolReadGuard readHelper(&txDataset); - uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; - agcValueHighByte = convertHexStringToUint8(reinterpret_cast(packet + offset)); + PoolReadGuard readHelper(&txDataset); + uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; + agcValueHighByte = convertHexStringToUint8(reinterpret_cast(packet + offset)); } -void SyrlinksHkHandler::setNormalDatapoolEntriesInvalid(){ +void SyrlinksHkHandler::setNormalDatapoolEntriesInvalid() {} -} - -uint32_t SyrlinksHkHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){ - return 500; -} +uint32_t SyrlinksHkHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } ReturnValue_t SyrlinksHkHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { + LocalDataPoolManager& poolManager) { + localDataPoolMap.emplace(SYRLINKS::RX_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::RX_SENSITIVITY, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::RX_FREQUENCY_SHIFT, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::RX_IQ_POWER, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::RX_AGC_VALUE, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::RX_DEMOD_EB, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::RX_DEMOD_N0, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::RX_DATA_RATE, new PoolEntry({0})); - localDataPoolMap.emplace(SYRLINKS::RX_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::RX_SENSITIVITY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::RX_FREQUENCY_SHIFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::RX_IQ_POWER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::RX_AGC_VALUE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::RX_DEMOD_EB, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::RX_DEMOD_N0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::RX_DATA_RATE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(SYRLINKS::TX_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::TX_WAVEFORM, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::TX_AGC_VALUE, new PoolEntry({0})); - localDataPoolMap.emplace(SYRLINKS::TX_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::TX_WAVEFORM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::TX_AGC_VALUE, new PoolEntry( { 0 })); - - return HasReturnvaluesIF::RETURN_OK; -} - -void SyrlinksHkHandler::setModeNormal() { - mode = MODE_NORMAL; + return HasReturnvaluesIF::RETURN_OK; } +void SyrlinksHkHandler::setModeNormal() { mode = MODE_NORMAL; } diff --git a/mission/devices/SyrlinksHkHandler.h b/mission/devices/SyrlinksHkHandler.h index c194fd18..ea39dc61 100644 --- a/mission/devices/SyrlinksHkHandler.h +++ b/mission/devices/SyrlinksHkHandler.h @@ -13,166 +13,162 @@ * * @author J. Meier */ -class SyrlinksHkHandler: public DeviceHandlerBase { -public: +class SyrlinksHkHandler : public DeviceHandlerBase { + public: + SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + virtual ~SyrlinksHkHandler(); - SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie); - virtual ~SyrlinksHkHandler(); + /** + * @brief Sets mode to MODE_NORMAL. Can be used for debugging. + */ + void setModeNormal(); - /** - * @brief Sets mode to MODE_NORMAL. Can be used for debugging. - */ - void setModeNormal(); + 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; + LocalPoolDataSetBase* getDataSetHandle(sid_t sid) 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; - LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::SYRLINKS_HANDLER; -private: + static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0); + static const ReturnValue_t UART_FRAMIN_OR_PARITY_ERROR_ACK = MAKE_RETURN_CODE(0xA1); + static const ReturnValue_t BAD_CHARACTER_ACK = MAKE_RETURN_CODE(0xA2); + static const ReturnValue_t BAD_PARAMETER_VALUE_ACK = MAKE_RETURN_CODE(0xA3); + static const ReturnValue_t BAD_END_OF_FRAME_ACK = MAKE_RETURN_CODE(0xA4); + static const ReturnValue_t UNKNOWN_COMMAND_ID_ACK = MAKE_RETURN_CODE(0xA5); + static const ReturnValue_t BAD_CRC_ACK = MAKE_RETURN_CODE(0xA6); + static const ReturnValue_t REPLY_WRONG_SIZE = MAKE_RETURN_CODE(0xA7); + static const ReturnValue_t MISSING_START_FRAME_CHARACTER = MAKE_RETURN_CODE(0xA8); - static const uint8_t INTERFACE_ID = CLASS_ID::SYRLINKS_HANDLER; + static const uint8_t CRC_INITIAL_VALUE = 0x0; - static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0); - static const ReturnValue_t UART_FRAMIN_OR_PARITY_ERROR_ACK = MAKE_RETURN_CODE(0xA1); - static const ReturnValue_t BAD_CHARACTER_ACK = MAKE_RETURN_CODE(0xA2); - static const ReturnValue_t BAD_PARAMETER_VALUE_ACK = MAKE_RETURN_CODE(0xA3); - static const ReturnValue_t BAD_END_OF_FRAME_ACK = MAKE_RETURN_CODE(0xA4); - static const ReturnValue_t UNKNOWN_COMMAND_ID_ACK = MAKE_RETURN_CODE(0xA5); - static const ReturnValue_t BAD_CRC_ACK = MAKE_RETURN_CODE(0xA6); - static const ReturnValue_t REPLY_WRONG_SIZE = MAKE_RETURN_CODE(0xA7); - static const ReturnValue_t MISSING_START_FRAME_CHARACTER = MAKE_RETURN_CODE(0xA8); + std::string resetCommand = ""; + std::string readRxStatusRegCommand = ""; + std::string setTxModeStandby = ""; + /** W - write, 04 - 4 bytes in data field, 01 - value, 40 register to write value */ + std::string setTxModeModulation = ""; + std::string setTxModeCw = ""; + std::string readTxStatus = ""; + std::string readTxWaveform = ""; + std::string readTxAgcValueHighByte = ""; + std::string readTxAgcValueLowByte = ""; - static const uint8_t CRC_INITIAL_VALUE = 0x0; + /** + * In some cases it is not possible to extract from the received reply the information about + * the associated command. This variable is thus used to remember the command id. + */ + DeviceCommandId_t rememberCommandId = SYRLINKS::NONE; - std::string resetCommand = ""; - std::string readRxStatusRegCommand = ""; - std::string setTxModeStandby = ""; - /** W - write, 04 - 4 bytes in data field, 01 - value, 40 register to write value */ - std::string setTxModeModulation = ""; - std::string setTxModeCw = ""; - std::string readTxStatus = ""; - std::string readTxWaveform = ""; - std::string readTxAgcValueHighByte = ""; - std::string readTxAgcValueLowByte = ""; + SYRLINKS::RxDataset rxDataset; + SYRLINKS::TxDataset txDataset; - /** - * In some cases it is not possible to extract from the received reply the information about - * the associated command. This variable is thus used to remember the command id. - */ - DeviceCommandId_t rememberCommandId = SYRLINKS::NONE; + uint8_t agcValueHighByte; - SYRLINKS::RxDataset rxDataset; - SYRLINKS::TxDataset txDataset; + uint8_t commandBuffer[SYRLINKS::MAX_COMMAND_SIZE]; - uint8_t agcValueHighByte; + /** + * This object is used to store the id of the next command to execute. This controls the + * read out of multiple registers which can not be fetched with one single command. + */ + DeviceCommandId_t nextCommand = SYRLINKS::READ_RX_STATUS_REGISTERS; - uint8_t commandBuffer[SYRLINKS::MAX_COMMAND_SIZE]; + /** + * @brief This function converts an uint16_t into its hexadecimal string representation. + * + * @param intValue The value to convert. + * + * @return An std::string object containing the hex representation of intValue. + */ + std::string convertUint16ToHexString(uint16_t intValue); - /** - * This object is used to store the id of the next command to execute. This controls the - * read out of multiple registers which can not be fetched with one single command. - */ - DeviceCommandId_t nextCommand = SYRLINKS::READ_RX_STATUS_REGISTERS; + /** + * @brief This function converts a hex number represented by to chars to an 8-bit integer. + * + * @param twoChars Pointer to the two characters representing the hex value. + * + * @details E.g. when twoChars points to an array with the two characters "A5" then the function + * will return 0xA5. + * @return The converted integer. + */ + uint8_t convertHexStringToUint8(const char* twoChars); - /** - * @brief This function converts an uint16_t into its hexadecimal string representation. - * - * @param intValue The value to convert. - * - * @return An std::string object containing the hex representation of intValue. - */ - std::string convertUint16ToHexString(uint16_t intValue); + /** + * @brief This function converts a hex number represented by 4 chars to an uint16_t. + * + * @param Pointer to the fourCharacters representing the 16-bit integer. + * + * @return The uint16_t result. + */ + uint16_t convertHexStringToUint16(const char* fourChars); - /** - * @brief This function converts a hex number represented by to chars to an 8-bit integer. - * - * @param twoChars Pointer to the two characters representing the hex value. - * - * @details E.g. when twoChars points to an array with the two characters "A5" then the function - * will return 0xA5. - * @return The converted integer. - */ - uint8_t convertHexStringToUint8(const char* twoChars); + /** + * @brief Function converts a hex number represented by 6 or 8 characters to an uint32_t. + * + * @param characters Pointer to the hex characters array. + * @param numberOfChars Number of characters representing the hex value. Must be 6 or 8. + * + * @return The uint32_t value. + */ + uint32_t convertHexStringToUint32(const char* characters, uint8_t numberOfChars); - /** - * @brief This function converts a hex number represented by 4 chars to an uint16_t. - * - * @param Pointer to the fourCharacters representing the 16-bit integer. - * - * @return The uint16_t result. - */ - uint16_t convertHexStringToUint16(const char* fourChars); + /** + * @brief This function parses the status reply + * @param status Pointer to the status information. + * + * @details Some commands reply with a status message giving information about the preceding + * command transmission and/or execution was successful. + */ + ReturnValue_t parseReplyStatus(const char* status); - /** - * @brief Function converts a hex number represented by 6 or 8 characters to an uint32_t. - * - * @param characters Pointer to the hex characters array. - * @param numberOfChars Number of characters representing the hex value. Must be 6 or 8. - * - * @return The uint32_t value. - */ - uint32_t convertHexStringToUint32(const char* characters, uint8_t numberOfChars); + /** + * @brief Function verifies the received reply from the syrlinks by recalculating and + * comparing the crc. + * + * @param packet Pointer to the received reply. + * @param size Size of the whole packet including the crc and the packet termination + * character '>'. + * + * @return RETURN_OK if successful, otherwise RETURN_FAILED. + */ + ReturnValue_t verifyReply(const uint8_t* packet, uint8_t size); - /** - * @brief This function parses the status reply - * @param status Pointer to the status information. - * - * @details Some commands reply with a status message giving information about the preceding - * command transmission and/or execution was successful. - */ - ReturnValue_t parseReplyStatus(const char* status); + /** + * @brief This function extracts the data from a rx status registers reply and writes the + * information to the status registers dataset. + * @param packet Pointer to the reply packet. + */ + void parseRxStatusRegistersReply(const uint8_t* packet); - /** - * @brief Function verifies the received reply from the syrlinks by recalculating and - * comparing the crc. - * - * @param packet Pointer to the received reply. - * @param size Size of the whole packet including the crc and the packet termination - * character '>'. - * - * @return RETURN_OK if successful, otherwise RETURN_FAILED. - */ - ReturnValue_t verifyReply(const uint8_t* packet, uint8_t size); + /** + * @brief This function writes the read tx status register to the txStatusDataset. + * @param packet Pointer to the received packet. + */ + void parseTxStatusReply(const uint8_t* packet); - /** - * @brief This function extracts the data from a rx status registers reply and writes the - * information to the status registers dataset. - * @param packet Pointer to the reply packet. - */ - void parseRxStatusRegistersReply(const uint8_t* packet); + /** + * @brief This function writes the received waveform configuration to the txDataset. + */ + void parseTxWaveformReply(const uint8_t* packet); - /** - * @brief This function writes the read tx status register to the txStatusDataset. - * @param packet Pointer to the received packet. - */ - void parseTxStatusReply(const uint8_t* packet); - - /** - * @brief This function writes the received waveform configuration to the txDataset. - */ - void parseTxWaveformReply(const uint8_t* packet); - - /** - * @brief The agc value is split over two registers. The parse agc functions are used to get - * the values from the received reply and write them into the txDataset. - */ - void parseAgcLowByte(const uint8_t* packet); - void parseAgcHighByte(const uint8_t* packet); + /** + * @brief The agc value is split over two registers. The parse agc functions are used to get + * the values from the received reply and write them into the txDataset. + */ + void parseAgcLowByte(const uint8_t* packet); + void parseAgcHighByte(const uint8_t* packet); }; #endif /* MISSION_DEVICES_SYRLINKSHKHANDLER_H_ */ diff --git a/mission/devices/Tmp1075Handler.cpp b/mission/devices/Tmp1075Handler.cpp index 95b8685f..59298851 100644 --- a/mission/devices/Tmp1075Handler.cpp +++ b/mission/devices/Tmp1075Handler.cpp @@ -1,145 +1,124 @@ +#include #include #include -#include -Tmp1075Handler::Tmp1075Handler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie) : - DeviceHandlerBase(objectId, comIF, comCookie), dataset( - this) { - if (comCookie == NULL) { - sif::error << "Tmp1075Handler: Invalid com cookie" << std::endl; - } +Tmp1075Handler::Tmp1075Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie) + : DeviceHandlerBase(objectId, comIF, comCookie), dataset(this) { + if (comCookie == NULL) { + sif::error << "Tmp1075Handler: Invalid com cookie" << std::endl; + } } -Tmp1075Handler::~Tmp1075Handler() { +Tmp1075Handler::~Tmp1075Handler() {} + +void Tmp1075Handler::doStartUp() { + if (mode == _MODE_START_UP) { + setMode(MODE_ON); + } } +void Tmp1075Handler::doShutDown() { setMode(_MODE_POWER_DOWN); } -void Tmp1075Handler::doStartUp(){ - if(mode == _MODE_START_UP){ - setMode(MODE_ON); - } +ReturnValue_t Tmp1075Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + if (communicationStep == CommunicationStep::START_ADC_CONVERSION) { + *id = TMP1075::START_ADC_CONVERSION; + communicationStep = CommunicationStep::GET_TEMPERATURE; + return buildCommandFromCommand(*id, NULL, 0); + } else { + *id = TMP1075::GET_TEMP; + communicationStep = CommunicationStep::START_ADC_CONVERSION; + return buildCommandFromCommand(*id, NULL, 0); + } + return HasReturnvaluesIF::RETURN_OK; } -void Tmp1075Handler::doShutDown(){ - setMode(_MODE_POWER_DOWN); +ReturnValue_t Tmp1075Handler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t Tmp1075Handler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - - if(communicationStep == CommunicationStep::START_ADC_CONVERSION) { - *id = TMP1075::START_ADC_CONVERSION; - communicationStep = CommunicationStep::GET_TEMPERATURE; - return buildCommandFromCommand(*id, NULL, 0); - } - else { - *id = TMP1075::GET_TEMP; - communicationStep = CommunicationStep::START_ADC_CONVERSION; - return buildCommandFromCommand(*id, NULL, 0); - } - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t Tmp1075Handler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, + size_t commandDataLen) { + switch (deviceCommand) { + case (TMP1075::START_ADC_CONVERSION): { + std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); + prepareAdcConversionCommand(); + rawPacket = cmdBuffer; + rawPacketLen = TMP1075::CFGR_CMD_SIZE; + return RETURN_OK; + } + case (TMP1075::GET_TEMP): { + std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); + prepareGetTempCommand(); + rawPacket = cmdBuffer; + rawPacketLen = TMP1075::POINTER_REG_SIZE; + rememberCommandId = TMP1075::GET_TEMP; + return RETURN_OK; + } + default: + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } -ReturnValue_t Tmp1075Handler::buildTransitionDeviceCommand( - DeviceCommandId_t * id){ - return HasReturnvaluesIF::RETURN_OK; +void Tmp1075Handler::fillCommandAndReplyMap() { + this->insertInCommandMap(TMP1075::START_ADC_CONVERSION); + this->insertInCommandAndReplyMap(TMP1075::GET_TEMP, 1, &dataset, TMP1075::GET_TEMP_REPLY_SIZE); } -ReturnValue_t Tmp1075Handler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t * commandData, - size_t commandDataLen) { - switch(deviceCommand) { - case(TMP1075::START_ADC_CONVERSION): { - std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); - prepareAdcConversionCommand(); - rawPacket = cmdBuffer; - rawPacketLen = TMP1075::CFGR_CMD_SIZE; - return RETURN_OK; - } - case(TMP1075::GET_TEMP): { - std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); - prepareGetTempCommand(); - rawPacket = cmdBuffer; - rawPacketLen = TMP1075::POINTER_REG_SIZE; - rememberCommandId = TMP1075::GET_TEMP; - return RETURN_OK; - } - default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; +ReturnValue_t Tmp1075Handler::scanForReply(const uint8_t *start, size_t remainingSize, + DeviceCommandId_t *foundId, size_t *foundLen) { + switch (rememberCommandId) { + case (TMP1075::GET_TEMP): + *foundId = TMP1075::GET_TEMP; + *foundLen = TMP1075::GET_TEMP_REPLY_SIZE; + rememberCommandId = TMP1075::NONE; + break; + default: + return IGNORE_REPLY_DATA; + } + return HasReturnvaluesIF::RETURN_OK; } -void Tmp1075Handler::fillCommandAndReplyMap(){ - this->insertInCommandMap(TMP1075::START_ADC_CONVERSION); - this->insertInCommandAndReplyMap(TMP1075::GET_TEMP, 1, &dataset, - TMP1075::GET_TEMP_REPLY_SIZE); -} - -ReturnValue_t Tmp1075Handler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { - switch(rememberCommandId) { - case(TMP1075::GET_TEMP): - *foundId = TMP1075::GET_TEMP; - *foundLen = TMP1075::GET_TEMP_REPLY_SIZE; - rememberCommandId = TMP1075::NONE; - break; - default: - return IGNORE_REPLY_DATA; - } - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t Tmp1075Handler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { - switch (id) { - case TMP1075::GET_TEMP: { - int16_t tempValueRaw = 0; - tempValueRaw = packet[0] << 4 | packet[1] >> 4; - float tempValue = ((static_cast(tempValueRaw)) * 0.0625); +ReturnValue_t Tmp1075Handler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { + switch (id) { + case TMP1075::GET_TEMP: { + int16_t tempValueRaw = 0; + tempValueRaw = packet[0] << 4 | packet[1] >> 4; + float tempValue = ((static_cast(tempValueRaw)) * 0.0625); #if OBSW_VERBOSE_LEVEL >= 1 - sif::info << "Tmp1075 with object id: 0x" << std::hex << getObjectId() - << ": Temperature: " << tempValue<< " °C" - << std::endl; + sif::info << "Tmp1075 with object id: 0x" << std::hex << getObjectId() + << ": Temperature: " << tempValue << " °C" << std::endl; #endif - ReturnValue_t result = dataset.read(); - if(result == HasReturnvaluesIF::RETURN_OK) { - dataset.temperatureCelcius = tempValue; - dataset.commit(); - } - break; - } + ReturnValue_t result = dataset.read(); + if (result == HasReturnvaluesIF::RETURN_OK) { + dataset.temperatureCelcius = tempValue; + dataset.commit(); + } + break; + } - default: { - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } - - } - return HasReturnvaluesIF::RETURN_OK; + default: { + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; + } + } + return HasReturnvaluesIF::RETURN_OK; } -void Tmp1075Handler::setNormalDatapoolEntriesInvalid(){ +void Tmp1075Handler::setNormalDatapoolEntriesInvalid() {} +void Tmp1075Handler::prepareAdcConversionCommand() { + cmdBuffer[0] = TMP1075::CFGR_ADDR; + cmdBuffer[1] = TMP1075::ONE_SHOT_MODE >> 8; + cmdBuffer[2] = TMP1075::ONE_SHOT_MODE & 0xFF; } -void Tmp1075Handler::prepareAdcConversionCommand(){ - cmdBuffer[0] = TMP1075::CFGR_ADDR; - cmdBuffer[1] = TMP1075::ONE_SHOT_MODE >> 8; - cmdBuffer[2] = TMP1075::ONE_SHOT_MODE & 0xFF; -} +void Tmp1075Handler::prepareGetTempCommand() { cmdBuffer[0] = TMP1075::TEMP_REG_ADDR; } -void Tmp1075Handler::prepareGetTempCommand(){ - cmdBuffer[0] = TMP1075::TEMP_REG_ADDR; -} +uint32_t Tmp1075Handler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } -uint32_t Tmp1075Handler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){ - return 500; +ReturnValue_t Tmp1075Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(TMP1075::TEMPERATURE_C_TMP1075_1, new PoolEntry({0.0})); + return HasReturnvaluesIF::RETURN_OK; } - -ReturnValue_t Tmp1075Handler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { - localDataPoolMap.emplace(TMP1075::TEMPERATURE_C_TMP1075_1, new PoolEntry( { 0.0 })); - return HasReturnvaluesIF::RETURN_OK; -} - diff --git a/mission/devices/Tmp1075Handler.h b/mission/devices/Tmp1075Handler.h index 190ac47f..3077cf1a 100644 --- a/mission/devices/Tmp1075Handler.h +++ b/mission/devices/Tmp1075Handler.h @@ -15,54 +15,46 @@ * * @author J. Meier */ -class Tmp1075Handler: public DeviceHandlerBase { -public: +class Tmp1075Handler : public DeviceHandlerBase { + public: + Tmp1075Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie); + virtual ~Tmp1075Handler(); - Tmp1075Handler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie); - virtual ~Tmp1075Handler(); + 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; -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; + private: + /** + * @brief Function fills cmdBuffer with command to start the adc + * conversion for a new temperature value. + */ + void prepareAdcConversionCommand(); -private: + void prepareGetTempCommand(); - /** - * @brief Function fills cmdBuffer with command to start the adc - * conversion for a new temperature value. - */ - void prepareAdcConversionCommand(); + enum class CommunicationStep { START_ADC_CONVERSION, GET_TEMPERATURE }; - void prepareGetTempCommand(); + TMP1075::Tmp1075Dataset dataset; - enum class CommunicationStep { - START_ADC_CONVERSION, - GET_TEMPERATURE - }; + static const uint8_t MAX_CMD_LEN = 3; - TMP1075::Tmp1075Dataset dataset; - - static const uint8_t MAX_CMD_LEN = 3; - - uint8_t rememberRequestedSize = 0; - uint8_t rememberCommandId = TMP1075::NONE; - uint8_t cmdBuffer[MAX_CMD_LEN]; - CommunicationStep communicationStep = - CommunicationStep::START_ADC_CONVERSION; + uint8_t rememberRequestedSize = 0; + uint8_t rememberCommandId = TMP1075::NONE; + uint8_t cmdBuffer[MAX_CMD_LEN]; + CommunicationStep communicationStep = CommunicationStep::START_ADC_CONVERSION; }; #endif /* MISSION_DEVICES_TMP1075HANDLER_H_ */ diff --git a/mission/devices/devicedefinitions/GPSDefinitions.h b/mission/devices/devicedefinitions/GPSDefinitions.h index aea442a2..ce58f680 100644 --- a/mission/devices/devicedefinitions/GPSDefinitions.h +++ b/mission/devices/devicedefinitions/GPSDefinitions.h @@ -1,8 +1,8 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_GPSDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_GPSDEFINITIONS_H_ -#include "fsfw/devicehandlers/DeviceHandlerIF.h" #include "fsfw/datapoollocal/StaticLocalDataSet.h" +#include "fsfw/devicehandlers/DeviceHandlerIF.h" namespace GpsHyperion { @@ -11,60 +11,53 @@ static constexpr DeviceCommandId_t TRIGGER_RESET_PIN = 5; static constexpr uint32_t DATASET_ID = 0; -enum GpsPoolIds: lp_id_t { - LATITUDE = 0, - LONGITUDE = 1, - ALTITUDE = 2, - SPEED = 3, - FIX_MODE = 4, - SATS_IN_USE = 5, - SATS_IN_VIEW = 6, - UNIX_SECONDS = 7, - YEAR = 8, - MONTH = 9, - DAY = 10, - HOURS = 11, - MINUTES = 12, - SECONDS = 13 +enum GpsPoolIds : lp_id_t { + LATITUDE = 0, + LONGITUDE = 1, + ALTITUDE = 2, + SPEED = 3, + FIX_MODE = 4, + SATS_IN_USE = 5, + SATS_IN_VIEW = 6, + UNIX_SECONDS = 7, + YEAR = 8, + MONTH = 9, + DAY = 10, + HOURS = 11, + MINUTES = 12, + SECONDS = 13 }; -enum GpsFixModes: uint8_t { - INVALID = 0, - NO_FIX = 1, - FIX_2D = 2, - FIX_3D = 3 -}; +enum GpsFixModes : uint8_t { INVALID = 0, NO_FIX = 1, FIX_2D = 2, FIX_3D = 3 }; -} +} // namespace GpsHyperion -class GpsPrimaryDataset: public StaticLocalDataSet<18> { -public: - GpsPrimaryDataset(object_id_t gpsId): - StaticLocalDataSet(sid_t(gpsId, GpsHyperion::DATASET_ID)) { - setAllVariablesReadOnly(); - } +class GpsPrimaryDataset : public StaticLocalDataSet<18> { + public: + GpsPrimaryDataset(object_id_t gpsId) : StaticLocalDataSet(sid_t(gpsId, GpsHyperion::DATASET_ID)) { + setAllVariablesReadOnly(); + } - lp_var_t latitude = lp_var_t(sid.objectId, - GpsHyperion::LATITUDE, this); - lp_var_t longitude = lp_var_t(sid.objectId, - GpsHyperion::LONGITUDE, this); - lp_var_t altitude = lp_var_t(sid.objectId, GpsHyperion::ALTITUDE, this); - lp_var_t speed = lp_var_t(sid.objectId, GpsHyperion::SPEED, this); - lp_var_t fixMode = lp_var_t(sid.objectId, GpsHyperion::FIX_MODE, this); - lp_var_t satInUse = lp_var_t(sid.objectId, GpsHyperion::SATS_IN_USE, this); - lp_var_t satInView = lp_var_t(sid.objectId, GpsHyperion::SATS_IN_VIEW, this); - lp_var_t year = lp_var_t(sid.objectId, GpsHyperion::YEAR, this); - lp_var_t month = lp_var_t(sid.objectId, GpsHyperion::MONTH, this); - lp_var_t day = lp_var_t(sid.objectId, GpsHyperion::DAY, this); - lp_var_t hours = lp_var_t(sid.objectId, GpsHyperion::HOURS, this); - lp_var_t minutes = lp_var_t(sid.objectId, GpsHyperion::MINUTES, this); - lp_var_t seconds = lp_var_t(sid.objectId, GpsHyperion::SECONDS, this); - lp_var_t unixSeconds = lp_var_t(sid.objectId, - GpsHyperion::UNIX_SECONDS, this); -private: - friend class GPSHyperionHandler; - GpsPrimaryDataset(HasLocalDataPoolIF* hkOwner): - StaticLocalDataSet(hkOwner, GpsHyperion::DATASET_ID) {} + lp_var_t latitude = lp_var_t(sid.objectId, GpsHyperion::LATITUDE, this); + lp_var_t longitude = lp_var_t(sid.objectId, GpsHyperion::LONGITUDE, this); + lp_var_t altitude = lp_var_t(sid.objectId, GpsHyperion::ALTITUDE, this); + lp_var_t speed = lp_var_t(sid.objectId, GpsHyperion::SPEED, this); + lp_var_t fixMode = lp_var_t(sid.objectId, GpsHyperion::FIX_MODE, this); + lp_var_t satInUse = lp_var_t(sid.objectId, GpsHyperion::SATS_IN_USE, this); + lp_var_t satInView = lp_var_t(sid.objectId, GpsHyperion::SATS_IN_VIEW, this); + lp_var_t year = lp_var_t(sid.objectId, GpsHyperion::YEAR, this); + lp_var_t month = lp_var_t(sid.objectId, GpsHyperion::MONTH, this); + lp_var_t day = lp_var_t(sid.objectId, GpsHyperion::DAY, this); + lp_var_t hours = lp_var_t(sid.objectId, GpsHyperion::HOURS, this); + lp_var_t minutes = lp_var_t(sid.objectId, GpsHyperion::MINUTES, this); + lp_var_t seconds = lp_var_t(sid.objectId, GpsHyperion::SECONDS, this); + lp_var_t unixSeconds = + lp_var_t(sid.objectId, GpsHyperion::UNIX_SECONDS, this); + + private: + friend class GPSHyperionHandler; + GpsPrimaryDataset(HasLocalDataPoolIF* hkOwner) + : StaticLocalDataSet(hkOwner, GpsHyperion::DATASET_ID) {} }; #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GPSDEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/GomSpacePackets.h b/mission/devices/devicedefinitions/GomSpacePackets.h index d410a3af..e6736255 100644 --- a/mission/devices/devicedefinitions/GomSpacePackets.h +++ b/mission/devices/devicedefinitions/GomSpacePackets.h @@ -2,37 +2,32 @@ #define MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEPACKETS_H_ #include -#include -#include #include +#include +#include #include - /** * @brief This class can be used to generated the command for the CspComIF * to reset the watchdog in a gomspace device. */ class WatchdogResetCommand : public SerialLinkedListAdapter { -public: + public: + WatchdogResetCommand() { setLinks(); } - WatchdogResetCommand() { - setLinks(); - } - -private: - WatchdogResetCommand(const WatchdogResetCommand &command); - void setLinks() { - setStart(&cspPort); - cspPort.setNext(&querySize); - querySize.setNext(&magic); - } - SerializeElement cspPort = GOMSPACE::P60_PORT_GNDWDT_RESET; - SerializeElement querySize = 1; - /* Sending 0x78 to port 9 of a gomspace device resets the ground watchdog */ - SerializeElement magic = 0x78; + private: + WatchdogResetCommand(const WatchdogResetCommand &command); + void setLinks() { + setStart(&cspPort); + cspPort.setNext(&querySize); + querySize.setNext(&magic); + } + SerializeElement cspPort = GOMSPACE::P60_PORT_GNDWDT_RESET; + SerializeElement querySize = 1; + /* Sending 0x78 to port 9 of a gomspace device resets the ground watchdog */ + SerializeElement magic = 0x78; }; - /** * @brief A serial linked list adapter implementation to generate ping * commands for devices supporting the CSP protocol. This command can @@ -44,33 +39,32 @@ private: * transmitted to the target device. */ class CspPingCommand : public SerialLinkedListAdapter { -public: - /** - * @brief Constructor - * - * @param querySize_ The size of bytes replied by the ping request. - * Amounts to the number of bytes send. - * @param data_ Pointer to data which should be sent to the device. - * All data will be sent back by the ping target. - */ - CspPingCommand(const uint8_t* data_, uint16_t querySize_) : - querySize(querySize_), data(data_, querySize_) { - setLinks(); - } + public: + /** + * @brief Constructor + * + * @param querySize_ The size of bytes replied by the ping request. + * Amounts to the number of bytes send. + * @param data_ Pointer to data which should be sent to the device. + * All data will be sent back by the ping target. + */ + CspPingCommand(const uint8_t *data_, uint16_t querySize_) + : querySize(querySize_), data(data_, querySize_) { + setLinks(); + } -private: - CspPingCommand(const CspPingCommand &command); - void setLinks() { - setStart(&cspPort); - cspPort.setNext(&querySize); - querySize.setNext(&data); - } - SerializeElement cspPort = GOMSPACE::PING_PORT; - SerializeElement querySize; - SerializeElement> data; + private: + CspPingCommand(const CspPingCommand &command); + void setLinks() { + setStart(&cspPort); + cspPort.setNext(&querySize); + querySize.setNext(&data); + } + SerializeElement cspPort = GOMSPACE::PING_PORT; + SerializeElement querySize; + SerializeElement> data; }; - /** * @brief A serial linked list adapter implementation of the gs_rparam_query_t * struct defined in rparam.h. Can be used to build the message to set @@ -81,47 +75,49 @@ private: * and the size to query. */ class CspSetParamCommand : public SerialLinkedListAdapter { -public: + public: + CspSetParamCommand(uint16_t querySize_, uint16_t payloadlength_, uint16_t checksum_, + uint16_t seq_, uint16_t total_, uint16_t addr_, const uint8_t *parameter_, + uint8_t parameterCount_) + : querySize(querySize_), + payloadlength(payloadlength_), + checksum(checksum_), + seq(seq_), + total(total_), + addr(addr_), + parameter(parameter_, parameterCount_) { + setLinks(); + } - CspSetParamCommand(uint16_t querySize_, uint16_t payloadlength_, - uint16_t checksum_, uint16_t seq_, uint16_t total_, uint16_t addr_, - const uint8_t* parameter_, uint8_t parameterCount_) : - querySize(querySize_), payloadlength( - payloadlength_), checksum(checksum_), seq(seq_), total( - total_), addr(addr_), parameter(parameter_, parameterCount_) { - setLinks(); - } - -private: - CspSetParamCommand(const CspSetParamCommand &command); - void setLinks() { - setStart(&cspPort); - cspPort.setNext(&querySize); - querySize.setNext(&action); - action.setNext(&tableId); - tableId.setNext(&payloadlength); - payloadlength.setNext(&checksum); - checksum.setNext(&seq); - seq.setNext(&total); - total.setNext(&addr); - addr.setNext(¶meter); - } - SerializeElement cspPort = GOMSPACE::PARAM_PORT; - /* Only a parameter will be set. No data will be queried with this command */ - SerializeElement querySize; - SerializeElement action = 0xFF; // param set - /* We will never set a parameter in a table other than the configuration - * table */ - SerializeElement tableId = 1; - SerializeElement payloadlength; - SerializeElement checksum; - SerializeElement seq; - SerializeElement total; - SerializeElement addr; - SerializeElement> parameter; + private: + CspSetParamCommand(const CspSetParamCommand &command); + void setLinks() { + setStart(&cspPort); + cspPort.setNext(&querySize); + querySize.setNext(&action); + action.setNext(&tableId); + tableId.setNext(&payloadlength); + payloadlength.setNext(&checksum); + checksum.setNext(&seq); + seq.setNext(&total); + total.setNext(&addr); + addr.setNext(¶meter); + } + SerializeElement cspPort = GOMSPACE::PARAM_PORT; + /* Only a parameter will be set. No data will be queried with this command */ + SerializeElement querySize; + SerializeElement action = 0xFF; // param set + /* We will never set a parameter in a table other than the configuration + * table */ + SerializeElement tableId = 1; + SerializeElement payloadlength; + SerializeElement checksum; + SerializeElement seq; + SerializeElement total; + SerializeElement addr; + SerializeElement> parameter; }; - /** * @brief This class can be used to generate a get param command for the * gomspace devices which will be sent to the device communication @@ -131,50 +127,50 @@ private: * and will not be transmitted physically to the target device. */ class CspGetParamCommand : public SerialLinkedListAdapter { -public: - /* The size of the header of a gomspace CSP packet. */ - static const uint8_t GS_HDR_LENGTH = 12; + public: + /* The size of the header of a gomspace CSP packet. */ + static const uint8_t GS_HDR_LENGTH = 12; - CspGetParamCommand(uint16_t querySize_, uint8_t tableId_, - uint16_t addresslength_, uint16_t checksum_, uint16_t seq_, - uint16_t total_, uint16_t addr_) : - querySize(querySize_), tableId(tableId_), addresslength( - addresslength_), checksum(checksum_), seq(seq_), total( - total_), addr(addr_) { - fixedValuesInit(); - setLinks(); - } + CspGetParamCommand(uint16_t querySize_, uint8_t tableId_, uint16_t addresslength_, + uint16_t checksum_, uint16_t seq_, uint16_t total_, uint16_t addr_) + : querySize(querySize_), + tableId(tableId_), + addresslength(addresslength_), + checksum(checksum_), + seq(seq_), + total(total_), + addr(addr_) { + fixedValuesInit(); + setLinks(); + } -private: - CspGetParamCommand(const CspGetParamCommand &command); - void setLinks() { - setStart(&cspPort); - cspPort.setNext(&querySize); - querySize.setNext(&action); - action.setNext(&tableId); - tableId.setNext(&addresslength); - addresslength.setNext(&checksum); - checksum.setNext(&seq); - seq.setNext(&total); - total.setNext(&addr); - } - void fixedValuesInit(){ - cspPort.entry = GOMSPACE::PARAM_PORT; - } - SerializeElement cspPort; - SerializeElement querySize; // size of bytes to query - /* Following information will also be physically transmitted to the target - * device*/ - SerializeElement action = 0x00; // get param - SerializeElement tableId; - SerializeElement addresslength; - SerializeElement checksum; - SerializeElement seq; - SerializeElement total; - SerializeElement addr; + private: + CspGetParamCommand(const CspGetParamCommand &command); + void setLinks() { + setStart(&cspPort); + cspPort.setNext(&querySize); + querySize.setNext(&action); + action.setNext(&tableId); + tableId.setNext(&addresslength); + addresslength.setNext(&checksum); + checksum.setNext(&seq); + seq.setNext(&total); + total.setNext(&addr); + } + void fixedValuesInit() { cspPort.entry = GOMSPACE::PARAM_PORT; } + SerializeElement cspPort; + SerializeElement querySize; // size of bytes to query + /* Following information will also be physically transmitted to the target + * device*/ + SerializeElement action = 0x00; // get param + SerializeElement tableId; + SerializeElement addresslength; + SerializeElement checksum; + SerializeElement seq; + SerializeElement total; + SerializeElement addr; }; - /** * @brief This class can be used to generate a get param command for the * gomspace devices which will be sent to the device communication @@ -184,205 +180,186 @@ private: * and will not be transmitted physically to the target device. */ class RequestFullTableCommand : public SerialLinkedListAdapter { -public: + public: + RequestFullTableCommand(uint16_t querySize_, uint8_t tableId_) + : querySize(querySize_), tableId(tableId_) { + setLinks(); + } - RequestFullTableCommand(uint16_t querySize_, uint8_t tableId_) : - querySize(querySize_), tableId(tableId_) { - setLinks(); - } - -private: - RequestFullTableCommand(const RequestFullTableCommand &command); - void setLinks() { - setStart(&cspPort); - cspPort.setNext(&querySize); - querySize.setNext(&action); - action.setNext(&tableId); - tableId.setNext(&addresslength); - addresslength.setNext(&checksum); - checksum.setNext(&seq); - seq.setNext(&total); - } - SerializeElement cspPort = GOMSPACE::PARAM_PORT; - /** Size of bytes to query (size of csp header + size of table) */ - SerializeElement querySize; - /* Following information will also be physically transmitted to the target - * device*/ - SerializeElement action = 0x00; // get param - SerializeElement tableId; - /* Size of address. Set to 0 to get full table */ - SerializeElement addresslength = 0; - SerializeElement checksum = GOMSPACE::IGNORE_CHECKSUM; - SerializeElement seq = 0; - SerializeElement total = 0; + private: + RequestFullTableCommand(const RequestFullTableCommand &command); + void setLinks() { + setStart(&cspPort); + cspPort.setNext(&querySize); + querySize.setNext(&action); + action.setNext(&tableId); + tableId.setNext(&addresslength); + addresslength.setNext(&checksum); + checksum.setNext(&seq); + seq.setNext(&total); + } + SerializeElement cspPort = GOMSPACE::PARAM_PORT; + /** Size of bytes to query (size of csp header + size of table) */ + SerializeElement querySize; + /* Following information will also be physically transmitted to the target + * device*/ + SerializeElement action = 0x00; // get param + SerializeElement tableId; + /* Size of address. Set to 0 to get full table */ + SerializeElement addresslength = 0; + SerializeElement checksum = GOMSPACE::IGNORE_CHECKSUM; + SerializeElement seq = 0; + SerializeElement total = 0; }; - /** * @brief This class can be used to deserialize replies from gomspace devices * and extract the relevant data. */ class CspGetParamReply : public SerialLinkedListAdapter { -public: - /** - * @brief Constructor - * - * @param payloadBuffer Pointer to a buffer to store the payload data of - * the CSP packet. - * @param payloadBufferSz The size of the payload buffer where the payload - * data will be stored. - */ - CspGetParamReply(uint8_t* payloadBuffer_, uint8_t payloadBufferSz_) : - payload(payloadBuffer_, payloadBufferSz_) { - setLinks(); - } + public: + /** + * @brief Constructor + * + * @param payloadBuffer Pointer to a buffer to store the payload data of + * the CSP packet. + * @param payloadBufferSz The size of the payload buffer where the payload + * data will be stored. + */ + CspGetParamReply(uint8_t *payloadBuffer_, uint8_t payloadBufferSz_) + : payload(payloadBuffer_, payloadBufferSz_) { + setLinks(); + } - uint8_t getAction(){ - return action; - } + uint8_t getAction() { return action; } - uint8_t getTableId(){ - return tableId; - } + uint8_t getTableId() { return tableId; } - uint16_t getLength(){ - return length; - } + uint16_t getLength() { return length; } - uint16_t getAddress(){ - return addr; - } + uint16_t getAddress() { return addr; } -private: - CspGetParamReply(const CspGetParamReply &reply); - void setLinks() { - setStart(&action); - action.setNext(&tableId); - tableId.setNext(&length); - length.setNext(&checksum); - checksum.setNext(&seq); - seq.setNext(&total); - total.setNext(&addr); - addr.setNext(&payload); - } + private: + CspGetParamReply(const CspGetParamReply &reply); + void setLinks() { + setStart(&action); + action.setNext(&tableId); + tableId.setNext(&length); + length.setNext(&checksum); + checksum.setNext(&seq); + seq.setNext(&total); + total.setNext(&addr); + addr.setNext(&payload); + } - SerializeElement action; - SerializeElement tableId; - SerializeElement length; //length of address field + payload data - SerializeElement checksum; - SerializeElement seq; - SerializeElement total; - SerializeElement addr; - SerializeElement> payload; + SerializeElement action; + SerializeElement tableId; + SerializeElement length; // length of address field + payload data + SerializeElement checksum; + SerializeElement seq; + SerializeElement total; + SerializeElement addr; + SerializeElement> payload; }; - /** * @brief This class generates telemetry packets containing data from * CSP get-parameter-replies. */ class ParamReply : public SerialLinkedListAdapter { -public: - /** - * @brief Constructor - * - * @param payloadBuffer Pointer to a buffer to store the payload data of - * the CSP packet. - * @param payloadBufferSz The size of the payload buffer where the payload - * data will be stored. - */ - ParamReply(uint8_t action_, uint8_t tableId_, uint16_t addr_, - uint16_t payloadLength_, uint8_t* payloadBuffer_) : - action(action_), tableId(tableId_), addr(addr_), payloadLength( - payloadLength_), payload(payloadBuffer_, payloadLength) { - setLinks(); - } + public: + /** + * @brief Constructor + * + * @param payloadBuffer Pointer to a buffer to store the payload data of + * the CSP packet. + * @param payloadBufferSz The size of the payload buffer where the payload + * data will be stored. + */ + ParamReply(uint8_t action_, uint8_t tableId_, uint16_t addr_, uint16_t payloadLength_, + uint8_t *payloadBuffer_) + : action(action_), + tableId(tableId_), + addr(addr_), + payloadLength(payloadLength_), + payload(payloadBuffer_, payloadLength) { + setLinks(); + } -private: - ParamReply(const CspGetParamReply &reply); - void setLinks() { - setStart(&action); - action.setNext(&tableId); - tableId.setNext(&addr); - addr.setNext(&payloadLength); - payloadLength.setNext(&payload); - } - SerializeElement action; - SerializeElement tableId; - SerializeElement addr; - SerializeElement payloadLength; - SerializeElement> payload; + private: + ParamReply(const CspGetParamReply &reply); + void setLinks() { + setStart(&action); + action.setNext(&tableId); + tableId.setNext(&addr); + addr.setNext(&payloadLength); + payloadLength.setNext(&payload); + } + SerializeElement action; + SerializeElement tableId; + SerializeElement addr; + SerializeElement payloadLength; + SerializeElement> payload; }; - /** - * @brief This class generates the reply containing data from a full housekeeping table request - * of the PDU2. + * @brief This class generates the reply containing data from a full housekeeping table + * request of the PDU2. */ class Pdu2FullTableReply : public SerialLinkedListAdapter { -public: - /** - * @brief Constructor - * - * @param action_ The command which triggered the full table request. - * @param tableId_ The id of the requested table. - * @param tableDataset_ The dataset holding the table data. - */ - Pdu2FullTableReply(uint8_t action_, uint8_t tableId_, SerializeIF* tableDataset_) : - action(action_), tableId(tableId_), dataset(tableDataset_) { - setLinks(); - } + public: + /** + * @brief Constructor + * + * @param action_ The command which triggered the full table request. + * @param tableId_ The id of the requested table. + * @param tableDataset_ The dataset holding the table data. + */ + Pdu2FullTableReply(uint8_t action_, uint8_t tableId_, SerializeIF *tableDataset_) + : action(action_), tableId(tableId_), dataset(tableDataset_) { + setLinks(); + } -private: - Pdu2FullTableReply(const Pdu2FullTableReply &reply); - void setLinks() { - setStart(&action); - action.setNext(&tableId); - tableId.setNext(&dataset); - } - SerializeElement action; - SerializeElement tableId; - LinkedElement dataset; + private: + Pdu2FullTableReply(const Pdu2FullTableReply &reply); + void setLinks() { + setStart(&action); + action.setNext(&tableId); + tableId.setNext(&dataset); + } + SerializeElement action; + SerializeElement tableId; + LinkedElement dataset; }; - /** * @brief This class helps to unpack information from an action message * to set a parameter in gomspace devices. The action message can be * for example received from the PUS Service 8. */ -class SetParamMessageUnpacker: public SerialLinkedListAdapter { -public: - /* Largest parameter is a uint32_t */ - static const uint32_t MAX_SIZE = 4; +class SetParamMessageUnpacker : public SerialLinkedListAdapter { + public: + /* Largest parameter is a uint32_t */ + static const uint32_t MAX_SIZE = 4; - SetParamMessageUnpacker() { - setLinks(); - } + SetParamMessageUnpacker() { setLinks(); } - uint16_t getAddress() { - return address; - } + uint16_t getAddress() { return address; } - uint8_t* getParameter() { - return parameter->front(); - } + uint8_t *getParameter() { return parameter->front(); } - uint8_t getParameterSize(){ - return parameter->size; - } + uint8_t getParameterSize() { return parameter->size; } -private: - void setLinks() { - setStart(&address); - address.setNext(¶meter); - } - SetParamMessageUnpacker(const SetParamMessageUnpacker &message); - SerializeElement address; - SerializeElement> parameter; + private: + void setLinks() { + setStart(&address); + address.setNext(¶meter); + } + SetParamMessageUnpacker(const SetParamMessageUnpacker &message); + SerializeElement address; + SerializeElement> parameter; }; - /** * @brief This class generates a message which can be sent to the GomspaceDeviceHandler to * command a parameter change. @@ -391,76 +368,64 @@ private: * | memory address | size of parameter value | parameter value | */ class GomspaceSetParamMessage : public SerialLinkedListAdapter { -public: + public: + /* The size of the largest parameter */ + static const uint8_t MAX_SIZE = 4; - /* The size of the largest parameter */ - static const uint8_t MAX_SIZE = 4; + /** + * @brief Constructor + * + * @param memoryAddress The address of the parameter to change in the configuration table. + * @param parameterValue Pointer to the parameter value to set. + * @param parameterSize The size of the parameter. + * + */ + GomspaceSetParamMessage(uint16_t memoryAddress, const uint8_t *parameterValue, + uint8_t parameterSize) + : memoryAddress(memoryAddress), parameterValueBuffer(parameterValue, parameterSize, true) { + setLinks(); + } - /** - * @brief Constructor - * - * @param memoryAddress The address of the parameter to change in the configuration table. - * @param parameterValue Pointer to the parameter value to set. - * @param parameterSize The size of the parameter. - * - */ - GomspaceSetParamMessage(uint16_t memoryAddress, const uint8_t* parameterValue, - uint8_t parameterSize) : - memoryAddress(memoryAddress), parameterValueBuffer(parameterValue, parameterSize, true) { - setLinks(); - } - -private: - GomspaceSetParamMessage(const GomspaceSetParamMessage &reply); - void setLinks() { - setStart(&memoryAddress); - memoryAddress.setNext(¶meterValueBuffer); - } - SerializeElement memoryAddress; - /** - * Parameter can be uint8_t, uint16_t or uint32_t. Thus max size of parameterValueBuffer is - * four bytes. - */ - SerializeElement> parameterValueBuffer; + private: + GomspaceSetParamMessage(const GomspaceSetParamMessage &reply); + void setLinks() { + setStart(&memoryAddress); + memoryAddress.setNext(¶meterValueBuffer); + } + SerializeElement memoryAddress; + /** + * Parameter can be uint8_t, uint16_t or uint32_t. Thus max size of parameterValueBuffer is + * four bytes. + */ + SerializeElement> parameterValueBuffer; }; - /** * @brief This class helps to unpack information from an action message * to get a parameter from gomspace devices. The action message can be * for example received from the PUS Service 8. */ -class GetParamMessageUnpacker: public SerialLinkedListAdapter { -public: +class GetParamMessageUnpacker : public SerialLinkedListAdapter { + public: + GetParamMessageUnpacker() { setLinks(); } - GetParamMessageUnpacker() { - setLinks(); - } + uint8_t getTableId() { return tableId; } - uint8_t getTableId() { - return tableId; - } + uint16_t getAddress() { return address; } - uint16_t getAddress() { - return address; - } + uint8_t getParameterSize() { return parameterSize; } - uint8_t getParameterSize(){ - return parameterSize; - } - - -private: - GetParamMessageUnpacker(const GetParamMessageUnpacker &message); - void setLinks() { - setStart(&tableId); - tableId.setNext(&address); - address.setNext(¶meterSize); - } - SerializeElement tableId; - SerializeElement address; //The memory address offset within the table - /* The size of the requested value (e.g. temperature is a uint16_t value) */ - SerializeElement parameterSize; + private: + GetParamMessageUnpacker(const GetParamMessageUnpacker &message); + void setLinks() { + setStart(&tableId); + tableId.setNext(&address); + address.setNext(¶meterSize); + } + SerializeElement tableId; + SerializeElement address; // The memory address offset within the table + /* The size of the requested value (e.g. temperature is a uint16_t value) */ + SerializeElement parameterSize; }; #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEPACKETS_H_ */ diff --git a/mission/devices/devicedefinitions/GomspaceDefinitions.h b/mission/devices/devicedefinitions/GomspaceDefinitions.h index 0fbbc5b0..a575747f 100644 --- a/mission/devices/devicedefinitions/GomspaceDefinitions.h +++ b/mission/devices/devicedefinitions/GomspaceDefinitions.h @@ -9,12 +9,13 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEDEFINITIONS_H_ -#include -#include -#include #include +#include +#include -namespace GOMSPACE{ +#include + +namespace GOMSPACE { 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; @@ -29,339 +30,337 @@ static const uint8_t P60_PORT_GNDWDT_RESET = 9; * Device commands are derived from the rparam.h of the gomspace lib.. * IDs above 50 are reserved for device specific commands. */ -static const DeviceCommandId_t PING = 1; //!< [EXPORT] : [COMMAND] -static const DeviceCommandId_t NONE = 2; // Set when no command is pending -static const DeviceCommandId_t REBOOT = 4; //!< [EXPORT] : [COMMAND] -static const DeviceCommandId_t GNDWDT_RESET = 9; //!< [EXPORT] : [COMMAND] -static const DeviceCommandId_t PARAM_GET = 0; //!< [EXPORT] : [COMMAND] -static const DeviceCommandId_t PARAM_SET = 255; //!< [EXPORT] : [COMMAND] -static const DeviceCommandId_t REQUEST_HK_TABLE = 16; //!< [EXPORT] : [COMMAND] +static const DeviceCommandId_t PING = 1; //!< [EXPORT] : [COMMAND] +static const DeviceCommandId_t NONE = 2; // Set when no command is pending +static const DeviceCommandId_t REBOOT = 4; //!< [EXPORT] : [COMMAND] +static const DeviceCommandId_t GNDWDT_RESET = 9; //!< [EXPORT] : [COMMAND] +static const DeviceCommandId_t PARAM_GET = 0; //!< [EXPORT] : [COMMAND] +static const DeviceCommandId_t PARAM_SET = 255; //!< [EXPORT] : [COMMAND] +static const DeviceCommandId_t REQUEST_HK_TABLE = 16; //!< [EXPORT] : [COMMAND] //!< [EXPORT] : [COMMAND] Print switch states, voltages and currents to the console static const DeviceCommandId_t PRINT_SWITCH_V_I = 32; - -} +} // namespace GOMSPACE namespace P60System { -enum P60SytemPoolIds: lp_id_t { - P60DOCK_CURRENT_ACU_VCC, - P60DOCK_CURRENT_PDU1_VCC, - P60DOCK_CURRENT_X3_IDLE_VCC, - P60DOCK_CURRENT_PDU2_VCC, - P60DOCK_CURRENT_ACU_VBAT, - P60DOCK_CURRENT_PDU1_VBAT, - P60DOCK_CURRENT_X3_IDLE_VBAT, - P60DOCK_CURRENT_PDU2_VBAT, - P60DOCK_CURRENT_STACK_VBAT, - P60DOCK_CURRENT_STACK_3V3, - P60DOCK_CURRENT_STACK_5V, - P60DOCK_CURRENT_GS3V3, - P60DOCK_CURRENT_GS5V, - P60DOCK_VOLTAGE_ACU_VCC, - P60DOCK_VOLTAGE_PDU1_VCC, - P60DOCK_VOLTAGE_X3_IDLE_VCC, - P60DOCK_VOLTAGE_PDU2_VCC, - P60DOCK_VOLTAGE_ACU_VBAT, - P60DOCK_VOLTAGE_PDU1_VBAT, - P60DOCK_VOLTAGE_X3_IDLE_VBAT, - P60DOCK_VOLTAGE_PDU2_VBAT, - P60DOCK_VOLTAGE_STACK_VBAT, - P60DOCK_VOLTAGE_STACK_3V3, - P60DOCK_VOLTAGE_STACK_5V, - P60DOCK_VOLTAGE_GS3V3, - P60DOCK_VOLTAGE_GS5V, - P60DOCK_OUTPUTENABLE_ACU_VCC, - P60DOCK_OUTPUTENABLE_PDU1_VCC, - P60DOCK_OUTPUTENABLE_X3_IDLE_VCC, - P60DOCK_OUTPUTENABLE_PDU2_VCC, - P60DOCK_OUTPUTENABLE_ACU_VBAT, - P60DOCK_OUTPUTENABLE_PDU1_VBAT, - P60DOCK_OUTPUTENABLE_X3_IDLE_VBAT, - P60DOCK_OUTPUTENABLE_PDU2_VBAT, - P60DOCK_OUTPUTENABLE_STACK_VBAT, - P60DOCK_OUTPUTENABLE_STACK_3V3, - P60DOCK_OUTPUTENABLE_STACK_5V, - P60DOCK_OUTPUTENABLE_GS3V3, - P60DOCK_OUTPUTENABLE_GS5V, - P60DOCK_TEMPERATURE_1, - P60DOCK_TEMPERATURE_2, - P60DOCK_BOOT_CAUSE, - P60DOCK_BOOT_CNT, - P60DOCK_UPTIME, - P60DOCK_RESETCAUSE, - P60DOCK_BATT_MODE, - P60DOCK_HEATER_ON, - P60DOCK_CONV_5V_ENABLE_STATUS, - P60DOCK_LATCHUP_ACU_VCC, - P60DOCK_LATCHUP_PDU1_VCC, - P60DOCK_LATCHUP_X3_IDLE_VCC, - P60DOCK_LATCHUP_PDU2_VCC, - P60DOCK_LATCHUP_ACU_VBAT, - P60DOCK_LATCHUP_PDU1_VBAT, - P60DOCK_LATCHUP_X3_IDLE_VBAT, - P60DOCK_LATCHUP_PDU2_VBAT, - P60DOCK_LATCHUP_STACK_VBAT, - P60DOCK_LATCHUP_STACK_3V3, - P60DOCK_LATCHUP_STACK_5V, - P60DOCK_LATCHUP_GS3V3, - P60DOCK_LATCHUP_GS5V, - P60DOCK_VBAT_VALUE, - P60DOCK_VCC_CURRENT_VALUE, - P60DOCK_BATTERY_CURRENT, - P60DOCK_BATTERY_VOLTAGE, - P60DOCK_BATTERY_TEMPERATURE_1, - P60DOCK_BATTERY_TEMPERATURE_2, - P60DOCK_DEVICE_0, - P60DOCK_DEVICE_1, - P60DOCK_DEVICE_2, - P60DOCK_DEVICE_3, - P60DOCK_DEVICE_4, - P60DOCK_DEVICE_5, - P60DOCK_DEVICE_6, - P60DOCK_DEVICE_7, - P60DOCK_DEVICE_0_STATUS, - P60DOCK_DEVICE_1_STATUS, - P60DOCK_DEVICE_2_STATUS, - P60DOCK_DEVICE_3_STATUS, - P60DOCK_DEVICE_4_STATUS, - P60DOCK_DEVICE_5_STATUS, - P60DOCK_DEVICE_6_STATUS, - P60DOCK_DEVICE_7_STATUS, - P60DOCK_DEVICE_TYPE_GROUP, - P60DOCK_DEVICE_STATUS_GROUP, - P60DOCK_DEARM_STATUS, - P60DOCK_WDT_CNT_GND, - P60DOCK_WDT_CNT_I2C, - P60DOCK_WDT_CNT_CAN, - P60DOCK_WDT_CNT_CSP_1, - P60DOCK_WDT_CNT_CSP_2, - P60DOCK_WDT_GND_LEFT, - P60DOCK_WDT_I2C_LEFT, - P60DOCK_WDT_CAN_LEFT, - P60DOCK_WDT_CSP_LEFT_1, - P60DOCK_WDT_CSP_LEFT_2, - P60DOCK_BATT_CHARGE_CURRENT, - P60DOCK_BATT_DISCHARGE_CURRENT, - P60DOCK_ANT6_DEPL, - P60DOCK_AR6_DEPL, +enum P60SytemPoolIds : lp_id_t { + P60DOCK_CURRENT_ACU_VCC, + P60DOCK_CURRENT_PDU1_VCC, + P60DOCK_CURRENT_X3_IDLE_VCC, + P60DOCK_CURRENT_PDU2_VCC, + P60DOCK_CURRENT_ACU_VBAT, + P60DOCK_CURRENT_PDU1_VBAT, + P60DOCK_CURRENT_X3_IDLE_VBAT, + P60DOCK_CURRENT_PDU2_VBAT, + P60DOCK_CURRENT_STACK_VBAT, + P60DOCK_CURRENT_STACK_3V3, + P60DOCK_CURRENT_STACK_5V, + P60DOCK_CURRENT_GS3V3, + P60DOCK_CURRENT_GS5V, + P60DOCK_VOLTAGE_ACU_VCC, + P60DOCK_VOLTAGE_PDU1_VCC, + P60DOCK_VOLTAGE_X3_IDLE_VCC, + P60DOCK_VOLTAGE_PDU2_VCC, + P60DOCK_VOLTAGE_ACU_VBAT, + P60DOCK_VOLTAGE_PDU1_VBAT, + P60DOCK_VOLTAGE_X3_IDLE_VBAT, + P60DOCK_VOLTAGE_PDU2_VBAT, + P60DOCK_VOLTAGE_STACK_VBAT, + P60DOCK_VOLTAGE_STACK_3V3, + P60DOCK_VOLTAGE_STACK_5V, + P60DOCK_VOLTAGE_GS3V3, + P60DOCK_VOLTAGE_GS5V, + P60DOCK_OUTPUTENABLE_ACU_VCC, + P60DOCK_OUTPUTENABLE_PDU1_VCC, + P60DOCK_OUTPUTENABLE_X3_IDLE_VCC, + P60DOCK_OUTPUTENABLE_PDU2_VCC, + P60DOCK_OUTPUTENABLE_ACU_VBAT, + P60DOCK_OUTPUTENABLE_PDU1_VBAT, + P60DOCK_OUTPUTENABLE_X3_IDLE_VBAT, + P60DOCK_OUTPUTENABLE_PDU2_VBAT, + P60DOCK_OUTPUTENABLE_STACK_VBAT, + P60DOCK_OUTPUTENABLE_STACK_3V3, + P60DOCK_OUTPUTENABLE_STACK_5V, + P60DOCK_OUTPUTENABLE_GS3V3, + P60DOCK_OUTPUTENABLE_GS5V, + P60DOCK_TEMPERATURE_1, + P60DOCK_TEMPERATURE_2, + P60DOCK_BOOT_CAUSE, + P60DOCK_BOOT_CNT, + P60DOCK_UPTIME, + P60DOCK_RESETCAUSE, + P60DOCK_BATT_MODE, + P60DOCK_HEATER_ON, + P60DOCK_CONV_5V_ENABLE_STATUS, + P60DOCK_LATCHUP_ACU_VCC, + P60DOCK_LATCHUP_PDU1_VCC, + P60DOCK_LATCHUP_X3_IDLE_VCC, + P60DOCK_LATCHUP_PDU2_VCC, + P60DOCK_LATCHUP_ACU_VBAT, + P60DOCK_LATCHUP_PDU1_VBAT, + P60DOCK_LATCHUP_X3_IDLE_VBAT, + P60DOCK_LATCHUP_PDU2_VBAT, + P60DOCK_LATCHUP_STACK_VBAT, + P60DOCK_LATCHUP_STACK_3V3, + P60DOCK_LATCHUP_STACK_5V, + P60DOCK_LATCHUP_GS3V3, + P60DOCK_LATCHUP_GS5V, + P60DOCK_VBAT_VALUE, + P60DOCK_VCC_CURRENT_VALUE, + P60DOCK_BATTERY_CURRENT, + P60DOCK_BATTERY_VOLTAGE, + P60DOCK_BATTERY_TEMPERATURE_1, + P60DOCK_BATTERY_TEMPERATURE_2, + P60DOCK_DEVICE_0, + P60DOCK_DEVICE_1, + P60DOCK_DEVICE_2, + P60DOCK_DEVICE_3, + P60DOCK_DEVICE_4, + P60DOCK_DEVICE_5, + P60DOCK_DEVICE_6, + P60DOCK_DEVICE_7, + P60DOCK_DEVICE_0_STATUS, + P60DOCK_DEVICE_1_STATUS, + P60DOCK_DEVICE_2_STATUS, + P60DOCK_DEVICE_3_STATUS, + P60DOCK_DEVICE_4_STATUS, + P60DOCK_DEVICE_5_STATUS, + P60DOCK_DEVICE_6_STATUS, + P60DOCK_DEVICE_7_STATUS, + P60DOCK_DEVICE_TYPE_GROUP, + P60DOCK_DEVICE_STATUS_GROUP, + P60DOCK_DEARM_STATUS, + P60DOCK_WDT_CNT_GND, + P60DOCK_WDT_CNT_I2C, + P60DOCK_WDT_CNT_CAN, + P60DOCK_WDT_CNT_CSP_1, + P60DOCK_WDT_CNT_CSP_2, + P60DOCK_WDT_GND_LEFT, + P60DOCK_WDT_I2C_LEFT, + P60DOCK_WDT_CAN_LEFT, + P60DOCK_WDT_CSP_LEFT_1, + P60DOCK_WDT_CSP_LEFT_2, + P60DOCK_BATT_CHARGE_CURRENT, + P60DOCK_BATT_DISCHARGE_CURRENT, + P60DOCK_ANT6_DEPL, + P60DOCK_AR6_DEPL, - PDU1_CURRENT_OUT_TCS_BOARD_3V3, - PDU1_CURRENT_OUT_SYRLINKS, - PDU1_CURRENT_OUT_STAR_TRACKER, - PDU1_CURRENT_OUT_MGT, - PDU1_CURRENT_OUT_SUS_NOMINAL, - PDU1_CURRENT_OUT_SOLAR_CELL_EXP, - PDU1_CURRENT_OUT_PLOC, - PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, - PDU1_CURRENT_OUT_CHANNEL8, - PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, - PDU1_VOLTAGE_OUT_SYRLINKS, - PDU1_VOLTAGE_OUT_STAR_TRACKER, - PDU1_VOLTAGE_OUT_MGT, - PDU1_VOLTAGE_OUT_SUS_NOMINAL, - PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, - PDU1_VOLTAGE_OUT_PLOC, - PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, - PDU1_VOLTAGE_OUT_CHANNEL8, - PDU1_VCC, - PDU1_VBAT, - PDU1_TEMPERATURE, - PDU1_CONV_EN_1, - PDU1_CONV_EN_2, - PDU1_CONV_EN_3, - PDU1_OUT_EN_TCS_BOARD_3V3, - PDU1_OUT_EN_SYRLINKS, - PDU1_OUT_EN_STAR_TRACKER, - PDU1_OUT_EN_MGT, - PDU1_OUT_EN_SUS_NOMINAL, - PDU1_OUT_EN_SOLAR_CELL_EXP, - PDU1_OUT_EN_PLOC, - PDU1_OUT_EN_ACS_BOARD_SIDE_A, - PDU1_OUT_EN_CHANNEL8, - PDU1_BOOTCAUSE, - PDU1_BOOTCNT, - PDU1_UPTIME, - PDU1_RESETCAUSE, - PDU1_BATT_MODE, - PDU1_LATCHUP_TCS_BOARD_3V3, - PDU1_LATCHUP_SYRLINKS, - PDU1_LATCHUP_STAR_TRACKER, - PDU1_LATCHUP_MGT, - PDU1_LATCHUP_SUS_NOMINAL, - PDU1_LATCHUP_SOLAR_CELL_EXP, - PDU1_LATCHUP_PLOC, - PDU1_LATCHUP_ACS_BOARD_SIDE_A, - PDU1_LATCHUP_CHANNEL8, - PDU1_DEVICE_0, - PDU1_DEVICE_1, - PDU1_DEVICE_2, - PDU1_DEVICE_3, - PDU1_DEVICE_4, - PDU1_DEVICE_5, - PDU1_DEVICE_6, - PDU1_DEVICE_7, - PDU1_DEVICE_0_STATUS, - PDU1_DEVICE_1_STATUS, - PDU1_DEVICE_2_STATUS, - PDU1_DEVICE_3_STATUS, - PDU1_DEVICE_4_STATUS, - PDU1_DEVICE_5_STATUS, - PDU1_DEVICE_6_STATUS, - PDU1_DEVICE_7_STATUS, - PDU1_WDT_CNT_GND, - PDU1_WDT_CNT_I2C, - PDU1_WDT_CNT_CAN, - PDU1_WDT_CNT_CSP1, - PDU1_WDT_CNT_CSP2, - PDU1_WDT_GND_LEFT, - PDU1_WDT_I2C_LEFT, - PDU1_WDT_CAN_LEFT, - PDU1_WDT_CSP_LEFT1, - PDU1_WDT_CSP_LEFT2, + PDU1_CURRENT_OUT_TCS_BOARD_3V3, + PDU1_CURRENT_OUT_SYRLINKS, + PDU1_CURRENT_OUT_STAR_TRACKER, + PDU1_CURRENT_OUT_MGT, + PDU1_CURRENT_OUT_SUS_NOMINAL, + PDU1_CURRENT_OUT_SOLAR_CELL_EXP, + PDU1_CURRENT_OUT_PLOC, + PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, + PDU1_CURRENT_OUT_CHANNEL8, + PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, + PDU1_VOLTAGE_OUT_SYRLINKS, + PDU1_VOLTAGE_OUT_STAR_TRACKER, + PDU1_VOLTAGE_OUT_MGT, + PDU1_VOLTAGE_OUT_SUS_NOMINAL, + PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, + PDU1_VOLTAGE_OUT_PLOC, + PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, + PDU1_VOLTAGE_OUT_CHANNEL8, + PDU1_VCC, + PDU1_VBAT, + PDU1_TEMPERATURE, + PDU1_CONV_EN_1, + PDU1_CONV_EN_2, + PDU1_CONV_EN_3, + PDU1_OUT_EN_TCS_BOARD_3V3, + PDU1_OUT_EN_SYRLINKS, + PDU1_OUT_EN_STAR_TRACKER, + PDU1_OUT_EN_MGT, + PDU1_OUT_EN_SUS_NOMINAL, + PDU1_OUT_EN_SOLAR_CELL_EXP, + PDU1_OUT_EN_PLOC, + PDU1_OUT_EN_ACS_BOARD_SIDE_A, + PDU1_OUT_EN_CHANNEL8, + PDU1_BOOTCAUSE, + PDU1_BOOTCNT, + PDU1_UPTIME, + PDU1_RESETCAUSE, + PDU1_BATT_MODE, + PDU1_LATCHUP_TCS_BOARD_3V3, + PDU1_LATCHUP_SYRLINKS, + PDU1_LATCHUP_STAR_TRACKER, + PDU1_LATCHUP_MGT, + PDU1_LATCHUP_SUS_NOMINAL, + PDU1_LATCHUP_SOLAR_CELL_EXP, + PDU1_LATCHUP_PLOC, + PDU1_LATCHUP_ACS_BOARD_SIDE_A, + PDU1_LATCHUP_CHANNEL8, + PDU1_DEVICE_0, + PDU1_DEVICE_1, + PDU1_DEVICE_2, + PDU1_DEVICE_3, + PDU1_DEVICE_4, + PDU1_DEVICE_5, + PDU1_DEVICE_6, + PDU1_DEVICE_7, + PDU1_DEVICE_0_STATUS, + PDU1_DEVICE_1_STATUS, + PDU1_DEVICE_2_STATUS, + PDU1_DEVICE_3_STATUS, + PDU1_DEVICE_4_STATUS, + PDU1_DEVICE_5_STATUS, + PDU1_DEVICE_6_STATUS, + PDU1_DEVICE_7_STATUS, + PDU1_WDT_CNT_GND, + PDU1_WDT_CNT_I2C, + PDU1_WDT_CNT_CAN, + PDU1_WDT_CNT_CSP1, + PDU1_WDT_CNT_CSP2, + PDU1_WDT_GND_LEFT, + PDU1_WDT_I2C_LEFT, + PDU1_WDT_CAN_LEFT, + PDU1_WDT_CSP_LEFT1, + PDU1_WDT_CSP_LEFT2, - /** PDU2 Ids */ - PDU2_CURRENT_OUT_Q7S, - PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, - PDU2_CURRENT_OUT_RW, - PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, - PDU2_CURRENT_OUT_SUS_REDUNDANT, - PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, - PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, - PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, - PDU2_CURRENT_OUT_PAYLOAD_CAMERA, - PDU2_VOLTAGE_OUT_Q7S, - PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, - PDU2_VOLTAGE_OUT_RW, - PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, - PDU2_VOLTAGE_OUT_SUS_REDUNDANT, - PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, - PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, - PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, - PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, - PDU2_VCC, - PDU2_VBAT, - PDU2_TEMPERATURE, - PDU2_CONV_EN_1, - PDU2_CONV_EN_2, - PDU2_CONV_EN_3, - PDU2_OUT_EN_Q7S, - PDU2_OUT_EN_PAYLOAD_PCDU_CH1, - PDU2_OUT_EN_RW, - PDU2_OUT_EN_TCS_BOARD_HEATER_IN, - PDU2_OUT_EN_SUS_REDUNDANT, - PDU2_OUT_EN_DEPLOYMENT_MECHANISM, - PDU2_OUT_EN_PAYLOAD_PCDU_CH6, - PDU2_OUT_EN_ACS_BOARD_SIDE_B, - PDU2_OUT_EN_PAYLOAD_CAMERA, - PDU2_BOOTCAUSE, - PDU2_BOOTCNT, - PDU2_UPTIME, - PDU2_RESETCAUSE, - PDU2_BATT_MODE, - PDU2_LATCHUP_Q7S, - PDU2_LATCHUP_PAYLOAD_PCDU_CH1, - PDU2_LATCHUP_RW, - PDU2_LATCHUP_TCS_BOARD_HEATER_IN, - PDU2_LATCHUP_SUS_REDUNDANT, - PDU2_LATCHUP_DEPLOYMENT_MECHANISM, - PDU2_LATCHUP_PAYLOAD_PCDU_CH6, - PDU2_LATCHUP_ACS_BOARD_SIDE_B, - PDU2_LATCHUP_PAYLOAD_CAMERA, - PDU2_DEVICE_0, - PDU2_DEVICE_1, - PDU2_DEVICE_2, - PDU2_DEVICE_3, - PDU2_DEVICE_4, - PDU2_DEVICE_5, - PDU2_DEVICE_6, - PDU2_DEVICE_7, - PDU2_DEVICE_0_STATUS, - PDU2_DEVICE_1_STATUS, - PDU2_DEVICE_2_STATUS, - PDU2_DEVICE_3_STATUS, - PDU2_DEVICE_4_STATUS, - PDU2_DEVICE_5_STATUS, - PDU2_DEVICE_6_STATUS, - PDU2_DEVICE_7_STATUS, - PDU2_WDT_CNT_GND, - PDU2_WDT_CNT_I2C, - PDU2_WDT_CNT_CAN, - PDU2_WDT_CNT_CSP1, - PDU2_WDT_CNT_CSP2, - PDU2_WDT_GND_LEFT, - PDU2_WDT_I2C_LEFT, - PDU2_WDT_CAN_LEFT, - PDU2_WDT_CSP_LEFT1, - PDU2_WDT_CSP_LEFT2, + /** PDU2 Ids */ + PDU2_CURRENT_OUT_Q7S, + PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, + PDU2_CURRENT_OUT_RW, + PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, + PDU2_CURRENT_OUT_SUS_REDUNDANT, + PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, + PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, + PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, + PDU2_CURRENT_OUT_PAYLOAD_CAMERA, + PDU2_VOLTAGE_OUT_Q7S, + PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, + PDU2_VOLTAGE_OUT_RW, + PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, + PDU2_VOLTAGE_OUT_SUS_REDUNDANT, + PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, + PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, + PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, + PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, + PDU2_VCC, + PDU2_VBAT, + PDU2_TEMPERATURE, + PDU2_CONV_EN_1, + PDU2_CONV_EN_2, + PDU2_CONV_EN_3, + PDU2_OUT_EN_Q7S, + PDU2_OUT_EN_PAYLOAD_PCDU_CH1, + PDU2_OUT_EN_RW, + PDU2_OUT_EN_TCS_BOARD_HEATER_IN, + PDU2_OUT_EN_SUS_REDUNDANT, + PDU2_OUT_EN_DEPLOYMENT_MECHANISM, + PDU2_OUT_EN_PAYLOAD_PCDU_CH6, + PDU2_OUT_EN_ACS_BOARD_SIDE_B, + PDU2_OUT_EN_PAYLOAD_CAMERA, + PDU2_BOOTCAUSE, + PDU2_BOOTCNT, + PDU2_UPTIME, + PDU2_RESETCAUSE, + PDU2_BATT_MODE, + PDU2_LATCHUP_Q7S, + PDU2_LATCHUP_PAYLOAD_PCDU_CH1, + PDU2_LATCHUP_RW, + PDU2_LATCHUP_TCS_BOARD_HEATER_IN, + PDU2_LATCHUP_SUS_REDUNDANT, + PDU2_LATCHUP_DEPLOYMENT_MECHANISM, + PDU2_LATCHUP_PAYLOAD_PCDU_CH6, + PDU2_LATCHUP_ACS_BOARD_SIDE_B, + PDU2_LATCHUP_PAYLOAD_CAMERA, + PDU2_DEVICE_0, + PDU2_DEVICE_1, + PDU2_DEVICE_2, + PDU2_DEVICE_3, + PDU2_DEVICE_4, + PDU2_DEVICE_5, + PDU2_DEVICE_6, + PDU2_DEVICE_7, + PDU2_DEVICE_0_STATUS, + PDU2_DEVICE_1_STATUS, + PDU2_DEVICE_2_STATUS, + PDU2_DEVICE_3_STATUS, + PDU2_DEVICE_4_STATUS, + PDU2_DEVICE_5_STATUS, + PDU2_DEVICE_6_STATUS, + PDU2_DEVICE_7_STATUS, + PDU2_WDT_CNT_GND, + PDU2_WDT_CNT_I2C, + PDU2_WDT_CNT_CAN, + PDU2_WDT_CNT_CSP1, + PDU2_WDT_CNT_CSP2, + PDU2_WDT_GND_LEFT, + PDU2_WDT_I2C_LEFT, + PDU2_WDT_CAN_LEFT, + PDU2_WDT_CSP_LEFT1, + PDU2_WDT_CSP_LEFT2, - /** ACU Ids */ - ACU_CURRENT_IN_CHANNEL0, - ACU_CURRENT_IN_CHANNEL1, - ACU_CURRENT_IN_CHANNEL2, - ACU_CURRENT_IN_CHANNEL3, - ACU_CURRENT_IN_CHANNEL4, - ACU_CURRENT_IN_CHANNEL5, - ACU_VOLTAGE_IN_CHANNEL0, - ACU_VOLTAGE_IN_CHANNEL1, - ACU_VOLTAGE_IN_CHANNEL2, - ACU_VOLTAGE_IN_CHANNEL3, - ACU_VOLTAGE_IN_CHANNEL4, - ACU_VOLTAGE_IN_CHANNEL5, - ACU_VCC, - ACU_VBAT, - ACU_TEMPERATURE_1, - ACU_TEMPERATURE_2, - ACU_TEMPERATURE_3, - ACU_MPPT_MODE, - ACU_VBOOST_CHANNEL0, - ACU_VBOOST_CHANNEL1, - ACU_VBOOST_CHANNEL2, - ACU_VBOOST_CHANNEL3, - ACU_VBOOST_CHANNEL4, - ACU_VBOOST_CHANNEL5, - ACU_POWER_CHANNEL0, - ACU_POWER_CHANNEL1, - ACU_POWER_CHANNEL2, - ACU_POWER_CHANNEL3, - ACU_POWER_CHANNEL4, - ACU_POWER_CHANNEL5, - ACU_DAC_EN_0, - ACU_DAC_EN_1, - ACU_DAC_EN_2, - ACU_DAC_RAW_0, - ACU_DAC_RAW_1, - ACU_DAC_RAW_2, - ACU_DAC_RAW_3, - ACU_DAC_RAW_4, - ACU_DAC_RAW_5, - ACU_BOOTCAUSE, - ACU_BOOTCNT, - ACU_UPTIME, - ACU_RESET_CAUSE, - ACU_MPPT_TIME, - ACU_MPPT_PERIOD, - ACU_DEVICE_0, - ACU_DEVICE_1, - ACU_DEVICE_2, - ACU_DEVICE_3, - ACU_DEVICE_4, - ACU_DEVICE_5, - ACU_DEVICE_6, - ACU_DEVICE_7, - ACU_DEVICE_0_STATUS, - ACU_DEVICE_1_STATUS, - ACU_DEVICE_2_STATUS, - ACU_DEVICE_3_STATUS, - ACU_DEVICE_4_STATUS, - ACU_DEVICE_5_STATUS, - ACU_DEVICE_6_STATUS, - ACU_DEVICE_7_STATUS, - ACU_WDT_CNT_GND, - ACU_WDT_GND_LEFT + /** ACU Ids */ + ACU_CURRENT_IN_CHANNEL0, + ACU_CURRENT_IN_CHANNEL1, + ACU_CURRENT_IN_CHANNEL2, + ACU_CURRENT_IN_CHANNEL3, + ACU_CURRENT_IN_CHANNEL4, + ACU_CURRENT_IN_CHANNEL5, + ACU_VOLTAGE_IN_CHANNEL0, + ACU_VOLTAGE_IN_CHANNEL1, + ACU_VOLTAGE_IN_CHANNEL2, + ACU_VOLTAGE_IN_CHANNEL3, + ACU_VOLTAGE_IN_CHANNEL4, + ACU_VOLTAGE_IN_CHANNEL5, + ACU_VCC, + ACU_VBAT, + ACU_TEMPERATURE_1, + ACU_TEMPERATURE_2, + ACU_TEMPERATURE_3, + ACU_MPPT_MODE, + ACU_VBOOST_CHANNEL0, + ACU_VBOOST_CHANNEL1, + ACU_VBOOST_CHANNEL2, + ACU_VBOOST_CHANNEL3, + ACU_VBOOST_CHANNEL4, + ACU_VBOOST_CHANNEL5, + ACU_POWER_CHANNEL0, + ACU_POWER_CHANNEL1, + ACU_POWER_CHANNEL2, + ACU_POWER_CHANNEL3, + ACU_POWER_CHANNEL4, + ACU_POWER_CHANNEL5, + ACU_DAC_EN_0, + ACU_DAC_EN_1, + ACU_DAC_EN_2, + ACU_DAC_RAW_0, + ACU_DAC_RAW_1, + ACU_DAC_RAW_2, + ACU_DAC_RAW_3, + ACU_DAC_RAW_4, + ACU_DAC_RAW_5, + ACU_BOOTCAUSE, + ACU_BOOTCNT, + ACU_UPTIME, + ACU_RESET_CAUSE, + ACU_MPPT_TIME, + ACU_MPPT_PERIOD, + ACU_DEVICE_0, + ACU_DEVICE_1, + ACU_DEVICE_2, + ACU_DEVICE_3, + ACU_DEVICE_4, + ACU_DEVICE_5, + ACU_DEVICE_6, + ACU_DEVICE_7, + ACU_DEVICE_0_STATUS, + ACU_DEVICE_1_STATUS, + ACU_DEVICE_2_STATUS, + ACU_DEVICE_3_STATUS, + ACU_DEVICE_4_STATUS, + ACU_DEVICE_5_STATUS, + ACU_DEVICE_6_STATUS, + ACU_DEVICE_7_STATUS, + ACU_WDT_CNT_GND, + ACU_WDT_GND_LEFT }; } - namespace P60Dock { /** Max reply size reached when requesting full hk table */ @@ -386,240 +385,221 @@ static const uint16_t HK_TABLE_REPLY_SIZE = 407; * The GS port and X3 are not required for EIVE. X3 is another slot on the P60 dock and * GS is required for a module from Gomspace which is not used. */ -class HkTableDataset: - public StaticLocalDataSet { - public: +class HkTableDataset : public StaticLocalDataSet { + public: + HkTableDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) {} - HkTableDataset(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) { - } + HkTableDataset(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) {} - HkTableDataset(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) { - } + /** Measured output currents */ + lp_var_t currentAcuVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_ACU_VCC, this); + lp_var_t currentPdu1Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_PDU1_VCC, this); + lp_var_t currentX3IdleVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_X3_IDLE_VCC, this); + lp_var_t currentPdu2Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_PDU2_VCC, this); + lp_var_t currentAcuVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_ACU_VBAT, this); + lp_var_t currentPdu1Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_PDU1_VBAT, this); + lp_var_t currentX3IdleVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_X3_IDLE_VBAT, this); + lp_var_t currentPdu2Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_PDU2_VBAT, this); + lp_var_t currentStackVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_STACK_VBAT, this); + lp_var_t currentStack3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_STACK_3V3, this); + lp_var_t currentStack5V = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_STACK_5V, this); + lp_var_t currentGS3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_GS3V3, this); + lp_var_t currentGS5V = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_GS5V, this); - /** Measured output currents */ - lp_var_t currentAcuVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_ACU_VCC, this); - lp_var_t currentPdu1Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_PDU1_VCC, this); - lp_var_t currentX3IdleVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_X3_IDLE_VCC, this); - lp_var_t currentPdu2Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_PDU2_VCC, this); - lp_var_t currentAcuVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_ACU_VBAT, this); - lp_var_t currentPdu1Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_PDU1_VBAT, this); - lp_var_t currentX3IdleVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_X3_IDLE_VBAT, this); - lp_var_t currentPdu2Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_PDU2_VBAT, this); - lp_var_t currentStackVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_STACK_VBAT, this); - lp_var_t currentStack3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_STACK_3V3, this); - lp_var_t currentStack5V = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_STACK_5V, this); - lp_var_t currentGS3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_GS3V3, this); - lp_var_t currentGS5V = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_GS5V, this); + /** Measured output voltages */ + lp_var_t voltageAcuVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_ACU_VCC, this); + lp_var_t voltagePdu1Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_PDU1_VCC, this); + lp_var_t voltageX3IdleVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_X3_IDLE_VCC, this); + lp_var_t voltagePdu2Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_PDU2_VCC, this); + lp_var_t voltageAcuVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_ACU_VBAT, this); + lp_var_t voltagePdu1Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_PDU1_VBAT, this); + lp_var_t voltageX3IdleVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_X3_IDLE_VBAT, this); + lp_var_t voltagePdu2Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_PDU2_VBAT, this); + lp_var_t voltageStackVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_STACK_VBAT, this); + lp_var_t voltageStack3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_STACK_3V3, this); + lp_var_t voltageStack5V = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_STACK_5V, this); + lp_var_t voltageGS3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_GS3V3, this); + lp_var_t voltageGS5V = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_GS5V, this); - /** Measured output voltages */ - lp_var_t voltageAcuVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_ACU_VCC, this); - lp_var_t voltagePdu1Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_PDU1_VCC, this); - lp_var_t voltageX3IdleVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_X3_IDLE_VCC, this); - lp_var_t voltagePdu2Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_PDU2_VCC, this); - lp_var_t voltageAcuVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_ACU_VBAT, this); - lp_var_t voltagePdu1Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_PDU1_VBAT, this); - lp_var_t voltageX3IdleVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_X3_IDLE_VBAT, this); - lp_var_t voltagePdu2Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_PDU2_VBAT, this); - lp_var_t voltageStackVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_STACK_VBAT, this); - lp_var_t voltageStack3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_STACK_3V3, this); - lp_var_t voltageStack5V = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_STACK_5V, this); - lp_var_t voltageGS3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_GS3V3, this); - lp_var_t voltageGS5V = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_GS5V, this); + /** Output enable states */ + lp_var_t outputEnableStateAcuVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_ACU_VCC, this); + lp_var_t outputEnableStatePdu1Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_PDU1_VCC, this); + lp_var_t outputEnableStateX3IdleVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VCC, this); + lp_var_t outputEnableStatePdu2Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_PDU2_VCC, this); + lp_var_t outputEnableStateAcuVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_ACU_VBAT, this); + lp_var_t outputEnableStatePdu1Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_PDU1_VBAT, this); + lp_var_t outputEnableStateX3IdleVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VBAT, this); + lp_var_t outputEnableStatePdu2Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_PDU2_VBAT, this); + lp_var_t outputEnableStateStackVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_STACK_VBAT, this); + lp_var_t outputEnableStateStack3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_STACK_3V3, this); + lp_var_t outputEnableStateStack5V = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_STACK_5V, this); + lp_var_t outputEnableStateGS3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_GS3V3, this); + lp_var_t outputEnableStateGS5V = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_GS5V, this); - /** Output enable states */ - lp_var_t outputEnableStateAcuVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_ACU_VCC, this); - lp_var_t outputEnableStatePdu1Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_PDU1_VCC, this); - lp_var_t outputEnableStateX3IdleVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VCC, this); - lp_var_t outputEnableStatePdu2Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_PDU2_VCC, this); - lp_var_t outputEnableStateAcuVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_ACU_VBAT, this); - lp_var_t outputEnableStatePdu1Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_PDU1_VBAT, this); - lp_var_t outputEnableStateX3IdleVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VBAT, this); - lp_var_t outputEnableStatePdu2Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_PDU2_VBAT, this); - lp_var_t outputEnableStateStackVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_STACK_VBAT, this); - lp_var_t outputEnableStateStack3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_STACK_3V3, this); - lp_var_t outputEnableStateStack5V = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_STACK_5V, this); - lp_var_t outputEnableStateGS3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_GS3V3, this); - lp_var_t outputEnableStateGS5V = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_GS5V, this); + lp_var_t temperature1 = + lp_var_t(sid.objectId, P60System::P60DOCK_TEMPERATURE_1, this); + lp_var_t temperature2 = + lp_var_t(sid.objectId, P60System::P60DOCK_TEMPERATURE_2, this); - lp_var_t temperature1 = lp_var_t(sid.objectId, - P60System::P60DOCK_TEMPERATURE_1, this); - lp_var_t temperature2 = lp_var_t(sid.objectId, - P60System::P60DOCK_TEMPERATURE_2, this); + lp_var_t bootcause = + lp_var_t(sid.objectId, P60System::P60DOCK_BOOT_CAUSE, this); + lp_var_t bootCount = + lp_var_t(sid.objectId, P60System::P60DOCK_BOOT_CNT, this); + lp_var_t uptime = lp_var_t(sid.objectId, P60System::P60DOCK_UPTIME, this); + lp_var_t resetcause = + lp_var_t(sid.objectId, P60System::P60DOCK_RESETCAUSE, this); + lp_var_t battMode = lp_var_t(sid.objectId, P60System::P60DOCK_BATT_MODE, this); + /** Battery heater control only possible on BP4 packs */ + lp_var_t heaterOn = lp_var_t(sid.objectId, P60System::P60DOCK_HEATER_ON, this); + lp_var_t converter5VStatus = + lp_var_t(sid.objectId, P60System::P60DOCK_CONV_5V_ENABLE_STATUS, this); - lp_var_t bootcause = lp_var_t(sid.objectId, - P60System::P60DOCK_BOOT_CAUSE, this); - lp_var_t bootCount = lp_var_t(sid.objectId, - P60System::P60DOCK_BOOT_CNT, this); - lp_var_t uptime = lp_var_t(sid.objectId, - P60System::P60DOCK_UPTIME, this); - lp_var_t resetcause = lp_var_t(sid.objectId, - P60System::P60DOCK_RESETCAUSE, this); - lp_var_t battMode = lp_var_t(sid.objectId, - P60System::P60DOCK_BATT_MODE, this); - /** Battery heater control only possible on BP4 packs */ - lp_var_t heaterOn = lp_var_t(sid.objectId, - P60System::P60DOCK_HEATER_ON, this); - lp_var_t converter5VStatus = lp_var_t(sid.objectId, - P60System::P60DOCK_CONV_5V_ENABLE_STATUS, this); + /** Number of detected latchups on each output channel */ + lp_var_t latchupsAcuVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_ACU_VCC, this); + lp_var_t latchupsPdu1Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_PDU1_VCC, this); + lp_var_t latchupsX3IdleVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_X3_IDLE_VCC, this); + lp_var_t latchupsPdu2Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_PDU2_VCC, this); + lp_var_t latchupsAcuVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_ACU_VBAT, this); + lp_var_t latchupsPdu1Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_PDU1_VBAT, this); + lp_var_t latchupsX3IdleVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_X3_IDLE_VBAT, this); + lp_var_t latchupsPdu2Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_PDU2_VBAT, this); + lp_var_t latchupsStackVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_STACK_VBAT, this); + lp_var_t latchupsStack3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_STACK_3V3, this); + lp_var_t latchupsStack5V = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_STACK_5V, this); + lp_var_t latchupsGS3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_GS3V3, this); + lp_var_t latchupsGS5V = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_GS5V, this); - /** Number of detected latchups on each output channel */ - lp_var_t latchupsAcuVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_ACU_VCC, this); - lp_var_t latchupsPdu1Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_PDU1_VCC, this); - lp_var_t latchupsX3IdleVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_X3_IDLE_VCC, this); - lp_var_t latchupsPdu2Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_PDU2_VCC, this); - lp_var_t latchupsAcuVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_ACU_VBAT, this); - lp_var_t latchupsPdu1Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_PDU1_VBAT, this); - lp_var_t latchupsX3IdleVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_X3_IDLE_VBAT, this); - lp_var_t latchupsPdu2Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_PDU2_VBAT, this); - lp_var_t latchupsStackVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_STACK_VBAT, this); - lp_var_t latchupsStack3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_STACK_3V3, this); - lp_var_t latchupsStack5V = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_STACK_5V, this); - lp_var_t latchupsGS3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_GS3V3, this); - lp_var_t latchupsGS5V = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_GS5V, this); + lp_var_t vbatVoltageValue = + lp_var_t(sid.objectId, P60System::P60DOCK_VBAT_VALUE, this); + lp_var_t vccCurrent = + lp_var_t(sid.objectId, P60System::P60DOCK_VCC_CURRENT_VALUE, this); + lp_var_t batteryCurrent = + lp_var_t(sid.objectId, P60System::P60DOCK_BATTERY_CURRENT, this); + lp_var_t batteryVoltage = + lp_var_t(sid.objectId, P60System::P60DOCK_BATTERY_VOLTAGE, this); - lp_var_t vbatVoltageValue = lp_var_t(sid.objectId, - P60System::P60DOCK_VBAT_VALUE, this); - lp_var_t vccCurrent = lp_var_t(sid.objectId, - P60System::P60DOCK_VCC_CURRENT_VALUE, this); - lp_var_t batteryCurrent = lp_var_t(sid.objectId, - P60System::P60DOCK_BATTERY_CURRENT, this); - lp_var_t batteryVoltage = lp_var_t(sid.objectId, - P60System::P60DOCK_BATTERY_VOLTAGE, this); + lp_var_t batteryTemperature1 = + lp_var_t(sid.objectId, P60System::P60DOCK_BATTERY_TEMPERATURE_1, this); + lp_var_t batteryTemperature2 = + lp_var_t(sid.objectId, P60System::P60DOCK_BATTERY_TEMPERATURE_2, this); - lp_var_t batteryTemperature1 = lp_var_t(sid.objectId, - P60System::P60DOCK_BATTERY_TEMPERATURE_1, this); - lp_var_t batteryTemperature2 = lp_var_t(sid.objectId, - P60System::P60DOCK_BATTERY_TEMPERATURE_2, this); + lp_var_t device0 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_0, this); + lp_var_t device1 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_1, this); + lp_var_t device2 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_2, this); + lp_var_t device3 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_3, this); + lp_var_t device4 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_4, this); + lp_var_t device5 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_5, this); + lp_var_t device6 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_6, this); + lp_var_t device7 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_7, this); - lp_var_t device0 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_0, this); - lp_var_t device1 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_1, this); - lp_var_t device2 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_2, this); - lp_var_t device3 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_3, this); - lp_var_t device4 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_4, this); - lp_var_t device5 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_5, this); - lp_var_t device6 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_6, this); - lp_var_t device7 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_7, this); + lp_var_t device0Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_0_STATUS, this); + lp_var_t device1Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_1_STATUS, this); + lp_var_t device2Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_2_STATUS, this); + lp_var_t device3Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_3_STATUS, this); + lp_var_t device4Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_4_STATUS, this); + lp_var_t device5Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_5_STATUS, this); + lp_var_t device6Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_6_STATUS, this); + lp_var_t device7Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_7_STATUS, this); - lp_var_t device0Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_0_STATUS, this); - lp_var_t device1Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_1_STATUS, this); - lp_var_t device2Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_2_STATUS, this); - lp_var_t device3Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_3_STATUS, this); - lp_var_t device4Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_4_STATUS, this); - lp_var_t device5Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_5_STATUS, this); - lp_var_t device6Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_6_STATUS, this); - lp_var_t device7Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_7_STATUS, this); + lp_var_t dearmStatus = + lp_var_t(sid.objectId, P60System::P60DOCK_DEARM_STATUS, this); - lp_var_t dearmStatus = lp_var_t(sid.objectId, - P60System::P60DOCK_DEARM_STATUS, this); + /** Number of reboots due to gnd, i2c, csp watchdog timeout */ + lp_var_t wdtCntGnd = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CNT_GND, this); + lp_var_t wdtCntI2c = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CNT_I2C, this); + lp_var_t wdtCntCan = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CNT_CAN, this); + lp_var_t wdtCntCsp1 = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CNT_CSP_1, this); + lp_var_t wdtCntCsp2 = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CNT_CSP_2, this); - /** Number of reboots due to gnd, i2c, csp watchdog timeout */ - lp_var_t wdtCntGnd = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CNT_GND, this); - lp_var_t wdtCntI2c = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CNT_I2C, this); - lp_var_t wdtCntCan = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CNT_CAN, this); - lp_var_t wdtCntCsp1 = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CNT_CSP_1, this); - lp_var_t wdtCntCsp2 = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CNT_CSP_2, this); - - lp_var_t wdtGndLeft = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_GND_LEFT, this); - lp_var_t wdtI2cLeft = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_I2C_LEFT, this); - lp_var_t wdtCanLeft = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CAN_LEFT, this); - lp_var_t wdtCspLeft1 = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CSP_LEFT_1, this); - lp_var_t wdtCspLeft2 = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CSP_LEFT_2, this); - lp_var_t batteryChargeCurrent = lp_var_t(sid.objectId, - P60System::P60DOCK_BATT_CHARGE_CURRENT, this); - lp_var_t batteryDischargeCurrent = lp_var_t(sid.objectId, - P60System::P60DOCK_BATT_DISCHARGE_CURRENT, this); - lp_var_t ant6Depl = lp_var_t(sid.objectId, - P60System::P60DOCK_ANT6_DEPL, this); - lp_var_t ar6Depl = lp_var_t(sid.objectId, - P60System::P60DOCK_AR6_DEPL, this); + lp_var_t wdtGndLeft = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_GND_LEFT, this); + lp_var_t wdtI2cLeft = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_I2C_LEFT, this); + lp_var_t wdtCanLeft = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CAN_LEFT, this); + lp_var_t wdtCspLeft1 = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CSP_LEFT_1, this); + lp_var_t wdtCspLeft2 = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CSP_LEFT_2, this); + lp_var_t batteryChargeCurrent = + lp_var_t(sid.objectId, P60System::P60DOCK_BATT_CHARGE_CURRENT, this); + lp_var_t batteryDischargeCurrent = + lp_var_t(sid.objectId, P60System::P60DOCK_BATT_DISCHARGE_CURRENT, this); + lp_var_t ant6Depl = lp_var_t(sid.objectId, P60System::P60DOCK_ANT6_DEPL, this); + lp_var_t ar6Depl = lp_var_t(sid.objectId, P60System::P60DOCK_AR6_DEPL, this); }; -} - +} // namespace P60Dock /** * @brief Constants common for both PDU1 and PDU2. */ -namespace PDU{ +namespace PDU { /** When retrieving full configuration parameter table */ static const uint16_t MAX_REPLY_LENGTH = 318; static const uint16_t MAX_CONFIGTABLE_ADDRESS = 316; @@ -627,11 +607,10 @@ static const uint16_t MAX_HKTABLE_ADDRESS = 141; /** The size of the csp reply containing the housekeeping table data */ static const uint16_t HK_TABLE_REPLY_SIZE = 303; static const uint8_t HK_TABLE_ENTRIES = 73; -} - +} // namespace PDU namespace PDU1 { -static const uint32_t HK_TABLE_DATA_SET_ID = 0x1; // hk table has table id 4 +static const uint32_t HK_TABLE_DATA_SET_ID = 0x1; // hk table has table id 4 /** * Addresses within configuration table to enable or disable output channels. Refer also to * gs-man-nanopower-p60-pdu-200.pdf on page 16. @@ -649,194 +628,174 @@ static const uint16_t CONFIG_ADDRESS_OUT_EN_CHANNEL8 = 0x56; /** * @brief This class defines a dataset for the hk table of the PDU1. */ -class PDU1HkTableDataset : - public StaticLocalDataSet { - public: +class PDU1HkTableDataset : public StaticLocalDataSet { + public: + PDU1HkTableDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) {} - PDU1HkTableDataset(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) { - } + PDU1HkTableDataset(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) {} - PDU1HkTableDataset(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) { - } + /** Measured output currents */ + lp_var_t currentOutTCSBoard3V3 = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_TCS_BOARD_3V3, this); + lp_var_t currentOutSyrlinks = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_SYRLINKS, this); + lp_var_t currentOutStarTracker = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_STAR_TRACKER, this); + lp_var_t currentOutMGT = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_MGT, this); + lp_var_t currentOutSUSNominal = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_SUS_NOMINAL, this); + lp_var_t currentOutSolarCellExp = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, this); + lp_var_t currentOutPLOC = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_PLOC, this); + lp_var_t currentOutACSBoardSideA = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, this); + lp_var_t currentOutChannel8 = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_CHANNEL8, this); + /** Measured voltage of output channels */ + lp_var_t voltageOutTCSBoard3V3 = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, this); + lp_var_t voltageOutSyrlinks = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_SYRLINKS, this); + lp_var_t voltageOutStarTracker = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_STAR_TRACKER, this); + lp_var_t voltageOutMGT = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_MGT, this); + lp_var_t voltageOutSUSNominal = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_SUS_NOMINAL, this); + lp_var_t voltageOutSolarCellExp = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, this); + lp_var_t voltageOutPLOC = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_PLOC, this); + lp_var_t voltageOutACSBoardSideA = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, this); + lp_var_t voltageOutChannel8 = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_CHANNEL8, this); + /** Measured VCC */ + lp_var_t vcc = lp_var_t(sid.objectId, P60System::PDU1_VCC, this); + /** Measured VBAT */ + lp_var_t vbat = lp_var_t(sid.objectId, P60System::PDU1_VBAT, this); + lp_var_t temperature = + lp_var_t(sid.objectId, P60System::PDU1_TEMPERATURE, this); + /** Output converter enable status */ + lp_var_t converterEnable1 = + lp_var_t(sid.objectId, P60System::PDU1_CONV_EN_1, this); + lp_var_t converterEnable2 = + lp_var_t(sid.objectId, P60System::PDU1_CONV_EN_2, this); + lp_var_t converterEnable3 = + lp_var_t(sid.objectId, P60System::PDU1_CONV_EN_3, this); - /** Measured output currents */ - lp_var_t currentOutTCSBoard3V3 = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_TCS_BOARD_3V3, this); - lp_var_t currentOutSyrlinks = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_SYRLINKS, this); - lp_var_t currentOutStarTracker = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_STAR_TRACKER, this); - lp_var_t currentOutMGT = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_MGT, this); - lp_var_t currentOutSUSNominal = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_SUS_NOMINAL, this); - lp_var_t currentOutSolarCellExp = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, this); - lp_var_t currentOutPLOC = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_PLOC, this); - lp_var_t currentOutACSBoardSideA = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, this); - lp_var_t currentOutChannel8 = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_CHANNEL8, this); - /** Measured voltage of output channels */ - lp_var_t voltageOutTCSBoard3V3 = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, this); - lp_var_t voltageOutSyrlinks = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_SYRLINKS, this); - lp_var_t voltageOutStarTracker = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_STAR_TRACKER, this); - lp_var_t voltageOutMGT = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_MGT, this); - lp_var_t voltageOutSUSNominal = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_SUS_NOMINAL, this); - lp_var_t voltageOutSolarCellExp = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, this); - lp_var_t voltageOutPLOC = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_PLOC, this); - lp_var_t voltageOutACSBoardSideA = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, this); - lp_var_t voltageOutChannel8 = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_CHANNEL8, this); - /** Measured VCC */ - lp_var_t vcc = lp_var_t(sid.objectId, - P60System::PDU1_VCC, this); - /** Measured VBAT */ - lp_var_t vbat = lp_var_t(sid.objectId, - P60System::PDU1_VBAT, this); - lp_var_t temperature = lp_var_t(sid.objectId, - P60System::PDU1_TEMPERATURE, this); - /** Output converter enable status */ - lp_var_t converterEnable1 = lp_var_t(sid.objectId, - P60System::PDU1_CONV_EN_1, this); - lp_var_t converterEnable2 = lp_var_t(sid.objectId, - P60System::PDU1_CONV_EN_2, this); - lp_var_t converterEnable3 = lp_var_t(sid.objectId, - P60System::PDU1_CONV_EN_3, this); + /** Output channels enable status */ + lp_var_t outEnabledTCSBoard3V3 = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_TCS_BOARD_3V3, this); + lp_var_t outEnabledSyrlinks = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_SYRLINKS, this); + lp_var_t outEnabledStarTracker = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_STAR_TRACKER, this); + lp_var_t outEnabledMGT = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_MGT, this); + lp_var_t outEnabledSUSNominal = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_SUS_NOMINAL, this); + lp_var_t outEnabledSolarCellExp = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_SOLAR_CELL_EXP, this); + lp_var_t outEnabledPLOC = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_PLOC, this); + lp_var_t outEnabledAcsBoardSideA = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_ACS_BOARD_SIDE_A, this); + lp_var_t outEnabledChannel8 = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_CHANNEL8, this); + lp_var_t bootcause = lp_var_t(sid.objectId, P60System::PDU1_BOOTCAUSE, this); + /** Number of reboots */ + lp_var_t bootcount = lp_var_t(sid.objectId, P60System::PDU1_BOOTCNT, this); + /** Uptime in seconds */ + lp_var_t uptime = lp_var_t(sid.objectId, P60System::PDU1_UPTIME, this); + lp_var_t resetcause = + lp_var_t(sid.objectId, P60System::PDU1_RESETCAUSE, this); + /** Battery mode: 1 = Critical, 2 = Safe, 3 = Normal, 4 = Full */ + lp_var_t battMode = lp_var_t(sid.objectId, P60System::PDU1_BATT_MODE, this); - /** Output channels enable status */ - lp_var_t outEnabledTCSBoard3V3 = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_TCS_BOARD_3V3, this); - lp_var_t outEnabledSyrlinks = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_SYRLINKS, this); - lp_var_t outEnabledStarTracker = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_STAR_TRACKER, this); - lp_var_t outEnabledMGT = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_MGT, this); - lp_var_t outEnabledSUSNominal = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_SUS_NOMINAL, this); - lp_var_t outEnabledSolarCellExp = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_SOLAR_CELL_EXP, this); - lp_var_t outEnabledPLOC = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_PLOC, this); - lp_var_t outEnabledAcsBoardSideA = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_ACS_BOARD_SIDE_A, this); - lp_var_t outEnabledChannel8 = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_CHANNEL8, this); - lp_var_t bootcause = lp_var_t(sid.objectId, - P60System::PDU1_BOOTCAUSE, this); - /** Number of reboots */ - lp_var_t bootcount = lp_var_t(sid.objectId, - P60System::PDU1_BOOTCNT, this); - /** Uptime in seconds */ - lp_var_t uptime = lp_var_t(sid.objectId, - P60System::PDU1_UPTIME, this); - lp_var_t resetcause = lp_var_t(sid.objectId, - P60System::PDU1_RESETCAUSE, this); - /** Battery mode: 1 = Critical, 2 = Safe, 3 = Normal, 4 = Full */ - lp_var_t battMode = lp_var_t(sid.objectId, - P60System::PDU1_BATT_MODE, this); + /** Number of detected latchups on each output channel */ + lp_var_t latchupsTcsBoard3V3 = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_TCS_BOARD_3V3, this); + lp_var_t latchupsSyrlinks = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_SYRLINKS, this); + lp_var_t latchupsStarTracker = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_STAR_TRACKER, this); + lp_var_t latchupsMgt = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_MGT, this); + lp_var_t latchupsSusNominal = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_SUS_NOMINAL, this); + lp_var_t latchupsSolarCellExp = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_SOLAR_CELL_EXP, this); + lp_var_t latchupsPloc = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_PLOC, this); + lp_var_t latchupsAcsBoardSideA = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_ACS_BOARD_SIDE_A, this); + lp_var_t latchupsChannel8 = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_CHANNEL8, this); - /** Number of detected latchups on each output channel */ - lp_var_t latchupsTcsBoard3V3 = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_TCS_BOARD_3V3, this); - lp_var_t latchupsSyrlinks = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_SYRLINKS, this); - lp_var_t latchupsStarTracker = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_STAR_TRACKER, this); - lp_var_t latchupsMgt = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_MGT, this); - lp_var_t latchupsSusNominal = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_SUS_NOMINAL, this); - lp_var_t latchupsSolarCellExp = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_SOLAR_CELL_EXP, this); - lp_var_t latchupsPloc = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_PLOC, this); - lp_var_t latchupsAcsBoardSideA = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_ACS_BOARD_SIDE_A, this); - lp_var_t latchupsChannel8 = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_CHANNEL8, this); + /** + * There are 8 devices on the PDU. FRAM, ADCs, temperature sensor etc. Each device is + * identified by an ID. Refer also to gs-man-nanopower-p60-pdu-200-1.pdf on pages 17 and 18. + */ + lp_var_t device0 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_0, this); + lp_var_t device1 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_1, this); + lp_var_t device2 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_2, this); + lp_var_t device3 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_3, this); + lp_var_t device4 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_4, this); + lp_var_t device5 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_5, this); + lp_var_t device6 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_6, this); + lp_var_t device7 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_7, this); + /** The status of each device. 0 = None, 1 = Ok, 2 = Error, 3 = Not found */ + lp_var_t device0Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_0_STATUS, this); + lp_var_t device1Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_1_STATUS, this); + lp_var_t device2Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_2_STATUS, this); + lp_var_t device3Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_3_STATUS, this); + lp_var_t device4Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_4_STATUS, this); + lp_var_t device5Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_5_STATUS, this); + lp_var_t device6Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_6_STATUS, this); + lp_var_t device7Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_7_STATUS, this); - /** - * There are 8 devices on the PDU. FRAM, ADCs, temperature sensor etc. Each device is - * identified by an ID. Refer also to gs-man-nanopower-p60-pdu-200-1.pdf on pages 17 and 18. - */ - lp_var_t device0 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_0, this); - lp_var_t device1 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_1, this); - lp_var_t device2 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_2, this); - lp_var_t device3 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_3, this); - lp_var_t device4 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_4, this); - lp_var_t device5 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_5, this); - lp_var_t device6 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_6, this); - lp_var_t device7 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_7, this); - /** The status of each device. 0 = None, 1 = Ok, 2 = Error, 3 = Not found */ - lp_var_t device0Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_0_STATUS, this); - lp_var_t device1Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_1_STATUS, this); - lp_var_t device2Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_2_STATUS, this); - lp_var_t device3Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_3_STATUS, this); - lp_var_t device4Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_4_STATUS, this); - lp_var_t device5Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_5_STATUS, this); - lp_var_t device6Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_6_STATUS, this); - lp_var_t device7Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_7_STATUS, this); - - /** Number of reboots triggered by the ground watchdog */ - lp_var_t gndWdtReboots = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CNT_GND, this); - /** Number of reboots triggered through the I2C watchdog. Not relevant for EIVE. */ - lp_var_t i2cWdtReboots = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CNT_I2C, this); - /** Number of reboots triggered through the CAN watchdog */ - lp_var_t canWdtReboots = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CNT_CAN, this); - /** Number of reboots triggered through the CSP watchdog */ - lp_var_t csp1WdtReboots = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CNT_CSP1, this); - lp_var_t csp2WdtReboots = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CNT_CSP2, this); - /** Ground watchdog remaining seconds before rebooting */ - lp_var_t groundWatchdogSecondsLeft = lp_var_t(sid.objectId, - P60System::PDU1_WDT_GND_LEFT, this); - /** I2C watchdog remaining seconds before rebooting. Not relevant for EIVE. */ - lp_var_t i2cWatchdogSecondsLeft = lp_var_t(sid.objectId, - P60System::PDU1_WDT_I2C_LEFT, this); - /** CAN watchdog remaining seconds before rebooting. */ - lp_var_t canWatchdogSecondsLeft = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CAN_LEFT, this); - /** CSP watchdogs remaining pings before rebooting. */ - lp_var_t csp2WatchdogPingsLeft = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CSP_LEFT1, this); - lp_var_t csp1WatchdogPingsLeft = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CSP_LEFT2, this); + /** Number of reboots triggered by the ground watchdog */ + lp_var_t gndWdtReboots = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CNT_GND, this); + /** Number of reboots triggered through the I2C watchdog. Not relevant for EIVE. */ + lp_var_t i2cWdtReboots = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CNT_I2C, this); + /** Number of reboots triggered through the CAN watchdog */ + lp_var_t canWdtReboots = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CNT_CAN, this); + /** Number of reboots triggered through the CSP watchdog */ + lp_var_t csp1WdtReboots = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CNT_CSP1, this); + lp_var_t csp2WdtReboots = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CNT_CSP2, this); + /** Ground watchdog remaining seconds before rebooting */ + lp_var_t groundWatchdogSecondsLeft = + lp_var_t(sid.objectId, P60System::PDU1_WDT_GND_LEFT, this); + /** I2C watchdog remaining seconds before rebooting. Not relevant for EIVE. */ + lp_var_t i2cWatchdogSecondsLeft = + lp_var_t(sid.objectId, P60System::PDU1_WDT_I2C_LEFT, this); + /** CAN watchdog remaining seconds before rebooting. */ + lp_var_t canWatchdogSecondsLeft = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CAN_LEFT, this); + /** CSP watchdogs remaining pings before rebooting. */ + lp_var_t csp2WatchdogPingsLeft = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CSP_LEFT1, this); + lp_var_t csp1WatchdogPingsLeft = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CSP_LEFT2, this); }; -} - +} // namespace PDU1 namespace PDU2 { static const uint32_t HK_TABLE_DATA_SET_ID = 0x2; @@ -857,194 +816,174 @@ static const uint16_t CONFIG_ADDRESS_OUT_EN_PAYLOAD_CAMERA = 0x50; /** * @brief This class defines a dataset for the hk table of the PDU2. */ -class PDU2HkTableDataset: - public StaticLocalDataSet { - public: +class PDU2HkTableDataset : public StaticLocalDataSet { + public: + PDU2HkTableDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) {} - PDU2HkTableDataset(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) { - } + PDU2HkTableDataset(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) {} - PDU2HkTableDataset(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) { - } + /** Measured output currents */ + lp_var_t currentOutQ7S = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_Q7S, this); + lp_var_t currentOutPayloadPCDUCh1 = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, this); + lp_var_t currentOutReactionWheels = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_RW, this); + lp_var_t currentOutTCSBoardHeaterIn = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, this); + lp_var_t currentOutSUSRedundant = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_SUS_REDUNDANT, this); + lp_var_t currentOutDeplMechanism = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, this); + lp_var_t currentOutPayloadPCDUCh6 = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, this); + lp_var_t currentOutACSBoardSideB = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, this); + lp_var_t currentOutPayloadCamera = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, this); + /** Measured voltage of output channels */ + lp_var_t voltageOutQ7S = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_Q7S, this); + lp_var_t voltageOutPayloadPCDUCh1 = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, this); + lp_var_t voltageOutReactionWheels = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_RW, this); + lp_var_t voltageOutTCSBoardHeaterIn = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, this); + lp_var_t voltageOutSUSRedundant = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, this); + lp_var_t voltageOutDeplMechanism = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, this); + lp_var_t voltageOutPayloadPCDUCh6 = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, this); + lp_var_t voltageOutACSBoardSideB = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, this); + lp_var_t voltageOutPayloadCamera = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, this); + /** Measured VCC */ + lp_var_t vcc = lp_var_t(sid.objectId, P60System::PDU2_VCC, this); + /** Measured VBAT */ + lp_var_t vbat = lp_var_t(sid.objectId, P60System::PDU2_VBAT, this); + lp_var_t temperature = + lp_var_t(sid.objectId, P60System::PDU2_TEMPERATURE, this); + /** Output converter enable status */ + lp_var_t converterEnable1 = + lp_var_t(sid.objectId, P60System::PDU2_CONV_EN_1, this); + lp_var_t converterEnable2 = + lp_var_t(sid.objectId, P60System::PDU2_CONV_EN_2, this); + lp_var_t converterEnable3 = + lp_var_t(sid.objectId, P60System::PDU2_CONV_EN_3, this); + /** Output channels enable status */ + lp_var_t outEnabledQ7S = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_Q7S, this); + lp_var_t outEnabledPlPCDUCh1 = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, this); + lp_var_t outEnabledReactionWheels = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_RW, this); + lp_var_t outEnabledTCSBoardHeaterIn = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, this); + lp_var_t outEnabledSUSRedundant = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_SUS_REDUNDANT, this); + lp_var_t outEnabledDeplMechanism = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_DEPLOYMENT_MECHANISM, this); + lp_var_t outEnabledPlPCDUCh6 = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH6, this); + lp_var_t outEnabledAcsBoardSideB = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_ACS_BOARD_SIDE_B, this); + lp_var_t outEnabledPayloadCamera = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_PAYLOAD_CAMERA, this); - /** Measured output currents */ - lp_var_t currentOutQ7S = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_Q7S, this); - lp_var_t currentOutPayloadPCDUCh1 = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, this); - lp_var_t currentOutReactionWheels = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_RW, this); - lp_var_t currentOutTCSBoardHeaterIn = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, this); - lp_var_t currentOutSUSRedundant = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_SUS_REDUNDANT, this); - lp_var_t currentOutDeplMechanism = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, this); - lp_var_t currentOutPayloadPCDUCh6 = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, this); - lp_var_t currentOutACSBoardSideB = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, this); - lp_var_t currentOutPayloadCamera = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, this); - /** Measured voltage of output channels */ - lp_var_t voltageOutQ7S = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_Q7S, this); - lp_var_t voltageOutPayloadPCDUCh1 = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, this); - lp_var_t voltageOutReactionWheels = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_RW, this); - lp_var_t voltageOutTCSBoardHeaterIn = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, this); - lp_var_t voltageOutSUSRedundant = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, this); - lp_var_t voltageOutDeplMechanism = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, this); - lp_var_t voltageOutPayloadPCDUCh6 = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, this); - lp_var_t voltageOutACSBoardSideB = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, this); - lp_var_t voltageOutPayloadCamera = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, this); - /** Measured VCC */ - lp_var_t vcc = lp_var_t(sid.objectId, - P60System::PDU2_VCC, this); - /** Measured VBAT */ - lp_var_t vbat = lp_var_t(sid.objectId, - P60System::PDU2_VBAT, this); - lp_var_t temperature = lp_var_t(sid.objectId, - P60System::PDU2_TEMPERATURE, this); - /** Output converter enable status */ - lp_var_t converterEnable1 = lp_var_t(sid.objectId, - P60System::PDU2_CONV_EN_1, this); - lp_var_t converterEnable2 = lp_var_t(sid.objectId, - P60System::PDU2_CONV_EN_2, this); - lp_var_t converterEnable3 = lp_var_t(sid.objectId, - P60System::PDU2_CONV_EN_3, this); - /** Output channels enable status */ - lp_var_t outEnabledQ7S = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_Q7S, this); - lp_var_t outEnabledPlPCDUCh1 = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, this); - lp_var_t outEnabledReactionWheels = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_RW, this); - lp_var_t outEnabledTCSBoardHeaterIn = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, this); - lp_var_t outEnabledSUSRedundant = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_SUS_REDUNDANT, this); - lp_var_t outEnabledDeplMechanism = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_DEPLOYMENT_MECHANISM, this); - lp_var_t outEnabledPlPCDUCh6 = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH6, this); - lp_var_t outEnabledAcsBoardSideB = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_ACS_BOARD_SIDE_B, this); - lp_var_t outEnabledPayloadCamera = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_PAYLOAD_CAMERA, this); + lp_var_t bootcause = lp_var_t(sid.objectId, P60System::PDU2_BOOTCAUSE, this); + /** Number of reboots */ + lp_var_t bootcount = lp_var_t(sid.objectId, P60System::PDU2_BOOTCNT, this); + /** Uptime in seconds */ + lp_var_t uptime = lp_var_t(sid.objectId, P60System::PDU2_UPTIME, this); + lp_var_t resetcause = + lp_var_t(sid.objectId, P60System::PDU2_RESETCAUSE, this); + /** Battery mode: 1 = Critical, 2 = Safe, 3 = Normal, 4 = Full */ + lp_var_t battMode = lp_var_t(sid.objectId, P60System::PDU2_BATT_MODE, this); - lp_var_t bootcause = lp_var_t(sid.objectId, - P60System::PDU2_BOOTCAUSE, this); - /** Number of reboots */ - lp_var_t bootcount = lp_var_t(sid.objectId, - P60System::PDU2_BOOTCNT, this); - /** Uptime in seconds */ - lp_var_t uptime = lp_var_t(sid.objectId, - P60System::PDU2_UPTIME, this); - lp_var_t resetcause = lp_var_t(sid.objectId, - P60System::PDU2_RESETCAUSE, this); - /** Battery mode: 1 = Critical, 2 = Safe, 3 = Normal, 4 = Full */ - lp_var_t battMode = lp_var_t(sid.objectId, - P60System::PDU2_BATT_MODE, this); + /** Number of detected latchups on each output channel */ + lp_var_t latchupsQ7S = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_Q7S, this); + lp_var_t latchupsPayloadPcduCh1 = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, this); + lp_var_t latchupsRw = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_RW, this); + lp_var_t latchupsTcsBoardHeaterIn = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, this); + lp_var_t latchupsSusRedundant = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_SUS_REDUNDANT, this); + lp_var_t latchupsDeplMenchanism = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_DEPLOYMENT_MECHANISM, this); + lp_var_t latchupsPayloadPcduCh6 = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, this); + lp_var_t latchupsAcsBoardSideB = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_ACS_BOARD_SIDE_B, this); + lp_var_t latchupsPayloadCamera = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_PAYLOAD_CAMERA, this); - /** Number of detected latchups on each output channel */ - lp_var_t latchupsQ7S = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_Q7S, this); - lp_var_t latchupsPayloadPcduCh1 = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, this); - lp_var_t latchupsRw = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_RW, this); - lp_var_t latchupsTcsBoardHeaterIn = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, this); - lp_var_t latchupsSusRedundant = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_SUS_REDUNDANT, this); - lp_var_t latchupsDeplMenchanism = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_DEPLOYMENT_MECHANISM, this); - lp_var_t latchupsPayloadPcduCh6 = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, this); - lp_var_t latchupsAcsBoardSideB = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_ACS_BOARD_SIDE_B, this); - lp_var_t latchupsPayloadCamera = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_PAYLOAD_CAMERA, this); + /** + * There are 8 devices on the PDU. FRAM, ADCs, temperature sensor etc. Each device is + * identified by an ID. Refer also to gs-man-nanopower-p60-pdu-200-1.pdf on pages 17 and 18. + */ + lp_var_t device0 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_0, this); + lp_var_t device1 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_1, this); + lp_var_t device2 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_2, this); + lp_var_t device3 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_3, this); + lp_var_t device4 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_4, this); + lp_var_t device5 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_5, this); + lp_var_t device6 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_6, this); + lp_var_t device7 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_7, this); + /** The status of each device. 0 = None, 1 = Ok, 2 = Error, 3 = Not found */ + lp_var_t device0Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_0_STATUS, this); + lp_var_t device1Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_1_STATUS, this); + lp_var_t device2Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_2_STATUS, this); + lp_var_t device3Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_3_STATUS, this); + lp_var_t device4Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_4_STATUS, this); + lp_var_t device5Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_5_STATUS, this); + lp_var_t device6Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_6_STATUS, this); + lp_var_t device7Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_7_STATUS, this); - /** - * There are 8 devices on the PDU. FRAM, ADCs, temperature sensor etc. Each device is - * identified by an ID. Refer also to gs-man-nanopower-p60-pdu-200-1.pdf on pages 17 and 18. - */ - lp_var_t device0 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_0, this); - lp_var_t device1 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_1, this); - lp_var_t device2 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_2, this); - lp_var_t device3 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_3, this); - lp_var_t device4 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_4, this); - lp_var_t device5 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_5, this); - lp_var_t device6 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_6, this); - lp_var_t device7 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_7, this); - /** The status of each device. 0 = None, 1 = Ok, 2 = Error, 3 = Not found */ - lp_var_t device0Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_0_STATUS, this); - lp_var_t device1Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_1_STATUS, this); - lp_var_t device2Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_2_STATUS, this); - lp_var_t device3Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_3_STATUS, this); - lp_var_t device4Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_4_STATUS, this); - lp_var_t device5Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_5_STATUS, this); - lp_var_t device6Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_6_STATUS, this); - lp_var_t device7Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_7_STATUS, this); - - /** Number of reboots triggered by the ground watchdog */ - lp_var_t gndWdtReboots = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CNT_GND, this); - /** Number of reboots triggered through the I2C watchdog. Not relevant for EIVE. */ - lp_var_t i2cWdtReboots = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CNT_I2C, this); - /** Number of reboots triggered through the CAN watchdog */ - lp_var_t canWdtReboots = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CNT_CAN, this); - /** Number of reboots triggered through the CSP watchdog */ - lp_var_t csp1WdtReboots = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CNT_CSP1, this); - lp_var_t csp2WdtReboots = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CNT_CSP2, this); - /** Ground watchdog remaining seconds before rebooting */ - lp_var_t groundWatchdogSecondsLeft = lp_var_t(sid.objectId, - P60System::PDU2_WDT_GND_LEFT, this); - /** I2C watchdog remaining seconds before rebooting. Not relevant for EIVE. */ - lp_var_t i2cWatchdogSecondsLeft = lp_var_t(sid.objectId, - P60System::PDU2_WDT_I2C_LEFT, this); - /** CAN watchdog remaining seconds before rebooting. */ - lp_var_t canWatchdogSecondsLeft = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CAN_LEFT, this); - /** CSP watchdog remaining pings before rebooting. */ - lp_var_t csp1WatchdogPingsLeft = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CSP_LEFT1, this); - lp_var_t csp2WatchdogPingsLeft = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CSP_LEFT2, this); + /** Number of reboots triggered by the ground watchdog */ + lp_var_t gndWdtReboots = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CNT_GND, this); + /** Number of reboots triggered through the I2C watchdog. Not relevant for EIVE. */ + lp_var_t i2cWdtReboots = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CNT_I2C, this); + /** Number of reboots triggered through the CAN watchdog */ + lp_var_t canWdtReboots = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CNT_CAN, this); + /** Number of reboots triggered through the CSP watchdog */ + lp_var_t csp1WdtReboots = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CNT_CSP1, this); + lp_var_t csp2WdtReboots = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CNT_CSP2, this); + /** Ground watchdog remaining seconds before rebooting */ + lp_var_t groundWatchdogSecondsLeft = + lp_var_t(sid.objectId, P60System::PDU2_WDT_GND_LEFT, this); + /** I2C watchdog remaining seconds before rebooting. Not relevant for EIVE. */ + lp_var_t i2cWatchdogSecondsLeft = + lp_var_t(sid.objectId, P60System::PDU2_WDT_I2C_LEFT, this); + /** CAN watchdog remaining seconds before rebooting. */ + lp_var_t canWatchdogSecondsLeft = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CAN_LEFT, this); + /** CSP watchdog remaining pings before rebooting. */ + lp_var_t csp1WatchdogPingsLeft = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CSP_LEFT1, this); + lp_var_t csp2WatchdogPingsLeft = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CSP_LEFT2, this); }; -} - +} // namespace PDU2 namespace ACU { @@ -1060,157 +999,133 @@ static const uint16_t HK_TABLE_REPLY_SIZE = 262; /** * @brief This class defines a dataset for the hk table of the ACU. */ -class HkTableDataset: - public StaticLocalDataSet { - public: +class HkTableDataset : public StaticLocalDataSet { + public: + HkTableDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) {} - HkTableDataset(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) { - } + HkTableDataset(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) {} - HkTableDataset(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) { - } + lp_var_t currentInChannel0 = + lp_var_t(sid.objectId, P60System::ACU_CURRENT_IN_CHANNEL0, this); + lp_var_t currentInChannel1 = + lp_var_t(sid.objectId, P60System::ACU_CURRENT_IN_CHANNEL1, this); + lp_var_t currentInChannel2 = + lp_var_t(sid.objectId, P60System::ACU_CURRENT_IN_CHANNEL2, this); + lp_var_t currentInChannel3 = + lp_var_t(sid.objectId, P60System::ACU_CURRENT_IN_CHANNEL3, this); + lp_var_t currentInChannel4 = + lp_var_t(sid.objectId, P60System::ACU_CURRENT_IN_CHANNEL4, this); + lp_var_t currentInChannel5 = + lp_var_t(sid.objectId, P60System::ACU_CURRENT_IN_CHANNEL5, this); - lp_var_t currentInChannel0 = lp_var_t(sid.objectId, - P60System::ACU_CURRENT_IN_CHANNEL0, this); - lp_var_t currentInChannel1 = lp_var_t(sid.objectId, - P60System::ACU_CURRENT_IN_CHANNEL1, this); - lp_var_t currentInChannel2 = lp_var_t(sid.objectId, - P60System::ACU_CURRENT_IN_CHANNEL2, this); - lp_var_t currentInChannel3 = lp_var_t(sid.objectId, - P60System::ACU_CURRENT_IN_CHANNEL3, this); - lp_var_t currentInChannel4 = lp_var_t(sid.objectId, - P60System::ACU_CURRENT_IN_CHANNEL4, this); - lp_var_t currentInChannel5 = lp_var_t(sid.objectId, - P60System::ACU_CURRENT_IN_CHANNEL5, this); + lp_var_t voltageInChannel0 = + lp_var_t(sid.objectId, P60System::ACU_VOLTAGE_IN_CHANNEL0, this); + lp_var_t voltageInChannel1 = + lp_var_t(sid.objectId, P60System::ACU_VOLTAGE_IN_CHANNEL1, this); + lp_var_t voltageInChannel2 = + lp_var_t(sid.objectId, P60System::ACU_VOLTAGE_IN_CHANNEL2, this); + lp_var_t voltageInChannel3 = + lp_var_t(sid.objectId, P60System::ACU_VOLTAGE_IN_CHANNEL3, this); + lp_var_t voltageInChannel4 = + lp_var_t(sid.objectId, P60System::ACU_VOLTAGE_IN_CHANNEL4, this); + lp_var_t voltageInChannel5 = + lp_var_t(sid.objectId, P60System::ACU_VOLTAGE_IN_CHANNEL5, this); - lp_var_t voltageInChannel0 = lp_var_t(sid.objectId, - P60System::ACU_VOLTAGE_IN_CHANNEL0, this); - lp_var_t voltageInChannel1 = lp_var_t(sid.objectId, - P60System::ACU_VOLTAGE_IN_CHANNEL1, this); - lp_var_t voltageInChannel2 = lp_var_t(sid.objectId, - P60System::ACU_VOLTAGE_IN_CHANNEL2, this); - lp_var_t voltageInChannel3 = lp_var_t(sid.objectId, - P60System::ACU_VOLTAGE_IN_CHANNEL3, this); - lp_var_t voltageInChannel4 = lp_var_t(sid.objectId, - P60System::ACU_VOLTAGE_IN_CHANNEL4, this); - lp_var_t voltageInChannel5 = lp_var_t(sid.objectId, - P60System::ACU_VOLTAGE_IN_CHANNEL5, this); + lp_var_t vcc = lp_var_t(sid.objectId, P60System::ACU_VCC, this); + lp_var_t vbat = lp_var_t(sid.objectId, P60System::ACU_VBAT, this); - lp_var_t vcc = lp_var_t(sid.objectId, - P60System::ACU_VCC, this); - lp_var_t vbat = lp_var_t(sid.objectId, - P60System::ACU_VBAT, this); + lp_var_t temperature1 = + lp_var_t(sid.objectId, P60System::ACU_TEMPERATURE_1, this); + lp_var_t temperature2 = + lp_var_t(sid.objectId, P60System::ACU_TEMPERATURE_2, this); + lp_var_t temperature3 = + lp_var_t(sid.objectId, P60System::ACU_TEMPERATURE_3, this); - lp_var_t temperature1 = lp_var_t(sid.objectId, - P60System::ACU_TEMPERATURE_1, this); - lp_var_t temperature2 = lp_var_t(sid.objectId, - P60System::ACU_TEMPERATURE_2, this); - lp_var_t temperature3 = lp_var_t(sid.objectId, - P60System::ACU_TEMPERATURE_3, this); + lp_var_t mpptMode = lp_var_t(sid.objectId, P60System::ACU_MPPT_MODE, this); - lp_var_t mpptMode = lp_var_t(sid.objectId, - P60System::ACU_MPPT_MODE, this); + lp_var_t vboostInChannel0 = + lp_var_t(sid.objectId, P60System::ACU_VBOOST_CHANNEL0, this); + lp_var_t vboostInChannel1 = + lp_var_t(sid.objectId, P60System::ACU_VBOOST_CHANNEL1, this); + lp_var_t vboostInChannel2 = + lp_var_t(sid.objectId, P60System::ACU_VBOOST_CHANNEL2, this); + lp_var_t vboostInChannel3 = + lp_var_t(sid.objectId, P60System::ACU_VBOOST_CHANNEL3, this); + lp_var_t vboostInChannel4 = + lp_var_t(sid.objectId, P60System::ACU_VBOOST_CHANNEL4, this); + lp_var_t vboostInChannel5 = + lp_var_t(sid.objectId, P60System::ACU_VBOOST_CHANNEL5, this); - lp_var_t vboostInChannel0 = lp_var_t(sid.objectId, - P60System::ACU_VBOOST_CHANNEL0, this); - lp_var_t vboostInChannel1 = lp_var_t(sid.objectId, - P60System::ACU_VBOOST_CHANNEL1, this); - lp_var_t vboostInChannel2 = lp_var_t(sid.objectId, - P60System::ACU_VBOOST_CHANNEL2, this); - lp_var_t vboostInChannel3 = lp_var_t(sid.objectId, - P60System::ACU_VBOOST_CHANNEL3, this); - lp_var_t vboostInChannel4 = lp_var_t(sid.objectId, - P60System::ACU_VBOOST_CHANNEL4, this); - lp_var_t vboostInChannel5 = lp_var_t(sid.objectId, - P60System::ACU_VBOOST_CHANNEL5, this); + lp_var_t powerInChannel0 = + lp_var_t(sid.objectId, P60System::ACU_POWER_CHANNEL0, this); + lp_var_t powerInChannel1 = + lp_var_t(sid.objectId, P60System::ACU_POWER_CHANNEL1, this); + lp_var_t powerInChannel2 = + lp_var_t(sid.objectId, P60System::ACU_POWER_CHANNEL2, this); + lp_var_t powerInChannel3 = + lp_var_t(sid.objectId, P60System::ACU_POWER_CHANNEL3, this); + lp_var_t powerInChannel4 = + lp_var_t(sid.objectId, P60System::ACU_POWER_CHANNEL4, this); + lp_var_t powerInChannel5 = + lp_var_t(sid.objectId, P60System::ACU_POWER_CHANNEL5, this); - lp_var_t powerInChannel0 = lp_var_t(sid.objectId, - P60System::ACU_POWER_CHANNEL0, this); - lp_var_t powerInChannel1 = lp_var_t(sid.objectId, - P60System::ACU_POWER_CHANNEL1, this); - lp_var_t powerInChannel2 = lp_var_t(sid.objectId, - P60System::ACU_POWER_CHANNEL2, this); - lp_var_t powerInChannel3 = lp_var_t(sid.objectId, - P60System::ACU_POWER_CHANNEL3, this); - lp_var_t powerInChannel4 = lp_var_t(sid.objectId, - P60System::ACU_POWER_CHANNEL4, this); - lp_var_t powerInChannel5 = lp_var_t(sid.objectId, - P60System::ACU_POWER_CHANNEL5, this); + lp_var_t dac0Enable = lp_var_t(sid.objectId, P60System::ACU_DAC_EN_0, this); + lp_var_t dac1Enable = lp_var_t(sid.objectId, P60System::ACU_DAC_EN_1, this); + lp_var_t dac2Enable = lp_var_t(sid.objectId, P60System::ACU_DAC_EN_2, this); - lp_var_t dac0Enable = lp_var_t(sid.objectId, - P60System::ACU_DAC_EN_0, this); - lp_var_t dac1Enable = lp_var_t(sid.objectId, - P60System::ACU_DAC_EN_1, this); - lp_var_t dac2Enable = lp_var_t(sid.objectId, - P60System::ACU_DAC_EN_2, this); + lp_var_t dacRawChannelVal0 = + lp_var_t(sid.objectId, P60System::ACU_DAC_RAW_0, this); + lp_var_t dacRawChannelVal1 = + lp_var_t(sid.objectId, P60System::ACU_DAC_RAW_1, this); + lp_var_t dacRawChannelVal2 = + lp_var_t(sid.objectId, P60System::ACU_DAC_RAW_2, this); + lp_var_t dacRawChannelVal3 = + lp_var_t(sid.objectId, P60System::ACU_DAC_RAW_3, this); + lp_var_t dacRawChannelVal4 = + lp_var_t(sid.objectId, P60System::ACU_DAC_RAW_4, this); + lp_var_t dacRawChannelVal5 = + lp_var_t(sid.objectId, P60System::ACU_DAC_RAW_5, this); - lp_var_t dacRawChannelVal0 = lp_var_t(sid.objectId, - P60System::ACU_DAC_RAW_0, this); - lp_var_t dacRawChannelVal1 = lp_var_t(sid.objectId, - P60System::ACU_DAC_RAW_1, this); - lp_var_t dacRawChannelVal2 = lp_var_t(sid.objectId, - P60System::ACU_DAC_RAW_2, this); - lp_var_t dacRawChannelVal3 = lp_var_t(sid.objectId, - P60System::ACU_DAC_RAW_3, this); - lp_var_t dacRawChannelVal4 = lp_var_t(sid.objectId, - P60System::ACU_DAC_RAW_4, this); - lp_var_t dacRawChannelVal5 = lp_var_t(sid.objectId, - P60System::ACU_DAC_RAW_5, this); + lp_var_t bootCause = lp_var_t(sid.objectId, P60System::ACU_BOOTCAUSE, this); + lp_var_t bootcnt = lp_var_t(sid.objectId, P60System::ACU_BOOTCNT, this); + lp_var_t uptime = lp_var_t(sid.objectId, P60System::ACU_UPTIME, this); + lp_var_t resetCause = + lp_var_t(sid.objectId, P60System::ACU_RESET_CAUSE, this); + lp_var_t mpptTime = lp_var_t(sid.objectId, P60System::ACU_MPPT_TIME, this); + lp_var_t mpptPeriod = + lp_var_t(sid.objectId, P60System::ACU_MPPT_PERIOD, this); - lp_var_t bootCause = lp_var_t(sid.objectId, - P60System::ACU_BOOTCAUSE, this); - lp_var_t bootcnt = lp_var_t(sid.objectId, - P60System::ACU_BOOTCNT, this); - lp_var_t uptime = lp_var_t(sid.objectId, - P60System::ACU_UPTIME, this); - lp_var_t resetCause = lp_var_t(sid.objectId, - P60System::ACU_RESET_CAUSE, this); - lp_var_t mpptTime = lp_var_t(sid.objectId, - P60System::ACU_MPPT_TIME, this); - lp_var_t mpptPeriod = lp_var_t(sid.objectId, - P60System::ACU_MPPT_PERIOD, this); + lp_var_t device0 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_0, this); + lp_var_t device1 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_1, this); + lp_var_t device2 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_2, this); + lp_var_t device3 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_3, this); + lp_var_t device4 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_4, this); + lp_var_t device5 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_5, this); + lp_var_t device6 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_6, this); + lp_var_t device7 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_7, this); - lp_var_t device0 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_0, this); - lp_var_t device1 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_1, this); - lp_var_t device2 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_2, this); - lp_var_t device3 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_3, this); - lp_var_t device4 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_4, this); - lp_var_t device5 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_5, this); - lp_var_t device6 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_6, this); - lp_var_t device7 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_7, this); + lp_var_t device0Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_0_STATUS, this); + lp_var_t device1Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_1_STATUS, this); + lp_var_t device2Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_2_STATUS, this); + lp_var_t device3Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_3_STATUS, this); + lp_var_t device4Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_4_STATUS, this); + lp_var_t device5Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_5_STATUS, this); + lp_var_t device6Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_6_STATUS, this); + lp_var_t device7Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_7_STATUS, this); - lp_var_t device0Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_0_STATUS, this); - lp_var_t device1Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_1_STATUS, this); - lp_var_t device2Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_2_STATUS, this); - lp_var_t device3Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_3_STATUS, this); - lp_var_t device4Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_4_STATUS, this); - lp_var_t device5Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_5_STATUS, this); - lp_var_t device6Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_6_STATUS, this); - lp_var_t device7Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_7_STATUS, this); - - lp_var_t wdtCntGnd = lp_var_t(sid.objectId, - P60System::ACU_WDT_CNT_GND, this); - lp_var_t wdtGndLeft = lp_var_t(sid.objectId, - P60System::ACU_WDT_GND_LEFT, this); + lp_var_t wdtCntGnd = lp_var_t(sid.objectId, P60System::ACU_WDT_CNT_GND, this); + lp_var_t wdtGndLeft = + lp_var_t(sid.objectId, P60System::ACU_WDT_GND_LEFT, this); }; -} +} // namespace ACU #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEDEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/GyroADIS1650XDefinitions.h b/mission/devices/devicedefinitions/GyroADIS1650XDefinitions.h index 62744e3a..a09d2fb7 100644 --- a/mission/devices/devicedefinitions/GyroADIS1650XDefinitions.h +++ b/mission/devices/devicedefinitions/GyroADIS1650XDefinitions.h @@ -1,17 +1,14 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_GYROADIS16507DEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_GYROADIS16507DEFINITIONS_H_ -#include "fsfw/devicehandlers/DeviceHandlerIF.h" -#include "fsfw/datapoollocal/StaticLocalDataSet.h" - #include +#include "fsfw/datapoollocal/StaticLocalDataSet.h" +#include "fsfw/devicehandlers/DeviceHandlerIF.h" + namespace ADIS1650X { -enum class Type { - ADIS16505, - ADIS16507 -}; +enum class Type { ADIS16505, ADIS16507 }; static constexpr size_t MAXIMUM_REPLY_SIZE = 64; static constexpr uint8_t WRITE_MASK = 0b1000'0000; @@ -63,91 +60,82 @@ static constexpr size_t SENSOR_READOUT_SIZE = 20 + 2; static constexpr uint32_t ADIS_DATASET_ID = READ_SENSOR_DATA; static constexpr uint32_t ADIS_CFG_DATASET_ID = READ_OUT_CONFIG; -enum GlobCmds: uint8_t { - FACTORY_CALIBRATION = 0b0000'0010, - SENSOR_SELF_TEST = 0b0000'0100, - FLASH_MEMORY_UPDATE = 0b0000'1000, - FLASH_MEMORY_TEST = 0b0001'0000, - SOFTWARE_RESET = 0b1000'0000 +enum GlobCmds : uint8_t { + FACTORY_CALIBRATION = 0b0000'0010, + SENSOR_SELF_TEST = 0b0000'0100, + FLASH_MEMORY_UPDATE = 0b0000'1000, + FLASH_MEMORY_TEST = 0b0001'0000, + SOFTWARE_RESET = 0b1000'0000 }; -enum PrimaryPoolIds: lp_id_t { - ANG_VELOC_X, - ANG_VELOC_Y, - ANG_VELOC_Z, - ACCELERATION_X, - ACCELERATION_Y, - ACCELERATION_Z, - TEMPERATURE, - DIAG_STAT_REGISTER, - FILTER_SETTINGS, - MSC_CTRL_REGISTER, - DEC_RATE_REGISTER, +enum PrimaryPoolIds : lp_id_t { + ANG_VELOC_X, + ANG_VELOC_Y, + ANG_VELOC_Z, + ACCELERATION_X, + ACCELERATION_Y, + ACCELERATION_Z, + TEMPERATURE, + DIAG_STAT_REGISTER, + FILTER_SETTINGS, + MSC_CTRL_REGISTER, + DEC_RATE_REGISTER, }; -enum FilterSettings: uint8_t { - NO_FILTER = 0, - TWO_TAPS = 1, - FOUR_TAPS = 2, - EIGHT_TAPS = 3, - SIXTEEN_TAPS = 4, - THIRTYTWO_TAPS = 5, - SIXTYFOUR_TAPS = 6 +enum FilterSettings : uint8_t { + NO_FILTER = 0, + TWO_TAPS = 1, + FOUR_TAPS = 2, + EIGHT_TAPS = 3, + SIXTEEN_TAPS = 4, + THIRTYTWO_TAPS = 5, + SIXTYFOUR_TAPS = 6 }; -} +} // namespace ADIS1650X -class AdisGyroPrimaryDataset: public StaticLocalDataSet<8> { -public: +class AdisGyroPrimaryDataset : public StaticLocalDataSet<8> { + public: + /** Constructor for data users like controllers */ + AdisGyroPrimaryDataset(object_id_t adisId) + : StaticLocalDataSet(sid_t(adisId, ADIS1650X::ADIS_DATASET_ID)) { + setAllVariablesReadOnly(); + } - /** Constructor for data users like controllers */ - AdisGyroPrimaryDataset(object_id_t adisId): - StaticLocalDataSet(sid_t(adisId, ADIS1650X::ADIS_DATASET_ID)) { - setAllVariablesReadOnly(); - } + /* Angular velocities in degrees per second (DPS) */ + lp_var_t angVelocX = lp_var_t(sid.objectId, ADIS1650X::ANG_VELOC_X, this); + lp_var_t angVelocY = lp_var_t(sid.objectId, ADIS1650X::ANG_VELOC_Y, this); + lp_var_t angVelocZ = lp_var_t(sid.objectId, ADIS1650X::ANG_VELOC_Z, this); + lp_var_t accelX = lp_var_t(sid.objectId, ADIS1650X::ACCELERATION_X, this); + lp_var_t accelY = lp_var_t(sid.objectId, ADIS1650X::ACCELERATION_Y, this); + lp_var_t accelZ = lp_var_t(sid.objectId, ADIS1650X::ACCELERATION_Z, this); + lp_var_t temperature = lp_var_t(sid.objectId, ADIS1650X::TEMPERATURE, this); - /* Angular velocities in degrees per second (DPS) */ - lp_var_t angVelocX = lp_var_t(sid.objectId, - ADIS1650X::ANG_VELOC_X, this); - lp_var_t angVelocY = lp_var_t(sid.objectId, - ADIS1650X::ANG_VELOC_Y, this); - lp_var_t angVelocZ = lp_var_t(sid.objectId, - ADIS1650X::ANG_VELOC_Z, this); - lp_var_t accelX = lp_var_t(sid.objectId, - ADIS1650X::ACCELERATION_X, this); - lp_var_t accelY = lp_var_t(sid.objectId, - ADIS1650X::ACCELERATION_Y, this); - lp_var_t accelZ = lp_var_t(sid.objectId, - ADIS1650X::ACCELERATION_Z, this); - lp_var_t temperature = lp_var_t(sid.objectId, - ADIS1650X::TEMPERATURE, this); -private: - - friend class GyroADIS1650XHandler; - /** Constructor for the data creator */ - AdisGyroPrimaryDataset(HasLocalDataPoolIF* hkOwner): - StaticLocalDataSet(hkOwner, ADIS1650X::ADIS_DATASET_ID) {} + private: + friend class GyroADIS1650XHandler; + /** Constructor for the data creator */ + AdisGyroPrimaryDataset(HasLocalDataPoolIF* hkOwner) + : StaticLocalDataSet(hkOwner, ADIS1650X::ADIS_DATASET_ID) {} }; -class AdisGyroConfigDataset: public StaticLocalDataSet<5> { -public: +class AdisGyroConfigDataset : public StaticLocalDataSet<5> { + public: + /** Constructor for data users like controllers */ + AdisGyroConfigDataset(object_id_t adisId) + : StaticLocalDataSet(sid_t(adisId, ADIS1650X::ADIS_CFG_DATASET_ID)) { + setAllVariablesReadOnly(); + } - /** Constructor for data users like controllers */ - AdisGyroConfigDataset(object_id_t adisId): - StaticLocalDataSet(sid_t(adisId, ADIS1650X::ADIS_CFG_DATASET_ID)) { - setAllVariablesReadOnly(); - } + lp_var_t diagStatReg = lp_var_t(sid.objectId, ADIS1650X::DIAG_STAT_REGISTER); + lp_var_t filterSetting = lp_var_t(sid.objectId, ADIS1650X::FILTER_SETTINGS); + lp_var_t mscCtrlReg = lp_var_t(sid.objectId, ADIS1650X::MSC_CTRL_REGISTER); + lp_var_t decRateReg = lp_var_t(sid.objectId, ADIS1650X::DEC_RATE_REGISTER); - lp_var_t diagStatReg = lp_var_t(sid.objectId, - ADIS1650X::DIAG_STAT_REGISTER); - lp_var_t filterSetting = lp_var_t(sid.objectId, ADIS1650X::FILTER_SETTINGS); - lp_var_t mscCtrlReg = lp_var_t(sid.objectId, ADIS1650X::MSC_CTRL_REGISTER); - lp_var_t decRateReg = lp_var_t(sid.objectId, ADIS1650X::DEC_RATE_REGISTER); -private: - friend class GyroADIS1650XHandler; - /** Constructor for the data creator */ - AdisGyroConfigDataset(HasLocalDataPoolIF* hkOwner): - StaticLocalDataSet(hkOwner, ADIS1650X::ADIS_CFG_DATASET_ID) {} + private: + friend class GyroADIS1650XHandler; + /** Constructor for the data creator */ + AdisGyroConfigDataset(HasLocalDataPoolIF* hkOwner) + : StaticLocalDataSet(hkOwner, ADIS1650X::ADIS_CFG_DATASET_ID) {} }; #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GYROADIS16507DEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/GyroL3GD20Definitions.h b/mission/devices/devicedefinitions/GyroL3GD20Definitions.h index b5b80495..4c4543d0 100644 --- a/mission/devices/devicedefinitions/GyroL3GD20Definitions.h +++ b/mission/devices/devicedefinitions/GyroL3GD20Definitions.h @@ -3,6 +3,7 @@ #include #include + #include namespace L3GD20H { @@ -36,8 +37,8 @@ static constexpr uint8_t SET_Z_ENABLE = 1 << 2; static constexpr uint8_t SET_X_ENABLE = 1 << 1; static constexpr uint8_t SET_Y_ENABLE = 1; -static constexpr uint8_t CTRL_REG_1_VAL = SET_POWER_NORMAL_MODE | SET_Z_ENABLE | - SET_Y_ENABLE | SET_X_ENABLE; +static constexpr uint8_t CTRL_REG_1_VAL = + SET_POWER_NORMAL_MODE | SET_Z_ENABLE | SET_Y_ENABLE | SET_X_ENABLE; /* Register 2 */ static constexpr uint8_t EXTERNAL_EDGE_ENB = 1 << 7; @@ -101,40 +102,29 @@ static constexpr DeviceCommandId_t READ_CTRL_REGS = 2; static constexpr uint32_t GYRO_DATASET_ID = READ_REGS; -enum GyroPoolIds: lp_id_t { - ANG_VELOC_X, - ANG_VELOC_Y, - ANG_VELOC_Z, - TEMPERATURE +enum GyroPoolIds : lp_id_t { ANG_VELOC_X, ANG_VELOC_Y, ANG_VELOC_Z, TEMPERATURE }; + +} // namespace L3GD20H + +class GyroPrimaryDataset : public StaticLocalDataSet<5> { + public: + /** Constructor for data users like controllers */ + GyroPrimaryDataset(object_id_t mgmId) + : StaticLocalDataSet(sid_t(mgmId, L3GD20H::GYRO_DATASET_ID)) { + setAllVariablesReadOnly(); + } + + /* Angular velocities in degrees per second (DPS) */ + lp_var_t angVelocX = lp_var_t(sid.objectId, L3GD20H::ANG_VELOC_X, this); + lp_var_t angVelocY = lp_var_t(sid.objectId, L3GD20H::ANG_VELOC_Y, this); + lp_var_t angVelocZ = lp_var_t(sid.objectId, L3GD20H::ANG_VELOC_Z, this); + lp_var_t temperature = lp_var_t(sid.objectId, L3GD20H::TEMPERATURE, this); + + private: + friend class GyroHandlerL3GD20H; + /** Constructor for the data creator */ + GyroPrimaryDataset(HasLocalDataPoolIF* hkOwner) + : StaticLocalDataSet(hkOwner, L3GD20H::GYRO_DATASET_ID) {} }; -} - -class GyroPrimaryDataset: public StaticLocalDataSet<5> { -public: - - /** Constructor for data users like controllers */ - GyroPrimaryDataset(object_id_t mgmId): - StaticLocalDataSet(sid_t(mgmId, L3GD20H::GYRO_DATASET_ID)) { - setAllVariablesReadOnly(); - } - - /* Angular velocities in degrees per second (DPS) */ - lp_var_t angVelocX = lp_var_t(sid.objectId, - L3GD20H::ANG_VELOC_X, this); - lp_var_t angVelocY = lp_var_t(sid.objectId, - L3GD20H::ANG_VELOC_Y, this); - lp_var_t angVelocZ = lp_var_t(sid.objectId, - L3GD20H::ANG_VELOC_Z, this); - lp_var_t temperature = lp_var_t(sid.objectId, - L3GD20H::TEMPERATURE, this); -private: - - friend class GyroHandlerL3GD20H; - /** Constructor for the data creator */ - GyroPrimaryDataset(HasLocalDataPoolIF* hkOwner): - StaticLocalDataSet(hkOwner, L3GD20H::GYRO_DATASET_ID) {} -}; - - #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GYROL3GD20DEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/IMTQHandlerDefinitions.h b/mission/devices/devicedefinitions/IMTQHandlerDefinitions.h index e95bd42e..609bbdf8 100644 --- a/mission/devices/devicedefinitions/IMTQHandlerDefinitions.h +++ b/mission/devices/devicedefinitions/IMTQHandlerDefinitions.h @@ -5,453 +5,435 @@ namespace IMTQ { - static const DeviceCommandId_t NONE = 0x0; - static const DeviceCommandId_t GET_ENG_HK_DATA = 0x1; - static const DeviceCommandId_t START_ACTUATION_DIPOLE = 0x2; - static const DeviceCommandId_t GET_COMMANDED_DIPOLE = 0x3; - /** Generates new measurement of the magnetic field */ - static const DeviceCommandId_t START_MTM_MEASUREMENT = 0x4; - /** Requests the calibrated magnetometer measurement */ - static const DeviceCommandId_t GET_CAL_MTM_MEASUREMENT = 0x5; - /** Requests the raw values measured by the built-in MTM XEN1210 */ - static const DeviceCommandId_t GET_RAW_MTM_MEASUREMENT = 0x6; - static const DeviceCommandId_t POS_X_SELF_TEST = 0x7; - static const DeviceCommandId_t NEG_X_SELF_TEST = 0x8; - static const DeviceCommandId_t POS_Y_SELF_TEST = 0x9; - static const DeviceCommandId_t NEG_Y_SELF_TEST = 0xA; - static const DeviceCommandId_t POS_Z_SELF_TEST = 0xB; - static const DeviceCommandId_t NEG_Z_SELF_TEST = 0xC; - static const DeviceCommandId_t GET_SELF_TEST_RESULT = 0xD; +static const DeviceCommandId_t NONE = 0x0; +static const DeviceCommandId_t GET_ENG_HK_DATA = 0x1; +static const DeviceCommandId_t START_ACTUATION_DIPOLE = 0x2; +static const DeviceCommandId_t GET_COMMANDED_DIPOLE = 0x3; +/** Generates new measurement of the magnetic field */ +static const DeviceCommandId_t START_MTM_MEASUREMENT = 0x4; +/** Requests the calibrated magnetometer measurement */ +static const DeviceCommandId_t GET_CAL_MTM_MEASUREMENT = 0x5; +/** Requests the raw values measured by the built-in MTM XEN1210 */ +static const DeviceCommandId_t GET_RAW_MTM_MEASUREMENT = 0x6; +static const DeviceCommandId_t POS_X_SELF_TEST = 0x7; +static const DeviceCommandId_t NEG_X_SELF_TEST = 0x8; +static const DeviceCommandId_t POS_Y_SELF_TEST = 0x9; +static const DeviceCommandId_t NEG_Y_SELF_TEST = 0xA; +static const DeviceCommandId_t POS_Z_SELF_TEST = 0xB; +static const DeviceCommandId_t NEG_Z_SELF_TEST = 0xC; +static const DeviceCommandId_t GET_SELF_TEST_RESULT = 0xD; - static const uint8_t GET_TEMP_REPLY_SIZE = 2; - static const uint8_t CFGR_CMD_SIZE = 3; - static const uint8_t POINTER_REG_SIZE = 1; +static const uint8_t GET_TEMP_REPLY_SIZE = 2; +static const uint8_t CFGR_CMD_SIZE = 3; +static const uint8_t POINTER_REG_SIZE = 1; - static const uint32_t ENG_HK_DATA_SET_ID = 1; - static const uint32_t CAL_MTM_SET = 2; - static const uint32_t RAW_MTM_SET = 3; - static const uint32_t POS_X_TEST_DATASET = 4; - static const uint32_t NEG_X_TEST_DATASET = 5; - static const uint32_t POS_Y_TEST_DATASET = 6; - static const uint32_t NEG_Y_TEST_DATASET = 7; - static const uint32_t POS_Z_TEST_DATASET = 8; - static const uint32_t NEG_Z_TEST_DATASET = 9; +static const uint32_t ENG_HK_DATA_SET_ID = 1; +static const uint32_t CAL_MTM_SET = 2; +static const uint32_t RAW_MTM_SET = 3; +static const uint32_t POS_X_TEST_DATASET = 4; +static const uint32_t NEG_X_TEST_DATASET = 5; +static const uint32_t POS_Y_TEST_DATASET = 6; +static const uint32_t NEG_Y_TEST_DATASET = 7; +static const uint32_t POS_Z_TEST_DATASET = 8; +static const uint32_t NEG_Z_TEST_DATASET = 9; - static const uint8_t SIZE_ENG_HK_COMMAND = 1; - static const uint8_t SIZE_STATUS_REPLY = 2; - static const uint8_t SIZE_ENG_HK_DATA_REPLY = 24; - static const uint8_t SIZE_GET_COMMANDED_DIPOLE_REPLY = 8; - static const uint8_t SIZE_GET_CAL_MTM_MEASUREMENT = 15; - static const uint8_t SIZE_GET_RAW_MTM_MEASUREMENT = 15; - static const uint16_t SIZE_SELF_TEST_RESULTS = 120; +static const uint8_t SIZE_ENG_HK_COMMAND = 1; +static const uint8_t SIZE_STATUS_REPLY = 2; +static const uint8_t SIZE_ENG_HK_DATA_REPLY = 24; +static const uint8_t SIZE_GET_COMMANDED_DIPOLE_REPLY = 8; +static const uint8_t SIZE_GET_CAL_MTM_MEASUREMENT = 15; +static const uint8_t SIZE_GET_RAW_MTM_MEASUREMENT = 15; +static const uint16_t SIZE_SELF_TEST_RESULTS = 120; - static const uint16_t MAX_REPLY_SIZE = SIZE_SELF_TEST_RESULTS; - static const uint8_t MAX_COMMAND_SIZE = 9; +static const uint16_t MAX_REPLY_SIZE = SIZE_SELF_TEST_RESULTS; +static const uint8_t MAX_COMMAND_SIZE = 9; - /** Define entries in IMTQ specific dataset */ - static const uint8_t ENG_HK_SET_POOL_ENTRIES = 11; - static const uint8_t CAL_MTM_POOL_ENTRIES = 4; - static const uint8_t SELF_TEST_DATASET_ENTRIES = 104; +/** Define entries in IMTQ specific dataset */ +static const uint8_t ENG_HK_SET_POOL_ENTRIES = 11; +static const uint8_t CAL_MTM_POOL_ENTRIES = 4; +static const uint8_t SELF_TEST_DATASET_ENTRIES = 104; - /** Error codes for interpreting the self test error byte */ - static const uint8_t I2C_FAILURE_MASK = 0x1; - static const uint8_t SPI_FAILURE_MASK = 0x2; // MTM connectivity - static const uint8_t ADC_FAILURE_MASK = 0x4; // Current/Temp measurement - static const uint8_t PWM_FAILURE_MASK = 0x8; // Coil actuation - static const uint8_t TC_FAILURE_MASK = 0x10; // System failure - static const uint8_t MTM_RANGE_FAILURE_MASK = 0x20; // MTM values outside of expected range - static const uint8_t COIL_CURRENT_FAILURE_MASK = 0x40; // Coil currents outside of expected range - static const uint8_t INVALID_ERROR_BYTE = 0x80; // This is an invalid error byte and should be never replied by the IMTQ +/** Error codes for interpreting the self test error byte */ +static const uint8_t I2C_FAILURE_MASK = 0x1; +static const uint8_t SPI_FAILURE_MASK = 0x2; // MTM connectivity +static const uint8_t ADC_FAILURE_MASK = 0x4; // Current/Temp measurement +static const uint8_t PWM_FAILURE_MASK = 0x8; // Coil actuation +static const uint8_t TC_FAILURE_MASK = 0x10; // System failure +static const uint8_t MTM_RANGE_FAILURE_MASK = 0x20; // MTM values outside of expected range +static const uint8_t COIL_CURRENT_FAILURE_MASK = 0x40; // Coil currents outside of expected range +static const uint8_t INVALID_ERROR_BYTE = + 0x80; // This is an invalid error byte and should be never replied by the IMTQ - static const uint8_t MAIN_STEP_OFFSET = 43; +static const uint8_t MAIN_STEP_OFFSET = 43; - /** - * Command code definitions. Each command or reply of an IMTQ request will begin with one of - * the following command codes. - */ - namespace CC { - static const uint8_t START_MTM_MEASUREMENT = 0x4; - static const uint8_t START_ACTUATION_DIPOLE = 0x6; - static const uint8_t SELF_TEST_CMD = 0x8; - static const uint8_t SOFTWARE_RESET = 0xAA; - static const uint8_t GET_ENG_HK_DATA = 0x4A; - static const uint8_t GET_COMMANDED_DIPOLE = 0x46; - static const uint8_t GET_RAW_MTM_MEASUREMENT = 0x42; - static const uint8_t GET_CAL_MTM_MEASUREMENT = 0x43; - static const uint8_t GET_SELF_TEST_RESULT = 0x47; - }; +/** + * Command code definitions. Each command or reply of an IMTQ request will begin with one of + * the following command codes. + */ +namespace CC { +static const uint8_t START_MTM_MEASUREMENT = 0x4; +static const uint8_t START_ACTUATION_DIPOLE = 0x6; +static const uint8_t SELF_TEST_CMD = 0x8; +static const uint8_t SOFTWARE_RESET = 0xAA; +static const uint8_t GET_ENG_HK_DATA = 0x4A; +static const uint8_t GET_COMMANDED_DIPOLE = 0x46; +static const uint8_t GET_RAW_MTM_MEASUREMENT = 0x42; +static const uint8_t GET_CAL_MTM_MEASUREMENT = 0x43; +static const uint8_t GET_SELF_TEST_RESULT = 0x47; +}; // namespace CC - namespace SELF_TEST_AXIS { - static const uint8_t ALL = 0x0; - static const uint8_t X_POSITIVE = 0x1; - static const uint8_t X_NEGATIVE = 0x2; - static const uint8_t Y_POSITIVE = 0x3; - static const uint8_t Y_NEGATIVE = 0x4; - static const uint8_t Z_POSITIVE = 0x5; - static const uint8_t Z_NEGATIVE = 0x6; - } +namespace SELF_TEST_AXIS { +static const uint8_t ALL = 0x0; +static const uint8_t X_POSITIVE = 0x1; +static const uint8_t X_NEGATIVE = 0x2; +static const uint8_t Y_POSITIVE = 0x3; +static const uint8_t Y_NEGATIVE = 0x4; +static const uint8_t Z_POSITIVE = 0x5; +static const uint8_t Z_NEGATIVE = 0x6; +} // namespace SELF_TEST_AXIS - namespace SELF_TEST_STEPS { - static const uint8_t INIT = 0x0; - static const uint8_t X_POSITIVE = 0x1; - static const uint8_t X_NEGATIVE = 0x2; - static const uint8_t Y_POSITIVE = 0x3; - static const uint8_t Y_NEGATIVE = 0x4; - static const uint8_t Z_POSITIVE = 0x5; - static const uint8_t Z_NEGATIVE = 0x6; - static const uint8_t FINA = 0x7; - } +namespace SELF_TEST_STEPS { +static const uint8_t INIT = 0x0; +static const uint8_t X_POSITIVE = 0x1; +static const uint8_t X_NEGATIVE = 0x2; +static const uint8_t Y_POSITIVE = 0x3; +static const uint8_t Y_NEGATIVE = 0x4; +static const uint8_t Z_POSITIVE = 0x5; +static const uint8_t Z_NEGATIVE = 0x6; +static const uint8_t FINA = 0x7; +} // namespace SELF_TEST_STEPS - enum IMTQPoolIds: lp_id_t { - DIGITAL_VOLTAGE_MV, - ANALOG_VOLTAGE_MV, - DIGITAL_CURRENT, - ANALOG_CURRENT, - COIL_X_CURRENT, - COIL_Y_CURRENT, - COIL_Z_CURRENT, - COIL_X_TEMPERATURE, - COIL_Y_TEMPERATURE, - COIL_Z_TEMPERATURE, - MCU_TEMPERATURE, - MTM_CAL_X, - MTM_CAL_Y, - MTM_CAL_Z, - ACTUATION_CAL_STATUS, - MTM_RAW_X, - MTM_RAW_Y, - MTM_RAW_Z, - ACTUATION_RAW_STATUS, +enum IMTQPoolIds : lp_id_t { + DIGITAL_VOLTAGE_MV, + ANALOG_VOLTAGE_MV, + DIGITAL_CURRENT, + ANALOG_CURRENT, + COIL_X_CURRENT, + COIL_Y_CURRENT, + COIL_Z_CURRENT, + COIL_X_TEMPERATURE, + COIL_Y_TEMPERATURE, + COIL_Z_TEMPERATURE, + MCU_TEMPERATURE, + MTM_CAL_X, + MTM_CAL_Y, + MTM_CAL_Z, + ACTUATION_CAL_STATUS, + MTM_RAW_X, + MTM_RAW_Y, + MTM_RAW_Z, + ACTUATION_RAW_STATUS, - INIT_POS_X_ERR, - INIT_POS_X_RAW_MAG_X, - INIT_POS_X_RAW_MAG_Y, - INIT_POS_X_RAW_MAG_Z, - INIT_POS_X_CAL_MAG_X, - INIT_POS_X_CAL_MAG_Y, - INIT_POS_X_CAL_MAG_Z, - INIT_POS_X_COIL_X_CURRENT, - INIT_POS_X_COIL_Y_CURRENT, - INIT_POS_X_COIL_Z_CURRENT, - INIT_POS_X_COIL_X_TEMPERATURE, - INIT_POS_X_COIL_Y_TEMPERATURE, - INIT_POS_X_COIL_Z_TEMPERATURE, + INIT_POS_X_ERR, + INIT_POS_X_RAW_MAG_X, + INIT_POS_X_RAW_MAG_Y, + INIT_POS_X_RAW_MAG_Z, + INIT_POS_X_CAL_MAG_X, + INIT_POS_X_CAL_MAG_Y, + INIT_POS_X_CAL_MAG_Z, + INIT_POS_X_COIL_X_CURRENT, + INIT_POS_X_COIL_Y_CURRENT, + INIT_POS_X_COIL_Z_CURRENT, + INIT_POS_X_COIL_X_TEMPERATURE, + INIT_POS_X_COIL_Y_TEMPERATURE, + INIT_POS_X_COIL_Z_TEMPERATURE, - INIT_NEG_X_ERR, - INIT_NEG_X_RAW_MAG_X, - INIT_NEG_X_RAW_MAG_Y, - INIT_NEG_X_RAW_MAG_Z, - INIT_NEG_X_CAL_MAG_X, - INIT_NEG_X_CAL_MAG_Y, - INIT_NEG_X_CAL_MAG_Z, - INIT_NEG_X_COIL_X_CURRENT, - INIT_NEG_X_COIL_Y_CURRENT, - INIT_NEG_X_COIL_Z_CURRENT, - INIT_NEG_X_COIL_X_TEMPERATURE, - INIT_NEG_X_COIL_Y_TEMPERATURE, - INIT_NEG_X_COIL_Z_TEMPERATURE, + INIT_NEG_X_ERR, + INIT_NEG_X_RAW_MAG_X, + INIT_NEG_X_RAW_MAG_Y, + INIT_NEG_X_RAW_MAG_Z, + INIT_NEG_X_CAL_MAG_X, + INIT_NEG_X_CAL_MAG_Y, + INIT_NEG_X_CAL_MAG_Z, + INIT_NEG_X_COIL_X_CURRENT, + INIT_NEG_X_COIL_Y_CURRENT, + INIT_NEG_X_COIL_Z_CURRENT, + INIT_NEG_X_COIL_X_TEMPERATURE, + INIT_NEG_X_COIL_Y_TEMPERATURE, + INIT_NEG_X_COIL_Z_TEMPERATURE, - INIT_POS_Y_ERR, - INIT_POS_Y_RAW_MAG_X, - INIT_POS_Y_RAW_MAG_Y, - INIT_POS_Y_RAW_MAG_Z, - INIT_POS_Y_CAL_MAG_X, - INIT_POS_Y_CAL_MAG_Y, - INIT_POS_Y_CAL_MAG_Z, - INIT_POS_Y_COIL_X_CURRENT, - INIT_POS_Y_COIL_Y_CURRENT, - INIT_POS_Y_COIL_Z_CURRENT, - INIT_POS_Y_COIL_X_TEMPERATURE, - INIT_POS_Y_COIL_Y_TEMPERATURE, - INIT_POS_Y_COIL_Z_TEMPERATURE, + INIT_POS_Y_ERR, + INIT_POS_Y_RAW_MAG_X, + INIT_POS_Y_RAW_MAG_Y, + INIT_POS_Y_RAW_MAG_Z, + INIT_POS_Y_CAL_MAG_X, + INIT_POS_Y_CAL_MAG_Y, + INIT_POS_Y_CAL_MAG_Z, + INIT_POS_Y_COIL_X_CURRENT, + INIT_POS_Y_COIL_Y_CURRENT, + INIT_POS_Y_COIL_Z_CURRENT, + INIT_POS_Y_COIL_X_TEMPERATURE, + INIT_POS_Y_COIL_Y_TEMPERATURE, + INIT_POS_Y_COIL_Z_TEMPERATURE, - INIT_NEG_Y_ERR, - INIT_NEG_Y_RAW_MAG_X, - INIT_NEG_Y_RAW_MAG_Y, - INIT_NEG_Y_RAW_MAG_Z, - INIT_NEG_Y_CAL_MAG_X, - INIT_NEG_Y_CAL_MAG_Y, - INIT_NEG_Y_CAL_MAG_Z, - INIT_NEG_Y_COIL_X_CURRENT, - INIT_NEG_Y_COIL_Y_CURRENT, - INIT_NEG_Y_COIL_Z_CURRENT, - INIT_NEG_Y_COIL_X_TEMPERATURE, - INIT_NEG_Y_COIL_Y_TEMPERATURE, - INIT_NEG_Y_COIL_Z_TEMPERATURE, + INIT_NEG_Y_ERR, + INIT_NEG_Y_RAW_MAG_X, + INIT_NEG_Y_RAW_MAG_Y, + INIT_NEG_Y_RAW_MAG_Z, + INIT_NEG_Y_CAL_MAG_X, + INIT_NEG_Y_CAL_MAG_Y, + INIT_NEG_Y_CAL_MAG_Z, + INIT_NEG_Y_COIL_X_CURRENT, + INIT_NEG_Y_COIL_Y_CURRENT, + INIT_NEG_Y_COIL_Z_CURRENT, + INIT_NEG_Y_COIL_X_TEMPERATURE, + INIT_NEG_Y_COIL_Y_TEMPERATURE, + INIT_NEG_Y_COIL_Z_TEMPERATURE, - INIT_POS_Z_ERR, - INIT_POS_Z_RAW_MAG_X, - INIT_POS_Z_RAW_MAG_Y, - INIT_POS_Z_RAW_MAG_Z, - INIT_POS_Z_CAL_MAG_X, - INIT_POS_Z_CAL_MAG_Y, - INIT_POS_Z_CAL_MAG_Z, - INIT_POS_Z_COIL_X_CURRENT, - INIT_POS_Z_COIL_Y_CURRENT, - INIT_POS_Z_COIL_Z_CURRENT, - INIT_POS_Z_COIL_X_TEMPERATURE, - INIT_POS_Z_COIL_Y_TEMPERATURE, - INIT_POS_Z_COIL_Z_TEMPERATURE, + INIT_POS_Z_ERR, + INIT_POS_Z_RAW_MAG_X, + INIT_POS_Z_RAW_MAG_Y, + INIT_POS_Z_RAW_MAG_Z, + INIT_POS_Z_CAL_MAG_X, + INIT_POS_Z_CAL_MAG_Y, + INIT_POS_Z_CAL_MAG_Z, + INIT_POS_Z_COIL_X_CURRENT, + INIT_POS_Z_COIL_Y_CURRENT, + INIT_POS_Z_COIL_Z_CURRENT, + INIT_POS_Z_COIL_X_TEMPERATURE, + INIT_POS_Z_COIL_Y_TEMPERATURE, + INIT_POS_Z_COIL_Z_TEMPERATURE, - INIT_NEG_Z_ERR, - INIT_NEG_Z_RAW_MAG_X, - INIT_NEG_Z_RAW_MAG_Y, - INIT_NEG_Z_RAW_MAG_Z, - INIT_NEG_Z_CAL_MAG_X, - INIT_NEG_Z_CAL_MAG_Y, - INIT_NEG_Z_CAL_MAG_Z, - INIT_NEG_Z_COIL_X_CURRENT, - INIT_NEG_Z_COIL_Y_CURRENT, - INIT_NEG_Z_COIL_Z_CURRENT, - INIT_NEG_Z_COIL_X_TEMPERATURE, - INIT_NEG_Z_COIL_Y_TEMPERATURE, - INIT_NEG_Z_COIL_Z_TEMPERATURE, + INIT_NEG_Z_ERR, + INIT_NEG_Z_RAW_MAG_X, + INIT_NEG_Z_RAW_MAG_Y, + INIT_NEG_Z_RAW_MAG_Z, + INIT_NEG_Z_CAL_MAG_X, + INIT_NEG_Z_CAL_MAG_Y, + INIT_NEG_Z_CAL_MAG_Z, + INIT_NEG_Z_COIL_X_CURRENT, + INIT_NEG_Z_COIL_Y_CURRENT, + INIT_NEG_Z_COIL_Z_CURRENT, + INIT_NEG_Z_COIL_X_TEMPERATURE, + INIT_NEG_Z_COIL_Y_TEMPERATURE, + INIT_NEG_Z_COIL_Z_TEMPERATURE, - POS_X_ERR, - POS_X_RAW_MAG_X, - POS_X_RAW_MAG_Y, - POS_X_RAW_MAG_Z, - POS_X_CAL_MAG_X, - POS_X_CAL_MAG_Y, - POS_X_CAL_MAG_Z, - POS_X_COIL_X_CURRENT, - POS_X_COIL_Y_CURRENT, - POS_X_COIL_Z_CURRENT, - POS_X_COIL_X_TEMPERATURE, - POS_X_COIL_Y_TEMPERATURE, - POS_X_COIL_Z_TEMPERATURE, + POS_X_ERR, + POS_X_RAW_MAG_X, + POS_X_RAW_MAG_Y, + POS_X_RAW_MAG_Z, + POS_X_CAL_MAG_X, + POS_X_CAL_MAG_Y, + POS_X_CAL_MAG_Z, + POS_X_COIL_X_CURRENT, + POS_X_COIL_Y_CURRENT, + POS_X_COIL_Z_CURRENT, + POS_X_COIL_X_TEMPERATURE, + POS_X_COIL_Y_TEMPERATURE, + POS_X_COIL_Z_TEMPERATURE, - NEG_X_ERR, - NEG_X_RAW_MAG_X, - NEG_X_RAW_MAG_Y, - NEG_X_RAW_MAG_Z, - NEG_X_CAL_MAG_X, - NEG_X_CAL_MAG_Y, - NEG_X_CAL_MAG_Z, - NEG_X_COIL_X_CURRENT, - NEG_X_COIL_Y_CURRENT, - NEG_X_COIL_Z_CURRENT, - NEG_X_COIL_X_TEMPERATURE, - NEG_X_COIL_Y_TEMPERATURE, - NEG_X_COIL_Z_TEMPERATURE, + NEG_X_ERR, + NEG_X_RAW_MAG_X, + NEG_X_RAW_MAG_Y, + NEG_X_RAW_MAG_Z, + NEG_X_CAL_MAG_X, + NEG_X_CAL_MAG_Y, + NEG_X_CAL_MAG_Z, + NEG_X_COIL_X_CURRENT, + NEG_X_COIL_Y_CURRENT, + NEG_X_COIL_Z_CURRENT, + NEG_X_COIL_X_TEMPERATURE, + NEG_X_COIL_Y_TEMPERATURE, + NEG_X_COIL_Z_TEMPERATURE, - POS_Y_ERR, - POS_Y_RAW_MAG_X, - POS_Y_RAW_MAG_Y, - POS_Y_RAW_MAG_Z, - POS_Y_CAL_MAG_X, - POS_Y_CAL_MAG_Y, - POS_Y_CAL_MAG_Z, - POS_Y_COIL_X_CURRENT, - POS_Y_COIL_Y_CURRENT, - POS_Y_COIL_Z_CURRENT, - POS_Y_COIL_X_TEMPERATURE, - POS_Y_COIL_Y_TEMPERATURE, - POS_Y_COIL_Z_TEMPERATURE, + POS_Y_ERR, + POS_Y_RAW_MAG_X, + POS_Y_RAW_MAG_Y, + POS_Y_RAW_MAG_Z, + POS_Y_CAL_MAG_X, + POS_Y_CAL_MAG_Y, + POS_Y_CAL_MAG_Z, + POS_Y_COIL_X_CURRENT, + POS_Y_COIL_Y_CURRENT, + POS_Y_COIL_Z_CURRENT, + POS_Y_COIL_X_TEMPERATURE, + POS_Y_COIL_Y_TEMPERATURE, + POS_Y_COIL_Z_TEMPERATURE, - NEG_Y_ERR, - NEG_Y_RAW_MAG_X, - NEG_Y_RAW_MAG_Y, - NEG_Y_RAW_MAG_Z, - NEG_Y_CAL_MAG_X, - NEG_Y_CAL_MAG_Y, - NEG_Y_CAL_MAG_Z, - NEG_Y_COIL_X_CURRENT, - NEG_Y_COIL_Y_CURRENT, - NEG_Y_COIL_Z_CURRENT, - NEG_Y_COIL_X_TEMPERATURE, - NEG_Y_COIL_Y_TEMPERATURE, - NEG_Y_COIL_Z_TEMPERATURE, + NEG_Y_ERR, + NEG_Y_RAW_MAG_X, + NEG_Y_RAW_MAG_Y, + NEG_Y_RAW_MAG_Z, + NEG_Y_CAL_MAG_X, + NEG_Y_CAL_MAG_Y, + NEG_Y_CAL_MAG_Z, + NEG_Y_COIL_X_CURRENT, + NEG_Y_COIL_Y_CURRENT, + NEG_Y_COIL_Z_CURRENT, + NEG_Y_COIL_X_TEMPERATURE, + NEG_Y_COIL_Y_TEMPERATURE, + NEG_Y_COIL_Z_TEMPERATURE, - POS_Z_ERR, - POS_Z_RAW_MAG_X, - POS_Z_RAW_MAG_Y, - POS_Z_RAW_MAG_Z, - POS_Z_CAL_MAG_X, - POS_Z_CAL_MAG_Y, - POS_Z_CAL_MAG_Z, - POS_Z_COIL_X_CURRENT, - POS_Z_COIL_Y_CURRENT, - POS_Z_COIL_Z_CURRENT, - POS_Z_COIL_X_TEMPERATURE, - POS_Z_COIL_Y_TEMPERATURE, - POS_Z_COIL_Z_TEMPERATURE, + POS_Z_ERR, + POS_Z_RAW_MAG_X, + POS_Z_RAW_MAG_Y, + POS_Z_RAW_MAG_Z, + POS_Z_CAL_MAG_X, + POS_Z_CAL_MAG_Y, + POS_Z_CAL_MAG_Z, + POS_Z_COIL_X_CURRENT, + POS_Z_COIL_Y_CURRENT, + POS_Z_COIL_Z_CURRENT, + POS_Z_COIL_X_TEMPERATURE, + POS_Z_COIL_Y_TEMPERATURE, + POS_Z_COIL_Z_TEMPERATURE, - NEG_Z_ERR, - NEG_Z_RAW_MAG_X, - NEG_Z_RAW_MAG_Y, - NEG_Z_RAW_MAG_Z, - NEG_Z_CAL_MAG_X, - NEG_Z_CAL_MAG_Y, - NEG_Z_CAL_MAG_Z, - NEG_Z_COIL_X_CURRENT, - NEG_Z_COIL_Y_CURRENT, - NEG_Z_COIL_Z_CURRENT, - NEG_Z_COIL_X_TEMPERATURE, - NEG_Z_COIL_Y_TEMPERATURE, - NEG_Z_COIL_Z_TEMPERATURE, + NEG_Z_ERR, + NEG_Z_RAW_MAG_X, + NEG_Z_RAW_MAG_Y, + NEG_Z_RAW_MAG_Z, + NEG_Z_CAL_MAG_X, + NEG_Z_CAL_MAG_Y, + NEG_Z_CAL_MAG_Z, + NEG_Z_COIL_X_CURRENT, + NEG_Z_COIL_Y_CURRENT, + NEG_Z_COIL_Z_CURRENT, + NEG_Z_COIL_X_TEMPERATURE, + NEG_Z_COIL_Y_TEMPERATURE, + NEG_Z_COIL_Z_TEMPERATURE, - FINA_POS_X_ERR, - FINA_POS_X_RAW_MAG_X, - FINA_POS_X_RAW_MAG_Y, - FINA_POS_X_RAW_MAG_Z, - FINA_POS_X_CAL_MAG_X, - FINA_POS_X_CAL_MAG_Y, - FINA_POS_X_CAL_MAG_Z, - FINA_POS_X_COIL_X_CURRENT, - FINA_POS_X_COIL_Y_CURRENT, - FINA_POS_X_COIL_Z_CURRENT, - FINA_POS_X_COIL_X_TEMPERATURE, - FINA_POS_X_COIL_Y_TEMPERATURE, - FINA_POS_X_COIL_Z_TEMPERATURE, + FINA_POS_X_ERR, + FINA_POS_X_RAW_MAG_X, + FINA_POS_X_RAW_MAG_Y, + FINA_POS_X_RAW_MAG_Z, + FINA_POS_X_CAL_MAG_X, + FINA_POS_X_CAL_MAG_Y, + FINA_POS_X_CAL_MAG_Z, + FINA_POS_X_COIL_X_CURRENT, + FINA_POS_X_COIL_Y_CURRENT, + FINA_POS_X_COIL_Z_CURRENT, + FINA_POS_X_COIL_X_TEMPERATURE, + FINA_POS_X_COIL_Y_TEMPERATURE, + FINA_POS_X_COIL_Z_TEMPERATURE, - FINA_NEG_X_ERR, - FINA_NEG_X_RAW_MAG_X, - FINA_NEG_X_RAW_MAG_Y, - FINA_NEG_X_RAW_MAG_Z, - FINA_NEG_X_CAL_MAG_X, - FINA_NEG_X_CAL_MAG_Y, - FINA_NEG_X_CAL_MAG_Z, - FINA_NEG_X_COIL_X_CURRENT, - FINA_NEG_X_COIL_Y_CURRENT, - FINA_NEG_X_COIL_Z_CURRENT, - FINA_NEG_X_COIL_X_TEMPERATURE, - FINA_NEG_X_COIL_Y_TEMPERATURE, - FINA_NEG_X_COIL_Z_TEMPERATURE, + FINA_NEG_X_ERR, + FINA_NEG_X_RAW_MAG_X, + FINA_NEG_X_RAW_MAG_Y, + FINA_NEG_X_RAW_MAG_Z, + FINA_NEG_X_CAL_MAG_X, + FINA_NEG_X_CAL_MAG_Y, + FINA_NEG_X_CAL_MAG_Z, + FINA_NEG_X_COIL_X_CURRENT, + FINA_NEG_X_COIL_Y_CURRENT, + FINA_NEG_X_COIL_Z_CURRENT, + FINA_NEG_X_COIL_X_TEMPERATURE, + FINA_NEG_X_COIL_Y_TEMPERATURE, + FINA_NEG_X_COIL_Z_TEMPERATURE, - FINA_POS_Y_ERR, - FINA_POS_Y_RAW_MAG_X, - FINA_POS_Y_RAW_MAG_Y, - FINA_POS_Y_RAW_MAG_Z, - FINA_POS_Y_CAL_MAG_X, - FINA_POS_Y_CAL_MAG_Y, - FINA_POS_Y_CAL_MAG_Z, - FINA_POS_Y_COIL_X_CURRENT, - FINA_POS_Y_COIL_Y_CURRENT, - FINA_POS_Y_COIL_Z_CURRENT, - FINA_POS_Y_COIL_X_TEMPERATURE, - FINA_POS_Y_COIL_Y_TEMPERATURE, - FINA_POS_Y_COIL_Z_TEMPERATURE, + FINA_POS_Y_ERR, + FINA_POS_Y_RAW_MAG_X, + FINA_POS_Y_RAW_MAG_Y, + FINA_POS_Y_RAW_MAG_Z, + FINA_POS_Y_CAL_MAG_X, + FINA_POS_Y_CAL_MAG_Y, + FINA_POS_Y_CAL_MAG_Z, + FINA_POS_Y_COIL_X_CURRENT, + FINA_POS_Y_COIL_Y_CURRENT, + FINA_POS_Y_COIL_Z_CURRENT, + FINA_POS_Y_COIL_X_TEMPERATURE, + FINA_POS_Y_COIL_Y_TEMPERATURE, + FINA_POS_Y_COIL_Z_TEMPERATURE, - FINA_NEG_Y_ERR, - FINA_NEG_Y_RAW_MAG_X, - FINA_NEG_Y_RAW_MAG_Y, - FINA_NEG_Y_RAW_MAG_Z, - FINA_NEG_Y_CAL_MAG_X, - FINA_NEG_Y_CAL_MAG_Y, - FINA_NEG_Y_CAL_MAG_Z, - FINA_NEG_Y_COIL_X_CURRENT, - FINA_NEG_Y_COIL_Y_CURRENT, - FINA_NEG_Y_COIL_Z_CURRENT, - FINA_NEG_Y_COIL_X_TEMPERATURE, - FINA_NEG_Y_COIL_Y_TEMPERATURE, - FINA_NEG_Y_COIL_Z_TEMPERATURE, + FINA_NEG_Y_ERR, + FINA_NEG_Y_RAW_MAG_X, + FINA_NEG_Y_RAW_MAG_Y, + FINA_NEG_Y_RAW_MAG_Z, + FINA_NEG_Y_CAL_MAG_X, + FINA_NEG_Y_CAL_MAG_Y, + FINA_NEG_Y_CAL_MAG_Z, + FINA_NEG_Y_COIL_X_CURRENT, + FINA_NEG_Y_COIL_Y_CURRENT, + FINA_NEG_Y_COIL_Z_CURRENT, + FINA_NEG_Y_COIL_X_TEMPERATURE, + FINA_NEG_Y_COIL_Y_TEMPERATURE, + FINA_NEG_Y_COIL_Z_TEMPERATURE, - FINA_POS_Z_ERR, - FINA_POS_Z_RAW_MAG_X, - FINA_POS_Z_RAW_MAG_Y, - FINA_POS_Z_RAW_MAG_Z, - FINA_POS_Z_CAL_MAG_X, - FINA_POS_Z_CAL_MAG_Y, - FINA_POS_Z_CAL_MAG_Z, - FINA_POS_Z_COIL_X_CURRENT, - FINA_POS_Z_COIL_Y_CURRENT, - FINA_POS_Z_COIL_Z_CURRENT, - FINA_POS_Z_COIL_X_TEMPERATURE, - FINA_POS_Z_COIL_Y_TEMPERATURE, - FINA_POS_Z_COIL_Z_TEMPERATURE, + FINA_POS_Z_ERR, + FINA_POS_Z_RAW_MAG_X, + FINA_POS_Z_RAW_MAG_Y, + FINA_POS_Z_RAW_MAG_Z, + FINA_POS_Z_CAL_MAG_X, + FINA_POS_Z_CAL_MAG_Y, + FINA_POS_Z_CAL_MAG_Z, + FINA_POS_Z_COIL_X_CURRENT, + FINA_POS_Z_COIL_Y_CURRENT, + FINA_POS_Z_COIL_Z_CURRENT, + FINA_POS_Z_COIL_X_TEMPERATURE, + FINA_POS_Z_COIL_Y_TEMPERATURE, + FINA_POS_Z_COIL_Z_TEMPERATURE, - FINA_NEG_Z_ERR, - FINA_NEG_Z_RAW_MAG_X, - FINA_NEG_Z_RAW_MAG_Y, - FINA_NEG_Z_RAW_MAG_Z, - FINA_NEG_Z_CAL_MAG_X, - FINA_NEG_Z_CAL_MAG_Y, - FINA_NEG_Z_CAL_MAG_Z, - FINA_NEG_Z_COIL_X_CURRENT, - FINA_NEG_Z_COIL_Y_CURRENT, - FINA_NEG_Z_COIL_Z_CURRENT, - FINA_NEG_Z_COIL_X_TEMPERATURE, - FINA_NEG_Z_COIL_Y_TEMPERATURE, - FINA_NEG_Z_COIL_Z_TEMPERATURE, - }; + FINA_NEG_Z_ERR, + FINA_NEG_Z_RAW_MAG_X, + FINA_NEG_Z_RAW_MAG_Y, + FINA_NEG_Z_RAW_MAG_Z, + FINA_NEG_Z_CAL_MAG_X, + FINA_NEG_Z_CAL_MAG_Y, + FINA_NEG_Z_CAL_MAG_Z, + FINA_NEG_Z_COIL_X_CURRENT, + FINA_NEG_Z_COIL_Y_CURRENT, + FINA_NEG_Z_COIL_Z_CURRENT, + FINA_NEG_Z_COIL_X_TEMPERATURE, + FINA_NEG_Z_COIL_Y_TEMPERATURE, + FINA_NEG_Z_COIL_Z_TEMPERATURE, +}; -class EngHkDataset: public StaticLocalDataSet { -public: +class EngHkDataset : public StaticLocalDataSet { + public: + EngHkDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, ENG_HK_DATA_SET_ID) {} - EngHkDataset(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, ENG_HK_DATA_SET_ID) { - } + EngHkDataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, ENG_HK_DATA_SET_ID)) {} - EngHkDataset(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, ENG_HK_DATA_SET_ID)) { - } - - lp_var_t digitalVoltageMv = lp_var_t(sid.objectId, DIGITAL_VOLTAGE_MV, - this); - lp_var_t analogVoltageMv = lp_var_t(sid.objectId, ANALOG_VOLTAGE_MV, this); - lp_var_t digitalCurrentmA = lp_var_t(sid.objectId, DIGITAL_CURRENT, this); - lp_var_t analogCurrentmA = lp_var_t(sid.objectId, ANALOG_CURRENT, this); - lp_var_t coilXCurrentmA = lp_var_t(sid.objectId, COIL_X_CURRENT, this); - lp_var_t coilYCurrentmA = lp_var_t(sid.objectId, COIL_Y_CURRENT, this); - lp_var_t coilZCurrentmA = lp_var_t(sid.objectId, COIL_Z_CURRENT, this); - /** All temperatures in [°C] */ - lp_var_t coilXTemperature = lp_var_t(sid.objectId, COIL_X_TEMPERATURE, - this); - lp_var_t coilYTemperature = lp_var_t(sid.objectId, COIL_Y_TEMPERATURE, - this); - lp_var_t coilZTemperature = lp_var_t(sid.objectId, COIL_Z_TEMPERATURE, - this); - lp_var_t mcuTemperature = lp_var_t(sid.objectId, MCU_TEMPERATURE, this); + lp_var_t digitalVoltageMv = lp_var_t(sid.objectId, DIGITAL_VOLTAGE_MV, this); + lp_var_t analogVoltageMv = lp_var_t(sid.objectId, ANALOG_VOLTAGE_MV, this); + lp_var_t digitalCurrentmA = lp_var_t(sid.objectId, DIGITAL_CURRENT, this); + lp_var_t analogCurrentmA = lp_var_t(sid.objectId, ANALOG_CURRENT, this); + lp_var_t coilXCurrentmA = lp_var_t(sid.objectId, COIL_X_CURRENT, this); + lp_var_t coilYCurrentmA = lp_var_t(sid.objectId, COIL_Y_CURRENT, this); + lp_var_t coilZCurrentmA = lp_var_t(sid.objectId, COIL_Z_CURRENT, this); + /** All temperatures in [°C] */ + lp_var_t coilXTemperature = lp_var_t(sid.objectId, COIL_X_TEMPERATURE, this); + lp_var_t coilYTemperature = lp_var_t(sid.objectId, COIL_Y_TEMPERATURE, this); + lp_var_t coilZTemperature = lp_var_t(sid.objectId, COIL_Z_TEMPERATURE, this); + lp_var_t mcuTemperature = lp_var_t(sid.objectId, MCU_TEMPERATURE, this); }; /** * @brief This dataset holds the last calibrated MTM measurement. */ -class CalibratedMtmMeasurementSet: public StaticLocalDataSet { -public: +class CalibratedMtmMeasurementSet : public StaticLocalDataSet { + public: + CalibratedMtmMeasurementSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, CAL_MTM_SET) {} - CalibratedMtmMeasurementSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, CAL_MTM_SET) { - } + CalibratedMtmMeasurementSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, CAL_MTM_SET)) {} - CalibratedMtmMeasurementSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, CAL_MTM_SET)) { - } - - /** The unit of all measurements is nT */ - lp_var_t mtmXnT = lp_var_t(sid.objectId, MTM_CAL_X, this); - lp_var_t mtmYnT = lp_var_t(sid.objectId, MTM_CAL_Y, this); - lp_var_t mtmZnT = lp_var_t(sid.objectId, MTM_CAL_Z, this); - /** 1 if coils were actuating during measurement otherwise 0 */ - lp_var_t coilActuationStatus = lp_var_t(sid.objectId, ACTUATION_CAL_STATUS, - this); + /** The unit of all measurements is nT */ + lp_var_t mtmXnT = lp_var_t(sid.objectId, MTM_CAL_X, this); + lp_var_t mtmYnT = lp_var_t(sid.objectId, MTM_CAL_Y, this); + lp_var_t mtmZnT = lp_var_t(sid.objectId, MTM_CAL_Z, this); + /** 1 if coils were actuating during measurement otherwise 0 */ + lp_var_t coilActuationStatus = + lp_var_t(sid.objectId, ACTUATION_CAL_STATUS, this); }; /** * @brief This dataset holds the raw MTM measurements. */ -class RawMtmMeasurementSet: public StaticLocalDataSet { -public: +class RawMtmMeasurementSet : public StaticLocalDataSet { + public: + RawMtmMeasurementSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, RAW_MTM_SET) {} - RawMtmMeasurementSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, RAW_MTM_SET) { - } + RawMtmMeasurementSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, RAW_MTM_SET)) {} - RawMtmMeasurementSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, RAW_MTM_SET)) { - } - - /** The unit of all measurements is nT */ - lp_var_t mtmXnT = lp_var_t(sid.objectId, MTM_RAW_X, this); - lp_var_t mtmYnT = lp_var_t(sid.objectId, MTM_RAW_Y, this); - lp_var_t mtmZnT = lp_var_t(sid.objectId, MTM_RAW_Z, this); - /** 1 if coils were actuating during measurement otherwise 0 */ - lp_var_t coilActuationStatus = lp_var_t(sid.objectId, ACTUATION_RAW_STATUS, - this); + /** The unit of all measurements is nT */ + lp_var_t mtmXnT = lp_var_t(sid.objectId, MTM_RAW_X, this); + lp_var_t mtmYnT = lp_var_t(sid.objectId, MTM_RAW_Y, this); + lp_var_t mtmZnT = lp_var_t(sid.objectId, MTM_RAW_Z, this); + /** 1 if coils were actuating during measurement otherwise 0 */ + lp_var_t coilActuationStatus = + lp_var_t(sid.objectId, ACTUATION_RAW_STATUS, this); }; - /** * @brief This class can be used to ease the generation of an action message commanding the * IMTQHandler to configure the magnettorquer with the desired dipoles. @@ -460,37 +442,32 @@ public: * the ipc store address in the action message. */ class CommandDipolePacket : public SerialLinkedListAdapter { -public: + public: + CommandDipolePacket() { setLinks(); } - CommandDipolePacket() { - setLinks(); - } - -private: - - /** - * @brief Constructor - * - * @param xDipole The dipole of the x coil in 10 ^ -4 * Am^2 - * @param yDipole The dipole of the y coil in 10 ^ -4 * Am^2 - * @param zDipole The dipole of the z coil in 10 ^ -4 * Am^2 - * @param duration The duration in milliseconds the dipole will be generated by the coils. - * When set to 0, the dipole will be generated until a new dipole actuation - * command is sent. - */ - CommandDipolePacket(uint16_t xDipole, uint16_t yDipole, uint16_t zDipole, uint16_t duration) : - xDipole(xDipole), yDipole(yDipole), zDipole(zDipole), duration(duration) { - } - void setLinks() { - setStart(&xDipole); - xDipole.setNext(&yDipole); - yDipole.setNext(&zDipole); - zDipole.setNext(&duration); - } - SerializeElement xDipole; - SerializeElement yDipole; - SerializeElement zDipole; - SerializeElement duration; + private: + /** + * @brief Constructor + * + * @param xDipole The dipole of the x coil in 10 ^ -4 * Am^2 + * @param yDipole The dipole of the y coil in 10 ^ -4 * Am^2 + * @param zDipole The dipole of the z coil in 10 ^ -4 * Am^2 + * @param duration The duration in milliseconds the dipole will be generated by the coils. + * When set to 0, the dipole will be generated until a new dipole actuation + * command is sent. + */ + CommandDipolePacket(uint16_t xDipole, uint16_t yDipole, uint16_t zDipole, uint16_t duration) + : xDipole(xDipole), yDipole(yDipole), zDipole(zDipole), duration(duration) {} + void setLinks() { + setStart(&xDipole); + xDipole.setNext(&yDipole); + yDipole.setNext(&zDipole); + zDipole.setNext(&duration); + } + SerializeElement xDipole; + SerializeElement yDipole; + SerializeElement zDipole; + SerializeElement duration; }; /** @@ -507,79 +484,67 @@ private: * 2. +X actuation * 3. All coils off (FINA step) */ -class PosXSelfTestSet: public StaticLocalDataSet { -public: +class PosXSelfTestSet : public StaticLocalDataSet { + public: + PosXSelfTestSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, IMTQ::POS_X_TEST_DATASET) {} - PosXSelfTestSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, IMTQ::POS_X_TEST_DATASET) { - } + PosXSelfTestSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, IMTQ::POS_X_TEST_DATASET)) {} - PosXSelfTestSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, IMTQ::POS_X_TEST_DATASET)) { - } + /** INIT block */ + lp_var_t initErr = lp_var_t(sid.objectId, INIT_POS_X_ERR, this); + lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_POS_X_RAW_MAG_X, this); + lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_POS_X_RAW_MAG_Y, this); + lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_POS_X_RAW_MAG_Z, this); + lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_POS_X_CAL_MAG_X, this); + lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_POS_X_CAL_MAG_Y, this); + lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_POS_X_CAL_MAG_Z, this); + lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_POS_X_COIL_X_CURRENT, this); + lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_POS_X_COIL_Y_CURRENT, this); + lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_POS_X_COIL_Z_CURRENT, this); + lp_var_t initCoilXTemperature = + lp_var_t(sid.objectId, INIT_POS_X_COIL_X_TEMPERATURE, this); + lp_var_t initCoilYTemperature = + lp_var_t(sid.objectId, INIT_POS_X_COIL_Y_TEMPERATURE, this); + lp_var_t initCoilZTemperature = + lp_var_t(sid.objectId, INIT_POS_X_COIL_Z_TEMPERATURE, this); - /** INIT block */ - lp_var_t initErr = lp_var_t(sid.objectId, INIT_POS_X_ERR, this); - lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_POS_X_RAW_MAG_X, this); - lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_POS_X_RAW_MAG_Y, this); - lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_POS_X_RAW_MAG_Z, this); - lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_POS_X_CAL_MAG_X, this); - lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_POS_X_CAL_MAG_Y, this); - lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_POS_X_CAL_MAG_Z, this); - lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_POS_X_COIL_X_CURRENT, - this); - lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_POS_X_COIL_Y_CURRENT, - this); - lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_POS_X_COIL_Z_CURRENT, - this); - lp_var_t initCoilXTemperature = lp_var_t(sid.objectId, - INIT_POS_X_COIL_X_TEMPERATURE, this); - lp_var_t initCoilYTemperature = lp_var_t(sid.objectId, - INIT_POS_X_COIL_Y_TEMPERATURE, this); - lp_var_t initCoilZTemperature = lp_var_t(sid.objectId, - INIT_POS_X_COIL_Z_TEMPERATURE, this); + /** +X block */ + lp_var_t err = lp_var_t(sid.objectId, POS_X_ERR, this); + lp_var_t rawMagX = lp_var_t(sid.objectId, POS_X_RAW_MAG_X, this); + lp_var_t rawMagY = lp_var_t(sid.objectId, POS_X_RAW_MAG_Y, this); + lp_var_t rawMagZ = lp_var_t(sid.objectId, POS_X_RAW_MAG_Z, this); + lp_var_t calMagX = lp_var_t(sid.objectId, POS_X_CAL_MAG_X, this); + lp_var_t calMagY = lp_var_t(sid.objectId, POS_X_CAL_MAG_Y, this); + lp_var_t calMagZ = lp_var_t(sid.objectId, POS_X_CAL_MAG_Z, this); + lp_var_t coilXCurrent = lp_var_t(sid.objectId, POS_X_COIL_X_CURRENT, this); + lp_var_t coilYCurrent = lp_var_t(sid.objectId, POS_X_COIL_Y_CURRENT, this); + lp_var_t coilZCurrent = lp_var_t(sid.objectId, POS_X_COIL_Z_CURRENT, this); + lp_var_t coilXTemperature = + lp_var_t(sid.objectId, POS_X_COIL_X_TEMPERATURE, this); + lp_var_t coilYTemperature = + lp_var_t(sid.objectId, POS_X_COIL_Y_TEMPERATURE, this); + lp_var_t coilZTemperature = + lp_var_t(sid.objectId, POS_X_COIL_Z_TEMPERATURE, this); - /** +X block */ - lp_var_t err = lp_var_t(sid.objectId, POS_X_ERR, this); - lp_var_t rawMagX = lp_var_t(sid.objectId, POS_X_RAW_MAG_X, this); - lp_var_t rawMagY = lp_var_t(sid.objectId, POS_X_RAW_MAG_Y, this); - lp_var_t rawMagZ = lp_var_t(sid.objectId, POS_X_RAW_MAG_Z, this); - lp_var_t calMagX = lp_var_t(sid.objectId, POS_X_CAL_MAG_X, this); - lp_var_t calMagY = lp_var_t(sid.objectId, POS_X_CAL_MAG_Y, this); - lp_var_t calMagZ = lp_var_t(sid.objectId, POS_X_CAL_MAG_Z, this); - lp_var_t coilXCurrent = lp_var_t(sid.objectId, POS_X_COIL_X_CURRENT, - this); - lp_var_t coilYCurrent = lp_var_t(sid.objectId, POS_X_COIL_Y_CURRENT, - this); - lp_var_t coilZCurrent = lp_var_t(sid.objectId, POS_X_COIL_Z_CURRENT, - this); - lp_var_t coilXTemperature = lp_var_t(sid.objectId, - POS_X_COIL_X_TEMPERATURE, this); - lp_var_t coilYTemperature = lp_var_t(sid.objectId, - POS_X_COIL_Y_TEMPERATURE, this); - lp_var_t coilZTemperature = lp_var_t(sid.objectId, - POS_X_COIL_Z_TEMPERATURE, this); - - /** FINA block */ - lp_var_t finaErr = lp_var_t(sid.objectId, FINA_POS_X_ERR, this); - lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_POS_X_RAW_MAG_X, this); - lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_POS_X_RAW_MAG_Y, this); - lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_POS_X_RAW_MAG_Z, this); - lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_POS_X_CAL_MAG_X, this); - lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_POS_X_CAL_MAG_Y, this); - lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_POS_X_CAL_MAG_Z, this); - lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_POS_X_COIL_X_CURRENT, - this); - lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_POS_X_COIL_Y_CURRENT, - this); - lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_POS_X_COIL_Z_CURRENT, - this); - lp_var_t finaCoilXTemperature = lp_var_t(sid.objectId, - FINA_POS_X_COIL_X_TEMPERATURE, this); - lp_var_t finaCoilYTemperature = lp_var_t(sid.objectId, - FINA_POS_X_COIL_Y_TEMPERATURE, this); - lp_var_t finaCoilZTemperature = lp_var_t(sid.objectId, - FINA_POS_X_COIL_Z_TEMPERATURE, this); + /** FINA block */ + lp_var_t finaErr = lp_var_t(sid.objectId, FINA_POS_X_ERR, this); + lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_POS_X_RAW_MAG_X, this); + lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_POS_X_RAW_MAG_Y, this); + lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_POS_X_RAW_MAG_Z, this); + lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_POS_X_CAL_MAG_X, this); + lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_POS_X_CAL_MAG_Y, this); + lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_POS_X_CAL_MAG_Z, this); + lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_POS_X_COIL_X_CURRENT, this); + lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_POS_X_COIL_Y_CURRENT, this); + lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_POS_X_COIL_Z_CURRENT, this); + lp_var_t finaCoilXTemperature = + lp_var_t(sid.objectId, FINA_POS_X_COIL_X_TEMPERATURE, this); + lp_var_t finaCoilYTemperature = + lp_var_t(sid.objectId, FINA_POS_X_COIL_Y_TEMPERATURE, this); + lp_var_t finaCoilZTemperature = + lp_var_t(sid.objectId, FINA_POS_X_COIL_Z_TEMPERATURE, this); }; /** @@ -596,82 +561,69 @@ public: * 2. -X actuation * 3. All coils off (FINA step) */ -class NegXSelfTestSet: public StaticLocalDataSet { -public: +class NegXSelfTestSet : public StaticLocalDataSet { + public: + NegXSelfTestSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, IMTQ::NEG_X_TEST_DATASET) {} - NegXSelfTestSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, IMTQ::NEG_X_TEST_DATASET) { - } + NegXSelfTestSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, IMTQ::NEG_X_TEST_DATASET)) {} - NegXSelfTestSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, IMTQ::NEG_X_TEST_DATASET)) { - } + /** INIT block */ + lp_var_t initErr = lp_var_t(sid.objectId, INIT_NEG_X_ERR, this); + lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_NEG_X_RAW_MAG_X, this); + lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_NEG_X_RAW_MAG_Y, this); + lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_NEG_X_RAW_MAG_Z, this); + lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_NEG_X_CAL_MAG_X, this); + lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_NEG_X_CAL_MAG_Y, this); + lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_NEG_X_CAL_MAG_Z, this); + lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_NEG_X_COIL_X_CURRENT, this); + lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_NEG_X_COIL_Y_CURRENT, this); + lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_NEG_X_COIL_Z_CURRENT, this); + lp_var_t initCoilXTemperature = + lp_var_t(sid.objectId, INIT_NEG_X_COIL_X_TEMPERATURE, this); + lp_var_t initCoilYTemperature = + lp_var_t(sid.objectId, INIT_NEG_X_COIL_Y_TEMPERATURE, this); + lp_var_t initCoilZTemperature = + lp_var_t(sid.objectId, INIT_NEG_X_COIL_Z_TEMPERATURE, this); - /** INIT block */ - lp_var_t initErr = lp_var_t(sid.objectId, INIT_NEG_X_ERR, this); - lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_NEG_X_RAW_MAG_X, this); - lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_NEG_X_RAW_MAG_Y, this); - lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_NEG_X_RAW_MAG_Z, this); - lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_NEG_X_CAL_MAG_X, this); - lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_NEG_X_CAL_MAG_Y, this); - lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_NEG_X_CAL_MAG_Z, this); - lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_NEG_X_COIL_X_CURRENT, - this); - lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_NEG_X_COIL_Y_CURRENT, - this); - lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_NEG_X_COIL_Z_CURRENT, - this); - lp_var_t initCoilXTemperature = lp_var_t(sid.objectId, - INIT_NEG_X_COIL_X_TEMPERATURE, this); - lp_var_t initCoilYTemperature = lp_var_t(sid.objectId, - INIT_NEG_X_COIL_Y_TEMPERATURE, this); - lp_var_t initCoilZTemperature = lp_var_t(sid.objectId, - INIT_NEG_X_COIL_Z_TEMPERATURE, this); + /** -X block */ + lp_var_t err = lp_var_t(sid.objectId, NEG_X_ERR, this); + lp_var_t rawMagX = lp_var_t(sid.objectId, NEG_X_RAW_MAG_X, this); + lp_var_t rawMagY = lp_var_t(sid.objectId, NEG_X_RAW_MAG_Y, this); + lp_var_t rawMagZ = lp_var_t(sid.objectId, NEG_X_RAW_MAG_Z, this); + lp_var_t calMagX = lp_var_t(sid.objectId, NEG_X_CAL_MAG_X, this); + lp_var_t calMagY = lp_var_t(sid.objectId, NEG_X_CAL_MAG_Y, this); + lp_var_t calMagZ = lp_var_t(sid.objectId, NEG_X_CAL_MAG_Z, this); + lp_var_t coilXCurrent = lp_var_t(sid.objectId, NEG_X_COIL_X_CURRENT, this); + lp_var_t coilYCurrent = lp_var_t(sid.objectId, NEG_X_COIL_Y_CURRENT, this); + lp_var_t coilZCurrent = lp_var_t(sid.objectId, NEG_X_COIL_Z_CURRENT, this); + lp_var_t coilXTemperature = + lp_var_t(sid.objectId, NEG_X_COIL_X_TEMPERATURE, this); + lp_var_t coilYTemperature = + lp_var_t(sid.objectId, NEG_X_COIL_Y_TEMPERATURE, this); + lp_var_t coilZTemperature = + lp_var_t(sid.objectId, NEG_X_COIL_Z_TEMPERATURE, this); - /** -X block */ - lp_var_t err = lp_var_t(sid.objectId, NEG_X_ERR, this); - lp_var_t rawMagX = lp_var_t(sid.objectId, NEG_X_RAW_MAG_X, this); - lp_var_t rawMagY = lp_var_t(sid.objectId, NEG_X_RAW_MAG_Y, this); - lp_var_t rawMagZ = lp_var_t(sid.objectId, NEG_X_RAW_MAG_Z, this); - lp_var_t calMagX = lp_var_t(sid.objectId, NEG_X_CAL_MAG_X, this); - lp_var_t calMagY = lp_var_t(sid.objectId, NEG_X_CAL_MAG_Y, this); - lp_var_t calMagZ = lp_var_t(sid.objectId, NEG_X_CAL_MAG_Z, this); - lp_var_t coilXCurrent = lp_var_t(sid.objectId, NEG_X_COIL_X_CURRENT, - this); - lp_var_t coilYCurrent = lp_var_t(sid.objectId, NEG_X_COIL_Y_CURRENT, - this); - lp_var_t coilZCurrent = lp_var_t(sid.objectId, NEG_X_COIL_Z_CURRENT, - this); - lp_var_t coilXTemperature = lp_var_t(sid.objectId, - NEG_X_COIL_X_TEMPERATURE, this); - lp_var_t coilYTemperature = lp_var_t(sid.objectId, - NEG_X_COIL_Y_TEMPERATURE, this); - lp_var_t coilZTemperature = lp_var_t(sid.objectId, - NEG_X_COIL_Z_TEMPERATURE, this); - - /** FINA block */ - lp_var_t finaErr = lp_var_t(sid.objectId, FINA_NEG_X_ERR, this); - lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_NEG_X_RAW_MAG_X, this); - lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_NEG_X_RAW_MAG_Y, this); - lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_NEG_X_RAW_MAG_Z, this); - lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_NEG_X_CAL_MAG_X, this); - lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_NEG_X_CAL_MAG_Y, this); - lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_NEG_X_CAL_MAG_Z, this); - lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_NEG_X_COIL_X_CURRENT, - this); - lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_NEG_X_COIL_Y_CURRENT, - this); - lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_NEG_X_COIL_Z_CURRENT, - this); - lp_var_t finaCoilXTemperature = lp_var_t(sid.objectId, - FINA_NEG_X_COIL_X_TEMPERATURE, this); - lp_var_t finaCoilYTemperature = lp_var_t(sid.objectId, - FINA_NEG_X_COIL_Y_TEMPERATURE, this); - lp_var_t finaCoilZTemperature = lp_var_t(sid.objectId, - FINA_NEG_X_COIL_Z_TEMPERATURE, this); + /** FINA block */ + lp_var_t finaErr = lp_var_t(sid.objectId, FINA_NEG_X_ERR, this); + lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_NEG_X_RAW_MAG_X, this); + lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_NEG_X_RAW_MAG_Y, this); + lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_NEG_X_RAW_MAG_Z, this); + lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_NEG_X_CAL_MAG_X, this); + lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_NEG_X_CAL_MAG_Y, this); + lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_NEG_X_CAL_MAG_Z, this); + lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_NEG_X_COIL_X_CURRENT, this); + lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_NEG_X_COIL_Y_CURRENT, this); + lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_NEG_X_COIL_Z_CURRENT, this); + lp_var_t finaCoilXTemperature = + lp_var_t(sid.objectId, FINA_NEG_X_COIL_X_TEMPERATURE, this); + lp_var_t finaCoilYTemperature = + lp_var_t(sid.objectId, FINA_NEG_X_COIL_Y_TEMPERATURE, this); + lp_var_t finaCoilZTemperature = + lp_var_t(sid.objectId, FINA_NEG_X_COIL_Z_TEMPERATURE, this); }; - /** * @brief This dataset can be used to store the self test results of the +Y self test. * @@ -686,79 +638,67 @@ public: * 2. +Y actuation * 3. All coils off (FINA step) */ -class PosYSelfTestSet: public StaticLocalDataSet { -public: +class PosYSelfTestSet : public StaticLocalDataSet { + public: + PosYSelfTestSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, IMTQ::POS_Y_TEST_DATASET) {} - PosYSelfTestSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, IMTQ::POS_Y_TEST_DATASET) { - } + PosYSelfTestSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, IMTQ::POS_Y_TEST_DATASET)) {} - PosYSelfTestSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, IMTQ::POS_Y_TEST_DATASET)) { - } + /** INIT block */ + lp_var_t initErr = lp_var_t(sid.objectId, INIT_POS_Y_ERR, this); + lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_POS_Y_RAW_MAG_X, this); + lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_POS_Y_RAW_MAG_Y, this); + lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_POS_Y_RAW_MAG_Z, this); + lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_POS_Y_CAL_MAG_X, this); + lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_POS_Y_CAL_MAG_Y, this); + lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_POS_Y_CAL_MAG_Z, this); + lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_POS_Y_COIL_X_CURRENT, this); + lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_POS_Y_COIL_Y_CURRENT, this); + lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_POS_Y_COIL_Z_CURRENT, this); + lp_var_t initCoilXTemperature = + lp_var_t(sid.objectId, INIT_POS_Y_COIL_X_TEMPERATURE, this); + lp_var_t initCoilYTemperature = + lp_var_t(sid.objectId, INIT_POS_Y_COIL_Y_TEMPERATURE, this); + lp_var_t initCoilZTemperature = + lp_var_t(sid.objectId, INIT_POS_Y_COIL_Z_TEMPERATURE, this); - /** INIT block */ - lp_var_t initErr = lp_var_t(sid.objectId, INIT_POS_Y_ERR, this); - lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_POS_Y_RAW_MAG_X, this); - lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_POS_Y_RAW_MAG_Y, this); - lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_POS_Y_RAW_MAG_Z, this); - lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_POS_Y_CAL_MAG_X, this); - lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_POS_Y_CAL_MAG_Y, this); - lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_POS_Y_CAL_MAG_Z, this); - lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_POS_Y_COIL_X_CURRENT, - this); - lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_POS_Y_COIL_Y_CURRENT, - this); - lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_POS_Y_COIL_Z_CURRENT, - this); - lp_var_t initCoilXTemperature = lp_var_t(sid.objectId, - INIT_POS_Y_COIL_X_TEMPERATURE, this); - lp_var_t initCoilYTemperature = lp_var_t(sid.objectId, - INIT_POS_Y_COIL_Y_TEMPERATURE, this); - lp_var_t initCoilZTemperature = lp_var_t(sid.objectId, - INIT_POS_Y_COIL_Z_TEMPERATURE, this); + /** +Y block */ + lp_var_t err = lp_var_t(sid.objectId, POS_Y_ERR, this); + lp_var_t rawMagX = lp_var_t(sid.objectId, POS_Y_RAW_MAG_X, this); + lp_var_t rawMagY = lp_var_t(sid.objectId, POS_Y_RAW_MAG_Y, this); + lp_var_t rawMagZ = lp_var_t(sid.objectId, POS_Y_RAW_MAG_Z, this); + lp_var_t calMagX = lp_var_t(sid.objectId, POS_Y_CAL_MAG_X, this); + lp_var_t calMagY = lp_var_t(sid.objectId, POS_Y_CAL_MAG_Y, this); + lp_var_t calMagZ = lp_var_t(sid.objectId, POS_Y_CAL_MAG_Z, this); + lp_var_t coilXCurrent = lp_var_t(sid.objectId, POS_Y_COIL_X_CURRENT, this); + lp_var_t coilYCurrent = lp_var_t(sid.objectId, POS_Y_COIL_Y_CURRENT, this); + lp_var_t coilZCurrent = lp_var_t(sid.objectId, POS_Y_COIL_Z_CURRENT, this); + lp_var_t coilXTemperature = + lp_var_t(sid.objectId, POS_Y_COIL_X_TEMPERATURE, this); + lp_var_t coilYTemperature = + lp_var_t(sid.objectId, POS_Y_COIL_Y_TEMPERATURE, this); + lp_var_t coilZTemperature = + lp_var_t(sid.objectId, POS_Y_COIL_Z_TEMPERATURE, this); - /** +Y block */ - lp_var_t err = lp_var_t(sid.objectId, POS_Y_ERR, this); - lp_var_t rawMagX = lp_var_t(sid.objectId, POS_Y_RAW_MAG_X, this); - lp_var_t rawMagY = lp_var_t(sid.objectId, POS_Y_RAW_MAG_Y, this); - lp_var_t rawMagZ = lp_var_t(sid.objectId, POS_Y_RAW_MAG_Z, this); - lp_var_t calMagX = lp_var_t(sid.objectId, POS_Y_CAL_MAG_X, this); - lp_var_t calMagY = lp_var_t(sid.objectId, POS_Y_CAL_MAG_Y, this); - lp_var_t calMagZ = lp_var_t(sid.objectId, POS_Y_CAL_MAG_Z, this); - lp_var_t coilXCurrent = lp_var_t(sid.objectId, POS_Y_COIL_X_CURRENT, - this); - lp_var_t coilYCurrent = lp_var_t(sid.objectId, POS_Y_COIL_Y_CURRENT, - this); - lp_var_t coilZCurrent = lp_var_t(sid.objectId, POS_Y_COIL_Z_CURRENT, - this); - lp_var_t coilXTemperature = lp_var_t(sid.objectId, - POS_Y_COIL_X_TEMPERATURE, this); - lp_var_t coilYTemperature = lp_var_t(sid.objectId, - POS_Y_COIL_Y_TEMPERATURE, this); - lp_var_t coilZTemperature = lp_var_t(sid.objectId, - POS_Y_COIL_Z_TEMPERATURE, this); - - /** FINA block */ - lp_var_t finaErr = lp_var_t(sid.objectId, FINA_POS_Y_ERR, this); - lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_POS_Y_RAW_MAG_X, this); - lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_POS_Y_RAW_MAG_Y, this); - lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_POS_Y_RAW_MAG_Z, this); - lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_POS_Y_CAL_MAG_X, this); - lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_POS_Y_CAL_MAG_Y, this); - lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_POS_Y_CAL_MAG_Z, this); - lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_POS_Y_COIL_X_CURRENT, - this); - lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_POS_Y_COIL_Y_CURRENT, - this); - lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_POS_Y_COIL_Z_CURRENT, - this); - lp_var_t finaCoilXTemperature = lp_var_t(sid.objectId, - FINA_POS_Y_COIL_X_TEMPERATURE, this); - lp_var_t finaCoilYTemperature = lp_var_t(sid.objectId, - FINA_POS_Y_COIL_Y_TEMPERATURE, this); - lp_var_t finaCoilZTemperature = lp_var_t(sid.objectId, - FINA_POS_Y_COIL_Z_TEMPERATURE, this); + /** FINA block */ + lp_var_t finaErr = lp_var_t(sid.objectId, FINA_POS_Y_ERR, this); + lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_POS_Y_RAW_MAG_X, this); + lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_POS_Y_RAW_MAG_Y, this); + lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_POS_Y_RAW_MAG_Z, this); + lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_POS_Y_CAL_MAG_X, this); + lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_POS_Y_CAL_MAG_Y, this); + lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_POS_Y_CAL_MAG_Z, this); + lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_POS_Y_COIL_X_CURRENT, this); + lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_POS_Y_COIL_Y_CURRENT, this); + lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_POS_Y_COIL_Z_CURRENT, this); + lp_var_t finaCoilXTemperature = + lp_var_t(sid.objectId, FINA_POS_Y_COIL_X_TEMPERATURE, this); + lp_var_t finaCoilYTemperature = + lp_var_t(sid.objectId, FINA_POS_Y_COIL_Y_TEMPERATURE, this); + lp_var_t finaCoilZTemperature = + lp_var_t(sid.objectId, FINA_POS_Y_COIL_Z_TEMPERATURE, this); }; /** @@ -775,79 +715,67 @@ public: * 2. -Y actuation * 3. All coils off (FINA step) */ -class NegYSelfTestSet: public StaticLocalDataSet { -public: +class NegYSelfTestSet : public StaticLocalDataSet { + public: + NegYSelfTestSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, IMTQ::NEG_Y_TEST_DATASET) {} - NegYSelfTestSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, IMTQ::NEG_Y_TEST_DATASET) { - } + NegYSelfTestSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, IMTQ::NEG_Y_TEST_DATASET)) {} - NegYSelfTestSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, IMTQ::NEG_Y_TEST_DATASET)) { - } + /** INIT block */ + lp_var_t initErr = lp_var_t(sid.objectId, INIT_NEG_Y_ERR, this); + lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_NEG_Y_RAW_MAG_X, this); + lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_NEG_Y_RAW_MAG_Y, this); + lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_NEG_Y_RAW_MAG_Z, this); + lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_NEG_Y_CAL_MAG_X, this); + lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_NEG_Y_CAL_MAG_Y, this); + lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_NEG_Y_CAL_MAG_Z, this); + lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_NEG_Y_COIL_X_CURRENT, this); + lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_NEG_Y_COIL_Y_CURRENT, this); + lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_NEG_Y_COIL_Z_CURRENT, this); + lp_var_t initCoilXTemperature = + lp_var_t(sid.objectId, INIT_NEG_Y_COIL_X_TEMPERATURE, this); + lp_var_t initCoilYTemperature = + lp_var_t(sid.objectId, INIT_NEG_Y_COIL_Y_TEMPERATURE, this); + lp_var_t initCoilZTemperature = + lp_var_t(sid.objectId, INIT_NEG_Y_COIL_Z_TEMPERATURE, this); - /** INIT block */ - lp_var_t initErr = lp_var_t(sid.objectId, INIT_NEG_Y_ERR, this); - lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_NEG_Y_RAW_MAG_X, this); - lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_NEG_Y_RAW_MAG_Y, this); - lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_NEG_Y_RAW_MAG_Z, this); - lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_NEG_Y_CAL_MAG_X, this); - lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_NEG_Y_CAL_MAG_Y, this); - lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_NEG_Y_CAL_MAG_Z, this); - lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_NEG_Y_COIL_X_CURRENT, - this); - lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_NEG_Y_COIL_Y_CURRENT, - this); - lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_NEG_Y_COIL_Z_CURRENT, - this); - lp_var_t initCoilXTemperature = lp_var_t(sid.objectId, - INIT_NEG_Y_COIL_X_TEMPERATURE, this); - lp_var_t initCoilYTemperature = lp_var_t(sid.objectId, - INIT_NEG_Y_COIL_Y_TEMPERATURE, this); - lp_var_t initCoilZTemperature = lp_var_t(sid.objectId, - INIT_NEG_Y_COIL_Z_TEMPERATURE, this); + /** -Y block */ + lp_var_t err = lp_var_t(sid.objectId, NEG_Y_ERR, this); + lp_var_t rawMagX = lp_var_t(sid.objectId, NEG_Y_RAW_MAG_X, this); + lp_var_t rawMagY = lp_var_t(sid.objectId, NEG_Y_RAW_MAG_Y, this); + lp_var_t rawMagZ = lp_var_t(sid.objectId, NEG_Y_RAW_MAG_Z, this); + lp_var_t calMagX = lp_var_t(sid.objectId, NEG_Y_CAL_MAG_X, this); + lp_var_t calMagY = lp_var_t(sid.objectId, NEG_Y_CAL_MAG_Y, this); + lp_var_t calMagZ = lp_var_t(sid.objectId, NEG_Y_CAL_MAG_Z, this); + lp_var_t coilXCurrent = lp_var_t(sid.objectId, NEG_Y_COIL_X_CURRENT, this); + lp_var_t coilYCurrent = lp_var_t(sid.objectId, NEG_Y_COIL_Y_CURRENT, this); + lp_var_t coilZCurrent = lp_var_t(sid.objectId, NEG_Y_COIL_Z_CURRENT, this); + lp_var_t coilXTemperature = + lp_var_t(sid.objectId, NEG_Y_COIL_X_TEMPERATURE, this); + lp_var_t coilYTemperature = + lp_var_t(sid.objectId, NEG_Y_COIL_Y_TEMPERATURE, this); + lp_var_t coilZTemperature = + lp_var_t(sid.objectId, NEG_Y_COIL_Z_TEMPERATURE, this); - /** -Y block */ - lp_var_t err = lp_var_t(sid.objectId, NEG_Y_ERR, this); - lp_var_t rawMagX = lp_var_t(sid.objectId, NEG_Y_RAW_MAG_X, this); - lp_var_t rawMagY = lp_var_t(sid.objectId, NEG_Y_RAW_MAG_Y, this); - lp_var_t rawMagZ = lp_var_t(sid.objectId, NEG_Y_RAW_MAG_Z, this); - lp_var_t calMagX = lp_var_t(sid.objectId, NEG_Y_CAL_MAG_X, this); - lp_var_t calMagY = lp_var_t(sid.objectId, NEG_Y_CAL_MAG_Y, this); - lp_var_t calMagZ = lp_var_t(sid.objectId, NEG_Y_CAL_MAG_Z, this); - lp_var_t coilXCurrent = lp_var_t(sid.objectId, NEG_Y_COIL_X_CURRENT, - this); - lp_var_t coilYCurrent = lp_var_t(sid.objectId, NEG_Y_COIL_Y_CURRENT, - this); - lp_var_t coilZCurrent = lp_var_t(sid.objectId, NEG_Y_COIL_Z_CURRENT, - this); - lp_var_t coilXTemperature = lp_var_t(sid.objectId, - NEG_Y_COIL_X_TEMPERATURE, this); - lp_var_t coilYTemperature = lp_var_t(sid.objectId, - NEG_Y_COIL_Y_TEMPERATURE, this); - lp_var_t coilZTemperature = lp_var_t(sid.objectId, - NEG_Y_COIL_Z_TEMPERATURE, this); - - /** FINA block */ - lp_var_t finaErr = lp_var_t(sid.objectId, FINA_NEG_Y_ERR, this); - lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_NEG_Y_RAW_MAG_X, this); - lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_NEG_Y_RAW_MAG_Y, this); - lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_NEG_Y_RAW_MAG_Z, this); - lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_NEG_Y_CAL_MAG_X, this); - lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_NEG_Y_CAL_MAG_Y, this); - lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_NEG_Y_CAL_MAG_Z, this); - lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_NEG_Y_COIL_X_CURRENT, - this); - lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_NEG_Y_COIL_Y_CURRENT, - this); - lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_NEG_Y_COIL_Z_CURRENT, - this); - lp_var_t finaCoilXTemperature = lp_var_t(sid.objectId, - FINA_NEG_Y_COIL_X_TEMPERATURE, this); - lp_var_t finaCoilYTemperature = lp_var_t(sid.objectId, - FINA_NEG_Y_COIL_Y_TEMPERATURE, this); - lp_var_t finaCoilZTemperature = lp_var_t(sid.objectId, - FINA_NEG_Y_COIL_Z_TEMPERATURE, this); + /** FINA block */ + lp_var_t finaErr = lp_var_t(sid.objectId, FINA_NEG_Y_ERR, this); + lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_NEG_Y_RAW_MAG_X, this); + lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_NEG_Y_RAW_MAG_Y, this); + lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_NEG_Y_RAW_MAG_Z, this); + lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_NEG_Y_CAL_MAG_X, this); + lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_NEG_Y_CAL_MAG_Y, this); + lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_NEG_Y_CAL_MAG_Z, this); + lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_NEG_Y_COIL_X_CURRENT, this); + lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_NEG_Y_COIL_Y_CURRENT, this); + lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_NEG_Y_COIL_Z_CURRENT, this); + lp_var_t finaCoilXTemperature = + lp_var_t(sid.objectId, FINA_NEG_Y_COIL_X_TEMPERATURE, this); + lp_var_t finaCoilYTemperature = + lp_var_t(sid.objectId, FINA_NEG_Y_COIL_Y_TEMPERATURE, this); + lp_var_t finaCoilZTemperature = + lp_var_t(sid.objectId, FINA_NEG_Y_COIL_Z_TEMPERATURE, this); }; /** @@ -864,79 +792,67 @@ public: * 2. +Z actuation * 3. All coils off (FINA step) */ -class PosZSelfTestSet: public StaticLocalDataSet { -public: +class PosZSelfTestSet : public StaticLocalDataSet { + public: + PosZSelfTestSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, IMTQ::POS_Z_TEST_DATASET) {} - PosZSelfTestSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, IMTQ::POS_Z_TEST_DATASET) { - } + PosZSelfTestSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, IMTQ::POS_Z_TEST_DATASET)) {} - PosZSelfTestSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, IMTQ::POS_Z_TEST_DATASET)) { - } + /** INIT block */ + lp_var_t initErr = lp_var_t(sid.objectId, INIT_POS_Z_ERR, this); + lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_POS_Z_RAW_MAG_X, this); + lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_POS_Z_RAW_MAG_Y, this); + lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_POS_Z_RAW_MAG_Z, this); + lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_POS_Z_CAL_MAG_X, this); + lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_POS_Z_CAL_MAG_Y, this); + lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_POS_Z_CAL_MAG_Z, this); + lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_POS_Z_COIL_X_CURRENT, this); + lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_POS_Z_COIL_Y_CURRENT, this); + lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_POS_Z_COIL_Z_CURRENT, this); + lp_var_t initCoilXTemperature = + lp_var_t(sid.objectId, INIT_POS_Z_COIL_X_TEMPERATURE, this); + lp_var_t initCoilYTemperature = + lp_var_t(sid.objectId, INIT_POS_Z_COIL_Y_TEMPERATURE, this); + lp_var_t initCoilZTemperature = + lp_var_t(sid.objectId, INIT_POS_Z_COIL_Z_TEMPERATURE, this); - /** INIT block */ - lp_var_t initErr = lp_var_t(sid.objectId, INIT_POS_Z_ERR, this); - lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_POS_Z_RAW_MAG_X, this); - lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_POS_Z_RAW_MAG_Y, this); - lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_POS_Z_RAW_MAG_Z, this); - lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_POS_Z_CAL_MAG_X, this); - lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_POS_Z_CAL_MAG_Y, this); - lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_POS_Z_CAL_MAG_Z, this); - lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_POS_Z_COIL_X_CURRENT, - this); - lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_POS_Z_COIL_Y_CURRENT, - this); - lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_POS_Z_COIL_Z_CURRENT, - this); - lp_var_t initCoilXTemperature = lp_var_t(sid.objectId, - INIT_POS_Z_COIL_X_TEMPERATURE, this); - lp_var_t initCoilYTemperature = lp_var_t(sid.objectId, - INIT_POS_Z_COIL_Y_TEMPERATURE, this); - lp_var_t initCoilZTemperature = lp_var_t(sid.objectId, - INIT_POS_Z_COIL_Z_TEMPERATURE, this); + /** +Z block */ + lp_var_t err = lp_var_t(sid.objectId, POS_Z_ERR, this); + lp_var_t rawMagX = lp_var_t(sid.objectId, POS_Z_RAW_MAG_X, this); + lp_var_t rawMagY = lp_var_t(sid.objectId, POS_Z_RAW_MAG_Y, this); + lp_var_t rawMagZ = lp_var_t(sid.objectId, POS_Z_RAW_MAG_Z, this); + lp_var_t calMagX = lp_var_t(sid.objectId, POS_Z_CAL_MAG_X, this); + lp_var_t calMagY = lp_var_t(sid.objectId, POS_Z_CAL_MAG_Y, this); + lp_var_t calMagZ = lp_var_t(sid.objectId, POS_Z_CAL_MAG_Z, this); + lp_var_t coilXCurrent = lp_var_t(sid.objectId, POS_Z_COIL_X_CURRENT, this); + lp_var_t coilYCurrent = lp_var_t(sid.objectId, POS_Z_COIL_Y_CURRENT, this); + lp_var_t coilZCurrent = lp_var_t(sid.objectId, POS_Z_COIL_Z_CURRENT, this); + lp_var_t coilXTemperature = + lp_var_t(sid.objectId, POS_Z_COIL_X_TEMPERATURE, this); + lp_var_t coilYTemperature = + lp_var_t(sid.objectId, POS_Z_COIL_Y_TEMPERATURE, this); + lp_var_t coilZTemperature = + lp_var_t(sid.objectId, POS_Z_COIL_Z_TEMPERATURE, this); - /** +Z block */ - lp_var_t err = lp_var_t(sid.objectId, POS_Z_ERR, this); - lp_var_t rawMagX = lp_var_t(sid.objectId, POS_Z_RAW_MAG_X, this); - lp_var_t rawMagY = lp_var_t(sid.objectId, POS_Z_RAW_MAG_Y, this); - lp_var_t rawMagZ = lp_var_t(sid.objectId, POS_Z_RAW_MAG_Z, this); - lp_var_t calMagX = lp_var_t(sid.objectId, POS_Z_CAL_MAG_X, this); - lp_var_t calMagY = lp_var_t(sid.objectId, POS_Z_CAL_MAG_Y, this); - lp_var_t calMagZ = lp_var_t(sid.objectId, POS_Z_CAL_MAG_Z, this); - lp_var_t coilXCurrent = lp_var_t(sid.objectId, POS_Z_COIL_X_CURRENT, - this); - lp_var_t coilYCurrent = lp_var_t(sid.objectId, POS_Z_COIL_Y_CURRENT, - this); - lp_var_t coilZCurrent = lp_var_t(sid.objectId, POS_Z_COIL_Z_CURRENT, - this); - lp_var_t coilXTemperature = lp_var_t(sid.objectId, - POS_Z_COIL_X_TEMPERATURE, this); - lp_var_t coilYTemperature = lp_var_t(sid.objectId, - POS_Z_COIL_Y_TEMPERATURE, this); - lp_var_t coilZTemperature = lp_var_t(sid.objectId, - POS_Z_COIL_Z_TEMPERATURE, this); - - /** FINA block */ - lp_var_t finaErr = lp_var_t(sid.objectId, FINA_POS_Z_ERR, this); - lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_POS_Z_RAW_MAG_X, this); - lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_POS_Z_RAW_MAG_Y, this); - lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_POS_Z_RAW_MAG_Z, this); - lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_POS_Z_CAL_MAG_X, this); - lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_POS_Z_CAL_MAG_Y, this); - lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_POS_Z_CAL_MAG_Z, this); - lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_POS_Z_COIL_X_CURRENT, - this); - lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_POS_Z_COIL_Y_CURRENT, - this); - lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_POS_Z_COIL_Z_CURRENT, - this); - lp_var_t finaCoilXTemperature = lp_var_t(sid.objectId, - FINA_POS_Z_COIL_X_TEMPERATURE, this); - lp_var_t finaCoilYTemperature = lp_var_t(sid.objectId, - FINA_POS_Z_COIL_Y_TEMPERATURE, this); - lp_var_t finaCoilZTemperature = lp_var_t(sid.objectId, - FINA_POS_Z_COIL_Z_TEMPERATURE, this); + /** FINA block */ + lp_var_t finaErr = lp_var_t(sid.objectId, FINA_POS_Z_ERR, this); + lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_POS_Z_RAW_MAG_X, this); + lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_POS_Z_RAW_MAG_Y, this); + lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_POS_Z_RAW_MAG_Z, this); + lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_POS_Z_CAL_MAG_X, this); + lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_POS_Z_CAL_MAG_Y, this); + lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_POS_Z_CAL_MAG_Z, this); + lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_POS_Z_COIL_X_CURRENT, this); + lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_POS_Z_COIL_Y_CURRENT, this); + lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_POS_Z_COIL_Z_CURRENT, this); + lp_var_t finaCoilXTemperature = + lp_var_t(sid.objectId, FINA_POS_Z_COIL_X_TEMPERATURE, this); + lp_var_t finaCoilYTemperature = + lp_var_t(sid.objectId, FINA_POS_Z_COIL_Y_TEMPERATURE, this); + lp_var_t finaCoilZTemperature = + lp_var_t(sid.objectId, FINA_POS_Z_COIL_Z_TEMPERATURE, this); }; /** @@ -953,82 +869,69 @@ public: * 2. -Z actuation * 3. All coils off (FINA step) */ -class NegZSelfTestSet: public StaticLocalDataSet { -public: +class NegZSelfTestSet : public StaticLocalDataSet { + public: + NegZSelfTestSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, IMTQ::NEG_Z_TEST_DATASET) {} - NegZSelfTestSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, IMTQ::NEG_Z_TEST_DATASET) { - } + NegZSelfTestSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, IMTQ::NEG_Z_TEST_DATASET)) {} - NegZSelfTestSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, IMTQ::NEG_Z_TEST_DATASET)) { - } + /** INIT block */ + lp_var_t initErr = lp_var_t(sid.objectId, INIT_NEG_Z_ERR, this); + lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_NEG_Z_RAW_MAG_X, this); + lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_NEG_Z_RAW_MAG_Y, this); + lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_NEG_Z_RAW_MAG_Z, this); + lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_NEG_Z_CAL_MAG_X, this); + lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_NEG_Z_CAL_MAG_Y, this); + lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_NEG_Z_CAL_MAG_Z, this); + lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_NEG_Z_COIL_X_CURRENT, this); + lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_NEG_Z_COIL_Y_CURRENT, this); + lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_NEG_Z_COIL_Z_CURRENT, this); + lp_var_t initCoilXTemperature = + lp_var_t(sid.objectId, INIT_NEG_Z_COIL_X_TEMPERATURE, this); + lp_var_t initCoilYTemperature = + lp_var_t(sid.objectId, INIT_NEG_Z_COIL_Y_TEMPERATURE, this); + lp_var_t initCoilZTemperature = + lp_var_t(sid.objectId, INIT_NEG_Z_COIL_Z_TEMPERATURE, this); - /** INIT block */ - lp_var_t initErr = lp_var_t(sid.objectId, INIT_NEG_Z_ERR, this); - lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_NEG_Z_RAW_MAG_X, this); - lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_NEG_Z_RAW_MAG_Y, this); - lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_NEG_Z_RAW_MAG_Z, this); - lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_NEG_Z_CAL_MAG_X, this); - lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_NEG_Z_CAL_MAG_Y, this); - lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_NEG_Z_CAL_MAG_Z, this); - lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_NEG_Z_COIL_X_CURRENT, - this); - lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_NEG_Z_COIL_Y_CURRENT, - this); - lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_NEG_Z_COIL_Z_CURRENT, - this); - lp_var_t initCoilXTemperature = lp_var_t(sid.objectId, - INIT_NEG_Z_COIL_X_TEMPERATURE, this); - lp_var_t initCoilYTemperature = lp_var_t(sid.objectId, - INIT_NEG_Z_COIL_Y_TEMPERATURE, this); - lp_var_t initCoilZTemperature = lp_var_t(sid.objectId, - INIT_NEG_Z_COIL_Z_TEMPERATURE, this); + /** +Z block */ + lp_var_t err = lp_var_t(sid.objectId, NEG_Z_ERR, this); + lp_var_t rawMagX = lp_var_t(sid.objectId, NEG_Z_RAW_MAG_X, this); + lp_var_t rawMagY = lp_var_t(sid.objectId, NEG_Z_RAW_MAG_Y, this); + lp_var_t rawMagZ = lp_var_t(sid.objectId, NEG_Z_RAW_MAG_Z, this); + lp_var_t calMagX = lp_var_t(sid.objectId, NEG_Z_CAL_MAG_X, this); + lp_var_t calMagY = lp_var_t(sid.objectId, NEG_Z_CAL_MAG_Y, this); + lp_var_t calMagZ = lp_var_t(sid.objectId, NEG_Z_CAL_MAG_Z, this); + lp_var_t coilXCurrent = lp_var_t(sid.objectId, NEG_Z_COIL_X_CURRENT, this); + lp_var_t coilYCurrent = lp_var_t(sid.objectId, NEG_Z_COIL_Y_CURRENT, this); + lp_var_t coilZCurrent = lp_var_t(sid.objectId, NEG_Z_COIL_Z_CURRENT, this); + lp_var_t coilXTemperature = + lp_var_t(sid.objectId, NEG_Z_COIL_X_TEMPERATURE, this); + lp_var_t coilYTemperature = + lp_var_t(sid.objectId, NEG_Z_COIL_Y_TEMPERATURE, this); + lp_var_t coilZTemperature = + lp_var_t(sid.objectId, NEG_Z_COIL_Z_TEMPERATURE, this); - /** +Z block */ - lp_var_t err = lp_var_t(sid.objectId, NEG_Z_ERR, this); - lp_var_t rawMagX = lp_var_t(sid.objectId, NEG_Z_RAW_MAG_X, this); - lp_var_t rawMagY = lp_var_t(sid.objectId, NEG_Z_RAW_MAG_Y, this); - lp_var_t rawMagZ = lp_var_t(sid.objectId, NEG_Z_RAW_MAG_Z, this); - lp_var_t calMagX = lp_var_t(sid.objectId, NEG_Z_CAL_MAG_X, this); - lp_var_t calMagY = lp_var_t(sid.objectId, NEG_Z_CAL_MAG_Y, this); - lp_var_t calMagZ = lp_var_t(sid.objectId, NEG_Z_CAL_MAG_Z, this); - lp_var_t coilXCurrent = lp_var_t(sid.objectId, NEG_Z_COIL_X_CURRENT, - this); - lp_var_t coilYCurrent = lp_var_t(sid.objectId, NEG_Z_COIL_Y_CURRENT, - this); - lp_var_t coilZCurrent = lp_var_t(sid.objectId, NEG_Z_COIL_Z_CURRENT, - this); - lp_var_t coilXTemperature = lp_var_t(sid.objectId, - NEG_Z_COIL_X_TEMPERATURE, this); - lp_var_t coilYTemperature = lp_var_t(sid.objectId, - NEG_Z_COIL_Y_TEMPERATURE, this); - lp_var_t coilZTemperature = lp_var_t(sid.objectId, - NEG_Z_COIL_Z_TEMPERATURE, this); - - /** FINA block */ - lp_var_t finaErr = lp_var_t(sid.objectId, FINA_NEG_Z_ERR, this); - lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_NEG_Z_RAW_MAG_X, this); - lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_NEG_Z_RAW_MAG_Y, this); - lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_NEG_Z_RAW_MAG_Z, this); - lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_NEG_Z_CAL_MAG_X, this); - lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_NEG_Z_CAL_MAG_Y, this); - lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_NEG_Z_CAL_MAG_Z, this); - lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_NEG_Z_COIL_X_CURRENT, - this); - lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_NEG_Z_COIL_Y_CURRENT, - this); - lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_NEG_Z_COIL_Z_CURRENT, - this); - lp_var_t finaCoilXTemperature = lp_var_t(sid.objectId, - FINA_NEG_Z_COIL_X_TEMPERATURE, this); - lp_var_t finaCoilYTemperature = lp_var_t(sid.objectId, - FINA_NEG_Z_COIL_Y_TEMPERATURE, this); - lp_var_t finaCoilZTemperature = lp_var_t(sid.objectId, - FINA_NEG_Z_COIL_Z_TEMPERATURE, this); + /** FINA block */ + lp_var_t finaErr = lp_var_t(sid.objectId, FINA_NEG_Z_ERR, this); + lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_NEG_Z_RAW_MAG_X, this); + lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_NEG_Z_RAW_MAG_Y, this); + lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_NEG_Z_RAW_MAG_Z, this); + lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_NEG_Z_CAL_MAG_X, this); + lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_NEG_Z_CAL_MAG_Y, this); + lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_NEG_Z_CAL_MAG_Z, this); + lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_NEG_Z_COIL_X_CURRENT, this); + lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_NEG_Z_COIL_Y_CURRENT, this); + lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_NEG_Z_COIL_Z_CURRENT, this); + lp_var_t finaCoilXTemperature = + lp_var_t(sid.objectId, FINA_NEG_Z_COIL_X_TEMPERATURE, this); + lp_var_t finaCoilYTemperature = + lp_var_t(sid.objectId, FINA_NEG_Z_COIL_Y_TEMPERATURE, this); + lp_var_t finaCoilZTemperature = + lp_var_t(sid.objectId, FINA_NEG_Z_COIL_Z_TEMPERATURE, this); }; -} - +} // namespace IMTQ #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_IMTQDEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/Max31865Definitions.h b/mission/devices/devicedefinitions/Max31865Definitions.h index c9c8255e..58faaf97 100644 --- a/mission/devices/devicedefinitions/Max31865Definitions.h +++ b/mission/devices/devicedefinitions/Max31865Definitions.h @@ -1,18 +1,15 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_MAX13865DEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_MAX13865DEFINITIONS_H_ -#include #include +#include #include + #include "objects/systemObjectList.h" namespace Max31865Definitions { -enum PoolIds: lp_id_t { - RTD_VALUE, - TEMPERATURE_C, - FAULT_BYTE -}; +enum PoolIds : lp_id_t { RTD_VALUE, TEMPERATURE_C, FAULT_BYTE }; static constexpr DeviceCommandId_t CONFIG_CMD = 0x80; static constexpr DeviceCommandId_t WRITE_HIGH_THRESHOLD = 0x83; @@ -31,35 +28,26 @@ static constexpr uint8_t CLEAR_FAULT_BIT_VAL = 0b0000'0010; static constexpr size_t MAX_REPLY_SIZE = 5; -class Max31865Set: - public StaticLocalDataSet { -public: - /** - * Constructor used by owner and data creators like device handlers. - * @param owner - * @param setId - */ - Max31865Set(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, MAX31865_SET_ID) { - } +class Max31865Set : public StaticLocalDataSet { + public: + /** + * Constructor used by owner and data creators like device handlers. + * @param owner + * @param setId + */ + Max31865Set(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, MAX31865_SET_ID) {} - /** - * Constructor used by data users like controllers. - * @param sid - */ - Max31865Set(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, MAX31865_SET_ID)) { - } + /** + * Constructor used by data users like controllers. + * @param sid + */ + Max31865Set(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, MAX31865_SET_ID)) {} - lp_var_t rtdValue = lp_var_t(sid.objectId, - PoolIds::RTD_VALUE, this); - lp_var_t temperatureCelcius = lp_var_t(sid.objectId, - PoolIds::TEMPERATURE_C, this); - lp_var_t errorByte = lp_var_t(sid.objectId, - PoolIds::FAULT_BYTE, this); + lp_var_t rtdValue = lp_var_t(sid.objectId, PoolIds::RTD_VALUE, this); + lp_var_t temperatureCelcius = lp_var_t(sid.objectId, PoolIds::TEMPERATURE_C, this); + lp_var_t errorByte = lp_var_t(sid.objectId, PoolIds::FAULT_BYTE, this); }; -} +} // namespace Max31865Definitions #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_MAX13865DEFINITIONS_H_ */ - diff --git a/mission/devices/devicedefinitions/PlocMPSoCDefinitions.h b/mission/devices/devicedefinitions/PlocMPSoCDefinitions.h index 2b9466ab..2c8a081c 100644 --- a/mission/devices/devicedefinitions/PlocMPSoCDefinitions.h +++ b/mission/devices/devicedefinitions/PlocMPSoCDefinitions.h @@ -1,172 +1,166 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ -#include #include #include +#include namespace PLOC_MPSOC { - static const DeviceCommandId_t NONE = 0x0; - static const DeviceCommandId_t TC_MEM_WRITE = 0x1; - static const DeviceCommandId_t TC_MEM_READ = 0x2; - static const DeviceCommandId_t ACK_REPORT = 0x3; - static const DeviceCommandId_t EXE_REPORT = 0x5; - static const DeviceCommandId_t TM_MEMORY_READ_REPORT = 0x6; +static const DeviceCommandId_t NONE = 0x0; +static const DeviceCommandId_t TC_MEM_WRITE = 0x1; +static const DeviceCommandId_t TC_MEM_READ = 0x2; +static const DeviceCommandId_t ACK_REPORT = 0x3; +static const DeviceCommandId_t EXE_REPORT = 0x5; +static const DeviceCommandId_t TM_MEMORY_READ_REPORT = 0x6; - static const uint16_t SIZE_ACK_REPORT = 14; - static const uint16_t SIZE_EXE_REPORT = 14; - static const uint16_t SIZE_TM_MEM_READ_REPORT = 18; +static const uint16_t SIZE_ACK_REPORT = 14; +static const uint16_t SIZE_EXE_REPORT = 14; +static const uint16_t SIZE_TM_MEM_READ_REPORT = 18; - /** - * SpacePacket apids of PLOC telecommands and telemetry. - */ - static const uint16_t APID_TC_MEM_WRITE = 0x714; - static const uint16_t APID_TC_MEM_READ = 0x715; - static const uint16_t APID_TM_MEMORY_READ_REPORT = 0x404; - static const uint16_t APID_ACK_SUCCESS = 0x400; - static const uint16_t APID_ACK_FAILURE = 0x401; - static const uint16_t APID_EXE_SUCCESS = 0x402; - static const uint16_t APID_EXE_FAILURE = 0x403; +/** + * SpacePacket apids of PLOC telecommands and telemetry. + */ +static const uint16_t APID_TC_MEM_WRITE = 0x714; +static const uint16_t APID_TC_MEM_READ = 0x715; +static const uint16_t APID_TM_MEMORY_READ_REPORT = 0x404; +static const uint16_t APID_ACK_SUCCESS = 0x400; +static const uint16_t APID_ACK_FAILURE = 0x401; +static const uint16_t APID_EXE_SUCCESS = 0x402; +static const uint16_t APID_EXE_FAILURE = 0x403; - /** Offset from first byte in Space packet to first byte of data field */ - static const uint8_t DATA_FIELD_OFFSET = 6; +/** Offset from first byte in Space packet to first byte of data field */ +static const uint8_t DATA_FIELD_OFFSET = 6; - /** - * The size of payload data which will be forwarded to the requesting object. e.g. PUS Service - * 8. - */ - static const uint8_t SIZE_MEM_READ_REPORT_DATA = 10; +/** + * The size of payload data which will be forwarded to the requesting object. e.g. PUS Service + * 8. + */ +static const uint8_t SIZE_MEM_READ_REPORT_DATA = 10; - /** - * PLOC space packet length for fixed size packets. This is the size of the whole packet data - * field. For the length field in the space packet this size will be substracted by one. - */ - static const uint16_t LENGTH_TC_MEM_WRITE = 12; - static const uint16_t LENGTH_TC_MEM_READ = 8; +/** + * PLOC space packet length for fixed size packets. This is the size of the whole packet data + * field. For the length field in the space packet this size will be substracted by one. + */ +static const uint16_t LENGTH_TC_MEM_WRITE = 12; +static const uint16_t LENGTH_TC_MEM_READ = 8; - static const size_t MAX_REPLY_SIZE = SIZE_TM_MEM_READ_REPORT; - static const size_t MAX_COMMAND_SIZE = 18; +static const size_t MAX_REPLY_SIZE = SIZE_TM_MEM_READ_REPORT; +static const size_t MAX_COMMAND_SIZE = 18; - /** - * @brief This class helps to build the memory read command for the PLOC. - * - * @details The last two bytes of the packet data field contain a CRC calculated over the whole - * space packet. This is the CRC-16-CCITT as specified in - * ECSS-E-ST-70-41C Telemetry and telecommand packet utilization. - */ - class TcMemRead : public SpacePacket { - public: +/** + * @brief This class helps to build the memory read command for the PLOC. + * + * @details The last two bytes of the packet data field contain a CRC calculated over the whole + * space packet. This is the CRC-16-CCITT as specified in + * ECSS-E-ST-70-41C Telemetry and telecommand packet utilization. + */ +class TcMemRead : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param memAddr The memory address to read from. + */ + TcMemRead(const uint32_t memAddr, uint16_t sequenceCount) + : SpacePacket(LENGTH_TC_MEM_READ - 1, true, APID_TC_MEM_READ, sequenceCount) { + fillPacketDataField(&memAddr); + } - /** - * @brief Constructor - * - * @param memAddr The memory address to read from. - */ - TcMemRead(const uint32_t memAddr, uint16_t sequenceCount) : - SpacePacket(LENGTH_TC_MEM_READ - 1, true, APID_TC_MEM_READ, sequenceCount) { - fillPacketDataField(&memAddr); - } + private: + /** + * @brief This function builds the packet data field for the mem read command. + * + * @param memAddrPtr Pointer to the memory address to read from. + */ + void fillPacketDataField(const uint32_t* memAddrPtr) { + /* Add memAddr to packet data field */ + size_t serializedSize = 0; + uint8_t* memoryAddressPos = this->localData.fields.buffer; + SerializeAdapter::serialize(memAddrPtr, &memoryAddressPos, &serializedSize, + sizeof(*memAddrPtr), SerializeIF::Endianness::LITTLE); - private: + /* Add memLen to packet data field */ + this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD] = 1; + this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD + 1] = 0; - /** - * @brief This function builds the packet data field for the mem read command. - * - * @param memAddrPtr Pointer to the memory address to read from. - */ - void fillPacketDataField(const uint32_t* memAddrPtr) { - /* Add memAddr to packet data field */ - size_t serializedSize = 0; - uint8_t* memoryAddressPos = this->localData.fields.buffer; - SerializeAdapter::serialize(memAddrPtr, &memoryAddressPos, &serializedSize, - sizeof(*memAddrPtr), SerializeIF::Endianness::LITTLE); + /* Calculate crc */ + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + LENGTH_TC_MEM_READ - CRC_SIZE); - /* Add memLen to packet data field */ - this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD] = 1; - this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD + 1] = 0; + /* Add crc to packet data field of space packet */ + serializedSize = 0; + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } - /* Calculate crc */ - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + LENGTH_TC_MEM_READ - CRC_SIZE); + static const uint8_t OFFSET_MEM_LEN_FIELD = 4; + static const uint8_t CRC_OFFSET = 6; +}; - /* Add crc to packet data field of space packet */ - serializedSize = 0; - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, - sizeof(crc), SerializeIF::Endianness::BIG); - } +/** + * @brief This class helps to generate the space packet to write to a memory address within + * the PLOC. + * @details The last two bytes of the packet data field contain a CRC calculated over the whole + * space packet. This is the CRC-16-CCITT as specified in + * ECSS-E-ST-70-41C Telemetry and telecommand packet utilization. + */ +class TcMemWrite : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param memAddr The PLOC memory address where to write to. + * @param memoryData The data to write to the specified memory address. + * @param sequenceCount The subsequence count. Must be incremented with each new packet. + */ + TcMemWrite(const uint32_t memAddr, const uint32_t memoryData, uint16_t sequenceCount) + : SpacePacket(LENGTH_TC_MEM_WRITE - 1, true, APID_TC_MEM_WRITE, sequenceCount) { + fillPacketDataField(&memAddr, &memoryData); + } - static const uint8_t OFFSET_MEM_LEN_FIELD = 4; - static const uint8_t CRC_OFFSET = 6; + private: + /** + * @brief This function builds the packet data field for the mem write command. + * + * @param memAddrPtr Pointer to the PLOC memory address where to write to. + * @param memoryDataPtr Pointer to the memoryData to write + */ + void fillPacketDataField(const uint32_t* memAddrPtr, const uint32_t* memoryDataPtr) { + /* Add memAddr to packet data field */ + size_t serializedSize = 0; + uint8_t* memoryAddressPos = this->localData.fields.buffer; + SerializeAdapter::serialize(memAddrPtr, &memoryAddressPos, &serializedSize, + sizeof(*memAddrPtr), SerializeIF::Endianness::BIG); - }; + /* Add memLen to packet data field */ + this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD] = 1; + this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD + 1] = 0; - /** - * @brief This class helps to generate the space packet to write to a memory address within - * the PLOC. - * @details The last two bytes of the packet data field contain a CRC calculated over the whole - * space packet. This is the CRC-16-CCITT as specified in - * ECSS-E-ST-70-41C Telemetry and telecommand packet utilization. - */ - class TcMemWrite : public SpacePacket { - public: - /** - * @brief Constructor - * - * @param memAddr The PLOC memory address where to write to. - * @param memoryData The data to write to the specified memory address. - * @param sequenceCount The subsequence count. Must be incremented with each new packet. - */ - TcMemWrite(const uint32_t memAddr, const uint32_t memoryData, uint16_t sequenceCount) : - SpacePacket(LENGTH_TC_MEM_WRITE - 1, true, APID_TC_MEM_WRITE, sequenceCount) { - fillPacketDataField(&memAddr, &memoryData); - } + /* Add memData to packet data field */ + serializedSize = 0; + uint8_t* memoryDataPos = this->localData.fields.buffer + OFFSET_MEM_DATA_FIELD; + SerializeAdapter::serialize(memoryDataPtr, &memoryDataPos, &serializedSize, + sizeof(*memoryDataPtr), SerializeIF::Endianness::BIG); - private: + /* Calculate crc */ + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + LENGTH_TC_MEM_WRITE - CRC_SIZE); - /** - * @brief This function builds the packet data field for the mem write command. - * - * @param memAddrPtr Pointer to the PLOC memory address where to write to. - * @param memoryDataPtr Pointer to the memoryData to write - */ - void fillPacketDataField(const uint32_t* memAddrPtr, const uint32_t* memoryDataPtr) { + serializedSize = 0; + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + /* Add crc to packet data field of space packet */ + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } - /* Add memAddr to packet data field */ - size_t serializedSize = 0; - uint8_t* memoryAddressPos = this->localData.fields.buffer; - SerializeAdapter::serialize(memAddrPtr, &memoryAddressPos, &serializedSize, - sizeof(*memAddrPtr), SerializeIF::Endianness::BIG); - - /* Add memLen to packet data field */ - this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD] = 1; - this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD + 1] = 0; - - /* Add memData to packet data field */ - serializedSize = 0; - uint8_t* memoryDataPos = this->localData.fields.buffer + OFFSET_MEM_DATA_FIELD; - SerializeAdapter::serialize(memoryDataPtr, &memoryDataPos, &serializedSize, - sizeof(*memoryDataPtr), SerializeIF::Endianness::BIG); - - /* Calculate crc */ - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + LENGTH_TC_MEM_WRITE - CRC_SIZE); - - serializedSize = 0; - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - /* Add crc to packet data field of space packet */ - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, - sizeof(crc), SerializeIF::Endianness::BIG); - } - - /** Offsets from base address of packet data field */ - static const uint8_t OFFSET_MEM_LEN_FIELD = 4; - static const uint8_t OFFSET_MEM_DATA_FIELD = 6; - static const uint8_t CRC_OFFSET = 10; - }; - -} + /** Offsets from base address of packet data field */ + static const uint8_t OFFSET_MEM_LEN_FIELD = 4; + static const uint8_t OFFSET_MEM_DATA_FIELD = 6; + static const uint8_t CRC_OFFSET = 10; +}; +} // namespace PLOC_MPSOC #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/RadSensorDefinitions.h b/mission/devices/devicedefinitions/RadSensorDefinitions.h index d3c8e876..ab49b61b 100644 --- a/mission/devices/devicedefinitions/RadSensorDefinitions.h +++ b/mission/devices/devicedefinitions/RadSensorDefinitions.h @@ -3,84 +3,79 @@ namespace RAD_SENSOR { - static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending +static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending - /** - * This command initiates the ADC conversion for all channels including the internal - * temperature sensor. - */ - static const DeviceCommandId_t WRITE_SETUP = 0x1; - static const DeviceCommandId_t START_CONVERSION = 0x2; - static const DeviceCommandId_t READ_CONVERSIONS = 0x3; +/** + * This command initiates the ADC conversion for all channels including the internal + * temperature sensor. + */ +static const DeviceCommandId_t WRITE_SETUP = 0x1; +static const DeviceCommandId_t START_CONVERSION = 0x2; +static const DeviceCommandId_t READ_CONVERSIONS = 0x3; - /** - * @brief This is the configuration byte which will be written to the setup register after - * power on. - * - * @note Bit1 (DIFFSEL1) - Bit0 (DIFFSEL0): 0b00, no data follows the setup byte - * Bit3 (REFSEL1) - Bit2 (REFSEL0): 0b10, internal reference, no wake-up delay - * Bit5 (CLKSEL1) - Bit4 (CLKSEL0): 0b10, MAX1227 uses internal oscillator for timing - * Bit7 - Bit6: 0b01, tells MAX1227 that this is the setup register - * - */ - static const uint8_t SETUP_DEFINITION = 0b01101000; +/** + * @brief This is the configuration byte which will be written to the setup register after + * power on. + * + * @note Bit1 (DIFFSEL1) - Bit0 (DIFFSEL0): 0b00, no data follows the setup byte + * Bit3 (REFSEL1) - Bit2 (REFSEL0): 0b10, internal reference, no wake-up delay + * Bit5 (CLKSEL1) - Bit4 (CLKSEL0): 0b10, MAX1227 uses internal oscillator for timing + * Bit7 - Bit6: 0b01, tells MAX1227 that this is the setup register + * + */ +static const uint8_t SETUP_DEFINITION = 0b01101000; - /** - * @brief This value will always be written to the ADC conversion register to specify the - * conversions to perform. - * @details Bit0: 1 - Enables temperature conversion - * Bit2 (SCAN1) and Bit1 (SCAN0): 0b00 (channel conversion from 0 to N) - * Bit6 - Bit3 defines N: 0b0111 (N = 7) - * Bit7: Always 1. Tells the ADC that this is the conversion register. - */ - static const uint8_t CONVERSION_DEFINITION = 0b10111001; +/** + * @brief This value will always be written to the ADC conversion register to specify the + * conversions to perform. + * @details Bit0: 1 - Enables temperature conversion + * Bit2 (SCAN1) and Bit1 (SCAN0): 0b00 (channel conversion from 0 to N) + * Bit6 - Bit3 defines N: 0b0111 (N = 7) + * Bit7: Always 1. Tells the ADC that this is the conversion register. + */ +static const uint8_t CONVERSION_DEFINITION = 0b10111001; // static const uint8_t CONVERSION_DEFINITION = 0b10111111; - /** - * @brief Writing this value resets the fifo of the MAX1227. - */ - static const uint8_t RESET_DEFINITION = 0b00011000; +/** + * @brief Writing this value resets the fifo of the MAX1227. + */ +static const uint8_t RESET_DEFINITION = 0b00011000; - static const uint8_t DUMMY_BYTE = 0xFF; +static const uint8_t DUMMY_BYTE = 0xFF; - static const uint8_t RAD_SENSOR_DATA_SET_ID = READ_CONVERSIONS; +static const uint8_t RAD_SENSOR_DATA_SET_ID = READ_CONVERSIONS; - static const uint8_t DATASET_ENTRIES = 7; - /** - * One temperature value and conversions for AIN0 - AIN7 - */ - static const uint8_t READ_SIZE = 18; +static const uint8_t DATASET_ENTRIES = 7; +/** + * One temperature value and conversions for AIN0 - AIN7 + */ +static const uint8_t READ_SIZE = 18; - enum Max1227PoolIds: lp_id_t { - TEMPERATURE_C, - AIN0, - AIN1, - AIN4, - AIN5, - AIN6, - AIN7, - }; - -class RadSensorDataset: public StaticLocalDataSet { -public: - - RadSensorDataset(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, RAD_SENSOR_DATA_SET_ID) { - } - - RadSensorDataset(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, RAD_SENSOR_DATA_SET_ID)) { - } - - lp_var_t temperatureCelcius = lp_var_t(sid.objectId, TEMPERATURE_C, this); - lp_var_t ain0 = lp_var_t(sid.objectId, AIN0, this); - lp_var_t ain1 = lp_var_t(sid.objectId, AIN1, this); - lp_var_t ain4 = lp_var_t(sid.objectId, AIN4, this); - lp_var_t ain5 = lp_var_t(sid.objectId, AIN5, this); - lp_var_t ain6 = lp_var_t(sid.objectId, AIN6, this); - lp_var_t ain7 = lp_var_t(sid.objectId, AIN7, this); +enum Max1227PoolIds : lp_id_t { + TEMPERATURE_C, + AIN0, + AIN1, + AIN4, + AIN5, + AIN6, + AIN7, }; -} +class RadSensorDataset : public StaticLocalDataSet { + public: + RadSensorDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, RAD_SENSOR_DATA_SET_ID) {} + + RadSensorDataset(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, RAD_SENSOR_DATA_SET_ID)) {} + + lp_var_t temperatureCelcius = lp_var_t(sid.objectId, TEMPERATURE_C, this); + lp_var_t ain0 = lp_var_t(sid.objectId, AIN0, this); + lp_var_t ain1 = lp_var_t(sid.objectId, AIN1, this); + lp_var_t ain4 = lp_var_t(sid.objectId, AIN4, this); + lp_var_t ain5 = lp_var_t(sid.objectId, AIN5, this); + lp_var_t ain6 = lp_var_t(sid.objectId, AIN6, this); + lp_var_t ain7 = lp_var_t(sid.objectId, AIN7, this); +}; +} // namespace RAD_SENSOR #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_RADSENSOR_H_ */ diff --git a/mission/devices/devicedefinitions/RwDefinitions.h b/mission/devices/devicedefinitions/RwDefinitions.h index b8905002..c25e3f09 100644 --- a/mission/devices/devicedefinitions/RwDefinitions.h +++ b/mission/devices/devicedefinitions/RwDefinitions.h @@ -1,66 +1,61 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_RWDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_RWDEFINITIONS_H_ -#include #include +#include #include + #include "objects/systemObjectList.h" namespace RwDefinitions { -static const uint32_t SPI_REPLY_DELAY = 70000; //us +static const uint32_t SPI_REPLY_DELAY = 70000; // us -enum PoolIds: lp_id_t { - TEMPERATURE_C, - CURR_SPEED, - REFERENCE_SPEED, - STATE, - CLC_MODE, - LAST_RESET_STATUS, - CURRRENT_RESET_STATUS, - TM_LAST_RESET_STATUS, - TM_MCU_TEMPERATURE, - PRESSURE_SENSOR_TEMPERATURE, - PRESSURE, - TM_RW_STATE, - TM_CLC_MODE, - TM_RW_CURR_SPEED, - TM_RW_REF_SPEED, - INVALID_CRC_PACKETS, - INVALID_LEN_PACKETS, - INVALID_CMD_PACKETS, - EXECUTED_REPLIES, - COMMAND_REPLIES, - UART_BYTES_WRITTEN, - UART_BYTES_READ, - UART_PARITY_ERRORS, - UART_NOISE_ERRORS, - UART_FRAME_ERRORS, - UART_REG_OVERRUN_ERRORS, - UART_TOTAL_ERRORS, - TOTAL_ERRORS, - SPI_BYTES_WRITTEN, - SPI_BYTES_READ, - SPI_REG_OVERRUN_ERRORS, - SPI_TOTAL_ERRORS +enum PoolIds : lp_id_t { + TEMPERATURE_C, + CURR_SPEED, + REFERENCE_SPEED, + STATE, + CLC_MODE, + LAST_RESET_STATUS, + CURRRENT_RESET_STATUS, + TM_LAST_RESET_STATUS, + TM_MCU_TEMPERATURE, + PRESSURE_SENSOR_TEMPERATURE, + PRESSURE, + TM_RW_STATE, + TM_CLC_MODE, + TM_RW_CURR_SPEED, + TM_RW_REF_SPEED, + INVALID_CRC_PACKETS, + INVALID_LEN_PACKETS, + INVALID_CMD_PACKETS, + EXECUTED_REPLIES, + COMMAND_REPLIES, + UART_BYTES_WRITTEN, + UART_BYTES_READ, + UART_PARITY_ERRORS, + UART_NOISE_ERRORS, + UART_FRAME_ERRORS, + UART_REG_OVERRUN_ERRORS, + UART_TOTAL_ERRORS, + TOTAL_ERRORS, + SPI_BYTES_WRITTEN, + SPI_BYTES_READ, + SPI_REG_OVERRUN_ERRORS, + SPI_TOTAL_ERRORS }; -enum States: uint8_t { - STATE_ERROR, - IDLE, - COASTING, - RUNNING_SPEED_STABLE, - RUNNING_SPEED_CHANGING -}; +enum States : uint8_t { STATE_ERROR, IDLE, COASTING, RUNNING_SPEED_STABLE, RUNNING_SPEED_CHANGING }; -enum LastResetStatus: uint8_t { - CLEARED = 0, - PIN_RESET = 1, - POR_PDR_BOR_RESET = 2, - SOFTWARE_RESET = 4, - INDEPENDENT_WATCHDOG_RESET = 8, - WINDOW_WATCHDOG_RESET = 16, - LOW_POWER_RESET = 32 +enum LastResetStatus : uint8_t { + CLEARED = 0, + PIN_RESET = 1, + POR_PDR_BOR_RESET = 2, + SOFTWARE_RESET = 4, + INDEPENDENT_WATCHDOG_RESET = 8, + WINDOW_WATCHDOG_RESET = 16, + LOW_POWER_RESET = 32 }; static const DeviceCommandId_t RESET_MCU = 1; @@ -103,66 +98,45 @@ static const uint8_t TM_SET_ENTRIES = 24; /** * @brief This dataset can be used to store the temperature of a reaction wheel. */ -class TemperatureSet: - public StaticLocalDataSet { -public: +class TemperatureSet : public StaticLocalDataSet { + public: + TemperatureSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TEMPERATURE_SET_ID) {} - TemperatureSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, TEMPERATURE_SET_ID) { - } + TemperatureSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TEMPERATURE_SET_ID)) {} - TemperatureSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, TEMPERATURE_SET_ID)) { - } - - lp_var_t temperatureCelcius = lp_var_t(sid.objectId, - PoolIds::TEMPERATURE_C, this); + lp_var_t temperatureCelcius = + lp_var_t(sid.objectId, PoolIds::TEMPERATURE_C, this); }; /** * @brief This dataset can be used to store the reaction wheel status. */ -class StatusSet: - public StaticLocalDataSet { -public: +class StatusSet : public StaticLocalDataSet { + public: + StatusSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, STATUS_SET_ID) {} - StatusSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, STATUS_SET_ID) { - } + StatusSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, STATUS_SET_ID)) {} - StatusSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, STATUS_SET_ID)) { - } - - lp_var_t currSpeed = lp_var_t(sid.objectId, - PoolIds::CURR_SPEED, this); - lp_var_t referenceSpeed = lp_var_t(sid.objectId, - PoolIds::REFERENCE_SPEED, this); - lp_var_t state = lp_var_t(sid.objectId, - PoolIds::STATE, this); - lp_var_t clcMode = lp_var_t(sid.objectId, - PoolIds::CLC_MODE, this); + lp_var_t currSpeed = lp_var_t(sid.objectId, PoolIds::CURR_SPEED, this); + lp_var_t referenceSpeed = + lp_var_t(sid.objectId, PoolIds::REFERENCE_SPEED, this); + lp_var_t state = lp_var_t(sid.objectId, PoolIds::STATE, this); + lp_var_t clcMode = lp_var_t(sid.objectId, PoolIds::CLC_MODE, this); }; /** * @brief This dataset stores the last reset status. */ -class LastResetSatus: - public StaticLocalDataSet { -public: +class LastResetSatus : public StaticLocalDataSet { + public: + LastResetSatus(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, LAST_RESET_ID) {} - LastResetSatus(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, LAST_RESET_ID) { - } + LastResetSatus(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, LAST_RESET_ID)) {} - LastResetSatus(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, LAST_RESET_ID)) { - } - - lp_var_t lastResetStatus = lp_var_t(sid.objectId, - PoolIds::LAST_RESET_STATUS, this); - lp_var_t currentResetStatus = lp_var_t(sid.objectId, - PoolIds::CURRRENT_RESET_STATUS, this); + lp_var_t lastResetStatus = + lp_var_t(sid.objectId, PoolIds::LAST_RESET_STATUS, this); + lp_var_t currentResetStatus = + lp_var_t(sid.objectId, PoolIds::CURRRENT_RESET_STATUS, this); }; /** @@ -170,69 +144,57 @@ public: * reaction wheels. https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/ * EIVE_IRS/Arbeitsdaten/08_Used%20Components/Nanoavionics_Reactionwheels&fileid=181622 */ -class TmDataset: - public StaticLocalDataSet { -public: +class TmDataset : public StaticLocalDataSet { + public: + TmDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TM_SET_ID) {} - TmDataset(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, TM_SET_ID) { - } + TmDataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TM_SET_ID)) {} - TmDataset(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, TM_SET_ID)) { - } - - lp_var_t lastResetStatus = lp_var_t(sid.objectId, - PoolIds::TM_LAST_RESET_STATUS, this); - lp_var_t mcuTemperature = lp_var_t(sid.objectId, - PoolIds::TM_MCU_TEMPERATURE, this); - lp_var_t pressureSensorTemperature = lp_var_t(sid.objectId, - PoolIds::PRESSURE_SENSOR_TEMPERATURE, this); - lp_var_t pressure = lp_var_t(sid.objectId, - PoolIds::PRESSURE, this); - lp_var_t rwState = lp_var_t(sid.objectId, - PoolIds::TM_RW_STATE, this); - lp_var_t rwClcMode = lp_var_t(sid.objectId, - PoolIds::TM_CLC_MODE, this); - lp_var_t rwCurrSpeed = lp_var_t(sid.objectId, - PoolIds::TM_RW_CURR_SPEED, this); - lp_var_t rwRefSpeed = lp_var_t(sid.objectId, - PoolIds::TM_RW_REF_SPEED, this); - lp_var_t numOfInvalidCrcPackets = lp_var_t(sid.objectId, - PoolIds::INVALID_CRC_PACKETS, this); - lp_var_t numOfInvalidLenPackets = lp_var_t(sid.objectId, - PoolIds::INVALID_LEN_PACKETS, this); - lp_var_t numOfInvalidCmdPackets = lp_var_t(sid.objectId, - PoolIds::INVALID_CMD_PACKETS, this); - lp_var_t numOfCmdExecutedReplies = lp_var_t(sid.objectId, - PoolIds::EXECUTED_REPLIES, this); - lp_var_t numOfCmdReplies = lp_var_t(sid.objectId, - PoolIds::COMMAND_REPLIES, this); - lp_var_t uartNumOfBytesWritten = lp_var_t(sid.objectId, - PoolIds::UART_BYTES_WRITTEN, this); - lp_var_t uartNumOfBytesRead = lp_var_t(sid.objectId, - PoolIds::UART_BYTES_READ, this); - lp_var_t uartNumOfParityErrors = lp_var_t(sid.objectId, - PoolIds::UART_PARITY_ERRORS, this); - lp_var_t uartNumOfNoiseErrors = lp_var_t(sid.objectId, - PoolIds::UART_NOISE_ERRORS, this); - lp_var_t uartNumOfFrameErrors = lp_var_t(sid.objectId, - PoolIds::UART_FRAME_ERRORS, this); - lp_var_t uartNumOfRegisterOverrunErrors = lp_var_t(sid.objectId, - PoolIds::UART_REG_OVERRUN_ERRORS, this); - lp_var_t uartTotalNumOfErrors = lp_var_t(sid.objectId, - PoolIds::UART_TOTAL_ERRORS, this); - lp_var_t spiNumOfBytesWritten = lp_var_t(sid.objectId, - PoolIds::SPI_BYTES_WRITTEN, this); - lp_var_t spiNumOfBytesRead = lp_var_t(sid.objectId, - PoolIds::SPI_BYTES_READ, this); - lp_var_t spiNumOfRegisterOverrunErrors = lp_var_t(sid.objectId, - PoolIds::SPI_REG_OVERRUN_ERRORS, this); - lp_var_t spiTotalNumOfErrors = lp_var_t(sid.objectId, - PoolIds::SPI_TOTAL_ERRORS, this); + lp_var_t lastResetStatus = + lp_var_t(sid.objectId, PoolIds::TM_LAST_RESET_STATUS, this); + lp_var_t mcuTemperature = + lp_var_t(sid.objectId, PoolIds::TM_MCU_TEMPERATURE, this); + lp_var_t pressureSensorTemperature = + lp_var_t(sid.objectId, PoolIds::PRESSURE_SENSOR_TEMPERATURE, this); + lp_var_t pressure = lp_var_t(sid.objectId, PoolIds::PRESSURE, this); + lp_var_t rwState = lp_var_t(sid.objectId, PoolIds::TM_RW_STATE, this); + lp_var_t rwClcMode = lp_var_t(sid.objectId, PoolIds::TM_CLC_MODE, this); + lp_var_t rwCurrSpeed = lp_var_t(sid.objectId, PoolIds::TM_RW_CURR_SPEED, this); + lp_var_t rwRefSpeed = lp_var_t(sid.objectId, PoolIds::TM_RW_REF_SPEED, this); + lp_var_t numOfInvalidCrcPackets = + lp_var_t(sid.objectId, PoolIds::INVALID_CRC_PACKETS, this); + lp_var_t numOfInvalidLenPackets = + lp_var_t(sid.objectId, PoolIds::INVALID_LEN_PACKETS, this); + lp_var_t numOfInvalidCmdPackets = + lp_var_t(sid.objectId, PoolIds::INVALID_CMD_PACKETS, this); + lp_var_t numOfCmdExecutedReplies = + lp_var_t(sid.objectId, PoolIds::EXECUTED_REPLIES, this); + lp_var_t numOfCmdReplies = + lp_var_t(sid.objectId, PoolIds::COMMAND_REPLIES, this); + lp_var_t uartNumOfBytesWritten = + lp_var_t(sid.objectId, PoolIds::UART_BYTES_WRITTEN, this); + lp_var_t uartNumOfBytesRead = + lp_var_t(sid.objectId, PoolIds::UART_BYTES_READ, this); + lp_var_t uartNumOfParityErrors = + lp_var_t(sid.objectId, PoolIds::UART_PARITY_ERRORS, this); + lp_var_t uartNumOfNoiseErrors = + lp_var_t(sid.objectId, PoolIds::UART_NOISE_ERRORS, this); + lp_var_t uartNumOfFrameErrors = + lp_var_t(sid.objectId, PoolIds::UART_FRAME_ERRORS, this); + lp_var_t uartNumOfRegisterOverrunErrors = + lp_var_t(sid.objectId, PoolIds::UART_REG_OVERRUN_ERRORS, this); + lp_var_t uartTotalNumOfErrors = + lp_var_t(sid.objectId, PoolIds::UART_TOTAL_ERRORS, this); + lp_var_t spiNumOfBytesWritten = + lp_var_t(sid.objectId, PoolIds::SPI_BYTES_WRITTEN, this); + lp_var_t spiNumOfBytesRead = + lp_var_t(sid.objectId, PoolIds::SPI_BYTES_READ, this); + lp_var_t spiNumOfRegisterOverrunErrors = + lp_var_t(sid.objectId, PoolIds::SPI_REG_OVERRUN_ERRORS, this); + lp_var_t spiTotalNumOfErrors = + lp_var_t(sid.objectId, PoolIds::SPI_TOTAL_ERRORS, this); }; -} +} // namespace RwDefinitions #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_RWDEFINITIONS_H_ */ - diff --git a/mission/devices/devicedefinitions/SyrlinksDefinitions.h b/mission/devices/devicedefinitions/SyrlinksDefinitions.h index 7aa75b99..4002ee12 100644 --- a/mission/devices/devicedefinitions/SyrlinksDefinitions.h +++ b/mission/devices/devicedefinitions/SyrlinksDefinitions.h @@ -1,101 +1,88 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_SYRLINKSDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_SYRLINKSDEFINITIONS_H_ - namespace SYRLINKS { - static const DeviceCommandId_t NONE = 0x0; - static const DeviceCommandId_t RESET_UNIT = 0x01; - /** Reads out all status registers */ - static const DeviceCommandId_t READ_RX_STATUS_REGISTERS = 0x02; - /** Sets Tx mode to standby */ - static const DeviceCommandId_t SET_TX_MODE_STANDBY = 0x03; - /** Starts transmission mode. Only reached when clock signal is applying to the data tx input */ - static const DeviceCommandId_t SET_TX_MODE_MODULATION = 0x04; - /** Sends out a single carrier wave for testing purpose */ - static const DeviceCommandId_t SET_TX_MODE_CW = 0x05; - static const DeviceCommandId_t ACK_REPLY = 0x06; - static const DeviceCommandId_t READ_TX_STATUS = 0x07; - static const DeviceCommandId_t READ_TX_WAVEFORM = 0x08; - static const DeviceCommandId_t READ_TX_AGC_VALUE_HIGH_BYTE = 0x09; - static const DeviceCommandId_t READ_TX_AGC_VALUE_LOW_BYTE = 0x0A; +static const DeviceCommandId_t NONE = 0x0; +static const DeviceCommandId_t RESET_UNIT = 0x01; +/** Reads out all status registers */ +static const DeviceCommandId_t READ_RX_STATUS_REGISTERS = 0x02; +/** Sets Tx mode to standby */ +static const DeviceCommandId_t SET_TX_MODE_STANDBY = 0x03; +/** Starts transmission mode. Only reached when clock signal is applying to the data tx input */ +static const DeviceCommandId_t SET_TX_MODE_MODULATION = 0x04; +/** Sends out a single carrier wave for testing purpose */ +static const DeviceCommandId_t SET_TX_MODE_CW = 0x05; +static const DeviceCommandId_t ACK_REPLY = 0x06; +static const DeviceCommandId_t READ_TX_STATUS = 0x07; +static const DeviceCommandId_t READ_TX_WAVEFORM = 0x08; +static const DeviceCommandId_t READ_TX_AGC_VALUE_HIGH_BYTE = 0x09; +static const DeviceCommandId_t READ_TX_AGC_VALUE_LOW_BYTE = 0x0A; - /** Size of a simple transmission success response */ - static const uint8_t ACK_SIZE = 11; - static const uint8_t SIZE_CRC_AND_TERMINATION = 5; - /** The size of the header with the message identifier and the payload size field */ - static const uint8_t MESSAGE_HEADER_SIZE = 5; - /** Size of reply to an rx status registers request */ - static const uint8_t RX_STATUS_REGISTERS_REPLY_SIZE = 49; - static const uint8_t READ_ONE_REGISTER_REPLY_SIE = 13; +/** Size of a simple transmission success response */ +static const uint8_t ACK_SIZE = 11; +static const uint8_t SIZE_CRC_AND_TERMINATION = 5; +/** The size of the header with the message identifier and the payload size field */ +static const uint8_t MESSAGE_HEADER_SIZE = 5; +/** Size of reply to an rx status registers request */ +static const uint8_t RX_STATUS_REGISTERS_REPLY_SIZE = 49; +static const uint8_t READ_ONE_REGISTER_REPLY_SIE = 13; - static const uint8_t RX_DATASET_ID = 0x1; - static const uint8_t TX_DATASET_ID = 0x2; +static const uint8_t RX_DATASET_ID = 0x1; +static const uint8_t TX_DATASET_ID = 0x2; - static const size_t MAX_REPLY_SIZE = RX_STATUS_REGISTERS_REPLY_SIZE; - static const size_t MAX_COMMAND_SIZE = 15; +static const size_t MAX_REPLY_SIZE = RX_STATUS_REGISTERS_REPLY_SIZE; +static const size_t MAX_COMMAND_SIZE = 15; - static const size_t CRC_FIELD_SIZE = 4; +static const size_t CRC_FIELD_SIZE = 4; - static const uint8_t RX_DATASET_SIZE = 8; - static const uint8_t TX_DATASET_SIZE = 3; +static const uint8_t RX_DATASET_SIZE = 8; +static const uint8_t TX_DATASET_SIZE = 3; - enum SyrlinksPoolIds: lp_id_t { - RX_STATUS, - RX_SENSITIVITY, - RX_FREQUENCY_SHIFT, - RX_IQ_POWER, - RX_AGC_VALUE, - RX_DEMOD_EB, - RX_DEMOD_N0, - RX_DATA_RATE, - TX_STATUS, - TX_CONV_DIFF, - TX_CONV_FILTER, - TX_WAVEFORM, - TX_PCM_INDEX, - TX_AGC_VALUE, - }; - -class RxDataset: public StaticLocalDataSet { -public: - - RxDataset(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, RX_DATASET_ID) { - } - - RxDataset(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, RX_DATASET_ID)) { - } - - lp_var_t rxStatus = lp_var_t(sid.objectId, RX_STATUS, this); - lp_var_t rxSensitivity = lp_var_t(sid.objectId, RX_SENSITIVITY, this); - lp_var_t rxFrequencyShift = lp_var_t(sid.objectId, RX_FREQUENCY_SHIFT, this); - lp_var_t rxIqPower = lp_var_t(sid.objectId, RX_IQ_POWER, this); - lp_var_t rxAgcValue = lp_var_t(sid.objectId, RX_AGC_VALUE, this); - lp_var_t rxDemodEb = lp_var_t(sid.objectId, RX_DEMOD_EB, this); - lp_var_t rxDemodN0 = lp_var_t(sid.objectId, RX_DEMOD_N0, this); - lp_var_t rxDataRate = lp_var_t(sid.objectId, RX_DATA_RATE, this); +enum SyrlinksPoolIds : lp_id_t { + RX_STATUS, + RX_SENSITIVITY, + RX_FREQUENCY_SHIFT, + RX_IQ_POWER, + RX_AGC_VALUE, + RX_DEMOD_EB, + RX_DEMOD_N0, + RX_DATA_RATE, + TX_STATUS, + TX_CONV_DIFF, + TX_CONV_FILTER, + TX_WAVEFORM, + TX_PCM_INDEX, + TX_AGC_VALUE, }; +class RxDataset : public StaticLocalDataSet { + public: + RxDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, RX_DATASET_ID) {} -class TxDataset: public StaticLocalDataSet { -public: + RxDataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, RX_DATASET_ID)) {} - TxDataset(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, TX_DATASET_ID) { - } - - TxDataset(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, TX_DATASET_ID)) { - } - - lp_var_t txStatus = lp_var_t(sid.objectId, TX_STATUS, this); - lp_var_t txWaveform = lp_var_t(sid.objectId, TX_WAVEFORM, this); - lp_var_t txAgcValue = lp_var_t(sid.objectId, TX_AGC_VALUE, this); + lp_var_t rxStatus = lp_var_t(sid.objectId, RX_STATUS, this); + lp_var_t rxSensitivity = lp_var_t(sid.objectId, RX_SENSITIVITY, this); + lp_var_t rxFrequencyShift = lp_var_t(sid.objectId, RX_FREQUENCY_SHIFT, this); + lp_var_t rxIqPower = lp_var_t(sid.objectId, RX_IQ_POWER, this); + lp_var_t rxAgcValue = lp_var_t(sid.objectId, RX_AGC_VALUE, this); + lp_var_t rxDemodEb = lp_var_t(sid.objectId, RX_DEMOD_EB, this); + lp_var_t rxDemodN0 = lp_var_t(sid.objectId, RX_DEMOD_N0, this); + lp_var_t rxDataRate = lp_var_t(sid.objectId, RX_DATA_RATE, this); }; -} +class TxDataset : public StaticLocalDataSet { + public: + TxDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TX_DATASET_ID) {} + TxDataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TX_DATASET_ID)) {} + + lp_var_t txStatus = lp_var_t(sid.objectId, TX_STATUS, this); + lp_var_t txWaveform = lp_var_t(sid.objectId, TX_WAVEFORM, this); + lp_var_t txAgcValue = lp_var_t(sid.objectId, TX_AGC_VALUE, this); +}; + +} // namespace SYRLINKS #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_SYRLINKSDEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/Tmp1075Definitions.h b/mission/devices/devicedefinitions/Tmp1075Definitions.h index 603260ac..3f48508c 100644 --- a/mission/devices/devicedefinitions/Tmp1075Definitions.h +++ b/mission/devices/devicedefinitions/Tmp1075Definitions.h @@ -2,46 +2,35 @@ #define MISSION_DEVICES_DEVICEDEFINITIONS_TMP1075DEFINITIONS_H_ namespace TMP1075 { - static const uint8_t TEMP_REG_ADDR = 0x0; - static const uint8_t CFGR_ADDR = 0x1; +static const uint8_t TEMP_REG_ADDR = 0x0; +static const uint8_t CFGR_ADDR = 0x1; - /* Writing this information to the configuration register sets the tmp1075 - * to shutdown mode and starts a single temperature conversion */ - static const uint16_t ONE_SHOT_MODE = 0x8100; +/* Writing this information to the configuration register sets the tmp1075 + * to shutdown mode and starts a single temperature conversion */ +static const uint16_t ONE_SHOT_MODE = 0x8100; - static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending - static const DeviceCommandId_t GET_TEMP = 0x1; - static const DeviceCommandId_t START_ADC_CONVERSION = 0x2; +static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending +static const DeviceCommandId_t GET_TEMP = 0x1; +static const DeviceCommandId_t START_ADC_CONVERSION = 0x2; - static const uint8_t GET_TEMP_REPLY_SIZE = 2; - static const uint8_t CFGR_CMD_SIZE = 3; - static const uint8_t POINTER_REG_SIZE = 1; +static const uint8_t GET_TEMP_REPLY_SIZE = 2; +static const uint8_t CFGR_CMD_SIZE = 3; +static const uint8_t POINTER_REG_SIZE = 1; - static const uint32_t TMP1075_DATA_SET_ID = GET_TEMP; +static const uint32_t TMP1075_DATA_SET_ID = GET_TEMP; - static const uint8_t MAX_REPLY_LENGTH = GET_TEMP_REPLY_SIZE; +static const uint8_t MAX_REPLY_LENGTH = GET_TEMP_REPLY_SIZE; - enum Tmp1075PoolIds: lp_id_t { - TEMPERATURE_C_TMP1075_1, - TEMPERATURE_C_TMP1075_2 - }; +enum Tmp1075PoolIds : lp_id_t { TEMPERATURE_C_TMP1075_1, TEMPERATURE_C_TMP1075_2 }; -class Tmp1075Dataset: - public StaticLocalDataSet { -public: +class Tmp1075Dataset : public StaticLocalDataSet { + public: + Tmp1075Dataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TMP1075_DATA_SET_ID) {} - Tmp1075Dataset(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, TMP1075_DATA_SET_ID) { - } + Tmp1075Dataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TMP1075_DATA_SET_ID)) {} - Tmp1075Dataset(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, TMP1075_DATA_SET_ID)) { - } - - lp_var_t temperatureCelcius = lp_var_t(sid.objectId, - TEMPERATURE_C_TMP1075_1, this); + lp_var_t temperatureCelcius = lp_var_t(sid.objectId, TEMPERATURE_C_TMP1075_1, this); }; -} - +} // namespace TMP1075 #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_TMP1075DEFINITIONS_H_ */ diff --git a/mission/memory/NVMParameterBase.cpp b/mission/memory/NVMParameterBase.cpp index e7b8e8a6..0802a392 100644 --- a/mission/memory/NVMParameterBase.cpp +++ b/mission/memory/NVMParameterBase.cpp @@ -1,50 +1,44 @@ #include "NVMParameterBase.h" -#include "fsfw/memory/HasFileSystemIF.h" -#include "fsfw/serviceinterface/ServiceInterface.h" #include -NVMParameterBase::NVMParameterBase(std::string fullName): fullName(fullName) { -} +#include "fsfw/memory/HasFileSystemIF.h" +#include "fsfw/serviceinterface/ServiceInterface.h" + +NVMParameterBase::NVMParameterBase(std::string fullName) : fullName(fullName) {} ReturnValue_t NVMParameterBase::readJsonFile() { - if(std::filesystem::exists(fullName)) { - // Read JSON file content into object - std::ifstream i(fullName); - i >> json; - return HasReturnvaluesIF::RETURN_OK; - } - return HasFileSystemIF::FILE_DOES_NOT_EXIST; + if (std::filesystem::exists(fullName)) { + // Read JSON file content into object + std::ifstream i(fullName); + i >> json; + return HasReturnvaluesIF::RETURN_OK; + } + return HasFileSystemIF::FILE_DOES_NOT_EXIST; } ReturnValue_t NVMParameterBase::writeJsonFile() { - std::ofstream o(fullName); - o << std::setw(4) << json; - return HasReturnvaluesIF::RETURN_OK; + std::ofstream o(fullName); + o << std::setw(4) << json; + return HasReturnvaluesIF::RETURN_OK; } -void NVMParameterBase::setFullName(std::string fullName) { - this->fullName = fullName; -} +void NVMParameterBase::setFullName(std::string fullName) { this->fullName = fullName; } -std::string NVMParameterBase::getFullName() const { - return fullName; -} +std::string NVMParameterBase::getFullName() const { return fullName; } -bool NVMParameterBase::getJsonFileExists() { - return std::filesystem::exists(fullName); -} +bool NVMParameterBase::getJsonFileExists() { return std::filesystem::exists(fullName); } void NVMParameterBase::printKeys() const { - sif::info << "Printing keys for JSON file " << fullName << std::endl; - for(const auto& key: keys) { - sif::info << key << std::endl; - } + sif::info << "Printing keys for JSON file " << fullName << std::endl; + for (const auto& key : keys) { + sif::info << key << std::endl; + } } void NVMParameterBase::print() const { - sif::info << "Printing JSON file " << fullName << std::endl; - for(const auto& key: keys) { - sif::info << key << ": " << json[key] << std::endl; - } + sif::info << "Printing JSON file " << fullName << std::endl; + for (const auto& key : keys) { + sif::info << key << ": " << json[key] << std::endl; + } } diff --git a/mission/memory/NVMParameterBase.h b/mission/memory/NVMParameterBase.h index f41f9e63..aafbf8cc 100644 --- a/mission/memory/NVMParameterBase.h +++ b/mission/memory/NVMParameterBase.h @@ -1,79 +1,78 @@ #ifndef BSP_Q7S_CORE_NVMPARAMS_NVMPARAMIF_H_ #define BSP_Q7S_CORE_NVMPARAMS_NVMPARAMIF_H_ -#include "fsfw/returnvalues/HasReturnvaluesIF.h" - +#include #include #include -#include + +#include "fsfw/returnvalues/HasReturnvaluesIF.h" class NVMParameterBase : public HasReturnvaluesIF { -public: - virtual~ NVMParameterBase() {} + public: + virtual ~NVMParameterBase() {} - NVMParameterBase(std::string fullName); + NVMParameterBase(std::string fullName); - bool getJsonFileExists(); + bool getJsonFileExists(); - /** - * Returns RETURN_OK on successfull read and HasFileSystemIF::FILE_DOES_NOT_EXIST if - * file does not exist yet. - * @return - */ - virtual ReturnValue_t readJsonFile(); + /** + * Returns RETURN_OK on successfull read and HasFileSystemIF::FILE_DOES_NOT_EXIST if + * file does not exist yet. + * @return + */ + virtual ReturnValue_t readJsonFile(); - virtual ReturnValue_t writeJsonFile(); + virtual ReturnValue_t writeJsonFile(); - void setFullName(std::string fullName); - std::string getFullName() const; + void setFullName(std::string fullName); + std::string getFullName() const; - template - ReturnValue_t insertValue(std::string key, T value); + template + ReturnValue_t insertValue(std::string key, T value); - template - ReturnValue_t setValue(std::string key, T value); + template + ReturnValue_t setValue(std::string key, T value); - template - ReturnValue_t getValue(std::string key, T* value) const; + template + ReturnValue_t getValue(std::string key, T* value) const; - void printKeys() const; - void print() const; + void printKeys() const; + void print() const; -private: + private: + static const uint8_t INTERFACE_ID = CLASS_ID::NVM_PARAM_BASE; - static const uint8_t INTERFACE_ID = CLASS_ID::NVM_PARAM_BASE; + //! [EXPORT] : [COMMENT] Specified key does not exist in json file + static const ReturnValue_t KEY_NOT_EXISTS = MAKE_RETURN_CODE(0xA0); - //! [EXPORT] : [COMMENT] Specified key does not exist in json file - static const ReturnValue_t KEY_NOT_EXISTS = MAKE_RETURN_CODE(0xA0); - - nlohmann::json json; - std::vector keys; - std::string fullName; + nlohmann::json json; + std::vector keys; + std::string fullName; }; -template +template inline ReturnValue_t NVMParameterBase::insertValue(std::string key, T value) { - // Check whether key already exists. If it does not, insert it - if (std::find(keys.begin(), keys.end(), key) == keys.end()) { - keys.push_back(key); - } - json[key] = value; - return HasReturnvaluesIF::RETURN_OK; + // Check whether key already exists. If it does not, insert it + if (std::find(keys.begin(), keys.end(), key) == keys.end()) { + keys.push_back(key); + } + json[key] = value; + return HasReturnvaluesIF::RETURN_OK; } -template +template inline ReturnValue_t NVMParameterBase::setValue(std::string key, T value) { - json[key] = value; - return HasReturnvaluesIF::RETURN_OK; + json[key] = value; + return HasReturnvaluesIF::RETURN_OK; } -template +template inline ReturnValue_t NVMParameterBase::getValue(std::string key, T* value) const { - if (!json.contains(key)) { - return KEY_NOT_EXISTS; - } - *value = json[key]; - return RETURN_OK; + if (!json.contains(key)) { + return KEY_NOT_EXISTS; + } + *value = json[key]; + return RETURN_OK; } #endif /* BSP_Q7S_CORE_NVMPARAMS_NVMPARAMIF_H_ */ diff --git a/mission/tmtc/CCSDSHandler.cpp b/mission/tmtc/CCSDSHandler.cpp index 524fe4b8..ba34d273 100644 --- a/mission/tmtc/CCSDSHandler.cpp +++ b/mission/tmtc/CCSDSHandler.cpp @@ -1,303 +1,301 @@ -#include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/serviceinterface/serviceInterfaceDefintions.h" -#include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/ipc/QueueFactory.h" -#include "fsfw/events/EventManagerIF.h" +#include "CCSDSHandler.h" #include -#include "CCSDSHandler.h" +#include "fsfw/events/EventManagerIF.h" +#include "fsfw/ipc/QueueFactory.h" +#include "fsfw/objectmanager/ObjectManager.h" +#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface/serviceInterfaceDefintions.h" CCSDSHandler::CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination, - TxRateSetterIF* txRateSetterIF, GpioIF* gpioIF, gpioId_t enTxClock, gpioId_t enTxData) : - SystemObject(objectId), ptmeId(ptmeId), tcDestination(tcDestination), parameterHelper(this), actionHelper( - this, nullptr), txRateSetterIF(txRateSetterIF), gpioIF(gpioIF), enTxClock( - enTxClock), enTxData(enTxData) { - commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); - eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 2); + TxRateSetterIF* txRateSetterIF, GpioIF* gpioIF, gpioId_t enTxClock, + gpioId_t enTxData) + : SystemObject(objectId), + ptmeId(ptmeId), + tcDestination(tcDestination), + parameterHelper(this), + actionHelper(this, nullptr), + txRateSetterIF(txRateSetterIF), + gpioIF(gpioIF), + enTxClock(enTxClock), + enTxData(enTxData) { + commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); + eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 2); } -CCSDSHandler::~CCSDSHandler() { -} +CCSDSHandler::~CCSDSHandler() {} ReturnValue_t CCSDSHandler::performOperation(uint8_t operationCode) { - checkEvents(); - readCommandQueue(); - handleTelemetry(); - handleTelecommands(); - checkTxTimer(); - return RETURN_OK; + checkEvents(); + readCommandQueue(); + handleTelemetry(); + handleTelecommands(); + checkTxTimer(); + return RETURN_OK; } void CCSDSHandler::handleTelemetry() { - VirtualChannelMapIter iter; - for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { - iter->second->performOperation(); - } + VirtualChannelMapIter iter; + for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { + iter->second->performOperation(); + } } -void CCSDSHandler::handleTelecommands() { - -} +void CCSDSHandler::handleTelecommands() {} ReturnValue_t CCSDSHandler::initialize() { - ReturnValue_t result = RETURN_OK; - PtmeIF* ptme = ObjectManager::instance()->get(ptmeId); - if (ptme == nullptr) { - sif::warning << "Invalid PTME object" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + ReturnValue_t result = RETURN_OK; + PtmeIF* ptme = ObjectManager::instance()->get(ptmeId); + if (ptme == nullptr) { + sif::warning << "Invalid PTME object" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - AcceptsTelecommandsIF* tcDistributor = - ObjectManager::instance()->get(tcDestination); - if (tcDistributor == nullptr) { + AcceptsTelecommandsIF* tcDistributor = + ObjectManager::instance()->get(tcDestination); + if (tcDistributor == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "CCSDSHandler::initialize: Invalid TC Distributor object" << std::endl; + sif::error << "CCSDSHandler::initialize: Invalid TC Distributor object" << std::endl; #endif - return ObjectManagerIF::CHILD_INIT_FAILED; - } + return ObjectManagerIF::CHILD_INIT_FAILED; + } - tcDistributorQueueId = tcDistributor->getRequestQueue(); + tcDistributorQueueId = tcDistributor->getRequestQueue(); - result = parameterHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + result = parameterHelper.initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } - result = actionHelper.initialize(commandQueue); + result = actionHelper.initialize(commandQueue); + if (result != RETURN_OK) { + return result; + } + + VirtualChannelMapIter iter; + for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { + result = iter->second->initialize(); if (result != RETURN_OK) { - return result; + return result; } + iter->second->setPtmeObject(ptme); + } - VirtualChannelMapIter iter; - for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { - result = iter->second->initialize(); - if (result != RETURN_OK) { - return result; - } - iter->second->setPtmeObject(ptme); - } - - EventManagerIF* manager = ObjectManager::instance()->get( - objects::EVENT_MANAGER); - if (manager == nullptr) { + EventManagerIF* manager = ObjectManager::instance()->get(objects::EVENT_MANAGER); + if (manager == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "CCSDSHandler::initialize: Invalid event manager" << std::endl; + sif::error << "CCSDSHandler::initialize: Invalid event manager" << std::endl; #endif - return ObjectManagerIF::CHILD_INIT_FAILED; - } - result = manager->registerListener(eventQueue->getId()); - if (result != HasReturnvaluesIF::RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } + result = manager->registerListener(eventQueue->getId()); + if (result != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "CCSDSHandler::initialize: Failed to register CCSDS handler as event " - "listener" << std::endl; + sif::warning << "CCSDSHandler::initialize: Failed to register CCSDS handler as event " + "listener" + << std::endl; #endif - return ObjectManagerIF::CHILD_INIT_FAILED;; - } - result = manager->subscribeToEventRange(eventQueue->getId(), - event::getEventId(PdecHandler::CARRIER_LOCK), - event::getEventId(PdecHandler::BIT_LOCK_PDEC)); - if (result != HasReturnvaluesIF::RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + ; + } + result = manager->subscribeToEventRange(eventQueue->getId(), + event::getEventId(PdecHandler::CARRIER_LOCK), + event::getEventId(PdecHandler::BIT_LOCK_PDEC)); + if (result != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "CCSDSHandler::initialize: Failed to subscribe to events from PDEC " - "handler" << std::endl; + sif::error << "CCSDSHandler::initialize: Failed to subscribe to events from PDEC " + "handler" + << std::endl; #endif - return result; - } - return result; + return result; + } + return result; } void CCSDSHandler::readCommandQueue(void) { - CommandMessage commandMessage; - ReturnValue_t result = RETURN_FAILED; + CommandMessage commandMessage; + ReturnValue_t result = RETURN_FAILED; - result = commandQueue->receiveMessage(&commandMessage); + result = commandQueue->receiveMessage(&commandMessage); + if (result == RETURN_OK) { + result = parameterHelper.handleParameterMessage(&commandMessage); if (result == RETURN_OK) { - result = parameterHelper.handleParameterMessage(&commandMessage); - if (result == RETURN_OK) { - return; - } - result = actionHelper.handleActionMessage(&commandMessage); - if (result == RETURN_OK) { - return; - } - CommandMessage reply; - reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND, - commandMessage.getCommand()); - commandQueue->reply(&reply); - return; + return; } + result = actionHelper.handleActionMessage(&commandMessage); + if (result == RETURN_OK) { + return; + } + CommandMessage reply; + reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND, commandMessage.getCommand()); + commandQueue->reply(&reply); + return; + } } -MessageQueueId_t CCSDSHandler::getCommandQueue() const { - return commandQueue->getId(); -} +MessageQueueId_t CCSDSHandler::getCommandQueue() const { return commandQueue->getId(); } void CCSDSHandler::addVirtualChannel(VcId_t vcId, VirtualChannel* virtualChannel) { - if (vcId > common::NUMBER_OF_VIRTUAL_CHANNELS) { - sif::warning << "CCSDSHandler::addVirtualChannel: Invalid virtual channel ID" << std::endl; - return; - } + if (vcId > common::NUMBER_OF_VIRTUAL_CHANNELS) { + sif::warning << "CCSDSHandler::addVirtualChannel: Invalid virtual channel ID" << std::endl; + return; + } - if (virtualChannel == nullptr) { - sif::warning << "CCSDSHandler::addVirtualChannel: Invalid virtual channel interface" << std::endl; - return; - } + if (virtualChannel == nullptr) { + sif::warning << "CCSDSHandler::addVirtualChannel: Invalid virtual channel interface" + << std::endl; + return; + } - auto status = virtualChannelMap.emplace(vcId, virtualChannel); - if (status.second == false) { - sif::warning << "CCSDSHandler::addVirtualChannel: Failed to add virtual channel to " - "virtual channel map" << std::endl; - return; - } + auto status = virtualChannelMap.emplace(vcId, virtualChannel); + if (status.second == false) { + sif::warning << "CCSDSHandler::addVirtualChannel: Failed to add virtual channel to " + "virtual channel map" + << std::endl; + return; + } } MessageQueueId_t CCSDSHandler::getReportReceptionQueue(uint8_t virtualChannel) { - if (virtualChannel < common::NUMBER_OF_VIRTUAL_CHANNELS) { - VirtualChannelMapIter iter = virtualChannelMap.find(virtualChannel); - if (iter != virtualChannelMap.end()) { - return iter->second->getReportReceptionQueue(); - } - else { - sif::warning << "CCSDSHandler::getReportReceptionQueue: Virtual channel with ID " - << static_cast(virtualChannel) << " not in virtual channel map" - << std::endl; - return MessageQueueIF::NO_QUEUE; - } - } else { - sif::debug << "CCSDSHandler::getReportReceptionQueue: Invalid virtual channel requested"; - - } - return MessageQueueIF::NO_QUEUE; + if (virtualChannel < common::NUMBER_OF_VIRTUAL_CHANNELS) { + VirtualChannelMapIter iter = virtualChannelMap.find(virtualChannel); + if (iter != virtualChannelMap.end()) { + return iter->second->getReportReceptionQueue(); + } else { + sif::warning << "CCSDSHandler::getReportReceptionQueue: Virtual channel with ID " + << static_cast(virtualChannel) << " not in virtual channel map" + << std::endl; + return MessageQueueIF::NO_QUEUE; + } + } else { + sif::debug << "CCSDSHandler::getReportReceptionQueue: Invalid virtual channel requested"; + } + return MessageQueueIF::NO_QUEUE; } ReturnValue_t CCSDSHandler::getParameter(uint8_t domainId, uint8_t uniqueIdentifier, - ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues, - uint16_t startAtIndex) { - return RETURN_OK; + ParameterWrapper* parameterWrapper, + const ParameterWrapper* newValues, uint16_t startAtIndex) { + return RETURN_OK; } -uint16_t CCSDSHandler::getIdentifier() { - return 0; -} +uint16_t CCSDSHandler::getIdentifier() { return 0; } MessageQueueId_t CCSDSHandler::getRequestQueue() { - // Forward packets directly to TC distributor - return tcDistributorQueueId; + // Forward packets directly to TC distributor + return tcDistributorQueueId; } -ReturnValue_t CCSDSHandler::executeAction(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { - - switch(actionId) { +ReturnValue_t CCSDSHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) { + switch (actionId) { case SET_LOW_RATE: { - txRateSetterIF->setRate(BitRates::RATE_400KHZ); - return EXECUTION_FINISHED; + txRateSetterIF->setRate(BitRates::RATE_400KHZ); + return EXECUTION_FINISHED; } case SET_HIGH_RATE: { - txRateSetterIF->setRate(BitRates::RATE_2000KHZ); - return EXECUTION_FINISHED; + txRateSetterIF->setRate(BitRates::RATE_2000KHZ); + return EXECUTION_FINISHED; } case EN_TRANSMITTER: { - enableTransmit(); - return EXECUTION_FINISHED; + enableTransmit(); + return EXECUTION_FINISHED; } case DIS_TRANSMITTER: { - disableTransmit(); - return EXECUTION_FINISHED; + disableTransmit(); + return EXECUTION_FINISHED; } default: - return COMMAND_NOT_IMPLEMENTED; - } + return COMMAND_NOT_IMPLEMENTED; + } } void CCSDSHandler::checkEvents() { - EventMessage event; - for (ReturnValue_t result = eventQueue->receiveMessage(&event); - result == RETURN_OK; result = eventQueue->receiveMessage(&event)) { - switch (event.getMessageId()) { - case EventMessage::EVENT_MESSAGE: - handleEvent(&event); - break; - default: - sif::debug << "CCSDSHandler::checkEvents: Did not subscribe to this event message" - << std::endl; - break; - } + EventMessage event; + for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == RETURN_OK; + result = eventQueue->receiveMessage(&event)) { + switch (event.getMessageId()) { + case EventMessage::EVENT_MESSAGE: + handleEvent(&event); + break; + default: + sif::debug << "CCSDSHandler::checkEvents: Did not subscribe to this event message" + << std::endl; + break; } + } } - void CCSDSHandler::handleEvent(EventMessage* eventMessage) { - Event event = eventMessage->getEvent(); - switch(event){ + Event event = eventMessage->getEvent(); + switch (event) { case PdecHandler::BIT_LOCK_PDEC: { - handleBitLockEvent(); - break; + handleBitLockEvent(); + break; } case PdecHandler::CARRIER_LOCK: { - handleCarrierLockEvent(); - break; + handleCarrierLockEvent(); + break; } default: - sif::debug << "CCSDSHandler::handleEvent: Did not subscribe to this event" - << std::endl; - break; - } + sif::debug << "CCSDSHandler::handleEvent: Did not subscribe to this event" << std::endl; + break; + } } void CCSDSHandler::handleBitLockEvent() { - if(transmitterCountdown.isBusy()) { - // Transmitter already enabled - return; - } - enableTransmit(); + if (transmitterCountdown.isBusy()) { + // Transmitter already enabled + return; + } + enableTransmit(); } void CCSDSHandler::handleCarrierLockEvent() { - if (!enableTxWhenCarrierLock) { - return; - } - enableTransmit(); + if (!enableTxWhenCarrierLock) { + return; + } + enableTransmit(); } void CCSDSHandler::forwardLinkstate() { - VirtualChannelMapIter iter; - for(iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { - iter->second->setLinkState(linkState); - } + VirtualChannelMapIter iter; + for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { + iter->second->setLinkState(linkState); + } } void CCSDSHandler::enableTransmit() { - if(transmitterCountdown.isBusy()) { - // Transmitter already enabled - return; - } - transmitterCountdown.setTimeout(TRANSMITTER_TIMEOUT); + if (transmitterCountdown.isBusy()) { + // Transmitter already enabled + return; + } + transmitterCountdown.setTimeout(TRANSMITTER_TIMEOUT); #if BOARD_TE0720 == 0 - gpioIF->pullHigh(enTxClock); - gpioIF->pullHigh(enTxData); + gpioIF->pullHigh(enTxClock); + gpioIF->pullHigh(enTxData); #endif /* BOARD_TE0720 == 0 */ - linkState = UP; - // Set link state of all virtual channels to link up - forwardLinkstate(); + linkState = UP; + // Set link state of all virtual channels to link up + forwardLinkstate(); } void CCSDSHandler::checkTxTimer() { - if(linkState == DOWN) { - return; - } - if (transmitterCountdown.hasTimedOut()) { - disableTransmit(); - } + if (linkState == DOWN) { + return; + } + if (transmitterCountdown.hasTimedOut()) { + disableTransmit(); + } } void CCSDSHandler::disableTransmit() { #if BOARD_TE0720 == 0 - gpioIF->pullLow(enTxClock); - gpioIF->pullLow(enTxData); + gpioIF->pullLow(enTxClock); + gpioIF->pullLow(enTxData); #endif /* BOARD_TE0720 == 0 */ - linkState = DOWN; - forwardLinkstate(); - transmitterCountdown.setTimeout(0); + linkState = DOWN; + forwardLinkstate(); + transmitterCountdown.setTimeout(0); } diff --git a/mission/tmtc/CCSDSHandler.h b/mission/tmtc/CCSDSHandler.h index 6fb6168b..8203b807 100644 --- a/mission/tmtc/CCSDSHandler.h +++ b/mission/tmtc/CCSDSHandler.h @@ -1,22 +1,23 @@ #ifndef CCSDSHANDLER_H_ #define CCSDSHANDLER_H_ +#include + #include "OBSWConfig.h" -#include "fsfw/objectmanager/SystemObject.h" -#include "fsfw/tasks/ExecutableObjectIF.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" -#include "fsfw/tmtcservices/AcceptsTelemetryIF.h" -#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" -#include "fsfw/parameters/ParameterHelper.h" +#include "VirtualChannel.h" #include "fsfw/action/ActionHelper.h" #include "fsfw/action/HasActionsIF.h" -#include "fsfw/timemanager/Countdown.h" #include "fsfw/events/EventMessage.h" -#include "linux/obc/TxRateSetterIF.h" -#include "fsfw_hal/common/gpio/gpioDefinitions.h" +#include "fsfw/objectmanager/SystemObject.h" +#include "fsfw/parameters/ParameterHelper.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/tasks/ExecutableObjectIF.h" +#include "fsfw/timemanager/Countdown.h" +#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" +#include "fsfw/tmtcservices/AcceptsTelemetryIF.h" #include "fsfw_hal/common/gpio/GpioIF.h" -#include "VirtualChannel.h" -#include +#include "fsfw_hal/common/gpio/gpioDefinitions.h" +#include "linux/obc/TxRateSetterIF.h" /** * @brief This class handles the data exchange with the CCSDS IP cores implemented in the @@ -24,145 +25,144 @@ * * @author J. Meier */ -class CCSDSHandler: public SystemObject, - public ExecutableObjectIF, - public AcceptsTelemetryIF, - public AcceptsTelecommandsIF, - public HasReturnvaluesIF, - public ReceivesParameterMessagesIF, - public HasActionsIF { -public: +class CCSDSHandler : public SystemObject, + public ExecutableObjectIF, + public AcceptsTelemetryIF, + public AcceptsTelecommandsIF, + public HasReturnvaluesIF, + public ReceivesParameterMessagesIF, + public HasActionsIF { + public: + using VcId_t = uint8_t; - using VcId_t = uint8_t; + /** + * @brief Constructor + * + * @param objectId Object ID of the CCSDS handler + * @param ptmeId Object ID of the PTME object providing access to the PTME IP Core. + * @param tcDestination Object ID of object handling received TC space packets + * @param txRateSetter Object providing the functionality to switch the input bitrate of + * the S-Band transceiver. + * @param gpioIF Required to enable TX data and TX clock RS485 transceiver chips. + * @param enTxClock GPIO ID of RS485 tx clock enable + * @param enTxData GPIO ID of RS485 tx data enable + */ + CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination, + TxRateSetterIF* txRateSetterIF, GpioIF* gpioIF, gpioId_t enTxClock, + gpioId_t enTxData); - /** - * @brief Constructor - * - * @param objectId Object ID of the CCSDS handler - * @param ptmeId Object ID of the PTME object providing access to the PTME IP Core. - * @param tcDestination Object ID of object handling received TC space packets - * @param txRateSetter Object providing the functionality to switch the input bitrate of - * the S-Band transceiver. - * @param gpioIF Required to enable TX data and TX clock RS485 transceiver chips. - * @param enTxClock GPIO ID of RS485 tx clock enable - * @param enTxData GPIO ID of RS485 tx data enable - */ - CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination, - TxRateSetterIF* txRateSetterIF, GpioIF* gpioIF, gpioId_t enTxClock, gpioId_t enTxData); + ~CCSDSHandler(); - ~CCSDSHandler(); + ReturnValue_t performOperation(uint8_t operationCode = 0) override; + ReturnValue_t initialize(); + MessageQueueId_t getCommandQueue() const; - ReturnValue_t performOperation(uint8_t operationCode = 0) override; - ReturnValue_t initialize(); - MessageQueueId_t getCommandQueue() const; + /** + * @brief Function to add a virtual channel + * + * @param virtualChannelId ID of the virtual channel to add + * @param virtualChannel Pointer to virtual channel object + */ + void addVirtualChannel(VcId_t virtualChannelId, VirtualChannel* virtualChannel); - /** - * @brief Function to add a virtual channel - * - * @param virtualChannelId ID of the virtual channel to add - * @param virtualChannel Pointer to virtual channel object - */ - void addVirtualChannel(VcId_t virtualChannelId, VirtualChannel* virtualChannel); + MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0); + ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueIdentifier, + ParameterWrapper* parameterWrapper, const ParameterWrapper* newValues, + uint16_t startAtIndex); - MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0); - ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueIdentifier, - ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues, - uint16_t startAtIndex); + uint16_t getIdentifier() override; + MessageQueueId_t getRequestQueue() override; - uint16_t getIdentifier() override; - MessageQueueId_t getRequestQueue() override; + virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size); - virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size); + private: + static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_HANDLER; -private: + static const uint32_t QUEUE_SIZE = common::CCSDS_HANDLER_QUEUE_SIZE; - static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_HANDLER; + static const ActionId_t SET_LOW_RATE = 0; + static const ActionId_t SET_HIGH_RATE = 1; + static const ActionId_t EN_TRANSMITTER = 2; + static const ActionId_t DIS_TRANSMITTER = 3; - static const uint32_t QUEUE_SIZE = common::CCSDS_HANDLER_QUEUE_SIZE; - - static const ActionId_t SET_LOW_RATE = 0; - static const ActionId_t SET_HIGH_RATE = 1; - static const ActionId_t EN_TRANSMITTER = 2; - static const ActionId_t DIS_TRANSMITTER = 3; - - //! [EXPORT] : [COMMENT] Received action message with unknown action id - static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xA0); + //! [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 + // 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 /* TMTC_TEST_SETUP == 0 */ - static const bool UP = true; - static const bool DOWN = false; + static const bool UP = true; + static const bool DOWN = false; - using VirtualChannelMap = std::unordered_map; - using VirtualChannelMapIter = VirtualChannelMap::iterator; + using VirtualChannelMap = std::unordered_map; + using VirtualChannelMapIter = VirtualChannelMap::iterator; - VirtualChannelMap virtualChannelMap; + VirtualChannelMap virtualChannelMap; - // Object ID of PTME object - object_id_t ptmeId; + // Object ID of PTME object + object_id_t ptmeId; - object_id_t tcDestination; + object_id_t tcDestination; - MessageQueueIF* commandQueue = nullptr; - MessageQueueIF* eventQueue = nullptr; + MessageQueueIF* commandQueue = nullptr; + MessageQueueIF* eventQueue = nullptr; - ParameterHelper parameterHelper; + ParameterHelper parameterHelper; - ActionHelper actionHelper; + ActionHelper actionHelper; - MessageQueueId_t tcDistributorQueueId; + MessageQueueId_t tcDistributorQueueId; - TxRateSetterIF* txRateSetterIF = nullptr; + TxRateSetterIF* txRateSetterIF = nullptr; - GpioIF* gpioIF = nullptr; - gpioId_t enTxClock = gpio::NO_GPIO; - gpioId_t enTxData = gpio::NO_GPIO; + GpioIF* gpioIF = nullptr; + gpioId_t enTxClock = gpio::NO_GPIO; + gpioId_t enTxData = gpio::NO_GPIO; - // Countdown to disable transmitter after 15 minutes - Countdown transmitterCountdown; + // Countdown to disable transmitter after 15 minutes + Countdown transmitterCountdown; - // When true transmitting is started as soon as carrier lock has been detected - bool enableTxWhenCarrierLock = false; + // When true transmitting is started as soon as carrier lock has been detected + bool enableTxWhenCarrierLock = false; - bool linkState = DOWN; + bool linkState = DOWN; - void readCommandQueue(void); - void handleTelemetry(); - void handleTelecommands(); - void checkEvents(); - void handleEvent(EventMessage* eventMessage); + void readCommandQueue(void); + void handleTelemetry(); + void handleTelecommands(); + void checkEvents(); + void handleEvent(EventMessage* eventMessage); - void handleBitLockEvent(); - void handleCarrierLockEvent(); + void handleBitLockEvent(); + void handleCarrierLockEvent(); - /** - * @brief Forward link state to virtual channels. - */ - void forwardLinkstate(); + /** + * @brief Forward link state to virtual channels. + */ + void forwardLinkstate(); - /** - * @brief Starts transmit timer and enables transmitter. - */ - void enableTransmit(); + /** + * @brief Starts transmit timer and enables transmitter. + */ + void enableTransmit(); - /** - * @brief Checks Tx timer for timeout and disables RS485 tx clock and tx data in case - * timer has expired. - */ - void checkTxTimer(); + /** + * @brief Checks Tx timer for timeout and disables RS485 tx clock and tx data in case + * timer has expired. + */ + void checkTxTimer(); - /** - * @brief Disables the transmitter by pulling the enable tx clock and tx data pin of the - * RS485 transceiver chips to high. - */ - void disableTransmit(); + /** + * @brief Disables the transmitter by pulling the enable tx clock and tx data pin of the + * RS485 transceiver chips to high. + */ + void disableTransmit(); }; #endif /* CCSDSHANDLER_H_ */ diff --git a/mission/tmtc/VirtualChannel.cpp b/mission/tmtc/VirtualChannel.cpp index 0273f5ce..5b9387fd 100644 --- a/mission/tmtc/VirtualChannel.cpp +++ b/mission/tmtc/VirtualChannel.cpp @@ -1,69 +1,65 @@ -#include "CCSDSHandler.h" #include "VirtualChannel.h" + +#include "CCSDSHandler.h" #include "OBSWConfig.h" - -#include "fsfw/serviceinterface/ServiceInterfaceStream.h" -#include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/tmtcservices/TmTcMessage.h" #include "fsfw/ipc/QueueFactory.h" +#include "fsfw/objectmanager/ObjectManager.h" +#include "fsfw/serviceinterface/ServiceInterfaceStream.h" +#include "fsfw/tmtcservices/TmTcMessage.h" - -VirtualChannel::VirtualChannel(uint8_t vcId, uint32_t tmQueueDepth) : - vcId(vcId) { - tmQueue = QueueFactory::instance()->createMessageQueue(tmQueueDepth, - MessageQueueMessage::MAX_MESSAGE_SIZE); +VirtualChannel::VirtualChannel(uint8_t vcId, uint32_t tmQueueDepth) : vcId(vcId) { + tmQueue = QueueFactory::instance()->createMessageQueue(tmQueueDepth, + MessageQueueMessage::MAX_MESSAGE_SIZE); } ReturnValue_t VirtualChannel::initialize() { - tmStore = ObjectManager::instance()->get(objects::TM_STORE); - if(tmStore == nullptr) { - sif::error << "VirtualChannel::initialize: Failed to get tm store" << std::endl; - return RETURN_FAILED; - } - return RETURN_OK; + tmStore = ObjectManager::instance()->get(objects::TM_STORE); + if (tmStore == nullptr) { + sif::error << "VirtualChannel::initialize: Failed to get tm store" << std::endl; + return RETURN_FAILED; + } + return RETURN_OK; } ReturnValue_t VirtualChannel::performOperation() { - ReturnValue_t result = RETURN_OK; - TmTcMessage message; + ReturnValue_t result = RETURN_OK; + TmTcMessage message; - while(tmQueue->receiveMessage(&message) == RETURN_OK) { - store_address_t storeId = message.getStorageId(); - const uint8_t* data = nullptr; - size_t size = 0; - result = tmStore->getData(storeId, &data, &size); - if (result != RETURN_OK) { - sif::warning << "VirtualChannel::performOperation: Failed to read data from IPC store" - << std::endl; - tmStore->deleteData(storeId); - return result; - } + while (tmQueue->receiveMessage(&message) == RETURN_OK) { + store_address_t storeId = message.getStorageId(); + const uint8_t* data = nullptr; + size_t size = 0; + result = tmStore->getData(storeId, &data, &size); + if (result != RETURN_OK) { + sif::warning << "VirtualChannel::performOperation: Failed to read data from IPC store" + << std::endl; + tmStore->deleteData(storeId); + return result; + } - if (linkIsUp) { - result = ptme->writeToVc(vcId, data, size); - } + if (linkIsUp) { + result = ptme->writeToVc(vcId, data, size); + } - tmStore->deleteData(storeId); + tmStore->deleteData(storeId); - if (result != RETURN_OK) { - return result; - } - } - return result; + if (result != RETURN_OK) { + return result; + } + } + return result; } MessageQueueId_t VirtualChannel::getReportReceptionQueue(uint8_t virtualChannel) { - return tmQueue->getId(); + return tmQueue->getId(); } void VirtualChannel::setPtmeObject(PtmeIF* ptme_) { - if (ptme_ == nullptr) { - sif::warning << "VirtualChannel::setPtmeObject: Invalid ptme object" << std::endl; - return; - } - ptme = ptme_; + if (ptme_ == nullptr) { + sif::warning << "VirtualChannel::setPtmeObject: Invalid ptme object" << std::endl; + return; + } + ptme = ptme_; } -void VirtualChannel::setLinkState(bool linkIsUp_) { - linkIsUp = linkIsUp_; -} +void VirtualChannel::setLinkState(bool linkIsUp_) { linkIsUp = linkIsUp_; } diff --git a/mission/tmtc/VirtualChannel.h b/mission/tmtc/VirtualChannel.h index c6e2eb6d..c6d999ef 100644 --- a/mission/tmtc/VirtualChannel.h +++ b/mission/tmtc/VirtualChannel.h @@ -1,54 +1,54 @@ #ifndef VIRTUALCHANNEL_H_ #define VIRTUALCHANNEL_H_ -#include "OBSWConfig.h" -#include "fsfw/tmtcservices/AcceptsTelemetryIF.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include #include +#include "OBSWConfig.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/tmtcservices/AcceptsTelemetryIF.h" + /** * @brief This class represents a virtual channel. Sending a tm message to an object of this class * will forward the tm packet to the respective virtual channel of the PTME IP Core. * * @author J. Meier */ -class VirtualChannel: public AcceptsTelemetryIF, public HasReturnvaluesIF { - public: - /** - * @brief Constructor - * - * @param vcId The virtual channel id assigned to this object - * @param tmQueueDepth Queue depth of queue receiving telemetry from other objects - */ - VirtualChannel(uint8_t vcId, uint32_t tmQueueDepth); +class VirtualChannel : public AcceptsTelemetryIF, public HasReturnvaluesIF { + public: + /** + * @brief Constructor + * + * @param vcId The virtual channel id assigned to this object + * @param tmQueueDepth Queue depth of queue receiving telemetry from other objects + */ + VirtualChannel(uint8_t vcId, uint32_t tmQueueDepth); - ReturnValue_t initialize(); - MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) override; - ReturnValue_t performOperation(); + ReturnValue_t initialize(); + MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) override; + ReturnValue_t performOperation(); - /** - * @brief Sets the PTME object which handles access to the PTME IP Core. - * - * @param ptme Pointer to ptme object - */ - void setPtmeObject(PtmeIF* ptme_); + /** + * @brief Sets the PTME object which handles access to the PTME IP Core. + * + * @param ptme Pointer to ptme object + */ + void setPtmeObject(PtmeIF* ptme_); - /** - * @brief Can be used by the owner to set the link state. Packets will be discarded if link - * to ground station is down. - */ - void setLinkState(bool linkIsUp_); + /** + * @brief Can be used by the owner to set the link state. Packets will be discarded if link + * to ground station is down. + */ + void setLinkState(bool linkIsUp_); -private: + private: + PtmeIF* ptme = nullptr; + MessageQueueIF* tmQueue = nullptr; + uint8_t vcId; - PtmeIF* ptme = nullptr; - MessageQueueIF* tmQueue = nullptr; - uint8_t vcId; + bool linkIsUp = false; - bool linkIsUp = false; - - StorageManagerIF* tmStore = nullptr; + StorageManagerIF* tmStore = nullptr; }; #endif /* VIRTUALCHANNEL_H_ */ diff --git a/mission/utility/InitMission.h b/mission/utility/InitMission.h index b4a83a1e..dc131981 100644 --- a/mission/utility/InitMission.h +++ b/mission/utility/InitMission.h @@ -8,15 +8,15 @@ namespace initmission { void printAddObjectError(const char* name, object_id_t objectId) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "InitMission::printAddError: Adding object " << name << " with object ID 0x" - << std::hex << std::setfill('0') << std::setw(8) << objectId - << " failed!" << std::dec << std::endl; + sif::error << "InitMission::printAddError: Adding object " << name << " with object ID 0x" + << std::hex << std::setfill('0') << std::setw(8) << objectId << " failed!" << std::dec + << std::endl; #else - sif::printError("InitMission::printAddError: Adding object %s with object ID 0x%08x failed!\n" , - name, objectId); + sif::printError("InitMission::printAddError: Adding object %s with object ID 0x%08x failed!\n", + name, objectId); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ } -} +} // namespace initmission #endif /* MISSION_UTILITY_INITMISSION_H_ */ diff --git a/mission/utility/Timestamp.cpp b/mission/utility/Timestamp.cpp index c0848a59..095bd28c 100644 --- a/mission/utility/Timestamp.cpp +++ b/mission/utility/Timestamp.cpp @@ -1,28 +1,22 @@ #include "Timestamp.h" + #include "fsfw/serviceinterface/ServiceInterfaceStream.h" Timestamp::Timestamp() { - ReturnValue_t result = Clock::getDateAndTime(&time); - if (result != RETURN_OK) { - sif::warning << "Timestamp::Timestamp: Failed to get time" << std::endl; - } + ReturnValue_t result = Clock::getDateAndTime(&time); + if (result != RETURN_OK) { + sif::warning << "Timestamp::Timestamp: Failed to get time" << std::endl; + } } -Timestamp::~Timestamp() { -} +Timestamp::~Timestamp() {} std::string Timestamp::str() { - timestamp << std::to_string(time.year) << "-" - << std::setw(2) << std::setfill('0') - << std::to_string(time.month) << "-" - << std::setw(2) << std::setfill('0') - << std::to_string(time.day) << "--" - << std::setw(2) << std::setfill('0') - << std::to_string(time.hour) << "-" - << std::setw(2) << std::setfill('0') - << std::to_string(time.minute) << "-" - << std::setw(2) << std::setfill('0') - << std::to_string(time.second) << "--"; - return timestamp.str(); + timestamp << std::to_string(time.year) << "-" << std::setw(2) << std::setfill('0') + << std::to_string(time.month) << "-" << std::setw(2) << std::setfill('0') + << std::to_string(time.day) << "--" << std::setw(2) << std::setfill('0') + << std::to_string(time.hour) << "-" << std::setw(2) << std::setfill('0') + << std::to_string(time.minute) << "-" << std::setw(2) << std::setfill('0') + << std::to_string(time.second) << "--"; + return timestamp.str(); } - diff --git a/mission/utility/Timestamp.h b/mission/utility/Timestamp.h index 7146de53..4f783437 100644 --- a/mission/utility/Timestamp.h +++ b/mission/utility/Timestamp.h @@ -1,11 +1,12 @@ #ifndef MISSION_UTILITY_TIMESTAMP_H_ #define MISSION_UTILITY_TIMESTAMP_H_ -#include -#include #include -#include "fsfw/timemanager/Clock.h" +#include +#include + #include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/timemanager/Clock.h" /** * @brief This class generates timestamps for files. @@ -13,18 +14,18 @@ * @author J. Meier */ class Timestamp : public HasReturnvaluesIF { -public: - Timestamp(); - virtual ~Timestamp(); + public: + Timestamp(); + virtual ~Timestamp(); - /** - * @brief Returns the timestamp string - */ - std::string str(); + /** + * @brief Returns the timestamp string + */ + std::string str(); -private: - std::stringstream timestamp; - Clock::TimeOfDay_t time; + private: + std::stringstream timestamp; + Clock::TimeOfDay_t time; }; #endif /* MISSION_UTILITY_TIMESTAMP_H_ */ diff --git a/mission/utility/TmFunnel.cpp b/mission/utility/TmFunnel.cpp index 4b9eebdf..5577f5fa 100644 --- a/mission/utility/TmFunnel.cpp +++ b/mission/utility/TmFunnel.cpp @@ -1,122 +1,118 @@ -#include "OBSWConfig.h" #include -#include #include #include +#include #include +#include "OBSWConfig.h" + object_id_t TmFunnel::downlinkDestination = objects::NO_OBJECT; object_id_t TmFunnel::storageDestination = objects::NO_OBJECT; -TmFunnel::TmFunnel(object_id_t objectId, uint32_t messageDepth): - SystemObject(objectId), messageDepth(messageDepth) { - tmQueue = QueueFactory::instance()->createMessageQueue(messageDepth, - MessageQueueMessage::MAX_MESSAGE_SIZE); - storageQueue = QueueFactory::instance()->createMessageQueue(messageDepth, - MessageQueueMessage::MAX_MESSAGE_SIZE); +TmFunnel::TmFunnel(object_id_t objectId, uint32_t messageDepth) + : SystemObject(objectId), messageDepth(messageDepth) { + tmQueue = QueueFactory::instance()->createMessageQueue(messageDepth, + MessageQueueMessage::MAX_MESSAGE_SIZE); + storageQueue = QueueFactory::instance()->createMessageQueue( + messageDepth, MessageQueueMessage::MAX_MESSAGE_SIZE); } -TmFunnel::~TmFunnel() { -} +TmFunnel::~TmFunnel() {} MessageQueueId_t TmFunnel::getReportReceptionQueue(uint8_t virtualChannel) { - return tmQueue->getId(); + return tmQueue->getId(); } ReturnValue_t TmFunnel::performOperation(uint8_t operationCode) { - TmTcMessage currentMessage; - ReturnValue_t status = tmQueue->receiveMessage(¤tMessage); - while(status == HasReturnvaluesIF::RETURN_OK) - { - status = handlePacket(¤tMessage); - if(status != HasReturnvaluesIF::RETURN_OK){ - break; - } - status = tmQueue->receiveMessage(¤tMessage); - } + TmTcMessage currentMessage; + ReturnValue_t status = tmQueue->receiveMessage(¤tMessage); + while (status == HasReturnvaluesIF::RETURN_OK) { + status = handlePacket(¤tMessage); + if (status != HasReturnvaluesIF::RETURN_OK) { + break; + } + status = tmQueue->receiveMessage(¤tMessage); + } - if (status == MessageQueueIF::EMPTY) { - return HasReturnvaluesIF::RETURN_OK; - } - else { - return status; - } + if (status == MessageQueueIF::EMPTY) { + return HasReturnvaluesIF::RETURN_OK; + } else { + return status; + } } ReturnValue_t TmFunnel::handlePacket(TmTcMessage* message) { - uint8_t* packetData = nullptr; - size_t size = 0; - ReturnValue_t result = tmStore->modifyData(message->getStorageId(), - &packetData, &size); - if(result != HasReturnvaluesIF::RETURN_OK){ - return result; - } - TmPacketPusC packet(packetData); - packet.setPacketSequenceCount(this->sourceSequenceCount); - sourceSequenceCount++; - sourceSequenceCount = sourceSequenceCount % - SpacePacketBase::LIMIT_SEQUENCE_COUNT; - packet.setErrorControl(); + uint8_t* packetData = nullptr; + size_t size = 0; + ReturnValue_t result = tmStore->modifyData(message->getStorageId(), &packetData, &size); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + TmPacketPusC packet(packetData); + packet.setPacketSequenceCount(this->sourceSequenceCount); + sourceSequenceCount++; + sourceSequenceCount = sourceSequenceCount % SpacePacketBase::LIMIT_SEQUENCE_COUNT; + packet.setErrorControl(); - result = tmQueue->sendToDefault(message); - if(result != HasReturnvaluesIF::RETURN_OK){ - tmStore->deleteData(message->getStorageId()); - sif::error << "TmFunnel::handlePacket: Error sending to downlink " - "handler" << std::endl; - return result; - } + result = tmQueue->sendToDefault(message); + if (result != HasReturnvaluesIF::RETURN_OK) { + tmStore->deleteData(message->getStorageId()); + sif::error << "TmFunnel::handlePacket: Error sending to downlink " + "handler" + << std::endl; + return result; + } - if(storageDestination != objects::NO_OBJECT) { - result = storageQueue->sendToDefault(message); - if(result != HasReturnvaluesIF::RETURN_OK){ - tmStore->deleteData(message->getStorageId()); - sif::error << "TmFunnel::handlePacket: Error sending to storage " - "handler" << std::endl; - return result; - } - } - return result; + if (storageDestination != objects::NO_OBJECT) { + result = storageQueue->sendToDefault(message); + if (result != HasReturnvaluesIF::RETURN_OK) { + tmStore->deleteData(message->getStorageId()); + sif::error << "TmFunnel::handlePacket: Error sending to storage " + "handler" + << std::endl; + return result; + } + } + return result; } ReturnValue_t TmFunnel::initialize() { + tmStore = ObjectManager::instance()->get(objects::TM_STORE); + if (tmStore == nullptr) { + sif::error << "TmFunnel::initialize: TM store not set." << std::endl; + sif::error << "Make sure the tm store is set up properly" + " and implements StorageManagerIF" + << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - tmStore = ObjectManager::instance()->get(objects::TM_STORE); - if(tmStore == nullptr) { - sif::error << "TmFunnel::initialize: TM store not set." - << std::endl; - sif::error << "Make sure the tm store is set up properly" - " and implements StorageManagerIF" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } - - AcceptsTelemetryIF* tmTarget = - ObjectManager::instance()->get(downlinkDestination); - if(tmTarget == nullptr){ - sif::error << "TmFunnel::initialize: Downlink Destination not set." - << std::endl; - sif::error << "Make sure the downlink destination object is set up " - "properly and implements AcceptsTelemetryIF" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + AcceptsTelemetryIF* tmTarget = + ObjectManager::instance()->get(downlinkDestination); + if (tmTarget == nullptr) { + sif::error << "TmFunnel::initialize: Downlink Destination not set." << std::endl; + sif::error << "Make sure the downlink destination object is set up " + "properly and implements AcceptsTelemetryIF" + << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } #if OBSW_TM_TO_PTME == 1 - // Live TM will be sent via the virtual channel 0 - tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue(config::LIVE_TM)); + // Live TM will be sent via the virtual channel 0 + tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue(config::LIVE_TM)); #else - tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue()); + tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue()); #endif /* OBSW_TM_TO_PTME == 1 */ - // Storage destination is optional. - if(storageDestination == objects::NO_OBJECT) { - return SystemObject::initialize(); - } + // Storage destination is optional. + if (storageDestination == objects::NO_OBJECT) { + return SystemObject::initialize(); + } - AcceptsTelemetryIF* storageTarget = - ObjectManager::instance()->get(storageDestination); - if(storageTarget != nullptr) { - storageQueue->setDefaultDestination( - storageTarget->getReportReceptionQueue()); - } + AcceptsTelemetryIF* storageTarget = + ObjectManager::instance()->get(storageDestination); + if (storageTarget != nullptr) { + storageQueue->setDefaultDestination(storageTarget->getReportReceptionQueue()); + } - return SystemObject::initialize(); + return SystemObject::initialize(); } diff --git a/mission/utility/TmFunnel.h b/mission/utility/TmFunnel.h index b85a09e0..013e0ebc 100644 --- a/mission/utility/TmFunnel.h +++ b/mission/utility/TmFunnel.h @@ -1,13 +1,13 @@ #ifndef MISSION_UTILITY_TMFUNNEL_H_ #define MISSION_UTILITY_TMFUNNEL_H_ +#include #include #include #include -#include #include -namespace Factory{ +namespace Factory { void setStaticFrameworkObjectIds(); } @@ -19,32 +19,30 @@ void setStaticFrameworkObjectIds(); * @ingroup utility * @author J. Meier */ -class TmFunnel: public AcceptsTelemetryIF, - public ExecutableObjectIF, - public SystemObject { - friend void (Factory::setStaticFrameworkObjectIds)(); -public: - TmFunnel(object_id_t objectId, uint32_t messageDepth = 20); - virtual ~TmFunnel(); +class TmFunnel : public AcceptsTelemetryIF, public ExecutableObjectIF, public SystemObject { + friend void(Factory::setStaticFrameworkObjectIds)(); - virtual MessageQueueId_t getReportReceptionQueue( - uint8_t virtualChannel = 0) override; - virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; - virtual ReturnValue_t initialize() override; + public: + TmFunnel(object_id_t objectId, uint32_t messageDepth = 20); + virtual ~TmFunnel(); -protected: - static object_id_t downlinkDestination; - static object_id_t storageDestination; + virtual MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) override; + virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; + virtual ReturnValue_t initialize() override; -private: - uint16_t sourceSequenceCount = 0; - MessageQueueIF* tmQueue = nullptr; - MessageQueueIF* storageQueue = nullptr; + protected: + static object_id_t downlinkDestination; + static object_id_t storageDestination; - StorageManagerIF* tmStore = nullptr; - uint32_t messageDepth = 0; + private: + uint16_t sourceSequenceCount = 0; + MessageQueueIF* tmQueue = nullptr; + MessageQueueIF* storageQueue = nullptr; - ReturnValue_t handlePacket(TmTcMessage* message); + StorageManagerIF* tmStore = nullptr; + uint32_t messageDepth = 0; + + ReturnValue_t handlePacket(TmTcMessage* message); }; #endif /* MISSION_UTILITY_TMFUNNEL_H_ */ diff --git a/scripts/apply-clang-format.sh b/scripts/apply-clang-format.sh index 6d77c6e9..55a31487 100755 --- a/scripts/apply-clang-format.sh +++ b/scripts/apply-clang-format.sh @@ -3,7 +3,7 @@ if [[ ! -f README.md ]]; then cd .. fi -find ./mission -iname *.h o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i +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 diff --git a/test/DummyParameter.h b/test/DummyParameter.h index b8da7275..410f0958 100644 --- a/test/DummyParameter.h +++ b/test/DummyParameter.h @@ -1,26 +1,24 @@ #ifndef BSP_Q7S_CORE_NVMPARAMS_PARAMETERDEFINITIONS_H_ #define BSP_Q7S_CORE_NVMPARAMS_PARAMETERDEFINITIONS_H_ -#include "mission/memory/NVMParameterBase.h" +#include #include -#include +#include "mission/memory/NVMParameterBase.h" -class DummyParameter: public NVMParameterBase { -public: - static constexpr char DUMMY_KEY_PARAM_1[] = "dummy1"; - static constexpr char DUMMY_KEY_PARAM_2[] = "dummy2"; +class DummyParameter : public NVMParameterBase { + public: + static constexpr char DUMMY_KEY_PARAM_1[] = "dummy1"; + static constexpr char DUMMY_KEY_PARAM_2[] = "dummy2"; - DummyParameter(std::string mountPrefix, std::string jsonFileName): - NVMParameterBase(mountPrefix + "/conf/" + jsonFileName), - mountPrefix(mountPrefix) { - insertValue(DUMMY_KEY_PARAM_1, 1); - insertValue(DUMMY_KEY_PARAM_2, "blablub"); - } + DummyParameter(std::string mountPrefix, std::string jsonFileName) + : NVMParameterBase(mountPrefix + "/conf/" + jsonFileName), mountPrefix(mountPrefix) { + insertValue(DUMMY_KEY_PARAM_1, 1); + insertValue(DUMMY_KEY_PARAM_2, "blablub"); + } -private: - std::string mountPrefix; + private: + std::string mountPrefix; }; - #endif /* BSP_Q7S_CORE_NVMPARAMS_PARAMETERDEFINITIONS_H_ */ diff --git a/test/testtasks/PusTcInjector.cpp b/test/testtasks/PusTcInjector.cpp index 90f2ac75..82b1cb1c 100644 --- a/test/testtasks/PusTcInjector.cpp +++ b/test/testtasks/PusTcInjector.cpp @@ -1,29 +1,29 @@ -#include - +#include +#include #include +#include +#include #include #include -#include -#include -#include -#include +#include -PusTcInjector::PusTcInjector(object_id_t objectId, object_id_t destination, - object_id_t tcStore, uint16_t defaultApid): SystemObject(objectId), - defaultApid(defaultApid), destination(destination), tcStoreId(tcStore) { -} +PusTcInjector::PusTcInjector(object_id_t objectId, object_id_t destination, object_id_t tcStore, + uint16_t defaultApid) + : SystemObject(objectId), + defaultApid(defaultApid), + destination(destination), + tcStoreId(tcStore) {} -PusTcInjector::~PusTcInjector() { -} +PusTcInjector::~PusTcInjector() {} -//ReturnValue_t PusTcInjector::injectPusTelecommand(uint8_t service, +// ReturnValue_t PusTcInjector::injectPusTelecommand(uint8_t service, // uint8_t subservice,const uint8_t* appData, size_t appDataLen) { // return injectPusTelecommand(service, subservice, defaultApid, appData, // appDataLen); -//} +// } // TODO: ACK flags -//ReturnValue_t PusTcInjector::injectPusTelecommand(uint8_t service, +// ReturnValue_t PusTcInjector::injectPusTelecommand(uint8_t service, // uint8_t subservice,uint16_t apid, const uint8_t* appData, // size_t appDataLen) { // // Prepare TC packet. Store into TC store immediately. @@ -44,24 +44,22 @@ PusTcInjector::~PusTcInjector() { //} ReturnValue_t PusTcInjector::initialize() { - // Prepare message queue which is used to send telecommands. - injectionQueue = QueueFactory::instance()-> - createMessageQueue(INJECTION_QUEUE_DEPTH); - AcceptsTelecommandsIF* targetQueue = ObjectManager::instance()-> - get(destination); - if(targetQueue == nullptr) { - sif::error << "PusTcInjector: CCSDS distributor not initialized yet!" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } - else { - injectionQueue->setDefaultDestination(targetQueue->getRequestQueue()); - } + // Prepare message queue which is used to send telecommands. + injectionQueue = QueueFactory::instance()->createMessageQueue(INJECTION_QUEUE_DEPTH); + AcceptsTelecommandsIF* targetQueue = + ObjectManager::instance()->get(destination); + if (targetQueue == nullptr) { + sif::error << "PusTcInjector: CCSDS distributor not initialized yet!" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } else { + injectionQueue->setDefaultDestination(targetQueue->getRequestQueue()); + } - // Prepare store used to store TC messages - tcStore = ObjectManager::instance()->get(tcStoreId); - if(tcStore == nullptr) { - sif::error << "PusTcInjector: TC Store not initialized!" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + // Prepare store used to store TC messages + tcStore = ObjectManager::instance()->get(tcStoreId); + if (tcStore == nullptr) { + sif::error << "PusTcInjector: TC Store not initialized!" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } diff --git a/test/testtasks/PusTcInjector.h b/test/testtasks/PusTcInjector.h index df67e403..4d1cea7e 100644 --- a/test/testtasks/PusTcInjector.h +++ b/test/testtasks/PusTcInjector.h @@ -3,70 +3,71 @@ #include #include #include + #include -class PusTcInjector: public SystemObject { -public: - static constexpr uint8_t INJECTION_QUEUE_DEPTH = 10; - const uint16_t defaultApid; +class PusTcInjector : public SystemObject { + public: + static constexpr uint8_t INJECTION_QUEUE_DEPTH = 10; + const uint16_t defaultApid; - /** - * Initialize a software telecommand injector by supplying object IDs to - * various helper objects which must exist before calling initialiez() - * @param objectId ID of PUS telecommand injector - * @param destination ID of destination, which has to implement - * AcceptsTelecommandIF. - * @param tcStore ID of telecommand store, which has to implement - * StorageManagerIF. - * @param defaultApid Default APID which will be used if an injection - * without an APID is requested. - */ - PusTcInjector(object_id_t objectId, object_id_t destination, - object_id_t tcStore, uint16_t defaultApid); - /** - * This has to be called before using the PusTcInjector. - * Call Not necessary when using a factory and the object manager. - * @return -@c RETURN_OK for successfull init - * -@c ObjectManagerIF::CHILD_INIT_FAILED otherwise - */ - ReturnValue_t initialize() override; + /** + * Initialize a software telecommand injector by supplying object IDs to + * various helper objects which must exist before calling initialiez() + * @param objectId ID of PUS telecommand injector + * @param destination ID of destination, which has to implement + * AcceptsTelecommandIF. + * @param tcStore ID of telecommand store, which has to implement + * StorageManagerIF. + * @param defaultApid Default APID which will be used if an injection + * without an APID is requested. + */ + PusTcInjector(object_id_t objectId, object_id_t destination, object_id_t tcStore, + uint16_t defaultApid); + /** + * This has to be called before using the PusTcInjector. + * Call Not necessary when using a factory and the object manager. + * @return -@c RETURN_OK for successfull init + * -@c ObjectManagerIF::CHILD_INIT_FAILED otherwise + */ + ReturnValue_t initialize() override; - virtual~ PusTcInjector(); + virtual ~PusTcInjector(); - /** - * Can be used to inject a telecommand by supplying service, subservice - * and optional application data and its length. - * Default APID will be used. - * @param service PUS service type - * @param subservice PUS subservice type - * @param appData Pointer to application data - * @param appDataLen Length of application data - * @return - */ - //ReturnValue_t injectPusTelecommand(uint8_t service, uint8_t subservice, - // const uint8_t* appData = nullptr, size_t appDataLen = 0); + /** + * Can be used to inject a telecommand by supplying service, subservice + * and optional application data and its length. + * Default APID will be used. + * @param service PUS service type + * @param subservice PUS subservice type + * @param appData Pointer to application data + * @param appDataLen Length of application data + * @return + */ + // ReturnValue_t injectPusTelecommand(uint8_t service, uint8_t subservice, + // const uint8_t* appData = nullptr, size_t appDataLen = 0); - /** - * Provides the same functionality while also setting a user defined APID. - * @param service PUS service type - * @param subservice PUS subservice type - * @param apid Custom APID to, - * @param appData Pointer to application data - * @param appDataLen Length of application data - * @return - */ - //ReturnValue_t injectPusTelecommand(uint8_t service, uint8_t subservice, - // uint16_t apid, const uint8_t* appData = nullptr, - // size_t appDataLen = 0); -private: - MessageQueueIF* injectionQueue = nullptr; - StorageManagerIF *tcStore = nullptr; + /** + * Provides the same functionality while also setting a user defined APID. + * @param service PUS service type + * @param subservice PUS subservice type + * @param apid Custom APID to, + * @param appData Pointer to application data + * @param appDataLen Length of application data + * @return + */ + // ReturnValue_t injectPusTelecommand(uint8_t service, uint8_t subservice, + // uint16_t apid, const uint8_t* appData = nullptr, + // size_t appDataLen = 0); + private: + MessageQueueIF* injectionQueue = nullptr; + StorageManagerIF* tcStore = nullptr; - /* Cached for initialize function */ - object_id_t destination = 0; - object_id_t tcStoreId = 0; + /* Cached for initialize function */ + object_id_t destination = 0; + object_id_t tcStoreId = 0; - uint16_t sequenceCount = 0; + uint16_t sequenceCount = 0; }; #endif /* TEST_TESTTASKS_PUSTCINJECTOR_H_ */ diff --git a/test/testtasks/TestTask.cpp b/test/testtasks/TestTask.cpp index 6a90cc08..911767af 100644 --- a/test/testtasks/TestTask.cpp +++ b/test/testtasks/TestTask.cpp @@ -1,45 +1,43 @@ #include "TestTask.h" -#include "OBSWConfig.h" +#include +#include #include #include -#include #include -#include #include #include +#include "OBSWConfig.h" -EiveTestTask::EiveTestTask(object_id_t objectId_): TestTask(objectId_), testMode(testModes::A) { - IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); +EiveTestTask::EiveTestTask(object_id_t objectId_) : TestTask(objectId_), testMode(testModes::A) { + IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); } -EiveTestTask::~EiveTestTask() { -} +EiveTestTask::~EiveTestTask() {} ReturnValue_t EiveTestTask::performOperation(uint8_t operationCode) { - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = RETURN_OK; - if(oneShotAction) { - /* Add code here which should only be run once */ - performOneShotAction(); - oneShotAction = false; - } + if (oneShotAction) { + /* Add code here which should only be run once */ + performOneShotAction(); + oneShotAction = false; + } - /* Add code here which should only be run once per performOperation */ - performPeriodicAction(); + /* Add code here which should only be run once per performOperation */ + performPeriodicAction(); - /* Add code here which should only be run on alternating cycles. */ - if(testMode == testModes::A) { - performActionA(); - testMode = testModes::B; - } - else if(testMode == testModes::B) { - performActionB(); - testMode = testModes::A; - } - return result; + /* Add code here which should only be run on alternating cycles. */ + if (testMode == testModes::A) { + performActionA(); + testMode = testModes::B; + } else if (testMode == testModes::B) { + performActionB(); + testMode = testModes::A; + } + return result; } #include @@ -48,70 +46,70 @@ ReturnValue_t EiveTestTask::performOperation(uint8_t operationCode) { /** * @brief Dummy data from GPS receiver. Will be replaced witgh hyperion data later. */ -const char -gps_rx_data[] = "" - "$GPRMC,183729,A,3907.356,N,12102.482,W,000.0,360.0,080301,015.5,E*6F\r\n" - "$GPRMB,A,,,,,,,,,,,,V*71\r\n" - "$GPGGA,183730,3907.356,N,12102.482,W,1,05,1.6,646.4,M,-24.1,M,,*75\r\n" - "$GPGSA,A,3,02,,,07,,09,24,26,,,,,1.6,1.6,1.0*3D\r\n" - "$GPGSV,2,1,08,02,43,088,38,04,42,145,00,05,11,291,00,07,60,043,35*71\r\n" - "$GPGSV,2,2,08,08,02,145,00,09,46,303,47,24,16,178,32,26,18,231,43*77\r\n" - "$PGRME,22.0,M,52.9,M,51.0,M*14\r\n" - "$GPGLL,3907.360,N,12102.481,W,183730,A*33\r\n" - "$PGRMZ,2062,f,3*2D\r\n" - "$PGRMM,WGS84*06\r\n" - "$GPBOD,,T,,M,,*47\r\n" - "$GPRTE,1,1,c,0*07\r\n" - "$GPRMC,183731,A,3907.482,N,12102.436,W,000.0,360.0,080301,015.5,E*67\r\n" - "$GPRMB,A,,,,,,,,,,,,V*71\r\n"; +const char gps_rx_data[] = + "" + "$GPRMC,183729,A,3907.356,N,12102.482,W,000.0,360.0,080301,015.5,E*6F\r\n" + "$GPRMB,A,,,,,,,,,,,,V*71\r\n" + "$GPGGA,183730,3907.356,N,12102.482,W,1,05,1.6,646.4,M,-24.1,M,,*75\r\n" + "$GPGSA,A,3,02,,,07,,09,24,26,,,,,1.6,1.6,1.0*3D\r\n" + "$GPGSV,2,1,08,02,43,088,38,04,42,145,00,05,11,291,00,07,60,043,35*71\r\n" + "$GPGSV,2,2,08,08,02,145,00,09,46,303,47,24,16,178,32,26,18,231,43*77\r\n" + "$PGRME,22.0,M,52.9,M,51.0,M*14\r\n" + "$GPGLL,3907.360,N,12102.481,W,183730,A*33\r\n" + "$PGRMZ,2062,f,3*2D\r\n" + "$PGRMM,WGS84*06\r\n" + "$GPBOD,,T,,M,,*47\r\n" + "$GPRTE,1,1,c,0*07\r\n" + "$GPRMC,183731,A,3907.482,N,12102.436,W,000.0,360.0,080301,015.5,E*67\r\n" + "$GPRMB,A,,,,,,,,,,,,V*71\r\n"; -const char hyperion_gps_data[] = "" - "$GNGGA,173225.998892,4908.5596,N,00906.2765,E,1,05,2.1,215.0,M,48.2,M,,0000*74\r\n" - "$GNGLL,4908.5596,N,00906.2765,E,173225.998892,A,A*7F\r\n" - "$GPGSA,A,3,18,16,26,31,20,,,,,,,,3.2,2.1,2.4*3C\r\n" - "$GNRMC,173225.998892,A,4908.5596,N,00906.2765,E,000.0,040.7,270221,,,A*4F\r\n" - "$GNVTG,040.7,T,,M,000.0,N,000.0,K,A*10\r\n" - "$GNZDA,173225.998892,27,02,2021,00,00*75\r\n"; +const char hyperion_gps_data[] = + "" + "$GNGGA,173225.998892,4908.5596,N,00906.2765,E,1,05,2.1,215.0,M,48.2,M,,0000*74\r\n" + "$GNGLL,4908.5596,N,00906.2765,E,173225.998892,A,A*7F\r\n" + "$GPGSA,A,3,18,16,26,31,20,,,,,,,,3.2,2.1,2.4*3C\r\n" + "$GNRMC,173225.998892,A,4908.5596,N,00906.2765,E,000.0,040.7,270221,,,A*4F\r\n" + "$GNVTG,040.7,T,,M,000.0,N,000.0,K,A*10\r\n" + "$GNZDA,173225.998892,27,02,2021,00,00*75\r\n"; ReturnValue_t EiveTestTask::performOneShotAction() { #if OBSW_ADD_TEST_CODE == 1 - //performLwgpsTest(); + // performLwgpsTest(); #endif - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } - ReturnValue_t EiveTestTask::performPeriodicAction() { - ReturnValue_t result = RETURN_OK; - return result; + ReturnValue_t result = RETURN_OK; + return result; } ReturnValue_t EiveTestTask::performActionA() { - ReturnValue_t result = RETURN_OK; - /* Add periodically executed code here */ - return result; + ReturnValue_t result = RETURN_OK; + /* Add periodically executed code here */ + return result; } ReturnValue_t EiveTestTask::performActionB() { - ReturnValue_t result = RETURN_OK; - /* Add periodically executed code here */ - return result; + ReturnValue_t result = RETURN_OK; + /* Add periodically executed code here */ + return result; } void EiveTestTask::performLwgpsTest() { - /* Everything here will only be performed once. */ - sif::info << "Processing sample GPS output.." << std::endl; + /* Everything here will only be performed once. */ + sif::info << "Processing sample GPS output.." << std::endl; - lwgps_t gpsStruct; - sif::info << "Size of GPS struct: " << sizeof(gpsStruct) << std::endl; - lwgps_init(&gpsStruct); + lwgps_t gpsStruct; + sif::info << "Size of GPS struct: " << sizeof(gpsStruct) << std::endl; + lwgps_init(&gpsStruct); - /* Process all input data */ - lwgps_process(&gpsStruct, hyperion_gps_data, strlen(hyperion_gps_data)); + /* Process all input data */ + lwgps_process(&gpsStruct, hyperion_gps_data, strlen(hyperion_gps_data)); - /* Print messages */ - printf("Valid status: %d\n", gpsStruct.is_valid); - printf("Latitude: %f degrees\n", gpsStruct.latitude); - printf("Longitude: %f degrees\n", gpsStruct.longitude); - printf("Altitude: %f meters\n", gpsStruct.altitude); + /* Print messages */ + printf("Valid status: %d\n", gpsStruct.is_valid); + printf("Latitude: %f degrees\n", gpsStruct.latitude); + printf("Longitude: %f degrees\n", gpsStruct.longitude); + printf("Altitude: %f meters\n", gpsStruct.altitude); } diff --git a/test/testtasks/TestTask.h b/test/testtasks/TestTask.h index c2b8c8ed..2040ffb5 100644 --- a/test/testtasks/TestTask.h +++ b/test/testtasks/TestTask.h @@ -2,12 +2,12 @@ #define TEST_TESTTASK_H_ #include -#include #include -#include "fsfw_tests/integration/task/TestTask.h" +#include #include +#include "fsfw_tests/integration/task/TestTask.h" /** * @brief Test class for general C++ testing. @@ -16,38 +16,35 @@ * tests. Instead, a derived board test class should be used. */ class EiveTestTask : public TestTask { -public: - EiveTestTask(object_id_t objectId); - virtual ~EiveTestTask(); - virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; + public: + EiveTestTask(object_id_t objectId); + virtual ~EiveTestTask(); + virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; -protected: - virtual ReturnValue_t performOneShotAction(); - virtual ReturnValue_t performPeriodicAction(); - virtual ReturnValue_t performActionA(); - virtual ReturnValue_t performActionB(); + protected: + virtual ReturnValue_t performOneShotAction(); + virtual ReturnValue_t performPeriodicAction(); + virtual ReturnValue_t performActionA(); + virtual ReturnValue_t performActionB(); - enum testModes: uint8_t { - A, - B - }; + enum testModes : uint8_t { A, B }; - testModes testMode; + testModes testMode; - bool testFlag = false; - uint8_t counter { 1 }; - uint8_t counterTrigger { 3 }; + bool testFlag = false; + uint8_t counter{1}; + uint8_t counterTrigger{3}; - void performPusInjectorTest(); - void examplePacketTest(); -private: - // Actually, to be really thread-safe, a mutex should be used as well - // Let's keep it simple for now. - bool oneShotAction = true; - StorageManagerIF* IPCStore; + void performPusInjectorTest(); + void examplePacketTest(); - void performLwgpsTest(); + private: + // Actually, to be really thread-safe, a mutex should be used as well + // Let's keep it simple for now. + bool oneShotAction = true; + StorageManagerIF* IPCStore; + + void performLwgpsTest(); }; - #endif /* TESTTASK_H_ */ From 9438ba8dcc66df3b5dd53f9d99c21dbeabeb1038 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 17 Jan 2022 13:50:24 +0100 Subject: [PATCH 210/465] forward declaration fixes --- bsp_q7s/boardtest/Q7STestTask.h | 2 ++ mission/tmtc/VirtualChannel.h | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bsp_q7s/boardtest/Q7STestTask.h b/bsp_q7s/boardtest/Q7STestTask.h index ee26118c..b7aa791e 100644 --- a/bsp_q7s/boardtest/Q7STestTask.h +++ b/bsp_q7s/boardtest/Q7STestTask.h @@ -3,6 +3,8 @@ #include "test/testtasks/TestTask.h" +class CoreController; + class Q7STestTask : public TestTask { public: Q7STestTask(object_id_t objectId); diff --git a/mission/tmtc/VirtualChannel.h b/mission/tmtc/VirtualChannel.h index c6d999ef..62953dcb 100644 --- a/mission/tmtc/VirtualChannel.h +++ b/mission/tmtc/VirtualChannel.h @@ -1,12 +1,16 @@ #ifndef VIRTUALCHANNEL_H_ #define VIRTUALCHANNEL_H_ -#include -#include #include "OBSWConfig.h" + +#include "linux/obc/PtmeIF.h" + #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/tmtcservices/AcceptsTelemetryIF.h" +#include "fsfw/ipc/MessageQueueIF.h" + +class StorageManagerIF; /** * @brief This class represents a virtual channel. Sending a tm message to an object of this class From 71c5aa4df0c98d1da0491165fc09b796287937a0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 17 Jan 2022 13:51:03 +0100 Subject: [PATCH 211/465] added missing include --- linux/obc/PtmeIF.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/linux/obc/PtmeIF.h b/linux/obc/PtmeIF.h index 7108df05..5488fbfb 100644 --- a/linux/obc/PtmeIF.h +++ b/linux/obc/PtmeIF.h @@ -3,6 +3,8 @@ #include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include + /** * @brief Interface class for managing the PTME IP Core implemented in the programmable logic. * From 384122f811fd6e7babae21c0c117821aad47b996 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 17 Jan 2022 15:03:46 +0100 Subject: [PATCH 212/465] started BPX handler --- bsp_q7s/core/ObjectFactory.cpp | 3 +++ linux/fsfwconfig/devices/addresses.h | 1 + mission/devices/BpxBatteryHandler.h | 30 ++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 mission/devices/BpxBatteryHandler.h diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 69f6dfaf..9815c1d3 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -144,6 +144,9 @@ void ObjectFactory::produce(void* args) { new IMTQHandler(objects::IMTQ_HANDLER, objects::I2C_COM_IF, imtqI2cCookie); createReactionWheelComponents(gpioComIF); + I2cCookie* bpxI2cCookie = + new I2cCookie(addresses::BPX_BATTERY, 100, q7s::I2C_DEFAULT_DEV); + #if OBSW_ADD_PLOC_MPSOC == 1 UartCookie* plocMpsocCookie = new UartCookie(objects::PLOC_MPSOC_HANDLER, q7s::UART_PLOC_MPSOC_DEV, diff --git a/linux/fsfwconfig/devices/addresses.h b/linux/fsfwconfig/devices/addresses.h index 5ef82788..3405eb47 100644 --- a/linux/fsfwconfig/devices/addresses.h +++ b/linux/fsfwconfig/devices/addresses.h @@ -45,6 +45,7 @@ enum logicalAddresses : address_t { }; enum i2cAddresses : address_t { + BPX_BATTERY = 0x07, IMTQ = 16, TMP1075_TCS_1 = 72, TMP1075_TCS_2 = 73, diff --git a/mission/devices/BpxBatteryHandler.h b/mission/devices/BpxBatteryHandler.h new file mode 100644 index 00000000..99843e59 --- /dev/null +++ b/mission/devices/BpxBatteryHandler.h @@ -0,0 +1,30 @@ +#ifndef MISSION_DEVICES_BPXBATTERYHANDLER_H_ +#define MISSION_DEVICES_BPXBATTERYHANDLER_H_ + +#include + +class BpxBatteryHandler: public DeviceHandlerBase { +public: + BpxBatteryHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + virtual ~BpxBatteryHandler(); +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 ixd, const uint8_t* packet) override; + void setNormalDatapoolEntriesInvalid() override; + virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; +}; + + + +#endif /* MISSION_DEVICES_BPXBATTERYHANDLER_H_ */ From 5a210e19e1232ac0ebf82b4177474723dc6e30c6 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 17 Jan 2022 15:28:53 +0100 Subject: [PATCH 213/465] request limits, camera and blob parameters --- .../startracker/StarTrackerDefinitions.h | 145 +++++++++++++++++- .../startracker/StarTrackerHandler.cpp | 87 ++++++++++- .../devices/startracker/StarTrackerHandler.h | 12 ++ tmtc | 2 +- 4 files changed, 235 insertions(+), 11 deletions(-) diff --git a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h index 8a58149e..1f20c606 100644 --- a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h +++ b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h @@ -211,7 +211,33 @@ enum PoolIds: lp_id_t { CAM_REG3, CAM_VAL3, CAM_REG4, - CAM_VAL4 + CAM_VAL4, + LIMITS_ACTION, + LIMITS_FPGA18CURRENT, + LIMITS_FPGA25CURRENT, + LIMITS_FPGA10CURRENT, + LIMITS_MCUCURRENT, + LIMITS_CMOS21CURRENT, + LIMITS_CMOSPIXCURRENT, + LIMITS_CMOS33CURRENT, + LIMITS_CMOSVRESCURRENT, + LIMITS_CMOSTEMPERATURE, + LIMITS_MCUTEMPERATURE, + BLOB_MODE, + BLOB_MIN_VALUE, + BLOB_MIN_DISTANCE, + BLOB_NEIGHBOUR_DISTANCE, + BLOB_NEIGHBOUR_BRIGHTPIXELS, + BLOB_MIN_TOTAL_VALUE, + BLOB_MAX_TOTAL_VALUE, + BLOB_MIN_BRIGHT_NEIGHBOURS, + BLOB_MAX_BRIGHT_NEIGHBOURS, + BLOB_MAX_PIXELSTOCONSIDER, + BLOB_SIGNAL_THRESHOLD, + BLOB_DARK_THRESHOLD, + BLOB_ENABLE_HISTOGRAM, + BLOB_ENABLE_CONTRAST, + BLOB_BIN_MODE }; static const DeviceCommandId_t PING_REQUEST = 0; @@ -260,7 +286,9 @@ static const DeviceCommandId_t DOWNLOAD_FPGA_IMAGE = 63; static const DeviceCommandId_t CHANGE_FPGA_DOWNLOAD_FILE = 64; static const DeviceCommandId_t UPLOAD_FPGA_IMAGE = 65; static const DeviceCommandId_t FPGA_ACTION = 66; -static const DeviceCommandId_t REQ_CAMERA_PARAMS = 67; +static const DeviceCommandId_t REQ_CAMERA = 67; +static const DeviceCommandId_t REQ_LIMITS = 68; +static const DeviceCommandId_t REQ_BLOB_PARAMS = 69; static const DeviceCommandId_t NONE = 0xFFFFFFFF; static const uint32_t VERSION_SET_ID = REQ_VERSION; @@ -276,7 +304,9 @@ static const uint32_t DOWNLOADCENTROID_SET_ID = DOWNLOAD_CENTROID; static const uint32_t DOWNLOAD_MATCHED_STAR_SET_ID = DOWNLOAD_MATCHED_STAR; static const uint32_t DOWNLOAD_DBIMAGE_SET_ID = DOWNLOAD_DBIMAGE; static const uint32_t DOWNLOAD_BLOBPIXEL_SET_ID = DOWNLOAD_BLOBPIXEL; -static const uint32_t CAMERA_SET_ID = REQ_CAMERA_PARAMS; +static const uint32_t CAMERA_SET_ID = REQ_CAMERA; +static const uint32_t LIMITS_SET_ID = REQ_LIMITS; +static const uint32_t BLOB_SET_ID = REQ_BLOB_PARAMS; /** Max size of unencoded frame */ static const size_t MAX_FRAME_SIZE = 1200; @@ -295,6 +325,8 @@ static const uint8_t DOWNLOAD_MATCHED_STAR_SET_ENTRIES = 14; static const uint8_t DOWNLOAD_DBIMAGE_SET_ENTRIES = 6; static const uint8_t DOWNLOAD_BLOBPIXEL_SET_ENTRIES = 7; static const uint8_t CAMERA_SET_ENTRIES = 15; +static const uint8_t LIMITS_SET_ENTRIES = 11; +static const uint8_t BLOB_SET_ENTRIES = 15; // Action, parameter and telemetry IDs namespace ID { @@ -1289,5 +1321,112 @@ public: << static_cast(this->val4.value) << std::endl; } }; + +/** + * @brief Will store the requested limits + */ +class LimitsSet: public StaticLocalDataSet { +public: + + // Size of dataset + static const size_t SIZE = 41; + + LimitsSet(HasLocalDataPoolIF* owner) : + StaticLocalDataSet(owner, LIMITS_SET_ID) { + } + + LimitsSet(object_id_t objectId) : + StaticLocalDataSet(sid_t(objectId, LIMITS_SET_ID)) { + } + + lp_var_t action = lp_var_t(sid.objectId, PoolIds::LIMITS_ACTION, this); + lp_var_t fpga18current = lp_var_t(sid.objectId, PoolIds::LIMITS_FPGA18CURRENT, this); + lp_var_t fpga25current = lp_var_t(sid.objectId, PoolIds::LIMITS_FPGA25CURRENT, this); + lp_var_t fpga10current = lp_var_t(sid.objectId, PoolIds::LIMITS_FPGA10CURRENT, this); + lp_var_t mcuCurrent = lp_var_t(sid.objectId, PoolIds::LIMITS_MCUCURRENT, this); + lp_var_t cmos21current = lp_var_t(sid.objectId, PoolIds::LIMITS_CMOS21CURRENT, this); + lp_var_t cmosPixCurrent = lp_var_t(sid.objectId, PoolIds::LIMITS_CMOSPIXCURRENT, this); + lp_var_t cmos33current = lp_var_t(sid.objectId, PoolIds::LIMITS_CMOS33CURRENT, this); + lp_var_t cmosVresCurrent = lp_var_t(sid.objectId, PoolIds::LIMITS_CMOSVRESCURRENT, this); + lp_var_t cmosTemperature = lp_var_t(sid.objectId, PoolIds::LIMITS_CMOSTEMPERATURE, this); + + void printSet() { + PoolReadGuard rg(this); + sif::info << "CameraSet::printSet: action: " << static_cast(this->action.value) + << std::endl; + sif::info << "CameraSet::printSet: FPGA18Current: " << this->fpga18current << std::endl; + sif::info << "CameraSet::printSet: FPGA25Current: " << this->fpga25current << std::endl; + sif::info << "CameraSet::printSet: FPGA10Current: " << this->fpga10current << std::endl; + sif::info << "CameraSet::printSet: MCUCurrent: " << this->mcuCurrent << std::endl; + sif::info << "CameraSet::printSet: CMOS21Current: " << this->cmos21current << std::endl; + sif::info << "CameraSet::printSet: CMOSPixCurrent: " << this->cmosPixCurrent << std::endl; + sif::info << "CameraSet::printSet: CMOS33Current: " << this->cmos33current << std::endl; + sif::info << "CameraSet::printSet: CMOSVResCurrent: " << this->cmosVresCurrent << std::endl; + sif::info << "CameraSet::printSet: CMOSTemperature: " << this->cmosTemperature << std::endl; + } +}; + +/** + * @brief Will store the request of the blob parameters. + */ +class BlobSet: public StaticLocalDataSet { +public: + + // Size of dataset + static const size_t SIZE = 22; + + BlobSet(HasLocalDataPoolIF* owner) : + StaticLocalDataSet(owner, BLOB_SET_ID) { + } + + BlobSet(object_id_t objectId) : + StaticLocalDataSet(sid_t(objectId, BLOB_SET_ID)) { + } + + lp_var_t mode = lp_var_t(sid.objectId, PoolIds::BLOB_MODE, this); + lp_var_t minValue = lp_var_t(sid.objectId, PoolIds::BLOB_MIN_VALUE, this); + lp_var_t minDistance = lp_var_t(sid.objectId, PoolIds::BLOB_MIN_DISTANCE, this); + lp_var_t neighbourDistance = lp_var_t(sid.objectId, PoolIds::BLOB_NEIGHBOUR_DISTANCE, this); + lp_var_t neighbourBrightPixels = lp_var_t(sid.objectId, PoolIds::BLOB_NEIGHBOUR_BRIGHTPIXELS, this); + lp_var_t minTotalValue = lp_var_t(sid.objectId, PoolIds::BLOB_MIN_TOTAL_VALUE, this); + lp_var_t maxTotalValue = lp_var_t(sid.objectId, PoolIds::BLOB_MAX_TOTAL_VALUE, this); + lp_var_t minBrightNeighbours = lp_var_t(sid.objectId, PoolIds::BLOB_MIN_BRIGHT_NEIGHBOURS, this); + lp_var_t maxBrightNeighbours = lp_var_t(sid.objectId, PoolIds::BLOB_MAX_BRIGHT_NEIGHBOURS, this); + lp_var_t maxPixelsToConsider = lp_var_t(sid.objectId, PoolIds::BLOB_MAX_PIXELSTOCONSIDER, this); + lp_var_t signalThreshold = lp_var_t(sid.objectId, PoolIds::BLOB_SIGNAL_THRESHOLD, this); + lp_var_t darkThreshold = lp_var_t(sid.objectId, PoolIds::BLOB_DARK_THRESHOLD, this); + lp_var_t enableContrast = lp_var_t(sid.objectId, PoolIds::BLOB_ENABLE_CONTRAST, this); + lp_var_t enableBinMode = lp_var_t(sid.objectId, PoolIds::BLOB_BIN_MODE, this); + + void printSet() { + PoolReadGuard rg(this); + sif::info << "BlobSet::printSet: mode: " << static_cast(this->mode.value) + << std::endl; + sif::info << "BlobSet::printSet: minValue: " + << static_cast(this->minValue.value) << std::endl; + sif::info << "BlobSet::printSet: minDistance: " + << static_cast(this->minDistance.value) << std::endl; + sif::info << "BlobSet::printSet: neighboutDistance: " + << static_cast(this->neighbourDistance.value) << std::endl; + sif::info << "BlobSet::printSet: neighboutBrightPixels: " + << static_cast(this->neighbourBrightPixels.value) << std::endl; + sif::info << "BlobSet::printSet: minTotalValue: " << this->minTotalValue << std::endl; + sif::info << "BlobSet::printSet: maxTotalValue: " << this->maxTotalValue << std::endl; + sif::info << "BlobSet::printSet: minBrightNeighbours: " << this->minBrightNeighbours + << std::endl; + sif::info << "BlobSet::printSet: maxBrightNeighbours: " << this->maxBrightNeighbours + << std::endl; + sif::info << "BlobSet::printSet: maxPixelsToConsider: " << this->maxPixelsToConsider + << std::endl; + sif::info << "BlobSet::printSet: signalThreshold: " + << static_cast(this->signalThreshold.value) << std::endl; + sif::info << "BlobSet::printSet: darkThreshold: " + << static_cast(this->darkThreshold.value) << std::endl; + sif::info << "BlobSet::printSet: enableContrast: " + << static_cast(this->enableContrast.value) << std::endl; + sif::info << "BlobSet::printSet: enableBinMode: " + << static_cast(this->enableBinMode.value) << std::endl; + } +}; } #endif /* MISSION_STARTRACKER_DEFINITIONS_H_ */ diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp index efb54ff8..34575133 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp @@ -18,8 +18,8 @@ StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie, StrHelper* strHelper) : DeviceHandlerBase(objectId, comIF, comCookie), temperatureSet(this), versionSet(this), powerSet( this), interfaceSet(this), timeSet(this), solutionSet(this), histogramSet(this), contrastSet( - this), checksumSet(this), downloadCentroidSet(this), downloadMatchedStar(this), - downloadDbImage(this), downloadBlobPixel(this), cameraSet(this), strHelper( + this), checksumSet(this), downloadCentroidSet(this), downloadMatchedStar(this), downloadDbImage( + this), downloadBlobPixel(this), cameraSet(this), limitsSet(this), blobSet(this), strHelper( strHelper) { if (comCookie == nullptr) { sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl; @@ -496,10 +496,18 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi result = prepareFpgaActionCommand(commandData, commandDataLen); return result; } - case (StarTracker::REQ_CAMERA_PARAMS): { + case (StarTracker::REQ_CAMERA): { result = prepareRequestCameraParams(); return result; } + case (StarTracker::REQ_LIMITS): { + result = prepareRequestLimitsParams(); + return result; + } + case (StarTracker::REQ_BLOB_PARAMS): { + result = prepareRequestBlobParams(); + return result; + } default: return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } @@ -578,7 +586,11 @@ void StarTrackerHandler::fillCommandAndReplyMap() { StarTracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(StarTracker::FPGA_ACTION, 3, nullptr, StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_CAMERA_PARAMS, 3, nullptr, + this->insertInCommandAndReplyMap(StarTracker::REQ_CAMERA, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_LIMITS, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_BLOB_PARAMS, 3, nullptr, StarTracker::MAX_FRAME_SIZE * 2 + 2); } @@ -738,10 +750,18 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con result = handleSetParamReply(); break; } - case (StarTracker::REQ_CAMERA_PARAMS): { + case (StarTracker::REQ_CAMERA): { handleParamRequest(cameraSet, StarTracker::CameraSet::SIZE); break; } + case (StarTracker::REQ_LIMITS): { + handleParamRequest(limitsSet, StarTracker::LimitsSet::SIZE); + break; + } + case (StarTracker::REQ_BLOB_PARAMS): { + handleParamRequest(blobSet, StarTracker::BlobSet::SIZE); + break; + } default: { sif::debug << "StarTrackerHandler::interpretDeviceReply: Unknown device reply id:" << id << std::endl; @@ -966,6 +986,34 @@ ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& l localDataPoolMap.emplace(StarTracker::CAM_VAL3, new PoolEntry( { 0 })); localDataPoolMap.emplace(StarTracker::CAM_REG4, new PoolEntry( { 0 })); localDataPoolMap.emplace(StarTracker::CAM_VAL4, new PoolEntry( { 0 })); + + localDataPoolMap.emplace(StarTracker::LIMITS_ACTION, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::LIMITS_FPGA18CURRENT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::LIMITS_FPGA25CURRENT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::LIMITS_FPGA10CURRENT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::LIMITS_MCUCURRENT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::LIMITS_CMOS21CURRENT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::LIMITS_CMOSPIXCURRENT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::LIMITS_CMOS33CURRENT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::LIMITS_CMOSVRESCURRENT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::LIMITS_CMOSTEMPERATURE, new PoolEntry( { 0 })); + + localDataPoolMap.emplace(StarTracker::BLOB_MODE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOB_MIN_VALUE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOB_MIN_DISTANCE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOB_NEIGHBOUR_DISTANCE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOB_NEIGHBOUR_BRIGHTPIXELS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOB_NEIGHBOUR_BRIGHTPIXELS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOB_MIN_TOTAL_VALUE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOB_MAX_TOTAL_VALUE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOB_MIN_BRIGHT_NEIGHBOURS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOB_MAX_BRIGHT_NEIGHBOURS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOB_MAX_PIXELSTOCONSIDER, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOB_SIGNAL_THRESHOLD, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOB_DARK_THRESHOLD, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOB_ENABLE_HISTOGRAM, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOB_ENABLE_CONTRAST, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOB_BIN_MODE, new PoolEntry( { 0 })); return RETURN_OK; } @@ -1127,7 +1175,15 @@ ReturnValue_t StarTrackerHandler::scanForGetParameterReply(DeviceCommandId_t *fo const uint8_t* reply = dataLinkLayer.getReply(); switch (*reply) { case (StarTracker::ID::CAMERA): { - *foundId = StarTracker::REQ_CAMERA_PARAMS; + *foundId = StarTracker::REQ_CAMERA; + break; + } + case (StarTracker::ID::LIMITS): { + *foundId = StarTracker::REQ_LIMITS; + break; + } + case (StarTracker::ID::BLOB): { + *foundId = StarTracker::REQ_BLOB_PARAMS; break; } default: { @@ -1749,7 +1805,6 @@ ReturnValue_t StarTrackerHandler::prepareFpgaActionCommand(const uint8_t* comman } ReturnValue_t StarTrackerHandler::prepareRequestCameraParams() { - struct Camera req; uint32_t length = 0; arc_pack_camera_parameter_req(commandBuffer, &length); dataLinkLayer.encodeFrame(commandBuffer, length); @@ -1758,6 +1813,24 @@ ReturnValue_t StarTrackerHandler::prepareRequestCameraParams() { return RETURN_OK; } +ReturnValue_t StarTrackerHandler::prepareRequestLimitsParams() { + uint32_t length = 0; + arc_pack_limits_parameter_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; +} + +ReturnValue_t StarTrackerHandler::prepareRequestBlobParams() { + uint32_t length = 0; + arc_pack_blob_parameter_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; +} + ReturnValue_t StarTrackerHandler::handleSetParamReply() { const uint8_t* reply = dataLinkLayer.getReply(); uint8_t status = *(reply + STATUS_OFFSET); diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.h b/bsp_q7s/devices/startracker/StarTrackerHandler.h index 0461af27..2a7c7501 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.h +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.h @@ -262,6 +262,8 @@ private: StarTracker::DownloadDBImage downloadDbImage; StarTracker::DownloadBlobPixel downloadBlobPixel; StarTracker::CameraSet cameraSet; + StarTracker::LimitsSet limitsSet; + StarTracker::BlobSet blobSet; // Pointer to object responsible for uploading and downloading images to/from the star tracker StrHelper* strHelper = nullptr; @@ -500,6 +502,16 @@ private: */ ReturnValue_t prepareRequestCameraParams(); + /** + * @brief Will fill the command buffer with the command to request the set limits. + */ + ReturnValue_t prepareRequestLimitsParams(); + + /** + * @brief Will fill the command buffer with the command to request the set blob parameters. + */ + ReturnValue_t prepareRequestBlobParams(); + /** * @brief Handles action replies with datasets. */ diff --git a/tmtc b/tmtc index 6270d90f..672f2339 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 6270d90f98b4ec694b6d543ce9a9ddd49ba743f9 +Subproject commit 672f2339d7504c83d953cc4eecca6057ff920909 From 3a274e7a9ba0a2d690a95b5de04bcf82975bfa45 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 17 Jan 2022 15:35:46 +0100 Subject: [PATCH 214/465] apply clang format --- bsp_q7s/core/ObjectFactory.cpp | 5 ++- linux/obc/PtmeIF.h | 4 +-- mission/devices/BpxBatteryHandler.cpp | 47 ++++++++++++++++++++++++++ mission/devices/BpxBatteryHandler.h | 15 ++++---- mission/devices/CMakeLists.txt | 1 + mission/devices/GPSHyperionHandler.cpp | 10 +++++- mission/tmtc/VirtualChannel.h | 7 ++-- 7 files changed, 70 insertions(+), 19 deletions(-) create mode 100644 mission/devices/BpxBatteryHandler.cpp diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 9815c1d3..77d3207e 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -144,9 +144,8 @@ void ObjectFactory::produce(void* args) { new IMTQHandler(objects::IMTQ_HANDLER, objects::I2C_COM_IF, imtqI2cCookie); createReactionWheelComponents(gpioComIF); - I2cCookie* bpxI2cCookie = - new I2cCookie(addresses::BPX_BATTERY, 100, q7s::I2C_DEFAULT_DEV); - + I2cCookie* bpxI2cCookie = new I2cCookie(addresses::BPX_BATTERY, 100, q7s::I2C_DEFAULT_DEV); + (void)bpxI2cCookie; #if OBSW_ADD_PLOC_MPSOC == 1 UartCookie* plocMpsocCookie = new UartCookie(objects::PLOC_MPSOC_HANDLER, q7s::UART_PLOC_MPSOC_DEV, diff --git a/linux/obc/PtmeIF.h b/linux/obc/PtmeIF.h index 5488fbfb..77e976e0 100644 --- a/linux/obc/PtmeIF.h +++ b/linux/obc/PtmeIF.h @@ -1,10 +1,10 @@ #ifndef LINUX_OBC_PTMEIF_H_ #define LINUX_OBC_PTMEIF_H_ -#include "fsfw/returnvalues/HasReturnvaluesIF.h" - #include +#include "fsfw/returnvalues/HasReturnvaluesIF.h" + /** * @brief Interface class for managing the PTME IP Core implemented in the programmable logic. * diff --git a/mission/devices/BpxBatteryHandler.cpp b/mission/devices/BpxBatteryHandler.cpp new file mode 100644 index 00000000..7d504105 --- /dev/null +++ b/mission/devices/BpxBatteryHandler.cpp @@ -0,0 +1,47 @@ +#include "BpxBatteryHandler.h" + +BpxBatteryHandler::BpxBatteryHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie) + : DeviceHandlerBase(objectId, comIF, comCookie) {} + +BpxBatteryHandler::~BpxBatteryHandler() {} + +void BpxBatteryHandler::doStartUp() {} + +void BpxBatteryHandler::doShutDown() {} + +ReturnValue_t BpxBatteryHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t BpxBatteryHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { + return HasReturnvaluesIF::RETURN_OK; +} + +void BpxBatteryHandler::fillCommandAndReplyMap() {} + +ReturnValue_t BpxBatteryHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t* commandData, + size_t commandDataLen) { + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t BpxBatteryHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t BpxBatteryHandler::interpretDeviceReply(DeviceCommandId_t ixd, + const uint8_t* packet) { + return HasReturnvaluesIF::RETURN_OK; +} + +void BpxBatteryHandler::setNormalDatapoolEntriesInvalid() {} + +LocalPoolDataSetBase* BpxBatteryHandler::getDataSetHandle(sid_t sid) { return nullptr; } + +uint32_t BpxBatteryHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 10000; } + +ReturnValue_t BpxBatteryHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) { + return HasReturnvaluesIF::RETURN_OK; +} diff --git a/mission/devices/BpxBatteryHandler.h b/mission/devices/BpxBatteryHandler.h index 99843e59..887827fd 100644 --- a/mission/devices/BpxBatteryHandler.h +++ b/mission/devices/BpxBatteryHandler.h @@ -3,28 +3,27 @@ #include -class BpxBatteryHandler: public DeviceHandlerBase { -public: +class BpxBatteryHandler : public DeviceHandlerBase { + public: BpxBatteryHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); virtual ~BpxBatteryHandler(); -protected: + + 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; + size_t commandDataLen) override; ReturnValue_t scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId, - size_t* foundLen) override; + size_t* foundLen) override; ReturnValue_t interpretDeviceReply(DeviceCommandId_t ixd, const uint8_t* packet) override; void setNormalDatapoolEntriesInvalid() override; virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; + LocalDataPoolManager& poolManager) override; }; - - #endif /* MISSION_DEVICES_BPXBATTERYHANDLER_H_ */ diff --git a/mission/devices/CMakeLists.txt b/mission/devices/CMakeLists.txt index ed811ed3..a9c52b0b 100644 --- a/mission/devices/CMakeLists.txt +++ b/mission/devices/CMakeLists.txt @@ -1,6 +1,7 @@ target_sources(${TARGET_NAME} PUBLIC GPSHyperionHandler.cpp GomspaceDeviceHandler.cpp + BpxBatteryHandler.cpp Tmp1075Handler.cpp PCDUHandler.cpp P60DockHandler.cpp diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index 5b2a2a95..9ffc6c8f 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -1,7 +1,9 @@ #include "GPSHyperionHandler.h" +#ifdef FSFW_OSAL_LINUX #include #include +#endif #include @@ -22,7 +24,11 @@ GPSHyperionHandler::GPSHyperionHandler(object_id_t objectId, object_id_t parentI GPSHyperionHandler::~GPSHyperionHandler() {} -void GPSHyperionHandler::performControlOperation() { readGpsDataFromGpsd(); } +void GPSHyperionHandler::performControlOperation() { +#ifdef FSFW_OSAL_LINUX + readGpsDataFromGpsd(); +#endif +} LocalPoolDataSetBase *GPSHyperionHandler::getDataSetHandle(sid_t sid) { return nullptr; } @@ -83,6 +89,7 @@ ReturnValue_t GPSHyperionHandler::handleCommandMessage(CommandMessage *message) return ExtendedControllerBase::handleCommandMessage(message); } +#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 @@ -166,3 +173,4 @@ void GPSHyperionHandler::readGpsDataFromGpsd() { std::cout << "Speed(m/s): " << gps->fix.speed << std::endl; } } +#endif diff --git a/mission/tmtc/VirtualChannel.h b/mission/tmtc/VirtualChannel.h index 62953dcb..13e30b32 100644 --- a/mission/tmtc/VirtualChannel.h +++ b/mission/tmtc/VirtualChannel.h @@ -1,14 +1,11 @@ #ifndef VIRTUALCHANNEL_H_ #define VIRTUALCHANNEL_H_ - #include "OBSWConfig.h" - -#include "linux/obc/PtmeIF.h" - +#include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/tmtcservices/AcceptsTelemetryIF.h" -#include "fsfw/ipc/MessageQueueIF.h" +#include "linux/obc/PtmeIF.h" class StorageManagerIF; From 643584e1c5215b8362eb16393a0000f593f0605a Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 17 Jan 2022 15:36:37 +0100 Subject: [PATCH 215/465] rerun generator scripts --- generators/events/translateEvents.cpp | 2 +- generators/objects/translateObjects.cpp | 2 +- linux/fsfwconfig/events/translateEvents.cpp | 2 +- linux/fsfwconfig/objects/translateObjects.cpp | 2 +- tmtc | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp index 75fa2a5c..11a02c64 100644 --- a/generators/events/translateEvents.cpp +++ b/generators/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** * @brief Auto-generated event translation file. Contains 140 translations. * @details - * Generated on: 2022-01-16 16:01:54 + * Generated on: 2022-01-17 15:35:58 */ #include "translateEvents.h" diff --git a/generators/objects/translateObjects.cpp b/generators/objects/translateObjects.cpp index 49900a5d..899aaf2b 100644 --- a/generators/objects/translateObjects.cpp +++ b/generators/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 113 translations. - * Generated on: 2021-12-21 17:21:23 + * Generated on: 2022-01-17 15:36:10 */ #include "translateObjects.h" diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index 75fa2a5c..11a02c64 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** * @brief Auto-generated event translation file. Contains 140 translations. * @details - * Generated on: 2022-01-16 16:01:54 + * Generated on: 2022-01-17 15:35:58 */ #include "translateEvents.h" diff --git a/linux/fsfwconfig/objects/translateObjects.cpp b/linux/fsfwconfig/objects/translateObjects.cpp index 49900a5d..899aaf2b 100644 --- a/linux/fsfwconfig/objects/translateObjects.cpp +++ b/linux/fsfwconfig/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 113 translations. - * Generated on: 2021-12-21 17:21:23 + * Generated on: 2022-01-17 15:36:10 */ #include "translateObjects.h" diff --git a/tmtc b/tmtc index 672f2339..580ac8b2 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 672f2339d7504c83d953cc4eecca6057ff920909 +Subproject commit 580ac8b2d7e73aa860f3de55066187d7684d2d64 From a9cd072acdc2fc15d2cde9442a9ccb29875e2623 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 17 Jan 2022 15:36:52 +0100 Subject: [PATCH 216/465] add battery definitions file --- mission/devices/devicedefinitions/BpxBatteryDefinitions.h | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 mission/devices/devicedefinitions/BpxBatteryDefinitions.h diff --git a/mission/devices/devicedefinitions/BpxBatteryDefinitions.h b/mission/devices/devicedefinitions/BpxBatteryDefinitions.h new file mode 100644 index 00000000..436cc6f6 --- /dev/null +++ b/mission/devices/devicedefinitions/BpxBatteryDefinitions.h @@ -0,0 +1,8 @@ +#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_BPXBATTERYDEFINITIONS_H_ +#define MISSION_DEVICES_DEVICEDEFINITIONS_BPXBATTERYDEFINITIONS_H_ + +namespace BpxBattery { + +} + +#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_BPXBATTERYDEFINITIONS_H_ */ From c657264832fdc68607f0cb920e5c212b8dbed875 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 17 Jan 2022 15:41:22 +0100 Subject: [PATCH 217/465] small fix --- mission/devices/GPSHyperionHandler.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index d42421a0..a0036867 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -4,8 +4,11 @@ #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 @@ -22,7 +25,9 @@ GPSHyperionHandler::GPSHyperionHandler(object_id_t objectId, object_id_t parentI GPSHyperionHandler::~GPSHyperionHandler() {} void GPSHyperionHandler::performControlOperation() { +#ifdef FSFW_OSAL_LINUX readGpsDataFromGpsd(); +#endif } LocalPoolDataSetBase* GPSHyperionHandler::getDataSetHandle(sid_t sid) { @@ -88,6 +93,7 @@ ReturnValue_t GPSHyperionHandler::handleCommandMessage(CommandMessage *message) return ExtendedControllerBase::handleCommandMessage(message); } +#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 @@ -172,3 +178,4 @@ void GPSHyperionHandler::readGpsDataFromGpsd() { std::cout << "Speed(m/s): " << gps->fix.speed << std::endl; } } +#endif From 975b3cd294dab45c213acfdee3592ab5fbb305e3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 17 Jan 2022 15:57:52 +0100 Subject: [PATCH 218/465] added clang script and forward declarations --- .clang-format | 8 ++++++++ bsp_q7s/boardtest/Q7STestTask.h | 2 ++ mission/tmtc/VirtualChannel.h | 2 ++ scripts/apply-clang-format.sh | 11 +++++++++++ 4 files changed, 23 insertions(+) create mode 100644 .clang-format create mode 100755 scripts/apply-clang-format.sh diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..ada61da2 --- /dev/null +++ b/.clang-format @@ -0,0 +1,8 @@ +--- +BasedOnStyle: Google +IndentWidth: 2 +--- +Language: Cpp +ColumnLimit: 100 +ReflowComments: true +--- diff --git a/bsp_q7s/boardtest/Q7STestTask.h b/bsp_q7s/boardtest/Q7STestTask.h index 91e8c3d6..631c238a 100644 --- a/bsp_q7s/boardtest/Q7STestTask.h +++ b/bsp_q7s/boardtest/Q7STestTask.h @@ -3,6 +3,8 @@ #include "test/testtasks/TestTask.h" +class CoreController; + class Q7STestTask: public TestTask { public: Q7STestTask(object_id_t objectId); diff --git a/mission/tmtc/VirtualChannel.h b/mission/tmtc/VirtualChannel.h index c6e2eb6d..213a3421 100644 --- a/mission/tmtc/VirtualChannel.h +++ b/mission/tmtc/VirtualChannel.h @@ -7,6 +7,8 @@ #include #include +class StorageManagerIF; + /** * @brief This class represents a virtual channel. Sending a tm message to an object of this class * will forward the tm packet to the respective virtual channel of the PTME IP Core. diff --git a/scripts/apply-clang-format.sh b/scripts/apply-clang-format.sh new file mode 100755 index 00000000..55a31487 --- /dev/null +++ b/scripts/apply-clang-format.sh @@ -0,0 +1,11 @@ +#!/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 From 77c45c0de9871a90fd1fa48de1825a49e847664f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 17 Jan 2022 15:58:27 +0100 Subject: [PATCH 219/465] applied formatting --- bsp_hosted/InitMission.cpp | 214 +- bsp_hosted/InitMission.h | 2 +- bsp_hosted/ObjectFactory.cpp | 41 +- bsp_hosted/ObjectFactory.h | 7 +- bsp_hosted/boardconfig/etl_profile.h | 4 +- bsp_hosted/boardconfig/gcov.h | 5 +- bsp_hosted/boardconfig/print.c | 14 +- bsp_hosted/comIF/ArduinoComIF.cpp | 539 ++- bsp_hosted/comIF/ArduinoComIF.h | 71 +- bsp_hosted/comIF/ArduinoCookie.cpp | 12 +- bsp_hosted/comIF/ArduinoCookie.h | 27 +- bsp_hosted/fsfwconfig/devices/gpioIds.h | 89 +- .../fsfwconfig/devices/powerSwitcherList.h | 89 +- .../fsfwconfig/events/subsystemIdRanges.h | 5 +- .../fsfwconfig/events/translateEvents.cpp | 344 +- .../fsfwconfig/events/translateEvents.h | 2 +- .../fsfwconfig/ipc/MissionMessageTypes.cpp | 11 +- .../fsfwconfig/ipc/MissionMessageTypes.h | 4 +- .../fsfwconfig/objects/systemObjectList.h | 33 +- .../fsfwconfig/objects/translateObjects.cpp | 138 +- bsp_hosted/fsfwconfig/returnvalues/classIds.h | 6 +- bsp_hosted/fsfwconfig/tmtc/apid.h | 3 +- bsp_hosted/fsfwconfig/tmtc/pusIds.h | 30 +- bsp_hosted/main.cpp | 32 +- bsp_linux_board/InitMission.cpp | 363 +- bsp_linux_board/InitMission.h | 17 +- bsp_linux_board/ObjectFactory.cpp | 319 +- bsp_linux_board/ObjectFactory.h | 9 +- bsp_linux_board/boardconfig/etl_profile.h | 4 +- bsp_linux_board/boardconfig/gcov.h | 5 +- bsp_linux_board/boardconfig/print.c | 14 +- bsp_linux_board/main.cpp | 32 +- bsp_q7s/boardconfig/busConf.h | 106 +- bsp_q7s/boardconfig/etl_profile.h | 4 +- bsp_q7s/boardconfig/gcov.h | 5 +- bsp_q7s/boardconfig/print.c | 14 +- bsp_q7s/boardtest/FileSystemTest.cpp | 35 +- bsp_q7s/boardtest/FileSystemTest.h | 11 +- bsp_q7s/boardtest/Q7STestTask.cpp | 685 ++-- bsp_q7s/boardtest/Q7STestTask.h | 60 +- bsp_q7s/callbacks/gnssCallback.cpp | 39 +- bsp_q7s/callbacks/gnssCallback.h | 8 +- bsp_q7s/callbacks/rwSpiCallback.cpp | 412 +- bsp_q7s/callbacks/rwSpiCallback.h | 9 +- bsp_q7s/core/CoreController.cpp | 1850 +++++---- bsp_q7s/core/CoreController.h | 274 +- bsp_q7s/core/InitMission.cpp | 538 ++- bsp_q7s/core/InitMission.h | 11 +- bsp_q7s/core/ObjectFactory.cpp | 1703 +++++---- bsp_q7s/core/ObjectFactory.h | 6 +- bsp_q7s/core/ParameterHandler.cpp | 7 +- bsp_q7s/core/ParameterHandler.h | 18 +- bsp_q7s/core/obsw.cpp | 57 +- bsp_q7s/devices/PlocMemoryDumper.cpp | 282 +- bsp_q7s/devices/PlocMemoryDumper.h | 145 +- bsp_q7s/devices/PlocSupervisorHandler.cpp | 2295 ++++++----- bsp_q7s/devices/PlocSupervisorHandler.h | 549 +-- bsp_q7s/devices/PlocUpdater.cpp | 582 ++- bsp_q7s/devices/PlocUpdater.h | 247 +- .../PlocMemDumpDefinitions.h | 41 +- .../PlocSupervisorDefinitions.h | 2261 ++++++----- .../startracker/ArcsecDatalinkLayer.cpp | 100 +- .../devices/startracker/ArcsecDatalinkLayer.h | 138 +- bsp_q7s/devices/startracker/ArcsecJsonKeys.h | 214 +- .../startracker/ArcsecJsonParamBase.cpp | 103 +- .../devices/startracker/ArcsecJsonParamBase.h | 215 +- .../startracker/StarTrackerDefinitions.h | 1786 ++++----- .../startracker/StarTrackerHandler.cpp | 2958 +++++++------- .../devices/startracker/StarTrackerHandler.h | 1053 +++-- .../startracker/StarTrackerJsonCommands.cpp | 1281 +++---- .../startracker/StarTrackerJsonCommands.h | 161 +- bsp_q7s/devices/startracker/StrHelper.cpp | 1164 +++--- bsp_q7s/devices/startracker/StrHelper.h | 662 ++-- bsp_q7s/gpio/gpioCallbacks.cpp | 858 +++-- bsp_q7s/gpio/gpioCallbacks.h | 111 +- bsp_q7s/main.cpp | 9 +- bsp_q7s/memory/FileSystemHandler.cpp | 418 +- bsp_q7s/memory/FileSystemHandler.h | 104 +- bsp_q7s/memory/SdCardManager.cpp | 773 ++-- bsp_q7s/memory/SdCardManager.h | 345 +- bsp_q7s/memory/definitions.h | 21 +- bsp_q7s/memory/scratchApi.cpp | 75 +- bsp_q7s/memory/scratchApi.h | 142 +- bsp_q7s/simple/simple.cpp | 10 +- bsp_q7s/spi/Q7sSpiComIF.cpp | 8 +- bsp_q7s/spi/Q7sSpiComIF.h | 23 +- linux/archive/gpio/GpioCookie.cpp | 44 +- linux/archive/gpio/GpioCookie.h | 34 +- linux/archive/gpio/GpioIF.h | 68 +- linux/archive/gpio/LinuxLibgpioIF.cpp | 459 ++- linux/archive/gpio/LinuxLibgpioIF.h | 98 +- linux/archive/gpio/gpioDefinitions.h | 89 +- linux/archive/tmtc/CCSDSIPCoreBridge.cpp | 180 +- linux/archive/tmtc/CCSDSIPCoreBridge.h | 186 +- linux/boardtest/I2cTestClass.cpp | 7 +- linux/boardtest/I2cTestClass.h | 12 +- linux/boardtest/LibgpiodTest.cpp | 208 +- linux/boardtest/LibgpiodTest.h | 33 +- linux/boardtest/SpiTestClass.cpp | 762 ++-- linux/boardtest/SpiTestClass.h | 117 +- linux/boardtest/UartTestClass.cpp | 163 +- linux/boardtest/UartTestClass.h | 30 +- linux/csp/CspComIF.cpp | 441 ++- linux/csp/CspComIF.h | 110 +- linux/csp/CspCookie.cpp | 16 +- linux/csp/CspCookie.h | 21 +- linux/devices/SolarArrayDeploymentHandler.cpp | 305 +- linux/devices/SolarArrayDeploymentHandler.h | 224 +- linux/devices/SusHandler.cpp | 368 +- linux/devices/SusHandler.h | 83 +- .../devicedefinitions/SusDefinitions.h | 140 +- linux/fsfwconfig/devices/addresses.cpp | 4 - linux/fsfwconfig/devices/addresses.h | 137 +- linux/fsfwconfig/devices/gpioIds.h | 180 +- linux/fsfwconfig/devices/powerSwitcherList.h | 89 +- linux/fsfwconfig/events/subsystemIdRanges.h | 10 +- linux/fsfwconfig/events/translateEvents.cpp | 572 +-- linux/fsfwconfig/events/translateEvents.h | 2 +- linux/fsfwconfig/ipc/MissionMessageTypes.cpp | 12 +- linux/fsfwconfig/ipc/MissionMessageTypes.h | 6 +- linux/fsfwconfig/objects/systemObjectList.h | 60 +- linux/fsfwconfig/objects/translateObjects.cpp | 464 +-- .../pollingSequenceFactory.cpp | 1254 +++--- .../pollingsequence/pollingSequenceFactory.h | 7 +- linux/fsfwconfig/returnvalues/classIds.h | 13 +- linux/fsfwconfig/tmtc/pusIds.h | 30 +- linux/obc/PapbVcInterface.cpp | 138 +- linux/obc/PapbVcInterface.h | 158 +- linux/obc/PdecConfig.cpp | 49 +- linux/obc/PdecConfig.h | 56 +- linux/obc/PdecHandler.cpp | 842 ++-- linux/obc/PdecHandler.h | 613 ++- linux/obc/Ptme.cpp | 103 +- linux/obc/Ptme.h | 116 +- linux/obc/PtmeConfig.h | 25 +- linux/obc/PtmeIF.h | 21 +- linux/obc/PtmeRateSetter.cpp | 32 +- linux/obc/PtmeRateSetter.h | 36 +- linux/obc/TxRateSetterIF.h | 13 +- linux/obc/VcInterfaceIF.h | 23 +- linux/utility/utility.cpp | 11 +- linux/utility/utility.h | 3 +- mission/controller/ThermalController.cpp | 67 +- mission/controller/ThermalController.h | 32 +- mission/core/GenericFactory.cpp | 126 +- mission/core/GenericFactory.h | 2 - mission/devices/ACUHandler.cpp | 503 +-- mission/devices/ACUHandler.h | 57 +- mission/devices/GPSHyperionHandler.cpp | 241 +- mission/devices/GPSHyperionHandler.h | 55 +- mission/devices/GomspaceDeviceHandler.cpp | 686 ++-- mission/devices/GomspaceDeviceHandler.h | 214 +- mission/devices/GyroADIS1650XHandler.cpp | 727 ++-- mission/devices/GyroADIS1650XHandler.h | 92 +- mission/devices/HeaterHandler.cpp | 577 ++- mission/devices/HeaterHandler.h | 244 +- mission/devices/IMTQHandler.cpp | 3387 +++++++++-------- mission/devices/IMTQHandler.h | 312 +- mission/devices/Max31865PT1000Handler.cpp | 819 ++-- mission/devices/Max31865PT1000Handler.h | 151 +- mission/devices/P60DockHandler.cpp | 860 +++-- mission/devices/P60DockHandler.h | 54 +- mission/devices/PCDUHandler.cpp | 804 ++-- mission/devices/PCDUHandler.h | 178 +- mission/devices/PDU1Handler.cpp | 709 ++-- mission/devices/PDU1Handler.h | 37 +- mission/devices/PDU2Handler.cpp | 697 ++-- mission/devices/PDU2Handler.h | 40 +- mission/devices/PlocMPSoCHandler.cpp | 726 ++-- mission/devices/PlocMPSoCHandler.h | 328 +- mission/devices/RadiationSensorHandler.cpp | 263 +- mission/devices/RadiationSensorHandler.h | 68 +- mission/devices/RwHandler.cpp | 727 ++-- mission/devices/RwHandler.h | 228 +- mission/devices/SyrlinksHkHandler.cpp | 731 ++-- mission/devices/SyrlinksHkHandler.h | 274 +- mission/devices/Tmp1075Handler.cpp | 211 +- mission/devices/Tmp1075Handler.h | 74 +- .../devicedefinitions/GPSDefinitions.h | 93 +- .../devicedefinitions/GomSpacePackets.h | 637 ++-- .../devicedefinitions/GomspaceDefinitions.h | 2001 +++++----- .../GyroADIS1650XDefinitions.h | 146 +- .../devicedefinitions/GyroL3GD20Definitions.h | 62 +- .../IMTQHandlerDefinitions.h | 1595 ++++---- .../devicedefinitions/Max31865Definitions.h | 52 +- .../devicedefinitions/PlocMPSoCDefinitions.h | 278 +- .../devicedefinitions/RadSensorDefinitions.h | 131 +- .../devices/devicedefinitions/RwDefinitions.h | 270 +- .../devicedefinitions/SyrlinksDefinitions.h | 149 +- .../devicedefinitions/Tmp1075Definitions.h | 51 +- mission/memory/NVMParameterBase.cpp | 56 +- mission/memory/NVMParameterBase.h | 95 +- mission/tmtc/CCSDSHandler.cpp | 406 +- mission/tmtc/CCSDSHandler.h | 230 +- mission/tmtc/VirtualChannel.cpp | 90 +- mission/tmtc/VirtualChannel.h | 66 +- mission/utility/InitMission.h | 12 +- mission/utility/Timestamp.cpp | 32 +- mission/utility/Timestamp.h | 27 +- mission/utility/TmFunnel.cpp | 174 +- mission/utility/TmFunnel.h | 44 +- test/DummyParameter.h | 28 +- test/testtasks/PusTcInjector.cpp | 66 +- test/testtasks/PusTcInjector.h | 113 +- test/testtasks/TestTask.cpp | 140 +- test/testtasks/TestTask.h | 53 +- 206 files changed, 28883 insertions(+), 30263 deletions(-) diff --git a/bsp_hosted/InitMission.cpp b/bsp_hosted/InitMission.cpp index ed6b8820..0ca59db5 100644 --- a/bsp_hosted/InitMission.cpp +++ b/bsp_hosted/InitMission.cpp @@ -1,20 +1,19 @@ #include "InitMission.h" -#include "ObjectFactory.h" #include - +#include #include #include #include -#include #include #include #include - #include #include +#include "ObjectFactory.h" + #ifdef LINUX ServiceInterfaceStream sif::debug("DEBUG"); ServiceInterfaceStream sif::info("INFO"); @@ -27,133 +26,132 @@ ServiceInterfaceStream sif::warning("WARNING", true); ServiceInterfaceStream sif::error("ERROR", true, false, true); #endif -ObjectManagerIF *objectManager = nullptr; +ObjectManagerIF* objectManager = nullptr; void initmission::initMission() { - sif::info << "Building global objects.." << std::endl; - /* Instantiate global object manager and also create all objects */ - ObjectManager::instance()->setObjectFactoryFunction(ObjectFactory::produce, nullptr); - sif::info << "Initializing all objects.." << std::endl; - ObjectManager::instance()->initialize(); + sif::info << "Building global objects.." << std::endl; + /* Instantiate global object manager and also create all objects */ + ObjectManager::instance()->setObjectFactoryFunction(ObjectFactory::produce, nullptr); + sif::info << "Initializing all objects.." << std::endl; + ObjectManager::instance()->initialize(); - /* This function creates and starts all tasks */ - initTasks(); + /* This function creates and starts all tasks */ + initTasks(); } void initmission::initTasks() { - TaskFactory* factory = TaskFactory::instance(); - if(factory == nullptr) { - /* Should never happen ! */ - return; - } + TaskFactory* factory = TaskFactory::instance(); + if (factory == nullptr) { + /* Should never happen ! */ + return; + } #if OBSW_PRINT_MISSED_DEADLINES == 1 - void (*missedDeadlineFunc) (void) = TaskFactory::printMissedDeadline; + void (*missedDeadlineFunc)(void) = TaskFactory::printMissedDeadline; #else - void (*missedDeadlineFunc) (void) = nullptr; + void (*missedDeadlineFunc)(void) = nullptr; #endif - /* TMTC Distribution */ - PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask( - "DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - ReturnValue_t result = tmTcDistributor->addComponent( - objects::CCSDS_PACKET_DISTRIBUTOR); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } - result = tmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } - result = tmTcDistributor->addComponent(objects::TM_FUNNEL); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Object add component failed" << std::endl; - } + /* TMTC Distribution */ + PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask( + "DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + ReturnValue_t result = tmTcDistributor->addComponent(objects::CCSDS_PACKET_DISTRIBUTOR); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } + result = tmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } + result = tmTcDistributor->addComponent(objects::TM_FUNNEL); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } - /* UDP bridge */ - PeriodicTaskIF* tmtcBridgeTask = factory->createPeriodicTask( - "TMTC_UNIX_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - result = tmtcBridgeTask->addComponent(objects::TMTC_BRIDGE); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Add component UDP Unix Bridge failed" << std::endl; - } - PeriodicTaskIF* tmtcPollingTask = factory->createPeriodicTask( - "UDP_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); - result = tmtcPollingTask->addComponent(objects::TMTC_POLLING_TASK); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Add component UDP Polling failed" << std::endl; - } + /* UDP bridge */ + PeriodicTaskIF* tmtcBridgeTask = factory->createPeriodicTask( + "TMTC_UNIX_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + result = tmtcBridgeTask->addComponent(objects::TMTC_BRIDGE); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Add component UDP Unix Bridge failed" << std::endl; + } + PeriodicTaskIF* tmtcPollingTask = factory->createPeriodicTask( + "UDP_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = tmtcPollingTask->addComponent(objects::TMTC_POLLING_TASK); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Add component UDP Polling failed" << std::endl; + } - /* PUS Services */ - PeriodicTaskIF* pusVerification = factory->createPeriodicTask( - "PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } + /* PUS Services */ + PeriodicTaskIF* pusVerification = factory->createPeriodicTask( + "PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } - PeriodicTaskIF* pusEvents = factory->createPeriodicTask( - "PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusVerification->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); - if(result != HasReturnvaluesIF::RETURN_OK){ - initmission::printAddObjectError("PUS5", objects::PUS_SERVICE_5_EVENT_REPORTING); - } + PeriodicTaskIF* pusEvents = factory->createPeriodicTask( + "PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusVerification->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS5", objects::PUS_SERVICE_5_EVENT_REPORTING); + } - PeriodicTaskIF* pusHighPrio = factory->createPeriodicTask( - "PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS2", objects::PUS_SERVICE_2_DEVICE_ACCESS); - } - result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS9", objects::PUS_SERVICE_9_TIME_MGMT); - } + PeriodicTaskIF* pusHighPrio = factory->createPeriodicTask( + "PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS2", objects::PUS_SERVICE_2_DEVICE_ACCESS); + } + result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS9", objects::PUS_SERVICE_9_TIME_MGMT); + } - PeriodicTaskIF* pusMedPrio = factory->createPeriodicTask( - "PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); - result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS8", objects::PUS_SERVICE_8_FUNCTION_MGMT); - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS200", objects::PUS_SERVICE_200_MODE_MGMT); - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS20", objects::PUS_SERVICE_20_PARAMETERS); - } + PeriodicTaskIF* pusMedPrio = factory->createPeriodicTask( + "PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); + result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS8", objects::PUS_SERVICE_8_FUNCTION_MGMT); + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS200", objects::PUS_SERVICE_200_MODE_MGMT); + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS20", objects::PUS_SERVICE_20_PARAMETERS); + } - PeriodicTaskIF* pusLowPrio = factory->createPeriodicTask( - "PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc); - result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS17", objects::PUS_SERVICE_17_TEST); - } + PeriodicTaskIF* pusLowPrio = factory->createPeriodicTask( + "PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc); + result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS17", objects::PUS_SERVICE_17_TEST); + } - PeriodicTaskIF* testTask = factory->createPeriodicTask( - "TEST_TASK", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + PeriodicTaskIF* testTask = factory->createPeriodicTask( + "TEST_TASK", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); #if OBSW_ADD_TEST_CODE == 1 - result = testTask->addComponent(objects::TEST_TASK); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK); - } + result = testTask->addComponent(objects::TEST_TASK); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK); + } #endif /* OBSW_ADD_TEST_CODE == 1 */ - sif::info << "Starting tasks.." << std::endl; - tmTcDistributor->startTask(); - tmtcBridgeTask->startTask(); - tmtcPollingTask->startTask(); + sif::info << "Starting tasks.." << std::endl; + tmTcDistributor->startTask(); + tmtcBridgeTask->startTask(); + tmtcPollingTask->startTask(); - pusVerification->startTask(); - pusEvents->startTask(); - pusHighPrio->startTask(); - pusMedPrio->startTask(); - pusLowPrio->startTask(); + pusVerification->startTask(); + pusEvents->startTask(); + pusHighPrio->startTask(); + pusMedPrio->startTask(); + pusLowPrio->startTask(); #if OBSW_ADD_TEST_CODE == 1 - testTask->startTask(); + testTask->startTask(); #endif /* OBSW_ADD_TEST_CODE == 1 */ - sif::info << "Tasks started.." << std::endl; + sif::info << "Tasks started.." << std::endl; } diff --git a/bsp_hosted/InitMission.h b/bsp_hosted/InitMission.h index 01c72008..507de592 100644 --- a/bsp_hosted/InitMission.h +++ b/bsp_hosted/InitMission.h @@ -4,6 +4,6 @@ namespace initmission { void initMission(); void initTasks(); -}; +}; // namespace initmission #endif /* BSP_LINUX_INITMISSION_H_ */ diff --git a/bsp_hosted/ObjectFactory.cpp b/bsp_hosted/ObjectFactory.cpp index 6803ace4..e1be7588 100644 --- a/bsp_hosted/ObjectFactory.cpp +++ b/bsp_hosted/ObjectFactory.cpp @@ -1,14 +1,14 @@ #include "ObjectFactory.h" -#include "OBSWConfig.h" + +#include +#include +#include +#include #include #include #include -#include -#include - -#include -#include +#include "OBSWConfig.h" #if OBSW_USE_TMTC_TCP_BRIDGE == 0 #include "fsfw/osal/common/UdpTcPollingTask.h" @@ -20,29 +20,28 @@ #include - #if OBSW_ADD_TEST_CODE == 1 #include #endif -void Factory::setStaticFrameworkObjectIds(){ - PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; - PusServiceBase::packetDestination = objects::TM_FUNNEL; +void Factory::setStaticFrameworkObjectIds() { + PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; + PusServiceBase::packetDestination = objects::TM_FUNNEL; - CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; - CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; + CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; + CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; - TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; - // No storage object for now. - TmFunnel::storageDestination = objects::NO_OBJECT; + TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; + // No storage object for now. + TmFunnel::storageDestination = objects::NO_OBJECT; - VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; - TmPacketBase::timeStamperId = objects::TIME_STAMPER; + VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; + TmPacketBase::timeStamperId = objects::TIME_STAMPER; } -void ObjectFactory::produce(void* args){ - Factory::setStaticFrameworkObjectIds(); - ObjectFactory::produceGenericObjects(); +void ObjectFactory::produce(void* args) { + Factory::setStaticFrameworkObjectIds(); + ObjectFactory::produceGenericObjects(); - new TestTask(objects::TEST_TASK); + new TestTask(objects::TEST_TASK); } diff --git a/bsp_hosted/ObjectFactory.h b/bsp_hosted/ObjectFactory.h index feaba70e..b042f9dc 100644 --- a/bsp_hosted/ObjectFactory.h +++ b/bsp_hosted/ObjectFactory.h @@ -1,10 +1,9 @@ #ifndef BSP_LINUX_OBJECTFACTORY_H_ #define BSP_LINUX_OBJECTFACTORY_H_ - namespace ObjectFactory { - void setStatics(); - void produce(void* args); -}; +void setStatics(); +void produce(void* args); +}; // namespace ObjectFactory #endif /* BSP_LINUX_OBJECTFACTORY_H_ */ diff --git a/bsp_hosted/boardconfig/etl_profile.h b/bsp_hosted/boardconfig/etl_profile.h index c35ffb46..54aca344 100644 --- a/bsp_hosted/boardconfig/etl_profile.h +++ b/bsp_hosted/boardconfig/etl_profile.h @@ -32,7 +32,7 @@ SOFTWARE. #define ETL_CHECK_PUSH_POP -#define ETL_CPP11_SUPPORTED 1 -#define ETL_NO_NULLPTR_SUPPORT 0 +#define ETL_CPP11_SUPPORTED 1 +#define ETL_NO_NULLPTR_SUPPORT 0 #endif diff --git a/bsp_hosted/boardconfig/gcov.h b/bsp_hosted/boardconfig/gcov.h index 491d24c6..80acdd86 100644 --- a/bsp_hosted/boardconfig/gcov.h +++ b/bsp_hosted/boardconfig/gcov.h @@ -6,8 +6,9 @@ extern "C" void __gcov_flush(); #else void __gcov_flush() { - sif::info << "GCC GCOV: Please supply GCOV=1 in Makefile if " - "coverage information is desired.\n" << std::flush; + sif::info << "GCC GCOV: Please supply GCOV=1 in Makefile if " + "coverage information is desired.\n" + << std::flush; } #endif diff --git a/bsp_hosted/boardconfig/print.c b/bsp_hosted/boardconfig/print.c index f35f9447..9653fe5f 100644 --- a/bsp_hosted/boardconfig/print.c +++ b/bsp_hosted/boardconfig/print.c @@ -3,13 +3,9 @@ #include void printChar(const char* character, bool errStream) { - if(errStream) { - putc(*character, stderr); - return; - } - putc(*character, stdout); + if (errStream) { + putc(*character, stderr); + return; + } + putc(*character, stdout); } - - - - diff --git a/bsp_hosted/comIF/ArduinoComIF.cpp b/bsp_hosted/comIF/ArduinoComIF.cpp index 2db293e6..be136e45 100644 --- a/bsp_hosted/comIF/ArduinoComIF.cpp +++ b/bsp_hosted/comIF/ArduinoComIF.cpp @@ -1,376 +1,351 @@ #include "ArduinoComIF.h" -#include "ArduinoCookie.h" -#include #include +#include #include +#include "ArduinoCookie.h" + // This only works on Linux #ifdef LINUX -#include #include +#include #include #elif WIN32 -#include #include +#include #endif #include -ArduinoComIF::ArduinoComIF(object_id_t setObjectId, bool promptComIF, - const char *serialDevice): - rxBuffer(MAX_PACKET_SIZE * MAX_NUMBER_OF_SPI_DEVICES*10, true), - SystemObject(setObjectId) { +ArduinoComIF::ArduinoComIF(object_id_t setObjectId, bool promptComIF, const char *serialDevice) + : rxBuffer(MAX_PACKET_SIZE * MAX_NUMBER_OF_SPI_DEVICES * 10, true), SystemObject(setObjectId) { #ifdef LINUX - initialized = false; - serialPort = ::open("/dev/ttyUSB0", O_RDWR); + initialized = false; + serialPort = ::open("/dev/ttyUSB0", O_RDWR); - if (serialPort < 0) { - //configuration error - printf("Error %i from open: %s\n", errno, strerror(errno)); - return; - } + if (serialPort < 0) { + // configuration error + printf("Error %i from open: %s\n", errno, strerror(errno)); + return; + } - struct termios tty; - memset(&tty, 0, sizeof tty); + struct termios tty; + memset(&tty, 0, sizeof tty); - // Read in existing settings, and handle any error - if (tcgetattr(serialPort, &tty) != 0) { - printf("Error %i from tcgetattr: %s\n", errno, strerror(errno)); - return; - } + // Read in existing settings, and handle any error + if (tcgetattr(serialPort, &tty) != 0) { + printf("Error %i from tcgetattr: %s\n", errno, strerror(errno)); + return; + } - tty.c_cflag &= ~PARENB; // Clear parity bit, disabling parity - tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication - tty.c_cflag |= CS8; // 8 bits per byte - tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control - tty.c_lflag &= ~ICANON; //Disable Canonical Mode - tty.c_oflag &= ~OPOST; // Prevent special interpretation of output bytes (e.g. newline chars) - tty.c_oflag &= ~ONLCR; // Prevent conversion of newline to carriage return/line feed - tty.c_cc[VTIME] = 0; // Non Blocking - tty.c_cc[VMIN] = 0; + tty.c_cflag &= ~PARENB; // Clear parity bit, disabling parity + tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication + tty.c_cflag |= CS8; // 8 bits per byte + tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control + tty.c_lflag &= ~ICANON; // Disable Canonical Mode + tty.c_oflag &= ~OPOST; // Prevent special interpretation of output bytes (e.g. newline chars) + tty.c_oflag &= ~ONLCR; // Prevent conversion of newline to carriage return/line feed + tty.c_cc[VTIME] = 0; // Non Blocking + tty.c_cc[VMIN] = 0; - cfsetispeed(&tty, B9600); //Baudrate + cfsetispeed(&tty, B9600); // Baudrate - if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { - //printf("Error %i from tcsetattr: %s\n", errno, strerror(errno)); - return; - } + if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { + // printf("Error %i from tcsetattr: %s\n", errno, strerror(errno)); + return; + } - initialized = true; + initialized = true; #elif WIN32 - DCB serialParams = { 0 }; + DCB serialParams = {0}; - // we need to ask the COM port from the user. - if(promptComIF) { - sif::info << "Please enter the COM port (c to cancel): " << std::flush; - std::string comPort; - while(hCom == INVALID_HANDLE_VALUE) { + // we need to ask the COM port from the user. + if (promptComIF) { + sif::info << "Please enter the COM port (c to cancel): " << std::flush; + std::string comPort; + while (hCom == INVALID_HANDLE_VALUE) { + std::getline(std::cin, comPort); + if (comPort[0] == 'c') { + break; + } + const TCHAR *pcCommPort = comPort.c_str(); + hCom = CreateFileA(pcCommPort, // port name + GENERIC_READ | GENERIC_WRITE, // Read/Write + 0, // No Sharing + NULL, // No Security + OPEN_EXISTING, // Open existing port only + 0, // Non Overlapped I/O + NULL); // Null for Comm Devices - std::getline(std::cin, comPort); - if(comPort[0] == 'c') { - break; - } - const TCHAR *pcCommPort = comPort.c_str(); - hCom = CreateFileA(pcCommPort, //port name - GENERIC_READ | GENERIC_WRITE, //Read/Write - 0, // No Sharing - NULL, // No Security - OPEN_EXISTING,// Open existing port only - 0, // Non Overlapped I/O - NULL); // Null for Comm Devices + if (hCom == INVALID_HANDLE_VALUE) { + if (GetLastError() == 2) { + sif::error << "COM Port does not found!" << std::endl; + } else { + TCHAR err[128]; + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), err, sizeof(err), NULL); + // Handle the error. + sif::info << "CreateFileA Error code: " << GetLastError() << std::endl; + sif::error << err << std::flush; + } + sif::info << "Please enter a valid COM port: " << std::flush; + } + } + } - if (hCom == INVALID_HANDLE_VALUE) - { - if(GetLastError() == 2) { - sif::error << "COM Port does not found!" << std::endl; - } - else { - TCHAR err[128]; - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - err, sizeof(err), NULL); - // Handle the error. - sif::info << "CreateFileA Error code: " << GetLastError() - << std::endl; - sif::error << err << std::flush; - } - sif::info << "Please enter a valid COM port: " << std::flush; - } - } + serialParams.DCBlength = sizeof(serialParams); + if (baudRate == 9600) { + serialParams.BaudRate = CBR_9600; + } + if (baudRate == 115200) { + serialParams.BaudRate = CBR_115200; + } else { + serialParams.BaudRate = baudRate; + } - } + serialParams.ByteSize = 8; + serialParams.Parity = NOPARITY; + serialParams.StopBits = ONESTOPBIT; + SetCommState(hCom, &serialParams); - - serialParams.DCBlength = sizeof(serialParams); - if(baudRate == 9600) { - serialParams.BaudRate = CBR_9600; - } - if(baudRate == 115200) { - serialParams.BaudRate = CBR_115200; - } - else { - serialParams.BaudRate = baudRate; - } - - serialParams.ByteSize = 8; - serialParams.Parity = NOPARITY; - serialParams.StopBits = ONESTOPBIT; - SetCommState(hCom, &serialParams); - - COMMTIMEOUTS timeout = { 0 }; - // This will set the read operation to be blocking until data is received - // and then read continuously until there is a gap of one millisecond. - timeout.ReadIntervalTimeout = 1; - timeout.ReadTotalTimeoutConstant = 0; - timeout.ReadTotalTimeoutMultiplier = 0; - timeout.WriteTotalTimeoutConstant = 0; - timeout.WriteTotalTimeoutMultiplier = 0; - SetCommTimeouts(hCom, &timeout); - // Serial port should now be read for operations. + COMMTIMEOUTS timeout = {0}; + // This will set the read operation to be blocking until data is received + // and then read continuously until there is a gap of one millisecond. + timeout.ReadIntervalTimeout = 1; + timeout.ReadTotalTimeoutConstant = 0; + timeout.ReadTotalTimeoutMultiplier = 0; + timeout.WriteTotalTimeoutConstant = 0; + timeout.WriteTotalTimeoutMultiplier = 0; + SetCommTimeouts(hCom, &timeout); + // Serial port should now be read for operations. #endif } ArduinoComIF::~ArduinoComIF() { #ifdef LINUX - ::close(serialPort); + ::close(serialPort); #elif WIN32 - CloseHandle(hCom); + CloseHandle(hCom); #endif } -ReturnValue_t ArduinoComIF::initializeInterface(CookieIF * cookie) { - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t ArduinoComIF::initializeInterface(CookieIF *cookie) { + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t ArduinoComIF::sendMessage(CookieIF *cookie, const uint8_t *data, - size_t len) { - ArduinoCookie *arduinoCookie = dynamic_cast(cookie); - if (arduinoCookie == nullptr) { - return INVALID_COOKIE_TYPE; - } +ReturnValue_t ArduinoComIF::sendMessage(CookieIF *cookie, const uint8_t *data, size_t len) { + ArduinoCookie *arduinoCookie = dynamic_cast(cookie); + if (arduinoCookie == nullptr) { + return INVALID_COOKIE_TYPE; + } - return sendMessage(arduinoCookie->command, arduinoCookie->address, data, - len); + return sendMessage(arduinoCookie->command, arduinoCookie->address, data, len); } -ReturnValue_t ArduinoComIF::getSendSuccess(CookieIF *cookie) { - return RETURN_OK; +ReturnValue_t ArduinoComIF::getSendSuccess(CookieIF *cookie) { return RETURN_OK; } + +ReturnValue_t ArduinoComIF::requestReceiveMessage(CookieIF *cookie, size_t requestLen) { + return RETURN_OK; } -ReturnValue_t ArduinoComIF::requestReceiveMessage(CookieIF *cookie, - size_t requestLen) { - return RETURN_OK; +ReturnValue_t ArduinoComIF::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, size_t *size) { + handleSerialPortRx(); + + ArduinoCookie *arduinoCookie = dynamic_cast(cookie); + if (arduinoCookie == nullptr) { + return INVALID_COOKIE_TYPE; + } + + *buffer = arduinoCookie->replyBuffer.data(); + *size = arduinoCookie->receivedDataLen; + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t ArduinoComIF::readReceivedMessage(CookieIF *cookie, - uint8_t **buffer, size_t *size) { +ReturnValue_t ArduinoComIF::sendMessage(uint8_t command, uint8_t address, const uint8_t *data, + size_t dataLen) { + if (dataLen > UINT16_MAX) { + return TOO_MUCH_DATA; + } - handleSerialPortRx(); + // being conservative here + uint8_t sendBuffer[(dataLen + 6) * 2 + 2]; - ArduinoCookie *arduinoCookie = dynamic_cast(cookie); - if (arduinoCookie == nullptr) { - return INVALID_COOKIE_TYPE; - } + sendBuffer[0] = DleEncoder::STX_CHAR; - *buffer = arduinoCookie->replyBuffer.data(); - *size = arduinoCookie->receivedDataLen; - return HasReturnvaluesIF::RETURN_OK; -} + uint8_t *currentPosition = sendBuffer + 1; + size_t remainingLen = sizeof(sendBuffer) - 1; + size_t encodedLen = 0; -ReturnValue_t ArduinoComIF::sendMessage(uint8_t command, - uint8_t address, const uint8_t *data, size_t dataLen) { - if (dataLen > UINT16_MAX) { - return TOO_MUCH_DATA; - } + ReturnValue_t result = + DleEncoder::encode(&command, 1, currentPosition, remainingLen, &encodedLen, false); + if (result != RETURN_OK) { + return result; + } + currentPosition += encodedLen; + remainingLen -= encodedLen; // DleEncoder will never return encodedLen > remainingLen - //being conservative here - uint8_t sendBuffer[(dataLen + 6) * 2 + 2]; + result = DleEncoder::encode(&address, 1, currentPosition, remainingLen, &encodedLen, false); + if (result != RETURN_OK) { + return result; + } + currentPosition += encodedLen; + remainingLen -= encodedLen; // DleEncoder will never return encodedLen > remainingLen - sendBuffer[0] = DleEncoder::STX_CHAR; + uint8_t temporaryBuffer[2]; - uint8_t *currentPosition = sendBuffer + 1; - size_t remainingLen = sizeof(sendBuffer) - 1; - size_t encodedLen = 0; + // note to Lukas: yes we _could_ use Serialize here, but for 16 bit it is a bit too much... + temporaryBuffer[0] = dataLen >> 8; // we checked dataLen above + temporaryBuffer[1] = dataLen; - ReturnValue_t result = DleEncoder::encode(&command, 1, currentPosition, - remainingLen, &encodedLen, false); - if (result != RETURN_OK) { - return result; - } - currentPosition += encodedLen; - remainingLen -= encodedLen; //DleEncoder will never return encodedLen > remainingLen + result = + DleEncoder::encode(temporaryBuffer, 2, currentPosition, remainingLen, &encodedLen, false); + if (result != RETURN_OK) { + return result; + } + currentPosition += encodedLen; + remainingLen -= encodedLen; // DleEncoder will never return encodedLen > remainingLen - result = DleEncoder::encode(&address, 1, currentPosition, remainingLen, - &encodedLen, false); - if (result != RETURN_OK) { - return result; - } - currentPosition += encodedLen; - remainingLen -= encodedLen; //DleEncoder will never return encodedLen > remainingLen + // encoding the actual data + result = DleEncoder::encode(data, dataLen, currentPosition, remainingLen, &encodedLen, false); + if (result != RETURN_OK) { + return result; + } + currentPosition += encodedLen; + remainingLen -= encodedLen; // DleEncoder will never return encodedLen > remainingLen - uint8_t temporaryBuffer[2]; + uint16_t crc = CRC::crc16ccitt(&command, 1); + crc = CRC::crc16ccitt(&address, 1, crc); + // fortunately the length is still there + crc = CRC::crc16ccitt(temporaryBuffer, 2, crc); + crc = CRC::crc16ccitt(data, dataLen, crc); - //note to Lukas: yes we _could_ use Serialize here, but for 16 bit it is a bit too much... - temporaryBuffer[0] = dataLen >> 8; //we checked dataLen above - temporaryBuffer[1] = dataLen; + temporaryBuffer[0] = crc >> 8; + temporaryBuffer[1] = crc; - result = DleEncoder::encode(temporaryBuffer, 2, currentPosition, - remainingLen, &encodedLen, false); - if (result != RETURN_OK) { - return result; - } - currentPosition += encodedLen; - remainingLen -= encodedLen; //DleEncoder will never return encodedLen > remainingLen + result = + DleEncoder::encode(temporaryBuffer, 2, currentPosition, remainingLen, &encodedLen, false); + if (result != RETURN_OK) { + return result; + } + currentPosition += encodedLen; + remainingLen -= encodedLen; // DleEncoder will never return encodedLen > remainingLen - //encoding the actual data - result = DleEncoder::encode(data, dataLen, currentPosition, remainingLen, - &encodedLen, false); - if (result != RETURN_OK) { - return result; - } - currentPosition += encodedLen; - remainingLen -= encodedLen; //DleEncoder will never return encodedLen > remainingLen + if (remainingLen > 0) { + *currentPosition = DleEncoder::ETX_CHAR; + } + remainingLen -= 1; - uint16_t crc = CRC::crc16ccitt(&command, 1); - crc = CRC::crc16ccitt(&address, 1, crc); - //fortunately the length is still there - crc = CRC::crc16ccitt(temporaryBuffer, 2, crc); - crc = CRC::crc16ccitt(data, dataLen, crc); - - temporaryBuffer[0] = crc >> 8; - temporaryBuffer[1] = crc; - - result = DleEncoder::encode(temporaryBuffer, 2, currentPosition, - remainingLen, &encodedLen, false); - if (result != RETURN_OK) { - return result; - } - currentPosition += encodedLen; - remainingLen -= encodedLen; //DleEncoder will never return encodedLen > remainingLen - - if (remainingLen > 0) { - *currentPosition = DleEncoder::ETX_CHAR; - } - remainingLen -= 1; - - encodedLen = sizeof(sendBuffer) - remainingLen; + encodedLen = sizeof(sendBuffer) - remainingLen; #ifdef LINUX - ssize_t writtenlen = ::write(serialPort, sendBuffer, encodedLen); - if (writtenlen < 0) { - //we could try to find out what happened... - return RETURN_FAILED; - } - if (writtenlen != encodedLen) { - //the OS failed us, we do not try to block until everything is written, as - //we can not block the whole system here - return RETURN_FAILED; - } - return RETURN_OK; + ssize_t writtenlen = ::write(serialPort, sendBuffer, encodedLen); + if (writtenlen < 0) { + // we could try to find out what happened... + return RETURN_FAILED; + } + if (writtenlen != encodedLen) { + // the OS failed us, we do not try to block until everything is written, as + // we can not block the whole system here + return RETURN_FAILED; + } + return RETURN_OK; #elif WIN32 - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; #endif } void ArduinoComIF::handleSerialPortRx() { #ifdef LINUX - uint32_t availableSpace = rxBuffer.availableWriteSpace(); + uint32_t availableSpace = rxBuffer.availableWriteSpace(); - uint8_t dataFromSerial[availableSpace]; + uint8_t dataFromSerial[availableSpace]; - ssize_t bytesRead = read(serialPort, dataFromSerial, - sizeof(dataFromSerial)); + ssize_t bytesRead = read(serialPort, dataFromSerial, sizeof(dataFromSerial)); - if (bytesRead < 0) { - return; - } + if (bytesRead < 0) { + return; + } - rxBuffer.writeData(dataFromSerial, bytesRead); + rxBuffer.writeData(dataFromSerial, bytesRead); - uint8_t dataReceivedSoFar[rxBuffer.getMaxSize()]; + uint8_t dataReceivedSoFar[rxBuffer.getMaxSize()]; - uint32_t dataLenReceivedSoFar = 0; + uint32_t dataLenReceivedSoFar = 0; - rxBuffer.readData(dataReceivedSoFar, sizeof(dataReceivedSoFar), true, - &dataLenReceivedSoFar); + rxBuffer.readData(dataReceivedSoFar, sizeof(dataReceivedSoFar), true, &dataLenReceivedSoFar); - //look for STX - size_t firstSTXinRawData = 0; - while ((firstSTXinRawData < dataLenReceivedSoFar) - && (dataReceivedSoFar[firstSTXinRawData] != DleEncoder::STX_CHAR)) { - firstSTXinRawData++; - } + // look for STX + size_t firstSTXinRawData = 0; + while ((firstSTXinRawData < dataLenReceivedSoFar) && + (dataReceivedSoFar[firstSTXinRawData] != DleEncoder::STX_CHAR)) { + firstSTXinRawData++; + } - if (dataReceivedSoFar[firstSTXinRawData] != DleEncoder::STX_CHAR) { - //there is no STX in our data, throw it away... - rxBuffer.deleteData(dataLenReceivedSoFar); - return; - } + if (dataReceivedSoFar[firstSTXinRawData] != DleEncoder::STX_CHAR) { + // there is no STX in our data, throw it away... + rxBuffer.deleteData(dataLenReceivedSoFar); + return; + } - uint8_t packet[MAX_PACKET_SIZE]; - size_t packetLen = 0; + uint8_t packet[MAX_PACKET_SIZE]; + size_t packetLen = 0; - size_t readSize = 0; + size_t readSize = 0; - ReturnValue_t result = DleEncoder::decode( - dataReceivedSoFar + firstSTXinRawData, - dataLenReceivedSoFar - firstSTXinRawData, &readSize, packet, - sizeof(packet), &packetLen); + ReturnValue_t result = DleEncoder::decode(dataReceivedSoFar + firstSTXinRawData, + dataLenReceivedSoFar - firstSTXinRawData, &readSize, + packet, sizeof(packet), &packetLen); - size_t toDelete = firstSTXinRawData; - if (result == HasReturnvaluesIF::RETURN_OK) { - handlePacket(packet, packetLen); + size_t toDelete = firstSTXinRawData; + if (result == HasReturnvaluesIF::RETURN_OK) { + handlePacket(packet, packetLen); - // after handling the packet, we can delete it from the raw stream, - // it has been copied to packet - toDelete += readSize; - } + // after handling the packet, we can delete it from the raw stream, + // it has been copied to packet + toDelete += readSize; + } - //remove Data which was processed - rxBuffer.deleteData(toDelete); + // remove Data which was processed + rxBuffer.deleteData(toDelete); #elif WIN32 #endif } -void ArduinoComIF::setBaudrate(uint32_t baudRate) { - this->baudRate = baudRate; -} +void ArduinoComIF::setBaudrate(uint32_t baudRate) { this->baudRate = baudRate; } void ArduinoComIF::handlePacket(uint8_t *packet, size_t packetLen) { - uint16_t crc = CRC::crc16ccitt(packet, packetLen); - if (crc != 0) { - //CRC error - return; - } + uint16_t crc = CRC::crc16ccitt(packet, packetLen); + if (crc != 0) { + // CRC error + return; + } - uint8_t command = packet[0]; - uint8_t address = packet[1]; + uint8_t command = packet[0]; + uint8_t address = packet[1]; - uint16_t size = (packet[2] << 8) + packet[3]; + uint16_t size = (packet[2] << 8) + packet[3]; - if (size != packetLen - 6) { - //Invalid Length - return; - } + if (size != packetLen - 6) { + // Invalid Length + return; + } - switch (command) { - case ArduinoCookie::SPI: { - //ArduinoCookie **itsComplicated; - auto findIter = spiMap.find(address); - if (findIter == spiMap.end()) { - //we do no know this address - return; - } - ArduinoCookie& cookie = findIter->second; - if (packetLen > cookie.maxReplySize + 6) { - packetLen = cookie.maxReplySize + 6; - } - std::memcpy(cookie.replyBuffer.data(), packet + 4, packetLen - 6); - cookie.receivedDataLen = packetLen - 6; - } - break; - default: - return; - } + switch (command) { + case ArduinoCookie::SPI: { + // ArduinoCookie **itsComplicated; + auto findIter = spiMap.find(address); + if (findIter == spiMap.end()) { + // we do no know this address + return; + } + ArduinoCookie &cookie = findIter->second; + if (packetLen > cookie.maxReplySize + 6) { + packetLen = cookie.maxReplySize + 6; + } + std::memcpy(cookie.replyBuffer.data(), packet + 4, packetLen - 6); + cookie.receivedDataLen = packetLen - 6; + } break; + default: + return; + } } diff --git a/bsp_hosted/comIF/ArduinoComIF.h b/bsp_hosted/comIF/ArduinoComIF.h index 84bd959d..8476b6b5 100644 --- a/bsp_hosted/comIF/ArduinoComIF.h +++ b/bsp_hosted/comIF/ArduinoComIF.h @@ -4,8 +4,8 @@ #include #include #include -#include #include +#include #include #include @@ -14,56 +14,53 @@ #include #endif -//Forward declaration, so users don't peek +// Forward declaration, so users don't peek class ArduinoCookie; -class ArduinoComIF: public SystemObject, - public DeviceCommunicationIF { -public: - static const uint8_t MAX_NUMBER_OF_SPI_DEVICES = 8; - static const uint8_t MAX_PACKET_SIZE = 64; +class ArduinoComIF : public SystemObject, public DeviceCommunicationIF { + public: + static const uint8_t MAX_NUMBER_OF_SPI_DEVICES = 8; + static const uint8_t MAX_PACKET_SIZE = 64; - static const uint8_t COMMAND_INVALID = -1; - static const uint8_t COMMAND_SPI = 1; + static const uint8_t COMMAND_INVALID = -1; + static const uint8_t COMMAND_SPI = 1; - ArduinoComIF(object_id_t setObjectId, bool promptComIF = false, - const char *serialDevice = nullptr); - void setBaudrate(uint32_t baudRate); + ArduinoComIF(object_id_t setObjectId, bool promptComIF = false, + const char *serialDevice = nullptr); + void setBaudrate(uint32_t baudRate); - virtual ~ArduinoComIF(); + virtual ~ArduinoComIF(); - /** DeviceCommunicationIF overrides */ - virtual ReturnValue_t initializeInterface(CookieIF * cookie) override; - virtual ReturnValue_t sendMessage(CookieIF *cookie, - const uint8_t * sendData, size_t sendLen) override; - virtual ReturnValue_t getSendSuccess(CookieIF *cookie) override; - virtual ReturnValue_t requestReceiveMessage(CookieIF *cookie, - size_t requestLen) override; - virtual ReturnValue_t readReceivedMessage(CookieIF *cookie, - uint8_t **buffer, size_t *size) override; + /** DeviceCommunicationIF overrides */ + virtual ReturnValue_t initializeInterface(CookieIF *cookie) override; + virtual ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t *sendData, + size_t sendLen) override; + virtual ReturnValue_t getSendSuccess(CookieIF *cookie) override; + virtual ReturnValue_t requestReceiveMessage(CookieIF *cookie, size_t requestLen) override; + virtual ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer, + size_t *size) override; -private: + private: #ifdef LINUX #elif WIN32 - HANDLE hCom = INVALID_HANDLE_VALUE; + HANDLE hCom = INVALID_HANDLE_VALUE; #endif - // remembering if the initialization in the ctor worked - // if not, all calls are disabled - bool initialized = false; - int serialPort = 0; - // Default baud rate is 9600 for now. - uint32_t baudRate = 9600; + // remembering if the initialization in the ctor worked + // if not, all calls are disabled + bool initialized = false; + int serialPort = 0; + // Default baud rate is 9600 for now. + uint32_t baudRate = 9600; - //used to know where to put the data if a reply is received - std::map spiMap; + // used to know where to put the data if a reply is received + std::map spiMap; - SimpleRingBuffer rxBuffer; + SimpleRingBuffer rxBuffer; - ReturnValue_t sendMessage(uint8_t command, uint8_t address, - const uint8_t *data, size_t dataLen); - void handleSerialPortRx(); + ReturnValue_t sendMessage(uint8_t command, uint8_t address, const uint8_t *data, size_t dataLen); + void handleSerialPortRx(); - void handlePacket(uint8_t *packet, size_t packetLen); + void handlePacket(uint8_t *packet, size_t packetLen); }; #endif /* MISSION_ARDUINOCOMMINTERFACE_H_ */ diff --git a/bsp_hosted/comIF/ArduinoCookie.cpp b/bsp_hosted/comIF/ArduinoCookie.cpp index bc698720..89cb1568 100644 --- a/bsp_hosted/comIF/ArduinoCookie.cpp +++ b/bsp_hosted/comIF/ArduinoCookie.cpp @@ -1,8 +1,8 @@ #include -ArduinoCookie::ArduinoCookie(Protocol_t protocol, uint8_t address, - const size_t maxReplySize) : - protocol(protocol), command(protocol), address(address), - maxReplySize(maxReplySize), replyBuffer(maxReplySize) { -} - +ArduinoCookie::ArduinoCookie(Protocol_t protocol, uint8_t address, const size_t maxReplySize) + : protocol(protocol), + command(protocol), + address(address), + maxReplySize(maxReplySize), + replyBuffer(maxReplySize) {} diff --git a/bsp_hosted/comIF/ArduinoCookie.h b/bsp_hosted/comIF/ArduinoCookie.h index a5f91f64..04d4bd83 100644 --- a/bsp_hosted/comIF/ArduinoCookie.h +++ b/bsp_hosted/comIF/ArduinoCookie.h @@ -2,26 +2,21 @@ #define MISSION_ARDUINO_ARDUINOCOOKIE_H_ #include + #include -class ArduinoCookie: public CookieIF { -public: - enum Protocol_t: uint8_t { - INVALID, - SPI, - I2C - }; +class ArduinoCookie : public CookieIF { + public: + enum Protocol_t : uint8_t { INVALID, SPI, I2C }; - ArduinoCookie(Protocol_t protocol, uint8_t address, - const size_t maxReplySize); - - Protocol_t protocol; - uint8_t command; - uint8_t address; - std::vector replyBuffer; - size_t receivedDataLen = 0; - size_t maxReplySize; + ArduinoCookie(Protocol_t protocol, uint8_t address, const size_t maxReplySize); + Protocol_t protocol; + uint8_t command; + uint8_t address; + std::vector replyBuffer; + size_t receivedDataLen = 0; + size_t maxReplySize; }; #endif /* MISSION_ARDUINO_ARDUINOCOOKIE_H_ */ diff --git a/bsp_hosted/fsfwconfig/devices/gpioIds.h b/bsp_hosted/fsfwconfig/devices/gpioIds.h index a4b4ac81..1ede0571 100644 --- a/bsp_hosted/fsfwconfig/devices/gpioIds.h +++ b/bsp_hosted/fsfwconfig/devices/gpioIds.h @@ -2,56 +2,53 @@ #define FSFWCONFIG_DEVICES_GPIOIDS_H_ namespace gpioIds { - enum gpioId_t { - HEATER_0, - HEATER_1, - HEATER_2, - HEATER_3, - HEATER_4, - HEATER_5, - HEATER_6, - HEATER_7, - DEPLSA1, - DEPLSA2, +enum gpioId_t { + HEATER_0, + HEATER_1, + HEATER_2, + HEATER_3, + HEATER_4, + HEATER_5, + HEATER_6, + HEATER_7, + DEPLSA1, + DEPLSA2, - MGM_0_LIS3_CS, - MGM_1_RM3100_CS, - GYRO_0_ADIS_CS, - GYRO_1_L3G_CS, - GYRO_2_L3G_CS, - MGM_2_LIS3_CS, - MGM_3_RM3100_CS, + MGM_0_LIS3_CS, + MGM_1_RM3100_CS, + GYRO_0_ADIS_CS, + GYRO_1_L3G_CS, + GYRO_2_L3G_CS, + MGM_2_LIS3_CS, + MGM_3_RM3100_CS, - TEST_ID_0, - TEST_ID_1, + TEST_ID_0, + TEST_ID_1, - RTD_IC_3, - RTD_IC_4, - RTD_IC_5, - RTD_IC_6, - RTD_IC_7, - RTD_IC_8, - RTD_IC_9, - RTD_IC_10, - RTD_IC_11, - RTD_IC_12, - RTD_IC_13, - RTD_IC_14, - RTD_IC_15, - RTD_IC_16, - RTD_IC_17, - RTD_IC_18, + RTD_IC_3, + RTD_IC_4, + RTD_IC_5, + RTD_IC_6, + RTD_IC_7, + RTD_IC_8, + RTD_IC_9, + RTD_IC_10, + RTD_IC_11, + RTD_IC_12, + RTD_IC_13, + RTD_IC_14, + RTD_IC_15, + RTD_IC_16, + RTD_IC_17, + RTD_IC_18, - SPI_MUX_BIT_1, - SPI_MUX_BIT_2, - SPI_MUX_BIT_3, - SPI_MUX_BIT_4, - SPI_MUX_BIT_5, - SPI_MUX_BIT_6 - }; + SPI_MUX_BIT_1, + SPI_MUX_BIT_2, + SPI_MUX_BIT_3, + SPI_MUX_BIT_4, + SPI_MUX_BIT_5, + SPI_MUX_BIT_6 +}; } - - - #endif /* FSFWCONFIG_DEVICES_GPIOIDS_H_ */ diff --git a/bsp_hosted/fsfwconfig/devices/powerSwitcherList.h b/bsp_hosted/fsfwconfig/devices/powerSwitcherList.h index c216c828..ae259374 100644 --- a/bsp_hosted/fsfwconfig/devices/powerSwitcherList.h +++ b/bsp_hosted/fsfwconfig/devices/powerSwitcherList.h @@ -4,55 +4,54 @@ #include namespace pcduSwitches { - /* Switches are uint8_t datatype and go from 0 to 255 */ - enum SwitcherList { - Q7S, - PAYLOAD_PCDU_CH1, - RW, - TCS_BOARD_8V_HEATER_IN, - SUS_REDUNDANT, - DEPLOYMENT_MECHANISM, - PAYLOAD_PCDU_CH6, - ACS_BOARD_SIDE_B, - PAYLOAD_CAMERA, - TCS_BOARD_3V3, - SYRLINKS, - STAR_TRACKER, - MGT, - SUS_NOMINAL, - SOLAR_CELL_EXP, - PLOC, - ACS_BOARD_SIDE_A, - NUMBER_OF_SWITCHES - }; +/* Switches are uint8_t datatype and go from 0 to 255 */ +enum SwitcherList { + Q7S, + PAYLOAD_PCDU_CH1, + RW, + TCS_BOARD_8V_HEATER_IN, + SUS_REDUNDANT, + DEPLOYMENT_MECHANISM, + PAYLOAD_PCDU_CH6, + ACS_BOARD_SIDE_B, + PAYLOAD_CAMERA, + TCS_BOARD_3V3, + SYRLINKS, + STAR_TRACKER, + MGT, + SUS_NOMINAL, + SOLAR_CELL_EXP, + PLOC, + ACS_BOARD_SIDE_A, + NUMBER_OF_SWITCHES +}; - static const uint8_t ON = 1; - static const uint8_t OFF = 0; +static const uint8_t ON = 1; +static const uint8_t OFF = 0; - /* Output states after reboot of the PDUs */ - static const uint8_t INIT_STATE_Q7S = ON; - static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH1 = OFF; - static const uint8_t INIT_STATE_RW = OFF; +/* Output states after reboot of the PDUs */ +static const uint8_t INIT_STATE_Q7S = ON; +static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH1 = OFF; +static const uint8_t INIT_STATE_RW = OFF; #if BOARD_TE0720 == 1 - /* Because the TE0720 is not connected to the PCDU, this switch is always on */ - static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = ON; +/* Because the TE0720 is not connected to the PCDU, this switch is always on */ +static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = ON; #else - static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = OFF; +static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = OFF; #endif - static const uint8_t INIT_STATE_SUS_REDUNDANT = OFF; - static const uint8_t INIT_STATE_DEPLOYMENT_MECHANISM = OFF; - static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH6 = OFF; - static const uint8_t INIT_STATE_ACS_BOARD_SIDE_B = OFF; - static const uint8_t INIT_STATE_PAYLOAD_CAMERA = OFF; - static const uint8_t INIT_STATE_TCS_BOARD_3V3 = OFF; - static const uint8_t INIT_STATE_SYRLINKS = OFF; - static const uint8_t INIT_STATE_STAR_TRACKER = OFF; - static const uint8_t INIT_STATE_MGT = OFF; - static const uint8_t INIT_STATE_SUS_NOMINAL = OFF; - static const uint8_t INIT_STATE_SOLAR_CELL_EXP = OFF; - static const uint8_t INIT_STATE_PLOC = OFF; - static const uint8_t INIT_STATE_ACS_BOARD_SIDE_A = OFF; -} - +static const uint8_t INIT_STATE_SUS_REDUNDANT = OFF; +static const uint8_t INIT_STATE_DEPLOYMENT_MECHANISM = OFF; +static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH6 = OFF; +static const uint8_t INIT_STATE_ACS_BOARD_SIDE_B = OFF; +static const uint8_t INIT_STATE_PAYLOAD_CAMERA = OFF; +static const uint8_t INIT_STATE_TCS_BOARD_3V3 = OFF; +static const uint8_t INIT_STATE_SYRLINKS = OFF; +static const uint8_t INIT_STATE_STAR_TRACKER = OFF; +static const uint8_t INIT_STATE_MGT = OFF; +static const uint8_t INIT_STATE_SUS_NOMINAL = OFF; +static const uint8_t INIT_STATE_SOLAR_CELL_EXP = OFF; +static const uint8_t INIT_STATE_PLOC = OFF; +static const uint8_t INIT_STATE_ACS_BOARD_SIDE_A = OFF; +} // namespace pcduSwitches #endif /* FSFWCONFIG_DEVICES_POWERSWITCHERLIST_H_ */ diff --git a/bsp_hosted/fsfwconfig/events/subsystemIdRanges.h b/bsp_hosted/fsfwconfig/events/subsystemIdRanges.h index 7335a804..9dc50c50 100644 --- a/bsp_hosted/fsfwconfig/events/subsystemIdRanges.h +++ b/bsp_hosted/fsfwconfig/events/subsystemIdRanges.h @@ -2,6 +2,7 @@ #define CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ #include + #include /** @@ -9,9 +10,7 @@ * Numbers 0-80 are reserved for FSFW Subsystem IDs (framework/events/) */ namespace SUBSYSTEM_ID { -enum: uint8_t { - SUBSYSTEM_ID_START = COMMON_SUBSYSTEM_ID_END -}; +enum : uint8_t { SUBSYSTEM_ID_START = COMMON_SUBSYSTEM_ID_END }; } #endif /* CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ */ diff --git a/bsp_hosted/fsfwconfig/events/translateEvents.cpp b/bsp_hosted/fsfwconfig/events/translateEvents.cpp index 7b9ce4b5..fb9e1bf4 100644 --- a/bsp_hosted/fsfwconfig/events/translateEvents.cpp +++ b/bsp_hosted/fsfwconfig/events/translateEvents.cpp @@ -89,176 +89,176 @@ const char *ACK_FAILURE_STRING = "ACK_FAILURE"; const char *EXE_FAILURE_STRING = "EXE_FAILURE"; const char *CRC_FAILURE_EVENT_STRING = "CRC_FAILURE_EVENT"; -const char * translateEvents(Event event) { - switch( (event & 0xffff) ) { - case(2200): - return STORE_SEND_WRITE_FAILED_STRING; - case(2201): - return STORE_WRITE_FAILED_STRING; - case(2202): - return STORE_SEND_READ_FAILED_STRING; - case(2203): - return STORE_READ_FAILED_STRING; - case(2204): - return UNEXPECTED_MSG_STRING; - case(2205): - return STORING_FAILED_STRING; - case(2206): - return TM_DUMP_FAILED_STRING; - case(2207): - return STORE_INIT_FAILED_STRING; - case(2208): - return STORE_INIT_EMPTY_STRING; - case(2209): - return STORE_CONTENT_CORRUPTED_STRING; - case(2210): - return STORE_INITIALIZE_STRING; - case(2211): - return INIT_DONE_STRING; - case(2212): - return DUMP_FINISHED_STRING; - case(2213): - return DELETION_FINISHED_STRING; - case(2214): - return DELETION_FAILED_STRING; - case(2215): - return AUTO_CATALOGS_SENDING_FAILED_STRING; - case(2600): - return GET_DATA_FAILED_STRING; - case(2601): - return STORE_DATA_FAILED_STRING; - case(2800): - return DEVICE_BUILDING_COMMAND_FAILED_STRING; - case(2801): - return DEVICE_SENDING_COMMAND_FAILED_STRING; - case(2802): - return DEVICE_REQUESTING_REPLY_FAILED_STRING; - case(2803): - return DEVICE_READING_REPLY_FAILED_STRING; - case(2804): - return DEVICE_INTERPRETING_REPLY_FAILED_STRING; - case(2805): - return DEVICE_MISSED_REPLY_STRING; - case(2806): - return DEVICE_UNKNOWN_REPLY_STRING; - case(2807): - return DEVICE_UNREQUESTED_REPLY_STRING; - case(2808): - return INVALID_DEVICE_COMMAND_STRING; - case(2809): - return MONITORING_LIMIT_EXCEEDED_STRING; - case(2810): - return MONITORING_AMBIGUOUS_STRING; - case(4201): - return FUSE_CURRENT_HIGH_STRING; - case(4202): - return FUSE_WENT_OFF_STRING; - case(4204): - return POWER_ABOVE_HIGH_LIMIT_STRING; - case(4205): - return POWER_BELOW_LOW_LIMIT_STRING; - case(4300): - return SWITCH_WENT_OFF_STRING; - case(5000): - return HEATER_ON_STRING; - case(5001): - return HEATER_OFF_STRING; - case(5002): - return HEATER_TIMEOUT_STRING; - case(5003): - return HEATER_STAYED_ON_STRING; - case(5004): - return HEATER_STAYED_OFF_STRING; - case(5200): - return TEMP_SENSOR_HIGH_STRING; - case(5201): - return TEMP_SENSOR_LOW_STRING; - case(5202): - return TEMP_SENSOR_GRADIENT_STRING; - case(5901): - return COMPONENT_TEMP_LOW_STRING; - case(5902): - return COMPONENT_TEMP_HIGH_STRING; - case(5903): - return COMPONENT_TEMP_OOL_LOW_STRING; - case(5904): - return COMPONENT_TEMP_OOL_HIGH_STRING; - case(5905): - return TEMP_NOT_IN_OP_RANGE_STRING; - case(7101): - return FDIR_CHANGED_STATE_STRING; - case(7102): - return FDIR_STARTS_RECOVERY_STRING; - case(7103): - return FDIR_TURNS_OFF_DEVICE_STRING; - case(7201): - return MONITOR_CHANGED_STATE_STRING; - case(7202): - return VALUE_BELOW_LOW_LIMIT_STRING; - case(7203): - return VALUE_ABOVE_HIGH_LIMIT_STRING; - case(7204): - return VALUE_OUT_OF_RANGE_STRING; - case(7301): - return SWITCHING_TM_FAILED_STRING; - case(7400): - return CHANGING_MODE_STRING; - case(7401): - return MODE_INFO_STRING; - case(7402): - return FALLBACK_FAILED_STRING; - case(7403): - return MODE_TRANSITION_FAILED_STRING; - case(7404): - return CANT_KEEP_MODE_STRING; - case(7405): - return OBJECT_IN_INVALID_MODE_STRING; - case(7406): - return FORCING_MODE_STRING; - case(7407): - return MODE_CMD_REJECTED_STRING; - case(7506): - return HEALTH_INFO_STRING; - case(7507): - return CHILD_CHANGED_HEALTH_STRING; - case(7508): - return CHILD_PROBLEMS_STRING; - case(7509): - return OVERWRITING_HEALTH_STRING; - case(7510): - return TRYING_RECOVERY_STRING; - case(7511): - return RECOVERY_STEP_STRING; - case(7512): - return RECOVERY_DONE_STRING; - case(7900): - return RF_AVAILABLE_STRING; - case(7901): - return RF_LOST_STRING; - case(7902): - return BIT_LOCK_STRING; - case(7903): - return BIT_LOCK_LOST_STRING; - case(7905): - return FRAME_PROCESSING_FAILED_STRING; - case(8900): - return CLOCK_SET_STRING; - case(8901): - return CLOCK_SET_FAILURE_STRING; - case(9700): - return TEST_STRING; - case(10600): - return CHANGE_OF_SETUP_PARAMETER_STRING; - case(11101): - return MEMORY_READ_RPT_CRC_FAILURE_STRING; - case(11102): - return ACK_FAILURE_STRING; - case(11103): - return EXE_FAILURE_STRING; - case(11104): - return CRC_FAILURE_EVENT_STRING; - default: - return "UNKNOWN_EVENT"; - } - return 0; +const char *translateEvents(Event event) { + switch ((event & 0xffff)) { + case (2200): + return STORE_SEND_WRITE_FAILED_STRING; + case (2201): + return STORE_WRITE_FAILED_STRING; + case (2202): + return STORE_SEND_READ_FAILED_STRING; + case (2203): + return STORE_READ_FAILED_STRING; + case (2204): + return UNEXPECTED_MSG_STRING; + case (2205): + return STORING_FAILED_STRING; + case (2206): + return TM_DUMP_FAILED_STRING; + case (2207): + return STORE_INIT_FAILED_STRING; + case (2208): + return STORE_INIT_EMPTY_STRING; + case (2209): + return STORE_CONTENT_CORRUPTED_STRING; + case (2210): + return STORE_INITIALIZE_STRING; + case (2211): + return INIT_DONE_STRING; + case (2212): + return DUMP_FINISHED_STRING; + case (2213): + return DELETION_FINISHED_STRING; + case (2214): + return DELETION_FAILED_STRING; + case (2215): + return AUTO_CATALOGS_SENDING_FAILED_STRING; + case (2600): + return GET_DATA_FAILED_STRING; + case (2601): + return STORE_DATA_FAILED_STRING; + case (2800): + return DEVICE_BUILDING_COMMAND_FAILED_STRING; + case (2801): + return DEVICE_SENDING_COMMAND_FAILED_STRING; + case (2802): + return DEVICE_REQUESTING_REPLY_FAILED_STRING; + case (2803): + return DEVICE_READING_REPLY_FAILED_STRING; + case (2804): + return DEVICE_INTERPRETING_REPLY_FAILED_STRING; + case (2805): + return DEVICE_MISSED_REPLY_STRING; + case (2806): + return DEVICE_UNKNOWN_REPLY_STRING; + case (2807): + return DEVICE_UNREQUESTED_REPLY_STRING; + case (2808): + return INVALID_DEVICE_COMMAND_STRING; + case (2809): + return MONITORING_LIMIT_EXCEEDED_STRING; + case (2810): + return MONITORING_AMBIGUOUS_STRING; + case (4201): + return FUSE_CURRENT_HIGH_STRING; + case (4202): + return FUSE_WENT_OFF_STRING; + case (4204): + return POWER_ABOVE_HIGH_LIMIT_STRING; + case (4205): + return POWER_BELOW_LOW_LIMIT_STRING; + case (4300): + return SWITCH_WENT_OFF_STRING; + case (5000): + return HEATER_ON_STRING; + case (5001): + return HEATER_OFF_STRING; + case (5002): + return HEATER_TIMEOUT_STRING; + case (5003): + return HEATER_STAYED_ON_STRING; + case (5004): + return HEATER_STAYED_OFF_STRING; + case (5200): + return TEMP_SENSOR_HIGH_STRING; + case (5201): + return TEMP_SENSOR_LOW_STRING; + case (5202): + return TEMP_SENSOR_GRADIENT_STRING; + case (5901): + return COMPONENT_TEMP_LOW_STRING; + case (5902): + return COMPONENT_TEMP_HIGH_STRING; + case (5903): + return COMPONENT_TEMP_OOL_LOW_STRING; + case (5904): + return COMPONENT_TEMP_OOL_HIGH_STRING; + case (5905): + return TEMP_NOT_IN_OP_RANGE_STRING; + case (7101): + return FDIR_CHANGED_STATE_STRING; + case (7102): + return FDIR_STARTS_RECOVERY_STRING; + case (7103): + return FDIR_TURNS_OFF_DEVICE_STRING; + case (7201): + return MONITOR_CHANGED_STATE_STRING; + case (7202): + return VALUE_BELOW_LOW_LIMIT_STRING; + case (7203): + return VALUE_ABOVE_HIGH_LIMIT_STRING; + case (7204): + return VALUE_OUT_OF_RANGE_STRING; + case (7301): + return SWITCHING_TM_FAILED_STRING; + case (7400): + return CHANGING_MODE_STRING; + case (7401): + return MODE_INFO_STRING; + case (7402): + return FALLBACK_FAILED_STRING; + case (7403): + return MODE_TRANSITION_FAILED_STRING; + case (7404): + return CANT_KEEP_MODE_STRING; + case (7405): + return OBJECT_IN_INVALID_MODE_STRING; + case (7406): + return FORCING_MODE_STRING; + case (7407): + return MODE_CMD_REJECTED_STRING; + case (7506): + return HEALTH_INFO_STRING; + case (7507): + return CHILD_CHANGED_HEALTH_STRING; + case (7508): + return CHILD_PROBLEMS_STRING; + case (7509): + return OVERWRITING_HEALTH_STRING; + case (7510): + return TRYING_RECOVERY_STRING; + case (7511): + return RECOVERY_STEP_STRING; + case (7512): + return RECOVERY_DONE_STRING; + case (7900): + return RF_AVAILABLE_STRING; + case (7901): + return RF_LOST_STRING; + case (7902): + return BIT_LOCK_STRING; + case (7903): + return BIT_LOCK_LOST_STRING; + case (7905): + return FRAME_PROCESSING_FAILED_STRING; + case (8900): + return CLOCK_SET_STRING; + case (8901): + return CLOCK_SET_FAILURE_STRING; + case (9700): + return TEST_STRING; + case (10600): + return CHANGE_OF_SETUP_PARAMETER_STRING; + case (11101): + return MEMORY_READ_RPT_CRC_FAILURE_STRING; + case (11102): + return ACK_FAILURE_STRING; + case (11103): + return EXE_FAILURE_STRING; + case (11104): + return CRC_FAILURE_EVENT_STRING; + default: + return "UNKNOWN_EVENT"; + } + return 0; } diff --git a/bsp_hosted/fsfwconfig/events/translateEvents.h b/bsp_hosted/fsfwconfig/events/translateEvents.h index 9034dcf2..a42d9b5a 100644 --- a/bsp_hosted/fsfwconfig/events/translateEvents.h +++ b/bsp_hosted/fsfwconfig/events/translateEvents.h @@ -3,6 +3,6 @@ #include -const char * translateEvents(Event event); +const char* translateEvents(Event event); #endif /* FSFWCONFIG_EVENTS_TRANSLATEEVENTS_H_ */ diff --git a/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.cpp b/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.cpp index 36ef1b73..fa1c4877 100644 --- a/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.cpp +++ b/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.cpp @@ -1,11 +1,10 @@ #include "MissionMessageTypes.h" + #include void messagetypes::clearMissionMessage(CommandMessage* message) { - switch(message->getMessageType()) { - default: - break; - } + switch (message->getMessageType()) { + default: + break; + } } - - diff --git a/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.h b/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.h index 7e3c448f..1d93ba21 100644 --- a/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.h +++ b/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.h @@ -13,10 +13,10 @@ class CommandMessage; */ namespace messagetypes { enum MESSAGE_TYPE { - MISSION_MESSAGE_TYPE_START = FW_MESSAGES_COUNT, + MISSION_MESSAGE_TYPE_START = FW_MESSAGES_COUNT, }; void clearMissionMessage(CommandMessage* message); -} +} // namespace messagetypes #endif /* CONFIG_IPC_MISSIONMESSAGETYPES_H_ */ diff --git a/bsp_hosted/fsfwconfig/objects/systemObjectList.h b/bsp_hosted/fsfwconfig/objects/systemObjectList.h index 21a5f939..91bd2bed 100644 --- a/bsp_hosted/fsfwconfig/objects/systemObjectList.h +++ b/bsp_hosted/fsfwconfig/objects/systemObjectList.h @@ -1,31 +1,32 @@ #ifndef HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ #define HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ -#include #include +#include + // The objects will be instantiated in the ID order namespace objects { - enum sourceObjects: uint32_t { +enum sourceObjects : uint32_t { - PUS_SERVICE_3 = 0x51000300, - PUS_SERVICE_5 = 0x51000400, - PUS_SERVICE_6 = 0x51000500, - PUS_SERVICE_8 = 0x51000800, - PUS_SERVICE_23 = 0x51002300, - PUS_SERVICE_201 = 0x51020100, + PUS_SERVICE_3 = 0x51000300, + PUS_SERVICE_5 = 0x51000400, + PUS_SERVICE_6 = 0x51000500, + PUS_SERVICE_8 = 0x51000800, + PUS_SERVICE_23 = 0x51002300, + PUS_SERVICE_201 = 0x51020100, - TM_FUNNEL = 0x52000002, + TM_FUNNEL = 0x52000002, - /* Test Task */ + /* Test Task */ - TEST_TASK = 0x42694269, - DUMMY_INTERFACE = 0xCAFECAFE, - DUMMY_HANDLER = 0x4400AFFE, + TEST_TASK = 0x42694269, + DUMMY_INTERFACE = 0xCAFECAFE, + DUMMY_HANDLER = 0x4400AFFE, - /* 0x49 ('I') for Communication Interfaces **/ - ARDUINO_COM_IF = 0x49000001 - }; + /* 0x49 ('I') for Communication Interfaces **/ + ARDUINO_COM_IF = 0x49000001 +}; } #endif /* BSP_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ */ diff --git a/bsp_hosted/fsfwconfig/objects/translateObjects.cpp b/bsp_hosted/fsfwconfig/objects/translateObjects.cpp index 9aac2b47..f29e4d65 100644 --- a/bsp_hosted/fsfwconfig/objects/translateObjects.cpp +++ b/bsp_hosted/fsfwconfig/objects/translateObjects.cpp @@ -1,4 +1,4 @@ -/** +/** * @brief Auto-generated object translation file. * @details * Contains 31 translations. @@ -38,72 +38,72 @@ const char *FSFW_OBJECTS_END_STRING = "FSFW_OBJECTS_END"; const char *DUMMY_INTERFACE_STRING = "DUMMY_INTERFACE"; const char *NO_OBJECT_STRING = "NO_OBJECT"; -const char* translateObject(object_id_t object) { - switch( (object & 0xFFFFFFFF) ) { - case 0x42694269: - return TEST_TASK_STRING; - case 0x4400AFFE: - return DUMMY_HANDLER_STRING; - case 0x49000001: - return ARDUINO_COM_IF_STRING; - case 0x51000300: - return PUS_SERVICE_3_STRING; - case 0x51000400: - return PUS_SERVICE_5_STRING; - case 0x51000500: - return PUS_SERVICE_6_STRING; - case 0x51000800: - return PUS_SERVICE_8_STRING; - case 0x51002300: - return PUS_SERVICE_23_STRING; - case 0x51020100: - return PUS_SERVICE_201_STRING; - case 0x52000002: - return TM_FUNNEL_STRING; - case 0x53000000: - return FSFW_OBJECTS_START_STRING; - case 0x53000001: - return PUS_SERVICE_1_VERIFICATION_STRING; - case 0x53000002: - return PUS_SERVICE_2_DEVICE_ACCESS_STRING; - case 0x53000003: - return PUS_SERVICE_3_HOUSEKEEPING_STRING; - case 0x53000005: - return PUS_SERVICE_5_EVENT_REPORTING_STRING; - case 0x53000008: - return PUS_SERVICE_8_FUNCTION_MGMT_STRING; - case 0x53000009: - return PUS_SERVICE_9_TIME_MGMT_STRING; - case 0x53000017: - return PUS_SERVICE_17_TEST_STRING; - case 0x53000020: - return PUS_SERVICE_20_PARAMETERS_STRING; - case 0x53000200: - return PUS_SERVICE_200_MODE_MGMT_STRING; - case 0x53010000: - return HEALTH_TABLE_STRING; - case 0x53010100: - return MODE_STORE_STRING; - case 0x53030000: - return EVENT_MANAGER_STRING; - case 0x53040000: - return INTERNAL_ERROR_REPORTER_STRING; - case 0x534f0100: - return TC_STORE_STRING; - case 0x534f0200: - return TM_STORE_STRING; - case 0x534f0300: - return IPC_STORE_STRING; - case 0x53500010: - return TIME_STAMPER_STRING; - case 0x53ffffff: - return FSFW_OBJECTS_END_STRING; - case 0xCAFECAFE: - return DUMMY_INTERFACE_STRING; - case 0xFFFFFFFF: - return NO_OBJECT_STRING; - default: - return "UNKNOWN_OBJECT"; - } - return 0; +const char *translateObject(object_id_t object) { + switch ((object & 0xFFFFFFFF)) { + case 0x42694269: + return TEST_TASK_STRING; + case 0x4400AFFE: + return DUMMY_HANDLER_STRING; + case 0x49000001: + return ARDUINO_COM_IF_STRING; + case 0x51000300: + return PUS_SERVICE_3_STRING; + case 0x51000400: + return PUS_SERVICE_5_STRING; + case 0x51000500: + return PUS_SERVICE_6_STRING; + case 0x51000800: + return PUS_SERVICE_8_STRING; + case 0x51002300: + return PUS_SERVICE_23_STRING; + case 0x51020100: + return PUS_SERVICE_201_STRING; + case 0x52000002: + return TM_FUNNEL_STRING; + case 0x53000000: + return FSFW_OBJECTS_START_STRING; + case 0x53000001: + return PUS_SERVICE_1_VERIFICATION_STRING; + case 0x53000002: + return PUS_SERVICE_2_DEVICE_ACCESS_STRING; + case 0x53000003: + return PUS_SERVICE_3_HOUSEKEEPING_STRING; + case 0x53000005: + return PUS_SERVICE_5_EVENT_REPORTING_STRING; + case 0x53000008: + return PUS_SERVICE_8_FUNCTION_MGMT_STRING; + case 0x53000009: + return PUS_SERVICE_9_TIME_MGMT_STRING; + case 0x53000017: + return PUS_SERVICE_17_TEST_STRING; + case 0x53000020: + return PUS_SERVICE_20_PARAMETERS_STRING; + case 0x53000200: + return PUS_SERVICE_200_MODE_MGMT_STRING; + case 0x53010000: + return HEALTH_TABLE_STRING; + case 0x53010100: + return MODE_STORE_STRING; + case 0x53030000: + return EVENT_MANAGER_STRING; + case 0x53040000: + return INTERNAL_ERROR_REPORTER_STRING; + case 0x534f0100: + return TC_STORE_STRING; + case 0x534f0200: + return TM_STORE_STRING; + case 0x534f0300: + return IPC_STORE_STRING; + case 0x53500010: + return TIME_STAMPER_STRING; + case 0x53ffffff: + return FSFW_OBJECTS_END_STRING; + case 0xCAFECAFE: + return DUMMY_INTERFACE_STRING; + case 0xFFFFFFFF: + return NO_OBJECT_STRING; + default: + return "UNKNOWN_OBJECT"; + } + return 0; } diff --git a/bsp_hosted/fsfwconfig/returnvalues/classIds.h b/bsp_hosted/fsfwconfig/returnvalues/classIds.h index cc159fec..b50e8ac0 100644 --- a/bsp_hosted/fsfwconfig/returnvalues/classIds.h +++ b/bsp_hosted/fsfwconfig/returnvalues/classIds.h @@ -1,9 +1,10 @@ #ifndef CONFIG_RETURNVALUES_CLASSIDS_H_ #define CONFIG_RETURNVALUES_CLASSIDS_H_ -#include "commonClassIds.h" #include +#include "commonClassIds.h" + /** * Source IDs starts at 73 for now * Framework IDs for ReturnValues run from 0 to 56 @@ -11,9 +12,8 @@ */ namespace CLASS_ID { enum { - CLASS_ID_START = COMMON_CLASS_ID_END, + CLASS_ID_START = COMMON_CLASS_ID_END, }; } - #endif /* CONFIG_RETURNVALUES_CLASSIDS_H_ */ diff --git a/bsp_hosted/fsfwconfig/tmtc/apid.h b/bsp_hosted/fsfwconfig/tmtc/apid.h index ee2fc7c4..9d5c9ed5 100644 --- a/bsp_hosted/fsfwconfig/tmtc/apid.h +++ b/bsp_hosted/fsfwconfig/tmtc/apid.h @@ -12,8 +12,7 @@ * APID is a 11 bit number */ namespace apid { - static const uint16_t EIVE_OBSW = 0x65; +static const uint16_t EIVE_OBSW = 0x65; } - #endif /* FSFWCONFIG_TMTC_APID_H_ */ diff --git a/bsp_hosted/fsfwconfig/tmtc/pusIds.h b/bsp_hosted/fsfwconfig/tmtc/pusIds.h index a2dd7575..37503786 100644 --- a/bsp_hosted/fsfwconfig/tmtc/pusIds.h +++ b/bsp_hosted/fsfwconfig/tmtc/pusIds.h @@ -2,21 +2,21 @@ #define CONFIG_TMTC_PUSIDS_HPP_ namespace pus { -enum Ids{ - PUS_SERVICE_1 = 1, - PUS_SERVICE_2 = 2, - PUS_SERVICE_3 = 3, - PUS_SERVICE_3_PSB = 3, - PUS_SERVICE_5 = 5, - PUS_SERVICE_6 = 6, - PUS_SERVICE_8 = 8, - PUS_SERVICE_9 = 9, - PUS_SERVICE_17 = 17, - PUS_SERVICE_19 = 19, - PUS_SERVICE_20 = 20, - PUS_SERVICE_23 = 23, - PUS_SERVICE_200 = 200, - PUS_SERVICE_201 = 201, +enum Ids { + PUS_SERVICE_1 = 1, + PUS_SERVICE_2 = 2, + PUS_SERVICE_3 = 3, + PUS_SERVICE_3_PSB = 3, + PUS_SERVICE_5 = 5, + PUS_SERVICE_6 = 6, + PUS_SERVICE_8 = 8, + PUS_SERVICE_9 = 9, + PUS_SERVICE_17 = 17, + PUS_SERVICE_19 = 19, + PUS_SERVICE_20 = 20, + PUS_SERVICE_23 = 23, + PUS_SERVICE_200 = 200, + PUS_SERVICE_201 = 201, }; }; diff --git a/bsp_hosted/main.cpp b/bsp_hosted/main.cpp index 153cc447..b7ebc422 100644 --- a/bsp_hosted/main.cpp +++ b/bsp_hosted/main.cpp @@ -1,10 +1,9 @@ +#include + #include "InitMission.h" #include "OBSWVersion.h" - #include "fsfw/FSFWVersion.h" #include "fsfw/tasks/TaskFactory.h" - -#include #ifdef WIN32 static const char* COMPILE_PRINTOUT = "Windows"; #elif LINUX @@ -17,21 +16,18 @@ static const char* COMPILE_PRINTOUT = "unknown OS"; * Linux and Windows. * @return */ -int main(void) -{ - std::cout << "-- EIVE OBSW --" << std::endl; - std::cout << "-- Compiled for " << COMPILE_PRINTOUT << " --" << std::endl; - std::cout << "-- OBSW " << SW_NAME << " v" << SW_VERSION << "." << SW_SUBVERSION << - "." << SW_REVISION << ", FSFW v" << FSFW_VERSION << "." << FSFW_SUBVERSION << "." << - FSFW_REVISION << "--" << std::endl; - std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; +int main(void) { + std::cout << "-- EIVE OBSW --" << std::endl; + std::cout << "-- Compiled for " << COMPILE_PRINTOUT << " --" << std::endl; + std::cout << "-- OBSW " << SW_NAME << " v" << SW_VERSION << "." << SW_SUBVERSION << "." + << SW_REVISION << ", FSFW v" << FSFW_VERSION << "." << FSFW_SUBVERSION << "." + << FSFW_REVISION << "--" << std::endl; + std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; - initmission::initMission(); + initmission::initMission(); - for(;;) { - // suspend main thread by sleeping it. - TaskFactory::delayTask(5000); - } + for (;;) { + // suspend main thread by sleeping it. + TaskFactory::delayTask(5000); + } } - - diff --git a/bsp_linux_board/InitMission.cpp b/bsp_linux_board/InitMission.cpp index d265fded..86d5fb4b 100644 --- a/bsp_linux_board/InitMission.cpp +++ b/bsp_linux_board/InitMission.cpp @@ -1,247 +1,244 @@ #include "InitMission.h" -#include "ObjectFactory.h" -#include "objects/systemObjectList.h" -#include "OBSWConfig.h" -#include "pollingsequence/pollingSequenceFactory.h" - -#include +#include #include #include #include -#include #include #include #include +#include #include +#include "OBSWConfig.h" +#include "ObjectFactory.h" +#include "objects/systemObjectList.h" +#include "pollingsequence/pollingSequenceFactory.h" + ServiceInterfaceStream sif::debug("DEBUG"); ServiceInterfaceStream sif::info("INFO"); ServiceInterfaceStream sif::warning("WARNING"); ServiceInterfaceStream sif::error("ERROR"); -ObjectManagerIF *objectManager = nullptr; +ObjectManagerIF* objectManager = nullptr; void initmission::initMission() { - sif::info << "Building global objects.." << std::endl; - /* Instantiate global object manager and also create all objects */ - ObjectManager::instance()->setObjectFactoryFunction(ObjectFactory::produce, nullptr); - sif::info << "Initializing all objects.." << std::endl; - ObjectManager::instance()->initialize(); + sif::info << "Building global objects.." << std::endl; + /* Instantiate global object manager and also create all objects */ + ObjectManager::instance()->setObjectFactoryFunction(ObjectFactory::produce, nullptr); + sif::info << "Initializing all objects.." << std::endl; + ObjectManager::instance()->initialize(); - /* This function creates and starts all tasks */ - initTasks(); + /* This function creates and starts all tasks */ + initTasks(); } void initmission::initTasks() { - TaskFactory* factory = TaskFactory::instance(); - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - if(factory == nullptr) { - /* Should never happen ! */ - return; - } + TaskFactory* factory = TaskFactory::instance(); + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + if (factory == nullptr) { + /* Should never happen ! */ + return; + } #if OBSW_PRINT_MISSED_DEADLINES == 1 - void (*missedDeadlineFunc) (void) = TaskFactory::printMissedDeadline; + void (*missedDeadlineFunc)(void) = TaskFactory::printMissedDeadline; #else - void (*missedDeadlineFunc) (void) = nullptr; + void (*missedDeadlineFunc)(void) = nullptr; #endif + /* TMTC Distribution */ + PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask( + "DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + result = tmTcDistributor->addComponent(objects::CCSDS_PACKET_DISTRIBUTOR); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } + result = tmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } + result = tmTcDistributor->addComponent(objects::TM_FUNNEL); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } - /* TMTC Distribution */ - PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask( - "DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - result = tmTcDistributor->addComponent(objects::CCSDS_PACKET_DISTRIBUTOR); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } - result = tmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } - result = tmTcDistributor->addComponent(objects::TM_FUNNEL); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Object add component failed" << std::endl; - } + /* UDP bridge */ + PeriodicTaskIF* udpBridgeTask = factory->createPeriodicTask( + "UDP_UNIX_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + result = udpBridgeTask->addComponent(objects::TMTC_BRIDGE); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Add component UDP Unix Bridge failed" << std::endl; + } + PeriodicTaskIF* udpPollingTask = factory->createPeriodicTask( + "UDP_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = udpPollingTask->addComponent(objects::TMTC_POLLING_TASK); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Add component UDP Polling failed" << std::endl; + } - /* UDP bridge */ - PeriodicTaskIF* udpBridgeTask = factory->createPeriodicTask( - "UDP_UNIX_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - result = udpBridgeTask->addComponent(objects::TMTC_BRIDGE); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Add component UDP Unix Bridge failed" << std::endl; - } - PeriodicTaskIF* udpPollingTask = factory->createPeriodicTask( - "UDP_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); - result = udpPollingTask->addComponent(objects::TMTC_POLLING_TASK); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Add component UDP Polling failed" << std::endl; - } + /* PUS Services */ + std::vector pusTasks; + createPusTasks(*factory, missedDeadlineFunc, pusTasks); - /* PUS Services */ - std::vector pusTasks; - createPusTasks(*factory, missedDeadlineFunc, pusTasks); - - std::vector pstTasks; - createPstTasks(*factory, missedDeadlineFunc, pstTasks); + std::vector pstTasks; + createPstTasks(*factory, missedDeadlineFunc, pstTasks); #if OBSW_ADD_TEST_CODE == 1 - std::vector testTasks; - createTestTasks(*factory, missedDeadlineFunc, pstTasks); + std::vector testTasks; + createTestTasks(*factory, missedDeadlineFunc, pstTasks); #endif /* OBSW_ADD_TEST_CODE == 1 */ - auto taskStarter = [](std::vector& taskVector, std::string name) { - for(const auto& task: taskVector) { - if(task != nullptr) { - task->startTask(); - } - else { - sif::error << "Task in vector " << name << " is invalid!" << std::endl; - } - } - }; + auto taskStarter = [](std::vector& taskVector, std::string name) { + for (const auto& task : taskVector) { + if (task != nullptr) { + task->startTask(); + } else { + sif::error << "Task in vector " << name << " is invalid!" << std::endl; + } + } + }; - sif::info << "Starting tasks.." << std::endl; - tmTcDistributor->startTask(); - udpBridgeTask->startTask(); - udpPollingTask->startTask(); + sif::info << "Starting tasks.." << std::endl; + tmTcDistributor->startTask(); + udpBridgeTask->startTask(); + udpPollingTask->startTask(); - taskStarter(pusTasks, "PUS Tasks"); + taskStarter(pusTasks, "PUS Tasks"); #if OBSW_ADD_TEST_CODE == 1 - taskStarter(testTasks, "Test Tasks"); + taskStarter(testTasks, "Test Tasks"); #endif /* OBSW_ADD_TEST_CODE == 1 */ - taskStarter(pstTasks, "PST Tasks"); + taskStarter(pstTasks, "PST Tasks"); #if OBSW_ADD_TEST_PST == 1 - if(startTestPst) { - pstTestTask->startTask(); - } + if (startTestPst) { + pstTestTask->startTask(); + } #endif /* RPI_TEST_ACS_BOARD == 1 */ - sif::info << "Tasks started.." << std::endl; + sif::info << "Tasks started.." << std::endl; } void initmission::createPusTasks(TaskFactory& factory, - TaskDeadlineMissedFunction missedDeadlineFunc, std::vector& taskVec) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - PeriodicTaskIF* pusVerification = factory.createPeriodicTask( - "PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } - taskVec.push_back(pusVerification); + TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + PeriodicTaskIF* pusVerification = factory.createPeriodicTask( + "PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } + taskVec.push_back(pusVerification); - PeriodicTaskIF* pusEvents = factory.createPeriodicTask( - "PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusEvents->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_EVENTS", objects::PUS_SERVICE_5_EVENT_REPORTING); - } - result = pusEvents->addComponent(objects::EVENT_MANAGER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_MGMT", objects::EVENT_MANAGER); - } - taskVec.push_back(pusEvents); + PeriodicTaskIF* pusEvents = factory.createPeriodicTask( + "PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusEvents->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_EVENTS", objects::PUS_SERVICE_5_EVENT_REPORTING); + } + result = pusEvents->addComponent(objects::EVENT_MANAGER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_MGMT", objects::EVENT_MANAGER); + } + taskVec.push_back(pusEvents); - PeriodicTaskIF* pusHighPrio = factory.createPeriodicTask( - "PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS2", objects::PUS_SERVICE_2_DEVICE_ACCESS); - } - result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS9", objects::PUS_SERVICE_9_TIME_MGMT); - } - taskVec.push_back(pusHighPrio); + PeriodicTaskIF* pusHighPrio = factory.createPeriodicTask( + "PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS2", objects::PUS_SERVICE_2_DEVICE_ACCESS); + } + result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS9", objects::PUS_SERVICE_9_TIME_MGMT); + } + taskVec.push_back(pusHighPrio); - PeriodicTaskIF* pusMedPrio = factory.createPeriodicTask( - "PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); - result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS8", objects::PUS_SERVICE_8_FUNCTION_MGMT); - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS200", objects::PUS_SERVICE_200_MODE_MGMT); - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS20", objects::PUS_SERVICE_20_PARAMETERS); - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_3_HOUSEKEEPING); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS3", objects::PUS_SERVICE_3_HOUSEKEEPING); - } - taskVec.push_back(pusMedPrio); + PeriodicTaskIF* pusMedPrio = factory.createPeriodicTask( + "PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); + result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS8", objects::PUS_SERVICE_8_FUNCTION_MGMT); + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS200", objects::PUS_SERVICE_200_MODE_MGMT); + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS20", objects::PUS_SERVICE_20_PARAMETERS); + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_3_HOUSEKEEPING); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS3", objects::PUS_SERVICE_3_HOUSEKEEPING); + } + taskVec.push_back(pusMedPrio); - PeriodicTaskIF* pusLowPrio = factory.createPeriodicTask( - "PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc); - result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS17", objects::PUS_SERVICE_17_TEST); - } - result = pusLowPrio->addComponent(objects::INTERNAL_ERROR_REPORTER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("INT_ERR_RPRT", - objects::INTERNAL_ERROR_REPORTER); - } - taskVec.push_back(pusLowPrio); + PeriodicTaskIF* pusLowPrio = factory.createPeriodicTask( + "PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc); + result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS17", objects::PUS_SERVICE_17_TEST); + } + result = pusLowPrio->addComponent(objects::INTERNAL_ERROR_REPORTER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("INT_ERR_RPRT", objects::INTERNAL_ERROR_REPORTER); + } + taskVec.push_back(pusLowPrio); } void initmission::createPstTasks(TaskFactory& factory, - TaskDeadlineMissedFunction missedDeadlineFunc, std::vector &taskVec) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; #if OBSW_ADD_SPI_TEST_CODE == 0 - FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask( - "SPI_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 3.0, - missedDeadlineFunc); - result = pst::pstSpi(spiPst); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; - } - taskVec.push_back(spiPst); + FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask( + "SPI_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 3.0, missedDeadlineFunc); + result = pst::pstSpi(spiPst); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; + } + taskVec.push_back(spiPst); #endif } void initmission::createTestTasks(TaskFactory& factory, - TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector &taskVec) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - PeriodicTaskIF* testTask = factory.createPeriodicTask( - "TEST_TASK", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); - result = testTask->addComponent(objects::TEST_TASK); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK); - } + TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + PeriodicTaskIF* testTask = factory.createPeriodicTask( + "TEST_TASK", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = testTask->addComponent(objects::TEST_TASK); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK); + } #if RPI_ADD_SPI_TEST == 1 - result = testTask->addComponent(objects::SPI_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("SPI_TEST", objects::SPI_TEST); - } + result = testTask->addComponent(objects::SPI_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("SPI_TEST", objects::SPI_TEST); + } #endif /* RPI_ADD_SPI_TEST == 1 */ #if RPI_ADD_GPIO_TEST == 1 - result = testTask->addComponent(objects::LIBGPIOD_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("GPIOD_TEST", objects::LIBGPIOD_TEST); - } + result = testTask->addComponent(objects::LIBGPIOD_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("GPIOD_TEST", objects::LIBGPIOD_TEST); + } #endif /* RPI_ADD_GPIO_TEST == 1 */ #if RPI_ADD_UART_TEST == 1 - result = testTask->addComponent(objects::UART_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("UART_TEST", objects::UART_TEST); - } + result = testTask->addComponent(objects::UART_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("UART_TEST", objects::UART_TEST); + } #endif /* RPI_ADD_GPIO_TEST == 1 */ - bool startTestPst = true; - static_cast(startTestPst); + bool startTestPst = true; + static_cast(startTestPst); #if OBSW_ADD_TEST_PST == 1 - FixedTimeslotTaskIF* pstTestTask = factory->createFixedTimeslotTask("TEST_PST", 50, - PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 2.0, missedDeadlineFunc); - result = pst::pstTest(pstTestTask); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::info << "initmission::initTasks: ACS PST empty or invalid" << std::endl; - startTestPst = false; - } + FixedTimeslotTaskIF* pstTestTask = factory->createFixedTimeslotTask( + "TEST_PST", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 2.0, missedDeadlineFunc); + result = pst::pstTest(pstTestTask); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::info << "initmission::initTasks: ACS PST empty or invalid" << std::endl; + startTestPst = false; + } #endif /* RPI_TEST_ACS_BOARD == 1 */ - } diff --git a/bsp_linux_board/InitMission.h b/bsp_linux_board/InitMission.h index f5da5855..f14135dd 100644 --- a/bsp_linux_board/InitMission.h +++ b/bsp_linux_board/InitMission.h @@ -1,9 +1,10 @@ #ifndef BSP_LINUX_INITMISSION_H_ #define BSP_LINUX_INITMISSION_H_ -#include "fsfw/tasks/Typedef.h" #include +#include "fsfw/tasks/Typedef.h" + class PeriodicTaskIF; class TaskFactory; @@ -11,14 +12,12 @@ namespace initmission { void initMission(); void initTasks(); -void createPstTasks(TaskFactory& factory, - TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector &taskVec); -void createTestTasks(TaskFactory& factory, - TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector &taskVec); +void createPstTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec); +void createTestTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec); void createPusTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector& taskVec); -}; + std::vector& taskVec); +}; // namespace initmission #endif /* BSP_LINUX_INITMISSION_H_ */ diff --git a/bsp_linux_board/ObjectFactory.cpp b/bsp_linux_board/ObjectFactory.cpp index bb86ecce..71966164 100644 --- a/bsp_linux_board/ObjectFactory.cpp +++ b/bsp_linux_board/ObjectFactory.cpp @@ -1,236 +1,241 @@ -#include #include "ObjectFactory.h" -#include "objects/systemObjectList.h" +#include +#include + +#include "OBSWConfig.h" #include "devices/addresses.h" #include "devices/gpioIds.h" -#include "OBSWConfig.h" -#include "tmtc/apid.h" -#include "tmtc/pusIds.h" +#include "fsfw/datapoollocal/LocalDataPoolManager.h" +#include "fsfw/tasks/TaskFactory.h" +#include "fsfw/tmtcpacket/pus/tm.h" +#include "fsfw/tmtcservices/CommandingServiceBase.h" +#include "fsfw/tmtcservices/PusServiceBase.h" #include "linux/boardtest/LibgpiodTest.h" #include "linux/boardtest/SpiTestClass.h" #include "linux/boardtest/UartTestClass.h" - #include "mission/core/GenericFactory.h" -#include "mission/utility/TmFunnel.h" -#include #include "mission/devices/GyroADIS1650XHandler.h" - -#include "fsfw/datapoollocal/LocalDataPoolManager.h" -#include "fsfw/tmtcservices/CommandingServiceBase.h" -#include "fsfw/tmtcservices/PusServiceBase.h" -#include "fsfw/tmtcpacket/pus/tm.h" -#include "fsfw/tasks/TaskFactory.h" +#include "mission/utility/TmFunnel.h" +#include "objects/systemObjectList.h" +#include "tmtc/apid.h" +#include "tmtc/pusIds.h" /* UDP server includes */ #if OBSW_USE_TMTC_TCP_BRIDGE == 1 #include #include #else -#include "fsfw/osal/common/UdpTmTcBridge.h" #include "fsfw/osal/common/UdpTcPollingTask.h" +#include "fsfw/osal/common/UdpTmTcBridge.h" #endif -#include "fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h" -#include "fsfw_hal/devicehandlers/MgmRM3100Handler.h" -#include "fsfw_hal/devicehandlers/GyroL3GD20Handler.h" -#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" -#include "fsfw_hal/linux/rpi/GpioRPi.h" -#include "fsfw_hal/common/gpio/GpioCookie.h" -#include "fsfw_hal/linux/spi/SpiCookie.h" -#include "fsfw_hal/linux/spi/SpiComIF.h" #include #include +#include "fsfw_hal/common/gpio/GpioCookie.h" +#include "fsfw_hal/devicehandlers/GyroL3GD20Handler.h" +#include "fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h" +#include "fsfw_hal/devicehandlers/MgmRM3100Handler.h" +#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" +#include "fsfw_hal/linux/rpi/GpioRPi.h" +#include "fsfw_hal/linux/spi/SpiComIF.h" +#include "fsfw_hal/linux/spi/SpiCookie.h" + void Factory::setStaticFrameworkObjectIds() { - PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; - PusServiceBase::packetDestination = objects::TM_FUNNEL; + PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; + PusServiceBase::packetDestination = objects::TM_FUNNEL; - CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; - CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; + CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; + CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; - TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; - // No storage object for now. - TmFunnel::storageDestination = objects::NO_OBJECT; + TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; + // No storage object for now. + TmFunnel::storageDestination = objects::NO_OBJECT; - VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; - TmPacketBase::timeStamperId = objects::TIME_STAMPER; + VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; + TmPacketBase::timeStamperId = objects::TIME_STAMPER; } - - -void ObjectFactory::produce(void* args){ - Factory::setStaticFrameworkObjectIds(); - ObjectFactory::produceGenericObjects(); +void ObjectFactory::produce(void* args) { + Factory::setStaticFrameworkObjectIds(); + ObjectFactory::produceGenericObjects(); #if OBSW_USE_TMTC_TCP_BRIDGE == 1 - auto tmtcBridge = new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - tmtcBridge->setMaxNumberOfPacketsStored(50); - new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); + auto tmtcBridge = new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + tmtcBridge->setMaxNumberOfPacketsStored(50); + new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); #else - auto tmtcBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - tmtcBridge->setMaxNumberOfPacketsStored(50); - new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); + auto tmtcBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + tmtcBridge->setMaxNumberOfPacketsStored(50); + new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); #endif - GpioIF* gpioIF = new LinuxLibgpioIF(objects::GPIO_IF); - GpioCookie* gpioCookie = nullptr; - static_cast(gpioCookie); + GpioIF* gpioIF = new LinuxLibgpioIF(objects::GPIO_IF); + GpioCookie* gpioCookie = nullptr; + static_cast(gpioCookie); - new SpiComIF(objects::SPI_COM_IF, gpioIF); + new SpiComIF(objects::SPI_COM_IF, gpioIF); - std::string spiDev; - SpiCookie* spiCookie = nullptr; - static_cast(spiCookie); + std::string spiDev; + SpiCookie* spiCookie = nullptr; + static_cast(spiCookie); #if OBSW_ADD_ACS_BOARD == 1 - if(gpioCookie == nullptr) { - gpioCookie = new GpioCookie(); - } - // TODO: Missing pin for Gyro 2 - gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_0_LIS3_CS, gpio::MGM_0_BCM_PIN, - "MGM_0_LIS3", gpio::Direction::OUT, 1); - gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_1_RM3100_CS, gpio::MGM_1_BCM_PIN, - "MGM_1_RM3100", gpio::Direction::OUT, 1); - gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_2_LIS3_CS, gpio::MGM_2_BCM_PIN, - "MGM_2_LIS3", gpio::Direction::OUT, 1); - gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_3_RM3100_CS, gpio::MGM_3_BCM_PIN, - "MGM_3_RM3100", gpio::Direction::OUT, 1); - gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_0_ADIS_CS, gpio::GYRO_0_BCM_PIN, - "GYRO_0_ADIS", gpio::Direction::OUT, 1); - gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_1_L3G_CS, gpio::GYRO_1_BCM_PIN, - "GYRO_1_L3G", gpio::Direction::OUT, 1); - gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_2_ADIS_CS, gpio::GYRO_2_BCM_PIN, - "GYRO_2_ADIS", gpio::Direction::OUT, 1); - gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_3_L3G_CS, gpio::GYRO_3_BCM_PIN, - "GYRO_3_L3G", gpio::Direction::OUT, 1); - gpioIF->addGpios(gpioCookie); + if (gpioCookie == nullptr) { + gpioCookie = new GpioCookie(); + } + // TODO: Missing pin for Gyro 2 + gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_0_LIS3_CS, gpio::MGM_0_BCM_PIN, "MGM_0_LIS3", + gpio::Direction::OUT, 1); + gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_1_RM3100_CS, gpio::MGM_1_BCM_PIN, + "MGM_1_RM3100", gpio::Direction::OUT, 1); + gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_2_LIS3_CS, gpio::MGM_2_BCM_PIN, "MGM_2_LIS3", + gpio::Direction::OUT, 1); + gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_3_RM3100_CS, gpio::MGM_3_BCM_PIN, + "MGM_3_RM3100", gpio::Direction::OUT, 1); + gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_0_ADIS_CS, gpio::GYRO_0_BCM_PIN, + "GYRO_0_ADIS", gpio::Direction::OUT, 1); + gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_1_L3G_CS, gpio::GYRO_1_BCM_PIN, "GYRO_1_L3G", + gpio::Direction::OUT, 1); + gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_2_ADIS_CS, gpio::GYRO_2_BCM_PIN, + "GYRO_2_ADIS", gpio::Direction::OUT, 1); + gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_3_L3G_CS, gpio::GYRO_3_BCM_PIN, "GYRO_3_L3G", + gpio::Direction::OUT, 1); + gpioIF->addGpios(gpioCookie); - spiDev = "/dev/spidev0.1"; - spiCookie = new SpiCookie(addresses::MGM_0_LIS3, gpioIds::MGM_0_LIS3_CS, spiDev, - MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); - auto mgmLis3Handler = new MgmLIS3MDLHandler(objects::MGM_0_LIS3_HANDLER, - objects::SPI_COM_IF, spiCookie, 0); - mgmLis3Handler->setStartUpImmediately(); + spiDev = "/dev/spidev0.1"; + spiCookie = + new SpiCookie(addresses::MGM_0_LIS3, gpioIds::MGM_0_LIS3_CS, spiDev, + MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); + auto mgmLis3Handler = + new MgmLIS3MDLHandler(objects::MGM_0_LIS3_HANDLER, objects::SPI_COM_IF, spiCookie, 0); + mgmLis3Handler->setStartUpImmediately(); #if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1 - mgmLis3Handler->setToGoToNormalMode(true); + mgmLis3Handler->setToGoToNormalMode(true); #endif - spiCookie = new SpiCookie(addresses::MGM_1_RM3100, gpioIds::MGM_1_RM3100_CS, spiDev, - RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); - auto mgmRm3100Handler = new MgmRM3100Handler(objects::MGM_1_RM3100_HANDLER, - objects::SPI_COM_IF, spiCookie, 0); - mgmRm3100Handler->setStartUpImmediately(); + spiCookie = + new SpiCookie(addresses::MGM_1_RM3100, gpioIds::MGM_1_RM3100_CS, spiDev, + RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); + auto mgmRm3100Handler = + new MgmRM3100Handler(objects::MGM_1_RM3100_HANDLER, objects::SPI_COM_IF, spiCookie, 0); + mgmRm3100Handler->setStartUpImmediately(); #if FSFW_HAL_RM3100_MGM_DEBUG == 1 - mgmRm3100Handler->setToGoToNormalMode(true); + mgmRm3100Handler->setToGoToNormalMode(true); #endif - spiCookie = new SpiCookie(addresses::MGM_2_LIS3, gpioIds::MGM_2_LIS3_CS, spiDev, - MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); - mgmLis3Handler = new MgmLIS3MDLHandler(objects::MGM_2_LIS3_HANDLER, - objects::SPI_COM_IF, spiCookie, 0); - mgmLis3Handler->setStartUpImmediately(); + spiCookie = + new SpiCookie(addresses::MGM_2_LIS3, gpioIds::MGM_2_LIS3_CS, spiDev, + MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); + mgmLis3Handler = + new MgmLIS3MDLHandler(objects::MGM_2_LIS3_HANDLER, objects::SPI_COM_IF, spiCookie, 0); + mgmLis3Handler->setStartUpImmediately(); #if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1 - mgmLis3Handler->setToGoToNormalMode(true); + mgmLis3Handler->setToGoToNormalMode(true); #endif - spiCookie = new SpiCookie(addresses::MGM_3_RM3100, gpioIds::MGM_3_RM3100_CS, spiDev, - RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); - mgmRm3100Handler = new MgmRM3100Handler(objects::MGM_3_RM3100_HANDLER, - objects::SPI_COM_IF, spiCookie, 0); - mgmRm3100Handler->setStartUpImmediately(); + spiCookie = + new SpiCookie(addresses::MGM_3_RM3100, gpioIds::MGM_3_RM3100_CS, spiDev, + RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); + mgmRm3100Handler = + new MgmRM3100Handler(objects::MGM_3_RM3100_HANDLER, objects::SPI_COM_IF, spiCookie, 0); + mgmRm3100Handler->setStartUpImmediately(); #if FSFW_HAL_RM3100_MGM_DEBUG == 1 - mgmRm3100Handler->setToGoToNormalMode(true); + mgmRm3100Handler->setToGoToNormalMode(true); #endif - spiCookie = new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, spiDev, - ADIS16507::MAXIMUM_REPLY_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); - auto adisHandler = new GyroADIS16507Handler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, - spiCookie); - adisHandler->setStartUpImmediately(); - spiCookie = new SpiCookie(addresses::GYRO_1_L3G, gpioIds::GYRO_1_L3G_CS, spiDev, - L3GD20H::MAX_BUFFER_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); - auto gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_1_L3G_HANDLER, objects::SPI_COM_IF, - spiCookie, 0); - gyroL3gHandler->setStartUpImmediately(); -#if FSFW_HAL_L3GD20_GYRO_DEBUG== 1 - gyroL3gHandler->setToGoToNormalMode(true); + spiCookie = + new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, spiDev, + ADIS16507::MAXIMUM_REPLY_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); + auto adisHandler = + new GyroADIS16507Handler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, spiCookie); + adisHandler->setStartUpImmediately(); + spiCookie = + new SpiCookie(addresses::GYRO_1_L3G, gpioIds::GYRO_1_L3G_CS, spiDev, L3GD20H::MAX_BUFFER_SIZE, + spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); + auto gyroL3gHandler = + new GyroHandlerL3GD20H(objects::GYRO_1_L3G_HANDLER, objects::SPI_COM_IF, spiCookie, 0); + gyroL3gHandler->setStartUpImmediately(); +#if FSFW_HAL_L3GD20_GYRO_DEBUG == 1 + gyroL3gHandler->setToGoToNormalMode(true); #endif - spiCookie = new SpiCookie(addresses::GYRO_2_ADIS, gpioIds::GYRO_2_ADIS_CS, spiDev, - ADIS16507::MAXIMUM_REPLY_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); - adisHandler = new GyroADIS16507Handler(objects::GYRO_2_ADIS_HANDLER, objects::SPI_COM_IF, - spiCookie); - adisHandler->setStartUpImmediately(); + spiCookie = + new SpiCookie(addresses::GYRO_2_ADIS, gpioIds::GYRO_2_ADIS_CS, spiDev, + ADIS16507::MAXIMUM_REPLY_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); + adisHandler = + new GyroADIS16507Handler(objects::GYRO_2_ADIS_HANDLER, objects::SPI_COM_IF, spiCookie); + adisHandler->setStartUpImmediately(); - spiCookie = new SpiCookie(addresses::GYRO_3_L3G, gpioIds::GYRO_3_L3G_CS, spiDev, - L3GD20H::MAX_BUFFER_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); - gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_3_L3G_HANDLER, objects::SPI_COM_IF, - spiCookie, 0); - gyroL3gHandler->setStartUpImmediately(); -#if FSFW_HAL_L3GD20_GYRO_DEBUG== 1 - gyroL3gHandler->setToGoToNormalMode(true); + spiCookie = + new SpiCookie(addresses::GYRO_3_L3G, gpioIds::GYRO_3_L3G_CS, spiDev, L3GD20H::MAX_BUFFER_SIZE, + spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); + gyroL3gHandler = + new GyroHandlerL3GD20H(objects::GYRO_3_L3G_HANDLER, objects::SPI_COM_IF, spiCookie, 0); + gyroL3gHandler->setStartUpImmediately(); +#if FSFW_HAL_L3GD20_GYRO_DEBUG == 1 + gyroL3gHandler->setToGoToNormalMode(true); #endif #endif /* RPI_TEST_ACS_BOARD == 1 */ #if OBSW_ADD_TEST_CODE == 1 - createTestTasks(); + createTestTasks(); #endif /* OBSW_ADD_TEST_CODE == 1 */ } void ObjectFactory::createTestTasks() { - - new TestTask(objects::TEST_TASK); + new TestTask(objects::TEST_TASK); #if RPI_ADD_SPI_TEST == 1 - new SpiTestClass(objects::SPI_TEST, gpioIF); + new SpiTestClass(objects::SPI_TEST, gpioIF); #endif #if RPI_ADD_UART_TEST == 1 - new UartTestClass(objects::UART_TEST); + new UartTestClass(objects::UART_TEST); #else - new UartComIF(objects::UART_COM_IF); + new UartComIF(objects::UART_COM_IF); #endif #if RPI_LOOPBACK_TEST_GPIO == 1 - GpioCookie* gpioCookieLoopback = new GpioCookie(); - /* Loopback pins. Adapt according to setup */ - gpioId_t gpioIdSender = gpioIds::TEST_ID_0; - int bcmPinSender = 26; - gpioId_t gpioIdReader = gpioIds::TEST_ID_1; - int bcmPinReader = 16; - gpio::createRpiGpioConfig(gpioCookieLoopback, gpioIdSender, bcmPinSender, "GPIO_LB_SENDER", - gpio::Direction::OUT, 0); - gpio::createRpiGpioConfig(gpioCookieLoopback, gpioIdReader, bcmPinReader, "GPIO_LB_READER", - gpio::Direction::IN, 0); - new LibgpiodTest(objects::LIBGPIOD_TEST, objects::GPIO_IF, gpioCookieLoopback); + GpioCookie* gpioCookieLoopback = new GpioCookie(); + /* Loopback pins. Adapt according to setup */ + gpioId_t gpioIdSender = gpioIds::TEST_ID_0; + int bcmPinSender = 26; + gpioId_t gpioIdReader = gpioIds::TEST_ID_1; + int bcmPinReader = 16; + gpio::createRpiGpioConfig(gpioCookieLoopback, gpioIdSender, bcmPinSender, "GPIO_LB_SENDER", + gpio::Direction::OUT, 0); + gpio::createRpiGpioConfig(gpioCookieLoopback, gpioIdReader, bcmPinReader, "GPIO_LB_READER", + gpio::Direction::IN, 0); + new LibgpiodTest(objects::LIBGPIOD_TEST, objects::GPIO_IF, gpioCookieLoopback); #endif /* RPI_LOOPBACK_TEST_GPIO == 1 */ #if RPI_TEST_ADIS16507 == 1 - if(gpioCookie == nullptr) { - gpioCookie = new GpioCookie(); - } - gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_0_ADIS_CS, gpio::GYRO_0_BCM_PIN, - "GYRO_0_ADIS", gpio::Direction::OUT, 1); - gpioIF->addGpios(gpioCookie); + if (gpioCookie == nullptr) { + gpioCookie = new GpioCookie(); + } + gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_0_ADIS_CS, gpio::GYRO_0_BCM_PIN, + "GYRO_0_ADIS", gpio::Direction::OUT, 1); + gpioIF->addGpios(gpioCookie); - spiDev = "/dev/spidev0.1"; - spiCookie = new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, spiDev, - ADIS16507::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, spi::DEFAULT_ADIS16507_SPEED, - nullptr, nullptr); - auto adisGyroHandler = new GyroADIS16507Handler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, spiCookie); - adisGyroHandler->setStartUpImmediately(); + spiDev = "/dev/spidev0.1"; + spiCookie = new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, spiDev, + ADIS16507::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, + spi::DEFAULT_ADIS16507_SPEED, nullptr, nullptr); + auto adisGyroHandler = + new GyroADIS16507Handler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, spiCookie); + adisGyroHandler->setStartUpImmediately(); #endif /* RPI_TEST_ADIS16507 == 1 */ #if RPI_TEST_GPS_HANDLER == 1 - UartCookie* uartCookie = new UartCookie(objects::GPS0_HANDLER, "/dev/serial0", - UartModes::CANONICAL, 9600, 1024); - uartCookie->setToFlushInput(true); - uartCookie->setReadCycles(6); - GPSHyperionHandler* gpsHandler = new GPSHyperionHandler(objects::GPS0_HANDLER, - objects::UART_COM_IF, uartCookie, false); - gpsHandler->setStartUpImmediately(); + UartCookie* uartCookie = + new UartCookie(objects::GPS0_HANDLER, "/dev/serial0", UartModes::CANONICAL, 9600, 1024); + uartCookie->setToFlushInput(true); + uartCookie->setReadCycles(6); + GPSHyperionHandler* gpsHandler = + new GPSHyperionHandler(objects::GPS0_HANDLER, objects::UART_COM_IF, uartCookie, false); + gpsHandler->setStartUpImmediately(); #endif - } diff --git a/bsp_linux_board/ObjectFactory.h b/bsp_linux_board/ObjectFactory.h index 3b9aca49..909baf06 100644 --- a/bsp_linux_board/ObjectFactory.h +++ b/bsp_linux_board/ObjectFactory.h @@ -1,12 +1,11 @@ #ifndef BSP_LINUX_OBJECTFACTORY_H_ #define BSP_LINUX_OBJECTFACTORY_H_ - namespace ObjectFactory { - void setStatics(); - void produce(void* args); +void setStatics(); +void produce(void* args); - void createTestTasks(); -}; +void createTestTasks(); +}; // namespace ObjectFactory #endif /* BSP_LINUX_OBJECTFACTORY_H_ */ diff --git a/bsp_linux_board/boardconfig/etl_profile.h b/bsp_linux_board/boardconfig/etl_profile.h index c35ffb46..54aca344 100644 --- a/bsp_linux_board/boardconfig/etl_profile.h +++ b/bsp_linux_board/boardconfig/etl_profile.h @@ -32,7 +32,7 @@ SOFTWARE. #define ETL_CHECK_PUSH_POP -#define ETL_CPP11_SUPPORTED 1 -#define ETL_NO_NULLPTR_SUPPORT 0 +#define ETL_CPP11_SUPPORTED 1 +#define ETL_NO_NULLPTR_SUPPORT 0 #endif diff --git a/bsp_linux_board/boardconfig/gcov.h b/bsp_linux_board/boardconfig/gcov.h index 491d24c6..80acdd86 100644 --- a/bsp_linux_board/boardconfig/gcov.h +++ b/bsp_linux_board/boardconfig/gcov.h @@ -6,8 +6,9 @@ extern "C" void __gcov_flush(); #else void __gcov_flush() { - sif::info << "GCC GCOV: Please supply GCOV=1 in Makefile if " - "coverage information is desired.\n" << std::flush; + sif::info << "GCC GCOV: Please supply GCOV=1 in Makefile if " + "coverage information is desired.\n" + << std::flush; } #endif diff --git a/bsp_linux_board/boardconfig/print.c b/bsp_linux_board/boardconfig/print.c index c501e0b7..3aba2d73 100644 --- a/bsp_linux_board/boardconfig/print.c +++ b/bsp_linux_board/boardconfig/print.c @@ -2,13 +2,9 @@ #include void printChar(const char* character, bool errStream) { - if(errStream) { - putc(*character, stderr); - return; - } - putc(*character, stdout); + if (errStream) { + putc(*character, stderr); + return; + } + putc(*character, stdout); } - - - - diff --git a/bsp_linux_board/main.cpp b/bsp_linux_board/main.cpp index a766f2a0..4e286f5d 100644 --- a/bsp_linux_board/main.cpp +++ b/bsp_linux_board/main.cpp @@ -1,12 +1,11 @@ +#include + #include "InitMission.h" #include "OBSWConfig.h" #include "OBSWVersion.h" - #include "fsfw/FSFWVersion.h" #include "fsfw/tasks/TaskFactory.h" -#include - #ifdef RASPBERRY_PI static const char* const BOARD_NAME = "Raspberry Pi"; #elif defined(BEAGLEBONEBLACK) @@ -19,21 +18,18 @@ static const char* const BOARD_NAME = "Unknown Board"; * @brief This is the main program and entry point for the Raspberry Pi. * @return */ -int main(void) -{ - std::cout << "-- EIVE OBSW --" << std::endl; - std::cout << "-- Compiled for Linux board " << BOARD_NAME << " --" << std::endl; - std::cout << "-- OBSW " << SW_NAME << " v" << SW_VERSION << "." << SW_SUBVERSION << - "." << SW_REVISION << ", FSFW v" << FSFW_VERSION << "." << FSFW_SUBVERSION << - FSFW_REVISION << "--" << std::endl; - std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; +int main(void) { + std::cout << "-- EIVE OBSW --" << std::endl; + std::cout << "-- Compiled for Linux board " << BOARD_NAME << " --" << std::endl; + std::cout << "-- OBSW " << SW_NAME << " v" << SW_VERSION << "." << SW_SUBVERSION << "." + << SW_REVISION << ", FSFW v" << FSFW_VERSION << "." << FSFW_SUBVERSION << FSFW_REVISION + << "--" << std::endl; + std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; - initmission::initMission(); + initmission::initMission(); - for(;;) { - /* Suspend main thread by sleeping it. */ - TaskFactory::delayTask(5000); - } + for (;;) { + /* Suspend main thread by sleeping it. */ + TaskFactory::delayTask(5000); + } } - - diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index 34516fa6..e41ed093 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -19,58 +19,58 @@ static constexpr char UIO_PDEC_CONFIG_MEMORY[] = "/dev/uio2"; static constexpr char UIO_PDEC_RAM[] = "/dev/uio3"; namespace gpioNames { - static constexpr char GYRO_0_ADIS_CS[] = "gyro_0_adis_chip_select"; - static constexpr char GYRO_1_L3G_CS[] = "gyro_1_l3g_chip_select"; - static constexpr char GYRO_2_ADIS_CS[] = "gyro_2_adis_chip_select"; - static constexpr char GYRO_3_L3G_CS[] = "gyro_3_l3g_chip_select"; - static constexpr char MGM_0_CS[] = "mgm_0_lis3_chip_select"; - static constexpr char MGM_1_CS[] = "mgm_1_rm3100_chip_select"; - static constexpr char MGM_2_CS[] = "mgm_2_lis3_chip_select"; - static constexpr char MGM_3_CS[] = "mgm_3_rm3100_chip_select"; - static constexpr char RESET_GNSS_0[] = "reset_gnss_0"; - static constexpr char RESET_GNSS_1[] = "reset_gnss_1"; - static constexpr char GNSS_0_ENABLE[] = "enable_gnss_0"; - static constexpr char GNSS_1_ENABLE[] = "enable_gnss_1"; - static constexpr char GYRO_0_ENABLE[] = "enable_gyro_0"; - static constexpr char GYRO_2_ENABLE[] = "enable_gyro_2"; - static constexpr char HEATER_0[] = "heater0"; - static constexpr char HEATER_1[] = "heater1"; - static constexpr char HEATER_2[] = "heater2"; - static constexpr char HEATER_3[] = "heater3"; - static constexpr char HEATER_4[] = "heater4"; - static constexpr char HEATER_5[] = "heater5"; - static constexpr char HEATER_6[] = "heater6"; - static constexpr char HEATER_7[] = "heater7"; - static constexpr char SA_DPL_PIN_0[] = "sa_dpl_0"; - static constexpr char SA_DPL_PIN_1[] = "sa_dpl_1"; - static constexpr char SPI_MUX_BIT_1_PIN[] = "spi_mux_bit_1"; - static constexpr char SPI_MUX_BIT_2_PIN[] = "spi_mux_bit_2"; - static constexpr char SPI_MUX_BIT_3_PIN[] = "spi_mux_bit_3"; - static constexpr char SPI_MUX_BIT_4_PIN[] = "spi_mux_bit_4"; - static constexpr char SPI_MUX_BIT_5_PIN[] = "spi_mux_bit_5"; - static constexpr char SPI_MUX_BIT_6_PIN[] = "spi_mux_bit_6"; - static constexpr char EN_RW_CS[] = "en_rw_cs"; - static constexpr char EN_RW_1[] = "enable_rw_1"; - static constexpr char EN_RW_2[] = "enable_rw_2"; - static constexpr char EN_RW_3[] = "enable_rw_3"; - static constexpr char EN_RW_4[] = "enable_rw_4"; - static constexpr char GNSS_MUX_SELECT[] = "gnss_mux_select"; - static constexpr char RAD_SENSOR_CHIP_SELECT[] = "rad_sensor_chip_select"; - static constexpr char PAPB_BUSY_SIGNAL_VC0[] = "papb_busy_signal_vc0"; - static constexpr char PAPB_EMPTY_SIGNAL_VC0[] = "papb_empty_signal_vc0"; - static constexpr char PAPB_BUSY_SIGNAL_VC1[] = "papb_busy_signal_vc1"; - static constexpr char PAPB_EMPTY_SIGNAL_VC1[] = "papb_empty_signal_vc1"; - static constexpr char PAPB_BUSY_SIGNAL_VC2[] = "papb_busy_signal_vc2"; - static constexpr char PAPB_EMPTY_SIGNAL_VC2[] = "papb_empty_signal_vc2"; - static constexpr char PAPB_BUSY_SIGNAL_VC3[] = "papb_busy_signal_vc3"; - static constexpr char PAPB_EMPTY_SIGNAL_VC3[] = "papb_empty_signal_vc3"; - static constexpr char RS485_EN_TX_CLOCK[] = "tx_clock_enable_ltc2872"; - 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"; -} -} +static constexpr char GYRO_0_ADIS_CS[] = "gyro_0_adis_chip_select"; +static constexpr char GYRO_1_L3G_CS[] = "gyro_1_l3g_chip_select"; +static constexpr char GYRO_2_ADIS_CS[] = "gyro_2_adis_chip_select"; +static constexpr char GYRO_3_L3G_CS[] = "gyro_3_l3g_chip_select"; +static constexpr char MGM_0_CS[] = "mgm_0_lis3_chip_select"; +static constexpr char MGM_1_CS[] = "mgm_1_rm3100_chip_select"; +static constexpr char MGM_2_CS[] = "mgm_2_lis3_chip_select"; +static constexpr char MGM_3_CS[] = "mgm_3_rm3100_chip_select"; +static constexpr char RESET_GNSS_0[] = "reset_gnss_0"; +static constexpr char RESET_GNSS_1[] = "reset_gnss_1"; +static constexpr char GNSS_0_ENABLE[] = "enable_gnss_0"; +static constexpr char GNSS_1_ENABLE[] = "enable_gnss_1"; +static constexpr char GYRO_0_ENABLE[] = "enable_gyro_0"; +static constexpr char GYRO_2_ENABLE[] = "enable_gyro_2"; +static constexpr char HEATER_0[] = "heater0"; +static constexpr char HEATER_1[] = "heater1"; +static constexpr char HEATER_2[] = "heater2"; +static constexpr char HEATER_3[] = "heater3"; +static constexpr char HEATER_4[] = "heater4"; +static constexpr char HEATER_5[] = "heater5"; +static constexpr char HEATER_6[] = "heater6"; +static constexpr char HEATER_7[] = "heater7"; +static constexpr char SA_DPL_PIN_0[] = "sa_dpl_0"; +static constexpr char SA_DPL_PIN_1[] = "sa_dpl_1"; +static constexpr char SPI_MUX_BIT_1_PIN[] = "spi_mux_bit_1"; +static constexpr char SPI_MUX_BIT_2_PIN[] = "spi_mux_bit_2"; +static constexpr char SPI_MUX_BIT_3_PIN[] = "spi_mux_bit_3"; +static constexpr char SPI_MUX_BIT_4_PIN[] = "spi_mux_bit_4"; +static constexpr char SPI_MUX_BIT_5_PIN[] = "spi_mux_bit_5"; +static constexpr char SPI_MUX_BIT_6_PIN[] = "spi_mux_bit_6"; +static constexpr char EN_RW_CS[] = "en_rw_cs"; +static constexpr char EN_RW_1[] = "enable_rw_1"; +static constexpr char EN_RW_2[] = "enable_rw_2"; +static constexpr char EN_RW_3[] = "enable_rw_3"; +static constexpr char EN_RW_4[] = "enable_rw_4"; +static constexpr char GNSS_MUX_SELECT[] = "gnss_mux_select"; +static constexpr char RAD_SENSOR_CHIP_SELECT[] = "rad_sensor_chip_select"; +static constexpr char PAPB_BUSY_SIGNAL_VC0[] = "papb_busy_signal_vc0"; +static constexpr char PAPB_EMPTY_SIGNAL_VC0[] = "papb_empty_signal_vc0"; +static constexpr char PAPB_BUSY_SIGNAL_VC1[] = "papb_busy_signal_vc1"; +static constexpr char PAPB_EMPTY_SIGNAL_VC1[] = "papb_empty_signal_vc1"; +static constexpr char PAPB_BUSY_SIGNAL_VC2[] = "papb_busy_signal_vc2"; +static constexpr char PAPB_EMPTY_SIGNAL_VC2[] = "papb_empty_signal_vc2"; +static constexpr char PAPB_BUSY_SIGNAL_VC3[] = "papb_busy_signal_vc3"; +static constexpr char PAPB_EMPTY_SIGNAL_VC3[] = "papb_empty_signal_vc3"; +static constexpr char RS485_EN_TX_CLOCK[] = "tx_clock_enable_ltc2872"; +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 #endif /* BSP_Q7S_BOARDCONFIG_BUSCONF_H_ */ diff --git a/bsp_q7s/boardconfig/etl_profile.h b/bsp_q7s/boardconfig/etl_profile.h index c35ffb46..54aca344 100644 --- a/bsp_q7s/boardconfig/etl_profile.h +++ b/bsp_q7s/boardconfig/etl_profile.h @@ -32,7 +32,7 @@ SOFTWARE. #define ETL_CHECK_PUSH_POP -#define ETL_CPP11_SUPPORTED 1 -#define ETL_NO_NULLPTR_SUPPORT 0 +#define ETL_CPP11_SUPPORTED 1 +#define ETL_NO_NULLPTR_SUPPORT 0 #endif diff --git a/bsp_q7s/boardconfig/gcov.h b/bsp_q7s/boardconfig/gcov.h index 491d24c6..80acdd86 100644 --- a/bsp_q7s/boardconfig/gcov.h +++ b/bsp_q7s/boardconfig/gcov.h @@ -6,8 +6,9 @@ extern "C" void __gcov_flush(); #else void __gcov_flush() { - sif::info << "GCC GCOV: Please supply GCOV=1 in Makefile if " - "coverage information is desired.\n" << std::flush; + sif::info << "GCC GCOV: Please supply GCOV=1 in Makefile if " + "coverage information is desired.\n" + << std::flush; } #endif diff --git a/bsp_q7s/boardconfig/print.c b/bsp_q7s/boardconfig/print.c index c501e0b7..3aba2d73 100644 --- a/bsp_q7s/boardconfig/print.c +++ b/bsp_q7s/boardconfig/print.c @@ -2,13 +2,9 @@ #include void printChar(const char* character, bool errStream) { - if(errStream) { - putc(*character, stderr); - return; - } - putc(*character, stdout); + if (errStream) { + putc(*character, stderr); + return; + } + putc(*character, stdout); } - - - - diff --git a/bsp_q7s/boardtest/FileSystemTest.cpp b/bsp_q7s/boardtest/FileSystemTest.cpp index 92c4cf3d..e1dd564d 100644 --- a/bsp_q7s/boardtest/FileSystemTest.cpp +++ b/bsp_q7s/boardtest/FileSystemTest.cpp @@ -1,26 +1,23 @@ #include "FileSystemTest.h" + +#include +#include + #include "fsfw/timemanager/Stopwatch.h" -#include -#include - -enum SdCard { - SDC0, - SDC1 -}; +enum SdCard { SDC0, SDC1 }; FileSystemTest::FileSystemTest() { - using namespace std; - SdCard sdCard = SdCard::SDC0; - cout << "SD Card Test for SD card " << static_cast(sdCard) << std::endl; - //Stopwatch stopwatch; - std::system("q7hw sd info all > /tmp/sd_status.txt"); - //stopwatch.stop(true); - std::system("q7hw sd set 0 on > /tmp/sd_set.txt"); - //stopwatch.stop(true); - std::system("q7hw sd set 0 off > /tmp/sd_set.txt"); - //stopwatch.stop(true); + using namespace std; + SdCard sdCard = SdCard::SDC0; + cout << "SD Card Test for SD card " << static_cast(sdCard) << std::endl; + // Stopwatch stopwatch; + std::system("q7hw sd info all > /tmp/sd_status.txt"); + // stopwatch.stop(true); + std::system("q7hw sd set 0 on > /tmp/sd_set.txt"); + // stopwatch.stop(true); + std::system("q7hw sd set 0 off > /tmp/sd_set.txt"); + // stopwatch.stop(true); } -FileSystemTest::~FileSystemTest() { -} +FileSystemTest::~FileSystemTest() {} diff --git a/bsp_q7s/boardtest/FileSystemTest.h b/bsp_q7s/boardtest/FileSystemTest.h index 256a0b36..bdb7989f 100644 --- a/bsp_q7s/boardtest/FileSystemTest.h +++ b/bsp_q7s/boardtest/FileSystemTest.h @@ -2,12 +2,11 @@ #define BSP_Q7S_BOARDTEST_FILESYSTEMTEST_H_ class FileSystemTest { -public: - FileSystemTest(); - virtual~ FileSystemTest(); -private: + public: + FileSystemTest(); + virtual ~FileSystemTest(); + + private: }; - - #endif /* BSP_Q7S_BOARDTEST_FILESYSTEMTEST_H_ */ diff --git a/bsp_q7s/boardtest/Q7STestTask.cpp b/bsp_q7s/boardtest/Q7STestTask.cpp index dc87cd3b..5d9042ac 100644 --- a/bsp_q7s/boardtest/Q7STestTask.cpp +++ b/bsp_q7s/boardtest/Q7STestTask.cpp @@ -1,414 +1,397 @@ +#include "Q7STestTask.h" + #include #include #include -#include "Q7STestTask.h" - -#include "bsp_q7s/memory/SdCardManager.h" -#include "bsp_q7s/memory/scratchApi.h" - -#include "fsfw/timemanager/Stopwatch.h" -#include "fsfw/tasks/TaskFactory.h" - -#include "test/DummyParameter.h" - -#include #include #include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include -Q7STestTask::Q7STestTask(object_id_t objectId): TestTask(objectId) { - doTestSdCard = false; - doTestScratchApi = false; - doTestGps = false; +#include "bsp_q7s/memory/SdCardManager.h" +#include "bsp_q7s/memory/scratchApi.h" +#include "fsfw/tasks/TaskFactory.h" +#include "fsfw/timemanager/Stopwatch.h" +#include "test/DummyParameter.h" + +Q7STestTask::Q7STestTask(object_id_t objectId) : TestTask(objectId) { + doTestSdCard = false; + doTestScratchApi = false; + doTestGps = false; } ReturnValue_t Q7STestTask::performOneShotAction() { - if (doTestSdCard) { - testSdCard(); - } - if (doTestScratchApi) { - testScratchApi(); - } - //testJsonLibDirect(); - //testDummyParams(); - //testProtHandler(); - FsOpCodes opCode = FsOpCodes::APPEND_TO_FILE; - testFileSystemHandlerDirect(opCode); - return TestTask::performOneShotAction(); + if (doTestSdCard) { + testSdCard(); + } + if (doTestScratchApi) { + testScratchApi(); + } + // testJsonLibDirect(); + // testDummyParams(); + // testProtHandler(); + FsOpCodes opCode = FsOpCodes::APPEND_TO_FILE; + testFileSystemHandlerDirect(opCode); + return TestTask::performOneShotAction(); } ReturnValue_t Q7STestTask::performPeriodicAction() { - if(doTestGps) { - testGpsDaemon(); - } - return TestTask::performPeriodicAction(); + if (doTestGps) { + testGpsDaemon(); + } + return TestTask::performPeriodicAction(); } void Q7STestTask::testSdCard() { - using namespace std; - Stopwatch stopwatch; - int result = std::system("q7hw sd info all > /tmp/sd_status.txt"); - if(result != 0) { - sif::debug << "system call failed with " << result << endl; + using namespace std; + Stopwatch stopwatch; + int result = std::system("q7hw sd info all > /tmp/sd_status.txt"); + if (result != 0) { + sif::debug << "system call failed with " << result << endl; + } + ifstream sdStatus("/tmp/sd_status.txt"); + string line; + uint8_t idx = 0; + while (std::getline(sdStatus, line)) { + std::istringstream iss(line); + string word; + while (iss >> word) { + if (word == "on") { + sif::info << "SD card " << static_cast(idx) << " is on" << endl; + } else if (word == "off") { + sif::info << "SD card " << static_cast(idx) << " is off" << endl; + } } - ifstream sdStatus("/tmp/sd_status.txt"); - string line; - uint8_t idx = 0; - while (std::getline(sdStatus, line)) { - std::istringstream iss(line); - string word; - while(iss >> word) { - if(word == "on") { - sif::info << "SD card " << static_cast(idx) << " is on" << endl; - } - else if(word == "off") { - sif::info << "SD card " << static_cast(idx) << " is off" << endl; - } - } - idx++; - } - std::remove("/tmp/sd_status.txt"); + idx++; + } + std::remove("/tmp/sd_status.txt"); } void Q7STestTask::fileTests() { - using namespace std; - ofstream testFile("/tmp/test.txt"); - testFile << "Hallo Welt" << endl; - testFile.close(); + using namespace std; + ofstream testFile("/tmp/test.txt"); + testFile << "Hallo Welt" << endl; + testFile.close(); - system("echo \"Hallo Welt\" > /tmp/test2.txt"); - system("echo \"Hallo Welt\""); + system("echo \"Hallo Welt\" > /tmp/test2.txt"); + system("echo \"Hallo Welt\""); } void Q7STestTask::testScratchApi() { - ReturnValue_t result = scratch::writeNumber("TEST", 1); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "Q7STestTask::scratchApiTest: Writing number failed" << std::endl; - } - int number = 0; - result = scratch::readNumber("TEST", number); - sif::info << "Q7STestTask::testScratchApi: Value for key \"TEST\": " << number << std::endl; - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "Q7STestTask::scratchApiTest: Reading number failed" << std::endl; - } + ReturnValue_t result = scratch::writeNumber("TEST", 1); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "Q7STestTask::scratchApiTest: Writing number failed" << std::endl; + } + int number = 0; + result = scratch::readNumber("TEST", number); + sif::info << "Q7STestTask::testScratchApi: Value for key \"TEST\": " << number << std::endl; + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "Q7STestTask::scratchApiTest: Reading number failed" << std::endl; + } - result = scratch::writeString("TEST2", "halloWelt"); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "Q7STestTask::scratchApiTest: Writing string failed" << std::endl; - } - std::string string; - result = scratch::readString("TEST2", string); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "Q7STestTask::scratchApiTest: Reading number failed" << std::endl; - } - sif::info << "Q7STestTask::testScratchApi: Value for key \"TEST2\": " << string << std::endl; + result = scratch::writeString("TEST2", "halloWelt"); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "Q7STestTask::scratchApiTest: Writing string failed" << std::endl; + } + std::string string; + result = scratch::readString("TEST2", string); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "Q7STestTask::scratchApiTest: Reading number failed" << std::endl; + } + sif::info << "Q7STestTask::testScratchApi: Value for key \"TEST2\": " << string << std::endl; - result = scratch::clearValue("TEST"); - result = scratch::clearValue("TEST2"); + result = scratch::clearValue("TEST"); + result = scratch::clearValue("TEST2"); } void Q7STestTask::testJsonLibDirect() { - Stopwatch stopwatch; - // for convenience - using json = nlohmann::json; - json helloTest; - // add a number that is stored as double (note the implicit conversion of j to an object) - helloTest["pi"] = 3.141; - std::string mntPrefix = SdCardManager::instance()->getCurrentMountPrefix(); - std::string fileName = mntPrefix + "/pretty.json"; - std::ofstream o(fileName); - o << std::setw(4) << helloTest << std::endl; + Stopwatch stopwatch; + // for convenience + using json = nlohmann::json; + json helloTest; + // add a number that is stored as double (note the implicit conversion of j to an object) + helloTest["pi"] = 3.141; + std::string mntPrefix = SdCardManager::instance()->getCurrentMountPrefix(); + std::string fileName = mntPrefix + "/pretty.json"; + std::ofstream o(fileName); + o << std::setw(4) << helloTest << std::endl; } void Q7STestTask::testDummyParams() { - std::string mntPrefix = SdCardManager::instance()->getCurrentMountPrefix(); - DummyParameter param(mntPrefix, "dummy_json.txt"); - param.printKeys(); - param.print(); - if(not param.getJsonFileExists()) { - param.writeJsonFile(); - } - - ReturnValue_t result = param.readJsonFile(); - if(result != HasReturnvaluesIF::RETURN_OK) { - - } - - param.setValue(DummyParameter::DUMMY_KEY_PARAM_1, 3); - param.setValue(DummyParameter::DUMMY_KEY_PARAM_2, "blirb"); - + std::string mntPrefix = SdCardManager::instance()->getCurrentMountPrefix(); + DummyParameter param(mntPrefix, "dummy_json.txt"); + param.printKeys(); + param.print(); + if (not param.getJsonFileExists()) { param.writeJsonFile(); - param.print(); + } - int test = 0; - result = param.getValue(DummyParameter::DUMMY_KEY_PARAM_1, &test); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Q7STestTask::testDummyParams: Key " << DummyParameter::DUMMY_KEY_PARAM_1 - << " does not exist" << std::endl; - } - std::string test2; - result = param.getValue(DummyParameter::DUMMY_KEY_PARAM_2, &test2); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Q7STestTask::testDummyParams: Key " << DummyParameter::DUMMY_KEY_PARAM_1 - << " does not exist" << std::endl; - } - sif::info << "Test value (3 expected): " << test << std::endl; - sif::info << "Test value 2 (\"blirb\" expected): " << test2 << std::endl; + ReturnValue_t result = param.readJsonFile(); + if (result != HasReturnvaluesIF::RETURN_OK) { + } + + param.setValue(DummyParameter::DUMMY_KEY_PARAM_1, 3); + param.setValue(DummyParameter::DUMMY_KEY_PARAM_2, "blirb"); + + param.writeJsonFile(); + param.print(); + + int test = 0; + result = param.getValue(DummyParameter::DUMMY_KEY_PARAM_1, &test); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testDummyParams: Key " << DummyParameter::DUMMY_KEY_PARAM_1 + << " does not exist" << std::endl; + } + std::string test2; + result = param.getValue(DummyParameter::DUMMY_KEY_PARAM_2, &test2); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testDummyParams: Key " << DummyParameter::DUMMY_KEY_PARAM_1 + << " does not exist" << std::endl; + } + sif::info << "Test value (3 expected): " << test << std::endl; + sif::info << "Test value 2 (\"blirb\" expected): " << test2 << std::endl; } ReturnValue_t Q7STestTask::initialize() { - coreController = ObjectManager::instance()->get(objects::CORE_CONTROLLER); - if(coreController == nullptr) { - sif::warning << "Q7STestTask::initialize: Could not retrieve CORE_CONTROLLER object" << - std::endl; - } - return TestTask::initialize(); + coreController = ObjectManager::instance()->get(objects::CORE_CONTROLLER); + if (coreController == nullptr) { + sif::warning << "Q7STestTask::initialize: Could not retrieve CORE_CONTROLLER object" + << std::endl; + } + return TestTask::initialize(); } void Q7STestTask::testProtHandler() { - bool opPerformed = false; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - // If any chips are unlocked, lock them here - result = coreController->setBootCopyProtection( - CoreController::Chip::ALL_CHIP, CoreController::Copy::ALL_COPY, true, - opPerformed, true); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; - } + bool opPerformed = false; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + // If any chips are unlocked, lock them here + result = coreController->setBootCopyProtection( + CoreController::Chip::ALL_CHIP, CoreController::Copy::ALL_COPY, true, opPerformed, true); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; + } - // unlock own copy - result = coreController->setBootCopyProtection( - CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, false, - opPerformed, true); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; - } - if(not opPerformed) { - sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; - } - int retval = std::system("print-chip-prot-status.sh"); - if(retval != 0) { - utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); - } + // unlock own copy + result = coreController->setBootCopyProtection( + CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, false, opPerformed, true); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; + } + if (not opPerformed) { + sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; + } + int retval = std::system("print-chip-prot-status.sh"); + if (retval != 0) { + utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); + } - // lock own copy - result = coreController->setBootCopyProtection( - CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, true, - opPerformed, true); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; - } - if(not opPerformed) { - sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; - } - retval = std::system("print-chip-prot-status.sh"); - if(retval != 0) { - utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); - } + // lock own copy + result = coreController->setBootCopyProtection( + CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, true, opPerformed, true); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; + } + if (not opPerformed) { + sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; + } + retval = std::system("print-chip-prot-status.sh"); + if (retval != 0) { + utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); + } - // unlock specific copy - result = coreController->setBootCopyProtection( - CoreController::Chip::CHIP_1, CoreController::Copy::COPY_1, false, - opPerformed, true); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; - } - if(not opPerformed) { - sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; - } - retval = std::system("print-chip-prot-status.sh"); - if(retval != 0) { - utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); - } + // unlock specific copy + result = coreController->setBootCopyProtection( + CoreController::Chip::CHIP_1, CoreController::Copy::COPY_1, false, opPerformed, true); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; + } + if (not opPerformed) { + sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; + } + retval = std::system("print-chip-prot-status.sh"); + if (retval != 0) { + utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); + } - // lock specific copy - result = coreController->setBootCopyProtection( - CoreController::Chip::CHIP_1, CoreController::Copy::COPY_1, true, - opPerformed, true); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; - } - if(not opPerformed) { - sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; - } - retval = std::system("print-chip-prot-status.sh"); - if(retval != 0) { - utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); - } + // lock specific copy + result = coreController->setBootCopyProtection( + CoreController::Chip::CHIP_1, CoreController::Copy::COPY_1, true, opPerformed, true); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; + } + if (not opPerformed) { + sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; + } + retval = std::system("print-chip-prot-status.sh"); + if (retval != 0) { + utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); + } } void Q7STestTask::testGpsDaemon() { - gpsmm gpsmm(GPSD_SHARED_MEMORY, 0); - gps_data_t* gps; - gps = gpsmm.read(); - if(gps == nullptr) { - sif::warning << "Q7STestTask: Reading GPS data failed" << std::endl; - } - sif::info << "-- Q7STestTask: GPS shared memory read test --" << std::endl; - time_t timeRaw = gps->fix.time.tv_sec; - std::tm* time = gmtime(&timeRaw); - sif::info << "Time: " << std::put_time(time, "%c %Z") << std::endl; - sif::info << "Visible satellites: " << gps->satellites_visible << std::endl; - sif::info << "Satellites used: " << gps->satellites_used << std::endl; - sif::info << "Fix (0:Not Seen|1:No Fix|2:2D|3:3D): " << gps->fix.mode << std::endl; - sif::info << "Latitude: " << gps->fix.latitude << std::endl; - sif::info << "Longitude: " << gps->fix.longitude << std::endl; - sif::info << "Altitude(MSL): " << gps->fix.altMSL << std::endl; - sif::info << "Speed(m/s): " << gps->fix.speed << std::endl; + gpsmm gpsmm(GPSD_SHARED_MEMORY, 0); + gps_data_t* gps; + gps = gpsmm.read(); + if (gps == nullptr) { + sif::warning << "Q7STestTask: Reading GPS data failed" << std::endl; + } + sif::info << "-- Q7STestTask: GPS shared memory read test --" << std::endl; + time_t timeRaw = gps->fix.time.tv_sec; + std::tm* time = gmtime(&timeRaw); + sif::info << "Time: " << std::put_time(time, "%c %Z") << std::endl; + sif::info << "Visible satellites: " << gps->satellites_visible << std::endl; + sif::info << "Satellites used: " << gps->satellites_used << std::endl; + sif::info << "Fix (0:Not Seen|1:No Fix|2:2D|3:3D): " << gps->fix.mode << std::endl; + sif::info << "Latitude: " << gps->fix.latitude << std::endl; + sif::info << "Longitude: " << gps->fix.longitude << std::endl; + sif::info << "Altitude(MSL): " << gps->fix.altMSL << std::endl; + sif::info << "Speed(m/s): " << gps->fix.speed << std::endl; } void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) { - auto fsHandler = ObjectManager::instance()-> - get(objects::FILE_SYSTEM_HANDLER); - if(fsHandler == nullptr) { - sif::warning << "Q7STestTask::testFileSystemHandlerDirect: No FS handler running.." - << std::endl; - } - FileSystemHandler::FsCommandCfg cfg = {}; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + auto fsHandler = ObjectManager::instance()->get(objects::FILE_SYSTEM_HANDLER); + if (fsHandler == nullptr) { + sif::warning << "Q7STestTask::testFileSystemHandlerDirect: No FS handler running.." + << std::endl; + } + FileSystemHandler::FsCommandCfg cfg = {}; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - // Lambda for common code - auto createNonEmptyTmpDir = [&]() { - if(not std::filesystem::exists("/tmp/test")) { - result = fsHandler->createDirectory("/tmp", "test", false, &cfg); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - } - // Creating sample files - sif::info << "Creating sample files in directory" << std::endl; - result = fsHandler->createFile("/tmp/test", "test1.txt", nullptr, 0, &cfg); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - result = fsHandler->createFile("/tmp/test", "test2.txt", nullptr, 0, &cfg); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + // Lambda for common code + auto createNonEmptyTmpDir = [&]() { + if (not std::filesystem::exists("/tmp/test")) { + result = fsHandler->createDirectory("/tmp", "test", false, &cfg); + if (result != HasReturnvaluesIF::RETURN_OK) { return result; - }; + } + } + // Creating sample files + sif::info << "Creating sample files in directory" << std::endl; + result = fsHandler->createFile("/tmp/test", "test1.txt", nullptr, 0, &cfg); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = fsHandler->createFile("/tmp/test", "test2.txt", nullptr, 0, &cfg); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + return result; + }; - - switch(opCode) { - case(FsOpCodes::CREATE_EMPTY_FILE_IN_TMP): { - // No mount prefix, cause file is created in tmp - cfg.useMountPrefix = false; - sif::info << "Creating empty file in /tmp folder" << std::endl; - // Do not delete file, user can check existence in shell + switch (opCode) { + case (FsOpCodes::CREATE_EMPTY_FILE_IN_TMP): { + // No mount prefix, cause file is created in tmp + cfg.useMountPrefix = false; + sif::info << "Creating empty file in /tmp folder" << std::endl; + // Do not delete file, user can check existence in shell + fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg); + break; + } + case (FsOpCodes::REMOVE_TMP_FILE): { + sif::info << "Deleting /tmp/test.txt sample file" << std::endl; + // No mount prefix, cause file is created in tmp + cfg.useMountPrefix = false; + if (not std::filesystem::exists("/tmp/test.txt")) { + // Creating sample file + sif::info << "Creating sample file /tmp/test.txt to delete" << std::endl; fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg); - break; + } + result = fsHandler->removeFile("/tmp", "test.txt", &cfg); + if (result == HasReturnvaluesIF::RETURN_OK) { + sif::info << "File removed successfully" << std::endl; + } else { + sif::warning << "File removal failed!" << std::endl; + } + break; } - case(FsOpCodes::REMOVE_TMP_FILE): { - sif::info << "Deleting /tmp/test.txt sample file" << std::endl; - // No mount prefix, cause file is created in tmp - cfg.useMountPrefix = false; - if(not std::filesystem::exists("/tmp/test.txt")) { - // Creating sample file - sif::info << "Creating sample file /tmp/test.txt to delete" << std::endl; - fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg); - } - result = fsHandler->removeFile("/tmp", "test.txt", &cfg); - if(result == HasReturnvaluesIF::RETURN_OK) { - sif::info << "File removed successfully" << std::endl; - } - else { - sif::warning << "File removal failed!" << std::endl; - } - break; + case (FsOpCodes::CREATE_DIR_IN_TMP): { + // No mount prefix, cause file is created in tmp + cfg.useMountPrefix = false; + sif::info << "Creating empty file in /tmp folder" << std::endl; + // Do not delete file, user can check existence in shell + ReturnValue_t result = fsHandler->createDirectory("/tmp/", "test", false, &cfg); + if (result == HasReturnvaluesIF::RETURN_OK) { + sif::info << "Directory created successfully" << std::endl; + } else { + sif::warning << "Directory creation failed!" << std::endl; + } + break; } - case(FsOpCodes::CREATE_DIR_IN_TMP): { - // No mount prefix, cause file is created in tmp - cfg.useMountPrefix = false; - sif::info << "Creating empty file in /tmp folder" << std::endl; - // Do not delete file, user can check existence in shell - ReturnValue_t result = fsHandler->createDirectory("/tmp/", "test", false, &cfg); - if(result == HasReturnvaluesIF::RETURN_OK) { - sif::info << "Directory created successfully" << std::endl; - } - else { - sif::warning << "Directory creation failed!" << std::endl; - } - break; + case (FsOpCodes::REMOVE_EMPTY_DIR_IN_TMP): { + // No mount prefix, cause file is created in tmp + cfg.useMountPrefix = false; + if (not std::filesystem::exists("/tmp/test")) { + result = fsHandler->createDirectory("/tmp", "test", false, &cfg); + } else { + // Delete any leftover files to regular dir removal works + std::remove("/tmp/test/*"); + } + result = fsHandler->removeDirectory("/tmp/", "test", false, &cfg); + if (result == HasReturnvaluesIF::RETURN_OK) { + sif::info << "Directory removed successfully" << std::endl; + } else { + sif::warning << "Directory removal failed!" << std::endl; + } + break; } - case(FsOpCodes::REMOVE_EMPTY_DIR_IN_TMP): { - // No mount prefix, cause file is created in tmp - cfg.useMountPrefix = false; - if(not std::filesystem::exists("/tmp/test")) { - result = fsHandler->createDirectory("/tmp", "test", false, &cfg); - } - else { - // Delete any leftover files to regular dir removal works - std::remove("/tmp/test/*"); - } - result = fsHandler->removeDirectory("/tmp/", "test", false, &cfg); - if(result == HasReturnvaluesIF::RETURN_OK) { - sif::info << "Directory removed successfully" << std::endl; - } - else { - sif::warning << "Directory removal failed!" << std::endl; - } - break; + case (FsOpCodes::REMOVE_FILLED_DIR_IN_TMP): { + result = createNonEmptyTmpDir(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return; + } + result = fsHandler->removeDirectory("/tmp/", "test", true, &cfg); + if (result == HasReturnvaluesIF::RETURN_OK) { + sif::info << "Directory removed recursively successfully" << std::endl; + } else { + sif::warning << "Recursive directory removal failed!" << std::endl; + } + break; } - case(FsOpCodes::REMOVE_FILLED_DIR_IN_TMP): { - result = createNonEmptyTmpDir(); - if(result != HasReturnvaluesIF::RETURN_OK) { - return; - } - result = fsHandler->removeDirectory("/tmp/", "test", true, &cfg); - if(result == HasReturnvaluesIF::RETURN_OK) { - sif::info << "Directory removed recursively successfully" << std::endl; - } - else { - sif::warning << "Recursive directory removal failed!" << std::endl; - } - break; + case (FsOpCodes::ATTEMPT_DIR_REMOVAL_NON_EMPTY): { + result = createNonEmptyTmpDir(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return; + } + result = fsHandler->removeDirectory("/tmp/", "test", false, &cfg); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::info << "Directory removal attempt failed as expected" << std::endl; + } else { + sif::warning << "Directory removal worked when it should not have!" << std::endl; + } + break; } - case(FsOpCodes::ATTEMPT_DIR_REMOVAL_NON_EMPTY): { - result = createNonEmptyTmpDir(); - if(result != HasReturnvaluesIF::RETURN_OK) { - return; - } - result = fsHandler->removeDirectory("/tmp/", "test", false, &cfg); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::info << "Directory removal attempt failed as expected" << std::endl; - } - else { - sif::warning << "Directory removal worked when it should not have!" << std::endl; - } - break; - } - case(FsOpCodes::RENAME_FILE): { - // No mount prefix, cause file is created in tmp - cfg.useMountPrefix = false; - if(std::filesystem::exists("/tmp/test.txt")) { - fsHandler->removeDirectory("/tmp/", "test", false, &cfg); - } - sif::info << "Creating empty file /tmp/test.txt and rename to /tmp/test2.txt" << std::endl; - // Do not delete file, user can check existence in shell - fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg); - fsHandler->renameFile("/tmp/", "test.txt", "test2.txt", &cfg); - break; - } - case(FsOpCodes::APPEND_TO_FILE): { - // No mount prefix, cause file is created in tmp - cfg.useMountPrefix = false; - if(std::filesystem::exists("/tmp/test.txt")) { - fsHandler->removeDirectory("/tmp/", "test", false, &cfg); - } - if(std::filesystem::exists("/tmp/test.txt")) { - fsHandler->removeDirectory("/tmp/", "test", false, &cfg); - } - sif::info << "Creating empty file /tmp/test.txt and adding content" << std::endl; - std::string content = "Hello World\n"; - // Do not delete file, user can check existence in shell - fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg); - fsHandler->appendToFile("/tmp/", "test.txt", reinterpret_cast( - content.data()), content.size(), 0, &cfg); + case (FsOpCodes::RENAME_FILE): { + // No mount prefix, cause file is created in tmp + cfg.useMountPrefix = false; + if (std::filesystem::exists("/tmp/test.txt")) { + fsHandler->removeDirectory("/tmp/", "test", false, &cfg); + } + sif::info << "Creating empty file /tmp/test.txt and rename to /tmp/test2.txt" << std::endl; + // Do not delete file, user can check existence in shell + fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg); + fsHandler->renameFile("/tmp/", "test.txt", "test2.txt", &cfg); + break; } + case (FsOpCodes::APPEND_TO_FILE): { + // No mount prefix, cause file is created in tmp + cfg.useMountPrefix = false; + if (std::filesystem::exists("/tmp/test.txt")) { + fsHandler->removeDirectory("/tmp/", "test", false, &cfg); + } + if (std::filesystem::exists("/tmp/test.txt")) { + fsHandler->removeDirectory("/tmp/", "test", false, &cfg); + } + sif::info << "Creating empty file /tmp/test.txt and adding content" << std::endl; + std::string content = "Hello World\n"; + // Do not delete file, user can check existence in shell + fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg); + fsHandler->appendToFile("/tmp/", "test.txt", reinterpret_cast(content.data()), + content.size(), 0, &cfg); } + } } diff --git a/bsp_q7s/boardtest/Q7STestTask.h b/bsp_q7s/boardtest/Q7STestTask.h index 631c238a..b7aa791e 100644 --- a/bsp_q7s/boardtest/Q7STestTask.h +++ b/bsp_q7s/boardtest/Q7STestTask.h @@ -5,42 +5,42 @@ class CoreController; -class Q7STestTask: public TestTask { -public: - Q7STestTask(object_id_t objectId); +class Q7STestTask : public TestTask { + public: + Q7STestTask(object_id_t objectId); - ReturnValue_t initialize() override; -private: - bool doTestSdCard = false; - bool doTestScratchApi = false; - bool doTestGps = false; + ReturnValue_t initialize() override; - CoreController* coreController = nullptr; - ReturnValue_t performOneShotAction() override; - ReturnValue_t performPeriodicAction() override; + private: + bool doTestSdCard = false; + bool doTestScratchApi = false; + bool doTestGps = false; - void testGpsDaemon(); + CoreController* coreController = nullptr; + ReturnValue_t performOneShotAction() override; + ReturnValue_t performPeriodicAction() override; - void testSdCard(); - void fileTests(); + void testGpsDaemon(); - void testScratchApi(); - void testJsonLibDirect(); - void testDummyParams(); - void testProtHandler(); + void testSdCard(); + void fileTests(); - enum FsOpCodes { - CREATE_EMPTY_FILE_IN_TMP, - REMOVE_TMP_FILE, - CREATE_DIR_IN_TMP, - REMOVE_EMPTY_DIR_IN_TMP, - ATTEMPT_DIR_REMOVAL_NON_EMPTY, - REMOVE_FILLED_DIR_IN_TMP, - RENAME_FILE, - APPEND_TO_FILE, - }; - void testFileSystemHandlerDirect(FsOpCodes opCode); + void testScratchApi(); + void testJsonLibDirect(); + void testDummyParams(); + void testProtHandler(); + + enum FsOpCodes { + CREATE_EMPTY_FILE_IN_TMP, + REMOVE_TMP_FILE, + CREATE_DIR_IN_TMP, + REMOVE_EMPTY_DIR_IN_TMP, + ATTEMPT_DIR_REMOVAL_NON_EMPTY, + REMOVE_FILLED_DIR_IN_TMP, + RENAME_FILE, + APPEND_TO_FILE, + }; + void testFileSystemHandlerDirect(FsOpCodes opCode); }; - #endif /* BSP_Q7S_BOARDTEST_Q7STESTTASK_H_ */ diff --git a/bsp_q7s/callbacks/gnssCallback.cpp b/bsp_q7s/callbacks/gnssCallback.cpp index 479f4a2b..d5dbc3b0 100644 --- a/bsp_q7s/callbacks/gnssCallback.cpp +++ b/bsp_q7s/callbacks/gnssCallback.cpp @@ -1,26 +1,25 @@ #include "gnssCallback.h" -#include "devices/gpioIds.h" +#include "devices/gpioIds.h" #include "fsfw/tasks/TaskFactory.h" -ReturnValue_t gps::triggerGpioResetPin(void *args) { - ResetArgs* resetArgs = reinterpret_cast(args); - if(args == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; - } - if (resetArgs->gpioComIF == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; - } - gpioId_t gpioId; - if(resetArgs->gnss1) { - gpioId = gpioIds::GNSS_1_NRESET; +ReturnValue_t gps::triggerGpioResetPin(void* args) { + ResetArgs* resetArgs = reinterpret_cast(args); + if (args == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } + if (resetArgs->gpioComIF == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } + gpioId_t gpioId; + if (resetArgs->gnss1) { + gpioId = gpioIds::GNSS_1_NRESET; - } - else { - gpioId = gpioIds::GNSS_0_NRESET; - } - resetArgs->gpioComIF->pullLow(gpioId); - TaskFactory::delayTask(resetArgs->waitPeriodMs); - resetArgs->gpioComIF->pullHigh(gpioId); - return HasReturnvaluesIF::RETURN_OK; + } else { + gpioId = gpioIds::GNSS_0_NRESET; + } + resetArgs->gpioComIF->pullLow(gpioId); + TaskFactory::delayTask(resetArgs->waitPeriodMs); + resetArgs->gpioComIF->pullHigh(gpioId); + return HasReturnvaluesIF::RETURN_OK; } diff --git a/bsp_q7s/callbacks/gnssCallback.h b/bsp_q7s/callbacks/gnssCallback.h index 9cbb6669..3e769899 100644 --- a/bsp_q7s/callbacks/gnssCallback.h +++ b/bsp_q7s/callbacks/gnssCallback.h @@ -1,13 +1,13 @@ #ifndef BSP_Q7S_CALLBACKS_GNSSCALLBACK_H_ #define BSP_Q7S_CALLBACKS_GNSSCALLBACK_H_ -#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" struct ResetArgs { - bool gnss1 = false; - LinuxLibgpioIF* gpioComIF = nullptr; - uint32_t waitPeriodMs = 100; + bool gnss1 = false; + LinuxLibgpioIF* gpioComIF = nullptr; + uint32_t waitPeriodMs = 100; }; namespace gps { diff --git a/bsp_q7s/callbacks/rwSpiCallback.cpp b/bsp_q7s/callbacks/rwSpiCallback.cpp index 1e60e3c0..3ca3c181 100644 --- a/bsp_q7s/callbacks/rwSpiCallback.cpp +++ b/bsp_q7s/callbacks/rwSpiCallback.cpp @@ -1,238 +1,232 @@ #include "rwSpiCallback.h" -#include "devices/gpioIds.h" -#include "mission/devices/RwHandler.h" -#include "fsfw_hal/linux/spi/SpiCookie.h" -#include "fsfw_hal/linux/UnixFileGuard.h" +#include "devices/gpioIds.h" #include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw_hal/linux/UnixFileGuard.h" +#include "fsfw_hal/linux/spi/SpiCookie.h" +#include "mission/devices/RwHandler.h" namespace rwSpiCallback { -ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sendData, - size_t sendLen, void* args) { +ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sendData, + size_t sendLen, void* args) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + RwHandler* handler = reinterpret_cast(args); + if (handler == nullptr) { + sif::error << "rwSpiCallback::spiCallback: Pointer to handler is invalid" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } - RwHandler* handler = reinterpret_cast(args); - if(handler == nullptr) { - sif::error << "rwSpiCallback::spiCallback: Pointer to handler is invalid" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; + uint8_t writeBuffer[2]; + uint8_t writeSize = 0; + + gpioId_t gpioId = cookie->getChipSelectPin(); + GpioIF* gpioIF = comIf->getGpioInterface(); + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; + uint32_t timeoutMs = 0; + MutexIF* mutex = comIf->getMutex(&timeoutType, &timeoutMs); + if (mutex == nullptr or gpioIF == nullptr) { + sif::debug << "rwSpiCallback::spiCallback: Mutex or GPIO interface invalid" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + + int fileDescriptor = 0; + std::string device = cookie->getSpiDevice(); + UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "rwSpiCallback::spiCallback"); + if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "rwSpiCallback::spiCallback: Failed to open device file" << std::endl; + return SpiComIF::OPENING_FILE_FAILED; + } + spi::SpiModes spiMode = spi::SpiModes::MODE_0; + uint32_t spiSpeed = 0; + cookie->getSpiParameters(spiMode, spiSpeed, nullptr); + comIf->setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); + + result = mutex->lockMutex(timeoutType, timeoutMs); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "rwSpiCallback::spiCallback: Failed to lock mutex" << std::endl; + return result; + } + + /** Sending frame start sign */ + writeBuffer[0] = 0x7E; + writeSize = 1; + + // Pull SPI CS low. For now, no support for active high given + if (gpioId != gpio::NO_GPIO) { + if (gpioIF->pullLow(gpioId) != HasReturnvaluesIF::RETURN_OK) { + sif::error << "rwSpiCallback::spiCallback: Failed to pull chip select low" << std::endl; } + } - uint8_t writeBuffer[2]; - uint8_t writeSize = 0; + if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { + sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; + closeSpi(gpioId, gpioIF, mutex); + return RwHandler::SPI_WRITE_FAILURE; + } - gpioId_t gpioId = cookie->getChipSelectPin(); - GpioIF* gpioIF = comIf->getGpioInterface(); - MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; - uint32_t timeoutMs = 0; - MutexIF* mutex = comIf->getMutex(&timeoutType, &timeoutMs); - if(mutex == nullptr or gpioIF == nullptr) { - sif::debug << "rwSpiCallback::spiCallback: Mutex or GPIO interface invalid" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - - int fileDescriptor = 0; - std::string device = cookie->getSpiDevice(); - UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "rwSpiCallback::spiCallback"); - if(fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "rwSpiCallback::spiCallback: Failed to open device file" << std::endl; - return SpiComIF::OPENING_FILE_FAILED; + /** Encoding and sending command */ + size_t idx = 0; + while (idx < sendLen) { + switch (*(sendData + idx)) { + case 0x7E: + writeBuffer[0] = 0x7D; + writeBuffer[1] = 0x5E; + writeSize = 2; + break; + case 0x7D: + writeBuffer[0] = 0x7D; + writeBuffer[1] = 0x5D; + writeSize = 2; + break; + default: + writeBuffer[0] = *(sendData + idx); + writeSize = 1; + break; } - spi::SpiModes spiMode = spi::SpiModes::MODE_0; - uint32_t spiSpeed = 0; - cookie->getSpiParameters(spiMode, spiSpeed, nullptr); - comIf->setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); - - result = mutex->lockMutex(timeoutType, timeoutMs); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "rwSpiCallback::spiCallback: Failed to lock mutex" << std::endl; - return result; - } - - /** Sending frame start sign */ - writeBuffer[0] = 0x7E; - writeSize = 1; - - // Pull SPI CS low. For now, no support for active high given - if(gpioId != gpio::NO_GPIO) { - if(gpioIF->pullLow(gpioId) != HasReturnvaluesIF::RETURN_OK) { - sif::error << "rwSpiCallback::spiCallback: Failed to pull chip select low" << std::endl; - } - } - if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { - sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; + sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; + closeSpi(gpioId, gpioIF, mutex); + return RwHandler::SPI_WRITE_FAILURE; + } + idx++; + } + + /** Sending frame end sign */ + writeBuffer[0] = 0x7E; + writeSize = 1; + + if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { + sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; + closeSpi(gpioId, gpioIF, mutex); + return RwHandler::SPI_WRITE_FAILURE; + } + + uint8_t* rxBuf = nullptr; + result = comIf->getReadBuffer(cookie->getSpiAddress(), &rxBuf); + if (result != HasReturnvaluesIF::RETURN_OK) { + closeSpi(gpioId, gpioIF, mutex); + return result; + } + + size_t replyBufferSize = cookie->getMaxBufferSize(); + + /** There must be a delay of at least 20 ms after sending the command */ + usleep(RwDefinitions::SPI_REPLY_DELAY); + + /** + * The reaction wheel responds with empty frames while preparing the reply data. + * However, receiving more than 5 empty frames will be interpreted as an error. + */ + uint8_t byteRead = 0; + for (int idx = 0; idx < 10; idx++) { + if (read(fileDescriptor, &byteRead, 1) != 1) { + sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; + closeSpi(gpioId, gpioIF, mutex); + return RwHandler::SPI_READ_FAILURE; + } + if (idx == 0) { + if (byteRead != FLAG_BYTE) { + sif::error << "Invalid data, expected start marker" << std::endl; closeSpi(gpioId, gpioIF, mutex); - return RwHandler::SPI_WRITE_FAILURE; + return RwHandler::NO_START_MARKER; + } } - /** Encoding and sending command */ - size_t idx = 0; - while(idx < sendLen) { - switch(*(sendData + idx)) { - case 0x7E: - writeBuffer[0] = 0x7D; - writeBuffer[1] = 0x5E; - writeSize = 2; - break; - case 0x7D: - writeBuffer[0] = 0x7D; - writeBuffer[1] = 0x5D; - writeSize = 2; - break; - default: - writeBuffer[0] = *(sendData + idx); - writeSize = 1; - break; - } - if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { - sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; - closeSpi(gpioId, gpioIF, mutex); - return RwHandler::SPI_WRITE_FAILURE; - } - idx++; + if (byteRead != FLAG_BYTE) { + break; } - /** Sending frame end sign */ - writeBuffer[0] = 0x7E; - writeSize = 1; - - if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { - sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; - closeSpi(gpioId, gpioIF, mutex); - return RwHandler::SPI_WRITE_FAILURE; - } - - uint8_t* rxBuf = nullptr; - result = comIf->getReadBuffer(cookie->getSpiAddress(), &rxBuf); - if(result != HasReturnvaluesIF::RETURN_OK) { - closeSpi(gpioId, gpioIF, mutex); - return result; - } - - size_t replyBufferSize = cookie->getMaxBufferSize(); - - /** There must be a delay of at least 20 ms after sending the command */ - usleep(RwDefinitions::SPI_REPLY_DELAY); - - /** - * The reaction wheel responds with empty frames while preparing the reply data. - * However, receiving more than 5 empty frames will be interpreted as an error. - */ - uint8_t byteRead = 0; - for (int idx = 0; idx < 10; idx++) { - if(read(fileDescriptor, &byteRead, 1) != 1) { - sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; - closeSpi(gpioId, gpioIF, mutex); - return RwHandler::SPI_READ_FAILURE; - } - if(idx == 0) { - if(byteRead != FLAG_BYTE) { - sif::error << "Invalid data, expected start marker" << std::endl; - closeSpi(gpioId, gpioIF, mutex); - return RwHandler::NO_START_MARKER; - } - } - - if (byteRead != FLAG_BYTE) { - break; - } - - if (idx == 9) { - sif::error << "rwSpiCallback::spiCallback: Empty frame timeout" << std::endl; - closeSpi(gpioId, gpioIF, mutex); - return RwHandler::NO_REPLY; - } + if (idx == 9) { + sif::error << "rwSpiCallback::spiCallback: Empty frame timeout" << std::endl; + closeSpi(gpioId, gpioIF, mutex); + return RwHandler::NO_REPLY; } + } #if FSFW_HAL_SPI_WIRETAPPING == 1 - sif::info << "RW start marker detected" << std::endl; + sif::info << "RW start marker detected" << std::endl; #endif - size_t decodedFrameLen = 0; - while(decodedFrameLen < replyBufferSize) { - - /** First byte already read in */ - if (decodedFrameLen != 0) { - byteRead = 0; - if(read(fileDescriptor, &byteRead, 1) != 1) { - sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; - result = RwHandler::SPI_READ_FAILURE; - break; - } - } - - if (byteRead == FLAG_BYTE) { - /** Reached end of frame */ - break; - } - else if (byteRead == 0x7D) { - if(read(fileDescriptor, &byteRead, 1) != 1) { - sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; - result = RwHandler::SPI_READ_FAILURE; - break; - } - if (byteRead == 0x5E) { - *(rxBuf + decodedFrameLen) = 0x7E; - decodedFrameLen++; - continue; - } - else if (byteRead == 0x5D) { - *(rxBuf + decodedFrameLen) = 0x7D; - decodedFrameLen++; - continue; - } - else { - sif::error << "rwSpiCallback::spiCallback: Invalid substitute" << std::endl; - closeSpi(gpioId, gpioIF, mutex); - result = RwHandler::INVALID_SUBSTITUTE; - break; - } - } - else { - *(rxBuf + decodedFrameLen) = byteRead; - decodedFrameLen++; - continue; - } - - /** - * There might be the unlikely case that each byte in a get-telemetry reply has been - * replaced by its substitute. Than the next byte must correspond to the end sign 0x7E. - * Otherwise there might be something wrong. - */ - if (decodedFrameLen == replyBufferSize) { - if(read(fileDescriptor, &byteRead, 1) != 1) { - sif::error << "rwSpiCallback::spiCallback: Failed to read last byte" << std::endl; - result = RwHandler::SPI_READ_FAILURE; - break; - } - if (byteRead != 0x7E) { - sif::error << "rwSpiCallback::spiCallback: Missing end sign 0x7E" << std::endl; - decodedFrameLen--; - result = RwHandler::MISSING_END_SIGN; - break; - } - } - result = HasReturnvaluesIF::RETURN_OK; + size_t decodedFrameLen = 0; + while (decodedFrameLen < replyBufferSize) { + /** First byte already read in */ + if (decodedFrameLen != 0) { + byteRead = 0; + if (read(fileDescriptor, &byteRead, 1) != 1) { + sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; + result = RwHandler::SPI_READ_FAILURE; + break; + } } - cookie->setTransferSize(decodedFrameLen); - - closeSpi(gpioId, gpioIF, mutex); - - return result; -} - -void closeSpi (gpioId_t gpioId, GpioIF* gpioIF, MutexIF* mutex) { - if(gpioId != gpio::NO_GPIO) { - if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) { - sif::error << "closeSpi: Failed to pull chip select high" << std::endl; - } + if (byteRead == FLAG_BYTE) { + /** Reached end of frame */ + break; + } else if (byteRead == 0x7D) { + if (read(fileDescriptor, &byteRead, 1) != 1) { + sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; + result = RwHandler::SPI_READ_FAILURE; + break; + } + if (byteRead == 0x5E) { + *(rxBuf + decodedFrameLen) = 0x7E; + decodedFrameLen++; + continue; + } else if (byteRead == 0x5D) { + *(rxBuf + decodedFrameLen) = 0x7D; + decodedFrameLen++; + continue; + } else { + sif::error << "rwSpiCallback::spiCallback: Invalid substitute" << std::endl; + closeSpi(gpioId, gpioIF, mutex); + result = RwHandler::INVALID_SUBSTITUTE; + break; + } + } else { + *(rxBuf + decodedFrameLen) = byteRead; + decodedFrameLen++; + continue; } - if(mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "rwSpiCallback::closeSpi: Failed to unlock mutex" << std::endl;; + + /** + * There might be the unlikely case that each byte in a get-telemetry reply has been + * replaced by its substitute. Than the next byte must correspond to the end sign 0x7E. + * Otherwise there might be something wrong. + */ + if (decodedFrameLen == replyBufferSize) { + if (read(fileDescriptor, &byteRead, 1) != 1) { + sif::error << "rwSpiCallback::spiCallback: Failed to read last byte" << std::endl; + result = RwHandler::SPI_READ_FAILURE; + break; + } + if (byteRead != 0x7E) { + sif::error << "rwSpiCallback::spiCallback: Missing end sign 0x7E" << std::endl; + decodedFrameLen--; + result = RwHandler::MISSING_END_SIGN; + break; + } } + result = HasReturnvaluesIF::RETURN_OK; + } + + cookie->setTransferSize(decodedFrameLen); + + closeSpi(gpioId, gpioIF, mutex); + + return result; } + +void closeSpi(gpioId_t gpioId, GpioIF* gpioIF, MutexIF* mutex) { + if (gpioId != gpio::NO_GPIO) { + if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) { + sif::error << "closeSpi: Failed to pull chip select high" << std::endl; + } + } + if (mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "rwSpiCallback::closeSpi: Failed to unlock mutex" << std::endl; + ; + } } +} // namespace rwSpiCallback diff --git a/bsp_q7s/callbacks/rwSpiCallback.h b/bsp_q7s/callbacks/rwSpiCallback.h index 8952f873..843d5b80 100644 --- a/bsp_q7s/callbacks/rwSpiCallback.h +++ b/bsp_q7s/callbacks/rwSpiCallback.h @@ -2,9 +2,8 @@ #define BSP_Q7S_RW_SPI_CALLBACK_H_ #include "fsfw/returnvalues/HasReturnvaluesIF.h" -#include "fsfw_hal/linux/spi/SpiComIF.h" #include "fsfw_hal/common/gpio/GpioCookie.h" - +#include "fsfw_hal/linux/spi/SpiComIF.h" namespace rwSpiCallback { @@ -31,8 +30,8 @@ static constexpr uint8_t FLAG_BYTE = 0x7E; * To switch between the to SPI peripherals, an EMIO is used which will also be controlled * by this function. */ -ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sendData, - size_t sendLen, void* args); +ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sendData, + size_t sendLen, void* args); /** * @brief This function closes a spi session. Pulls the chip select to high an releases the @@ -43,5 +42,5 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sen */ void closeSpi(gpioId_t gpioId, GpioIF* gpioIF, MutexIF* mutex); -} +} // namespace rwSpiCallback #endif /* BSP_Q7S_RW_SPI_CALLBACK_H_ */ diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 271ec508..bdbd51cc 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -1,1171 +1,1103 @@ #include "CoreController.h" + #include "OBSWConfig.h" #include "OBSWVersion.h" -#include "watchdogConf.h" - #include "fsfw/FSFWVersion.h" -#include "fsfw/timemanager/Stopwatch.h" #include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/timemanager/Stopwatch.h" +#include "watchdogConf.h" #if OBSW_USE_TMTC_TCP_BRIDGE == 0 #include "fsfw/osal/common/UdpTmTcBridge.h" #else #include "fsfw/osal/common/TcpTmTcServer.h" #endif -#include "bsp_q7s/memory/scratchApi.h" -#include "bsp_q7s/memory/SdCardManager.h" - #include #include #include +#include "bsp_q7s/memory/SdCardManager.h" +#include "bsp_q7s/memory/scratchApi.h" + CoreController::Chip CoreController::CURRENT_CHIP = Chip::NO_CHIP; CoreController::Copy CoreController::CURRENT_COPY = Copy::NO_COPY; -CoreController::CoreController(object_id_t objectId): - ExtendedControllerBase(objectId, objects::NO_OBJECT, 5), opDivider(5) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - try { - result = initWatchdogFifo(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::CoreController: Watchdog FIFO init failed" << - std::endl; - } - sdcMan = SdCardManager::instance(); - if(sdcMan == nullptr) { - sif::error << "CoreController::CoreController: SD card manager invalid!" << std::endl; - } - - if(not BLOCKING_SD_INIT) { - sdcMan->setBlocking(false); - } - sdStateMachine(); - - result = initBootCopy(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::CoreController: Boot copy init" << std::endl; - } +CoreController::CoreController(object_id_t objectId) + : ExtendedControllerBase(objectId, objects::NO_OBJECT, 5), opDivider(5) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + try { + result = initWatchdogFifo(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::CoreController: Watchdog FIFO init failed" << std::endl; } - catch(const std::filesystem::filesystem_error& e) { - sif::error << "CoreController::CoreController: Failed with exception " << - e.what() << std::endl; + sdcMan = SdCardManager::instance(); + if (sdcMan == nullptr) { + sif::error << "CoreController::CoreController: SD card manager invalid!" << std::endl; } + + if (not BLOCKING_SD_INIT) { + sdcMan->setBlocking(false); + } + sdStateMachine(); + + result = initBootCopy(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::CoreController: Boot copy init" << std::endl; + } + } catch (const std::filesystem::filesystem_error &e) { + sif::error << "CoreController::CoreController: Failed with exception " << e.what() << std::endl; + } } ReturnValue_t CoreController::handleCommandMessage(CommandMessage *message) { - return ExtendedControllerBase::handleCommandMessage(message); + return ExtendedControllerBase::handleCommandMessage(message); } void CoreController::performControlOperation() { - performWatchdogControlOperation(); - sdStateMachine(); + performWatchdogControlOperation(); + sdStateMachine(); } ReturnValue_t CoreController::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) { - return HasReturnvaluesIF::RETURN_OK; + LocalDataPoolManager &poolManager) { + return HasReturnvaluesIF::RETURN_OK; } -LocalPoolDataSetBase* CoreController::getDataSetHandle(sid_t sid) { - return nullptr; -} +LocalPoolDataSetBase *CoreController::getDataSetHandle(sid_t sid) { return nullptr; } ReturnValue_t CoreController::initialize() { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - result = scratch::writeNumber(scratch::ALLOC_FAILURE_COUNT, 0); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::initialize: Setting up alloc failure " - "count failed" << std::endl; - } + result = scratch::writeNumber(scratch::ALLOC_FAILURE_COUNT, 0); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::initialize: Setting up alloc failure " + "count failed" + << std::endl; + } - sdStateMachine(); - return ExtendedControllerBase::initialize(); + sdStateMachine(); + return ExtendedControllerBase::initialize(); } ReturnValue_t CoreController::initializeAfterTaskCreation() { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - if(BLOCKING_SD_INIT) { - ReturnValue_t result = initSdCardBlocking(); - if(result != HasReturnvaluesIF::RETURN_OK and result != SdCardManager::ALREADY_MOUNTED) { - sif::warning << "CoreController::CoreController: SD card init failed" << std::endl; - } + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + if (BLOCKING_SD_INIT) { + ReturnValue_t result = initSdCardBlocking(); + if (result != HasReturnvaluesIF::RETURN_OK and result != SdCardManager::ALREADY_MOUNTED) { + sif::warning << "CoreController::CoreController: SD card init failed" << std::endl; } - sdStateMachine(); - result = initVersionFile(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::initialize: Version initialization failed" << std::endl; - } - // Add script folder to path - char* currentEnvPath = getenv("PATH"); - std::string updatedEnvPath = std::string(currentEnvPath) + ":/home/root/scripts"; - setenv("PATH", updatedEnvPath.c_str(), true); - updateProtInfo(); - initPrint(); - return result; + } + sdStateMachine(); + result = initVersionFile(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::initialize: Version initialization failed" << std::endl; + } + // Add script folder to path + char *currentEnvPath = getenv("PATH"); + std::string updatedEnvPath = std::string(currentEnvPath) + ":/home/root/scripts"; + setenv("PATH", updatedEnvPath.c_str(), true); + updateProtInfo(); + initPrint(); + return result; } ReturnValue_t CoreController::checkModeCommand(Mode_t mode, Submode_t submode, - uint32_t *msToReachTheMode) { - return HasReturnvaluesIF::RETURN_OK; + uint32_t *msToReachTheMode) { + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t CoreController::initSdCardBlocking() { - // Create update status file - ReturnValue_t result = sdcMan->updateSdCardStateFile(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::initialize: Updating SD card state file failed" - << std::endl; - } + // Create update status file + ReturnValue_t result = sdcMan->updateSdCardStateFile(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::initialize: Updating SD card state file failed" << std::endl; + } #if Q7S_SD_CARD_CONFIG == Q7S_SD_NONE - sif::info << "No SD card initialization will be performed" << std::endl; - return HasReturnvaluesIF::RETURN_OK; + sif::info << "No SD card initialization will be performed" << std::endl; + return HasReturnvaluesIF::RETURN_OK; #else - result = sdcMan->getSdCardActiveStatus(sdInfo.currentState); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Getting SD card activity status failed" << std::endl; - } + result = sdcMan->getSdCardActiveStatus(sdInfo.currentState); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Getting SD card activity status failed" << std::endl; + } #if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT - determinePreferredSdCard(); - updateSdInfoOther(); - sif::info << "Cold redundant SD card configuration, preferred SD card: " << - static_cast(sdInfo.pref) << std::endl; - result = sdColdRedundantBlockingInit(); - // Update status file - sdcMan->updateSdCardStateFile(); - return result; + determinePreferredSdCard(); + updateSdInfoOther(); + sif::info << "Cold redundant SD card configuration, preferred SD card: " + << static_cast(sdInfo.pref) << std::endl; + result = sdColdRedundantBlockingInit(); + // Update status file + sdcMan->updateSdCardStateFile(); + return result; #elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT - sif::info << "Hot redundant SD card configuration" << std::endl; - sdCardSetup(sd::SdCard::SLOT_0, sd::SdState::MOUNTED, "0", false); - sdCardSetup(sd::SdCard::SLOT_1, sd::SdState::MOUNTED, "1", false); - // Update status file - sdcMan->updateSdCardStateFile(); - return HasReturnvaluesIF::RETURN_OK; + sif::info << "Hot redundant SD card configuration" << std::endl; + sdCardSetup(sd::SdCard::SLOT_0, sd::SdState::MOUNTED, "0", false); + sdCardSetup(sd::SdCard::SLOT_1, sd::SdState::MOUNTED, "1", false); + // Update status file + sdcMan->updateSdCardStateFile(); + return HasReturnvaluesIF::RETURN_OK; #endif #endif /* Q7S_SD_CARD_CONFIG != Q7S_SD_NONE */ - } ReturnValue_t CoreController::sdStateMachine() { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - SdCardManager::Operations operation; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + SdCardManager::Operations operation; - if(sdInfo.state == SdStates::IDLE) { - // Nothing to do - return result; - } + if (sdInfo.state == SdStates::IDLE) { + // Nothing to do + return result; + } - if(sdInfo.state == SdStates::START) { - // Init will be performed by separate function - if(BLOCKING_SD_INIT) { - sdInfo.state = SdStates::IDLE; - sdInfo.initFinished = true; - return result; - } - else { - // Still update SD state file + if (sdInfo.state == SdStates::START) { + // Init will be performed by separate function + if (BLOCKING_SD_INIT) { + sdInfo.state = SdStates::IDLE; + sdInfo.initFinished = true; + return result; + } else { + // Still update SD state file #if Q7S_SD_CARD_CONFIG == Q7S_SD_NONE - sdInfo.state = SdStates::UPDATE_INFO; + sdInfo.state = SdStates::UPDATE_INFO; #else - sdInfo.cycleCount = 0; - sdInfo.commandExecuted = false; - sdInfo.state = SdStates::GET_INFO; + sdInfo.cycleCount = 0; + sdInfo.commandExecuted = false; + sdInfo.state = SdStates::GET_INFO; #endif - } } + } - // This lambda checks the non-blocking operation and assigns the new state on success. - // It returns true for an operation success and false otherwise - auto nonBlockingOpChecking = [&](SdStates newStateOnSuccess, - uint16_t maxCycleCount, std::string opPrintout) { - SdCardManager::OpStatus status = sdcMan->checkCurrentOp(operation); - if(status == SdCardManager::OpStatus::SUCCESS) { - sdInfo.state = newStateOnSuccess; - sdInfo.commandExecuted = false; - sdInfo.cycleCount = 0; - return true; - } - else if(sdInfo.cycleCount > 4) { - sif::warning << "CoreController::sdInitStateMachine: " << opPrintout << - " takes too long" << std::endl; - return false; - } - return false; - }; - - if(sdInfo.state == SdStates::GET_INFO) { - if(not sdInfo.commandExecuted) { - // Create update status file - result = sdcMan->updateSdCardStateFile(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::initialize: Updating SD card state file failed" - << std::endl; - } - sdInfo.commandExecuted = true; - } - else { - nonBlockingOpChecking(SdStates::SET_STATE_SELF, 4, "Updating SDC file"); - } + // This lambda checks the non-blocking operation and assigns the new state on success. + // It returns true for an operation success and false otherwise + auto nonBlockingOpChecking = [&](SdStates newStateOnSuccess, uint16_t maxCycleCount, + std::string opPrintout) { + SdCardManager::OpStatus status = sdcMan->checkCurrentOp(operation); + if (status == SdCardManager::OpStatus::SUCCESS) { + sdInfo.state = newStateOnSuccess; + sdInfo.commandExecuted = false; + sdInfo.cycleCount = 0; + return true; + } else if (sdInfo.cycleCount > 4) { + sif::warning << "CoreController::sdInitStateMachine: " << opPrintout << " takes too long" + << std::endl; + return false; } + return false; + }; - if(sdInfo.state == SdStates::SET_STATE_SELF) { - if(not sdInfo.commandExecuted) { - result = sdcMan->getSdCardActiveStatus(sdInfo.currentState); - determinePreferredSdCard(); - updateSdInfoOther(); - if(sdInfo.pref != sd::SdCard::SLOT_0 and sdInfo.pref != sd::SdCard::SLOT_1) { - sif::warning << "Preferred SD card invalid. Setting to card 0.." << std::endl; - sdInfo.pref = sd::SdCard::SLOT_0; - } - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Getting SD card activity status failed" << std::endl; - } + if (sdInfo.state == SdStates::GET_INFO) { + if (not sdInfo.commandExecuted) { + // Create update status file + result = sdcMan->updateSdCardStateFile(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::initialize: Updating SD card state file failed" + << std::endl; + } + sdInfo.commandExecuted = true; + } else { + nonBlockingOpChecking(SdStates::SET_STATE_SELF, 4, "Updating SDC file"); + } + } + + if (sdInfo.state == SdStates::SET_STATE_SELF) { + if (not sdInfo.commandExecuted) { + result = sdcMan->getSdCardActiveStatus(sdInfo.currentState); + determinePreferredSdCard(); + updateSdInfoOther(); + if (sdInfo.pref != sd::SdCard::SLOT_0 and sdInfo.pref != sd::SdCard::SLOT_1) { + sif::warning << "Preferred SD card invalid. Setting to card 0.." << std::endl; + sdInfo.pref = sd::SdCard::SLOT_0; + } + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Getting SD card activity status failed" << std::endl; + } #if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT - sif::info << "Cold redundant SD card configuration, preferred SD card: " << - static_cast(sdInfo.pref) << std::endl; + sif::info << "Cold redundant SD card configuration, preferred SD card: " + << static_cast(sdInfo.pref) << std::endl; #endif - if(sdInfo.prefState == sd::SdState::MOUNTED) { + if (sdInfo.prefState == sd::SdState::MOUNTED) { #if OBSW_VERBOSE_LEVEL >= 1 - std::string mountString; - if(sdInfo.pref == sd::SdCard::SLOT_0) { - mountString = SdCardManager::SD_0_MOUNT_POINT; - } - else { - mountString = SdCardManager::SD_1_MOUNT_POINT; - } - sif::info << "SD card " << sdInfo.prefChar << " already on and mounted at " << - mountString << std::endl; + std::string mountString; + if (sdInfo.pref == sd::SdCard::SLOT_0) { + mountString = SdCardManager::SD_0_MOUNT_POINT; + } else { + mountString = SdCardManager::SD_1_MOUNT_POINT; + } + sif::info << "SD card " << sdInfo.prefChar << " already on and mounted at " << mountString + << std::endl; #endif - sdInfo.state = SdStates::DETERMINE_OTHER; - } - else if(sdInfo.prefState == sd::SdState::OFF) { - sdCardSetup(sdInfo.pref, sd::SdState::ON, sdInfo.prefChar, false); - sdInfo.commandExecuted = true; - } - else if(sdInfo.prefState == sd::SdState::ON) { - sdInfo.state = SdStates::MOUNT_SELF; - } - } - else { - if(nonBlockingOpChecking(SdStates::MOUNT_SELF, 10, "Setting SDC state")) { - sdInfo.prefState = sd::SdState::ON; - currentStateSetter(sdInfo.pref, sd::SdState::ON); - } - } + sdInfo.state = SdStates::DETERMINE_OTHER; + } else if (sdInfo.prefState == sd::SdState::OFF) { + sdCardSetup(sdInfo.pref, sd::SdState::ON, sdInfo.prefChar, false); + sdInfo.commandExecuted = true; + } else if (sdInfo.prefState == sd::SdState::ON) { + sdInfo.state = SdStates::MOUNT_SELF; + } + } else { + if (nonBlockingOpChecking(SdStates::MOUNT_SELF, 10, "Setting SDC state")) { + sdInfo.prefState = sd::SdState::ON; + currentStateSetter(sdInfo.pref, sd::SdState::ON); + } } + } - if(sdInfo.state == SdStates::MOUNT_SELF) { - if(not sdInfo.commandExecuted) { - result = sdCardSetup(sdInfo.pref, sd::SdState::MOUNTED, sdInfo.prefChar); - sdInfo.commandExecuted = true; - } - else { - if(nonBlockingOpChecking(SdStates::DETERMINE_OTHER, 5, "Mounting SD card")) { - sdInfo.prefState = sd::SdState::MOUNTED; - currentStateSetter(sdInfo.pref, sd::SdState::MOUNTED); - } - } + if (sdInfo.state == SdStates::MOUNT_SELF) { + if (not sdInfo.commandExecuted) { + result = sdCardSetup(sdInfo.pref, sd::SdState::MOUNTED, sdInfo.prefChar); + sdInfo.commandExecuted = true; + } else { + if (nonBlockingOpChecking(SdStates::DETERMINE_OTHER, 5, "Mounting SD card")) { + sdInfo.prefState = sd::SdState::MOUNTED; + currentStateSetter(sdInfo.pref, sd::SdState::MOUNTED); + } } + } - if(sdInfo.state == SdStates::DETERMINE_OTHER) { - // Determine whether any additional operations have to be done for the other SD card - // 1. Cold redundant case: Other SD card needs to be unmounted and switched off - // 2. Hot redundant case: Other SD card needs to be mounted and switched on + if (sdInfo.state == SdStates::DETERMINE_OTHER) { + // Determine whether any additional operations have to be done for the other SD card + // 1. Cold redundant case: Other SD card needs to be unmounted and switched off + // 2. Hot redundant case: Other SD card needs to be mounted and switched on #if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT - if(sdInfo.otherState == sd::SdState::ON) { - sdInfo.state = SdStates::SET_STATE_OTHER; - } - else if(sdInfo.otherState == sd::SdState::MOUNTED) { - sdInfo.state = SdStates::MOUNT_UNMOUNT_OTHER; - } - else { - // Is already off, update info, but with a small delay - sdInfo.state = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE; - } -#elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT - if(sdInfo.otherState == sd::SdState::OFF) { - sdInfo.state = SdStates::SET_STATE_OTHER; - } - else if(sdInfo.otherState == sd::SdState::ON) { - sdInfo.state = SdStates::MOUNT_UNMOUNT_OTHER; - } - else { - // Is already on and mounted, update info - sdInfo.state = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE; - } -#endif + if (sdInfo.otherState == sd::SdState::ON) { + sdInfo.state = SdStates::SET_STATE_OTHER; + } else if (sdInfo.otherState == sd::SdState::MOUNTED) { + sdInfo.state = SdStates::MOUNT_UNMOUNT_OTHER; + } else { + // Is already off, update info, but with a small delay + sdInfo.state = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE; } +#elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT + if (sdInfo.otherState == sd::SdState::OFF) { + sdInfo.state = SdStates::SET_STATE_OTHER; + } else if (sdInfo.otherState == sd::SdState::ON) { + sdInfo.state = SdStates::MOUNT_UNMOUNT_OTHER; + } else { + // Is already on and mounted, update info + sdInfo.state = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE; + } +#endif + } - if(sdInfo.state == SdStates::SET_STATE_OTHER) { - // Set state of other SD card to ON or OFF, depending on redundancy mode + if (sdInfo.state == SdStates::SET_STATE_OTHER) { + // Set state of other SD card to ON or OFF, depending on redundancy mode #if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT - if(not sdInfo.commandExecuted) { - result = sdCardSetup(sdInfo.other, sd::SdState::OFF, sdInfo.otherChar, false); - sdInfo.commandExecuted = true; - } - else { - if(nonBlockingOpChecking(SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE, 10, - "Switching off other SD card")) { - sdInfo.otherState = sd::SdState::OFF; - currentStateSetter(sdInfo.other, sd::SdState::OFF); - } - } -#elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT - if(not sdInfo.commandExecuted) { - result = sdCardSetup(sdInfo.other, sd::SdState::ON, sdInfo.otherChar, false); - sdInfo.commandExecuted = true; - } - else { - if(nonBlockingOpChecking(SdStates::MOUNT_UNMOUNT_OTHER, 10, - "Switching on other SD card")) { - sdInfo.otherState = sd::SdState::ON; - currentStateSetter(sdInfo.other, sd::SdState::ON); - } - } -#endif + if (not sdInfo.commandExecuted) { + result = sdCardSetup(sdInfo.other, sd::SdState::OFF, sdInfo.otherChar, false); + sdInfo.commandExecuted = true; + } else { + if (nonBlockingOpChecking(SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE, 10, + "Switching off other SD card")) { + sdInfo.otherState = sd::SdState::OFF; + currentStateSetter(sdInfo.other, sd::SdState::OFF); + } } +#elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT + if (not sdInfo.commandExecuted) { + result = sdCardSetup(sdInfo.other, sd::SdState::ON, sdInfo.otherChar, false); + sdInfo.commandExecuted = true; + } else { + if (nonBlockingOpChecking(SdStates::MOUNT_UNMOUNT_OTHER, 10, "Switching on other SD card")) { + sdInfo.otherState = sd::SdState::ON; + currentStateSetter(sdInfo.other, sd::SdState::ON); + } + } +#endif + } - if(sdInfo.state == SdStates::MOUNT_UNMOUNT_OTHER) { - // Mount or unmount other SD card, depending on redundancy mode + if (sdInfo.state == SdStates::MOUNT_UNMOUNT_OTHER) { + // Mount or unmount other SD card, depending on redundancy mode #if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT - if(not sdInfo.commandExecuted) { - result = sdCardSetup(sdInfo.other, sd::SdState::ON, sdInfo.otherChar); - sdInfo.commandExecuted = true; - } - else { - if(nonBlockingOpChecking(SdStates::SET_STATE_OTHER, 10, "Unmounting other SD card")) { - sdInfo.otherState = sd::SdState::ON; - currentStateSetter(sdInfo.other, sd::SdState::ON); - } - } + if (not sdInfo.commandExecuted) { + result = sdCardSetup(sdInfo.other, sd::SdState::ON, sdInfo.otherChar); + sdInfo.commandExecuted = true; + } else { + if (nonBlockingOpChecking(SdStates::SET_STATE_OTHER, 10, "Unmounting other SD card")) { + sdInfo.otherState = sd::SdState::ON; + currentStateSetter(sdInfo.other, sd::SdState::ON); + } + } #elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT - if(not sdInfo.commandExecuted) { - result = sdCardSetup(sdInfo.other, sd::SdState::MOUNTED, sdInfo.otherChar); - sdInfo.commandExecuted = true; - } - else { - if(nonBlockingOpChecking(SdStates::UPDATE_INFO, 4, "Mounting other SD card")) { - sdInfo.otherState = sd::SdState::MOUNTED; - currentStateSetter(sdInfo.other, sd::SdState::MOUNTED); - } - } + if (not sdInfo.commandExecuted) { + result = sdCardSetup(sdInfo.other, sd::SdState::MOUNTED, sdInfo.otherChar); + sdInfo.commandExecuted = true; + } else { + if (nonBlockingOpChecking(SdStates::UPDATE_INFO, 4, "Mounting other SD card")) { + sdInfo.otherState = sd::SdState::MOUNTED; + currentStateSetter(sdInfo.other, sd::SdState::MOUNTED); + } + } #endif - } + } - if(sdInfo.state == SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE) { - sdInfo.state = SdStates::UPDATE_INFO; + if (sdInfo.state == SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE) { + sdInfo.state = SdStates::UPDATE_INFO; + } else if (sdInfo.state == SdStates::UPDATE_INFO) { + // It is assumed that all tasks are running by the point this section is reached. + // Therefore, perform this operation in blocking mode because it does not take long + // and the ready state of the SD card is available sooner + sdcMan->setBlocking(true); + // Update status file + result = sdcMan->updateSdCardStateFile(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::initialize: Updating SD card state file failed" << std::endl; } - else if(sdInfo.state == SdStates::UPDATE_INFO) { - // It is assumed that all tasks are running by the point this section is reached. - // Therefore, perform this operation in blocking mode because it does not take long - // and the ready state of the SD card is available sooner - sdcMan->setBlocking(true); - // Update status file - result = sdcMan->updateSdCardStateFile(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::initialize: Updating SD card state file failed" - << std::endl; - } - sdInfo.commandExecuted = false; - sdInfo.state = SdStates::IDLE; - sdInfo.cycleCount = 0; - sdcMan->setBlocking(false); - sdcMan->getSdCardActiveStatus(sdInfo.currentState); - if(not sdInfo.initFinished) { - updateSdInfoOther(); - sdInfo.initFinished = true; - sif::info << "SD card initialization finished" << std::endl; - } + sdInfo.commandExecuted = false; + sdInfo.state = SdStates::IDLE; + sdInfo.cycleCount = 0; + sdcMan->setBlocking(false); + sdcMan->getSdCardActiveStatus(sdInfo.currentState); + if (not sdInfo.initFinished) { + updateSdInfoOther(); + sdInfo.initFinished = true; + sif::info << "SD card initialization finished" << std::endl; } + } - if(sdInfo.state == SdStates::SET_STATE_FROM_COMMAND) { - if(not sdInfo.commandExecuted) { - executeNextExternalSdCommand(); - } - else { - checkExternalSdCommandStatus(); - } + if (sdInfo.state == SdStates::SET_STATE_FROM_COMMAND) { + if (not sdInfo.commandExecuted) { + executeNextExternalSdCommand(); + } else { + checkExternalSdCommandStatus(); } + } - sdInfo.cycleCount++; - return HasReturnvaluesIF::RETURN_OK; + sdInfo.cycleCount++; + return HasReturnvaluesIF::RETURN_OK; } void CoreController::executeNextExternalSdCommand() { - std::string sdChar; - sd::SdState currentStateOfCard = sd::SdState::OFF; - if(sdInfo.commandedCard == sd::SdCard::SLOT_0) { - sdChar = "0"; - currentStateOfCard = sdInfo.currentState.first; + std::string sdChar; + sd::SdState currentStateOfCard = sd::SdState::OFF; + if (sdInfo.commandedCard == sd::SdCard::SLOT_0) { + sdChar = "0"; + currentStateOfCard = sdInfo.currentState.first; + } else { + sdChar = "1"; + currentStateOfCard = sdInfo.currentState.second; + } + if (currentStateOfCard == sd::SdState::OFF) { + if (sdInfo.commandedState == sd::SdState::ON) { + sdInfo.currentlyCommandedState = sdInfo.commandedState; + } else if (sdInfo.commandedState == sd::SdState::MOUNTED) { + sdInfo.currentlyCommandedState = sd::SdState::ON; + } else { + // SD card is already on target state + sdInfo.commandFinished = true; + sdInfo.state = SdStates::IDLE; } - else { - sdChar = "1"; - currentStateOfCard = sdInfo.currentState.second; + } else if (currentStateOfCard == sd::SdState::ON) { + if (sdInfo.commandedState == sd::SdState::OFF or + sdInfo.commandedState == sd::SdState::MOUNTED) { + sdInfo.currentlyCommandedState = sdInfo.commandedState; + } else { + // Already on target state + sdInfo.commandFinished = true; + sdInfo.state = SdStates::IDLE; } - if(currentStateOfCard == sd::SdState::OFF) { - if(sdInfo.commandedState == sd::SdState::ON) { - sdInfo.currentlyCommandedState = sdInfo.commandedState; - } - else if(sdInfo.commandedState == sd::SdState::MOUNTED) { - sdInfo.currentlyCommandedState = sd::SdState::ON; - } - else { - // SD card is already on target state - sdInfo.commandFinished = true; - sdInfo.state = SdStates::IDLE; - } + } else if (currentStateOfCard == sd::SdState::MOUNTED) { + if (sdInfo.commandedState == sd::SdState::ON) { + sdInfo.currentlyCommandedState = sdInfo.commandedState; + } else if (sdInfo.commandedState == sd::SdState::OFF) { + // This causes an unmount in sdCardSetup + sdInfo.currentlyCommandedState = sd::SdState::ON; + } else { + sdInfo.commandFinished = true; } - else if(currentStateOfCard == sd::SdState::ON) { - if(sdInfo.commandedState == sd::SdState::OFF or - sdInfo.commandedState == sd::SdState::MOUNTED) { - sdInfo.currentlyCommandedState = sdInfo.commandedState; - } - else { - // Already on target state - sdInfo.commandFinished = true; - sdInfo.state = SdStates::IDLE; - } - } - else if(currentStateOfCard == sd::SdState::MOUNTED) { - if(sdInfo.commandedState == sd::SdState::ON) { - sdInfo.currentlyCommandedState = sdInfo.commandedState; - } - else if(sdInfo.commandedState == sd::SdState::OFF) { - // This causes an unmount in sdCardSetup - sdInfo.currentlyCommandedState = sd::SdState::ON; - } - else { - sdInfo.commandFinished = true; - } - } - sdCardSetup(sdInfo.commandedCard, sdInfo.commandedState, sdChar); - sdInfo.commandExecuted = true; + } + sdCardSetup(sdInfo.commandedCard, sdInfo.commandedState, sdChar); + sdInfo.commandExecuted = true; } void CoreController::checkExternalSdCommandStatus() { - SdCardManager::Operations operation; - SdCardManager::OpStatus status = sdcMan->checkCurrentOp(operation); - if(status == SdCardManager::OpStatus::SUCCESS) { - if(sdInfo.currentlyCommandedState == sdInfo.commandedState) { - sdInfo.state = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE; - sdInfo.commandFinished = true; - } - else { - // stay on same state machine state because the target state was not reached yet. - sdInfo.cycleCount = 0; - } - currentStateSetter(sdInfo.commandedCard, sdInfo.currentlyCommandedState); - sdInfo.commandExecuted = false; - } - else if(sdInfo.cycleCount > 4) { - sif::warning << "CoreController::sdStateMachine: Commanding SD state " - "takes too long" << std::endl; + SdCardManager::Operations operation; + SdCardManager::OpStatus status = sdcMan->checkCurrentOp(operation); + if (status == SdCardManager::OpStatus::SUCCESS) { + if (sdInfo.currentlyCommandedState == sdInfo.commandedState) { + sdInfo.state = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE; + sdInfo.commandFinished = true; + } else { + // stay on same state machine state because the target state was not reached yet. + sdInfo.cycleCount = 0; } + currentStateSetter(sdInfo.commandedCard, sdInfo.currentlyCommandedState); + sdInfo.commandExecuted = false; + } else if (sdInfo.cycleCount > 4) { + sif::warning << "CoreController::sdStateMachine: Commanding SD state " + "takes too long" + << std::endl; + } } void CoreController::currentStateSetter(sd::SdCard sdCard, sd::SdState newState) { - if(sdCard == sd::SdCard::SLOT_0) { - sdInfo.currentState.first = newState; - } - else { - sdInfo.currentState.second = newState; - } + if (sdCard == sd::SdCard::SLOT_0) { + sdInfo.currentState.first = newState; + } else { + sdInfo.currentState.second = newState; + } } ReturnValue_t CoreController::sdCardSetup(sd::SdCard sdCard, sd::SdState targetState, - std::string sdChar, bool printOutput) { - std::string mountString; - sdcMan->setPrintCommandOutput(printOutput); - if(sdCard == sd::SdCard::SLOT_0) { - mountString = SdCardManager::SD_0_MOUNT_POINT; - } - else { - mountString = SdCardManager::SD_1_MOUNT_POINT; - } + std::string sdChar, bool printOutput) { + std::string mountString; + sdcMan->setPrintCommandOutput(printOutput); + if (sdCard == sd::SdCard::SLOT_0) { + mountString = SdCardManager::SD_0_MOUNT_POINT; + } else { + mountString = SdCardManager::SD_1_MOUNT_POINT; + } - sd::SdState state = sd::SdState::OFF; - if(sdCard == sd::SdCard::SLOT_0) { - state = sdInfo.currentState.first; - } - else { - state = sdInfo.currentState.second; - } - if(state == sd::SdState::MOUNTED) { - if(targetState == sd::SdState::OFF) { - sif::info << "Switching off SD card " << sdChar << std::endl; - return sdcMan->switchOffSdCard(sdCard, true, &sdInfo.currentState); - } - else if(targetState == sd::SdState::ON) { - sif::info << "Unmounting SD card " << sdChar << std::endl; - return sdcMan->unmountSdCard(sdCard); - } - else { - if(std::filesystem::exists(mountString)) { - sif::info << "SD card " << sdChar << " already on and mounted at " << - mountString << std::endl; - return SdCardManager::ALREADY_MOUNTED; - } - sif::error << "SD card mounted but expected mount point " << - mountString << " not found!" << std::endl; - return SdCardManager::MOUNT_ERROR; - } + sd::SdState state = sd::SdState::OFF; + if (sdCard == sd::SdCard::SLOT_0) { + state = sdInfo.currentState.first; + } else { + state = sdInfo.currentState.second; + } + if (state == sd::SdState::MOUNTED) { + if (targetState == sd::SdState::OFF) { + sif::info << "Switching off SD card " << sdChar << std::endl; + return sdcMan->switchOffSdCard(sdCard, true, &sdInfo.currentState); + } else if (targetState == sd::SdState::ON) { + sif::info << "Unmounting SD card " << sdChar << std::endl; + return sdcMan->unmountSdCard(sdCard); + } else { + if (std::filesystem::exists(mountString)) { + sif::info << "SD card " << sdChar << " already on and mounted at " << mountString + << std::endl; + return SdCardManager::ALREADY_MOUNTED; + } + sif::error << "SD card mounted but expected mount point " << mountString << " not found!" + << std::endl; + return SdCardManager::MOUNT_ERROR; } + } - if(state == sd::SdState::OFF) { - if(targetState == sd::SdState::MOUNTED) { - sif::info << "Switching on and mounting SD card " << sdChar << " at " << - mountString << std::endl; - return sdcMan->switchOnSdCard(sdCard, true, &sdInfo.currentState); - } - else if(targetState == sd::SdState::ON) { - sif::info << "Switching on SD card " << sdChar << std::endl; - return sdcMan->switchOnSdCard(sdCard, false, &sdInfo.currentState); - } + if (state == sd::SdState::OFF) { + if (targetState == sd::SdState::MOUNTED) { + sif::info << "Switching on and mounting SD card " << sdChar << " at " << mountString + << std::endl; + return sdcMan->switchOnSdCard(sdCard, true, &sdInfo.currentState); + } else if (targetState == sd::SdState::ON) { + sif::info << "Switching on SD card " << sdChar << std::endl; + return sdcMan->switchOnSdCard(sdCard, false, &sdInfo.currentState); } + } - else if(state == sd::SdState::ON) { - if(targetState == sd::SdState::MOUNTED) { - sif::info << "Mounting SD card " << sdChar << " at " << mountString << std::endl; - return sdcMan->mountSdCard(sdCard); - } - else if(targetState == sd::SdState::OFF) { - sif::info << "Switching off SD card " << sdChar << std::endl; - return sdcMan->switchOffSdCard(sdCard, false, &sdInfo.currentState); - } + else if (state == sd::SdState::ON) { + if (targetState == sd::SdState::MOUNTED) { + sif::info << "Mounting SD card " << sdChar << " at " << mountString << std::endl; + return sdcMan->mountSdCard(sdCard); + } else if (targetState == sd::SdState::OFF) { + sif::info << "Switching off SD card " << sdChar << std::endl; + return sdcMan->switchOffSdCard(sdCard, false, &sdInfo.currentState); } - else { - sif::warning << "CoreController::sdCardSetup: Invalid state for this call" << std::endl; - } - return HasReturnvaluesIF::RETURN_OK; + } else { + sif::warning << "CoreController::sdCardSetup: Invalid state for this call" << std::endl; + } + return HasReturnvaluesIF::RETURN_OK; } - ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t *data, size_t size) { - switch(actionId) { - case(LIST_DIRECTORY_INTO_FILE): { - return actionListDirectoryIntoFile(actionId, commandedBy, data, size); + const uint8_t *data, size_t size) { + switch (actionId) { + case (LIST_DIRECTORY_INTO_FILE): { + return actionListDirectoryIntoFile(actionId, commandedBy, data, size); } - case(REBOOT_OBC): { - return actionPerformReboot(data, size); + case (REBOOT_OBC): { + return actionPerformReboot(data, size); } default: { - return HasActionsIF::INVALID_ACTION_ID; - } + return HasActionsIF::INVALID_ACTION_ID; } + } } ReturnValue_t CoreController::sdColdRedundantBlockingInit() { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - result = sdCardSetup(sdInfo.pref, sd::SdState::MOUNTED, sdInfo.prefChar); - if(result != SdCardManager::ALREADY_MOUNTED and result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Setting up preferred card " << sdInfo.otherChar << - " in cold redundant mode failed" << std::endl; - // Try other SD card and mark set up operation as failed - sdCardSetup(sdInfo.pref, sd::SdState::MOUNTED, sdInfo.prefChar); - result = HasReturnvaluesIF::RETURN_FAILED; - } + result = sdCardSetup(sdInfo.pref, sd::SdState::MOUNTED, sdInfo.prefChar); + if (result != SdCardManager::ALREADY_MOUNTED and result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Setting up preferred card " << sdInfo.otherChar + << " in cold redundant mode failed" << std::endl; + // Try other SD card and mark set up operation as failed + sdCardSetup(sdInfo.pref, sd::SdState::MOUNTED, sdInfo.prefChar); + result = HasReturnvaluesIF::RETURN_FAILED; + } - if(result != HasReturnvaluesIF::RETURN_FAILED and sdInfo.otherState != sd::SdState::OFF) { - sif::info << "Switching off secondary SD card " << sdInfo.otherChar << std::endl; - // Switch off other SD card in cold redundant mode if setting up preferred one worked - // without issues - ReturnValue_t result2 = sdcMan->switchOffSdCard(sdInfo.other, - sdInfo.otherState, &sdInfo.currentState); - if(result2 != HasReturnvaluesIF::RETURN_OK and result2 != SdCardManager::ALREADY_OFF) { - sif::warning << "Switching off secondary SD card " << sdInfo.otherChar << - " in cold redundant mode failed" << std::endl; - } + if (result != HasReturnvaluesIF::RETURN_FAILED and sdInfo.otherState != sd::SdState::OFF) { + sif::info << "Switching off secondary SD card " << sdInfo.otherChar << std::endl; + // Switch off other SD card in cold redundant mode if setting up preferred one worked + // without issues + ReturnValue_t result2 = + sdcMan->switchOffSdCard(sdInfo.other, sdInfo.otherState, &sdInfo.currentState); + if (result2 != HasReturnvaluesIF::RETURN_OK and result2 != SdCardManager::ALREADY_OFF) { + sif::warning << "Switching off secondary SD card " << sdInfo.otherChar + << " in cold redundant mode failed" << std::endl; } - return result; + } + return result; } ReturnValue_t CoreController::incrementAllocationFailureCount() { - uint32_t count = 0; - ReturnValue_t result = scratch::readNumber(scratch::ALLOC_FAILURE_COUNT, count); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - count++; - return scratch::writeNumber(scratch::ALLOC_FAILURE_COUNT, count); + uint32_t count = 0; + ReturnValue_t result = scratch::readNumber(scratch::ALLOC_FAILURE_COUNT, count); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + count++; + return scratch::writeNumber(scratch::ALLOC_FAILURE_COUNT, count); } ReturnValue_t CoreController::initVersionFile() { + std::string unameFileName = "/tmp/uname_version.txt"; + // TODO: No -v flag for now. If the kernel version is used, need to cut off first few letters + std::string unameCmd = "uname -mnrso > " + unameFileName; + int result = std::system(unameCmd.c_str()); + if (result != 0) { + utility::handleSystemError(result, "CoreController::versionFileInit"); + } + std::ifstream unameFile(unameFileName); + std::string unameLine; + if (not std::getline(unameFile, unameLine)) { + sif::warning << "CoreController::versionFileInit: Retrieving uname line failed" << std::endl; + } - std::string unameFileName = "/tmp/uname_version.txt"; - // TODO: No -v flag for now. If the kernel version is used, need to cut off first few letters - std::string unameCmd = "uname -mnrso > " + unameFileName; - int result = std::system(unameCmd.c_str()); - if(result != 0) { - utility::handleSystemError(result, "CoreController::versionFileInit"); - } - std::ifstream unameFile(unameFileName); - std::string unameLine; - if(not std::getline(unameFile, unameLine)) { - sif::warning << "CoreController::versionFileInit: Retrieving uname line failed" - << std::endl; - } - - std::string fullObswVersionString = "OBSW: v" + std::to_string(SW_VERSION) + "." + - std::to_string(SW_SUBVERSION) + "." + std::to_string(SW_REVISION); - std::string fullFsfwVersionString = "FSFW: v" + std::to_string(FSFW_VERSION) + "." + - std::to_string(FSFW_SUBVERSION) + "." + std::to_string(FSFW_REVISION); - std::string systemString = "System: " + unameLine; - std::string mountPrefix = SdCardManager::instance()->getCurrentMountPrefix(); - std::string versionFilePath = mountPrefix + VERSION_FILE; - std::fstream versionFile; - - if(not std::filesystem::exists(versionFilePath)) { - sif::info << "Writing version file " << versionFilePath << ".." << std::endl; - versionFile.open(versionFilePath, std::ios_base::out); - versionFile << fullObswVersionString << std::endl; - versionFile << fullFsfwVersionString << std::endl; - versionFile << systemString << std::endl; - return HasReturnvaluesIF::RETURN_OK; - } - - // Check whether any version has changed - bool createNewFile = false; - versionFile.open(versionFilePath); - std::string currentVersionString; - uint8_t idx = 0; - while(std::getline(versionFile, currentVersionString)) { - if(idx == 0) { - if(currentVersionString != fullObswVersionString) { - sif::info << "OBSW version changed" << std::endl; - sif::info << "From " << currentVersionString << " to " << - fullObswVersionString << std::endl; - createNewFile = true; - } - } - else if(idx == 1) { - if(currentVersionString != fullFsfwVersionString) { - sif::info << "FSFW version changed" << std::endl; - sif::info << "From " << currentVersionString << " to " << - fullFsfwVersionString << std::endl; - createNewFile = true; - } - } - else if(idx == 2) { - if(currentVersionString != systemString) { - sif::info << "System version changed" << std::endl; - sif::info << "Old: " << currentVersionString << std::endl; - sif::info << "New: " << systemString << std::endl; - createNewFile = true; - } - } - else { - sif::warning << "Invalid version file! Rewriting it.." << std::endl; - createNewFile = true; - } - idx++; - } - - // Overwrite file if necessary - if(createNewFile) { - sif::info << "Rewriting version.txt file with updated versions.." << std::endl; - versionFile.close(); - versionFile.open(versionFilePath, std::ios_base::out | std::ios_base::trunc); - versionFile << fullObswVersionString << std::endl; - versionFile << fullFsfwVersionString << std::endl; - versionFile << systemString << std::endl; - } + std::string fullObswVersionString = "OBSW: v" + std::to_string(SW_VERSION) + "." + + std::to_string(SW_SUBVERSION) + "." + + std::to_string(SW_REVISION); + std::string fullFsfwVersionString = "FSFW: v" + std::to_string(FSFW_VERSION) + "." + + std::to_string(FSFW_SUBVERSION) + "." + + std::to_string(FSFW_REVISION); + std::string systemString = "System: " + unameLine; + std::string mountPrefix = SdCardManager::instance()->getCurrentMountPrefix(); + std::string versionFilePath = mountPrefix + VERSION_FILE; + std::fstream versionFile; + if (not std::filesystem::exists(versionFilePath)) { + sif::info << "Writing version file " << versionFilePath << ".." << std::endl; + versionFile.open(versionFilePath, std::ios_base::out); + versionFile << fullObswVersionString << std::endl; + versionFile << fullFsfwVersionString << std::endl; + versionFile << systemString << std::endl; return HasReturnvaluesIF::RETURN_OK; + } + + // Check whether any version has changed + bool createNewFile = false; + versionFile.open(versionFilePath); + std::string currentVersionString; + uint8_t idx = 0; + while (std::getline(versionFile, currentVersionString)) { + if (idx == 0) { + if (currentVersionString != fullObswVersionString) { + sif::info << "OBSW version changed" << std::endl; + sif::info << "From " << currentVersionString << " to " << fullObswVersionString + << std::endl; + createNewFile = true; + } + } else if (idx == 1) { + if (currentVersionString != fullFsfwVersionString) { + sif::info << "FSFW version changed" << std::endl; + sif::info << "From " << currentVersionString << " to " << fullFsfwVersionString + << std::endl; + createNewFile = true; + } + } else if (idx == 2) { + if (currentVersionString != systemString) { + sif::info << "System version changed" << std::endl; + sif::info << "Old: " << currentVersionString << std::endl; + sif::info << "New: " << systemString << std::endl; + createNewFile = true; + } + } else { + sif::warning << "Invalid version file! Rewriting it.." << std::endl; + createNewFile = true; + } + idx++; + } + + // Overwrite file if necessary + if (createNewFile) { + sif::info << "Rewriting version.txt file with updated versions.." << std::endl; + versionFile.close(); + versionFile.open(versionFilePath, std::ios_base::out | std::ios_base::trunc); + versionFile << fullObswVersionString << std::endl; + versionFile << fullFsfwVersionString << std::endl; + versionFile << systemString << std::endl; + } + + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t CoreController::actionListDirectoryIntoFile(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t *data, size_t size) { - // TODO: Packet definition for clean deserialization - // 2 bytes for a and R flag, at least 5 bytes for minimum valid path /tmp with - // null termination, at least 7 bytes for minimum target file name /tmp/a with - // null termination. - if(size < 14) { - return HasActionsIF::INVALID_PARAMETERS; - } - // We could also make -l optional, but I can't think of a reason why to not use -l.. + MessageQueueId_t commandedBy, + const uint8_t *data, size_t size) { + // TODO: Packet definition for clean deserialization + // 2 bytes for a and R flag, at least 5 bytes for minimum valid path /tmp with + // null termination, at least 7 bytes for minimum target file name /tmp/a with + // null termination. + if (size < 14) { + return HasActionsIF::INVALID_PARAMETERS; + } + // We could also make -l optional, but I can't think of a reason why to not use -l.. - // This flag specifies to run ls with -a - bool aFlag = data[0]; - data += 1; - // This flag specifies to run ls with -R - bool RFlag = data[1]; - data += 1; + // This flag specifies to run ls with -a + bool aFlag = data[0]; + data += 1; + // This flag specifies to run ls with -R + bool RFlag = data[1]; + data += 1; - size_t remainingSize = size - 2; - // One larger for null termination, which prevents undefined behaviour if the sent - // strings are not 0 terminated properly - std::vector repoAndTargetFileBuffer(remainingSize + 1, 0); - std::memcpy(repoAndTargetFileBuffer.data(), data, remainingSize); - const char* currentCharPtr = reinterpret_cast(repoAndTargetFileBuffer.data()); - // Full target file name - std::string repoName(currentCharPtr); - size_t repoLength = repoName.length(); - // The other string needs to be at least one letter plus NULL termination to be valid at all - // The first string also needs to be NULL terminated, but the termination is not included - // in the string length, so this is subtracted from the remaining size as well - if(repoLength > remainingSize - 3) { - return HasActionsIF::INVALID_PARAMETERS; - } - // The file length will not include the NULL termination, so we skip it - currentCharPtr += repoLength + 1; - std::string targetFileName(currentCharPtr); - std::ostringstream oss; - oss << "ls -l"; - if(aFlag) { - oss << "a"; - } - if(RFlag) { - oss << "R"; - } + size_t remainingSize = size - 2; + // One larger for null termination, which prevents undefined behaviour if the sent + // strings are not 0 terminated properly + std::vector repoAndTargetFileBuffer(remainingSize + 1, 0); + std::memcpy(repoAndTargetFileBuffer.data(), data, remainingSize); + const char *currentCharPtr = reinterpret_cast(repoAndTargetFileBuffer.data()); + // Full target file name + std::string repoName(currentCharPtr); + size_t repoLength = repoName.length(); + // The other string needs to be at least one letter plus NULL termination to be valid at all + // The first string also needs to be NULL terminated, but the termination is not included + // in the string length, so this is subtracted from the remaining size as well + if (repoLength > remainingSize - 3) { + return HasActionsIF::INVALID_PARAMETERS; + } + // The file length will not include the NULL termination, so we skip it + currentCharPtr += repoLength + 1; + std::string targetFileName(currentCharPtr); + std::ostringstream oss; + oss << "ls -l"; + if (aFlag) { + oss << "a"; + } + if (RFlag) { + oss << "R"; + } - oss << " " << repoName << " > " << targetFileName; - int result = std::system(oss.str().c_str()); - if(result != 0) { - utility::handleSystemError(result, "CoreController::actionListDirectoryIntoFile"); - actionHelper.finish(false, commandedBy, actionId); - } - return HasReturnvaluesIF::RETURN_OK; + oss << " " << repoName << " > " << targetFileName; + int result = std::system(oss.str().c_str()); + if (result != 0) { + utility::handleSystemError(result, "CoreController::actionListDirectoryIntoFile"); + actionHelper.finish(false, commandedBy, actionId); + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t CoreController::initBootCopy() { - if(not std::filesystem::exists(CURR_COPY_FILE)) { - // Thils file is created by the systemd service eive-early-config so this should - // not happen normally - std::string cmd = "xsc_boot_copy > " + std::string(CURR_COPY_FILE); - int result = std::system(cmd.c_str()); - if(result != 0) { - utility::handleSystemError(result, "CoreController::initBootCopy"); - } + if (not std::filesystem::exists(CURR_COPY_FILE)) { + // Thils file is created by the systemd service eive-early-config so this should + // not happen normally + std::string cmd = "xsc_boot_copy > " + std::string(CURR_COPY_FILE); + int result = std::system(cmd.c_str()); + if (result != 0) { + utility::handleSystemError(result, "CoreController::initBootCopy"); } - std::ifstream file(CURR_COPY_FILE); - std::string line; - std::getline(file, line); - std::istringstream iss(line); - int value = 0; - iss >> value; - CURRENT_CHIP = static_cast(value); - iss >> value; - CURRENT_COPY = static_cast(value); - return HasReturnvaluesIF::RETURN_OK; + } + std::ifstream file(CURR_COPY_FILE); + std::string line; + std::getline(file, line); + std::istringstream iss(line); + int value = 0; + iss >> value; + CURRENT_CHIP = static_cast(value); + iss >> value; + CURRENT_COPY = static_cast(value); + return HasReturnvaluesIF::RETURN_OK; } void CoreController::getCurrentBootCopy(Chip &chip, Copy ©) { - // Not really thread-safe but it does not need to be - chip = CURRENT_CHIP; - copy = CURRENT_COPY; + // Not really thread-safe but it does not need to be + chip = CURRENT_CHIP; + copy = CURRENT_COPY; } ReturnValue_t CoreController::initWatchdogFifo() { - if(not std::filesystem::exists(watchdog::FIFO_NAME)) { - // Still return RETURN_OK for now - sif::info << "Watchdog FIFO " << watchdog::FIFO_NAME << " does not exist, can't initiate" << - " watchdog" << std::endl; - return HasReturnvaluesIF::RETURN_OK; - } - // Open FIFO write only and non-blocking to prevent SW from killing itself. - watchdogFifoFd = open(watchdog::FIFO_NAME.c_str(), O_WRONLY | O_NONBLOCK); - if(watchdogFifoFd < 0) { - if(errno == ENXIO) { - watchdogFifoFd = RETRY_FIFO_OPEN; - sif::info << "eive-watchdog not running. FIFO can not be opened" << std::endl; - } - else { - sif::error << "Opening pipe " << watchdog::FIFO_NAME << " write-only failed with " << - errno << ": " << strerror(errno) << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - } + if (not std::filesystem::exists(watchdog::FIFO_NAME)) { + // Still return RETURN_OK for now + sif::info << "Watchdog FIFO " << watchdog::FIFO_NAME << " does not exist, can't initiate" + << " watchdog" << std::endl; return HasReturnvaluesIF::RETURN_OK; + } + // Open FIFO write only and non-blocking to prevent SW from killing itself. + watchdogFifoFd = open(watchdog::FIFO_NAME.c_str(), O_WRONLY | O_NONBLOCK); + if (watchdogFifoFd < 0) { + if (errno == ENXIO) { + watchdogFifoFd = RETRY_FIFO_OPEN; + sif::info << "eive-watchdog not running. FIFO can not be opened" << std::endl; + } else { + sif::error << "Opening pipe " << watchdog::FIFO_NAME << " write-only failed with " << errno + << ": " << strerror(errno) << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + } + return HasReturnvaluesIF::RETURN_OK; } void CoreController::initPrint() { #if OBSW_VERBOSE_LEVEL >= 1 - if(watchdogFifoFd > 0) { - sif::info << "Opened watchdog FIFO successfully.." << std::endl; - } + if (watchdogFifoFd > 0) { + sif::info << "Opened watchdog FIFO successfully.." << std::endl; + } #endif } ReturnValue_t CoreController::actionPerformReboot(const uint8_t *data, size_t size) { - if(size < 1) { - return HasActionsIF::INVALID_PARAMETERS; - } - bool rebootSameBootCopy = data[0]; - bool protOpPerformed; - if(rebootSameBootCopy) { + if (size < 1) { + return HasActionsIF::INVALID_PARAMETERS; + } + bool rebootSameBootCopy = data[0]; + bool protOpPerformed; + if (rebootSameBootCopy) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::info << "CoreController::actionPerformReboot: Rebooting on current image" << std::endl; + sif::info << "CoreController::actionPerformReboot: Rebooting on current image" << std::endl; #endif - // Attempt graceful shutdown by unmounting and switching off SD cards - SdCardManager::instance()->switchOffSdCard(sd::SdCard::SLOT_0); - SdCardManager::instance()->switchOffSdCard(sd::SdCard::SLOT_1); - // If any boot copies are unprotected - ReturnValue_t retval = setBootCopyProtection(Chip::SELF_CHIP, Copy::SELF_COPY, - true, protOpPerformed, false); - if(retval == HasReturnvaluesIF::RETURN_OK and protOpPerformed) { - sif::info << "Running slot was writeprotected before reboot" << std::endl; - } - int result = std::system("xsc_boot_copy -r"); - if(result != 0) { - utility::handleSystemError(result, "CoreController::executeAction"); - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasActionsIF::EXECUTION_FINISHED; + // Attempt graceful shutdown by unmounting and switching off SD cards + SdCardManager::instance()->switchOffSdCard(sd::SdCard::SLOT_0); + SdCardManager::instance()->switchOffSdCard(sd::SdCard::SLOT_1); + // If any boot copies are unprotected + ReturnValue_t retval = + setBootCopyProtection(Chip::SELF_CHIP, Copy::SELF_COPY, true, protOpPerformed, false); + if (retval == HasReturnvaluesIF::RETURN_OK and protOpPerformed) { + sif::info << "Running slot was writeprotected before reboot" << std::endl; } - if(size < 3) { - return HasActionsIF::INVALID_PARAMETERS; - } -#if OBSW_VERBOSE_LEVEL >= 1 - sif::info << "CoreController::actionPerformReboot: Rebooting on " << - static_cast(data[1]) << " " << static_cast(data[2]) << std::endl; -#endif - - // Check that the target chip and copy is writeprotected first - generateChipStateFile(); - // If any boot copies are unprotected, protect them here - ReturnValue_t retval = setBootCopyProtection(static_cast(data[1]), - static_cast(data[2]), true, protOpPerformed, false); - if(retval == HasReturnvaluesIF::RETURN_OK and protOpPerformed) { - sif::info << "Target slot was writeprotected before reboot" << std::endl; - } - - // The second byte in data is the target chip, the third byte is the target copy - std::string cmdString = "xsc_boot_copy " + std::to_string(data[1]) + " " + - std::to_string(data[2]); - int result = std::system(cmdString.c_str()); - if(result != 0) { - utility::handleSystemError(result, "CoreController::executeAction"); - return HasReturnvaluesIF::RETURN_FAILED; + int result = std::system("xsc_boot_copy -r"); + if (result != 0) { + utility::handleSystemError(result, "CoreController::executeAction"); + return HasReturnvaluesIF::RETURN_FAILED; } return HasActionsIF::EXECUTION_FINISHED; + } + if (size < 3) { + return HasActionsIF::INVALID_PARAMETERS; + } +#if OBSW_VERBOSE_LEVEL >= 1 + sif::info << "CoreController::actionPerformReboot: Rebooting on " << static_cast(data[1]) + << " " << static_cast(data[2]) << std::endl; +#endif + + // Check that the target chip and copy is writeprotected first + generateChipStateFile(); + // If any boot copies are unprotected, protect them here + ReturnValue_t retval = setBootCopyProtection( + static_cast(data[1]), static_cast(data[2]), true, protOpPerformed, false); + if (retval == HasReturnvaluesIF::RETURN_OK and protOpPerformed) { + sif::info << "Target slot was writeprotected before reboot" << std::endl; + } + + // The second byte in data is the target chip, the third byte is the target copy + std::string cmdString = + "xsc_boot_copy " + std::to_string(data[1]) + " " + std::to_string(data[2]); + int result = std::system(cmdString.c_str()); + if (result != 0) { + utility::handleSystemError(result, "CoreController::executeAction"); + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasActionsIF::EXECUTION_FINISHED; } -CoreController::~CoreController() { -} +CoreController::~CoreController() {} void CoreController::determinePreferredSdCard() { - if(sdInfo.pref == sd::SdCard::NONE) { - ReturnValue_t result = sdcMan->getPreferredSdCard(sdInfo.pref); - if(result != HasReturnvaluesIF::RETURN_OK) { - if(result == scratch::KEY_NOT_FOUND) { - sif::warning << "CoreController::sdCardInit: " - "Preferred SD card not set. Setting to 0" << std::endl; - sdcMan->setPreferredSdCard(sd::SdCard::SLOT_0); - sdInfo.pref = sd::SdCard::SLOT_0; - } - else { - sif::warning << "CoreController::sdCardInit: Could not get preferred SD card" - "information from the scratch buffer" << std::endl; - } - } + if (sdInfo.pref == sd::SdCard::NONE) { + ReturnValue_t result = sdcMan->getPreferredSdCard(sdInfo.pref); + if (result != HasReturnvaluesIF::RETURN_OK) { + if (result == scratch::KEY_NOT_FOUND) { + sif::warning << "CoreController::sdCardInit: " + "Preferred SD card not set. Setting to 0" + << std::endl; + sdcMan->setPreferredSdCard(sd::SdCard::SLOT_0); + sdInfo.pref = sd::SdCard::SLOT_0; + } else { + sif::warning << "CoreController::sdCardInit: Could not get preferred SD card" + "information from the scratch buffer" + << std::endl; + } } + } } void CoreController::updateSdInfoOther() { - if(sdInfo.pref == sd::SdCard::SLOT_0) { - sdInfo.prefChar = "0"; - sdInfo.otherChar = "1"; - sdInfo.otherState = sdInfo.currentState.second; - sdInfo.prefState = sdInfo.currentState.first; - sdInfo.other = sd::SdCard::SLOT_1; + if (sdInfo.pref == sd::SdCard::SLOT_0) { + sdInfo.prefChar = "0"; + sdInfo.otherChar = "1"; + sdInfo.otherState = sdInfo.currentState.second; + sdInfo.prefState = sdInfo.currentState.first; + sdInfo.other = sd::SdCard::SLOT_1; - } - else if(sdInfo.pref == sd::SdCard::SLOT_1) { - sdInfo.prefChar = "1"; - sdInfo.otherChar = "0"; - sdInfo.otherState = sdInfo.currentState.first; - sdInfo.prefState = sdInfo.currentState.second; - sdInfo.other = sd::SdCard::SLOT_0; - } - else { - sif::warning << "CoreController::updateSdInfoOther: Invalid SD card passed" << std::endl; - } + } else if (sdInfo.pref == sd::SdCard::SLOT_1) { + sdInfo.prefChar = "1"; + sdInfo.otherChar = "0"; + sdInfo.otherState = sdInfo.currentState.first; + sdInfo.prefState = sdInfo.currentState.second; + sdInfo.other = sd::SdCard::SLOT_0; + } else { + sif::warning << "CoreController::updateSdInfoOther: Invalid SD card passed" << std::endl; + } } -bool CoreController::sdInitFinished() const { - return sdInfo.initFinished; -} +bool CoreController::sdInitFinished() const { return sdInfo.initFinished; } ReturnValue_t CoreController::generateChipStateFile() { - int result = std::system(CHIP_PROT_SCRIPT); - if(result != 0) { - utility::handleSystemError(result, "CoreController::generateChipStateFile"); - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + int result = std::system(CHIP_PROT_SCRIPT); + if (result != 0) { + utility::handleSystemError(result, "CoreController::generateChipStateFile"); + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t CoreController::setBootCopyProtection(Chip targetChip, Copy targetCopy, - bool protect, bool& protOperationPerformed, bool updateProtFile) { - bool allChips = false; - bool allCopies = false; - bool selfChip = false; - bool selfCopy = false; - protOperationPerformed = false; +ReturnValue_t CoreController::setBootCopyProtection(Chip targetChip, Copy targetCopy, bool protect, + bool &protOperationPerformed, + bool updateProtFile) { + bool allChips = false; + bool allCopies = false; + bool selfChip = false; + bool selfCopy = false; + protOperationPerformed = false; - switch(targetChip) { - case(Chip::ALL_CHIP): { - allChips = true; - break; + switch (targetChip) { + case (Chip::ALL_CHIP): { + allChips = true; + break; } - case(Chip::NO_CHIP): { - return HasReturnvaluesIF::RETURN_OK; + case (Chip::NO_CHIP): { + return HasReturnvaluesIF::RETURN_OK; } - case(Chip::SELF_CHIP): { - selfChip = true; - targetChip = CURRENT_CHIP; - break; + case (Chip::SELF_CHIP): { + selfChip = true; + targetChip = CURRENT_CHIP; + break; } default: { - break; + break; } + } + switch (targetCopy) { + case (Copy::ALL_COPY): { + allCopies = true; + break; } - switch(targetCopy) { - case(Copy::ALL_COPY): { - allCopies = true; - break; + case (Copy::NO_COPY): { + return HasReturnvaluesIF::RETURN_OK; } - case(Copy::NO_COPY): { - return HasReturnvaluesIF::RETURN_OK; - } - case(Copy::SELF_COPY): { - selfCopy = true; - targetCopy = CURRENT_COPY; - break; + case (Copy::SELF_COPY): { + selfCopy = true; + targetCopy = CURRENT_COPY; + break; } default: { - break; - } + break; } + } - for(uint8_t arrIdx = 0; arrIdx < protArray.size(); arrIdx++) { - int result = handleBootCopyProtAtIndex(targetChip, targetCopy, protect, - protOperationPerformed, selfChip, selfCopy, allChips, allCopies, arrIdx); - if(result != 0) { - break; - } + for (uint8_t arrIdx = 0; arrIdx < protArray.size(); arrIdx++) { + int result = handleBootCopyProtAtIndex(targetChip, targetCopy, protect, protOperationPerformed, + selfChip, selfCopy, allChips, allCopies, arrIdx); + if (result != 0) { + break; } - if(protOperationPerformed and updateProtFile) { - updateProtInfo(); - } - return HasReturnvaluesIF::RETURN_OK; + } + if (protOperationPerformed and updateProtFile) { + updateProtInfo(); + } + return HasReturnvaluesIF::RETURN_OK; } int CoreController::handleBootCopyProtAtIndex(Chip targetChip, Copy targetCopy, bool protect, - bool &protOperationPerformed, bool selfChip, bool selfCopy, bool allChips, - bool allCopies, uint8_t arrIdx) { - bool currentProt = protArray[arrIdx]; - std::ostringstream oss; - bool performOp = false; - if(protect == currentProt) { - return 0; - } - if(protOperationPerformed) { - if((selfChip and selfCopy) or (not allCopies and not allChips)) { - // No need to continue, only one operation was requested - return 1; - } - } - Chip currentChip; - Copy currentCopy; - oss << "writeprotect "; - if(arrIdx == 0 or arrIdx == 1) { - oss << "0 "; - currentChip = Chip::CHIP_0; - } - else { - oss << "1 "; - currentChip = Chip::CHIP_1; - } - if(arrIdx == 0 or arrIdx == 2) { - oss << "0 "; - currentCopy = Copy::COPY_0; - } - else { - oss << "1 "; - currentCopy = Copy::COPY_1; - } - if(protect) { - oss << "1"; - } - else { - oss << "0"; - } - - int result = 0; - if(allChips and allCopies) { - performOp = true; - } - else if(allChips) { - if((selfCopy and CURRENT_COPY == targetCopy) or - (currentCopy == targetCopy)) { - performOp = true; - } - } - else if(allCopies) { - if((selfChip and CURRENT_COPY == targetCopy) or - (currentChip == targetChip)) { - performOp = true; - } - } - else if(selfChip and (currentChip == targetChip)) { - if(selfCopy) { - if(currentCopy == targetCopy) { - performOp = true; - } - } - else { - performOp = true; - } - - } - else if(selfCopy and (currentCopy == targetCopy)) { - if(selfChip) { - if(currentChip == targetChip) { - performOp = true; - } - } - else { - performOp = true; - } - } - else if((targetChip == currentChip) and (targetCopy == currentCopy)) { - performOp = true; - } - if(result != 0) { - utility::handleSystemError(result, "CoreController::checkAndSetBootCopyProtection"); - } - if(performOp) { - // TODO: Lock operation take a long time. Use command executor? That would require a - // new state machine.. - protOperationPerformed = true; - sif::info << "Executing command: " << oss.str() << std::endl; - result = std::system(oss.str().c_str()); - } + bool &protOperationPerformed, bool selfChip, + bool selfCopy, bool allChips, bool allCopies, + uint8_t arrIdx) { + bool currentProt = protArray[arrIdx]; + std::ostringstream oss; + bool performOp = false; + if (protect == currentProt) { return 0; + } + if (protOperationPerformed) { + if ((selfChip and selfCopy) or (not allCopies and not allChips)) { + // No need to continue, only one operation was requested + return 1; + } + } + Chip currentChip; + Copy currentCopy; + oss << "writeprotect "; + if (arrIdx == 0 or arrIdx == 1) { + oss << "0 "; + currentChip = Chip::CHIP_0; + } else { + oss << "1 "; + currentChip = Chip::CHIP_1; + } + if (arrIdx == 0 or arrIdx == 2) { + oss << "0 "; + currentCopy = Copy::COPY_0; + } else { + oss << "1 "; + currentCopy = Copy::COPY_1; + } + if (protect) { + oss << "1"; + } else { + oss << "0"; + } + + int result = 0; + if (allChips and allCopies) { + performOp = true; + } else if (allChips) { + if ((selfCopy and CURRENT_COPY == targetCopy) or (currentCopy == targetCopy)) { + performOp = true; + } + } else if (allCopies) { + if ((selfChip and CURRENT_COPY == targetCopy) or (currentChip == targetChip)) { + performOp = true; + } + } else if (selfChip and (currentChip == targetChip)) { + if (selfCopy) { + if (currentCopy == targetCopy) { + performOp = true; + } + } else { + performOp = true; + } + + } else if (selfCopy and (currentCopy == targetCopy)) { + if (selfChip) { + if (currentChip == targetChip) { + performOp = true; + } + } else { + performOp = true; + } + } else if ((targetChip == currentChip) and (targetCopy == currentCopy)) { + performOp = true; + } + if (result != 0) { + utility::handleSystemError(result, "CoreController::checkAndSetBootCopyProtection"); + } + if (performOp) { + // TODO: Lock operation take a long time. Use command executor? That would require a + // new state machine.. + protOperationPerformed = true; + sif::info << "Executing command: " << oss.str() << std::endl; + result = std::system(oss.str().c_str()); + } + return 0; } ReturnValue_t CoreController::updateProtInfo(bool regenerateChipStateFile) { - using namespace std; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - if(regenerateChipStateFile) { - result = generateChipStateFile(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::updateProtInfo: Generating chip state file failed" << - std::endl; - return result; - } + using namespace std; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + if (regenerateChipStateFile) { + result = generateChipStateFile(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::updateProtInfo: Generating chip state file failed" + << std::endl; + return result; } - if(not filesystem::exists(CHIP_STATE_FILE)) { - return HasReturnvaluesIF::RETURN_FAILED; + } + if (not filesystem::exists(CHIP_STATE_FILE)) { + return HasReturnvaluesIF::RETURN_FAILED; + } + ifstream chipStateFile(CHIP_STATE_FILE); + if (not chipStateFile.good()) { + return HasReturnvaluesIF::RETURN_FAILED; + } + string nextLine; + uint8_t lineCounter = 0; + string word; + while (getline(chipStateFile, nextLine)) { + ReturnValue_t result = handleProtInfoUpdateLine(nextLine); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::updateProtInfo: Protection info update failed!" << std::endl; + return result; } - ifstream chipStateFile(CHIP_STATE_FILE); - if(not chipStateFile.good()) { - return HasReturnvaluesIF::RETURN_FAILED; + ++lineCounter; + if (lineCounter > 4) { + sif::warning << "CoreController::checkAndProtectBootCopy: " + "Line counter larger than 4" + << std::endl; } - string nextLine; - uint8_t lineCounter = 0; - string word; - while(getline(chipStateFile, nextLine)) { - ReturnValue_t result = handleProtInfoUpdateLine(nextLine); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::updateProtInfo: Protection info update failed!" << - std::endl; - return result; - } - ++lineCounter; - if(lineCounter > 4) { - sif::warning << "CoreController::checkAndProtectBootCopy: " - "Line counter larger than 4" << std::endl; - } - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t CoreController::handleProtInfoUpdateLine(std::string nextLine) { - using namespace std; - string word; - uint8_t wordIdx = 0; - uint8_t arrayIdx = 0; - istringstream iss(nextLine); - Chip currentChip = Chip::CHIP_0; - Copy currentCopy = Copy::COPY_0; - while(iss >> word) { - if(wordIdx == 1) { - currentChip = static_cast(stoi(word)); - } - if(wordIdx == 3) { - currentCopy = static_cast(stoi(word)); - } - - if(wordIdx == 3) { - if(currentChip == Chip::CHIP_0) { - if(currentCopy == Copy::COPY_0) { - arrayIdx = 0; - } - else if(currentCopy == Copy::COPY_1) { - arrayIdx = 1; - } - } - - else if(currentChip == Chip::CHIP_1) { - if(currentCopy == Copy::COPY_0) { - arrayIdx = 2; - } - else if(currentCopy == Copy::COPY_1) { - arrayIdx = 3; - } - } - } - if(wordIdx == 5) { - if(word == "unlocked.") { - protArray[arrayIdx] = false; - } - else { - protArray[arrayIdx] = true; - } - } - wordIdx++; + using namespace std; + string word; + uint8_t wordIdx = 0; + uint8_t arrayIdx = 0; + istringstream iss(nextLine); + Chip currentChip = Chip::CHIP_0; + Copy currentCopy = Copy::COPY_0; + while (iss >> word) { + if (wordIdx == 1) { + currentChip = static_cast(stoi(word)); } - return HasReturnvaluesIF::RETURN_OK; + if (wordIdx == 3) { + currentCopy = static_cast(stoi(word)); + } + + if (wordIdx == 3) { + if (currentChip == Chip::CHIP_0) { + if (currentCopy == Copy::COPY_0) { + arrayIdx = 0; + } else if (currentCopy == Copy::COPY_1) { + arrayIdx = 1; + } + } + + else if (currentChip == Chip::CHIP_1) { + if (currentCopy == Copy::COPY_0) { + arrayIdx = 2; + } else if (currentCopy == Copy::COPY_1) { + arrayIdx = 3; + } + } + } + if (wordIdx == 5) { + if (word == "unlocked.") { + protArray[arrayIdx] = false; + } else { + protArray[arrayIdx] = true; + } + } + wordIdx++; + } + return HasReturnvaluesIF::RETURN_OK; } void CoreController::performWatchdogControlOperation() { - // Only perform each fifth iteration - if(watchdogFifoFd != 0 and opDivider.checkAndIncrement()) { - if(watchdogFifoFd == RETRY_FIFO_OPEN) { - // Open FIFO write only and non-blocking - watchdogFifoFd = open(watchdog::FIFO_NAME.c_str(), O_WRONLY | O_NONBLOCK); - if(watchdogFifoFd < 0) { - if(errno == ENXIO) { - watchdogFifoFd = RETRY_FIFO_OPEN; - // No printout for now, would be spam - return; - } - else { - sif::error << "Opening pipe " << watchdog::FIFO_NAME << - " write-only failed with " << errno << ": " << - strerror(errno) << std::endl; - return; - } - } - sif::info << "Opened " << watchdog::FIFO_NAME << " successfully" << std::endl; - } - else if(watchdogFifoFd > 0) { - // Write to OBSW watchdog FIFO here - const char writeChar = 'a'; - ssize_t writtenBytes = write(watchdogFifoFd, &writeChar, 1); - if(writtenBytes < 0) { - sif::error << "Errors writing to watchdog FIFO, code " << errno << ": " << - strerror(errno) << std::endl; - } + // Only perform each fifth iteration + if (watchdogFifoFd != 0 and opDivider.checkAndIncrement()) { + if (watchdogFifoFd == RETRY_FIFO_OPEN) { + // Open FIFO write only and non-blocking + watchdogFifoFd = open(watchdog::FIFO_NAME.c_str(), O_WRONLY | O_NONBLOCK); + if (watchdogFifoFd < 0) { + if (errno == ENXIO) { + watchdogFifoFd = RETRY_FIFO_OPEN; + // No printout for now, would be spam + return; + } else { + sif::error << "Opening pipe " << watchdog::FIFO_NAME << " write-only failed with " + << errno << ": " << strerror(errno) << std::endl; + return; } + } + sif::info << "Opened " << watchdog::FIFO_NAME << " successfully" << std::endl; + } else if (watchdogFifoFd > 0) { + // Write to OBSW watchdog FIFO here + const char writeChar = 'a'; + ssize_t writtenBytes = write(watchdogFifoFd, &writeChar, 1); + if (writtenBytes < 0) { + sif::error << "Errors writing to watchdog FIFO, code " << errno << ": " << strerror(errno) + << std::endl; + } } - + } } diff --git a/bsp_q7s/core/CoreController.h b/bsp_q7s/core/CoreController.h index 74702441..5365000a 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -2,183 +2,167 @@ #define BSP_Q7S_CORE_CORECONTROLLER_H_ #include -#include "fsfw/controller/ExtendedControllerBase.h" + #include "bsp_q7s/memory/SdCardManager.h" - #include "events/subsystemIdRanges.h" - +#include "fsfw/controller/ExtendedControllerBase.h" class Timer; class SdCardManager; -class CoreController: public ExtendedControllerBase { -public: - enum Chip: uint8_t { - CHIP_0, - CHIP_1, - NO_CHIP, - SELF_CHIP, - ALL_CHIP - }; +class CoreController : public ExtendedControllerBase { + public: + enum Chip : uint8_t { CHIP_0, CHIP_1, NO_CHIP, SELF_CHIP, ALL_CHIP }; - enum Copy: uint8_t { - COPY_0, - COPY_1, - NO_COPY, - SELF_COPY, - ALL_COPY - }; + enum Copy : uint8_t { COPY_0, COPY_1, NO_COPY, SELF_COPY, ALL_COPY }; - static constexpr char CHIP_PROT_SCRIPT[] = "/home/root/scripts/get-chip-prot-status.sh"; - static constexpr char CHIP_STATE_FILE[] = "/tmp/chip_prot_status.txt"; - static constexpr char CURR_COPY_FILE[] = "/tmp/curr_copy.txt"; - static constexpr char VERSION_FILE[] = "/conf/sd_status"; + static constexpr char CHIP_PROT_SCRIPT[] = "/home/root/scripts/get-chip-prot-status.sh"; + static constexpr char CHIP_STATE_FILE[] = "/tmp/chip_prot_status.txt"; + static constexpr char CURR_COPY_FILE[] = "/tmp/curr_copy.txt"; + static constexpr char VERSION_FILE[] = "/conf/sd_status"; - static constexpr ActionId_t LIST_DIRECTORY_INTO_FILE = 0; - static constexpr ActionId_t REBOOT_OBC = 32; - static constexpr ActionId_t MOUNT_OTHER_COPY = 33; + static constexpr ActionId_t LIST_DIRECTORY_INTO_FILE = 0; + static constexpr ActionId_t REBOOT_OBC = 32; + static constexpr ActionId_t MOUNT_OTHER_COPY = 33; + static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CORE; - static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CORE; + static constexpr Event ALLOC_FAILURE = event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM); - static constexpr Event ALLOC_FAILURE = event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM); + CoreController(object_id_t objectId); + virtual ~CoreController(); + ReturnValue_t initialize() override; - CoreController(object_id_t objectId); - virtual~ CoreController(); + ReturnValue_t initializeAfterTaskCreation() override; - ReturnValue_t initialize() override; + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) override; - ReturnValue_t initializeAfterTaskCreation() override; + ReturnValue_t handleCommandMessage(CommandMessage* message) override; + void performControlOperation() override; - ReturnValue_t executeAction(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t *data, size_t size) override; + /** + * Generate a file containing the chip lock/unlock states inside /tmp/chip_prot_status.txt + * @return + */ + static ReturnValue_t generateChipStateFile(); + static ReturnValue_t incrementAllocationFailureCount(); + static void getCurrentBootCopy(Chip& chip, Copy& copy); - ReturnValue_t handleCommandMessage(CommandMessage *message) override; - void performControlOperation() override; + ReturnValue_t updateProtInfo(bool regenerateChipStateFile = true); - /** - * Generate a file containing the chip lock/unlock states inside /tmp/chip_prot_status.txt - * @return - */ - static ReturnValue_t generateChipStateFile(); - static ReturnValue_t incrementAllocationFailureCount(); - static void getCurrentBootCopy(Chip& chip, Copy& copy); + /** + * Checks whether the target chip and copy are write protected and protect set them to a target + * state where applicable. + * @param targetChip + * @param targetCopy + * @param protect Target state + * @param protOperationPerformed [out] Can be used to determine whether any operation + * was performed + * @param updateProtFile Specify whether the protection info file is updated + * @return + */ + ReturnValue_t setBootCopyProtection(Chip targetChip, Copy targetCopy, bool protect, + bool& protOperationPerformed, bool updateProtFile = true); - ReturnValue_t updateProtInfo(bool regenerateChipStateFile = true); + bool sdInitFinished() const; - /** - * Checks whether the target chip and copy are write protected and protect set them to a target - * state where applicable. - * @param targetChip - * @param targetCopy - * @param protect Target state - * @param protOperationPerformed [out] Can be used to determine whether any operation - * was performed - * @param updateProtFile Specify whether the protection info file is updated - * @return - */ - ReturnValue_t setBootCopyProtection(Chip targetChip, Copy targetCopy, - bool protect, bool& protOperationPerformed, bool updateProtFile = true); + private: + static Chip CURRENT_CHIP; + static Copy CURRENT_COPY; - bool sdInitFinished() const; + // Designated value for rechecking FIFO open + static constexpr int RETRY_FIFO_OPEN = -2; + int watchdogFifoFd = 0; -private: - static Chip CURRENT_CHIP; - static Copy CURRENT_COPY; + // States for SD state machine, which is used in non-blocking mode + enum class SdStates { + NONE, + START, + GET_INFO, + SET_STATE_SELF, + MOUNT_SELF, + // Determine operations for other SD card, depending on redundancy configuration + DETERMINE_OTHER, + SET_STATE_OTHER, + // Mount or unmount other + MOUNT_UNMOUNT_OTHER, + // Skip period because the shell command used to generate the info file sometimes is + // missing the last performed operation if executed too early + SKIP_CYCLE_BEFORE_INFO_UPDATE, + UPDATE_INFO, + // SD initialization done + IDLE, + // Used if SD switches or mount commands are issued via telecommand + SET_STATE_FROM_COMMAND, + }; + static constexpr bool BLOCKING_SD_INIT = false; - // Designated value for rechecking FIFO open - static constexpr int RETRY_FIFO_OPEN = -2; - int watchdogFifoFd = 0; + SdCardManager* sdcMan = nullptr; - // States for SD state machine, which is used in non-blocking mode - enum class SdStates { - NONE, - START, - GET_INFO, - SET_STATE_SELF, - MOUNT_SELF, - // Determine operations for other SD card, depending on redundancy configuration - DETERMINE_OTHER, - SET_STATE_OTHER, - // Mount or unmount other - MOUNT_UNMOUNT_OTHER, - // Skip period because the shell command used to generate the info file sometimes is - // missing the last performed operation if executed too early - SKIP_CYCLE_BEFORE_INFO_UPDATE, - UPDATE_INFO, - // SD initialization done - IDLE, - // Used if SD switches or mount commands are issued via telecommand - SET_STATE_FROM_COMMAND, - }; - static constexpr bool BLOCKING_SD_INIT = false; + struct SdInfo { + sd::SdCard pref = sd::SdCard::NONE; + sd::SdState prefState = sd::SdState::OFF; + sd::SdCard other = sd::SdCard::NONE; + sd::SdState otherState = sd::SdState::OFF; + std::string prefChar = "0"; + std::string otherChar = "1"; + SdStates state = SdStates::START; + // Used to track whether a command was executed + bool commandExecuted = true; + bool initFinished = false; + SdCardManager::SdStatePair currentState; + uint16_t cycleCount = 0; + // These two flags are related to external commanding + bool commandIssued = false; + bool commandFinished = false; + sd::SdState currentlyCommandedState = sd::SdState::OFF; + sd::SdCard commandedCard = sd::SdCard::NONE; + sd::SdState commandedState = sd::SdState::OFF; + }; + SdInfo sdInfo; - SdCardManager* sdcMan = nullptr; + /** + * Index 0: Chip 0 Copy 0 + * Index 1: Chip 0 Copy 1 + * Index 2: Chip 1 Copy 0 + * Index 3: Chip 1 Copy 1 + */ + std::array protArray; + PeriodicOperationDivider opDivider; - struct SdInfo { - sd::SdCard pref = sd::SdCard::NONE; - sd::SdState prefState = sd::SdState::OFF; - sd::SdCard other = sd::SdCard::NONE; - sd::SdState otherState = sd::SdState::OFF; - std::string prefChar = "0"; - std::string otherChar = "1"; - SdStates state = SdStates::START; - // Used to track whether a command was executed - bool commandExecuted = true; - bool initFinished = false; - SdCardManager::SdStatePair currentState; - uint16_t cycleCount = 0; - // These two flags are related to external commanding - bool commandIssued = false; - bool commandFinished = false; - sd::SdState currentlyCommandedState = sd::SdState::OFF; - sd::SdCard commandedCard = sd::SdCard::NONE; - sd::SdState commandedState = sd::SdState::OFF; - }; - SdInfo sdInfo; + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; + LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t* msToReachTheMode); - /** - * Index 0: Chip 0 Copy 0 - * Index 1: Chip 0 Copy 1 - * Index 2: Chip 1 Copy 0 - * Index 3: Chip 1 Copy 1 - */ - std::array protArray; - PeriodicOperationDivider opDivider; + ReturnValue_t initVersionFile(); + ReturnValue_t initBootCopy(); + ReturnValue_t initWatchdogFifo(); + ReturnValue_t initSdCardBlocking(); + void initPrint(); - ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; - LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; - ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, - uint32_t *msToReachTheMode); + ReturnValue_t sdStateMachine(); + void updateSdInfoOther(); + ReturnValue_t sdCardSetup(sd::SdCard sdCard, sd::SdState targetState, std::string sdChar, + bool printOutput = true); + ReturnValue_t sdColdRedundantBlockingInit(); + void currentStateSetter(sd::SdCard sdCard, sd::SdState newState); + void determinePreferredSdCard(); + void executeNextExternalSdCommand(); + void checkExternalSdCommandStatus(); - ReturnValue_t initVersionFile(); - ReturnValue_t initBootCopy(); - ReturnValue_t initWatchdogFifo(); - ReturnValue_t initSdCardBlocking(); - void initPrint(); + ReturnValue_t actionListDirectoryIntoFile(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size); + ReturnValue_t actionPerformReboot(const uint8_t* data, size_t size); - ReturnValue_t sdStateMachine(); - void updateSdInfoOther(); - ReturnValue_t sdCardSetup(sd::SdCard sdCard, sd::SdState targetState, std::string sdChar, - bool printOutput = true); - ReturnValue_t sdColdRedundantBlockingInit(); - void currentStateSetter(sd::SdCard sdCard, sd::SdState newState); - void determinePreferredSdCard(); - void executeNextExternalSdCommand(); - void checkExternalSdCommandStatus(); + void performWatchdogControlOperation(); - ReturnValue_t actionListDirectoryIntoFile(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t *data, size_t size); - ReturnValue_t actionPerformReboot(const uint8_t *data, size_t size); - - void performWatchdogControlOperation(); - - ReturnValue_t handleProtInfoUpdateLine(std::string nextLine); - int handleBootCopyProtAtIndex(Chip targetChip, Copy targetCopy, bool protect, - bool &protOperationPerformed, bool selfChip, bool selfCopy, bool allChips, - bool allCopies, uint8_t arrIdx); + ReturnValue_t handleProtInfoUpdateLine(std::string nextLine); + int handleBootCopyProtAtIndex(Chip targetChip, Copy targetCopy, bool protect, + bool& protOperationPerformed, bool selfChip, bool selfCopy, + bool allChips, bool allCopies, uint8_t arrIdx); }; #endif /* BSP_Q7S_CORE_CORECONTROLLER_H_ */ diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index df857d59..dce7f27e 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -1,22 +1,21 @@ #include "InitMission.h" -#include "ObjectFactory.h" -#include "OBSWConfig.h" -#include "pollingsequence/pollingSequenceFactory.h" - -#include "mission/utility/InitMission.h" - -#include "fsfw/platform.h" -#include "fsfw/objectmanager/ObjectManagerIF.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" -#include "fsfw/serviceinterface/ServiceInterfaceStream.h" -#include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/tasks/FixedTimeslotTaskIF.h" -#include "fsfw/tasks/PeriodicTaskIF.h" -#include "fsfw/tasks/TaskFactory.h" #include #include +#include "OBSWConfig.h" +#include "ObjectFactory.h" +#include "fsfw/objectmanager/ObjectManager.h" +#include "fsfw/objectmanager/ObjectManagerIF.h" +#include "fsfw/platform.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/serviceinterface/ServiceInterfaceStream.h" +#include "fsfw/tasks/FixedTimeslotTaskIF.h" +#include "fsfw/tasks/PeriodicTaskIF.h" +#include "fsfw/tasks/TaskFactory.h" +#include "mission/utility/InitMission.h" +#include "pollingsequence/pollingSequenceFactory.h" + /* This is configured for linux without CR */ #ifdef PLATFORM_UNIX ServiceInterfaceStream sif::debug("DEBUG"); @@ -30,344 +29,343 @@ ServiceInterfaceStream sif::warning("WARNING", true); ServiceInterfaceStream sif::error("ERROR", true, false, true); #endif -ObjectManagerIF *objectManager = nullptr; +ObjectManagerIF* objectManager = nullptr; void initmission::initMission() { + sif::info << "Building global objects.." << std::endl; + /* Instantiate global object manager and also create all objects */ + ObjectManager::instance()->setObjectFactoryFunction(ObjectFactory::produce, nullptr); + sif::info << "Initializing all objects.." << std::endl; + ObjectManager::instance()->initialize(); - sif::info << "Building global objects.." << std::endl; - /* Instantiate global object manager and also create all objects */ - ObjectManager::instance()->setObjectFactoryFunction(ObjectFactory::produce, nullptr); - sif::info << "Initializing all objects.." << std::endl; - ObjectManager::instance()->initialize(); - - /* This function creates and starts all tasks */ - initTasks(); + /* This function creates and starts all tasks */ + initTasks(); } void initmission::initTasks() { - TaskFactory* factory = TaskFactory::instance(); - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - if(factory == nullptr) { - /* Should never happen ! */ - return; - } + TaskFactory* factory = TaskFactory::instance(); + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + if (factory == nullptr) { + /* Should never happen ! */ + return; + } #if OBSW_PRINT_MISSED_DEADLINES == 1 - void (*missedDeadlineFunc) (void) = TaskFactory::printMissedDeadline; + void (*missedDeadlineFunc)(void) = TaskFactory::printMissedDeadline; #else - void (*missedDeadlineFunc) (void) = nullptr; + void (*missedDeadlineFunc)(void) = nullptr; #endif #if BOARD_TE0720 == 0 - PeriodicTaskIF* coreController = factory->createPeriodicTask( - "CORE_CTRL", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc); - result = coreController->addComponent(objects::CORE_CONTROLLER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("CORE_CTRL", objects::CORE_CONTROLLER); - } + PeriodicTaskIF* coreController = factory->createPeriodicTask( + "CORE_CTRL", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc); + result = coreController->addComponent(objects::CORE_CONTROLLER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("CORE_CTRL", objects::CORE_CONTROLLER); + } #endif - /* TMTC Distribution */ - PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask( - "DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - result = tmTcDistributor->addComponent(objects::CCSDS_PACKET_DISTRIBUTOR); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("CCSDS_DISTRIB", objects::CCSDS_PACKET_DISTRIBUTOR); - } - result = tmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_PACKET_DISTRIB", objects::PUS_PACKET_DISTRIBUTOR); - } - result = tmTcDistributor->addComponent(objects::TM_FUNNEL); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("TM_FUNNEL", objects::TM_FUNNEL); - } + /* TMTC Distribution */ + PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask( + "DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + result = tmTcDistributor->addComponent(objects::CCSDS_PACKET_DISTRIBUTOR); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("CCSDS_DISTRIB", objects::CCSDS_PACKET_DISTRIBUTOR); + } + result = tmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_PACKET_DISTRIB", objects::PUS_PACKET_DISTRIBUTOR); + } + result = tmTcDistributor->addComponent(objects::TM_FUNNEL); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("TM_FUNNEL", objects::TM_FUNNEL); + } #if OBSW_ADD_TCPIP_BRIDGE == 1 - // TMTC bridge - PeriodicTaskIF* tmtcBridgeTask = factory->createPeriodicTask( - "TCPIP_TMTC_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - result = tmtcBridgeTask->addComponent(objects::TMTC_BRIDGE); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("UDP_BRIDGE", objects::TMTC_BRIDGE); - } - PeriodicTaskIF* tmtcPollingTask = factory->createPeriodicTask( - "TMTC_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); - result = tmtcPollingTask->addComponent(objects::TMTC_POLLING_TASK); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("UDP_POLLING", objects::TMTC_POLLING_TASK); - } + // TMTC bridge + PeriodicTaskIF* tmtcBridgeTask = factory->createPeriodicTask( + "TCPIP_TMTC_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + result = tmtcBridgeTask->addComponent(objects::TMTC_BRIDGE); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("UDP_BRIDGE", objects::TMTC_BRIDGE); + } + PeriodicTaskIF* tmtcPollingTask = factory->createPeriodicTask( + "TMTC_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = tmtcPollingTask->addComponent(objects::TMTC_POLLING_TASK); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("UDP_POLLING", objects::TMTC_POLLING_TASK); + } #endif #if OBSW_USE_CCSDS_IP_CORE == 1 - PeriodicTaskIF* ccsdsHandlerTask = factory->createPeriodicTask( - "CCSDS_HANDLER", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); - result = ccsdsHandlerTask->addComponent(objects::CCSDS_HANDLER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("CCSDS Handler", objects::CCSDS_HANDLER); - } + PeriodicTaskIF* ccsdsHandlerTask = factory->createPeriodicTask( + "CCSDS_HANDLER", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = ccsdsHandlerTask->addComponent(objects::CCSDS_HANDLER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("CCSDS Handler", objects::CCSDS_HANDLER); + } - // Minimal distance between two received TCs amounts to 0.6 seconds - // If a command has not been read before the next one arrives, the old command will be - // overwritten by the PDEC. - PeriodicTaskIF* pdecHandlerTask = factory->createPeriodicTask( - "PDEC_HANDLER", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc); - result = pdecHandlerTask->addComponent(objects::PDEC_HANDLER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PDEC Handler", objects::PDEC_HANDLER); - } + // Minimal distance between two received TCs amounts to 0.6 seconds + // If a command has not been read before the next one arrives, the old command will be + // overwritten by the PDEC. + PeriodicTaskIF* pdecHandlerTask = factory->createPeriodicTask( + "PDEC_HANDLER", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc); + result = pdecHandlerTask->addComponent(objects::PDEC_HANDLER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PDEC Handler", objects::PDEC_HANDLER); + } #endif /* OBSW_USE_CCSDS_IP_CORE == 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); - } + 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); + } -# if BOARD_TE0720 == 0 - // FS task, task interval does not matter because it runs in permanent loop, priority low - // because it is a non-essential background task - PeriodicTaskIF* fsTask = factory->createPeriodicTask( - "FILE_SYSTEM_TASK", 25, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc); - result = fsTask->addComponent(objects::FILE_SYSTEM_HANDLER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("FILE_SYSTEM_TASK", objects::FILE_SYSTEM_HANDLER); - } +#if BOARD_TE0720 == 0 + // FS task, task interval does not matter because it runs in permanent loop, priority low + // because it is a non-essential background task + PeriodicTaskIF* fsTask = factory->createPeriodicTask( + "FILE_SYSTEM_TASK", 25, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc); + result = fsTask->addComponent(objects::FILE_SYSTEM_HANDLER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("FILE_SYSTEM_TASK", objects::FILE_SYSTEM_HANDLER); + } #if OBSW_ADD_STAR_TRACKER == 1 - PeriodicTaskIF* strImgLoaderTask = factory->createPeriodicTask( - "FILE_SYSTEM_TASK", 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); - } + PeriodicTaskIF* strImgLoaderTask = factory->createPeriodicTask( + "FILE_SYSTEM_TASK", 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); + } #endif /* OBSW_ADD_STAR_TRACKER == 1 */ #endif /* BOARD_TE0720 */ #if OBSW_TEST_CCSDS_BRIDGE == 1 - PeriodicTaskIF* ptmeTestTask = factory->createPeriodicTask( - "PTME_TEST", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); - result = ptmeTestTask->addComponent(objects::CCSDS_IP_CORE_BRIDGE); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PTME_TEST", objects::CCSDS_IP_CORE_BRIDGE); - } + PeriodicTaskIF* ptmeTestTask = factory->createPeriodicTask( + "PTME_TEST", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = ptmeTestTask->addComponent(objects::CCSDS_IP_CORE_BRIDGE); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PTME_TEST", objects::CCSDS_IP_CORE_BRIDGE); + } #endif - std::vector pusTasks; - createPusTasks(*factory, missedDeadlineFunc, pusTasks); - std::vector pstTasks; - createPstTasks(*factory, missedDeadlineFunc, pstTasks); + std::vector pusTasks; + createPusTasks(*factory, missedDeadlineFunc, pusTasks); + std::vector pstTasks; + createPstTasks(*factory, missedDeadlineFunc, pstTasks); #if OBSW_ADD_TEST_CODE == 1 - std::vector testTasks; - createTestTasks(*factory, missedDeadlineFunc, testTasks); + std::vector testTasks; + createTestTasks(*factory, missedDeadlineFunc, testTasks); #endif - auto taskStarter = [](std::vector& taskVector, std::string name) { - for(const auto& task: taskVector) { - if(task != nullptr) { - task->startTask(); - } - else { - sif::error << "Task in vector " << name << " is invalid!" << std::endl; - } - } - }; + auto taskStarter = [](std::vector& taskVector, std::string name) { + for (const auto& task : taskVector) { + if (task != nullptr) { + task->startTask(); + } else { + sif::error << "Task in vector " << name << " is invalid!" << std::endl; + } + } + }; - sif::info << "Starting tasks.." << std::endl; - tmTcDistributor->startTask(); + sif::info << "Starting tasks.." << std::endl; + tmTcDistributor->startTask(); #if OBSW_ADD_TCPIP_BRIDGE == 1 - tmtcBridgeTask->startTask(); - tmtcPollingTask->startTask(); + tmtcBridgeTask->startTask(); + tmtcPollingTask->startTask(); #endif #if OBSW_USE_CCSDS_IP_CORE == 1 - ccsdsHandlerTask->startTask(); - pdecHandlerTask->startTask(); + ccsdsHandlerTask->startTask(); + pdecHandlerTask->startTask(); #endif /* OBSW_USE_CCSDS_IP_CORE == 1 */ #if BOARD_TE0720 == 0 - coreController->startTask(); + coreController->startTask(); #endif - taskStarter(pstTasks, "PST task vector"); - taskStarter(pusTasks, "PUS task vector"); + taskStarter(pstTasks, "PST task vector"); + taskStarter(pusTasks, "PUS task vector"); #if OBSW_ADD_TEST_CODE == 1 - taskStarter(testTasks, "Test task vector"); + taskStarter(testTasks, "Test task vector"); #endif #if OBSW_TEST_CCSDS_BRIDGE == 1 - ptmeTestTask->startTask(); + ptmeTestTask->startTask(); #endif #if BOARD_TE0720 == 0 - fsTask->startTask(); + fsTask->startTask(); #if OBSW_ADD_STAR_TRACKER == 1 - strImgLoaderTask->startTask(); + strImgLoaderTask->startTask(); #endif /* OBSW_ADD_STAR_TRACKER == 1 */ #endif - acsCtrl->startTask(); + acsCtrl->startTask(); - sif::info << "Tasks started.." << std::endl; + sif::info << "Tasks started.." << std::endl; } void initmission::createPstTasks(TaskFactory& factory, - TaskDeadlineMissedFunction missedDeadlineFunc, std::vector &taskVec) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; #if BOARD_TE0720 == 0 - /* Polling Sequence Table Default */ + /* Polling Sequence Table Default */ #if OBSW_ADD_SPI_TEST_CODE == 0 - FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask( - "PST_TASK_DEFAULT", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.5, - missedDeadlineFunc); - result = pst::pstSpi(spiPst); - if (result != HasReturnvaluesIF::RETURN_OK) { - if(result != FixedTimeslotTaskIF::SLOT_LIST_EMPTY) { - sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; - } - } - else { - taskVec.push_back(spiPst); + FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask( + "PST_TASK_DEFAULT", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.5, missedDeadlineFunc); + result = pst::pstSpi(spiPst); + if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != FixedTimeslotTaskIF::SLOT_LIST_EMPTY) { + sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; } + } else { + taskVec.push_back(spiPst); + } #endif - FixedTimeslotTaskIF* uartPst = factory.createFixedTimeslotTask( - "UART_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc); - result = pst::pstUart(uartPst); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; - } - taskVec.push_back(uartPst); - FixedTimeslotTaskIF* gpioPst = factory.createFixedTimeslotTask( - "GPIO_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc); - result = pst::pstGpio(gpioPst); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; - } - taskVec.push_back(gpioPst); - FixedTimeslotTaskIF* i2cPst = factory.createFixedTimeslotTask( - "I2C_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc); - result = pst::pstI2c(i2cPst); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; - } + FixedTimeslotTaskIF* uartPst = factory.createFixedTimeslotTask( + "UART_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc); + result = pst::pstUart(uartPst); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; + } + taskVec.push_back(uartPst); + FixedTimeslotTaskIF* gpioPst = factory.createFixedTimeslotTask( + "GPIO_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc); + result = pst::pstGpio(gpioPst); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; + } + taskVec.push_back(gpioPst); + FixedTimeslotTaskIF* i2cPst = factory.createFixedTimeslotTask( + "I2C_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc); + result = pst::pstI2c(i2cPst); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; + } - FixedTimeslotTaskIF* gomSpacePstTask = factory.createFixedTimeslotTask( - "GS_PST_TASK", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 1.0, missedDeadlineFunc); - result = pst::pstGompaceCan(gomSpacePstTask); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "InitMission::initTasks: GomSpace PST initialization failed!" << std::endl; - } - taskVec.push_back(gomSpacePstTask); -#else /* BOARD_TE7020 == 0 */ - FixedTimeslotTaskIF * pollingSequenceTaskTE0720 = factory.createFixedTimeslotTask( - "PST_TASK_TE0720", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE * 8, 3.0, - missedDeadlineFunc); - result = pst::pollingSequenceTE0720(pollingSequenceTaskTE0720); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "InitMission::initTasks: Creating TE0720 PST failed!" << std::endl; - } - taskVec.push_back(pollingSequenceTaskTE0720); + FixedTimeslotTaskIF* gomSpacePstTask = factory.createFixedTimeslotTask( + "GS_PST_TASK", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 1.0, missedDeadlineFunc); + result = pst::pstGompaceCan(gomSpacePstTask); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "InitMission::initTasks: GomSpace PST initialization failed!" << std::endl; + } + taskVec.push_back(gomSpacePstTask); +#else /* BOARD_TE7020 == 0 */ + FixedTimeslotTaskIF* pollingSequenceTaskTE0720 = factory.createFixedTimeslotTask( + "PST_TASK_TE0720", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE * 8, 3.0, missedDeadlineFunc); + result = pst::pollingSequenceTE0720(pollingSequenceTaskTE0720); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "InitMission::initTasks: Creating TE0720 PST failed!" << std::endl; + } + taskVec.push_back(pollingSequenceTaskTE0720); #endif /* BOARD_TE7020 == 1 */ } -void initmission::createPusTasks(TaskFactory &factory, - TaskDeadlineMissedFunction missedDeadlineFunc, std::vector &taskVec) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - /* PUS Services */ - PeriodicTaskIF* pusVerification = factory.createPeriodicTask( - "PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_VERIF", objects::PUS_SERVICE_1_VERIFICATION); - } - taskVec.push_back(pusVerification); +void initmission::createPusTasks(TaskFactory& factory, + TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + /* PUS Services */ + PeriodicTaskIF* pusVerification = factory.createPeriodicTask( + "PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_VERIF", objects::PUS_SERVICE_1_VERIFICATION); + } + taskVec.push_back(pusVerification); - PeriodicTaskIF* pusEvents = factory.createPeriodicTask( - "PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusEvents->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_EVENTS", objects::PUS_SERVICE_5_EVENT_REPORTING); - } - result = pusEvents->addComponent(objects::EVENT_MANAGER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_MGMT", objects::EVENT_MANAGER); - } - taskVec.push_back(pusEvents); + PeriodicTaskIF* pusEvents = factory.createPeriodicTask( + "PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusEvents->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_EVENTS", objects::PUS_SERVICE_5_EVENT_REPORTING); + } + result = pusEvents->addComponent(objects::EVENT_MANAGER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_MGMT", objects::EVENT_MANAGER); + } + taskVec.push_back(pusEvents); - PeriodicTaskIF* pusHighPrio = factory.createPeriodicTask( - "PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_2", objects::PUS_SERVICE_2_DEVICE_ACCESS); - } - result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_9", objects::PUS_SERVICE_9_TIME_MGMT); - } - taskVec.push_back(pusHighPrio); + PeriodicTaskIF* pusHighPrio = factory.createPeriodicTask( + "PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_2", objects::PUS_SERVICE_2_DEVICE_ACCESS); + } + result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_9", objects::PUS_SERVICE_9_TIME_MGMT); + } + taskVec.push_back(pusHighPrio); - PeriodicTaskIF* pusMedPrio = factory.createPeriodicTask( - "PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); - result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_8", objects::PUS_SERVICE_8_FUNCTION_MGMT); - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_3_HOUSEKEEPING); - if(result!=HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_200", objects::PUS_SERVICE_200_MODE_MGMT); - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_20", objects::PUS_SERVICE_20_PARAMETERS); - } - taskVec.push_back(pusMedPrio); + PeriodicTaskIF* pusMedPrio = factory.createPeriodicTask( + "PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); + result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_8", objects::PUS_SERVICE_8_FUNCTION_MGMT); + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_3_HOUSEKEEPING); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_200", objects::PUS_SERVICE_200_MODE_MGMT); + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_20", objects::PUS_SERVICE_20_PARAMETERS); + } + taskVec.push_back(pusMedPrio); - PeriodicTaskIF* pusLowPrio = factory.createPeriodicTask( - "PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc); - result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_17", objects::PUS_SERVICE_17_TEST); - } - result = pusLowPrio->addComponent(objects::INTERNAL_ERROR_REPORTER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("ERROR_REPORTER", objects::INTERNAL_ERROR_REPORTER); - } - taskVec.push_back(pusLowPrio); + PeriodicTaskIF* pusLowPrio = factory.createPeriodicTask( + "PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc); + result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_17", objects::PUS_SERVICE_17_TEST); + } + result = pusLowPrio->addComponent(objects::INTERNAL_ERROR_REPORTER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("ERROR_REPORTER", objects::INTERNAL_ERROR_REPORTER); + } + taskVec.push_back(pusLowPrio); } -void initmission::createTestTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector& taskVec) { -#if OBSW_ADD_TEST_TASK == 1 || OBSW_ADD_SPI_TEST_CODE == 1 || (BOARD_TE0720 == 1 && OBSW_TEST_LIBGPIOD == 1) - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; +void initmission::createTestTasks(TaskFactory& factory, + TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec) { +#if OBSW_ADD_TEST_TASK == 1 || OBSW_ADD_SPI_TEST_CODE == 1 || \ + (BOARD_TE0720 == 1 && OBSW_TEST_LIBGPIOD == 1) + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; #endif - PeriodicTaskIF* testTask = factory.createPeriodicTask( - "TEST_TASK", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1, missedDeadlineFunc); + PeriodicTaskIF* testTask = factory.createPeriodicTask( + "TEST_TASK", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1, missedDeadlineFunc); #if OBSW_ADD_TEST_TASK == 1 - result = testTask->addComponent(objects::TEST_TASK); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK); - } + result = testTask->addComponent(objects::TEST_TASK); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK); + } #endif /* OBSW_ADD_TEST_TASK == 1 */ #if OBSW_ADD_SPI_TEST_CODE == 1 - result = testTask->addComponent(objects::SPI_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("SPI_TEST", objects::SPI_TEST); - } + result = testTask->addComponent(objects::SPI_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("SPI_TEST", objects::SPI_TEST); + } #endif #if BOARD_TE0720 == 1 && OBSW_TEST_LIBGPIOD == 1 - result = testTask->addComponent(objects::LIBGPIOD_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("GPIOD_TEST", objects::LIBGPIOD_TEST); - } + result = testTask->addComponent(objects::LIBGPIOD_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("GPIOD_TEST", objects::LIBGPIOD_TEST); + } #endif /* BOARD_TE0720 == 1 && OBSW_TEST_LIBGPIOD == 1 */ - taskVec.push_back(testTask); + taskVec.push_back(testTask); } diff --git a/bsp_q7s/core/InitMission.h b/bsp_q7s/core/InitMission.h index ffdfc11c..5c509b79 100644 --- a/bsp_q7s/core/InitMission.h +++ b/bsp_q7s/core/InitMission.h @@ -1,9 +1,10 @@ #ifndef BSP_Q7S_INITMISSION_H_ #define BSP_Q7S_INITMISSION_H_ -#include "fsfw/tasks/Typedef.h" #include +#include "fsfw/tasks/Typedef.h" + class PeriodicTaskIF; class TaskFactory; @@ -12,11 +13,11 @@ void initMission(); void initTasks(); void createPstTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector& taskVec); + std::vector& taskVec); void createPusTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector& taskVec); + std::vector& taskVec); void createTestTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector& taskVec); -}; + std::vector& taskVec); +}; // namespace initmission #endif /* BSP_Q7S_INITMISSION_H_ */ diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 7b111c4f..4c57ab34 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -1,87 +1,82 @@ -#include #include "ObjectFactory.h" -#include "bsp_q7s/devices/startracker/StrHelper.h" -#include "bsp_q7s/devices/startracker/StarTrackerDefinitions.h" +#include + #include "OBSWConfig.h" -#include "devConf.h" -#include "ccsdsConfig.h" -#include "busConf.h" -#include "tmtc/apid.h" -#include "devices/addresses.h" -#include "devices/gpioIds.h" -#include "tmtc/pusIds.h" -#include "devices/powerSwitcherList.h" -#include "bsp_q7s/gpio/gpioCallbacks.h" -#include "bsp_q7s/core/CoreController.h" #include "bsp_q7s/boardtest/Q7STestTask.h" -#include "bsp_q7s/memory/FileSystemHandler.h" +#include "bsp_q7s/callbacks/gnssCallback.h" +#include "bsp_q7s/callbacks/rwSpiCallback.h" +#include "bsp_q7s/core/CoreController.h" +#include "bsp_q7s/devices/PlocMemoryDumper.h" #include "bsp_q7s/devices/PlocSupervisorHandler.h" #include "bsp_q7s/devices/PlocUpdater.h" -#include "bsp_q7s/devices/PlocMemoryDumper.h" +#include "bsp_q7s/devices/startracker/StarTrackerDefinitions.h" #include "bsp_q7s/devices/startracker/StarTrackerHandler.h" -#include "bsp_q7s/callbacks/rwSpiCallback.h" -#include "bsp_q7s/callbacks/gnssCallback.h" - -#include "linux/devices/SolarArrayDeploymentHandler.h" -#include "linux/devices/devicedefinitions/SusDefinitions.h" -#include "linux/devices/SusHandler.h" -#include "linux/csp/CspCookie.h" +#include "bsp_q7s/devices/startracker/StrHelper.h" +#include "bsp_q7s/gpio/gpioCallbacks.h" +#include "bsp_q7s/memory/FileSystemHandler.h" +#include "busConf.h" +#include "ccsdsConfig.h" +#include "devConf.h" +#include "devices/addresses.h" +#include "devices/gpioIds.h" +#include "devices/powerSwitcherList.h" +#include "fsfw/datapoollocal/LocalDataPoolManager.h" +#include "fsfw/tmtcpacket/pus/tm.h" +#include "fsfw/tmtcservices/CommandingServiceBase.h" +#include "fsfw/tmtcservices/PusServiceBase.h" +#include "fsfw_hal/common/gpio/GpioCookie.h" +#include "fsfw_hal/devicehandlers/GyroL3GD20Handler.h" +#include "fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h" +#include "fsfw_hal/devicehandlers/MgmRM3100Handler.h" +#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" +#include "fsfw_hal/linux/i2c/I2cComIF.h" +#include "fsfw_hal/linux/i2c/I2cCookie.h" +#include "fsfw_hal/linux/spi/SpiComIF.h" +#include "fsfw_hal/linux/spi/SpiCookie.h" +#include "fsfw_hal/linux/uart/UartComIF.h" +#include "fsfw_hal/linux/uart/UartCookie.h" +#include "linux/boardtest/SpiTestClass.h" #include "linux/csp/CspComIF.h" - -#include "mission/devices/HeaterHandler.h" +#include "linux/csp/CspCookie.h" +#include "linux/devices/SolarArrayDeploymentHandler.h" +#include "linux/devices/SusHandler.h" +#include "linux/devices/devicedefinitions/SusDefinitions.h" #include "mission/core/GenericFactory.h" +#include "mission/devices/ACUHandler.h" +#include "mission/devices/GPSHyperionHandler.h" +#include "mission/devices/GyroADIS1650XHandler.h" +#include "mission/devices/HeaterHandler.h" +#include "mission/devices/IMTQHandler.h" +#include "mission/devices/Max31865PT1000Handler.h" +#include "mission/devices/P60DockHandler.h" +#include "mission/devices/PCDUHandler.h" #include "mission/devices/PDU1Handler.h" #include "mission/devices/PDU2Handler.h" -#include "mission/devices/ACUHandler.h" -#include "mission/devices/PCDUHandler.h" -#include "mission/devices/P60DockHandler.h" -#include "mission/devices/Tmp1075Handler.h" -#include "mission/devices/Max31865PT1000Handler.h" -#include "mission/devices/GyroADIS1650XHandler.h" -#include "mission/devices/IMTQHandler.h" -#include "mission/devices/SyrlinksHkHandler.h" #include "mission/devices/PlocMPSoCHandler.h" #include "mission/devices/RadiationSensorHandler.h" #include "mission/devices/RwHandler.h" +#include "mission/devices/SyrlinksHkHandler.h" +#include "mission/devices/Tmp1075Handler.h" #include "mission/devices/devicedefinitions/GomspaceDefinitions.h" -#include "mission/devices/devicedefinitions/SyrlinksDefinitions.h" +#include "mission/devices/devicedefinitions/Max31865Definitions.h" #include "mission/devices/devicedefinitions/PlocMPSoCDefinitions.h" #include "mission/devices/devicedefinitions/RadSensorDefinitions.h" -#include "mission/devices/devicedefinitions/Max31865Definitions.h" #include "mission/devices/devicedefinitions/RwDefinitions.h" - -#include "mission/devices/GPSHyperionHandler.h" +#include "mission/devices/devicedefinitions/SyrlinksDefinitions.h" #include "mission/tmtc/CCSDSHandler.h" #include "mission/tmtc/VirtualChannel.h" #include "mission/utility/TmFunnel.h" - -#include "fsfw_hal/linux/uart/UartComIF.h" -#include "fsfw_hal/linux/uart/UartCookie.h" -#include "fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h" -#include "fsfw_hal/devicehandlers/GyroL3GD20Handler.h" -#include "fsfw_hal/devicehandlers/MgmRM3100Handler.h" -#include "fsfw_hal/linux/i2c/I2cCookie.h" -#include "fsfw_hal/linux/i2c/I2cComIF.h" -#include "fsfw_hal/linux/spi/SpiCookie.h" -#include "fsfw_hal/linux/spi/SpiComIF.h" -#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" -#include "fsfw_hal/common/gpio/GpioCookie.h" - -#include "fsfw/datapoollocal/LocalDataPoolManager.h" -#include "fsfw/tmtcservices/CommandingServiceBase.h" -#include "fsfw/tmtcservices/PusServiceBase.h" -#include "fsfw/tmtcpacket/pus/tm.h" - -#include "linux/boardtest/SpiTestClass.h" +#include "tmtc/apid.h" +#include "tmtc/pusIds.h" #if OBSW_TEST_LIBGPIOD == 1 #include "linux/boardtest/LibgpiodTest.h" #endif -#include -#include #include +#include +#include #include #include #include @@ -89,1015 +84,1015 @@ ResetArgs resetArgsGnss0; ResetArgs resetArgsGnss1; -void ObjectFactory::setStatics() { - Factory::setStaticFrameworkObjectIds(); -} +void ObjectFactory::setStatics() { Factory::setStaticFrameworkObjectIds(); } void Factory::setStaticFrameworkObjectIds() { - PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; - PusServiceBase::packetDestination = objects::TM_FUNNEL; + PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; + PusServiceBase::packetDestination = objects::TM_FUNNEL; - CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; - CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; + CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; + CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; - //DeviceHandlerBase::powerSwitcherId = objects::PCDU_HANDLER; - DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT; + // DeviceHandlerBase::powerSwitcherId = objects::PCDU_HANDLER; + DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT; #if OBSW_TM_TO_PTME == 1 - TmFunnel::downlinkDestination = objects::CCSDS_HANDLER; + TmFunnel::downlinkDestination = objects::CCSDS_HANDLER; #else - TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; + TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; #endif /* OBSW_TM_TO_PTME == 1 */ - // No storage object for now. - TmFunnel::storageDestination = objects::NO_OBJECT; + // No storage object for now. + TmFunnel::storageDestination = objects::NO_OBJECT; - LocalDataPoolManager::defaultHkDestination = objects::PUS_SERVICE_3_HOUSEKEEPING; + LocalDataPoolManager::defaultHkDestination = objects::PUS_SERVICE_3_HOUSEKEEPING; - VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; - TmPacketBase::timeStamperId = objects::TIME_STAMPER; + VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; + TmPacketBase::timeStamperId = objects::TIME_STAMPER; } void ObjectFactory::produce(void* args) { - ObjectFactory::setStatics(); - ObjectFactory::produceGenericObjects(); + ObjectFactory::setStatics(); + ObjectFactory::produceGenericObjects(); - LinuxLibgpioIF* gpioComIF = nullptr; - UartComIF* uartComIF = nullptr; - SpiComIF* spiComIF = nullptr; - createCommunicationInterfaces(&gpioComIF, &uartComIF, &spiComIF); - createTmpComponents(); + LinuxLibgpioIF* gpioComIF = nullptr; + UartComIF* uartComIF = nullptr; + SpiComIF* spiComIF = nullptr; + createCommunicationInterfaces(&gpioComIF, &uartComIF, &spiComIF); + createTmpComponents(); #if BOARD_TE0720 == 0 - new CoreController(objects::CORE_CONTROLLER); + new CoreController(objects::CORE_CONTROLLER); - createPcduComponents(); - createRadSensorComponent(gpioComIF); - createSunSensorComponents(gpioComIF, spiComIF); + createPcduComponents(); + createRadSensorComponent(gpioComIF); + createSunSensorComponents(gpioComIF, spiComIF); #if OBSW_ADD_ACS_BOARD == 1 - createAcsBoardComponents(gpioComIF, uartComIF); + createAcsBoardComponents(gpioComIF, uartComIF); #endif /* OBSW_ADD_ACS_BOARD == 1 */ - createHeaterComponents(); - createSolarArrayDeploymentComponents(); + createHeaterComponents(); + createSolarArrayDeploymentComponents(); #if OBSW_ADD_SYRLINKS == 1 - createSyrlinksComponents(); + createSyrlinksComponents(); #endif /* OBSW_ADD_SYRLINKS == 1 */ #if OBSW_ADD_RTD_DEVICES == 1 - createRtdComponents(gpioComIF); + createRtdComponents(gpioComIF); #endif /* OBSW_ADD_RTD_DEVICES == 1 */ - I2cCookie* imtqI2cCookie = new I2cCookie(addresses::IMTQ, IMTQ::MAX_REPLY_SIZE, - q7s::I2C_DEFAULT_DEV); - new IMTQHandler(objects::IMTQ_HANDLER, objects::I2C_COM_IF, imtqI2cCookie); - createReactionWheelComponents(gpioComIF); + I2cCookie* imtqI2cCookie = + new I2cCookie(addresses::IMTQ, IMTQ::MAX_REPLY_SIZE, q7s::I2C_DEFAULT_DEV); + new IMTQHandler(objects::IMTQ_HANDLER, objects::I2C_COM_IF, imtqI2cCookie); + createReactionWheelComponents(gpioComIF); #if OBSW_ADD_PLOC_MPSOC == 1 - UartCookie* plocMpsocCookie = new UartCookie(objects::PLOC_MPSOC_HANDLER, - q7s::UART_PLOC_MPSOC_DEV, UartModes::NON_CANONICAL, uart::PLOC_MPSOC_BAUD, - PLOC_MPSOC::MAX_REPLY_SIZE); - new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, plocMpsocCookie); + UartCookie* plocMpsocCookie = + new UartCookie(objects::PLOC_MPSOC_HANDLER, q7s::UART_PLOC_MPSOC_DEV, + UartModes::NON_CANONICAL, uart::PLOC_MPSOC_BAUD, PLOC_MPSOC::MAX_REPLY_SIZE); + new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, plocMpsocCookie); #endif /* OBSW_ADD_PLOC_MPSOC == 1 */ #if OBSW_ADD_PLOC_SUPERVISOR == 1 - UartCookie* plocSupervisorCookie = new UartCookie(objects::PLOC_SUPERVISOR_HANDLER, - q7s::UART_PLOC_SUPERVSIOR_DEV, UartModes::NON_CANONICAL, uart::PLOC_SUPERVISOR_BAUD, - PLOC_SPV::MAX_PACKET_SIZE * 20); - plocSupervisorCookie->setNoFixedSizeReply(); - PlocSupervisorHandler* plocSupervisor = new PlocSupervisorHandler( - objects::PLOC_SUPERVISOR_HANDLER, objects::UART_COM_IF, plocSupervisorCookie); - plocSupervisor->setStartUpImmediately(); + UartCookie* plocSupervisorCookie = new UartCookie( + objects::PLOC_SUPERVISOR_HANDLER, q7s::UART_PLOC_SUPERVSIOR_DEV, UartModes::NON_CANONICAL, + uart::PLOC_SUPERVISOR_BAUD, PLOC_SPV::MAX_PACKET_SIZE * 20); + plocSupervisorCookie->setNoFixedSizeReply(); + PlocSupervisorHandler* plocSupervisor = new PlocSupervisorHandler( + objects::PLOC_SUPERVISOR_HANDLER, objects::UART_COM_IF, plocSupervisorCookie); + plocSupervisor->setStartUpImmediately(); #endif /* OBSW_ADD_PLOC_SUPERVISOR == 1 */ - new FileSystemHandler(objects::FILE_SYSTEM_HANDLER); + new FileSystemHandler(objects::FILE_SYSTEM_HANDLER); #if OBSW_ADD_STAR_TRACKER == 1 - UartCookie* starTrackerCookie = new UartCookie(objects::STAR_TRACKER, - q7s::UART_STAR_TRACKER_DEV, UartModes::NON_CANONICAL, uart::STAR_TRACKER_BAUD, - StarTracker::MAX_FRAME_SIZE* 2 + 2); - starTrackerCookie->setNoFixedSizeReply(); - StrHelper* strHelper = new StrHelper(objects::STR_HELPER); - StarTrackerHandler* starTrackerHandler = new StarTrackerHandler(objects::STAR_TRACKER, - objects::UART_COM_IF, starTrackerCookie, strHelper); - starTrackerHandler->setStartUpImmediately(); + UartCookie* starTrackerCookie = + new UartCookie(objects::STAR_TRACKER, q7s::UART_STAR_TRACKER_DEV, UartModes::NON_CANONICAL, + uart::STAR_TRACKER_BAUD, StarTracker::MAX_FRAME_SIZE * 2 + 2); + starTrackerCookie->setNoFixedSizeReply(); + StrHelper* strHelper = new StrHelper(objects::STR_HELPER); + StarTrackerHandler* starTrackerHandler = new StarTrackerHandler( + objects::STAR_TRACKER, objects::UART_COM_IF, starTrackerCookie, strHelper); + starTrackerHandler->setStartUpImmediately(); #endif /* OBSW_ADD_STAR_TRACKER == 1 */ #endif /* TE7020 == 0 */ #if OBSW_USE_CCSDS_IP_CORE == 1 - createCcsdsComponents(gpioComIF); + createCcsdsComponents(gpioComIF); #endif /* OBSW_USE_CCSDS_IP_CORE == 1 */ - /* Test Task */ + /* Test Task */ #if OBSW_ADD_TEST_CODE == 1 - createTestComponents(gpioComIF); + createTestComponents(gpioComIF); #endif /* OBSW_ADD_TEST_CODE == 1 */ - new PlocUpdater(objects::PLOC_UPDATER); - new PlocMemoryDumper(objects::PLOC_MEMORY_DUMPER); + new PlocUpdater(objects::PLOC_UPDATER); + new PlocMemoryDumper(objects::PLOC_MEMORY_DUMPER); } void ObjectFactory::createTmpComponents() { #if BOARD_TE0720 == 1 - I2cCookie* i2cCookieTmp1075tcs1 = new I2cCookie(addresses::TMP1075_TCS_1, - TMP1075::MAX_REPLY_LENGTH, std::string("/dev/i2c-0")); - I2cCookie* i2cCookieTmp1075tcs2 = new I2cCookie(addresses::TMP1075_TCS_2, - TMP1075::MAX_REPLY_LENGTH, std::string("/dev/i2c-0")); + I2cCookie* i2cCookieTmp1075tcs1 = + new I2cCookie(addresses::TMP1075_TCS_1, TMP1075::MAX_REPLY_LENGTH, std::string("/dev/i2c-0")); + I2cCookie* i2cCookieTmp1075tcs2 = + new I2cCookie(addresses::TMP1075_TCS_2, TMP1075::MAX_REPLY_LENGTH, std::string("/dev/i2c-0")); #else - I2cCookie* i2cCookieTmp1075tcs1 = new I2cCookie(addresses::TMP1075_TCS_1, - TMP1075::MAX_REPLY_LENGTH, q7s::I2C_DEFAULT_DEV); - I2cCookie* i2cCookieTmp1075tcs2 = new I2cCookie(addresses::TMP1075_TCS_2, - TMP1075::MAX_REPLY_LENGTH, q7s::I2C_DEFAULT_DEV); + I2cCookie* i2cCookieTmp1075tcs1 = + new I2cCookie(addresses::TMP1075_TCS_1, TMP1075::MAX_REPLY_LENGTH, q7s::I2C_DEFAULT_DEV); + I2cCookie* i2cCookieTmp1075tcs2 = + new I2cCookie(addresses::TMP1075_TCS_2, TMP1075::MAX_REPLY_LENGTH, q7s::I2C_DEFAULT_DEV); #endif - /* Temperature sensors */ - Tmp1075Handler* tmp1075Handler_1 = new Tmp1075Handler(objects::TMP1075_HANDLER_1, - objects::I2C_COM_IF, i2cCookieTmp1075tcs1); - (void) tmp1075Handler_1; - Tmp1075Handler* tmp1075Handler_2 = new Tmp1075Handler(objects::TMP1075_HANDLER_2, - objects::I2C_COM_IF, i2cCookieTmp1075tcs2); - (void) tmp1075Handler_2; + /* Temperature sensors */ + Tmp1075Handler* tmp1075Handler_1 = + new Tmp1075Handler(objects::TMP1075_HANDLER_1, objects::I2C_COM_IF, i2cCookieTmp1075tcs1); + (void)tmp1075Handler_1; + Tmp1075Handler* tmp1075Handler_2 = + new Tmp1075Handler(objects::TMP1075_HANDLER_2, objects::I2C_COM_IF, i2cCookieTmp1075tcs2); + (void)tmp1075Handler_2; } -void ObjectFactory::createCommunicationInterfaces(LinuxLibgpioIF **gpioComIF, UartComIF** uartComIF, - SpiComIF** spiComIF) { - if (gpioComIF == nullptr or uartComIF == nullptr or spiComIF == nullptr) { - sif::error << "ObjectFactory::createCommunicationInterfaces: Invalid passed ComIF pointer" - << std::endl; - } - *gpioComIF = new LinuxLibgpioIF(objects::GPIO_IF); +void ObjectFactory::createCommunicationInterfaces(LinuxLibgpioIF** gpioComIF, UartComIF** uartComIF, + SpiComIF** spiComIF) { + if (gpioComIF == nullptr or uartComIF == nullptr or spiComIF == nullptr) { + sif::error << "ObjectFactory::createCommunicationInterfaces: Invalid passed ComIF pointer" + << std::endl; + } + *gpioComIF = new LinuxLibgpioIF(objects::GPIO_IF); - /* Communication interfaces */ - new CspComIF(objects::CSP_COM_IF); - new I2cComIF(objects::I2C_COM_IF); - *uartComIF = new UartComIF(objects::UART_COM_IF); + /* Communication interfaces */ + new CspComIF(objects::CSP_COM_IF); + new I2cComIF(objects::I2C_COM_IF); + *uartComIF = new UartComIF(objects::UART_COM_IF); #if OBSW_ADD_SPI_TEST_CODE == 0 - *spiComIF = new SpiComIF(objects::SPI_COM_IF, *gpioComIF); + *spiComIF = new SpiComIF(objects::SPI_COM_IF, *gpioComIF); #endif /* Q7S_ADD_SPI_TEST_CODE == 0 */ #if BOARD_TE0720 == 0 - /* Adding gpios for chip select decoding to the gpioComIf */ - gpioCallbacks::initSpiCsDecoder(*gpioComIF); + /* Adding gpios for chip select decoding to the gpioComIf */ + gpioCallbacks::initSpiCsDecoder(*gpioComIF); #endif } void ObjectFactory::createPcduComponents() { - 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); - CspCookie* acuCspCookie = new CspCookie(ACU::MAX_REPLY_LENGTH, addresses::ACU); - /* Device Handler */ - P60DockHandler* p60dockhandler = new P60DockHandler(objects::P60DOCK_HANDLER, - objects::CSP_COM_IF, p60DockCspCookie); - PDU1Handler* pdu1handler = new PDU1Handler(objects::PDU1_HANDLER, objects::CSP_COM_IF, - pdu1CspCookie); - PDU2Handler* pdu2handler = new PDU2Handler(objects::PDU2_HANDLER, objects::CSP_COM_IF, - pdu2CspCookie); - ACUHandler* acuhandler = new ACUHandler(objects::ACU_HANDLER, objects::CSP_COM_IF, - acuCspCookie); - new PCDUHandler(objects::PCDU_HANDLER, 50); + 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); + CspCookie* acuCspCookie = new CspCookie(ACU::MAX_REPLY_LENGTH, addresses::ACU); + /* Device Handler */ + P60DockHandler* p60dockhandler = + new P60DockHandler(objects::P60DOCK_HANDLER, objects::CSP_COM_IF, p60DockCspCookie); + PDU1Handler* pdu1handler = + new PDU1Handler(objects::PDU1_HANDLER, objects::CSP_COM_IF, pdu1CspCookie); + PDU2Handler* pdu2handler = + new PDU2Handler(objects::PDU2_HANDLER, objects::CSP_COM_IF, pdu2CspCookie); + ACUHandler* acuhandler = new ACUHandler(objects::ACU_HANDLER, objects::CSP_COM_IF, acuCspCookie); + new PCDUHandler(objects::PCDU_HANDLER, 50); - /** - * Setting PCDU devices to mode normal immediately after start up because PCDU is always - * running. - */ - p60dockhandler->setModeNormal(); - pdu1handler->setModeNormal(); - pdu2handler->setModeNormal(); - acuhandler->setModeNormal(); + /** + * Setting PCDU devices to mode normal immediately after start up because PCDU is always + * running. + */ + p60dockhandler->setModeNormal(); + pdu1handler->setModeNormal(); + pdu2handler->setModeNormal(); + acuhandler->setModeNormal(); } void ObjectFactory::createRadSensorComponent(LinuxLibgpioIF* gpioComIF) { - GpioCookie* gpioCookieRadSensor = new GpioCookie; - std::stringstream consumer; - consumer << "0x" << std::hex << objects::RAD_SENSOR; - GpiodRegularByLineName* gpio = new GpiodRegularByLineName( - q7s::gpioNames::RAD_SENSOR_CHIP_SELECT, consumer.str(), gpio::DIR_OUT, gpio::HIGH); - gpioCookieRadSensor->addGpio(gpioIds::CS_RAD_SENSOR, gpio); - gpioComIF->addGpios(gpioCookieRadSensor); + GpioCookie* gpioCookieRadSensor = new GpioCookie; + std::stringstream consumer; + consumer << "0x" << std::hex << objects::RAD_SENSOR; + GpiodRegularByLineName* gpio = new GpiodRegularByLineName( + q7s::gpioNames::RAD_SENSOR_CHIP_SELECT, consumer.str(), gpio::DIR_OUT, gpio::HIGH); + gpioCookieRadSensor->addGpio(gpioIds::CS_RAD_SENSOR, gpio); + gpioComIF->addGpios(gpioCookieRadSensor); - SpiCookie* spiCookieRadSensor = new SpiCookie(addresses::RAD_SENSOR, gpioIds::CS_RAD_SENSOR, - std::string(q7s::SPI_DEFAULT_DEV), RAD_SENSOR::READ_SIZE, spi::DEFAULT_MAX_1227_MODE, - spi::DEFAULT_MAX_1227_SPEED); - new RadiationSensorHandler(objects::RAD_SENSOR, objects::SPI_COM_IF, spiCookieRadSensor); + SpiCookie* spiCookieRadSensor = new SpiCookie( + addresses::RAD_SENSOR, gpioIds::CS_RAD_SENSOR, std::string(q7s::SPI_DEFAULT_DEV), + RAD_SENSOR::READ_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED); + new RadiationSensorHandler(objects::RAD_SENSOR, objects::SPI_COM_IF, spiCookieRadSensor); } -void ObjectFactory::createSunSensorComponents(LinuxLibgpioIF *gpioComIF, SpiComIF* spiComIF) { - GpioCookie* gpioCookieSus = new GpioCookie(); - GpioCallback* susgpio = nullptr; +void ObjectFactory::createSunSensorComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* spiComIF) { + GpioCookie* gpioCookieSus = new GpioCookie(); + GpioCallback* susgpio = nullptr; - susgpio = new GpioCallback("Chip select SUS 1", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_1, susgpio); - susgpio = new GpioCallback("Chip select SUS 2", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_2, susgpio); - susgpio = new GpioCallback("Chip select SUS 3", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_3, susgpio); - susgpio = new GpioCallback("Chip select SUS 4", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_4, susgpio); - susgpio = new GpioCallback("Chip select SUS 5", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_5, susgpio); - susgpio = new GpioCallback("Chip select SUS 6", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_6, susgpio); - susgpio = new GpioCallback("Chip select SUS 7", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_7, susgpio); - susgpio = new GpioCallback("Chip select SUS 8", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_8, susgpio); - susgpio = new GpioCallback("Chip select SUS 9", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_9, susgpio); - susgpio = new GpioCallback("Chip select SUS 10", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_10, susgpio); - susgpio = new GpioCallback("Chip select SUS 11", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_11, susgpio); - susgpio = new GpioCallback("Chip select SUS 12", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_12, susgpio); - susgpio = new GpioCallback("Chip select SUS 13", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_13, susgpio); + susgpio = new GpioCallback("Chip select SUS 1", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_1, susgpio); + susgpio = new GpioCallback("Chip select SUS 2", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_2, susgpio); + susgpio = new GpioCallback("Chip select SUS 3", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_3, susgpio); + susgpio = new GpioCallback("Chip select SUS 4", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_4, susgpio); + susgpio = new GpioCallback("Chip select SUS 5", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_5, susgpio); + susgpio = new GpioCallback("Chip select SUS 6", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_6, susgpio); + susgpio = new GpioCallback("Chip select SUS 7", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_7, susgpio); + susgpio = new GpioCallback("Chip select SUS 8", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_8, susgpio); + susgpio = new GpioCallback("Chip select SUS 9", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_9, susgpio); + susgpio = new GpioCallback("Chip select SUS 10", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_10, susgpio); + susgpio = new GpioCallback("Chip select SUS 11", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_11, susgpio); + susgpio = new GpioCallback("Chip select SUS 12", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_12, susgpio); + susgpio = new GpioCallback("Chip select SUS 13", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_13, susgpio); - gpioComIF->addGpios(gpioCookieSus); + gpioComIF->addGpios(gpioCookieSus); - SpiCookie* spiCookieSus1 = new SpiCookie(addresses::SUS_1, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus2 = new SpiCookie(addresses::SUS_2, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus3 = new SpiCookie(addresses::SUS_3, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus4 = new SpiCookie(addresses::SUS_4, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus5 = new SpiCookie(addresses::SUS_5, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus6 = new SpiCookie(addresses::SUS_6, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus7 = new SpiCookie(addresses::SUS_7, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus8 = new SpiCookie(addresses::SUS_8, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus9 = new SpiCookie(addresses::SUS_9, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus10 = new SpiCookie(addresses::SUS_10, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus11 = new SpiCookie(addresses::SUS_11, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus12 = new SpiCookie(addresses::SUS_12, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus13 = new SpiCookie(addresses::SUS_13, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus1 = + new SpiCookie(addresses::SUS_1, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus2 = + new SpiCookie(addresses::SUS_2, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus3 = + new SpiCookie(addresses::SUS_3, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus4 = + new SpiCookie(addresses::SUS_4, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus5 = + new SpiCookie(addresses::SUS_5, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus6 = + new SpiCookie(addresses::SUS_6, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus7 = + new SpiCookie(addresses::SUS_7, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus8 = + new SpiCookie(addresses::SUS_8, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus9 = + new SpiCookie(addresses::SUS_9, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus10 = + new SpiCookie(addresses::SUS_10, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus11 = + new SpiCookie(addresses::SUS_11, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus12 = + new SpiCookie(addresses::SUS_12, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus13 = + new SpiCookie(addresses::SUS_13, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); - new SusHandler(objects::SUS_1, objects::SPI_COM_IF, spiCookieSus1, gpioComIF, - gpioIds::CS_SUS_1); - new SusHandler(objects::SUS_2, objects::SPI_COM_IF, spiCookieSus2, gpioComIF, - gpioIds::CS_SUS_2); - new SusHandler(objects::SUS_3, objects::SPI_COM_IF, spiCookieSus3, gpioComIF, - gpioIds::CS_SUS_3); - new SusHandler(objects::SUS_4, objects::SPI_COM_IF, spiCookieSus4, gpioComIF, - gpioIds::CS_SUS_4); - new SusHandler(objects::SUS_5, objects::SPI_COM_IF, spiCookieSus5, gpioComIF, - gpioIds::CS_SUS_5); - new SusHandler(objects::SUS_6, objects::SPI_COM_IF, spiCookieSus6, gpioComIF, - gpioIds::CS_SUS_6); - new SusHandler(objects::SUS_7, objects::SPI_COM_IF, spiCookieSus7, gpioComIF, - gpioIds::CS_SUS_7); - new SusHandler(objects::SUS_8, objects::SPI_COM_IF, spiCookieSus8, gpioComIF, - gpioIds::CS_SUS_8); - new SusHandler(objects::SUS_9, objects::SPI_COM_IF, spiCookieSus9, gpioComIF, - gpioIds::CS_SUS_9); - new SusHandler(objects::SUS_10, objects::SPI_COM_IF, spiCookieSus10, gpioComIF, - gpioIds::CS_SUS_10); - new SusHandler(objects::SUS_11, objects::SPI_COM_IF, spiCookieSus11, gpioComIF, - gpioIds::CS_SUS_11); - new SusHandler(objects::SUS_12, objects::SPI_COM_IF, spiCookieSus12, gpioComIF, - gpioIds::CS_SUS_12); - new SusHandler(objects::SUS_13, objects::SPI_COM_IF, spiCookieSus13, gpioComIF, - gpioIds::CS_SUS_13); + new SusHandler(objects::SUS_1, objects::SPI_COM_IF, spiCookieSus1, gpioComIF, gpioIds::CS_SUS_1); + new SusHandler(objects::SUS_2, objects::SPI_COM_IF, spiCookieSus2, gpioComIF, gpioIds::CS_SUS_2); + new SusHandler(objects::SUS_3, objects::SPI_COM_IF, spiCookieSus3, gpioComIF, gpioIds::CS_SUS_3); + new SusHandler(objects::SUS_4, objects::SPI_COM_IF, spiCookieSus4, gpioComIF, gpioIds::CS_SUS_4); + new SusHandler(objects::SUS_5, objects::SPI_COM_IF, spiCookieSus5, gpioComIF, gpioIds::CS_SUS_5); + new SusHandler(objects::SUS_6, objects::SPI_COM_IF, spiCookieSus6, gpioComIF, gpioIds::CS_SUS_6); + new SusHandler(objects::SUS_7, objects::SPI_COM_IF, spiCookieSus7, gpioComIF, gpioIds::CS_SUS_7); + new SusHandler(objects::SUS_8, objects::SPI_COM_IF, spiCookieSus8, gpioComIF, gpioIds::CS_SUS_8); + new SusHandler(objects::SUS_9, objects::SPI_COM_IF, spiCookieSus9, gpioComIF, gpioIds::CS_SUS_9); + new SusHandler(objects::SUS_10, objects::SPI_COM_IF, spiCookieSus10, gpioComIF, + gpioIds::CS_SUS_10); + new SusHandler(objects::SUS_11, objects::SPI_COM_IF, spiCookieSus11, gpioComIF, + gpioIds::CS_SUS_11); + new SusHandler(objects::SUS_12, objects::SPI_COM_IF, spiCookieSus12, gpioComIF, + gpioIds::CS_SUS_12); + new SusHandler(objects::SUS_13, objects::SPI_COM_IF, spiCookieSus13, gpioComIF, + gpioIds::CS_SUS_13); } -void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComIF* uartComIF) { - GpioCookie* gpioCookieAcsBoard = new GpioCookie(); +void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComIF* uartComIF) { + GpioCookie* gpioCookieAcsBoard = new GpioCookie(); - std::stringstream consumer; - GpiodRegularByLineName* gpio = nullptr; - consumer << "0x" << std::hex << objects::GYRO_0_ADIS_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ADIS_CS, consumer.str(), - gpio::DIR_OUT, gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); + std::stringstream consumer; + GpiodRegularByLineName* gpio = nullptr; + consumer << "0x" << std::hex << objects::GYRO_0_ADIS_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ADIS_CS, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GYRO_1_L3G_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_1_L3G_CS, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GYRO_1_L3G_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_1_L3G_CS, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GYRO_2_ADIS_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ADIS_CS, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::GYRO_2_ADIS_CS, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GYRO_2_ADIS_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ADIS_CS, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::GYRO_2_ADIS_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GYRO_3_L3G_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_3_L3G_CS, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GYRO_3_L3G_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_3_L3G_CS, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::MGM_0_LIS3_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_0_CS, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::MGM_0_LIS3_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_0_CS, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::MGM_1_RM3100_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::MGM_1_RM3100_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::MGM_2_LIS3_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_2_CS, consumer.str(), - gpio::DIR_OUT, gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::MGM_2_LIS3_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_2_CS, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::MGM_3_RM3100_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_3_CS, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::MGM_3_RM3100_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_3_CS, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GPS_CONTROLLER; - // GNSS reset pins are active low - gpio = new GpiodRegularByLineName(q7s::gpioNames::RESET_GNSS_0, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::GNSS_0_NRESET, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GPS_CONTROLLER; + // GNSS reset pins are active low + gpio = new GpiodRegularByLineName(q7s::gpioNames::RESET_GNSS_0, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::GNSS_0_NRESET, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GPS_CONTROLLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::RESET_GNSS_1, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::GNSS_1_NRESET, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GPS_CONTROLLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::RESET_GNSS_1, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::GNSS_1_NRESET, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GYRO_0_ADIS_HANDLER; - // Enable pins must be pulled low for regular operations - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, consumer.str(), - gpio::DIR_OUT, gpio::LOW); - gpioCookieAcsBoard->addGpio(gpioIds::GYRO_0_ENABLE, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GYRO_0_ADIS_HANDLER; + // Enable pins must be pulled low for regular operations + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + gpioCookieAcsBoard->addGpio(gpioIds::GYRO_0_ENABLE, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GYRO_2_ADIS_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ENABLE, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - gpioCookieAcsBoard->addGpio(gpioIds::GYRO_2_ENABLE, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GYRO_2_ADIS_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ENABLE, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + gpioCookieAcsBoard->addGpio(gpioIds::GYRO_2_ENABLE, gpio); - // Enable pins for GNSS - consumer.str(""); - consumer << "0x" << std::hex << objects::GPS_CONTROLLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::GNSS_0_ENABLE, consumer.str(), - gpio::DIR_OUT, gpio::LOW); - gpioCookieAcsBoard->addGpio(gpioIds::GNSS_0_ENABLE, gpio); + // Enable pins for GNSS + consumer.str(""); + consumer << "0x" << std::hex << objects::GPS_CONTROLLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GNSS_0_ENABLE, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + gpioCookieAcsBoard->addGpio(gpioIds::GNSS_0_ENABLE, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GPS_CONTROLLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::GNSS_1_ENABLE, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - gpioCookieAcsBoard->addGpio(gpioIds::GNSS_1_ENABLE, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GPS_CONTROLLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GNSS_1_ENABLE, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + gpioCookieAcsBoard->addGpio(gpioIds::GNSS_1_ENABLE, gpio); - gpioComIF->addGpios(gpioCookieAcsBoard); + gpioComIF->addGpios(gpioCookieAcsBoard); - std::string spiDev = q7s::SPI_DEFAULT_DEV; - SpiCookie* spiCookie = new SpiCookie(addresses::MGM_0_LIS3, gpioIds::MGM_0_LIS3_CS, spiDev, - MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); - auto mgmLis3Handler = new MgmLIS3MDLHandler(objects::MGM_0_LIS3_HANDLER, objects::SPI_COM_IF, - spiCookie, spi::LIS3_TRANSITION_DELAY); - mgmLis3Handler->setStartUpImmediately(); + std::string spiDev = q7s::SPI_DEFAULT_DEV; + SpiCookie* spiCookie = + new SpiCookie(addresses::MGM_0_LIS3, gpioIds::MGM_0_LIS3_CS, spiDev, + MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); + auto mgmLis3Handler = new MgmLIS3MDLHandler(objects::MGM_0_LIS3_HANDLER, objects::SPI_COM_IF, + spiCookie, spi::LIS3_TRANSITION_DELAY); + mgmLis3Handler->setStartUpImmediately(); #if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1 - mgmLis3Handler->setToGoToNormalMode(true); + mgmLis3Handler->setToGoToNormalMode(true); #endif - spiCookie = new SpiCookie(addresses::MGM_1_RM3100, gpioIds::MGM_1_RM3100_CS, spiDev, - RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); - auto mgmRm3100Handler = new MgmRM3100Handler(objects::MGM_1_RM3100_HANDLER, objects::SPI_COM_IF, - spiCookie, spi::RM3100_TRANSITION_DELAY); - mgmRm3100Handler->setStartUpImmediately(); + spiCookie = + new SpiCookie(addresses::MGM_1_RM3100, gpioIds::MGM_1_RM3100_CS, spiDev, + RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); + auto mgmRm3100Handler = new MgmRM3100Handler(objects::MGM_1_RM3100_HANDLER, objects::SPI_COM_IF, + spiCookie, spi::RM3100_TRANSITION_DELAY); + mgmRm3100Handler->setStartUpImmediately(); #if FSFW_HAL_RM3100_MGM_DEBUG == 1 - mgmRm3100Handler->setToGoToNormalMode(true); + mgmRm3100Handler->setToGoToNormalMode(true); #endif - spiCookie = new SpiCookie(addresses::MGM_2_LIS3, gpioIds::MGM_2_LIS3_CS, spiDev, - MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); - auto mgmLis3Handler2 = new MgmLIS3MDLHandler(objects::MGM_2_LIS3_HANDLER, objects::SPI_COM_IF, - spiCookie, spi::LIS3_TRANSITION_DELAY); - mgmLis3Handler2->setStartUpImmediately(); + spiCookie = + new SpiCookie(addresses::MGM_2_LIS3, gpioIds::MGM_2_LIS3_CS, spiDev, + MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); + auto mgmLis3Handler2 = new MgmLIS3MDLHandler(objects::MGM_2_LIS3_HANDLER, objects::SPI_COM_IF, + spiCookie, spi::LIS3_TRANSITION_DELAY); + mgmLis3Handler2->setStartUpImmediately(); #if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1 - mgmLis3Handler2->setToGoToNormalMode(true); + mgmLis3Handler2->setToGoToNormalMode(true); #endif - spiCookie = new SpiCookie(addresses::MGM_3_RM3100, gpioIds::MGM_3_RM3100_CS, spiDev, - RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); - mgmRm3100Handler = new MgmRM3100Handler(objects::MGM_3_RM3100_HANDLER, objects::SPI_COM_IF, - spiCookie, spi::RM3100_TRANSITION_DELAY); - mgmRm3100Handler->setStartUpImmediately(); + spiCookie = + new SpiCookie(addresses::MGM_3_RM3100, gpioIds::MGM_3_RM3100_CS, spiDev, + RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); + mgmRm3100Handler = new MgmRM3100Handler(objects::MGM_3_RM3100_HANDLER, objects::SPI_COM_IF, + spiCookie, spi::RM3100_TRANSITION_DELAY); + mgmRm3100Handler->setStartUpImmediately(); #if FSFW_HAL_RM3100_MGM_DEBUG == 1 - mgmRm3100Handler->setToGoToNormalMode(true); + mgmRm3100Handler->setToGoToNormalMode(true); #endif - // Commented until ACS board V2 in in clean room again - // Gyro 0 Side A - spiCookie = new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, spiDev, - ADIS1650X::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, - spi::DEFAULT_ADIS16507_SPEED); - auto adisHandler = new GyroADIS1650XHandler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, - spiCookie, ADIS1650X::Type::ADIS16505); - adisHandler->setStartUpImmediately(); - // Gyro 1 Side A - spiCookie = new SpiCookie(addresses::GYRO_1_L3G, gpioIds::GYRO_1_L3G_CS, spiDev, - L3GD20H::MAX_BUFFER_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); - auto gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_1_L3G_HANDLER, objects::SPI_COM_IF, - spiCookie, spi::L3G_TRANSITION_DELAY); - gyroL3gHandler->setStartUpImmediately(); + // Commented until ACS board V2 in in clean room again + // Gyro 0 Side A + spiCookie = new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, spiDev, + ADIS1650X::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, + spi::DEFAULT_ADIS16507_SPEED); + auto adisHandler = new GyroADIS1650XHandler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, + spiCookie, ADIS1650X::Type::ADIS16505); + adisHandler->setStartUpImmediately(); + // Gyro 1 Side A + spiCookie = + new SpiCookie(addresses::GYRO_1_L3G, gpioIds::GYRO_1_L3G_CS, spiDev, L3GD20H::MAX_BUFFER_SIZE, + spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); + auto gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_1_L3G_HANDLER, objects::SPI_COM_IF, + spiCookie, spi::L3G_TRANSITION_DELAY); + gyroL3gHandler->setStartUpImmediately(); #if FSFW_HAL_L3GD20_GYRO_DEBUG == 1 - gyroL3gHandler->setToGoToNormalMode(true); + gyroL3gHandler->setToGoToNormalMode(true); #endif - // Gyro 2 Side B - spiCookie = new SpiCookie(addresses::GYRO_2_ADIS, gpioIds::GYRO_2_ADIS_CS, spiDev, - ADIS1650X::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, - spi::DEFAULT_ADIS16507_SPEED); - adisHandler = new GyroADIS1650XHandler(objects::GYRO_2_ADIS_HANDLER, objects::SPI_COM_IF, - spiCookie, ADIS1650X::Type::ADIS16505); - adisHandler->setStartUpImmediately(); - // Gyro 3 Side B - spiCookie = new SpiCookie(addresses::GYRO_3_L3G, gpioIds::GYRO_3_L3G_CS, spiDev, - L3GD20H::MAX_BUFFER_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); - gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_3_L3G_HANDLER, objects::SPI_COM_IF, - spiCookie, spi::L3G_TRANSITION_DELAY); - gyroL3gHandler->setStartUpImmediately(); + // Gyro 2 Side B + spiCookie = new SpiCookie(addresses::GYRO_2_ADIS, gpioIds::GYRO_2_ADIS_CS, spiDev, + ADIS1650X::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, + spi::DEFAULT_ADIS16507_SPEED); + adisHandler = new GyroADIS1650XHandler(objects::GYRO_2_ADIS_HANDLER, objects::SPI_COM_IF, + spiCookie, ADIS1650X::Type::ADIS16505); + adisHandler->setStartUpImmediately(); + // Gyro 3 Side B + spiCookie = + new SpiCookie(addresses::GYRO_3_L3G, gpioIds::GYRO_3_L3G_CS, spiDev, L3GD20H::MAX_BUFFER_SIZE, + spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); + gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_3_L3G_HANDLER, objects::SPI_COM_IF, + spiCookie, spi::L3G_TRANSITION_DELAY); + gyroL3gHandler->setStartUpImmediately(); #if FSFW_HAL_L3GD20_GYRO_DEBUG == 1 - gyroL3gHandler->setToGoToNormalMode(true); + gyroL3gHandler->setToGoToNormalMode(true); #endif - bool debugGps = false; + bool debugGps = false; #if OBSW_DEBUG_GPS == 1 - debugGps = true; + debugGps = true; #endif - resetArgsGnss1.gnss1 = true; - resetArgsGnss1.gpioComIF = gpioComIF; - resetArgsGnss1.waitPeriodMs = 100; - resetArgsGnss0.gnss1 = false; - resetArgsGnss0.gpioComIF = gpioComIF; - resetArgsGnss0.waitPeriodMs = 100; - auto gpsHandler0 = new GPSHyperionHandler(objects::GPS_CONTROLLER, objects::NO_OBJECT, - debugGps); - gpsHandler0->setResetPinTriggerFunction(gps::triggerGpioResetPin, &resetArgsGnss0); + resetArgsGnss1.gnss1 = true; + resetArgsGnss1.gpioComIF = gpioComIF; + resetArgsGnss1.waitPeriodMs = 100; + resetArgsGnss0.gnss1 = false; + resetArgsGnss0.gpioComIF = gpioComIF; + resetArgsGnss0.waitPeriodMs = 100; + auto gpsHandler0 = new GPSHyperionHandler(objects::GPS_CONTROLLER, objects::NO_OBJECT, debugGps); + gpsHandler0->setResetPinTriggerFunction(gps::triggerGpioResetPin, &resetArgsGnss0); } void ObjectFactory::createHeaterComponents() { + GpioCookie* heaterGpiosCookie = new GpioCookie; + GpiodRegularByLineName* gpio = nullptr; - GpioCookie* heaterGpiosCookie = new GpioCookie; - GpiodRegularByLineName* gpio = nullptr; + std::stringstream consumer; + consumer << "0x" << std::hex << objects::HEATER_HANDLER; + /* Pin H2-11 on stack connector */ + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_0, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_0, gpio); + /* Pin H2-12 on stack connector */ + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_1, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_1, gpio); - std::stringstream consumer; - consumer << "0x" << std::hex << objects::HEATER_HANDLER; - /* Pin H2-11 on stack connector */ - gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_0, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_0, gpio); - /* Pin H2-12 on stack connector */ - gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_1, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_1, gpio); + /* Pin H2-13 on stack connector */ + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_2, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_2, gpio); - /* Pin H2-13 on stack connector */ - gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_2, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_2, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_3, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_3, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_3, consumer.str(), - gpio::DIR_OUT, gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_3, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_4, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_4, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_4, consumer.str(), - gpio::DIR_OUT, gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_4, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_5, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_5, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_5, consumer.str(), - gpio::DIR_OUT, gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_5, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_6, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_6, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_6, consumer.str(), - gpio::DIR_OUT, gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_6, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_7, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_7, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_7, consumer.str(), - gpio::DIR_OUT, gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_7, gpio); - - new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, heaterGpiosCookie, - objects::PCDU_HANDLER, pcduSwitches::TCS_BOARD_8V_HEATER_IN); + new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, heaterGpiosCookie, + objects::PCDU_HANDLER, pcduSwitches::TCS_BOARD_8V_HEATER_IN); } void ObjectFactory::createSolarArrayDeploymentComponents() { - GpioCookie* solarArrayDeplCookie = new GpioCookie; - GpiodRegularByLineName* gpio = nullptr; + GpioCookie* solarArrayDeplCookie = new GpioCookie; + GpiodRegularByLineName* gpio = nullptr; - std::stringstream consumer; - consumer << "0x" << std::hex << objects::SOLAR_ARRAY_DEPL_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::SA_DPL_PIN_0, - consumer.str(), gpio::DIR_OUT, gpio::LOW); - solarArrayDeplCookie->addGpio(gpioIds::DEPLSA1, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::SA_DPL_PIN_1, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - solarArrayDeplCookie->addGpio(gpioIds::DEPLSA2, gpio); + std::stringstream consumer; + consumer << "0x" << std::hex << objects::SOLAR_ARRAY_DEPL_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::SA_DPL_PIN_0, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + solarArrayDeplCookie->addGpio(gpioIds::DEPLSA1, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::SA_DPL_PIN_1, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + solarArrayDeplCookie->addGpio(gpioIds::DEPLSA2, gpio); - //TODO: Find out burn time. For now set to 1000 ms. - new SolarArrayDeploymentHandler(objects::SOLAR_ARRAY_DEPL_HANDLER, objects::GPIO_IF, - solarArrayDeplCookie, objects::PCDU_HANDLER, pcduSwitches::DEPLOYMENT_MECHANISM, - gpioIds::DEPLSA1, gpioIds::DEPLSA2, 1000); + // TODO: Find out burn time. For now set to 1000 ms. + new SolarArrayDeploymentHandler(objects::SOLAR_ARRAY_DEPL_HANDLER, objects::GPIO_IF, + solarArrayDeplCookie, objects::PCDU_HANDLER, + pcduSwitches::DEPLOYMENT_MECHANISM, gpioIds::DEPLSA1, + gpioIds::DEPLSA2, 1000); } void ObjectFactory::createSyrlinksComponents() { - UartCookie* syrlinksUartCookie = new UartCookie(objects::SYRLINKS_HK_HANDLER, - q7s::UART_SYRLINKS_DEV, UartModes::NON_CANONICAL, uart::SYRLINKS_BAUD, - SYRLINKS::MAX_REPLY_SIZE); - syrlinksUartCookie->setParityEven(); + UartCookie* syrlinksUartCookie = + new UartCookie(objects::SYRLINKS_HK_HANDLER, q7s::UART_SYRLINKS_DEV, UartModes::NON_CANONICAL, + uart::SYRLINKS_BAUD, SYRLINKS::MAX_REPLY_SIZE); + syrlinksUartCookie->setParityEven(); - new SyrlinksHkHandler(objects::SYRLINKS_HK_HANDLER, objects::UART_COM_IF, syrlinksUartCookie); + new SyrlinksHkHandler(objects::SYRLINKS_HK_HANDLER, objects::UART_COM_IF, syrlinksUartCookie); } -void ObjectFactory::createRtdComponents(LinuxLibgpioIF *gpioComIF) { - GpioCookie* rtdGpioCookie = new GpioCookie; +void ObjectFactory::createRtdComponents(LinuxLibgpioIF* gpioComIF) { + GpioCookie* rtdGpioCookie = new GpioCookie; - GpioCallback* gpioRtdIc0 = new GpioCallback("Chip select RTD IC0", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_3, gpioRtdIc0); - GpioCallback* gpioRtdIc1 = new GpioCallback("Chip select RTD IC1", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_4, gpioRtdIc1); - GpioCallback* gpioRtdIc2 = new GpioCallback("Chip select RTD IC2", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_5, gpioRtdIc2); - GpioCallback* gpioRtdIc3 = new GpioCallback("Chip select RTD IC3", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_6, gpioRtdIc3); - GpioCallback* gpioRtdIc4 = new GpioCallback("Chip select RTD IC4", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_7, gpioRtdIc4); - GpioCallback* gpioRtdIc5 = new GpioCallback("Chip select RTD IC5", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_8, gpioRtdIc5); - GpioCallback* gpioRtdIc6 = new GpioCallback("Chip select RTD IC6", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_9, gpioRtdIc6); - GpioCallback* gpioRtdIc7 = new GpioCallback("Chip select RTD IC7", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_10, gpioRtdIc7); - GpioCallback* gpioRtdIc8 = new GpioCallback("Chip select RTD IC8", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_11, gpioRtdIc8); - GpioCallback* gpioRtdIc9 = new GpioCallback("Chip select RTD IC9", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_12, gpioRtdIc9); - GpioCallback* gpioRtdIc10 = new GpioCallback("Chip select RTD IC10", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_13, gpioRtdIc10); - GpioCallback* gpioRtdIc11 = new GpioCallback("Chip select RTD IC11", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_14, gpioRtdIc11); - GpioCallback* gpioRtdIc12 = new GpioCallback("Chip select RTD IC12", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_15, gpioRtdIc12); - GpioCallback* gpioRtdIc13 = new GpioCallback("Chip select RTD IC13", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_16, gpioRtdIc13); - GpioCallback* gpioRtdIc14 = new GpioCallback("Chip select RTD IC14", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_17, gpioRtdIc14); - GpioCallback* gpioRtdIc15 = new GpioCallback("Chip select RTD IC15", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_18, gpioRtdIc15); + GpioCallback* gpioRtdIc0 = new GpioCallback("Chip select RTD IC0", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_3, gpioRtdIc0); + GpioCallback* gpioRtdIc1 = new GpioCallback("Chip select RTD IC1", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_4, gpioRtdIc1); + GpioCallback* gpioRtdIc2 = new GpioCallback("Chip select RTD IC2", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_5, gpioRtdIc2); + GpioCallback* gpioRtdIc3 = new GpioCallback("Chip select RTD IC3", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_6, gpioRtdIc3); + GpioCallback* gpioRtdIc4 = new GpioCallback("Chip select RTD IC4", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_7, gpioRtdIc4); + GpioCallback* gpioRtdIc5 = new GpioCallback("Chip select RTD IC5", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_8, gpioRtdIc5); + GpioCallback* gpioRtdIc6 = new GpioCallback("Chip select RTD IC6", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_9, gpioRtdIc6); + GpioCallback* gpioRtdIc7 = new GpioCallback("Chip select RTD IC7", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_10, gpioRtdIc7); + GpioCallback* gpioRtdIc8 = new GpioCallback("Chip select RTD IC8", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_11, gpioRtdIc8); + GpioCallback* gpioRtdIc9 = new GpioCallback("Chip select RTD IC9", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_12, gpioRtdIc9); + GpioCallback* gpioRtdIc10 = new GpioCallback("Chip select RTD IC10", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_13, gpioRtdIc10); + GpioCallback* gpioRtdIc11 = new GpioCallback("Chip select RTD IC11", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_14, gpioRtdIc11); + GpioCallback* gpioRtdIc12 = new GpioCallback("Chip select RTD IC12", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_15, gpioRtdIc12); + GpioCallback* gpioRtdIc13 = new GpioCallback("Chip select RTD IC13", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_16, gpioRtdIc13); + GpioCallback* gpioRtdIc14 = new GpioCallback("Chip select RTD IC14", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_17, gpioRtdIc14); + GpioCallback* gpioRtdIc15 = new GpioCallback("Chip select RTD IC15", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_18, gpioRtdIc15); - gpioComIF->addGpios(rtdGpioCookie); + gpioComIF->addGpios(rtdGpioCookie); - SpiCookie* spiRtdIc0 = new SpiCookie(addresses::RTD_IC_3, gpioIds::RTD_IC_3, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); - SpiCookie* spiRtdIc1 = new SpiCookie(addresses::RTD_IC_4, gpioIds::RTD_IC_4, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); - SpiCookie* spiRtdIc2 = new SpiCookie(addresses::RTD_IC_5, gpioIds::RTD_IC_5, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); - SpiCookie* spiRtdIc3 = new SpiCookie(addresses::RTD_IC_6, gpioIds::RTD_IC_6, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); - SpiCookie* spiRtdIc4 = new SpiCookie(addresses::RTD_IC_7, gpioIds::RTD_IC_7, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); - SpiCookie* spiRtdIc5 = new SpiCookie(addresses::RTD_IC_8, gpioIds::RTD_IC_8, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); - SpiCookie* spiRtdIc6 = new SpiCookie(addresses::RTD_IC_9, gpioIds::RTD_IC_9, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); - SpiCookie* spiRtdIc7 = new SpiCookie(addresses::RTD_IC_10, gpioIds::RTD_IC_10, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, - spi::RTD_SPEED); - SpiCookie* spiRtdIc8 = new SpiCookie(addresses::RTD_IC_11, gpioIds::RTD_IC_11, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, - spi::RTD_SPEED); - SpiCookie* spiRtdIc9 = new SpiCookie(addresses::RTD_IC_12, gpioIds::RTD_IC_12, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, - spi::RTD_SPEED); - SpiCookie* spiRtdIc10 = new SpiCookie(addresses::RTD_IC_13, gpioIds::RTD_IC_13, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, - spi::RTD_SPEED); - SpiCookie* spiRtdIc11 = new SpiCookie(addresses::RTD_IC_14, gpioIds::RTD_IC_14, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, - spi::RTD_SPEED); - SpiCookie* spiRtdIc12 = new SpiCookie(addresses::RTD_IC_15, gpioIds::RTD_IC_15, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, - spi::RTD_SPEED); - SpiCookie* spiRtdIc13 = new SpiCookie(addresses::RTD_IC_16, gpioIds::RTD_IC_16, - std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, - spi::RTD_MODE, spi::RTD_SPEED); - SpiCookie* spiRtdIc14 = new SpiCookie(addresses::RTD_IC_17, gpioIds::RTD_IC_17, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, - spi::RTD_SPEED); - SpiCookie* spiRtdIc15 = new SpiCookie(addresses::RTD_IC_18, gpioIds::RTD_IC_18, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, - spi::RTD_SPEED); + SpiCookie* spiRtdIc0 = + new SpiCookie(addresses::RTD_IC_3, gpioIds::RTD_IC_3, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc1 = + new SpiCookie(addresses::RTD_IC_4, gpioIds::RTD_IC_4, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc2 = + new SpiCookie(addresses::RTD_IC_5, gpioIds::RTD_IC_5, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc3 = + new SpiCookie(addresses::RTD_IC_6, gpioIds::RTD_IC_6, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc4 = + new SpiCookie(addresses::RTD_IC_7, gpioIds::RTD_IC_7, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc5 = + new SpiCookie(addresses::RTD_IC_8, gpioIds::RTD_IC_8, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc6 = + new SpiCookie(addresses::RTD_IC_9, gpioIds::RTD_IC_9, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc7 = + new SpiCookie(addresses::RTD_IC_10, gpioIds::RTD_IC_10, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc8 = + new SpiCookie(addresses::RTD_IC_11, gpioIds::RTD_IC_11, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc9 = + new SpiCookie(addresses::RTD_IC_12, gpioIds::RTD_IC_12, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc10 = + new SpiCookie(addresses::RTD_IC_13, gpioIds::RTD_IC_13, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc11 = + new SpiCookie(addresses::RTD_IC_14, gpioIds::RTD_IC_14, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc12 = + new SpiCookie(addresses::RTD_IC_15, gpioIds::RTD_IC_15, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc13 = + new SpiCookie(addresses::RTD_IC_16, gpioIds::RTD_IC_16, std::string(q7s::SPI_DEFAULT_DEV), + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc14 = + new SpiCookie(addresses::RTD_IC_17, gpioIds::RTD_IC_17, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc15 = + new SpiCookie(addresses::RTD_IC_18, gpioIds::RTD_IC_18, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); - Max31865PT1000Handler* rtdIc0 = new Max31865PT1000Handler(objects::RTD_IC_3, objects::SPI_COM_IF, - spiRtdIc0); - Max31865PT1000Handler* rtdIc1 = new Max31865PT1000Handler(objects::RTD_IC_4, objects::SPI_COM_IF, - spiRtdIc1); - Max31865PT1000Handler* rtdIc2 = new Max31865PT1000Handler(objects::RTD_IC_5, objects::SPI_COM_IF, - spiRtdIc2); - Max31865PT1000Handler* rtdIc3 = new Max31865PT1000Handler(objects::RTD_IC_6, objects::SPI_COM_IF, - spiRtdIc3); - Max31865PT1000Handler* rtdIc4 = new Max31865PT1000Handler(objects::RTD_IC_7, objects::SPI_COM_IF, - spiRtdIc4); - Max31865PT1000Handler* rtdIc5 = new Max31865PT1000Handler(objects::RTD_IC_8, objects::SPI_COM_IF, - spiRtdIc5); - Max31865PT1000Handler* rtdIc6 = new Max31865PT1000Handler(objects::RTD_IC_9, objects::SPI_COM_IF, - spiRtdIc6); - Max31865PT1000Handler* rtdIc7 = new Max31865PT1000Handler(objects::RTD_IC_10, - objects::SPI_COM_IF, spiRtdIc7); - Max31865PT1000Handler* rtdIc8 = new Max31865PT1000Handler(objects::RTD_IC_11, - objects::SPI_COM_IF, spiRtdIc8); - Max31865PT1000Handler* rtdIc9 = new Max31865PT1000Handler(objects::RTD_IC_12, - objects::SPI_COM_IF, spiRtdIc9); - Max31865PT1000Handler* rtdIc10 = new Max31865PT1000Handler(objects::RTD_IC_13, - objects::SPI_COM_IF, spiRtdIc10); - Max31865PT1000Handler* rtdIc11 = new Max31865PT1000Handler(objects::RTD_IC_14, - objects::SPI_COM_IF, spiRtdIc11); - Max31865PT1000Handler* rtdIc12 = new Max31865PT1000Handler(objects::RTD_IC_15, - objects::SPI_COM_IF, spiRtdIc12); - Max31865PT1000Handler* rtdIc13 = new Max31865PT1000Handler(objects::RTD_IC_16, - objects::SPI_COM_IF, spiRtdIc13); - Max31865PT1000Handler* rtdIc14 = new Max31865PT1000Handler(objects::RTD_IC_17, - objects::SPI_COM_IF, spiRtdIc14); - Max31865PT1000Handler* rtdIc15 = new Max31865PT1000Handler(objects::RTD_IC_18, - objects::SPI_COM_IF, spiRtdIc15); + Max31865PT1000Handler* rtdIc0 = + new Max31865PT1000Handler(objects::RTD_IC_3, objects::SPI_COM_IF, spiRtdIc0); + Max31865PT1000Handler* rtdIc1 = + new Max31865PT1000Handler(objects::RTD_IC_4, objects::SPI_COM_IF, spiRtdIc1); + Max31865PT1000Handler* rtdIc2 = + new Max31865PT1000Handler(objects::RTD_IC_5, objects::SPI_COM_IF, spiRtdIc2); + Max31865PT1000Handler* rtdIc3 = + new Max31865PT1000Handler(objects::RTD_IC_6, objects::SPI_COM_IF, spiRtdIc3); + Max31865PT1000Handler* rtdIc4 = + new Max31865PT1000Handler(objects::RTD_IC_7, objects::SPI_COM_IF, spiRtdIc4); + Max31865PT1000Handler* rtdIc5 = + new Max31865PT1000Handler(objects::RTD_IC_8, objects::SPI_COM_IF, spiRtdIc5); + Max31865PT1000Handler* rtdIc6 = + new Max31865PT1000Handler(objects::RTD_IC_9, objects::SPI_COM_IF, spiRtdIc6); + Max31865PT1000Handler* rtdIc7 = + new Max31865PT1000Handler(objects::RTD_IC_10, objects::SPI_COM_IF, spiRtdIc7); + Max31865PT1000Handler* rtdIc8 = + new Max31865PT1000Handler(objects::RTD_IC_11, objects::SPI_COM_IF, spiRtdIc8); + Max31865PT1000Handler* rtdIc9 = + new Max31865PT1000Handler(objects::RTD_IC_12, objects::SPI_COM_IF, spiRtdIc9); + Max31865PT1000Handler* rtdIc10 = + new Max31865PT1000Handler(objects::RTD_IC_13, objects::SPI_COM_IF, spiRtdIc10); + Max31865PT1000Handler* rtdIc11 = + new Max31865PT1000Handler(objects::RTD_IC_14, objects::SPI_COM_IF, spiRtdIc11); + Max31865PT1000Handler* rtdIc12 = + new Max31865PT1000Handler(objects::RTD_IC_15, objects::SPI_COM_IF, spiRtdIc12); + Max31865PT1000Handler* rtdIc13 = + new Max31865PT1000Handler(objects::RTD_IC_16, objects::SPI_COM_IF, spiRtdIc13); + Max31865PT1000Handler* rtdIc14 = + new Max31865PT1000Handler(objects::RTD_IC_17, objects::SPI_COM_IF, spiRtdIc14); + Max31865PT1000Handler* rtdIc15 = + new Max31865PT1000Handler(objects::RTD_IC_18, objects::SPI_COM_IF, spiRtdIc15); - rtdIc0->setStartUpImmediately(); - rtdIc1->setStartUpImmediately(); - rtdIc2->setStartUpImmediately(); + rtdIc0->setStartUpImmediately(); + rtdIc1->setStartUpImmediately(); + rtdIc2->setStartUpImmediately(); #if OBSW_DEBUG_RTD == 1 - rtdIc0->setInstantNormal(true); - rtdIc1->setInstantNormal(true); - rtdIc2->setInstantNormal(true); + rtdIc0->setInstantNormal(true); + rtdIc1->setInstantNormal(true); + rtdIc2->setInstantNormal(true); #endif - static_cast(rtdIc0); - static_cast(rtdIc1); - static_cast(rtdIc2); - static_cast(rtdIc3); - static_cast(rtdIc4); - static_cast(rtdIc5); - static_cast(rtdIc6); - static_cast(rtdIc7); - static_cast(rtdIc8); - static_cast(rtdIc9); - static_cast(rtdIc10); - static_cast(rtdIc11); - static_cast(rtdIc12); - static_cast(rtdIc13); - static_cast(rtdIc14); - static_cast(rtdIc15); + static_cast(rtdIc0); + static_cast(rtdIc1); + static_cast(rtdIc2); + static_cast(rtdIc3); + static_cast(rtdIc4); + static_cast(rtdIc5); + static_cast(rtdIc6); + static_cast(rtdIc7); + static_cast(rtdIc8); + static_cast(rtdIc9); + static_cast(rtdIc10); + static_cast(rtdIc11); + static_cast(rtdIc12); + static_cast(rtdIc13); + static_cast(rtdIc14); + static_cast(rtdIc15); } void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF) { - GpioCookie* gpioCookieRw = new GpioCookie; - GpioCallback* csRw1 = new GpioCallback("Chip select reaction wheel 1", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieRw->addGpio(gpioIds::CS_RW1, csRw1); - GpioCallback* csRw2 = new GpioCallback("Chip select reaction wheel 2", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieRw->addGpio(gpioIds::CS_RW2, csRw2); - GpioCallback* csRw3 = new GpioCallback("Chip select reaction wheel 3", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieRw->addGpio(gpioIds::CS_RW3, csRw3); - GpioCallback* csRw4 = new GpioCallback("Chip select reaction wheel 4", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieRw->addGpio(gpioIds::CS_RW4, csRw4); + GpioCookie* gpioCookieRw = new GpioCookie; + GpioCallback* csRw1 = new GpioCallback("Chip select reaction wheel 1", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieRw->addGpio(gpioIds::CS_RW1, csRw1); + GpioCallback* csRw2 = new GpioCallback("Chip select reaction wheel 2", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieRw->addGpio(gpioIds::CS_RW2, csRw2); + GpioCallback* csRw3 = new GpioCallback("Chip select reaction wheel 3", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieRw->addGpio(gpioIds::CS_RW3, csRw3); + GpioCallback* csRw4 = new GpioCallback("Chip select reaction wheel 4", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieRw->addGpio(gpioIds::CS_RW4, csRw4); - std::stringstream consumer; - GpiodRegularByLineName* gpio = nullptr; - consumer << "0x" << std::hex << objects::RW1; - gpio = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_1, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - gpioCookieRw->addGpio(gpioIds::EN_RW1, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::RW2; - gpio = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_2, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - gpioCookieRw->addGpio(gpioIds::EN_RW2, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::RW3; - gpio = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_3, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - gpioCookieRw->addGpio(gpioIds::EN_RW3, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::RW4; - gpio = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_4, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - gpioCookieRw->addGpio(gpioIds::EN_RW4, gpio); + std::stringstream consumer; + GpiodRegularByLineName* gpio = nullptr; + consumer << "0x" << std::hex << objects::RW1; + gpio = + new GpiodRegularByLineName(q7s::gpioNames::EN_RW_1, consumer.str(), gpio::DIR_OUT, gpio::LOW); + gpioCookieRw->addGpio(gpioIds::EN_RW1, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::RW2; + gpio = + new GpiodRegularByLineName(q7s::gpioNames::EN_RW_2, consumer.str(), gpio::DIR_OUT, gpio::LOW); + gpioCookieRw->addGpio(gpioIds::EN_RW2, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::RW3; + gpio = + new GpiodRegularByLineName(q7s::gpioNames::EN_RW_3, consumer.str(), gpio::DIR_OUT, gpio::LOW); + gpioCookieRw->addGpio(gpioIds::EN_RW3, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::RW4; + gpio = + new GpiodRegularByLineName(q7s::gpioNames::EN_RW_4, consumer.str(), gpio::DIR_OUT, gpio::LOW); + gpioCookieRw->addGpio(gpioIds::EN_RW4, gpio); - gpioComIF->addGpios(gpioCookieRw); + gpioComIF->addGpios(gpioCookieRw); - auto rw1SpiCookie = new SpiCookie(addresses::RW1, gpioIds::CS_RW1, q7s::SPI_RW_DEV, - RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, - nullptr); - auto rw2SpiCookie = new SpiCookie(addresses::RW2, gpioIds::CS_RW2, q7s::SPI_RW_DEV, - RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, - nullptr); - auto rw3SpiCookie = new SpiCookie(addresses::RW3, gpioIds::CS_RW3, q7s::SPI_RW_DEV, - RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, - nullptr); - auto rw4SpiCookie = new SpiCookie(addresses::RW4, gpioIds::CS_RW4, q7s::SPI_RW_DEV, - RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, - nullptr); + auto rw1SpiCookie = + new SpiCookie(addresses::RW1, gpioIds::CS_RW1, q7s::SPI_RW_DEV, RwDefinitions::MAX_REPLY_SIZE, + spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, nullptr); + auto rw2SpiCookie = + new SpiCookie(addresses::RW2, gpioIds::CS_RW2, q7s::SPI_RW_DEV, RwDefinitions::MAX_REPLY_SIZE, + spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, nullptr); + auto rw3SpiCookie = + new SpiCookie(addresses::RW3, gpioIds::CS_RW3, q7s::SPI_RW_DEV, RwDefinitions::MAX_REPLY_SIZE, + spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, nullptr); + auto rw4SpiCookie = + new SpiCookie(addresses::RW4, gpioIds::CS_RW4, q7s::SPI_RW_DEV, RwDefinitions::MAX_REPLY_SIZE, + spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, nullptr); - auto rwHandler1 = new RwHandler(objects::RW1, objects::SPI_COM_IF, rw1SpiCookie, gpioComIF, - gpioIds::EN_RW1); + auto rwHandler1 = + new RwHandler(objects::RW1, objects::SPI_COM_IF, rw1SpiCookie, gpioComIF, gpioIds::EN_RW1); #if OBSW_DEBUG_RW == 1 - rwHandler1->setStartUpImmediately(); + rwHandler1->setStartUpImmediately(); #endif - rw1SpiCookie->setCallbackArgs(rwHandler1); + rw1SpiCookie->setCallbackArgs(rwHandler1); - auto rwHandler2 = new RwHandler(objects::RW2, objects::SPI_COM_IF, rw2SpiCookie, gpioComIF, - gpioIds::EN_RW2); + auto rwHandler2 = + new RwHandler(objects::RW2, objects::SPI_COM_IF, rw2SpiCookie, gpioComIF, gpioIds::EN_RW2); #if OBSW_DEBUG_RW == 1 - rwHandler2->setStartUpImmediately(); + rwHandler2->setStartUpImmediately(); #endif - rw2SpiCookie->setCallbackArgs(rwHandler2); + rw2SpiCookie->setCallbackArgs(rwHandler2); - auto rwHandler3 = new RwHandler(objects::RW3, objects::SPI_COM_IF, rw3SpiCookie, gpioComIF, - gpioIds::EN_RW3); + auto rwHandler3 = + new RwHandler(objects::RW3, objects::SPI_COM_IF, rw3SpiCookie, gpioComIF, gpioIds::EN_RW3); #if OBSW_DEBUG_RW == 1 - rwHandler3->setStartUpImmediately(); + rwHandler3->setStartUpImmediately(); #endif - rw3SpiCookie->setCallbackArgs(rwHandler3); + rw3SpiCookie->setCallbackArgs(rwHandler3); - auto rwHandler4 = new RwHandler(objects::RW4, objects::SPI_COM_IF, rw4SpiCookie, gpioComIF, - gpioIds::EN_RW4); + auto rwHandler4 = + new RwHandler(objects::RW4, objects::SPI_COM_IF, rw4SpiCookie, gpioComIF, gpioIds::EN_RW4); #if OBSW_DEBUG_RW == 1 - rwHandler4->setStartUpImmediately(); + rwHandler4->setStartUpImmediately(); #endif - rw4SpiCookie->setCallbackArgs(rwHandler4); + rw4SpiCookie->setCallbackArgs(rwHandler4); } -void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF *gpioComIF) { - // GPIO definitions of signals connected to the virtual channel interfaces of the PTME IP Core - GpioCookie* gpioCookiePtmeIp = new GpioCookie; - GpiodRegularByLineName* gpio = nullptr; - std::stringstream consumer; - consumer << "0x" << std::hex << objects::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; - 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; - 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()); - gpioCookiePtmeIp->addGpio(gpioIds::VC1_PAPB_EMPTY, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::PAPB_VC2; - 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; - 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; - 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; - gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_EMPTY_SIGNAL_VC3, consumer.str()); - gpioCookiePtmeIp->addGpio(gpioIds::VC3_PAPB_EMPTY, gpio); +void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF* gpioComIF) { + // GPIO definitions of signals connected to the virtual channel interfaces of the PTME IP Core + GpioCookie* gpioCookiePtmeIp = new GpioCookie; + GpiodRegularByLineName* gpio = nullptr; + std::stringstream consumer; + consumer << "0x" << std::hex << objects::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; + 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; + 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()); + gpioCookiePtmeIp->addGpio(gpioIds::VC1_PAPB_EMPTY, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::PAPB_VC2; + 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; + 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; + 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; + gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_EMPTY_SIGNAL_VC3, consumer.str()); + gpioCookiePtmeIp->addGpio(gpioIds::VC3_PAPB_EMPTY, gpio); - gpioComIF->addGpios(gpioCookiePtmeIp); + 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); + // 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); - // Creating ptme object and adding virtual channel interfaces - Ptme* ptme = new Ptme(objects::PTME); - ptme->addVcInterface(ccsds::VC0, vc0); - ptme->addVcInterface(ccsds::VC1, vc1); - ptme->addVcInterface(ccsds::VC2, vc2); - ptme->addVcInterface(ccsds::VC3, vc3); + // Creating ptme object and adding virtual channel interfaces + Ptme* ptme = new Ptme(objects::PTME); + ptme->addVcInterface(ccsds::VC0, vc0); + ptme->addVcInterface(ccsds::VC1, vc1); + 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); + 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); + TxRateSetterIF* txRateSetterIF = new PtmeRateSetter(gpioIds::BIT_RATE_SEL, gpioComIF); - 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); + 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); - VirtualChannel* vc = nullptr; - vc = new VirtualChannel(ccsds::VC0, common::VC0_QUEUE_SIZE); - ccsdsHandler->addVirtualChannel(ccsds::VC0, vc); - vc = new VirtualChannel(ccsds::VC1, common::VC1_QUEUE_SIZE); - ccsdsHandler->addVirtualChannel(ccsds::VC1, vc); - vc = new VirtualChannel(ccsds::VC2, common::VC2_QUEUE_SIZE); - ccsdsHandler->addVirtualChannel(ccsds::VC2, vc); - vc = new VirtualChannel(ccsds::VC3, common::VC3_QUEUE_SIZE); - ccsdsHandler->addVirtualChannel(ccsds::VC3, vc); + VirtualChannel* vc = nullptr; + vc = new VirtualChannel(ccsds::VC0, common::VC0_QUEUE_SIZE); + ccsdsHandler->addVirtualChannel(ccsds::VC0, vc); + vc = new VirtualChannel(ccsds::VC1, common::VC1_QUEUE_SIZE); + ccsdsHandler->addVirtualChannel(ccsds::VC1, vc); + vc = new VirtualChannel(ccsds::VC2, common::VC2_QUEUE_SIZE); + ccsdsHandler->addVirtualChannel(ccsds::VC2, vc); + vc = new VirtualChannel(ccsds::VC3, common::VC3_QUEUE_SIZE); + ccsdsHandler->addVirtualChannel(ccsds::VC3, vc); - GpioCookie* gpioCookiePdec = new GpioCookie; - consumer.str(""); - consumer << "0x" << std::hex << objects::PDEC_HANDLER; - // GPIO also low after linux boot (specified by device-tree) - gpio = new GpiodRegularByLineName(q7s::gpioNames::PDEC_RESET, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - gpioCookiePdec->addGpio(gpioIds::PDEC_RESET, gpio); + GpioCookie* gpioCookiePdec = new GpioCookie; + consumer.str(""); + consumer << "0x" << std::hex << objects::PDEC_HANDLER; + // GPIO also low after linux boot (specified by device-tree) + gpio = new GpiodRegularByLineName(q7s::gpioNames::PDEC_RESET, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + gpioCookiePdec->addGpio(gpioIds::PDEC_RESET, gpio); - gpioComIF->addGpios(gpioCookiePdec); + 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)); + 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)); #if BOARD_TE0720 == 0 - GpioCookie* gpioRS485Chip = new GpioCookie; - gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_TX_CLOCK, "RS485 Transceiver", - gpio::Direction::DIR_OUT, gpio::LOW); - gpioRS485Chip->addGpio(gpioIds::RS485_EN_TX_CLOCK, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_TX_DATA, "RS485 Transceiver", - gpio::Direction::DIR_OUT, gpio::LOW); - gpioRS485Chip->addGpio(gpioIds::RS485_EN_TX_DATA, gpio); + GpioCookie* gpioRS485Chip = new GpioCookie; + gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_TX_CLOCK, "RS485 Transceiver", + gpio::Direction::DIR_OUT, gpio::LOW); + gpioRS485Chip->addGpio(gpioIds::RS485_EN_TX_CLOCK, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_TX_DATA, "RS485 Transceiver", + gpio::Direction::DIR_OUT, gpio::LOW); + gpioRS485Chip->addGpio(gpioIds::RS485_EN_TX_DATA, gpio); - // Default configuration enables RX channels (RXEN = LOW) - gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_RX_CLOCK, "RS485 Transceiver", - gpio::Direction::DIR_OUT, gpio::LOW); - gpioRS485Chip->addGpio(gpioIds::RS485_EN_RX_CLOCK, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_RX_DATA, "RS485 Transceiver", - gpio::Direction::DIR_OUT, gpio::LOW); - gpioRS485Chip->addGpio(gpioIds::RS485_EN_RX_DATA, gpio); + // Default configuration enables RX channels (RXEN = LOW) + gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_RX_CLOCK, "RS485 Transceiver", + gpio::Direction::DIR_OUT, gpio::LOW); + gpioRS485Chip->addGpio(gpioIds::RS485_EN_RX_CLOCK, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_RX_DATA, "RS485 Transceiver", + gpio::Direction::DIR_OUT, gpio::LOW); + gpioRS485Chip->addGpio(gpioIds::RS485_EN_RX_DATA, gpio); - gpioComIF->addGpios(gpioRS485Chip); + gpioComIF->addGpios(gpioRS485Chip); #endif /* BOARD_TE0720 == 0 */ } void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) { - #if BOARD_TE0720 == 0 - new Q7STestTask(objects::TEST_TASK); + new Q7STestTask(objects::TEST_TASK); #endif #if BOARD_TE0720 == 1 && OBSW_TEST_LIBGPIOD == 1 #if OBSW_TEST_GPIO_OPEN_BYLABEL == 1 - /* Configure MIO0 as input */ - GpiodRegular* testGpio = new GpiodRegular("MIO0", gpio::DIR_OUT, 0, "/amba_pl/gpio@41200000", 0); + /* Configure MIO0 as input */ + GpiodRegular* testGpio = new GpiodRegular("MIO0", gpio::DIR_OUT, 0, "/amba_pl/gpio@41200000", 0); #elif OBSW_TEST_GPIO_OPEN_BY_LINE_NAME - GpiodRegularByLineName* testGpio = new GpiodRegularByLineName("test-name", "gpio-test", - gpio::DIR_OUT, 0); + GpiodRegularByLineName* testGpio = + new GpiodRegularByLineName("test-name", "gpio-test", gpio::DIR_OUT, 0); #else - /* Configure MIO0 as input */ - GpiodRegular* testGpio = new GpiodRegular("gpiochip0", 0, "MIO0", gpio::IN, 0); + /* Configure MIO0 as input */ + GpiodRegular* testGpio = new GpiodRegular("gpiochip0", 0, "MIO0", gpio::IN, 0); #endif /* OBSW_TEST_GPIO_LABEL == 1 */ - GpioCookie* gpioCookie = new GpioCookie; - gpioCookie->addGpio(gpioIds::TEST_ID_0, testGpio); - new LibgpiodTest(objects::LIBGPIOD_TEST, objects::GPIO_IF, gpioCookie); + GpioCookie* gpioCookie = new GpioCookie; + gpioCookie->addGpio(gpioIds::TEST_ID_0, testGpio); + new LibgpiodTest(objects::LIBGPIOD_TEST, objects::GPIO_IF, gpioCookie); #endif #if BOARD_TE0720 == 1 && OBSW_TEST_SUS_HANDLER == 1 - GpioCookie* gpioCookieSus = new GpioCookie; - GpiodRegular* chipSelectSus = new GpiodRegular(std::string("gpiochip1"), 9, - std::string("Chip Select Sus Sensor"), gpio::DIR_OUT, 1); - gpioCookieSus->addGpio(gpioIds::CS_SUS_1, chipSelectSus); - gpioComIF->addGpios(gpioCookieSus); + GpioCookie* gpioCookieSus = new GpioCookie; + GpiodRegular* chipSelectSus = new GpiodRegular( + std::string("gpiochip1"), 9, std::string("Chip Select Sus Sensor"), gpio::DIR_OUT, 1); + gpioCookieSus->addGpio(gpioIds::CS_SUS_1, chipSelectSus); + gpioComIF->addGpios(gpioCookieSus); - SpiCookie* spiCookieSus = new SpiCookie(addresses::SUS_1, std::string("/dev/spidev1.0"), - SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED); + SpiCookie* spiCookieSus = + new SpiCookie(addresses::SUS_1, std::string("/dev/spidev1.0"), SUS::MAX_CMD_SIZE, + spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED); - new SusHandler(objects::SUS_1, objects::SPI_COM_IF, spiCookieSus, gpioComIF, - gpioIds::CS_SUS_1); + new SusHandler(objects::SUS_1, objects::SPI_COM_IF, spiCookieSus, gpioComIF, gpioIds::CS_SUS_1); #endif #if BOARD_TE0720 == 1 && OBSW_TEST_CCSDS_BRIDGE == 1 - GpioCookie* gpioCookieCcsdsIp = new GpioCookie; - GpiodRegular* papbBusyN = new GpiodRegular(std::string("gpiochip0"), 0, std::string("PAPBBusy_VC0")); - gpioCookieCcsdsIp->addGpio(gpioIds::PAPB_BUSY_N, papbBusyN); - GpiodRegular* papbEmpty = new GpiodRegular(std::string("gpiochip0"), 1, - std::string("PAPBEmpty_VC0")); - gpioCookieCcsdsIp->addGpio(gpioIds::PAPB_EMPTY, papbEmpty); - gpioComIF->addGpios(gpioCookieCcsdsIp); + GpioCookie* gpioCookieCcsdsIp = new GpioCookie; + GpiodRegular* papbBusyN = + new GpiodRegular(std::string("gpiochip0"), 0, std::string("PAPBBusy_VC0")); + gpioCookieCcsdsIp->addGpio(gpioIds::PAPB_BUSY_N, papbBusyN); + GpiodRegular* papbEmpty = + new GpiodRegular(std::string("gpiochip0"), 1, std::string("PAPBEmpty_VC0")); + gpioCookieCcsdsIp->addGpio(gpioIds::PAPB_EMPTY, papbEmpty); + gpioComIF->addGpios(gpioCookieCcsdsIp); - new CCSDSIPCoreBridge(objects::CCSDS_IP_CORE_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR, - objects::TM_STORE, objects::TC_STORE, gpioComIF, std::string("/dev/uio0"), - gpioIds::PAPB_BUSY_N, gpioIds::PAPB_EMPTY); + new CCSDSIPCoreBridge(objects::CCSDS_IP_CORE_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR, + objects::TM_STORE, objects::TC_STORE, gpioComIF, std::string("/dev/uio0"), + gpioIds::PAPB_BUSY_N, gpioIds::PAPB_EMPTY); #endif #if BOARD_TE0720 == 1 && OBSW_TEST_RADIATION_SENSOR_HANDLER == 1 - GpioCookie* gpioCookieRadSensor = new GpioCookie; - GpiodRegular* chipSelectRadSensor = new GpiodRegular(std::string("gpiochip1"), 0, - std::string("Chip select radiation sensor"), gpio::DIR_OUT, 1); - gpioCookieRadSensor->addGpio(gpioIds::CS_RAD_SENSOR, chipSelectRadSensor); - gpioComIF->addGpios(gpioCookieRadSensor); + GpioCookie* gpioCookieRadSensor = new GpioCookie; + GpiodRegular* chipSelectRadSensor = new GpiodRegular( + std::string("gpiochip1"), 0, std::string("Chip select radiation sensor"), gpio::DIR_OUT, 1); + gpioCookieRadSensor->addGpio(gpioIds::CS_RAD_SENSOR, chipSelectRadSensor); + gpioComIF->addGpios(gpioCookieRadSensor); - SpiCookie* spiCookieRadSensor = new SpiCookie(addresses::RAD_SENSOR, gpioIds::CS_RAD_SENSOR, - std::string("/dev/spidev1.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - spi::DEFAULT_MAX_1227_SPEED); + SpiCookie* spiCookieRadSensor = + new SpiCookie(addresses::RAD_SENSOR, gpioIds::CS_RAD_SENSOR, std::string("/dev/spidev1.0"), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED); - RadiationSensorHandler* radSensor = new RadiationSensorHandler(objects::RAD_SENSOR, - objects::SPI_COM_IF, spiCookieRadSensor); - radSensor->setStartUpImmediately(); + RadiationSensorHandler* radSensor = + new RadiationSensorHandler(objects::RAD_SENSOR, objects::SPI_COM_IF, spiCookieRadSensor); + radSensor->setStartUpImmediately(); #endif #if BOARD_TE0720 == 1 && OBSW_ADD_PLOC_MPSOC == 1 - UartCookie* plocUartCookie = new UartCookie(std::string("/dev/ttyPS1"), 115200, - PLOC_MPSOC::MAX_REPLY_SIZE); - /* Testing PlocMPSoCHandler on TE0720-03-1CFA */ - PlocMPSoCHandler* mpsocPlocHandler = new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, - plocUartCookie); - mpsocPlocHandler->setStartUpImmediately(); + UartCookie* plocUartCookie = + new UartCookie(std::string("/dev/ttyPS1"), 115200, PLOC_MPSOC::MAX_REPLY_SIZE); + /* Testing PlocMPSoCHandler on TE0720-03-1CFA */ + PlocMPSoCHandler* mpsocPlocHandler = + new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, plocUartCookie); + mpsocPlocHandler->setStartUpImmediately(); #endif #if BOARD_TE0720 == 1 && OBSW_TEST_TE7020_HEATER == 1 - /* Configuration for MIO0 on TE0720-03-1CFA */ - GpiodRegular* heaterGpio = new GpiodRegular(std::string("gpiochip0"), 0, std::string("MIO0"), gpio::IN, 0); - GpioCookie* gpioCookie = new GpioCookie; - gpioCookie->addGpio(gpioIds::HEATER_0, heaterGpio); - new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, gpioCookie, objects::PCDU_HANDLER, - pcduSwitches::TCS_BOARD_8V_HEATER_IN); + /* Configuration for MIO0 on TE0720-03-1CFA */ + GpiodRegular* heaterGpio = + new GpiodRegular(std::string("gpiochip0"), 0, std::string("MIO0"), gpio::IN, 0); + GpioCookie* gpioCookie = new GpioCookie; + gpioCookie->addGpio(gpioIds::HEATER_0, heaterGpio); + new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, gpioCookie, objects::PCDU_HANDLER, + pcduSwitches::TCS_BOARD_8V_HEATER_IN); #endif #if BOARD_TE0720 == 1 && OBSW_ADD_PLOC_SUPERVISOR == 1 - /* Configuration for MIO0 on TE0720-03-1CFA */ - UartCookie* plocSupervisorCookie = new UartCookie(objects::PLOC_SUPERVISOR_HANDLER, - std::string("/dev/ttyPS1"), UartModes::NON_CANONICAL, 115200, - PLOC_SPV::MAX_PACKET_SIZE * 20); - plocSupervisorCookie->setNoFixedSizeReply(); - PlocSupervisorHandler* plocSupervisor = new PlocSupervisorHandler( - objects::PLOC_SUPERVISOR_HANDLER, objects::UART_COM_IF, plocSupervisorCookie); - plocSupervisor->setStartUpImmediately(); + /* Configuration for MIO0 on TE0720-03-1CFA */ + UartCookie* plocSupervisorCookie = + new UartCookie(objects::PLOC_SUPERVISOR_HANDLER, std::string("/dev/ttyPS1"), + UartModes::NON_CANONICAL, 115200, PLOC_SPV::MAX_PACKET_SIZE * 20); + plocSupervisorCookie->setNoFixedSizeReply(); + PlocSupervisorHandler* plocSupervisor = new PlocSupervisorHandler( + objects::PLOC_SUPERVISOR_HANDLER, objects::UART_COM_IF, plocSupervisorCookie); + plocSupervisor->setStartUpImmediately(); #endif #if OBSW_ADD_SPI_TEST_CODE == 1 - new SpiTestClass(objects::SPI_TEST, gpioComIF); + new SpiTestClass(objects::SPI_TEST, gpioComIF); #endif - } diff --git a/bsp_q7s/core/ObjectFactory.h b/bsp_q7s/core/ObjectFactory.h index 0e723142..47e06e33 100644 --- a/bsp_q7s/core/ObjectFactory.h +++ b/bsp_q7s/core/ObjectFactory.h @@ -11,7 +11,7 @@ void setStatics(); void produce(void* args); void createCommunicationInterfaces(LinuxLibgpioIF** gpioComIF, UartComIF** uartComIF, - SpiComIF** spiComIF); + SpiComIF** spiComIF); void createTmpComponents(); void createPcduComponents(); void createRadSensorComponent(LinuxLibgpioIF* gpioComIF); @@ -22,9 +22,9 @@ void createSolarArrayDeploymentComponents(); void createSyrlinksComponents(); void createRtdComponents(LinuxLibgpioIF* gpioComIF); void createReactionWheelComponents(LinuxLibgpioIF* gpioComIF); -void createCcsdsComponents(LinuxLibgpioIF *gpioComIF); +void createCcsdsComponents(LinuxLibgpioIF* gpioComIF); void createTestComponents(LinuxLibgpioIF* gpioComIF); -}; +}; // namespace ObjectFactory #endif /* BSP_Q7S_OBJECTFACTORY_H_ */ diff --git a/bsp_q7s/core/ParameterHandler.cpp b/bsp_q7s/core/ParameterHandler.cpp index d6c8f34f..8cee046e 100644 --- a/bsp_q7s/core/ParameterHandler.cpp +++ b/bsp_q7s/core/ParameterHandler.cpp @@ -1,8 +1,5 @@ #include "ParameterHandler.h" -ParameterHandler::ParameterHandler(std::string mountPrefix): mountPrefix(mountPrefix) { -} +ParameterHandler::ParameterHandler(std::string mountPrefix) : mountPrefix(mountPrefix) {} -void ParameterHandler::setMountPrefix(std::string prefix) { - mountPrefix = prefix; -} +void ParameterHandler::setMountPrefix(std::string prefix) { mountPrefix = prefix; } diff --git a/bsp_q7s/core/ParameterHandler.h b/bsp_q7s/core/ParameterHandler.h index 81cbc099..4a108586 100644 --- a/bsp_q7s/core/ParameterHandler.h +++ b/bsp_q7s/core/ParameterHandler.h @@ -4,19 +4,17 @@ #include #include - - class ParameterHandler { -public: - ParameterHandler(std::string mountPrefix); + public: + ParameterHandler(std::string mountPrefix); - void setMountPrefix(std::string prefix); + void setMountPrefix(std::string prefix); - void setUpDummyParameter(); -private: - std::string mountPrefix; - DummyParameter dummyParam; + void setUpDummyParameter(); + + private: + std::string mountPrefix; + DummyParameter dummyParam; }; - #endif /* BSP_Q7S_CORE_PARAMETERHANDLER_H_ */ diff --git a/bsp_q7s/core/obsw.cpp b/bsp_q7s/core/obsw.cpp index e55d5652..a69e94a2 100644 --- a/bsp_q7s/core/obsw.cpp +++ b/bsp_q7s/core/obsw.cpp @@ -1,43 +1,44 @@ #include "obsw.h" -#include "OBSWVersion.h" -#include "OBSWConfig.h" -#include "InitMission.h" -#include "watchdogConf.h" -#include "fsfw/tasks/TaskFactory.h" -#include "fsfw/FSFWVersion.h" - -#include #include +#include + +#include "InitMission.h" +#include "OBSWConfig.h" +#include "OBSWVersion.h" +#include "fsfw/FSFWVersion.h" +#include "fsfw/tasks/TaskFactory.h" +#include "watchdogConf.h" static int OBSW_ALREADY_RUNNING = -2; int obsw::obsw() { - std::cout << "-- EIVE OBSW --" << std::endl; + std::cout << "-- EIVE OBSW --" << std::endl; #if BOARD_TE0720 == 0 - std::cout << "-- Compiled for Linux (Xiphos Q7S) --" << std::endl; + std::cout << "-- Compiled for Linux (Xiphos Q7S) --" << std::endl; #else - std::cout << "-- Compiled for Linux (TE0720) --" << std::endl; + std::cout << "-- Compiled for Linux (TE0720) --" << std::endl; #endif - std::cout << "-- OBSW v" << SW_VERSION << "." << SW_SUBVERSION << - "." << SW_REVISION << ", FSFW v" << FSFW_VERSION << "." << FSFW_SUBVERSION << "." << - FSFW_REVISION << "--" << std::endl; - std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; + std::cout << "-- OBSW v" << SW_VERSION << "." << SW_SUBVERSION << "." << SW_REVISION << ", FSFW v" + << FSFW_VERSION << "." << FSFW_SUBVERSION << "." << FSFW_REVISION << "--" << std::endl; + std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; #if Q7S_CHECK_FOR_ALREADY_RUNNING_IMG == 1 - // Check special file here. This file is created or deleted by the eive-watchdog application - // or systemd service! - if(std::filesystem::exists(watchdog::RUNNING_FILE_NAME)) { - sif::warning << "File " << watchdog::RUNNING_FILE_NAME << " exists so the software might " - "already be running. Aborting.." << std::endl; - return OBSW_ALREADY_RUNNING; - } + // Check special file here. This file is created or deleted by the eive-watchdog application + // or systemd service! + if (std::filesystem::exists(watchdog::RUNNING_FILE_NAME)) { + sif::warning << "File " << watchdog::RUNNING_FILE_NAME + << " exists so the software might " + "already be running. Aborting.." + << std::endl; + return OBSW_ALREADY_RUNNING; + } #endif - initmission::initMission(); + initmission::initMission(); - for(;;) { - /* Suspend main thread by sleeping it. */ - TaskFactory::delayTask(5000); - } - return 0; + for (;;) { + /* Suspend main thread by sleeping it. */ + TaskFactory::delayTask(5000); + } + return 0; } diff --git a/bsp_q7s/devices/PlocMemoryDumper.cpp b/bsp_q7s/devices/PlocMemoryDumper.cpp index cc4361bb..c7ba58bd 100644 --- a/bsp_q7s/devices/PlocMemoryDumper.cpp +++ b/bsp_q7s/devices/PlocMemoryDumper.cpp @@ -1,206 +1,192 @@ -#include -#include "fsfw/ipc/QueueFactory.h" #include "PlocMemoryDumper.h" -#include +#include + #include +#include #include -PlocMemoryDumper::PlocMemoryDumper(object_id_t objectId) : - SystemObject(objectId), commandActionHelper(this), actionHelper(this, nullptr) { - commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); +#include "fsfw/ipc/QueueFactory.h" + +PlocMemoryDumper::PlocMemoryDumper(object_id_t objectId) + : SystemObject(objectId), commandActionHelper(this), actionHelper(this, nullptr) { + commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); } -PlocMemoryDumper::~PlocMemoryDumper() { -} +PlocMemoryDumper::~PlocMemoryDumper() {} ReturnValue_t PlocMemoryDumper::initialize() { + ReturnValue_t result = SystemObject::initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = commandActionHelper.initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = actionHelper.initialize(commandQueue); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } - ReturnValue_t result = SystemObject::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - result = commandActionHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - result = actionHelper.initialize(commandQueue); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t PlocMemoryDumper::performOperation(uint8_t operationCode) { - readCommandQueue(); - doStateMachine(); - return HasReturnvaluesIF::RETURN_OK; + readCommandQueue(); + doStateMachine(); + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t PlocMemoryDumper::executeAction(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { +ReturnValue_t PlocMemoryDumper::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) { + if (state != State::IDLE) { + return IS_BUSY; + } - if (state != State::IDLE) { - return IS_BUSY; - } - - switch (actionId) { + switch (actionId) { case DUMP_MRAM: { - size_t deserializeSize = sizeof(mram.startAddress) + sizeof(mram.endAddress); - SerializeAdapter::deSerialize(&mram.startAddress, &data, &deserializeSize, - SerializeIF::Endianness::BIG); - SerializeAdapter::deSerialize(&mram.endAddress, &data, &deserializeSize, - SerializeIF::Endianness::BIG); - if (mram.endAddress > MAX_MRAM_ADDRESS) { - return MRAM_ADDRESS_TOO_HIGH; - } - if (mram.endAddress <= mram.startAddress) { - return MRAM_INVALID_ADDRESS_COMBINATION; - } - state = State::COMMAND_FIRST_MRAM_DUMP; - break; + size_t deserializeSize = sizeof(mram.startAddress) + sizeof(mram.endAddress); + SerializeAdapter::deSerialize(&mram.startAddress, &data, &deserializeSize, + SerializeIF::Endianness::BIG); + SerializeAdapter::deSerialize(&mram.endAddress, &data, &deserializeSize, + SerializeIF::Endianness::BIG); + if (mram.endAddress > MAX_MRAM_ADDRESS) { + return MRAM_ADDRESS_TOO_HIGH; + } + if (mram.endAddress <= mram.startAddress) { + return MRAM_INVALID_ADDRESS_COMBINATION; + } + state = State::COMMAND_FIRST_MRAM_DUMP; + break; } default: { - sif::warning << "PlocMemoryDumper::executeAction: Received command with invalid action id" - << std::endl; - return INVALID_ACTION_ID; - } + sif::warning << "PlocMemoryDumper::executeAction: Received command with invalid action id" + << std::endl; + return INVALID_ACTION_ID; } + } - return EXECUTION_FINISHED; + return EXECUTION_FINISHED; } -MessageQueueId_t PlocMemoryDumper::getCommandQueue() const { - return commandQueue->getId(); -} +MessageQueueId_t PlocMemoryDumper::getCommandQueue() const { return commandQueue->getId(); } -MessageQueueIF* PlocMemoryDumper::getCommandQueuePtr() { - return commandQueue; -} +MessageQueueIF* PlocMemoryDumper::getCommandQueuePtr() { return commandQueue; } void PlocMemoryDumper::readCommandQueue() { - CommandMessage message; - ReturnValue_t result; + CommandMessage message; + ReturnValue_t result; - for (result = commandQueue->receiveMessage(&message); result == HasReturnvaluesIF::RETURN_OK; - result = commandQueue->receiveMessage(&message)) { - if (result != RETURN_OK) { - continue; - } - result = actionHelper.handleActionMessage(&message); - if (result == HasReturnvaluesIF::RETURN_OK) { - continue; - } - - result = commandActionHelper.handleReply(&message); - if (result == HasReturnvaluesIF::RETURN_OK) { - continue; - } - - sif::debug << "PlocMemoryDumper::readCommandQueue: Received message with invalid format" - << std::endl; + for (result = commandQueue->receiveMessage(&message); result == HasReturnvaluesIF::RETURN_OK; + result = commandQueue->receiveMessage(&message)) { + if (result != RETURN_OK) { + continue; } + result = actionHelper.handleActionMessage(&message); + if (result == HasReturnvaluesIF::RETURN_OK) { + continue; + } + + result = commandActionHelper.handleReply(&message); + if (result == HasReturnvaluesIF::RETURN_OK) { + continue; + } + + sif::debug << "PlocMemoryDumper::readCommandQueue: Received message with invalid format" + << std::endl; + } } void PlocMemoryDumper::doStateMachine() { - switch (state) { + switch (state) { case State::IDLE: - break; + break; case State::COMMAND_FIRST_MRAM_DUMP: - commandNextMramDump(PLOC_SPV::FIRST_MRAM_DUMP); - break; + commandNextMramDump(PLOC_SPV::FIRST_MRAM_DUMP); + break; case State::COMMAND_CONSECUTIVE_MRAM_DUMP: - commandNextMramDump(PLOC_SPV::CONSECUTIVE_MRAM_DUMP); - break; + commandNextMramDump(PLOC_SPV::CONSECUTIVE_MRAM_DUMP); + break; case State::EXECUTING_MRAM_DUMP: - break; + break; default: - sif::debug << "PlocMemoryDumper::doStateMachine: Invalid state" << std::endl; - break; - } + sif::debug << "PlocMemoryDumper::doStateMachine: Invalid state" << std::endl; + break; + } } -void PlocMemoryDumper::stepSuccessfulReceived(ActionId_t actionId, - uint8_t step) { -} +void PlocMemoryDumper::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) {} void PlocMemoryDumper::stepFailedReceived(ActionId_t actionId, uint8_t step, - ReturnValue_t returnCode) { -} + ReturnValue_t returnCode) {} -void PlocMemoryDumper::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) { - -} +void PlocMemoryDumper::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) {} void PlocMemoryDumper::completionSuccessfulReceived(ActionId_t actionId) { - switch (pendingCommand) { + switch (pendingCommand) { case (PLOC_SPV::FIRST_MRAM_DUMP): case (PLOC_SPV::CONSECUTIVE_MRAM_DUMP): - if (mram.endAddress == mram.startAddress) { - triggerEvent(MRAM_DUMP_FINISHED); - state = State::IDLE; - } - else { - state = State::COMMAND_CONSECUTIVE_MRAM_DUMP; - } - break; - default: - sif::debug << "PlocMemoryDumper::completionSuccessfulReceived: Invalid pending command" - << std::endl; + if (mram.endAddress == mram.startAddress) { + triggerEvent(MRAM_DUMP_FINISHED); state = State::IDLE; - break; - } + } else { + state = State::COMMAND_CONSECUTIVE_MRAM_DUMP; + } + break; + default: + sif::debug << "PlocMemoryDumper::completionSuccessfulReceived: Invalid pending command" + << std::endl; + state = State::IDLE; + break; + } } -void PlocMemoryDumper::completionFailedReceived(ActionId_t actionId, - ReturnValue_t returnCode) { - switch(pendingCommand) { - case(PLOC_SPV::FIRST_MRAM_DUMP): - case(PLOC_SPV::CONSECUTIVE_MRAM_DUMP): - triggerEvent(MRAM_DUMP_FAILED, mram.lastStartAddress); - break; +void PlocMemoryDumper::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) { + switch (pendingCommand) { + case (PLOC_SPV::FIRST_MRAM_DUMP): + case (PLOC_SPV::CONSECUTIVE_MRAM_DUMP): + triggerEvent(MRAM_DUMP_FAILED, mram.lastStartAddress); + break; default: - sif::debug << "PlocMemoryDumper::completionFailedReceived: Invalid pending command " - << std::endl; - break; - } - state = State::IDLE; + sif::debug << "PlocMemoryDumper::completionFailedReceived: Invalid pending command " + << std::endl; + break; + } + state = State::IDLE; } void PlocMemoryDumper::commandNextMramDump(ActionId_t dumpCommand) { - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = RETURN_OK; - uint32_t tempStartAddress = 0; - uint32_t tempEndAddress = 0; + uint32_t tempStartAddress = 0; + uint32_t tempEndAddress = 0; - if (mram.endAddress - mram.startAddress > MAX_MRAM_DUMP_SIZE) { - tempStartAddress = mram.startAddress; - tempEndAddress = mram.startAddress + MAX_MRAM_DUMP_SIZE; - mram.startAddress += MAX_MRAM_DUMP_SIZE; - mram.lastStartAddress = tempStartAddress; - } - else { - tempStartAddress = mram.startAddress; - tempEndAddress = mram.endAddress; - mram.startAddress = mram.endAddress; - } + if (mram.endAddress - mram.startAddress > MAX_MRAM_DUMP_SIZE) { + tempStartAddress = mram.startAddress; + tempEndAddress = mram.startAddress + MAX_MRAM_DUMP_SIZE; + mram.startAddress += MAX_MRAM_DUMP_SIZE; + mram.lastStartAddress = tempStartAddress; + } else { + tempStartAddress = mram.startAddress; + tempEndAddress = mram.endAddress; + mram.startAddress = mram.endAddress; + } - MemoryParams params(tempStartAddress, tempEndAddress); + MemoryParams params(tempStartAddress, tempEndAddress); - result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, - dumpCommand, ¶ms); - if (result != RETURN_OK) { - sif::warning << "PlocMemoryDumper::commandNextMramDump: Failed to send mram dump command " - << "with start address " << tempStartAddress << " and end address " - << tempEndAddress << std::endl; - triggerEvent(SEND_MRAM_DUMP_FAILED, result, tempStartAddress); - state = State::IDLE; - pendingCommand = NONE; - return; - } - state = State::EXECUTING_MRAM_DUMP; - pendingCommand = dumpCommand; + result = + commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, dumpCommand, ¶ms); + if (result != RETURN_OK) { + sif::warning << "PlocMemoryDumper::commandNextMramDump: Failed to send mram dump command " + << "with start address " << tempStartAddress << " and end address " + << tempEndAddress << std::endl; + triggerEvent(SEND_MRAM_DUMP_FAILED, result, tempStartAddress); + state = State::IDLE; + pendingCommand = NONE; return; + } + state = State::EXECUTING_MRAM_DUMP; + pendingCommand = dumpCommand; + return; } - diff --git a/bsp_q7s/devices/PlocMemoryDumper.h b/bsp_q7s/devices/PlocMemoryDumper.h index 72b031ae..2ee26824 100644 --- a/bsp_q7s/devices/PlocMemoryDumper.h +++ b/bsp_q7s/devices/PlocMemoryDumper.h @@ -3,18 +3,18 @@ #include #include + #include "OBSWConfig.h" -#include "fsfw/action/CommandActionHelper.h" +#include "bsp_q7s/memory/SdCardManager.h" #include "fsfw/action/ActionHelper.h" -#include "fsfw/action/HasActionsIF.h" +#include "fsfw/action/CommandActionHelper.h" #include "fsfw/action/CommandsActionsIF.h" +#include "fsfw/action/HasActionsIF.h" +#include "fsfw/objectmanager/SystemObject.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/tasks/ExecutableObjectIF.h" -#include "fsfw/objectmanager/SystemObject.h" -#include "bsp_q7s/memory/SdCardManager.h" -#include "linux/fsfwconfig/objects/systemObjectList.h" #include "fsfw/tmtcpacket/SpacePacket.h" - +#include "linux/fsfwconfig/objects/systemObjectList.h" /** * @brief Because the buffer of the linux tty driver is limited to 2 x 65535 bytes, this class is @@ -25,91 +25,90 @@ * @author J. Meier */ class PlocMemoryDumper : public SystemObject, - public HasActionsIF, - public ExecutableObjectIF, - public HasReturnvaluesIF, - public CommandsActionsIF { -public: + public HasActionsIF, + public ExecutableObjectIF, + public HasReturnvaluesIF, + public CommandsActionsIF { + public: + static const ActionId_t NONE = 0; + static const ActionId_t DUMP_MRAM = 1; - static const ActionId_t NONE = 0; - static const ActionId_t DUMP_MRAM = 1; + PlocMemoryDumper(object_id_t objectId); + virtual ~PlocMemoryDumper(); - PlocMemoryDumper(object_id_t objectId); - virtual ~PlocMemoryDumper(); + ReturnValue_t performOperation(uint8_t operationCode = 0) override; + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size); + MessageQueueId_t getCommandQueue() const; + ReturnValue_t initialize() override; + MessageQueueIF* getCommandQueuePtr() override; + void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) override; + void stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) override; + void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) override; + void completionSuccessfulReceived(ActionId_t actionId) override; + void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override; - ReturnValue_t performOperation(uint8_t operationCode = 0) override; - ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size); - MessageQueueId_t getCommandQueue() const; - ReturnValue_t initialize() override; - MessageQueueIF* getCommandQueuePtr() override; - void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) override; - void stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) override; - void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) override; - void completionSuccessfulReceived(ActionId_t actionId) override; - void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override; + private: + static const uint32_t QUEUE_SIZE = 10; -private: + static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MEMORY_DUMPER; - static const uint32_t QUEUE_SIZE = 10; + //! [EXPORT] : [COMMENT] The capacity of the MRAM amounts to 512 kB. Thus the maximum address must + //! not be higher than 0x7d000. + static const ReturnValue_t MRAM_ADDRESS_TOO_HIGH = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] The specified end address is lower than the start address + static const ReturnValue_t MRAM_INVALID_ADDRESS_COMBINATION = MAKE_RETURN_CODE(0xA1); - static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MEMORY_DUMPER; + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MEMORY_DUMPER; - //! [EXPORT] : [COMMENT] The capacity of the MRAM amounts to 512 kB. Thus the maximum address must not be higher than 0x7d000. - static const ReturnValue_t MRAM_ADDRESS_TOO_HIGH = MAKE_RETURN_CODE(0xA0); - //! [EXPORT] : [COMMENT] The specified end address is lower than the start address - static const ReturnValue_t MRAM_INVALID_ADDRESS_COMBINATION = MAKE_RETURN_CODE(0xA1); + //! [EXPORT] : [COMMENT] Failed to send mram dump command to supervisor handler + //! P1: Return value of commandAction function + //! P2: Start address of MRAM to dump with this command + static const Event SEND_MRAM_DUMP_FAILED = MAKE_EVENT(0, severity::LOW); + //! [EXPORT] : [COMMENT] Received completion failure report form PLOC supervisor handler + //! P1: MRAM start address of failing dump command + static const Event MRAM_DUMP_FAILED = MAKE_EVENT(1, severity::LOW); + //! [EXPORT] : [COMMENT] MRAM dump finished successfully + static const Event MRAM_DUMP_FINISHED = MAKE_EVENT(2, severity::LOW); - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MEMORY_DUMPER; + // Maximum size of mram dump which can be retrieved with one command + static const uint32_t MAX_MRAM_DUMP_SIZE = 100000; + static const uint32_t MAX_MRAM_ADDRESS = 0x7d000; - //! [EXPORT] : [COMMENT] Failed to send mram dump command to supervisor handler - //! P1: Return value of commandAction function - //! P2: Start address of MRAM to dump with this command - static const Event SEND_MRAM_DUMP_FAILED = MAKE_EVENT(0, severity::LOW); - //! [EXPORT] : [COMMENT] Received completion failure report form PLOC supervisor handler - //! P1: MRAM start address of failing dump command - static const Event MRAM_DUMP_FAILED = MAKE_EVENT(1, severity::LOW); - //! [EXPORT] : [COMMENT] MRAM dump finished successfully - static const Event MRAM_DUMP_FINISHED = MAKE_EVENT(2, severity::LOW); + MessageQueueIF* commandQueue = nullptr; - // Maximum size of mram dump which can be retrieved with one command - static const uint32_t MAX_MRAM_DUMP_SIZE = 100000; - static const uint32_t MAX_MRAM_ADDRESS = 0x7d000; + CommandActionHelper commandActionHelper; - MessageQueueIF* commandQueue = nullptr; + ActionHelper actionHelper; - CommandActionHelper commandActionHelper; + enum class State : uint8_t { + IDLE, + COMMAND_FIRST_MRAM_DUMP, + COMMAND_CONSECUTIVE_MRAM_DUMP, + EXECUTING_MRAM_DUMP + }; - ActionHelper actionHelper; + State state = State::IDLE; - enum class State: uint8_t { - IDLE, - COMMAND_FIRST_MRAM_DUMP, - COMMAND_CONSECUTIVE_MRAM_DUMP, - EXECUTING_MRAM_DUMP - }; + ActionId_t pendingCommand = NONE; - State state = State::IDLE; + typedef struct MemoryInfo { + // Stores the start address of the next memory range to dump + uint32_t startAddress; + uint32_t endAddress; + // Stores the start address of the last sent dump command + uint32_t lastStartAddress; + } MemoryInfo_t; - ActionId_t pendingCommand = NONE; + MemoryInfo_t mram = {0, 0, 0}; - typedef struct MemoryInfo { - // Stores the start address of the next memory range to dump - uint32_t startAddress; - uint32_t endAddress; - // Stores the start address of the last sent dump command - uint32_t lastStartAddress; - } MemoryInfo_t; + void readCommandQueue(); + void doStateMachine(); - MemoryInfo_t mram = {0, 0, 0}; - - void readCommandQueue(); - void doStateMachine(); - - /** - * @brief Sends the next mram dump command to the PLOC supervisor handler. - */ - void commandNextMramDump(ActionId_t dumpCommand); + /** + * @brief Sends the next mram dump command to the PLOC supervisor handler. + */ + void commandNextMramDump(ActionId_t dumpCommand); }; #endif /* MISSION_DEVICES_PLOCMEMORYDUMPER_H_ */ diff --git a/bsp_q7s/devices/PlocSupervisorHandler.cpp b/bsp_q7s/devices/PlocSupervisorHandler.cpp index 30ea9572..a56c9e1c 100644 --- a/bsp_q7s/devices/PlocSupervisorHandler.cpp +++ b/bsp_q7s/devices/PlocSupervisorHandler.cpp @@ -1,540 +1,530 @@ -#include -#include -#include -#include - #include "PlocSupervisorHandler.h" -#include "OBSWConfig.h" -#include #include +#include #include +#include +#include +#include +#include + +#include "OBSWConfig.h" + PlocSupervisorHandler::PlocSupervisorHandler(object_id_t objectId, object_id_t uartComIFid, - CookieIF * comCookie) : - DeviceHandlerBase(objectId, uartComIFid, comCookie), hkset(this), bootStatusReport(this), latchupStatusReport( - this) { - if (comCookie == NULL) { - sif::error << "PlocSupervisorHandler: Invalid com cookie" << std::endl; - } + CookieIF* comCookie) + : DeviceHandlerBase(objectId, uartComIFid, comCookie), + hkset(this), + bootStatusReport(this), + latchupStatusReport(this) { + if (comCookie == NULL) { + sif::error << "PlocSupervisorHandler: Invalid com cookie" << std::endl; + } } -PlocSupervisorHandler::~PlocSupervisorHandler() { -} +PlocSupervisorHandler::~PlocSupervisorHandler() {} ReturnValue_t PlocSupervisorHandler::initialize() { - ReturnValue_t result = RETURN_OK; - result = DeviceHandlerBase::initialize(); - if (result != RETURN_OK) { - return result; - } - uartComIf = dynamic_cast(communicationInterface); - if (uartComIf == nullptr) { - sif::warning << "PlocSupervisorHandler::initialize: Invalid uart com if" << std::endl; - return INVALID_UART_COM_IF; - } + ReturnValue_t result = RETURN_OK; + result = DeviceHandlerBase::initialize(); + if (result != RETURN_OK) { + return result; + } + uartComIf = dynamic_cast(communicationInterface); + if (uartComIf == nullptr) { + sif::warning << "PlocSupervisorHandler::initialize: Invalid uart com if" << std::endl; + return INVALID_UART_COM_IF; + } #if BOARD_TE0720 == 0 - sdcMan = SdCardManager::instance(); + sdcMan = SdCardManager::instance(); #endif /* BOARD_TE0720 == 0 */ - return result; + return result; } - -void PlocSupervisorHandler::doStartUp(){ +void PlocSupervisorHandler::doStartUp() { #if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 - setMode(MODE_NORMAL); + setMode(MODE_NORMAL); #else - setMode(_MODE_TO_ON); + setMode(_MODE_TO_ON); #endif } -void PlocSupervisorHandler::doShutDown(){ - setMode(_MODE_POWER_DOWN); +void PlocSupervisorHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } + +ReturnValue_t PlocSupervisorHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + return NOTHING_TO_SEND; } -ReturnValue_t PlocSupervisorHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - return NOTHING_TO_SEND; +ReturnValue_t PlocSupervisorHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { + return NOTHING_TO_SEND; } -ReturnValue_t PlocSupervisorHandler::buildTransitionDeviceCommand( - DeviceCommandId_t * id){ - return NOTHING_TO_SEND; -} - -ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t * commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_FAILED; - switch(deviceCommand) { - case(PLOC_SPV::GET_HK_REPORT): { - prepareEmptyCmd(PLOC_SPV::APID_GET_HK_REPORT); - result = RETURN_OK; - break; - } - case(PLOC_SPV::RESTART_MPSOC): { - prepareEmptyCmd(PLOC_SPV::APID_RESTART_MPSOC); - result = RETURN_OK; - break; - } - case(PLOC_SPV::START_MPSOC): { - prepareEmptyCmd(PLOC_SPV::APID_START_MPSOC); - result = RETURN_OK; - break; - } - case(PLOC_SPV::SHUTDOWN_MPSOC): { - prepareEmptyCmd(PLOC_SPV::APID_SHUTWOWN_MPSOC); - result = RETURN_OK; - break; - } - case(PLOC_SPV::SEL_MPSOC_BOOT_IMAGE): { - prepareSelBootImageCmd(commandData); - result = RETURN_OK; - break; - } - case(PLOC_SPV::RESET_MPSOC): { - prepareEmptyCmd(PLOC_SPV::APID_RESET_MPSOC); - result = RETURN_OK; - break; +ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t* commandData, + size_t commandDataLen) { + ReturnValue_t result = RETURN_FAILED; + switch (deviceCommand) { + case (PLOC_SPV::GET_HK_REPORT): { + prepareEmptyCmd(PLOC_SPV::APID_GET_HK_REPORT); + result = RETURN_OK; + break; } - case(PLOC_SPV::SET_TIME_REF): { - result = prepareSetTimeRefCmd(); - break; - } - case(PLOC_SPV::SET_BOOT_TIMEOUT): { - prepareSetBootTimeoutCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::RESTART_MPSOC): { + prepareEmptyCmd(PLOC_SPV::APID_RESTART_MPSOC); + result = RETURN_OK; + break; } - case(PLOC_SPV::SET_MAX_RESTART_TRIES): { - prepareRestartTriesCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::START_MPSOC): { + prepareEmptyCmd(PLOC_SPV::APID_START_MPSOC); + result = RETURN_OK; + break; } - case(PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION): { - prepareDisableHk(); - result = RETURN_OK; - break; + case (PLOC_SPV::SHUTDOWN_MPSOC): { + prepareEmptyCmd(PLOC_SPV::APID_SHUTWOWN_MPSOC); + result = RETURN_OK; + break; } - case(PLOC_SPV::GET_BOOT_STATUS_REPORT): { - prepareEmptyCmd(PLOC_SPV::APID_GET_BOOT_STATUS_RPT); - result = RETURN_OK; - break; + case (PLOC_SPV::SEL_MPSOC_BOOT_IMAGE): { + prepareSelBootImageCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::WATCHDOGS_ENABLE): { - prepareWatchdogsEnableCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::RESET_MPSOC): { + prepareEmptyCmd(PLOC_SPV::APID_RESET_MPSOC); + result = RETURN_OK; + break; } - case(PLOC_SPV::WATCHDOGS_CONFIG_TIMEOUT): { - result = prepareWatchdogsConfigTimeoutCmd(commandData); - break; + case (PLOC_SPV::SET_TIME_REF): { + result = prepareSetTimeRefCmd(); + break; } - case(PLOC_SPV::ENABLE_LATCHUP_ALERT): { - result = prepareLatchupConfigCmd(commandData, deviceCommand); - break; + case (PLOC_SPV::SET_BOOT_TIMEOUT): { + prepareSetBootTimeoutCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::DISABLE_LATCHUP_ALERT): { - result = prepareLatchupConfigCmd(commandData, deviceCommand); - break; + case (PLOC_SPV::SET_MAX_RESTART_TRIES): { + prepareRestartTriesCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::AUTO_CALIBRATE_ALERT): { - result = prepareAutoCalibrateAlertCmd(commandData); - break; + case (PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION): { + prepareDisableHk(); + result = RETURN_OK; + break; } - case(PLOC_SPV::SET_ALERT_LIMIT): { - result = prepareSetAlertLimitCmd(commandData); - break; + case (PLOC_SPV::GET_BOOT_STATUS_REPORT): { + prepareEmptyCmd(PLOC_SPV::APID_GET_BOOT_STATUS_RPT); + result = RETURN_OK; + break; } - case(PLOC_SPV::SET_ALERT_IRQ_FILTER): { - result = prepareSetAlertIrqFilterCmd(commandData); - break; + case (PLOC_SPV::WATCHDOGS_ENABLE): { + prepareWatchdogsEnableCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::SET_ADC_SWEEP_PERIOD): { - result = prepareSetAdcSweetPeriodCmd(commandData); - break; + case (PLOC_SPV::WATCHDOGS_CONFIG_TIMEOUT): { + result = prepareWatchdogsConfigTimeoutCmd(commandData); + break; } - case(PLOC_SPV::SET_ADC_ENABLED_CHANNELS): { - prepareSetAdcEnabledChannelsCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::ENABLE_LATCHUP_ALERT): { + result = prepareLatchupConfigCmd(commandData, deviceCommand); + break; } - case(PLOC_SPV::SET_ADC_WINDOW_AND_STRIDE): { - prepareSetAdcWindowAndStrideCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::DISABLE_LATCHUP_ALERT): { + result = prepareLatchupConfigCmd(commandData, deviceCommand); + break; } - case(PLOC_SPV::SET_ADC_THRESHOLD): { - prepareSetAdcThresholdCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::AUTO_CALIBRATE_ALERT): { + result = prepareAutoCalibrateAlertCmd(commandData); + break; } - case(PLOC_SPV::GET_LATCHUP_STATUS_REPORT): { - prepareEmptyCmd(PLOC_SPV::APID_GET_LATCHUP_STATUS_REPORT); - result = RETURN_OK; - break; + case (PLOC_SPV::SET_ALERT_LIMIT): { + result = prepareSetAlertLimitCmd(commandData); + break; } - case(PLOC_SPV::COPY_ADC_DATA_TO_MRAM): { - prepareEmptyCmd(PLOC_SPV::APID_COPY_ADC_DATA_TO_MRAM); - result = RETURN_OK; - break; + case (PLOC_SPV::SET_ALERT_IRQ_FILTER): { + result = prepareSetAlertIrqFilterCmd(commandData); + break; } - case(PLOC_SPV::ENABLE_NVMS): { - prepareEnableNvmsCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::SET_ADC_SWEEP_PERIOD): { + result = prepareSetAdcSweetPeriodCmd(commandData); + break; } - case(PLOC_SPV::SELECT_NVM): { - prepareSelectNvmCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::SET_ADC_ENABLED_CHANNELS): { + prepareSetAdcEnabledChannelsCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::RUN_AUTO_EM_TESTS): { - result = prepareRunAutoEmTest(commandData); - break; + case (PLOC_SPV::SET_ADC_WINDOW_AND_STRIDE): { + prepareSetAdcWindowAndStrideCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::WIPE_MRAM): { - result = prepareWipeMramCmd(commandData); - break; + case (PLOC_SPV::SET_ADC_THRESHOLD): { + prepareSetAdcThresholdCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::FIRST_MRAM_DUMP): - case(PLOC_SPV::CONSECUTIVE_MRAM_DUMP): - result = prepareDumpMramCmd(commandData); - break; - case(PLOC_SPV::PRINT_CPU_STATS): { - preparePrintCpuStatsCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::GET_LATCHUP_STATUS_REPORT): { + prepareEmptyCmd(PLOC_SPV::APID_GET_LATCHUP_STATUS_REPORT); + result = RETURN_OK; + break; } - case(PLOC_SPV::SET_DBG_VERBOSITY): { - prepareSetDbgVerbosityCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::COPY_ADC_DATA_TO_MRAM): { + prepareEmptyCmd(PLOC_SPV::APID_COPY_ADC_DATA_TO_MRAM); + result = RETURN_OK; + break; } - case(PLOC_SPV::CAN_LOOPBACK_TEST): { - prepareEmptyCmd(PLOC_SPV::APID_CAN_LOOPBACK_TEST); - result = RETURN_OK; - break; + case (PLOC_SPV::ENABLE_NVMS): { + prepareEnableNvmsCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::SET_GPIO): { - prepareSetGpioCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::SELECT_NVM): { + prepareSelectNvmCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::READ_GPIO): { - prepareReadGpioCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::RUN_AUTO_EM_TESTS): { + result = prepareRunAutoEmTest(commandData); + break; } - case(PLOC_SPV::RESTART_SUPERVISOR): { - prepareEmptyCmd(PLOC_SPV::APID_RESTART_SUPERVISOR); - result = RETURN_OK; - break; - } - case(PLOC_SPV::FACTORY_RESET_CLEAR_ALL): { - PLOC_SPV::FactoryReset packet(PLOC_SPV::FactoryReset::Op::CLEAR_ALL); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - result = RETURN_OK; - break; - } - case(PLOC_SPV::FACTORY_RESET_CLEAR_MIRROR): { - PLOC_SPV::FactoryReset packet(PLOC_SPV::FactoryReset::Op::MIRROR_ENTRIES); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - result = RETURN_OK; - break; - } - case(PLOC_SPV::FACTORY_RESET_CLEAR_CIRCULAR): { - PLOC_SPV::FactoryReset packet(PLOC_SPV::FactoryReset::Op::CIRCULAR_ENTRIES); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - result = RETURN_OK; - break; - } - case(PLOC_SPV::UPDATE_AVAILABLE): - case(PLOC_SPV::UPDATE_IMAGE_DATA): - case(PLOC_SPV::UPDATE_VERIFY): - // Simply forward data from PLOC Updater to supervisor - std::memcpy(commandBuffer, commandData, commandDataLen); - rawPacket = commandBuffer; - rawPacketLen = commandDataLen; - nextReplyId = PLOC_SPV::ACK_REPORT; - result = RETURN_OK; - break; - default: - sif::debug << "PlocSupervisorHandler::buildCommandFromCommand: Command not implemented" - << std::endl; - result = DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - break; - } - - if (result == RETURN_OK) { - /** - * Flushing the receive buffer to make sure there are no data left from a faulty reply. - */ - uartComIf->flushUartRxBuffer(comCookie); - } - - return result; -} - -void PlocSupervisorHandler::fillCommandAndReplyMap() { - this->insertInCommandMap(PLOC_SPV::GET_HK_REPORT); - this->insertInCommandMap(PLOC_SPV::RESTART_MPSOC); - this->insertInCommandMap(PLOC_SPV::START_MPSOC); - this->insertInCommandMap(PLOC_SPV::SHUTDOWN_MPSOC); - this->insertInCommandMap(PLOC_SPV::SEL_MPSOC_BOOT_IMAGE); - this->insertInCommandMap(PLOC_SPV::SET_BOOT_TIMEOUT); - this->insertInCommandMap(PLOC_SPV::SET_MAX_RESTART_TRIES); - this->insertInCommandMap(PLOC_SPV::RESET_MPSOC); - this->insertInCommandMap(PLOC_SPV::SET_TIME_REF); - this->insertInCommandMap(PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION); - this->insertInCommandMap(PLOC_SPV::GET_BOOT_STATUS_REPORT); - this->insertInCommandMap(PLOC_SPV::UPDATE_AVAILABLE); - this->insertInCommandMap(PLOC_SPV::UPDATE_VERIFY); - this->insertInCommandMap(PLOC_SPV::UPDATE_IMAGE_DATA); - this->insertInCommandMap(PLOC_SPV::WATCHDOGS_ENABLE); - this->insertInCommandMap(PLOC_SPV::WATCHDOGS_CONFIG_TIMEOUT); - this->insertInCommandMap(PLOC_SPV::ENABLE_LATCHUP_ALERT); - this->insertInCommandMap(PLOC_SPV::DISABLE_LATCHUP_ALERT); - this->insertInCommandMap(PLOC_SPV::AUTO_CALIBRATE_ALERT); - this->insertInCommandMap(PLOC_SPV::SET_ALERT_LIMIT); - this->insertInCommandMap(PLOC_SPV::SET_ALERT_IRQ_FILTER); - this->insertInCommandMap(PLOC_SPV::SET_ADC_SWEEP_PERIOD); - this->insertInCommandMap(PLOC_SPV::SET_ADC_ENABLED_CHANNELS); - this->insertInCommandMap(PLOC_SPV::SET_ADC_WINDOW_AND_STRIDE); - this->insertInCommandMap(PLOC_SPV::SET_ADC_THRESHOLD); - this->insertInCommandMap(PLOC_SPV::GET_LATCHUP_STATUS_REPORT); - this->insertInCommandMap(PLOC_SPV::COPY_ADC_DATA_TO_MRAM); - this->insertInCommandMap(PLOC_SPV::ENABLE_NVMS); - this->insertInCommandMap(PLOC_SPV::SELECT_NVM); - this->insertInCommandMap(PLOC_SPV::RUN_AUTO_EM_TESTS); - this->insertInCommandMap(PLOC_SPV::WIPE_MRAM); - this->insertInCommandMap(PLOC_SPV::PRINT_CPU_STATS); - this->insertInCommandMap(PLOC_SPV::SET_DBG_VERBOSITY); - this->insertInCommandMap(PLOC_SPV::SET_GPIO); - this->insertInCommandMap(PLOC_SPV::READ_GPIO); - this->insertInCommandMap(PLOC_SPV::RESTART_SUPERVISOR); - this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_ALL); - this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_MIRROR); - this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_CIRCULAR); - this->insertInCommandMap(PLOC_SPV::CAN_LOOPBACK_TEST); - this->insertInCommandAndReplyMap(PLOC_SPV::FIRST_MRAM_DUMP, 3); - this->insertInCommandAndReplyMap(PLOC_SPV::CONSECUTIVE_MRAM_DUMP, 3); - this->insertInReplyMap(PLOC_SPV::ACK_REPORT, 3, nullptr, PLOC_SPV::SIZE_ACK_REPORT); - this->insertInReplyMap(PLOC_SPV::EXE_REPORT, 3, nullptr, PLOC_SPV::SIZE_EXE_REPORT); - this->insertInReplyMap(PLOC_SPV::HK_REPORT, 3, &hkset, PLOC_SPV::SIZE_HK_REPORT); - this->insertInReplyMap(PLOC_SPV::BOOT_STATUS_REPORT, 3, &bootStatusReport, - PLOC_SPV::SIZE_BOOT_STATUS_REPORT); - this->insertInReplyMap(PLOC_SPV::LATCHUP_REPORT, 3, &latchupStatusReport, - PLOC_SPV::SIZE_LATCHUP_STATUS_REPORT); -} - -ReturnValue_t PlocSupervisorHandler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { - - if (nextReplyId == PLOC_SPV::FIRST_MRAM_DUMP) { - *foundId = PLOC_SPV::FIRST_MRAM_DUMP; - return parseMramPackets(start, remainingSize, foundLen); - } - else if (nextReplyId == PLOC_SPV::CONSECUTIVE_MRAM_DUMP) { - *foundId = PLOC_SPV::CONSECUTIVE_MRAM_DUMP; - return parseMramPackets(start, remainingSize, foundLen); - } - - ReturnValue_t result = RETURN_OK; - - uint16_t apid = (*(start) << 8 | *(start + 1)) & APID_MASK; - - switch(apid) { - case(PLOC_SPV::APID_ACK_SUCCESS): - *foundLen = PLOC_SPV::SIZE_ACK_REPORT; - *foundId = PLOC_SPV::ACK_REPORT; - break; - case(PLOC_SPV::APID_ACK_FAILURE): - *foundLen = PLOC_SPV::SIZE_ACK_REPORT; - *foundId = PLOC_SPV::ACK_REPORT; - break; - case(PLOC_SPV::APID_HK_REPORT): - *foundLen = PLOC_SPV::SIZE_HK_REPORT; - *foundId = PLOC_SPV::HK_REPORT; - break; - case(PLOC_SPV::APID_BOOT_STATUS_REPORT): - *foundLen = PLOC_SPV::SIZE_BOOT_STATUS_REPORT; - *foundId = PLOC_SPV::BOOT_STATUS_REPORT; - break; - case(PLOC_SPV::APID_LATCHUP_STATUS_REPORT): - *foundLen = PLOC_SPV::SIZE_LATCHUP_STATUS_REPORT; - *foundId = PLOC_SPV::LATCHUP_REPORT; - break; - case(PLOC_SPV::APID_EXE_SUCCESS): - *foundLen = PLOC_SPV::SIZE_EXE_REPORT; - *foundId = PLOC_SPV::EXE_REPORT; - break; - case(PLOC_SPV::APID_EXE_FAILURE): - *foundLen = PLOC_SPV::SIZE_EXE_REPORT; - *foundId = PLOC_SPV::EXE_REPORT; - break; - default: { - sif::debug << "PlocSupervisorHandler::scanForReply: Reply has invalid apid" << std::endl; - *foundLen = remainingSize; - return INVALID_APID; - } - } - - return result; -} - -ReturnValue_t PlocSupervisorHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { - - ReturnValue_t result = RETURN_OK; - - switch (id) { - case PLOC_SPV::ACK_REPORT: { - result = handleAckReport(packet); - break; - } - case (PLOC_SPV::HK_REPORT): { - result = handleHkReport(packet); - break; - } - case (PLOC_SPV::BOOT_STATUS_REPORT): { - result = handleBootStatusReport(packet); - break; - } - case (PLOC_SPV::LATCHUP_REPORT): { - result = handleLatchupStatusReport(packet); - break; + case (PLOC_SPV::WIPE_MRAM): { + result = prepareWipeMramCmd(commandData); + break; } case (PLOC_SPV::FIRST_MRAM_DUMP): case (PLOC_SPV::CONSECUTIVE_MRAM_DUMP): - result = handleMramDumpPacket(id); - break; + result = prepareDumpMramCmd(commandData); + break; + case (PLOC_SPV::PRINT_CPU_STATS): { + preparePrintCpuStatsCmd(commandData); + result = RETURN_OK; + break; + } + case (PLOC_SPV::SET_DBG_VERBOSITY): { + prepareSetDbgVerbosityCmd(commandData); + result = RETURN_OK; + break; + } + case (PLOC_SPV::CAN_LOOPBACK_TEST): { + prepareEmptyCmd(PLOC_SPV::APID_CAN_LOOPBACK_TEST); + result = RETURN_OK; + break; + } + case (PLOC_SPV::SET_GPIO): { + prepareSetGpioCmd(commandData); + result = RETURN_OK; + break; + } + case (PLOC_SPV::READ_GPIO): { + prepareReadGpioCmd(commandData); + result = RETURN_OK; + break; + } + case (PLOC_SPV::RESTART_SUPERVISOR): { + prepareEmptyCmd(PLOC_SPV::APID_RESTART_SUPERVISOR); + result = RETURN_OK; + break; + } + case (PLOC_SPV::FACTORY_RESET_CLEAR_ALL): { + PLOC_SPV::FactoryReset packet(PLOC_SPV::FactoryReset::Op::CLEAR_ALL); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + result = RETURN_OK; + break; + } + case (PLOC_SPV::FACTORY_RESET_CLEAR_MIRROR): { + PLOC_SPV::FactoryReset packet(PLOC_SPV::FactoryReset::Op::MIRROR_ENTRIES); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + result = RETURN_OK; + break; + } + case (PLOC_SPV::FACTORY_RESET_CLEAR_CIRCULAR): { + PLOC_SPV::FactoryReset packet(PLOC_SPV::FactoryReset::Op::CIRCULAR_ENTRIES); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + result = RETURN_OK; + break; + } + case (PLOC_SPV::UPDATE_AVAILABLE): + case (PLOC_SPV::UPDATE_IMAGE_DATA): + case (PLOC_SPV::UPDATE_VERIFY): + // Simply forward data from PLOC Updater to supervisor + std::memcpy(commandBuffer, commandData, commandDataLen); + rawPacket = commandBuffer; + rawPacketLen = commandDataLen; + nextReplyId = PLOC_SPV::ACK_REPORT; + result = RETURN_OK; + break; + default: + sif::debug << "PlocSupervisorHandler::buildCommandFromCommand: Command not implemented" + << std::endl; + result = DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + break; + } + + if (result == RETURN_OK) { + /** + * Flushing the receive buffer to make sure there are no data left from a faulty reply. + */ + uartComIf->flushUartRxBuffer(comCookie); + } + + return result; +} + +void PlocSupervisorHandler::fillCommandAndReplyMap() { + this->insertInCommandMap(PLOC_SPV::GET_HK_REPORT); + this->insertInCommandMap(PLOC_SPV::RESTART_MPSOC); + this->insertInCommandMap(PLOC_SPV::START_MPSOC); + this->insertInCommandMap(PLOC_SPV::SHUTDOWN_MPSOC); + this->insertInCommandMap(PLOC_SPV::SEL_MPSOC_BOOT_IMAGE); + this->insertInCommandMap(PLOC_SPV::SET_BOOT_TIMEOUT); + this->insertInCommandMap(PLOC_SPV::SET_MAX_RESTART_TRIES); + this->insertInCommandMap(PLOC_SPV::RESET_MPSOC); + this->insertInCommandMap(PLOC_SPV::SET_TIME_REF); + this->insertInCommandMap(PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION); + this->insertInCommandMap(PLOC_SPV::GET_BOOT_STATUS_REPORT); + this->insertInCommandMap(PLOC_SPV::UPDATE_AVAILABLE); + this->insertInCommandMap(PLOC_SPV::UPDATE_VERIFY); + this->insertInCommandMap(PLOC_SPV::UPDATE_IMAGE_DATA); + this->insertInCommandMap(PLOC_SPV::WATCHDOGS_ENABLE); + this->insertInCommandMap(PLOC_SPV::WATCHDOGS_CONFIG_TIMEOUT); + this->insertInCommandMap(PLOC_SPV::ENABLE_LATCHUP_ALERT); + this->insertInCommandMap(PLOC_SPV::DISABLE_LATCHUP_ALERT); + this->insertInCommandMap(PLOC_SPV::AUTO_CALIBRATE_ALERT); + this->insertInCommandMap(PLOC_SPV::SET_ALERT_LIMIT); + this->insertInCommandMap(PLOC_SPV::SET_ALERT_IRQ_FILTER); + this->insertInCommandMap(PLOC_SPV::SET_ADC_SWEEP_PERIOD); + this->insertInCommandMap(PLOC_SPV::SET_ADC_ENABLED_CHANNELS); + this->insertInCommandMap(PLOC_SPV::SET_ADC_WINDOW_AND_STRIDE); + this->insertInCommandMap(PLOC_SPV::SET_ADC_THRESHOLD); + this->insertInCommandMap(PLOC_SPV::GET_LATCHUP_STATUS_REPORT); + this->insertInCommandMap(PLOC_SPV::COPY_ADC_DATA_TO_MRAM); + this->insertInCommandMap(PLOC_SPV::ENABLE_NVMS); + this->insertInCommandMap(PLOC_SPV::SELECT_NVM); + this->insertInCommandMap(PLOC_SPV::RUN_AUTO_EM_TESTS); + this->insertInCommandMap(PLOC_SPV::WIPE_MRAM); + this->insertInCommandMap(PLOC_SPV::PRINT_CPU_STATS); + this->insertInCommandMap(PLOC_SPV::SET_DBG_VERBOSITY); + this->insertInCommandMap(PLOC_SPV::SET_GPIO); + this->insertInCommandMap(PLOC_SPV::READ_GPIO); + this->insertInCommandMap(PLOC_SPV::RESTART_SUPERVISOR); + this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_ALL); + this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_MIRROR); + this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_CIRCULAR); + this->insertInCommandMap(PLOC_SPV::CAN_LOOPBACK_TEST); + this->insertInCommandAndReplyMap(PLOC_SPV::FIRST_MRAM_DUMP, 3); + this->insertInCommandAndReplyMap(PLOC_SPV::CONSECUTIVE_MRAM_DUMP, 3); + this->insertInReplyMap(PLOC_SPV::ACK_REPORT, 3, nullptr, PLOC_SPV::SIZE_ACK_REPORT); + this->insertInReplyMap(PLOC_SPV::EXE_REPORT, 3, nullptr, PLOC_SPV::SIZE_EXE_REPORT); + this->insertInReplyMap(PLOC_SPV::HK_REPORT, 3, &hkset, PLOC_SPV::SIZE_HK_REPORT); + this->insertInReplyMap(PLOC_SPV::BOOT_STATUS_REPORT, 3, &bootStatusReport, + PLOC_SPV::SIZE_BOOT_STATUS_REPORT); + this->insertInReplyMap(PLOC_SPV::LATCHUP_REPORT, 3, &latchupStatusReport, + PLOC_SPV::SIZE_LATCHUP_STATUS_REPORT); +} + +ReturnValue_t PlocSupervisorHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + if (nextReplyId == PLOC_SPV::FIRST_MRAM_DUMP) { + *foundId = PLOC_SPV::FIRST_MRAM_DUMP; + return parseMramPackets(start, remainingSize, foundLen); + } else if (nextReplyId == PLOC_SPV::CONSECUTIVE_MRAM_DUMP) { + *foundId = PLOC_SPV::CONSECUTIVE_MRAM_DUMP; + return parseMramPackets(start, remainingSize, foundLen); + } + + ReturnValue_t result = RETURN_OK; + + uint16_t apid = (*(start) << 8 | *(start + 1)) & APID_MASK; + + switch (apid) { + case (PLOC_SPV::APID_ACK_SUCCESS): + *foundLen = PLOC_SPV::SIZE_ACK_REPORT; + *foundId = PLOC_SPV::ACK_REPORT; + break; + case (PLOC_SPV::APID_ACK_FAILURE): + *foundLen = PLOC_SPV::SIZE_ACK_REPORT; + *foundId = PLOC_SPV::ACK_REPORT; + break; + case (PLOC_SPV::APID_HK_REPORT): + *foundLen = PLOC_SPV::SIZE_HK_REPORT; + *foundId = PLOC_SPV::HK_REPORT; + break; + case (PLOC_SPV::APID_BOOT_STATUS_REPORT): + *foundLen = PLOC_SPV::SIZE_BOOT_STATUS_REPORT; + *foundId = PLOC_SPV::BOOT_STATUS_REPORT; + break; + case (PLOC_SPV::APID_LATCHUP_STATUS_REPORT): + *foundLen = PLOC_SPV::SIZE_LATCHUP_STATUS_REPORT; + *foundId = PLOC_SPV::LATCHUP_REPORT; + break; + case (PLOC_SPV::APID_EXE_SUCCESS): + *foundLen = PLOC_SPV::SIZE_EXE_REPORT; + *foundId = PLOC_SPV::EXE_REPORT; + break; + case (PLOC_SPV::APID_EXE_FAILURE): + *foundLen = PLOC_SPV::SIZE_EXE_REPORT; + *foundId = PLOC_SPV::EXE_REPORT; + break; + default: { + sif::debug << "PlocSupervisorHandler::scanForReply: Reply has invalid apid" << std::endl; + *foundLen = remainingSize; + return INVALID_APID; + } + } + + return result; +} + +ReturnValue_t PlocSupervisorHandler::interpretDeviceReply(DeviceCommandId_t id, + const uint8_t* packet) { + ReturnValue_t result = RETURN_OK; + + switch (id) { + case PLOC_SPV::ACK_REPORT: { + result = handleAckReport(packet); + break; + } + case (PLOC_SPV::HK_REPORT): { + result = handleHkReport(packet); + break; + } + case (PLOC_SPV::BOOT_STATUS_REPORT): { + result = handleBootStatusReport(packet); + break; + } + case (PLOC_SPV::LATCHUP_REPORT): { + result = handleLatchupStatusReport(packet); + break; + } + case (PLOC_SPV::FIRST_MRAM_DUMP): + case (PLOC_SPV::CONSECUTIVE_MRAM_DUMP): + result = handleMramDumpPacket(id); + break; case (PLOC_SPV::EXE_REPORT): { - result = handleExecutionReport(packet); - break; + result = handleExecutionReport(packet); + break; } default: { - sif::debug << "PlocSupervisorHandler::interpretDeviceReply: Unknown device reply id" << std::endl; - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } + sif::debug << "PlocSupervisorHandler::interpretDeviceReply: Unknown device reply id" + << std::endl; + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; } + } - return result; + return result; } -void PlocSupervisorHandler::setNormalDatapoolEntriesInvalid(){ +void PlocSupervisorHandler::setNormalDatapoolEntriesInvalid() {} -} - -uint32_t PlocSupervisorHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){ - return 500; -} +uint32_t PlocSupervisorHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } ReturnValue_t PlocSupervisorHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { + LocalDataPoolManager& poolManager) { + localDataPoolMap.emplace(PLOC_SPV::NUM_TMS, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::TEMP_PS, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::TEMP_PL, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::SOC_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::NVM0_1_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::NVM3_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::MISSION_IO_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::FMC_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::NUM_TCS, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CPULOAD, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::AVAILABLEHEAP, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::NUM_TMS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::TEMP_PS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::TEMP_PL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::SOC_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::NVM0_1_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::NVM3_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::MISSION_IO_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::FMC_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::NUM_TCS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::UPTIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CPULOAD, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::AVAILABLEHEAP, new PoolEntry( { 0 })); + localDataPoolMap.emplace(PLOC_SPV::BOOT_SIGNAL, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::RESET_COUNTER, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::BOOT_AFTER_MS, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::BOOT_TIMEOUT_MS, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::ACTIVE_NVM, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::BP0_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::BP1_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::BP2_STATE, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::BOOT_SIGNAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::RESET_COUNTER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::BOOT_AFTER_MS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::BOOT_TIMEOUT_MS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::ACTIVE_NVM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::BP0_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::BP1_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::BP2_STATE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_ID, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CNT0, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CNT1, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CNT2, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CNT3, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CNT4, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CNT5, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CNT6, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_SEC, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MIN, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_HOUR, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_DAY, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MON, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_YEAR, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MSEC, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_IS_SET, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_ID, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CNT0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CNT1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CNT2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CNT3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CNT4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CNT5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CNT6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_SEC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MIN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_HOUR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_DAY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MON, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_YEAR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MSEC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_IS_SET, new PoolEntry( { 0 })); - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command, - uint8_t expectedReplies, bool useAlternateId, - DeviceCommandId_t alternateReplyID) { + uint8_t expectedReplies, + bool useAlternateId, + DeviceCommandId_t alternateReplyID) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + uint8_t enabledReplies = 0; - uint8_t enabledReplies = 0; - - switch (command->first) { + switch (command->first) { case PLOC_SPV::GET_HK_REPORT: { - enabledReplies = 3; - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::HK_REPORT); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::HK_REPORT << " not in replyMap" << std::endl; - } - break; + enabledReplies = 3; + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_SPV::HK_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " + << PLOC_SPV::HK_REPORT << " not in replyMap" << std::endl; + } + break; } case PLOC_SPV::GET_BOOT_STATUS_REPORT: { - enabledReplies = 3; - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::BOOT_STATUS_REPORT); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::BOOT_STATUS_REPORT << " not in replyMap" << std::endl; - } - break; + enabledReplies = 3; + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_SPV::BOOT_STATUS_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " + << PLOC_SPV::BOOT_STATUS_REPORT << " not in replyMap" << std::endl; + } + break; } case PLOC_SPV::GET_LATCHUP_STATUS_REPORT: { - enabledReplies = 3; - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::LATCHUP_REPORT); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::LATCHUP_REPORT << " not in replyMap" << std::endl; - } - break; + enabledReplies = 3; + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_SPV::LATCHUP_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " + << PLOC_SPV::LATCHUP_REPORT << " not in replyMap" << std::endl; + } + break; } case PLOC_SPV::FIRST_MRAM_DUMP: { - enabledReplies = 2; // expected replies will be increased in handleMramDumpPacket - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::FIRST_MRAM_DUMP); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::FIRST_MRAM_DUMP << " not in replyMap" << std::endl; - } - break; + enabledReplies = 2; // expected replies will be increased in handleMramDumpPacket + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_SPV::FIRST_MRAM_DUMP); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " + << PLOC_SPV::FIRST_MRAM_DUMP << " not in replyMap" << std::endl; + } + break; } case PLOC_SPV::CONSECUTIVE_MRAM_DUMP: { - enabledReplies = 2; // expected replies will be increased in handleMramDumpPacket - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::CONSECUTIVE_MRAM_DUMP); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::CONSECUTIVE_MRAM_DUMP << " not in replyMap" << std::endl; - } - break; + enabledReplies = 2; // expected replies will be increased in handleMramDumpPacket + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_SPV::CONSECUTIVE_MRAM_DUMP); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " + << PLOC_SPV::CONSECUTIVE_MRAM_DUMP << " not in replyMap" << std::endl; + } + break; } case PLOC_SPV::RESTART_MPSOC: case PLOC_SPV::START_MPSOC: @@ -574,957 +564,948 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite case PLOC_SPV::FACTORY_RESET_CLEAR_CIRCULAR: case PLOC_SPV::REQUEST_LOGGING_DATA: case PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION: - enabledReplies = 2; - break; + enabledReplies = 2; + break; default: - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Unknown command id" << std::endl; - break; - } + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Unknown command id" << std::endl; + break; + } - /** - * Every command causes at least one acknowledgment and one execution report. Therefore both - * replies will be enabled here. - */ - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::ACK_REPORT); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::ACK_REPORT << " not in replyMap" << std::endl; - } + /** + * Every command causes at least one acknowledgment and one execution report. Therefore both + * replies will be enabled here. + */ + result = + DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, PLOC_SPV::ACK_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " + << PLOC_SPV::ACK_REPORT << " not in replyMap" << std::endl; + } - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::EXE_REPORT); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::EXE_REPORT << " not in replyMap" << std::endl; - } + result = + DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, PLOC_SPV::EXE_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " + << PLOC_SPV::EXE_REPORT << " not in replyMap" << std::endl; + } - return RETURN_OK; + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::verifyPacket(const uint8_t* start, size_t foundLen) { + uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1); - uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1); + uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2); - uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2); + if (receivedCrc != recalculatedCrc) { + return CRC_FAILURE; + } - if (receivedCrc != recalculatedCrc) { - return CRC_FAILURE; - } - - return RETURN_OK; + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::handleAckReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_SPV::SIZE_ACK_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocSupervisorHandler::handleAckReport: CRC failure" << std::endl; + nextReplyId = PLOC_SPV::NONE; + replyRawReplyIfnotWiretapped(data, PLOC_SPV::SIZE_ACK_REPORT); + triggerEvent(SUPV_CRC_FAILURE_EVENT); + sendFailureReport(PLOC_SPV::ACK_REPORT, CRC_FAILURE); + disableAllReplies(); + return RETURN_OK; + } - result = verifyPacket(data, PLOC_SPV::SIZE_ACK_REPORT); - if(result == CRC_FAILURE) { - sif::error << "PlocSupervisorHandler::handleAckReport: CRC failure" << std::endl; - nextReplyId = PLOC_SPV::NONE; - replyRawReplyIfnotWiretapped(data, PLOC_SPV::SIZE_ACK_REPORT); - triggerEvent(SUPV_CRC_FAILURE_EVENT); - sendFailureReport(PLOC_SPV::ACK_REPORT, CRC_FAILURE); - disableAllReplies(); - return RETURN_OK; + uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; + + switch (apid) { + case PLOC_SPV::APID_ACK_FAILURE: { + // TODO: Interpretation of status field in acknowledgment report + sif::debug << "PlocSupervisorHandler::handleAckReport: Received Ack failure report" + << std::endl; + DeviceCommandId_t commandId = getPendingCommand(); + if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { + triggerEvent(SUPV_ACK_FAILURE, commandId); + } + sendFailureReport(PLOC_SPV::ACK_REPORT, RECEIVED_ACK_FAILURE); + disableAllReplies(); + nextReplyId = PLOC_SPV::NONE; + result = IGNORE_REPLY_DATA; + break; } + case PLOC_SPV::APID_ACK_SUCCESS: { + setNextReplyId(); + break; + } + default: { + sif::debug << "PlocSupervisorHandler::handleAckReport: Invalid APID in Ack report" + << std::endl; + result = RETURN_FAILED; + break; + } + } - uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; - - switch(apid) { - case PLOC_SPV::APID_ACK_FAILURE: { - //TODO: Interpretation of status field in acknowledgment report - sif::debug << "PlocSupervisorHandler::handleAckReport: Received Ack failure report" << std::endl; - DeviceCommandId_t commandId = getPendingCommand(); - if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { - triggerEvent(SUPV_ACK_FAILURE, commandId); - } - sendFailureReport(PLOC_SPV::ACK_REPORT, RECEIVED_ACK_FAILURE); - disableAllReplies(); - nextReplyId = PLOC_SPV::NONE; - result = IGNORE_REPLY_DATA; - break; - } - case PLOC_SPV::APID_ACK_SUCCESS: { - setNextReplyId(); - break; - } - default: { - sif::debug << "PlocSupervisorHandler::handleAckReport: Invalid APID in Ack report" << std::endl; - result = RETURN_FAILED; - break; - } - } - - return result; + return result; } ReturnValue_t PlocSupervisorHandler::handleExecutionReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_SPV::SIZE_EXE_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocSupervisorHandler::handleExecutionReport: CRC failure" << std::endl; + nextReplyId = PLOC_SPV::NONE; + return result; + } - result = verifyPacket(data, PLOC_SPV::SIZE_EXE_REPORT); - if(result == CRC_FAILURE) { - sif::error << "PlocSupervisorHandler::handleExecutionReport: CRC failure" << std::endl; - nextReplyId = PLOC_SPV::NONE; - return result; - } + uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; - uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; - - switch (apid) { + switch (apid) { case (PLOC_SPV::APID_EXE_SUCCESS): { - break; + break; } case (PLOC_SPV::APID_EXE_FAILURE): { - //TODO: Interpretation of status field in execution report - sif::error << "PlocSupervisorHandler::handleExecutionReport: Received execution failure report" - << std::endl; - DeviceCommandId_t commandId = getPendingCommand(); - if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { - triggerEvent(SUPV_EXE_FAILURE, commandId); - } - else { - sif::debug << "PlocSupervisorHandler::handleExecutionReport: Unknown command id" << std::endl; - } - sendFailureReport(PLOC_SPV::EXE_REPORT, RECEIVED_EXE_FAILURE); - disableExeReportReply(); - result = IGNORE_REPLY_DATA; - break; + // TODO: Interpretation of status field in execution report + sif::error + << "PlocSupervisorHandler::handleExecutionReport: Received execution failure report" + << std::endl; + DeviceCommandId_t commandId = getPendingCommand(); + if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { + triggerEvent(SUPV_EXE_FAILURE, commandId); + } else { + sif::debug << "PlocSupervisorHandler::handleExecutionReport: Unknown command id" + << std::endl; + } + sendFailureReport(PLOC_SPV::EXE_REPORT, RECEIVED_EXE_FAILURE); + disableExeReportReply(); + result = IGNORE_REPLY_DATA; + break; } default: { - sif::error << "PlocSupervisorHandler::handleExecutionReport: Unknown APID" << std::endl; - result = RETURN_FAILED; - break; - } + sif::error << "PlocSupervisorHandler::handleExecutionReport: Unknown APID" << std::endl; + result = RETURN_FAILED; + break; } + } - nextReplyId = PLOC_SPV::NONE; + nextReplyId = PLOC_SPV::NONE; - return result; + return result; } ReturnValue_t PlocSupervisorHandler::handleHkReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_SPV::SIZE_HK_REPORT); - result = verifyPacket(data, PLOC_SPV::SIZE_HK_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocSupervisorHandler::handleHkReport: Hk report has invalid crc" << std::endl; + } - if(result == CRC_FAILURE) { - sif::error << "PlocSupervisorHandler::handleHkReport: Hk report has invalid crc" - << std::endl; - } + uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET; + hkset.tempPs = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 | + *(data + offset + 3); + offset += 4; + hkset.tempPl = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 | + *(data + offset + 3); + offset += 4; + hkset.tempSup = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 | + *(data + offset + 3); + offset += 4; + hkset.uptime = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 | + *(data + offset + 3); + offset += 4; + hkset.cpuLoad = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 | + *(data + offset + 3); + offset += 4; + hkset.availableHeap = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + hkset.numTcs = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 | + *(data + offset + 3); + offset += 4; + hkset.numTms = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 | + *(data + offset + 3); + offset += 4; + hkset.socState = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 | + *(data + offset + 3); + offset += 4; + hkset.nvm0_1_state = *(data + offset); + offset += 1; + hkset.nvm3_state = *(data + offset); + offset += 1; + hkset.missionIoState = *(data + offset); + offset += 1; + hkset.fmcState = *(data + offset); + offset += 1; - uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET; - hkset.tempPs = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 - | *(data + offset + 3); - offset += 4; - hkset.tempPl = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 - | *(data + offset + 3); - offset += 4; - hkset.tempSup = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 - | *(data + offset + 3); - offset += 4; - hkset.uptime = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 - | *(data + offset + 3); - offset += 4; - hkset.cpuLoad = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 - | *(data + offset + 3); - offset += 4; - hkset.availableHeap = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 - | *(data + offset + 3); - offset += 4; - hkset.numTcs = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 - | *(data + offset + 3); - offset += 4; - hkset.numTms = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 - | *(data + offset + 3); - offset += 4; - hkset.socState = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 - | *(data + offset + 3); - offset += 4; - hkset.nvm0_1_state = *(data + offset); - offset += 1; - hkset.nvm3_state = *(data + offset); - offset += 1; - hkset.missionIoState = *(data + offset); - offset += 1; - hkset.fmcState = *(data + offset); - offset += 1; - - nextReplyId = PLOC_SPV::EXE_REPORT; + nextReplyId = PLOC_SPV::EXE_REPORT; #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PLOC_SUPERVISOR == 1 - sif::info << "PlocSupervisorHandler::handleHkReport: temp_ps: " << hkset.tempPs << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: temp_pl: " << hkset.tempPl << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: temp_sup: " << hkset.tempSup << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: uptime: " << hkset.uptime << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: cpu_load: " << hkset.cpuLoad << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: available_heap: " << hkset.availableHeap << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: num_tcs: " << hkset.numTcs << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: num_tms: " << hkset.numTms << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: soc_state: " << hkset.socState << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: nvm0_1_state: " + sif::info << "PlocSupervisorHandler::handleHkReport: temp_ps: " << hkset.tempPs << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: temp_pl: " << hkset.tempPl << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: temp_sup: " << hkset.tempSup << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: uptime: " << hkset.uptime << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: cpu_load: " << hkset.cpuLoad << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: available_heap: " << hkset.availableHeap + << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: num_tcs: " << hkset.numTcs << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: num_tms: " << hkset.numTms << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: soc_state: " << hkset.socState << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: nvm0_1_state: " << static_cast(hkset.nvm0_1_state.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: nvm3_state: " + sif::info << "PlocSupervisorHandler::handleHkReport: nvm3_state: " << static_cast(hkset.nvm3_state.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: missoin_io_state: " + sif::info << "PlocSupervisorHandler::handleHkReport: missoin_io_state: " << static_cast(hkset.missionIoState.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: fmc_state: " + sif::info << "PlocSupervisorHandler::handleHkReport: fmc_state: " << static_cast(hkset.fmcState.value) << std::endl; #endif - return result; + return result; } ReturnValue_t PlocSupervisorHandler::handleBootStatusReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_SPV::SIZE_BOOT_STATUS_REPORT); - result = verifyPacket(data, PLOC_SPV::SIZE_BOOT_STATUS_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocSupervisorHandler::handleBootStatusReport: Boot status report has invalid" + " crc" + << std::endl; + return result; + } - if(result == CRC_FAILURE) { - sif::error << "PlocSupervisorHandler::handleBootStatusReport: Boot status report has invalid" - " crc" << std::endl; - return result; - } + uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET; + bootStatusReport.bootSignal = *(data + offset); + offset += 1; + bootStatusReport.resetCounter = *(data + offset); + offset += 1; + bootStatusReport.bootAfterMs = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + bootStatusReport.bootTimeoutMs = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + bootStatusReport.activeNvm = *(data + offset); + offset += 1; + bootStatusReport.bp0State = *(data + offset); + offset += 1; + bootStatusReport.bp1State = *(data + offset); + offset += 1; + bootStatusReport.bp2State = *(data + offset); - uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET; - bootStatusReport.bootSignal = *(data + offset); - offset += 1; - bootStatusReport.resetCounter = *(data + offset); - offset += 1; - bootStatusReport.bootAfterMs = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - bootStatusReport.bootTimeoutMs = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - bootStatusReport.activeNvm = *(data + offset); - offset += 1; - bootStatusReport.bp0State = *(data + offset); - offset += 1; - bootStatusReport.bp1State = *(data + offset); - offset += 1; - bootStatusReport.bp2State = *(data + offset); - - nextReplyId = PLOC_SPV::EXE_REPORT; + nextReplyId = PLOC_SPV::EXE_REPORT; #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PLOC_SUPERVISOR == 1 - sif::info << "PlocSupervisorHandler::handleBootStatusReport: Boot signal: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: Boot signal: " << static_cast(bootStatusReport.bootSignal.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleBootStatusReport: Reset counter: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: Reset counter: " << static_cast(bootStatusReport.resetCounter.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleBootStatusReport: BootAfterMs: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: BootAfterMs: " << bootStatusReport.bootAfterMs << " ms" << std::endl; - sif::info << "PlocSupervisorHandler::handleBootStatusReport: BootTimeoutMs: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: BootTimeoutMs: " << bootStatusReport.bootTimeoutMs << " ms" << std::endl; - sif::info << "PlocSupervisorHandler::handleBootStatusReport: Active NVM: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: Active NVM: " << static_cast(bootStatusReport.activeNvm.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP0: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP0: " << static_cast(bootStatusReport.bp0State.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP1: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP1: " << static_cast(bootStatusReport.bp1State.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP2: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP2: " << static_cast(bootStatusReport.bp2State.value) << std::endl; #endif - return result; + return result; } ReturnValue_t PlocSupervisorHandler::handleLatchupStatusReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_SPV::SIZE_LATCHUP_STATUS_REPORT); - result = verifyPacket(data, PLOC_SPV::SIZE_LATCHUP_STATUS_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocSupervisorHandler::handleLatchupStatusReport: Latchup status report has " + << "invalid crc" << std::endl; + return result; + } - if(result == CRC_FAILURE) { - sif::error << "PlocSupervisorHandler::handleLatchupStatusReport: Latchup status report has " - << "invalid crc" << std::endl; - return result; - } + uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET; + latchupStatusReport.id = *(data + offset); + offset += 1; + latchupStatusReport.cnt0 = *(data + offset) << 8 | *(data + offset + 1); + offset += 2; + latchupStatusReport.cnt1 = *(data + offset) << 8 | *(data + offset + 1); + offset += 2; + latchupStatusReport.cnt2 = *(data + offset) << 8 | *(data + offset + 1); + offset += 2; + latchupStatusReport.cnt3 = *(data + offset) << 8 | *(data + offset + 1); + offset += 2; + latchupStatusReport.cnt4 = *(data + offset) << 8 | *(data + offset + 1); + offset += 2; + latchupStatusReport.cnt5 = *(data + offset) << 8 | *(data + offset + 1); + offset += 2; + latchupStatusReport.cnt6 = *(data + offset) << 8 | *(data + offset + 1); + offset += 2; + latchupStatusReport.timeSec = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + latchupStatusReport.timeMin = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + latchupStatusReport.timeHour = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + latchupStatusReport.timeDay = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + latchupStatusReport.timeMon = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + latchupStatusReport.timeYear = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + latchupStatusReport.timeMsec = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + latchupStatusReport.isSet = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; - uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET; - latchupStatusReport.id = *(data + offset); - offset += 1; - latchupStatusReport.cnt0 = *(data + offset) << 8 | *(data + offset + 1); - offset += 2; - latchupStatusReport.cnt1 = *(data + offset) << 8 | *(data + offset + 1); - offset += 2; - latchupStatusReport.cnt2 = *(data + offset) << 8 | *(data + offset + 1); - offset += 2; - latchupStatusReport.cnt3 = *(data + offset) << 8 | *(data + offset + 1); - offset += 2; - latchupStatusReport.cnt4 = *(data + offset) << 8 | *(data + offset + 1); - offset += 2; - latchupStatusReport.cnt5 = *(data + offset) << 8 | *(data + offset + 1); - offset += 2; - latchupStatusReport.cnt6 = *(data + offset) << 8 | *(data + offset + 1); - offset += 2; - latchupStatusReport.timeSec = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - latchupStatusReport.timeMin = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - latchupStatusReport.timeHour = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - latchupStatusReport.timeDay = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - latchupStatusReport.timeMon = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - latchupStatusReport.timeYear = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - latchupStatusReport.timeMsec = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - latchupStatusReport.isSet = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - - nextReplyId = PLOC_SPV::EXE_REPORT; + nextReplyId = PLOC_SPV::EXE_REPORT; #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PLOC_SUPERVISOR == 1 - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Latchup ID: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Latchup ID: " << static_cast(latchupStatusReport.id.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT0: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT0: " << latchupStatusReport.cnt0 << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT1: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT1: " << latchupStatusReport.cnt1 << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT2: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT2: " << latchupStatusReport.cnt2 << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT3: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT3: " << latchupStatusReport.cnt3 << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT4: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT4: " << latchupStatusReport.cnt4 << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT5: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT5: " << latchupStatusReport.cnt5 << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT6: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT6: " << latchupStatusReport.cnt6 << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Sec: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Sec: " << latchupStatusReport.timeSec << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Min: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Min: " << latchupStatusReport.timeMin << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Hour: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Hour: " << latchupStatusReport.timeHour << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Day: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Day: " << latchupStatusReport.timeDay << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Mon: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Mon: " << latchupStatusReport.timeMon << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Year: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Year: " << latchupStatusReport.timeYear << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Msec: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Msec: " << latchupStatusReport.timeMsec << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: isSet: 0x" - << std::hex << latchupStatusReport.timeMsec << std::dec << std::endl; + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: isSet: 0x" << std::hex + << latchupStatusReport.timeMsec << std::dec << std::endl; #endif - return result; + return result; } void PlocSupervisorHandler::setNextReplyId() { - switch(getPendingCommand()) { + switch (getPendingCommand()) { case PLOC_SPV::GET_HK_REPORT: - nextReplyId = PLOC_SPV::HK_REPORT; - break; + nextReplyId = PLOC_SPV::HK_REPORT; + break; case PLOC_SPV::GET_BOOT_STATUS_REPORT: - nextReplyId = PLOC_SPV::BOOT_STATUS_REPORT; - break; + nextReplyId = PLOC_SPV::BOOT_STATUS_REPORT; + break; case PLOC_SPV::GET_LATCHUP_STATUS_REPORT: - nextReplyId = PLOC_SPV::LATCHUP_REPORT; - break; + nextReplyId = PLOC_SPV::LATCHUP_REPORT; + break; case PLOC_SPV::FIRST_MRAM_DUMP: - nextReplyId = PLOC_SPV::FIRST_MRAM_DUMP; - break; + nextReplyId = PLOC_SPV::FIRST_MRAM_DUMP; + break; case PLOC_SPV::CONSECUTIVE_MRAM_DUMP: - nextReplyId = PLOC_SPV::CONSECUTIVE_MRAM_DUMP; - break; + nextReplyId = PLOC_SPV::CONSECUTIVE_MRAM_DUMP; + break; default: - /* If no telemetry is expected the next reply is always the execution report */ - nextReplyId = PLOC_SPV::EXE_REPORT; - break; - } + /* If no telemetry is expected the next reply is always the execution report */ + nextReplyId = PLOC_SPV::EXE_REPORT; + break; + } } -size_t PlocSupervisorHandler::getNextReplyLength(DeviceCommandId_t commandId){ - - size_t replyLen = 0; - - if (nextReplyId == PLOC_SPV::NONE) { - return replyLen; - } - - if (nextReplyId == PLOC_SPV::FIRST_MRAM_DUMP - || nextReplyId == PLOC_SPV::CONSECUTIVE_MRAM_DUMP) { - /** - * Try to read 20 MRAM packets. If reply is larger, the packets will be read with the - * next doSendRead call. The command will be as long active as the packet with the sequence - * count indicating the last packet has not been received. - */ - replyLen = PLOC_SPV::MAX_PACKET_SIZE * 20; - return replyLen; - } - - DeviceReplyIter iter = deviceReplyMap.find(nextReplyId); - if (iter != deviceReplyMap.end()) { - if (iter->second.delayCycles == 0) { - /* Reply inactive */ - return replyLen; - } - replyLen = iter->second.replyLen; - } - else { - sif::debug << "PlocSupervisorHandler::getNextReplyLength: No entry for reply with reply id " - << std::hex << nextReplyId << " in deviceReplyMap" << std::endl; - } +size_t PlocSupervisorHandler::getNextReplyLength(DeviceCommandId_t commandId) { + size_t replyLen = 0; + if (nextReplyId == PLOC_SPV::NONE) { return replyLen; + } + + if (nextReplyId == PLOC_SPV::FIRST_MRAM_DUMP || nextReplyId == PLOC_SPV::CONSECUTIVE_MRAM_DUMP) { + /** + * Try to read 20 MRAM packets. If reply is larger, the packets will be read with the + * next doSendRead call. The command will be as long active as the packet with the sequence + * count indicating the last packet has not been received. + */ + replyLen = PLOC_SPV::MAX_PACKET_SIZE * 20; + return replyLen; + } + + DeviceReplyIter iter = deviceReplyMap.find(nextReplyId); + if (iter != deviceReplyMap.end()) { + if (iter->second.delayCycles == 0) { + /* Reply inactive */ + return replyLen; + } + replyLen = iter->second.replyLen; + } else { + sif::debug << "PlocSupervisorHandler::getNextReplyLength: No entry for reply with reply id " + << std::hex << nextReplyId << " in deviceReplyMap" << std::endl; + } + + return replyLen; } -void PlocSupervisorHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId) { +void PlocSupervisorHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, + DeviceCommandId_t replyId) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + if (wiretappingMode == RAW) { + /* Data already sent in doGetRead() */ + return; + } - if (wiretappingMode == RAW) { - /* Data already sent in doGetRead() */ - return; - } + DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId); + if (iter == deviceReplyMap.end()) { + sif::debug << "PlocSupervisorHandler::handleDeviceTM: Unknown reply id" << std::endl; + return; + } + MessageQueueId_t queueId = iter->second.command->second.sendReplyTo; - DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId); - if (iter == deviceReplyMap.end()) { - sif::debug << "PlocSupervisorHandler::handleDeviceTM: Unknown reply id" << std::endl; - return; - } - MessageQueueId_t queueId = iter->second.command->second.sendReplyTo; + if (queueId == NO_COMMANDER) { + return; + } - if (queueId == NO_COMMANDER) { - return; - } - - result = actionHelper.reportData(queueId, replyId, data, dataSize); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::handleDeviceTM: Failed to report data" << std::endl; - } + result = actionHelper.reportData(queueId, replyId, data, dataSize); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::handleDeviceTM: Failed to report data" << std::endl; + } } void PlocSupervisorHandler::prepareEmptyCmd(uint16_t apid) { - PLOC_SPV::EmptyPacket packet(apid); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + PLOC_SPV::EmptyPacket packet(apid); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } -void PlocSupervisorHandler::prepareSelBootImageCmd(const uint8_t * commandData) { - PLOC_SPV::MPSoCBootSelect packet(*commandData, *(commandData + 1), *(commandData + 2), - *(commandData + 3)); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); +void PlocSupervisorHandler::prepareSelBootImageCmd(const uint8_t* commandData) { + PLOC_SPV::MPSoCBootSelect packet(*commandData, *(commandData + 1), *(commandData + 2), + *(commandData + 3)); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } ReturnValue_t PlocSupervisorHandler::prepareSetTimeRefCmd() { - Clock::TimeOfDay_t time; - ReturnValue_t result = Clock::getDateAndTime(&time); - if (result != RETURN_OK) { - sif::warning << "PlocSupervisorHandler::prepareSetTimeRefCmd: Failed to get current time" - << std::endl; - return GET_TIME_FAILURE; - } - PLOC_SPV::SetTimeRef packet(&time); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; + Clock::TimeOfDay_t time; + ReturnValue_t result = Clock::getDateAndTime(&time); + if (result != RETURN_OK) { + sif::warning << "PlocSupervisorHandler::prepareSetTimeRefCmd: Failed to get current time" + << std::endl; + return GET_TIME_FAILURE; + } + PLOC_SPV::SetTimeRef packet(&time); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } void PlocSupervisorHandler::prepareDisableHk() { - PLOC_SPV::DisablePeriodicHkTransmission packet; - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + PLOC_SPV::DisablePeriodicHkTransmission packet; + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } -void PlocSupervisorHandler::prepareSetBootTimeoutCmd(const uint8_t * commandData) { - uint32_t timeout = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 - | *(commandData + 3); - PLOC_SPV::SetBootTimeout packet(timeout); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); +void PlocSupervisorHandler::prepareSetBootTimeoutCmd(const uint8_t* commandData) { + uint32_t timeout = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 | + *(commandData + 3); + PLOC_SPV::SetBootTimeout packet(timeout); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } -void PlocSupervisorHandler::prepareRestartTriesCmd(const uint8_t * commandData) { - uint8_t restartTries = *(commandData); - PLOC_SPV::SetRestartTries packet(restartTries); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); +void PlocSupervisorHandler::prepareRestartTriesCmd(const uint8_t* commandData) { + uint8_t restartTries = *(commandData); + PLOC_SPV::SetRestartTries packet(restartTries); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } -void PlocSupervisorHandler::prepareWatchdogsEnableCmd(const uint8_t * commandData) { - uint8_t offset = 0; - uint8_t watchdogPs = *(commandData + offset); - offset += 1; - uint8_t watchdogPl = *(commandData + offset); - offset += 1; - uint8_t watchdogInt = *(commandData + offset); - PLOC_SPV::WatchdogsEnable packet(watchdogPs, watchdogPl, watchdogInt); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); +void PlocSupervisorHandler::prepareWatchdogsEnableCmd(const uint8_t* commandData) { + uint8_t offset = 0; + uint8_t watchdogPs = *(commandData + offset); + offset += 1; + uint8_t watchdogPl = *(commandData + offset); + offset += 1; + uint8_t watchdogInt = *(commandData + offset); + PLOC_SPV::WatchdogsEnable packet(watchdogPs, watchdogPl, watchdogInt); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } -ReturnValue_t PlocSupervisorHandler::prepareWatchdogsConfigTimeoutCmd(const uint8_t * commandData) { - uint8_t offset = 0; - uint8_t watchdog = *(commandData + offset); - offset += 1; - if (watchdog > 2) { - return INVALID_WATCHDOG; - } - uint32_t timeout = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16 - | *(commandData + offset + 2) << 8 | *(commandData + offset + 3); - if (timeout < 1000 || timeout > 360000) { - return INVALID_WATCHDOG_TIMEOUT; - } - PLOC_SPV::WatchdogsConfigTimeout packet(watchdog, timeout); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; +ReturnValue_t PlocSupervisorHandler::prepareWatchdogsConfigTimeoutCmd(const uint8_t* commandData) { + uint8_t offset = 0; + uint8_t watchdog = *(commandData + offset); + offset += 1; + if (watchdog > 2) { + return INVALID_WATCHDOG; + } + uint32_t timeout = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16 | + *(commandData + offset + 2) << 8 | *(commandData + offset + 3); + if (timeout < 1000 || timeout > 360000) { + return INVALID_WATCHDOG_TIMEOUT; + } + PLOC_SPV::WatchdogsConfigTimeout packet(watchdog, timeout); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::prepareLatchupConfigCmd(const uint8_t* commandData, - DeviceCommandId_t deviceCommand) { - ReturnValue_t result = RETURN_OK; - uint8_t latchupId = *commandData; - if (latchupId > 6) { - return INVALID_LATCHUP_ID; - } - switch (deviceCommand) { + DeviceCommandId_t deviceCommand) { + ReturnValue_t result = RETURN_OK; + uint8_t latchupId = *commandData; + if (latchupId > 6) { + return INVALID_LATCHUP_ID; + } + switch (deviceCommand) { case (PLOC_SPV::ENABLE_LATCHUP_ALERT): { - PLOC_SPV::LatchupAlert packet(true, latchupId); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - break; + PLOC_SPV::LatchupAlert packet(true, latchupId); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + break; } case (PLOC_SPV::DISABLE_LATCHUP_ALERT): { - PLOC_SPV::LatchupAlert packet(false, latchupId); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - break; + PLOC_SPV::LatchupAlert packet(false, latchupId); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + break; } default: { - sif::debug << "PlocSupervisorHandler::prepareLatchupConfigCmd: Invalid command id" - << std::endl; - result = RETURN_FAILED; - break; + sif::debug << "PlocSupervisorHandler::prepareLatchupConfigCmd: Invalid command id" + << std::endl; + result = RETURN_FAILED; + break; } - } - return result; + } + return result; } ReturnValue_t PlocSupervisorHandler::prepareAutoCalibrateAlertCmd(const uint8_t* commandData) { - uint8_t offset = 0; - uint8_t latchupId = *commandData; - offset += 1; - uint32_t mg = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16 - | *(commandData + offset + 2) << 8 | *(commandData + offset + 3); - if (latchupId > 6) { - return INVALID_LATCHUP_ID; - } - PLOC_SPV::AutoCalibrateAlert packet(latchupId, mg); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; + uint8_t offset = 0; + uint8_t latchupId = *commandData; + offset += 1; + uint32_t mg = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16 | + *(commandData + offset + 2) << 8 | *(commandData + offset + 3); + if (latchupId > 6) { + return INVALID_LATCHUP_ID; + } + PLOC_SPV::AutoCalibrateAlert packet(latchupId, mg); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::prepareSetAlertIrqFilterCmd(const uint8_t* commandData) { - uint8_t latchupId = *commandData; - uint8_t tp = *(commandData + 1); - uint8_t div = *(commandData + 2); - if (latchupId > 6) { - return INVALID_LATCHUP_ID; - } - PLOC_SPV::SetAlertIrqFilter packet(latchupId, tp, div); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; + uint8_t latchupId = *commandData; + uint8_t tp = *(commandData + 1); + uint8_t div = *(commandData + 2); + if (latchupId > 6) { + return INVALID_LATCHUP_ID; + } + PLOC_SPV::SetAlertIrqFilter packet(latchupId, tp, div); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::prepareSetAlertLimitCmd(const uint8_t* commandData) { - uint8_t offset = 0; - uint8_t latchupId = *commandData; - offset += 1; - uint32_t dutycycle = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16 - | *(commandData + offset + 2) << 8 | *(commandData + offset + 3); - if (latchupId > 6) { - return INVALID_LATCHUP_ID; - } - PLOC_SPV::SetAlertlimit packet(latchupId, dutycycle); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; + uint8_t offset = 0; + uint8_t latchupId = *commandData; + offset += 1; + uint32_t dutycycle = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16 | + *(commandData + offset + 2) << 8 | *(commandData + offset + 3); + if (latchupId > 6) { + return INVALID_LATCHUP_ID; + } + PLOC_SPV::SetAlertlimit packet(latchupId, dutycycle); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::prepareSetAdcSweetPeriodCmd(const uint8_t* commandData) { - uint32_t sweepPeriod = *(commandData) << 24 | *(commandData + 1) << 16 - | *(commandData + 2) << 8 | *(commandData + 3); - if (sweepPeriod < 21) { - return SWEEP_PERIOD_TOO_SMALL; - } - PLOC_SPV::SetAdcSweepPeriod packet(sweepPeriod); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; + uint32_t sweepPeriod = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 | + *(commandData + 3); + if (sweepPeriod < 21) { + return SWEEP_PERIOD_TOO_SMALL; + } + PLOC_SPV::SetAdcSweepPeriod packet(sweepPeriod); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } void PlocSupervisorHandler::prepareSetAdcEnabledChannelsCmd(const uint8_t* commandData) { - uint16_t ch = *(commandData) << 8 | *(commandData + 1); - PLOC_SPV::SetAdcEnabledChannels packet(ch); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint16_t ch = *(commandData) << 8 | *(commandData + 1); + PLOC_SPV::SetAdcEnabledChannels packet(ch); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareSetAdcWindowAndStrideCmd(const uint8_t* commandData) { - uint8_t offset = 0; - uint16_t windowSize = *(commandData + offset) << 8 | *(commandData + offset + 1); - offset += 2; - uint16_t stridingStepSize = *(commandData + offset) << 8 | *(commandData + offset + 1); - PLOC_SPV::SetAdcWindowAndStride packet(windowSize, stridingStepSize); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint8_t offset = 0; + uint16_t windowSize = *(commandData + offset) << 8 | *(commandData + offset + 1); + offset += 2; + uint16_t stridingStepSize = *(commandData + offset) << 8 | *(commandData + offset + 1); + PLOC_SPV::SetAdcWindowAndStride packet(windowSize, stridingStepSize); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareSetAdcThresholdCmd(const uint8_t* commandData) { - uint32_t threshold = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 - | *(commandData + 3); - PLOC_SPV::SetAdcThreshold packet(threshold); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint32_t threshold = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 | + *(commandData + 3); + PLOC_SPV::SetAdcThreshold packet(threshold); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareEnableNvmsCmd(const uint8_t* commandData) { - uint8_t n01 = *commandData; - uint8_t n3 = *(commandData + 1); - PLOC_SPV::EnableNvms packet(n01, n3); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint8_t n01 = *commandData; + uint8_t n3 = *(commandData + 1); + PLOC_SPV::EnableNvms packet(n01, n3); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareSelectNvmCmd(const uint8_t* commandData) { - uint8_t mem = *commandData; - PLOC_SPV::SelectNvm packet(mem); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint8_t mem = *commandData; + PLOC_SPV::SelectNvm packet(mem); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } ReturnValue_t PlocSupervisorHandler::prepareRunAutoEmTest(const uint8_t* commandData) { - uint8_t test = *commandData; - if (test != 1 && test != 2) { - return INVALID_TEST_PARAM; - } - PLOC_SPV::RunAutoEmTests packet(test); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; + uint8_t test = *commandData; + if (test != 1 && test != 2) { + return INVALID_TEST_PARAM; + } + PLOC_SPV::RunAutoEmTests packet(test); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::prepareWipeMramCmd(const uint8_t* commandData) { - uint32_t start = 0; - uint32_t stop = 0; - size_t size = sizeof(start) + sizeof(stop); - SerializeAdapter::deSerialize(&start, &commandData, &size, SerializeIF::Endianness::BIG); - SerializeAdapter::deSerialize(&stop, &commandData, &size, SerializeIF::Endianness::BIG); - if ((stop - start) <= 0) { - return INVALID_MRAM_ADDRESSES; - } - PLOC_SPV::MramCmd packet(start, stop, PLOC_SPV::MramCmd::MramAction::WIPE); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; + uint32_t start = 0; + uint32_t stop = 0; + size_t size = sizeof(start) + sizeof(stop); + SerializeAdapter::deSerialize(&start, &commandData, &size, SerializeIF::Endianness::BIG); + SerializeAdapter::deSerialize(&stop, &commandData, &size, SerializeIF::Endianness::BIG); + if ((stop - start) <= 0) { + return INVALID_MRAM_ADDRESSES; + } + PLOC_SPV::MramCmd packet(start, stop, PLOC_SPV::MramCmd::MramAction::WIPE); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::prepareDumpMramCmd(const uint8_t* commandData) { - uint32_t start = 0; - uint32_t stop = 0; - size_t size = sizeof(start) + sizeof(stop); - SerializeAdapter::deSerialize(&start, &commandData, &size, SerializeIF::Endianness::BIG); - SerializeAdapter::deSerialize(&stop, &commandData, &size, SerializeIF::Endianness::BIG); - PLOC_SPV::MramCmd packet(start, stop, PLOC_SPV::MramCmd::MramAction::DUMP); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - if ((stop - start) <= 0) { - return INVALID_MRAM_ADDRESSES; - } - expectedMramDumpPackets = (stop - start) / PLOC_SPV::MAX_DATA_CAPACITY; - if ((stop - start) % PLOC_SPV::MAX_DATA_CAPACITY) { - expectedMramDumpPackets++; - } - receivedMramDumpPackets = 0; - return RETURN_OK; + uint32_t start = 0; + uint32_t stop = 0; + size_t size = sizeof(start) + sizeof(stop); + SerializeAdapter::deSerialize(&start, &commandData, &size, SerializeIF::Endianness::BIG); + SerializeAdapter::deSerialize(&stop, &commandData, &size, SerializeIF::Endianness::BIG); + PLOC_SPV::MramCmd packet(start, stop, PLOC_SPV::MramCmd::MramAction::DUMP); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + if ((stop - start) <= 0) { + return INVALID_MRAM_ADDRESSES; + } + expectedMramDumpPackets = (stop - start) / PLOC_SPV::MAX_DATA_CAPACITY; + if ((stop - start) % PLOC_SPV::MAX_DATA_CAPACITY) { + expectedMramDumpPackets++; + } + receivedMramDumpPackets = 0; + return RETURN_OK; } void PlocSupervisorHandler::preparePrintCpuStatsCmd(const uint8_t* commandData) { - uint8_t en = *commandData; - PLOC_SPV::PrintCpuStats packet(en); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint8_t en = *commandData; + PLOC_SPV::PrintCpuStats packet(en); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareSetDbgVerbosityCmd(const uint8_t* commandData) { - uint8_t vb = *commandData; - PLOC_SPV::SetDbgVerbosity packet(vb); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint8_t vb = *commandData; + PLOC_SPV::SetDbgVerbosity packet(vb); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareSetGpioCmd(const uint8_t* commandData) { - uint8_t port = *commandData; - uint8_t pin = *(commandData + 1); - uint8_t val = *(commandData + 2); - PLOC_SPV::SetGpio packet(port, pin, val); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint8_t port = *commandData; + uint8_t pin = *(commandData + 1); + uint8_t val = *(commandData + 2); + PLOC_SPV::SetGpio packet(port, pin, val); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareReadGpioCmd(const uint8_t* commandData) { - uint8_t port = *commandData; - uint8_t pin = *(commandData + 1); - PLOC_SPV::ReadGpio packet(port, pin); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint8_t port = *commandData; + uint8_t pin = *(commandData + 1); + PLOC_SPV::ReadGpio packet(port, pin); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::packetToOutBuffer(uint8_t* packetData, size_t fullSize) { - memcpy(commandBuffer, packetData, fullSize); - rawPacket = commandBuffer; - rawPacketLen = fullSize; - nextReplyId = PLOC_SPV::ACK_REPORT; + memcpy(commandBuffer, packetData, fullSize); + rawPacket = commandBuffer; + rawPacketLen = fullSize; + nextReplyId = PLOC_SPV::ACK_REPORT; } void PlocSupervisorHandler::disableAllReplies() { + DeviceReplyMap::iterator iter; - DeviceReplyMap::iterator iter; + /* Disable ack reply */ + iter = deviceReplyMap.find(PLOC_SPV::ACK_REPORT); + DeviceReplyInfo* info = &(iter->second); + info->delayCycles = 0; + info->command = deviceCommandMap.end(); - /* Disable ack reply */ - iter = deviceReplyMap.find(PLOC_SPV::ACK_REPORT); - DeviceReplyInfo *info = &(iter->second); - info->delayCycles = 0; - info->command = deviceCommandMap.end(); + DeviceCommandId_t commandId = getPendingCommand(); - DeviceCommandId_t commandId = getPendingCommand(); - - /* If the command expects a telemetry packet the appropriate tm reply will be disabled here */ - switch (commandId) { + /* If the command expects a telemetry packet the appropriate tm reply will be disabled here */ + switch (commandId) { case PLOC_SPV::GET_HK_REPORT: { - iter = deviceReplyMap.find(PLOC_SPV::GET_HK_REPORT); - info = &(iter->second); - info->delayCycles = 0; - info->command = deviceCommandMap.end(); - break; + iter = deviceReplyMap.find(PLOC_SPV::GET_HK_REPORT); + info = &(iter->second); + info->delayCycles = 0; + info->command = deviceCommandMap.end(); + break; } default: { - break; - } + break; } + } - /* We must always disable the execution report reply here */ - disableExeReportReply(); + /* We must always disable the execution report reply here */ + disableExeReportReply(); } void PlocSupervisorHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status) { + DeviceReplyIter iter = deviceReplyMap.find(replyId); - DeviceReplyIter iter = deviceReplyMap.find(replyId); + if (iter == deviceReplyMap.end()) { + sif::debug << "PlocSupervisorHandler::sendFailureReport: Reply not in reply map" << std::endl; + return; + } - if (iter == deviceReplyMap.end()) { - sif::debug << "PlocSupervisorHandler::sendFailureReport: Reply not in reply map" << std::endl; - return; - } + DeviceCommandInfo* info = &(iter->second.command->second); - DeviceCommandInfo* info = &(iter->second.command->second); + if (info == nullptr) { + sif::debug << "PlocSupervisorHandler::sendFailureReport: Reply has no active command" + << std::endl; + return; + } - if (info == nullptr) { - sif::debug << "PlocSupervisorHandler::sendFailureReport: Reply has no active command" << std::endl; - return; - } - - if (info->sendReplyTo != NO_COMMANDER) { - actionHelper.finish(false, info->sendReplyTo, iter->first, status); - } - info->isExecuting = false; + if (info->sendReplyTo != NO_COMMANDER) { + actionHelper.finish(false, info->sendReplyTo, iter->first, status); + } + info->isExecuting = false; } void PlocSupervisorHandler::disableExeReportReply() { - DeviceReplyIter iter = deviceReplyMap.find(PLOC_SPV::EXE_REPORT); - DeviceReplyInfo *info = &(iter->second); - info->delayCycles = 0; - info->command = deviceCommandMap.end(); - /* Expected replies is set to one here. The value will set to 0 in replyToReply() */ - info->command->second.expectedReplies = 1; + DeviceReplyIter iter = deviceReplyMap.find(PLOC_SPV::EXE_REPORT); + DeviceReplyInfo* info = &(iter->second); + info->delayCycles = 0; + info->command = deviceCommandMap.end(); + /* Expected replies is set to one here. The value will set to 0 in replyToReply() */ + info->command->second.expectedReplies = 1; } -ReturnValue_t PlocSupervisorHandler::parseMramPackets(const uint8_t *packet, size_t remainingSize, - size_t* foundLen) { - ReturnValue_t result = IGNORE_FULL_PACKET; - uint16_t packetLen = 0; - *foundLen = 0; +ReturnValue_t PlocSupervisorHandler::parseMramPackets(const uint8_t* packet, size_t remainingSize, + size_t* foundLen) { + ReturnValue_t result = IGNORE_FULL_PACKET; + uint16_t packetLen = 0; + *foundLen = 0; - for (size_t idx = 0; idx < remainingSize; idx++) { - std::memcpy(spacePacketBuffer + bufferTop, packet + idx, 1); - bufferTop += 1; - *foundLen += 1; - if (bufferTop >= PLOC_SPV::SPACE_PACKET_HEADER_LENGTH) { - packetLen = readSpacePacketLength(spacePacketBuffer); - } - - if (bufferTop == PLOC_SPV::SPACE_PACKET_HEADER_LENGTH + packetLen + 1) { - packetInBuffer = true; - bufferTop = 0; - return checkMramPacketApid(); - } - - if (bufferTop == PLOC_SPV::MAX_PACKET_SIZE) { - *foundLen = remainingSize; - disableAllReplies(); - bufferTop = 0; - return MRAM_PACKET_PARSING_FAILURE; - } + for (size_t idx = 0; idx < remainingSize; idx++) { + std::memcpy(spacePacketBuffer + bufferTop, packet + idx, 1); + bufferTop += 1; + *foundLen += 1; + if (bufferTop >= PLOC_SPV::SPACE_PACKET_HEADER_LENGTH) { + packetLen = readSpacePacketLength(spacePacketBuffer); } - return result; + if (bufferTop == PLOC_SPV::SPACE_PACKET_HEADER_LENGTH + packetLen + 1) { + packetInBuffer = true; + bufferTop = 0; + return checkMramPacketApid(); + } + + if (bufferTop == PLOC_SPV::MAX_PACKET_SIZE) { + *foundLen = remainingSize; + disableAllReplies(); + bufferTop = 0; + return MRAM_PACKET_PARSING_FAILURE; + } + } + + return result; } ReturnValue_t PlocSupervisorHandler::handleMramDumpPacket(DeviceCommandId_t id) { + ReturnValue_t result = RETURN_FAILED; - ReturnValue_t result = RETURN_FAILED; - - // Prepare packet for downlink - if (packetInBuffer) { - uint16_t packetLen = readSpacePacketLength(spacePacketBuffer); - result = verifyPacket(spacePacketBuffer, PLOC_SPV::SPACE_PACKET_HEADER_LENGTH + packetLen + 1); - if (result != RETURN_OK) { - sif::warning << "PlocSupervisorHandler::handleMramDumpPacket: CRC failure" << std::endl; - return result; - } - handleMramDumpFile(id); - if (downlinkMramDump == true) { - handleDeviceTM(spacePacketBuffer + PLOC_SPV::SPACE_PACKET_HEADER_LENGTH, packetLen - 1, - id); - } - packetInBuffer = false; - receivedMramDumpPackets++; - if (expectedMramDumpPackets == receivedMramDumpPackets) { - nextReplyId = PLOC_SPV::EXE_REPORT; - } - increaseExpectedMramReplies(id); - return RETURN_OK; + // Prepare packet for downlink + if (packetInBuffer) { + uint16_t packetLen = readSpacePacketLength(spacePacketBuffer); + result = verifyPacket(spacePacketBuffer, PLOC_SPV::SPACE_PACKET_HEADER_LENGTH + packetLen + 1); + if (result != RETURN_OK) { + sif::warning << "PlocSupervisorHandler::handleMramDumpPacket: CRC failure" << std::endl; + return result; } - return result; + handleMramDumpFile(id); + if (downlinkMramDump == true) { + handleDeviceTM(spacePacketBuffer + PLOC_SPV::SPACE_PACKET_HEADER_LENGTH, packetLen - 1, id); + } + packetInBuffer = false; + receivedMramDumpPackets++; + if (expectedMramDumpPackets == receivedMramDumpPackets) { + nextReplyId = PLOC_SPV::EXE_REPORT; + } + increaseExpectedMramReplies(id); + return RETURN_OK; + } + return result; } void PlocSupervisorHandler::increaseExpectedMramReplies(DeviceCommandId_t id) { - DeviceReplyMap::iterator mramDumpIter = deviceReplyMap.find(id); - DeviceReplyMap::iterator exeReportIter = deviceReplyMap.find(PLOC_SPV::EXE_REPORT); - if (mramDumpIter == deviceReplyMap.end()) { - sif::debug << "PlocSupervisorHandler::increaseExpectedMramReplies: Dump MRAM reply not " - << "in reply map" << std::endl; - return; - } - if (exeReportIter == deviceReplyMap.end()) { - sif::debug << "PlocSupervisorHandler::increaseExpectedMramReplies: Execution report not " - << "in reply map" << std::endl; - return; - } - DeviceReplyInfo *mramReplyInfo = &(mramDumpIter->second); - if (mramReplyInfo == nullptr) { - sif::debug << "PlocSupervisorHandler::increaseExpectedReplies: MRAM reply info nullptr" - << std::endl; - return; - } - DeviceReplyInfo *exeReplyInfo = &(exeReportIter->second); - if (exeReplyInfo == nullptr) { - sif::debug << "PlocSupervisorHandler::increaseExpectedReplies: Execution reply info" - << " nullptr" << std::endl; - return; - } - DeviceCommandInfo* info = &(mramReplyInfo->command->second); - if (info == nullptr){ - sif::debug << "PlocSupervisorHandler::increaseExpectedReplies: Command info nullptr" - << std::endl; - return; - } - uint8_t sequenceFlags = spacePacketBuffer[2] >> 6; - if (sequenceFlags != static_cast(PLOC_SPV::SequenceFlags::LAST_PKT) - && (sequenceFlags != static_cast(PLOC_SPV::SequenceFlags::STANDALONE_PKT))) { - // Command expects at least one MRAM packet more and the execution report - info->expectedReplies = 2; - // Wait maximum of 2 cycles for next MRAM packet - mramReplyInfo->delayCycles = 2; - // Also adapting delay cycles for execution report - exeReplyInfo->delayCycles = 3; - } - else { - // Command expects the execution report - info->expectedReplies = 1; - mramReplyInfo->delayCycles = 0; - } + DeviceReplyMap::iterator mramDumpIter = deviceReplyMap.find(id); + DeviceReplyMap::iterator exeReportIter = deviceReplyMap.find(PLOC_SPV::EXE_REPORT); + if (mramDumpIter == deviceReplyMap.end()) { + sif::debug << "PlocSupervisorHandler::increaseExpectedMramReplies: Dump MRAM reply not " + << "in reply map" << std::endl; return; + } + if (exeReportIter == deviceReplyMap.end()) { + sif::debug << "PlocSupervisorHandler::increaseExpectedMramReplies: Execution report not " + << "in reply map" << std::endl; + return; + } + DeviceReplyInfo* mramReplyInfo = &(mramDumpIter->second); + if (mramReplyInfo == nullptr) { + sif::debug << "PlocSupervisorHandler::increaseExpectedReplies: MRAM reply info nullptr" + << std::endl; + return; + } + DeviceReplyInfo* exeReplyInfo = &(exeReportIter->second); + if (exeReplyInfo == nullptr) { + sif::debug << "PlocSupervisorHandler::increaseExpectedReplies: Execution reply info" + << " nullptr" << std::endl; + return; + } + DeviceCommandInfo* info = &(mramReplyInfo->command->second); + if (info == nullptr) { + sif::debug << "PlocSupervisorHandler::increaseExpectedReplies: Command info nullptr" + << std::endl; + return; + } + uint8_t sequenceFlags = spacePacketBuffer[2] >> 6; + if (sequenceFlags != static_cast(PLOC_SPV::SequenceFlags::LAST_PKT) && + (sequenceFlags != static_cast(PLOC_SPV::SequenceFlags::STANDALONE_PKT))) { + // Command expects at least one MRAM packet more and the execution report + info->expectedReplies = 2; + // Wait maximum of 2 cycles for next MRAM packet + mramReplyInfo->delayCycles = 2; + // Also adapting delay cycles for execution report + exeReplyInfo->delayCycles = 3; + } else { + // Command expects the execution report + info->expectedReplies = 1; + mramReplyInfo->delayCycles = 0; + } + return; } ReturnValue_t PlocSupervisorHandler::checkMramPacketApid() { - uint16_t apid = (spacePacketBuffer[0] << 8 | spacePacketBuffer[1]) & PLOC_SPV::APID_MASK; - if (apid != PLOC_SPV::APID_MRAM_DUMP_TM) { - return NO_MRAM_PACKET; - } - return APERIODIC_REPLY; + uint16_t apid = (spacePacketBuffer[0] << 8 | spacePacketBuffer[1]) & PLOC_SPV::APID_MASK; + if (apid != PLOC_SPV::APID_MRAM_DUMP_TM) { + return NO_MRAM_PACKET; + } + return APERIODIC_REPLY; } ReturnValue_t PlocSupervisorHandler::handleMramDumpFile(DeviceCommandId_t id) { - ReturnValue_t result = RETURN_OK; - uint16_t packetLen = readSpacePacketLength(spacePacketBuffer); - uint8_t sequenceFlags = readSequenceFlags(spacePacketBuffer); - if (id == PLOC_SPV::FIRST_MRAM_DUMP) { - if (sequenceFlags == static_cast(PLOC_SPV::SequenceFlags::FIRST_PKT) - || (sequenceFlags == static_cast(PLOC_SPV::SequenceFlags::STANDALONE_PKT))) { - result = createMramDumpFile(); - if (result != RETURN_OK) { - return result; - } - } + ReturnValue_t result = RETURN_OK; + uint16_t packetLen = readSpacePacketLength(spacePacketBuffer); + uint8_t sequenceFlags = readSequenceFlags(spacePacketBuffer); + if (id == PLOC_SPV::FIRST_MRAM_DUMP) { + if (sequenceFlags == static_cast(PLOC_SPV::SequenceFlags::FIRST_PKT) || + (sequenceFlags == static_cast(PLOC_SPV::SequenceFlags::STANDALONE_PKT))) { + result = createMramDumpFile(); + if (result != RETURN_OK) { + return result; + } } - if (not std::filesystem::exists(activeMramFile)) { - sif::warning << "PlocSupervisorHandler::handleMramDumpFile: MRAM file does not exist" - << std::endl; - return MRAM_FILE_NOT_EXISTS; - } - std::ofstream file(activeMramFile, std::ios_base::app | std::ios_base::out); - file.write( - reinterpret_cast(spacePacketBuffer + PLOC_SPV::SPACE_PACKET_HEADER_LENGTH), - packetLen - 1); - file.close(); - return RETURN_OK; + } + if (not std::filesystem::exists(activeMramFile)) { + sif::warning << "PlocSupervisorHandler::handleMramDumpFile: MRAM file does not exist" + << std::endl; + return MRAM_FILE_NOT_EXISTS; + } + std::ofstream file(activeMramFile, std::ios_base::app | std::ios_base::out); + file.write( + reinterpret_cast(spacePacketBuffer + PLOC_SPV::SPACE_PACKET_HEADER_LENGTH), + packetLen - 1); + file.close(); + return RETURN_OK; } uint16_t PlocSupervisorHandler::readSpacePacketLength(uint8_t* spacePacket) { - return spacePacket[4] << 8 | spacePacket[5]; + return spacePacket[4] << 8 | spacePacket[5]; } uint8_t PlocSupervisorHandler::readSequenceFlags(uint8_t* spacePacket) { - return spacePacketBuffer[2] >> 6; + return spacePacketBuffer[2] >> 6; } ReturnValue_t PlocSupervisorHandler::createMramDumpFile() { - ReturnValue_t result = RETURN_OK; - std::string timeStamp; - result = getTimeStampString(timeStamp); - if (result != RETURN_OK) { - return result; - } + ReturnValue_t result = RETURN_OK; + std::string timeStamp; + result = getTimeStampString(timeStamp); + if (result != RETURN_OK) { + return result; + } - std::string filename = "mram-dump--" + timeStamp + ".bin"; + std::string filename = "mram-dump--" + timeStamp + ".bin"; #if BOARD_TE0720 == 0 - std::string currentMountPrefix = sdcMan->getCurrentMountPrefix(); + std::string currentMountPrefix = sdcMan->getCurrentMountPrefix(); #else - std::string currentMountPrefix("/mnt/sd0"); + std::string currentMountPrefix("/mnt/sd0"); #endif /* BOARD_TE0720 == 0 */ - // Check if path to PLOC directory exists - if (not std::filesystem::exists(std::string(currentMountPrefix + "/" + plocFilePath))) { - sif::warning << "PlocSupervisorHandler::createMramDumpFile: Ploc path does not exist" - << std::endl; - return PATH_DOES_NOT_EXIST; - } - activeMramFile = currentMountPrefix + "/" + plocFilePath + "/" + filename; - // Create new file - std::ofstream file(activeMramFile, std::ios_base::out); - file.close(); + // Check if path to PLOC directory exists + if (not std::filesystem::exists(std::string(currentMountPrefix + "/" + plocFilePath))) { + sif::warning << "PlocSupervisorHandler::createMramDumpFile: Ploc path does not exist" + << std::endl; + return PATH_DOES_NOT_EXIST; + } + activeMramFile = currentMountPrefix + "/" + plocFilePath + "/" + filename; + // Create new file + std::ofstream file(activeMramFile, std::ios_base::out); + file.close(); - return RETURN_OK; + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::getTimeStampString(std::string& timeStamp) { - Clock::TimeOfDay_t time; - ReturnValue_t result = Clock::getDateAndTime(&time); - if (result != RETURN_OK) { - sif::warning << "PlocSupervisorHandler::createMramDumpFile: Failed to get current time" - << std::endl; - return GET_TIME_FAILURE; - } - timeStamp = std::to_string(time.year) + "-" + std::to_string(time.month) + "-" - + std::to_string(time.day) + "--" + std::to_string(time.hour) + "-" - + std::to_string(time.minute) + "-" + std::to_string(time.second); - return RETURN_OK; + Clock::TimeOfDay_t time; + ReturnValue_t result = Clock::getDateAndTime(&time); + if (result != RETURN_OK) { + sif::warning << "PlocSupervisorHandler::createMramDumpFile: Failed to get current time" + << std::endl; + return GET_TIME_FAILURE; + } + timeStamp = std::to_string(time.year) + "-" + std::to_string(time.month) + "-" + + std::to_string(time.day) + "--" + std::to_string(time.hour) + "-" + + std::to_string(time.minute) + "-" + std::to_string(time.second); + return RETURN_OK; } diff --git a/bsp_q7s/devices/PlocSupervisorHandler.h b/bsp_q7s/devices/PlocSupervisorHandler.h index f22c86b1..986e5bbb 100644 --- a/bsp_q7s/devices/PlocSupervisorHandler.h +++ b/bsp_q7s/devices/PlocSupervisorHandler.h @@ -1,12 +1,12 @@ #ifndef MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_ #define MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_ -#include "devicedefinitions/PlocSupervisorDefinitions.h" #include - #include #include +#include "devicedefinitions/PlocSupervisorDefinitions.h" + /** * @brief This is the device handler for the supervisor of the PLOC which is programmed by * Thales. @@ -19,324 +19,327 @@ * Arbeitsdaten/08_Used%20Components/PLOC&fileid=940960 * @author J. Meier */ -class PlocSupervisorHandler: public DeviceHandlerBase { -public: +class PlocSupervisorHandler : public DeviceHandlerBase { + 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 ~PlocSupervisorHandler(); + virtual ReturnValue_t initialize() override; - 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: - void doStartUp() override; - void doShutDown() override; - ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; - ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override; - void fillCommandAndReplyMap() override; - ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t * commandData,size_t commandDataLen) override; - ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize, - DeviceCommandId_t *foundId, size_t *foundLen) override; - ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) override; - void setNormalDatapoolEntriesInvalid() override; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; - ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator command, - uint8_t expectedReplies = 1, bool useAlternateId = false, - DeviceCommandId_t alternateReplyID = 0) override; - size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_SUPERVISOR_HANDLER; -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] Invalid communication interface specified + static const ReturnValue_t INVALID_UART_COM_IF = MAKE_RETURN_CODE(0xA5); + //! [EXPORT] : [COMMENT] Received command with invalid watchdog parameter. Valid watchdogs are 0 + //! for PS, 1 for PL and 2 for INT + static const ReturnValue_t INVALID_WATCHDOG = MAKE_RETURN_CODE(0xA6); + //! [EXPORT] : [COMMENT] Received watchdog timeout config command with invalid timeout. Valid + //! timeouts must be in the range between 1000 and 360000 ms. + static const ReturnValue_t INVALID_WATCHDOG_TIMEOUT = MAKE_RETURN_CODE(0xA7); + //! [EXPORT] : [COMMENT] Received latchup config command with invalid latchup ID + static const ReturnValue_t INVALID_LATCHUP_ID = MAKE_RETURN_CODE(0xA8); + //! [EXPORT] : [COMMENT] Received set adc sweep period command with invalid sweep period. Must be + //! larger than 21. + static const ReturnValue_t SWEEP_PERIOD_TOO_SMALL = MAKE_RETURN_CODE(0xA9); + //! [EXPORT] : [COMMENT] Receive auto EM test command with invalid test param. Valid params are 1 + //! and 2. + static const ReturnValue_t INVALID_TEST_PARAM = MAKE_RETURN_CODE(0xAA); + //! [EXPORT] : [COMMENT] Returned when scanning for MRAM dump packets failed. + static const ReturnValue_t MRAM_PACKET_PARSING_FAILURE = MAKE_RETURN_CODE(0xAB); + //! [EXPORT] : [COMMENT] Returned when the start and stop addresses of the MRAM dump or MRAM wipe + //! commands are invalid (e.g. start address bigger than stop address) + static const ReturnValue_t INVALID_MRAM_ADDRESSES = MAKE_RETURN_CODE(0xAC); + //! [EXPORT] : [COMMENT] Expect reception of an MRAM dump packet but received space packet with + //! other apid. + static const ReturnValue_t NO_MRAM_PACKET = MAKE_RETURN_CODE(0xAD); + //! [EXPORT] : [COMMENT] Path to PLOC directory on SD card does not exist + static const ReturnValue_t PATH_DOES_NOT_EXIST = MAKE_RETURN_CODE(0xAE); + //! [EXPORT] : [COMMENT] MRAM dump file does not exists. The file should actually already have + //! been created with the reception of the first dump packet. + static const ReturnValue_t MRAM_FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xAF); - static 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 - 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] Invalid communication interface specified - static const ReturnValue_t INVALID_UART_COM_IF = MAKE_RETURN_CODE(0xA5); - //! [EXPORT] : [COMMENT] Received command with invalid watchdog parameter. Valid watchdogs are 0 for PS, 1 for PL and 2 for INT - static const ReturnValue_t INVALID_WATCHDOG = MAKE_RETURN_CODE(0xA6); - //! [EXPORT] : [COMMENT] Received watchdog timeout config command with invalid timeout. Valid timeouts must be in the range between 1000 and 360000 ms. - static const ReturnValue_t INVALID_WATCHDOG_TIMEOUT = MAKE_RETURN_CODE(0xA7); - //! [EXPORT] : [COMMENT] Received latchup config command with invalid latchup ID - static const ReturnValue_t INVALID_LATCHUP_ID = MAKE_RETURN_CODE(0xA8); - //! [EXPORT] : [COMMENT] Received set adc sweep period command with invalid sweep period. Must be larger than 21. - static const ReturnValue_t SWEEP_PERIOD_TOO_SMALL = MAKE_RETURN_CODE(0xA9); - //! [EXPORT] : [COMMENT] Receive auto EM test command with invalid test param. Valid params are 1 and 2. - static const ReturnValue_t INVALID_TEST_PARAM = MAKE_RETURN_CODE(0xAA); - //! [EXPORT] : [COMMENT] Returned when scanning for MRAM dump packets failed. - static const ReturnValue_t MRAM_PACKET_PARSING_FAILURE = MAKE_RETURN_CODE(0xAB); - //! [EXPORT] : [COMMENT] Returned when the start and stop addresses of the MRAM dump or MRAM wipe commands are invalid (e.g. start address bigger than stop address) - static const ReturnValue_t INVALID_MRAM_ADDRESSES = MAKE_RETURN_CODE(0xAC); - //! [EXPORT] : [COMMENT] Expect reception of an MRAM dump packet but received space packet with other apid. - static const ReturnValue_t NO_MRAM_PACKET = MAKE_RETURN_CODE(0xAD); - //! [EXPORT] : [COMMENT] Path to PLOC directory on SD card does not exist - static const ReturnValue_t PATH_DOES_NOT_EXIST = MAKE_RETURN_CODE(0xAE); - //! [EXPORT] : [COMMENT] MRAM dump file does not exists. The file should actually already have been created with the reception of the first dump packet. - static const ReturnValue_t MRAM_FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xAF); + //! [EXPORT] : [COMMENT] PLOC supervisor crc failure in telemetry packet + static const Event SUPV_MEMORY_READ_RPT_CRC_FAILURE = MAKE_EVENT(1, severity::LOW); + //! [EXPORT] : [COMMENT] 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 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 - 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); + uint8_t commandBuffer[PLOC_SPV::MAX_COMMAND_SIZE]; - 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; - /** - * This variable is used to store the id of the next reply to receive. This is necessary - * because the PLOC sends as reply to each command at least one acknowledgment and execution - * report. - */ - DeviceCommandId_t nextReplyId = PLOC_SPV::NONE; + PLOC_SPV::HkSet hkset; + PLOC_SPV::BootStatusReport bootStatusReport; + PLOC_SPV::LatchupStatusReport latchupStatusReport; - 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; - PLOC_SPV::BootStatusReport bootStatusReport; - 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]; + /** This buffer is used to concatenate space packets received in two different read steps */ + uint8_t spacePacketBuffer[PLOC_SPV::MAX_PACKET_SIZE]; #if BOARD_TE0720 == 0 - SdCardManager* sdcMan = nullptr; + SdCardManager* sdcMan = nullptr; #endif /* BOARD_TE0720 == 0 */ - /** Path to PLOC specific files on SD card */ - std::string plocFilePath = "ploc"; - std::string activeMramFile; + /** Path to PLOC specific files on SD card */ + std::string plocFilePath = "ploc"; + std::string activeMramFile; - /** Setting this variable to true will enable direct downlink of MRAM packets */ - bool downlinkMramDump = false; + /** Setting this variable to true will enable direct downlink of MRAM packets */ + bool downlinkMramDump = false; - /** - * @brief This function checks the crc of the received PLOC reply. - * - * @param start Pointer to the first byte of the reply. - * @param foundLen Pointer to the length of the whole packet. - * - * @return RETURN_OK if CRC is ok, otherwise CRC_FAILURE. - */ - ReturnValue_t verifyPacket(const uint8_t* start, size_t foundLen); + /** + * @brief This function checks the crc of the received PLOC reply. + * + * @param start Pointer to the first byte of the reply. + * @param foundLen Pointer to the length of the whole packet. + * + * @return RETURN_OK if CRC is ok, otherwise CRC_FAILURE. + */ + ReturnValue_t verifyPacket(const uint8_t* start, size_t foundLen); - /** - * @brief This function handles the acknowledgment report. - * - * @param data Pointer to the data holding the acknowledgment report. - * - * @return RETURN_OK if successful, otherwise an error code. - */ - ReturnValue_t handleAckReport(const uint8_t* data); + /** + * @brief This function handles the acknowledgment report. + * + * @param data Pointer to the data holding the acknowledgment report. + * + * @return RETURN_OK if successful, otherwise an error code. + */ + ReturnValue_t handleAckReport(const uint8_t* data); - /** - * @brief This function handles the data of a execution report. - * - * @param data Pointer to the received data packet. - * - * @return RETURN_OK if successful, otherwise an error code. - */ - ReturnValue_t handleExecutionReport(const uint8_t* data); + /** + * @brief This function handles the data of a execution report. + * + * @param data Pointer to the received data packet. + * + * @return RETURN_OK if successful, otherwise an error code. + */ + ReturnValue_t handleExecutionReport(const uint8_t* data); - /** - * @brief This function handles the housekeeping report. This means verifying the CRC of the - * reply and filling the appropriate dataset. - * - * @param data Pointer to the data buffer holding the housekeeping read report. - * - * @return RETURN_OK if successful, otherwise an error code. - */ - ReturnValue_t handleHkReport(const uint8_t* data); + /** + * @brief This function handles the housekeeping report. This means verifying the CRC of the + * reply and filling the appropriate dataset. + * + * @param data Pointer to the data buffer holding the housekeeping read report. + * + * @return RETURN_OK if successful, otherwise an error code. + */ + ReturnValue_t handleHkReport(const uint8_t* data); - /** - * @brief 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. - */ - ReturnValue_t handleBootStatusReport(const uint8_t* data); + /** + * @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. + */ + 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 - * next reply after a successful acknowledgment report has been received. This is - * required by the function getNextReplyLength() to identify the length of the next - * reply to read. - */ - void setNextReplyId(); + /** + * @brief Depending on the current active command, this function sets the reply id of the + * next reply after a successful acknowledgment report has been received. This is + * required by the function getNextReplyLength() to identify the length of the next + * reply to read. + */ + void setNextReplyId(); - /** - * @brief This function handles action message replies in case the telemetry has been - * requested by another object. - * - * @param data Pointer to the telemetry data. - * @param dataSize Size of telemetry in bytes. - * @param replyId Id of the reply. This will be added to the ActionMessage. - */ - void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); + /** + * @brief This function handles action message replies in case the telemetry has been + * requested by another object. + * + * @param data Pointer to the telemetry data. + * @param dataSize Size of telemetry in bytes. + * @param replyId Id of the reply. This will be added to the ActionMessage. + */ + void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); - /** - * @brief This function prepares a space packet which does not transport any data in the - * packet data field apart from the crc. - */ - void prepareEmptyCmd(uint16_t apid); + /** + * @brief This function prepares a space packet which does not transport any data in the + * packet data field apart from the crc. + */ + void prepareEmptyCmd(uint16_t apid); - /** - * @brief This function initializes the space packet to select the boot image of the MPSoC. - */ - void prepareSelBootImageCmd(const uint8_t * commandData); + /** + * @brief This function initializes the space packet to select the boot image of the MPSoC. + */ + 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 - * PLOC supervisor. - */ - ReturnValue_t prepareSetTimeRefCmd(); + /** + * @brief This function fills the commandBuffer with the data to update the time of the + * PLOC supervisor. + */ + ReturnValue_t prepareSetTimeRefCmd(); - /** - * @brief This function fills the commandBuffer with the data to change the boot timeout - * value in the PLOC supervisor. - */ - void prepareSetBootTimeoutCmd(const uint8_t * commandData); + /** + * @brief This function fills the commandBuffer with the data to change the boot timeout + * value in the PLOC supervisor. + */ + 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 - * watchdogs on the PLOC. - */ - void prepareWatchdogsEnableCmd(const uint8_t * commandData); + /** + * @brief This function fills the command buffer with the packet to enable or disable the + * watchdogs on the PLOC. + */ + void prepareWatchdogsEnableCmd(const uint8_t* commandData); - /** - * @brief This function fills the command buffer with the packet to set the watchdog timer - * of one of the three watchdogs (PS, PL, INT). - */ - ReturnValue_t prepareWatchdogsConfigTimeoutCmd(const uint8_t * commandData); + /** + * @brief This function fills the command buffer with the packet to set the watchdog timer + * of one of the three watchdogs (PS, PL, INT). + */ + ReturnValue_t prepareWatchdogsConfigTimeoutCmd(const uint8_t* commandData); - ReturnValue_t prepareLatchupConfigCmd(const uint8_t* commandData, - DeviceCommandId_t deviceCommand); - ReturnValue_t prepareAutoCalibrateAlertCmd(const uint8_t* commandData); - ReturnValue_t prepareSetAlertLimitCmd(const uint8_t* commandData); - ReturnValue_t prepareSetAlertIrqFilterCmd(const uint8_t* commandData); - ReturnValue_t prepareSetAdcSweetPeriodCmd(const uint8_t* commandData); - void prepareSetAdcEnabledChannelsCmd(const uint8_t* commandData); - void prepareSetAdcWindowAndStrideCmd(const uint8_t* commandData); - void prepareSetAdcThresholdCmd(const uint8_t* commandData); - void prepareEnableNvmsCmd(const uint8_t* commandData); - void prepareSelectNvmCmd(const uint8_t* commandData); - ReturnValue_t prepareRunAutoEmTest(const uint8_t* commandData); - ReturnValue_t prepareWipeMramCmd(const uint8_t* commandData); - ReturnValue_t prepareDumpMramCmd(const uint8_t* commandData); - void preparePrintCpuStatsCmd(const uint8_t* commandData); - void prepareSetDbgVerbosityCmd(const uint8_t* commandData); - void prepareSetGpioCmd(const uint8_t* commandData); - void prepareReadGpioCmd(const uint8_t* commandData); + ReturnValue_t prepareLatchupConfigCmd(const uint8_t* commandData, + DeviceCommandId_t deviceCommand); + ReturnValue_t prepareAutoCalibrateAlertCmd(const uint8_t* commandData); + ReturnValue_t prepareSetAlertLimitCmd(const uint8_t* commandData); + ReturnValue_t prepareSetAlertIrqFilterCmd(const uint8_t* commandData); + ReturnValue_t prepareSetAdcSweetPeriodCmd(const uint8_t* commandData); + void prepareSetAdcEnabledChannelsCmd(const uint8_t* commandData); + void prepareSetAdcWindowAndStrideCmd(const uint8_t* commandData); + void prepareSetAdcThresholdCmd(const uint8_t* commandData); + void prepareEnableNvmsCmd(const uint8_t* commandData); + void prepareSelectNvmCmd(const uint8_t* commandData); + ReturnValue_t prepareRunAutoEmTest(const uint8_t* commandData); + ReturnValue_t prepareWipeMramCmd(const uint8_t* commandData); + ReturnValue_t prepareDumpMramCmd(const uint8_t* commandData); + void preparePrintCpuStatsCmd(const uint8_t* commandData); + void prepareSetDbgVerbosityCmd(const uint8_t* commandData); + void prepareSetGpioCmd(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. - */ - void packetToOutBuffer(uint8_t* packetData, size_t fullSize); + /** + * @brief In case an acknowledgment failure reply has been received this function disables + * all previously enabled commands and resets the exepected replies variable of an + * active command. + */ + void disableAllReplies(); - /** - * @brief In case an acknowledgment failure reply has been received this function disables - * all previously enabled commands and resets the exepected replies variable of an - * active command. - */ - void disableAllReplies(); + /** + * @brief This function sends a failure report if the active action was commanded by an other + * object. + * + * @param replyId The id of the reply which signals a failure. + * @param status A status byte which gives information about the failure type. + */ + void sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status); - /** - * @brief This function sends a failure report if the active action was commanded by an other - * object. - * - * @param replyId The id of the reply which signals a failure. - * @param status A status byte which gives information about the failure type. - */ - void sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status); + /** + * @brief This function disables the execution report reply. Within this function also the + * the variable expectedReplies of an active command will be set to 0. + */ + void disableExeReportReply(); - /** - * @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(); + /** + * @brief Function is called in scanForReply and fills the spacePacketBuffer with the read + * data until a full packet has been received. + */ + 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 - * data until a full packet has been received. - */ - 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. + */ + ReturnValue_t handleMramDumpPacket(DeviceCommandId_t id); - /** - * @brief This function generates the Service 8 packets for the MRAM dump data. - */ - ReturnValue_t handleMramDumpPacket(DeviceCommandId_t id); + /** + * @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 + * have been received. + */ + void increaseExpectedMramReplies(DeviceCommandId_t id); - /** - * @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 - * have been received. - */ - void increaseExpectedMramReplies(DeviceCommandId_t id); + /** + * @brief Function checks if the packet written to the space packet buffer is really a + * MRAM dump packet. + */ + ReturnValue_t checkMramPacketApid(); - /** - * @brief Function checks if the packet written to the space packet buffer is really a - * MRAM dump packet. - */ - ReturnValue_t checkMramPacketApid(); + /** + * @brief Writes the data of the MRAM dump to a file. The file will be created when receiving + * the first packet. + */ + ReturnValue_t handleMramDumpFile(DeviceCommandId_t id); - /** - * @brief Writes the data of the MRAM dump to a file. The file will be created when receiving - * the first packet. - */ - ReturnValue_t handleMramDumpFile(DeviceCommandId_t id); + /** + * @brief Extracts the length field of a spacePacket referenced by the spacePacket pointer. + * + * @param spacePacket Pointer to the buffer holding the space packet. + * + * @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. - * - * @param spacePacket Pointer to the buffer holding the space packet. - * - * @return The value stored in the length field of the data field. - */ - uint16_t readSpacePacketLength(uint8_t* spacePacket); + /** + * @brief Extracts the sequence flags from a space packet referenced by the spacePacket + * 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); - /** - * @brief Extracts the sequence flags from a space packet referenced by the spacePacket - * 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); + ReturnValue_t createMramDumpFile(); + ReturnValue_t getTimeStampString(std::string& timeStamp); }; #endif /* MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_ */ diff --git a/bsp_q7s/devices/PlocUpdater.cpp b/bsp_q7s/devices/PlocUpdater.cpp index 592a2c0d..1478fbb8 100644 --- a/bsp_q7s/devices/PlocUpdater.cpp +++ b/bsp_q7s/devices/PlocUpdater.cpp @@ -1,405 +1,393 @@ -#include "fsfw/ipc/QueueFactory.h" #include "PlocUpdater.h" -#include #include +#include #include -PlocUpdater::PlocUpdater(object_id_t objectId) : - SystemObject(objectId), commandActionHelper(this), actionHelper(this, nullptr) { - commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); +#include "fsfw/ipc/QueueFactory.h" + +PlocUpdater::PlocUpdater(object_id_t objectId) + : SystemObject(objectId), commandActionHelper(this), actionHelper(this, nullptr) { + commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); } -PlocUpdater::~PlocUpdater() { -} +PlocUpdater::~PlocUpdater() {} ReturnValue_t PlocUpdater::initialize() { #if BOARD_TE0720 == 0 - sdcMan = SdCardManager::instance(); + sdcMan = SdCardManager::instance(); #endif - ReturnValue_t result = SystemObject::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - result = commandActionHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - result = actionHelper.initialize(commandQueue); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + ReturnValue_t result = SystemObject::initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = commandActionHelper.initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = actionHelper.initialize(commandQueue); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t PlocUpdater::performOperation(uint8_t operationCode) { - readCommandQueue(); - doStateMachine(); - return HasReturnvaluesIF::RETURN_OK; + readCommandQueue(); + doStateMachine(); + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t PlocUpdater::executeAction(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { - ReturnValue_t result = RETURN_FAILED; +ReturnValue_t PlocUpdater::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) { + ReturnValue_t result = RETURN_FAILED; - if (state != State::IDLE) { - return IS_BUSY; - } + if (state != State::IDLE) { + return IS_BUSY; + } - if (size > MAX_PLOC_UPDATE_PATH) { - return NAME_TOO_LONG; - } + if (size > MAX_PLOC_UPDATE_PATH) { + return NAME_TOO_LONG; + } - switch (actionId) { + switch (actionId) { case UPDATE_A_UBOOT: - image = Image::A; - partition = Partition::UBOOT; - break; + image = Image::A; + partition = Partition::UBOOT; + break; case UPDATE_A_BITSTREAM: - image = Image::A; - partition = Partition::BITSTREAM; - break; + image = Image::A; + partition = Partition::BITSTREAM; + break; case UPDATE_A_LINUX: - image = Image::A; - partition = Partition::LINUX_OS; - break; + image = Image::A; + partition = Partition::LINUX_OS; + break; case UPDATE_A_APP_SW: - image = Image::A; - partition = Partition::APP_SW; - break; + image = Image::A; + partition = Partition::APP_SW; + break; case UPDATE_B_UBOOT: - image = Image::B; - partition = Partition::UBOOT; - break; + image = Image::B; + partition = Partition::UBOOT; + break; case UPDATE_B_BITSTREAM: - image = Image::B; - partition = Partition::BITSTREAM; - break; + image = Image::B; + partition = Partition::BITSTREAM; + break; case UPDATE_B_LINUX: - image = Image::B; - partition = Partition::LINUX_OS; - break; + image = Image::B; + partition = Partition::LINUX_OS; + break; case UPDATE_B_APP_SW: - image = Image::B; - partition = Partition::APP_SW; - break; + image = Image::B; + partition = Partition::APP_SW; + break; default: - return INVALID_ACTION_ID; - } + return INVALID_ACTION_ID; + } - result = getImageLocation(data, size); + result = getImageLocation(data, size); - if (result != RETURN_OK) { - return result; - } + if (result != RETURN_OK) { + return result; + } - state = State::UPDATE_AVAILABLE; + state = State::UPDATE_AVAILABLE; - return EXECUTION_FINISHED; + return EXECUTION_FINISHED; } -MessageQueueId_t PlocUpdater::getCommandQueue() const { - return commandQueue->getId(); -} +MessageQueueId_t PlocUpdater::getCommandQueue() const { return commandQueue->getId(); } -MessageQueueIF* PlocUpdater::getCommandQueuePtr() { - return commandQueue; -} +MessageQueueIF* PlocUpdater::getCommandQueuePtr() { return commandQueue; } void PlocUpdater::readCommandQueue() { - CommandMessage message; - ReturnValue_t result; + CommandMessage message; + ReturnValue_t result; - for (result = commandQueue->receiveMessage(&message); result == HasReturnvaluesIF::RETURN_OK; - result = commandQueue->receiveMessage(&message)) { - if (result != RETURN_OK) { - continue; - } - result = actionHelper.handleActionMessage(&message); - if (result == HasReturnvaluesIF::RETURN_OK) { - continue; - } - - result = commandActionHelper.handleReply(&message); - if (result == HasReturnvaluesIF::RETURN_OK) { - continue; - } - - sif::debug << "PlocUpdater::readCommandQueue: Received message with invalid format" - << std::endl; + for (result = commandQueue->receiveMessage(&message); result == HasReturnvaluesIF::RETURN_OK; + result = commandQueue->receiveMessage(&message)) { + if (result != RETURN_OK) { + continue; } + result = actionHelper.handleActionMessage(&message); + if (result == HasReturnvaluesIF::RETURN_OK) { + continue; + } + + result = commandActionHelper.handleReply(&message); + if (result == HasReturnvaluesIF::RETURN_OK) { + continue; + } + + sif::debug << "PlocUpdater::readCommandQueue: Received message with invalid format" + << std::endl; + } } void PlocUpdater::doStateMachine() { - switch (state) { + switch (state) { case State::IDLE: - break; + break; case State::UPDATE_AVAILABLE: - commandUpdateAvailable(); - break; + commandUpdateAvailable(); + break; case State::UPDATE_TRANSFER: - commandUpdatePacket(); - break; + commandUpdatePacket(); + break; case State::UPDATE_VERIFY: - commandUpdateVerify(); - break; + commandUpdateVerify(); + break; case State::COMMAND_EXECUTING: - break; + break; default: - sif::debug << "PlocUpdater::doStateMachine: Invalid state" << std::endl; - break; - } + sif::debug << "PlocUpdater::doStateMachine: Invalid state" << std::endl; + break; + } } ReturnValue_t PlocUpdater::checkNameLength(size_t size) { - if (size > MAX_PLOC_UPDATE_PATH) { - return NAME_TOO_LONG; - } - return RETURN_OK; + if (size > MAX_PLOC_UPDATE_PATH) { + return NAME_TOO_LONG; + } + return RETURN_OK; } ReturnValue_t PlocUpdater::getImageLocation(const uint8_t* data, size_t size) { - ReturnValue_t result = checkNameLength(size); - if (result != RETURN_OK) { - return result; - } + ReturnValue_t result = checkNameLength(size); + if (result != RETURN_OK) { + return result; + } #if BOARD_TE0720 == 0 - // Check if file is stored on SD card and if associated SD card is mounted - if (std::string(reinterpret_cast(data), SD_PREFIX_LENGTH) == std::string(SdCardManager::SD_0_MOUNT_POINT)) { - if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { - sif::warning << "PlocUpdater::getImageLocation: SD card 0 not mounted" << std::endl; - return SD_NOT_MOUNTED; - } + // Check if file is stored on SD card and if associated SD card is mounted + if (std::string(reinterpret_cast(data), SD_PREFIX_LENGTH) == + std::string(SdCardManager::SD_0_MOUNT_POINT)) { + if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { + sif::warning << "PlocUpdater::getImageLocation: SD card 0 not mounted" << std::endl; + return SD_NOT_MOUNTED; } - else if (std::string(reinterpret_cast(data), SD_PREFIX_LENGTH) == std::string(SdCardManager::SD_1_MOUNT_POINT)) { - if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { - sif::warning << "PlocUpdater::getImageLocation: SD card 1 not mounted" << std::endl; - return SD_NOT_MOUNTED; - } - } - else { - //update image not stored on SD card + } else if (std::string(reinterpret_cast(data), SD_PREFIX_LENGTH) == + std::string(SdCardManager::SD_1_MOUNT_POINT)) { + if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { + sif::warning << "PlocUpdater::getImageLocation: SD card 1 not mounted" << std::endl; + return SD_NOT_MOUNTED; } + } else { + // update image not stored on SD card + } #endif /* BOARD_TE0720 == 0 */ - updateFile = std::string(reinterpret_cast(data), size); + updateFile = std::string(reinterpret_cast(data), size); - // Check if file exists - if(not std::filesystem::exists(updateFile)) { - return FILE_NOT_EXISTS; - } - return RETURN_OK; + // Check if file exists + if (not std::filesystem::exists(updateFile)) { + return FILE_NOT_EXISTS; + } + return RETURN_OK; } -void PlocUpdater::stepSuccessfulReceived(ActionId_t actionId, - uint8_t step) { -} +void PlocUpdater::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) {} -void PlocUpdater::stepFailedReceived(ActionId_t actionId, uint8_t step, - ReturnValue_t returnCode) { -} +void PlocUpdater::stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) {} -void PlocUpdater::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) { - -} +void PlocUpdater::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) {} void PlocUpdater::completionSuccessfulReceived(ActionId_t actionId) { - switch (pendingCommand) { + switch (pendingCommand) { case (PLOC_SPV::UPDATE_AVAILABLE): - state = State::UPDATE_TRANSFER; - break; + state = State::UPDATE_TRANSFER; + break; case (PLOC_SPV::UPDATE_IMAGE_DATA): - if (remainingPackets == 0) { - packetsSent = 0; // Reset packets sent variable for next update sequence - state = State::UPDATE_VERIFY; - } - else { - state = State::UPDATE_TRANSFER; - } - break; + if (remainingPackets == 0) { + packetsSent = 0; // Reset packets sent variable for next update sequence + state = State::UPDATE_VERIFY; + } else { + state = State::UPDATE_TRANSFER; + } + break; case (PLOC_SPV::UPDATE_VERIFY): - triggerEvent(UPDATE_FINISHED); - state = State::IDLE; - pendingCommand = PLOC_SPV::NONE; - break; + triggerEvent(UPDATE_FINISHED); + state = State::IDLE; + pendingCommand = PLOC_SPV::NONE; + break; default: - sif::debug << "PlocUpdater::completionSuccessfulReceived: Invalid pending command" - << std::endl; - state = State::IDLE; - break; - } + sif::debug << "PlocUpdater::completionSuccessfulReceived: Invalid pending command" + << std::endl; + state = State::IDLE; + break; + } } -void PlocUpdater::completionFailedReceived(ActionId_t actionId, - ReturnValue_t returnCode) { - switch(pendingCommand) { - case(PLOC_SPV::UPDATE_AVAILABLE): { - triggerEvent(UPDATE_AVAILABLE_FAILED); - break; +void PlocUpdater::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) { + switch (pendingCommand) { + case (PLOC_SPV::UPDATE_AVAILABLE): { + triggerEvent(UPDATE_AVAILABLE_FAILED); + break; } - case(PLOC_SPV::UPDATE_IMAGE_DATA): { - triggerEvent(UPDATE_TRANSFER_FAILED, packetsSent); - break; + case (PLOC_SPV::UPDATE_IMAGE_DATA): { + triggerEvent(UPDATE_TRANSFER_FAILED, packetsSent); + break; } - case(PLOC_SPV::UPDATE_VERIFY): { - triggerEvent(UPDATE_VERIFY_FAILED); - break; + case (PLOC_SPV::UPDATE_VERIFY): { + triggerEvent(UPDATE_VERIFY_FAILED); + break; } default: - sif::debug << "PlocUpdater::completionFailedReceived: Invalid pending command " - << std::endl; - break; - } - state = State::IDLE; + sif::debug << "PlocUpdater::completionFailedReceived: Invalid pending command " << std::endl; + break; + } + state = State::IDLE; } void PlocUpdater::commandUpdateAvailable() { - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = RETURN_OK; - if (not std::filesystem::exists(updateFile)) { - triggerEvent(UPDATE_FILE_NOT_EXISTS, static_cast(state)); - state = State::IDLE; - return; - } - - std::ifstream file(updateFile, std::ifstream::binary); - file.seekg(0, file.end); - imageSize = static_cast(file.tellg()); - file.close(); - - numOfUpdatePackets = imageSize / MAX_SP_DATA ; - if (imageSize % MAX_SP_DATA) { - numOfUpdatePackets++; - } - - remainingPackets = numOfUpdatePackets; - packetsSent = 0; - - calcImageCrc(); - - PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_AVAILABLE, static_cast(image), - static_cast(partition), imageSize, imageCrc, numOfUpdatePackets); - - result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, - PLOC_SPV::UPDATE_AVAILABLE, packet.getWholeData(), packet.getFullSize()); - if (result != RETURN_OK) { - sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update available" - << " packet to supervisor handler" << std::endl; - triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_AVAILABLE); - state = State::IDLE; - pendingCommand = PLOC_SPV::NONE; - return; - } - - pendingCommand = PLOC_SPV::UPDATE_AVAILABLE; - state = State::COMMAND_EXECUTING; + if (not std::filesystem::exists(updateFile)) { + triggerEvent(UPDATE_FILE_NOT_EXISTS, static_cast(state)); + state = State::IDLE; return; + } + + std::ifstream file(updateFile, std::ifstream::binary); + file.seekg(0, file.end); + imageSize = static_cast(file.tellg()); + file.close(); + + numOfUpdatePackets = imageSize / MAX_SP_DATA; + if (imageSize % MAX_SP_DATA) { + numOfUpdatePackets++; + } + + remainingPackets = numOfUpdatePackets; + packetsSent = 0; + + calcImageCrc(); + + PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_AVAILABLE, static_cast(image), + static_cast(partition), imageSize, imageCrc, + numOfUpdatePackets); + + result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, + PLOC_SPV::UPDATE_AVAILABLE, packet.getWholeData(), + packet.getFullSize()); + if (result != RETURN_OK) { + sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update available" + << " packet to supervisor handler" << std::endl; + triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_AVAILABLE); + state = State::IDLE; + pendingCommand = PLOC_SPV::NONE; + return; + } + + pendingCommand = PLOC_SPV::UPDATE_AVAILABLE; + state = State::COMMAND_EXECUTING; + return; } void PlocUpdater::commandUpdatePacket() { - ReturnValue_t result = RETURN_OK; - uint16_t payloadLength = 0; + ReturnValue_t result = RETURN_OK; + uint16_t payloadLength = 0; - if (not std::filesystem::exists(updateFile)) { - triggerEvent(UPDATE_FILE_NOT_EXISTS, static_cast(state), packetsSent); - state = State::IDLE; - return; - } + if (not std::filesystem::exists(updateFile)) { + triggerEvent(UPDATE_FILE_NOT_EXISTS, static_cast(state), packetsSent); + state = State::IDLE; + return; + } - std::ifstream file(updateFile, std::ifstream::binary); - file.seekg(packetsSent * MAX_SP_DATA, file.beg); + std::ifstream file(updateFile, std::ifstream::binary); + file.seekg(packetsSent * MAX_SP_DATA, file.beg); - if (remainingPackets == 1) { - payloadLength = imageSize - static_cast(file.tellg()); - } - else { - payloadLength = MAX_SP_DATA; - } + if (remainingPackets == 1) { + payloadLength = imageSize - static_cast(file.tellg()); + } else { + payloadLength = MAX_SP_DATA; + } - PLOC_SPV::UpdatePacket packet(payloadLength); - file.read(reinterpret_cast(packet.getDataFieldPointer()), payloadLength); - file.close(); - // sequence count of first packet is 1 - packet.setPacketSequenceCount((packetsSent + 1) & PLOC_SPV::SEQUENCE_COUNT_MASK); - if (numOfUpdatePackets > 1) { - adjustSequenceFlags(packet); - } - packet.makeCrc(); + PLOC_SPV::UpdatePacket packet(payloadLength); + file.read(reinterpret_cast(packet.getDataFieldPointer()), payloadLength); + file.close(); + // sequence count of first packet is 1 + packet.setPacketSequenceCount((packetsSent + 1) & PLOC_SPV::SEQUENCE_COUNT_MASK); + if (numOfUpdatePackets > 1) { + adjustSequenceFlags(packet); + } + packet.makeCrc(); - result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, - PLOC_SPV::UPDATE_IMAGE_DATA, packet.getWholeData(), packet.getFullSize()); + result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, + PLOC_SPV::UPDATE_IMAGE_DATA, packet.getWholeData(), + packet.getFullSize()); - if (result != RETURN_OK) { - sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update" - << " packet to supervisor handler" << std::endl; - triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_IMAGE_DATA); - state = State::IDLE; - pendingCommand = PLOC_SPV::NONE; - return; - } + if (result != RETURN_OK) { + sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update" + << " packet to supervisor handler" << std::endl; + triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_IMAGE_DATA); + state = State::IDLE; + pendingCommand = PLOC_SPV::NONE; + return; + } - remainingPackets--; - packetsSent++; + remainingPackets--; + packetsSent++; - pendingCommand = PLOC_SPV::UPDATE_IMAGE_DATA; - state = State::COMMAND_EXECUTING; + pendingCommand = PLOC_SPV::UPDATE_IMAGE_DATA; + state = State::COMMAND_EXECUTING; } void PlocUpdater::commandUpdateVerify() { - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = RETURN_OK; - PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_VERIFY, static_cast(image), - static_cast(partition), imageSize, imageCrc, numOfUpdatePackets); + PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_VERIFY, static_cast(image), + static_cast(partition), imageSize, imageCrc, + numOfUpdatePackets); - result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, - PLOC_SPV::UPDATE_VERIFY, packet.getWholeData(), packet.getFullSize()); - if (result != RETURN_OK) { - sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update available" - << " packet to supervisor handler" << std::endl; - triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_VERIFY); - state = State::IDLE; - pendingCommand = PLOC_SPV::NONE; - return; - } - state = State::COMMAND_EXECUTING; - pendingCommand = PLOC_SPV::UPDATE_VERIFY; + result = + commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, PLOC_SPV::UPDATE_VERIFY, + packet.getWholeData(), packet.getFullSize()); + if (result != RETURN_OK) { + sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update available" + << " packet to supervisor handler" << std::endl; + triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_VERIFY); + state = State::IDLE; + pendingCommand = PLOC_SPV::NONE; return; + } + state = State::COMMAND_EXECUTING; + pendingCommand = PLOC_SPV::UPDATE_VERIFY; + return; } void PlocUpdater::calcImageCrc() { - std::ifstream file(updateFile, std::ifstream::binary); - file.seekg(0, file.end); - uint32_t count; - uint32_t bit; - uint32_t remainder = INITIAL_REMAINDER_32; - char input; - for (count = 0; count < imageSize; count++) { - file.seekg(count, file.beg); - file.read(&input, 1); - remainder ^= (input << 16); - for (bit = 8; bit > 0; --bit) { - if (remainder & TOPBIT_32) { - remainder = (remainder << 1) ^ POLYNOMIAL_32; - } else { - remainder = (remainder << 1); - } - } + std::ifstream file(updateFile, std::ifstream::binary); + file.seekg(0, file.end); + uint32_t count; + uint32_t bit; + uint32_t remainder = INITIAL_REMAINDER_32; + char input; + for (count = 0; count < imageSize; count++) { + file.seekg(count, file.beg); + file.read(&input, 1); + remainder ^= (input << 16); + for (bit = 8; bit > 0; --bit) { + if (remainder & TOPBIT_32) { + remainder = (remainder << 1) ^ POLYNOMIAL_32; + } else { + remainder = (remainder << 1); + } } - file.close(); - imageCrc = (remainder ^ FINAL_XOR_VALUE_32); + } + file.close(); + imageCrc = (remainder ^ FINAL_XOR_VALUE_32); } void PlocUpdater::adjustSequenceFlags(PLOC_SPV::UpdatePacket& packet) { - if (packetsSent == 0) { - packet.setSequenceFlags(static_cast(PLOC_SPV::SequenceFlags::FIRST_PKT)); - } - else if (remainingPackets == 1) { - packet.setSequenceFlags(static_cast(PLOC_SPV::SequenceFlags::LAST_PKT)); - } - else { - packet.setSequenceFlags(static_cast(PLOC_SPV::SequenceFlags::CONTINUED_PKT)); - } + if (packetsSent == 0) { + packet.setSequenceFlags(static_cast(PLOC_SPV::SequenceFlags::FIRST_PKT)); + } else if (remainingPackets == 1) { + packet.setSequenceFlags(static_cast(PLOC_SPV::SequenceFlags::LAST_PKT)); + } else { + packet.setSequenceFlags(static_cast(PLOC_SPV::SequenceFlags::CONTINUED_PKT)); + } } - diff --git a/bsp_q7s/devices/PlocUpdater.h b/bsp_q7s/devices/PlocUpdater.h index d016b9e5..bfd86995 100644 --- a/bsp_q7s/devices/PlocUpdater.h +++ b/bsp_q7s/devices/PlocUpdater.h @@ -2,181 +2,170 @@ #define MISSION_DEVICES_PLOCUPDATER_H_ #include "OBSWConfig.h" +#include "bsp_q7s/memory/SdCardManager.h" #include "devicedefinitions/PlocSupervisorDefinitions.h" - -#include "fsfw/action/CommandActionHelper.h" #include "fsfw/action/ActionHelper.h" -#include "fsfw/action/HasActionsIF.h" +#include "fsfw/action/CommandActionHelper.h" #include "fsfw/action/CommandsActionsIF.h" +#include "fsfw/action/HasActionsIF.h" +#include "fsfw/objectmanager/SystemObject.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/tasks/ExecutableObjectIF.h" -#include "fsfw/objectmanager/SystemObject.h" -#include "bsp_q7s/memory/SdCardManager.h" -#include "linux/fsfwconfig/objects/systemObjectList.h" #include "fsfw/tmtcpacket/SpacePacket.h" - +#include "linux/fsfwconfig/objects/systemObjectList.h" /** * @brief An object of this class can be used to perform the software updates of the PLOC. The * software update will be read from one of the SD cards, split into multiple space * packets and sent to the PlocSupervisorHandler. * - * @details The MPSoC has two boot memories (NVM0 and NVM1) where each stores two images (Partition A - * and Partition B) + * @details The MPSoC has two boot memories (NVM0 and NVM1) where each stores two images (Partition + * A and Partition B) * * @author J. Meier */ class PlocUpdater : public SystemObject, - public HasActionsIF, - public ExecutableObjectIF, - public HasReturnvaluesIF, - public CommandsActionsIF { -public: + public HasActionsIF, + public ExecutableObjectIF, + public HasReturnvaluesIF, + public CommandsActionsIF { + public: + static const ActionId_t UPDATE_A_UBOOT = 0; + static const ActionId_t UPDATE_A_BITSTREAM = 1; + static const ActionId_t UPDATE_A_LINUX = 2; + static const ActionId_t UPDATE_A_APP_SW = 3; + static const ActionId_t UPDATE_B_UBOOT = 4; + static const ActionId_t UPDATE_B_BITSTREAM = 5; + static const ActionId_t UPDATE_B_LINUX = 6; + static const ActionId_t UPDATE_B_APP_SW = 7; - static const ActionId_t UPDATE_A_UBOOT = 0; - static const ActionId_t UPDATE_A_BITSTREAM = 1; - static const ActionId_t UPDATE_A_LINUX = 2; - static const ActionId_t UPDATE_A_APP_SW = 3; - static const ActionId_t UPDATE_B_UBOOT = 4; - static const ActionId_t UPDATE_B_BITSTREAM = 5; - static const ActionId_t UPDATE_B_LINUX = 6; - static const ActionId_t UPDATE_B_APP_SW = 7; + PlocUpdater(object_id_t objectId); + virtual ~PlocUpdater(); - PlocUpdater(object_id_t objectId); - virtual ~PlocUpdater(); + ReturnValue_t performOperation(uint8_t operationCode = 0) override; + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size); + MessageQueueId_t getCommandQueue() const; + ReturnValue_t initialize() override; + MessageQueueIF* getCommandQueuePtr() override; + void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) override; + void stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) override; + void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) override; + void completionSuccessfulReceived(ActionId_t actionId) override; + void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override; - ReturnValue_t performOperation(uint8_t operationCode = 0) override; - ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size); - MessageQueueId_t getCommandQueue() const; - ReturnValue_t initialize() override; - MessageQueueIF* getCommandQueuePtr() override; - void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) override; - void stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) override; - void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) override; - void completionSuccessfulReceived(ActionId_t actionId) override; - void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_UPDATER; -private: + //! [EXPORT] : [COMMENT] Updater is already performing an update + static const ReturnValue_t UPDATER_BUSY = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] Received update command with invalid path string (too long). + static const ReturnValue_t NAME_TOO_LONG = MAKE_RETURN_CODE(0xA1); + //! [EXPORT] : [COMMENT] Received command to initiate update but SD card with update image not + //! mounted. + static const ReturnValue_t SD_NOT_MOUNTED = MAKE_RETURN_CODE(0xA2); + //! [EXPORT] : [COMMENT] Update file received with update command does not exist. + static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xA3); - static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_UPDATER; + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_UPDATER; - //! [EXPORT] : [COMMENT] Updater is already performing an update - static const ReturnValue_t UPDATER_BUSY = MAKE_RETURN_CODE(0xA0); - //! [EXPORT] : [COMMENT] Received update command with invalid path string (too long). - static const ReturnValue_t NAME_TOO_LONG = MAKE_RETURN_CODE(0xA1); - //! [EXPORT] : [COMMENT] Received command to initiate update but SD card with update image not mounted. - static const ReturnValue_t SD_NOT_MOUNTED = MAKE_RETURN_CODE(0xA2); - //! [EXPORT] : [COMMENT] Update file received with update command does not exist. - static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xA3); + //! [EXPORT] : [COMMENT] Try to read update file but the file does not exist. + //! P1: Indicates in which state the file read fails + //! P2: During the update transfer the second parameter gives information about the number of + //! already sent packets + static const Event UPDATE_FILE_NOT_EXISTS = MAKE_EVENT(0, severity::LOW); + //! [EXPORT] : [COMMENT] Failed to send command to supervisor handler + //! P1: Return value of CommandActionHelper::commandAction + //! P2: Action ID of command to send + static const Event ACTION_COMMANDING_FAILED = MAKE_EVENT(1, severity::LOW); + //! [EXPORT] : [COMMENT] Supervisor handler replied action message indicating a command execution + //! failure of the update available command + static const Event UPDATE_AVAILABLE_FAILED = MAKE_EVENT(2, severity::LOW); + //! [EXPORT] : [COMMENT] Supervisor handler failed to transfer an update space packet. + //! P1: Parameter holds the number of update packets already sent (inclusive the failed packet) + static const Event UPDATE_TRANSFER_FAILED = MAKE_EVENT(3, severity::LOW); + //! [EXPORT] : [COMMENT] Supervisor failed to execute the update verify command. + static const Event UPDATE_VERIFY_FAILED = MAKE_EVENT(4, severity::LOW); + //! [EXPORT] : [COMMENT] MPSoC update successful completed + static const Event UPDATE_FINISHED = MAKE_EVENT(5, severity::INFO); - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_UPDATER; + static const uint32_t QUEUE_SIZE = config::PLOC_UPDATER_QUEUE_SIZE; + static const size_t MAX_PLOC_UPDATE_PATH = 50; + static const size_t SD_PREFIX_LENGTH = 8; + // Maximum size of update payload data per space packet (max size of space packet is 1024 bytes) + static const size_t MAX_SP_DATA = 1016; - //! [EXPORT] : [COMMENT] Try to read update file but the file does not exist. - //! P1: Indicates in which state the file read fails - //! P2: During the update transfer the second parameter gives information about the number of already sent packets - static const Event UPDATE_FILE_NOT_EXISTS = MAKE_EVENT(0, severity::LOW); - //! [EXPORT] : [COMMENT] Failed to send command to supervisor handler - //! P1: Return value of CommandActionHelper::commandAction - //! P2: Action ID of command to send - static const Event ACTION_COMMANDING_FAILED = MAKE_EVENT(1, severity::LOW); - //! [EXPORT] : [COMMENT] Supervisor handler replied action message indicating a command execution failure of the update available command - static const Event UPDATE_AVAILABLE_FAILED = MAKE_EVENT(2, severity::LOW); - //! [EXPORT] : [COMMENT] Supervisor handler failed to transfer an update space packet. - //! P1: Parameter holds the number of update packets already sent (inclusive the failed packet) - static const Event UPDATE_TRANSFER_FAILED = MAKE_EVENT(3, severity::LOW); - //! [EXPORT] : [COMMENT] Supervisor failed to execute the update verify command. - static const Event UPDATE_VERIFY_FAILED = MAKE_EVENT(4, severity::LOW); - //! [EXPORT] : [COMMENT] MPSoC update successful completed - static const Event UPDATE_FINISHED = MAKE_EVENT(5, severity::INFO); + static const uint32_t TOPBIT_32 = (1 << 31); + static const uint32_t POLYNOMIAL_32 = 0x04C11DB7; + static const uint32_t INITIAL_REMAINDER_32 = 0xFFFFFFFF; + static const uint32_t FINAL_XOR_VALUE_32 = 0xFFFFFFFF; - static const uint32_t QUEUE_SIZE = config::PLOC_UPDATER_QUEUE_SIZE; - static const size_t MAX_PLOC_UPDATE_PATH = 50; - static const size_t SD_PREFIX_LENGTH = 8; - // Maximum size of update payload data per space packet (max size of space packet is 1024 bytes) - static const size_t MAX_SP_DATA = 1016; - - static const uint32_t TOPBIT_32 = (1 << 31); - static const uint32_t POLYNOMIAL_32 = 0x04C11DB7; - static const uint32_t INITIAL_REMAINDER_32 = 0xFFFFFFFF; - static const uint32_t FINAL_XOR_VALUE_32 = 0xFFFFFFFF; - - MessageQueueIF* commandQueue = nullptr; + MessageQueueIF* commandQueue = nullptr; #if BOARD_TE0720 == 0 - SdCardManager* sdcMan = nullptr; + SdCardManager* sdcMan = nullptr; #endif - CommandActionHelper commandActionHelper; + CommandActionHelper commandActionHelper; - ActionHelper actionHelper; + ActionHelper actionHelper; - enum class State: uint8_t { - IDLE, - UPDATE_AVAILABLE, - UPDATE_TRANSFER, - UPDATE_VERIFY, - COMMAND_EXECUTING - }; + enum class State : uint8_t { + IDLE, + UPDATE_AVAILABLE, + UPDATE_TRANSFER, + UPDATE_VERIFY, + COMMAND_EXECUTING + }; - State state = State::IDLE; + State state = State::IDLE; - ActionId_t pendingCommand = PLOC_SPV::NONE; + ActionId_t pendingCommand = PLOC_SPV::NONE; - enum class Image: uint8_t { - NONE, - A, - B - }; + enum class Image : uint8_t { NONE, A, B }; - Image image = Image::NONE; + Image image = Image::NONE; - enum class Partition: uint8_t { - NONE, - UBOOT, - BITSTREAM, - LINUX_OS, - APP_SW - }; + enum class Partition : uint8_t { NONE, UBOOT, BITSTREAM, LINUX_OS, APP_SW }; - Partition partition = Partition::NONE; + Partition partition = Partition::NONE; - uint32_t packetsSent = 0; - uint32_t remainingPackets = 0; - // Number of packets required to transfer the update image - uint32_t numOfUpdatePackets = 0; + uint32_t packetsSent = 0; + uint32_t remainingPackets = 0; + // Number of packets required to transfer the update image + uint32_t numOfUpdatePackets = 0; - std::string updateFile; - uint32_t imageSize = 0; - uint32_t imageCrc = 0; + std::string updateFile; + uint32_t imageSize = 0; + uint32_t imageCrc = 0; - void readCommandQueue(); - void doStateMachine(); + void readCommandQueue(); + void doStateMachine(); - /** - * @brief Extracts the path and name of the update image from the service 8 command data. - */ - ReturnValue_t getImageLocation(const uint8_t* data, size_t size); + /** + * @brief Extracts the path and name of the update image from the service 8 command data. + */ + ReturnValue_t getImageLocation(const uint8_t* data, size_t size); - ReturnValue_t checkNameLength(size_t size); + ReturnValue_t checkNameLength(size_t size); - /** - * @brief Prepares and sends update available command to PLOC supervisor handler. - */ - void commandUpdateAvailable(); + /** + * @brief Prepares and sends update available command to PLOC supervisor handler. + */ + void commandUpdateAvailable(); - /** - * @brief Prepares and sends and update packet to the PLOC supervisor handler. - */ - void commandUpdatePacket(); + /** + * @brief Prepares and sends and update packet to the PLOC supervisor handler. + */ + void commandUpdatePacket(); - /** - * @brief Prepares and sends the update verification packet to the PLOC supervisor handler. - */ - void commandUpdateVerify(); + /** + * @brief Prepares and sends the update verification packet to the PLOC supervisor handler. + */ + void commandUpdateVerify(); - void calcImageCrc(); + void calcImageCrc(); - void adjustSequenceFlags(PLOC_SPV::UpdatePacket& packet); + void adjustSequenceFlags(PLOC_SPV::UpdatePacket& packet); }; #endif /* MISSION_DEVICES_PLOCUPDATER_H_ */ diff --git a/bsp_q7s/devices/devicedefinitions/PlocMemDumpDefinitions.h b/bsp_q7s/devices/devicedefinitions/PlocMemDumpDefinitions.h index 6e44cf35..00dc9003 100644 --- a/bsp_q7s/devices/devicedefinitions/PlocMemDumpDefinitions.h +++ b/bsp_q7s/devices/devicedefinitions/PlocMemDumpDefinitions.h @@ -3,31 +3,26 @@ #include -class MemoryParams: public SerialLinkedListAdapter { -public: +class MemoryParams : public SerialLinkedListAdapter { + public: + /** + * @brief Constructor + * @param startAddress Start of address range to dump + * @param endAddress End of address range to dump + */ + MemoryParams(uint32_t startAddress, uint32_t endAddress) + : startAddress(startAddress), endAddress(endAddress) { + setLinks(); + } - /** - * @brief Constructor - * @param startAddress Start of address range to dump - * @param endAddress End of address range to dump - */ - MemoryParams(uint32_t startAddress, uint32_t endAddress) : - startAddress(startAddress), endAddress(endAddress) { - setLinks(); - } -private: - - void setLinks() { - setStart(&startAddress); - startAddress.setNext(&endAddress); - } - - SerializeElement startAddress; - SerializeElement endAddress; + private: + void setLinks() { + setStart(&startAddress); + startAddress.setNext(&endAddress); + } + SerializeElement startAddress; + SerializeElement endAddress; }; - - - #endif /* BSP_Q7S_DEVICES_DEVICEDEFINITIONS_PLOCMEMDUMPDEFINITIONS_H_ */ diff --git a/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h b/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h index 0235d281..3fc21441 100644 --- a/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h +++ b/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h @@ -1,12 +1,12 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_PLOCSVPDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_PLOCSVPDEFINITIONS_H_ -#include +#include +#include #include #include #include -#include -#include +#include namespace PLOC_SPV { @@ -143,7 +143,7 @@ static const uint8_t DATA_FIELD_OFFSET = 6; * Space packet length for fixed size packets. This is the size of the whole packet data * field. For the length field in the space packet this size will be substracted by one. */ -static const uint16_t LENGTH_EMPTY_TC = 2; // Only CRC will be transported with the data field +static const uint16_t LENGTH_EMPTY_TC = 2; // Only CRC will be transported with the data field /** This is the maximum length of a space packet as defined by the TAS ICD */ static const size_t MAX_COMMAND_SIZE = 1024; @@ -153,51 +153,53 @@ static const size_t MAX_PACKET_SIZE = 1024; static const uint8_t SPACE_PACKET_HEADER_LENGTH = 6; -enum class SequenceFlags: uint8_t { - CONTINUED_PKT = 0b00, FIRST_PKT = 0b01, LAST_PKT = 0b10, STANDALONE_PKT = 0b11 +enum class SequenceFlags : uint8_t { + CONTINUED_PKT = 0b00, + FIRST_PKT = 0b01, + LAST_PKT = 0b10, + STANDALONE_PKT = 0b11 }; -enum PoolIds - : lp_id_t { - NUM_TMS, - TEMP_PS, - TEMP_PL, - SOC_STATE, - NVM0_1_STATE, - NVM3_STATE, - MISSION_IO_STATE, - FMC_STATE, - NUM_TCS, - TEMP_SUP, - UPTIME, - CPULOAD, - AVAILABLEHEAP, - BOOT_SIGNAL, - RESET_COUNTER, - BOOT_AFTER_MS, - BOOT_TIMEOUT_MS, - ACTIVE_NVM, - BP0_STATE, - BP1_STATE, - BP2_STATE, +enum PoolIds : lp_id_t { + NUM_TMS, + TEMP_PS, + TEMP_PL, + SOC_STATE, + NVM0_1_STATE, + NVM3_STATE, + MISSION_IO_STATE, + FMC_STATE, + NUM_TCS, + TEMP_SUP, + UPTIME, + CPULOAD, + AVAILABLEHEAP, + BOOT_SIGNAL, + RESET_COUNTER, + BOOT_AFTER_MS, + BOOT_TIMEOUT_MS, + ACTIVE_NVM, + BP0_STATE, + BP1_STATE, + BP2_STATE, - LATCHUP_ID, - CNT0, - CNT1, - CNT2, - CNT3, - CNT4, - CNT5, - CNT6, - LATCHUP_RPT_TIME_SEC, - LATCHUP_RPT_TIME_MIN, - LATCHUP_RPT_TIME_HOUR, - LATCHUP_RPT_TIME_DAY, - LATCHUP_RPT_TIME_MON, - LATCHUP_RPT_TIME_YEAR, - LATCHUP_RPT_TIME_MSEC, - LATCHUP_RPT_TIME_USEC, - LATCHUP_RPT_TIME_IS_SET, + LATCHUP_ID, + CNT0, + CNT1, + CNT2, + CNT3, + CNT4, + CNT5, + CNT6, + LATCHUP_RPT_TIME_SEC, + LATCHUP_RPT_TIME_MIN, + LATCHUP_RPT_TIME_HOUR, + LATCHUP_RPT_TIME_DAY, + LATCHUP_RPT_TIME_MON, + LATCHUP_RPT_TIME_YEAR, + LATCHUP_RPT_TIME_MSEC, + LATCHUP_RPT_TIME_USEC, + LATCHUP_RPT_TIME_IS_SET, }; static const uint8_t HK_SET_ENTRIES = 13; @@ -211,285 +213,273 @@ static const uint32_t LATCHUP_RPT_ID = LATCHUP_REPORT; /** * @brief With this class a space packet can be created which does not contain any data. */ -class EmptyPacket: public SpacePacket { -public: +class EmptyPacket : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param apid The APID to set in the space packet. + * + * @note Sequence count of empty packet is always 1. + */ + EmptyPacket(uint16_t apid) : SpacePacket(LENGTH_EMPTY_TC - 1, true, apid, 1) { calcCrc(); } - /** - * @brief Constructor - * - * @param apid The APID to set in the space packet. - * - * @note Sequence count of empty packet is always 1. - */ - EmptyPacket(uint16_t apid) : - SpacePacket(LENGTH_EMPTY_TC - 1, true, apid, 1) { - calcCrc(); - } + private: + /** + * @brief CRC calculation which involves only the header in an empty packet + */ + void calcCrc() { + /* Calculate crc */ + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, sizeof(CCSDSPrimaryHeader)); -private: - - /** - * @brief CRC calculation which involves only the header in an empty packet - */ - void calcCrc() { - - /* Calculate crc */ - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, sizeof(CCSDSPrimaryHeader)); - - /* Add crc to packet data field of space packet */ - size_t serializedSize = 0; - uint8_t* crcPos = this->localData.fields.buffer; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + /* Add crc to packet data field of space packet */ + size_t serializedSize = 0; + uint8_t* crcPos = this->localData.fields.buffer; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class can be used to generate the space packet selecting the boot image of * of the MPSoC. */ -class MPSoCBootSelect: public SpacePacket { -public: +class MPSoCBootSelect : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param mem The memory to boot from: NVM0 (0), NVM1 (1) + * @param bp0 Partition pin 0 + * @param bp1 Partition pin 1 + * @param bp2 Partition pin 2 + */ + MPSoCBootSelect(uint8_t mem, uint8_t bp0, uint8_t bp1, uint8_t bp2) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SEL_MPSOC_BOOT_IMAGE, DEFAULT_SEQUENCE_COUNT), + mem(mem), + bp0(bp0), + bp1(bp1), + bp2(bp2) { + initPacket(); + } - /** - * @brief Constructor - * - * @param mem The memory to boot from: NVM0 (0), NVM1 (1) - * @param bp0 Partition pin 0 - * @param bp1 Partition pin 1 - * @param bp2 Partition pin 2 - */ - MPSoCBootSelect(uint8_t mem, uint8_t bp0, uint8_t bp1, uint8_t bp2) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SEL_MPSOC_BOOT_IMAGE, - DEFAULT_SEQUENCE_COUNT), mem(mem), bp0(bp0), bp1(bp1), bp2(bp2) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 6; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint8_t MEM_OFFSET = 0; + static const uint8_t BP0_OFFSET = 1; + static const uint8_t BP1_OFFSET = 2; + static const uint8_t BP2_OFFSET = 3; + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 6; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t mem = 0; + uint8_t bp0 = 0; + uint8_t bp1 = 0; + uint8_t bp2 = 0; - static const uint8_t MEM_OFFSET = 0; - static const uint8_t BP0_OFFSET = 1; - static const uint8_t BP1_OFFSET = 2; - static const uint8_t BP2_OFFSET = 3; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; + void initPacket() { + uint8_t* data_field_start = this->localData.fields.buffer; + std::memcpy(data_field_start + MEM_OFFSET, &mem, sizeof(mem)); + std::memcpy(data_field_start + BP0_OFFSET, &bp0, sizeof(bp0)); + std::memcpy(data_field_start + BP1_OFFSET, &bp1, sizeof(bp1)); + std::memcpy(data_field_start + BP2_OFFSET, &bp2, sizeof(bp2)); + /* Calculate crc */ + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t mem = 0; - uint8_t bp0 = 0; - uint8_t bp1 = 0; - uint8_t bp2 = 0; - - void initPacket() { - uint8_t* data_field_start = this->localData.fields.buffer; - std::memcpy(data_field_start + MEM_OFFSET, &mem, sizeof(mem)); - std::memcpy(data_field_start + BP0_OFFSET, &bp0, sizeof(bp0)); - std::memcpy(data_field_start + BP1_OFFSET, &bp1, sizeof(bp1)); - std::memcpy(data_field_start + BP2_OFFSET, &bp2, sizeof(bp2)); - /* Calculate crc */ - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - - /* Add crc to packet data field of space packet */ - size_t serializedSize = 0; - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + /* Add crc to packet data field of space packet */ + size_t serializedSize = 0; + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class generates the space packet to update the time of the PLOC supervisor. */ -class SetTimeRef: public SpacePacket { -public: +class SetTimeRef : public SpacePacket { + public: + SetTimeRef(Clock::TimeOfDay_t* time) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_TIME_REF, DEFAULT_SEQUENCE_COUNT) { + initPacket(time); + } - SetTimeRef(Clock::TimeOfDay_t* time) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_TIME_REF, DEFAULT_SEQUENCE_COUNT) { - initPacket(time); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 34; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; -private: - - static const uint16_t DATA_FIELD_LENGTH = 34; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - void initPacket(Clock::TimeOfDay_t* time) { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&time->second, &data_field_ptr, &serializedSize, - sizeof(time->second), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&time->minute, &data_field_ptr, &serializedSize, - sizeof(time->minute), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&time->hour, &data_field_ptr, &serializedSize, - sizeof(time->hour), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&time->day, &data_field_ptr, &serializedSize, - sizeof(time->day), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&time->month, &data_field_ptr, &serializedSize, - sizeof(time->month), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&time->year, &data_field_ptr, &serializedSize, - sizeof(time->year), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint32_t milliseconds = time->usecond / 1000; - SerializeAdapter::serialize(&milliseconds, &data_field_ptr, &serializedSize, - sizeof(milliseconds), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint32_t isSet = 0xFFFFFFFF; - SerializeAdapter::serialize(&isSet, &data_field_ptr, &serializedSize, - sizeof(isSet), SerializeIF::Endianness::BIG); - serializedSize = 0; - /* Calculate crc */ - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - SerializeAdapter::serialize(&crc, &data_field_ptr, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket(Clock::TimeOfDay_t* time) { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&time->second, &data_field_ptr, &serializedSize, + sizeof(time->second), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&time->minute, &data_field_ptr, &serializedSize, + sizeof(time->minute), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&time->hour, &data_field_ptr, &serializedSize, + sizeof(time->hour), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&time->day, &data_field_ptr, &serializedSize, + sizeof(time->day), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&time->month, &data_field_ptr, &serializedSize, + sizeof(time->month), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&time->year, &data_field_ptr, &serializedSize, + sizeof(time->year), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint32_t milliseconds = time->usecond / 1000; + SerializeAdapter::serialize(&milliseconds, &data_field_ptr, &serializedSize, + sizeof(milliseconds), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint32_t isSet = 0xFFFFFFFF; + SerializeAdapter::serialize(&isSet, &data_field_ptr, &serializedSize, sizeof(isSet), + SerializeIF::Endianness::BIG); + serializedSize = 0; + /* Calculate crc */ + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + SerializeAdapter::serialize(&crc, &data_field_ptr, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class can be used to generate the set boot timout command. */ -class SetBootTimeout: public SpacePacket { -public: +class SetBootTimeout : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param timeout The boot timeout in milliseconds. + */ + SetBootTimeout(uint32_t timeout) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_BOOT_TIMEOUT, 1), timeout(timeout) { + initPacket(); + } - /** - * @brief Constructor - * - * @param timeout The boot timeout in milliseconds. - */ - SetBootTimeout(uint32_t timeout) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_BOOT_TIMEOUT, 1), timeout(timeout) { - initPacket(); - } + private: + uint32_t timeout = 0; -private: + /** boot timeout value (uint32_t) and crc (uint16_t) */ + static const uint16_t DATA_FIELD_LENGTH = 6; - uint32_t timeout = 0; - - /** boot timeout value (uint32_t) and crc (uint16_t) */ - static const uint16_t DATA_FIELD_LENGTH = 6; - - void initPacket() { - - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&timeout, &data_field_ptr, &serializedSize, - sizeof(timeout), SerializeIF::Endianness::BIG); - /* Calculate crc */ - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - /* Add crc to packet data field of space packet */ - serializedSize = 0; - SerializeAdapter::serialize(&crc, &data_field_ptr, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&timeout, &data_field_ptr, &serializedSize, + sizeof(timeout), SerializeIF::Endianness::BIG); + /* Calculate crc */ + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + /* Add crc to packet data field of space packet */ + serializedSize = 0; + SerializeAdapter::serialize(&crc, &data_field_ptr, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class can be used to generate the space packet to set the maximum boot tries. */ -class SetRestartTries: public SpacePacket { -public: +class SetRestartTries : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param restartTries Maximum restart tries to set. + */ + SetRestartTries(uint8_t restartTries) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_MAX_RESTART_TRIES, 1), + restartTries(restartTries) { + initPacket(); + } - /** - * @brief Constructor - * - * @param restartTries Maximum restart tries to set. - */ - SetRestartTries(uint8_t restartTries) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_MAX_RESTART_TRIES, 1), restartTries( - restartTries) { - initPacket(); - } + private: + uint8_t restartTries = 0; -private: + /** Restart tries value (uint8_t) and crc (uint16_t) */ + static const uint16_t DATA_FIELD_LENGTH = 3; - uint8_t restartTries = 0; - - /** Restart tries value (uint8_t) and crc (uint16_t) */ - static const uint16_t DATA_FIELD_LENGTH = 3; - - void initPacket() { - uint8_t* data_field_ptr = this->localData.fields.buffer; - *data_field_ptr = restartTries; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - size_t serializedSize = 0; - uint8_t* crcPtr = data_field_ptr + 1; - SerializeAdapter::serialize(&crc, &crcPtr, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + uint8_t* data_field_ptr = this->localData.fields.buffer; + *data_field_ptr = restartTries; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + size_t serializedSize = 0; + uint8_t* crcPtr = data_field_ptr + 1; + SerializeAdapter::serialize(&crc, &crcPtr, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the command to notify the supervisor that a new update for the * MPSoC is available. */ -class UpdateAvailable: public SpacePacket { -public: +class UpdateAvailable : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param imageSelect + * @param imagePartition + * @param imageSize + * @param imageCrc + * @param numberOfPackets + */ + UpdateAvailable(uint8_t imageSelect, uint8_t imagePartition, uint32_t imageSize, + uint32_t imageCrc, uint32_t numberOfPackets) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_UPDATE_AVAILABLE, DEFAULT_SEQUENCE_COUNT), + imageSelect(imageSelect), + imagePartition(imagePartition), + imageSize(imageSize), + imageCrc(imageCrc), + numberOfPackets(numberOfPackets) { + initPacket(); + } - /** - * @brief Constructor - * - * @param imageSelect - * @param imagePartition - * @param imageSize - * @param imageCrc - * @param numberOfPackets - */ - UpdateAvailable(uint8_t imageSelect, uint8_t imagePartition, uint32_t imageSize, - uint32_t imageCrc, uint32_t numberOfPackets) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_UPDATE_AVAILABLE, - DEFAULT_SEQUENCE_COUNT), imageSelect(imageSelect), imagePartition( - imagePartition), imageSize(imageSize), imageCrc(imageCrc), numberOfPackets( - numberOfPackets) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 16; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 16; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t imageSelect = 0; + uint8_t imagePartition = 0; + uint32_t imageSize = 0; + uint32_t imageCrc = 0; + uint32_t numberOfPackets = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t imageSelect = 0; - uint8_t imagePartition = 0; - uint32_t imageSize = 0; - uint32_t imageCrc = 0; - uint32_t numberOfPackets = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&imageSelect, &data_field_ptr, &serializedSize, - sizeof(imageSelect), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&imagePartition, &data_field_ptr, &serializedSize, - sizeof(imagePartition), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&imageSize, &data_field_ptr, &serializedSize, - sizeof(imageSize), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&imageCrc, &data_field_ptr, &serializedSize, - sizeof(imageCrc), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&numberOfPackets, &data_field_ptr, &serializedSize, - sizeof(numberOfPackets), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&imageSelect, &data_field_ptr, &serializedSize, + sizeof(imageSelect), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&imagePartition, &data_field_ptr, &serializedSize, + sizeof(imagePartition), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&imageSize, &data_field_ptr, &serializedSize, + sizeof(imageSize), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&imageCrc, &data_field_ptr, &serializedSize, + sizeof(imageCrc), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&numberOfPackets, &data_field_ptr, &serializedSize, + sizeof(numberOfPackets), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** @@ -497,130 +487,126 @@ private: * of housekeeping data. Normally, this will be disabled by default. However, adding this * command can be useful for debugging. */ -class DisablePeriodicHkTransmission: public SpacePacket { -public: +class DisablePeriodicHkTransmission : public SpacePacket { + public: + /** + * @brief Constructor + */ + DisablePeriodicHkTransmission() : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_DISABLE_HK, 1) { + initPacket(); + } - /** - * @brief Constructor - */ - DisablePeriodicHkTransmission() : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_DISABLE_HK, 1) { - initPacket(); - } + private: + uint8_t disableHk = 0; -private: + /** Restart tries value (uint8_t) and crc (uint16_t) */ + static const uint16_t DATA_FIELD_LENGTH = 3; - uint8_t disableHk = 0; - - /** Restart tries value (uint8_t) and crc (uint16_t) */ - static const uint16_t DATA_FIELD_LENGTH = 3; - - void initPacket() { - uint8_t* data_field_ptr = this->localData.fields.buffer; - *data_field_ptr = disableHk; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - size_t serializedSize = 0; - uint8_t* crcPtr = data_field_ptr + 1; - SerializeAdapter::serialize(&crc, &crcPtr, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + uint8_t* data_field_ptr = this->localData.fields.buffer; + *data_field_ptr = disableHk; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + size_t serializedSize = 0; + uint8_t* crcPtr = data_field_ptr + 1; + SerializeAdapter::serialize(&crc, &crcPtr, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the command to enable the watchdogs of the PLOC. */ -class WatchdogsEnable: public SpacePacket { -public: +class WatchdogsEnable : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param watchdogPs Enables processing system watchdog + * @param watchdogPl Enables programmable logic wathdog + * @param watchdogInt + */ + WatchdogsEnable(uint8_t watchdogPs, uint8_t watchdogPl, uint8_t watchdogInt) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_WTD_ENABLE, DEFAULT_SEQUENCE_COUNT), + watchdogPs(watchdogPs), + watchdogPl(watchdogPl), + watchdogInt(watchdogInt) { + initPacket(); + } - /** - * @brief Constructor - * - * @param watchdogPs Enables processing system watchdog - * @param watchdogPl Enables programmable logic wathdog - * @param watchdogInt - */ - WatchdogsEnable(uint8_t watchdogPs, uint8_t watchdogPl, uint8_t watchdogInt) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_WTD_ENABLE, DEFAULT_SEQUENCE_COUNT), - watchdogPs(watchdogPs), watchdogPl(watchdogPl), watchdogInt(watchdogInt) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 5; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 5; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t watchdogPs = 0; + uint8_t watchdogPl = 0; + uint8_t watchdogInt = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t watchdogPs = 0; - uint8_t watchdogPl = 0; - uint8_t watchdogInt = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&watchdogPs, &data_field_ptr, &serializedSize, - sizeof(watchdogPs), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&watchdogPl, &data_field_ptr, &serializedSize, - sizeof(watchdogPl), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&watchdogInt, &data_field_ptr, &serializedSize, - sizeof(watchdogInt), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&watchdogPs, &data_field_ptr, &serializedSize, + sizeof(watchdogPs), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&watchdogPl, &data_field_ptr, &serializedSize, + sizeof(watchdogPl), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&watchdogInt, &data_field_ptr, &serializedSize, + sizeof(watchdogInt), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the command to set the timeout of one of the three watchdogs (PS, * PL, INT) */ -class WatchdogsConfigTimeout: public SpacePacket { -public: +class WatchdogsConfigTimeout : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param watchdogPs Selects the watchdog to configure (0 - PS, 1 - PL, 2 - INT) + * @param timeout The timeout to set + */ + WatchdogsConfigTimeout(uint8_t watchdog, uint32_t timeout) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_WTD_CONFIG_TIMEOUT, DEFAULT_SEQUENCE_COUNT), + watchdog(watchdog), + timeout(timeout) { + initPacket(); + } - /** - * @brief Constructor - * - * @param watchdogPs Selects the watchdog to configure (0 - PS, 1 - PL, 2 - INT) - * @param timeout The timeout to set - */ - WatchdogsConfigTimeout(uint8_t watchdog, uint32_t timeout) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_WTD_CONFIG_TIMEOUT, - DEFAULT_SEQUENCE_COUNT), watchdog(watchdog), timeout(timeout) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 7; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 7; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t watchdog = 0; + uint32_t timeout = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t watchdog = 0; - uint32_t timeout = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&watchdog, &data_field_ptr, &serializedSize, - sizeof(watchdog), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&timeout, &data_field_ptr, &serializedSize, - sizeof(timeout), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&watchdog, &data_field_ptr, &serializedSize, + sizeof(watchdog), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&timeout, &data_field_ptr, &serializedSize, + sizeof(timeout), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** @@ -628,723 +614,693 @@ private: * * @details There are 7 different latchup alerts. */ -class LatchupAlert: public SpacePacket { -public: - - /** - * @brief Constructor - * - * @param state true - enable, false - disable - * @param latchupId Identifies the latchup to enable/disable (0 - 0.85V, 1 - 1.8V, 2 - MISC, - * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) - */ - LatchupAlert(bool state, uint8_t latchupId) : - SpacePacket(DATA_FIELD_LENGTH - 1, true), latchupId(latchupId) { - if (state) { - this->setAPID(APID_ENABLE_LATCHUP_ALERT); - } else { - this->setAPID(APID_DISABLE_LATCHUP_ALERT); - } - this->setPacketSequenceCount(DEFAULT_SEQUENCE_COUNT); - initPacket(); +class LatchupAlert : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param state true - enable, false - disable + * @param latchupId Identifies the latchup to enable/disable (0 - 0.85V, 1 - 1.8V, 2 - MISC, + * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) + */ + LatchupAlert(bool state, uint8_t latchupId) + : SpacePacket(DATA_FIELD_LENGTH - 1, true), latchupId(latchupId) { + if (state) { + this->setAPID(APID_ENABLE_LATCHUP_ALERT); + } else { + this->setAPID(APID_DISABLE_LATCHUP_ALERT); } + this->setPacketSequenceCount(DEFAULT_SEQUENCE_COUNT); + initPacket(); + } -private: + private: + static const uint16_t DATA_FIELD_LENGTH = 3; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; - static const uint16_t DATA_FIELD_LENGTH = 3; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; + uint8_t latchupId = 0; - uint8_t latchupId = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, - sizeof(latchupId), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, + sizeof(latchupId), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the command to calibrate a certain latchup alert. */ -class AutoCalibrateAlert: public SpacePacket { -public: +class AutoCalibrateAlert : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param latchupId Identifies the latchup alert to calibrate (0 - 0.85V, 1 - 1.8V, 2 - MISC, + * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) + * @param mg + */ + AutoCalibrateAlert(uint8_t latchupId, uint32_t mg) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_AUTO_CALIBRATE_ALERT, DEFAULT_SEQUENCE_COUNT), + latchupId(latchupId), + mg(mg) { + initPacket(); + } - /** - * @brief Constructor - * - * @param latchupId Identifies the latchup alert to calibrate (0 - 0.85V, 1 - 1.8V, 2 - MISC, - * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) - * @param mg - */ - AutoCalibrateAlert(uint8_t latchupId, uint32_t mg) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_AUTO_CALIBRATE_ALERT, - DEFAULT_SEQUENCE_COUNT), latchupId(latchupId), mg(mg) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 7; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 7; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t latchupId = 0; + uint32_t mg = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t latchupId = 0; - uint32_t mg = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, - sizeof(latchupId), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&mg, &data_field_ptr, &serializedSize, - sizeof(mg), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, + sizeof(latchupId), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&mg, &data_field_ptr, &serializedSize, sizeof(mg), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; +class SetAlertlimit : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param latchupId Identifies the latchup alert to calibrate (0 - 0.85V, 1 - 1.8V, 2 - MISC, + * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) + * @param dutycycle + */ + SetAlertlimit(uint8_t latchupId, uint32_t dutycycle) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ALERT_LIMIT, DEFAULT_SEQUENCE_COUNT), + latchupId(latchupId), + dutycycle(dutycycle) { + initPacket(); + } -class SetAlertlimit: public SpacePacket { -public: + private: + static const uint16_t DATA_FIELD_LENGTH = 7; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; - /** - * @brief Constructor - * - * @param latchupId Identifies the latchup alert to calibrate (0 - 0.85V, 1 - 1.8V, 2 - MISC, - * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) - * @param dutycycle - */ - SetAlertlimit(uint8_t latchupId, uint32_t dutycycle) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ALERT_LIMIT, - DEFAULT_SEQUENCE_COUNT), latchupId(latchupId), dutycycle(dutycycle) { - initPacket(); - } + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; -private: + uint8_t latchupId = 0; + uint32_t dutycycle = 0; - static const uint16_t DATA_FIELD_LENGTH = 7; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; - - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t latchupId = 0; - uint32_t dutycycle = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, - sizeof(latchupId), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&dutycycle, &data_field_ptr, &serializedSize, - sizeof(dutycycle), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, + sizeof(latchupId), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&dutycycle, &data_field_ptr, &serializedSize, + sizeof(dutycycle), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; -class SetAlertIrqFilter: public SpacePacket { -public: +class SetAlertIrqFilter : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param latchupId Identifies the latchup alert to calibrate (0 - 0.85V, 1 - 1.8V, 2 - MISC, + * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) + * @param tp + * @param div + */ + SetAlertIrqFilter(uint8_t latchupId, uint8_t tp, uint8_t div) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ALERT_IRQ_FILTER, DEFAULT_SEQUENCE_COUNT), + tp(tp), + div(div) { + initPacket(); + } - /** - * @brief Constructor - * - * @param latchupId Identifies the latchup alert to calibrate (0 - 0.85V, 1 - 1.8V, 2 - MISC, - * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) - * @param tp - * @param div - */ - SetAlertIrqFilter(uint8_t latchupId, uint8_t tp, uint8_t div) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ALERT_IRQ_FILTER, - DEFAULT_SEQUENCE_COUNT), tp(tp), div(div) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 5; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 5; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t latchupId = 0; + uint8_t tp = 0; + uint8_t div = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t latchupId = 0; - uint8_t tp = 0; - uint8_t div = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, - sizeof(latchupId), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&tp, &data_field_ptr, &serializedSize, - sizeof(tp), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&div, &data_field_ptr, &serializedSize, - sizeof(div), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, + sizeof(latchupId), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&tp, &data_field_ptr, &serializedSize, sizeof(tp), + SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&div, &data_field_ptr, &serializedSize, sizeof(div), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; - /** * @brief This class packages the space packet to set the sweep period of the ADC. */ -class SetAdcSweepPeriod: public SpacePacket { -public: +class SetAdcSweepPeriod : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param sweepPeriod Sweep period in us. minimum is 21 us + */ + SetAdcSweepPeriod(uint32_t sweepPeriod) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_SWEEP_PERIOD, DEFAULT_SEQUENCE_COUNT), + sweepPeriod(sweepPeriod) { + initPacket(); + } - /** - * @brief Constructor - * - * @param sweepPeriod Sweep period in us. minimum is 21 us - */ - SetAdcSweepPeriod(uint32_t sweepPeriod) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_SWEEP_PERIOD, - DEFAULT_SEQUENCE_COUNT), sweepPeriod(sweepPeriod) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 6; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 6; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint32_t sweepPeriod = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint32_t sweepPeriod = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&sweepPeriod, &data_field_ptr, &serializedSize, - sizeof(sweepPeriod), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&sweepPeriod, &data_field_ptr, &serializedSize, + sizeof(sweepPeriod), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet to enable or disable ADC channels. */ -class SetAdcEnabledChannels: public SpacePacket { -public: +class SetAdcEnabledChannels : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param ch Defines channels to be enabled or disabled. + */ + SetAdcEnabledChannels(uint16_t ch) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_ENABLED_CHANNELS, + DEFAULT_SEQUENCE_COUNT), + ch(ch) { + initPacket(); + } - /** - * @brief Constructor - * - * @param ch Defines channels to be enabled or disabled. - */ - SetAdcEnabledChannels(uint16_t ch) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_ENABLED_CHANNELS, - DEFAULT_SEQUENCE_COUNT), ch(ch) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 4; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 4; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint16_t ch = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint16_t ch = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&ch, &data_field_ptr, &serializedSize, - sizeof(ch), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&ch, &data_field_ptr, &serializedSize, sizeof(ch), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet to configures the window size and striding step of * the moving average filter applied to the ADC readings. */ -class SetAdcWindowAndStride: public SpacePacket { -public: +class SetAdcWindowAndStride : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param windowSize + * @param stridingStepSize + */ + SetAdcWindowAndStride(uint16_t windowSize, uint16_t stridingStepSize) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_WINDOW_AND_STRIDE, + DEFAULT_SEQUENCE_COUNT), + windowSize(windowSize), + stridingStepSize(stridingStepSize) { + initPacket(); + } - /** - * @brief Constructor - * - * @param windowSize - * @param stridingStepSize - */ - SetAdcWindowAndStride(uint16_t windowSize, uint16_t stridingStepSize) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_WINDOW_AND_STRIDE, - DEFAULT_SEQUENCE_COUNT), windowSize(windowSize), stridingStepSize( - stridingStepSize) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 6; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 6; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint16_t windowSize = 0; + uint16_t stridingStepSize = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint16_t windowSize = 0; - uint16_t stridingStepSize = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&windowSize, &data_field_ptr, &serializedSize, - sizeof(windowSize), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&stridingStepSize, &data_field_ptr, &serializedSize, - sizeof(stridingStepSize), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&windowSize, &data_field_ptr, &serializedSize, + sizeof(windowSize), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&stridingStepSize, &data_field_ptr, &serializedSize, + sizeof(stridingStepSize), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet to set the ADC trigger threshold. */ -class SetAdcThreshold: public SpacePacket { -public: +class SetAdcThreshold : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param threshold + */ + SetAdcThreshold(uint32_t threshold) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_THRESHOLD, DEFAULT_SEQUENCE_COUNT), + threshold(threshold) { + initPacket(); + } - /** - * @brief Constructor - * - * @param threshold - */ - SetAdcThreshold(uint32_t threshold) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_THRESHOLD, - DEFAULT_SEQUENCE_COUNT), threshold(threshold) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 6; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 6; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint32_t threshold = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint32_t threshold = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&threshold, &data_field_ptr, &serializedSize, - sizeof(threshold), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&threshold, &data_field_ptr, &serializedSize, + sizeof(threshold), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet to select between NVM 0 and NVM 1. */ -class SelectNvm: public SpacePacket { -public: +class SelectNvm : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param mem 0 - select NVM0, 1 - select NVM1. + */ + SelectNvm(uint8_t mem) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SELECT_NVM, DEFAULT_SEQUENCE_COUNT), + mem(mem) { + initPacket(); + } - /** - * @brief Constructor - * - * @param mem 0 - select NVM0, 1 - select NVM1. - */ - SelectNvm(uint8_t mem) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SELECT_NVM, - DEFAULT_SEQUENCE_COUNT), mem(mem) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 3; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 3; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t mem = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t mem = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&mem, &data_field_ptr, &serializedSize, - sizeof(mem), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&mem, &data_field_ptr, &serializedSize, sizeof(mem), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet to power the NVMs on or off. */ -class EnableNvms: public SpacePacket { -public: +class EnableNvms : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param n01 Set to one to power NVM0 and NVM1 on. 0 powers off memory. + * @param n3 Set to one to power NVM3 on. 0 powers off the memory. + */ + EnableNvms(uint8_t n01, uint8_t n3) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_ENABLE_NVMS, DEFAULT_SEQUENCE_COUNT), + n01(n01), + n3(n3) { + initPacket(); + } - /** - * @brief Constructor - * - * @param n01 Set to one to power NVM0 and NVM1 on. 0 powers off memory. - * @param n3 Set to one to power NVM3 on. 0 powers off the memory. - */ - EnableNvms(uint8_t n01, uint8_t n3) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_ENABLE_NVMS, - DEFAULT_SEQUENCE_COUNT), n01(n01), n3(n3) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 4; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 4; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t n01 = 0; + uint8_t n3 = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t n01 = 0; - uint8_t n3 = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&n01, &data_field_ptr, &serializedSize, - sizeof(n01), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&n3, &data_field_ptr, &serializedSize, - sizeof(n3), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&n01, &data_field_ptr, &serializedSize, sizeof(n01), + SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&n3, &data_field_ptr, &serializedSize, sizeof(n3), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet to run auto EM tests. */ -class RunAutoEmTests: public SpacePacket { -public: +class RunAutoEmTests : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param test 1 - complete EM test, 2 - Short test (only memory readback NVM0,1,3) + */ + RunAutoEmTests(uint8_t test) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_RUN_AUTO_EM_TESTS, DEFAULT_SEQUENCE_COUNT), + test(test) { + initPacket(); + } - /** - * @brief Constructor - * - * @param test 1 - complete EM test, 2 - Short test (only memory readback NVM0,1,3) - */ - RunAutoEmTests(uint8_t test) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_RUN_AUTO_EM_TESTS, - DEFAULT_SEQUENCE_COUNT), test(test) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 3; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 3; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t test = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t test = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&test, &data_field_ptr, &serializedSize, - sizeof(test), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&test, &data_field_ptr, &serializedSize, sizeof(test), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet causing the supervisor to print the CPU load to * the debug output. */ -class PrintCpuStats: public SpacePacket { -public: +class PrintCpuStats : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param en Print is enabled if en != 0 + */ + PrintCpuStats(uint8_t en) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_PRINT_CPU_STATS, DEFAULT_SEQUENCE_COUNT), + en(en) { + initPacket(); + } - /** - * @brief Constructor - * - * @param en Print is enabled if en != 0 - */ - PrintCpuStats(uint8_t en) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_PRINT_CPU_STATS, - DEFAULT_SEQUENCE_COUNT), en(en) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 3; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 3; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t en = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t en = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&en, &data_field_ptr, &serializedSize, - sizeof(en), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&en, &data_field_ptr, &serializedSize, sizeof(en), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet to set the print verbosity in the supervisor * software. */ -class SetDbgVerbosity: public SpacePacket { -public: +class SetDbgVerbosity : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param vb 0: None, 1: Error, 2: Warn, 3: Info + */ + SetDbgVerbosity(uint8_t vb) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_DBG_VERBOSITY, DEFAULT_SEQUENCE_COUNT), + vb(vb) { + initPacket(); + } - /** - * @brief Constructor - * - * @param vb 0: None, 1: Error, 2: Warn, 3: Info - */ - SetDbgVerbosity(uint8_t vb) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_DBG_VERBOSITY, - DEFAULT_SEQUENCE_COUNT), vb(vb) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 3; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 3; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t vb = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t vb = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&vb, &data_field_ptr, &serializedSize, - sizeof(vb), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&vb, &data_field_ptr, &serializedSize, sizeof(vb), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; - /** * @brief This class packages the space packet to wipe or dump parts of the MRAM. */ -class MramCmd: public SpacePacket { -public: +class MramCmd : public SpacePacket { + public: + enum class MramAction { WIPE, DUMP }; - enum class MramAction { - WIPE, - DUMP - }; - - /** - * @brief Constructor - * - * @param start Start address of the MRAM section to wipe or dump - * @param stop End address of the MRAM section to wipe or dump - * @param action Dump or wipe MRAM - * - * @note The content at the stop address is excluded from the dump or wipe operation. - */ - MramCmd(uint32_t start, uint32_t stop, MramAction action) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_IDLE_PACKET, - DEFAULT_SEQUENCE_COUNT), start(start), stop(stop) { - if(action == MramAction::WIPE) { - this->setAPID(APID_WIPE_MRAM); - } - else if (action == MramAction::DUMP) { - this->setAPID(APID_DUMP_MRAM); - } - else { - sif::debug << "WipeMram: Invalid action specified"; - } - initPacket(); + /** + * @brief Constructor + * + * @param start Start address of the MRAM section to wipe or dump + * @param stop End address of the MRAM section to wipe or dump + * @param action Dump or wipe MRAM + * + * @note The content at the stop address is excluded from the dump or wipe operation. + */ + MramCmd(uint32_t start, uint32_t stop, MramAction action) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_IDLE_PACKET, DEFAULT_SEQUENCE_COUNT), + start(start), + stop(stop) { + if (action == MramAction::WIPE) { + this->setAPID(APID_WIPE_MRAM); + } else if (action == MramAction::DUMP) { + this->setAPID(APID_DUMP_MRAM); + } else { + sif::debug << "WipeMram: Invalid action specified"; } + initPacket(); + } -private: + private: + static const uint16_t DATA_FIELD_LENGTH = 8; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; - static const uint16_t DATA_FIELD_LENGTH = 8; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; + uint32_t start = 0; + uint32_t stop = 0; - uint32_t start = 0; - uint32_t stop = 0; - - void initPacket() { - uint8_t concatBuffer[6]; - concatBuffer[0] = static_cast(start >> 16); - concatBuffer[1] = static_cast(start >> 8); - concatBuffer[2] = static_cast(start); - concatBuffer[3] = static_cast(stop >> 16); - concatBuffer[4] = static_cast(stop >> 8); - concatBuffer[5] = static_cast(stop); - uint8_t* data_field_ptr = this->localData.fields.buffer; - std::memcpy(data_field_ptr, concatBuffer, sizeof(concatBuffer)); - size_t serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + uint8_t concatBuffer[6]; + concatBuffer[0] = static_cast(start >> 16); + concatBuffer[1] = static_cast(start >> 8); + concatBuffer[2] = static_cast(start); + concatBuffer[3] = static_cast(stop >> 16); + concatBuffer[4] = static_cast(stop >> 8); + concatBuffer[5] = static_cast(stop); + uint8_t* data_field_ptr = this->localData.fields.buffer; + std::memcpy(data_field_ptr, concatBuffer, sizeof(concatBuffer)); + size_t serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet change the state of a GPIO. This command is only * required for ground testing. */ -class SetGpio: public SpacePacket { -public: +class SetGpio : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param port + * @param pin + * @param val + */ + SetGpio(uint8_t port, uint8_t pin, uint8_t val) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_GPIO, DEFAULT_SEQUENCE_COUNT), + port(port), + pin(pin), + val(val) { + initPacket(); + } - /** - * @brief Constructor - * - * @param port - * @param pin - * @param val - */ - SetGpio(uint8_t port, uint8_t pin, uint8_t val) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_GPIO, - DEFAULT_SEQUENCE_COUNT), port(port), pin(pin), val(val) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 5; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 5; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t port = 0; + uint8_t pin = 0; + uint8_t val = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t port = 0; - uint8_t pin = 0; - uint8_t val = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&port, &data_field_ptr, &serializedSize, - sizeof(port), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&pin, &data_field_ptr, &serializedSize, - sizeof(pin), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&val, &data_field_ptr, &serializedSize, - sizeof(val), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&port, &data_field_ptr, &serializedSize, sizeof(port), + SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&pin, &data_field_ptr, &serializedSize, sizeof(pin), + SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&val, &data_field_ptr, &serializedSize, sizeof(val), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet causing the supervisor print the state of a GPIO * to the debug output. */ -class ReadGpio: public SpacePacket { -public: +class ReadGpio : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param port + * @param pin + */ + ReadGpio(uint8_t port, uint8_t pin) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_READ_GPIO, DEFAULT_SEQUENCE_COUNT), + port(port), + pin(pin) { + initPacket(); + } - /** - * @brief Constructor - * - * @param port - * @param pin - */ - ReadGpio(uint8_t port, uint8_t pin) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_READ_GPIO, - DEFAULT_SEQUENCE_COUNT), port(port), pin(pin) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 4; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 4; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t port = 0; + uint8_t pin = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t port = 0; - uint8_t pin = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&port, &data_field_ptr, &serializedSize, - sizeof(port), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&pin, &data_field_ptr, &serializedSize, - sizeof(pin), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&port, &data_field_ptr, &serializedSize, sizeof(port), + SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&pin, &data_field_ptr, &serializedSize, sizeof(pin), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** @@ -1355,255 +1311,236 @@ private: * OP = 0x01: Only the mirror entries will be wiped. * OP = 0x02: Only the circular entries will be wiped. */ -class FactoryReset: public SpacePacket { -public: +class FactoryReset : public SpacePacket { + public: + enum class Op { CLEAR_ALL, MIRROR_ENTRIES, CIRCULAR_ENTRIES }; - enum class Op { - CLEAR_ALL, - MIRROR_ENTRIES, - CIRCULAR_ENTRIES - }; + /** + * @brief Constructor + * + * @param op + */ + FactoryReset(Op op) : SpacePacket(0, true, APID_FACTORY_RESET, DEFAULT_SEQUENCE_COUNT), op(op) { + initPacket(); + } - /** - * @brief Constructor - * - * @param op - */ - FactoryReset(Op op) : - SpacePacket(0, true, APID_FACTORY_RESET, - DEFAULT_SEQUENCE_COUNT), op(op) { - initPacket(); - } - -private: - - uint16_t packetLen = 1; // only CRC in data field - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; - - uint8_t crcOffset = 0; - - Op op = Op::CLEAR_ALL; - - void initPacket() { - - uint8_t* data_field_ptr = this->localData.fields.buffer; - - switch(op) { - case Op::MIRROR_ENTRIES: - *data_field_ptr = 1; - packetLen = 2; - crcOffset = 1; - break; - case Op::CIRCULAR_ENTRIES: - *data_field_ptr = 2; - packetLen = 2; - crcOffset = 1; - break; - default: - break; - } - this->setPacketDataLength(packetLen); - size_t serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + packetLen - 1); - uint8_t* crcPos = this->localData.fields.buffer + crcOffset; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); + private: + uint16_t packetLen = 1; // only CRC in data field + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + + uint8_t crcOffset = 0; + + Op op = Op::CLEAR_ALL; + + void initPacket() { + uint8_t* data_field_ptr = this->localData.fields.buffer; + + switch (op) { + case Op::MIRROR_ENTRIES: + *data_field_ptr = 1; + packetLen = 2; + crcOffset = 1; + break; + case Op::CIRCULAR_ENTRIES: + *data_field_ptr = 2; + packetLen = 2; + crcOffset = 1; + break; + default: + break; } + this->setPacketDataLength(packetLen); + size_t serializedSize = 0; + uint16_t crc = + CRC::crc16ccitt(this->localData.byteStream, sizeof(CCSDSPrimaryHeader) + packetLen - 1); + uint8_t* crcPos = this->localData.fields.buffer + crcOffset; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; class SupvTcSpacePacket : public SpacePacket { -public: - SupvTcSpacePacket(size_t payloadDataLen, uint16_t apid) : - SpacePacket(payloadDataLen + 1, true, apid, - DEFAULT_SEQUENCE_COUNT), payloadDataLen(payloadDataLen) { - } + public: + SupvTcSpacePacket(size_t payloadDataLen, uint16_t apid) + : SpacePacket(payloadDataLen + 1, true, apid, DEFAULT_SEQUENCE_COUNT), + payloadDataLen(payloadDataLen) {} - void makeCrc() { - size_t serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + payloadDataLen); - uint8_t* crcPos = this->localData.fields.buffer + payloadDataLen; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void makeCrc() { + size_t serializedSize = 0; + uint16_t crc = + CRC::crc16ccitt(this->localData.byteStream, sizeof(CCSDSPrimaryHeader) + payloadDataLen); + uint8_t* crcPos = this->localData.fields.buffer + payloadDataLen; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } -private: - // The sequence count of most of the TC packets for the supervisor is 1. - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + private: + // The sequence count of most of the TC packets for the supervisor is 1. + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; - // The size of the payload data (data field without crc size) - size_t payloadDataLen = 0; + // The size of the payload data (data field without crc size) + size_t payloadDataLen = 0; }; /** * @brief This class can be used to package the update available or update verify command. */ -class UpdateInfo: public SupvTcSpacePacket { -public: +class UpdateInfo : public SupvTcSpacePacket { + public: + /** + * @brief Constructor + * + * @param apid Packet can be used to generate the update available and the update verify + * packet. Thus the APID must be specified here. + * @param image The image to update on a NVM (A - 0, B - 1) + * @param partition The partition to update. uboot - 1, bitstream - 2, linux - 3, + * application - 4 + * @param imageSize The size of the update image + * param numPackets The number of space packets required to transfer all data. + */ + UpdateInfo(uint16_t apid, uint8_t image, uint8_t partition, uint32_t imageSize, uint32_t imageCrc, + uint32_t numPackets) + : SupvTcSpacePacket(PAYLOAD_LENGTH, apid), + image(image), + partition(partition), + imageSize(imageSize), + imageCrc(imageCrc), + numPackets(numPackets) { + initPacket(); + makeCrc(); + } - /** - * @brief Constructor - * - * @param apid Packet can be used to generate the update available and the update verify - * packet. Thus the APID must be specified here. - * @param image The image to update on a NVM (A - 0, B - 1) - * @param partition The partition to update. uboot - 1, bitstream - 2, linux - 3, - * application - 4 - * @param imageSize The size of the update image - * param numPackets The number of space packets required to transfer all data. - */ - UpdateInfo(uint16_t apid, uint8_t image, uint8_t partition, uint32_t imageSize, - uint32_t imageCrc, uint32_t numPackets) : - SupvTcSpacePacket(PAYLOAD_LENGTH, apid), image(image), partition(partition), imageSize( - imageSize), imageCrc(imageCrc), numPackets(numPackets) { - initPacket(); - makeCrc(); - } + private: + static const uint16_t PAYLOAD_LENGTH = 14; // length without CRC field -private: + uint8_t image = 0; + uint8_t partition = 0; + uint32_t imageSize = 0; + uint32_t imageCrc = 0; + uint32_t numPackets = 0; - static const uint16_t PAYLOAD_LENGTH = 14; // length without CRC field - - uint8_t image = 0; - uint8_t partition = 0; - uint32_t imageSize = 0; - uint32_t imageCrc = 0; - uint32_t numPackets = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&image, &data_field_ptr, &serializedSize, - sizeof(image), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&partition, &data_field_ptr, &serializedSize, - sizeof(partition), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&imageSize, &data_field_ptr, &serializedSize, - sizeof(imageSize), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&imageCrc, &data_field_ptr, &serializedSize, - sizeof(imageCrc), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&numPackets, &data_field_ptr, &serializedSize, - sizeof(numPackets), SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&image, &data_field_ptr, &serializedSize, sizeof(image), + SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&partition, &data_field_ptr, &serializedSize, + sizeof(partition), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&imageSize, &data_field_ptr, &serializedSize, + sizeof(imageSize), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&imageCrc, &data_field_ptr, &serializedSize, + sizeof(imageCrc), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&numPackets, &data_field_ptr, &serializedSize, + sizeof(numPackets), SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet transporting a part of an MPSoC update. */ -class UpdatePacket: public SupvTcSpacePacket { -public: +class UpdatePacket : public SupvTcSpacePacket { + public: + /** + * @brief Constructor + * + * @param payloadLength Update data length (data field length without CRC) + */ + UpdatePacket(uint16_t payloadLength) : SupvTcSpacePacket(payloadLength, APID_UPDATE_IMAGE_DATA) {} - /** - * @brief Constructor - * - * @param payloadLength Update data length (data field length without CRC) - */ - UpdatePacket(uint16_t payloadLength) : - SupvTcSpacePacket(payloadLength, APID_UPDATE_IMAGE_DATA) { - } - - /** - * @brief Returns the pointer to the beginning of the data field. - */ - uint8_t* getDataFieldPointer() { - return this->localData.fields.buffer; - } + /** + * @brief Returns the pointer to the beginning of the data field. + */ + uint8_t* getDataFieldPointer() { return this->localData.fields.buffer; } }; /** * @brief This dataset stores the boot status report of the supervisor. */ -class BootStatusReport: public StaticLocalDataSet { -public: +class BootStatusReport : public StaticLocalDataSet { + public: + BootStatusReport(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, BOOT_REPORT_SET_ID) {} - BootStatusReport(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, BOOT_REPORT_SET_ID) { - } + BootStatusReport(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, BOOT_REPORT_SET_ID)) {} - BootStatusReport(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, BOOT_REPORT_SET_ID)) { - } - - /** Information about boot status of MPSoC */ - lp_var_t bootSignal = lp_var_t(sid.objectId, PoolIds::BOOT_SIGNAL, this); - lp_var_t resetCounter = lp_var_t(sid.objectId, PoolIds::RESET_COUNTER, this); - /** Time the MPSoC needs for last boot */ - lp_var_t bootAfterMs = lp_var_t(sid.objectId, PoolIds::BOOT_AFTER_MS, this); - /** The currently set boot timeout */ - lp_var_t bootTimeoutMs = lp_var_t(sid.objectId, PoolIds::BOOT_TIMEOUT_MS, this); - lp_var_t activeNvm = lp_var_t(sid.objectId, PoolIds::ACTIVE_NVM, this); - /** States of the boot partition pins */ - lp_var_t bp0State = lp_var_t(sid.objectId, PoolIds::BP0_STATE, this); - lp_var_t bp1State = lp_var_t(sid.objectId, PoolIds::BP1_STATE, this); - lp_var_t bp2State = lp_var_t(sid.objectId, PoolIds::BP2_STATE, this); + /** Information about boot status of MPSoC */ + lp_var_t bootSignal = lp_var_t(sid.objectId, PoolIds::BOOT_SIGNAL, this); + lp_var_t resetCounter = lp_var_t(sid.objectId, PoolIds::RESET_COUNTER, this); + /** Time the MPSoC needs for last boot */ + lp_var_t bootAfterMs = lp_var_t(sid.objectId, PoolIds::BOOT_AFTER_MS, this); + /** The currently set boot timeout */ + lp_var_t bootTimeoutMs = + lp_var_t(sid.objectId, PoolIds::BOOT_TIMEOUT_MS, this); + lp_var_t activeNvm = lp_var_t(sid.objectId, PoolIds::ACTIVE_NVM, this); + /** States of the boot partition pins */ + lp_var_t bp0State = lp_var_t(sid.objectId, PoolIds::BP0_STATE, this); + lp_var_t bp1State = lp_var_t(sid.objectId, PoolIds::BP1_STATE, this); + lp_var_t bp2State = lp_var_t(sid.objectId, PoolIds::BP2_STATE, this); }; /** * @brief This dataset stores the housekeeping data of the supervisor. */ -class HkSet: public StaticLocalDataSet { -public: +class HkSet : public StaticLocalDataSet { + public: + HkSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_SET_ID) {} - HkSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, HK_SET_ID) { - } + HkSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, HK_SET_ID)) {} - HkSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, HK_SET_ID)) { - } - - lp_var_t tempPs = lp_var_t(sid.objectId, PoolIds::TEMP_PS, this); - lp_var_t tempPl = lp_var_t(sid.objectId, PoolIds::TEMP_PS, this); - lp_var_t tempSup = lp_var_t(sid.objectId, PoolIds::TEMP_SUP, this); - lp_var_t uptime = lp_var_t(sid.objectId, PoolIds::UPTIME, this); - lp_var_t cpuLoad = lp_var_t(sid.objectId, PoolIds::CPULOAD, this); - lp_var_t availableHeap = lp_var_t(sid.objectId, PoolIds::AVAILABLEHEAP, - this); - lp_var_t numTcs = lp_var_t(sid.objectId, PoolIds::NUM_TCS, this); - lp_var_t numTms = lp_var_t(sid.objectId, PoolIds::NUM_TMS, this); - lp_var_t socState = lp_var_t(sid.objectId, PoolIds::SOC_STATE, this); - lp_var_t nvm0_1_state = lp_var_t(sid.objectId, PoolIds::NVM0_1_STATE, this); - lp_var_t nvm3_state = lp_var_t(sid.objectId, PoolIds::NVM3_STATE, this); - lp_var_t missionIoState = lp_var_t(sid.objectId, PoolIds::MISSION_IO_STATE, - this); - lp_var_t fmcState = lp_var_t(sid.objectId, PoolIds::FMC_STATE, this); + lp_var_t tempPs = lp_var_t(sid.objectId, PoolIds::TEMP_PS, this); + lp_var_t tempPl = lp_var_t(sid.objectId, PoolIds::TEMP_PS, this); + lp_var_t tempSup = lp_var_t(sid.objectId, PoolIds::TEMP_SUP, this); + lp_var_t uptime = lp_var_t(sid.objectId, PoolIds::UPTIME, this); + lp_var_t cpuLoad = lp_var_t(sid.objectId, PoolIds::CPULOAD, this); + lp_var_t availableHeap = lp_var_t(sid.objectId, PoolIds::AVAILABLEHEAP, this); + lp_var_t numTcs = lp_var_t(sid.objectId, PoolIds::NUM_TCS, this); + lp_var_t numTms = lp_var_t(sid.objectId, PoolIds::NUM_TMS, this); + lp_var_t socState = lp_var_t(sid.objectId, PoolIds::SOC_STATE, this); + lp_var_t nvm0_1_state = lp_var_t(sid.objectId, PoolIds::NVM0_1_STATE, this); + lp_var_t nvm3_state = lp_var_t(sid.objectId, PoolIds::NVM3_STATE, this); + lp_var_t missionIoState = + lp_var_t(sid.objectId, PoolIds::MISSION_IO_STATE, this); + lp_var_t fmcState = lp_var_t(sid.objectId, PoolIds::FMC_STATE, this); }; /** * @brief This dataset stores the last requested latchup status report. */ -class LatchupStatusReport: public StaticLocalDataSet { -public: +class LatchupStatusReport : public StaticLocalDataSet { + public: + LatchupStatusReport(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, LATCHUP_RPT_ID) {} - LatchupStatusReport(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, LATCHUP_RPT_ID) { - } + LatchupStatusReport(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, LATCHUP_RPT_ID)) {} - LatchupStatusReport(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, LATCHUP_RPT_ID)) { - } - - lp_var_t id = lp_var_t(sid.objectId, PoolIds::LATCHUP_ID, this); - lp_var_t cnt0 = lp_var_t(sid.objectId, PoolIds::CNT0, this); - lp_var_t cnt1 = lp_var_t(sid.objectId, PoolIds::CNT1, this); - lp_var_t cnt2 = lp_var_t(sid.objectId, PoolIds::CNT2, this); - lp_var_t cnt3 = lp_var_t(sid.objectId, PoolIds::CNT3, this); - lp_var_t cnt4 = lp_var_t(sid.objectId, PoolIds::CNT4, this); - lp_var_t cnt5 = lp_var_t(sid.objectId, PoolIds::CNT5, this); - lp_var_t cnt6 = lp_var_t(sid.objectId, PoolIds::CNT6, this); - lp_var_t timeSec = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_SEC, this); - lp_var_t timeMin = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MIN, this); - lp_var_t timeHour = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_HOUR, this); - lp_var_t timeDay = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_DAY, this); - lp_var_t timeMon = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MON, this); - lp_var_t timeYear = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_YEAR, this); - lp_var_t timeMsec = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MSEC, this); - lp_var_t isSet = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_IS_SET, this); + lp_var_t id = lp_var_t(sid.objectId, PoolIds::LATCHUP_ID, this); + lp_var_t cnt0 = lp_var_t(sid.objectId, PoolIds::CNT0, this); + lp_var_t cnt1 = lp_var_t(sid.objectId, PoolIds::CNT1, this); + lp_var_t cnt2 = lp_var_t(sid.objectId, PoolIds::CNT2, this); + lp_var_t cnt3 = lp_var_t(sid.objectId, PoolIds::CNT3, this); + lp_var_t cnt4 = lp_var_t(sid.objectId, PoolIds::CNT4, this); + lp_var_t cnt5 = lp_var_t(sid.objectId, PoolIds::CNT5, this); + lp_var_t cnt6 = lp_var_t(sid.objectId, PoolIds::CNT6, this); + lp_var_t timeSec = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_SEC, this); + lp_var_t timeMin = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MIN, this); + lp_var_t timeHour = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_HOUR, this); + lp_var_t timeDay = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_DAY, this); + lp_var_t timeMon = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MON, this); + lp_var_t timeYear = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_YEAR, this); + lp_var_t timeMsec = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MSEC, this); + lp_var_t isSet = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_IS_SET, this); }; -} +} // namespace PLOC_SPV #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCSVPDEFINITIONS_H_ */ diff --git a/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.cpp b/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.cpp index 4e7c9458..9d8d7bbf 100644 --- a/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.cpp +++ b/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.cpp @@ -1,78 +1,62 @@ #include "ArcsecDatalinkLayer.h" -ArcsecDatalinkLayer::ArcsecDatalinkLayer() { - slipInit(); -} +ArcsecDatalinkLayer::ArcsecDatalinkLayer() { slipInit(); } -ArcsecDatalinkLayer::~ArcsecDatalinkLayer() { -} +ArcsecDatalinkLayer::~ArcsecDatalinkLayer() {} void ArcsecDatalinkLayer::slipInit() { - slipInfo.buffer = rxBuffer; - slipInfo.maxlength = StarTracker::MAX_FRAME_SIZE; - slipInfo.length = 0; - slipInfo.unescape_next = 0; - slipInfo.prev_state = SLIP_COMPLETE; + slipInfo.buffer = rxBuffer; + slipInfo.maxlength = StarTracker::MAX_FRAME_SIZE; + slipInfo.length = 0; + slipInfo.unescape_next = 0; + slipInfo.prev_state = SLIP_COMPLETE; } ReturnValue_t ArcsecDatalinkLayer::decodeFrame(const uint8_t* rawData, size_t rawDataSize, - size_t* bytesLeft) { - size_t bytePos = 0; - for (bytePos = 0; bytePos < rawDataSize; bytePos++) { - enum arc_dec_result decResult = arc_transport_decode_body(*(rawData + bytePos), &slipInfo, - decodedFrame, &decFrameSize); - *bytesLeft = rawDataSize - bytePos - 1; - switch (decResult) { - case ARC_DEC_INPROGRESS: { - if (bytePos == rawDataSize - 1) { - return DEC_IN_PROGRESS; - } - continue; - } - case ARC_DEC_ERROR_FRAME_SHORT: - return REPLY_TOO_SHORT; - case ARC_DEC_ERROR_CHECKSUM: - return CRC_FAILURE; - case ARC_DEC_ASYNC: - case ARC_DEC_SYNC: { - // Reset length of SLIP struct for next frame - slipInfo.length = 0; - return RETURN_OK; - } - default: - sif::debug << "ArcsecDatalinkLayer::decodeFrame: Unknown result code" << std::endl; - break; - return RETURN_FAILED; + size_t* bytesLeft) { + size_t bytePos = 0; + for (bytePos = 0; bytePos < rawDataSize; bytePos++) { + enum arc_dec_result decResult = + arc_transport_decode_body(*(rawData + bytePos), &slipInfo, decodedFrame, &decFrameSize); + *bytesLeft = rawDataSize - bytePos - 1; + switch (decResult) { + case ARC_DEC_INPROGRESS: { + if (bytePos == rawDataSize - 1) { + return DEC_IN_PROGRESS; } + continue; + } + case ARC_DEC_ERROR_FRAME_SHORT: + return REPLY_TOO_SHORT; + case ARC_DEC_ERROR_CHECKSUM: + return CRC_FAILURE; + case ARC_DEC_ASYNC: + case ARC_DEC_SYNC: { + // Reset length of SLIP struct for next frame + slipInfo.length = 0; + return RETURN_OK; + } + default: + sif::debug << "ArcsecDatalinkLayer::decodeFrame: Unknown result code" << std::endl; + break; + return RETURN_FAILED; } - return RETURN_FAILED; + } + return RETURN_FAILED; } -uint8_t ArcsecDatalinkLayer::getReplyFrameType() { - return decodedFrame[0]; -} +uint8_t ArcsecDatalinkLayer::getReplyFrameType() { return decodedFrame[0]; } -const uint8_t* ArcsecDatalinkLayer::getReply() { - return &decodedFrame[1]; -} +const uint8_t* ArcsecDatalinkLayer::getReply() { return &decodedFrame[1]; } void ArcsecDatalinkLayer::encodeFrame(const uint8_t* data, uint32_t length) { - arc_transport_encode_body(data, length, encBuffer, &encFrameSize); + arc_transport_encode_body(data, length, encBuffer, &encFrameSize); } -uint8_t* ArcsecDatalinkLayer::getEncodedFrame() { - return encBuffer; -} +uint8_t* ArcsecDatalinkLayer::getEncodedFrame() { return encBuffer; } -uint32_t ArcsecDatalinkLayer::getEncodedLength() { - return encFrameSize; -} +uint32_t ArcsecDatalinkLayer::getEncodedLength() { return encFrameSize; } -uint8_t ArcsecDatalinkLayer::getStatusField() { - return *(decodedFrame + STATUS_OFFSET); -} - -uint8_t ArcsecDatalinkLayer::getId() { - return *(decodedFrame + ID_OFFSET); -} +uint8_t ArcsecDatalinkLayer::getStatusField() { return *(decodedFrame + STATUS_OFFSET); } +uint8_t ArcsecDatalinkLayer::getId() { return *(decodedFrame + ID_OFFSET); } diff --git a/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.h b/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.h index a65881c7..6b4d3095 100644 --- a/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.h +++ b/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.h @@ -5,96 +5,94 @@ #include "fsfw/returnvalues/HasReturnvaluesIF.h" extern "C" { - #include "common/misc.h" +#include "common/misc.h" } /** * @brief Helper class to handle the datalinklayer of replies from the star tracker of arcsec. */ -class ArcsecDatalinkLayer: public HasReturnvaluesIF { -public: +class ArcsecDatalinkLayer : public HasReturnvaluesIF { + public: + static const uint8_t INTERFACE_ID = CLASS_ID::STR_HANDLER; - static const uint8_t INTERFACE_ID = CLASS_ID::STR_HANDLER; + //! [EXPORT] : [COMMENT] More data required to complete frame + static const ReturnValue_t DEC_IN_PROGRESS = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] Data too short to represent a valid frame + static const ReturnValue_t REPLY_TOO_SHORT = MAKE_RETURN_CODE(0xA1); + //! [EXPORT] : [COMMENT] Detected CRC failure in received frame + static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA2); - //! [EXPORT] : [COMMENT] More data required to complete frame - static const ReturnValue_t DEC_IN_PROGRESS = MAKE_RETURN_CODE(0xA0); - //! [EXPORT] : [COMMENT] Data too short to represent a valid frame - static const ReturnValue_t REPLY_TOO_SHORT = MAKE_RETURN_CODE(0xA1); - //! [EXPORT] : [COMMENT] Detected CRC failure in received frame - static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA2); + static const uint8_t STATUS_OK = 0; - static const uint8_t STATUS_OK = 0; + ArcsecDatalinkLayer(); + virtual ~ArcsecDatalinkLayer(); - ArcsecDatalinkLayer(); - virtual ~ArcsecDatalinkLayer(); + /** + * @brief Applies decoding to data referenced by rawData pointer + * + * @param rawData Pointer to raw data received from star tracker + * @param rawDataSize Size of raw data stream + * @param remainingBytes Number of bytes left + */ + ReturnValue_t decodeFrame(const uint8_t* rawData, size_t rawDataSize, size_t* bytesLeft); - /** - * @brief Applies decoding to data referenced by rawData pointer - * - * @param rawData Pointer to raw data received from star tracker - * @param rawDataSize Size of raw data stream - * @param remainingBytes Number of bytes left - */ - ReturnValue_t decodeFrame(const uint8_t* rawData, size_t rawDataSize, size_t* bytesLeft); + /** + * @brief SLIP encodes data pointed to by data pointer. + * + * @param data Pointer to data to encode + * @param length Length of buffer to encode + */ + void encodeFrame(const uint8_t* data, uint32_t length); - /** - * @brief SLIP encodes data pointed to by data pointer. - * - * @param data Pointer to data to encode - * @param length Length of buffer to encode - */ - void encodeFrame(const uint8_t* data, uint32_t length); + /** + * @brief Returns the frame type field of a decoded frame. + */ + uint8_t getReplyFrameType(); - /** - * @brief Returns the frame type field of a decoded frame. - */ - uint8_t getReplyFrameType(); + /** + * @brief Returns pointer to reply packet (first entry normally action ID, telemetry ID etc.) + */ + const uint8_t* getReply(); - /** - * @brief Returns pointer to reply packet (first entry normally action ID, telemetry ID etc.) - */ - const uint8_t* getReply(); + /** + * @brief Returns size of encoded frame + */ + uint32_t getEncodedLength(); - /** - * @brief Returns size of encoded frame - */ - uint32_t getEncodedLength(); + /** + * @brief Returns pointer to encoded frame + */ + uint8_t* getEncodedFrame(); - /** - * @brief Returns pointer to encoded frame - */ - uint8_t* getEncodedFrame(); + /** + * @brief Returns status of reply + */ + uint8_t getStatusField(); - /** - * @brief Returns status of reply - */ - uint8_t getStatusField(); + /** + * @brief Returns ID of reply + */ + uint8_t getId(); - /** - * @brief Returns ID of reply - */ - uint8_t getId(); + private: + static const uint8_t ID_OFFSET = 1; + static const uint8_t STATUS_OFFSET = 2; -private: + // Used by arcsec slip decoding function process received data + uint8_t rxBuffer[StarTracker::MAX_FRAME_SIZE]; + // Decoded frame will be copied to this buffer + uint8_t decodedFrame[StarTracker::MAX_FRAME_SIZE]; + // Buffer where encoded frames will be stored. First byte of encoded frame represents type of + // reply + uint8_t encBuffer[StarTracker::MAX_FRAME_SIZE * 2 + 2]; + // Size of decoded frame + uint32_t decFrameSize = 0; + // Size of encoded frame + uint32_t encFrameSize = 0; - static const uint8_t ID_OFFSET = 1; - static const uint8_t STATUS_OFFSET = 2; + slip_decode_state slipInfo; - // Used by arcsec slip decoding function process received data - uint8_t rxBuffer[StarTracker::MAX_FRAME_SIZE]; - // Decoded frame will be copied to this buffer - uint8_t decodedFrame[StarTracker::MAX_FRAME_SIZE]; - // Buffer where encoded frames will be stored. First byte of encoded frame represents type of - // reply - uint8_t encBuffer[StarTracker::MAX_FRAME_SIZE * 2 + 2]; - // Size of decoded frame - uint32_t decFrameSize = 0; - // Size of encoded frame - uint32_t encFrameSize = 0; - - slip_decode_state slipInfo; - - void slipInit(); + void slipInit(); }; #endif /* BSP_Q7S_DEVICES_ARCSECDATALINKLAYER_H_ */ diff --git a/bsp_q7s/devices/startracker/ArcsecJsonKeys.h b/bsp_q7s/devices/startracker/ArcsecJsonKeys.h index 2c598b43..67a80b88 100644 --- a/bsp_q7s/devices/startracker/ArcsecJsonKeys.h +++ b/bsp_q7s/devices/startracker/ArcsecJsonKeys.h @@ -5,122 +5,122 @@ * @brief Keys used in JSON file of ARCSEC. */ namespace arcseckeys { - static const char PROPERTIES[] = "properties"; - static const char NAME[] = "name"; - static const char VALUE[] = "value"; +static const char PROPERTIES[] = "properties"; +static const char NAME[] = "name"; +static const char VALUE[] = "value"; - static const char LIMITS[] = "limits"; - static const char ACTION[] = "action"; - static const char FPGA18CURRENT[] = "FPGA18Current"; - static const char FPGA25CURRENT[] = "FPGA25Current"; - static const char FPGA10CURRENT[] = "FPGA10Current"; - static const char MCUCURRENT[] = "MCUCurrent"; - static const char CMOS21CURRENT[] = "CMOS21Current"; - static const char CMOSPIXCURRENT[] = "CMOSPixCurrent"; - static const char CMOS33CURRENT[] = "CMOS33Current"; - static const char CMOSVRESCURRENT[] = "CMOSVResCurrent"; - static const char CMOS_TEMPERATURE[] = "CMOSTemperature"; - static const char MCU_TEMPERATURE[] = "MCUTemperature"; +static const char LIMITS[] = "limits"; +static const char ACTION[] = "action"; +static const char FPGA18CURRENT[] = "FPGA18Current"; +static const char FPGA25CURRENT[] = "FPGA25Current"; +static const char FPGA10CURRENT[] = "FPGA10Current"; +static const char MCUCURRENT[] = "MCUCurrent"; +static const char CMOS21CURRENT[] = "CMOS21Current"; +static const char CMOSPIXCURRENT[] = "CMOSPixCurrent"; +static const char CMOS33CURRENT[] = "CMOS33Current"; +static const char CMOSVRESCURRENT[] = "CMOSVResCurrent"; +static const char CMOS_TEMPERATURE[] = "CMOSTemperature"; +static const char MCU_TEMPERATURE[] = "MCUTemperature"; - static const char MOUNTING[] = "mounting"; - static const char qw[] = "qw"; - static const char qx[] = "qx"; - static const char qy[] = "qy"; - static const char qz[] = "qz"; +static const char MOUNTING[] = "mounting"; +static const char qw[] = "qw"; +static const char qx[] = "qx"; +static const char qy[] = "qy"; +static const char qz[] = "qz"; - static const char CAMERA[] = "camera"; - static const char MODE[] = "mode"; - static const char FOCALLENGTH[] = "focallength"; - static const char EXPOSURE[] = "exposure"; - static const char INTERVAL[] = "interval"; - static const char OFFSET[] = "offset"; - static const char PGAGAIN[] = "PGAGain"; - static const char ADCGAIN[] = "ADCGain"; - static const char REG_1[] = "reg1"; - static const char VAL_1[] = "val1"; - static const char REG_2[] = "reg2"; - static const char VAL_2[] = "val2"; - static const char REG_3[] = "reg3"; - static const char VAL_3[] = "val3"; - static const char REG_4[] = "reg4"; - static const char VAL_4[] = "val4"; - static const char REG_5[] = "reg5"; - static const char VAL_5[] = "val5"; - static const char REG_6[] = "reg6"; - static const char VAL_6[] = "val6"; - static const char REG_7[] = "reg7"; - static const char VAL_7[] = "val7"; - static const char REG_8[] = "reg8"; - static const char VAL_8[] = "val8"; - static const char FREQ_1[] = "freq1"; - static const char FREQ_2[] = "freq2"; +static const char CAMERA[] = "camera"; +static const char MODE[] = "mode"; +static const char FOCALLENGTH[] = "focallength"; +static const char EXPOSURE[] = "exposure"; +static const char INTERVAL[] = "interval"; +static const char OFFSET[] = "offset"; +static const char PGAGAIN[] = "PGAGain"; +static const char ADCGAIN[] = "ADCGain"; +static const char REG_1[] = "reg1"; +static const char VAL_1[] = "val1"; +static const char REG_2[] = "reg2"; +static const char VAL_2[] = "val2"; +static const char REG_3[] = "reg3"; +static const char VAL_3[] = "val3"; +static const char REG_4[] = "reg4"; +static const char VAL_4[] = "val4"; +static const char REG_5[] = "reg5"; +static const char VAL_5[] = "val5"; +static const char REG_6[] = "reg6"; +static const char VAL_6[] = "val6"; +static const char REG_7[] = "reg7"; +static const char VAL_7[] = "val7"; +static const char REG_8[] = "reg8"; +static const char VAL_8[] = "val8"; +static const char FREQ_1[] = "freq1"; +static const char FREQ_2[] = "freq2"; - static const char BLOB[] = "blob"; - static const char MIN_VALUE[] = "minValue"; - static const char MIN_DISTANCE[] = "minDistance"; - static const char NEIGHBOUR_DISTANCE[] = "neighbourDistance"; - static const char NEIGHBOUR_BRIGHT_PIXELS[] = "neighbourBrightPixels"; - static const char MIN_TOTAL_VALUE[] = "minTotalValue"; - static const char MAX_TOTAL_VALUE[] = "maxTotalValue"; - static const char MIN_BRIGHT_NEIGHBOURS[] = "minBrightNeighbours"; - static const char MAX_BRIGHT_NEIGHBOURS[] = "maxBrightNeighbours"; - static const char MAX_PIXEL_TO_CONSIDER[] = "maxPixelsToConsider"; - static const char SIGNAL_THRESHOLD[] = "signalThreshold"; - static const char DARK_THRESHOLD[] = "darkThreshold"; - static const char ENABLE_HISTOGRAM[] = "enableHistogram"; - static const char ENABLE_CONTRAST[] = "enableContrast"; - static const char BIN_MODE[] = "binMode"; +static const char BLOB[] = "blob"; +static const char MIN_VALUE[] = "minValue"; +static const char MIN_DISTANCE[] = "minDistance"; +static const char NEIGHBOUR_DISTANCE[] = "neighbourDistance"; +static const char NEIGHBOUR_BRIGHT_PIXELS[] = "neighbourBrightPixels"; +static const char MIN_TOTAL_VALUE[] = "minTotalValue"; +static const char MAX_TOTAL_VALUE[] = "maxTotalValue"; +static const char MIN_BRIGHT_NEIGHBOURS[] = "minBrightNeighbours"; +static const char MAX_BRIGHT_NEIGHBOURS[] = "maxBrightNeighbours"; +static const char MAX_PIXEL_TO_CONSIDER[] = "maxPixelsToConsider"; +static const char SIGNAL_THRESHOLD[] = "signalThreshold"; +static const char DARK_THRESHOLD[] = "darkThreshold"; +static const char ENABLE_HISTOGRAM[] = "enableHistogram"; +static const char ENABLE_CONTRAST[] = "enableContrast"; +static const char BIN_MODE[] = "binMode"; - static const char CENTROIDING[] = "centroiding"; - static const char ENABLE_FILTER[] = "enableFilter"; - static const char MAX_QUALITY[] = "maxquality"; - static const char MIN_QUALITY[] = "minquality"; - static const char MAX_INTENSITY[] = "maxintensity"; - static const char MIN_INTENSITY[] = "minintensity"; - static const char MAX_MAGNITUDE[] = "maxmagnitude"; - static const char GAUSSIAN_CMAX[] = "gaussianCmax"; - static const char GAUSSIAN_CMIN[] = "gaussianCmin"; - static const char TRANSMATRIX_00[] = "transmatrix00"; - static const char TRANSMATRIX_01[] = "transmatrix01"; - static const char TRANSMATRIX_10[] = "transmatrix10"; - static const char TRANSMATRIX_11[] = "transmatrix11"; +static const char CENTROIDING[] = "centroiding"; +static const char ENABLE_FILTER[] = "enableFilter"; +static const char MAX_QUALITY[] = "maxquality"; +static const char MIN_QUALITY[] = "minquality"; +static const char MAX_INTENSITY[] = "maxintensity"; +static const char MIN_INTENSITY[] = "minintensity"; +static const char MAX_MAGNITUDE[] = "maxmagnitude"; +static const char GAUSSIAN_CMAX[] = "gaussianCmax"; +static const char GAUSSIAN_CMIN[] = "gaussianCmin"; +static const char TRANSMATRIX_00[] = "transmatrix00"; +static const char TRANSMATRIX_01[] = "transmatrix01"; +static const char TRANSMATRIX_10[] = "transmatrix10"; +static const char TRANSMATRIX_11[] = "transmatrix11"; - static const char LISA[] = "lisa"; - static const char PREFILTER_DIST_THRESHOLD[] = "prefilterDistThreshold"; - static const char PREFILTER_ANGLE_THRESHOLD[] = "prefilterAngleThreshold"; - static const char FOV_WIDTH[] = "fov_width"; - static const char FOV_HEIGHT[] = "fov_height"; - static const char FLOAT_STAR_LIMIT[] = "float_star_limit"; - static const char CLOSE_STAR_LIMIT[] = "close_star_limit"; - static const char RATING_WEIGHT_CLOSE_STAR_COUNT[] = "rating_weight_close_star_count"; - static const char RATING_WEIGHT_FRACTION_CLOSE[] = "rating_weight_fraction_close"; - static const char RATING_WEIGHT_MEAN_SUM[] = "rating_weight_mean_sum"; - static const char RATING_WEIGHT_DB_STAR_COUNT[] = "rating_weight_db_star_count"; - static const char MAX_COMBINATIONS[] = "max_combinations"; - static const char NR_STARS_STOP[] = "nr_stars_stop"; - static const char FRACTION_CLOSE_STOP[] = "fraction_close_stop"; +static const char LISA[] = "lisa"; +static const char PREFILTER_DIST_THRESHOLD[] = "prefilterDistThreshold"; +static const char PREFILTER_ANGLE_THRESHOLD[] = "prefilterAngleThreshold"; +static const char FOV_WIDTH[] = "fov_width"; +static const char FOV_HEIGHT[] = "fov_height"; +static const char FLOAT_STAR_LIMIT[] = "float_star_limit"; +static const char CLOSE_STAR_LIMIT[] = "close_star_limit"; +static const char RATING_WEIGHT_CLOSE_STAR_COUNT[] = "rating_weight_close_star_count"; +static const char RATING_WEIGHT_FRACTION_CLOSE[] = "rating_weight_fraction_close"; +static const char RATING_WEIGHT_MEAN_SUM[] = "rating_weight_mean_sum"; +static const char RATING_WEIGHT_DB_STAR_COUNT[] = "rating_weight_db_star_count"; +static const char MAX_COMBINATIONS[] = "max_combinations"; +static const char NR_STARS_STOP[] = "nr_stars_stop"; +static const char FRACTION_CLOSE_STOP[] = "fraction_close_stop"; - static const char MATCHING[] = "matching"; - static const char SQUARED_DISTANCE_LIMIT[] = "squaredDistanceLimit"; - static const char SQUARED_SHIFT_LIMIT[] = "squaredShiftLimit"; +static const char MATCHING[] = "matching"; +static const char SQUARED_DISTANCE_LIMIT[] = "squaredDistanceLimit"; +static const char SQUARED_SHIFT_LIMIT[] = "squaredShiftLimit"; - static const char VALIDATION[] = "validation"; - static const char STABLE_COUNT[] = "stable_count"; - static const char MAX_DIFFERENCE[] = "max_difference"; - static const char MIN_TRACKER_CONFIDENCE[] = "min_trackerConfidence"; - static const char MIN_MATCHED_STARS[] = "min_matchedStars"; +static const char VALIDATION[] = "validation"; +static const char STABLE_COUNT[] = "stable_count"; +static const char MAX_DIFFERENCE[] = "max_difference"; +static const char MIN_TRACKER_CONFIDENCE[] = "min_trackerConfidence"; +static const char MIN_MATCHED_STARS[] = "min_matchedStars"; - static const char TRACKING[] = "tracking"; - static const char THIN_LIMIT[] = "thinLimit"; - static const char OUTLIER_THRESHOLD[] = "outlierThreshold"; - static const char OUTLIER_THRESHOLD_QUEST[] = "outlierThresholdQUEST"; - static const char TRACKER_CHOICE[] = "trackerChoice"; +static const char TRACKING[] = "tracking"; +static const char THIN_LIMIT[] = "thinLimit"; +static const char OUTLIER_THRESHOLD[] = "outlierThreshold"; +static const char OUTLIER_THRESHOLD_QUEST[] = "outlierThresholdQUEST"; +static const char TRACKER_CHOICE[] = "trackerChoice"; - static const char ALGO[] = "algo"; - static const char L2T_MIN_CONFIDENCE[] = "l2t_minConfidence"; - static const char L2T_MIN_MATCHED[] = "l2t_minConfidence"; - static const char T2L_MIN_CONFIDENCE[] = "t2l_minConfidence"; - static const char T2L_MIN_MATCHED[] = "t2l_minMatched"; -} +static const char ALGO[] = "algo"; +static const char L2T_MIN_CONFIDENCE[] = "l2t_minConfidence"; +static const char L2T_MIN_MATCHED[] = "l2t_minConfidence"; +static const char T2L_MIN_CONFIDENCE[] = "t2l_minConfidence"; +static const char T2L_MIN_MATCHED[] = "t2l_minMatched"; +} // namespace arcseckeys #endif /* BSP_Q7S_DEVICES_DEVICEDEFINITIONS_ARCSECJSONKEYS_H_ */ diff --git a/bsp_q7s/devices/startracker/ArcsecJsonParamBase.cpp b/bsp_q7s/devices/startracker/ArcsecJsonParamBase.cpp index 339c3fe7..3ecd1d91 100644 --- a/bsp_q7s/devices/startracker/ArcsecJsonParamBase.cpp +++ b/bsp_q7s/devices/startracker/ArcsecJsonParamBase.cpp @@ -1,94 +1,95 @@ #include "ArcsecJsonParamBase.h" + #include "ArcsecJsonKeys.h" ArcsecJsonParamBase::ArcsecJsonParamBase(std::string setName) : setName(setName) {} ReturnValue_t ArcsecJsonParamBase::create(std::string fullname, uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - result = init(fullname); - if (result != RETURN_OK) { - return result; - } - result = createCommand(buffer); + ReturnValue_t result = RETURN_OK; + result = init(fullname); + if (result != RETURN_OK) { return result; + } + result = createCommand(buffer); + return result; } ReturnValue_t ArcsecJsonParamBase::getParam(const std::string name, std::string& value) { - for (json::iterator it = set.begin(); it != set.end(); ++it) { - if ((*it)[arcseckeys::NAME] == name) { - value = (*it)[arcseckeys::VALUE]; - convertEmpty(value); - return RETURN_OK; - } + for (json::iterator it = set.begin(); it != set.end(); ++it) { + if ((*it)[arcseckeys::NAME] == name) { + value = (*it)[arcseckeys::VALUE]; + convertEmpty(value); + return RETURN_OK; } - return PARAM_NOT_EXISTS; + } + return PARAM_NOT_EXISTS; } void ArcsecJsonParamBase::convertEmpty(std::string& value) { - if (value == "") { - value = "0"; - } + if (value == "") { + value = "0"; + } } void ArcsecJsonParamBase::addfloat(const std::string value, uint8_t* buffer) { - float param = std::stof(value); - std::memcpy(buffer, ¶m, sizeof(param)); + float param = std::stof(value); + std::memcpy(buffer, ¶m, sizeof(param)); } void ArcsecJsonParamBase::adduint8(const std::string value, uint8_t* buffer) { - uint8_t param = std::stoi(value); - std::memcpy(buffer, ¶m, sizeof(param)); + uint8_t param = std::stoi(value); + std::memcpy(buffer, ¶m, sizeof(param)); } void ArcsecJsonParamBase::addint16(const std::string value, uint8_t* buffer) { - int16_t param = std::stoi(value); - std::memcpy(buffer, ¶m, sizeof(param)); + int16_t param = std::stoi(value); + std::memcpy(buffer, ¶m, sizeof(param)); } void ArcsecJsonParamBase::adduint16(const std::string value, uint8_t* buffer) { - uint16_t param = std::stoi(value); - std::memcpy(buffer, ¶m, sizeof(param)); + uint16_t param = std::stoi(value); + std::memcpy(buffer, ¶m, sizeof(param)); } void ArcsecJsonParamBase::adduint32(const std::string value, uint8_t* buffer) { - uint32_t param = std::stoi(value); - std::memcpy(buffer, ¶m, sizeof(param)); + uint32_t param = std::stoi(value); + std::memcpy(buffer, ¶m, sizeof(param)); } void ArcsecJsonParamBase::addSetParamHeader(uint8_t* buffer, uint8_t setId) { - *buffer = static_cast(TMTC_SETPARAMREQ); - *(buffer + 1) = setId; + *buffer = static_cast(TMTC_SETPARAMREQ); + *(buffer + 1) = setId; } ReturnValue_t ArcsecJsonParamBase::init(const std::string filename) { - ReturnValue_t result = RETURN_OK; - if (not std::filesystem::exists(filename)) { - sif::warning << "ArcsecJsonParamBase::init: JSON file " << filename << " does not exist" - << std::endl; - return JSON_FILE_NOT_EXISTS; - } - createJsonObject(filename); - result = initSet(); - if (result != RETURN_OK) { - return result; - } - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + if (not std::filesystem::exists(filename)) { + sif::warning << "ArcsecJsonParamBase::init: JSON file " << filename << " does not exist" + << std::endl; + return JSON_FILE_NOT_EXISTS; + } + createJsonObject(filename); + result = initSet(); + if (result != RETURN_OK) { + return result; + } + return RETURN_OK; } void ArcsecJsonParamBase::createJsonObject(const std::string fullname) { - json j; - std::ifstream file(fullname); - file >> j; - file.close(); - properties = j[arcseckeys::PROPERTIES]; + json j; + std::ifstream file(fullname); + file >> j; + file.close(); + properties = j[arcseckeys::PROPERTIES]; } ReturnValue_t ArcsecJsonParamBase::initSet() { - for (json::iterator it = properties.begin(); it != properties.end(); ++it) { - if ((*it)["name"] == setName) { - set = (*it)["fields"]; - return RETURN_OK; - } + for (json::iterator it = properties.begin(); it != properties.end(); ++it) { + if ((*it)["name"] == setName) { + set = (*it)["fields"]; + return RETURN_OK; } - return SET_NOT_EXISTS; + } + return SET_NOT_EXISTS; } diff --git a/bsp_q7s/devices/startracker/ArcsecJsonParamBase.h b/bsp_q7s/devices/startracker/ArcsecJsonParamBase.h index 320eff53..a3e7528f 100644 --- a/bsp_q7s/devices/startracker/ArcsecJsonParamBase.h +++ b/bsp_q7s/devices/startracker/ArcsecJsonParamBase.h @@ -1,16 +1,16 @@ #ifndef BSP_Q7S_DEVICES_STARTRACKER_ARCSECJSONPARAMBASE_H_ #define BSP_Q7S_DEVICES_STARTRACKER_ARCSECJSONPARAMBASE_H_ -#include #include +#include #include -#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "StarTrackerDefinitions.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" extern "C" { - #include "thirdparty/arcsec_star_tracker/common/generated/tmtcstructs.h" - #include "thirdparty/arcsec_star_tracker/common/genericstructs.h" +#include "thirdparty/arcsec_star_tracker/common/generated/tmtcstructs.h" +#include "thirdparty/arcsec_star_tracker/common/genericstructs.h" } using json = nlohmann::json; @@ -23,127 +23,124 @@ using json = nlohmann::json; * @author J. Meier */ class ArcsecJsonParamBase : public HasReturnvaluesIF { -public: + public: + static const uint8_t INTERFACE_ID = CLASS_ID::ARCSEC_JSON_BASE; + //! [EXPORT] : [COMMENT] Specified json file does not exist + static const ReturnValue_t JSON_FILE_NOT_EXISTS = MAKE_RETURN_CODE(1); + //! [EXPORT] : [COMMENT] Requested set does not exist in json file + static const ReturnValue_t SET_NOT_EXISTS = MAKE_RETURN_CODE(2); + //! [EXPORT] : [COMMENT] Requested parameter does not exist in json file + static const ReturnValue_t PARAM_NOT_EXISTS = MAKE_RETURN_CODE(3); - static const uint8_t INTERFACE_ID = CLASS_ID::ARCSEC_JSON_BASE; - //! [EXPORT] : [COMMENT] Specified json file does not exist - static const ReturnValue_t JSON_FILE_NOT_EXISTS = MAKE_RETURN_CODE(1); - //! [EXPORT] : [COMMENT] Requested set does not exist in json file - static const ReturnValue_t SET_NOT_EXISTS = MAKE_RETURN_CODE(2); - //! [EXPORT] : [COMMENT] Requested parameter does not exist in json file - static const ReturnValue_t PARAM_NOT_EXISTS = MAKE_RETURN_CODE(3); + /** + * @brief Constructor + * + * @param fullname Name with absolute path of json file containing the parameters to set. + */ + ArcsecJsonParamBase(std::string setName); - /** - * @brief Constructor - * - * @param fullname Name with absolute path of json file containing the parameters to set. - */ - ArcsecJsonParamBase(std::string setName); + /** + * @brief Fills a buffer with a parameter set + * + * @param fullname The name including the absolute path of the json file containing the + * parameter set. + * @param buffer Pointer to the buffer the command will be written to + */ + ReturnValue_t create(std::string fullname, uint8_t* buffer); - /** - * @brief Fills a buffer with a parameter set - * - * @param fullname The name including the absolute path of the json file containing the - * parameter set. - * @param buffer Pointer to the buffer the command will be written to - */ - ReturnValue_t create(std::string fullname, uint8_t* buffer); + /** + * @brief Returns the size of the parameter command. + */ + virtual size_t getSize() = 0; - /** - * @brief Returns the size of the parameter command. - */ - virtual size_t getSize() = 0; + protected: + /** + * @brief Reads the value of a parameter from a json set + * + * @param name The name of the parameter + * @param value The string representation of the read value + * + * @return RETURN_OK if successful, otherwise PARAM_NOT_EXISTS + */ + ReturnValue_t getParam(const std::string name, std::string& value); -protected: + /** + * @brief Converts empty string which is equal to define a value as zero. + */ + void convertEmpty(std::string& value); - /** - * @brief Reads the value of a parameter from a json set - * - * @param name The name of the parameter - * @param value The string representation of the read value - * - * @return RETURN_OK if successful, otherwise PARAM_NOT_EXISTS - */ - ReturnValue_t getParam(const std::string name, std::string& value); + /** + * @brief This function adds a float represented as string to a buffer + * + * @param value The float in string representation to add + * @param buffer Pointer to the buffer the float will be written to + */ + void addfloat(const std::string value, uint8_t* buffer); - /** - * @brief Converts empty string which is equal to define a value as zero. - */ - void convertEmpty(std::string& value); + /** + * @brief This function adds a uint8_t represented as string to a buffer + * + * @param value The uint8_t in string representation to add + * @param buffer Pointer to the buffer the uint8_t will be written to + */ + void adduint8(const std::string value, uint8_t* buffer); - /** - * @brief This function adds a float represented as string to a buffer - * - * @param value The float in string representation to add - * @param buffer Pointer to the buffer the float will be written to - */ - void addfloat(const std::string value, uint8_t* buffer); + /** + * @brief This function adds a int16_t represented as string to a buffer + * + * @param value The int16_t in string representation to add + * @param buffer Pointer to the buffer the int16_t will be written to + */ + void addint16(const std::string value, uint8_t* buffer); - /** - * @brief This function adds a uint8_t represented as string to a buffer - * - * @param value The uint8_t in string representation to add - * @param buffer Pointer to the buffer the uint8_t will be written to - */ - void adduint8(const std::string value, uint8_t* buffer); + /** + * @brief This function adds a uint16_t represented as string to a buffer + * + * @param value The uint16_t in string representation to add + * @param buffer Pointer to the buffer the uint16_t will be written to + */ + void adduint16(const std::string value, uint8_t* buffer); - /** - * @brief This function adds a int16_t represented as string to a buffer - * - * @param value The int16_t in string representation to add - * @param buffer Pointer to the buffer the int16_t will be written to - */ - void addint16(const std::string value, uint8_t* buffer); + /** + * @brief This function adds a uint32_t represented as string to a buffer + * + * @param value The uint32_t in string representation to add + * @param buffer Pointer to the buffer the uint32_t will be written to + */ + void adduint32(const std::string value, uint8_t* buffer); - /** - * @brief This function adds a uint16_t represented as string to a buffer - * - * @param value The uint16_t in string representation to add - * @param buffer Pointer to the buffer the uint16_t will be written to - */ - void adduint16(const std::string value, uint8_t* buffer); + void addSetParamHeader(uint8_t* buffer, uint8_t setId); - /** - * @brief This function adds a uint32_t represented as string to a buffer - * - * @param value The uint32_t in string representation to add - * @param buffer Pointer to the buffer the uint32_t will be written to - */ - void adduint32(const std::string value, uint8_t* buffer); + private: + json properties; + json set; + std::string setName; - void addSetParamHeader(uint8_t* buffer, uint8_t setId); + /** + * @brief This function must be implemented by the derived class to define creation of a + * parameter command. + */ + virtual ReturnValue_t createCommand(uint8_t* buffer) = 0; -private: + /** + * @brief Initializes the properties json object and the set json object + * + * @param fullname Name including absolute path to json file + * @param setName The name of the set to work on + * + * @param return JSON_FILE_NOT_EXISTS if specified file does not exist, otherwise + * RETURN_OK + */ + ReturnValue_t init(const std::string filename); - json properties; - json set; - std::string setName; + void createJsonObject(const std::string fullname); - /** - * @brief This function must be implemented by the derived class to define creation of a - * parameter command. - */ - virtual ReturnValue_t createCommand(uint8_t* buffer) = 0; - - /** - * @brief Initializes the properties json object and the set json object - * - * @param fullname Name including absolute path to json file - * @param setName The name of the set to work on - * - * @param return JSON_FILE_NOT_EXISTS if specified file does not exist, otherwise - * RETURN_OK - */ - ReturnValue_t init(const std::string filename); - - void createJsonObject(const std::string fullname); - - /** - * @brief Extracts the json set object form the json file - * - * @param setName The name of the set to create the json object from - */ - ReturnValue_t initSet(); + /** + * @brief Extracts the json set object form the json file + * + * @param setName The name of the set to create the json object from + */ + ReturnValue_t initSet(); }; #endif /* BSP_Q7S_DEVICES_STARTRACKER_ARCSECJSONPARAMBASE_H_ */ diff --git a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h index f1f7b7d0..c8a45683 100644 --- a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h +++ b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h @@ -1,12 +1,13 @@ #ifndef MISSION_STARTRACKER_DEFINITIONS_H_ #define MISSION_STARTRACKER_DEFINITIONS_H_ -#include +#include #include +#include #include #include + #include "objects/systemObjectList.h" -#include namespace StarTracker { @@ -15,188 +16,188 @@ static const uint8_t ADDRESS = 33; static const uint8_t STATUS_OK = 0; -enum PoolIds: lp_id_t { - TICKS_TIME_SET, - TIME_TIME_SET, - RUN_TIME, - UNIX_TIME, - TICKS_VERSION_SET, - TIME_VERSION_SET, - PROGRAM, - MAJOR, - MINOR, - TICKS_INTERFACE_SET, - TIME_INTERFACE_SET, - FRAME_COUNT, - CHECKSUM_ERROR_COUNT, - SET_PARAM_COUNT, - SET_PARAM_REPLY_COUNT, - PARAM_REQUEST_COUNT, - PARAM_REPLY_COUNT, - REQ_TM_COUNT, - TM_REPLY_COUNT, - ACTION_REQ_COUNT, - ACTION_REPLY_COUNT, - TICKS_POWER_SET, - TIME_POWER_SET, - MCU_CURRENT, - MCU_VOLTAGE, - FPGA_CORE_CURRENT, - FPGA_CORE_VOLTAGE, - FPGA_18_CURRENT, - FPGA_18_VOLTAGE, - FPGA_25_CURRENT, - FPGA_25_VOLTAGE, - CMV_21_CURRENT, - CMV_21_VOLTAGE, - CMV_PIX_CURRENT, - CMV_PIX_VOLTAGE, - CMV_33_CURRENT, - CMV_33_VOLTAGE, - CMV_RES_CURRENT, - CMV_RES_VOLTAGE, - TICKS_TEMPERATURE_SET, - TIME_TEMPERATURE_SET, - MCU_TEMPERATURE, - CMOS_TEMPERATURE, - TICKS_SOLUTION_SET, - TIME_SOLUTION_SET, - CALI_QW, - CALI_QX, - CALI_QY, - CALI_QZ, - TRACK_CONFIDENCE, - TRACK_QW, - TRACK_QX, - TRACK_QY, - TRACK_QZ, - TRACK_REMOVED, - STARS_CENTROIDED, - STARS_MATCHED_DATABASE, - LISA_QW, - LISA_QX, - LISA_QY, - LISA_QZ, - LISA_PERC_CLOSE, - LISA_NR_CLOSE, - TRUST_WORTHY, - STABLE_COUNT, - SOLUTION_STRATEGY, - TICKS_HISTOGRAM_SET, - TIME_HISTOGRAM_SET, - HISTOGRAM_BINA0, - HISTOGRAM_BINA1, - HISTOGRAM_BINA2, - HISTOGRAM_BINA3, - HISTOGRAM_BINA4, - HISTOGRAM_BINA5, - HISTOGRAM_BINA6, - HISTOGRAM_BINA7, - HISTOGRAM_BINA8, - HISTOGRAM_BINB0, - HISTOGRAM_BINB1, - HISTOGRAM_BINB2, - HISTOGRAM_BINB3, - HISTOGRAM_BINB4, - HISTOGRAM_BINB5, - HISTOGRAM_BINB6, - HISTOGRAM_BINB7, - HISTOGRAM_BINB8, - HISTOGRAM_BINC0, - HISTOGRAM_BINC1, - HISTOGRAM_BINC2, - HISTOGRAM_BINC3, - HISTOGRAM_BINC4, - HISTOGRAM_BINC5, - HISTOGRAM_BINC6, - HISTOGRAM_BINC7, - HISTOGRAM_BINC8, - HISTOGRAM_BIND0, - HISTOGRAM_BIND1, - HISTOGRAM_BIND2, - HISTOGRAM_BIND3, - HISTOGRAM_BIND4, - HISTOGRAM_BIND5, - HISTOGRAM_BIND6, - HISTOGRAM_BIND7, - HISTOGRAM_BIND8, - TICKS_CONTRAST_SET, - TIME_CONTRAST_SET, - CONTRAST_BINA0, - CONTRAST_BINA1, - CONTRAST_BINA2, - CONTRAST_BINA3, - CONTRAST_BINA4, - CONTRAST_BINA5, - CONTRAST_BINA6, - CONTRAST_BINA7, - CONTRAST_BINA8, - CONTRAST_BINB0, - CONTRAST_BINB1, - CONTRAST_BINB2, - CONTRAST_BINB3, - CONTRAST_BINB4, - CONTRAST_BINB5, - CONTRAST_BINB6, - CONTRAST_BINB7, - CONTRAST_BINB8, - CONTRAST_BINC0, - CONTRAST_BINC1, - CONTRAST_BINC2, - CONTRAST_BINC3, - CONTRAST_BINC4, - CONTRAST_BINC5, - CONTRAST_BINC6, - CONTRAST_BINC7, - CONTRAST_BINC8, - CONTRAST_BIND0, - CONTRAST_BIND1, - CONTRAST_BIND2, - CONTRAST_BIND3, - CONTRAST_BIND4, - CONTRAST_BIND5, - CONTRAST_BIND6, - CONTRAST_BIND7, - CONTRAST_BIND8, - CHKSUM, - DWL_ID, - DWL_PIXX, - DWL_PIXY, - DWL_X_UNCORRECTED, - DWL_Y_UNCORRECTED, - DWL_X_CORRECTED, - DWL_Y_CORRECTED, - DWL_MAGNITUDE, - DWL_CXA, - DWL_CYA, - DWL_QUALITY, - MATCHEDSTR_ID, - MATCHEDSTR_CAMFPX, - MATCHEDSTR_CAMFPY, - MATCHEDSTR_CAMCARTX, - MATCHEDSTR_CAMCARTY, - MATCHEDSTR_CAMCARTZ, - MATCHEDSTR_CAMMAGNITUDE, - MATCHEDSTR_DBFPX, - MATCHEDSTR_DBFPY, - MATCHEDSTR_DBCARTX, - MATCHEDSTR_DBCARTY, - MATCHEDSTR_DBCARTZ, - MATCHEDSTR_DBMAGNITUDE, - MATCHEDSTR_CATALOGID, - DBIMAGE_ID, - DBIMAGE_PIXX, - DBIMAGE_PIXY, - DBIMAGE_X, - DBIMAGE_Y, - DBIMAGE_MAGNITUDE, - BLOBPIX_ID, - BLOBPIX_X, - BLOBPIX_Y, - BLOBPIX_TOT_VAL, - BLOBPIX_IN_USE, - BLOBPIX_BRIGHT_NEIGHBOURS, - BLOBPIX_REGION +enum PoolIds : lp_id_t { + TICKS_TIME_SET, + TIME_TIME_SET, + RUN_TIME, + UNIX_TIME, + TICKS_VERSION_SET, + TIME_VERSION_SET, + PROGRAM, + MAJOR, + MINOR, + TICKS_INTERFACE_SET, + TIME_INTERFACE_SET, + FRAME_COUNT, + CHECKSUM_ERROR_COUNT, + SET_PARAM_COUNT, + SET_PARAM_REPLY_COUNT, + PARAM_REQUEST_COUNT, + PARAM_REPLY_COUNT, + REQ_TM_COUNT, + TM_REPLY_COUNT, + ACTION_REQ_COUNT, + ACTION_REPLY_COUNT, + TICKS_POWER_SET, + TIME_POWER_SET, + MCU_CURRENT, + MCU_VOLTAGE, + FPGA_CORE_CURRENT, + FPGA_CORE_VOLTAGE, + FPGA_18_CURRENT, + FPGA_18_VOLTAGE, + FPGA_25_CURRENT, + FPGA_25_VOLTAGE, + CMV_21_CURRENT, + CMV_21_VOLTAGE, + CMV_PIX_CURRENT, + CMV_PIX_VOLTAGE, + CMV_33_CURRENT, + CMV_33_VOLTAGE, + CMV_RES_CURRENT, + CMV_RES_VOLTAGE, + TICKS_TEMPERATURE_SET, + TIME_TEMPERATURE_SET, + MCU_TEMPERATURE, + CMOS_TEMPERATURE, + TICKS_SOLUTION_SET, + TIME_SOLUTION_SET, + CALI_QW, + CALI_QX, + CALI_QY, + CALI_QZ, + TRACK_CONFIDENCE, + TRACK_QW, + TRACK_QX, + TRACK_QY, + TRACK_QZ, + TRACK_REMOVED, + STARS_CENTROIDED, + STARS_MATCHED_DATABASE, + LISA_QW, + LISA_QX, + LISA_QY, + LISA_QZ, + LISA_PERC_CLOSE, + LISA_NR_CLOSE, + TRUST_WORTHY, + STABLE_COUNT, + SOLUTION_STRATEGY, + TICKS_HISTOGRAM_SET, + TIME_HISTOGRAM_SET, + HISTOGRAM_BINA0, + HISTOGRAM_BINA1, + HISTOGRAM_BINA2, + HISTOGRAM_BINA3, + HISTOGRAM_BINA4, + HISTOGRAM_BINA5, + HISTOGRAM_BINA6, + HISTOGRAM_BINA7, + HISTOGRAM_BINA8, + HISTOGRAM_BINB0, + HISTOGRAM_BINB1, + HISTOGRAM_BINB2, + HISTOGRAM_BINB3, + HISTOGRAM_BINB4, + HISTOGRAM_BINB5, + HISTOGRAM_BINB6, + HISTOGRAM_BINB7, + HISTOGRAM_BINB8, + HISTOGRAM_BINC0, + HISTOGRAM_BINC1, + HISTOGRAM_BINC2, + HISTOGRAM_BINC3, + HISTOGRAM_BINC4, + HISTOGRAM_BINC5, + HISTOGRAM_BINC6, + HISTOGRAM_BINC7, + HISTOGRAM_BINC8, + HISTOGRAM_BIND0, + HISTOGRAM_BIND1, + HISTOGRAM_BIND2, + HISTOGRAM_BIND3, + HISTOGRAM_BIND4, + HISTOGRAM_BIND5, + HISTOGRAM_BIND6, + HISTOGRAM_BIND7, + HISTOGRAM_BIND8, + TICKS_CONTRAST_SET, + TIME_CONTRAST_SET, + CONTRAST_BINA0, + CONTRAST_BINA1, + CONTRAST_BINA2, + CONTRAST_BINA3, + CONTRAST_BINA4, + CONTRAST_BINA5, + CONTRAST_BINA6, + CONTRAST_BINA7, + CONTRAST_BINA8, + CONTRAST_BINB0, + CONTRAST_BINB1, + CONTRAST_BINB2, + CONTRAST_BINB3, + CONTRAST_BINB4, + CONTRAST_BINB5, + CONTRAST_BINB6, + CONTRAST_BINB7, + CONTRAST_BINB8, + CONTRAST_BINC0, + CONTRAST_BINC1, + CONTRAST_BINC2, + CONTRAST_BINC3, + CONTRAST_BINC4, + CONTRAST_BINC5, + CONTRAST_BINC6, + CONTRAST_BINC7, + CONTRAST_BINC8, + CONTRAST_BIND0, + CONTRAST_BIND1, + CONTRAST_BIND2, + CONTRAST_BIND3, + CONTRAST_BIND4, + CONTRAST_BIND5, + CONTRAST_BIND6, + CONTRAST_BIND7, + CONTRAST_BIND8, + CHKSUM, + DWL_ID, + DWL_PIXX, + DWL_PIXY, + DWL_X_UNCORRECTED, + DWL_Y_UNCORRECTED, + DWL_X_CORRECTED, + DWL_Y_CORRECTED, + DWL_MAGNITUDE, + DWL_CXA, + DWL_CYA, + DWL_QUALITY, + MATCHEDSTR_ID, + MATCHEDSTR_CAMFPX, + MATCHEDSTR_CAMFPY, + MATCHEDSTR_CAMCARTX, + MATCHEDSTR_CAMCARTY, + MATCHEDSTR_CAMCARTZ, + MATCHEDSTR_CAMMAGNITUDE, + MATCHEDSTR_DBFPX, + MATCHEDSTR_DBFPY, + MATCHEDSTR_DBCARTX, + MATCHEDSTR_DBCARTY, + MATCHEDSTR_DBCARTZ, + MATCHEDSTR_DBMAGNITUDE, + MATCHEDSTR_CATALOGID, + DBIMAGE_ID, + DBIMAGE_PIXX, + DBIMAGE_PIXY, + DBIMAGE_X, + DBIMAGE_Y, + DBIMAGE_MAGNITUDE, + BLOBPIX_ID, + BLOBPIX_X, + BLOBPIX_Y, + BLOBPIX_TOT_VAL, + BLOBPIX_IN_USE, + BLOBPIX_BRIGHT_NEIGHBOURS, + BLOBPIX_REGION }; static const DeviceCommandId_t PING_REQUEST = 0; @@ -280,931 +281,768 @@ static const uint8_t DOWNLOAD_BLOBPIXEL_SET_ENTRIES = 7; // Action, parameter and telemetry IDs namespace ID { - static const uint8_t PING = 0; - static const uint8_t BOOT = 1; - static const uint8_t VERSION = 2; - static const uint8_t INTERFACE = 3; - static const uint8_t LIMITS = 5; - static const uint8_t MOUNTING = 6; - static const uint8_t CAMERA = 9; - static const uint8_t BLOB = 10; - static const uint8_t CENTROIDING = 11; - static const uint8_t LISA = 12; - static const uint8_t MATCHING = 13; - static const uint8_t TRACKING = 14; - static const uint8_t VALIDATION = 15; - static const uint8_t ALGO = 16; - static const uint8_t REBOOT = 7; - static const uint8_t UPLOAD_IMAGE = 10; - static const uint8_t POWER = 11; - static const uint8_t SET_TIME = 14; - static const uint8_t SUBSCRIBE = 18; - static const uint8_t SOLUTION = 24; - static const uint8_t TEMPERATURE = 25; - static const uint8_t HISTOGRAM = 28; - static const uint8_t CONTRAST = 29; - static const uint8_t TIME = 1; - static const uint8_t WRITE = 2; - static const uint8_t READ = 3; - static const uint8_t CHECKSUM = 4; - static const uint8_t ERASE = 5; - static const uint8_t UNLOCK = 6; - static const uint8_t TAKE_IMAGE = 15; - static const uint8_t ERROR_RESET = 12; - static const uint8_t DOWNLOAD_CENTROID = 16; - static const uint8_t UPLOAD_CENTROID = 17; - static const uint8_t DOWNLOAD_MATCHED_STAR = 18; - static const uint8_t DOWNLOAD_DBIMAGE = 19; - static const uint8_t DOWNLOAD_BLOBPIXEL = 24; - static const uint8_t FPGA_ACTION = 22; -} +static const uint8_t PING = 0; +static const uint8_t BOOT = 1; +static const uint8_t VERSION = 2; +static const uint8_t INTERFACE = 3; +static const uint8_t LIMITS = 5; +static const uint8_t MOUNTING = 6; +static const uint8_t CAMERA = 9; +static const uint8_t BLOB = 10; +static const uint8_t CENTROIDING = 11; +static const uint8_t LISA = 12; +static const uint8_t MATCHING = 13; +static const uint8_t TRACKING = 14; +static const uint8_t VALIDATION = 15; +static const uint8_t ALGO = 16; +static const uint8_t REBOOT = 7; +static const uint8_t UPLOAD_IMAGE = 10; +static const uint8_t POWER = 11; +static const uint8_t SET_TIME = 14; +static const uint8_t SUBSCRIBE = 18; +static const uint8_t SOLUTION = 24; +static const uint8_t TEMPERATURE = 25; +static const uint8_t HISTOGRAM = 28; +static const uint8_t CONTRAST = 29; +static const uint8_t TIME = 1; +static const uint8_t WRITE = 2; +static const uint8_t READ = 3; +static const uint8_t CHECKSUM = 4; +static const uint8_t ERASE = 5; +static const uint8_t UNLOCK = 6; +static const uint8_t TAKE_IMAGE = 15; +static const uint8_t ERROR_RESET = 12; +static const uint8_t DOWNLOAD_CENTROID = 16; +static const uint8_t UPLOAD_CENTROID = 17; +static const uint8_t DOWNLOAD_MATCHED_STAR = 18; +static const uint8_t DOWNLOAD_DBIMAGE = 19; +static const uint8_t DOWNLOAD_BLOBPIXEL = 24; +static const uint8_t FPGA_ACTION = 22; +} // namespace ID namespace Program { - static const uint8_t BOOTLOADER = 1; - static const uint8_t FIRMWARE = 2; -} +static const uint8_t BOOTLOADER = 1; +static const uint8_t FIRMWARE = 2; +} // namespace Program /** * @brief This dataset can be used to store the temperature of a reaction wheel. */ -class TemperatureSet: - public StaticLocalDataSet { -public: +class TemperatureSet : public StaticLocalDataSet { + public: + static const size_t SIZE = 20; - static const size_t SIZE = 20; + TemperatureSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TEMPERATURE_SET_ID) {} - TemperatureSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, TEMPERATURE_SET_ID) { - } + TemperatureSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TEMPERATURE_SET_ID)) {} - TemperatureSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, TEMPERATURE_SET_ID)) { - } + // Ticks is time reference generated by internal counter of the star tracker + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_TEMPERATURE_SET, this); + /** Unix time in microseconds */ + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_TEMPERATURE_SET, this); + lp_var_t mcuTemperature = lp_var_t(sid.objectId, PoolIds::MCU_TEMPERATURE, this); + lp_var_t cmosTemperature = lp_var_t(sid.objectId, PoolIds::CMOS_TEMPERATURE, this); - // Ticks is time reference generated by internal counter of the star tracker - lp_var_t ticks = lp_var_t(sid.objectId, - PoolIds::TICKS_TEMPERATURE_SET, this); - /** Unix time in microseconds */ - lp_var_t time = lp_var_t(sid.objectId, - PoolIds::TIME_TEMPERATURE_SET, this); - lp_var_t mcuTemperature = lp_var_t(sid.objectId, - PoolIds::MCU_TEMPERATURE, this); - lp_var_t cmosTemperature = lp_var_t(sid.objectId, - PoolIds::CMOS_TEMPERATURE, this); - - void printSet() { - sif::info << "TemperatureSet::printSet: Ticks: " - << this->ticks << std::endl; - sif::info << "TemperatureSet::printSet: Time: " - << this->time << " us" << std::endl; - sif::info << "TemperatureSet::printSet: MCU Temperature: " - << this->mcuTemperature << " °C" << std::endl; - sif::info << "TemperatureSet::printSet: CMOS Temperature: " - << this->cmosTemperature << " °C" << std::endl; - } + void printSet() { + sif::info << "TemperatureSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "TemperatureSet::printSet: Time: " << this->time << " us" << std::endl; + sif::info << "TemperatureSet::printSet: MCU Temperature: " << this->mcuTemperature << " °C" + << std::endl; + sif::info << "TemperatureSet::printSet: CMOS Temperature: " << this->cmosTemperature << " °C" + << std::endl; + } }; /** * @brief Package to store version parameters */ -class VersionSet: - public StaticLocalDataSet { -public: +class VersionSet : public StaticLocalDataSet { + public: + static const size_t SIZE = 15; - static const size_t SIZE = 15; + VersionSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, VERSION_SET_ID) {} - VersionSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, VERSION_SET_ID) { - } + VersionSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, VERSION_SET_ID)) {} - VersionSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, VERSION_SET_ID)) { - } + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_VERSION_SET, this); + /** Unix time in microseconds */ + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_VERSION_SET, this); + lp_var_t program = lp_var_t(sid.objectId, PoolIds::PROGRAM, this); + lp_var_t major = lp_var_t(sid.objectId, PoolIds::MAJOR, this); + lp_var_t minor = lp_var_t(sid.objectId, PoolIds::MINOR, this); - lp_var_t ticks = lp_var_t(sid.objectId, - PoolIds::TICKS_VERSION_SET, this); - /** Unix time in microseconds */ - lp_var_t time = lp_var_t(sid.objectId, - PoolIds::TIME_VERSION_SET, this); - lp_var_t program = lp_var_t(sid.objectId, - PoolIds::PROGRAM, this); - lp_var_t major = lp_var_t(sid.objectId, - PoolIds::MAJOR, this); - lp_var_t minor = lp_var_t(sid.objectId, - PoolIds::MINOR, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "VersionSet::printSet: Ticks: " - << this->ticks << std::endl; - sif::info << "VersionSet::printSet: Unix Time: " - << this->time << " us" << std::endl; - sif::info << "VersionSet::printSet: Program: " - << static_cast(this->program.value) << std::endl; - sif::info << "VersionSet::printSet: Major: " - << static_cast(this->major.value) << std::endl; - sif::info << "VersionSet::printSet: Minor: " - << static_cast(this->minor.value) << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "VersionSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "VersionSet::printSet: Unix Time: " << this->time << " us" << std::endl; + sif::info << "VersionSet::printSet: Program: " << static_cast(this->program.value) + << std::endl; + sif::info << "VersionSet::printSet: Major: " << static_cast(this->major.value) + << std::endl; + sif::info << "VersionSet::printSet: Minor: " << static_cast(this->minor.value) + << std::endl; + } }; /** * @brief Dataset to store the interface telemtry data. */ -class InterfaceSet: - public StaticLocalDataSet { -public: +class InterfaceSet : public StaticLocalDataSet { + public: + static const size_t SIZE = 20; - static const size_t SIZE = 20; + InterfaceSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, REQ_INTERFACE) {} - InterfaceSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, REQ_INTERFACE) { - } + InterfaceSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, REQ_INTERFACE)) {} - InterfaceSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, REQ_INTERFACE)) { - } + // Ticks is time reference generated by interanl counter of the star tracker + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_INTERFACE_SET, this); + /** Unix time in microseconds */ + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_INTERFACE_SET, this); + lp_var_t frameCount = lp_var_t(sid.objectId, PoolIds::FRAME_COUNT, this); + lp_var_t checksumerrorCount = + lp_var_t(sid.objectId, PoolIds::CHECKSUM_ERROR_COUNT, this); - // Ticks is time reference generated by interanl counter of the star tracker - lp_var_t ticks = lp_var_t(sid.objectId, - PoolIds::TICKS_INTERFACE_SET, this); - /** Unix time in microseconds */ - lp_var_t time = lp_var_t(sid.objectId, - PoolIds::TIME_INTERFACE_SET, this); - lp_var_t frameCount = lp_var_t(sid.objectId, - PoolIds::FRAME_COUNT, this); - lp_var_t checksumerrorCount = lp_var_t(sid.objectId, - PoolIds::CHECKSUM_ERROR_COUNT, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "InterfaceSet::printSet: Ticks: " - << this->ticks << std::endl; - sif::info << "InterfaceSet::printSet: Time: " - << this->time << " us" << std::endl; - sif::info << "InterfaceSet::printSet: Frame Count: " - << this->frameCount << std::endl; - sif::info << "InterfaceSet::printSet: Checksum Error Count: " - << this->checksumerrorCount << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "InterfaceSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "InterfaceSet::printSet: Time: " << this->time << " us" << std::endl; + sif::info << "InterfaceSet::printSet: Frame Count: " << this->frameCount << std::endl; + sif::info << "InterfaceSet::printSet: Checksum Error Count: " << this->checksumerrorCount + << std::endl; + } }; /** * @brief Dataset to store the data of the power telemetry reply. */ -class PowerSet: - public StaticLocalDataSet { -public: +class PowerSet : public StaticLocalDataSet { + public: + static const size_t SIZE = 76; - static const size_t SIZE = 76; + PowerSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, REQ_INTERFACE) {} - PowerSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, REQ_INTERFACE) { - } + PowerSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, REQ_INTERFACE)) {} - PowerSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, REQ_INTERFACE)) { - } + // Ticks is time reference generated by interanl counter of the star tracker + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_POWER_SET, this); + /** Unix time in microseconds */ + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_POWER_SET, this); + lp_var_t mcuCurrent = lp_var_t(sid.objectId, PoolIds::MCU_CURRENT, this); + lp_var_t mcuVoltage = lp_var_t(sid.objectId, PoolIds::MCU_VOLTAGE, this); + lp_var_t fpgaCoreCurrent = lp_var_t(sid.objectId, PoolIds::FPGA_CORE_CURRENT, this); + lp_var_t fpgaCoreVoltage = lp_var_t(sid.objectId, PoolIds::FPGA_CORE_VOLTAGE, this); + lp_var_t fpga18Current = lp_var_t(sid.objectId, PoolIds::FPGA_18_CURRENT, this); + lp_var_t fpga18Voltage = lp_var_t(sid.objectId, PoolIds::FPGA_18_VOLTAGE, this); + lp_var_t fpga25Current = lp_var_t(sid.objectId, PoolIds::FPGA_25_CURRENT, this); + lp_var_t fpga25Voltage = lp_var_t(sid.objectId, PoolIds::FPGA_25_VOLTAGE, this); + lp_var_t cmv21Current = lp_var_t(sid.objectId, PoolIds::CMV_21_CURRENT, this); + lp_var_t cmv21Voltage = lp_var_t(sid.objectId, PoolIds::CMV_21_VOLTAGE, this); + lp_var_t cmvPixCurrent = lp_var_t(sid.objectId, PoolIds::CMV_PIX_CURRENT, this); + lp_var_t cmvPixVoltage = lp_var_t(sid.objectId, PoolIds::CMV_PIX_VOLTAGE, this); + lp_var_t cmv33Current = lp_var_t(sid.objectId, PoolIds::CMV_33_CURRENT, this); + lp_var_t cmv33Voltage = lp_var_t(sid.objectId, PoolIds::CMV_33_VOLTAGE, this); + lp_var_t cmvResCurrent = lp_var_t(sid.objectId, PoolIds::CMV_RES_CURRENT, this); + lp_var_t cmvResVoltage = lp_var_t(sid.objectId, PoolIds::CMV_RES_VOLTAGE, this); - // Ticks is time reference generated by interanl counter of the star tracker - lp_var_t ticks = lp_var_t(sid.objectId, - PoolIds::TICKS_POWER_SET, this); - /** Unix time in microseconds */ - lp_var_t time = lp_var_t(sid.objectId, - PoolIds::TIME_POWER_SET, this); - lp_var_t mcuCurrent = lp_var_t(sid.objectId, - PoolIds::MCU_CURRENT, this); - lp_var_t mcuVoltage = lp_var_t(sid.objectId, - PoolIds::MCU_VOLTAGE, this); - lp_var_t fpgaCoreCurrent = lp_var_t(sid.objectId, - PoolIds::FPGA_CORE_CURRENT, this); - lp_var_t fpgaCoreVoltage = lp_var_t(sid.objectId, - PoolIds::FPGA_CORE_VOLTAGE, this); - lp_var_t fpga18Current = lp_var_t(sid.objectId, - PoolIds::FPGA_18_CURRENT, this); - lp_var_t fpga18Voltage = lp_var_t(sid.objectId, - PoolIds::FPGA_18_VOLTAGE, this); - lp_var_t fpga25Current = lp_var_t(sid.objectId, - PoolIds::FPGA_25_CURRENT, this); - lp_var_t fpga25Voltage = lp_var_t(sid.objectId, - PoolIds::FPGA_25_VOLTAGE, this); - lp_var_t cmv21Current = lp_var_t(sid.objectId, - PoolIds::CMV_21_CURRENT, this); - lp_var_t cmv21Voltage = lp_var_t(sid.objectId, - PoolIds::CMV_21_VOLTAGE, this); - lp_var_t cmvPixCurrent = lp_var_t(sid.objectId, - PoolIds::CMV_PIX_CURRENT, this); - lp_var_t cmvPixVoltage = lp_var_t(sid.objectId, - PoolIds::CMV_PIX_VOLTAGE, this); - lp_var_t cmv33Current = lp_var_t(sid.objectId, - PoolIds::CMV_33_CURRENT, this); - lp_var_t cmv33Voltage = lp_var_t(sid.objectId, - PoolIds::CMV_33_VOLTAGE, this); - lp_var_t cmvResCurrent = lp_var_t(sid.objectId, - PoolIds::CMV_RES_CURRENT, this); - lp_var_t cmvResVoltage = lp_var_t(sid.objectId, - PoolIds::CMV_RES_VOLTAGE, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "PowerSet::printSet: Ticks: " - << this->ticks << std::endl; - sif::info << "PowerSet::printSet: Time: " - << this->time << " us" << std::endl; - sif::info << "PowerSet::printSet: MCU Current: " - << this->mcuCurrent << " A" << std::endl; - sif::info << "PowerSet::printSet: MCU Voltage: " - << this->mcuVoltage << " V" << std::endl; - sif::info << "PowerSet::printSet: FPGA Core current: " - << this->fpgaCoreCurrent << " A" << std::endl; - sif::info << "PowerSet::printSet: FPGA Core voltage: " - << this->fpgaCoreVoltage << " V" << std::endl; - sif::info << "PowerSet::printSet: FPGA 18 current: " - << this->fpga18Current << " A" << std::endl; - sif::info << "PowerSet::printSet: FPGA 18 voltage: " - << this->fpga18Voltage << " V" << std::endl; - sif::info << "PowerSet::printSet: FPGA 25 current: " - << this->fpga25Current << " A" << std::endl; - sif::info << "PowerSet::printSet: FPGA 25 voltage: " - << this->fpga25Voltage << " V" << std::endl; - sif::info << "PowerSet::printSet: CMV 21 current: " - << this->cmv21Current << " A" << std::endl; - sif::info << "PowerSet::printSet: CMV 21 voltage: " - << this->cmv21Voltage << " V" << std::endl; - sif::info << "PowerSet::printSet: CMV Pix current: " - << this->cmvPixCurrent << " A" << std::endl; - sif::info << "PowerSet::printSet: CMV Pix voltage: " - << this->cmvPixVoltage << " V" << std::endl; - sif::info << "PowerSet::printSet: CMV 33 current: " - << this->cmv33Current << " A" << std::endl; - sif::info << "PowerSet::printSet: CMV 33 voltage: " - << this->cmv33Voltage << " V" << std::endl; - sif::info << "PowerSet::printSet: CMV Res current: " - << this->cmvResCurrent << " A" << std::endl; - sif::info << "PowerSet::printSet: CMV Res voltage: " - << this->cmvResVoltage << " V" << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "PowerSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "PowerSet::printSet: Time: " << this->time << " us" << std::endl; + sif::info << "PowerSet::printSet: MCU Current: " << this->mcuCurrent << " A" << std::endl; + sif::info << "PowerSet::printSet: MCU Voltage: " << this->mcuVoltage << " V" << std::endl; + sif::info << "PowerSet::printSet: FPGA Core current: " << this->fpgaCoreCurrent << " A" + << std::endl; + sif::info << "PowerSet::printSet: FPGA Core voltage: " << this->fpgaCoreVoltage << " V" + << std::endl; + sif::info << "PowerSet::printSet: FPGA 18 current: " << this->fpga18Current << " A" + << std::endl; + sif::info << "PowerSet::printSet: FPGA 18 voltage: " << this->fpga18Voltage << " V" + << std::endl; + sif::info << "PowerSet::printSet: FPGA 25 current: " << this->fpga25Current << " A" + << std::endl; + sif::info << "PowerSet::printSet: FPGA 25 voltage: " << this->fpga25Voltage << " V" + << std::endl; + sif::info << "PowerSet::printSet: CMV 21 current: " << this->cmv21Current << " A" << std::endl; + sif::info << "PowerSet::printSet: CMV 21 voltage: " << this->cmv21Voltage << " V" << std::endl; + sif::info << "PowerSet::printSet: CMV Pix current: " << this->cmvPixCurrent << " A" + << std::endl; + sif::info << "PowerSet::printSet: CMV Pix voltage: " << this->cmvPixVoltage << " V" + << std::endl; + sif::info << "PowerSet::printSet: CMV 33 current: " << this->cmv33Current << " A" << std::endl; + sif::info << "PowerSet::printSet: CMV 33 voltage: " << this->cmv33Voltage << " V" << std::endl; + sif::info << "PowerSet::printSet: CMV Res current: " << this->cmvResCurrent << " A" + << std::endl; + sif::info << "PowerSet::printSet: CMV Res voltage: " << this->cmvResVoltage << " V" + << std::endl; + } }; /** * @brief Data set to store the time telemetry packet. */ -class TimeSet: - public StaticLocalDataSet { -public: +class TimeSet : public StaticLocalDataSet { + public: + static const size_t SIZE = 24; - static const size_t SIZE = 24; + TimeSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TIME_SET_ID) {} - TimeSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, TIME_SET_ID) { - } + TimeSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TIME_SET_ID)) {} - TimeSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, TIME_SET_ID)) { - } - - lp_var_t ticks = lp_var_t(sid.objectId, - PoolIds::TICKS_TIME_SET, this); - /** Unix time in microseconds */ - lp_var_t time = lp_var_t(sid.objectId, - PoolIds::TIME_TIME_SET, this); - // Number of milliseconds since processor start-up - lp_var_t runTime = lp_var_t(sid.objectId, - PoolIds::RUN_TIME, this); - // Unix time in seconds?? --> maybe typo in datasheet. Seems to be microseconds - lp_var_t unixTime = lp_var_t(sid.objectId, - PoolIds::UNIX_TIME, this); - void printSet() { - PoolReadGuard rg(this); - sif::info << "TimeSet::printSet: Ticks: " - << this->ticks << std::endl; - sif::info << "TimeSet::printSet: Time (time stamp): " - << this->time << " us" << std::endl; - sif::info << "TimeSet::printSet: Run Time: " - << this->runTime << " ms" << std::endl; - sif::info << "TimeSet::printSet: Unix Time: " - << this->unixTime << " s" << std::endl; - } + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_TIME_SET, this); + /** Unix time in microseconds */ + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_TIME_SET, this); + // Number of milliseconds since processor start-up + lp_var_t runTime = lp_var_t(sid.objectId, PoolIds::RUN_TIME, this); + // Unix time in seconds?? --> maybe typo in datasheet. Seems to be microseconds + lp_var_t unixTime = lp_var_t(sid.objectId, PoolIds::UNIX_TIME, this); + void printSet() { + PoolReadGuard rg(this); + sif::info << "TimeSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "TimeSet::printSet: Time (time stamp): " << this->time << " us" << std::endl; + sif::info << "TimeSet::printSet: Run Time: " << this->runTime << " ms" << std::endl; + sif::info << "TimeSet::printSet: Unix Time: " << this->unixTime << " s" << std::endl; + } }; /** * @brief The solution dataset is the main dataset of the star tracker and contains the * attitude information. */ -class SolutionSet: - public StaticLocalDataSet { -public: +class SolutionSet : public StaticLocalDataSet { + public: + static const size_t SIZE = 78; - static const size_t SIZE = 78; + SolutionSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, SOLUTION_SET_ID) {} - SolutionSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, SOLUTION_SET_ID) { - } + SolutionSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, SOLUTION_SET_ID)) {} - SolutionSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, SOLUTION_SET_ID)) { - } + // Ticks timestamp + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_SOLUTION_SET, this); + /// Unix time stamp + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_SOLUTION_SET, this); + // Calibrated quaternion (takes into account the mounting quaternion), typically same as + // track q values + lp_var_t caliQw = lp_var_t(sid.objectId, PoolIds::CALI_QW, this); + lp_var_t caliQx = lp_var_t(sid.objectId, PoolIds::CALI_QX, this); + lp_var_t caliQy = lp_var_t(sid.objectId, PoolIds::CALI_QY, this); + lp_var_t caliQz = lp_var_t(sid.objectId, PoolIds::CALI_QZ, this); + // The lower this value the more confidence that the star tracker solution is correct + lp_var_t trackConfidence = lp_var_t(sid.objectId, PoolIds::TRACK_CONFIDENCE, this); + // Estimated attitude of spacecraft + lp_var_t trackQw = lp_var_t(sid.objectId, PoolIds::TRACK_QW, this); + lp_var_t trackQx = lp_var_t(sid.objectId, PoolIds::TRACK_QX, this); + lp_var_t trackQy = lp_var_t(sid.objectId, PoolIds::TRACK_QY, this); + lp_var_t trackQz = lp_var_t(sid.objectId, PoolIds::TRACK_QZ, this); + // Number of stars removed from tracking solution + lp_var_t trackRemoved = lp_var_t(sid.objectId, PoolIds::TRACK_REMOVED, this); + // Number of stars for which a valid centroid was found + lp_var_t starsCentroided = + lp_var_t(sid.objectId, PoolIds::STARS_CENTROIDED, this); + // Number of stars that matched to a database star + lp_var_t starsMatchedDatabase = + lp_var_t(sid.objectId, PoolIds::STARS_MATCHED_DATABASE, this); + // Result of LISA (lost in space algorithm), searches for stars without prior knowledge of + // attitude + lp_var_t lisaQw = lp_var_t(sid.objectId, PoolIds::LISA_QW, this); + lp_var_t lisaQx = lp_var_t(sid.objectId, PoolIds::LISA_QX, this); + lp_var_t lisaQy = lp_var_t(sid.objectId, PoolIds::LISA_QY, this); + lp_var_t lisaQz = lp_var_t(sid.objectId, PoolIds::LISA_QZ, this); + // Percentage of close stars in LISA solution + lp_var_t lisaPercentageClose = + lp_var_t(sid.objectId, PoolIds::LISA_PERC_CLOSE, this); + // Number of close stars in LISA solution + lp_var_t lisaNrClose = lp_var_t(sid.objectId, PoolIds::LISA_NR_CLOSE, this); + // Gives a combined overview of the validation parameters (1 for valid solution, otherwise 0) + lp_var_t isTrustWorthy = lp_var_t(sid.objectId, PoolIds::TRUST_WORTHY, this); + // Number of times the validation criteria was met + lp_var_t stableCount = lp_var_t(sid.objectId, PoolIds::STABLE_COUNT, this); + // Shows the autonomous mode used to obtain the star tracker attitude + lp_var_t solutionStrategy = + lp_var_t(sid.objectId, PoolIds::SOLUTION_STRATEGY, this); - // Ticks timestamp - lp_var_t ticks = lp_var_t(sid.objectId, - PoolIds::TICKS_SOLUTION_SET, this); - /// Unix time stamp - lp_var_t time = lp_var_t(sid.objectId, - PoolIds::TIME_SOLUTION_SET, this); - // Calibrated quaternion (takes into account the mounting quaternion), typically same as - // track q values - lp_var_t caliQw = lp_var_t(sid.objectId, PoolIds::CALI_QW, this); - lp_var_t caliQx = lp_var_t(sid.objectId, PoolIds::CALI_QX, this); - lp_var_t caliQy = lp_var_t(sid.objectId, PoolIds::CALI_QY, this); - lp_var_t caliQz = lp_var_t(sid.objectId, PoolIds::CALI_QZ, this); - // The lower this value the more confidence that the star tracker solution is correct - lp_var_t trackConfidence = lp_var_t(sid.objectId, PoolIds::TRACK_CONFIDENCE, - this); - // Estimated attitude of spacecraft - lp_var_t trackQw = lp_var_t(sid.objectId, PoolIds::TRACK_QW, this); - lp_var_t trackQx = lp_var_t(sid.objectId, PoolIds::TRACK_QX, this); - lp_var_t trackQy = lp_var_t(sid.objectId, PoolIds::TRACK_QY, this); - lp_var_t trackQz = lp_var_t(sid.objectId, PoolIds::TRACK_QZ, this); - // Number of stars removed from tracking solution - lp_var_t trackRemoved = lp_var_t(sid.objectId, PoolIds::TRACK_REMOVED, this); - // Number of stars for which a valid centroid was found - lp_var_t starsCentroided = lp_var_t(sid.objectId, PoolIds::STARS_CENTROIDED, - this); - // Number of stars that matched to a database star - lp_var_t starsMatchedDatabase = lp_var_t(sid.objectId, - PoolIds::STARS_MATCHED_DATABASE, this); - // Result of LISA (lost in space algorithm), searches for stars without prior knowledge of - // attitude - lp_var_t lisaQw = lp_var_t(sid.objectId, PoolIds::LISA_QW, this); - lp_var_t lisaQx = lp_var_t(sid.objectId, PoolIds::LISA_QX, this); - lp_var_t lisaQy = lp_var_t(sid.objectId, PoolIds::LISA_QY, this); - lp_var_t lisaQz = lp_var_t(sid.objectId, PoolIds::LISA_QZ, this); - // Percentage of close stars in LISA solution - lp_var_t lisaPercentageClose = lp_var_t(sid.objectId, PoolIds::LISA_PERC_CLOSE, - this); - // Number of close stars in LISA solution - lp_var_t lisaNrClose = lp_var_t(sid.objectId, PoolIds::LISA_NR_CLOSE, this); - // Gives a combined overview of the validation parameters (1 for valid solution, otherwise 0) - lp_var_t isTrustWorthy = lp_var_t(sid.objectId, PoolIds::TRUST_WORTHY, this); - // Number of times the validation criteria was met - lp_var_t stableCount = lp_var_t(sid.objectId, PoolIds::STABLE_COUNT, this); - // Shows the autonomous mode used to obtain the star tracker attitude - lp_var_t solutionStrategy = lp_var_t(sid.objectId, PoolIds::SOLUTION_STRATEGY, - this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "SolutionSet::printSet: Ticks: " - << this->ticks << std::endl; - sif::info << "SolutionSet::printSet: Time: " - << this->time << std::endl; - sif::info << "SolutionSet::printSet: Calibrated quaternion Qw: " - << this->caliQw << std::endl; - sif::info << "SolutionSet::printSet: Calibrated quaternion Qx: " - << this->caliQx << std::endl; - sif::info << "SolutionSet::printSet: Calibrated quaternion Qy: " - << this->caliQy << std::endl; - sif::info << "SolutionSet::printSet: Calibrated quaternion Qz: " - << this->caliQz << std::endl; - sif::info << "SolutionSet::printSet: Track confidence: " - << this->trackConfidence << std::endl; - sif::info << "SolutionSet::printSet: Track Qw: " - << this->trackQw << std::endl; - sif::info << "SolutionSet::printSet: Track Qx: " - << this->trackQx << std::endl; - sif::info << "SolutionSet::printSet: Track Qy: " - << this->trackQy << std::endl; - sif::info << "SolutionSet::printSet: Track Qz: " - << this->trackQz << std::endl; - sif::info << "SolutionSet::printSet: Track removed: " - << static_cast(this->trackRemoved.value) << std::endl; - sif::info << "SolutionSet::printSet: Number of stars centroided: " - << static_cast(this->starsCentroided.value) << std::endl; - sif::info << "SolutionSet::printSet: Number of stars matched database: " - << static_cast(this->starsMatchedDatabase.value) << std::endl; - sif::info << "SolutionSet::printSet: LISA Qw: " - << this->lisaQw << std::endl; - sif::info << "SolutionSet::printSet: LISA Qx: " - << this->lisaQx << std::endl; - sif::info << "SolutionSet::printSet: LISA Qy: " - << this->lisaQy << std::endl; - sif::info << "SolutionSet::printSet: LISA Qz: " - << this->lisaQz << std::endl; - sif::info << "SolutionSet::printSet: LISA Percentage close: " - << this->lisaPercentageClose << std::endl; - sif::info << "SolutionSet::printSet: LISA number of close stars: " - << static_cast(this->lisaNrClose.value) << std::endl; - sif::info << "SolutionSet::printSet: Is trust worthy: " - << static_cast(this->isTrustWorthy.value) << std::endl; - sif::info << "SolutionSet::printSet: Stable count: " - << this->stableCount << std::endl; - sif::info << "SolutionSet::printSet: Solution strategy: " - << static_cast(this->solutionStrategy.value) << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "SolutionSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "SolutionSet::printSet: Time: " << this->time << std::endl; + sif::info << "SolutionSet::printSet: Calibrated quaternion Qw: " << this->caliQw << std::endl; + sif::info << "SolutionSet::printSet: Calibrated quaternion Qx: " << this->caliQx << std::endl; + sif::info << "SolutionSet::printSet: Calibrated quaternion Qy: " << this->caliQy << std::endl; + sif::info << "SolutionSet::printSet: Calibrated quaternion Qz: " << this->caliQz << std::endl; + sif::info << "SolutionSet::printSet: Track confidence: " << this->trackConfidence << std::endl; + sif::info << "SolutionSet::printSet: Track Qw: " << this->trackQw << std::endl; + sif::info << "SolutionSet::printSet: Track Qx: " << this->trackQx << std::endl; + sif::info << "SolutionSet::printSet: Track Qy: " << this->trackQy << std::endl; + sif::info << "SolutionSet::printSet: Track Qz: " << this->trackQz << std::endl; + sif::info << "SolutionSet::printSet: Track removed: " + << static_cast(this->trackRemoved.value) << std::endl; + sif::info << "SolutionSet::printSet: Number of stars centroided: " + << static_cast(this->starsCentroided.value) << std::endl; + sif::info << "SolutionSet::printSet: Number of stars matched database: " + << static_cast(this->starsMatchedDatabase.value) << std::endl; + sif::info << "SolutionSet::printSet: LISA Qw: " << this->lisaQw << std::endl; + sif::info << "SolutionSet::printSet: LISA Qx: " << this->lisaQx << std::endl; + sif::info << "SolutionSet::printSet: LISA Qy: " << this->lisaQy << std::endl; + sif::info << "SolutionSet::printSet: LISA Qz: " << this->lisaQz << std::endl; + sif::info << "SolutionSet::printSet: LISA Percentage close: " << this->lisaPercentageClose + << std::endl; + sif::info << "SolutionSet::printSet: LISA number of close stars: " + << static_cast(this->lisaNrClose.value) << std::endl; + sif::info << "SolutionSet::printSet: Is trust worthy: " + << static_cast(this->isTrustWorthy.value) << std::endl; + sif::info << "SolutionSet::printSet: Stable count: " << this->stableCount << std::endl; + sif::info << "SolutionSet::printSet: Solution strategy: " + << static_cast(this->solutionStrategy.value) << std::endl; + } }; /** * @brief Dataset to store the histogram */ -class HistogramSet: - public StaticLocalDataSet { -public: +class HistogramSet : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 156; - // Size of dataset - static const size_t SIZE = 156; + HistogramSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HISTOGRAM_SET_ID) {} - HistogramSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, HISTOGRAM_SET_ID) { - } + HistogramSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, HISTOGRAM_SET_ID)) {} - HistogramSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, HISTOGRAM_SET_ID)) { - } + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_HISTOGRAM_SET, this); + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_HISTOGRAM_SET, this); + lp_var_t binA0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA0, this); + lp_var_t binA1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA1, this); + lp_var_t binA2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA2, this); + lp_var_t binA3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA3, this); + lp_var_t binA4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA4, this); + lp_var_t binA5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA5, this); + lp_var_t binA6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA6, this); + lp_var_t binA7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA7, this); + lp_var_t binA8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA8, this); + lp_var_t binB0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB0, this); + lp_var_t binB1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB1, this); + lp_var_t binB2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB2, this); + lp_var_t binB3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB3, this); + lp_var_t binB4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB4, this); + lp_var_t binB5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB5, this); + lp_var_t binB6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB6, this); + lp_var_t binB7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB7, this); + lp_var_t binB8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB8, this); + lp_var_t binC0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC0, this); + lp_var_t binC1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC1, this); + lp_var_t binC2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC2, this); + lp_var_t binC3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC3, this); + lp_var_t binC4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC4, this); + lp_var_t binC5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC5, this); + lp_var_t binC6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC6, this); + lp_var_t binC7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC7, this); + lp_var_t binC8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC8, this); + lp_var_t binD0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND0, this); + lp_var_t binD1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND1, this); + lp_var_t binD2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND2, this); + lp_var_t binD3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND3, this); + lp_var_t binD4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND4, this); + lp_var_t binD5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND5, this); + lp_var_t binD6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND6, this); + lp_var_t binD7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND7, this); + lp_var_t binD8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND8, this); - lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_HISTOGRAM_SET, this); - lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_HISTOGRAM_SET, this); - lp_var_t binA0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA0, this); - lp_var_t binA1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA1, this); - lp_var_t binA2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA2, this); - lp_var_t binA3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA3, this); - lp_var_t binA4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA4, this); - lp_var_t binA5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA5, this); - lp_var_t binA6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA6, this); - lp_var_t binA7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA7, this); - lp_var_t binA8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA8, this); - lp_var_t binB0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB0, this); - lp_var_t binB1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB1, this); - lp_var_t binB2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB2, this); - lp_var_t binB3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB3, this); - lp_var_t binB4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB4, this); - lp_var_t binB5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB5, this); - lp_var_t binB6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB6, this); - lp_var_t binB7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB7, this); - lp_var_t binB8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB8, this); - lp_var_t binC0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC0, this); - lp_var_t binC1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC1, this); - lp_var_t binC2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC2, this); - lp_var_t binC3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC3, this); - lp_var_t binC4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC4, this); - lp_var_t binC5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC5, this); - lp_var_t binC6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC6, this); - lp_var_t binC7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC7, this); - lp_var_t binC8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC8, this); - lp_var_t binD0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND0, this); - lp_var_t binD1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND1, this); - lp_var_t binD2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND2, this); - lp_var_t binD3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND3, this); - lp_var_t binD4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND4, this); - lp_var_t binD5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND5, this); - lp_var_t binD6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND6, this); - lp_var_t binD7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND7, this); - lp_var_t binD8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND8, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "HistogramSet::printSet: Ticks: " << this->ticks << std::endl; - sif::info << "HistogramSet::printSet: Time (time stamp): " << this->time << " us" - << std::endl; - sif::info << "HistogramSet::printSet: BinA0: " << this->binA0 << std::endl; - sif::info << "HistogramSet::printSet: BinA1: " << this->binA1 << std::endl; - sif::info << "HistogramSet::printSet: BinA2: " << this->binA2 << std::endl; - sif::info << "HistogramSet::printSet: BinA3: " << this->binA3 << std::endl; - sif::info << "HistogramSet::printSet: BinA4: " << this->binA4 << std::endl; - sif::info << "HistogramSet::printSet: BinA5: " << this->binA5 << std::endl; - sif::info << "HistogramSet::printSet: BinA6: " << this->binA6 << std::endl; - sif::info << "HistogramSet::printSet: BinA7: " << this->binA7 << std::endl; - sif::info << "HistogramSet::printSet: BinA8: " << this->binA8 << std::endl; - sif::info << "HistogramSet::printSet: BinB0: " << this->binB0 << std::endl; - sif::info << "HistogramSet::printSet: BinB1: " << this->binB1 << std::endl; - sif::info << "HistogramSet::printSet: BinB2: " << this->binB2 << std::endl; - sif::info << "HistogramSet::printSet: BinB3: " << this->binB3 << std::endl; - sif::info << "HistogramSet::printSet: BinB4: " << this->binB4 << std::endl; - sif::info << "HistogramSet::printSet: BinB5: " << this->binB5 << std::endl; - sif::info << "HistogramSet::printSet: BinB6: " << this->binB6 << std::endl; - sif::info << "HistogramSet::printSet: BinB7: " << this->binB7 << std::endl; - sif::info << "HistogramSet::printSet: BinB8: " << this->binB8 << std::endl; - sif::info << "HistogramSet::printSet: BinC0: " << this->binC0 << std::endl; - sif::info << "HistogramSet::printSet: BinC1: " << this->binC1 << std::endl; - sif::info << "HistogramSet::printSet: BinC2: " << this->binC2 << std::endl; - sif::info << "HistogramSet::printSet: BinC3: " << this->binC3 << std::endl; - sif::info << "HistogramSet::printSet: BinC4: " << this->binC4 << std::endl; - sif::info << "HistogramSet::printSet: BinC5: " << this->binC5 << std::endl; - sif::info << "HistogramSet::printSet: BinC6: " << this->binC6 << std::endl; - sif::info << "HistogramSet::printSet: BinC7: " << this->binC7 << std::endl; - sif::info << "HistogramSet::printSet: BinC8: " << this->binC8 << std::endl; - sif::info << "HistogramSet::printSet: BinD0: " << this->binD0 << std::endl; - sif::info << "HistogramSet::printSet: BinD1: " << this->binD1 << std::endl; - sif::info << "HistogramSet::printSet: BinD2: " << this->binD2 << std::endl; - sif::info << "HistogramSet::printSet: BinD3: " << this->binD3 << std::endl; - sif::info << "HistogramSet::printSet: BinD4: " << this->binD4 << std::endl; - sif::info << "HistogramSet::printSet: BinD5: " << this->binD5 << std::endl; - sif::info << "HistogramSet::printSet: BinD6: " << this->binD6 << std::endl; - sif::info << "HistogramSet::printSet: BinD7: " << this->binD7 << std::endl; - sif::info << "HistogramSet::printSet: BinD8: " << this->binD8 << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "HistogramSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "HistogramSet::printSet: Time (time stamp): " << this->time << " us" << std::endl; + sif::info << "HistogramSet::printSet: BinA0: " << this->binA0 << std::endl; + sif::info << "HistogramSet::printSet: BinA1: " << this->binA1 << std::endl; + sif::info << "HistogramSet::printSet: BinA2: " << this->binA2 << std::endl; + sif::info << "HistogramSet::printSet: BinA3: " << this->binA3 << std::endl; + sif::info << "HistogramSet::printSet: BinA4: " << this->binA4 << std::endl; + sif::info << "HistogramSet::printSet: BinA5: " << this->binA5 << std::endl; + sif::info << "HistogramSet::printSet: BinA6: " << this->binA6 << std::endl; + sif::info << "HistogramSet::printSet: BinA7: " << this->binA7 << std::endl; + sif::info << "HistogramSet::printSet: BinA8: " << this->binA8 << std::endl; + sif::info << "HistogramSet::printSet: BinB0: " << this->binB0 << std::endl; + sif::info << "HistogramSet::printSet: BinB1: " << this->binB1 << std::endl; + sif::info << "HistogramSet::printSet: BinB2: " << this->binB2 << std::endl; + sif::info << "HistogramSet::printSet: BinB3: " << this->binB3 << std::endl; + sif::info << "HistogramSet::printSet: BinB4: " << this->binB4 << std::endl; + sif::info << "HistogramSet::printSet: BinB5: " << this->binB5 << std::endl; + sif::info << "HistogramSet::printSet: BinB6: " << this->binB6 << std::endl; + sif::info << "HistogramSet::printSet: BinB7: " << this->binB7 << std::endl; + sif::info << "HistogramSet::printSet: BinB8: " << this->binB8 << std::endl; + sif::info << "HistogramSet::printSet: BinC0: " << this->binC0 << std::endl; + sif::info << "HistogramSet::printSet: BinC1: " << this->binC1 << std::endl; + sif::info << "HistogramSet::printSet: BinC2: " << this->binC2 << std::endl; + sif::info << "HistogramSet::printSet: BinC3: " << this->binC3 << std::endl; + sif::info << "HistogramSet::printSet: BinC4: " << this->binC4 << std::endl; + sif::info << "HistogramSet::printSet: BinC5: " << this->binC5 << std::endl; + sif::info << "HistogramSet::printSet: BinC6: " << this->binC6 << std::endl; + sif::info << "HistogramSet::printSet: BinC7: " << this->binC7 << std::endl; + sif::info << "HistogramSet::printSet: BinC8: " << this->binC8 << std::endl; + sif::info << "HistogramSet::printSet: BinD0: " << this->binD0 << std::endl; + sif::info << "HistogramSet::printSet: BinD1: " << this->binD1 << std::endl; + sif::info << "HistogramSet::printSet: BinD2: " << this->binD2 << std::endl; + sif::info << "HistogramSet::printSet: BinD3: " << this->binD3 << std::endl; + sif::info << "HistogramSet::printSet: BinD4: " << this->binD4 << std::endl; + sif::info << "HistogramSet::printSet: BinD5: " << this->binD5 << std::endl; + sif::info << "HistogramSet::printSet: BinD6: " << this->binD6 << std::endl; + sif::info << "HistogramSet::printSet: BinD7: " << this->binD7 << std::endl; + sif::info << "HistogramSet::printSet: BinD8: " << this->binD8 << std::endl; + } }; /** * @brief Dataset to store the contrast telemetry data */ -class ContrastSet: - public StaticLocalDataSet { -public: +class ContrastSet : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 156; - // Size of dataset - static const size_t SIZE = 156; + ContrastSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, CONTRAST_SET_ID) {} - ContrastSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, CONTRAST_SET_ID) { - } + ContrastSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, CONTRAST_SET_ID)) {} - ContrastSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, CONTRAST_SET_ID)) { - } + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_CONTRAST_SET, this); + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_CONTRAST_SET, this); + lp_var_t binA0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA0, this); + lp_var_t binA1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA1, this); + lp_var_t binA2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA2, this); + lp_var_t binA3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA3, this); + lp_var_t binA4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA4, this); + lp_var_t binA5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA5, this); + lp_var_t binA6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA6, this); + lp_var_t binA7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA7, this); + lp_var_t binA8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA8, this); + lp_var_t binb0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB0, this); + lp_var_t binB1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB1, this); + lp_var_t binB2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB2, this); + lp_var_t binB3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB3, this); + lp_var_t binB4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB4, this); + lp_var_t binB5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB5, this); + lp_var_t binB6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB6, this); + lp_var_t binB7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB7, this); + lp_var_t binB8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB8, this); + lp_var_t binC0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC0, this); + lp_var_t binC1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC1, this); + lp_var_t binC2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC2, this); + lp_var_t binC3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC3, this); + lp_var_t binC4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC4, this); + lp_var_t binC5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC5, this); + lp_var_t binC6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC6, this); + lp_var_t binC7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC7, this); + lp_var_t binC8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC8, this); + lp_var_t binD0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND0, this); + lp_var_t binD1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND1, this); + lp_var_t binD2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND2, this); + lp_var_t binD3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND3, this); + lp_var_t binD4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND4, this); + lp_var_t binD5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND5, this); + lp_var_t binD6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND6, this); + lp_var_t binD7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND7, this); + lp_var_t binD8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND8, this); - lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_CONTRAST_SET, this); - lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_CONTRAST_SET, this); - lp_var_t binA0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA0, this); - lp_var_t binA1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA1, this); - lp_var_t binA2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA2, this); - lp_var_t binA3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA3, this); - lp_var_t binA4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA4, this); - lp_var_t binA5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA5, this); - lp_var_t binA6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA6, this); - lp_var_t binA7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA7, this); - lp_var_t binA8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA8, this); - lp_var_t binb0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB0, this); - lp_var_t binB1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB1, this); - lp_var_t binB2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB2, this); - lp_var_t binB3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB3, this); - lp_var_t binB4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB4, this); - lp_var_t binB5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB5, this); - lp_var_t binB6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB6, this); - lp_var_t binB7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB7, this); - lp_var_t binB8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB8, this); - lp_var_t binC0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC0, this); - lp_var_t binC1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC1, this); - lp_var_t binC2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC2, this); - lp_var_t binC3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC3, this); - lp_var_t binC4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC4, this); - lp_var_t binC5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC5, this); - lp_var_t binC6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC6, this); - lp_var_t binC7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC7, this); - lp_var_t binC8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC8, this); - lp_var_t binD0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND0, this); - lp_var_t binD1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND1, this); - lp_var_t binD2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND2, this); - lp_var_t binD3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND3, this); - lp_var_t binD4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND4, this); - lp_var_t binD5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND5, this); - lp_var_t binD6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND6, this); - lp_var_t binD7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND7, this); - lp_var_t binD8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND8, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "ContrastSet::printSet: Ticks: " << this->ticks << std::endl; - sif::info << "ContrastSet::printSet: Time (time stamp): " << this->time << " us" - << std::endl; - sif::info << "ContrastSet::printSet: BinA0: " << this->binA0 << std::endl; - sif::info << "ContrastSet::printSet: BinA1: " << this->binA1 << std::endl; - sif::info << "ContrastSet::printSet: BinA2: " << this->binA2 << std::endl; - sif::info << "ContrastSet::printSet: BinA3: " << this->binA3 << std::endl; - sif::info << "ContrastSet::printSet: BinA4: " << this->binA4 << std::endl; - sif::info << "ContrastSet::printSet: BinA5: " << this->binA5 << std::endl; - sif::info << "ContrastSet::printSet: BinA6: " << this->binA6 << std::endl; - sif::info << "ContrastSet::printSet: BinA7: " << this->binA7 << std::endl; - sif::info << "ContrastSet::printSet: BinA8: " << this->binA8 << std::endl; - sif::info << "ContrastSet::printSet: BinB0: " << this->binA0 << std::endl; - sif::info << "ContrastSet::printSet: BinB1: " << this->binB1 << std::endl; - sif::info << "ContrastSet::printSet: BinB2: " << this->binB2 << std::endl; - sif::info << "ContrastSet::printSet: BinB3: " << this->binB3 << std::endl; - sif::info << "ContrastSet::printSet: BinB4: " << this->binB4 << std::endl; - sif::info << "ContrastSet::printSet: BinB5: " << this->binB5 << std::endl; - sif::info << "ContrastSet::printSet: BinB6: " << this->binB6 << std::endl; - sif::info << "ContrastSet::printSet: BinB7: " << this->binB7 << std::endl; - sif::info << "ContrastSet::printSet: BinB8: " << this->binB8 << std::endl; - sif::info << "ContrastSet::printSet: BinC0: " << this->binC0 << std::endl; - sif::info << "ContrastSet::printSet: BinC1: " << this->binC1 << std::endl; - sif::info << "ContrastSet::printSet: BinC2: " << this->binC2 << std::endl; - sif::info << "ContrastSet::printSet: BinC3: " << this->binC3 << std::endl; - sif::info << "ContrastSet::printSet: BinC4: " << this->binC4 << std::endl; - sif::info << "ContrastSet::printSet: BinC5: " << this->binC5 << std::endl; - sif::info << "ContrastSet::printSet: BinC6: " << this->binC6 << std::endl; - sif::info << "ContrastSet::printSet: BinC7: " << this->binC7 << std::endl; - sif::info << "ContrastSet::printSet: BinC8: " << this->binC8 << std::endl; - sif::info << "ContrastSet::printSet: BinD0: " << this->binD0 << std::endl; - sif::info << "ContrastSet::printSet: BinD1: " << this->binD1 << std::endl; - sif::info << "ContrastSet::printSet: BinD2: " << this->binD2 << std::endl; - sif::info << "ContrastSet::printSet: BinD3: " << this->binD3 << std::endl; - sif::info << "ContrastSet::printSet: BinD4: " << this->binD4 << std::endl; - sif::info << "ContrastSet::printSet: BinD5: " << this->binD5 << std::endl; - sif::info << "ContrastSet::printSet: BinD6: " << this->binD6 << std::endl; - sif::info << "ContrastSet::printSet: BinD7: " << this->binD7 << std::endl; - sif::info << "ContrastSet::printSet: BinD8: " << this->binD8 << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "ContrastSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "ContrastSet::printSet: Time (time stamp): " << this->time << " us" << std::endl; + sif::info << "ContrastSet::printSet: BinA0: " << this->binA0 << std::endl; + sif::info << "ContrastSet::printSet: BinA1: " << this->binA1 << std::endl; + sif::info << "ContrastSet::printSet: BinA2: " << this->binA2 << std::endl; + sif::info << "ContrastSet::printSet: BinA3: " << this->binA3 << std::endl; + sif::info << "ContrastSet::printSet: BinA4: " << this->binA4 << std::endl; + sif::info << "ContrastSet::printSet: BinA5: " << this->binA5 << std::endl; + sif::info << "ContrastSet::printSet: BinA6: " << this->binA6 << std::endl; + sif::info << "ContrastSet::printSet: BinA7: " << this->binA7 << std::endl; + sif::info << "ContrastSet::printSet: BinA8: " << this->binA8 << std::endl; + sif::info << "ContrastSet::printSet: BinB0: " << this->binA0 << std::endl; + sif::info << "ContrastSet::printSet: BinB1: " << this->binB1 << std::endl; + sif::info << "ContrastSet::printSet: BinB2: " << this->binB2 << std::endl; + sif::info << "ContrastSet::printSet: BinB3: " << this->binB3 << std::endl; + sif::info << "ContrastSet::printSet: BinB4: " << this->binB4 << std::endl; + sif::info << "ContrastSet::printSet: BinB5: " << this->binB5 << std::endl; + sif::info << "ContrastSet::printSet: BinB6: " << this->binB6 << std::endl; + sif::info << "ContrastSet::printSet: BinB7: " << this->binB7 << std::endl; + sif::info << "ContrastSet::printSet: BinB8: " << this->binB8 << std::endl; + sif::info << "ContrastSet::printSet: BinC0: " << this->binC0 << std::endl; + sif::info << "ContrastSet::printSet: BinC1: " << this->binC1 << std::endl; + sif::info << "ContrastSet::printSet: BinC2: " << this->binC2 << std::endl; + sif::info << "ContrastSet::printSet: BinC3: " << this->binC3 << std::endl; + sif::info << "ContrastSet::printSet: BinC4: " << this->binC4 << std::endl; + sif::info << "ContrastSet::printSet: BinC5: " << this->binC5 << std::endl; + sif::info << "ContrastSet::printSet: BinC6: " << this->binC6 << std::endl; + sif::info << "ContrastSet::printSet: BinC7: " << this->binC7 << std::endl; + sif::info << "ContrastSet::printSet: BinC8: " << this->binC8 << std::endl; + sif::info << "ContrastSet::printSet: BinD0: " << this->binD0 << std::endl; + sif::info << "ContrastSet::printSet: BinD1: " << this->binD1 << std::endl; + sif::info << "ContrastSet::printSet: BinD2: " << this->binD2 << std::endl; + sif::info << "ContrastSet::printSet: BinD3: " << this->binD3 << std::endl; + sif::info << "ContrastSet::printSet: BinD4: " << this->binD4 << std::endl; + sif::info << "ContrastSet::printSet: BinD5: " << this->binD5 << std::endl; + sif::info << "ContrastSet::printSet: BinD6: " << this->binD6 << std::endl; + sif::info << "ContrastSet::printSet: BinD7: " << this->binD7 << std::endl; + sif::info << "ContrastSet::printSet: BinD8: " << this->binD8 << std::endl; + } }; /** * @brief Helper Class to extract information from bytestream. */ class ChecksumReply { -public: - - /** - * @brief Constructor - * - * @param datafield Pointer to datafield in reply buffer - * - */ - ChecksumReply(const uint8_t* datafield) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - region = *(datafield); - const uint8_t* addressData = datafield + ADDRESS_OFFSET; - size_t size = sizeof(address); - result = SerializeAdapter::deSerialize(&address, &addressData, &size, - SerializeIF::Endianness::LITTLE); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "ChecksumReply::ChecksumReply: Failed to deserialize address" - << std::endl; - } - const uint8_t* lengthData = datafield + LENGTH_OFFSET; - size = sizeof(length); - result = SerializeAdapter::deSerialize(&length, &lengthData, &size, - SerializeIF::Endianness::LITTLE); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "ChecksumReply::ChecksumReply: Failed to deserialize length" - << std::endl; - } - const uint8_t* checksumData = datafield + CHECKSUM_OFFSET; - size = sizeof(checksum); - result = SerializeAdapter::deSerialize(&checksum, &checksumData, &size, - SerializeIF::Endianness::LITTLE); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "ChecksumReply::ChecksumReply: Failed to deserialize checksum" - << std::endl; - } + public: + /** + * @brief Constructor + * + * @param datafield Pointer to datafield in reply buffer + * + */ + ChecksumReply(const uint8_t* datafield) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + region = *(datafield); + const uint8_t* addressData = datafield + ADDRESS_OFFSET; + size_t size = sizeof(address); + result = SerializeAdapter::deSerialize(&address, &addressData, &size, + SerializeIF::Endianness::LITTLE); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "ChecksumReply::ChecksumReply: Failed to deserialize address" << std::endl; } - - uint8_t getRegion() { - return region; + const uint8_t* lengthData = datafield + LENGTH_OFFSET; + size = sizeof(length); + result = + SerializeAdapter::deSerialize(&length, &lengthData, &size, SerializeIF::Endianness::LITTLE); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "ChecksumReply::ChecksumReply: Failed to deserialize length" << std::endl; } - - uint32_t getAddress() { - return address; + const uint8_t* checksumData = datafield + CHECKSUM_OFFSET; + size = sizeof(checksum); + result = SerializeAdapter::deSerialize(&checksum, &checksumData, &size, + SerializeIF::Endianness::LITTLE); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "ChecksumReply::ChecksumReply: Failed to deserialize checksum" << std::endl; } + } - uint32_t getLength() { - return length; - } + uint8_t getRegion() { return region; } - uint32_t getChecksum() { - return checksum; - } + uint32_t getAddress() { return address; } - void printChecksum() { - sif::info << "ChecksumReply::printChecksum: 0x" << std::hex << checksum << std::endl; - } + uint32_t getLength() { return length; } -private: + uint32_t getChecksum() { return checksum; } - static const uint8_t ADDRESS_OFFSET = 1; - static const uint8_t LENGTH_OFFSET = 5; - static const uint8_t CHECKSUM_OFFSET = 9; + void printChecksum() { + sif::info << "ChecksumReply::printChecksum: 0x" << std::hex << checksum << std::endl; + } - uint8_t region = 0; - uint32_t address = 0; - uint32_t length = 0; - uint32_t checksum = 0; + private: + static const uint8_t ADDRESS_OFFSET = 1; + static const uint8_t LENGTH_OFFSET = 5; + static const uint8_t CHECKSUM_OFFSET = 9; + + uint8_t region = 0; + uint32_t address = 0; + uint32_t length = 0; + uint32_t checksum = 0; }; class EraseReply { -public: - EraseReply(const uint8_t* datafield) { - region = *datafield; - } + public: + EraseReply(const uint8_t* datafield) { region = *datafield; } - uint8_t getRegion() { - return region; - } + uint8_t getRegion() { return region; } -private: - uint8_t region = 0; + private: + uint8_t region = 0; }; -class ChecksumSet: - public StaticLocalDataSet { -public: +class ChecksumSet : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 156; - // Size of dataset - static const size_t SIZE = 156; + ChecksumSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, CHECKSUM_SET_ID) {} - ChecksumSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, CHECKSUM_SET_ID) { - } + ChecksumSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, CHECKSUM_SET_ID)) {} - ChecksumSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, CHECKSUM_SET_ID)) { - } - - lp_var_t checksum = lp_var_t(sid.objectId, PoolIds::CHKSUM, this); + lp_var_t checksum = lp_var_t(sid.objectId, PoolIds::CHKSUM, this); }; /** * @brief Dataset to store download centroid response */ -class DownloadCentroidSet: - public StaticLocalDataSet { -public: +class DownloadCentroidSet : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 34; - // Size of dataset - static const size_t SIZE = 34; + DownloadCentroidSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, DOWNLOADCENTROID_SET_ID) {} - DownloadCentroidSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, DOWNLOADCENTROID_SET_ID) { - } + DownloadCentroidSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, DOWNLOADCENTROID_SET_ID)) {} - DownloadCentroidSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, DOWNLOADCENTROID_SET_ID)) { - } + lp_var_t id = lp_var_t(sid.objectId, PoolIds::DWL_ID, this); + lp_var_t pixx = lp_var_t(sid.objectId, PoolIds::DWL_PIXX, this); + lp_var_t pixy = lp_var_t(sid.objectId, PoolIds::DWL_PIXY, this); + lp_var_t xUncorrected = lp_var_t(sid.objectId, PoolIds::DWL_X_UNCORRECTED, this); + lp_var_t yUncorrected = lp_var_t(sid.objectId, PoolIds::DWL_Y_UNCORRECTED, this); + lp_var_t xCorrected = lp_var_t(sid.objectId, PoolIds::DWL_X_CORRECTED, this); + lp_var_t yCorrected = lp_var_t(sid.objectId, PoolIds::DWL_Y_CORRECTED, this); + lp_var_t magnitude = lp_var_t(sid.objectId, PoolIds::DWL_MAGNITUDE, this); + lp_var_t cxa = lp_var_t(sid.objectId, PoolIds::DWL_CXA, this); + lp_var_t cya = lp_var_t(sid.objectId, PoolIds::DWL_CYA, this); + lp_var_t quality = lp_var_t(sid.objectId, PoolIds::DWL_QUALITY, this); - lp_var_t id = lp_var_t(sid.objectId, PoolIds::DWL_ID, this); - lp_var_t pixx = lp_var_t(sid.objectId, PoolIds::DWL_PIXX, this); - lp_var_t pixy = lp_var_t(sid.objectId, PoolIds::DWL_PIXY, this); - lp_var_t xUncorrected = lp_var_t(sid.objectId, PoolIds::DWL_X_UNCORRECTED, this); - lp_var_t yUncorrected = lp_var_t(sid.objectId, PoolIds::DWL_Y_UNCORRECTED, this); - lp_var_t xCorrected = lp_var_t(sid.objectId, PoolIds::DWL_X_CORRECTED, this); - lp_var_t yCorrected = lp_var_t(sid.objectId, PoolIds::DWL_Y_CORRECTED, this); - lp_var_t magnitude = lp_var_t(sid.objectId, PoolIds::DWL_MAGNITUDE, this); - lp_var_t cxa = lp_var_t(sid.objectId, PoolIds::DWL_CXA, this); - lp_var_t cya = lp_var_t(sid.objectId, PoolIds::DWL_CYA, this); - lp_var_t quality = lp_var_t(sid.objectId, PoolIds::DWL_QUALITY, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "ContrastSet::printSet: id: " << static_cast(this->id.value) - << std::endl; - sif::info << "ContrastSet::printSet: pixx: " << this->pixx << std::endl; - sif::info << "ContrastSet::printSet: pixy: " << this->pixy << std::endl; - sif::info << "ContrastSet::printSet: xUncorrected: " << this->xUncorrected << std::endl; - sif::info << "ContrastSet::printSet: yUncorrected: " << this->yUncorrected << std::endl; - sif::info << "ContrastSet::printSet: xCorrected: " << this->xCorrected << std::endl; - sif::info << "ContrastSet::printSet: yCorrected: " << this->yCorrected << std::endl; - sif::info << "ContrastSet::printSet: magnitude: " << this->magnitude << std::endl; - sif::info << "ContrastSet::printSet: cxa: " << this->cxa << std::endl; - sif::info << "ContrastSet::printSet: cya: " << this->cya << std::endl; - sif::info << "ContrastSet::printSet: quality: " << this->quality << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "ContrastSet::printSet: id: " << static_cast(this->id.value) + << std::endl; + sif::info << "ContrastSet::printSet: pixx: " << this->pixx << std::endl; + sif::info << "ContrastSet::printSet: pixy: " << this->pixy << std::endl; + sif::info << "ContrastSet::printSet: xUncorrected: " << this->xUncorrected << std::endl; + sif::info << "ContrastSet::printSet: yUncorrected: " << this->yUncorrected << std::endl; + sif::info << "ContrastSet::printSet: xCorrected: " << this->xCorrected << std::endl; + sif::info << "ContrastSet::printSet: yCorrected: " << this->yCorrected << std::endl; + sif::info << "ContrastSet::printSet: magnitude: " << this->magnitude << std::endl; + sif::info << "ContrastSet::printSet: cxa: " << this->cxa << std::endl; + sif::info << "ContrastSet::printSet: cya: " << this->cya << std::endl; + sif::info << "ContrastSet::printSet: quality: " << this->quality << std::endl; + } }; namespace UploadCentroidKeys { - static const char id[] = "id"; - static const char pixx[] = "pixx"; - static const char pixy[] = "pixy"; - static const char x_uncorrected[] = "x_uncorrected"; - static const char y_uncorrected[] = "y_uncorrected"; - static const char x_corrected[] = "x_corrected"; - static const char y_corrected[] = "y_corrected"; - static const char magnitude[] = "magnitude"; - static const char cxa[] = "cxa"; - static const char cya[] = "cya"; - static const char quality[] = "quality"; -}; +static const char id[] = "id"; +static const char pixx[] = "pixx"; +static const char pixy[] = "pixy"; +static const char x_uncorrected[] = "x_uncorrected"; +static const char y_uncorrected[] = "y_uncorrected"; +static const char x_corrected[] = "x_corrected"; +static const char y_corrected[] = "y_corrected"; +static const char magnitude[] = "magnitude"; +static const char cxa[] = "cxa"; +static const char cya[] = "cya"; +static const char quality[] = "quality"; +}; // namespace UploadCentroidKeys /** * @brief Dataset to store matched star information */ -class DownloadMatchedStar : - public StaticLocalDataSet { -public: +class DownloadMatchedStar : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 53; - // Size of dataset - static const size_t SIZE = 53; + DownloadMatchedStar(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, DOWNLOAD_MATCHED_STAR_SET_ID) {} - DownloadMatchedStar(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, DOWNLOAD_MATCHED_STAR_SET_ID) { - } + DownloadMatchedStar(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, DOWNLOAD_MATCHED_STAR_SET_ID)) {} - DownloadMatchedStar(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, DOWNLOAD_MATCHED_STAR_SET_ID)) { - } + lp_var_t id = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_ID, this); + lp_var_t camfpx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMFPX, this); + lp_var_t camfpy = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMFPY, this); + lp_var_t camcartx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTX, this); + lp_var_t camcarty = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTY, this); + lp_var_t camcartz = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTZ, this); + lp_var_t cammagnitude = + lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMMAGNITUDE, this); + lp_var_t dbfpx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBFPX, this); + lp_var_t dbfpy = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBFPY, this); + lp_var_t dbcartx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBCARTX, this); + lp_var_t dbcarty = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBCARTY, this); + lp_var_t dbcartz = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBCARTZ, this); + lp_var_t dbmagnitude = + lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBMAGNITUDE, this); + lp_var_t catalogid = + lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CATALOGID, this); - lp_var_t id = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_ID, this); - lp_var_t camfpx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMFPX, this); - lp_var_t camfpy = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMFPY, this); - lp_var_t camcartx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTX, this); - lp_var_t camcarty = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTY, this); - lp_var_t camcartz = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTZ, this); - lp_var_t cammagnitude = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMMAGNITUDE, - this); - lp_var_t dbfpx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBFPX, this); - lp_var_t dbfpy = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBFPY, this); - lp_var_t dbcartx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBCARTX, this); - lp_var_t dbcarty = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBCARTY, this); - lp_var_t dbcartz = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBCARTZ, this); - lp_var_t dbmagnitude = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBMAGNITUDE, - this); - lp_var_t catalogid = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CATALOGID, - this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "DownloadMatchedStar::printSet: id: " - << static_cast(this->id.value) << std::endl; - sif::info << "DownloadMatchedStar::printSet: camfpx: " << this->camfpx << std::endl; - sif::info << "DownloadMatchedStar::printSet: camfpy: " << this->camfpy << std::endl; - sif::info << "DownloadMatchedStar::printSet: camcartx: " << this->camcartx << std::endl; - sif::info << "DownloadMatchedStar::printSet: camcarty: " << this->camcarty << std::endl; - sif::info << "DownloadMatchedStar::printSet: camcartz: " << this->camcartz << std::endl; - sif::info << "DownloadMatchedStar::printSet: cammagnitude: " << this->cammagnitude - << std::endl; - sif::info << "DownloadMatchedStar::printSet: dbfpx: " << this->dbfpx << std::endl; - sif::info << "DownloadMatchedStar::printSet: dbfpy: " << this->dbfpy << std::endl; - sif::info << "DownloadMatchedStar::printSet: dbcartx: " << this->dbcartx << std::endl; - sif::info << "DownloadMatchedStar::printSet: dbcarty: " << this->dbcarty << std::endl; - sif::info << "DownloadMatchedStar::printSet: dbcartz: " << this->dbcartz << std::endl; - sif::info << "DownloadMatchedStar::printSet: dbmagnitude: " << this->dbmagnitude - << std::endl; - sif::info << "DownloadMatchedStar::printSet: catalogid: " << this->catalogid << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "DownloadMatchedStar::printSet: id: " << static_cast(this->id.value) + << std::endl; + sif::info << "DownloadMatchedStar::printSet: camfpx: " << this->camfpx << std::endl; + sif::info << "DownloadMatchedStar::printSet: camfpy: " << this->camfpy << std::endl; + sif::info << "DownloadMatchedStar::printSet: camcartx: " << this->camcartx << std::endl; + sif::info << "DownloadMatchedStar::printSet: camcarty: " << this->camcarty << std::endl; + sif::info << "DownloadMatchedStar::printSet: camcartz: " << this->camcartz << std::endl; + sif::info << "DownloadMatchedStar::printSet: cammagnitude: " << this->cammagnitude << std::endl; + sif::info << "DownloadMatchedStar::printSet: dbfpx: " << this->dbfpx << std::endl; + sif::info << "DownloadMatchedStar::printSet: dbfpy: " << this->dbfpy << std::endl; + sif::info << "DownloadMatchedStar::printSet: dbcartx: " << this->dbcartx << std::endl; + sif::info << "DownloadMatchedStar::printSet: dbcarty: " << this->dbcarty << std::endl; + sif::info << "DownloadMatchedStar::printSet: dbcartz: " << this->dbcartz << std::endl; + sif::info << "DownloadMatchedStar::printSet: dbmagnitude: " << this->dbmagnitude << std::endl; + sif::info << "DownloadMatchedStar::printSet: catalogid: " << this->catalogid << std::endl; + } }; /** * @brief Dataset to store the response to the DownloadDBImage request */ -class DownloadDBImage : - public StaticLocalDataSet { -public: +class DownloadDBImage : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 21; - // Size of dataset - static const size_t SIZE = 21; + DownloadDBImage(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, DOWNLOAD_DBIMAGE_SET_ID) {} - DownloadDBImage(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, DOWNLOAD_DBIMAGE_SET_ID) { - } + DownloadDBImage(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, DOWNLOAD_DBIMAGE_SET_ID)) {} - DownloadDBImage(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, DOWNLOAD_DBIMAGE_SET_ID)) { - } + lp_var_t id = lp_var_t(sid.objectId, PoolIds::DBIMAGE_ID, this); + lp_var_t pixx = lp_var_t(sid.objectId, PoolIds::DBIMAGE_PIXX, this); + lp_var_t pixy = lp_var_t(sid.objectId, PoolIds::DBIMAGE_PIXY, this); + lp_var_t x = lp_var_t(sid.objectId, PoolIds::DBIMAGE_X, this); + lp_var_t y = lp_var_t(sid.objectId, PoolIds::DBIMAGE_Y, this); + lp_var_t magnitude = lp_var_t(sid.objectId, PoolIds::DBIMAGE_MAGNITUDE, this); - lp_var_t id = lp_var_t(sid.objectId, PoolIds::DBIMAGE_ID, this); - lp_var_t pixx = lp_var_t(sid.objectId, PoolIds::DBIMAGE_PIXX, this); - lp_var_t pixy = lp_var_t(sid.objectId, PoolIds::DBIMAGE_PIXY, this); - lp_var_t x = lp_var_t(sid.objectId, PoolIds::DBIMAGE_X, this); - lp_var_t y = lp_var_t(sid.objectId, PoolIds::DBIMAGE_Y, this); - lp_var_t magnitude = lp_var_t(sid.objectId, PoolIds::DBIMAGE_MAGNITUDE, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "DownloadDBImage::printSet: id: " - << static_cast(this->id.value) << std::endl; - sif::info << "DownloadDBImage::printSet: pixx: " << this->pixx << std::endl; - sif::info << "DownloadDBImage::printSet: pixy: " << this->pixy << std::endl; - sif::info << "DownloadDBImage::printSet: x: " << this->x << std::endl; - sif::info << "DownloadDBImage::printSet: y: " << this->y << std::endl; - sif::info << "DownloadDBImage::printSet: magnitude: " << this->magnitude << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "DownloadDBImage::printSet: id: " << static_cast(this->id.value) + << std::endl; + sif::info << "DownloadDBImage::printSet: pixx: " << this->pixx << std::endl; + sif::info << "DownloadDBImage::printSet: pixy: " << this->pixy << std::endl; + sif::info << "DownloadDBImage::printSet: x: " << this->x << std::endl; + sif::info << "DownloadDBImage::printSet: y: " << this->y << std::endl; + sif::info << "DownloadDBImage::printSet: magnitude: " << this->magnitude << std::endl; + } }; /** * @brief Dataset to store the response to the download blob pixel action request */ -class DownloadBlobPixel: public StaticLocalDataSet { -public: +class DownloadBlobPixel : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 22; - // Size of dataset - static const size_t SIZE = 22; + DownloadBlobPixel(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, DOWNLOAD_BLOBPIXEL_SET_ID) {} - DownloadBlobPixel(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, DOWNLOAD_BLOBPIXEL_SET_ID) { - } + DownloadBlobPixel(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, DOWNLOAD_BLOBPIXEL_SET_ENTRIES)) {} - DownloadBlobPixel(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, DOWNLOAD_BLOBPIXEL_SET_ENTRIES)) { - } + lp_var_t id = lp_var_t(sid.objectId, PoolIds::BLOBPIX_ID, this); + lp_var_t x = lp_var_t(sid.objectId, PoolIds::BLOBPIX_X, this); + lp_var_t y = lp_var_t(sid.objectId, PoolIds::BLOBPIX_Y, this); + lp_var_t totalValue = lp_var_t(sid.objectId, PoolIds::BLOBPIX_TOT_VAL, this); + lp_var_t inUse = lp_var_t(sid.objectId, PoolIds::BLOBPIX_IN_USE, this); + lp_var_t brightNeighbours = + lp_var_t(sid.objectId, PoolIds::BLOBPIX_BRIGHT_NEIGHBOURS, this); + lp_var_t region = lp_var_t(sid.objectId, PoolIds::BLOBPIX_REGION, this); - lp_var_t id = lp_var_t(sid.objectId, PoolIds::BLOBPIX_ID, this); - lp_var_t x = lp_var_t(sid.objectId, PoolIds::BLOBPIX_X, this); - lp_var_t y = lp_var_t(sid.objectId, PoolIds::BLOBPIX_Y, this); - lp_var_t totalValue = lp_var_t(sid.objectId, PoolIds::BLOBPIX_TOT_VAL, this); - lp_var_t inUse = lp_var_t(sid.objectId, PoolIds::BLOBPIX_IN_USE, this); - lp_var_t brightNeighbours = lp_var_t(sid.objectId, - PoolIds::BLOBPIX_BRIGHT_NEIGHBOURS, this); - lp_var_t region = lp_var_t(sid.objectId, PoolIds::BLOBPIX_REGION, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "DownloadBlobPixel::printSet: id: " - << static_cast(this->id.value) << std::endl; - sif::info << "DownloadBlobPixel::printSet: x: " << this->x << std::endl; - sif::info << "DownloadBlobPixel::printSet: y: " << this->y << std::endl; - sif::info << "DownloadBlobPixel::printSet: totalValue: " << this->totalValue << std::endl; - sif::info << "DownloadBlobPixel::printSet: inUse: " - << static_cast(this->inUse.value) << std::endl; - sif::info << "DownloadBlobPixel::printSet: brightNeighbours: " << this->brightNeighbours - << std::endl; - sif::info << "DownloadBlobPixel::printSet: region: " << this->region << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "DownloadBlobPixel::printSet: id: " << static_cast(this->id.value) + << std::endl; + sif::info << "DownloadBlobPixel::printSet: x: " << this->x << std::endl; + sif::info << "DownloadBlobPixel::printSet: y: " << this->y << std::endl; + sif::info << "DownloadBlobPixel::printSet: totalValue: " << this->totalValue << std::endl; + sif::info << "DownloadBlobPixel::printSet: inUse: " + << static_cast(this->inUse.value) << std::endl; + sif::info << "DownloadBlobPixel::printSet: brightNeighbours: " << this->brightNeighbours + << std::endl; + sif::info << "DownloadBlobPixel::printSet: region: " << this->region << std::endl; + } }; -} +} // namespace StarTracker #endif /* MISSION_STARTRACKER_DEFINITIONS_H_ */ diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp index de70037a..81fea5e7 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp @@ -1,645 +1,653 @@ -#include #include "StarTrackerHandler.h" -#include "OBSWConfig.h" -#include "StarTrackerJsonCommands.h" + #include #include #include + +#include + +#include "OBSWConfig.h" +#include "StarTrackerJsonCommands.h" extern "C" { - #include - #include - #include "common/misc.h" +#include +#include + +#include "common/misc.h" } using json = nlohmann::json; -StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie, StrHelper* strHelper) : - DeviceHandlerBase(objectId, comIF, comCookie), temperatureSet(this), versionSet(this), powerSet( - this), interfaceSet(this), timeSet(this), solutionSet(this), histogramSet(this), contrastSet( - this), checksumSet(this), downloadCentroidSet(this), downloadMatchedStar(this), - downloadDbImage(this), downloadBlobPixel(this), strHelper( - strHelper) { - if (comCookie == nullptr) { - sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl; - } - if (strHelper == nullptr) { - sif::error << "StarTrackerHandler: Invalid str image loader" << std::endl; - } - eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5); +StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, + StrHelper* strHelper) + : DeviceHandlerBase(objectId, comIF, comCookie), + temperatureSet(this), + versionSet(this), + powerSet(this), + interfaceSet(this), + timeSet(this), + solutionSet(this), + histogramSet(this), + contrastSet(this), + checksumSet(this), + downloadCentroidSet(this), + downloadMatchedStar(this), + downloadDbImage(this), + downloadBlobPixel(this), + strHelper(strHelper) { + if (comCookie == nullptr) { + sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl; + } + if (strHelper == nullptr) { + sif::error << "StarTrackerHandler: Invalid str image loader" << std::endl; + } + eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5); } -StarTrackerHandler::~StarTrackerHandler() { -} +StarTrackerHandler::~StarTrackerHandler() {} ReturnValue_t StarTrackerHandler::initialize() { - ReturnValue_t result = RETURN_OK; - result = DeviceHandlerBase::initialize(); - if (result != RETURN_OK) { - return result; - } + ReturnValue_t result = RETURN_OK; + result = DeviceHandlerBase::initialize(); + if (result != RETURN_OK) { + return result; + } - EventManagerIF* manager = ObjectManager::instance()->get( - objects::EVENT_MANAGER); - if (manager == nullptr) { + EventManagerIF* manager = ObjectManager::instance()->get(objects::EVENT_MANAGER); + if (manager == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "StarTrackerHandler::initialize: Invalid event manager" << std::endl; + sif::error << "StarTrackerHandler::initialize: Invalid event manager" << std::endl; #endif - return ObjectManagerIF::CHILD_INIT_FAILED;; - } - result = manager->registerListener(eventQueue->getId()); - if (result != RETURN_OK) { - return result; - } - result = manager->subscribeToEventRange(eventQueue->getId(), - event::getEventId(StrHelper::IMAGE_UPLOAD_FAILED), - event::getEventId(StrHelper::FPGA_UPLOAD_FAILED)); - if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + ; + } + result = manager->registerListener(eventQueue->getId()); + if (result != RETURN_OK) { + return result; + } + result = manager->subscribeToEventRange(eventQueue->getId(), + event::getEventId(StrHelper::IMAGE_UPLOAD_FAILED), + event::getEventId(StrHelper::FPGA_UPLOAD_FAILED)); + if (result != RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "StarTrackerHandler::initialize: Failed to subscribe to events from " - " str helper" << std::endl; + sif::warning << "StarTrackerHandler::initialize: Failed to subscribe to events from " + " str helper" + << std::endl; #endif - return ObjectManagerIF::CHILD_INIT_FAILED; - } + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = strHelper->setComIF(communicationInterface); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } - strHelper->setComCookie(comCookie); - return RETURN_OK; + result = strHelper->setComIF(communicationInterface); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } + strHelper->setComCookie(comCookie); + return RETURN_OK; } ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size) { + const uint8_t* data, size_t size) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; - - switch(actionId) { - case(StarTracker::STOP_IMAGE_LOADER): { - strHelper->stopProcess(); - return EXECUTION_FINISHED; + switch (actionId) { + case (StarTracker::STOP_IMAGE_LOADER): { + strHelper->stopProcess(); + return EXECUTION_FINISHED; } - case(StarTracker::SET_JSON_FILE_NAME): { - if (size > MAX_PATH_SIZE) { - return FILE_PATH_TOO_LONG; - } - paramJsonFile = std::string(reinterpret_cast(data), size); - return EXECUTION_FINISHED; + case (StarTracker::SET_JSON_FILE_NAME): { + if (size > MAX_PATH_SIZE) { + return FILE_PATH_TOO_LONG; + } + paramJsonFile = std::string(reinterpret_cast(data), size); + return EXECUTION_FINISHED; } default: - break; - } + break; + } - if (strHelperExecuting == true) { - return IMAGE_LOADER_EXECUTING; - } + if (strHelperExecuting == true) { + return IMAGE_LOADER_EXECUTING; + } - result = checkMode(actionId); - if (result != RETURN_OK) { + result = checkMode(actionId); + if (result != RETURN_OK) { + return result; + } + + // Intercept image loader commands which do not follow the common DHB communication flow + switch (actionId) { + case (StarTracker::UPLOAD_IMAGE): { + result = DeviceHandlerBase::acceptExternalDeviceCommands(); + if (result != RETURN_OK) { return result; + } + if (size > MAX_PATH_SIZE + MAX_FILE_NAME) { + return FILE_PATH_TOO_LONG; + } + result = strHelper->startImageUpload(std::string(reinterpret_cast(data), size)); + if (result != RETURN_OK) { + return result; + } + strHelperExecuting = true; + return EXECUTION_FINISHED; } + case (StarTracker::DOWNLOAD_IMAGE): { + result = DeviceHandlerBase::acceptExternalDeviceCommands(); + if (result != RETURN_OK) { + return result; + } + if (size > MAX_PATH_SIZE) { + return FILE_PATH_TOO_LONG; + } + result = + strHelper->startImageDownload(std::string(reinterpret_cast(data), size)); + if (result != RETURN_OK) { + return result; + } + strHelperExecuting = true; + return EXECUTION_FINISHED; + } + case (StarTracker::WRITE): { + result = DeviceHandlerBase::acceptExternalDeviceCommands(); + if (result != RETURN_OK) { + return result; + } + result = executeWriteCommand(data, size); + if (result != RETURN_OK) { + return result; + } - // Intercept image loader commands which do not follow the common DHB communication flow - switch(actionId) { - case(StarTracker::UPLOAD_IMAGE): { - result = DeviceHandlerBase::acceptExternalDeviceCommands(); - if (result != RETURN_OK) { - return result; - } - if (size > MAX_PATH_SIZE + MAX_FILE_NAME) { - return FILE_PATH_TOO_LONG; - } - result = strHelper->startImageUpload( - std::string(reinterpret_cast(data), size)); - if (result != RETURN_OK) { - return result; - } - strHelperExecuting = true; - return EXECUTION_FINISHED; + strHelperExecuting = true; + return EXECUTION_FINISHED; } - case(StarTracker::DOWNLOAD_IMAGE): { - result = DeviceHandlerBase::acceptExternalDeviceCommands(); - if (result != RETURN_OK) { - return result; - } - if (size > MAX_PATH_SIZE) { - return FILE_PATH_TOO_LONG; - } - result = strHelper->startImageDownload( - std::string(reinterpret_cast(data), size)); - if (result != RETURN_OK) { - return result; - } - strHelperExecuting = true; - return EXECUTION_FINISHED; + case (StarTracker::READ): { + result = DeviceHandlerBase::acceptExternalDeviceCommands(); + if (result != RETURN_OK) { + return result; + } + result = executeReadCommand(data, size); + if (result != RETURN_OK) { + return result; + } + strHelperExecuting = true; + return EXECUTION_FINISHED; } - case(StarTracker::WRITE): { - result = DeviceHandlerBase::acceptExternalDeviceCommands(); - if (result != RETURN_OK) { - return result; - } - result = executeWriteCommand(data, size); - if (result != RETURN_OK) { - return result; - } - - strHelperExecuting = true; - return EXECUTION_FINISHED; + case (StarTracker::CHANGE_DOWNLOAD_FILE): { + if (size > MAX_FILE_NAME) { + return FILENAME_TOO_LONG; + } + strHelper->setDownloadImageName(std::string(reinterpret_cast(data), size)); + return EXECUTION_FINISHED; } - case(StarTracker::READ): { - result = DeviceHandlerBase::acceptExternalDeviceCommands(); - if (result != RETURN_OK) { - return result; - } - result = executeReadCommand(data, size); - if (result != RETURN_OK) { - return result; - } - strHelperExecuting = true; - return EXECUTION_FINISHED; + case (StarTracker::CHANGE_FPGA_DOWNLOAD_FILE): { + if (size > MAX_FILE_NAME) { + return FILENAME_TOO_LONG; + } + strHelper->setDownloadFpgaImage(std::string(reinterpret_cast(data), size)); + return EXECUTION_FINISHED; } - case(StarTracker::CHANGE_DOWNLOAD_FILE): { - if (size > MAX_FILE_NAME) { - return FILENAME_TOO_LONG; - } - strHelper->setDownloadImageName( - std::string(reinterpret_cast(data), size)); - return EXECUTION_FINISHED; + case (StarTracker::SET_READ_FILENAME): { + if (size > MAX_FILE_NAME) { + return FILENAME_TOO_LONG; + } + strHelper->setDownloadImageName(std::string(reinterpret_cast(data), size)); + return EXECUTION_FINISHED; } - case(StarTracker::CHANGE_FPGA_DOWNLOAD_FILE): { - if (size > MAX_FILE_NAME) { - return FILENAME_TOO_LONG; - } - strHelper->setDownloadFpgaImage(std::string(reinterpret_cast(data), size)); - return EXECUTION_FINISHED; + case (StarTracker::DOWNLOAD_FPGA_IMAGE): { + result = DeviceHandlerBase::acceptExternalDeviceCommands(); + if (result != RETURN_OK) { + return result; + } + if (size > MAX_PATH_SIZE) { + return FILE_PATH_TOO_LONG; + } + result = executeFpgaDownloadCommand(data, size); + if (result != RETURN_OK) { + return result; + } + strHelperExecuting = true; + return EXECUTION_FINISHED; } - case(StarTracker::SET_READ_FILENAME): { - if (size > MAX_FILE_NAME) { - return FILENAME_TOO_LONG; - } - strHelper->setDownloadImageName( - std::string(reinterpret_cast(data), size)); - return EXECUTION_FINISHED; - } - case(StarTracker::DOWNLOAD_FPGA_IMAGE): { - result = DeviceHandlerBase::acceptExternalDeviceCommands(); - if (result != RETURN_OK) { - return result; - } - if (size > MAX_PATH_SIZE) { - return FILE_PATH_TOO_LONG; - } - result = executeFpgaDownloadCommand(data, size); - if (result != RETURN_OK) { - return result; - } - strHelperExecuting = true; - return EXECUTION_FINISHED; - } - case(StarTracker::UPLOAD_FPGA_IMAGE): { - result = DeviceHandlerBase::acceptExternalDeviceCommands(); - if (result != RETURN_OK) { - return result; - } - if (size > MAX_PATH_SIZE + MAX_FILE_NAME) { - return FILE_PATH_TOO_LONG; - } - result = strHelper->startFpgaUpload(std::string(reinterpret_cast(data), size)); - if (result != RETURN_OK) { - return result; - } - strHelperExecuting = true; - return EXECUTION_FINISHED; + case (StarTracker::UPLOAD_FPGA_IMAGE): { + result = DeviceHandlerBase::acceptExternalDeviceCommands(); + if (result != RETURN_OK) { + return result; + } + if (size > MAX_PATH_SIZE + MAX_FILE_NAME) { + return FILE_PATH_TOO_LONG; + } + result = strHelper->startFpgaUpload(std::string(reinterpret_cast(data), size)); + if (result != RETURN_OK) { + return result; + } + strHelperExecuting = true; + return EXECUTION_FINISHED; } default: - break; - } - return DeviceHandlerBase::executeAction(actionId, commandedBy, data, size); + break; + } + return DeviceHandlerBase::executeAction(actionId, commandedBy, data, size); } void StarTrackerHandler::performOperationHook() { - EventMessage event; - for (ReturnValue_t result = eventQueue->receiveMessage(&event); - result == RETURN_OK; result = eventQueue->receiveMessage(&event)) { - switch (event.getMessageId()) { - case EventMessage::EVENT_MESSAGE: - handleEvent(&event); - break; - default: - sif::debug << "CCSDSHandler::checkEvents: Did not subscribe to this event message" - << std::endl; - break; - } + EventMessage event; + for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == RETURN_OK; + result = eventQueue->receiveMessage(&event)) { + switch (event.getMessageId()) { + case EventMessage::EVENT_MESSAGE: + handleEvent(&event); + break; + default: + sif::debug << "CCSDSHandler::checkEvents: Did not subscribe to this event message" + << std::endl; + break; } + } } void StarTrackerHandler::doStartUp() { - switch(startupState) { + switch (startupState) { case StartupState::IDLE: - startupState = StartupState::CHECK_BOOT_STATE; - return; + startupState = StartupState::CHECK_BOOT_STATE; + return; case StartupState::BOOT_DELAY: - if (bootCountdown.hasTimedOut()) { - startupState = StartupState::LIMITS; - } - return; + if (bootCountdown.hasTimedOut()) { + startupState = StartupState::LIMITS; + } + return; case StartupState::DONE: - break; + break; default: - return; - } - setMode(_MODE_TO_ON); + return; + } + setMode(_MODE_TO_ON); } void StarTrackerHandler::doShutDown() { - // If star tracker is shutdown also stop all running processes in the image loader task - strHelper->stopProcess(); - setMode(_MODE_POWER_DOWN); + // If star tracker is shutdown also stop all running processes in the image loader task + strHelper->stopProcess(); + setMode(_MODE_POWER_DOWN); } -void StarTrackerHandler::doOffActivity() { - startupState = StartupState::IDLE; -} +void StarTrackerHandler::doOffActivity() { startupState = StartupState::IDLE; } -ReturnValue_t StarTrackerHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) { - switch (internalState) { +ReturnValue_t StarTrackerHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + switch (internalState) { case InternalState::TEMPERATURE_REQUEST: - *id = StarTracker::REQ_TEMPERATURE; - break; + *id = StarTracker::REQ_TEMPERATURE; + break; default: - sif::debug << "StarTrackerHandler::buildNormalDeviceCommand: Invalid internal step" - << std::endl; - break; - } - return buildCommandFromCommand(*id, NULL, 0); + sif::debug << "StarTrackerHandler::buildNormalDeviceCommand: Invalid internal step" + << std::endl; + break; + } + return buildCommandFromCommand(*id, NULL, 0); } -ReturnValue_t StarTrackerHandler::buildTransitionDeviceCommand(DeviceCommandId_t * id) { - if (mode != _MODE_START_UP) { - return NOTHING_TO_SEND; - } - switch (startupState) { - case StartupState::CHECK_BOOT_STATE: - *id = StarTracker::REQ_VERSION; - startupState = StartupState::WAIT_FOR_EXECUTION; - return buildCommandFromCommand(*id, nullptr, 0); - case StartupState::BOOT: - *id = StarTracker::BOOT; - bootCountdown.setTimeout(BOOT_TIMEOUT); - startupState = StartupState::BOOT_DELAY; - return buildCommandFromCommand(*id, nullptr, 0); - case StartupState::LIMITS: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::LIMITS; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::TRACKING: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::TRACKING; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::MOUNTING: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::MOUNTING; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::CAMERA: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::CAMERA; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::BLOB: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::BLOB; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::CENTROIDING: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::CENTROIDING; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::LISA: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::LISA; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::MATCHING: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::MATCHING; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::VALIDATION: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::VALIDATION; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::ALGO: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::ALGO; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - default: - break; - } +ReturnValue_t StarTrackerHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { + if (mode != _MODE_START_UP) { return NOTHING_TO_SEND; + } + switch (startupState) { + case StartupState::CHECK_BOOT_STATE: + *id = StarTracker::REQ_VERSION; + startupState = StartupState::WAIT_FOR_EXECUTION; + return buildCommandFromCommand(*id, nullptr, 0); + case StartupState::BOOT: + *id = StarTracker::BOOT; + bootCountdown.setTimeout(BOOT_TIMEOUT); + startupState = StartupState::BOOT_DELAY; + return buildCommandFromCommand(*id, nullptr, 0); + case StartupState::LIMITS: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::LIMITS; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::TRACKING: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::TRACKING; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::MOUNTING: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::MOUNTING; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::CAMERA: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::CAMERA; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::BLOB: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::BLOB; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::CENTROIDING: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::CENTROIDING; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::LISA: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::LISA; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::MATCHING: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::MATCHING; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::VALIDATION: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::VALIDATION; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::ALGO: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::ALGO; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + default: + break; + } + return NOTHING_TO_SEND; } ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t * commandData, size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - switch (deviceCommand) { + const uint8_t* commandData, + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + switch (deviceCommand) { case (StarTracker::PING_REQUEST): { - preparePingRequest(); - return RETURN_OK; + preparePingRequest(); + return RETURN_OK; } case (StarTracker::REQ_TIME): { - prepareTimeRequest(); - return RETURN_OK; + prepareTimeRequest(); + return RETURN_OK; } case (StarTracker::BOOT): { - prepareBootCommand(); - return RETURN_OK; + prepareBootCommand(); + return RETURN_OK; } case (StarTracker::REQ_VERSION): { - prepareVersionRequest(); - return RETURN_OK; + prepareVersionRequest(); + return RETURN_OK; } case (StarTracker::REQ_INTERFACE): { - prepareInterfaceRequest(); - return RETURN_OK; + prepareInterfaceRequest(); + return RETURN_OK; } case (StarTracker::REQ_POWER): { - preparePowerRequest(); - return RETURN_OK; + preparePowerRequest(); + return RETURN_OK; } case (StarTracker::SWITCH_TO_BOOTLOADER_PROGRAM): { - prepareRebootCommand(); - return RETURN_OK; + prepareRebootCommand(); + return RETURN_OK; } case (StarTracker::TAKE_IMAGE): { - prepareTakeImageCommand(commandData); - return RETURN_OK; + prepareTakeImageCommand(commandData); + return RETURN_OK; } case (StarTracker::SUBSCRIBE_TO_TM): { - prepareSubscriptionCommand(commandData); - return RETURN_OK; + prepareSubscriptionCommand(commandData); + return RETURN_OK; } case (StarTracker::REQ_SOLUTION): { - prepareSolutionRequest(); - return RETURN_OK; + prepareSolutionRequest(); + return RETURN_OK; } case (StarTracker::REQ_TEMPERATURE): { - prepareTemperatureRequest(); - return RETURN_OK; + prepareTemperatureRequest(); + return RETURN_OK; } case (StarTracker::REQ_HISTOGRAM): { - prepareHistogramRequest(); - return RETURN_OK; + prepareHistogramRequest(); + return RETURN_OK; } case (StarTracker::REQ_CONTRAST): { - prepareContrastRequest(); - return RETURN_OK; + prepareContrastRequest(); + return RETURN_OK; } case (StarTracker::RESET_ERROR): { - prepareErrorResetRequest(); - return RETURN_OK; + prepareErrorResetRequest(); + return RETURN_OK; } case (StarTracker::LIMITS): { - Limits limits; - result = prepareParamCommand(commandData, commandDataLen, limits); - return result; + Limits limits; + result = prepareParamCommand(commandData, commandDataLen, limits); + return result; } case (StarTracker::MOUNTING): { - Mounting mounting; - result = prepareParamCommand(commandData, commandDataLen, mounting); - return result; + Mounting mounting; + result = prepareParamCommand(commandData, commandDataLen, mounting); + return result; } case (StarTracker::CAMERA): { - Camera camera; - result = prepareParamCommand(commandData, commandDataLen, camera); - return result; + Camera camera; + result = prepareParamCommand(commandData, commandDataLen, camera); + return result; } case (StarTracker::BLOB): { - Blob blob; - result = prepareParamCommand(commandData, commandDataLen, blob); - return result; + Blob blob; + result = prepareParamCommand(commandData, commandDataLen, blob); + return result; } case (StarTracker::CENTROIDING): { - Centroiding centroiding; - result = prepareParamCommand(commandData, commandDataLen, centroiding); - return result; + Centroiding centroiding; + result = prepareParamCommand(commandData, commandDataLen, centroiding); + return result; } case (StarTracker::LISA): { - Lisa lisa; - result = prepareParamCommand(commandData, commandDataLen, lisa); - return result; + Lisa lisa; + result = prepareParamCommand(commandData, commandDataLen, lisa); + return result; } case (StarTracker::MATCHING): { - Matching matching; - result = prepareParamCommand(commandData, commandDataLen, matching); - return result; + Matching matching; + result = prepareParamCommand(commandData, commandDataLen, matching); + return result; } case (StarTracker::VALIDATION): { - Validation validation; - result = prepareParamCommand(commandData, commandDataLen, validation); - return result; + Validation validation; + result = prepareParamCommand(commandData, commandDataLen, validation); + return result; } case (StarTracker::ALGO): { - Algo algo; - result = prepareParamCommand(commandData, commandDataLen, algo); - return result; + Algo algo; + result = prepareParamCommand(commandData, commandDataLen, algo); + return result; } case (StarTracker::TRACKING): { - Tracking tracking; - result = prepareParamCommand(commandData, commandDataLen, tracking); - return result; + Tracking tracking; + result = prepareParamCommand(commandData, commandDataLen, tracking); + return result; } case (StarTracker::ERASE): { - result = prepareEraseCommand(commandData, commandDataLen); - return result; + result = prepareEraseCommand(commandData, commandDataLen); + return result; } case (StarTracker::UNLOCK): { - result = prepareUnlockCommand(commandData, commandDataLen); - return result; + result = prepareUnlockCommand(commandData, commandDataLen); + return result; } case (StarTracker::CHECKSUM): { - result = prepareChecksumCommand(commandData, commandDataLen); - return result; + result = prepareChecksumCommand(commandData, commandDataLen); + return result; } case (StarTracker::SET_TIME): { - result = prepareSetTimeCommand(commandData, commandDataLen); - return result; + result = prepareSetTimeCommand(commandData, commandDataLen); + return result; } case (StarTracker::DOWNLOAD_CENTROID): { - result = prepareDownloadCentroidCommand(commandData, commandDataLen); - return result; + result = prepareDownloadCentroidCommand(commandData, commandDataLen); + return result; } case (StarTracker::UPLOAD_CENTROID): { - result = prepareUploadCentroidCommand(commandData, commandDataLen); - return result; + result = prepareUploadCentroidCommand(commandData, commandDataLen); + return result; } case (StarTracker::DOWNLOAD_MATCHED_STAR): { - result = prepareDownloadMatchedStarCommand(commandData, commandDataLen); - return result; + result = prepareDownloadMatchedStarCommand(commandData, commandDataLen); + return result; } case (StarTracker::DOWNLOAD_DBIMAGE): { - result = prepareDownloadDbImageCommand(commandData, commandDataLen); - return result; + result = prepareDownloadDbImageCommand(commandData, commandDataLen); + return result; } case (StarTracker::DOWNLOAD_BLOBPIXEL): { - result = prepareDownloadBlobPixelCommand(commandData, commandDataLen); - return result; + result = prepareDownloadBlobPixelCommand(commandData, commandDataLen); + return result; } case (StarTracker::FPGA_ACTION): { - result = prepareFpgaActionCommand(commandData, commandDataLen); - return result; + result = prepareFpgaActionCommand(commandData, commandDataLen); + return result; } default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } void StarTrackerHandler::fillCommandAndReplyMap() { - /** Reply lengths are unknown because of the slip encoding. Thus always maximum reply size - * is specified */ - this->insertInCommandAndReplyMap(StarTracker::PING_REQUEST, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandMap(StarTracker::BOOT); - this->insertInCommandAndReplyMap(StarTracker::REQ_VERSION, 3, &versionSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_TIME, 3, &timeSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandMap(StarTracker::UPLOAD_IMAGE); - this->insertInCommandMap(StarTracker::DOWNLOAD_IMAGE); - this->insertInCommandAndReplyMap(StarTracker::REQ_POWER, 3, &powerSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_INTERFACE, 3, &interfaceSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - // Reboot has no reply. Star tracker reboots immediately - this->insertInCommandMap(StarTracker::SWITCH_TO_BOOTLOADER_PROGRAM); - this->insertInCommandAndReplyMap(StarTracker::SUBSCRIBE_TO_TM, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_SOLUTION, 3, &solutionSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_TEMPERATURE, 3, &temperatureSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_HISTOGRAM, 3, &histogramSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_CONTRAST, 3, &contrastSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::LIMITS, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::MOUNTING, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::CAMERA, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::BLOB, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::CENTROIDING, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::LISA, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::MATCHING, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::TRACKING, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::VALIDATION, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::ALGO, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::TAKE_IMAGE, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::RESET_ERROR, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::ERASE, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::UNLOCK, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::CHECKSUM, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::SET_TIME, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_CENTROID, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::UPLOAD_CENTROID, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_MATCHED_STAR, 3, &downloadMatchedStar, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_DBIMAGE, 3, &downloadDbImage, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_BLOBPIXEL, 3, &downloadBlobPixel, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::FPGA_ACTION, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); + /** Reply lengths are unknown because of the slip encoding. Thus always maximum reply size + * is specified */ + this->insertInCommandAndReplyMap(StarTracker::PING_REQUEST, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandMap(StarTracker::BOOT); + this->insertInCommandAndReplyMap(StarTracker::REQ_VERSION, 3, &versionSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_TIME, 3, &timeSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandMap(StarTracker::UPLOAD_IMAGE); + this->insertInCommandMap(StarTracker::DOWNLOAD_IMAGE); + this->insertInCommandAndReplyMap(StarTracker::REQ_POWER, 3, &powerSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_INTERFACE, 3, &interfaceSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + // Reboot has no reply. Star tracker reboots immediately + this->insertInCommandMap(StarTracker::SWITCH_TO_BOOTLOADER_PROGRAM); + this->insertInCommandAndReplyMap(StarTracker::SUBSCRIBE_TO_TM, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_SOLUTION, 3, &solutionSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_TEMPERATURE, 3, &temperatureSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_HISTOGRAM, 3, &histogramSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_CONTRAST, 3, &contrastSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::LIMITS, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::MOUNTING, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::CAMERA, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::BLOB, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::CENTROIDING, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::LISA, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::MATCHING, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::TRACKING, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::VALIDATION, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::ALGO, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::TAKE_IMAGE, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::RESET_ERROR, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::ERASE, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::UNLOCK, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::CHECKSUM, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::SET_TIME, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_CENTROID, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::UPLOAD_CENTROID, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_MATCHED_STAR, 3, &downloadMatchedStar, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_DBIMAGE, 3, &downloadDbImage, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_BLOBPIXEL, 3, &downloadBlobPixel, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::FPGA_ACTION, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); } -ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t remainingSize, - DeviceCommandId_t *foundId, size_t *foundLen) { +ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + ReturnValue_t result = RETURN_OK; + size_t bytesLeft = 0; - ReturnValue_t result = RETURN_OK; - size_t bytesLeft = 0; - - result = dataLinkLayer.decodeFrame(start, remainingSize, &bytesLeft); - switch(result) { + result = dataLinkLayer.decodeFrame(start, remainingSize, &bytesLeft); + switch (result) { case ArcsecDatalinkLayer::DEC_IN_PROGRESS: { - remainingSize = bytesLeft; - // Need a second doSendRead pass to reaa in whole packet - return IGNORE_REPLY_DATA; + remainingSize = bytesLeft; + // Need a second doSendRead pass to reaa in whole packet + return IGNORE_REPLY_DATA; } case RETURN_OK: { - break; + break; } default: - remainingSize = bytesLeft; - return result; - } + remainingSize = bytesLeft; + return result; + } - switch (dataLinkLayer.getReplyFrameType()) { + switch (dataLinkLayer.getReplyFrameType()) { case TMTC_ACTIONREPLY: { - *foundLen = remainingSize - bytesLeft; - result = scanForActionReply(foundId); - break; + *foundLen = remainingSize - bytesLeft; + result = scanForActionReply(foundId); + break; } case TMTC_SETPARAMREPLY: { - *foundLen = remainingSize - bytesLeft; - result = scanForParameterReply(foundId); - break; + *foundLen = remainingSize - bytesLeft; + result = scanForParameterReply(foundId); + break; } case TMTC_TELEMETRYREPLYA: case TMTC_TELEMETRYREPLY: { - *foundLen = remainingSize - bytesLeft; - result = scanForTmReply(foundId); - break; + *foundLen = remainingSize - bytesLeft; + result = scanForTmReply(foundId); + break; } default: { - sif::debug << "StarTrackerHandler::scanForReply: Reply has invalid type id" << std::endl; - result = RETURN_FAILED; - } + sif::debug << "StarTrackerHandler::scanForReply: Reply has invalid type id" << std::endl; + result = RETURN_FAILED; } + } - remainingSize = bytesLeft; + remainingSize = bytesLeft; - return result; + return result; } -ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { +ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, + const uint8_t* packet) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; - - switch (id) { + switch (id) { case (StarTracker::SUBSCRIBE_TO_TM): { - result = handleSetParamReply(); - break; + result = handleSetParamReply(); + break; } case (StarTracker::REQ_TIME): { - result = handleTm(timeSet, StarTracker::TimeSet::SIZE); - break; + result = handleTm(timeSet, StarTracker::TimeSet::SIZE); + break; } case (StarTracker::PING_REQUEST): { - result = handlePingReply(); - break; + result = handlePingReply(); + break; } case (StarTracker::BOOT): case (StarTracker::TAKE_IMAGE): @@ -647,71 +655,71 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con case (StarTracker::UNLOCK): case (StarTracker::SET_TIME): case (StarTracker::FPGA_ACTION): { - result = handleActionReply(); - break; + result = handleActionReply(); + break; } case (StarTracker::DOWNLOAD_CENTROID): { - result = handleActionReplySet(downloadCentroidSet, StarTracker::DownloadCentroidSet::SIZE); - break; + result = handleActionReplySet(downloadCentroidSet, StarTracker::DownloadCentroidSet::SIZE); + break; } case (StarTracker::DOWNLOAD_MATCHED_STAR): { - result = handleActionReplySet(downloadMatchedStar, StarTracker::DownloadMatchedStar::SIZE); - break; + result = handleActionReplySet(downloadMatchedStar, StarTracker::DownloadMatchedStar::SIZE); + break; } case (StarTracker::DOWNLOAD_DBIMAGE): { - result = handleActionReplySet(downloadDbImage, StarTracker::DownloadDBImage::SIZE); - break; + result = handleActionReplySet(downloadDbImage, StarTracker::DownloadDBImage::SIZE); + break; } case (StarTracker::DOWNLOAD_BLOBPIXEL): { - result = handleActionReplySet(downloadBlobPixel, StarTracker::DownloadBlobPixel::SIZE); - break; + result = handleActionReplySet(downloadBlobPixel, StarTracker::DownloadBlobPixel::SIZE); + break; } case (StarTracker::UPLOAD_CENTROID): { - result = handleUploadCentroidReply(); - break; + result = handleUploadCentroidReply(); + break; } case (StarTracker::ERASE): { - result = handleEraseReply(); - break; + result = handleEraseReply(); + break; } case (StarTracker::CHECKSUM): { - result = handleChecksumReply(); - break; + result = handleChecksumReply(); + break; } case (StarTracker::REQ_VERSION): { - result = handleTm(versionSet, StarTracker::VersionSet::SIZE); - if (result != RETURN_OK) { - return result; - } - result = checkProgram(); - if (result != RETURN_OK) { - return result; - } - break; + result = handleTm(versionSet, StarTracker::VersionSet::SIZE); + if (result != RETURN_OK) { + return result; + } + result = checkProgram(); + if (result != RETURN_OK) { + return result; + } + break; } case (StarTracker::REQ_INTERFACE): { - result = handleTm(interfaceSet, StarTracker::InterfaceSet::SIZE); - break; + result = handleTm(interfaceSet, StarTracker::InterfaceSet::SIZE); + break; } case (StarTracker::REQ_POWER): { - result = handleTm(powerSet, StarTracker::PowerSet::SIZE); - break; + result = handleTm(powerSet, StarTracker::PowerSet::SIZE); + break; } case (StarTracker::REQ_SOLUTION): { - result = handleTm(solutionSet, StarTracker::SolutionSet::SIZE); - break; + result = handleTm(solutionSet, StarTracker::SolutionSet::SIZE); + break; } case (StarTracker::REQ_TEMPERATURE): { - result = handleTm(temperatureSet, StarTracker::TemperatureSet::SIZE); - break; + result = handleTm(temperatureSet, StarTracker::TemperatureSet::SIZE); + break; } case (StarTracker::REQ_HISTOGRAM): { - result = handleTm(histogramSet, StarTracker::HistogramSet::SIZE); - break; + result = handleTm(histogramSet, StarTracker::HistogramSet::SIZE); + break; } case (StarTracker::REQ_CONTRAST): { - result = handleTm(contrastSet, StarTracker::ContrastSet::SIZE); - break; + result = handleTm(contrastSet, StarTracker::ContrastSet::SIZE); + break; } case (StarTracker::LIMITS): case (StarTracker::MOUNTING): @@ -723,1227 +731,1217 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con case (StarTracker::TRACKING): case (StarTracker::VALIDATION): case (StarTracker::ALGO): { - result = handleSetParamReply(); - break; + result = handleSetParamReply(); + break; } default: { - sif::debug << "StarTrackerHandler::interpretDeviceReply: Unknown device reply id:" << id - << std::endl; - result = DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } + sif::debug << "StarTrackerHandler::interpretDeviceReply: Unknown device reply id:" << id + << std::endl; + result = DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; } + } - return result; + return result; } +void StarTrackerHandler::setNormalDatapoolEntriesInvalid() {} -void StarTrackerHandler::setNormalDatapoolEntriesInvalid() { - -} - -uint32_t StarTrackerHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { - return 20000; -} +uint32_t StarTrackerHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 20000; } ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { + LocalDataPoolManager& poolManager) { + localDataPoolMap.emplace(StarTracker::TICKS_TIME_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_TIME_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::RUN_TIME, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::UNIX_TIME, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_TIME_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_TIME_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::RUN_TIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::UNIX_TIME, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_VERSION_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_VERSION_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::PROGRAM, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MAJOR, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MINOR, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_VERSION_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_VERSION_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::PROGRAM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MAJOR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MINOR, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_INTERFACE_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_INTERFACE_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::FRAME_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CHECKSUM_ERROR_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::SET_PARAM_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::SET_PARAM_REPLY_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::PARAM_REQUEST_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::PARAM_REPLY_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::REQ_TM_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TM_REPLY_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::ACTION_REQ_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::ACTION_REPLY_COUNT, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_INTERFACE_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_INTERFACE_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::FRAME_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CHECKSUM_ERROR_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::SET_PARAM_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::SET_PARAM_REPLY_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::PARAM_REQUEST_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::PARAM_REPLY_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::REQ_TM_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TM_REPLY_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::ACTION_REQ_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::ACTION_REPLY_COUNT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_POWER_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_POWER_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MCU_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MCU_VOLTAGE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::FPGA_CORE_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::FPGA_CORE_VOLTAGE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::FPGA_18_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::FPGA_18_VOLTAGE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::FPGA_25_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::FPGA_25_VOLTAGE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_21_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_21_VOLTAGE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_PIX_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_PIX_VOLTAGE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_33_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_33_VOLTAGE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_RES_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_RES_VOLTAGE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_POWER_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_POWER_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MCU_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MCU_VOLTAGE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::FPGA_CORE_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::FPGA_CORE_VOLTAGE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::FPGA_18_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::FPGA_18_VOLTAGE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::FPGA_25_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::FPGA_25_VOLTAGE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_21_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_21_VOLTAGE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_PIX_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_PIX_VOLTAGE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_33_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_33_VOLTAGE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_RES_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_RES_VOLTAGE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_TEMPERATURE_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_TEMPERATURE_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MCU_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMOS_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_TEMPERATURE_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_TEMPERATURE_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MCU_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMOS_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_SOLUTION_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_SOLUTION_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CALI_QW, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CALI_QX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CALI_QY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CALI_QZ, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TRACK_CONFIDENCE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TRACK_QW, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TRACK_QX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TRACK_QY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TRACK_QZ, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TRACK_REMOVED, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::STARS_CENTROIDED, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::STARS_MATCHED_DATABASE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LISA_QW, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LISA_QX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LISA_QY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LISA_QZ, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LISA_PERC_CLOSE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LISA_NR_CLOSE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TRUST_WORTHY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::STABLE_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::SOLUTION_STRATEGY, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_SOLUTION_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_SOLUTION_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CALI_QW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CALI_QX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CALI_QY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CALI_QZ, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TRACK_CONFIDENCE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TRACK_QW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TRACK_QX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TRACK_QY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TRACK_QZ, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TRACK_REMOVED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::STARS_CENTROIDED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::STARS_MATCHED_DATABASE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LISA_QW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LISA_QX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LISA_QY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LISA_QZ, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LISA_PERC_CLOSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LISA_NR_CLOSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TRUST_WORTHY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::STABLE_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::SOLUTION_STRATEGY, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_HISTOGRAM_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_HISTOGRAM_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND8, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_HISTOGRAM_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_HISTOGRAM_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_CONTRAST_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_CONTRAST_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CHKSUM, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_CONTRAST_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_CONTRAST_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CHKSUM, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::DWL_ID, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_PIXX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_PIXY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_X_UNCORRECTED, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_Y_UNCORRECTED, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_X_CORRECTED, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_Y_CORRECTED, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_MAGNITUDE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_CXA, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_CYA, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_QUALITY, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::DWL_ID, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_PIXX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_PIXY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_X_UNCORRECTED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_Y_UNCORRECTED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_X_CORRECTED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_Y_CORRECTED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_MAGNITUDE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_CXA, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_CYA, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_QUALITY, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_ID, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMFPX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMFPY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTZ, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMMAGNITUDE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBFPX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBFPY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTZ, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBMAGNITUDE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CATALOGID, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_ID, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMFPX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMFPY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTZ, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMMAGNITUDE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBFPX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBFPY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTZ, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBMAGNITUDE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CATALOGID, new PoolEntry( { 0 })); - - localDataPoolMap.emplace(StarTracker::BLOBPIX_ID, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOBPIX_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOBPIX_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOBPIX_TOT_VAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOBPIX_IN_USE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOBPIX_BRIGHT_NEIGHBOURS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOBPIX_REGION, new PoolEntry( { 0 })); - return RETURN_OK; + localDataPoolMap.emplace(StarTracker::BLOBPIX_ID, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOBPIX_X, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOBPIX_Y, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOBPIX_TOT_VAL, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOBPIX_IN_USE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOBPIX_BRIGHT_NEIGHBOURS, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOBPIX_REGION, new PoolEntry({0})); + return RETURN_OK; } -size_t StarTrackerHandler::getNextReplyLength(DeviceCommandId_t commandId){ - return StarTracker::MAX_FRAME_SIZE; +size_t StarTrackerHandler::getNextReplyLength(DeviceCommandId_t commandId) { + return StarTracker::MAX_FRAME_SIZE; } ReturnValue_t StarTrackerHandler::doSendReadHook() { - // Prevent DHB from polling UART during commands executed by the image loader task - if(strHelperExecuting) { - return RETURN_FAILED; - } - return RETURN_OK; + // Prevent DHB from polling UART during commands executed by the image loader task + if (strHelperExecuting) { + return RETURN_FAILED; + } + return RETURN_OK; } ReturnValue_t StarTrackerHandler::checkMode(ActionId_t actionId) { - switch(actionId) { + switch (actionId) { case StarTracker::UPLOAD_IMAGE: case StarTracker::DOWNLOAD_IMAGE: { - return DeviceHandlerBase::acceptExternalDeviceCommands(); - default: + return DeviceHandlerBase::acceptExternalDeviceCommands(); + default: break; } - } - return RETURN_OK; + } + return RETURN_OK; } -ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t *foundId) { - const uint8_t* reply = dataLinkLayer.getReply(); - switch (*reply) { +ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t* foundId) { + const uint8_t* reply = dataLinkLayer.getReply(); + switch (*reply) { case (StarTracker::ID::PING): { - *foundId = StarTracker::PING_REQUEST; - break; + *foundId = StarTracker::PING_REQUEST; + break; } case (StarTracker::ID::WRITE): { - *foundId = StarTracker::WRITE; - break; + *foundId = StarTracker::WRITE; + break; } case (StarTracker::ID::BOOT): { - *foundId = StarTracker::BOOT; - break; + *foundId = StarTracker::BOOT; + break; } case (StarTracker::ID::TAKE_IMAGE): { - *foundId = StarTracker::TAKE_IMAGE; - break; + *foundId = StarTracker::TAKE_IMAGE; + break; } case (StarTracker::ID::UPLOAD_IMAGE): { - *foundId = StarTracker::UPLOAD_IMAGE; - break; + *foundId = StarTracker::UPLOAD_IMAGE; + break; } case (StarTracker::ID::ERROR_RESET): { - *foundId = StarTracker::RESET_ERROR; - break; + *foundId = StarTracker::RESET_ERROR; + break; } case (StarTracker::ID::ERASE): { - *foundId = StarTracker::ERASE; - break; + *foundId = StarTracker::ERASE; + break; } case (StarTracker::ID::UNLOCK): { - *foundId = StarTracker::UNLOCK; - break; + *foundId = StarTracker::UNLOCK; + break; } case (StarTracker::ID::CHECKSUM): { - *foundId = StarTracker::CHECKSUM; - break; + *foundId = StarTracker::CHECKSUM; + break; } case (StarTracker::ID::SET_TIME): { - *foundId = StarTracker::SET_TIME; - break; + *foundId = StarTracker::SET_TIME; + break; } case (StarTracker::ID::DOWNLOAD_CENTROID): { - *foundId = StarTracker::DOWNLOAD_CENTROID; - break; + *foundId = StarTracker::DOWNLOAD_CENTROID; + break; } case (StarTracker::ID::UPLOAD_CENTROID): { - *foundId = StarTracker::UPLOAD_CENTROID; - break; + *foundId = StarTracker::UPLOAD_CENTROID; + break; } case (StarTracker::ID::DOWNLOAD_MATCHED_STAR): { - *foundId = StarTracker::DOWNLOAD_MATCHED_STAR; - break; + *foundId = StarTracker::DOWNLOAD_MATCHED_STAR; + break; } case (StarTracker::ID::DOWNLOAD_DBIMAGE): { - *foundId = StarTracker::DOWNLOAD_DBIMAGE; - break; + *foundId = StarTracker::DOWNLOAD_DBIMAGE; + break; } case (StarTracker::ID::DOWNLOAD_BLOBPIXEL): { - *foundId = StarTracker::DOWNLOAD_BLOBPIXEL; - break; + *foundId = StarTracker::DOWNLOAD_BLOBPIXEL; + break; } case (StarTracker::ID::FPGA_ACTION): { - *foundId = StarTracker::FPGA_ACTION; - break; + *foundId = StarTracker::FPGA_ACTION; + break; } default: - sif::warning << "StarTrackerHandler::scanForParameterReply: Unknown parameter reply id" - << std::endl; - return RETURN_FAILED; - } - return RETURN_OK; + sif::warning << "StarTrackerHandler::scanForParameterReply: Unknown parameter reply id" + << std::endl; + return RETURN_FAILED; + } + return RETURN_OK; } -ReturnValue_t StarTrackerHandler::scanForParameterReply(DeviceCommandId_t *foundId) { - const uint8_t* reply = dataLinkLayer.getReply(); - switch (*reply) { +ReturnValue_t StarTrackerHandler::scanForParameterReply(DeviceCommandId_t* foundId) { + const uint8_t* reply = dataLinkLayer.getReply(); + switch (*reply) { case (StarTracker::ID::SUBSCRIBE): { - *foundId = StarTracker::SUBSCRIBE_TO_TM; - break; + *foundId = StarTracker::SUBSCRIBE_TO_TM; + break; } case (StarTracker::ID::LIMITS): { - *foundId = StarTracker::LIMITS; - break; + *foundId = StarTracker::LIMITS; + break; } case (StarTracker::ID::MOUNTING): { - *foundId = StarTracker::MOUNTING; - break; + *foundId = StarTracker::MOUNTING; + break; } case (StarTracker::ID::CAMERA): { - *foundId = StarTracker::CAMERA; - break; + *foundId = StarTracker::CAMERA; + break; } case (StarTracker::ID::BLOB): { - *foundId = StarTracker::BLOB; - break; + *foundId = StarTracker::BLOB; + break; } case (StarTracker::ID::CENTROIDING): { - *foundId = StarTracker::CENTROIDING; - break; + *foundId = StarTracker::CENTROIDING; + break; } case (StarTracker::ID::LISA): { - *foundId = StarTracker::LISA; - break; + *foundId = StarTracker::LISA; + break; } case (StarTracker::ID::MATCHING): { - *foundId = StarTracker::MATCHING; - break; + *foundId = StarTracker::MATCHING; + break; } case (StarTracker::ID::TRACKING): { - *foundId = StarTracker::TRACKING; - break; + *foundId = StarTracker::TRACKING; + break; } case (StarTracker::ID::VALIDATION): { - *foundId = StarTracker::VALIDATION; - break; + *foundId = StarTracker::VALIDATION; + break; } case (StarTracker::ID::ALGO): { - *foundId = StarTracker::ALGO; - break; + *foundId = StarTracker::ALGO; + break; } default: - sif::debug << "StarTrackerHandler::scanForParameterReply: Unknown parameter reply id" - << std::endl; - return RETURN_FAILED; - } - return RETURN_OK; + sif::debug << "StarTrackerHandler::scanForParameterReply: Unknown parameter reply id" + << std::endl; + return RETURN_FAILED; + } + return RETURN_OK; } -ReturnValue_t StarTrackerHandler::scanForTmReply(DeviceCommandId_t *foundId) { - const uint8_t* reply = dataLinkLayer.getReply(); - switch (*reply) { - case (StarTracker::ID::VERSION): { - *foundId = StarTracker::REQ_VERSION; - break; - } - case (StarTracker::ID::INTERFACE): { - *foundId = StarTracker::REQ_INTERFACE; - break; - } - case (StarTracker::ID::POWER): { - *foundId = StarTracker::REQ_POWER; - break; - } - case (StarTracker::ID::TEMPERATURE): { - *foundId = StarTracker::REQ_TEMPERATURE; - break; - } - case (StarTracker::ID::HISTOGRAM): { - *foundId = StarTracker::REQ_HISTOGRAM; - break; - } - case (StarTracker::ID::CONTRAST): { - *foundId = StarTracker::REQ_CONTRAST; - break; - } - case (StarTracker::ID::TIME): { - *foundId = StarTracker::REQ_TIME; - break; - } - case (StarTracker::ID::SOLUTION): { - *foundId = StarTracker::REQ_SOLUTION; - break; - } - default: { - sif::debug << "StarTrackerHandler::scanForTmReply: Reply contains invalid reply id" - << std::endl; - return RETURN_FAILED; - break; - } +ReturnValue_t StarTrackerHandler::scanForTmReply(DeviceCommandId_t* foundId) { + const uint8_t* reply = dataLinkLayer.getReply(); + switch (*reply) { + case (StarTracker::ID::VERSION): { + *foundId = StarTracker::REQ_VERSION; + break; } - return RETURN_OK; + case (StarTracker::ID::INTERFACE): { + *foundId = StarTracker::REQ_INTERFACE; + break; + } + case (StarTracker::ID::POWER): { + *foundId = StarTracker::REQ_POWER; + break; + } + case (StarTracker::ID::TEMPERATURE): { + *foundId = StarTracker::REQ_TEMPERATURE; + break; + } + case (StarTracker::ID::HISTOGRAM): { + *foundId = StarTracker::REQ_HISTOGRAM; + break; + } + case (StarTracker::ID::CONTRAST): { + *foundId = StarTracker::REQ_CONTRAST; + break; + } + case (StarTracker::ID::TIME): { + *foundId = StarTracker::REQ_TIME; + break; + } + case (StarTracker::ID::SOLUTION): { + *foundId = StarTracker::REQ_SOLUTION; + break; + } + default: { + sif::debug << "StarTrackerHandler::scanForTmReply: Reply contains invalid reply id" + << std::endl; + return RETURN_FAILED; + break; + } + } + return RETURN_OK; } void StarTrackerHandler::handleEvent(EventMessage* eventMessage) { - object_id_t objectId = eventMessage->getReporter(); - switch(objectId){ + object_id_t objectId = eventMessage->getReporter(); + switch (objectId) { case objects::STR_HELPER: { - // All events from image loader signal either that the operation was successful or that it - // failed - strHelperExecuting = false; - break; + // All events from image loader signal either that the operation was successful or that it + // failed + strHelperExecuting = false; + break; } default: - sif::debug << "StarTrackerHandler::handleEvent: Did not subscribe to this event" - << std::endl; - break; - } + sif::debug << "StarTrackerHandler::handleEvent: Did not subscribe to this event" << std::endl; + break; + } } ReturnValue_t StarTrackerHandler::executeWriteCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - if (commandDataLen < WriteCmd::MIN_LENGTH) { - sif::warning << "StarTrackerHandler::executeWriteCommand: Command too short" << std::endl; - return COMMAND_TOO_SHORT; - } - uint8_t region = *(commandData); - uint32_t address; - size_t size = sizeof(address); - const uint8_t* addressPtr = commandData + WriteCmd::ADDRESS_OFFSET; - result = SerializeAdapter::deSerialize(&address, addressPtr, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of address failed" - << std::endl; - return result; - } - if (commandDataLen - sizeof(address) - sizeof(region) > MAX_PATH_SIZE) { - sif::warning << "StarTrackerHandler::executeWriteCommand: Received command with invalid" - << " path and filename" << std::endl; - return FILE_PATH_TOO_LONG; - } - const uint8_t* filePtr = commandData + WriteCmd::FILE_OFFSET; - std::string fullname = std::string(reinterpret_cast(filePtr), - commandDataLen - sizeof(address) - sizeof(region)); - result = strHelper->startFlashWrite(fullname, region, address); - if (result != RETURN_OK) { - return result; - } + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + if (commandDataLen < WriteCmd::MIN_LENGTH) { + sif::warning << "StarTrackerHandler::executeWriteCommand: Command too short" << std::endl; + return COMMAND_TOO_SHORT; + } + uint8_t region = *(commandData); + uint32_t address; + size_t size = sizeof(address); + const uint8_t* addressPtr = commandData + WriteCmd::ADDRESS_OFFSET; + result = SerializeAdapter::deSerialize(&address, addressPtr, &size, SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of address failed" + << std::endl; return result; + } + if (commandDataLen - sizeof(address) - sizeof(region) > MAX_PATH_SIZE) { + sif::warning << "StarTrackerHandler::executeWriteCommand: Received command with invalid" + << " path and filename" << std::endl; + return FILE_PATH_TOO_LONG; + } + const uint8_t* filePtr = commandData + WriteCmd::FILE_OFFSET; + std::string fullname = std::string(reinterpret_cast(filePtr), + commandDataLen - sizeof(address) - sizeof(region)); + result = strHelper->startFlashWrite(fullname, region, address); + if (result != RETURN_OK) { + return result; + } + return result; } ReturnValue_t StarTrackerHandler::executeFpgaDownloadCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - if (commandDataLen < FpgaDownloadCmd::MIN_LENGTH) { - sif::warning << "StarTrackerHandler::executeFpgaDownloadCommand: Command too short" - << std::endl; - return COMMAND_TOO_SHORT; - } - uint32_t position; - size_t size = sizeof(position); - result = SerializeAdapter::deSerialize(&position, &commandData, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of position failed" - << std::endl; - return result; - } - uint32_t length; - size = sizeof(length); - result = SerializeAdapter::deSerialize(&length, &commandData, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of length failed" - << std::endl; - return result; - } - if (commandDataLen - sizeof(position) - sizeof(length) > MAX_PATH_SIZE) { - sif::warning << "StarTrackerHandler::executeFpgaDownloadCommand: Received command with " - " invalid path and filename" << std::endl; - return FILE_PATH_TOO_LONG; - } - std::string fullname = std::string(reinterpret_cast(commandData), - commandDataLen - sizeof(position) - sizeof(length)); - result = strHelper->startFpgaDownload(fullname, position, length); - if (result != RETURN_OK) { - return result; - } + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + if (commandDataLen < FpgaDownloadCmd::MIN_LENGTH) { + sif::warning << "StarTrackerHandler::executeFpgaDownloadCommand: Command too short" + << std::endl; + return COMMAND_TOO_SHORT; + } + uint32_t position; + size_t size = sizeof(position); + result = + SerializeAdapter::deSerialize(&position, &commandData, &size, SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of position failed" + << std::endl; return result; + } + uint32_t length; + size = sizeof(length); + result = + SerializeAdapter::deSerialize(&length, &commandData, &size, SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of length failed" + << std::endl; + return result; + } + if (commandDataLen - sizeof(position) - sizeof(length) > MAX_PATH_SIZE) { + sif::warning << "StarTrackerHandler::executeFpgaDownloadCommand: Received command with " + " invalid path and filename" + << std::endl; + return FILE_PATH_TOO_LONG; + } + std::string fullname = std::string(reinterpret_cast(commandData), + commandDataLen - sizeof(position) - sizeof(length)); + result = strHelper->startFpgaDownload(fullname, position, length); + if (result != RETURN_OK) { + return result; + } + return result; } ReturnValue_t StarTrackerHandler::executeReadCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - if (commandDataLen < ReadCmd::MIN_LENGTH) { - sif::warning << "StarTrackerHandler::executeReadCommand: Command too short" << std::endl; - return COMMAND_TOO_SHORT; - } - uint8_t region = *(commandData); - uint32_t address; - size_t size = sizeof(address); - const uint8_t* addressPtr = commandData + ReadCmd::ADDRESS_OFFSET; - result = SerializeAdapter::deSerialize(&address, addressPtr, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::executeReadCommand: Deserialization of address failed" - << std::endl; - return result; - } - uint32_t length; - size = sizeof(length); - const uint8_t* lengthPtr = commandData + ReadCmd::LENGTH_OFFSET; - result = SerializeAdapter::deSerialize(&length, lengthPtr, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::executeReadCommand: Deserialization of length failed" - << std::endl; - return result; - } - if (commandDataLen - sizeof(address) - sizeof(region) - sizeof(length) > MAX_PATH_SIZE) { - sif::warning << "StarTrackerHandler::executeReadCommand: Received command with invalid" - << " path and filename" << std::endl; - return FILE_PATH_TOO_LONG; - } - const uint8_t* filePtr = commandData + ReadCmd::FILE_OFFSET; - std::string fullname = std::string(reinterpret_cast(filePtr), - commandDataLen - sizeof(address) - sizeof(region) - sizeof(length)); - result = strHelper->startFlashRead(fullname, region, address, length); - if (result != RETURN_OK) { - return result; - } + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + if (commandDataLen < ReadCmd::MIN_LENGTH) { + sif::warning << "StarTrackerHandler::executeReadCommand: Command too short" << std::endl; + return COMMAND_TOO_SHORT; + } + uint8_t region = *(commandData); + uint32_t address; + size_t size = sizeof(address); + const uint8_t* addressPtr = commandData + ReadCmd::ADDRESS_OFFSET; + result = SerializeAdapter::deSerialize(&address, addressPtr, &size, SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::executeReadCommand: Deserialization of address failed" + << std::endl; return result; + } + uint32_t length; + size = sizeof(length); + const uint8_t* lengthPtr = commandData + ReadCmd::LENGTH_OFFSET; + result = SerializeAdapter::deSerialize(&length, lengthPtr, &size, SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::executeReadCommand: Deserialization of length failed" + << std::endl; + return result; + } + if (commandDataLen - sizeof(address) - sizeof(region) - sizeof(length) > MAX_PATH_SIZE) { + sif::warning << "StarTrackerHandler::executeReadCommand: Received command with invalid" + << " path and filename" << std::endl; + return FILE_PATH_TOO_LONG; + } + const uint8_t* filePtr = commandData + ReadCmd::FILE_OFFSET; + std::string fullname = + std::string(reinterpret_cast(filePtr), + commandDataLen - sizeof(address) - sizeof(region) - sizeof(length)); + result = strHelper->startFlashRead(fullname, region, address, length); + if (result != RETURN_OK) { + return result; + } + return result; } void StarTrackerHandler::prepareBootCommand() { - uint32_t length = 0; - struct BootActionRequest bootRequest = {BOOT_REGION_ID}; - arc_pack_boot_action_req(&bootRequest, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + struct BootActionRequest bootRequest = {BOOT_REGION_ID}; + arc_pack_boot_action_req(&bootRequest, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } ReturnValue_t StarTrackerHandler::prepareEraseCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - if (commandDataLen != EraseCmd::LENGTH) { - return INVALID_LENGTH; - } - uint32_t length = 0; - struct EraseActionRequest req; - req.region = *commandData; - arc_pack_erase_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - eraseCmd.rememberRegion = req.region; - return result; + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + if (commandDataLen != EraseCmd::LENGTH) { + return INVALID_LENGTH; + } + uint32_t length = 0; + struct EraseActionRequest req; + req.region = *commandData; + arc_pack_erase_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + eraseCmd.rememberRegion = req.region; + return result; } ReturnValue_t StarTrackerHandler::prepareUnlockCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - uint32_t length = 0; - struct UnlockActionRequest req; - req.region = *commandData; - size_t size = sizeof(req.code); - const uint8_t* codePtr = commandData + UnlockCmd::CODE_OFFSET; - result = SerializeAdapter::deSerialize(&req.code, &codePtr, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - return result; - } - arc_pack_unlock_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + uint32_t length = 0; + struct UnlockActionRequest req; + req.region = *commandData; + size_t size = sizeof(req.code); + const uint8_t* codePtr = commandData + UnlockCmd::CODE_OFFSET; + result = SerializeAdapter::deSerialize(&req.code, &codePtr, &size, SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { return result; + } + arc_pack_unlock_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return result; } ReturnValue_t StarTrackerHandler::prepareChecksumCommand(const uint8_t* commandData, - size_t commandDataLen) { - struct ChecksumActionRequest req; - ReturnValue_t result = RETURN_OK; - if (commandDataLen != ChecksumCmd::LENGTH) { - sif::warning << "StarTrackerHandler::prepareChecksumCommand: Invalid length" << std::endl; - return INVALID_LENGTH; - } - req.region = *(commandData); - size_t size = sizeof(req.address); - const uint8_t* addressPtr = commandData + ChecksumCmd::ADDRESS_OFFSET; - result = SerializeAdapter::deSerialize(&req.address, addressPtr, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::prepareChecksumCommand: Deserialization of address " - << "failed" << std::endl; - return result; - } - size = sizeof(req.length); - const uint8_t* lengthPtr = commandData + ChecksumCmd::LENGTH_OFFSET; - result = SerializeAdapter::deSerialize(&req.length, lengthPtr, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::prepareChecksumCommand: Deserialization of length failed" - << std::endl; - return result; - } - uint32_t rawCmdLength = 0; - arc_pack_checksum_action_req(&req, commandBuffer, &rawCmdLength); - dataLinkLayer.encodeFrame(commandBuffer, rawCmdLength); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - checksumCmd.rememberRegion = req.region; - checksumCmd.rememberAddress = req.address; - checksumCmd.rememberLength = req.length; + size_t commandDataLen) { + struct ChecksumActionRequest req; + ReturnValue_t result = RETURN_OK; + if (commandDataLen != ChecksumCmd::LENGTH) { + sif::warning << "StarTrackerHandler::prepareChecksumCommand: Invalid length" << std::endl; + return INVALID_LENGTH; + } + req.region = *(commandData); + size_t size = sizeof(req.address); + const uint8_t* addressPtr = commandData + ChecksumCmd::ADDRESS_OFFSET; + result = + SerializeAdapter::deSerialize(&req.address, addressPtr, &size, SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::prepareChecksumCommand: Deserialization of address " + << "failed" << std::endl; return result; + } + size = sizeof(req.length); + const uint8_t* lengthPtr = commandData + ChecksumCmd::LENGTH_OFFSET; + result = + SerializeAdapter::deSerialize(&req.length, lengthPtr, &size, SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::prepareChecksumCommand: Deserialization of length failed" + << std::endl; + return result; + } + uint32_t rawCmdLength = 0; + arc_pack_checksum_action_req(&req, commandBuffer, &rawCmdLength); + dataLinkLayer.encodeFrame(commandBuffer, rawCmdLength); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + checksumCmd.rememberRegion = req.region; + checksumCmd.rememberAddress = req.address; + checksumCmd.rememberLength = req.length; + return result; } - ReturnValue_t StarTrackerHandler::prepareSetTimeCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - struct SetTimeActionRequest req; - if (commandDataLen != SetTimeCmd::LENGTH) { - sif::warning << "StarTrackerHandler::prepareSetTimeCommand: Invalid length" << std::endl; - return INVALID_LENGTH; - } - size_t size = sizeof(req.unixTime); - result = SerializeAdapter::deSerialize(&req.unixTime, commandData, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::prepareSetTimeCommand: Deserialization failed" - << std::endl; - return result; - } - uint32_t length = 0; - arc_pack_settime_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + struct SetTimeActionRequest req; + if (commandDataLen != SetTimeCmd::LENGTH) { + sif::warning << "StarTrackerHandler::prepareSetTimeCommand: Invalid length" << std::endl; + return INVALID_LENGTH; + } + size_t size = sizeof(req.unixTime); + result = SerializeAdapter::deSerialize(&req.unixTime, commandData, &size, + SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::prepareSetTimeCommand: Deserialization failed" << std::endl; return result; + } + uint32_t length = 0; + arc_pack_settime_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return result; } ReturnValue_t StarTrackerHandler::prepareDownloadCentroidCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - struct DownloadCentroidActionRequest req; - if (commandDataLen != DownloadCentroidCmd::LENGTH) { - sif::warning << "StarTrackerHandler::prepareDownloadCentroidCommand: Invalid length" - << std::endl; - return INVALID_LENGTH; - } - req.id = *commandData; - uint32_t length = 0; - arc_pack_downloadcentroid_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return result; + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + struct DownloadCentroidActionRequest req; + if (commandDataLen != DownloadCentroidCmd::LENGTH) { + sif::warning << "StarTrackerHandler::prepareDownloadCentroidCommand: Invalid length" + << std::endl; + return INVALID_LENGTH; + } + req.id = *commandData; + uint32_t length = 0; + arc_pack_downloadcentroid_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return result; } ReturnValue_t StarTrackerHandler::prepareUploadCentroidCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen > MAX_PATH_SIZE) { - return FILE_PATH_TOO_LONG; - } - ReturnValue_t result = RETURN_OK; - struct UploadCentroidActionRequest req; - std::string jsonFileName = std::string(reinterpret_cast(commandData), - commandDataLen); - NVMParameterBase j(jsonFileName); - result = j.readJsonFile(); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: " << jsonFileName - << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::id, &req.id); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::id << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::pixx, &req.pixx); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::pixx << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::pixy, &req.pixy); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::pixy << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::x_uncorrected, &req.x_uncorrected); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::x_uncorrected << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::y_uncorrected, &req.y_uncorrected); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::y_uncorrected << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::x_corrected, &req.x_corrected); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::x_corrected << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::y_corrected, &req.y_corrected); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::y_corrected << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::magnitude, &req.magnitude); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::magnitude << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::cxa, &req.cxa); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::cxa << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::cya, &req.cya); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::cya << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::quality, &req.quality); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::quality << " does not exist" << std::endl; - return result; - } - uint32_t length = 0; - arc_pack_uploadcentroid_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - uploadCentroid.rememberId = req.id; + size_t commandDataLen) { + if (commandDataLen > MAX_PATH_SIZE) { + return FILE_PATH_TOO_LONG; + } + ReturnValue_t result = RETURN_OK; + struct UploadCentroidActionRequest req; + std::string jsonFileName = + std::string(reinterpret_cast(commandData), commandDataLen); + NVMParameterBase j(jsonFileName); + result = j.readJsonFile(); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: " << jsonFileName + << " does not exist" << std::endl; return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::id, &req.id); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::id << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::pixx, &req.pixx); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::pixx << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::pixy, &req.pixy); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::pixy << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::x_uncorrected, &req.x_uncorrected); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::x_uncorrected << " does not exist" + << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::y_uncorrected, &req.y_uncorrected); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::y_uncorrected << " does not exist" + << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::x_corrected, &req.x_corrected); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::x_corrected << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::y_corrected, &req.y_corrected); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::y_corrected << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::magnitude, &req.magnitude); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::magnitude << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::cxa, &req.cxa); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::cxa << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::cya, &req.cya); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::cya << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::quality, &req.quality); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::quality << " does not exist" << std::endl; + return result; + } + uint32_t length = 0; + arc_pack_uploadcentroid_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + uploadCentroid.rememberId = req.id; + return result; } void StarTrackerHandler::prepareTimeRequest() { - uint32_t length = 0; - arc_tm_pack_time_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_time_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::preparePingRequest() { - uint32_t length = 0; - struct PingActionRequest pingRequest = {PING_ID}; - arc_pack_ping_action_req(&pingRequest, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + struct PingActionRequest pingRequest = {PING_ID}; + arc_pack_ping_action_req(&pingRequest, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareVersionRequest() { - uint32_t length = 0; - arc_tm_pack_version_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_version_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareInterfaceRequest() { - uint32_t length = 0; - arc_tm_pack_interface_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_interface_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::preparePowerRequest() { - uint32_t length = 0; - arc_tm_pack_power_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_power_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareRebootCommand() { - uint32_t length = 0; - struct RebootActionRequest rebootReq; - arc_pack_reboot_action_req(&rebootReq, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + struct RebootActionRequest rebootReq; + arc_pack_reboot_action_req(&rebootReq, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareTakeImageCommand(const uint8_t* commandData) { - uint32_t length = 0; - struct CameraActionRequest camReq; - camReq.actionid = *commandData; - arc_pack_camera_action_req(&camReq, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + struct CameraActionRequest camReq; + camReq.actionid = *commandData; + arc_pack_camera_action_req(&camReq, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareSubscriptionCommand(const uint8_t* tmId) { - uint32_t length = 18; - commandBuffer[0] = TMTC_SETPARAMREQ; - commandBuffer[1] = StarTracker::ID::SUBSCRIBE; - // Fill all other fields with invalid tm id - commandBuffer[2] = *tmId; - commandBuffer[3] = 0; - commandBuffer[4] = 0; - commandBuffer[5] = 0; - commandBuffer[6] = 0; - commandBuffer[7] = 0; - commandBuffer[8] = 0; - commandBuffer[9] = 0; - commandBuffer[10] = 0; - commandBuffer[11] = 0; - commandBuffer[12] = 0; - commandBuffer[13] = 0; - commandBuffer[14] = 0; - commandBuffer[15] = 0; - commandBuffer[16] = 0; - commandBuffer[17] = 0; - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 18; + commandBuffer[0] = TMTC_SETPARAMREQ; + commandBuffer[1] = StarTracker::ID::SUBSCRIBE; + // Fill all other fields with invalid tm id + commandBuffer[2] = *tmId; + commandBuffer[3] = 0; + commandBuffer[4] = 0; + commandBuffer[5] = 0; + commandBuffer[6] = 0; + commandBuffer[7] = 0; + commandBuffer[8] = 0; + commandBuffer[9] = 0; + commandBuffer[10] = 0; + commandBuffer[11] = 0; + commandBuffer[12] = 0; + commandBuffer[13] = 0; + commandBuffer[14] = 0; + commandBuffer[15] = 0; + commandBuffer[16] = 0; + commandBuffer[17] = 0; + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareSolutionRequest() { - uint32_t length = 0; - arc_tm_pack_solution_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_solution_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareTemperatureRequest() { - uint32_t length = 0; - arc_tm_pack_temperature_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_temperature_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareHistogramRequest() { - uint32_t length = 0; - arc_tm_pack_histogram_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_histogram_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareContrastRequest() { - uint32_t length = 0; - arc_tm_pack_contrast_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_contrast_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareErrorResetRequest() { - uint32_t length = 0; - struct ResetErrorSignalActionRequest req; - arc_pack_reseterrorsignal_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + struct ResetErrorSignalActionRequest req; + arc_pack_reseterrorsignal_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } ReturnValue_t StarTrackerHandler::prepareParamCommand(const uint8_t* commandData, - size_t commandDataLen, ArcsecJsonParamBase& paramSet) { - ReturnValue_t result = RETURN_OK; - if (commandDataLen > MAX_PATH_SIZE) { - return FILE_PATH_TOO_LONG; - } - std::string fullName(reinterpret_cast(commandData), commandDataLen); + size_t commandDataLen, + ArcsecJsonParamBase& paramSet) { + ReturnValue_t result = RETURN_OK; + if (commandDataLen > MAX_PATH_SIZE) { + return FILE_PATH_TOO_LONG; + } + std::string fullName(reinterpret_cast(commandData), commandDataLen); - result = paramSet.create(fullName, commandBuffer); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareParamCommand: Failed to create parameter " - "command" << std::endl; - return result; - } - dataLinkLayer.encodeFrame(commandBuffer, paramSet.getSize()); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; + result = paramSet.create(fullName, commandBuffer); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareParamCommand: Failed to create parameter " + "command" + << std::endl; + return result; + } + dataLinkLayer.encodeFrame(commandBuffer, paramSet.getSize()); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; } ReturnValue_t StarTrackerHandler::prepareDownloadMatchedStarCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen != DownloadMatchedStarCmd::LENGTH) { - return INVALID_LENGTH; - } - struct DownloadMatchedStarActionRequest req; - req.id = *commandData; - uint32_t length = 0; - arc_pack_downloadmatchedstar_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; + size_t commandDataLen) { + if (commandDataLen != DownloadMatchedStarCmd::LENGTH) { + return INVALID_LENGTH; + } + struct DownloadMatchedStarActionRequest req; + req.id = *commandData; + uint32_t length = 0; + arc_pack_downloadmatchedstar_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; } ReturnValue_t StarTrackerHandler::prepareDownloadDbImageCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen != DownloadDbImageCmd::LENGTH) { - return INVALID_LENGTH; - } - struct DownloadDBImageActionRequest req; - req.id = *commandData; - uint32_t length = 0; - arc_pack_downloaddbimage_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; + size_t commandDataLen) { + if (commandDataLen != DownloadDbImageCmd::LENGTH) { + return INVALID_LENGTH; + } + struct DownloadDBImageActionRequest req; + req.id = *commandData; + uint32_t length = 0; + arc_pack_downloaddbimage_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; } ReturnValue_t StarTrackerHandler::prepareDownloadBlobPixelCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen != DownloadBlobPixCmd::LENGTH) { - return INVALID_LENGTH; - } - struct DownloadBlobPixelActionRequest req; - req.id = *commandData; - req.type = *(commandData + 1); - if ((req.type != DownloadBlobPixCmd::NORMAL) && (req.type != DownloadBlobPixCmd::FAST)) { - return INVALID_TYPE; - } - uint32_t length = 0; - arc_pack_downloadblobpixel_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; + size_t commandDataLen) { + if (commandDataLen != DownloadBlobPixCmd::LENGTH) { + return INVALID_LENGTH; + } + struct DownloadBlobPixelActionRequest req; + req.id = *commandData; + req.type = *(commandData + 1); + if ((req.type != DownloadBlobPixCmd::NORMAL) && (req.type != DownloadBlobPixCmd::FAST)) { + return INVALID_TYPE; + } + uint32_t length = 0; + arc_pack_downloadblobpixel_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; } ReturnValue_t StarTrackerHandler::prepareFpgaActionCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen != FpgaActionCmd::LENGTH) { - return INVALID_LENGTH; - } - struct FPGAActionActionRequest req; - req.id = *commandData; - if (req.id != FpgaActionCmd::ID) { - return INVALID_ID; - } - uint32_t length = 0; - arc_pack_fpgaaction_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; + size_t commandDataLen) { + if (commandDataLen != FpgaActionCmd::LENGTH) { + return INVALID_LENGTH; + } + struct FPGAActionActionRequest req; + req.id = *commandData; + if (req.id != FpgaActionCmd::ID) { + return INVALID_ID; + } + uint32_t length = 0; + arc_pack_fpgaaction_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; } ReturnValue_t StarTrackerHandler::handleSetParamReply() { - const uint8_t* reply = dataLinkLayer.getReply(); - uint8_t status = *(reply + STATUS_OFFSET); - if (status != StarTracker::STATUS_OK) { - sif::warning << "StarTrackerHandler::handleSetParamReply: Failed to execute parameter set " - " command with parameter ID" << - static_cast(*(reply + PARAMETER_ID_OFFSET)) << std::endl; - if (startupState != StartupState::IDLE) { - startupState = StartupState::IDLE; - } - return SET_PARAM_FAILED; - } + const uint8_t* reply = dataLinkLayer.getReply(); + uint8_t status = *(reply + STATUS_OFFSET); + if (status != StarTracker::STATUS_OK) { + sif::warning << "StarTrackerHandler::handleSetParamReply: Failed to execute parameter set " + " command with parameter ID" + << static_cast(*(reply + PARAMETER_ID_OFFSET)) << std::endl; if (startupState != StartupState::IDLE) { - handleStartup(reply + PARAMETER_ID_OFFSET); + startupState = StartupState::IDLE; } - return RETURN_OK; + return SET_PARAM_FAILED; + } + if (startupState != StartupState::IDLE) { + handleStartup(reply + PARAMETER_ID_OFFSET); + } + return RETURN_OK; } ReturnValue_t StarTrackerHandler::handleActionReply() { - const uint8_t* reply = dataLinkLayer.getReply(); - uint8_t status = *(reply + STATUS_OFFSET); - if (status != StarTracker::STATUS_OK) { - sif::warning << "StarTrackerHandler::handleActionReply: Failed to execute action " - << "command with action ID " - << static_cast(*(reply + ACTION_ID_OFFSET)) - << " and status "<< static_cast(status) << std::endl; - return ACTION_FAILED; - } - return RETURN_OK; + const uint8_t* reply = dataLinkLayer.getReply(); + uint8_t status = *(reply + STATUS_OFFSET); + if (status != StarTracker::STATUS_OK) { + sif::warning << "StarTrackerHandler::handleActionReply: Failed to execute action " + << "command with action ID " + << static_cast(*(reply + ACTION_ID_OFFSET)) << " and status " + << static_cast(status) << std::endl; + return ACTION_FAILED; + } + return RETURN_OK; } ReturnValue_t StarTrackerHandler::handleUploadCentroidReply() { - ReturnValue_t result = RETURN_OK; - result = handleActionReply(); - if (result != RETURN_OK) { - return result; - } - const uint8_t* reply = dataLinkLayer.getReply(); - if (*(reply + ACTION_DATA_OFFSET) != uploadCentroid.rememberId) { - return UPLOAD_CENTROID_ID_MISMATCH; - } - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + result = handleActionReply(); + if (result != RETURN_OK) { + return result; + } + const uint8_t* reply = dataLinkLayer.getReply(); + if (*(reply + ACTION_DATA_OFFSET) != uploadCentroid.rememberId) { + return UPLOAD_CENTROID_ID_MISMATCH; + } + return RETURN_OK; } ReturnValue_t StarTrackerHandler::handleEraseReply() { - ReturnValue_t result = RETURN_OK; - result = handleActionReply(); - if (result != RETURN_OK) { - return result; - } - const uint8_t* replyData = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; - StarTracker::EraseReply eraseReply(replyData); - if (eraseReply.getRegion() != eraseCmd.rememberRegion) { - sif::warning << "StarTrackerHandler::handleEraseReply: Region mismatch" << std::endl; - return REGION_MISMATCH; - } + ReturnValue_t result = RETURN_OK; + result = handleActionReply(); + if (result != RETURN_OK) { return result; + } + const uint8_t* replyData = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; + StarTracker::EraseReply eraseReply(replyData); + if (eraseReply.getRegion() != eraseCmd.rememberRegion) { + sif::warning << "StarTrackerHandler::handleEraseReply: Region mismatch" << std::endl; + return REGION_MISMATCH; + } + return result; } ReturnValue_t StarTrackerHandler::handleChecksumReply() { - ReturnValue_t result = RETURN_OK; - result = handleActionReply(); - if (result != RETURN_OK) { - return result; - } - const uint8_t* replyData = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; - StarTracker::ChecksumReply checksumReply(replyData); - if (checksumReply.getRegion() != checksumCmd.rememberRegion) { - sif::warning << "StarTrackerHandler::handleChecksumReply: Region mismatch" << std::endl; - return REGION_MISMATCH; - } - if (checksumReply.getAddress() != checksumCmd.rememberAddress) { - sif::warning << "StarTrackerHandler::handleChecksumReply: Address mismatch" << std::endl; - return ADDRESS_MISMATCH; - } - if (checksumReply.getLength() != checksumCmd.rememberLength) { - sif::warning << "StarTrackerHandler::handleChecksumReply: Length mismatch" << std::endl; - return LENGTH_MISSMATCH; - } - PoolReadGuard rg(&checksumSet); - checksumSet.checksum = checksumReply.getChecksum(); - handleDeviceTM(&checksumSet, StarTracker::CHECKSUM); + ReturnValue_t result = RETURN_OK; + result = handleActionReply(); + if (result != RETURN_OK) { + return result; + } + const uint8_t* replyData = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; + StarTracker::ChecksumReply checksumReply(replyData); + if (checksumReply.getRegion() != checksumCmd.rememberRegion) { + sif::warning << "StarTrackerHandler::handleChecksumReply: Region mismatch" << std::endl; + return REGION_MISMATCH; + } + if (checksumReply.getAddress() != checksumCmd.rememberAddress) { + sif::warning << "StarTrackerHandler::handleChecksumReply: Address mismatch" << std::endl; + return ADDRESS_MISMATCH; + } + if (checksumReply.getLength() != checksumCmd.rememberLength) { + sif::warning << "StarTrackerHandler::handleChecksumReply: Length mismatch" << std::endl; + return LENGTH_MISSMATCH; + } + PoolReadGuard rg(&checksumSet); + checksumSet.checksum = checksumReply.getChecksum(); + handleDeviceTM(&checksumSet, StarTracker::CHECKSUM); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - checksumReply.printChecksum(); + checksumReply.printChecksum(); #endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ - return RETURN_OK; + return RETURN_OK; } ReturnValue_t StarTrackerHandler::handlePingReply() { - ReturnValue_t result = RETURN_OK; - uint32_t pingId = 0; - const uint8_t* reply = dataLinkLayer.getReply(); - uint8_t status = dataLinkLayer.getStatusField(); - const uint8_t* buffer = reply + ACTION_DATA_OFFSET; - size_t size = sizeof(pingId); - SerializeAdapter::deSerialize(&pingId, &buffer, &size, SerializeIF::Endianness::LITTLE); + ReturnValue_t result = RETURN_OK; + uint32_t pingId = 0; + const uint8_t* reply = dataLinkLayer.getReply(); + uint8_t status = dataLinkLayer.getStatusField(); + const uint8_t* buffer = reply + ACTION_DATA_OFFSET; + size_t size = sizeof(pingId); + SerializeAdapter::deSerialize(&pingId, &buffer, &size, SerializeIF::Endianness::LITTLE); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - sif::info << "StarTracker: Ping status: "<< static_cast(status) << std::endl; - sif::info << "Ping id: 0x"<< std::hex << pingId << std::endl; + sif::info << "StarTracker: Ping status: " << static_cast(status) << std::endl; + sif::info << "Ping id: 0x" << std::hex << pingId << std::endl; #endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ - if (status != StarTracker::STATUS_OK || pingId != PING_ID) { - sif::warning << "StarTrackerHandler::handlePingReply: Ping failed" << std::endl; - result = PING_FAILED; - } - else { + if (status != StarTracker::STATUS_OK || pingId != PING_ID) { + sif::warning << "StarTrackerHandler::handlePingReply: Ping failed" << std::endl; + result = PING_FAILED; + } else { #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - sif::info << "StarTracker: Ping successful" << std::endl; + sif::info << "StarTracker: Ping successful" << std::endl; #endif - } - return result; + } + return result; } ReturnValue_t StarTrackerHandler::checkProgram() { - PoolReadGuard pg(&versionSet); - switch(versionSet.program.value) { + PoolReadGuard pg(&versionSet); + switch (versionSet.program.value) { case StarTracker::Program::BOOTLOADER: - // Star tracker currently in bootloader program. Need to send boot command to switch to - // firmware program - if (startupState != StartupState::IDLE) { - startupState = StartupState::BOOT; - } - break; + // Star tracker currently in bootloader program. Need to send boot command to switch to + // firmware program + if (startupState != StartupState::IDLE) { + startupState = StartupState::BOOT; + } + break; case StarTracker::Program::FIRMWARE: - // Firmware already booted - if (startupState != StartupState::IDLE) { - startupState = StartupState::LIMITS; - } - break; + // Firmware already booted + if (startupState != StartupState::IDLE) { + startupState = StartupState::LIMITS; + } + break; default: - sif::warning << "StarTrackerHandler::checkProgram: Version set has invalid program ID" - << std::endl; - return INVALID_PROGRAM; - } - return RETURN_OK; + sif::warning << "StarTrackerHandler::checkProgram: Version set has invalid program ID" + << std::endl; + return INVALID_PROGRAM; + } + return RETURN_OK; } ReturnValue_t StarTrackerHandler::handleTm(LocalPoolDataSetBase& dataset, size_t size) { - ReturnValue_t result = RETURN_OK; - uint8_t status = *(dataLinkLayer.getReply() + STATUS_OFFSET); - if(status != StarTracker::STATUS_OK) { - sif::warning << "StarTrackerHandler::handleTm: Reply error: " - << static_cast(status) << std::endl; - return REPLY_ERROR; - } - result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } - const uint8_t* reply = dataLinkLayer.getReply() + TICKS_OFFSET; - dataset.setValidityBufferGeneration(false); - result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::handleTm: Deserialization failed" - << std::endl; - } - dataset.setValidityBufferGeneration(true); - dataset.setValidity(true, true); - result = dataset.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - dataset.printSet(); -#endif + ReturnValue_t result = RETURN_OK; + uint8_t status = *(dataLinkLayer.getReply() + STATUS_OFFSET); + if (status != StarTracker::STATUS_OK) { + sif::warning << "StarTrackerHandler::handleTm: Reply error: " + << static_cast(status) << std::endl; + return REPLY_ERROR; + } + result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { return result; + } + const uint8_t* reply = dataLinkLayer.getReply() + TICKS_OFFSET; + dataset.setValidityBufferGeneration(false); + result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::handleTm: Deserialization failed" << std::endl; + } + dataset.setValidityBufferGeneration(true); + dataset.setValidity(true, true); + result = dataset.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { + return result; + } +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 + dataset.printSet(); +#endif + return result; } ReturnValue_t StarTrackerHandler::handleActionReplySet(LocalPoolDataSetBase& dataset, size_t size) { - ReturnValue_t result = RETURN_OK; - uint8_t status = *(dataLinkLayer.getReply() + STATUS_OFFSET); - if(status != StarTracker::STATUS_OK) { - sif::warning << "StarTrackerHandler::handleActionReplySet: Reply error: " - << static_cast(status) << std::endl; - return REPLY_ERROR; - } - result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } - const uint8_t* reply = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; - dataset.setValidityBufferGeneration(false); - result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::handleActionReplySet Deserialization failed" - << std::endl; - } - dataset.setValidityBufferGeneration(true); - dataset.setValidity(true, true); - result = dataset.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - dataset.printSet(); -#endif + ReturnValue_t result = RETURN_OK; + uint8_t status = *(dataLinkLayer.getReply() + STATUS_OFFSET); + if (status != StarTracker::STATUS_OK) { + sif::warning << "StarTrackerHandler::handleActionReplySet: Reply error: " + << static_cast(status) << std::endl; + return REPLY_ERROR; + } + result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { return result; + } + const uint8_t* reply = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; + dataset.setValidityBufferGeneration(false); + result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::handleActionReplySet Deserialization failed" << std::endl; + } + dataset.setValidityBufferGeneration(true); + dataset.setValidity(true, true); + result = dataset.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { + return result; + } +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 + dataset.printSet(); +#endif + return result; } void StarTrackerHandler::handleStartup(const uint8_t* parameterId) { - switch(*parameterId) { + switch (*parameterId) { case (StarTracker::ID::LIMITS): { - startupState = StartupState::TRACKING; - break; + startupState = StartupState::TRACKING; + break; } case (StarTracker::ID::TRACKING): { - startupState = StartupState::MOUNTING; - break; + startupState = StartupState::MOUNTING; + break; } case (StarTracker::ID::MOUNTING): { - startupState = StartupState::CAMERA; - break; + startupState = StartupState::CAMERA; + break; } case (StarTracker::ID::CAMERA): { - startupState = StartupState::BLOB; - break; + startupState = StartupState::BLOB; + break; } case (StarTracker::ID::BLOB): { - startupState = StartupState::CENTROIDING; - break; + startupState = StartupState::CENTROIDING; + break; } case (StarTracker::ID::CENTROIDING): { - startupState = StartupState::LISA; - break; + startupState = StartupState::LISA; + break; } case (StarTracker::ID::LISA): { - startupState = StartupState::MATCHING; - break; + startupState = StartupState::MATCHING; + break; } case (StarTracker::ID::MATCHING): { - startupState = StartupState::VALIDATION; - break; + startupState = StartupState::VALIDATION; + break; } case (StarTracker::ID::VALIDATION): { - startupState = StartupState::ALGO; - break; + startupState = StartupState::ALGO; + break; } case (StarTracker::ID::ALGO): { - startupState = StartupState::DONE; - break; + startupState = StartupState::DONE; + break; } default: { - sif::debug << "StarTrackerHandler::handleStartup: Received parameter reply with unexpected" - << " parameter ID" << std::endl; - break; - } + sif::debug << "StarTrackerHandler::handleStartup: Received parameter reply with unexpected" + << " parameter ID" << std::endl; + break; } + } } diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.h b/bsp_q7s/devices/startracker/StarTrackerHandler.h index 65bd65b8..1d7efeb3 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.h +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.h @@ -1,15 +1,16 @@ #ifndef MISSION_DEVICES_STARTRACKERHANDLER_H_ #define MISSION_DEVICES_STARTRACKERHANDLER_H_ +#include + +#include "ArcsecDatalinkLayer.h" +#include "ArcsecJsonParamBase.h" +#include "StarTrackerDefinitions.h" +#include "StrHelper.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" #include "fsfw/src/fsfw/serialize/SerializeAdapter.h" #include "fsfw/timemanager/Countdown.h" #include "thirdparty/arcsec_star_tracker/common/SLIP.h" -#include -#include "ArcsecDatalinkLayer.h" -#include "StarTrackerDefinitions.h" -#include "ArcsecJsonParamBase.h" -#include "StrHelper.h" /** * @brief This is the device handler for the star tracker from arcsec. @@ -19,530 +20,524 @@ * Sagitta%201.0%20Datapack&fileid=659181 * @author J. Meier */ -class StarTrackerHandler: public DeviceHandlerBase { -public: - - /** - * @brief Constructor - * - * @param objectId - * @param comIF - * @param comCookie - * @param gpioComIF Pointer to gpio communication interface - * @param enablePin GPIO connected to the enable pin of the reaction wheels. Must be pulled - * to high to enable the device. - */ - StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie, - StrHelper* strHelper); - virtual ~StarTrackerHandler(); - - ReturnValue_t initialize() override; - - /** - * @brief Overwrite this function from DHB to handle commands executed by the str image - * loader task. - */ - ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size) override; - - void performOperationHook() override; - -protected: - void doStartUp() override; - void doShutDown() override; - void doOffActivity() 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; - /** - * @brief Overwritten here to always read all available data from the UartComIF. - */ - virtual size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override; - virtual ReturnValue_t doSendReadHook() override; - -private: - - static const uint8_t INTERFACE_ID = CLASS_ID::STR_HANDLER; - - //! [EXPORT] : [COMMENT] Received reply is too short - static const ReturnValue_t REPLY_TOO_SHORT = MAKE_RETURN_CODE(0xB0); - //! [EXPORT] : [COMMENT] Received reply with invalid CRC - static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xB1); - //! [EXPORT] : [COMMENT] Image loader executing - static const ReturnValue_t IMAGE_LOADER_EXECUTING = MAKE_RETURN_CODE(0xB2); - - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_HANDLER; - - //! [EXPORT] : [COMMENT] Status in temperature reply signals error - static const ReturnValue_t TEMPERATURE_REQ_FAILED = MAKE_RETURN_CODE(0xA0); - //! [EXPORT] : [COMMENT] Ping command failed - static const ReturnValue_t PING_FAILED = MAKE_RETURN_CODE(0xA1); - //! [EXPORT] : [COMMENT] Status in version reply signals error - static const ReturnValue_t VERSION_REQ_FAILED = MAKE_RETURN_CODE(0xA3); - //! [EXPORT] : [COMMENT] Status in interface reply signals error - static const ReturnValue_t INTERFACE_REQ_FAILED = MAKE_RETURN_CODE(0xA4); - //! [EXPORT] : [COMMENT] Status in power reply signals error - static const ReturnValue_t POWER_REQ_FAILED = MAKE_RETURN_CODE(0xA5); - //! [EXPORT] : [COMMENT] Status of reply to parameter set command signals error - static const ReturnValue_t SET_PARAM_FAILED = MAKE_RETURN_CODE(0xA6); - //! [EXPORT] : [COMMENT] Status of reply to action command signals error - static const ReturnValue_t ACTION_FAILED = MAKE_RETURN_CODE(0xA7); - //! [EXPORT] : [COMMENT] Received upload image command with invalid length - static const ReturnValue_t UPLOAD_TOO_SHORT = MAKE_RETURN_CODE(0xA8); - //! [EXPORT] : [COMMENT] Received upload image command with invalid position field - static const ReturnValue_t UPLOAD_INVALID_POSITION = MAKE_RETURN_CODE(0xA8); - //! [EXPORT] : [COMMENT] Position value in upload image reply not matching sent position - static const ReturnValue_t UPLOAD_IMAGE_FAILED = MAKE_RETURN_CODE(0xA9); - //! [EXPORT] : [COMMENT] Received upload image command with invalid length - static const ReturnValue_t INVALID_UPLOAD_COMMAND = MAKE_RETURN_CODE(0xAA); - //! [EXPORT] : [COMMENT] Received invalid path string. Exceeds allowed length - static const ReturnValue_t FILE_PATH_TOO_LONG = MAKE_RETURN_CODE(0xAB); - //! [EXPORT] : [COMMENT] Name of file received with command is too long - static const ReturnValue_t FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xAC); - //! [EXPORT] : [COMMENT] Received version reply with invalid program ID - static const ReturnValue_t INVALID_PROGRAM = MAKE_RETURN_CODE(0xAD); - //! [EXPORT] : [COMMENT] Status field reply signals error - static const ReturnValue_t REPLY_ERROR = MAKE_RETURN_CODE(0xAE); - //! [EXPORT] : [COMMENT] Status field of contrast reply signals error - static const ReturnValue_t CONTRAST_REQ_FAILED = MAKE_RETURN_CODE(0xAE); - //! [EXPORT] : [COMMENT] Received command which is too short (some data is missing for proper execution) - static const ReturnValue_t COMMAND_TOO_SHORT = MAKE_RETURN_CODE(0xAF); - //! [EXPORT] : [COMMENT] Received command with invalid length (too few or too many parameters) - static const ReturnValue_t INVALID_LENGTH = MAKE_RETURN_CODE(0xB0); - //! [EXPORT] : [COMMENT] Region mismatch between send and received data - static const ReturnValue_t REGION_MISMATCH = MAKE_RETURN_CODE(0xB1); - //! [EXPORT] : [COMMENT] Address mismatch between send and received data - static const ReturnValue_t ADDRESS_MISMATCH = MAKE_RETURN_CODE(0xB2); - //! [EXPORT] : [COMMENT] Length field mismatch between send and received data - static const ReturnValue_t lENGTH_MISMATCH = MAKE_RETURN_CODE(0xB3); - //! [EXPORT] : [COMMENT] Specified file does not exist - static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xB4); - //! [EXPORT] : [COMMENT] Reply to upload centroid does not match commanded centroid id - static const ReturnValue_t UPLOAD_CENTROID_ID_MISMATCH = MAKE_RETURN_CODE(0xB5); - //! [EXPORT] : [COMMENT] Download blob pixel command has invalid type field - static const ReturnValue_t INVALID_TYPE = MAKE_RETURN_CODE(0xB6); - //! [EXPORT] : [COMMENT] Received FPGA action command with invalid ID - static const ReturnValue_t INVALID_ID = MAKE_RETURN_CODE(0xB7); - - static const size_t MAX_PATH_SIZE = 50; - static const size_t MAX_FILE_NAME = 30; - - // position (uint32) + 1024 image data - static const size_t UPLOAD_COMMAND_LEN = 1028; - // Max valid position value in upload image command - static const uint16_t MAX_POSITION= 4095; - static const uint8_t STATUS_OFFSET = 1; - static const uint8_t TICKS_OFFSET = 2; - static const uint8_t TIME_OFFSET = 6; - static const uint8_t TM_DATA_FIELD_OFFSET = 14; - static const uint8_t PARAMETER_ID_OFFSET = 0; - static const uint8_t ACTION_ID_OFFSET = 0; - static const uint8_t ACTION_DATA_OFFSET = 2; - // Ping request will reply ping with this ID (data field) - static const uint32_t PING_ID = 0x55; - static const uint32_t BOOT_REGION_ID = 1; - static const MutexIF::TimeoutType TIMEOUT_TYPE = MutexIF::TimeoutType::WAITING; - static const uint32_t MUTEX_TIMEOUT = 20; - static const uint32_t BOOT_TIMEOUT = 1000; - - class WriteCmd { - public: - static const uint8_t ADDRESS_OFFSET = 1; - static const uint8_t FILE_OFFSET = 5; - // Minimum length of a write command (region, address and filename) - static const size_t MIN_LENGTH = 7; - }; - - class ReadCmd { - public: - static const uint8_t ADDRESS_OFFSET = 1; - static const uint8_t LENGTH_OFFSET = 5; - static const uint8_t FILE_OFFSET = 9; - // Minimum length of a read command (region, address, length and filename) - static const size_t MIN_LENGTH = 11; - }; - - class EraseCmd { - public: - static const uint8_t LENGTH = 1; - uint8_t rememberRegion = 0; - }; - - EraseCmd eraseCmd; - - class UnlockCmd { - public: - static const uint8_t CODE_OFFSET = 1; - }; - - class ChecksumCmd { - public: - static const uint8_t ADDRESS_OFFSET = 1; - static const uint8_t LENGTH_OFFSET = 5; - // Length of checksum command - static const size_t LENGTH = 9; - uint8_t rememberRegion = 0; - uint32_t rememberAddress = 0; - uint32_t rememberLength = 0; - }; - - ChecksumCmd checksumCmd; - - class SetTimeCmd { - public: - static const uint8_t LENGTH = 8; - }; - - class DownloadCentroidCmd { - public: - static const uint8_t LENGTH = 1; - }; - - class UploadCentroid { - public: - uint8_t rememberId = 0; - }; - - UploadCentroid uploadCentroid; - - class DownloadMatchedStarCmd { - public: - static const uint8_t LENGTH = 1; - }; - - class DownloadDbImageCmd { - public: - static const uint8_t LENGTH = 1; - }; - - class DownloadBlobPixCmd { - public: - static const uint8_t LENGTH = 2; - static const uint8_t NORMAL = 0; - static const uint8_t FAST = 1; - }; - - class FpgaDownloadCmd { - public: - static const uint8_t MIN_LENGTH = 10; - }; - - class FpgaActionCmd { - public: - static const uint8_t LENGTH = 1; - static const uint8_t ID = 3; - }; - - MessageQueueIF* eventQueue = nullptr; - - ArcsecDatalinkLayer dataLinkLayer; - - StarTracker::TemperatureSet temperatureSet; - StarTracker::VersionSet versionSet; - StarTracker::PowerSet powerSet; - StarTracker::InterfaceSet interfaceSet; - StarTracker::TimeSet timeSet; - StarTracker::SolutionSet solutionSet; - StarTracker::HistogramSet histogramSet; - StarTracker::ContrastSet contrastSet; - StarTracker::ChecksumSet checksumSet; - StarTracker::DownloadCentroidSet downloadCentroidSet; - StarTracker::DownloadMatchedStar downloadMatchedStar; - StarTracker::DownloadDBImage downloadDbImage; - StarTracker::DownloadBlobPixel downloadBlobPixel; - - // Pointer to object responsible for uploading and downloading images to/from the star tracker - StrHelper* strHelper = nullptr; - - uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE]; - - // Countdown to insert delay for star tracker to switch from bootloader to firmware program - Countdown bootCountdown; - - std::string paramJsonFile = "/mnt/sd0/startracker/full.json"; - - enum class InternalState { - TEMPERATURE_REQUEST - }; - - InternalState internalState = InternalState::TEMPERATURE_REQUEST; - - enum class StartupState { - IDLE, - CHECK_BOOT_STATE, - BOOT, - BOOT_DELAY, - LIMITS, - TRACKING, - MOUNTING, - CAMERA, - BLOB, - CENTROIDING, - LISA, - MATCHING, - VALIDATION, - ALGO, - WAIT_FOR_EXECUTION, - DONE - }; - - StartupState startupState = StartupState::IDLE; - - bool strHelperExecuting = false; - - /** - * @brief Handles internal state - */ - void handleInternalState(); - - /** - * @brief Checks mode for commands requiring MODE_ON of MODE_NORMAL for execution. - * - * @param actionId Action id of command to execute - */ - ReturnValue_t checkMode(ActionId_t actionId); - - /** - * @brief This function initializes the serial link ip protocol struct slipInfo. - */ - void slipInit(); - - ReturnValue_t scanForActionReply(DeviceCommandId_t *foundId); - ReturnValue_t scanForParameterReply(DeviceCommandId_t *foundId); - ReturnValue_t scanForTmReply(DeviceCommandId_t *foundId); - - /** - * @brief Fills command buffer with data to ping the star tracker - */ - void preparePingRequest(); - - /** - * @brief Fills command buffer with data to request the time telemetry. - */ - void prepareTimeRequest(); - - /** - * @brief Handles all received event messages - */ - void handleEvent(EventMessage* eventMessage); - - /** - * @brief Executes the write command - * - * @param commandData Pointer to received command data - * @param commandDataLen Size of received command data - * - * @return RETURN_OK if start of execution was successful, otherwise error return value - */ - ReturnValue_t executeWriteCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Starts the execution of the fpga download command - * - * @param commandData Pointer to buffer with command data - * @param commandDataLen Size of received command - */ - ReturnValue_t executeFpgaDownloadCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Extracts information for flash-read-command from TC data and starts execution of - * flash-read-procedure - * - * @param commandData Pointer to received command data - * @param commandDataLen Size of received command data - * - * @return RETURN_OK if start of execution was successful, otherwise error return value - */ - ReturnValue_t executeReadCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills command buffer with data to boot image (works only when star tracker is - * in bootloader mode). - */ - void prepareBootCommand(); - - /** - * @brief Fills command buffer with command to erase a flash region - */ - ReturnValue_t prepareEraseCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills command buffer with command to unlock flash region - */ - ReturnValue_t prepareUnlockCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills command buffer with command to get the checksum of a flash part - */ - ReturnValue_t prepareChecksumCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills command buffer with command to set the unix time - */ - ReturnValue_t prepareSetTimeCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills command buffer with command to request a centroid - */ - ReturnValue_t prepareDownloadCentroidCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills command buffer with command to upload a centroid for testing purpose - */ - ReturnValue_t prepareUploadCentroidCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills the command buffer with the command to take an image. - */ - void prepareTakeImageCommand(const uint8_t* commandData); - - /** - * @brief Fills command buffer with data to request the version telemetry packet - */ - void prepareVersionRequest(); - - /** - * @brief Fills the command buffer with data to request the interface telemetry packet. - */ - void prepareInterfaceRequest(); - - /** - * @brief Fills the command buffer with data to request the power telemetry packet. - */ - void preparePowerRequest(); - - /** - * @brief Fills command buffer with data to reboot star tracker. - */ - void prepareRebootCommand(); - - /** - * @brief Fills command buffer with data to subscribe to a telemetry packet. - * - * @param tmId The ID of the telemetry packet to subscribe to - */ - void prepareSubscriptionCommand(const uint8_t* tmId); - - /** - * @brief Fills command buffer with data to request solution telemtry packet (contains - * attitude information) - */ - void prepareSolutionRequest(); - - /** - * @brief Fills command buffer with data to request temperature from star tracker - */ - void prepareTemperatureRequest(); - - /** - * @brief Fills command buffer with data to request histogram - */ - void prepareHistogramRequest(); - - void prepareContrastRequest(); - - /** - * @brief Fills command buffer with command to reset the error signal of the star tracker - */ - void prepareErrorResetRequest(); - - /** - * @brief Reads parameters from json file specified by string in commandData and - * prepares the command to apply the parameter set to the star tracker - * - * @param commandData Contains string with file name - * @param commandDataLen Length of command - * @param paramSet The object defining the command generation - * - * @return RETURN_OK if successful, otherwise error return Value - */ - ReturnValue_t prepareParamCommand(const uint8_t* commandData, size_t commandDataLen, - ArcsecJsonParamBase& paramSet); - - /** - * @brief Fills command buffer with data to request matched star. - */ - ReturnValue_t prepareDownloadMatchedStarCommand(const uint8_t* commandData, - size_t commandDataLen); - - /** - * @brief Fills command buffer with data to request matched star coordinates. - */ - ReturnValue_t prepareDownloadDbImageCommand(const uint8_t* commandData, - size_t commandDataLen); - - /** - * @brief Fills command buffer with data to request output of the blob filter algorithm. - */ - ReturnValue_t prepareDownloadBlobPixelCommand(const uint8_t* commandData, - size_t commandDataLen); - - /** - * @brief With this command the FPGA update will be applied to the star tracker - */ - ReturnValue_t prepareFpgaActionCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Handles action replies with datasets. - */ - ReturnValue_t handleActionReplySet(LocalPoolDataSetBase& dataset, size_t size); - - /** - * @brief Default function to handle action replies - */ - ReturnValue_t handleActionReply(); - - /** - * @brief Handles reply to upload centroid command - */ - ReturnValue_t handleUploadCentroidReply(); - - /** - * @brief Handles reply to erase command - */ - ReturnValue_t handleEraseReply(); - - /** - * @brief Handles reply to checksum command - */ - ReturnValue_t handleChecksumReply(); - - /** - * @brief Handles all set parameter replies - */ - ReturnValue_t handleSetParamReply(); - - ReturnValue_t handlePingReply(); - - /** - * @brief Checks the loaded program by means of the version set - */ - ReturnValue_t checkProgram(); - - /** - * @brief Handles the startup state machine - */ - void handleStartup(const uint8_t* parameterId); - - /** - * @brief Handles telemtry replies and fills the appropriate dataset - * - * @param dataset Dataset where reply data will be written to - * @param size Size of the dataset - * - * @return RETURN_OK if successful, otherwise error return value - */ - ReturnValue_t handleTm(LocalPoolDataSetBase& dataset, size_t size); +class StarTrackerHandler : public DeviceHandlerBase { + public: + /** + * @brief Constructor + * + * @param objectId + * @param comIF + * @param comCookie + * @param gpioComIF Pointer to gpio communication interface + * @param enablePin GPIO connected to the enable pin of the reaction wheels. Must be pulled + * to high to enable the device. + */ + StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, + StrHelper* strHelper); + virtual ~StarTrackerHandler(); + + ReturnValue_t initialize() override; + + /** + * @brief Overwrite this function from DHB to handle commands executed by the str image + * loader task. + */ + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) override; + + void performOperationHook() override; + + protected: + void doStartUp() override; + void doShutDown() override; + void doOffActivity() 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; + /** + * @brief Overwritten here to always read all available data from the UartComIF. + */ + virtual size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override; + virtual ReturnValue_t doSendReadHook() override; + + private: + static const uint8_t INTERFACE_ID = CLASS_ID::STR_HANDLER; + + //! [EXPORT] : [COMMENT] Received reply is too short + static const ReturnValue_t REPLY_TOO_SHORT = MAKE_RETURN_CODE(0xB0); + //! [EXPORT] : [COMMENT] Received reply with invalid CRC + static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xB1); + //! [EXPORT] : [COMMENT] Image loader executing + static const ReturnValue_t IMAGE_LOADER_EXECUTING = MAKE_RETURN_CODE(0xB2); + + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_HANDLER; + + //! [EXPORT] : [COMMENT] Status in temperature reply signals error + static const ReturnValue_t TEMPERATURE_REQ_FAILED = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] Ping command failed + static const ReturnValue_t PING_FAILED = MAKE_RETURN_CODE(0xA1); + //! [EXPORT] : [COMMENT] Status in version reply signals error + static const ReturnValue_t VERSION_REQ_FAILED = MAKE_RETURN_CODE(0xA3); + //! [EXPORT] : [COMMENT] Status in interface reply signals error + static const ReturnValue_t INTERFACE_REQ_FAILED = MAKE_RETURN_CODE(0xA4); + //! [EXPORT] : [COMMENT] Status in power reply signals error + static const ReturnValue_t POWER_REQ_FAILED = MAKE_RETURN_CODE(0xA5); + //! [EXPORT] : [COMMENT] Status of reply to parameter set command signals error + static const ReturnValue_t SET_PARAM_FAILED = MAKE_RETURN_CODE(0xA6); + //! [EXPORT] : [COMMENT] Status of reply to action command signals error + static const ReturnValue_t ACTION_FAILED = MAKE_RETURN_CODE(0xA7); + //! [EXPORT] : [COMMENT] Received upload image command with invalid length + static const ReturnValue_t UPLOAD_TOO_SHORT = MAKE_RETURN_CODE(0xA8); + //! [EXPORT] : [COMMENT] Received upload image command with invalid position field + static const ReturnValue_t UPLOAD_INVALID_POSITION = MAKE_RETURN_CODE(0xA8); + //! [EXPORT] : [COMMENT] Position value in upload image reply not matching sent position + static const ReturnValue_t UPLOAD_IMAGE_FAILED = MAKE_RETURN_CODE(0xA9); + //! [EXPORT] : [COMMENT] Received upload image command with invalid length + static const ReturnValue_t INVALID_UPLOAD_COMMAND = MAKE_RETURN_CODE(0xAA); + //! [EXPORT] : [COMMENT] Received invalid path string. Exceeds allowed length + static const ReturnValue_t FILE_PATH_TOO_LONG = MAKE_RETURN_CODE(0xAB); + //! [EXPORT] : [COMMENT] Name of file received with command is too long + static const ReturnValue_t FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xAC); + //! [EXPORT] : [COMMENT] Received version reply with invalid program ID + static const ReturnValue_t INVALID_PROGRAM = MAKE_RETURN_CODE(0xAD); + //! [EXPORT] : [COMMENT] Status field reply signals error + static const ReturnValue_t REPLY_ERROR = MAKE_RETURN_CODE(0xAE); + //! [EXPORT] : [COMMENT] Status field of contrast reply signals error + static const ReturnValue_t CONTRAST_REQ_FAILED = MAKE_RETURN_CODE(0xAE); + //! [EXPORT] : [COMMENT] Received command which is too short (some data is missing for proper + //! execution) + static const ReturnValue_t COMMAND_TOO_SHORT = MAKE_RETURN_CODE(0xAF); + //! [EXPORT] : [COMMENT] Received command with invalid length (too few or too many parameters) + static const ReturnValue_t INVALID_LENGTH = MAKE_RETURN_CODE(0xB0); + //! [EXPORT] : [COMMENT] Region mismatch between send and received data + static const ReturnValue_t REGION_MISMATCH = MAKE_RETURN_CODE(0xB1); + //! [EXPORT] : [COMMENT] Address mismatch between send and received data + static const ReturnValue_t ADDRESS_MISMATCH = MAKE_RETURN_CODE(0xB2); + //! [EXPORT] : [COMMENT] Length field mismatch between send and received data + static const ReturnValue_t lENGTH_MISMATCH = MAKE_RETURN_CODE(0xB3); + //! [EXPORT] : [COMMENT] Specified file does not exist + static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xB4); + //! [EXPORT] : [COMMENT] Reply to upload centroid does not match commanded centroid id + static const ReturnValue_t UPLOAD_CENTROID_ID_MISMATCH = MAKE_RETURN_CODE(0xB5); + //! [EXPORT] : [COMMENT] Download blob pixel command has invalid type field + static const ReturnValue_t INVALID_TYPE = MAKE_RETURN_CODE(0xB6); + //! [EXPORT] : [COMMENT] Received FPGA action command with invalid ID + static const ReturnValue_t INVALID_ID = MAKE_RETURN_CODE(0xB7); + + static const size_t MAX_PATH_SIZE = 50; + static const size_t MAX_FILE_NAME = 30; + + // position (uint32) + 1024 image data + static const size_t UPLOAD_COMMAND_LEN = 1028; + // Max valid position value in upload image command + static const uint16_t MAX_POSITION = 4095; + static const uint8_t STATUS_OFFSET = 1; + static const uint8_t TICKS_OFFSET = 2; + static const uint8_t TIME_OFFSET = 6; + static const uint8_t TM_DATA_FIELD_OFFSET = 14; + static const uint8_t PARAMETER_ID_OFFSET = 0; + static const uint8_t ACTION_ID_OFFSET = 0; + static const uint8_t ACTION_DATA_OFFSET = 2; + // Ping request will reply ping with this ID (data field) + static const uint32_t PING_ID = 0x55; + static const uint32_t BOOT_REGION_ID = 1; + static const MutexIF::TimeoutType TIMEOUT_TYPE = MutexIF::TimeoutType::WAITING; + static const uint32_t MUTEX_TIMEOUT = 20; + static const uint32_t BOOT_TIMEOUT = 1000; + + class WriteCmd { + public: + static const uint8_t ADDRESS_OFFSET = 1; + static const uint8_t FILE_OFFSET = 5; + // Minimum length of a write command (region, address and filename) + static const size_t MIN_LENGTH = 7; + }; + + class ReadCmd { + public: + static const uint8_t ADDRESS_OFFSET = 1; + static const uint8_t LENGTH_OFFSET = 5; + static const uint8_t FILE_OFFSET = 9; + // Minimum length of a read command (region, address, length and filename) + static const size_t MIN_LENGTH = 11; + }; + + class EraseCmd { + public: + static const uint8_t LENGTH = 1; + uint8_t rememberRegion = 0; + }; + + EraseCmd eraseCmd; + + class UnlockCmd { + public: + static const uint8_t CODE_OFFSET = 1; + }; + + class ChecksumCmd { + public: + static const uint8_t ADDRESS_OFFSET = 1; + static const uint8_t LENGTH_OFFSET = 5; + // Length of checksum command + static const size_t LENGTH = 9; + uint8_t rememberRegion = 0; + uint32_t rememberAddress = 0; + uint32_t rememberLength = 0; + }; + + ChecksumCmd checksumCmd; + + class SetTimeCmd { + public: + static const uint8_t LENGTH = 8; + }; + + class DownloadCentroidCmd { + public: + static const uint8_t LENGTH = 1; + }; + + class UploadCentroid { + public: + uint8_t rememberId = 0; + }; + + UploadCentroid uploadCentroid; + + class DownloadMatchedStarCmd { + public: + static const uint8_t LENGTH = 1; + }; + + class DownloadDbImageCmd { + public: + static const uint8_t LENGTH = 1; + }; + + class DownloadBlobPixCmd { + public: + static const uint8_t LENGTH = 2; + static const uint8_t NORMAL = 0; + static const uint8_t FAST = 1; + }; + + class FpgaDownloadCmd { + public: + static const uint8_t MIN_LENGTH = 10; + }; + + class FpgaActionCmd { + public: + static const uint8_t LENGTH = 1; + static const uint8_t ID = 3; + }; + + MessageQueueIF* eventQueue = nullptr; + + ArcsecDatalinkLayer dataLinkLayer; + + StarTracker::TemperatureSet temperatureSet; + StarTracker::VersionSet versionSet; + StarTracker::PowerSet powerSet; + StarTracker::InterfaceSet interfaceSet; + StarTracker::TimeSet timeSet; + StarTracker::SolutionSet solutionSet; + StarTracker::HistogramSet histogramSet; + StarTracker::ContrastSet contrastSet; + StarTracker::ChecksumSet checksumSet; + StarTracker::DownloadCentroidSet downloadCentroidSet; + StarTracker::DownloadMatchedStar downloadMatchedStar; + StarTracker::DownloadDBImage downloadDbImage; + StarTracker::DownloadBlobPixel downloadBlobPixel; + + // Pointer to object responsible for uploading and downloading images to/from the star tracker + StrHelper* strHelper = nullptr; + + uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE]; + + // Countdown to insert delay for star tracker to switch from bootloader to firmware program + Countdown bootCountdown; + + std::string paramJsonFile = "/mnt/sd0/startracker/full.json"; + + enum class InternalState { TEMPERATURE_REQUEST }; + + InternalState internalState = InternalState::TEMPERATURE_REQUEST; + + enum class StartupState { + IDLE, + CHECK_BOOT_STATE, + BOOT, + BOOT_DELAY, + LIMITS, + TRACKING, + MOUNTING, + CAMERA, + BLOB, + CENTROIDING, + LISA, + MATCHING, + VALIDATION, + ALGO, + WAIT_FOR_EXECUTION, + DONE + }; + + StartupState startupState = StartupState::IDLE; + + bool strHelperExecuting = false; + + /** + * @brief Handles internal state + */ + void handleInternalState(); + + /** + * @brief Checks mode for commands requiring MODE_ON of MODE_NORMAL for execution. + * + * @param actionId Action id of command to execute + */ + ReturnValue_t checkMode(ActionId_t actionId); + + /** + * @brief This function initializes the serial link ip protocol struct slipInfo. + */ + void slipInit(); + + ReturnValue_t scanForActionReply(DeviceCommandId_t* foundId); + ReturnValue_t scanForParameterReply(DeviceCommandId_t* foundId); + ReturnValue_t scanForTmReply(DeviceCommandId_t* foundId); + + /** + * @brief Fills command buffer with data to ping the star tracker + */ + void preparePingRequest(); + + /** + * @brief Fills command buffer with data to request the time telemetry. + */ + void prepareTimeRequest(); + + /** + * @brief Handles all received event messages + */ + void handleEvent(EventMessage* eventMessage); + + /** + * @brief Executes the write command + * + * @param commandData Pointer to received command data + * @param commandDataLen Size of received command data + * + * @return RETURN_OK if start of execution was successful, otherwise error return value + */ + ReturnValue_t executeWriteCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Starts the execution of the fpga download command + * + * @param commandData Pointer to buffer with command data + * @param commandDataLen Size of received command + */ + ReturnValue_t executeFpgaDownloadCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Extracts information for flash-read-command from TC data and starts execution of + * flash-read-procedure + * + * @param commandData Pointer to received command data + * @param commandDataLen Size of received command data + * + * @return RETURN_OK if start of execution was successful, otherwise error return value + */ + ReturnValue_t executeReadCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills command buffer with data to boot image (works only when star tracker is + * in bootloader mode). + */ + void prepareBootCommand(); + + /** + * @brief Fills command buffer with command to erase a flash region + */ + ReturnValue_t prepareEraseCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills command buffer with command to unlock flash region + */ + ReturnValue_t prepareUnlockCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills command buffer with command to get the checksum of a flash part + */ + ReturnValue_t prepareChecksumCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills command buffer with command to set the unix time + */ + ReturnValue_t prepareSetTimeCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills command buffer with command to request a centroid + */ + ReturnValue_t prepareDownloadCentroidCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills command buffer with command to upload a centroid for testing purpose + */ + ReturnValue_t prepareUploadCentroidCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills the command buffer with the command to take an image. + */ + void prepareTakeImageCommand(const uint8_t* commandData); + + /** + * @brief Fills command buffer with data to request the version telemetry packet + */ + void prepareVersionRequest(); + + /** + * @brief Fills the command buffer with data to request the interface telemetry packet. + */ + void prepareInterfaceRequest(); + + /** + * @brief Fills the command buffer with data to request the power telemetry packet. + */ + void preparePowerRequest(); + + /** + * @brief Fills command buffer with data to reboot star tracker. + */ + void prepareRebootCommand(); + + /** + * @brief Fills command buffer with data to subscribe to a telemetry packet. + * + * @param tmId The ID of the telemetry packet to subscribe to + */ + void prepareSubscriptionCommand(const uint8_t* tmId); + + /** + * @brief Fills command buffer with data to request solution telemtry packet (contains + * attitude information) + */ + void prepareSolutionRequest(); + + /** + * @brief Fills command buffer with data to request temperature from star tracker + */ + void prepareTemperatureRequest(); + + /** + * @brief Fills command buffer with data to request histogram + */ + void prepareHistogramRequest(); + + void prepareContrastRequest(); + + /** + * @brief Fills command buffer with command to reset the error signal of the star tracker + */ + void prepareErrorResetRequest(); + + /** + * @brief Reads parameters from json file specified by string in commandData and + * prepares the command to apply the parameter set to the star tracker + * + * @param commandData Contains string with file name + * @param commandDataLen Length of command + * @param paramSet The object defining the command generation + * + * @return RETURN_OK if successful, otherwise error return Value + */ + ReturnValue_t prepareParamCommand(const uint8_t* commandData, size_t commandDataLen, + ArcsecJsonParamBase& paramSet); + + /** + * @brief Fills command buffer with data to request matched star. + */ + ReturnValue_t prepareDownloadMatchedStarCommand(const uint8_t* commandData, + size_t commandDataLen); + + /** + * @brief Fills command buffer with data to request matched star coordinates. + */ + ReturnValue_t prepareDownloadDbImageCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills command buffer with data to request output of the blob filter algorithm. + */ + ReturnValue_t prepareDownloadBlobPixelCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief With this command the FPGA update will be applied to the star tracker + */ + ReturnValue_t prepareFpgaActionCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Handles action replies with datasets. + */ + ReturnValue_t handleActionReplySet(LocalPoolDataSetBase& dataset, size_t size); + + /** + * @brief Default function to handle action replies + */ + ReturnValue_t handleActionReply(); + + /** + * @brief Handles reply to upload centroid command + */ + ReturnValue_t handleUploadCentroidReply(); + + /** + * @brief Handles reply to erase command + */ + ReturnValue_t handleEraseReply(); + + /** + * @brief Handles reply to checksum command + */ + ReturnValue_t handleChecksumReply(); + + /** + * @brief Handles all set parameter replies + */ + ReturnValue_t handleSetParamReply(); + + ReturnValue_t handlePingReply(); + + /** + * @brief Checks the loaded program by means of the version set + */ + ReturnValue_t checkProgram(); + + /** + * @brief Handles the startup state machine + */ + void handleStartup(const uint8_t* parameterId); + + /** + * @brief Handles telemtry replies and fills the appropriate dataset + * + * @param dataset Dataset where reply data will be written to + * @param size Size of the dataset + * + * @return RETURN_OK if successful, otherwise error return value + */ + ReturnValue_t handleTm(LocalPoolDataSetBase& dataset, size_t size); }; #endif /* MISSION_DEVICES_STARTRACKERHANDLER_H_ */ diff --git a/bsp_q7s/devices/startracker/StarTrackerJsonCommands.cpp b/bsp_q7s/devices/startracker/StarTrackerJsonCommands.cpp index 9c33e1c9..b912c03e 100644 --- a/bsp_q7s/devices/startracker/StarTrackerJsonCommands.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerJsonCommands.cpp @@ -1,716 +1,689 @@ #include "StarTrackerJsonCommands.h" + #include "ArcsecJsonKeys.h" Limits::Limits() : ArcsecJsonParamBase(arcseckeys::LIMITS) {} -size_t Limits::getSize() { - return COMMAND_SIZE; -} +size_t Limits::getSize() { return COMMAND_SIZE; } ReturnValue_t Limits::createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::LIMITS); - offset = 2; - result = getParam(arcseckeys::ACTION, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::FPGA18CURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::FPGA25CURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::FPGA10CURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MCUCURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::CMOS21CURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::CMOSPIXCURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::CMOS33CURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::CMOSVRESCURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::CMOS_TEMPERATURE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MCU_TEMPERATURE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::LIMITS); + offset = 2; + result = getParam(arcseckeys::ACTION, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::FPGA18CURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FPGA25CURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FPGA10CURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MCUCURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CMOS21CURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CMOSPIXCURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CMOS33CURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CMOSVRESCURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CMOS_TEMPERATURE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MCU_TEMPERATURE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + return RETURN_OK; } - Tracking::Tracking() : ArcsecJsonParamBase(arcseckeys::TRACKING) {} -size_t Tracking::getSize() { - return COMMAND_SIZE; -} +size_t Tracking::getSize() { return COMMAND_SIZE; } ReturnValue_t Tracking::createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::TRACKING); - offset = 2; - result = getParam(arcseckeys::THIN_LIMIT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::OUTLIER_THRESHOLD, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::OUTLIER_THRESHOLD_QUEST, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::TRACKER_CHOICE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::TRACKING); + offset = 2; + result = getParam(arcseckeys::THIN_LIMIT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::OUTLIER_THRESHOLD, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::OUTLIER_THRESHOLD_QUEST, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::TRACKER_CHOICE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + return RETURN_OK; } - Mounting::Mounting() : ArcsecJsonParamBase(arcseckeys::MOUNTING) {} -size_t Mounting::getSize() { - return COMMAND_SIZE; -} +size_t Mounting::getSize() { return COMMAND_SIZE; } ReturnValue_t Mounting::createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::MOUNTING); - offset = 2; - result = getParam(arcseckeys::qw, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::qx, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::qy, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::qz, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::MOUNTING); + offset = 2; + result = getParam(arcseckeys::qw, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::qx, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::qy, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::qz, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + return RETURN_OK; } - Camera::Camera() : ArcsecJsonParamBase(arcseckeys::CAMERA) {} -size_t Camera::getSize() { - return COMMAND_SIZE; -} +size_t Camera::getSize() { return COMMAND_SIZE; } ReturnValue_t Camera::createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::CAMERA); - offset = 2; - result = getParam(arcseckeys::MODE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::FOCALLENGTH, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::EXPOSURE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::INTERVAL, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::OFFSET, param); - if (result != RETURN_OK) { - return result; - } - addint16(param, buffer + offset); - offset += sizeof(int16_t); - result = getParam(arcseckeys::PGAGAIN, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::ADCGAIN, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_1, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_1, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_2, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_2, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_3, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_3, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_4, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_4, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_5, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_5, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_6, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_6, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_7, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_7, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_8, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_8, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::FREQ_1, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::FREQ_2, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::CAMERA); + offset = 2; + result = getParam(arcseckeys::MODE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::FOCALLENGTH, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::EXPOSURE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::INTERVAL, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::OFFSET, param); + if (result != RETURN_OK) { + return result; + } + addint16(param, buffer + offset); + offset += sizeof(int16_t); + result = getParam(arcseckeys::PGAGAIN, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::ADCGAIN, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_1, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_1, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_2, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_2, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_3, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_3, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_4, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_4, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_5, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_5, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_6, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_6, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_7, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_7, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_8, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_8, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::FREQ_1, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FREQ_2, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + return RETURN_OK; } - Blob::Blob() : ArcsecJsonParamBase(arcseckeys::BLOB) {} -size_t Blob::getSize() { - return COMMAND_SIZE; -} +size_t Blob::getSize() { return COMMAND_SIZE; } ReturnValue_t Blob::createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::BLOB); - offset = 2; - result = getParam(arcseckeys::MODE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::MIN_VALUE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::MIN_DISTANCE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::NEIGHBOUR_DISTANCE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::NEIGHBOUR_BRIGHT_PIXELS, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::MIN_TOTAL_VALUE, param); - if (result != RETURN_OK) { - return result; - } - adduint16(param, buffer + offset); - offset += sizeof(uint16_t); - result = getParam(arcseckeys::MAX_TOTAL_VALUE, param); - if (result != RETURN_OK) { - return result; - } - adduint16(param, buffer + offset); - offset += sizeof(uint16_t); - result = getParam(arcseckeys::MIN_BRIGHT_NEIGHBOURS, param); - if (result != RETURN_OK) { - return result; - } - adduint16(param, buffer + offset); - offset += sizeof(uint16_t); - result = getParam(arcseckeys::MAX_BRIGHT_NEIGHBOURS, param); - if (result != RETURN_OK) { - return result; - } - adduint16(param, buffer + offset); - offset += sizeof(uint16_t); - result = getParam(arcseckeys::MAX_PIXEL_TO_CONSIDER, param); - if (result != RETURN_OK) { - return result; - } - adduint32(param, buffer + offset); - offset += sizeof(uint32_t); - result = getParam(arcseckeys::SIGNAL_THRESHOLD, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::DARK_THRESHOLD, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::ENABLE_HISTOGRAM, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::ENABLE_CONTRAST, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::BIN_MODE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::BLOB); + offset = 2; + result = getParam(arcseckeys::MODE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::MIN_VALUE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::MIN_DISTANCE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::NEIGHBOUR_DISTANCE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::NEIGHBOUR_BRIGHT_PIXELS, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::MIN_TOTAL_VALUE, param); + if (result != RETURN_OK) { + return result; + } + adduint16(param, buffer + offset); + offset += sizeof(uint16_t); + result = getParam(arcseckeys::MAX_TOTAL_VALUE, param); + if (result != RETURN_OK) { + return result; + } + adduint16(param, buffer + offset); + offset += sizeof(uint16_t); + result = getParam(arcseckeys::MIN_BRIGHT_NEIGHBOURS, param); + if (result != RETURN_OK) { + return result; + } + adduint16(param, buffer + offset); + offset += sizeof(uint16_t); + result = getParam(arcseckeys::MAX_BRIGHT_NEIGHBOURS, param); + if (result != RETURN_OK) { + return result; + } + adduint16(param, buffer + offset); + offset += sizeof(uint16_t); + result = getParam(arcseckeys::MAX_PIXEL_TO_CONSIDER, param); + if (result != RETURN_OK) { + return result; + } + adduint32(param, buffer + offset); + offset += sizeof(uint32_t); + result = getParam(arcseckeys::SIGNAL_THRESHOLD, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::DARK_THRESHOLD, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::ENABLE_HISTOGRAM, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::ENABLE_CONTRAST, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::BIN_MODE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + return RETURN_OK; } - Centroiding::Centroiding() : ArcsecJsonParamBase(arcseckeys::CENTROIDING) {} -size_t Centroiding::getSize() { - return COMMAND_SIZE; -} +size_t Centroiding::getSize() { return COMMAND_SIZE; } ReturnValue_t Centroiding::createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::CENTROIDING); - offset = 2; - result = getParam(arcseckeys::ENABLE_FILTER, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::MAX_QUALITY, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MIN_QUALITY, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MAX_INTENSITY, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MIN_INTENSITY, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MAX_MAGNITUDE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::GAUSSIAN_CMAX, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::GAUSSIAN_CMIN, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::TRANSMATRIX_00, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::TRANSMATRIX_01, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::TRANSMATRIX_10, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::TRANSMATRIX_11, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::CENTROIDING); + offset = 2; + result = getParam(arcseckeys::ENABLE_FILTER, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::MAX_QUALITY, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MIN_QUALITY, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MAX_INTENSITY, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MIN_INTENSITY, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MAX_MAGNITUDE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::GAUSSIAN_CMAX, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::GAUSSIAN_CMIN, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::TRANSMATRIX_00, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::TRANSMATRIX_01, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::TRANSMATRIX_10, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::TRANSMATRIX_11, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + return RETURN_OK; } - Lisa::Lisa() : ArcsecJsonParamBase(arcseckeys::LISA) {} -size_t Lisa::getSize() { - return COMMAND_SIZE; -} +size_t Lisa::getSize() { return COMMAND_SIZE; } ReturnValue_t Lisa::createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::LISA); - offset = 2; - result = getParam(arcseckeys::PREFILTER_DIST_THRESHOLD, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::PREFILTER_ANGLE_THRESHOLD, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::FOV_WIDTH, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::FOV_HEIGHT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::FLOAT_STAR_LIMIT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::CLOSE_STAR_LIMIT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::RATING_WEIGHT_CLOSE_STAR_COUNT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::RATING_WEIGHT_FRACTION_CLOSE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::RATING_WEIGHT_DB_STAR_COUNT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MAX_COMBINATIONS, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::NR_STARS_STOP, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::FRACTION_CLOSE_STOP, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::LISA); + offset = 2; + result = getParam(arcseckeys::PREFILTER_DIST_THRESHOLD, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::PREFILTER_ANGLE_THRESHOLD, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FOV_WIDTH, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FOV_HEIGHT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FLOAT_STAR_LIMIT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CLOSE_STAR_LIMIT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::RATING_WEIGHT_CLOSE_STAR_COUNT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::RATING_WEIGHT_FRACTION_CLOSE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::RATING_WEIGHT_DB_STAR_COUNT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MAX_COMBINATIONS, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::NR_STARS_STOP, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::FRACTION_CLOSE_STOP, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + return RETURN_OK; } - Matching::Matching() : ArcsecJsonParamBase(arcseckeys::MATCHING) {} -size_t Matching::getSize() { - return COMMAND_SIZE; -} +size_t Matching::getSize() { return COMMAND_SIZE; } ReturnValue_t Matching::createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::MATCHING); - offset = 2; - result = getParam(arcseckeys::SQUARED_DISTANCE_LIMIT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::SQUARED_SHIFT_LIMIT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::MATCHING); + offset = 2; + result = getParam(arcseckeys::SQUARED_DISTANCE_LIMIT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::SQUARED_SHIFT_LIMIT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + return RETURN_OK; } - Validation::Validation() : ArcsecJsonParamBase(arcseckeys::VALIDATION) {} -size_t Validation::getSize() { - return COMMAND_SIZE; -} +size_t Validation::getSize() { return COMMAND_SIZE; } ReturnValue_t Validation::createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::VALIDATION); - offset = 2; - result = getParam(arcseckeys::STABLE_COUNT, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::MAX_DIFFERENCE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MIN_TRACKER_CONFIDENCE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MIN_MATCHED_STARS, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::VALIDATION); + offset = 2; + result = getParam(arcseckeys::STABLE_COUNT, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::MAX_DIFFERENCE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MIN_TRACKER_CONFIDENCE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MIN_MATCHED_STARS, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + return RETURN_OK; } Algo::Algo() : ArcsecJsonParamBase(arcseckeys::ALGO) {} -size_t Algo::getSize() { - return COMMAND_SIZE; -} +size_t Algo::getSize() { return COMMAND_SIZE; } ReturnValue_t Algo::createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::ALGO); - offset = 2; - result = getParam(arcseckeys::MODE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::L2T_MIN_CONFIDENCE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::L2T_MIN_MATCHED, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::T2L_MIN_CONFIDENCE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::T2L_MIN_MATCHED, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::ALGO); + offset = 2; + result = getParam(arcseckeys::MODE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::L2T_MIN_CONFIDENCE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::L2T_MIN_MATCHED, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::T2L_MIN_CONFIDENCE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::T2L_MIN_MATCHED, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + return RETURN_OK; } diff --git a/bsp_q7s/devices/startracker/StarTrackerJsonCommands.h b/bsp_q7s/devices/startracker/StarTrackerJsonCommands.h index 868c18ea..96c52fa2 100644 --- a/bsp_q7s/devices/startracker/StarTrackerJsonCommands.h +++ b/bsp_q7s/devices/startracker/StarTrackerJsonCommands.h @@ -9,207 +9,168 @@ #include -#include "fsfw/serviceinterface/ServiceInterface.h" #include "ArcsecJsonParamBase.h" - +#include "fsfw/serviceinterface/ServiceInterface.h" /** * @brief Generates command to set the limit parameters * */ class Limits : public ArcsecJsonParamBase { -public: + public: + Limits(); - Limits(); + size_t getSize(); - size_t getSize(); + private: + static const size_t COMMAND_SIZE = 43; -private: - - static const size_t COMMAND_SIZE = 43; - - virtual ReturnValue_t createCommand(uint8_t* buffer) override; + virtual ReturnValue_t createCommand(uint8_t* buffer) override; }; - /** * @brief Generates the command to configure the tracking algorithm. * */ class Tracking : public ArcsecJsonParamBase { -public: + public: + Tracking(); - Tracking(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 15; - - ReturnValue_t createCommand(uint8_t* buffer) override; + private: + static const size_t COMMAND_SIZE = 15; + ReturnValue_t createCommand(uint8_t* buffer) override; }; - /** * @brief Generates the command to set the mounting quaternion * */ class Mounting : public ArcsecJsonParamBase { -public: + public: + Mounting(); - Mounting(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 18; - - ReturnValue_t createCommand(uint8_t* buffer) override; + private: + static const size_t COMMAND_SIZE = 18; + ReturnValue_t createCommand(uint8_t* buffer) override; }; - /** * @brief Generates the command to set the mounting quaternion * */ class Camera : public ArcsecJsonParamBase { -public: + public: + Camera(); - Camera(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 43; - - ReturnValue_t createCommand(uint8_t* buffer) override; + private: + static const size_t COMMAND_SIZE = 43; + ReturnValue_t createCommand(uint8_t* buffer) override; }; - /** * @brief Generates the command to configure the blob algorithm * */ class Blob : public ArcsecJsonParamBase { -public: + public: + Blob(); - Blob(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 24; - - ReturnValue_t createCommand(uint8_t* buffer) override; + private: + static const size_t COMMAND_SIZE = 24; + ReturnValue_t createCommand(uint8_t* buffer) override; }; - /** * @brief Generates the command to configure the centroiding algorithm * */ class Centroiding : public ArcsecJsonParamBase { -public: + public: + Centroiding(); - Centroiding(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 47; - - ReturnValue_t createCommand(uint8_t* buffer) override; + private: + static const size_t COMMAND_SIZE = 47; + ReturnValue_t createCommand(uint8_t* buffer) override; }; - /** * @brief Generates the command to configure the LISA (lost in space algorithm) * */ class Lisa : public ArcsecJsonParamBase { -public: + public: + Lisa(); - Lisa(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 48; - - ReturnValue_t createCommand(uint8_t* buffer) override; + private: + static const size_t COMMAND_SIZE = 48; + ReturnValue_t createCommand(uint8_t* buffer) override; }; - /** * @brief Generates the command to configure the matching algorithm * */ class Matching : public ArcsecJsonParamBase { -public: + public: + Matching(); - Matching(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 10; - - ReturnValue_t createCommand(uint8_t* buffer) override; + private: + static const size_t COMMAND_SIZE = 10; + ReturnValue_t createCommand(uint8_t* buffer) override; }; - /** * @brief Generates the command to configure the validation parameters * */ class Validation : public ArcsecJsonParamBase { -public: + public: + Validation(); - Validation(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 12; - - ReturnValue_t createCommand(uint8_t* buffer) override; + private: + static const size_t COMMAND_SIZE = 12; + ReturnValue_t createCommand(uint8_t* buffer) override; }; - /** * @brief Generates command to configure the mechanism of automatically switching between the * LISA and other algorithms. * */ class Algo : public ArcsecJsonParamBase { -public: + public: + Algo(); - Algo(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 13; - - ReturnValue_t createCommand(uint8_t* buffer) override; + private: + static const size_t COMMAND_SIZE = 13; + ReturnValue_t createCommand(uint8_t* buffer) override; }; #endif /* BSP_Q7S_DEVICES_DEVICEDEFINITIONS_STARTRACKERJSONCOMMANDS_H_ */ diff --git a/bsp_q7s/devices/startracker/StrHelper.cpp b/bsp_q7s/devices/startracker/StrHelper.cpp index 59587317..00a651b3 100644 --- a/bsp_q7s/devices/startracker/StrHelper.cpp +++ b/bsp_q7s/devices/startracker/StrHelper.cpp @@ -1,702 +1,672 @@ #include "StrHelper.h" +#include +#include + #include "mission/utility/Timestamp.h" -#include -#include +StrHelper::StrHelper(object_id_t objectId) : SystemObject(objectId) {} -StrHelper::StrHelper(object_id_t objectId) : SystemObject(objectId){ - -} - -StrHelper::~StrHelper() { -} +StrHelper::~StrHelper() {} ReturnValue_t StrHelper::initialize() { - sdcMan = SdCardManager::instance(); - if (sdcMan == nullptr) { - sif::warning << "StrHelper::initialize: Invalid SD Card Manager" << std::endl; - return RETURN_FAILED; - } - return RETURN_OK; + sdcMan = SdCardManager::instance(); + if (sdcMan == nullptr) { + sif::warning << "StrHelper::initialize: Invalid SD Card Manager" << std::endl; + return RETURN_FAILED; + } + return RETURN_OK; } ReturnValue_t StrHelper::performOperation(uint8_t operationCode) { - ReturnValue_t result = RETURN_OK; - semaphore.acquire(); - while(true) { - switch(internalState) { - case InternalState::IDLE: { - semaphore.acquire(); - break; + ReturnValue_t result = RETURN_OK; + semaphore.acquire(); + while (true) { + switch (internalState) { + case InternalState::IDLE: { + semaphore.acquire(); + break; + } + case InternalState::UPLOAD_IMAGE: { + result = performImageUpload(); + if (result == RETURN_OK) { + triggerEvent(IMAGE_UPLOAD_SUCCESSFUL); + } else { + triggerEvent(IMAGE_UPLOAD_FAILED); } - case InternalState::UPLOAD_IMAGE: { - result = performImageUpload(); - if (result == RETURN_OK){ - triggerEvent(IMAGE_UPLOAD_SUCCESSFUL); - } - else { - triggerEvent(IMAGE_UPLOAD_FAILED); - } - internalState = InternalState::IDLE; - break; + internalState = InternalState::IDLE; + break; + } + case InternalState::DOWNLOAD_IMAGE: { + result = performImageDownload(); + if (result == RETURN_OK) { + triggerEvent(IMAGE_DOWNLOAD_SUCCESSFUL); + } else { + triggerEvent(IMAGE_DOWNLOAD_FAILED); } - case InternalState::DOWNLOAD_IMAGE: { - result = performImageDownload(); - if (result == RETURN_OK){ - triggerEvent(IMAGE_DOWNLOAD_SUCCESSFUL); - } - else { - triggerEvent(IMAGE_DOWNLOAD_FAILED); - } - internalState = InternalState::IDLE; - break; + internalState = InternalState::IDLE; + break; + } + case InternalState::FLASH_WRITE: { + result = performFlashWrite(); + if (result == RETURN_OK) { + triggerEvent(FLASH_WRITE_SUCCESSFUL); + } else { + triggerEvent(FLASH_WRITE_FAILED); } - case InternalState::FLASH_WRITE: { - result = performFlashWrite(); - if (result == RETURN_OK){ - triggerEvent(FLASH_WRITE_SUCCESSFUL); - } - else { - triggerEvent(FLASH_WRITE_FAILED); - } - internalState = InternalState::IDLE; - break; + internalState = InternalState::IDLE; + break; + } + case InternalState::FLASH_READ: { + result = performFlashRead(); + if (result == RETURN_OK) { + triggerEvent(FLASH_READ_SUCCESSFUL); + } else { + triggerEvent(FLASH_READ_FAILED); } - case InternalState::FLASH_READ: { - result = performFlashRead(); - if (result == RETURN_OK){ - triggerEvent(FLASH_READ_SUCCESSFUL); - } - else { - triggerEvent(FLASH_READ_FAILED); - } - internalState = InternalState::IDLE; - break; + internalState = InternalState::IDLE; + break; + } + case InternalState::DOWNLOAD_FPGA_IMAGE: { + result = performFpgaDownload(); + if (result == RETURN_OK) { + triggerEvent(FPGA_DOWNLOAD_SUCCESSFUL); + } else { + triggerEvent(FPGA_DOWNLOAD_FAILED); } - case InternalState::DOWNLOAD_FPGA_IMAGE: { - result = performFpgaDownload(); - if (result == RETURN_OK){ - triggerEvent(FPGA_DOWNLOAD_SUCCESSFUL); - } - else { - triggerEvent(FPGA_DOWNLOAD_FAILED); - } - internalState = InternalState::IDLE; - break; - } - case InternalState::UPLOAD_FPGA_IMAGE: { - result = performFpgaUpload(); - if (result == RETURN_OK){ - triggerEvent(FPGA_UPLOAD_SUCCESSFUL); - } - else { - triggerEvent(FPGA_UPLOAD_FAILED); - } - internalState = InternalState::IDLE; - break; - } - default: - sif::debug << "StrHelper::performOperation: Invalid state" << std::endl; - break; + internalState = InternalState::IDLE; + break; + } + case InternalState::UPLOAD_FPGA_IMAGE: { + result = performFpgaUpload(); + if (result == RETURN_OK) { + triggerEvent(FPGA_UPLOAD_SUCCESSFUL); + } else { + triggerEvent(FPGA_UPLOAD_FAILED); } + internalState = InternalState::IDLE; + break; + } + default: + sif::debug << "StrHelper::performOperation: Invalid state" << std::endl; + break; } + } } ReturnValue_t StrHelper::setComIF(DeviceCommunicationIF* communicationInterface_) { - uartComIF = dynamic_cast(communicationInterface_); - if (uartComIF == nullptr) { - sif::warning << "StrHelper::initialize: Invalid uart com if" << std::endl; - return RETURN_FAILED; - } - return RETURN_OK; + uartComIF = dynamic_cast(communicationInterface_); + if (uartComIF == nullptr) { + sif::warning << "StrHelper::initialize: Invalid uart com if" << std::endl; + return RETURN_FAILED; + } + return RETURN_OK; } -void StrHelper::setComCookie(CookieIF* comCookie_) { - comCookie = comCookie_; -} +void StrHelper::setComCookie(CookieIF* comCookie_) { comCookie = comCookie_; } ReturnValue_t StrHelper::startImageUpload(std::string fullname) { - ReturnValue_t result = checkPath(fullname); - if (result != RETURN_OK) { - return result; - } - uploadImage.uploadFile = fullname; - if(not std::filesystem::exists(fullname)) { - return FILE_NOT_EXISTS; - } - internalState = InternalState::UPLOAD_FPGA_IMAGE; - semaphore.release(); - terminate = false; - return RETURN_OK; + ReturnValue_t result = checkPath(fullname); + if (result != RETURN_OK) { + return result; + } + uploadImage.uploadFile = fullname; + if (not std::filesystem::exists(fullname)) { + return FILE_NOT_EXISTS; + } + internalState = InternalState::UPLOAD_FPGA_IMAGE; + semaphore.release(); + terminate = false; + return RETURN_OK; } ReturnValue_t StrHelper::startImageDownload(std::string path) { - ReturnValue_t result = checkPath(path); - if (result != RETURN_OK) { - return result; - } - if(not std::filesystem::exists(path)) { - return PATH_NOT_EXISTS; - } - downloadImage.path = path; - internalState = InternalState::DOWNLOAD_IMAGE; - terminate = false; - semaphore.release(); - return RETURN_OK; + ReturnValue_t result = checkPath(path); + if (result != RETURN_OK) { + return result; + } + if (not std::filesystem::exists(path)) { + return PATH_NOT_EXISTS; + } + downloadImage.path = path; + internalState = InternalState::DOWNLOAD_IMAGE; + terminate = false; + semaphore.release(); + return RETURN_OK; } -void StrHelper::stopProcess() { - terminate = true; +void StrHelper::stopProcess() { terminate = true; } + +void StrHelper::setDownloadImageName(std::string filename) { downloadImage.filename = filename; } + +void StrHelper::setFlashReadFilename(std::string filename) { flashRead.filename = filename; } + +void StrHelper::setDownloadFpgaImage(std::string filename) { fpgaDownload.fileName = filename; } + +ReturnValue_t StrHelper::startFlashWrite(std::string fullname, uint8_t region, uint32_t address) { + ReturnValue_t result = checkPath(fullname); + if (result != RETURN_OK) { + return result; + } + flashWrite.fullname = fullname; + if (not std::filesystem::exists(flashWrite.fullname)) { + return FILE_NOT_EXISTS; + } + flashWrite.address = address; + flashWrite.region = region; + internalState = InternalState::FLASH_WRITE; + semaphore.release(); + terminate = false; + return RETURN_OK; } -void StrHelper::setDownloadImageName(std::string filename) { - downloadImage.filename = filename; -} - -void StrHelper::setFlashReadFilename(std::string filename) { - flashRead.filename = filename; -} - -void StrHelper::setDownloadFpgaImage(std::string filename) { - fpgaDownload.fileName = filename; -} - -ReturnValue_t StrHelper::startFlashWrite(std::string fullname, uint8_t region, - uint32_t address) { - ReturnValue_t result = checkPath(fullname); - if (result != RETURN_OK) { - return result; - } - flashWrite.fullname = fullname; - if(not std::filesystem::exists(flashWrite.fullname)) { - return FILE_NOT_EXISTS; - } - flashWrite.address = address; - flashWrite.region = region; - internalState = InternalState::FLASH_WRITE; - semaphore.release(); - terminate = false; - return RETURN_OK; -} - -ReturnValue_t StrHelper::startFlashRead(std::string path, uint8_t region, - uint32_t address, uint32_t length) { - ReturnValue_t result = checkPath(path); - if (result != RETURN_OK) { - return result; - } - flashRead.path = path; - if(not std::filesystem::exists(flashRead.path)) { - return FILE_NOT_EXISTS; - } - flashRead.address = address; - flashRead.region = region; - flashRead.size = length; - internalState = InternalState::FLASH_READ; - semaphore.release(); - terminate = false; - return RETURN_OK; +ReturnValue_t StrHelper::startFlashRead(std::string path, uint8_t region, uint32_t address, + uint32_t length) { + ReturnValue_t result = checkPath(path); + if (result != RETURN_OK) { + return result; + } + flashRead.path = path; + if (not std::filesystem::exists(flashRead.path)) { + return FILE_NOT_EXISTS; + } + flashRead.address = address; + flashRead.region = region; + flashRead.size = length; + internalState = InternalState::FLASH_READ; + semaphore.release(); + terminate = false; + return RETURN_OK; } ReturnValue_t StrHelper::startFpgaDownload(std::string path, uint32_t startPosition, - uint32_t length) { - fpgaDownload.path = path; - fpgaDownload.startPosition = startPosition; - fpgaDownload.length = length; - internalState = InternalState::DOWNLOAD_FPGA_IMAGE; - semaphore.release(); - terminate = false; - return RETURN_OK; + uint32_t length) { + fpgaDownload.path = path; + fpgaDownload.startPosition = startPosition; + fpgaDownload.length = length; + internalState = InternalState::DOWNLOAD_FPGA_IMAGE; + semaphore.release(); + terminate = false; + return RETURN_OK; } ReturnValue_t StrHelper::startFpgaUpload(std::string uploadFile) { - fpgaUpload.uploadFile = uploadFile; - internalState = InternalState::UPLOAD_FPGA_IMAGE; - semaphore.release(); - terminate = false; - return RETURN_OK; + fpgaUpload.uploadFile = uploadFile; + internalState = InternalState::UPLOAD_FPGA_IMAGE; + semaphore.release(); + terminate = false; + return RETURN_OK; } ReturnValue_t StrHelper::performImageDownload() { - ReturnValue_t result; - struct DownloadActionRequest downloadReq; - uint32_t size = 0; - uint32_t retries = 0; - Timestamp timestamp; - std::string image = downloadImage.path + "/" + timestamp.str() + downloadImage.filename ; - std::ofstream file(image, std::ios_base::app | std::ios_base::out); - if(not std::filesystem::exists(image)) { - return FILE_CREATION_FAILED; + ReturnValue_t result; + struct DownloadActionRequest downloadReq; + uint32_t size = 0; + uint32_t retries = 0; + Timestamp timestamp; + std::string image = downloadImage.path + "/" + timestamp.str() + downloadImage.filename; + std::ofstream file(image, std::ios_base::app | std::ios_base::out); + if (not std::filesystem::exists(image)) { + return FILE_CREATION_FAILED; + } + downloadReq.position = 0; + while (downloadReq.position < ImageDownload::LAST_POSITION) { + if (terminate) { + return RETURN_OK; } - downloadReq.position = 0; - while(downloadReq.position < ImageDownload::LAST_POSITION) { - if (terminate) { - return RETURN_OK; - } - arc_pack_download_action_req(&downloadReq, commandBuffer, &size); - result = sendAndRead(size, downloadReq.position); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - result = checkActionReply(); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - result = checkReplyPosition(downloadReq.position); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - file.write(reinterpret_cast(datalinkLayer.getReply() + IMAGE_DATA_OFFSET), - IMAGE_DATA_SIZE); - downloadReq.position++; - retries = 0; + arc_pack_download_action_req(&downloadReq, commandBuffer, &size); + result = sendAndRead(size, downloadReq.position); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; } - file.close(); - return RETURN_OK; + result = checkActionReply(); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + result = checkReplyPosition(downloadReq.position); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + file.write(reinterpret_cast(datalinkLayer.getReply() + IMAGE_DATA_OFFSET), + IMAGE_DATA_SIZE); + downloadReq.position++; + retries = 0; + } + file.close(); + return RETURN_OK; } ReturnValue_t StrHelper::performImageUpload() { - ReturnValue_t result = RETURN_OK; - uint32_t size = 0; - uint32_t imageSize = 0; - struct UploadActionRequest uploadReq; - uploadReq.position = 0; - std::memset(&uploadReq.data, 0, sizeof(uploadReq.data)); - if (not std::filesystem::exists(uploadImage.uploadFile)) { - triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast(internalState)); - internalState = InternalState::IDLE; - return RETURN_FAILED; + ReturnValue_t result = RETURN_OK; + uint32_t size = 0; + uint32_t imageSize = 0; + struct UploadActionRequest uploadReq; + uploadReq.position = 0; + std::memset(&uploadReq.data, 0, sizeof(uploadReq.data)); + if (not std::filesystem::exists(uploadImage.uploadFile)) { + triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast(internalState)); + internalState = InternalState::IDLE; + return RETURN_FAILED; + } + std::ifstream file(uploadImage.uploadFile, std::ifstream::binary); + // Set position of next character to end of file input stream + file.seekg(0, file.end); + // tellg returns position of character in input stream + imageSize = file.tellg(); + while ((uploadReq.position + 1) * SIZE_IMAGE_PART < imageSize) { + if (terminate) { + return RETURN_OK; } - std::ifstream file(uploadImage.uploadFile, std::ifstream::binary); - // Set position of next character to end of file input stream - file.seekg(0, file.end); - // tellg returns position of character in input stream - imageSize = file.tellg(); - while((uploadReq.position + 1) * SIZE_IMAGE_PART < imageSize) { - if (terminate) { - return RETURN_OK; - } - file.seekg(uploadReq.position * SIZE_IMAGE_PART, file.beg); - file.read(reinterpret_cast(uploadReq.data), SIZE_IMAGE_PART); - arc_pack_upload_action_req(&uploadReq, commandBuffer, &size); - result = sendAndRead(size, uploadReq.position); - if (result != RETURN_OK) { - return RETURN_FAILED; - } - result = checkActionReply(); - if (result != RETURN_OK) { - return result; - } - uploadReq.position++; - } - std::memset(uploadReq.data, 0, sizeof(uploadReq.data)); - uint32_t remainder = imageSize - uploadReq.position * SIZE_IMAGE_PART; file.seekg(uploadReq.position * SIZE_IMAGE_PART, file.beg); - file.read(reinterpret_cast(uploadReq.data), remainder); - file.close(); - uploadReq.position++; + file.read(reinterpret_cast(uploadReq.data), SIZE_IMAGE_PART); arc_pack_upload_action_req(&uploadReq, commandBuffer, &size); result = sendAndRead(size, uploadReq.position); if (result != RETURN_OK) { - return RETURN_FAILED; + return RETURN_FAILED; } result = checkActionReply(); if (result != RETURN_OK) { - return result; + return result; } - return RETURN_OK; + uploadReq.position++; + } + std::memset(uploadReq.data, 0, sizeof(uploadReq.data)); + uint32_t remainder = imageSize - uploadReq.position * SIZE_IMAGE_PART; + file.seekg(uploadReq.position * SIZE_IMAGE_PART, file.beg); + file.read(reinterpret_cast(uploadReq.data), remainder); + file.close(); + uploadReq.position++; + arc_pack_upload_action_req(&uploadReq, commandBuffer, &size); + result = sendAndRead(size, uploadReq.position); + if (result != RETURN_OK) { + return RETURN_FAILED; + } + result = checkActionReply(); + if (result != RETURN_OK) { + return result; + } + return RETURN_OK; } ReturnValue_t StrHelper::performFlashWrite() { - ReturnValue_t result = RETURN_OK; - uint32_t size = 0; - uint32_t remainingBytes = 0; - uint32_t fileSize = 0; - struct WriteActionRequest req; - if (not std::filesystem::exists(flashWrite.fullname)) { - triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast(internalState)); - internalState = InternalState::IDLE; - return RETURN_FAILED; - } - std::ifstream file(flashWrite.fullname, std::ifstream::binary); - file.seekg(0, file.end); - fileSize = file.tellg(); - remainingBytes = fileSize; - req.region = flashWrite.region; - req.address = flashWrite.address; - req.length = MAX_FLASH_DATA; - while(remainingBytes >= MAX_FLASH_DATA) { - if (terminate) { - return RETURN_OK; - } - file.seekg(fileSize - remainingBytes, file.beg); - file.read(reinterpret_cast(req.data), MAX_FLASH_DATA); - arc_pack_write_action_req(&req, commandBuffer, &size); - result = sendAndRead(size, req.address); - if (result != RETURN_OK) { - return RETURN_FAILED; - } - result = checkFlashActionReply(req.region, req.address, req.length); - if (result != RETURN_OK) { - return result; - } - remainingBytes = remainingBytes - MAX_FLASH_DATA; + ReturnValue_t result = RETURN_OK; + uint32_t size = 0; + uint32_t remainingBytes = 0; + uint32_t fileSize = 0; + struct WriteActionRequest req; + if (not std::filesystem::exists(flashWrite.fullname)) { + triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast(internalState)); + internalState = InternalState::IDLE; + return RETURN_FAILED; + } + std::ifstream file(flashWrite.fullname, std::ifstream::binary); + file.seekg(0, file.end); + fileSize = file.tellg(); + remainingBytes = fileSize; + req.region = flashWrite.region; + req.address = flashWrite.address; + req.length = MAX_FLASH_DATA; + while (remainingBytes >= MAX_FLASH_DATA) { + if (terminate) { + return RETURN_OK; } file.seekg(fileSize - remainingBytes, file.beg); - file.read(reinterpret_cast(req.data), remainingBytes); - file.close(); + file.read(reinterpret_cast(req.data), MAX_FLASH_DATA); arc_pack_write_action_req(&req, commandBuffer, &size); result = sendAndRead(size, req.address); if (result != RETURN_OK) { - return RETURN_FAILED; + return RETURN_FAILED; } result = checkFlashActionReply(req.region, req.address, req.length); if (result != RETURN_OK) { - return result; + return result; } - return RETURN_OK; + remainingBytes = remainingBytes - MAX_FLASH_DATA; + } + file.seekg(fileSize - remainingBytes, file.beg); + file.read(reinterpret_cast(req.data), remainingBytes); + file.close(); + arc_pack_write_action_req(&req, commandBuffer, &size); + result = sendAndRead(size, req.address); + if (result != RETURN_OK) { + return RETURN_FAILED; + } + result = checkFlashActionReply(req.region, req.address, req.length); + if (result != RETURN_OK) { + return result; + } + return RETURN_OK; } ReturnValue_t StrHelper::performFlashRead() { - ReturnValue_t result; - struct ReadActionRequest req; - uint32_t bytesRead = 0; - uint32_t size = 0; - uint32_t retries = 0; - Timestamp timestamp; - std::string fullname = flashRead.path + "/" + timestamp.str() + flashRead.filename ; - std::ofstream file(fullname, std::ios_base::app | std::ios_base::out); - if (not std::filesystem::exists(fullname)) { - return FILE_CREATION_FAILED; + ReturnValue_t result; + struct ReadActionRequest req; + uint32_t bytesRead = 0; + uint32_t size = 0; + uint32_t retries = 0; + Timestamp timestamp; + std::string fullname = flashRead.path + "/" + timestamp.str() + flashRead.filename; + std::ofstream file(fullname, std::ios_base::app | std::ios_base::out); + if (not std::filesystem::exists(fullname)) { + return FILE_CREATION_FAILED; + } + req.region = flashRead.region; + while (bytesRead < flashRead.size) { + if (terminate) { + return RETURN_OK; } - req.region = flashRead.region; - while(bytesRead < flashRead.size) { - if (terminate) { - return RETURN_OK; - } - if ((flashRead.size - bytesRead) < MAX_FLASH_DATA) { - req.length = flashRead.size - bytesRead; - } - else { - req.length = MAX_FLASH_DATA; - } - req.address = flashRead.address + bytesRead; - arc_pack_read_action_req(&req, commandBuffer, &size); - result = sendAndRead(size, req.address); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - result = checkActionReply(); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - result = checkFlashActionReply(req.region, req.address, req.length); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - file.write(reinterpret_cast(datalinkLayer.getReply() + FLASH_READ_DATA_OFFSET), - req.length); - bytesRead += req.length; - retries = 0; + if ((flashRead.size - bytesRead) < MAX_FLASH_DATA) { + req.length = flashRead.size - bytesRead; + } else { + req.length = MAX_FLASH_DATA; } - file.close(); - return RETURN_OK; + req.address = flashRead.address + bytesRead; + arc_pack_read_action_req(&req, commandBuffer, &size); + result = sendAndRead(size, req.address); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + result = checkActionReply(); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + result = checkFlashActionReply(req.region, req.address, req.length); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + file.write(reinterpret_cast(datalinkLayer.getReply() + FLASH_READ_DATA_OFFSET), + req.length); + bytesRead += req.length; + retries = 0; + } + file.close(); + return RETURN_OK; } ReturnValue_t StrHelper::performFpgaDownload() { - ReturnValue_t result; - struct DownloadFPGAImageActionRequest req; - uint32_t size = 0; - uint32_t retries = 0; - Timestamp timestamp; - std::string image = fpgaDownload.path + "/" + timestamp.str() + fpgaDownload.fileName; - std::ofstream file(image, std::ios_base::app | std::ios_base::out); - if(not std::filesystem::exists(image)) { - return FILE_CREATION_FAILED; + ReturnValue_t result; + struct DownloadFPGAImageActionRequest req; + uint32_t size = 0; + uint32_t retries = 0; + Timestamp timestamp; + std::string image = fpgaDownload.path + "/" + timestamp.str() + fpgaDownload.fileName; + std::ofstream file(image, std::ios_base::app | std::ios_base::out); + if (not std::filesystem::exists(image)) { + return FILE_CREATION_FAILED; + } + req.pos = fpgaDownload.startPosition; + while (req.pos < fpgaDownload.length) { + if (terminate) { + return RETURN_OK; } - req.pos = fpgaDownload.startPosition; - while(req.pos < fpgaDownload.length) { - if (terminate) { - return RETURN_OK; - } - if (fpgaDownload.length - req.pos >= FpgaDownload::MAX_DATA) { - req.length = FpgaDownload::MAX_DATA; - } - else { - req.length = fpgaDownload.length - req.pos; - } - arc_pack_downloadfpgaimage_action_req(&req, commandBuffer, &size); - result = sendAndRead(size, req.pos); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - result = checkFpgaActionReply(req.pos, req.length); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - file.write(reinterpret_cast(datalinkLayer.getReply() + FpgaDownload::DATA_OFFSET), - req.length); - req.pos += req.length; - retries = 0; + if (fpgaDownload.length - req.pos >= FpgaDownload::MAX_DATA) { + req.length = FpgaDownload::MAX_DATA; + } else { + req.length = fpgaDownload.length - req.pos; } - file.close(); - return RETURN_OK; + arc_pack_downloadfpgaimage_action_req(&req, commandBuffer, &size); + result = sendAndRead(size, req.pos); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + result = checkFpgaActionReply(req.pos, req.length); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + file.write(reinterpret_cast(datalinkLayer.getReply() + FpgaDownload::DATA_OFFSET), + req.length); + req.pos += req.length; + retries = 0; + } + file.close(); + return RETURN_OK; } ReturnValue_t StrHelper::performFpgaUpload() { - ReturnValue_t result = RETURN_OK; - uint32_t commandSize = 0; - uint32_t bytesUploaded = 0; - uint32_t fileSize = 0; - struct UploadFPGAImageActionRequest req; - if (not std::filesystem::exists(fpgaUpload.uploadFile)) { - triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast(internalState)); - internalState = InternalState::IDLE; - return RETURN_FAILED; + ReturnValue_t result = RETURN_OK; + uint32_t commandSize = 0; + uint32_t bytesUploaded = 0; + uint32_t fileSize = 0; + struct UploadFPGAImageActionRequest req; + if (not std::filesystem::exists(fpgaUpload.uploadFile)) { + triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast(internalState)); + internalState = InternalState::IDLE; + return RETURN_FAILED; + } + std::ifstream file(flashWrite.fullname, std::ifstream::binary); + file.seekg(0, file.end); + fileSize = file.tellg(); + req.pos = 0; + while (bytesUploaded <= fileSize) { + if (terminate) { + return RETURN_OK; } - std::ifstream file(flashWrite.fullname, std::ifstream::binary); - file.seekg(0, file.end); - fileSize = file.tellg(); - req.pos = 0; - while(bytesUploaded <= fileSize) { - if (terminate) { - return RETURN_OK; - } - if (fileSize - bytesUploaded > FpgaUpload::MAX_DATA) { - req.length = FpgaUpload::MAX_DATA; - } - else { - req.length = fileSize - bytesUploaded; - } - file.seekg(bytesUploaded, file.beg); - file.read(reinterpret_cast(req.data), req.length); - arc_pack_uploadfpgaimage_action_req(&req, commandBuffer, &commandSize); - result = sendAndRead(commandSize, req.pos); - if (result != RETURN_OK) { - return RETURN_FAILED; - } - result = checkFpgaActionReply(req.pos, req.length); - if (result != RETURN_OK) { - return result; - } - bytesUploaded += req.length; + if (fileSize - bytesUploaded > FpgaUpload::MAX_DATA) { + req.length = FpgaUpload::MAX_DATA; + } else { + req.length = fileSize - bytesUploaded; } - return RETURN_OK; + file.seekg(bytesUploaded, file.beg); + file.read(reinterpret_cast(req.data), req.length); + arc_pack_uploadfpgaimage_action_req(&req, commandBuffer, &commandSize); + result = sendAndRead(commandSize, req.pos); + if (result != RETURN_OK) { + return RETURN_FAILED; + } + result = checkFpgaActionReply(req.pos, req.length); + if (result != RETURN_OK) { + return result; + } + bytesUploaded += req.length; + } + return RETURN_OK; } ReturnValue_t StrHelper::sendAndRead(size_t size, uint32_t parameter) { - ReturnValue_t result = RETURN_OK; - ReturnValue_t decResult = RETURN_OK; - size_t receivedDataLen = 0; - uint8_t *receivedData = nullptr; - size_t bytesLeft = 0; - uint32_t missedReplies = 0; - datalinkLayer.encodeFrame(commandBuffer, size); - result = uartComIF->sendMessage(comCookie, datalinkLayer.getEncodedFrame(), - datalinkLayer.getEncodedLength()); + ReturnValue_t result = RETURN_OK; + ReturnValue_t decResult = RETURN_OK; + size_t receivedDataLen = 0; + uint8_t* receivedData = nullptr; + size_t bytesLeft = 0; + uint32_t missedReplies = 0; + datalinkLayer.encodeFrame(commandBuffer, size); + result = uartComIF->sendMessage(comCookie, datalinkLayer.getEncodedFrame(), + datalinkLayer.getEncodedLength()); + if (result != RETURN_OK) { + sif::warning << "StrHelper::sendAndRead: Failed to send packet" << std::endl; + triggerEvent(STR_HELPER_SENDING_PACKET_FAILED, result, parameter); + return RETURN_FAILED; + } + decResult = ArcsecDatalinkLayer::DEC_IN_PROGRESS; + while (decResult == ArcsecDatalinkLayer::DEC_IN_PROGRESS) { + result = uartComIF->requestReceiveMessage(comCookie, StarTracker::MAX_FRAME_SIZE * 2 + 2); if (result != RETURN_OK) { - sif::warning << "StrHelper::sendAndRead: Failed to send packet" << std::endl; - triggerEvent(STR_HELPER_SENDING_PACKET_FAILED, result, parameter); - return RETURN_FAILED; + sif::warning << "StrHelper::sendAndRead: Failed to request reply" << std::endl; + triggerEvent(STR_HELPER_REQUESTING_MSG_FAILED, result, parameter); + return RETURN_FAILED; } - decResult = ArcsecDatalinkLayer::DEC_IN_PROGRESS; - while (decResult == ArcsecDatalinkLayer::DEC_IN_PROGRESS) { - result = uartComIF->requestReceiveMessage(comCookie, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - if (result != RETURN_OK) { - sif::warning << "StrHelper::sendAndRead: Failed to request reply" << std::endl; - triggerEvent(STR_HELPER_REQUESTING_MSG_FAILED, result, parameter); - return RETURN_FAILED; - } - result = uartComIF->readReceivedMessage(comCookie, &receivedData, &receivedDataLen); - if (result != RETURN_OK) { - sif::warning << "StrHelper::sendAndRead: Failed to read received message" << std::endl; - triggerEvent(STR_HELPER_READING_REPLY_FAILED, result, parameter); - return RETURN_FAILED; - } - if (receivedDataLen == 0 && missedReplies < MAX_POLLS) { - missedReplies++; - continue; - } - else if ((receivedDataLen == 0) && (missedReplies >= MAX_POLLS)) { - triggerEvent(STR_HELPER_NO_REPLY, parameter); - return RETURN_FAILED; - } - else { - missedReplies = 0; - } - decResult = datalinkLayer.decodeFrame(receivedData, receivedDataLen, &bytesLeft); - if (bytesLeft != 0) { - // This should never happen - sif::warning << "StrHelper::sendAndRead: Bytes left after decoding" << std::endl; - triggerEvent(STR_HELPER_COM_ERROR, result, parameter); - return RETURN_FAILED; - } + result = uartComIF->readReceivedMessage(comCookie, &receivedData, &receivedDataLen); + if (result != RETURN_OK) { + sif::warning << "StrHelper::sendAndRead: Failed to read received message" << std::endl; + triggerEvent(STR_HELPER_READING_REPLY_FAILED, result, parameter); + return RETURN_FAILED; } - if (decResult != RETURN_OK) { - triggerEvent(STR_HELPER_DEC_ERROR, decResult, parameter); - return RETURN_FAILED; + if (receivedDataLen == 0 && missedReplies < MAX_POLLS) { + missedReplies++; + continue; + } else if ((receivedDataLen == 0) && (missedReplies >= MAX_POLLS)) { + triggerEvent(STR_HELPER_NO_REPLY, parameter); + return RETURN_FAILED; + } else { + missedReplies = 0; } - return RETURN_OK; + decResult = datalinkLayer.decodeFrame(receivedData, receivedDataLen, &bytesLeft); + if (bytesLeft != 0) { + // This should never happen + sif::warning << "StrHelper::sendAndRead: Bytes left after decoding" << std::endl; + triggerEvent(STR_HELPER_COM_ERROR, result, parameter); + return RETURN_FAILED; + } + } + if (decResult != RETURN_OK) { + triggerEvent(STR_HELPER_DEC_ERROR, decResult, parameter); + return RETURN_FAILED; + } + return RETURN_OK; } ReturnValue_t StrHelper::checkActionReply() { - uint8_t type = datalinkLayer.getReplyFrameType(); - if (type != TMTC_ACTIONREPLY) { - sif::warning << "StrHelper::checkActionReply: Received reply with invalid type ID" - << std::endl; - return INVALID_TYPE_ID; - } - uint8_t status = datalinkLayer.getStatusField(); - if (status != ArcsecDatalinkLayer::STATUS_OK) { - sif::warning << "StrHelper::checkActionReply: Status failure: " - << static_cast(status) << std::endl; - return STATUS_ERROR; - } - return RETURN_OK; + uint8_t type = datalinkLayer.getReplyFrameType(); + if (type != TMTC_ACTIONREPLY) { + sif::warning << "StrHelper::checkActionReply: Received reply with invalid type ID" << std::endl; + return INVALID_TYPE_ID; + } + uint8_t status = datalinkLayer.getStatusField(); + if (status != ArcsecDatalinkLayer::STATUS_OK) { + sif::warning << "StrHelper::checkActionReply: Status failure: " + << static_cast(status) << std::endl; + return STATUS_ERROR; + } + return RETURN_OK; } ReturnValue_t StrHelper::checkReplyPosition(uint32_t expectedPosition) { - uint32_t receivedPosition = 0; - std::memcpy(&receivedPosition, datalinkLayer.getReply() + POS_OFFSET, sizeof(receivedPosition)); - if (receivedPosition != expectedPosition) { - triggerEvent(POSITION_MISMATCH, receivedPosition); - return RETURN_FAILED; - } - return RETURN_OK; + uint32_t receivedPosition = 0; + std::memcpy(&receivedPosition, datalinkLayer.getReply() + POS_OFFSET, sizeof(receivedPosition)); + if (receivedPosition != expectedPosition) { + triggerEvent(POSITION_MISMATCH, receivedPosition); + return RETURN_FAILED; + } + return RETURN_OK; } ReturnValue_t StrHelper::checkFlashActionReply(uint8_t region_, uint32_t address_, - uint16_t length_) { - ReturnValue_t result = RETURN_OK; - result = checkActionReply(); - if (result != RETURN_OK) { - return result; - } - const uint8_t* data = datalinkLayer.getReply(); - uint8_t region = *(data + REGION_OFFSET); - uint32_t address; - const uint8_t* addressData = data + ADDRESS_OFFSET; - size_t size = sizeof(address); - result = SerializeAdapter::deSerialize(&address, &addressData, &size, - SerializeIF::Endianness::LITTLE); - if (result != RETURN_OK) { - sif::warning << "StrHelper::checkFlashActionReply: Deserialization of address failed" - << std::endl; - return result; - } - uint16_t length = 0; - size = sizeof(length); - const uint8_t* lengthData = data + LENGTH_OFFSET; - result = SerializeAdapter::deSerialize(&length, lengthData, &size, - SerializeIF::Endianness::LITTLE); - if (result != RETURN_OK) { - sif::warning << "StrHelper::checkFlashActionReply: Deserialization of length failed" - << std::endl; - } - if (region != region_) { - return REGION_MISMATCH; - } - if (address != address_) { - return ADDRESS_MISMATCH; - } - if (length != length_) { - return LENGTH_MISMATCH; - } - return RETURN_OK; + uint16_t length_) { + ReturnValue_t result = RETURN_OK; + result = checkActionReply(); + if (result != RETURN_OK) { + return result; + } + const uint8_t* data = datalinkLayer.getReply(); + uint8_t region = *(data + REGION_OFFSET); + uint32_t address; + const uint8_t* addressData = data + ADDRESS_OFFSET; + size_t size = sizeof(address); + result = + SerializeAdapter::deSerialize(&address, &addressData, &size, SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StrHelper::checkFlashActionReply: Deserialization of address failed" + << std::endl; + return result; + } + uint16_t length = 0; + size = sizeof(length); + const uint8_t* lengthData = data + LENGTH_OFFSET; + result = + SerializeAdapter::deSerialize(&length, lengthData, &size, SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StrHelper::checkFlashActionReply: Deserialization of length failed" + << std::endl; + } + if (region != region_) { + return REGION_MISMATCH; + } + if (address != address_) { + return ADDRESS_MISMATCH; + } + if (length != length_) { + return LENGTH_MISMATCH; + } + return RETURN_OK; } -ReturnValue_t StrHelper::checkFpgaActionReply(uint32_t expectedPosition, - uint32_t expectedLength) { - ReturnValue_t result = RETURN_OK; - result = checkActionReply(); - if (result != RETURN_OK) { - return result; - } - const uint8_t* data = datalinkLayer.getReply() + ACTION_DATA_OFFSET; - uint32_t position; - size_t size = sizeof(position); - result = SerializeAdapter::deSerialize(&position, &data, &size, - SerializeIF::Endianness::LITTLE); - if (result != RETURN_OK) { - sif::warning << "StrHelper::checkFpgaActionReply: Deserialization of position failed" - << std::endl; - return result; - } - uint32_t length; - size = sizeof(length); - result = SerializeAdapter::deSerialize(&length, &data, &size, - SerializeIF::Endianness::LITTLE); - if (result != RETURN_OK) { - sif::warning << "StrHelper::checkFpgaActionReply: Deserialization of length failed" - << std::endl; - return result; - } +ReturnValue_t StrHelper::checkFpgaActionReply(uint32_t expectedPosition, uint32_t expectedLength) { + ReturnValue_t result = RETURN_OK; + result = checkActionReply(); + if (result != RETURN_OK) { return result; + } + const uint8_t* data = datalinkLayer.getReply() + ACTION_DATA_OFFSET; + uint32_t position; + size_t size = sizeof(position); + result = SerializeAdapter::deSerialize(&position, &data, &size, SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StrHelper::checkFpgaActionReply: Deserialization of position failed" + << std::endl; + return result; + } + uint32_t length; + size = sizeof(length); + result = SerializeAdapter::deSerialize(&length, &data, &size, SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StrHelper::checkFpgaActionReply: Deserialization of length failed" + << std::endl; + return result; + } + return result; } ReturnValue_t StrHelper::checkPath(std::string name) { - if (name.substr(0, sizeof(SdCardManager::SD_0_MOUNT_POINT)) - == std::string(SdCardManager::SD_0_MOUNT_POINT)) { - if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { - sif::warning << "StrHelper::checkPath: SD card 0 not mounted" << std::endl; - return SD_NOT_MOUNTED; - } - } else if (name.substr(0, sizeof(SdCardManager::SD_1_MOUNT_POINT)) - == std::string(SdCardManager::SD_1_MOUNT_POINT)) { - if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { - sif::warning << "StrHelper::checkPath: SD card 1 not mounted" << std::endl; - return SD_NOT_MOUNTED; - } + if (name.substr(0, sizeof(SdCardManager::SD_0_MOUNT_POINT)) == + std::string(SdCardManager::SD_0_MOUNT_POINT)) { + if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { + sif::warning << "StrHelper::checkPath: SD card 0 not mounted" << std::endl; + return SD_NOT_MOUNTED; } - return RETURN_OK; + } else if (name.substr(0, sizeof(SdCardManager::SD_1_MOUNT_POINT)) == + std::string(SdCardManager::SD_1_MOUNT_POINT)) { + if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { + sif::warning << "StrHelper::checkPath: SD card 1 not mounted" << std::endl; + return SD_NOT_MOUNTED; + } + } + return RETURN_OK; } diff --git a/bsp_q7s/devices/startracker/StrHelper.h b/bsp_q7s/devices/startracker/StrHelper.h index e140a4d6..c08aaae1 100644 --- a/bsp_q7s/devices/startracker/StrHelper.h +++ b/bsp_q7s/devices/startracker/StrHelper.h @@ -2,396 +2,396 @@ #define BSP_Q7S_DEVICES_STRHELPER_H_ #include + #include "ArcsecDatalinkLayer.h" -#include "fsfw/osal/linux/BinarySemaphore.h" #include "bsp_q7s/memory/SdCardManager.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/devicehandlers/CookieIF.h" #include "fsfw/objectmanager/SystemObject.h" +#include "fsfw/osal/linux/BinarySemaphore.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw_hal/linux/uart/UartComIF.h" -#include "fsfw/devicehandlers/CookieIF.h" extern "C" { - #include "thirdparty/arcsec_star_tracker/common/generated/tmtcstructs.h" - #include "thirdparty/arcsec_star_tracker/client/generated/actionreq.h" +#include "thirdparty/arcsec_star_tracker/client/generated/actionreq.h" +#include "thirdparty/arcsec_star_tracker/common/generated/tmtcstructs.h" } /** * @brief Helper class for the star tracker handler to accelerate large data transfers. */ -class StrHelper: public SystemObject, public ExecutableObjectIF, public HasReturnvaluesIF { -public: +class StrHelper : public SystemObject, public ExecutableObjectIF, public HasReturnvaluesIF { + public: + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_HELPER; - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_HELPER; + //! [EXPORT] : [COMMENT] Image upload failed + static const Event IMAGE_UPLOAD_FAILED = MAKE_EVENT(0, severity::LOW); + //! [EXPORT] : [COMMENT] Image download failed + static const Event IMAGE_DOWNLOAD_FAILED = MAKE_EVENT(1, severity::LOW); + //! [EXPORT] : [COMMENT] Uploading image to star tracker was successfulop + static const Event IMAGE_UPLOAD_SUCCESSFUL = MAKE_EVENT(2, severity::LOW); + //! [EXPORT] : [COMMENT] Image download was successful + static const Event IMAGE_DOWNLOAD_SUCCESSFUL = MAKE_EVENT(3, severity::LOW); + //! [EXPORT] : [COMMENT] Finished flash write procedure successfully + static const Event FLASH_WRITE_SUCCESSFUL = MAKE_EVENT(4, severity::LOW); + //! [EXPORT] : [COMMENT] Finished flash read procedure successfully + static const Event FLASH_READ_SUCCESSFUL = MAKE_EVENT(5, severity::LOW); + //! [EXPORT] : [COMMENT] Flash write procedure failed + static const Event FLASH_WRITE_FAILED = MAKE_EVENT(6, severity::LOW); + //! [EXPORT] : [COMMENT] Flash read procedure failed + static const Event FLASH_READ_FAILED = MAKE_EVENT(7, severity::LOW); + //! [EXPORT] : [COMMENT] Download of FPGA image successful + static const Event FPGA_DOWNLOAD_SUCCESSFUL = MAKE_EVENT(8, severity::LOW); + //! [EXPORT] : [COMMENT] Download of FPGA image failed + static const Event FPGA_DOWNLOAD_FAILED = MAKE_EVENT(9, severity::LOW); + //! [EXPORT] : [COMMENT] Upload of FPGA image successful + static const Event FPGA_UPLOAD_SUCCESSFUL = MAKE_EVENT(10, severity::LOW); + //! [EXPORT] : [COMMENT] Upload of FPGA image failed + static const Event FPGA_UPLOAD_FAILED = MAKE_EVENT(11, severity::LOW); + //! [EXPORT] : [COMMENT] Failed to read communication interface reply data + //! P1: Return code of failed communication interface read call + //! P1: Upload/download position for which the read call failed + static const Event STR_HELPER_READING_REPLY_FAILED = MAKE_EVENT(12, severity::LOW); + //! [EXPORT] : [COMMENT] Unexpected stop of decoding sequence + //! P1: Return code of failed communication interface read call + //! P1: Upload/download position for which the read call failed + static const Event STR_HELPER_COM_ERROR = MAKE_EVENT(13, severity::LOW); + //! [EXPORT] : [COMMENT] Star tracker did not send replies (maybe device is powered off) + //! P1: Position of upload or download packet for which no reply was sent + static const Event STR_HELPER_NO_REPLY = MAKE_EVENT(14, severity::LOW); + //! [EXPORT] : [COMMENT] Error during decoding of received reply occurred + // P1: Return value of decoding function + // P2: Position of upload/download packet, or address of flash write/read request + static const Event STR_HELPER_DEC_ERROR = MAKE_EVENT(15, severity::LOW); + //! [EXPORT] : [COMMENT] Position mismatch + //! P1: The expected position and thus the position for which the image upload/download failed + static const Event POSITION_MISMATCH = MAKE_EVENT(16, severity::LOW); + //! [EXPORT] : [COMMENT] Specified file does not exist + //! P1: Internal state of str helper + static const Event STR_HELPER_FILE_NOT_EXISTS = MAKE_EVENT(17, severity::LOW); + //! [EXPORT] : [COMMENT] Sending packet to star tracker failed + //! P1: Return code of communication interface sendMessage function + //! P2: Position of upload/download packet, or address of flash write/read request for which + //! sending failed + static const Event STR_HELPER_SENDING_PACKET_FAILED = MAKE_EVENT(18, severity::LOW); + //! [EXPORT] : [COMMENT] Communication interface requesting reply failed + //! P1: Return code of failed request + //! P1: Upload/download position, or address of flash write/read request for which transmission + //! failed + static const Event STR_HELPER_REQUESTING_MSG_FAILED = MAKE_EVENT(19, severity::LOW); - //! [EXPORT] : [COMMENT] Image upload failed - static const Event IMAGE_UPLOAD_FAILED = MAKE_EVENT(0, severity::LOW); - //! [EXPORT] : [COMMENT] Image download failed - static const Event IMAGE_DOWNLOAD_FAILED = MAKE_EVENT(1, severity::LOW); - //! [EXPORT] : [COMMENT] Uploading image to star tracker was successfulop - static const Event IMAGE_UPLOAD_SUCCESSFUL = MAKE_EVENT(2, severity::LOW); - //! [EXPORT] : [COMMENT] Image download was successful - static const Event IMAGE_DOWNLOAD_SUCCESSFUL = MAKE_EVENT(3, severity::LOW); - //! [EXPORT] : [COMMENT] Finished flash write procedure successfully - static const Event FLASH_WRITE_SUCCESSFUL = MAKE_EVENT(4, severity::LOW); - //! [EXPORT] : [COMMENT] Finished flash read procedure successfully - static const Event FLASH_READ_SUCCESSFUL = MAKE_EVENT(5, severity::LOW); - //! [EXPORT] : [COMMENT] Flash write procedure failed - static const Event FLASH_WRITE_FAILED = MAKE_EVENT(6, severity::LOW); - //! [EXPORT] : [COMMENT] Flash read procedure failed - static const Event FLASH_READ_FAILED = MAKE_EVENT(7, severity::LOW); - //! [EXPORT] : [COMMENT] Download of FPGA image successful - static const Event FPGA_DOWNLOAD_SUCCESSFUL = MAKE_EVENT(8, severity::LOW); - //! [EXPORT] : [COMMENT] Download of FPGA image failed - static const Event FPGA_DOWNLOAD_FAILED = MAKE_EVENT(9, severity::LOW); - //! [EXPORT] : [COMMENT] Upload of FPGA image successful - static const Event FPGA_UPLOAD_SUCCESSFUL = MAKE_EVENT(10, severity::LOW); - //! [EXPORT] : [COMMENT] Upload of FPGA image failed - static const Event FPGA_UPLOAD_FAILED = MAKE_EVENT(11, severity::LOW); - //! [EXPORT] : [COMMENT] Failed to read communication interface reply data - //!P1: Return code of failed communication interface read call - //!P1: Upload/download position for which the read call failed - static const Event STR_HELPER_READING_REPLY_FAILED = MAKE_EVENT(12, severity::LOW); - //! [EXPORT] : [COMMENT] Unexpected stop of decoding sequence - //!P1: Return code of failed communication interface read call - //!P1: Upload/download position for which the read call failed - static const Event STR_HELPER_COM_ERROR = MAKE_EVENT(13, severity::LOW); - //! [EXPORT] : [COMMENT] Star tracker did not send replies (maybe device is powered off) - //!P1: Position of upload or download packet for which no reply was sent - static const Event STR_HELPER_NO_REPLY = MAKE_EVENT(14, severity::LOW); - //! [EXPORT] : [COMMENT] Error during decoding of received reply occurred - //P1: Return value of decoding function - //P2: Position of upload/download packet, or address of flash write/read request - static const Event STR_HELPER_DEC_ERROR = MAKE_EVENT(15, severity::LOW); - //! [EXPORT] : [COMMENT] Position mismatch - //! P1: The expected position and thus the position for which the image upload/download failed - static const Event POSITION_MISMATCH = MAKE_EVENT(16, severity::LOW); - //! [EXPORT] : [COMMENT] Specified file does not exist - //!P1: Internal state of str helper - static const Event STR_HELPER_FILE_NOT_EXISTS = MAKE_EVENT(17, severity::LOW); - //! [EXPORT] : [COMMENT] Sending packet to star tracker failed - //!P1: Return code of communication interface sendMessage function - //!P2: Position of upload/download packet, or address of flash write/read request for which sending failed - static const Event STR_HELPER_SENDING_PACKET_FAILED = MAKE_EVENT(18, severity::LOW); - //! [EXPORT] : [COMMENT] Communication interface requesting reply failed - //!P1: Return code of failed request - //!P1: Upload/download position, or address of flash write/read request for which transmission failed - static const Event STR_HELPER_REQUESTING_MSG_FAILED = MAKE_EVENT(19, severity::LOW); + StrHelper(object_id_t objectId); + virtual ~StrHelper(); - StrHelper(object_id_t objectId); - virtual ~StrHelper(); + ReturnValue_t initialize() override; + ReturnValue_t performOperation(uint8_t operationCode = 0) override; - ReturnValue_t initialize() override; - ReturnValue_t performOperation(uint8_t operationCode = 0) override; + ReturnValue_t setComIF(DeviceCommunicationIF* communicationInterface_); + void setComCookie(CookieIF* comCookie_); - ReturnValue_t setComIF(DeviceCommunicationIF* communicationInterface_); - void setComCookie(CookieIF* comCookie_); + /** + * @brief Starts sequence to upload image to star tracker + * + * @param uploadImage_ Name including absolute path of the image to upload. Must be previously + * transferred to the OBC with the CFDP protocol. + */ + ReturnValue_t startImageUpload(std::string uploadImage_); - /** - * @brief Starts sequence to upload image to star tracker - * - * @param uploadImage_ Name including absolute path of the image to upload. Must be previously - * transferred to the OBC with the CFDP protocol. - */ - ReturnValue_t startImageUpload(std::string uploadImage_); + /** + * @brief Calling this function initiates the download of an image from the star tracker. + * + * @param path Path where downloaded image will be stored + */ + ReturnValue_t startImageDownload(std::string path); - /** - * @brief Calling this function initiates the download of an image from the star tracker. - * - * @param path Path where downloaded image will be stored - */ - ReturnValue_t startImageDownload(std::string path); + /** + * @brief Starts the flash write procedure + * + * @param fullname Full name including absolute path of file to write to flash + * @param region Region ID of flash region to write to + * @param address Start address of flash write procedure + */ + ReturnValue_t startFlashWrite(std::string fullname, uint8_t region, uint32_t address); - /** - * @brief Starts the flash write procedure - * - * @param fullname Full name including absolute path of file to write to flash - * @param region Region ID of flash region to write to - * @param address Start address of flash write procedure - */ - ReturnValue_t startFlashWrite(std::string fullname, uint8_t region, uint32_t address); + /** + * @brief Starts the flash read procedure + * + * @param path Path where file with read flash data will be created + * @param region Region ID of flash region to read from + * @param address Start address of flash section to read + * @param length Number of bytes to read from flash + */ + ReturnValue_t startFlashRead(std::string path, uint8_t region, uint32_t address, uint32_t length); - /** - * @brief Starts the flash read procedure - * - * @param path Path where file with read flash data will be created - * @param region Region ID of flash region to read from - * @param address Start address of flash section to read - * @param length Number of bytes to read from flash - */ - ReturnValue_t startFlashRead(std::string path, uint8_t region, uint32_t address, - uint32_t length); + /** + * @brief Starts the download of the FPGA image + * + * @param path The path where the file with the downloaded data will be created + * @param startPosition Offset in fpga image to read from + * @param length Number of bytes to dwonload from the FPGA image + * + */ + ReturnValue_t startFpgaDownload(std::string path, uint32_t startPosition, uint32_t length); - /** - * @brief Starts the download of the FPGA image - * - * @param path The path where the file with the downloaded data will be created - * @param startPosition Offset in fpga image to read from - * @param length Number of bytes to dwonload from the FPGA image - * - */ - ReturnValue_t startFpgaDownload(std::string path, uint32_t startPosition, uint32_t length); + /** + * @brief Starts upload of new image to FPGA + * + * @param uploadFile Full name of file containing FPGA image data + */ + ReturnValue_t startFpgaUpload(std::string uploadFile); - /** - * @brief Starts upload of new image to FPGA - * - * @param uploadFile Full name of file containing FPGA image data - */ - ReturnValue_t startFpgaUpload(std::string uploadFile); + /** + * @brief Can be used to interrupt a running data transfer. + */ + void stopProcess(); - /** - * @brief Can be used to interrupt a running data transfer. - */ - void stopProcess(); + /** + * @brief Changes the dafault name of downloaded images + */ + void setDownloadImageName(std::string filename); - /** - * @brief Changes the dafault name of downloaded images - */ - void setDownloadImageName(std::string filename); + /** + * @brief Sets the name of the file which will be created to store the data read from flash + */ + void setFlashReadFilename(std::string filename); - /** - * @brief Sets the name of the file which will be created to store the data read from flash - */ - void setFlashReadFilename(std::string filename); + /** + * @brief Set download FPGA image name + */ + void setDownloadFpgaImage(std::string filename); - /** - * @brief Set download FPGA image name - */ - void setDownloadFpgaImage(std::string filename); + private: + static const uint8_t INTERFACE_ID = CLASS_ID::STR_HELPER; -private: + //! [EXPORT] : [COMMENT] SD card specified in 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] Specified path does not exist + static const ReturnValue_t PATH_NOT_EXISTS = MAKE_RETURN_CODE(0xA2); + //! [EXPORT] : [COMMENT] Failed to create download image or read flash file + static const ReturnValue_t FILE_CREATION_FAILED = MAKE_RETURN_CODE(0xA3); + //! [EXPORT] : [COMMENT] Region in flash write/read reply does not match expected region + static const ReturnValue_t REGION_MISMATCH = MAKE_RETURN_CODE(0xA4); + //! [EXPORT] : [COMMENT] Address in flash write/read reply does not match expected address + static const ReturnValue_t ADDRESS_MISMATCH = MAKE_RETURN_CODE(0xA5); + //! [EXPORT] : [COMMENT] Length in flash write/read reply does not match expected length + static const ReturnValue_t LENGTH_MISMATCH = MAKE_RETURN_CODE(0xA6); + //! [EXPORT] : [COMMENT] Status field in reply signals error + static const ReturnValue_t STATUS_ERROR = MAKE_RETURN_CODE(0xA7); + //! [EXPORT] : [COMMENT] Reply has invalid type ID (should be of action reply type) + static const ReturnValue_t INVALID_TYPE_ID = MAKE_RETURN_CODE(0xA8); - static const uint8_t INTERFACE_ID = CLASS_ID::STR_HELPER; + // Size of one image part which can be sent per action request + static const size_t SIZE_IMAGE_PART = 1024; - //! [EXPORT] : [COMMENT] SD card specified in 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] Specified path does not exist - static const ReturnValue_t PATH_NOT_EXISTS = MAKE_RETURN_CODE(0xA2); - //! [EXPORT] : [COMMENT] Failed to create download image or read flash file - static const ReturnValue_t FILE_CREATION_FAILED = MAKE_RETURN_CODE(0xA3); - //! [EXPORT] : [COMMENT] Region in flash write/read reply does not match expected region - static const ReturnValue_t REGION_MISMATCH = MAKE_RETURN_CODE(0xA4); - //! [EXPORT] : [COMMENT] Address in flash write/read reply does not match expected address - static const ReturnValue_t ADDRESS_MISMATCH = MAKE_RETURN_CODE(0xA5); - //! [EXPORT] : [COMMENT] Length in flash write/read reply does not match expected length - static const ReturnValue_t LENGTH_MISMATCH = MAKE_RETURN_CODE(0xA6); - //! [EXPORT] : [COMMENT] Status field in reply signals error - static const ReturnValue_t STATUS_ERROR = MAKE_RETURN_CODE(0xA7); - //! [EXPORT] : [COMMENT] Reply has invalid type ID (should be of action reply type) - static const ReturnValue_t INVALID_TYPE_ID = MAKE_RETURN_CODE(0xA8); + class ImageDownload { + public: + static const uint32_t LAST_POSITION = 4095; + }; - // Size of one image part which can be sent per action request - static const size_t SIZE_IMAGE_PART = 1024; + class FpgaDownload { + public: + static const uint16_t MAX_DATA = 1024; + static const uint8_t DATA_OFFSET = 10; + // Start position of fpga image part to download + uint32_t startPosition = 0; + // Length of image part to download + uint32_t length = 0; + // Path where downloaded FPGA image will be stored + std::string path; + // Name of file containing downloaded FPGA image + std::string fileName = "fpgaimage.bin"; + }; + FpgaDownload fpgaDownload; - class ImageDownload { - public: - static const uint32_t LAST_POSITION = 4095; - }; + class FpgaUpload { + public: + static const uint32_t MAX_DATA = 1024; + // Full name of file to upload + std::string uploadFile; + }; + FpgaUpload fpgaUpload; - class FpgaDownload { - public: - static const uint16_t MAX_DATA = 1024; - static const uint8_t DATA_OFFSET = 10; - // Start position of fpga image part to download - uint32_t startPosition = 0; - // Length of image part to download - uint32_t length = 0; - // Path where downloaded FPGA image will be stored - std::string path; - // Name of file containing downloaded FPGA image - std::string fileName = "fpgaimage.bin"; - }; - FpgaDownload fpgaDownload; + static const uint32_t MAX_POLLS = 10000; - class FpgaUpload { - public: - static const uint32_t MAX_DATA = 1024; - // Full name of file to upload - std::string uploadFile; - }; - FpgaUpload fpgaUpload; + static const uint8_t ACTION_DATA_OFFSET = 2; + static const uint8_t POS_OFFSET = 2; + static const uint8_t IMAGE_DATA_OFFSET = 5; + static const uint8_t FLASH_READ_DATA_OFFSET = 8; + static const uint8_t REGION_OFFSET = 2; + static const uint8_t ADDRESS_OFFSET = 3; + static const uint8_t LENGTH_OFFSET = 7; + static const size_t IMAGE_DATA_SIZE = 1024; + static const size_t MAX_FLASH_DATA = 1024; + static const size_t CONFIG_MAX_DOWNLOAD_RETRIES = 3; - static const uint32_t MAX_POLLS = 10000; + enum class InternalState { + IDLE, + UPLOAD_IMAGE, + DOWNLOAD_IMAGE, + FLASH_WRITE, + FLASH_READ, + DOWNLOAD_FPGA_IMAGE, + UPLOAD_FPGA_IMAGE + }; - static const uint8_t ACTION_DATA_OFFSET = 2; - static const uint8_t POS_OFFSET = 2; - static const uint8_t IMAGE_DATA_OFFSET = 5; - static const uint8_t FLASH_READ_DATA_OFFSET = 8; - static const uint8_t REGION_OFFSET = 2; - static const uint8_t ADDRESS_OFFSET = 3; - static const uint8_t LENGTH_OFFSET = 7; - static const size_t IMAGE_DATA_SIZE = 1024; - static const size_t MAX_FLASH_DATA = 1024; - static const size_t CONFIG_MAX_DOWNLOAD_RETRIES = 3; + InternalState internalState = InternalState::IDLE; - enum class InternalState { - IDLE, - UPLOAD_IMAGE, - DOWNLOAD_IMAGE, - FLASH_WRITE, - FLASH_READ, - DOWNLOAD_FPGA_IMAGE, - UPLOAD_FPGA_IMAGE - }; + ArcsecDatalinkLayer datalinkLayer; - InternalState internalState = InternalState::IDLE; + BinarySemaphore semaphore; - ArcsecDatalinkLayer datalinkLayer; + class UploadImage { + public: + // Name including absolute path of image to upload + std::string uploadFile; + }; + UploadImage uploadImage; - BinarySemaphore semaphore; + class DownloadImage { + public: + // Path where the downloaded image will be stored + std::string path; + // Default name of downloaded image, can be changed via command + std::string filename = "image.bin"; + }; + DownloadImage downloadImage; - class UploadImage { - public: - // Name including absolute path of image to upload - std::string uploadFile; - }; - UploadImage uploadImage; + class FlashWrite { + public: + // File which contains data to write when executing the flash write command + std::string fullname; + // Will be set with the flash write command + uint8_t region = 0; + // Will be set with the flash write command and specifies the start address where to write the + // flash data to + uint32_t address = 0; + }; + FlashWrite flashWrite; - class DownloadImage { - public: - // Path where the downloaded image will be stored - std::string path; - // Default name of downloaded image, can be changed via command - std::string filename = "image.bin"; - }; - DownloadImage downloadImage; + class FlashRead { + public: + // Path where the file containing the read data will be stored + std::string path = ""; + // Default name of file containing the data read from flash, can be changed via command + std::string filename = "flashread.bin"; + // Will be set with the flash read command + uint8_t region = 0; + // Will be set with the flash read command and specifies the start address of the flash section + // to read + uint32_t address = 0; + // Number of bytes to read from flash + uint32_t size = 0; + }; + FlashRead flashRead; - class FlashWrite { - public: - // File which contains data to write when executing the flash write command - std::string fullname; - // Will be set with the flash write command - uint8_t region = 0; - // Will be set with the flash write command and specifies the start address where to write the - // flash data to - uint32_t address = 0; - }; - FlashWrite flashWrite; + SdCardManager* sdcMan = nullptr; - class FlashRead { - public: - // Path where the file containing the read data will be stored - std::string path = ""; - // Default name of file containing the data read from flash, can be changed via command - std::string filename = "flashread.bin"; - // Will be set with the flash read command - uint8_t region = 0; - // Will be set with the flash read command and specifies the start address of the flash section - // to read - uint32_t address = 0; - // Number of bytes to read from flash - uint32_t size = 0; - }; - FlashRead flashRead; + uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE]; - SdCardManager* sdcMan = nullptr; + bool terminate = false; - uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE]; + /** + * UART communication object responsible for low level access of star tracker + * Must be set by star tracker handler + */ + UartComIF* uartComIF = nullptr; + // Communication cookie. Must be set by the star tracker handler + CookieIF* comCookie = nullptr; - bool terminate = false; + // Queue id of raw data receiver + MessageQueueId_t rawDataReceiver = MessageQueueIF::NO_QUEUE; - /** - * UART communication object responsible for low level access of star tracker - * Must be set by star tracker handler - */ - UartComIF* uartComIF = nullptr; - // Communication cookie. Must be set by the star tracker handler - CookieIF* comCookie = nullptr; + /** + * @brief Performs image uploading + */ + ReturnValue_t performImageUpload(); - // Queue id of raw data receiver - MessageQueueId_t rawDataReceiver = MessageQueueIF::NO_QUEUE; + /** + * @brief Performs download of last taken image from the star tracker. + * + * @details Download is split over multiple packets transporting each a maximum of 1024 bytes. + * In case the download of one position fails, the same packet will be again + * requested. If the download of the packet fails CONFIG_MAX_DOWNLOAD_RETRIES times, + * the download will be stopped. + */ + ReturnValue_t performImageDownload(); - /** - * @brief Performs image uploading - */ - ReturnValue_t performImageUpload(); + /** + * @brief Handles flash write procedure + * + * @return RETURN_OK if successful, otherwise RETURN_FAILED + */ + ReturnValue_t performFlashWrite(); - /** - * @brief Performs download of last taken image from the star tracker. - * - * @details Download is split over multiple packets transporting each a maximum of 1024 bytes. - * In case the download of one position fails, the same packet will be again - * requested. If the download of the packet fails CONFIG_MAX_DOWNLOAD_RETRIES times, - * the download will be stopped. - */ - ReturnValue_t performImageDownload(); + /** + * @brief Sends a sequence of commands to the star tracker to read larger parts from the + * flash memory. + */ + ReturnValue_t performFlashRead(); - /** - * @brief Handles flash write procedure - * - * @return RETURN_OK if successful, otherwise RETURN_FAILED - */ - ReturnValue_t performFlashWrite(); + /** + * @brief Performs the download of the FPGA image which requires to be slip over multiple + * action requests. + */ + ReturnValue_t performFpgaDownload(); - /** - * @brief Sends a sequence of commands to the star tracker to read larger parts from the - * flash memory. - */ - ReturnValue_t performFlashRead(); + /** + * @brief Performs upload of new FPGA image. Upload sequence split over multiple commands + * because one command can only transport 1024 bytes of image data. + */ + ReturnValue_t performFpgaUpload(); - /** - * @brief Performs the download of the FPGA image which requires to be slip over multiple - * action requests. - */ - ReturnValue_t performFpgaDownload(); + /** + * @brief Sends packet to the star tracker and reads reply by using the communication + * interface + * + * @param size Size of data beforehand written to the commandBuffer + * @param parameter Parameter 2 of trigger event function + * + * @return RETURN_OK if successful, otherwise RETURN_FAILED + */ + ReturnValue_t sendAndRead(size_t size, uint32_t parameter); - /** - * @brief Performs upload of new FPGA image. Upload sequence split over multiple commands - * because one command can only transport 1024 bytes of image data. - */ - ReturnValue_t performFpgaUpload(); + /** + * @brief Checks the header (type id and status fields) of the action reply + * + * @return RETURN_OK if reply confirms success of packet transfer, otherwise REUTRN_FAILED + */ + ReturnValue_t checkActionReply(); - /** - * @brief Sends packet to the star tracker and reads reply by using the communication - * interface - * - * @param size Size of data beforehand written to the commandBuffer - * @param parameter Parameter 2 of trigger event function - * - * @return RETURN_OK if successful, otherwise RETURN_FAILED - */ - ReturnValue_t sendAndRead(size_t size, uint32_t parameter); + /** + * @brief Checks the position field in a star tracker upload/download reply. + * + * @param expectedPosition Value of expected position + * + * @return RETURN_OK if received position matches expected position, otherwise RETURN_FAILED + */ + ReturnValue_t checkReplyPosition(uint32_t expectedPosition); - /** - * @brief Checks the header (type id and status fields) of the action reply - * - * @return RETURN_OK if reply confirms success of packet transfer, otherwise REUTRN_FAILED - */ - ReturnValue_t checkActionReply(); + /** + * @brief Checks the region, address and length value of a flash write or read reply. + * + * @return RETURN_OK if values match expected values, otherwise appropriate error return + * value. + */ + ReturnValue_t checkFlashActionReply(uint8_t region_, uint32_t address_, uint16_t length_); - /** - * @brief Checks the position field in a star tracker upload/download reply. - * - * @param expectedPosition Value of expected position - * - * @return RETURN_OK if received position matches expected position, otherwise RETURN_FAILED - */ - ReturnValue_t checkReplyPosition(uint32_t expectedPosition); + /** + * @brief Checks the reply to the fpga download and upload request + * + * @param expectedPosition The expected position value in the reply + * @param expectedLength The expected length field in the reply + */ + ReturnValue_t checkFpgaActionReply(uint32_t expectedPosition, uint32_t expectedLength); - /** - * @brief Checks the region, address and length value of a flash write or read reply. - * - * @return RETURN_OK if values match expected values, otherwise appropriate error return - * value. - */ - ReturnValue_t checkFlashActionReply(uint8_t region_, uint32_t address_, uint16_t length_); - - /** - * @brief Checks the reply to the fpga download and upload request - * - * @param expectedPosition The expected position value in the reply - * @param expectedLength The expected length field in the reply - */ - ReturnValue_t checkFpgaActionReply(uint32_t expectedPosition, uint32_t expectedLength); - - /** - * @brief Checks if a path points to an sd card and whether the SD card is monuted. - * - * @return SD_NOT_MOUNTED id SD card is not mounted, otherwise RETURN_OK - */ - ReturnValue_t checkPath(std::string name); + /** + * @brief Checks if a path points to an sd card and whether the SD card is monuted. + * + * @return SD_NOT_MOUNTED id SD card is not mounted, otherwise RETURN_OK + */ + ReturnValue_t checkPath(std::string name); }; #endif /* BSP_Q7S_DEVICES_STRHELPER_H_ */ diff --git a/bsp_q7s/gpio/gpioCallbacks.cpp b/bsp_q7s/gpio/gpioCallbacks.cpp index 2cbf3320..e3033b7d 100644 --- a/bsp_q7s/gpio/gpioCallbacks.cpp +++ b/bsp_q7s/gpio/gpioCallbacks.cpp @@ -1,512 +1,504 @@ #include "gpioCallbacks.h" -#include "busConf.h" + #include - -#include -#include #include +#include +#include +#include "busConf.h" namespace gpioCallbacks { GpioIF* gpioComInterface; void initSpiCsDecoder(GpioIF* gpioComIF) { + ReturnValue_t result; - ReturnValue_t result; + if (gpioComIF == nullptr) { + sif::debug << "initSpiCsDecoder: Invalid gpioComIF" << std::endl; + return; + } - if (gpioComIF == nullptr) { - sif::debug << "initSpiCsDecoder: Invalid gpioComIF" << std::endl; - return; - } + gpioComInterface = gpioComIF; - gpioComInterface = gpioComIF; + GpioCookie* spiMuxGpios = new GpioCookie; - GpioCookie* spiMuxGpios = new GpioCookie; + GpiodRegularByLineName* spiMuxBit = nullptr; + /** Setting mux bit 1 to low will disable IC21 on the interface board */ + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_1_PIN, "SPI Mux Bit 1", + gpio::DIR_OUT, gpio::HIGH); + spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_1, spiMuxBit); + /** Setting mux bit 2 to low disables IC1 on the TCS board */ + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_2_PIN, "SPI Mux Bit 2", + gpio::DIR_OUT, gpio::HIGH); + spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_2, spiMuxBit); + /** Setting mux bit 3 to low disables IC2 on the TCS board and IC22 on the interface board */ + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_3_PIN, "SPI Mux Bit 3", + gpio::DIR_OUT, gpio::LOW); + spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_3, spiMuxBit); - GpiodRegularByLineName* spiMuxBit = nullptr; - /** Setting mux bit 1 to low will disable IC21 on the interface board */ - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_1_PIN, "SPI Mux Bit 1", - gpio::DIR_OUT, gpio::HIGH); - spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_1, spiMuxBit); - /** Setting mux bit 2 to low disables IC1 on the TCS board */ - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_2_PIN, "SPI Mux Bit 2", - gpio::DIR_OUT, gpio::HIGH); - spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_2, spiMuxBit); - /** Setting mux bit 3 to low disables IC2 on the TCS board and IC22 on the interface board */ - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_3_PIN, "SPI Mux Bit 3", - gpio::DIR_OUT, gpio::LOW); - spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_3, spiMuxBit); + // spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_1_PIN, "SPI Mux Bit 1", + // gpio::OUT, gpio::LOW); + // spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_1, spiMuxBit); + // /** Setting mux bit 2 to low disables IC1 on the TCS board */ + // spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_2_PIN, "SPI Mux Bit 2", + // gpio::OUT, gpio::HIGH); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_2, spiMuxBit); + // /** Setting mux bit 3 to low disables IC2 on the TCS board and IC22 on the interface board + // */ spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_3_PIN, "SPI Mux Bit + // 3", gpio::OUT, gpio::LOW); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_3, spiMuxBit); -// spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_1_PIN, "SPI Mux Bit 1", -// gpio::OUT, gpio::LOW); -// spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_1, spiMuxBit); -// /** Setting mux bit 2 to low disables IC1 on the TCS board */ -// spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_2_PIN, "SPI Mux Bit 2", gpio::OUT, gpio::HIGH); -// spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_2, spiMuxBit); -// /** Setting mux bit 3 to low disables IC2 on the TCS board and IC22 on the interface board */ -// spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_3_PIN, "SPI Mux Bit 3", gpio::OUT, gpio::LOW); -// spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_3, spiMuxBit); + /** The following gpios can take arbitrary initial values */ + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_4_PIN, "SPI Mux Bit 4", + gpio::DIR_OUT, gpio::LOW); + spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_4, spiMuxBit); + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_5_PIN, "SPI Mux Bit 5", + gpio::DIR_OUT, gpio::LOW); + spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_5, spiMuxBit); + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_6_PIN, "SPI Mux Bit 6", + gpio::DIR_OUT, gpio::LOW); + spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_6, spiMuxBit); + GpiodRegularByLineName* enRwDecoder = + new GpiodRegularByLineName(q7s::gpioNames::EN_RW_CS, "EN_RW_CS", gpio::DIR_OUT, gpio::HIGH); + spiMuxGpios->addGpio(gpioIds::EN_RW_CS, enRwDecoder); - /** The following gpios can take arbitrary initial values */ - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_4_PIN, "SPI Mux Bit 4", - gpio::DIR_OUT, gpio::LOW); - spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_4, spiMuxBit); - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_5_PIN, "SPI Mux Bit 5", - gpio::DIR_OUT, gpio::LOW); - spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_5, spiMuxBit); - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_6_PIN, "SPI Mux Bit 6", - gpio::DIR_OUT, gpio::LOW); - spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_6, spiMuxBit); - GpiodRegularByLineName* enRwDecoder = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_CS, - "EN_RW_CS", gpio::DIR_OUT, gpio::HIGH); - spiMuxGpios->addGpio(gpioIds::EN_RW_CS, enRwDecoder); - - result = gpioComInterface->addGpios(spiMuxGpios); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "initSpiCsDecoder: Failed to add mux bit gpios to gpioComIF" << std::endl; - return; - } + result = gpioComInterface->addGpios(spiMuxGpios); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "initSpiCsDecoder: Failed to add mux bit gpios to gpioComIF" << std::endl; + return; + } } void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, gpio::Levels value, - void* args) { + void* args) { + if (gpioComInterface == nullptr) { + sif::debug << "spiCsDecoderCallback: No gpioComIF specified. Call initSpiCsDecoder " + << "to specify gpioComIF" << std::endl; + return; + } - if (gpioComInterface == nullptr) { - sif::debug << "spiCsDecoderCallback: No gpioComIF specified. Call initSpiCsDecoder " - << "to specify gpioComIF" << std::endl; - return; - } + /* Reading is not supported by the callback function */ + if (gpioOp == gpio::GpioOperation::READ) { + return; + } - /* Reading is not supported by the callback function */ - if (gpioOp == gpio::GpioOperation::READ) { - return; + if (value == gpio::HIGH) { + switch (gpioId) { + case (gpioIds::RTD_IC_3): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_4): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_5): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_6): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_7): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_8): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_9): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_10): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_11): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_12): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_13): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_14): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_15): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_16): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_17): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_18): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::CS_SUS_1): { + disableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_2): { + disableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_3): { + disableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_4): { + disableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_5): { + disableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_6): { + disableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_7): { + disableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_8): { + disableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_9): { + disableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_10): { + disableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_11): { + disableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_12): { + disableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_13): { + disableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_RW1): { + disableRwDecoder(); + break; + } + case (gpioIds::CS_RW2): { + disableRwDecoder(); + break; + } + case (gpioIds::CS_RW3): { + disableRwDecoder(); + break; + } + case (gpioIds::CS_RW4): { + disableRwDecoder(); + break; + } + default: + sif::debug << "spiCsDecoderCallback: Invalid gpio id " << gpioId << std::endl; } - - if (value == gpio::HIGH) { - switch (gpioId) { - case(gpioIds::RTD_IC_3): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_4): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_5): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_6): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_7): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_8): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_9): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_10): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_11): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_12): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_13): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_14): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_15): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_16): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_17): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_18): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::CS_SUS_1): { - disableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_2): { - disableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_3): { - disableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_4): { - disableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_5): { - disableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_6): { - disableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_7): { - disableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_8): { - disableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_9): { - disableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_10): { - disableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_11): { - disableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_12): { - disableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_13): { - disableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_RW1): { - disableRwDecoder(); - break; - } - case(gpioIds::CS_RW2): { - disableRwDecoder(); - break; - } - case(gpioIds::CS_RW3): { - disableRwDecoder(); - break; - } - case(gpioIds::CS_RW4): { - disableRwDecoder(); - break; - } - default: - sif::debug << "spiCsDecoderCallback: Invalid gpio id " << gpioId << std::endl; - } - } - else if (value == gpio::LOW) { - switch (gpioId) { - case(gpioIds::RTD_IC_3): { - selectY7(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_4): { - selectY6(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_5): { - selectY5(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_6): { - selectY4(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_7): { - selectY3(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_8): { - selectY2(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_9): { - selectY1(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_10): { - selectY0(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_11): { - selectY7(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_12): { - selectY6(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_13): { - selectY5(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_14): { - selectY4(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_15): { - selectY3(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_16): { - selectY2(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_17): { - selectY1(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_18): { - selectY0(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::CS_SUS_1): { - selectY0(); - enableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_2): { - selectY1(); - enableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_3): { - selectY0(); - enableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_4): { - selectY1(); - enableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_5): { - selectY2(); - enableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_6): { - selectY2(); - enableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_7): { - selectY3(); - enableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_8): { - selectY3(); - enableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_9): { - selectY4(); - enableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_10): { - selectY5(); - enableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_11): { - selectY4(); - enableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_12): { - selectY5(); - enableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_13): { - selectY6(); - enableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_RW1): { - selectY0(); - enableRwDecoder(); - break; - } - case(gpioIds::CS_RW2): { - selectY1(); - enableRwDecoder(); - break; - } - case(gpioIds::CS_RW3): { - selectY2(); - enableRwDecoder(); - break; - } - case(gpioIds::CS_RW4): { - selectY3(); - enableRwDecoder(); - break; - } - default: - sif::debug << "spiCsDecoderCallback: Invalid gpio id " << gpioId << std::endl; - } - } - else { - sif::debug << "spiCsDecoderCallback: Invalid value. Must be 0 or 1" << std::endl; + } else if (value == gpio::LOW) { + switch (gpioId) { + case (gpioIds::RTD_IC_3): { + selectY7(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_4): { + selectY6(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_5): { + selectY5(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_6): { + selectY4(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_7): { + selectY3(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_8): { + selectY2(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_9): { + selectY1(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_10): { + selectY0(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_11): { + selectY7(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_12): { + selectY6(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_13): { + selectY5(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_14): { + selectY4(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_15): { + selectY3(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_16): { + selectY2(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_17): { + selectY1(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_18): { + selectY0(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::CS_SUS_1): { + selectY0(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_2): { + selectY1(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_3): { + selectY0(); + enableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_4): { + selectY1(); + enableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_5): { + selectY2(); + enableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_6): { + selectY2(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_7): { + selectY3(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_8): { + selectY3(); + enableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_9): { + selectY4(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_10): { + selectY5(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_11): { + selectY4(); + enableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_12): { + selectY5(); + enableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_13): { + selectY6(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_RW1): { + selectY0(); + enableRwDecoder(); + break; + } + case (gpioIds::CS_RW2): { + selectY1(); + enableRwDecoder(); + break; + } + case (gpioIds::CS_RW3): { + selectY2(); + enableRwDecoder(); + break; + } + case (gpioIds::CS_RW4): { + selectY3(); + enableRwDecoder(); + break; + } + default: + sif::debug << "spiCsDecoderCallback: Invalid gpio id " << gpioId << std::endl; } + } else { + sif::debug << "spiCsDecoderCallback: Invalid value. Must be 0 or 1" << std::endl; + } } void enableDecoderTcsIc1() { - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); } void enableDecoderTcsIc2() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); } void enableDecoderInterfaceBoardIc1() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); } void enableDecoderInterfaceBoardIc2() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); } void disableDecoderTcsIc1() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); } void disableDecoderTcsIc2() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); } void disableDecoderInterfaceBoardIc1() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); } void disableDecoderInterfaceBoardIc2() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); } -void enableRwDecoder() { - gpioComInterface->pullHigh(gpioIds::EN_RW_CS); -} +void enableRwDecoder() { gpioComInterface->pullHigh(gpioIds::EN_RW_CS); } -void disableRwDecoder() { - gpioComInterface->pullLow(gpioIds::EN_RW_CS); -} +void disableRwDecoder() { gpioComInterface->pullLow(gpioIds::EN_RW_CS); } void selectY0() { - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); } void selectY1() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); } void selectY2() { - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); } void selectY3() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); } void selectY4() { - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); } void selectY5() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); } void selectY6() { - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); } void selectY7() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); } void disableAllDecoder() { - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullLow(gpioIds::EN_RW_CS); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullLow(gpioIds::EN_RW_CS); } -} +} // namespace gpioCallbacks diff --git a/bsp_q7s/gpio/gpioCallbacks.h b/bsp_q7s/gpio/gpioCallbacks.h index 18adb52b..6b4e99bf 100644 --- a/bsp_q7s/gpio/gpioCallbacks.h +++ b/bsp_q7s/gpio/gpioCallbacks.h @@ -1,74 +1,73 @@ #ifndef LINUX_GPIO_GPIOCALLBACKS_H_ #define LINUX_GPIO_GPIOCALLBACKS_H_ -#include #include - +#include namespace gpioCallbacks { - /** - * @brief This function initializes the GPIOs used to control the SN74LVC138APWR decoders on - * the TCS Board and the interface board. - */ - void initSpiCsDecoder(GpioIF* gpioComIF); +/** + * @brief This function initializes the GPIOs used to control the SN74LVC138APWR decoders on + * the TCS Board and the interface board. + */ +void initSpiCsDecoder(GpioIF* gpioComIF); - /** - * @brief This function implements the decoding to multiply gpios by using the decoder - * chips SN74LVC138APWR on the TCS board and the interface board. - */ - void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, - gpio::Levels value, void* args); +/** + * @brief This function implements the decoding to multiply gpios by using the decoder + * chips SN74LVC138APWR on the TCS board and the interface board. + */ +void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, gpio::Levels value, + void* args); - /** - * @brief This function sets mux bits 1-3 to a state which will only enable the decoder - * on the TCS board which is named to IC1 in the schematic. - */ - void enableDecoderTcsIc1(); +/** + * @brief This function sets mux bits 1-3 to a state which will only enable the decoder + * on the TCS board which is named to IC1 in the schematic. + */ +void enableDecoderTcsIc1(); - /** - * @brief This function sets mux bits 1-3 to a state which will only enable the decoder - * on the TCS board which is named to IC2 in the schematic. - */ - void enableDecoderTcsIc2(); +/** + * @brief This function sets mux bits 1-3 to a state which will only enable the decoder + * on the TCS board which is named to IC2 in the schematic. + */ +void enableDecoderTcsIc2(); - /** - * @brief This function sets mux bits 1-3 to a state which will only enable the decoder - * on the inteface board board which is named to IC21 in the schematic. - */ - void enableDecoderInterfaceBoardIc1(); +/** + * @brief This function sets mux bits 1-3 to a state which will only enable the decoder + * on the inteface board board which is named to IC21 in the schematic. + */ +void enableDecoderInterfaceBoardIc1(); - /** - * @brief This function sets mux bits 1-3 to a state which will only enable the decoder - * on the inteface board board which is named to IC22 in the schematic. - */ - void enableDecoderInterfaceBoardIc2(); +/** + * @brief This function sets mux bits 1-3 to a state which will only enable the decoder + * on the inteface board board which is named to IC22 in the schematic. + */ +void enableDecoderInterfaceBoardIc2(); - void disableDecoderTcsIc1(); - void disableDecoderTcsIc2(); - void disableDecoderInterfaceBoardIc1(); - void disableDecoderInterfaceBoardIc2(); +void disableDecoderTcsIc1(); +void disableDecoderTcsIc2(); +void disableDecoderInterfaceBoardIc1(); +void disableDecoderInterfaceBoardIc2(); - /** - * @brief Enables the reaction wheel chip select decoder (IC3). - */ - void enableRwDecoder(); - void disableRwDecoder(); +/** + * @brief Enables the reaction wheel chip select decoder (IC3). + */ +void enableRwDecoder(); +void disableRwDecoder(); - /** - * @brief This function disables all decoder. - */ - void disableAllDecoder(); +/** + * @brief This function disables all decoder. + */ +void disableAllDecoder(); - /** The following functions enable the appropriate channel of the currently enabled decoder */ - void selectY0(); - void selectY1(); - void selectY2(); - void selectY3(); - void selectY4(); - void selectY5(); - void selectY6(); - void selectY7(); -} +/** The following functions enable the appropriate channel of the currently enabled decoder */ +void selectY0(); +void selectY1(); +void selectY2(); +void selectY3(); +void selectY4(); +void selectY5(); +void selectY6(); +void selectY7(); +} // namespace gpioCallbacks #endif /* LINUX_GPIO_GPIOCALLBACKS_H_ */ diff --git a/bsp_q7s/main.cpp b/bsp_q7s/main.cpp index 9ce0dca2..dfcaebf0 100644 --- a/bsp_q7s/main.cpp +++ b/bsp_q7s/main.cpp @@ -12,12 +12,11 @@ * @brief This is the main program for the target hardware. * @return */ -int main(void) -{ - using namespace std; +int main(void) { + using namespace std; #if Q7S_SIMPLE_MODE == 0 - return obsw::obsw(); + return obsw::obsw(); #else - return simple::simple(); + return simple::simple(); #endif } diff --git a/bsp_q7s/memory/FileSystemHandler.cpp b/bsp_q7s/memory/FileSystemHandler.cpp index caad94a6..8b5f85c2 100644 --- a/bsp_q7s/memory/FileSystemHandler.cpp +++ b/bsp_q7s/memory/FileSystemHandler.cpp @@ -1,257 +1,241 @@ #include "FileSystemHandler.h" -#include "bsp_q7s/core/CoreController.h" - -#include "fsfw/tasks/TaskFactory.h" -#include "fsfw/memory/GenericFileSystemMessage.h" -#include "fsfw/ipc/QueueFactory.h" - #include -#include #include +#include -FileSystemHandler::FileSystemHandler(object_id_t fileSystemHandler): - SystemObject(fileSystemHandler) { - mq = QueueFactory::instance()->createMessageQueue(FS_MAX_QUEUE_SIZE); +#include "bsp_q7s/core/CoreController.h" +#include "fsfw/ipc/QueueFactory.h" +#include "fsfw/memory/GenericFileSystemMessage.h" +#include "fsfw/tasks/TaskFactory.h" + +FileSystemHandler::FileSystemHandler(object_id_t fileSystemHandler) + : SystemObject(fileSystemHandler) { + mq = QueueFactory::instance()->createMessageQueue(FS_MAX_QUEUE_SIZE); } -FileSystemHandler::~FileSystemHandler() { - QueueFactory::instance()->deleteMessageQueue(mq); -} +FileSystemHandler::~FileSystemHandler() { QueueFactory::instance()->deleteMessageQueue(mq); } ReturnValue_t FileSystemHandler::performOperation(uint8_t unsignedChar) { - while(true) { - try { - fileSystemHandlerLoop(); - } - catch(std::bad_alloc& e) { - // Restart OBSW, hints at a memory leak - sif::error << "Allocation error in FileSystemHandler::performOperation" - << e.what() << std::endl; - // Set up an error file or a special flag in the scratch buffer for these cases - triggerEvent(CoreController::ALLOC_FAILURE, 0 , 0); - CoreController::incrementAllocationFailureCount(); - } + while (true) { + try { + fileSystemHandlerLoop(); + } catch (std::bad_alloc& e) { + // Restart OBSW, hints at a memory leak + sif::error << "Allocation error in FileSystemHandler::performOperation" << e.what() + << std::endl; + // Set up an error file or a special flag in the scratch buffer for these cases + triggerEvent(CoreController::ALLOC_FAILURE, 0, 0); + CoreController::incrementAllocationFailureCount(); } + } } - void FileSystemHandler::fileSystemHandlerLoop() { - CommandMessage filemsg; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - while(true) { - if(opCounter % 5 == 0) { - if(coreCtrl->sdInitFinished()) { - fileSystemCheckup(); - } - } - result = mq->receiveMessage(&filemsg); - if(result == MessageQueueIF::EMPTY) { - break; - } - else if(result != HasReturnvaluesIF::RETURN_FAILED) { - sif::warning << "FileSystemHandler::performOperation: Message reception failed!" - << std::endl; - break; - } - Command_t command = filemsg.getCommand(); - switch(command) { - case(GenericFileSystemMessage::CMD_CREATE_DIRECTORY): { - break; - } - case(GenericFileSystemMessage::CMD_CREATE_FILE): { - break; - } - } - opCounter++; + CommandMessage filemsg; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + while (true) { + if (opCounter % 5 == 0) { + if (coreCtrl->sdInitFinished()) { + fileSystemCheckup(); + } + } + result = mq->receiveMessage(&filemsg); + if (result == MessageQueueIF::EMPTY) { + break; + } else if (result != HasReturnvaluesIF::RETURN_FAILED) { + sif::warning << "FileSystemHandler::performOperation: Message reception failed!" << std::endl; + break; + } + Command_t command = filemsg.getCommand(); + switch (command) { + case (GenericFileSystemMessage::CMD_CREATE_DIRECTORY): { + break; + } + case (GenericFileSystemMessage::CMD_CREATE_FILE): { + break; + } } - - // This task will have a low priority and will run permanently in the background - // so we will just run in a permanent loop here and check file system - // messages permanently opCounter++; - TaskFactory::instance()->delayTask(1000); + } + + // This task will have a low priority and will run permanently in the background + // so we will just run in a permanent loop here and check file system + // messages permanently + opCounter++; + TaskFactory::instance()->delayTask(1000); } void FileSystemHandler::fileSystemCheckup() { - SdCardManager::SdStatePair statusPair; - sdcMan->getSdCardActiveStatus(statusPair); - sd::SdCard preferredSdCard; - sdcMan->getPreferredSdCard(preferredSdCard); - if((preferredSdCard == sd::SdCard::SLOT_0) and - (statusPair.first == sd::SdState::MOUNTED)) { - currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; + SdCardManager::SdStatePair statusPair; + sdcMan->getSdCardActiveStatus(statusPair); + sd::SdCard preferredSdCard; + sdcMan->getPreferredSdCard(preferredSdCard); + if ((preferredSdCard == sd::SdCard::SLOT_0) and (statusPair.first == sd::SdState::MOUNTED)) { + currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; + } else if ((preferredSdCard == sd::SdCard::SLOT_1) and + (statusPair.second == sd::SdState::MOUNTED)) { + currentMountPrefix = SdCardManager::SD_1_MOUNT_POINT; + } else { + std::string sdString; + if (preferredSdCard == sd::SdCard::SLOT_0) { + sdString = "0"; + } else { + sdString = "1"; } - else if((preferredSdCard == sd::SdCard::SLOT_1) and - (statusPair.second == sd::SdState::MOUNTED)) { - currentMountPrefix = SdCardManager::SD_1_MOUNT_POINT; - } - else { - std::string sdString; - if(preferredSdCard == sd::SdCard::SLOT_0) { - sdString = "0"; - } - else { - sdString = "1"; - } - sif::warning << "FileSystemHandler::performOperation: " - "Inconsistent state detected" << std::endl; - sif::warning << "Preferred SD card is " << sdString << - " but does not appear to be mounted. Attempting fix.." << std::endl; - // This function will appear to fix the inconsistent state - ReturnValue_t result = sdcMan->sanitizeState(&statusPair, preferredSdCard); - if(result != HasReturnvaluesIF::RETURN_OK) { - // Oh no. - triggerEvent(SdCardManager::SANITIZATION_FAILED, 0, 0); - sif::error << "FileSystemHandler::fileSystemCheckup: Sanitization failed" << std::endl; - } + sif::warning << "FileSystemHandler::performOperation: " + "Inconsistent state detected" + << std::endl; + sif::warning << "Preferred SD card is " << sdString + << " but does not appear to be mounted. Attempting fix.." << std::endl; + // This function will appear to fix the inconsistent state + ReturnValue_t result = sdcMan->sanitizeState(&statusPair, preferredSdCard); + if (result != HasReturnvaluesIF::RETURN_OK) { + // Oh no. + triggerEvent(SdCardManager::SANITIZATION_FAILED, 0, 0); + sif::error << "FileSystemHandler::fileSystemCheckup: Sanitization failed" << std::endl; } + } } -MessageQueueId_t FileSystemHandler::getCommandQueue() const { - return mq->getId(); -} +MessageQueueId_t FileSystemHandler::getCommandQueue() const { return mq->getId(); } ReturnValue_t FileSystemHandler::initialize() { - coreCtrl = ObjectManager::instance()->get(objects::CORE_CONTROLLER); - if(coreCtrl == nullptr) { - sif::error << "FileSystemHandler::initialize: Could not retrieve core controller handle" << - std::endl; - } - sdcMan = SdCardManager::instance(); - sd::SdCard preferredSdCard; - ReturnValue_t result = sdcMan->getPreferredSdCard(preferredSdCard); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - if(preferredSdCard == sd::SdCard::SLOT_0) { - currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; - } - else if(preferredSdCard == sd::SdCard::SLOT_1) { - currentMountPrefix = SdCardManager::SD_1_MOUNT_POINT; - } - return HasReturnvaluesIF::RETURN_OK; + coreCtrl = ObjectManager::instance()->get(objects::CORE_CONTROLLER); + if (coreCtrl == nullptr) { + sif::error << "FileSystemHandler::initialize: Could not retrieve core controller handle" + << std::endl; + } + sdcMan = SdCardManager::instance(); + sd::SdCard preferredSdCard; + ReturnValue_t result = sdcMan->getPreferredSdCard(preferredSdCard); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + if (preferredSdCard == sd::SdCard::SLOT_0) { + currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; + } else if (preferredSdCard == sd::SdCard::SLOT_1) { + currentMountPrefix = SdCardManager::SD_1_MOUNT_POINT; + } + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t FileSystemHandler::appendToFile(const char* repositoryPath, - const char* filename, const uint8_t* data, size_t size, - uint16_t packetNumber, FileSystemArgsIF* args) { - auto path = getInitPath(args) / repositoryPath / filename; - if(not std::filesystem::exists(path)) { - return FILE_DOES_NOT_EXIST; - } - std::ofstream file(path, std::ios_base::app|std::ios_base::out); - file.write(reinterpret_cast(data), size); - if(not file.good()) { - return GENERIC_FILE_ERROR; - } - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t FileSystemHandler::createFile(const char* repositoryPath, - const char* filename, const uint8_t* data, size_t size, FileSystemArgsIF* args) { - auto path = getInitPath(args) / filename; - if(std::filesystem::exists(path)) { - return FILE_ALREADY_EXISTS; - } - std::ofstream file(path); - file.write(reinterpret_cast(data), size); - if(not file.good()) { - return GENERIC_FILE_ERROR; - } - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t FileSystemHandler::removeFile(const char* repositoryPath, - const char* filename, FileSystemArgsIF* args) { - auto path = getInitPath(args) / repositoryPath / filename; - if(not std::filesystem::exists(path)) { - return FILE_DOES_NOT_EXIST; - } - int result = std::remove(path.c_str()); - if(result != 0) { - sif::warning << "FileSystemHandler::deleteFile: Failed with code " << result << std::endl; - return GENERIC_FILE_ERROR; - } - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t FileSystemHandler:: createDirectory(const char* repositoryPath, const char* dirname, - bool createParentDirs, FileSystemArgsIF* args) { - auto path = getInitPath(args) / repositoryPath / dirname; - if(std::filesystem::exists(path)) { - return DIRECTORY_ALREADY_EXISTS; - } - if(std::filesystem::create_directory(path)) { - return HasReturnvaluesIF::RETURN_OK; - } - sif::warning << "Creating directory " << path << " failed" << std::endl; +ReturnValue_t FileSystemHandler::appendToFile(const char* repositoryPath, const char* filename, + const uint8_t* data, size_t size, + uint16_t packetNumber, FileSystemArgsIF* args) { + auto path = getInitPath(args) / repositoryPath / filename; + if (not std::filesystem::exists(path)) { + return FILE_DOES_NOT_EXIST; + } + std::ofstream file(path, std::ios_base::app | std::ios_base::out); + file.write(reinterpret_cast(data), size); + if (not file.good()) { return GENERIC_FILE_ERROR; + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t FileSystemHandler::createFile(const char* repositoryPath, const char* filename, + const uint8_t* data, size_t size, + FileSystemArgsIF* args) { + auto path = getInitPath(args) / filename; + if (std::filesystem::exists(path)) { + return FILE_ALREADY_EXISTS; + } + std::ofstream file(path); + file.write(reinterpret_cast(data), size); + if (not file.good()) { + return GENERIC_FILE_ERROR; + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t FileSystemHandler::removeFile(const char* repositoryPath, const char* filename, + FileSystemArgsIF* args) { + auto path = getInitPath(args) / repositoryPath / filename; + if (not std::filesystem::exists(path)) { + return FILE_DOES_NOT_EXIST; + } + int result = std::remove(path.c_str()); + if (result != 0) { + sif::warning << "FileSystemHandler::deleteFile: Failed with code " << result << std::endl; + return GENERIC_FILE_ERROR; + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t FileSystemHandler::createDirectory(const char* repositoryPath, const char* dirname, + bool createParentDirs, FileSystemArgsIF* args) { + auto path = getInitPath(args) / repositoryPath / dirname; + if (std::filesystem::exists(path)) { + return DIRECTORY_ALREADY_EXISTS; + } + if (std::filesystem::create_directory(path)) { + return HasReturnvaluesIF::RETURN_OK; + } + sif::warning << "Creating directory " << path << " failed" << std::endl; + return GENERIC_FILE_ERROR; } ReturnValue_t FileSystemHandler::removeDirectory(const char* repositoryPath, const char* dirname, - bool deleteRecurively, FileSystemArgsIF* args) { - auto path = getInitPath(args) / repositoryPath / dirname; - if(not std::filesystem::exists(path)) { - return DIRECTORY_DOES_NOT_EXIST; + bool deleteRecurively, FileSystemArgsIF* args) { + auto path = getInitPath(args) / repositoryPath / dirname; + if (not std::filesystem::exists(path)) { + return DIRECTORY_DOES_NOT_EXIST; + } + std::error_code err; + if (not deleteRecurively) { + if (std::filesystem::remove(path, err)) { + return HasReturnvaluesIF::RETURN_OK; + } else { + // Check error code. Most probably denied permissions because folder is not empty + sif::warning << "FileSystemHandler::removeDirectory: Deleting directory failed with " + "code " + << err.value() << ": " << strerror(err.value()) << std::endl; + if (err.value() == ENOTEMPTY) { + return DIRECTORY_NOT_EMPTY; + } else { + return GENERIC_FILE_ERROR; + } } - std::error_code err; - if(not deleteRecurively) { - if(std::filesystem::remove(path, err)) { - return HasReturnvaluesIF::RETURN_OK; - } - else { - // Check error code. Most probably denied permissions because folder is not empty - sif::warning << "FileSystemHandler::removeDirectory: Deleting directory failed with " - "code " << err.value() << ": " << strerror(err.value()) << std::endl; - if(err.value() == ENOTEMPTY) { - return DIRECTORY_NOT_EMPTY; - } - else { - return GENERIC_FILE_ERROR; - } + } else { + if (std::filesystem::remove_all(path, err)) { + return HasReturnvaluesIF::RETURN_OK; + } else { + sif::warning << "FileSystemHandler::removeDirectory: Deleting directory failed with " + "code " + << err.value() << ": " << strerror(err.value()) << std::endl; + // Check error code + if (err.value() == ENOTEMPTY) { + return DIRECTORY_NOT_EMPTY; + } else { + return GENERIC_FILE_ERROR; + } + } + } - } - } - else { - if(std::filesystem::remove_all(path, err)) { - return HasReturnvaluesIF::RETURN_OK; - } - else { - sif::warning << "FileSystemHandler::removeDirectory: Deleting directory failed with " - "code " << err.value() << ": " << strerror(err.value()) << std::endl; - // Check error code - if(err.value() == ENOTEMPTY) { - return DIRECTORY_NOT_EMPTY; - } - else { - return GENERIC_FILE_ERROR; - } - } - } - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t FileSystemHandler::renameFile(const char *repositoryPath, const char *oldFilename, - const char *newFilename, FileSystemArgsIF *args) { - auto basepath = getInitPath(args) / repositoryPath; - std::filesystem::rename(basepath / oldFilename, basepath / newFilename); - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t FileSystemHandler::renameFile(const char* repositoryPath, const char* oldFilename, + const char* newFilename, FileSystemArgsIF* args) { + auto basepath = getInitPath(args) / repositoryPath; + std::filesystem::rename(basepath / oldFilename, basepath / newFilename); + return HasReturnvaluesIF::RETURN_OK; } -void FileSystemHandler::parseCfg(FsCommandCfg *cfg, bool& useMountPrefix) { - if(cfg != nullptr) { - useMountPrefix = cfg->useMountPrefix; - } +void FileSystemHandler::parseCfg(FsCommandCfg* cfg, bool& useMountPrefix) { + if (cfg != nullptr) { + useMountPrefix = cfg->useMountPrefix; + } } std::filesystem::path FileSystemHandler::getInitPath(FileSystemArgsIF* args) { - bool useMountPrefix = true; - parseCfg(reinterpret_cast(args), useMountPrefix); - std::string path; - if(useMountPrefix) { - path = currentMountPrefix; - } - return std::filesystem::path(path); + bool useMountPrefix = true; + parseCfg(reinterpret_cast(args), useMountPrefix); + std::string path; + if (useMountPrefix) { + path = currentMountPrefix; + } + return std::filesystem::path(path); } diff --git a/bsp_q7s/memory/FileSystemHandler.h b/bsp_q7s/memory/FileSystemHandler.h index 35a0f533..6973c3c8 100644 --- a/bsp_q7s/memory/FileSystemHandler.h +++ b/bsp_q7s/memory/FileSystemHandler.h @@ -1,71 +1,67 @@ #ifndef BSP_Q7S_MEMORY_FILESYSTEMHANDLER_H_ #define BSP_Q7S_MEMORY_FILESYSTEMHANDLER_H_ -#include "SdCardManager.h" -#include "OBSWConfig.h" - -#include "fsfw/ipc/MessageQueueIF.h" -#include "fsfw/tasks/ExecutableObjectIF.h" -#include "fsfw/objectmanager/SystemObject.h" -#include "fsfw/memory/HasFileSystemIF.h" - -#include #include +#include + +#include "OBSWConfig.h" +#include "SdCardManager.h" +#include "fsfw/ipc/MessageQueueIF.h" +#include "fsfw/memory/HasFileSystemIF.h" +#include "fsfw/objectmanager/SystemObject.h" +#include "fsfw/tasks/ExecutableObjectIF.h" class CoreController; -class FileSystemHandler: public SystemObject, - public ExecutableObjectIF, - public HasFileSystemIF { -public: - struct FsCommandCfg: public FileSystemArgsIF { - // Can be used to automatically use mount prefix of active SD card. - // Otherwise, the operator has to specify the full path to the mounted SD card as well. - bool useMountPrefix = false; - }; +class FileSystemHandler : public SystemObject, public ExecutableObjectIF, public HasFileSystemIF { + public: + struct FsCommandCfg : public FileSystemArgsIF { + // Can be used to automatically use mount prefix of active SD card. + // Otherwise, the operator has to specify the full path to the mounted SD card as well. + bool useMountPrefix = false; + }; - FileSystemHandler(object_id_t fileSystemHandler); - virtual~ FileSystemHandler(); + FileSystemHandler(object_id_t fileSystemHandler); + virtual ~FileSystemHandler(); - ReturnValue_t performOperation(uint8_t) override; + ReturnValue_t performOperation(uint8_t) override; - ReturnValue_t initialize() override; + ReturnValue_t initialize() override; - /** - * Function to get the MessageQueueId_t of the implementing object - * @return MessageQueueId_t of the object - */ - MessageQueueId_t getCommandQueue() const override; - ReturnValue_t appendToFile(const char* repositoryPath, - const char* filename, const uint8_t* data, size_t size, - uint16_t packetNumber, FileSystemArgsIF* args = nullptr) override; - ReturnValue_t createFile(const char* repositoryPath, - const char* filename, const uint8_t* data = nullptr, - size_t size = 0, FileSystemArgsIF* args = nullptr) override; - ReturnValue_t removeFile(const char* repositoryPath, - const char* filename, FileSystemArgsIF* args = nullptr) override; - ReturnValue_t createDirectory(const char* repositoryPath, const char* dirname, - bool createParentDirs, FileSystemArgsIF* args = nullptr) override; - ReturnValue_t removeDirectory(const char* repositoryPath, const char* dirname, - bool deleteRecurively = false, FileSystemArgsIF* args = nullptr) override; - ReturnValue_t renameFile(const char* repositoryPath, const char* oldFilename, - const char* newFilename, FileSystemArgsIF* args = nullptr) override; + /** + * Function to get the MessageQueueId_t of the implementing object + * @return MessageQueueId_t of the object + */ + MessageQueueId_t getCommandQueue() const override; + ReturnValue_t appendToFile(const char* repositoryPath, const char* filename, const uint8_t* data, + size_t size, uint16_t packetNumber, + FileSystemArgsIF* args = nullptr) override; + ReturnValue_t createFile(const char* repositoryPath, const char* filename, + const uint8_t* data = nullptr, size_t size = 0, + FileSystemArgsIF* args = nullptr) override; + ReturnValue_t removeFile(const char* repositoryPath, const char* filename, + FileSystemArgsIF* args = nullptr) override; + ReturnValue_t createDirectory(const char* repositoryPath, const char* dirname, + bool createParentDirs, FileSystemArgsIF* args = nullptr) override; + ReturnValue_t removeDirectory(const char* repositoryPath, const char* dirname, + bool deleteRecurively = false, + FileSystemArgsIF* args = nullptr) override; + ReturnValue_t renameFile(const char* repositoryPath, const char* oldFilename, + const char* newFilename, FileSystemArgsIF* args = nullptr) override; -private: - CoreController* coreCtrl = nullptr; - MessageQueueIF* mq = nullptr; - std::string currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; - static constexpr uint32_t FS_MAX_QUEUE_SIZE = config::OBSW_FILESYSTEM_HANDLER_QUEUE_SIZE; + private: + CoreController* coreCtrl = nullptr; + MessageQueueIF* mq = nullptr; + std::string currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; + static constexpr uint32_t FS_MAX_QUEUE_SIZE = config::OBSW_FILESYSTEM_HANDLER_QUEUE_SIZE; - SdCardManager* sdcMan = nullptr; - uint8_t opCounter = 0; + SdCardManager* sdcMan = nullptr; + uint8_t opCounter = 0; - void fileSystemHandlerLoop(); - void fileSystemCheckup(); - std::filesystem::path getInitPath(FileSystemArgsIF* args); - void parseCfg(FsCommandCfg* cfg, bool& useMountPrefix); + void fileSystemHandlerLoop(); + void fileSystemCheckup(); + std::filesystem::path getInitPath(FileSystemArgsIF* args); + void parseCfg(FsCommandCfg* cfg, bool& useMountPrefix); }; - - #endif /* BSP_Q7S_MEMORY_FILESYSTEMMANAGER_H_ */ diff --git a/bsp_q7s/memory/SdCardManager.cpp b/bsp_q7s/memory/SdCardManager.cpp index 8a3d11f2..3647ff7b 100644 --- a/bsp_q7s/memory/SdCardManager.cpp +++ b/bsp_q7s/memory/SdCardManager.cpp @@ -1,487 +1,462 @@ #include "SdCardManager.h" -#include "scratchApi.h" - -#include "linux/utility/utility.h" - -#include "fsfw/ipc/MutexFactory.h" -#include "fsfw/serviceinterface/ServiceInterface.h" #include +#include +#include #include #include -#include -#include + +#include "fsfw/ipc/MutexFactory.h" +#include "fsfw/serviceinterface/ServiceInterface.h" +#include "linux/utility/utility.h" +#include "scratchApi.h" SdCardManager* SdCardManager::factoryInstance = nullptr; -SdCardManager::SdCardManager(): cmdExecutor(256) { -} +SdCardManager::SdCardManager() : cmdExecutor(256) {} -SdCardManager::~SdCardManager() { -} +SdCardManager::~SdCardManager() {} void SdCardManager::create() { - if(factoryInstance == nullptr) { - factoryInstance = new SdCardManager(); - } + if (factoryInstance == nullptr) { + factoryInstance = new SdCardManager(); + } } SdCardManager* SdCardManager::instance() { - SdCardManager::create(); - return SdCardManager::factoryInstance; + SdCardManager::create(); + return SdCardManager::factoryInstance; } ReturnValue_t SdCardManager::switchOnSdCard(sd::SdCard sdCard, bool doMountSdCard, - SdStatePair* statusPair) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - if(doMountSdCard) { - if(not blocking) { - sif::warning << "SdCardManager::switchOnSdCard: Two-step command but manager is" - " not configured for blocking operation. " - "Forcing blocking mode.." << std::endl; - blocking = true; - } + SdStatePair* statusPair) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + if (doMountSdCard) { + if (not blocking) { + sif::warning << "SdCardManager::switchOnSdCard: Two-step command but manager is" + " not configured for blocking operation. " + "Forcing blocking mode.." + << std::endl; + blocking = true; } - std::unique_ptr sdStatusPtr; - if(statusPair == nullptr) { - sdStatusPtr = std::make_unique(); - statusPair = sdStatusPtr.get(); - result = getSdCardActiveStatus(*statusPair); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + } + std::unique_ptr sdStatusPtr; + if (statusPair == nullptr) { + sdStatusPtr = std::make_unique(); + statusPair = sdStatusPtr.get(); + result = getSdCardActiveStatus(*statusPair); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; } + } - // Not allowed, this function turns on one SD card - if(sdCard == sd::SdCard::BOTH) { - sif::warning << "SdCardManager::switchOffSdCard: API does not allow sd::SdStatus::BOTH" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } + // Not allowed, this function turns on one SD card + if (sdCard == sd::SdCard::BOTH) { + sif::warning << "SdCardManager::switchOffSdCard: API does not allow sd::SdStatus::BOTH" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } - sd::SdState currentState; - if(sdCard == sd::SdCard::SLOT_0) { - currentState = statusPair->first; - } - else if(sdCard == sd::SdCard::SLOT_1) { - currentState = statusPair->second; - } - else { - // Should not happen - currentState = sd::SdState::OFF; - } + sd::SdState currentState; + if (sdCard == sd::SdCard::SLOT_0) { + currentState = statusPair->first; + } else if (sdCard == sd::SdCard::SLOT_1) { + currentState = statusPair->second; + } else { + // Should not happen + currentState = sd::SdState::OFF; + } - if(currentState == sd::SdState::ON) { - if(not doMountSdCard) { - return ALREADY_ON; - } - else { - return mountSdCard(sdCard); - } - } - else if(currentState == sd::SdState::MOUNTED) { - result = ALREADY_MOUNTED; - } - else if(currentState == sd::SdState::OFF) { - result = setSdCardState(sdCard, true); - } - else { - result = HasReturnvaluesIF::RETURN_FAILED; + if (currentState == sd::SdState::ON) { + if (not doMountSdCard) { + return ALREADY_ON; + } else { + return mountSdCard(sdCard); } + } else if (currentState == sd::SdState::MOUNTED) { + result = ALREADY_MOUNTED; + } else if (currentState == sd::SdState::OFF) { + result = setSdCardState(sdCard, true); + } else { + result = HasReturnvaluesIF::RETURN_FAILED; + } - if(result != HasReturnvaluesIF::RETURN_OK or not doMountSdCard) { - return result; - } + if (result != HasReturnvaluesIF::RETURN_OK or not doMountSdCard) { + return result; + } - return mountSdCard(sdCard); + return mountSdCard(sdCard); } ReturnValue_t SdCardManager::switchOffSdCard(sd::SdCard sdCard, bool doUnmountSdCard, - SdStatePair* statusPair) { - std::pair active; - ReturnValue_t result = getSdCardActiveStatus(active); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; + SdStatePair* statusPair) { + std::pair active; + ReturnValue_t result = getSdCardActiveStatus(active); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + if (doUnmountSdCard) { + if (not blocking) { + sif::warning << "SdCardManager::switchOffSdCard: Two-step command but manager is" + " not configured for blocking operation. Forcing blocking mode.." + << std::endl; + blocking = true; } - if(doUnmountSdCard) { - if(not blocking) { - sif::warning << "SdCardManager::switchOffSdCard: Two-step command but manager is" - " not configured for blocking operation. Forcing blocking mode.." << std::endl; - blocking = true; - } + } + // Not allowed, this function turns off one SD card + if (sdCard == sd::SdCard::BOTH) { + sif::warning << "SdCardManager::switchOffSdCard: API does not allow sd::SdStatus::BOTH" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + if (sdCard == sd::SdCard::SLOT_0) { + if (active.first == sd::SdState::OFF) { + return ALREADY_OFF; } - // Not allowed, this function turns off one SD card - if(sdCard == sd::SdCard::BOTH) { - sif::warning << "SdCardManager::switchOffSdCard: API does not allow sd::SdStatus::BOTH" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - if(sdCard == sd::SdCard::SLOT_0) { - if(active.first == sd::SdState::OFF) { - return ALREADY_OFF; - } - } - else if(sdCard == sd::SdCard::SLOT_1) { - if(active.second == sd::SdState::OFF) { - return ALREADY_OFF; - } + } else if (sdCard == sd::SdCard::SLOT_1) { + if (active.second == sd::SdState::OFF) { + return ALREADY_OFF; } + } - if(doUnmountSdCard) { - result = unmountSdCard(sdCard); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + if (doUnmountSdCard) { + result = unmountSdCard(sdCard); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; } + } - return setSdCardState(sdCard, false); + return setSdCardState(sdCard, false); } ReturnValue_t SdCardManager::setSdCardState(sd::SdCard sdCard, bool on) { - using namespace std; - if(cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { - return CommandExecutor::COMMAND_PENDING; - } - string sdstring = ""; - string statestring = ""; - if(sdCard == sd::SdCard::SLOT_0) { - sdstring = "0"; - } - else if(sdCard == sd::SdCard::SLOT_1) { - sdstring = "1"; - } - if(on) { - currentOp = Operations::SWITCHING_ON; - statestring = "on"; - } - else { - currentOp = Operations::SWITCHING_OFF; - statestring = "off"; - } - ostringstream command; - command << "q7hw sd set " << sdstring << " " << statestring; - cmdExecutor.load(command.str(), blocking, printCmdOutput); - ReturnValue_t result = cmdExecutor.execute(); - if(blocking and result != HasReturnvaluesIF::RETURN_OK) { - utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::setSdCardState"); - } - return result; + using namespace std; + if (cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { + return CommandExecutor::COMMAND_PENDING; + } + string sdstring = ""; + string statestring = ""; + if (sdCard == sd::SdCard::SLOT_0) { + sdstring = "0"; + } else if (sdCard == sd::SdCard::SLOT_1) { + sdstring = "1"; + } + if (on) { + currentOp = Operations::SWITCHING_ON; + statestring = "on"; + } else { + currentOp = Operations::SWITCHING_OFF; + statestring = "off"; + } + ostringstream command; + command << "q7hw sd set " << sdstring << " " << statestring; + cmdExecutor.load(command.str(), blocking, printCmdOutput); + ReturnValue_t result = cmdExecutor.execute(); + if (blocking and result != HasReturnvaluesIF::RETURN_OK) { + utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::setSdCardState"); + } + return result; } ReturnValue_t SdCardManager::getSdCardActiveStatus(SdStatePair& active) { - using namespace std; - if(not filesystem::exists(SD_STATE_FILE)) { - return STATUS_FILE_NEXISTS; - } + using namespace std; + if (not filesystem::exists(SD_STATE_FILE)) { + return STATUS_FILE_NEXISTS; + } - // Now the file should exist in any case. Still check whether it exists. - fstream sdStatus(SD_STATE_FILE); - if (not sdStatus.good()) { - return STATUS_FILE_NEXISTS; - } - string line; - uint8_t idx = 0; - sd::SdCard currentSd = sd::SdCard::SLOT_0; - // Process status file line by line - while (std::getline(sdStatus, line)) { - processSdStatusLine(active, line, idx, currentSd); - } - return HasReturnvaluesIF::RETURN_OK; + // Now the file should exist in any case. Still check whether it exists. + fstream sdStatus(SD_STATE_FILE); + if (not sdStatus.good()) { + return STATUS_FILE_NEXISTS; + } + string line; + uint8_t idx = 0; + sd::SdCard currentSd = sd::SdCard::SLOT_0; + // Process status file line by line + while (std::getline(sdStatus, line)) { + processSdStatusLine(active, line, idx, currentSd); + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t SdCardManager::mountSdCard(sd::SdCard sdCard) { - using namespace std; - if(cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { - return CommandExecutor::COMMAND_PENDING; - } - if(sdCard == sd::SdCard::BOTH) { - sif::warning << "SdCardManager::mountSdCard: API does not allow sd::SdStatus::BOTH" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - string mountDev; - string mountPoint; - if(sdCard == sd::SdCard::SLOT_0) { - mountDev = SD_0_DEV_NAME; - mountPoint = SD_0_MOUNT_POINT; - } - else if(sdCard == sd::SdCard::SLOT_1) { - mountDev = SD_1_DEV_NAME; - mountPoint = SD_1_MOUNT_POINT; - } - if(not filesystem::exists(mountDev)) { - sif::warning << "SdCardManager::mountSdCard: Device file does not exists. Make sure to" - " turn on the SD card" << std::endl; - return MOUNT_ERROR; - } + using namespace std; + if (cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { + return CommandExecutor::COMMAND_PENDING; + } + if (sdCard == sd::SdCard::BOTH) { + sif::warning << "SdCardManager::mountSdCard: API does not allow sd::SdStatus::BOTH" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + string mountDev; + string mountPoint; + if (sdCard == sd::SdCard::SLOT_0) { + mountDev = SD_0_DEV_NAME; + mountPoint = SD_0_MOUNT_POINT; + } else if (sdCard == sd::SdCard::SLOT_1) { + mountDev = SD_1_DEV_NAME; + mountPoint = SD_1_MOUNT_POINT; + } + if (not filesystem::exists(mountDev)) { + sif::warning << "SdCardManager::mountSdCard: Device file does not exists. Make sure to" + " turn on the SD card" + << std::endl; + return MOUNT_ERROR; + } - if(not blocking) { - currentOp = Operations::MOUNTING; - } - string sdMountCommand = "mount " + mountDev + " " + mountPoint; - cmdExecutor.load(sdMountCommand, blocking, printCmdOutput); - ReturnValue_t result = cmdExecutor.execute(); - if(blocking and result != HasReturnvaluesIF::RETURN_OK) { - utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::mountSdCard"); - } - return result; + if (not blocking) { + currentOp = Operations::MOUNTING; + } + string sdMountCommand = "mount " + mountDev + " " + mountPoint; + cmdExecutor.load(sdMountCommand, blocking, printCmdOutput); + ReturnValue_t result = cmdExecutor.execute(); + if (blocking and result != HasReturnvaluesIF::RETURN_OK) { + utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::mountSdCard"); + } + return result; } ReturnValue_t SdCardManager::unmountSdCard(sd::SdCard sdCard) { - if(cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { - return CommandExecutor::COMMAND_PENDING; - } - using namespace std; - if(sdCard == sd::SdCard::BOTH) { - sif::warning << "SdCardManager::unmountSdCard: API does not allow sd::SdStatus::BOTH" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - string mountPoint; - if(sdCard == sd::SdCard::SLOT_0) { - mountPoint = SD_0_MOUNT_POINT; - } - else if(sdCard == sd::SdCard::SLOT_1) { - mountPoint = SD_1_MOUNT_POINT; - } - if(not filesystem::exists(mountPoint)) { - sif::error << "SdCardManager::unmountSdCard: Default mount point " << mountPoint << - "does not exist" << std::endl; - return UNMOUNT_ERROR; - } - if(filesystem::is_empty(mountPoint)) { - // The mount point will always exist, but if it is empty, that is strong hint that - // the SD card was not mounted properly. Still proceed with operation. - sif::warning << "SdCardManager::unmountSdCard: Mount point is empty!" << std::endl; - } - string sdUnmountCommand = "umount " + mountPoint; - if(not blocking) { - currentOp = Operations::UNMOUNTING; - } - cmdExecutor.load(sdUnmountCommand, blocking, printCmdOutput); - ReturnValue_t result = cmdExecutor.execute(); - if(blocking and result != HasReturnvaluesIF::RETURN_OK) { - utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::unmountSdCard"); - } - return result; + if (cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { + return CommandExecutor::COMMAND_PENDING; + } + using namespace std; + if (sdCard == sd::SdCard::BOTH) { + sif::warning << "SdCardManager::unmountSdCard: API does not allow sd::SdStatus::BOTH" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + string mountPoint; + if (sdCard == sd::SdCard::SLOT_0) { + mountPoint = SD_0_MOUNT_POINT; + } else if (sdCard == sd::SdCard::SLOT_1) { + mountPoint = SD_1_MOUNT_POINT; + } + if (not filesystem::exists(mountPoint)) { + sif::error << "SdCardManager::unmountSdCard: Default mount point " << mountPoint + << "does not exist" << std::endl; + return UNMOUNT_ERROR; + } + if (filesystem::is_empty(mountPoint)) { + // The mount point will always exist, but if it is empty, that is strong hint that + // the SD card was not mounted properly. Still proceed with operation. + sif::warning << "SdCardManager::unmountSdCard: Mount point is empty!" << std::endl; + } + string sdUnmountCommand = "umount " + mountPoint; + if (not blocking) { + currentOp = Operations::UNMOUNTING; + } + cmdExecutor.load(sdUnmountCommand, blocking, printCmdOutput); + ReturnValue_t result = cmdExecutor.execute(); + if (blocking and result != HasReturnvaluesIF::RETURN_OK) { + utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::unmountSdCard"); + } + return result; } ReturnValue_t SdCardManager::sanitizeState(SdStatePair* statusPair, sd::SdCard prefSdCard) { - std::unique_ptr sdStatusPtr; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - // Enforce blocking operation for now. Be careful to reset it when returning prematurely! - bool resetNonBlockingState = false; - if(not this->blocking) { - blocking = true; - resetNonBlockingState = true; - } - if(prefSdCard == sd::SdCard::NONE) { - result = getPreferredSdCard(prefSdCard); - if(result != HasReturnvaluesIF::RETURN_OK) {} - } - if(statusPair == nullptr) { - sdStatusPtr = std::make_unique(); - statusPair = sdStatusPtr.get(); - getSdCardActiveStatus(*statusPair); + std::unique_ptr sdStatusPtr; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + // Enforce blocking operation for now. Be careful to reset it when returning prematurely! + bool resetNonBlockingState = false; + if (not this->blocking) { + blocking = true; + resetNonBlockingState = true; + } + if (prefSdCard == sd::SdCard::NONE) { + result = getPreferredSdCard(prefSdCard); + if (result != HasReturnvaluesIF::RETURN_OK) { } + } + if (statusPair == nullptr) { + sdStatusPtr = std::make_unique(); + statusPair = sdStatusPtr.get(); + getSdCardActiveStatus(*statusPair); + } - if(statusPair->first == sd::SdState::ON) { - result = mountSdCard(prefSdCard); - } + if (statusPair->first == sd::SdState::ON) { + result = mountSdCard(prefSdCard); + } - result = switchOnSdCard(prefSdCard, true, statusPair); - if(resetNonBlockingState) { - blocking = false; - } - return result; + result = switchOnSdCard(prefSdCard, true, statusPair); + if (resetNonBlockingState) { + blocking = false; + } + return result; } void SdCardManager::resetState() { - cmdExecutor.reset(); - currentOp = Operations::IDLE; + cmdExecutor.reset(); + currentOp = Operations::IDLE; } -void SdCardManager::processSdStatusLine(std::pair &active, - std::string& line, uint8_t& idx, sd::SdCard& currentSd) { - using namespace std; - istringstream iss(line); - string word; - bool slotLine = false; - bool mountLine = false; - while(iss >> word) { - if (word == "Slot") { - slotLine = true; - } - if(word == "Mounted") { - mountLine = true; - } - - if(slotLine) { - if (word == "1:") { - currentSd = sd::SdCard::SLOT_1; - } - - if(word == "on") { - if(currentSd == sd::SdCard::SLOT_0) { - active.first = sd::SdState::ON; - } - else { - active.second = sd::SdState::ON; - } - } - else if (word == "off") { - if(currentSd == sd::SdCard::SLOT_0) { - active.first = sd::SdState::OFF; - } - else { - active.second = sd::SdState::OFF; - } - } - } - - if(mountLine) { - if(currentSd == sd::SdCard::SLOT_0) { - active.first = sd::SdState::MOUNTED; - } - else { - active.second = sd::SdState::MOUNTED; - } - } - - if(idx > 5) { - sif::warning << "SdCardManager::sdCardActive: /tmp/sd_status.txt has more than 6 " - "lines and might be invalid!" << std::endl; - } +void SdCardManager::processSdStatusLine(std::pair& active, + std::string& line, uint8_t& idx, sd::SdCard& currentSd) { + using namespace std; + istringstream iss(line); + string word; + bool slotLine = false; + bool mountLine = false; + while (iss >> word) { + if (word == "Slot") { + slotLine = true; } - idx++; + if (word == "Mounted") { + mountLine = true; + } + + if (slotLine) { + if (word == "1:") { + currentSd = sd::SdCard::SLOT_1; + } + + if (word == "on") { + if (currentSd == sd::SdCard::SLOT_0) { + active.first = sd::SdState::ON; + } else { + active.second = sd::SdState::ON; + } + } else if (word == "off") { + if (currentSd == sd::SdCard::SLOT_0) { + active.first = sd::SdState::OFF; + } else { + active.second = sd::SdState::OFF; + } + } + } + + if (mountLine) { + if (currentSd == sd::SdCard::SLOT_0) { + active.first = sd::SdState::MOUNTED; + } else { + active.second = sd::SdState::MOUNTED; + } + } + + if (idx > 5) { + sif::warning << "SdCardManager::sdCardActive: /tmp/sd_status.txt has more than 6 " + "lines and might be invalid!" + << std::endl; + } + } + idx++; } ReturnValue_t SdCardManager::getPreferredSdCard(sd::SdCard& sdCard) const { - uint8_t prefSdCard = 0; - ReturnValue_t result = scratch::readNumber(scratch::PREFERED_SDC_KEY, prefSdCard); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - sdCard = static_cast(prefSdCard); - return HasReturnvaluesIF::RETURN_OK; + uint8_t prefSdCard = 0; + ReturnValue_t result = scratch::readNumber(scratch::PREFERED_SDC_KEY, prefSdCard); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + sdCard = static_cast(prefSdCard); + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t SdCardManager::setPreferredSdCard(sd::SdCard sdCard) { - if(sdCard == sd::SdCard::BOTH) { - return HasReturnvaluesIF::RETURN_FAILED; - } - return scratch::writeNumber(scratch::PREFERED_SDC_KEY, static_cast(sdCard)); + if (sdCard == sd::SdCard::BOTH) { + return HasReturnvaluesIF::RETURN_FAILED; + } + return scratch::writeNumber(scratch::PREFERED_SDC_KEY, static_cast(sdCard)); } ReturnValue_t SdCardManager::updateSdCardStateFile() { - if(cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { - return CommandExecutor::COMMAND_PENDING; - } - // Use q7hw utility and pipe the command output into the state file - std::string updateCmd = "q7hw sd info all > " + std::string(SD_STATE_FILE); - cmdExecutor.load(updateCmd, blocking, printCmdOutput); - ReturnValue_t result = cmdExecutor.execute(); - if(blocking and result != HasReturnvaluesIF::RETURN_OK) { - utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::mountSdCard"); - } - return result; + if (cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { + return CommandExecutor::COMMAND_PENDING; + } + // Use q7hw utility and pipe the command output into the state file + std::string updateCmd = "q7hw sd info all > " + std::string(SD_STATE_FILE); + cmdExecutor.load(updateCmd, blocking, printCmdOutput); + ReturnValue_t result = cmdExecutor.execute(); + if (blocking and result != HasReturnvaluesIF::RETURN_OK) { + utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::mountSdCard"); + } + return result; } std::string SdCardManager::getCurrentMountPrefix(sd::SdCard prefSdCard) { - if(prefSdCard == sd::SdCard::NONE) { - ReturnValue_t result = getPreferredSdCard(prefSdCard); - if(result != HasReturnvaluesIF::RETURN_OK) { - return SD_0_MOUNT_POINT; - } - } - if(prefSdCard == sd::SdCard::SLOT_0) { - return SD_0_MOUNT_POINT; - } - else { - return SD_1_MOUNT_POINT; + if (prefSdCard == sd::SdCard::NONE) { + ReturnValue_t result = getPreferredSdCard(prefSdCard); + if (result != HasReturnvaluesIF::RETURN_OK) { + return SD_0_MOUNT_POINT; } + } + if (prefSdCard == sd::SdCard::SLOT_0) { + return SD_0_MOUNT_POINT; + } else { + return SD_1_MOUNT_POINT; + } } -SdCardManager::OpStatus SdCardManager::checkCurrentOp(Operations ¤tOp) { - CommandExecutor::States state = cmdExecutor.getCurrentState(); - if(state == CommandExecutor::States::IDLE or state == CommandExecutor::States::COMMAND_LOADED) { - return OpStatus::IDLE; - } - currentOp = this->currentOp; - bool bytesRead = false; +SdCardManager::OpStatus SdCardManager::checkCurrentOp(Operations& currentOp) { + CommandExecutor::States state = cmdExecutor.getCurrentState(); + if (state == CommandExecutor::States::IDLE or state == CommandExecutor::States::COMMAND_LOADED) { + return OpStatus::IDLE; + } + currentOp = this->currentOp; + bool bytesRead = false; #if OBSW_ENABLE_TIMERS == 1 - Timer timer; - timer.setTimer(100); - uint32_t remainingTimeMs = 0; + Timer timer; + timer.setTimer(100); + uint32_t remainingTimeMs = 0; #endif - while(true) { - ReturnValue_t result = cmdExecutor.check(bytesRead); - // This timer can prevent deadlocks due to missconfigurations + while (true) { + ReturnValue_t result = cmdExecutor.check(bytesRead); + // This timer can prevent deadlocks due to missconfigurations #if OBSW_ENABLE_TIMERS == 1 - timer.getTimer(&remainingTimeMs); - if(remainingTimeMs == 0) { - sif::error << "SdCardManager::checkCurrentOp: Timeout!" << std::endl; - return OpStatus::FAIL; - } -#endif - switch(result) { - case(CommandExecutor::BYTES_READ): { - continue; - } - case(CommandExecutor::EXECUTION_FINISHED): { - return OpStatus::SUCCESS; - } - case(HasReturnvaluesIF::RETURN_OK): { - return OpStatus::ONGOING; - } - case(HasReturnvaluesIF::RETURN_FAILED): { - return OpStatus::FAIL; - } - default: { - sif::warning << "SdCardManager::checkCurrentOp: Unhandled case" << std::endl; - } - } + timer.getTimer(&remainingTimeMs); + if (remainingTimeMs == 0) { + sif::error << "SdCardManager::checkCurrentOp: Timeout!" << std::endl; + return OpStatus::FAIL; } +#endif + switch (result) { + case (CommandExecutor::BYTES_READ): { + continue; + } + case (CommandExecutor::EXECUTION_FINISHED): { + return OpStatus::SUCCESS; + } + case (HasReturnvaluesIF::RETURN_OK): { + return OpStatus::ONGOING; + } + case (HasReturnvaluesIF::RETURN_FAILED): { + return OpStatus::FAIL; + } + default: { + sif::warning << "SdCardManager::checkCurrentOp: Unhandled case" << std::endl; + } + } + } } -void SdCardManager::setBlocking(bool blocking) { - this->blocking = blocking; -} +void SdCardManager::setBlocking(bool blocking) { this->blocking = blocking; } -void SdCardManager::setPrintCommandOutput(bool print) { - this->printCmdOutput = print; - -} +void SdCardManager::setPrintCommandOutput(bool print) { this->printCmdOutput = print; } bool SdCardManager::isSdCardMounted(sd::SdCard sdCard) { - SdCardManager::SdStatePair active; - ReturnValue_t result = this->getSdCardActiveStatus(active); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "SdCardManager::isSdCardMounted: Failed to get SD card active state"; - return false; - } - if (sdCard == sd::SLOT_0) { - if (active.first == sd::MOUNTED) { - return true; - } - else { - return false; - } - } - else if (sdCard == sd::SLOT_1) { - if (active.second == sd::MOUNTED) { - return true; - } - else { - return false; - } - } - else { - sif::debug << "SdCardManager::isSdCardMounted: Unknown SD card specified" << std::endl; - } + SdCardManager::SdStatePair active; + ReturnValue_t result = this->getSdCardActiveStatus(active); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "SdCardManager::isSdCardMounted: Failed to get SD card active state"; return false; + } + if (sdCard == sd::SLOT_0) { + if (active.first == sd::MOUNTED) { + return true; + } else { + return false; + } + } else if (sdCard == sd::SLOT_1) { + if (active.second == sd::MOUNTED) { + return true; + } else { + return false; + } + } else { + sif::debug << "SdCardManager::isSdCardMounted: Unknown SD card specified" << std::endl; + } + return false; } - - diff --git a/bsp_q7s/memory/SdCardManager.h b/bsp_q7s/memory/SdCardManager.h index 6e4930da..4446a102 100644 --- a/bsp_q7s/memory/SdCardManager.h +++ b/bsp_q7s/memory/SdCardManager.h @@ -1,21 +1,20 @@ #ifndef BSP_Q7S_MEMORY_SDCARDACCESSMANAGER_H_ #define BSP_Q7S_MEMORY_SDCARDACCESSMANAGER_H_ -#include "fsfw_hal/linux/CommandExecutor.h" -#include "definitions.h" -#include "returnvalues/classIds.h" -#include "events/subsystemIdRanges.h" - -#include "fsfw/events/Event.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" - #include -#include -#include -#include -#include #include +#include +#include +#include +#include + +#include "definitions.h" +#include "events/subsystemIdRanges.h" +#include "fsfw/events/Event.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw_hal/linux/CommandExecutor.h" +#include "returnvalues/classIds.h" class MutexIF; @@ -24,202 +23,188 @@ class MutexIF; * state */ class SdCardManager { - friend class SdCardAccess; -public: - enum class Operations { - SWITCHING_ON, - SWITCHING_OFF, - MOUNTING, - UNMOUNTING, - IDLE - }; + friend class SdCardAccess; - enum class OpStatus { - IDLE, - TIMEOUT, - ONGOING, - SUCCESS, - FAIL - }; + public: + enum class Operations { SWITCHING_ON, SWITCHING_OFF, MOUNTING, UNMOUNTING, IDLE }; - using SdStatePair = std::pair; + enum class OpStatus { IDLE, TIMEOUT, ONGOING, SUCCESS, FAIL }; - static constexpr uint8_t INTERFACE_ID = CLASS_ID::SD_CARD_MANAGER; + using SdStatePair = std::pair; - static constexpr ReturnValue_t OP_ONGOING = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 0); - static constexpr ReturnValue_t ALREADY_ON = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 1); - static constexpr ReturnValue_t ALREADY_MOUNTED = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 2); - static constexpr ReturnValue_t ALREADY_OFF = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 3); - static constexpr ReturnValue_t STATUS_FILE_NEXISTS = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 10); - static constexpr ReturnValue_t STATUS_FILE_FORMAT_INVALID = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 11); - static constexpr ReturnValue_t MOUNT_ERROR = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 12); - static constexpr ReturnValue_t UNMOUNT_ERROR = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 13); - static constexpr ReturnValue_t SYSTEM_CALL_ERROR = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 14); - static constexpr ReturnValue_t POPEN_CALL_ERROR = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 15); + static constexpr uint8_t INTERFACE_ID = CLASS_ID::SD_CARD_MANAGER; - static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::FILE_SYSTEM; + static constexpr ReturnValue_t OP_ONGOING = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 0); + static constexpr ReturnValue_t ALREADY_ON = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 1); + static constexpr ReturnValue_t ALREADY_MOUNTED = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 2); + static constexpr ReturnValue_t ALREADY_OFF = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 3); + static constexpr ReturnValue_t STATUS_FILE_NEXISTS = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 10); + static constexpr ReturnValue_t STATUS_FILE_FORMAT_INVALID = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 11); + static constexpr ReturnValue_t MOUNT_ERROR = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 12); + static constexpr ReturnValue_t UNMOUNT_ERROR = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 13); + static constexpr ReturnValue_t SYSTEM_CALL_ERROR = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 14); + static constexpr ReturnValue_t POPEN_CALL_ERROR = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 15); - static constexpr Event SANITIZATION_FAILED = event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW); + static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::FILE_SYSTEM; - // C++17 does not support constexpr std::string yet - static constexpr char SD_0_DEV_NAME[] = "/dev/mmcblk0p1"; - static constexpr char SD_1_DEV_NAME[] = "/dev/mmcblk1p1"; - static constexpr char SD_0_MOUNT_POINT[] = "/mnt/sd0"; - static constexpr char SD_1_MOUNT_POINT[] = "/mnt/sd1"; - static constexpr char SD_STATE_FILE[] = "/tmp/sd_status.txt"; + static constexpr Event SANITIZATION_FAILED = event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW); - virtual ~SdCardManager(); + // C++17 does not support constexpr std::string yet + static constexpr char SD_0_DEV_NAME[] = "/dev/mmcblk0p1"; + static constexpr char SD_1_DEV_NAME[] = "/dev/mmcblk1p1"; + static constexpr char SD_0_MOUNT_POINT[] = "/mnt/sd0"; + static constexpr char SD_1_MOUNT_POINT[] = "/mnt/sd1"; + static constexpr char SD_STATE_FILE[] = "/tmp/sd_status.txt"; - static void create(); + virtual ~SdCardManager(); - /** - * Returns the single instance of the SD card manager. - */ - static SdCardManager* instance(); + static void create(); - /** - * Set the preferred SD card which will determine which SD card will be used as the primary - * SD card in hot redundant and cold redundant mode. This function will not switch the - * SD cards which are currently on and mounted, this needs to be implemented by - * an upper layer by using #switchOffSdCard , #switchOnSdCard and #updateSdCardStateFile - * @param sdCard - * @return - */ - ReturnValue_t setPreferredSdCard(sd::SdCard sdCard); + /** + * Returns the single instance of the SD card manager. + */ + static SdCardManager* instance(); - /** - * Get the currently configured preferred SD card - * @param sdCard - * @return - */ - ReturnValue_t getPreferredSdCard(sd::SdCard& sdCard) const; + /** + * Set the preferred SD card which will determine which SD card will be used as the primary + * SD card in hot redundant and cold redundant mode. This function will not switch the + * SD cards which are currently on and mounted, this needs to be implemented by + * an upper layer by using #switchOffSdCard , #switchOnSdCard and #updateSdCardStateFile + * @param sdCard + * @return + */ + ReturnValue_t setPreferredSdCard(sd::SdCard sdCard); - /** - * Switch on the specified SD card. - * @param sdCard - * @param doMountSdCard Mount the SD card after switching it on, which is necessary - * to use it - * @param statusPair If the status pair is already available, it can be passed here - * @return - RETURN_OK on success, ALREADY_ON if it is already on, - * SYSTEM_CALL_ERROR on system error - */ - ReturnValue_t switchOnSdCard(sd::SdCard sdCard, bool doMountSdCard = true, - SdStatePair* statusPair = nullptr); + /** + * Get the currently configured preferred SD card + * @param sdCard + * @return + */ + ReturnValue_t getPreferredSdCard(sd::SdCard& sdCard) const; - /** - * Switch off the specified SD card. - * @param sdCard - * @param doUnmountSdCard Unmount the SD card before switching the card off, which makes - * the operation safer - * @param statusPair If the status pair is already available, it can be passed here - * @return - RETURN_OK on success, ALREADY_ON if it is already on, - * SYSTEM_CALL_ERROR on system error - */ - ReturnValue_t switchOffSdCard(sd::SdCard sdCard, bool doUnmountSdCard = true, - SdStatePair* statusPair = nullptr); + /** + * Switch on the specified SD card. + * @param sdCard + * @param doMountSdCard Mount the SD card after switching it on, which is necessary + * to use it + * @param statusPair If the status pair is already available, it can be passed here + * @return - RETURN_OK on success, ALREADY_ON if it is already on, + * SYSTEM_CALL_ERROR on system error + */ + ReturnValue_t switchOnSdCard(sd::SdCard sdCard, bool doMountSdCard = true, + SdStatePair* statusPair = nullptr); - /** - * Update the state file or creates one if it does not exist. You need to call this - * function before calling #sdCardActive - * @return - * - RETURN_OK if the state file was updated successfully - * - CommandExecutor::COMMAND_PENDING: Non-blocking command is pending - * - RETURN_FAILED: blocking command failed - */ - ReturnValue_t updateSdCardStateFile(); + /** + * Switch off the specified SD card. + * @param sdCard + * @param doUnmountSdCard Unmount the SD card before switching the card off, which makes + * the operation safer + * @param statusPair If the status pair is already available, it can be passed here + * @return - RETURN_OK on success, ALREADY_ON if it is already on, + * SYSTEM_CALL_ERROR on system error + */ + ReturnValue_t switchOffSdCard(sd::SdCard sdCard, bool doUnmountSdCard = true, + SdStatePair* statusPair = nullptr); - /** - * Get the state of the SD cards. If the state file does not exist, this function will - * take care of updating it. If it does not, the function will use the state file to get - * the status of the SD cards and set the field of the provided boolean pair. - * @param active Pair of booleans, where the first entry is the state of the first SD card - * and the second one the state of the second SD card - * @return - RETURN_OK if the state was read successfully - * - STATUS_FILE_FORMAT_INVALID if there was an issue with the state file. The user - * should call #updateSdCardStateFile again in that case - * - STATUS_FILE_NEXISTS if the status file does not exist - */ - ReturnValue_t getSdCardActiveStatus(SdStatePair& active); + /** + * Update the state file or creates one if it does not exist. You need to call this + * function before calling #sdCardActive + * @return + * - RETURN_OK if the state file was updated successfully + * - CommandExecutor::COMMAND_PENDING: Non-blocking command is pending + * - RETURN_FAILED: blocking command failed + */ + ReturnValue_t updateSdCardStateFile(); - /** - * Mount the specified SD card. This is necessary to use it. - * @param sdCard - * @return - */ - ReturnValue_t mountSdCard(sd::SdCard sdCard); - /** - * Unmount the specified SD card. This is recommended before switching it off. The SD card - * can't be used after it has been unmounted. - * @param sdCard - * @return - */ - ReturnValue_t unmountSdCard(sd::SdCard sdCard); + /** + * Get the state of the SD cards. If the state file does not exist, this function will + * take care of updating it. If it does not, the function will use the state file to get + * the status of the SD cards and set the field of the provided boolean pair. + * @param active Pair of booleans, where the first entry is the state of the first SD card + * and the second one the state of the second SD card + * @return - RETURN_OK if the state was read successfully + * - STATUS_FILE_FORMAT_INVALID if there was an issue with the state file. The user + * should call #updateSdCardStateFile again in that case + * - STATUS_FILE_NEXISTS if the status file does not exist + */ + ReturnValue_t getSdCardActiveStatus(SdStatePair& active); - /** - * In case that there is a discrepancy between the preferred SD card and the currently - * mounted one, this function will sanitize the state by attempting to mount the - * currently preferred SD card. If the caller already has state information, it can be - * passed into the function. For now, this operation will be enforced in blocking mode. - * @param statusPair Current SD card status capture with #getSdCardActiveStatus - * @param prefSdCard Preferred SD card captured with #getPreferredSdCard - * @throws std::bad_alloc if one of the two arguments was a nullptr and an allocation failed - * @return - */ - ReturnValue_t sanitizeState(SdStatePair* statusPair = nullptr, - sd::SdCard prefSdCard = sd::SdCard::NONE); + /** + * Mount the specified SD card. This is necessary to use it. + * @param sdCard + * @return + */ + ReturnValue_t mountSdCard(sd::SdCard sdCard); + /** + * Unmount the specified SD card. This is recommended before switching it off. The SD card + * can't be used after it has been unmounted. + * @param sdCard + * @return + */ + ReturnValue_t unmountSdCard(sd::SdCard sdCard); - /** - * If sd::SdCard::NONE is passed as an argument, this function will get the currently - * preferred SD card from the scratch buffer. - * @param prefSdCardPtr - * @return - */ - std::string getCurrentMountPrefix(sd::SdCard prefSdCardPtr = sd::SdCard::NONE); + /** + * In case that there is a discrepancy between the preferred SD card and the currently + * mounted one, this function will sanitize the state by attempting to mount the + * currently preferred SD card. If the caller already has state information, it can be + * passed into the function. For now, this operation will be enforced in blocking mode. + * @param statusPair Current SD card status capture with #getSdCardActiveStatus + * @param prefSdCard Preferred SD card captured with #getPreferredSdCard + * @throws std::bad_alloc if one of the two arguments was a nullptr and an allocation failed + * @return + */ + ReturnValue_t sanitizeState(SdStatePair* statusPair = nullptr, + sd::SdCard prefSdCard = sd::SdCard::NONE); - OpStatus checkCurrentOp(Operations& currentOp); + /** + * If sd::SdCard::NONE is passed as an argument, this function will get the currently + * preferred SD card from the scratch buffer. + * @param prefSdCardPtr + * @return + */ + std::string getCurrentMountPrefix(sd::SdCard prefSdCardPtr = sd::SdCard::NONE); - /** - * If there are issues with the state machine, it can be reset with this function - */ - void resetState(); + OpStatus checkCurrentOp(Operations& currentOp); - void setBlocking(bool blocking); - void setPrintCommandOutput(bool print); + /** + * If there are issues with the state machine, it can be reset with this function + */ + void resetState(); - /** - * @brief Checks if an SD card is mounted - * - * @param sdCard The SD crad to check - * - * @return true if mounted, otherwise false - */ - bool isSdCardMounted(sd::SdCard sdCard); -private: - CommandExecutor cmdExecutor; - Operations currentOp = Operations::IDLE; - bool blocking = false; - bool printCmdOutput = true; + void setBlocking(bool blocking); + void setPrintCommandOutput(bool print); - SdCardManager(); + /** + * @brief Checks if an SD card is mounted + * + * @param sdCard The SD crad to check + * + * @return true if mounted, otherwise false + */ + bool isSdCardMounted(sd::SdCard sdCard); - ReturnValue_t setSdCardState(sd::SdCard sdCard, bool on); + private: + CommandExecutor cmdExecutor; + Operations currentOp = Operations::IDLE; + bool blocking = false; + bool printCmdOutput = true; - void processSdStatusLine(SdStatePair& active, std::string& line, uint8_t& idx, - sd::SdCard& currentSd); + SdCardManager(); - std::string currentPrefix; + ReturnValue_t setSdCardState(sd::SdCard sdCard, bool on); - static SdCardManager* factoryInstance; + void processSdStatusLine(SdStatePair& active, std::string& line, uint8_t& idx, + sd::SdCard& currentSd); + + std::string currentPrefix; + + static SdCardManager* factoryInstance; }; #endif /* BSP_Q7S_MEMORY_SDCARDACCESSMANAGER_H_ */ diff --git a/bsp_q7s/memory/definitions.h b/bsp_q7s/memory/definitions.h index 9e0bca65..53184e4e 100644 --- a/bsp_q7s/memory/definitions.h +++ b/bsp_q7s/memory/definitions.h @@ -5,22 +5,15 @@ namespace sd { -enum SdState: uint8_t { - OFF = 0, - ON = 1, - // A mounted SD card is on as well - MOUNTED = 2 +enum SdState : uint8_t { + OFF = 0, + ON = 1, + // A mounted SD card is on as well + MOUNTED = 2 }; -enum SdCard: uint8_t { - SLOT_0 = 0, - SLOT_1 = 1, - BOTH, - NONE -}; - -} - +enum SdCard : uint8_t { SLOT_0 = 0, SLOT_1 = 1, BOTH, NONE }; +} // namespace sd #endif /* BSP_Q7S_MEMORY_DEFINITIONS_H_ */ diff --git a/bsp_q7s/memory/scratchApi.cpp b/bsp_q7s/memory/scratchApi.cpp index 08d59df1..83bc8239 100644 --- a/bsp_q7s/memory/scratchApi.cpp +++ b/bsp_q7s/memory/scratchApi.cpp @@ -1,49 +1,50 @@ #include "scratchApi.h" ReturnValue_t scratch::writeString(std::string name, std::string string) { - std::ostringstream oss; - oss << "xsc_scratch write " << name << " \"" << string << "\""; - int result = std::system(oss.str().c_str()); - if(result != 0) { - utility::handleSystemError(result, "scratch::writeString"); - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + std::ostringstream oss; + oss << "xsc_scratch write " << name << " \"" << string << "\""; + int result = std::system(oss.str().c_str()); + if (result != 0) { + utility::handleSystemError(result, "scratch::writeString"); + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t scratch::readString(std::string key, std::string &string) { - std::ifstream file; - std::string filename; - ReturnValue_t result = readToFile(key, file, filename); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + std::ifstream file; + std::string filename; + ReturnValue_t result = readToFile(key, file, filename); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } - std::string line; - if (not std::getline(file, line)) { - std::remove(filename.c_str()); - return HasReturnvaluesIF::RETURN_FAILED; - } + std::string line; + if (not std::getline(file, line)) { + std::remove(filename.c_str()); + return HasReturnvaluesIF::RETURN_FAILED; + } - size_t pos = line.find("="); - if(pos == std::string::npos) { - sif::warning << "scratch::readNumber: Output file format invalid, " - "no \"=\" found" << std::endl; - // Could not find value - std::remove(filename.c_str()); - return KEY_NOT_FOUND; - } - string = line.substr(pos + 1); - return HasReturnvaluesIF::RETURN_OK; + size_t pos = line.find("="); + if (pos == std::string::npos) { + sif::warning << "scratch::readNumber: Output file format invalid, " + "no \"=\" found" + << std::endl; + // Could not find value + std::remove(filename.c_str()); + return KEY_NOT_FOUND; + } + string = line.substr(pos + 1); + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t scratch::clearValue(std::string key) { - std::ostringstream oss; - oss << "xsc_scratch clear " << key; - int result = std::system(oss.str().c_str()); - if(result != 0) { - utility::handleSystemError(result, "scratch::clearValue"); - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + std::ostringstream oss; + oss << "xsc_scratch clear " << key; + int result = std::system(oss.str().c_str()); + if (result != 0) { + utility::handleSystemError(result, "scratch::clearValue"); + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } diff --git a/bsp_q7s/memory/scratchApi.h b/bsp_q7s/memory/scratchApi.h index ee19e084..babd26dc 100644 --- a/bsp_q7s/memory/scratchApi.h +++ b/bsp_q7s/memory/scratchApi.h @@ -1,17 +1,17 @@ #ifndef BSP_Q7S_MEMORY_SCRATCHAPI_H_ #define BSP_Q7S_MEMORY_SCRATCHAPI_H_ +#include +#include +#include +#include +#include + #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "linux/utility/utility.h" #include "returnvalues/classIds.h" -#include -#include -#include -#include -#include - /** * @brief API for the scratch buffer */ @@ -48,7 +48,7 @@ ReturnValue_t readString(std::string key, std::string& string); * @param num Number. Template allows to set signed, unsigned and floating point numbers * @return */ -template::value>::type> +template ::value>::type> inline ReturnValue_t writeNumber(std::string key, T num) noexcept; /** @@ -59,90 +59,88 @@ inline ReturnValue_t writeNumber(std::string key, T num) noexcept; * @param num * @return */ -template::value>::type> +template ::value>::type> inline ReturnValue_t readNumber(std::string key, T& num) noexcept; - // Anonymous namespace namespace { static uint8_t counter = 0; ReturnValue_t readToFile(std::string name, std::ifstream& file, std::string& filename) { - using namespace std; - filename = "/tmp/sro" + std::to_string(counter++); - ostringstream oss; - oss << "xsc_scratch read " << name << " > " << filename; + using namespace std; + filename = "/tmp/sro" + std::to_string(counter++); + ostringstream oss; + oss << "xsc_scratch read " << name << " > " << filename; - int result = std::system(oss.str().c_str()); - if(result != 0) { - if(result == 256) { - sif::warning << "scratch::readNumber: Key " << name << " does not exist" << std::endl; - // Could not find value - std::remove(filename.c_str()); - return KEY_NOT_FOUND; - } - else { - utility::handleSystemError(result, "scratch::readNumber"); - std::remove(filename.c_str()); - return HasReturnvaluesIF::RETURN_FAILED; - } + int result = std::system(oss.str().c_str()); + if (result != 0) { + if (result == 256) { + sif::warning << "scratch::readNumber: Key " << name << " does not exist" << std::endl; + // Could not find value + std::remove(filename.c_str()); + return KEY_NOT_FOUND; + } else { + utility::handleSystemError(result, "scratch::readNumber"); + std::remove(filename.c_str()); + return HasReturnvaluesIF::RETURN_FAILED; } - file.open(filename); - return HasReturnvaluesIF::RETURN_OK; + } + file.open(filename); + return HasReturnvaluesIF::RETURN_OK; } -} // End of anonymous namespace +} // End of anonymous namespace -template::value>::type> +template ::value>::type> inline ReturnValue_t writeNumber(std::string key, T num) noexcept { - std::ostringstream oss; - oss << "xsc_scratch write " << key << " " << std::to_string(num); - int result = std::system(oss.str().c_str()); - if(result != 0) { - utility::handleSystemError(result, "scratch::writeNumber"); - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + std::ostringstream oss; + oss << "xsc_scratch write " << key << " " << std::to_string(num); + int result = std::system(oss.str().c_str()); + if (result != 0) { + utility::handleSystemError(result, "scratch::writeNumber"); + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } -template::value>::type> +template ::value>::type> inline ReturnValue_t readNumber(std::string key, T& num) noexcept { - using namespace std; - ifstream file; - std::string filename; - ReturnValue_t result = readToFile(key, file, filename); - if(result != HasReturnvaluesIF::RETURN_OK) { - std::remove(filename.c_str()); - return result; - } - - string line; - if (not std::getline(file, line)) { - std::remove(filename.c_str()); - return HasReturnvaluesIF::RETURN_FAILED; - } - - size_t pos = line.find("="); - if(pos == string::npos) { - sif::warning << "scratch::readNumber: Output file format invalid, " - "no \"=\" found" << std::endl; - // Could not find value - std::remove(filename.c_str()); - return KEY_NOT_FOUND; - } - std::string valueAsString = line.substr(pos + 1); - try { - num = std::stoi(valueAsString); - } - catch(std::invalid_argument& e) { - sif::warning << "scratch::readNumber: stoi call failed with " << e.what() << std::endl; - } - + using namespace std; + ifstream file; + std::string filename; + ReturnValue_t result = readToFile(key, file, filename); + if (result != HasReturnvaluesIF::RETURN_OK) { std::remove(filename.c_str()); - return HasReturnvaluesIF::RETURN_OK; + return result; + } + + string line; + if (not std::getline(file, line)) { + std::remove(filename.c_str()); + return HasReturnvaluesIF::RETURN_FAILED; + } + + size_t pos = line.find("="); + if (pos == string::npos) { + sif::warning << "scratch::readNumber: Output file format invalid, " + "no \"=\" found" + << std::endl; + // Could not find value + std::remove(filename.c_str()); + return KEY_NOT_FOUND; + } + std::string valueAsString = line.substr(pos + 1); + try { + num = std::stoi(valueAsString); + } catch (std::invalid_argument& e) { + sif::warning << "scratch::readNumber: stoi call failed with " << e.what() << std::endl; + } + + std::remove(filename.c_str()); + return HasReturnvaluesIF::RETURN_OK; } -} +} // namespace scratch #endif /* BSP_Q7S_MEMORY_SCRATCHAPI_H_ */ diff --git a/bsp_q7s/simple/simple.cpp b/bsp_q7s/simple/simple.cpp index 960aa7db..b300e456 100644 --- a/bsp_q7s/simple/simple.cpp +++ b/bsp_q7s/simple/simple.cpp @@ -1,4 +1,5 @@ #include "simple.h" + #include "q7sConfig.h" #if Q7S_SIMPLE_ADD_FILE_SYSTEM_TEST == 1 @@ -6,16 +7,13 @@ #endif int simple::simple() { - cout << "-- Q7S Simple Application --" << endl; + cout << "-- Q7S Simple Application --" << endl; #if Q7S_SIMPLE_ADD_FILE_SYSTEM_TEST == 1 - { - FileSystemTest fileSystemTest; - } + { FileSystemTest fileSystemTest; } #endif #if TE0720_GPIO_TEST #endif - return 0; + return 0; } - diff --git a/bsp_q7s/spi/Q7sSpiComIF.cpp b/bsp_q7s/spi/Q7sSpiComIF.cpp index 23dbe551..84552503 100644 --- a/bsp_q7s/spi/Q7sSpiComIF.cpp +++ b/bsp_q7s/spi/Q7sSpiComIF.cpp @@ -1,9 +1,5 @@ #include -Q7sSpiComIF::Q7sSpiComIF(object_id_t objectId, GpioIF* gpioComIF) : - SpiComIF(objectId, gpioComIF) { -} - -Q7sSpiComIF::~Q7sSpiComIF() { -} +Q7sSpiComIF::Q7sSpiComIF(object_id_t objectId, GpioIF* gpioComIF) : SpiComIF(objectId, gpioComIF) {} +Q7sSpiComIF::~Q7sSpiComIF() {} diff --git a/bsp_q7s/spi/Q7sSpiComIF.h b/bsp_q7s/spi/Q7sSpiComIF.h index a10d63dd..def754ab 100644 --- a/bsp_q7s/spi/Q7sSpiComIF.h +++ b/bsp_q7s/spi/Q7sSpiComIF.h @@ -3,7 +3,6 @@ #include - /** * @brief This additional communication interface is required because the SPI busses behind the * devices "/dev/spi2.0" and "dev/spidev3.0" are multiplexed to one SPI interface. @@ -17,17 +16,17 @@ * the SPI interface. The multiplexing is performed via a GPIO connected to a VHDL * module responsible for switching between the to SPI peripherals. */ -class Q7sSpiComIF: public SpiComIF { -public: - /** - * @brief Constructor - * - * @param objectId - * @param gpioComIF - * @param gpioSwitchId The gpio ID of the GPIO connected to the SPI mux module in the PL. - */ - Q7sSpiComIF(object_id_t objectId, GpioIF* gpioComIF, gpioId_t gpioSwitchId); - virtual ~Q7sSpiComIF(); +class Q7sSpiComIF : public SpiComIF { + public: + /** + * @brief Constructor + * + * @param objectId + * @param gpioComIF + * @param gpioSwitchId The gpio ID of the GPIO connected to the SPI mux module in the PL. + */ + Q7sSpiComIF(object_id_t objectId, GpioIF* gpioComIF, gpioId_t gpioSwitchId); + virtual ~Q7sSpiComIF(); }; #endif /* BSP_Q7S_SPI_Q7SSPICOMIF_H_ */ diff --git a/linux/archive/gpio/GpioCookie.cpp b/linux/archive/gpio/GpioCookie.cpp index c729502b..b1bb2db4 100644 --- a/linux/archive/gpio/GpioCookie.cpp +++ b/linux/archive/gpio/GpioCookie.cpp @@ -1,34 +1,32 @@ #include "GpioCookie.h" + #include -GpioCookie::GpioCookie() { -} +GpioCookie::GpioCookie() {} -ReturnValue_t GpioCookie::addGpio(gpioId_t gpioId, GpioBase* gpioConfig){ - if (gpioConfig == nullptr) { - sif::debug << "GpioCookie::addGpio: gpioConfig is nullpointer" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; +ReturnValue_t GpioCookie::addGpio(gpioId_t gpioId, GpioBase* gpioConfig) { + if (gpioConfig == nullptr) { + sif::debug << "GpioCookie::addGpio: gpioConfig is nullpointer" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + auto gpioMapIter = gpioMap.find(gpioId); + if (gpioMapIter == gpioMap.end()) { + auto statusPair = gpioMap.emplace(gpioId, gpioConfig); + if (statusPair.second == false) { +#if FSFW_VERBOSE_LEVEL >= 1 + sif::error << "GpioCookie::addGpio: Failed to add GPIO " << gpioId << " to GPIO map" + << std::endl; +#endif + return HasReturnvaluesIF::RETURN_FAILED; } - auto gpioMapIter = gpioMap.find(gpioId); - if(gpioMapIter == gpioMap.end()) { - auto statusPair = gpioMap.emplace(gpioId, gpioConfig); - if (statusPair.second == false) { + return HasReturnvaluesIF::RETURN_OK; + } #if FSFW_VERBOSE_LEVEL >= 1 - sif::error << "GpioCookie::addGpio: Failed to add GPIO " << gpioId << - " to GPIO map" << std::endl; + sif::error << "GpioCookie::addGpio: GPIO already exists in GPIO map " << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; - } -#if FSFW_VERBOSE_LEVEL >= 1 - sif::error << "GpioCookie::addGpio: GPIO already exists in GPIO map " << std::endl; -#endif - return HasReturnvaluesIF::RETURN_FAILED; + return HasReturnvaluesIF::RETURN_FAILED; } -GpioMap GpioCookie::getGpioMap() const { - return gpioMap; -} +GpioMap GpioCookie::getGpioMap() const { return gpioMap; } GpioCookie::~GpioCookie() {} diff --git a/linux/archive/gpio/GpioCookie.h b/linux/archive/gpio/GpioCookie.h index 3f8531ee..9295a4ac 100644 --- a/linux/archive/gpio/GpioCookie.h +++ b/linux/archive/gpio/GpioCookie.h @@ -1,11 +1,12 @@ #ifndef LINUX_GPIO_GPIOCOOKIE_H_ #define LINUX_GPIO_GPIOCOOKIE_H_ -#include "GpioIF.h" -#include "gpioDefinitions.h" #include #include +#include "GpioIF.h" +#include "gpioDefinitions.h" + /** * @brief Cookie for the GpioIF. Allows the GpioIF to determine which * GPIOs to initialize and whether they should be configured as in- or @@ -16,24 +17,23 @@ * * @author J. Meier */ -class GpioCookie: public CookieIF { -public: +class GpioCookie : public CookieIF { + public: + GpioCookie(); - GpioCookie(); + virtual ~GpioCookie(); - virtual ~GpioCookie(); + ReturnValue_t addGpio(gpioId_t gpioId, GpioBase* gpioConfig); + /** + * @brief Get map with registered GPIOs. + */ + GpioMap getGpioMap() const; - ReturnValue_t addGpio(gpioId_t gpioId, GpioBase* gpioConfig); - /** - * @brief Get map with registered GPIOs. - */ - GpioMap getGpioMap() const; - -private: - /** - * Returns a copy of the internal GPIO map. - */ - GpioMap gpioMap; + private: + /** + * Returns a copy of the internal GPIO map. + */ + GpioMap gpioMap; }; #endif /* LINUX_GPIO_GPIOCOOKIE_H_ */ diff --git a/linux/archive/gpio/GpioIF.h b/linux/archive/gpio/GpioIF.h index 75feb3ce..045af556 100644 --- a/linux/archive/gpio/GpioIF.h +++ b/linux/archive/gpio/GpioIF.h @@ -1,9 +1,10 @@ #ifndef LINUX_GPIO_GPIOIF_H_ #define LINUX_GPIO_GPIOIF_H_ -#include "gpioDefinitions.h" -#include #include +#include + +#include "gpioDefinitions.h" class GpioCookie; @@ -13,42 +14,41 @@ class GpioCookie; * @author J. Meier */ class GpioIF : public HasReturnvaluesIF { -public: + public: + virtual ~GpioIF(){}; - virtual ~GpioIF() {}; + /** + * @brief Called by the GPIO using object. + * @param cookie Cookie specifying informations of the GPIOs required + * by a object. + */ + virtual ReturnValue_t addGpios(GpioCookie* cookie) = 0; - /** - * @brief Called by the GPIO using object. - * @param cookie Cookie specifying informations of the GPIOs required - * by a object. - */ - virtual ReturnValue_t addGpios(GpioCookie* cookie) = 0; + /** + * @brief By implementing this function a child must provide the + * functionality to pull a certain GPIO to high logic level. + * + * @param gpioId A unique number which specifies the GPIO to drive. + * @return Returns RETURN_OK for success. This should never return RETURN_FAILED. + */ + virtual ReturnValue_t pullHigh(gpioId_t gpioId) = 0; - /** - * @brief By implementing this function a child must provide the - * functionality to pull a certain GPIO to high logic level. - * - * @param gpioId A unique number which specifies the GPIO to drive. - * @return Returns RETURN_OK for success. This should never return RETURN_FAILED. - */ - virtual ReturnValue_t pullHigh(gpioId_t gpioId) = 0; + /** + * @brief By implementing this function a child must provide the + * functionality to pull a certain GPIO to low logic level. + * + * @param gpioId A unique number which specifies the GPIO to drive. + */ + virtual ReturnValue_t pullLow(gpioId_t gpioId) = 0; - /** - * @brief By implementing this function a child must provide the - * functionality to pull a certain GPIO to low logic level. - * - * @param gpioId A unique number which specifies the GPIO to drive. - */ - virtual ReturnValue_t pullLow(gpioId_t gpioId) = 0; - - /** - * @brief This function requires a child to implement the functionality to read the state of - * an ouput or input gpio. - * - * @param gpioId A unique number which specifies the GPIO to read. - * @param gpioState State of GPIO will be written to this pointer. - */ - virtual ReturnValue_t readGpio(gpioId_t gpioId, int* gpioState) = 0; + /** + * @brief This function requires a child to implement the functionality to read the state of + * an ouput or input gpio. + * + * @param gpioId A unique number which specifies the GPIO to read. + * @param gpioState State of GPIO will be written to this pointer. + */ + virtual ReturnValue_t readGpio(gpioId_t gpioId, int* gpioState) = 0; }; #endif /* LINUX_GPIO_GPIOIF_H_ */ diff --git a/linux/archive/gpio/LinuxLibgpioIF.cpp b/linux/archive/gpio/LinuxLibgpioIF.cpp index 92ffa63c..e5dcc1f2 100644 --- a/linux/archive/gpio/LinuxLibgpioIF.cpp +++ b/linux/archive/gpio/LinuxLibgpioIF.cpp @@ -1,302 +1,295 @@ #include "LinuxLibgpioIF.h" -#include "GpioCookie.h" #include +#include #include +#include #include -#include -#include +#include "GpioCookie.h" LinuxLibgpioIF::LinuxLibgpioIF(object_id_t objectId) : SystemObject(objectId) { - struct gpiod_chip* chip = gpiod_chip_open_by_label("/amba_pl/gpio@42030000"); + struct gpiod_chip* chip = gpiod_chip_open_by_label("/amba_pl/gpio@42030000"); - sif::debug << chip->name << std::endl; + sif::debug << chip->name << std::endl; } -LinuxLibgpioIF::~LinuxLibgpioIF() { -} +LinuxLibgpioIF::~LinuxLibgpioIF() {} ReturnValue_t LinuxLibgpioIF::addGpios(GpioCookie* gpioCookie) { - ReturnValue_t result; - if(gpioCookie == nullptr) { - sif::error << "LinuxLibgpioIF::initialize: Invalid cookie" << std::endl; - return RETURN_FAILED; - } + ReturnValue_t result; + if (gpioCookie == nullptr) { + sif::error << "LinuxLibgpioIF::initialize: Invalid cookie" << std::endl; + return RETURN_FAILED; + } - GpioMap mapToAdd = gpioCookie->getGpioMap(); + GpioMap mapToAdd = gpioCookie->getGpioMap(); - /* Check whether this ID already exists in the map and remove duplicates */ - result = checkForConflicts(mapToAdd); - if (result != RETURN_OK){ - return result; - } + /* Check whether this ID already exists in the map and remove duplicates */ + result = checkForConflicts(mapToAdd); + if (result != RETURN_OK) { + return result; + } - result = configureGpios(mapToAdd); - if (result != RETURN_OK) { - return RETURN_FAILED; - } + result = configureGpios(mapToAdd); + if (result != RETURN_OK) { + return RETURN_FAILED; + } - /* Register new GPIOs in gpioMap */ - gpioMap.insert(mapToAdd.begin(), mapToAdd.end()); + /* Register new GPIOs in gpioMap */ + gpioMap.insert(mapToAdd.begin(), mapToAdd.end()); - return RETURN_OK; + return RETURN_OK; } ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap& mapToAdd) { - for(auto& gpioConfig: mapToAdd) { - switch(gpioConfig.second->gpioType) { - case(gpio::GpioTypes::NONE): { - return GPIO_INVALID_INSTANCE; - } - case(gpio::GpioTypes::GPIOD_REGULAR): { - GpiodRegular* regularGpio = dynamic_cast(gpioConfig.second); - if(regularGpio == nullptr) { - return GPIO_INVALID_INSTANCE; - } - configureRegularGpio(gpioConfig.first, regularGpio); - break; - } - case(gpio::GpioTypes::CALLBACK): { - auto gpioCallback = dynamic_cast(gpioConfig.second); - if(gpioCallback->callback == nullptr) { - return GPIO_INVALID_INSTANCE; - } - gpioCallback->callback(gpioConfig.first, gpio::GpioOperation::WRITE, - gpioCallback->initValue, gpioCallback->callbackArgs); + for (auto& gpioConfig : mapToAdd) { + switch (gpioConfig.second->gpioType) { + case (gpio::GpioTypes::NONE): { + return GPIO_INVALID_INSTANCE; + } + case (gpio::GpioTypes::GPIOD_REGULAR): { + GpiodRegular* regularGpio = dynamic_cast(gpioConfig.second); + if (regularGpio == nullptr) { + return GPIO_INVALID_INSTANCE; } + configureRegularGpio(gpioConfig.first, regularGpio); + break; + } + case (gpio::GpioTypes::CALLBACK): { + auto gpioCallback = dynamic_cast(gpioConfig.second); + if (gpioCallback->callback == nullptr) { + return GPIO_INVALID_INSTANCE; } + gpioCallback->callback(gpioConfig.first, gpio::GpioOperation::WRITE, + gpioCallback->initValue, gpioCallback->callbackArgs); + } } - return RETURN_OK; + } + return RETURN_OK; } -ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, GpiodRegular *regularGpio) { - std::string chipname; - unsigned int lineNum; - struct gpiod_chip *chip; - gpio::Direction direction; - std::string consumer; - struct gpiod_line *lineHandle; - int result = 0; +ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, GpiodRegular* regularGpio) { + std::string chipname; + unsigned int lineNum; + struct gpiod_chip* chip; + gpio::Direction direction; + std::string consumer; + struct gpiod_line* lineHandle; + int result = 0; - chipname = regularGpio->chipname; - chip = gpiod_chip_open_by_name(chipname.c_str()); - if (!chip) { - sif::error << "LinuxLibgpioIF::configureGpios: Failed to open chip " - << chipname << ". Gpio ID: " << gpioId << std::endl; + chipname = regularGpio->chipname; + chip = gpiod_chip_open_by_name(chipname.c_str()); + if (!chip) { + sif::error << "LinuxLibgpioIF::configureGpios: Failed to open chip " << chipname + << ". Gpio ID: " << gpioId << std::endl; + return RETURN_FAILED; + } + + lineNum = regularGpio->lineNum; + lineHandle = gpiod_chip_get_line(chip, lineNum); + if (!lineHandle) { + sif::error << "LinuxLibgpioIF::configureGpios: Failed to open line for GPIO with id " << gpioId + << std::endl; + gpiod_chip_close(chip); + return RETURN_FAILED; + } + + direction = regularGpio->direction; + consumer = regularGpio->consumer; + /* Configure direction and add a description to the GPIO */ + switch (direction) { + case (gpio::OUT): { + result = gpiod_line_request_output(lineHandle, consumer.c_str(), regularGpio->initValue); + if (result < 0) { + sif::error << "LinuxLibgpioIF::configureGpios: Failed to request line " << lineNum + << " from GPIO instance with ID: " << gpioId << std::endl; + gpiod_line_release(lineHandle); return RETURN_FAILED; + } + break; } - - lineNum = regularGpio->lineNum; - lineHandle = gpiod_chip_get_line(chip, lineNum); - if (!lineHandle) { - sif::error << "LinuxLibgpioIF::configureGpios: Failed to open line for GPIO with id " - << gpioId << std::endl; - gpiod_chip_close(chip); + case (gpio::IN): { + result = gpiod_line_request_input(lineHandle, consumer.c_str()); + if (result < 0) { + sif::error << "LinuxLibgpioIF::configureGpios: Failed to request line " << lineNum + << " from GPIO instance with ID: " << gpioId << std::endl; + gpiod_line_release(lineHandle); return RETURN_FAILED; - } - - direction = regularGpio->direction; - consumer = regularGpio->consumer; - /* Configure direction and add a description to the GPIO */ - switch (direction) { - case(gpio::OUT): { - result = gpiod_line_request_output(lineHandle, consumer.c_str(), - regularGpio->initValue); - if (result < 0) { - sif::error << "LinuxLibgpioIF::configureGpios: Failed to request line " << lineNum << - " from GPIO instance with ID: " << gpioId << std::endl; - gpiod_line_release(lineHandle); - return RETURN_FAILED; - } - break; - } - case(gpio::IN): { - result = gpiod_line_request_input(lineHandle, consumer.c_str()); - if (result < 0) { - sif::error << "LinuxLibgpioIF::configureGpios: Failed to request line " - << lineNum << " from GPIO instance with ID: " << gpioId << std::endl; - gpiod_line_release(lineHandle); - return RETURN_FAILED; - } - break; + } + break; } default: { - sif::error << "LinuxLibgpioIF::configureGpios: Invalid direction specified" - << std::endl; - return GPIO_INVALID_INSTANCE; + sif::error << "LinuxLibgpioIF::configureGpios: Invalid direction specified" << std::endl; + return GPIO_INVALID_INSTANCE; } - - } - /** - * Write line handle to GPIO configuration instance so it can later be used to set or - * read states of GPIOs. - */ - regularGpio->lineHandle = lineHandle; - return RETURN_OK; + } + /** + * Write line handle to GPIO configuration instance so it can later be used to set or + * read states of GPIOs. + */ + regularGpio->lineHandle = lineHandle; + return RETURN_OK; } ReturnValue_t LinuxLibgpioIF::pullHigh(gpioId_t gpioId) { - gpioMapIter = gpioMap.find(gpioId); - if (gpioMapIter == gpioMap.end()) { - sif::warning << "LinuxLibgpioIF::driveGpio: Unknown GPIOD ID " << gpioId << std::endl; - return UNKNOWN_GPIO_ID; - } + gpioMapIter = gpioMap.find(gpioId); + if (gpioMapIter == gpioMap.end()) { + sif::warning << "LinuxLibgpioIF::driveGpio: Unknown GPIOD ID " << gpioId << std::endl; + return UNKNOWN_GPIO_ID; + } - if(gpioMapIter->second->gpioType == gpio::GpioTypes::GPIOD_REGULAR) { - return driveGpio(gpioId, dynamic_cast(gpioMapIter->second), 1); + if (gpioMapIter->second->gpioType == gpio::GpioTypes::GPIOD_REGULAR) { + return driveGpio(gpioId, dynamic_cast(gpioMapIter->second), 1); + } else { + auto gpioCallback = dynamic_cast(gpioMapIter->second); + if (gpioCallback->callback == nullptr) { + return GPIO_INVALID_INSTANCE; } - else { - auto gpioCallback = dynamic_cast(gpioMapIter->second); - if(gpioCallback->callback == nullptr) { - return GPIO_INVALID_INSTANCE; - } - gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::WRITE, - 1, gpioCallback->callbackArgs); - } - return GPIO_TYPE_FAILURE; + gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::WRITE, 1, + gpioCallback->callbackArgs); + } + return GPIO_TYPE_FAILURE; } ReturnValue_t LinuxLibgpioIF::pullLow(gpioId_t gpioId) { - gpioMapIter = gpioMap.find(gpioId); - if (gpioMapIter == gpioMap.end()) { - sif::warning << "LinuxLibgpioIF::driveGpio: Unknown GPIOD ID " << gpioId << std::endl; - return UNKNOWN_GPIO_ID; - } + gpioMapIter = gpioMap.find(gpioId); + if (gpioMapIter == gpioMap.end()) { + sif::warning << "LinuxLibgpioIF::driveGpio: Unknown GPIOD ID " << gpioId << std::endl; + return UNKNOWN_GPIO_ID; + } - if(gpioMapIter->second->gpioType == gpio::GpioTypes::GPIOD_REGULAR) { - return driveGpio(gpioId, dynamic_cast(gpioMapIter->second), 0); + if (gpioMapIter->second->gpioType == gpio::GpioTypes::GPIOD_REGULAR) { + return driveGpio(gpioId, dynamic_cast(gpioMapIter->second), 0); + } else { + auto gpioCallback = dynamic_cast(gpioMapIter->second); + if (gpioCallback->callback == nullptr) { + return GPIO_INVALID_INSTANCE; } - else { - auto gpioCallback = dynamic_cast(gpioMapIter->second); - if(gpioCallback->callback == nullptr) { - return GPIO_INVALID_INSTANCE; - } - gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::WRITE, - 0, gpioCallback->callbackArgs); - } - return GPIO_TYPE_FAILURE; + gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::WRITE, 0, + gpioCallback->callbackArgs); + } + return GPIO_TYPE_FAILURE; } -ReturnValue_t LinuxLibgpioIF::driveGpio(gpioId_t gpioId, - GpiodRegular* regularGpio, unsigned int logicLevel) { - if(regularGpio == nullptr) { - return GPIO_TYPE_FAILURE; - } +ReturnValue_t LinuxLibgpioIF::driveGpio(gpioId_t gpioId, GpiodRegular* regularGpio, + unsigned int logicLevel) { + if (regularGpio == nullptr) { + return GPIO_TYPE_FAILURE; + } - int result = gpiod_line_set_value(regularGpio->lineHandle, logicLevel); - if (result < 0) { - sif::warning << "LinuxLibgpioIF::driveGpio: Failed to pull GPIO with ID " << gpioId << - " to logic level " << logicLevel << std::endl; - return DRIVE_GPIO_FAILURE; - } + int result = gpiod_line_set_value(regularGpio->lineHandle, logicLevel); + if (result < 0) { + sif::warning << "LinuxLibgpioIF::driveGpio: Failed to pull GPIO with ID " << gpioId + << " to logic level " << logicLevel << std::endl; + return DRIVE_GPIO_FAILURE; + } - return RETURN_OK; + return RETURN_OK; } ReturnValue_t LinuxLibgpioIF::readGpio(gpioId_t gpioId, int* gpioState) { - gpioMapIter = gpioMap.find(gpioId); - if (gpioMapIter == gpioMap.end()){ - sif::warning << "LinuxLibgpioIF::readGpio: Unknown GPIOD ID " << gpioId << std::endl; - return UNKNOWN_GPIO_ID; + gpioMapIter = gpioMap.find(gpioId); + if (gpioMapIter == gpioMap.end()) { + sif::warning << "LinuxLibgpioIF::readGpio: Unknown GPIOD ID " << gpioId << std::endl; + return UNKNOWN_GPIO_ID; + } + + if (gpioMapIter->second->gpioType == gpio::GpioTypes::GPIOD_REGULAR) { + GpiodRegular* regularGpio = dynamic_cast(gpioMapIter->second); + if (regularGpio == nullptr) { + return GPIO_TYPE_FAILURE; } + *gpioState = gpiod_line_get_value(regularGpio->lineHandle); + } else { + } - if(gpioMapIter->second->gpioType == gpio::GpioTypes::GPIOD_REGULAR) { - GpiodRegular* regularGpio = dynamic_cast(gpioMapIter->second); - if(regularGpio == nullptr) { - return GPIO_TYPE_FAILURE; - } - *gpioState = gpiod_line_get_value(regularGpio->lineHandle); - } - else { - - } - - - return RETURN_OK; + return RETURN_OK; } -ReturnValue_t LinuxLibgpioIF::checkForConflicts(GpioMap& mapToAdd){ - ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - for(auto& gpioConfig: mapToAdd) { - switch(gpioConfig.second->gpioType) { - case(gpio::GpioTypes::GPIOD_REGULAR): { - auto regularGpio = dynamic_cast(gpioConfig.second); - if(regularGpio == nullptr) { - return GPIO_TYPE_FAILURE; - } - /* Check for conflicts and remove duplicates if necessary */ - result = checkForConflictsRegularGpio(gpioConfig.first, regularGpio, mapToAdd); - if(result != HasReturnvaluesIF::RETURN_OK) { - status = result; - } - break; +ReturnValue_t LinuxLibgpioIF::checkForConflicts(GpioMap& mapToAdd) { + ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + for (auto& gpioConfig : mapToAdd) { + switch (gpioConfig.second->gpioType) { + case (gpio::GpioTypes::GPIOD_REGULAR): { + auto regularGpio = dynamic_cast(gpioConfig.second); + if (regularGpio == nullptr) { + return GPIO_TYPE_FAILURE; } - case(gpio::GpioTypes::CALLBACK): { - auto callbackGpio = dynamic_cast(gpioConfig.second); - if(callbackGpio == nullptr) { - return GPIO_TYPE_FAILURE; - } - /* Check for conflicts and remove duplicates if necessary */ - result = checkForConflictsCallbackGpio(gpioConfig.first, callbackGpio, mapToAdd); - if(result != HasReturnvaluesIF::RETURN_OK) { - status = result; - } - break; + /* Check for conflicts and remove duplicates if necessary */ + result = checkForConflictsRegularGpio(gpioConfig.first, regularGpio, mapToAdd); + if (result != HasReturnvaluesIF::RETURN_OK) { + status = result; } - default: { - + break; + } + case (gpio::GpioTypes::CALLBACK): { + auto callbackGpio = dynamic_cast(gpioConfig.second); + if (callbackGpio == nullptr) { + return GPIO_TYPE_FAILURE; } + /* Check for conflicts and remove duplicates if necessary */ + result = checkForConflictsCallbackGpio(gpioConfig.first, callbackGpio, mapToAdd); + if (result != HasReturnvaluesIF::RETURN_OK) { + status = result; } + break; + } + default: { + } } - return status; + } + return status; } - ReturnValue_t LinuxLibgpioIF::checkForConflictsRegularGpio(gpioId_t gpioIdToCheck, - GpiodRegular* gpioToCheck, GpioMap& mapToAdd) { - /* Cross check with private map */ - gpioMapIter = gpioMap.find(gpioIdToCheck); - if(gpioMapIter != gpioMap.end()) { - if(gpioMapIter->second->gpioType != gpio::GpioTypes::GPIOD_REGULAR) { - sif::warning << "LinuxLibgpioIF::checkForConflicts: ID already exists for different " - "GPIO type" << gpioIdToCheck << ". Removing duplicate." << std::endl; - mapToAdd.erase(gpioIdToCheck); - return HasReturnvaluesIF::RETURN_OK; - } - auto ownRegularGpio = dynamic_cast(gpioMapIter->second); - if(ownRegularGpio == nullptr) { - return GPIO_TYPE_FAILURE; - } - - /* Remove element from map to add because a entry for this GPIO - already exists */ - sif::warning << "LinuxLibgpioIF::checkForConflictsRegularGpio: Duplicate GPIO definition" - << " detected. Duplicate will be removed from map to add." << std::endl; - mapToAdd.erase(gpioIdToCheck); + GpiodRegular* gpioToCheck, + GpioMap& mapToAdd) { + /* Cross check with private map */ + gpioMapIter = gpioMap.find(gpioIdToCheck); + if (gpioMapIter != gpioMap.end()) { + if (gpioMapIter->second->gpioType != gpio::GpioTypes::GPIOD_REGULAR) { + sif::warning << "LinuxLibgpioIF::checkForConflicts: ID already exists for different " + "GPIO type" + << gpioIdToCheck << ". Removing duplicate." << std::endl; + mapToAdd.erase(gpioIdToCheck); + return HasReturnvaluesIF::RETURN_OK; } - return HasReturnvaluesIF::RETURN_OK; + auto ownRegularGpio = dynamic_cast(gpioMapIter->second); + if (ownRegularGpio == nullptr) { + return GPIO_TYPE_FAILURE; + } + + /* Remove element from map to add because a entry for this GPIO + already exists */ + sif::warning << "LinuxLibgpioIF::checkForConflictsRegularGpio: Duplicate GPIO definition" + << " detected. Duplicate will be removed from map to add." << std::endl; + mapToAdd.erase(gpioIdToCheck); + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t LinuxLibgpioIF::checkForConflictsCallbackGpio(gpioId_t gpioIdToCheck, - GpioCallback *callbackGpio, GpioMap& mapToAdd) { - /* Cross check with private map */ - gpioMapIter = gpioMap.find(gpioIdToCheck); - if(gpioMapIter != gpioMap.end()) { - if(gpioMapIter->second->gpioType != gpio::GpioTypes::CALLBACK) { - sif::warning << "LinuxLibgpioIF::checkForConflicts: ID already exists for different " - "GPIO type" << gpioIdToCheck << ". Removing duplicate." << std::endl; - mapToAdd.erase(gpioIdToCheck); - return HasReturnvaluesIF::RETURN_OK; - } - - /* Remove element from map to add because a entry for this GPIO - already exists */ - sif::warning << "LinuxLibgpioIF::checkForConflictsRegularGpio: Duplicate GPIO definition" - << " detected. Duplicate will be removed from map to add." << std::endl; - mapToAdd.erase(gpioIdToCheck); + GpioCallback* callbackGpio, + GpioMap& mapToAdd) { + /* Cross check with private map */ + gpioMapIter = gpioMap.find(gpioIdToCheck); + if (gpioMapIter != gpioMap.end()) { + if (gpioMapIter->second->gpioType != gpio::GpioTypes::CALLBACK) { + sif::warning << "LinuxLibgpioIF::checkForConflicts: ID already exists for different " + "GPIO type" + << gpioIdToCheck << ". Removing duplicate." << std::endl; + mapToAdd.erase(gpioIdToCheck); + return HasReturnvaluesIF::RETURN_OK; } - return HasReturnvaluesIF::RETURN_OK; + + /* Remove element from map to add because a entry for this GPIO + already exists */ + sif::warning << "LinuxLibgpioIF::checkForConflictsRegularGpio: Duplicate GPIO definition" + << " detected. Duplicate will be removed from map to add." << std::endl; + mapToAdd.erase(gpioIdToCheck); + } + return HasReturnvaluesIF::RETURN_OK; } diff --git a/linux/archive/gpio/LinuxLibgpioIF.h b/linux/archive/gpio/LinuxLibgpioIF.h index 9c444e50..1c974efb 100644 --- a/linux/archive/gpio/LinuxLibgpioIF.h +++ b/linux/archive/gpio/LinuxLibgpioIF.h @@ -1,9 +1,9 @@ #ifndef LINUX_GPIO_LINUXLIBGPIOIF_H_ #define LINUX_GPIO_LINUXLIBGPIOIF_H_ -#include -#include #include +#include +#include class GpioCookie; @@ -15,63 +15,61 @@ class GpioCookie; * 2019.1. */ class LinuxLibgpioIF : public GpioIF, public SystemObject { -public: + public: + static const uint8_t gpioRetvalId = CLASS_ID::LINUX_LIBGPIO_IF; - static const uint8_t gpioRetvalId = CLASS_ID::LINUX_LIBGPIO_IF; + static constexpr ReturnValue_t UNKNOWN_GPIO_ID = + HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 1); + static constexpr ReturnValue_t DRIVE_GPIO_FAILURE = + HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 2); + static constexpr ReturnValue_t GPIO_TYPE_FAILURE = + HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 3); + static constexpr ReturnValue_t GPIO_INVALID_INSTANCE = + HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 4); - static constexpr ReturnValue_t UNKNOWN_GPIO_ID = - HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 1); - static constexpr ReturnValue_t DRIVE_GPIO_FAILURE = - HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 2); - static constexpr ReturnValue_t GPIO_TYPE_FAILURE = - HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 3); - static constexpr ReturnValue_t GPIO_INVALID_INSTANCE = - HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 4); + LinuxLibgpioIF(object_id_t objectId); + virtual ~LinuxLibgpioIF(); - LinuxLibgpioIF(object_id_t objectId); - virtual ~LinuxLibgpioIF(); + ReturnValue_t addGpios(GpioCookie* gpioCookie) override; + ReturnValue_t pullHigh(gpioId_t gpioId) override; + ReturnValue_t pullLow(gpioId_t gpioId) override; + ReturnValue_t readGpio(gpioId_t gpioId, int* gpioState) override; - ReturnValue_t addGpios(GpioCookie* gpioCookie) override; - ReturnValue_t pullHigh(gpioId_t gpioId) override; - ReturnValue_t pullLow(gpioId_t gpioId) override; - ReturnValue_t readGpio(gpioId_t gpioId, int* gpioState) override; + private: + /* Holds the information and configuration of all used GPIOs */ + GpioMap gpioMap; + GpioMapIter gpioMapIter; -private: - /* Holds the information and configuration of all used GPIOs */ - GpioMap gpioMap; - GpioMapIter gpioMapIter; + /** + * @brief This functions drives line of a GPIO specified by the GPIO ID. + * + * @param gpioId The GPIO ID of the GPIO to drive. + * @param logiclevel The logic level to set. O or 1. + */ + ReturnValue_t driveGpio(gpioId_t gpioId, GpiodRegularBase& regularGpio, unsigned int logiclevel); - /** - * @brief This functions drives line of a GPIO specified by the GPIO ID. - * - * @param gpioId The GPIO ID of the GPIO to drive. - * @param logiclevel The logic level to set. O or 1. - */ - ReturnValue_t driveGpio(gpioId_t gpioId, GpiodRegularBase& regularGpio, unsigned int logiclevel); + ReturnValue_t configureRegularGpio(gpioId_t gpioId, GpiodRegularBase& regularGpio); - ReturnValue_t configureRegularGpio(gpioId_t gpioId, GpiodRegularBase& regularGpio); + /** + * @brief This function checks if GPIOs are already registered and whether + * there exists a conflict in the GPIO configuration. E.g. the + * direction. + * + * @param mapToAdd The GPIOs which shall be added to the gpioMap. + * + * @return RETURN_OK if successful, otherwise RETURN_FAILED + */ + ReturnValue_t checkForConflicts(GpioMap& mapToAdd); - /** - * @brief This function checks if GPIOs are already registered and whether - * there exists a conflict in the GPIO configuration. E.g. the - * direction. - * - * @param mapToAdd The GPIOs which shall be added to the gpioMap. - * - * @return RETURN_OK if successful, otherwise RETURN_FAILED - */ - ReturnValue_t checkForConflicts(GpioMap& mapToAdd); - - ReturnValue_t checkForConflictsRegularGpio(gpioId_t gpiodId, GpiodRegular* regularGpio, - GpioMap& mapToAdd); - ReturnValue_t checkForConflictsCallbackGpio(gpioId_t gpiodId, GpioCallback* regularGpio, - GpioMap& mapToAdd); - - /** - * @brief Performs the initial configuration of all GPIOs specified in the GpioMap mapToAdd. - */ - ReturnValue_t configureGpios(GpioMap& mapToAdd); + ReturnValue_t checkForConflictsRegularGpio(gpioId_t gpiodId, GpiodRegular* regularGpio, + GpioMap& mapToAdd); + ReturnValue_t checkForConflictsCallbackGpio(gpioId_t gpiodId, GpioCallback* regularGpio, + GpioMap& mapToAdd); + /** + * @brief Performs the initial configuration of all GPIOs specified in the GpioMap mapToAdd. + */ + ReturnValue_t configureGpios(GpioMap& mapToAdd); }; #endif /* LINUX_GPIO_LINUXLIBGPIOIF_H_ */ diff --git a/linux/archive/gpio/gpioDefinitions.h b/linux/archive/gpio/gpioDefinitions.h index 66c0b005..0db4db11 100644 --- a/linux/archive/gpio/gpioDefinitions.h +++ b/linux/archive/gpio/gpioDefinitions.h @@ -8,29 +8,16 @@ using gpioId_t = uint16_t; namespace gpio { -enum Levels { - LOW = 0, - HIGH = 1 -}; +enum Levels { LOW = 0, HIGH = 1 }; -enum Direction { - IN = 0, - OUT = 1 -}; +enum Direction { IN = 0, OUT = 1 }; -enum GpioOperation { - READ, - WRITE -}; +enum GpioOperation { READ, WRITE }; -enum GpioTypes { - NONE, - GPIOD_REGULAR, - CALLBACK -}; +enum GpioTypes { NONE, GPIOD_REGULAR, CALLBACK }; static constexpr gpioId_t NO_GPIO = -1; -} +} // namespace gpio /** * @brief Struct containing information about the GPIO to use. This is @@ -47,51 +34,49 @@ static constexpr gpioId_t NO_GPIO = -1; * pointer. */ class GpioBase { -public: + public: + GpioBase() = default; - GpioBase() = default; + GpioBase(gpio::GpioTypes gpioType, std::string consumer, gpio::Direction direction, int initValue) + : gpioType(gpioType), consumer(consumer), direction(direction), initValue(initValue) {} - GpioBase(gpio::GpioTypes gpioType, std::string consumer, gpio::Direction direction, - int initValue): - gpioType(gpioType), consumer(consumer),direction(direction), initValue(initValue) {} + virtual ~GpioBase(){}; - virtual~ GpioBase() {}; - - /* Can be used to cast GpioBase to a concrete child implementation */ - gpio::GpioTypes gpioType = gpio::GpioTypes::NONE; - std::string consumer; - gpio::Direction direction = gpio::Direction::IN; - int initValue = 0; + /* Can be used to cast GpioBase to a concrete child implementation */ + gpio::GpioTypes gpioType = gpio::GpioTypes::NONE; + std::string consumer; + gpio::Direction direction = gpio::Direction::IN; + int initValue = 0; }; -class GpiodRegular: public GpioBase { -public: - GpiodRegular(): GpioBase(gpio::GpioTypes::GPIOD_REGULAR, std::string(), - gpio::Direction::IN, 0) {}; +class GpiodRegular : public GpioBase { + public: + GpiodRegular() + : GpioBase(gpio::GpioTypes::GPIOD_REGULAR, std::string(), gpio::Direction::IN, 0){}; - GpiodRegular(std::string chipname_, int lineNum_, std::string consumer_, - gpio::Direction direction_, int initValue_): - GpioBase(gpio::GpioTypes::GPIOD_REGULAR, consumer_, direction_, initValue_), - chipname(chipname_), lineNum(lineNum_) {} - std::string chipname; - int lineNum = 0; - struct gpiod_line* lineHandle = nullptr; + GpiodRegular(std::string chipname_, int lineNum_, std::string consumer_, + gpio::Direction direction_, int initValue_) + : GpioBase(gpio::GpioTypes::GPIOD_REGULAR, consumer_, direction_, initValue_), + chipname(chipname_), + lineNum(lineNum_) {} + std::string chipname; + int lineNum = 0; + struct gpiod_line* lineHandle = nullptr; }; -class GpioCallback: public GpioBase { -public: - GpioCallback(std::string consumer, gpio::Direction direction_, int initValue_, - void (* callback) (gpioId_t gpioId, gpio::GpioOperation gpioOp, int value, void* args), - void* callbackArgs): - GpioBase(gpio::GpioTypes::CALLBACK, consumer, direction_, initValue_), - callback(callback), callbackArgs(callbackArgs) {} +class GpioCallback : public GpioBase { + public: + GpioCallback(std::string consumer, gpio::Direction direction_, int initValue_, + void (*callback)(gpioId_t gpioId, gpio::GpioOperation gpioOp, int value, void* args), + void* callbackArgs) + : GpioBase(gpio::GpioTypes::CALLBACK, consumer, direction_, initValue_), + callback(callback), + callbackArgs(callbackArgs) {} - void (* callback) (gpioId_t gpioId, gpio::GpioOperation gpioOp, - int value, void* args) = nullptr; - void* callbackArgs = nullptr; + void (*callback)(gpioId_t gpioId, gpio::GpioOperation gpioOp, int value, void* args) = nullptr; + void* callbackArgs = nullptr; }; - using GpioMap = std::unordered_map; using GpioMapIter = GpioMap::iterator; diff --git a/linux/archive/tmtc/CCSDSIPCoreBridge.cpp b/linux/archive/tmtc/CCSDSIPCoreBridge.cpp index 982f7fc2..607ccebd 100644 --- a/linux/archive/tmtc/CCSDSIPCoreBridge.cpp +++ b/linux/archive/tmtc/CCSDSIPCoreBridge.cpp @@ -1,136 +1,128 @@ -#include #include - #include +#include CCSDSIPCoreBridge::CCSDSIPCoreBridge(object_id_t objectId, object_id_t tcDestination, - object_id_t tmStoreId, object_id_t tcStoreId, LinuxLibgpioIF* gpioComIF, - std::string uioPtme, gpioId_t papbBusyId, gpioId_t papbEmptyId) : - TmTcBridge(objectId, tcDestination, tmStoreId, tcStoreId), gpioComIF(gpioComIF), uioPtme( - uioPtme), papbBusyId(papbBusyId), papbEmptyId(papbEmptyId) { -} + object_id_t tmStoreId, object_id_t tcStoreId, + LinuxLibgpioIF* gpioComIF, std::string uioPtme, + gpioId_t papbBusyId, gpioId_t papbEmptyId) + : TmTcBridge(objectId, tcDestination, tmStoreId, tcStoreId), + gpioComIF(gpioComIF), + uioPtme(uioPtme), + papbBusyId(papbBusyId), + papbEmptyId(papbEmptyId) {} -CCSDSIPCoreBridge::~CCSDSIPCoreBridge() { -} +CCSDSIPCoreBridge::~CCSDSIPCoreBridge() {} ReturnValue_t CCSDSIPCoreBridge::initialize() { - ReturnValue_t result = TmTcBridge::initialize(); + ReturnValue_t result = TmTcBridge::initialize(); - fd = open("/dev/uio0", O_RDWR); - if (fd < 1) { - sif::debug << "CCSDSIPCoreBridge::initialize: Invalid UIO device file" << std::endl; - return RETURN_FAILED; - } + fd = open("/dev/uio0", O_RDWR); + if (fd < 1) { + sif::debug << "CCSDSIPCoreBridge::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_READ | PROT_WRITE, - MAP_SHARED, fd, 0)); + /** + * Map uio device in virtual address space + * PROT_WRITE: Map uio device in writable only mode + */ + ptmeBaseAddress = + static_cast(mmap(NULL, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)); - if (ptmeBaseAddress == MAP_FAILED) { - sif::error << "CCSDSIPCoreBridge::initialize: Failed to map uio address" << std::endl; - return RETURN_FAILED; - } + if (ptmeBaseAddress == MAP_FAILED) { + sif::error << "CCSDSIPCoreBridge::initialize: Failed to map uio address" << std::endl; + return RETURN_FAILED; + } - return result; + return result; } ReturnValue_t CCSDSIPCoreBridge::handleTm() { - #if OBSW_TEST_CCSDS_PTME == 1 - return sendTestFrame(); + return sendTestFrame(); #else - return TmTcBridge::handleTm(); + return TmTcBridge::handleTm(); #endif - } -ReturnValue_t CCSDSIPCoreBridge::sendTm(const uint8_t * data, size_t dataLen) { +ReturnValue_t CCSDSIPCoreBridge::sendTm(const uint8_t* data, size_t dataLen) { + if (pollPapbBusySignal() == RETURN_OK) { + startPacketTransfer(); + } - if(pollPapbBusySignal() == RETURN_OK) { - startPacketTransfer(); + for (size_t idx = 0; idx < dataLen; idx++) { + if (pollPapbBusySignal() == RETURN_OK) { + *(ptmeBaseAddress + PTME_DATA_REG_OFFSET) = static_cast(*(data + idx)); + } else { + sif::debug << "CCSDSIPCoreBridge::sendTm: Only written " << idx - 1 << " of " << dataLen + << " data" << std::endl; + return RETURN_FAILED; } + } - for(size_t idx = 0; idx < dataLen; idx++) { - if(pollPapbBusySignal() == RETURN_OK) { - *(ptmeBaseAddress + PTME_DATA_REG_OFFSET) = static_cast(*(data + idx)); - } - else { - sif::debug << "CCSDSIPCoreBridge::sendTm: Only written " << idx - 1 << " of " << dataLen - << " data" << std::endl; - return RETURN_FAILED; - } - } - - if(pollPapbBusySignal() == RETURN_OK) { - endPacketTransfer(); - } - return RETURN_OK; + if (pollPapbBusySignal() == RETURN_OK) { + endPacketTransfer(); + } + return RETURN_OK; } -void CCSDSIPCoreBridge::startPacketTransfer() { - *ptmeBaseAddress = PTME_CONFIG_START; -} +void CCSDSIPCoreBridge::startPacketTransfer() { *ptmeBaseAddress = PTME_CONFIG_START; } -void CCSDSIPCoreBridge::endPacketTransfer() { - *ptmeBaseAddress = PTME_CONFIG_END; -} +void CCSDSIPCoreBridge::endPacketTransfer() { *ptmeBaseAddress = PTME_CONFIG_END; } ReturnValue_t CCSDSIPCoreBridge::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::debug << "CCSDSIPCoreBridge::pollPapbBusySignal: Failed to read papb busy signal" - << std::endl; - return RETURN_FAILED; - } - if (!papbBusyState) { - sif::debug << "CCSDSIPCoreBridge::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::debug << "CCSDSIPCoreBridge::pollPapbBusySignal: Failed to read papb busy signal" + << std::endl; + return RETURN_FAILED; + } + if (!papbBusyState) { + sif::debug << "CCSDSIPCoreBridge::pollPapbBusySignal: PAPB busy" << std::endl; + return PAPB_BUSY; + } - return RETURN_OK; + return RETURN_OK; } void CCSDSIPCoreBridge::isPtmeBufferEmpty() { - 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::debug << "CCSDSIPCoreBridge::isPtmeBufferEmpty: Failed to read papb empty signal" - << std::endl; - return; - } - - if (papbEmptyState == 1) { - sif::debug << "CCSDSIPCoreBridge::isPtmeBufferEmpty: Buffer is empty" << std::endl; - } - else { - sif::debug << "CCSDSIPCoreBridge::isPtmeBufferEmpty: Buffer is not empty" << std::endl; - } + if (result != RETURN_OK) { + sif::debug << "CCSDSIPCoreBridge::isPtmeBufferEmpty: Failed to read papb empty signal" + << std::endl; return; + } + + if (papbEmptyState == 1) { + sif::debug << "CCSDSIPCoreBridge::isPtmeBufferEmpty: Buffer is empty" << std::endl; + } else { + sif::debug << "CCSDSIPCoreBridge::isPtmeBufferEmpty: Buffer is not empty" << std::endl; + } + return; } ReturnValue_t CCSDSIPCoreBridge::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 = sendTm(testPacket, 1105); - if(result != RETURN_OK) { - return result; - } + ReturnValue_t result = sendTm(testPacket, 1105); + if (result != RETURN_OK) { + return result; + } - return RETURN_OK; + return RETURN_OK; } diff --git a/linux/archive/tmtc/CCSDSIPCoreBridge.h b/linux/archive/tmtc/CCSDSIPCoreBridge.h index 2ba68a3a..074769c4 100644 --- a/linux/archive/tmtc/CCSDSIPCoreBridge.h +++ b/linux/archive/tmtc/CCSDSIPCoreBridge.h @@ -1,131 +1,129 @@ #ifndef MISSION_OBC_CCSDSIPCOREBRIDGE_H_ #define MISSION_OBC_CCSDSIPCOREBRIDGE_H_ -#include "OBSWConfig.h" #include #include #include #include +#include "OBSWConfig.h" + /** * @brief This class handles the interfacing to the telemetry (PTME) and telecommand (PDEC) IP * cores responsible for the CCSDS encoding and decoding. The IP cores are implemented * on the programmable logic and are accessible through the linux UIO driver. */ -class CCSDSIPCoreBridge: public TmTcBridge { -public: - /** - * @brief Constructor - * - * @param objectId - * @param tcDestination - * @param tmStoreId - * @param tcStoreId - * @param uioPtme Name of the uio device file which provides access to the PTME IP Core. - * @param papbBusyId The ID of the GPIO which is connected to the PAPBBusy_N signal of the - * PTME IP Core. A low logic level indicates the PTME is not ready to - * receive more data. - * @param papbEmptyId The ID of the GPIO which is connected to the PAPBEmpty signal of the - * PTME IP Core. The signal is high when there are no packets in the - * external buffer memory (BRAM). - */ - CCSDSIPCoreBridge(object_id_t objectId, object_id_t tcDestination, object_id_t tmStoreId, - object_id_t tcStoreId, LinuxLibgpioIF* gpioComIF, std::string uioPtme, - gpioId_t papbBusyId, gpioId_t papbEmptyId); - virtual ~CCSDSIPCoreBridge(); +class CCSDSIPCoreBridge : public TmTcBridge { + public: + /** + * @brief Constructor + * + * @param objectId + * @param tcDestination + * @param tmStoreId + * @param tcStoreId + * @param uioPtme Name of the uio device file which provides access to the PTME IP Core. + * @param papbBusyId The ID of the GPIO which is connected to the PAPBBusy_N signal of the + * PTME IP Core. A low logic level indicates the PTME is not ready to + * receive more data. + * @param papbEmptyId The ID of the GPIO which is connected to the PAPBEmpty signal of the + * PTME IP Core. The signal is high when there are no packets in the + * external buffer memory (BRAM). + */ + CCSDSIPCoreBridge(object_id_t objectId, object_id_t tcDestination, object_id_t tmStoreId, + object_id_t tcStoreId, LinuxLibgpioIF* gpioComIF, std::string uioPtme, + gpioId_t papbBusyId, gpioId_t papbEmptyId); + virtual ~CCSDSIPCoreBridge(); - ReturnValue_t initialize() override; + ReturnValue_t initialize() override; -protected: + protected: + /** + * Overwriting this function to provide the capability of testing the PTME IP Core + * implementation. + */ + virtual ReturnValue_t handleTm() override; - /** - * Overwriting this function to provide the capability of testing the PTME IP Core - * implementation. - */ - virtual ReturnValue_t handleTm() override; + virtual ReturnValue_t sendTm(const uint8_t* data, size_t dataLen) override; - virtual ReturnValue_t sendTm(const uint8_t * data, size_t dataLen) override; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_IP_CORE_BRIDGE; -private: + static const ReturnValue_t PAPB_BUSY = MAKE_RETURN_CODE(0xA0); - static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_IP_CORE_BRIDGE; + /** Size of mapped address space. 4k (minimal size of pl device) */ + // static const int MAP_SIZE = 0xFA0; + static const int MAP_SIZE = 0x1000; - static const ReturnValue_t PAPB_BUSY = MAKE_RETURN_CODE(0xA0); + /** + * Configuration bits: + * bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00 + * bit[2]: Set this bit to 1 to abort a transfered packet + * bit[3]: Signals to PTME the start of a new telemetry packet + */ + static const uint32_t PTME_CONFIG_START = 0x8; + /** + * Writing this word to the ptme base address signals to the PTME that a complete tm packet has + * been transferred. + */ + static const uint32_t PTME_CONFIG_END = 0x0; - /** Size of mapped address space. 4k (minimal size of pl device) */ -// static const int MAP_SIZE = 0xFA0; - static const int MAP_SIZE = 0x1000; + /** + * Writing to this offset within the PTME memory space will insert data for encoding to the + * PTME IP core. + * The address offset is 0x400 (= 4 * 256) + */ + static const int PTME_DATA_REG_OFFSET = 256; - /** - * Configuration bits: - * bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00 - * bit[2]: Set this bit to 1 to abort a transfered packet - * bit[3]: Signals to PTME the start of a new telemetry packet - */ - static const uint32_t PTME_CONFIG_START = 0x8; + LinuxLibgpioIF* gpioComIF = nullptr; - /** - * Writing this word to the ptme base address signals to the PTME that a complete tm packet has - * been transferred. - */ - static const uint32_t PTME_CONFIG_END = 0x0; + /** The uio device file related to the PTME IP Core */ + std::string uioPtme; - /** - * Writing to this offset within the PTME memory space will insert data for encoding to the - * PTME IP core. - * The address offset is 0x400 (= 4 * 256) - */ - static const int PTME_DATA_REG_OFFSET = 256; + /** Pulled to low when PTME not ready to receive data */ + gpioId_t papbBusyId = gpio::NO_GPIO; - LinuxLibgpioIF* gpioComIF = nullptr; + /** High when externally buffer memory of PTME is empty */ + gpioId_t papbEmptyId = gpio::NO_GPIO; - /** The uio device file related to the PTME IP Core */ - std::string uioPtme; + /** The file descriptor of the UIO driver */ + int fd; - /** Pulled to low when PTME not ready to receive data */ - gpioId_t papbBusyId = gpio::NO_GPIO; + uint32_t* ptmeBaseAddress = nullptr; - /** High when externally buffer memory of PTME is empty */ - gpioId_t papbEmptyId = gpio::NO_GPIO; + /** + * @brief This function sends the config byte to the PTME IP Core to initiate a packet + * transfer. + */ + void startPacketTransfer(); - /** The file descriptor of the UIO driver */ - int fd; + /** + * @brief This function sends the config byte to the PTME IP Core to signal the end of a + * packet transfer. + */ + void endPacketTransfer(); - uint32_t* ptmeBaseAddress = nullptr; + /** + * @brief This function reads the papb busy signal indicating whether the PAPB interface is + * ready to receive more data or not. PAPB is ready when PAPB_Busy_N == '1'. + * + * @return RETURN_OK when ready to receive data else PAPB_BUSY. + */ + ReturnValue_t pollPapbBusySignal(); - /** - * @brief This function sends the config byte to the PTME IP Core to initiate a packet - * transfer. - */ - void startPacketTransfer(); + /** + * @brief This function can be used for debugging to check wheter there are packets in + * the packet buffer of the PTME or not. + */ + void isPtmeBufferEmpty(); - /** - * @brief This function sends the config byte to the PTME IP Core to signal the end of a - * packet transfer. - */ - void endPacketTransfer(); - - /** - * @brief This function reads the papb busy signal indicating whether the PAPB interface is - * ready to receive more data or not. PAPB is ready when PAPB_Busy_N == '1'. - * - * @return RETURN_OK when ready to receive data else PAPB_BUSY. - */ - ReturnValue_t pollPapbBusySignal(); - - /** - * @brief This function can be used for debugging to check wheter there are packets in - * the packet buffer of the PTME or not. - */ - void isPtmeBufferEmpty(); - - /** - * @brief This function sends a complete telemetry transfer frame data field (1105 bytes) - * to the input of the PTME IP Core. Can be used to test the implementation. - */ - ReturnValue_t sendTestFrame(); + /** + * @brief This function sends a complete telemetry transfer frame data field (1105 bytes) + * to the input of the PTME IP Core. Can be used to test the implementation. + */ + ReturnValue_t sendTestFrame(); }; #endif /* MISSION_OBC_CCSDSIPCOREBRIDGE_H_ */ diff --git a/linux/boardtest/I2cTestClass.cpp b/linux/boardtest/I2cTestClass.cpp index 66c16b33..090691e2 100644 --- a/linux/boardtest/I2cTestClass.cpp +++ b/linux/boardtest/I2cTestClass.cpp @@ -1,8 +1,5 @@ #include -I2cTestClass::I2cTestClass(object_id_t objectId): TestTask(objectId) { -} +I2cTestClass::I2cTestClass(object_id_t objectId) : TestTask(objectId) {} -ReturnValue_t I2cTestClass::performPeriodicAction() { - return HasReturnvaluesIF::RETURN_OK; -} +ReturnValue_t I2cTestClass::performPeriodicAction() { return HasReturnvaluesIF::RETURN_OK; } diff --git a/linux/boardtest/I2cTestClass.h b/linux/boardtest/I2cTestClass.h index 172a7f71..314f9dda 100644 --- a/linux/boardtest/I2cTestClass.h +++ b/linux/boardtest/I2cTestClass.h @@ -3,15 +3,13 @@ #include -class I2cTestClass: public TestTask { -public: - I2cTestClass(object_id_t objectId); +class I2cTestClass : public TestTask { + public: + I2cTestClass(object_id_t objectId); - ReturnValue_t performPeriodicAction() override; -private: + ReturnValue_t performPeriodicAction() override; + private: }; - - #endif /* LINUX_BOARDTEST_I2CTESTCLASS_H_ */ diff --git a/linux/boardtest/LibgpiodTest.cpp b/linux/boardtest/LibgpiodTest.cpp index 8eb9b536..0c5ebe2a 100644 --- a/linux/boardtest/LibgpiodTest.cpp +++ b/linux/boardtest/LibgpiodTest.cpp @@ -1,135 +1,127 @@ #include "LibgpiodTest.h" +#include +#include +#include + #include "devices/gpioIds.h" -#include -#include -#include - -LibgpiodTest::LibgpiodTest(object_id_t objectId, object_id_t gpioIfobjectId, - GpioCookie* gpioCookie): - TestTask(objectId) { - - gpioInterface = ObjectManager::instance()->get(gpioIfobjectId); - if (gpioInterface == nullptr) { - sif::error << "LibgpiodTest::LibgpiodTest: Invalid Gpio interface." << std::endl; - } - gpioInterface->addGpios(gpioCookie); - testCase = TestCases::BLINK; +LibgpiodTest::LibgpiodTest(object_id_t objectId, object_id_t gpioIfobjectId, GpioCookie* gpioCookie) + : TestTask(objectId) { + gpioInterface = ObjectManager::instance()->get(gpioIfobjectId); + if (gpioInterface == nullptr) { + sif::error << "LibgpiodTest::LibgpiodTest: Invalid Gpio interface." << std::endl; + } + gpioInterface->addGpios(gpioCookie); + testCase = TestCases::BLINK; } -LibgpiodTest::~LibgpiodTest() { -} +LibgpiodTest::~LibgpiodTest() {} ReturnValue_t LibgpiodTest::performPeriodicAction() { - int gpioState; - ReturnValue_t result; + int gpioState; + ReturnValue_t result; - switch(testCase) { - case(TestCases::READ): { - result = gpioInterface->readGpio(gpioIds::TEST_ID_0, &gpioState); - if (result != RETURN_OK) { - sif::warning << "LibgpiodTest::performPeriodicAction: Failed to read gpio " - << std::endl; - return RETURN_FAILED; - } - else { - sif::debug << "LibgpiodTest::performPeriodicAction: MIO 0 state = " << gpioState - << std::endl; - } - break; + switch (testCase) { + case (TestCases::READ): { + result = gpioInterface->readGpio(gpioIds::TEST_ID_0, &gpioState); + if (result != RETURN_OK) { + sif::warning << "LibgpiodTest::performPeriodicAction: Failed to read gpio " << std::endl; + return RETURN_FAILED; + } else { + sif::debug << "LibgpiodTest::performPeriodicAction: MIO 0 state = " << gpioState + << std::endl; + } + break; } - case(TestCases::LOOPBACK): { - break; + case (TestCases::LOOPBACK): { + break; } - case(TestCases::BLINK): { - result = gpioInterface->readGpio(gpioIds::TEST_ID_0, &gpioState); + case (TestCases::BLINK): { + result = gpioInterface->readGpio(gpioIds::TEST_ID_0, &gpioState); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "LibgpiodTest::performPeriodicAction: Failed to read gpio " << std::endl; + return RETURN_FAILED; + } + if (gpioState == 1) { + result = gpioInterface->pullLow(gpioIds::TEST_ID_0); if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "LibgpiodTest::performPeriodicAction: Failed to read gpio " - << std::endl; - return RETURN_FAILED; + sif::warning << "LibgpiodTest::performPeriodicAction: Could not pull GPIO low!" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; } - if (gpioState == 1) { - result = gpioInterface->pullLow(gpioIds::TEST_ID_0); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "LibgpiodTest::performPeriodicAction: Could not pull GPIO low!" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - } - else if (gpioState == 0) { - result = gpioInterface->pullHigh(gpioIds::TEST_ID_0); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "LibgpiodTest::performPeriodicAction: Could not pull GPIO high!" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - } - else { - sif::warning << "LibgpiodTest::performPeriodicAction: Invalid GPIO state" << std::endl; + } else if (gpioState == 0) { + result = gpioInterface->pullHigh(gpioIds::TEST_ID_0); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "LibgpiodTest::performPeriodicAction: Could not pull GPIO high!" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; } + } else { + sif::warning << "LibgpiodTest::performPeriodicAction: Invalid GPIO state" << std::endl; + } - break; + break; } default: - sif::debug << "LibgpiodTest::performPeriodicAction: Invalid test case" << std::endl; - break; - } + sif::debug << "LibgpiodTest::performPeriodicAction: Invalid test case" << std::endl; + break; + } - - return RETURN_OK; + return RETURN_OK; } ReturnValue_t LibgpiodTest::performOneShotAction() { - int gpioState; - ReturnValue_t result; + int gpioState; + ReturnValue_t result; - switch(testCase) { - case(TestCases::READ): { - break; + switch (testCase) { + case (TestCases::READ): { + break; } - case(TestCases::BLINK): { - break; + case (TestCases::BLINK): { + break; } - case(TestCases::LOOPBACK): { - result = gpioInterface->pullHigh(gpioIds::TEST_ID_0); - if(result == HasReturnvaluesIF::RETURN_OK) { - sif::info << "LibgpiodTest::performOneShotAction: " - "GPIO pulled high successfully for loopback test" << std::endl; - } - else { - sif::warning << "LibgpiodTest::performOneShotAction: Could not pull GPIO high!" - << std::endl; - return HasReturnvaluesIF::RETURN_OK; - } - result = gpioInterface->readGpio(gpioIds::TEST_ID_1, &gpioState); - if(result == HasReturnvaluesIF::RETURN_OK and gpioState == 1) { - sif::info << "LibgpiodTest::performOneShotAction: " - "GPIO state read successfully and is high" << std::endl; - } - else { - sif::warning << "LibgpiodTest::performOneShotAction: GPIO read and is not high!" - << std::endl; - return HasReturnvaluesIF::RETURN_OK; - } + case (TestCases::LOOPBACK): { + result = gpioInterface->pullHigh(gpioIds::TEST_ID_0); + if (result == HasReturnvaluesIF::RETURN_OK) { + sif::info << "LibgpiodTest::performOneShotAction: " + "GPIO pulled high successfully for loopback test" + << std::endl; + } else { + sif::warning << "LibgpiodTest::performOneShotAction: Could not pull GPIO high!" + << std::endl; + return HasReturnvaluesIF::RETURN_OK; + } + result = gpioInterface->readGpio(gpioIds::TEST_ID_1, &gpioState); + if (result == HasReturnvaluesIF::RETURN_OK and gpioState == 1) { + sif::info << "LibgpiodTest::performOneShotAction: " + "GPIO state read successfully and is high" + << std::endl; + } else { + sif::warning << "LibgpiodTest::performOneShotAction: GPIO read and is not high!" + << std::endl; + return HasReturnvaluesIF::RETURN_OK; + } - result = gpioInterface->pullLow(gpioIds::TEST_ID_0); - if(result == HasReturnvaluesIF::RETURN_OK) { - sif::info << "LibgpiodTest::performOneShotAction: " - "GPIO pulled low successfully for loopback test" << std::endl; - } - result = gpioInterface->readGpio(gpioIds::TEST_ID_1, &gpioState); - if(result == HasReturnvaluesIF::RETURN_OK and gpioState == 0) { - sif::info << "LibgpiodTest::performOneShotAction: " - "GPIO state read successfully and is low" << std::endl; - } - else { - sif::warning << "LibgpiodTest::performOneShotAction: GPIO read and is not low!" - << std::endl; - return HasReturnvaluesIF::RETURN_OK; - } - break; + result = gpioInterface->pullLow(gpioIds::TEST_ID_0); + if (result == HasReturnvaluesIF::RETURN_OK) { + sif::info << "LibgpiodTest::performOneShotAction: " + "GPIO pulled low successfully for loopback test" + << std::endl; + } + result = gpioInterface->readGpio(gpioIds::TEST_ID_1, &gpioState); + if (result == HasReturnvaluesIF::RETURN_OK and gpioState == 0) { + sif::info << "LibgpiodTest::performOneShotAction: " + "GPIO state read successfully and is low" + << std::endl; + } else { + sif::warning << "LibgpiodTest::performOneShotAction: GPIO read and is not low!" + << std::endl; + return HasReturnvaluesIF::RETURN_OK; + } + break; } - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } diff --git a/linux/boardtest/LibgpiodTest.h b/linux/boardtest/LibgpiodTest.h index 718d0209..4fcaffdf 100644 --- a/linux/boardtest/LibgpiodTest.h +++ b/linux/boardtest/LibgpiodTest.h @@ -1,34 +1,31 @@ #ifndef TEST_TESTTASKS_LIBGPIODTEST_H_ #define TEST_TESTTASKS_LIBGPIODTEST_H_ -#include "TestTask.h" -#include -#include #include +#include +#include + +#include "TestTask.h" /** * @brief Test for the GPIO read implementation of the LinuxLibgpioIF. * @author J. Meier */ -class LibgpiodTest: public TestTask { -public: - enum TestCases { - READ = 0, - LOOPBACK = 1, - BLINK - }; +class LibgpiodTest : public TestTask { + public: + enum TestCases { READ = 0, LOOPBACK = 1, BLINK }; - TestCases testCase; + TestCases testCase; - LibgpiodTest(object_id_t objectId, object_id_t gpioIfobjectId, GpioCookie* gpioCookie); - virtual ~LibgpiodTest(); + LibgpiodTest(object_id_t objectId, object_id_t gpioIfobjectId, GpioCookie* gpioCookie); + virtual ~LibgpiodTest(); -protected: - ReturnValue_t performOneShotAction() override; - ReturnValue_t performPeriodicAction() override; + protected: + ReturnValue_t performOneShotAction() override; + ReturnValue_t performPeriodicAction() override; -private: - GpioIF* gpioInterface; + private: + GpioIF* gpioInterface; }; #endif /* TEST_TESTTASKS_LIBGPIODTEST_H_ */ diff --git a/linux/boardtest/SpiTestClass.cpp b/linux/boardtest/SpiTestClass.cpp index 65f2ca9f..7ef76d95 100644 --- a/linux/boardtest/SpiTestClass.cpp +++ b/linux/boardtest/SpiTestClass.cpp @@ -1,503 +1,483 @@ #include "SpiTestClass.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + #include "devices/gpioIds.h" -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -SpiTestClass::SpiTestClass(object_id_t objectId, GpioIF* gpioIF): TestTask(objectId), -gpioIF(gpioIF) { - if(gpioIF == nullptr) { - sif::error << "SpiTestClass::SpiTestClass: Invalid GPIO ComIF!" << std::endl; - } - testMode = TestModes::MGM_LIS3MDL; - spiTransferStruct.rx_buf = reinterpret_cast<__u64>(recvBuffer.data()); - spiTransferStruct.tx_buf = reinterpret_cast<__u64>(sendBuffer.data()); +SpiTestClass::SpiTestClass(object_id_t objectId, GpioIF *gpioIF) + : TestTask(objectId), gpioIF(gpioIF) { + if (gpioIF == nullptr) { + sif::error << "SpiTestClass::SpiTestClass: Invalid GPIO ComIF!" << std::endl; + } + testMode = TestModes::MGM_LIS3MDL; + spiTransferStruct.rx_buf = reinterpret_cast<__u64>(recvBuffer.data()); + spiTransferStruct.tx_buf = reinterpret_cast<__u64>(sendBuffer.data()); } ReturnValue_t SpiTestClass::performOneShotAction() { - switch(testMode) { - case(TestModes::NONE): { - break; + switch (testMode) { + case (TestModes::NONE): { + break; } - case(TestModes::MGM_LIS3MDL): { - performLis3MdlTest(mgm0Lis3mdlChipSelect); - break; + case (TestModes::MGM_LIS3MDL): { + performLis3MdlTest(mgm0Lis3mdlChipSelect); + break; } - case(TestModes::MGM_RM3100): { - performRm3100Test(mgm1Rm3100ChipSelect); - break; + case (TestModes::MGM_RM3100): { + performRm3100Test(mgm1Rm3100ChipSelect); + break; } - case(TestModes::GYRO_L3GD20H): { - performL3gTest(gyro1L3gd20ChipSelect); - break; + case (TestModes::GYRO_L3GD20H): { + performL3gTest(gyro1L3gd20ChipSelect); + break; } - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t SpiTestClass::performPeriodicAction() { - return HasReturnvaluesIF::RETURN_OK; -} +ReturnValue_t SpiTestClass::performPeriodicAction() { return HasReturnvaluesIF::RETURN_OK; } void SpiTestClass::performRm3100Test(uint8_t mgmId) { - /* Configure all SPI chip selects and pull them high */ - acsInit(); + /* Configure all SPI chip selects and pull them high */ + acsInit(); - /* Adapt accordingly */ - if(mgmId != mgm1Rm3100ChipSelect and mgmId != mgm3Rm3100ChipSelect) { - sif::warning << "SpiTestClass::performRm3100Test: Invalid MGM ID!" << std::endl; - } - gpioId_t currentGpioId = 0; - uint8_t chipSelectPin = mgmId; - if(chipSelectPin == mgm1Rm3100ChipSelect) { - currentGpioId = gpioIds::MGM_1_RM3100_CS; - } - else { - currentGpioId = gpioIds::MGM_3_RM3100_CS; - } - uint32_t rm3100speed = 976'000; - uint8_t rm3100revidReg = 0x36; - spi::SpiModes rm3100mode = spi::SpiModes::MODE_3; + /* Adapt accordingly */ + if (mgmId != mgm1Rm3100ChipSelect and mgmId != mgm3Rm3100ChipSelect) { + sif::warning << "SpiTestClass::performRm3100Test: Invalid MGM ID!" << std::endl; + } + gpioId_t currentGpioId = 0; + uint8_t chipSelectPin = mgmId; + if (chipSelectPin == mgm1Rm3100ChipSelect) { + currentGpioId = gpioIds::MGM_1_RM3100_CS; + } else { + currentGpioId = gpioIds::MGM_3_RM3100_CS; + } + uint32_t rm3100speed = 976'000; + uint8_t rm3100revidReg = 0x36; + spi::SpiModes rm3100mode = spi::SpiModes::MODE_3; #ifdef RASPBERRY_PI - std::string deviceName = "/dev/spidev0.0"; + std::string deviceName = "/dev/spidev0.0"; #else - std::string deviceName = "/dev/spidev2.0"; + std::string deviceName = "/dev/spidev2.0"; #endif - int fileDescriptor = 0; + int fileDescriptor = 0; + UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR, "SpiComIF::initializeInterface"); + if (fileHelper.getOpenResult()) { + sif::error << "SpiTestClass::performRm3100Test: File descriptor could not be opened!" + << std::endl; + return; + } + setSpiSpeedAndMode(fileDescriptor, rm3100mode, rm3100speed); - UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR, - "SpiComIF::initializeInterface"); - if(fileHelper.getOpenResult()) { - sif::error << "SpiTestClass::performRm3100Test: File descriptor could not be opened!" - << std::endl; - return; - } - setSpiSpeedAndMode(fileDescriptor, rm3100mode, rm3100speed); + uint8_t revId = readRegister(fileDescriptor, currentGpioId, rm3100revidReg); + sif::info << "SpiTestClass::performRm3100Test: Revision ID 0b" << std::bitset<8>(revId) + << std::endl; - uint8_t revId = readRegister(fileDescriptor, currentGpioId, rm3100revidReg); - sif::info << "SpiTestClass::performRm3100Test: Revision ID 0b" << std::bitset<8>(revId) << - std::endl; + /* Write configuration to CMM register */ + writeRegister(fileDescriptor, currentGpioId, 0x01, 0x75); + uint8_t cmmRegister = readRm3100Register(fileDescriptor, currentGpioId, 0x01); + sif::info << "SpiTestClass::performRm3100Test: CMM register value: " << std::hex << "0x" + << static_cast(cmmRegister) << std::dec << std::endl; - /* Write configuration to CMM register */ - writeRegister(fileDescriptor, currentGpioId, 0x01, 0x75); - uint8_t cmmRegister = readRm3100Register(fileDescriptor , currentGpioId, 0x01); - sif::info << "SpiTestClass::performRm3100Test: CMM register value: " << - std::hex << "0x" << static_cast(cmmRegister) << std::dec << std::endl; + /* Read the cycle count registers */ + uint8_t cycleCountsRaw[6]; + readMultipleRegisters(fileDescriptor, currentGpioId, 0x04, cycleCountsRaw, 6); - /* Read the cycle count registers */ - uint8_t cycleCountsRaw[6]; - readMultipleRegisters(fileDescriptor, currentGpioId, 0x04, cycleCountsRaw, 6); + uint16_t cycleCountX = cycleCountsRaw[0] << 8 | cycleCountsRaw[1]; + uint16_t cycleCountY = cycleCountsRaw[2] << 8 | cycleCountsRaw[3]; + uint16_t cycleCountZ = cycleCountsRaw[4] << 8 | cycleCountsRaw[5]; - uint16_t cycleCountX = cycleCountsRaw[0] << 8 | cycleCountsRaw[1]; - uint16_t cycleCountY = cycleCountsRaw[2] << 8 | cycleCountsRaw[3]; - uint16_t cycleCountZ = cycleCountsRaw[4] << 8 | cycleCountsRaw[5]; + sif::info << "Cycle count X: " << cycleCountX << std::endl; + sif::info << "Cycle count Y: " << cycleCountY << std::endl; + sif::info << "Cycle count z: " << cycleCountZ << std::endl; - sif::info << "Cycle count X: " << cycleCountX << std::endl; - sif::info << "Cycle count Y: " << cycleCountY << std::endl; - sif::info << "Cycle count z: " << cycleCountZ << std::endl; - - writeRegister(fileDescriptor, currentGpioId, 0x0B, 0x96); - uint8_t tmrcReg = readRm3100Register(fileDescriptor, currentGpioId, 0x0B); - sif::info << "SpiTestClass::performRm3100Test: TMRC register value: " << - std::hex << "0x" << static_cast(tmrcReg) << std::dec << std::endl; + writeRegister(fileDescriptor, currentGpioId, 0x0B, 0x96); + uint8_t tmrcReg = readRm3100Register(fileDescriptor, currentGpioId, 0x0B); + sif::info << "SpiTestClass::performRm3100Test: TMRC register value: " << std::hex << "0x" + << static_cast(tmrcReg) << std::dec << std::endl; + TaskFactory::delayTask(10); + uint8_t statusReg = readRm3100Register(fileDescriptor, currentGpioId, 0x34); + sif::info << "SpiTestClass::performRm3100Test: Status Register 0b" << std::bitset<8>(statusReg) + << std::endl; + /* This means that data is not ready */ + if ((statusReg & 0b1000'0000) == 0) { + sif::warning << "SpiTestClass::performRm3100Test: Data not ready!" << std::endl; TaskFactory::delayTask(10); uint8_t statusReg = readRm3100Register(fileDescriptor, currentGpioId, 0x34); - sif::info << "SpiTestClass::performRm3100Test: Status Register 0b" << - std::bitset<8>(statusReg) << std::endl; - /* This means that data is not ready */ - if((statusReg & 0b1000'0000) == 0) { - sif::warning << "SpiTestClass::performRm3100Test: Data not ready!" << std::endl; - TaskFactory::delayTask(10); - uint8_t statusReg = readRm3100Register(fileDescriptor, currentGpioId, 0x34); - if((statusReg & 0b1000'0000) == 0) { - return; - } + if ((statusReg & 0b1000'0000) == 0) { + return; } + } - uint32_t rm3100DefaultCycleCout = 0xC8; - /* Gain scales lineary with cycle count and is 38 for cycle count 100 */ - float rm3100Gain = rm3100DefaultCycleCout / 100.0 * 38.0; - float scaleFactor = 1 / rm3100Gain; - uint8_t rawValues[9]; - readMultipleRegisters(fileDescriptor, currentGpioId, 0x24, rawValues, 9); + uint32_t rm3100DefaultCycleCout = 0xC8; + /* Gain scales lineary with cycle count and is 38 for cycle count 100 */ + float rm3100Gain = rm3100DefaultCycleCout / 100.0 * 38.0; + float scaleFactor = 1 / rm3100Gain; + uint8_t rawValues[9]; + readMultipleRegisters(fileDescriptor, currentGpioId, 0x24, rawValues, 9); - /* The sensor generates 24 bit signed values */ - int32_t rawX = ((rawValues[0] << 24) | (rawValues[1] << 16) | (rawValues[2] << 8)) >> 8; - int32_t rawY = ((rawValues[3] << 24) | (rawValues[4] << 16) | (rawValues[5] << 8)) >> 8; - int32_t rawZ = ((rawValues[6] << 24) | (rawValues[7] << 16) | (rawValues[8] << 8)) >> 8; + /* The sensor generates 24 bit signed values */ + int32_t rawX = ((rawValues[0] << 24) | (rawValues[1] << 16) | (rawValues[2] << 8)) >> 8; + int32_t rawY = ((rawValues[3] << 24) | (rawValues[4] << 16) | (rawValues[5] << 8)) >> 8; + int32_t rawZ = ((rawValues[6] << 24) | (rawValues[7] << 16) | (rawValues[8] << 8)) >> 8; - float fieldStrengthX = rawX * scaleFactor; - float fieldStrengthY = rawY * scaleFactor; - float fieldStrengthZ = rawZ * scaleFactor; + float fieldStrengthX = rawX * scaleFactor; + float fieldStrengthY = rawY * scaleFactor; + float fieldStrengthZ = rawZ * scaleFactor; - sif::info << "RM3100 measured field strengths in microtesla:" << std::endl; - sif::info << "Field Strength X: " << fieldStrengthX << " uT" << std::endl; - sif::info << "Field Strength Y: " << fieldStrengthY << " uT" << std::endl; - sif::info << "Field Strength Z: " << fieldStrengthZ << " uT" << std::endl; + sif::info << "RM3100 measured field strengths in microtesla:" << std::endl; + sif::info << "Field Strength X: " << fieldStrengthX << " uT" << std::endl; + sif::info << "Field Strength Y: " << fieldStrengthY << " uT" << std::endl; + sif::info << "Field Strength Z: " << fieldStrengthZ << " uT" << std::endl; } void SpiTestClass::performLis3MdlTest(uint8_t lis3Id) { - /* Configure all SPI chip selects and pull them high */ - acsInit(); + /* Configure all SPI chip selects and pull them high */ + acsInit(); - /* Adapt accordingly */ - if(lis3Id != mgm0Lis3mdlChipSelect and lis3Id != mgm2Lis3mdlChipSelect) { - sif::warning << "SpiTestClass::performLis3MdlTest: Invalid MGM ID!" << std::endl; - } - gpioId_t currentGpioId = 0; - uint8_t chipSelectPin = lis3Id; - uint8_t whoAmIReg = 0b0000'1111; - uint8_t whoAmIRegExpectedVal = 0b0011'1101; - if(chipSelectPin == mgm0Lis3mdlChipSelect) { - currentGpioId = gpioIds::MGM_0_LIS3_CS; - } - else { - currentGpioId = gpioIds::MGM_2_LIS3_CS; - } - uint32_t spiSpeed = 10'000'000; - spi::SpiModes spiMode = spi::SpiModes::MODE_0; + /* Adapt accordingly */ + if (lis3Id != mgm0Lis3mdlChipSelect and lis3Id != mgm2Lis3mdlChipSelect) { + sif::warning << "SpiTestClass::performLis3MdlTest: Invalid MGM ID!" << std::endl; + } + gpioId_t currentGpioId = 0; + uint8_t chipSelectPin = lis3Id; + uint8_t whoAmIReg = 0b0000'1111; + uint8_t whoAmIRegExpectedVal = 0b0011'1101; + if (chipSelectPin == mgm0Lis3mdlChipSelect) { + currentGpioId = gpioIds::MGM_0_LIS3_CS; + } else { + currentGpioId = gpioIds::MGM_2_LIS3_CS; + } + uint32_t spiSpeed = 10'000'000; + spi::SpiModes spiMode = spi::SpiModes::MODE_0; #ifdef RASPBERRY_PI - std::string deviceName = "/dev/spidev0.0"; + std::string deviceName = "/dev/spidev0.0"; #else - std::string deviceName = "/dev/spidev2.0"; + std::string deviceName = "/dev/spidev2.0"; #endif - int fileDescriptor = 0; + int fileDescriptor = 0; - UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR, - "SpiComIF::initializeInterface"); - if(fileHelper.getOpenResult()) { - sif::error << "SpiTestClass::performLis3Mdl3100Test: File descriptor could not be opened!" - << std::endl; - return; - } - setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); - spiTransferStruct.delay_usecs = 0; - - uint8_t whoAmIRegVal = readStmRegister(fileDescriptor, currentGpioId, whoAmIReg, false); - sif::info << "SpiTestClass::performLis3MdlTest: WHO AM I register 0b" << - std::bitset<8>(whoAmIRegVal) << std::endl; - if(whoAmIRegVal != whoAmIRegExpectedVal) { - sif::warning << "SpiTestClass::performLis3MdlTest: WHO AM I register invalid!" - << std::endl; - } + UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR, "SpiComIF::initializeInterface"); + if (fileHelper.getOpenResult()) { + sif::error << "SpiTestClass::performLis3Mdl3100Test: File descriptor could not be opened!" + << std::endl; + return; + } + setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); + spiTransferStruct.delay_usecs = 0; + uint8_t whoAmIRegVal = readStmRegister(fileDescriptor, currentGpioId, whoAmIReg, false); + sif::info << "SpiTestClass::performLis3MdlTest: WHO AM I register 0b" + << std::bitset<8>(whoAmIRegVal) << std::endl; + if (whoAmIRegVal != whoAmIRegExpectedVal) { + sif::warning << "SpiTestClass::performLis3MdlTest: WHO AM I register invalid!" << std::endl; + } } - void SpiTestClass::performL3gTest(uint8_t l3gId) { - /* Configure all SPI chip selects and pull them high */ - acsInit(); + /* Configure all SPI chip selects and pull them high */ + acsInit(); - gpioId_t currentGpioId = 0; - uint8_t chipSelectPin = l3gId; - uint8_t whoAmIReg = 0b0000'1111; - uint8_t whoAmIRegExpectedVal = 0b1101'0111; + gpioId_t currentGpioId = 0; + uint8_t chipSelectPin = l3gId; + uint8_t whoAmIReg = 0b0000'1111; + uint8_t whoAmIRegExpectedVal = 0b1101'0111; - if(chipSelectPin == gyro1L3gd20ChipSelect) { - currentGpioId = gpioIds::GYRO_1_L3G_CS; - } - else { - currentGpioId = gpioIds::GYRO_3_L3G_CS; - } - uint32_t spiSpeed = 3'900'000; - spi::SpiModes spiMode = spi::SpiModes::MODE_3; + if (chipSelectPin == gyro1L3gd20ChipSelect) { + currentGpioId = gpioIds::GYRO_1_L3G_CS; + } else { + currentGpioId = gpioIds::GYRO_3_L3G_CS; + } + uint32_t spiSpeed = 3'900'000; + spi::SpiModes spiMode = spi::SpiModes::MODE_3; #ifdef RASPBERRY_PI - std::string deviceName = "/dev/spidev0.0"; + std::string deviceName = "/dev/spidev0.0"; #else - std::string deviceName = "/dev/spidev2.0"; + std::string deviceName = "/dev/spidev2.0"; #endif - int fileDescriptor = 0; + int fileDescriptor = 0; - UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR, - "SpiComIF::initializeInterface"); - if(fileHelper.getOpenResult()) { - sif::error << "SpiTestClass::performLis3Mdl3100Test: File descriptor could not be opened!" - << std::endl; - return; - } - setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); - uint8_t whoAmIRegVal = readStmRegister(fileDescriptor, currentGpioId, whoAmIReg, false); - sif::info << "SpiTestClass::performLis3MdlTest: WHO AM I register 0b" << - std::bitset<8>(whoAmIRegVal) << std::endl; - if(whoAmIRegVal != whoAmIRegExpectedVal) { - sif::warning << "SpiTestClass::performL3gTest: Read WHO AM I register invalid!" << - std::endl; + UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR, "SpiComIF::initializeInterface"); + if (fileHelper.getOpenResult()) { + sif::error << "SpiTestClass::performLis3Mdl3100Test: File descriptor could not be opened!" + << std::endl; + return; + } + setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); + uint8_t whoAmIRegVal = readStmRegister(fileDescriptor, currentGpioId, whoAmIReg, false); + sif::info << "SpiTestClass::performLis3MdlTest: WHO AM I register 0b" + << std::bitset<8>(whoAmIRegVal) << std::endl; + if (whoAmIRegVal != whoAmIRegExpectedVal) { + sif::warning << "SpiTestClass::performL3gTest: Read WHO AM I register invalid!" << std::endl; + } + + uint8_t ctrlReg1Addr = 0b0010'0000; + { + uint8_t commandRegs[5]; + commandRegs[0] = 0b0000'1111; + commandRegs[1] = 0x0; + commandRegs[2] = 0x0; + /* Configure big endian data format */ + commandRegs[3] = 0b0100'0000; + commandRegs[4] = 0x0; + writeMultipleStmRegisters(fileDescriptor, currentGpioId, ctrlReg1Addr, commandRegs, + sizeof(commandRegs)); + uint8_t readRegs[5]; + readMultipleRegisters(fileDescriptor, currentGpioId, ctrlReg1Addr, readRegs, sizeof(readRegs)); + for (uint8_t idx = 0; idx < sizeof(readRegs); idx++) { + if (readRegs[idx] != commandRegs[0]) { + sif::warning << "SpiTestClass::performL3gTest: Read control register " + << static_cast(idx + 1) << " not equal to configured value" << std::endl; + } } + } - uint8_t ctrlReg1Addr = 0b0010'0000; - { - uint8_t commandRegs[5]; - commandRegs[0] = 0b0000'1111; - commandRegs[1] = 0x0; - commandRegs[2] = 0x0; - /* Configure big endian data format */ - commandRegs[3] = 0b0100'0000; - commandRegs[4] = 0x0; - writeMultipleStmRegisters(fileDescriptor, currentGpioId, ctrlReg1Addr, commandRegs, - sizeof(commandRegs)); - uint8_t readRegs[5]; - readMultipleRegisters(fileDescriptor, currentGpioId, ctrlReg1Addr, readRegs, - sizeof(readRegs)); - for(uint8_t idx = 0; idx < sizeof(readRegs); idx++) { - if(readRegs[idx] != commandRegs[0]) { - sif::warning << "SpiTestClass::performL3gTest: Read control register " << - static_cast(idx + 1) << " not equal to configured value" << std::endl; - } - } - } + uint8_t readOutBuffer[14]; + readMultipleStmRegisters(fileDescriptor, currentGpioId, ctrlReg1Addr, readOutBuffer, + sizeof(readOutBuffer)); - uint8_t readOutBuffer[14]; - readMultipleStmRegisters(fileDescriptor, currentGpioId, ctrlReg1Addr, readOutBuffer, - sizeof(readOutBuffer)); + uint8_t statusReg = readOutBuffer[7]; + sif::info << "SpiTestClass::performL3gTest: Status Register 0b" << std::bitset<8>(statusReg) + << std::endl; - uint8_t statusReg = readOutBuffer[7]; - sif::info << "SpiTestClass::performL3gTest: Status Register 0b" << - std::bitset<8>(statusReg) << std::endl; + uint16_t l3gRange = 245; + float scaleFactor = static_cast(l3gRange) / INT16_MAX; + /* The sensor spits out little endian */ + int16_t angVelocRawX = (readOutBuffer[8] << 8) | readOutBuffer[9]; + int16_t angVelocRawY = (readOutBuffer[10] << 8) | readOutBuffer[11]; + int16_t angVelocRawZ = (readOutBuffer[12] << 8) | readOutBuffer[13]; - uint16_t l3gRange = 245; - float scaleFactor = static_cast(l3gRange) / INT16_MAX; - /* The sensor spits out little endian */ - int16_t angVelocRawX = (readOutBuffer[8] << 8) | readOutBuffer[9]; - int16_t angVelocRawY = (readOutBuffer[10] << 8) | readOutBuffer[11]; - int16_t angVelocRawZ = (readOutBuffer[12] << 8) | readOutBuffer[13]; - - float angVelocX = scaleFactor * angVelocRawX; - float angVelocY = scaleFactor * angVelocRawY; - float angVelocZ = scaleFactor * angVelocRawZ; - - sif::info << "Angular velocities for the L3GD20H in degrees per second:" << std::endl; - sif::info << "X: " << angVelocX << std::endl; - sif::info << "Y: " << angVelocY << std::endl; - sif::info << "Z: " << angVelocZ << std::endl; + float angVelocX = scaleFactor * angVelocRawX; + float angVelocY = scaleFactor * angVelocRawY; + float angVelocZ = scaleFactor * angVelocRawZ; + sif::info << "Angular velocities for the L3GD20H in degrees per second:" << std::endl; + sif::info << "X: " << angVelocX << std::endl; + sif::info << "Y: " << angVelocY << std::endl; + sif::info << "Z: " << angVelocZ << std::endl; } void SpiTestClass::acsInit() { - GpioCookie* gpioCookie = new GpioCookie(); + GpioCookie *gpioCookie = new GpioCookie(); #ifdef RASPBERRY_PI - GpiodRegularByChip* gpio = nullptr; - std::string rpiGpioName = "gpiochip0"; - gpio = new GpiodRegularByChip(rpiGpioName, mgm0Lis3mdlChipSelect, "MGM_0_LIS3", - gpio::DIR_OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); + GpiodRegularByChip *gpio = nullptr; + std::string rpiGpioName = "gpiochip0"; + gpio = new GpiodRegularByChip(rpiGpioName, mgm0Lis3mdlChipSelect, "MGM_0_LIS3", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); - gpio = new GpiodRegularByChip(rpiGpioName, mgm1Rm3100ChipSelect, "MGM_1_RM3100", - gpio::DIR_OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); + gpio = new GpiodRegularByChip(rpiGpioName, mgm1Rm3100ChipSelect, "MGM_1_RM3100", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); - gpio = new GpiodRegularByChip(rpiGpioName, gyro0AdisChipSelect, "GYRO_0_ADIS", - gpio::DIR_OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); + gpio = new GpiodRegularByChip(rpiGpioName, gyro0AdisChipSelect, "GYRO_0_ADIS", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); - gpio = new GpiodRegularByChip(rpiGpioName, gyro1L3gd20ChipSelect, "GYRO_1_L3G", - gpio::DIR_OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); + gpio = new GpiodRegularByChip(rpiGpioName, gyro1L3gd20ChipSelect, "GYRO_1_L3G", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); - gpio = new GpiodRegularByChip(rpiGpioName, gyro3L3gd20ChipSelect, "GYRO_2_L3G", - gpio::DIR_OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); + gpio = new GpiodRegularByChip(rpiGpioName, gyro3L3gd20ChipSelect, "GYRO_2_L3G", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); - gpio = new GpiodRegularByChip(rpiGpioName, mgm2Lis3mdlChipSelect, "MGM_2_LIS3", - gpio::DIR_OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); + gpio = new GpiodRegularByChip(rpiGpioName, mgm2Lis3mdlChipSelect, "MGM_2_LIS3", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); - gpio = new GpiodRegularByChip(rpiGpioName, mgm3Rm3100ChipSelect, "MGM_3_RM3100", - gpio::DIR_OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); + gpio = new GpiodRegularByChip(rpiGpioName, mgm3Rm3100ChipSelect, "MGM_3_RM3100", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); #elif defined(XIPHOS_Q7S) - GpiodRegularByLineName* gpio = nullptr; - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_0_CS, "MGM_0_LIS3", gpio::DIR_OUT, - gpio::HIGH); - gpioCookie->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, "MGM_1_RM3100", gpio::DIR_OUT, - gpio::HIGH); - gpioCookie->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_2_CS, "MGM_2_LIS3", gpio::DIR_OUT, - gpio::HIGH); - gpioCookie->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, "MGM_3_RM3100", gpio::DIR_OUT, - gpio::HIGH); - gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); + GpiodRegularByLineName *gpio = nullptr; + gpio = + new GpiodRegularByLineName(q7s::gpioNames::MGM_0_CS, "MGM_0_LIS3", gpio::DIR_OUT, gpio::HIGH); + gpioCookie->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, "MGM_1_RM3100", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); + gpio = + new GpiodRegularByLineName(q7s::gpioNames::MGM_2_CS, "MGM_2_LIS3", gpio::DIR_OUT, gpio::HIGH); + gpioCookie->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, "MGM_3_RM3100", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ADIS_CS, "GYRO_0_ADIS", - gpio::DIR_OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_1_L3G_CS, "GYRO_1_L3G", gpio::DIR_OUT, - gpio::HIGH); - gpioCookie->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ADIS_CS, "GYRO_2_ADIS", - gpio::DIR_OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::GYRO_2_ADIS_CS, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_3_L3G_CS, "GYRO_3_L3G", gpio::DIR_OUT, - gpio::HIGH); - gpioCookie->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ADIS_CS, "GYRO_0_ADIS", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_1_L3G_CS, "GYRO_1_L3G", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ADIS_CS, "GYRO_2_ADIS", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::GYRO_2_ADIS_CS, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_3_L3G_CS, "GYRO_3_L3G", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); - // Enable pins must be pulled low for regular operations - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, "GYRO_0_ENABLE", gpio::DIR_OUT, - gpio::LOW); - gpioCookie->addGpio(gpioIds::GYRO_0_ENABLE, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, "GYRO_2_ENABLE", gpio::DIR_OUT, - gpio::LOW); - gpioCookie->addGpio(gpioIds::GYRO_2_ENABLE, gpio); + // Enable pins must be pulled low for regular operations + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, "GYRO_0_ENABLE", gpio::DIR_OUT, + gpio::LOW); + gpioCookie->addGpio(gpioIds::GYRO_0_ENABLE, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, "GYRO_2_ENABLE", gpio::DIR_OUT, + gpio::LOW); + gpioCookie->addGpio(gpioIds::GYRO_2_ENABLE, gpio); #endif - if (gpioIF != nullptr) { - gpioIF->addGpios(gpioCookie); - } + if (gpioIF != nullptr) { + gpioIF->addGpios(gpioCookie); + } } void SpiTestClass::setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed) { - int mode_test = SPI_MODE_3; - int retval = ioctl(spiFd, SPI_IOC_WR_MODE, &mode_test);//reinterpret_cast(&mode)); - if(retval != 0) { - utility::handleIoctlError("SpiTestClass::performRm3100Test: Setting SPI mode failed!"); - } + int mode_test = SPI_MODE_3; + int retval = ioctl(spiFd, SPI_IOC_WR_MODE, &mode_test); // reinterpret_cast(&mode)); + if (retval != 0) { + utility::handleIoctlError("SpiTestClass::performRm3100Test: Setting SPI mode failed!"); + } - retval = ioctl(spiFd, SPI_IOC_WR_MAX_SPEED_HZ, &speed); - if(retval != 0) { - utility::handleIoctlError("SpiTestClass::performRm3100Test: Setting SPI speed failed!"); - } + retval = ioctl(spiFd, SPI_IOC_WR_MAX_SPEED_HZ, &speed); + if (retval != 0) { + utility::handleIoctlError("SpiTestClass::performRm3100Test: Setting SPI speed failed!"); + } } void SpiTestClass::writeRegister(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t value) { - spiTransferStruct.len = 2; - sendBuffer[0] = reg; - sendBuffer[1] = value; + spiTransferStruct.len = 2; + sendBuffer[0] = reg; + sendBuffer[1] = value; - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullLow(chipSelect); - } - int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); - if(retval < 0) { - utility::handleIoctlError("SpiTestClass::writeRegister: Write failed"); - } - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullHigh(chipSelect); - } + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullLow(chipSelect); + } + int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); + if (retval < 0) { + utility::handleIoctlError("SpiTestClass::writeRegister: Write failed"); + } + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullHigh(chipSelect); + } } void SpiTestClass::writeStmRegister(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t value, - bool autoIncrement) { - if(autoIncrement) { - reg |= STM_AUTO_INCR_MASK; - } - writeRegister(fd, chipSelect, reg, value); + bool autoIncrement) { + if (autoIncrement) { + reg |= STM_AUTO_INCR_MASK; + } + writeRegister(fd, chipSelect, reg, value); } void SpiTestClass::writeMultipleStmRegisters(int fd, gpioId_t chipSelect, uint8_t reg, - uint8_t *values, size_t len) { - if(values == nullptr) { - return; - } - - reg |= STM_AUTO_INCR_MASK; - /* Clear read mask */ - reg &= ~STM_READ_MASK; - writeMultipleRegisters(fd, chipSelect, reg, values, len); + uint8_t *values, size_t len) { + if (values == nullptr) { + return; + } + reg |= STM_AUTO_INCR_MASK; + /* Clear read mask */ + reg &= ~STM_READ_MASK; + writeMultipleRegisters(fd, chipSelect, reg, values, len); } -void SpiTestClass::writeMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg, - uint8_t *values, size_t len) { - if(values == nullptr) { - return; - } +void SpiTestClass::writeMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t *values, + size_t len) { + if (values == nullptr) { + return; + } - sendBuffer[0] = reg; - std::memcpy(sendBuffer.data() + 1, values, len); - spiTransferStruct.len = len + 1; + sendBuffer[0] = reg; + std::memcpy(sendBuffer.data() + 1, values, len); + spiTransferStruct.len = len + 1; - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullLow(chipSelect); - } - int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); - if(retval < 0) { - utility::handleIoctlError("SpiTestClass::readRegister: Read failed"); - } - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullHigh(chipSelect); - } + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullLow(chipSelect); + } + int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); + if (retval < 0) { + utility::handleIoctlError("SpiTestClass::readRegister: Read failed"); + } + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullHigh(chipSelect); + } } uint8_t SpiTestClass::readRm3100Register(int fd, gpioId_t chipSelect, uint8_t reg) { - return readStmRegister(fd, chipSelect, reg, false); + return readStmRegister(fd, chipSelect, reg, false); } - -void SpiTestClass::readMultipleStmRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t *reply, - size_t len) { - reg |= STM_AUTO_INCR_MASK; - readMultipleRegisters(fd, chipSelect, reg, reply, len); +void SpiTestClass::readMultipleStmRegisters(int fd, gpioId_t chipSelect, uint8_t reg, + uint8_t *reply, size_t len) { + reg |= STM_AUTO_INCR_MASK; + readMultipleRegisters(fd, chipSelect, reg, reply, len); } void SpiTestClass::readMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t *reply, - size_t len) { - if(reply == nullptr) { - return; - } + size_t len) { + if (reply == nullptr) { + return; + } - spiTransferStruct.len = len + 1; - sendBuffer[0] = reg | STM_READ_MASK; + spiTransferStruct.len = len + 1; + sendBuffer[0] = reg | STM_READ_MASK; - for(uint8_t idx = 0; idx < len ; idx ++) { - sendBuffer[idx + 1] = 0; - } + for (uint8_t idx = 0; idx < len; idx++) { + sendBuffer[idx + 1] = 0; + } - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullLow(chipSelect); - } - int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); - if(retval < 0) { - utility::handleIoctlError("SpiTestClass::readRegister: Read failed"); - } - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullHigh(chipSelect); - } - std::memcpy(reply, recvBuffer.data() + 1, len); + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullLow(chipSelect); + } + int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); + if (retval < 0) { + utility::handleIoctlError("SpiTestClass::readRegister: Read failed"); + } + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullHigh(chipSelect); + } + std::memcpy(reply, recvBuffer.data() + 1, len); } uint8_t SpiTestClass::readStmRegister(int fd, gpioId_t chipSelect, uint8_t reg, - bool autoIncrement) { - reg |= STM_READ_MASK; - if(autoIncrement) { - reg |= STM_AUTO_INCR_MASK; - } - return readRegister(fd, chipSelect, reg); + bool autoIncrement) { + reg |= STM_READ_MASK; + if (autoIncrement) { + reg |= STM_AUTO_INCR_MASK; + } + return readRegister(fd, chipSelect, reg); } - uint8_t SpiTestClass::readRegister(int fd, gpioId_t chipSelect, uint8_t reg) { - spiTransferStruct.len = 2; - sendBuffer[0] = reg; - sendBuffer[1] = 0; + spiTransferStruct.len = 2; + sendBuffer[0] = reg; + sendBuffer[1] = 0; - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullLow(chipSelect); - } - int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); - if(retval < 0) { - utility::handleIoctlError("SpiTestClass::readRegister: Read failed"); - } - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullHigh(chipSelect); - } - return recvBuffer[1]; + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullLow(chipSelect); + } + int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); + if (retval < 0) { + utility::handleIoctlError("SpiTestClass::readRegister: Read failed"); + } + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullHigh(chipSelect); + } + return recvBuffer[1]; } diff --git a/linux/boardtest/SpiTestClass.h b/linux/boardtest/SpiTestClass.h index ffd56dd1..5df8cafb 100644 --- a/linux/boardtest/SpiTestClass.h +++ b/linux/boardtest/SpiTestClass.h @@ -13,83 +13,78 @@ #include -class SpiTestClass: public TestTask { -public: - enum TestModes { - NONE, - MGM_LIS3MDL, - MGM_RM3100, - GYRO_L3GD20H, - }; +class SpiTestClass : public TestTask { + public: + enum TestModes { + NONE, + MGM_LIS3MDL, + MGM_RM3100, + GYRO_L3GD20H, + }; - TestModes testMode; + TestModes testMode; - SpiTestClass(object_id_t objectId, GpioIF* gpioIF); + SpiTestClass(object_id_t objectId, GpioIF* gpioIF); - ReturnValue_t performOneShotAction() override; - ReturnValue_t performPeriodicAction() override; -private: + ReturnValue_t performOneShotAction() override; + ReturnValue_t performPeriodicAction() override; - GpioIF* gpioIF; + private: + GpioIF* gpioIF; - std::array recvBuffer; - std::array sendBuffer; - struct spi_ioc_transfer spiTransferStruct = {}; + std::array recvBuffer; + std::array sendBuffer; + struct spi_ioc_transfer spiTransferStruct = {}; - void performRm3100Test(uint8_t mgmId); - void performLis3MdlTest(uint8_t lis3Id); - void performL3gTest(uint8_t l3gId); + void performRm3100Test(uint8_t mgmId); + void performLis3MdlTest(uint8_t lis3Id); + void performL3gTest(uint8_t l3gId); - /* ACS board specific code which pulls all GPIOs high */ - void acsInit(); + /* ACS board specific code which pulls all GPIOs high */ + void acsInit(); - /* ACS board specific variables */ + /* ACS board specific variables */ #ifdef RASPBERRY_PI - uint8_t mgm0Lis3mdlChipSelect = gpio::MGM_0_BCM_PIN; - uint8_t mgm1Rm3100ChipSelect = gpio::MGM_1_BCM_PIN; - uint8_t mgm2Lis3mdlChipSelect = gpio::MGM_2_BCM_PIN; - uint8_t mgm3Rm3100ChipSelect = gpio::MGM_3_BCM_PIN; + uint8_t mgm0Lis3mdlChipSelect = gpio::MGM_0_BCM_PIN; + uint8_t mgm1Rm3100ChipSelect = gpio::MGM_1_BCM_PIN; + uint8_t mgm2Lis3mdlChipSelect = gpio::MGM_2_BCM_PIN; + uint8_t mgm3Rm3100ChipSelect = gpio::MGM_3_BCM_PIN; - uint8_t gyro0AdisChipSelect = gpio::GYRO_0_BCM_PIN; - uint8_t gyro1L3gd20ChipSelect = gpio::GYRO_1_BCM_PIN; - uint8_t gyro2AdisChipSelect = gpio::GYRO_2_BCM_PIN; - uint8_t gyro3L3gd20ChipSelect = gpio::GYRO_3_BCM_PIN; + uint8_t gyro0AdisChipSelect = gpio::GYRO_0_BCM_PIN; + uint8_t gyro1L3gd20ChipSelect = gpio::GYRO_1_BCM_PIN; + uint8_t gyro2AdisChipSelect = gpio::GYRO_2_BCM_PIN; + uint8_t gyro3L3gd20ChipSelect = gpio::GYRO_3_BCM_PIN; #else - uint8_t mgm0Lis3mdlChipSelect = 0; - uint8_t mgm1Rm3100ChipSelect = 0; - uint8_t gyro0AdisResetLine = 0; - uint8_t gyro0AdisChipSelect = 0; - uint8_t gyro1L3gd20ChipSelect = 0; - uint8_t gyro2L3gd20ChipSelect = 0; - uint8_t mgm2Lis3mdlChipSelect = 0; - uint8_t mgm3Rm3100ChipSelect = 0; + uint8_t mgm0Lis3mdlChipSelect = 0; + uint8_t mgm1Rm3100ChipSelect = 0; + uint8_t gyro0AdisResetLine = 0; + uint8_t gyro0AdisChipSelect = 0; + uint8_t gyro1L3gd20ChipSelect = 0; + uint8_t gyro2L3gd20ChipSelect = 0; + uint8_t mgm2Lis3mdlChipSelect = 0; + uint8_t mgm3Rm3100ChipSelect = 0; #endif - static constexpr uint8_t STM_READ_MASK = 0b1000'0000; - static constexpr uint8_t RM3100_READ_MASK = STM_READ_MASK; - static constexpr uint8_t STM_AUTO_INCR_MASK = 0b0100'0000; + static constexpr uint8_t STM_READ_MASK = 0b1000'0000; + static constexpr uint8_t RM3100_READ_MASK = STM_READ_MASK; + static constexpr uint8_t STM_AUTO_INCR_MASK = 0b0100'0000; - void setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed); + void setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed); - void writeStmRegister(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t value, - bool autoIncrement); - void writeMultipleStmRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t* values, - size_t len); - void writeMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t *values, - size_t len); - void writeRegister(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t value); - - uint8_t readRm3100Register(int fd, gpioId_t chipSelect, uint8_t reg); - uint8_t readStmRegister(int fd, gpioId_t chipSelect, uint8_t reg, bool autoIncrement); - uint8_t readRegister(int fd, gpioId_t chipSelect, uint8_t reg); - void readMultipleStmRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t *reply, - size_t len); - void readMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg, - uint8_t* reply, size_t len); + void writeStmRegister(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t value, + bool autoIncrement); + void writeMultipleStmRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t* values, + size_t len); + void writeMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t* values, + size_t len); + void writeRegister(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t value); + uint8_t readRm3100Register(int fd, gpioId_t chipSelect, uint8_t reg); + uint8_t readStmRegister(int fd, gpioId_t chipSelect, uint8_t reg, bool autoIncrement); + uint8_t readRegister(int fd, gpioId_t chipSelect, uint8_t reg); + void readMultipleStmRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t* reply, + size_t len); + void readMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t* reply, size_t len); }; - - - #endif /* LINUX_BOARDTEST_SPITESTCLASS_H_ */ diff --git a/linux/boardtest/UartTestClass.cpp b/linux/boardtest/UartTestClass.cpp index e69f0e5f..9b20ad13 100644 --- a/linux/boardtest/UartTestClass.cpp +++ b/linux/boardtest/UartTestClass.cpp @@ -5,110 +5,107 @@ #include "q7sConfig.h" #endif -#include "fsfw/serviceinterface/ServiceInterface.h" +#include // Error integer and strerror() function +#include // Contains file controls like O_RDWR +#include // write(), read(), close() +#include "fsfw/serviceinterface/ServiceInterface.h" #include "lwgps/lwgps.h" -#include // Contains file controls like O_RDWR -#include // Error integer and strerror() function -#include // write(), read(), close() +#define GPS_REPLY_WIRETAPPING 0 -#define GPS_REPLY_WIRETAPPING 0 - -UartTestClass::UartTestClass(object_id_t objectId): TestTask(objectId) { -} +UartTestClass::UartTestClass(object_id_t objectId) : TestTask(objectId) {} ReturnValue_t UartTestClass::initialize() { #if RPI_TEST_GPS_DEVICE == 1 - int result = lwgps_init(&gpsData); - if(result == 0) { - sif::warning << "lwgps_init error: " << result << std::endl; - } + int result = lwgps_init(&gpsData); + if (result == 0) { + sif::warning << "lwgps_init error: " << result << std::endl; + } - /* Get file descriptor */ - serialPort = open("/dev/serial0", O_RDWR); - if(serialPort < 0) { - sif::warning << "open call failed with error [" << errno << ", " << strerror(errno) - << std::endl; - } - /* Setting up UART parameters */ - tty.c_cflag &= ~PARENB; // Clear parity bit - tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication - tty.c_cflag &= ~CSIZE; // Clear all the size bits - tty.c_cflag |= CS8; // 8 bits per byte - tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control - tty.c_cflag |= CREAD | CLOCAL; // Turn on READ & ignore ctrl lines (CLOCAL = 1) - // Use canonical mode for GPS device - tty.c_lflag |= ICANON; - tty.c_lflag &= ~ECHO; // Disable echo - tty.c_lflag &= ~ECHOE; // Disable erasure - tty.c_lflag &= ~ECHONL; // Disable new-line echo - tty.c_lflag &= ~ISIG; // Disable interpretation of INTR, QUIT and SUSP - tty.c_iflag &= ~(IXON | IXOFF | IXANY); // Turn off s/w flow ctrl - tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL); // Disable any special handling of received bytes - tty.c_oflag &= ~OPOST; // Prevent special interpretation of output bytes (e.g. newline chars) - tty.c_oflag &= ~ONLCR; // Prevent conversion of newline to carriage return/line feed + /* Get file descriptor */ + serialPort = open("/dev/serial0", O_RDWR); + if (serialPort < 0) { + sif::warning << "open call failed with error [" << errno << ", " << strerror(errno) + << std::endl; + } + /* Setting up UART parameters */ + tty.c_cflag &= ~PARENB; // Clear parity bit + tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication + tty.c_cflag &= ~CSIZE; // Clear all the size bits + tty.c_cflag |= CS8; // 8 bits per byte + tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control + tty.c_cflag |= CREAD | CLOCAL; // Turn on READ & ignore ctrl lines (CLOCAL = 1) + // Use canonical mode for GPS device + tty.c_lflag |= ICANON; + tty.c_lflag &= ~ECHO; // Disable echo + tty.c_lflag &= ~ECHOE; // Disable erasure + tty.c_lflag &= ~ECHONL; // Disable new-line echo + tty.c_lflag &= ~ISIG; // Disable interpretation of INTR, QUIT and SUSP + tty.c_iflag &= ~(IXON | IXOFF | IXANY); // Turn off s/w flow ctrl + tty.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | + ICRNL); // Disable any special handling of received bytes + tty.c_oflag &= ~OPOST; // Prevent special interpretation of output bytes (e.g. newline chars) + tty.c_oflag &= ~ONLCR; // Prevent conversion of newline to carriage return/line feed - // Non-blocking mode - tty.c_cc[VTIME] = 0; - tty.c_cc[VMIN] = 0; + // Non-blocking mode + tty.c_cc[VTIME] = 0; + tty.c_cc[VMIN] = 0; - cfsetispeed(&tty, B9600); - cfsetospeed(&tty, B9600); - if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { - sif::warning << "tcsetattr call failed with error [" << errno << ", " << - strerror(errno) << std::endl;; - } - // Flush received and unread data. Those are old NMEA strings which are not relevant anymore - tcflush(serialPort, TCIFLUSH); + cfsetispeed(&tty, B9600); + cfsetospeed(&tty, B9600); + if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { + sif::warning << "tcsetattr call failed with error [" << errno << ", " << strerror(errno) + << std::endl; + ; + } + // Flush received and unread data. Those are old NMEA strings which are not relevant anymore + tcflush(serialPort, TCIFLUSH); #endif - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t UartTestClass::performOneShotAction() { #if RPI_TEST_GPS_DEVICE == 1 #endif - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t UartTestClass::performPeriodicAction() { #if RPI_TEST_GPS_DEVICE == 1 - int bytesRead = 0; - do { - bytesRead = read(serialPort, - reinterpret_cast(recBuf.data()), - static_cast(recBuf.size())); - if(bytesRead < 0) { - sif::warning << "UartTestClass::performPeriodicAction: read call failed with error [" << - errno << ", " << strerror(errno) << "]" << std::endl; - break; - } - else if(bytesRead >= static_cast(recBuf.size())) { - sif::debug << "UartTestClass::performPeriodicAction: " - "recv buffer might not be large enough" << std::endl; - } - else if(bytesRead > 0) { - // pass data to lwgps for processing + int bytesRead = 0; + do { + bytesRead = read(serialPort, reinterpret_cast(recBuf.data()), + static_cast(recBuf.size())); + if (bytesRead < 0) { + sif::warning << "UartTestClass::performPeriodicAction: read call failed with error [" << errno + << ", " << strerror(errno) << "]" << std::endl; + break; + } else if (bytesRead >= static_cast(recBuf.size())) { + sif::debug << "UartTestClass::performPeriodicAction: " + "recv buffer might not be large enough" + << std::endl; + } else if (bytesRead > 0) { + // pass data to lwgps for processing #if GPS_REPLY_WIRETAPPING == 1 - sif::info << recBuf.data() << std::endl; + sif::info << recBuf.data() << std::endl; #endif - int result = lwgps_process(&gpsData, recBuf.data(), bytesRead); - if(result == 0) { - sif::warning << "UartTestClass::performPeriodicAction: lwgps_process error" - << std::endl; - } - recvCnt++; - if(recvCnt == 6) { - recvCnt = 0; - sif::info << "GPS Data" << std::endl; - // Print messages - 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); - } - } - } while(bytesRead > 0); + int result = lwgps_process(&gpsData, recBuf.data(), bytesRead); + if (result == 0) { + sif::warning << "UartTestClass::performPeriodicAction: lwgps_process error" << std::endl; + } + recvCnt++; + if (recvCnt == 6) { + recvCnt = 0; + sif::info << "GPS Data" << std::endl; + // Print messages + 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); + } + } + } while (bytesRead > 0); #endif - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } diff --git a/linux/boardtest/UartTestClass.h b/linux/boardtest/UartTestClass.h index aeb2c396..f32d909d 100644 --- a/linux/boardtest/UartTestClass.h +++ b/linux/boardtest/UartTestClass.h @@ -1,27 +1,27 @@ #ifndef LINUX_BOARDTEST_UARTTESTCLASS_H_ #define LINUX_BOARDTEST_UARTTESTCLASS_H_ -#include "test/testtasks/TestTask.h" -#include "lwgps/lwgps.h" +#include // Contains POSIX terminal control definitions #include -#include // Contains POSIX terminal control definitions -class UartTestClass: public TestTask { -public: - UartTestClass(object_id_t objectId); +#include "lwgps/lwgps.h" +#include "test/testtasks/TestTask.h" - ReturnValue_t initialize() override; - ReturnValue_t performOneShotAction() override; - ReturnValue_t performPeriodicAction() override; -private: +class UartTestClass : public TestTask { + public: + UartTestClass(object_id_t objectId); - lwgps_t gpsData = {}; - struct termios tty = {}; - int serialPort = 0; - std::array recBuf; - uint8_t recvCnt = 0; + ReturnValue_t initialize() override; + ReturnValue_t performOneShotAction() override; + ReturnValue_t performPeriodicAction() override; + private: + lwgps_t gpsData = {}; + struct termios tty = {}; + int serialPort = 0; + std::array recBuf; + uint8_t recvCnt = 0; }; #endif /* LINUX_BOARDTEST_UARTTESTCLASS_H_ */ diff --git a/linux/csp/CspComIF.cpp b/linux/csp/CspComIF.cpp index 07fe63d3..fa372d4d 100644 --- a/linux/csp/CspComIF.cpp +++ b/linux/csp/CspComIF.cpp @@ -1,259 +1,246 @@ #include "CspComIF.h" -#include "CspCookie.h" -#include #include #include +#include -CspComIF::CspComIF(object_id_t objectId) : - SystemObject(objectId) { -} +#include "CspCookie.h" -CspComIF::~CspComIF() { -} +CspComIF::CspComIF(object_id_t objectId) : SystemObject(objectId) {} -ReturnValue_t CspComIF::initializeInterface(CookieIF *cookie) { - if(cookie == nullptr) { - return NULLPOINTER; - } +CspComIF::~CspComIF() {} - CspCookie* cspCookie = dynamic_cast(cookie); - if(cspCookie == nullptr) { - return NULLPOINTER; - } +ReturnValue_t CspComIF::initializeInterface(CookieIF* cookie) { + if (cookie == nullptr) { + return NULLPOINTER; + } - /* Perform CAN and CSP initialization only once */ - if(cspDeviceMap.empty()){ - sif::info << "Performing " << canInterface << " initialization.." << std::endl; + CspCookie* cspCookie = dynamic_cast(cookie); + if (cspCookie == nullptr) { + return NULLPOINTER; + } - /* Define the memory to allocate for the CSP stack */ - int buf_count = 10; - int buf_size = 300; - /* Init CSP and CSP buffer system */ - if (csp_init(cspOwnAddress) != CSP_ERR_NONE - || csp_buffer_init(buf_count, buf_size) != CSP_ERR_NONE) { - sif::error << "Failed to init CSP\r\n" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } + /* Perform CAN and CSP initialization only once */ + if (cspDeviceMap.empty()) { + sif::info << "Performing " << canInterface << " initialization.." << std::endl; - int promisc = 0; // Set filter mode on - csp_iface_t *csp_if_ptr = &csp_if; - csp_if_ptr = csp_can_socketcan_init(canInterface, bitrate, promisc); - - /* Set default route and start router */ - uint8_t address = CSP_DEFAULT_ROUTE; - uint8_t netmask = 0; - uint8_t mac = CSP_NODE_MAC; - int result = csp_rtable_set(address, netmask, csp_if_ptr, mac); - if(result != CSP_ERR_NONE){ - sif::error << "Failed to add can interface to router table" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - - /* Start the route task */ - unsigned int task_stack_size = 500; - unsigned int priority = 0; - result = csp_route_start_task(task_stack_size, priority); - if(result != CSP_ERR_NONE){ - sif::error << "Failed to start csp route task" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - sif::info << canInterface << " initialized successfully" << std::endl; - } - - uint8_t cspAddress = cspCookie->getCspAddress(); - uint16_t maxReplyLength = cspCookie->getMaxReplyLength(); - if(cspDeviceMap.find(cspAddress) == cspDeviceMap.end()){ - /* Insert device information in CSP map */ - cspDeviceMap.emplace(cspAddress, vectorBuffer(maxReplyLength)); - } - - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t CspComIF::sendMessage(CookieIF *cookie, - const uint8_t * sendData, size_t sendLen) { - int result; - if(cookie == NULL){ - return HasReturnvaluesIF::RETURN_FAILED; - } - CspCookie* cspCookie = dynamic_cast (cookie); - if(cspCookie == NULL){ - return HasReturnvaluesIF::RETURN_FAILED; - } - - /* Extract csp port and bytes to query from command buffer */ - uint8_t cspPort; - uint16_t querySize = 0; - result = getPortAndQuerySize(&sendData, &sendLen, &cspPort, &querySize); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - uint8_t cspAddress = cspCookie->getCspAddress(); - switch(cspPort) { - case(Ports::CSP_PING): { - initiatePingRequest(cspAddress, querySize); - break; - } - case(Ports::CSP_REBOOT): { - csp_reboot(cspAddress); - break; - } - case(Ports::P60_PORT_GNDWDT_RESET): - case(Ports::P60_PORT_RPARAM): { - /* No CSP fixed port was selected. Send data to the specified port and - * wait for querySize number of bytes */ - result = cspTransfer(cspAddress, cspPort, sendData, sendLen, - querySize); - if(result != HasReturnvaluesIF::RETURN_OK){ - return HasReturnvaluesIF::RETURN_FAILED; - } - replySize = querySize; - break; - } - default: - sif::error << "CspComIF: Invalid port specified" << std::endl; - break; - } - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t CspComIF::getSendSuccess(CookieIF *cookie) { - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t CspComIF::requestReceiveMessage(CookieIF *cookie, - size_t requestLen) { - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t CspComIF::readReceivedMessage(CookieIF *cookie, - uint8_t** buffer, size_t* size) { - if(cookie == NULL){ - return HasReturnvaluesIF::RETURN_FAILED; - } - CspCookie* cspCookie = dynamic_cast (cookie); - if(cspCookie == NULL){ - return HasReturnvaluesIF::RETURN_FAILED; - } - - uint8_t cspAddress = cspCookie->getCspAddress(); - - *buffer = cspDeviceMap[cspAddress].data(); - *size = replySize; - - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t CspComIF::cspTransfer(uint8_t cspAddress, uint8_t cspPort, - const uint8_t* cmdBuffer, int cmdLen, uint16_t querySize) { - - uint32_t timeout_ms = 1000; - uint16_t bytesRead = 0; - int32_t expectedSize = (int32_t)querySize; - vectorBufferIter iter = cspDeviceMap.find(cspAddress); - if(iter == cspDeviceMap.end()){ - sif::error << "CSP device with address " << cspAddress << " no found in" - << " device map" << std::endl; - } - uint8_t* replyBuffer = iter->second.data(); - - csp_conn_t * conn = csp_connect(CSP_PRIO_HIGH, cspAddress, cspPort, 0, - CSP_O_NONE); - - csp_packet_t* commandPacket = (csp_packet_t*)csp_buffer_get(cmdLen); - if (commandPacket == NULL) { - sif::error << "CspComIF::cspTransfer: Failed to get memory for a csp packet from the csp " - << "stack" << std::endl; - csp_close(conn); - return RETURN_FAILED; + /* Define the memory to allocate for the CSP stack */ + int buf_count = 10; + int buf_size = 300; + /* Init CSP and CSP buffer system */ + if (csp_init(cspOwnAddress) != CSP_ERR_NONE || + csp_buffer_init(buf_count, buf_size) != CSP_ERR_NONE) { + sif::error << "Failed to init CSP\r\n" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; } - memcpy(commandPacket->data, cmdBuffer, cmdLen); - commandPacket->length = cmdLen; + int promisc = 0; // Set filter mode on + csp_iface_t* csp_if_ptr = &csp_if; + csp_if_ptr = csp_can_socketcan_init(canInterface, bitrate, promisc); - if (!csp_send(conn, commandPacket, timeout_ms)) { - csp_buffer_free(commandPacket); - sif::error << "CspComIF::cspTransfer: Failed to send csp packet" << std::endl; - csp_close(conn); - return RETURN_FAILED; + /* Set default route and start router */ + uint8_t address = CSP_DEFAULT_ROUTE; + uint8_t netmask = 0; + uint8_t mac = CSP_NODE_MAC; + int result = csp_rtable_set(address, netmask, csp_if_ptr, mac); + if (result != CSP_ERR_NONE) { + sif::error << "Failed to add can interface to router table" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; } - /* Return when no reply is expected */ - if (expectedSize == 0) { - return RETURN_OK; + /* Start the route task */ + unsigned int task_stack_size = 500; + unsigned int priority = 0; + result = csp_route_start_task(task_stack_size, priority); + if (result != CSP_ERR_NONE) { + sif::error << "Failed to start csp route task" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; } + sif::info << canInterface << " initialized successfully" << std::endl; + } - csp_packet_t * reply; + uint8_t cspAddress = cspCookie->getCspAddress(); + uint16_t maxReplyLength = cspCookie->getMaxReplyLength(); + if (cspDeviceMap.find(cspAddress) == cspDeviceMap.end()) { + /* Insert device information in CSP map */ + cspDeviceMap.emplace(cspAddress, vectorBuffer(maxReplyLength)); + } + + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t CspComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) { + int result; + if (cookie == NULL) { + return HasReturnvaluesIF::RETURN_FAILED; + } + CspCookie* cspCookie = dynamic_cast(cookie); + if (cspCookie == NULL) { + return HasReturnvaluesIF::RETURN_FAILED; + } + + /* Extract csp port and bytes to query from command buffer */ + uint8_t cspPort; + uint16_t querySize = 0; + result = getPortAndQuerySize(&sendData, &sendLen, &cspPort, &querySize); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + uint8_t cspAddress = cspCookie->getCspAddress(); + switch (cspPort) { + case (Ports::CSP_PING): { + initiatePingRequest(cspAddress, querySize); + break; + } + case (Ports::CSP_REBOOT): { + csp_reboot(cspAddress); + break; + } + case (Ports::P60_PORT_GNDWDT_RESET): + case (Ports::P60_PORT_RPARAM): { + /* No CSP fixed port was selected. Send data to the specified port and + * wait for querySize number of bytes */ + result = cspTransfer(cspAddress, cspPort, sendData, sendLen, querySize); + if (result != HasReturnvaluesIF::RETURN_OK) { + return HasReturnvaluesIF::RETURN_FAILED; + } + replySize = querySize; + break; + } + default: + sif::error << "CspComIF: Invalid port specified" << std::endl; + break; + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t CspComIF::getSendSuccess(CookieIF* cookie) { return HasReturnvaluesIF::RETURN_OK; } + +ReturnValue_t CspComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLen) { + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t CspComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) { + if (cookie == NULL) { + return HasReturnvaluesIF::RETURN_FAILED; + } + CspCookie* cspCookie = dynamic_cast(cookie); + if (cspCookie == NULL) { + return HasReturnvaluesIF::RETURN_FAILED; + } + + uint8_t cspAddress = cspCookie->getCspAddress(); + + *buffer = cspDeviceMap[cspAddress].data(); + *size = replySize; + + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t CspComIF::cspTransfer(uint8_t cspAddress, uint8_t cspPort, const uint8_t* cmdBuffer, + int cmdLen, uint16_t querySize) { + uint32_t timeout_ms = 1000; + uint16_t bytesRead = 0; + int32_t expectedSize = (int32_t)querySize; + vectorBufferIter iter = cspDeviceMap.find(cspAddress); + if (iter == cspDeviceMap.end()) { + sif::error << "CSP device with address " << cspAddress << " no found in" + << " device map" << std::endl; + } + uint8_t* replyBuffer = iter->second.data(); + + csp_conn_t* conn = csp_connect(CSP_PRIO_HIGH, cspAddress, cspPort, 0, CSP_O_NONE); + + csp_packet_t* commandPacket = (csp_packet_t*)csp_buffer_get(cmdLen); + if (commandPacket == NULL) { + sif::error << "CspComIF::cspTransfer: Failed to get memory for a csp packet from the csp " + << "stack" << std::endl; + csp_close(conn); + return RETURN_FAILED; + } + + memcpy(commandPacket->data, cmdBuffer, cmdLen); + commandPacket->length = cmdLen; + + if (!csp_send(conn, commandPacket, timeout_ms)) { + csp_buffer_free(commandPacket); + sif::error << "CspComIF::cspTransfer: Failed to send csp packet" << std::endl; + csp_close(conn); + return RETURN_FAILED; + } + + /* Return when no reply is expected */ + if (expectedSize == 0) { + return RETURN_OK; + } + + csp_packet_t* reply; + reply = csp_read(conn, timeout_ms); + if (reply == NULL) { + sif::error << "CspComIF::cspTransfer: Failed to read csp packet" << std::endl; + csp_close(conn); + return RETURN_FAILED; + } + memcpy(replyBuffer, reply->data, reply->length); + expectedSize = expectedSize - reply->length; + bytesRead += reply->length; + csp_buffer_free(reply); + while (expectedSize > 0) { reply = csp_read(conn, timeout_ms); if (reply == NULL) { - sif::error << "CspComIF::cspTransfer: Failed to read csp packet" << std::endl; - csp_close(conn); - return RETURN_FAILED; + sif::error << "CspComIF::cspTransfer: Failed to read csp packet" << std::endl; + csp_close(conn); + return RETURN_FAILED; } - memcpy(replyBuffer, reply->data, reply->length); + if ((reply->length + bytesRead) > iter->second.size()) { + sif::error << "CspComIF::cspTransfer: Reply buffer to short" << std::endl; + csp_buffer_free(reply); + csp_close(conn); + return RETURN_FAILED; + } + memcpy(replyBuffer + bytesRead, reply->data, reply->length); expectedSize = expectedSize - reply->length; bytesRead += reply->length; csp_buffer_free(reply); - while (expectedSize > 0) { - reply = csp_read(conn, timeout_ms); - if (reply == NULL) { - sif::error << "CspComIF::cspTransfer: Failed to read csp packet" << std::endl; - csp_close(conn); - return RETURN_FAILED; - } - if ((reply->length + bytesRead) > iter->second.size()) { - sif::error << "CspComIF::cspTransfer: Reply buffer to short" << std::endl; - csp_buffer_free(reply); - csp_close(conn); - return RETURN_FAILED; - } - memcpy(replyBuffer + bytesRead, reply->data, reply->length); - expectedSize = expectedSize - reply->length; - bytesRead += reply->length; - csp_buffer_free(reply); - } + } - if(expectedSize != 0){ - sif::error << "CspComIF::cspTransfer: Received more bytes than requested" << std::endl; - sif::debug << "CspComIF::cspTransfer: Received bytes: " << bytesRead << std::endl; - csp_close(conn); - return RETURN_FAILED; - } + if (expectedSize != 0) { + sif::error << "CspComIF::cspTransfer: Received more bytes than requested" << std::endl; + sif::debug << "CspComIF::cspTransfer: Received bytes: " << bytesRead << std::endl; + csp_close(conn); + return RETURN_FAILED; + } - csp_close(conn); + csp_close(conn); - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t CspComIF::getPortAndQuerySize(const uint8_t** sendData, - size_t* sendLen, uint8_t* cspPort, uint16_t* querySize) { - ReturnValue_t result = SerializeAdapter::deSerialize(cspPort, sendData, - sendLen, SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "CspComIF: Failed to deserialize CSP port from command " - << "buffer" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - SerializeAdapter::deSerialize(querySize, sendData, sendLen, - SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "CspComIF: Failed to deserialize querySize from command " - << "buffer" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t CspComIF::getPortAndQuerySize(const uint8_t** sendData, size_t* sendLen, + uint8_t* cspPort, uint16_t* querySize) { + ReturnValue_t result = + SerializeAdapter::deSerialize(cspPort, sendData, sendLen, SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "CspComIF: Failed to deserialize CSP port from command " + << "buffer" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + SerializeAdapter::deSerialize(querySize, sendData, sendLen, SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "CspComIF: Failed to deserialize querySize from command " + << "buffer" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } -void CspComIF::initiatePingRequest(uint8_t cspAddress, uint16_t querySize){ - uint32_t timeout_ms = 500; - uint32_t replyTime = csp_ping(cspAddress, timeout_ms, querySize, - CSP_O_NONE); - sif::info << "Ping address: " << cspAddress << ", reply after " - << replyTime << " ms" << std::endl; - /* Store reply time in reply buffer * */ - uint8_t* replyBuffer = cspDeviceMap[cspAddress].data(); - memcpy(replyBuffer, &replyTime, sizeof(replyTime)); - replySize = sizeof(replyTime); +void CspComIF::initiatePingRequest(uint8_t cspAddress, uint16_t querySize) { + uint32_t timeout_ms = 500; + uint32_t replyTime = csp_ping(cspAddress, timeout_ms, querySize, CSP_O_NONE); + sif::info << "Ping address: " << cspAddress << ", reply after " << replyTime << " ms" + << std::endl; + /* Store reply time in reply buffer * */ + uint8_t* replyBuffer = cspDeviceMap[cspAddress].data(); + memcpy(replyBuffer, &replyTime, sizeof(replyTime)); + replySize = sizeof(replyTime); } diff --git a/linux/csp/CspComIF.h b/linux/csp/CspComIF.h index 4b8d323b..d36bbf4f 100644 --- a/linux/csp/CspComIF.h +++ b/linux/csp/CspComIF.h @@ -1,13 +1,13 @@ #ifndef LINUX_CSP_CSPCOMIF_H_ #define LINUX_CSP_CSPCOMIF_H_ +#include #include #include #include -#include -#include #include +#include /** * @brief This class serves as the communication interface to devices @@ -15,75 +15,65 @@ * in this implementation. * @author J. Meier */ -class CspComIF: public DeviceCommunicationIF, public SystemObject { -public: - CspComIF(object_id_t objectId); - virtual ~CspComIF(); +class CspComIF : public DeviceCommunicationIF, public SystemObject { + public: + CspComIF(object_id_t objectId); + virtual ~CspComIF(); - ReturnValue_t initializeInterface(CookieIF * cookie) override; - ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t * sendData, - size_t sendLen) override; - ReturnValue_t getSendSuccess(CookieIF *cookie) override; - ReturnValue_t requestReceiveMessage(CookieIF *cookie, - size_t requestLen) override; - ReturnValue_t readReceivedMessage(CookieIF *cookie, - uint8_t **readData, size_t *readLen) override; + ReturnValue_t initializeInterface(CookieIF *cookie) override; + ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t *sendData, size_t sendLen) override; + ReturnValue_t getSendSuccess(CookieIF *cookie) override; + ReturnValue_t requestReceiveMessage(CookieIF *cookie, size_t requestLen) override; + ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **readData, size_t *readLen) override; -private: + private: + /** + * @brief This function initiates the CSP transfer. + * + * @param cspAddress The CSP address of the target device. + * @param cspPort The port of the target device. + * @param timeout The timeout to wait for csp_send and csp_read + * functions. Specifies how long the functions wait + * for a successful operation. + * @param cmdBuffer The data to send. + * @param cmdLen The number of bytes to send. + * @param querySize The size of the requested message. + */ + ReturnValue_t cspTransfer(uint8_t cspAddress, uint8_t cspPort, const uint8_t *cmdBuffer, + int cmdLen, uint16_t querySize); - /** - * @brief This function initiates the CSP transfer. - * - * @param cspAddress The CSP address of the target device. - * @param cspPort The port of the target device. - * @param timeout The timeout to wait for csp_send and csp_read - * functions. Specifies how long the functions wait - * for a successful operation. - * @param cmdBuffer The data to send. - * @param cmdLen The number of bytes to send. - * @param querySize The size of the requested message. - */ - ReturnValue_t cspTransfer(uint8_t cspAddress, uint8_t cspPort, - const uint8_t* cmdBuffer, int cmdLen, uint16_t querySize); + enum Ports { CSP_PING = 1, CSP_REBOOT = 4, P60_PORT_RPARAM = 7, P60_PORT_GNDWDT_RESET = 9 }; - enum Ports { - CSP_PING = 1, - CSP_REBOOT = 4, - P60_PORT_RPARAM = 7, - P60_PORT_GNDWDT_RESET = 9 - }; + typedef uint8_t node_t; + using vectorBuffer = std::vector; + using VectorBufferMap = std::unordered_map; + using vectorBufferIter = VectorBufferMap::iterator; + /* In this map assigns reply buffers to a CSP device */ + VectorBufferMap cspDeviceMap; - typedef uint8_t node_t; - using vectorBuffer = std::vector; - using VectorBufferMap = std::unordered_map; - using vectorBufferIter = VectorBufferMap::iterator; + uint16_t replySize = 0; - /* In this map assigns reply buffers to a CSP device */ - VectorBufferMap cspDeviceMap; + /* This is the CSP address of the OBC. */ + node_t cspOwnAddress = 1; - uint16_t replySize = 0; + /* Interface struct for csp protocol stack */ + csp_iface_t csp_if; - /* This is the CSP address of the OBC. */ - node_t cspOwnAddress = 1; + char canInterface[5] = "can0"; + int bitrate = 1000; - /* Interface struct for csp protocol stack */ - csp_iface_t csp_if; + /** + * @brief Function to extract the csp port and the query size from the + * command buffer. + */ + ReturnValue_t getPortAndQuerySize(const uint8_t **sendData, size_t *sendLen, uint8_t *cspPort, + uint16_t *querySize); - char canInterface[5] = "can0"; - int bitrate = 1000; - - /** - * @brief Function to extract the csp port and the query size from the - * command buffer. - */ - ReturnValue_t getPortAndQuerySize(const uint8_t** sendData, size_t* sendLen, - uint8_t* cspPort, uint16_t* querySize); - - /** - * @brief This function initiates the ping request. - */ - void initiatePingRequest(uint8_t cspAddress, uint16_t querySize); + /** + * @brief This function initiates the ping request. + */ + void initiatePingRequest(uint8_t cspAddress, uint16_t querySize); }; #endif /* LINUX_CSP_CSPCOMIF_H_ */ diff --git a/linux/csp/CspCookie.cpp b/linux/csp/CspCookie.cpp index 18cfabd2..39274908 100644 --- a/linux/csp/CspCookie.cpp +++ b/linux/csp/CspCookie.cpp @@ -1,16 +1,10 @@ #include "CspCookie.h" -CspCookie::CspCookie(uint16_t maxReplyLength_, uint8_t cspAddress_) : - maxReplyLength(maxReplyLength_), cspAddress(cspAddress_) { -} +CspCookie::CspCookie(uint16_t maxReplyLength_, uint8_t cspAddress_) + : maxReplyLength(maxReplyLength_), cspAddress(cspAddress_) {} -CspCookie::~CspCookie() { -} +CspCookie::~CspCookie() {} -uint16_t CspCookie::getMaxReplyLength(){ - return maxReplyLength; -} +uint16_t CspCookie::getMaxReplyLength() { return maxReplyLength; } -uint8_t CspCookie::getCspAddress(){ - return cspAddress; -} +uint8_t CspCookie::getCspAddress() { return cspAddress; } diff --git a/linux/csp/CspCookie.h b/linux/csp/CspCookie.h index 4514c257..e59f3d35 100644 --- a/linux/csp/CspCookie.h +++ b/linux/csp/CspCookie.h @@ -2,6 +2,7 @@ #define LINUX_CSP_CSPCOOKIE_H_ #include + #include /** @@ -9,19 +10,17 @@ * Protocol). * @author J. Meier */ -class CspCookie: public CookieIF { -public: +class CspCookie : public CookieIF { + public: + CspCookie(uint16_t maxReplyLength_, uint8_t cspAddress_); + virtual ~CspCookie(); - CspCookie(uint16_t maxReplyLength_, uint8_t cspAddress_); - virtual ~CspCookie(); + uint16_t getMaxReplyLength(); + uint8_t getCspAddress(); - uint16_t getMaxReplyLength(); - uint8_t getCspAddress(); - -private: - - uint16_t maxReplyLength; - uint8_t cspAddress; + private: + uint16_t maxReplyLength; + uint8_t cspAddress; }; #endif /* LINUX_CSP_CSPCOOKIE_H_ */ diff --git a/linux/devices/SolarArrayDeploymentHandler.cpp b/linux/devices/SolarArrayDeploymentHandler.cpp index eea546f6..fed3992b 100644 --- a/linux/devices/SolarArrayDeploymentHandler.cpp +++ b/linux/devices/SolarArrayDeploymentHandler.cpp @@ -1,202 +1,209 @@ #include "SolarArrayDeploymentHandler.h" -#include #include - -#include +#include #include #include - +#include SolarArrayDeploymentHandler::SolarArrayDeploymentHandler(object_id_t setObjectId_, - object_id_t gpioDriverId_, CookieIF * gpioCookie_, object_id_t mainLineSwitcherObjectId_, - uint8_t mainLineSwitch_, gpioId_t deplSA1, gpioId_t deplSA2, uint32_t burnTimeMs) : - SystemObject(setObjectId_), gpioDriverId(gpioDriverId_), gpioCookie(gpioCookie_), - mainLineSwitcherObjectId(mainLineSwitcherObjectId_), mainLineSwitch(mainLineSwitch_), - deplSA1(deplSA1), deplSA2(deplSA2), burnTimeMs(burnTimeMs), actionHelper(this, nullptr) { - commandQueue = QueueFactory::instance()->createMessageQueue(cmdQueueSize, - MessageQueueMessage::MAX_MESSAGE_SIZE); + object_id_t gpioDriverId_, + CookieIF* gpioCookie_, + object_id_t mainLineSwitcherObjectId_, + uint8_t mainLineSwitch_, gpioId_t deplSA1, + gpioId_t deplSA2, uint32_t burnTimeMs) + : SystemObject(setObjectId_), + gpioDriverId(gpioDriverId_), + gpioCookie(gpioCookie_), + mainLineSwitcherObjectId(mainLineSwitcherObjectId_), + mainLineSwitch(mainLineSwitch_), + deplSA1(deplSA1), + deplSA2(deplSA2), + burnTimeMs(burnTimeMs), + actionHelper(this, nullptr) { + commandQueue = QueueFactory::instance()->createMessageQueue( + cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE); } -SolarArrayDeploymentHandler::~SolarArrayDeploymentHandler() { -} +SolarArrayDeploymentHandler::~SolarArrayDeploymentHandler() {} ReturnValue_t SolarArrayDeploymentHandler::performOperation(uint8_t operationCode) { - - if (operationCode == DeviceHandlerIF::PERFORM_OPERATION) { - handleStateMachine(); - return RETURN_OK; - } + if (operationCode == DeviceHandlerIF::PERFORM_OPERATION) { + handleStateMachine(); return RETURN_OK; + } + return RETURN_OK; } ReturnValue_t SolarArrayDeploymentHandler::initialize() { - ReturnValue_t result = SystemObject::initialize(); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + ReturnValue_t result = SystemObject::initialize(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - gpioInterface = ObjectManager::instance()->get(gpioDriverId); - if (gpioInterface == nullptr) { - sif::error << "SolarArrayDeploymentHandler::initialize: Invalid Gpio interface." - << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + gpioInterface = ObjectManager::instance()->get(gpioDriverId); + if (gpioInterface == nullptr) { + sif::error << "SolarArrayDeploymentHandler::initialize: Invalid Gpio interface." << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = gpioInterface->addGpios(dynamic_cast(gpioCookie)); - if (result != RETURN_OK) { - sif::error << "SolarArrayDeploymentHandler::initialize: Failed to initialize Gpio interface" - << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = gpioInterface->addGpios(dynamic_cast(gpioCookie)); + if (result != RETURN_OK) { + sif::error << "SolarArrayDeploymentHandler::initialize: Failed to initialize Gpio interface" + << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - if (mainLineSwitcherObjectId != objects::NO_OBJECT) { - mainLineSwitcher = ObjectManager::instance()->get(mainLineSwitcherObjectId); - if (mainLineSwitcher == nullptr) { - sif::error - << "SolarArrayDeploymentHandler::initialize: Main line switcher failed to fetch object" - << "from object ID." << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + if (mainLineSwitcherObjectId != objects::NO_OBJECT) { + mainLineSwitcher = ObjectManager::instance()->get(mainLineSwitcherObjectId); + if (mainLineSwitcher == nullptr) { + sif::error + << "SolarArrayDeploymentHandler::initialize: Main line switcher failed to fetch object" + << "from object ID." << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; } + } - result = actionHelper.initialize(commandQueue); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = actionHelper.initialize(commandQueue); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - return RETURN_OK; + return RETURN_OK; } void SolarArrayDeploymentHandler::handleStateMachine() { - switch (stateMachine) { + switch (stateMachine) { case WAIT_ON_DELOYMENT_COMMAND: - readCommandQueue(); - break; + readCommandQueue(); + break; case SWITCH_8V_ON: - mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_ON); - mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs()); - stateMachine = WAIT_ON_8V_SWITCH; - break; + mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_ON); + mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs()); + stateMachine = WAIT_ON_8V_SWITCH; + break; case WAIT_ON_8V_SWITCH: - performWaitOn8VActions(); - break; + performWaitOn8VActions(); + break; case SWITCH_DEPL_GPIOS: - switchDeploymentTransistors(); - break; + switchDeploymentTransistors(); + break; case WAIT_ON_DEPLOYMENT_FINISH: - handleDeploymentFinish(); - break; + handleDeploymentFinish(); + break; case WAIT_FOR_MAIN_SWITCH_OFF: - if (mainLineSwitcher->getSwitchState(mainLineSwitch) == PowerSwitchIF::SWITCH_OFF) { - stateMachine = WAIT_ON_DELOYMENT_COMMAND; - } else if (mainSwitchCountdown.hasTimedOut()) { - triggerEvent(MAIN_SWITCH_OFF_TIMEOUT); - sif::error << "SolarArrayDeploymentHandler::handleStateMachine: Failed to switch main" - << " switch off" << std::endl; - stateMachine = WAIT_ON_DELOYMENT_COMMAND; - } - break; + if (mainLineSwitcher->getSwitchState(mainLineSwitch) == PowerSwitchIF::SWITCH_OFF) { + stateMachine = WAIT_ON_DELOYMENT_COMMAND; + } else if (mainSwitchCountdown.hasTimedOut()) { + triggerEvent(MAIN_SWITCH_OFF_TIMEOUT); + sif::error << "SolarArrayDeploymentHandler::handleStateMachine: Failed to switch main" + << " switch off" << std::endl; + stateMachine = WAIT_ON_DELOYMENT_COMMAND; + } + break; default: - sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Invalid state" << std::endl; - break; - } + sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Invalid state" << std::endl; + break; + } } void SolarArrayDeploymentHandler::performWaitOn8VActions() { - if (mainLineSwitcher->getSwitchState(mainLineSwitch) == PowerSwitchIF::SWITCH_ON) { - stateMachine = SWITCH_DEPL_GPIOS; - } else { - if (mainSwitchCountdown.hasTimedOut()) { - triggerEvent(MAIN_SWITCH_ON_TIMEOUT); - actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, - MAIN_SWITCH_TIMEOUT_FAILURE); - stateMachine = WAIT_ON_DELOYMENT_COMMAND; - } + if (mainLineSwitcher->getSwitchState(mainLineSwitch) == PowerSwitchIF::SWITCH_ON) { + stateMachine = SWITCH_DEPL_GPIOS; + } else { + if (mainSwitchCountdown.hasTimedOut()) { + triggerEvent(MAIN_SWITCH_ON_TIMEOUT); + actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, + MAIN_SWITCH_TIMEOUT_FAILURE); + stateMachine = WAIT_ON_DELOYMENT_COMMAND; } + } } void SolarArrayDeploymentHandler::switchDeploymentTransistors() { - ReturnValue_t result = RETURN_OK; - result = gpioInterface->pullHigh(deplSA1); - if (result != RETURN_OK) { - sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" - " array deployment switch 1 high " << std::endl; - /* If gpio switch high failed, state machine is reset to wait for a command reinitiating - * the deployment sequence. */ - stateMachine = WAIT_ON_DELOYMENT_COMMAND; - triggerEvent(DEPL_SA1_GPIO_SWTICH_ON_FAILED); - actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, - SWITCHING_DEPL_SA2_FAILED); - mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); - } - result = gpioInterface->pullHigh(deplSA2); - if (result != RETURN_OK) { - sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" - " array deployment switch 2 high " << std::endl; - stateMachine = WAIT_ON_DELOYMENT_COMMAND; - triggerEvent(DEPL_SA2_GPIO_SWTICH_ON_FAILED); - actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, - SWITCHING_DEPL_SA2_FAILED); - mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); - } - deploymentCountdown.setTimeout(burnTimeMs); - stateMachine = WAIT_ON_DEPLOYMENT_FINISH; + ReturnValue_t result = RETURN_OK; + result = gpioInterface->pullHigh(deplSA1); + if (result != RETURN_OK) { + sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" + " array deployment switch 1 high " + << std::endl; + /* If gpio switch high failed, state machine is reset to wait for a command reinitiating + * the deployment sequence. */ + stateMachine = WAIT_ON_DELOYMENT_COMMAND; + triggerEvent(DEPL_SA1_GPIO_SWTICH_ON_FAILED); + actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, SWITCHING_DEPL_SA2_FAILED); + mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); + } + result = gpioInterface->pullHigh(deplSA2); + if (result != RETURN_OK) { + sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" + " array deployment switch 2 high " + << std::endl; + stateMachine = WAIT_ON_DELOYMENT_COMMAND; + triggerEvent(DEPL_SA2_GPIO_SWTICH_ON_FAILED); + actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, SWITCHING_DEPL_SA2_FAILED); + mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); + } + deploymentCountdown.setTimeout(burnTimeMs); + stateMachine = WAIT_ON_DEPLOYMENT_FINISH; } void SolarArrayDeploymentHandler::handleDeploymentFinish() { - ReturnValue_t result = RETURN_OK; - if (deploymentCountdown.hasTimedOut()) { - actionHelper.finish(true, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, RETURN_OK); - result = gpioInterface->pullLow(deplSA1); - if (result != RETURN_OK) { - sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" - " array deployment switch 1 low " << std::endl; - } - result = gpioInterface->pullLow(deplSA2); - if (result != RETURN_OK) { - sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" - " array deployment switch 2 low " << std::endl; - } - mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); - mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs()); - stateMachine = WAIT_FOR_MAIN_SWITCH_OFF; + ReturnValue_t result = RETURN_OK; + if (deploymentCountdown.hasTimedOut()) { + actionHelper.finish(true, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, RETURN_OK); + result = gpioInterface->pullLow(deplSA1); + if (result != RETURN_OK) { + sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" + " array deployment switch 1 low " + << std::endl; } + result = gpioInterface->pullLow(deplSA2); + if (result != RETURN_OK) { + sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" + " array deployment switch 2 low " + << std::endl; + } + mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); + mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs()); + stateMachine = WAIT_FOR_MAIN_SWITCH_OFF; + } } void SolarArrayDeploymentHandler::readCommandQueue() { - CommandMessage command; - ReturnValue_t result = commandQueue->receiveMessage(&command); - if (result != RETURN_OK) { - return; - } + CommandMessage command; + ReturnValue_t result = commandQueue->receiveMessage(&command); + if (result != RETURN_OK) { + return; + } - result = actionHelper.handleActionMessage(&command); - if (result == RETURN_OK) { - return; - } + result = actionHelper.handleActionMessage(&command); + if (result == RETURN_OK) { + return; + } } ReturnValue_t SolarArrayDeploymentHandler::executeAction(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { - ReturnValue_t result; - if (stateMachine != WAIT_ON_DELOYMENT_COMMAND) { - sif::error << "SolarArrayDeploymentHandler::executeAction: Received command while not in" - << "waiting-on-command-state" << std::endl; - return DEPLOYMENT_ALREADY_EXECUTING; - } - if (actionId != DEPLOY_SOLAR_ARRAYS) { - sif::error << "SolarArrayDeploymentHandler::executeAction: Received invalid command" - << std::endl; - result = COMMAND_NOT_SUPPORTED; - } else { - stateMachine = SWITCH_8V_ON; - rememberCommanderId = commandedBy; - result = RETURN_OK; - } - return result; + MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) { + ReturnValue_t result; + if (stateMachine != WAIT_ON_DELOYMENT_COMMAND) { + sif::error << "SolarArrayDeploymentHandler::executeAction: Received command while not in" + << "waiting-on-command-state" << std::endl; + return DEPLOYMENT_ALREADY_EXECUTING; + } + if (actionId != DEPLOY_SOLAR_ARRAYS) { + sif::error << "SolarArrayDeploymentHandler::executeAction: Received invalid command" + << std::endl; + result = COMMAND_NOT_SUPPORTED; + } else { + stateMachine = SWITCH_8V_ON; + rememberCommanderId = commandedBy; + result = RETURN_OK; + } + return result; } MessageQueueId_t SolarArrayDeploymentHandler::getCommandQueue() const { - return commandQueue->getId(); + return commandQueue->getId(); } diff --git a/linux/devices/SolarArrayDeploymentHandler.h b/linux/devices/SolarArrayDeploymentHandler.h index 5e573128..90380ae2 100644 --- a/linux/devices/SolarArrayDeploymentHandler.h +++ b/linux/devices/SolarArrayDeploymentHandler.h @@ -1,15 +1,16 @@ #ifndef MISSION_DEVICES_SOLARARRAYDEPLOYMENT_H_ #define MISSION_DEVICES_SOLARARRAYDEPLOYMENT_H_ -#include -#include -#include #include -#include #include #include +#include +#include +#include +#include #include #include + #include /** @@ -17,142 +18,139 @@ * * @author J. Meier */ -class SolarArrayDeploymentHandler: public ExecutableObjectIF, - public SystemObject, - public HasReturnvaluesIF, - public HasActionsIF { -public: +class SolarArrayDeploymentHandler : public ExecutableObjectIF, + public SystemObject, + public HasReturnvaluesIF, + public HasActionsIF { + public: + static const DeviceCommandId_t DEPLOY_SOLAR_ARRAYS = 0x5; - static const DeviceCommandId_t DEPLOY_SOLAR_ARRAYS = 0x5; + /** + * @brief constructor + * + * @param setObjectId The object id of the SolarArrayDeploymentHandler. + * @param gpioDriverId The id of the gpio com if. + * @param gpioCookie GpioCookie holding information about the gpios used to switch the + * transistors. + * @param mainLineSwitcherObjectId The object id of the object responsible for switching + * the 8V power source. This is normally the PCDU. + * @param mainLineSwitch The id of the main line switch. This is defined in + * powerSwitcherList.h. + * @param deplSA1 gpioId of the GPIO controlling the deployment 1 transistor. + * @param deplSA2 gpioId of the GPIO controlling the deployment 2 transistor. + * @param burnTimeMs Time duration the power will be applied to the burn wires. + */ + SolarArrayDeploymentHandler(object_id_t setObjectId, object_id_t gpioDriverId, + CookieIF* gpioCookie, object_id_t mainLineSwitcherObjectId, + uint8_t mainLineSwitch, gpioId_t deplSA1, gpioId_t deplSA2, + uint32_t burnTimeMs); - /** - * @brief constructor - * - * @param setObjectId The object id of the SolarArrayDeploymentHandler. - * @param gpioDriverId The id of the gpio com if. - * @param gpioCookie GpioCookie holding information about the gpios used to switch the - * transistors. - * @param mainLineSwitcherObjectId The object id of the object responsible for switching - * the 8V power source. This is normally the PCDU. - * @param mainLineSwitch The id of the main line switch. This is defined in - * powerSwitcherList.h. - * @param deplSA1 gpioId of the GPIO controlling the deployment 1 transistor. - * @param deplSA2 gpioId of the GPIO controlling the deployment 2 transistor. - * @param burnTimeMs Time duration the power will be applied to the burn wires. - */ - SolarArrayDeploymentHandler(object_id_t setObjectId, object_id_t gpioDriverId, - CookieIF * gpioCookie, object_id_t mainLineSwitcherObjectId, uint8_t mainLineSwitch, - gpioId_t deplSA1, gpioId_t deplSA2, uint32_t burnTimeMs); + virtual ~SolarArrayDeploymentHandler(); - virtual ~SolarArrayDeploymentHandler(); + virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; - virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; + virtual MessageQueueId_t getCommandQueue() const override; + virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) override; + virtual ReturnValue_t initialize() override; - virtual MessageQueueId_t getCommandQueue() const override; - virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size) override; - virtual ReturnValue_t initialize() override; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::SA_DEPL_HANDLER; + static const ReturnValue_t COMMAND_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA0); + static const ReturnValue_t DEPLOYMENT_ALREADY_EXECUTING = MAKE_RETURN_CODE(0xA1); + static const ReturnValue_t MAIN_SWITCH_TIMEOUT_FAILURE = MAKE_RETURN_CODE(0xA2); + static const ReturnValue_t SWITCHING_DEPL_SA1_FAILED = MAKE_RETURN_CODE(0xA3); + static const ReturnValue_t SWITCHING_DEPL_SA2_FAILED = MAKE_RETURN_CODE(0xA4); -private: + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SA_DEPL_HANDLER; + static const Event MAIN_SWITCH_ON_TIMEOUT = MAKE_EVENT(0, severity::LOW); + static const Event MAIN_SWITCH_OFF_TIMEOUT = MAKE_EVENT(1, severity::LOW); + static const Event DEPLOYMENT_FAILED = MAKE_EVENT(2, severity::HIGH); + static const Event DEPL_SA1_GPIO_SWTICH_ON_FAILED = MAKE_EVENT(3, severity::HIGH); + static const Event DEPL_SA2_GPIO_SWTICH_ON_FAILED = MAKE_EVENT(4, severity::HIGH); - static const uint8_t INTERFACE_ID = CLASS_ID::SA_DEPL_HANDLER; - static const ReturnValue_t COMMAND_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA0); - static const ReturnValue_t DEPLOYMENT_ALREADY_EXECUTING = MAKE_RETURN_CODE(0xA1); - static const ReturnValue_t MAIN_SWITCH_TIMEOUT_FAILURE = MAKE_RETURN_CODE(0xA2); - static const ReturnValue_t SWITCHING_DEPL_SA1_FAILED = MAKE_RETURN_CODE(0xA3); - static const ReturnValue_t SWITCHING_DEPL_SA2_FAILED = MAKE_RETURN_CODE(0xA4); + enum StateMachine { + WAIT_ON_DELOYMENT_COMMAND, + SWITCH_8V_ON, + WAIT_ON_8V_SWITCH, + SWITCH_DEPL_GPIOS, + WAIT_ON_DEPLOYMENT_FINISH, + WAIT_FOR_MAIN_SWITCH_OFF + }; - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SA_DEPL_HANDLER; - static const Event MAIN_SWITCH_ON_TIMEOUT = MAKE_EVENT(0, severity::LOW); - static const Event MAIN_SWITCH_OFF_TIMEOUT = MAKE_EVENT(1, severity::LOW); - static const Event DEPLOYMENT_FAILED = MAKE_EVENT(2, severity::HIGH); - static const Event DEPL_SA1_GPIO_SWTICH_ON_FAILED = MAKE_EVENT(3, severity::HIGH); - static const Event DEPL_SA2_GPIO_SWTICH_ON_FAILED = MAKE_EVENT(4, severity::HIGH); + StateMachine stateMachine = WAIT_ON_DELOYMENT_COMMAND; + /** + * This countdown is used to check if the PCDU sets the 8V line on in the intended time. + */ + Countdown mainSwitchCountdown; - enum StateMachine { - WAIT_ON_DELOYMENT_COMMAND, - SWITCH_8V_ON, - WAIT_ON_8V_SWITCH, - SWITCH_DEPL_GPIOS, - WAIT_ON_DEPLOYMENT_FINISH, - WAIT_FOR_MAIN_SWITCH_OFF - }; + /** + * This countdown is used to wait for the burn wire being successful cut. + */ + Countdown deploymentCountdown; - StateMachine stateMachine = WAIT_ON_DELOYMENT_COMMAND; + /** + * The message queue id of the component commanding an action will be stored in this variable. + * This is necessary to send later the action finish replies. + */ + MessageQueueId_t rememberCommanderId = 0; - /** - * This countdown is used to check if the PCDU sets the 8V line on in the intended time. - */ - Countdown mainSwitchCountdown; + /** Size of command queue */ + size_t cmdQueueSize = 20; - /** - * This countdown is used to wait for the burn wire being successful cut. - */ - Countdown deploymentCountdown; + /** The object ID of the GPIO driver which switches the deployment transistors */ + object_id_t gpioDriverId; + CookieIF* gpioCookie; - /** - * The message queue id of the component commanding an action will be stored in this variable. - * This is necessary to send later the action finish replies. - */ - MessageQueueId_t rememberCommanderId = 0; + /** Object id of the object responsible to switch the 8V power input. Typically the PCDU. */ + object_id_t mainLineSwitcherObjectId; - /** Size of command queue */ - size_t cmdQueueSize = 20; + /** Switch number of the 8V power switch */ + uint8_t mainLineSwitch; - /** The object ID of the GPIO driver which switches the deployment transistors */ - object_id_t gpioDriverId; + gpioId_t deplSA1; + gpioId_t deplSA2; - CookieIF * gpioCookie; + GpioIF* gpioInterface = nullptr; - /** Object id of the object responsible to switch the 8V power input. Typically the PCDU. */ - object_id_t mainLineSwitcherObjectId; + /** Time duration switches are active to cut the burn wire */ + uint32_t burnTimeMs; - /** Switch number of the 8V power switch */ - uint8_t mainLineSwitch; + /** Queue to receive messages from other objects. */ + MessageQueueIF* commandQueue = nullptr; - gpioId_t deplSA1; - gpioId_t deplSA2; + /** + * After initialization this pointer will hold the reference to the main line switcher object. + */ + PowerSwitchIF* mainLineSwitcher = nullptr; - GpioIF* gpioInterface = nullptr; + ActionHelper actionHelper; - /** Time duration switches are active to cut the burn wire */ - uint32_t burnTimeMs; + void readCommandQueue(); - /** Queue to receive messages from other objects. */ - MessageQueueIF* commandQueue = nullptr; + /** + * @brief This function performs actions dependent on the current state. + */ + void handleStateMachine(); - /** - * After initialization this pointer will hold the reference to the main line switcher object. - */ - PowerSwitchIF *mainLineSwitcher = nullptr; + /** + * @brief This function polls the 8V switch state and changes the state machine when the + * switch has been enabled. + */ + void performWaitOn8VActions(); - ActionHelper actionHelper; + /** + * @brief This functions handles the switching of the solar array deployment transistors. + */ + void switchDeploymentTransistors(); - void readCommandQueue(); - - /** - * @brief This function performs actions dependent on the current state. - */ - void handleStateMachine(); - - /** - * @brief This function polls the 8V switch state and changes the state machine when the - * switch has been enabled. - */ - void performWaitOn8VActions(); - - /** - * @brief This functions handles the switching of the solar array deployment transistors. - */ - void switchDeploymentTransistors(); - - /** - * @brief This function performs actions to finish the deployment. Essentially switches - * are turned of after the burn time has expired. - */ - void handleDeploymentFinish(); + /** + * @brief This function performs actions to finish the deployment. Essentially switches + * are turned of after the burn time has expired. + */ + void handleDeploymentFinish(); }; #endif /* MISSION_DEVICES_SOLARARRAYDEPLOYMENT_H_ */ diff --git a/linux/devices/SusHandler.cpp b/linux/devices/SusHandler.cpp index 67263756..44755f41 100644 --- a/linux/devices/SusHandler.cpp +++ b/linux/devices/SusHandler.cpp @@ -1,230 +1,214 @@ #include "SusHandler.h" -#include "OBSWConfig.h" #include #include -SusHandler::SusHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie, - LinuxLibgpioIF* gpioComIF, gpioId_t chipSelectId) : - DeviceHandlerBase(objectId, comIF, comCookie), gpioComIF(gpioComIF), chipSelectId( - chipSelectId), dataset(this) { - if (comCookie == NULL) { - sif::error << "SusHandler: Invalid com cookie" << std::endl; - } - if (gpioComIF == NULL) { - sif::error << "SusHandler: Invalid GpioComIF" << std::endl; - } +#include "OBSWConfig.h" + +SusHandler::SusHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie, + LinuxLibgpioIF *gpioComIF, gpioId_t chipSelectId) + : DeviceHandlerBase(objectId, comIF, comCookie), + gpioComIF(gpioComIF), + chipSelectId(chipSelectId), + dataset(this) { + if (comCookie == NULL) { + sif::error << "SusHandler: Invalid com cookie" << std::endl; + } + if (gpioComIF == NULL) { + sif::error << "SusHandler: Invalid GpioComIF" << std::endl; + } } -SusHandler::~SusHandler() { -} +SusHandler::~SusHandler() {} ReturnValue_t SusHandler::performOperation(uint8_t counter) { - - if (counter != FIRST_WRITE) { - DeviceHandlerBase::performOperation(counter); - return RETURN_OK; - } - - if (mode != MODE_NORMAL) { - DeviceHandlerBase::performOperation(DeviceHandlerIF::SEND_WRITE); - return RETURN_OK; - } - - /* If device is in normale mode the communication sequence is initiated here */ - if (communicationStep == CommunicationStep::IDLE) { - communicationStep = CommunicationStep::WRITE_SETUP; - } - - DeviceHandlerBase::performOperation(DeviceHandlerIF::SEND_WRITE); - + if (counter != FIRST_WRITE) { + DeviceHandlerBase::performOperation(counter); return RETURN_OK; + } + + if (mode != MODE_NORMAL) { + DeviceHandlerBase::performOperation(DeviceHandlerIF::SEND_WRITE); + return RETURN_OK; + } + + /* If device is in normale mode the communication sequence is initiated here */ + if (communicationStep == CommunicationStep::IDLE) { + communicationStep = CommunicationStep::WRITE_SETUP; + } + + DeviceHandlerBase::performOperation(DeviceHandlerIF::SEND_WRITE); + + return RETURN_OK; } ReturnValue_t SusHandler::initialize() { - ReturnValue_t result = RETURN_OK; - result = DeviceHandlerBase::initialize(); - if (result != RETURN_OK) { - return result; - } - auto spiComIF = dynamic_cast(communicationInterface); - if (spiComIF == nullptr) { - sif::debug << "SusHandler::initialize: Invalid communication interface" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } - spiMutex = spiComIF->getMutex(); - if (spiMutex == nullptr) { - sif::debug << "SusHandler::initialize: Failed to get spi mutex" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + result = DeviceHandlerBase::initialize(); + if (result != RETURN_OK) { + return result; + } + auto spiComIF = dynamic_cast(communicationInterface); + if (spiComIF == nullptr) { + sif::debug << "SusHandler::initialize: Invalid communication interface" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } + spiMutex = spiComIF->getMutex(); + if (spiMutex == nullptr) { + sif::debug << "SusHandler::initialize: Failed to get spi mutex" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } + return RETURN_OK; } -void SusHandler::doStartUp(){ +void SusHandler::doStartUp() { #if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 - setMode(MODE_NORMAL); + setMode(MODE_NORMAL); #else - setMode(_MODE_TO_ON); + setMode(_MODE_TO_ON); #endif } -void SusHandler::doShutDown(){ - setMode(_MODE_POWER_DOWN); +void SusHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } + +ReturnValue_t SusHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + if (communicationStep == CommunicationStep::IDLE) { + return NOTHING_TO_SEND; + } + + if (communicationStep == CommunicationStep::WRITE_SETUP) { + *id = SUS::WRITE_SETUP; + communicationStep = CommunicationStep::START_CONVERSIONS; + } else if (communicationStep == CommunicationStep::START_CONVERSIONS) { + *id = SUS::START_CONVERSIONS; + communicationStep = CommunicationStep::READ_CONVERSIONS; + } else if (communicationStep == CommunicationStep::READ_CONVERSIONS) { + *id = SUS::READ_CONVERSIONS; + communicationStep = CommunicationStep::IDLE; + } + return buildCommandFromCommand(*id, nullptr, 0); } -ReturnValue_t SusHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - - if (communicationStep == CommunicationStep::IDLE) { - return NOTHING_TO_SEND; - } - - if (communicationStep == CommunicationStep::WRITE_SETUP) { - *id = SUS::WRITE_SETUP; - communicationStep = CommunicationStep::START_CONVERSIONS; - } - else if (communicationStep == CommunicationStep::START_CONVERSIONS) { - *id = SUS::START_CONVERSIONS; - communicationStep = CommunicationStep::READ_CONVERSIONS; - } - else if (communicationStep == CommunicationStep::READ_CONVERSIONS) { - *id = SUS::READ_CONVERSIONS; - communicationStep = CommunicationStep::IDLE; - } - return buildCommandFromCommand(*id, nullptr, 0); +ReturnValue_t SusHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t SusHandler::buildTransitionDeviceCommand( - DeviceCommandId_t * id){ - return HasReturnvaluesIF::RETURN_OK; -} +ReturnValue_t SusHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, + size_t commandDataLen) { + switch (deviceCommand) { + case (SUS::WRITE_SETUP): { + /** + * The sun sensor ADC is shutdown when CS is pulled high, so each time requesting a + * measurement the setup has to be rewritten. There must also be a little delay between + * the transmission of the setup byte and the first conversion. Thus the conversion + * will be performed in an extra step. + * Because the chip select is driven manually by the SusHandler the SPI bus must be + * protected with a mutex here. + */ + ReturnValue_t result = spiMutex->lockMutex(timeoutType, timeoutMs); + if (result == MutexIF::MUTEX_TIMEOUT) { + sif::error << "SusHandler::buildCommandFromCommand: Mutex timeout" << std::endl; + return ERROR_LOCK_MUTEX; + } else if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "SusHandler::buildCommandFromCommand: Failed to lock spi mutex" << std::endl; + return ERROR_LOCK_MUTEX; + } -ReturnValue_t SusHandler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t * commandData, - size_t commandDataLen) { - switch(deviceCommand) { - case(SUS::WRITE_SETUP): { - /** - * The sun sensor ADC is shutdown when CS is pulled high, so each time requesting a - * measurement the setup has to be rewritten. There must also be a little delay between - * the transmission of the setup byte and the first conversion. Thus the conversion - * will be performed in an extra step. - * Because the chip select is driven manually by the SusHandler the SPI bus must be - * protected with a mutex here. - */ - ReturnValue_t result = spiMutex->lockMutex(timeoutType, timeoutMs); - if(result == MutexIF::MUTEX_TIMEOUT) { - sif::error << "SusHandler::buildCommandFromCommand: Mutex timeout" << std::endl; - return ERROR_LOCK_MUTEX; - } - else if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "SusHandler::buildCommandFromCommand: Failed to lock spi mutex" - << std::endl; - return ERROR_LOCK_MUTEX; - } - - gpioComIF->pullLow(chipSelectId); - cmdBuffer[0] = SUS::SETUP; - rawPacket = cmdBuffer; - rawPacketLen = 1; - return RETURN_OK; - } - case(SUS::START_CONVERSIONS): { - std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); - cmdBuffer[0] = SUS::CONVERSION; - rawPacket = cmdBuffer; - rawPacketLen = 2; - return RETURN_OK; - } - case(SUS::READ_CONVERSIONS): { - std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); - rawPacket = cmdBuffer; - rawPacketLen = SUS::SIZE_READ_CONVERSIONS; - return RETURN_OK; - } - default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; + gpioComIF->pullLow(chipSelectId); + cmdBuffer[0] = SUS::SETUP; + rawPacket = cmdBuffer; + rawPacketLen = 1; + return RETURN_OK; + } + case (SUS::START_CONVERSIONS): { + std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); + cmdBuffer[0] = SUS::CONVERSION; + rawPacket = cmdBuffer; + rawPacketLen = 2; + return RETURN_OK; + } + case (SUS::READ_CONVERSIONS): { + std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); + rawPacket = cmdBuffer; + rawPacketLen = SUS::SIZE_READ_CONVERSIONS; + return RETURN_OK; + } + default: + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } void SusHandler::fillCommandAndReplyMap() { - this->insertInCommandMap(SUS::WRITE_SETUP); - this->insertInCommandMap(SUS::START_CONVERSIONS); - this->insertInCommandAndReplyMap(SUS::READ_CONVERSIONS, 1, &dataset, SUS::SIZE_READ_CONVERSIONS); + this->insertInCommandMap(SUS::WRITE_SETUP); + this->insertInCommandMap(SUS::START_CONVERSIONS); + this->insertInCommandAndReplyMap(SUS::READ_CONVERSIONS, 1, &dataset, SUS::SIZE_READ_CONVERSIONS); } -ReturnValue_t SusHandler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { - *foundId = this->getPendingCommand(); - *foundLen = remainingSize; - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t SusHandler::scanForReply(const uint8_t *start, size_t remainingSize, + DeviceCommandId_t *foundId, size_t *foundLen) { + *foundId = this->getPendingCommand(); + *foundLen = remainingSize; + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t SusHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { - switch (id) { - case SUS::READ_CONVERSIONS: { - PoolReadGuard readSet(&dataset); - dataset.temperatureCelcius = (*(packet) << 8 | *(packet + 1)) * 0.125; - dataset.ain0 = (*(packet + 2) << 8 | *(packet + 3)); - dataset.ain1 = (*(packet + 4) << 8 | *(packet + 5)); - dataset.ain2 = (*(packet + 6) << 8 | *(packet + 7)); - dataset.ain3 = (*(packet + 8) << 8 | *(packet + 9)); - dataset.ain4 = (*(packet + 10) << 8 | *(packet + 11)); - dataset.ain5 = (*(packet + 12) << 8 | *(packet + 13)); +ReturnValue_t SusHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { + switch (id) { + case SUS::READ_CONVERSIONS: { + PoolReadGuard readSet(&dataset); + dataset.temperatureCelcius = (*(packet) << 8 | *(packet + 1)) * 0.125; + dataset.ain0 = (*(packet + 2) << 8 | *(packet + 3)); + dataset.ain1 = (*(packet + 4) << 8 | *(packet + 5)); + dataset.ain2 = (*(packet + 6) << 8 | *(packet + 7)); + dataset.ain3 = (*(packet + 8) << 8 | *(packet + 9)); + dataset.ain4 = (*(packet + 10) << 8 | *(packet + 11)); + dataset.ain5 = (*(packet + 12) << 8 | *(packet + 13)); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SUS - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", Temperature: " - << dataset.temperatureCelcius << " °C" << std::endl; - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN0: " - << std::dec << dataset.ain0 << std::endl; - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN1: " - << std::dec << dataset.ain1 << std::endl; - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN2: " - << std::dec << dataset.ain2 << std::endl; - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN3: " - << std::dec << dataset.ain3 << std::endl; - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN4: " - << std::dec << dataset.ain4 << std::endl; - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN5: " - << std::dec << dataset.ain5 << std::endl; + sif::info << "SUS object id 0x" << std::hex << this->getObjectId() + << ", Temperature: " << dataset.temperatureCelcius << " °C" << std::endl; + sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN0: " << std::dec + << dataset.ain0 << std::endl; + sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN1: " << std::dec + << dataset.ain1 << std::endl; + sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN2: " << std::dec + << dataset.ain2 << std::endl; + sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN3: " << std::dec + << dataset.ain3 << std::endl; + sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN4: " << std::dec + << dataset.ain4 << std::endl; + sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN5: " << std::dec + << dataset.ain5 << std::endl; #endif - /** SUS can now be shutdown and thus the SPI bus released again */ - gpioComIF->pullHigh(chipSelectId); - ReturnValue_t result = spiMutex->unlockMutex(); - if (result != RETURN_OK) { - sif::error << "SusHandler::interpretDeviceReply: Failed to unlock spi mutex" - << std::endl; - return ERROR_UNLOCK_MUTEX; - } - break; - } - default: { - sif::debug << "SusHandler::interpretDeviceReply: Unknown reply id" << std::endl; - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } - - } - return HasReturnvaluesIF::RETURN_OK; + /** SUS can now be shutdown and thus the SPI bus released again */ + gpioComIF->pullHigh(chipSelectId); + ReturnValue_t result = spiMutex->unlockMutex(); + if (result != RETURN_OK) { + sif::error << "SusHandler::interpretDeviceReply: Failed to unlock spi mutex" << std::endl; + return ERROR_UNLOCK_MUTEX; + } + break; + } + default: { + sif::debug << "SusHandler::interpretDeviceReply: Unknown reply id" << std::endl; + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; + } + } + return HasReturnvaluesIF::RETURN_OK; } -void SusHandler::setNormalDatapoolEntriesInvalid(){ +void SusHandler::setNormalDatapoolEntriesInvalid() {} +uint32_t SusHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 1000; } + +ReturnValue_t SusHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(SUS::TEMPERATURE_C, new PoolEntry({0.0})); + localDataPoolMap.emplace(SUS::AIN0, new PoolEntry({0})); + localDataPoolMap.emplace(SUS::AIN1, new PoolEntry({0})); + localDataPoolMap.emplace(SUS::AIN2, new PoolEntry({0})); + localDataPoolMap.emplace(SUS::AIN3, new PoolEntry({0})); + localDataPoolMap.emplace(SUS::AIN4, new PoolEntry({0})); + localDataPoolMap.emplace(SUS::AIN5, new PoolEntry({0})); + return HasReturnvaluesIF::RETURN_OK; } - -uint32_t SusHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){ - return 1000; -} - -ReturnValue_t SusHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { - localDataPoolMap.emplace(SUS::TEMPERATURE_C, new PoolEntry( { 0.0 })); - localDataPoolMap.emplace(SUS::AIN0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SUS::AIN1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SUS::AIN2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SUS::AIN3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SUS::AIN4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SUS::AIN5, new PoolEntry( { 0 })); - return HasReturnvaluesIF::RETURN_OK; -} - diff --git a/linux/devices/SusHandler.h b/linux/devices/SusHandler.h index ca9a5c45..0eab5fd0 100644 --- a/linux/devices/SusHandler.h +++ b/linux/devices/SusHandler.h @@ -1,10 +1,11 @@ #ifndef MISSION_DEVICES_SUSHANDLER_H_ #define MISSION_DEVICES_SUSHANDLER_H_ -#include "devicedefinitions/SusDefinitions.h" #include #include +#include "devicedefinitions/SusDefinitions.h" + /** * @brief This is the device handler class for the SUS sensor. The sensor is * based on the MAX1227 ADC. Details about the SUS electronic can be found at @@ -18,63 +19,55 @@ * * @author J. Meier */ -class SusHandler: public DeviceHandlerBase { -public: +class SusHandler : public DeviceHandlerBase { + public: + static const uint8_t FIRST_WRITE = 7; - static const uint8_t FIRST_WRITE = 7; + SusHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, + LinuxLibgpioIF* gpioComIF, gpioId_t chipSelectId); + virtual ~SusHandler(); - SusHandler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie, LinuxLibgpioIF* gpioComIF, gpioId_t chipSelectId); - virtual ~SusHandler(); + virtual ReturnValue_t performOperation(uint8_t counter) override; - virtual ReturnValue_t performOperation(uint8_t counter) override; + virtual ReturnValue_t initialize() override; - 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; -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; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::SUS_HANDLER; -private: + static const ReturnValue_t ERROR_UNLOCK_MUTEX = MAKE_RETURN_CODE(0xA0); + static const ReturnValue_t ERROR_LOCK_MUTEX = MAKE_RETURN_CODE(0xA1); - static const uint8_t INTERFACE_ID = CLASS_ID::SUS_HANDLER; + enum class CommunicationStep { IDLE, WRITE_SETUP, START_CONVERSIONS, READ_CONVERSIONS }; - static const ReturnValue_t ERROR_UNLOCK_MUTEX = MAKE_RETURN_CODE(0xA0); - static const ReturnValue_t ERROR_LOCK_MUTEX = MAKE_RETURN_CODE(0xA1); + LinuxLibgpioIF* gpioComIF = nullptr; - enum class CommunicationStep { - IDLE, - WRITE_SETUP, - START_CONVERSIONS, - READ_CONVERSIONS - }; + gpioId_t chipSelectId = gpio::NO_GPIO; - LinuxLibgpioIF* gpioComIF = nullptr; + SUS::SusDataset dataset; - gpioId_t chipSelectId = gpio::NO_GPIO; + uint8_t cmdBuffer[SUS::MAX_CMD_SIZE]; + CommunicationStep communicationStep = CommunicationStep::IDLE; - SUS::SusDataset dataset; + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; + uint32_t timeoutMs = 20; - uint8_t cmdBuffer[SUS::MAX_CMD_SIZE]; - CommunicationStep communicationStep = CommunicationStep::IDLE; - - MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; - uint32_t timeoutMs = 20; - - MutexIF* spiMutex = nullptr; + MutexIF* spiMutex = nullptr; }; #endif /* MISSION_DEVICES_SUSHANDLER_H_ */ diff --git a/linux/devices/devicedefinitions/SusDefinitions.h b/linux/devices/devicedefinitions/SusDefinitions.h index ba56ec07..2a45ebc5 100644 --- a/linux/devices/devicedefinitions/SusDefinitions.h +++ b/linux/devices/devicedefinitions/SusDefinitions.h @@ -3,93 +3,87 @@ #include #include -#include +#include namespace SUS { - /** - * Some MAX1227 could not be reached with frequencies around 4 MHz. Maybe this is caused by - * the decoder and buffer circuits. Thus frequency is here defined to 1 MHz. - */ - static const uint32_t MAX1227_SPI_FREQ = 1000000; +/** + * Some MAX1227 could not be reached with frequencies around 4 MHz. Maybe this is caused by + * the decoder and buffer circuits. Thus frequency is here defined to 1 MHz. + */ +static const uint32_t MAX1227_SPI_FREQ = 1000000; - static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending +static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending - static const DeviceCommandId_t WRITE_SETUP = 0x1; - /** - * This command initiates the ADC conversion for all channels including the internal - * temperature sensor. - */ - static const DeviceCommandId_t START_CONVERSIONS = 0x2; - /** - * This command reads the internal fifo which holds the temperature and the channel - * conversions. - */ - static const DeviceCommandId_t READ_CONVERSIONS = 0x3; +static const DeviceCommandId_t WRITE_SETUP = 0x1; +/** + * This command initiates the ADC conversion for all channels including the internal + * temperature sensor. + */ +static const DeviceCommandId_t START_CONVERSIONS = 0x2; +/** + * This command reads the internal fifo which holds the temperature and the channel + * conversions. + */ +static const DeviceCommandId_t READ_CONVERSIONS = 0x3; - /** - * @brief This is the configuration byte which will be written to the setup register after - * power on. - * - * @note Bit1 (DIFFSEL1) - Bit0 (DIFFSEL0): 0b00, No byte is following the setup byte - * Bit3 (REFSEL1) - Bit2 (REFSEL0): 0b10, Internal reference, no wake-up delay - * Bit5 (CLKSEL1) - Bit4 (CLKSEL0): 0b10, Internally clocked - * Bit7 - Bit6: 0b01, Tells MAX1227 that this byte should be - * written to the setup register - * - */ - static const uint8_t SETUP = 0b01101000; +/** + * @brief This is the configuration byte which will be written to the setup register after + * power on. + * + * @note Bit1 (DIFFSEL1) - Bit0 (DIFFSEL0): 0b00, No byte is following the setup byte + * Bit3 (REFSEL1) - Bit2 (REFSEL0): 0b10, Internal reference, no wake-up delay + * Bit5 (CLKSEL1) - Bit4 (CLKSEL0): 0b10, Internally clocked + * Bit7 - Bit6: 0b01, Tells MAX1227 that this byte should be + * written to the setup register + * + */ +static const uint8_t SETUP = 0b01101000; - /** - * @brief This values will always be written to the ADC conversion register to specify the - * conversions to perform. - * @details Bit0: 1 - Enables temperature conversion - * Bit2 (SCAN1) and Bit1 (SCAN0): 0b00, Scans channels 0 through N - * Bit6 - Bit3 defines N: 0b0101 (N = 5) - * Bit7: Always 1. Tells the ADC that this is the conversion register. - */ - static const uint8_t CONVERSION = 0b10101001; +/** + * @brief This values will always be written to the ADC conversion register to specify the + * conversions to perform. + * @details Bit0: 1 - Enables temperature conversion + * Bit2 (SCAN1) and Bit1 (SCAN0): 0b00, Scans channels 0 through N + * Bit6 - Bit3 defines N: 0b0101 (N = 5) + * Bit7: Always 1. Tells the ADC that this is the conversion register. + */ +static const uint8_t CONVERSION = 0b10101001; - static const uint8_t SUS_DATA_SET_ID = READ_CONVERSIONS; +static const uint8_t SUS_DATA_SET_ID = READ_CONVERSIONS; - /** Size of data replies. Temperature and 6 channel convesions (AIN0 - AIN5) */ - static const uint8_t SIZE_READ_CONVERSIONS = 14; +/** Size of data replies. Temperature and 6 channel convesions (AIN0 - AIN5) */ +static const uint8_t SIZE_READ_CONVERSIONS = 14; - static const uint8_t MAX_CMD_SIZE = SIZE_READ_CONVERSIONS; +static const uint8_t MAX_CMD_SIZE = SIZE_READ_CONVERSIONS; - static const uint8_t POOL_ENTRIES = 7; +static const uint8_t POOL_ENTRIES = 7; - enum Max1227PoolIds: lp_id_t { - TEMPERATURE_C, - AIN0, - AIN1, - AIN2, - AIN3, - AIN4, - AIN5, - }; - -class SusDataset: public StaticLocalDataSet { -public: - - SusDataset(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, SUS_DATA_SET_ID) { - } - - SusDataset(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, SUS_DATA_SET_ID)) { - } - - lp_var_t temperatureCelcius = lp_var_t(sid.objectId, TEMPERATURE_C, this); - lp_var_t ain0 = lp_var_t(sid.objectId, AIN0, this); - lp_var_t ain1 = lp_var_t(sid.objectId, AIN1, this); - lp_var_t ain2 = lp_var_t(sid.objectId, AIN2, this); - lp_var_t ain3 = lp_var_t(sid.objectId, AIN3, this); - lp_var_t ain4 = lp_var_t(sid.objectId, AIN4, this); - lp_var_t ain5 = lp_var_t(sid.objectId, AIN5, this); +enum Max1227PoolIds : lp_id_t { + TEMPERATURE_C, + AIN0, + AIN1, + AIN2, + AIN3, + AIN4, + AIN5, }; -} +class SusDataset : public StaticLocalDataSet { + public: + SusDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, SUS_DATA_SET_ID) {} + + SusDataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, SUS_DATA_SET_ID)) {} + + lp_var_t temperatureCelcius = lp_var_t(sid.objectId, TEMPERATURE_C, this); + lp_var_t ain0 = lp_var_t(sid.objectId, AIN0, this); + lp_var_t ain1 = lp_var_t(sid.objectId, AIN1, this); + lp_var_t ain2 = lp_var_t(sid.objectId, AIN2, this); + lp_var_t ain3 = lp_var_t(sid.objectId, AIN3, this); + lp_var_t ain4 = lp_var_t(sid.objectId, AIN4, this); + lp_var_t ain5 = lp_var_t(sid.objectId, AIN5, this); +}; +} // namespace SUS #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_SUS_H_ */ diff --git a/linux/fsfwconfig/devices/addresses.cpp b/linux/fsfwconfig/devices/addresses.cpp index 38877737..60b1370b 100644 --- a/linux/fsfwconfig/devices/addresses.cpp +++ b/linux/fsfwconfig/devices/addresses.cpp @@ -5,7 +5,3 @@ */ #include "addresses.h" - - - - diff --git a/linux/fsfwconfig/devices/addresses.h b/linux/fsfwconfig/devices/addresses.h index 94f22c54..5ef82788 100644 --- a/linux/fsfwconfig/devices/addresses.h +++ b/linux/fsfwconfig/devices/addresses.h @@ -2,84 +2,85 @@ #define FSFWCONFIG_DEVICES_ADDRESSES_H_ #include -#include "objects/systemObjectList.h" + #include +#include "objects/systemObjectList.h" + namespace addresses { - /* Logical addresses have uint32_t datatype */ - enum logicalAddresses: address_t { - PCDU, +/* Logical addresses have uint32_t datatype */ +enum logicalAddresses : address_t { + PCDU, - MGM_0_LIS3 = objects::MGM_0_LIS3_HANDLER, - MGM_1_RM3100 = objects::MGM_1_RM3100_HANDLER, - MGM_2_LIS3 = objects::MGM_2_LIS3_HANDLER, - MGM_3_RM3100 = objects::MGM_3_RM3100_HANDLER, + MGM_0_LIS3 = objects::MGM_0_LIS3_HANDLER, + MGM_1_RM3100 = objects::MGM_1_RM3100_HANDLER, + MGM_2_LIS3 = objects::MGM_2_LIS3_HANDLER, + MGM_3_RM3100 = objects::MGM_3_RM3100_HANDLER, - GYRO_0_ADIS = objects::GYRO_0_ADIS_HANDLER, - GYRO_1_L3G = objects::GYRO_1_L3G_HANDLER, - GYRO_2_ADIS = objects::GYRO_2_ADIS_HANDLER, - GYRO_3_L3G = objects::GYRO_3_L3G_HANDLER, + GYRO_0_ADIS = objects::GYRO_0_ADIS_HANDLER, + GYRO_1_L3G = objects::GYRO_1_L3G_HANDLER, + GYRO_2_ADIS = objects::GYRO_2_ADIS_HANDLER, + GYRO_3_L3G = objects::GYRO_3_L3G_HANDLER, - RAD_SENSOR = objects::RAD_SENSOR, + RAD_SENSOR = objects::RAD_SENSOR, - SUS_1 = objects::SUS_1, - SUS_2 = objects::SUS_2, - SUS_3 = objects::SUS_3, - SUS_4 = objects::SUS_4, - SUS_5 = objects::SUS_5, - SUS_6 = objects::SUS_6, - SUS_7 = objects::SUS_7, - SUS_8 = objects::SUS_8, - SUS_9 = objects::SUS_9, - SUS_10 = objects::SUS_10, - SUS_11 = objects::SUS_11, - SUS_12 = objects::SUS_12, - SUS_13 = objects::SUS_13, + SUS_1 = objects::SUS_1, + SUS_2 = objects::SUS_2, + SUS_3 = objects::SUS_3, + SUS_4 = objects::SUS_4, + SUS_5 = objects::SUS_5, + SUS_6 = objects::SUS_6, + SUS_7 = objects::SUS_7, + SUS_8 = objects::SUS_8, + SUS_9 = objects::SUS_9, + SUS_10 = objects::SUS_10, + SUS_11 = objects::SUS_11, + SUS_12 = objects::SUS_12, + SUS_13 = objects::SUS_13, - /* Dummy and Test Addresses */ - DUMMY_ECHO = 129, - DUMMY_GPS0 = 130, - DUMMY_GPS1 = 131, - }; + /* Dummy and Test Addresses */ + DUMMY_ECHO = 129, + DUMMY_GPS0 = 130, + DUMMY_GPS1 = 131, +}; - enum i2cAddresses: address_t { - IMTQ = 16, - TMP1075_TCS_1 = 72, - TMP1075_TCS_2 = 73, - }; +enum i2cAddresses : address_t { + IMTQ = 16, + TMP1075_TCS_1 = 72, + TMP1075_TCS_2 = 73, +}; - enum spiAddresses: address_t { - RTD_IC_3, - RTD_IC_4, - RTD_IC_5, - RTD_IC_6, - RTD_IC_7, - RTD_IC_8, - RTD_IC_9, - RTD_IC_10, - RTD_IC_11, - RTD_IC_12, - RTD_IC_13, - RTD_IC_14, - RTD_IC_15, - RTD_IC_16, - RTD_IC_17, - RTD_IC_18, - RW1, - RW2, - RW3, - RW4 - }; - - /* Addresses of devices supporting the CSP protocol */ - enum cspAddresses: uint8_t { - P60DOCK = 4, - ACU = 2, - PDU1 = 3, - /* PDU2 occupies X4 slot of P60Dock */ - PDU2 = 6 - }; -} +enum spiAddresses : address_t { + RTD_IC_3, + RTD_IC_4, + RTD_IC_5, + RTD_IC_6, + RTD_IC_7, + RTD_IC_8, + RTD_IC_9, + RTD_IC_10, + RTD_IC_11, + RTD_IC_12, + RTD_IC_13, + RTD_IC_14, + RTD_IC_15, + RTD_IC_16, + RTD_IC_17, + RTD_IC_18, + RW1, + RW2, + RW3, + RW4 +}; +/* Addresses of devices supporting the CSP protocol */ +enum cspAddresses : uint8_t { + P60DOCK = 4, + ACU = 2, + PDU1 = 3, + /* PDU2 occupies X4 slot of P60Dock */ + PDU2 = 6 +}; +} // namespace addresses #endif /* FSFWCONFIG_DEVICES_ADDRESSES_H_ */ diff --git a/linux/fsfwconfig/devices/gpioIds.h b/linux/fsfwconfig/devices/gpioIds.h index e4b9f727..bb753a30 100644 --- a/linux/fsfwconfig/devices/gpioIds.h +++ b/linux/fsfwconfig/devices/gpioIds.h @@ -5,116 +5,112 @@ namespace gpioIds { enum gpioId_t { - HEATER_0, - HEATER_1, - HEATER_2, - HEATER_3, - HEATER_4, - HEATER_5, - HEATER_6, - HEATER_7, - DEPLSA1, - DEPLSA2, + HEATER_0, + HEATER_1, + HEATER_2, + HEATER_3, + HEATER_4, + HEATER_5, + HEATER_6, + HEATER_7, + DEPLSA1, + DEPLSA2, - MGM_0_LIS3_CS, - MGM_1_RM3100_CS, - GYRO_0_ADIS_CS, - GYRO_1_L3G_CS, - GYRO_2_ADIS_CS, - GYRO_3_L3G_CS, - MGM_2_LIS3_CS, - MGM_3_RM3100_CS, + MGM_0_LIS3_CS, + MGM_1_RM3100_CS, + GYRO_0_ADIS_CS, + GYRO_1_L3G_CS, + GYRO_2_ADIS_CS, + GYRO_3_L3G_CS, + MGM_2_LIS3_CS, + MGM_3_RM3100_CS, - GNSS_0_NRESET, - GNSS_1_NRESET, - GNSS_0_ENABLE, - GNSS_1_ENABLE, + GNSS_0_NRESET, + GNSS_1_NRESET, + GNSS_0_ENABLE, + GNSS_1_ENABLE, - GYRO_0_ENABLE, - GYRO_2_ENABLE, + GYRO_0_ENABLE, + GYRO_2_ENABLE, - TEST_ID_0, - TEST_ID_1, + TEST_ID_0, + TEST_ID_1, - RTD_IC_3, - RTD_IC_4, - RTD_IC_5, - RTD_IC_6, - RTD_IC_7, - RTD_IC_8, - RTD_IC_9, - RTD_IC_10, - RTD_IC_11, - RTD_IC_12, - RTD_IC_13, - RTD_IC_14, - RTD_IC_15, - RTD_IC_16, - RTD_IC_17, - RTD_IC_18, + RTD_IC_3, + RTD_IC_4, + RTD_IC_5, + RTD_IC_6, + RTD_IC_7, + RTD_IC_8, + RTD_IC_9, + RTD_IC_10, + RTD_IC_11, + RTD_IC_12, + RTD_IC_13, + RTD_IC_14, + RTD_IC_15, + RTD_IC_16, + RTD_IC_17, + RTD_IC_18, - CS_SUS_1, - CS_SUS_2, - CS_SUS_3, - CS_SUS_4, - CS_SUS_5, - CS_SUS_6, - CS_SUS_7, - CS_SUS_8, - CS_SUS_9, - CS_SUS_10, - CS_SUS_11, - CS_SUS_12, - CS_SUS_13, + CS_SUS_1, + CS_SUS_2, + CS_SUS_3, + CS_SUS_4, + CS_SUS_5, + CS_SUS_6, + CS_SUS_7, + CS_SUS_8, + CS_SUS_9, + CS_SUS_10, + CS_SUS_11, + CS_SUS_12, + CS_SUS_13, - SPI_MUX_BIT_1, - SPI_MUX_BIT_2, - SPI_MUX_BIT_3, - SPI_MUX_BIT_4, - SPI_MUX_BIT_5, - SPI_MUX_BIT_6, + SPI_MUX_BIT_1, + SPI_MUX_BIT_2, + SPI_MUX_BIT_3, + SPI_MUX_BIT_4, + SPI_MUX_BIT_5, + SPI_MUX_BIT_6, - CS_RAD_SENSOR, + CS_RAD_SENSOR, - PAPB_BUSY_N, - PAPB_EMPTY, + PAPB_BUSY_N, + PAPB_EMPTY, - EN_RW1, - EN_RW2, - EN_RW3, - EN_RW4, + EN_RW1, + EN_RW2, + EN_RW3, + EN_RW4, - CS_RW1, - CS_RW2, - CS_RW3, - CS_RW4, + CS_RW1, + CS_RW2, + CS_RW3, + CS_RW4, - EN_RW_CS, + EN_RW_CS, - SPI_MUX, + SPI_MUX, - VC0_PAPB_EMPTY, - VC0_PAPB_BUSY, - VC1_PAPB_EMPTY, - VC1_PAPB_BUSY, - VC2_PAPB_EMPTY, - VC2_PAPB_BUSY, - VC3_PAPB_EMPTY, - VC3_PAPB_BUSY, + VC0_PAPB_EMPTY, + VC0_PAPB_BUSY, + VC1_PAPB_EMPTY, + VC1_PAPB_BUSY, + VC2_PAPB_EMPTY, + VC2_PAPB_BUSY, + VC3_PAPB_EMPTY, + VC3_PAPB_BUSY, - PDEC_RESET, + PDEC_RESET, + RS485_EN_TX_DATA, + RS485_EN_TX_CLOCK, + RS485_EN_RX_DATA, + RS485_EN_RX_CLOCK, - RS485_EN_TX_DATA, - RS485_EN_TX_CLOCK, - RS485_EN_RX_DATA, - RS485_EN_RX_CLOCK, - - BIT_RATE_SEL + BIT_RATE_SEL }; } - - - #endif /* FSFWCONFIG_DEVICES_GPIOIDS_H_ */ diff --git a/linux/fsfwconfig/devices/powerSwitcherList.h b/linux/fsfwconfig/devices/powerSwitcherList.h index bc5731fd..cc6bc141 100644 --- a/linux/fsfwconfig/devices/powerSwitcherList.h +++ b/linux/fsfwconfig/devices/powerSwitcherList.h @@ -4,55 +4,54 @@ #include "OBSWConfig.h" namespace pcduSwitches { - /* Switches are uint8_t datatype and go from 0 to 255 */ - enum SwitcherList: uint8_t { - Q7S, - PAYLOAD_PCDU_CH1, - RW, - TCS_BOARD_8V_HEATER_IN, - SUS_REDUNDANT, - DEPLOYMENT_MECHANISM, - PAYLOAD_PCDU_CH6, - ACS_BOARD_SIDE_B, - PAYLOAD_CAMERA, - TCS_BOARD_3V3, - SYRLINKS, - STAR_TRACKER, - MGT, - SUS_NOMINAL, - SOLAR_CELL_EXP, - PLOC, - ACS_BOARD_SIDE_A, - NUMBER_OF_SWITCHES - }; +/* Switches are uint8_t datatype and go from 0 to 255 */ +enum SwitcherList : uint8_t { + Q7S, + PAYLOAD_PCDU_CH1, + RW, + TCS_BOARD_8V_HEATER_IN, + SUS_REDUNDANT, + DEPLOYMENT_MECHANISM, + PAYLOAD_PCDU_CH6, + ACS_BOARD_SIDE_B, + PAYLOAD_CAMERA, + TCS_BOARD_3V3, + SYRLINKS, + STAR_TRACKER, + MGT, + SUS_NOMINAL, + SOLAR_CELL_EXP, + PLOC, + ACS_BOARD_SIDE_A, + NUMBER_OF_SWITCHES +}; - static const uint8_t ON = 1; - static const uint8_t OFF = 0; +static const uint8_t ON = 1; +static const uint8_t OFF = 0; - /* Output states after reboot of the PDUs */ - static const uint8_t INIT_STATE_Q7S = ON; - static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH1 = OFF; - static const uint8_t INIT_STATE_RW = OFF; +/* Output states after reboot of the PDUs */ +static const uint8_t INIT_STATE_Q7S = ON; +static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH1 = OFF; +static const uint8_t INIT_STATE_RW = OFF; #if BOARD_TE0720 == 1 - /* Because the TE0720 is not connected to the PCDU, this switch is always on */ - static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = ON; +/* Because the TE0720 is not connected to the PCDU, this switch is always on */ +static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = ON; #else - static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = OFF; +static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = OFF; #endif - static const uint8_t INIT_STATE_SUS_REDUNDANT = OFF; - static const uint8_t INIT_STATE_DEPLOYMENT_MECHANISM = OFF; - static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH6 = OFF; - static const uint8_t INIT_STATE_ACS_BOARD_SIDE_B = OFF; - static const uint8_t INIT_STATE_PAYLOAD_CAMERA = OFF; - static const uint8_t INIT_STATE_TCS_BOARD_3V3 = OFF; - static const uint8_t INIT_STATE_SYRLINKS = OFF; - static const uint8_t INIT_STATE_STAR_TRACKER = OFF; - static const uint8_t INIT_STATE_MGT = OFF; - static const uint8_t INIT_STATE_SUS_NOMINAL = OFF; - static const uint8_t INIT_STATE_SOLAR_CELL_EXP = OFF; - static const uint8_t INIT_STATE_PLOC = OFF; - static const uint8_t INIT_STATE_ACS_BOARD_SIDE_A = OFF; -} - +static const uint8_t INIT_STATE_SUS_REDUNDANT = OFF; +static const uint8_t INIT_STATE_DEPLOYMENT_MECHANISM = OFF; +static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH6 = OFF; +static const uint8_t INIT_STATE_ACS_BOARD_SIDE_B = OFF; +static const uint8_t INIT_STATE_PAYLOAD_CAMERA = OFF; +static const uint8_t INIT_STATE_TCS_BOARD_3V3 = OFF; +static const uint8_t INIT_STATE_SYRLINKS = OFF; +static const uint8_t INIT_STATE_STAR_TRACKER = OFF; +static const uint8_t INIT_STATE_MGT = OFF; +static const uint8_t INIT_STATE_SUS_NOMINAL = OFF; +static const uint8_t INIT_STATE_SOLAR_CELL_EXP = OFF; +static const uint8_t INIT_STATE_PLOC = OFF; +static const uint8_t INIT_STATE_ACS_BOARD_SIDE_A = OFF; +} // namespace pcduSwitches #endif /* FSFWCONFIG_DEVICES_POWERSWITCHERLIST_H_ */ diff --git a/linux/fsfwconfig/events/subsystemIdRanges.h b/linux/fsfwconfig/events/subsystemIdRanges.h index 4894be16..33ef1a09 100644 --- a/linux/fsfwconfig/events/subsystemIdRanges.h +++ b/linux/fsfwconfig/events/subsystemIdRanges.h @@ -1,19 +1,19 @@ #ifndef FSFWCONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ #define FSFWCONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ +#include + #include "common/config/commonSubsystemIds.h" #include "fsfw/events/fwSubsystemIdRanges.h" -#include - /** * These IDs are part of the ID for an event thrown by a subsystem. * Numbers 0-80 are reserved for FSFW Subsystem IDs (framework/events/) */ namespace SUBSYSTEM_ID { -enum: uint8_t { - SUBSYSTEM_ID_START = COMMON_SUBSYSTEM_ID_END, - CORE = 116, +enum : uint8_t { + SUBSYSTEM_ID_START = COMMON_SUBSYSTEM_ID_END, + CORE = 116, }; } diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index 17150762..2d028fdd 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -146,290 +146,290 @@ const char *STR_HELPER_FILE_NOT_EXISTS_STRING = "STR_HELPER_FILE_NOT_EXISTS"; const char *STR_HELPER_SENDING_PACKET_FAILED_STRING = "STR_HELPER_SENDING_PACKET_FAILED"; const char *STR_HELPER_REQUESTING_MSG_FAILED_STRING = "STR_HELPER_REQUESTING_MSG_FAILED"; -const char * translateEvents(Event event) { - switch( (event & 0xffff) ) { - case(2200): - return STORE_SEND_WRITE_FAILED_STRING; - case(2201): - return STORE_WRITE_FAILED_STRING; - case(2202): - return STORE_SEND_READ_FAILED_STRING; - case(2203): - return STORE_READ_FAILED_STRING; - case(2204): - return UNEXPECTED_MSG_STRING; - case(2205): - return STORING_FAILED_STRING; - case(2206): - return TM_DUMP_FAILED_STRING; - case(2207): - return STORE_INIT_FAILED_STRING; - case(2208): - return STORE_INIT_EMPTY_STRING; - case(2209): - return STORE_CONTENT_CORRUPTED_STRING; - case(2210): - return STORE_INITIALIZE_STRING; - case(2211): - return INIT_DONE_STRING; - case(2212): - return DUMP_FINISHED_STRING; - case(2213): - return DELETION_FINISHED_STRING; - case(2214): - return DELETION_FAILED_STRING; - case(2215): - return AUTO_CATALOGS_SENDING_FAILED_STRING; - case(2600): - return GET_DATA_FAILED_STRING; - case(2601): - return STORE_DATA_FAILED_STRING; - case(2800): - return DEVICE_BUILDING_COMMAND_FAILED_STRING; - case(2801): - return DEVICE_SENDING_COMMAND_FAILED_STRING; - case(2802): - return DEVICE_REQUESTING_REPLY_FAILED_STRING; - case(2803): - return DEVICE_READING_REPLY_FAILED_STRING; - case(2804): - return DEVICE_INTERPRETING_REPLY_FAILED_STRING; - case(2805): - return DEVICE_MISSED_REPLY_STRING; - case(2806): - return DEVICE_UNKNOWN_REPLY_STRING; - case(2807): - return DEVICE_UNREQUESTED_REPLY_STRING; - case(2808): - return INVALID_DEVICE_COMMAND_STRING; - case(2809): - return MONITORING_LIMIT_EXCEEDED_STRING; - case(2810): - return MONITORING_AMBIGUOUS_STRING; - case(4201): - return FUSE_CURRENT_HIGH_STRING; - case(4202): - return FUSE_WENT_OFF_STRING; - case(4204): - return POWER_ABOVE_HIGH_LIMIT_STRING; - case(4205): - return POWER_BELOW_LOW_LIMIT_STRING; - case(4300): - return SWITCH_WENT_OFF_STRING; - case(5000): - return HEATER_ON_STRING; - case(5001): - return HEATER_OFF_STRING; - case(5002): - return HEATER_TIMEOUT_STRING; - case(5003): - return HEATER_STAYED_ON_STRING; - case(5004): - return HEATER_STAYED_OFF_STRING; - case(5200): - return TEMP_SENSOR_HIGH_STRING; - case(5201): - return TEMP_SENSOR_LOW_STRING; - case(5202): - return TEMP_SENSOR_GRADIENT_STRING; - case(5901): - return COMPONENT_TEMP_LOW_STRING; - case(5902): - return COMPONENT_TEMP_HIGH_STRING; - case(5903): - return COMPONENT_TEMP_OOL_LOW_STRING; - case(5904): - return COMPONENT_TEMP_OOL_HIGH_STRING; - case(5905): - return TEMP_NOT_IN_OP_RANGE_STRING; - case(7101): - return FDIR_CHANGED_STATE_STRING; - case(7102): - return FDIR_STARTS_RECOVERY_STRING; - case(7103): - return FDIR_TURNS_OFF_DEVICE_STRING; - case(7201): - return MONITOR_CHANGED_STATE_STRING; - case(7202): - return VALUE_BELOW_LOW_LIMIT_STRING; - case(7203): - return VALUE_ABOVE_HIGH_LIMIT_STRING; - case(7204): - return VALUE_OUT_OF_RANGE_STRING; - case(7301): - return SWITCHING_TM_FAILED_STRING; - case(7400): - return CHANGING_MODE_STRING; - case(7401): - return MODE_INFO_STRING; - case(7402): - return FALLBACK_FAILED_STRING; - case(7403): - return MODE_TRANSITION_FAILED_STRING; - case(7404): - return CANT_KEEP_MODE_STRING; - case(7405): - return OBJECT_IN_INVALID_MODE_STRING; - case(7406): - return FORCING_MODE_STRING; - case(7407): - return MODE_CMD_REJECTED_STRING; - case(7506): - return HEALTH_INFO_STRING; - case(7507): - return CHILD_CHANGED_HEALTH_STRING; - case(7508): - return CHILD_PROBLEMS_STRING; - case(7509): - return OVERWRITING_HEALTH_STRING; - case(7510): - return TRYING_RECOVERY_STRING; - case(7511): - return RECOVERY_STEP_STRING; - case(7512): - return RECOVERY_DONE_STRING; - case(7900): - return RF_AVAILABLE_STRING; - case(7901): - return RF_LOST_STRING; - case(7902): - return BIT_LOCK_STRING; - case(7903): - return BIT_LOCK_LOST_STRING; - case(7905): - return FRAME_PROCESSING_FAILED_STRING; - case(8900): - return CLOCK_SET_STRING; - case(8901): - return CLOCK_SET_FAILURE_STRING; - case(9700): - return TEST_STRING; - case(10600): - return CHANGE_OF_SETUP_PARAMETER_STRING; - case(10900): - return GPIO_PULL_HIGH_FAILED_STRING; - case(10901): - return GPIO_PULL_LOW_FAILED_STRING; - case(10902): - return SWITCH_ALREADY_ON_STRING; - case(10903): - return SWITCH_ALREADY_OFF_STRING; - case(10904): - return MAIN_SWITCH_TIMEOUT_STRING; - case(11000): - return MAIN_SWITCH_ON_TIMEOUT_STRING; - case(11001): - return MAIN_SWITCH_OFF_TIMEOUT_STRING; - case(11002): - return DEPLOYMENT_FAILED_STRING; - case(11003): - return DEPL_SA1_GPIO_SWTICH_ON_FAILED_STRING; - case(11004): - return DEPL_SA2_GPIO_SWTICH_ON_FAILED_STRING; - case(11101): - return MEMORY_READ_RPT_CRC_FAILURE_STRING; - case(11102): - return ACK_FAILURE_STRING; - case(11103): - return EXE_FAILURE_STRING; - case(11104): - return CRC_FAILURE_EVENT_STRING; - case(11201): - return SELF_TEST_I2C_FAILURE_STRING; - case(11202): - return SELF_TEST_SPI_FAILURE_STRING; - case(11203): - return SELF_TEST_ADC_FAILURE_STRING; - case(11204): - return SELF_TEST_PWM_FAILURE_STRING; - case(11205): - return SELF_TEST_TC_FAILURE_STRING; - case(11206): - return SELF_TEST_MTM_RANGE_FAILURE_STRING; - case(11207): - return SELF_TEST_COIL_CURRENT_FAILURE_STRING; - case(11208): - return INVALID_ERROR_BYTE_STRING; - case(11301): - return ERROR_STATE_STRING; - case(11501): - return SUPV_MEMORY_READ_RPT_CRC_FAILURE_STRING; - case(11502): - return SUPV_ACK_FAILURE_STRING; - case(11503): - return SUPV_EXE_FAILURE_STRING; - case(11504): - return SUPV_CRC_FAILURE_EVENT_STRING; - case(11600): - return SANITIZATION_FAILED_STRING; - case(11700): - return UPDATE_FILE_NOT_EXISTS_STRING; - case(11701): - return ACTION_COMMANDING_FAILED_STRING; - case(11702): - return UPDATE_AVAILABLE_FAILED_STRING; - case(11703): - return UPDATE_TRANSFER_FAILED_STRING; - case(11704): - return UPDATE_VERIFY_FAILED_STRING; - case(11705): - return UPDATE_FINISHED_STRING; - case(11800): - return SEND_MRAM_DUMP_FAILED_STRING; - case(11801): - return MRAM_DUMP_FAILED_STRING; - case(11802): - return MRAM_DUMP_FINISHED_STRING; - case(11901): - return INVALID_TC_FRAME_STRING; - case(11902): - return INVALID_FAR_STRING; - case(11903): - return CARRIER_LOCK_STRING; - case(11904): - return BIT_LOCK_PDEC_STRING; - case(12000): - return IMAGE_UPLOAD_FAILED_STRING; - case(12001): - return IMAGE_DOWNLOAD_FAILED_STRING; - case(12002): - return IMAGE_UPLOAD_SUCCESSFUL_STRING; - case(12003): - return IMAGE_DOWNLOAD_SUCCESSFUL_STRING; - case(12004): - return FLASH_WRITE_SUCCESSFUL_STRING; - case(12005): - return FLASH_READ_SUCCESSFUL_STRING; - case(12006): - return FLASH_WRITE_FAILED_STRING; - case(12007): - return FLASH_READ_FAILED_STRING; - case(12008): - return FPGA_DOWNLOAD_SUCCESSFUL_STRING; - case(12009): - return FPGA_DOWNLOAD_FAILED_STRING; - case(12010): - return FPGA_UPLOAD_SUCCESSFUL_STRING; - case(12011): - return FPGA_UPLOAD_FAILED_STRING; - case(12012): - return STR_HELPER_READING_REPLY_FAILED_STRING; - case(12013): - return STR_HELPER_COM_ERROR_STRING; - case(12014): - return STR_HELPER_NO_REPLY_STRING; - case(12015): - return STR_HELPER_DEC_ERROR_STRING; - case(12016): - return POSITION_MISMATCH_STRING; - case(12017): - return STR_HELPER_FILE_NOT_EXISTS_STRING; - case(12018): - return STR_HELPER_SENDING_PACKET_FAILED_STRING; - case(12019): - return STR_HELPER_REQUESTING_MSG_FAILED_STRING; - default: - return "UNKNOWN_EVENT"; - } - return 0; +const char *translateEvents(Event event) { + switch ((event & 0xffff)) { + case (2200): + return STORE_SEND_WRITE_FAILED_STRING; + case (2201): + return STORE_WRITE_FAILED_STRING; + case (2202): + return STORE_SEND_READ_FAILED_STRING; + case (2203): + return STORE_READ_FAILED_STRING; + case (2204): + return UNEXPECTED_MSG_STRING; + case (2205): + return STORING_FAILED_STRING; + case (2206): + return TM_DUMP_FAILED_STRING; + case (2207): + return STORE_INIT_FAILED_STRING; + case (2208): + return STORE_INIT_EMPTY_STRING; + case (2209): + return STORE_CONTENT_CORRUPTED_STRING; + case (2210): + return STORE_INITIALIZE_STRING; + case (2211): + return INIT_DONE_STRING; + case (2212): + return DUMP_FINISHED_STRING; + case (2213): + return DELETION_FINISHED_STRING; + case (2214): + return DELETION_FAILED_STRING; + case (2215): + return AUTO_CATALOGS_SENDING_FAILED_STRING; + case (2600): + return GET_DATA_FAILED_STRING; + case (2601): + return STORE_DATA_FAILED_STRING; + case (2800): + return DEVICE_BUILDING_COMMAND_FAILED_STRING; + case (2801): + return DEVICE_SENDING_COMMAND_FAILED_STRING; + case (2802): + return DEVICE_REQUESTING_REPLY_FAILED_STRING; + case (2803): + return DEVICE_READING_REPLY_FAILED_STRING; + case (2804): + return DEVICE_INTERPRETING_REPLY_FAILED_STRING; + case (2805): + return DEVICE_MISSED_REPLY_STRING; + case (2806): + return DEVICE_UNKNOWN_REPLY_STRING; + case (2807): + return DEVICE_UNREQUESTED_REPLY_STRING; + case (2808): + return INVALID_DEVICE_COMMAND_STRING; + case (2809): + return MONITORING_LIMIT_EXCEEDED_STRING; + case (2810): + return MONITORING_AMBIGUOUS_STRING; + case (4201): + return FUSE_CURRENT_HIGH_STRING; + case (4202): + return FUSE_WENT_OFF_STRING; + case (4204): + return POWER_ABOVE_HIGH_LIMIT_STRING; + case (4205): + return POWER_BELOW_LOW_LIMIT_STRING; + case (4300): + return SWITCH_WENT_OFF_STRING; + case (5000): + return HEATER_ON_STRING; + case (5001): + return HEATER_OFF_STRING; + case (5002): + return HEATER_TIMEOUT_STRING; + case (5003): + return HEATER_STAYED_ON_STRING; + case (5004): + return HEATER_STAYED_OFF_STRING; + case (5200): + return TEMP_SENSOR_HIGH_STRING; + case (5201): + return TEMP_SENSOR_LOW_STRING; + case (5202): + return TEMP_SENSOR_GRADIENT_STRING; + case (5901): + return COMPONENT_TEMP_LOW_STRING; + case (5902): + return COMPONENT_TEMP_HIGH_STRING; + case (5903): + return COMPONENT_TEMP_OOL_LOW_STRING; + case (5904): + return COMPONENT_TEMP_OOL_HIGH_STRING; + case (5905): + return TEMP_NOT_IN_OP_RANGE_STRING; + case (7101): + return FDIR_CHANGED_STATE_STRING; + case (7102): + return FDIR_STARTS_RECOVERY_STRING; + case (7103): + return FDIR_TURNS_OFF_DEVICE_STRING; + case (7201): + return MONITOR_CHANGED_STATE_STRING; + case (7202): + return VALUE_BELOW_LOW_LIMIT_STRING; + case (7203): + return VALUE_ABOVE_HIGH_LIMIT_STRING; + case (7204): + return VALUE_OUT_OF_RANGE_STRING; + case (7301): + return SWITCHING_TM_FAILED_STRING; + case (7400): + return CHANGING_MODE_STRING; + case (7401): + return MODE_INFO_STRING; + case (7402): + return FALLBACK_FAILED_STRING; + case (7403): + return MODE_TRANSITION_FAILED_STRING; + case (7404): + return CANT_KEEP_MODE_STRING; + case (7405): + return OBJECT_IN_INVALID_MODE_STRING; + case (7406): + return FORCING_MODE_STRING; + case (7407): + return MODE_CMD_REJECTED_STRING; + case (7506): + return HEALTH_INFO_STRING; + case (7507): + return CHILD_CHANGED_HEALTH_STRING; + case (7508): + return CHILD_PROBLEMS_STRING; + case (7509): + return OVERWRITING_HEALTH_STRING; + case (7510): + return TRYING_RECOVERY_STRING; + case (7511): + return RECOVERY_STEP_STRING; + case (7512): + return RECOVERY_DONE_STRING; + case (7900): + return RF_AVAILABLE_STRING; + case (7901): + return RF_LOST_STRING; + case (7902): + return BIT_LOCK_STRING; + case (7903): + return BIT_LOCK_LOST_STRING; + case (7905): + return FRAME_PROCESSING_FAILED_STRING; + case (8900): + return CLOCK_SET_STRING; + case (8901): + return CLOCK_SET_FAILURE_STRING; + case (9700): + return TEST_STRING; + case (10600): + return CHANGE_OF_SETUP_PARAMETER_STRING; + case (10900): + return GPIO_PULL_HIGH_FAILED_STRING; + case (10901): + return GPIO_PULL_LOW_FAILED_STRING; + case (10902): + return SWITCH_ALREADY_ON_STRING; + case (10903): + return SWITCH_ALREADY_OFF_STRING; + case (10904): + return MAIN_SWITCH_TIMEOUT_STRING; + case (11000): + return MAIN_SWITCH_ON_TIMEOUT_STRING; + case (11001): + return MAIN_SWITCH_OFF_TIMEOUT_STRING; + case (11002): + return DEPLOYMENT_FAILED_STRING; + case (11003): + return DEPL_SA1_GPIO_SWTICH_ON_FAILED_STRING; + case (11004): + return DEPL_SA2_GPIO_SWTICH_ON_FAILED_STRING; + case (11101): + return MEMORY_READ_RPT_CRC_FAILURE_STRING; + case (11102): + return ACK_FAILURE_STRING; + case (11103): + return EXE_FAILURE_STRING; + case (11104): + return CRC_FAILURE_EVENT_STRING; + case (11201): + return SELF_TEST_I2C_FAILURE_STRING; + case (11202): + return SELF_TEST_SPI_FAILURE_STRING; + case (11203): + return SELF_TEST_ADC_FAILURE_STRING; + case (11204): + return SELF_TEST_PWM_FAILURE_STRING; + case (11205): + return SELF_TEST_TC_FAILURE_STRING; + case (11206): + return SELF_TEST_MTM_RANGE_FAILURE_STRING; + case (11207): + return SELF_TEST_COIL_CURRENT_FAILURE_STRING; + case (11208): + return INVALID_ERROR_BYTE_STRING; + case (11301): + return ERROR_STATE_STRING; + case (11501): + return SUPV_MEMORY_READ_RPT_CRC_FAILURE_STRING; + case (11502): + return SUPV_ACK_FAILURE_STRING; + case (11503): + return SUPV_EXE_FAILURE_STRING; + case (11504): + return SUPV_CRC_FAILURE_EVENT_STRING; + case (11600): + return SANITIZATION_FAILED_STRING; + case (11700): + return UPDATE_FILE_NOT_EXISTS_STRING; + case (11701): + return ACTION_COMMANDING_FAILED_STRING; + case (11702): + return UPDATE_AVAILABLE_FAILED_STRING; + case (11703): + return UPDATE_TRANSFER_FAILED_STRING; + case (11704): + return UPDATE_VERIFY_FAILED_STRING; + case (11705): + return UPDATE_FINISHED_STRING; + case (11800): + return SEND_MRAM_DUMP_FAILED_STRING; + case (11801): + return MRAM_DUMP_FAILED_STRING; + case (11802): + return MRAM_DUMP_FINISHED_STRING; + case (11901): + return INVALID_TC_FRAME_STRING; + case (11902): + return INVALID_FAR_STRING; + case (11903): + return CARRIER_LOCK_STRING; + case (11904): + return BIT_LOCK_PDEC_STRING; + case (12000): + return IMAGE_UPLOAD_FAILED_STRING; + case (12001): + return IMAGE_DOWNLOAD_FAILED_STRING; + case (12002): + return IMAGE_UPLOAD_SUCCESSFUL_STRING; + case (12003): + return IMAGE_DOWNLOAD_SUCCESSFUL_STRING; + case (12004): + return FLASH_WRITE_SUCCESSFUL_STRING; + case (12005): + return FLASH_READ_SUCCESSFUL_STRING; + case (12006): + return FLASH_WRITE_FAILED_STRING; + case (12007): + return FLASH_READ_FAILED_STRING; + case (12008): + return FPGA_DOWNLOAD_SUCCESSFUL_STRING; + case (12009): + return FPGA_DOWNLOAD_FAILED_STRING; + case (12010): + return FPGA_UPLOAD_SUCCESSFUL_STRING; + case (12011): + return FPGA_UPLOAD_FAILED_STRING; + case (12012): + return STR_HELPER_READING_REPLY_FAILED_STRING; + case (12013): + return STR_HELPER_COM_ERROR_STRING; + case (12014): + return STR_HELPER_NO_REPLY_STRING; + case (12015): + return STR_HELPER_DEC_ERROR_STRING; + case (12016): + return POSITION_MISMATCH_STRING; + case (12017): + return STR_HELPER_FILE_NOT_EXISTS_STRING; + case (12018): + return STR_HELPER_SENDING_PACKET_FAILED_STRING; + case (12019): + return STR_HELPER_REQUESTING_MSG_FAILED_STRING; + default: + return "UNKNOWN_EVENT"; + } + return 0; } diff --git a/linux/fsfwconfig/events/translateEvents.h b/linux/fsfwconfig/events/translateEvents.h index bdabb21b..1b8a8831 100644 --- a/linux/fsfwconfig/events/translateEvents.h +++ b/linux/fsfwconfig/events/translateEvents.h @@ -3,6 +3,6 @@ #include "fsfw/events/Event.h" -const char * translateEvents(Event event); +const char* translateEvents(Event event); #endif /* FSFWCONFIG_EVENTS_TRANSLATEEVENTS_H_ */ diff --git a/linux/fsfwconfig/ipc/MissionMessageTypes.cpp b/linux/fsfwconfig/ipc/MissionMessageTypes.cpp index 9ac6f0f4..fa1c4877 100644 --- a/linux/fsfwconfig/ipc/MissionMessageTypes.cpp +++ b/linux/fsfwconfig/ipc/MissionMessageTypes.cpp @@ -1,12 +1,10 @@ #include "MissionMessageTypes.h" + #include - void messagetypes::clearMissionMessage(CommandMessage* message) { - switch(message->getMessageType()) { - default: - break; - } + switch (message->getMessageType()) { + default: + break; + } } - - diff --git a/linux/fsfwconfig/ipc/MissionMessageTypes.h b/linux/fsfwconfig/ipc/MissionMessageTypes.h index ab2a84b5..78b0d343 100644 --- a/linux/fsfwconfig/ipc/MissionMessageTypes.h +++ b/linux/fsfwconfig/ipc/MissionMessageTypes.h @@ -11,12 +11,12 @@ class CommandMessage; * * @param message Generic Command Message */ -namespace messagetypes{ +namespace messagetypes { enum MESSAGE_TYPE { - MISSION_MESSAGE_TYPE_START = FW_MESSAGES_COUNT, + MISSION_MESSAGE_TYPE_START = FW_MESSAGES_COUNT, }; void clearMissionMessage(CommandMessage* message); -} +} // namespace messagetypes #endif /* FSFWCONFIG_IPC_MISSIONMESSAGETYPES_H_ */ diff --git a/linux/fsfwconfig/objects/systemObjectList.h b/linux/fsfwconfig/objects/systemObjectList.h index a8929187..c868730b 100644 --- a/linux/fsfwconfig/objects/systemObjectList.h +++ b/linux/fsfwconfig/objects/systemObjectList.h @@ -1,10 +1,12 @@ #ifndef HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ #define HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ -#include "commonObjects.h" #include + #include +#include "commonObjects.h" + // The objects will be instantiated in the ID order // For naming scheme see flight manual /* @@ -31,38 +33,38 @@ Fourth byte is a unique counter. */ namespace objects { -enum sourceObjects: uint32_t { - /* 0x53 reserved for FSFW */ - FW_ADDRESS_START = PUS_SERVICE_1_VERIFICATION, - FW_ADDRESS_END = TIME_STAMPER, - PUS_SERVICE_6 = 0x51000500, +enum sourceObjects : uint32_t { + /* 0x53 reserved for FSFW */ + FW_ADDRESS_START = PUS_SERVICE_1_VERIFICATION, + FW_ADDRESS_END = TIME_STAMPER, + PUS_SERVICE_6 = 0x51000500, - CCSDS_IP_CORE_BRIDGE = 0x73500000, - TM_FUNNEL = 0x73000100, + CCSDS_IP_CORE_BRIDGE = 0x73500000, + TM_FUNNEL = 0x73000100, - /* 0x49 ('I') for Communication Interfaces **/ - ARDUINO_COM_IF = 0x49000000, - CSP_COM_IF = 0x49050001, - I2C_COM_IF = 0x49040002, - UART_COM_IF = 0x49030003, - SPI_COM_IF = 0x49020004, - GPIO_IF = 0x49010005, + /* 0x49 ('I') for Communication Interfaces **/ + ARDUINO_COM_IF = 0x49000000, + CSP_COM_IF = 0x49050001, + I2C_COM_IF = 0x49040002, + UART_COM_IF = 0x49030003, + SPI_COM_IF = 0x49020004, + GPIO_IF = 0x49010005, - /* Custom device handler */ - PCDU_HANDLER = 0x442000A1, - SOLAR_ARRAY_DEPL_HANDLER = 0x444100A2, - SYRLINKS_HK_HANDLER = 0x445300A3, - HEATER_HANDLER = 0x444100A4, - RAD_SENSOR = 0x443200A5, + /* Custom device handler */ + PCDU_HANDLER = 0x442000A1, + SOLAR_ARRAY_DEPL_HANDLER = 0x444100A2, + SYRLINKS_HK_HANDLER = 0x445300A3, + HEATER_HANDLER = 0x444100A4, + RAD_SENSOR = 0x443200A5, - /* 0x54 ('T') for test handlers */ - TEST_TASK = 0x54694269, - LIBGPIOD_TEST = 0x54123456, - SPI_TEST = 0x54000010, - UART_TEST = 0x54000020, - DUMMY_INTERFACE = 0x5400CAFE, - DUMMY_HANDLER = 0x5400AFFE, - P60DOCK_TEST_TASK = 0x00005060, + /* 0x54 ('T') for test handlers */ + TEST_TASK = 0x54694269, + LIBGPIOD_TEST = 0x54123456, + SPI_TEST = 0x54000010, + UART_TEST = 0x54000020, + DUMMY_INTERFACE = 0x5400CAFE, + DUMMY_HANDLER = 0x5400AFFE, + P60DOCK_TEST_TASK = 0x00005060, }; } diff --git a/linux/fsfwconfig/objects/translateObjects.cpp b/linux/fsfwconfig/objects/translateObjects.cpp index 49900a5d..56cbc575 100644 --- a/linux/fsfwconfig/objects/translateObjects.cpp +++ b/linux/fsfwconfig/objects/translateObjects.cpp @@ -120,236 +120,236 @@ const char *TM_FUNNEL_STRING = "TM_FUNNEL"; const char *CCSDS_IP_CORE_BRIDGE_STRING = "CCSDS_IP_CORE_BRIDGE"; const char *NO_OBJECT_STRING = "NO_OBJECT"; -const char* translateObject(object_id_t object) { - switch( (object & 0xFFFFFFFF) ) { - case 0x00005060: - return P60DOCK_TEST_TASK_STRING; - case 0x43000003: - return CORE_CONTROLLER_STRING; - case 0x43100002: - return ACS_CONTROLLER_STRING; - case 0x43400001: - return THERMAL_CONTROLLER_STRING; - case 0x44120006: - return MGM_0_LIS3_HANDLER_STRING; - case 0x44120010: - return GYRO_0_ADIS_HANDLER_STRING; - case 0x44120032: - return SUS_1_STRING; - case 0x44120033: - return SUS_2_STRING; - case 0x44120034: - return SUS_3_STRING; - case 0x44120035: - return SUS_4_STRING; - case 0x44120036: - return SUS_5_STRING; - case 0x44120037: - return SUS_6_STRING; - case 0x44120038: - return SUS_7_STRING; - case 0x44120039: - return SUS_8_STRING; - case 0x44120040: - return SUS_9_STRING; - case 0x44120041: - return SUS_10_STRING; - case 0x44120042: - return SUS_11_STRING; - case 0x44120043: - return SUS_12_STRING; - case 0x44120044: - return SUS_13_STRING; - case 0x44120047: - return RW1_STRING; - case 0x44120107: - return MGM_1_RM3100_HANDLER_STRING; - case 0x44120111: - return GYRO_1_L3G_HANDLER_STRING; - case 0x44120148: - return RW2_STRING; - case 0x44120208: - return MGM_2_LIS3_HANDLER_STRING; - case 0x44120212: - return GYRO_2_ADIS_HANDLER_STRING; - case 0x44120249: - return RW3_STRING; - case 0x44120309: - return MGM_3_RM3100_HANDLER_STRING; - case 0x44120313: - return GYRO_3_L3G_HANDLER_STRING; - case 0x44120350: - return RW4_STRING; - case 0x44130001: - return STAR_TRACKER_STRING; - case 0x44130045: - return GPS0_HANDLER_STRING; - case 0x44130146: - return GPS1_HANDLER_STRING; - case 0x44140014: - return IMTQ_HANDLER_STRING; - case 0x442000A1: - return PCDU_HANDLER_STRING; - case 0x44250000: - return P60DOCK_HANDLER_STRING; - case 0x44250001: - return PDU1_HANDLER_STRING; - case 0x44250002: - return PDU2_HANDLER_STRING; - case 0x44250003: - return ACU_HANDLER_STRING; - case 0x443200A5: - return RAD_SENSOR_STRING; - case 0x44330000: - return PLOC_UPDATER_STRING; - case 0x44330001: - return PLOC_MEMORY_DUMPER_STRING; - case 0x44330002: - return STR_HELPER_STRING; - case 0x44330015: - return PLOC_MPSOC_HANDLER_STRING; - case 0x44330016: - return PLOC_SUPERVISOR_HANDLER_STRING; - case 0x444100A2: - return SOLAR_ARRAY_DEPL_HANDLER_STRING; - case 0x444100A4: - return HEATER_HANDLER_STRING; - case 0x44420004: - return TMP1075_HANDLER_1_STRING; - case 0x44420005: - return TMP1075_HANDLER_2_STRING; - case 0x44420016: - return RTD_IC_3_STRING; - case 0x44420017: - return RTD_IC_4_STRING; - case 0x44420018: - return RTD_IC_5_STRING; - case 0x44420019: - return RTD_IC_6_STRING; - case 0x44420020: - return RTD_IC_7_STRING; - case 0x44420021: - return RTD_IC_8_STRING; - case 0x44420022: - return RTD_IC_9_STRING; - case 0x44420023: - return RTD_IC_10_STRING; - case 0x44420024: - return RTD_IC_11_STRING; - case 0x44420025: - return RTD_IC_12_STRING; - case 0x44420026: - return RTD_IC_13_STRING; - case 0x44420027: - return RTD_IC_14_STRING; - case 0x44420028: - return RTD_IC_15_STRING; - case 0x44420029: - return RTD_IC_16_STRING; - case 0x44420030: - return RTD_IC_17_STRING; - case 0x44420031: - return RTD_IC_18_STRING; - case 0x445300A3: - return SYRLINKS_HK_HANDLER_STRING; - case 0x49000000: - return ARDUINO_COM_IF_STRING; - case 0x49010005: - return GPIO_IF_STRING; - case 0x49020004: - return SPI_COM_IF_STRING; - case 0x49030003: - return UART_COM_IF_STRING; - case 0x49040002: - return I2C_COM_IF_STRING; - case 0x49050001: - return CSP_COM_IF_STRING; - case 0x50000100: - return CCSDS_PACKET_DISTRIBUTOR_STRING; - case 0x50000200: - return PUS_PACKET_DISTRIBUTOR_STRING; - case 0x50000300: - return TMTC_BRIDGE_STRING; - case 0x50000400: - return TMTC_POLLING_TASK_STRING; - case 0x50000500: - return FILE_SYSTEM_HANDLER_STRING; - case 0x50000600: - return PTME_STRING; - case 0x50000700: - return PAPB_VC0_STRING; - case 0x50000701: - return PAPB_VC1_STRING; - case 0x50000702: - return PAPB_VC2_STRING; - case 0x50000703: - return PAPB_VC3_STRING; - case 0x50000704: - return PDEC_HANDLER_STRING; - case 0x50000800: - return CCSDS_HANDLER_STRING; - case 0x51000500: - return PUS_SERVICE_6_STRING; - case 0x53000000: - return FSFW_OBJECTS_START_STRING; - case 0x53000001: - return PUS_SERVICE_1_VERIFICATION_STRING; - case 0x53000002: - return PUS_SERVICE_2_DEVICE_ACCESS_STRING; - case 0x53000003: - return PUS_SERVICE_3_HOUSEKEEPING_STRING; - case 0x53000005: - return PUS_SERVICE_5_EVENT_REPORTING_STRING; - case 0x53000008: - return PUS_SERVICE_8_FUNCTION_MGMT_STRING; - case 0x53000009: - return PUS_SERVICE_9_TIME_MGMT_STRING; - case 0x53000017: - return PUS_SERVICE_17_TEST_STRING; - case 0x53000020: - return PUS_SERVICE_20_PARAMETERS_STRING; - case 0x53000200: - return PUS_SERVICE_200_MODE_MGMT_STRING; - case 0x53000201: - return PUS_SERVICE_201_HEALTH_STRING; - case 0x53010000: - return HEALTH_TABLE_STRING; - case 0x53010100: - return MODE_STORE_STRING; - case 0x53030000: - return EVENT_MANAGER_STRING; - case 0x53040000: - return INTERNAL_ERROR_REPORTER_STRING; - case 0x534f0100: - return TC_STORE_STRING; - case 0x534f0200: - return TM_STORE_STRING; - case 0x534f0300: - return IPC_STORE_STRING; - case 0x53500010: - return TIME_STAMPER_STRING; - case 0x53ffffff: - return FSFW_OBJECTS_END_STRING; - case 0x54000010: - return SPI_TEST_STRING; - case 0x54000020: - return UART_TEST_STRING; - case 0x5400AFFE: - return DUMMY_HANDLER_STRING; - case 0x5400CAFE: - return DUMMY_INTERFACE_STRING; - case 0x54123456: - return LIBGPIOD_TEST_STRING; - case 0x54694269: - return TEST_TASK_STRING; - case 0x73000100: - return TM_FUNNEL_STRING; - case 0x73500000: - return CCSDS_IP_CORE_BRIDGE_STRING; - case 0xFFFFFFFF: - return NO_OBJECT_STRING; - default: - return "UNKNOWN_OBJECT"; - } - return 0; +const char *translateObject(object_id_t object) { + switch ((object & 0xFFFFFFFF)) { + case 0x00005060: + return P60DOCK_TEST_TASK_STRING; + case 0x43000003: + return CORE_CONTROLLER_STRING; + case 0x43100002: + return ACS_CONTROLLER_STRING; + case 0x43400001: + return THERMAL_CONTROLLER_STRING; + case 0x44120006: + return MGM_0_LIS3_HANDLER_STRING; + case 0x44120010: + return GYRO_0_ADIS_HANDLER_STRING; + case 0x44120032: + return SUS_1_STRING; + case 0x44120033: + return SUS_2_STRING; + case 0x44120034: + return SUS_3_STRING; + case 0x44120035: + return SUS_4_STRING; + case 0x44120036: + return SUS_5_STRING; + case 0x44120037: + return SUS_6_STRING; + case 0x44120038: + return SUS_7_STRING; + case 0x44120039: + return SUS_8_STRING; + case 0x44120040: + return SUS_9_STRING; + case 0x44120041: + return SUS_10_STRING; + case 0x44120042: + return SUS_11_STRING; + case 0x44120043: + return SUS_12_STRING; + case 0x44120044: + return SUS_13_STRING; + case 0x44120047: + return RW1_STRING; + case 0x44120107: + return MGM_1_RM3100_HANDLER_STRING; + case 0x44120111: + return GYRO_1_L3G_HANDLER_STRING; + case 0x44120148: + return RW2_STRING; + case 0x44120208: + return MGM_2_LIS3_HANDLER_STRING; + case 0x44120212: + return GYRO_2_ADIS_HANDLER_STRING; + case 0x44120249: + return RW3_STRING; + case 0x44120309: + return MGM_3_RM3100_HANDLER_STRING; + case 0x44120313: + return GYRO_3_L3G_HANDLER_STRING; + case 0x44120350: + return RW4_STRING; + case 0x44130001: + return STAR_TRACKER_STRING; + case 0x44130045: + return GPS0_HANDLER_STRING; + case 0x44130146: + return GPS1_HANDLER_STRING; + case 0x44140014: + return IMTQ_HANDLER_STRING; + case 0x442000A1: + return PCDU_HANDLER_STRING; + case 0x44250000: + return P60DOCK_HANDLER_STRING; + case 0x44250001: + return PDU1_HANDLER_STRING; + case 0x44250002: + return PDU2_HANDLER_STRING; + case 0x44250003: + return ACU_HANDLER_STRING; + case 0x443200A5: + return RAD_SENSOR_STRING; + case 0x44330000: + return PLOC_UPDATER_STRING; + case 0x44330001: + return PLOC_MEMORY_DUMPER_STRING; + case 0x44330002: + return STR_HELPER_STRING; + case 0x44330015: + return PLOC_MPSOC_HANDLER_STRING; + case 0x44330016: + return PLOC_SUPERVISOR_HANDLER_STRING; + case 0x444100A2: + return SOLAR_ARRAY_DEPL_HANDLER_STRING; + case 0x444100A4: + return HEATER_HANDLER_STRING; + case 0x44420004: + return TMP1075_HANDLER_1_STRING; + case 0x44420005: + return TMP1075_HANDLER_2_STRING; + case 0x44420016: + return RTD_IC_3_STRING; + case 0x44420017: + return RTD_IC_4_STRING; + case 0x44420018: + return RTD_IC_5_STRING; + case 0x44420019: + return RTD_IC_6_STRING; + case 0x44420020: + return RTD_IC_7_STRING; + case 0x44420021: + return RTD_IC_8_STRING; + case 0x44420022: + return RTD_IC_9_STRING; + case 0x44420023: + return RTD_IC_10_STRING; + case 0x44420024: + return RTD_IC_11_STRING; + case 0x44420025: + return RTD_IC_12_STRING; + case 0x44420026: + return RTD_IC_13_STRING; + case 0x44420027: + return RTD_IC_14_STRING; + case 0x44420028: + return RTD_IC_15_STRING; + case 0x44420029: + return RTD_IC_16_STRING; + case 0x44420030: + return RTD_IC_17_STRING; + case 0x44420031: + return RTD_IC_18_STRING; + case 0x445300A3: + return SYRLINKS_HK_HANDLER_STRING; + case 0x49000000: + return ARDUINO_COM_IF_STRING; + case 0x49010005: + return GPIO_IF_STRING; + case 0x49020004: + return SPI_COM_IF_STRING; + case 0x49030003: + return UART_COM_IF_STRING; + case 0x49040002: + return I2C_COM_IF_STRING; + case 0x49050001: + return CSP_COM_IF_STRING; + case 0x50000100: + return CCSDS_PACKET_DISTRIBUTOR_STRING; + case 0x50000200: + return PUS_PACKET_DISTRIBUTOR_STRING; + case 0x50000300: + return TMTC_BRIDGE_STRING; + case 0x50000400: + return TMTC_POLLING_TASK_STRING; + case 0x50000500: + return FILE_SYSTEM_HANDLER_STRING; + case 0x50000600: + return PTME_STRING; + case 0x50000700: + return PAPB_VC0_STRING; + case 0x50000701: + return PAPB_VC1_STRING; + case 0x50000702: + return PAPB_VC2_STRING; + case 0x50000703: + return PAPB_VC3_STRING; + case 0x50000704: + return PDEC_HANDLER_STRING; + case 0x50000800: + return CCSDS_HANDLER_STRING; + case 0x51000500: + return PUS_SERVICE_6_STRING; + case 0x53000000: + return FSFW_OBJECTS_START_STRING; + case 0x53000001: + return PUS_SERVICE_1_VERIFICATION_STRING; + case 0x53000002: + return PUS_SERVICE_2_DEVICE_ACCESS_STRING; + case 0x53000003: + return PUS_SERVICE_3_HOUSEKEEPING_STRING; + case 0x53000005: + return PUS_SERVICE_5_EVENT_REPORTING_STRING; + case 0x53000008: + return PUS_SERVICE_8_FUNCTION_MGMT_STRING; + case 0x53000009: + return PUS_SERVICE_9_TIME_MGMT_STRING; + case 0x53000017: + return PUS_SERVICE_17_TEST_STRING; + case 0x53000020: + return PUS_SERVICE_20_PARAMETERS_STRING; + case 0x53000200: + return PUS_SERVICE_200_MODE_MGMT_STRING; + case 0x53000201: + return PUS_SERVICE_201_HEALTH_STRING; + case 0x53010000: + return HEALTH_TABLE_STRING; + case 0x53010100: + return MODE_STORE_STRING; + case 0x53030000: + return EVENT_MANAGER_STRING; + case 0x53040000: + return INTERNAL_ERROR_REPORTER_STRING; + case 0x534f0100: + return TC_STORE_STRING; + case 0x534f0200: + return TM_STORE_STRING; + case 0x534f0300: + return IPC_STORE_STRING; + case 0x53500010: + return TIME_STAMPER_STRING; + case 0x53ffffff: + return FSFW_OBJECTS_END_STRING; + case 0x54000010: + return SPI_TEST_STRING; + case 0x54000020: + return UART_TEST_STRING; + case 0x5400AFFE: + return DUMMY_HANDLER_STRING; + case 0x5400CAFE: + return DUMMY_INTERFACE_STRING; + case 0x54123456: + return LIBGPIOD_TEST_STRING; + case 0x54694269: + return TEST_TASK_STRING; + case 0x73000100: + return TM_FUNNEL_STRING; + case 0x73500000: + return CCSDS_IP_CORE_BRIDGE_STRING; + case 0xFFFFFFFF: + return NO_OBJECT_STRING; + default: + return "UNKNOWN_OBJECT"; + } + return 0; } diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 82748821..814e5c2d 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -1,792 +1,730 @@ #include "pollingSequenceFactory.h" -#include "linux/devices/SusHandler.h" -#include "OBSWConfig.h" +#include #include #include -#include #include + +#include "OBSWConfig.h" +#include "linux/devices/SusHandler.h" #include "objects/systemObjectList.h" +ReturnValue_t pst::pstGpio(FixedTimeslotTaskIF *thisSequence) { + // Length of a communication cycle + uint32_t length = thisSequence->getPeriodMs(); -ReturnValue_t pst::pstGpio(FixedTimeslotTaskIF *thisSequence) -{ - // Length of a communication cycle - uint32_t length = thisSequence->getPeriodMs(); + thisSequence->addSlot(objects::HEATER_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SOLAR_ARRAY_DEPL_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::HEATER_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SOLAR_ARRAY_DEPL_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); + if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { + return HasReturnvaluesIF::RETURN_OK; + } - if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { - return HasReturnvaluesIF::RETURN_OK; - } - - sif::error << "PollingSequence::initialize has errors!" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; + sif::error << "PollingSequence::initialize has errors!" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; } ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { - uint32_t length = thisSequence->getPeriodMs(); - static_cast(length); + uint32_t length = thisSequence->getPeriodMs(); + static_cast(length); #if OBSW_ADD_TMP_DEVICES == 1 - thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0, DeviceHandlerIF::PERFORM_OPERATION); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC_3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_5, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_6, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_7, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_8, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_9, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_10, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_11, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_12, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_13, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_14, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_15, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_16, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_17, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_18, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_5, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_6, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_7, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_8, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_9, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_10, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_11, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_12, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_13, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_14, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_15, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_16, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_17, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_18, length * 0, DeviceHandlerIF::PERFORM_OPERATION); #endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_TMP_DEVICES == 1 - thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.2, DeviceHandlerIF::SEND_WRITE); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC_3, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_4, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_5, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_6, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_7, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_8, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_9, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_10, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_11, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_12, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_13, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_14, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_15, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_16, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_17, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_18, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_3, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_4, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_5, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_6, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_7, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_8, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_9, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_10, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_11, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_12, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_13, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_14, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_15, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_16, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_17, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_18, length * 0.2, DeviceHandlerIF::SEND_WRITE); #endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_TMP_DEVICES == 1 - thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.4, DeviceHandlerIF::GET_WRITE); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC_3, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_4, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_5, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_6, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_7, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_8, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_9, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_10, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_11, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_12, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_13, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_14, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_15, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_16, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_17, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_18, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_3, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_4, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_5, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_6, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_7, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_8, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_9, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_10, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_11, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_12, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_13, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_14, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_15, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_16, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_17, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_18, length * 0.4, DeviceHandlerIF::GET_WRITE); #endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_TMP_DEVICES == 1 - thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.6, DeviceHandlerIF::SEND_READ); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC_3, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_4, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_5, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_6, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_7, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_8, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_9, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_10, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_11, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_12, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_13, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_14, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_15, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_16, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_17, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_18, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_3, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_4, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_5, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_6, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_7, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_8, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_9, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_10, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_11, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_12, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_13, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_14, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_15, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_16, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_17, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_18, length * 0.6, DeviceHandlerIF::SEND_READ); #endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_TMP_DEVICES == 1 - thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC_3, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_4, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_5, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_6, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_7, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_8, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_9, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_10, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_11, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_12, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_13, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_14, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_15, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_16, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_17, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_18, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_3, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_4, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_5, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_6, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_7, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_8, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_9, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_10, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_11, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_12, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_13, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_14, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_15, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_16, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_17, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_18, length * 0.8, DeviceHandlerIF::GET_READ); #endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_RAD_SENSORS == 1 - /* Radiation sensor */ - thisSequence->addSlot(objects::RAD_SENSOR, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.8, DeviceHandlerIF::GET_READ); + /* Radiation sensor */ + thisSequence->addSlot(objects::RAD_SENSOR, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_SUN_SENSORS == 1 - /** - * The sun sensor will be shutdown as soon as the chip select is pulled high. Thus all - * requests to a sun sensor must be performed consecutively. Another reason for calling multiple - * device handler cycles is that the ADC conversions take some time. Thus first the ADC - * conversions are initiated and in a next step the results can be read from the internal FIFO. - * One sun sensor communication sequence also blocks the SPI bus. So other devices can not be - * inserted between the device handler cycles of one SUS. - */ - /* Write setup */ - thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_1, length * 0.9, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_1, length * 0.901, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_1, length * 0.902, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::GET_READ); + /** + * The sun sensor will be shutdown as soon as the chip select is pulled high. Thus all + * requests to a sun sensor must be performed consecutively. Another reason for calling multiple + * device handler cycles is that the ADC conversions take some time. Thus first the ADC + * conversions are initiated and in a next step the results can be read from the internal FIFO. + * One sun sensor communication sequence also blocks the SPI bus. So other devices can not be + * inserted between the device handler cycles of one SUS. + */ + /* Write setup */ + thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_1, length * 0.9, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_1, length * 0.901, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_1, length * 0.902, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_2, length * 0.903, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_2, length * 0.904, SusHandler::SEND_WRITE); - thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_2, length * 0.905, SusHandler::SEND_WRITE); - thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_2, length * 0.903, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_2, length * 0.904, SusHandler::SEND_WRITE); + thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_2, length * 0.905, SusHandler::SEND_WRITE); + thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_3, length * 0.8, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_3, length * 0.91, SusHandler::SEND_WRITE); - thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_3, length * 0.93, SusHandler::SEND_WRITE); - thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_3, length * 0.8, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_3, length * 0.91, SusHandler::SEND_WRITE); + thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_3, length * 0.93, SusHandler::SEND_WRITE); + thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_4, length * 0.909, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_4, length * 0.91, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_4, length * 0.911, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_4, length * 0.909, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_4, length * 0.91, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_4, length * 0.911, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_5, length * 0.912, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_5, length * 0.913, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_5, length * 0.914, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_5, length * 0.912, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_5, length * 0.913, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_5, length * 0.914, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_6, length * 0.915, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::GET_READ); - /* Read ADC conversions from inernal FIFO */ - thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_6, length * 0.915, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::GET_READ); + /* Read ADC conversions from inernal FIFO */ + thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_7, length * 0.918, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::GET_READ); - /* Read ADC conversions from inernal FIFO */ - thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_7, length * 0.918, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::GET_READ); + /* Read ADC conversions from inernal FIFO */ + thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_8, length * 0.921, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::GET_READ); - /* Read ADC conversions from inernal FIFO */ - thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_8, length * 0.921, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::GET_READ); + /* Read ADC conversions from inernal FIFO */ + thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_9, length * 0.924, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::GET_READ); - /* Read ADC conversions */ - thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_9, length * 0.924, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::GET_READ); + /* Read ADC conversions */ + thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_10, length * 0.927, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::GET_READ); - /* Read ADC conversions */ - thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_10, length * 0.927, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::GET_READ); + /* Read ADC conversions */ + thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_11, length * 0.93, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::GET_READ); - /* Read ADC conversions */ - thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_11, length * 0.93, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::GET_READ); + /* Read ADC conversions */ + thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_12, length * 0.933, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::GET_READ); - /* Read ADC conversions */ - thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_12, length * 0.933, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::GET_READ); + /* Read ADC conversions */ + thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_13, length * 0.936, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::GET_READ); - /* Read ADC conversions */ - thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_13, length * 0.936, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::GET_READ); + /* Read ADC conversions */ + thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_RW == 1 - thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RW1, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW1, length * 0.5, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW1, length * 0.65, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW1, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW1, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW1, length * 0.5, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW1, length * 0.65, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW1, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RW2, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW2, length * 0.5, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW2, length * 0.65, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW2, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW2, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW2, length * 0.5, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW2, length * 0.65, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW2, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RW3, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW3, length * 0.5, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW3, length * 0.65, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW3, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW3, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW3, length * 0.5, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW3, length * 0.65, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW3, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RW4, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW4, length * 0.5, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW4, length * 0.65, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW4, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW4, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW4, length * 0.5, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW4, length * 0.65, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW4, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_ACS_BOARD == 1 - bool enableAside = true; - bool enableBside = false; - if(enableAside) { - // A side - thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.25, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.7, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); + bool enableAside = true; + bool enableBside = false; + if (enableAside) { + // A side + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.25, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.7, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.25, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.75, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.25, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.3, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.75, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.3, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.35, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.75, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); - } + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.35, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); + } - if(enableBside) { - // B side - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.2, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.7, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); + if (enableBside) { + // B side + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.7, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.25, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.75, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.25, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.3, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.75, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.3, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.35, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - 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); - } + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.35, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + 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 */ - ReturnValue_t seqCheck = thisSequence->checkSequence(); - if (seqCheck != HasReturnvaluesIF::RETURN_OK) { - if(seqCheck == FixedTimeslotTaskIF::SLOT_LIST_EMPTY) { - sif::warning << "SPI PST is empty.." << std::endl; - } - else { - sif::error << "SPI PST initialization failed" << std::endl; - } - - return seqCheck; + ReturnValue_t seqCheck = thisSequence->checkSequence(); + if (seqCheck != HasReturnvaluesIF::RETURN_OK) { + if (seqCheck == FixedTimeslotTaskIF::SLOT_LIST_EMPTY) { + sif::warning << "SPI PST is empty.." << std::endl; + } else { + sif::error << "SPI PST initialization failed" << std::endl; } - return HasReturnvaluesIF::RETURN_OK; + + return seqCheck; + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t pst::pstI2c(FixedTimeslotTaskIF *thisSequence) { - // Length of a communication cycle - uint32_t length = thisSequence->getPeriodMs(); - thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); - if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "I2C PST initialization failed" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + // Length of a communication cycle + uint32_t length = thisSequence->getPeriodMs(); + thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); + if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "I2C PST initialization failed" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) { - // Length of a communication cycle - uint32_t length = thisSequence->getPeriodMs(); - bool uartPstEmpty = true; + // Length of a communication cycle + uint32_t length = thisSequence->getPeriodMs(); + bool uartPstEmpty = true; #if OBSW_ADD_PLOC_MPSOC == 1 - uartPstEmpty = false; - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.2, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.4, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.6, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.8, - DeviceHandlerIF::GET_READ); + uartPstEmpty = false; + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif - thisSequence->addSlot(objects::PLOC_UPDATER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PLOC_MEMORY_DUMPER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_UPDATER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_MEMORY_DUMPER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); #if OBSW_ADD_PLOC_SUPERVISOR == 1 - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.2, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.4, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.6, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.8, - DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.2, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_SYRLINKS == 1 - uartPstEmpty = false; - thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.2, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.4, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.6, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.8, - DeviceHandlerIF::GET_READ); + uartPstEmpty = false; + thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_STAR_TRACKER == 1 - uartPstEmpty = false; - thisSequence->addSlot(objects::STAR_TRACKER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::STAR_TRACKER, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::STAR_TRACKER, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::STAR_TRACKER, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::STAR_TRACKER, length * 0.8, DeviceHandlerIF::GET_READ); + uartPstEmpty = false; + thisSequence->addSlot(objects::STAR_TRACKER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::STAR_TRACKER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::STAR_TRACKER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::STAR_TRACKER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::STAR_TRACKER, length * 0.8, DeviceHandlerIF::GET_READ); #endif - if(uartPstEmpty) { - return HasReturnvaluesIF::RETURN_OK; - } - if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "UART PST initialization failed" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } + if (uartPstEmpty) { return HasReturnvaluesIF::RETURN_OK; + } + if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "UART PST initialization failed" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t pst::pstGompaceCan(FixedTimeslotTaskIF *thisSequence){ - uint32_t length = thisSequence->getPeriodMs(); +ReturnValue_t pst::pstGompaceCan(FixedTimeslotTaskIF *thisSequence) { + uint32_t length = thisSequence->getPeriodMs(); - // PCDU handlers receives two messages and both must be handled - thisSequence->addSlot(objects::PCDU_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PCDU_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + // PCDU handlers receives two messages and both must be handled + thisSequence->addSlot(objects::PCDU_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PCDU_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::P60DOCK_HANDLER, - length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PDU1_HANDLER, - length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PDU2_HANDLER, - length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::ACU_HANDLER, - length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PDU1_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PDU2_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::ACU_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::P60DOCK_HANDLER, - length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::PDU1_HANDLER, - length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::PDU2_HANDLER, - length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::ACU_HANDLER, - length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::ACU_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::P60DOCK_HANDLER, - length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::PDU1_HANDLER, - length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::PDU2_HANDLER, - length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::ACU_HANDLER, - length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::ACU_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::P60DOCK_HANDLER, - length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::PDU1_HANDLER, - length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::PDU2_HANDLER, - length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::ACU_HANDLER, - length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::ACU_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::P60DOCK_HANDLER, - length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::PDU1_HANDLER, - length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::PDU2_HANDLER, - length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::ACU_HANDLER, - length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::ACU_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); - if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "GomSpace PST initialization failed" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomSpace PST initialization failed" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t pst::pstTest(FixedTimeslotTaskIF* thisSequence) { - /* Length of a communication cycle */ - uint32_t length = thisSequence->getPeriodMs(); - bool notEmpty = false; +ReturnValue_t pst::pstTest(FixedTimeslotTaskIF *thisSequence) { + /* Length of a communication cycle */ + uint32_t length = thisSequence->getPeriodMs(); + bool notEmpty = false; #if RPI_TEST_ADIS16507 == 1 - notEmpty = true; - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); + notEmpty = true; + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if RPI_TEST_GPS_HANDLER == 1 - notEmpty = true; - thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + notEmpty = true; + thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.5, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.5, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.5, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.5, DeviceHandlerIF::GET_READ); #endif - static_cast(length); - if(not notEmpty) { - return HasReturnvaluesIF::RETURN_FAILED; - } - if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Test PST initialization failed" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + static_cast(length); + if (not notEmpty) { + return HasReturnvaluesIF::RETURN_FAILED; + } + if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Test PST initialization failed" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } #if BOARD_TE0720 == 1 ReturnValue_t pst::pollingSequenceTE0720(FixedTimeslotTaskIF *thisSequence) { - uint32_t length = thisSequence->getPeriodMs(); + uint32_t length = thisSequence->getPeriodMs(); #if TEST_PLOC_MPSOC_HANDLER == 1 - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_TEST_RADIATION_SENSOR_HANDLER == 1 - thisSequence->addSlot(objects::RAD_SENSOR, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_TEST_SUS_HANDLER == 1 - /* Write setup */ - thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_1, length * 0.902, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.903, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.904, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_1, length * 0.905, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_1, length * 0.902, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.903, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.904, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_1, length * 0.905, DeviceHandlerIF::GET_READ); - /* Start conversion*/ - thisSequence->addSlot(objects::SUS_1, length * 0.906, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_1, length * 0.907, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.908, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.909, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_1, length * 0.91, DeviceHandlerIF::GET_READ); + /* Start conversion*/ + thisSequence->addSlot(objects::SUS_1, length * 0.906, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_1, length * 0.907, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.908, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.909, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_1, length * 0.91, DeviceHandlerIF::GET_READ); - /* Read conversions */ - thisSequence->addSlot(objects::SUS_1, length * 0.911, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_1, length * 0.912, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.913, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.914, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_1, length * 0.915, DeviceHandlerIF::GET_READ); + /* Read conversions */ + thisSequence->addSlot(objects::SUS_1, length * 0.911, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_1, length * 0.912, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.913, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.914, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_1, length * 0.915, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_PLOC_SUPERVISOR == 1 - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.7, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.2, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.7, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif - thisSequence->addSlot(objects::PLOC_UPDATER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PLOC_MEMORY_DUMPER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_UPDATER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_MEMORY_DUMPER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); - if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Initialization of TE0720 PST failed" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Initialization of TE0720 PST failed" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } #endif /* BOARD_TE0720 == 1 */ diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h index 5bb5ff2a..36b86ba8 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h @@ -32,7 +32,7 @@ class FixedTimeslotTaskIF; namespace pst { /* 0.4 second period init*/ -ReturnValue_t pstGpio(FixedTimeslotTaskIF *thisSequence); +ReturnValue_t pstGpio(FixedTimeslotTaskIF* thisSequence); /** * @brief This function creates the PST for all gomspace devices. @@ -40,7 +40,7 @@ ReturnValue_t pstGpio(FixedTimeslotTaskIF *thisSequence); * Scheduled in a separate PST because the gomspace library uses blocking calls when requesting * data from devices. */ -ReturnValue_t pstGompaceCan(FixedTimeslotTaskIF *thisSequence); +ReturnValue_t pstGompaceCan(FixedTimeslotTaskIF* thisSequence); ReturnValue_t pstUart(FixedTimeslotTaskIF* thisSequence); @@ -62,7 +62,6 @@ ReturnValue_t pstTest(FixedTimeslotTaskIF* thisSequence); ReturnValue_t pollingSequenceTE0720(FixedTimeslotTaskIF* thisSequence); #endif -} - +} // namespace pst #endif /* POLLINGSEQUENCEINIT_H_ */ diff --git a/linux/fsfwconfig/returnvalues/classIds.h b/linux/fsfwconfig/returnvalues/classIds.h index b98801e2..86edb85f 100644 --- a/linux/fsfwconfig/returnvalues/classIds.h +++ b/linux/fsfwconfig/returnvalues/classIds.h @@ -1,8 +1,8 @@ #ifndef FSFWCONFIG_RETURNVALUES_CLASSIDS_H_ #define FSFWCONFIG_RETURNVALUES_CLASSIDS_H_ -#include #include +#include /** * Source IDs starts at 73 for now @@ -11,13 +11,12 @@ */ namespace CLASS_ID { enum { - CLASS_ID_START = COMMON_CLASS_ID_END, - SA_DEPL_HANDLER, //SADPL - SD_CARD_MANAGER, //SDMA - SCRATCH_BUFFER, //SCBU - CLASS_ID_END // [EXPORT] : [END] + CLASS_ID_START = COMMON_CLASS_ID_END, + SA_DEPL_HANDLER, // SADPL + SD_CARD_MANAGER, // SDMA + SCRATCH_BUFFER, // SCBU + CLASS_ID_END // [EXPORT] : [END] }; } - #endif /* FSFWCONFIG_RETURNVALUES_CLASSIDS_H_ */ diff --git a/linux/fsfwconfig/tmtc/pusIds.h b/linux/fsfwconfig/tmtc/pusIds.h index a2dd7575..37503786 100644 --- a/linux/fsfwconfig/tmtc/pusIds.h +++ b/linux/fsfwconfig/tmtc/pusIds.h @@ -2,21 +2,21 @@ #define CONFIG_TMTC_PUSIDS_HPP_ namespace pus { -enum Ids{ - PUS_SERVICE_1 = 1, - PUS_SERVICE_2 = 2, - PUS_SERVICE_3 = 3, - PUS_SERVICE_3_PSB = 3, - PUS_SERVICE_5 = 5, - PUS_SERVICE_6 = 6, - PUS_SERVICE_8 = 8, - PUS_SERVICE_9 = 9, - PUS_SERVICE_17 = 17, - PUS_SERVICE_19 = 19, - PUS_SERVICE_20 = 20, - PUS_SERVICE_23 = 23, - PUS_SERVICE_200 = 200, - PUS_SERVICE_201 = 201, +enum Ids { + PUS_SERVICE_1 = 1, + PUS_SERVICE_2 = 2, + PUS_SERVICE_3 = 3, + PUS_SERVICE_3_PSB = 3, + PUS_SERVICE_5 = 5, + PUS_SERVICE_6 = 6, + PUS_SERVICE_8 = 8, + PUS_SERVICE_9 = 9, + PUS_SERVICE_17 = 17, + PUS_SERVICE_19 = 19, + PUS_SERVICE_20 = 20, + PUS_SERVICE_23 = 23, + PUS_SERVICE_200 = 200, + PUS_SERVICE_201 = 201, }; }; diff --git a/linux/obc/PapbVcInterface.cpp b/linux/obc/PapbVcInterface.cpp index 5bb72066..f144306c 100644 --- a/linux/obc/PapbVcInterface.cpp +++ b/linux/obc/PapbVcInterface.cpp @@ -1,104 +1,98 @@ #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) { -} - -PapbVcInterface::~PapbVcInterface() { -} + gpioId_t papbBusyId, gpioId_t papbEmptyId, uint32_t vcOffset) + : SystemObject(objectId), + gpioComIF(gpioComIF), + papbBusyId(papbBusyId), + papbEmptyId(papbEmptyId), + vcOffset(vcOffset) {} +PapbVcInterface::~PapbVcInterface() {} void PapbVcInterface::setRegisterAddress(uint32_t* ptmeBaseAddress) { - vcBaseReg = ptmeBaseAddress + vcOffset; + vcBaseReg = ptmeBaseAddress + vcOffset; } -ReturnValue_t PapbVcInterface::write(const uint8_t * data, size_t size) { +ReturnValue_t PapbVcInterface::write(const uint8_t* data, size_t size) { + if (pollPapbBusySignal() == RETURN_OK) { + startPacketTransfer(); + } - 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; } + } - 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 937f4280..e7d03a70 100644 --- a/linux/obc/PapbVcInterface.h +++ b/linux/obc/PapbVcInterface.h @@ -1,12 +1,13 @@ #ifndef LINUX_OBC_PAPBVCINTERFACE_H_ #define LINUX_OBC_PAPBVCINTERFACE_H_ -#include "OBSWConfig.h" -#include "linux/obc/VcInterfaceIF.h" #include #include -#include "fsfw/returnvalues/HasReturnvaluesIF.h" + +#include "OBSWConfig.h" #include "fsfw/objectmanager/ObjectManager.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "linux/obc/VcInterfaceIF.h" /** * @brief This class handles the transmission of data to a virtual channel of the PTME IP Core @@ -14,99 +15,96 @@ * * @author J. Meier */ -class PapbVcInterface: public SystemObject, - 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. - * @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). - */ - PapbVcInterface(object_id_t objectId, LinuxLibgpioIF* gpioComIF, gpioId_t papbBusyId, - gpioId_t papbEmptyId, uint32_t vcOffset); - virtual ~PapbVcInterface(); +class PapbVcInterface : public SystemObject, 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. + * @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). + */ + PapbVcInterface(object_id_t objectId, LinuxLibgpioIF* gpioComIF, gpioId_t papbBusyId, + gpioId_t papbEmptyId, uint32_t vcOffset); + virtual ~PapbVcInterface(); - ReturnValue_t write(const uint8_t* data, size_t size) override; + ReturnValue_t write(const uint8_t* data, size_t size) override; - void setRegisterAddress(uint32_t* ptmeBaseAddress) override; + void setRegisterAddress(uint32_t* ptmeBaseAddress) override; -private: + private: + static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_IP_CORE_BRIDGE; - static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_IP_CORE_BRIDGE; + static const ReturnValue_t PAPB_BUSY = MAKE_RETURN_CODE(0xA0); - static const ReturnValue_t PAPB_BUSY = MAKE_RETURN_CODE(0xA0); + /** + * Configuration bits: + * bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00 + * bit[2]: Set this bit to 1 to abort a transfered packet + * bit[3]: Signals to VcInterface the start of a new telemetry packet + */ + static const uint32_t CONFIG_START = 0x8; - /** - * Configuration bits: - * bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00 - * bit[2]: Set this bit to 1 to abort a transfered packet - * bit[3]: Signals to VcInterface the start of a new telemetry packet - */ - static const uint32_t CONFIG_START = 0x8; + /** + * Writing this word to the VcInterface base address signals to the virtual channel interface + * that a complete tm packet has been transferred. + */ + static const uint32_t CONFIG_END = 0x0; - /** - * Writing this word to the VcInterface base address signals to the virtual channel interface - * that a complete tm packet has been transferred. - */ - static const uint32_t CONFIG_END = 0x0; + /** + * Writing to this offset within the memory space of a virtual channel will insert data for + * encoding to the external buffer memory of the PTME IP Core. + * The address offset is 0x400 (= 4 * 256) + */ + static const int DATA_REG_OFFSET = 256; - /** - * Writing to this offset within the memory space of a virtual channel will insert data for - * encoding to the external buffer memory of the PTME IP Core. - * The address offset is 0x400 (= 4 * 256) - */ - static const int DATA_REG_OFFSET = 256; + LinuxLibgpioIF* gpioComIF = nullptr; - LinuxLibgpioIF* gpioComIF = nullptr; + /** Pulled to low when virtual channel not ready to receive data */ + gpioId_t papbBusyId = gpio::NO_GPIO; + /** High when external buffer memory of virtual channel is empty */ + gpioId_t papbEmptyId = gpio::NO_GPIO; - /** Pulled to low when virtual channel not ready to receive data */ - gpioId_t papbBusyId = gpio::NO_GPIO; - /** High when external buffer memory of virtual channel is empty */ - gpioId_t papbEmptyId = gpio::NO_GPIO; + uint32_t* vcBaseReg = nullptr; - uint32_t* vcBaseReg = nullptr; + uint32_t vcOffset = 0; - uint32_t vcOffset = 0; + /** + * @brief This function sends the config byte to the virtual channel of the PTME IP Core + * to initiate a packet transfer. + */ + void startPacketTransfer(); - /** - * @brief This function sends the config byte to the virtual channel of the PTME IP Core - * to initiate a packet transfer. - */ - void startPacketTransfer(); + /** + * @brief This function sends the config byte to the virtual channel interface of the PTME + * IP Core to signal the end of a packet transfer. + */ + void endPacketTransfer(); - /** - * @brief This function sends the config byte to the virtual channel interface of the PTME - * IP Core to signal the end of a packet transfer. - */ - void endPacketTransfer(); + /** + * @brief This function reads the papb busy signal indicating whether the virtual channel + * interface is ready to receive more data or not. PAPB is ready when + * PAPB_Busy_N == '1'. + * + * @return RETURN_OK when ready to receive data else PAPB_BUSY. + */ + ReturnValue_t pollPapbBusySignal(); - /** - * @brief This function reads the papb busy signal indicating whether the virtual channel - * interface is ready to receive more data or not. PAPB is ready when - * PAPB_Busy_N == '1'. - * - * @return RETURN_OK when ready to receive data else PAPB_BUSY. - */ - ReturnValue_t pollPapbBusySignal(); + /** + * @brief This function can be used for debugging to check whether there are packets in + * the packet buffer of the virtual channel or not. + */ + void isVcInterfaceBufferEmpty(); - /** - * @brief This function can be used for debugging to check whether there are packets in - * the packet buffer of the virtual channel or not. - */ - void isVcInterfaceBufferEmpty(); - - /** - * @brief This function sends a complete telemetry transfer frame data field (1105 bytes) - * to the papb interface of the PTME IP Core. Can be used to test the implementation. - */ - ReturnValue_t sendTestFrame(); + /** + * @brief This function sends a complete telemetry transfer frame data field (1105 bytes) + * to the papb interface of the PTME IP Core. Can be used to test the implementation. + */ + ReturnValue_t sendTestFrame(); }; #endif /* LINUX_OBC_PAPBVCINTERFACE_H_ */ diff --git a/linux/obc/PdecConfig.cpp b/linux/obc/PdecConfig.cpp index bb2ffb13..ac762a6c 100644 --- a/linux/obc/PdecConfig.cpp +++ b/linux/obc/PdecConfig.cpp @@ -1,36 +1,33 @@ #include "PdecConfig.h" + #include "fsfw/serviceinterface/ServiceInterface.h" -PdecConfig::PdecConfig() { - initialize(); -} +PdecConfig::PdecConfig() { initialize(); } -PdecConfig::~PdecConfig() { - -} +PdecConfig::~PdecConfig() {} void PdecConfig::initialize() { - uint32_t word = 0; - word |= (VERSION_ID << 30); - word |= (BYPASS_FLAG << 29); - word |= (CONTROL_COMMAND_FLAG << 28); - word |= (RESERVED_FIELD_A << 26); - word |= (SPACECRAFT_ID << 16); - word |= (VIRTUAL_CHANNEL << 10); - word |= (DUMMY_BITS << 8); - word |= POSITIVE_WINDOW; - configWords[0] = word; - word = 0; - word |= (NEGATIVE_WINDOW << 24); - word |= (HIGH_AU_MAP_ID << 16); - word |= (ENABLE_DERANDOMIZER << 8); - configWords[1] = word; + uint32_t word = 0; + word |= (VERSION_ID << 30); + word |= (BYPASS_FLAG << 29); + word |= (CONTROL_COMMAND_FLAG << 28); + word |= (RESERVED_FIELD_A << 26); + word |= (SPACECRAFT_ID << 16); + word |= (VIRTUAL_CHANNEL << 10); + word |= (DUMMY_BITS << 8); + word |= POSITIVE_WINDOW; + configWords[0] = word; + word = 0; + word |= (NEGATIVE_WINDOW << 24); + word |= (HIGH_AU_MAP_ID << 16); + word |= (ENABLE_DERANDOMIZER << 8); + configWords[1] = word; } uint32_t PdecConfig::getConfigWord(uint8_t wordNo) { - if (wordNo >= CONFIG_WORDS_NUM) { - sif::error << "PdecConfig::getConfigWord: Invalid word number" << std::endl; - return 0; - } - return configWords[wordNo]; + if (wordNo >= CONFIG_WORDS_NUM) { + sif::error << "PdecConfig::getConfigWord: Invalid word number" << std::endl; + return 0; + } + return configWords[wordNo]; } diff --git a/linux/obc/PdecConfig.h b/linux/obc/PdecConfig.h index 46cd5097..37dab151 100644 --- a/linux/obc/PdecConfig.h +++ b/linux/obc/PdecConfig.h @@ -1,9 +1,10 @@ #ifndef LINUX_OBC_PDECCONFIG_H_ #define LINUX_OBC_PDECCONFIG_H_ -#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include +#include "fsfw/returnvalues/HasReturnvaluesIF.h" + /** * @brief This class generates the configuration words for the configuration memory of the PDEC * IP Cores. @@ -14,39 +15,38 @@ * @author J. Meier */ class PdecConfig { + public: + PdecConfig(); + virtual ~PdecConfig(); -public: - PdecConfig(); - virtual ~PdecConfig(); + /** + * @brief Returns the configuration word by specifying the position. + */ + uint32_t getConfigWord(uint8_t wordNo); - /** - * @brief Returns the configuration word by specifying the position. - */ - uint32_t getConfigWord(uint8_t wordNo); + private: + // TC transfer frame configuration parameters + static const uint8_t VERSION_ID = 0; + // BD Frames + static const uint8_t BYPASS_FLAG = 1; + static const uint8_t CONTROL_COMMAND_FLAG = 0; -private: - // TC transfer frame configuration parameters - static const uint8_t VERSION_ID = 0; - // BD Frames - static const uint8_t BYPASS_FLAG = 1; - static const uint8_t CONTROL_COMMAND_FLAG = 0; + static const uint8_t VIRTUAL_CHANNEL = 0; + static const uint8_t RESERVED_FIELD_A = 0; + static const uint16_t SPACECRAFT_ID = 0x274; + static const uint16_t DUMMY_BITS = 0; + // Parameters to control the FARM for AD frames + // Set here for future use + static const uint8_t POSITIVE_WINDOW = 10; + static const uint8_t NEGATIVE_WINDOW = 151; + static const uint8_t HIGH_AU_MAP_ID = 0xF; + static const uint8_t ENABLE_DERANDOMIZER = 1; - static const uint8_t VIRTUAL_CHANNEL = 0; - static const uint8_t RESERVED_FIELD_A = 0; - static const uint16_t SPACECRAFT_ID = 0x274; - static const uint16_t DUMMY_BITS = 0; - // Parameters to control the FARM for AD frames - // Set here for future use - static const uint8_t POSITIVE_WINDOW = 10; - static const uint8_t NEGATIVE_WINDOW = 151; - static const uint8_t HIGH_AU_MAP_ID = 0xF; - static const uint8_t ENABLE_DERANDOMIZER = 1; + static const uint8_t CONFIG_WORDS_NUM = 2; - static const uint8_t CONFIG_WORDS_NUM = 2; + uint32_t configWords[CONFIG_WORDS_NUM]; - uint32_t configWords[CONFIG_WORDS_NUM]; - - void initialize(); + void initialize(); }; #endif /* LINUX_OBC_PDECCONFIG_H_ */ diff --git a/linux/obc/PdecHandler.cpp b/linux/obc/PdecHandler.cpp index aa46c23c..a5ee98d6 100644 --- a/linux/obc/PdecHandler.cpp +++ b/linux/obc/PdecHandler.cpp @@ -1,578 +1,568 @@ +#include "PdecHandler.h" + +#include +#include + #include #include -#include -#include - -#include "PdecHandler.h" #include "OBSWConfig.h" +#include "fsfw/ipc/QueueFactory.h" +#include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/tmtcservices/TmTcMessage.h" -#include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/ipc/QueueFactory.h" - PdecHandler::PdecHandler(object_id_t objectId, object_id_t tcDestinationId, - LinuxLibgpioIF* gpioComIF, gpioId_t pdecReset, std::string uioConfigMemory, - std::string uioRamMemory, std::string uioRegisters) : - SystemObject(objectId), tcDestinationId(tcDestinationId), gpioComIF(gpioComIF), pdecReset( - pdecReset), uioConfigMemory(uioConfigMemory), uioRamMemory(uioRamMemory), uioRegisters( - uioRegisters), actionHelper(this, nullptr) { - commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); + LinuxLibgpioIF* gpioComIF, gpioId_t pdecReset, std::string uioConfigMemory, + std::string uioRamMemory, std::string uioRegisters) + : SystemObject(objectId), + tcDestinationId(tcDestinationId), + gpioComIF(gpioComIF), + pdecReset(pdecReset), + uioConfigMemory(uioConfigMemory), + uioRamMemory(uioRamMemory), + uioRegisters(uioRegisters), + actionHelper(this, nullptr) { + commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); } -PdecHandler::~PdecHandler() { -} +PdecHandler::~PdecHandler() {} ReturnValue_t PdecHandler::initialize() { + tcStore = ObjectManager::instance()->get(objects::TC_STORE); + if (tcStore == nullptr) { + sif::error << "PdecHandler::initialize: Invalid TC store" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - tcStore = ObjectManager::instance()->get(objects::TC_STORE); - if (tcStore == nullptr) { - sif::error << "PdecHandler::initialize: Invalid TC store" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + tcDestination = ObjectManager::instance()->get(tcDestinationId); - tcDestination = ObjectManager::instance()->get( - tcDestinationId); + if (tcDestination == nullptr) { + sif::error << "PdecHandler::initialize: Invalid tc destination specified" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - if (tcDestination == nullptr) { - sif::error << "PdecHandler::initialize: Invalid tc destination specified" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = getRegisterAddress(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = getRegisterAddress(); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = getConfigMemoryBaseAddress(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = getConfigMemoryBaseAddress(); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = getRamBaseAddress(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = getRamBaseAddress(); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + writePdecConfig(); - writePdecConfig(); + result = releasePdec(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = releasePdec(); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = actionHelper.initialize(commandQueue); + if (result != RETURN_OK) { + return result; + } - result = actionHelper.initialize(commandQueue); - if (result != RETURN_OK) { - return result; - } - - return RETURN_OK; + return RETURN_OK; } -MessageQueueId_t PdecHandler::getCommandQueue() const { - return commandQueue->getId(); -} +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; - } + 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)); + 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; - } + if (registerBaseAddress == MAP_FAILED) { + sif::error << "PdecHandler::getRegisterAddress: Failed to map uio address" << std::endl; + return RETURN_FAILED; + } - return RETURN_OK; + 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; - } + 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)); + 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; - } + if (memoryBaseAddress == MAP_FAILED) { + sif::error << "PdecHandler::getConfigMemoryBaseAddress: Failed to map uio address" << std::endl; + return RETURN_FAILED; + } - return RETURN_OK; + return RETURN_OK; } ReturnValue_t PdecHandler::getRamBaseAddress() { - int fd = open(uioRamMemory.c_str(), O_RDWR); + int fd = open(uioRamMemory.c_str(), O_RDWR); - ramBaseAddress = static_cast(mmap(NULL, RAM_MAP_SIZE, PROT_WRITE | PROT_READ, - MAP_SHARED, fd, 0)); + 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; + 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() { +void PdecHandler::writePdecConfig() { + PdecConfig pdecConfig; - PdecConfig pdecConfig; + *(memoryBaseAddress + FRAME_HEADER_OFFSET) = pdecConfig.getConfigWord(0); + *(memoryBaseAddress + FRAME_HEADER_OFFSET + 1) = pdecConfig.getConfigWord(1); - *(memoryBaseAddress + FRAME_HEADER_OFFSET)= pdecConfig.getConfigWord(0); - *(memoryBaseAddress + FRAME_HEADER_OFFSET + 1) = pdecConfig.getConfigWord(1); + // Configure all MAP IDs as invalid + for (int idx = 0; idx <= MAX_MAP_ADDR; idx += 4) { + *(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + idx + 1 / 4) = + NO_DESTINATION << 24 | NO_DESTINATION << 16 | NO_DESTINATION << 8 | NO_DESTINATION; + } - // Configure all MAP IDs as invalid - for (int idx = 0; idx <= MAX_MAP_ADDR; idx += 4) { - *(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + idx + 1 / 4) = NO_DESTINATION << 24 - | NO_DESTINATION << 16 | NO_DESTINATION << 8 | NO_DESTINATION; + // All TCs with MAP ID 7 will be routed to the PM module (can then be read from memory) + uint8_t routeToPm = calcMapAddrEntry(PM_BUFFER); + *(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + 1) = + (NO_DESTINATION << 24) | (NO_DESTINATION << 16) | (NO_DESTINATION << 8) | routeToPm; - } - - // All TCs with MAP ID 7 will be routed to the PM module (can then be read from memory) - uint8_t routeToPm = calcMapAddrEntry(PM_BUFFER); - *(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + 1) = (NO_DESTINATION << 24) | (NO_DESTINATION << 16) | (NO_DESTINATION << 8) - | routeToPm; - - // Write map id clock frequencies - for (int idx = 0; idx <= MAX_MAP_ADDR; idx += 4) { - *(memoryBaseAddress + MAP_CLK_FREQ_OFFSET + idx / 4) = MAP_CLK_FREQ << 24 - | MAP_CLK_FREQ << 16 | MAP_CLK_FREQ << 8 | MAP_CLK_FREQ; - - } + // Write map id clock frequencies + for (int idx = 0; idx <= MAX_MAP_ADDR; idx += 4) { + *(memoryBaseAddress + MAP_CLK_FREQ_OFFSET + idx / 4) = + MAP_CLK_FREQ << 24 | MAP_CLK_FREQ << 16 | MAP_CLK_FREQ << 8 | MAP_CLK_FREQ; + } } ReturnValue_t PdecHandler::resetFarStatFlag() { - uint32_t pdecFar = *(registerBaseAddress + PDEC_FAR_OFFSET); - if (pdecFar != FAR_RESET) { - sif::warning << "PdecHandler::resetFarStatFlag: FAR register did not match expected value." - << " Read value: 0x" << std::hex << static_cast(pdecFar) << std::endl; - return RETURN_FAILED; - } + uint32_t pdecFar = *(registerBaseAddress + PDEC_FAR_OFFSET); + if (pdecFar != FAR_RESET) { + sif::warning << "PdecHandler::resetFarStatFlag: FAR register did not match expected value." + << " Read value: 0x" << std::hex << static_cast(pdecFar) + << std::endl; + return RETURN_FAILED; + } #if OBSW_DEBUG_PDEC_HANDLER == 1 - sif::debug << "PdecHandler::resetFarStatFlag: read FAR with value: 0x" << std::hex << pdecFar - << std::endl; + sif::debug << "PdecHandler::resetFarStatFlag: read FAR with value: 0x" << std::hex << pdecFar + << std::endl; #endif /* OBSW_DEBUG_PDEC_HANDLER == 1 */ - return RETURN_OK; + return RETURN_OK; } -ReturnValue_t PdecHandler::releasePdec() { - ReturnValue_t result = RETURN_OK; - result = gpioComIF->pullHigh(pdecReset); - if (result != RETURN_OK) { - sif::error << "PdecHandler::releasePdec: Failed to release PDEC reset signal" << std::endl; - } - return result; +ReturnValue_t PdecHandler::releasePdec() { + ReturnValue_t result = RETURN_OK; + result = gpioComIF->pullHigh(pdecReset); + if (result != RETURN_OK) { + sif::error << "PdecHandler::releasePdec: Failed to release PDEC reset signal" << std::endl; + } + return result; } ReturnValue_t PdecHandler::performOperation(uint8_t operationCode) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + readCommandQueue(); - readCommandQueue(); - - switch(state) { + switch (state) { case State::INIT: - resetFarStatFlag(); - if (result != RETURN_OK) { - // Requires reconfiguration and reinitialization of PDEC - triggerEvent(INVALID_FAR); - state = State::WAIT_FOR_RECOVERY; - return result; - } - state = State::RUNNING; - break; + resetFarStatFlag(); + if (result != RETURN_OK) { + // Requires reconfiguration and reinitialization of PDEC + triggerEvent(INVALID_FAR); + state = State::WAIT_FOR_RECOVERY; + return result; + } + state = State::RUNNING; + break; case State::RUNNING: - if (newTcReceived()) { - handleNewTc(); - } - checkLocks(); - break; + if (newTcReceived()) { + handleNewTc(); + } + checkLocks(); + break; case State::WAIT_FOR_RECOVERY: - break; + break; default: - sif::debug << "PdecHandler::performOperation: Invalid state" << std::endl; - break; - } + sif::debug << "PdecHandler::performOperation: Invalid state" << std::endl; + break; + } - return RETURN_OK; + return RETURN_OK; } void PdecHandler::readCommandQueue(void) { - CommandMessage commandMessage; - ReturnValue_t result = RETURN_FAILED; + CommandMessage commandMessage; + ReturnValue_t result = RETURN_FAILED; - result = commandQueue->receiveMessage(&commandMessage); + result = commandQueue->receiveMessage(&commandMessage); + if (result == RETURN_OK) { + result = actionHelper.handleActionMessage(&commandMessage); if (result == RETURN_OK) { - result = actionHelper.handleActionMessage(&commandMessage); - if (result == RETURN_OK) { - return; - } - CommandMessage reply; - reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND, - commandMessage.getCommand()); - commandQueue->reply(&reply); - return; + return; } + CommandMessage reply; + reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND, commandMessage.getCommand()); + commandQueue->reply(&reply); + return; + } } bool PdecHandler::newTcReceived() { - uint32_t pdecFar = *(registerBaseAddress + PDEC_FAR_OFFSET); + uint32_t pdecFar = *(registerBaseAddress + PDEC_FAR_OFFSET); - if (pdecFar >> STAT_POSITION != NEW_FAR_RECEIVED) { - return false; - } - if (!checkFrameAna(pdecFar)) { - return false; - } - return true; + if (pdecFar >> STAT_POSITION != NEW_FAR_RECEIVED) { + return false; + } + if (!checkFrameAna(pdecFar)) { + return false; + } + return true; } void PdecHandler::checkLocks() { - uint32_t clcw = getClcw(); - if (!(clcw & NO_RF_MASK) && (lastClcw & NO_RF_MASK)) { - // Rf available changed from 0 to 1 - triggerEvent(CARRIER_LOCK); - } - if (!(clcw & NO_BITLOCK_MASK) && (lastClcw & NO_BITLOCK_MASK)) { - // Bit lock changed from 0 to 1 - triggerEvent(BIT_LOCK_PDEC); - } - lastClcw = clcw; + uint32_t clcw = getClcw(); + if (!(clcw & NO_RF_MASK) && (lastClcw & NO_RF_MASK)) { + // Rf available changed from 0 to 1 + triggerEvent(CARRIER_LOCK); + } + if (!(clcw & NO_BITLOCK_MASK) && (lastClcw & NO_BITLOCK_MASK)) { + // Bit lock changed from 0 to 1 + triggerEvent(BIT_LOCK_PDEC); + } + lastClcw = clcw; } bool PdecHandler::checkFrameAna(uint32_t pdecFar) { - bool frameValid = false; - FrameAna_t frameAna = static_cast((pdecFar & FRAME_ANA_MASK) >> FRAME_ANA_POSITION); - switch(frameAna) { - case(FrameAna_t::ABANDONED_CLTU): { - triggerEvent(INVALID_TC_FRAME, ABANDONED_CLTU); - sif::warning << "PdecHandler::checkFrameAna: Abondoned CLTU" << std::endl; - break; + bool frameValid = false; + FrameAna_t frameAna = static_cast((pdecFar & FRAME_ANA_MASK) >> FRAME_ANA_POSITION); + switch (frameAna) { + case (FrameAna_t::ABANDONED_CLTU): { + triggerEvent(INVALID_TC_FRAME, ABANDONED_CLTU); + sif::warning << "PdecHandler::checkFrameAna: Abondoned CLTU" << std::endl; + break; } - case(FrameAna_t::FRAME_DIRTY): { - triggerEvent(INVALID_TC_FRAME, FRAME_DIRTY); - sif::warning << "PdecHandler::checkFrameAna: Frame dirty" << std::endl; - break; + case (FrameAna_t::FRAME_DIRTY): { + triggerEvent(INVALID_TC_FRAME, FRAME_DIRTY); + sif::warning << "PdecHandler::checkFrameAna: Frame dirty" << std::endl; + break; } - case(FrameAna_t::FRAME_ILLEGAL): { - sif::warning << "PdecHandler::checkFrameAna: Frame illegal for one reason" << std::endl; - handleIReason(pdecFar, FRAME_ILLEGAL_ONE_REASON); - break; + case (FrameAna_t::FRAME_ILLEGAL): { + sif::warning << "PdecHandler::checkFrameAna: Frame illegal for one reason" << std::endl; + handleIReason(pdecFar, FRAME_ILLEGAL_ONE_REASON); + break; } - case(FrameAna_t::FRAME_ILLEGAL_MULTI_REASON): { - sif::warning << "PdecHandler::checkFrameAna: Frame illegal for multiple reasons" - << std::endl; - handleIReason(pdecFar, FRAME_ILLEGAL_MULTIPLE_REASONS); - break; + case (FrameAna_t::FRAME_ILLEGAL_MULTI_REASON): { + sif::warning << "PdecHandler::checkFrameAna: Frame illegal for multiple reasons" << std::endl; + handleIReason(pdecFar, FRAME_ILLEGAL_MULTIPLE_REASONS); + break; } - case(FrameAna_t::AD_DISCARDED_LOCKOUT): { - triggerEvent(INVALID_TC_FRAME, AD_DISCARDED_LOCKOUT); - sif::warning << "PdecHandler::checkFrameAna: AD frame discarded because of lockout" - << std::endl; - break; + case (FrameAna_t::AD_DISCARDED_LOCKOUT): { + triggerEvent(INVALID_TC_FRAME, AD_DISCARDED_LOCKOUT); + sif::warning << "PdecHandler::checkFrameAna: AD frame discarded because of lockout" + << std::endl; + break; } - case(FrameAna_t::AD_DISCARDED_WAIT): { - triggerEvent(INVALID_TC_FRAME, AD_DISCARDED_LOCKOUT); - sif::warning << "PdecHandler::checkFrameAna: AD frame discarded because of wait" - << std::endl; - break; + case (FrameAna_t::AD_DISCARDED_WAIT): { + triggerEvent(INVALID_TC_FRAME, AD_DISCARDED_LOCKOUT); + sif::warning << "PdecHandler::checkFrameAna: AD frame discarded because of wait" << std::endl; + break; } - case(FrameAna_t::AD_DISCARDED_NS_VR): { - triggerEvent(INVALID_TC_FRAME, AD_DISCARDED_NS_VS); - sif::warning << "PdecHandler::checkFrameAna: AD frame discarded because N(S) or V(R)" - << std::endl; - break; + case (FrameAna_t::AD_DISCARDED_NS_VR): { + triggerEvent(INVALID_TC_FRAME, AD_DISCARDED_NS_VS); + sif::warning << "PdecHandler::checkFrameAna: AD frame discarded because N(S) or V(R)" + << std::endl; + break; } - case(FrameAna_t::FRAME_ACCEPTED): { + case (FrameAna_t::FRAME_ACCEPTED): { #if OBSW_DEBUG_PDEC_HANDLER == 1 - sif::info << "PdecHandler::checkFrameAna: Accepted TC frame" << std::endl; + sif::info << "PdecHandler::checkFrameAna: Accepted TC frame" << std::endl; #endif - frameValid = true; - break; + frameValid = true; + break; } default: { - sif::debug << "PdecHandler::checkFrameAna: Invalid frame analysis report" << std::endl; - break; + sif::debug << "PdecHandler::checkFrameAna: Invalid frame analysis report" << std::endl; + break; } - } - return frameValid; + } + return frameValid; } void PdecHandler::handleIReason(uint32_t pdecFar, ReturnValue_t parameter1) { - IReason_t ireason = static_cast((pdecFar & IREASON_MASK) >> IREASON_POSITION); - switch(ireason) { - case(IReason_t::NO_REPORT): { - triggerEvent(INVALID_TC_FRAME, parameter1, NO_REPORT); - sif::info << "PdecHandler::handleIReason: No illegal report" << std::endl; - break; + IReason_t ireason = static_cast((pdecFar & IREASON_MASK) >> IREASON_POSITION); + switch (ireason) { + case (IReason_t::NO_REPORT): { + triggerEvent(INVALID_TC_FRAME, parameter1, NO_REPORT); + sif::info << "PdecHandler::handleIReason: No illegal report" << std::endl; + break; } - case(IReason_t::ERROR_VERSION_NUMBER): { - triggerEvent(INVALID_TC_FRAME, parameter1, ERROR_VERSION_NUMBER); - sif::info << "PdecHandler::handleIReason: Error in version number and reserved A and B " + case (IReason_t::ERROR_VERSION_NUMBER): { + triggerEvent(INVALID_TC_FRAME, parameter1, ERROR_VERSION_NUMBER); + sif::info << "PdecHandler::handleIReason: Error in version number and reserved A and B " << "fields" << std::endl; - break; + break; } - case(IReason_t::ILLEGAL_COMBINATION): { - triggerEvent(INVALID_TC_FRAME, parameter1, ILLEGAL_COMBINATION); - sif::info << "PdecHandler::handleIReason: Illegal combination (AC) of bypass and control " + case (IReason_t::ILLEGAL_COMBINATION): { + triggerEvent(INVALID_TC_FRAME, parameter1, ILLEGAL_COMBINATION); + sif::info << "PdecHandler::handleIReason: Illegal combination (AC) of bypass and control " << "command flags" << std::endl; - break; + break; } - case(IReason_t::INVALID_SC_ID): { - triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_SC_ID); - sif::info << "PdecHandler::handleIReason: Invalid spacecraft identifier " << std::endl; - break; + case (IReason_t::INVALID_SC_ID): { + triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_SC_ID); + sif::info << "PdecHandler::handleIReason: Invalid spacecraft identifier " << std::endl; + break; } - case(IReason_t::INVALID_VC_ID_MSB): { - triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_VC_ID_MSB); - sif::info << "PdecHandler::handleIReason: VC identifier bit 0 to 4 did not match " + case (IReason_t::INVALID_VC_ID_MSB): { + triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_VC_ID_MSB); + sif::info << "PdecHandler::handleIReason: VC identifier bit 0 to 4 did not match " << std::endl; - break; + break; } - case(IReason_t::INVALID_VC_ID_LSB): { - triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_VC_ID_LSB); - sif::info << "PdecHandler::handleIReason: VC identifier bit 5 did not match " << std::endl; - break; + case (IReason_t::INVALID_VC_ID_LSB): { + triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_VC_ID_LSB); + sif::info << "PdecHandler::handleIReason: VC identifier bit 5 did not match " << std::endl; + break; } - case(IReason_t::NS_NOT_ZERO): { - triggerEvent(INVALID_TC_FRAME, parameter1, NS_NOT_ZERO); - sif::info << "PdecHandler::handleIReason: N(S) of BC or BD frame not set to all zeros" + case (IReason_t::NS_NOT_ZERO): { + triggerEvent(INVALID_TC_FRAME, parameter1, NS_NOT_ZERO); + sif::info << "PdecHandler::handleIReason: N(S) of BC or BD frame not set to all zeros" << std::endl; - break; + break; } - case(IReason_t::INCORRECT_BC_CC): { - triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_BC_CC); - sif::info << "PdecHandler::handleIReason: Invalid BC control command format" << std::endl; - break; + case (IReason_t::INCORRECT_BC_CC): { + triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_BC_CC); + sif::info << "PdecHandler::handleIReason: Invalid BC control command format" << std::endl; + break; } default: { - sif::info << "PdecHandler::handleIReason: Invalid reason id" << std::endl; - break; - } + sif::info << "PdecHandler::handleIReason: Invalid reason id" << std::endl; + break; } + } } void PdecHandler::handleNewTc() { - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = RETURN_OK; - uint32_t tcLength = 0; - result = readTc(tcLength); - if (result != RETURN_OK) { - return; - } + uint32_t tcLength = 0; + result = readTc(tcLength); + if (result != RETURN_OK) { + return; + } #if OBSW_DEBUG_PDEC_HANDLER == 1 - unsigned int mapId = tcSegment[0] & MAP_ID_MASK; - sif::info << "PdecHandler::handleNewTc: Received TC segment with map ID " << mapId - << std::endl; - printTC(tcLength); + unsigned int mapId = tcSegment[0] & MAP_ID_MASK; + sif::info << "PdecHandler::handleNewTc: Received TC segment with map ID " << mapId << std::endl; + printTC(tcLength); #endif /* OBSW_DEBUG_PDEC_HANDLER */ - store_address_t storeId; - result = tcStore->addData(&storeId, tcSegment + 1, tcLength - 1); - if (result != RETURN_OK) { - sif::warning << "PdecHandler::handleNewTc: Failed to add received space packet to store" - << std::endl; - return; - } - - TmTcMessage message(storeId); - - result = MessageQueueSenderIF::sendMessage(tcDestination->getRequestQueue(), &message); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "PdecHandler::handleNewTc: Failed to send message to TC destination" - << std::endl; - tcStore->deleteData(storeId); - return; - } - + store_address_t storeId; + result = tcStore->addData(&storeId, tcSegment + 1, tcLength - 1); + if (result != RETURN_OK) { + sif::warning << "PdecHandler::handleNewTc: Failed to add received space packet to store" + << std::endl; return; + } + + TmTcMessage message(storeId); + + result = MessageQueueSenderIF::sendMessage(tcDestination->getRequestQueue(), &message); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "PdecHandler::handleNewTc: Failed to send message to TC destination" + << std::endl; + tcStore->deleteData(storeId); + return; + } + + return; } ReturnValue_t PdecHandler::readTc(uint32_t& tcLength) { - uint32_t tcOffset = (*(registerBaseAddress + PDEC_BPTR_OFFSET) - PHYSICAL_RAM_BASE_ADDRESS) / 4; + uint32_t tcOffset = (*(registerBaseAddress + PDEC_BPTR_OFFSET) - PHYSICAL_RAM_BASE_ADDRESS) / 4; #if OBSW_DEBUG_PDEC_HANDLER == 1 - sif::debug << "PdecHandler::readTc: TC offset: 0x" << std::hex << tcOffset << std::endl; + sif::debug << "PdecHandler::readTc: TC offset: 0x" << std::hex << tcOffset << std::endl; #endif /* OBSW_DEBUG_PDEC_HANDLER */ - tcLength = *(registerBaseAddress + PDEC_SLEN_OFFSET); + tcLength = *(registerBaseAddress + PDEC_SLEN_OFFSET); #if OBSW_DEBUG_PDEC_HANDLER == 1 - sif::debug << "PdecHandler::readTc: TC segment length: " << std::dec << tcLength << std::endl; + sif::debug << "PdecHandler::readTc: TC segment length: " << std::dec << tcLength << std::endl; #endif /* OBSW_DEBUG_PDEC_HANDLER */ - if (tcLength > MAX_TC_SEGMENT_SIZE) { - sif::warning << "PdecHandler::handleNewTc: Read invalid TC length from PDEC register" - << std::endl; - return RETURN_FAILED; + if (tcLength > MAX_TC_SEGMENT_SIZE) { + sif::warning << "PdecHandler::handleNewTc: Read invalid TC length from PDEC register" + << std::endl; + return RETURN_FAILED; + } + + uint32_t idx = 0; + uint32_t tcData = 0; + for (idx = 0; idx <= tcLength; idx = idx + 4) { + tcData = *(ramBaseAddress + tcOffset + idx / 4); + if (idx == 0) { + tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); + tcSegment[idx + 1] = static_cast((tcData >> 8) & 0xFF); + tcSegment[idx + 2] = static_cast(tcData & 0xFF); + } else if (tcLength - idx + 1 == 3) { + tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); + tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); + tcSegment[idx + 1] = static_cast((tcData >> 8) & 0xFF); + } else if (tcLength - idx + 1 == 2) { + tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); + tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); + } else if (tcLength - idx + 1 == 1) { + tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); + } else { + tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); + tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); + tcSegment[idx + 1] = static_cast((tcData >> 8) & 0xFF); + tcSegment[idx + 2] = static_cast(tcData & 0xFF); } + } - uint32_t idx = 0; - uint32_t tcData = 0; - for (idx = 0; idx <= tcLength; idx = idx + 4) { - tcData = *(ramBaseAddress + tcOffset + idx / 4); - if (idx == 0) { - tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); - tcSegment[idx + 1] = static_cast((tcData >> 8) & 0xFF); - tcSegment[idx + 2] = static_cast(tcData & 0xFF); - } - else if (tcLength - idx + 1 == 3) { - tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); - tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); - tcSegment[idx + 1] = static_cast((tcData >> 8) & 0xFF); - } - else if (tcLength - idx + 1 == 2) { - tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); - tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); - } - else if (tcLength - idx + 1 == 1) { - tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); - } - else { - tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); - tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); - tcSegment[idx + 1] = static_cast((tcData >> 8) & 0xFF); - tcSegment[idx + 2] = static_cast(tcData & 0xFF); - } - } + // Backend buffer is handled back to PDEC3 + *(registerBaseAddress + PDEC_BFREE_OFFSET) = 0; - // Backend buffer is handled back to PDEC3 - *(registerBaseAddress + PDEC_BFREE_OFFSET) = 0; - - return RETURN_OK; + return RETURN_OK; } void PdecHandler::printTC(uint32_t tcLength) { - std::stringstream tcSegmentStream; - tcSegmentStream << "TC segment data: 0x"; - for (uint32_t idx = 0; idx < tcLength; idx++) { - tcSegmentStream << std::setfill('0') << std::setw(2) << std::hex - << static_cast(tcSegment[idx]); - } - sif::info << tcSegmentStream.str() << std::endl; + std::stringstream tcSegmentStream; + tcSegmentStream << "TC segment data: 0x"; + for (uint32_t idx = 0; idx < tcLength; idx++) { + tcSegmentStream << std::setfill('0') << std::setw(2) << std::hex + << static_cast(tcSegment[idx]); + } + sif::info << tcSegmentStream.str() << std::endl; } uint8_t PdecHandler::calcMapAddrEntry(uint8_t moduleId) { - uint8_t lutEntry = 0; - uint8_t parity = getOddParity(moduleId | (1 << VALID_POSITION)); - lutEntry = (parity << PARITY_POSITION) | (1 << VALID_POSITION) | moduleId; - return lutEntry; + uint8_t lutEntry = 0; + uint8_t parity = getOddParity(moduleId | (1 << VALID_POSITION)); + lutEntry = (parity << PARITY_POSITION) | (1 << VALID_POSITION) | moduleId; + return lutEntry; } uint8_t PdecHandler::getOddParity(uint8_t number) { - uint8_t parityBit = 0; - uint8_t countBits = 0; - for (unsigned int idx = 0; idx < sizeof(number) * 8; idx++) { - countBits += (number >> idx) & 0x1; - } - parityBit = ~(countBits & 0x1) & 0x1; - return parityBit; + uint8_t parityBit = 0; + uint8_t countBits = 0; + for (unsigned int idx = 0; idx < sizeof(number) * 8; idx++) { + countBits += (number >> idx) & 0x1; + } + parityBit = ~(countBits & 0x1) & 0x1; + return parityBit; } -uint32_t PdecHandler::getClcw() { - return *(registerBaseAddress + PDEC_CLCW_OFFSET); -} +uint32_t PdecHandler::getClcw() { return *(registerBaseAddress + PDEC_CLCW_OFFSET); } -uint32_t PdecHandler::getPdecMon() { - return *(registerBaseAddress + PDEC_MON_OFFSET); -} +uint32_t PdecHandler::getPdecMon() { return *(registerBaseAddress + PDEC_MON_OFFSET); } void PdecHandler::printClcw() { - uint32_t clcw = getClcw(); - uint8_t type = static_cast((clcw >> 31) & 0x1); - uint8_t versionNo = static_cast((clcw >> 29) & 0x3); - uint8_t status = static_cast((clcw >> 26) & 0x7); - uint8_t cop = static_cast((clcw >> 24) & 0x3); - uint8_t vcId = static_cast((clcw >> 18) & 0x3F); - uint8_t noRf = static_cast((clcw >> 15) & 0x1); - uint8_t noBitLock = static_cast((clcw >> 14) & 0x1); - uint8_t lockoutFlag = static_cast((clcw >> 13) & 0x1); - uint8_t waitFlag = static_cast((clcw >> 12) & 0x1); - uint8_t retransmitFlag = static_cast((clcw >> 11) & 0x1); - uint8_t farmBcnt = static_cast((clcw >> 9) & 0x3); - // Expected frame sequence number in te next AD frame - uint8_t repValue = static_cast(clcw & 0xFF); - sif::info << std::setw(30) << std::left << "CLCW type: " << std::hex - << "0x" << static_cast(type) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW version no: " << std::hex - << "0x" << static_cast(versionNo) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW status: " << std::hex - << "0x" << static_cast(status) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW COP: " << std::hex - << "0x" << static_cast(cop) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW virtual channel ID: " << std::hex - << "0x" << static_cast(vcId) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW no RF: " << std::hex - << "0x" << static_cast(noRf) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW no bit lock: " << std::hex - << "0x" << static_cast(noBitLock) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW lockout flag: " << std::hex - << "0x" << static_cast(lockoutFlag) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW wait flag: " << std::hex - << "0x" << static_cast(waitFlag) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW retransmit flag: " << std::hex - << "0x" << static_cast(retransmitFlag) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW FARM B count: " << std::hex - << "0x" << static_cast(farmBcnt) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW rep value: " << std::hex - << "0x" << static_cast(repValue) << std::endl; + uint32_t clcw = getClcw(); + uint8_t type = static_cast((clcw >> 31) & 0x1); + uint8_t versionNo = static_cast((clcw >> 29) & 0x3); + uint8_t status = static_cast((clcw >> 26) & 0x7); + uint8_t cop = static_cast((clcw >> 24) & 0x3); + uint8_t vcId = static_cast((clcw >> 18) & 0x3F); + uint8_t noRf = static_cast((clcw >> 15) & 0x1); + uint8_t noBitLock = static_cast((clcw >> 14) & 0x1); + uint8_t lockoutFlag = static_cast((clcw >> 13) & 0x1); + uint8_t waitFlag = static_cast((clcw >> 12) & 0x1); + uint8_t retransmitFlag = static_cast((clcw >> 11) & 0x1); + uint8_t farmBcnt = static_cast((clcw >> 9) & 0x3); + // Expected frame sequence number in te next AD frame + uint8_t repValue = static_cast(clcw & 0xFF); + sif::info << std::setw(30) << std::left << "CLCW type: " << std::hex << "0x" + << static_cast(type) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW version no: " << std::hex << "0x" + << static_cast(versionNo) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW status: " << std::hex << "0x" + << static_cast(status) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW COP: " << std::hex << "0x" + << static_cast(cop) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW virtual channel ID: " << std::hex << "0x" + << static_cast(vcId) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW no RF: " << std::hex << "0x" + << static_cast(noRf) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW no bit lock: " << std::hex << "0x" + << static_cast(noBitLock) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW lockout flag: " << std::hex << "0x" + << static_cast(lockoutFlag) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW wait flag: " << std::hex << "0x" + << static_cast(waitFlag) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW retransmit flag: " << std::hex << "0x" + << static_cast(retransmitFlag) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW FARM B count: " << std::hex << "0x" + << static_cast(farmBcnt) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW rep value: " << std::hex << "0x" + << static_cast(repValue) << std::endl; } void PdecHandler::printPdecMon() { - uint32_t pdecMon = getPdecMon(); - uint32_t tc0ChannelStatus = (pdecMon & TC0_STATUS_MASK) >> TC0_STATUS_POS; - uint32_t tc1ChannelStatus = (pdecMon & TC1_STATUS_MASK) >> TC1_STATUS_POS; - uint32_t tc2ChannelStatus = (pdecMon & TC2_STATUS_MASK) >> TC2_STATUS_POS; - uint32_t tc3ChannelStatus = (pdecMon & TC3_STATUS_MASK) >> TC3_STATUS_POS; - uint32_t tc4ChannelStatus = (pdecMon & TC4_STATUS_MASK) >> TC4_STATUS_POS; - uint32_t tc5ChannelStatus = (pdecMon & TC5_STATUS_MASK) >> TC5_STATUS_POS; - uint32_t lock = (pdecMon & LOCK_MASK) >> LOCK_POS; - sif::info << std::setw(30) << std::left << "TC0 status: " << getMonStatusString(tc0ChannelStatus) << std::endl; - sif::info << std::setw(30) << std::left << "TC1 status: " << getMonStatusString(tc1ChannelStatus) << std::endl; - sif::info << std::setw(30) << std::left << "TC2 status: " << getMonStatusString(tc2ChannelStatus) << std::endl; - sif::info << std::setw(30) << std::left << "TC3 status: " << getMonStatusString(tc3ChannelStatus) << std::endl; - sif::info << std::setw(30) << std::left << "TC4 status: " << getMonStatusString(tc4ChannelStatus) << std::endl; - sif::info << std::setw(30) << std::left << "TC5 status: " << getMonStatusString(tc5ChannelStatus) << std::endl; - sif::info << std::setw(30) << std::left << "Start sequence lock: " << lock << std::endl; + uint32_t pdecMon = getPdecMon(); + uint32_t tc0ChannelStatus = (pdecMon & TC0_STATUS_MASK) >> TC0_STATUS_POS; + uint32_t tc1ChannelStatus = (pdecMon & TC1_STATUS_MASK) >> TC1_STATUS_POS; + uint32_t tc2ChannelStatus = (pdecMon & TC2_STATUS_MASK) >> TC2_STATUS_POS; + uint32_t tc3ChannelStatus = (pdecMon & TC3_STATUS_MASK) >> TC3_STATUS_POS; + uint32_t tc4ChannelStatus = (pdecMon & TC4_STATUS_MASK) >> TC4_STATUS_POS; + uint32_t tc5ChannelStatus = (pdecMon & TC5_STATUS_MASK) >> TC5_STATUS_POS; + uint32_t lock = (pdecMon & LOCK_MASK) >> LOCK_POS; + sif::info << std::setw(30) << std::left << "TC0 status: " << getMonStatusString(tc0ChannelStatus) + << std::endl; + sif::info << std::setw(30) << std::left << "TC1 status: " << getMonStatusString(tc1ChannelStatus) + << std::endl; + sif::info << std::setw(30) << std::left << "TC2 status: " << getMonStatusString(tc2ChannelStatus) + << std::endl; + sif::info << std::setw(30) << std::left << "TC3 status: " << getMonStatusString(tc3ChannelStatus) + << std::endl; + sif::info << std::setw(30) << std::left << "TC4 status: " << getMonStatusString(tc4ChannelStatus) + << std::endl; + sif::info << std::setw(30) << std::left << "TC5 status: " << getMonStatusString(tc5ChannelStatus) + << std::endl; + sif::info << std::setw(30) << std::left << "Start sequence lock: " << lock << std::endl; } std::string PdecHandler::getMonStatusString(uint32_t status) { - switch(status) { - case TC_CHANNEL_INACTIVE: - return std::string("inactive"); - case TC_CHANNEL_ACTIVE: - return std::string("active"); - case TC_CHANNEL_TIMEDOUT: - return std::string("timed out"); - default: - sif::warning << "PdecHandler::getMonStatusString: Invalid status" << std::endl; - return std::string(); - break; - } -} - - -ReturnValue_t PdecHandler::executeAction(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { - switch(actionId) { - case PRINT_CLCW: - printClcw(); - return EXECUTION_FINISHED; - case PRINT_PDEC_MON: - printPdecMon(); - return EXECUTION_FINISHED; + switch (status) { + case TC_CHANNEL_INACTIVE: + return std::string("inactive"); + case TC_CHANNEL_ACTIVE: + return std::string("active"); + case TC_CHANNEL_TIMEDOUT: + return std::string("timed out"); default: - return COMMAND_NOT_IMPLEMENTED; - } + sif::warning << "PdecHandler::getMonStatusString: Invalid status" << std::endl; + return std::string(); + break; + } +} + +ReturnValue_t PdecHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) { + switch (actionId) { + case PRINT_CLCW: + printClcw(); + return EXECUTION_FINISHED; + case PRINT_PDEC_MON: + printPdecMon(); + return EXECUTION_FINISHED; + default: + return COMMAND_NOT_IMPLEMENTED; + } } diff --git a/linux/obc/PdecHandler.h b/linux/obc/PdecHandler.h index 8c8e8d9b..2125800f 100644 --- a/linux/obc/PdecHandler.h +++ b/linux/obc/PdecHandler.h @@ -3,15 +3,15 @@ #include "OBSWConfig.h" #include "PdecConfig.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" -#include "fsfw_hal/common/gpio/gpioDefinitions.h" -#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" -#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" -#include "fsfw/storagemanager/StorageManagerIF.h" -#include "fsfw/objectmanager/SystemObject.h" -#include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw/action/ActionHelper.h" #include "fsfw/action/HasActionsIF.h" +#include "fsfw/objectmanager/SystemObject.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/storagemanager/StorageManagerIF.h" +#include "fsfw/tasks/ExecutableObjectIF.h" +#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" +#include "fsfw_hal/common/gpio/gpioDefinitions.h" +#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" /** * @brief This class controls the PDEC IP Core implemented in the programmable logic of the @@ -35,386 +35,381 @@ class PdecHandler : public SystemObject, public ExecutableObjectIF, public HasReturnvaluesIF, public HasActionsIF { + public: + /** + * @brief Constructor + * @param objectId Object ID of PDEC handler system object + * @param tcDestinationId Object ID of object responsible for processing TCs. + * @param gpioComIF Pointer to GPIO interace responsible for driving GPIOs. + * @param pdecReset GPIO ID of GPIO connected to the reset signal of the PDEC. + * @param uioConfigMemory String of uio device file same mapped to the PDEC memory space + * @param uioregsiters String of uio device file same mapped to the PDEC register space + */ + PdecHandler(object_id_t objectId, object_id_t tcDestinationId, LinuxLibgpioIF* gpioComIF, + gpioId_t pdecReset, std::string uioConfigMemory, std::string uioRamMemory, + std::string uioRegisters); -public: - /** - * @brief Constructor - * @param objectId Object ID of PDEC handler system object - * @param tcDestinationId Object ID of object responsible for processing TCs. - * @param gpioComIF Pointer to GPIO interace responsible for driving GPIOs. - * @param pdecReset GPIO ID of GPIO connected to the reset signal of the PDEC. - * @param uioConfigMemory String of uio device file same mapped to the PDEC memory space - * @param uioregsiters String of uio device file same mapped to the PDEC register space - */ - PdecHandler(object_id_t objectId, object_id_t tcDestinationId, LinuxLibgpioIF* gpioComIF, - gpioId_t pdecReset, std::string uioConfigMemory, std::string uioRamMemory, - std::string uioRegisters); + virtual ~PdecHandler(); - virtual ~PdecHandler(); + ReturnValue_t performOperation(uint8_t operationCode = 0); - ReturnValue_t performOperation(uint8_t operationCode = 0); + ReturnValue_t initialize() override; - ReturnValue_t initialize() override; + MessageQueueId_t getCommandQueue() const; - MessageQueueId_t getCommandQueue() const; + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) override; - ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size) override; + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PDEC_HANDLER; - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PDEC_HANDLER; + //! [EXPORT] : [COMMENT] Frame acceptance report signals an invalid frame + //! P1: The frame analysis information (FrameAna field of PDEC_FAR register) + //! P2: When frame declared illegal this parameter this parameter gives information about the + //! reason (IReason field of the PDEC_FAR register) + static const Event INVALID_TC_FRAME = MAKE_EVENT(1, severity::HIGH); + //! [EXPORT] : [COMMENT] Read invalid FAR from PDEC after startup + static const Event INVALID_FAR = MAKE_EVENT(2, severity::HIGH); + //! [EXPORT] : [COMMENT] Carrier lock detected + static const Event CARRIER_LOCK = MAKE_EVENT(3, severity::INFO); + //! [EXPORT] : [COMMENT] Bit lock detected (data valid) + static const Event BIT_LOCK_PDEC = MAKE_EVENT(4, severity::INFO); - //! [EXPORT] : [COMMENT] Frame acceptance report signals an invalid frame - //! P1: The frame analysis information (FrameAna field of PDEC_FAR register) - //! P2: When frame declared illegal this parameter this parameter gives information about the reason (IReason field of the PDEC_FAR register) - static const Event INVALID_TC_FRAME = MAKE_EVENT(1, severity::HIGH); - //! [EXPORT] : [COMMENT] Read invalid FAR from PDEC after startup - static const Event INVALID_FAR = MAKE_EVENT(2, severity::HIGH); - //! [EXPORT] : [COMMENT] Carrier lock detected - static const Event CARRIER_LOCK = MAKE_EVENT(3, severity::INFO); - //! [EXPORT] : [COMMENT] Bit lock detected (data valid) - static const Event BIT_LOCK_PDEC = MAKE_EVENT(4, severity::INFO); + private: + static const uint8_t INTERFACE_ID = CLASS_ID::PDEC_HANDLER; -private: + static const ReturnValue_t ABANDONED_CLTU = MAKE_RETURN_CODE(0xA0); + static const ReturnValue_t FRAME_DIRTY = MAKE_RETURN_CODE(0xA1); + static const ReturnValue_t FRAME_ILLEGAL_ONE_REASON = MAKE_RETURN_CODE(0xA2); + static const ReturnValue_t FRAME_ILLEGAL_MULTIPLE_REASONS = MAKE_RETURN_CODE(0xA2); + static const ReturnValue_t AD_DISCARDED_LOCKOUT = MAKE_RETURN_CODE(0xA3); + static const ReturnValue_t AD_DISCARDED_WAIT = MAKE_RETURN_CODE(0xA4); + static const ReturnValue_t AD_DISCARDED_NS_VS = MAKE_RETURN_CODE(0xA5); - static const uint8_t INTERFACE_ID = CLASS_ID::PDEC_HANDLER; + //! [EXPORT] : [COMMENT] Received action message with unknown action id + static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xB0); - static const ReturnValue_t ABANDONED_CLTU = MAKE_RETURN_CODE(0xA0); - static const ReturnValue_t FRAME_DIRTY = MAKE_RETURN_CODE(0xA1); - static const ReturnValue_t FRAME_ILLEGAL_ONE_REASON = MAKE_RETURN_CODE(0xA2); - static const ReturnValue_t FRAME_ILLEGAL_MULTIPLE_REASONS = MAKE_RETURN_CODE(0xA2); - static const ReturnValue_t AD_DISCARDED_LOCKOUT = MAKE_RETURN_CODE(0xA3); - static const ReturnValue_t AD_DISCARDED_WAIT = MAKE_RETURN_CODE(0xA4); - static const ReturnValue_t AD_DISCARDED_NS_VS = MAKE_RETURN_CODE(0xA5); + static const ReturnValue_t NO_REPORT = MAKE_RETURN_CODE(0xA6); + //! Error in version number and reserved A and B fields + static const ReturnValue_t ERROR_VERSION_NUMBER = MAKE_RETURN_CODE(0xA7); + //! Illegal combination of bypass and control command flag + static const ReturnValue_t ILLEGAL_COMBINATION = MAKE_RETURN_CODE(0xA8); + //! Spacecraft identifier did not match + static const ReturnValue_t INVALID_SC_ID = MAKE_RETURN_CODE(0xA9); + //! VC identifier bits 0 to 4 did not match + static const ReturnValue_t INVALID_VC_ID_MSB = MAKE_RETURN_CODE(0xAA); + //! VC identifier bit 5 did not match + static const ReturnValue_t INVALID_VC_ID_LSB = MAKE_RETURN_CODE(0xAB); + //! N(S) of BC or BD frame not set to all zeros + static const ReturnValue_t NS_NOT_ZERO = MAKE_RETURN_CODE(0xAC); + //! Invalid BC control command + static const ReturnValue_t INVALID_BC_CC = MAKE_RETURN_CODE(0xAE); - //! [EXPORT] : [COMMENT] Received action message with unknown action id - static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xB0); + static const uint32_t QUEUE_SIZE = common::CCSDS_HANDLER_QUEUE_SIZE; - static const ReturnValue_t NO_REPORT = MAKE_RETURN_CODE(0xA6); - //! Error in version number and reserved A and B fields - static const ReturnValue_t ERROR_VERSION_NUMBER = MAKE_RETURN_CODE(0xA7); - //! Illegal combination of bypass and control command flag - static const ReturnValue_t ILLEGAL_COMBINATION = MAKE_RETURN_CODE(0xA8); - //! Spacecraft identifier did not match - static const ReturnValue_t INVALID_SC_ID = MAKE_RETURN_CODE(0xA9); - //! VC identifier bits 0 to 4 did not match - static const ReturnValue_t INVALID_VC_ID_MSB = MAKE_RETURN_CODE(0xAA); - //! VC identifier bit 5 did not match - static const ReturnValue_t INVALID_VC_ID_LSB = MAKE_RETURN_CODE(0xAB); - //! N(S) of BC or BD frame not set to all zeros - static const ReturnValue_t NS_NOT_ZERO = MAKE_RETURN_CODE(0xAC); - //! Invalid BC control command - static const ReturnValue_t INVALID_BC_CC = MAKE_RETURN_CODE(0xAE); + // Action IDs + static const ActionId_t PRINT_CLCW = 0; + // Print PDEC monitor register + static const ActionId_t PRINT_PDEC_MON = 1; - static const uint32_t QUEUE_SIZE = common::CCSDS_HANDLER_QUEUE_SIZE; + static const uint8_t STAT_POSITION = 31; + static const uint8_t FRAME_ANA_POSITION = 28; + static const uint8_t IREASON_POSITION = 25; - // Action IDs - static const ActionId_t PRINT_CLCW = 0; - // Print PDEC monitor register - static const ActionId_t PRINT_PDEC_MON = 1; + static const uint8_t NEW_FAR_RECEIVED = 0; - static const uint8_t STAT_POSITION = 31; - static const uint8_t FRAME_ANA_POSITION = 28; - static const uint8_t IREASON_POSITION = 25; + static const uint32_t FRAME_ANA_MASK = 0x70000000; + static const uint32_t IREASON_MASK = 0x0E000000; - static const uint8_t NEW_FAR_RECEIVED = 0; + static const uint32_t TC_CHANNEL_INACTIVE = 0x0; + static const uint32_t TC_CHANNEL_ACTIVE = 0x1; + static const uint32_t TC_CHANNEL_TIMEDOUT = 0x2; - static const uint32_t FRAME_ANA_MASK = 0x70000000; - static const uint32_t IREASON_MASK = 0x0E000000; + static const uint32_t TC0_STATUS_MASK = 0x3; + static const uint32_t TC1_STATUS_MASK = 0xC; + static const uint32_t TC2_STATUS_MASK = 0x300; + static const uint32_t TC3_STATUS_MASK = 0xC00; + static const uint32_t TC4_STATUS_MASK = 0x30000; + static const uint32_t TC5_STATUS_MASK = 0xc00000; + // Lock register set to 1 when start sequence has been found (CLTU is beeing processed) + static const uint32_t LOCK_MASK = 0xc00000; - static const uint32_t TC_CHANNEL_INACTIVE = 0x0; - static const uint32_t TC_CHANNEL_ACTIVE = 0x1; - static const uint32_t TC_CHANNEL_TIMEDOUT = 0x2; + static const uint32_t TC0_STATUS_POS = 0; + static const uint32_t TC1_STATUS_POS = 2; + static const uint32_t TC2_STATUS_POS = 4; + static const uint32_t TC3_STATUS_POS = 6; + static const uint32_t TC4_STATUS_POS = 8; + static const uint32_t TC5_STATUS_POS = 10; + // Lock register set to 1 when start sequence has been found (CLTU is beeing processed) + static const uint32_t LOCK_POS = 12; - static const uint32_t TC0_STATUS_MASK = 0x3; - static const uint32_t TC1_STATUS_MASK = 0xC; - static const uint32_t TC2_STATUS_MASK = 0x300; - static const uint32_t TC3_STATUS_MASK = 0xC00; - static const uint32_t TC4_STATUS_MASK = 0x30000; - static const uint32_t TC5_STATUS_MASK = 0xc00000; - // Lock register set to 1 when start sequence has been found (CLTU is beeing processed) - static const uint32_t LOCK_MASK = 0xc00000; - - static const uint32_t TC0_STATUS_POS = 0; - static const uint32_t TC1_STATUS_POS = 2; - static const uint32_t TC2_STATUS_POS = 4; - static const uint32_t TC3_STATUS_POS = 6; - static const uint32_t TC4_STATUS_POS = 8; - static const uint32_t TC5_STATUS_POS = 10; - // Lock register set to 1 when start sequence has been found (CLTU is beeing processed) - static const uint32_t LOCK_POS = 12; - - /** - * UIO is 4 byte aligned. Thus offset is calculated with "true offset" / 4 - * Example: PDEC_FAR = 0x2840 => Offset in virtual address space is 0xA10 - */ - static const uint32_t PDEC_FAR_OFFSET = 0xA10; - static const uint32_t PDEC_CLCW_OFFSET = 0xA12; - static const uint32_t PDEC_BFREE_OFFSET = 0xA24; - static const uint32_t PDEC_BPTR_OFFSET = 0xA25; - static const uint32_t PDEC_SLEN_OFFSET = 0xA26; - static const uint32_t PDEC_MON_OFFSET = 0xA27; + /** + * UIO is 4 byte aligned. Thus offset is calculated with "true offset" / 4 + * Example: PDEC_FAR = 0x2840 => Offset in virtual address space is 0xA10 + */ + static const uint32_t PDEC_FAR_OFFSET = 0xA10; + static const uint32_t PDEC_CLCW_OFFSET = 0xA12; + static const uint32_t PDEC_BFREE_OFFSET = 0xA24; + static const uint32_t PDEC_BPTR_OFFSET = 0xA25; + static const uint32_t PDEC_SLEN_OFFSET = 0xA26; + static const uint32_t PDEC_MON_OFFSET = 0xA27; #if BOARD_TE0720 == 1 - static const int CONFIG_MEMORY_MAP_SIZE = 0x400; - static const int RAM_MAP_SIZE = 0x4000; - static const int REGISTER_MAP_SIZE = 0x10000; + static const int CONFIG_MEMORY_MAP_SIZE = 0x400; + static const int RAM_MAP_SIZE = 0x4000; + static const int REGISTER_MAP_SIZE = 0x10000; #else - static const int CONFIG_MEMORY_MAP_SIZE = 0x400; - static const int RAM_MAP_SIZE = 0x4000; - static const int REGISTER_MAP_SIZE = 0x4000; + static const int CONFIG_MEMORY_MAP_SIZE = 0x400; + static const int RAM_MAP_SIZE = 0x4000; + static const int REGISTER_MAP_SIZE = 0x4000; #endif /* BOARD_TE0720 == 1 */ - // 0x200 / 4 = 0x80 - static const uint32_t FRAME_HEADER_OFFSET = 0x80; + // 0x200 / 4 = 0x80 + static const uint32_t FRAME_HEADER_OFFSET = 0x80; - static const size_t MAX_TC_SEGMENT_SIZE = 1017; - static const uint8_t MAP_ID_MASK = 0x3F; + static const size_t MAX_TC_SEGMENT_SIZE = 1017; + static const uint8_t MAP_ID_MASK = 0x3F; #if BOARD_TE0720 == 1 - static const uint32_t PHYSICAL_RAM_BASE_ADDRESS = 0x32000000; + static const uint32_t PHYSICAL_RAM_BASE_ADDRESS = 0x32000000; #else - static const uint32_t PHYSICAL_RAM_BASE_ADDRESS = 0x26000000; + static const uint32_t PHYSICAL_RAM_BASE_ADDRESS = 0x26000000; #endif - static const uint32_t MAP_ADDR_LUT_OFFSET = 0xA0; - static const uint32_t MAP_CLK_FREQ_OFFSET = 0x90; + static const uint32_t MAP_ADDR_LUT_OFFSET = 0xA0; + static const uint32_t MAP_CLK_FREQ_OFFSET = 0x90; - static const uint8_t MAX_MAP_ADDR = 63; - // Writing this to the map address in the look up table will invalidate a MAP ID. - static const uint8_t NO_DESTINATION = 0; - static const uint8_t VALID_POSITION = 6; - static const uint8_t PARITY_POSITION = 7; + static const uint8_t MAX_MAP_ADDR = 63; + // Writing this to the map address in the look up table will invalidate a MAP ID. + static const uint8_t NO_DESTINATION = 0; + static const uint8_t VALID_POSITION = 6; + static const uint8_t PARITY_POSITION = 7; - // Expected value stored in FAR register after reset - static const uint32_t FAR_RESET = 0x7FE0; + // Expected value stored in FAR register after reset + static const uint32_t FAR_RESET = 0x7FE0; - static const uint32_t TC_SEGMENT_LEN = 1017; + static const uint32_t TC_SEGMENT_LEN = 1017; - static const uint32_t NO_RF_MASK = 0x8000; - static const uint32_t NO_BITLOCK_MASK = 0x4000; + static const uint32_t NO_RF_MASK = 0x8000; + static const uint32_t NO_BITLOCK_MASK = 0x4000; - /** - * TCs with map addresses (also know as Map IDs) assigned to this channel will be stored in - * the PDEC memory. - */ - static const uint8_t PM_BUFFER = 7; + /** + * TCs with map addresses (also know as Map IDs) assigned to this channel will be stored in + * the PDEC memory. + */ + static const uint8_t PM_BUFFER = 7; - // MAP clock frequency. Must be a value between 1 and 13 otherwise the TC segment will be - // discarded - static const uint8_t MAP_CLK_FREQ = 2; + // MAP clock frequency. Must be a value between 1 and 13 otherwise the TC segment will be + // discarded + static const uint8_t MAP_CLK_FREQ = 2; - enum class FrameAna_t: uint8_t { - ABANDONED_CLTU, - FRAME_DIRTY, - FRAME_ILLEGAL, - FRAME_ILLEGAL_MULTI_REASON, - AD_DISCARDED_LOCKOUT, - AD_DISCARDED_WAIT, - AD_DISCARDED_NS_VR, - FRAME_ACCEPTED - }; + enum class FrameAna_t : uint8_t { + ABANDONED_CLTU, + FRAME_DIRTY, + FRAME_ILLEGAL, + FRAME_ILLEGAL_MULTI_REASON, + AD_DISCARDED_LOCKOUT, + AD_DISCARDED_WAIT, + AD_DISCARDED_NS_VR, + FRAME_ACCEPTED + }; - enum class IReason_t: uint8_t { - NO_REPORT, - ERROR_VERSION_NUMBER, - ILLEGAL_COMBINATION, - INVALID_SC_ID, - INVALID_VC_ID_LSB, - INVALID_VC_ID_MSB, - NS_NOT_ZERO, - INCORRECT_BC_CC - }; + enum class IReason_t : uint8_t { + NO_REPORT, + ERROR_VERSION_NUMBER, + ILLEGAL_COMBINATION, + INVALID_SC_ID, + INVALID_VC_ID_LSB, + INVALID_VC_ID_MSB, + NS_NOT_ZERO, + INCORRECT_BC_CC + }; - enum class State: uint8_t { - INIT, - RUNNING, - WAIT_FOR_RECOVERY - }; + enum class State : uint8_t { INIT, RUNNING, WAIT_FOR_RECOVERY }; - /** - * @brief Reads and handles messages stored in the commandQueue - */ - void readCommandQueue(void); + /** + * @brief Reads and handles messages stored in the commandQueue + */ + 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 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 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 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. - */ - void writePdecConfig(); + /** + * @brief This functions writes the configuration parameters to the configuration + * section of the PDEC. + */ + void writePdecConfig(); - /** - * @brief Reading the FAR resets the set stat flag which signals a new TC. Without clearing - * this flag no new TC will be excepted. After start up the flag is set and needs - * to be reset. - * Stat flag 0 - new TC received - * Stat flag 1 - old TC (ready to receive next TC) - */ - ReturnValue_t resetFarStatFlag(); + /** + * @brief Reading the FAR resets the set stat flag which signals a new TC. Without clearing + * this flag no new TC will be excepted. After start up the flag is set and needs + * to be reset. + * Stat flag 0 - new TC received + * Stat flag 1 - old TC (ready to receive next TC) + */ + ReturnValue_t resetFarStatFlag(); - /** - * @brief Releases the PDEC from reset state. PDEC will start with loading the written - * configuration parameters. - */ - ReturnValue_t releasePdec(); + /** + * @brief Releases the PDEC from reset state. PDEC will start with loading the written + * configuration parameters. + */ + ReturnValue_t releasePdec(); - /** - * @brief Reads the FAR register and checks if a new TC has been received. - */ - bool newTcReceived(); + /** + * @brief Reads the FAR register and checks if a new TC has been received. + */ + bool newTcReceived(); - /** - * @brief Checks if carrier lock or bit lock has been detected and triggers appropriate - * event. - */ - void checkLocks(); + /** + * @brief Checks if carrier lock or bit lock has been detected and triggers appropriate + * event. + */ + void checkLocks(); - /** - * @brief Analyzes the FramAna field (frame analysis data) of a FAR report. - * - * @return True if frame valid, otherwise false. - */ - bool checkFrameAna(uint32_t pdecFar); + /** + * @brief Analyzes the FramAna field (frame analysis data) of a FAR report. + * + * @return True if frame valid, otherwise false. + */ + bool checkFrameAna(uint32_t pdecFar); - /** - * @brief This function handles the IReason field of the frame analysis report. - * - * @details In case frame as been declared illegal for multiple reasons, the reason with the - * lowest value will be shown. - */ - void handleIReason(uint32_t pdecFar, ReturnValue_t parameter1); + /** + * @brief This function handles the IReason field of the frame analysis report. + * + * @details In case frame as been declared illegal for multiple reasons, the reason with the + * lowest value will be shown. + */ + void handleIReason(uint32_t pdecFar, ReturnValue_t parameter1); - /** - * @brief Handles the reception of new TCs. Reads the pointer to the storage location of the - * new TC segment, extracts the PUS packet and forwards the data to the object - * responsible for processing the TC. - */ - void handleNewTc(); + /** + * @brief Handles the reception of new TCs. Reads the pointer to the storage location of the + * new TC segment, extracts the PUS packet and forwards the data to the object + * responsible for processing the TC. + */ + void handleNewTc(); - /** - * @brief Function reads the last received TC segment from the PDEC memory and copies - * the data to the tcSegement array. - * - * @param tcLength The length of the received TC. - * - */ - ReturnValue_t readTc(uint32_t& tcLength); + /** + * @brief Function reads the last received TC segment from the PDEC memory and copies + * the data to the tcSegement array. + * + * @param tcLength The length of the received TC. + * + */ + ReturnValue_t readTc(uint32_t& tcLength); - /** - * @brief Prints the tc segment data - */ - void printTC(uint32_t tcLength); + /** + * @brief Prints the tc segment data + */ + void printTC(uint32_t tcLength); - /** - * @brief This function calculates the entry for the configuration of the MAP ID routing. - * - * @param mapAddr The MAP ID to configure - * @param moduleId The destination module where all TCs with the map id mapAddr will be routed - * to. - * - * @details The PDEC has different modules where the TCs can be routed to. A lookup table is - * used which links the MAP ID field to the destination module. The entry for this - * lookup table is created by this function and must be stored in the configuration - * memory region of the PDEC. The entry has a specific format - */ - uint8_t calcMapAddrEntry(uint8_t moduleId); + /** + * @brief This function calculates the entry for the configuration of the MAP ID routing. + * + * @param mapAddr The MAP ID to configure + * @param moduleId The destination module where all TCs with the map id mapAddr will be routed + * to. + * + * @details The PDEC has different modules where the TCs can be routed to. A lookup table is + * used which links the MAP ID field to the destination module. The entry for this + * lookup table is created by this function and must be stored in the configuration + * memory region of the PDEC. The entry has a specific format + */ + uint8_t calcMapAddrEntry(uint8_t moduleId); - /** - * @brief This functions calculates the odd parity of the bits in number. - * - * @param number The number from which to calculate the odd parity. - */ - uint8_t getOddParity(uint8_t number); + /** + * @brief This functions calculates the odd parity of the bits in number. + * + * @param number The number from which to calculate the odd parity. + */ + uint8_t getOddParity(uint8_t number); - /** - * brief Returns the 32-bit wide communication link control word (CLCW) - */ - uint32_t getClcw(); + /** + * brief Returns the 32-bit wide communication link control word (CLCW) + */ + uint32_t getClcw(); - /** - * @brief Returns the PDEC monitor register content - * - */ - uint32_t getPdecMon(); + /** + * @brief Returns the PDEC monitor register content + * + */ + uint32_t getPdecMon(); - /** - * @brief Reads and prints the CLCW. Can be useful for debugging. - */ - void printClcw(); + /** + * @brief Reads and prints the CLCW. Can be useful for debugging. + */ + void printClcw(); - /** - * @brief Prints monitor register information to debug console. - */ - void printPdecMon(); + /** + * @brief Prints monitor register information to debug console. + */ + void printPdecMon(); - std::string getMonStatusString(uint32_t status); + std::string getMonStatusString(uint32_t status); - object_id_t tcDestinationId; + object_id_t tcDestinationId; - AcceptsTelecommandsIF* tcDestination = nullptr; + AcceptsTelecommandsIF* tcDestination = nullptr; - LinuxLibgpioIF* gpioComIF = nullptr; + LinuxLibgpioIF* gpioComIF = nullptr; - /** - * Reset signal is required to hold PDEC in reset state until the configuration has been - * written to the appropriate memory space. - * Can also be used to reboot PDEC in case of erros. - */ - gpioId_t pdecReset = gpio::NO_GPIO; + /** + * Reset signal is required to hold PDEC in reset state until the configuration has been + * written to the appropriate memory space. + * Can also be used to reboot PDEC in case of erros. + */ + gpioId_t pdecReset = gpio::NO_GPIO; - // UIO device file giving access to the PDEC configuration memory section - std::string uioConfigMemory; + // UIO device file giving access to the PDEC configuration memory section + std::string uioConfigMemory; - // UIO device file giving access to the PDEC RAM section - std::string uioRamMemory; + // UIO device file giving access to the PDEC RAM section + std::string uioRamMemory; - // UIO device file giving access to the PDEC register space - std::string uioRegisters; + // UIO device file giving access to the PDEC register space + std::string uioRegisters; - ActionHelper actionHelper; + ActionHelper actionHelper; - StorageManagerIF* tcStore = nullptr; + StorageManagerIF* tcStore = nullptr; - MessageQueueIF* commandQueue = nullptr; + MessageQueueIF* commandQueue = nullptr; - State state = State::INIT; + State state = State::INIT; - /** - * Pointer pointing to base address of the PDEC memory space. - * This address is equivalent with the base address of the section named configuration area in - * the PDEC datasheet. - */ - uint32_t* memoryBaseAddress = nullptr; + /** + * Pointer pointing to base address of the PDEC memory space. + * This address is equivalent with the base address of the section named configuration area in + * the PDEC datasheet. + */ + uint32_t* memoryBaseAddress = nullptr; - uint32_t* ramBaseAddress = nullptr; + uint32_t* ramBaseAddress = nullptr; - // Pointer pointing to base address of register space - uint32_t* registerBaseAddress = nullptr; + // Pointer pointing to base address of register space + uint32_t* registerBaseAddress = nullptr; - uint32_t pdecFar = 0; + uint32_t pdecFar = 0; - uint8_t tcSegment[TC_SEGMENT_LEN]; + uint8_t tcSegment[TC_SEGMENT_LEN]; - // Used to check carrier and bit lock changes (default set to no rf and no bitlock) - uint32_t lastClcw = 0xC000; + // Used to check carrier and bit lock changes (default set to no rf and no bitlock) + uint32_t lastClcw = 0xC000; }; #endif /* LINUX_OBC_PDECHANDLER_H_ */ diff --git a/linux/obc/Ptme.cpp b/linux/obc/Ptme.cpp index 63af5d33..237e66ab 100644 --- a/linux/obc/Ptme.cpp +++ b/linux/obc/Ptme.cpp @@ -1,72 +1,69 @@ -#include #include - #include -#include "fsfw/serviceinterface/ServiceInterface.h" +#include + #include "PtmeConfig.h" +#include "fsfw/serviceinterface/ServiceInterface.h" -Ptme::Ptme(object_id_t objectId): SystemObject(objectId) { -} +Ptme::Ptme(object_id_t objectId) : SystemObject(objectId) {} -Ptme::~Ptme() { -} +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; + } - 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)); - /** - * 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)); + if (ptmeBaseAddress == MAP_FAILED) { + sif::error << "Ptme::initialize: Failed to map uio address" << std::endl; + return RETURN_FAILED; + } - 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->setRegisterAddress(ptmeBaseAddress); + } - VcInterfaceMapIter iter; - for (iter = vcInterfaceMap.begin(); iter != vcInterfaceMap.end(); iter++) { - iter->second->setRegisterAddress(ptmeBaseAddress); - } - - return RETURN_OK; + return RETURN_OK; } -ReturnValue_t Ptme::writeToVc(uint8_t vcId, const uint8_t * data, size_t size) { - ReturnValue_t result = RETURN_OK; - VcInterfaceMapIter vcInterfaceMapIter = vcInterfaceMap.find(vcId); - if (vcInterfaceMapIter == vcInterfaceMap.end()) { - sif::warning << "Ptme::writeToVc: No virtual channel interface found for the virtual " - "channel with id " << static_cast(vcId) << std::endl; - return UNKNOWN_VC_ID; - } - result = vcInterfaceMapIter->second->write(data, size); - return result; +ReturnValue_t Ptme::writeToVc(uint8_t vcId, const uint8_t* data, size_t size) { + ReturnValue_t result = RETURN_OK; + VcInterfaceMapIter vcInterfaceMapIter = vcInterfaceMap.find(vcId); + if (vcInterfaceMapIter == vcInterfaceMap.end()) { + sif::warning << "Ptme::writeToVc: No virtual channel interface found for the virtual " + "channel with id " + << static_cast(vcId) << std::endl; + return UNKNOWN_VC_ID; + } + result = vcInterfaceMapIter->second->write(data, size); + return result; } void Ptme::addVcInterface(VcId_t vcId, VcInterfaceIF* vc) { + if (vcId > common::NUMBER_OF_VIRTUAL_CHANNELS) { + sif::warning << "Ptme::addVcInterface: Invalid virtual channel ID" << std::endl; + return; + } - if (vcId > common::NUMBER_OF_VIRTUAL_CHANNELS) { - sif::warning << "Ptme::addVcInterface: Invalid virtual channel ID" << std::endl; - return; - } + if (vc == nullptr) { + sif::warning << "Ptme::addVcInterface: Invalid virtual channel interface" << std::endl; + return; + } - if (vc == nullptr) { - sif::warning << "Ptme::addVcInterface: Invalid virtual channel interface" << std::endl; - return; - } - - auto status = vcInterfaceMap.emplace(vcId, vc); - if (status.second == false) { - sif::warning << "Ptme::addVcInterface: Failed to add virtual channel interface to " - "virtual channel map" << std::endl; - return; - } + auto status = vcInterfaceMap.emplace(vcId, vc); + if (status.second == false) { + sif::warning << "Ptme::addVcInterface: Failed to add virtual channel interface to " + "virtual channel map" + << std::endl; + return; + } } diff --git a/linux/obc/Ptme.h b/linux/obc/Ptme.h index 5364974f..d85885bc 100644 --- a/linux/obc/Ptme.h +++ b/linux/obc/Ptme.h @@ -1,91 +1,87 @@ #ifndef LINUX_OBC_PTME_H_ #define LINUX_OBC_PTME_H_ -#include "OBSWConfig.h" -#include "linux/obc/PtmeIF.h" -#include "linux/obc/VcInterfaceIF.h" #include #include -#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include #include +#include "OBSWConfig.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "linux/obc/PtmeIF.h" +#include "linux/obc/VcInterfaceIF.h" + /** * @brief This class handles the interfacing to the telemetry (PTME) IP core responsible for the - * encoding of telemetry packets according to the CCSDS standards CCSDS 131.0-B-3 (TM Synchro- - * nization and channel coding) and CCSDS 132.0-B-2 (TM Space Data Link Protocoll). - * The IP cores are implemented on the programmable logic and are accessible through the - * linux UIO driver. + * encoding of telemetry packets according to the CCSDS standards CCSDS 131.0-B-3 (TM + * Synchro- nization and channel coding) and CCSDS 132.0-B-2 (TM Space Data Link Protocoll). The IP + * cores are implemented on the programmable logic and are accessible through the linux UIO driver. */ -class Ptme : public PtmeIF, - public SystemObject, - public HasReturnvaluesIF { -public: +class Ptme : public PtmeIF, public SystemObject, public HasReturnvaluesIF { + public: + using VcId_t = uint8_t; - using VcId_t = uint8_t; + /** + * @brief Constructor + * + * @param objectId + */ + Ptme(object_id_t objectId); + virtual ~Ptme(); - /** - * @brief Constructor - * - * @param objectId - */ - Ptme(object_id_t objectId); - virtual ~Ptme(); + ReturnValue_t initialize() override; + ReturnValue_t writeToVc(uint8_t vcId, const uint8_t* data, size_t size) override; - ReturnValue_t initialize() override; - ReturnValue_t writeToVc(uint8_t vcId, const uint8_t* data, size_t size) override; + /** + * @brief This function adds the reference to a virtual channel interface to the vcInterface + * map. + */ + void addVcInterface(VcId_t vcId, VcInterfaceIF* vc); - /** - * @brief This function adds the reference to a virtual channel interface to the vcInterface - * map. - */ - void addVcInterface(VcId_t vcId, VcInterfaceIF* vc); + private: + static const uint8_t INTERFACE_ID = CLASS_ID::PTME; -private: - - static const uint8_t INTERFACE_ID = CLASS_ID::PTME; - - static const ReturnValue_t UNKNOWN_VC_ID = MAKE_RETURN_CODE(0xA0); + 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; + /** Size of mapped address space */ + static const int MAP_SIZE = 0x40000; #else - /** Size of mapped address space */ - static const int MAP_SIZE = 0x40000; + /** Size of mapped address space */ + static const int MAP_SIZE = 0x40000; #endif /* BOARD_TE0720 == 1 */ - /** - * Configuration bits: - * bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00 - * bit[2]: Set this bit to 1 to abort a transfered packet - * bit[3]: Signals to PTME the start of a new telemetry packet - */ - static const uint32_t PTME_CONFIG_START = 0x8; + /** + * Configuration bits: + * bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00 + * bit[2]: Set this bit to 1 to abort a transfered packet + * bit[3]: Signals to PTME the start of a new telemetry packet + */ + static const uint32_t PTME_CONFIG_START = 0x8; - /** - * Writing this word to the ptme base address signals to the PTME that a complete tm packet has - * been transferred. - */ - static const uint32_t PTME_CONFIG_END = 0x0; + /** + * Writing this word to the ptme base address signals to the PTME that a complete tm packet has + * been transferred. + */ + static const uint32_t PTME_CONFIG_END = 0x0; - /** - * Writing to this offset within the PTME memory space will insert data for encoding to the - * PTME IP core. - * The address offset is 0x400 (= 4 * 256) - */ - static const int PTME_DATA_REG_OFFSET = 256; + /** + * Writing to this offset within the PTME memory space will insert data for encoding to the + * PTME IP core. + * The address offset is 0x400 (= 4 * 256) + */ + static const int PTME_DATA_REG_OFFSET = 256; - /** The file descriptor of the UIO driver */ - int fd = 0; + /** The file descriptor of the UIO driver */ + int fd = 0; - uint32_t* ptmeBaseAddress = nullptr; + uint32_t* ptmeBaseAddress = nullptr; - using VcInterfaceMap = std::unordered_map; - using VcInterfaceMapIter = VcInterfaceMap::iterator; + using VcInterfaceMap = std::unordered_map; + using VcInterfaceMapIter = VcInterfaceMap::iterator; - VcInterfaceMap vcInterfaceMap; + VcInterfaceMap vcInterfaceMap; }; #endif /* LINUX_OBC_PTME_H_ */ diff --git a/linux/obc/PtmeConfig.h b/linux/obc/PtmeConfig.h index 814dfeda..b5b722ac 100644 --- a/linux/obc/PtmeConfig.h +++ b/linux/obc/PtmeConfig.h @@ -1,9 +1,10 @@ #ifndef LINUX_OBC_PTMECONFIG_H_ #define LINUX_OBC_PTMECONFIG_H_ -#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include + #include "OBSWConfig.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" /** * @brief PTME specific configuration parameters derived from FPGA design and device tree. @@ -11,20 +12,20 @@ * @author J. Meier */ namespace PtmeConfig { - /** - * Offset of virtual channels mapped into address space - * 0x10000 = (0x4000 * 4) - */ - static const uint32_t VC0_OFFSETT = 0; - static const uint32_t VC1_OFFSETT = 0x4000; - static const uint32_t VC2_OFFSETT = 0x8000; - static const uint32_t VC3_OFFSETT = 0xC000; +/** + * Offset of virtual channels mapped into address space + * 0x10000 = (0x4000 * 4) + */ +static const uint32_t VC0_OFFSETT = 0; +static const uint32_t VC1_OFFSETT = 0x4000; +static const uint32_t VC2_OFFSETT = 0x8000; +static const uint32_t VC3_OFFSETT = 0xC000; #if BOARD_TE0720 == 0 - static const char UIO_DEVICE_FILE[] = "/dev/uio1"; +static const char UIO_DEVICE_FILE[] = "/dev/uio1"; #else - static const char UIO_DEVICE_FILE[] = "/dev/uio1"; +static const char UIO_DEVICE_FILE[] = "/dev/uio1"; #endif -}; +}; // namespace PtmeConfig #endif /* LINUX_OBC_PTMECONFIG_H_ */ diff --git a/linux/obc/PtmeIF.h b/linux/obc/PtmeIF.h index 53d9498b..7108df05 100644 --- a/linux/obc/PtmeIF.h +++ b/linux/obc/PtmeIF.h @@ -3,7 +3,6 @@ #include "fsfw/returnvalues/HasReturnvaluesIF.h" - /** * @brief Interface class for managing the PTME IP Core implemented in the programmable logic. * @@ -12,17 +11,17 @@ * @author J. Meier */ class PtmeIF { -public: - virtual ~PtmeIF(){}; + public: + virtual ~PtmeIF(){}; - /** - * @brief Implements to function to write to a specific virtual channel. - * - * @param vcId Virtual channel to write to - * @param data Pointer to buffer holding the data to write - * @param size Number of bytes to write - */ - virtual ReturnValue_t writeToVc(uint8_t vcId, const uint8_t* data, size_t size) = 0; + /** + * @brief Implements to function to write to a specific virtual channel. + * + * @param vcId Virtual channel to write to + * @param data Pointer to buffer holding the data to write + * @param size Number of bytes to write + */ + virtual ReturnValue_t writeToVc(uint8_t vcId, const uint8_t* data, size_t size) = 0; }; #endif /* LINUX_OBC_PTMEIF_H_ */ diff --git a/linux/obc/PtmeRateSetter.cpp b/linux/obc/PtmeRateSetter.cpp index 92886623..b5a6ee1c 100644 --- a/linux/obc/PtmeRateSetter.cpp +++ b/linux/obc/PtmeRateSetter.cpp @@ -1,27 +1,25 @@ #include "PtmeRateSetter.h" + #include "fsfw/serviceinterface/ServiceInterface.h" -PtmeRateSetter::PtmeRateSetter(gpioId_t bitrateSel, GpioIF* gpioif) : - bitrateSel(bitrateSel), gpioif(gpioif) { -} +PtmeRateSetter::PtmeRateSetter(gpioId_t bitrateSel, GpioIF* gpioif) + : bitrateSel(bitrateSel), gpioif(gpioif) {} -PtmeRateSetter::~PtmeRateSetter() { -} +PtmeRateSetter::~PtmeRateSetter() {} ReturnValue_t PtmeRateSetter::setRate(BitRates rate) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - switch(rate) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + switch (rate) { case RATE_2000KHZ: - result = gpioif->pullHigh(bitrateSel); - break; + result = gpioif->pullHigh(bitrateSel); + break; case RATE_400KHZ: - result = gpioif->pullLow(bitrateSel); - break; + result = gpioif->pullLow(bitrateSel); + break; default: - sif::debug << "PtmeRateSetter::setRate: Invalid rate" << std::endl; - result = HasReturnvaluesIF::RETURN_FAILED; - break; - } - return result; + sif::debug << "PtmeRateSetter::setRate: Invalid rate" << std::endl; + result = HasReturnvaluesIF::RETURN_FAILED; + break; + } + return result; } - diff --git a/linux/obc/PtmeRateSetter.h b/linux/obc/PtmeRateSetter.h index ece78e91..14dfec4b 100644 --- a/linux/obc/PtmeRateSetter.h +++ b/linux/obc/PtmeRateSetter.h @@ -2,9 +2,9 @@ #define LINUX_OBC_PTMERATESETTER_H_ #include "TxRateSetterIF.h" -#include "fsfw_hal/common/gpio/gpioDefinitions.h" -#include "fsfw_hal/common/gpio/GpioIF.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw_hal/common/gpio/GpioIF.h" +#include "fsfw_hal/common/gpio/gpioDefinitions.h" /** * @brief Class to set the downlink bit rate by using the cadu_rate_switcher implemented in @@ -15,26 +15,24 @@ * * @author J. Meier */ -class PtmeRateSetter: public TxRateSetterIF { -public: +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(); - /** - * @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(); + virtual ReturnValue_t setRate(BitRates rate); - virtual ReturnValue_t setRate(BitRates rate); + private: + gpioId_t bitrateSel = gpio::NO_GPIO; -private: - - gpioId_t bitrateSel = gpio::NO_GPIO; - - GpioIF* gpioif = nullptr; + GpioIF* gpioif = nullptr; }; #endif /* LINUX_OBC_PTMERATESETTER_H_ */ diff --git a/linux/obc/TxRateSetterIF.h b/linux/obc/TxRateSetterIF.h index c07106e4..1eaded33 100644 --- a/linux/obc/TxRateSetterIF.h +++ b/linux/obc/TxRateSetterIF.h @@ -3,10 +3,7 @@ #include "fsfw/returnvalues/HasReturnvaluesIF.h" -enum BitRates : uint32_t { - RATE_2000KHZ, - RATE_400KHZ -}; +enum BitRates : uint32_t { RATE_2000KHZ, RATE_400KHZ }; /** * @brief Abstract class for objects implementing the functionality to switch the @@ -15,11 +12,11 @@ enum BitRates : uint32_t { * @author J. Meier */ class TxRateSetterIF { -public: - TxRateSetterIF() {}; - virtual ~TxRateSetterIF() {}; + public: + TxRateSetterIF(){}; + virtual ~TxRateSetterIF(){}; - virtual ReturnValue_t setRate(BitRates bitRate) = 0; + virtual ReturnValue_t setRate(BitRates bitRate) = 0; }; #endif /* LINUX_OBC_TXRATESETTERIF_H_ */ diff --git a/linux/obc/VcInterfaceIF.h b/linux/obc/VcInterfaceIF.h index 28b8d1f1..0aa95691 100644 --- a/linux/obc/VcInterfaceIF.h +++ b/linux/obc/VcInterfaceIF.h @@ -2,6 +2,7 @@ #define LINUX_OBC_VCINTERFACEIF_H_ #include + #include "fsfw/returnvalues/HasReturnvaluesIF.h" /** @@ -11,19 +12,19 @@ * @author J. Meier */ class VcInterfaceIF { -public: - virtual ~VcInterfaceIF(){}; + public: + virtual ~VcInterfaceIF(){}; - /** - * @brief Implememts the functionality to write data in the virtual channel of the PTME IP - * Core. - * - * @param data Pointer to buffer holding the data to write - * @param size Number of bytes to write - */ - virtual ReturnValue_t write(const uint8_t* data, size_t size) = 0; + /** + * @brief Implememts the functionality to write data in the virtual channel of the PTME IP + * Core. + * + * @param data Pointer to buffer holding the data to write + * @param size Number of bytes to write + */ + virtual ReturnValue_t write(const uint8_t* data, size_t size) = 0; - virtual void setRegisterAddress(uint32_t* ptmeBaseAddress) = 0; + virtual void setRegisterAddress(uint32_t* ptmeBaseAddress) = 0; }; #endif /* LINUX_OBC_VCINTERFACEIF_H_ */ diff --git a/linux/utility/utility.cpp b/linux/utility/utility.cpp index 1d6ec5c0..cd0d47ef 100644 --- a/linux/utility/utility.cpp +++ b/linux/utility/utility.cpp @@ -1,13 +1,14 @@ -#include "OBSWConfig.h" -#include "FSFWConfig.h" #include "utility.h" -#include "fsfw/serviceinterface/ServiceInterface.h" #include +#include "FSFWConfig.h" +#include "OBSWConfig.h" +#include "fsfw/serviceinterface/ServiceInterface.h" + void utility::handleSystemError(int retcode, std::string function) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::warning << function << ": System call failed with code " << retcode << ": " << - strerror(retcode) << std::endl; + sif::warning << function << ": System call failed with code " << retcode << ": " + << strerror(retcode) << std::endl; #endif } diff --git a/linux/utility/utility.h b/linux/utility/utility.h index 3eb17a9b..8f7df04f 100644 --- a/linux/utility/utility.h +++ b/linux/utility/utility.h @@ -1,9 +1,10 @@ #ifndef LINUX_UTILITY_UTILITY_H_ #define LINUX_UTILITY_UTILITY_H_ -#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include +#include "fsfw/returnvalues/HasReturnvaluesIF.h" + namespace utility { void handleSystemError(int retcode, std::string function); diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 538e63f3..cd8c8b22 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1,49 +1,42 @@ #include "ThermalController.h" + #include -ThermalController::ThermalController(object_id_t objectId): - ExtendedControllerBase(objectId, objects::NO_OBJECT), - thermalControllerSet(objectId) { +ThermalController::ThermalController(object_id_t objectId) + : ExtendedControllerBase(objectId, objects::NO_OBJECT), thermalControllerSet(objectId) {} + +ReturnValue_t ThermalController::handleCommandMessage(CommandMessage *message) { + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t ThermalController::handleCommandMessage( - CommandMessage *message) { - return HasReturnvaluesIF::RETURN_OK; -} +void ThermalController::performControlOperation() {} -void ThermalController::performControlOperation() { - -} - -void ThermalController::handleChangedDataset(sid_t sid, - store_address_t storeId) { - if(sid == sid_t(TSensorDefinitions::ObjIds::TEST_HKB_HANDLER, - TSensorDefinitions::THERMAL_SENSOR_SET_ID)) { - sif::info << "Update registered!" << std::endl; - } +void ThermalController::handleChangedDataset(sid_t sid, store_address_t storeId) { + if (sid == sid_t(TSensorDefinitions::ObjIds::TEST_HKB_HANDLER, + TSensorDefinitions::THERMAL_SENSOR_SET_ID)) { + sif::info << "Update registered!" << std::endl; + } } ReturnValue_t ThermalController::initializeAfterTaskCreation() { - ReturnValue_t result = - ExtendedControllerBase::initializeAfterTaskCreation(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "ThermalController::initializeAfterTaskCreation: Base" - << " class initialization failed!" << std::endl; - } - HasLocalDataPoolIF* testHkbHandler = ObjectManager::instance()->get( - TSensorDefinitions::ObjIds::TEST_HKB_HANDLER); - if(testHkbHandler == nullptr) { - sif::warning << "ThermalController::initializeAfterTaskCreation: Test" - << " HKB Handler invalid!" << std::endl; - } - // Test normal notifications without data packet first. - testHkbHandler->getHkManagerHandle()->subscribeForSetUpdateMessages( - TSensorDefinitions::THERMAL_SENSOR_SET_ID, - this->getObjectId(), commandQueue->getId(), false); - return result; + ReturnValue_t result = ExtendedControllerBase::initializeAfterTaskCreation(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "ThermalController::initializeAfterTaskCreation: Base" + << " class initialization failed!" << std::endl; + } + HasLocalDataPoolIF *testHkbHandler = ObjectManager::instance()->get( + TSensorDefinitions::ObjIds::TEST_HKB_HANDLER); + if (testHkbHandler == nullptr) { + sif::warning << "ThermalController::initializeAfterTaskCreation: Test" + << " HKB Handler invalid!" << std::endl; + } + // Test normal notifications without data packet first. + testHkbHandler->getHkManagerHandle()->subscribeForSetUpdateMessages( + TSensorDefinitions::THERMAL_SENSOR_SET_ID, this->getObjectId(), commandQueue->getId(), false); + return result; } -ReturnValue_t ThermalController::checkModeCommand(Mode_t mode, - Submode_t submode, uint32_t *msToReachTheMode) { - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t ThermalController::checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t *msToReachTheMode) { + return HasReturnvaluesIF::RETURN_OK; } diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 67c5b24a..2d76ce8d 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -2,32 +2,30 @@ #define MISSION_CONTROLLER_THERMALCONTROLLER_H_ #include + #include "ctrldefinitions/ThermalCtrlPackets.h" +class ThermalController : public ExtendedControllerBase { + public: + ThermalController(object_id_t objectId); -class ThermalController: public ExtendedControllerBase { -public: - ThermalController(object_id_t objectId); -private: + private: + // TODO: Add stubs for thermal components. Each device / assembly with one + // or multiple redundant sensors will have a thermal component. - // TODO: Add stubs for thermal components. Each device / assembly with one - // or multiple redundant sensors will have a thermal component. + /** ExtendedControllerBase overrides */ + virtual ReturnValue_t handleCommandMessage(CommandMessage *message) override; - /** ExtendedControllerBase overrides */ - virtual ReturnValue_t handleCommandMessage( - CommandMessage *message) override; + virtual void performControlOperation() override; - virtual void performControlOperation() override; + virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t *msToReachTheMode) override; - virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, - uint32_t *msToReachTheMode) override; + ReturnValue_t initializeAfterTaskCreation() override; - ReturnValue_t initializeAfterTaskCreation() override; + void handleChangedDataset(sid_t sid, store_address_t storeId) override; - void handleChangedDataset(sid_t sid, store_address_t storeId) override; - - ThermalCtrl::ThermalControllerTemperatureSet thermalControllerSet; + ThermalCtrl::ThermalControllerTemperatureSet thermalControllerSet; }; - #endif /* MISSION_CONTROLLER_THERMALCONTROLLER_H_ */ diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index 14c8791a..b17812e6 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -1,11 +1,6 @@ #include "GenericFactory.h" #include - -#include -#include -#include "objects/systemObjectList.h" - #include #include #include @@ -13,8 +8,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -23,12 +18,16 @@ #include #include #include +#include +#include + +#include "objects/systemObjectList.h" #if OBSW_ADD_TCPIP_BRIDGE == 1 #if OBSW_USE_TCP_BRIDGE == 0 // UDP server includes -#include "fsfw/osal/common/UdpTmTcBridge.h" #include "fsfw/osal/common/UdpTcPollingTask.h" +#include "fsfw/osal/common/UdpTmTcBridge.h" #else // TCP server includes #include "fsfw/osal/common/TcpTmTcBridge.h" @@ -41,78 +40,69 @@ #endif void ObjectFactory::produceGenericObjects() { - // Framework objects - new EventManager(objects::EVENT_MANAGER); - new HealthTable(objects::HEALTH_TABLE); - new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER); - new TimeStamper(objects::TIME_STAMPER); + // Framework objects + new EventManager(objects::EVENT_MANAGER); + new HealthTable(objects::HEALTH_TABLE); + new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER); + new TimeStamper(objects::TIME_STAMPER); - { - PoolManager::LocalPoolConfig poolCfg = { - {300, 16}, {300, 32}, {200, 64}, {200, 128}, {100, 1024}, {10, 2048} - }; - new PoolManager(objects::TC_STORE, poolCfg); - } + { + PoolManager::LocalPoolConfig poolCfg = {{300, 16}, {300, 32}, {200, 64}, + {200, 128}, {100, 1024}, {10, 2048}}; + new PoolManager(objects::TC_STORE, poolCfg); + } - { - PoolManager::LocalPoolConfig poolCfg = { - {300, 16}, {300, 32}, {100, 64}, {100, 128}, {100, 1024}, {10, 2048} - }; - new PoolManager(objects::TM_STORE, poolCfg); - } + { + PoolManager::LocalPoolConfig poolCfg = {{300, 16}, {300, 32}, {100, 64}, + {100, 128}, {100, 1024}, {10, 2048}}; + new PoolManager(objects::TM_STORE, poolCfg); + } - { - PoolManager::LocalPoolConfig poolCfg = { - { 300, 16 }, { 200, 32 }, { 150, 64 }, - { 150, 128 }, { 100, 256 }, { 50, 512 }, { 50, 1024 }, { 10, 2048 } - }; - new PoolManager(objects::IPC_STORE, poolCfg); - } + { + PoolManager::LocalPoolConfig poolCfg = {{300, 16}, {200, 32}, {150, 64}, {150, 128}, + {100, 256}, {50, 512}, {50, 1024}, {10, 2048}}; + new PoolManager(objects::IPC_STORE, poolCfg); + } - new CCSDSDistributor(apid::EIVE_OBSW, objects::CCSDS_PACKET_DISTRIBUTOR); - new PUSDistributor(apid::EIVE_OBSW, objects::PUS_PACKET_DISTRIBUTOR, - objects::CCSDS_PACKET_DISTRIBUTOR); + new CCSDSDistributor(apid::EIVE_OBSW, objects::CCSDS_PACKET_DISTRIBUTOR); + new PUSDistributor(apid::EIVE_OBSW, objects::PUS_PACKET_DISTRIBUTOR, + objects::CCSDS_PACKET_DISTRIBUTOR); + // Every TM packet goes through this funnel + new TmFunnel(objects::TM_FUNNEL); - // Every TM packet goes through this funnel - new TmFunnel(objects::TM_FUNNEL); - - // PUS service stack - new Service1TelecommandVerification(objects::PUS_SERVICE_1_VERIFICATION, - apid::EIVE_OBSW, pus::PUS_SERVICE_1, objects::TM_FUNNEL, 20); - new Service2DeviceAccess(objects::PUS_SERVICE_2_DEVICE_ACCESS, - apid::EIVE_OBSW, pus::PUS_SERVICE_2, 3, 10); - new Service3Housekeeping(objects::PUS_SERVICE_3_HOUSEKEEPING, - apid::EIVE_OBSW, pus::PUS_SERVICE_3); - new Service5EventReporting(objects::PUS_SERVICE_5_EVENT_REPORTING, - apid::EIVE_OBSW, pus::PUS_SERVICE_5, 50); - new Service8FunctionManagement(objects::PUS_SERVICE_8_FUNCTION_MGMT, - apid::EIVE_OBSW, pus::PUS_SERVICE_8, 3, 60); - new Service9TimeManagement(objects::PUS_SERVICE_9_TIME_MGMT, - apid::EIVE_OBSW, pus::PUS_SERVICE_9); - new Service17Test(objects::PUS_SERVICE_17_TEST, apid::EIVE_OBSW, - pus::PUS_SERVICE_17); - new Service20ParameterManagement(objects::PUS_SERVICE_20_PARAMETERS, apid::EIVE_OBSW, - pus::PUS_SERVICE_20); - new CService200ModeCommanding(objects::PUS_SERVICE_200_MODE_MGMT, - apid::EIVE_OBSW, pus::PUS_SERVICE_200); - + // PUS service stack + new Service1TelecommandVerification(objects::PUS_SERVICE_1_VERIFICATION, apid::EIVE_OBSW, + pus::PUS_SERVICE_1, objects::TM_FUNNEL, 20); + new Service2DeviceAccess(objects::PUS_SERVICE_2_DEVICE_ACCESS, apid::EIVE_OBSW, + pus::PUS_SERVICE_2, 3, 10); + new Service3Housekeeping(objects::PUS_SERVICE_3_HOUSEKEEPING, apid::EIVE_OBSW, + pus::PUS_SERVICE_3); + new Service5EventReporting(objects::PUS_SERVICE_5_EVENT_REPORTING, apid::EIVE_OBSW, + pus::PUS_SERVICE_5, 50); + new Service8FunctionManagement(objects::PUS_SERVICE_8_FUNCTION_MGMT, apid::EIVE_OBSW, + pus::PUS_SERVICE_8, 3, 60); + new Service9TimeManagement(objects::PUS_SERVICE_9_TIME_MGMT, apid::EIVE_OBSW, pus::PUS_SERVICE_9); + new Service17Test(objects::PUS_SERVICE_17_TEST, apid::EIVE_OBSW, pus::PUS_SERVICE_17); + new Service20ParameterManagement(objects::PUS_SERVICE_20_PARAMETERS, apid::EIVE_OBSW, + pus::PUS_SERVICE_20); + new CService200ModeCommanding(objects::PUS_SERVICE_200_MODE_MGMT, apid::EIVE_OBSW, + pus::PUS_SERVICE_200); #if OBSW_ADD_TCPIP_BRIDGE == 1 #if OBSW_USE_TCP_BRIDGE == 0 - auto tmtcBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); - sif::info << "Created UDP server for TMTC commanding with listener port " << - udpBridge->getUdpPort() << std::endl; + auto tmtcBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); + sif::info << "Created UDP server for TMTC commanding with listener port " + << udpBridge->getUdpPort() << std::endl; #else - auto tmtcBridge = new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - auto tcpServer = new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); - // TCP is stream based. Use packet ID as start marker when parsing for space packets - tcpServer->setSpacePacketParsingOptions({common::PUS_PACKET_ID}); - sif::info << "Created TCP server for TMTC commanding with listener port " + auto tmtcBridge = new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + auto tcpServer = new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); + // TCP is stream based. Use packet ID as start marker when parsing for space packets + tcpServer->setSpacePacketParsingOptions({common::PUS_PACKET_ID}); + sif::info << "Created TCP server for TMTC commanding with listener port " << tcpServer->getTcpPort() << std::endl; #endif /* OBSW_USE_TMTC_TCP_BRIDGE == 0 */ - tmtcBridge->setMaxNumberOfPacketsStored(70); + tmtcBridge->setMaxNumberOfPacketsStored(70); #endif /* OBSW_ADD_TCPIP_BRIDGE == 1 */ - } diff --git a/mission/core/GenericFactory.h b/mission/core/GenericFactory.h index c96c7818..1a3b1300 100644 --- a/mission/core/GenericFactory.h +++ b/mission/core/GenericFactory.h @@ -5,8 +5,6 @@ namespace ObjectFactory { void produceGenericObjects(); - } - #endif /* MISSION_CORE_GENERICFACTORY_H_ */ diff --git a/mission/devices/ACUHandler.cpp b/mission/devices/ACUHandler.cpp index 955b1703..239a0c7a 100644 --- a/mission/devices/ACUHandler.cpp +++ b/mission/devices/ACUHandler.cpp @@ -1,308 +1,309 @@ #include "ACUHandler.h" + #include "OBSWConfig.h" -ACUHandler::ACUHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - GomspaceDeviceHandler(objectId, comIF, comCookie, ACU::MAX_CONFIGTABLE_ADDRESS, - ACU::MAX_HKTABLE_ADDRESS, ACU::HK_TABLE_REPLY_SIZE, &acuHkTableDataset), acuHkTableDataset( - this) { -} +ACUHandler::ACUHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie) + : GomspaceDeviceHandler(objectId, comIF, comCookie, ACU::MAX_CONFIGTABLE_ADDRESS, + ACU::MAX_HKTABLE_ADDRESS, ACU::HK_TABLE_REPLY_SIZE, &acuHkTableDataset), + acuHkTableDataset(this) {} -ACUHandler::~ACUHandler() { -} +ACUHandler::~ACUHandler() {} -ReturnValue_t ACUHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - *id = GOMSPACE::REQUEST_HK_TABLE; - return buildCommandFromCommand(*id, NULL, 0); +ReturnValue_t ACUHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + *id = GOMSPACE::REQUEST_HK_TABLE; + return buildCommandFromCommand(*id, NULL, 0); } void ACUHandler::fillCommandAndReplyMap() { - GomspaceDeviceHandler::fillCommandAndReplyMap(); - this->insertInCommandMap(PRINT_CHANNEL_STATS); + GomspaceDeviceHandler::fillCommandAndReplyMap(); + this->insertInCommandMap(PRINT_CHANNEL_STATS); } void ACUHandler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) { - - parseHkTableReply(packet); - handleDeviceTM(&acuHkTableDataset, id, true); + parseHkTableReply(packet); + handleDeviceTM(&acuHkTableDataset, id, true); #if OBSW_ENHANCED_PRINTOUT == 1 && OBSW_DEBUG_ACU == 1 - acuHkTableDataset.read(); - float temperatureC_1 = acuHkTableDataset.temperature1.value * 0.1; - float temperatureC_2 = acuHkTableDataset.temperature2.value * 0.1; - float temperatureC_3 = acuHkTableDataset.temperature3.value * 0.1; - sif::info << "ACU: Temperature 1: " << temperatureC_1 << " °C" << std::endl; - sif::info << "ACU: Temperature 2: " << temperatureC_2 << " °C" << std::endl; - sif::info << "ACU: Temperature 3: " << temperatureC_3 << " °C" << std::endl; - sif::info << "ACU: Ground Watchdog Timer Count: " - << acuHkTableDataset.wdtCntGnd.value << std::endl; - sif::info << "ACU: Ground watchdog timer, seconds left before reboot: " - << acuHkTableDataset.wdtGndLeft.value << std::endl; - acuHkTableDataset.commit(); + acuHkTableDataset.read(); + float temperatureC_1 = acuHkTableDataset.temperature1.value * 0.1; + float temperatureC_2 = acuHkTableDataset.temperature2.value * 0.1; + float temperatureC_3 = acuHkTableDataset.temperature3.value * 0.1; + sif::info << "ACU: Temperature 1: " << temperatureC_1 << " °C" << std::endl; + sif::info << "ACU: Temperature 2: " << temperatureC_2 << " °C" << std::endl; + sif::info << "ACU: Temperature 3: " << temperatureC_3 << " °C" << std::endl; + sif::info << "ACU: Ground Watchdog Timer Count: " << acuHkTableDataset.wdtCntGnd.value + << std::endl; + sif::info << "ACU: Ground watchdog timer, seconds left before reboot: " + << acuHkTableDataset.wdtGndLeft.value << std::endl; + acuHkTableDataset.commit(); #endif } void ACUHandler::parseHkTableReply(const uint8_t *packet) { - uint16_t dataOffset = 0; - acuHkTableDataset.read(); - dataOffset += 12; - acuHkTableDataset.currentInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.currentInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.currentInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.currentInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.currentInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.currentInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + uint16_t dataOffset = 0; + acuHkTableDataset.read(); + dataOffset += 12; + acuHkTableDataset.currentInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.currentInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.currentInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.currentInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.currentInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.currentInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.voltageInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.voltageInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.voltageInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.voltageInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.voltageInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.voltageInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + acuHkTableDataset.voltageInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.voltageInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.voltageInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.voltageInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.voltageInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.voltageInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + acuHkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.temperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.temperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.temperature3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + acuHkTableDataset.temperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.temperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.temperature3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.mpptMode = *(packet + dataOffset); - dataOffset += 3; + acuHkTableDataset.mpptMode = *(packet + dataOffset); + dataOffset += 3; - acuHkTableDataset.vboostInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.vboostInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.vboostInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.vboostInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.vboostInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.vboostInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + acuHkTableDataset.vboostInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.vboostInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.vboostInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.vboostInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.vboostInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.vboostInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.powerInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.powerInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.powerInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.powerInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.powerInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.powerInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + acuHkTableDataset.powerInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.powerInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.powerInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.powerInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.powerInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.powerInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.dac0Enable = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.dac1Enable = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.dac2Enable = *(packet + dataOffset); - dataOffset += 3; + acuHkTableDataset.dac0Enable = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.dac1Enable = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.dac2Enable = *(packet + dataOffset); + dataOffset += 3; - acuHkTableDataset.dacRawChannelVal0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.dacRawChannelVal1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.dacRawChannelVal2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.dacRawChannelVal3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.dacRawChannelVal4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.dacRawChannelVal5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + acuHkTableDataset.dacRawChannelVal0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.dacRawChannelVal1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.dacRawChannelVal2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.dacRawChannelVal3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.dacRawChannelVal4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.dacRawChannelVal5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.bootCause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - acuHkTableDataset.bootcnt = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - acuHkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - acuHkTableDataset.resetCause = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.mpptTime = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - /* +12 because here starts the second csp packet */ - dataOffset += 2 + 12; + acuHkTableDataset.bootCause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + acuHkTableDataset.bootcnt = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + acuHkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + acuHkTableDataset.resetCause = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.mpptTime = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + /* +12 because here starts the second csp packet */ + dataOffset += 2 + 12; - acuHkTableDataset.mpptPeriod = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + acuHkTableDataset.mpptPeriod = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.device0 = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device1 = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device2 = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device3 = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device4 = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device5 = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device6 = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device7 = *(packet + dataOffset); - dataOffset += 3; + acuHkTableDataset.device0 = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device1 = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device2 = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device3 = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device4 = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device5 = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device6 = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device7 = *(packet + dataOffset); + dataOffset += 3; - acuHkTableDataset.device0Status = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device1Status = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device2Status = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device3Status = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device4Status = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device5Status = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device6Status = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device7Status = *(packet + dataOffset); - dataOffset += 3; + acuHkTableDataset.device0Status = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device1Status = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device2Status = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device3Status = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device4Status = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device5Status = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device6Status = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device7Status = *(packet + dataOffset); + dataOffset += 3; - acuHkTableDataset.wdtCntGnd = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - acuHkTableDataset.wdtGndLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; + acuHkTableDataset.wdtCntGnd = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + acuHkTableDataset.wdtGndLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; - acuHkTableDataset.commit(); + acuHkTableDataset.commit(); } -ReturnValue_t ACUHandler::initializeLocalDataPool( - localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { +ReturnValue_t ACUHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL5, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL5, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL5, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL5, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VBAT, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VBAT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_TEMPERATURE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_TEMPERATURE_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_TEMPERATURE_3, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_TEMPERATURE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_TEMPERATURE_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_TEMPERATURE_3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_MPPT_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_MPPT_MODE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL5, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL5, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL5, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL5, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_DAC_EN_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DAC_EN_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DAC_EN_2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_DAC_EN_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DAC_EN_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DAC_EN_2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_DAC_RAW_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DAC_RAW_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DAC_RAW_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DAC_RAW_3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DAC_RAW_4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DAC_RAW_5, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_DAC_RAW_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DAC_RAW_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DAC_RAW_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DAC_RAW_3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DAC_RAW_4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DAC_RAW_5, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_BOOTCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_BOOTCNT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_RESET_CAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_MPPT_TIME, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_MPPT_PERIOD, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_BOOTCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_BOOTCNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_UPTIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_RESET_CAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_MPPT_TIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_MPPT_PERIOD, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_DEVICE_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_5, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_7, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_DEVICE_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_DEVICE_0_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_1_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_2_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_3_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_4_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_5_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_6_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_7_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_DEVICE_0_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_1_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_2_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_3_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_4_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_5_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_6_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_7_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_WDT_CNT_GND, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_WDT_GND_LEFT, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_WDT_CNT_GND, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_WDT_GND_LEFT, new PoolEntry( { 0 })); - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t ACUHandler::deviceSpecificCommand(DeviceCommandId_t cmd) { - switch(cmd) { + switch (cmd) { case PRINT_CHANNEL_STATS: { - printChannelStats(); - return RETURN_OK; + printChannelStats(); + return RETURN_OK; } default: { - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } + } } void ACUHandler::printChannelStats() { - PoolReadGuard pg(&acuHkTableDataset); - sif::info << "ACU Info: Current [mA], Voltage [mV]" << std::endl; - sif::info << std::setw(8) << std::left << "Ch0" << std::dec << "| " << - static_cast(acuHkTableDataset.currentInChannel0.value) << - std::setw(15) << std::right << acuHkTableDataset.voltageInChannel0.value << std::endl; - sif::info << std::setw(8) << std::left << "Ch1" << std::dec << "| " << - static_cast(acuHkTableDataset.currentInChannel1.value) << - std::setw(15) << std::right << acuHkTableDataset.voltageInChannel1.value << std::endl; - sif::info << std::setw(8) << std::left << "Ch2" << std::dec << "| " << - static_cast(acuHkTableDataset.currentInChannel2.value) << - std::setw(15) << std::right << acuHkTableDataset.voltageInChannel2.value << std::endl; - sif::info << std::setw(8) << std::left << "Ch3" << std::dec << "| " << - static_cast(acuHkTableDataset.currentInChannel3.value) << - std::setw(15) << std::right << acuHkTableDataset.voltageInChannel3.value << std::endl; - sif::info << std::setw(8) << std::left << "Ch4" << std::dec << "| " << - static_cast(acuHkTableDataset.currentInChannel4.value) << - std::setw(15) << std::right << acuHkTableDataset.voltageInChannel4.value << std::endl; - sif::info << std::setw(8) << std::left << "Ch5" << std::dec << "| " << - static_cast(acuHkTableDataset.currentInChannel5.value) << - std::setw(15) << std::right << acuHkTableDataset.voltageInChannel5.value << std::endl; + PoolReadGuard pg(&acuHkTableDataset); + sif::info << "ACU Info: Current [mA], Voltage [mV]" << std::endl; + sif::info << std::setw(8) << std::left << "Ch0" << std::dec << "| " + << static_cast(acuHkTableDataset.currentInChannel0.value) << std::setw(15) + << std::right << acuHkTableDataset.voltageInChannel0.value << std::endl; + sif::info << std::setw(8) << std::left << "Ch1" << std::dec << "| " + << static_cast(acuHkTableDataset.currentInChannel1.value) << std::setw(15) + << std::right << acuHkTableDataset.voltageInChannel1.value << std::endl; + sif::info << std::setw(8) << std::left << "Ch2" << std::dec << "| " + << static_cast(acuHkTableDataset.currentInChannel2.value) << std::setw(15) + << std::right << acuHkTableDataset.voltageInChannel2.value << std::endl; + sif::info << std::setw(8) << std::left << "Ch3" << std::dec << "| " + << static_cast(acuHkTableDataset.currentInChannel3.value) << std::setw(15) + << std::right << acuHkTableDataset.voltageInChannel3.value << std::endl; + sif::info << std::setw(8) << std::left << "Ch4" << std::dec << "| " + << static_cast(acuHkTableDataset.currentInChannel4.value) << std::setw(15) + << std::right << acuHkTableDataset.voltageInChannel4.value << std::endl; + sif::info << std::setw(8) << std::left << "Ch5" << std::dec << "| " + << static_cast(acuHkTableDataset.currentInChannel5.value) << std::setw(15) + << std::right << acuHkTableDataset.voltageInChannel5.value << std::endl; } diff --git a/mission/devices/ACUHandler.h b/mission/devices/ACUHandler.h index 2bb688e7..0d93c5fe 100644 --- a/mission/devices/ACUHandler.h +++ b/mission/devices/ACUHandler.h @@ -1,51 +1,50 @@ #ifndef MISSION_DEVICES_ACUHANDLER_H_ #define MISSION_DEVICES_ACUHANDLER_H_ -#include "GomspaceDeviceHandler.h" #include + +#include "GomspaceDeviceHandler.h" #include "fsfw/datapool/PoolReadGuard.h" /** * @brief Handler for the ACU from Gomspace. Monitors and controls the battery charging via * the solar panels. */ -class ACUHandler: public GomspaceDeviceHandler { -public: - ACUHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); - virtual ~ACUHandler(); +class ACUHandler : public GomspaceDeviceHandler { + public: + ACUHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + virtual ~ACUHandler(); - virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; + virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; -protected: + protected: + virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t* packet) override; - virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) override; + /** + * @brief As soon as the device is in MODE_NORMAL, this function is executed periodically. + */ + virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override; - /** - * @brief As soon as the device is in MODE_NORMAL, this function is executed periodically. - */ - virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; + virtual void fillCommandAndReplyMap() override; - virtual void fillCommandAndReplyMap() override; + virtual ReturnValue_t deviceSpecificCommand(DeviceCommandId_t cmd) override; - virtual ReturnValue_t deviceSpecificCommand(DeviceCommandId_t cmd) override; + private: + static const DeviceCommandId_t PRINT_CHANNEL_STATS = 51; -private: + ACU::HkTableDataset acuHkTableDataset; - static const DeviceCommandId_t PRINT_CHANNEL_STATS = 51; + /** + * @brief Function extracts the hk table information from the received csp packet and stores + * the values in the acuHkTableDataset. + */ + void parseHkTableReply(const uint8_t* packet); - ACU::HkTableDataset acuHkTableDataset; - - /** - * @brief Function extracts the hk table information from the received csp packet and stores - * the values in the acuHkTableDataset. - */ - void parseHkTableReply(const uint8_t *packet); - - /** - * @brief Prints channel statistics (current and voltage) to console - */ - void printChannelStats(); + /** + * @brief Prints channel statistics (current and voltage) to console + */ + void printChannelStats(); }; #endif /* MISSION_DEVICES_ACUHANDLER_H_ */ diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index a0036867..d49b9db4 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -1,6 +1,6 @@ #include "GPSHyperionHandler.h" -#include "devicedefinitions/GPSDefinitions.h" +#include "devicedefinitions/GPSDefinitions.h" #include "fsfw/datapool/PoolReadGuard.h" #include "fsfw/timemanager/Clock.h" @@ -17,165 +17,160 @@ #endif GPSHyperionHandler::GPSHyperionHandler(object_id_t objectId, object_id_t parentId, - bool debugHyperionGps): - ExtendedControllerBase(objectId, objects::NO_OBJECT), gpsSet(this), - debugHyperionGps(debugHyperionGps) { -} + bool debugHyperionGps) + : ExtendedControllerBase(objectId, objects::NO_OBJECT), + gpsSet(this), + debugHyperionGps(debugHyperionGps) {} GPSHyperionHandler::~GPSHyperionHandler() {} void GPSHyperionHandler::performControlOperation() { #ifdef FSFW_OSAL_LINUX - readGpsDataFromGpsd(); + readGpsDataFromGpsd(); #endif } -LocalPoolDataSetBase* GPSHyperionHandler::getDataSetHandle(sid_t sid) { - return nullptr; -} +LocalPoolDataSetBase *GPSHyperionHandler::getDataSetHandle(sid_t sid) { return nullptr; } ReturnValue_t GPSHyperionHandler::checkModeCommand(Mode_t mode, Submode_t submode, - uint32_t *msToReachTheMode) { - return HasReturnvaluesIF::RETURN_OK; + uint32_t *msToReachTheMode) { + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t GPSHyperionHandler::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; + 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; + } + return HasReturnvaluesIF::RETURN_OK; } -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::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::FIX_MODE, new PoolEntry()); - poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), true, 2.0, false); - return HasReturnvaluesIF::RETURN_OK; +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::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::FIX_MODE, new PoolEntry()); + poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), true, 2.0, false); + return HasReturnvaluesIF::RETURN_OK; } -void GPSHyperionHandler::setResetPinTriggerFunction(gpioResetFunction_t resetCallback, - void *args) { - this->resetCallback = resetCallback; - resetCallbackArgs = args; +void GPSHyperionHandler::setResetPinTriggerFunction(gpioResetFunction_t resetCallback, void *args) { + this->resetCallback = resetCallback; + resetCallbackArgs = args; } - ReturnValue_t GPSHyperionHandler::initialize() { - ReturnValue_t result = ExtendedControllerBase::initialize(); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + ReturnValue_t result = ExtendedControllerBase::initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { return result; + } + return result; } ReturnValue_t GPSHyperionHandler::handleCommandMessage(CommandMessage *message) { - return ExtendedControllerBase::handleCommandMessage(message); + return ExtendedControllerBase::handleCommandMessage(message); } #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 - gpsmm gpsmm(GPSD_SHARED_MEMORY, 0); - gps_data_t* gps; - gps = gpsmm.read(); - if(gps == nullptr) { - sif::warning << "Q7STestTask: Reading GPS data failed" << std::endl; - } - PoolReadGuard pg(&gpsSet); - if(pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) { + // 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); + gps_data_t *gps; + gps = gpsmm.read(); + if (gps == nullptr) { + sif::warning << "Q7STestTask: 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::scanForReply: 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; - } + } + // Print messages + if ((gps->set & MODE_SET) != MODE_SET) { + // Could not even set mode + gpsSet.setValidity(false, true); + return; + } - if(gps->satellites_used > 0) { - gpsSet.setValidity(true, true); - } + if (gps->satellites_used > 0) { + gpsSet.setValidity(true, true); + } - gpsSet.satInUse.value = gps->satellites_used; - gpsSet.satInView.value = gps->satellites_visible; + 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; - } else { - gpsSet.latitude.setValid(false); - } + // 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; + } 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.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.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); - } + 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; - 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; - } + 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; + 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 96d6089e..026e1779 100644 --- a/mission/devices/GPSHyperionHandler.h +++ b/mission/devices/GPSHyperionHandler.h @@ -1,10 +1,10 @@ #ifndef MISSION_DEVICES_GPSHYPERIONHANDLER_H_ #define MISSION_DEVICES_GPSHYPERIONHANDLER_H_ -#include "fsfw/FSFW.h" -#include "fsfw/devicehandlers/DeviceHandlerBase.h" -#include "fsfw/controller/ExtendedControllerBase.h" #include "devicedefinitions/GPSDefinitions.h" +#include "fsfw/FSFW.h" +#include "fsfw/controller/ExtendedControllerBase.h" +#include "fsfw/devicehandlers/DeviceHandlerBase.h" /** * @brief Device handler for the Hyperion HT-GPS200 device @@ -12,38 +12,35 @@ * Flight manual: * https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/Hyperion_HT-GPS200 */ -class GPSHyperionHandler: public ExtendedControllerBase { -public: +class GPSHyperionHandler : public ExtendedControllerBase { + public: + GPSHyperionHandler(object_id_t objectId, object_id_t parentId, bool debugHyperionGps = false); + virtual ~GPSHyperionHandler(); - GPSHyperionHandler(object_id_t objectId, object_id_t parentId, - 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 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; - 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: + protected: + gpioResetFunction_t resetCallback = nullptr; + void* resetCallbackArgs = nullptr; - gpioResetFunction_t resetCallback = nullptr; - void* resetCallbackArgs = nullptr; + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) override; + private: + GpsPrimaryDataset gpsSet; + bool debugHyperionGps = false; -private: - GpsPrimaryDataset gpsSet; - bool debugHyperionGps = false; - - void readGpsDataFromGpsd(); + void readGpsDataFromGpsd(); }; #endif /* MISSION_DEVICES_GPSHYPERIONHANDLER_H_ */ diff --git a/mission/devices/GomspaceDeviceHandler.cpp b/mission/devices/GomspaceDeviceHandler.cpp index 95e35a5e..eea1368a 100644 --- a/mission/devices/GomspaceDeviceHandler.cpp +++ b/mission/devices/GomspaceDeviceHandler.cpp @@ -2,411 +2,397 @@ #include GomspaceDeviceHandler::GomspaceDeviceHandler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie, uint16_t maxConfigTableAddress, uint16_t maxHkTableAddress, - uint16_t hkTableReplySize, LocalPoolDataSetBase* hkTableDataset) : - DeviceHandlerBase(objectId, comIF, comCookie), maxConfigTableAddress(maxConfigTableAddress), - maxHkTableAddress(maxHkTableAddress), hkTableReplySize(hkTableReplySize), - hkTableDataset(hkTableDataset) { - if (comCookie == nullptr) { - sif::error << "GomspaceDeviceHandler::GomspaceDeviceHandler: Invalid com cookie" - << std::endl; - } - if (hkTableDataset == nullptr) { - sif::error << "GomspaceDeviceHandler::GomspaceDeviceHandler: Invalid hk table data set" - << std::endl; - } + CookieIF* comCookie, uint16_t maxConfigTableAddress, + uint16_t maxHkTableAddress, uint16_t hkTableReplySize, + LocalPoolDataSetBase* hkTableDataset) + : DeviceHandlerBase(objectId, comIF, comCookie), + maxConfigTableAddress(maxConfigTableAddress), + maxHkTableAddress(maxHkTableAddress), + hkTableReplySize(hkTableReplySize), + hkTableDataset(hkTableDataset) { + if (comCookie == nullptr) { + sif::error << "GomspaceDeviceHandler::GomspaceDeviceHandler: Invalid com cookie" << std::endl; + } + if (hkTableDataset == nullptr) { + sif::error << "GomspaceDeviceHandler::GomspaceDeviceHandler: Invalid hk table data set" + << std::endl; + } } -GomspaceDeviceHandler::~GomspaceDeviceHandler() { +GomspaceDeviceHandler::~GomspaceDeviceHandler() {} + +void GomspaceDeviceHandler::doStartUp() {} + +void GomspaceDeviceHandler::doShutDown() {} + +ReturnValue_t GomspaceDeviceHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + return HasReturnvaluesIF::RETURN_OK; } - -void GomspaceDeviceHandler::doStartUp(){ +ReturnValue_t GomspaceDeviceHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { + return HasReturnvaluesIF::RETURN_OK; } -void GomspaceDeviceHandler::doShutDown(){ - -} - -ReturnValue_t GomspaceDeviceHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t GomspaceDeviceHandler::buildTransitionDeviceCommand( - DeviceCommandId_t * id){ - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t GomspaceDeviceHandler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t * commandData, - size_t commandDataLen) { - ReturnValue_t result; - switch(deviceCommand) { - case(GOMSPACE::PING): { - result = generatePingCommand(commandData, commandDataLen); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - break; +ReturnValue_t GomspaceDeviceHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t* commandData, + size_t commandDataLen) { + ReturnValue_t result; + switch (deviceCommand) { + case (GOMSPACE::PING): { + result = generatePingCommand(commandData, commandDataLen); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + break; } - case(GOMSPACE::REBOOT): { - generateRebootCommand(); - break; + case (GOMSPACE::REBOOT): { + generateRebootCommand(); + break; } - case(GOMSPACE::PARAM_SET):{ - result = generateSetParamCommand(commandData, commandDataLen); - if(result != HasReturnvaluesIF::RETURN_OK){ - return result; - } - break; + case (GOMSPACE::PARAM_SET): { + result = generateSetParamCommand(commandData, commandDataLen); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + break; } - case(GOMSPACE::PARAM_GET):{ - result = generateGetParamCommand(commandData, commandDataLen); - if(result != HasReturnvaluesIF::RETURN_OK){ - return result; - } - break; + case (GOMSPACE::PARAM_GET): { + result = generateGetParamCommand(commandData, commandDataLen); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + break; } - case(GOMSPACE::GNDWDT_RESET): { - result = generateResetWatchdogCmd(); - if(result != HasReturnvaluesIF::RETURN_OK){ - return result; - } - break; + case (GOMSPACE::GNDWDT_RESET): { + result = generateResetWatchdogCmd(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + break; } - case(GOMSPACE::PRINT_SWITCH_V_I): { - result = printStatus(deviceCommand); - break; + case (GOMSPACE::PRINT_SWITCH_V_I): { + result = printStatus(deviceCommand); + break; } - case(GOMSPACE::REQUEST_HK_TABLE): { - result = generateRequestFullHkTableCmd(hkTableReplySize); - if(result != HasReturnvaluesIF::RETURN_OK){ - return result; - } - break; + case (GOMSPACE::REQUEST_HK_TABLE): { + result = generateRequestFullHkTableCmd(hkTableReplySize); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + break; } default: - return deviceSpecificCommand(deviceCommand); - } - return HasReturnvaluesIF::RETURN_OK; + return deviceSpecificCommand(deviceCommand); + } + return HasReturnvaluesIF::RETURN_OK; } -void GomspaceDeviceHandler::fillCommandAndReplyMap(){ - this->insertInCommandAndReplyMap(GOMSPACE::PING, 3); - this->insertInCommandMap(GOMSPACE::REBOOT); - this->insertInCommandAndReplyMap(GOMSPACE::PARAM_SET, 3); - this->insertInCommandAndReplyMap(GOMSPACE::PARAM_GET, 3); - this->insertInCommandAndReplyMap(GOMSPACE::REQUEST_HK_TABLE, 3); - this->insertInCommandMap(GOMSPACE::GNDWDT_RESET); - this->insertInCommandMap(GOMSPACE::PRINT_SWITCH_V_I); +void GomspaceDeviceHandler::fillCommandAndReplyMap() { + this->insertInCommandAndReplyMap(GOMSPACE::PING, 3); + this->insertInCommandMap(GOMSPACE::REBOOT); + this->insertInCommandAndReplyMap(GOMSPACE::PARAM_SET, 3); + this->insertInCommandAndReplyMap(GOMSPACE::PARAM_GET, 3); + this->insertInCommandAndReplyMap(GOMSPACE::REQUEST_HK_TABLE, 3); + this->insertInCommandMap(GOMSPACE::GNDWDT_RESET); + this->insertInCommandMap(GOMSPACE::PRINT_SWITCH_V_I); } -ReturnValue_t GomspaceDeviceHandler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { - switch(rememberCommandId) { - case(GOMSPACE::PING): - *foundId = GOMSPACE::PING; - *foundLen = PING_REPLY_SIZE; - rememberCommandId = GOMSPACE::NONE; - break; - case(GOMSPACE::PARAM_GET): { - *foundId = GOMSPACE::PARAM_GET; - *foundLen = rememberRequestedSize + GOMSPACE::GS_HDR_LENGTH; - rememberCommandId = GOMSPACE::NONE; - break; +ReturnValue_t GomspaceDeviceHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + switch (rememberCommandId) { + case (GOMSPACE::PING): + *foundId = GOMSPACE::PING; + *foundLen = PING_REPLY_SIZE; + rememberCommandId = GOMSPACE::NONE; + break; + case (GOMSPACE::PARAM_GET): { + *foundId = GOMSPACE::PARAM_GET; + *foundLen = rememberRequestedSize + GOMSPACE::GS_HDR_LENGTH; + rememberCommandId = GOMSPACE::NONE; + break; } - case(GOMSPACE::PARAM_SET): { - *foundId = GOMSPACE::PARAM_SET; - *foundLen = rememberRequestedSize; - rememberCommandId = GOMSPACE::NONE; - break; + case (GOMSPACE::PARAM_SET): { + *foundId = GOMSPACE::PARAM_SET; + *foundLen = rememberRequestedSize; + rememberCommandId = GOMSPACE::NONE; + break; } - case(GOMSPACE::REQUEST_HK_TABLE): { - *foundId = GOMSPACE::REQUEST_HK_TABLE; - *foundLen = rememberRequestedSize + GOMSPACE::GS_HDR_LENGTH; - rememberCommandId = GOMSPACE::NONE; - break; + case (GOMSPACE::REQUEST_HK_TABLE): { + *foundId = GOMSPACE::REQUEST_HK_TABLE; + *foundLen = rememberRequestedSize + GOMSPACE::GS_HDR_LENGTH; + rememberCommandId = GOMSPACE::NONE; + break; } default: - return IGNORE_REPLY_DATA; - } - return HasReturnvaluesIF::RETURN_OK; + return IGNORE_REPLY_DATA; + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t GomspaceDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { - switch(id) { - case(GOMSPACE::PING): { - SerializeElement replyTime = *packet; - handleDeviceTM(&replyTime, id, true); - break; + const uint8_t* packet) { + switch (id) { + case (GOMSPACE::PING): { + SerializeElement replyTime = *packet; + handleDeviceTM(&replyTime, id, true); + break; } - case(GOMSPACE::PARAM_GET): { - // -2 to subtract address size from gomspace parameter reply packet - uint16_t payloadLength = (*(packet + 2) << 8 | *(packet + 3)) - 2; - if(payloadLength > sizeof(uint32_t)){ - sif::error << "GomspaceDeviceHandler: PARAM_GET: Invalid payload " - << "size in reply" << std::endl; - return INVALID_PAYLOAD_SIZE; - } - uint8_t tempPayloadBuffer[payloadLength]; - /* Extract information from received data */ - CspGetParamReply cspGetParamReply(tempPayloadBuffer, payloadLength); - size_t size = GOMSPACE::GS_HDR_LENGTH + payloadLength; - ReturnValue_t result = cspGetParamReply.deSerialize(&packet, &size, - SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "GomspaceDeviceHandler: Failed to deserialize get parameter" - << "reply" << std::endl; - return result; - } - uint8_t action = cspGetParamReply.getAction(); - uint8_t tableId = cspGetParamReply.getTableId(); - uint16_t address = cspGetParamReply.getAddress(); - /* Pack relevant information into a tm packet */ - ParamReply paramReply(action, tableId, address, payloadLength, - tempPayloadBuffer); - handleDeviceTM(¶mReply, id, true); - break; + case (GOMSPACE::PARAM_GET): { + // -2 to subtract address size from gomspace parameter reply packet + uint16_t payloadLength = (*(packet + 2) << 8 | *(packet + 3)) - 2; + if (payloadLength > sizeof(uint32_t)) { + sif::error << "GomspaceDeviceHandler: PARAM_GET: Invalid payload " + << "size in reply" << std::endl; + return INVALID_PAYLOAD_SIZE; + } + uint8_t tempPayloadBuffer[payloadLength]; + /* Extract information from received data */ + CspGetParamReply cspGetParamReply(tempPayloadBuffer, payloadLength); + size_t size = GOMSPACE::GS_HDR_LENGTH + payloadLength; + ReturnValue_t result = + cspGetParamReply.deSerialize(&packet, &size, SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomspaceDeviceHandler: Failed to deserialize get parameter" + << "reply" << std::endl; + return result; + } + uint8_t action = cspGetParamReply.getAction(); + uint8_t tableId = cspGetParamReply.getTableId(); + uint16_t address = cspGetParamReply.getAddress(); + /* Pack relevant information into a tm packet */ + ParamReply paramReply(action, tableId, address, payloadLength, tempPayloadBuffer); + handleDeviceTM(¶mReply, id, true); + break; } - case(GOMSPACE::PARAM_SET): { - /* When setting a parameter, the p60dock sends back the state of the - * operation */ - if(*packet != PARAM_SET_OK){ - return HasReturnvaluesIF::RETURN_FAILED; - } - break; + case (GOMSPACE::PARAM_SET): { + /* When setting a parameter, the p60dock sends back the state of the + * operation */ + if (*packet != PARAM_SET_OK) { + return HasReturnvaluesIF::RETURN_FAILED; + } + break; } - case(GOMSPACE::REQUEST_HK_TABLE): { - letChildHandleHkReply(id, packet); - break; + case (GOMSPACE::REQUEST_HK_TABLE): { + letChildHandleHkReply(id, packet); + break; } default: - break; - } - return HasReturnvaluesIF::RETURN_OK; + break; + } + return HasReturnvaluesIF::RETURN_OK; } -void GomspaceDeviceHandler::setNormalDatapoolEntriesInvalid(){ +void GomspaceDeviceHandler::setNormalDatapoolEntriesInvalid() {} +ReturnValue_t GomspaceDeviceHandler::generateSetParamCommand(const uint8_t* commandData, + size_t commandDataLen) { + SetParamMessageUnpacker setParamMessageUnpacker; + ReturnValue_t result = setParamMessageUnpacker.deSerialize(&commandData, &commandDataLen, + SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomspaceDeviceHandler: Failed to deserialize set parameter " + "message" + << std::endl; + return result; + } + /* Get and check address */ + uint16_t address = setParamMessageUnpacker.getAddress(); + if (address > maxConfigTableAddress) { + sif::error << "GomspaceDeviceHandler: Invalid address for set parameter " + << "action" << std::endl; + return INVALID_ADDRESS; + } + uint16_t checksum = GOMSPACE::IGNORE_CHECKSUM; + uint16_t seq = 0; + 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(); + uint16_t payloadlength = sizeof(address) + parameterSize; + + /* Generate command for CspComIF */ + CspSetParamCommand setParamCmd(querySize, payloadlength, checksum, seq, total, address, + parameterPtr, parameterSize); + size_t cspPacketLen = 0; + uint8_t* buffer = cspPacket; + result = setParamCmd.serialize(&buffer, &cspPacketLen, sizeof(cspPacket), + SerializeIF::Endianness::BIG); + + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomspaceDeviceHandler: Failed to serialize command for " + << "CspComIF" << std::endl; + return result; + } + if (cspPacketLen > MAX_PACKET_LEN) { + sif::error << "GomspaceDeviceHandler: Invalid length of set parameter " + "command" + << std::endl; + return PACKET_TOO_LONG; + } + rawPacket = cspPacket; + rawPacketLen = cspPacketLen; + rememberRequestedSize = querySize; + rememberCommandId = GOMSPACE::PARAM_SET; + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t GomspaceDeviceHandler::generateSetParamCommand( - const uint8_t * commandData, size_t commandDataLen) { - SetParamMessageUnpacker setParamMessageUnpacker; - ReturnValue_t result = setParamMessageUnpacker.deSerialize(&commandData, - &commandDataLen, SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "GomspaceDeviceHandler: Failed to deserialize set parameter " - "message" << std::endl; - return result; - } - /* Get and check address */ - uint16_t address = setParamMessageUnpacker.getAddress(); - if(address > maxConfigTableAddress){ - sif::error << "GomspaceDeviceHandler: Invalid address for set parameter " - << "action" << std::endl; - return INVALID_ADDRESS; - } - uint16_t checksum = GOMSPACE::IGNORE_CHECKSUM; - uint16_t seq = 0; - 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(); - uint16_t payloadlength = sizeof(address) + parameterSize; +ReturnValue_t GomspaceDeviceHandler::generateGetParamCommand(const uint8_t* commandData, + size_t commandDataLen) { + ReturnValue_t result; + /* Unpack the received action message */ + GetParamMessageUnpacker getParamMessage; + result = getParamMessage.deSerialize(&commandData, &commandDataLen, SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Failed to deserialize message to extract information " + "from get parameter message" + << std::endl; + return result; + } + /* Get an check table id to read from */ + uint8_t tableId = getParamMessage.getTableId(); + if (tableId != CONFIG_TABLE_ID && tableId != HK_TABLE_ID) { + sif::error << "GomspaceDeviceHandler: Invalid table id in get parameter" + " message" + << std::endl; + return INVALID_TABLE_ID; + } + /* Get and check address */ + uint16_t address = getParamMessage.getAddress(); + if (address > maxHkTableAddress && tableId == HK_TABLE_ID) { + sif::error << "GomspaceDeviceHandler: Invalid address to get parameter from " + << "housekeeping table" << std::endl; + return INVALID_ADDRESS; + } + if (address > maxConfigTableAddress && tableId == CONFIG_TABLE_ID) { + sif::error << "GomspaceDeviceHandler: Invalid address to get parameter from " + << "configuration table" << std::endl; + return INVALID_ADDRESS; + } + uint16_t length = sizeof(address); + uint16_t checksum = GOMSPACE::IGNORE_CHECKSUM; + uint16_t seq = 0; + uint16_t total = 0; + uint8_t parameterSize = getParamMessage.getParameterSize(); + if (parameterSize > sizeof(uint32_t)) { + sif::error << "GomspaceDeviceHandler: GET_PARAM: Invalid parameter " + << "size" << std::endl; + return INVALID_PARAM_SIZE; + } + uint16_t querySize = parameterSize + GOMSPACE::GS_HDR_LENGTH; - /* Generate command for CspComIF */ - CspSetParamCommand setParamCmd(querySize, payloadlength, checksum, seq, - total, address, parameterPtr, parameterSize); - size_t cspPacketLen = 0; - uint8_t* buffer = cspPacket; - result = setParamCmd.serialize(&buffer, &cspPacketLen, sizeof(cspPacket), - SerializeIF::Endianness::BIG); - - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "GomspaceDeviceHandler: Failed to serialize command for " - << "CspComIF" << std::endl; - return result; - } - if(cspPacketLen > MAX_PACKET_LEN){ - sif::error << "GomspaceDeviceHandler: Invalid length of set parameter " - "command" << std::endl; - return PACKET_TOO_LONG; - } - rawPacket = cspPacket; - rawPacketLen = cspPacketLen; - rememberRequestedSize = querySize; - rememberCommandId = GOMSPACE::PARAM_SET; - return HasReturnvaluesIF::RETURN_OK; + /* Generate the CSP command to send to the P60 Dock */ + CspGetParamCommand getParamCmd(querySize, tableId, length, checksum, seq, total, address); + size_t cspPacketLen = 0; + uint8_t* buffer = cspPacket; + result = getParamCmd.serialize(&buffer, &cspPacketLen, sizeof(cspPacket), + SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomspaceDeviceHandler: Failed to serialize command to " + << "get parameter" << std::endl; + } + if (cspPacketLen > MAX_PACKET_LEN) { + sif::error << "GomspaceDeviceHandler: Received invalid get parameter " + "command" + << std::endl; + return PACKET_TOO_LONG; + } + rawPacket = cspPacket; + rawPacketLen = cspPacketLen; + rememberRequestedSize = querySize; + rememberCommandId = GOMSPACE::PARAM_GET; + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t GomspaceDeviceHandler::generateGetParamCommand( - const uint8_t * commandData, size_t commandDataLen){ - ReturnValue_t result; - /* Unpack the received action message */ - GetParamMessageUnpacker getParamMessage; - result = getParamMessage.deSerialize(&commandData, &commandDataLen, - SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Failed to deserialize message to extract information " - "from get parameter message" << std::endl; - return result; - } - /* Get an check table id to read from */ - uint8_t tableId = getParamMessage.getTableId(); - if(tableId != CONFIG_TABLE_ID && tableId != HK_TABLE_ID){ - sif::error << "GomspaceDeviceHandler: Invalid table id in get parameter" - " message" << std::endl; - return INVALID_TABLE_ID; - } - /* Get and check address */ - uint16_t address = getParamMessage.getAddress(); - if(address > maxHkTableAddress && tableId == HK_TABLE_ID){ - sif::error << "GomspaceDeviceHandler: Invalid address to get parameter from " - << "housekeeping table" << std::endl; - return INVALID_ADDRESS; - } - if(address > maxConfigTableAddress && tableId == CONFIG_TABLE_ID){ - sif::error << "GomspaceDeviceHandler: Invalid address to get parameter from " - << "configuration table" << std::endl; - return INVALID_ADDRESS; - } - uint16_t length = sizeof(address); - uint16_t checksum = GOMSPACE::IGNORE_CHECKSUM; - uint16_t seq = 0; - uint16_t total = 0; - uint8_t parameterSize = getParamMessage.getParameterSize(); - if(parameterSize > sizeof(uint32_t)) { - sif::error << "GomspaceDeviceHandler: GET_PARAM: Invalid parameter " - << "size" << std::endl; - return INVALID_PARAM_SIZE; - } - uint16_t querySize = parameterSize + GOMSPACE::GS_HDR_LENGTH; - - /* Generate the CSP command to send to the P60 Dock */ - CspGetParamCommand getParamCmd(querySize, tableId, length, - checksum, seq, total, address); - size_t cspPacketLen = 0; - uint8_t* buffer = cspPacket; - result = getParamCmd.serialize(&buffer, &cspPacketLen, sizeof(cspPacket), - SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "GomspaceDeviceHandler: Failed to serialize command to " - << "get parameter" << std::endl; - } - if(cspPacketLen > MAX_PACKET_LEN){ - sif::error << "GomspaceDeviceHandler: Received invalid get parameter " - "command" << std::endl; - return PACKET_TOO_LONG; - } - rawPacket = cspPacket; - rawPacketLen = cspPacketLen; - rememberRequestedSize = querySize; - rememberCommandId = GOMSPACE::PARAM_GET; - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t GomspaceDeviceHandler::generatePingCommand(const uint8_t* commandData, + size_t commandDataLen) { + CspPingCommand cspPingCommand(commandData, commandDataLen); + size_t cspPacketLen = 0; + uint8_t* buffer = cspPacket; + ReturnValue_t result = cspPingCommand.serialize(&buffer, &cspPacketLen, sizeof(cspPacket), + SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomspaceDeviceHandler: Failed to serialize ping command" << std::endl; + return result; + } + if (cspPacketLen > MAX_PACKET_LEN) { + sif::error << "GomspaceDeviceHandler: Received invalid ping message" << std::endl; + return PACKET_TOO_LONG; + } + rawPacket = cspPacket; + rawPacketLen = cspPacketLen; + rememberCommandId = GOMSPACE::PING; + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t GomspaceDeviceHandler::generatePingCommand( - const uint8_t * commandData, size_t commandDataLen) { - CspPingCommand cspPingCommand(commandData, commandDataLen); - size_t cspPacketLen = 0; - uint8_t* buffer = cspPacket; - ReturnValue_t result = cspPingCommand.serialize(&buffer, &cspPacketLen, - sizeof(cspPacket), - SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "GomspaceDeviceHandler: Failed to serialize ping command" - << std::endl; - return result; - } - if(cspPacketLen > MAX_PACKET_LEN){ - sif::error << "GomspaceDeviceHandler: Received invalid ping message" - << std::endl; - return PACKET_TOO_LONG; - } - rawPacket = cspPacket; - rawPacketLen = cspPacketLen; - rememberCommandId = GOMSPACE::PING; - return HasReturnvaluesIF::RETURN_OK; +void GomspaceDeviceHandler::generateRebootCommand() { + uint8_t cspPort = GOMSPACE::REBOOT_PORT; + uint16_t querySize = 0; + *cspPacket = GOMSPACE::REBOOT_PORT; + *(cspPacket + 1) = querySize; + size_t cspPacketLen = sizeof(cspPort) + sizeof(cspPacketLen); + rawPacket = cspPacket; + rawPacketLen = cspPacketLen; } -void GomspaceDeviceHandler::generateRebootCommand(){ - uint8_t cspPort = GOMSPACE::REBOOT_PORT; - uint16_t querySize = 0; - *cspPacket = GOMSPACE::REBOOT_PORT; - *(cspPacket + 1) = querySize; - size_t cspPacketLen = sizeof(cspPort) + sizeof(cspPacketLen); - rawPacket = cspPacket; - rawPacketLen = cspPacketLen; -} - -ReturnValue_t GomspaceDeviceHandler::generateResetWatchdogCmd(){ - WatchdogResetCommand watchdogResetCommand; - size_t cspPacketLen = 0; - uint8_t* buffer = cspPacket; - ReturnValue_t result = watchdogResetCommand.serialize(&buffer, - &cspPacketLen, sizeof(cspPacket), SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "GomspaceDeviceHandler: Failed to serialize watchdog reset " - << "command" << std::endl; - return result; - } - rawPacket = cspPacket; - rawPacketLen = cspPacketLen; - rememberRequestedSize = 0; // No bytes will be queried with the ground - // watchdog command. - rememberCommandId = GOMSPACE::GNDWDT_RESET; - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t GomspaceDeviceHandler::generateResetWatchdogCmd() { + WatchdogResetCommand watchdogResetCommand; + size_t cspPacketLen = 0; + uint8_t* buffer = cspPacket; + ReturnValue_t result = watchdogResetCommand.serialize(&buffer, &cspPacketLen, sizeof(cspPacket), + SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomspaceDeviceHandler: Failed to serialize watchdog reset " + << "command" << std::endl; + return result; + } + rawPacket = cspPacket; + rawPacketLen = cspPacketLen; + rememberRequestedSize = 0; // No bytes will be queried with the ground + // watchdog command. + rememberCommandId = GOMSPACE::GNDWDT_RESET; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t GomspaceDeviceHandler::generateRequestFullHkTableCmd(uint16_t hkTableReplySize) { + uint16_t querySize = hkTableReplySize; + uint8_t tableId = HK_TABLE_ID; + RequestFullTableCommand requestFullTableCommand(querySize, tableId); - uint16_t querySize = hkTableReplySize; - uint8_t tableId = HK_TABLE_ID; - RequestFullTableCommand requestFullTableCommand(querySize, tableId); - - size_t cspPacketLen = 0; - uint8_t* buffer = cspPacket; - ReturnValue_t result = requestFullTableCommand.serialize(&buffer, - &cspPacketLen, sizeof(cspPacket), SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "GomspaceDeviceHandler::generateRequestFullHkTableCmd Failed to serialize " - "full table request command " << std::endl; - return result; - } - rawPacket = cspPacket; - rawPacketLen = cspPacketLen; - rememberRequestedSize = querySize; - rememberCommandId = GOMSPACE::REQUEST_HK_TABLE; - return RETURN_OK; + size_t cspPacketLen = 0; + uint8_t* buffer = cspPacket; + ReturnValue_t result = requestFullTableCommand.serialize( + &buffer, &cspPacketLen, sizeof(cspPacket), SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomspaceDeviceHandler::generateRequestFullHkTableCmd Failed to serialize " + "full table request command " + << std::endl; + return result; + } + rawPacket = cspPacket; + rawPacketLen = cspPacketLen; + rememberRequestedSize = querySize; + rememberCommandId = GOMSPACE::REQUEST_HK_TABLE; + return RETURN_OK; } -uint32_t GomspaceDeviceHandler::getTransitionDelayMs(Mode_t modeFrom, - Mode_t modeTo) { - return 0; -} +uint32_t GomspaceDeviceHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 0; } LocalPoolDataSetBase* GomspaceDeviceHandler::getDataSetHandle(sid_t sid) { - if(sid == hkTableDataset->getSid()) { - return hkTableDataset; - } - else { - return nullptr; - } + if (sid == hkTableDataset->getSid()) { + return hkTableDataset; + } else { + return nullptr; + } } ReturnValue_t GomspaceDeviceHandler::deviceSpecificCommand(DeviceCommandId_t cmd) { - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } -void GomspaceDeviceHandler::setModeNormal() { - mode = MODE_NORMAL; -} +void GomspaceDeviceHandler::setModeNormal() { mode = MODE_NORMAL; } ReturnValue_t GomspaceDeviceHandler::printStatus(DeviceCommandId_t cmd) { - sif::info << "No printHkTable implementation given.." << std::endl; - return HasReturnvaluesIF::RETURN_OK; + sif::info << "No printHkTable implementation given.." << std::endl; + return HasReturnvaluesIF::RETURN_OK; } diff --git a/mission/devices/GomspaceDeviceHandler.h b/mission/devices/GomspaceDeviceHandler.h index 29156fce..c9c08609 100644 --- a/mission/devices/GomspaceDeviceHandler.h +++ b/mission/devices/GomspaceDeviceHandler.h @@ -16,135 +16,125 @@ * Flight manual: * https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/Gomspace_PCDU_P60_System */ -class GomspaceDeviceHandler: public DeviceHandlerBase { -public: +class GomspaceDeviceHandler : public DeviceHandlerBase { + public: + static constexpr uint8_t CLASS_ID = CLASS_ID::GOM_SPACE_HANDLER; + static const ReturnValue_t PACKET_TOO_LONG = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 0); + static const ReturnValue_t INVALID_TABLE_ID = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 1); + static const ReturnValue_t INVALID_ADDRESS = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 2); + static const ReturnValue_t INVALID_PARAM_SIZE = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 3); + static const ReturnValue_t INVALID_PAYLOAD_SIZE = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 4); + static const ReturnValue_t UNKNOWN_REPLY_ID = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 5); - static constexpr uint8_t CLASS_ID = CLASS_ID::GOM_SPACE_HANDLER; - static const ReturnValue_t PACKET_TOO_LONG = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 0); - static const ReturnValue_t INVALID_TABLE_ID = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 1); - static const ReturnValue_t INVALID_ADDRESS = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 2); - static const ReturnValue_t INVALID_PARAM_SIZE = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 3); - static const ReturnValue_t INVALID_PAYLOAD_SIZE = - HasReturnvaluesIF::makeReturnCode(CLASS_ID, 4); - static const ReturnValue_t UNKNOWN_REPLY_ID = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 5); + /** + * @brief Constructor + * + * @param maxConfigTableAddress The maximum memory address of the configu- + * ration table of a gomspace device. + * @param maxHkTableAddress The maximum memory address of a value in the + * houskeeping (telemetry) table of a gomspace + * device. + */ + GomspaceDeviceHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie, + uint16_t maxConfigTableAddress, uint16_t maxHkTableAddress, + uint16_t hkTableReplySize, LocalPoolDataSetBase *hkTableDataset); + virtual ~GomspaceDeviceHandler(); - /** - * @brief Constructor - * - * @param maxConfigTableAddress The maximum memory address of the configu- - * ration table of a gomspace device. - * @param maxHkTableAddress The maximum memory address of a value in the - * houskeeping (telemetry) table of a gomspace - * device. - */ - GomspaceDeviceHandler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie, uint16_t maxConfigTableAddress, uint16_t maxHkTableAddress, - uint16_t hkTableReplySize, LocalPoolDataSetBase* hkTableDataset); - virtual ~GomspaceDeviceHandler(); + /** + * @brief This function can be used to set a gomspace device to normal mode immediately after + * object creation. + */ + void setModeNormal(); - /** - * @brief This function can be used to set a gomspace device to normal mode immediately after - * object creation. - */ - void setModeNormal(); + protected: + static const uint8_t MAX_PACKET_LEN = 36; + static const uint8_t PARAM_SET_OK = 1; + static const uint8_t PING_REPLY_SIZE = 2; + static const uint8_t CONFIG_TABLE_ID = 1; + static const uint8_t HK_TABLE_ID = 4; -protected: + uint8_t rememberRequestedSize = 0; + uint8_t rememberCommandId = GOMSPACE::NONE; + uint8_t cspPacket[MAX_PACKET_LEN]; - static const uint8_t MAX_PACKET_LEN = 36; - static const uint8_t PARAM_SET_OK = 1; - static const uint8_t PING_REPLY_SIZE = 2; - static const uint8_t CONFIG_TABLE_ID = 1; - static const uint8_t HK_TABLE_ID = 4; + uint16_t maxConfigTableAddress; + uint16_t maxHkTableAddress; - uint8_t rememberRequestedSize = 0; - uint8_t rememberCommandId = GOMSPACE::NONE; - uint8_t cspPacket[MAX_PACKET_LEN]; + /** The size of the reply following a full hk table request.*/ + uint16_t hkTableReplySize; - uint16_t maxConfigTableAddress; - uint16_t maxHkTableAddress; + LocalPoolDataSetBase *hkTableDataset = nullptr; - /** The size of the reply following a full hk table request.*/ - uint16_t hkTableReplySize; + void doStartUp() override; + void doShutDown() override; + virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; + virtual 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; + /** + * @brief The command to generate a request to receive the full housekeeping table is device + * specific. Thus the child has to build this command. + */ + virtual ReturnValue_t generateRequestFullHkTableCmd(uint16_t hkTableSize); - LocalPoolDataSetBase* hkTableDataset = nullptr; + /** + * This command handles printing the HK table to the console. This is useful for debugging + * purposes + * @return + */ + virtual ReturnValue_t printStatus(DeviceCommandId_t cmd); - void doStartUp() override; - void doShutDown() override; - virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) - override; - ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override; - virtual 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; - /** - * @brief The command to generate a request to receive the full housekeeping table is device - * specific. Thus the child has to build this command. - */ - virtual ReturnValue_t generateRequestFullHkTableCmd(uint16_t hkTableSize); + /** + * @brief Because housekeeping tables are device specific the handling of the reply is + * given to the child class. + * @param id The id of the command which initiates the full table request. + * @param packet Pointer to the reply containing the hk table. + */ + virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) = 0; - /** - * This command handles printing the HK table to the console. This is useful for debugging - * purposes - * @return - */ - virtual ReturnValue_t printStatus(DeviceCommandId_t cmd); + virtual LocalPoolDataSetBase *getDataSetHandle(sid_t sid) override; - /** - * @brief Because housekeeping tables are device specific the handling of the reply is - * given to the child class. - * @param id The id of the command which initiates the full table request. - * @param packet Pointer to the reply containing the hk table. - */ - virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) = 0; + /** + * @brief Can be used by gomspace devices to implement device specific commands. + */ + virtual ReturnValue_t deviceSpecificCommand(DeviceCommandId_t cmd); - virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + private: + /** + * @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); - /** - * @brief Can be used by gomspace devices to implement device specific commands. - */ - virtual ReturnValue_t deviceSpecificCommand(DeviceCommandId_t cmd); + /** + * @brief Function to generate the command to get a parameter from a + * gomspace device. Command will be sent to the ComIF over the + * rawPacket buffer. + */ + ReturnValue_t generateGetParamCommand(const uint8_t *commandData, size_t commandDataLen); -private: + /** + * @brief Function to generate the ping command for the ComIF. + */ + ReturnValue_t generatePingCommand(const uint8_t *commandData, size_t commandDataLen); - /** - * @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); - - /** - * @brief Function to generate the command to get a parameter from a - * gomspace device. Command will be sent to the ComIF over the - * rawPacket buffer. - */ - ReturnValue_t generateGetParamCommand(const uint8_t * commandData, - size_t commandDataLen); - - /** - * @brief Function to generate the ping command for the ComIF. - */ - ReturnValue_t generatePingCommand(const uint8_t * commandData, - size_t commandDataLen); - - /** - * @brief Function to generate the command to reboot a gomspace device - * via the ComIF. - */ - void generateRebootCommand(); - - /** - * @brief Function to generate the command to force a ground watchdog - * reset in a gomspace device. - */ - ReturnValue_t generateResetWatchdogCmd(); + /** + * @brief Function to generate the command to reboot a gomspace device + * via the ComIF. + */ + void generateRebootCommand(); + /** + * @brief Function to generate the command to force a ground watchdog + * reset in a gomspace device. + */ + ReturnValue_t generateResetWatchdogCmd(); }; #endif /* MISSION_DEVICES_GOMSPACEDEVICEHANDLER_H_ */ diff --git a/mission/devices/GyroADIS1650XHandler.cpp b/mission/devices/GyroADIS1650XHandler.cpp index 4820eefc..7ea76758 100644 --- a/mission/devices/GyroADIS1650XHandler.cpp +++ b/mission/devices/GyroADIS1650XHandler.cpp @@ -1,481 +1,482 @@ #include "GyroADIS1650XHandler.h" + #include #include #if OBSW_ADIS1650X_LINUX_COM_IF == 1 -#include "fsfw_hal/linux/utility.h" -#include "fsfw_hal/linux/spi/SpiCookie.h" -#include "fsfw_hal/linux/spi/SpiComIF.h" -#include "fsfw_hal/linux/UnixFileGuard.h" #include #include + +#include "fsfw_hal/linux/UnixFileGuard.h" +#include "fsfw_hal/linux/spi/SpiComIF.h" +#include "fsfw_hal/linux/spi/SpiCookie.h" +#include "fsfw_hal/linux/utility.h" #endif -GyroADIS1650XHandler::GyroADIS1650XHandler(object_id_t objectId, - object_id_t deviceCommunication, CookieIF * comCookie, ADIS1650X::Type type): - DeviceHandlerBase(objectId, deviceCommunication, comCookie), adisType(type), - primaryDataset(this), configDataset(this), breakCountdown() { +GyroADIS1650XHandler::GyroADIS1650XHandler(object_id_t objectId, object_id_t deviceCommunication, + CookieIF *comCookie, ADIS1650X::Type type) + : DeviceHandlerBase(objectId, deviceCommunication, comCookie), + adisType(type), + primaryDataset(this), + configDataset(this), + breakCountdown() { #if FSFW_HAL_ADIS1650X_GYRO_DEBUG == 1 - debugDivider = new PeriodicOperationDivider(5); + debugDivider = new PeriodicOperationDivider(5); #endif #if OBSW_ADIS1650X_LINUX_COM_IF == 1 - SpiCookie* cookie = dynamic_cast(comCookie); - if(cookie != nullptr) { - cookie->setCallbackMode(&spiSendCallback, this); - } + SpiCookie *cookie = dynamic_cast(comCookie); + if (cookie != nullptr) { + cookie->setCallbackMode(&spiSendCallback, this); + } #endif } void GyroADIS1650XHandler::doStartUp() { - // Initial 310 ms start up time after power-up - if(internalState == InternalState::STARTUP) { - if(not commandExecuted) { - breakCountdown.setTimeout(ADIS1650X::START_UP_TIME); - commandExecuted = true; - } - if(breakCountdown.hasTimedOut()) { - internalState = InternalState::CONFIG; - commandExecuted = false; - } + // Initial 310 ms start up time after power-up + if (internalState == InternalState::STARTUP) { + if (not commandExecuted) { + breakCountdown.setTimeout(ADIS1650X::START_UP_TIME); + commandExecuted = true; } + if (breakCountdown.hasTimedOut()) { + internalState = InternalState::CONFIG; + commandExecuted = false; + } + } - // Read all configuration registers first - if(internalState == InternalState::CONFIG) { - if(commandExecuted) { - commandExecuted = false; - internalState = InternalState::IDLE; - } + // Read all configuration registers first + if (internalState == InternalState::CONFIG) { + if (commandExecuted) { + commandExecuted = false; + internalState = InternalState::IDLE; } + } - if(internalState == InternalState::IDLE) { - setMode(MODE_NORMAL); - // setMode(MODE_ON); - } + if (internalState == InternalState::IDLE) { + setMode(MODE_NORMAL); + // setMode(MODE_ON); + } } void GyroADIS1650XHandler::doShutDown() { - commandExecuted = false; - setMode(_MODE_POWER_DOWN); + commandExecuted = false; + setMode(_MODE_POWER_DOWN); } ReturnValue_t GyroADIS1650XHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { - *id = ADIS1650X::READ_SENSOR_DATA; - return buildCommandFromCommand(*id, nullptr, 0); + *id = ADIS1650X::READ_SENSOR_DATA; + return buildCommandFromCommand(*id, nullptr, 0); } ReturnValue_t GyroADIS1650XHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { - switch(internalState) { - case(InternalState::CONFIG): { - *id = ADIS1650X::READ_OUT_CONFIG; - buildCommandFromCommand(*id, nullptr, 0); - break; + switch (internalState) { + case (InternalState::CONFIG): { + *id = ADIS1650X::READ_OUT_CONFIG; + buildCommandFromCommand(*id, nullptr, 0); + break; } - case(InternalState::STARTUP): { - return NOTHING_TO_SEND; - break; + case (InternalState::STARTUP): { + return NOTHING_TO_SEND; + break; } default: { - /* Might be a configuration error. */ - sif::debug << "GyroADIS16507Handler::buildTransitionDeviceCommand: " - "Unknown internal state!" << std::endl; - return HasReturnvaluesIF::RETURN_OK; + /* Might be a configuration error. */ + sif::debug << "GyroADIS16507Handler::buildTransitionDeviceCommand: " + "Unknown internal state!" + << std::endl; + return HasReturnvaluesIF::RETURN_OK; } - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t GyroADIS1650XHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t *commandData, size_t commandDataLen) { - switch(deviceCommand) { - case(ADIS1650X::READ_OUT_CONFIG): { - this->rawPacketLen = ADIS1650X::CONFIG_READOUT_SIZE; - uint8_t regList[5]; - regList[0] = ADIS1650X::DIAG_STAT_REG; - regList[1] = ADIS1650X::FILTER_CTRL_REG; - regList[2] = ADIS1650X::MSC_CTRL_REG; - regList[3] = ADIS1650X::DEC_RATE_REG; - regList[4] = ADIS1650X::PROD_ID_REG; - prepareReadCommand(regList, sizeof(regList)); - this->rawPacket = commandBuffer.data(); - break; + const uint8_t *commandData, + size_t commandDataLen) { + switch (deviceCommand) { + case (ADIS1650X::READ_OUT_CONFIG): { + this->rawPacketLen = ADIS1650X::CONFIG_READOUT_SIZE; + uint8_t regList[5]; + regList[0] = ADIS1650X::DIAG_STAT_REG; + regList[1] = ADIS1650X::FILTER_CTRL_REG; + regList[2] = ADIS1650X::MSC_CTRL_REG; + regList[3] = ADIS1650X::DEC_RATE_REG; + regList[4] = ADIS1650X::PROD_ID_REG; + prepareReadCommand(regList, sizeof(regList)); + this->rawPacket = commandBuffer.data(); + break; } - case(ADIS1650X::READ_SENSOR_DATA): { - if(breakCountdown.isBusy()) { - // A glob command is pending and sensor data can't be read currently - return NO_REPLY_EXPECTED; - } - std::memcpy(commandBuffer.data(), ADIS1650X::BURST_READ_ENABLE.data(), - ADIS1650X::BURST_READ_ENABLE.size()); - std::memset(commandBuffer.data() + 2, 0, 10 * 2); - this->rawPacketLen = ADIS1650X::SENSOR_READOUT_SIZE; - this->rawPacket = commandBuffer.data(); - break; + case (ADIS1650X::READ_SENSOR_DATA): { + if (breakCountdown.isBusy()) { + // A glob command is pending and sensor data can't be read currently + return NO_REPLY_EXPECTED; + } + std::memcpy(commandBuffer.data(), ADIS1650X::BURST_READ_ENABLE.data(), + ADIS1650X::BURST_READ_ENABLE.size()); + std::memset(commandBuffer.data() + 2, 0, 10 * 2); + this->rawPacketLen = ADIS1650X::SENSOR_READOUT_SIZE; + this->rawPacket = commandBuffer.data(); + break; } - case(ADIS1650X::SELF_TEST_SENSORS): { - if(breakCountdown.isBusy()) { - // Another glob command is pending - return HasActionsIF::IS_BUSY; - } - prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::SENSOR_SELF_TEST, 0x00); - breakCountdown.setTimeout(ADIS1650X::SELF_TEST_BREAK); - break; + case (ADIS1650X::SELF_TEST_SENSORS): { + if (breakCountdown.isBusy()) { + // Another glob command is pending + return HasActionsIF::IS_BUSY; + } + prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::SENSOR_SELF_TEST, 0x00); + breakCountdown.setTimeout(ADIS1650X::SELF_TEST_BREAK); + break; } - case(ADIS1650X::SELF_TEST_MEMORY): { - if(breakCountdown.isBusy()) { - // Another glob command is pending - return HasActionsIF::IS_BUSY; - } - prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FLASH_MEMORY_TEST, 0x00); - breakCountdown.setTimeout(ADIS1650X::FLASH_MEMORY_TEST_BREAK); - break; + case (ADIS1650X::SELF_TEST_MEMORY): { + if (breakCountdown.isBusy()) { + // Another glob command is pending + return HasActionsIF::IS_BUSY; + } + prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FLASH_MEMORY_TEST, 0x00); + breakCountdown.setTimeout(ADIS1650X::FLASH_MEMORY_TEST_BREAK); + break; } - case(ADIS1650X::UPDATE_NV_CONFIGURATION): { - if(breakCountdown.isBusy()) { - // Another glob command is pending - return HasActionsIF::IS_BUSY; - } - prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FLASH_MEMORY_UPDATE, 0x00); - breakCountdown.setTimeout(ADIS1650X::FLASH_MEMORY_UPDATE_BREAK); - break; + case (ADIS1650X::UPDATE_NV_CONFIGURATION): { + if (breakCountdown.isBusy()) { + // Another glob command is pending + return HasActionsIF::IS_BUSY; + } + prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FLASH_MEMORY_UPDATE, 0x00); + breakCountdown.setTimeout(ADIS1650X::FLASH_MEMORY_UPDATE_BREAK); + break; } - case(ADIS1650X::RESET_SENSOR_CONFIGURATION): { - if(breakCountdown.isBusy()) { - // Another glob command is pending - return HasActionsIF::IS_BUSY; - } - prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FACTORY_CALIBRATION, 0x00); - breakCountdown.setTimeout(ADIS1650X::FACTORY_CALIBRATION_BREAK); - break; + case (ADIS1650X::RESET_SENSOR_CONFIGURATION): { + if (breakCountdown.isBusy()) { + // Another glob command is pending + return HasActionsIF::IS_BUSY; + } + prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FACTORY_CALIBRATION, 0x00); + breakCountdown.setTimeout(ADIS1650X::FACTORY_CALIBRATION_BREAK); + break; } - case(ADIS1650X::SW_RESET): { - if(breakCountdown.isBusy()) { - // Another glob command is pending - return HasActionsIF::IS_BUSY; - } - prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::SOFTWARE_RESET, 0x00); - breakCountdown.setTimeout(ADIS1650X::SW_RESET_BREAK); - break; + case (ADIS1650X::SW_RESET): { + if (breakCountdown.isBusy()) { + // Another glob command is pending + return HasActionsIF::IS_BUSY; + } + prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::SOFTWARE_RESET, 0x00); + breakCountdown.setTimeout(ADIS1650X::SW_RESET_BREAK); + break; } - case(ADIS1650X::PRINT_CURRENT_CONFIGURATION): { + case (ADIS1650X::PRINT_CURRENT_CONFIGURATION): { #if OBSW_VERBOSE_LEVEL >= 1 - PoolReadGuard pg(&configDataset); - sif::info << "ADIS16507 Sensor configuration: DIAG_STAT: 0x" << std::hex << std::setw(4) << - std::setfill('0') << "0x" << configDataset.diagStatReg.value << std::endl; - sif::info << "MSC_CTRL: " << std::hex << std::setw(4) << "0x" << - configDataset.mscCtrlReg.value << " | FILT_CTRL: 0x" << - configDataset.filterSetting.value << " | DEC_RATE: 0x" << - configDataset.decRateReg.value << std::setfill(' ') << std::endl; + PoolReadGuard pg(&configDataset); + sif::info << "ADIS16507 Sensor configuration: DIAG_STAT: 0x" << std::hex << std::setw(4) + << std::setfill('0') << "0x" << configDataset.diagStatReg.value << std::endl; + sif::info << "MSC_CTRL: " << std::hex << std::setw(4) << "0x" + << configDataset.mscCtrlReg.value << " | FILT_CTRL: 0x" + << configDataset.filterSetting.value << " | DEC_RATE: 0x" + << configDataset.decRateReg.value << std::setfill(' ') << std::endl; #endif /* OBSW_VERBOSE_LEVEL >= 1 */ } - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } void GyroADIS1650XHandler::fillCommandAndReplyMap() { - insertInCommandAndReplyMap(ADIS1650X::READ_SENSOR_DATA, 1, &primaryDataset); - insertInCommandAndReplyMap(ADIS1650X::READ_OUT_CONFIG, 1, &configDataset); - insertInCommandAndReplyMap(ADIS1650X::SELF_TEST_SENSORS, 1); - insertInCommandAndReplyMap(ADIS1650X::SELF_TEST_MEMORY, 1); - insertInCommandAndReplyMap(ADIS1650X::UPDATE_NV_CONFIGURATION, 1); - insertInCommandAndReplyMap(ADIS1650X::RESET_SENSOR_CONFIGURATION, 1); - insertInCommandAndReplyMap(ADIS1650X::SW_RESET, 1); - insertInCommandAndReplyMap(ADIS1650X::PRINT_CURRENT_CONFIGURATION, 1); + insertInCommandAndReplyMap(ADIS1650X::READ_SENSOR_DATA, 1, &primaryDataset); + insertInCommandAndReplyMap(ADIS1650X::READ_OUT_CONFIG, 1, &configDataset); + insertInCommandAndReplyMap(ADIS1650X::SELF_TEST_SENSORS, 1); + insertInCommandAndReplyMap(ADIS1650X::SELF_TEST_MEMORY, 1); + insertInCommandAndReplyMap(ADIS1650X::UPDATE_NV_CONFIGURATION, 1); + insertInCommandAndReplyMap(ADIS1650X::RESET_SENSOR_CONFIGURATION, 1); + insertInCommandAndReplyMap(ADIS1650X::SW_RESET, 1); + insertInCommandAndReplyMap(ADIS1650X::PRINT_CURRENT_CONFIGURATION, 1); } ReturnValue_t GyroADIS1650XHandler::scanForReply(const uint8_t *start, size_t remainingSize, - DeviceCommandId_t *foundId, size_t *foundLen) { - // For SPI, the ID will always be the one of the last sent command - *foundId = this->getPendingCommand(); - *foundLen = this->rawPacketLen; + DeviceCommandId_t *foundId, size_t *foundLen) { + // For SPI, the ID will always be the one of the last sent command + *foundId = this->getPendingCommand(); + *foundLen = this->rawPacketLen; - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t GyroADIS1650XHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { - switch(id) { - case(ADIS1650X::READ_OUT_CONFIG): { - - uint16_t readProdId = packet[10] << 8 | packet[11]; - if(((adisType == ADIS1650X::Type::ADIS16507) and - (readProdId != ADIS1650X::PROD_ID_16507)) or - ((adisType == ADIS1650X::Type::ADIS16505) and - (readProdId != ADIS1650X::PROD_ID_16505))) { + const uint8_t *packet) { + switch (id) { + case (ADIS1650X::READ_OUT_CONFIG): { + uint16_t readProdId = packet[10] << 8 | packet[11]; + 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 - sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Invalid product ID " - << readProdId << std::endl; + sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Invalid product ID " + << readProdId << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; - } - PoolReadGuard rg(&configDataset); - configDataset.diagStatReg.value = packet[2] << 8 | packet[3]; - configDataset.filterSetting.value = packet[4] << 8 | packet[5]; - configDataset.mscCtrlReg.value = packet[6] << 8 | packet[7]; - configDataset.decRateReg.value = packet[8] << 8 | packet[9]; - configDataset.setValidity(true, true); - if(internalState == InternalState::CONFIG) { - commandExecuted = true; - } - break; + return HasReturnvaluesIF::RETURN_FAILED; + } + PoolReadGuard rg(&configDataset); + configDataset.diagStatReg.value = packet[2] << 8 | packet[3]; + configDataset.filterSetting.value = packet[4] << 8 | packet[5]; + configDataset.mscCtrlReg.value = packet[6] << 8 | packet[7]; + configDataset.decRateReg.value = packet[8] << 8 | packet[9]; + configDataset.setValidity(true, true); + if (internalState == InternalState::CONFIG) { + commandExecuted = true; + } + break; } - case(ADIS1650X::READ_SENSOR_DATA): { - return handleSensorData(packet); + case (ADIS1650X::READ_SENSOR_DATA): { + return handleSensorData(packet); } - - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } - ReturnValue_t GyroADIS1650XHandler::handleSensorData(const uint8_t *packet) { - BurstModes burstMode = getBurstMode(); - switch(burstMode) { - case(BurstModes::BURST_16_BURST_SEL_1): - case(BurstModes::BURST_32_BURST_SEL_1): { - sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Analysis with BURST_SEL1" - " not implemented!" << std::endl; - return HasReturnvaluesIF::RETURN_OK; + BurstModes burstMode = getBurstMode(); + switch (burstMode) { + case (BurstModes::BURST_16_BURST_SEL_1): + case (BurstModes::BURST_32_BURST_SEL_1): { + sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Analysis with BURST_SEL1" + " not implemented!" + << std::endl; + return HasReturnvaluesIF::RETURN_OK; } - case(BurstModes::BURST_16_BURST_SEL_0): { - uint16_t checksum = packet[20] << 8 | packet[21]; - // Now verify the read checksum with the expected checksum according to datasheet p. 20 - uint16_t calcChecksum = 0; - for(size_t idx = 2; idx < 20; idx ++) { - calcChecksum += packet[idx]; - } - if(checksum != calcChecksum) { + case (BurstModes::BURST_16_BURST_SEL_0): { + uint16_t checksum = packet[20] << 8 | packet[21]; + // Now verify the read checksum with the expected checksum according to datasheet p. 20 + uint16_t calcChecksum = 0; + for (size_t idx = 2; idx < 20; idx++) { + calcChecksum += packet[idx]; + } + if (checksum != calcChecksum) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: " - "Invalid checksum detected!" << std::endl; + sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: " + "Invalid checksum detected!" + << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return HasReturnvaluesIF::RETURN_FAILED; + } + + ReturnValue_t result = configDataset.diagStatReg.read(); + if (result == HasReturnvaluesIF::RETURN_OK) { + configDataset.diagStatReg.value = packet[2] << 8 | packet[3]; + configDataset.diagStatReg.setValid(true); + } + configDataset.diagStatReg.commit(); + + { + PoolReadGuard pg(&primaryDataset); + int16_t angVelocXRaw = packet[4] << 8 | packet[5]; + primaryDataset.angVelocX.value = + static_cast(angVelocXRaw) / INT16_MAX * ADIS1650X::GYRO_RANGE; + int16_t angVelocYRaw = packet[6] << 8 | packet[7]; + primaryDataset.angVelocY.value = + static_cast(angVelocYRaw) / INT16_MAX * ADIS1650X::GYRO_RANGE; + int16_t angVelocZRaw = packet[8] << 8 | packet[9]; + primaryDataset.angVelocZ.value = + static_cast(angVelocZRaw) / INT16_MAX * ADIS1650X::GYRO_RANGE; + + float accelScaling = 0; + if (adisType == ADIS1650X::Type::ADIS16507) { + accelScaling = ADIS1650X::ACCELEROMETER_RANGE_16507; + } else if (adisType == ADIS1650X::Type::ADIS16505) { + accelScaling = ADIS1650X::ACCELEROMETER_RANGE_16505; + } else { + sif::warning << "GyroADIS1650XHandler::handleSensorData: " + "Unknown ADIS type" + << std::endl; } + int16_t accelXRaw = packet[10] << 8 | packet[11]; + primaryDataset.accelX.value = static_cast(accelXRaw) / INT16_MAX * accelScaling; + int16_t accelYRaw = packet[12] << 8 | packet[13]; + primaryDataset.accelY.value = static_cast(accelYRaw) / INT16_MAX * accelScaling; + int16_t accelZRaw = packet[14] << 8 | packet[15]; + primaryDataset.accelZ.value = static_cast(accelZRaw) / INT16_MAX * accelScaling; - ReturnValue_t result = configDataset.diagStatReg.read(); - if(result == HasReturnvaluesIF::RETURN_OK) { - configDataset.diagStatReg.value = packet[2] << 8 | packet[3]; - configDataset.diagStatReg.setValid(true); - } - configDataset.diagStatReg.commit(); - - { - PoolReadGuard pg(&primaryDataset); - int16_t angVelocXRaw = packet[4] << 8 | packet[5]; - primaryDataset.angVelocX.value = static_cast(angVelocXRaw) / INT16_MAX * - ADIS1650X::GYRO_RANGE; - int16_t angVelocYRaw = packet[6] << 8 | packet[7]; - primaryDataset.angVelocY.value = static_cast(angVelocYRaw) / INT16_MAX * - ADIS1650X::GYRO_RANGE; - int16_t angVelocZRaw = packet[8] << 8 | packet[9]; - primaryDataset.angVelocZ.value = static_cast(angVelocZRaw) / INT16_MAX * - ADIS1650X::GYRO_RANGE; - - float accelScaling = 0; - if(adisType == ADIS1650X::Type::ADIS16507) { - accelScaling = ADIS1650X::ACCELEROMETER_RANGE_16507; - } else if(adisType == ADIS1650X::Type::ADIS16505) { - accelScaling = ADIS1650X::ACCELEROMETER_RANGE_16505; - } else { - sif::warning << "GyroADIS1650XHandler::handleSensorData: " - "Unknown ADIS type" << std::endl; - } - int16_t accelXRaw = packet[10] << 8 | packet[11]; - primaryDataset.accelX.value = static_cast(accelXRaw) / INT16_MAX * - accelScaling; - int16_t accelYRaw = packet[12] << 8 | packet[13]; - primaryDataset.accelY.value = static_cast(accelYRaw) / INT16_MAX * - accelScaling; - int16_t accelZRaw = packet[14] << 8 | packet[15]; - primaryDataset.accelZ.value = static_cast(accelZRaw) / INT16_MAX * - accelScaling; - - int16_t temperatureRaw = packet[16] << 8 | packet[17]; - primaryDataset.temperature.value = static_cast(temperatureRaw) * 0.1; - // Ignore data counter for now - primaryDataset.setValidity(true, true); - } + int16_t temperatureRaw = packet[16] << 8 | packet[17]; + primaryDataset.temperature.value = static_cast(temperatureRaw) * 0.1; + // Ignore data counter for now + primaryDataset.setValidity(true, true); + } #if FSFW_HAL_ADIS1650X_GYRO_DEBUG == 1 - if(debugDivider->checkAndIncrement()) { - sif::info << "GyroADIS1650XHandler: Angular velocities in deg / s" << std::endl; - sif::info << "X: " << primaryDataset.angVelocX.value << std::endl; - sif::info << "Y: " << primaryDataset.angVelocY.value << std::endl; - sif::info << "Z: " << primaryDataset.angVelocZ.value << std::endl; - sif::info << "GyroADIS1650XHandler: Accelerations in m / s^2: " << std::endl; - sif::info << "X: " << primaryDataset.accelX.value << std::endl; - sif::info << "Y: " << primaryDataset.accelY.value << std::endl; - sif::info << "Z: " << primaryDataset.accelZ.value << std::endl; - } + if (debugDivider->checkAndIncrement()) { + sif::info << "GyroADIS1650XHandler: Angular velocities in deg / s" << std::endl; + sif::info << "X: " << primaryDataset.angVelocX.value << std::endl; + sif::info << "Y: " << primaryDataset.angVelocY.value << std::endl; + sif::info << "Z: " << primaryDataset.angVelocZ.value << std::endl; + sif::info << "GyroADIS1650XHandler: Accelerations in m / s^2: " << std::endl; + sif::info << "X: " << primaryDataset.accelX.value << std::endl; + sif::info << "Y: " << primaryDataset.accelY.value << std::endl; + sif::info << "Z: " << primaryDataset.accelZ.value << std::endl; + } #endif - break; + break; } - case(BurstModes::BURST_32_BURST_SEL_0): { - break; + case (BurstModes::BURST_32_BURST_SEL_0): { + break; } - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } uint32_t GyroADIS1650XHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { - return 10000; + return 10000; } void GyroADIS1650XHandler::prepareWriteCommand(uint8_t startReg, uint8_t valueOne, - uint8_t valueTwo) { - uint8_t secondReg = startReg + 1; - startReg |= ADIS1650X::WRITE_MASK; - secondReg |= ADIS1650X::WRITE_MASK; - commandBuffer[0] = startReg; - commandBuffer[1] = valueOne; - commandBuffer[2] = secondReg; - commandBuffer[3] = valueTwo; - this->rawPacketLen = 4; - this->rawPacket = commandBuffer.data(); + uint8_t valueTwo) { + uint8_t secondReg = startReg + 1; + startReg |= ADIS1650X::WRITE_MASK; + secondReg |= ADIS1650X::WRITE_MASK; + commandBuffer[0] = startReg; + commandBuffer[1] = valueOne; + commandBuffer[2] = secondReg; + commandBuffer[3] = valueTwo; + this->rawPacketLen = 4; + this->rawPacket = commandBuffer.data(); } void GyroADIS1650XHandler::prepareReadCommand(uint8_t *regList, size_t len) { - for(size_t idx = 0; idx < len; idx++) { - commandBuffer[idx * 2] = regList[idx]; - commandBuffer[idx * 2 + 1] = 0x00; - } - commandBuffer[len * 2] = 0x00; - commandBuffer[len * 2 + 1] = 0x00; + for (size_t idx = 0; idx < len; idx++) { + commandBuffer[idx * 2] = regList[idx]; + commandBuffer[idx * 2 + 1] = 0x00; + } + commandBuffer[len * 2] = 0x00; + commandBuffer[len * 2 + 1] = 0x00; } ReturnValue_t GyroADIS1650XHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) { - localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_X, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_Y, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_Z, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS1650X::ACCELERATION_X, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS1650X::ACCELERATION_Y, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS1650X::ACCELERATION_Z, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS1650X::TEMPERATURE, new PoolEntry({0.0})); + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_X, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_Y, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_Z, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::ACCELERATION_X, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::ACCELERATION_Y, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::ACCELERATION_Z, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::TEMPERATURE, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS1650X::DIAG_STAT_REGISTER, new PoolEntry()); - localDataPoolMap.emplace(ADIS1650X::FILTER_SETTINGS, new PoolEntry()); - localDataPoolMap.emplace(ADIS1650X::MSC_CTRL_REGISTER, new PoolEntry()); - localDataPoolMap.emplace(ADIS1650X::DEC_RATE_REGISTER, new PoolEntry()); - return HasReturnvaluesIF::RETURN_OK; + localDataPoolMap.emplace(ADIS1650X::DIAG_STAT_REGISTER, new PoolEntry()); + localDataPoolMap.emplace(ADIS1650X::FILTER_SETTINGS, new PoolEntry()); + localDataPoolMap.emplace(ADIS1650X::MSC_CTRL_REGISTER, new PoolEntry()); + localDataPoolMap.emplace(ADIS1650X::DEC_RATE_REGISTER, new PoolEntry()); + return HasReturnvaluesIF::RETURN_OK; } GyroADIS1650XHandler::BurstModes GyroADIS1650XHandler::getBurstMode() { - configDataset.mscCtrlReg.read(); - uint16_t currentCtrlReg = configDataset.mscCtrlReg.value; - configDataset.mscCtrlReg.commit(); - if((currentCtrlReg & ADIS1650X::BURST_32_BIT) == ADIS1650X::BURST_32_BIT) { - if((currentCtrlReg & ADIS1650X::BURST_SEL_BIT) == ADIS1650X::BURST_SEL_BIT) { - return BurstModes::BURST_32_BURST_SEL_1; - } - else { - return BurstModes::BURST_32_BURST_SEL_0; - } + configDataset.mscCtrlReg.read(); + uint16_t currentCtrlReg = configDataset.mscCtrlReg.value; + configDataset.mscCtrlReg.commit(); + if ((currentCtrlReg & ADIS1650X::BURST_32_BIT) == ADIS1650X::BURST_32_BIT) { + if ((currentCtrlReg & ADIS1650X::BURST_SEL_BIT) == ADIS1650X::BURST_SEL_BIT) { + return BurstModes::BURST_32_BURST_SEL_1; + } else { + return BurstModes::BURST_32_BURST_SEL_0; } - else { - if((currentCtrlReg & ADIS1650X::BURST_SEL_BIT) == ADIS1650X::BURST_SEL_BIT) { - return BurstModes::BURST_16_BURST_SEL_1; - } - else { - return BurstModes::BURST_16_BURST_SEL_0; - } + } else { + if ((currentCtrlReg & ADIS1650X::BURST_SEL_BIT) == ADIS1650X::BURST_SEL_BIT) { + return BurstModes::BURST_16_BURST_SEL_1; + } else { + return BurstModes::BURST_16_BURST_SEL_0; } + } } #if OBSW_ADIS1650X_LINUX_COM_IF == 1 ReturnValue_t GyroADIS1650XHandler::spiSendCallback(SpiComIF *comIf, SpiCookie *cookie, - const uint8_t *sendData, size_t sendLen, void *args) { - GyroADIS1650XHandler* handler = reinterpret_cast(args); - if(handler == nullptr) { - sif::error << "GyroADIS16507Handler::spiSendCallback: Passed handler pointer is invalid!" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; + const uint8_t *sendData, size_t sendLen, + void *args) { + GyroADIS1650XHandler *handler = reinterpret_cast(args); + if (handler == nullptr) { + sif::error << "GyroADIS16507Handler::spiSendCallback: Passed handler pointer is invalid!" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + DeviceCommandId_t currentCommand = handler->getPendingCommand(); + switch (currentCommand) { + case (ADIS1650X::READ_SENSOR_DATA): { + return comIf->performRegularSendOperation(cookie, sendData, sendLen); } - DeviceCommandId_t currentCommand = handler->getPendingCommand(); - switch(currentCommand) { - case(ADIS1650X::READ_SENSOR_DATA): { - return comIf->performRegularSendOperation(cookie, sendData, sendLen); - } - case(ADIS1650X::READ_OUT_CONFIG): + case (ADIS1650X::READ_OUT_CONFIG): default: { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - int retval = 0; - // Prepare transfer - int fileDescriptor = 0; - std::string device = cookie->getSpiDevice(); - UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "SpiComIF::sendMessage"); - if(fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { - return SpiComIF::OPENING_FILE_FAILED; - } - spi::SpiModes spiMode = spi::SpiModes::MODE_0; - uint32_t spiSpeed = 0; - cookie->getSpiParameters(spiMode, spiSpeed, nullptr); - comIf->setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); - cookie->assignWriteBuffer(sendData); - cookie->setTransferSize(2); + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + int retval = 0; + // Prepare transfer + int fileDescriptor = 0; + std::string device = cookie->getSpiDevice(); + UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "SpiComIF::sendMessage"); + if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { + return SpiComIF::OPENING_FILE_FAILED; + } + spi::SpiModes spiMode = spi::SpiModes::MODE_0; + uint32_t spiSpeed = 0; + cookie->getSpiParameters(spiMode, spiSpeed, nullptr); + comIf->setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); + cookie->assignWriteBuffer(sendData); + cookie->setTransferSize(2); - gpioId_t gpioId = cookie->getChipSelectPin(); - GpioIF* gpioIF = comIf->getGpioInterface(); - MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; - uint32_t timeoutMs = 0; - MutexIF* mutex = comIf->getMutex(&timeoutType, &timeoutMs); - if(mutex == nullptr or gpioIF == nullptr) { + gpioId_t gpioId = cookie->getChipSelectPin(); + GpioIF *gpioIF = comIf->getGpioInterface(); + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; + uint32_t timeoutMs = 0; + MutexIF *mutex = comIf->getMutex(&timeoutType, &timeoutMs); + if (mutex == nullptr or gpioIF == nullptr) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::warning << "GyroADIS16507Handler::spiSendCallback: " - "Mutex or GPIO interface invalid" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; + sif::warning << "GyroADIS16507Handler::spiSendCallback: " + "Mutex or GPIO interface invalid" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; #endif - } + } - if(gpioId != gpio::NO_GPIO) { - result = mutex->lockMutex(timeoutType, timeoutMs); - if (result != RETURN_OK) { + if (gpioId != gpio::NO_GPIO) { + result = mutex->lockMutex(timeoutType, timeoutMs); + if (result != RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "SpiComIF::sendMessage: Failed to lock mutex" << std::endl; + sif::error << "SpiComIF::sendMessage: Failed to lock mutex" << std::endl; #endif - return result; - } + return result; + } + } + + size_t idx = 0; + while (idx < sendLen) { + // Pull SPI CS low. For now, no support for active high given + if (gpioId != gpio::NO_GPIO) { + gpioIF->pullLow(gpioId); } - size_t idx = 0; - while(idx < sendLen) { - // Pull SPI CS low. For now, no support for active high given - if(gpioId != gpio::NO_GPIO) { - gpioIF->pullLow(gpioId); - } - - // Execute transfer - // Initiate a full duplex SPI transfer. - retval = ioctl(fileDescriptor, SPI_IOC_MESSAGE(1), cookie->getTransferStructHandle()); - if(retval < 0) { - utility::handleIoctlError("SpiComIF::sendMessage: ioctl error."); - result = SpiComIF::FULL_DUPLEX_TRANSFER_FAILED; - } + // Execute transfer + // Initiate a full duplex SPI transfer. + retval = ioctl(fileDescriptor, SPI_IOC_MESSAGE(1), cookie->getTransferStructHandle()); + if (retval < 0) { + utility::handleIoctlError("SpiComIF::sendMessage: ioctl error."); + result = SpiComIF::FULL_DUPLEX_TRANSFER_FAILED; + } #if FSFW_HAL_SPI_WIRETAPPING == 1 - comIf->performSpiWiretapping(cookie); + comIf->performSpiWiretapping(cookie); #endif /* FSFW_LINUX_SPI_WIRETAPPING == 1 */ - if(gpioId != gpio::NO_GPIO) { - gpioIF->pullHigh(gpioId); - } - - idx += 2; - if(idx < sendLen) { - usleep(ADIS1650X::STALL_TIME_MICROSECONDS); - } - spi_ioc_transfer* transferStruct = cookie->getTransferStructHandle(); - transferStruct->tx_buf += 2; - transferStruct->rx_buf += 2; + if (gpioId != gpio::NO_GPIO) { + gpioIF->pullHigh(gpioId); } - if(gpioId != gpio::NO_GPIO) { - mutex->unlockMutex(); + idx += 2; + if (idx < sendLen) { + usleep(ADIS1650X::STALL_TIME_MICROSECONDS); } + spi_ioc_transfer *transferStruct = cookie->getTransferStructHandle(); + transferStruct->tx_buf += 2; + transferStruct->rx_buf += 2; + } + + if (gpioId != gpio::NO_GPIO) { + mutex->unlockMutex(); + } } - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } #endif /* OBSW_ADIS1650X_LINUX_COM_IF == 1 */ diff --git a/mission/devices/GyroADIS1650XHandler.h b/mission/devices/GyroADIS1650XHandler.h index b1ac50f5..c1f9ae98 100644 --- a/mission/devices/GyroADIS1650XHandler.h +++ b/mission/devices/GyroADIS1650XHandler.h @@ -1,12 +1,11 @@ #ifndef MISSION_DEVICES_GYROADIS16507HANDLER_H_ #define MISSION_DEVICES_GYROADIS16507HANDLER_H_ -#include "OBSWConfig.h" #include "FSFWConfig.h" +#include "OBSWConfig.h" #include "devicedefinitions/GyroADIS1650XDefinitions.h" - -#include "fsfw/globalfunctions/PeriodicOperationDivider.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" +#include "fsfw/globalfunctions/PeriodicOperationDivider.h" #if OBSW_ADIS1650X_LINUX_COM_IF == 1 class SpiComIF; @@ -19,67 +18,60 @@ class SpiCookie; * Flight manual: * https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/ADIS16507_Gyro */ -class GyroADIS1650XHandler: public DeviceHandlerBase { -public: - GyroADIS1650XHandler(object_id_t objectId, object_id_t deviceCommunication, - CookieIF* comCookie, ADIS1650X::Type type); +class GyroADIS1650XHandler : public DeviceHandlerBase { + public: + GyroADIS1650XHandler(object_id_t objectId, object_id_t deviceCommunication, CookieIF *comCookie, + ADIS1650X::Type type); - // DeviceHandlerBase abstract function implementation - void doStartUp() override; - void doShutDown() override; - ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; - ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override; - ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t * commandData, size_t commandDataLen) override; - void fillCommandAndReplyMap() 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; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) override; + // DeviceHandlerBase abstract function implementation + void doStartUp() override; + void doShutDown() override; + ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, + size_t commandDataLen) override; + void fillCommandAndReplyMap() 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; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) override; -private: - std::array commandBuffer; - ADIS1650X::Type adisType; - AdisGyroPrimaryDataset primaryDataset; - AdisGyroConfigDataset configDataset; + private: + std::array commandBuffer; + ADIS1650X::Type adisType; + AdisGyroPrimaryDataset primaryDataset; + AdisGyroConfigDataset configDataset; - enum class InternalState { - STARTUP, - CONFIG, - IDLE - }; + enum class InternalState { STARTUP, CONFIG, IDLE }; - enum class BurstModes { - BURST_16_BURST_SEL_0, - BURST_16_BURST_SEL_1, - BURST_32_BURST_SEL_0, - BURST_32_BURST_SEL_1 - }; + enum class BurstModes { + BURST_16_BURST_SEL_0, + BURST_16_BURST_SEL_1, + BURST_32_BURST_SEL_0, + BURST_32_BURST_SEL_1 + }; - InternalState internalState = InternalState::STARTUP; - bool commandExecuted = false; + InternalState internalState = InternalState::STARTUP; + bool commandExecuted = false; - void prepareReadCommand(uint8_t* regList, size_t len); + void prepareReadCommand(uint8_t *regList, size_t len); - BurstModes getBurstMode(); + BurstModes getBurstMode(); #if OBSW_ADIS1650X_LINUX_COM_IF == 1 - static ReturnValue_t spiSendCallback(SpiComIF* comIf, SpiCookie *cookie, - const uint8_t *sendData, size_t sendLen, void* args); + static ReturnValue_t spiSendCallback(SpiComIF *comIf, SpiCookie *cookie, const uint8_t *sendData, + size_t sendLen, void *args); #endif #if FSFW_HAL_ADIS1650X_GYRO_DEBUG == 1 - PeriodicOperationDivider* debugDivider; + PeriodicOperationDivider *debugDivider; #endif - Countdown breakCountdown; - void prepareWriteCommand(uint8_t startReg, uint8_t valueOne, uint8_t valueTwo); + Countdown breakCountdown; + void prepareWriteCommand(uint8_t startReg, uint8_t valueOne, uint8_t valueTwo); - ReturnValue_t handleSensorData(const uint8_t* packet); + ReturnValue_t handleSensorData(const uint8_t *packet); }; - - #endif /* MISSION_DEVICES_GYROADIS16507HANDLER_H_ */ diff --git a/mission/devices/HeaterHandler.cpp b/mission/devices/HeaterHandler.cpp index 60a60328..572810bd 100644 --- a/mission/devices/HeaterHandler.cpp +++ b/mission/devices/HeaterHandler.cpp @@ -1,373 +1,346 @@ #include "HeaterHandler.h" + +#include +#include +#include + #include "devices/gpioIds.h" #include "devices/powerSwitcherList.h" -#include -#include -#include - HeaterHandler::HeaterHandler(object_id_t setObjectId_, object_id_t gpioDriverId_, - CookieIF * gpioCookie_, object_id_t mainLineSwitcherObjectId_, uint8_t mainLineSwitch_) : - SystemObject(setObjectId_), gpioDriverId(gpioDriverId_), gpioCookie(gpioCookie_), - mainLineSwitcherObjectId(mainLineSwitcherObjectId_), mainLineSwitch(mainLineSwitch_), - actionHelper(this, nullptr) { - commandQueue = QueueFactory::instance()->createMessageQueue(cmdQueueSize, - MessageQueueMessage::MAX_MESSAGE_SIZE); + CookieIF* gpioCookie_, object_id_t mainLineSwitcherObjectId_, + uint8_t mainLineSwitch_) + : SystemObject(setObjectId_), + gpioDriverId(gpioDriverId_), + gpioCookie(gpioCookie_), + mainLineSwitcherObjectId(mainLineSwitcherObjectId_), + mainLineSwitch(mainLineSwitch_), + actionHelper(this, nullptr) { + commandQueue = QueueFactory::instance()->createMessageQueue( + cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE); } -HeaterHandler::~HeaterHandler() { -} +HeaterHandler::~HeaterHandler() {} ReturnValue_t HeaterHandler::performOperation(uint8_t operationCode) { - - if (operationCode == DeviceHandlerIF::PERFORM_OPERATION) { - readCommandQueue(); - handleActiveCommands(); - return RETURN_OK; - } - return RETURN_OK; + if (operationCode == DeviceHandlerIF::PERFORM_OPERATION) { + readCommandQueue(); + handleActiveCommands(); + return RETURN_OK; + } + return RETURN_OK; } ReturnValue_t HeaterHandler::initialize() { - ReturnValue_t result = SystemObject::initialize(); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + ReturnValue_t result = SystemObject::initialize(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = initializeHeaterMap(); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = initializeHeaterMap(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - gpioInterface = ObjectManager::instance()->get(gpioDriverId); - if (gpioInterface == nullptr) { - sif::error << "HeaterHandler::initialize: Invalid Gpio interface." << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + gpioInterface = ObjectManager::instance()->get(gpioDriverId); + if (gpioInterface == nullptr) { + sif::error << "HeaterHandler::initialize: Invalid Gpio interface." << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = gpioInterface->addGpios(dynamic_cast(gpioCookie)); - if (result != RETURN_OK) { - sif::error << "HeaterHandler::initialize: Failed to initialize Gpio interface" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = gpioInterface->addGpios(dynamic_cast(gpioCookie)); + if (result != RETURN_OK) { + sif::error << "HeaterHandler::initialize: Failed to initialize Gpio interface" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); - if (IPCStore == nullptr) { - sif::error << "HeaterHandler::initialize: IPC store not set up in factory." << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); + if (IPCStore == nullptr) { + sif::error << "HeaterHandler::initialize: IPC store not set up in factory." << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - if(mainLineSwitcherObjectId != objects::NO_OBJECT) { - mainLineSwitcher = ObjectManager::instance()->get(mainLineSwitcherObjectId); - if (mainLineSwitcher == nullptr) { - sif::error - << "HeaterHandler::initialize: Failed to get main line switcher. Make sure " - << "main line switcher object is initialized." << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } - } + if (mainLineSwitcherObjectId != objects::NO_OBJECT) { + mainLineSwitcher = ObjectManager::instance()->get(mainLineSwitcherObjectId); + if (mainLineSwitcher == nullptr) { + sif::error << "HeaterHandler::initialize: Failed to get main line switcher. Make sure " + << "main line switcher object is initialized." << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } + } - result = actionHelper.initialize(commandQueue); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = actionHelper.initialize(commandQueue); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - return RETURN_OK; + return RETURN_OK; } -ReturnValue_t HeaterHandler::initializeHeaterMap(){ - HeaterCommandInfo_t heaterCommandInfo; - for(switchNr_t switchNr = 0; switchNr < heaterSwitches::NUMBER_OF_SWITCHES; switchNr++) { - std::pair status = heaterMap.emplace(switchNr, heaterCommandInfo); - if (status.second == false) { - sif::error << "HeaterHandler::initializeHeaterMap: Failed to initialize heater map" - << std::endl; - return RETURN_FAILED; - } - } - return RETURN_OK; +ReturnValue_t HeaterHandler::initializeHeaterMap() { + HeaterCommandInfo_t heaterCommandInfo; + for (switchNr_t switchNr = 0; switchNr < heaterSwitches::NUMBER_OF_SWITCHES; switchNr++) { + std::pair status = heaterMap.emplace(switchNr, heaterCommandInfo); + if (status.second == false) { + sif::error << "HeaterHandler::initializeHeaterMap: Failed to initialize heater map" + << std::endl; + return RETURN_FAILED; + } + } + return RETURN_OK; } void HeaterHandler::setInitialSwitchStates() { - for (switchNr_t switchNr = 0; switchNr < heaterSwitches::NUMBER_OF_SWITCHES; switchNr++) { - switchStates[switchNr] = OFF; - } + for (switchNr_t switchNr = 0; switchNr < heaterSwitches::NUMBER_OF_SWITCHES; switchNr++) { + switchStates[switchNr] = OFF; + } } void HeaterHandler::readCommandQueue() { - CommandMessage command; - ReturnValue_t result = commandQueue->receiveMessage(&command); - if (result != RETURN_OK) { - return; - } + CommandMessage command; + ReturnValue_t result = commandQueue->receiveMessage(&command); + if (result != RETURN_OK) { + return; + } - result = actionHelper.handleActionMessage(&command); - if (result == RETURN_OK) { - return; - } + result = actionHelper.handleActionMessage(&command); + if (result == RETURN_OK) { + return; + } } -ReturnValue_t HeaterHandler::executeAction(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { - ReturnValue_t result; - if (actionId != SWITCH_HEATER) { - result = COMMAND_NOT_SUPPORTED; - } else { - switchNr_t switchNr = *data; - HeaterMapIter heaterMapIter = heaterMap.find(switchNr); - if (heaterMapIter != heaterMap.end()) { - if (heaterMapIter->second.active) { - return COMMAND_ALREADY_WAITING; - } - heaterMapIter->second.action = *(data + 1); - heaterMapIter->second.active = true; - heaterMapIter->second.replyQueue = commandedBy; - } - else { - sif::error << "HeaterHandler::executeAction: Invalid switchNr" << std::endl; - return INVALID_SWITCH_NR; - } - result = RETURN_OK; - } - return result; +ReturnValue_t HeaterHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) { + ReturnValue_t result; + if (actionId != SWITCH_HEATER) { + result = COMMAND_NOT_SUPPORTED; + } else { + switchNr_t switchNr = *data; + HeaterMapIter heaterMapIter = heaterMap.find(switchNr); + if (heaterMapIter != heaterMap.end()) { + if (heaterMapIter->second.active) { + return COMMAND_ALREADY_WAITING; + } + heaterMapIter->second.action = *(data + 1); + heaterMapIter->second.active = true; + heaterMapIter->second.replyQueue = commandedBy; + } else { + sif::error << "HeaterHandler::executeAction: Invalid switchNr" << std::endl; + return INVALID_SWITCH_NR; + } + result = RETURN_OK; + } + return result; } +void HeaterHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const { + ReturnValue_t result; + store_address_t storeAddress; + uint8_t commandData[2]; -void HeaterHandler::sendSwitchCommand(uint8_t switchNr, - ReturnValue_t onOff) const { + switch (onOff) { + case PowerSwitchIF::SWITCH_ON: + commandData[0] = switchNr; + commandData[1] = SET_SWITCH_ON; + break; + case PowerSwitchIF::SWITCH_OFF: + commandData[0] = switchNr; + commandData[1] = SET_SWITCH_OFF; + break; + default: + sif::error << "HeaterHandler::sendSwitchCommand: Invalid switch request" << std::endl; + break; + } - ReturnValue_t result; - store_address_t storeAddress; - uint8_t commandData[2]; - - switch(onOff) { - case PowerSwitchIF::SWITCH_ON: - commandData[0] = switchNr; - commandData[1] = SET_SWITCH_ON; - break; - case PowerSwitchIF::SWITCH_OFF: - commandData[0] = switchNr; - commandData[1] = SET_SWITCH_OFF; - break; - default: - sif::error << "HeaterHandler::sendSwitchCommand: Invalid switch request" - << std::endl; - break; - } - - result = IPCStore->addData(&storeAddress, commandData, sizeof(commandData)); - if (result == RETURN_OK) { - CommandMessage message; - ActionMessage::setCommand(&message, SWITCH_HEATER, storeAddress); - /* Send heater command to own command queue */ - result = commandQueue->sendMessage(commandQueue->getId(), &message, 0); - if (result != RETURN_OK) { - sif::debug << "HeaterHandler::sendSwitchCommand: Failed to send switch" - << "message" << std::endl; - } - } + result = IPCStore->addData(&storeAddress, commandData, sizeof(commandData)); + if (result == RETURN_OK) { + CommandMessage message; + ActionMessage::setCommand(&message, SWITCH_HEATER, storeAddress); + /* Send heater command to own command queue */ + result = commandQueue->sendMessage(commandQueue->getId(), &message, 0); + if (result != RETURN_OK) { + sif::debug << "HeaterHandler::sendSwitchCommand: Failed to send switch" + << "message" << std::endl; + } + } } -void HeaterHandler::handleActiveCommands(){ - - HeaterMapIter heaterMapIter = heaterMap.begin(); - for (; heaterMapIter != heaterMap.end(); heaterMapIter++) { - if (heaterMapIter->second.active) { - switch(heaterMapIter->second.action) { - case SET_SWITCH_ON: - handleSwitchOnCommand(heaterMapIter); - break; - case SET_SWITCH_OFF: - handleSwitchOffCommand(heaterMapIter); - break; - default: - sif::error << "HeaterHandler::handleActiveCommands: Invalid action commanded" - << std::endl; - break; - } - } - } +void HeaterHandler::handleActiveCommands() { + HeaterMapIter heaterMapIter = heaterMap.begin(); + for (; heaterMapIter != heaterMap.end(); heaterMapIter++) { + if (heaterMapIter->second.active) { + switch (heaterMapIter->second.action) { + case SET_SWITCH_ON: + handleSwitchOnCommand(heaterMapIter); + break; + case SET_SWITCH_OFF: + handleSwitchOffCommand(heaterMapIter); + break; + default: + sif::error << "HeaterHandler::handleActiveCommands: Invalid action commanded" + << std::endl; + break; + } + } + } } void HeaterHandler::handleSwitchOnCommand(HeaterMapIter heaterMapIter) { + ReturnValue_t result = RETURN_OK; + switchNr_t switchNr; - ReturnValue_t result = RETURN_OK; - switchNr_t switchNr; + /* Check if command waits for main switch being set on and whether the timeout has expired */ + if (heaterMapIter->second.waitMainSwitchOn && + heaterMapIter->second.mainSwitchCountdown.hasTimedOut()) { + // TODO - This requires the initiation of an FDIR procedure + triggerEvent(MAIN_SWITCH_TIMEOUT); + sif::error << "HeaterHandler::handleSwitchOnCommand: Main switch setting on timeout" + << std::endl; + heaterMapIter->second.active = false; + heaterMapIter->second.waitMainSwitchOn = false; + if (heaterMapIter->second.replyQueue != commandQueue->getId()) { + actionHelper.finish(false, heaterMapIter->second.replyQueue, heaterMapIter->second.action, + MAIN_SWITCH_SET_TIMEOUT); + } + return; + } - /* Check if command waits for main switch being set on and whether the timeout has expired */ - if (heaterMapIter->second.waitMainSwitchOn - && heaterMapIter->second.mainSwitchCountdown.hasTimedOut()) { - //TODO - This requires the initiation of an FDIR procedure - triggerEvent(MAIN_SWITCH_TIMEOUT); - sif::error << "HeaterHandler::handleSwitchOnCommand: Main switch setting on timeout" - << std::endl; - heaterMapIter->second.active = false; - heaterMapIter->second.waitMainSwitchOn = false; - if (heaterMapIter->second.replyQueue != commandQueue->getId()) { - actionHelper.finish(false, heaterMapIter->second.replyQueue, - heaterMapIter->second.action, MAIN_SWITCH_SET_TIMEOUT ); - } - return; + switchNr = heaterMapIter->first; + /* Check state of main line switch */ + ReturnValue_t mainSwitchState = mainLineSwitcher->getSwitchState(mainLineSwitch); + if (mainSwitchState == PowerSwitchIF::SWITCH_ON) { + if (!checkSwitchState(switchNr)) { + gpioId_t gpioId = getGpioIdFromSwitchNr(switchNr); + result = gpioInterface->pullHigh(gpioId); + if (result != RETURN_OK) { + sif::error << "HeaterHandler::handleSwitchOnCommand: Failed to pull gpio with id " << gpioId + << " high" << std::endl; + triggerEvent(GPIO_PULL_HIGH_FAILED, result); + } else { + switchStates[switchNr] = ON; + } + } else { + triggerEvent(SWITCH_ALREADY_ON, switchNr); } - - switchNr = heaterMapIter->first; - /* Check state of main line switch */ - ReturnValue_t mainSwitchState = mainLineSwitcher->getSwitchState(mainLineSwitch); - if (mainSwitchState == PowerSwitchIF::SWITCH_ON) { - if (!checkSwitchState(switchNr)) { - gpioId_t gpioId = getGpioIdFromSwitchNr(switchNr); - result = gpioInterface->pullHigh(gpioId); - if (result != RETURN_OK) { - sif::error << "HeaterHandler::handleSwitchOnCommand: Failed to pull gpio with id " - << gpioId << " high" << std::endl; - triggerEvent(GPIO_PULL_HIGH_FAILED, result); - } - else { - switchStates[switchNr] = ON; - } - } - else { - triggerEvent(SWITCH_ALREADY_ON, switchNr); - } - /* There is no need to send action finish replies if the sender was the - * HeaterHandler itself. */ - if (heaterMapIter->second.replyQueue != commandQueue->getId()) { - if(result == RETURN_OK) { - actionHelper.finish(true, heaterMapIter->second.replyQueue, - heaterMapIter->second.action, result); - } - else { - actionHelper.finish(false, heaterMapIter->second.replyQueue, - heaterMapIter->second.action, result); - } - - } - heaterMapIter->second.active = false; - heaterMapIter->second.waitMainSwitchOn = false; + /* There is no need to send action finish replies if the sender was the + * HeaterHandler itself. */ + if (heaterMapIter->second.replyQueue != commandQueue->getId()) { + if (result == RETURN_OK) { + actionHelper.finish(true, heaterMapIter->second.replyQueue, heaterMapIter->second.action, + result); + } else { + actionHelper.finish(false, heaterMapIter->second.replyQueue, heaterMapIter->second.action, + result); + } } - else if (mainSwitchState == PowerSwitchIF::SWITCH_OFF - && heaterMapIter->second.waitMainSwitchOn) { - /* Just waiting for the main switch being set on */ - return; - } - else if (mainSwitchState == PowerSwitchIF::SWITCH_OFF) { - mainLineSwitcher->sendSwitchCommand(mainLineSwitch, - PowerSwitchIF::SWITCH_ON); - heaterMapIter->second.mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs()); - heaterMapIter->second.waitMainSwitchOn = true; - } - else { - sif::debug << "HeaterHandler::handleActiveCommands: Failed to get state of" - << " main line switch" << std::endl; - if (heaterMapIter->second.replyQueue != commandQueue->getId()) { - actionHelper.finish(false, heaterMapIter->second.replyQueue, - heaterMapIter->second.action, mainSwitchState); - } - heaterMapIter->second.active = false; + heaterMapIter->second.active = false; + heaterMapIter->second.waitMainSwitchOn = false; + } else if (mainSwitchState == PowerSwitchIF::SWITCH_OFF && + heaterMapIter->second.waitMainSwitchOn) { + /* Just waiting for the main switch being set on */ + return; + } else if (mainSwitchState == PowerSwitchIF::SWITCH_OFF) { + mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_ON); + heaterMapIter->second.mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs()); + heaterMapIter->second.waitMainSwitchOn = true; + } else { + sif::debug << "HeaterHandler::handleActiveCommands: Failed to get state of" + << " main line switch" << std::endl; + if (heaterMapIter->second.replyQueue != commandQueue->getId()) { + actionHelper.finish(false, heaterMapIter->second.replyQueue, heaterMapIter->second.action, + mainSwitchState); } + heaterMapIter->second.active = false; + } } void HeaterHandler::handleSwitchOffCommand(HeaterMapIter heaterMapIter) { - ReturnValue_t result = RETURN_OK; - switchNr_t switchNr = heaterMapIter->first; - /* Check whether switch is already off */ - if (checkSwitchState(switchNr)) { - gpioId_t gpioId = getGpioIdFromSwitchNr(switchNr); - result = gpioInterface->pullLow(gpioId); - if (result != RETURN_OK) { - sif::error << "HeaterHandler::handleSwitchOffCommand: Failed to pull gpio with id" - << gpioId << " low" << std::endl; - triggerEvent(GPIO_PULL_LOW_FAILED, result); - } - else { - switchStates[switchNr] = OFF; - /* When all switches are off, also main line switch will be turned off */ - if (allSwitchesOff()) { - mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); - } - } + ReturnValue_t result = RETURN_OK; + switchNr_t switchNr = heaterMapIter->first; + /* Check whether switch is already off */ + if (checkSwitchState(switchNr)) { + gpioId_t gpioId = getGpioIdFromSwitchNr(switchNr); + result = gpioInterface->pullLow(gpioId); + if (result != RETURN_OK) { + sif::error << "HeaterHandler::handleSwitchOffCommand: Failed to pull gpio with id" << gpioId + << " low" << std::endl; + triggerEvent(GPIO_PULL_LOW_FAILED, result); + } else { + switchStates[switchNr] = OFF; + /* When all switches are off, also main line switch will be turned off */ + if (allSwitchesOff()) { + mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); + } } - else { - sif::info << "HeaterHandler::handleSwitchOffCommand: Switch already off" << std::endl; - triggerEvent(SWITCH_ALREADY_OFF, switchNr); + } else { + sif::info << "HeaterHandler::handleSwitchOffCommand: Switch already off" << std::endl; + triggerEvent(SWITCH_ALREADY_OFF, switchNr); + } + if (heaterMapIter->second.replyQueue != NO_COMMANDER) { + /* Report back switch command reply if necessary */ + if (result == HasReturnvaluesIF::RETURN_OK) { + actionHelper.finish(true, heaterMapIter->second.replyQueue, heaterMapIter->second.action, + result); + } else { + actionHelper.finish(false, heaterMapIter->second.replyQueue, heaterMapIter->second.action, + result); } - if (heaterMapIter->second.replyQueue != NO_COMMANDER) { - /* Report back switch command reply if necessary */ - if(result == HasReturnvaluesIF::RETURN_OK) { - actionHelper.finish(true, heaterMapIter->second.replyQueue, - heaterMapIter->second.action, result); - } - else { - actionHelper.finish(false, heaterMapIter->second.replyQueue, - heaterMapIter->second.action, result); - } - } - heaterMapIter->second.active = false; + } + heaterMapIter->second.active = false; } -bool HeaterHandler::checkSwitchState(int switchNr) { - return switchStates[switchNr]; -} +bool HeaterHandler::checkSwitchState(int switchNr) { return switchStates[switchNr]; } bool HeaterHandler::allSwitchesOff() { - bool allSwitchesOrd = false; - /* Or all switches. As soon one switch is on, allSwitchesOrd will be true */ - for (switchNr_t switchNr = 0; switchNr < heaterSwitches::NUMBER_OF_SWITCHES; switchNr++) { - allSwitchesOrd = allSwitchesOrd || switchStates[switchNr]; - } - return !allSwitchesOrd; + bool allSwitchesOrd = false; + /* Or all switches. As soon one switch is on, allSwitchesOrd will be true */ + for (switchNr_t switchNr = 0; switchNr < heaterSwitches::NUMBER_OF_SWITCHES; switchNr++) { + allSwitchesOrd = allSwitchesOrd || switchStates[switchNr]; + } + return !allSwitchesOrd; } gpioId_t HeaterHandler::getGpioIdFromSwitchNr(int switchNr) { - gpioId_t gpioId = 0xFFFF; - switch(switchNr) { + gpioId_t gpioId = 0xFFFF; + switch (switchNr) { case heaterSwitches::HEATER_0: - gpioId = gpioIds::HEATER_0; - break; + gpioId = gpioIds::HEATER_0; + break; case heaterSwitches::HEATER_1: - gpioId = gpioIds::HEATER_1; - break; + gpioId = gpioIds::HEATER_1; + break; case heaterSwitches::HEATER_2: - gpioId = gpioIds::HEATER_2; - break; + gpioId = gpioIds::HEATER_2; + break; case heaterSwitches::HEATER_3: - gpioId = gpioIds::HEATER_3; - break; + gpioId = gpioIds::HEATER_3; + break; case heaterSwitches::HEATER_4: - gpioId = gpioIds::HEATER_4; - break; + gpioId = gpioIds::HEATER_4; + break; case heaterSwitches::HEATER_5: - gpioId = gpioIds::HEATER_5; - break; + gpioId = gpioIds::HEATER_5; + break; case heaterSwitches::HEATER_6: - gpioId = gpioIds::HEATER_6; - break; + gpioId = gpioIds::HEATER_6; + break; case heaterSwitches::HEATER_7: - gpioId = gpioIds::HEATER_7; - break; + gpioId = gpioIds::HEATER_7; + break; default: - sif::error << "HeaterHandler::getGpioIdFromSwitchNr: Unknown heater switch number" - << std::endl; - break; - } - return gpioId; + sif::error << "HeaterHandler::getGpioIdFromSwitchNr: Unknown heater switch number" + << std::endl; + break; + } + return gpioId; } -MessageQueueId_t HeaterHandler::getCommandQueue() const { - return commandQueue->getId(); -} +MessageQueueId_t HeaterHandler::getCommandQueue() const { return commandQueue->getId(); } -void HeaterHandler::sendFuseOnCommand(uint8_t fuseNr) const { -} +void HeaterHandler::sendFuseOnCommand(uint8_t fuseNr) const {} -ReturnValue_t HeaterHandler::getSwitchState( uint8_t switchNr ) const { - return 0; -} +ReturnValue_t HeaterHandler::getSwitchState(uint8_t switchNr) const { return 0; } -ReturnValue_t HeaterHandler::getFuseState( uint8_t fuseNr ) const { - return 0; -} +ReturnValue_t HeaterHandler::getFuseState(uint8_t fuseNr) const { return 0; } -uint32_t HeaterHandler::getSwitchDelayMs(void) const { - return 0; -} +uint32_t HeaterHandler::getSwitchDelayMs(void) const { return 0; } diff --git a/mission/devices/HeaterHandler.h b/mission/devices/HeaterHandler.h index b52e22d4..2a8ce555 100644 --- a/mission/devices/HeaterHandler.h +++ b/mission/devices/HeaterHandler.h @@ -1,177 +1,169 @@ #ifndef MISSION_DEVICES_HEATERHANDLER_H_ #define MISSION_DEVICES_HEATERHANDLER_H_ -#include "devices/heaterSwitcherList.h" - -#include -#include -#include #include -#include -#include #include +#include +#include +#include +#include +#include #include #include + #include +#include "devices/heaterSwitcherList.h" + /** * @brief This class intends the control of heaters. * * @author J. Meier */ -class HeaterHandler: public ExecutableObjectIF, - public PowerSwitchIF, - public SystemObject, - public HasActionsIF { -public: - static const uint8_t INTERFACE_ID = CLASS_ID::HEATER_HANDLER; +class HeaterHandler : public ExecutableObjectIF, + public PowerSwitchIF, + public SystemObject, + public HasActionsIF { + public: + static const uint8_t INTERFACE_ID = CLASS_ID::HEATER_HANDLER; - static const ReturnValue_t COMMAND_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA1); - static const ReturnValue_t INIT_FAILED = MAKE_RETURN_CODE(0xA2); - static const ReturnValue_t INVALID_SWITCH_NR = MAKE_RETURN_CODE(0xA3); - static const ReturnValue_t MAIN_SWITCH_SET_TIMEOUT = MAKE_RETURN_CODE(0xA4); - static const ReturnValue_t COMMAND_ALREADY_WAITING = MAKE_RETURN_CODE(0xA5); + static const ReturnValue_t COMMAND_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA1); + static const ReturnValue_t INIT_FAILED = MAKE_RETURN_CODE(0xA2); + static const ReturnValue_t INVALID_SWITCH_NR = MAKE_RETURN_CODE(0xA3); + static const ReturnValue_t MAIN_SWITCH_SET_TIMEOUT = MAKE_RETURN_CODE(0xA4); + static const ReturnValue_t COMMAND_ALREADY_WAITING = MAKE_RETURN_CODE(0xA5); - /** Device command IDs */ - static const DeviceCommandId_t SWITCH_HEATER = 0x0; + /** Device command IDs */ + static const DeviceCommandId_t SWITCH_HEATER = 0x0; - HeaterHandler(object_id_t setObjectId, object_id_t gpioDriverId, CookieIF * gpioCookie, - object_id_t mainLineSwitcherObjectId, uint8_t mainLineSwitch); + HeaterHandler(object_id_t setObjectId, object_id_t gpioDriverId, CookieIF* gpioCookie, + object_id_t mainLineSwitcherObjectId, uint8_t mainLineSwitch); - virtual ~HeaterHandler(); + virtual ~HeaterHandler(); - virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; + virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; - virtual void sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const override; - virtual void sendFuseOnCommand(uint8_t fuseNr) const override; - /** - * @brief This function will be called from the Heater object to check - * the current switch state. - */ - virtual ReturnValue_t getSwitchState( uint8_t switchNr ) const override; - virtual ReturnValue_t getFuseState( uint8_t fuseNr ) const override; - virtual uint32_t getSwitchDelayMs(void) const override; + virtual void sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const override; + virtual void sendFuseOnCommand(uint8_t fuseNr) const override; + /** + * @brief This function will be called from the Heater object to check + * the current switch state. + */ + virtual ReturnValue_t getSwitchState(uint8_t switchNr) const override; + virtual ReturnValue_t getFuseState(uint8_t fuseNr) const override; + virtual uint32_t getSwitchDelayMs(void) const override; - virtual MessageQueueId_t getCommandQueue() const override; - virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size) override; - virtual ReturnValue_t initialize() override; + virtual MessageQueueId_t getCommandQueue() const override; + virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) override; + virtual ReturnValue_t initialize() override; -private: + private: + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::HEATER_HANDLER; + static const Event GPIO_PULL_HIGH_FAILED = MAKE_EVENT(0, severity::LOW); + static const Event GPIO_PULL_LOW_FAILED = MAKE_EVENT(1, severity::LOW); + static const Event SWITCH_ALREADY_ON = MAKE_EVENT(2, severity::LOW); + static const Event SWITCH_ALREADY_OFF = MAKE_EVENT(3, severity::LOW); + static const Event MAIN_SWITCH_TIMEOUT = MAKE_EVENT(4, severity::LOW); - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::HEATER_HANDLER; - static const Event GPIO_PULL_HIGH_FAILED = MAKE_EVENT(0, severity::LOW); - static const Event GPIO_PULL_LOW_FAILED = MAKE_EVENT(1, severity::LOW); - static const Event SWITCH_ALREADY_ON = MAKE_EVENT(2, severity::LOW); - static const Event SWITCH_ALREADY_OFF = MAKE_EVENT(3, severity::LOW); - static const Event MAIN_SWITCH_TIMEOUT = MAKE_EVENT(4, severity::LOW); + static const MessageQueueId_t NO_COMMANDER = 0; - static const MessageQueueId_t NO_COMMANDER = 0; + enum SwitchState : bool { ON = true, OFF = false }; - enum SwitchState : bool { - ON = true, - OFF = false - }; + /** + * @brief Struct holding information about a heater command to execute. + * + * @param action The action to perform. + * @param replyQueue The queue of the commander to which status replies + * will be sent. + * @param active True if command is waiting for execution, otherwise false. + * @param waitSwitchOn True if the command is waiting for the main switch being set on. + * @param mainSwitchCountdown Sets timeout to wait for main switch being set on. + */ + typedef struct HeaterCommandInfo { + uint8_t action; + MessageQueueId_t replyQueue; + bool active = false; + bool waitMainSwitchOn = false; + Countdown mainSwitchCountdown; + } HeaterCommandInfo_t; + enum SwitchAction { SET_SWITCH_OFF, SET_SWITCH_ON }; - /** - * @brief Struct holding information about a heater command to execute. - * - * @param action The action to perform. - * @param replyQueue The queue of the commander to which status replies - * will be sent. - * @param active True if command is waiting for execution, otherwise false. - * @param waitSwitchOn True if the command is waiting for the main switch being set on. - * @param mainSwitchCountdown Sets timeout to wait for main switch being set on. - */ - typedef struct HeaterCommandInfo { - uint8_t action; - MessageQueueId_t replyQueue; - bool active = false; - bool waitMainSwitchOn = false; - Countdown mainSwitchCountdown; - } HeaterCommandInfo_t; + using switchNr_t = uint8_t; + using HeaterMap = std::unordered_map; + using HeaterMapIter = HeaterMap::iterator; - enum SwitchAction { - SET_SWITCH_OFF, - SET_SWITCH_ON - }; + HeaterMap heaterMap; - using switchNr_t = uint8_t; - using HeaterMap = std::unordered_map; - using HeaterMapIter = HeaterMap::iterator; + bool switchStates[heaterSwitches::NUMBER_OF_SWITCHES]; - HeaterMap heaterMap; + /** Size of command queue */ + size_t cmdQueueSize = 20; - bool switchStates[heaterSwitches::NUMBER_OF_SWITCHES]; + /** + * The object ID of the GPIO driver which enables and disables the + * heaters. + */ + object_id_t gpioDriverId; - /** Size of command queue */ - size_t cmdQueueSize = 20; + CookieIF* gpioCookie; - /** - * The object ID of the GPIO driver which enables and disables the - * heaters. - */ - object_id_t gpioDriverId; + GpioIF* gpioInterface = nullptr; - CookieIF * gpioCookie; + /** Queue to receive messages from other objects. */ + MessageQueueIF* commandQueue = nullptr; - GpioIF* gpioInterface = nullptr; + object_id_t mainLineSwitcherObjectId; - /** Queue to receive messages from other objects. */ - MessageQueueIF* commandQueue = nullptr; + /** Switch number of the heater power supply switch */ + uint8_t mainLineSwitch; - object_id_t mainLineSwitcherObjectId; + /** + * Power switcher object which controls the 8V main line of the heater + * logic on the TCS board. + */ + PowerSwitchIF* mainLineSwitcher = nullptr; - /** Switch number of the heater power supply switch */ - uint8_t mainLineSwitch; + ActionHelper actionHelper; - /** - * Power switcher object which controls the 8V main line of the heater - * logic on the TCS board. - */ - PowerSwitchIF *mainLineSwitcher = nullptr; + StorageManagerIF* IPCStore = nullptr; - ActionHelper actionHelper; + void readCommandQueue(); - StorageManagerIF *IPCStore = nullptr; + /** + * @brief Returns the state of a switch (ON - true, or OFF - false). + * @param switchNr The number of the switch to check. + */ + bool checkSwitchState(int switchNr); - void readCommandQueue(); + /** + * @brief Returns the ID of the GPIO related to a heater identified by the switch number + * which is defined in the heaterSwitches list. + */ + gpioId_t getGpioIdFromSwitchNr(int switchNr); - /** - * @brief Returns the state of a switch (ON - true, or OFF - false). - * @param switchNr The number of the switch to check. - */ - bool checkSwitchState(int switchNr); + /** + * @brief This function runs commands waiting for execution. + */ + void handleActiveCommands(); - /** - * @brief Returns the ID of the GPIO related to a heater identified by the switch number - * which is defined in the heaterSwitches list. - */ - gpioId_t getGpioIdFromSwitchNr(int switchNr); + ReturnValue_t initializeHeaterMap(); - /** - * @brief This function runs commands waiting for execution. - */ - void handleActiveCommands(); + /** + * @brief Sets all switches to OFF. + */ + void setInitialSwitchStates(); - ReturnValue_t initializeHeaterMap(); + void handleSwitchOnCommand(HeaterMapIter heaterMapIter); - /** - * @brief Sets all switches to OFF. - */ - void setInitialSwitchStates(); - - void handleSwitchOnCommand(HeaterMapIter heaterMapIter); - - void handleSwitchOffCommand(HeaterMapIter heaterMapIter); - - /** - * @brief Checks if all switches are off. - * @return True if all switches are off, otherwise false. - */ - bool allSwitchesOff(); + void handleSwitchOffCommand(HeaterMapIter heaterMapIter); + /** + * @brief Checks if all switches are off. + * @return True if all switches are off, otherwise false. + */ + bool allSwitchesOff(); }; #endif /* MISSION_DEVICES_HEATERHANDLER_H_ */ diff --git a/mission/devices/IMTQHandler.cpp b/mission/devices/IMTQHandler.cpp index 125040d7..499b4d6e 100644 --- a/mission/devices/IMTQHandler.cpp +++ b/mission/devices/IMTQHandler.cpp @@ -1,248 +1,249 @@ #include "IMTQHandler.h" -#include "OBSWConfig.h" -#include #include +#include #include -IMTQHandler::IMTQHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - DeviceHandlerBase(objectId, comIF, comCookie), engHkDataset(this), calMtmMeasurementSet( - this), rawMtmMeasurementSet(this), posXselfTestDataset(this), negXselfTestDataset( - this), posYselfTestDataset(this), negYselfTestDataset(this), posZselfTestDataset( - this), negZselfTestDataset(this) { - if (comCookie == NULL) { - sif::error << "IMTQHandler: Invalid com cookie" << std::endl; - } +#include "OBSWConfig.h" + +IMTQHandler::IMTQHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie) + : DeviceHandlerBase(objectId, comIF, comCookie), + engHkDataset(this), + calMtmMeasurementSet(this), + rawMtmMeasurementSet(this), + posXselfTestDataset(this), + negXselfTestDataset(this), + posYselfTestDataset(this), + negYselfTestDataset(this), + posZselfTestDataset(this), + negZselfTestDataset(this) { + if (comCookie == NULL) { + sif::error << "IMTQHandler: Invalid com cookie" << std::endl; + } } -IMTQHandler::~IMTQHandler() { -} +IMTQHandler::~IMTQHandler() {} void IMTQHandler::doStartUp() { #if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 - setMode(MODE_NORMAL); + setMode(MODE_NORMAL); #else - setMode(_MODE_TO_ON); + setMode(_MODE_TO_ON); #endif } -void IMTQHandler::doShutDown() { - setMode(_MODE_POWER_DOWN); -} +void IMTQHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } -ReturnValue_t IMTQHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) { - switch (communicationStep) { +ReturnValue_t IMTQHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + switch (communicationStep) { case CommunicationStep::GET_ENG_HK_DATA: - *id = IMTQ::GET_ENG_HK_DATA; - communicationStep = CommunicationStep::START_MTM_MEASUREMENT; - break; + *id = IMTQ::GET_ENG_HK_DATA; + communicationStep = CommunicationStep::START_MTM_MEASUREMENT; + break; case CommunicationStep::START_MTM_MEASUREMENT: - *id = IMTQ::START_MTM_MEASUREMENT; - communicationStep = CommunicationStep::GET_CAL_MTM_MEASUREMENT; - break; + *id = IMTQ::START_MTM_MEASUREMENT; + communicationStep = CommunicationStep::GET_CAL_MTM_MEASUREMENT; + break; case CommunicationStep::GET_CAL_MTM_MEASUREMENT: - *id = IMTQ::GET_CAL_MTM_MEASUREMENT; - communicationStep = CommunicationStep::GET_RAW_MTM_MEASUREMENT; - break; + *id = IMTQ::GET_CAL_MTM_MEASUREMENT; + communicationStep = CommunicationStep::GET_RAW_MTM_MEASUREMENT; + break; case CommunicationStep::GET_RAW_MTM_MEASUREMENT: - *id = IMTQ::GET_RAW_MTM_MEASUREMENT; - communicationStep = CommunicationStep::GET_ENG_HK_DATA; - break; + *id = IMTQ::GET_RAW_MTM_MEASUREMENT; + communicationStep = CommunicationStep::GET_ENG_HK_DATA; + break; default: - sif::debug << "IMTQHandler::buildNormalDeviceCommand: Invalid communication step" - << std::endl; - break; - } - return buildCommandFromCommand(*id, NULL, 0); + sif::debug << "IMTQHandler::buildNormalDeviceCommand: Invalid communication step" + << std::endl; + break; + } + return buildCommandFromCommand(*id, NULL, 0); } -ReturnValue_t IMTQHandler::buildTransitionDeviceCommand(DeviceCommandId_t * id) { - return RETURN_OK; -} +ReturnValue_t IMTQHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { return RETURN_OK; } ReturnValue_t IMTQHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t * commandData, size_t commandDataLen) { - switch (deviceCommand) { + const uint8_t* commandData, + size_t commandDataLen) { + switch (deviceCommand) { case (IMTQ::POS_X_SELF_TEST): { - commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; - commandBuffer[1] = IMTQ::SELF_TEST_AXIS::X_POSITIVE; - rawPacket = commandBuffer; - rawPacketLen = 2; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; + commandBuffer[1] = IMTQ::SELF_TEST_AXIS::X_POSITIVE; + rawPacket = commandBuffer; + rawPacketLen = 2; + return RETURN_OK; } case (IMTQ::NEG_X_SELF_TEST): { - commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; - commandBuffer[1] = IMTQ::SELF_TEST_AXIS::X_NEGATIVE; - rawPacket = commandBuffer; - rawPacketLen = 2; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; + commandBuffer[1] = IMTQ::SELF_TEST_AXIS::X_NEGATIVE; + rawPacket = commandBuffer; + rawPacketLen = 2; + return RETURN_OK; } case (IMTQ::POS_Y_SELF_TEST): { - commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; - commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Y_POSITIVE; - rawPacket = commandBuffer; - rawPacketLen = 2; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; + commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Y_POSITIVE; + rawPacket = commandBuffer; + rawPacketLen = 2; + return RETURN_OK; } case (IMTQ::NEG_Y_SELF_TEST): { - commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; - commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Y_NEGATIVE; - rawPacket = commandBuffer; - rawPacketLen = 2; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; + commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Y_NEGATIVE; + rawPacket = commandBuffer; + rawPacketLen = 2; + return RETURN_OK; } case (IMTQ::POS_Z_SELF_TEST): { - commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; - commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Z_POSITIVE; - rawPacket = commandBuffer; - rawPacketLen = 2; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; + commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Z_POSITIVE; + rawPacket = commandBuffer; + rawPacketLen = 2; + return RETURN_OK; } case (IMTQ::NEG_Z_SELF_TEST): { - commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; - commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Z_NEGATIVE; - rawPacket = commandBuffer; - rawPacketLen = 2; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; + commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Z_NEGATIVE; + rawPacket = commandBuffer; + rawPacketLen = 2; + return RETURN_OK; } case (IMTQ::GET_SELF_TEST_RESULT): { - commandBuffer[0] = IMTQ::CC::GET_SELF_TEST_RESULT; - rawPacket = commandBuffer; - rawPacketLen = 1; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::GET_SELF_TEST_RESULT; + rawPacket = commandBuffer; + rawPacketLen = 1; + return RETURN_OK; } case (IMTQ::START_ACTUATION_DIPOLE): { - /* IMTQ expects low byte first */ - commandBuffer[0] = IMTQ::CC::START_ACTUATION_DIPOLE; - commandBuffer[1] = *(commandData + 1); - commandBuffer[2] = *(commandData); - commandBuffer[3] = *(commandData + 3); - commandBuffer[4] = *(commandData + 2); - commandBuffer[5] = *(commandData + 5); - commandBuffer[6] = *(commandData + 4); - commandBuffer[7] = *(commandData + 7); - commandBuffer[8] = *(commandData + 6); - rawPacket = commandBuffer; - rawPacketLen = 9; - return RETURN_OK; + /* IMTQ expects low byte first */ + commandBuffer[0] = IMTQ::CC::START_ACTUATION_DIPOLE; + commandBuffer[1] = *(commandData + 1); + commandBuffer[2] = *(commandData); + commandBuffer[3] = *(commandData + 3); + commandBuffer[4] = *(commandData + 2); + commandBuffer[5] = *(commandData + 5); + commandBuffer[6] = *(commandData + 4); + commandBuffer[7] = *(commandData + 7); + commandBuffer[8] = *(commandData + 6); + rawPacket = commandBuffer; + rawPacketLen = 9; + return RETURN_OK; } case (IMTQ::GET_ENG_HK_DATA): { - commandBuffer[0] = IMTQ::CC::GET_ENG_HK_DATA; - rawPacket = commandBuffer; - rawPacketLen = 1; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::GET_ENG_HK_DATA; + rawPacket = commandBuffer; + rawPacketLen = 1; + return RETURN_OK; } case (IMTQ::GET_COMMANDED_DIPOLE): { - commandBuffer[0] = IMTQ::CC::GET_COMMANDED_DIPOLE; - rawPacket = commandBuffer; - rawPacketLen = 1; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::GET_COMMANDED_DIPOLE; + rawPacket = commandBuffer; + rawPacketLen = 1; + return RETURN_OK; } case (IMTQ::START_MTM_MEASUREMENT): { - commandBuffer[0] = IMTQ::CC::START_MTM_MEASUREMENT; - rawPacket = commandBuffer; - rawPacketLen = 1; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::START_MTM_MEASUREMENT; + rawPacket = commandBuffer; + rawPacketLen = 1; + return RETURN_OK; } case (IMTQ::GET_CAL_MTM_MEASUREMENT): { - commandBuffer[0] = IMTQ::CC::GET_CAL_MTM_MEASUREMENT; - rawPacket = commandBuffer; - rawPacketLen = 1; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::GET_CAL_MTM_MEASUREMENT; + rawPacket = commandBuffer; + rawPacketLen = 1; + return RETURN_OK; } case (IMTQ::GET_RAW_MTM_MEASUREMENT): { - commandBuffer[0] = IMTQ::CC::GET_RAW_MTM_MEASUREMENT; - rawPacket = commandBuffer; - rawPacketLen = 1; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::GET_RAW_MTM_MEASUREMENT; + rawPacket = commandBuffer; + rawPacketLen = 1; + return RETURN_OK; } default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } void IMTQHandler::fillCommandAndReplyMap() { - this->insertInCommandAndReplyMap(IMTQ::POS_X_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::NEG_X_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::POS_Y_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::NEG_Y_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::POS_Z_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::NEG_Z_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::GET_SELF_TEST_RESULT, 1, nullptr, - IMTQ::SIZE_SELF_TEST_RESULTS); - this->insertInCommandAndReplyMap(IMTQ::START_ACTUATION_DIPOLE, 1, nullptr, - IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::GET_ENG_HK_DATA, 1, &engHkDataset, - IMTQ::SIZE_ENG_HK_DATA_REPLY); - this->insertInCommandAndReplyMap(IMTQ::GET_COMMANDED_DIPOLE, 1, nullptr, - IMTQ::SIZE_GET_COMMANDED_DIPOLE_REPLY); - this->insertInCommandAndReplyMap(IMTQ::START_MTM_MEASUREMENT, 1, nullptr, - IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::GET_CAL_MTM_MEASUREMENT, 1, &calMtmMeasurementSet, - IMTQ::SIZE_GET_CAL_MTM_MEASUREMENT); - this->insertInCommandAndReplyMap(IMTQ::GET_RAW_MTM_MEASUREMENT, 1, &rawMtmMeasurementSet, - IMTQ::SIZE_GET_RAW_MTM_MEASUREMENT); + this->insertInCommandAndReplyMap(IMTQ::POS_X_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::NEG_X_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::POS_Y_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::NEG_Y_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::POS_Z_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::NEG_Z_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::GET_SELF_TEST_RESULT, 1, nullptr, + IMTQ::SIZE_SELF_TEST_RESULTS); + this->insertInCommandAndReplyMap(IMTQ::START_ACTUATION_DIPOLE, 1, nullptr, + IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::GET_ENG_HK_DATA, 1, &engHkDataset, + IMTQ::SIZE_ENG_HK_DATA_REPLY); + this->insertInCommandAndReplyMap(IMTQ::GET_COMMANDED_DIPOLE, 1, nullptr, + IMTQ::SIZE_GET_COMMANDED_DIPOLE_REPLY); + this->insertInCommandAndReplyMap(IMTQ::START_MTM_MEASUREMENT, 1, nullptr, + IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::GET_CAL_MTM_MEASUREMENT, 1, &calMtmMeasurementSet, + IMTQ::SIZE_GET_CAL_MTM_MEASUREMENT); + this->insertInCommandAndReplyMap(IMTQ::GET_RAW_MTM_MEASUREMENT, 1, &rawMtmMeasurementSet, + IMTQ::SIZE_GET_RAW_MTM_MEASUREMENT); } -ReturnValue_t IMTQHandler::scanForReply(const uint8_t *start, size_t remainingSize, - DeviceCommandId_t *foundId, size_t *foundLen) { +ReturnValue_t IMTQHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; - - switch (*start) { + switch (*start) { case (IMTQ::CC::START_ACTUATION_DIPOLE): - *foundLen = IMTQ::SIZE_STATUS_REPLY; - *foundId = IMTQ::START_ACTUATION_DIPOLE; - break; + *foundLen = IMTQ::SIZE_STATUS_REPLY; + *foundId = IMTQ::START_ACTUATION_DIPOLE; + break; case (IMTQ::CC::START_MTM_MEASUREMENT): - *foundLen = IMTQ::SIZE_STATUS_REPLY; - *foundId = IMTQ::START_MTM_MEASUREMENT; - break; + *foundLen = IMTQ::SIZE_STATUS_REPLY; + *foundId = IMTQ::START_MTM_MEASUREMENT; + break; case (IMTQ::CC::GET_ENG_HK_DATA): - *foundLen = IMTQ::SIZE_ENG_HK_DATA_REPLY; - *foundId = IMTQ::GET_ENG_HK_DATA; - break; + *foundLen = IMTQ::SIZE_ENG_HK_DATA_REPLY; + *foundId = IMTQ::GET_ENG_HK_DATA; + break; case (IMTQ::CC::GET_COMMANDED_DIPOLE): - *foundLen = IMTQ::SIZE_GET_COMMANDED_DIPOLE_REPLY; - *foundId = IMTQ::GET_COMMANDED_DIPOLE; - break; + *foundLen = IMTQ::SIZE_GET_COMMANDED_DIPOLE_REPLY; + *foundId = IMTQ::GET_COMMANDED_DIPOLE; + break; case (IMTQ::CC::GET_CAL_MTM_MEASUREMENT): - *foundLen = IMTQ::SIZE_GET_CAL_MTM_MEASUREMENT; - *foundId = IMTQ::GET_CAL_MTM_MEASUREMENT; - break; + *foundLen = IMTQ::SIZE_GET_CAL_MTM_MEASUREMENT; + *foundId = IMTQ::GET_CAL_MTM_MEASUREMENT; + break; case (IMTQ::CC::GET_RAW_MTM_MEASUREMENT): - *foundLen = IMTQ::SIZE_GET_RAW_MTM_MEASUREMENT; - *foundId = IMTQ::GET_RAW_MTM_MEASUREMENT; - break; + *foundLen = IMTQ::SIZE_GET_RAW_MTM_MEASUREMENT; + *foundId = IMTQ::GET_RAW_MTM_MEASUREMENT; + break; case (IMTQ::CC::SELF_TEST_CMD): - *foundLen = IMTQ::SIZE_STATUS_REPLY; - result = getSelfTestCommandId(foundId); - break; + *foundLen = IMTQ::SIZE_STATUS_REPLY; + result = getSelfTestCommandId(foundId); + break; case (IMTQ::CC::GET_SELF_TEST_RESULT): - *foundLen = IMTQ::SIZE_SELF_TEST_RESULTS; - *foundId = IMTQ::GET_SELF_TEST_RESULT; - break; + *foundLen = IMTQ::SIZE_SELF_TEST_RESULTS; + *foundId = IMTQ::GET_SELF_TEST_RESULT; + break; default: - sif::debug << "IMTQHandler::scanForReply: Reply contains invalid command code" << std::endl; - result = IGNORE_REPLY_DATA; - break; - } + sif::debug << "IMTQHandler::scanForReply: Reply contains invalid command code" << std::endl; + result = IGNORE_REPLY_DATA; + break; + } - return result; + return result; } -ReturnValue_t IMTQHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { +ReturnValue_t IMTQHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = parseStatusByte(packet); - result = parseStatusByte(packet); + if (result != RETURN_OK) { + return result; + } - if (result != RETURN_OK) { - return result; - } - - switch (id) { + switch (id) { case (IMTQ::POS_X_SELF_TEST): case (IMTQ::NEG_X_SELF_TEST): case (IMTQ::POS_Y_SELF_TEST): @@ -251,1879 +252,1923 @@ ReturnValue_t IMTQHandler::interpretDeviceReply(DeviceCommandId_t id, const uint case (IMTQ::NEG_Z_SELF_TEST): case (IMTQ::START_ACTUATION_DIPOLE): case (IMTQ::START_MTM_MEASUREMENT): - /* Replies only the status byte which is already handled with parseStatusByte */ - break; + /* Replies only the status byte which is already handled with parseStatusByte */ + break; case (IMTQ::GET_ENG_HK_DATA): - fillEngHkDataset(packet); - break; + fillEngHkDataset(packet); + break; case (IMTQ::GET_COMMANDED_DIPOLE): - handleGetCommandedDipoleReply(packet); - break; + handleGetCommandedDipoleReply(packet); + break; case (IMTQ::GET_CAL_MTM_MEASUREMENT): - fillCalibratedMtmDataset(packet); - break; + fillCalibratedMtmDataset(packet); + break; case (IMTQ::GET_RAW_MTM_MEASUREMENT): - fillRawMtmDataset(packet); - break; + fillRawMtmDataset(packet); + break; case (IMTQ::GET_SELF_TEST_RESULT): - handleSelfTestReply(packet); - break; + handleSelfTestReply(packet); + break; default: { - sif::debug << "IMTQHandler::interpretDeviceReply: Unknown device reply id" << std::endl; - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } + sif::debug << "IMTQHandler::interpretDeviceReply: Unknown device reply id" << std::endl; + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; } + } - return RETURN_OK; + return RETURN_OK; } -void IMTQHandler::setNormalDatapoolEntriesInvalid() { - -} +void IMTQHandler::setNormalDatapoolEntriesInvalid() {} LocalPoolDataSetBase* IMTQHandler::getDataSetHandle(sid_t sid) { - if (sid == engHkDataset.getSid()) { - return &engHkDataset; - } else if (sid == calMtmMeasurementSet.getSid()) { - return &calMtmMeasurementSet; - } else if (sid == rawMtmMeasurementSet.getSid()) { - return &rawMtmMeasurementSet; - } else if (sid == posXselfTestDataset.getSid()) { - return &posXselfTestDataset; - } else if (sid == negXselfTestDataset.getSid()) { - return &negXselfTestDataset; - } else if (sid == posYselfTestDataset.getSid()) { - return &posYselfTestDataset; - } else if (sid == negYselfTestDataset.getSid()) { - return &negYselfTestDataset; - } else if (sid == posZselfTestDataset.getSid()) { - return &posZselfTestDataset; - } else if (sid == negZselfTestDataset.getSid()) { - return &negZselfTestDataset; - } else { - sif::error << "IMTQHandler::getDataSetHandle: Invalid sid" << std::endl; - return nullptr; - } + if (sid == engHkDataset.getSid()) { + return &engHkDataset; + } else if (sid == calMtmMeasurementSet.getSid()) { + return &calMtmMeasurementSet; + } else if (sid == rawMtmMeasurementSet.getSid()) { + return &rawMtmMeasurementSet; + } else if (sid == posXselfTestDataset.getSid()) { + return &posXselfTestDataset; + } else if (sid == negXselfTestDataset.getSid()) { + return &negXselfTestDataset; + } else if (sid == posYselfTestDataset.getSid()) { + return &posYselfTestDataset; + } else if (sid == negYselfTestDataset.getSid()) { + return &negYselfTestDataset; + } else if (sid == posZselfTestDataset.getSid()) { + return &posZselfTestDataset; + } else if (sid == negZselfTestDataset.getSid()) { + return &negZselfTestDataset; + } else { + sif::error << "IMTQHandler::getDataSetHandle: Invalid sid" << std::endl; + return nullptr; + } } -uint32_t IMTQHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { - return 5000; -} +uint32_t IMTQHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 5000; } ReturnValue_t IMTQHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { + LocalDataPoolManager& poolManager) { + /** Entries of engineering housekeeping dataset */ + localDataPoolMap.emplace(IMTQ::DIGITAL_VOLTAGE_MV, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::ANALOG_VOLTAGE_MV, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::DIGITAL_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::ANALOG_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::COIL_Z_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::MCU_TEMPERATURE, new PoolEntry({0})); - /** Entries of engineering housekeeping dataset */ - localDataPoolMap.emplace(IMTQ::DIGITAL_VOLTAGE_MV, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::ANALOG_VOLTAGE_MV, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::DIGITAL_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::ANALOG_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::MCU_TEMPERATURE, new PoolEntry( { 0 })); + /** Entries of calibrated MTM measurement dataset */ + localDataPoolMap.emplace(IMTQ::MTM_CAL_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::MTM_CAL_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::MTM_CAL_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::ACTUATION_CAL_STATUS, new PoolEntry({0})); - /** Entries of calibrated MTM measurement dataset */ - localDataPoolMap.emplace(IMTQ::MTM_CAL_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::MTM_CAL_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::MTM_CAL_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::ACTUATION_CAL_STATUS, new PoolEntry( { 0 })); + /** Entries of raw MTM measurement dataset */ + localDataPoolMap.emplace(IMTQ::MTM_RAW_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::MTM_RAW_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::MTM_RAW_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::ACTUATION_RAW_STATUS, new PoolEntry({0})); - /** Entries of raw MTM measurement dataset */ - localDataPoolMap.emplace(IMTQ::MTM_RAW_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::MTM_RAW_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::MTM_RAW_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::ACTUATION_RAW_STATUS, new PoolEntry( { 0 })); + /** INIT measurements for positive X axis test */ + localDataPoolMap.emplace(IMTQ::INIT_POS_X_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** INIT measurements for positive X axis test */ - localDataPoolMap.emplace(IMTQ::INIT_POS_X_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** INIT measurements for negative X axis test */ + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** INIT measurements for negative X axis test */ - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** INIT measurements for positive Y axis test */ + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** INIT measurements for positive Y axis test */ - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** INIT measurements for negative Y axis test */ + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** INIT measurements for negative Y axis test */ - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** INIT measurements for positive Z axis test */ + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** INIT measurements for positive Z axis test */ - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** INIT measurements for negative Z axis test */ + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** INIT measurements for negative Z axis test */ - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(IMTQ::POS_X_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_COIL_Z_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(IMTQ::POS_X_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(IMTQ::NEG_X_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Z_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(IMTQ::NEG_X_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(IMTQ::POS_Y_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Z_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(IMTQ::POS_Y_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(IMTQ::NEG_Y_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Z_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(IMTQ::NEG_Y_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(IMTQ::POS_Z_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Z_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(IMTQ::POS_Z_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(IMTQ::NEG_Z_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Z_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(IMTQ::NEG_Z_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** FINA measurements for positive X axis test */ + localDataPoolMap.emplace(IMTQ::FINA_POS_X_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** FINA measurements for positive X axis test */ - localDataPoolMap.emplace(IMTQ::FINA_POS_X_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** FINA measurements for negative X axis test */ + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** FINA measurements for negative X axis test */ - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** FINA measurements for positive Y axis test */ + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** FINA measurements for positive Y axis test */ - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** FINA measurements for negative Y axis test */ + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** FINA measurements for negative Y axis test */ - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** FINA measurements for positive Z axis test */ + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** FINA measurements for positive Z axis test */ - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** FINA measurements for negative Z axis test */ + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** FINA measurements for negative Z axis test */ - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t IMTQHandler::getSelfTestCommandId(DeviceCommandId_t* id) { - DeviceCommandId_t commandId = getPendingCommand(); - switch (commandId) { + DeviceCommandId_t commandId = getPendingCommand(); + switch (commandId) { case IMTQ::POS_X_SELF_TEST: case IMTQ::NEG_X_SELF_TEST: case IMTQ::POS_Y_SELF_TEST: case IMTQ::NEG_Y_SELF_TEST: case IMTQ::POS_Z_SELF_TEST: case IMTQ::NEG_Z_SELF_TEST: - *id = commandId; - break; + *id = commandId; + break; default: - sif::error << "IMTQHandler::getSelfTestCommandId: Reply does not match to pending " - << "command" << std::endl; - return UNEXPECTED_SELF_TEST_REPLY; - } - return RETURN_OK; + sif::error << "IMTQHandler::getSelfTestCommandId: Reply does not match to pending " + << "command" << std::endl; + return UNEXPECTED_SELF_TEST_REPLY; + } + return RETURN_OK; } ReturnValue_t IMTQHandler::parseStatusByte(const uint8_t* packet) { - uint8_t cmdErrorField = *(packet + 1) & 0xF; - switch (cmdErrorField) { + uint8_t cmdErrorField = *(packet + 1) & 0xF; + switch (cmdErrorField) { case 0: - return RETURN_OK; + return RETURN_OK; case 1: - sif::error << "IMTQHandler::parseStatusByte: Command rejected without reason" << std::endl; - return REJECTED_WITHOUT_REASON; + sif::error << "IMTQHandler::parseStatusByte: Command rejected without reason" << std::endl; + return REJECTED_WITHOUT_REASON; case 2: - sif::error << "IMTQHandler::parseStatusByte: Command has invalid command code" << std::endl; - return INVALID_COMMAND_CODE; + sif::error << "IMTQHandler::parseStatusByte: Command has invalid command code" << std::endl; + return INVALID_COMMAND_CODE; case 3: - sif::error << "IMTQHandler::parseStatusByte: Command has missing parameter" << std::endl; - return PARAMETER_MISSING; + sif::error << "IMTQHandler::parseStatusByte: Command has missing parameter" << std::endl; + return PARAMETER_MISSING; case 4: - sif::error << "IMTQHandler::parseStatusByte: Command has invalid parameter" << std::endl; - return PARAMETER_INVALID; + sif::error << "IMTQHandler::parseStatusByte: Command has invalid parameter" << std::endl; + return PARAMETER_INVALID; case 5: - sif::error << "IMTQHandler::parseStatusByte: CC unavailable" << std::endl; - return CC_UNAVAILABLE; + sif::error << "IMTQHandler::parseStatusByte: CC unavailable" << std::endl; + return CC_UNAVAILABLE; case 7: - sif::error << "IMTQHandler::parseStatusByte: IMQT replied internal processing error" - << std::endl; - return INTERNAL_PROCESSING_ERROR; + sif::error << "IMTQHandler::parseStatusByte: IMQT replied internal processing error" + << std::endl; + return INTERNAL_PROCESSING_ERROR; default: - sif::error << "IMTQHandler::parseStatusByte: CMD Error field contains unknown error code " - << cmdErrorField << std::endl; - return CMD_ERR_UNKNOWN; - } + sif::error << "IMTQHandler::parseStatusByte: CMD Error field contains unknown error code " + << cmdErrorField << std::endl; + return CMD_ERR_UNKNOWN; + } } void IMTQHandler::fillEngHkDataset(const uint8_t* packet) { - PoolReadGuard rg(&engHkDataset); - uint8_t offset = 2; - engHkDataset.digitalVoltageMv = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - engHkDataset.analogVoltageMv = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - engHkDataset.digitalCurrentmA = (*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; - offset += 2; - engHkDataset.analogCurrentmA = (*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; - offset += 2; - engHkDataset.coilXCurrentmA = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - engHkDataset.coilYCurrentmA = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - engHkDataset.coilZCurrentmA = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - engHkDataset.coilXTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); - offset += 2; - engHkDataset.coilYTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); - offset += 2; - engHkDataset.coilZTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); - offset += 2; - engHkDataset.mcuTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); + PoolReadGuard rg(&engHkDataset); + uint8_t offset = 2; + engHkDataset.digitalVoltageMv = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + engHkDataset.analogVoltageMv = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + engHkDataset.digitalCurrentmA = (*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + engHkDataset.analogCurrentmA = (*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + engHkDataset.coilXCurrentmA = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + engHkDataset.coilYCurrentmA = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + engHkDataset.coilZCurrentmA = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + engHkDataset.coilXTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); + offset += 2; + engHkDataset.coilYTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); + offset += 2; + engHkDataset.coilZTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); + offset += 2; + engHkDataset.mcuTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ digital voltage: " << engHkDataset.digitalVoltageMv << " mV" << std::endl; - sif::info << "IMTQ analog voltage: " << engHkDataset.analogVoltageMv << " mV" << std::endl; - sif::info << "IMTQ digital current: " << engHkDataset.digitalCurrentmA << " mA" << std::endl; - sif::info << "IMTQ analog current: " << engHkDataset.analogCurrentmA << " mA" << std::endl; - sif::info << "IMTQ coil X current: " << engHkDataset.coilXCurrentmA << " mA" << std::endl; - sif::info << "IMTQ coil Y current: " << engHkDataset.coilYCurrentmA << " mA" << std::endl; - sif::info << "IMTQ coil Z current: " << engHkDataset.coilZCurrentmA << " mA" << std::endl; - sif::info << "IMTQ coil X temperature: " << engHkDataset.coilXTemperature << " °C" - << std::endl; - sif::info << "IMTQ coil Y temperature: " << engHkDataset.coilYTemperature << " °C" - << std::endl; - sif::info << "IMTQ coil Z temperature: " << engHkDataset.coilZTemperature << " °C" - << std::endl; - sif::info << "IMTQ coil MCU temperature: " << engHkDataset.mcuTemperature << " °C" - << std::endl; +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ digital voltage: " << engHkDataset.digitalVoltageMv << " mV" << std::endl; + sif::info << "IMTQ analog voltage: " << engHkDataset.analogVoltageMv << " mV" << std::endl; + sif::info << "IMTQ digital current: " << engHkDataset.digitalCurrentmA << " mA" << std::endl; + sif::info << "IMTQ analog current: " << engHkDataset.analogCurrentmA << " mA" << std::endl; + sif::info << "IMTQ coil X current: " << engHkDataset.coilXCurrentmA << " mA" << std::endl; + sif::info << "IMTQ coil Y current: " << engHkDataset.coilYCurrentmA << " mA" << std::endl; + sif::info << "IMTQ coil Z current: " << engHkDataset.coilZCurrentmA << " mA" << std::endl; + sif::info << "IMTQ coil X temperature: " << engHkDataset.coilXTemperature << " °C" << std::endl; + sif::info << "IMTQ coil Y temperature: " << engHkDataset.coilYTemperature << " °C" << std::endl; + sif::info << "IMTQ coil Z temperature: " << engHkDataset.coilZTemperature << " °C" << std::endl; + sif::info << "IMTQ coil MCU temperature: " << engHkDataset.mcuTemperature << " °C" << std::endl; #endif } -void IMTQHandler::setModeNormal() { - mode = MODE_NORMAL; -} +void IMTQHandler::setModeNormal() { mode = MODE_NORMAL; } void IMTQHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId) { + if (wiretappingMode == RAW) { + /* Data already sent in doGetRead() */ + return; + } - if (wiretappingMode == RAW) { - /* Data already sent in doGetRead() */ - return; - } + DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId); + if (iter == deviceReplyMap.end()) { + sif::debug << "IMTQHandler::handleDeviceTM: Unknown reply id" << std::endl; + return; + } + MessageQueueId_t queueId = iter->second.command->second.sendReplyTo; - DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId); - if (iter == deviceReplyMap.end()) { - sif::debug << "IMTQHandler::handleDeviceTM: Unknown reply id" << std::endl; - return; - } - MessageQueueId_t queueId = iter->second.command->second.sendReplyTo; + if (queueId == NO_COMMANDER) { + return; + } - if (queueId == NO_COMMANDER) { - return; - } - - ReturnValue_t result = actionHelper.reportData(queueId, replyId, data, dataSize); - if (result != RETURN_OK) { - sif::debug << "IMTQHandler::handleDeviceTM: Failed to report data" << std::endl; - return; - } + ReturnValue_t result = actionHelper.reportData(queueId, replyId, data, dataSize); + if (result != RETURN_OK) { + sif::debug << "IMTQHandler::handleDeviceTM: Failed to report data" << std::endl; + return; + } } void IMTQHandler::handleGetCommandedDipoleReply(const uint8_t* packet) { - uint8_t tmData[6]; - /* Switching endianess of received dipole values */ - tmData[0] = *(packet + 3); - tmData[1] = *(packet + 2); - tmData[2] = *(packet + 5); - tmData[3] = *(packet + 4); - tmData[4] = *(packet + 7); - tmData[5] = *(packet + 6); - handleDeviceTM(tmData, sizeof(tmData), IMTQ::GET_COMMANDED_DIPOLE); + uint8_t tmData[6]; + /* Switching endianess of received dipole values */ + tmData[0] = *(packet + 3); + tmData[1] = *(packet + 2); + tmData[2] = *(packet + 5); + tmData[3] = *(packet + 4); + tmData[4] = *(packet + 7); + tmData[5] = *(packet + 6); + handleDeviceTM(tmData, sizeof(tmData), IMTQ::GET_COMMANDED_DIPOLE); } void IMTQHandler::fillCalibratedMtmDataset(const uint8_t* packet) { - PoolReadGuard rg(&calMtmMeasurementSet); - int8_t offset = 2; - calMtmMeasurementSet.mtmXnT = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - calMtmMeasurementSet.mtmYnT = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - calMtmMeasurementSet.mtmZnT = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - calMtmMeasurementSet.coilActuationStatus = (*(packet + offset + 3) << 24) - | (*(packet + offset + 2) << 16) | (*(packet + offset + 1) << 8) | (*(packet + offset)); -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ calibrated MTM measurement X: " << calMtmMeasurementSet.mtmXnT << " nT" + PoolReadGuard rg(&calMtmMeasurementSet); + int8_t offset = 2; + calMtmMeasurementSet.mtmXnT = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + calMtmMeasurementSet.mtmYnT = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + calMtmMeasurementSet.mtmZnT = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + calMtmMeasurementSet.coilActuationStatus = (*(packet + offset + 3) << 24) | + (*(packet + offset + 2) << 16) | + (*(packet + offset + 1) << 8) | (*(packet + offset)); +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ calibrated MTM measurement X: " << calMtmMeasurementSet.mtmXnT << " nT" << std::endl; - sif::info << "IMTQ calibrated MTM measurement Y: " << calMtmMeasurementSet.mtmYnT << " nT" + sif::info << "IMTQ calibrated MTM measurement Y: " << calMtmMeasurementSet.mtmYnT << " nT" << std::endl; - sif::info << "IMTQ calibrated MTM measurement Z: " << calMtmMeasurementSet.mtmZnT << " nT" + sif::info << "IMTQ calibrated MTM measurement Z: " << calMtmMeasurementSet.mtmZnT << " nT" << std::endl; - sif::info << "IMTQ coil actuation status during MTM measurement: " - << (unsigned int) calMtmMeasurementSet.coilActuationStatus.value << std::endl; + sif::info << "IMTQ coil actuation status during MTM measurement: " + << (unsigned int)calMtmMeasurementSet.coilActuationStatus.value << std::endl; #endif } void IMTQHandler::fillRawMtmDataset(const uint8_t* packet) { - PoolReadGuard rg(&rawMtmMeasurementSet); - int8_t offset = 2; - rawMtmMeasurementSet.mtmXnT = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - rawMtmMeasurementSet.mtmYnT = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - rawMtmMeasurementSet.mtmZnT = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - rawMtmMeasurementSet.coilActuationStatus = (*(packet + offset + 3) << 24) - | (*(packet + offset + 2) << 16) | (*(packet + offset + 1) << 8) | (*(packet + offset)); -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ raw MTM measurement X: " << rawMtmMeasurementSet.mtmXnT << " nT" - << std::endl; - sif::info << "IMTQ raw MTM measurement Y: " << rawMtmMeasurementSet.mtmYnT << " nT" - << std::endl; - sif::info << "IMTQ raw MTM measurement Z: " << rawMtmMeasurementSet.mtmZnT << " nT" - << std::endl; - sif::info << "IMTQ coil actuation status during MTM measurement: " - << (unsigned int) rawMtmMeasurementSet.coilActuationStatus.value << std::endl; + PoolReadGuard rg(&rawMtmMeasurementSet); + int8_t offset = 2; + rawMtmMeasurementSet.mtmXnT = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + rawMtmMeasurementSet.mtmYnT = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + rawMtmMeasurementSet.mtmZnT = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + rawMtmMeasurementSet.coilActuationStatus = (*(packet + offset + 3) << 24) | + (*(packet + offset + 2) << 16) | + (*(packet + offset + 1) << 8) | (*(packet + offset)); +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ raw MTM measurement X: " << rawMtmMeasurementSet.mtmXnT << " nT" << std::endl; + sif::info << "IMTQ raw MTM measurement Y: " << rawMtmMeasurementSet.mtmYnT << " nT" << std::endl; + sif::info << "IMTQ raw MTM measurement Z: " << rawMtmMeasurementSet.mtmZnT << " nT" << std::endl; + sif::info << "IMTQ coil actuation status during MTM measurement: " + << (unsigned int)rawMtmMeasurementSet.coilActuationStatus.value << std::endl; #endif } void IMTQHandler::handleSelfTestReply(const uint8_t* packet) { - uint16_t offset = 2; - checkErrorByte(*(packet + offset), *(packet + offset + 1)); + uint16_t offset = 2; + checkErrorByte(*(packet + offset), *(packet + offset + 1)); - switch (*(packet + IMTQ::MAIN_STEP_OFFSET)) { + switch (*(packet + IMTQ::MAIN_STEP_OFFSET)) { case IMTQ::SELF_TEST_STEPS::X_POSITIVE: { - handlePositiveXSelfTestReply(packet); - break; + handlePositiveXSelfTestReply(packet); + break; } case IMTQ::SELF_TEST_STEPS::X_NEGATIVE: { - handleNegativeXSelfTestReply(packet); - break; + handleNegativeXSelfTestReply(packet); + break; } case IMTQ::SELF_TEST_STEPS::Y_POSITIVE: { - handlePositiveYSelfTestReply(packet); - break; + handlePositiveYSelfTestReply(packet); + break; } case IMTQ::SELF_TEST_STEPS::Y_NEGATIVE: { - handleNegativeYSelfTestReply(packet); - break; + handleNegativeYSelfTestReply(packet); + break; } case IMTQ::SELF_TEST_STEPS::Z_POSITIVE: { - handlePositiveZSelfTestReply(packet); - break; + handlePositiveZSelfTestReply(packet); + break; } case IMTQ::SELF_TEST_STEPS::Z_NEGATIVE: { - handleNegativeZSelfTestReply(packet); - break; + handleNegativeZSelfTestReply(packet); + break; } default: - break; - } + break; + } } void IMTQHandler::handlePositiveXSelfTestReply(const uint8_t* packet) { - PoolReadGuard rg(&posXselfTestDataset); + PoolReadGuard rg(&posXselfTestDataset); - uint16_t offset = 2; - /** Init measurements */ - posXselfTestDataset.initErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - posXselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.initCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.initCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.initCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posXselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posXselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + uint16_t offset = 2; + /** Init measurements */ + posXselfTestDataset.initErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + posXselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.initCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.initCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.initCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posXselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posXselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** +X measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - posXselfTestDataset.err = *(packet + offset); - offset += 2; // STEP byte will not be stored - posXselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.coilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.coilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.coilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posXselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posXselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** +X measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + posXselfTestDataset.err = *(packet + offset); + offset += 2; // STEP byte will not be stored + posXselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.coilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.coilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.coilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posXselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posXselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** FINA measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - posXselfTestDataset.finaErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - posXselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.finaCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.finaCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.finaCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posXselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posXselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** FINA measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + posXselfTestDataset.finaErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + posXselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.finaCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.finaCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.finaCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posXselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posXselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ self test (INIT) err: " +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ self test (INIT) err: " << static_cast(posXselfTestDataset.initErr.value) << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field X: " << posXselfTestDataset.initRawMagX + sif::info << "IMTQ self test (INIT) raw magnetic field X: " << posXselfTestDataset.initRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << posXselfTestDataset.initRawMagY + sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << posXselfTestDataset.initRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << posXselfTestDataset.initRawMagZ + sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << posXselfTestDataset.initRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " << posXselfTestDataset.initCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " << posXselfTestDataset.initCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " << posXselfTestDataset.initCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) coil X current: " << posXselfTestDataset.initCoilXCurrent + sif::info << "IMTQ self test (INIT) coil X current: " << posXselfTestDataset.initCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y current: " << posXselfTestDataset.initCoilYCurrent + sif::info << "IMTQ self test (INIT) coil Y current: " << posXselfTestDataset.initCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z current: " << posXselfTestDataset.initCoilZCurrent + sif::info << "IMTQ self test (INIT) coil Z current: " << posXselfTestDataset.initCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil X temperature: " + sif::info << "IMTQ self test (INIT) coil X temperature: " << posXselfTestDataset.initCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y temperature: " + sif::info << "IMTQ self test (INIT) coil Y temperature: " << posXselfTestDataset.initCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z temperature: " + sif::info << "IMTQ self test (INIT) coil Z temperature: " << posXselfTestDataset.initCoilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+X) err: " + sif::info << "IMTQ self test (+X) err: " << static_cast(posXselfTestDataset.err.value) << std::endl; - sif::info << "IMTQ self test (+X) raw magnetic field X: " << posXselfTestDataset.rawMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (+X) raw magnetic field Y: " << posXselfTestDataset.rawMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (+X) raw magnetic field Z: " << posXselfTestDataset.rawMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (+X) calibrated magnetic field X: " << posXselfTestDataset.calMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (+X) calibrated magnetic field Y: " << posXselfTestDataset.calMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (+X) calibrated magnetic field Z: " << posXselfTestDataset.calMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (+X) coil X current: " << posXselfTestDataset.coilXCurrent << " mA" + sif::info << "IMTQ self test (+X) raw magnetic field X: " << posXselfTestDataset.rawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (+X) coil Y current: " << posXselfTestDataset.coilYCurrent << " mA" + sif::info << "IMTQ self test (+X) raw magnetic field Y: " << posXselfTestDataset.rawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (+X) coil Z current: " << posXselfTestDataset.coilZCurrent << " mA" + sif::info << "IMTQ self test (+X) raw magnetic field Z: " << posXselfTestDataset.rawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (+X) coil X temperature: " << posXselfTestDataset.coilXTemperature + sif::info << "IMTQ self test (+X) calibrated magnetic field X: " << posXselfTestDataset.calMagX + << " nT" << std::endl; + sif::info << "IMTQ self test (+X) calibrated magnetic field Y: " << posXselfTestDataset.calMagY + << " nT" << std::endl; + sif::info << "IMTQ self test (+X) calibrated magnetic field Z: " << posXselfTestDataset.calMagZ + << " nT" << std::endl; + sif::info << "IMTQ self test (+X) coil X current: " << posXselfTestDataset.coilXCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+X) coil Y current: " << posXselfTestDataset.coilYCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+X) coil Z current: " << posXselfTestDataset.coilZCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+X) coil X temperature: " << posXselfTestDataset.coilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+X) coil Y temperature: " << posXselfTestDataset.coilYTemperature + sif::info << "IMTQ self test (+X) coil Y temperature: " << posXselfTestDataset.coilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+X) coil Z temperature: " << posXselfTestDataset.coilZTemperature + sif::info << "IMTQ self test (+X) coil Z temperature: " << posXselfTestDataset.coilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) err: " + sif::info << "IMTQ self test (FINA) err: " << static_cast(posXselfTestDataset.finaErr.value) << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field X: " << posXselfTestDataset.finaRawMagX + sif::info << "IMTQ self test (FINA) raw magnetic field X: " << posXselfTestDataset.finaRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << posXselfTestDataset.finaRawMagY + sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << posXselfTestDataset.finaRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << posXselfTestDataset.finaRawMagZ + sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << posXselfTestDataset.finaRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " << posXselfTestDataset.finaCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " << posXselfTestDataset.finaCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " << posXselfTestDataset.finaCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) coil X current: " << posXselfTestDataset.finaCoilXCurrent + sif::info << "IMTQ self test (FINA) coil X current: " << posXselfTestDataset.finaCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y current: " << posXselfTestDataset.finaCoilYCurrent + sif::info << "IMTQ self test (FINA) coil Y current: " << posXselfTestDataset.finaCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z current: " << posXselfTestDataset.finaCoilZCurrent + sif::info << "IMTQ self test (FINA) coil Z current: " << posXselfTestDataset.finaCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil X temperature: " + sif::info << "IMTQ self test (FINA) coil X temperature: " << posXselfTestDataset.finaCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y temperature: " + sif::info << "IMTQ self test (FINA) coil Y temperature: " << posXselfTestDataset.finaCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z temperature: " + sif::info << "IMTQ self test (FINA) coil Z temperature: " << posXselfTestDataset.finaCoilZTemperature << " °C" << std::endl; #endif } void IMTQHandler::handleNegativeXSelfTestReply(const uint8_t* packet) { - PoolReadGuard rg(&posXselfTestDataset); + PoolReadGuard rg(&posXselfTestDataset); - uint16_t offset = 2; - /** Init measurements */ - negXselfTestDataset.initErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - negXselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.initCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.initCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.initCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negXselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negXselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + uint16_t offset = 2; + /** Init measurements */ + negXselfTestDataset.initErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + negXselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.initCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.initCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.initCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negXselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negXselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** +X measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - negXselfTestDataset.err = *(packet + offset); - offset += 2; // STEP byte will not be stored - negXselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.coilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.coilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.coilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negXselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negXselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** +X measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + negXselfTestDataset.err = *(packet + offset); + offset += 2; // STEP byte will not be stored + negXselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.coilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.coilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.coilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negXselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negXselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** FINA measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - negXselfTestDataset.finaErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - negXselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.finaCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.finaCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.finaCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negXselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negXselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** FINA measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + negXselfTestDataset.finaErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + negXselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.finaCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.finaCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.finaCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negXselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negXselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ self test (INIT) err: " +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ self test (INIT) err: " << static_cast(negXselfTestDataset.initErr.value) << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field X: " << negXselfTestDataset.initRawMagX + sif::info << "IMTQ self test (INIT) raw magnetic field X: " << negXselfTestDataset.initRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << negXselfTestDataset.initRawMagY + sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << negXselfTestDataset.initRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << negXselfTestDataset.initRawMagZ + sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << negXselfTestDataset.initRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " << negXselfTestDataset.initCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " << negXselfTestDataset.initCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " << negXselfTestDataset.initCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) coil X current: " << negXselfTestDataset.initCoilXCurrent + sif::info << "IMTQ self test (INIT) coil X current: " << negXselfTestDataset.initCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y current: " << negXselfTestDataset.initCoilYCurrent + sif::info << "IMTQ self test (INIT) coil Y current: " << negXselfTestDataset.initCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z current: " << negXselfTestDataset.initCoilZCurrent + sif::info << "IMTQ self test (INIT) coil Z current: " << negXselfTestDataset.initCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil X temperature: " + sif::info << "IMTQ self test (INIT) coil X temperature: " << negXselfTestDataset.initCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y temperature: " + sif::info << "IMTQ self test (INIT) coil Y temperature: " << negXselfTestDataset.initCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z temperature: " + sif::info << "IMTQ self test (INIT) coil Z temperature: " << negXselfTestDataset.initCoilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-X) err: " + sif::info << "IMTQ self test (-X) err: " << static_cast(negXselfTestDataset.err.value) << std::endl; - sif::info << "IMTQ self test (-X) raw magnetic field X: " << negXselfTestDataset.rawMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (-X) raw magnetic field Y: " << negXselfTestDataset.rawMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (-X) raw magnetic field Z: " << negXselfTestDataset.rawMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (-X) calibrated magnetic field X: " << negXselfTestDataset.calMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (-X) calibrated magnetic field Y: " << negXselfTestDataset.calMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (-X) calibrated magnetic field Z: " << negXselfTestDataset.calMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (-X) coil X current: " << negXselfTestDataset.coilXCurrent << " mA" + sif::info << "IMTQ self test (-X) raw magnetic field X: " << negXselfTestDataset.rawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (-X) coil Y current: " << negXselfTestDataset.coilYCurrent << " mA" + sif::info << "IMTQ self test (-X) raw magnetic field Y: " << negXselfTestDataset.rawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (-X) coil Z current: " << negXselfTestDataset.coilZCurrent << " mA" + sif::info << "IMTQ self test (-X) raw magnetic field Z: " << negXselfTestDataset.rawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (-X) coil X temperature: " << negXselfTestDataset.coilXTemperature + sif::info << "IMTQ self test (-X) calibrated magnetic field X: " << negXselfTestDataset.calMagX + << " nT" << std::endl; + sif::info << "IMTQ self test (-X) calibrated magnetic field Y: " << negXselfTestDataset.calMagY + << " nT" << std::endl; + sif::info << "IMTQ self test (-X) calibrated magnetic field Z: " << negXselfTestDataset.calMagZ + << " nT" << std::endl; + sif::info << "IMTQ self test (-X) coil X current: " << negXselfTestDataset.coilXCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-X) coil Y current: " << negXselfTestDataset.coilYCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-X) coil Z current: " << negXselfTestDataset.coilZCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-X) coil X temperature: " << negXselfTestDataset.coilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-X) coil Y temperature: " << negXselfTestDataset.coilYTemperature + sif::info << "IMTQ self test (-X) coil Y temperature: " << negXselfTestDataset.coilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-X) coil Z temperature: " << negXselfTestDataset.coilZTemperature + sif::info << "IMTQ self test (-X) coil Z temperature: " << negXselfTestDataset.coilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) err: " + sif::info << "IMTQ self test (FINA) err: " << static_cast(negXselfTestDataset.finaErr.value) << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field X: " << negXselfTestDataset.finaRawMagX + sif::info << "IMTQ self test (FINA) raw magnetic field X: " << negXselfTestDataset.finaRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << negXselfTestDataset.finaRawMagY + sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << negXselfTestDataset.finaRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << negXselfTestDataset.finaRawMagZ + sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << negXselfTestDataset.finaRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " << negXselfTestDataset.finaCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " << negXselfTestDataset.finaCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " << negXselfTestDataset.finaCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) coil X current: " << negXselfTestDataset.finaCoilXCurrent + sif::info << "IMTQ self test (FINA) coil X current: " << negXselfTestDataset.finaCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y current: " << negXselfTestDataset.finaCoilYCurrent + sif::info << "IMTQ self test (FINA) coil Y current: " << negXselfTestDataset.finaCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z current: " << negXselfTestDataset.finaCoilZCurrent + sif::info << "IMTQ self test (FINA) coil Z current: " << negXselfTestDataset.finaCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil X temperature: " + sif::info << "IMTQ self test (FINA) coil X temperature: " << negXselfTestDataset.finaCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y temperature: " + sif::info << "IMTQ self test (FINA) coil Y temperature: " << negXselfTestDataset.finaCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z temperature: " + sif::info << "IMTQ self test (FINA) coil Z temperature: " << negXselfTestDataset.finaCoilZTemperature << " °C" << std::endl; #endif } void IMTQHandler::handlePositiveYSelfTestReply(const uint8_t* packet) { - PoolReadGuard rg(&posXselfTestDataset); + PoolReadGuard rg(&posXselfTestDataset); - uint16_t offset = 2; - /** Init measurements */ - posYselfTestDataset.initErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - posYselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.initCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.initCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.initCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posYselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posYselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + uint16_t offset = 2; + /** Init measurements */ + posYselfTestDataset.initErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + posYselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.initCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.initCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.initCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posYselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posYselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** +X measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - posYselfTestDataset.err = *(packet + offset); - offset += 2; // STEP byte will not be stored - posYselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.coilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.coilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.coilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posYselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posYselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** +X measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + posYselfTestDataset.err = *(packet + offset); + offset += 2; // STEP byte will not be stored + posYselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.coilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.coilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.coilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posYselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posYselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** FINA measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - posYselfTestDataset.finaErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - posYselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.finaCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.finaCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.finaCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posYselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posYselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** FINA measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + posYselfTestDataset.finaErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + posYselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.finaCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.finaCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.finaCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posYselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posYselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ self test (INIT) err: " +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ self test (INIT) err: " << static_cast(posYselfTestDataset.initErr.value) << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field X: " << posYselfTestDataset.initRawMagX + sif::info << "IMTQ self test (INIT) raw magnetic field X: " << posYselfTestDataset.initRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << posYselfTestDataset.initRawMagY + sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << posYselfTestDataset.initRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << posYselfTestDataset.initRawMagZ + sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << posYselfTestDataset.initRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " << posYselfTestDataset.initCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " << posYselfTestDataset.initCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " << posYselfTestDataset.initCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) coil X current: " << posYselfTestDataset.initCoilXCurrent + sif::info << "IMTQ self test (INIT) coil X current: " << posYselfTestDataset.initCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y current: " << posYselfTestDataset.initCoilYCurrent + sif::info << "IMTQ self test (INIT) coil Y current: " << posYselfTestDataset.initCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z current: " << posYselfTestDataset.initCoilZCurrent + sif::info << "IMTQ self test (INIT) coil Z current: " << posYselfTestDataset.initCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil X temperature: " + sif::info << "IMTQ self test (INIT) coil X temperature: " << posYselfTestDataset.initCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y temperature: " + sif::info << "IMTQ self test (INIT) coil Y temperature: " << posYselfTestDataset.initCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z temperature: " + sif::info << "IMTQ self test (INIT) coil Z temperature: " << posYselfTestDataset.initCoilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+Y) err: " + sif::info << "IMTQ self test (+Y) err: " << static_cast(posYselfTestDataset.err.value) << std::endl; - sif::info << "IMTQ self test (+Y) raw magnetic field X: " << posYselfTestDataset.rawMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) raw magnetic field Y: " << posYselfTestDataset.rawMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) raw magnetic field Z: " << posYselfTestDataset.rawMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) calibrated magnetic field X: " << posYselfTestDataset.calMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) calibrated magnetic field Y: " << posYselfTestDataset.calMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) calibrated magnetic field Z: " << posYselfTestDataset.calMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) coil X current: " << posYselfTestDataset.coilXCurrent << " mA" + sif::info << "IMTQ self test (+Y) raw magnetic field X: " << posYselfTestDataset.rawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) coil Y current: " << posYselfTestDataset.coilYCurrent << " mA" + sif::info << "IMTQ self test (+Y) raw magnetic field Y: " << posYselfTestDataset.rawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) coil Z current: " << posYselfTestDataset.coilZCurrent << " mA" + sif::info << "IMTQ self test (+Y) raw magnetic field Z: " << posYselfTestDataset.rawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) coil X temperature: " << posYselfTestDataset.coilXTemperature + sif::info << "IMTQ self test (+Y) calibrated magnetic field X: " << posYselfTestDataset.calMagX + << " nT" << std::endl; + sif::info << "IMTQ self test (+Y) calibrated magnetic field Y: " << posYselfTestDataset.calMagY + << " nT" << std::endl; + sif::info << "IMTQ self test (+Y) calibrated magnetic field Z: " << posYselfTestDataset.calMagZ + << " nT" << std::endl; + sif::info << "IMTQ self test (+Y) coil X current: " << posYselfTestDataset.coilXCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+Y) coil Y current: " << posYselfTestDataset.coilYCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+Y) coil Z current: " << posYselfTestDataset.coilZCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+Y) coil X temperature: " << posYselfTestDataset.coilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+Y) coil Y temperature: " << posYselfTestDataset.coilYTemperature + sif::info << "IMTQ self test (+Y) coil Y temperature: " << posYselfTestDataset.coilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+Y) coil Z temperature: " << posYselfTestDataset.coilZTemperature + sif::info << "IMTQ self test (+Y) coil Z temperature: " << posYselfTestDataset.coilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) err: " + sif::info << "IMTQ self test (FINA) err: " << static_cast(posYselfTestDataset.finaErr.value) << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field X: " << posYselfTestDataset.finaRawMagX + sif::info << "IMTQ self test (FINA) raw magnetic field X: " << posYselfTestDataset.finaRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << posYselfTestDataset.finaRawMagY + sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << posYselfTestDataset.finaRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << posYselfTestDataset.finaRawMagZ + sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << posYselfTestDataset.finaRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " << posYselfTestDataset.finaCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " << posYselfTestDataset.finaCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " << posYselfTestDataset.finaCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) coil X current: " << posYselfTestDataset.finaCoilXCurrent + sif::info << "IMTQ self test (FINA) coil X current: " << posYselfTestDataset.finaCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y current: " << posYselfTestDataset.finaCoilYCurrent + sif::info << "IMTQ self test (FINA) coil Y current: " << posYselfTestDataset.finaCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z current: " << posYselfTestDataset.finaCoilZCurrent + sif::info << "IMTQ self test (FINA) coil Z current: " << posYselfTestDataset.finaCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil X temperature: " + sif::info << "IMTQ self test (FINA) coil X temperature: " << posYselfTestDataset.finaCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y temperature: " + sif::info << "IMTQ self test (FINA) coil Y temperature: " << posYselfTestDataset.finaCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z temperature: " + sif::info << "IMTQ self test (FINA) coil Z temperature: " << posYselfTestDataset.finaCoilZTemperature << " °C" << std::endl; #endif } void IMTQHandler::handleNegativeYSelfTestReply(const uint8_t* packet) { - PoolReadGuard rg(&posXselfTestDataset); + PoolReadGuard rg(&posXselfTestDataset); - uint16_t offset = 2; - /** Init measurements */ - posZselfTestDataset.initErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - negYselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.initCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.initCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.initCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negYselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negYselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + uint16_t offset = 2; + /** Init measurements */ + posZselfTestDataset.initErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + negYselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.initCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.initCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.initCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negYselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negYselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** +X measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - negYselfTestDataset.err = *(packet + offset); - offset += 2; // STEP byte will not be stored - negYselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.coilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.coilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.coilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negYselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negYselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** +X measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + negYselfTestDataset.err = *(packet + offset); + offset += 2; // STEP byte will not be stored + negYselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.coilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.coilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.coilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negYselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negYselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** FINA measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - negYselfTestDataset.finaErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - negYselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.finaCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.finaCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.finaCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negYselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negYselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** FINA measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + negYselfTestDataset.finaErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + negYselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.finaCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.finaCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.finaCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negYselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negYselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ self test (INIT) err: " +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ self test (INIT) err: " << static_cast(negYselfTestDataset.initErr.value) << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field X: " << negYselfTestDataset.initRawMagX + sif::info << "IMTQ self test (INIT) raw magnetic field X: " << negYselfTestDataset.initRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << negYselfTestDataset.initRawMagY + sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << negYselfTestDataset.initRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << negYselfTestDataset.initRawMagZ + sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << negYselfTestDataset.initRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " << negYselfTestDataset.initCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " << negYselfTestDataset.initCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " << negYselfTestDataset.initCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) coil X current: " << negYselfTestDataset.initCoilXCurrent + sif::info << "IMTQ self test (INIT) coil X current: " << negYselfTestDataset.initCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y current: " << negYselfTestDataset.initCoilYCurrent + sif::info << "IMTQ self test (INIT) coil Y current: " << negYselfTestDataset.initCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z current: " << negYselfTestDataset.initCoilZCurrent + sif::info << "IMTQ self test (INIT) coil Z current: " << negYselfTestDataset.initCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil X temperature: " + sif::info << "IMTQ self test (INIT) coil X temperature: " << negYselfTestDataset.initCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y temperature: " + sif::info << "IMTQ self test (INIT) coil Y temperature: " << negYselfTestDataset.initCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z temperature: " + sif::info << "IMTQ self test (INIT) coil Z temperature: " << negYselfTestDataset.initCoilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-Y) err: " + sif::info << "IMTQ self test (-Y) err: " << static_cast(negYselfTestDataset.err.value) << std::endl; - sif::info << "IMTQ self test (-Y) raw magnetic field X: " << negYselfTestDataset.rawMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) raw magnetic field Y: " << negYselfTestDataset.rawMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) raw magnetic field Z: " << negYselfTestDataset.rawMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) calibrated magnetic field X: " << negYselfTestDataset.calMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) calibrated magnetic field Y: " << negYselfTestDataset.calMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) calibrated magnetic field Z: " << negYselfTestDataset.calMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) coil X current: " << negYselfTestDataset.coilXCurrent << " mA" + sif::info << "IMTQ self test (-Y) raw magnetic field X: " << negYselfTestDataset.rawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) coil Y current: " << negYselfTestDataset.coilYCurrent << " mA" + sif::info << "IMTQ self test (-Y) raw magnetic field Y: " << negYselfTestDataset.rawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) coil Z current: " << negYselfTestDataset.coilZCurrent << " mA" + sif::info << "IMTQ self test (-Y) raw magnetic field Z: " << negYselfTestDataset.rawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) coil X temperature: " << negYselfTestDataset.coilXTemperature + sif::info << "IMTQ self test (-Y) calibrated magnetic field X: " << negYselfTestDataset.calMagX + << " nT" << std::endl; + sif::info << "IMTQ self test (-Y) calibrated magnetic field Y: " << negYselfTestDataset.calMagY + << " nT" << std::endl; + sif::info << "IMTQ self test (-Y) calibrated magnetic field Z: " << negYselfTestDataset.calMagZ + << " nT" << std::endl; + sif::info << "IMTQ self test (-Y) coil X current: " << negYselfTestDataset.coilXCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-Y) coil Y current: " << negYselfTestDataset.coilYCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-Y) coil Z current: " << negYselfTestDataset.coilZCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-Y) coil X temperature: " << negYselfTestDataset.coilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-Y) coil Y temperature: " << negYselfTestDataset.coilYTemperature + sif::info << "IMTQ self test (-Y) coil Y temperature: " << negYselfTestDataset.coilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-Y) coil Z temperature: " << negYselfTestDataset.coilZTemperature + sif::info << "IMTQ self test (-Y) coil Z temperature: " << negYselfTestDataset.coilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) err: " + sif::info << "IMTQ self test (FINA) err: " << static_cast(negYselfTestDataset.finaErr.value) << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field X: " << negYselfTestDataset.finaRawMagX + sif::info << "IMTQ self test (FINA) raw magnetic field X: " << negYselfTestDataset.finaRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << negYselfTestDataset.finaRawMagY + sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << negYselfTestDataset.finaRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << negYselfTestDataset.finaRawMagZ + sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << negYselfTestDataset.finaRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " << negYselfTestDataset.finaCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " << negYselfTestDataset.finaCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " << negYselfTestDataset.finaCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) coil X current: " << negYselfTestDataset.finaCoilXCurrent + sif::info << "IMTQ self test (FINA) coil X current: " << negYselfTestDataset.finaCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y current: " << negYselfTestDataset.finaCoilYCurrent + sif::info << "IMTQ self test (FINA) coil Y current: " << negYselfTestDataset.finaCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z current: " << negYselfTestDataset.finaCoilZCurrent + sif::info << "IMTQ self test (FINA) coil Z current: " << negYselfTestDataset.finaCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil X temperature: " + sif::info << "IMTQ self test (FINA) coil X temperature: " << negYselfTestDataset.finaCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y temperature: " + sif::info << "IMTQ self test (FINA) coil Y temperature: " << negYselfTestDataset.finaCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z temperature: " + sif::info << "IMTQ self test (FINA) coil Z temperature: " << negYselfTestDataset.finaCoilZTemperature << " °C" << std::endl; #endif } void IMTQHandler::handlePositiveZSelfTestReply(const uint8_t* packet) { - PoolReadGuard rg(&posXselfTestDataset); + PoolReadGuard rg(&posXselfTestDataset); - uint16_t offset = 2; - /** Init measurements */ - posZselfTestDataset.initErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - posZselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.initCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.initCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.initCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posZselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posZselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + uint16_t offset = 2; + /** Init measurements */ + posZselfTestDataset.initErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + posZselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.initCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.initCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.initCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posZselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posZselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** +X measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - posZselfTestDataset.err = *(packet + offset); - offset += 2; // STEP byte will not be stored - posZselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.coilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.coilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.coilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posZselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posZselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** +X measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + posZselfTestDataset.err = *(packet + offset); + offset += 2; // STEP byte will not be stored + posZselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.coilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.coilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.coilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posZselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posZselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** FINA measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - posZselfTestDataset.finaErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - posZselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.finaCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.finaCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.finaCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posZselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posZselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** FINA measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + posZselfTestDataset.finaErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + posZselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.finaCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.finaCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.finaCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posZselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posZselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ self test (INIT) err: " +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ self test (INIT) err: " << static_cast(posZselfTestDataset.initErr.value) << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field X: " << posZselfTestDataset.initRawMagX + sif::info << "IMTQ self test (INIT) raw magnetic field X: " << posZselfTestDataset.initRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << posZselfTestDataset.initRawMagY + sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << posZselfTestDataset.initRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << posZselfTestDataset.initRawMagZ + sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << posZselfTestDataset.initRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " << posZselfTestDataset.initCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " << posZselfTestDataset.initCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " << posZselfTestDataset.initCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) coil X current: " << posZselfTestDataset.initCoilXCurrent + sif::info << "IMTQ self test (INIT) coil X current: " << posZselfTestDataset.initCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y current: " << posZselfTestDataset.initCoilYCurrent + sif::info << "IMTQ self test (INIT) coil Y current: " << posZselfTestDataset.initCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z current: " << posZselfTestDataset.initCoilZCurrent + sif::info << "IMTQ self test (INIT) coil Z current: " << posZselfTestDataset.initCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil X temperature: " + sif::info << "IMTQ self test (INIT) coil X temperature: " << posZselfTestDataset.initCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y temperature: " + sif::info << "IMTQ self test (INIT) coil Y temperature: " << posZselfTestDataset.initCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z temperature: " + sif::info << "IMTQ self test (INIT) coil Z temperature: " << posZselfTestDataset.initCoilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+Z) err: " + sif::info << "IMTQ self test (+Z) err: " << static_cast(posZselfTestDataset.err.value) << std::endl; - sif::info << "IMTQ self test (+Z) raw magnetic field X: " << posZselfTestDataset.rawMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) raw magnetic field Y: " << posZselfTestDataset.rawMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) raw magnetic field Z: " << posZselfTestDataset.rawMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) calibrated magnetic field X: " << posZselfTestDataset.calMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) calibrated magnetic field Y: " << posZselfTestDataset.calMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) calibrated magnetic field Z: " << posZselfTestDataset.calMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) coil X current: " << posZselfTestDataset.coilXCurrent << " mA" + sif::info << "IMTQ self test (+Z) raw magnetic field X: " << posZselfTestDataset.rawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) coil Y current: " << posZselfTestDataset.coilYCurrent << " mA" + sif::info << "IMTQ self test (+Z) raw magnetic field Y: " << posZselfTestDataset.rawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) coil Z current: " << posZselfTestDataset.coilZCurrent << " mA" + sif::info << "IMTQ self test (+Z) raw magnetic field Z: " << posZselfTestDataset.rawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) coil X temperature: " << posZselfTestDataset.coilXTemperature + sif::info << "IMTQ self test (+Z) calibrated magnetic field X: " << posZselfTestDataset.calMagX + << " nT" << std::endl; + sif::info << "IMTQ self test (+Z) calibrated magnetic field Y: " << posZselfTestDataset.calMagY + << " nT" << std::endl; + sif::info << "IMTQ self test (+Z) calibrated magnetic field Z: " << posZselfTestDataset.calMagZ + << " nT" << std::endl; + sif::info << "IMTQ self test (+Z) coil X current: " << posZselfTestDataset.coilXCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+Z) coil Y current: " << posZselfTestDataset.coilYCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+Z) coil Z current: " << posZselfTestDataset.coilZCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+Z) coil X temperature: " << posZselfTestDataset.coilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+Z) coil Y temperature: " << posZselfTestDataset.coilYTemperature + sif::info << "IMTQ self test (+Z) coil Y temperature: " << posZselfTestDataset.coilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+Z) coil Z temperature: " << negYselfTestDataset.coilZTemperature + sif::info << "IMTQ self test (+Z) coil Z temperature: " << negYselfTestDataset.coilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) err: " + sif::info << "IMTQ self test (FINA) err: " << static_cast(posZselfTestDataset.finaErr.value) << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field X: " << posZselfTestDataset.finaRawMagX + sif::info << "IMTQ self test (FINA) raw magnetic field X: " << posZselfTestDataset.finaRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << posZselfTestDataset.finaRawMagY + sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << posZselfTestDataset.finaRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << posZselfTestDataset.finaRawMagZ + sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << posZselfTestDataset.finaRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " << posZselfTestDataset.finaCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " << posZselfTestDataset.finaCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " << posZselfTestDataset.finaCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) coil X current: " << posZselfTestDataset.finaCoilXCurrent + sif::info << "IMTQ self test (FINA) coil X current: " << posZselfTestDataset.finaCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y current: " << posZselfTestDataset.finaCoilYCurrent + sif::info << "IMTQ self test (FINA) coil Y current: " << posZselfTestDataset.finaCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z current: " << posZselfTestDataset.finaCoilZCurrent + sif::info << "IMTQ self test (FINA) coil Z current: " << posZselfTestDataset.finaCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil X temperature: " + sif::info << "IMTQ self test (FINA) coil X temperature: " << posZselfTestDataset.finaCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y temperature: " + sif::info << "IMTQ self test (FINA) coil Y temperature: " << posZselfTestDataset.finaCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z temperature: " + sif::info << "IMTQ self test (FINA) coil Z temperature: " << posZselfTestDataset.finaCoilZTemperature << " °C" << std::endl; #endif } void IMTQHandler::handleNegativeZSelfTestReply(const uint8_t* packet) { - PoolReadGuard rg(&posXselfTestDataset); + PoolReadGuard rg(&posXselfTestDataset); - uint16_t offset = 2; - /** Init measurements */ - negZselfTestDataset.initErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - negZselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.initCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.initCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.initCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negZselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negZselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + uint16_t offset = 2; + /** Init measurements */ + negZselfTestDataset.initErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + negZselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.initCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.initCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.initCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negZselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negZselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** +X measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - negZselfTestDataset.err = *(packet + offset); - offset += 2; // STEP byte will not be stored - negZselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.coilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.coilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.coilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negZselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negZselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** +X measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + negZselfTestDataset.err = *(packet + offset); + offset += 2; // STEP byte will not be stored + negZselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.coilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.coilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.coilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negZselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negZselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** FINA measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - negZselfTestDataset.finaErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - negZselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.finaCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.finaCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.finaCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negZselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negZselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** FINA measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + negZselfTestDataset.finaErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + negZselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.finaCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.finaCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.finaCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negZselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negZselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ self test (INIT) err: " +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ self test (INIT) err: " << static_cast(negZselfTestDataset.initErr.value) << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field X: " << negZselfTestDataset.initRawMagX + sif::info << "IMTQ self test (INIT) raw magnetic field X: " << negZselfTestDataset.initRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << negZselfTestDataset.initRawMagY + sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << negZselfTestDataset.initRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << negZselfTestDataset.initRawMagZ + sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << negZselfTestDataset.initRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " << negZselfTestDataset.initCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " << negZselfTestDataset.initCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " << negZselfTestDataset.initCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) coil X current: " << negZselfTestDataset.initCoilXCurrent + sif::info << "IMTQ self test (INIT) coil X current: " << negZselfTestDataset.initCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y current: " << negZselfTestDataset.initCoilYCurrent + sif::info << "IMTQ self test (INIT) coil Y current: " << negZselfTestDataset.initCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z current: " << negZselfTestDataset.initCoilZCurrent + sif::info << "IMTQ self test (INIT) coil Z current: " << negZselfTestDataset.initCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil X temperature: " + sif::info << "IMTQ self test (INIT) coil X temperature: " << negZselfTestDataset.initCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y temperature: " + sif::info << "IMTQ self test (INIT) coil Y temperature: " << negZselfTestDataset.initCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z temperature: " + sif::info << "IMTQ self test (INIT) coil Z temperature: " << negZselfTestDataset.initCoilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-Z) err: " + sif::info << "IMTQ self test (-Z) err: " << static_cast(negZselfTestDataset.err.value) << std::endl; - sif::info << "IMTQ self test (-Z) raw magnetic field X: " << negZselfTestDataset.rawMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) raw magnetic field Y: " << negZselfTestDataset.rawMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) raw magnetic field Z: " << negZselfTestDataset.rawMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) calibrated magnetic field X: " << negZselfTestDataset.calMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) calibrated magnetic field Y: " << negZselfTestDataset.calMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) calibrated magnetic field Z: " << negZselfTestDataset.calMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) coil X current: " << negZselfTestDataset.coilXCurrent << " mA" + sif::info << "IMTQ self test (-Z) raw magnetic field X: " << negZselfTestDataset.rawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) coil Y current: " << negZselfTestDataset.coilYCurrent << " mA" + sif::info << "IMTQ self test (-Z) raw magnetic field Y: " << negZselfTestDataset.rawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) coil Z current: " << negZselfTestDataset.coilZCurrent << " mA" + sif::info << "IMTQ self test (-Z) raw magnetic field Z: " << negZselfTestDataset.rawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) coil X temperature: " << negZselfTestDataset.coilXTemperature + sif::info << "IMTQ self test (-Z) calibrated magnetic field X: " << negZselfTestDataset.calMagX + << " nT" << std::endl; + sif::info << "IMTQ self test (-Z) calibrated magnetic field Y: " << negZselfTestDataset.calMagY + << " nT" << std::endl; + sif::info << "IMTQ self test (-Z) calibrated magnetic field Z: " << negZselfTestDataset.calMagZ + << " nT" << std::endl; + sif::info << "IMTQ self test (-Z) coil X current: " << negZselfTestDataset.coilXCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-Z) coil Y current: " << negZselfTestDataset.coilYCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-Z) coil Z current: " << negZselfTestDataset.coilZCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-Z) coil X temperature: " << negZselfTestDataset.coilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-Z) coil Y temperature: " << negZselfTestDataset.coilYTemperature + sif::info << "IMTQ self test (-Z) coil Y temperature: " << negZselfTestDataset.coilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-Z) coil Z temperature: " << negYselfTestDataset.coilZTemperature + sif::info << "IMTQ self test (-Z) coil Z temperature: " << negYselfTestDataset.coilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) err: " + sif::info << "IMTQ self test (FINA) err: " << static_cast(negZselfTestDataset.finaErr.value) << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field X: " << negZselfTestDataset.finaRawMagX + sif::info << "IMTQ self test (FINA) raw magnetic field X: " << negZselfTestDataset.finaRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << negZselfTestDataset.finaRawMagY + sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << negZselfTestDataset.finaRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << negZselfTestDataset.finaRawMagZ + sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << negZselfTestDataset.finaRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " << negZselfTestDataset.finaCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " << negZselfTestDataset.finaCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " << negZselfTestDataset.finaCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) coil X current: " << negZselfTestDataset.finaCoilXCurrent + sif::info << "IMTQ self test (FINA) coil X current: " << negZselfTestDataset.finaCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y current: " << negZselfTestDataset.finaCoilYCurrent + sif::info << "IMTQ self test (FINA) coil Y current: " << negZselfTestDataset.finaCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z current: " << negZselfTestDataset.finaCoilZCurrent + sif::info << "IMTQ self test (FINA) coil Z current: " << negZselfTestDataset.finaCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil X temperature: " + sif::info << "IMTQ self test (FINA) coil X temperature: " << negZselfTestDataset.finaCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y temperature: " + sif::info << "IMTQ self test (FINA) coil Y temperature: " << negZselfTestDataset.finaCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z temperature: " + sif::info << "IMTQ self test (FINA) coil Z temperature: " << negZselfTestDataset.finaCoilZTemperature << " °C" << std::endl; #endif } void IMTQHandler::checkErrorByte(const uint8_t errorByte, const uint8_t step) { - std::string stepString(""); - if (step < 8) { - stepString = makeStepString(step); - } else { - /** This should normally never happen */ - sif::debug << "IMTQHandler::checkErrorByte: Invalid step" << std::endl; - return; - } + std::string stepString(""); + if (step < 8) { + stepString = makeStepString(step); + } else { + /** This should normally never happen */ + sif::debug << "IMTQHandler::checkErrorByte: Invalid step" << std::endl; + return; + } - if (errorByte == 0) { - return; - } + if (errorByte == 0) { + return; + } - if (errorByte & IMTQ::I2C_FAILURE_MASK) { - triggerEvent(SELF_TEST_I2C_FAILURE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test I2C failure for step " << stepString - << std::endl; - } - if (errorByte & IMTQ::SPI_FAILURE_MASK) { - triggerEvent(SELF_TEST_SPI_FAILURE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test SPI failure for step " << stepString - << std::endl; - } - if (errorByte & IMTQ::ADC_FAILURE_MASK) { - triggerEvent(SELF_TEST_ADC_FAILURE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test ADC failure for step " << stepString - << std::endl; - } - if (errorByte & IMTQ::PWM_FAILURE_MASK) { - triggerEvent(SELF_TEST_PWM_FAILURE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test PWM failure for step " << stepString - << std::endl; - } - if (errorByte & IMTQ::TC_FAILURE_MASK) { - triggerEvent(SELF_TEST_TC_FAILURE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test TC failure (system failure) for step " - << stepString << std::endl; - } - if (errorByte & IMTQ::MTM_RANGE_FAILURE_MASK) { - triggerEvent(SELF_TEST_TC_FAILURE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test MTM range failure for step " - << stepString << std::endl; - } - if (errorByte & IMTQ::COIL_CURRENT_FAILURE_MASK) { - triggerEvent(SELF_TEST_COIL_CURRENT_FAILURE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test coil current outside of expected " - "range for step " << stepString << std::endl; - } + if (errorByte & IMTQ::I2C_FAILURE_MASK) { + triggerEvent(SELF_TEST_I2C_FAILURE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test I2C failure for step " << stepString + << std::endl; + } + if (errorByte & IMTQ::SPI_FAILURE_MASK) { + triggerEvent(SELF_TEST_SPI_FAILURE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test SPI failure for step " << stepString + << std::endl; + } + if (errorByte & IMTQ::ADC_FAILURE_MASK) { + triggerEvent(SELF_TEST_ADC_FAILURE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test ADC failure for step " << stepString + << std::endl; + } + if (errorByte & IMTQ::PWM_FAILURE_MASK) { + triggerEvent(SELF_TEST_PWM_FAILURE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test PWM failure for step " << stepString + << std::endl; + } + if (errorByte & IMTQ::TC_FAILURE_MASK) { + triggerEvent(SELF_TEST_TC_FAILURE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test TC failure (system failure) for step " + << stepString << std::endl; + } + if (errorByte & IMTQ::MTM_RANGE_FAILURE_MASK) { + triggerEvent(SELF_TEST_TC_FAILURE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test MTM range failure for step " << stepString + << std::endl; + } + if (errorByte & IMTQ::COIL_CURRENT_FAILURE_MASK) { + triggerEvent(SELF_TEST_COIL_CURRENT_FAILURE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test coil current outside of expected " + "range for step " + << stepString << std::endl; + } - if (errorByte & IMTQ::INVALID_ERROR_BYTE) { - triggerEvent(INVALID_ERROR_BYTE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test result of step " << stepString - << " has invalid error byte" << std::endl; - } + if (errorByte & IMTQ::INVALID_ERROR_BYTE) { + triggerEvent(INVALID_ERROR_BYTE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test result of step " << stepString + << " has invalid error byte" << std::endl; + } } std::string IMTQHandler::makeStepString(const uint8_t step) { - std::string stepString(""); - switch (step) { + std::string stepString(""); + switch (step) { case IMTQ::SELF_TEST_STEPS::INIT: - stepString = std::string("INIT"); - break; + stepString = std::string("INIT"); + break; case IMTQ::SELF_TEST_STEPS::X_POSITIVE: - stepString = std::string("+X"); - break; + stepString = std::string("+X"); + break; case IMTQ::SELF_TEST_STEPS::X_NEGATIVE: - stepString = std::string("-X"); - break; + stepString = std::string("-X"); + break; case IMTQ::SELF_TEST_STEPS::Y_POSITIVE: - stepString = std::string("+Y"); - break; + stepString = std::string("+Y"); + break; case IMTQ::SELF_TEST_STEPS::Y_NEGATIVE: - stepString = std::string("-Y"); - break; + stepString = std::string("-Y"); + break; case IMTQ::SELF_TEST_STEPS::Z_POSITIVE: - stepString = std::string("+Z"); - break; + stepString = std::string("+Z"); + break; case IMTQ::SELF_TEST_STEPS::Z_NEGATIVE: - stepString = std::string("-Z"); - break; + stepString = std::string("-Z"); + break; case IMTQ::SELF_TEST_STEPS::FINA: - stepString = std::string("FINA"); - break; + stepString = std::string("FINA"); + break; default: - sif::error << "IMTQHandler::checkErrorByte: Received packet with invalid step information" - << std::endl; - break; - } - return stepString; + sif::error << "IMTQHandler::checkErrorByte: Received packet with invalid step information" + << std::endl; + break; + } + return stepString; } - diff --git a/mission/devices/IMTQHandler.h b/mission/devices/IMTQHandler.h index ce9e45e0..b12cdf97 100644 --- a/mission/devices/IMTQHandler.h +++ b/mission/devices/IMTQHandler.h @@ -10,186 +10,188 @@ * * @author J. Meier */ -class IMTQHandler: public DeviceHandlerBase { -public: +class IMTQHandler : public DeviceHandlerBase { + public: + IMTQHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + virtual ~IMTQHandler(); - IMTQHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); - virtual ~IMTQHandler(); + /** + * @brief Sets mode to MODE_NORMAL. Can be used for debugging. + */ + void setModeNormal(); - /** - * @brief Sets mode to MODE_NORMAL. Can be used for debugging. - */ - void setModeNormal(); + 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; + virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) 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; - virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::IMTQ_HANDLER; -private: + static const ReturnValue_t INVALID_COMMAND_CODE = MAKE_RETURN_CODE(0xA0); + static const ReturnValue_t PARAMETER_MISSING = MAKE_RETURN_CODE(0xA1); + static const ReturnValue_t PARAMETER_INVALID = MAKE_RETURN_CODE(0xA2); + static const ReturnValue_t CC_UNAVAILABLE = MAKE_RETURN_CODE(0xA3); + static const ReturnValue_t INTERNAL_PROCESSING_ERROR = MAKE_RETURN_CODE(0xA4); + static const ReturnValue_t REJECTED_WITHOUT_REASON = MAKE_RETURN_CODE(0xA5); + static const ReturnValue_t CMD_ERR_UNKNOWN = MAKE_RETURN_CODE(0xA6); + //! [EXPORT] : [COMMENT] The status reply to a self test command was received but no self test + //! command has been sent. This should normally never happen. + static const ReturnValue_t UNEXPECTED_SELF_TEST_REPLY = MAKE_RETURN_CODE(0xA7); - static const uint8_t INTERFACE_ID = CLASS_ID::IMTQ_HANDLER; + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::IMTQ_HANDLER; - static const ReturnValue_t INVALID_COMMAND_CODE = MAKE_RETURN_CODE(0xA0); - static const ReturnValue_t PARAMETER_MISSING = MAKE_RETURN_CODE(0xA1); - static const ReturnValue_t PARAMETER_INVALID = MAKE_RETURN_CODE(0xA2); - static const ReturnValue_t CC_UNAVAILABLE = MAKE_RETURN_CODE(0xA3); - static const ReturnValue_t INTERNAL_PROCESSING_ERROR = MAKE_RETURN_CODE(0xA4); - static const ReturnValue_t REJECTED_WITHOUT_REASON = MAKE_RETURN_CODE(0xA5); - static const ReturnValue_t CMD_ERR_UNKNOWN = MAKE_RETURN_CODE(0xA6); - //! [EXPORT] : [COMMENT] The status reply to a self test command was received but no self test command has been sent. This should normally never happen. - static const ReturnValue_t UNEXPECTED_SELF_TEST_REPLY = MAKE_RETURN_CODE(0xA7); + //! [EXPORT] : [COMMENT] Get self test result returns I2C failure + //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> + //! -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA + static const Event SELF_TEST_I2C_FAILURE = MAKE_EVENT(1, severity::LOW); + //! [EXPORT] : [COMMENT] Get self test result returns SPI failure. This concerns the MTM + //! connectivity. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 + //! -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA + static const Event SELF_TEST_SPI_FAILURE = MAKE_EVENT(2, severity::LOW); + //! [EXPORT] : [COMMENT] Get self test result returns failure in measurement of current and + //! temperature. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 + //! -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA + static const Event SELF_TEST_ADC_FAILURE = MAKE_EVENT(3, severity::LOW); + //! [EXPORT] : [COMMENT] Get self test result returns PWM failure which concerns the coil + //! actuation. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> + //! +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA + static const Event SELF_TEST_PWM_FAILURE = MAKE_EVENT(4, severity::LOW); + //! [EXPORT] : [COMMENT] Get self test result returns TC failure (system failure) + //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> + //! -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA + static const Event SELF_TEST_TC_FAILURE = MAKE_EVENT(5, severity::LOW); + //! [EXPORT] : [COMMENT] Get self test result returns failure that MTM values were outside of the + //! expected range. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, + //! 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA + static const Event SELF_TEST_MTM_RANGE_FAILURE = MAKE_EVENT(6, severity::LOW); + //! [EXPORT] : [COMMENT] Get self test result returns failure indicating that the coil current was + //! outside of the expected range P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 + //! -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA + static const Event SELF_TEST_COIL_CURRENT_FAILURE = MAKE_EVENT(7, severity::LOW); + //! [EXPORT] : [COMMENT] Received invalid error byte. This indicates an error of the communication + //! link between IMTQ and OBC. + static const Event INVALID_ERROR_BYTE = MAKE_EVENT(8, severity::LOW); - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::IMTQ_HANDLER; + IMTQ::EngHkDataset engHkDataset; + IMTQ::CalibratedMtmMeasurementSet calMtmMeasurementSet; + IMTQ::RawMtmMeasurementSet rawMtmMeasurementSet; + IMTQ::PosXSelfTestSet posXselfTestDataset; + IMTQ::NegXSelfTestSet negXselfTestDataset; + IMTQ::PosYSelfTestSet posYselfTestDataset; + IMTQ::NegYSelfTestSet negYselfTestDataset; + IMTQ::PosZSelfTestSet posZselfTestDataset; + IMTQ::NegZSelfTestSet negZselfTestDataset; - //! [EXPORT] : [COMMENT] Get self test result returns I2C failure - //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA - static const Event SELF_TEST_I2C_FAILURE = MAKE_EVENT(1, severity::LOW); - //! [EXPORT] : [COMMENT] Get self test result returns SPI failure. This concerns the MTM connectivity. - //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA - static const Event SELF_TEST_SPI_FAILURE = MAKE_EVENT(2, severity::LOW); - //! [EXPORT] : [COMMENT] Get self test result returns failure in measurement of current and temperature. - //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA - static const Event SELF_TEST_ADC_FAILURE = MAKE_EVENT(3, severity::LOW); - //! [EXPORT] : [COMMENT] Get self test result returns PWM failure which concerns the coil actuation. - //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA - static const Event SELF_TEST_PWM_FAILURE = MAKE_EVENT(4, severity::LOW); - //! [EXPORT] : [COMMENT] Get self test result returns TC failure (system failure) - //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA - static const Event SELF_TEST_TC_FAILURE = MAKE_EVENT(5, severity::LOW); - //! [EXPORT] : [COMMENT] Get self test result returns failure that MTM values were outside of the expected range. - //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA - static const Event SELF_TEST_MTM_RANGE_FAILURE = MAKE_EVENT(6, severity::LOW); - //! [EXPORT] : [COMMENT] Get self test result returns failure indicating that the coil current was outside of the expected range - //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA - static const Event SELF_TEST_COIL_CURRENT_FAILURE = MAKE_EVENT(7, severity::LOW); - //! [EXPORT] : [COMMENT] Received invalid error byte. This indicates an error of the communication link between IMTQ and OBC. - static const Event INVALID_ERROR_BYTE = MAKE_EVENT(8, severity::LOW); + uint8_t commandBuffer[IMTQ::MAX_COMMAND_SIZE]; - IMTQ::EngHkDataset engHkDataset; - IMTQ::CalibratedMtmMeasurementSet calMtmMeasurementSet; - IMTQ::RawMtmMeasurementSet rawMtmMeasurementSet; - IMTQ::PosXSelfTestSet posXselfTestDataset; - IMTQ::NegXSelfTestSet negXselfTestDataset; - IMTQ::PosYSelfTestSet posYselfTestDataset; - IMTQ::NegYSelfTestSet negYselfTestDataset; - IMTQ::PosZSelfTestSet posZselfTestDataset; - IMTQ::NegZSelfTestSet negZselfTestDataset; + enum class CommunicationStep { + GET_ENG_HK_DATA, + START_MTM_MEASUREMENT, + GET_CAL_MTM_MEASUREMENT, + GET_RAW_MTM_MEASUREMENT + }; - uint8_t commandBuffer[IMTQ::MAX_COMMAND_SIZE]; + CommunicationStep communicationStep = CommunicationStep::GET_ENG_HK_DATA; - enum class CommunicationStep { - GET_ENG_HK_DATA, - START_MTM_MEASUREMENT, - GET_CAL_MTM_MEASUREMENT, - GET_RAW_MTM_MEASUREMENT - }; + enum class StartupStep { NONE, COMMAND_SELF_TEST, GET_SELF_TEST_RESULT }; - CommunicationStep communicationStep = CommunicationStep::GET_ENG_HK_DATA; + StartupStep startupStep = StartupStep::COMMAND_SELF_TEST; - enum class StartupStep { - NONE, - COMMAND_SELF_TEST, - GET_SELF_TEST_RESULT - }; + bool selfTestPerformed = false; - StartupStep startupStep = StartupStep::COMMAND_SELF_TEST; + /** + * @brief In case of a status reply to a single axis self test command, this function + * searches for the actual pending command. + */ + ReturnValue_t getSelfTestCommandId(DeviceCommandId_t* id); - bool selfTestPerformed = false; + /** + * @brief Each reply contains a status byte giving information about a request. This function + * parses this byte and returns the associated failure message. + * + * @param packet Pointer to the received message containing the status byte. + * + * @return The return code derived from the received status byte. + */ + ReturnValue_t parseStatusByte(const uint8_t* packet); - /** - * @brief In case of a status reply to a single axis self test command, this function - * searches for the actual pending command. - */ - ReturnValue_t getSelfTestCommandId(DeviceCommandId_t* id); + /** + * @brief This function fills the engineering housekeeping dataset with the received data. - /** - * @brief Each reply contains a status byte giving information about a request. This function - * parses this byte and returns the associated failure message. - * - * @param packet Pointer to the received message containing the status byte. - * - * @return The return code derived from the received status byte. - */ - ReturnValue_t parseStatusByte(const uint8_t* packet); + * @param packet Pointer to the received data. + * + */ + void fillEngHkDataset(const uint8_t* packet); - /** - * @brief This function fills the engineering housekeeping dataset with the received data. + /** + * @brief This function sends a command reply to the requesting queue. + * + * @param data Pointer to the data to send. + * @param dataSize Size of the data to send. + * @param relplyId Reply id which will be inserted at the beginning of the action message. + */ + void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); - * @param packet Pointer to the received data. - * - */ - void fillEngHkDataset(const uint8_t* packet); + /** + * @brief This function handles the reply containing the commanded dipole. + * + * @param packet Pointer to the reply data. + */ + void handleGetCommandedDipoleReply(const uint8_t* packet); - /** - * @brief This function sends a command reply to the requesting queue. - * - * @param data Pointer to the data to send. - * @param dataSize Size of the data to send. - * @param relplyId Reply id which will be inserted at the beginning of the action message. - */ - void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); + /** + * @brief This function parses the reply containing the calibrated MTM measurement and writes + * the values to the appropriate dataset. + * @param packet Pointer to the reply data. + */ + void fillCalibratedMtmDataset(const uint8_t* packet); - /** - * @brief This function handles the reply containing the commanded dipole. - * - * @param packet Pointer to the reply data. - */ - void handleGetCommandedDipoleReply(const uint8_t* packet); + /** + * @brief This function copies the raw MTM measurements to the MTM raw dataset. + * @param packet Pointer to the reply data requested with the GET_RAW_MTM_MEASUREMENTS + * command. + */ + void fillRawMtmDataset(const uint8_t* packet); - /** - * @brief This function parses the reply containing the calibrated MTM measurement and writes - * the values to the appropriate dataset. - * @param packet Pointer to the reply data. - */ - void fillCalibratedMtmDataset(const uint8_t* packet); + /** + * @brief This function handles all self test results. This comprises parsing the error byte + * and step byte and calling the function to fill the respective dataset. + */ + void handleSelfTestReply(const uint8_t* packet); - /** - * @brief This function copies the raw MTM measurements to the MTM raw dataset. - * @param packet Pointer to the reply data requested with the GET_RAW_MTM_MEASUREMENTS - * command. - */ - void fillRawMtmDataset(const uint8_t* packet); + /** + * @brief The following functions fill the respective dataset of the single axis self tests. + * @param packet Pointer to the reply data holding the self test result. + */ + void handlePositiveXSelfTestReply(const uint8_t* packet); + void handleNegativeXSelfTestReply(const uint8_t* packet); + void handlePositiveYSelfTestReply(const uint8_t* packet); + void handleNegativeYSelfTestReply(const uint8_t* packet); + void handlePositiveZSelfTestReply(const uint8_t* packet); + void handleNegativeZSelfTestReply(const uint8_t* packet); - /** - * @brief This function handles all self test results. This comprises parsing the error byte - * and step byte and calling the function to fill the respective dataset. - */ - void handleSelfTestReply(const uint8_t* packet); + /** + * @brief This function checks the error byte of a self test measurement. + * + * @param errorByte The received error byte to check + * @param step The step of the error byte. + */ + void checkErrorByte(const uint8_t errorByte, const uint8_t step); - /** - * @brief The following functions fill the respective dataset of the single axis self tests. - * @param packet Pointer to the reply data holding the self test result. - */ - void handlePositiveXSelfTestReply(const uint8_t* packet); - void handleNegativeXSelfTestReply(const uint8_t* packet); - void handlePositiveYSelfTestReply(const uint8_t* packet); - void handleNegativeYSelfTestReply(const uint8_t* packet); - void handlePositiveZSelfTestReply(const uint8_t* packet); - void handleNegativeZSelfTestReply(const uint8_t* packet); - - /** - * @brief This function checks the error byte of a self test measurement. - * - * @param errorByte The received error byte to check - * @param step The step of the error byte. - */ - void checkErrorByte(const uint8_t errorByte, const uint8_t step); - - std::string makeStepString(const uint8_t step); + std::string makeStepString(const uint8_t step); }; #endif /* MISSION_DEVICES_IMTQHANDLER_H_ */ diff --git a/mission/devices/Max31865PT1000Handler.cpp b/mission/devices/Max31865PT1000Handler.cpp index 750d56e5..809e669b 100644 --- a/mission/devices/Max31865PT1000Handler.cpp +++ b/mission/devices/Max31865PT1000Handler.cpp @@ -1,546 +1,531 @@ #include "Max31865PT1000Handler.h" -#include "fsfw/datapool/PoolReadGuard.h" - #include #include +#include "fsfw/datapool/PoolReadGuard.h" + Max31865PT1000Handler::Max31865PT1000Handler(object_id_t objectId, object_id_t comIF, - CookieIF *comCookie): - DeviceHandlerBase(objectId, comIF, comCookie), - sensorDataset(this), sensorDatasetSid(sensorDataset.getSid()) { + CookieIF *comCookie) + : DeviceHandlerBase(objectId, comIF, comCookie), + sensorDataset(this), + sensorDatasetSid(sensorDataset.getSid()) { #if OBSW_VERBOSE_LEVEL >= 1 - debugDivider = new PeriodicOperationDivider(10); + debugDivider = new PeriodicOperationDivider(10); #endif } -Max31865PT1000Handler::~Max31865PT1000Handler() { -} +Max31865PT1000Handler::~Max31865PT1000Handler() {} void Max31865PT1000Handler::doStartUp() { - if(internalState == InternalState::NONE) { - internalState = InternalState::WARMUP; - Clock::getUptime(&startTime); - } + if (internalState == InternalState::NONE) { + internalState = InternalState::WARMUP; + Clock::getUptime(&startTime); + } - if(internalState == InternalState::WARMUP) { - dur_millis_t timeNow = 0; - Clock::getUptime(&timeNow); - if(timeNow - startTime >= 100) { - internalState = InternalState::CONFIGURE; - } + if (internalState == InternalState::WARMUP) { + dur_millis_t timeNow = 0; + Clock::getUptime(&timeNow); + if (timeNow - startTime >= 100) { + internalState = InternalState::CONFIGURE; } + } - if(internalState == InternalState::CONFIGURE) { - if(commandExecuted) { - commandExecuted = false; - internalState = InternalState::REQUEST_CONFIG; - } + if (internalState == InternalState::CONFIGURE) { + if (commandExecuted) { + commandExecuted = false; + internalState = InternalState::REQUEST_CONFIG; } + } - if(internalState == InternalState::REQUEST_CONFIG) { - if (commandExecuted) { - commandExecuted = false; - internalState = InternalState::CONFIG_HIGH_THRESHOLD; - } + if (internalState == InternalState::REQUEST_CONFIG) { + if (commandExecuted) { + commandExecuted = false; + internalState = InternalState::CONFIG_HIGH_THRESHOLD; } + } - if(internalState == InternalState::CONFIG_HIGH_THRESHOLD) { - if(commandExecuted) { - internalState = InternalState::REQUEST_HIGH_THRESHOLD; - commandExecuted = false; - } + if (internalState == InternalState::CONFIG_HIGH_THRESHOLD) { + if (commandExecuted) { + internalState = InternalState::REQUEST_HIGH_THRESHOLD; + commandExecuted = false; } + } - if(internalState == InternalState::REQUEST_HIGH_THRESHOLD) { - if(commandExecuted) { - internalState = InternalState::CONFIG_LOW_THRESHOLD; - commandExecuted = false; - } + if (internalState == InternalState::REQUEST_HIGH_THRESHOLD) { + if (commandExecuted) { + internalState = InternalState::CONFIG_LOW_THRESHOLD; + commandExecuted = false; } + } - if(internalState == InternalState::CONFIG_LOW_THRESHOLD) { - if(commandExecuted) { - internalState = InternalState::REQUEST_LOW_THRESHOLD; - commandExecuted = false; - } + if (internalState == InternalState::CONFIG_LOW_THRESHOLD) { + if (commandExecuted) { + internalState = InternalState::REQUEST_LOW_THRESHOLD; + commandExecuted = false; } + } - if(internalState == InternalState::REQUEST_LOW_THRESHOLD) { - if(commandExecuted) { - internalState = InternalState::CLEAR_FAULT_BYTE; - commandExecuted = false; - } + if (internalState == InternalState::REQUEST_LOW_THRESHOLD) { + if (commandExecuted) { + internalState = InternalState::CLEAR_FAULT_BYTE; + commandExecuted = false; } - if(internalState == InternalState::CLEAR_FAULT_BYTE) { - if(commandExecuted) { - commandExecuted = false; - internalState = InternalState::RUNNING; - if(instantNormal) { - setMode(MODE_NORMAL); - } else { - setMode(_MODE_TO_ON); - } - } + } + if (internalState == InternalState::CLEAR_FAULT_BYTE) { + if (commandExecuted) { + commandExecuted = false; + internalState = InternalState::RUNNING; + if (instantNormal) { + setMode(MODE_NORMAL); + } else { + setMode(_MODE_TO_ON); + } } + } } void Max31865PT1000Handler::doShutDown() { - commandExecuted = false; - setMode(_MODE_POWER_DOWN); + commandExecuted = false; + setMode(_MODE_POWER_DOWN); } -ReturnValue_t Max31865PT1000Handler::buildNormalDeviceCommand( - DeviceCommandId_t *id) { - if(internalState == InternalState::RUNNING) { - *id = Max31865Definitions::REQUEST_RTD; - return buildCommandFromCommand(*id, nullptr, 0); - } - else if(internalState == InternalState::REQUEST_FAULT_BYTE) { - *id = Max31865Definitions::REQUEST_FAULT_BYTE; - return buildCommandFromCommand(*id, nullptr, 0); - } - else if(internalState == InternalState::CLEAR_FAULT_BYTE) { - *id = Max31865Definitions::CLEAR_FAULT_BYTE; - return buildCommandFromCommand(*id, nullptr, 0); - } - else { - return DeviceHandlerBase::NOTHING_TO_SEND; - } -} - -ReturnValue_t Max31865PT1000Handler::buildTransitionDeviceCommand( - DeviceCommandId_t *id) { - switch(internalState) { - case(InternalState::NONE): - case(InternalState::WARMUP): - case(InternalState::RUNNING): +ReturnValue_t Max31865PT1000Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + if (internalState == InternalState::RUNNING) { + *id = Max31865Definitions::REQUEST_RTD; + return buildCommandFromCommand(*id, nullptr, 0); + } else if (internalState == InternalState::REQUEST_FAULT_BYTE) { + *id = Max31865Definitions::REQUEST_FAULT_BYTE; + return buildCommandFromCommand(*id, nullptr, 0); + } else if (internalState == InternalState::CLEAR_FAULT_BYTE) { + *id = Max31865Definitions::CLEAR_FAULT_BYTE; + return buildCommandFromCommand(*id, nullptr, 0); + } else { return DeviceHandlerBase::NOTHING_TO_SEND; - case(InternalState::CONFIGURE): { - *id = Max31865Definitions::CONFIG_CMD; - uint8_t config[1] = {DEFAULT_CONFIG}; - return buildCommandFromCommand(*id, config, 1); + } +} + +ReturnValue_t Max31865PT1000Handler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { + switch (internalState) { + case (InternalState::NONE): + case (InternalState::WARMUP): + case (InternalState::RUNNING): + return DeviceHandlerBase::NOTHING_TO_SEND; + case (InternalState::CONFIGURE): { + *id = Max31865Definitions::CONFIG_CMD; + uint8_t config[1] = {DEFAULT_CONFIG}; + return buildCommandFromCommand(*id, config, 1); } - case(InternalState::REQUEST_CONFIG): { - *id = Max31865Definitions::REQUEST_CONFIG; - return buildCommandFromCommand(*id, nullptr, 0); + case (InternalState::REQUEST_CONFIG): { + *id = Max31865Definitions::REQUEST_CONFIG; + return buildCommandFromCommand(*id, nullptr, 0); } - case(InternalState::CONFIG_HIGH_THRESHOLD): { - *id = Max31865Definitions::WRITE_HIGH_THRESHOLD; - return buildCommandFromCommand(*id, nullptr, 0); + case (InternalState::CONFIG_HIGH_THRESHOLD): { + *id = Max31865Definitions::WRITE_HIGH_THRESHOLD; + return buildCommandFromCommand(*id, nullptr, 0); } - case(InternalState::REQUEST_HIGH_THRESHOLD): { - *id = Max31865Definitions::REQUEST_HIGH_THRESHOLD; - return buildCommandFromCommand(*id, nullptr, 0); + case (InternalState::REQUEST_HIGH_THRESHOLD): { + *id = Max31865Definitions::REQUEST_HIGH_THRESHOLD; + return buildCommandFromCommand(*id, nullptr, 0); } - case(InternalState::CONFIG_LOW_THRESHOLD): { - *id = Max31865Definitions::WRITE_LOW_THRESHOLD; - return buildCommandFromCommand(*id, nullptr, 0); + case (InternalState::CONFIG_LOW_THRESHOLD): { + *id = Max31865Definitions::WRITE_LOW_THRESHOLD; + return buildCommandFromCommand(*id, nullptr, 0); } - case(InternalState::REQUEST_LOW_THRESHOLD): { - *id = Max31865Definitions::REQUEST_LOW_THRESHOLD; - return buildCommandFromCommand(*id, nullptr, 0); + case (InternalState::REQUEST_LOW_THRESHOLD): { + *id = Max31865Definitions::REQUEST_LOW_THRESHOLD; + return buildCommandFromCommand(*id, nullptr, 0); } - case(InternalState::CLEAR_FAULT_BYTE): { - *id = Max31865Definitions::CLEAR_FAULT_BYTE; - return buildCommandFromCommand(*id, nullptr, 0); + case (InternalState::CLEAR_FAULT_BYTE): { + *id = Max31865Definitions::CLEAR_FAULT_BYTE; + return buildCommandFromCommand(*id, nullptr, 0); } default: #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Max31865PT1000Handler: Invalid internal state" << std::endl; + sif::error << "Max31865PT1000Handler: Invalid internal state" << std::endl; #else - sif::printError("Max31865PT1000Handler: Invalid internal state\n"); + sif::printError("Max31865PT1000Handler: Invalid internal state\n"); #endif - return HasReturnvaluesIF::RETURN_FAILED; - } + return HasReturnvaluesIF::RETURN_FAILED; + } } -ReturnValue_t Max31865PT1000Handler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t *commandData, - size_t commandDataLen) { - switch(deviceCommand) { - case(Max31865Definitions::CONFIG_CMD) : { - commandBuffer[0] = static_cast(Max31865Definitions::CONFIG_CMD); - if(commandDataLen == 1) { - commandBuffer[1] = commandData[0]; - DeviceHandlerBase::rawPacketLen = 2; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; - } - else { - return DeviceHandlerIF::NO_COMMAND_DATA; - } - } - case(Max31865Definitions::CLEAR_FAULT_BYTE): { - commandBuffer[0] = static_cast(Max31865Definitions::CONFIG_CMD); - commandBuffer[1] = Max31865Definitions::CLEAR_FAULT_BIT_VAL; +ReturnValue_t Max31865PT1000Handler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, + size_t commandDataLen) { + switch (deviceCommand) { + case (Max31865Definitions::CONFIG_CMD): { + commandBuffer[0] = static_cast(Max31865Definitions::CONFIG_CMD); + if (commandDataLen == 1) { + commandBuffer[1] = commandData[0]; DeviceHandlerBase::rawPacketLen = 2; DeviceHandlerBase::rawPacket = commandBuffer.data(); return HasReturnvaluesIF::RETURN_OK; + } else { + return DeviceHandlerIF::NO_COMMAND_DATA; + } } - case(Max31865Definitions::REQUEST_CONFIG): { - commandBuffer[0] = static_cast( - Max31865Definitions::REQUEST_CONFIG); - commandBuffer[1] = 0x00; // dummy byte - DeviceHandlerBase::rawPacketLen = 2; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; + case (Max31865Definitions::CLEAR_FAULT_BYTE): { + commandBuffer[0] = static_cast(Max31865Definitions::CONFIG_CMD); + commandBuffer[1] = Max31865Definitions::CLEAR_FAULT_BIT_VAL; + DeviceHandlerBase::rawPacketLen = 2; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; } - case(Max31865Definitions::WRITE_HIGH_THRESHOLD): { - commandBuffer[0] = static_cast( - Max31865Definitions::WRITE_HIGH_THRESHOLD); - commandBuffer[1] = static_cast(HIGH_THRESHOLD >> 8); - commandBuffer[2] = static_cast(HIGH_THRESHOLD & 0xFF); - DeviceHandlerBase::rawPacketLen = 3; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; + case (Max31865Definitions::REQUEST_CONFIG): { + commandBuffer[0] = static_cast(Max31865Definitions::REQUEST_CONFIG); + commandBuffer[1] = 0x00; // dummy byte + DeviceHandlerBase::rawPacketLen = 2; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; } - case(Max31865Definitions::REQUEST_HIGH_THRESHOLD): { - commandBuffer[0] = static_cast( - Max31865Definitions::REQUEST_HIGH_THRESHOLD); - commandBuffer[1] = 0x00; //dummy byte - commandBuffer[2] = 0x00; //dummy byte - DeviceHandlerBase::rawPacketLen = 3; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; + case (Max31865Definitions::WRITE_HIGH_THRESHOLD): { + commandBuffer[0] = static_cast(Max31865Definitions::WRITE_HIGH_THRESHOLD); + commandBuffer[1] = static_cast(HIGH_THRESHOLD >> 8); + commandBuffer[2] = static_cast(HIGH_THRESHOLD & 0xFF); + DeviceHandlerBase::rawPacketLen = 3; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; } - case(Max31865Definitions::WRITE_LOW_THRESHOLD): { - commandBuffer[0] = static_cast( - Max31865Definitions::WRITE_LOW_THRESHOLD); - commandBuffer[1] = static_cast(LOW_THRESHOLD >> 8); - commandBuffer[2] = static_cast(LOW_THRESHOLD & 0xFF); - DeviceHandlerBase::rawPacketLen = 3; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; + case (Max31865Definitions::REQUEST_HIGH_THRESHOLD): { + commandBuffer[0] = static_cast(Max31865Definitions::REQUEST_HIGH_THRESHOLD); + commandBuffer[1] = 0x00; // dummy byte + commandBuffer[2] = 0x00; // dummy byte + DeviceHandlerBase::rawPacketLen = 3; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; } - case(Max31865Definitions::REQUEST_LOW_THRESHOLD): { - commandBuffer[0] = static_cast( - Max31865Definitions::REQUEST_LOW_THRESHOLD); - commandBuffer[1] = 0x00; //dummy byte - commandBuffer[2] = 0x00; //dummy byte - DeviceHandlerBase::rawPacketLen = 3; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; + case (Max31865Definitions::WRITE_LOW_THRESHOLD): { + commandBuffer[0] = static_cast(Max31865Definitions::WRITE_LOW_THRESHOLD); + commandBuffer[1] = static_cast(LOW_THRESHOLD >> 8); + commandBuffer[2] = static_cast(LOW_THRESHOLD & 0xFF); + DeviceHandlerBase::rawPacketLen = 3; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; } - case(Max31865Definitions::REQUEST_RTD): { - commandBuffer[0] = static_cast( - Max31865Definitions::REQUEST_RTD); - // two dummy bytes - commandBuffer[1] = 0x00; - commandBuffer[2] = 0x00; - DeviceHandlerBase::rawPacketLen = 3; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; + case (Max31865Definitions::REQUEST_LOW_THRESHOLD): { + commandBuffer[0] = static_cast(Max31865Definitions::REQUEST_LOW_THRESHOLD); + commandBuffer[1] = 0x00; // dummy byte + commandBuffer[2] = 0x00; // dummy byte + DeviceHandlerBase::rawPacketLen = 3; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; } - case(Max31865Definitions::REQUEST_FAULT_BYTE): { - commandBuffer[0] = static_cast( - Max31865Definitions::REQUEST_FAULT_BYTE); - commandBuffer[1] = 0x00; - DeviceHandlerBase::rawPacketLen = 2; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; + case (Max31865Definitions::REQUEST_RTD): { + commandBuffer[0] = static_cast(Max31865Definitions::REQUEST_RTD); + // two dummy bytes + commandBuffer[1] = 0x00; + commandBuffer[2] = 0x00; + DeviceHandlerBase::rawPacketLen = 3; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; + } + case (Max31865Definitions::REQUEST_FAULT_BYTE): { + commandBuffer[0] = static_cast(Max31865Definitions::REQUEST_FAULT_BYTE); + commandBuffer[1] = 0x00; + DeviceHandlerBase::rawPacketLen = 2; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; } default: - //Unknown DeviceCommand - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } + // Unknown DeviceCommand + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } } void Max31865PT1000Handler::fillCommandAndReplyMap() { - insertInCommandAndReplyMap(Max31865Definitions::CONFIG_CMD, 3); - insertInCommandAndReplyMap(Max31865Definitions::REQUEST_CONFIG, 3); - insertInCommandAndReplyMap(Max31865Definitions::WRITE_LOW_THRESHOLD, 3); - insertInCommandAndReplyMap(Max31865Definitions::REQUEST_LOW_THRESHOLD, 3); - insertInCommandAndReplyMap(Max31865Definitions::WRITE_HIGH_THRESHOLD, 3); - insertInCommandAndReplyMap(Max31865Definitions::REQUEST_HIGH_THRESHOLD, 3); - insertInCommandAndReplyMap(Max31865Definitions::REQUEST_RTD, 3, - &sensorDataset); - insertInCommandAndReplyMap(Max31865Definitions::REQUEST_FAULT_BYTE, 3); - insertInCommandAndReplyMap(Max31865Definitions::CLEAR_FAULT_BYTE, 3); + insertInCommandAndReplyMap(Max31865Definitions::CONFIG_CMD, 3); + insertInCommandAndReplyMap(Max31865Definitions::REQUEST_CONFIG, 3); + insertInCommandAndReplyMap(Max31865Definitions::WRITE_LOW_THRESHOLD, 3); + insertInCommandAndReplyMap(Max31865Definitions::REQUEST_LOW_THRESHOLD, 3); + insertInCommandAndReplyMap(Max31865Definitions::WRITE_HIGH_THRESHOLD, 3); + insertInCommandAndReplyMap(Max31865Definitions::REQUEST_HIGH_THRESHOLD, 3); + insertInCommandAndReplyMap(Max31865Definitions::REQUEST_RTD, 3, &sensorDataset); + insertInCommandAndReplyMap(Max31865Definitions::REQUEST_FAULT_BYTE, 3); + insertInCommandAndReplyMap(Max31865Definitions::CLEAR_FAULT_BYTE, 3); } -ReturnValue_t Max31865PT1000Handler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { - size_t rtdReplySize = 3; - size_t configReplySize = 2; - - if(remainingSize == rtdReplySize and - internalState == InternalState::RUNNING) { - *foundId = Max31865Definitions::REQUEST_RTD; - *foundLen = rtdReplySize; - return RETURN_OK; - } - - if(remainingSize == 3) { - switch(internalState) { - case(InternalState::CONFIG_HIGH_THRESHOLD): { - *foundLen = 3; - *foundId = Max31865Definitions::WRITE_HIGH_THRESHOLD; - commandExecuted = true; - return RETURN_OK; - } - case(InternalState::REQUEST_HIGH_THRESHOLD): { - *foundLen = 3; - *foundId = Max31865Definitions::REQUEST_HIGH_THRESHOLD; - return RETURN_OK; - } - case(InternalState::CONFIG_LOW_THRESHOLD): { - *foundLen = 3; - *foundId = Max31865Definitions::WRITE_LOW_THRESHOLD; - commandExecuted = true; - return RETURN_OK; - } - case(InternalState::REQUEST_LOW_THRESHOLD): { - *foundLen = 3; - *foundId = Max31865Definitions::REQUEST_LOW_THRESHOLD; - return RETURN_OK; - } - default: { - sif::debug << "Max31865PT1000Handler::scanForReply: Unknown internal state" - << std::endl; - return RETURN_OK; - } - } - } - - if(remainingSize == configReplySize) { - if(internalState == InternalState::CONFIGURE) { - commandExecuted = true; - *foundLen = configReplySize; - *foundId = Max31865Definitions::CONFIG_CMD; - } - else if(internalState == InternalState::REQUEST_FAULT_BYTE) { - *foundId = Max31865Definitions::REQUEST_FAULT_BYTE; - *foundLen = 2; - internalState = InternalState::RUNNING; - } - else if(internalState == InternalState::CLEAR_FAULT_BYTE) { - *foundId = Max31865Definitions::CLEAR_FAULT_BYTE; - *foundLen = 2; - if(mode == _MODE_START_UP) { - commandExecuted = true; - } else { - internalState = InternalState::RUNNING; - } - } - else { - *foundId = Max31865Definitions::REQUEST_CONFIG; - *foundLen = configReplySize; - } - } +ReturnValue_t Max31865PT1000Handler::scanForReply(const uint8_t *start, size_t remainingSize, + DeviceCommandId_t *foundId, size_t *foundLen) { + size_t rtdReplySize = 3; + size_t configReplySize = 2; + if (remainingSize == rtdReplySize and internalState == InternalState::RUNNING) { + *foundId = Max31865Definitions::REQUEST_RTD; + *foundLen = rtdReplySize; return RETURN_OK; + } + + if (remainingSize == 3) { + switch (internalState) { + case (InternalState::CONFIG_HIGH_THRESHOLD): { + *foundLen = 3; + *foundId = Max31865Definitions::WRITE_HIGH_THRESHOLD; + commandExecuted = true; + return RETURN_OK; + } + case (InternalState::REQUEST_HIGH_THRESHOLD): { + *foundLen = 3; + *foundId = Max31865Definitions::REQUEST_HIGH_THRESHOLD; + return RETURN_OK; + } + case (InternalState::CONFIG_LOW_THRESHOLD): { + *foundLen = 3; + *foundId = Max31865Definitions::WRITE_LOW_THRESHOLD; + commandExecuted = true; + return RETURN_OK; + } + case (InternalState::REQUEST_LOW_THRESHOLD): { + *foundLen = 3; + *foundId = Max31865Definitions::REQUEST_LOW_THRESHOLD; + return RETURN_OK; + } + default: { + sif::debug << "Max31865PT1000Handler::scanForReply: Unknown internal state" << std::endl; + return RETURN_OK; + } + } + } + + if (remainingSize == configReplySize) { + if (internalState == InternalState::CONFIGURE) { + commandExecuted = true; + *foundLen = configReplySize; + *foundId = Max31865Definitions::CONFIG_CMD; + } else if (internalState == InternalState::REQUEST_FAULT_BYTE) { + *foundId = Max31865Definitions::REQUEST_FAULT_BYTE; + *foundLen = 2; + internalState = InternalState::RUNNING; + } else if (internalState == InternalState::CLEAR_FAULT_BYTE) { + *foundId = Max31865Definitions::CLEAR_FAULT_BYTE; + *foundLen = 2; + if (mode == _MODE_START_UP) { + commandExecuted = true; + } else { + internalState = InternalState::RUNNING; + } + } else { + *foundId = Max31865Definitions::REQUEST_CONFIG; + *foundLen = configReplySize; + } + } + + return RETURN_OK; } -ReturnValue_t Max31865PT1000Handler::interpretDeviceReply( - DeviceCommandId_t id, const uint8_t *packet) { - switch(id) { - case(Max31865Definitions::REQUEST_CONFIG): { - if(packet[1] != DEFAULT_CONFIG) { +ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(DeviceCommandId_t id, + const uint8_t *packet) { + switch (id) { + case (Max31865Definitions::REQUEST_CONFIG): { + if (packet[1] != DEFAULT_CONFIG) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - // it propably would be better if we at least try one restart.. - sif::error << "Max31865PT1000Handler: 0x" << std::hex << this->getObjectId() - << ": Invalid configuration reply" << std::endl; + // it propably would be better if we at least try one restart.. + sif::error << "Max31865PT1000Handler: 0x" << std::hex << this->getObjectId() + << ": Invalid configuration reply" << std::endl; #else - sif::printError("Max31865PT1000Handler: %04x: Invalid configuration reply!\n", - this->getObjectId()); + sif::printError("Max31865PT1000Handler: %04x: Invalid configuration reply!\n", + this->getObjectId()); #endif - return HasReturnvaluesIF::RETURN_OK; - } - // set to true for invalid configs too for now. - if(internalState == InternalState::REQUEST_CONFIG) { - commandExecuted = true; - } - else if(internalState == InternalState::RUNNING) { - // we should propably generate a telemetry with the config byte - // as payload here. - } - break; + return HasReturnvaluesIF::RETURN_OK; + } + // set to true for invalid configs too for now. + if (internalState == InternalState::REQUEST_CONFIG) { + commandExecuted = true; + } else if (internalState == InternalState::RUNNING) { + // we should propably generate a telemetry with the config byte + // as payload here. + } + break; } - case(Max31865Definitions::REQUEST_LOW_THRESHOLD): { - uint16_t readLowThreshold = packet[1] << 8 | packet[2]; - if(readLowThreshold != LOW_THRESHOLD) { + case (Max31865Definitions::REQUEST_LOW_THRESHOLD): { + uint16_t readLowThreshold = packet[1] << 8 | packet[2]; + if (readLowThreshold != LOW_THRESHOLD) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << - std::hex << this->getObjectId() << ": Missmatch between " << - "written and readback value of low threshold register" << std::endl; + sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex + << this->getObjectId() << ": Missmatch between " + << "written and readback value of low threshold register" << std::endl; #else - sif::printWarning("Max31865PT1000Handler::interpretDeviceReply: Missmatch between " - "written and readback value of low threshold register\n"); + sif::printWarning( + "Max31865PT1000Handler::interpretDeviceReply: Missmatch between " + "written and readback value of low threshold register\n"); #endif #endif - } - commandExecuted = true; - break; + } + commandExecuted = true; + break; } - case(Max31865Definitions::REQUEST_HIGH_THRESHOLD): { - uint16_t readHighThreshold = packet[1] << 8 | packet[2]; - if(readHighThreshold != HIGH_THRESHOLD) { + case (Max31865Definitions::REQUEST_HIGH_THRESHOLD): { + uint16_t readHighThreshold = packet[1] << 8 | packet[2]; + if (readHighThreshold != HIGH_THRESHOLD) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " - << std::hex << this->getObjectId() << ": Missmatch between " << - "written and readback value of high threshold register" << std::endl; + sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex + << this->getObjectId() << ": Missmatch between " + << "written and readback value of high threshold register" << std::endl; #else - sif::printWarning("Max31865PT1000Handler::interpretDeviceReply: Missmatch between " - "written and readback value of high threshold register\n"); + sif::printWarning( + "Max31865PT1000Handler::interpretDeviceReply: Missmatch between " + "written and readback value of high threshold register\n"); #endif #endif - } - commandExecuted = true; - break; + } + commandExecuted = true; + break; } - case(Max31865Definitions::REQUEST_RTD): { - // first bit of LSB reply byte is the fault bit - uint8_t faultBit = packet[2] & 0b0000'0001; - if(resetFaultBit) { - internalState = InternalState::CLEAR_FAULT_BYTE; - resetFaultBit = false; - } - else if(faultBit == 1) { - // Maybe we should attempt to restart it? - internalState = InternalState::REQUEST_FAULT_BYTE; - resetFaultBit = true; - } + case (Max31865Definitions::REQUEST_RTD): { + // first bit of LSB reply byte is the fault bit + uint8_t faultBit = packet[2] & 0b0000'0001; + if (resetFaultBit) { + internalState = InternalState::CLEAR_FAULT_BYTE; + resetFaultBit = false; + } else if (faultBit == 1) { + // Maybe we should attempt to restart it? + internalState = InternalState::REQUEST_FAULT_BYTE; + resetFaultBit = true; + } - // RTD value consists of last seven bits of the LSB reply byte and - // the MSB reply byte - uint16_t adcCode = ((packet[1] << 8) | packet[2]) >> 1; - // do something with rtd value, will propably be stored in - // dataset. - float rtdValue = adcCode * RTD_RREF_PT1000 / INT16_MAX; - // calculate approximation - float approxTemp = adcCode / 32.0 - 256.0; + // RTD value consists of last seven bits of the LSB reply byte and + // the MSB reply byte + uint16_t adcCode = ((packet[1] << 8) | packet[2]) >> 1; + // do something with rtd value, will propably be stored in + // dataset. + float rtdValue = adcCode * RTD_RREF_PT1000 / INT16_MAX; + // calculate approximation + float approxTemp = adcCode / 32.0 - 256.0; #if OBSW_DEBUG_RTD == 1 #if OBSW_VERBOSE_LEVEL >= 1 - if(debugDivider->checkAndIncrement()) { + if (debugDivider->checkAndIncrement()) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "Max31865: Object ID: " << std::hex << this->getObjectId() - << ": Measured resistance is " << rtdValue << " Ohms." << std::endl; - sif::info << "Approximated temperature is " << approxTemp << " C" << std::endl; + sif::info << "Max31865: Object ID: " << std::hex << this->getObjectId() + << ": Measured resistance is " << rtdValue << " Ohms." << std::endl; + sif::info << "Approximated temperature is " << approxTemp << " C" << std::endl; #else - sif::printInfo("Max31685: Measured resistance is %f Ohms\n", rtdValue); - sif::printInfo("Approximated temperature is %f C\n", approxTemp); + sif::printInfo("Max31685: Measured resistance is %f Ohms\n", rtdValue); + sif::printInfo("Approximated temperature is %f C\n", approxTemp); #endif - } + } #endif #endif - PoolReadGuard pg(&sensorDataset); - if(pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) { - // Configuration error + PoolReadGuard pg(&sensorDataset); + if (pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) { + // Configuration error #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " - << std::hex << this->getObjectId() << ": Error reading dataset!" - << std::endl; + sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex + << this->getObjectId() << ": Error reading dataset!" << std::endl; #else - sif::printWarning("Max31865PT1000Handler::interpretDeviceReply: " - "Error reading dataset!\n"); + sif::printWarning( + "Max31865PT1000Handler::interpretDeviceReply: " + "Error reading dataset!\n"); #endif - return pg.getReadResult(); - } + return pg.getReadResult(); + } - if(not sensorDataset.isValid()) { - sensorDataset.setValidity(true, false); - sensorDataset.rtdValue.setValid(true); - sensorDataset.temperatureCelcius.setValid(true); - } + if (not sensorDataset.isValid()) { + sensorDataset.setValidity(true, false); + sensorDataset.rtdValue.setValid(true); + sensorDataset.temperatureCelcius.setValid(true); + } - sensorDataset.rtdValue = rtdValue; - sensorDataset.temperatureCelcius = approxTemp; - break; + sensorDataset.rtdValue = rtdValue; + sensorDataset.temperatureCelcius = approxTemp; + break; } - case(Max31865Definitions::REQUEST_FAULT_BYTE): { - faultByte = packet[1]; + case (Max31865Definitions::REQUEST_FAULT_BYTE): { + faultByte = packet[1]; #if OBSW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " - << std::hex << this->getObjectId() << ": Fault byte" - " is: 0b" << std::bitset<8>(faultByte) << std::endl; + sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex + << this->getObjectId() + << ": Fault byte" + " is: 0b" + << std::bitset<8>(faultByte) << std::endl; #else - sif::printWarning("Max31865PT1000Handler::interpretDeviceReply: Fault byte" - " is: 0b" BYTE_TO_BINARY_PATTERN "\n", BYTE_TO_BINARY(faultByte)); + sif::printWarning( + "Max31865PT1000Handler::interpretDeviceReply: Fault byte" + " is: 0b" BYTE_TO_BINARY_PATTERN "\n", + BYTE_TO_BINARY(faultByte)); #endif #endif - ReturnValue_t result = sensorDataset.read(); - if(result != HasReturnvaluesIF::RETURN_OK) { - // Configuration error + ReturnValue_t result = sensorDataset.read(); + if (result != HasReturnvaluesIF::RETURN_OK) { + // Configuration error #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex - << this->getObjectId() << ":" - "Error reading dataset!" << std::endl; + sif::debug << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex + << this->getObjectId() + << ":" + "Error reading dataset!" + << std::endl; #else - sif::printDebug("Max31865PT1000Handler::interpretDeviceReply: " - "Error reading dataset!\n"); + sif::printDebug( + "Max31865PT1000Handler::interpretDeviceReply: " + "Error reading dataset!\n"); #endif - return result; - } - sensorDataset.errorByte.setValid(true); - sensorDataset.errorByte = faultByte; - if(faultByte != 0) { - sensorDataset.temperatureCelcius.setValid(false); - } + return result; + } + sensorDataset.errorByte.setValid(true); + sensorDataset.errorByte = faultByte; + if (faultByte != 0) { + sensorDataset.temperatureCelcius.setValid(false); + } - result = sensorDataset.commit(); - if(result != HasReturnvaluesIF::RETURN_OK) { - // Configuration error + result = sensorDataset.commit(); + if (result != HasReturnvaluesIF::RETURN_OK) { + // Configuration error #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex - << this->getObjectId() << ": Error commiting dataset!" << std::endl; + sif::debug << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex + << this->getObjectId() << ": Error commiting dataset!" << std::endl; #else - sif::printDebug("Max31865PT1000Handler::interpretDeviceReply: " - "Error commiting dataset!\n"); + sif::printDebug( + "Max31865PT1000Handler::interpretDeviceReply: " + "Error commiting dataset!\n"); #endif - return result; - } + return result; + } - break; + break; } default: - break; - } - return HasReturnvaluesIF::RETURN_OK; + break; + } + return HasReturnvaluesIF::RETURN_OK; } -void Max31865PT1000Handler::debugInterface(uint8_t positionTracker, - object_id_t objectId, uint32_t parameter) { +void Max31865PT1000Handler::debugInterface(uint8_t positionTracker, object_id_t objectId, + uint32_t parameter) {} + +uint32_t Max31865PT1000Handler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { + return 25000; } -uint32_t Max31865PT1000Handler::getTransitionDelayMs( - Mode_t modeFrom, Mode_t modeTo) { - return 25000; +ReturnValue_t Max31865PT1000Handler::getSwitches(const uint8_t **switches, + uint8_t *numberOfSwitches) { + return DeviceHandlerBase::NO_SWITCH; } -ReturnValue_t Max31865PT1000Handler::getSwitches( - const uint8_t **switches, uint8_t *numberOfSwitches) { - return DeviceHandlerBase::NO_SWITCH; +void Max31865PT1000Handler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { + DeviceHandlerBase::doTransition(modeFrom, subModeFrom); } -void Max31865PT1000Handler::doTransition(Mode_t modeFrom, - Submode_t subModeFrom) { - DeviceHandlerBase::doTransition(modeFrom, subModeFrom); -} - -ReturnValue_t Max31865PT1000Handler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { - localDataPoolMap.emplace(Max31865Definitions::PoolIds::RTD_VALUE, new PoolEntry({0})); - localDataPoolMap.emplace(Max31865Definitions::PoolIds::TEMPERATURE_C, - new PoolEntry({0}, 1, true)); - localDataPoolMap.emplace(Max31865Definitions::PoolIds::FAULT_BYTE, - new PoolEntry({0})); -// poolManager.subscribeForPeriodicPacket(sensorDatasetSid, -// false, 4.0, false); - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t Max31865PT1000Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(Max31865Definitions::PoolIds::RTD_VALUE, new PoolEntry({0})); + localDataPoolMap.emplace(Max31865Definitions::PoolIds::TEMPERATURE_C, + new PoolEntry({0}, 1, true)); + localDataPoolMap.emplace(Max31865Definitions::PoolIds::FAULT_BYTE, new PoolEntry({0})); + // poolManager.subscribeForPeriodicPacket(sensorDatasetSid, + // false, 4.0, false); + return HasReturnvaluesIF::RETURN_OK; } void Max31865PT1000Handler::setInstantNormal(bool instantNormal) { - this->instantNormal = instantNormal; + this->instantNormal = instantNormal; } void Max31865PT1000Handler::modeChanged() { - if(mode == MODE_OFF) { - internalState = InternalState::NONE; - } + if (mode == MODE_OFF) { + internalState = InternalState::NONE; + } } diff --git a/mission/devices/Max31865PT1000Handler.h b/mission/devices/Max31865PT1000Handler.h index 3be16150..44d7a2e7 100644 --- a/mission/devices/Max31865PT1000Handler.h +++ b/mission/devices/Max31865PT1000Handler.h @@ -2,12 +2,12 @@ #define MISSION_DEVICES_MAX31865PT1000HANDLER_H_ #include - #include #include #include #include + #include "devicedefinitions/Max31865Definitions.h" /** @@ -28,95 +28,92 @@ * @author R. Mueller * @ingroup devices */ -class Max31865PT1000Handler: public DeviceHandlerBase { -public: - Max31865PT1000Handler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); - virtual~ Max31865PT1000Handler(); +class Max31865PT1000Handler : public DeviceHandlerBase { + public: + Max31865PT1000Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie); + virtual ~Max31865PT1000Handler(); - // Configuration in 8 digit code: - // 1. 1 for V_BIAS enabled, 0 for disabled - // 2. 1 for Auto-conversion, 0 for off - // 3. 1 for 1-shot enabled, 0 for disabled (self-clearing bit) - // 4. 1 for 3-wire enabled, 0 for disabled (two and four wired RTD) - // 5./6. Fault detection: 00 for no action, 01 for automatic delay, 1 - // 0 for run fault detection with manual delay, - // 11 for finish fault detection with manual delay - // 7. Fault status: Write 1 to reset fault status register (Bit is self cleared afterwards) - // 8. 1 for 50 Hz filter, 0 for 60 Hz filter (noise rejection filter) - static constexpr uint8_t DEFAULT_CONFIG = 0b11000001; + // Configuration in 8 digit code: + // 1. 1 for V_BIAS enabled, 0 for disabled + // 2. 1 for Auto-conversion, 0 for off + // 3. 1 for 1-shot enabled, 0 for disabled (self-clearing bit) + // 4. 1 for 3-wire enabled, 0 for disabled (two and four wired RTD) + // 5./6. Fault detection: 00 for no action, 01 for automatic delay, 1 + // 0 for run fault detection with manual delay, + // 11 for finish fault detection with manual delay + // 7. Fault status: Write 1 to reset fault status register (Bit is self cleared afterwards) + // 8. 1 for 50 Hz filter, 0 for 60 Hz filter (noise rejection filter) + static constexpr uint8_t DEFAULT_CONFIG = 0b11000001; - void setInstantNormal(bool instantNormal); - /** - * Expected temperature range is -100 C and 100 C. - * If there are temperatures beyond this range there must be a fault. - * The threshold variables cause the MAX1385 to signal an error in case the measured resistance - * indicates a temperature higher than 100 C or lower than -100 C. - * Default settings of MAX13865 are 0xFFFF for the high threshold register and 0x0 for the - * low threshold register. - */ - static constexpr uint16_t HIGH_THRESHOLD = 11298; // = 100 C - static constexpr uint16_t LOW_THRESHOLD = 4902; // = -100 C + void setInstantNormal(bool instantNormal); + /** + * Expected temperature range is -100 C and 100 C. + * If there are temperatures beyond this range there must be a fault. + * The threshold variables cause the MAX1385 to signal an error in case the measured resistance + * indicates a temperature higher than 100 C or lower than -100 C. + * Default settings of MAX13865 are 0xFFFF for the high threshold register and 0x0 for the + * low threshold register. + */ + static constexpr uint16_t HIGH_THRESHOLD = 11298; // = 100 C + static constexpr uint16_t LOW_THRESHOLD = 4902; // = -100 C - static constexpr float RTD_RREF_PT1000 = 4020.0; //!< Ohm - static constexpr float RTD_RESISTANCE0_PT1000 = 1000.0; //!< Ohm -protected: - // DeviceHandlerBase abstract function implementation - void doStartUp() override; - void doShutDown() override; - ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; - ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override; - ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t * commandData, size_t commandDataLen) override; - void fillCommandAndReplyMap() 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; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; - ReturnValue_t getSwitches(const uint8_t **switches, - uint8_t *numberOfSwitches) override; + static constexpr float RTD_RREF_PT1000 = 4020.0; //!< Ohm + static constexpr float RTD_RESISTANCE0_PT1000 = 1000.0; //!< Ohm + protected: + // DeviceHandlerBase abstract function implementation + void doStartUp() override; + void doShutDown() override; + ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, + size_t commandDataLen) override; + void fillCommandAndReplyMap() 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; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t getSwitches(const uint8_t **switches, uint8_t *numberOfSwitches) override; - void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override; + void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override; - void debugInterface(uint8_t positionTracker = 0, - object_id_t objectId = 0, uint32_t parameter = 0) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; - void modeChanged() override; + void debugInterface(uint8_t positionTracker = 0, object_id_t objectId = 0, + uint32_t parameter = 0) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) override; + void modeChanged() override; -private: - uint8_t switchId = 0; - bool instantNormal = true; + private: + uint8_t switchId = 0; + bool instantNormal = true; - enum class InternalState { - NONE, - WARMUP, - CONFIGURE, - CONFIG_HIGH_THRESHOLD, - REQUEST_HIGH_THRESHOLD, - CONFIG_LOW_THRESHOLD, - REQUEST_LOW_THRESHOLD, - REQUEST_CONFIG, - RUNNING, - REQUEST_FAULT_BYTE, - CLEAR_FAULT_BYTE - }; + enum class InternalState { + NONE, + WARMUP, + CONFIGURE, + CONFIG_HIGH_THRESHOLD, + REQUEST_HIGH_THRESHOLD, + CONFIG_LOW_THRESHOLD, + REQUEST_LOW_THRESHOLD, + REQUEST_CONFIG, + RUNNING, + REQUEST_FAULT_BYTE, + CLEAR_FAULT_BYTE + }; - InternalState internalState = InternalState::NONE; - bool commandExecuted = false; + InternalState internalState = InternalState::NONE; + bool commandExecuted = false; - bool resetFaultBit = false; - dur_millis_t startTime = 0; - uint8_t faultByte = 0; - std::array commandBuffer { 0 }; + bool resetFaultBit = false; + dur_millis_t startTime = 0; + uint8_t faultByte = 0; + std::array commandBuffer{0}; - Max31865Definitions::Max31865Set sensorDataset; - sid_t sensorDatasetSid; + Max31865Definitions::Max31865Set sensorDataset; + sid_t sensorDatasetSid; #if OBSW_VERBOSE_LEVEL >= 1 - PeriodicOperationDivider* debugDivider; + PeriodicOperationDivider *debugDivider; #endif }; #endif /* MISSION_DEVICES_MAX31865PT1000HANDLER_H_ */ - diff --git a/mission/devices/P60DockHandler.cpp b/mission/devices/P60DockHandler.cpp index 4ade2a0b..a89debc6 100644 --- a/mission/devices/P60DockHandler.cpp +++ b/mission/devices/P60DockHandler.cpp @@ -1,480 +1,506 @@ -#include #include "P60DockHandler.h" + +#include + #include "OBSWConfig.h" -P60DockHandler::P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - GomspaceDeviceHandler(objectId, comIF, comCookie, P60Dock::MAX_CONFIGTABLE_ADDRESS, - P60Dock::MAX_HKTABLE_ADDRESS, P60Dock::HK_TABLE_REPLY_SIZE, &p60dockHkTableDataset), p60dockHkTableDataset( - this) { -} +P60DockHandler::P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie) + : GomspaceDeviceHandler(objectId, comIF, comCookie, P60Dock::MAX_CONFIGTABLE_ADDRESS, + P60Dock::MAX_HKTABLE_ADDRESS, P60Dock::HK_TABLE_REPLY_SIZE, + &p60dockHkTableDataset), + p60dockHkTableDataset(this) {} -P60DockHandler::~P60DockHandler() { -} +P60DockHandler::~P60DockHandler() {} -ReturnValue_t P60DockHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - *id = GOMSPACE::REQUEST_HK_TABLE; - return buildCommandFromCommand(*id, NULL, 0); +ReturnValue_t P60DockHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + *id = GOMSPACE::REQUEST_HK_TABLE; + return buildCommandFromCommand(*id, NULL, 0); } void P60DockHandler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) { - - parseHkTableReply(packet); - /** - * Hk table will be sent to the commander if hk table request was not triggered by the - * P60DockHandler itself. - */ - handleDeviceTM(&p60dockHkTableDataset, id, true); + parseHkTableReply(packet); + /** + * Hk table will be sent to the commander if hk table request was not triggered by the + * P60DockHandler itself. + */ + handleDeviceTM(&p60dockHkTableDataset, id, true); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_P60DOCK == 1 - p60dockHkTableDataset.read(); - sif::info << "P60 Dock: ACU VCC switch: " << - static_cast(p60dockHkTableDataset.outputEnableStateAcuVcc.value) << std::endl; - sif::info << "P60 Dock: PDU1 VCC switch: " << - static_cast(p60dockHkTableDataset.outputEnableStatePdu1Vcc.value) << std::endl; - sif::info << "P60 Dock: PDU2 VCC switch: " << - static_cast(p60dockHkTableDataset.outputEnableStatePdu2Vcc.value) << std::endl; - sif::info << "P60 Dock: ACU VBAT switch: " << - static_cast(p60dockHkTableDataset.outputEnableStateAcuVbat.value) << std::endl; - sif::info << "P60 Dock: PDU1 VBAT switch: " << - static_cast(p60dockHkTableDataset.outputEnableStatePdu1Vbat.value) << std::endl; - sif::info << "P60 Dock: PDU2 VBAT switch: " << - static_cast(p60dockHkTableDataset.outputEnableStatePdu2Vbat.value) << std::endl; - sif::info << "P60 Dock: Stack VBAT switch: " << - static_cast(p60dockHkTableDataset.outputEnableStateStackVbat.value) << std::endl; - sif::info << "P60 Dock: Stack 3V3 switch: " << - static_cast(p60dockHkTableDataset.outputEnableStateStack3V3.value) << std::endl; - sif::info << "P60 Dock: Stack 5V switch: " << - static_cast(p60dockHkTableDataset.outputEnableStateStack5V.value) << std::endl; + p60dockHkTableDataset.read(); + sif::info << "P60 Dock: ACU VCC switch: " + << static_cast(p60dockHkTableDataset.outputEnableStateAcuVcc.value) + << std::endl; + sif::info << "P60 Dock: PDU1 VCC switch: " + << static_cast(p60dockHkTableDataset.outputEnableStatePdu1Vcc.value) + << std::endl; + sif::info << "P60 Dock: PDU2 VCC switch: " + << static_cast(p60dockHkTableDataset.outputEnableStatePdu2Vcc.value) + << std::endl; + sif::info << "P60 Dock: ACU VBAT switch: " + << static_cast(p60dockHkTableDataset.outputEnableStateAcuVbat.value) + << std::endl; + sif::info << "P60 Dock: PDU1 VBAT switch: " + << static_cast(p60dockHkTableDataset.outputEnableStatePdu1Vbat.value) + << std::endl; + sif::info << "P60 Dock: PDU2 VBAT switch: " + << static_cast(p60dockHkTableDataset.outputEnableStatePdu2Vbat.value) + << std::endl; + sif::info << "P60 Dock: Stack VBAT switch: " + << static_cast(p60dockHkTableDataset.outputEnableStateStackVbat.value) + << std::endl; + sif::info << "P60 Dock: Stack 3V3 switch: " + << static_cast(p60dockHkTableDataset.outputEnableStateStack3V3.value) + << std::endl; + sif::info << "P60 Dock: Stack 5V switch: " + << static_cast(p60dockHkTableDataset.outputEnableStateStack5V.value) + << std::endl; - float temperatureC = p60dockHkTableDataset.temperature1.value * 0.1; - sif::info << "P60 Dock: Temperature 1: " << temperatureC << " °C" << std::endl; - temperatureC = p60dockHkTableDataset.temperature2.value * 0.1; - sif::info << "P60 Dock: Temperature 2: " << temperatureC << " °C" << std::endl; - sif::info << "P60 Dock: Watchdog Timer seconds left before reboot: " + float temperatureC = p60dockHkTableDataset.temperature1.value * 0.1; + sif::info << "P60 Dock: Temperature 1: " << temperatureC << " °C" << std::endl; + temperatureC = p60dockHkTableDataset.temperature2.value * 0.1; + sif::info << "P60 Dock: Temperature 2: " << temperatureC << " °C" << std::endl; + sif::info << "P60 Dock: Watchdog Timer seconds left before reboot: " << p60dockHkTableDataset.wdtGndLeft << " seconds" << std::endl; - sif::info << "P60 Dock: CSP 1, pings left before reboot: " - << (int) p60dockHkTableDataset.wdtCspLeft1.value << std::endl; - sif::info << "P60 Dock: CSP 2, pings left before reboot: " - << (int) p60dockHkTableDataset.wdtCspLeft1.value << std::endl; + sif::info << "P60 Dock: CSP 1, pings left before reboot: " + << (int)p60dockHkTableDataset.wdtCspLeft1.value << std::endl; + sif::info << "P60 Dock: CSP 2, pings left before reboot: " + << (int)p60dockHkTableDataset.wdtCspLeft1.value << std::endl; - p60dockHkTableDataset.commit(); + p60dockHkTableDataset.commit(); #endif - } void P60DockHandler::parseHkTableReply(const uint8_t *packet) { - uint16_t dataOffset = 0; - p60dockHkTableDataset.read(); - /** - * Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table - * address. - */ - dataOffset += 12; - p60dockHkTableDataset.currentAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentPdu1Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentX3IdleVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentPdu2Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentAcuVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentPdu1Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentX3IdleVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentPdu2Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentStackVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentStack3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentStack5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentGS3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentGS5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + uint16_t dataOffset = 0; + p60dockHkTableDataset.read(); + /** + * Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table + * address. + */ + dataOffset += 12; + p60dockHkTableDataset.currentAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentPdu1Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentX3IdleVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentPdu2Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentAcuVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentPdu1Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentX3IdleVbat = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentPdu2Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentStackVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentStack3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentStack5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentGS3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentGS5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - p60dockHkTableDataset.voltageAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltagePdu1Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageX3IdleVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltagePdu2Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageAcuVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltagePdu1Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageX3IdleVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltagePdu2Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageStackVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageStack3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageStack5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageGS3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + p60dockHkTableDataset.voltageAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltagePdu1Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageX3IdleVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltagePdu2Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageAcuVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltagePdu1Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageX3IdleVbat = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltagePdu2Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageStackVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageStack3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageStack5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageGS3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - p60dockHkTableDataset.outputEnableStateAcuVcc = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStatePdu1Vcc = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateX3IdleVcc = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStatePdu2Vcc = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateAcuVbat = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStatePdu1Vbat = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateX3IdleVbat = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStatePdu2Vbat = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateStackVbat = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateStack3V3 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateStack5V = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateGS3V3 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateGS5V = *(packet + dataOffset); - dataOffset += 3; + p60dockHkTableDataset.outputEnableStateAcuVcc = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStatePdu1Vcc = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateX3IdleVcc = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStatePdu2Vcc = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateAcuVbat = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStatePdu1Vbat = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateX3IdleVbat = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStatePdu2Vbat = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateStackVbat = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateStack3V3 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateStack5V = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateGS3V3 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateGS5V = *(packet + dataOffset); + dataOffset += 3; - p60dockHkTableDataset.temperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.temperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + p60dockHkTableDataset.temperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.temperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - p60dockHkTableDataset.bootcause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.bootCount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.resetcause = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.battMode = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.heaterOn = *(packet + dataOffset); - /* + 13 because here begins a new gomspace csp data field */ - dataOffset += 13; - p60dockHkTableDataset.converter5VStatus = *(packet + dataOffset); - dataOffset += 3; + p60dockHkTableDataset.bootcause = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.bootCount = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.resetcause = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.battMode = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.heaterOn = *(packet + dataOffset); + /* + 13 because here begins a new gomspace csp data field */ + dataOffset += 13; + p60dockHkTableDataset.converter5VStatus = *(packet + dataOffset); + dataOffset += 3; - p60dockHkTableDataset.latchupsAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsPdu1Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsX3IdleVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsPdu2Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsAcuVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsPdu1Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsX3IdleVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsPdu2Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsStackVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsStack3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsStack5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsGS3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + p60dockHkTableDataset.latchupsAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsPdu1Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsX3IdleVcc = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsPdu2Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsAcuVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsPdu1Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsX3IdleVbat = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsPdu2Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsStackVbat = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsStack3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsStack5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsGS3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - p60dockHkTableDataset.vbatVoltageValue = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.vccCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.batteryCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.batteryVoltage = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + p60dockHkTableDataset.vbatVoltageValue = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.vccCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.batteryCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.batteryVoltage = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - p60dockHkTableDataset.batteryTemperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.batteryTemperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + p60dockHkTableDataset.batteryTemperature1 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.batteryTemperature2 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - p60dockHkTableDataset.device0 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device1 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device2 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device3 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device4 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device5 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device6 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device7 = *(packet + dataOffset); - dataOffset += 3; + p60dockHkTableDataset.device0 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device1 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device2 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device3 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device4 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device5 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device6 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device7 = *(packet + dataOffset); + dataOffset += 3; - p60dockHkTableDataset.device0Status = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device1Status = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device2Status = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device3Status = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device4Status = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device5Status = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device6Status = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device7Status = *(packet + dataOffset); - dataOffset += 3; + p60dockHkTableDataset.device0Status = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device1Status = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device2Status = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device3Status = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device4Status = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device5Status = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device6Status = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device7Status = *(packet + dataOffset); + dataOffset += 3; - p60dockHkTableDataset.dearmStatus = *(packet + dataOffset); - dataOffset += 3; + p60dockHkTableDataset.dearmStatus = *(packet + dataOffset); + dataOffset += 3; - p60dockHkTableDataset.wdtCntGnd = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.wdtCntI2c = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.wdtCntCan = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.wdtCntCsp1 = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.wdtCntCsp2 = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; + p60dockHkTableDataset.wdtCntGnd = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.wdtCntI2c = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.wdtCntCan = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.wdtCntCsp1 = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.wdtCntCsp2 = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; - p60dockHkTableDataset.wdtGndLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.wdtI2cLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.wdtCanLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - /* +16 because here begins a new gomspace csp packet */ - dataOffset += 16; + p60dockHkTableDataset.wdtGndLeft = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.wdtI2cLeft = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.wdtCanLeft = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + /* +16 because here begins a new gomspace csp packet */ + dataOffset += 16; - p60dockHkTableDataset.wdtCspLeft1 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.wdtCspLeft2 = *(packet + dataOffset); - dataOffset += 3; + p60dockHkTableDataset.wdtCspLeft1 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.wdtCspLeft2 = *(packet + dataOffset); + dataOffset += 3; - p60dockHkTableDataset.batteryChargeCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.batteryDischargeCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.ant6Depl = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.ar6Depl = *(packet + dataOffset); + p60dockHkTableDataset.batteryChargeCurrent = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.batteryDischargeCurrent = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.ant6Depl = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.ar6Depl = *(packet + dataOffset); - p60dockHkTableDataset.commit(); + p60dockHkTableDataset.commit(); } -ReturnValue_t P60DockHandler::initializeLocalDataPool( - localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { +ReturnValue_t P60DockHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_ACU_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU1_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_X3_IDLE_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU2_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_ACU_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU1_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_X3_IDLE_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU2_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_5V, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_GS3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_GS5V, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_ACU_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU1_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_X3_IDLE_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU2_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_ACU_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU1_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_X3_IDLE_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU2_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_5V, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_GS3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_GS5V, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_ACU_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU1_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_X3_IDLE_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU2_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_ACU_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU1_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_X3_IDLE_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU2_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_5V, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_GS3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_GS5V, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_ACU_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU1_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_X3_IDLE_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU2_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_ACU_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU1_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_X3_IDLE_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU2_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_5V, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_GS3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_GS5V, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_ACU_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU1_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VCC, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU2_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_ACU_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU1_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VBAT, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU2_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_5V, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_GS3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_GS5V, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_ACU_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU1_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU2_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_ACU_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU1_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU2_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_5V, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_GS3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_GS5V, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_TEMPERATURE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_TEMPERATURE_2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_TEMPERATURE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_TEMPERATURE_2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_BOOT_CAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_BOOT_CNT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_RESETCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_BATT_MODE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_HEATER_ON, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CONV_5V_ENABLE_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_BOOT_CAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_BOOT_CNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_UPTIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_RESETCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_BATT_MODE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_HEATER_ON, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CONV_5V_ENABLE_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_ACU_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU1_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_X3_IDLE_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU2_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_ACU_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU1_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_X3_IDLE_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU2_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_5V, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_GS3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_GS5V, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_ACU_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU1_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_X3_IDLE_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU2_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_ACU_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU1_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_X3_IDLE_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU2_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_5V, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_GS3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_GS5V, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_VBAT_VALUE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VCC_CURRENT_VALUE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_VOLTAGE, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_VBAT_VALUE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VCC_CURRENT_VALUE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_VOLTAGE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_TEMPERATURE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_TEMPERATURE_2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_TEMPERATURE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_TEMPERATURE_2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_5, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_7, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_0_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_1_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_2_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_3_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_4_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_5_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_6_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_7_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_0_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_1_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_2_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_3_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_4_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_5_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_6_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_7_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_DEARM_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_DEARM_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_GND, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_I2C, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CAN, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CSP_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CSP_2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_GND, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_I2C, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CAN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CSP_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CSP_2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_GND_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_I2C_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CAN_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CSP_LEFT_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CSP_LEFT_2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_GND_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_I2C_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CAN_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CSP_LEFT_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CSP_LEFT_2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_BATT_CHARGE_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_BATT_DISCHARGE_CURRENT, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_BATT_CHARGE_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_BATT_DISCHARGE_CURRENT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_ANT6_DEPL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_AR6_DEPL, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_ANT6_DEPL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_AR6_DEPL, new PoolEntry( { 0 })); - - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } - ReturnValue_t P60DockHandler::printStatus(DeviceCommandId_t cmd) { - switch(cmd) { - case(GOMSPACE::PRINT_SWITCH_V_I): { - PoolReadGuard pg(&p60dockHkTableDataset); - ReturnValue_t readResult = pg.getReadResult(); - if(readResult != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Reading PDU1 HK table failed!" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - printHkTable(); - return HasReturnvaluesIF::RETURN_OK; + switch (cmd) { + case (GOMSPACE::PRINT_SWITCH_V_I): { + PoolReadGuard pg(&p60dockHkTableDataset); + ReturnValue_t readResult = pg.getReadResult(); + if (readResult != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Reading PDU1 HK table failed!" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + printHkTable(); + return HasReturnvaluesIF::RETURN_OK; } default: { - return HasReturnvaluesIF::RETURN_FAILED; - } + return HasReturnvaluesIF::RETURN_FAILED; } + } } void P60DockHandler::printHkTable() { - sif::info << "P60 Dock Info: SwitchState, Currents [mA], Voltages [mV]" << std::endl; + sif::info << "P60 Dock Info: SwitchState, Currents [mA], Voltages [mV]" << std::endl; - sif::info << std::setw(30) << std::left << "ACU VCC" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStateAcuVcc.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentAcuVcc.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltageAcuVcc.value << std::endl; - sif::info << std::setw(30) << std::left << "ACU VBAT" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStateAcuVbat.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentAcuVbat.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltageAcuVbat.value << std::endl; + sif::info << std::setw(30) << std::left << "ACU VCC" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStateAcuVcc.value) << ", " << std::setw(4) + << std::right << p60dockHkTableDataset.currentAcuVcc.value << ", " << std::setw(5) + << p60dockHkTableDataset.voltageAcuVcc.value << std::endl; + sif::info << std::setw(30) << std::left << "ACU VBAT" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStateAcuVbat.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentAcuVbat.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltageAcuVbat.value << std::endl; - sif::info << std::setw(30) << std::left << "PDU1 VCC" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStatePdu1Vcc.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentPdu1Vcc.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltagePdu1Vcc.value << std::endl; - sif::info << std::setw(30) << std::left << "PDU1 VBAT" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStatePdu1Vbat.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentPdu1Vbat.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltagePdu1Vbat.value << std::endl; + sif::info << std::setw(30) << std::left << "PDU1 VCC" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStatePdu1Vcc.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentPdu1Vcc.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltagePdu1Vcc.value << std::endl; + sif::info << std::setw(30) << std::left << "PDU1 VBAT" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStatePdu1Vbat.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentPdu1Vbat.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltagePdu1Vbat.value << std::endl; - sif::info << std::setw(30) << std::left << "PDU2 VCC" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStatePdu2Vcc.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentPdu2Vcc.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltagePdu2Vcc.value << std::endl; - sif::info << std::setw(30) << std::left << "PDU2 VBAT" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStatePdu2Vbat.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentPdu2Vbat.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltagePdu2Vbat.value << std::endl; + sif::info << std::setw(30) << std::left << "PDU2 VCC" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStatePdu2Vcc.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentPdu2Vcc.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltagePdu2Vcc.value << std::endl; + sif::info << std::setw(30) << std::left << "PDU2 VBAT" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStatePdu2Vbat.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentPdu2Vbat.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltagePdu2Vbat.value << std::endl; - sif::info << std::setw(30) << std::left << "Stack VBAT" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStateStackVbat.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentStackVbat.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltageStackVbat.value << std::endl; - sif::info << std::setw(30) << std::left << "Stack 3V3" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStateStack3V3.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentStack3V3.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltageStack3V3.value << std::endl; - sif::info << std::setw(30) << std::left << "Stack 5V" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStateStack5V.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentStack5V.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltageStack5V.value << std::endl; + sif::info << std::setw(30) << std::left << "Stack VBAT" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStateStackVbat.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentStackVbat.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltageStackVbat.value << std::endl; + sif::info << std::setw(30) << std::left << "Stack 3V3" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStateStack3V3.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentStack3V3.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltageStack3V3.value << std::endl; + sif::info << std::setw(30) << std::left << "Stack 5V" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStateStack5V.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentStack5V.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltageStack5V.value << std::endl; } - diff --git a/mission/devices/P60DockHandler.h b/mission/devices/P60DockHandler.h index cee0ecec..937ef122 100644 --- a/mission/devices/P60DockHandler.h +++ b/mission/devices/P60DockHandler.h @@ -1,47 +1,47 @@ #ifndef MISSION_DEVICES_P60DOCKHANDLER_H_ #define MISSION_DEVICES_P60DOCKHANDLER_H_ -#include "GomspaceDeviceHandler.h" #include +#include "GomspaceDeviceHandler.h" /** * @brief Device handler for the P60Dock. The P60Dock serves as carrier for the ACU, PDU1 and * PDU2. Via the P60Dock each of these modules can be turned on and off individually. */ -class P60DockHandler: public GomspaceDeviceHandler { -public: - P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); - virtual ~P60DockHandler(); +class P60DockHandler : public GomspaceDeviceHandler { + public: + P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + virtual ~P60DockHandler(); - virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; + virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; -protected: + protected: + /** + * @brief As soon as the device is in MODE_NORMAL, this function is executed periodically. + */ + virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override; - /** - * @brief As soon as the device is in MODE_NORMAL, this function is executed periodically. - */ - virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; + virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t* packet) override; - virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) override; + /** + * This command handles printing the HK table to the console. This is useful for debugging + * purposes + * @return + */ + ReturnValue_t printStatus(DeviceCommandId_t cmd) override; - /** - * This command handles printing the HK table to the console. This is useful for debugging - * purposes - * @return - */ - ReturnValue_t printStatus(DeviceCommandId_t cmd) override; + void printHkTable(); - void printHkTable(); -private: - P60Dock::HkTableDataset p60dockHkTableDataset; + private: + P60Dock::HkTableDataset p60dockHkTableDataset; - /** - * @brief Function extracts the hk table information from the received csp packet and stores - * the values in the p60dockHkTableDataset. - */ - void parseHkTableReply(const uint8_t *packet); + /** + * @brief Function extracts the hk table information from the received csp packet and stores + * the values in the p60dockHkTableDataset. + */ + void parseHkTableReply(const uint8_t* packet); }; #endif /* MISSION_DEVICES_P60DOCKHANDLER_H_ */ diff --git a/mission/devices/PCDUHandler.cpp b/mission/devices/PCDUHandler.cpp index fe7294ea..13bed074 100644 --- a/mission/devices/PCDUHandler.cpp +++ b/mission/devices/PCDUHandler.cpp @@ -1,506 +1,488 @@ #include "PCDUHandler.h" + #include +#include +#include +#include #include -#include - -#include -#include - - -PCDUHandler::PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize) : - SystemObject(setObjectId), poolManager(this, nullptr), pdu2HkTableDataset(this), pdu1HkTableDataset( - this), cmdQueueSize(cmdQueueSize) { - - commandQueue = QueueFactory::instance()->createMessageQueue(cmdQueueSize, - MessageQueueMessage::MAX_MESSAGE_SIZE); +PCDUHandler::PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize) + : SystemObject(setObjectId), + poolManager(this, nullptr), + pdu2HkTableDataset(this), + pdu1HkTableDataset(this), + cmdQueueSize(cmdQueueSize) { + commandQueue = QueueFactory::instance()->createMessageQueue( + cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE); } -PCDUHandler::~PCDUHandler() { -} +PCDUHandler::~PCDUHandler() {} ReturnValue_t PCDUHandler::performOperation(uint8_t counter) { - - if (counter == DeviceHandlerIF::PERFORM_OPERATION) { - readCommandQueue(); - return RETURN_OK; - } - + if (counter == DeviceHandlerIF::PERFORM_OPERATION) { + readCommandQueue(); return RETURN_OK; + } + + return RETURN_OK; } ReturnValue_t PCDUHandler::initialize() { + ReturnValue_t result; - ReturnValue_t result; + IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); + if (IPCStore == nullptr) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); - if (IPCStore == nullptr) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = poolManager.initialize(commandQueue); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } - result = poolManager.initialize(commandQueue); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + /* Subscribing for housekeeping table update messages of the PDU2 */ + HasLocalDataPoolIF* pdu2Handler = + ObjectManager::instance()->get(objects::PDU2_HANDLER); + if (pdu2Handler == nullptr) { + sif::error << "PCDUHandler::initialize: Invalid pdu2Handler" << std::endl; + return RETURN_FAILED; + } + result = pdu2Handler->getSubscriptionInterface()->subscribeForSetUpdateMessage( + PDU2::HK_TABLE_DATA_SET_ID, this->getObjectId(), commandQueue->getId(), true); + if (result != RETURN_OK) { + sif::error << "PCDUHandler::initialize: Failed to subscribe for set update messages from " + << "PDU2Handler" << std::endl; + return result; + } - /* Subscribing for housekeeping table update messages of the PDU2 */ - HasLocalDataPoolIF* pdu2Handler = ObjectManager::instance()->get( - objects::PDU2_HANDLER); - if(pdu2Handler == nullptr) { - sif::error << "PCDUHandler::initialize: Invalid pdu2Handler" << std::endl; - return RETURN_FAILED; - } - result = pdu2Handler->getSubscriptionInterface()->subscribeForSetUpdateMessage( - PDU2::HK_TABLE_DATA_SET_ID, this->getObjectId(), commandQueue->getId(), true); - if (result != RETURN_OK) { - sif::error << "PCDUHandler::initialize: Failed to subscribe for set update messages from " - << "PDU2Handler" << std::endl; - return result; - } + /* Subscribing for housekeeping table update messages of the PDU1 */ + HasLocalDataPoolIF* pdu1Handler = + ObjectManager::instance()->get(objects::PDU1_HANDLER); + if (pdu1Handler == nullptr) { + sif::error << "PCDUHandler::initialize: Invalid pdu1Handler" << std::endl; + return RETURN_FAILED; + } + result = pdu1Handler->getSubscriptionInterface()->subscribeForSetUpdateMessage( + PDU1::HK_TABLE_DATA_SET_ID, this->getObjectId(), commandQueue->getId(), true); + if (result != RETURN_OK) { + sif::error << "PCDUHandler::initialize: Failed to subscribe for set update messages from " + << "PDU1Handler" << std::endl; + return result; + } - /* Subscribing for housekeeping table update messages of the PDU1 */ - HasLocalDataPoolIF* pdu1Handler = ObjectManager::instance()->get( - objects::PDU1_HANDLER); - if(pdu1Handler == nullptr) { - sif::error << "PCDUHandler::initialize: Invalid pdu1Handler" << std::endl; - return RETURN_FAILED; - } - result = pdu1Handler->getSubscriptionInterface()->subscribeForSetUpdateMessage( - PDU1::HK_TABLE_DATA_SET_ID, this->getObjectId(), commandQueue->getId(), true); - if (result != RETURN_OK) { - sif::error << "PCDUHandler::initialize: Failed to subscribe for set update messages from " - << "PDU1Handler" << std::endl; - return result; - } - - return RETURN_OK; + return RETURN_OK; } void PCDUHandler::initializeSwitchStates() { - switchStates[pcduSwitches::Q7S] = pcduSwitches::INIT_STATE_Q7S; - switchStates[pcduSwitches::PAYLOAD_PCDU_CH1] = pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH1; - switchStates[pcduSwitches::RW] = pcduSwitches::INIT_STATE_RW; - switchStates[pcduSwitches::TCS_BOARD_8V_HEATER_IN] = pcduSwitches::INIT_STATE_TCS_BOARD_8V_HEATER_IN; - switchStates[pcduSwitches::SUS_REDUNDANT] = pcduSwitches::INIT_STATE_SUS_REDUNDANT; - switchStates[pcduSwitches::DEPLOYMENT_MECHANISM] = pcduSwitches::INIT_STATE_DEPLOYMENT_MECHANISM; - switchStates[pcduSwitches::PAYLOAD_PCDU_CH6] = pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH6; - switchStates[pcduSwitches::ACS_BOARD_SIDE_B] = pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_B; - switchStates[pcduSwitches::PAYLOAD_CAMERA] = pcduSwitches::INIT_STATE_PAYLOAD_CAMERA; - switchStates[pcduSwitches::TCS_BOARD_3V3] = pcduSwitches::INIT_STATE_TCS_BOARD_3V3; - switchStates[pcduSwitches::SYRLINKS] = pcduSwitches::INIT_STATE_SYRLINKS; - switchStates[pcduSwitches::STAR_TRACKER] = pcduSwitches::INIT_STATE_STAR_TRACKER; - switchStates[pcduSwitches::MGT] = pcduSwitches::INIT_STATE_MGT; - switchStates[pcduSwitches::SUS_NOMINAL] = pcduSwitches::INIT_STATE_SUS_NOMINAL; - switchStates[pcduSwitches::SOLAR_CELL_EXP] = pcduSwitches::INIT_STATE_SOLAR_CELL_EXP; - switchStates[pcduSwitches::PLOC] = pcduSwitches::INIT_STATE_PLOC; - switchStates[pcduSwitches::ACS_BOARD_SIDE_A] = pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_A; + switchStates[pcduSwitches::Q7S] = pcduSwitches::INIT_STATE_Q7S; + switchStates[pcduSwitches::PAYLOAD_PCDU_CH1] = pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH1; + switchStates[pcduSwitches::RW] = pcduSwitches::INIT_STATE_RW; + switchStates[pcduSwitches::TCS_BOARD_8V_HEATER_IN] = + pcduSwitches::INIT_STATE_TCS_BOARD_8V_HEATER_IN; + switchStates[pcduSwitches::SUS_REDUNDANT] = pcduSwitches::INIT_STATE_SUS_REDUNDANT; + switchStates[pcduSwitches::DEPLOYMENT_MECHANISM] = pcduSwitches::INIT_STATE_DEPLOYMENT_MECHANISM; + switchStates[pcduSwitches::PAYLOAD_PCDU_CH6] = pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH6; + switchStates[pcduSwitches::ACS_BOARD_SIDE_B] = pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_B; + switchStates[pcduSwitches::PAYLOAD_CAMERA] = pcduSwitches::INIT_STATE_PAYLOAD_CAMERA; + switchStates[pcduSwitches::TCS_BOARD_3V3] = pcduSwitches::INIT_STATE_TCS_BOARD_3V3; + switchStates[pcduSwitches::SYRLINKS] = pcduSwitches::INIT_STATE_SYRLINKS; + switchStates[pcduSwitches::STAR_TRACKER] = pcduSwitches::INIT_STATE_STAR_TRACKER; + switchStates[pcduSwitches::MGT] = pcduSwitches::INIT_STATE_MGT; + switchStates[pcduSwitches::SUS_NOMINAL] = pcduSwitches::INIT_STATE_SUS_NOMINAL; + switchStates[pcduSwitches::SOLAR_CELL_EXP] = pcduSwitches::INIT_STATE_SOLAR_CELL_EXP; + switchStates[pcduSwitches::PLOC] = pcduSwitches::INIT_STATE_PLOC; + switchStates[pcduSwitches::ACS_BOARD_SIDE_A] = pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_A; } void PCDUHandler::readCommandQueue() { - ReturnValue_t result; - CommandMessage command; + ReturnValue_t result; + CommandMessage command; - result = commandQueue->receiveMessage(&command); - if (result != RETURN_OK) { - return; - } + result = commandQueue->receiveMessage(&command); + if (result != RETURN_OK) { + return; + } - result = poolManager.handleHousekeepingMessage(&command); - if (result == RETURN_OK) { - return; - } + result = poolManager.handleHousekeepingMessage(&command); + if (result == RETURN_OK) { + return; + } } -MessageQueueId_t PCDUHandler::getCommandQueue() const { - return commandQueue->getId(); -} +MessageQueueId_t PCDUHandler::getCommandQueue() const { return commandQueue->getId(); } void PCDUHandler::handleChangedDataset(sid_t sid, store_address_t storeId) { - - if (sid == sid_t(objects::PDU2_HANDLER, PDU2::HK_TABLE_DATA_SET_ID)) { - updateHkTableDataset(storeId, &pdu2HkTableDataset, &timeStampPdu2HkDataset); - updatePdu2SwitchStates(); - } - else if (sid == sid_t(objects::PDU1_HANDLER, PDU1::HK_TABLE_DATA_SET_ID)) { - updateHkTableDataset(storeId, &pdu1HkTableDataset, &timeStampPdu1HkDataset); - updatePdu1SwitchStates(); - } - else { - sif::error << "PCDUHandler::handleChangedDataset: Invalid sid" << std::endl; - } + if (sid == sid_t(objects::PDU2_HANDLER, PDU2::HK_TABLE_DATA_SET_ID)) { + updateHkTableDataset(storeId, &pdu2HkTableDataset, &timeStampPdu2HkDataset); + updatePdu2SwitchStates(); + } else if (sid == sid_t(objects::PDU1_HANDLER, PDU1::HK_TABLE_DATA_SET_ID)) { + updateHkTableDataset(storeId, &pdu1HkTableDataset, &timeStampPdu1HkDataset); + updatePdu1SwitchStates(); + } else { + sif::error << "PCDUHandler::handleChangedDataset: Invalid sid" << std::endl; + } } -void PCDUHandler::updateHkTableDataset(store_address_t storeId, - LocalPoolDataSetBase* dataset, CCSDSTime::CDS_short* datasetTimeStamp) { - ReturnValue_t result; +void PCDUHandler::updateHkTableDataset(store_address_t storeId, LocalPoolDataSetBase* dataset, + CCSDSTime::CDS_short* datasetTimeStamp) { + ReturnValue_t result; - HousekeepingSnapshot packetUpdate(reinterpret_cast(datasetTimeStamp), - sizeof(CCSDSTime::CDS_short), dataset); - const uint8_t* packet_ptr = NULL; - size_t size; - result = IPCStore->getData(storeId, &packet_ptr, &size); - if (result != RETURN_OK) { - sif::error << "PCDUHandler::updateHkTableDataset: Failed to get data from IPCStore." - << std::endl; - } - dataset->read(); - result = packetUpdate.deSerialize(&packet_ptr, &size, SerializeIF::Endianness::MACHINE); - if (result != RETURN_OK) { - sif::error << "PCDUHandler::updateHkTableDataset: Failed to deserialize received packet " - "in hk table dataset"<< std::endl; - } - dataset->commit(); - result = IPCStore->deleteData(storeId); - if (result != RETURN_OK) { - sif::error << "PCDUHandler::updateHkTableDataset: Failed to delete data in IPCStore" - << std::endl; - } + HousekeepingSnapshot packetUpdate(reinterpret_cast(datasetTimeStamp), + sizeof(CCSDSTime::CDS_short), dataset); + const uint8_t* packet_ptr = NULL; + size_t size; + result = IPCStore->getData(storeId, &packet_ptr, &size); + if (result != RETURN_OK) { + sif::error << "PCDUHandler::updateHkTableDataset: Failed to get data from IPCStore." + << std::endl; + } + dataset->read(); + result = packetUpdate.deSerialize(&packet_ptr, &size, SerializeIF::Endianness::MACHINE); + if (result != RETURN_OK) { + sif::error << "PCDUHandler::updateHkTableDataset: Failed to deserialize received packet " + "in hk table dataset" + << std::endl; + } + dataset->commit(); + result = IPCStore->deleteData(storeId); + if (result != RETURN_OK) { + sif::error << "PCDUHandler::updateHkTableDataset: Failed to delete data in IPCStore" + << std::endl; + } } void PCDUHandler::updatePdu2SwitchStates() { - //TODO: pool read helper - if (pdu2HkTableDataset.read() == RETURN_OK) { - switchStates[pcduSwitches::Q7S] = pdu2HkTableDataset.outEnabledQ7S.value; - switchStates[pcduSwitches::PAYLOAD_PCDU_CH1] = pdu2HkTableDataset.outEnabledPlPCDUCh1.value; - switchStates[pcduSwitches::RW] = pdu2HkTableDataset.outEnabledReactionWheels.value; - switchStates[pcduSwitches::TCS_BOARD_8V_HEATER_IN] = pdu2HkTableDataset.outEnabledTCSBoardHeaterIn.value; - switchStates[pcduSwitches::SUS_REDUNDANT] = pdu2HkTableDataset.outEnabledSUSRedundant.value; - switchStates[pcduSwitches::DEPLOYMENT_MECHANISM] = pdu2HkTableDataset.outEnabledDeplMechanism.value; - switchStates[pcduSwitches::PAYLOAD_PCDU_CH6] = pdu2HkTableDataset.outEnabledPlPCDUCh6.value; - switchStates[pcduSwitches::ACS_BOARD_SIDE_B] = pdu2HkTableDataset.outEnabledAcsBoardSideB.value; - switchStates[pcduSwitches::PAYLOAD_CAMERA] = pdu2HkTableDataset.outEnabledPayloadCamera.value; - } - else { - sif::debug << "PCDUHandler::updatePdu2SwitchStates: Failed to read PDU2 Hk Dataset" - << std::endl; - } - pdu2HkTableDataset.commit(); + // TODO: pool read helper + if (pdu2HkTableDataset.read() == RETURN_OK) { + switchStates[pcduSwitches::Q7S] = pdu2HkTableDataset.outEnabledQ7S.value; + switchStates[pcduSwitches::PAYLOAD_PCDU_CH1] = pdu2HkTableDataset.outEnabledPlPCDUCh1.value; + switchStates[pcduSwitches::RW] = pdu2HkTableDataset.outEnabledReactionWheels.value; + switchStates[pcduSwitches::TCS_BOARD_8V_HEATER_IN] = + pdu2HkTableDataset.outEnabledTCSBoardHeaterIn.value; + switchStates[pcduSwitches::SUS_REDUNDANT] = pdu2HkTableDataset.outEnabledSUSRedundant.value; + switchStates[pcduSwitches::DEPLOYMENT_MECHANISM] = + pdu2HkTableDataset.outEnabledDeplMechanism.value; + switchStates[pcduSwitches::PAYLOAD_PCDU_CH6] = pdu2HkTableDataset.outEnabledPlPCDUCh6.value; + switchStates[pcduSwitches::ACS_BOARD_SIDE_B] = pdu2HkTableDataset.outEnabledAcsBoardSideB.value; + switchStates[pcduSwitches::PAYLOAD_CAMERA] = pdu2HkTableDataset.outEnabledPayloadCamera.value; + } else { + sif::debug << "PCDUHandler::updatePdu2SwitchStates: Failed to read PDU2 Hk Dataset" + << std::endl; + } + pdu2HkTableDataset.commit(); } void PCDUHandler::updatePdu1SwitchStates() { - if (pdu1HkTableDataset.read() == RETURN_OK) { - switchStates[pcduSwitches::TCS_BOARD_3V3] = pdu1HkTableDataset.voltageOutTCSBoard3V3.value; - switchStates[pcduSwitches::SYRLINKS] = pdu1HkTableDataset.voltageOutSyrlinks.value; - switchStates[pcduSwitches::STAR_TRACKER] = pdu1HkTableDataset.voltageOutStarTracker.value; - switchStates[pcduSwitches::MGT] = pdu1HkTableDataset.voltageOutMGT.value; - switchStates[pcduSwitches::SUS_NOMINAL] = pdu1HkTableDataset.voltageOutSUSNominal.value; - switchStates[pcduSwitches::SOLAR_CELL_EXP] = pdu1HkTableDataset.voltageOutSolarCellExp.value; - switchStates[pcduSwitches::PLOC] = pdu1HkTableDataset.voltageOutPLOC.value; - switchStates[pcduSwitches::ACS_BOARD_SIDE_A] = pdu1HkTableDataset.voltageOutACSBoardSideA.value; - } - else { - sif::debug << "PCDUHandler::updatePdu1SwitchStates: Failed to read dataset" << std::endl; - } - pdu1HkTableDataset.commit(); + if (pdu1HkTableDataset.read() == RETURN_OK) { + switchStates[pcduSwitches::TCS_BOARD_3V3] = pdu1HkTableDataset.voltageOutTCSBoard3V3.value; + switchStates[pcduSwitches::SYRLINKS] = pdu1HkTableDataset.voltageOutSyrlinks.value; + switchStates[pcduSwitches::STAR_TRACKER] = pdu1HkTableDataset.voltageOutStarTracker.value; + switchStates[pcduSwitches::MGT] = pdu1HkTableDataset.voltageOutMGT.value; + switchStates[pcduSwitches::SUS_NOMINAL] = pdu1HkTableDataset.voltageOutSUSNominal.value; + switchStates[pcduSwitches::SOLAR_CELL_EXP] = pdu1HkTableDataset.voltageOutSolarCellExp.value; + switchStates[pcduSwitches::PLOC] = pdu1HkTableDataset.voltageOutPLOC.value; + switchStates[pcduSwitches::ACS_BOARD_SIDE_A] = pdu1HkTableDataset.voltageOutACSBoardSideA.value; + } else { + sif::debug << "PCDUHandler::updatePdu1SwitchStates: Failed to read dataset" << std::endl; + } + pdu1HkTableDataset.commit(); } -LocalDataPoolManager* PCDUHandler::getHkManagerHandle() { - return &poolManager; -} +LocalDataPoolManager* PCDUHandler::getHkManagerHandle() { return &poolManager; } void PCDUHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const { + ReturnValue_t result; + uint16_t memoryAddress; + size_t parameterValueSize = sizeof(uint8_t); + uint8_t parameterValue; + GomspaceDeviceHandler* pdu; - ReturnValue_t result; - uint16_t memoryAddress; - size_t parameterValueSize = sizeof(uint8_t); - uint8_t parameterValue; - GomspaceDeviceHandler* pdu; - - switch (switchNr) { + switch (switchNr) { case pcduSwitches::TCS_BOARD_8V_HEATER_IN: - memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_TCS_BOARD_HEATER_IN; - pdu = ObjectManager::instance()->get(objects::PDU2_HANDLER); - break; + memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_TCS_BOARD_HEATER_IN; + pdu = ObjectManager::instance()->get(objects::PDU2_HANDLER); + break; case pcduSwitches::DEPLOYMENT_MECHANISM: - memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_DEPLOYMENT_MECHANISM; - pdu = ObjectManager::instance()->get(objects::PDU2_HANDLER); - break; + memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_DEPLOYMENT_MECHANISM; + pdu = ObjectManager::instance()->get(objects::PDU2_HANDLER); + break; default: - sif::error << "PCDUHandler::sendSwitchCommand: Invalid switch number " << std::endl; - return; - } + sif::error << "PCDUHandler::sendSwitchCommand: Invalid switch number " << std::endl; + return; + } - switch (onOff) { + switch (onOff) { case PowerSwitchIF::SWITCH_ON: - parameterValue = 1; - break; + parameterValue = 1; + break; case PowerSwitchIF::SWITCH_OFF: - parameterValue = 0; - break; + parameterValue = 0; + break; default: - sif::error << "PCDUHandler::sendSwitchCommand: Invalid state commanded" << std::endl; - return; - } + sif::error << "PCDUHandler::sendSwitchCommand: Invalid state commanded" << std::endl; + return; + } - GomspaceSetParamMessage setParamMessage(memoryAddress, ¶meterValue, parameterValueSize); + GomspaceSetParamMessage setParamMessage(memoryAddress, ¶meterValue, parameterValueSize); - size_t serializedLength = 0; - uint8_t command[4]; - uint8_t* commandPtr = command; - size_t maxSize = sizeof(command); - setParamMessage.serialize(&commandPtr, &serializedLength, maxSize, - SerializeIF::Endianness::BIG); + size_t serializedLength = 0; + uint8_t command[4]; + uint8_t* commandPtr = command; + size_t maxSize = sizeof(command); + setParamMessage.serialize(&commandPtr, &serializedLength, maxSize, SerializeIF::Endianness::BIG); - store_address_t storeAddress; - result = IPCStore->addData(&storeAddress, command,sizeof(command)); + store_address_t storeAddress; + result = IPCStore->addData(&storeAddress, command, sizeof(command)); - CommandMessage message; - ActionMessage::setCommand(&message, GOMSPACE::PARAM_SET, storeAddress); + CommandMessage message; + ActionMessage::setCommand(&message, GOMSPACE::PARAM_SET, storeAddress); - result = commandQueue->sendMessage(pdu->getCommandQueue(), &message, 0); - if (result != RETURN_OK) { - sif::debug << "PCDUHandler::sendSwitchCommand: Failed to send message to PDU Handler" - << std::endl; - } + result = commandQueue->sendMessage(pdu->getCommandQueue(), &message, 0); + if (result != RETURN_OK) { + sif::debug << "PCDUHandler::sendSwitchCommand: Failed to send message to PDU Handler" + << std::endl; + } } -void PCDUHandler::sendFuseOnCommand(uint8_t fuseNr) const { +void PCDUHandler::sendFuseOnCommand(uint8_t fuseNr) const {} +ReturnValue_t PCDUHandler::getSwitchState(uint8_t switchNr) const { + if (switchNr >= pcduSwitches::NUMBER_OF_SWITCHES) { + sif::debug << "PCDUHandler::getSwitchState: Invalid switch number" << std::endl; + return RETURN_FAILED; + } + if (switchStates[switchNr] == 1) { + return PowerSwitchIF::SWITCH_ON; + } else { + return PowerSwitchIF::SWITCH_OFF; + } } -ReturnValue_t PCDUHandler::getSwitchState( uint8_t switchNr ) const { - if (switchNr >= pcduSwitches::NUMBER_OF_SWITCHES) { - sif::debug << "PCDUHandler::getSwitchState: Invalid switch number" << std::endl; - return RETURN_FAILED; - } - if (switchStates[switchNr] == 1) { - return PowerSwitchIF::SWITCH_ON; - } - else { - return PowerSwitchIF::SWITCH_OFF; - } -} +ReturnValue_t PCDUHandler::getFuseState(uint8_t fuseNr) const { return RETURN_OK; } -ReturnValue_t PCDUHandler::getFuseState( uint8_t fuseNr ) const { - return RETURN_OK; -} +uint32_t PCDUHandler::getSwitchDelayMs(void) const { return 20000; } -uint32_t PCDUHandler::getSwitchDelayMs(void) const { - return 20000; -} +object_id_t PCDUHandler::getObjectId() const { return SystemObject::getObjectId(); } -object_id_t PCDUHandler::getObjectId() const { - return SystemObject::getObjectId(); -} +ReturnValue_t PCDUHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) { + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_Q7S, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_RW, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_SUS_REDUNDANT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, new PoolEntry({0})); -ReturnValue_t PCDUHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_Q7S, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_RW, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_Q7S, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_RW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_SUS_REDUNDANT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CONV_EN_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CONV_EN_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CONV_EN_3, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_Q7S, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_RW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, new PoolEntry( { 0 })); - - localDataPoolMap.emplace(P60System::PDU2_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CONV_EN_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CONV_EN_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CONV_EN_3, new PoolEntry( { 0 })); - - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_Q7S, new PoolEntry( { - pcduSwitches::INIT_STATE_Q7S })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, new PoolEntry( { - pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH1 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_RW, new PoolEntry( { - pcduSwitches::INIT_STATE_RW })); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_Q7S, + new PoolEntry({pcduSwitches::INIT_STATE_Q7S})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, + new PoolEntry({pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH1})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_RW, + new PoolEntry({pcduSwitches::INIT_STATE_RW})); #if BOARD_TE0720 == 1 - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry( { 1 })); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry({1})); #else - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry( {pcduSwitches::INIT_STATE_TCS_BOARD_8V_HEATER_IN})); + localDataPoolMap.emplace( + P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, + new PoolEntry({pcduSwitches::INIT_STATE_TCS_BOARD_8V_HEATER_IN})); #endif - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_SUS_REDUNDANT, new PoolEntry( { - pcduSwitches::INIT_STATE_SUS_REDUNDANT })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_DEPLOYMENT_MECHANISM, new PoolEntry( { - pcduSwitches::INIT_STATE_DEPLOYMENT_MECHANISM })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH6, new PoolEntry( { - pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH6 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_ACS_BOARD_SIDE_B, new PoolEntry( { - pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_B })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_CAMERA, new PoolEntry( { - pcduSwitches::INIT_STATE_PAYLOAD_CAMERA })); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_SUS_REDUNDANT, + new PoolEntry({pcduSwitches::INIT_STATE_SUS_REDUNDANT})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_DEPLOYMENT_MECHANISM, + new PoolEntry({pcduSwitches::INIT_STATE_DEPLOYMENT_MECHANISM})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH6, + new PoolEntry({pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH6})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_ACS_BOARD_SIDE_B, + new PoolEntry({pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_B})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_CAMERA, + new PoolEntry({pcduSwitches::INIT_STATE_PAYLOAD_CAMERA})); - localDataPoolMap.emplace(P60System::PDU2_BOOTCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_BOOTCNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_UPTIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_RESETCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_BATT_MODE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_BOOTCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_BOOTCNT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_RESETCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_BATT_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_Q7S, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_RW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_SUS_REDUNDANT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_DEPLOYMENT_MECHANISM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_ACS_BOARD_SIDE_B, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_CAMERA, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_Q7S, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_RW, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_SUS_REDUNDANT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_DEPLOYMENT_MECHANISM, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_ACS_BOARD_SIDE_B, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_CAMERA, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_5, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_7, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_0_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_1_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_2_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_3_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_4_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_5_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_6_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_7_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_0_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_1_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_2_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_3_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_4_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_5_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_6_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_7_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_GND, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_I2C, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CAN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_GND_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_I2C_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CAN_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_GND, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_I2C, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CAN, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_GND_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_I2C_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CAN_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CONV_EN_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CONV_EN_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CONV_EN_3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CONV_EN_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CONV_EN_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CONV_EN_3, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_ACS_BOARD_SIDE_A, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_BOOTCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_BOOTCNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_UPTIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_RESETCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_BATT_MODE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_BOOTCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_BOOTCNT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_RESETCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_BATT_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_ACS_BOARD_SIDE_A, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_5, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_7, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_0_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_1_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_2_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_3_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_4_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_5_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_6_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_7_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_0_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_1_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_2_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_3_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_4_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_5_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_6_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_7_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_GND, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_I2C, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CAN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_GND_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_I2C_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CAN_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_GND, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_I2C, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CAN, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_GND_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_I2C_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CAN_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT2, new PoolEntry({0})); - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t PCDUHandler::initializeAfterTaskCreation() { + if (executingTask != nullptr) { + pstIntervalMs = executingTask->getPeriodMs(); + } + this->poolManager.initializeAfterTaskCreation(); - if(executingTask != nullptr) { - pstIntervalMs = executingTask->getPeriodMs(); - } - this->poolManager.initializeAfterTaskCreation(); + initializeSwitchStates(); - initializeSwitchStates(); - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } -uint32_t PCDUHandler::getPeriodicOperationFrequency() const { - return pstIntervalMs; -} +uint32_t PCDUHandler::getPeriodicOperationFrequency() const { return pstIntervalMs; } -void PCDUHandler::setTaskIF(PeriodicTaskIF* task){ - executingTask = task; -} +void PCDUHandler::setTaskIF(PeriodicTaskIF* task) { executingTask = task; } LocalPoolDataSetBase* PCDUHandler::getDataSetHandle(sid_t sid) { - if (sid == pdu2HkTableDataset.getSid()) { - return &pdu2HkTableDataset; - } else { - sif::error << "PCDUHandler::getDataSetHandle: Invalid sid" << std::endl; - return nullptr; - } + if (sid == pdu2HkTableDataset.getSid()) { + return &pdu2HkTableDataset; + } else { + sif::error << "PCDUHandler::getDataSetHandle: Invalid sid" << std::endl; + return nullptr; + } } diff --git a/mission/devices/PCDUHandler.h b/mission/devices/PCDUHandler.h index 566e1d9c..c045ed03 100644 --- a/mission/devices/PCDUHandler.h +++ b/mission/devices/PCDUHandler.h @@ -2,120 +2,116 @@ #define MISSION_DEVICES_PCDUHANDLER_H_ #include -#include -#include -#include -#include #include #include +#include #include -#include - +#include +#include +#include /** * @brief The PCDUHandler provides a compact interface to handle all devices related to the - * control of power. This is necessary because the fsfw manages all power related - * functionalities via one power object. This includes for example the switch on and off - * of devices. + * control of power. This is necessary because the fsfw manages all power + * related functionalities via one power object. This includes for example the switch on and off of + * devices. */ -class PCDUHandler: public PowerSwitchIF, - public HasLocalDataPoolIF, - public SystemObject, - public ExecutableObjectIF { -public: +class PCDUHandler : public PowerSwitchIF, + public HasLocalDataPoolIF, + public SystemObject, + public ExecutableObjectIF { + public: + PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize = 20); + virtual ~PCDUHandler(); - PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize = 20); - virtual ~PCDUHandler(); + virtual ReturnValue_t initialize() override; + virtual ReturnValue_t performOperation(uint8_t counter) override; + virtual void handleChangedDataset(sid_t sid, + store_address_t storeId = storeId::INVALID_STORE_ADDRESS); - virtual ReturnValue_t initialize() override; - virtual ReturnValue_t performOperation(uint8_t counter) override; - virtual void handleChangedDataset(sid_t sid, store_address_t storeId = - storeId::INVALID_STORE_ADDRESS); + virtual void sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const override; + virtual void sendFuseOnCommand(uint8_t fuseNr) const override; + virtual ReturnValue_t getSwitchState(uint8_t switchNr) const override; + virtual ReturnValue_t getFuseState(uint8_t fuseNr) const override; + virtual uint32_t getSwitchDelayMs(void) const override; + virtual object_id_t getObjectId() const override; + virtual LocalDataPoolManager* getHkManagerHandle() override; - virtual void sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const override; - virtual void sendFuseOnCommand(uint8_t fuseNr) const override; - virtual ReturnValue_t getSwitchState( uint8_t switchNr ) const override; - virtual ReturnValue_t getFuseState( uint8_t fuseNr ) const override; - virtual uint32_t getSwitchDelayMs(void) const override; - virtual object_id_t getObjectId() const override; - virtual LocalDataPoolManager* getHkManagerHandle() override; + virtual MessageQueueId_t getCommandQueue() const override; + virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; + virtual uint32_t getPeriodicOperationFrequency() const override; + virtual ReturnValue_t initializeAfterTaskCreation() override; + virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + virtual void setTaskIF(PeriodicTaskIF* task_); - virtual MessageQueueId_t getCommandQueue() const override; - virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; - virtual uint32_t getPeriodicOperationFrequency() const override; - virtual ReturnValue_t initializeAfterTaskCreation() override; - virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; - virtual void setTaskIF(PeriodicTaskIF* task_); + private: + uint32_t pstIntervalMs = 0; -private: + /** Housekeeping manager. Handles updates of local pool variables. */ + LocalDataPoolManager poolManager; - uint32_t pstIntervalMs = 0; + /** + * The dataset holding the hk table of PDU2. This dataset is a copy of the PDU2 HK dataset + * of the PDU2Handler. Each time the PDU2Handler updates his HK dataset, a copy is sent + * to this object via a HousekeepingMessage. + */ + PDU2::PDU2HkTableDataset pdu2HkTableDataset; + /** The timeStamp of the current pdu2HkTableDataset */ + CCSDSTime::CDS_short timeStampPdu2HkDataset; - /** Housekeeping manager. Handles updates of local pool variables. */ - LocalDataPoolManager poolManager; + /** Hk table dataset of PDU1 */ + PDU1::PDU1HkTableDataset pdu1HkTableDataset; + /** The timeStamp of the current pdu1HkTableDataset */ + CCSDSTime::CDS_short timeStampPdu1HkDataset; - /** - * The dataset holding the hk table of PDU2. This dataset is a copy of the PDU2 HK dataset - * of the PDU2Handler. Each time the PDU2Handler updates his HK dataset, a copy is sent - * to this object via a HousekeepingMessage. - */ - PDU2::PDU2HkTableDataset pdu2HkTableDataset; - /** The timeStamp of the current pdu2HkTableDataset */ - CCSDSTime::CDS_short timeStampPdu2HkDataset; + uint8_t switchStates[pcduSwitches::NUMBER_OF_SWITCHES]; + /** + * Pointer to the IPCStore. + * This caches the pointer received from the objectManager in the constructor. + */ + StorageManagerIF* IPCStore = nullptr; - /** Hk table dataset of PDU1 */ - PDU1::PDU1HkTableDataset pdu1HkTableDataset; - /** The timeStamp of the current pdu1HkTableDataset */ - CCSDSTime::CDS_short timeStampPdu1HkDataset; + /** + * Message queue to communicate with other objetcs. Used for example to receive + * local pool messages from ACU, PDU1 and PDU2. + */ + MessageQueueIF* commandQueue = nullptr; - uint8_t switchStates[pcduSwitches::NUMBER_OF_SWITCHES]; - /** - * Pointer to the IPCStore. - * This caches the pointer received from the objectManager in the constructor. - */ - StorageManagerIF *IPCStore = nullptr; + size_t cmdQueueSize; - /** - * Message queue to communicate with other objetcs. Used for example to receive - * local pool messages from ACU, PDU1 and PDU2. - */ - MessageQueueIF* commandQueue = nullptr; + PeriodicTaskIF* executingTask = nullptr; - size_t cmdQueueSize; + void readCommandQueue(); - PeriodicTaskIF* executingTask = nullptr; + /** + * @brief This function sets all switchStates to the initial switch configuration of the + * two PDUs after reboot. + */ + void initializeSwitchStates(); - void readCommandQueue(); + /** + * @brief Updates all switchStates related to the PDU2. + * Function is called each time a new hk dataset has been received from the PDU2Handler. + */ + void updatePdu2SwitchStates(); - /** - * @brief This function sets all switchStates to the initial switch configuration of the - * two PDUs after reboot. - */ - void initializeSwitchStates(); + /** + * @brief Updates all switchStates related to the PDU1. Called each time the PDU1Handler + * sends a new hk dataset. + */ + void updatePdu1SwitchStates(); - /** - * @brief Updates all switchStates related to the PDU2. - * Function is called each time a new hk dataset has been received from the PDU2Handler. - */ - void updatePdu2SwitchStates(); - - /** - * @brief Updates all switchStates related to the PDU1. Called each time the PDU1Handler - * sends a new hk dataset. - */ - void updatePdu1SwitchStates(); - - /** - * @brief In case of an update snapshot message this function handles the update of the - * local dataset. - * @param storeId Storage id of updated dataset. - * @param dataset Pointer to the local dataset. - * @param datasetTimeStamp Pointer to a variable which will hold the timestamp of the updated - * dataset. - */ - void updateHkTableDataset(store_address_t storeId, LocalPoolDataSetBase* dataset, - CCSDSTime::CDS_short* datasetTimeStamp); + /** + * @brief In case of an update snapshot message this function handles the update of the + * local dataset. + * @param storeId Storage id of updated dataset. + * @param dataset Pointer to the local dataset. + * @param datasetTimeStamp Pointer to a variable which will hold the timestamp of the updated + * dataset. + */ + void updateHkTableDataset(store_address_t storeId, LocalPoolDataSetBase* dataset, + CCSDSTime::CDS_short* datasetTimeStamp); }; #endif /* MISSION_DEVICES_PCDUHANDLER_H_ */ diff --git a/mission/devices/PDU1Handler.cpp b/mission/devices/PDU1Handler.cpp index 1676e488..a1486588 100644 --- a/mission/devices/PDU1Handler.cpp +++ b/mission/devices/PDU1Handler.cpp @@ -1,402 +1,421 @@ -#include "OBSWConfig.h" #include "PDU1Handler.h" #include -PDU1Handler::PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - GomspaceDeviceHandler(objectId, comIF, comCookie, PDU::MAX_CONFIGTABLE_ADDRESS, - PDU::MAX_HKTABLE_ADDRESS, PDU::HK_TABLE_REPLY_SIZE, &pdu1HkTableDataset), - pdu1HkTableDataset(this) { -} +#include "OBSWConfig.h" -PDU1Handler::~PDU1Handler() { -} +PDU1Handler::PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie) + : GomspaceDeviceHandler(objectId, comIF, comCookie, PDU::MAX_CONFIGTABLE_ADDRESS, + PDU::MAX_HKTABLE_ADDRESS, PDU::HK_TABLE_REPLY_SIZE, + &pdu1HkTableDataset), + pdu1HkTableDataset(this) {} -ReturnValue_t PDU1Handler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - *id = GOMSPACE::REQUEST_HK_TABLE; - return buildCommandFromCommand(*id, NULL, 0); +PDU1Handler::~PDU1Handler() {} + +ReturnValue_t PDU1Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + *id = GOMSPACE::REQUEST_HK_TABLE; + return buildCommandFromCommand(*id, NULL, 0); } void PDU1Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) { - - parseHkTableReply(packet); - handleDeviceTM(&pdu1HkTableDataset, id, true); + parseHkTableReply(packet); + handleDeviceTM(&pdu1HkTableDataset, id, true); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PDU1 == 1 - pdu1HkTableDataset.read(); - sif::info << "PDU1 TCS Board voltage: " << pdu1HkTableDataset.voltageOutTCSBoard3V3 + pdu1HkTableDataset.read(); + sif::info << "PDU1 TCS Board voltage: " << pdu1HkTableDataset.voltageOutTCSBoard3V3 << std::endl; + sif::info << "PDU1 Syrlinks voltage: " << pdu1HkTableDataset.voltageOutSyrlinks << std::endl; + sif::info << "PDU1 star tracker voltage: " << pdu1HkTableDataset.voltageOutStarTracker << std::endl; - sif::info << "PDU1 Syrlinks voltage: " << pdu1HkTableDataset.voltageOutSyrlinks << std::endl; - sif::info << "PDU1 star tracker voltage: " << pdu1HkTableDataset.voltageOutStarTracker + sif::info << "PDU1 MGT voltage: " << pdu1HkTableDataset.voltageOutMGT << std::endl; + sif::info << "PDU1 SUS nominal voltage: " << pdu1HkTableDataset.voltageOutSUSNominal << std::endl; + sif::info << "PDU1 solar cell experiment voltage: " << pdu1HkTableDataset.voltageOutSolarCellExp << std::endl; - sif::info << "PDU1 MGT voltage: " << pdu1HkTableDataset.voltageOutMGT << std::endl; - sif::info << "PDU1 SUS nominal voltage: " << pdu1HkTableDataset.voltageOutSUSNominal + sif::info << "PDU1 PLOC voltage: " << pdu1HkTableDataset.voltageOutPLOC << std::endl; + sif::info << "PDU1 ACS Side A voltage: " << pdu1HkTableDataset.voltageOutACSBoardSideA << std::endl; - sif::info << "PDU1 solar cell experiment voltage: " << pdu1HkTableDataset.voltageOutSolarCellExp - << std::endl; - sif::info << "PDU1 PLOC voltage: " << pdu1HkTableDataset.voltageOutPLOC << std::endl; - sif::info << "PDU1 ACS Side A voltage: " << pdu1HkTableDataset.voltageOutACSBoardSideA - << std::endl; - sif::info << "PDU1 channel 8 voltage: " << pdu1HkTableDataset.voltageOutACSBoardSideA + sif::info << "PDU1 channel 8 voltage: " << pdu1HkTableDataset.voltageOutACSBoardSideA << std::endl; - sif::info << "PDU1 TCS Board current: " << pdu1HkTableDataset.currentOutTCSBoard3V3 + sif::info << "PDU1 TCS Board current: " << pdu1HkTableDataset.currentOutTCSBoard3V3 << std::endl; + sif::info << "PDU1 Syrlinks current: " << pdu1HkTableDataset.currentOutSyrlinks << std::endl; + sif::info << "PDU1 star tracker current: " << pdu1HkTableDataset.currentOutStarTracker << std::endl; - sif::info << "PDU1 Syrlinks current: " << pdu1HkTableDataset.currentOutSyrlinks << std::endl; - sif::info << "PDU1 star tracker current: " << pdu1HkTableDataset.currentOutStarTracker + sif::info << "PDU1 MGT current: " << pdu1HkTableDataset.currentOutMGT << std::endl; + sif::info << "PDU1 SUS nominal current: " << pdu1HkTableDataset.currentOutSUSNominal << std::endl; + sif::info << "PDU1 solar cell experiment current: " << pdu1HkTableDataset.currentOutSolarCellExp << std::endl; - sif::info << "PDU1 MGT current: " << pdu1HkTableDataset.currentOutMGT << std::endl; - sif::info << "PDU1 SUS nominal current: " << pdu1HkTableDataset.currentOutSUSNominal + sif::info << "PDU1 PLOC current: " << pdu1HkTableDataset.currentOutPLOC << std::endl; + sif::info << "PDU1 ACS Side A current: " << pdu1HkTableDataset.currentOutACSBoardSideA << std::endl; - sif::info << "PDU1 solar cell experiment current: " << pdu1HkTableDataset.currentOutSolarCellExp + sif::info << "PDU1 channel 8 current: " << pdu1HkTableDataset.currentOutChannel8 << std::endl; + printOutputSwitchStates(); + sif::info << "PDU1 battery mode: " << static_cast(pdu1HkTableDataset.battMode.value) << std::endl; - sif::info << "PDU1 PLOC current: " << pdu1HkTableDataset.currentOutPLOC << std::endl; - sif::info << "PDU1 ACS Side A current: " << pdu1HkTableDataset.currentOutACSBoardSideA + sif::info << "PDU1 VCC: " << pdu1HkTableDataset.vcc << " mV" << std::endl; + float vbat = pdu1HkTableDataset.vbat.value * 0.001; + sif::info << "PDU1 VBAT: " << vbat << "V" << std::endl; + float temperatureC = pdu1HkTableDataset.temperature.value * 0.1; + sif::info << "PDU1 Temperature: " << temperatureC << " °C" << std::endl; + sif::info << "PDU1 csp1 watchdog pings before reboot: " + << static_cast(pdu1HkTableDataset.csp1WatchdogPingsLeft.value) << std::endl; - sif::info << "PDU1 channel 8 current: " << pdu1HkTableDataset.currentOutChannel8 + sif::info << "PDU1 csp2 watchdog pings before reboot: " + << static_cast(pdu1HkTableDataset.csp2WatchdogPingsLeft.value) << std::endl; - printOutputSwitchStates(); - sif::info << "PDU1 battery mode: " << - static_cast(pdu1HkTableDataset.battMode.value) << std::endl; - sif::info << "PDU1 VCC: " << pdu1HkTableDataset.vcc << " mV" << std::endl; - float vbat = pdu1HkTableDataset.vbat.value * 0.001; - sif::info << "PDU1 VBAT: " << vbat << "V" << std::endl; - float temperatureC = pdu1HkTableDataset.temperature.value * 0.1; - sif::info << "PDU1 Temperature: " << temperatureC << " °C" << std::endl; - sif::info << "PDU1 csp1 watchdog pings before reboot: " - << static_cast(pdu1HkTableDataset.csp1WatchdogPingsLeft.value) << std::endl; - sif::info << "PDU1 csp2 watchdog pings before reboot: " - << static_cast(pdu1HkTableDataset.csp2WatchdogPingsLeft.value) << std::endl; - pdu1HkTableDataset.commit(); + pdu1HkTableDataset.commit(); #endif } void PDU1Handler::parseHkTableReply(const uint8_t *packet) { - uint16_t dataOffset = 0; - PoolReadGuard pg(&pdu1HkTableDataset); - ReturnValue_t readResult = pg.getReadResult(); - if(readResult != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Reading PDU1 HK table failed!" << std::endl; - return; - } - /* Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table - * address. */ - dataOffset += 12; - pdu1HkTableDataset.currentOutTCSBoard3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutStarTracker = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutMGT = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutSUSNominal = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutSolarCellExp = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutPLOC = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutACSBoardSideA = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + uint16_t dataOffset = 0; + PoolReadGuard pg(&pdu1HkTableDataset); + ReturnValue_t readResult = pg.getReadResult(); + if (readResult != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Reading PDU1 HK table failed!" << std::endl; + return; + } + /* Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table + * address. */ + dataOffset += 12; + pdu1HkTableDataset.currentOutTCSBoard3V3 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutStarTracker = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutMGT = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutSUSNominal = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutSolarCellExp = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutPLOC = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutACSBoardSideA = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu1HkTableDataset.voltageOutTCSBoard3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutStarTracker = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutMGT = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutSUSNominal = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutSolarCellExp = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutPLOC = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutACSBoardSideA = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + pdu1HkTableDataset.voltageOutTCSBoard3V3 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutStarTracker = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutMGT = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutSUSNominal = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutSolarCellExp = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutPLOC = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutACSBoardSideA = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu1HkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.temperature = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + pdu1HkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.temperature = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu1HkTableDataset.converterEnable1 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.converterEnable2 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.converterEnable3 = *(packet + dataOffset); - dataOffset += 3; + pdu1HkTableDataset.converterEnable1 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.converterEnable2 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.converterEnable3 = *(packet + dataOffset); + dataOffset += 3; - pdu1HkTableDataset.outEnabledTCSBoard3V3 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledSyrlinks = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledStarTracker = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledMGT = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledSUSNominal = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledSolarCellExp = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledPLOC = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledAcsBoardSideA = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledChannel8 = *(packet + dataOffset); - dataOffset += 3; + pdu1HkTableDataset.outEnabledTCSBoard3V3 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledSyrlinks = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledStarTracker = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledMGT = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledSUSNominal = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledSolarCellExp = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledPLOC = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledAcsBoardSideA = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledChannel8 = *(packet + dataOffset); + dataOffset += 3; - pdu1HkTableDataset.bootcause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.bootcount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.resetcause = *(packet + dataOffset + 1) << 8 | *(packet + dataOffset); - dataOffset += 4; - pdu1HkTableDataset.battMode = *(packet + dataOffset); - /* +10 because here begins the second gomspace csp packet */ - dataOffset += 3 + 10; + pdu1HkTableDataset.bootcause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.bootcount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.resetcause = *(packet + dataOffset + 1) << 8 | *(packet + dataOffset); + dataOffset += 4; + pdu1HkTableDataset.battMode = *(packet + dataOffset); + /* +10 because here begins the second gomspace csp packet */ + dataOffset += 3 + 10; - pdu1HkTableDataset.latchupsTcsBoard3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsStarTracker = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsMgt = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsSusNominal = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsSolarCellExp = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsPloc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsAcsBoardSideA = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + pdu1HkTableDataset.latchupsTcsBoard3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsStarTracker = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsMgt = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsSusNominal = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsSolarCellExp = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsPloc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsAcsBoardSideA = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu1HkTableDataset.device0 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device1 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device2 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device3 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device4 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device5 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device6 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device7 = *(packet + dataOffset); - dataOffset += 3; + pdu1HkTableDataset.device0 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device1 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device2 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device3 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device4 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device5 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device6 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device7 = *(packet + dataOffset); + dataOffset += 3; - pdu1HkTableDataset.device0Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device1Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device2Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device3Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device4Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device5Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device6Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device7Status = *(packet + dataOffset); - dataOffset += 3; + pdu1HkTableDataset.device0Status = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device1Status = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device2Status = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device3Status = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device4Status = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device5Status = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device6Status = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device7Status = *(packet + dataOffset); + dataOffset += 3; - pdu1HkTableDataset.gndWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.i2cWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.canWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.csp1WdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.csp2WdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.groundWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.i2cWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.canWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.csp1WatchdogPingsLeft = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.csp2WatchdogPingsLeft = *(packet + dataOffset); + pdu1HkTableDataset.gndWdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.i2cWdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.canWdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.csp1WdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.csp2WdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.groundWatchdogSecondsLeft = + *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.i2cWatchdogSecondsLeft = + *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.canWatchdogSecondsLeft = + *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.csp1WatchdogPingsLeft = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.csp2WatchdogPingsLeft = *(packet + dataOffset); - pdu1HkTableDataset.setChanged(true); - if(not pdu1HkTableDataset.isValid()) { - pdu1HkTableDataset.setValidity(true, true); - } + pdu1HkTableDataset.setChanged(true); + if (not pdu1HkTableDataset.isValid()) { + pdu1HkTableDataset.setValidity(true, true); + } } -ReturnValue_t PDU1Handler::initializeLocalDataPool( - localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { +ReturnValue_t PDU1Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CONV_EN_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CONV_EN_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CONV_EN_3, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CONV_EN_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CONV_EN_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CONV_EN_3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_ACS_BOARD_SIDE_A, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_BOOTCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_BOOTCNT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_RESETCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_BATT_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_BOOTCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_BOOTCNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_UPTIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_RESETCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_BATT_MODE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_ACS_BOARD_SIDE_A, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_5, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_7, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_0_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_1_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_2_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_3_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_4_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_5_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_6_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_7_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_0_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_1_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_2_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_3_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_4_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_5_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_6_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_7_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_GND, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_I2C, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CAN, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_GND_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_I2C_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CAN_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_GND, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_I2C, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CAN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_GND_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_I2C_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CAN_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT2, new PoolEntry( { 0 })); - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t PDU1Handler::printStatus(DeviceCommandId_t cmd) { - switch(cmd) { - case(GOMSPACE::PRINT_SWITCH_V_I): { - PoolReadGuard pg(&pdu1HkTableDataset); - ReturnValue_t readResult = pg.getReadResult(); - if(readResult != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Reading PDU1 HK table failed!" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - printHkTable(); - return HasReturnvaluesIF::RETURN_OK; + switch (cmd) { + case (GOMSPACE::PRINT_SWITCH_V_I): { + PoolReadGuard pg(&pdu1HkTableDataset); + ReturnValue_t readResult = pg.getReadResult(); + if (readResult != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Reading PDU1 HK table failed!" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + printHkTable(); + return HasReturnvaluesIF::RETURN_OK; } default: { - return HasReturnvaluesIF::RETURN_FAILED; - } + return HasReturnvaluesIF::RETURN_FAILED; } + } } void PDU1Handler::printHkTable() { - sif::info << "PDU1 Info: SwitchState, Currents [mA], Voltages [mV]" << std::endl; - sif::info << std::setw(30) << std::left << "TCS Board" << std::dec << "| " << - unsigned(pdu1HkTableDataset.outEnabledTCSBoard3V3.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutTCSBoard3V3.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutTCSBoard3V3.value << std::endl; - sif::info << std::setw(30) << std::left << "Syrlinks" << std::dec << "| " << - unsigned(pdu1HkTableDataset.outEnabledSyrlinks.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutSyrlinks.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutSyrlinks.value << std::endl; - sif::info << std::setw(30) << std::left << "Star Tracker" << std::dec << "| " << - static_cast(pdu1HkTableDataset.outEnabledStarTracker.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutStarTracker.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutStarTracker.value << std::endl; - sif::info << std::setw(30) << std::left << "MGT" << std::dec << "| " << - static_cast(pdu1HkTableDataset.outEnabledMGT.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutMGT.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutMGT.value << std::endl; - sif::info << std::setw(30) << std::left << "SuS nominal" << std::dec << "| " << - static_cast(pdu1HkTableDataset.outEnabledSUSNominal.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutSUSNominal.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutSUSNominal.value << std::endl; - sif::info << std::setw(30) << std::left << "Solar Cell Experiment" << std::dec << "| " << - static_cast(pdu1HkTableDataset.outEnabledSolarCellExp.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutSolarCellExp.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutSolarCellExp.value << std::endl; - sif::info << std::setw(30) << std::left << "PLOC" << std::dec << "| " << - static_cast(pdu1HkTableDataset.outEnabledPLOC.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutPLOC.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutPLOC.value << std::endl; - sif::info << std::setw(30) << std::left << "ACS Side A" << std::dec << "| " << - static_cast(pdu1HkTableDataset.outEnabledAcsBoardSideA.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutACSBoardSideA.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutACSBoardSideA.value << std::endl; - sif::info << std::setw(30) << std::left << "Channel 8" << std::dec << "| " << - static_cast(pdu1HkTableDataset.outEnabledChannel8.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutChannel8.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutChannel8.value << std::right << std::endl; + sif::info << "PDU1 Info: SwitchState, Currents [mA], Voltages [mV]" << std::endl; + sif::info << std::setw(30) << std::left << "TCS Board" << std::dec << "| " + << unsigned(pdu1HkTableDataset.outEnabledTCSBoard3V3.value) << ", " << std::setw(4) + << std::right << pdu1HkTableDataset.currentOutTCSBoard3V3.value << ", " << std::setw(4) + << pdu1HkTableDataset.voltageOutTCSBoard3V3.value << std::endl; + sif::info << std::setw(30) << std::left << "Syrlinks" << std::dec << "| " + << unsigned(pdu1HkTableDataset.outEnabledSyrlinks.value) << ", " << std::setw(4) + << std::right << pdu1HkTableDataset.currentOutSyrlinks.value << ", " << std::setw(4) + << pdu1HkTableDataset.voltageOutSyrlinks.value << std::endl; + sif::info << std::setw(30) << std::left << "Star Tracker" << std::dec << "| " + << static_cast(pdu1HkTableDataset.outEnabledStarTracker.value) << ", " + << std::setw(4) << std::right << pdu1HkTableDataset.currentOutStarTracker.value << ", " + << std::setw(4) << pdu1HkTableDataset.voltageOutStarTracker.value << std::endl; + sif::info << std::setw(30) << std::left << "MGT" << std::dec << "| " + << static_cast(pdu1HkTableDataset.outEnabledMGT.value) << ", " + << std::setw(4) << std::right << pdu1HkTableDataset.currentOutMGT.value << ", " + << std::setw(4) << pdu1HkTableDataset.voltageOutMGT.value << std::endl; + sif::info << std::setw(30) << std::left << "SuS nominal" << std::dec << "| " + << static_cast(pdu1HkTableDataset.outEnabledSUSNominal.value) << ", " + << std::setw(4) << std::right << pdu1HkTableDataset.currentOutSUSNominal.value << ", " + << std::setw(4) << pdu1HkTableDataset.voltageOutSUSNominal.value << std::endl; + sif::info << std::setw(30) << std::left << "Solar Cell Experiment" << std::dec << "| " + << static_cast(pdu1HkTableDataset.outEnabledSolarCellExp.value) << ", " + << std::setw(4) << std::right << pdu1HkTableDataset.currentOutSolarCellExp.value << ", " + << std::setw(4) << pdu1HkTableDataset.voltageOutSolarCellExp.value << std::endl; + sif::info << std::setw(30) << std::left << "PLOC" << std::dec << "| " + << static_cast(pdu1HkTableDataset.outEnabledPLOC.value) << ", " + << std::setw(4) << std::right << pdu1HkTableDataset.currentOutPLOC.value << ", " + << std::setw(4) << pdu1HkTableDataset.voltageOutPLOC.value << std::endl; + sif::info << std::setw(30) << std::left << "ACS Side A" << std::dec << "| " + << static_cast(pdu1HkTableDataset.outEnabledAcsBoardSideA.value) << ", " + << std::setw(4) << std::right << pdu1HkTableDataset.currentOutACSBoardSideA.value + << ", " << std::setw(4) << pdu1HkTableDataset.voltageOutACSBoardSideA.value + << std::endl; + sif::info << std::setw(30) << std::left << "Channel 8" << std::dec << "| " + << static_cast(pdu1HkTableDataset.outEnabledChannel8.value) << ", " + << std::setw(4) << std::right << pdu1HkTableDataset.currentOutChannel8.value << ", " + << std::setw(4) << pdu1HkTableDataset.voltageOutChannel8.value << std::right + << std::endl; } - diff --git a/mission/devices/PDU1Handler.h b/mission/devices/PDU1Handler.h index 3df99776..0715b078 100644 --- a/mission/devices/PDU1Handler.h +++ b/mission/devices/PDU1Handler.h @@ -19,27 +19,28 @@ * ACS 3.3V for Side A group, channel 7 * Unoccupied, 5V, channel 8 */ -class PDU1Handler: public GomspaceDeviceHandler { -public: - PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); - virtual ~PDU1Handler(); +class PDU1Handler : public GomspaceDeviceHandler { + public: + PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + virtual ~PDU1Handler(); - virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; -protected: - /** - * @brief In MODE_NORMAL, a command will be built periodically by this function. - */ - 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; + virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; -private: - /** Dataset for the housekeeping table of the PDU1 */ - PDU1::PDU1HkTableDataset pdu1HkTableDataset; + protected: + /** + * @brief In MODE_NORMAL, a command will be built periodically by this function. + */ + 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; - void printHkTable(); - void parseHkTableReply(const uint8_t *packet); + private: + /** Dataset for the housekeeping table of the PDU1 */ + PDU1::PDU1HkTableDataset pdu1HkTableDataset; + + void printHkTable(); + void parseHkTableReply(const uint8_t* packet); }; #endif /* MISSION_DEVICES_PDU1Handler_H_ */ diff --git a/mission/devices/PDU2Handler.cpp b/mission/devices/PDU2Handler.cpp index 287fdaf3..b5c34af6 100644 --- a/mission/devices/PDU2Handler.cpp +++ b/mission/devices/PDU2Handler.cpp @@ -1,378 +1,423 @@ -#include "OBSWConfig.h" #include "PDU2Handler.h" -#include #include +#include -PDU2Handler::PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - GomspaceDeviceHandler(objectId, comIF, comCookie, PDU::MAX_CONFIGTABLE_ADDRESS, - PDU::MAX_HKTABLE_ADDRESS, PDU::HK_TABLE_REPLY_SIZE, &pdu2HkTableDataset), - pdu2HkTableDataset(this) { -} +#include "OBSWConfig.h" -PDU2Handler::~PDU2Handler() { -} +PDU2Handler::PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie) + : GomspaceDeviceHandler(objectId, comIF, comCookie, PDU::MAX_CONFIGTABLE_ADDRESS, + PDU::MAX_HKTABLE_ADDRESS, PDU::HK_TABLE_REPLY_SIZE, + &pdu2HkTableDataset), + pdu2HkTableDataset(this) {} -ReturnValue_t PDU2Handler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - *id = GOMSPACE::REQUEST_HK_TABLE; - return buildCommandFromCommand(*id, NULL, 0); +PDU2Handler::~PDU2Handler() {} + +ReturnValue_t PDU2Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + *id = GOMSPACE::REQUEST_HK_TABLE; + return buildCommandFromCommand(*id, NULL, 0); } void PDU2Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) { - - parseHkTableReply(packet); - /** - * Hk table will be sent to the commander if hk table request was not triggered by the - * PDU2Handler itself. - */ - handleDeviceTM(&pdu2HkTableDataset, id, true); + parseHkTableReply(packet); + /** + * Hk table will be sent to the commander if hk table request was not triggered by the + * PDU2Handler itself. + */ + handleDeviceTM(&pdu2HkTableDataset, id, true); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PDU2 == 1 - pdu2HkTableDataset.read(); - sif::info << "PDU2 Q7S current voltage: " << pdu2HkTableDataset.voltageOutQ7S << " mV" << std::endl; - sif::info << "PDU2 VCC: " << pdu2HkTableDataset.vcc << " mV" << std::endl; - float vbat = pdu2HkTableDataset.vbat.value * 0.1; - sif::info << "PDU2 VBAT: " << vbat << std::endl; - float temperatureC = pdu2HkTableDataset.temperature.value * 0.1; - sif::info << "PDU2 Temperature: " << temperatureC << " °C" << std::endl; - printOutputSwitchStates(); - sif::info << "PDU2 uptime: " << pdu2HkTableDataset.uptime << " seconds" << std::endl; - sif::info << "PDU2 battery mode: " << unsigned(pdu2HkTableDataset.battMode.value) << std::endl; - sif::info << "PDU2 ground watchdog reboots: " << pdu2HkTableDataset.gndWdtReboots << std::endl; - sif::info << "PDU2 ground watchdog timer seconds left: " + pdu2HkTableDataset.read(); + sif::info << "PDU2 Q7S current voltage: " << pdu2HkTableDataset.voltageOutQ7S << " mV" + << std::endl; + sif::info << "PDU2 VCC: " << pdu2HkTableDataset.vcc << " mV" << std::endl; + float vbat = pdu2HkTableDataset.vbat.value * 0.1; + sif::info << "PDU2 VBAT: " << vbat << std::endl; + float temperatureC = pdu2HkTableDataset.temperature.value * 0.1; + sif::info << "PDU2 Temperature: " << temperatureC << " °C" << std::endl; + printOutputSwitchStates(); + sif::info << "PDU2 uptime: " << pdu2HkTableDataset.uptime << " seconds" << std::endl; + sif::info << "PDU2 battery mode: " << unsigned(pdu2HkTableDataset.battMode.value) << std::endl; + sif::info << "PDU2 ground watchdog reboots: " << pdu2HkTableDataset.gndWdtReboots << std::endl; + sif::info << "PDU2 ground watchdog timer seconds left: " << pdu2HkTableDataset.groundWatchdogSecondsLeft << " seconds" << std::endl; - sif::info << "PDU2 csp1 watchdog pings before reboot: " + sif::info << "PDU2 csp1 watchdog pings before reboot: " << unsigned(pdu2HkTableDataset.csp1WatchdogPingsLeft.value) << std::endl; - sif::info << "PDU2 csp2 watchdog pings before reboot: " + sif::info << "PDU2 csp2 watchdog pings before reboot: " << unsigned(pdu2HkTableDataset.csp2WatchdogPingsLeft.value) << std::endl; - pdu2HkTableDataset.commit(); + pdu2HkTableDataset.commit(); #endif } void PDU2Handler::parseHkTableReply(const uint8_t *packet) { - uint16_t dataOffset = 0; - pdu2HkTableDataset.read(); - /** - * Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table - * address. - */ - dataOffset += 12; - pdu2HkTableDataset.currentOutQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutPayloadPCDUCh1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutReactionWheels = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutTCSBoardHeaterIn = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutSUSRedundant = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutDeplMechanism = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutPayloadPCDUCh6 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutACSBoardSideB = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutPayloadCamera = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + uint16_t dataOffset = 0; + pdu2HkTableDataset.read(); + /** + * Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table + * address. + */ + dataOffset += 12; + pdu2HkTableDataset.currentOutQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutPayloadPCDUCh1 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutReactionWheels = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutTCSBoardHeaterIn = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutSUSRedundant = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutDeplMechanism = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutPayloadPCDUCh6 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutACSBoardSideB = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutPayloadCamera = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu2HkTableDataset.voltageOutQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutPayloadPCDUCh1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutReactionWheels = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutTCSBoardHeaterIn = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutSUSRedundant = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutDeplMechanism = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutPayloadPCDUCh6 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutACSBoardSideB = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutPayloadCamera = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + pdu2HkTableDataset.voltageOutQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutPayloadPCDUCh1 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutReactionWheels = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutTCSBoardHeaterIn = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutSUSRedundant = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutDeplMechanism = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutPayloadPCDUCh6 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutACSBoardSideB = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutPayloadCamera = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu2HkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.temperature = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + pdu2HkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.temperature = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu2HkTableDataset.converterEnable1 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.converterEnable2 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.converterEnable3 = *(packet + dataOffset); - dataOffset += 3; + pdu2HkTableDataset.converterEnable1 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.converterEnable2 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.converterEnable3 = *(packet + dataOffset); + dataOffset += 3; - pdu2HkTableDataset.outEnabledQ7S = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledPlPCDUCh1 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledReactionWheels = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledTCSBoardHeaterIn = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledSUSRedundant = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledDeplMechanism = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledPlPCDUCh6 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledAcsBoardSideB = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledPayloadCamera = *(packet + dataOffset); - dataOffset += 3; + pdu2HkTableDataset.outEnabledQ7S = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledPlPCDUCh1 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledReactionWheels = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledTCSBoardHeaterIn = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledSUSRedundant = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledDeplMechanism = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledPlPCDUCh6 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledAcsBoardSideB = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledPayloadCamera = *(packet + dataOffset); + dataOffset += 3; - pdu2HkTableDataset.bootcause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.bootcount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.resetcause = *(packet + dataOffset + 1) << 8 | *(packet + dataOffset); - dataOffset += 4; - pdu2HkTableDataset.battMode = *(packet + dataOffset); - /* +10 because here begins the second gomspace csp packet */ - dataOffset += 3 + 10; + pdu2HkTableDataset.bootcause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.bootcount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.resetcause = *(packet + dataOffset + 1) << 8 | *(packet + dataOffset); + dataOffset += 4; + pdu2HkTableDataset.battMode = *(packet + dataOffset); + /* +10 because here begins the second gomspace csp packet */ + dataOffset += 3 + 10; - pdu2HkTableDataset.latchupsQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsPayloadPcduCh1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsRw = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsTcsBoardHeaterIn = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsSusRedundant = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsDeplMenchanism = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsPayloadPcduCh6 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsAcsBoardSideB = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsPayloadCamera = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + pdu2HkTableDataset.latchupsQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsPayloadPcduCh1 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsRw = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsTcsBoardHeaterIn = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsSusRedundant = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsDeplMenchanism = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsPayloadPcduCh6 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsAcsBoardSideB = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsPayloadCamera = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu2HkTableDataset.device0 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device1 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device2 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device3 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device4 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device5 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device6 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device7 = *(packet + dataOffset); - dataOffset += 3; + pdu2HkTableDataset.device0 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device1 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device2 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device3 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device4 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device5 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device6 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device7 = *(packet + dataOffset); + dataOffset += 3; - pdu2HkTableDataset.device0Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device1Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device2Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device3Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device4Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device5Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device6Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device7Status = *(packet + dataOffset); - dataOffset += 3; + pdu2HkTableDataset.device0Status = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device1Status = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device2Status = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device3Status = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device4Status = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device5Status = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device6Status = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device7Status = *(packet + dataOffset); + dataOffset += 3; - pdu2HkTableDataset.gndWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.i2cWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.canWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.csp1WdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.csp2WdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.groundWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.i2cWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.canWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.csp1WatchdogPingsLeft = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.csp2WatchdogPingsLeft = *(packet + dataOffset); + pdu2HkTableDataset.gndWdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.i2cWdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.canWdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.csp1WdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.csp2WdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.groundWatchdogSecondsLeft = + *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.i2cWatchdogSecondsLeft = + *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.canWatchdogSecondsLeft = + *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.csp1WatchdogPingsLeft = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.csp2WatchdogPingsLeft = *(packet + dataOffset); - pdu2HkTableDataset.commit(); - pdu2HkTableDataset.setChanged(true); + pdu2HkTableDataset.commit(); + pdu2HkTableDataset.setChanged(true); } -ReturnValue_t PDU2Handler::initializeLocalDataPool( - localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { +ReturnValue_t PDU2Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_Q7S, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_RW, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_SUS_REDUNDANT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_Q7S, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_RW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_SUS_REDUNDANT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_Q7S, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_RW, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_Q7S, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_RW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CONV_EN_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CONV_EN_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CONV_EN_3, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CONV_EN_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CONV_EN_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CONV_EN_3, new PoolEntry( { 0 })); - - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_Q7S, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_RW, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_Q7S, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_RW, new PoolEntry({0})); #if BOARD_TE0720 == 1 - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry( { 1 })); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry({1})); #else - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry({0})); #endif - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_SUS_REDUNDANT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_DEPLOYMENT_MECHANISM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_ACS_BOARD_SIDE_B, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_CAMERA, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_SUS_REDUNDANT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_DEPLOYMENT_MECHANISM, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_ACS_BOARD_SIDE_B, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_CAMERA, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_BOOTCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_BOOTCNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_UPTIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_RESETCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_BATT_MODE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_BOOTCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_BOOTCNT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_RESETCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_BATT_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_Q7S, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_RW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_SUS_REDUNDANT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_DEPLOYMENT_MECHANISM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_ACS_BOARD_SIDE_B, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_CAMERA, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_Q7S, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_RW, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_SUS_REDUNDANT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_DEPLOYMENT_MECHANISM, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_ACS_BOARD_SIDE_B, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_CAMERA, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_5, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_7, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_0_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_1_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_2_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_3_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_4_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_5_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_6_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_7_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_0_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_1_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_2_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_3_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_4_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_5_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_6_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_7_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_GND, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_I2C, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CAN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_GND_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_I2C_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CAN_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_GND, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_I2C, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CAN, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_GND_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_I2C_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CAN_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT2, new PoolEntry({0})); - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t PDU2Handler::printStatus(DeviceCommandId_t cmd) { - switch(cmd) { - case(GOMSPACE::PRINT_SWITCH_V_I): { - PoolReadGuard pg(&pdu2HkTableDataset); - ReturnValue_t readResult = pg.getReadResult(); - if(readResult != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Reading PDU1 HK table failed!" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - printHkTable(); - return HasReturnvaluesIF::RETURN_OK; + switch (cmd) { + case (GOMSPACE::PRINT_SWITCH_V_I): { + PoolReadGuard pg(&pdu2HkTableDataset); + ReturnValue_t readResult = pg.getReadResult(); + if (readResult != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Reading PDU1 HK table failed!" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + printHkTable(); + return HasReturnvaluesIF::RETURN_OK; } default: { - return HasReturnvaluesIF::RETURN_FAILED; - } + return HasReturnvaluesIF::RETURN_FAILED; } + } } void PDU2Handler::printHkTable() { - sif::info << "PDU2 Info: SwitchState, Currents [mA], Voltages [mV]" << std::endl; - sif::info << std::setw(30) << std::left << "Q7S" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledQ7S.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutQ7S.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutQ7S.value << std::endl; - sif::info << std::setw(30) << std::left << "Payload PCDU Channel 1" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledPlPCDUCh1.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutPayloadPCDUCh1.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutPayloadPCDUCh1.value << std::endl; - sif::info << std::setw(30) << std::left << "Reaction Wheels" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledReactionWheels.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutReactionWheels.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutReactionWheels.value << std::endl; - sif::info << std::setw(30) << std::left << "TCS Board 8V heater input" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledTCSBoardHeaterIn.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutTCSBoardHeaterIn.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutTCSBoardHeaterIn.value << std::endl; - sif::info << std::setw(30) << std::left << "Redundant SUS group" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledSUSRedundant.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutSUSRedundant.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutSUSRedundant.value << std::endl; - sif::info << std::setw(30) << std::left << "Deployment mechanism" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledDeplMechanism.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutDeplMechanism.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutDeplMechanism.value << std::endl; - sif::info << std::setw(30) << std::left << "Payload PCDU Channel 6" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledPlPCDUCh6.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutPayloadPCDUCh6.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutPayloadPCDUCh6.value<< std::endl; - sif::info << std::setw(30) << std::left << "ACS Board Side B" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledAcsBoardSideB.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutACSBoardSideB.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutACSBoardSideB.value << std::endl; - sif::info << std::setw(30) << std::left << "Payload Camera enable state" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledPayloadCamera.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutPayloadCamera.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutPayloadCamera.value << std::right << std::endl; + sif::info << "PDU2 Info: SwitchState, Currents [mA], Voltages [mV]" << std::endl; + sif::info << std::setw(30) << std::left << "Q7S" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledQ7S.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutQ7S.value << ", " << std::setw(4) + << pdu2HkTableDataset.voltageOutQ7S.value << std::endl; + sif::info << std::setw(30) << std::left << "Payload PCDU Channel 1" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledPlPCDUCh1.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutPayloadPCDUCh1.value << ", " + << std::setw(4) << pdu2HkTableDataset.voltageOutPayloadPCDUCh1.value << std::endl; + sif::info << std::setw(30) << std::left << "Reaction Wheels" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledReactionWheels.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutReactionWheels.value << ", " + << std::setw(4) << pdu2HkTableDataset.voltageOutReactionWheels.value << std::endl; + sif::info << std::setw(30) << std::left << "TCS Board 8V heater input" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledTCSBoardHeaterIn.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutTCSBoardHeaterIn.value << ", " + << std::setw(4) << pdu2HkTableDataset.voltageOutTCSBoardHeaterIn.value << std::endl; + sif::info << std::setw(30) << std::left << "Redundant SUS group" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledSUSRedundant.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutSUSRedundant.value << ", " << std::setw(4) + << pdu2HkTableDataset.voltageOutSUSRedundant.value << std::endl; + sif::info << std::setw(30) << std::left << "Deployment mechanism" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledDeplMechanism.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutDeplMechanism.value << ", " + << std::setw(4) << pdu2HkTableDataset.voltageOutDeplMechanism.value << std::endl; + sif::info << std::setw(30) << std::left << "Payload PCDU Channel 6" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledPlPCDUCh6.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutPayloadPCDUCh6.value << ", " + << std::setw(4) << pdu2HkTableDataset.voltageOutPayloadPCDUCh6.value << std::endl; + sif::info << std::setw(30) << std::left << "ACS Board Side B" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledAcsBoardSideB.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutACSBoardSideB.value << ", " + << std::setw(4) << pdu2HkTableDataset.voltageOutACSBoardSideB.value << std::endl; + sif::info << std::setw(30) << std::left << "Payload Camera enable state" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledPayloadCamera.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutPayloadCamera.value << ", " + << std::setw(4) << pdu2HkTableDataset.voltageOutPayloadCamera.value << std::right + << std::endl; } diff --git a/mission/devices/PDU2Handler.h b/mission/devices/PDU2Handler.h index c44d1267..258b616d 100644 --- a/mission/devices/PDU2Handler.h +++ b/mission/devices/PDU2Handler.h @@ -1,9 +1,10 @@ #ifndef MISSION_DEVICES_PDU2HANDLER_H_ #define MISSION_DEVICES_PDU2HANDLER_H_ -#include "GomspaceDeviceHandler.h" #include +#include "GomspaceDeviceHandler.h" + /** * @brief This is the device handler for the PDU2. * @@ -18,30 +19,29 @@ * ACS Board (Gyro, MGMs, GPS), 3.3V channel 7 * Payload Camera, 8V, channel 8 */ -class PDU2Handler: public GomspaceDeviceHandler { -public: - PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); - virtual ~PDU2Handler(); +class PDU2Handler : public GomspaceDeviceHandler { + public: + PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + virtual ~PDU2Handler(); - virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; + virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; -protected: - /** - * @brief As soon as the device is in MODE_NORMAL, this function is executed periodically. - */ - 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; + protected: + /** + * @brief As soon as the device is in MODE_NORMAL, this function is executed periodically. + */ + 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; -private: + private: + /** Dataset for the housekeeping table of the PDU2 */ + PDU2::PDU2HkTableDataset pdu2HkTableDataset; - /** Dataset for the housekeeping table of the PDU2 */ - PDU2::PDU2HkTableDataset pdu2HkTableDataset; + void printHkTable(); - void printHkTable(); - - void parseHkTableReply(const uint8_t *packet); + void parseHkTableReply(const uint8_t* packet); }; #endif /* MISSION_DEVICES_PDU2HANDLER_H_ */ diff --git a/mission/devices/PlocMPSoCHandler.cpp b/mission/devices/PlocMPSoCHandler.cpp index dcc81ef7..07b9b0fa 100644 --- a/mission/devices/PlocMPSoCHandler.cpp +++ b/mission/devices/PlocMPSoCHandler.cpp @@ -1,497 +1,473 @@ #include "PlocMPSoCHandler.h" + +#include +#include + #include "OBSWConfig.h" -#include -#include +PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie) + : DeviceHandlerBase(objectId, comIF, comCookie) { + if (comCookie == NULL) { + sif::error << "PlocMPSoCHandler: Invalid com cookie" << std::endl; + } +} -PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - DeviceHandlerBase(objectId, comIF, comCookie) { - if (comCookie == NULL) { - sif::error << "PlocMPSoCHandler: Invalid com cookie" << std::endl; +PlocMPSoCHandler::~PlocMPSoCHandler() {} + +void PlocMPSoCHandler::doStartUp() { + if (mode == _MODE_START_UP) { + setMode(MODE_ON); + } +} + +void PlocMPSoCHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } + +ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + return RETURN_OK; +} + +ReturnValue_t PlocMPSoCHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t* commandData, + size_t commandDataLen) { + switch (deviceCommand) { + case (PLOC_MPSOC::TC_MEM_WRITE): { + return prepareTcMemWriteCommand(commandData, commandDataLen); } -} - -PlocMPSoCHandler::~PlocMPSoCHandler() { -} - - -void PlocMPSoCHandler::doStartUp(){ - if(mode == _MODE_START_UP){ - setMode(MODE_ON); - } -} - -void PlocMPSoCHandler::doShutDown(){ - setMode(_MODE_POWER_DOWN); -} - -ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - return RETURN_OK; -} - -ReturnValue_t PlocMPSoCHandler::buildTransitionDeviceCommand( - DeviceCommandId_t * id){ - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t * commandData, - size_t commandDataLen) { - switch(deviceCommand) { - case(PLOC_MPSOC::TC_MEM_WRITE): { - return prepareTcMemWriteCommand(commandData, commandDataLen); - } - case(PLOC_MPSOC::TC_MEM_READ): { - return prepareTcMemReadCommand(commandData, commandDataLen); - } - default: - sif::debug << "PlocMPSoCHandler::buildCommandFromCommand: Command not implemented" << std::endl; - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; + case (PLOC_MPSOC::TC_MEM_READ): { + return prepareTcMemReadCommand(commandData, commandDataLen); + } + default: + sif::debug << "PlocMPSoCHandler::buildCommandFromCommand: Command not implemented" + << std::endl; + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } void PlocMPSoCHandler::fillCommandAndReplyMap() { - this->insertInCommandMap(PLOC_MPSOC::TC_MEM_WRITE); - this->insertInCommandMap(PLOC_MPSOC::TC_MEM_READ); - this->insertInReplyMap(PLOC_MPSOC::ACK_REPORT, 1, nullptr, PLOC_MPSOC::SIZE_ACK_REPORT); - this->insertInReplyMap(PLOC_MPSOC::EXE_REPORT, 3, nullptr, PLOC_MPSOC::SIZE_EXE_REPORT); - this->insertInReplyMap(PLOC_MPSOC::TM_MEMORY_READ_REPORT, 2, nullptr, PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT); + this->insertInCommandMap(PLOC_MPSOC::TC_MEM_WRITE); + this->insertInCommandMap(PLOC_MPSOC::TC_MEM_READ); + this->insertInReplyMap(PLOC_MPSOC::ACK_REPORT, 1, nullptr, PLOC_MPSOC::SIZE_ACK_REPORT); + this->insertInReplyMap(PLOC_MPSOC::EXE_REPORT, 3, nullptr, PLOC_MPSOC::SIZE_EXE_REPORT); + this->insertInReplyMap(PLOC_MPSOC::TM_MEMORY_READ_REPORT, 2, nullptr, + PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT); } -ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { +ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + uint16_t apid = (*(start) << 8 | *(start + 1)) & APID_MASK; - uint16_t apid = (*(start) << 8 | *(start + 1)) & APID_MASK; + switch (apid) { + case (PLOC_MPSOC::APID_ACK_SUCCESS): + *foundLen = PLOC_MPSOC::SIZE_ACK_REPORT; + *foundId = PLOC_MPSOC::ACK_REPORT; + break; + case (PLOC_MPSOC::APID_ACK_FAILURE): + *foundLen = PLOC_MPSOC::SIZE_ACK_REPORT; + *foundId = PLOC_MPSOC::ACK_REPORT; + break; + case (PLOC_MPSOC::APID_TM_MEMORY_READ_REPORT): + *foundLen = PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT; + *foundId = PLOC_MPSOC::TM_MEMORY_READ_REPORT; + break; + case (PLOC_MPSOC::APID_EXE_SUCCESS): + *foundLen = PLOC_MPSOC::SIZE_EXE_REPORT; + *foundId = PLOC_MPSOC::EXE_REPORT; + break; + case (PLOC_MPSOC::APID_EXE_FAILURE): + *foundLen = PLOC_MPSOC::SIZE_EXE_REPORT; + *foundId = PLOC_MPSOC::EXE_REPORT; + break; + default: { + sif::debug << "PlocMPSoCHandler::scanForReply: Reply has invalid apid" << std::endl; + *foundLen = remainingSize; + return INVALID_APID; + } + } - switch(apid) { - case(PLOC_MPSOC::APID_ACK_SUCCESS): - *foundLen = PLOC_MPSOC::SIZE_ACK_REPORT; - *foundId = PLOC_MPSOC::ACK_REPORT; - break; - case(PLOC_MPSOC::APID_ACK_FAILURE): - *foundLen = PLOC_MPSOC::SIZE_ACK_REPORT; - *foundId = PLOC_MPSOC::ACK_REPORT; - break; - case(PLOC_MPSOC::APID_TM_MEMORY_READ_REPORT): - *foundLen = PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT; - *foundId = PLOC_MPSOC::TM_MEMORY_READ_REPORT; - break; - case(PLOC_MPSOC::APID_EXE_SUCCESS): - *foundLen = PLOC_MPSOC::SIZE_EXE_REPORT; - *foundId = PLOC_MPSOC::EXE_REPORT; - break; - case(PLOC_MPSOC::APID_EXE_FAILURE): - *foundLen = PLOC_MPSOC::SIZE_EXE_REPORT; - *foundId = PLOC_MPSOC::EXE_REPORT; - break; - default: { - sif::debug << "PlocMPSoCHandler::scanForReply: Reply has invalid apid" << std::endl; - *foundLen = remainingSize; - return INVALID_APID; - } - } + /** + * This should normally never fail. However, this function is also responsible for incrementing + * the packet sequence count why it is called here. + */ + result = checkPacketSequenceCount(start); - /** - * This should normally never fail. However, this function is also responsible for incrementing - * the packet sequence count why it is called here. - */ - result = checkPacketSequenceCount(start); - - return result; + return result; } -ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { +ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; - - switch (id) { + switch (id) { case PLOC_MPSOC::ACK_REPORT: { - result = handleAckReport(packet); - break; + result = handleAckReport(packet); + break; } case (PLOC_MPSOC::TM_MEMORY_READ_REPORT): { - result = handleMemoryReadReport(packet); - break; + result = handleMemoryReadReport(packet); + break; } case (PLOC_MPSOC::EXE_REPORT): { - result = handleExecutionReport(packet); - break; + result = handleExecutionReport(packet); + break; } default: { - sif::debug << "PlocMPSoCHandler::interpretDeviceReply: Unknown device reply id" << std::endl; - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } + sif::debug << "PlocMPSoCHandler::interpretDeviceReply: Unknown device reply id" << std::endl; + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; } + } - return result; + return result; } -void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid(){ +void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid() {} -} - -uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){ - return 500; -} +uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } ReturnValue_t PlocMPSoCHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { - - return HasReturnvaluesIF::RETURN_OK; + LocalDataPoolManager& poolManager) { + return HasReturnvaluesIF::RETURN_OK; } -void PlocMPSoCHandler::setModeNormal() { - mode = MODE_NORMAL; +void PlocMPSoCHandler::setModeNormal() { mode = MODE_NORMAL; } + +ReturnValue_t PlocMPSoCHandler::prepareTcMemWriteCommand(const uint8_t* commandData, + size_t commandDataLen) { + const uint32_t memoryAddress = *(commandData) << 24 | *(commandData + 1) << 16 | + *(commandData + 2) << 8 | *(commandData + 3); + const uint32_t memoryData = *(commandData + 4) << 24 | *(commandData + 5) << 16 | + *(commandData + 6) << 8 | *(commandData + 7); + packetSequenceCount = (packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK; + PLOC_MPSOC::TcMemWrite tcMemWrite(memoryAddress, memoryData, packetSequenceCount); + if (tcMemWrite.getFullSize() > PLOC_MPSOC::MAX_COMMAND_SIZE) { + sif::debug << "PlocMPSoCHandler::prepareTcMemWriteCommand: Command too big" << std::endl; + return RETURN_FAILED; + } + memcpy(commandBuffer, tcMemWrite.getWholeData(), tcMemWrite.getFullSize()); + rawPacket = commandBuffer; + rawPacketLen = tcMemWrite.getFullSize(); + nextReplyId = PLOC_MPSOC::ACK_REPORT; + return RETURN_OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcMemWriteCommand(const uint8_t * commandData, - size_t commandDataLen) { - const uint32_t memoryAddress = *(commandData) << 24 | *(commandData + 1) << 16 - | *(commandData + 2) << 8 | *(commandData + 3); - const uint32_t memoryData = *(commandData + 4) << 24 | *(commandData + 5) << 16 - | *(commandData + 6) << 8 | *(commandData + 7); - packetSequenceCount = (packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK; - PLOC_MPSOC::TcMemWrite tcMemWrite(memoryAddress, memoryData, packetSequenceCount); - if (tcMemWrite.getFullSize() > PLOC_MPSOC::MAX_COMMAND_SIZE) { - sif::debug << "PlocMPSoCHandler::prepareTcMemWriteCommand: Command too big" << std::endl; - return RETURN_FAILED; - } - memcpy(commandBuffer, tcMemWrite.getWholeData(), tcMemWrite.getFullSize()); - rawPacket = commandBuffer; - rawPacketLen = tcMemWrite.getFullSize(); - nextReplyId = PLOC_MPSOC::ACK_REPORT; - return RETURN_OK; -} +ReturnValue_t PlocMPSoCHandler::prepareTcMemReadCommand(const uint8_t* commandData, + size_t commandDataLen) { + const uint32_t memoryAddress = *(commandData) << 24 | *(commandData + 1) << 16 | + *(commandData + 2) << 8 | *(commandData + 3); + packetSequenceCount = (packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK; + PLOC_MPSOC::TcMemRead tcMemRead(memoryAddress, packetSequenceCount); + if (tcMemRead.getFullSize() > PLOC_MPSOC::MAX_COMMAND_SIZE) { + sif::debug << "PlocMPSoCHandler::prepareTcMemReadCommand: Command too big" << std::endl; + return RETURN_FAILED; + } + memcpy(commandBuffer, tcMemRead.getWholeData(), tcMemRead.getFullSize()); + rawPacket = commandBuffer; + rawPacketLen = tcMemRead.getFullSize(); + nextReplyId = PLOC_MPSOC::ACK_REPORT; -ReturnValue_t PlocMPSoCHandler::prepareTcMemReadCommand(const uint8_t * commandData, - size_t commandDataLen) { - const uint32_t memoryAddress = *(commandData) << 24 | *(commandData + 1) << 16 - | *(commandData + 2) << 8 | *(commandData + 3); - packetSequenceCount = (packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK; - PLOC_MPSOC::TcMemRead tcMemRead(memoryAddress, packetSequenceCount); - if (tcMemRead.getFullSize() > PLOC_MPSOC::MAX_COMMAND_SIZE) { - sif::debug << "PlocMPSoCHandler::prepareTcMemReadCommand: Command too big" << std::endl; - return RETURN_FAILED; - } - memcpy(commandBuffer, tcMemRead.getWholeData(), tcMemRead.getFullSize()); - rawPacket = commandBuffer; - rawPacketLen = tcMemRead.getFullSize(); - nextReplyId = PLOC_MPSOC::ACK_REPORT; - - return RETURN_OK; + return RETURN_OK; } ReturnValue_t PlocMPSoCHandler::verifyPacket(const uint8_t* start, size_t foundLen) { + uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1); - uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1); + uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2); - uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2); + if (receivedCrc != recalculatedCrc) { + return CRC_FAILURE; + } - if (receivedCrc != recalculatedCrc) { - return CRC_FAILURE; - } - - return RETURN_OK; + return RETURN_OK; } ReturnValue_t PlocMPSoCHandler::handleAckReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_MPSOC::SIZE_ACK_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocMPSoCHandler::handleAckReport: CRC failure" << std::endl; + nextReplyId = PLOC_MPSOC::NONE; + replyRawReplyIfnotWiretapped(data, PLOC_MPSOC::SIZE_ACK_REPORT); + triggerEvent(CRC_FAILURE_EVENT); + sendFailureReport(PLOC_MPSOC::ACK_REPORT, CRC_FAILURE); + disableAllReplies(); + return IGNORE_REPLY_DATA; + } - result = verifyPacket(data, PLOC_MPSOC::SIZE_ACK_REPORT); - if(result == CRC_FAILURE) { - sif::error << "PlocMPSoCHandler::handleAckReport: CRC failure" << std::endl; - nextReplyId = PLOC_MPSOC::NONE; - replyRawReplyIfnotWiretapped(data, PLOC_MPSOC::SIZE_ACK_REPORT); - triggerEvent(CRC_FAILURE_EVENT); - sendFailureReport(PLOC_MPSOC::ACK_REPORT, CRC_FAILURE); - disableAllReplies(); - return IGNORE_REPLY_DATA; + uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; + + switch (apid) { + case PLOC_MPSOC::APID_ACK_FAILURE: { + // TODO: Interpretation of status field in acknowledgment report + sif::debug << "PlocMPSoCHandler::handleAckReport: Received Ack failure report" << std::endl; + DeviceCommandId_t commandId = getPendingCommand(); + if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { + triggerEvent(ACK_FAILURE, commandId); + } + sendFailureReport(PLOC_MPSOC::ACK_REPORT, RECEIVED_ACK_FAILURE); + disableAllReplies(); + nextReplyId = PLOC_MPSOC::NONE; + result = IGNORE_REPLY_DATA; + break; } + case PLOC_MPSOC::APID_ACK_SUCCESS: { + setNextReplyId(); + break; + } + default: { + sif::debug << "PlocMPSoCHandler::handleAckReport: Invalid APID in Ack report" << std::endl; + result = RETURN_FAILED; + break; + } + } - uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; - - switch(apid) { - case PLOC_MPSOC::APID_ACK_FAILURE: { - //TODO: Interpretation of status field in acknowledgment report - sif::debug << "PlocMPSoCHandler::handleAckReport: Received Ack failure report" << std::endl; - DeviceCommandId_t commandId = getPendingCommand(); - if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { - triggerEvent(ACK_FAILURE, commandId); - } - sendFailureReport(PLOC_MPSOC::ACK_REPORT, RECEIVED_ACK_FAILURE); - disableAllReplies(); - nextReplyId = PLOC_MPSOC::NONE; - result = IGNORE_REPLY_DATA; - break; - } - case PLOC_MPSOC::APID_ACK_SUCCESS: { - setNextReplyId(); - break; - } - default: { - sif::debug << "PlocMPSoCHandler::handleAckReport: Invalid APID in Ack report" << std::endl; - result = RETURN_FAILED; - break; - } - } - - return result; + return result; } ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_MPSOC::SIZE_EXE_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocMPSoCHandler::handleExecutionReport: CRC failure" << std::endl; + nextReplyId = PLOC_MPSOC::NONE; + return result; + } - result = verifyPacket(data, PLOC_MPSOC::SIZE_EXE_REPORT); - if(result == CRC_FAILURE) { - sif::error << "PlocMPSoCHandler::handleExecutionReport: CRC failure" << std::endl; - nextReplyId = PLOC_MPSOC::NONE; - return result; - } + uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; - uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; - - switch (apid) { + switch (apid) { case (PLOC_MPSOC::APID_EXE_SUCCESS): { - break; + break; } case (PLOC_MPSOC::APID_EXE_FAILURE): { - //TODO: Interpretation of status field in execution report - sif::error << "PlocMPSoCHandler::handleExecutionReport: Received execution failure report" - << std::endl; - DeviceCommandId_t commandId = getPendingCommand(); - if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { - triggerEvent(EXE_FAILURE, commandId); - } - else { - sif::debug << "PlocMPSoCHandler::handleExecutionReport: Unknown command id" << std::endl; - } - sendFailureReport(PLOC_MPSOC::EXE_REPORT, RECEIVED_EXE_FAILURE); - disableExeReportReply(); - result = IGNORE_REPLY_DATA; - break; + // TODO: Interpretation of status field in execution report + sif::error << "PlocMPSoCHandler::handleExecutionReport: Received execution failure report" + << std::endl; + DeviceCommandId_t commandId = getPendingCommand(); + if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { + triggerEvent(EXE_FAILURE, commandId); + } else { + sif::debug << "PlocMPSoCHandler::handleExecutionReport: Unknown command id" << std::endl; + } + sendFailureReport(PLOC_MPSOC::EXE_REPORT, RECEIVED_EXE_FAILURE); + disableExeReportReply(); + result = IGNORE_REPLY_DATA; + break; } default: { - sif::error << "PlocMPSoCHandler::handleExecutionReport: Unknown APID" << std::endl; - result = RETURN_FAILED; - break; - } + sif::error << "PlocMPSoCHandler::handleExecutionReport: Unknown APID" << std::endl; + result = RETURN_FAILED; + break; } + } - nextReplyId = PLOC_MPSOC::NONE; + nextReplyId = PLOC_MPSOC::NONE; - return result; + return result; } ReturnValue_t PlocMPSoCHandler::handleMemoryReadReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT); - result = verifyPacket(data, PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocMPSoCHandler::handleMemoryReadReport: Memory read report has invalid crc" + << std::endl; + } + /** Send data to commanding queue */ + handleDeviceTM(data + PLOC_MPSOC::DATA_FIELD_OFFSET, PLOC_MPSOC::SIZE_MEM_READ_REPORT_DATA, + PLOC_MPSOC::TM_MEMORY_READ_REPORT); - if(result == CRC_FAILURE) { - sif::error << "PlocMPSoCHandler::handleMemoryReadReport: Memory read report has invalid crc" - << std::endl; - } - /** Send data to commanding queue */ - handleDeviceTM(data + PLOC_MPSOC::DATA_FIELD_OFFSET, PLOC_MPSOC::SIZE_MEM_READ_REPORT_DATA, - PLOC_MPSOC::TM_MEMORY_READ_REPORT); + nextReplyId = PLOC_MPSOC::EXE_REPORT; - nextReplyId = PLOC_MPSOC::EXE_REPORT; - - return result; + return result; } ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command, - uint8_t expectedReplies, bool useAlternateId, - DeviceCommandId_t alternateReplyID) { + uint8_t expectedReplies, bool useAlternateId, + DeviceCommandId_t alternateReplyID) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + uint8_t enabledReplies = 0; - uint8_t enabledReplies = 0; - - switch (command->first) { + switch (command->first) { case PLOC_MPSOC::TC_MEM_WRITE: - enabledReplies = 2; - break; + enabledReplies = 2; + break; case PLOC_MPSOC::TC_MEM_READ: { - enabledReplies = 3; - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_MPSOC::TM_MEMORY_READ_REPORT); - if (result != RETURN_OK) { - sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " - << PLOC_MPSOC::TM_MEMORY_READ_REPORT << " not in replyMap" << std::endl; - } - break; + enabledReplies = 3; + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_MPSOC::TM_MEMORY_READ_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " + << PLOC_MPSOC::TM_MEMORY_READ_REPORT << " not in replyMap" << std::endl; + } + break; } default: - sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Unknown command id" << std::endl; - break; - } + sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Unknown command id" << std::endl; + break; + } - /** - * Every command causes at least one acknowledgment and one execution report. Therefore both - * replies will be enabled here. - */ - result = DeviceHandlerBase::enableReplyInReplyMap(command, - enabledReplies, true, PLOC_MPSOC::ACK_REPORT); - if (result != RETURN_OK) { - sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " << PLOC_MPSOC::ACK_REPORT - << " not in replyMap" << std::endl; - } + /** + * Every command causes at least one acknowledgment and one execution report. Therefore both + * replies will be enabled here. + */ + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_MPSOC::ACK_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " + << PLOC_MPSOC::ACK_REPORT << " not in replyMap" << std::endl; + } - result = DeviceHandlerBase::enableReplyInReplyMap(command, - enabledReplies, true, PLOC_MPSOC::EXE_REPORT); - if (result != RETURN_OK) { - sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " << PLOC_MPSOC::EXE_REPORT - << " not in replyMap" << std::endl; - } + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_MPSOC::EXE_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " + << PLOC_MPSOC::EXE_REPORT << " not in replyMap" << std::endl; + } - return RETURN_OK; + return RETURN_OK; } void PlocMPSoCHandler::setNextReplyId() { - switch(getPendingCommand()) { + switch (getPendingCommand()) { case PLOC_MPSOC::TC_MEM_READ: - nextReplyId = PLOC_MPSOC::TM_MEMORY_READ_REPORT; - break; + nextReplyId = PLOC_MPSOC::TM_MEMORY_READ_REPORT; + break; default: - /* If no telemetry is expected the next reply is always the execution report */ - nextReplyId = PLOC_MPSOC::EXE_REPORT; - break; - } + /* If no telemetry is expected the next reply is always the execution report */ + nextReplyId = PLOC_MPSOC::EXE_REPORT; + break; + } } -size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId){ - - size_t replyLen = 0; - - if (nextReplyId == PLOC_MPSOC::NONE) { - return replyLen; - } - - DeviceReplyIter iter = deviceReplyMap.find(nextReplyId); - if (iter != deviceReplyMap.end()) { - if (iter->second.delayCycles == 0) { - /* Reply inactive */ - return replyLen; - } - replyLen = iter->second.replyLen; - } - else { - sif::debug << "PlocMPSoCHandler::getNextReplyLength: No entry for reply with reply id " - << std::hex << nextReplyId << " in deviceReplyMap" << std::endl; - } +size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) { + size_t replyLen = 0; + if (nextReplyId == PLOC_MPSOC::NONE) { return replyLen; + } + + DeviceReplyIter iter = deviceReplyMap.find(nextReplyId); + if (iter != deviceReplyMap.end()) { + if (iter->second.delayCycles == 0) { + /* Reply inactive */ + return replyLen; + } + replyLen = iter->second.replyLen; + } else { + sif::debug << "PlocMPSoCHandler::getNextReplyLength: No entry for reply with reply id " + << std::hex << nextReplyId << " in deviceReplyMap" << std::endl; + } + + return replyLen; } -void PlocMPSoCHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId) { +void PlocMPSoCHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, + DeviceCommandId_t replyId) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + if (wiretappingMode == RAW) { + /* Data already sent in doGetRead() */ + return; + } - if (wiretappingMode == RAW) { - /* Data already sent in doGetRead() */ - return; - } + DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId); + if (iter == deviceReplyMap.end()) { + sif::debug << "PlocMPSoCHandler::handleDeviceTM: Unknown reply id" << std::endl; + return; + } + MessageQueueId_t queueId = iter->second.command->second.sendReplyTo; - DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId); - if (iter == deviceReplyMap.end()) { - sif::debug << "PlocMPSoCHandler::handleDeviceTM: Unknown reply id" << std::endl; - return; - } - MessageQueueId_t queueId = iter->second.command->second.sendReplyTo; + if (queueId == NO_COMMANDER) { + return; + } - if (queueId == NO_COMMANDER) { - return; - } - - result = actionHelper.reportData(queueId, replyId, data, dataSize); - if (result != RETURN_OK) { - sif::debug << "PlocMPSoCHandler::handleDeviceTM: Failed to report data" << std::endl; - } + result = actionHelper.reportData(queueId, replyId, data, dataSize); + if (result != RETURN_OK) { + sif::debug << "PlocMPSoCHandler::handleDeviceTM: Failed to report data" << std::endl; + } } void PlocMPSoCHandler::disableAllReplies() { + DeviceReplyMap::iterator iter; - DeviceReplyMap::iterator iter; + /* Disable ack reply */ + iter = deviceReplyMap.find(PLOC_MPSOC::ACK_REPORT); + DeviceReplyInfo* info = &(iter->second); + info->delayCycles = 0; + info->command = deviceCommandMap.end(); - /* Disable ack reply */ - iter = deviceReplyMap.find(PLOC_MPSOC::ACK_REPORT); - DeviceReplyInfo *info = &(iter->second); - info->delayCycles = 0; - info->command = deviceCommandMap.end(); + DeviceCommandId_t commandId = getPendingCommand(); - DeviceCommandId_t commandId = getPendingCommand(); - - /* If the command expects a telemetry packet the appropriate tm reply will be disabled here */ - switch (commandId) { + /* If the command expects a telemetry packet the appropriate tm reply will be disabled here */ + switch (commandId) { case PLOC_MPSOC::TC_MEM_WRITE: - break; + break; case PLOC_MPSOC::TC_MEM_READ: { - iter = deviceReplyMap.find(PLOC_MPSOC::TM_MEMORY_READ_REPORT); - info = &(iter->second); - info->delayCycles = 0; - info->command = deviceCommandMap.end(); - break; + iter = deviceReplyMap.find(PLOC_MPSOC::TM_MEMORY_READ_REPORT); + info = &(iter->second); + info->delayCycles = 0; + info->command = deviceCommandMap.end(); + break; } default: { - sif::debug << "PlocMPSoCHandler::disableAllReplies: Unknown command id" << commandId - << std::endl; - break; - } + sif::debug << "PlocMPSoCHandler::disableAllReplies: Unknown command id" << commandId + << std::endl; + break; } + } - /* We must always disable the execution report reply here */ - disableExeReportReply(); + /* We must always disable the execution report reply here */ + disableExeReportReply(); } void PlocMPSoCHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status) { + DeviceReplyIter iter = deviceReplyMap.find(replyId); - DeviceReplyIter iter = deviceReplyMap.find(replyId); + if (iter == deviceReplyMap.end()) { + sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply not in reply map" << std::endl; + return; + } - if (iter == deviceReplyMap.end()) { - sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply not in reply map" << std::endl; - return; - } + DeviceCommandInfo* info = &(iter->second.command->second); - DeviceCommandInfo* info = &(iter->second.command->second); + if (info == nullptr) { + sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply has no active command" << std::endl; + return; + } - if (info == nullptr) { - sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply has no active command" << std::endl; - return; - } - - if (info->sendReplyTo != NO_COMMANDER) { - actionHelper.finish(false, info->sendReplyTo, iter->first, status); - } - info->isExecuting = false; + if (info->sendReplyTo != NO_COMMANDER) { + actionHelper.finish(false, info->sendReplyTo, iter->first, status); + } + info->isExecuting = false; } void PlocMPSoCHandler::disableExeReportReply() { - DeviceReplyIter iter = deviceReplyMap.find(PLOC_MPSOC::EXE_REPORT); - DeviceReplyInfo *info = &(iter->second); - info->delayCycles = 0; - info->command = deviceCommandMap.end(); - /* Expected replies is set to one here. The value will set to 0 in replyToReply() */ - info->command->second.expectedReplies = 0; + DeviceReplyIter iter = deviceReplyMap.find(PLOC_MPSOC::EXE_REPORT); + DeviceReplyInfo* info = &(iter->second); + info->delayCycles = 0; + info->command = deviceCommandMap.end(); + /* Expected replies is set to one here. The value will set to 0 in replyToReply() */ + info->command->second.expectedReplies = 0; } ReturnValue_t PlocMPSoCHandler::checkPacketSequenceCount(const uint8_t* data) { - uint16_t receivedSequenceCount = (*(data + 2) << 8 | *(data + 3)) & PACKET_SEQUENCE_COUNT_MASK; - uint16_t expectedPacketSequenceCount = ((packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK); - if (receivedSequenceCount != expectedPacketSequenceCount) { - sif::debug - << "PlocMPSoCHandler::checkPacketSequenceCount: Packet sequence count mismatch. " - << std::endl; - sif::debug << "Received sequence count: " << receivedSequenceCount << ". OBSW sequence " - << "count: " << expectedPacketSequenceCount << std::endl; - } - packetSequenceCount = receivedSequenceCount; - return RETURN_OK; + uint16_t receivedSequenceCount = (*(data + 2) << 8 | *(data + 3)) & PACKET_SEQUENCE_COUNT_MASK; + uint16_t expectedPacketSequenceCount = ((packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK); + if (receivedSequenceCount != expectedPacketSequenceCount) { + sif::debug << "PlocMPSoCHandler::checkPacketSequenceCount: Packet sequence count mismatch. " + << std::endl; + sif::debug << "Received sequence count: " << receivedSequenceCount << ". OBSW sequence " + << "count: " << expectedPacketSequenceCount << std::endl; + } + packetSequenceCount = receivedSequenceCount; + return RETURN_OK; } diff --git a/mission/devices/PlocMPSoCHandler.h b/mission/devices/PlocMPSoCHandler.h index 2b3f6a57..2b14424f 100644 --- a/mission/devices/PlocMPSoCHandler.h +++ b/mission/devices/PlocMPSoCHandler.h @@ -3,6 +3,7 @@ #include #include + #include /** @@ -18,189 +19,194 @@ * Arbeitsdaten/08_Used%20Components/PLOC&fileid=940960 * @author J. Meier */ -class PlocMPSoCHandler: public DeviceHandlerBase { -public: +class PlocMPSoCHandler : public DeviceHandlerBase { + public: + PlocMPSoCHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + virtual ~PlocMPSoCHandler(); - PlocMPSoCHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); - virtual ~PlocMPSoCHandler(); + /** + * @brief Sets mode to MODE_NORMAL. Can be used for debugging. + */ + void setModeNormal(); - /** - * @brief Sets mode to MODE_NORMAL. Can be used for debugging. - */ - void setModeNormal(); + 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: - void doStartUp() override; - void doShutDown() override; - ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; - ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override; - void fillCommandAndReplyMap() override; - ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t * commandData,size_t commandDataLen) override; - ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize, - DeviceCommandId_t *foundId, size_t *foundLen) override; - ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) override; - void setNormalDatapoolEntriesInvalid() override; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; - ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator command, - uint8_t expectedReplies = 1, bool useAlternateId = false, - DeviceCommandId_t alternateReplyID = 0) override; - size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MPSOC_HANDLER; -private: + static const ReturnValue_t CRC_FAILURE = + MAKE_RETURN_CODE(0xA0); //!> Space Packet received from PLOC has invalid CRC + static const ReturnValue_t RECEIVED_ACK_FAILURE = + MAKE_RETURN_CODE(0xA1); //!> Received ACK failure reply from PLOC + static const ReturnValue_t RECEIVED_EXE_FAILURE = + MAKE_RETURN_CODE(0xA2); //!> Received execution failure reply from PLOC + static const ReturnValue_t INVALID_APID = + MAKE_RETURN_CODE(0xA3); //!> Received space packet with invalid APID from PLOC - static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MPSOC_HANDLER; + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MPSOC_HANDLER; - static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0); //!> Space Packet received from PLOC has invalid CRC - static const ReturnValue_t RECEIVED_ACK_FAILURE = MAKE_RETURN_CODE(0xA1); //!> Received ACK failure reply from PLOC - static const ReturnValue_t RECEIVED_EXE_FAILURE = MAKE_RETURN_CODE(0xA2); //!> Received execution failure reply from PLOC - static const ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(0xA3); //!> Received space packet with invalid APID from PLOC + static const Event MEMORY_READ_RPT_CRC_FAILURE = + MAKE_EVENT(1, severity::LOW); //!> PLOC crc failure in telemetry packet + static const Event ACK_FAILURE = + MAKE_EVENT(2, severity::LOW); //!> PLOC receive acknowledgment failure report + static const Event EXE_FAILURE = + MAKE_EVENT(3, severity::LOW); //!> PLOC receive execution failure report + static const Event CRC_FAILURE_EVENT = + MAKE_EVENT(4, severity::LOW); //!> PLOC reply has invalid crc - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MPSOC_HANDLER; + static const uint16_t APID_MASK = 0x7FF; + static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF; - static const Event MEMORY_READ_RPT_CRC_FAILURE = MAKE_EVENT(1, severity::LOW); //!> PLOC crc failure in telemetry packet - static const Event ACK_FAILURE = MAKE_EVENT(2, severity::LOW); //!> PLOC receive acknowledgment failure report - static const Event EXE_FAILURE = MAKE_EVENT(3, severity::LOW); //!> PLOC receive execution failure report - static const Event CRC_FAILURE_EVENT = MAKE_EVENT(4, severity::LOW); //!> PLOC reply has invalid crc + uint8_t commandBuffer[PLOC_MPSOC::MAX_COMMAND_SIZE]; - static const uint16_t APID_MASK = 0x7FF; - static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF; + /** + * @brief This object is incremented each time a packet is sent or received. By checking the + * packet sequence count of a received packet, no packets can be lost without noticing + * it. Only the least significant 14 bits represent the packet sequence count in a + * space packet. Thus the maximum value amounts to 16383 (0x3FFF). + * @note Normally this should never happen because the PLOC replies are always sent in a + * fixed order. However, the PLOC software checks this value and will return an ACK + * failure report in case the sequence count is not incremented with each transferred + * space packet. + */ + uint16_t packetSequenceCount = 0x3FFF; - uint8_t commandBuffer[PLOC_MPSOC::MAX_COMMAND_SIZE]; + /** + * 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_MPSOC::NONE; - /** - * @brief This object is incremented each time a packet is sent or received. By checking the - * packet sequence count of a received packet, no packets can be lost without noticing - * it. Only the least significant 14 bits represent the packet sequence count in a - * space packet. Thus the maximum value amounts to 16383 (0x3FFF). - * @note Normally this should never happen because the PLOC replies are always sent in a - * fixed order. However, the PLOC software checks this value and will return an ACK - * failure report in case the sequence count is not incremented with each transferred - * space packet. - */ - uint16_t packetSequenceCount = 0x3FFF; + /** + * @brief This function fills the commandBuffer to initiate the write memory command. + * + * @param commandData Pointer to action command data. + * @param commanDataLen Size of command data in bytes. + * + * @return RETURN_OK if successful, else RETURN_FAILURE. + */ + ReturnValue_t prepareTcMemWriteCommand(const uint8_t* commandData, size_t commandDataLen); - /** - * 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_MPSOC::NONE; + /** + * @brief This function fills the commandBuffer to initiate the write reads command. + * + * @param commandData Pointer to action command data. + * @param commanDataLen Size of command data in bytes. + * + * @return RETURN_OK if successful, else RETURN_FAILURE. + */ + ReturnValue_t prepareTcMemReadCommand(const uint8_t* commandData, size_t commandDataLen); - /** - * @brief This function fills the commandBuffer to initiate the write memory command. - * - * @param commandData Pointer to action command data. - * @param commanDataLen Size of command data in bytes. - * - * @return RETURN_OK if successful, else RETURN_FAILURE. - */ - ReturnValue_t prepareTcMemWriteCommand(const uint8_t * commandData, size_t commandDataLen); + /** + * @brief This function checks the crc of the received PLOC reply. + * + * @param start Pointer to the first byte of the reply. + * @param foundLen Pointer to the length of the whole packet. + * + * @return RETURN_OK if CRC is ok, otherwise CRC_FAILURE. + */ + ReturnValue_t verifyPacket(const uint8_t* start, size_t foundLen); - /** - * @brief This function fills the commandBuffer to initiate the write reads command. - * - * @param commandData Pointer to action command data. - * @param commanDataLen Size of command data in bytes. - * - * @return RETURN_OK if successful, else RETURN_FAILURE. - */ - ReturnValue_t prepareTcMemReadCommand(const uint8_t * commandData, size_t commandDataLen); + /** + * @brief This function handles the acknowledgment report. + * + * @param data Pointer to the data holding the acknowledgment report. + * + * @return RETURN_OK if successful, otherwise an error code. + */ + ReturnValue_t handleAckReport(const uint8_t* data); - /** - * @brief This function checks the crc of the received PLOC reply. - * - * @param start Pointer to the first byte of the reply. - * @param foundLen Pointer to the length of the whole packet. - * - * @return RETURN_OK if CRC is ok, otherwise CRC_FAILURE. - */ - ReturnValue_t verifyPacket(const uint8_t* start, size_t foundLen); + /** + * @brief This function handles the data of a execution report. + * + * @param data Pointer to the received data packet. + * + * @return RETURN_OK if successful, otherwise an error code. + */ + ReturnValue_t handleExecutionReport(const uint8_t* data); - /** - * @brief This function handles the acknowledgment report. - * - * @param data Pointer to the data holding the acknowledgment report. - * - * @return RETURN_OK if successful, otherwise an error code. - */ - ReturnValue_t handleAckReport(const uint8_t* data); + /** + * @brief This function handles the memory read report. + * + * @param data Pointer to the data buffer holding the memory read report. + * + * @return RETURN_OK if successful, otherwise an error code. + */ + ReturnValue_t handleMemoryReadReport(const uint8_t* data); - /** - * @brief This function handles the data of a execution report. - * - * @param data Pointer to the received data packet. - * - * @return RETURN_OK if successful, otherwise an error code. - */ - ReturnValue_t handleExecutionReport(const uint8_t* data); + /** + * @brief Depending on the current active command, this function sets the reply id of the + * next reply after a successful acknowledgment report has been received. This is + * required by the function getNextReplyLength() to identify the length of the next + * reply to read. + */ + void setNextReplyId(); - /** - * @brief This function handles the memory read report. - * - * @param data Pointer to the data buffer holding the memory read report. - * - * @return RETURN_OK if successful, otherwise an error code. - */ - ReturnValue_t handleMemoryReadReport(const uint8_t* data); + /** + * @brief This function handles action message replies in case the telemetry has been + * requested by another object. + * + * @param data Pointer to the telemetry data. + * @param dataSize Size of telemetry in bytes. + * @param replyId Id of the reply. This will be added to the ActionMessage. + */ + void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); - /** - * @brief Depending on the current active command, this function sets the reply id of the - * next reply after a successful acknowledgment report has been received. This is - * required by the function getNextReplyLength() to identify the length of the next - * reply to read. - */ - void setNextReplyId(); + /** + * @brief In case an acknowledgment failure reply has been received this function disables + * all previously enabled commands and resets the exepected replies variable of an + * active command. + */ + void disableAllReplies(); - /** - * @brief This function handles action message replies in case the telemetry has been - * requested by another object. - * - * @param data Pointer to the telemetry data. - * @param dataSize Size of telemetry in bytes. - * @param replyId Id of the reply. This will be added to the ActionMessage. - */ - void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); + /** + * @brief This function sends a failure report if the active action was commanded by an other + * object. + * + * @param replyId The id of the reply which signals a failure. + * @param status A status byte which gives information about the failure type. + */ + void sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status); - /** - * @brief In case an acknowledgment failure reply has been received this function disables - * all previously enabled commands and resets the exepected replies variable of an - * active command. - */ - void disableAllReplies(); + /** + * @brief This function disables the execution report reply. Within this function also the + * the variable expectedReplies of an active command will be set to 0. + */ + void disableExeReportReply(); - /** - * @brief This function sends a failure report if the active action was commanded by an other - * object. - * - * @param replyId The id of the reply which signals a failure. - * @param status A status byte which gives information about the failure type. - */ - void sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status); - - /** - * @brief This function disables the execution report reply. Within this function also the - * the variable expectedReplies of an active command will be set to 0. - */ - void disableExeReportReply(); - - /** - * @brief This function checks and increments the packet sequence count of a received space - * packet. - * - * @param data Pointer to a space packet. - * - * @return RETURN_OK if successful - * - * @details There should be never a case in which a wrong packet sequence count is received - * because the communication scheme between PLOC and OBC always follows a strict - * procedure. Thus this function mainly serves for debugging purposes to detected an - * invalid handling of the packet sequence count. - */ - ReturnValue_t checkPacketSequenceCount(const uint8_t* data); + /** + * @brief This function checks and increments the packet sequence count of a received space + * packet. + * + * @param data Pointer to a space packet. + * + * @return RETURN_OK if successful + * + * @details There should be never a case in which a wrong packet sequence count is received + * because the communication scheme between PLOC and OBC always follows a strict + * procedure. Thus this function mainly serves for debugging purposes to detected an + * invalid handling of the packet sequence count. + */ + ReturnValue_t checkPacketSequenceCount(const uint8_t* data); }; #endif /* MISSION_DEVICES_PLOCMPSOCHANDLER_H_ */ diff --git a/mission/devices/RadiationSensorHandler.cpp b/mission/devices/RadiationSensorHandler.cpp index 95f045d8..83720b53 100644 --- a/mission/devices/RadiationSensorHandler.cpp +++ b/mission/devices/RadiationSensorHandler.cpp @@ -1,196 +1,177 @@ +#include #include #include -#include RadiationSensorHandler::RadiationSensorHandler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie) : - DeviceHandlerBase(objectId, comIF, comCookie), dataset( - this) { - if (comCookie == NULL) { - sif::error << "RadiationSensorHandler: Invalid com cookie" << std::endl; - } + CookieIF *comCookie) + : DeviceHandlerBase(objectId, comIF, comCookie), dataset(this) { + if (comCookie == NULL) { + sif::error << "RadiationSensorHandler: Invalid com cookie" << std::endl; + } } -RadiationSensorHandler::~RadiationSensorHandler() { -} +RadiationSensorHandler::~RadiationSensorHandler() {} - -void RadiationSensorHandler::doStartUp(){ - if (internalState == InternalState::CONFIGURED) { +void RadiationSensorHandler::doStartUp() { + if (internalState == InternalState::CONFIGURED) { #if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 - setMode(MODE_NORMAL); + setMode(MODE_NORMAL); #else - setMode(_MODE_TO_ON); + setMode(_MODE_TO_ON); #endif - } + } } -void RadiationSensorHandler::doShutDown(){ - setMode(_MODE_POWER_DOWN); -} +void RadiationSensorHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } -ReturnValue_t RadiationSensorHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - - switch (communicationStep) { +ReturnValue_t RadiationSensorHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + switch (communicationStep) { case CommunicationStep::START_CONVERSION: { - *id = RAD_SENSOR::START_CONVERSION; - communicationStep = CommunicationStep::READ_CONVERSIONS; - break; + *id = RAD_SENSOR::START_CONVERSION; + communicationStep = CommunicationStep::READ_CONVERSIONS; + break; } case CommunicationStep::READ_CONVERSIONS: { - *id = RAD_SENSOR::READ_CONVERSIONS; - communicationStep = CommunicationStep::START_CONVERSION; - break; + *id = RAD_SENSOR::READ_CONVERSIONS; + communicationStep = CommunicationStep::START_CONVERSION; + break; } default: { - sif::debug << "RadiationSensorHandler::buildNormalDeviceCommand: Unknown communication " - << "step" << std::endl; - return HasReturnvaluesIF::RETURN_OK; + sif::debug << "RadiationSensorHandler::buildNormalDeviceCommand: Unknown communication " + << "step" << std::endl; + return HasReturnvaluesIF::RETURN_OK; } - } - return buildCommandFromCommand(*id, nullptr, 0); + } + return buildCommandFromCommand(*id, nullptr, 0); } -ReturnValue_t RadiationSensorHandler::buildTransitionDeviceCommand( - DeviceCommandId_t * id){ - if (internalState == InternalState::SETUP) { - *id = RAD_SENSOR::WRITE_SETUP; - } - else { - return NOTHING_TO_SEND; - } - return buildCommandFromCommand(*id, nullptr, 0); +ReturnValue_t RadiationSensorHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { + if (internalState == InternalState::SETUP) { + *id = RAD_SENSOR::WRITE_SETUP; + } else { + return NOTHING_TO_SEND; + } + return buildCommandFromCommand(*id, nullptr, 0); } -ReturnValue_t RadiationSensorHandler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t * commandData, - size_t commandDataLen) { - switch(deviceCommand) { - case(RAD_SENSOR::WRITE_SETUP): { - cmdBuffer[0] = RAD_SENSOR::SETUP_DEFINITION; - rawPacket = cmdBuffer; - rawPacketLen = 1; - internalState = InternalState::CONFIGURED; - return RETURN_OK; +ReturnValue_t RadiationSensorHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, + size_t commandDataLen) { + switch (deviceCommand) { + case (RAD_SENSOR::WRITE_SETUP): { + cmdBuffer[0] = RAD_SENSOR::SETUP_DEFINITION; + rawPacket = cmdBuffer; + rawPacketLen = 1; + internalState = InternalState::CONFIGURED; + return RETURN_OK; } - case(RAD_SENSOR::START_CONVERSION): { - /* First the fifo will be reset here */ - cmdBuffer[0] = RAD_SENSOR::RESET_DEFINITION; - cmdBuffer[1] = RAD_SENSOR::CONVERSION_DEFINITION; - rawPacket = cmdBuffer; - rawPacketLen = 2; - return RETURN_OK; + case (RAD_SENSOR::START_CONVERSION): { + /* First the fifo will be reset here */ + cmdBuffer[0] = RAD_SENSOR::RESET_DEFINITION; + cmdBuffer[1] = RAD_SENSOR::CONVERSION_DEFINITION; + rawPacket = cmdBuffer; + rawPacketLen = 2; + return RETURN_OK; } - case(RAD_SENSOR::READ_CONVERSIONS): { - cmdBuffer[0] = RAD_SENSOR::DUMMY_BYTE; - std::memset(cmdBuffer, RAD_SENSOR::DUMMY_BYTE, RAD_SENSOR::READ_SIZE); - rawPacket = cmdBuffer; - rawPacketLen = RAD_SENSOR::READ_SIZE; - return RETURN_OK; + case (RAD_SENSOR::READ_CONVERSIONS): { + cmdBuffer[0] = RAD_SENSOR::DUMMY_BYTE; + std::memset(cmdBuffer, RAD_SENSOR::DUMMY_BYTE, RAD_SENSOR::READ_SIZE); + rawPacket = cmdBuffer; + rawPacketLen = RAD_SENSOR::READ_SIZE; + return RETURN_OK; } -// case(RAD_SENSOR::AIN0_AND_TMP_CONVERSION): { -// /* First the fifo will be reset here */ -// cmdBuffer[0] = RAD_SENSOR::RESET_DEFINITION; -// cmdBuffer[1] = RAD_SENSOR::CONVERSION_DEFINITION; -// rawPacket = cmdBuffer; -// rawPacketLen = 2; -// return RETURN_OK; -// } + // case(RAD_SENSOR::AIN0_AND_TMP_CONVERSION): { + // /* First the fifo will be reset here */ + // cmdBuffer[0] = RAD_SENSOR::RESET_DEFINITION; + // cmdBuffer[1] = RAD_SENSOR::CONVERSION_DEFINITION; + // rawPacket = cmdBuffer; + // rawPacketLen = 2; + // return RETURN_OK; + // } default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } void RadiationSensorHandler::fillCommandAndReplyMap() { - this->insertInCommandMap(RAD_SENSOR::WRITE_SETUP); - this->insertInCommandMap(RAD_SENSOR::START_CONVERSION); - this->insertInCommandAndReplyMap(RAD_SENSOR::READ_CONVERSIONS, 1, &dataset, - RAD_SENSOR::READ_SIZE); + this->insertInCommandMap(RAD_SENSOR::WRITE_SETUP); + this->insertInCommandMap(RAD_SENSOR::START_CONVERSION); + this->insertInCommandAndReplyMap(RAD_SENSOR::READ_CONVERSIONS, 1, &dataset, + RAD_SENSOR::READ_SIZE); } -ReturnValue_t RadiationSensorHandler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { - *foundId = this->getPendingCommand(); +ReturnValue_t RadiationSensorHandler::scanForReply(const uint8_t *start, size_t remainingSize, + DeviceCommandId_t *foundId, size_t *foundLen) { + *foundId = this->getPendingCommand(); - switch (*foundId) { + switch (*foundId) { case RAD_SENSOR::START_CONVERSION: case RAD_SENSOR::WRITE_SETUP: - return IGNORE_REPLY_DATA; + return IGNORE_REPLY_DATA; default: - break; - } + break; + } - *foundLen = remainingSize; + *foundLen = remainingSize; - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t RadiationSensorHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { - switch (id) { + const uint8_t *packet) { + switch (id) { case RAD_SENSOR::READ_CONVERSIONS: { - uint8_t offset = 0; - PoolReadGuard readSet(&dataset); - dataset.temperatureCelcius = (*(packet + offset) << 8 | *(packet + offset + 1)) * 0.125; - offset += 2; - dataset.ain0 = (*(packet + offset) << 8 | *(packet + offset +1)); - offset += 2; - dataset.ain1 = (*(packet + offset) << 8 | *(packet + offset + 1)); - offset += 6; - dataset.ain4 = (*(packet + offset) << 8 | *(packet + offset + 1)); - offset += 2; - dataset.ain5 = (*(packet + offset) << 8 | *(packet + offset + 1)); - offset += 2; - dataset.ain6 = (*(packet + offset) << 8 | *(packet + offset + 1)); - offset += 2; - dataset.ain7 = (*(packet + offset) << 8 | *(packet + offset + 1)); + uint8_t offset = 0; + PoolReadGuard readSet(&dataset); + dataset.temperatureCelcius = (*(packet + offset) << 8 | *(packet + offset + 1)) * 0.125; + offset += 2; + dataset.ain0 = (*(packet + offset) << 8 | *(packet + offset + 1)); + offset += 2; + dataset.ain1 = (*(packet + offset) << 8 | *(packet + offset + 1)); + offset += 6; + dataset.ain4 = (*(packet + offset) << 8 | *(packet + offset + 1)); + offset += 2; + dataset.ain5 = (*(packet + offset) << 8 | *(packet + offset + 1)); + offset += 2; + dataset.ain6 = (*(packet + offset) << 8 | *(packet + offset + 1)); + offset += 2; + dataset.ain7 = (*(packet + offset) << 8 | *(packet + offset + 1)); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RAD_SENSOR - sif::info << "Radiation sensor temperature: " << dataset.temperatureCelcius << " °C" - << std::endl; - sif::info << "Radiation sensor ADC value channel 0: " << dataset.ain0 - << std::endl; - sif::info << "Radiation sensor ADC value channel 1: " << dataset.ain1 - << std::endl; - sif::info << "Radiation sensor ADC value channel 4: " << dataset.ain4 - << std::endl; - sif::info << "Radiation sensor ADC value channel 5: " << dataset.ain5 - << std::endl; - sif::info << "Radiation sensor ADC value channel 6: " << dataset.ain6 - << std::endl; - sif::info << "Radiation sensor ADC value channel 7: " << dataset.ain7 + sif::info << "Radiation sensor temperature: " << dataset.temperatureCelcius << " °C" << std::endl; + sif::info << "Radiation sensor ADC value channel 0: " << dataset.ain0 << std::endl; + sif::info << "Radiation sensor ADC value channel 1: " << dataset.ain1 << std::endl; + sif::info << "Radiation sensor ADC value channel 4: " << dataset.ain4 << std::endl; + sif::info << "Radiation sensor ADC value channel 5: " << dataset.ain5 << std::endl; + sif::info << "Radiation sensor ADC value channel 6: " << dataset.ain6 << std::endl; + sif::info << "Radiation sensor ADC value channel 7: " << dataset.ain7 << std::endl; #endif - break; + break; } default: { - sif::debug << "RadiationSensorHandler::interpretDeviceReply: Unknown reply id" << std::endl; - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; + sif::debug << "RadiationSensorHandler::interpretDeviceReply: Unknown reply id" << std::endl; + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; } - - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } -void RadiationSensorHandler::setNormalDatapoolEntriesInvalid(){ +void RadiationSensorHandler::setNormalDatapoolEntriesInvalid() {} +uint32_t RadiationSensorHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { + return 5000; } -uint32_t RadiationSensorHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){ - return 5000; +ReturnValue_t RadiationSensorHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(RAD_SENSOR::TEMPERATURE_C, new PoolEntry({0.0})); + localDataPoolMap.emplace(RAD_SENSOR::AIN0, new PoolEntry({0})); + localDataPoolMap.emplace(RAD_SENSOR::AIN1, new PoolEntry({0})); + localDataPoolMap.emplace(RAD_SENSOR::AIN4, new PoolEntry({0})); + localDataPoolMap.emplace(RAD_SENSOR::AIN5, new PoolEntry({0})); + localDataPoolMap.emplace(RAD_SENSOR::AIN6, new PoolEntry({0})); + localDataPoolMap.emplace(RAD_SENSOR::AIN7, new PoolEntry({0})); + return HasReturnvaluesIF::RETURN_OK; } - -ReturnValue_t RadiationSensorHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { - localDataPoolMap.emplace(RAD_SENSOR::TEMPERATURE_C, new PoolEntry( { 0.0 })); - localDataPoolMap.emplace(RAD_SENSOR::AIN0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RAD_SENSOR::AIN1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RAD_SENSOR::AIN4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RAD_SENSOR::AIN5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RAD_SENSOR::AIN6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RAD_SENSOR::AIN7, new PoolEntry( { 0 })); - return HasReturnvaluesIF::RETURN_OK; -} - diff --git a/mission/devices/RadiationSensorHandler.h b/mission/devices/RadiationSensorHandler.h index 5612a1e0..fe4e4264 100644 --- a/mission/devices/RadiationSensorHandler.h +++ b/mission/devices/RadiationSensorHandler.h @@ -5,56 +5,46 @@ #include /** - * @brief This is the device handler class for radiation sensor on the OBC IF Board. The sensor - * is based on the MAX1227 ADC converter. + * @brief This is the device handler class for radiation sensor on the OBC IF Board. The + * sensor is based on the MAX1227 ADC converter. * * @details Datasheet of MAX1227: https://datasheets.maximintegrated.com/en/ds/MAX1227-MAX1231.pdf * * @author J. Meier */ -class RadiationSensorHandler: public DeviceHandlerBase { -public: +class RadiationSensorHandler : public DeviceHandlerBase { + public: + RadiationSensorHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie); + virtual ~RadiationSensorHandler(); - RadiationSensorHandler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie); - virtual ~RadiationSensorHandler(); + 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; -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; + private: + enum class CommunicationStep { START_CONVERSION, READ_CONVERSIONS }; -private: + enum class InternalState { SETUP, CONFIGURED }; - enum class CommunicationStep { - START_CONVERSION, - READ_CONVERSIONS - }; + RAD_SENSOR::RadSensorDataset dataset; - enum class InternalState { - SETUP, - CONFIGURED - }; + static const uint8_t MAX_CMD_LEN = RAD_SENSOR::READ_SIZE; - RAD_SENSOR::RadSensorDataset dataset; - - static const uint8_t MAX_CMD_LEN = RAD_SENSOR::READ_SIZE; - - uint8_t cmdBuffer[MAX_CMD_LEN]; - InternalState internalState = InternalState::SETUP; - CommunicationStep communicationStep = CommunicationStep::START_CONVERSION; + uint8_t cmdBuffer[MAX_CMD_LEN]; + InternalState internalState = InternalState::SETUP; + CommunicationStep communicationStep = CommunicationStep::START_CONVERSION; }; #endif /* MISSION_DEVICES_RADIATIONSENSORHANDLER_H_ */ diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index c848c809..f3cd0737 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -1,526 +1,523 @@ #include "RwHandler.h" + +#include +#include + #include "OBSWConfig.h" -#include -#include - -RwHandler::RwHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie, - LinuxLibgpioIF* gpioComIF, gpioId_t enableGpio) : - DeviceHandlerBase(objectId, comIF, comCookie), gpioComIF(gpioComIF), enableGpio(enableGpio), - temperatureSet(this), statusSet(this), lastResetStatusSet(this), tmDataset(this) { - if (comCookie == NULL) { - sif::error << "RwHandler: Invalid com cookie" << std::endl; - } - if (gpioComIF == NULL) { - sif::error << "RwHandler: Invalid gpio communication interface" << std::endl; - } +RwHandler::RwHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, + LinuxLibgpioIF* gpioComIF, gpioId_t enableGpio) + : DeviceHandlerBase(objectId, comIF, comCookie), + gpioComIF(gpioComIF), + enableGpio(enableGpio), + temperatureSet(this), + statusSet(this), + lastResetStatusSet(this), + tmDataset(this) { + if (comCookie == NULL) { + sif::error << "RwHandler: Invalid com cookie" << std::endl; + } + if (gpioComIF == NULL) { + sif::error << "RwHandler: Invalid gpio communication interface" << std::endl; + } } -RwHandler::~RwHandler() { -} +RwHandler::~RwHandler() {} void RwHandler::doStartUp() { + internalState = InternalState::GET_RESET_STATUS; - internalState = InternalState::GET_RESET_STATUS; - - if(gpioComIF->pullHigh(enableGpio) != RETURN_OK) { - sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to high"; - } + if (gpioComIF->pullHigh(enableGpio) != RETURN_OK) { + sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to high"; + } #if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 - setMode(MODE_NORMAL); + setMode(MODE_NORMAL); #else - setMode(_MODE_TO_ON); + setMode(_MODE_TO_ON); #endif } void RwHandler::doShutDown() { - if(gpioComIF->pullLow(enableGpio) != RETURN_OK) { - sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to low"; - } - setMode(_MODE_POWER_DOWN); + if (gpioComIF->pullLow(enableGpio) != RETURN_OK) { + sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to low"; + } + setMode(_MODE_POWER_DOWN); } -ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) { - switch (internalState) { +ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + switch (internalState) { case InternalState::GET_RESET_STATUS: - *id = RwDefinitions::GET_LAST_RESET_STATUS; - internalState = InternalState::READ_TEMPERATURE; - break; + *id = RwDefinitions::GET_LAST_RESET_STATUS; + internalState = InternalState::READ_TEMPERATURE; + break; case InternalState::CLEAR_RESET_STATUS: - *id = RwDefinitions::CLEAR_LAST_RESET_STATUS; - /** After reset status is cleared, reset status will be polled again for verification */ - internalState = InternalState::GET_RESET_STATUS; - break; + *id = RwDefinitions::CLEAR_LAST_RESET_STATUS; + /** After reset status is cleared, reset status will be polled again for verification */ + internalState = InternalState::GET_RESET_STATUS; + break; case InternalState::READ_TEMPERATURE: - *id = RwDefinitions::GET_TEMPERATURE; - internalState = InternalState::GET_RW_SATUS; - break; + *id = RwDefinitions::GET_TEMPERATURE; + internalState = InternalState::GET_RW_SATUS; + break; case InternalState::GET_RW_SATUS: - *id = RwDefinitions::GET_RW_STATUS; - internalState = InternalState::GET_RESET_STATUS; - break; + *id = RwDefinitions::GET_RW_STATUS; + internalState = InternalState::GET_RESET_STATUS; + break; default: - sif::debug << "RwHandler::buildNormalDeviceCommand: Invalid internal step" - << std::endl; - break; - } - return buildCommandFromCommand(*id, NULL, 0); + sif::debug << "RwHandler::buildNormalDeviceCommand: Invalid internal step" << std::endl; + break; + } + return buildCommandFromCommand(*id, NULL, 0); } -ReturnValue_t RwHandler::buildTransitionDeviceCommand(DeviceCommandId_t * id) { - return NOTHING_TO_SEND; +ReturnValue_t RwHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { + return NOTHING_TO_SEND; } ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t * commandData, size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; + const uint8_t* commandData, + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; - switch (deviceCommand) { + switch (deviceCommand) { case (RwDefinitions::RESET_MCU): { - prepareSimpleCommand(deviceCommand); - return RETURN_OK; + prepareSimpleCommand(deviceCommand); + return RETURN_OK; } case (RwDefinitions::GET_LAST_RESET_STATUS): { - prepareSimpleCommand(deviceCommand); - return RETURN_OK; + prepareSimpleCommand(deviceCommand); + return RETURN_OK; } case (RwDefinitions::CLEAR_LAST_RESET_STATUS): { - prepareSimpleCommand(deviceCommand); - return RETURN_OK; + prepareSimpleCommand(deviceCommand); + return RETURN_OK; } case (RwDefinitions::GET_RW_STATUS): { - prepareSimpleCommand(deviceCommand); - return RETURN_OK; + prepareSimpleCommand(deviceCommand); + return RETURN_OK; } case (RwDefinitions::INIT_RW_CONTROLLER): { - prepareSimpleCommand(deviceCommand); - return RETURN_OK; + prepareSimpleCommand(deviceCommand); + return RETURN_OK; } case (RwDefinitions::SET_SPEED): { - if (commandDataLen != 6) { - sif::error << "RwHandler::buildCommandFromCommand: Received set speed command with" - << " invalid length" << std::endl; - return SET_SPEED_COMMAND_INVALID_LENGTH; - } - result = checkSpeedAndRampTime(commandData, commandDataLen); - if (result != RETURN_OK) { - return result; - } - prepareSetSpeedCmd(commandData, commandDataLen); + if (commandDataLen != 6) { + sif::error << "RwHandler::buildCommandFromCommand: Received set speed command with" + << " invalid length" << std::endl; + return SET_SPEED_COMMAND_INVALID_LENGTH; + } + result = checkSpeedAndRampTime(commandData, commandDataLen); + if (result != RETURN_OK) { return result; + } + prepareSetSpeedCmd(commandData, commandDataLen); + return result; } case (RwDefinitions::GET_TEMPERATURE): { - prepareSimpleCommand(deviceCommand); - return RETURN_OK; + prepareSimpleCommand(deviceCommand); + return RETURN_OK; } case (RwDefinitions::GET_TM): { - prepareSimpleCommand(deviceCommand); - return RETURN_OK; + prepareSimpleCommand(deviceCommand); + return RETURN_OK; } default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } void RwHandler::fillCommandAndReplyMap() { - this->insertInCommandMap(RwDefinitions::RESET_MCU); - this->insertInCommandAndReplyMap(RwDefinitions::GET_LAST_RESET_STATUS, 1, &lastResetStatusSet, - RwDefinitions::SIZE_GET_RESET_STATUS); - this->insertInCommandAndReplyMap(RwDefinitions::CLEAR_LAST_RESET_STATUS, 1, nullptr, - RwDefinitions::SIZE_CLEAR_RESET_STATUS); - this->insertInCommandAndReplyMap(RwDefinitions::GET_RW_STATUS, 1, &statusSet, - RwDefinitions::SIZE_GET_RW_STATUS); - this->insertInCommandAndReplyMap(RwDefinitions::INIT_RW_CONTROLLER, 1, nullptr, - RwDefinitions::SIZE_INIT_RW); - this->insertInCommandAndReplyMap(RwDefinitions::GET_TEMPERATURE, 1, &temperatureSet, - RwDefinitions::SIZE_GET_TEMPERATURE_REPLY); - this->insertInCommandAndReplyMap(RwDefinitions::SET_SPEED, 1, nullptr, - RwDefinitions::SIZE_SET_SPEED_REPLY); - this->insertInCommandAndReplyMap(RwDefinitions::GET_TM, 1, &tmDataset, - RwDefinitions::SIZE_GET_TELEMETRY_REPLY); + this->insertInCommandMap(RwDefinitions::RESET_MCU); + this->insertInCommandAndReplyMap(RwDefinitions::GET_LAST_RESET_STATUS, 1, &lastResetStatusSet, + RwDefinitions::SIZE_GET_RESET_STATUS); + this->insertInCommandAndReplyMap(RwDefinitions::CLEAR_LAST_RESET_STATUS, 1, nullptr, + RwDefinitions::SIZE_CLEAR_RESET_STATUS); + this->insertInCommandAndReplyMap(RwDefinitions::GET_RW_STATUS, 1, &statusSet, + RwDefinitions::SIZE_GET_RW_STATUS); + this->insertInCommandAndReplyMap(RwDefinitions::INIT_RW_CONTROLLER, 1, nullptr, + RwDefinitions::SIZE_INIT_RW); + this->insertInCommandAndReplyMap(RwDefinitions::GET_TEMPERATURE, 1, &temperatureSet, + RwDefinitions::SIZE_GET_TEMPERATURE_REPLY); + this->insertInCommandAndReplyMap(RwDefinitions::SET_SPEED, 1, nullptr, + RwDefinitions::SIZE_SET_SPEED_REPLY); + this->insertInCommandAndReplyMap(RwDefinitions::GET_TM, 1, &tmDataset, + RwDefinitions::SIZE_GET_TELEMETRY_REPLY); } -ReturnValue_t RwHandler::scanForReply(const uint8_t *start, size_t remainingSize, - DeviceCommandId_t *foundId, size_t *foundLen) { - uint8_t replyByte = *start; - switch (replyByte) { +ReturnValue_t RwHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + uint8_t replyByte = *start; + switch (replyByte) { case (RwDefinitions::GET_LAST_RESET_STATUS): { - *foundLen = RwDefinitions::SIZE_GET_RESET_STATUS; - *foundId = RwDefinitions::GET_LAST_RESET_STATUS; - break; + *foundLen = RwDefinitions::SIZE_GET_RESET_STATUS; + *foundId = RwDefinitions::GET_LAST_RESET_STATUS; + break; } case (RwDefinitions::CLEAR_LAST_RESET_STATUS): { - *foundLen = RwDefinitions::SIZE_CLEAR_RESET_STATUS; - *foundId = RwDefinitions::CLEAR_LAST_RESET_STATUS; - break; + *foundLen = RwDefinitions::SIZE_CLEAR_RESET_STATUS; + *foundId = RwDefinitions::CLEAR_LAST_RESET_STATUS; + break; } case (RwDefinitions::GET_RW_STATUS): { - *foundLen = RwDefinitions::SIZE_GET_RW_STATUS; - *foundId = RwDefinitions::GET_RW_STATUS; - break; + *foundLen = RwDefinitions::SIZE_GET_RW_STATUS; + *foundId = RwDefinitions::GET_RW_STATUS; + break; } case (RwDefinitions::INIT_RW_CONTROLLER): { - *foundLen = RwDefinitions::SIZE_INIT_RW; - *foundId = RwDefinitions::INIT_RW_CONTROLLER; - break; + *foundLen = RwDefinitions::SIZE_INIT_RW; + *foundId = RwDefinitions::INIT_RW_CONTROLLER; + break; } case (RwDefinitions::SET_SPEED): { - *foundLen = RwDefinitions::SIZE_SET_SPEED_REPLY; - *foundId = RwDefinitions::SET_SPEED; - break; + *foundLen = RwDefinitions::SIZE_SET_SPEED_REPLY; + *foundId = RwDefinitions::SET_SPEED; + break; } case (RwDefinitions::GET_TEMPERATURE): { - *foundLen = RwDefinitions::SIZE_GET_TEMPERATURE_REPLY; - *foundId = RwDefinitions::GET_TEMPERATURE; - break; + *foundLen = RwDefinitions::SIZE_GET_TEMPERATURE_REPLY; + *foundId = RwDefinitions::GET_TEMPERATURE; + break; } case (RwDefinitions::GET_TM): { - *foundLen = RwDefinitions::SIZE_GET_TELEMETRY_REPLY; - *foundId = RwDefinitions::GET_TM; - break; + *foundLen = RwDefinitions::SIZE_GET_TELEMETRY_REPLY; + *foundId = RwDefinitions::GET_TM; + break; } default: { - sif::warning << "RwHandler::scanForReply: Reply contains invalid command code" << - std::endl; - *foundLen = remainingSize; - return RETURN_FAILED; - } + sif::warning << "RwHandler::scanForReply: Reply contains invalid command code" << std::endl; + *foundLen = remainingSize; + return RETURN_FAILED; } + } - sizeOfReply = *foundLen; + sizeOfReply = *foundLen; - return RETURN_OK; + return RETURN_OK; } -ReturnValue_t RwHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { +ReturnValue_t RwHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { + /** Check result code */ + if (*(packet + 1) == RwDefinitions::STATE_ERROR) { + sif::error << "RwHandler::interpretDeviceReply: Command execution failed. Command id: " << id + << std::endl; + return EXECUTION_FAILED; + } - /** Check result code */ - if (*(packet + 1) == RwDefinitions::STATE_ERROR) { - sif::error << "RwHandler::interpretDeviceReply: Command execution failed. Command id: " - << id << std::endl; - return EXECUTION_FAILED; - } + /** Received in little endian byte order */ + uint16_t replyCrc = *(packet + sizeOfReply - 1) << 8 | *(packet + sizeOfReply - 2); - /** Received in little endian byte order */ - uint16_t replyCrc = *(packet + sizeOfReply - 1) << 8 | *(packet + sizeOfReply - 2) ; + if (CRC::crc16ccitt(packet, sizeOfReply - 2, 0xFFFF) != replyCrc) { + sif::error << "RwHandler::interpretDeviceReply: cRC error" << std::endl; + return CRC_ERROR; + } - if (CRC::crc16ccitt(packet, sizeOfReply - 2, 0xFFFF) != replyCrc) { - sif::error << "RwHandler::interpretDeviceReply: cRC error" << std::endl; - return CRC_ERROR; - } - - switch (id) { + switch (id) { case (RwDefinitions::GET_LAST_RESET_STATUS): { - handleResetStatusReply(packet); - break; + handleResetStatusReply(packet); + break; } case (RwDefinitions::GET_RW_STATUS): { - handleGetRwStatusReply(packet); - break; + handleGetRwStatusReply(packet); + break; } case (RwDefinitions::CLEAR_LAST_RESET_STATUS): case (RwDefinitions::INIT_RW_CONTROLLER): case (RwDefinitions::SET_SPEED): - // no reply data expected - break; + // no reply data expected + break; case (RwDefinitions::GET_TEMPERATURE): { - handleTemperatureReply(packet); - break; + handleTemperatureReply(packet); + break; } case (RwDefinitions::GET_TM): { - handleGetTelemetryReply(packet); - break; + handleGetTelemetryReply(packet); + break; } default: { - sif::debug << "RwHandler::interpretDeviceReply: Unknown device reply id" << std::endl; - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } + sif::debug << "RwHandler::interpretDeviceReply: Unknown device reply id" << std::endl; + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; } + } - return RETURN_OK; + return RETURN_OK; } -void RwHandler::setNormalDatapoolEntriesInvalid() { +void RwHandler::setNormalDatapoolEntriesInvalid() {} -} - -uint32_t RwHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { - return 5000; -} +uint32_t RwHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 5000; } ReturnValue_t RwHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { + LocalDataPoolManager& poolManager) { + localDataPoolMap.emplace(RwDefinitions::TEMPERATURE_C, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::TEMPERATURE_C, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::CURR_SPEED, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::REFERENCE_SPEED, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::STATE, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::CLC_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::CURR_SPEED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::REFERENCE_SPEED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::CLC_MODE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::LAST_RESET_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::CURRRENT_RESET_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::LAST_RESET_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::CURRRENT_RESET_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::TM_LAST_RESET_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::TM_MCU_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::PRESSURE_SENSOR_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::PRESSURE, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::TM_RW_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::TM_CLC_MODE, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::TM_RW_CURR_SPEED, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::TM_RW_REF_SPEED, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::INVALID_CRC_PACKETS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::INVALID_LEN_PACKETS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::INVALID_CMD_PACKETS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::EXECUTED_REPLIES, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::COMMAND_REPLIES, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::UART_BYTES_WRITTEN, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::UART_BYTES_READ, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::UART_PARITY_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::UART_NOISE_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::UART_FRAME_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::UART_REG_OVERRUN_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::UART_TOTAL_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_WRITTEN, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_READ, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::SPI_REG_OVERRUN_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::SPI_TOTAL_ERRORS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::TM_LAST_RESET_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::TM_MCU_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::PRESSURE_SENSOR_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::PRESSURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::TM_RW_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::TM_CLC_MODE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::TM_RW_CURR_SPEED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::TM_RW_REF_SPEED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::INVALID_CRC_PACKETS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::INVALID_LEN_PACKETS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::INVALID_CMD_PACKETS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::EXECUTED_REPLIES, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::COMMAND_REPLIES, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::UART_BYTES_WRITTEN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::UART_BYTES_READ, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::UART_PARITY_ERRORS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::UART_NOISE_ERRORS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::UART_FRAME_ERRORS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::UART_REG_OVERRUN_ERRORS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::UART_TOTAL_ERRORS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_WRITTEN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_READ, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::SPI_REG_OVERRUN_ERRORS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::SPI_TOTAL_ERRORS, new PoolEntry( { 0 })); - - return RETURN_OK; + return RETURN_OK; } void RwHandler::prepareSimpleCommand(DeviceCommandId_t id) { - commandBuffer[0] = static_cast(id); - uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF); - commandBuffer[1] = static_cast(crc & 0xFF); - commandBuffer[2] = static_cast(crc >> 8 & 0xFF); - rawPacket = commandBuffer; - rawPacketLen = 3; + commandBuffer[0] = static_cast(id); + uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF); + commandBuffer[1] = static_cast(crc & 0xFF); + commandBuffer[2] = static_cast(crc >> 8 & 0xFF); + rawPacket = commandBuffer; + rawPacketLen = 3; } ReturnValue_t RwHandler::checkSpeedAndRampTime(const uint8_t* commandData, size_t commandDataLen) { - int32_t speed = *commandData << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 - | *(commandData + 3); + int32_t speed = + *commandData << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 | *(commandData + 3); - if ((speed < -65000 || speed > 65000 || (speed > -1000 && speed < 1000)) && (speed != 0)) { - sif::error << "RwHandler::checkSpeedAndRampTime: Command has invalid speed" << std::endl; - return INVALID_SPEED; - } + if ((speed < -65000 || speed > 65000 || (speed > -1000 && speed < 1000)) && (speed != 0)) { + sif::error << "RwHandler::checkSpeedAndRampTime: Command has invalid speed" << std::endl; + return INVALID_SPEED; + } - uint16_t rampTime = *(commandData + 4) << 8 | *(commandData + 5); + uint16_t rampTime = *(commandData + 4) << 8 | *(commandData + 5); - if (rampTime < 10 || rampTime > 10000) { - sif::error << "RwHandler::checkSpeedAndRampTime: Command has invalid ramp time" - << std::endl; - return INVALID_RAMP_TIME; - } + if (rampTime < 10 || rampTime > 10000) { + sif::error << "RwHandler::checkSpeedAndRampTime: Command has invalid ramp time" << std::endl; + return INVALID_RAMP_TIME; + } - return RETURN_OK; + return RETURN_OK; } -void RwHandler::prepareSetSpeedCmd(const uint8_t * commandData, size_t commandDataLen) { - commandBuffer[0] = static_cast(RwDefinitions::SET_SPEED); +void RwHandler::prepareSetSpeedCmd(const uint8_t* commandData, size_t commandDataLen) { + commandBuffer[0] = static_cast(RwDefinitions::SET_SPEED); - /** Speed (0.1 RPM) */ - commandBuffer[1] = *(commandData + 3); - commandBuffer[2] = *(commandData + 2); - commandBuffer[3] = *(commandData + 1); - commandBuffer[4] = *commandData; - /** Ramp time (ms) */ - commandBuffer[5] = *(commandData + 5); - commandBuffer[6] = *(commandData + 4); + /** Speed (0.1 RPM) */ + commandBuffer[1] = *(commandData + 3); + commandBuffer[2] = *(commandData + 2); + commandBuffer[3] = *(commandData + 1); + commandBuffer[4] = *commandData; + /** Ramp time (ms) */ + commandBuffer[5] = *(commandData + 5); + commandBuffer[6] = *(commandData + 4); - uint16_t crc = CRC::crc16ccitt(commandBuffer, 7, 0xFFFF); - commandBuffer[7] = static_cast(crc & 0xFF); - commandBuffer[8] = static_cast(crc >> 8 & 0xFF); - rawPacket = commandBuffer; - rawPacketLen = 9; + uint16_t crc = CRC::crc16ccitt(commandBuffer, 7, 0xFFFF); + commandBuffer[7] = static_cast(crc & 0xFF); + commandBuffer[8] = static_cast(crc >> 8 & 0xFF); + rawPacket = commandBuffer; + rawPacketLen = 9; } void RwHandler::handleResetStatusReply(const uint8_t* packet) { - PoolReadGuard rg(&lastResetStatusSet); - uint8_t offset = 2; - uint8_t resetStatus = *(packet + offset); - if (resetStatus != RwDefinitions::CLEARED) { - internalState = InternalState::CLEAR_RESET_STATUS; - lastResetStatusSet.lastResetStatus = resetStatus; - } - lastResetStatusSet.currentResetStatus = resetStatus; + PoolReadGuard rg(&lastResetStatusSet); + uint8_t offset = 2; + uint8_t resetStatus = *(packet + offset); + if (resetStatus != RwDefinitions::CLEARED) { + internalState = InternalState::CLEAR_RESET_STATUS; + lastResetStatusSet.lastResetStatus = resetStatus; + } + lastResetStatusSet.currentResetStatus = resetStatus; #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RW == 1 - sif::info << "RwHandler::handleResetStatusReply: Last reset status: " + sif::info << "RwHandler::handleResetStatusReply: Last reset status: " << static_cast(lastResetStatusSet.lastResetStatus.value) << std::endl; - sif::info << "RwHandler::handleResetStatusReply: Current reset status: " + sif::info << "RwHandler::handleResetStatusReply: Current reset status: " << static_cast(lastResetStatusSet.currentResetStatus.value) << std::endl; #endif } void RwHandler::handleGetRwStatusReply(const uint8_t* packet) { - PoolReadGuard rg(&statusSet); - uint8_t offset = 2; - statusSet.currSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - statusSet.referenceSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - statusSet.state = *(packet + offset); - offset += 1; - statusSet.clcMode = *(packet + offset); + PoolReadGuard rg(&statusSet); + uint8_t offset = 2; + statusSet.currSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + statusSet.referenceSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + statusSet.state = *(packet + offset); + offset += 1; + statusSet.clcMode = *(packet + offset); - if (statusSet.state == RwDefinitions::STATE_ERROR) { - /** - * This requires the commanding of the init reaction wheel controller command to recover - * form error state which must be handled by the FDIR instance. - */ - triggerEvent(ERROR_STATE); - sif::error << "RwHandler::handleGetRwStatusReply: Reaction wheel in error state" - << std::endl; - } + if (statusSet.state == RwDefinitions::STATE_ERROR) { + /** + * This requires the commanding of the init reaction wheel controller command to recover + * form error state which must be handled by the FDIR instance. + */ + triggerEvent(ERROR_STATE); + sif::error << "RwHandler::handleGetRwStatusReply: Reaction wheel in error state" << std::endl; + } #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RW == 1 - sif::info << "RwHandler::handleGetRwStatusReply: Current speed is: " << statusSet.currSpeed + sif::info << "RwHandler::handleGetRwStatusReply: Current speed is: " << statusSet.currSpeed << " * 0.1 RPM" << std::endl; - sif::info << "RwHandler::handleGetRwStatusReply: Reference speed is: " - << statusSet.referenceSpeed << " * 0.1 RPM" << std::endl; - sif::info << "RwHandler::handleGetRwStatusReply: State is: " - << (unsigned int) statusSet.state.value << std::endl; - sif::info << "RwHandler::handleGetRwStatusReply: clc mode is: " - << (unsigned int) statusSet.clcMode.value << std::endl; + sif::info << "RwHandler::handleGetRwStatusReply: Reference speed is: " << statusSet.referenceSpeed + << " * 0.1 RPM" << std::endl; + sif::info << "RwHandler::handleGetRwStatusReply: State is: " + << (unsigned int)statusSet.state.value << std::endl; + sif::info << "RwHandler::handleGetRwStatusReply: clc mode is: " + << (unsigned int)statusSet.clcMode.value << std::endl; #endif } void RwHandler::handleTemperatureReply(const uint8_t* packet) { - PoolReadGuard rg(&temperatureSet); - uint8_t offset = 2; - temperatureSet.temperatureCelcius = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); + PoolReadGuard rg(&temperatureSet); + uint8_t offset = 2; + temperatureSet.temperatureCelcius = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RW == 1 - sif::info << "RwHandler::handleTemperatureReply: Temperature: " + sif::info << "RwHandler::handleTemperatureReply: Temperature: " << temperatureSet.temperatureCelcius << " °C" << std::endl; #endif } void RwHandler::handleGetTelemetryReply(const uint8_t* packet) { - PoolReadGuard rg(&tmDataset); - uint8_t offset = 2; - tmDataset.lastResetStatus = *(packet + offset); - offset += 1; - tmDataset.mcuTemperature = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.pressureSensorTemperature = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.pressure = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.rwState = *(packet + offset); - offset += 1; - tmDataset.rwClcMode = *(packet + offset); - offset += 1; - tmDataset.rwCurrSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.rwRefSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.numOfInvalidCrcPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.numOfInvalidLenPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.numOfInvalidCmdPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.numOfCmdExecutedReplies = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.numOfCmdReplies = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.uartNumOfBytesWritten = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.uartNumOfBytesRead = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.uartNumOfParityErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.uartNumOfNoiseErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.uartNumOfFrameErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.uartNumOfRegisterOverrunErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.uartTotalNumOfErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.spiNumOfBytesWritten = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.spiNumOfBytesRead = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.spiNumOfRegisterOverrunErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.spiTotalNumOfErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); + PoolReadGuard rg(&tmDataset); + uint8_t offset = 2; + tmDataset.lastResetStatus = *(packet + offset); + offset += 1; + tmDataset.mcuTemperature = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.pressureSensorTemperature = *(packet + offset + 3) << 24 | + *(packet + offset + 2) << 16 | *(packet + offset + 1) << 8 | + *(packet + offset); + offset += 4; + tmDataset.pressure = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.rwState = *(packet + offset); + offset += 1; + tmDataset.rwClcMode = *(packet + offset); + offset += 1; + tmDataset.rwCurrSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.rwRefSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.numOfInvalidCrcPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.numOfInvalidLenPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.numOfInvalidCmdPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.numOfCmdExecutedReplies = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.numOfCmdReplies = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartNumOfBytesWritten = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartNumOfBytesRead = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartNumOfParityErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartNumOfNoiseErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartNumOfFrameErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartNumOfRegisterOverrunErrors = *(packet + offset + 3) << 24 | + *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartTotalNumOfErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.spiNumOfBytesWritten = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.spiNumOfBytesRead = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.spiNumOfRegisterOverrunErrors = *(packet + offset + 3) << 24 | + *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.spiTotalNumOfErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RW == 1 - sif::info << "RwHandler::handleTemperatureReply: Last reset status: " + sif::info << "RwHandler::handleTemperatureReply: Last reset status: " << static_cast(tmDataset.lastResetStatus.value) << std::endl; - sif::info << "RwHandler::handleTemperatureReply: MCU temperature: " << tmDataset.mcuTemperature + sif::info << "RwHandler::handleTemperatureReply: MCU temperature: " << tmDataset.mcuTemperature << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Pressure sensor temperature: " + sif::info << "RwHandler::handleTemperatureReply: Pressure sensor temperature: " << tmDataset.pressureSensorTemperature << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Pressure " - << tmDataset.pressure << std::endl; - sif::info << "RwHandler::handleTemperatureReply: State: " + sif::info << "RwHandler::handleTemperatureReply: Pressure " << tmDataset.pressure << std::endl; + sif::info << "RwHandler::handleTemperatureReply: State: " << static_cast(tmDataset.rwState.value) << std::endl; - sif::info << "RwHandler::handleTemperatureReply: CLC mode: " + sif::info << "RwHandler::handleTemperatureReply: CLC mode: " << static_cast(tmDataset.rwClcMode.value) << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Current speed: " << tmDataset.rwCurrSpeed + sif::info << "RwHandler::handleTemperatureReply: Current speed: " << tmDataset.rwCurrSpeed << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Reference speed: " << tmDataset.rwRefSpeed + sif::info << "RwHandler::handleTemperatureReply: Reference speed: " << tmDataset.rwRefSpeed << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Number of invalid CRC packets: " + sif::info << "RwHandler::handleTemperatureReply: Number of invalid CRC packets: " << tmDataset.numOfInvalidCrcPackets << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Number of invalid length packets: " + sif::info << "RwHandler::handleTemperatureReply: Number of invalid length packets: " << tmDataset.numOfInvalidLenPackets << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Number of invalid command packets: " + sif::info << "RwHandler::handleTemperatureReply: Number of invalid command packets: " << tmDataset.numOfInvalidCmdPackets << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Number of command executed replies: " + sif::info << "RwHandler::handleTemperatureReply: Number of command executed replies: " << tmDataset.numOfCmdExecutedReplies << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Number of command replies: " + sif::info << "RwHandler::handleTemperatureReply: Number of command replies: " << tmDataset.numOfCmdReplies << std::endl; - sif::info << "RwHandler::handleTemperatureReply: UART number of bytes written: " + sif::info << "RwHandler::handleTemperatureReply: UART number of bytes written: " << tmDataset.uartNumOfBytesWritten << std::endl; - sif::info << "RwHandler::handleTemperatureReply: UART number of bytes read: " + sif::info << "RwHandler::handleTemperatureReply: UART number of bytes read: " << tmDataset.uartNumOfBytesRead << std::endl; - sif::info << "RwHandler::handleTemperatureReply: UART number of parity errors: " + sif::info << "RwHandler::handleTemperatureReply: UART number of parity errors: " << tmDataset.uartNumOfParityErrors << std::endl; - sif::info << "RwHandler::handleTemperatureReply: UART number of noise errors: " + sif::info << "RwHandler::handleTemperatureReply: UART number of noise errors: " << tmDataset.uartNumOfNoiseErrors << std::endl; - sif::info << "RwHandler::handleTemperatureReply: UART number of frame errors: " + sif::info << "RwHandler::handleTemperatureReply: UART number of frame errors: " << tmDataset.uartNumOfFrameErrors << std::endl; - sif::info << "RwHandler::handleTemperatureReply: UART number of register overrun errors: " + sif::info << "RwHandler::handleTemperatureReply: UART number of register overrun errors: " << tmDataset.uartNumOfRegisterOverrunErrors << std::endl; - sif::info << "RwHandler::handleTemperatureReply: UART number of total errors: " + sif::info << "RwHandler::handleTemperatureReply: UART number of total errors: " << tmDataset.uartTotalNumOfErrors << std::endl; - sif::info << "RwHandler::handleTemperatureReply: SPI number of bytes written: " + sif::info << "RwHandler::handleTemperatureReply: SPI number of bytes written: " << tmDataset.spiNumOfBytesWritten << std::endl; - sif::info << "RwHandler::handleTemperatureReply: SPI number of bytes read: " + sif::info << "RwHandler::handleTemperatureReply: SPI number of bytes read: " << tmDataset.spiNumOfBytesRead << std::endl; - sif::info << "RwHandler::handleTemperatureReply: SPI number of register overrun errors: " + sif::info << "RwHandler::handleTemperatureReply: SPI number of register overrun errors: " << tmDataset.spiNumOfRegisterOverrunErrors << std::endl; - sif::info << "RwHandler::handleTemperatureReply: SPI number of register total errors: " + sif::info << "RwHandler::handleTemperatureReply: SPI number of register total errors: " << tmDataset.spiTotalNumOfErrors << std::endl; #endif } diff --git a/mission/devices/RwHandler.h b/mission/devices/RwHandler.h index 57895ca6..31b88e01 100644 --- a/mission/devices/RwHandler.h +++ b/mission/devices/RwHandler.h @@ -2,8 +2,8 @@ #define MISSION_DEVICES_RWHANDLER_H_ #include -#include #include +#include #include /** @@ -16,141 +16,135 @@ * * @author J. Meier */ -class RwHandler: public DeviceHandlerBase { -public: +class RwHandler : public DeviceHandlerBase { + public: + /** + * @brief Constructor + * + * @param objectId + * @param comIF + * @param comCookie + * @param gpioComIF Pointer to gpio communication interface + * @param enablePin GPIO connected to the enable pin of the reaction wheels. Must be pulled + * to high to enable the device. + */ + RwHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, LinuxLibgpioIF* gpioComIF, + gpioId_t enableGpio); + virtual ~RwHandler(); - /** - * @brief Constructor - * - * @param objectId - * @param comIF - * @param comCookie - * @param gpioComIF Pointer to gpio communication interface - * @param enablePin GPIO connected to the enable pin of the reaction wheels. Must be pulled - * to high to enable the device. - */ - RwHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie, - LinuxLibgpioIF* gpioComIF, gpioId_t enableGpio); - virtual ~RwHandler(); + static const uint8_t INTERFACE_ID = CLASS_ID::RW_HANDLER; - static const uint8_t INTERFACE_ID = CLASS_ID::RW_HANDLER; + static const ReturnValue_t SPI_WRITE_FAILURE = MAKE_RETURN_CODE(0xB0); + //! [EXPORT] : [COMMENT] Used by the spi send function to tell a failing read call + static const ReturnValue_t SPI_READ_FAILURE = MAKE_RETURN_CODE(0xB1); + //! [EXPORT] : [COMMENT] Can be used by the HDLC decoding mechanism to inform about a missing + //! start sign 0x7E + static const ReturnValue_t MISSING_START_SIGN = MAKE_RETURN_CODE(0xB2); + //! [EXPORT] : [COMMENT] Can be used by the HDLC decoding mechanism to inform about an invalid + //! substitution combination + static const ReturnValue_t INVALID_SUBSTITUTE = MAKE_RETURN_CODE(0xB3); + //! [EXPORT] : [COMMENT] HDLC decoding mechanism never receives the end sign 0x7E + static const ReturnValue_t MISSING_END_SIGN = MAKE_RETURN_CODE(0xB4); + //! [EXPORT] : [COMMENT] Reaction wheel only responds with empty frames. + static const ReturnValue_t NO_REPLY = MAKE_RETURN_CODE(0xB5); + //! [EXPORT] : [COMMENT] Expected a start marker as first byte + static const ReturnValue_t NO_START_MARKER = MAKE_RETURN_CODE(0xB6); - static const ReturnValue_t SPI_WRITE_FAILURE = MAKE_RETURN_CODE(0xB0); - //! [EXPORT] : [COMMENT] Used by the spi send function to tell a failing read call - static const ReturnValue_t SPI_READ_FAILURE = MAKE_RETURN_CODE(0xB1); - //! [EXPORT] : [COMMENT] Can be used by the HDLC decoding mechanism to inform about a missing start sign 0x7E - static const ReturnValue_t MISSING_START_SIGN = MAKE_RETURN_CODE(0xB2); - //! [EXPORT] : [COMMENT] Can be used by the HDLC decoding mechanism to inform about an invalid substitution combination - static const ReturnValue_t INVALID_SUBSTITUTE = MAKE_RETURN_CODE(0xB3); - //! [EXPORT] : [COMMENT] HDLC decoding mechanism never receives the end sign 0x7E - static const ReturnValue_t MISSING_END_SIGN = MAKE_RETURN_CODE(0xB4); - //! [EXPORT] : [COMMENT] Reaction wheel only responds with empty frames. - static const ReturnValue_t NO_REPLY = MAKE_RETURN_CODE(0xB5); - //! [EXPORT] : [COMMENT] Expected a start marker as first byte - static const ReturnValue_t NO_START_MARKER = MAKE_RETURN_CODE(0xB6); + 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; -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; + private: + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::RW_HANDLER; -private: + //! [EXPORT] : [COMMENT] Action Message with invalid speed was received. Valid speeds must be in + //! the range of [-65000; 1000] or [1000; 65000] + static const ReturnValue_t INVALID_SPEED = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] Action Message with invalid ramp time was received. + static const ReturnValue_t INVALID_RAMP_TIME = MAKE_RETURN_CODE(0xA1); + //! [EXPORT] : [COMMENT] Received set speed command has invalid length. Should be 6. + static const ReturnValue_t SET_SPEED_COMMAND_INVALID_LENGTH = MAKE_RETURN_CODE(0xA2); + //! [EXPORT] : [COMMENT] Command execution failed + static const ReturnValue_t EXECUTION_FAILED = MAKE_RETURN_CODE(0xA3); + //! [EXPORT] : [COMMENT] Reaction wheel reply has invalid crc + static const ReturnValue_t CRC_ERROR = MAKE_RETURN_CODE(0xA4); - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::RW_HANDLER; + //! [EXPORT] : [COMMENT] Reaction wheel signals an error state + static const Event ERROR_STATE = MAKE_EVENT(1, severity::HIGH); - //! [EXPORT] : [COMMENT] Action Message with invalid speed was received. Valid speeds must be in the range of [-65000; 1000] or [1000; 65000] - static const ReturnValue_t INVALID_SPEED = MAKE_RETURN_CODE(0xA0); - //! [EXPORT] : [COMMENT] Action Message with invalid ramp time was received. - static const ReturnValue_t INVALID_RAMP_TIME = MAKE_RETURN_CODE(0xA1); - //! [EXPORT] : [COMMENT] Received set speed command has invalid length. Should be 6. - static const ReturnValue_t SET_SPEED_COMMAND_INVALID_LENGTH = MAKE_RETURN_CODE(0xA2); - //! [EXPORT] : [COMMENT] Command execution failed - static const ReturnValue_t EXECUTION_FAILED = MAKE_RETURN_CODE(0xA3); - //! [EXPORT] : [COMMENT] Reaction wheel reply has invalid crc - static const ReturnValue_t CRC_ERROR = MAKE_RETURN_CODE(0xA4); + LinuxLibgpioIF* gpioComIF = nullptr; + gpioId_t enableGpio = gpio::NO_GPIO; - //! [EXPORT] : [COMMENT] Reaction wheel signals an error state - static const Event ERROR_STATE = MAKE_EVENT(1, severity::HIGH); + RwDefinitions::TemperatureSet temperatureSet; + RwDefinitions::StatusSet statusSet; + RwDefinitions::LastResetSatus lastResetStatusSet; + RwDefinitions::TmDataset tmDataset; - LinuxLibgpioIF* gpioComIF = nullptr; - gpioId_t enableGpio = gpio::NO_GPIO; + uint8_t commandBuffer[RwDefinitions::MAX_CMD_SIZE]; - RwDefinitions::TemperatureSet temperatureSet; - RwDefinitions::StatusSet statusSet; - RwDefinitions::LastResetSatus lastResetStatusSet; - RwDefinitions::TmDataset tmDataset; + enum class InternalState { GET_RESET_STATUS, CLEAR_RESET_STATUS, READ_TEMPERATURE, GET_RW_SATUS }; + InternalState internalState = InternalState::GET_RESET_STATUS; - uint8_t commandBuffer[RwDefinitions::MAX_CMD_SIZE]; + size_t sizeOfReply = 0; - enum class InternalState { - GET_RESET_STATUS, - CLEAR_RESET_STATUS, - READ_TEMPERATURE, - GET_RW_SATUS - }; + /** + * @brief This function can be used to build commands which do not contain any data apart + * from the command id and the CRC. + * @param commandId The command id of the command to build. + */ + void prepareSimpleCommand(DeviceCommandId_t id); - InternalState internalState = InternalState::GET_RESET_STATUS; + /** + * @brief This function checks if the receiced speed and ramp time to set are in a valid + * range. + * @return RETURN_OK if successful, otherwise error code. + */ + ReturnValue_t checkSpeedAndRampTime(const uint8_t* commandData, size_t commandDataLen); - size_t sizeOfReply = 0; + /** + * @brief This function prepares the set speed command from the commandData received with + * an action message. + */ + void prepareSetSpeedCmd(const uint8_t* commandData, size_t commandDataLen); - /** - * @brief This function can be used to build commands which do not contain any data apart - * from the command id and the CRC. - * @param commandId The command id of the command to build. - */ - void prepareSimpleCommand(DeviceCommandId_t id); + /** + * @brief This function writes the last reset status retrieved with the get last reset status + * command into the reset status dataset. + * + * @param packet Pointer to the buffer holding the reply data. + */ + void handleResetStatusReply(const uint8_t* packet); - /** - * @brief This function checks if the receiced speed and ramp time to set are in a valid - * range. - * @return RETURN_OK if successful, otherwise error code. - */ - ReturnValue_t checkSpeedAndRampTime(const uint8_t * commandData, size_t commandDataLen); + /** + * @brief This function handles the reply of the get temperature command. + * + * @param packet Pointer to the reply data + */ + void handleTemperatureReply(const uint8_t* packet); - /** - * @brief This function prepares the set speed command from the commandData received with - * an action message. - */ - void prepareSetSpeedCmd(const uint8_t * commandData, size_t commandDataLen); + /** + * @brief This function fills the status set with the data from the get-status-reply. + */ + void handleGetRwStatusReply(const uint8_t* packet); - /** - * @brief This function writes the last reset status retrieved with the get last reset status - * command into the reset status dataset. - * - * @param packet Pointer to the buffer holding the reply data. - */ - void handleResetStatusReply(const uint8_t* packet); - - /** - * @brief This function handles the reply of the get temperature command. - * - * @param packet Pointer to the reply data - */ - void handleTemperatureReply(const uint8_t* packet); - - /** - * @brief This function fills the status set with the data from the get-status-reply. - */ - void handleGetRwStatusReply(const uint8_t* packet); - - /** - * @brief This function fills the tmDataset with the reply data requested with get telemetry - * command. - */ - void handleGetTelemetryReply(const uint8_t* packet); + /** + * @brief This function fills the tmDataset with the reply data requested with get telemetry + * command. + */ + void handleGetTelemetryReply(const uint8_t* packet); }; #endif /* MISSION_DEVICES_RWHANDLER_H_ */ diff --git a/mission/devices/SyrlinksHkHandler.cpp b/mission/devices/SyrlinksHkHandler.cpp index 9f359bd1..8694f261 100644 --- a/mission/devices/SyrlinksHkHandler.cpp +++ b/mission/devices/SyrlinksHkHandler.cpp @@ -1,464 +1,451 @@ +#include +#include +#include + #include "OBSWConfig.h" -#include -#include -#include - - -SyrlinksHkHandler::SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - DeviceHandlerBase(objectId, comIF, comCookie), rxDataset(this), txDataset(this) { - if (comCookie == NULL) { - sif::error << "SyrlinksHkHandler: Invalid com cookie" << std::endl; - } +SyrlinksHkHandler::SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie) + : DeviceHandlerBase(objectId, comIF, comCookie), rxDataset(this), txDataset(this) { + if (comCookie == NULL) { + sif::error << "SyrlinksHkHandler: Invalid com cookie" << std::endl; + } } -SyrlinksHkHandler::~SyrlinksHkHandler() { +SyrlinksHkHandler::~SyrlinksHkHandler() {} + +void SyrlinksHkHandler::doStartUp() { + if (mode == _MODE_START_UP) { + setMode(MODE_ON); + } } +void SyrlinksHkHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } -void SyrlinksHkHandler::doStartUp(){ - if(mode == _MODE_START_UP){ - setMode(MODE_ON); - } -} - -void SyrlinksHkHandler::doShutDown(){ - setMode(_MODE_POWER_DOWN); -} - -ReturnValue_t SyrlinksHkHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - switch (nextCommand) { - case(SYRLINKS::READ_RX_STATUS_REGISTERS): - *id = SYRLINKS::READ_RX_STATUS_REGISTERS; - nextCommand = SYRLINKS::READ_TX_STATUS; - break; - case(SYRLINKS::READ_TX_STATUS): - *id = SYRLINKS::READ_TX_STATUS; - nextCommand = SYRLINKS::READ_TX_WAVEFORM; - break; - case(SYRLINKS::READ_TX_WAVEFORM): - *id = SYRLINKS::READ_TX_WAVEFORM; - nextCommand = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE; - break; - case(SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): - *id = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE; - nextCommand = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE; - break; - case(SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): - *id = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE; - nextCommand = SYRLINKS::READ_RX_STATUS_REGISTERS; - break; +ReturnValue_t SyrlinksHkHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + switch (nextCommand) { + case (SYRLINKS::READ_RX_STATUS_REGISTERS): + *id = SYRLINKS::READ_RX_STATUS_REGISTERS; + nextCommand = SYRLINKS::READ_TX_STATUS; + break; + case (SYRLINKS::READ_TX_STATUS): + *id = SYRLINKS::READ_TX_STATUS; + nextCommand = SYRLINKS::READ_TX_WAVEFORM; + break; + case (SYRLINKS::READ_TX_WAVEFORM): + *id = SYRLINKS::READ_TX_WAVEFORM; + nextCommand = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE; + break; + case (SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): + *id = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE; + nextCommand = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE; + break; + case (SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): + *id = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE; + nextCommand = SYRLINKS::READ_RX_STATUS_REGISTERS; + break; default: - sif::debug << "SyrlinksHkHandler::buildNormalDeviceCommand: rememberCommandId has invalid" - << "command id" << std::endl; - break; + sif::debug << "SyrlinksHkHandler::buildNormalDeviceCommand: rememberCommandId has invalid" + << "command id" << std::endl; + break; + } + return buildCommandFromCommand(*id, NULL, 0); +} + +ReturnValue_t SyrlinksHkHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t* commandData, + size_t commandDataLen) { + switch (deviceCommand) { + case (SYRLINKS::RESET_UNIT): { + resetCommand.copy(reinterpret_cast(commandBuffer), resetCommand.size(), 0); + rawPacketLen = resetCommand.size(); + rawPacket = commandBuffer; + return RETURN_OK; } - return buildCommandFromCommand(*id, NULL, 0); -} - -ReturnValue_t SyrlinksHkHandler::buildTransitionDeviceCommand( - DeviceCommandId_t * id){ - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t * commandData, - size_t commandDataLen) { - switch(deviceCommand) { - case(SYRLINKS::RESET_UNIT): { - resetCommand.copy(reinterpret_cast(commandBuffer), resetCommand.size(), 0); - rawPacketLen = resetCommand.size(); - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::SET_TX_MODE_STANDBY): { - setTxModeStandby.copy(reinterpret_cast(commandBuffer), setTxModeStandby.size(), 0); - rawPacketLen = setTxModeStandby.size(); - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::SET_TX_MODE_MODULATION): { - setTxModeModulation.copy(reinterpret_cast(commandBuffer), setTxModeModulation.size(), 0); - rawPacketLen = setTxModeModulation.size(); - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::SET_TX_MODE_CW): { - setTxModeCw.copy(reinterpret_cast(commandBuffer), setTxModeCw.size(), 0); - rawPacketLen = setTxModeCw.size(); - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::READ_RX_STATUS_REGISTERS): { - readRxStatusRegCommand.copy(reinterpret_cast(commandBuffer), readRxStatusRegCommand.size(), 0); - rawPacketLen = readRxStatusRegCommand.size(); - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::READ_TX_STATUS): { - readTxStatus.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); - rawPacketLen = readTxStatus.size(); - rememberCommandId = SYRLINKS::READ_TX_STATUS; - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::READ_TX_WAVEFORM): { - readTxWaveform.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); - rawPacketLen = readTxWaveform.size(); - rememberCommandId = SYRLINKS::READ_TX_WAVEFORM; - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): { - readTxAgcValueHighByte.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); - rawPacketLen = readTxAgcValueHighByte.size(); - rememberCommandId = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE; - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): { - readTxAgcValueLowByte.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); - rawPacketLen = readTxAgcValueLowByte.size(); - rememberCommandId = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE; - rawPacket = commandBuffer; - return RETURN_OK; - } - default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; + case (SYRLINKS::SET_TX_MODE_STANDBY): { + setTxModeStandby.copy(reinterpret_cast(commandBuffer), setTxModeStandby.size(), 0); + rawPacketLen = setTxModeStandby.size(); + rawPacket = commandBuffer; + return RETURN_OK; + } + case (SYRLINKS::SET_TX_MODE_MODULATION): { + setTxModeModulation.copy(reinterpret_cast(commandBuffer), setTxModeModulation.size(), + 0); + rawPacketLen = setTxModeModulation.size(); + rawPacket = commandBuffer; + return RETURN_OK; + } + case (SYRLINKS::SET_TX_MODE_CW): { + setTxModeCw.copy(reinterpret_cast(commandBuffer), setTxModeCw.size(), 0); + rawPacketLen = setTxModeCw.size(); + rawPacket = commandBuffer; + return RETURN_OK; + } + case (SYRLINKS::READ_RX_STATUS_REGISTERS): { + readRxStatusRegCommand.copy(reinterpret_cast(commandBuffer), + readRxStatusRegCommand.size(), 0); + rawPacketLen = readRxStatusRegCommand.size(); + rawPacket = commandBuffer; + return RETURN_OK; + } + case (SYRLINKS::READ_TX_STATUS): { + readTxStatus.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); + rawPacketLen = readTxStatus.size(); + rememberCommandId = SYRLINKS::READ_TX_STATUS; + rawPacket = commandBuffer; + return RETURN_OK; + } + case (SYRLINKS::READ_TX_WAVEFORM): { + readTxWaveform.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); + rawPacketLen = readTxWaveform.size(); + rememberCommandId = SYRLINKS::READ_TX_WAVEFORM; + rawPacket = commandBuffer; + return RETURN_OK; + } + case (SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): { + readTxAgcValueHighByte.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); + rawPacketLen = readTxAgcValueHighByte.size(); + rememberCommandId = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE; + rawPacket = commandBuffer; + return RETURN_OK; + } + case (SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): { + readTxAgcValueLowByte.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); + rawPacketLen = readTxAgcValueLowByte.size(); + rememberCommandId = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE; + rawPacket = commandBuffer; + return RETURN_OK; + } + default: + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } void SyrlinksHkHandler::fillCommandAndReplyMap() { - this->insertInCommandAndReplyMap(SYRLINKS::RESET_UNIT, 1, nullptr, SYRLINKS::ACK_SIZE, false, - true, SYRLINKS::ACK_REPLY); - this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_STANDBY, 1, nullptr, SYRLINKS::ACK_SIZE, - false, true, SYRLINKS::ACK_REPLY); - this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_MODULATION, 1, nullptr, - SYRLINKS::ACK_SIZE, false, true, SYRLINKS::ACK_REPLY); - this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_CW, 1, nullptr, SYRLINKS::ACK_SIZE, - false, true, SYRLINKS::ACK_REPLY); - this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_STATUS, 1, &txDataset, - SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_WAVEFORM, 1, &txDataset, - SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE, 1, &txDataset, - SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE, 1, &txDataset, - SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - this->insertInCommandAndReplyMap(SYRLINKS::READ_RX_STATUS_REGISTERS, 1, &rxDataset, - SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE); + this->insertInCommandAndReplyMap(SYRLINKS::RESET_UNIT, 1, nullptr, SYRLINKS::ACK_SIZE, false, + true, SYRLINKS::ACK_REPLY); + this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_STANDBY, 1, nullptr, SYRLINKS::ACK_SIZE, + false, true, SYRLINKS::ACK_REPLY); + this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_MODULATION, 1, nullptr, SYRLINKS::ACK_SIZE, + false, true, SYRLINKS::ACK_REPLY); + this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_CW, 1, nullptr, SYRLINKS::ACK_SIZE, false, + true, SYRLINKS::ACK_REPLY); + this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_STATUS, 1, &txDataset, + SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_WAVEFORM, 1, &txDataset, + SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE, 1, &txDataset, + SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE, 1, &txDataset, + SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + this->insertInCommandAndReplyMap(SYRLINKS::READ_RX_STATUS_REGISTERS, 1, &rxDataset, + SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE); } -ReturnValue_t SyrlinksHkHandler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { +ReturnValue_t SyrlinksHkHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + if (*start != '<') { + sif::error << "SyrlinksHkHandler::scanForReply: Missing start frame character" << std::endl; + return MISSING_START_FRAME_CHARACTER; + } - if(*start != '<') { - sif::error << "SyrlinksHkHandler::scanForReply: Missing start frame character" << std::endl; - return MISSING_START_FRAME_CHARACTER; - } + switch (*(start + 1)) { + case ('A'): + *foundLen = SYRLINKS::ACK_SIZE; + *foundId = SYRLINKS::ACK_REPLY; + break; + case ('E'): + *foundLen = SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE; + *foundId = SYRLINKS::READ_RX_STATUS_REGISTERS; + break; + case ('R'): + *foundId = rememberCommandId; + *foundLen = SYRLINKS::READ_ONE_REGISTER_REPLY_SIE; + break; + default: + sif::error << "SyrlinksHkHandler::scanForReply: Unknown reply identifier" << std::endl; + result = IGNORE_REPLY_DATA; + break; + } - switch(*(start + 1)) { - case('A'): - *foundLen = SYRLINKS::ACK_SIZE; - *foundId = SYRLINKS::ACK_REPLY; - break; - case('E'): - *foundLen = SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE; - *foundId = SYRLINKS::READ_RX_STATUS_REGISTERS; - break; - case('R'): - *foundId = rememberCommandId; - *foundLen = SYRLINKS::READ_ONE_REGISTER_REPLY_SIE; - break; - default: - sif::error << "SyrlinksHkHandler::scanForReply: Unknown reply identifier" << std::endl; - result = IGNORE_REPLY_DATA; - break; - } - - return result; + return result; } -ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { +ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { + ReturnValue_t result; - ReturnValue_t result; - - switch (id) { + switch (id) { case (SYRLINKS::ACK_REPLY): - result = verifyReply(packet, SYRLINKS::ACK_SIZE); - if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Acknowledgement reply has " - "invalid crc" << std::endl; - return CRC_FAILURE; - } - result = parseReplyStatus(reinterpret_cast(packet + SYRLINKS::MESSAGE_HEADER_SIZE)); - if (result != RETURN_OK) { - return result; - } - break; - case(SYRLINKS::READ_RX_STATUS_REGISTERS): - result = verifyReply(packet, SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE); - if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read rx status registers reply " - << "has invalid crc" << std::endl; - return CRC_FAILURE; - } - parseRxStatusRegistersReply(packet); - break; - case(SYRLINKS::READ_TX_STATUS): - result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx status reply " - << "has invalid crc" << std::endl; - return CRC_FAILURE; - } - parseTxStatusReply(packet); - break; - case(SYRLINKS::READ_TX_WAVEFORM): - result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx waveform reply " - << "has invalid crc" << std::endl; - return CRC_FAILURE; - } - parseTxWaveformReply(packet); - break; - case(SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): - result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx AGC high byte reply " - << "has invalid crc" << std::endl; - return CRC_FAILURE; - } - parseAgcHighByte(packet); - break; - case(SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): - result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx AGC low byte reply " - << "has invalid crc" << std::endl; - return CRC_FAILURE; - } - parseAgcLowByte(packet); - break; - default: { - sif::debug << "SyrlinksHkHandler::interpretDeviceReply: Unknown device reply id" - << std::endl; - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } - } + result = verifyReply(packet, SYRLINKS::ACK_SIZE); + if (result != RETURN_OK) { + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Acknowledgement reply has " + "invalid crc" + << std::endl; + return CRC_FAILURE; + } + result = + parseReplyStatus(reinterpret_cast(packet + SYRLINKS::MESSAGE_HEADER_SIZE)); + if (result != RETURN_OK) { + return result; + } + break; + case (SYRLINKS::READ_RX_STATUS_REGISTERS): + result = verifyReply(packet, SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE); + if (result != RETURN_OK) { + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read rx status registers reply " + << "has invalid crc" << std::endl; + return CRC_FAILURE; + } + parseRxStatusRegistersReply(packet); + break; + case (SYRLINKS::READ_TX_STATUS): + result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + if (result != RETURN_OK) { + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx status reply " + << "has invalid crc" << std::endl; + return CRC_FAILURE; + } + parseTxStatusReply(packet); + break; + case (SYRLINKS::READ_TX_WAVEFORM): + result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + if (result != RETURN_OK) { + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx waveform reply " + << "has invalid crc" << std::endl; + return CRC_FAILURE; + } + parseTxWaveformReply(packet); + break; + case (SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): + result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + if (result != RETURN_OK) { + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx AGC high byte reply " + << "has invalid crc" << std::endl; + return CRC_FAILURE; + } + parseAgcHighByte(packet); + break; + case (SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): + result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + if (result != RETURN_OK) { + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx AGC low byte reply " + << "has invalid crc" << std::endl; + return CRC_FAILURE; + } + parseAgcLowByte(packet); + break; + default: { + sif::debug << "SyrlinksHkHandler::interpretDeviceReply: Unknown device reply id" << std::endl; + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; + } + } - return RETURN_OK; + return RETURN_OK; } LocalPoolDataSetBase* SyrlinksHkHandler::getDataSetHandle(sid_t sid) { - if (sid == rxDataset.getSid()) { - return &rxDataset; - } - else if (sid== txDataset.getSid()) { - return &txDataset; - } - else { - sif::error << "SyrlinksHkHandler::getDataSetHandle: Invalid sid" << std::endl; - return nullptr; - } + if (sid == rxDataset.getSid()) { + return &rxDataset; + } else if (sid == txDataset.getSid()) { + return &txDataset; + } else { + sif::error << "SyrlinksHkHandler::getDataSetHandle: Invalid sid" << std::endl; + return nullptr; + } } std::string SyrlinksHkHandler::convertUint16ToHexString(uint16_t intValue) { - std::stringstream stream; - stream << std::setfill('0') << std::setw(4) << std::hex << std::uppercase << intValue; - return stream.str(); + std::stringstream stream; + stream << std::setfill('0') << std::setw(4) << std::hex << std::uppercase << intValue; + return stream.str(); } uint8_t SyrlinksHkHandler::convertHexStringToUint8(const char* twoChars) { - uint32_t value; - std::string hexString(twoChars, 2); - std::stringstream stream; - stream << std::hex << hexString; - stream >> value; - return static_cast(value); + uint32_t value; + std::string hexString(twoChars, 2); + std::stringstream stream; + stream << std::hex << hexString; + stream >> value; + return static_cast(value); } uint16_t SyrlinksHkHandler::convertHexStringToUint16(const char* fourChars) { - uint16_t value = 0; - value = convertHexStringToUint8(fourChars) << 8 | convertHexStringToUint8(fourChars+2); - return value; + uint16_t value = 0; + value = convertHexStringToUint8(fourChars) << 8 | convertHexStringToUint8(fourChars + 2); + return value; } -uint32_t SyrlinksHkHandler::convertHexStringToUint32(const char* characters, uint8_t numberOfChars) { +uint32_t SyrlinksHkHandler::convertHexStringToUint32(const char* characters, + uint8_t numberOfChars) { + uint32_t value = 0; - uint32_t value = 0; - - switch (numberOfChars) { + switch (numberOfChars) { case 6: - value = convertHexStringToUint8(characters) << 16 - | convertHexStringToUint8(characters + 2) << 8 - | convertHexStringToUint8(characters + 4); - return value; + value = convertHexStringToUint8(characters) << 16 | + convertHexStringToUint8(characters + 2) << 8 | + convertHexStringToUint8(characters + 4); + return value; case 8: - value = convertHexStringToUint8(characters) << 24 - | convertHexStringToUint8(characters + 2) << 16 - | convertHexStringToUint8(characters + 4) << 8 - | convertHexStringToUint8(characters + 4); - return value; + value = convertHexStringToUint8(characters) << 24 | + convertHexStringToUint8(characters + 2) << 16 | + convertHexStringToUint8(characters + 4) << 8 | + convertHexStringToUint8(characters + 4); + return value; default: - sif::debug << "SyrlinksHkHandler::convertHexStringToUint32: Invalid number of characters. " - << "Must be either 6 or 8" << std::endl; - return 0; - } + sif::debug << "SyrlinksHkHandler::convertHexStringToUint32: Invalid number of characters. " + << "Must be either 6 or 8" << std::endl; + return 0; + } } ReturnValue_t SyrlinksHkHandler::parseReplyStatus(const char* status) { - switch (*status) { + switch (*status) { case '0': - return RETURN_OK; + return RETURN_OK; case '1': - sif::debug << "SyrlinksHkHandler::parseReplyStatus: Uart faming or parity error" - << std::endl; - return UART_FRAMIN_OR_PARITY_ERROR_ACK; + sif::debug << "SyrlinksHkHandler::parseReplyStatus: Uart faming or parity error" << std::endl; + return UART_FRAMIN_OR_PARITY_ERROR_ACK; case '2': - sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad character detected" << std::endl; - return BAD_CHARACTER_ACK; + sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad character detected" << std::endl; + return BAD_CHARACTER_ACK; case '3': - sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad parameter value (unexpected value " - << "detected" << std::endl; - return BAD_PARAMETER_VALUE_ACK; + sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad parameter value (unexpected value " + << "detected" << std::endl; + return BAD_PARAMETER_VALUE_ACK; case '4': - sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad end of frame" << std::endl; - return BAD_END_OF_FRAME_ACK; + sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad end of frame" << std::endl; + return BAD_END_OF_FRAME_ACK; case '5': - sif::debug << "SyrlinksHkHandler::parseReplyStatus: Unknown command id or attempt to access" - << " a protected register" << std::endl; - return UNKNOWN_COMMAND_ID_ACK; + sif::debug << "SyrlinksHkHandler::parseReplyStatus: Unknown command id or attempt to access" + << " a protected register" << std::endl; + return UNKNOWN_COMMAND_ID_ACK; case '6': - sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad CRC" << std::endl; - return BAD_CRC_ACK; + sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad CRC" << std::endl; + return BAD_CRC_ACK; default: - sif::debug << "SyrlinksHkHandler::parseReplyStatus: Status reply contains an invalid " - << "status id" << std::endl; - return RETURN_FAILED; - } + sif::debug << "SyrlinksHkHandler::parseReplyStatus: Status reply contains an invalid " + << "status id" << std::endl; + return RETURN_FAILED; + } } ReturnValue_t SyrlinksHkHandler::verifyReply(const uint8_t* packet, uint8_t size) { - int result = 0; - /* Calculate crc from received packet */ - uint16_t crc = CRC::crc16ccitt(packet, size - SYRLINKS::SIZE_CRC_AND_TERMINATION, - CRC_INITIAL_VALUE); - std::string recalculatedCrc = convertUint16ToHexString(crc); + int result = 0; + /* Calculate crc from received packet */ + uint16_t crc = + CRC::crc16ccitt(packet, size - SYRLINKS::SIZE_CRC_AND_TERMINATION, CRC_INITIAL_VALUE); + std::string recalculatedCrc = convertUint16ToHexString(crc); - const char* startOfCrc = reinterpret_cast(packet + size - SYRLINKS::SIZE_CRC_AND_TERMINATION); - const char* endOfCrc = reinterpret_cast(packet + size - 1); + const char* startOfCrc = + reinterpret_cast(packet + size - SYRLINKS::SIZE_CRC_AND_TERMINATION); + const char* endOfCrc = reinterpret_cast(packet + size - 1); - std::string replyCrc(startOfCrc, endOfCrc); + std::string replyCrc(startOfCrc, endOfCrc); - result = recalculatedCrc.compare(replyCrc); - if (result != 0) { - return RETURN_FAILED; - } - return RETURN_OK; + result = recalculatedCrc.compare(replyCrc); + if (result != 0) { + return RETURN_FAILED; + } + return RETURN_OK; } void SyrlinksHkHandler::parseRxStatusRegistersReply(const uint8_t* packet) { - PoolReadGuard readHelper(&rxDataset); - uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; - rxDataset.rxStatus = convertHexStringToUint8(reinterpret_cast(packet + offset)); - offset += 2; - rxDataset.rxSensitivity = convertHexStringToUint32(reinterpret_cast(packet + offset), 6); - offset += 6; - rxDataset.rxFrequencyShift = convertHexStringToUint32(reinterpret_cast(packet + offset), 6); - offset += 6; - rxDataset.rxIqPower = convertHexStringToUint16(reinterpret_cast(packet + offset)); - offset += 4; - rxDataset.rxAgcValue = convertHexStringToUint16(reinterpret_cast(packet + offset)); - offset += 4; - offset += 2; // reserved register - rxDataset.rxDemodEb= convertHexStringToUint32(reinterpret_cast(packet + offset), 6); - offset += 6; - rxDataset.rxDemodN0= convertHexStringToUint32(reinterpret_cast(packet + offset), 6); - offset += 6; - rxDataset.rxDataRate = convertHexStringToUint8(reinterpret_cast(packet + offset)); + PoolReadGuard readHelper(&rxDataset); + uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; + rxDataset.rxStatus = convertHexStringToUint8(reinterpret_cast(packet + offset)); + offset += 2; + rxDataset.rxSensitivity = + convertHexStringToUint32(reinterpret_cast(packet + offset), 6); + offset += 6; + rxDataset.rxFrequencyShift = + convertHexStringToUint32(reinterpret_cast(packet + offset), 6); + offset += 6; + rxDataset.rxIqPower = convertHexStringToUint16(reinterpret_cast(packet + offset)); + offset += 4; + rxDataset.rxAgcValue = convertHexStringToUint16(reinterpret_cast(packet + offset)); + offset += 4; + offset += 2; // reserved register + rxDataset.rxDemodEb = convertHexStringToUint32(reinterpret_cast(packet + offset), 6); + offset += 6; + rxDataset.rxDemodN0 = convertHexStringToUint32(reinterpret_cast(packet + offset), 6); + offset += 6; + rxDataset.rxDataRate = convertHexStringToUint8(reinterpret_cast(packet + offset)); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1 - sif::info << "Syrlinks RX Status: 0x" << std::hex << (unsigned int)rxDataset.rxStatus.value << std::endl; - sif::info << "Syrlinks RX Sensitivity: " << std::dec << rxDataset.rxSensitivity << std::endl; - sif::info << "Syrlinks RX Frequency Shift: " << rxDataset.rxFrequencyShift << std::endl; - sif::info << "Syrlinks RX IQ Power: " << rxDataset.rxIqPower << std::endl; - sif::info << "Syrlinks RX AGC Value: " << rxDataset.rxAgcValue << std::endl; - sif::info << "Syrlinks RX Demod Eb: " << rxDataset.rxDemodEb << std::endl; - sif::info << "Syrlinks RX Demod N0: " << rxDataset.rxDemodN0 << std::endl; - sif::info << "Syrlinks RX Datarate: " << (unsigned int)rxDataset.rxDataRate.value << std::endl; + sif::info << "Syrlinks RX Status: 0x" << std::hex << (unsigned int)rxDataset.rxStatus.value + << std::endl; + sif::info << "Syrlinks RX Sensitivity: " << std::dec << rxDataset.rxSensitivity << std::endl; + sif::info << "Syrlinks RX Frequency Shift: " << rxDataset.rxFrequencyShift << std::endl; + sif::info << "Syrlinks RX IQ Power: " << rxDataset.rxIqPower << std::endl; + sif::info << "Syrlinks RX AGC Value: " << rxDataset.rxAgcValue << std::endl; + sif::info << "Syrlinks RX Demod Eb: " << rxDataset.rxDemodEb << std::endl; + sif::info << "Syrlinks RX Demod N0: " << rxDataset.rxDemodN0 << std::endl; + sif::info << "Syrlinks RX Datarate: " << (unsigned int)rxDataset.rxDataRate.value << std::endl; #endif } void SyrlinksHkHandler::parseTxStatusReply(const uint8_t* packet) { - PoolReadGuard readHelper(&txDataset); - uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; - txDataset.txStatus = convertHexStringToUint8(reinterpret_cast(packet + offset)); + PoolReadGuard readHelper(&txDataset); + uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; + txDataset.txStatus = convertHexStringToUint8(reinterpret_cast(packet + offset)); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1 - sif::info << "Syrlinks TX Status: 0x" << std::hex << (unsigned int) txDataset.txStatus.value + sif::info << "Syrlinks TX Status: 0x" << std::hex << (unsigned int)txDataset.txStatus.value << std::endl; #endif } void SyrlinksHkHandler::parseTxWaveformReply(const uint8_t* packet) { - PoolReadGuard readHelper(&txDataset); - uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; - txDataset.txWaveform = convertHexStringToUint8(reinterpret_cast(packet + offset)); + PoolReadGuard readHelper(&txDataset); + uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; + txDataset.txWaveform = convertHexStringToUint8(reinterpret_cast(packet + offset)); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1 - sif::info << "Syrlinks TX Waveform: 0x" << std::hex << (unsigned int) txDataset.txWaveform.value + sif::info << "Syrlinks TX Waveform: 0x" << std::hex << (unsigned int)txDataset.txWaveform.value << std::endl; #endif } void SyrlinksHkHandler::parseAgcLowByte(const uint8_t* packet) { - PoolReadGuard readHelper(&txDataset); - uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; - txDataset.txAgcValue = agcValueHighByte << 8 | convertHexStringToUint8(reinterpret_cast(packet + offset)); + PoolReadGuard readHelper(&txDataset); + uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; + txDataset.txAgcValue = agcValueHighByte << 8 | + convertHexStringToUint8(reinterpret_cast(packet + offset)); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1 - sif::info << "Syrlinks TX AGC Value: " << txDataset.txAgcValue << std::endl; + sif::info << "Syrlinks TX AGC Value: " << txDataset.txAgcValue << std::endl; #endif } void SyrlinksHkHandler::parseAgcHighByte(const uint8_t* packet) { - PoolReadGuard readHelper(&txDataset); - uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; - agcValueHighByte = convertHexStringToUint8(reinterpret_cast(packet + offset)); + PoolReadGuard readHelper(&txDataset); + uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; + agcValueHighByte = convertHexStringToUint8(reinterpret_cast(packet + offset)); } -void SyrlinksHkHandler::setNormalDatapoolEntriesInvalid(){ +void SyrlinksHkHandler::setNormalDatapoolEntriesInvalid() {} -} - -uint32_t SyrlinksHkHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){ - return 500; -} +uint32_t SyrlinksHkHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } ReturnValue_t SyrlinksHkHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { + LocalDataPoolManager& poolManager) { + localDataPoolMap.emplace(SYRLINKS::RX_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::RX_SENSITIVITY, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::RX_FREQUENCY_SHIFT, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::RX_IQ_POWER, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::RX_AGC_VALUE, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::RX_DEMOD_EB, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::RX_DEMOD_N0, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::RX_DATA_RATE, new PoolEntry({0})); - localDataPoolMap.emplace(SYRLINKS::RX_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::RX_SENSITIVITY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::RX_FREQUENCY_SHIFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::RX_IQ_POWER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::RX_AGC_VALUE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::RX_DEMOD_EB, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::RX_DEMOD_N0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::RX_DATA_RATE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(SYRLINKS::TX_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::TX_WAVEFORM, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::TX_AGC_VALUE, new PoolEntry({0})); - localDataPoolMap.emplace(SYRLINKS::TX_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::TX_WAVEFORM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::TX_AGC_VALUE, new PoolEntry( { 0 })); - - return HasReturnvaluesIF::RETURN_OK; -} - -void SyrlinksHkHandler::setModeNormal() { - mode = MODE_NORMAL; + return HasReturnvaluesIF::RETURN_OK; } +void SyrlinksHkHandler::setModeNormal() { mode = MODE_NORMAL; } diff --git a/mission/devices/SyrlinksHkHandler.h b/mission/devices/SyrlinksHkHandler.h index bf8a489a..b2e893b2 100644 --- a/mission/devices/SyrlinksHkHandler.h +++ b/mission/devices/SyrlinksHkHandler.h @@ -13,166 +13,162 @@ * * @author J. Meier */ -class SyrlinksHkHandler: public DeviceHandlerBase { -public: +class SyrlinksHkHandler : public DeviceHandlerBase { + public: + SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + virtual ~SyrlinksHkHandler(); - SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie); - virtual ~SyrlinksHkHandler(); + /** + * @brief Sets mode to MODE_NORMAL. Can be used for debugging. + */ + void setModeNormal(); - /** - * @brief Sets mode to MODE_NORMAL. Can be used for debugging. - */ - void setModeNormal(); + 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; + LocalPoolDataSetBase* getDataSetHandle(sid_t sid) 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; - LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::SYRLINKS_HANDLER; -private: + static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0); + static const ReturnValue_t UART_FRAMIN_OR_PARITY_ERROR_ACK = MAKE_RETURN_CODE(0xA1); + static const ReturnValue_t BAD_CHARACTER_ACK = MAKE_RETURN_CODE(0xA2); + static const ReturnValue_t BAD_PARAMETER_VALUE_ACK = MAKE_RETURN_CODE(0xA3); + static const ReturnValue_t BAD_END_OF_FRAME_ACK = MAKE_RETURN_CODE(0xA4); + static const ReturnValue_t UNKNOWN_COMMAND_ID_ACK = MAKE_RETURN_CODE(0xA5); + static const ReturnValue_t BAD_CRC_ACK = MAKE_RETURN_CODE(0xA6); + static const ReturnValue_t REPLY_WRONG_SIZE = MAKE_RETURN_CODE(0xA7); + static const ReturnValue_t MISSING_START_FRAME_CHARACTER = MAKE_RETURN_CODE(0xA8); - static const uint8_t INTERFACE_ID = CLASS_ID::SYRLINKS_HANDLER; + static const uint8_t CRC_INITIAL_VALUE = 0x0; - static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0); - static const ReturnValue_t UART_FRAMIN_OR_PARITY_ERROR_ACK = MAKE_RETURN_CODE(0xA1); - static const ReturnValue_t BAD_CHARACTER_ACK = MAKE_RETURN_CODE(0xA2); - static const ReturnValue_t BAD_PARAMETER_VALUE_ACK = MAKE_RETURN_CODE(0xA3); - static const ReturnValue_t BAD_END_OF_FRAME_ACK = MAKE_RETURN_CODE(0xA4); - static const ReturnValue_t UNKNOWN_COMMAND_ID_ACK = MAKE_RETURN_CODE(0xA5); - static const ReturnValue_t BAD_CRC_ACK = MAKE_RETURN_CODE(0xA6); - static const ReturnValue_t REPLY_WRONG_SIZE = MAKE_RETURN_CODE(0xA7); - static const ReturnValue_t MISSING_START_FRAME_CHARACTER = MAKE_RETURN_CODE(0xA8); + std::string resetCommand = ""; + std::string readRxStatusRegCommand = ""; + std::string setTxModeStandby = ""; + /** W - write, 04 - 4 bytes in data field, 01 - value, 40 register to write value */ + std::string setTxModeModulation = ""; + std::string setTxModeCw = ""; + std::string readTxStatus = ""; + std::string readTxWaveform = ""; + std::string readTxAgcValueHighByte = ""; + std::string readTxAgcValueLowByte = ""; - static const uint8_t CRC_INITIAL_VALUE = 0x0; + /** + * In some cases it is not possible to extract from the received reply the information about + * the associated command. This variable is thus used to remember the command id. + */ + DeviceCommandId_t rememberCommandId = SYRLINKS::NONE; - std::string resetCommand = ""; - std::string readRxStatusRegCommand = ""; - std::string setTxModeStandby = ""; - /** W - write, 04 - 4 bytes in data field, 01 - value, 40 register to write value */ - std::string setTxModeModulation = ""; - std::string setTxModeCw = ""; - std::string readTxStatus = ""; - std::string readTxWaveform = ""; - std::string readTxAgcValueHighByte = ""; - std::string readTxAgcValueLowByte = ""; + SYRLINKS::RxDataset rxDataset; + SYRLINKS::TxDataset txDataset; - /** - * In some cases it is not possible to extract from the received reply the information about - * the associated command. This variable is thus used to remember the command id. - */ - DeviceCommandId_t rememberCommandId = SYRLINKS::NONE; + uint8_t agcValueHighByte; - SYRLINKS::RxDataset rxDataset; - SYRLINKS::TxDataset txDataset; + uint8_t commandBuffer[SYRLINKS::MAX_COMMAND_SIZE]; - uint8_t agcValueHighByte; + /** + * This object is used to store the id of the next command to execute. This controls the + * read out of multiple registers which can not be fetched with one single command. + */ + DeviceCommandId_t nextCommand = SYRLINKS::READ_RX_STATUS_REGISTERS; - uint8_t commandBuffer[SYRLINKS::MAX_COMMAND_SIZE]; + /** + * @brief This function converts an uint16_t into its hexadecimal string representation. + * + * @param intValue The value to convert. + * + * @return An std::string object containing the hex representation of intValue. + */ + std::string convertUint16ToHexString(uint16_t intValue); - /** - * This object is used to store the id of the next command to execute. This controls the - * read out of multiple registers which can not be fetched with one single command. - */ - DeviceCommandId_t nextCommand = SYRLINKS::READ_RX_STATUS_REGISTERS; + /** + * @brief This function converts a hex number represented by to chars to an 8-bit integer. + * + * @param twoChars Pointer to the two characters representing the hex value. + * + * @details E.g. when twoChars points to an array with the two characters "A5" then the function + * will return 0xA5. + * @return The converted integer. + */ + uint8_t convertHexStringToUint8(const char* twoChars); - /** - * @brief This function converts an uint16_t into its hexadecimal string representation. - * - * @param intValue The value to convert. - * - * @return An std::string object containing the hex representation of intValue. - */ - std::string convertUint16ToHexString(uint16_t intValue); + /** + * @brief This function converts a hex number represented by 4 chars to an uint16_t. + * + * @param Pointer to the fourCharacters representing the 16-bit integer. + * + * @return The uint16_t result. + */ + uint16_t convertHexStringToUint16(const char* fourChars); - /** - * @brief This function converts a hex number represented by to chars to an 8-bit integer. - * - * @param twoChars Pointer to the two characters representing the hex value. - * - * @details E.g. when twoChars points to an array with the two characters "A5" then the function - * will return 0xA5. - * @return The converted integer. - */ - uint8_t convertHexStringToUint8(const char* twoChars); + /** + * @brief Function converts a hex number represented by 6 or 8 characters to an uint32_t. + * + * @param characters Pointer to the hex characters array. + * @param numberOfChars Number of characters representing the hex value. Must be 6 or 8. + * + * @return The uint32_t value. + */ + uint32_t convertHexStringToUint32(const char* characters, uint8_t numberOfChars); - /** - * @brief This function converts a hex number represented by 4 chars to an uint16_t. - * - * @param Pointer to the fourCharacters representing the 16-bit integer. - * - * @return The uint16_t result. - */ - uint16_t convertHexStringToUint16(const char* fourChars); + /** + * @brief This function parses the status reply + * @param status Pointer to the status information. + * + * @details Some commands reply with a status message giving information about the preceding + * command transmission and/or execution was successful. + */ + ReturnValue_t parseReplyStatus(const char* status); - /** - * @brief Function converts a hex number represented by 6 or 8 characters to an uint32_t. - * - * @param characters Pointer to the hex characters array. - * @param numberOfChars Number of characters representing the hex value. Must be 6 or 8. - * - * @return The uint32_t value. - */ - uint32_t convertHexStringToUint32(const char* characters, uint8_t numberOfChars); + /** + * @brief Function verifies the received reply from the syrlinks by recalculating and + * comparing the crc. + * + * @param packet Pointer to the received reply. + * @param size Size of the whole packet including the crc and the packet termination + * character '>'. + * + * @return RETURN_OK if successful, otherwise RETURN_FAILED. + */ + ReturnValue_t verifyReply(const uint8_t* packet, uint8_t size); - /** - * @brief This function parses the status reply - * @param status Pointer to the status information. - * - * @details Some commands reply with a status message giving information about the preceding - * command transmission and/or execution was successful. - */ - ReturnValue_t parseReplyStatus(const char* status); + /** + * @brief This function extracts the data from a rx status registers reply and writes the + * information to the status registers dataset. + * @param packet Pointer to the reply packet. + */ + void parseRxStatusRegistersReply(const uint8_t* packet); - /** - * @brief Function verifies the received reply from the syrlinks by recalculating and - * comparing the crc. - * - * @param packet Pointer to the received reply. - * @param size Size of the whole packet including the crc and the packet termination - * character '>'. - * - * @return RETURN_OK if successful, otherwise RETURN_FAILED. - */ - ReturnValue_t verifyReply(const uint8_t* packet, uint8_t size); + /** + * @brief This function writes the read tx status register to the txStatusDataset. + * @param packet Pointer to the received packet. + */ + void parseTxStatusReply(const uint8_t* packet); - /** - * @brief This function extracts the data from a rx status registers reply and writes the - * information to the status registers dataset. - * @param packet Pointer to the reply packet. - */ - void parseRxStatusRegistersReply(const uint8_t* packet); + /** + * @brief This function writes the received waveform configuration to the txDataset. + */ + void parseTxWaveformReply(const uint8_t* packet); - /** - * @brief This function writes the read tx status register to the txStatusDataset. - * @param packet Pointer to the received packet. - */ - void parseTxStatusReply(const uint8_t* packet); - - /** - * @brief This function writes the received waveform configuration to the txDataset. - */ - void parseTxWaveformReply(const uint8_t* packet); - - /** - * @brief The agc value is split over two registers. The parse agc functions are used to get - * the values from the received reply and write them into the txDataset. - */ - void parseAgcLowByte(const uint8_t* packet); - void parseAgcHighByte(const uint8_t* packet); + /** + * @brief The agc value is split over two registers. The parse agc functions are used to get + * the values from the received reply and write them into the txDataset. + */ + void parseAgcLowByte(const uint8_t* packet); + void parseAgcHighByte(const uint8_t* packet); }; #endif /* MISSION_DEVICES_SYRLINKSHKHANDLER_H_ */ diff --git a/mission/devices/Tmp1075Handler.cpp b/mission/devices/Tmp1075Handler.cpp index 95b8685f..59298851 100644 --- a/mission/devices/Tmp1075Handler.cpp +++ b/mission/devices/Tmp1075Handler.cpp @@ -1,145 +1,124 @@ +#include #include #include -#include -Tmp1075Handler::Tmp1075Handler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie) : - DeviceHandlerBase(objectId, comIF, comCookie), dataset( - this) { - if (comCookie == NULL) { - sif::error << "Tmp1075Handler: Invalid com cookie" << std::endl; - } +Tmp1075Handler::Tmp1075Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie) + : DeviceHandlerBase(objectId, comIF, comCookie), dataset(this) { + if (comCookie == NULL) { + sif::error << "Tmp1075Handler: Invalid com cookie" << std::endl; + } } -Tmp1075Handler::~Tmp1075Handler() { +Tmp1075Handler::~Tmp1075Handler() {} + +void Tmp1075Handler::doStartUp() { + if (mode == _MODE_START_UP) { + setMode(MODE_ON); + } } +void Tmp1075Handler::doShutDown() { setMode(_MODE_POWER_DOWN); } -void Tmp1075Handler::doStartUp(){ - if(mode == _MODE_START_UP){ - setMode(MODE_ON); - } +ReturnValue_t Tmp1075Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + if (communicationStep == CommunicationStep::START_ADC_CONVERSION) { + *id = TMP1075::START_ADC_CONVERSION; + communicationStep = CommunicationStep::GET_TEMPERATURE; + return buildCommandFromCommand(*id, NULL, 0); + } else { + *id = TMP1075::GET_TEMP; + communicationStep = CommunicationStep::START_ADC_CONVERSION; + return buildCommandFromCommand(*id, NULL, 0); + } + return HasReturnvaluesIF::RETURN_OK; } -void Tmp1075Handler::doShutDown(){ - setMode(_MODE_POWER_DOWN); +ReturnValue_t Tmp1075Handler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t Tmp1075Handler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - - if(communicationStep == CommunicationStep::START_ADC_CONVERSION) { - *id = TMP1075::START_ADC_CONVERSION; - communicationStep = CommunicationStep::GET_TEMPERATURE; - return buildCommandFromCommand(*id, NULL, 0); - } - else { - *id = TMP1075::GET_TEMP; - communicationStep = CommunicationStep::START_ADC_CONVERSION; - return buildCommandFromCommand(*id, NULL, 0); - } - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t Tmp1075Handler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, + size_t commandDataLen) { + switch (deviceCommand) { + case (TMP1075::START_ADC_CONVERSION): { + std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); + prepareAdcConversionCommand(); + rawPacket = cmdBuffer; + rawPacketLen = TMP1075::CFGR_CMD_SIZE; + return RETURN_OK; + } + case (TMP1075::GET_TEMP): { + std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); + prepareGetTempCommand(); + rawPacket = cmdBuffer; + rawPacketLen = TMP1075::POINTER_REG_SIZE; + rememberCommandId = TMP1075::GET_TEMP; + return RETURN_OK; + } + default: + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } -ReturnValue_t Tmp1075Handler::buildTransitionDeviceCommand( - DeviceCommandId_t * id){ - return HasReturnvaluesIF::RETURN_OK; +void Tmp1075Handler::fillCommandAndReplyMap() { + this->insertInCommandMap(TMP1075::START_ADC_CONVERSION); + this->insertInCommandAndReplyMap(TMP1075::GET_TEMP, 1, &dataset, TMP1075::GET_TEMP_REPLY_SIZE); } -ReturnValue_t Tmp1075Handler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t * commandData, - size_t commandDataLen) { - switch(deviceCommand) { - case(TMP1075::START_ADC_CONVERSION): { - std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); - prepareAdcConversionCommand(); - rawPacket = cmdBuffer; - rawPacketLen = TMP1075::CFGR_CMD_SIZE; - return RETURN_OK; - } - case(TMP1075::GET_TEMP): { - std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); - prepareGetTempCommand(); - rawPacket = cmdBuffer; - rawPacketLen = TMP1075::POINTER_REG_SIZE; - rememberCommandId = TMP1075::GET_TEMP; - return RETURN_OK; - } - default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; +ReturnValue_t Tmp1075Handler::scanForReply(const uint8_t *start, size_t remainingSize, + DeviceCommandId_t *foundId, size_t *foundLen) { + switch (rememberCommandId) { + case (TMP1075::GET_TEMP): + *foundId = TMP1075::GET_TEMP; + *foundLen = TMP1075::GET_TEMP_REPLY_SIZE; + rememberCommandId = TMP1075::NONE; + break; + default: + return IGNORE_REPLY_DATA; + } + return HasReturnvaluesIF::RETURN_OK; } -void Tmp1075Handler::fillCommandAndReplyMap(){ - this->insertInCommandMap(TMP1075::START_ADC_CONVERSION); - this->insertInCommandAndReplyMap(TMP1075::GET_TEMP, 1, &dataset, - TMP1075::GET_TEMP_REPLY_SIZE); -} - -ReturnValue_t Tmp1075Handler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { - switch(rememberCommandId) { - case(TMP1075::GET_TEMP): - *foundId = TMP1075::GET_TEMP; - *foundLen = TMP1075::GET_TEMP_REPLY_SIZE; - rememberCommandId = TMP1075::NONE; - break; - default: - return IGNORE_REPLY_DATA; - } - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t Tmp1075Handler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { - switch (id) { - case TMP1075::GET_TEMP: { - int16_t tempValueRaw = 0; - tempValueRaw = packet[0] << 4 | packet[1] >> 4; - float tempValue = ((static_cast(tempValueRaw)) * 0.0625); +ReturnValue_t Tmp1075Handler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { + switch (id) { + case TMP1075::GET_TEMP: { + int16_t tempValueRaw = 0; + tempValueRaw = packet[0] << 4 | packet[1] >> 4; + float tempValue = ((static_cast(tempValueRaw)) * 0.0625); #if OBSW_VERBOSE_LEVEL >= 1 - sif::info << "Tmp1075 with object id: 0x" << std::hex << getObjectId() - << ": Temperature: " << tempValue<< " °C" - << std::endl; + sif::info << "Tmp1075 with object id: 0x" << std::hex << getObjectId() + << ": Temperature: " << tempValue << " °C" << std::endl; #endif - ReturnValue_t result = dataset.read(); - if(result == HasReturnvaluesIF::RETURN_OK) { - dataset.temperatureCelcius = tempValue; - dataset.commit(); - } - break; - } + ReturnValue_t result = dataset.read(); + if (result == HasReturnvaluesIF::RETURN_OK) { + dataset.temperatureCelcius = tempValue; + dataset.commit(); + } + break; + } - default: { - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } - - } - return HasReturnvaluesIF::RETURN_OK; + default: { + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; + } + } + return HasReturnvaluesIF::RETURN_OK; } -void Tmp1075Handler::setNormalDatapoolEntriesInvalid(){ +void Tmp1075Handler::setNormalDatapoolEntriesInvalid() {} +void Tmp1075Handler::prepareAdcConversionCommand() { + cmdBuffer[0] = TMP1075::CFGR_ADDR; + cmdBuffer[1] = TMP1075::ONE_SHOT_MODE >> 8; + cmdBuffer[2] = TMP1075::ONE_SHOT_MODE & 0xFF; } -void Tmp1075Handler::prepareAdcConversionCommand(){ - cmdBuffer[0] = TMP1075::CFGR_ADDR; - cmdBuffer[1] = TMP1075::ONE_SHOT_MODE >> 8; - cmdBuffer[2] = TMP1075::ONE_SHOT_MODE & 0xFF; -} +void Tmp1075Handler::prepareGetTempCommand() { cmdBuffer[0] = TMP1075::TEMP_REG_ADDR; } -void Tmp1075Handler::prepareGetTempCommand(){ - cmdBuffer[0] = TMP1075::TEMP_REG_ADDR; -} +uint32_t Tmp1075Handler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } -uint32_t Tmp1075Handler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){ - return 500; +ReturnValue_t Tmp1075Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(TMP1075::TEMPERATURE_C_TMP1075_1, new PoolEntry({0.0})); + return HasReturnvaluesIF::RETURN_OK; } - -ReturnValue_t Tmp1075Handler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { - localDataPoolMap.emplace(TMP1075::TEMPERATURE_C_TMP1075_1, new PoolEntry( { 0.0 })); - return HasReturnvaluesIF::RETURN_OK; -} - diff --git a/mission/devices/Tmp1075Handler.h b/mission/devices/Tmp1075Handler.h index 190ac47f..3077cf1a 100644 --- a/mission/devices/Tmp1075Handler.h +++ b/mission/devices/Tmp1075Handler.h @@ -15,54 +15,46 @@ * * @author J. Meier */ -class Tmp1075Handler: public DeviceHandlerBase { -public: +class Tmp1075Handler : public DeviceHandlerBase { + public: + Tmp1075Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie); + virtual ~Tmp1075Handler(); - Tmp1075Handler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie); - virtual ~Tmp1075Handler(); + 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; -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; + private: + /** + * @brief Function fills cmdBuffer with command to start the adc + * conversion for a new temperature value. + */ + void prepareAdcConversionCommand(); -private: + void prepareGetTempCommand(); - /** - * @brief Function fills cmdBuffer with command to start the adc - * conversion for a new temperature value. - */ - void prepareAdcConversionCommand(); + enum class CommunicationStep { START_ADC_CONVERSION, GET_TEMPERATURE }; - void prepareGetTempCommand(); + TMP1075::Tmp1075Dataset dataset; - enum class CommunicationStep { - START_ADC_CONVERSION, - GET_TEMPERATURE - }; + static const uint8_t MAX_CMD_LEN = 3; - TMP1075::Tmp1075Dataset dataset; - - static const uint8_t MAX_CMD_LEN = 3; - - uint8_t rememberRequestedSize = 0; - uint8_t rememberCommandId = TMP1075::NONE; - uint8_t cmdBuffer[MAX_CMD_LEN]; - CommunicationStep communicationStep = - CommunicationStep::START_ADC_CONVERSION; + uint8_t rememberRequestedSize = 0; + uint8_t rememberCommandId = TMP1075::NONE; + uint8_t cmdBuffer[MAX_CMD_LEN]; + CommunicationStep communicationStep = CommunicationStep::START_ADC_CONVERSION; }; #endif /* MISSION_DEVICES_TMP1075HANDLER_H_ */ diff --git a/mission/devices/devicedefinitions/GPSDefinitions.h b/mission/devices/devicedefinitions/GPSDefinitions.h index aea442a2..ce58f680 100644 --- a/mission/devices/devicedefinitions/GPSDefinitions.h +++ b/mission/devices/devicedefinitions/GPSDefinitions.h @@ -1,8 +1,8 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_GPSDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_GPSDEFINITIONS_H_ -#include "fsfw/devicehandlers/DeviceHandlerIF.h" #include "fsfw/datapoollocal/StaticLocalDataSet.h" +#include "fsfw/devicehandlers/DeviceHandlerIF.h" namespace GpsHyperion { @@ -11,60 +11,53 @@ static constexpr DeviceCommandId_t TRIGGER_RESET_PIN = 5; static constexpr uint32_t DATASET_ID = 0; -enum GpsPoolIds: lp_id_t { - LATITUDE = 0, - LONGITUDE = 1, - ALTITUDE = 2, - SPEED = 3, - FIX_MODE = 4, - SATS_IN_USE = 5, - SATS_IN_VIEW = 6, - UNIX_SECONDS = 7, - YEAR = 8, - MONTH = 9, - DAY = 10, - HOURS = 11, - MINUTES = 12, - SECONDS = 13 +enum GpsPoolIds : lp_id_t { + LATITUDE = 0, + LONGITUDE = 1, + ALTITUDE = 2, + SPEED = 3, + FIX_MODE = 4, + SATS_IN_USE = 5, + SATS_IN_VIEW = 6, + UNIX_SECONDS = 7, + YEAR = 8, + MONTH = 9, + DAY = 10, + HOURS = 11, + MINUTES = 12, + SECONDS = 13 }; -enum GpsFixModes: uint8_t { - INVALID = 0, - NO_FIX = 1, - FIX_2D = 2, - FIX_3D = 3 -}; +enum GpsFixModes : uint8_t { INVALID = 0, NO_FIX = 1, FIX_2D = 2, FIX_3D = 3 }; -} +} // namespace GpsHyperion -class GpsPrimaryDataset: public StaticLocalDataSet<18> { -public: - GpsPrimaryDataset(object_id_t gpsId): - StaticLocalDataSet(sid_t(gpsId, GpsHyperion::DATASET_ID)) { - setAllVariablesReadOnly(); - } +class GpsPrimaryDataset : public StaticLocalDataSet<18> { + public: + GpsPrimaryDataset(object_id_t gpsId) : StaticLocalDataSet(sid_t(gpsId, GpsHyperion::DATASET_ID)) { + setAllVariablesReadOnly(); + } - lp_var_t latitude = lp_var_t(sid.objectId, - GpsHyperion::LATITUDE, this); - lp_var_t longitude = lp_var_t(sid.objectId, - GpsHyperion::LONGITUDE, this); - lp_var_t altitude = lp_var_t(sid.objectId, GpsHyperion::ALTITUDE, this); - lp_var_t speed = lp_var_t(sid.objectId, GpsHyperion::SPEED, this); - lp_var_t fixMode = lp_var_t(sid.objectId, GpsHyperion::FIX_MODE, this); - lp_var_t satInUse = lp_var_t(sid.objectId, GpsHyperion::SATS_IN_USE, this); - lp_var_t satInView = lp_var_t(sid.objectId, GpsHyperion::SATS_IN_VIEW, this); - lp_var_t year = lp_var_t(sid.objectId, GpsHyperion::YEAR, this); - lp_var_t month = lp_var_t(sid.objectId, GpsHyperion::MONTH, this); - lp_var_t day = lp_var_t(sid.objectId, GpsHyperion::DAY, this); - lp_var_t hours = lp_var_t(sid.objectId, GpsHyperion::HOURS, this); - lp_var_t minutes = lp_var_t(sid.objectId, GpsHyperion::MINUTES, this); - lp_var_t seconds = lp_var_t(sid.objectId, GpsHyperion::SECONDS, this); - lp_var_t unixSeconds = lp_var_t(sid.objectId, - GpsHyperion::UNIX_SECONDS, this); -private: - friend class GPSHyperionHandler; - GpsPrimaryDataset(HasLocalDataPoolIF* hkOwner): - StaticLocalDataSet(hkOwner, GpsHyperion::DATASET_ID) {} + lp_var_t latitude = lp_var_t(sid.objectId, GpsHyperion::LATITUDE, this); + lp_var_t longitude = lp_var_t(sid.objectId, GpsHyperion::LONGITUDE, this); + lp_var_t altitude = lp_var_t(sid.objectId, GpsHyperion::ALTITUDE, this); + lp_var_t speed = lp_var_t(sid.objectId, GpsHyperion::SPEED, this); + lp_var_t fixMode = lp_var_t(sid.objectId, GpsHyperion::FIX_MODE, this); + lp_var_t satInUse = lp_var_t(sid.objectId, GpsHyperion::SATS_IN_USE, this); + lp_var_t satInView = lp_var_t(sid.objectId, GpsHyperion::SATS_IN_VIEW, this); + lp_var_t year = lp_var_t(sid.objectId, GpsHyperion::YEAR, this); + lp_var_t month = lp_var_t(sid.objectId, GpsHyperion::MONTH, this); + lp_var_t day = lp_var_t(sid.objectId, GpsHyperion::DAY, this); + lp_var_t hours = lp_var_t(sid.objectId, GpsHyperion::HOURS, this); + lp_var_t minutes = lp_var_t(sid.objectId, GpsHyperion::MINUTES, this); + lp_var_t seconds = lp_var_t(sid.objectId, GpsHyperion::SECONDS, this); + lp_var_t unixSeconds = + lp_var_t(sid.objectId, GpsHyperion::UNIX_SECONDS, this); + + private: + friend class GPSHyperionHandler; + GpsPrimaryDataset(HasLocalDataPoolIF* hkOwner) + : StaticLocalDataSet(hkOwner, GpsHyperion::DATASET_ID) {} }; #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GPSDEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/GomSpacePackets.h b/mission/devices/devicedefinitions/GomSpacePackets.h index d410a3af..e6736255 100644 --- a/mission/devices/devicedefinitions/GomSpacePackets.h +++ b/mission/devices/devicedefinitions/GomSpacePackets.h @@ -2,37 +2,32 @@ #define MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEPACKETS_H_ #include -#include -#include #include +#include +#include #include - /** * @brief This class can be used to generated the command for the CspComIF * to reset the watchdog in a gomspace device. */ class WatchdogResetCommand : public SerialLinkedListAdapter { -public: + public: + WatchdogResetCommand() { setLinks(); } - WatchdogResetCommand() { - setLinks(); - } - -private: - WatchdogResetCommand(const WatchdogResetCommand &command); - void setLinks() { - setStart(&cspPort); - cspPort.setNext(&querySize); - querySize.setNext(&magic); - } - SerializeElement cspPort = GOMSPACE::P60_PORT_GNDWDT_RESET; - SerializeElement querySize = 1; - /* Sending 0x78 to port 9 of a gomspace device resets the ground watchdog */ - SerializeElement magic = 0x78; + private: + WatchdogResetCommand(const WatchdogResetCommand &command); + void setLinks() { + setStart(&cspPort); + cspPort.setNext(&querySize); + querySize.setNext(&magic); + } + SerializeElement cspPort = GOMSPACE::P60_PORT_GNDWDT_RESET; + SerializeElement querySize = 1; + /* Sending 0x78 to port 9 of a gomspace device resets the ground watchdog */ + SerializeElement magic = 0x78; }; - /** * @brief A serial linked list adapter implementation to generate ping * commands for devices supporting the CSP protocol. This command can @@ -44,33 +39,32 @@ private: * transmitted to the target device. */ class CspPingCommand : public SerialLinkedListAdapter { -public: - /** - * @brief Constructor - * - * @param querySize_ The size of bytes replied by the ping request. - * Amounts to the number of bytes send. - * @param data_ Pointer to data which should be sent to the device. - * All data will be sent back by the ping target. - */ - CspPingCommand(const uint8_t* data_, uint16_t querySize_) : - querySize(querySize_), data(data_, querySize_) { - setLinks(); - } + public: + /** + * @brief Constructor + * + * @param querySize_ The size of bytes replied by the ping request. + * Amounts to the number of bytes send. + * @param data_ Pointer to data which should be sent to the device. + * All data will be sent back by the ping target. + */ + CspPingCommand(const uint8_t *data_, uint16_t querySize_) + : querySize(querySize_), data(data_, querySize_) { + setLinks(); + } -private: - CspPingCommand(const CspPingCommand &command); - void setLinks() { - setStart(&cspPort); - cspPort.setNext(&querySize); - querySize.setNext(&data); - } - SerializeElement cspPort = GOMSPACE::PING_PORT; - SerializeElement querySize; - SerializeElement> data; + private: + CspPingCommand(const CspPingCommand &command); + void setLinks() { + setStart(&cspPort); + cspPort.setNext(&querySize); + querySize.setNext(&data); + } + SerializeElement cspPort = GOMSPACE::PING_PORT; + SerializeElement querySize; + SerializeElement> data; }; - /** * @brief A serial linked list adapter implementation of the gs_rparam_query_t * struct defined in rparam.h. Can be used to build the message to set @@ -81,47 +75,49 @@ private: * and the size to query. */ class CspSetParamCommand : public SerialLinkedListAdapter { -public: + public: + CspSetParamCommand(uint16_t querySize_, uint16_t payloadlength_, uint16_t checksum_, + uint16_t seq_, uint16_t total_, uint16_t addr_, const uint8_t *parameter_, + uint8_t parameterCount_) + : querySize(querySize_), + payloadlength(payloadlength_), + checksum(checksum_), + seq(seq_), + total(total_), + addr(addr_), + parameter(parameter_, parameterCount_) { + setLinks(); + } - CspSetParamCommand(uint16_t querySize_, uint16_t payloadlength_, - uint16_t checksum_, uint16_t seq_, uint16_t total_, uint16_t addr_, - const uint8_t* parameter_, uint8_t parameterCount_) : - querySize(querySize_), payloadlength( - payloadlength_), checksum(checksum_), seq(seq_), total( - total_), addr(addr_), parameter(parameter_, parameterCount_) { - setLinks(); - } - -private: - CspSetParamCommand(const CspSetParamCommand &command); - void setLinks() { - setStart(&cspPort); - cspPort.setNext(&querySize); - querySize.setNext(&action); - action.setNext(&tableId); - tableId.setNext(&payloadlength); - payloadlength.setNext(&checksum); - checksum.setNext(&seq); - seq.setNext(&total); - total.setNext(&addr); - addr.setNext(¶meter); - } - SerializeElement cspPort = GOMSPACE::PARAM_PORT; - /* Only a parameter will be set. No data will be queried with this command */ - SerializeElement querySize; - SerializeElement action = 0xFF; // param set - /* We will never set a parameter in a table other than the configuration - * table */ - SerializeElement tableId = 1; - SerializeElement payloadlength; - SerializeElement checksum; - SerializeElement seq; - SerializeElement total; - SerializeElement addr; - SerializeElement> parameter; + private: + CspSetParamCommand(const CspSetParamCommand &command); + void setLinks() { + setStart(&cspPort); + cspPort.setNext(&querySize); + querySize.setNext(&action); + action.setNext(&tableId); + tableId.setNext(&payloadlength); + payloadlength.setNext(&checksum); + checksum.setNext(&seq); + seq.setNext(&total); + total.setNext(&addr); + addr.setNext(¶meter); + } + SerializeElement cspPort = GOMSPACE::PARAM_PORT; + /* Only a parameter will be set. No data will be queried with this command */ + SerializeElement querySize; + SerializeElement action = 0xFF; // param set + /* We will never set a parameter in a table other than the configuration + * table */ + SerializeElement tableId = 1; + SerializeElement payloadlength; + SerializeElement checksum; + SerializeElement seq; + SerializeElement total; + SerializeElement addr; + SerializeElement> parameter; }; - /** * @brief This class can be used to generate a get param command for the * gomspace devices which will be sent to the device communication @@ -131,50 +127,50 @@ private: * and will not be transmitted physically to the target device. */ class CspGetParamCommand : public SerialLinkedListAdapter { -public: - /* The size of the header of a gomspace CSP packet. */ - static const uint8_t GS_HDR_LENGTH = 12; + public: + /* The size of the header of a gomspace CSP packet. */ + static const uint8_t GS_HDR_LENGTH = 12; - CspGetParamCommand(uint16_t querySize_, uint8_t tableId_, - uint16_t addresslength_, uint16_t checksum_, uint16_t seq_, - uint16_t total_, uint16_t addr_) : - querySize(querySize_), tableId(tableId_), addresslength( - addresslength_), checksum(checksum_), seq(seq_), total( - total_), addr(addr_) { - fixedValuesInit(); - setLinks(); - } + CspGetParamCommand(uint16_t querySize_, uint8_t tableId_, uint16_t addresslength_, + uint16_t checksum_, uint16_t seq_, uint16_t total_, uint16_t addr_) + : querySize(querySize_), + tableId(tableId_), + addresslength(addresslength_), + checksum(checksum_), + seq(seq_), + total(total_), + addr(addr_) { + fixedValuesInit(); + setLinks(); + } -private: - CspGetParamCommand(const CspGetParamCommand &command); - void setLinks() { - setStart(&cspPort); - cspPort.setNext(&querySize); - querySize.setNext(&action); - action.setNext(&tableId); - tableId.setNext(&addresslength); - addresslength.setNext(&checksum); - checksum.setNext(&seq); - seq.setNext(&total); - total.setNext(&addr); - } - void fixedValuesInit(){ - cspPort.entry = GOMSPACE::PARAM_PORT; - } - SerializeElement cspPort; - SerializeElement querySize; // size of bytes to query - /* Following information will also be physically transmitted to the target - * device*/ - SerializeElement action = 0x00; // get param - SerializeElement tableId; - SerializeElement addresslength; - SerializeElement checksum; - SerializeElement seq; - SerializeElement total; - SerializeElement addr; + private: + CspGetParamCommand(const CspGetParamCommand &command); + void setLinks() { + setStart(&cspPort); + cspPort.setNext(&querySize); + querySize.setNext(&action); + action.setNext(&tableId); + tableId.setNext(&addresslength); + addresslength.setNext(&checksum); + checksum.setNext(&seq); + seq.setNext(&total); + total.setNext(&addr); + } + void fixedValuesInit() { cspPort.entry = GOMSPACE::PARAM_PORT; } + SerializeElement cspPort; + SerializeElement querySize; // size of bytes to query + /* Following information will also be physically transmitted to the target + * device*/ + SerializeElement action = 0x00; // get param + SerializeElement tableId; + SerializeElement addresslength; + SerializeElement checksum; + SerializeElement seq; + SerializeElement total; + SerializeElement addr; }; - /** * @brief This class can be used to generate a get param command for the * gomspace devices which will be sent to the device communication @@ -184,205 +180,186 @@ private: * and will not be transmitted physically to the target device. */ class RequestFullTableCommand : public SerialLinkedListAdapter { -public: + public: + RequestFullTableCommand(uint16_t querySize_, uint8_t tableId_) + : querySize(querySize_), tableId(tableId_) { + setLinks(); + } - RequestFullTableCommand(uint16_t querySize_, uint8_t tableId_) : - querySize(querySize_), tableId(tableId_) { - setLinks(); - } - -private: - RequestFullTableCommand(const RequestFullTableCommand &command); - void setLinks() { - setStart(&cspPort); - cspPort.setNext(&querySize); - querySize.setNext(&action); - action.setNext(&tableId); - tableId.setNext(&addresslength); - addresslength.setNext(&checksum); - checksum.setNext(&seq); - seq.setNext(&total); - } - SerializeElement cspPort = GOMSPACE::PARAM_PORT; - /** Size of bytes to query (size of csp header + size of table) */ - SerializeElement querySize; - /* Following information will also be physically transmitted to the target - * device*/ - SerializeElement action = 0x00; // get param - SerializeElement tableId; - /* Size of address. Set to 0 to get full table */ - SerializeElement addresslength = 0; - SerializeElement checksum = GOMSPACE::IGNORE_CHECKSUM; - SerializeElement seq = 0; - SerializeElement total = 0; + private: + RequestFullTableCommand(const RequestFullTableCommand &command); + void setLinks() { + setStart(&cspPort); + cspPort.setNext(&querySize); + querySize.setNext(&action); + action.setNext(&tableId); + tableId.setNext(&addresslength); + addresslength.setNext(&checksum); + checksum.setNext(&seq); + seq.setNext(&total); + } + SerializeElement cspPort = GOMSPACE::PARAM_PORT; + /** Size of bytes to query (size of csp header + size of table) */ + SerializeElement querySize; + /* Following information will also be physically transmitted to the target + * device*/ + SerializeElement action = 0x00; // get param + SerializeElement tableId; + /* Size of address. Set to 0 to get full table */ + SerializeElement addresslength = 0; + SerializeElement checksum = GOMSPACE::IGNORE_CHECKSUM; + SerializeElement seq = 0; + SerializeElement total = 0; }; - /** * @brief This class can be used to deserialize replies from gomspace devices * and extract the relevant data. */ class CspGetParamReply : public SerialLinkedListAdapter { -public: - /** - * @brief Constructor - * - * @param payloadBuffer Pointer to a buffer to store the payload data of - * the CSP packet. - * @param payloadBufferSz The size of the payload buffer where the payload - * data will be stored. - */ - CspGetParamReply(uint8_t* payloadBuffer_, uint8_t payloadBufferSz_) : - payload(payloadBuffer_, payloadBufferSz_) { - setLinks(); - } + public: + /** + * @brief Constructor + * + * @param payloadBuffer Pointer to a buffer to store the payload data of + * the CSP packet. + * @param payloadBufferSz The size of the payload buffer where the payload + * data will be stored. + */ + CspGetParamReply(uint8_t *payloadBuffer_, uint8_t payloadBufferSz_) + : payload(payloadBuffer_, payloadBufferSz_) { + setLinks(); + } - uint8_t getAction(){ - return action; - } + uint8_t getAction() { return action; } - uint8_t getTableId(){ - return tableId; - } + uint8_t getTableId() { return tableId; } - uint16_t getLength(){ - return length; - } + uint16_t getLength() { return length; } - uint16_t getAddress(){ - return addr; - } + uint16_t getAddress() { return addr; } -private: - CspGetParamReply(const CspGetParamReply &reply); - void setLinks() { - setStart(&action); - action.setNext(&tableId); - tableId.setNext(&length); - length.setNext(&checksum); - checksum.setNext(&seq); - seq.setNext(&total); - total.setNext(&addr); - addr.setNext(&payload); - } + private: + CspGetParamReply(const CspGetParamReply &reply); + void setLinks() { + setStart(&action); + action.setNext(&tableId); + tableId.setNext(&length); + length.setNext(&checksum); + checksum.setNext(&seq); + seq.setNext(&total); + total.setNext(&addr); + addr.setNext(&payload); + } - SerializeElement action; - SerializeElement tableId; - SerializeElement length; //length of address field + payload data - SerializeElement checksum; - SerializeElement seq; - SerializeElement total; - SerializeElement addr; - SerializeElement> payload; + SerializeElement action; + SerializeElement tableId; + SerializeElement length; // length of address field + payload data + SerializeElement checksum; + SerializeElement seq; + SerializeElement total; + SerializeElement addr; + SerializeElement> payload; }; - /** * @brief This class generates telemetry packets containing data from * CSP get-parameter-replies. */ class ParamReply : public SerialLinkedListAdapter { -public: - /** - * @brief Constructor - * - * @param payloadBuffer Pointer to a buffer to store the payload data of - * the CSP packet. - * @param payloadBufferSz The size of the payload buffer where the payload - * data will be stored. - */ - ParamReply(uint8_t action_, uint8_t tableId_, uint16_t addr_, - uint16_t payloadLength_, uint8_t* payloadBuffer_) : - action(action_), tableId(tableId_), addr(addr_), payloadLength( - payloadLength_), payload(payloadBuffer_, payloadLength) { - setLinks(); - } + public: + /** + * @brief Constructor + * + * @param payloadBuffer Pointer to a buffer to store the payload data of + * the CSP packet. + * @param payloadBufferSz The size of the payload buffer where the payload + * data will be stored. + */ + ParamReply(uint8_t action_, uint8_t tableId_, uint16_t addr_, uint16_t payloadLength_, + uint8_t *payloadBuffer_) + : action(action_), + tableId(tableId_), + addr(addr_), + payloadLength(payloadLength_), + payload(payloadBuffer_, payloadLength) { + setLinks(); + } -private: - ParamReply(const CspGetParamReply &reply); - void setLinks() { - setStart(&action); - action.setNext(&tableId); - tableId.setNext(&addr); - addr.setNext(&payloadLength); - payloadLength.setNext(&payload); - } - SerializeElement action; - SerializeElement tableId; - SerializeElement addr; - SerializeElement payloadLength; - SerializeElement> payload; + private: + ParamReply(const CspGetParamReply &reply); + void setLinks() { + setStart(&action); + action.setNext(&tableId); + tableId.setNext(&addr); + addr.setNext(&payloadLength); + payloadLength.setNext(&payload); + } + SerializeElement action; + SerializeElement tableId; + SerializeElement addr; + SerializeElement payloadLength; + SerializeElement> payload; }; - /** - * @brief This class generates the reply containing data from a full housekeeping table request - * of the PDU2. + * @brief This class generates the reply containing data from a full housekeeping table + * request of the PDU2. */ class Pdu2FullTableReply : public SerialLinkedListAdapter { -public: - /** - * @brief Constructor - * - * @param action_ The command which triggered the full table request. - * @param tableId_ The id of the requested table. - * @param tableDataset_ The dataset holding the table data. - */ - Pdu2FullTableReply(uint8_t action_, uint8_t tableId_, SerializeIF* tableDataset_) : - action(action_), tableId(tableId_), dataset(tableDataset_) { - setLinks(); - } + public: + /** + * @brief Constructor + * + * @param action_ The command which triggered the full table request. + * @param tableId_ The id of the requested table. + * @param tableDataset_ The dataset holding the table data. + */ + Pdu2FullTableReply(uint8_t action_, uint8_t tableId_, SerializeIF *tableDataset_) + : action(action_), tableId(tableId_), dataset(tableDataset_) { + setLinks(); + } -private: - Pdu2FullTableReply(const Pdu2FullTableReply &reply); - void setLinks() { - setStart(&action); - action.setNext(&tableId); - tableId.setNext(&dataset); - } - SerializeElement action; - SerializeElement tableId; - LinkedElement dataset; + private: + Pdu2FullTableReply(const Pdu2FullTableReply &reply); + void setLinks() { + setStart(&action); + action.setNext(&tableId); + tableId.setNext(&dataset); + } + SerializeElement action; + SerializeElement tableId; + LinkedElement dataset; }; - /** * @brief This class helps to unpack information from an action message * to set a parameter in gomspace devices. The action message can be * for example received from the PUS Service 8. */ -class SetParamMessageUnpacker: public SerialLinkedListAdapter { -public: - /* Largest parameter is a uint32_t */ - static const uint32_t MAX_SIZE = 4; +class SetParamMessageUnpacker : public SerialLinkedListAdapter { + public: + /* Largest parameter is a uint32_t */ + static const uint32_t MAX_SIZE = 4; - SetParamMessageUnpacker() { - setLinks(); - } + SetParamMessageUnpacker() { setLinks(); } - uint16_t getAddress() { - return address; - } + uint16_t getAddress() { return address; } - uint8_t* getParameter() { - return parameter->front(); - } + uint8_t *getParameter() { return parameter->front(); } - uint8_t getParameterSize(){ - return parameter->size; - } + uint8_t getParameterSize() { return parameter->size; } -private: - void setLinks() { - setStart(&address); - address.setNext(¶meter); - } - SetParamMessageUnpacker(const SetParamMessageUnpacker &message); - SerializeElement address; - SerializeElement> parameter; + private: + void setLinks() { + setStart(&address); + address.setNext(¶meter); + } + SetParamMessageUnpacker(const SetParamMessageUnpacker &message); + SerializeElement address; + SerializeElement> parameter; }; - /** * @brief This class generates a message which can be sent to the GomspaceDeviceHandler to * command a parameter change. @@ -391,76 +368,64 @@ private: * | memory address | size of parameter value | parameter value | */ class GomspaceSetParamMessage : public SerialLinkedListAdapter { -public: + public: + /* The size of the largest parameter */ + static const uint8_t MAX_SIZE = 4; - /* The size of the largest parameter */ - static const uint8_t MAX_SIZE = 4; + /** + * @brief Constructor + * + * @param memoryAddress The address of the parameter to change in the configuration table. + * @param parameterValue Pointer to the parameter value to set. + * @param parameterSize The size of the parameter. + * + */ + GomspaceSetParamMessage(uint16_t memoryAddress, const uint8_t *parameterValue, + uint8_t parameterSize) + : memoryAddress(memoryAddress), parameterValueBuffer(parameterValue, parameterSize, true) { + setLinks(); + } - /** - * @brief Constructor - * - * @param memoryAddress The address of the parameter to change in the configuration table. - * @param parameterValue Pointer to the parameter value to set. - * @param parameterSize The size of the parameter. - * - */ - GomspaceSetParamMessage(uint16_t memoryAddress, const uint8_t* parameterValue, - uint8_t parameterSize) : - memoryAddress(memoryAddress), parameterValueBuffer(parameterValue, parameterSize, true) { - setLinks(); - } - -private: - GomspaceSetParamMessage(const GomspaceSetParamMessage &reply); - void setLinks() { - setStart(&memoryAddress); - memoryAddress.setNext(¶meterValueBuffer); - } - SerializeElement memoryAddress; - /** - * Parameter can be uint8_t, uint16_t or uint32_t. Thus max size of parameterValueBuffer is - * four bytes. - */ - SerializeElement> parameterValueBuffer; + private: + GomspaceSetParamMessage(const GomspaceSetParamMessage &reply); + void setLinks() { + setStart(&memoryAddress); + memoryAddress.setNext(¶meterValueBuffer); + } + SerializeElement memoryAddress; + /** + * Parameter can be uint8_t, uint16_t or uint32_t. Thus max size of parameterValueBuffer is + * four bytes. + */ + SerializeElement> parameterValueBuffer; }; - /** * @brief This class helps to unpack information from an action message * to get a parameter from gomspace devices. The action message can be * for example received from the PUS Service 8. */ -class GetParamMessageUnpacker: public SerialLinkedListAdapter { -public: +class GetParamMessageUnpacker : public SerialLinkedListAdapter { + public: + GetParamMessageUnpacker() { setLinks(); } - GetParamMessageUnpacker() { - setLinks(); - } + uint8_t getTableId() { return tableId; } - uint8_t getTableId() { - return tableId; - } + uint16_t getAddress() { return address; } - uint16_t getAddress() { - return address; - } + uint8_t getParameterSize() { return parameterSize; } - uint8_t getParameterSize(){ - return parameterSize; - } - - -private: - GetParamMessageUnpacker(const GetParamMessageUnpacker &message); - void setLinks() { - setStart(&tableId); - tableId.setNext(&address); - address.setNext(¶meterSize); - } - SerializeElement tableId; - SerializeElement address; //The memory address offset within the table - /* The size of the requested value (e.g. temperature is a uint16_t value) */ - SerializeElement parameterSize; + private: + GetParamMessageUnpacker(const GetParamMessageUnpacker &message); + void setLinks() { + setStart(&tableId); + tableId.setNext(&address); + address.setNext(¶meterSize); + } + SerializeElement tableId; + SerializeElement address; // The memory address offset within the table + /* The size of the requested value (e.g. temperature is a uint16_t value) */ + SerializeElement parameterSize; }; #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEPACKETS_H_ */ diff --git a/mission/devices/devicedefinitions/GomspaceDefinitions.h b/mission/devices/devicedefinitions/GomspaceDefinitions.h index 0fbbc5b0..a575747f 100644 --- a/mission/devices/devicedefinitions/GomspaceDefinitions.h +++ b/mission/devices/devicedefinitions/GomspaceDefinitions.h @@ -9,12 +9,13 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEDEFINITIONS_H_ -#include -#include -#include #include +#include +#include -namespace GOMSPACE{ +#include + +namespace GOMSPACE { 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; @@ -29,339 +30,337 @@ static const uint8_t P60_PORT_GNDWDT_RESET = 9; * Device commands are derived from the rparam.h of the gomspace lib.. * IDs above 50 are reserved for device specific commands. */ -static const DeviceCommandId_t PING = 1; //!< [EXPORT] : [COMMAND] -static const DeviceCommandId_t NONE = 2; // Set when no command is pending -static const DeviceCommandId_t REBOOT = 4; //!< [EXPORT] : [COMMAND] -static const DeviceCommandId_t GNDWDT_RESET = 9; //!< [EXPORT] : [COMMAND] -static const DeviceCommandId_t PARAM_GET = 0; //!< [EXPORT] : [COMMAND] -static const DeviceCommandId_t PARAM_SET = 255; //!< [EXPORT] : [COMMAND] -static const DeviceCommandId_t REQUEST_HK_TABLE = 16; //!< [EXPORT] : [COMMAND] +static const DeviceCommandId_t PING = 1; //!< [EXPORT] : [COMMAND] +static const DeviceCommandId_t NONE = 2; // Set when no command is pending +static const DeviceCommandId_t REBOOT = 4; //!< [EXPORT] : [COMMAND] +static const DeviceCommandId_t GNDWDT_RESET = 9; //!< [EXPORT] : [COMMAND] +static const DeviceCommandId_t PARAM_GET = 0; //!< [EXPORT] : [COMMAND] +static const DeviceCommandId_t PARAM_SET = 255; //!< [EXPORT] : [COMMAND] +static const DeviceCommandId_t REQUEST_HK_TABLE = 16; //!< [EXPORT] : [COMMAND] //!< [EXPORT] : [COMMAND] Print switch states, voltages and currents to the console static const DeviceCommandId_t PRINT_SWITCH_V_I = 32; - -} +} // namespace GOMSPACE namespace P60System { -enum P60SytemPoolIds: lp_id_t { - P60DOCK_CURRENT_ACU_VCC, - P60DOCK_CURRENT_PDU1_VCC, - P60DOCK_CURRENT_X3_IDLE_VCC, - P60DOCK_CURRENT_PDU2_VCC, - P60DOCK_CURRENT_ACU_VBAT, - P60DOCK_CURRENT_PDU1_VBAT, - P60DOCK_CURRENT_X3_IDLE_VBAT, - P60DOCK_CURRENT_PDU2_VBAT, - P60DOCK_CURRENT_STACK_VBAT, - P60DOCK_CURRENT_STACK_3V3, - P60DOCK_CURRENT_STACK_5V, - P60DOCK_CURRENT_GS3V3, - P60DOCK_CURRENT_GS5V, - P60DOCK_VOLTAGE_ACU_VCC, - P60DOCK_VOLTAGE_PDU1_VCC, - P60DOCK_VOLTAGE_X3_IDLE_VCC, - P60DOCK_VOLTAGE_PDU2_VCC, - P60DOCK_VOLTAGE_ACU_VBAT, - P60DOCK_VOLTAGE_PDU1_VBAT, - P60DOCK_VOLTAGE_X3_IDLE_VBAT, - P60DOCK_VOLTAGE_PDU2_VBAT, - P60DOCK_VOLTAGE_STACK_VBAT, - P60DOCK_VOLTAGE_STACK_3V3, - P60DOCK_VOLTAGE_STACK_5V, - P60DOCK_VOLTAGE_GS3V3, - P60DOCK_VOLTAGE_GS5V, - P60DOCK_OUTPUTENABLE_ACU_VCC, - P60DOCK_OUTPUTENABLE_PDU1_VCC, - P60DOCK_OUTPUTENABLE_X3_IDLE_VCC, - P60DOCK_OUTPUTENABLE_PDU2_VCC, - P60DOCK_OUTPUTENABLE_ACU_VBAT, - P60DOCK_OUTPUTENABLE_PDU1_VBAT, - P60DOCK_OUTPUTENABLE_X3_IDLE_VBAT, - P60DOCK_OUTPUTENABLE_PDU2_VBAT, - P60DOCK_OUTPUTENABLE_STACK_VBAT, - P60DOCK_OUTPUTENABLE_STACK_3V3, - P60DOCK_OUTPUTENABLE_STACK_5V, - P60DOCK_OUTPUTENABLE_GS3V3, - P60DOCK_OUTPUTENABLE_GS5V, - P60DOCK_TEMPERATURE_1, - P60DOCK_TEMPERATURE_2, - P60DOCK_BOOT_CAUSE, - P60DOCK_BOOT_CNT, - P60DOCK_UPTIME, - P60DOCK_RESETCAUSE, - P60DOCK_BATT_MODE, - P60DOCK_HEATER_ON, - P60DOCK_CONV_5V_ENABLE_STATUS, - P60DOCK_LATCHUP_ACU_VCC, - P60DOCK_LATCHUP_PDU1_VCC, - P60DOCK_LATCHUP_X3_IDLE_VCC, - P60DOCK_LATCHUP_PDU2_VCC, - P60DOCK_LATCHUP_ACU_VBAT, - P60DOCK_LATCHUP_PDU1_VBAT, - P60DOCK_LATCHUP_X3_IDLE_VBAT, - P60DOCK_LATCHUP_PDU2_VBAT, - P60DOCK_LATCHUP_STACK_VBAT, - P60DOCK_LATCHUP_STACK_3V3, - P60DOCK_LATCHUP_STACK_5V, - P60DOCK_LATCHUP_GS3V3, - P60DOCK_LATCHUP_GS5V, - P60DOCK_VBAT_VALUE, - P60DOCK_VCC_CURRENT_VALUE, - P60DOCK_BATTERY_CURRENT, - P60DOCK_BATTERY_VOLTAGE, - P60DOCK_BATTERY_TEMPERATURE_1, - P60DOCK_BATTERY_TEMPERATURE_2, - P60DOCK_DEVICE_0, - P60DOCK_DEVICE_1, - P60DOCK_DEVICE_2, - P60DOCK_DEVICE_3, - P60DOCK_DEVICE_4, - P60DOCK_DEVICE_5, - P60DOCK_DEVICE_6, - P60DOCK_DEVICE_7, - P60DOCK_DEVICE_0_STATUS, - P60DOCK_DEVICE_1_STATUS, - P60DOCK_DEVICE_2_STATUS, - P60DOCK_DEVICE_3_STATUS, - P60DOCK_DEVICE_4_STATUS, - P60DOCK_DEVICE_5_STATUS, - P60DOCK_DEVICE_6_STATUS, - P60DOCK_DEVICE_7_STATUS, - P60DOCK_DEVICE_TYPE_GROUP, - P60DOCK_DEVICE_STATUS_GROUP, - P60DOCK_DEARM_STATUS, - P60DOCK_WDT_CNT_GND, - P60DOCK_WDT_CNT_I2C, - P60DOCK_WDT_CNT_CAN, - P60DOCK_WDT_CNT_CSP_1, - P60DOCK_WDT_CNT_CSP_2, - P60DOCK_WDT_GND_LEFT, - P60DOCK_WDT_I2C_LEFT, - P60DOCK_WDT_CAN_LEFT, - P60DOCK_WDT_CSP_LEFT_1, - P60DOCK_WDT_CSP_LEFT_2, - P60DOCK_BATT_CHARGE_CURRENT, - P60DOCK_BATT_DISCHARGE_CURRENT, - P60DOCK_ANT6_DEPL, - P60DOCK_AR6_DEPL, +enum P60SytemPoolIds : lp_id_t { + P60DOCK_CURRENT_ACU_VCC, + P60DOCK_CURRENT_PDU1_VCC, + P60DOCK_CURRENT_X3_IDLE_VCC, + P60DOCK_CURRENT_PDU2_VCC, + P60DOCK_CURRENT_ACU_VBAT, + P60DOCK_CURRENT_PDU1_VBAT, + P60DOCK_CURRENT_X3_IDLE_VBAT, + P60DOCK_CURRENT_PDU2_VBAT, + P60DOCK_CURRENT_STACK_VBAT, + P60DOCK_CURRENT_STACK_3V3, + P60DOCK_CURRENT_STACK_5V, + P60DOCK_CURRENT_GS3V3, + P60DOCK_CURRENT_GS5V, + P60DOCK_VOLTAGE_ACU_VCC, + P60DOCK_VOLTAGE_PDU1_VCC, + P60DOCK_VOLTAGE_X3_IDLE_VCC, + P60DOCK_VOLTAGE_PDU2_VCC, + P60DOCK_VOLTAGE_ACU_VBAT, + P60DOCK_VOLTAGE_PDU1_VBAT, + P60DOCK_VOLTAGE_X3_IDLE_VBAT, + P60DOCK_VOLTAGE_PDU2_VBAT, + P60DOCK_VOLTAGE_STACK_VBAT, + P60DOCK_VOLTAGE_STACK_3V3, + P60DOCK_VOLTAGE_STACK_5V, + P60DOCK_VOLTAGE_GS3V3, + P60DOCK_VOLTAGE_GS5V, + P60DOCK_OUTPUTENABLE_ACU_VCC, + P60DOCK_OUTPUTENABLE_PDU1_VCC, + P60DOCK_OUTPUTENABLE_X3_IDLE_VCC, + P60DOCK_OUTPUTENABLE_PDU2_VCC, + P60DOCK_OUTPUTENABLE_ACU_VBAT, + P60DOCK_OUTPUTENABLE_PDU1_VBAT, + P60DOCK_OUTPUTENABLE_X3_IDLE_VBAT, + P60DOCK_OUTPUTENABLE_PDU2_VBAT, + P60DOCK_OUTPUTENABLE_STACK_VBAT, + P60DOCK_OUTPUTENABLE_STACK_3V3, + P60DOCK_OUTPUTENABLE_STACK_5V, + P60DOCK_OUTPUTENABLE_GS3V3, + P60DOCK_OUTPUTENABLE_GS5V, + P60DOCK_TEMPERATURE_1, + P60DOCK_TEMPERATURE_2, + P60DOCK_BOOT_CAUSE, + P60DOCK_BOOT_CNT, + P60DOCK_UPTIME, + P60DOCK_RESETCAUSE, + P60DOCK_BATT_MODE, + P60DOCK_HEATER_ON, + P60DOCK_CONV_5V_ENABLE_STATUS, + P60DOCK_LATCHUP_ACU_VCC, + P60DOCK_LATCHUP_PDU1_VCC, + P60DOCK_LATCHUP_X3_IDLE_VCC, + P60DOCK_LATCHUP_PDU2_VCC, + P60DOCK_LATCHUP_ACU_VBAT, + P60DOCK_LATCHUP_PDU1_VBAT, + P60DOCK_LATCHUP_X3_IDLE_VBAT, + P60DOCK_LATCHUP_PDU2_VBAT, + P60DOCK_LATCHUP_STACK_VBAT, + P60DOCK_LATCHUP_STACK_3V3, + P60DOCK_LATCHUP_STACK_5V, + P60DOCK_LATCHUP_GS3V3, + P60DOCK_LATCHUP_GS5V, + P60DOCK_VBAT_VALUE, + P60DOCK_VCC_CURRENT_VALUE, + P60DOCK_BATTERY_CURRENT, + P60DOCK_BATTERY_VOLTAGE, + P60DOCK_BATTERY_TEMPERATURE_1, + P60DOCK_BATTERY_TEMPERATURE_2, + P60DOCK_DEVICE_0, + P60DOCK_DEVICE_1, + P60DOCK_DEVICE_2, + P60DOCK_DEVICE_3, + P60DOCK_DEVICE_4, + P60DOCK_DEVICE_5, + P60DOCK_DEVICE_6, + P60DOCK_DEVICE_7, + P60DOCK_DEVICE_0_STATUS, + P60DOCK_DEVICE_1_STATUS, + P60DOCK_DEVICE_2_STATUS, + P60DOCK_DEVICE_3_STATUS, + P60DOCK_DEVICE_4_STATUS, + P60DOCK_DEVICE_5_STATUS, + P60DOCK_DEVICE_6_STATUS, + P60DOCK_DEVICE_7_STATUS, + P60DOCK_DEVICE_TYPE_GROUP, + P60DOCK_DEVICE_STATUS_GROUP, + P60DOCK_DEARM_STATUS, + P60DOCK_WDT_CNT_GND, + P60DOCK_WDT_CNT_I2C, + P60DOCK_WDT_CNT_CAN, + P60DOCK_WDT_CNT_CSP_1, + P60DOCK_WDT_CNT_CSP_2, + P60DOCK_WDT_GND_LEFT, + P60DOCK_WDT_I2C_LEFT, + P60DOCK_WDT_CAN_LEFT, + P60DOCK_WDT_CSP_LEFT_1, + P60DOCK_WDT_CSP_LEFT_2, + P60DOCK_BATT_CHARGE_CURRENT, + P60DOCK_BATT_DISCHARGE_CURRENT, + P60DOCK_ANT6_DEPL, + P60DOCK_AR6_DEPL, - PDU1_CURRENT_OUT_TCS_BOARD_3V3, - PDU1_CURRENT_OUT_SYRLINKS, - PDU1_CURRENT_OUT_STAR_TRACKER, - PDU1_CURRENT_OUT_MGT, - PDU1_CURRENT_OUT_SUS_NOMINAL, - PDU1_CURRENT_OUT_SOLAR_CELL_EXP, - PDU1_CURRENT_OUT_PLOC, - PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, - PDU1_CURRENT_OUT_CHANNEL8, - PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, - PDU1_VOLTAGE_OUT_SYRLINKS, - PDU1_VOLTAGE_OUT_STAR_TRACKER, - PDU1_VOLTAGE_OUT_MGT, - PDU1_VOLTAGE_OUT_SUS_NOMINAL, - PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, - PDU1_VOLTAGE_OUT_PLOC, - PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, - PDU1_VOLTAGE_OUT_CHANNEL8, - PDU1_VCC, - PDU1_VBAT, - PDU1_TEMPERATURE, - PDU1_CONV_EN_1, - PDU1_CONV_EN_2, - PDU1_CONV_EN_3, - PDU1_OUT_EN_TCS_BOARD_3V3, - PDU1_OUT_EN_SYRLINKS, - PDU1_OUT_EN_STAR_TRACKER, - PDU1_OUT_EN_MGT, - PDU1_OUT_EN_SUS_NOMINAL, - PDU1_OUT_EN_SOLAR_CELL_EXP, - PDU1_OUT_EN_PLOC, - PDU1_OUT_EN_ACS_BOARD_SIDE_A, - PDU1_OUT_EN_CHANNEL8, - PDU1_BOOTCAUSE, - PDU1_BOOTCNT, - PDU1_UPTIME, - PDU1_RESETCAUSE, - PDU1_BATT_MODE, - PDU1_LATCHUP_TCS_BOARD_3V3, - PDU1_LATCHUP_SYRLINKS, - PDU1_LATCHUP_STAR_TRACKER, - PDU1_LATCHUP_MGT, - PDU1_LATCHUP_SUS_NOMINAL, - PDU1_LATCHUP_SOLAR_CELL_EXP, - PDU1_LATCHUP_PLOC, - PDU1_LATCHUP_ACS_BOARD_SIDE_A, - PDU1_LATCHUP_CHANNEL8, - PDU1_DEVICE_0, - PDU1_DEVICE_1, - PDU1_DEVICE_2, - PDU1_DEVICE_3, - PDU1_DEVICE_4, - PDU1_DEVICE_5, - PDU1_DEVICE_6, - PDU1_DEVICE_7, - PDU1_DEVICE_0_STATUS, - PDU1_DEVICE_1_STATUS, - PDU1_DEVICE_2_STATUS, - PDU1_DEVICE_3_STATUS, - PDU1_DEVICE_4_STATUS, - PDU1_DEVICE_5_STATUS, - PDU1_DEVICE_6_STATUS, - PDU1_DEVICE_7_STATUS, - PDU1_WDT_CNT_GND, - PDU1_WDT_CNT_I2C, - PDU1_WDT_CNT_CAN, - PDU1_WDT_CNT_CSP1, - PDU1_WDT_CNT_CSP2, - PDU1_WDT_GND_LEFT, - PDU1_WDT_I2C_LEFT, - PDU1_WDT_CAN_LEFT, - PDU1_WDT_CSP_LEFT1, - PDU1_WDT_CSP_LEFT2, + PDU1_CURRENT_OUT_TCS_BOARD_3V3, + PDU1_CURRENT_OUT_SYRLINKS, + PDU1_CURRENT_OUT_STAR_TRACKER, + PDU1_CURRENT_OUT_MGT, + PDU1_CURRENT_OUT_SUS_NOMINAL, + PDU1_CURRENT_OUT_SOLAR_CELL_EXP, + PDU1_CURRENT_OUT_PLOC, + PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, + PDU1_CURRENT_OUT_CHANNEL8, + PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, + PDU1_VOLTAGE_OUT_SYRLINKS, + PDU1_VOLTAGE_OUT_STAR_TRACKER, + PDU1_VOLTAGE_OUT_MGT, + PDU1_VOLTAGE_OUT_SUS_NOMINAL, + PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, + PDU1_VOLTAGE_OUT_PLOC, + PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, + PDU1_VOLTAGE_OUT_CHANNEL8, + PDU1_VCC, + PDU1_VBAT, + PDU1_TEMPERATURE, + PDU1_CONV_EN_1, + PDU1_CONV_EN_2, + PDU1_CONV_EN_3, + PDU1_OUT_EN_TCS_BOARD_3V3, + PDU1_OUT_EN_SYRLINKS, + PDU1_OUT_EN_STAR_TRACKER, + PDU1_OUT_EN_MGT, + PDU1_OUT_EN_SUS_NOMINAL, + PDU1_OUT_EN_SOLAR_CELL_EXP, + PDU1_OUT_EN_PLOC, + PDU1_OUT_EN_ACS_BOARD_SIDE_A, + PDU1_OUT_EN_CHANNEL8, + PDU1_BOOTCAUSE, + PDU1_BOOTCNT, + PDU1_UPTIME, + PDU1_RESETCAUSE, + PDU1_BATT_MODE, + PDU1_LATCHUP_TCS_BOARD_3V3, + PDU1_LATCHUP_SYRLINKS, + PDU1_LATCHUP_STAR_TRACKER, + PDU1_LATCHUP_MGT, + PDU1_LATCHUP_SUS_NOMINAL, + PDU1_LATCHUP_SOLAR_CELL_EXP, + PDU1_LATCHUP_PLOC, + PDU1_LATCHUP_ACS_BOARD_SIDE_A, + PDU1_LATCHUP_CHANNEL8, + PDU1_DEVICE_0, + PDU1_DEVICE_1, + PDU1_DEVICE_2, + PDU1_DEVICE_3, + PDU1_DEVICE_4, + PDU1_DEVICE_5, + PDU1_DEVICE_6, + PDU1_DEVICE_7, + PDU1_DEVICE_0_STATUS, + PDU1_DEVICE_1_STATUS, + PDU1_DEVICE_2_STATUS, + PDU1_DEVICE_3_STATUS, + PDU1_DEVICE_4_STATUS, + PDU1_DEVICE_5_STATUS, + PDU1_DEVICE_6_STATUS, + PDU1_DEVICE_7_STATUS, + PDU1_WDT_CNT_GND, + PDU1_WDT_CNT_I2C, + PDU1_WDT_CNT_CAN, + PDU1_WDT_CNT_CSP1, + PDU1_WDT_CNT_CSP2, + PDU1_WDT_GND_LEFT, + PDU1_WDT_I2C_LEFT, + PDU1_WDT_CAN_LEFT, + PDU1_WDT_CSP_LEFT1, + PDU1_WDT_CSP_LEFT2, - /** PDU2 Ids */ - PDU2_CURRENT_OUT_Q7S, - PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, - PDU2_CURRENT_OUT_RW, - PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, - PDU2_CURRENT_OUT_SUS_REDUNDANT, - PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, - PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, - PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, - PDU2_CURRENT_OUT_PAYLOAD_CAMERA, - PDU2_VOLTAGE_OUT_Q7S, - PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, - PDU2_VOLTAGE_OUT_RW, - PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, - PDU2_VOLTAGE_OUT_SUS_REDUNDANT, - PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, - PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, - PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, - PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, - PDU2_VCC, - PDU2_VBAT, - PDU2_TEMPERATURE, - PDU2_CONV_EN_1, - PDU2_CONV_EN_2, - PDU2_CONV_EN_3, - PDU2_OUT_EN_Q7S, - PDU2_OUT_EN_PAYLOAD_PCDU_CH1, - PDU2_OUT_EN_RW, - PDU2_OUT_EN_TCS_BOARD_HEATER_IN, - PDU2_OUT_EN_SUS_REDUNDANT, - PDU2_OUT_EN_DEPLOYMENT_MECHANISM, - PDU2_OUT_EN_PAYLOAD_PCDU_CH6, - PDU2_OUT_EN_ACS_BOARD_SIDE_B, - PDU2_OUT_EN_PAYLOAD_CAMERA, - PDU2_BOOTCAUSE, - PDU2_BOOTCNT, - PDU2_UPTIME, - PDU2_RESETCAUSE, - PDU2_BATT_MODE, - PDU2_LATCHUP_Q7S, - PDU2_LATCHUP_PAYLOAD_PCDU_CH1, - PDU2_LATCHUP_RW, - PDU2_LATCHUP_TCS_BOARD_HEATER_IN, - PDU2_LATCHUP_SUS_REDUNDANT, - PDU2_LATCHUP_DEPLOYMENT_MECHANISM, - PDU2_LATCHUP_PAYLOAD_PCDU_CH6, - PDU2_LATCHUP_ACS_BOARD_SIDE_B, - PDU2_LATCHUP_PAYLOAD_CAMERA, - PDU2_DEVICE_0, - PDU2_DEVICE_1, - PDU2_DEVICE_2, - PDU2_DEVICE_3, - PDU2_DEVICE_4, - PDU2_DEVICE_5, - PDU2_DEVICE_6, - PDU2_DEVICE_7, - PDU2_DEVICE_0_STATUS, - PDU2_DEVICE_1_STATUS, - PDU2_DEVICE_2_STATUS, - PDU2_DEVICE_3_STATUS, - PDU2_DEVICE_4_STATUS, - PDU2_DEVICE_5_STATUS, - PDU2_DEVICE_6_STATUS, - PDU2_DEVICE_7_STATUS, - PDU2_WDT_CNT_GND, - PDU2_WDT_CNT_I2C, - PDU2_WDT_CNT_CAN, - PDU2_WDT_CNT_CSP1, - PDU2_WDT_CNT_CSP2, - PDU2_WDT_GND_LEFT, - PDU2_WDT_I2C_LEFT, - PDU2_WDT_CAN_LEFT, - PDU2_WDT_CSP_LEFT1, - PDU2_WDT_CSP_LEFT2, + /** PDU2 Ids */ + PDU2_CURRENT_OUT_Q7S, + PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, + PDU2_CURRENT_OUT_RW, + PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, + PDU2_CURRENT_OUT_SUS_REDUNDANT, + PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, + PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, + PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, + PDU2_CURRENT_OUT_PAYLOAD_CAMERA, + PDU2_VOLTAGE_OUT_Q7S, + PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, + PDU2_VOLTAGE_OUT_RW, + PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, + PDU2_VOLTAGE_OUT_SUS_REDUNDANT, + PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, + PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, + PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, + PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, + PDU2_VCC, + PDU2_VBAT, + PDU2_TEMPERATURE, + PDU2_CONV_EN_1, + PDU2_CONV_EN_2, + PDU2_CONV_EN_3, + PDU2_OUT_EN_Q7S, + PDU2_OUT_EN_PAYLOAD_PCDU_CH1, + PDU2_OUT_EN_RW, + PDU2_OUT_EN_TCS_BOARD_HEATER_IN, + PDU2_OUT_EN_SUS_REDUNDANT, + PDU2_OUT_EN_DEPLOYMENT_MECHANISM, + PDU2_OUT_EN_PAYLOAD_PCDU_CH6, + PDU2_OUT_EN_ACS_BOARD_SIDE_B, + PDU2_OUT_EN_PAYLOAD_CAMERA, + PDU2_BOOTCAUSE, + PDU2_BOOTCNT, + PDU2_UPTIME, + PDU2_RESETCAUSE, + PDU2_BATT_MODE, + PDU2_LATCHUP_Q7S, + PDU2_LATCHUP_PAYLOAD_PCDU_CH1, + PDU2_LATCHUP_RW, + PDU2_LATCHUP_TCS_BOARD_HEATER_IN, + PDU2_LATCHUP_SUS_REDUNDANT, + PDU2_LATCHUP_DEPLOYMENT_MECHANISM, + PDU2_LATCHUP_PAYLOAD_PCDU_CH6, + PDU2_LATCHUP_ACS_BOARD_SIDE_B, + PDU2_LATCHUP_PAYLOAD_CAMERA, + PDU2_DEVICE_0, + PDU2_DEVICE_1, + PDU2_DEVICE_2, + PDU2_DEVICE_3, + PDU2_DEVICE_4, + PDU2_DEVICE_5, + PDU2_DEVICE_6, + PDU2_DEVICE_7, + PDU2_DEVICE_0_STATUS, + PDU2_DEVICE_1_STATUS, + PDU2_DEVICE_2_STATUS, + PDU2_DEVICE_3_STATUS, + PDU2_DEVICE_4_STATUS, + PDU2_DEVICE_5_STATUS, + PDU2_DEVICE_6_STATUS, + PDU2_DEVICE_7_STATUS, + PDU2_WDT_CNT_GND, + PDU2_WDT_CNT_I2C, + PDU2_WDT_CNT_CAN, + PDU2_WDT_CNT_CSP1, + PDU2_WDT_CNT_CSP2, + PDU2_WDT_GND_LEFT, + PDU2_WDT_I2C_LEFT, + PDU2_WDT_CAN_LEFT, + PDU2_WDT_CSP_LEFT1, + PDU2_WDT_CSP_LEFT2, - /** ACU Ids */ - ACU_CURRENT_IN_CHANNEL0, - ACU_CURRENT_IN_CHANNEL1, - ACU_CURRENT_IN_CHANNEL2, - ACU_CURRENT_IN_CHANNEL3, - ACU_CURRENT_IN_CHANNEL4, - ACU_CURRENT_IN_CHANNEL5, - ACU_VOLTAGE_IN_CHANNEL0, - ACU_VOLTAGE_IN_CHANNEL1, - ACU_VOLTAGE_IN_CHANNEL2, - ACU_VOLTAGE_IN_CHANNEL3, - ACU_VOLTAGE_IN_CHANNEL4, - ACU_VOLTAGE_IN_CHANNEL5, - ACU_VCC, - ACU_VBAT, - ACU_TEMPERATURE_1, - ACU_TEMPERATURE_2, - ACU_TEMPERATURE_3, - ACU_MPPT_MODE, - ACU_VBOOST_CHANNEL0, - ACU_VBOOST_CHANNEL1, - ACU_VBOOST_CHANNEL2, - ACU_VBOOST_CHANNEL3, - ACU_VBOOST_CHANNEL4, - ACU_VBOOST_CHANNEL5, - ACU_POWER_CHANNEL0, - ACU_POWER_CHANNEL1, - ACU_POWER_CHANNEL2, - ACU_POWER_CHANNEL3, - ACU_POWER_CHANNEL4, - ACU_POWER_CHANNEL5, - ACU_DAC_EN_0, - ACU_DAC_EN_1, - ACU_DAC_EN_2, - ACU_DAC_RAW_0, - ACU_DAC_RAW_1, - ACU_DAC_RAW_2, - ACU_DAC_RAW_3, - ACU_DAC_RAW_4, - ACU_DAC_RAW_5, - ACU_BOOTCAUSE, - ACU_BOOTCNT, - ACU_UPTIME, - ACU_RESET_CAUSE, - ACU_MPPT_TIME, - ACU_MPPT_PERIOD, - ACU_DEVICE_0, - ACU_DEVICE_1, - ACU_DEVICE_2, - ACU_DEVICE_3, - ACU_DEVICE_4, - ACU_DEVICE_5, - ACU_DEVICE_6, - ACU_DEVICE_7, - ACU_DEVICE_0_STATUS, - ACU_DEVICE_1_STATUS, - ACU_DEVICE_2_STATUS, - ACU_DEVICE_3_STATUS, - ACU_DEVICE_4_STATUS, - ACU_DEVICE_5_STATUS, - ACU_DEVICE_6_STATUS, - ACU_DEVICE_7_STATUS, - ACU_WDT_CNT_GND, - ACU_WDT_GND_LEFT + /** ACU Ids */ + ACU_CURRENT_IN_CHANNEL0, + ACU_CURRENT_IN_CHANNEL1, + ACU_CURRENT_IN_CHANNEL2, + ACU_CURRENT_IN_CHANNEL3, + ACU_CURRENT_IN_CHANNEL4, + ACU_CURRENT_IN_CHANNEL5, + ACU_VOLTAGE_IN_CHANNEL0, + ACU_VOLTAGE_IN_CHANNEL1, + ACU_VOLTAGE_IN_CHANNEL2, + ACU_VOLTAGE_IN_CHANNEL3, + ACU_VOLTAGE_IN_CHANNEL4, + ACU_VOLTAGE_IN_CHANNEL5, + ACU_VCC, + ACU_VBAT, + ACU_TEMPERATURE_1, + ACU_TEMPERATURE_2, + ACU_TEMPERATURE_3, + ACU_MPPT_MODE, + ACU_VBOOST_CHANNEL0, + ACU_VBOOST_CHANNEL1, + ACU_VBOOST_CHANNEL2, + ACU_VBOOST_CHANNEL3, + ACU_VBOOST_CHANNEL4, + ACU_VBOOST_CHANNEL5, + ACU_POWER_CHANNEL0, + ACU_POWER_CHANNEL1, + ACU_POWER_CHANNEL2, + ACU_POWER_CHANNEL3, + ACU_POWER_CHANNEL4, + ACU_POWER_CHANNEL5, + ACU_DAC_EN_0, + ACU_DAC_EN_1, + ACU_DAC_EN_2, + ACU_DAC_RAW_0, + ACU_DAC_RAW_1, + ACU_DAC_RAW_2, + ACU_DAC_RAW_3, + ACU_DAC_RAW_4, + ACU_DAC_RAW_5, + ACU_BOOTCAUSE, + ACU_BOOTCNT, + ACU_UPTIME, + ACU_RESET_CAUSE, + ACU_MPPT_TIME, + ACU_MPPT_PERIOD, + ACU_DEVICE_0, + ACU_DEVICE_1, + ACU_DEVICE_2, + ACU_DEVICE_3, + ACU_DEVICE_4, + ACU_DEVICE_5, + ACU_DEVICE_6, + ACU_DEVICE_7, + ACU_DEVICE_0_STATUS, + ACU_DEVICE_1_STATUS, + ACU_DEVICE_2_STATUS, + ACU_DEVICE_3_STATUS, + ACU_DEVICE_4_STATUS, + ACU_DEVICE_5_STATUS, + ACU_DEVICE_6_STATUS, + ACU_DEVICE_7_STATUS, + ACU_WDT_CNT_GND, + ACU_WDT_GND_LEFT }; } - namespace P60Dock { /** Max reply size reached when requesting full hk table */ @@ -386,240 +385,221 @@ static const uint16_t HK_TABLE_REPLY_SIZE = 407; * The GS port and X3 are not required for EIVE. X3 is another slot on the P60 dock and * GS is required for a module from Gomspace which is not used. */ -class HkTableDataset: - public StaticLocalDataSet { - public: +class HkTableDataset : public StaticLocalDataSet { + public: + HkTableDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) {} - HkTableDataset(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) { - } + HkTableDataset(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) {} - HkTableDataset(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) { - } + /** Measured output currents */ + lp_var_t currentAcuVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_ACU_VCC, this); + lp_var_t currentPdu1Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_PDU1_VCC, this); + lp_var_t currentX3IdleVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_X3_IDLE_VCC, this); + lp_var_t currentPdu2Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_PDU2_VCC, this); + lp_var_t currentAcuVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_ACU_VBAT, this); + lp_var_t currentPdu1Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_PDU1_VBAT, this); + lp_var_t currentX3IdleVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_X3_IDLE_VBAT, this); + lp_var_t currentPdu2Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_PDU2_VBAT, this); + lp_var_t currentStackVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_STACK_VBAT, this); + lp_var_t currentStack3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_STACK_3V3, this); + lp_var_t currentStack5V = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_STACK_5V, this); + lp_var_t currentGS3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_GS3V3, this); + lp_var_t currentGS5V = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_GS5V, this); - /** Measured output currents */ - lp_var_t currentAcuVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_ACU_VCC, this); - lp_var_t currentPdu1Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_PDU1_VCC, this); - lp_var_t currentX3IdleVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_X3_IDLE_VCC, this); - lp_var_t currentPdu2Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_PDU2_VCC, this); - lp_var_t currentAcuVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_ACU_VBAT, this); - lp_var_t currentPdu1Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_PDU1_VBAT, this); - lp_var_t currentX3IdleVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_X3_IDLE_VBAT, this); - lp_var_t currentPdu2Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_PDU2_VBAT, this); - lp_var_t currentStackVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_STACK_VBAT, this); - lp_var_t currentStack3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_STACK_3V3, this); - lp_var_t currentStack5V = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_STACK_5V, this); - lp_var_t currentGS3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_GS3V3, this); - lp_var_t currentGS5V = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_GS5V, this); + /** Measured output voltages */ + lp_var_t voltageAcuVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_ACU_VCC, this); + lp_var_t voltagePdu1Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_PDU1_VCC, this); + lp_var_t voltageX3IdleVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_X3_IDLE_VCC, this); + lp_var_t voltagePdu2Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_PDU2_VCC, this); + lp_var_t voltageAcuVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_ACU_VBAT, this); + lp_var_t voltagePdu1Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_PDU1_VBAT, this); + lp_var_t voltageX3IdleVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_X3_IDLE_VBAT, this); + lp_var_t voltagePdu2Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_PDU2_VBAT, this); + lp_var_t voltageStackVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_STACK_VBAT, this); + lp_var_t voltageStack3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_STACK_3V3, this); + lp_var_t voltageStack5V = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_STACK_5V, this); + lp_var_t voltageGS3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_GS3V3, this); + lp_var_t voltageGS5V = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_GS5V, this); - /** Measured output voltages */ - lp_var_t voltageAcuVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_ACU_VCC, this); - lp_var_t voltagePdu1Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_PDU1_VCC, this); - lp_var_t voltageX3IdleVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_X3_IDLE_VCC, this); - lp_var_t voltagePdu2Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_PDU2_VCC, this); - lp_var_t voltageAcuVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_ACU_VBAT, this); - lp_var_t voltagePdu1Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_PDU1_VBAT, this); - lp_var_t voltageX3IdleVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_X3_IDLE_VBAT, this); - lp_var_t voltagePdu2Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_PDU2_VBAT, this); - lp_var_t voltageStackVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_STACK_VBAT, this); - lp_var_t voltageStack3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_STACK_3V3, this); - lp_var_t voltageStack5V = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_STACK_5V, this); - lp_var_t voltageGS3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_GS3V3, this); - lp_var_t voltageGS5V = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_GS5V, this); + /** Output enable states */ + lp_var_t outputEnableStateAcuVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_ACU_VCC, this); + lp_var_t outputEnableStatePdu1Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_PDU1_VCC, this); + lp_var_t outputEnableStateX3IdleVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VCC, this); + lp_var_t outputEnableStatePdu2Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_PDU2_VCC, this); + lp_var_t outputEnableStateAcuVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_ACU_VBAT, this); + lp_var_t outputEnableStatePdu1Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_PDU1_VBAT, this); + lp_var_t outputEnableStateX3IdleVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VBAT, this); + lp_var_t outputEnableStatePdu2Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_PDU2_VBAT, this); + lp_var_t outputEnableStateStackVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_STACK_VBAT, this); + lp_var_t outputEnableStateStack3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_STACK_3V3, this); + lp_var_t outputEnableStateStack5V = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_STACK_5V, this); + lp_var_t outputEnableStateGS3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_GS3V3, this); + lp_var_t outputEnableStateGS5V = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_GS5V, this); - /** Output enable states */ - lp_var_t outputEnableStateAcuVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_ACU_VCC, this); - lp_var_t outputEnableStatePdu1Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_PDU1_VCC, this); - lp_var_t outputEnableStateX3IdleVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VCC, this); - lp_var_t outputEnableStatePdu2Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_PDU2_VCC, this); - lp_var_t outputEnableStateAcuVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_ACU_VBAT, this); - lp_var_t outputEnableStatePdu1Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_PDU1_VBAT, this); - lp_var_t outputEnableStateX3IdleVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VBAT, this); - lp_var_t outputEnableStatePdu2Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_PDU2_VBAT, this); - lp_var_t outputEnableStateStackVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_STACK_VBAT, this); - lp_var_t outputEnableStateStack3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_STACK_3V3, this); - lp_var_t outputEnableStateStack5V = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_STACK_5V, this); - lp_var_t outputEnableStateGS3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_GS3V3, this); - lp_var_t outputEnableStateGS5V = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_GS5V, this); + lp_var_t temperature1 = + lp_var_t(sid.objectId, P60System::P60DOCK_TEMPERATURE_1, this); + lp_var_t temperature2 = + lp_var_t(sid.objectId, P60System::P60DOCK_TEMPERATURE_2, this); - lp_var_t temperature1 = lp_var_t(sid.objectId, - P60System::P60DOCK_TEMPERATURE_1, this); - lp_var_t temperature2 = lp_var_t(sid.objectId, - P60System::P60DOCK_TEMPERATURE_2, this); + lp_var_t bootcause = + lp_var_t(sid.objectId, P60System::P60DOCK_BOOT_CAUSE, this); + lp_var_t bootCount = + lp_var_t(sid.objectId, P60System::P60DOCK_BOOT_CNT, this); + lp_var_t uptime = lp_var_t(sid.objectId, P60System::P60DOCK_UPTIME, this); + lp_var_t resetcause = + lp_var_t(sid.objectId, P60System::P60DOCK_RESETCAUSE, this); + lp_var_t battMode = lp_var_t(sid.objectId, P60System::P60DOCK_BATT_MODE, this); + /** Battery heater control only possible on BP4 packs */ + lp_var_t heaterOn = lp_var_t(sid.objectId, P60System::P60DOCK_HEATER_ON, this); + lp_var_t converter5VStatus = + lp_var_t(sid.objectId, P60System::P60DOCK_CONV_5V_ENABLE_STATUS, this); - lp_var_t bootcause = lp_var_t(sid.objectId, - P60System::P60DOCK_BOOT_CAUSE, this); - lp_var_t bootCount = lp_var_t(sid.objectId, - P60System::P60DOCK_BOOT_CNT, this); - lp_var_t uptime = lp_var_t(sid.objectId, - P60System::P60DOCK_UPTIME, this); - lp_var_t resetcause = lp_var_t(sid.objectId, - P60System::P60DOCK_RESETCAUSE, this); - lp_var_t battMode = lp_var_t(sid.objectId, - P60System::P60DOCK_BATT_MODE, this); - /** Battery heater control only possible on BP4 packs */ - lp_var_t heaterOn = lp_var_t(sid.objectId, - P60System::P60DOCK_HEATER_ON, this); - lp_var_t converter5VStatus = lp_var_t(sid.objectId, - P60System::P60DOCK_CONV_5V_ENABLE_STATUS, this); + /** Number of detected latchups on each output channel */ + lp_var_t latchupsAcuVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_ACU_VCC, this); + lp_var_t latchupsPdu1Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_PDU1_VCC, this); + lp_var_t latchupsX3IdleVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_X3_IDLE_VCC, this); + lp_var_t latchupsPdu2Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_PDU2_VCC, this); + lp_var_t latchupsAcuVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_ACU_VBAT, this); + lp_var_t latchupsPdu1Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_PDU1_VBAT, this); + lp_var_t latchupsX3IdleVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_X3_IDLE_VBAT, this); + lp_var_t latchupsPdu2Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_PDU2_VBAT, this); + lp_var_t latchupsStackVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_STACK_VBAT, this); + lp_var_t latchupsStack3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_STACK_3V3, this); + lp_var_t latchupsStack5V = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_STACK_5V, this); + lp_var_t latchupsGS3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_GS3V3, this); + lp_var_t latchupsGS5V = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_GS5V, this); - /** Number of detected latchups on each output channel */ - lp_var_t latchupsAcuVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_ACU_VCC, this); - lp_var_t latchupsPdu1Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_PDU1_VCC, this); - lp_var_t latchupsX3IdleVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_X3_IDLE_VCC, this); - lp_var_t latchupsPdu2Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_PDU2_VCC, this); - lp_var_t latchupsAcuVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_ACU_VBAT, this); - lp_var_t latchupsPdu1Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_PDU1_VBAT, this); - lp_var_t latchupsX3IdleVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_X3_IDLE_VBAT, this); - lp_var_t latchupsPdu2Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_PDU2_VBAT, this); - lp_var_t latchupsStackVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_STACK_VBAT, this); - lp_var_t latchupsStack3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_STACK_3V3, this); - lp_var_t latchupsStack5V = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_STACK_5V, this); - lp_var_t latchupsGS3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_GS3V3, this); - lp_var_t latchupsGS5V = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_GS5V, this); + lp_var_t vbatVoltageValue = + lp_var_t(sid.objectId, P60System::P60DOCK_VBAT_VALUE, this); + lp_var_t vccCurrent = + lp_var_t(sid.objectId, P60System::P60DOCK_VCC_CURRENT_VALUE, this); + lp_var_t batteryCurrent = + lp_var_t(sid.objectId, P60System::P60DOCK_BATTERY_CURRENT, this); + lp_var_t batteryVoltage = + lp_var_t(sid.objectId, P60System::P60DOCK_BATTERY_VOLTAGE, this); - lp_var_t vbatVoltageValue = lp_var_t(sid.objectId, - P60System::P60DOCK_VBAT_VALUE, this); - lp_var_t vccCurrent = lp_var_t(sid.objectId, - P60System::P60DOCK_VCC_CURRENT_VALUE, this); - lp_var_t batteryCurrent = lp_var_t(sid.objectId, - P60System::P60DOCK_BATTERY_CURRENT, this); - lp_var_t batteryVoltage = lp_var_t(sid.objectId, - P60System::P60DOCK_BATTERY_VOLTAGE, this); + lp_var_t batteryTemperature1 = + lp_var_t(sid.objectId, P60System::P60DOCK_BATTERY_TEMPERATURE_1, this); + lp_var_t batteryTemperature2 = + lp_var_t(sid.objectId, P60System::P60DOCK_BATTERY_TEMPERATURE_2, this); - lp_var_t batteryTemperature1 = lp_var_t(sid.objectId, - P60System::P60DOCK_BATTERY_TEMPERATURE_1, this); - lp_var_t batteryTemperature2 = lp_var_t(sid.objectId, - P60System::P60DOCK_BATTERY_TEMPERATURE_2, this); + lp_var_t device0 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_0, this); + lp_var_t device1 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_1, this); + lp_var_t device2 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_2, this); + lp_var_t device3 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_3, this); + lp_var_t device4 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_4, this); + lp_var_t device5 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_5, this); + lp_var_t device6 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_6, this); + lp_var_t device7 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_7, this); - lp_var_t device0 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_0, this); - lp_var_t device1 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_1, this); - lp_var_t device2 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_2, this); - lp_var_t device3 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_3, this); - lp_var_t device4 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_4, this); - lp_var_t device5 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_5, this); - lp_var_t device6 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_6, this); - lp_var_t device7 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_7, this); + lp_var_t device0Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_0_STATUS, this); + lp_var_t device1Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_1_STATUS, this); + lp_var_t device2Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_2_STATUS, this); + lp_var_t device3Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_3_STATUS, this); + lp_var_t device4Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_4_STATUS, this); + lp_var_t device5Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_5_STATUS, this); + lp_var_t device6Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_6_STATUS, this); + lp_var_t device7Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_7_STATUS, this); - lp_var_t device0Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_0_STATUS, this); - lp_var_t device1Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_1_STATUS, this); - lp_var_t device2Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_2_STATUS, this); - lp_var_t device3Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_3_STATUS, this); - lp_var_t device4Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_4_STATUS, this); - lp_var_t device5Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_5_STATUS, this); - lp_var_t device6Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_6_STATUS, this); - lp_var_t device7Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_7_STATUS, this); + lp_var_t dearmStatus = + lp_var_t(sid.objectId, P60System::P60DOCK_DEARM_STATUS, this); - lp_var_t dearmStatus = lp_var_t(sid.objectId, - P60System::P60DOCK_DEARM_STATUS, this); + /** Number of reboots due to gnd, i2c, csp watchdog timeout */ + lp_var_t wdtCntGnd = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CNT_GND, this); + lp_var_t wdtCntI2c = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CNT_I2C, this); + lp_var_t wdtCntCan = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CNT_CAN, this); + lp_var_t wdtCntCsp1 = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CNT_CSP_1, this); + lp_var_t wdtCntCsp2 = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CNT_CSP_2, this); - /** Number of reboots due to gnd, i2c, csp watchdog timeout */ - lp_var_t wdtCntGnd = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CNT_GND, this); - lp_var_t wdtCntI2c = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CNT_I2C, this); - lp_var_t wdtCntCan = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CNT_CAN, this); - lp_var_t wdtCntCsp1 = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CNT_CSP_1, this); - lp_var_t wdtCntCsp2 = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CNT_CSP_2, this); - - lp_var_t wdtGndLeft = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_GND_LEFT, this); - lp_var_t wdtI2cLeft = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_I2C_LEFT, this); - lp_var_t wdtCanLeft = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CAN_LEFT, this); - lp_var_t wdtCspLeft1 = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CSP_LEFT_1, this); - lp_var_t wdtCspLeft2 = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CSP_LEFT_2, this); - lp_var_t batteryChargeCurrent = lp_var_t(sid.objectId, - P60System::P60DOCK_BATT_CHARGE_CURRENT, this); - lp_var_t batteryDischargeCurrent = lp_var_t(sid.objectId, - P60System::P60DOCK_BATT_DISCHARGE_CURRENT, this); - lp_var_t ant6Depl = lp_var_t(sid.objectId, - P60System::P60DOCK_ANT6_DEPL, this); - lp_var_t ar6Depl = lp_var_t(sid.objectId, - P60System::P60DOCK_AR6_DEPL, this); + lp_var_t wdtGndLeft = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_GND_LEFT, this); + lp_var_t wdtI2cLeft = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_I2C_LEFT, this); + lp_var_t wdtCanLeft = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CAN_LEFT, this); + lp_var_t wdtCspLeft1 = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CSP_LEFT_1, this); + lp_var_t wdtCspLeft2 = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CSP_LEFT_2, this); + lp_var_t batteryChargeCurrent = + lp_var_t(sid.objectId, P60System::P60DOCK_BATT_CHARGE_CURRENT, this); + lp_var_t batteryDischargeCurrent = + lp_var_t(sid.objectId, P60System::P60DOCK_BATT_DISCHARGE_CURRENT, this); + lp_var_t ant6Depl = lp_var_t(sid.objectId, P60System::P60DOCK_ANT6_DEPL, this); + lp_var_t ar6Depl = lp_var_t(sid.objectId, P60System::P60DOCK_AR6_DEPL, this); }; -} - +} // namespace P60Dock /** * @brief Constants common for both PDU1 and PDU2. */ -namespace PDU{ +namespace PDU { /** When retrieving full configuration parameter table */ static const uint16_t MAX_REPLY_LENGTH = 318; static const uint16_t MAX_CONFIGTABLE_ADDRESS = 316; @@ -627,11 +607,10 @@ static const uint16_t MAX_HKTABLE_ADDRESS = 141; /** The size of the csp reply containing the housekeeping table data */ static const uint16_t HK_TABLE_REPLY_SIZE = 303; static const uint8_t HK_TABLE_ENTRIES = 73; -} - +} // namespace PDU namespace PDU1 { -static const uint32_t HK_TABLE_DATA_SET_ID = 0x1; // hk table has table id 4 +static const uint32_t HK_TABLE_DATA_SET_ID = 0x1; // hk table has table id 4 /** * Addresses within configuration table to enable or disable output channels. Refer also to * gs-man-nanopower-p60-pdu-200.pdf on page 16. @@ -649,194 +628,174 @@ static const uint16_t CONFIG_ADDRESS_OUT_EN_CHANNEL8 = 0x56; /** * @brief This class defines a dataset for the hk table of the PDU1. */ -class PDU1HkTableDataset : - public StaticLocalDataSet { - public: +class PDU1HkTableDataset : public StaticLocalDataSet { + public: + PDU1HkTableDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) {} - PDU1HkTableDataset(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) { - } + PDU1HkTableDataset(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) {} - PDU1HkTableDataset(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) { - } + /** Measured output currents */ + lp_var_t currentOutTCSBoard3V3 = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_TCS_BOARD_3V3, this); + lp_var_t currentOutSyrlinks = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_SYRLINKS, this); + lp_var_t currentOutStarTracker = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_STAR_TRACKER, this); + lp_var_t currentOutMGT = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_MGT, this); + lp_var_t currentOutSUSNominal = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_SUS_NOMINAL, this); + lp_var_t currentOutSolarCellExp = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, this); + lp_var_t currentOutPLOC = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_PLOC, this); + lp_var_t currentOutACSBoardSideA = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, this); + lp_var_t currentOutChannel8 = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_CHANNEL8, this); + /** Measured voltage of output channels */ + lp_var_t voltageOutTCSBoard3V3 = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, this); + lp_var_t voltageOutSyrlinks = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_SYRLINKS, this); + lp_var_t voltageOutStarTracker = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_STAR_TRACKER, this); + lp_var_t voltageOutMGT = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_MGT, this); + lp_var_t voltageOutSUSNominal = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_SUS_NOMINAL, this); + lp_var_t voltageOutSolarCellExp = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, this); + lp_var_t voltageOutPLOC = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_PLOC, this); + lp_var_t voltageOutACSBoardSideA = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, this); + lp_var_t voltageOutChannel8 = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_CHANNEL8, this); + /** Measured VCC */ + lp_var_t vcc = lp_var_t(sid.objectId, P60System::PDU1_VCC, this); + /** Measured VBAT */ + lp_var_t vbat = lp_var_t(sid.objectId, P60System::PDU1_VBAT, this); + lp_var_t temperature = + lp_var_t(sid.objectId, P60System::PDU1_TEMPERATURE, this); + /** Output converter enable status */ + lp_var_t converterEnable1 = + lp_var_t(sid.objectId, P60System::PDU1_CONV_EN_1, this); + lp_var_t converterEnable2 = + lp_var_t(sid.objectId, P60System::PDU1_CONV_EN_2, this); + lp_var_t converterEnable3 = + lp_var_t(sid.objectId, P60System::PDU1_CONV_EN_3, this); - /** Measured output currents */ - lp_var_t currentOutTCSBoard3V3 = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_TCS_BOARD_3V3, this); - lp_var_t currentOutSyrlinks = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_SYRLINKS, this); - lp_var_t currentOutStarTracker = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_STAR_TRACKER, this); - lp_var_t currentOutMGT = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_MGT, this); - lp_var_t currentOutSUSNominal = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_SUS_NOMINAL, this); - lp_var_t currentOutSolarCellExp = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, this); - lp_var_t currentOutPLOC = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_PLOC, this); - lp_var_t currentOutACSBoardSideA = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, this); - lp_var_t currentOutChannel8 = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_CHANNEL8, this); - /** Measured voltage of output channels */ - lp_var_t voltageOutTCSBoard3V3 = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, this); - lp_var_t voltageOutSyrlinks = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_SYRLINKS, this); - lp_var_t voltageOutStarTracker = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_STAR_TRACKER, this); - lp_var_t voltageOutMGT = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_MGT, this); - lp_var_t voltageOutSUSNominal = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_SUS_NOMINAL, this); - lp_var_t voltageOutSolarCellExp = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, this); - lp_var_t voltageOutPLOC = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_PLOC, this); - lp_var_t voltageOutACSBoardSideA = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, this); - lp_var_t voltageOutChannel8 = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_CHANNEL8, this); - /** Measured VCC */ - lp_var_t vcc = lp_var_t(sid.objectId, - P60System::PDU1_VCC, this); - /** Measured VBAT */ - lp_var_t vbat = lp_var_t(sid.objectId, - P60System::PDU1_VBAT, this); - lp_var_t temperature = lp_var_t(sid.objectId, - P60System::PDU1_TEMPERATURE, this); - /** Output converter enable status */ - lp_var_t converterEnable1 = lp_var_t(sid.objectId, - P60System::PDU1_CONV_EN_1, this); - lp_var_t converterEnable2 = lp_var_t(sid.objectId, - P60System::PDU1_CONV_EN_2, this); - lp_var_t converterEnable3 = lp_var_t(sid.objectId, - P60System::PDU1_CONV_EN_3, this); + /** Output channels enable status */ + lp_var_t outEnabledTCSBoard3V3 = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_TCS_BOARD_3V3, this); + lp_var_t outEnabledSyrlinks = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_SYRLINKS, this); + lp_var_t outEnabledStarTracker = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_STAR_TRACKER, this); + lp_var_t outEnabledMGT = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_MGT, this); + lp_var_t outEnabledSUSNominal = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_SUS_NOMINAL, this); + lp_var_t outEnabledSolarCellExp = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_SOLAR_CELL_EXP, this); + lp_var_t outEnabledPLOC = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_PLOC, this); + lp_var_t outEnabledAcsBoardSideA = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_ACS_BOARD_SIDE_A, this); + lp_var_t outEnabledChannel8 = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_CHANNEL8, this); + lp_var_t bootcause = lp_var_t(sid.objectId, P60System::PDU1_BOOTCAUSE, this); + /** Number of reboots */ + lp_var_t bootcount = lp_var_t(sid.objectId, P60System::PDU1_BOOTCNT, this); + /** Uptime in seconds */ + lp_var_t uptime = lp_var_t(sid.objectId, P60System::PDU1_UPTIME, this); + lp_var_t resetcause = + lp_var_t(sid.objectId, P60System::PDU1_RESETCAUSE, this); + /** Battery mode: 1 = Critical, 2 = Safe, 3 = Normal, 4 = Full */ + lp_var_t battMode = lp_var_t(sid.objectId, P60System::PDU1_BATT_MODE, this); - /** Output channels enable status */ - lp_var_t outEnabledTCSBoard3V3 = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_TCS_BOARD_3V3, this); - lp_var_t outEnabledSyrlinks = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_SYRLINKS, this); - lp_var_t outEnabledStarTracker = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_STAR_TRACKER, this); - lp_var_t outEnabledMGT = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_MGT, this); - lp_var_t outEnabledSUSNominal = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_SUS_NOMINAL, this); - lp_var_t outEnabledSolarCellExp = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_SOLAR_CELL_EXP, this); - lp_var_t outEnabledPLOC = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_PLOC, this); - lp_var_t outEnabledAcsBoardSideA = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_ACS_BOARD_SIDE_A, this); - lp_var_t outEnabledChannel8 = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_CHANNEL8, this); - lp_var_t bootcause = lp_var_t(sid.objectId, - P60System::PDU1_BOOTCAUSE, this); - /** Number of reboots */ - lp_var_t bootcount = lp_var_t(sid.objectId, - P60System::PDU1_BOOTCNT, this); - /** Uptime in seconds */ - lp_var_t uptime = lp_var_t(sid.objectId, - P60System::PDU1_UPTIME, this); - lp_var_t resetcause = lp_var_t(sid.objectId, - P60System::PDU1_RESETCAUSE, this); - /** Battery mode: 1 = Critical, 2 = Safe, 3 = Normal, 4 = Full */ - lp_var_t battMode = lp_var_t(sid.objectId, - P60System::PDU1_BATT_MODE, this); + /** Number of detected latchups on each output channel */ + lp_var_t latchupsTcsBoard3V3 = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_TCS_BOARD_3V3, this); + lp_var_t latchupsSyrlinks = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_SYRLINKS, this); + lp_var_t latchupsStarTracker = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_STAR_TRACKER, this); + lp_var_t latchupsMgt = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_MGT, this); + lp_var_t latchupsSusNominal = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_SUS_NOMINAL, this); + lp_var_t latchupsSolarCellExp = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_SOLAR_CELL_EXP, this); + lp_var_t latchupsPloc = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_PLOC, this); + lp_var_t latchupsAcsBoardSideA = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_ACS_BOARD_SIDE_A, this); + lp_var_t latchupsChannel8 = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_CHANNEL8, this); - /** Number of detected latchups on each output channel */ - lp_var_t latchupsTcsBoard3V3 = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_TCS_BOARD_3V3, this); - lp_var_t latchupsSyrlinks = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_SYRLINKS, this); - lp_var_t latchupsStarTracker = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_STAR_TRACKER, this); - lp_var_t latchupsMgt = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_MGT, this); - lp_var_t latchupsSusNominal = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_SUS_NOMINAL, this); - lp_var_t latchupsSolarCellExp = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_SOLAR_CELL_EXP, this); - lp_var_t latchupsPloc = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_PLOC, this); - lp_var_t latchupsAcsBoardSideA = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_ACS_BOARD_SIDE_A, this); - lp_var_t latchupsChannel8 = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_CHANNEL8, this); + /** + * There are 8 devices on the PDU. FRAM, ADCs, temperature sensor etc. Each device is + * identified by an ID. Refer also to gs-man-nanopower-p60-pdu-200-1.pdf on pages 17 and 18. + */ + lp_var_t device0 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_0, this); + lp_var_t device1 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_1, this); + lp_var_t device2 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_2, this); + lp_var_t device3 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_3, this); + lp_var_t device4 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_4, this); + lp_var_t device5 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_5, this); + lp_var_t device6 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_6, this); + lp_var_t device7 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_7, this); + /** The status of each device. 0 = None, 1 = Ok, 2 = Error, 3 = Not found */ + lp_var_t device0Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_0_STATUS, this); + lp_var_t device1Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_1_STATUS, this); + lp_var_t device2Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_2_STATUS, this); + lp_var_t device3Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_3_STATUS, this); + lp_var_t device4Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_4_STATUS, this); + lp_var_t device5Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_5_STATUS, this); + lp_var_t device6Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_6_STATUS, this); + lp_var_t device7Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_7_STATUS, this); - /** - * There are 8 devices on the PDU. FRAM, ADCs, temperature sensor etc. Each device is - * identified by an ID. Refer also to gs-man-nanopower-p60-pdu-200-1.pdf on pages 17 and 18. - */ - lp_var_t device0 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_0, this); - lp_var_t device1 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_1, this); - lp_var_t device2 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_2, this); - lp_var_t device3 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_3, this); - lp_var_t device4 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_4, this); - lp_var_t device5 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_5, this); - lp_var_t device6 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_6, this); - lp_var_t device7 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_7, this); - /** The status of each device. 0 = None, 1 = Ok, 2 = Error, 3 = Not found */ - lp_var_t device0Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_0_STATUS, this); - lp_var_t device1Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_1_STATUS, this); - lp_var_t device2Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_2_STATUS, this); - lp_var_t device3Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_3_STATUS, this); - lp_var_t device4Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_4_STATUS, this); - lp_var_t device5Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_5_STATUS, this); - lp_var_t device6Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_6_STATUS, this); - lp_var_t device7Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_7_STATUS, this); - - /** Number of reboots triggered by the ground watchdog */ - lp_var_t gndWdtReboots = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CNT_GND, this); - /** Number of reboots triggered through the I2C watchdog. Not relevant for EIVE. */ - lp_var_t i2cWdtReboots = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CNT_I2C, this); - /** Number of reboots triggered through the CAN watchdog */ - lp_var_t canWdtReboots = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CNT_CAN, this); - /** Number of reboots triggered through the CSP watchdog */ - lp_var_t csp1WdtReboots = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CNT_CSP1, this); - lp_var_t csp2WdtReboots = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CNT_CSP2, this); - /** Ground watchdog remaining seconds before rebooting */ - lp_var_t groundWatchdogSecondsLeft = lp_var_t(sid.objectId, - P60System::PDU1_WDT_GND_LEFT, this); - /** I2C watchdog remaining seconds before rebooting. Not relevant for EIVE. */ - lp_var_t i2cWatchdogSecondsLeft = lp_var_t(sid.objectId, - P60System::PDU1_WDT_I2C_LEFT, this); - /** CAN watchdog remaining seconds before rebooting. */ - lp_var_t canWatchdogSecondsLeft = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CAN_LEFT, this); - /** CSP watchdogs remaining pings before rebooting. */ - lp_var_t csp2WatchdogPingsLeft = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CSP_LEFT1, this); - lp_var_t csp1WatchdogPingsLeft = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CSP_LEFT2, this); + /** Number of reboots triggered by the ground watchdog */ + lp_var_t gndWdtReboots = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CNT_GND, this); + /** Number of reboots triggered through the I2C watchdog. Not relevant for EIVE. */ + lp_var_t i2cWdtReboots = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CNT_I2C, this); + /** Number of reboots triggered through the CAN watchdog */ + lp_var_t canWdtReboots = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CNT_CAN, this); + /** Number of reboots triggered through the CSP watchdog */ + lp_var_t csp1WdtReboots = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CNT_CSP1, this); + lp_var_t csp2WdtReboots = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CNT_CSP2, this); + /** Ground watchdog remaining seconds before rebooting */ + lp_var_t groundWatchdogSecondsLeft = + lp_var_t(sid.objectId, P60System::PDU1_WDT_GND_LEFT, this); + /** I2C watchdog remaining seconds before rebooting. Not relevant for EIVE. */ + lp_var_t i2cWatchdogSecondsLeft = + lp_var_t(sid.objectId, P60System::PDU1_WDT_I2C_LEFT, this); + /** CAN watchdog remaining seconds before rebooting. */ + lp_var_t canWatchdogSecondsLeft = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CAN_LEFT, this); + /** CSP watchdogs remaining pings before rebooting. */ + lp_var_t csp2WatchdogPingsLeft = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CSP_LEFT1, this); + lp_var_t csp1WatchdogPingsLeft = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CSP_LEFT2, this); }; -} - +} // namespace PDU1 namespace PDU2 { static const uint32_t HK_TABLE_DATA_SET_ID = 0x2; @@ -857,194 +816,174 @@ static const uint16_t CONFIG_ADDRESS_OUT_EN_PAYLOAD_CAMERA = 0x50; /** * @brief This class defines a dataset for the hk table of the PDU2. */ -class PDU2HkTableDataset: - public StaticLocalDataSet { - public: +class PDU2HkTableDataset : public StaticLocalDataSet { + public: + PDU2HkTableDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) {} - PDU2HkTableDataset(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) { - } + PDU2HkTableDataset(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) {} - PDU2HkTableDataset(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) { - } + /** Measured output currents */ + lp_var_t currentOutQ7S = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_Q7S, this); + lp_var_t currentOutPayloadPCDUCh1 = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, this); + lp_var_t currentOutReactionWheels = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_RW, this); + lp_var_t currentOutTCSBoardHeaterIn = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, this); + lp_var_t currentOutSUSRedundant = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_SUS_REDUNDANT, this); + lp_var_t currentOutDeplMechanism = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, this); + lp_var_t currentOutPayloadPCDUCh6 = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, this); + lp_var_t currentOutACSBoardSideB = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, this); + lp_var_t currentOutPayloadCamera = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, this); + /** Measured voltage of output channels */ + lp_var_t voltageOutQ7S = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_Q7S, this); + lp_var_t voltageOutPayloadPCDUCh1 = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, this); + lp_var_t voltageOutReactionWheels = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_RW, this); + lp_var_t voltageOutTCSBoardHeaterIn = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, this); + lp_var_t voltageOutSUSRedundant = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, this); + lp_var_t voltageOutDeplMechanism = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, this); + lp_var_t voltageOutPayloadPCDUCh6 = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, this); + lp_var_t voltageOutACSBoardSideB = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, this); + lp_var_t voltageOutPayloadCamera = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, this); + /** Measured VCC */ + lp_var_t vcc = lp_var_t(sid.objectId, P60System::PDU2_VCC, this); + /** Measured VBAT */ + lp_var_t vbat = lp_var_t(sid.objectId, P60System::PDU2_VBAT, this); + lp_var_t temperature = + lp_var_t(sid.objectId, P60System::PDU2_TEMPERATURE, this); + /** Output converter enable status */ + lp_var_t converterEnable1 = + lp_var_t(sid.objectId, P60System::PDU2_CONV_EN_1, this); + lp_var_t converterEnable2 = + lp_var_t(sid.objectId, P60System::PDU2_CONV_EN_2, this); + lp_var_t converterEnable3 = + lp_var_t(sid.objectId, P60System::PDU2_CONV_EN_3, this); + /** Output channels enable status */ + lp_var_t outEnabledQ7S = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_Q7S, this); + lp_var_t outEnabledPlPCDUCh1 = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, this); + lp_var_t outEnabledReactionWheels = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_RW, this); + lp_var_t outEnabledTCSBoardHeaterIn = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, this); + lp_var_t outEnabledSUSRedundant = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_SUS_REDUNDANT, this); + lp_var_t outEnabledDeplMechanism = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_DEPLOYMENT_MECHANISM, this); + lp_var_t outEnabledPlPCDUCh6 = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH6, this); + lp_var_t outEnabledAcsBoardSideB = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_ACS_BOARD_SIDE_B, this); + lp_var_t outEnabledPayloadCamera = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_PAYLOAD_CAMERA, this); - /** Measured output currents */ - lp_var_t currentOutQ7S = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_Q7S, this); - lp_var_t currentOutPayloadPCDUCh1 = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, this); - lp_var_t currentOutReactionWheels = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_RW, this); - lp_var_t currentOutTCSBoardHeaterIn = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, this); - lp_var_t currentOutSUSRedundant = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_SUS_REDUNDANT, this); - lp_var_t currentOutDeplMechanism = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, this); - lp_var_t currentOutPayloadPCDUCh6 = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, this); - lp_var_t currentOutACSBoardSideB = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, this); - lp_var_t currentOutPayloadCamera = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, this); - /** Measured voltage of output channels */ - lp_var_t voltageOutQ7S = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_Q7S, this); - lp_var_t voltageOutPayloadPCDUCh1 = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, this); - lp_var_t voltageOutReactionWheels = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_RW, this); - lp_var_t voltageOutTCSBoardHeaterIn = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, this); - lp_var_t voltageOutSUSRedundant = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, this); - lp_var_t voltageOutDeplMechanism = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, this); - lp_var_t voltageOutPayloadPCDUCh6 = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, this); - lp_var_t voltageOutACSBoardSideB = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, this); - lp_var_t voltageOutPayloadCamera = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, this); - /** Measured VCC */ - lp_var_t vcc = lp_var_t(sid.objectId, - P60System::PDU2_VCC, this); - /** Measured VBAT */ - lp_var_t vbat = lp_var_t(sid.objectId, - P60System::PDU2_VBAT, this); - lp_var_t temperature = lp_var_t(sid.objectId, - P60System::PDU2_TEMPERATURE, this); - /** Output converter enable status */ - lp_var_t converterEnable1 = lp_var_t(sid.objectId, - P60System::PDU2_CONV_EN_1, this); - lp_var_t converterEnable2 = lp_var_t(sid.objectId, - P60System::PDU2_CONV_EN_2, this); - lp_var_t converterEnable3 = lp_var_t(sid.objectId, - P60System::PDU2_CONV_EN_3, this); - /** Output channels enable status */ - lp_var_t outEnabledQ7S = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_Q7S, this); - lp_var_t outEnabledPlPCDUCh1 = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, this); - lp_var_t outEnabledReactionWheels = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_RW, this); - lp_var_t outEnabledTCSBoardHeaterIn = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, this); - lp_var_t outEnabledSUSRedundant = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_SUS_REDUNDANT, this); - lp_var_t outEnabledDeplMechanism = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_DEPLOYMENT_MECHANISM, this); - lp_var_t outEnabledPlPCDUCh6 = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH6, this); - lp_var_t outEnabledAcsBoardSideB = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_ACS_BOARD_SIDE_B, this); - lp_var_t outEnabledPayloadCamera = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_PAYLOAD_CAMERA, this); + lp_var_t bootcause = lp_var_t(sid.objectId, P60System::PDU2_BOOTCAUSE, this); + /** Number of reboots */ + lp_var_t bootcount = lp_var_t(sid.objectId, P60System::PDU2_BOOTCNT, this); + /** Uptime in seconds */ + lp_var_t uptime = lp_var_t(sid.objectId, P60System::PDU2_UPTIME, this); + lp_var_t resetcause = + lp_var_t(sid.objectId, P60System::PDU2_RESETCAUSE, this); + /** Battery mode: 1 = Critical, 2 = Safe, 3 = Normal, 4 = Full */ + lp_var_t battMode = lp_var_t(sid.objectId, P60System::PDU2_BATT_MODE, this); - lp_var_t bootcause = lp_var_t(sid.objectId, - P60System::PDU2_BOOTCAUSE, this); - /** Number of reboots */ - lp_var_t bootcount = lp_var_t(sid.objectId, - P60System::PDU2_BOOTCNT, this); - /** Uptime in seconds */ - lp_var_t uptime = lp_var_t(sid.objectId, - P60System::PDU2_UPTIME, this); - lp_var_t resetcause = lp_var_t(sid.objectId, - P60System::PDU2_RESETCAUSE, this); - /** Battery mode: 1 = Critical, 2 = Safe, 3 = Normal, 4 = Full */ - lp_var_t battMode = lp_var_t(sid.objectId, - P60System::PDU2_BATT_MODE, this); + /** Number of detected latchups on each output channel */ + lp_var_t latchupsQ7S = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_Q7S, this); + lp_var_t latchupsPayloadPcduCh1 = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, this); + lp_var_t latchupsRw = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_RW, this); + lp_var_t latchupsTcsBoardHeaterIn = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, this); + lp_var_t latchupsSusRedundant = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_SUS_REDUNDANT, this); + lp_var_t latchupsDeplMenchanism = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_DEPLOYMENT_MECHANISM, this); + lp_var_t latchupsPayloadPcduCh6 = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, this); + lp_var_t latchupsAcsBoardSideB = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_ACS_BOARD_SIDE_B, this); + lp_var_t latchupsPayloadCamera = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_PAYLOAD_CAMERA, this); - /** Number of detected latchups on each output channel */ - lp_var_t latchupsQ7S = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_Q7S, this); - lp_var_t latchupsPayloadPcduCh1 = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, this); - lp_var_t latchupsRw = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_RW, this); - lp_var_t latchupsTcsBoardHeaterIn = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, this); - lp_var_t latchupsSusRedundant = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_SUS_REDUNDANT, this); - lp_var_t latchupsDeplMenchanism = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_DEPLOYMENT_MECHANISM, this); - lp_var_t latchupsPayloadPcduCh6 = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, this); - lp_var_t latchupsAcsBoardSideB = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_ACS_BOARD_SIDE_B, this); - lp_var_t latchupsPayloadCamera = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_PAYLOAD_CAMERA, this); + /** + * There are 8 devices on the PDU. FRAM, ADCs, temperature sensor etc. Each device is + * identified by an ID. Refer also to gs-man-nanopower-p60-pdu-200-1.pdf on pages 17 and 18. + */ + lp_var_t device0 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_0, this); + lp_var_t device1 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_1, this); + lp_var_t device2 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_2, this); + lp_var_t device3 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_3, this); + lp_var_t device4 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_4, this); + lp_var_t device5 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_5, this); + lp_var_t device6 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_6, this); + lp_var_t device7 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_7, this); + /** The status of each device. 0 = None, 1 = Ok, 2 = Error, 3 = Not found */ + lp_var_t device0Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_0_STATUS, this); + lp_var_t device1Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_1_STATUS, this); + lp_var_t device2Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_2_STATUS, this); + lp_var_t device3Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_3_STATUS, this); + lp_var_t device4Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_4_STATUS, this); + lp_var_t device5Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_5_STATUS, this); + lp_var_t device6Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_6_STATUS, this); + lp_var_t device7Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_7_STATUS, this); - /** - * There are 8 devices on the PDU. FRAM, ADCs, temperature sensor etc. Each device is - * identified by an ID. Refer also to gs-man-nanopower-p60-pdu-200-1.pdf on pages 17 and 18. - */ - lp_var_t device0 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_0, this); - lp_var_t device1 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_1, this); - lp_var_t device2 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_2, this); - lp_var_t device3 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_3, this); - lp_var_t device4 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_4, this); - lp_var_t device5 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_5, this); - lp_var_t device6 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_6, this); - lp_var_t device7 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_7, this); - /** The status of each device. 0 = None, 1 = Ok, 2 = Error, 3 = Not found */ - lp_var_t device0Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_0_STATUS, this); - lp_var_t device1Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_1_STATUS, this); - lp_var_t device2Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_2_STATUS, this); - lp_var_t device3Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_3_STATUS, this); - lp_var_t device4Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_4_STATUS, this); - lp_var_t device5Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_5_STATUS, this); - lp_var_t device6Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_6_STATUS, this); - lp_var_t device7Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_7_STATUS, this); - - /** Number of reboots triggered by the ground watchdog */ - lp_var_t gndWdtReboots = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CNT_GND, this); - /** Number of reboots triggered through the I2C watchdog. Not relevant for EIVE. */ - lp_var_t i2cWdtReboots = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CNT_I2C, this); - /** Number of reboots triggered through the CAN watchdog */ - lp_var_t canWdtReboots = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CNT_CAN, this); - /** Number of reboots triggered through the CSP watchdog */ - lp_var_t csp1WdtReboots = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CNT_CSP1, this); - lp_var_t csp2WdtReboots = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CNT_CSP2, this); - /** Ground watchdog remaining seconds before rebooting */ - lp_var_t groundWatchdogSecondsLeft = lp_var_t(sid.objectId, - P60System::PDU2_WDT_GND_LEFT, this); - /** I2C watchdog remaining seconds before rebooting. Not relevant for EIVE. */ - lp_var_t i2cWatchdogSecondsLeft = lp_var_t(sid.objectId, - P60System::PDU2_WDT_I2C_LEFT, this); - /** CAN watchdog remaining seconds before rebooting. */ - lp_var_t canWatchdogSecondsLeft = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CAN_LEFT, this); - /** CSP watchdog remaining pings before rebooting. */ - lp_var_t csp1WatchdogPingsLeft = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CSP_LEFT1, this); - lp_var_t csp2WatchdogPingsLeft = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CSP_LEFT2, this); + /** Number of reboots triggered by the ground watchdog */ + lp_var_t gndWdtReboots = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CNT_GND, this); + /** Number of reboots triggered through the I2C watchdog. Not relevant for EIVE. */ + lp_var_t i2cWdtReboots = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CNT_I2C, this); + /** Number of reboots triggered through the CAN watchdog */ + lp_var_t canWdtReboots = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CNT_CAN, this); + /** Number of reboots triggered through the CSP watchdog */ + lp_var_t csp1WdtReboots = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CNT_CSP1, this); + lp_var_t csp2WdtReboots = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CNT_CSP2, this); + /** Ground watchdog remaining seconds before rebooting */ + lp_var_t groundWatchdogSecondsLeft = + lp_var_t(sid.objectId, P60System::PDU2_WDT_GND_LEFT, this); + /** I2C watchdog remaining seconds before rebooting. Not relevant for EIVE. */ + lp_var_t i2cWatchdogSecondsLeft = + lp_var_t(sid.objectId, P60System::PDU2_WDT_I2C_LEFT, this); + /** CAN watchdog remaining seconds before rebooting. */ + lp_var_t canWatchdogSecondsLeft = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CAN_LEFT, this); + /** CSP watchdog remaining pings before rebooting. */ + lp_var_t csp1WatchdogPingsLeft = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CSP_LEFT1, this); + lp_var_t csp2WatchdogPingsLeft = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CSP_LEFT2, this); }; -} - +} // namespace PDU2 namespace ACU { @@ -1060,157 +999,133 @@ static const uint16_t HK_TABLE_REPLY_SIZE = 262; /** * @brief This class defines a dataset for the hk table of the ACU. */ -class HkTableDataset: - public StaticLocalDataSet { - public: +class HkTableDataset : public StaticLocalDataSet { + public: + HkTableDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) {} - HkTableDataset(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) { - } + HkTableDataset(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) {} - HkTableDataset(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) { - } + lp_var_t currentInChannel0 = + lp_var_t(sid.objectId, P60System::ACU_CURRENT_IN_CHANNEL0, this); + lp_var_t currentInChannel1 = + lp_var_t(sid.objectId, P60System::ACU_CURRENT_IN_CHANNEL1, this); + lp_var_t currentInChannel2 = + lp_var_t(sid.objectId, P60System::ACU_CURRENT_IN_CHANNEL2, this); + lp_var_t currentInChannel3 = + lp_var_t(sid.objectId, P60System::ACU_CURRENT_IN_CHANNEL3, this); + lp_var_t currentInChannel4 = + lp_var_t(sid.objectId, P60System::ACU_CURRENT_IN_CHANNEL4, this); + lp_var_t currentInChannel5 = + lp_var_t(sid.objectId, P60System::ACU_CURRENT_IN_CHANNEL5, this); - lp_var_t currentInChannel0 = lp_var_t(sid.objectId, - P60System::ACU_CURRENT_IN_CHANNEL0, this); - lp_var_t currentInChannel1 = lp_var_t(sid.objectId, - P60System::ACU_CURRENT_IN_CHANNEL1, this); - lp_var_t currentInChannel2 = lp_var_t(sid.objectId, - P60System::ACU_CURRENT_IN_CHANNEL2, this); - lp_var_t currentInChannel3 = lp_var_t(sid.objectId, - P60System::ACU_CURRENT_IN_CHANNEL3, this); - lp_var_t currentInChannel4 = lp_var_t(sid.objectId, - P60System::ACU_CURRENT_IN_CHANNEL4, this); - lp_var_t currentInChannel5 = lp_var_t(sid.objectId, - P60System::ACU_CURRENT_IN_CHANNEL5, this); + lp_var_t voltageInChannel0 = + lp_var_t(sid.objectId, P60System::ACU_VOLTAGE_IN_CHANNEL0, this); + lp_var_t voltageInChannel1 = + lp_var_t(sid.objectId, P60System::ACU_VOLTAGE_IN_CHANNEL1, this); + lp_var_t voltageInChannel2 = + lp_var_t(sid.objectId, P60System::ACU_VOLTAGE_IN_CHANNEL2, this); + lp_var_t voltageInChannel3 = + lp_var_t(sid.objectId, P60System::ACU_VOLTAGE_IN_CHANNEL3, this); + lp_var_t voltageInChannel4 = + lp_var_t(sid.objectId, P60System::ACU_VOLTAGE_IN_CHANNEL4, this); + lp_var_t voltageInChannel5 = + lp_var_t(sid.objectId, P60System::ACU_VOLTAGE_IN_CHANNEL5, this); - lp_var_t voltageInChannel0 = lp_var_t(sid.objectId, - P60System::ACU_VOLTAGE_IN_CHANNEL0, this); - lp_var_t voltageInChannel1 = lp_var_t(sid.objectId, - P60System::ACU_VOLTAGE_IN_CHANNEL1, this); - lp_var_t voltageInChannel2 = lp_var_t(sid.objectId, - P60System::ACU_VOLTAGE_IN_CHANNEL2, this); - lp_var_t voltageInChannel3 = lp_var_t(sid.objectId, - P60System::ACU_VOLTAGE_IN_CHANNEL3, this); - lp_var_t voltageInChannel4 = lp_var_t(sid.objectId, - P60System::ACU_VOLTAGE_IN_CHANNEL4, this); - lp_var_t voltageInChannel5 = lp_var_t(sid.objectId, - P60System::ACU_VOLTAGE_IN_CHANNEL5, this); + lp_var_t vcc = lp_var_t(sid.objectId, P60System::ACU_VCC, this); + lp_var_t vbat = lp_var_t(sid.objectId, P60System::ACU_VBAT, this); - lp_var_t vcc = lp_var_t(sid.objectId, - P60System::ACU_VCC, this); - lp_var_t vbat = lp_var_t(sid.objectId, - P60System::ACU_VBAT, this); + lp_var_t temperature1 = + lp_var_t(sid.objectId, P60System::ACU_TEMPERATURE_1, this); + lp_var_t temperature2 = + lp_var_t(sid.objectId, P60System::ACU_TEMPERATURE_2, this); + lp_var_t temperature3 = + lp_var_t(sid.objectId, P60System::ACU_TEMPERATURE_3, this); - lp_var_t temperature1 = lp_var_t(sid.objectId, - P60System::ACU_TEMPERATURE_1, this); - lp_var_t temperature2 = lp_var_t(sid.objectId, - P60System::ACU_TEMPERATURE_2, this); - lp_var_t temperature3 = lp_var_t(sid.objectId, - P60System::ACU_TEMPERATURE_3, this); + lp_var_t mpptMode = lp_var_t(sid.objectId, P60System::ACU_MPPT_MODE, this); - lp_var_t mpptMode = lp_var_t(sid.objectId, - P60System::ACU_MPPT_MODE, this); + lp_var_t vboostInChannel0 = + lp_var_t(sid.objectId, P60System::ACU_VBOOST_CHANNEL0, this); + lp_var_t vboostInChannel1 = + lp_var_t(sid.objectId, P60System::ACU_VBOOST_CHANNEL1, this); + lp_var_t vboostInChannel2 = + lp_var_t(sid.objectId, P60System::ACU_VBOOST_CHANNEL2, this); + lp_var_t vboostInChannel3 = + lp_var_t(sid.objectId, P60System::ACU_VBOOST_CHANNEL3, this); + lp_var_t vboostInChannel4 = + lp_var_t(sid.objectId, P60System::ACU_VBOOST_CHANNEL4, this); + lp_var_t vboostInChannel5 = + lp_var_t(sid.objectId, P60System::ACU_VBOOST_CHANNEL5, this); - lp_var_t vboostInChannel0 = lp_var_t(sid.objectId, - P60System::ACU_VBOOST_CHANNEL0, this); - lp_var_t vboostInChannel1 = lp_var_t(sid.objectId, - P60System::ACU_VBOOST_CHANNEL1, this); - lp_var_t vboostInChannel2 = lp_var_t(sid.objectId, - P60System::ACU_VBOOST_CHANNEL2, this); - lp_var_t vboostInChannel3 = lp_var_t(sid.objectId, - P60System::ACU_VBOOST_CHANNEL3, this); - lp_var_t vboostInChannel4 = lp_var_t(sid.objectId, - P60System::ACU_VBOOST_CHANNEL4, this); - lp_var_t vboostInChannel5 = lp_var_t(sid.objectId, - P60System::ACU_VBOOST_CHANNEL5, this); + lp_var_t powerInChannel0 = + lp_var_t(sid.objectId, P60System::ACU_POWER_CHANNEL0, this); + lp_var_t powerInChannel1 = + lp_var_t(sid.objectId, P60System::ACU_POWER_CHANNEL1, this); + lp_var_t powerInChannel2 = + lp_var_t(sid.objectId, P60System::ACU_POWER_CHANNEL2, this); + lp_var_t powerInChannel3 = + lp_var_t(sid.objectId, P60System::ACU_POWER_CHANNEL3, this); + lp_var_t powerInChannel4 = + lp_var_t(sid.objectId, P60System::ACU_POWER_CHANNEL4, this); + lp_var_t powerInChannel5 = + lp_var_t(sid.objectId, P60System::ACU_POWER_CHANNEL5, this); - lp_var_t powerInChannel0 = lp_var_t(sid.objectId, - P60System::ACU_POWER_CHANNEL0, this); - lp_var_t powerInChannel1 = lp_var_t(sid.objectId, - P60System::ACU_POWER_CHANNEL1, this); - lp_var_t powerInChannel2 = lp_var_t(sid.objectId, - P60System::ACU_POWER_CHANNEL2, this); - lp_var_t powerInChannel3 = lp_var_t(sid.objectId, - P60System::ACU_POWER_CHANNEL3, this); - lp_var_t powerInChannel4 = lp_var_t(sid.objectId, - P60System::ACU_POWER_CHANNEL4, this); - lp_var_t powerInChannel5 = lp_var_t(sid.objectId, - P60System::ACU_POWER_CHANNEL5, this); + lp_var_t dac0Enable = lp_var_t(sid.objectId, P60System::ACU_DAC_EN_0, this); + lp_var_t dac1Enable = lp_var_t(sid.objectId, P60System::ACU_DAC_EN_1, this); + lp_var_t dac2Enable = lp_var_t(sid.objectId, P60System::ACU_DAC_EN_2, this); - lp_var_t dac0Enable = lp_var_t(sid.objectId, - P60System::ACU_DAC_EN_0, this); - lp_var_t dac1Enable = lp_var_t(sid.objectId, - P60System::ACU_DAC_EN_1, this); - lp_var_t dac2Enable = lp_var_t(sid.objectId, - P60System::ACU_DAC_EN_2, this); + lp_var_t dacRawChannelVal0 = + lp_var_t(sid.objectId, P60System::ACU_DAC_RAW_0, this); + lp_var_t dacRawChannelVal1 = + lp_var_t(sid.objectId, P60System::ACU_DAC_RAW_1, this); + lp_var_t dacRawChannelVal2 = + lp_var_t(sid.objectId, P60System::ACU_DAC_RAW_2, this); + lp_var_t dacRawChannelVal3 = + lp_var_t(sid.objectId, P60System::ACU_DAC_RAW_3, this); + lp_var_t dacRawChannelVal4 = + lp_var_t(sid.objectId, P60System::ACU_DAC_RAW_4, this); + lp_var_t dacRawChannelVal5 = + lp_var_t(sid.objectId, P60System::ACU_DAC_RAW_5, this); - lp_var_t dacRawChannelVal0 = lp_var_t(sid.objectId, - P60System::ACU_DAC_RAW_0, this); - lp_var_t dacRawChannelVal1 = lp_var_t(sid.objectId, - P60System::ACU_DAC_RAW_1, this); - lp_var_t dacRawChannelVal2 = lp_var_t(sid.objectId, - P60System::ACU_DAC_RAW_2, this); - lp_var_t dacRawChannelVal3 = lp_var_t(sid.objectId, - P60System::ACU_DAC_RAW_3, this); - lp_var_t dacRawChannelVal4 = lp_var_t(sid.objectId, - P60System::ACU_DAC_RAW_4, this); - lp_var_t dacRawChannelVal5 = lp_var_t(sid.objectId, - P60System::ACU_DAC_RAW_5, this); + lp_var_t bootCause = lp_var_t(sid.objectId, P60System::ACU_BOOTCAUSE, this); + lp_var_t bootcnt = lp_var_t(sid.objectId, P60System::ACU_BOOTCNT, this); + lp_var_t uptime = lp_var_t(sid.objectId, P60System::ACU_UPTIME, this); + lp_var_t resetCause = + lp_var_t(sid.objectId, P60System::ACU_RESET_CAUSE, this); + lp_var_t mpptTime = lp_var_t(sid.objectId, P60System::ACU_MPPT_TIME, this); + lp_var_t mpptPeriod = + lp_var_t(sid.objectId, P60System::ACU_MPPT_PERIOD, this); - lp_var_t bootCause = lp_var_t(sid.objectId, - P60System::ACU_BOOTCAUSE, this); - lp_var_t bootcnt = lp_var_t(sid.objectId, - P60System::ACU_BOOTCNT, this); - lp_var_t uptime = lp_var_t(sid.objectId, - P60System::ACU_UPTIME, this); - lp_var_t resetCause = lp_var_t(sid.objectId, - P60System::ACU_RESET_CAUSE, this); - lp_var_t mpptTime = lp_var_t(sid.objectId, - P60System::ACU_MPPT_TIME, this); - lp_var_t mpptPeriod = lp_var_t(sid.objectId, - P60System::ACU_MPPT_PERIOD, this); + lp_var_t device0 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_0, this); + lp_var_t device1 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_1, this); + lp_var_t device2 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_2, this); + lp_var_t device3 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_3, this); + lp_var_t device4 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_4, this); + lp_var_t device5 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_5, this); + lp_var_t device6 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_6, this); + lp_var_t device7 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_7, this); - lp_var_t device0 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_0, this); - lp_var_t device1 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_1, this); - lp_var_t device2 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_2, this); - lp_var_t device3 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_3, this); - lp_var_t device4 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_4, this); - lp_var_t device5 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_5, this); - lp_var_t device6 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_6, this); - lp_var_t device7 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_7, this); + lp_var_t device0Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_0_STATUS, this); + lp_var_t device1Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_1_STATUS, this); + lp_var_t device2Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_2_STATUS, this); + lp_var_t device3Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_3_STATUS, this); + lp_var_t device4Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_4_STATUS, this); + lp_var_t device5Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_5_STATUS, this); + lp_var_t device6Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_6_STATUS, this); + lp_var_t device7Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_7_STATUS, this); - lp_var_t device0Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_0_STATUS, this); - lp_var_t device1Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_1_STATUS, this); - lp_var_t device2Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_2_STATUS, this); - lp_var_t device3Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_3_STATUS, this); - lp_var_t device4Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_4_STATUS, this); - lp_var_t device5Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_5_STATUS, this); - lp_var_t device6Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_6_STATUS, this); - lp_var_t device7Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_7_STATUS, this); - - lp_var_t wdtCntGnd = lp_var_t(sid.objectId, - P60System::ACU_WDT_CNT_GND, this); - lp_var_t wdtGndLeft = lp_var_t(sid.objectId, - P60System::ACU_WDT_GND_LEFT, this); + lp_var_t wdtCntGnd = lp_var_t(sid.objectId, P60System::ACU_WDT_CNT_GND, this); + lp_var_t wdtGndLeft = + lp_var_t(sid.objectId, P60System::ACU_WDT_GND_LEFT, this); }; -} +} // namespace ACU #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEDEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/GyroADIS1650XDefinitions.h b/mission/devices/devicedefinitions/GyroADIS1650XDefinitions.h index 62744e3a..a09d2fb7 100644 --- a/mission/devices/devicedefinitions/GyroADIS1650XDefinitions.h +++ b/mission/devices/devicedefinitions/GyroADIS1650XDefinitions.h @@ -1,17 +1,14 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_GYROADIS16507DEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_GYROADIS16507DEFINITIONS_H_ -#include "fsfw/devicehandlers/DeviceHandlerIF.h" -#include "fsfw/datapoollocal/StaticLocalDataSet.h" - #include +#include "fsfw/datapoollocal/StaticLocalDataSet.h" +#include "fsfw/devicehandlers/DeviceHandlerIF.h" + namespace ADIS1650X { -enum class Type { - ADIS16505, - ADIS16507 -}; +enum class Type { ADIS16505, ADIS16507 }; static constexpr size_t MAXIMUM_REPLY_SIZE = 64; static constexpr uint8_t WRITE_MASK = 0b1000'0000; @@ -63,91 +60,82 @@ static constexpr size_t SENSOR_READOUT_SIZE = 20 + 2; static constexpr uint32_t ADIS_DATASET_ID = READ_SENSOR_DATA; static constexpr uint32_t ADIS_CFG_DATASET_ID = READ_OUT_CONFIG; -enum GlobCmds: uint8_t { - FACTORY_CALIBRATION = 0b0000'0010, - SENSOR_SELF_TEST = 0b0000'0100, - FLASH_MEMORY_UPDATE = 0b0000'1000, - FLASH_MEMORY_TEST = 0b0001'0000, - SOFTWARE_RESET = 0b1000'0000 +enum GlobCmds : uint8_t { + FACTORY_CALIBRATION = 0b0000'0010, + SENSOR_SELF_TEST = 0b0000'0100, + FLASH_MEMORY_UPDATE = 0b0000'1000, + FLASH_MEMORY_TEST = 0b0001'0000, + SOFTWARE_RESET = 0b1000'0000 }; -enum PrimaryPoolIds: lp_id_t { - ANG_VELOC_X, - ANG_VELOC_Y, - ANG_VELOC_Z, - ACCELERATION_X, - ACCELERATION_Y, - ACCELERATION_Z, - TEMPERATURE, - DIAG_STAT_REGISTER, - FILTER_SETTINGS, - MSC_CTRL_REGISTER, - DEC_RATE_REGISTER, +enum PrimaryPoolIds : lp_id_t { + ANG_VELOC_X, + ANG_VELOC_Y, + ANG_VELOC_Z, + ACCELERATION_X, + ACCELERATION_Y, + ACCELERATION_Z, + TEMPERATURE, + DIAG_STAT_REGISTER, + FILTER_SETTINGS, + MSC_CTRL_REGISTER, + DEC_RATE_REGISTER, }; -enum FilterSettings: uint8_t { - NO_FILTER = 0, - TWO_TAPS = 1, - FOUR_TAPS = 2, - EIGHT_TAPS = 3, - SIXTEEN_TAPS = 4, - THIRTYTWO_TAPS = 5, - SIXTYFOUR_TAPS = 6 +enum FilterSettings : uint8_t { + NO_FILTER = 0, + TWO_TAPS = 1, + FOUR_TAPS = 2, + EIGHT_TAPS = 3, + SIXTEEN_TAPS = 4, + THIRTYTWO_TAPS = 5, + SIXTYFOUR_TAPS = 6 }; -} +} // namespace ADIS1650X -class AdisGyroPrimaryDataset: public StaticLocalDataSet<8> { -public: +class AdisGyroPrimaryDataset : public StaticLocalDataSet<8> { + public: + /** Constructor for data users like controllers */ + AdisGyroPrimaryDataset(object_id_t adisId) + : StaticLocalDataSet(sid_t(adisId, ADIS1650X::ADIS_DATASET_ID)) { + setAllVariablesReadOnly(); + } - /** Constructor for data users like controllers */ - AdisGyroPrimaryDataset(object_id_t adisId): - StaticLocalDataSet(sid_t(adisId, ADIS1650X::ADIS_DATASET_ID)) { - setAllVariablesReadOnly(); - } + /* Angular velocities in degrees per second (DPS) */ + lp_var_t angVelocX = lp_var_t(sid.objectId, ADIS1650X::ANG_VELOC_X, this); + lp_var_t angVelocY = lp_var_t(sid.objectId, ADIS1650X::ANG_VELOC_Y, this); + lp_var_t angVelocZ = lp_var_t(sid.objectId, ADIS1650X::ANG_VELOC_Z, this); + lp_var_t accelX = lp_var_t(sid.objectId, ADIS1650X::ACCELERATION_X, this); + lp_var_t accelY = lp_var_t(sid.objectId, ADIS1650X::ACCELERATION_Y, this); + lp_var_t accelZ = lp_var_t(sid.objectId, ADIS1650X::ACCELERATION_Z, this); + lp_var_t temperature = lp_var_t(sid.objectId, ADIS1650X::TEMPERATURE, this); - /* Angular velocities in degrees per second (DPS) */ - lp_var_t angVelocX = lp_var_t(sid.objectId, - ADIS1650X::ANG_VELOC_X, this); - lp_var_t angVelocY = lp_var_t(sid.objectId, - ADIS1650X::ANG_VELOC_Y, this); - lp_var_t angVelocZ = lp_var_t(sid.objectId, - ADIS1650X::ANG_VELOC_Z, this); - lp_var_t accelX = lp_var_t(sid.objectId, - ADIS1650X::ACCELERATION_X, this); - lp_var_t accelY = lp_var_t(sid.objectId, - ADIS1650X::ACCELERATION_Y, this); - lp_var_t accelZ = lp_var_t(sid.objectId, - ADIS1650X::ACCELERATION_Z, this); - lp_var_t temperature = lp_var_t(sid.objectId, - ADIS1650X::TEMPERATURE, this); -private: - - friend class GyroADIS1650XHandler; - /** Constructor for the data creator */ - AdisGyroPrimaryDataset(HasLocalDataPoolIF* hkOwner): - StaticLocalDataSet(hkOwner, ADIS1650X::ADIS_DATASET_ID) {} + private: + friend class GyroADIS1650XHandler; + /** Constructor for the data creator */ + AdisGyroPrimaryDataset(HasLocalDataPoolIF* hkOwner) + : StaticLocalDataSet(hkOwner, ADIS1650X::ADIS_DATASET_ID) {} }; -class AdisGyroConfigDataset: public StaticLocalDataSet<5> { -public: +class AdisGyroConfigDataset : public StaticLocalDataSet<5> { + public: + /** Constructor for data users like controllers */ + AdisGyroConfigDataset(object_id_t adisId) + : StaticLocalDataSet(sid_t(adisId, ADIS1650X::ADIS_CFG_DATASET_ID)) { + setAllVariablesReadOnly(); + } - /** Constructor for data users like controllers */ - AdisGyroConfigDataset(object_id_t adisId): - StaticLocalDataSet(sid_t(adisId, ADIS1650X::ADIS_CFG_DATASET_ID)) { - setAllVariablesReadOnly(); - } + lp_var_t diagStatReg = lp_var_t(sid.objectId, ADIS1650X::DIAG_STAT_REGISTER); + lp_var_t filterSetting = lp_var_t(sid.objectId, ADIS1650X::FILTER_SETTINGS); + lp_var_t mscCtrlReg = lp_var_t(sid.objectId, ADIS1650X::MSC_CTRL_REGISTER); + lp_var_t decRateReg = lp_var_t(sid.objectId, ADIS1650X::DEC_RATE_REGISTER); - lp_var_t diagStatReg = lp_var_t(sid.objectId, - ADIS1650X::DIAG_STAT_REGISTER); - lp_var_t filterSetting = lp_var_t(sid.objectId, ADIS1650X::FILTER_SETTINGS); - lp_var_t mscCtrlReg = lp_var_t(sid.objectId, ADIS1650X::MSC_CTRL_REGISTER); - lp_var_t decRateReg = lp_var_t(sid.objectId, ADIS1650X::DEC_RATE_REGISTER); -private: - friend class GyroADIS1650XHandler; - /** Constructor for the data creator */ - AdisGyroConfigDataset(HasLocalDataPoolIF* hkOwner): - StaticLocalDataSet(hkOwner, ADIS1650X::ADIS_CFG_DATASET_ID) {} + private: + friend class GyroADIS1650XHandler; + /** Constructor for the data creator */ + AdisGyroConfigDataset(HasLocalDataPoolIF* hkOwner) + : StaticLocalDataSet(hkOwner, ADIS1650X::ADIS_CFG_DATASET_ID) {} }; #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GYROADIS16507DEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/GyroL3GD20Definitions.h b/mission/devices/devicedefinitions/GyroL3GD20Definitions.h index b5b80495..4c4543d0 100644 --- a/mission/devices/devicedefinitions/GyroL3GD20Definitions.h +++ b/mission/devices/devicedefinitions/GyroL3GD20Definitions.h @@ -3,6 +3,7 @@ #include #include + #include namespace L3GD20H { @@ -36,8 +37,8 @@ static constexpr uint8_t SET_Z_ENABLE = 1 << 2; static constexpr uint8_t SET_X_ENABLE = 1 << 1; static constexpr uint8_t SET_Y_ENABLE = 1; -static constexpr uint8_t CTRL_REG_1_VAL = SET_POWER_NORMAL_MODE | SET_Z_ENABLE | - SET_Y_ENABLE | SET_X_ENABLE; +static constexpr uint8_t CTRL_REG_1_VAL = + SET_POWER_NORMAL_MODE | SET_Z_ENABLE | SET_Y_ENABLE | SET_X_ENABLE; /* Register 2 */ static constexpr uint8_t EXTERNAL_EDGE_ENB = 1 << 7; @@ -101,40 +102,29 @@ static constexpr DeviceCommandId_t READ_CTRL_REGS = 2; static constexpr uint32_t GYRO_DATASET_ID = READ_REGS; -enum GyroPoolIds: lp_id_t { - ANG_VELOC_X, - ANG_VELOC_Y, - ANG_VELOC_Z, - TEMPERATURE +enum GyroPoolIds : lp_id_t { ANG_VELOC_X, ANG_VELOC_Y, ANG_VELOC_Z, TEMPERATURE }; + +} // namespace L3GD20H + +class GyroPrimaryDataset : public StaticLocalDataSet<5> { + public: + /** Constructor for data users like controllers */ + GyroPrimaryDataset(object_id_t mgmId) + : StaticLocalDataSet(sid_t(mgmId, L3GD20H::GYRO_DATASET_ID)) { + setAllVariablesReadOnly(); + } + + /* Angular velocities in degrees per second (DPS) */ + lp_var_t angVelocX = lp_var_t(sid.objectId, L3GD20H::ANG_VELOC_X, this); + lp_var_t angVelocY = lp_var_t(sid.objectId, L3GD20H::ANG_VELOC_Y, this); + lp_var_t angVelocZ = lp_var_t(sid.objectId, L3GD20H::ANG_VELOC_Z, this); + lp_var_t temperature = lp_var_t(sid.objectId, L3GD20H::TEMPERATURE, this); + + private: + friend class GyroHandlerL3GD20H; + /** Constructor for the data creator */ + GyroPrimaryDataset(HasLocalDataPoolIF* hkOwner) + : StaticLocalDataSet(hkOwner, L3GD20H::GYRO_DATASET_ID) {} }; -} - -class GyroPrimaryDataset: public StaticLocalDataSet<5> { -public: - - /** Constructor for data users like controllers */ - GyroPrimaryDataset(object_id_t mgmId): - StaticLocalDataSet(sid_t(mgmId, L3GD20H::GYRO_DATASET_ID)) { - setAllVariablesReadOnly(); - } - - /* Angular velocities in degrees per second (DPS) */ - lp_var_t angVelocX = lp_var_t(sid.objectId, - L3GD20H::ANG_VELOC_X, this); - lp_var_t angVelocY = lp_var_t(sid.objectId, - L3GD20H::ANG_VELOC_Y, this); - lp_var_t angVelocZ = lp_var_t(sid.objectId, - L3GD20H::ANG_VELOC_Z, this); - lp_var_t temperature = lp_var_t(sid.objectId, - L3GD20H::TEMPERATURE, this); -private: - - friend class GyroHandlerL3GD20H; - /** Constructor for the data creator */ - GyroPrimaryDataset(HasLocalDataPoolIF* hkOwner): - StaticLocalDataSet(hkOwner, L3GD20H::GYRO_DATASET_ID) {} -}; - - #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GYROL3GD20DEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/IMTQHandlerDefinitions.h b/mission/devices/devicedefinitions/IMTQHandlerDefinitions.h index e95bd42e..609bbdf8 100644 --- a/mission/devices/devicedefinitions/IMTQHandlerDefinitions.h +++ b/mission/devices/devicedefinitions/IMTQHandlerDefinitions.h @@ -5,453 +5,435 @@ namespace IMTQ { - static const DeviceCommandId_t NONE = 0x0; - static const DeviceCommandId_t GET_ENG_HK_DATA = 0x1; - static const DeviceCommandId_t START_ACTUATION_DIPOLE = 0x2; - static const DeviceCommandId_t GET_COMMANDED_DIPOLE = 0x3; - /** Generates new measurement of the magnetic field */ - static const DeviceCommandId_t START_MTM_MEASUREMENT = 0x4; - /** Requests the calibrated magnetometer measurement */ - static const DeviceCommandId_t GET_CAL_MTM_MEASUREMENT = 0x5; - /** Requests the raw values measured by the built-in MTM XEN1210 */ - static const DeviceCommandId_t GET_RAW_MTM_MEASUREMENT = 0x6; - static const DeviceCommandId_t POS_X_SELF_TEST = 0x7; - static const DeviceCommandId_t NEG_X_SELF_TEST = 0x8; - static const DeviceCommandId_t POS_Y_SELF_TEST = 0x9; - static const DeviceCommandId_t NEG_Y_SELF_TEST = 0xA; - static const DeviceCommandId_t POS_Z_SELF_TEST = 0xB; - static const DeviceCommandId_t NEG_Z_SELF_TEST = 0xC; - static const DeviceCommandId_t GET_SELF_TEST_RESULT = 0xD; +static const DeviceCommandId_t NONE = 0x0; +static const DeviceCommandId_t GET_ENG_HK_DATA = 0x1; +static const DeviceCommandId_t START_ACTUATION_DIPOLE = 0x2; +static const DeviceCommandId_t GET_COMMANDED_DIPOLE = 0x3; +/** Generates new measurement of the magnetic field */ +static const DeviceCommandId_t START_MTM_MEASUREMENT = 0x4; +/** Requests the calibrated magnetometer measurement */ +static const DeviceCommandId_t GET_CAL_MTM_MEASUREMENT = 0x5; +/** Requests the raw values measured by the built-in MTM XEN1210 */ +static const DeviceCommandId_t GET_RAW_MTM_MEASUREMENT = 0x6; +static const DeviceCommandId_t POS_X_SELF_TEST = 0x7; +static const DeviceCommandId_t NEG_X_SELF_TEST = 0x8; +static const DeviceCommandId_t POS_Y_SELF_TEST = 0x9; +static const DeviceCommandId_t NEG_Y_SELF_TEST = 0xA; +static const DeviceCommandId_t POS_Z_SELF_TEST = 0xB; +static const DeviceCommandId_t NEG_Z_SELF_TEST = 0xC; +static const DeviceCommandId_t GET_SELF_TEST_RESULT = 0xD; - static const uint8_t GET_TEMP_REPLY_SIZE = 2; - static const uint8_t CFGR_CMD_SIZE = 3; - static const uint8_t POINTER_REG_SIZE = 1; +static const uint8_t GET_TEMP_REPLY_SIZE = 2; +static const uint8_t CFGR_CMD_SIZE = 3; +static const uint8_t POINTER_REG_SIZE = 1; - static const uint32_t ENG_HK_DATA_SET_ID = 1; - static const uint32_t CAL_MTM_SET = 2; - static const uint32_t RAW_MTM_SET = 3; - static const uint32_t POS_X_TEST_DATASET = 4; - static const uint32_t NEG_X_TEST_DATASET = 5; - static const uint32_t POS_Y_TEST_DATASET = 6; - static const uint32_t NEG_Y_TEST_DATASET = 7; - static const uint32_t POS_Z_TEST_DATASET = 8; - static const uint32_t NEG_Z_TEST_DATASET = 9; +static const uint32_t ENG_HK_DATA_SET_ID = 1; +static const uint32_t CAL_MTM_SET = 2; +static const uint32_t RAW_MTM_SET = 3; +static const uint32_t POS_X_TEST_DATASET = 4; +static const uint32_t NEG_X_TEST_DATASET = 5; +static const uint32_t POS_Y_TEST_DATASET = 6; +static const uint32_t NEG_Y_TEST_DATASET = 7; +static const uint32_t POS_Z_TEST_DATASET = 8; +static const uint32_t NEG_Z_TEST_DATASET = 9; - static const uint8_t SIZE_ENG_HK_COMMAND = 1; - static const uint8_t SIZE_STATUS_REPLY = 2; - static const uint8_t SIZE_ENG_HK_DATA_REPLY = 24; - static const uint8_t SIZE_GET_COMMANDED_DIPOLE_REPLY = 8; - static const uint8_t SIZE_GET_CAL_MTM_MEASUREMENT = 15; - static const uint8_t SIZE_GET_RAW_MTM_MEASUREMENT = 15; - static const uint16_t SIZE_SELF_TEST_RESULTS = 120; +static const uint8_t SIZE_ENG_HK_COMMAND = 1; +static const uint8_t SIZE_STATUS_REPLY = 2; +static const uint8_t SIZE_ENG_HK_DATA_REPLY = 24; +static const uint8_t SIZE_GET_COMMANDED_DIPOLE_REPLY = 8; +static const uint8_t SIZE_GET_CAL_MTM_MEASUREMENT = 15; +static const uint8_t SIZE_GET_RAW_MTM_MEASUREMENT = 15; +static const uint16_t SIZE_SELF_TEST_RESULTS = 120; - static const uint16_t MAX_REPLY_SIZE = SIZE_SELF_TEST_RESULTS; - static const uint8_t MAX_COMMAND_SIZE = 9; +static const uint16_t MAX_REPLY_SIZE = SIZE_SELF_TEST_RESULTS; +static const uint8_t MAX_COMMAND_SIZE = 9; - /** Define entries in IMTQ specific dataset */ - static const uint8_t ENG_HK_SET_POOL_ENTRIES = 11; - static const uint8_t CAL_MTM_POOL_ENTRIES = 4; - static const uint8_t SELF_TEST_DATASET_ENTRIES = 104; +/** Define entries in IMTQ specific dataset */ +static const uint8_t ENG_HK_SET_POOL_ENTRIES = 11; +static const uint8_t CAL_MTM_POOL_ENTRIES = 4; +static const uint8_t SELF_TEST_DATASET_ENTRIES = 104; - /** Error codes for interpreting the self test error byte */ - static const uint8_t I2C_FAILURE_MASK = 0x1; - static const uint8_t SPI_FAILURE_MASK = 0x2; // MTM connectivity - static const uint8_t ADC_FAILURE_MASK = 0x4; // Current/Temp measurement - static const uint8_t PWM_FAILURE_MASK = 0x8; // Coil actuation - static const uint8_t TC_FAILURE_MASK = 0x10; // System failure - static const uint8_t MTM_RANGE_FAILURE_MASK = 0x20; // MTM values outside of expected range - static const uint8_t COIL_CURRENT_FAILURE_MASK = 0x40; // Coil currents outside of expected range - static const uint8_t INVALID_ERROR_BYTE = 0x80; // This is an invalid error byte and should be never replied by the IMTQ +/** Error codes for interpreting the self test error byte */ +static const uint8_t I2C_FAILURE_MASK = 0x1; +static const uint8_t SPI_FAILURE_MASK = 0x2; // MTM connectivity +static const uint8_t ADC_FAILURE_MASK = 0x4; // Current/Temp measurement +static const uint8_t PWM_FAILURE_MASK = 0x8; // Coil actuation +static const uint8_t TC_FAILURE_MASK = 0x10; // System failure +static const uint8_t MTM_RANGE_FAILURE_MASK = 0x20; // MTM values outside of expected range +static const uint8_t COIL_CURRENT_FAILURE_MASK = 0x40; // Coil currents outside of expected range +static const uint8_t INVALID_ERROR_BYTE = + 0x80; // This is an invalid error byte and should be never replied by the IMTQ - static const uint8_t MAIN_STEP_OFFSET = 43; +static const uint8_t MAIN_STEP_OFFSET = 43; - /** - * Command code definitions. Each command or reply of an IMTQ request will begin with one of - * the following command codes. - */ - namespace CC { - static const uint8_t START_MTM_MEASUREMENT = 0x4; - static const uint8_t START_ACTUATION_DIPOLE = 0x6; - static const uint8_t SELF_TEST_CMD = 0x8; - static const uint8_t SOFTWARE_RESET = 0xAA; - static const uint8_t GET_ENG_HK_DATA = 0x4A; - static const uint8_t GET_COMMANDED_DIPOLE = 0x46; - static const uint8_t GET_RAW_MTM_MEASUREMENT = 0x42; - static const uint8_t GET_CAL_MTM_MEASUREMENT = 0x43; - static const uint8_t GET_SELF_TEST_RESULT = 0x47; - }; +/** + * Command code definitions. Each command or reply of an IMTQ request will begin with one of + * the following command codes. + */ +namespace CC { +static const uint8_t START_MTM_MEASUREMENT = 0x4; +static const uint8_t START_ACTUATION_DIPOLE = 0x6; +static const uint8_t SELF_TEST_CMD = 0x8; +static const uint8_t SOFTWARE_RESET = 0xAA; +static const uint8_t GET_ENG_HK_DATA = 0x4A; +static const uint8_t GET_COMMANDED_DIPOLE = 0x46; +static const uint8_t GET_RAW_MTM_MEASUREMENT = 0x42; +static const uint8_t GET_CAL_MTM_MEASUREMENT = 0x43; +static const uint8_t GET_SELF_TEST_RESULT = 0x47; +}; // namespace CC - namespace SELF_TEST_AXIS { - static const uint8_t ALL = 0x0; - static const uint8_t X_POSITIVE = 0x1; - static const uint8_t X_NEGATIVE = 0x2; - static const uint8_t Y_POSITIVE = 0x3; - static const uint8_t Y_NEGATIVE = 0x4; - static const uint8_t Z_POSITIVE = 0x5; - static const uint8_t Z_NEGATIVE = 0x6; - } +namespace SELF_TEST_AXIS { +static const uint8_t ALL = 0x0; +static const uint8_t X_POSITIVE = 0x1; +static const uint8_t X_NEGATIVE = 0x2; +static const uint8_t Y_POSITIVE = 0x3; +static const uint8_t Y_NEGATIVE = 0x4; +static const uint8_t Z_POSITIVE = 0x5; +static const uint8_t Z_NEGATIVE = 0x6; +} // namespace SELF_TEST_AXIS - namespace SELF_TEST_STEPS { - static const uint8_t INIT = 0x0; - static const uint8_t X_POSITIVE = 0x1; - static const uint8_t X_NEGATIVE = 0x2; - static const uint8_t Y_POSITIVE = 0x3; - static const uint8_t Y_NEGATIVE = 0x4; - static const uint8_t Z_POSITIVE = 0x5; - static const uint8_t Z_NEGATIVE = 0x6; - static const uint8_t FINA = 0x7; - } +namespace SELF_TEST_STEPS { +static const uint8_t INIT = 0x0; +static const uint8_t X_POSITIVE = 0x1; +static const uint8_t X_NEGATIVE = 0x2; +static const uint8_t Y_POSITIVE = 0x3; +static const uint8_t Y_NEGATIVE = 0x4; +static const uint8_t Z_POSITIVE = 0x5; +static const uint8_t Z_NEGATIVE = 0x6; +static const uint8_t FINA = 0x7; +} // namespace SELF_TEST_STEPS - enum IMTQPoolIds: lp_id_t { - DIGITAL_VOLTAGE_MV, - ANALOG_VOLTAGE_MV, - DIGITAL_CURRENT, - ANALOG_CURRENT, - COIL_X_CURRENT, - COIL_Y_CURRENT, - COIL_Z_CURRENT, - COIL_X_TEMPERATURE, - COIL_Y_TEMPERATURE, - COIL_Z_TEMPERATURE, - MCU_TEMPERATURE, - MTM_CAL_X, - MTM_CAL_Y, - MTM_CAL_Z, - ACTUATION_CAL_STATUS, - MTM_RAW_X, - MTM_RAW_Y, - MTM_RAW_Z, - ACTUATION_RAW_STATUS, +enum IMTQPoolIds : lp_id_t { + DIGITAL_VOLTAGE_MV, + ANALOG_VOLTAGE_MV, + DIGITAL_CURRENT, + ANALOG_CURRENT, + COIL_X_CURRENT, + COIL_Y_CURRENT, + COIL_Z_CURRENT, + COIL_X_TEMPERATURE, + COIL_Y_TEMPERATURE, + COIL_Z_TEMPERATURE, + MCU_TEMPERATURE, + MTM_CAL_X, + MTM_CAL_Y, + MTM_CAL_Z, + ACTUATION_CAL_STATUS, + MTM_RAW_X, + MTM_RAW_Y, + MTM_RAW_Z, + ACTUATION_RAW_STATUS, - INIT_POS_X_ERR, - INIT_POS_X_RAW_MAG_X, - INIT_POS_X_RAW_MAG_Y, - INIT_POS_X_RAW_MAG_Z, - INIT_POS_X_CAL_MAG_X, - INIT_POS_X_CAL_MAG_Y, - INIT_POS_X_CAL_MAG_Z, - INIT_POS_X_COIL_X_CURRENT, - INIT_POS_X_COIL_Y_CURRENT, - INIT_POS_X_COIL_Z_CURRENT, - INIT_POS_X_COIL_X_TEMPERATURE, - INIT_POS_X_COIL_Y_TEMPERATURE, - INIT_POS_X_COIL_Z_TEMPERATURE, + INIT_POS_X_ERR, + INIT_POS_X_RAW_MAG_X, + INIT_POS_X_RAW_MAG_Y, + INIT_POS_X_RAW_MAG_Z, + INIT_POS_X_CAL_MAG_X, + INIT_POS_X_CAL_MAG_Y, + INIT_POS_X_CAL_MAG_Z, + INIT_POS_X_COIL_X_CURRENT, + INIT_POS_X_COIL_Y_CURRENT, + INIT_POS_X_COIL_Z_CURRENT, + INIT_POS_X_COIL_X_TEMPERATURE, + INIT_POS_X_COIL_Y_TEMPERATURE, + INIT_POS_X_COIL_Z_TEMPERATURE, - INIT_NEG_X_ERR, - INIT_NEG_X_RAW_MAG_X, - INIT_NEG_X_RAW_MAG_Y, - INIT_NEG_X_RAW_MAG_Z, - INIT_NEG_X_CAL_MAG_X, - INIT_NEG_X_CAL_MAG_Y, - INIT_NEG_X_CAL_MAG_Z, - INIT_NEG_X_COIL_X_CURRENT, - INIT_NEG_X_COIL_Y_CURRENT, - INIT_NEG_X_COIL_Z_CURRENT, - INIT_NEG_X_COIL_X_TEMPERATURE, - INIT_NEG_X_COIL_Y_TEMPERATURE, - INIT_NEG_X_COIL_Z_TEMPERATURE, + INIT_NEG_X_ERR, + INIT_NEG_X_RAW_MAG_X, + INIT_NEG_X_RAW_MAG_Y, + INIT_NEG_X_RAW_MAG_Z, + INIT_NEG_X_CAL_MAG_X, + INIT_NEG_X_CAL_MAG_Y, + INIT_NEG_X_CAL_MAG_Z, + INIT_NEG_X_COIL_X_CURRENT, + INIT_NEG_X_COIL_Y_CURRENT, + INIT_NEG_X_COIL_Z_CURRENT, + INIT_NEG_X_COIL_X_TEMPERATURE, + INIT_NEG_X_COIL_Y_TEMPERATURE, + INIT_NEG_X_COIL_Z_TEMPERATURE, - INIT_POS_Y_ERR, - INIT_POS_Y_RAW_MAG_X, - INIT_POS_Y_RAW_MAG_Y, - INIT_POS_Y_RAW_MAG_Z, - INIT_POS_Y_CAL_MAG_X, - INIT_POS_Y_CAL_MAG_Y, - INIT_POS_Y_CAL_MAG_Z, - INIT_POS_Y_COIL_X_CURRENT, - INIT_POS_Y_COIL_Y_CURRENT, - INIT_POS_Y_COIL_Z_CURRENT, - INIT_POS_Y_COIL_X_TEMPERATURE, - INIT_POS_Y_COIL_Y_TEMPERATURE, - INIT_POS_Y_COIL_Z_TEMPERATURE, + INIT_POS_Y_ERR, + INIT_POS_Y_RAW_MAG_X, + INIT_POS_Y_RAW_MAG_Y, + INIT_POS_Y_RAW_MAG_Z, + INIT_POS_Y_CAL_MAG_X, + INIT_POS_Y_CAL_MAG_Y, + INIT_POS_Y_CAL_MAG_Z, + INIT_POS_Y_COIL_X_CURRENT, + INIT_POS_Y_COIL_Y_CURRENT, + INIT_POS_Y_COIL_Z_CURRENT, + INIT_POS_Y_COIL_X_TEMPERATURE, + INIT_POS_Y_COIL_Y_TEMPERATURE, + INIT_POS_Y_COIL_Z_TEMPERATURE, - INIT_NEG_Y_ERR, - INIT_NEG_Y_RAW_MAG_X, - INIT_NEG_Y_RAW_MAG_Y, - INIT_NEG_Y_RAW_MAG_Z, - INIT_NEG_Y_CAL_MAG_X, - INIT_NEG_Y_CAL_MAG_Y, - INIT_NEG_Y_CAL_MAG_Z, - INIT_NEG_Y_COIL_X_CURRENT, - INIT_NEG_Y_COIL_Y_CURRENT, - INIT_NEG_Y_COIL_Z_CURRENT, - INIT_NEG_Y_COIL_X_TEMPERATURE, - INIT_NEG_Y_COIL_Y_TEMPERATURE, - INIT_NEG_Y_COIL_Z_TEMPERATURE, + INIT_NEG_Y_ERR, + INIT_NEG_Y_RAW_MAG_X, + INIT_NEG_Y_RAW_MAG_Y, + INIT_NEG_Y_RAW_MAG_Z, + INIT_NEG_Y_CAL_MAG_X, + INIT_NEG_Y_CAL_MAG_Y, + INIT_NEG_Y_CAL_MAG_Z, + INIT_NEG_Y_COIL_X_CURRENT, + INIT_NEG_Y_COIL_Y_CURRENT, + INIT_NEG_Y_COIL_Z_CURRENT, + INIT_NEG_Y_COIL_X_TEMPERATURE, + INIT_NEG_Y_COIL_Y_TEMPERATURE, + INIT_NEG_Y_COIL_Z_TEMPERATURE, - INIT_POS_Z_ERR, - INIT_POS_Z_RAW_MAG_X, - INIT_POS_Z_RAW_MAG_Y, - INIT_POS_Z_RAW_MAG_Z, - INIT_POS_Z_CAL_MAG_X, - INIT_POS_Z_CAL_MAG_Y, - INIT_POS_Z_CAL_MAG_Z, - INIT_POS_Z_COIL_X_CURRENT, - INIT_POS_Z_COIL_Y_CURRENT, - INIT_POS_Z_COIL_Z_CURRENT, - INIT_POS_Z_COIL_X_TEMPERATURE, - INIT_POS_Z_COIL_Y_TEMPERATURE, - INIT_POS_Z_COIL_Z_TEMPERATURE, + INIT_POS_Z_ERR, + INIT_POS_Z_RAW_MAG_X, + INIT_POS_Z_RAW_MAG_Y, + INIT_POS_Z_RAW_MAG_Z, + INIT_POS_Z_CAL_MAG_X, + INIT_POS_Z_CAL_MAG_Y, + INIT_POS_Z_CAL_MAG_Z, + INIT_POS_Z_COIL_X_CURRENT, + INIT_POS_Z_COIL_Y_CURRENT, + INIT_POS_Z_COIL_Z_CURRENT, + INIT_POS_Z_COIL_X_TEMPERATURE, + INIT_POS_Z_COIL_Y_TEMPERATURE, + INIT_POS_Z_COIL_Z_TEMPERATURE, - INIT_NEG_Z_ERR, - INIT_NEG_Z_RAW_MAG_X, - INIT_NEG_Z_RAW_MAG_Y, - INIT_NEG_Z_RAW_MAG_Z, - INIT_NEG_Z_CAL_MAG_X, - INIT_NEG_Z_CAL_MAG_Y, - INIT_NEG_Z_CAL_MAG_Z, - INIT_NEG_Z_COIL_X_CURRENT, - INIT_NEG_Z_COIL_Y_CURRENT, - INIT_NEG_Z_COIL_Z_CURRENT, - INIT_NEG_Z_COIL_X_TEMPERATURE, - INIT_NEG_Z_COIL_Y_TEMPERATURE, - INIT_NEG_Z_COIL_Z_TEMPERATURE, + INIT_NEG_Z_ERR, + INIT_NEG_Z_RAW_MAG_X, + INIT_NEG_Z_RAW_MAG_Y, + INIT_NEG_Z_RAW_MAG_Z, + INIT_NEG_Z_CAL_MAG_X, + INIT_NEG_Z_CAL_MAG_Y, + INIT_NEG_Z_CAL_MAG_Z, + INIT_NEG_Z_COIL_X_CURRENT, + INIT_NEG_Z_COIL_Y_CURRENT, + INIT_NEG_Z_COIL_Z_CURRENT, + INIT_NEG_Z_COIL_X_TEMPERATURE, + INIT_NEG_Z_COIL_Y_TEMPERATURE, + INIT_NEG_Z_COIL_Z_TEMPERATURE, - POS_X_ERR, - POS_X_RAW_MAG_X, - POS_X_RAW_MAG_Y, - POS_X_RAW_MAG_Z, - POS_X_CAL_MAG_X, - POS_X_CAL_MAG_Y, - POS_X_CAL_MAG_Z, - POS_X_COIL_X_CURRENT, - POS_X_COIL_Y_CURRENT, - POS_X_COIL_Z_CURRENT, - POS_X_COIL_X_TEMPERATURE, - POS_X_COIL_Y_TEMPERATURE, - POS_X_COIL_Z_TEMPERATURE, + POS_X_ERR, + POS_X_RAW_MAG_X, + POS_X_RAW_MAG_Y, + POS_X_RAW_MAG_Z, + POS_X_CAL_MAG_X, + POS_X_CAL_MAG_Y, + POS_X_CAL_MAG_Z, + POS_X_COIL_X_CURRENT, + POS_X_COIL_Y_CURRENT, + POS_X_COIL_Z_CURRENT, + POS_X_COIL_X_TEMPERATURE, + POS_X_COIL_Y_TEMPERATURE, + POS_X_COIL_Z_TEMPERATURE, - NEG_X_ERR, - NEG_X_RAW_MAG_X, - NEG_X_RAW_MAG_Y, - NEG_X_RAW_MAG_Z, - NEG_X_CAL_MAG_X, - NEG_X_CAL_MAG_Y, - NEG_X_CAL_MAG_Z, - NEG_X_COIL_X_CURRENT, - NEG_X_COIL_Y_CURRENT, - NEG_X_COIL_Z_CURRENT, - NEG_X_COIL_X_TEMPERATURE, - NEG_X_COIL_Y_TEMPERATURE, - NEG_X_COIL_Z_TEMPERATURE, + NEG_X_ERR, + NEG_X_RAW_MAG_X, + NEG_X_RAW_MAG_Y, + NEG_X_RAW_MAG_Z, + NEG_X_CAL_MAG_X, + NEG_X_CAL_MAG_Y, + NEG_X_CAL_MAG_Z, + NEG_X_COIL_X_CURRENT, + NEG_X_COIL_Y_CURRENT, + NEG_X_COIL_Z_CURRENT, + NEG_X_COIL_X_TEMPERATURE, + NEG_X_COIL_Y_TEMPERATURE, + NEG_X_COIL_Z_TEMPERATURE, - POS_Y_ERR, - POS_Y_RAW_MAG_X, - POS_Y_RAW_MAG_Y, - POS_Y_RAW_MAG_Z, - POS_Y_CAL_MAG_X, - POS_Y_CAL_MAG_Y, - POS_Y_CAL_MAG_Z, - POS_Y_COIL_X_CURRENT, - POS_Y_COIL_Y_CURRENT, - POS_Y_COIL_Z_CURRENT, - POS_Y_COIL_X_TEMPERATURE, - POS_Y_COIL_Y_TEMPERATURE, - POS_Y_COIL_Z_TEMPERATURE, + POS_Y_ERR, + POS_Y_RAW_MAG_X, + POS_Y_RAW_MAG_Y, + POS_Y_RAW_MAG_Z, + POS_Y_CAL_MAG_X, + POS_Y_CAL_MAG_Y, + POS_Y_CAL_MAG_Z, + POS_Y_COIL_X_CURRENT, + POS_Y_COIL_Y_CURRENT, + POS_Y_COIL_Z_CURRENT, + POS_Y_COIL_X_TEMPERATURE, + POS_Y_COIL_Y_TEMPERATURE, + POS_Y_COIL_Z_TEMPERATURE, - NEG_Y_ERR, - NEG_Y_RAW_MAG_X, - NEG_Y_RAW_MAG_Y, - NEG_Y_RAW_MAG_Z, - NEG_Y_CAL_MAG_X, - NEG_Y_CAL_MAG_Y, - NEG_Y_CAL_MAG_Z, - NEG_Y_COIL_X_CURRENT, - NEG_Y_COIL_Y_CURRENT, - NEG_Y_COIL_Z_CURRENT, - NEG_Y_COIL_X_TEMPERATURE, - NEG_Y_COIL_Y_TEMPERATURE, - NEG_Y_COIL_Z_TEMPERATURE, + NEG_Y_ERR, + NEG_Y_RAW_MAG_X, + NEG_Y_RAW_MAG_Y, + NEG_Y_RAW_MAG_Z, + NEG_Y_CAL_MAG_X, + NEG_Y_CAL_MAG_Y, + NEG_Y_CAL_MAG_Z, + NEG_Y_COIL_X_CURRENT, + NEG_Y_COIL_Y_CURRENT, + NEG_Y_COIL_Z_CURRENT, + NEG_Y_COIL_X_TEMPERATURE, + NEG_Y_COIL_Y_TEMPERATURE, + NEG_Y_COIL_Z_TEMPERATURE, - POS_Z_ERR, - POS_Z_RAW_MAG_X, - POS_Z_RAW_MAG_Y, - POS_Z_RAW_MAG_Z, - POS_Z_CAL_MAG_X, - POS_Z_CAL_MAG_Y, - POS_Z_CAL_MAG_Z, - POS_Z_COIL_X_CURRENT, - POS_Z_COIL_Y_CURRENT, - POS_Z_COIL_Z_CURRENT, - POS_Z_COIL_X_TEMPERATURE, - POS_Z_COIL_Y_TEMPERATURE, - POS_Z_COIL_Z_TEMPERATURE, + POS_Z_ERR, + POS_Z_RAW_MAG_X, + POS_Z_RAW_MAG_Y, + POS_Z_RAW_MAG_Z, + POS_Z_CAL_MAG_X, + POS_Z_CAL_MAG_Y, + POS_Z_CAL_MAG_Z, + POS_Z_COIL_X_CURRENT, + POS_Z_COIL_Y_CURRENT, + POS_Z_COIL_Z_CURRENT, + POS_Z_COIL_X_TEMPERATURE, + POS_Z_COIL_Y_TEMPERATURE, + POS_Z_COIL_Z_TEMPERATURE, - NEG_Z_ERR, - NEG_Z_RAW_MAG_X, - NEG_Z_RAW_MAG_Y, - NEG_Z_RAW_MAG_Z, - NEG_Z_CAL_MAG_X, - NEG_Z_CAL_MAG_Y, - NEG_Z_CAL_MAG_Z, - NEG_Z_COIL_X_CURRENT, - NEG_Z_COIL_Y_CURRENT, - NEG_Z_COIL_Z_CURRENT, - NEG_Z_COIL_X_TEMPERATURE, - NEG_Z_COIL_Y_TEMPERATURE, - NEG_Z_COIL_Z_TEMPERATURE, + NEG_Z_ERR, + NEG_Z_RAW_MAG_X, + NEG_Z_RAW_MAG_Y, + NEG_Z_RAW_MAG_Z, + NEG_Z_CAL_MAG_X, + NEG_Z_CAL_MAG_Y, + NEG_Z_CAL_MAG_Z, + NEG_Z_COIL_X_CURRENT, + NEG_Z_COIL_Y_CURRENT, + NEG_Z_COIL_Z_CURRENT, + NEG_Z_COIL_X_TEMPERATURE, + NEG_Z_COIL_Y_TEMPERATURE, + NEG_Z_COIL_Z_TEMPERATURE, - FINA_POS_X_ERR, - FINA_POS_X_RAW_MAG_X, - FINA_POS_X_RAW_MAG_Y, - FINA_POS_X_RAW_MAG_Z, - FINA_POS_X_CAL_MAG_X, - FINA_POS_X_CAL_MAG_Y, - FINA_POS_X_CAL_MAG_Z, - FINA_POS_X_COIL_X_CURRENT, - FINA_POS_X_COIL_Y_CURRENT, - FINA_POS_X_COIL_Z_CURRENT, - FINA_POS_X_COIL_X_TEMPERATURE, - FINA_POS_X_COIL_Y_TEMPERATURE, - FINA_POS_X_COIL_Z_TEMPERATURE, + FINA_POS_X_ERR, + FINA_POS_X_RAW_MAG_X, + FINA_POS_X_RAW_MAG_Y, + FINA_POS_X_RAW_MAG_Z, + FINA_POS_X_CAL_MAG_X, + FINA_POS_X_CAL_MAG_Y, + FINA_POS_X_CAL_MAG_Z, + FINA_POS_X_COIL_X_CURRENT, + FINA_POS_X_COIL_Y_CURRENT, + FINA_POS_X_COIL_Z_CURRENT, + FINA_POS_X_COIL_X_TEMPERATURE, + FINA_POS_X_COIL_Y_TEMPERATURE, + FINA_POS_X_COIL_Z_TEMPERATURE, - FINA_NEG_X_ERR, - FINA_NEG_X_RAW_MAG_X, - FINA_NEG_X_RAW_MAG_Y, - FINA_NEG_X_RAW_MAG_Z, - FINA_NEG_X_CAL_MAG_X, - FINA_NEG_X_CAL_MAG_Y, - FINA_NEG_X_CAL_MAG_Z, - FINA_NEG_X_COIL_X_CURRENT, - FINA_NEG_X_COIL_Y_CURRENT, - FINA_NEG_X_COIL_Z_CURRENT, - FINA_NEG_X_COIL_X_TEMPERATURE, - FINA_NEG_X_COIL_Y_TEMPERATURE, - FINA_NEG_X_COIL_Z_TEMPERATURE, + FINA_NEG_X_ERR, + FINA_NEG_X_RAW_MAG_X, + FINA_NEG_X_RAW_MAG_Y, + FINA_NEG_X_RAW_MAG_Z, + FINA_NEG_X_CAL_MAG_X, + FINA_NEG_X_CAL_MAG_Y, + FINA_NEG_X_CAL_MAG_Z, + FINA_NEG_X_COIL_X_CURRENT, + FINA_NEG_X_COIL_Y_CURRENT, + FINA_NEG_X_COIL_Z_CURRENT, + FINA_NEG_X_COIL_X_TEMPERATURE, + FINA_NEG_X_COIL_Y_TEMPERATURE, + FINA_NEG_X_COIL_Z_TEMPERATURE, - FINA_POS_Y_ERR, - FINA_POS_Y_RAW_MAG_X, - FINA_POS_Y_RAW_MAG_Y, - FINA_POS_Y_RAW_MAG_Z, - FINA_POS_Y_CAL_MAG_X, - FINA_POS_Y_CAL_MAG_Y, - FINA_POS_Y_CAL_MAG_Z, - FINA_POS_Y_COIL_X_CURRENT, - FINA_POS_Y_COIL_Y_CURRENT, - FINA_POS_Y_COIL_Z_CURRENT, - FINA_POS_Y_COIL_X_TEMPERATURE, - FINA_POS_Y_COIL_Y_TEMPERATURE, - FINA_POS_Y_COIL_Z_TEMPERATURE, + FINA_POS_Y_ERR, + FINA_POS_Y_RAW_MAG_X, + FINA_POS_Y_RAW_MAG_Y, + FINA_POS_Y_RAW_MAG_Z, + FINA_POS_Y_CAL_MAG_X, + FINA_POS_Y_CAL_MAG_Y, + FINA_POS_Y_CAL_MAG_Z, + FINA_POS_Y_COIL_X_CURRENT, + FINA_POS_Y_COIL_Y_CURRENT, + FINA_POS_Y_COIL_Z_CURRENT, + FINA_POS_Y_COIL_X_TEMPERATURE, + FINA_POS_Y_COIL_Y_TEMPERATURE, + FINA_POS_Y_COIL_Z_TEMPERATURE, - FINA_NEG_Y_ERR, - FINA_NEG_Y_RAW_MAG_X, - FINA_NEG_Y_RAW_MAG_Y, - FINA_NEG_Y_RAW_MAG_Z, - FINA_NEG_Y_CAL_MAG_X, - FINA_NEG_Y_CAL_MAG_Y, - FINA_NEG_Y_CAL_MAG_Z, - FINA_NEG_Y_COIL_X_CURRENT, - FINA_NEG_Y_COIL_Y_CURRENT, - FINA_NEG_Y_COIL_Z_CURRENT, - FINA_NEG_Y_COIL_X_TEMPERATURE, - FINA_NEG_Y_COIL_Y_TEMPERATURE, - FINA_NEG_Y_COIL_Z_TEMPERATURE, + FINA_NEG_Y_ERR, + FINA_NEG_Y_RAW_MAG_X, + FINA_NEG_Y_RAW_MAG_Y, + FINA_NEG_Y_RAW_MAG_Z, + FINA_NEG_Y_CAL_MAG_X, + FINA_NEG_Y_CAL_MAG_Y, + FINA_NEG_Y_CAL_MAG_Z, + FINA_NEG_Y_COIL_X_CURRENT, + FINA_NEG_Y_COIL_Y_CURRENT, + FINA_NEG_Y_COIL_Z_CURRENT, + FINA_NEG_Y_COIL_X_TEMPERATURE, + FINA_NEG_Y_COIL_Y_TEMPERATURE, + FINA_NEG_Y_COIL_Z_TEMPERATURE, - FINA_POS_Z_ERR, - FINA_POS_Z_RAW_MAG_X, - FINA_POS_Z_RAW_MAG_Y, - FINA_POS_Z_RAW_MAG_Z, - FINA_POS_Z_CAL_MAG_X, - FINA_POS_Z_CAL_MAG_Y, - FINA_POS_Z_CAL_MAG_Z, - FINA_POS_Z_COIL_X_CURRENT, - FINA_POS_Z_COIL_Y_CURRENT, - FINA_POS_Z_COIL_Z_CURRENT, - FINA_POS_Z_COIL_X_TEMPERATURE, - FINA_POS_Z_COIL_Y_TEMPERATURE, - FINA_POS_Z_COIL_Z_TEMPERATURE, + FINA_POS_Z_ERR, + FINA_POS_Z_RAW_MAG_X, + FINA_POS_Z_RAW_MAG_Y, + FINA_POS_Z_RAW_MAG_Z, + FINA_POS_Z_CAL_MAG_X, + FINA_POS_Z_CAL_MAG_Y, + FINA_POS_Z_CAL_MAG_Z, + FINA_POS_Z_COIL_X_CURRENT, + FINA_POS_Z_COIL_Y_CURRENT, + FINA_POS_Z_COIL_Z_CURRENT, + FINA_POS_Z_COIL_X_TEMPERATURE, + FINA_POS_Z_COIL_Y_TEMPERATURE, + FINA_POS_Z_COIL_Z_TEMPERATURE, - FINA_NEG_Z_ERR, - FINA_NEG_Z_RAW_MAG_X, - FINA_NEG_Z_RAW_MAG_Y, - FINA_NEG_Z_RAW_MAG_Z, - FINA_NEG_Z_CAL_MAG_X, - FINA_NEG_Z_CAL_MAG_Y, - FINA_NEG_Z_CAL_MAG_Z, - FINA_NEG_Z_COIL_X_CURRENT, - FINA_NEG_Z_COIL_Y_CURRENT, - FINA_NEG_Z_COIL_Z_CURRENT, - FINA_NEG_Z_COIL_X_TEMPERATURE, - FINA_NEG_Z_COIL_Y_TEMPERATURE, - FINA_NEG_Z_COIL_Z_TEMPERATURE, - }; + FINA_NEG_Z_ERR, + FINA_NEG_Z_RAW_MAG_X, + FINA_NEG_Z_RAW_MAG_Y, + FINA_NEG_Z_RAW_MAG_Z, + FINA_NEG_Z_CAL_MAG_X, + FINA_NEG_Z_CAL_MAG_Y, + FINA_NEG_Z_CAL_MAG_Z, + FINA_NEG_Z_COIL_X_CURRENT, + FINA_NEG_Z_COIL_Y_CURRENT, + FINA_NEG_Z_COIL_Z_CURRENT, + FINA_NEG_Z_COIL_X_TEMPERATURE, + FINA_NEG_Z_COIL_Y_TEMPERATURE, + FINA_NEG_Z_COIL_Z_TEMPERATURE, +}; -class EngHkDataset: public StaticLocalDataSet { -public: +class EngHkDataset : public StaticLocalDataSet { + public: + EngHkDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, ENG_HK_DATA_SET_ID) {} - EngHkDataset(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, ENG_HK_DATA_SET_ID) { - } + EngHkDataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, ENG_HK_DATA_SET_ID)) {} - EngHkDataset(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, ENG_HK_DATA_SET_ID)) { - } - - lp_var_t digitalVoltageMv = lp_var_t(sid.objectId, DIGITAL_VOLTAGE_MV, - this); - lp_var_t analogVoltageMv = lp_var_t(sid.objectId, ANALOG_VOLTAGE_MV, this); - lp_var_t digitalCurrentmA = lp_var_t(sid.objectId, DIGITAL_CURRENT, this); - lp_var_t analogCurrentmA = lp_var_t(sid.objectId, ANALOG_CURRENT, this); - lp_var_t coilXCurrentmA = lp_var_t(sid.objectId, COIL_X_CURRENT, this); - lp_var_t coilYCurrentmA = lp_var_t(sid.objectId, COIL_Y_CURRENT, this); - lp_var_t coilZCurrentmA = lp_var_t(sid.objectId, COIL_Z_CURRENT, this); - /** All temperatures in [°C] */ - lp_var_t coilXTemperature = lp_var_t(sid.objectId, COIL_X_TEMPERATURE, - this); - lp_var_t coilYTemperature = lp_var_t(sid.objectId, COIL_Y_TEMPERATURE, - this); - lp_var_t coilZTemperature = lp_var_t(sid.objectId, COIL_Z_TEMPERATURE, - this); - lp_var_t mcuTemperature = lp_var_t(sid.objectId, MCU_TEMPERATURE, this); + lp_var_t digitalVoltageMv = lp_var_t(sid.objectId, DIGITAL_VOLTAGE_MV, this); + lp_var_t analogVoltageMv = lp_var_t(sid.objectId, ANALOG_VOLTAGE_MV, this); + lp_var_t digitalCurrentmA = lp_var_t(sid.objectId, DIGITAL_CURRENT, this); + lp_var_t analogCurrentmA = lp_var_t(sid.objectId, ANALOG_CURRENT, this); + lp_var_t coilXCurrentmA = lp_var_t(sid.objectId, COIL_X_CURRENT, this); + lp_var_t coilYCurrentmA = lp_var_t(sid.objectId, COIL_Y_CURRENT, this); + lp_var_t coilZCurrentmA = lp_var_t(sid.objectId, COIL_Z_CURRENT, this); + /** All temperatures in [°C] */ + lp_var_t coilXTemperature = lp_var_t(sid.objectId, COIL_X_TEMPERATURE, this); + lp_var_t coilYTemperature = lp_var_t(sid.objectId, COIL_Y_TEMPERATURE, this); + lp_var_t coilZTemperature = lp_var_t(sid.objectId, COIL_Z_TEMPERATURE, this); + lp_var_t mcuTemperature = lp_var_t(sid.objectId, MCU_TEMPERATURE, this); }; /** * @brief This dataset holds the last calibrated MTM measurement. */ -class CalibratedMtmMeasurementSet: public StaticLocalDataSet { -public: +class CalibratedMtmMeasurementSet : public StaticLocalDataSet { + public: + CalibratedMtmMeasurementSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, CAL_MTM_SET) {} - CalibratedMtmMeasurementSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, CAL_MTM_SET) { - } + CalibratedMtmMeasurementSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, CAL_MTM_SET)) {} - CalibratedMtmMeasurementSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, CAL_MTM_SET)) { - } - - /** The unit of all measurements is nT */ - lp_var_t mtmXnT = lp_var_t(sid.objectId, MTM_CAL_X, this); - lp_var_t mtmYnT = lp_var_t(sid.objectId, MTM_CAL_Y, this); - lp_var_t mtmZnT = lp_var_t(sid.objectId, MTM_CAL_Z, this); - /** 1 if coils were actuating during measurement otherwise 0 */ - lp_var_t coilActuationStatus = lp_var_t(sid.objectId, ACTUATION_CAL_STATUS, - this); + /** The unit of all measurements is nT */ + lp_var_t mtmXnT = lp_var_t(sid.objectId, MTM_CAL_X, this); + lp_var_t mtmYnT = lp_var_t(sid.objectId, MTM_CAL_Y, this); + lp_var_t mtmZnT = lp_var_t(sid.objectId, MTM_CAL_Z, this); + /** 1 if coils were actuating during measurement otherwise 0 */ + lp_var_t coilActuationStatus = + lp_var_t(sid.objectId, ACTUATION_CAL_STATUS, this); }; /** * @brief This dataset holds the raw MTM measurements. */ -class RawMtmMeasurementSet: public StaticLocalDataSet { -public: +class RawMtmMeasurementSet : public StaticLocalDataSet { + public: + RawMtmMeasurementSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, RAW_MTM_SET) {} - RawMtmMeasurementSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, RAW_MTM_SET) { - } + RawMtmMeasurementSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, RAW_MTM_SET)) {} - RawMtmMeasurementSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, RAW_MTM_SET)) { - } - - /** The unit of all measurements is nT */ - lp_var_t mtmXnT = lp_var_t(sid.objectId, MTM_RAW_X, this); - lp_var_t mtmYnT = lp_var_t(sid.objectId, MTM_RAW_Y, this); - lp_var_t mtmZnT = lp_var_t(sid.objectId, MTM_RAW_Z, this); - /** 1 if coils were actuating during measurement otherwise 0 */ - lp_var_t coilActuationStatus = lp_var_t(sid.objectId, ACTUATION_RAW_STATUS, - this); + /** The unit of all measurements is nT */ + lp_var_t mtmXnT = lp_var_t(sid.objectId, MTM_RAW_X, this); + lp_var_t mtmYnT = lp_var_t(sid.objectId, MTM_RAW_Y, this); + lp_var_t mtmZnT = lp_var_t(sid.objectId, MTM_RAW_Z, this); + /** 1 if coils were actuating during measurement otherwise 0 */ + lp_var_t coilActuationStatus = + lp_var_t(sid.objectId, ACTUATION_RAW_STATUS, this); }; - /** * @brief This class can be used to ease the generation of an action message commanding the * IMTQHandler to configure the magnettorquer with the desired dipoles. @@ -460,37 +442,32 @@ public: * the ipc store address in the action message. */ class CommandDipolePacket : public SerialLinkedListAdapter { -public: + public: + CommandDipolePacket() { setLinks(); } - CommandDipolePacket() { - setLinks(); - } - -private: - - /** - * @brief Constructor - * - * @param xDipole The dipole of the x coil in 10 ^ -4 * Am^2 - * @param yDipole The dipole of the y coil in 10 ^ -4 * Am^2 - * @param zDipole The dipole of the z coil in 10 ^ -4 * Am^2 - * @param duration The duration in milliseconds the dipole will be generated by the coils. - * When set to 0, the dipole will be generated until a new dipole actuation - * command is sent. - */ - CommandDipolePacket(uint16_t xDipole, uint16_t yDipole, uint16_t zDipole, uint16_t duration) : - xDipole(xDipole), yDipole(yDipole), zDipole(zDipole), duration(duration) { - } - void setLinks() { - setStart(&xDipole); - xDipole.setNext(&yDipole); - yDipole.setNext(&zDipole); - zDipole.setNext(&duration); - } - SerializeElement xDipole; - SerializeElement yDipole; - SerializeElement zDipole; - SerializeElement duration; + private: + /** + * @brief Constructor + * + * @param xDipole The dipole of the x coil in 10 ^ -4 * Am^2 + * @param yDipole The dipole of the y coil in 10 ^ -4 * Am^2 + * @param zDipole The dipole of the z coil in 10 ^ -4 * Am^2 + * @param duration The duration in milliseconds the dipole will be generated by the coils. + * When set to 0, the dipole will be generated until a new dipole actuation + * command is sent. + */ + CommandDipolePacket(uint16_t xDipole, uint16_t yDipole, uint16_t zDipole, uint16_t duration) + : xDipole(xDipole), yDipole(yDipole), zDipole(zDipole), duration(duration) {} + void setLinks() { + setStart(&xDipole); + xDipole.setNext(&yDipole); + yDipole.setNext(&zDipole); + zDipole.setNext(&duration); + } + SerializeElement xDipole; + SerializeElement yDipole; + SerializeElement zDipole; + SerializeElement duration; }; /** @@ -507,79 +484,67 @@ private: * 2. +X actuation * 3. All coils off (FINA step) */ -class PosXSelfTestSet: public StaticLocalDataSet { -public: +class PosXSelfTestSet : public StaticLocalDataSet { + public: + PosXSelfTestSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, IMTQ::POS_X_TEST_DATASET) {} - PosXSelfTestSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, IMTQ::POS_X_TEST_DATASET) { - } + PosXSelfTestSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, IMTQ::POS_X_TEST_DATASET)) {} - PosXSelfTestSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, IMTQ::POS_X_TEST_DATASET)) { - } + /** INIT block */ + lp_var_t initErr = lp_var_t(sid.objectId, INIT_POS_X_ERR, this); + lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_POS_X_RAW_MAG_X, this); + lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_POS_X_RAW_MAG_Y, this); + lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_POS_X_RAW_MAG_Z, this); + lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_POS_X_CAL_MAG_X, this); + lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_POS_X_CAL_MAG_Y, this); + lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_POS_X_CAL_MAG_Z, this); + lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_POS_X_COIL_X_CURRENT, this); + lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_POS_X_COIL_Y_CURRENT, this); + lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_POS_X_COIL_Z_CURRENT, this); + lp_var_t initCoilXTemperature = + lp_var_t(sid.objectId, INIT_POS_X_COIL_X_TEMPERATURE, this); + lp_var_t initCoilYTemperature = + lp_var_t(sid.objectId, INIT_POS_X_COIL_Y_TEMPERATURE, this); + lp_var_t initCoilZTemperature = + lp_var_t(sid.objectId, INIT_POS_X_COIL_Z_TEMPERATURE, this); - /** INIT block */ - lp_var_t initErr = lp_var_t(sid.objectId, INIT_POS_X_ERR, this); - lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_POS_X_RAW_MAG_X, this); - lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_POS_X_RAW_MAG_Y, this); - lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_POS_X_RAW_MAG_Z, this); - lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_POS_X_CAL_MAG_X, this); - lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_POS_X_CAL_MAG_Y, this); - lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_POS_X_CAL_MAG_Z, this); - lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_POS_X_COIL_X_CURRENT, - this); - lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_POS_X_COIL_Y_CURRENT, - this); - lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_POS_X_COIL_Z_CURRENT, - this); - lp_var_t initCoilXTemperature = lp_var_t(sid.objectId, - INIT_POS_X_COIL_X_TEMPERATURE, this); - lp_var_t initCoilYTemperature = lp_var_t(sid.objectId, - INIT_POS_X_COIL_Y_TEMPERATURE, this); - lp_var_t initCoilZTemperature = lp_var_t(sid.objectId, - INIT_POS_X_COIL_Z_TEMPERATURE, this); + /** +X block */ + lp_var_t err = lp_var_t(sid.objectId, POS_X_ERR, this); + lp_var_t rawMagX = lp_var_t(sid.objectId, POS_X_RAW_MAG_X, this); + lp_var_t rawMagY = lp_var_t(sid.objectId, POS_X_RAW_MAG_Y, this); + lp_var_t rawMagZ = lp_var_t(sid.objectId, POS_X_RAW_MAG_Z, this); + lp_var_t calMagX = lp_var_t(sid.objectId, POS_X_CAL_MAG_X, this); + lp_var_t calMagY = lp_var_t(sid.objectId, POS_X_CAL_MAG_Y, this); + lp_var_t calMagZ = lp_var_t(sid.objectId, POS_X_CAL_MAG_Z, this); + lp_var_t coilXCurrent = lp_var_t(sid.objectId, POS_X_COIL_X_CURRENT, this); + lp_var_t coilYCurrent = lp_var_t(sid.objectId, POS_X_COIL_Y_CURRENT, this); + lp_var_t coilZCurrent = lp_var_t(sid.objectId, POS_X_COIL_Z_CURRENT, this); + lp_var_t coilXTemperature = + lp_var_t(sid.objectId, POS_X_COIL_X_TEMPERATURE, this); + lp_var_t coilYTemperature = + lp_var_t(sid.objectId, POS_X_COIL_Y_TEMPERATURE, this); + lp_var_t coilZTemperature = + lp_var_t(sid.objectId, POS_X_COIL_Z_TEMPERATURE, this); - /** +X block */ - lp_var_t err = lp_var_t(sid.objectId, POS_X_ERR, this); - lp_var_t rawMagX = lp_var_t(sid.objectId, POS_X_RAW_MAG_X, this); - lp_var_t rawMagY = lp_var_t(sid.objectId, POS_X_RAW_MAG_Y, this); - lp_var_t rawMagZ = lp_var_t(sid.objectId, POS_X_RAW_MAG_Z, this); - lp_var_t calMagX = lp_var_t(sid.objectId, POS_X_CAL_MAG_X, this); - lp_var_t calMagY = lp_var_t(sid.objectId, POS_X_CAL_MAG_Y, this); - lp_var_t calMagZ = lp_var_t(sid.objectId, POS_X_CAL_MAG_Z, this); - lp_var_t coilXCurrent = lp_var_t(sid.objectId, POS_X_COIL_X_CURRENT, - this); - lp_var_t coilYCurrent = lp_var_t(sid.objectId, POS_X_COIL_Y_CURRENT, - this); - lp_var_t coilZCurrent = lp_var_t(sid.objectId, POS_X_COIL_Z_CURRENT, - this); - lp_var_t coilXTemperature = lp_var_t(sid.objectId, - POS_X_COIL_X_TEMPERATURE, this); - lp_var_t coilYTemperature = lp_var_t(sid.objectId, - POS_X_COIL_Y_TEMPERATURE, this); - lp_var_t coilZTemperature = lp_var_t(sid.objectId, - POS_X_COIL_Z_TEMPERATURE, this); - - /** FINA block */ - lp_var_t finaErr = lp_var_t(sid.objectId, FINA_POS_X_ERR, this); - lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_POS_X_RAW_MAG_X, this); - lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_POS_X_RAW_MAG_Y, this); - lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_POS_X_RAW_MAG_Z, this); - lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_POS_X_CAL_MAG_X, this); - lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_POS_X_CAL_MAG_Y, this); - lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_POS_X_CAL_MAG_Z, this); - lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_POS_X_COIL_X_CURRENT, - this); - lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_POS_X_COIL_Y_CURRENT, - this); - lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_POS_X_COIL_Z_CURRENT, - this); - lp_var_t finaCoilXTemperature = lp_var_t(sid.objectId, - FINA_POS_X_COIL_X_TEMPERATURE, this); - lp_var_t finaCoilYTemperature = lp_var_t(sid.objectId, - FINA_POS_X_COIL_Y_TEMPERATURE, this); - lp_var_t finaCoilZTemperature = lp_var_t(sid.objectId, - FINA_POS_X_COIL_Z_TEMPERATURE, this); + /** FINA block */ + lp_var_t finaErr = lp_var_t(sid.objectId, FINA_POS_X_ERR, this); + lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_POS_X_RAW_MAG_X, this); + lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_POS_X_RAW_MAG_Y, this); + lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_POS_X_RAW_MAG_Z, this); + lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_POS_X_CAL_MAG_X, this); + lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_POS_X_CAL_MAG_Y, this); + lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_POS_X_CAL_MAG_Z, this); + lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_POS_X_COIL_X_CURRENT, this); + lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_POS_X_COIL_Y_CURRENT, this); + lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_POS_X_COIL_Z_CURRENT, this); + lp_var_t finaCoilXTemperature = + lp_var_t(sid.objectId, FINA_POS_X_COIL_X_TEMPERATURE, this); + lp_var_t finaCoilYTemperature = + lp_var_t(sid.objectId, FINA_POS_X_COIL_Y_TEMPERATURE, this); + lp_var_t finaCoilZTemperature = + lp_var_t(sid.objectId, FINA_POS_X_COIL_Z_TEMPERATURE, this); }; /** @@ -596,82 +561,69 @@ public: * 2. -X actuation * 3. All coils off (FINA step) */ -class NegXSelfTestSet: public StaticLocalDataSet { -public: +class NegXSelfTestSet : public StaticLocalDataSet { + public: + NegXSelfTestSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, IMTQ::NEG_X_TEST_DATASET) {} - NegXSelfTestSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, IMTQ::NEG_X_TEST_DATASET) { - } + NegXSelfTestSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, IMTQ::NEG_X_TEST_DATASET)) {} - NegXSelfTestSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, IMTQ::NEG_X_TEST_DATASET)) { - } + /** INIT block */ + lp_var_t initErr = lp_var_t(sid.objectId, INIT_NEG_X_ERR, this); + lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_NEG_X_RAW_MAG_X, this); + lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_NEG_X_RAW_MAG_Y, this); + lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_NEG_X_RAW_MAG_Z, this); + lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_NEG_X_CAL_MAG_X, this); + lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_NEG_X_CAL_MAG_Y, this); + lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_NEG_X_CAL_MAG_Z, this); + lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_NEG_X_COIL_X_CURRENT, this); + lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_NEG_X_COIL_Y_CURRENT, this); + lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_NEG_X_COIL_Z_CURRENT, this); + lp_var_t initCoilXTemperature = + lp_var_t(sid.objectId, INIT_NEG_X_COIL_X_TEMPERATURE, this); + lp_var_t initCoilYTemperature = + lp_var_t(sid.objectId, INIT_NEG_X_COIL_Y_TEMPERATURE, this); + lp_var_t initCoilZTemperature = + lp_var_t(sid.objectId, INIT_NEG_X_COIL_Z_TEMPERATURE, this); - /** INIT block */ - lp_var_t initErr = lp_var_t(sid.objectId, INIT_NEG_X_ERR, this); - lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_NEG_X_RAW_MAG_X, this); - lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_NEG_X_RAW_MAG_Y, this); - lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_NEG_X_RAW_MAG_Z, this); - lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_NEG_X_CAL_MAG_X, this); - lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_NEG_X_CAL_MAG_Y, this); - lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_NEG_X_CAL_MAG_Z, this); - lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_NEG_X_COIL_X_CURRENT, - this); - lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_NEG_X_COIL_Y_CURRENT, - this); - lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_NEG_X_COIL_Z_CURRENT, - this); - lp_var_t initCoilXTemperature = lp_var_t(sid.objectId, - INIT_NEG_X_COIL_X_TEMPERATURE, this); - lp_var_t initCoilYTemperature = lp_var_t(sid.objectId, - INIT_NEG_X_COIL_Y_TEMPERATURE, this); - lp_var_t initCoilZTemperature = lp_var_t(sid.objectId, - INIT_NEG_X_COIL_Z_TEMPERATURE, this); + /** -X block */ + lp_var_t err = lp_var_t(sid.objectId, NEG_X_ERR, this); + lp_var_t rawMagX = lp_var_t(sid.objectId, NEG_X_RAW_MAG_X, this); + lp_var_t rawMagY = lp_var_t(sid.objectId, NEG_X_RAW_MAG_Y, this); + lp_var_t rawMagZ = lp_var_t(sid.objectId, NEG_X_RAW_MAG_Z, this); + lp_var_t calMagX = lp_var_t(sid.objectId, NEG_X_CAL_MAG_X, this); + lp_var_t calMagY = lp_var_t(sid.objectId, NEG_X_CAL_MAG_Y, this); + lp_var_t calMagZ = lp_var_t(sid.objectId, NEG_X_CAL_MAG_Z, this); + lp_var_t coilXCurrent = lp_var_t(sid.objectId, NEG_X_COIL_X_CURRENT, this); + lp_var_t coilYCurrent = lp_var_t(sid.objectId, NEG_X_COIL_Y_CURRENT, this); + lp_var_t coilZCurrent = lp_var_t(sid.objectId, NEG_X_COIL_Z_CURRENT, this); + lp_var_t coilXTemperature = + lp_var_t(sid.objectId, NEG_X_COIL_X_TEMPERATURE, this); + lp_var_t coilYTemperature = + lp_var_t(sid.objectId, NEG_X_COIL_Y_TEMPERATURE, this); + lp_var_t coilZTemperature = + lp_var_t(sid.objectId, NEG_X_COIL_Z_TEMPERATURE, this); - /** -X block */ - lp_var_t err = lp_var_t(sid.objectId, NEG_X_ERR, this); - lp_var_t rawMagX = lp_var_t(sid.objectId, NEG_X_RAW_MAG_X, this); - lp_var_t rawMagY = lp_var_t(sid.objectId, NEG_X_RAW_MAG_Y, this); - lp_var_t rawMagZ = lp_var_t(sid.objectId, NEG_X_RAW_MAG_Z, this); - lp_var_t calMagX = lp_var_t(sid.objectId, NEG_X_CAL_MAG_X, this); - lp_var_t calMagY = lp_var_t(sid.objectId, NEG_X_CAL_MAG_Y, this); - lp_var_t calMagZ = lp_var_t(sid.objectId, NEG_X_CAL_MAG_Z, this); - lp_var_t coilXCurrent = lp_var_t(sid.objectId, NEG_X_COIL_X_CURRENT, - this); - lp_var_t coilYCurrent = lp_var_t(sid.objectId, NEG_X_COIL_Y_CURRENT, - this); - lp_var_t coilZCurrent = lp_var_t(sid.objectId, NEG_X_COIL_Z_CURRENT, - this); - lp_var_t coilXTemperature = lp_var_t(sid.objectId, - NEG_X_COIL_X_TEMPERATURE, this); - lp_var_t coilYTemperature = lp_var_t(sid.objectId, - NEG_X_COIL_Y_TEMPERATURE, this); - lp_var_t coilZTemperature = lp_var_t(sid.objectId, - NEG_X_COIL_Z_TEMPERATURE, this); - - /** FINA block */ - lp_var_t finaErr = lp_var_t(sid.objectId, FINA_NEG_X_ERR, this); - lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_NEG_X_RAW_MAG_X, this); - lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_NEG_X_RAW_MAG_Y, this); - lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_NEG_X_RAW_MAG_Z, this); - lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_NEG_X_CAL_MAG_X, this); - lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_NEG_X_CAL_MAG_Y, this); - lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_NEG_X_CAL_MAG_Z, this); - lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_NEG_X_COIL_X_CURRENT, - this); - lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_NEG_X_COIL_Y_CURRENT, - this); - lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_NEG_X_COIL_Z_CURRENT, - this); - lp_var_t finaCoilXTemperature = lp_var_t(sid.objectId, - FINA_NEG_X_COIL_X_TEMPERATURE, this); - lp_var_t finaCoilYTemperature = lp_var_t(sid.objectId, - FINA_NEG_X_COIL_Y_TEMPERATURE, this); - lp_var_t finaCoilZTemperature = lp_var_t(sid.objectId, - FINA_NEG_X_COIL_Z_TEMPERATURE, this); + /** FINA block */ + lp_var_t finaErr = lp_var_t(sid.objectId, FINA_NEG_X_ERR, this); + lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_NEG_X_RAW_MAG_X, this); + lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_NEG_X_RAW_MAG_Y, this); + lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_NEG_X_RAW_MAG_Z, this); + lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_NEG_X_CAL_MAG_X, this); + lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_NEG_X_CAL_MAG_Y, this); + lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_NEG_X_CAL_MAG_Z, this); + lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_NEG_X_COIL_X_CURRENT, this); + lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_NEG_X_COIL_Y_CURRENT, this); + lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_NEG_X_COIL_Z_CURRENT, this); + lp_var_t finaCoilXTemperature = + lp_var_t(sid.objectId, FINA_NEG_X_COIL_X_TEMPERATURE, this); + lp_var_t finaCoilYTemperature = + lp_var_t(sid.objectId, FINA_NEG_X_COIL_Y_TEMPERATURE, this); + lp_var_t finaCoilZTemperature = + lp_var_t(sid.objectId, FINA_NEG_X_COIL_Z_TEMPERATURE, this); }; - /** * @brief This dataset can be used to store the self test results of the +Y self test. * @@ -686,79 +638,67 @@ public: * 2. +Y actuation * 3. All coils off (FINA step) */ -class PosYSelfTestSet: public StaticLocalDataSet { -public: +class PosYSelfTestSet : public StaticLocalDataSet { + public: + PosYSelfTestSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, IMTQ::POS_Y_TEST_DATASET) {} - PosYSelfTestSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, IMTQ::POS_Y_TEST_DATASET) { - } + PosYSelfTestSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, IMTQ::POS_Y_TEST_DATASET)) {} - PosYSelfTestSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, IMTQ::POS_Y_TEST_DATASET)) { - } + /** INIT block */ + lp_var_t initErr = lp_var_t(sid.objectId, INIT_POS_Y_ERR, this); + lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_POS_Y_RAW_MAG_X, this); + lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_POS_Y_RAW_MAG_Y, this); + lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_POS_Y_RAW_MAG_Z, this); + lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_POS_Y_CAL_MAG_X, this); + lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_POS_Y_CAL_MAG_Y, this); + lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_POS_Y_CAL_MAG_Z, this); + lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_POS_Y_COIL_X_CURRENT, this); + lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_POS_Y_COIL_Y_CURRENT, this); + lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_POS_Y_COIL_Z_CURRENT, this); + lp_var_t initCoilXTemperature = + lp_var_t(sid.objectId, INIT_POS_Y_COIL_X_TEMPERATURE, this); + lp_var_t initCoilYTemperature = + lp_var_t(sid.objectId, INIT_POS_Y_COIL_Y_TEMPERATURE, this); + lp_var_t initCoilZTemperature = + lp_var_t(sid.objectId, INIT_POS_Y_COIL_Z_TEMPERATURE, this); - /** INIT block */ - lp_var_t initErr = lp_var_t(sid.objectId, INIT_POS_Y_ERR, this); - lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_POS_Y_RAW_MAG_X, this); - lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_POS_Y_RAW_MAG_Y, this); - lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_POS_Y_RAW_MAG_Z, this); - lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_POS_Y_CAL_MAG_X, this); - lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_POS_Y_CAL_MAG_Y, this); - lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_POS_Y_CAL_MAG_Z, this); - lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_POS_Y_COIL_X_CURRENT, - this); - lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_POS_Y_COIL_Y_CURRENT, - this); - lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_POS_Y_COIL_Z_CURRENT, - this); - lp_var_t initCoilXTemperature = lp_var_t(sid.objectId, - INIT_POS_Y_COIL_X_TEMPERATURE, this); - lp_var_t initCoilYTemperature = lp_var_t(sid.objectId, - INIT_POS_Y_COIL_Y_TEMPERATURE, this); - lp_var_t initCoilZTemperature = lp_var_t(sid.objectId, - INIT_POS_Y_COIL_Z_TEMPERATURE, this); + /** +Y block */ + lp_var_t err = lp_var_t(sid.objectId, POS_Y_ERR, this); + lp_var_t rawMagX = lp_var_t(sid.objectId, POS_Y_RAW_MAG_X, this); + lp_var_t rawMagY = lp_var_t(sid.objectId, POS_Y_RAW_MAG_Y, this); + lp_var_t rawMagZ = lp_var_t(sid.objectId, POS_Y_RAW_MAG_Z, this); + lp_var_t calMagX = lp_var_t(sid.objectId, POS_Y_CAL_MAG_X, this); + lp_var_t calMagY = lp_var_t(sid.objectId, POS_Y_CAL_MAG_Y, this); + lp_var_t calMagZ = lp_var_t(sid.objectId, POS_Y_CAL_MAG_Z, this); + lp_var_t coilXCurrent = lp_var_t(sid.objectId, POS_Y_COIL_X_CURRENT, this); + lp_var_t coilYCurrent = lp_var_t(sid.objectId, POS_Y_COIL_Y_CURRENT, this); + lp_var_t coilZCurrent = lp_var_t(sid.objectId, POS_Y_COIL_Z_CURRENT, this); + lp_var_t coilXTemperature = + lp_var_t(sid.objectId, POS_Y_COIL_X_TEMPERATURE, this); + lp_var_t coilYTemperature = + lp_var_t(sid.objectId, POS_Y_COIL_Y_TEMPERATURE, this); + lp_var_t coilZTemperature = + lp_var_t(sid.objectId, POS_Y_COIL_Z_TEMPERATURE, this); - /** +Y block */ - lp_var_t err = lp_var_t(sid.objectId, POS_Y_ERR, this); - lp_var_t rawMagX = lp_var_t(sid.objectId, POS_Y_RAW_MAG_X, this); - lp_var_t rawMagY = lp_var_t(sid.objectId, POS_Y_RAW_MAG_Y, this); - lp_var_t rawMagZ = lp_var_t(sid.objectId, POS_Y_RAW_MAG_Z, this); - lp_var_t calMagX = lp_var_t(sid.objectId, POS_Y_CAL_MAG_X, this); - lp_var_t calMagY = lp_var_t(sid.objectId, POS_Y_CAL_MAG_Y, this); - lp_var_t calMagZ = lp_var_t(sid.objectId, POS_Y_CAL_MAG_Z, this); - lp_var_t coilXCurrent = lp_var_t(sid.objectId, POS_Y_COIL_X_CURRENT, - this); - lp_var_t coilYCurrent = lp_var_t(sid.objectId, POS_Y_COIL_Y_CURRENT, - this); - lp_var_t coilZCurrent = lp_var_t(sid.objectId, POS_Y_COIL_Z_CURRENT, - this); - lp_var_t coilXTemperature = lp_var_t(sid.objectId, - POS_Y_COIL_X_TEMPERATURE, this); - lp_var_t coilYTemperature = lp_var_t(sid.objectId, - POS_Y_COIL_Y_TEMPERATURE, this); - lp_var_t coilZTemperature = lp_var_t(sid.objectId, - POS_Y_COIL_Z_TEMPERATURE, this); - - /** FINA block */ - lp_var_t finaErr = lp_var_t(sid.objectId, FINA_POS_Y_ERR, this); - lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_POS_Y_RAW_MAG_X, this); - lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_POS_Y_RAW_MAG_Y, this); - lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_POS_Y_RAW_MAG_Z, this); - lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_POS_Y_CAL_MAG_X, this); - lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_POS_Y_CAL_MAG_Y, this); - lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_POS_Y_CAL_MAG_Z, this); - lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_POS_Y_COIL_X_CURRENT, - this); - lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_POS_Y_COIL_Y_CURRENT, - this); - lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_POS_Y_COIL_Z_CURRENT, - this); - lp_var_t finaCoilXTemperature = lp_var_t(sid.objectId, - FINA_POS_Y_COIL_X_TEMPERATURE, this); - lp_var_t finaCoilYTemperature = lp_var_t(sid.objectId, - FINA_POS_Y_COIL_Y_TEMPERATURE, this); - lp_var_t finaCoilZTemperature = lp_var_t(sid.objectId, - FINA_POS_Y_COIL_Z_TEMPERATURE, this); + /** FINA block */ + lp_var_t finaErr = lp_var_t(sid.objectId, FINA_POS_Y_ERR, this); + lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_POS_Y_RAW_MAG_X, this); + lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_POS_Y_RAW_MAG_Y, this); + lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_POS_Y_RAW_MAG_Z, this); + lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_POS_Y_CAL_MAG_X, this); + lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_POS_Y_CAL_MAG_Y, this); + lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_POS_Y_CAL_MAG_Z, this); + lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_POS_Y_COIL_X_CURRENT, this); + lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_POS_Y_COIL_Y_CURRENT, this); + lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_POS_Y_COIL_Z_CURRENT, this); + lp_var_t finaCoilXTemperature = + lp_var_t(sid.objectId, FINA_POS_Y_COIL_X_TEMPERATURE, this); + lp_var_t finaCoilYTemperature = + lp_var_t(sid.objectId, FINA_POS_Y_COIL_Y_TEMPERATURE, this); + lp_var_t finaCoilZTemperature = + lp_var_t(sid.objectId, FINA_POS_Y_COIL_Z_TEMPERATURE, this); }; /** @@ -775,79 +715,67 @@ public: * 2. -Y actuation * 3. All coils off (FINA step) */ -class NegYSelfTestSet: public StaticLocalDataSet { -public: +class NegYSelfTestSet : public StaticLocalDataSet { + public: + NegYSelfTestSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, IMTQ::NEG_Y_TEST_DATASET) {} - NegYSelfTestSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, IMTQ::NEG_Y_TEST_DATASET) { - } + NegYSelfTestSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, IMTQ::NEG_Y_TEST_DATASET)) {} - NegYSelfTestSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, IMTQ::NEG_Y_TEST_DATASET)) { - } + /** INIT block */ + lp_var_t initErr = lp_var_t(sid.objectId, INIT_NEG_Y_ERR, this); + lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_NEG_Y_RAW_MAG_X, this); + lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_NEG_Y_RAW_MAG_Y, this); + lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_NEG_Y_RAW_MAG_Z, this); + lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_NEG_Y_CAL_MAG_X, this); + lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_NEG_Y_CAL_MAG_Y, this); + lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_NEG_Y_CAL_MAG_Z, this); + lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_NEG_Y_COIL_X_CURRENT, this); + lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_NEG_Y_COIL_Y_CURRENT, this); + lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_NEG_Y_COIL_Z_CURRENT, this); + lp_var_t initCoilXTemperature = + lp_var_t(sid.objectId, INIT_NEG_Y_COIL_X_TEMPERATURE, this); + lp_var_t initCoilYTemperature = + lp_var_t(sid.objectId, INIT_NEG_Y_COIL_Y_TEMPERATURE, this); + lp_var_t initCoilZTemperature = + lp_var_t(sid.objectId, INIT_NEG_Y_COIL_Z_TEMPERATURE, this); - /** INIT block */ - lp_var_t initErr = lp_var_t(sid.objectId, INIT_NEG_Y_ERR, this); - lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_NEG_Y_RAW_MAG_X, this); - lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_NEG_Y_RAW_MAG_Y, this); - lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_NEG_Y_RAW_MAG_Z, this); - lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_NEG_Y_CAL_MAG_X, this); - lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_NEG_Y_CAL_MAG_Y, this); - lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_NEG_Y_CAL_MAG_Z, this); - lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_NEG_Y_COIL_X_CURRENT, - this); - lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_NEG_Y_COIL_Y_CURRENT, - this); - lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_NEG_Y_COIL_Z_CURRENT, - this); - lp_var_t initCoilXTemperature = lp_var_t(sid.objectId, - INIT_NEG_Y_COIL_X_TEMPERATURE, this); - lp_var_t initCoilYTemperature = lp_var_t(sid.objectId, - INIT_NEG_Y_COIL_Y_TEMPERATURE, this); - lp_var_t initCoilZTemperature = lp_var_t(sid.objectId, - INIT_NEG_Y_COIL_Z_TEMPERATURE, this); + /** -Y block */ + lp_var_t err = lp_var_t(sid.objectId, NEG_Y_ERR, this); + lp_var_t rawMagX = lp_var_t(sid.objectId, NEG_Y_RAW_MAG_X, this); + lp_var_t rawMagY = lp_var_t(sid.objectId, NEG_Y_RAW_MAG_Y, this); + lp_var_t rawMagZ = lp_var_t(sid.objectId, NEG_Y_RAW_MAG_Z, this); + lp_var_t calMagX = lp_var_t(sid.objectId, NEG_Y_CAL_MAG_X, this); + lp_var_t calMagY = lp_var_t(sid.objectId, NEG_Y_CAL_MAG_Y, this); + lp_var_t calMagZ = lp_var_t(sid.objectId, NEG_Y_CAL_MAG_Z, this); + lp_var_t coilXCurrent = lp_var_t(sid.objectId, NEG_Y_COIL_X_CURRENT, this); + lp_var_t coilYCurrent = lp_var_t(sid.objectId, NEG_Y_COIL_Y_CURRENT, this); + lp_var_t coilZCurrent = lp_var_t(sid.objectId, NEG_Y_COIL_Z_CURRENT, this); + lp_var_t coilXTemperature = + lp_var_t(sid.objectId, NEG_Y_COIL_X_TEMPERATURE, this); + lp_var_t coilYTemperature = + lp_var_t(sid.objectId, NEG_Y_COIL_Y_TEMPERATURE, this); + lp_var_t coilZTemperature = + lp_var_t(sid.objectId, NEG_Y_COIL_Z_TEMPERATURE, this); - /** -Y block */ - lp_var_t err = lp_var_t(sid.objectId, NEG_Y_ERR, this); - lp_var_t rawMagX = lp_var_t(sid.objectId, NEG_Y_RAW_MAG_X, this); - lp_var_t rawMagY = lp_var_t(sid.objectId, NEG_Y_RAW_MAG_Y, this); - lp_var_t rawMagZ = lp_var_t(sid.objectId, NEG_Y_RAW_MAG_Z, this); - lp_var_t calMagX = lp_var_t(sid.objectId, NEG_Y_CAL_MAG_X, this); - lp_var_t calMagY = lp_var_t(sid.objectId, NEG_Y_CAL_MAG_Y, this); - lp_var_t calMagZ = lp_var_t(sid.objectId, NEG_Y_CAL_MAG_Z, this); - lp_var_t coilXCurrent = lp_var_t(sid.objectId, NEG_Y_COIL_X_CURRENT, - this); - lp_var_t coilYCurrent = lp_var_t(sid.objectId, NEG_Y_COIL_Y_CURRENT, - this); - lp_var_t coilZCurrent = lp_var_t(sid.objectId, NEG_Y_COIL_Z_CURRENT, - this); - lp_var_t coilXTemperature = lp_var_t(sid.objectId, - NEG_Y_COIL_X_TEMPERATURE, this); - lp_var_t coilYTemperature = lp_var_t(sid.objectId, - NEG_Y_COIL_Y_TEMPERATURE, this); - lp_var_t coilZTemperature = lp_var_t(sid.objectId, - NEG_Y_COIL_Z_TEMPERATURE, this); - - /** FINA block */ - lp_var_t finaErr = lp_var_t(sid.objectId, FINA_NEG_Y_ERR, this); - lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_NEG_Y_RAW_MAG_X, this); - lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_NEG_Y_RAW_MAG_Y, this); - lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_NEG_Y_RAW_MAG_Z, this); - lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_NEG_Y_CAL_MAG_X, this); - lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_NEG_Y_CAL_MAG_Y, this); - lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_NEG_Y_CAL_MAG_Z, this); - lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_NEG_Y_COIL_X_CURRENT, - this); - lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_NEG_Y_COIL_Y_CURRENT, - this); - lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_NEG_Y_COIL_Z_CURRENT, - this); - lp_var_t finaCoilXTemperature = lp_var_t(sid.objectId, - FINA_NEG_Y_COIL_X_TEMPERATURE, this); - lp_var_t finaCoilYTemperature = lp_var_t(sid.objectId, - FINA_NEG_Y_COIL_Y_TEMPERATURE, this); - lp_var_t finaCoilZTemperature = lp_var_t(sid.objectId, - FINA_NEG_Y_COIL_Z_TEMPERATURE, this); + /** FINA block */ + lp_var_t finaErr = lp_var_t(sid.objectId, FINA_NEG_Y_ERR, this); + lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_NEG_Y_RAW_MAG_X, this); + lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_NEG_Y_RAW_MAG_Y, this); + lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_NEG_Y_RAW_MAG_Z, this); + lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_NEG_Y_CAL_MAG_X, this); + lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_NEG_Y_CAL_MAG_Y, this); + lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_NEG_Y_CAL_MAG_Z, this); + lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_NEG_Y_COIL_X_CURRENT, this); + lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_NEG_Y_COIL_Y_CURRENT, this); + lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_NEG_Y_COIL_Z_CURRENT, this); + lp_var_t finaCoilXTemperature = + lp_var_t(sid.objectId, FINA_NEG_Y_COIL_X_TEMPERATURE, this); + lp_var_t finaCoilYTemperature = + lp_var_t(sid.objectId, FINA_NEG_Y_COIL_Y_TEMPERATURE, this); + lp_var_t finaCoilZTemperature = + lp_var_t(sid.objectId, FINA_NEG_Y_COIL_Z_TEMPERATURE, this); }; /** @@ -864,79 +792,67 @@ public: * 2. +Z actuation * 3. All coils off (FINA step) */ -class PosZSelfTestSet: public StaticLocalDataSet { -public: +class PosZSelfTestSet : public StaticLocalDataSet { + public: + PosZSelfTestSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, IMTQ::POS_Z_TEST_DATASET) {} - PosZSelfTestSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, IMTQ::POS_Z_TEST_DATASET) { - } + PosZSelfTestSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, IMTQ::POS_Z_TEST_DATASET)) {} - PosZSelfTestSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, IMTQ::POS_Z_TEST_DATASET)) { - } + /** INIT block */ + lp_var_t initErr = lp_var_t(sid.objectId, INIT_POS_Z_ERR, this); + lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_POS_Z_RAW_MAG_X, this); + lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_POS_Z_RAW_MAG_Y, this); + lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_POS_Z_RAW_MAG_Z, this); + lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_POS_Z_CAL_MAG_X, this); + lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_POS_Z_CAL_MAG_Y, this); + lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_POS_Z_CAL_MAG_Z, this); + lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_POS_Z_COIL_X_CURRENT, this); + lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_POS_Z_COIL_Y_CURRENT, this); + lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_POS_Z_COIL_Z_CURRENT, this); + lp_var_t initCoilXTemperature = + lp_var_t(sid.objectId, INIT_POS_Z_COIL_X_TEMPERATURE, this); + lp_var_t initCoilYTemperature = + lp_var_t(sid.objectId, INIT_POS_Z_COIL_Y_TEMPERATURE, this); + lp_var_t initCoilZTemperature = + lp_var_t(sid.objectId, INIT_POS_Z_COIL_Z_TEMPERATURE, this); - /** INIT block */ - lp_var_t initErr = lp_var_t(sid.objectId, INIT_POS_Z_ERR, this); - lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_POS_Z_RAW_MAG_X, this); - lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_POS_Z_RAW_MAG_Y, this); - lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_POS_Z_RAW_MAG_Z, this); - lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_POS_Z_CAL_MAG_X, this); - lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_POS_Z_CAL_MAG_Y, this); - lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_POS_Z_CAL_MAG_Z, this); - lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_POS_Z_COIL_X_CURRENT, - this); - lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_POS_Z_COIL_Y_CURRENT, - this); - lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_POS_Z_COIL_Z_CURRENT, - this); - lp_var_t initCoilXTemperature = lp_var_t(sid.objectId, - INIT_POS_Z_COIL_X_TEMPERATURE, this); - lp_var_t initCoilYTemperature = lp_var_t(sid.objectId, - INIT_POS_Z_COIL_Y_TEMPERATURE, this); - lp_var_t initCoilZTemperature = lp_var_t(sid.objectId, - INIT_POS_Z_COIL_Z_TEMPERATURE, this); + /** +Z block */ + lp_var_t err = lp_var_t(sid.objectId, POS_Z_ERR, this); + lp_var_t rawMagX = lp_var_t(sid.objectId, POS_Z_RAW_MAG_X, this); + lp_var_t rawMagY = lp_var_t(sid.objectId, POS_Z_RAW_MAG_Y, this); + lp_var_t rawMagZ = lp_var_t(sid.objectId, POS_Z_RAW_MAG_Z, this); + lp_var_t calMagX = lp_var_t(sid.objectId, POS_Z_CAL_MAG_X, this); + lp_var_t calMagY = lp_var_t(sid.objectId, POS_Z_CAL_MAG_Y, this); + lp_var_t calMagZ = lp_var_t(sid.objectId, POS_Z_CAL_MAG_Z, this); + lp_var_t coilXCurrent = lp_var_t(sid.objectId, POS_Z_COIL_X_CURRENT, this); + lp_var_t coilYCurrent = lp_var_t(sid.objectId, POS_Z_COIL_Y_CURRENT, this); + lp_var_t coilZCurrent = lp_var_t(sid.objectId, POS_Z_COIL_Z_CURRENT, this); + lp_var_t coilXTemperature = + lp_var_t(sid.objectId, POS_Z_COIL_X_TEMPERATURE, this); + lp_var_t coilYTemperature = + lp_var_t(sid.objectId, POS_Z_COIL_Y_TEMPERATURE, this); + lp_var_t coilZTemperature = + lp_var_t(sid.objectId, POS_Z_COIL_Z_TEMPERATURE, this); - /** +Z block */ - lp_var_t err = lp_var_t(sid.objectId, POS_Z_ERR, this); - lp_var_t rawMagX = lp_var_t(sid.objectId, POS_Z_RAW_MAG_X, this); - lp_var_t rawMagY = lp_var_t(sid.objectId, POS_Z_RAW_MAG_Y, this); - lp_var_t rawMagZ = lp_var_t(sid.objectId, POS_Z_RAW_MAG_Z, this); - lp_var_t calMagX = lp_var_t(sid.objectId, POS_Z_CAL_MAG_X, this); - lp_var_t calMagY = lp_var_t(sid.objectId, POS_Z_CAL_MAG_Y, this); - lp_var_t calMagZ = lp_var_t(sid.objectId, POS_Z_CAL_MAG_Z, this); - lp_var_t coilXCurrent = lp_var_t(sid.objectId, POS_Z_COIL_X_CURRENT, - this); - lp_var_t coilYCurrent = lp_var_t(sid.objectId, POS_Z_COIL_Y_CURRENT, - this); - lp_var_t coilZCurrent = lp_var_t(sid.objectId, POS_Z_COIL_Z_CURRENT, - this); - lp_var_t coilXTemperature = lp_var_t(sid.objectId, - POS_Z_COIL_X_TEMPERATURE, this); - lp_var_t coilYTemperature = lp_var_t(sid.objectId, - POS_Z_COIL_Y_TEMPERATURE, this); - lp_var_t coilZTemperature = lp_var_t(sid.objectId, - POS_Z_COIL_Z_TEMPERATURE, this); - - /** FINA block */ - lp_var_t finaErr = lp_var_t(sid.objectId, FINA_POS_Z_ERR, this); - lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_POS_Z_RAW_MAG_X, this); - lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_POS_Z_RAW_MAG_Y, this); - lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_POS_Z_RAW_MAG_Z, this); - lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_POS_Z_CAL_MAG_X, this); - lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_POS_Z_CAL_MAG_Y, this); - lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_POS_Z_CAL_MAG_Z, this); - lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_POS_Z_COIL_X_CURRENT, - this); - lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_POS_Z_COIL_Y_CURRENT, - this); - lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_POS_Z_COIL_Z_CURRENT, - this); - lp_var_t finaCoilXTemperature = lp_var_t(sid.objectId, - FINA_POS_Z_COIL_X_TEMPERATURE, this); - lp_var_t finaCoilYTemperature = lp_var_t(sid.objectId, - FINA_POS_Z_COIL_Y_TEMPERATURE, this); - lp_var_t finaCoilZTemperature = lp_var_t(sid.objectId, - FINA_POS_Z_COIL_Z_TEMPERATURE, this); + /** FINA block */ + lp_var_t finaErr = lp_var_t(sid.objectId, FINA_POS_Z_ERR, this); + lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_POS_Z_RAW_MAG_X, this); + lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_POS_Z_RAW_MAG_Y, this); + lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_POS_Z_RAW_MAG_Z, this); + lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_POS_Z_CAL_MAG_X, this); + lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_POS_Z_CAL_MAG_Y, this); + lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_POS_Z_CAL_MAG_Z, this); + lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_POS_Z_COIL_X_CURRENT, this); + lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_POS_Z_COIL_Y_CURRENT, this); + lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_POS_Z_COIL_Z_CURRENT, this); + lp_var_t finaCoilXTemperature = + lp_var_t(sid.objectId, FINA_POS_Z_COIL_X_TEMPERATURE, this); + lp_var_t finaCoilYTemperature = + lp_var_t(sid.objectId, FINA_POS_Z_COIL_Y_TEMPERATURE, this); + lp_var_t finaCoilZTemperature = + lp_var_t(sid.objectId, FINA_POS_Z_COIL_Z_TEMPERATURE, this); }; /** @@ -953,82 +869,69 @@ public: * 2. -Z actuation * 3. All coils off (FINA step) */ -class NegZSelfTestSet: public StaticLocalDataSet { -public: +class NegZSelfTestSet : public StaticLocalDataSet { + public: + NegZSelfTestSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, IMTQ::NEG_Z_TEST_DATASET) {} - NegZSelfTestSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, IMTQ::NEG_Z_TEST_DATASET) { - } + NegZSelfTestSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, IMTQ::NEG_Z_TEST_DATASET)) {} - NegZSelfTestSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, IMTQ::NEG_Z_TEST_DATASET)) { - } + /** INIT block */ + lp_var_t initErr = lp_var_t(sid.objectId, INIT_NEG_Z_ERR, this); + lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_NEG_Z_RAW_MAG_X, this); + lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_NEG_Z_RAW_MAG_Y, this); + lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_NEG_Z_RAW_MAG_Z, this); + lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_NEG_Z_CAL_MAG_X, this); + lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_NEG_Z_CAL_MAG_Y, this); + lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_NEG_Z_CAL_MAG_Z, this); + lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_NEG_Z_COIL_X_CURRENT, this); + lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_NEG_Z_COIL_Y_CURRENT, this); + lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_NEG_Z_COIL_Z_CURRENT, this); + lp_var_t initCoilXTemperature = + lp_var_t(sid.objectId, INIT_NEG_Z_COIL_X_TEMPERATURE, this); + lp_var_t initCoilYTemperature = + lp_var_t(sid.objectId, INIT_NEG_Z_COIL_Y_TEMPERATURE, this); + lp_var_t initCoilZTemperature = + lp_var_t(sid.objectId, INIT_NEG_Z_COIL_Z_TEMPERATURE, this); - /** INIT block */ - lp_var_t initErr = lp_var_t(sid.objectId, INIT_NEG_Z_ERR, this); - lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_NEG_Z_RAW_MAG_X, this); - lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_NEG_Z_RAW_MAG_Y, this); - lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_NEG_Z_RAW_MAG_Z, this); - lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_NEG_Z_CAL_MAG_X, this); - lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_NEG_Z_CAL_MAG_Y, this); - lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_NEG_Z_CAL_MAG_Z, this); - lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_NEG_Z_COIL_X_CURRENT, - this); - lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_NEG_Z_COIL_Y_CURRENT, - this); - lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_NEG_Z_COIL_Z_CURRENT, - this); - lp_var_t initCoilXTemperature = lp_var_t(sid.objectId, - INIT_NEG_Z_COIL_X_TEMPERATURE, this); - lp_var_t initCoilYTemperature = lp_var_t(sid.objectId, - INIT_NEG_Z_COIL_Y_TEMPERATURE, this); - lp_var_t initCoilZTemperature = lp_var_t(sid.objectId, - INIT_NEG_Z_COIL_Z_TEMPERATURE, this); + /** +Z block */ + lp_var_t err = lp_var_t(sid.objectId, NEG_Z_ERR, this); + lp_var_t rawMagX = lp_var_t(sid.objectId, NEG_Z_RAW_MAG_X, this); + lp_var_t rawMagY = lp_var_t(sid.objectId, NEG_Z_RAW_MAG_Y, this); + lp_var_t rawMagZ = lp_var_t(sid.objectId, NEG_Z_RAW_MAG_Z, this); + lp_var_t calMagX = lp_var_t(sid.objectId, NEG_Z_CAL_MAG_X, this); + lp_var_t calMagY = lp_var_t(sid.objectId, NEG_Z_CAL_MAG_Y, this); + lp_var_t calMagZ = lp_var_t(sid.objectId, NEG_Z_CAL_MAG_Z, this); + lp_var_t coilXCurrent = lp_var_t(sid.objectId, NEG_Z_COIL_X_CURRENT, this); + lp_var_t coilYCurrent = lp_var_t(sid.objectId, NEG_Z_COIL_Y_CURRENT, this); + lp_var_t coilZCurrent = lp_var_t(sid.objectId, NEG_Z_COIL_Z_CURRENT, this); + lp_var_t coilXTemperature = + lp_var_t(sid.objectId, NEG_Z_COIL_X_TEMPERATURE, this); + lp_var_t coilYTemperature = + lp_var_t(sid.objectId, NEG_Z_COIL_Y_TEMPERATURE, this); + lp_var_t coilZTemperature = + lp_var_t(sid.objectId, NEG_Z_COIL_Z_TEMPERATURE, this); - /** +Z block */ - lp_var_t err = lp_var_t(sid.objectId, NEG_Z_ERR, this); - lp_var_t rawMagX = lp_var_t(sid.objectId, NEG_Z_RAW_MAG_X, this); - lp_var_t rawMagY = lp_var_t(sid.objectId, NEG_Z_RAW_MAG_Y, this); - lp_var_t rawMagZ = lp_var_t(sid.objectId, NEG_Z_RAW_MAG_Z, this); - lp_var_t calMagX = lp_var_t(sid.objectId, NEG_Z_CAL_MAG_X, this); - lp_var_t calMagY = lp_var_t(sid.objectId, NEG_Z_CAL_MAG_Y, this); - lp_var_t calMagZ = lp_var_t(sid.objectId, NEG_Z_CAL_MAG_Z, this); - lp_var_t coilXCurrent = lp_var_t(sid.objectId, NEG_Z_COIL_X_CURRENT, - this); - lp_var_t coilYCurrent = lp_var_t(sid.objectId, NEG_Z_COIL_Y_CURRENT, - this); - lp_var_t coilZCurrent = lp_var_t(sid.objectId, NEG_Z_COIL_Z_CURRENT, - this); - lp_var_t coilXTemperature = lp_var_t(sid.objectId, - NEG_Z_COIL_X_TEMPERATURE, this); - lp_var_t coilYTemperature = lp_var_t(sid.objectId, - NEG_Z_COIL_Y_TEMPERATURE, this); - lp_var_t coilZTemperature = lp_var_t(sid.objectId, - NEG_Z_COIL_Z_TEMPERATURE, this); - - /** FINA block */ - lp_var_t finaErr = lp_var_t(sid.objectId, FINA_NEG_Z_ERR, this); - lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_NEG_Z_RAW_MAG_X, this); - lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_NEG_Z_RAW_MAG_Y, this); - lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_NEG_Z_RAW_MAG_Z, this); - lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_NEG_Z_CAL_MAG_X, this); - lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_NEG_Z_CAL_MAG_Y, this); - lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_NEG_Z_CAL_MAG_Z, this); - lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_NEG_Z_COIL_X_CURRENT, - this); - lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_NEG_Z_COIL_Y_CURRENT, - this); - lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_NEG_Z_COIL_Z_CURRENT, - this); - lp_var_t finaCoilXTemperature = lp_var_t(sid.objectId, - FINA_NEG_Z_COIL_X_TEMPERATURE, this); - lp_var_t finaCoilYTemperature = lp_var_t(sid.objectId, - FINA_NEG_Z_COIL_Y_TEMPERATURE, this); - lp_var_t finaCoilZTemperature = lp_var_t(sid.objectId, - FINA_NEG_Z_COIL_Z_TEMPERATURE, this); + /** FINA block */ + lp_var_t finaErr = lp_var_t(sid.objectId, FINA_NEG_Z_ERR, this); + lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_NEG_Z_RAW_MAG_X, this); + lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_NEG_Z_RAW_MAG_Y, this); + lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_NEG_Z_RAW_MAG_Z, this); + lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_NEG_Z_CAL_MAG_X, this); + lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_NEG_Z_CAL_MAG_Y, this); + lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_NEG_Z_CAL_MAG_Z, this); + lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_NEG_Z_COIL_X_CURRENT, this); + lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_NEG_Z_COIL_Y_CURRENT, this); + lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_NEG_Z_COIL_Z_CURRENT, this); + lp_var_t finaCoilXTemperature = + lp_var_t(sid.objectId, FINA_NEG_Z_COIL_X_TEMPERATURE, this); + lp_var_t finaCoilYTemperature = + lp_var_t(sid.objectId, FINA_NEG_Z_COIL_Y_TEMPERATURE, this); + lp_var_t finaCoilZTemperature = + lp_var_t(sid.objectId, FINA_NEG_Z_COIL_Z_TEMPERATURE, this); }; -} - +} // namespace IMTQ #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_IMTQDEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/Max31865Definitions.h b/mission/devices/devicedefinitions/Max31865Definitions.h index c9c8255e..58faaf97 100644 --- a/mission/devices/devicedefinitions/Max31865Definitions.h +++ b/mission/devices/devicedefinitions/Max31865Definitions.h @@ -1,18 +1,15 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_MAX13865DEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_MAX13865DEFINITIONS_H_ -#include #include +#include #include + #include "objects/systemObjectList.h" namespace Max31865Definitions { -enum PoolIds: lp_id_t { - RTD_VALUE, - TEMPERATURE_C, - FAULT_BYTE -}; +enum PoolIds : lp_id_t { RTD_VALUE, TEMPERATURE_C, FAULT_BYTE }; static constexpr DeviceCommandId_t CONFIG_CMD = 0x80; static constexpr DeviceCommandId_t WRITE_HIGH_THRESHOLD = 0x83; @@ -31,35 +28,26 @@ static constexpr uint8_t CLEAR_FAULT_BIT_VAL = 0b0000'0010; static constexpr size_t MAX_REPLY_SIZE = 5; -class Max31865Set: - public StaticLocalDataSet { -public: - /** - * Constructor used by owner and data creators like device handlers. - * @param owner - * @param setId - */ - Max31865Set(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, MAX31865_SET_ID) { - } +class Max31865Set : public StaticLocalDataSet { + public: + /** + * Constructor used by owner and data creators like device handlers. + * @param owner + * @param setId + */ + Max31865Set(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, MAX31865_SET_ID) {} - /** - * Constructor used by data users like controllers. - * @param sid - */ - Max31865Set(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, MAX31865_SET_ID)) { - } + /** + * Constructor used by data users like controllers. + * @param sid + */ + Max31865Set(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, MAX31865_SET_ID)) {} - lp_var_t rtdValue = lp_var_t(sid.objectId, - PoolIds::RTD_VALUE, this); - lp_var_t temperatureCelcius = lp_var_t(sid.objectId, - PoolIds::TEMPERATURE_C, this); - lp_var_t errorByte = lp_var_t(sid.objectId, - PoolIds::FAULT_BYTE, this); + lp_var_t rtdValue = lp_var_t(sid.objectId, PoolIds::RTD_VALUE, this); + lp_var_t temperatureCelcius = lp_var_t(sid.objectId, PoolIds::TEMPERATURE_C, this); + lp_var_t errorByte = lp_var_t(sid.objectId, PoolIds::FAULT_BYTE, this); }; -} +} // namespace Max31865Definitions #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_MAX13865DEFINITIONS_H_ */ - diff --git a/mission/devices/devicedefinitions/PlocMPSoCDefinitions.h b/mission/devices/devicedefinitions/PlocMPSoCDefinitions.h index 2b9466ab..2c8a081c 100644 --- a/mission/devices/devicedefinitions/PlocMPSoCDefinitions.h +++ b/mission/devices/devicedefinitions/PlocMPSoCDefinitions.h @@ -1,172 +1,166 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ -#include #include #include +#include namespace PLOC_MPSOC { - static const DeviceCommandId_t NONE = 0x0; - static const DeviceCommandId_t TC_MEM_WRITE = 0x1; - static const DeviceCommandId_t TC_MEM_READ = 0x2; - static const DeviceCommandId_t ACK_REPORT = 0x3; - static const DeviceCommandId_t EXE_REPORT = 0x5; - static const DeviceCommandId_t TM_MEMORY_READ_REPORT = 0x6; +static const DeviceCommandId_t NONE = 0x0; +static const DeviceCommandId_t TC_MEM_WRITE = 0x1; +static const DeviceCommandId_t TC_MEM_READ = 0x2; +static const DeviceCommandId_t ACK_REPORT = 0x3; +static const DeviceCommandId_t EXE_REPORT = 0x5; +static const DeviceCommandId_t TM_MEMORY_READ_REPORT = 0x6; - static const uint16_t SIZE_ACK_REPORT = 14; - static const uint16_t SIZE_EXE_REPORT = 14; - static const uint16_t SIZE_TM_MEM_READ_REPORT = 18; +static const uint16_t SIZE_ACK_REPORT = 14; +static const uint16_t SIZE_EXE_REPORT = 14; +static const uint16_t SIZE_TM_MEM_READ_REPORT = 18; - /** - * SpacePacket apids of PLOC telecommands and telemetry. - */ - static const uint16_t APID_TC_MEM_WRITE = 0x714; - static const uint16_t APID_TC_MEM_READ = 0x715; - static const uint16_t APID_TM_MEMORY_READ_REPORT = 0x404; - static const uint16_t APID_ACK_SUCCESS = 0x400; - static const uint16_t APID_ACK_FAILURE = 0x401; - static const uint16_t APID_EXE_SUCCESS = 0x402; - static const uint16_t APID_EXE_FAILURE = 0x403; +/** + * SpacePacket apids of PLOC telecommands and telemetry. + */ +static const uint16_t APID_TC_MEM_WRITE = 0x714; +static const uint16_t APID_TC_MEM_READ = 0x715; +static const uint16_t APID_TM_MEMORY_READ_REPORT = 0x404; +static const uint16_t APID_ACK_SUCCESS = 0x400; +static const uint16_t APID_ACK_FAILURE = 0x401; +static const uint16_t APID_EXE_SUCCESS = 0x402; +static const uint16_t APID_EXE_FAILURE = 0x403; - /** Offset from first byte in Space packet to first byte of data field */ - static const uint8_t DATA_FIELD_OFFSET = 6; +/** Offset from first byte in Space packet to first byte of data field */ +static const uint8_t DATA_FIELD_OFFSET = 6; - /** - * The size of payload data which will be forwarded to the requesting object. e.g. PUS Service - * 8. - */ - static const uint8_t SIZE_MEM_READ_REPORT_DATA = 10; +/** + * The size of payload data which will be forwarded to the requesting object. e.g. PUS Service + * 8. + */ +static const uint8_t SIZE_MEM_READ_REPORT_DATA = 10; - /** - * PLOC space packet length for fixed size packets. This is the size of the whole packet data - * field. For the length field in the space packet this size will be substracted by one. - */ - static const uint16_t LENGTH_TC_MEM_WRITE = 12; - static const uint16_t LENGTH_TC_MEM_READ = 8; +/** + * PLOC space packet length for fixed size packets. This is the size of the whole packet data + * field. For the length field in the space packet this size will be substracted by one. + */ +static const uint16_t LENGTH_TC_MEM_WRITE = 12; +static const uint16_t LENGTH_TC_MEM_READ = 8; - static const size_t MAX_REPLY_SIZE = SIZE_TM_MEM_READ_REPORT; - static const size_t MAX_COMMAND_SIZE = 18; +static const size_t MAX_REPLY_SIZE = SIZE_TM_MEM_READ_REPORT; +static const size_t MAX_COMMAND_SIZE = 18; - /** - * @brief This class helps to build the memory read command for the PLOC. - * - * @details The last two bytes of the packet data field contain a CRC calculated over the whole - * space packet. This is the CRC-16-CCITT as specified in - * ECSS-E-ST-70-41C Telemetry and telecommand packet utilization. - */ - class TcMemRead : public SpacePacket { - public: +/** + * @brief This class helps to build the memory read command for the PLOC. + * + * @details The last two bytes of the packet data field contain a CRC calculated over the whole + * space packet. This is the CRC-16-CCITT as specified in + * ECSS-E-ST-70-41C Telemetry and telecommand packet utilization. + */ +class TcMemRead : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param memAddr The memory address to read from. + */ + TcMemRead(const uint32_t memAddr, uint16_t sequenceCount) + : SpacePacket(LENGTH_TC_MEM_READ - 1, true, APID_TC_MEM_READ, sequenceCount) { + fillPacketDataField(&memAddr); + } - /** - * @brief Constructor - * - * @param memAddr The memory address to read from. - */ - TcMemRead(const uint32_t memAddr, uint16_t sequenceCount) : - SpacePacket(LENGTH_TC_MEM_READ - 1, true, APID_TC_MEM_READ, sequenceCount) { - fillPacketDataField(&memAddr); - } + private: + /** + * @brief This function builds the packet data field for the mem read command. + * + * @param memAddrPtr Pointer to the memory address to read from. + */ + void fillPacketDataField(const uint32_t* memAddrPtr) { + /* Add memAddr to packet data field */ + size_t serializedSize = 0; + uint8_t* memoryAddressPos = this->localData.fields.buffer; + SerializeAdapter::serialize(memAddrPtr, &memoryAddressPos, &serializedSize, + sizeof(*memAddrPtr), SerializeIF::Endianness::LITTLE); - private: + /* Add memLen to packet data field */ + this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD] = 1; + this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD + 1] = 0; - /** - * @brief This function builds the packet data field for the mem read command. - * - * @param memAddrPtr Pointer to the memory address to read from. - */ - void fillPacketDataField(const uint32_t* memAddrPtr) { - /* Add memAddr to packet data field */ - size_t serializedSize = 0; - uint8_t* memoryAddressPos = this->localData.fields.buffer; - SerializeAdapter::serialize(memAddrPtr, &memoryAddressPos, &serializedSize, - sizeof(*memAddrPtr), SerializeIF::Endianness::LITTLE); + /* Calculate crc */ + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + LENGTH_TC_MEM_READ - CRC_SIZE); - /* Add memLen to packet data field */ - this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD] = 1; - this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD + 1] = 0; + /* Add crc to packet data field of space packet */ + serializedSize = 0; + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } - /* Calculate crc */ - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + LENGTH_TC_MEM_READ - CRC_SIZE); + static const uint8_t OFFSET_MEM_LEN_FIELD = 4; + static const uint8_t CRC_OFFSET = 6; +}; - /* Add crc to packet data field of space packet */ - serializedSize = 0; - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, - sizeof(crc), SerializeIF::Endianness::BIG); - } +/** + * @brief This class helps to generate the space packet to write to a memory address within + * the PLOC. + * @details The last two bytes of the packet data field contain a CRC calculated over the whole + * space packet. This is the CRC-16-CCITT as specified in + * ECSS-E-ST-70-41C Telemetry and telecommand packet utilization. + */ +class TcMemWrite : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param memAddr The PLOC memory address where to write to. + * @param memoryData The data to write to the specified memory address. + * @param sequenceCount The subsequence count. Must be incremented with each new packet. + */ + TcMemWrite(const uint32_t memAddr, const uint32_t memoryData, uint16_t sequenceCount) + : SpacePacket(LENGTH_TC_MEM_WRITE - 1, true, APID_TC_MEM_WRITE, sequenceCount) { + fillPacketDataField(&memAddr, &memoryData); + } - static const uint8_t OFFSET_MEM_LEN_FIELD = 4; - static const uint8_t CRC_OFFSET = 6; + private: + /** + * @brief This function builds the packet data field for the mem write command. + * + * @param memAddrPtr Pointer to the PLOC memory address where to write to. + * @param memoryDataPtr Pointer to the memoryData to write + */ + void fillPacketDataField(const uint32_t* memAddrPtr, const uint32_t* memoryDataPtr) { + /* Add memAddr to packet data field */ + size_t serializedSize = 0; + uint8_t* memoryAddressPos = this->localData.fields.buffer; + SerializeAdapter::serialize(memAddrPtr, &memoryAddressPos, &serializedSize, + sizeof(*memAddrPtr), SerializeIF::Endianness::BIG); - }; + /* Add memLen to packet data field */ + this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD] = 1; + this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD + 1] = 0; - /** - * @brief This class helps to generate the space packet to write to a memory address within - * the PLOC. - * @details The last two bytes of the packet data field contain a CRC calculated over the whole - * space packet. This is the CRC-16-CCITT as specified in - * ECSS-E-ST-70-41C Telemetry and telecommand packet utilization. - */ - class TcMemWrite : public SpacePacket { - public: - /** - * @brief Constructor - * - * @param memAddr The PLOC memory address where to write to. - * @param memoryData The data to write to the specified memory address. - * @param sequenceCount The subsequence count. Must be incremented with each new packet. - */ - TcMemWrite(const uint32_t memAddr, const uint32_t memoryData, uint16_t sequenceCount) : - SpacePacket(LENGTH_TC_MEM_WRITE - 1, true, APID_TC_MEM_WRITE, sequenceCount) { - fillPacketDataField(&memAddr, &memoryData); - } + /* Add memData to packet data field */ + serializedSize = 0; + uint8_t* memoryDataPos = this->localData.fields.buffer + OFFSET_MEM_DATA_FIELD; + SerializeAdapter::serialize(memoryDataPtr, &memoryDataPos, &serializedSize, + sizeof(*memoryDataPtr), SerializeIF::Endianness::BIG); - private: + /* Calculate crc */ + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + LENGTH_TC_MEM_WRITE - CRC_SIZE); - /** - * @brief This function builds the packet data field for the mem write command. - * - * @param memAddrPtr Pointer to the PLOC memory address where to write to. - * @param memoryDataPtr Pointer to the memoryData to write - */ - void fillPacketDataField(const uint32_t* memAddrPtr, const uint32_t* memoryDataPtr) { + serializedSize = 0; + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + /* Add crc to packet data field of space packet */ + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } - /* Add memAddr to packet data field */ - size_t serializedSize = 0; - uint8_t* memoryAddressPos = this->localData.fields.buffer; - SerializeAdapter::serialize(memAddrPtr, &memoryAddressPos, &serializedSize, - sizeof(*memAddrPtr), SerializeIF::Endianness::BIG); - - /* Add memLen to packet data field */ - this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD] = 1; - this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD + 1] = 0; - - /* Add memData to packet data field */ - serializedSize = 0; - uint8_t* memoryDataPos = this->localData.fields.buffer + OFFSET_MEM_DATA_FIELD; - SerializeAdapter::serialize(memoryDataPtr, &memoryDataPos, &serializedSize, - sizeof(*memoryDataPtr), SerializeIF::Endianness::BIG); - - /* Calculate crc */ - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + LENGTH_TC_MEM_WRITE - CRC_SIZE); - - serializedSize = 0; - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - /* Add crc to packet data field of space packet */ - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, - sizeof(crc), SerializeIF::Endianness::BIG); - } - - /** Offsets from base address of packet data field */ - static const uint8_t OFFSET_MEM_LEN_FIELD = 4; - static const uint8_t OFFSET_MEM_DATA_FIELD = 6; - static const uint8_t CRC_OFFSET = 10; - }; - -} + /** Offsets from base address of packet data field */ + static const uint8_t OFFSET_MEM_LEN_FIELD = 4; + static const uint8_t OFFSET_MEM_DATA_FIELD = 6; + static const uint8_t CRC_OFFSET = 10; +}; +} // namespace PLOC_MPSOC #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/RadSensorDefinitions.h b/mission/devices/devicedefinitions/RadSensorDefinitions.h index d3c8e876..ab49b61b 100644 --- a/mission/devices/devicedefinitions/RadSensorDefinitions.h +++ b/mission/devices/devicedefinitions/RadSensorDefinitions.h @@ -3,84 +3,79 @@ namespace RAD_SENSOR { - static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending +static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending - /** - * This command initiates the ADC conversion for all channels including the internal - * temperature sensor. - */ - static const DeviceCommandId_t WRITE_SETUP = 0x1; - static const DeviceCommandId_t START_CONVERSION = 0x2; - static const DeviceCommandId_t READ_CONVERSIONS = 0x3; +/** + * This command initiates the ADC conversion for all channels including the internal + * temperature sensor. + */ +static const DeviceCommandId_t WRITE_SETUP = 0x1; +static const DeviceCommandId_t START_CONVERSION = 0x2; +static const DeviceCommandId_t READ_CONVERSIONS = 0x3; - /** - * @brief This is the configuration byte which will be written to the setup register after - * power on. - * - * @note Bit1 (DIFFSEL1) - Bit0 (DIFFSEL0): 0b00, no data follows the setup byte - * Bit3 (REFSEL1) - Bit2 (REFSEL0): 0b10, internal reference, no wake-up delay - * Bit5 (CLKSEL1) - Bit4 (CLKSEL0): 0b10, MAX1227 uses internal oscillator for timing - * Bit7 - Bit6: 0b01, tells MAX1227 that this is the setup register - * - */ - static const uint8_t SETUP_DEFINITION = 0b01101000; +/** + * @brief This is the configuration byte which will be written to the setup register after + * power on. + * + * @note Bit1 (DIFFSEL1) - Bit0 (DIFFSEL0): 0b00, no data follows the setup byte + * Bit3 (REFSEL1) - Bit2 (REFSEL0): 0b10, internal reference, no wake-up delay + * Bit5 (CLKSEL1) - Bit4 (CLKSEL0): 0b10, MAX1227 uses internal oscillator for timing + * Bit7 - Bit6: 0b01, tells MAX1227 that this is the setup register + * + */ +static const uint8_t SETUP_DEFINITION = 0b01101000; - /** - * @brief This value will always be written to the ADC conversion register to specify the - * conversions to perform. - * @details Bit0: 1 - Enables temperature conversion - * Bit2 (SCAN1) and Bit1 (SCAN0): 0b00 (channel conversion from 0 to N) - * Bit6 - Bit3 defines N: 0b0111 (N = 7) - * Bit7: Always 1. Tells the ADC that this is the conversion register. - */ - static const uint8_t CONVERSION_DEFINITION = 0b10111001; +/** + * @brief This value will always be written to the ADC conversion register to specify the + * conversions to perform. + * @details Bit0: 1 - Enables temperature conversion + * Bit2 (SCAN1) and Bit1 (SCAN0): 0b00 (channel conversion from 0 to N) + * Bit6 - Bit3 defines N: 0b0111 (N = 7) + * Bit7: Always 1. Tells the ADC that this is the conversion register. + */ +static const uint8_t CONVERSION_DEFINITION = 0b10111001; // static const uint8_t CONVERSION_DEFINITION = 0b10111111; - /** - * @brief Writing this value resets the fifo of the MAX1227. - */ - static const uint8_t RESET_DEFINITION = 0b00011000; +/** + * @brief Writing this value resets the fifo of the MAX1227. + */ +static const uint8_t RESET_DEFINITION = 0b00011000; - static const uint8_t DUMMY_BYTE = 0xFF; +static const uint8_t DUMMY_BYTE = 0xFF; - static const uint8_t RAD_SENSOR_DATA_SET_ID = READ_CONVERSIONS; +static const uint8_t RAD_SENSOR_DATA_SET_ID = READ_CONVERSIONS; - static const uint8_t DATASET_ENTRIES = 7; - /** - * One temperature value and conversions for AIN0 - AIN7 - */ - static const uint8_t READ_SIZE = 18; +static const uint8_t DATASET_ENTRIES = 7; +/** + * One temperature value and conversions for AIN0 - AIN7 + */ +static const uint8_t READ_SIZE = 18; - enum Max1227PoolIds: lp_id_t { - TEMPERATURE_C, - AIN0, - AIN1, - AIN4, - AIN5, - AIN6, - AIN7, - }; - -class RadSensorDataset: public StaticLocalDataSet { -public: - - RadSensorDataset(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, RAD_SENSOR_DATA_SET_ID) { - } - - RadSensorDataset(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, RAD_SENSOR_DATA_SET_ID)) { - } - - lp_var_t temperatureCelcius = lp_var_t(sid.objectId, TEMPERATURE_C, this); - lp_var_t ain0 = lp_var_t(sid.objectId, AIN0, this); - lp_var_t ain1 = lp_var_t(sid.objectId, AIN1, this); - lp_var_t ain4 = lp_var_t(sid.objectId, AIN4, this); - lp_var_t ain5 = lp_var_t(sid.objectId, AIN5, this); - lp_var_t ain6 = lp_var_t(sid.objectId, AIN6, this); - lp_var_t ain7 = lp_var_t(sid.objectId, AIN7, this); +enum Max1227PoolIds : lp_id_t { + TEMPERATURE_C, + AIN0, + AIN1, + AIN4, + AIN5, + AIN6, + AIN7, }; -} +class RadSensorDataset : public StaticLocalDataSet { + public: + RadSensorDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, RAD_SENSOR_DATA_SET_ID) {} + + RadSensorDataset(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, RAD_SENSOR_DATA_SET_ID)) {} + + lp_var_t temperatureCelcius = lp_var_t(sid.objectId, TEMPERATURE_C, this); + lp_var_t ain0 = lp_var_t(sid.objectId, AIN0, this); + lp_var_t ain1 = lp_var_t(sid.objectId, AIN1, this); + lp_var_t ain4 = lp_var_t(sid.objectId, AIN4, this); + lp_var_t ain5 = lp_var_t(sid.objectId, AIN5, this); + lp_var_t ain6 = lp_var_t(sid.objectId, AIN6, this); + lp_var_t ain7 = lp_var_t(sid.objectId, AIN7, this); +}; +} // namespace RAD_SENSOR #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_RADSENSOR_H_ */ diff --git a/mission/devices/devicedefinitions/RwDefinitions.h b/mission/devices/devicedefinitions/RwDefinitions.h index b8905002..c25e3f09 100644 --- a/mission/devices/devicedefinitions/RwDefinitions.h +++ b/mission/devices/devicedefinitions/RwDefinitions.h @@ -1,66 +1,61 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_RWDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_RWDEFINITIONS_H_ -#include #include +#include #include + #include "objects/systemObjectList.h" namespace RwDefinitions { -static const uint32_t SPI_REPLY_DELAY = 70000; //us +static const uint32_t SPI_REPLY_DELAY = 70000; // us -enum PoolIds: lp_id_t { - TEMPERATURE_C, - CURR_SPEED, - REFERENCE_SPEED, - STATE, - CLC_MODE, - LAST_RESET_STATUS, - CURRRENT_RESET_STATUS, - TM_LAST_RESET_STATUS, - TM_MCU_TEMPERATURE, - PRESSURE_SENSOR_TEMPERATURE, - PRESSURE, - TM_RW_STATE, - TM_CLC_MODE, - TM_RW_CURR_SPEED, - TM_RW_REF_SPEED, - INVALID_CRC_PACKETS, - INVALID_LEN_PACKETS, - INVALID_CMD_PACKETS, - EXECUTED_REPLIES, - COMMAND_REPLIES, - UART_BYTES_WRITTEN, - UART_BYTES_READ, - UART_PARITY_ERRORS, - UART_NOISE_ERRORS, - UART_FRAME_ERRORS, - UART_REG_OVERRUN_ERRORS, - UART_TOTAL_ERRORS, - TOTAL_ERRORS, - SPI_BYTES_WRITTEN, - SPI_BYTES_READ, - SPI_REG_OVERRUN_ERRORS, - SPI_TOTAL_ERRORS +enum PoolIds : lp_id_t { + TEMPERATURE_C, + CURR_SPEED, + REFERENCE_SPEED, + STATE, + CLC_MODE, + LAST_RESET_STATUS, + CURRRENT_RESET_STATUS, + TM_LAST_RESET_STATUS, + TM_MCU_TEMPERATURE, + PRESSURE_SENSOR_TEMPERATURE, + PRESSURE, + TM_RW_STATE, + TM_CLC_MODE, + TM_RW_CURR_SPEED, + TM_RW_REF_SPEED, + INVALID_CRC_PACKETS, + INVALID_LEN_PACKETS, + INVALID_CMD_PACKETS, + EXECUTED_REPLIES, + COMMAND_REPLIES, + UART_BYTES_WRITTEN, + UART_BYTES_READ, + UART_PARITY_ERRORS, + UART_NOISE_ERRORS, + UART_FRAME_ERRORS, + UART_REG_OVERRUN_ERRORS, + UART_TOTAL_ERRORS, + TOTAL_ERRORS, + SPI_BYTES_WRITTEN, + SPI_BYTES_READ, + SPI_REG_OVERRUN_ERRORS, + SPI_TOTAL_ERRORS }; -enum States: uint8_t { - STATE_ERROR, - IDLE, - COASTING, - RUNNING_SPEED_STABLE, - RUNNING_SPEED_CHANGING -}; +enum States : uint8_t { STATE_ERROR, IDLE, COASTING, RUNNING_SPEED_STABLE, RUNNING_SPEED_CHANGING }; -enum LastResetStatus: uint8_t { - CLEARED = 0, - PIN_RESET = 1, - POR_PDR_BOR_RESET = 2, - SOFTWARE_RESET = 4, - INDEPENDENT_WATCHDOG_RESET = 8, - WINDOW_WATCHDOG_RESET = 16, - LOW_POWER_RESET = 32 +enum LastResetStatus : uint8_t { + CLEARED = 0, + PIN_RESET = 1, + POR_PDR_BOR_RESET = 2, + SOFTWARE_RESET = 4, + INDEPENDENT_WATCHDOG_RESET = 8, + WINDOW_WATCHDOG_RESET = 16, + LOW_POWER_RESET = 32 }; static const DeviceCommandId_t RESET_MCU = 1; @@ -103,66 +98,45 @@ static const uint8_t TM_SET_ENTRIES = 24; /** * @brief This dataset can be used to store the temperature of a reaction wheel. */ -class TemperatureSet: - public StaticLocalDataSet { -public: +class TemperatureSet : public StaticLocalDataSet { + public: + TemperatureSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TEMPERATURE_SET_ID) {} - TemperatureSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, TEMPERATURE_SET_ID) { - } + TemperatureSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TEMPERATURE_SET_ID)) {} - TemperatureSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, TEMPERATURE_SET_ID)) { - } - - lp_var_t temperatureCelcius = lp_var_t(sid.objectId, - PoolIds::TEMPERATURE_C, this); + lp_var_t temperatureCelcius = + lp_var_t(sid.objectId, PoolIds::TEMPERATURE_C, this); }; /** * @brief This dataset can be used to store the reaction wheel status. */ -class StatusSet: - public StaticLocalDataSet { -public: +class StatusSet : public StaticLocalDataSet { + public: + StatusSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, STATUS_SET_ID) {} - StatusSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, STATUS_SET_ID) { - } + StatusSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, STATUS_SET_ID)) {} - StatusSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, STATUS_SET_ID)) { - } - - lp_var_t currSpeed = lp_var_t(sid.objectId, - PoolIds::CURR_SPEED, this); - lp_var_t referenceSpeed = lp_var_t(sid.objectId, - PoolIds::REFERENCE_SPEED, this); - lp_var_t state = lp_var_t(sid.objectId, - PoolIds::STATE, this); - lp_var_t clcMode = lp_var_t(sid.objectId, - PoolIds::CLC_MODE, this); + lp_var_t currSpeed = lp_var_t(sid.objectId, PoolIds::CURR_SPEED, this); + lp_var_t referenceSpeed = + lp_var_t(sid.objectId, PoolIds::REFERENCE_SPEED, this); + lp_var_t state = lp_var_t(sid.objectId, PoolIds::STATE, this); + lp_var_t clcMode = lp_var_t(sid.objectId, PoolIds::CLC_MODE, this); }; /** * @brief This dataset stores the last reset status. */ -class LastResetSatus: - public StaticLocalDataSet { -public: +class LastResetSatus : public StaticLocalDataSet { + public: + LastResetSatus(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, LAST_RESET_ID) {} - LastResetSatus(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, LAST_RESET_ID) { - } + LastResetSatus(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, LAST_RESET_ID)) {} - LastResetSatus(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, LAST_RESET_ID)) { - } - - lp_var_t lastResetStatus = lp_var_t(sid.objectId, - PoolIds::LAST_RESET_STATUS, this); - lp_var_t currentResetStatus = lp_var_t(sid.objectId, - PoolIds::CURRRENT_RESET_STATUS, this); + lp_var_t lastResetStatus = + lp_var_t(sid.objectId, PoolIds::LAST_RESET_STATUS, this); + lp_var_t currentResetStatus = + lp_var_t(sid.objectId, PoolIds::CURRRENT_RESET_STATUS, this); }; /** @@ -170,69 +144,57 @@ public: * reaction wheels. https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/ * EIVE_IRS/Arbeitsdaten/08_Used%20Components/Nanoavionics_Reactionwheels&fileid=181622 */ -class TmDataset: - public StaticLocalDataSet { -public: +class TmDataset : public StaticLocalDataSet { + public: + TmDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TM_SET_ID) {} - TmDataset(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, TM_SET_ID) { - } + TmDataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TM_SET_ID)) {} - TmDataset(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, TM_SET_ID)) { - } - - lp_var_t lastResetStatus = lp_var_t(sid.objectId, - PoolIds::TM_LAST_RESET_STATUS, this); - lp_var_t mcuTemperature = lp_var_t(sid.objectId, - PoolIds::TM_MCU_TEMPERATURE, this); - lp_var_t pressureSensorTemperature = lp_var_t(sid.objectId, - PoolIds::PRESSURE_SENSOR_TEMPERATURE, this); - lp_var_t pressure = lp_var_t(sid.objectId, - PoolIds::PRESSURE, this); - lp_var_t rwState = lp_var_t(sid.objectId, - PoolIds::TM_RW_STATE, this); - lp_var_t rwClcMode = lp_var_t(sid.objectId, - PoolIds::TM_CLC_MODE, this); - lp_var_t rwCurrSpeed = lp_var_t(sid.objectId, - PoolIds::TM_RW_CURR_SPEED, this); - lp_var_t rwRefSpeed = lp_var_t(sid.objectId, - PoolIds::TM_RW_REF_SPEED, this); - lp_var_t numOfInvalidCrcPackets = lp_var_t(sid.objectId, - PoolIds::INVALID_CRC_PACKETS, this); - lp_var_t numOfInvalidLenPackets = lp_var_t(sid.objectId, - PoolIds::INVALID_LEN_PACKETS, this); - lp_var_t numOfInvalidCmdPackets = lp_var_t(sid.objectId, - PoolIds::INVALID_CMD_PACKETS, this); - lp_var_t numOfCmdExecutedReplies = lp_var_t(sid.objectId, - PoolIds::EXECUTED_REPLIES, this); - lp_var_t numOfCmdReplies = lp_var_t(sid.objectId, - PoolIds::COMMAND_REPLIES, this); - lp_var_t uartNumOfBytesWritten = lp_var_t(sid.objectId, - PoolIds::UART_BYTES_WRITTEN, this); - lp_var_t uartNumOfBytesRead = lp_var_t(sid.objectId, - PoolIds::UART_BYTES_READ, this); - lp_var_t uartNumOfParityErrors = lp_var_t(sid.objectId, - PoolIds::UART_PARITY_ERRORS, this); - lp_var_t uartNumOfNoiseErrors = lp_var_t(sid.objectId, - PoolIds::UART_NOISE_ERRORS, this); - lp_var_t uartNumOfFrameErrors = lp_var_t(sid.objectId, - PoolIds::UART_FRAME_ERRORS, this); - lp_var_t uartNumOfRegisterOverrunErrors = lp_var_t(sid.objectId, - PoolIds::UART_REG_OVERRUN_ERRORS, this); - lp_var_t uartTotalNumOfErrors = lp_var_t(sid.objectId, - PoolIds::UART_TOTAL_ERRORS, this); - lp_var_t spiNumOfBytesWritten = lp_var_t(sid.objectId, - PoolIds::SPI_BYTES_WRITTEN, this); - lp_var_t spiNumOfBytesRead = lp_var_t(sid.objectId, - PoolIds::SPI_BYTES_READ, this); - lp_var_t spiNumOfRegisterOverrunErrors = lp_var_t(sid.objectId, - PoolIds::SPI_REG_OVERRUN_ERRORS, this); - lp_var_t spiTotalNumOfErrors = lp_var_t(sid.objectId, - PoolIds::SPI_TOTAL_ERRORS, this); + lp_var_t lastResetStatus = + lp_var_t(sid.objectId, PoolIds::TM_LAST_RESET_STATUS, this); + lp_var_t mcuTemperature = + lp_var_t(sid.objectId, PoolIds::TM_MCU_TEMPERATURE, this); + lp_var_t pressureSensorTemperature = + lp_var_t(sid.objectId, PoolIds::PRESSURE_SENSOR_TEMPERATURE, this); + lp_var_t pressure = lp_var_t(sid.objectId, PoolIds::PRESSURE, this); + lp_var_t rwState = lp_var_t(sid.objectId, PoolIds::TM_RW_STATE, this); + lp_var_t rwClcMode = lp_var_t(sid.objectId, PoolIds::TM_CLC_MODE, this); + lp_var_t rwCurrSpeed = lp_var_t(sid.objectId, PoolIds::TM_RW_CURR_SPEED, this); + lp_var_t rwRefSpeed = lp_var_t(sid.objectId, PoolIds::TM_RW_REF_SPEED, this); + lp_var_t numOfInvalidCrcPackets = + lp_var_t(sid.objectId, PoolIds::INVALID_CRC_PACKETS, this); + lp_var_t numOfInvalidLenPackets = + lp_var_t(sid.objectId, PoolIds::INVALID_LEN_PACKETS, this); + lp_var_t numOfInvalidCmdPackets = + lp_var_t(sid.objectId, PoolIds::INVALID_CMD_PACKETS, this); + lp_var_t numOfCmdExecutedReplies = + lp_var_t(sid.objectId, PoolIds::EXECUTED_REPLIES, this); + lp_var_t numOfCmdReplies = + lp_var_t(sid.objectId, PoolIds::COMMAND_REPLIES, this); + lp_var_t uartNumOfBytesWritten = + lp_var_t(sid.objectId, PoolIds::UART_BYTES_WRITTEN, this); + lp_var_t uartNumOfBytesRead = + lp_var_t(sid.objectId, PoolIds::UART_BYTES_READ, this); + lp_var_t uartNumOfParityErrors = + lp_var_t(sid.objectId, PoolIds::UART_PARITY_ERRORS, this); + lp_var_t uartNumOfNoiseErrors = + lp_var_t(sid.objectId, PoolIds::UART_NOISE_ERRORS, this); + lp_var_t uartNumOfFrameErrors = + lp_var_t(sid.objectId, PoolIds::UART_FRAME_ERRORS, this); + lp_var_t uartNumOfRegisterOverrunErrors = + lp_var_t(sid.objectId, PoolIds::UART_REG_OVERRUN_ERRORS, this); + lp_var_t uartTotalNumOfErrors = + lp_var_t(sid.objectId, PoolIds::UART_TOTAL_ERRORS, this); + lp_var_t spiNumOfBytesWritten = + lp_var_t(sid.objectId, PoolIds::SPI_BYTES_WRITTEN, this); + lp_var_t spiNumOfBytesRead = + lp_var_t(sid.objectId, PoolIds::SPI_BYTES_READ, this); + lp_var_t spiNumOfRegisterOverrunErrors = + lp_var_t(sid.objectId, PoolIds::SPI_REG_OVERRUN_ERRORS, this); + lp_var_t spiTotalNumOfErrors = + lp_var_t(sid.objectId, PoolIds::SPI_TOTAL_ERRORS, this); }; -} +} // namespace RwDefinitions #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_RWDEFINITIONS_H_ */ - diff --git a/mission/devices/devicedefinitions/SyrlinksDefinitions.h b/mission/devices/devicedefinitions/SyrlinksDefinitions.h index 43ce16f2..3b56918a 100644 --- a/mission/devices/devicedefinitions/SyrlinksDefinitions.h +++ b/mission/devices/devicedefinitions/SyrlinksDefinitions.h @@ -1,101 +1,88 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_SYRLINKSDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_SYRLINKSDEFINITIONS_H_ - namespace SYRLINKS { - static const DeviceCommandId_t NONE = 0x0; - static const DeviceCommandId_t RESET_UNIT = 0x01; - /** Reads out all status registers */ - static const DeviceCommandId_t READ_RX_STATUS_REGISTERS = 0x02; - /** Sets Tx mode to standby */ - static const DeviceCommandId_t SET_TX_MODE_STANDBY = 0x03; - /** Starts transmission mode. Only reached when clock signal is applying to the data tx input */ - static const DeviceCommandId_t SET_TX_MODE_MODULATION = 0x04; - /** Sends out a single carrier wave for testing purpose */ - static const DeviceCommandId_t SET_TX_MODE_CW = 0x05; - static const DeviceCommandId_t ACK_REPLY = 0x06; - static const DeviceCommandId_t READ_TX_STATUS = 0x07; - static const DeviceCommandId_t READ_TX_WAVEFORM = 0x08; - static const DeviceCommandId_t READ_TX_AGC_VALUE_HIGH_BYTE = 0x09; - static const DeviceCommandId_t READ_TX_AGC_VALUE_LOW_BYTE = 0x0A; +static const DeviceCommandId_t NONE = 0x0; +static const DeviceCommandId_t RESET_UNIT = 0x01; +/** Reads out all status registers */ +static const DeviceCommandId_t READ_RX_STATUS_REGISTERS = 0x02; +/** Sets Tx mode to standby */ +static const DeviceCommandId_t SET_TX_MODE_STANDBY = 0x03; +/** Starts transmission mode. Only reached when clock signal is applying to the data tx input */ +static const DeviceCommandId_t SET_TX_MODE_MODULATION = 0x04; +/** Sends out a single carrier wave for testing purpose */ +static const DeviceCommandId_t SET_TX_MODE_CW = 0x05; +static const DeviceCommandId_t ACK_REPLY = 0x06; +static const DeviceCommandId_t READ_TX_STATUS = 0x07; +static const DeviceCommandId_t READ_TX_WAVEFORM = 0x08; +static const DeviceCommandId_t READ_TX_AGC_VALUE_HIGH_BYTE = 0x09; +static const DeviceCommandId_t READ_TX_AGC_VALUE_LOW_BYTE = 0x0A; - /** Size of a simple transmission success response */ - static const uint8_t ACK_SIZE = 12; - static const uint8_t SIZE_CRC_AND_TERMINATION = 5; - /** The size of the header with the message identifier and the payload size field */ - static const uint8_t MESSAGE_HEADER_SIZE = 5; - /** Size of reply to an rx status registers request */ - static const uint8_t RX_STATUS_REGISTERS_REPLY_SIZE = 49; - static const uint8_t READ_ONE_REGISTER_REPLY_SIE = 13; +/** Size of a simple transmission success response */ +static const uint8_t ACK_SIZE = 12; +static const uint8_t SIZE_CRC_AND_TERMINATION = 5; +/** The size of the header with the message identifier and the payload size field */ +static const uint8_t MESSAGE_HEADER_SIZE = 5; +/** Size of reply to an rx status registers request */ +static const uint8_t RX_STATUS_REGISTERS_REPLY_SIZE = 49; +static const uint8_t READ_ONE_REGISTER_REPLY_SIE = 13; - static const uint8_t RX_DATASET_ID = 0x1; - static const uint8_t TX_DATASET_ID = 0x2; +static const uint8_t RX_DATASET_ID = 0x1; +static const uint8_t TX_DATASET_ID = 0x2; - static const size_t MAX_REPLY_SIZE = RX_STATUS_REGISTERS_REPLY_SIZE; - static const size_t MAX_COMMAND_SIZE = 15; +static const size_t MAX_REPLY_SIZE = RX_STATUS_REGISTERS_REPLY_SIZE; +static const size_t MAX_COMMAND_SIZE = 15; - static const size_t CRC_FIELD_SIZE = 4; +static const size_t CRC_FIELD_SIZE = 4; - static const uint8_t RX_DATASET_SIZE = 8; - static const uint8_t TX_DATASET_SIZE = 3; +static const uint8_t RX_DATASET_SIZE = 8; +static const uint8_t TX_DATASET_SIZE = 3; - enum SyrlinksPoolIds: lp_id_t { - RX_STATUS, - RX_SENSITIVITY, - RX_FREQUENCY_SHIFT, - RX_IQ_POWER, - RX_AGC_VALUE, - RX_DEMOD_EB, - RX_DEMOD_N0, - RX_DATA_RATE, - TX_STATUS, - TX_CONV_DIFF, - TX_CONV_FILTER, - TX_WAVEFORM, - TX_PCM_INDEX, - TX_AGC_VALUE, - }; - -class RxDataset: public StaticLocalDataSet { -public: - - RxDataset(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, RX_DATASET_ID) { - } - - RxDataset(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, RX_DATASET_ID)) { - } - - lp_var_t rxStatus = lp_var_t(sid.objectId, RX_STATUS, this); - lp_var_t rxSensitivity = lp_var_t(sid.objectId, RX_SENSITIVITY, this); - lp_var_t rxFrequencyShift = lp_var_t(sid.objectId, RX_FREQUENCY_SHIFT, this); - lp_var_t rxIqPower = lp_var_t(sid.objectId, RX_IQ_POWER, this); - lp_var_t rxAgcValue = lp_var_t(sid.objectId, RX_AGC_VALUE, this); - lp_var_t rxDemodEb = lp_var_t(sid.objectId, RX_DEMOD_EB, this); - lp_var_t rxDemodN0 = lp_var_t(sid.objectId, RX_DEMOD_N0, this); - lp_var_t rxDataRate = lp_var_t(sid.objectId, RX_DATA_RATE, this); +enum SyrlinksPoolIds : lp_id_t { + RX_STATUS, + RX_SENSITIVITY, + RX_FREQUENCY_SHIFT, + RX_IQ_POWER, + RX_AGC_VALUE, + RX_DEMOD_EB, + RX_DEMOD_N0, + RX_DATA_RATE, + TX_STATUS, + TX_CONV_DIFF, + TX_CONV_FILTER, + TX_WAVEFORM, + TX_PCM_INDEX, + TX_AGC_VALUE, }; +class RxDataset : public StaticLocalDataSet { + public: + RxDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, RX_DATASET_ID) {} -class TxDataset: public StaticLocalDataSet { -public: + RxDataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, RX_DATASET_ID)) {} - TxDataset(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, TX_DATASET_ID) { - } - - TxDataset(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, TX_DATASET_ID)) { - } - - lp_var_t txStatus = lp_var_t(sid.objectId, TX_STATUS, this); - lp_var_t txWaveform = lp_var_t(sid.objectId, TX_WAVEFORM, this); - lp_var_t txAgcValue = lp_var_t(sid.objectId, TX_AGC_VALUE, this); + lp_var_t rxStatus = lp_var_t(sid.objectId, RX_STATUS, this); + lp_var_t rxSensitivity = lp_var_t(sid.objectId, RX_SENSITIVITY, this); + lp_var_t rxFrequencyShift = lp_var_t(sid.objectId, RX_FREQUENCY_SHIFT, this); + lp_var_t rxIqPower = lp_var_t(sid.objectId, RX_IQ_POWER, this); + lp_var_t rxAgcValue = lp_var_t(sid.objectId, RX_AGC_VALUE, this); + lp_var_t rxDemodEb = lp_var_t(sid.objectId, RX_DEMOD_EB, this); + lp_var_t rxDemodN0 = lp_var_t(sid.objectId, RX_DEMOD_N0, this); + lp_var_t rxDataRate = lp_var_t(sid.objectId, RX_DATA_RATE, this); }; -} +class TxDataset : public StaticLocalDataSet { + public: + TxDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TX_DATASET_ID) {} + TxDataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TX_DATASET_ID)) {} + + lp_var_t txStatus = lp_var_t(sid.objectId, TX_STATUS, this); + lp_var_t txWaveform = lp_var_t(sid.objectId, TX_WAVEFORM, this); + lp_var_t txAgcValue = lp_var_t(sid.objectId, TX_AGC_VALUE, this); +}; + +} // namespace SYRLINKS #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_SYRLINKSDEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/Tmp1075Definitions.h b/mission/devices/devicedefinitions/Tmp1075Definitions.h index 603260ac..3f48508c 100644 --- a/mission/devices/devicedefinitions/Tmp1075Definitions.h +++ b/mission/devices/devicedefinitions/Tmp1075Definitions.h @@ -2,46 +2,35 @@ #define MISSION_DEVICES_DEVICEDEFINITIONS_TMP1075DEFINITIONS_H_ namespace TMP1075 { - static const uint8_t TEMP_REG_ADDR = 0x0; - static const uint8_t CFGR_ADDR = 0x1; +static const uint8_t TEMP_REG_ADDR = 0x0; +static const uint8_t CFGR_ADDR = 0x1; - /* Writing this information to the configuration register sets the tmp1075 - * to shutdown mode and starts a single temperature conversion */ - static const uint16_t ONE_SHOT_MODE = 0x8100; +/* Writing this information to the configuration register sets the tmp1075 + * to shutdown mode and starts a single temperature conversion */ +static const uint16_t ONE_SHOT_MODE = 0x8100; - static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending - static const DeviceCommandId_t GET_TEMP = 0x1; - static const DeviceCommandId_t START_ADC_CONVERSION = 0x2; +static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending +static const DeviceCommandId_t GET_TEMP = 0x1; +static const DeviceCommandId_t START_ADC_CONVERSION = 0x2; - static const uint8_t GET_TEMP_REPLY_SIZE = 2; - static const uint8_t CFGR_CMD_SIZE = 3; - static const uint8_t POINTER_REG_SIZE = 1; +static const uint8_t GET_TEMP_REPLY_SIZE = 2; +static const uint8_t CFGR_CMD_SIZE = 3; +static const uint8_t POINTER_REG_SIZE = 1; - static const uint32_t TMP1075_DATA_SET_ID = GET_TEMP; +static const uint32_t TMP1075_DATA_SET_ID = GET_TEMP; - static const uint8_t MAX_REPLY_LENGTH = GET_TEMP_REPLY_SIZE; +static const uint8_t MAX_REPLY_LENGTH = GET_TEMP_REPLY_SIZE; - enum Tmp1075PoolIds: lp_id_t { - TEMPERATURE_C_TMP1075_1, - TEMPERATURE_C_TMP1075_2 - }; +enum Tmp1075PoolIds : lp_id_t { TEMPERATURE_C_TMP1075_1, TEMPERATURE_C_TMP1075_2 }; -class Tmp1075Dataset: - public StaticLocalDataSet { -public: +class Tmp1075Dataset : public StaticLocalDataSet { + public: + Tmp1075Dataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TMP1075_DATA_SET_ID) {} - Tmp1075Dataset(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, TMP1075_DATA_SET_ID) { - } + Tmp1075Dataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TMP1075_DATA_SET_ID)) {} - Tmp1075Dataset(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, TMP1075_DATA_SET_ID)) { - } - - lp_var_t temperatureCelcius = lp_var_t(sid.objectId, - TEMPERATURE_C_TMP1075_1, this); + lp_var_t temperatureCelcius = lp_var_t(sid.objectId, TEMPERATURE_C_TMP1075_1, this); }; -} - +} // namespace TMP1075 #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_TMP1075DEFINITIONS_H_ */ diff --git a/mission/memory/NVMParameterBase.cpp b/mission/memory/NVMParameterBase.cpp index e7b8e8a6..0802a392 100644 --- a/mission/memory/NVMParameterBase.cpp +++ b/mission/memory/NVMParameterBase.cpp @@ -1,50 +1,44 @@ #include "NVMParameterBase.h" -#include "fsfw/memory/HasFileSystemIF.h" -#include "fsfw/serviceinterface/ServiceInterface.h" #include -NVMParameterBase::NVMParameterBase(std::string fullName): fullName(fullName) { -} +#include "fsfw/memory/HasFileSystemIF.h" +#include "fsfw/serviceinterface/ServiceInterface.h" + +NVMParameterBase::NVMParameterBase(std::string fullName) : fullName(fullName) {} ReturnValue_t NVMParameterBase::readJsonFile() { - if(std::filesystem::exists(fullName)) { - // Read JSON file content into object - std::ifstream i(fullName); - i >> json; - return HasReturnvaluesIF::RETURN_OK; - } - return HasFileSystemIF::FILE_DOES_NOT_EXIST; + if (std::filesystem::exists(fullName)) { + // Read JSON file content into object + std::ifstream i(fullName); + i >> json; + return HasReturnvaluesIF::RETURN_OK; + } + return HasFileSystemIF::FILE_DOES_NOT_EXIST; } ReturnValue_t NVMParameterBase::writeJsonFile() { - std::ofstream o(fullName); - o << std::setw(4) << json; - return HasReturnvaluesIF::RETURN_OK; + std::ofstream o(fullName); + o << std::setw(4) << json; + return HasReturnvaluesIF::RETURN_OK; } -void NVMParameterBase::setFullName(std::string fullName) { - this->fullName = fullName; -} +void NVMParameterBase::setFullName(std::string fullName) { this->fullName = fullName; } -std::string NVMParameterBase::getFullName() const { - return fullName; -} +std::string NVMParameterBase::getFullName() const { return fullName; } -bool NVMParameterBase::getJsonFileExists() { - return std::filesystem::exists(fullName); -} +bool NVMParameterBase::getJsonFileExists() { return std::filesystem::exists(fullName); } void NVMParameterBase::printKeys() const { - sif::info << "Printing keys for JSON file " << fullName << std::endl; - for(const auto& key: keys) { - sif::info << key << std::endl; - } + sif::info << "Printing keys for JSON file " << fullName << std::endl; + for (const auto& key : keys) { + sif::info << key << std::endl; + } } void NVMParameterBase::print() const { - sif::info << "Printing JSON file " << fullName << std::endl; - for(const auto& key: keys) { - sif::info << key << ": " << json[key] << std::endl; - } + sif::info << "Printing JSON file " << fullName << std::endl; + for (const auto& key : keys) { + sif::info << key << ": " << json[key] << std::endl; + } } diff --git a/mission/memory/NVMParameterBase.h b/mission/memory/NVMParameterBase.h index f41f9e63..aafbf8cc 100644 --- a/mission/memory/NVMParameterBase.h +++ b/mission/memory/NVMParameterBase.h @@ -1,79 +1,78 @@ #ifndef BSP_Q7S_CORE_NVMPARAMS_NVMPARAMIF_H_ #define BSP_Q7S_CORE_NVMPARAMS_NVMPARAMIF_H_ -#include "fsfw/returnvalues/HasReturnvaluesIF.h" - +#include #include #include -#include + +#include "fsfw/returnvalues/HasReturnvaluesIF.h" class NVMParameterBase : public HasReturnvaluesIF { -public: - virtual~ NVMParameterBase() {} + public: + virtual ~NVMParameterBase() {} - NVMParameterBase(std::string fullName); + NVMParameterBase(std::string fullName); - bool getJsonFileExists(); + bool getJsonFileExists(); - /** - * Returns RETURN_OK on successfull read and HasFileSystemIF::FILE_DOES_NOT_EXIST if - * file does not exist yet. - * @return - */ - virtual ReturnValue_t readJsonFile(); + /** + * Returns RETURN_OK on successfull read and HasFileSystemIF::FILE_DOES_NOT_EXIST if + * file does not exist yet. + * @return + */ + virtual ReturnValue_t readJsonFile(); - virtual ReturnValue_t writeJsonFile(); + virtual ReturnValue_t writeJsonFile(); - void setFullName(std::string fullName); - std::string getFullName() const; + void setFullName(std::string fullName); + std::string getFullName() const; - template - ReturnValue_t insertValue(std::string key, T value); + template + ReturnValue_t insertValue(std::string key, T value); - template - ReturnValue_t setValue(std::string key, T value); + template + ReturnValue_t setValue(std::string key, T value); - template - ReturnValue_t getValue(std::string key, T* value) const; + template + ReturnValue_t getValue(std::string key, T* value) const; - void printKeys() const; - void print() const; + void printKeys() const; + void print() const; -private: + private: + static const uint8_t INTERFACE_ID = CLASS_ID::NVM_PARAM_BASE; - static const uint8_t INTERFACE_ID = CLASS_ID::NVM_PARAM_BASE; + //! [EXPORT] : [COMMENT] Specified key does not exist in json file + static const ReturnValue_t KEY_NOT_EXISTS = MAKE_RETURN_CODE(0xA0); - //! [EXPORT] : [COMMENT] Specified key does not exist in json file - static const ReturnValue_t KEY_NOT_EXISTS = MAKE_RETURN_CODE(0xA0); - - nlohmann::json json; - std::vector keys; - std::string fullName; + nlohmann::json json; + std::vector keys; + std::string fullName; }; -template +template inline ReturnValue_t NVMParameterBase::insertValue(std::string key, T value) { - // Check whether key already exists. If it does not, insert it - if (std::find(keys.begin(), keys.end(), key) == keys.end()) { - keys.push_back(key); - } - json[key] = value; - return HasReturnvaluesIF::RETURN_OK; + // Check whether key already exists. If it does not, insert it + if (std::find(keys.begin(), keys.end(), key) == keys.end()) { + keys.push_back(key); + } + json[key] = value; + return HasReturnvaluesIF::RETURN_OK; } -template +template inline ReturnValue_t NVMParameterBase::setValue(std::string key, T value) { - json[key] = value; - return HasReturnvaluesIF::RETURN_OK; + json[key] = value; + return HasReturnvaluesIF::RETURN_OK; } -template +template inline ReturnValue_t NVMParameterBase::getValue(std::string key, T* value) const { - if (!json.contains(key)) { - return KEY_NOT_EXISTS; - } - *value = json[key]; - return RETURN_OK; + if (!json.contains(key)) { + return KEY_NOT_EXISTS; + } + *value = json[key]; + return RETURN_OK; } #endif /* BSP_Q7S_CORE_NVMPARAMS_NVMPARAMIF_H_ */ diff --git a/mission/tmtc/CCSDSHandler.cpp b/mission/tmtc/CCSDSHandler.cpp index 524fe4b8..ba34d273 100644 --- a/mission/tmtc/CCSDSHandler.cpp +++ b/mission/tmtc/CCSDSHandler.cpp @@ -1,303 +1,301 @@ -#include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/serviceinterface/serviceInterfaceDefintions.h" -#include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/ipc/QueueFactory.h" -#include "fsfw/events/EventManagerIF.h" +#include "CCSDSHandler.h" #include -#include "CCSDSHandler.h" +#include "fsfw/events/EventManagerIF.h" +#include "fsfw/ipc/QueueFactory.h" +#include "fsfw/objectmanager/ObjectManager.h" +#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface/serviceInterfaceDefintions.h" CCSDSHandler::CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination, - TxRateSetterIF* txRateSetterIF, GpioIF* gpioIF, gpioId_t enTxClock, gpioId_t enTxData) : - SystemObject(objectId), ptmeId(ptmeId), tcDestination(tcDestination), parameterHelper(this), actionHelper( - this, nullptr), txRateSetterIF(txRateSetterIF), gpioIF(gpioIF), enTxClock( - enTxClock), enTxData(enTxData) { - commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); - eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 2); + TxRateSetterIF* txRateSetterIF, GpioIF* gpioIF, gpioId_t enTxClock, + gpioId_t enTxData) + : SystemObject(objectId), + ptmeId(ptmeId), + tcDestination(tcDestination), + parameterHelper(this), + actionHelper(this, nullptr), + txRateSetterIF(txRateSetterIF), + gpioIF(gpioIF), + enTxClock(enTxClock), + enTxData(enTxData) { + commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); + eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 2); } -CCSDSHandler::~CCSDSHandler() { -} +CCSDSHandler::~CCSDSHandler() {} ReturnValue_t CCSDSHandler::performOperation(uint8_t operationCode) { - checkEvents(); - readCommandQueue(); - handleTelemetry(); - handleTelecommands(); - checkTxTimer(); - return RETURN_OK; + checkEvents(); + readCommandQueue(); + handleTelemetry(); + handleTelecommands(); + checkTxTimer(); + return RETURN_OK; } void CCSDSHandler::handleTelemetry() { - VirtualChannelMapIter iter; - for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { - iter->second->performOperation(); - } + VirtualChannelMapIter iter; + for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { + iter->second->performOperation(); + } } -void CCSDSHandler::handleTelecommands() { - -} +void CCSDSHandler::handleTelecommands() {} ReturnValue_t CCSDSHandler::initialize() { - ReturnValue_t result = RETURN_OK; - PtmeIF* ptme = ObjectManager::instance()->get(ptmeId); - if (ptme == nullptr) { - sif::warning << "Invalid PTME object" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + ReturnValue_t result = RETURN_OK; + PtmeIF* ptme = ObjectManager::instance()->get(ptmeId); + if (ptme == nullptr) { + sif::warning << "Invalid PTME object" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - AcceptsTelecommandsIF* tcDistributor = - ObjectManager::instance()->get(tcDestination); - if (tcDistributor == nullptr) { + AcceptsTelecommandsIF* tcDistributor = + ObjectManager::instance()->get(tcDestination); + if (tcDistributor == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "CCSDSHandler::initialize: Invalid TC Distributor object" << std::endl; + sif::error << "CCSDSHandler::initialize: Invalid TC Distributor object" << std::endl; #endif - return ObjectManagerIF::CHILD_INIT_FAILED; - } + return ObjectManagerIF::CHILD_INIT_FAILED; + } - tcDistributorQueueId = tcDistributor->getRequestQueue(); + tcDistributorQueueId = tcDistributor->getRequestQueue(); - result = parameterHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + result = parameterHelper.initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } - result = actionHelper.initialize(commandQueue); + result = actionHelper.initialize(commandQueue); + if (result != RETURN_OK) { + return result; + } + + VirtualChannelMapIter iter; + for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { + result = iter->second->initialize(); if (result != RETURN_OK) { - return result; + return result; } + iter->second->setPtmeObject(ptme); + } - VirtualChannelMapIter iter; - for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { - result = iter->second->initialize(); - if (result != RETURN_OK) { - return result; - } - iter->second->setPtmeObject(ptme); - } - - EventManagerIF* manager = ObjectManager::instance()->get( - objects::EVENT_MANAGER); - if (manager == nullptr) { + EventManagerIF* manager = ObjectManager::instance()->get(objects::EVENT_MANAGER); + if (manager == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "CCSDSHandler::initialize: Invalid event manager" << std::endl; + sif::error << "CCSDSHandler::initialize: Invalid event manager" << std::endl; #endif - return ObjectManagerIF::CHILD_INIT_FAILED; - } - result = manager->registerListener(eventQueue->getId()); - if (result != HasReturnvaluesIF::RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } + result = manager->registerListener(eventQueue->getId()); + if (result != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "CCSDSHandler::initialize: Failed to register CCSDS handler as event " - "listener" << std::endl; + sif::warning << "CCSDSHandler::initialize: Failed to register CCSDS handler as event " + "listener" + << std::endl; #endif - return ObjectManagerIF::CHILD_INIT_FAILED;; - } - result = manager->subscribeToEventRange(eventQueue->getId(), - event::getEventId(PdecHandler::CARRIER_LOCK), - event::getEventId(PdecHandler::BIT_LOCK_PDEC)); - if (result != HasReturnvaluesIF::RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + ; + } + result = manager->subscribeToEventRange(eventQueue->getId(), + event::getEventId(PdecHandler::CARRIER_LOCK), + event::getEventId(PdecHandler::BIT_LOCK_PDEC)); + if (result != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "CCSDSHandler::initialize: Failed to subscribe to events from PDEC " - "handler" << std::endl; + sif::error << "CCSDSHandler::initialize: Failed to subscribe to events from PDEC " + "handler" + << std::endl; #endif - return result; - } - return result; + return result; + } + return result; } void CCSDSHandler::readCommandQueue(void) { - CommandMessage commandMessage; - ReturnValue_t result = RETURN_FAILED; + CommandMessage commandMessage; + ReturnValue_t result = RETURN_FAILED; - result = commandQueue->receiveMessage(&commandMessage); + result = commandQueue->receiveMessage(&commandMessage); + if (result == RETURN_OK) { + result = parameterHelper.handleParameterMessage(&commandMessage); if (result == RETURN_OK) { - result = parameterHelper.handleParameterMessage(&commandMessage); - if (result == RETURN_OK) { - return; - } - result = actionHelper.handleActionMessage(&commandMessage); - if (result == RETURN_OK) { - return; - } - CommandMessage reply; - reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND, - commandMessage.getCommand()); - commandQueue->reply(&reply); - return; + return; } + result = actionHelper.handleActionMessage(&commandMessage); + if (result == RETURN_OK) { + return; + } + CommandMessage reply; + reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND, commandMessage.getCommand()); + commandQueue->reply(&reply); + return; + } } -MessageQueueId_t CCSDSHandler::getCommandQueue() const { - return commandQueue->getId(); -} +MessageQueueId_t CCSDSHandler::getCommandQueue() const { return commandQueue->getId(); } void CCSDSHandler::addVirtualChannel(VcId_t vcId, VirtualChannel* virtualChannel) { - if (vcId > common::NUMBER_OF_VIRTUAL_CHANNELS) { - sif::warning << "CCSDSHandler::addVirtualChannel: Invalid virtual channel ID" << std::endl; - return; - } + if (vcId > common::NUMBER_OF_VIRTUAL_CHANNELS) { + sif::warning << "CCSDSHandler::addVirtualChannel: Invalid virtual channel ID" << std::endl; + return; + } - if (virtualChannel == nullptr) { - sif::warning << "CCSDSHandler::addVirtualChannel: Invalid virtual channel interface" << std::endl; - return; - } + if (virtualChannel == nullptr) { + sif::warning << "CCSDSHandler::addVirtualChannel: Invalid virtual channel interface" + << std::endl; + return; + } - auto status = virtualChannelMap.emplace(vcId, virtualChannel); - if (status.second == false) { - sif::warning << "CCSDSHandler::addVirtualChannel: Failed to add virtual channel to " - "virtual channel map" << std::endl; - return; - } + auto status = virtualChannelMap.emplace(vcId, virtualChannel); + if (status.second == false) { + sif::warning << "CCSDSHandler::addVirtualChannel: Failed to add virtual channel to " + "virtual channel map" + << std::endl; + return; + } } MessageQueueId_t CCSDSHandler::getReportReceptionQueue(uint8_t virtualChannel) { - if (virtualChannel < common::NUMBER_OF_VIRTUAL_CHANNELS) { - VirtualChannelMapIter iter = virtualChannelMap.find(virtualChannel); - if (iter != virtualChannelMap.end()) { - return iter->second->getReportReceptionQueue(); - } - else { - sif::warning << "CCSDSHandler::getReportReceptionQueue: Virtual channel with ID " - << static_cast(virtualChannel) << " not in virtual channel map" - << std::endl; - return MessageQueueIF::NO_QUEUE; - } - } else { - sif::debug << "CCSDSHandler::getReportReceptionQueue: Invalid virtual channel requested"; - - } - return MessageQueueIF::NO_QUEUE; + if (virtualChannel < common::NUMBER_OF_VIRTUAL_CHANNELS) { + VirtualChannelMapIter iter = virtualChannelMap.find(virtualChannel); + if (iter != virtualChannelMap.end()) { + return iter->second->getReportReceptionQueue(); + } else { + sif::warning << "CCSDSHandler::getReportReceptionQueue: Virtual channel with ID " + << static_cast(virtualChannel) << " not in virtual channel map" + << std::endl; + return MessageQueueIF::NO_QUEUE; + } + } else { + sif::debug << "CCSDSHandler::getReportReceptionQueue: Invalid virtual channel requested"; + } + return MessageQueueIF::NO_QUEUE; } ReturnValue_t CCSDSHandler::getParameter(uint8_t domainId, uint8_t uniqueIdentifier, - ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues, - uint16_t startAtIndex) { - return RETURN_OK; + ParameterWrapper* parameterWrapper, + const ParameterWrapper* newValues, uint16_t startAtIndex) { + return RETURN_OK; } -uint16_t CCSDSHandler::getIdentifier() { - return 0; -} +uint16_t CCSDSHandler::getIdentifier() { return 0; } MessageQueueId_t CCSDSHandler::getRequestQueue() { - // Forward packets directly to TC distributor - return tcDistributorQueueId; + // Forward packets directly to TC distributor + return tcDistributorQueueId; } -ReturnValue_t CCSDSHandler::executeAction(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { - - switch(actionId) { +ReturnValue_t CCSDSHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) { + switch (actionId) { case SET_LOW_RATE: { - txRateSetterIF->setRate(BitRates::RATE_400KHZ); - return EXECUTION_FINISHED; + txRateSetterIF->setRate(BitRates::RATE_400KHZ); + return EXECUTION_FINISHED; } case SET_HIGH_RATE: { - txRateSetterIF->setRate(BitRates::RATE_2000KHZ); - return EXECUTION_FINISHED; + txRateSetterIF->setRate(BitRates::RATE_2000KHZ); + return EXECUTION_FINISHED; } case EN_TRANSMITTER: { - enableTransmit(); - return EXECUTION_FINISHED; + enableTransmit(); + return EXECUTION_FINISHED; } case DIS_TRANSMITTER: { - disableTransmit(); - return EXECUTION_FINISHED; + disableTransmit(); + return EXECUTION_FINISHED; } default: - return COMMAND_NOT_IMPLEMENTED; - } + return COMMAND_NOT_IMPLEMENTED; + } } void CCSDSHandler::checkEvents() { - EventMessage event; - for (ReturnValue_t result = eventQueue->receiveMessage(&event); - result == RETURN_OK; result = eventQueue->receiveMessage(&event)) { - switch (event.getMessageId()) { - case EventMessage::EVENT_MESSAGE: - handleEvent(&event); - break; - default: - sif::debug << "CCSDSHandler::checkEvents: Did not subscribe to this event message" - << std::endl; - break; - } + EventMessage event; + for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == RETURN_OK; + result = eventQueue->receiveMessage(&event)) { + switch (event.getMessageId()) { + case EventMessage::EVENT_MESSAGE: + handleEvent(&event); + break; + default: + sif::debug << "CCSDSHandler::checkEvents: Did not subscribe to this event message" + << std::endl; + break; } + } } - void CCSDSHandler::handleEvent(EventMessage* eventMessage) { - Event event = eventMessage->getEvent(); - switch(event){ + Event event = eventMessage->getEvent(); + switch (event) { case PdecHandler::BIT_LOCK_PDEC: { - handleBitLockEvent(); - break; + handleBitLockEvent(); + break; } case PdecHandler::CARRIER_LOCK: { - handleCarrierLockEvent(); - break; + handleCarrierLockEvent(); + break; } default: - sif::debug << "CCSDSHandler::handleEvent: Did not subscribe to this event" - << std::endl; - break; - } + sif::debug << "CCSDSHandler::handleEvent: Did not subscribe to this event" << std::endl; + break; + } } void CCSDSHandler::handleBitLockEvent() { - if(transmitterCountdown.isBusy()) { - // Transmitter already enabled - return; - } - enableTransmit(); + if (transmitterCountdown.isBusy()) { + // Transmitter already enabled + return; + } + enableTransmit(); } void CCSDSHandler::handleCarrierLockEvent() { - if (!enableTxWhenCarrierLock) { - return; - } - enableTransmit(); + if (!enableTxWhenCarrierLock) { + return; + } + enableTransmit(); } void CCSDSHandler::forwardLinkstate() { - VirtualChannelMapIter iter; - for(iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { - iter->second->setLinkState(linkState); - } + VirtualChannelMapIter iter; + for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { + iter->second->setLinkState(linkState); + } } void CCSDSHandler::enableTransmit() { - if(transmitterCountdown.isBusy()) { - // Transmitter already enabled - return; - } - transmitterCountdown.setTimeout(TRANSMITTER_TIMEOUT); + if (transmitterCountdown.isBusy()) { + // Transmitter already enabled + return; + } + transmitterCountdown.setTimeout(TRANSMITTER_TIMEOUT); #if BOARD_TE0720 == 0 - gpioIF->pullHigh(enTxClock); - gpioIF->pullHigh(enTxData); + gpioIF->pullHigh(enTxClock); + gpioIF->pullHigh(enTxData); #endif /* BOARD_TE0720 == 0 */ - linkState = UP; - // Set link state of all virtual channels to link up - forwardLinkstate(); + linkState = UP; + // Set link state of all virtual channels to link up + forwardLinkstate(); } void CCSDSHandler::checkTxTimer() { - if(linkState == DOWN) { - return; - } - if (transmitterCountdown.hasTimedOut()) { - disableTransmit(); - } + if (linkState == DOWN) { + return; + } + if (transmitterCountdown.hasTimedOut()) { + disableTransmit(); + } } void CCSDSHandler::disableTransmit() { #if BOARD_TE0720 == 0 - gpioIF->pullLow(enTxClock); - gpioIF->pullLow(enTxData); + gpioIF->pullLow(enTxClock); + gpioIF->pullLow(enTxData); #endif /* BOARD_TE0720 == 0 */ - linkState = DOWN; - forwardLinkstate(); - transmitterCountdown.setTimeout(0); + linkState = DOWN; + forwardLinkstate(); + transmitterCountdown.setTimeout(0); } diff --git a/mission/tmtc/CCSDSHandler.h b/mission/tmtc/CCSDSHandler.h index 6fb6168b..8203b807 100644 --- a/mission/tmtc/CCSDSHandler.h +++ b/mission/tmtc/CCSDSHandler.h @@ -1,22 +1,23 @@ #ifndef CCSDSHANDLER_H_ #define CCSDSHANDLER_H_ +#include + #include "OBSWConfig.h" -#include "fsfw/objectmanager/SystemObject.h" -#include "fsfw/tasks/ExecutableObjectIF.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" -#include "fsfw/tmtcservices/AcceptsTelemetryIF.h" -#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" -#include "fsfw/parameters/ParameterHelper.h" +#include "VirtualChannel.h" #include "fsfw/action/ActionHelper.h" #include "fsfw/action/HasActionsIF.h" -#include "fsfw/timemanager/Countdown.h" #include "fsfw/events/EventMessage.h" -#include "linux/obc/TxRateSetterIF.h" -#include "fsfw_hal/common/gpio/gpioDefinitions.h" +#include "fsfw/objectmanager/SystemObject.h" +#include "fsfw/parameters/ParameterHelper.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/tasks/ExecutableObjectIF.h" +#include "fsfw/timemanager/Countdown.h" +#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" +#include "fsfw/tmtcservices/AcceptsTelemetryIF.h" #include "fsfw_hal/common/gpio/GpioIF.h" -#include "VirtualChannel.h" -#include +#include "fsfw_hal/common/gpio/gpioDefinitions.h" +#include "linux/obc/TxRateSetterIF.h" /** * @brief This class handles the data exchange with the CCSDS IP cores implemented in the @@ -24,145 +25,144 @@ * * @author J. Meier */ -class CCSDSHandler: public SystemObject, - public ExecutableObjectIF, - public AcceptsTelemetryIF, - public AcceptsTelecommandsIF, - public HasReturnvaluesIF, - public ReceivesParameterMessagesIF, - public HasActionsIF { -public: +class CCSDSHandler : public SystemObject, + public ExecutableObjectIF, + public AcceptsTelemetryIF, + public AcceptsTelecommandsIF, + public HasReturnvaluesIF, + public ReceivesParameterMessagesIF, + public HasActionsIF { + public: + using VcId_t = uint8_t; - using VcId_t = uint8_t; + /** + * @brief Constructor + * + * @param objectId Object ID of the CCSDS handler + * @param ptmeId Object ID of the PTME object providing access to the PTME IP Core. + * @param tcDestination Object ID of object handling received TC space packets + * @param txRateSetter Object providing the functionality to switch the input bitrate of + * the S-Band transceiver. + * @param gpioIF Required to enable TX data and TX clock RS485 transceiver chips. + * @param enTxClock GPIO ID of RS485 tx clock enable + * @param enTxData GPIO ID of RS485 tx data enable + */ + CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination, + TxRateSetterIF* txRateSetterIF, GpioIF* gpioIF, gpioId_t enTxClock, + gpioId_t enTxData); - /** - * @brief Constructor - * - * @param objectId Object ID of the CCSDS handler - * @param ptmeId Object ID of the PTME object providing access to the PTME IP Core. - * @param tcDestination Object ID of object handling received TC space packets - * @param txRateSetter Object providing the functionality to switch the input bitrate of - * the S-Band transceiver. - * @param gpioIF Required to enable TX data and TX clock RS485 transceiver chips. - * @param enTxClock GPIO ID of RS485 tx clock enable - * @param enTxData GPIO ID of RS485 tx data enable - */ - CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination, - TxRateSetterIF* txRateSetterIF, GpioIF* gpioIF, gpioId_t enTxClock, gpioId_t enTxData); + ~CCSDSHandler(); - ~CCSDSHandler(); + ReturnValue_t performOperation(uint8_t operationCode = 0) override; + ReturnValue_t initialize(); + MessageQueueId_t getCommandQueue() const; - ReturnValue_t performOperation(uint8_t operationCode = 0) override; - ReturnValue_t initialize(); - MessageQueueId_t getCommandQueue() const; + /** + * @brief Function to add a virtual channel + * + * @param virtualChannelId ID of the virtual channel to add + * @param virtualChannel Pointer to virtual channel object + */ + void addVirtualChannel(VcId_t virtualChannelId, VirtualChannel* virtualChannel); - /** - * @brief Function to add a virtual channel - * - * @param virtualChannelId ID of the virtual channel to add - * @param virtualChannel Pointer to virtual channel object - */ - void addVirtualChannel(VcId_t virtualChannelId, VirtualChannel* virtualChannel); + MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0); + ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueIdentifier, + ParameterWrapper* parameterWrapper, const ParameterWrapper* newValues, + uint16_t startAtIndex); - MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0); - ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueIdentifier, - ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues, - uint16_t startAtIndex); + uint16_t getIdentifier() override; + MessageQueueId_t getRequestQueue() override; - uint16_t getIdentifier() override; - MessageQueueId_t getRequestQueue() override; + virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size); - virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size); + private: + static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_HANDLER; -private: + static const uint32_t QUEUE_SIZE = common::CCSDS_HANDLER_QUEUE_SIZE; - static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_HANDLER; + static const ActionId_t SET_LOW_RATE = 0; + static const ActionId_t SET_HIGH_RATE = 1; + static const ActionId_t EN_TRANSMITTER = 2; + static const ActionId_t DIS_TRANSMITTER = 3; - static const uint32_t QUEUE_SIZE = common::CCSDS_HANDLER_QUEUE_SIZE; - - static const ActionId_t SET_LOW_RATE = 0; - static const ActionId_t SET_HIGH_RATE = 1; - static const ActionId_t EN_TRANSMITTER = 2; - static const ActionId_t DIS_TRANSMITTER = 3; - - //! [EXPORT] : [COMMENT] Received action message with unknown action id - static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xA0); + //! [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 + // 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 /* TMTC_TEST_SETUP == 0 */ - static const bool UP = true; - static const bool DOWN = false; + static const bool UP = true; + static const bool DOWN = false; - using VirtualChannelMap = std::unordered_map; - using VirtualChannelMapIter = VirtualChannelMap::iterator; + using VirtualChannelMap = std::unordered_map; + using VirtualChannelMapIter = VirtualChannelMap::iterator; - VirtualChannelMap virtualChannelMap; + VirtualChannelMap virtualChannelMap; - // Object ID of PTME object - object_id_t ptmeId; + // Object ID of PTME object + object_id_t ptmeId; - object_id_t tcDestination; + object_id_t tcDestination; - MessageQueueIF* commandQueue = nullptr; - MessageQueueIF* eventQueue = nullptr; + MessageQueueIF* commandQueue = nullptr; + MessageQueueIF* eventQueue = nullptr; - ParameterHelper parameterHelper; + ParameterHelper parameterHelper; - ActionHelper actionHelper; + ActionHelper actionHelper; - MessageQueueId_t tcDistributorQueueId; + MessageQueueId_t tcDistributorQueueId; - TxRateSetterIF* txRateSetterIF = nullptr; + TxRateSetterIF* txRateSetterIF = nullptr; - GpioIF* gpioIF = nullptr; - gpioId_t enTxClock = gpio::NO_GPIO; - gpioId_t enTxData = gpio::NO_GPIO; + GpioIF* gpioIF = nullptr; + gpioId_t enTxClock = gpio::NO_GPIO; + gpioId_t enTxData = gpio::NO_GPIO; - // Countdown to disable transmitter after 15 minutes - Countdown transmitterCountdown; + // Countdown to disable transmitter after 15 minutes + Countdown transmitterCountdown; - // When true transmitting is started as soon as carrier lock has been detected - bool enableTxWhenCarrierLock = false; + // When true transmitting is started as soon as carrier lock has been detected + bool enableTxWhenCarrierLock = false; - bool linkState = DOWN; + bool linkState = DOWN; - void readCommandQueue(void); - void handleTelemetry(); - void handleTelecommands(); - void checkEvents(); - void handleEvent(EventMessage* eventMessage); + void readCommandQueue(void); + void handleTelemetry(); + void handleTelecommands(); + void checkEvents(); + void handleEvent(EventMessage* eventMessage); - void handleBitLockEvent(); - void handleCarrierLockEvent(); + void handleBitLockEvent(); + void handleCarrierLockEvent(); - /** - * @brief Forward link state to virtual channels. - */ - void forwardLinkstate(); + /** + * @brief Forward link state to virtual channels. + */ + void forwardLinkstate(); - /** - * @brief Starts transmit timer and enables transmitter. - */ - void enableTransmit(); + /** + * @brief Starts transmit timer and enables transmitter. + */ + void enableTransmit(); - /** - * @brief Checks Tx timer for timeout and disables RS485 tx clock and tx data in case - * timer has expired. - */ - void checkTxTimer(); + /** + * @brief Checks Tx timer for timeout and disables RS485 tx clock and tx data in case + * timer has expired. + */ + void checkTxTimer(); - /** - * @brief Disables the transmitter by pulling the enable tx clock and tx data pin of the - * RS485 transceiver chips to high. - */ - void disableTransmit(); + /** + * @brief Disables the transmitter by pulling the enable tx clock and tx data pin of the + * RS485 transceiver chips to high. + */ + void disableTransmit(); }; #endif /* CCSDSHANDLER_H_ */ diff --git a/mission/tmtc/VirtualChannel.cpp b/mission/tmtc/VirtualChannel.cpp index 0273f5ce..5b9387fd 100644 --- a/mission/tmtc/VirtualChannel.cpp +++ b/mission/tmtc/VirtualChannel.cpp @@ -1,69 +1,65 @@ -#include "CCSDSHandler.h" #include "VirtualChannel.h" + +#include "CCSDSHandler.h" #include "OBSWConfig.h" - -#include "fsfw/serviceinterface/ServiceInterfaceStream.h" -#include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/tmtcservices/TmTcMessage.h" #include "fsfw/ipc/QueueFactory.h" +#include "fsfw/objectmanager/ObjectManager.h" +#include "fsfw/serviceinterface/ServiceInterfaceStream.h" +#include "fsfw/tmtcservices/TmTcMessage.h" - -VirtualChannel::VirtualChannel(uint8_t vcId, uint32_t tmQueueDepth) : - vcId(vcId) { - tmQueue = QueueFactory::instance()->createMessageQueue(tmQueueDepth, - MessageQueueMessage::MAX_MESSAGE_SIZE); +VirtualChannel::VirtualChannel(uint8_t vcId, uint32_t tmQueueDepth) : vcId(vcId) { + tmQueue = QueueFactory::instance()->createMessageQueue(tmQueueDepth, + MessageQueueMessage::MAX_MESSAGE_SIZE); } ReturnValue_t VirtualChannel::initialize() { - tmStore = ObjectManager::instance()->get(objects::TM_STORE); - if(tmStore == nullptr) { - sif::error << "VirtualChannel::initialize: Failed to get tm store" << std::endl; - return RETURN_FAILED; - } - return RETURN_OK; + tmStore = ObjectManager::instance()->get(objects::TM_STORE); + if (tmStore == nullptr) { + sif::error << "VirtualChannel::initialize: Failed to get tm store" << std::endl; + return RETURN_FAILED; + } + return RETURN_OK; } ReturnValue_t VirtualChannel::performOperation() { - ReturnValue_t result = RETURN_OK; - TmTcMessage message; + ReturnValue_t result = RETURN_OK; + TmTcMessage message; - while(tmQueue->receiveMessage(&message) == RETURN_OK) { - store_address_t storeId = message.getStorageId(); - const uint8_t* data = nullptr; - size_t size = 0; - result = tmStore->getData(storeId, &data, &size); - if (result != RETURN_OK) { - sif::warning << "VirtualChannel::performOperation: Failed to read data from IPC store" - << std::endl; - tmStore->deleteData(storeId); - return result; - } + while (tmQueue->receiveMessage(&message) == RETURN_OK) { + store_address_t storeId = message.getStorageId(); + const uint8_t* data = nullptr; + size_t size = 0; + result = tmStore->getData(storeId, &data, &size); + if (result != RETURN_OK) { + sif::warning << "VirtualChannel::performOperation: Failed to read data from IPC store" + << std::endl; + tmStore->deleteData(storeId); + return result; + } - if (linkIsUp) { - result = ptme->writeToVc(vcId, data, size); - } + if (linkIsUp) { + result = ptme->writeToVc(vcId, data, size); + } - tmStore->deleteData(storeId); + tmStore->deleteData(storeId); - if (result != RETURN_OK) { - return result; - } - } - return result; + if (result != RETURN_OK) { + return result; + } + } + return result; } MessageQueueId_t VirtualChannel::getReportReceptionQueue(uint8_t virtualChannel) { - return tmQueue->getId(); + return tmQueue->getId(); } void VirtualChannel::setPtmeObject(PtmeIF* ptme_) { - if (ptme_ == nullptr) { - sif::warning << "VirtualChannel::setPtmeObject: Invalid ptme object" << std::endl; - return; - } - ptme = ptme_; + if (ptme_ == nullptr) { + sif::warning << "VirtualChannel::setPtmeObject: Invalid ptme object" << std::endl; + return; + } + ptme = ptme_; } -void VirtualChannel::setLinkState(bool linkIsUp_) { - linkIsUp = linkIsUp_; -} +void VirtualChannel::setLinkState(bool linkIsUp_) { linkIsUp = linkIsUp_; } diff --git a/mission/tmtc/VirtualChannel.h b/mission/tmtc/VirtualChannel.h index 213a3421..48cc74a4 100644 --- a/mission/tmtc/VirtualChannel.h +++ b/mission/tmtc/VirtualChannel.h @@ -1,12 +1,13 @@ #ifndef VIRTUALCHANNEL_H_ #define VIRTUALCHANNEL_H_ -#include "OBSWConfig.h" -#include "fsfw/tmtcservices/AcceptsTelemetryIF.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include #include +#include "OBSWConfig.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/tmtcservices/AcceptsTelemetryIF.h" + class StorageManagerIF; /** @@ -15,42 +16,41 @@ class StorageManagerIF; * * @author J. Meier */ -class VirtualChannel: public AcceptsTelemetryIF, public HasReturnvaluesIF { - public: - /** - * @brief Constructor - * - * @param vcId The virtual channel id assigned to this object - * @param tmQueueDepth Queue depth of queue receiving telemetry from other objects - */ - VirtualChannel(uint8_t vcId, uint32_t tmQueueDepth); +class VirtualChannel : public AcceptsTelemetryIF, public HasReturnvaluesIF { + public: + /** + * @brief Constructor + * + * @param vcId The virtual channel id assigned to this object + * @param tmQueueDepth Queue depth of queue receiving telemetry from other objects + */ + VirtualChannel(uint8_t vcId, uint32_t tmQueueDepth); - ReturnValue_t initialize(); - MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) override; - ReturnValue_t performOperation(); + ReturnValue_t initialize(); + MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) override; + ReturnValue_t performOperation(); - /** - * @brief Sets the PTME object which handles access to the PTME IP Core. - * - * @param ptme Pointer to ptme object - */ - void setPtmeObject(PtmeIF* ptme_); + /** + * @brief Sets the PTME object which handles access to the PTME IP Core. + * + * @param ptme Pointer to ptme object + */ + void setPtmeObject(PtmeIF* ptme_); - /** - * @brief Can be used by the owner to set the link state. Packets will be discarded if link - * to ground station is down. - */ - void setLinkState(bool linkIsUp_); + /** + * @brief Can be used by the owner to set the link state. Packets will be discarded if link + * to ground station is down. + */ + void setLinkState(bool linkIsUp_); -private: + private: + PtmeIF* ptme = nullptr; + MessageQueueIF* tmQueue = nullptr; + uint8_t vcId; - PtmeIF* ptme = nullptr; - MessageQueueIF* tmQueue = nullptr; - uint8_t vcId; + bool linkIsUp = false; - bool linkIsUp = false; - - StorageManagerIF* tmStore = nullptr; + StorageManagerIF* tmStore = nullptr; }; #endif /* VIRTUALCHANNEL_H_ */ diff --git a/mission/utility/InitMission.h b/mission/utility/InitMission.h index b4a83a1e..dc131981 100644 --- a/mission/utility/InitMission.h +++ b/mission/utility/InitMission.h @@ -8,15 +8,15 @@ namespace initmission { void printAddObjectError(const char* name, object_id_t objectId) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "InitMission::printAddError: Adding object " << name << " with object ID 0x" - << std::hex << std::setfill('0') << std::setw(8) << objectId - << " failed!" << std::dec << std::endl; + sif::error << "InitMission::printAddError: Adding object " << name << " with object ID 0x" + << std::hex << std::setfill('0') << std::setw(8) << objectId << " failed!" << std::dec + << std::endl; #else - sif::printError("InitMission::printAddError: Adding object %s with object ID 0x%08x failed!\n" , - name, objectId); + sif::printError("InitMission::printAddError: Adding object %s with object ID 0x%08x failed!\n", + name, objectId); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ } -} +} // namespace initmission #endif /* MISSION_UTILITY_INITMISSION_H_ */ diff --git a/mission/utility/Timestamp.cpp b/mission/utility/Timestamp.cpp index c0848a59..095bd28c 100644 --- a/mission/utility/Timestamp.cpp +++ b/mission/utility/Timestamp.cpp @@ -1,28 +1,22 @@ #include "Timestamp.h" + #include "fsfw/serviceinterface/ServiceInterfaceStream.h" Timestamp::Timestamp() { - ReturnValue_t result = Clock::getDateAndTime(&time); - if (result != RETURN_OK) { - sif::warning << "Timestamp::Timestamp: Failed to get time" << std::endl; - } + ReturnValue_t result = Clock::getDateAndTime(&time); + if (result != RETURN_OK) { + sif::warning << "Timestamp::Timestamp: Failed to get time" << std::endl; + } } -Timestamp::~Timestamp() { -} +Timestamp::~Timestamp() {} std::string Timestamp::str() { - timestamp << std::to_string(time.year) << "-" - << std::setw(2) << std::setfill('0') - << std::to_string(time.month) << "-" - << std::setw(2) << std::setfill('0') - << std::to_string(time.day) << "--" - << std::setw(2) << std::setfill('0') - << std::to_string(time.hour) << "-" - << std::setw(2) << std::setfill('0') - << std::to_string(time.minute) << "-" - << std::setw(2) << std::setfill('0') - << std::to_string(time.second) << "--"; - return timestamp.str(); + timestamp << std::to_string(time.year) << "-" << std::setw(2) << std::setfill('0') + << std::to_string(time.month) << "-" << std::setw(2) << std::setfill('0') + << std::to_string(time.day) << "--" << std::setw(2) << std::setfill('0') + << std::to_string(time.hour) << "-" << std::setw(2) << std::setfill('0') + << std::to_string(time.minute) << "-" << std::setw(2) << std::setfill('0') + << std::to_string(time.second) << "--"; + return timestamp.str(); } - diff --git a/mission/utility/Timestamp.h b/mission/utility/Timestamp.h index 7146de53..4f783437 100644 --- a/mission/utility/Timestamp.h +++ b/mission/utility/Timestamp.h @@ -1,11 +1,12 @@ #ifndef MISSION_UTILITY_TIMESTAMP_H_ #define MISSION_UTILITY_TIMESTAMP_H_ -#include -#include #include -#include "fsfw/timemanager/Clock.h" +#include +#include + #include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/timemanager/Clock.h" /** * @brief This class generates timestamps for files. @@ -13,18 +14,18 @@ * @author J. Meier */ class Timestamp : public HasReturnvaluesIF { -public: - Timestamp(); - virtual ~Timestamp(); + public: + Timestamp(); + virtual ~Timestamp(); - /** - * @brief Returns the timestamp string - */ - std::string str(); + /** + * @brief Returns the timestamp string + */ + std::string str(); -private: - std::stringstream timestamp; - Clock::TimeOfDay_t time; + private: + std::stringstream timestamp; + Clock::TimeOfDay_t time; }; #endif /* MISSION_UTILITY_TIMESTAMP_H_ */ diff --git a/mission/utility/TmFunnel.cpp b/mission/utility/TmFunnel.cpp index 4b9eebdf..5577f5fa 100644 --- a/mission/utility/TmFunnel.cpp +++ b/mission/utility/TmFunnel.cpp @@ -1,122 +1,118 @@ -#include "OBSWConfig.h" #include -#include #include #include +#include #include +#include "OBSWConfig.h" + object_id_t TmFunnel::downlinkDestination = objects::NO_OBJECT; object_id_t TmFunnel::storageDestination = objects::NO_OBJECT; -TmFunnel::TmFunnel(object_id_t objectId, uint32_t messageDepth): - SystemObject(objectId), messageDepth(messageDepth) { - tmQueue = QueueFactory::instance()->createMessageQueue(messageDepth, - MessageQueueMessage::MAX_MESSAGE_SIZE); - storageQueue = QueueFactory::instance()->createMessageQueue(messageDepth, - MessageQueueMessage::MAX_MESSAGE_SIZE); +TmFunnel::TmFunnel(object_id_t objectId, uint32_t messageDepth) + : SystemObject(objectId), messageDepth(messageDepth) { + tmQueue = QueueFactory::instance()->createMessageQueue(messageDepth, + MessageQueueMessage::MAX_MESSAGE_SIZE); + storageQueue = QueueFactory::instance()->createMessageQueue( + messageDepth, MessageQueueMessage::MAX_MESSAGE_SIZE); } -TmFunnel::~TmFunnel() { -} +TmFunnel::~TmFunnel() {} MessageQueueId_t TmFunnel::getReportReceptionQueue(uint8_t virtualChannel) { - return tmQueue->getId(); + return tmQueue->getId(); } ReturnValue_t TmFunnel::performOperation(uint8_t operationCode) { - TmTcMessage currentMessage; - ReturnValue_t status = tmQueue->receiveMessage(¤tMessage); - while(status == HasReturnvaluesIF::RETURN_OK) - { - status = handlePacket(¤tMessage); - if(status != HasReturnvaluesIF::RETURN_OK){ - break; - } - status = tmQueue->receiveMessage(¤tMessage); - } + TmTcMessage currentMessage; + ReturnValue_t status = tmQueue->receiveMessage(¤tMessage); + while (status == HasReturnvaluesIF::RETURN_OK) { + status = handlePacket(¤tMessage); + if (status != HasReturnvaluesIF::RETURN_OK) { + break; + } + status = tmQueue->receiveMessage(¤tMessage); + } - if (status == MessageQueueIF::EMPTY) { - return HasReturnvaluesIF::RETURN_OK; - } - else { - return status; - } + if (status == MessageQueueIF::EMPTY) { + return HasReturnvaluesIF::RETURN_OK; + } else { + return status; + } } ReturnValue_t TmFunnel::handlePacket(TmTcMessage* message) { - uint8_t* packetData = nullptr; - size_t size = 0; - ReturnValue_t result = tmStore->modifyData(message->getStorageId(), - &packetData, &size); - if(result != HasReturnvaluesIF::RETURN_OK){ - return result; - } - TmPacketPusC packet(packetData); - packet.setPacketSequenceCount(this->sourceSequenceCount); - sourceSequenceCount++; - sourceSequenceCount = sourceSequenceCount % - SpacePacketBase::LIMIT_SEQUENCE_COUNT; - packet.setErrorControl(); + uint8_t* packetData = nullptr; + size_t size = 0; + ReturnValue_t result = tmStore->modifyData(message->getStorageId(), &packetData, &size); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + TmPacketPusC packet(packetData); + packet.setPacketSequenceCount(this->sourceSequenceCount); + sourceSequenceCount++; + sourceSequenceCount = sourceSequenceCount % SpacePacketBase::LIMIT_SEQUENCE_COUNT; + packet.setErrorControl(); - result = tmQueue->sendToDefault(message); - if(result != HasReturnvaluesIF::RETURN_OK){ - tmStore->deleteData(message->getStorageId()); - sif::error << "TmFunnel::handlePacket: Error sending to downlink " - "handler" << std::endl; - return result; - } + result = tmQueue->sendToDefault(message); + if (result != HasReturnvaluesIF::RETURN_OK) { + tmStore->deleteData(message->getStorageId()); + sif::error << "TmFunnel::handlePacket: Error sending to downlink " + "handler" + << std::endl; + return result; + } - if(storageDestination != objects::NO_OBJECT) { - result = storageQueue->sendToDefault(message); - if(result != HasReturnvaluesIF::RETURN_OK){ - tmStore->deleteData(message->getStorageId()); - sif::error << "TmFunnel::handlePacket: Error sending to storage " - "handler" << std::endl; - return result; - } - } - return result; + if (storageDestination != objects::NO_OBJECT) { + result = storageQueue->sendToDefault(message); + if (result != HasReturnvaluesIF::RETURN_OK) { + tmStore->deleteData(message->getStorageId()); + sif::error << "TmFunnel::handlePacket: Error sending to storage " + "handler" + << std::endl; + return result; + } + } + return result; } ReturnValue_t TmFunnel::initialize() { + tmStore = ObjectManager::instance()->get(objects::TM_STORE); + if (tmStore == nullptr) { + sif::error << "TmFunnel::initialize: TM store not set." << std::endl; + sif::error << "Make sure the tm store is set up properly" + " and implements StorageManagerIF" + << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - tmStore = ObjectManager::instance()->get(objects::TM_STORE); - if(tmStore == nullptr) { - sif::error << "TmFunnel::initialize: TM store not set." - << std::endl; - sif::error << "Make sure the tm store is set up properly" - " and implements StorageManagerIF" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } - - AcceptsTelemetryIF* tmTarget = - ObjectManager::instance()->get(downlinkDestination); - if(tmTarget == nullptr){ - sif::error << "TmFunnel::initialize: Downlink Destination not set." - << std::endl; - sif::error << "Make sure the downlink destination object is set up " - "properly and implements AcceptsTelemetryIF" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + AcceptsTelemetryIF* tmTarget = + ObjectManager::instance()->get(downlinkDestination); + if (tmTarget == nullptr) { + sif::error << "TmFunnel::initialize: Downlink Destination not set." << std::endl; + sif::error << "Make sure the downlink destination object is set up " + "properly and implements AcceptsTelemetryIF" + << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } #if OBSW_TM_TO_PTME == 1 - // Live TM will be sent via the virtual channel 0 - tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue(config::LIVE_TM)); + // Live TM will be sent via the virtual channel 0 + tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue(config::LIVE_TM)); #else - tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue()); + tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue()); #endif /* OBSW_TM_TO_PTME == 1 */ - // Storage destination is optional. - if(storageDestination == objects::NO_OBJECT) { - return SystemObject::initialize(); - } + // Storage destination is optional. + if (storageDestination == objects::NO_OBJECT) { + return SystemObject::initialize(); + } - AcceptsTelemetryIF* storageTarget = - ObjectManager::instance()->get(storageDestination); - if(storageTarget != nullptr) { - storageQueue->setDefaultDestination( - storageTarget->getReportReceptionQueue()); - } + AcceptsTelemetryIF* storageTarget = + ObjectManager::instance()->get(storageDestination); + if (storageTarget != nullptr) { + storageQueue->setDefaultDestination(storageTarget->getReportReceptionQueue()); + } - return SystemObject::initialize(); + return SystemObject::initialize(); } diff --git a/mission/utility/TmFunnel.h b/mission/utility/TmFunnel.h index b85a09e0..013e0ebc 100644 --- a/mission/utility/TmFunnel.h +++ b/mission/utility/TmFunnel.h @@ -1,13 +1,13 @@ #ifndef MISSION_UTILITY_TMFUNNEL_H_ #define MISSION_UTILITY_TMFUNNEL_H_ +#include #include #include #include -#include #include -namespace Factory{ +namespace Factory { void setStaticFrameworkObjectIds(); } @@ -19,32 +19,30 @@ void setStaticFrameworkObjectIds(); * @ingroup utility * @author J. Meier */ -class TmFunnel: public AcceptsTelemetryIF, - public ExecutableObjectIF, - public SystemObject { - friend void (Factory::setStaticFrameworkObjectIds)(); -public: - TmFunnel(object_id_t objectId, uint32_t messageDepth = 20); - virtual ~TmFunnel(); +class TmFunnel : public AcceptsTelemetryIF, public ExecutableObjectIF, public SystemObject { + friend void(Factory::setStaticFrameworkObjectIds)(); - virtual MessageQueueId_t getReportReceptionQueue( - uint8_t virtualChannel = 0) override; - virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; - virtual ReturnValue_t initialize() override; + public: + TmFunnel(object_id_t objectId, uint32_t messageDepth = 20); + virtual ~TmFunnel(); -protected: - static object_id_t downlinkDestination; - static object_id_t storageDestination; + virtual MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) override; + virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; + virtual ReturnValue_t initialize() override; -private: - uint16_t sourceSequenceCount = 0; - MessageQueueIF* tmQueue = nullptr; - MessageQueueIF* storageQueue = nullptr; + protected: + static object_id_t downlinkDestination; + static object_id_t storageDestination; - StorageManagerIF* tmStore = nullptr; - uint32_t messageDepth = 0; + private: + uint16_t sourceSequenceCount = 0; + MessageQueueIF* tmQueue = nullptr; + MessageQueueIF* storageQueue = nullptr; - ReturnValue_t handlePacket(TmTcMessage* message); + StorageManagerIF* tmStore = nullptr; + uint32_t messageDepth = 0; + + ReturnValue_t handlePacket(TmTcMessage* message); }; #endif /* MISSION_UTILITY_TMFUNNEL_H_ */ diff --git a/test/DummyParameter.h b/test/DummyParameter.h index b8da7275..410f0958 100644 --- a/test/DummyParameter.h +++ b/test/DummyParameter.h @@ -1,26 +1,24 @@ #ifndef BSP_Q7S_CORE_NVMPARAMS_PARAMETERDEFINITIONS_H_ #define BSP_Q7S_CORE_NVMPARAMS_PARAMETERDEFINITIONS_H_ -#include "mission/memory/NVMParameterBase.h" +#include #include -#include +#include "mission/memory/NVMParameterBase.h" -class DummyParameter: public NVMParameterBase { -public: - static constexpr char DUMMY_KEY_PARAM_1[] = "dummy1"; - static constexpr char DUMMY_KEY_PARAM_2[] = "dummy2"; +class DummyParameter : public NVMParameterBase { + public: + static constexpr char DUMMY_KEY_PARAM_1[] = "dummy1"; + static constexpr char DUMMY_KEY_PARAM_2[] = "dummy2"; - DummyParameter(std::string mountPrefix, std::string jsonFileName): - NVMParameterBase(mountPrefix + "/conf/" + jsonFileName), - mountPrefix(mountPrefix) { - insertValue(DUMMY_KEY_PARAM_1, 1); - insertValue(DUMMY_KEY_PARAM_2, "blablub"); - } + DummyParameter(std::string mountPrefix, std::string jsonFileName) + : NVMParameterBase(mountPrefix + "/conf/" + jsonFileName), mountPrefix(mountPrefix) { + insertValue(DUMMY_KEY_PARAM_1, 1); + insertValue(DUMMY_KEY_PARAM_2, "blablub"); + } -private: - std::string mountPrefix; + private: + std::string mountPrefix; }; - #endif /* BSP_Q7S_CORE_NVMPARAMS_PARAMETERDEFINITIONS_H_ */ diff --git a/test/testtasks/PusTcInjector.cpp b/test/testtasks/PusTcInjector.cpp index 90f2ac75..82b1cb1c 100644 --- a/test/testtasks/PusTcInjector.cpp +++ b/test/testtasks/PusTcInjector.cpp @@ -1,29 +1,29 @@ -#include - +#include +#include #include +#include +#include #include #include -#include -#include -#include -#include +#include -PusTcInjector::PusTcInjector(object_id_t objectId, object_id_t destination, - object_id_t tcStore, uint16_t defaultApid): SystemObject(objectId), - defaultApid(defaultApid), destination(destination), tcStoreId(tcStore) { -} +PusTcInjector::PusTcInjector(object_id_t objectId, object_id_t destination, object_id_t tcStore, + uint16_t defaultApid) + : SystemObject(objectId), + defaultApid(defaultApid), + destination(destination), + tcStoreId(tcStore) {} -PusTcInjector::~PusTcInjector() { -} +PusTcInjector::~PusTcInjector() {} -//ReturnValue_t PusTcInjector::injectPusTelecommand(uint8_t service, +// ReturnValue_t PusTcInjector::injectPusTelecommand(uint8_t service, // uint8_t subservice,const uint8_t* appData, size_t appDataLen) { // return injectPusTelecommand(service, subservice, defaultApid, appData, // appDataLen); -//} +// } // TODO: ACK flags -//ReturnValue_t PusTcInjector::injectPusTelecommand(uint8_t service, +// ReturnValue_t PusTcInjector::injectPusTelecommand(uint8_t service, // uint8_t subservice,uint16_t apid, const uint8_t* appData, // size_t appDataLen) { // // Prepare TC packet. Store into TC store immediately. @@ -44,24 +44,22 @@ PusTcInjector::~PusTcInjector() { //} ReturnValue_t PusTcInjector::initialize() { - // Prepare message queue which is used to send telecommands. - injectionQueue = QueueFactory::instance()-> - createMessageQueue(INJECTION_QUEUE_DEPTH); - AcceptsTelecommandsIF* targetQueue = ObjectManager::instance()-> - get(destination); - if(targetQueue == nullptr) { - sif::error << "PusTcInjector: CCSDS distributor not initialized yet!" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } - else { - injectionQueue->setDefaultDestination(targetQueue->getRequestQueue()); - } + // Prepare message queue which is used to send telecommands. + injectionQueue = QueueFactory::instance()->createMessageQueue(INJECTION_QUEUE_DEPTH); + AcceptsTelecommandsIF* targetQueue = + ObjectManager::instance()->get(destination); + if (targetQueue == nullptr) { + sif::error << "PusTcInjector: CCSDS distributor not initialized yet!" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } else { + injectionQueue->setDefaultDestination(targetQueue->getRequestQueue()); + } - // Prepare store used to store TC messages - tcStore = ObjectManager::instance()->get(tcStoreId); - if(tcStore == nullptr) { - sif::error << "PusTcInjector: TC Store not initialized!" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + // Prepare store used to store TC messages + tcStore = ObjectManager::instance()->get(tcStoreId); + if (tcStore == nullptr) { + sif::error << "PusTcInjector: TC Store not initialized!" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } diff --git a/test/testtasks/PusTcInjector.h b/test/testtasks/PusTcInjector.h index df67e403..4d1cea7e 100644 --- a/test/testtasks/PusTcInjector.h +++ b/test/testtasks/PusTcInjector.h @@ -3,70 +3,71 @@ #include #include #include + #include -class PusTcInjector: public SystemObject { -public: - static constexpr uint8_t INJECTION_QUEUE_DEPTH = 10; - const uint16_t defaultApid; +class PusTcInjector : public SystemObject { + public: + static constexpr uint8_t INJECTION_QUEUE_DEPTH = 10; + const uint16_t defaultApid; - /** - * Initialize a software telecommand injector by supplying object IDs to - * various helper objects which must exist before calling initialiez() - * @param objectId ID of PUS telecommand injector - * @param destination ID of destination, which has to implement - * AcceptsTelecommandIF. - * @param tcStore ID of telecommand store, which has to implement - * StorageManagerIF. - * @param defaultApid Default APID which will be used if an injection - * without an APID is requested. - */ - PusTcInjector(object_id_t objectId, object_id_t destination, - object_id_t tcStore, uint16_t defaultApid); - /** - * This has to be called before using the PusTcInjector. - * Call Not necessary when using a factory and the object manager. - * @return -@c RETURN_OK for successfull init - * -@c ObjectManagerIF::CHILD_INIT_FAILED otherwise - */ - ReturnValue_t initialize() override; + /** + * Initialize a software telecommand injector by supplying object IDs to + * various helper objects which must exist before calling initialiez() + * @param objectId ID of PUS telecommand injector + * @param destination ID of destination, which has to implement + * AcceptsTelecommandIF. + * @param tcStore ID of telecommand store, which has to implement + * StorageManagerIF. + * @param defaultApid Default APID which will be used if an injection + * without an APID is requested. + */ + PusTcInjector(object_id_t objectId, object_id_t destination, object_id_t tcStore, + uint16_t defaultApid); + /** + * This has to be called before using the PusTcInjector. + * Call Not necessary when using a factory and the object manager. + * @return -@c RETURN_OK for successfull init + * -@c ObjectManagerIF::CHILD_INIT_FAILED otherwise + */ + ReturnValue_t initialize() override; - virtual~ PusTcInjector(); + virtual ~PusTcInjector(); - /** - * Can be used to inject a telecommand by supplying service, subservice - * and optional application data and its length. - * Default APID will be used. - * @param service PUS service type - * @param subservice PUS subservice type - * @param appData Pointer to application data - * @param appDataLen Length of application data - * @return - */ - //ReturnValue_t injectPusTelecommand(uint8_t service, uint8_t subservice, - // const uint8_t* appData = nullptr, size_t appDataLen = 0); + /** + * Can be used to inject a telecommand by supplying service, subservice + * and optional application data and its length. + * Default APID will be used. + * @param service PUS service type + * @param subservice PUS subservice type + * @param appData Pointer to application data + * @param appDataLen Length of application data + * @return + */ + // ReturnValue_t injectPusTelecommand(uint8_t service, uint8_t subservice, + // const uint8_t* appData = nullptr, size_t appDataLen = 0); - /** - * Provides the same functionality while also setting a user defined APID. - * @param service PUS service type - * @param subservice PUS subservice type - * @param apid Custom APID to, - * @param appData Pointer to application data - * @param appDataLen Length of application data - * @return - */ - //ReturnValue_t injectPusTelecommand(uint8_t service, uint8_t subservice, - // uint16_t apid, const uint8_t* appData = nullptr, - // size_t appDataLen = 0); -private: - MessageQueueIF* injectionQueue = nullptr; - StorageManagerIF *tcStore = nullptr; + /** + * Provides the same functionality while also setting a user defined APID. + * @param service PUS service type + * @param subservice PUS subservice type + * @param apid Custom APID to, + * @param appData Pointer to application data + * @param appDataLen Length of application data + * @return + */ + // ReturnValue_t injectPusTelecommand(uint8_t service, uint8_t subservice, + // uint16_t apid, const uint8_t* appData = nullptr, + // size_t appDataLen = 0); + private: + MessageQueueIF* injectionQueue = nullptr; + StorageManagerIF* tcStore = nullptr; - /* Cached for initialize function */ - object_id_t destination = 0; - object_id_t tcStoreId = 0; + /* Cached for initialize function */ + object_id_t destination = 0; + object_id_t tcStoreId = 0; - uint16_t sequenceCount = 0; + uint16_t sequenceCount = 0; }; #endif /* TEST_TESTTASKS_PUSTCINJECTOR_H_ */ diff --git a/test/testtasks/TestTask.cpp b/test/testtasks/TestTask.cpp index 6a90cc08..911767af 100644 --- a/test/testtasks/TestTask.cpp +++ b/test/testtasks/TestTask.cpp @@ -1,45 +1,43 @@ #include "TestTask.h" -#include "OBSWConfig.h" +#include +#include #include #include -#include #include -#include #include #include +#include "OBSWConfig.h" -EiveTestTask::EiveTestTask(object_id_t objectId_): TestTask(objectId_), testMode(testModes::A) { - IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); +EiveTestTask::EiveTestTask(object_id_t objectId_) : TestTask(objectId_), testMode(testModes::A) { + IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); } -EiveTestTask::~EiveTestTask() { -} +EiveTestTask::~EiveTestTask() {} ReturnValue_t EiveTestTask::performOperation(uint8_t operationCode) { - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = RETURN_OK; - if(oneShotAction) { - /* Add code here which should only be run once */ - performOneShotAction(); - oneShotAction = false; - } + if (oneShotAction) { + /* Add code here which should only be run once */ + performOneShotAction(); + oneShotAction = false; + } - /* Add code here which should only be run once per performOperation */ - performPeriodicAction(); + /* Add code here which should only be run once per performOperation */ + performPeriodicAction(); - /* Add code here which should only be run on alternating cycles. */ - if(testMode == testModes::A) { - performActionA(); - testMode = testModes::B; - } - else if(testMode == testModes::B) { - performActionB(); - testMode = testModes::A; - } - return result; + /* Add code here which should only be run on alternating cycles. */ + if (testMode == testModes::A) { + performActionA(); + testMode = testModes::B; + } else if (testMode == testModes::B) { + performActionB(); + testMode = testModes::A; + } + return result; } #include @@ -48,70 +46,70 @@ ReturnValue_t EiveTestTask::performOperation(uint8_t operationCode) { /** * @brief Dummy data from GPS receiver. Will be replaced witgh hyperion data later. */ -const char -gps_rx_data[] = "" - "$GPRMC,183729,A,3907.356,N,12102.482,W,000.0,360.0,080301,015.5,E*6F\r\n" - "$GPRMB,A,,,,,,,,,,,,V*71\r\n" - "$GPGGA,183730,3907.356,N,12102.482,W,1,05,1.6,646.4,M,-24.1,M,,*75\r\n" - "$GPGSA,A,3,02,,,07,,09,24,26,,,,,1.6,1.6,1.0*3D\r\n" - "$GPGSV,2,1,08,02,43,088,38,04,42,145,00,05,11,291,00,07,60,043,35*71\r\n" - "$GPGSV,2,2,08,08,02,145,00,09,46,303,47,24,16,178,32,26,18,231,43*77\r\n" - "$PGRME,22.0,M,52.9,M,51.0,M*14\r\n" - "$GPGLL,3907.360,N,12102.481,W,183730,A*33\r\n" - "$PGRMZ,2062,f,3*2D\r\n" - "$PGRMM,WGS84*06\r\n" - "$GPBOD,,T,,M,,*47\r\n" - "$GPRTE,1,1,c,0*07\r\n" - "$GPRMC,183731,A,3907.482,N,12102.436,W,000.0,360.0,080301,015.5,E*67\r\n" - "$GPRMB,A,,,,,,,,,,,,V*71\r\n"; +const char gps_rx_data[] = + "" + "$GPRMC,183729,A,3907.356,N,12102.482,W,000.0,360.0,080301,015.5,E*6F\r\n" + "$GPRMB,A,,,,,,,,,,,,V*71\r\n" + "$GPGGA,183730,3907.356,N,12102.482,W,1,05,1.6,646.4,M,-24.1,M,,*75\r\n" + "$GPGSA,A,3,02,,,07,,09,24,26,,,,,1.6,1.6,1.0*3D\r\n" + "$GPGSV,2,1,08,02,43,088,38,04,42,145,00,05,11,291,00,07,60,043,35*71\r\n" + "$GPGSV,2,2,08,08,02,145,00,09,46,303,47,24,16,178,32,26,18,231,43*77\r\n" + "$PGRME,22.0,M,52.9,M,51.0,M*14\r\n" + "$GPGLL,3907.360,N,12102.481,W,183730,A*33\r\n" + "$PGRMZ,2062,f,3*2D\r\n" + "$PGRMM,WGS84*06\r\n" + "$GPBOD,,T,,M,,*47\r\n" + "$GPRTE,1,1,c,0*07\r\n" + "$GPRMC,183731,A,3907.482,N,12102.436,W,000.0,360.0,080301,015.5,E*67\r\n" + "$GPRMB,A,,,,,,,,,,,,V*71\r\n"; -const char hyperion_gps_data[] = "" - "$GNGGA,173225.998892,4908.5596,N,00906.2765,E,1,05,2.1,215.0,M,48.2,M,,0000*74\r\n" - "$GNGLL,4908.5596,N,00906.2765,E,173225.998892,A,A*7F\r\n" - "$GPGSA,A,3,18,16,26,31,20,,,,,,,,3.2,2.1,2.4*3C\r\n" - "$GNRMC,173225.998892,A,4908.5596,N,00906.2765,E,000.0,040.7,270221,,,A*4F\r\n" - "$GNVTG,040.7,T,,M,000.0,N,000.0,K,A*10\r\n" - "$GNZDA,173225.998892,27,02,2021,00,00*75\r\n"; +const char hyperion_gps_data[] = + "" + "$GNGGA,173225.998892,4908.5596,N,00906.2765,E,1,05,2.1,215.0,M,48.2,M,,0000*74\r\n" + "$GNGLL,4908.5596,N,00906.2765,E,173225.998892,A,A*7F\r\n" + "$GPGSA,A,3,18,16,26,31,20,,,,,,,,3.2,2.1,2.4*3C\r\n" + "$GNRMC,173225.998892,A,4908.5596,N,00906.2765,E,000.0,040.7,270221,,,A*4F\r\n" + "$GNVTG,040.7,T,,M,000.0,N,000.0,K,A*10\r\n" + "$GNZDA,173225.998892,27,02,2021,00,00*75\r\n"; ReturnValue_t EiveTestTask::performOneShotAction() { #if OBSW_ADD_TEST_CODE == 1 - //performLwgpsTest(); + // performLwgpsTest(); #endif - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } - ReturnValue_t EiveTestTask::performPeriodicAction() { - ReturnValue_t result = RETURN_OK; - return result; + ReturnValue_t result = RETURN_OK; + return result; } ReturnValue_t EiveTestTask::performActionA() { - ReturnValue_t result = RETURN_OK; - /* Add periodically executed code here */ - return result; + ReturnValue_t result = RETURN_OK; + /* Add periodically executed code here */ + return result; } ReturnValue_t EiveTestTask::performActionB() { - ReturnValue_t result = RETURN_OK; - /* Add periodically executed code here */ - return result; + ReturnValue_t result = RETURN_OK; + /* Add periodically executed code here */ + return result; } void EiveTestTask::performLwgpsTest() { - /* Everything here will only be performed once. */ - sif::info << "Processing sample GPS output.." << std::endl; + /* Everything here will only be performed once. */ + sif::info << "Processing sample GPS output.." << std::endl; - lwgps_t gpsStruct; - sif::info << "Size of GPS struct: " << sizeof(gpsStruct) << std::endl; - lwgps_init(&gpsStruct); + lwgps_t gpsStruct; + sif::info << "Size of GPS struct: " << sizeof(gpsStruct) << std::endl; + lwgps_init(&gpsStruct); - /* Process all input data */ - lwgps_process(&gpsStruct, hyperion_gps_data, strlen(hyperion_gps_data)); + /* Process all input data */ + lwgps_process(&gpsStruct, hyperion_gps_data, strlen(hyperion_gps_data)); - /* Print messages */ - printf("Valid status: %d\n", gpsStruct.is_valid); - printf("Latitude: %f degrees\n", gpsStruct.latitude); - printf("Longitude: %f degrees\n", gpsStruct.longitude); - printf("Altitude: %f meters\n", gpsStruct.altitude); + /* Print messages */ + printf("Valid status: %d\n", gpsStruct.is_valid); + printf("Latitude: %f degrees\n", gpsStruct.latitude); + printf("Longitude: %f degrees\n", gpsStruct.longitude); + printf("Altitude: %f meters\n", gpsStruct.altitude); } diff --git a/test/testtasks/TestTask.h b/test/testtasks/TestTask.h index c2b8c8ed..2040ffb5 100644 --- a/test/testtasks/TestTask.h +++ b/test/testtasks/TestTask.h @@ -2,12 +2,12 @@ #define TEST_TESTTASK_H_ #include -#include #include -#include "fsfw_tests/integration/task/TestTask.h" +#include #include +#include "fsfw_tests/integration/task/TestTask.h" /** * @brief Test class for general C++ testing. @@ -16,38 +16,35 @@ * tests. Instead, a derived board test class should be used. */ class EiveTestTask : public TestTask { -public: - EiveTestTask(object_id_t objectId); - virtual ~EiveTestTask(); - virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; + public: + EiveTestTask(object_id_t objectId); + virtual ~EiveTestTask(); + virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; -protected: - virtual ReturnValue_t performOneShotAction(); - virtual ReturnValue_t performPeriodicAction(); - virtual ReturnValue_t performActionA(); - virtual ReturnValue_t performActionB(); + protected: + virtual ReturnValue_t performOneShotAction(); + virtual ReturnValue_t performPeriodicAction(); + virtual ReturnValue_t performActionA(); + virtual ReturnValue_t performActionB(); - enum testModes: uint8_t { - A, - B - }; + enum testModes : uint8_t { A, B }; - testModes testMode; + testModes testMode; - bool testFlag = false; - uint8_t counter { 1 }; - uint8_t counterTrigger { 3 }; + bool testFlag = false; + uint8_t counter{1}; + uint8_t counterTrigger{3}; - void performPusInjectorTest(); - void examplePacketTest(); -private: - // Actually, to be really thread-safe, a mutex should be used as well - // Let's keep it simple for now. - bool oneShotAction = true; - StorageManagerIF* IPCStore; + void performPusInjectorTest(); + void examplePacketTest(); - void performLwgpsTest(); + private: + // Actually, to be really thread-safe, a mutex should be used as well + // Let's keep it simple for now. + bool oneShotAction = true; + StorageManagerIF* IPCStore; + + void performLwgpsTest(); }; - #endif /* TESTTASK_H_ */ From 1d6f999ab6b96275b0634bb3bf0547b7339a74be Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 17 Jan 2022 16:21:33 +0100 Subject: [PATCH 220/465] added HK deserializer --- mission/devices/BpxBatteryHandler.h | 2 + .../devicedefinitions/BpxBatteryDefinitions.h | 64 +++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/mission/devices/BpxBatteryHandler.h b/mission/devices/BpxBatteryHandler.h index 887827fd..5edc0348 100644 --- a/mission/devices/BpxBatteryHandler.h +++ b/mission/devices/BpxBatteryHandler.h @@ -1,6 +1,8 @@ #ifndef MISSION_DEVICES_BPXBATTERYHANDLER_H_ #define MISSION_DEVICES_BPXBATTERYHANDLER_H_ +#include "devicedefinitions/BpxBatteryDefinitions.h" + #include class BpxBatteryHandler : public DeviceHandlerBase { diff --git a/mission/devices/devicedefinitions/BpxBatteryDefinitions.h b/mission/devices/devicedefinitions/BpxBatteryDefinitions.h index 436cc6f6..ff96e857 100644 --- a/mission/devices/devicedefinitions/BpxBatteryDefinitions.h +++ b/mission/devices/devicedefinitions/BpxBatteryDefinitions.h @@ -1,8 +1,72 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_BPXBATTERYDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_BPXBATTERYDEFINITIONS_H_ +#include +#include + namespace BpxBattery { +static constexpr uint8_t PORT_PING = 1; +static constexpr uint8_t PORT_REBOOT = 4; +static constexpr uint8_t PORT_GET_HK = 9; +static constexpr uint8_t PORT_RESET_COUNTERS = 15; +static constexpr uint8_t PORT_CONFIG_CMD = 17; +static constexpr uint8_t PORT_CONFIG_GET = 18; +static constexpr uint8_t PORT_CONFIG_SET = 19; +static constexpr uint8_t PORT_MAN_HEAT_ON = 20; +static constexpr uint8_t PORT_MAN_HEAT_OFF = 21; + +// Taken from BPX manual 3.14 +typedef struct __attribute__((packed)) { + //! Mode for battheater [0=OFF,1=Auto] + uint8_t battheater_mode; + int8_t battheater_low; + //! Turn heater on at [degC] + int8_t battheater_high; + //! Turn heater off at [degC] +} bpx_config_t; + +class BpxHkDeserializer: public SerialLinkedListAdapter { +public: + BpxHkDeserializer() { + setLinks(); + } + + //! Charge current in mA + SerializeElement chargeCurrent; + //! Discharge current in mA + SerializeElement dischargeCurrent; + //! Heater current in mA + SerializeElement heaterCurrent; + + //! Battery voltage in mV + SerializeElement battVoltage; + //! Battery temperature 1 in degC + SerializeElement battTemp1; + //! Battery temperature 2 in degC + SerializeElement battTemp2; + //! Battery temperature 3 in degC + SerializeElement battTemp3; + //! Battery temperature 4 in degC + SerializeElement battTemp4; + + SerializeElement rebootCounter; + SerializeElement bootcause; +private: + void setLinks() { + setStart(&chargeCurrent); + chargeCurrent.setNext(&dischargeCurrent); + dischargeCurrent.setNext(&heaterCurrent); + heaterCurrent.setNext(&battVoltage); + battVoltage.setNext(&battTemp1); + battTemp1.setNext(&battTemp2); + battTemp2.setNext(&battTemp3); + battTemp3.setNext(&battTemp4); + battTemp4.setNext(&rebootCounter); + rebootCounter.setNext(&bootcause); + } +}; + } #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_BPXBATTERYDEFINITIONS_H_ */ From fab259a2b5a6f8fc5f541ab30e2807493230bf94 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 17 Jan 2022 16:44:20 +0100 Subject: [PATCH 221/465] added BPX HK set --- mission/devices/BpxBatteryHandler.h | 4 +- .../devicedefinitions/BpxBatteryDefinitions.h | 144 ++++++++++++++++-- 2 files changed, 135 insertions(+), 13 deletions(-) diff --git a/mission/devices/BpxBatteryHandler.h b/mission/devices/BpxBatteryHandler.h index 5edc0348..6ab0ea9c 100644 --- a/mission/devices/BpxBatteryHandler.h +++ b/mission/devices/BpxBatteryHandler.h @@ -1,10 +1,10 @@ #ifndef MISSION_DEVICES_BPXBATTERYHANDLER_H_ #define MISSION_DEVICES_BPXBATTERYHANDLER_H_ -#include "devicedefinitions/BpxBatteryDefinitions.h" - #include +#include "devicedefinitions/BpxBatteryDefinitions.h" + class BpxBatteryHandler : public DeviceHandlerBase { public: BpxBatteryHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); diff --git a/mission/devices/devicedefinitions/BpxBatteryDefinitions.h b/mission/devices/devicedefinitions/BpxBatteryDefinitions.h index ff96e857..b0ab8df7 100644 --- a/mission/devices/devicedefinitions/BpxBatteryDefinitions.h +++ b/mission/devices/devicedefinitions/BpxBatteryDefinitions.h @@ -1,11 +1,28 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_BPXBATTERYDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_BPXBATTERYDEFINITIONS_H_ +#include #include + #include namespace BpxBattery { +enum BpxPoolIds { + CHARGE_CURRENT = 0, + DISCHARGE_CURRENT = 1, + HEATER_CURRENT = 2, + BATT_VOLTAGE = 3, + BATT_TEMP_1 = 4, + BATT_TEMP_2 = 5, + BATT_TEMP_3 = 6, + BATT_TEMP_4 = 7, + REBOOT_COUNTER = 8, + BOOTCAUSE = 9 +}; + +static constexpr uint32_t HK_SET_ID = 0; + static constexpr uint8_t PORT_PING = 1; static constexpr uint8_t PORT_REBOOT = 4; static constexpr uint8_t PORT_GET_HK = 9; @@ -16,6 +33,9 @@ static constexpr uint8_t PORT_CONFIG_SET = 19; static constexpr uint8_t PORT_MAN_HEAT_ON = 20; static constexpr uint8_t PORT_MAN_HEAT_OFF = 21; +static constexpr uint8_t HK_ENTRIES = 10; + + // Taken from BPX manual 3.14 typedef struct __attribute__((packed)) { //! Mode for battheater [0=OFF,1=Auto] @@ -26,11 +46,11 @@ typedef struct __attribute__((packed)) { //! Turn heater off at [degC] } bpx_config_t; -class BpxHkDeserializer: public SerialLinkedListAdapter { -public: - BpxHkDeserializer() { - setLinks(); - } + +//! Not used for more but might still be useful +class BpxHkDeserializer : public SerialLinkedListAdapter { + public: + BpxHkDeserializer() { setLinks(); } //! Charge current in mA SerializeElement chargeCurrent; @@ -42,17 +62,18 @@ public: //! Battery voltage in mV SerializeElement battVoltage; //! Battery temperature 1 in degC - SerializeElement battTemp1; + SerializeElement battTemp1; //! Battery temperature 2 in degC - SerializeElement battTemp2; + SerializeElement battTemp2; //! Battery temperature 3 in degC - SerializeElement battTemp3; + SerializeElement battTemp3; //! Battery temperature 4 in degC - SerializeElement battTemp4; + SerializeElement battTemp4; SerializeElement rebootCounter; SerializeElement bootcause; -private: + + private: void setLinks() { setStart(&chargeCurrent); chargeCurrent.setNext(&dischargeCurrent); @@ -67,6 +88,107 @@ private: } }; -} + +/** + * @brief BPX HK data holder + */ +class BpxBatteryHk : public StaticLocalDataSet { + public: + /** + * Constructor for data users + * @param gyroId + */ + BpxBatteryHk(object_id_t bpxId) : StaticLocalDataSet(sid_t(bpxId, BpxBattery::HK_SET_ID)) { + setAllVariablesReadOnly(); + } + + ReturnValue_t parseRawHk(const uint8_t* data, size_t size) { + size_t remSize = size; + ReturnValue_t result = + chargeCurrent.deSerialize(&data, &remSize, SerializeIF::Endianness::NETWORK); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = dischargeCurrent.deSerialize(&data, &remSize, SerializeIF::Endianness::NETWORK); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = heaterCurrent.deSerialize(&data, &remSize, SerializeIF::Endianness::NETWORK); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = battVoltage.deSerialize(&data, &remSize, SerializeIF::Endianness::NETWORK); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = battTemp1.deSerialize(&data, &remSize, SerializeIF::Endianness::NETWORK); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = battTemp2.deSerialize(&data, &remSize, SerializeIF::Endianness::NETWORK); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = battTemp3.deSerialize(&data, &remSize, SerializeIF::Endianness::NETWORK); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = battTemp4.deSerialize(&data, &remSize, SerializeIF::Endianness::NETWORK); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = rebootCounter.deSerialize(&data, &remSize, SerializeIF::Endianness::NETWORK); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = bootcause.deSerialize(&data, &remSize, SerializeIF::Endianness::NETWORK); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + return result; + } + + BpxBatteryHk(); + + private: + //! Charge current in mA + lp_var_t chargeCurrent = + lp_var_t(sid.objectId, BpxBattery::BpxPoolIds::CHARGE_CURRENT, this); + //! Discharge current in mA + lp_var_t dischargeCurrent = + lp_var_t(sid.objectId, BpxBattery::BpxPoolIds::DISCHARGE_CURRENT, this); + //! Heater current in mA + lp_var_t heaterCurrent = + lp_var_t(sid.objectId, BpxBattery::BpxPoolIds::HEATER_CURRENT, this); + + //! Battery voltage in mV + lp_var_t battVoltage = + lp_var_t(sid.objectId, BpxBattery::BpxPoolIds::BATT_VOLTAGE, this); + //! Battery temperature 1 in degC + SerializeElement battTemp1 = + lp_var_t(sid.objectId, BpxBattery::BpxPoolIds::BATT_TEMP_1, this); + //! Battery temperature 2 in degC + SerializeElement battTemp2 = + lp_var_t(sid.objectId, BpxBattery::BpxPoolIds::BATT_TEMP_2, this); + //! Battery temperature 3 in degC + SerializeElement battTemp3 = + lp_var_t(sid.objectId, BpxBattery::BpxPoolIds::BATT_TEMP_3, this); + //! Battery temperature 4 in degC + SerializeElement battTemp4 = + lp_var_t(sid.objectId, BpxBattery::BpxPoolIds::BATT_TEMP_4, this); + SerializeElement rebootCounter = + lp_var_t(sid.objectId, BpxBattery::BpxPoolIds::REBOOT_COUNTER, this); + SerializeElement bootcause = + lp_var_t(sid.objectId, BpxBattery::BpxPoolIds::BOOTCAUSE, this); + + friend class BpxBatteryHandler; + /** + * Constructor for data creator + * @param hkOwner + */ + BpxBatteryHk(HasLocalDataPoolIF* hkOwner) : StaticLocalDataSet(hkOwner, BpxBattery::HK_SET_ID) {} +}; + +}; #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_BPXBATTERYDEFINITIONS_H_ */ From d5a09dc2808ad7e843e96748a9ba38cee6102c73 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 17 Jan 2022 17:11:27 +0100 Subject: [PATCH 222/465] added cfg HK --- mission/devices/BpxBatteryHandler.cpp | 11 ++- mission/devices/BpxBatteryHandler.h | 3 + .../devicedefinitions/BpxBatteryDefinitions.h | 82 +++++++++++++++---- 3 files changed, 78 insertions(+), 18 deletions(-) diff --git a/mission/devices/BpxBatteryHandler.cpp b/mission/devices/BpxBatteryHandler.cpp index 7d504105..111a5acf 100644 --- a/mission/devices/BpxBatteryHandler.cpp +++ b/mission/devices/BpxBatteryHandler.cpp @@ -1,7 +1,7 @@ #include "BpxBatteryHandler.h" BpxBatteryHandler::BpxBatteryHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie) - : DeviceHandlerBase(objectId, comIF, comCookie) {} + : DeviceHandlerBase(objectId, comIF, comCookie), hkSet(this), cfgSet(this) {} BpxBatteryHandler::~BpxBatteryHandler() {} @@ -17,7 +17,14 @@ ReturnValue_t BpxBatteryHandler::buildTransitionDeviceCommand(DeviceCommandId_t* return HasReturnvaluesIF::RETURN_OK; } -void BpxBatteryHandler::fillCommandAndReplyMap() {} +void BpxBatteryHandler::fillCommandAndReplyMap() { + insertInCommandAndReplyMap(BpxBattery::READ_HK, 1, &hkSet); + insertInCommandAndReplyMap(BpxBattery::PING, 1); + insertInCommandAndReplyMap(BpxBattery::REBOOT, 1); + insertInCommandAndReplyMap(BpxBattery::RESET_COUNTERS, 1); + insertInCommandAndReplyMap(BpxBattery::RESTORE_DEFAULT_CONFIG, 1); + insertInCommandAndReplyMap(BpxBattery::READ_CONFIG, 1); +} ReturnValue_t BpxBatteryHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData, diff --git a/mission/devices/BpxBatteryHandler.h b/mission/devices/BpxBatteryHandler.h index 6ab0ea9c..2699f548 100644 --- a/mission/devices/BpxBatteryHandler.h +++ b/mission/devices/BpxBatteryHandler.h @@ -11,6 +11,9 @@ class BpxBatteryHandler : public DeviceHandlerBase { virtual ~BpxBatteryHandler(); protected: + BpxBatteryHk hkSet; + BpxBatteryCfg cfgSet; + void doStartUp() override; void doShutDown() override; ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override; diff --git a/mission/devices/devicedefinitions/BpxBatteryDefinitions.h b/mission/devices/devicedefinitions/BpxBatteryDefinitions.h index b0ab8df7..1fbe4653 100644 --- a/mission/devices/devicedefinitions/BpxBatteryDefinitions.h +++ b/mission/devices/devicedefinitions/BpxBatteryDefinitions.h @@ -8,7 +8,7 @@ namespace BpxBattery { -enum BpxPoolIds { +enum HkPoolIds { CHARGE_CURRENT = 0, DISCHARGE_CURRENT = 1, HEATER_CURRENT = 2, @@ -21,7 +21,21 @@ enum BpxPoolIds { BOOTCAUSE = 9 }; +enum CfgPoolIds { BATTERY_HEATER_MODE = 0, BATTHEAT_LOW_LIMIT = 1, BATTHEAT_HIGH_LIMIT = 2 }; + +static constexpr DeviceCommandId_t READ_HK = 0; +static constexpr DeviceCommandId_t PING = 1; +static constexpr DeviceCommandId_t REBOOT = 2; +static constexpr DeviceCommandId_t RESET_COUNTERS = 3; +static constexpr DeviceCommandId_t RESTORE_DEFAULT_CONFIG = 4; +static constexpr DeviceCommandId_t READ_CONFIG = 5; +static constexpr DeviceCommandId_t WRITE_CONFIG = 6; + +static constexpr DeviceCommandId_t MANUAL_HEATER_ON = 10; +static constexpr DeviceCommandId_t MANUAL_HEATER_OFF = 11; + static constexpr uint32_t HK_SET_ID = 0; +static constexpr uint32_t CFG_SET_ID = 1; static constexpr uint8_t PORT_PING = 1; static constexpr uint8_t PORT_REBOOT = 4; @@ -34,7 +48,7 @@ static constexpr uint8_t PORT_MAN_HEAT_ON = 20; static constexpr uint8_t PORT_MAN_HEAT_OFF = 21; static constexpr uint8_t HK_ENTRIES = 10; - +static constexpr uint8_t CFG_ENTRIES = 3; // Taken from BPX manual 3.14 typedef struct __attribute__((packed)) { @@ -46,7 +60,6 @@ typedef struct __attribute__((packed)) { //! Turn heater off at [degC] } bpx_config_t; - //! Not used for more but might still be useful class BpxHkDeserializer : public SerialLinkedListAdapter { public: @@ -88,11 +101,12 @@ class BpxHkDeserializer : public SerialLinkedListAdapter { } }; +}; // namespace BpxBattery /** * @brief BPX HK data holder */ -class BpxBatteryHk : public StaticLocalDataSet { +class BpxBatteryHk : public StaticLocalDataSet { public: /** * Constructor for data users @@ -148,38 +162,36 @@ class BpxBatteryHk : public StaticLocalDataSet { return result; } - BpxBatteryHk(); - private: //! Charge current in mA lp_var_t chargeCurrent = - lp_var_t(sid.objectId, BpxBattery::BpxPoolIds::CHARGE_CURRENT, this); + lp_var_t(sid.objectId, BpxBattery::HkPoolIds::CHARGE_CURRENT, this); //! Discharge current in mA lp_var_t dischargeCurrent = - lp_var_t(sid.objectId, BpxBattery::BpxPoolIds::DISCHARGE_CURRENT, this); + lp_var_t(sid.objectId, BpxBattery::HkPoolIds::DISCHARGE_CURRENT, this); //! Heater current in mA lp_var_t heaterCurrent = - lp_var_t(sid.objectId, BpxBattery::BpxPoolIds::HEATER_CURRENT, this); + lp_var_t(sid.objectId, BpxBattery::HkPoolIds::HEATER_CURRENT, this); //! Battery voltage in mV lp_var_t battVoltage = - lp_var_t(sid.objectId, BpxBattery::BpxPoolIds::BATT_VOLTAGE, this); + lp_var_t(sid.objectId, BpxBattery::HkPoolIds::BATT_VOLTAGE, this); //! Battery temperature 1 in degC SerializeElement battTemp1 = - lp_var_t(sid.objectId, BpxBattery::BpxPoolIds::BATT_TEMP_1, this); + lp_var_t(sid.objectId, BpxBattery::HkPoolIds::BATT_TEMP_1, this); //! Battery temperature 2 in degC SerializeElement battTemp2 = - lp_var_t(sid.objectId, BpxBattery::BpxPoolIds::BATT_TEMP_2, this); + lp_var_t(sid.objectId, BpxBattery::HkPoolIds::BATT_TEMP_2, this); //! Battery temperature 3 in degC SerializeElement battTemp3 = - lp_var_t(sid.objectId, BpxBattery::BpxPoolIds::BATT_TEMP_3, this); + lp_var_t(sid.objectId, BpxBattery::HkPoolIds::BATT_TEMP_3, this); //! Battery temperature 4 in degC SerializeElement battTemp4 = - lp_var_t(sid.objectId, BpxBattery::BpxPoolIds::BATT_TEMP_4, this); + lp_var_t(sid.objectId, BpxBattery::HkPoolIds::BATT_TEMP_4, this); SerializeElement rebootCounter = - lp_var_t(sid.objectId, BpxBattery::BpxPoolIds::REBOOT_COUNTER, this); + lp_var_t(sid.objectId, BpxBattery::HkPoolIds::REBOOT_COUNTER, this); SerializeElement bootcause = - lp_var_t(sid.objectId, BpxBattery::BpxPoolIds::BOOTCAUSE, this); + lp_var_t(sid.objectId, BpxBattery::HkPoolIds::BOOTCAUSE, this); friend class BpxBatteryHandler; /** @@ -189,6 +201,44 @@ class BpxBatteryHk : public StaticLocalDataSet { BpxBatteryHk(HasLocalDataPoolIF* hkOwner) : StaticLocalDataSet(hkOwner, BpxBattery::HK_SET_ID) {} }; +class BpxBatteryCfg : public StaticLocalDataSet { + public: + /** + * Constructor for data users + * @param gyroId + */ + BpxBatteryCfg(object_id_t bpxId) : StaticLocalDataSet(sid_t(bpxId, BpxBattery::CFG_SET_ID)) { + setAllVariablesReadOnly(); + } + + ReturnValue_t parseRawHk(const uint8_t* data, size_t size) { + if (size < 3) { + return SerializeIF::STREAM_TOO_SHORT; + } + battheatermode.value = data[0]; + battheaterLow.value = data[1]; + battheaterHigh.value = data[2]; + return HasReturnvaluesIF::RETURN_OK; + } + + //! Mode for battheater [0=OFF,1=Auto] + lp_var_t battheatermode = + lp_var_t(sid.objectId, BpxBattery::CfgPoolIds::BATTERY_HEATER_MODE, this); + //! Turn heater on at [degC] + lp_var_t battheaterLow = + lp_var_t(sid.objectId, BpxBattery::CfgPoolIds::BATTHEAT_LOW_LIMIT, this); + //! Turn heater off at [degC] + lp_var_t battheaterHigh = + lp_var_t(sid.objectId, BpxBattery::CfgPoolIds::BATTHEAT_HIGH_LIMIT, this); + + private: + friend class BpxBatteryHandler; + /** + * Constructor for data creator + * @param hkOwner + */ + BpxBatteryCfg(HasLocalDataPoolIF* hkOwner) + : StaticLocalDataSet(hkOwner, BpxBattery::CFG_SET_ID) {} }; #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_BPXBATTERYDEFINITIONS_H_ */ From c32ca422fc1bde7856e8c0ab754bd192551ad437 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 18 Jan 2022 11:37:15 +0100 Subject: [PATCH 223/465] updated shell script helpers --- .../{win_path_helper_xilinx_tools.sh => q7s-env-win.sh} | 0 cmake/scripts/Q7S/q7s-env.sh | 7 +++++++ cmake/scripts/Q7S/unix_path_helper.sh | 6 ------ 3 files changed, 7 insertions(+), 6 deletions(-) rename cmake/scripts/Q7S/{win_path_helper_xilinx_tools.sh => q7s-env-win.sh} (100%) create mode 100755 cmake/scripts/Q7S/q7s-env.sh delete mode 100644 cmake/scripts/Q7S/unix_path_helper.sh diff --git a/cmake/scripts/Q7S/win_path_helper_xilinx_tools.sh b/cmake/scripts/Q7S/q7s-env-win.sh similarity index 100% rename from cmake/scripts/Q7S/win_path_helper_xilinx_tools.sh rename to cmake/scripts/Q7S/q7s-env-win.sh diff --git a/cmake/scripts/Q7S/q7s-env.sh b/cmake/scripts/Q7S/q7s-env.sh new file mode 100755 index 00000000..818ff213 --- /dev/null +++ b/cmake/scripts/Q7S/q7s-env.sh @@ -0,0 +1,7 @@ +#!/bin/bash -i +export PATH=$PATH:"$HOME/EIVE/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin" +export CROSS_COMPILE="arm-linux-gnueabihf" + +export Q7S_SYSROOT="$HOME/Xilinx/cortexa9hf-neon-xiphos-linux-gnueabi" +export CONSOLE_PREFIX="[Q7S ENV]" +/bin/bash diff --git a/cmake/scripts/Q7S/unix_path_helper.sh b/cmake/scripts/Q7S/unix_path_helper.sh deleted file mode 100644 index 296bfdd8..00000000 --- a/cmake/scripts/Q7S/unix_path_helper.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -export PATH=$PATH:"/opt/Xilinx/SDK/2018.2/gnu/aarch32/lin/gcc-arm-linux-gnueabi/bin" -export CROSS_COMPILE="arm-linux-gnueabihf" - -export Q7S_SYSROOT="$HOME/Xilinx/cortexa9hf-neon-xiphos-linux-gnueabi" - From 0ed46911130f3f9b8e183fb6499bd3b74b967a19 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 18 Jan 2022 11:38:52 +0100 Subject: [PATCH 224/465] readme update --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index adb3c3e5..6ad16a87 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Target systems: relevant pages. The most recent datasheet can be found [here](https://trac2.xiphos.ca/manual/wiki/Q7RevB/UserManual). * Linux OS built with Yocto 2.5 - * Linux Kernel https://github.com/XiphosSystemsCorp/linux-xlnx.git . EIVE version can be found + * [Linux Kernel](https://github.com/XiphosSystemsCorp/linux-xlnx.git) . EIVE version can be found [here](https://github.com/spacefisch/linux-xlnx) . Pre-compiled files can be found [here](https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/EIVE_IRS/Software/q7s-linux-components&fileid=777299). * Q7S base project can be found [here](https://egit.irs.uni-stuttgart.de/eive/q7s-base) @@ -1093,7 +1093,7 @@ The [TCF agent](https://wiki.eclipse.org/TCF) can be used to perform remote debu 1. Install the TCF agent plugin in Eclipse from the [releases](https://www.eclipse.org/tcf/downloads.php). Go to Help → Install New Software and use the download page, for - example https://download.eclipse.org/tools/tcf/releases/1.6/1.6.2/ to search for the plugin and install it. + example https://download.eclipse.org/tools/tcf/releases/1.7/1.7.0/ to search for the plugin and install it. You can find the newest version [here](https://www.eclipse.org/tcf/downloads.php) 2. Go to Window → Perspective → Open Perspective and open the **Target Explorer Perspective**. Here, the Q7S should show up if the local port forwarding was set up as explained previously. From 76adea6bd5d632da11a4c2db485124c3e7443a24 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 18 Jan 2022 11:39:03 +0100 Subject: [PATCH 225/465] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index c1e0bcee..2c871af7 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit c1e0bcee6db652d6c474c87a4099e61ecf86b694 +Subproject commit 2c871af7b98abc794cdf6072fae174c9dc3ac63b From 5cc7331e90f1edef72ee6c37602e2709d5ceb7b2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 18 Jan 2022 11:41:19 +0100 Subject: [PATCH 226/465] applied clang formatting --- bsp_hosted/InitMission.cpp | 214 +- bsp_hosted/InitMission.h | 2 +- bsp_hosted/ObjectFactory.cpp | 41 +- bsp_hosted/ObjectFactory.h | 7 +- bsp_hosted/boardconfig/etl_profile.h | 4 +- bsp_hosted/boardconfig/gcov.h | 5 +- bsp_hosted/boardconfig/print.c | 14 +- bsp_hosted/comIF/ArduinoComIF.cpp | 539 ++- bsp_hosted/comIF/ArduinoComIF.h | 71 +- bsp_hosted/comIF/ArduinoCookie.cpp | 12 +- bsp_hosted/comIF/ArduinoCookie.h | 27 +- bsp_hosted/fsfwconfig/devices/gpioIds.h | 89 +- .../fsfwconfig/devices/powerSwitcherList.h | 89 +- .../fsfwconfig/events/subsystemIdRanges.h | 5 +- .../fsfwconfig/events/translateEvents.cpp | 344 +- .../fsfwconfig/events/translateEvents.h | 2 +- .../fsfwconfig/ipc/MissionMessageTypes.cpp | 11 +- .../fsfwconfig/ipc/MissionMessageTypes.h | 4 +- .../fsfwconfig/objects/systemObjectList.h | 33 +- .../fsfwconfig/objects/translateObjects.cpp | 138 +- bsp_hosted/fsfwconfig/returnvalues/classIds.h | 6 +- bsp_hosted/fsfwconfig/tmtc/apid.h | 3 +- bsp_hosted/fsfwconfig/tmtc/pusIds.h | 30 +- bsp_hosted/main.cpp | 32 +- bsp_linux_board/InitMission.cpp | 363 +- bsp_linux_board/InitMission.h | 17 +- bsp_linux_board/ObjectFactory.cpp | 319 +- bsp_linux_board/ObjectFactory.h | 9 +- bsp_linux_board/boardconfig/etl_profile.h | 4 +- bsp_linux_board/boardconfig/gcov.h | 5 +- bsp_linux_board/boardconfig/print.c | 14 +- bsp_linux_board/main.cpp | 32 +- bsp_q7s/boardconfig/busConf.h | 106 +- bsp_q7s/boardconfig/etl_profile.h | 4 +- bsp_q7s/boardconfig/gcov.h | 5 +- bsp_q7s/boardconfig/print.c | 14 +- bsp_q7s/boardtest/FileSystemTest.cpp | 35 +- bsp_q7s/boardtest/FileSystemTest.h | 11 +- bsp_q7s/boardtest/Q7STestTask.cpp | 685 ++-- bsp_q7s/boardtest/Q7STestTask.h | 60 +- bsp_q7s/callbacks/gnssCallback.cpp | 39 +- bsp_q7s/callbacks/gnssCallback.h | 8 +- bsp_q7s/callbacks/rwSpiCallback.cpp | 412 +- bsp_q7s/callbacks/rwSpiCallback.h | 9 +- bsp_q7s/core/CoreController.cpp | 1850 +++++---- bsp_q7s/core/CoreController.h | 274 +- bsp_q7s/core/InitMission.cpp | 538 ++- bsp_q7s/core/InitMission.h | 11 +- bsp_q7s/core/ObjectFactory.cpp | 1703 +++++---- bsp_q7s/core/ObjectFactory.h | 6 +- bsp_q7s/core/ParameterHandler.cpp | 7 +- bsp_q7s/core/ParameterHandler.h | 18 +- bsp_q7s/core/obsw.cpp | 57 +- bsp_q7s/devices/PlocMemoryDumper.cpp | 282 +- bsp_q7s/devices/PlocMemoryDumper.h | 145 +- bsp_q7s/devices/PlocSupervisorHandler.cpp | 2295 ++++++----- bsp_q7s/devices/PlocSupervisorHandler.h | 549 +-- bsp_q7s/devices/PlocUpdater.cpp | 582 ++- bsp_q7s/devices/PlocUpdater.h | 247 +- .../PlocMemDumpDefinitions.h | 41 +- .../PlocSupervisorDefinitions.h | 2261 ++++++----- .../startracker/ArcsecDatalinkLayer.cpp | 100 +- .../devices/startracker/ArcsecDatalinkLayer.h | 138 +- bsp_q7s/devices/startracker/ArcsecJsonKeys.h | 214 +- .../startracker/ArcsecJsonParamBase.cpp | 103 +- .../devices/startracker/ArcsecJsonParamBase.h | 215 +- .../startracker/StarTrackerDefinitions.h | 1786 ++++----- .../startracker/StarTrackerHandler.cpp | 2958 +++++++------- .../devices/startracker/StarTrackerHandler.h | 1053 +++-- .../startracker/StarTrackerJsonCommands.cpp | 1281 +++---- .../startracker/StarTrackerJsonCommands.h | 161 +- bsp_q7s/devices/startracker/StrHelper.cpp | 1164 +++--- bsp_q7s/devices/startracker/StrHelper.h | 662 ++-- bsp_q7s/gpio/gpioCallbacks.cpp | 858 +++-- bsp_q7s/gpio/gpioCallbacks.h | 111 +- bsp_q7s/main.cpp | 9 +- bsp_q7s/memory/FileSystemHandler.cpp | 418 +- bsp_q7s/memory/FileSystemHandler.h | 104 +- bsp_q7s/memory/SdCardManager.cpp | 773 ++-- bsp_q7s/memory/SdCardManager.h | 345 +- bsp_q7s/memory/definitions.h | 21 +- bsp_q7s/memory/scratchApi.cpp | 75 +- bsp_q7s/memory/scratchApi.h | 142 +- bsp_q7s/simple/simple.cpp | 10 +- bsp_q7s/spi/Q7sSpiComIF.cpp | 8 +- bsp_q7s/spi/Q7sSpiComIF.h | 23 +- fsfw | 2 +- linux/archive/gpio/GpioCookie.cpp | 44 +- linux/archive/gpio/GpioCookie.h | 34 +- linux/archive/gpio/GpioIF.h | 68 +- linux/archive/gpio/LinuxLibgpioIF.cpp | 459 ++- linux/archive/gpio/LinuxLibgpioIF.h | 98 +- linux/archive/gpio/gpioDefinitions.h | 89 +- linux/archive/tmtc/CCSDSIPCoreBridge.cpp | 180 +- linux/archive/tmtc/CCSDSIPCoreBridge.h | 186 +- linux/boardtest/I2cTestClass.cpp | 7 +- linux/boardtest/I2cTestClass.h | 12 +- linux/boardtest/LibgpiodTest.cpp | 208 +- linux/boardtest/LibgpiodTest.h | 33 +- linux/boardtest/SpiTestClass.cpp | 762 ++-- linux/boardtest/SpiTestClass.h | 117 +- linux/boardtest/UartTestClass.cpp | 163 +- linux/boardtest/UartTestClass.h | 30 +- linux/csp/CspComIF.cpp | 441 ++- linux/csp/CspComIF.h | 110 +- linux/csp/CspCookie.cpp | 16 +- linux/csp/CspCookie.h | 21 +- linux/devices/SolarArrayDeploymentHandler.cpp | 305 +- linux/devices/SolarArrayDeploymentHandler.h | 224 +- linux/devices/SusHandler.cpp | 368 +- linux/devices/SusHandler.h | 83 +- .../devicedefinitions/SusDefinitions.h | 140 +- linux/fsfwconfig/devices/addresses.cpp | 4 - linux/fsfwconfig/devices/addresses.h | 137 +- linux/fsfwconfig/devices/gpioIds.h | 180 +- linux/fsfwconfig/devices/powerSwitcherList.h | 89 +- linux/fsfwconfig/events/subsystemIdRanges.h | 10 +- linux/fsfwconfig/events/translateEvents.cpp | 572 +-- linux/fsfwconfig/events/translateEvents.h | 2 +- linux/fsfwconfig/ipc/MissionMessageTypes.cpp | 12 +- linux/fsfwconfig/ipc/MissionMessageTypes.h | 6 +- linux/fsfwconfig/objects/systemObjectList.h | 60 +- linux/fsfwconfig/objects/translateObjects.cpp | 464 +-- .../pollingSequenceFactory.cpp | 1254 +++--- .../pollingsequence/pollingSequenceFactory.h | 7 +- linux/fsfwconfig/returnvalues/classIds.h | 13 +- linux/fsfwconfig/tmtc/pusIds.h | 30 +- linux/obc/PapbVcInterface.cpp | 138 +- linux/obc/PapbVcInterface.h | 158 +- linux/obc/PdecConfig.cpp | 49 +- linux/obc/PdecConfig.h | 56 +- linux/obc/PdecHandler.cpp | 842 ++-- linux/obc/PdecHandler.h | 613 ++- linux/obc/Ptme.cpp | 103 +- linux/obc/Ptme.h | 116 +- linux/obc/PtmeConfig.h | 25 +- linux/obc/PtmeIF.h | 21 +- linux/obc/PtmeRateSetter.cpp | 32 +- linux/obc/PtmeRateSetter.h | 36 +- linux/obc/TxRateSetterIF.h | 13 +- linux/obc/VcInterfaceIF.h | 23 +- linux/utility/utility.cpp | 11 +- linux/utility/utility.h | 3 +- mission/controller/ThermalController.cpp | 67 +- mission/controller/ThermalController.h | 32 +- mission/core/GenericFactory.cpp | 126 +- mission/core/GenericFactory.h | 2 - mission/devices/ACUHandler.cpp | 503 +-- mission/devices/ACUHandler.h | 57 +- mission/devices/GPSHyperionHandler.cpp | 241 +- mission/devices/GPSHyperionHandler.h | 55 +- mission/devices/GomspaceDeviceHandler.cpp | 686 ++-- mission/devices/GomspaceDeviceHandler.h | 214 +- mission/devices/GyroADIS1650XHandler.cpp | 727 ++-- mission/devices/GyroADIS1650XHandler.h | 92 +- mission/devices/HeaterHandler.cpp | 577 ++- mission/devices/HeaterHandler.h | 244 +- mission/devices/IMTQHandler.cpp | 3387 +++++++++-------- mission/devices/IMTQHandler.h | 312 +- mission/devices/Max31865PT1000Handler.cpp | 819 ++-- mission/devices/Max31865PT1000Handler.h | 151 +- mission/devices/P60DockHandler.cpp | 860 +++-- mission/devices/P60DockHandler.h | 54 +- mission/devices/PCDUHandler.cpp | 804 ++-- mission/devices/PCDUHandler.h | 178 +- mission/devices/PDU1Handler.cpp | 709 ++-- mission/devices/PDU1Handler.h | 37 +- mission/devices/PDU2Handler.cpp | 697 ++-- mission/devices/PDU2Handler.h | 40 +- mission/devices/PlocMPSoCHandler.cpp | 726 ++-- mission/devices/PlocMPSoCHandler.h | 328 +- mission/devices/RadiationSensorHandler.cpp | 263 +- mission/devices/RadiationSensorHandler.h | 68 +- mission/devices/RwHandler.cpp | 727 ++-- mission/devices/RwHandler.h | 228 +- mission/devices/SyrlinksHkHandler.cpp | 731 ++-- mission/devices/SyrlinksHkHandler.h | 274 +- mission/devices/Tmp1075Handler.cpp | 211 +- mission/devices/Tmp1075Handler.h | 74 +- .../devicedefinitions/GPSDefinitions.h | 93 +- .../devicedefinitions/GomSpacePackets.h | 637 ++-- .../devicedefinitions/GomspaceDefinitions.h | 2001 +++++----- .../GyroADIS1650XDefinitions.h | 146 +- .../devicedefinitions/GyroL3GD20Definitions.h | 62 +- .../IMTQHandlerDefinitions.h | 1595 ++++---- .../devicedefinitions/Max31865Definitions.h | 52 +- .../devicedefinitions/PlocMPSoCDefinitions.h | 278 +- .../devicedefinitions/RadSensorDefinitions.h | 131 +- .../devices/devicedefinitions/RwDefinitions.h | 270 +- .../devicedefinitions/SyrlinksDefinitions.h | 149 +- .../devicedefinitions/Tmp1075Definitions.h | 51 +- mission/memory/NVMParameterBase.cpp | 56 +- mission/memory/NVMParameterBase.h | 95 +- mission/tmtc/CCSDSHandler.cpp | 406 +- mission/tmtc/CCSDSHandler.h | 230 +- mission/tmtc/VirtualChannel.cpp | 90 +- mission/tmtc/VirtualChannel.h | 66 +- mission/utility/InitMission.h | 12 +- mission/utility/Timestamp.cpp | 32 +- mission/utility/Timestamp.h | 27 +- mission/utility/TmFunnel.cpp | 174 +- mission/utility/TmFunnel.h | 44 +- test/DummyParameter.h | 28 +- test/testtasks/PusTcInjector.cpp | 66 +- test/testtasks/PusTcInjector.h | 113 +- test/testtasks/TestTask.cpp | 140 +- test/testtasks/TestTask.h | 53 +- 207 files changed, 28884 insertions(+), 30264 deletions(-) diff --git a/bsp_hosted/InitMission.cpp b/bsp_hosted/InitMission.cpp index ed6b8820..0ca59db5 100644 --- a/bsp_hosted/InitMission.cpp +++ b/bsp_hosted/InitMission.cpp @@ -1,20 +1,19 @@ #include "InitMission.h" -#include "ObjectFactory.h" #include - +#include #include #include #include -#include #include #include #include - #include #include +#include "ObjectFactory.h" + #ifdef LINUX ServiceInterfaceStream sif::debug("DEBUG"); ServiceInterfaceStream sif::info("INFO"); @@ -27,133 +26,132 @@ ServiceInterfaceStream sif::warning("WARNING", true); ServiceInterfaceStream sif::error("ERROR", true, false, true); #endif -ObjectManagerIF *objectManager = nullptr; +ObjectManagerIF* objectManager = nullptr; void initmission::initMission() { - sif::info << "Building global objects.." << std::endl; - /* Instantiate global object manager and also create all objects */ - ObjectManager::instance()->setObjectFactoryFunction(ObjectFactory::produce, nullptr); - sif::info << "Initializing all objects.." << std::endl; - ObjectManager::instance()->initialize(); + sif::info << "Building global objects.." << std::endl; + /* Instantiate global object manager and also create all objects */ + ObjectManager::instance()->setObjectFactoryFunction(ObjectFactory::produce, nullptr); + sif::info << "Initializing all objects.." << std::endl; + ObjectManager::instance()->initialize(); - /* This function creates and starts all tasks */ - initTasks(); + /* This function creates and starts all tasks */ + initTasks(); } void initmission::initTasks() { - TaskFactory* factory = TaskFactory::instance(); - if(factory == nullptr) { - /* Should never happen ! */ - return; - } + TaskFactory* factory = TaskFactory::instance(); + if (factory == nullptr) { + /* Should never happen ! */ + return; + } #if OBSW_PRINT_MISSED_DEADLINES == 1 - void (*missedDeadlineFunc) (void) = TaskFactory::printMissedDeadline; + void (*missedDeadlineFunc)(void) = TaskFactory::printMissedDeadline; #else - void (*missedDeadlineFunc) (void) = nullptr; + void (*missedDeadlineFunc)(void) = nullptr; #endif - /* TMTC Distribution */ - PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask( - "DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - ReturnValue_t result = tmTcDistributor->addComponent( - objects::CCSDS_PACKET_DISTRIBUTOR); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } - result = tmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } - result = tmTcDistributor->addComponent(objects::TM_FUNNEL); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Object add component failed" << std::endl; - } + /* TMTC Distribution */ + PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask( + "DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + ReturnValue_t result = tmTcDistributor->addComponent(objects::CCSDS_PACKET_DISTRIBUTOR); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } + result = tmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } + result = tmTcDistributor->addComponent(objects::TM_FUNNEL); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } - /* UDP bridge */ - PeriodicTaskIF* tmtcBridgeTask = factory->createPeriodicTask( - "TMTC_UNIX_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - result = tmtcBridgeTask->addComponent(objects::TMTC_BRIDGE); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Add component UDP Unix Bridge failed" << std::endl; - } - PeriodicTaskIF* tmtcPollingTask = factory->createPeriodicTask( - "UDP_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); - result = tmtcPollingTask->addComponent(objects::TMTC_POLLING_TASK); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Add component UDP Polling failed" << std::endl; - } + /* UDP bridge */ + PeriodicTaskIF* tmtcBridgeTask = factory->createPeriodicTask( + "TMTC_UNIX_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + result = tmtcBridgeTask->addComponent(objects::TMTC_BRIDGE); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Add component UDP Unix Bridge failed" << std::endl; + } + PeriodicTaskIF* tmtcPollingTask = factory->createPeriodicTask( + "UDP_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = tmtcPollingTask->addComponent(objects::TMTC_POLLING_TASK); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Add component UDP Polling failed" << std::endl; + } - /* PUS Services */ - PeriodicTaskIF* pusVerification = factory->createPeriodicTask( - "PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } + /* PUS Services */ + PeriodicTaskIF* pusVerification = factory->createPeriodicTask( + "PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } - PeriodicTaskIF* pusEvents = factory->createPeriodicTask( - "PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusVerification->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); - if(result != HasReturnvaluesIF::RETURN_OK){ - initmission::printAddObjectError("PUS5", objects::PUS_SERVICE_5_EVENT_REPORTING); - } + PeriodicTaskIF* pusEvents = factory->createPeriodicTask( + "PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusVerification->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS5", objects::PUS_SERVICE_5_EVENT_REPORTING); + } - PeriodicTaskIF* pusHighPrio = factory->createPeriodicTask( - "PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS2", objects::PUS_SERVICE_2_DEVICE_ACCESS); - } - result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS9", objects::PUS_SERVICE_9_TIME_MGMT); - } + PeriodicTaskIF* pusHighPrio = factory->createPeriodicTask( + "PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS2", objects::PUS_SERVICE_2_DEVICE_ACCESS); + } + result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS9", objects::PUS_SERVICE_9_TIME_MGMT); + } - PeriodicTaskIF* pusMedPrio = factory->createPeriodicTask( - "PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); - result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS8", objects::PUS_SERVICE_8_FUNCTION_MGMT); - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS200", objects::PUS_SERVICE_200_MODE_MGMT); - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS20", objects::PUS_SERVICE_20_PARAMETERS); - } + PeriodicTaskIF* pusMedPrio = factory->createPeriodicTask( + "PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); + result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS8", objects::PUS_SERVICE_8_FUNCTION_MGMT); + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS200", objects::PUS_SERVICE_200_MODE_MGMT); + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS20", objects::PUS_SERVICE_20_PARAMETERS); + } - PeriodicTaskIF* pusLowPrio = factory->createPeriodicTask( - "PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc); - result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS17", objects::PUS_SERVICE_17_TEST); - } + PeriodicTaskIF* pusLowPrio = factory->createPeriodicTask( + "PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc); + result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS17", objects::PUS_SERVICE_17_TEST); + } - PeriodicTaskIF* testTask = factory->createPeriodicTask( - "TEST_TASK", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + PeriodicTaskIF* testTask = factory->createPeriodicTask( + "TEST_TASK", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); #if OBSW_ADD_TEST_CODE == 1 - result = testTask->addComponent(objects::TEST_TASK); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK); - } + result = testTask->addComponent(objects::TEST_TASK); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK); + } #endif /* OBSW_ADD_TEST_CODE == 1 */ - sif::info << "Starting tasks.." << std::endl; - tmTcDistributor->startTask(); - tmtcBridgeTask->startTask(); - tmtcPollingTask->startTask(); + sif::info << "Starting tasks.." << std::endl; + tmTcDistributor->startTask(); + tmtcBridgeTask->startTask(); + tmtcPollingTask->startTask(); - pusVerification->startTask(); - pusEvents->startTask(); - pusHighPrio->startTask(); - pusMedPrio->startTask(); - pusLowPrio->startTask(); + pusVerification->startTask(); + pusEvents->startTask(); + pusHighPrio->startTask(); + pusMedPrio->startTask(); + pusLowPrio->startTask(); #if OBSW_ADD_TEST_CODE == 1 - testTask->startTask(); + testTask->startTask(); #endif /* OBSW_ADD_TEST_CODE == 1 */ - sif::info << "Tasks started.." << std::endl; + sif::info << "Tasks started.." << std::endl; } diff --git a/bsp_hosted/InitMission.h b/bsp_hosted/InitMission.h index 01c72008..507de592 100644 --- a/bsp_hosted/InitMission.h +++ b/bsp_hosted/InitMission.h @@ -4,6 +4,6 @@ namespace initmission { void initMission(); void initTasks(); -}; +}; // namespace initmission #endif /* BSP_LINUX_INITMISSION_H_ */ diff --git a/bsp_hosted/ObjectFactory.cpp b/bsp_hosted/ObjectFactory.cpp index 6803ace4..e1be7588 100644 --- a/bsp_hosted/ObjectFactory.cpp +++ b/bsp_hosted/ObjectFactory.cpp @@ -1,14 +1,14 @@ #include "ObjectFactory.h" -#include "OBSWConfig.h" + +#include +#include +#include +#include #include #include #include -#include -#include - -#include -#include +#include "OBSWConfig.h" #if OBSW_USE_TMTC_TCP_BRIDGE == 0 #include "fsfw/osal/common/UdpTcPollingTask.h" @@ -20,29 +20,28 @@ #include - #if OBSW_ADD_TEST_CODE == 1 #include #endif -void Factory::setStaticFrameworkObjectIds(){ - PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; - PusServiceBase::packetDestination = objects::TM_FUNNEL; +void Factory::setStaticFrameworkObjectIds() { + PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; + PusServiceBase::packetDestination = objects::TM_FUNNEL; - CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; - CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; + CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; + CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; - TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; - // No storage object for now. - TmFunnel::storageDestination = objects::NO_OBJECT; + TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; + // No storage object for now. + TmFunnel::storageDestination = objects::NO_OBJECT; - VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; - TmPacketBase::timeStamperId = objects::TIME_STAMPER; + VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; + TmPacketBase::timeStamperId = objects::TIME_STAMPER; } -void ObjectFactory::produce(void* args){ - Factory::setStaticFrameworkObjectIds(); - ObjectFactory::produceGenericObjects(); +void ObjectFactory::produce(void* args) { + Factory::setStaticFrameworkObjectIds(); + ObjectFactory::produceGenericObjects(); - new TestTask(objects::TEST_TASK); + new TestTask(objects::TEST_TASK); } diff --git a/bsp_hosted/ObjectFactory.h b/bsp_hosted/ObjectFactory.h index feaba70e..b042f9dc 100644 --- a/bsp_hosted/ObjectFactory.h +++ b/bsp_hosted/ObjectFactory.h @@ -1,10 +1,9 @@ #ifndef BSP_LINUX_OBJECTFACTORY_H_ #define BSP_LINUX_OBJECTFACTORY_H_ - namespace ObjectFactory { - void setStatics(); - void produce(void* args); -}; +void setStatics(); +void produce(void* args); +}; // namespace ObjectFactory #endif /* BSP_LINUX_OBJECTFACTORY_H_ */ diff --git a/bsp_hosted/boardconfig/etl_profile.h b/bsp_hosted/boardconfig/etl_profile.h index c35ffb46..54aca344 100644 --- a/bsp_hosted/boardconfig/etl_profile.h +++ b/bsp_hosted/boardconfig/etl_profile.h @@ -32,7 +32,7 @@ SOFTWARE. #define ETL_CHECK_PUSH_POP -#define ETL_CPP11_SUPPORTED 1 -#define ETL_NO_NULLPTR_SUPPORT 0 +#define ETL_CPP11_SUPPORTED 1 +#define ETL_NO_NULLPTR_SUPPORT 0 #endif diff --git a/bsp_hosted/boardconfig/gcov.h b/bsp_hosted/boardconfig/gcov.h index 491d24c6..80acdd86 100644 --- a/bsp_hosted/boardconfig/gcov.h +++ b/bsp_hosted/boardconfig/gcov.h @@ -6,8 +6,9 @@ extern "C" void __gcov_flush(); #else void __gcov_flush() { - sif::info << "GCC GCOV: Please supply GCOV=1 in Makefile if " - "coverage information is desired.\n" << std::flush; + sif::info << "GCC GCOV: Please supply GCOV=1 in Makefile if " + "coverage information is desired.\n" + << std::flush; } #endif diff --git a/bsp_hosted/boardconfig/print.c b/bsp_hosted/boardconfig/print.c index f35f9447..9653fe5f 100644 --- a/bsp_hosted/boardconfig/print.c +++ b/bsp_hosted/boardconfig/print.c @@ -3,13 +3,9 @@ #include void printChar(const char* character, bool errStream) { - if(errStream) { - putc(*character, stderr); - return; - } - putc(*character, stdout); + if (errStream) { + putc(*character, stderr); + return; + } + putc(*character, stdout); } - - - - diff --git a/bsp_hosted/comIF/ArduinoComIF.cpp b/bsp_hosted/comIF/ArduinoComIF.cpp index 2db293e6..be136e45 100644 --- a/bsp_hosted/comIF/ArduinoComIF.cpp +++ b/bsp_hosted/comIF/ArduinoComIF.cpp @@ -1,376 +1,351 @@ #include "ArduinoComIF.h" -#include "ArduinoCookie.h" -#include #include +#include #include +#include "ArduinoCookie.h" + // This only works on Linux #ifdef LINUX -#include #include +#include #include #elif WIN32 -#include #include +#include #endif #include -ArduinoComIF::ArduinoComIF(object_id_t setObjectId, bool promptComIF, - const char *serialDevice): - rxBuffer(MAX_PACKET_SIZE * MAX_NUMBER_OF_SPI_DEVICES*10, true), - SystemObject(setObjectId) { +ArduinoComIF::ArduinoComIF(object_id_t setObjectId, bool promptComIF, const char *serialDevice) + : rxBuffer(MAX_PACKET_SIZE * MAX_NUMBER_OF_SPI_DEVICES * 10, true), SystemObject(setObjectId) { #ifdef LINUX - initialized = false; - serialPort = ::open("/dev/ttyUSB0", O_RDWR); + initialized = false; + serialPort = ::open("/dev/ttyUSB0", O_RDWR); - if (serialPort < 0) { - //configuration error - printf("Error %i from open: %s\n", errno, strerror(errno)); - return; - } + if (serialPort < 0) { + // configuration error + printf("Error %i from open: %s\n", errno, strerror(errno)); + return; + } - struct termios tty; - memset(&tty, 0, sizeof tty); + struct termios tty; + memset(&tty, 0, sizeof tty); - // Read in existing settings, and handle any error - if (tcgetattr(serialPort, &tty) != 0) { - printf("Error %i from tcgetattr: %s\n", errno, strerror(errno)); - return; - } + // Read in existing settings, and handle any error + if (tcgetattr(serialPort, &tty) != 0) { + printf("Error %i from tcgetattr: %s\n", errno, strerror(errno)); + return; + } - tty.c_cflag &= ~PARENB; // Clear parity bit, disabling parity - tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication - tty.c_cflag |= CS8; // 8 bits per byte - tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control - tty.c_lflag &= ~ICANON; //Disable Canonical Mode - tty.c_oflag &= ~OPOST; // Prevent special interpretation of output bytes (e.g. newline chars) - tty.c_oflag &= ~ONLCR; // Prevent conversion of newline to carriage return/line feed - tty.c_cc[VTIME] = 0; // Non Blocking - tty.c_cc[VMIN] = 0; + tty.c_cflag &= ~PARENB; // Clear parity bit, disabling parity + tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication + tty.c_cflag |= CS8; // 8 bits per byte + tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control + tty.c_lflag &= ~ICANON; // Disable Canonical Mode + tty.c_oflag &= ~OPOST; // Prevent special interpretation of output bytes (e.g. newline chars) + tty.c_oflag &= ~ONLCR; // Prevent conversion of newline to carriage return/line feed + tty.c_cc[VTIME] = 0; // Non Blocking + tty.c_cc[VMIN] = 0; - cfsetispeed(&tty, B9600); //Baudrate + cfsetispeed(&tty, B9600); // Baudrate - if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { - //printf("Error %i from tcsetattr: %s\n", errno, strerror(errno)); - return; - } + if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { + // printf("Error %i from tcsetattr: %s\n", errno, strerror(errno)); + return; + } - initialized = true; + initialized = true; #elif WIN32 - DCB serialParams = { 0 }; + DCB serialParams = {0}; - // we need to ask the COM port from the user. - if(promptComIF) { - sif::info << "Please enter the COM port (c to cancel): " << std::flush; - std::string comPort; - while(hCom == INVALID_HANDLE_VALUE) { + // we need to ask the COM port from the user. + if (promptComIF) { + sif::info << "Please enter the COM port (c to cancel): " << std::flush; + std::string comPort; + while (hCom == INVALID_HANDLE_VALUE) { + std::getline(std::cin, comPort); + if (comPort[0] == 'c') { + break; + } + const TCHAR *pcCommPort = comPort.c_str(); + hCom = CreateFileA(pcCommPort, // port name + GENERIC_READ | GENERIC_WRITE, // Read/Write + 0, // No Sharing + NULL, // No Security + OPEN_EXISTING, // Open existing port only + 0, // Non Overlapped I/O + NULL); // Null for Comm Devices - std::getline(std::cin, comPort); - if(comPort[0] == 'c') { - break; - } - const TCHAR *pcCommPort = comPort.c_str(); - hCom = CreateFileA(pcCommPort, //port name - GENERIC_READ | GENERIC_WRITE, //Read/Write - 0, // No Sharing - NULL, // No Security - OPEN_EXISTING,// Open existing port only - 0, // Non Overlapped I/O - NULL); // Null for Comm Devices + if (hCom == INVALID_HANDLE_VALUE) { + if (GetLastError() == 2) { + sif::error << "COM Port does not found!" << std::endl; + } else { + TCHAR err[128]; + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), err, sizeof(err), NULL); + // Handle the error. + sif::info << "CreateFileA Error code: " << GetLastError() << std::endl; + sif::error << err << std::flush; + } + sif::info << "Please enter a valid COM port: " << std::flush; + } + } + } - if (hCom == INVALID_HANDLE_VALUE) - { - if(GetLastError() == 2) { - sif::error << "COM Port does not found!" << std::endl; - } - else { - TCHAR err[128]; - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - err, sizeof(err), NULL); - // Handle the error. - sif::info << "CreateFileA Error code: " << GetLastError() - << std::endl; - sif::error << err << std::flush; - } - sif::info << "Please enter a valid COM port: " << std::flush; - } - } + serialParams.DCBlength = sizeof(serialParams); + if (baudRate == 9600) { + serialParams.BaudRate = CBR_9600; + } + if (baudRate == 115200) { + serialParams.BaudRate = CBR_115200; + } else { + serialParams.BaudRate = baudRate; + } - } + serialParams.ByteSize = 8; + serialParams.Parity = NOPARITY; + serialParams.StopBits = ONESTOPBIT; + SetCommState(hCom, &serialParams); - - serialParams.DCBlength = sizeof(serialParams); - if(baudRate == 9600) { - serialParams.BaudRate = CBR_9600; - } - if(baudRate == 115200) { - serialParams.BaudRate = CBR_115200; - } - else { - serialParams.BaudRate = baudRate; - } - - serialParams.ByteSize = 8; - serialParams.Parity = NOPARITY; - serialParams.StopBits = ONESTOPBIT; - SetCommState(hCom, &serialParams); - - COMMTIMEOUTS timeout = { 0 }; - // This will set the read operation to be blocking until data is received - // and then read continuously until there is a gap of one millisecond. - timeout.ReadIntervalTimeout = 1; - timeout.ReadTotalTimeoutConstant = 0; - timeout.ReadTotalTimeoutMultiplier = 0; - timeout.WriteTotalTimeoutConstant = 0; - timeout.WriteTotalTimeoutMultiplier = 0; - SetCommTimeouts(hCom, &timeout); - // Serial port should now be read for operations. + COMMTIMEOUTS timeout = {0}; + // This will set the read operation to be blocking until data is received + // and then read continuously until there is a gap of one millisecond. + timeout.ReadIntervalTimeout = 1; + timeout.ReadTotalTimeoutConstant = 0; + timeout.ReadTotalTimeoutMultiplier = 0; + timeout.WriteTotalTimeoutConstant = 0; + timeout.WriteTotalTimeoutMultiplier = 0; + SetCommTimeouts(hCom, &timeout); + // Serial port should now be read for operations. #endif } ArduinoComIF::~ArduinoComIF() { #ifdef LINUX - ::close(serialPort); + ::close(serialPort); #elif WIN32 - CloseHandle(hCom); + CloseHandle(hCom); #endif } -ReturnValue_t ArduinoComIF::initializeInterface(CookieIF * cookie) { - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t ArduinoComIF::initializeInterface(CookieIF *cookie) { + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t ArduinoComIF::sendMessage(CookieIF *cookie, const uint8_t *data, - size_t len) { - ArduinoCookie *arduinoCookie = dynamic_cast(cookie); - if (arduinoCookie == nullptr) { - return INVALID_COOKIE_TYPE; - } +ReturnValue_t ArduinoComIF::sendMessage(CookieIF *cookie, const uint8_t *data, size_t len) { + ArduinoCookie *arduinoCookie = dynamic_cast(cookie); + if (arduinoCookie == nullptr) { + return INVALID_COOKIE_TYPE; + } - return sendMessage(arduinoCookie->command, arduinoCookie->address, data, - len); + return sendMessage(arduinoCookie->command, arduinoCookie->address, data, len); } -ReturnValue_t ArduinoComIF::getSendSuccess(CookieIF *cookie) { - return RETURN_OK; +ReturnValue_t ArduinoComIF::getSendSuccess(CookieIF *cookie) { return RETURN_OK; } + +ReturnValue_t ArduinoComIF::requestReceiveMessage(CookieIF *cookie, size_t requestLen) { + return RETURN_OK; } -ReturnValue_t ArduinoComIF::requestReceiveMessage(CookieIF *cookie, - size_t requestLen) { - return RETURN_OK; +ReturnValue_t ArduinoComIF::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, size_t *size) { + handleSerialPortRx(); + + ArduinoCookie *arduinoCookie = dynamic_cast(cookie); + if (arduinoCookie == nullptr) { + return INVALID_COOKIE_TYPE; + } + + *buffer = arduinoCookie->replyBuffer.data(); + *size = arduinoCookie->receivedDataLen; + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t ArduinoComIF::readReceivedMessage(CookieIF *cookie, - uint8_t **buffer, size_t *size) { +ReturnValue_t ArduinoComIF::sendMessage(uint8_t command, uint8_t address, const uint8_t *data, + size_t dataLen) { + if (dataLen > UINT16_MAX) { + return TOO_MUCH_DATA; + } - handleSerialPortRx(); + // being conservative here + uint8_t sendBuffer[(dataLen + 6) * 2 + 2]; - ArduinoCookie *arduinoCookie = dynamic_cast(cookie); - if (arduinoCookie == nullptr) { - return INVALID_COOKIE_TYPE; - } + sendBuffer[0] = DleEncoder::STX_CHAR; - *buffer = arduinoCookie->replyBuffer.data(); - *size = arduinoCookie->receivedDataLen; - return HasReturnvaluesIF::RETURN_OK; -} + uint8_t *currentPosition = sendBuffer + 1; + size_t remainingLen = sizeof(sendBuffer) - 1; + size_t encodedLen = 0; -ReturnValue_t ArduinoComIF::sendMessage(uint8_t command, - uint8_t address, const uint8_t *data, size_t dataLen) { - if (dataLen > UINT16_MAX) { - return TOO_MUCH_DATA; - } + ReturnValue_t result = + DleEncoder::encode(&command, 1, currentPosition, remainingLen, &encodedLen, false); + if (result != RETURN_OK) { + return result; + } + currentPosition += encodedLen; + remainingLen -= encodedLen; // DleEncoder will never return encodedLen > remainingLen - //being conservative here - uint8_t sendBuffer[(dataLen + 6) * 2 + 2]; + result = DleEncoder::encode(&address, 1, currentPosition, remainingLen, &encodedLen, false); + if (result != RETURN_OK) { + return result; + } + currentPosition += encodedLen; + remainingLen -= encodedLen; // DleEncoder will never return encodedLen > remainingLen - sendBuffer[0] = DleEncoder::STX_CHAR; + uint8_t temporaryBuffer[2]; - uint8_t *currentPosition = sendBuffer + 1; - size_t remainingLen = sizeof(sendBuffer) - 1; - size_t encodedLen = 0; + // note to Lukas: yes we _could_ use Serialize here, but for 16 bit it is a bit too much... + temporaryBuffer[0] = dataLen >> 8; // we checked dataLen above + temporaryBuffer[1] = dataLen; - ReturnValue_t result = DleEncoder::encode(&command, 1, currentPosition, - remainingLen, &encodedLen, false); - if (result != RETURN_OK) { - return result; - } - currentPosition += encodedLen; - remainingLen -= encodedLen; //DleEncoder will never return encodedLen > remainingLen + result = + DleEncoder::encode(temporaryBuffer, 2, currentPosition, remainingLen, &encodedLen, false); + if (result != RETURN_OK) { + return result; + } + currentPosition += encodedLen; + remainingLen -= encodedLen; // DleEncoder will never return encodedLen > remainingLen - result = DleEncoder::encode(&address, 1, currentPosition, remainingLen, - &encodedLen, false); - if (result != RETURN_OK) { - return result; - } - currentPosition += encodedLen; - remainingLen -= encodedLen; //DleEncoder will never return encodedLen > remainingLen + // encoding the actual data + result = DleEncoder::encode(data, dataLen, currentPosition, remainingLen, &encodedLen, false); + if (result != RETURN_OK) { + return result; + } + currentPosition += encodedLen; + remainingLen -= encodedLen; // DleEncoder will never return encodedLen > remainingLen - uint8_t temporaryBuffer[2]; + uint16_t crc = CRC::crc16ccitt(&command, 1); + crc = CRC::crc16ccitt(&address, 1, crc); + // fortunately the length is still there + crc = CRC::crc16ccitt(temporaryBuffer, 2, crc); + crc = CRC::crc16ccitt(data, dataLen, crc); - //note to Lukas: yes we _could_ use Serialize here, but for 16 bit it is a bit too much... - temporaryBuffer[0] = dataLen >> 8; //we checked dataLen above - temporaryBuffer[1] = dataLen; + temporaryBuffer[0] = crc >> 8; + temporaryBuffer[1] = crc; - result = DleEncoder::encode(temporaryBuffer, 2, currentPosition, - remainingLen, &encodedLen, false); - if (result != RETURN_OK) { - return result; - } - currentPosition += encodedLen; - remainingLen -= encodedLen; //DleEncoder will never return encodedLen > remainingLen + result = + DleEncoder::encode(temporaryBuffer, 2, currentPosition, remainingLen, &encodedLen, false); + if (result != RETURN_OK) { + return result; + } + currentPosition += encodedLen; + remainingLen -= encodedLen; // DleEncoder will never return encodedLen > remainingLen - //encoding the actual data - result = DleEncoder::encode(data, dataLen, currentPosition, remainingLen, - &encodedLen, false); - if (result != RETURN_OK) { - return result; - } - currentPosition += encodedLen; - remainingLen -= encodedLen; //DleEncoder will never return encodedLen > remainingLen + if (remainingLen > 0) { + *currentPosition = DleEncoder::ETX_CHAR; + } + remainingLen -= 1; - uint16_t crc = CRC::crc16ccitt(&command, 1); - crc = CRC::crc16ccitt(&address, 1, crc); - //fortunately the length is still there - crc = CRC::crc16ccitt(temporaryBuffer, 2, crc); - crc = CRC::crc16ccitt(data, dataLen, crc); - - temporaryBuffer[0] = crc >> 8; - temporaryBuffer[1] = crc; - - result = DleEncoder::encode(temporaryBuffer, 2, currentPosition, - remainingLen, &encodedLen, false); - if (result != RETURN_OK) { - return result; - } - currentPosition += encodedLen; - remainingLen -= encodedLen; //DleEncoder will never return encodedLen > remainingLen - - if (remainingLen > 0) { - *currentPosition = DleEncoder::ETX_CHAR; - } - remainingLen -= 1; - - encodedLen = sizeof(sendBuffer) - remainingLen; + encodedLen = sizeof(sendBuffer) - remainingLen; #ifdef LINUX - ssize_t writtenlen = ::write(serialPort, sendBuffer, encodedLen); - if (writtenlen < 0) { - //we could try to find out what happened... - return RETURN_FAILED; - } - if (writtenlen != encodedLen) { - //the OS failed us, we do not try to block until everything is written, as - //we can not block the whole system here - return RETURN_FAILED; - } - return RETURN_OK; + ssize_t writtenlen = ::write(serialPort, sendBuffer, encodedLen); + if (writtenlen < 0) { + // we could try to find out what happened... + return RETURN_FAILED; + } + if (writtenlen != encodedLen) { + // the OS failed us, we do not try to block until everything is written, as + // we can not block the whole system here + return RETURN_FAILED; + } + return RETURN_OK; #elif WIN32 - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; #endif } void ArduinoComIF::handleSerialPortRx() { #ifdef LINUX - uint32_t availableSpace = rxBuffer.availableWriteSpace(); + uint32_t availableSpace = rxBuffer.availableWriteSpace(); - uint8_t dataFromSerial[availableSpace]; + uint8_t dataFromSerial[availableSpace]; - ssize_t bytesRead = read(serialPort, dataFromSerial, - sizeof(dataFromSerial)); + ssize_t bytesRead = read(serialPort, dataFromSerial, sizeof(dataFromSerial)); - if (bytesRead < 0) { - return; - } + if (bytesRead < 0) { + return; + } - rxBuffer.writeData(dataFromSerial, bytesRead); + rxBuffer.writeData(dataFromSerial, bytesRead); - uint8_t dataReceivedSoFar[rxBuffer.getMaxSize()]; + uint8_t dataReceivedSoFar[rxBuffer.getMaxSize()]; - uint32_t dataLenReceivedSoFar = 0; + uint32_t dataLenReceivedSoFar = 0; - rxBuffer.readData(dataReceivedSoFar, sizeof(dataReceivedSoFar), true, - &dataLenReceivedSoFar); + rxBuffer.readData(dataReceivedSoFar, sizeof(dataReceivedSoFar), true, &dataLenReceivedSoFar); - //look for STX - size_t firstSTXinRawData = 0; - while ((firstSTXinRawData < dataLenReceivedSoFar) - && (dataReceivedSoFar[firstSTXinRawData] != DleEncoder::STX_CHAR)) { - firstSTXinRawData++; - } + // look for STX + size_t firstSTXinRawData = 0; + while ((firstSTXinRawData < dataLenReceivedSoFar) && + (dataReceivedSoFar[firstSTXinRawData] != DleEncoder::STX_CHAR)) { + firstSTXinRawData++; + } - if (dataReceivedSoFar[firstSTXinRawData] != DleEncoder::STX_CHAR) { - //there is no STX in our data, throw it away... - rxBuffer.deleteData(dataLenReceivedSoFar); - return; - } + if (dataReceivedSoFar[firstSTXinRawData] != DleEncoder::STX_CHAR) { + // there is no STX in our data, throw it away... + rxBuffer.deleteData(dataLenReceivedSoFar); + return; + } - uint8_t packet[MAX_PACKET_SIZE]; - size_t packetLen = 0; + uint8_t packet[MAX_PACKET_SIZE]; + size_t packetLen = 0; - size_t readSize = 0; + size_t readSize = 0; - ReturnValue_t result = DleEncoder::decode( - dataReceivedSoFar + firstSTXinRawData, - dataLenReceivedSoFar - firstSTXinRawData, &readSize, packet, - sizeof(packet), &packetLen); + ReturnValue_t result = DleEncoder::decode(dataReceivedSoFar + firstSTXinRawData, + dataLenReceivedSoFar - firstSTXinRawData, &readSize, + packet, sizeof(packet), &packetLen); - size_t toDelete = firstSTXinRawData; - if (result == HasReturnvaluesIF::RETURN_OK) { - handlePacket(packet, packetLen); + size_t toDelete = firstSTXinRawData; + if (result == HasReturnvaluesIF::RETURN_OK) { + handlePacket(packet, packetLen); - // after handling the packet, we can delete it from the raw stream, - // it has been copied to packet - toDelete += readSize; - } + // after handling the packet, we can delete it from the raw stream, + // it has been copied to packet + toDelete += readSize; + } - //remove Data which was processed - rxBuffer.deleteData(toDelete); + // remove Data which was processed + rxBuffer.deleteData(toDelete); #elif WIN32 #endif } -void ArduinoComIF::setBaudrate(uint32_t baudRate) { - this->baudRate = baudRate; -} +void ArduinoComIF::setBaudrate(uint32_t baudRate) { this->baudRate = baudRate; } void ArduinoComIF::handlePacket(uint8_t *packet, size_t packetLen) { - uint16_t crc = CRC::crc16ccitt(packet, packetLen); - if (crc != 0) { - //CRC error - return; - } + uint16_t crc = CRC::crc16ccitt(packet, packetLen); + if (crc != 0) { + // CRC error + return; + } - uint8_t command = packet[0]; - uint8_t address = packet[1]; + uint8_t command = packet[0]; + uint8_t address = packet[1]; - uint16_t size = (packet[2] << 8) + packet[3]; + uint16_t size = (packet[2] << 8) + packet[3]; - if (size != packetLen - 6) { - //Invalid Length - return; - } + if (size != packetLen - 6) { + // Invalid Length + return; + } - switch (command) { - case ArduinoCookie::SPI: { - //ArduinoCookie **itsComplicated; - auto findIter = spiMap.find(address); - if (findIter == spiMap.end()) { - //we do no know this address - return; - } - ArduinoCookie& cookie = findIter->second; - if (packetLen > cookie.maxReplySize + 6) { - packetLen = cookie.maxReplySize + 6; - } - std::memcpy(cookie.replyBuffer.data(), packet + 4, packetLen - 6); - cookie.receivedDataLen = packetLen - 6; - } - break; - default: - return; - } + switch (command) { + case ArduinoCookie::SPI: { + // ArduinoCookie **itsComplicated; + auto findIter = spiMap.find(address); + if (findIter == spiMap.end()) { + // we do no know this address + return; + } + ArduinoCookie &cookie = findIter->second; + if (packetLen > cookie.maxReplySize + 6) { + packetLen = cookie.maxReplySize + 6; + } + std::memcpy(cookie.replyBuffer.data(), packet + 4, packetLen - 6); + cookie.receivedDataLen = packetLen - 6; + } break; + default: + return; + } } diff --git a/bsp_hosted/comIF/ArduinoComIF.h b/bsp_hosted/comIF/ArduinoComIF.h index 84bd959d..8476b6b5 100644 --- a/bsp_hosted/comIF/ArduinoComIF.h +++ b/bsp_hosted/comIF/ArduinoComIF.h @@ -4,8 +4,8 @@ #include #include #include -#include #include +#include #include #include @@ -14,56 +14,53 @@ #include #endif -//Forward declaration, so users don't peek +// Forward declaration, so users don't peek class ArduinoCookie; -class ArduinoComIF: public SystemObject, - public DeviceCommunicationIF { -public: - static const uint8_t MAX_NUMBER_OF_SPI_DEVICES = 8; - static const uint8_t MAX_PACKET_SIZE = 64; +class ArduinoComIF : public SystemObject, public DeviceCommunicationIF { + public: + static const uint8_t MAX_NUMBER_OF_SPI_DEVICES = 8; + static const uint8_t MAX_PACKET_SIZE = 64; - static const uint8_t COMMAND_INVALID = -1; - static const uint8_t COMMAND_SPI = 1; + static const uint8_t COMMAND_INVALID = -1; + static const uint8_t COMMAND_SPI = 1; - ArduinoComIF(object_id_t setObjectId, bool promptComIF = false, - const char *serialDevice = nullptr); - void setBaudrate(uint32_t baudRate); + ArduinoComIF(object_id_t setObjectId, bool promptComIF = false, + const char *serialDevice = nullptr); + void setBaudrate(uint32_t baudRate); - virtual ~ArduinoComIF(); + virtual ~ArduinoComIF(); - /** DeviceCommunicationIF overrides */ - virtual ReturnValue_t initializeInterface(CookieIF * cookie) override; - virtual ReturnValue_t sendMessage(CookieIF *cookie, - const uint8_t * sendData, size_t sendLen) override; - virtual ReturnValue_t getSendSuccess(CookieIF *cookie) override; - virtual ReturnValue_t requestReceiveMessage(CookieIF *cookie, - size_t requestLen) override; - virtual ReturnValue_t readReceivedMessage(CookieIF *cookie, - uint8_t **buffer, size_t *size) override; + /** DeviceCommunicationIF overrides */ + virtual ReturnValue_t initializeInterface(CookieIF *cookie) override; + virtual ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t *sendData, + size_t sendLen) override; + virtual ReturnValue_t getSendSuccess(CookieIF *cookie) override; + virtual ReturnValue_t requestReceiveMessage(CookieIF *cookie, size_t requestLen) override; + virtual ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer, + size_t *size) override; -private: + private: #ifdef LINUX #elif WIN32 - HANDLE hCom = INVALID_HANDLE_VALUE; + HANDLE hCom = INVALID_HANDLE_VALUE; #endif - // remembering if the initialization in the ctor worked - // if not, all calls are disabled - bool initialized = false; - int serialPort = 0; - // Default baud rate is 9600 for now. - uint32_t baudRate = 9600; + // remembering if the initialization in the ctor worked + // if not, all calls are disabled + bool initialized = false; + int serialPort = 0; + // Default baud rate is 9600 for now. + uint32_t baudRate = 9600; - //used to know where to put the data if a reply is received - std::map spiMap; + // used to know where to put the data if a reply is received + std::map spiMap; - SimpleRingBuffer rxBuffer; + SimpleRingBuffer rxBuffer; - ReturnValue_t sendMessage(uint8_t command, uint8_t address, - const uint8_t *data, size_t dataLen); - void handleSerialPortRx(); + ReturnValue_t sendMessage(uint8_t command, uint8_t address, const uint8_t *data, size_t dataLen); + void handleSerialPortRx(); - void handlePacket(uint8_t *packet, size_t packetLen); + void handlePacket(uint8_t *packet, size_t packetLen); }; #endif /* MISSION_ARDUINOCOMMINTERFACE_H_ */ diff --git a/bsp_hosted/comIF/ArduinoCookie.cpp b/bsp_hosted/comIF/ArduinoCookie.cpp index bc698720..89cb1568 100644 --- a/bsp_hosted/comIF/ArduinoCookie.cpp +++ b/bsp_hosted/comIF/ArduinoCookie.cpp @@ -1,8 +1,8 @@ #include -ArduinoCookie::ArduinoCookie(Protocol_t protocol, uint8_t address, - const size_t maxReplySize) : - protocol(protocol), command(protocol), address(address), - maxReplySize(maxReplySize), replyBuffer(maxReplySize) { -} - +ArduinoCookie::ArduinoCookie(Protocol_t protocol, uint8_t address, const size_t maxReplySize) + : protocol(protocol), + command(protocol), + address(address), + maxReplySize(maxReplySize), + replyBuffer(maxReplySize) {} diff --git a/bsp_hosted/comIF/ArduinoCookie.h b/bsp_hosted/comIF/ArduinoCookie.h index a5f91f64..04d4bd83 100644 --- a/bsp_hosted/comIF/ArduinoCookie.h +++ b/bsp_hosted/comIF/ArduinoCookie.h @@ -2,26 +2,21 @@ #define MISSION_ARDUINO_ARDUINOCOOKIE_H_ #include + #include -class ArduinoCookie: public CookieIF { -public: - enum Protocol_t: uint8_t { - INVALID, - SPI, - I2C - }; +class ArduinoCookie : public CookieIF { + public: + enum Protocol_t : uint8_t { INVALID, SPI, I2C }; - ArduinoCookie(Protocol_t protocol, uint8_t address, - const size_t maxReplySize); - - Protocol_t protocol; - uint8_t command; - uint8_t address; - std::vector replyBuffer; - size_t receivedDataLen = 0; - size_t maxReplySize; + ArduinoCookie(Protocol_t protocol, uint8_t address, const size_t maxReplySize); + Protocol_t protocol; + uint8_t command; + uint8_t address; + std::vector replyBuffer; + size_t receivedDataLen = 0; + size_t maxReplySize; }; #endif /* MISSION_ARDUINO_ARDUINOCOOKIE_H_ */ diff --git a/bsp_hosted/fsfwconfig/devices/gpioIds.h b/bsp_hosted/fsfwconfig/devices/gpioIds.h index a4b4ac81..1ede0571 100644 --- a/bsp_hosted/fsfwconfig/devices/gpioIds.h +++ b/bsp_hosted/fsfwconfig/devices/gpioIds.h @@ -2,56 +2,53 @@ #define FSFWCONFIG_DEVICES_GPIOIDS_H_ namespace gpioIds { - enum gpioId_t { - HEATER_0, - HEATER_1, - HEATER_2, - HEATER_3, - HEATER_4, - HEATER_5, - HEATER_6, - HEATER_7, - DEPLSA1, - DEPLSA2, +enum gpioId_t { + HEATER_0, + HEATER_1, + HEATER_2, + HEATER_3, + HEATER_4, + HEATER_5, + HEATER_6, + HEATER_7, + DEPLSA1, + DEPLSA2, - MGM_0_LIS3_CS, - MGM_1_RM3100_CS, - GYRO_0_ADIS_CS, - GYRO_1_L3G_CS, - GYRO_2_L3G_CS, - MGM_2_LIS3_CS, - MGM_3_RM3100_CS, + MGM_0_LIS3_CS, + MGM_1_RM3100_CS, + GYRO_0_ADIS_CS, + GYRO_1_L3G_CS, + GYRO_2_L3G_CS, + MGM_2_LIS3_CS, + MGM_3_RM3100_CS, - TEST_ID_0, - TEST_ID_1, + TEST_ID_0, + TEST_ID_1, - RTD_IC_3, - RTD_IC_4, - RTD_IC_5, - RTD_IC_6, - RTD_IC_7, - RTD_IC_8, - RTD_IC_9, - RTD_IC_10, - RTD_IC_11, - RTD_IC_12, - RTD_IC_13, - RTD_IC_14, - RTD_IC_15, - RTD_IC_16, - RTD_IC_17, - RTD_IC_18, + RTD_IC_3, + RTD_IC_4, + RTD_IC_5, + RTD_IC_6, + RTD_IC_7, + RTD_IC_8, + RTD_IC_9, + RTD_IC_10, + RTD_IC_11, + RTD_IC_12, + RTD_IC_13, + RTD_IC_14, + RTD_IC_15, + RTD_IC_16, + RTD_IC_17, + RTD_IC_18, - SPI_MUX_BIT_1, - SPI_MUX_BIT_2, - SPI_MUX_BIT_3, - SPI_MUX_BIT_4, - SPI_MUX_BIT_5, - SPI_MUX_BIT_6 - }; + SPI_MUX_BIT_1, + SPI_MUX_BIT_2, + SPI_MUX_BIT_3, + SPI_MUX_BIT_4, + SPI_MUX_BIT_5, + SPI_MUX_BIT_6 +}; } - - - #endif /* FSFWCONFIG_DEVICES_GPIOIDS_H_ */ diff --git a/bsp_hosted/fsfwconfig/devices/powerSwitcherList.h b/bsp_hosted/fsfwconfig/devices/powerSwitcherList.h index c216c828..ae259374 100644 --- a/bsp_hosted/fsfwconfig/devices/powerSwitcherList.h +++ b/bsp_hosted/fsfwconfig/devices/powerSwitcherList.h @@ -4,55 +4,54 @@ #include namespace pcduSwitches { - /* Switches are uint8_t datatype and go from 0 to 255 */ - enum SwitcherList { - Q7S, - PAYLOAD_PCDU_CH1, - RW, - TCS_BOARD_8V_HEATER_IN, - SUS_REDUNDANT, - DEPLOYMENT_MECHANISM, - PAYLOAD_PCDU_CH6, - ACS_BOARD_SIDE_B, - PAYLOAD_CAMERA, - TCS_BOARD_3V3, - SYRLINKS, - STAR_TRACKER, - MGT, - SUS_NOMINAL, - SOLAR_CELL_EXP, - PLOC, - ACS_BOARD_SIDE_A, - NUMBER_OF_SWITCHES - }; +/* Switches are uint8_t datatype and go from 0 to 255 */ +enum SwitcherList { + Q7S, + PAYLOAD_PCDU_CH1, + RW, + TCS_BOARD_8V_HEATER_IN, + SUS_REDUNDANT, + DEPLOYMENT_MECHANISM, + PAYLOAD_PCDU_CH6, + ACS_BOARD_SIDE_B, + PAYLOAD_CAMERA, + TCS_BOARD_3V3, + SYRLINKS, + STAR_TRACKER, + MGT, + SUS_NOMINAL, + SOLAR_CELL_EXP, + PLOC, + ACS_BOARD_SIDE_A, + NUMBER_OF_SWITCHES +}; - static const uint8_t ON = 1; - static const uint8_t OFF = 0; +static const uint8_t ON = 1; +static const uint8_t OFF = 0; - /* Output states after reboot of the PDUs */ - static const uint8_t INIT_STATE_Q7S = ON; - static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH1 = OFF; - static const uint8_t INIT_STATE_RW = OFF; +/* Output states after reboot of the PDUs */ +static const uint8_t INIT_STATE_Q7S = ON; +static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH1 = OFF; +static const uint8_t INIT_STATE_RW = OFF; #if BOARD_TE0720 == 1 - /* Because the TE0720 is not connected to the PCDU, this switch is always on */ - static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = ON; +/* Because the TE0720 is not connected to the PCDU, this switch is always on */ +static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = ON; #else - static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = OFF; +static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = OFF; #endif - static const uint8_t INIT_STATE_SUS_REDUNDANT = OFF; - static const uint8_t INIT_STATE_DEPLOYMENT_MECHANISM = OFF; - static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH6 = OFF; - static const uint8_t INIT_STATE_ACS_BOARD_SIDE_B = OFF; - static const uint8_t INIT_STATE_PAYLOAD_CAMERA = OFF; - static const uint8_t INIT_STATE_TCS_BOARD_3V3 = OFF; - static const uint8_t INIT_STATE_SYRLINKS = OFF; - static const uint8_t INIT_STATE_STAR_TRACKER = OFF; - static const uint8_t INIT_STATE_MGT = OFF; - static const uint8_t INIT_STATE_SUS_NOMINAL = OFF; - static const uint8_t INIT_STATE_SOLAR_CELL_EXP = OFF; - static const uint8_t INIT_STATE_PLOC = OFF; - static const uint8_t INIT_STATE_ACS_BOARD_SIDE_A = OFF; -} - +static const uint8_t INIT_STATE_SUS_REDUNDANT = OFF; +static const uint8_t INIT_STATE_DEPLOYMENT_MECHANISM = OFF; +static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH6 = OFF; +static const uint8_t INIT_STATE_ACS_BOARD_SIDE_B = OFF; +static const uint8_t INIT_STATE_PAYLOAD_CAMERA = OFF; +static const uint8_t INIT_STATE_TCS_BOARD_3V3 = OFF; +static const uint8_t INIT_STATE_SYRLINKS = OFF; +static const uint8_t INIT_STATE_STAR_TRACKER = OFF; +static const uint8_t INIT_STATE_MGT = OFF; +static const uint8_t INIT_STATE_SUS_NOMINAL = OFF; +static const uint8_t INIT_STATE_SOLAR_CELL_EXP = OFF; +static const uint8_t INIT_STATE_PLOC = OFF; +static const uint8_t INIT_STATE_ACS_BOARD_SIDE_A = OFF; +} // namespace pcduSwitches #endif /* FSFWCONFIG_DEVICES_POWERSWITCHERLIST_H_ */ diff --git a/bsp_hosted/fsfwconfig/events/subsystemIdRanges.h b/bsp_hosted/fsfwconfig/events/subsystemIdRanges.h index 7335a804..9dc50c50 100644 --- a/bsp_hosted/fsfwconfig/events/subsystemIdRanges.h +++ b/bsp_hosted/fsfwconfig/events/subsystemIdRanges.h @@ -2,6 +2,7 @@ #define CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ #include + #include /** @@ -9,9 +10,7 @@ * Numbers 0-80 are reserved for FSFW Subsystem IDs (framework/events/) */ namespace SUBSYSTEM_ID { -enum: uint8_t { - SUBSYSTEM_ID_START = COMMON_SUBSYSTEM_ID_END -}; +enum : uint8_t { SUBSYSTEM_ID_START = COMMON_SUBSYSTEM_ID_END }; } #endif /* CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ */ diff --git a/bsp_hosted/fsfwconfig/events/translateEvents.cpp b/bsp_hosted/fsfwconfig/events/translateEvents.cpp index 7b9ce4b5..fb9e1bf4 100644 --- a/bsp_hosted/fsfwconfig/events/translateEvents.cpp +++ b/bsp_hosted/fsfwconfig/events/translateEvents.cpp @@ -89,176 +89,176 @@ const char *ACK_FAILURE_STRING = "ACK_FAILURE"; const char *EXE_FAILURE_STRING = "EXE_FAILURE"; const char *CRC_FAILURE_EVENT_STRING = "CRC_FAILURE_EVENT"; -const char * translateEvents(Event event) { - switch( (event & 0xffff) ) { - case(2200): - return STORE_SEND_WRITE_FAILED_STRING; - case(2201): - return STORE_WRITE_FAILED_STRING; - case(2202): - return STORE_SEND_READ_FAILED_STRING; - case(2203): - return STORE_READ_FAILED_STRING; - case(2204): - return UNEXPECTED_MSG_STRING; - case(2205): - return STORING_FAILED_STRING; - case(2206): - return TM_DUMP_FAILED_STRING; - case(2207): - return STORE_INIT_FAILED_STRING; - case(2208): - return STORE_INIT_EMPTY_STRING; - case(2209): - return STORE_CONTENT_CORRUPTED_STRING; - case(2210): - return STORE_INITIALIZE_STRING; - case(2211): - return INIT_DONE_STRING; - case(2212): - return DUMP_FINISHED_STRING; - case(2213): - return DELETION_FINISHED_STRING; - case(2214): - return DELETION_FAILED_STRING; - case(2215): - return AUTO_CATALOGS_SENDING_FAILED_STRING; - case(2600): - return GET_DATA_FAILED_STRING; - case(2601): - return STORE_DATA_FAILED_STRING; - case(2800): - return DEVICE_BUILDING_COMMAND_FAILED_STRING; - case(2801): - return DEVICE_SENDING_COMMAND_FAILED_STRING; - case(2802): - return DEVICE_REQUESTING_REPLY_FAILED_STRING; - case(2803): - return DEVICE_READING_REPLY_FAILED_STRING; - case(2804): - return DEVICE_INTERPRETING_REPLY_FAILED_STRING; - case(2805): - return DEVICE_MISSED_REPLY_STRING; - case(2806): - return DEVICE_UNKNOWN_REPLY_STRING; - case(2807): - return DEVICE_UNREQUESTED_REPLY_STRING; - case(2808): - return INVALID_DEVICE_COMMAND_STRING; - case(2809): - return MONITORING_LIMIT_EXCEEDED_STRING; - case(2810): - return MONITORING_AMBIGUOUS_STRING; - case(4201): - return FUSE_CURRENT_HIGH_STRING; - case(4202): - return FUSE_WENT_OFF_STRING; - case(4204): - return POWER_ABOVE_HIGH_LIMIT_STRING; - case(4205): - return POWER_BELOW_LOW_LIMIT_STRING; - case(4300): - return SWITCH_WENT_OFF_STRING; - case(5000): - return HEATER_ON_STRING; - case(5001): - return HEATER_OFF_STRING; - case(5002): - return HEATER_TIMEOUT_STRING; - case(5003): - return HEATER_STAYED_ON_STRING; - case(5004): - return HEATER_STAYED_OFF_STRING; - case(5200): - return TEMP_SENSOR_HIGH_STRING; - case(5201): - return TEMP_SENSOR_LOW_STRING; - case(5202): - return TEMP_SENSOR_GRADIENT_STRING; - case(5901): - return COMPONENT_TEMP_LOW_STRING; - case(5902): - return COMPONENT_TEMP_HIGH_STRING; - case(5903): - return COMPONENT_TEMP_OOL_LOW_STRING; - case(5904): - return COMPONENT_TEMP_OOL_HIGH_STRING; - case(5905): - return TEMP_NOT_IN_OP_RANGE_STRING; - case(7101): - return FDIR_CHANGED_STATE_STRING; - case(7102): - return FDIR_STARTS_RECOVERY_STRING; - case(7103): - return FDIR_TURNS_OFF_DEVICE_STRING; - case(7201): - return MONITOR_CHANGED_STATE_STRING; - case(7202): - return VALUE_BELOW_LOW_LIMIT_STRING; - case(7203): - return VALUE_ABOVE_HIGH_LIMIT_STRING; - case(7204): - return VALUE_OUT_OF_RANGE_STRING; - case(7301): - return SWITCHING_TM_FAILED_STRING; - case(7400): - return CHANGING_MODE_STRING; - case(7401): - return MODE_INFO_STRING; - case(7402): - return FALLBACK_FAILED_STRING; - case(7403): - return MODE_TRANSITION_FAILED_STRING; - case(7404): - return CANT_KEEP_MODE_STRING; - case(7405): - return OBJECT_IN_INVALID_MODE_STRING; - case(7406): - return FORCING_MODE_STRING; - case(7407): - return MODE_CMD_REJECTED_STRING; - case(7506): - return HEALTH_INFO_STRING; - case(7507): - return CHILD_CHANGED_HEALTH_STRING; - case(7508): - return CHILD_PROBLEMS_STRING; - case(7509): - return OVERWRITING_HEALTH_STRING; - case(7510): - return TRYING_RECOVERY_STRING; - case(7511): - return RECOVERY_STEP_STRING; - case(7512): - return RECOVERY_DONE_STRING; - case(7900): - return RF_AVAILABLE_STRING; - case(7901): - return RF_LOST_STRING; - case(7902): - return BIT_LOCK_STRING; - case(7903): - return BIT_LOCK_LOST_STRING; - case(7905): - return FRAME_PROCESSING_FAILED_STRING; - case(8900): - return CLOCK_SET_STRING; - case(8901): - return CLOCK_SET_FAILURE_STRING; - case(9700): - return TEST_STRING; - case(10600): - return CHANGE_OF_SETUP_PARAMETER_STRING; - case(11101): - return MEMORY_READ_RPT_CRC_FAILURE_STRING; - case(11102): - return ACK_FAILURE_STRING; - case(11103): - return EXE_FAILURE_STRING; - case(11104): - return CRC_FAILURE_EVENT_STRING; - default: - return "UNKNOWN_EVENT"; - } - return 0; +const char *translateEvents(Event event) { + switch ((event & 0xffff)) { + case (2200): + return STORE_SEND_WRITE_FAILED_STRING; + case (2201): + return STORE_WRITE_FAILED_STRING; + case (2202): + return STORE_SEND_READ_FAILED_STRING; + case (2203): + return STORE_READ_FAILED_STRING; + case (2204): + return UNEXPECTED_MSG_STRING; + case (2205): + return STORING_FAILED_STRING; + case (2206): + return TM_DUMP_FAILED_STRING; + case (2207): + return STORE_INIT_FAILED_STRING; + case (2208): + return STORE_INIT_EMPTY_STRING; + case (2209): + return STORE_CONTENT_CORRUPTED_STRING; + case (2210): + return STORE_INITIALIZE_STRING; + case (2211): + return INIT_DONE_STRING; + case (2212): + return DUMP_FINISHED_STRING; + case (2213): + return DELETION_FINISHED_STRING; + case (2214): + return DELETION_FAILED_STRING; + case (2215): + return AUTO_CATALOGS_SENDING_FAILED_STRING; + case (2600): + return GET_DATA_FAILED_STRING; + case (2601): + return STORE_DATA_FAILED_STRING; + case (2800): + return DEVICE_BUILDING_COMMAND_FAILED_STRING; + case (2801): + return DEVICE_SENDING_COMMAND_FAILED_STRING; + case (2802): + return DEVICE_REQUESTING_REPLY_FAILED_STRING; + case (2803): + return DEVICE_READING_REPLY_FAILED_STRING; + case (2804): + return DEVICE_INTERPRETING_REPLY_FAILED_STRING; + case (2805): + return DEVICE_MISSED_REPLY_STRING; + case (2806): + return DEVICE_UNKNOWN_REPLY_STRING; + case (2807): + return DEVICE_UNREQUESTED_REPLY_STRING; + case (2808): + return INVALID_DEVICE_COMMAND_STRING; + case (2809): + return MONITORING_LIMIT_EXCEEDED_STRING; + case (2810): + return MONITORING_AMBIGUOUS_STRING; + case (4201): + return FUSE_CURRENT_HIGH_STRING; + case (4202): + return FUSE_WENT_OFF_STRING; + case (4204): + return POWER_ABOVE_HIGH_LIMIT_STRING; + case (4205): + return POWER_BELOW_LOW_LIMIT_STRING; + case (4300): + return SWITCH_WENT_OFF_STRING; + case (5000): + return HEATER_ON_STRING; + case (5001): + return HEATER_OFF_STRING; + case (5002): + return HEATER_TIMEOUT_STRING; + case (5003): + return HEATER_STAYED_ON_STRING; + case (5004): + return HEATER_STAYED_OFF_STRING; + case (5200): + return TEMP_SENSOR_HIGH_STRING; + case (5201): + return TEMP_SENSOR_LOW_STRING; + case (5202): + return TEMP_SENSOR_GRADIENT_STRING; + case (5901): + return COMPONENT_TEMP_LOW_STRING; + case (5902): + return COMPONENT_TEMP_HIGH_STRING; + case (5903): + return COMPONENT_TEMP_OOL_LOW_STRING; + case (5904): + return COMPONENT_TEMP_OOL_HIGH_STRING; + case (5905): + return TEMP_NOT_IN_OP_RANGE_STRING; + case (7101): + return FDIR_CHANGED_STATE_STRING; + case (7102): + return FDIR_STARTS_RECOVERY_STRING; + case (7103): + return FDIR_TURNS_OFF_DEVICE_STRING; + case (7201): + return MONITOR_CHANGED_STATE_STRING; + case (7202): + return VALUE_BELOW_LOW_LIMIT_STRING; + case (7203): + return VALUE_ABOVE_HIGH_LIMIT_STRING; + case (7204): + return VALUE_OUT_OF_RANGE_STRING; + case (7301): + return SWITCHING_TM_FAILED_STRING; + case (7400): + return CHANGING_MODE_STRING; + case (7401): + return MODE_INFO_STRING; + case (7402): + return FALLBACK_FAILED_STRING; + case (7403): + return MODE_TRANSITION_FAILED_STRING; + case (7404): + return CANT_KEEP_MODE_STRING; + case (7405): + return OBJECT_IN_INVALID_MODE_STRING; + case (7406): + return FORCING_MODE_STRING; + case (7407): + return MODE_CMD_REJECTED_STRING; + case (7506): + return HEALTH_INFO_STRING; + case (7507): + return CHILD_CHANGED_HEALTH_STRING; + case (7508): + return CHILD_PROBLEMS_STRING; + case (7509): + return OVERWRITING_HEALTH_STRING; + case (7510): + return TRYING_RECOVERY_STRING; + case (7511): + return RECOVERY_STEP_STRING; + case (7512): + return RECOVERY_DONE_STRING; + case (7900): + return RF_AVAILABLE_STRING; + case (7901): + return RF_LOST_STRING; + case (7902): + return BIT_LOCK_STRING; + case (7903): + return BIT_LOCK_LOST_STRING; + case (7905): + return FRAME_PROCESSING_FAILED_STRING; + case (8900): + return CLOCK_SET_STRING; + case (8901): + return CLOCK_SET_FAILURE_STRING; + case (9700): + return TEST_STRING; + case (10600): + return CHANGE_OF_SETUP_PARAMETER_STRING; + case (11101): + return MEMORY_READ_RPT_CRC_FAILURE_STRING; + case (11102): + return ACK_FAILURE_STRING; + case (11103): + return EXE_FAILURE_STRING; + case (11104): + return CRC_FAILURE_EVENT_STRING; + default: + return "UNKNOWN_EVENT"; + } + return 0; } diff --git a/bsp_hosted/fsfwconfig/events/translateEvents.h b/bsp_hosted/fsfwconfig/events/translateEvents.h index 9034dcf2..a42d9b5a 100644 --- a/bsp_hosted/fsfwconfig/events/translateEvents.h +++ b/bsp_hosted/fsfwconfig/events/translateEvents.h @@ -3,6 +3,6 @@ #include -const char * translateEvents(Event event); +const char* translateEvents(Event event); #endif /* FSFWCONFIG_EVENTS_TRANSLATEEVENTS_H_ */ diff --git a/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.cpp b/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.cpp index 36ef1b73..fa1c4877 100644 --- a/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.cpp +++ b/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.cpp @@ -1,11 +1,10 @@ #include "MissionMessageTypes.h" + #include void messagetypes::clearMissionMessage(CommandMessage* message) { - switch(message->getMessageType()) { - default: - break; - } + switch (message->getMessageType()) { + default: + break; + } } - - diff --git a/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.h b/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.h index 7e3c448f..1d93ba21 100644 --- a/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.h +++ b/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.h @@ -13,10 +13,10 @@ class CommandMessage; */ namespace messagetypes { enum MESSAGE_TYPE { - MISSION_MESSAGE_TYPE_START = FW_MESSAGES_COUNT, + MISSION_MESSAGE_TYPE_START = FW_MESSAGES_COUNT, }; void clearMissionMessage(CommandMessage* message); -} +} // namespace messagetypes #endif /* CONFIG_IPC_MISSIONMESSAGETYPES_H_ */ diff --git a/bsp_hosted/fsfwconfig/objects/systemObjectList.h b/bsp_hosted/fsfwconfig/objects/systemObjectList.h index 21a5f939..91bd2bed 100644 --- a/bsp_hosted/fsfwconfig/objects/systemObjectList.h +++ b/bsp_hosted/fsfwconfig/objects/systemObjectList.h @@ -1,31 +1,32 @@ #ifndef HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ #define HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ -#include #include +#include + // The objects will be instantiated in the ID order namespace objects { - enum sourceObjects: uint32_t { +enum sourceObjects : uint32_t { - PUS_SERVICE_3 = 0x51000300, - PUS_SERVICE_5 = 0x51000400, - PUS_SERVICE_6 = 0x51000500, - PUS_SERVICE_8 = 0x51000800, - PUS_SERVICE_23 = 0x51002300, - PUS_SERVICE_201 = 0x51020100, + PUS_SERVICE_3 = 0x51000300, + PUS_SERVICE_5 = 0x51000400, + PUS_SERVICE_6 = 0x51000500, + PUS_SERVICE_8 = 0x51000800, + PUS_SERVICE_23 = 0x51002300, + PUS_SERVICE_201 = 0x51020100, - TM_FUNNEL = 0x52000002, + TM_FUNNEL = 0x52000002, - /* Test Task */ + /* Test Task */ - TEST_TASK = 0x42694269, - DUMMY_INTERFACE = 0xCAFECAFE, - DUMMY_HANDLER = 0x4400AFFE, + TEST_TASK = 0x42694269, + DUMMY_INTERFACE = 0xCAFECAFE, + DUMMY_HANDLER = 0x4400AFFE, - /* 0x49 ('I') for Communication Interfaces **/ - ARDUINO_COM_IF = 0x49000001 - }; + /* 0x49 ('I') for Communication Interfaces **/ + ARDUINO_COM_IF = 0x49000001 +}; } #endif /* BSP_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ */ diff --git a/bsp_hosted/fsfwconfig/objects/translateObjects.cpp b/bsp_hosted/fsfwconfig/objects/translateObjects.cpp index 9aac2b47..f29e4d65 100644 --- a/bsp_hosted/fsfwconfig/objects/translateObjects.cpp +++ b/bsp_hosted/fsfwconfig/objects/translateObjects.cpp @@ -1,4 +1,4 @@ -/** +/** * @brief Auto-generated object translation file. * @details * Contains 31 translations. @@ -38,72 +38,72 @@ const char *FSFW_OBJECTS_END_STRING = "FSFW_OBJECTS_END"; const char *DUMMY_INTERFACE_STRING = "DUMMY_INTERFACE"; const char *NO_OBJECT_STRING = "NO_OBJECT"; -const char* translateObject(object_id_t object) { - switch( (object & 0xFFFFFFFF) ) { - case 0x42694269: - return TEST_TASK_STRING; - case 0x4400AFFE: - return DUMMY_HANDLER_STRING; - case 0x49000001: - return ARDUINO_COM_IF_STRING; - case 0x51000300: - return PUS_SERVICE_3_STRING; - case 0x51000400: - return PUS_SERVICE_5_STRING; - case 0x51000500: - return PUS_SERVICE_6_STRING; - case 0x51000800: - return PUS_SERVICE_8_STRING; - case 0x51002300: - return PUS_SERVICE_23_STRING; - case 0x51020100: - return PUS_SERVICE_201_STRING; - case 0x52000002: - return TM_FUNNEL_STRING; - case 0x53000000: - return FSFW_OBJECTS_START_STRING; - case 0x53000001: - return PUS_SERVICE_1_VERIFICATION_STRING; - case 0x53000002: - return PUS_SERVICE_2_DEVICE_ACCESS_STRING; - case 0x53000003: - return PUS_SERVICE_3_HOUSEKEEPING_STRING; - case 0x53000005: - return PUS_SERVICE_5_EVENT_REPORTING_STRING; - case 0x53000008: - return PUS_SERVICE_8_FUNCTION_MGMT_STRING; - case 0x53000009: - return PUS_SERVICE_9_TIME_MGMT_STRING; - case 0x53000017: - return PUS_SERVICE_17_TEST_STRING; - case 0x53000020: - return PUS_SERVICE_20_PARAMETERS_STRING; - case 0x53000200: - return PUS_SERVICE_200_MODE_MGMT_STRING; - case 0x53010000: - return HEALTH_TABLE_STRING; - case 0x53010100: - return MODE_STORE_STRING; - case 0x53030000: - return EVENT_MANAGER_STRING; - case 0x53040000: - return INTERNAL_ERROR_REPORTER_STRING; - case 0x534f0100: - return TC_STORE_STRING; - case 0x534f0200: - return TM_STORE_STRING; - case 0x534f0300: - return IPC_STORE_STRING; - case 0x53500010: - return TIME_STAMPER_STRING; - case 0x53ffffff: - return FSFW_OBJECTS_END_STRING; - case 0xCAFECAFE: - return DUMMY_INTERFACE_STRING; - case 0xFFFFFFFF: - return NO_OBJECT_STRING; - default: - return "UNKNOWN_OBJECT"; - } - return 0; +const char *translateObject(object_id_t object) { + switch ((object & 0xFFFFFFFF)) { + case 0x42694269: + return TEST_TASK_STRING; + case 0x4400AFFE: + return DUMMY_HANDLER_STRING; + case 0x49000001: + return ARDUINO_COM_IF_STRING; + case 0x51000300: + return PUS_SERVICE_3_STRING; + case 0x51000400: + return PUS_SERVICE_5_STRING; + case 0x51000500: + return PUS_SERVICE_6_STRING; + case 0x51000800: + return PUS_SERVICE_8_STRING; + case 0x51002300: + return PUS_SERVICE_23_STRING; + case 0x51020100: + return PUS_SERVICE_201_STRING; + case 0x52000002: + return TM_FUNNEL_STRING; + case 0x53000000: + return FSFW_OBJECTS_START_STRING; + case 0x53000001: + return PUS_SERVICE_1_VERIFICATION_STRING; + case 0x53000002: + return PUS_SERVICE_2_DEVICE_ACCESS_STRING; + case 0x53000003: + return PUS_SERVICE_3_HOUSEKEEPING_STRING; + case 0x53000005: + return PUS_SERVICE_5_EVENT_REPORTING_STRING; + case 0x53000008: + return PUS_SERVICE_8_FUNCTION_MGMT_STRING; + case 0x53000009: + return PUS_SERVICE_9_TIME_MGMT_STRING; + case 0x53000017: + return PUS_SERVICE_17_TEST_STRING; + case 0x53000020: + return PUS_SERVICE_20_PARAMETERS_STRING; + case 0x53000200: + return PUS_SERVICE_200_MODE_MGMT_STRING; + case 0x53010000: + return HEALTH_TABLE_STRING; + case 0x53010100: + return MODE_STORE_STRING; + case 0x53030000: + return EVENT_MANAGER_STRING; + case 0x53040000: + return INTERNAL_ERROR_REPORTER_STRING; + case 0x534f0100: + return TC_STORE_STRING; + case 0x534f0200: + return TM_STORE_STRING; + case 0x534f0300: + return IPC_STORE_STRING; + case 0x53500010: + return TIME_STAMPER_STRING; + case 0x53ffffff: + return FSFW_OBJECTS_END_STRING; + case 0xCAFECAFE: + return DUMMY_INTERFACE_STRING; + case 0xFFFFFFFF: + return NO_OBJECT_STRING; + default: + return "UNKNOWN_OBJECT"; + } + return 0; } diff --git a/bsp_hosted/fsfwconfig/returnvalues/classIds.h b/bsp_hosted/fsfwconfig/returnvalues/classIds.h index cc159fec..b50e8ac0 100644 --- a/bsp_hosted/fsfwconfig/returnvalues/classIds.h +++ b/bsp_hosted/fsfwconfig/returnvalues/classIds.h @@ -1,9 +1,10 @@ #ifndef CONFIG_RETURNVALUES_CLASSIDS_H_ #define CONFIG_RETURNVALUES_CLASSIDS_H_ -#include "commonClassIds.h" #include +#include "commonClassIds.h" + /** * Source IDs starts at 73 for now * Framework IDs for ReturnValues run from 0 to 56 @@ -11,9 +12,8 @@ */ namespace CLASS_ID { enum { - CLASS_ID_START = COMMON_CLASS_ID_END, + CLASS_ID_START = COMMON_CLASS_ID_END, }; } - #endif /* CONFIG_RETURNVALUES_CLASSIDS_H_ */ diff --git a/bsp_hosted/fsfwconfig/tmtc/apid.h b/bsp_hosted/fsfwconfig/tmtc/apid.h index ee2fc7c4..9d5c9ed5 100644 --- a/bsp_hosted/fsfwconfig/tmtc/apid.h +++ b/bsp_hosted/fsfwconfig/tmtc/apid.h @@ -12,8 +12,7 @@ * APID is a 11 bit number */ namespace apid { - static const uint16_t EIVE_OBSW = 0x65; +static const uint16_t EIVE_OBSW = 0x65; } - #endif /* FSFWCONFIG_TMTC_APID_H_ */ diff --git a/bsp_hosted/fsfwconfig/tmtc/pusIds.h b/bsp_hosted/fsfwconfig/tmtc/pusIds.h index a2dd7575..37503786 100644 --- a/bsp_hosted/fsfwconfig/tmtc/pusIds.h +++ b/bsp_hosted/fsfwconfig/tmtc/pusIds.h @@ -2,21 +2,21 @@ #define CONFIG_TMTC_PUSIDS_HPP_ namespace pus { -enum Ids{ - PUS_SERVICE_1 = 1, - PUS_SERVICE_2 = 2, - PUS_SERVICE_3 = 3, - PUS_SERVICE_3_PSB = 3, - PUS_SERVICE_5 = 5, - PUS_SERVICE_6 = 6, - PUS_SERVICE_8 = 8, - PUS_SERVICE_9 = 9, - PUS_SERVICE_17 = 17, - PUS_SERVICE_19 = 19, - PUS_SERVICE_20 = 20, - PUS_SERVICE_23 = 23, - PUS_SERVICE_200 = 200, - PUS_SERVICE_201 = 201, +enum Ids { + PUS_SERVICE_1 = 1, + PUS_SERVICE_2 = 2, + PUS_SERVICE_3 = 3, + PUS_SERVICE_3_PSB = 3, + PUS_SERVICE_5 = 5, + PUS_SERVICE_6 = 6, + PUS_SERVICE_8 = 8, + PUS_SERVICE_9 = 9, + PUS_SERVICE_17 = 17, + PUS_SERVICE_19 = 19, + PUS_SERVICE_20 = 20, + PUS_SERVICE_23 = 23, + PUS_SERVICE_200 = 200, + PUS_SERVICE_201 = 201, }; }; diff --git a/bsp_hosted/main.cpp b/bsp_hosted/main.cpp index 153cc447..b7ebc422 100644 --- a/bsp_hosted/main.cpp +++ b/bsp_hosted/main.cpp @@ -1,10 +1,9 @@ +#include + #include "InitMission.h" #include "OBSWVersion.h" - #include "fsfw/FSFWVersion.h" #include "fsfw/tasks/TaskFactory.h" - -#include #ifdef WIN32 static const char* COMPILE_PRINTOUT = "Windows"; #elif LINUX @@ -17,21 +16,18 @@ static const char* COMPILE_PRINTOUT = "unknown OS"; * Linux and Windows. * @return */ -int main(void) -{ - std::cout << "-- EIVE OBSW --" << std::endl; - std::cout << "-- Compiled for " << COMPILE_PRINTOUT << " --" << std::endl; - std::cout << "-- OBSW " << SW_NAME << " v" << SW_VERSION << "." << SW_SUBVERSION << - "." << SW_REVISION << ", FSFW v" << FSFW_VERSION << "." << FSFW_SUBVERSION << "." << - FSFW_REVISION << "--" << std::endl; - std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; +int main(void) { + std::cout << "-- EIVE OBSW --" << std::endl; + std::cout << "-- Compiled for " << COMPILE_PRINTOUT << " --" << std::endl; + std::cout << "-- OBSW " << SW_NAME << " v" << SW_VERSION << "." << SW_SUBVERSION << "." + << SW_REVISION << ", FSFW v" << FSFW_VERSION << "." << FSFW_SUBVERSION << "." + << FSFW_REVISION << "--" << std::endl; + std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; - initmission::initMission(); + initmission::initMission(); - for(;;) { - // suspend main thread by sleeping it. - TaskFactory::delayTask(5000); - } + for (;;) { + // suspend main thread by sleeping it. + TaskFactory::delayTask(5000); + } } - - diff --git a/bsp_linux_board/InitMission.cpp b/bsp_linux_board/InitMission.cpp index d265fded..86d5fb4b 100644 --- a/bsp_linux_board/InitMission.cpp +++ b/bsp_linux_board/InitMission.cpp @@ -1,247 +1,244 @@ #include "InitMission.h" -#include "ObjectFactory.h" -#include "objects/systemObjectList.h" -#include "OBSWConfig.h" -#include "pollingsequence/pollingSequenceFactory.h" - -#include +#include #include #include #include -#include #include #include #include +#include #include +#include "OBSWConfig.h" +#include "ObjectFactory.h" +#include "objects/systemObjectList.h" +#include "pollingsequence/pollingSequenceFactory.h" + ServiceInterfaceStream sif::debug("DEBUG"); ServiceInterfaceStream sif::info("INFO"); ServiceInterfaceStream sif::warning("WARNING"); ServiceInterfaceStream sif::error("ERROR"); -ObjectManagerIF *objectManager = nullptr; +ObjectManagerIF* objectManager = nullptr; void initmission::initMission() { - sif::info << "Building global objects.." << std::endl; - /* Instantiate global object manager and also create all objects */ - ObjectManager::instance()->setObjectFactoryFunction(ObjectFactory::produce, nullptr); - sif::info << "Initializing all objects.." << std::endl; - ObjectManager::instance()->initialize(); + sif::info << "Building global objects.." << std::endl; + /* Instantiate global object manager and also create all objects */ + ObjectManager::instance()->setObjectFactoryFunction(ObjectFactory::produce, nullptr); + sif::info << "Initializing all objects.." << std::endl; + ObjectManager::instance()->initialize(); - /* This function creates and starts all tasks */ - initTasks(); + /* This function creates and starts all tasks */ + initTasks(); } void initmission::initTasks() { - TaskFactory* factory = TaskFactory::instance(); - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - if(factory == nullptr) { - /* Should never happen ! */ - return; - } + TaskFactory* factory = TaskFactory::instance(); + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + if (factory == nullptr) { + /* Should never happen ! */ + return; + } #if OBSW_PRINT_MISSED_DEADLINES == 1 - void (*missedDeadlineFunc) (void) = TaskFactory::printMissedDeadline; + void (*missedDeadlineFunc)(void) = TaskFactory::printMissedDeadline; #else - void (*missedDeadlineFunc) (void) = nullptr; + void (*missedDeadlineFunc)(void) = nullptr; #endif + /* TMTC Distribution */ + PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask( + "DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + result = tmTcDistributor->addComponent(objects::CCSDS_PACKET_DISTRIBUTOR); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } + result = tmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } + result = tmTcDistributor->addComponent(objects::TM_FUNNEL); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } - /* TMTC Distribution */ - PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask( - "DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - result = tmTcDistributor->addComponent(objects::CCSDS_PACKET_DISTRIBUTOR); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } - result = tmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } - result = tmTcDistributor->addComponent(objects::TM_FUNNEL); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Object add component failed" << std::endl; - } + /* UDP bridge */ + PeriodicTaskIF* udpBridgeTask = factory->createPeriodicTask( + "UDP_UNIX_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + result = udpBridgeTask->addComponent(objects::TMTC_BRIDGE); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Add component UDP Unix Bridge failed" << std::endl; + } + PeriodicTaskIF* udpPollingTask = factory->createPeriodicTask( + "UDP_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = udpPollingTask->addComponent(objects::TMTC_POLLING_TASK); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Add component UDP Polling failed" << std::endl; + } - /* UDP bridge */ - PeriodicTaskIF* udpBridgeTask = factory->createPeriodicTask( - "UDP_UNIX_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - result = udpBridgeTask->addComponent(objects::TMTC_BRIDGE); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Add component UDP Unix Bridge failed" << std::endl; - } - PeriodicTaskIF* udpPollingTask = factory->createPeriodicTask( - "UDP_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); - result = udpPollingTask->addComponent(objects::TMTC_POLLING_TASK); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Add component UDP Polling failed" << std::endl; - } + /* PUS Services */ + std::vector pusTasks; + createPusTasks(*factory, missedDeadlineFunc, pusTasks); - /* PUS Services */ - std::vector pusTasks; - createPusTasks(*factory, missedDeadlineFunc, pusTasks); - - std::vector pstTasks; - createPstTasks(*factory, missedDeadlineFunc, pstTasks); + std::vector pstTasks; + createPstTasks(*factory, missedDeadlineFunc, pstTasks); #if OBSW_ADD_TEST_CODE == 1 - std::vector testTasks; - createTestTasks(*factory, missedDeadlineFunc, pstTasks); + std::vector testTasks; + createTestTasks(*factory, missedDeadlineFunc, pstTasks); #endif /* OBSW_ADD_TEST_CODE == 1 */ - auto taskStarter = [](std::vector& taskVector, std::string name) { - for(const auto& task: taskVector) { - if(task != nullptr) { - task->startTask(); - } - else { - sif::error << "Task in vector " << name << " is invalid!" << std::endl; - } - } - }; + auto taskStarter = [](std::vector& taskVector, std::string name) { + for (const auto& task : taskVector) { + if (task != nullptr) { + task->startTask(); + } else { + sif::error << "Task in vector " << name << " is invalid!" << std::endl; + } + } + }; - sif::info << "Starting tasks.." << std::endl; - tmTcDistributor->startTask(); - udpBridgeTask->startTask(); - udpPollingTask->startTask(); + sif::info << "Starting tasks.." << std::endl; + tmTcDistributor->startTask(); + udpBridgeTask->startTask(); + udpPollingTask->startTask(); - taskStarter(pusTasks, "PUS Tasks"); + taskStarter(pusTasks, "PUS Tasks"); #if OBSW_ADD_TEST_CODE == 1 - taskStarter(testTasks, "Test Tasks"); + taskStarter(testTasks, "Test Tasks"); #endif /* OBSW_ADD_TEST_CODE == 1 */ - taskStarter(pstTasks, "PST Tasks"); + taskStarter(pstTasks, "PST Tasks"); #if OBSW_ADD_TEST_PST == 1 - if(startTestPst) { - pstTestTask->startTask(); - } + if (startTestPst) { + pstTestTask->startTask(); + } #endif /* RPI_TEST_ACS_BOARD == 1 */ - sif::info << "Tasks started.." << std::endl; + sif::info << "Tasks started.." << std::endl; } void initmission::createPusTasks(TaskFactory& factory, - TaskDeadlineMissedFunction missedDeadlineFunc, std::vector& taskVec) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - PeriodicTaskIF* pusVerification = factory.createPeriodicTask( - "PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } - taskVec.push_back(pusVerification); + TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + PeriodicTaskIF* pusVerification = factory.createPeriodicTask( + "PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } + taskVec.push_back(pusVerification); - PeriodicTaskIF* pusEvents = factory.createPeriodicTask( - "PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusEvents->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_EVENTS", objects::PUS_SERVICE_5_EVENT_REPORTING); - } - result = pusEvents->addComponent(objects::EVENT_MANAGER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_MGMT", objects::EVENT_MANAGER); - } - taskVec.push_back(pusEvents); + PeriodicTaskIF* pusEvents = factory.createPeriodicTask( + "PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusEvents->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_EVENTS", objects::PUS_SERVICE_5_EVENT_REPORTING); + } + result = pusEvents->addComponent(objects::EVENT_MANAGER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_MGMT", objects::EVENT_MANAGER); + } + taskVec.push_back(pusEvents); - PeriodicTaskIF* pusHighPrio = factory.createPeriodicTask( - "PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS2", objects::PUS_SERVICE_2_DEVICE_ACCESS); - } - result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS9", objects::PUS_SERVICE_9_TIME_MGMT); - } - taskVec.push_back(pusHighPrio); + PeriodicTaskIF* pusHighPrio = factory.createPeriodicTask( + "PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS2", objects::PUS_SERVICE_2_DEVICE_ACCESS); + } + result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS9", objects::PUS_SERVICE_9_TIME_MGMT); + } + taskVec.push_back(pusHighPrio); - PeriodicTaskIF* pusMedPrio = factory.createPeriodicTask( - "PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); - result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS8", objects::PUS_SERVICE_8_FUNCTION_MGMT); - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS200", objects::PUS_SERVICE_200_MODE_MGMT); - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS20", objects::PUS_SERVICE_20_PARAMETERS); - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_3_HOUSEKEEPING); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS3", objects::PUS_SERVICE_3_HOUSEKEEPING); - } - taskVec.push_back(pusMedPrio); + PeriodicTaskIF* pusMedPrio = factory.createPeriodicTask( + "PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); + result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS8", objects::PUS_SERVICE_8_FUNCTION_MGMT); + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS200", objects::PUS_SERVICE_200_MODE_MGMT); + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS20", objects::PUS_SERVICE_20_PARAMETERS); + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_3_HOUSEKEEPING); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS3", objects::PUS_SERVICE_3_HOUSEKEEPING); + } + taskVec.push_back(pusMedPrio); - PeriodicTaskIF* pusLowPrio = factory.createPeriodicTask( - "PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc); - result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS17", objects::PUS_SERVICE_17_TEST); - } - result = pusLowPrio->addComponent(objects::INTERNAL_ERROR_REPORTER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("INT_ERR_RPRT", - objects::INTERNAL_ERROR_REPORTER); - } - taskVec.push_back(pusLowPrio); + PeriodicTaskIF* pusLowPrio = factory.createPeriodicTask( + "PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc); + result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS17", objects::PUS_SERVICE_17_TEST); + } + result = pusLowPrio->addComponent(objects::INTERNAL_ERROR_REPORTER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("INT_ERR_RPRT", objects::INTERNAL_ERROR_REPORTER); + } + taskVec.push_back(pusLowPrio); } void initmission::createPstTasks(TaskFactory& factory, - TaskDeadlineMissedFunction missedDeadlineFunc, std::vector &taskVec) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; #if OBSW_ADD_SPI_TEST_CODE == 0 - FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask( - "SPI_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 3.0, - missedDeadlineFunc); - result = pst::pstSpi(spiPst); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; - } - taskVec.push_back(spiPst); + FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask( + "SPI_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 3.0, missedDeadlineFunc); + result = pst::pstSpi(spiPst); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; + } + taskVec.push_back(spiPst); #endif } void initmission::createTestTasks(TaskFactory& factory, - TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector &taskVec) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - PeriodicTaskIF* testTask = factory.createPeriodicTask( - "TEST_TASK", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); - result = testTask->addComponent(objects::TEST_TASK); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK); - } + TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + PeriodicTaskIF* testTask = factory.createPeriodicTask( + "TEST_TASK", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = testTask->addComponent(objects::TEST_TASK); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK); + } #if RPI_ADD_SPI_TEST == 1 - result = testTask->addComponent(objects::SPI_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("SPI_TEST", objects::SPI_TEST); - } + result = testTask->addComponent(objects::SPI_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("SPI_TEST", objects::SPI_TEST); + } #endif /* RPI_ADD_SPI_TEST == 1 */ #if RPI_ADD_GPIO_TEST == 1 - result = testTask->addComponent(objects::LIBGPIOD_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("GPIOD_TEST", objects::LIBGPIOD_TEST); - } + result = testTask->addComponent(objects::LIBGPIOD_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("GPIOD_TEST", objects::LIBGPIOD_TEST); + } #endif /* RPI_ADD_GPIO_TEST == 1 */ #if RPI_ADD_UART_TEST == 1 - result = testTask->addComponent(objects::UART_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("UART_TEST", objects::UART_TEST); - } + result = testTask->addComponent(objects::UART_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("UART_TEST", objects::UART_TEST); + } #endif /* RPI_ADD_GPIO_TEST == 1 */ - bool startTestPst = true; - static_cast(startTestPst); + bool startTestPst = true; + static_cast(startTestPst); #if OBSW_ADD_TEST_PST == 1 - FixedTimeslotTaskIF* pstTestTask = factory->createFixedTimeslotTask("TEST_PST", 50, - PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 2.0, missedDeadlineFunc); - result = pst::pstTest(pstTestTask); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::info << "initmission::initTasks: ACS PST empty or invalid" << std::endl; - startTestPst = false; - } + FixedTimeslotTaskIF* pstTestTask = factory->createFixedTimeslotTask( + "TEST_PST", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 2.0, missedDeadlineFunc); + result = pst::pstTest(pstTestTask); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::info << "initmission::initTasks: ACS PST empty or invalid" << std::endl; + startTestPst = false; + } #endif /* RPI_TEST_ACS_BOARD == 1 */ - } diff --git a/bsp_linux_board/InitMission.h b/bsp_linux_board/InitMission.h index f5da5855..f14135dd 100644 --- a/bsp_linux_board/InitMission.h +++ b/bsp_linux_board/InitMission.h @@ -1,9 +1,10 @@ #ifndef BSP_LINUX_INITMISSION_H_ #define BSP_LINUX_INITMISSION_H_ -#include "fsfw/tasks/Typedef.h" #include +#include "fsfw/tasks/Typedef.h" + class PeriodicTaskIF; class TaskFactory; @@ -11,14 +12,12 @@ namespace initmission { void initMission(); void initTasks(); -void createPstTasks(TaskFactory& factory, - TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector &taskVec); -void createTestTasks(TaskFactory& factory, - TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector &taskVec); +void createPstTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec); +void createTestTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec); void createPusTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector& taskVec); -}; + std::vector& taskVec); +}; // namespace initmission #endif /* BSP_LINUX_INITMISSION_H_ */ diff --git a/bsp_linux_board/ObjectFactory.cpp b/bsp_linux_board/ObjectFactory.cpp index bb86ecce..71966164 100644 --- a/bsp_linux_board/ObjectFactory.cpp +++ b/bsp_linux_board/ObjectFactory.cpp @@ -1,236 +1,241 @@ -#include #include "ObjectFactory.h" -#include "objects/systemObjectList.h" +#include +#include + +#include "OBSWConfig.h" #include "devices/addresses.h" #include "devices/gpioIds.h" -#include "OBSWConfig.h" -#include "tmtc/apid.h" -#include "tmtc/pusIds.h" +#include "fsfw/datapoollocal/LocalDataPoolManager.h" +#include "fsfw/tasks/TaskFactory.h" +#include "fsfw/tmtcpacket/pus/tm.h" +#include "fsfw/tmtcservices/CommandingServiceBase.h" +#include "fsfw/tmtcservices/PusServiceBase.h" #include "linux/boardtest/LibgpiodTest.h" #include "linux/boardtest/SpiTestClass.h" #include "linux/boardtest/UartTestClass.h" - #include "mission/core/GenericFactory.h" -#include "mission/utility/TmFunnel.h" -#include #include "mission/devices/GyroADIS1650XHandler.h" - -#include "fsfw/datapoollocal/LocalDataPoolManager.h" -#include "fsfw/tmtcservices/CommandingServiceBase.h" -#include "fsfw/tmtcservices/PusServiceBase.h" -#include "fsfw/tmtcpacket/pus/tm.h" -#include "fsfw/tasks/TaskFactory.h" +#include "mission/utility/TmFunnel.h" +#include "objects/systemObjectList.h" +#include "tmtc/apid.h" +#include "tmtc/pusIds.h" /* UDP server includes */ #if OBSW_USE_TMTC_TCP_BRIDGE == 1 #include #include #else -#include "fsfw/osal/common/UdpTmTcBridge.h" #include "fsfw/osal/common/UdpTcPollingTask.h" +#include "fsfw/osal/common/UdpTmTcBridge.h" #endif -#include "fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h" -#include "fsfw_hal/devicehandlers/MgmRM3100Handler.h" -#include "fsfw_hal/devicehandlers/GyroL3GD20Handler.h" -#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" -#include "fsfw_hal/linux/rpi/GpioRPi.h" -#include "fsfw_hal/common/gpio/GpioCookie.h" -#include "fsfw_hal/linux/spi/SpiCookie.h" -#include "fsfw_hal/linux/spi/SpiComIF.h" #include #include +#include "fsfw_hal/common/gpio/GpioCookie.h" +#include "fsfw_hal/devicehandlers/GyroL3GD20Handler.h" +#include "fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h" +#include "fsfw_hal/devicehandlers/MgmRM3100Handler.h" +#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" +#include "fsfw_hal/linux/rpi/GpioRPi.h" +#include "fsfw_hal/linux/spi/SpiComIF.h" +#include "fsfw_hal/linux/spi/SpiCookie.h" + void Factory::setStaticFrameworkObjectIds() { - PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; - PusServiceBase::packetDestination = objects::TM_FUNNEL; + PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; + PusServiceBase::packetDestination = objects::TM_FUNNEL; - CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; - CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; + CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; + CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; - TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; - // No storage object for now. - TmFunnel::storageDestination = objects::NO_OBJECT; + TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; + // No storage object for now. + TmFunnel::storageDestination = objects::NO_OBJECT; - VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; - TmPacketBase::timeStamperId = objects::TIME_STAMPER; + VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; + TmPacketBase::timeStamperId = objects::TIME_STAMPER; } - - -void ObjectFactory::produce(void* args){ - Factory::setStaticFrameworkObjectIds(); - ObjectFactory::produceGenericObjects(); +void ObjectFactory::produce(void* args) { + Factory::setStaticFrameworkObjectIds(); + ObjectFactory::produceGenericObjects(); #if OBSW_USE_TMTC_TCP_BRIDGE == 1 - auto tmtcBridge = new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - tmtcBridge->setMaxNumberOfPacketsStored(50); - new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); + auto tmtcBridge = new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + tmtcBridge->setMaxNumberOfPacketsStored(50); + new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); #else - auto tmtcBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - tmtcBridge->setMaxNumberOfPacketsStored(50); - new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); + auto tmtcBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + tmtcBridge->setMaxNumberOfPacketsStored(50); + new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); #endif - GpioIF* gpioIF = new LinuxLibgpioIF(objects::GPIO_IF); - GpioCookie* gpioCookie = nullptr; - static_cast(gpioCookie); + GpioIF* gpioIF = new LinuxLibgpioIF(objects::GPIO_IF); + GpioCookie* gpioCookie = nullptr; + static_cast(gpioCookie); - new SpiComIF(objects::SPI_COM_IF, gpioIF); + new SpiComIF(objects::SPI_COM_IF, gpioIF); - std::string spiDev; - SpiCookie* spiCookie = nullptr; - static_cast(spiCookie); + std::string spiDev; + SpiCookie* spiCookie = nullptr; + static_cast(spiCookie); #if OBSW_ADD_ACS_BOARD == 1 - if(gpioCookie == nullptr) { - gpioCookie = new GpioCookie(); - } - // TODO: Missing pin for Gyro 2 - gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_0_LIS3_CS, gpio::MGM_0_BCM_PIN, - "MGM_0_LIS3", gpio::Direction::OUT, 1); - gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_1_RM3100_CS, gpio::MGM_1_BCM_PIN, - "MGM_1_RM3100", gpio::Direction::OUT, 1); - gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_2_LIS3_CS, gpio::MGM_2_BCM_PIN, - "MGM_2_LIS3", gpio::Direction::OUT, 1); - gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_3_RM3100_CS, gpio::MGM_3_BCM_PIN, - "MGM_3_RM3100", gpio::Direction::OUT, 1); - gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_0_ADIS_CS, gpio::GYRO_0_BCM_PIN, - "GYRO_0_ADIS", gpio::Direction::OUT, 1); - gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_1_L3G_CS, gpio::GYRO_1_BCM_PIN, - "GYRO_1_L3G", gpio::Direction::OUT, 1); - gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_2_ADIS_CS, gpio::GYRO_2_BCM_PIN, - "GYRO_2_ADIS", gpio::Direction::OUT, 1); - gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_3_L3G_CS, gpio::GYRO_3_BCM_PIN, - "GYRO_3_L3G", gpio::Direction::OUT, 1); - gpioIF->addGpios(gpioCookie); + if (gpioCookie == nullptr) { + gpioCookie = new GpioCookie(); + } + // TODO: Missing pin for Gyro 2 + gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_0_LIS3_CS, gpio::MGM_0_BCM_PIN, "MGM_0_LIS3", + gpio::Direction::OUT, 1); + gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_1_RM3100_CS, gpio::MGM_1_BCM_PIN, + "MGM_1_RM3100", gpio::Direction::OUT, 1); + gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_2_LIS3_CS, gpio::MGM_2_BCM_PIN, "MGM_2_LIS3", + gpio::Direction::OUT, 1); + gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_3_RM3100_CS, gpio::MGM_3_BCM_PIN, + "MGM_3_RM3100", gpio::Direction::OUT, 1); + gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_0_ADIS_CS, gpio::GYRO_0_BCM_PIN, + "GYRO_0_ADIS", gpio::Direction::OUT, 1); + gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_1_L3G_CS, gpio::GYRO_1_BCM_PIN, "GYRO_1_L3G", + gpio::Direction::OUT, 1); + gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_2_ADIS_CS, gpio::GYRO_2_BCM_PIN, + "GYRO_2_ADIS", gpio::Direction::OUT, 1); + gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_3_L3G_CS, gpio::GYRO_3_BCM_PIN, "GYRO_3_L3G", + gpio::Direction::OUT, 1); + gpioIF->addGpios(gpioCookie); - spiDev = "/dev/spidev0.1"; - spiCookie = new SpiCookie(addresses::MGM_0_LIS3, gpioIds::MGM_0_LIS3_CS, spiDev, - MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); - auto mgmLis3Handler = new MgmLIS3MDLHandler(objects::MGM_0_LIS3_HANDLER, - objects::SPI_COM_IF, spiCookie, 0); - mgmLis3Handler->setStartUpImmediately(); + spiDev = "/dev/spidev0.1"; + spiCookie = + new SpiCookie(addresses::MGM_0_LIS3, gpioIds::MGM_0_LIS3_CS, spiDev, + MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); + auto mgmLis3Handler = + new MgmLIS3MDLHandler(objects::MGM_0_LIS3_HANDLER, objects::SPI_COM_IF, spiCookie, 0); + mgmLis3Handler->setStartUpImmediately(); #if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1 - mgmLis3Handler->setToGoToNormalMode(true); + mgmLis3Handler->setToGoToNormalMode(true); #endif - spiCookie = new SpiCookie(addresses::MGM_1_RM3100, gpioIds::MGM_1_RM3100_CS, spiDev, - RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); - auto mgmRm3100Handler = new MgmRM3100Handler(objects::MGM_1_RM3100_HANDLER, - objects::SPI_COM_IF, spiCookie, 0); - mgmRm3100Handler->setStartUpImmediately(); + spiCookie = + new SpiCookie(addresses::MGM_1_RM3100, gpioIds::MGM_1_RM3100_CS, spiDev, + RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); + auto mgmRm3100Handler = + new MgmRM3100Handler(objects::MGM_1_RM3100_HANDLER, objects::SPI_COM_IF, spiCookie, 0); + mgmRm3100Handler->setStartUpImmediately(); #if FSFW_HAL_RM3100_MGM_DEBUG == 1 - mgmRm3100Handler->setToGoToNormalMode(true); + mgmRm3100Handler->setToGoToNormalMode(true); #endif - spiCookie = new SpiCookie(addresses::MGM_2_LIS3, gpioIds::MGM_2_LIS3_CS, spiDev, - MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); - mgmLis3Handler = new MgmLIS3MDLHandler(objects::MGM_2_LIS3_HANDLER, - objects::SPI_COM_IF, spiCookie, 0); - mgmLis3Handler->setStartUpImmediately(); + spiCookie = + new SpiCookie(addresses::MGM_2_LIS3, gpioIds::MGM_2_LIS3_CS, spiDev, + MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); + mgmLis3Handler = + new MgmLIS3MDLHandler(objects::MGM_2_LIS3_HANDLER, objects::SPI_COM_IF, spiCookie, 0); + mgmLis3Handler->setStartUpImmediately(); #if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1 - mgmLis3Handler->setToGoToNormalMode(true); + mgmLis3Handler->setToGoToNormalMode(true); #endif - spiCookie = new SpiCookie(addresses::MGM_3_RM3100, gpioIds::MGM_3_RM3100_CS, spiDev, - RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); - mgmRm3100Handler = new MgmRM3100Handler(objects::MGM_3_RM3100_HANDLER, - objects::SPI_COM_IF, spiCookie, 0); - mgmRm3100Handler->setStartUpImmediately(); + spiCookie = + new SpiCookie(addresses::MGM_3_RM3100, gpioIds::MGM_3_RM3100_CS, spiDev, + RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); + mgmRm3100Handler = + new MgmRM3100Handler(objects::MGM_3_RM3100_HANDLER, objects::SPI_COM_IF, spiCookie, 0); + mgmRm3100Handler->setStartUpImmediately(); #if FSFW_HAL_RM3100_MGM_DEBUG == 1 - mgmRm3100Handler->setToGoToNormalMode(true); + mgmRm3100Handler->setToGoToNormalMode(true); #endif - spiCookie = new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, spiDev, - ADIS16507::MAXIMUM_REPLY_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); - auto adisHandler = new GyroADIS16507Handler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, - spiCookie); - adisHandler->setStartUpImmediately(); - spiCookie = new SpiCookie(addresses::GYRO_1_L3G, gpioIds::GYRO_1_L3G_CS, spiDev, - L3GD20H::MAX_BUFFER_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); - auto gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_1_L3G_HANDLER, objects::SPI_COM_IF, - spiCookie, 0); - gyroL3gHandler->setStartUpImmediately(); -#if FSFW_HAL_L3GD20_GYRO_DEBUG== 1 - gyroL3gHandler->setToGoToNormalMode(true); + spiCookie = + new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, spiDev, + ADIS16507::MAXIMUM_REPLY_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); + auto adisHandler = + new GyroADIS16507Handler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, spiCookie); + adisHandler->setStartUpImmediately(); + spiCookie = + new SpiCookie(addresses::GYRO_1_L3G, gpioIds::GYRO_1_L3G_CS, spiDev, L3GD20H::MAX_BUFFER_SIZE, + spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); + auto gyroL3gHandler = + new GyroHandlerL3GD20H(objects::GYRO_1_L3G_HANDLER, objects::SPI_COM_IF, spiCookie, 0); + gyroL3gHandler->setStartUpImmediately(); +#if FSFW_HAL_L3GD20_GYRO_DEBUG == 1 + gyroL3gHandler->setToGoToNormalMode(true); #endif - spiCookie = new SpiCookie(addresses::GYRO_2_ADIS, gpioIds::GYRO_2_ADIS_CS, spiDev, - ADIS16507::MAXIMUM_REPLY_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); - adisHandler = new GyroADIS16507Handler(objects::GYRO_2_ADIS_HANDLER, objects::SPI_COM_IF, - spiCookie); - adisHandler->setStartUpImmediately(); + spiCookie = + new SpiCookie(addresses::GYRO_2_ADIS, gpioIds::GYRO_2_ADIS_CS, spiDev, + ADIS16507::MAXIMUM_REPLY_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); + adisHandler = + new GyroADIS16507Handler(objects::GYRO_2_ADIS_HANDLER, objects::SPI_COM_IF, spiCookie); + adisHandler->setStartUpImmediately(); - spiCookie = new SpiCookie(addresses::GYRO_3_L3G, gpioIds::GYRO_3_L3G_CS, spiDev, - L3GD20H::MAX_BUFFER_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); - gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_3_L3G_HANDLER, objects::SPI_COM_IF, - spiCookie, 0); - gyroL3gHandler->setStartUpImmediately(); -#if FSFW_HAL_L3GD20_GYRO_DEBUG== 1 - gyroL3gHandler->setToGoToNormalMode(true); + spiCookie = + new SpiCookie(addresses::GYRO_3_L3G, gpioIds::GYRO_3_L3G_CS, spiDev, L3GD20H::MAX_BUFFER_SIZE, + spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); + gyroL3gHandler = + new GyroHandlerL3GD20H(objects::GYRO_3_L3G_HANDLER, objects::SPI_COM_IF, spiCookie, 0); + gyroL3gHandler->setStartUpImmediately(); +#if FSFW_HAL_L3GD20_GYRO_DEBUG == 1 + gyroL3gHandler->setToGoToNormalMode(true); #endif #endif /* RPI_TEST_ACS_BOARD == 1 */ #if OBSW_ADD_TEST_CODE == 1 - createTestTasks(); + createTestTasks(); #endif /* OBSW_ADD_TEST_CODE == 1 */ } void ObjectFactory::createTestTasks() { - - new TestTask(objects::TEST_TASK); + new TestTask(objects::TEST_TASK); #if RPI_ADD_SPI_TEST == 1 - new SpiTestClass(objects::SPI_TEST, gpioIF); + new SpiTestClass(objects::SPI_TEST, gpioIF); #endif #if RPI_ADD_UART_TEST == 1 - new UartTestClass(objects::UART_TEST); + new UartTestClass(objects::UART_TEST); #else - new UartComIF(objects::UART_COM_IF); + new UartComIF(objects::UART_COM_IF); #endif #if RPI_LOOPBACK_TEST_GPIO == 1 - GpioCookie* gpioCookieLoopback = new GpioCookie(); - /* Loopback pins. Adapt according to setup */ - gpioId_t gpioIdSender = gpioIds::TEST_ID_0; - int bcmPinSender = 26; - gpioId_t gpioIdReader = gpioIds::TEST_ID_1; - int bcmPinReader = 16; - gpio::createRpiGpioConfig(gpioCookieLoopback, gpioIdSender, bcmPinSender, "GPIO_LB_SENDER", - gpio::Direction::OUT, 0); - gpio::createRpiGpioConfig(gpioCookieLoopback, gpioIdReader, bcmPinReader, "GPIO_LB_READER", - gpio::Direction::IN, 0); - new LibgpiodTest(objects::LIBGPIOD_TEST, objects::GPIO_IF, gpioCookieLoopback); + GpioCookie* gpioCookieLoopback = new GpioCookie(); + /* Loopback pins. Adapt according to setup */ + gpioId_t gpioIdSender = gpioIds::TEST_ID_0; + int bcmPinSender = 26; + gpioId_t gpioIdReader = gpioIds::TEST_ID_1; + int bcmPinReader = 16; + gpio::createRpiGpioConfig(gpioCookieLoopback, gpioIdSender, bcmPinSender, "GPIO_LB_SENDER", + gpio::Direction::OUT, 0); + gpio::createRpiGpioConfig(gpioCookieLoopback, gpioIdReader, bcmPinReader, "GPIO_LB_READER", + gpio::Direction::IN, 0); + new LibgpiodTest(objects::LIBGPIOD_TEST, objects::GPIO_IF, gpioCookieLoopback); #endif /* RPI_LOOPBACK_TEST_GPIO == 1 */ #if RPI_TEST_ADIS16507 == 1 - if(gpioCookie == nullptr) { - gpioCookie = new GpioCookie(); - } - gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_0_ADIS_CS, gpio::GYRO_0_BCM_PIN, - "GYRO_0_ADIS", gpio::Direction::OUT, 1); - gpioIF->addGpios(gpioCookie); + if (gpioCookie == nullptr) { + gpioCookie = new GpioCookie(); + } + gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_0_ADIS_CS, gpio::GYRO_0_BCM_PIN, + "GYRO_0_ADIS", gpio::Direction::OUT, 1); + gpioIF->addGpios(gpioCookie); - spiDev = "/dev/spidev0.1"; - spiCookie = new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, spiDev, - ADIS16507::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, spi::DEFAULT_ADIS16507_SPEED, - nullptr, nullptr); - auto adisGyroHandler = new GyroADIS16507Handler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, spiCookie); - adisGyroHandler->setStartUpImmediately(); + spiDev = "/dev/spidev0.1"; + spiCookie = new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, spiDev, + ADIS16507::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, + spi::DEFAULT_ADIS16507_SPEED, nullptr, nullptr); + auto adisGyroHandler = + new GyroADIS16507Handler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, spiCookie); + adisGyroHandler->setStartUpImmediately(); #endif /* RPI_TEST_ADIS16507 == 1 */ #if RPI_TEST_GPS_HANDLER == 1 - UartCookie* uartCookie = new UartCookie(objects::GPS0_HANDLER, "/dev/serial0", - UartModes::CANONICAL, 9600, 1024); - uartCookie->setToFlushInput(true); - uartCookie->setReadCycles(6); - GPSHyperionHandler* gpsHandler = new GPSHyperionHandler(objects::GPS0_HANDLER, - objects::UART_COM_IF, uartCookie, false); - gpsHandler->setStartUpImmediately(); + UartCookie* uartCookie = + new UartCookie(objects::GPS0_HANDLER, "/dev/serial0", UartModes::CANONICAL, 9600, 1024); + uartCookie->setToFlushInput(true); + uartCookie->setReadCycles(6); + GPSHyperionHandler* gpsHandler = + new GPSHyperionHandler(objects::GPS0_HANDLER, objects::UART_COM_IF, uartCookie, false); + gpsHandler->setStartUpImmediately(); #endif - } diff --git a/bsp_linux_board/ObjectFactory.h b/bsp_linux_board/ObjectFactory.h index 3b9aca49..909baf06 100644 --- a/bsp_linux_board/ObjectFactory.h +++ b/bsp_linux_board/ObjectFactory.h @@ -1,12 +1,11 @@ #ifndef BSP_LINUX_OBJECTFACTORY_H_ #define BSP_LINUX_OBJECTFACTORY_H_ - namespace ObjectFactory { - void setStatics(); - void produce(void* args); +void setStatics(); +void produce(void* args); - void createTestTasks(); -}; +void createTestTasks(); +}; // namespace ObjectFactory #endif /* BSP_LINUX_OBJECTFACTORY_H_ */ diff --git a/bsp_linux_board/boardconfig/etl_profile.h b/bsp_linux_board/boardconfig/etl_profile.h index c35ffb46..54aca344 100644 --- a/bsp_linux_board/boardconfig/etl_profile.h +++ b/bsp_linux_board/boardconfig/etl_profile.h @@ -32,7 +32,7 @@ SOFTWARE. #define ETL_CHECK_PUSH_POP -#define ETL_CPP11_SUPPORTED 1 -#define ETL_NO_NULLPTR_SUPPORT 0 +#define ETL_CPP11_SUPPORTED 1 +#define ETL_NO_NULLPTR_SUPPORT 0 #endif diff --git a/bsp_linux_board/boardconfig/gcov.h b/bsp_linux_board/boardconfig/gcov.h index 491d24c6..80acdd86 100644 --- a/bsp_linux_board/boardconfig/gcov.h +++ b/bsp_linux_board/boardconfig/gcov.h @@ -6,8 +6,9 @@ extern "C" void __gcov_flush(); #else void __gcov_flush() { - sif::info << "GCC GCOV: Please supply GCOV=1 in Makefile if " - "coverage information is desired.\n" << std::flush; + sif::info << "GCC GCOV: Please supply GCOV=1 in Makefile if " + "coverage information is desired.\n" + << std::flush; } #endif diff --git a/bsp_linux_board/boardconfig/print.c b/bsp_linux_board/boardconfig/print.c index c501e0b7..3aba2d73 100644 --- a/bsp_linux_board/boardconfig/print.c +++ b/bsp_linux_board/boardconfig/print.c @@ -2,13 +2,9 @@ #include void printChar(const char* character, bool errStream) { - if(errStream) { - putc(*character, stderr); - return; - } - putc(*character, stdout); + if (errStream) { + putc(*character, stderr); + return; + } + putc(*character, stdout); } - - - - diff --git a/bsp_linux_board/main.cpp b/bsp_linux_board/main.cpp index a766f2a0..4e286f5d 100644 --- a/bsp_linux_board/main.cpp +++ b/bsp_linux_board/main.cpp @@ -1,12 +1,11 @@ +#include + #include "InitMission.h" #include "OBSWConfig.h" #include "OBSWVersion.h" - #include "fsfw/FSFWVersion.h" #include "fsfw/tasks/TaskFactory.h" -#include - #ifdef RASPBERRY_PI static const char* const BOARD_NAME = "Raspberry Pi"; #elif defined(BEAGLEBONEBLACK) @@ -19,21 +18,18 @@ static const char* const BOARD_NAME = "Unknown Board"; * @brief This is the main program and entry point for the Raspberry Pi. * @return */ -int main(void) -{ - std::cout << "-- EIVE OBSW --" << std::endl; - std::cout << "-- Compiled for Linux board " << BOARD_NAME << " --" << std::endl; - std::cout << "-- OBSW " << SW_NAME << " v" << SW_VERSION << "." << SW_SUBVERSION << - "." << SW_REVISION << ", FSFW v" << FSFW_VERSION << "." << FSFW_SUBVERSION << - FSFW_REVISION << "--" << std::endl; - std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; +int main(void) { + std::cout << "-- EIVE OBSW --" << std::endl; + std::cout << "-- Compiled for Linux board " << BOARD_NAME << " --" << std::endl; + std::cout << "-- OBSW " << SW_NAME << " v" << SW_VERSION << "." << SW_SUBVERSION << "." + << SW_REVISION << ", FSFW v" << FSFW_VERSION << "." << FSFW_SUBVERSION << FSFW_REVISION + << "--" << std::endl; + std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; - initmission::initMission(); + initmission::initMission(); - for(;;) { - /* Suspend main thread by sleeping it. */ - TaskFactory::delayTask(5000); - } + for (;;) { + /* Suspend main thread by sleeping it. */ + TaskFactory::delayTask(5000); + } } - - diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index 34516fa6..e41ed093 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -19,58 +19,58 @@ static constexpr char UIO_PDEC_CONFIG_MEMORY[] = "/dev/uio2"; static constexpr char UIO_PDEC_RAM[] = "/dev/uio3"; namespace gpioNames { - static constexpr char GYRO_0_ADIS_CS[] = "gyro_0_adis_chip_select"; - static constexpr char GYRO_1_L3G_CS[] = "gyro_1_l3g_chip_select"; - static constexpr char GYRO_2_ADIS_CS[] = "gyro_2_adis_chip_select"; - static constexpr char GYRO_3_L3G_CS[] = "gyro_3_l3g_chip_select"; - static constexpr char MGM_0_CS[] = "mgm_0_lis3_chip_select"; - static constexpr char MGM_1_CS[] = "mgm_1_rm3100_chip_select"; - static constexpr char MGM_2_CS[] = "mgm_2_lis3_chip_select"; - static constexpr char MGM_3_CS[] = "mgm_3_rm3100_chip_select"; - static constexpr char RESET_GNSS_0[] = "reset_gnss_0"; - static constexpr char RESET_GNSS_1[] = "reset_gnss_1"; - static constexpr char GNSS_0_ENABLE[] = "enable_gnss_0"; - static constexpr char GNSS_1_ENABLE[] = "enable_gnss_1"; - static constexpr char GYRO_0_ENABLE[] = "enable_gyro_0"; - static constexpr char GYRO_2_ENABLE[] = "enable_gyro_2"; - static constexpr char HEATER_0[] = "heater0"; - static constexpr char HEATER_1[] = "heater1"; - static constexpr char HEATER_2[] = "heater2"; - static constexpr char HEATER_3[] = "heater3"; - static constexpr char HEATER_4[] = "heater4"; - static constexpr char HEATER_5[] = "heater5"; - static constexpr char HEATER_6[] = "heater6"; - static constexpr char HEATER_7[] = "heater7"; - static constexpr char SA_DPL_PIN_0[] = "sa_dpl_0"; - static constexpr char SA_DPL_PIN_1[] = "sa_dpl_1"; - static constexpr char SPI_MUX_BIT_1_PIN[] = "spi_mux_bit_1"; - static constexpr char SPI_MUX_BIT_2_PIN[] = "spi_mux_bit_2"; - static constexpr char SPI_MUX_BIT_3_PIN[] = "spi_mux_bit_3"; - static constexpr char SPI_MUX_BIT_4_PIN[] = "spi_mux_bit_4"; - static constexpr char SPI_MUX_BIT_5_PIN[] = "spi_mux_bit_5"; - static constexpr char SPI_MUX_BIT_6_PIN[] = "spi_mux_bit_6"; - static constexpr char EN_RW_CS[] = "en_rw_cs"; - static constexpr char EN_RW_1[] = "enable_rw_1"; - static constexpr char EN_RW_2[] = "enable_rw_2"; - static constexpr char EN_RW_3[] = "enable_rw_3"; - static constexpr char EN_RW_4[] = "enable_rw_4"; - static constexpr char GNSS_MUX_SELECT[] = "gnss_mux_select"; - static constexpr char RAD_SENSOR_CHIP_SELECT[] = "rad_sensor_chip_select"; - static constexpr char PAPB_BUSY_SIGNAL_VC0[] = "papb_busy_signal_vc0"; - static constexpr char PAPB_EMPTY_SIGNAL_VC0[] = "papb_empty_signal_vc0"; - static constexpr char PAPB_BUSY_SIGNAL_VC1[] = "papb_busy_signal_vc1"; - static constexpr char PAPB_EMPTY_SIGNAL_VC1[] = "papb_empty_signal_vc1"; - static constexpr char PAPB_BUSY_SIGNAL_VC2[] = "papb_busy_signal_vc2"; - static constexpr char PAPB_EMPTY_SIGNAL_VC2[] = "papb_empty_signal_vc2"; - static constexpr char PAPB_BUSY_SIGNAL_VC3[] = "papb_busy_signal_vc3"; - static constexpr char PAPB_EMPTY_SIGNAL_VC3[] = "papb_empty_signal_vc3"; - static constexpr char RS485_EN_TX_CLOCK[] = "tx_clock_enable_ltc2872"; - 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"; -} -} +static constexpr char GYRO_0_ADIS_CS[] = "gyro_0_adis_chip_select"; +static constexpr char GYRO_1_L3G_CS[] = "gyro_1_l3g_chip_select"; +static constexpr char GYRO_2_ADIS_CS[] = "gyro_2_adis_chip_select"; +static constexpr char GYRO_3_L3G_CS[] = "gyro_3_l3g_chip_select"; +static constexpr char MGM_0_CS[] = "mgm_0_lis3_chip_select"; +static constexpr char MGM_1_CS[] = "mgm_1_rm3100_chip_select"; +static constexpr char MGM_2_CS[] = "mgm_2_lis3_chip_select"; +static constexpr char MGM_3_CS[] = "mgm_3_rm3100_chip_select"; +static constexpr char RESET_GNSS_0[] = "reset_gnss_0"; +static constexpr char RESET_GNSS_1[] = "reset_gnss_1"; +static constexpr char GNSS_0_ENABLE[] = "enable_gnss_0"; +static constexpr char GNSS_1_ENABLE[] = "enable_gnss_1"; +static constexpr char GYRO_0_ENABLE[] = "enable_gyro_0"; +static constexpr char GYRO_2_ENABLE[] = "enable_gyro_2"; +static constexpr char HEATER_0[] = "heater0"; +static constexpr char HEATER_1[] = "heater1"; +static constexpr char HEATER_2[] = "heater2"; +static constexpr char HEATER_3[] = "heater3"; +static constexpr char HEATER_4[] = "heater4"; +static constexpr char HEATER_5[] = "heater5"; +static constexpr char HEATER_6[] = "heater6"; +static constexpr char HEATER_7[] = "heater7"; +static constexpr char SA_DPL_PIN_0[] = "sa_dpl_0"; +static constexpr char SA_DPL_PIN_1[] = "sa_dpl_1"; +static constexpr char SPI_MUX_BIT_1_PIN[] = "spi_mux_bit_1"; +static constexpr char SPI_MUX_BIT_2_PIN[] = "spi_mux_bit_2"; +static constexpr char SPI_MUX_BIT_3_PIN[] = "spi_mux_bit_3"; +static constexpr char SPI_MUX_BIT_4_PIN[] = "spi_mux_bit_4"; +static constexpr char SPI_MUX_BIT_5_PIN[] = "spi_mux_bit_5"; +static constexpr char SPI_MUX_BIT_6_PIN[] = "spi_mux_bit_6"; +static constexpr char EN_RW_CS[] = "en_rw_cs"; +static constexpr char EN_RW_1[] = "enable_rw_1"; +static constexpr char EN_RW_2[] = "enable_rw_2"; +static constexpr char EN_RW_3[] = "enable_rw_3"; +static constexpr char EN_RW_4[] = "enable_rw_4"; +static constexpr char GNSS_MUX_SELECT[] = "gnss_mux_select"; +static constexpr char RAD_SENSOR_CHIP_SELECT[] = "rad_sensor_chip_select"; +static constexpr char PAPB_BUSY_SIGNAL_VC0[] = "papb_busy_signal_vc0"; +static constexpr char PAPB_EMPTY_SIGNAL_VC0[] = "papb_empty_signal_vc0"; +static constexpr char PAPB_BUSY_SIGNAL_VC1[] = "papb_busy_signal_vc1"; +static constexpr char PAPB_EMPTY_SIGNAL_VC1[] = "papb_empty_signal_vc1"; +static constexpr char PAPB_BUSY_SIGNAL_VC2[] = "papb_busy_signal_vc2"; +static constexpr char PAPB_EMPTY_SIGNAL_VC2[] = "papb_empty_signal_vc2"; +static constexpr char PAPB_BUSY_SIGNAL_VC3[] = "papb_busy_signal_vc3"; +static constexpr char PAPB_EMPTY_SIGNAL_VC3[] = "papb_empty_signal_vc3"; +static constexpr char RS485_EN_TX_CLOCK[] = "tx_clock_enable_ltc2872"; +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 #endif /* BSP_Q7S_BOARDCONFIG_BUSCONF_H_ */ diff --git a/bsp_q7s/boardconfig/etl_profile.h b/bsp_q7s/boardconfig/etl_profile.h index c35ffb46..54aca344 100644 --- a/bsp_q7s/boardconfig/etl_profile.h +++ b/bsp_q7s/boardconfig/etl_profile.h @@ -32,7 +32,7 @@ SOFTWARE. #define ETL_CHECK_PUSH_POP -#define ETL_CPP11_SUPPORTED 1 -#define ETL_NO_NULLPTR_SUPPORT 0 +#define ETL_CPP11_SUPPORTED 1 +#define ETL_NO_NULLPTR_SUPPORT 0 #endif diff --git a/bsp_q7s/boardconfig/gcov.h b/bsp_q7s/boardconfig/gcov.h index 491d24c6..80acdd86 100644 --- a/bsp_q7s/boardconfig/gcov.h +++ b/bsp_q7s/boardconfig/gcov.h @@ -6,8 +6,9 @@ extern "C" void __gcov_flush(); #else void __gcov_flush() { - sif::info << "GCC GCOV: Please supply GCOV=1 in Makefile if " - "coverage information is desired.\n" << std::flush; + sif::info << "GCC GCOV: Please supply GCOV=1 in Makefile if " + "coverage information is desired.\n" + << std::flush; } #endif diff --git a/bsp_q7s/boardconfig/print.c b/bsp_q7s/boardconfig/print.c index c501e0b7..3aba2d73 100644 --- a/bsp_q7s/boardconfig/print.c +++ b/bsp_q7s/boardconfig/print.c @@ -2,13 +2,9 @@ #include void printChar(const char* character, bool errStream) { - if(errStream) { - putc(*character, stderr); - return; - } - putc(*character, stdout); + if (errStream) { + putc(*character, stderr); + return; + } + putc(*character, stdout); } - - - - diff --git a/bsp_q7s/boardtest/FileSystemTest.cpp b/bsp_q7s/boardtest/FileSystemTest.cpp index 92c4cf3d..e1dd564d 100644 --- a/bsp_q7s/boardtest/FileSystemTest.cpp +++ b/bsp_q7s/boardtest/FileSystemTest.cpp @@ -1,26 +1,23 @@ #include "FileSystemTest.h" + +#include +#include + #include "fsfw/timemanager/Stopwatch.h" -#include -#include - -enum SdCard { - SDC0, - SDC1 -}; +enum SdCard { SDC0, SDC1 }; FileSystemTest::FileSystemTest() { - using namespace std; - SdCard sdCard = SdCard::SDC0; - cout << "SD Card Test for SD card " << static_cast(sdCard) << std::endl; - //Stopwatch stopwatch; - std::system("q7hw sd info all > /tmp/sd_status.txt"); - //stopwatch.stop(true); - std::system("q7hw sd set 0 on > /tmp/sd_set.txt"); - //stopwatch.stop(true); - std::system("q7hw sd set 0 off > /tmp/sd_set.txt"); - //stopwatch.stop(true); + using namespace std; + SdCard sdCard = SdCard::SDC0; + cout << "SD Card Test for SD card " << static_cast(sdCard) << std::endl; + // Stopwatch stopwatch; + std::system("q7hw sd info all > /tmp/sd_status.txt"); + // stopwatch.stop(true); + std::system("q7hw sd set 0 on > /tmp/sd_set.txt"); + // stopwatch.stop(true); + std::system("q7hw sd set 0 off > /tmp/sd_set.txt"); + // stopwatch.stop(true); } -FileSystemTest::~FileSystemTest() { -} +FileSystemTest::~FileSystemTest() {} diff --git a/bsp_q7s/boardtest/FileSystemTest.h b/bsp_q7s/boardtest/FileSystemTest.h index 256a0b36..bdb7989f 100644 --- a/bsp_q7s/boardtest/FileSystemTest.h +++ b/bsp_q7s/boardtest/FileSystemTest.h @@ -2,12 +2,11 @@ #define BSP_Q7S_BOARDTEST_FILESYSTEMTEST_H_ class FileSystemTest { -public: - FileSystemTest(); - virtual~ FileSystemTest(); -private: + public: + FileSystemTest(); + virtual ~FileSystemTest(); + + private: }; - - #endif /* BSP_Q7S_BOARDTEST_FILESYSTEMTEST_H_ */ diff --git a/bsp_q7s/boardtest/Q7STestTask.cpp b/bsp_q7s/boardtest/Q7STestTask.cpp index dc87cd3b..5d9042ac 100644 --- a/bsp_q7s/boardtest/Q7STestTask.cpp +++ b/bsp_q7s/boardtest/Q7STestTask.cpp @@ -1,414 +1,397 @@ +#include "Q7STestTask.h" + #include #include #include -#include "Q7STestTask.h" - -#include "bsp_q7s/memory/SdCardManager.h" -#include "bsp_q7s/memory/scratchApi.h" - -#include "fsfw/timemanager/Stopwatch.h" -#include "fsfw/tasks/TaskFactory.h" - -#include "test/DummyParameter.h" - -#include #include #include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include -Q7STestTask::Q7STestTask(object_id_t objectId): TestTask(objectId) { - doTestSdCard = false; - doTestScratchApi = false; - doTestGps = false; +#include "bsp_q7s/memory/SdCardManager.h" +#include "bsp_q7s/memory/scratchApi.h" +#include "fsfw/tasks/TaskFactory.h" +#include "fsfw/timemanager/Stopwatch.h" +#include "test/DummyParameter.h" + +Q7STestTask::Q7STestTask(object_id_t objectId) : TestTask(objectId) { + doTestSdCard = false; + doTestScratchApi = false; + doTestGps = false; } ReturnValue_t Q7STestTask::performOneShotAction() { - if (doTestSdCard) { - testSdCard(); - } - if (doTestScratchApi) { - testScratchApi(); - } - //testJsonLibDirect(); - //testDummyParams(); - //testProtHandler(); - FsOpCodes opCode = FsOpCodes::APPEND_TO_FILE; - testFileSystemHandlerDirect(opCode); - return TestTask::performOneShotAction(); + if (doTestSdCard) { + testSdCard(); + } + if (doTestScratchApi) { + testScratchApi(); + } + // testJsonLibDirect(); + // testDummyParams(); + // testProtHandler(); + FsOpCodes opCode = FsOpCodes::APPEND_TO_FILE; + testFileSystemHandlerDirect(opCode); + return TestTask::performOneShotAction(); } ReturnValue_t Q7STestTask::performPeriodicAction() { - if(doTestGps) { - testGpsDaemon(); - } - return TestTask::performPeriodicAction(); + if (doTestGps) { + testGpsDaemon(); + } + return TestTask::performPeriodicAction(); } void Q7STestTask::testSdCard() { - using namespace std; - Stopwatch stopwatch; - int result = std::system("q7hw sd info all > /tmp/sd_status.txt"); - if(result != 0) { - sif::debug << "system call failed with " << result << endl; + using namespace std; + Stopwatch stopwatch; + int result = std::system("q7hw sd info all > /tmp/sd_status.txt"); + if (result != 0) { + sif::debug << "system call failed with " << result << endl; + } + ifstream sdStatus("/tmp/sd_status.txt"); + string line; + uint8_t idx = 0; + while (std::getline(sdStatus, line)) { + std::istringstream iss(line); + string word; + while (iss >> word) { + if (word == "on") { + sif::info << "SD card " << static_cast(idx) << " is on" << endl; + } else if (word == "off") { + sif::info << "SD card " << static_cast(idx) << " is off" << endl; + } } - ifstream sdStatus("/tmp/sd_status.txt"); - string line; - uint8_t idx = 0; - while (std::getline(sdStatus, line)) { - std::istringstream iss(line); - string word; - while(iss >> word) { - if(word == "on") { - sif::info << "SD card " << static_cast(idx) << " is on" << endl; - } - else if(word == "off") { - sif::info << "SD card " << static_cast(idx) << " is off" << endl; - } - } - idx++; - } - std::remove("/tmp/sd_status.txt"); + idx++; + } + std::remove("/tmp/sd_status.txt"); } void Q7STestTask::fileTests() { - using namespace std; - ofstream testFile("/tmp/test.txt"); - testFile << "Hallo Welt" << endl; - testFile.close(); + using namespace std; + ofstream testFile("/tmp/test.txt"); + testFile << "Hallo Welt" << endl; + testFile.close(); - system("echo \"Hallo Welt\" > /tmp/test2.txt"); - system("echo \"Hallo Welt\""); + system("echo \"Hallo Welt\" > /tmp/test2.txt"); + system("echo \"Hallo Welt\""); } void Q7STestTask::testScratchApi() { - ReturnValue_t result = scratch::writeNumber("TEST", 1); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "Q7STestTask::scratchApiTest: Writing number failed" << std::endl; - } - int number = 0; - result = scratch::readNumber("TEST", number); - sif::info << "Q7STestTask::testScratchApi: Value for key \"TEST\": " << number << std::endl; - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "Q7STestTask::scratchApiTest: Reading number failed" << std::endl; - } + ReturnValue_t result = scratch::writeNumber("TEST", 1); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "Q7STestTask::scratchApiTest: Writing number failed" << std::endl; + } + int number = 0; + result = scratch::readNumber("TEST", number); + sif::info << "Q7STestTask::testScratchApi: Value for key \"TEST\": " << number << std::endl; + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "Q7STestTask::scratchApiTest: Reading number failed" << std::endl; + } - result = scratch::writeString("TEST2", "halloWelt"); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "Q7STestTask::scratchApiTest: Writing string failed" << std::endl; - } - std::string string; - result = scratch::readString("TEST2", string); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "Q7STestTask::scratchApiTest: Reading number failed" << std::endl; - } - sif::info << "Q7STestTask::testScratchApi: Value for key \"TEST2\": " << string << std::endl; + result = scratch::writeString("TEST2", "halloWelt"); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "Q7STestTask::scratchApiTest: Writing string failed" << std::endl; + } + std::string string; + result = scratch::readString("TEST2", string); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "Q7STestTask::scratchApiTest: Reading number failed" << std::endl; + } + sif::info << "Q7STestTask::testScratchApi: Value for key \"TEST2\": " << string << std::endl; - result = scratch::clearValue("TEST"); - result = scratch::clearValue("TEST2"); + result = scratch::clearValue("TEST"); + result = scratch::clearValue("TEST2"); } void Q7STestTask::testJsonLibDirect() { - Stopwatch stopwatch; - // for convenience - using json = nlohmann::json; - json helloTest; - // add a number that is stored as double (note the implicit conversion of j to an object) - helloTest["pi"] = 3.141; - std::string mntPrefix = SdCardManager::instance()->getCurrentMountPrefix(); - std::string fileName = mntPrefix + "/pretty.json"; - std::ofstream o(fileName); - o << std::setw(4) << helloTest << std::endl; + Stopwatch stopwatch; + // for convenience + using json = nlohmann::json; + json helloTest; + // add a number that is stored as double (note the implicit conversion of j to an object) + helloTest["pi"] = 3.141; + std::string mntPrefix = SdCardManager::instance()->getCurrentMountPrefix(); + std::string fileName = mntPrefix + "/pretty.json"; + std::ofstream o(fileName); + o << std::setw(4) << helloTest << std::endl; } void Q7STestTask::testDummyParams() { - std::string mntPrefix = SdCardManager::instance()->getCurrentMountPrefix(); - DummyParameter param(mntPrefix, "dummy_json.txt"); - param.printKeys(); - param.print(); - if(not param.getJsonFileExists()) { - param.writeJsonFile(); - } - - ReturnValue_t result = param.readJsonFile(); - if(result != HasReturnvaluesIF::RETURN_OK) { - - } - - param.setValue(DummyParameter::DUMMY_KEY_PARAM_1, 3); - param.setValue(DummyParameter::DUMMY_KEY_PARAM_2, "blirb"); - + std::string mntPrefix = SdCardManager::instance()->getCurrentMountPrefix(); + DummyParameter param(mntPrefix, "dummy_json.txt"); + param.printKeys(); + param.print(); + if (not param.getJsonFileExists()) { param.writeJsonFile(); - param.print(); + } - int test = 0; - result = param.getValue(DummyParameter::DUMMY_KEY_PARAM_1, &test); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Q7STestTask::testDummyParams: Key " << DummyParameter::DUMMY_KEY_PARAM_1 - << " does not exist" << std::endl; - } - std::string test2; - result = param.getValue(DummyParameter::DUMMY_KEY_PARAM_2, &test2); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Q7STestTask::testDummyParams: Key " << DummyParameter::DUMMY_KEY_PARAM_1 - << " does not exist" << std::endl; - } - sif::info << "Test value (3 expected): " << test << std::endl; - sif::info << "Test value 2 (\"blirb\" expected): " << test2 << std::endl; + ReturnValue_t result = param.readJsonFile(); + if (result != HasReturnvaluesIF::RETURN_OK) { + } + + param.setValue(DummyParameter::DUMMY_KEY_PARAM_1, 3); + param.setValue(DummyParameter::DUMMY_KEY_PARAM_2, "blirb"); + + param.writeJsonFile(); + param.print(); + + int test = 0; + result = param.getValue(DummyParameter::DUMMY_KEY_PARAM_1, &test); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testDummyParams: Key " << DummyParameter::DUMMY_KEY_PARAM_1 + << " does not exist" << std::endl; + } + std::string test2; + result = param.getValue(DummyParameter::DUMMY_KEY_PARAM_2, &test2); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testDummyParams: Key " << DummyParameter::DUMMY_KEY_PARAM_1 + << " does not exist" << std::endl; + } + sif::info << "Test value (3 expected): " << test << std::endl; + sif::info << "Test value 2 (\"blirb\" expected): " << test2 << std::endl; } ReturnValue_t Q7STestTask::initialize() { - coreController = ObjectManager::instance()->get(objects::CORE_CONTROLLER); - if(coreController == nullptr) { - sif::warning << "Q7STestTask::initialize: Could not retrieve CORE_CONTROLLER object" << - std::endl; - } - return TestTask::initialize(); + coreController = ObjectManager::instance()->get(objects::CORE_CONTROLLER); + if (coreController == nullptr) { + sif::warning << "Q7STestTask::initialize: Could not retrieve CORE_CONTROLLER object" + << std::endl; + } + return TestTask::initialize(); } void Q7STestTask::testProtHandler() { - bool opPerformed = false; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - // If any chips are unlocked, lock them here - result = coreController->setBootCopyProtection( - CoreController::Chip::ALL_CHIP, CoreController::Copy::ALL_COPY, true, - opPerformed, true); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; - } + bool opPerformed = false; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + // If any chips are unlocked, lock them here + result = coreController->setBootCopyProtection( + CoreController::Chip::ALL_CHIP, CoreController::Copy::ALL_COPY, true, opPerformed, true); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; + } - // unlock own copy - result = coreController->setBootCopyProtection( - CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, false, - opPerformed, true); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; - } - if(not opPerformed) { - sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; - } - int retval = std::system("print-chip-prot-status.sh"); - if(retval != 0) { - utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); - } + // unlock own copy + result = coreController->setBootCopyProtection( + CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, false, opPerformed, true); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; + } + if (not opPerformed) { + sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; + } + int retval = std::system("print-chip-prot-status.sh"); + if (retval != 0) { + utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); + } - // lock own copy - result = coreController->setBootCopyProtection( - CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, true, - opPerformed, true); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; - } - if(not opPerformed) { - sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; - } - retval = std::system("print-chip-prot-status.sh"); - if(retval != 0) { - utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); - } + // lock own copy + result = coreController->setBootCopyProtection( + CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, true, opPerformed, true); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; + } + if (not opPerformed) { + sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; + } + retval = std::system("print-chip-prot-status.sh"); + if (retval != 0) { + utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); + } - // unlock specific copy - result = coreController->setBootCopyProtection( - CoreController::Chip::CHIP_1, CoreController::Copy::COPY_1, false, - opPerformed, true); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; - } - if(not opPerformed) { - sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; - } - retval = std::system("print-chip-prot-status.sh"); - if(retval != 0) { - utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); - } + // unlock specific copy + result = coreController->setBootCopyProtection( + CoreController::Chip::CHIP_1, CoreController::Copy::COPY_1, false, opPerformed, true); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; + } + if (not opPerformed) { + sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; + } + retval = std::system("print-chip-prot-status.sh"); + if (retval != 0) { + utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); + } - // lock specific copy - result = coreController->setBootCopyProtection( - CoreController::Chip::CHIP_1, CoreController::Copy::COPY_1, true, - opPerformed, true); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; - } - if(not opPerformed) { - sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; - } - retval = std::system("print-chip-prot-status.sh"); - if(retval != 0) { - utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); - } + // lock specific copy + result = coreController->setBootCopyProtection( + CoreController::Chip::CHIP_1, CoreController::Copy::COPY_1, true, opPerformed, true); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; + } + if (not opPerformed) { + sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; + } + retval = std::system("print-chip-prot-status.sh"); + if (retval != 0) { + utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); + } } void Q7STestTask::testGpsDaemon() { - gpsmm gpsmm(GPSD_SHARED_MEMORY, 0); - gps_data_t* gps; - gps = gpsmm.read(); - if(gps == nullptr) { - sif::warning << "Q7STestTask: Reading GPS data failed" << std::endl; - } - sif::info << "-- Q7STestTask: GPS shared memory read test --" << std::endl; - time_t timeRaw = gps->fix.time.tv_sec; - std::tm* time = gmtime(&timeRaw); - sif::info << "Time: " << std::put_time(time, "%c %Z") << std::endl; - sif::info << "Visible satellites: " << gps->satellites_visible << std::endl; - sif::info << "Satellites used: " << gps->satellites_used << std::endl; - sif::info << "Fix (0:Not Seen|1:No Fix|2:2D|3:3D): " << gps->fix.mode << std::endl; - sif::info << "Latitude: " << gps->fix.latitude << std::endl; - sif::info << "Longitude: " << gps->fix.longitude << std::endl; - sif::info << "Altitude(MSL): " << gps->fix.altMSL << std::endl; - sif::info << "Speed(m/s): " << gps->fix.speed << std::endl; + gpsmm gpsmm(GPSD_SHARED_MEMORY, 0); + gps_data_t* gps; + gps = gpsmm.read(); + if (gps == nullptr) { + sif::warning << "Q7STestTask: Reading GPS data failed" << std::endl; + } + sif::info << "-- Q7STestTask: GPS shared memory read test --" << std::endl; + time_t timeRaw = gps->fix.time.tv_sec; + std::tm* time = gmtime(&timeRaw); + sif::info << "Time: " << std::put_time(time, "%c %Z") << std::endl; + sif::info << "Visible satellites: " << gps->satellites_visible << std::endl; + sif::info << "Satellites used: " << gps->satellites_used << std::endl; + sif::info << "Fix (0:Not Seen|1:No Fix|2:2D|3:3D): " << gps->fix.mode << std::endl; + sif::info << "Latitude: " << gps->fix.latitude << std::endl; + sif::info << "Longitude: " << gps->fix.longitude << std::endl; + sif::info << "Altitude(MSL): " << gps->fix.altMSL << std::endl; + sif::info << "Speed(m/s): " << gps->fix.speed << std::endl; } void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) { - auto fsHandler = ObjectManager::instance()-> - get(objects::FILE_SYSTEM_HANDLER); - if(fsHandler == nullptr) { - sif::warning << "Q7STestTask::testFileSystemHandlerDirect: No FS handler running.." - << std::endl; - } - FileSystemHandler::FsCommandCfg cfg = {}; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + auto fsHandler = ObjectManager::instance()->get(objects::FILE_SYSTEM_HANDLER); + if (fsHandler == nullptr) { + sif::warning << "Q7STestTask::testFileSystemHandlerDirect: No FS handler running.." + << std::endl; + } + FileSystemHandler::FsCommandCfg cfg = {}; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - // Lambda for common code - auto createNonEmptyTmpDir = [&]() { - if(not std::filesystem::exists("/tmp/test")) { - result = fsHandler->createDirectory("/tmp", "test", false, &cfg); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - } - // Creating sample files - sif::info << "Creating sample files in directory" << std::endl; - result = fsHandler->createFile("/tmp/test", "test1.txt", nullptr, 0, &cfg); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - result = fsHandler->createFile("/tmp/test", "test2.txt", nullptr, 0, &cfg); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + // Lambda for common code + auto createNonEmptyTmpDir = [&]() { + if (not std::filesystem::exists("/tmp/test")) { + result = fsHandler->createDirectory("/tmp", "test", false, &cfg); + if (result != HasReturnvaluesIF::RETURN_OK) { return result; - }; + } + } + // Creating sample files + sif::info << "Creating sample files in directory" << std::endl; + result = fsHandler->createFile("/tmp/test", "test1.txt", nullptr, 0, &cfg); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = fsHandler->createFile("/tmp/test", "test2.txt", nullptr, 0, &cfg); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + return result; + }; - - switch(opCode) { - case(FsOpCodes::CREATE_EMPTY_FILE_IN_TMP): { - // No mount prefix, cause file is created in tmp - cfg.useMountPrefix = false; - sif::info << "Creating empty file in /tmp folder" << std::endl; - // Do not delete file, user can check existence in shell + switch (opCode) { + case (FsOpCodes::CREATE_EMPTY_FILE_IN_TMP): { + // No mount prefix, cause file is created in tmp + cfg.useMountPrefix = false; + sif::info << "Creating empty file in /tmp folder" << std::endl; + // Do not delete file, user can check existence in shell + fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg); + break; + } + case (FsOpCodes::REMOVE_TMP_FILE): { + sif::info << "Deleting /tmp/test.txt sample file" << std::endl; + // No mount prefix, cause file is created in tmp + cfg.useMountPrefix = false; + if (not std::filesystem::exists("/tmp/test.txt")) { + // Creating sample file + sif::info << "Creating sample file /tmp/test.txt to delete" << std::endl; fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg); - break; + } + result = fsHandler->removeFile("/tmp", "test.txt", &cfg); + if (result == HasReturnvaluesIF::RETURN_OK) { + sif::info << "File removed successfully" << std::endl; + } else { + sif::warning << "File removal failed!" << std::endl; + } + break; } - case(FsOpCodes::REMOVE_TMP_FILE): { - sif::info << "Deleting /tmp/test.txt sample file" << std::endl; - // No mount prefix, cause file is created in tmp - cfg.useMountPrefix = false; - if(not std::filesystem::exists("/tmp/test.txt")) { - // Creating sample file - sif::info << "Creating sample file /tmp/test.txt to delete" << std::endl; - fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg); - } - result = fsHandler->removeFile("/tmp", "test.txt", &cfg); - if(result == HasReturnvaluesIF::RETURN_OK) { - sif::info << "File removed successfully" << std::endl; - } - else { - sif::warning << "File removal failed!" << std::endl; - } - break; + case (FsOpCodes::CREATE_DIR_IN_TMP): { + // No mount prefix, cause file is created in tmp + cfg.useMountPrefix = false; + sif::info << "Creating empty file in /tmp folder" << std::endl; + // Do not delete file, user can check existence in shell + ReturnValue_t result = fsHandler->createDirectory("/tmp/", "test", false, &cfg); + if (result == HasReturnvaluesIF::RETURN_OK) { + sif::info << "Directory created successfully" << std::endl; + } else { + sif::warning << "Directory creation failed!" << std::endl; + } + break; } - case(FsOpCodes::CREATE_DIR_IN_TMP): { - // No mount prefix, cause file is created in tmp - cfg.useMountPrefix = false; - sif::info << "Creating empty file in /tmp folder" << std::endl; - // Do not delete file, user can check existence in shell - ReturnValue_t result = fsHandler->createDirectory("/tmp/", "test", false, &cfg); - if(result == HasReturnvaluesIF::RETURN_OK) { - sif::info << "Directory created successfully" << std::endl; - } - else { - sif::warning << "Directory creation failed!" << std::endl; - } - break; + case (FsOpCodes::REMOVE_EMPTY_DIR_IN_TMP): { + // No mount prefix, cause file is created in tmp + cfg.useMountPrefix = false; + if (not std::filesystem::exists("/tmp/test")) { + result = fsHandler->createDirectory("/tmp", "test", false, &cfg); + } else { + // Delete any leftover files to regular dir removal works + std::remove("/tmp/test/*"); + } + result = fsHandler->removeDirectory("/tmp/", "test", false, &cfg); + if (result == HasReturnvaluesIF::RETURN_OK) { + sif::info << "Directory removed successfully" << std::endl; + } else { + sif::warning << "Directory removal failed!" << std::endl; + } + break; } - case(FsOpCodes::REMOVE_EMPTY_DIR_IN_TMP): { - // No mount prefix, cause file is created in tmp - cfg.useMountPrefix = false; - if(not std::filesystem::exists("/tmp/test")) { - result = fsHandler->createDirectory("/tmp", "test", false, &cfg); - } - else { - // Delete any leftover files to regular dir removal works - std::remove("/tmp/test/*"); - } - result = fsHandler->removeDirectory("/tmp/", "test", false, &cfg); - if(result == HasReturnvaluesIF::RETURN_OK) { - sif::info << "Directory removed successfully" << std::endl; - } - else { - sif::warning << "Directory removal failed!" << std::endl; - } - break; + case (FsOpCodes::REMOVE_FILLED_DIR_IN_TMP): { + result = createNonEmptyTmpDir(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return; + } + result = fsHandler->removeDirectory("/tmp/", "test", true, &cfg); + if (result == HasReturnvaluesIF::RETURN_OK) { + sif::info << "Directory removed recursively successfully" << std::endl; + } else { + sif::warning << "Recursive directory removal failed!" << std::endl; + } + break; } - case(FsOpCodes::REMOVE_FILLED_DIR_IN_TMP): { - result = createNonEmptyTmpDir(); - if(result != HasReturnvaluesIF::RETURN_OK) { - return; - } - result = fsHandler->removeDirectory("/tmp/", "test", true, &cfg); - if(result == HasReturnvaluesIF::RETURN_OK) { - sif::info << "Directory removed recursively successfully" << std::endl; - } - else { - sif::warning << "Recursive directory removal failed!" << std::endl; - } - break; + case (FsOpCodes::ATTEMPT_DIR_REMOVAL_NON_EMPTY): { + result = createNonEmptyTmpDir(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return; + } + result = fsHandler->removeDirectory("/tmp/", "test", false, &cfg); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::info << "Directory removal attempt failed as expected" << std::endl; + } else { + sif::warning << "Directory removal worked when it should not have!" << std::endl; + } + break; } - case(FsOpCodes::ATTEMPT_DIR_REMOVAL_NON_EMPTY): { - result = createNonEmptyTmpDir(); - if(result != HasReturnvaluesIF::RETURN_OK) { - return; - } - result = fsHandler->removeDirectory("/tmp/", "test", false, &cfg); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::info << "Directory removal attempt failed as expected" << std::endl; - } - else { - sif::warning << "Directory removal worked when it should not have!" << std::endl; - } - break; - } - case(FsOpCodes::RENAME_FILE): { - // No mount prefix, cause file is created in tmp - cfg.useMountPrefix = false; - if(std::filesystem::exists("/tmp/test.txt")) { - fsHandler->removeDirectory("/tmp/", "test", false, &cfg); - } - sif::info << "Creating empty file /tmp/test.txt and rename to /tmp/test2.txt" << std::endl; - // Do not delete file, user can check existence in shell - fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg); - fsHandler->renameFile("/tmp/", "test.txt", "test2.txt", &cfg); - break; - } - case(FsOpCodes::APPEND_TO_FILE): { - // No mount prefix, cause file is created in tmp - cfg.useMountPrefix = false; - if(std::filesystem::exists("/tmp/test.txt")) { - fsHandler->removeDirectory("/tmp/", "test", false, &cfg); - } - if(std::filesystem::exists("/tmp/test.txt")) { - fsHandler->removeDirectory("/tmp/", "test", false, &cfg); - } - sif::info << "Creating empty file /tmp/test.txt and adding content" << std::endl; - std::string content = "Hello World\n"; - // Do not delete file, user can check existence in shell - fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg); - fsHandler->appendToFile("/tmp/", "test.txt", reinterpret_cast( - content.data()), content.size(), 0, &cfg); + case (FsOpCodes::RENAME_FILE): { + // No mount prefix, cause file is created in tmp + cfg.useMountPrefix = false; + if (std::filesystem::exists("/tmp/test.txt")) { + fsHandler->removeDirectory("/tmp/", "test", false, &cfg); + } + sif::info << "Creating empty file /tmp/test.txt and rename to /tmp/test2.txt" << std::endl; + // Do not delete file, user can check existence in shell + fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg); + fsHandler->renameFile("/tmp/", "test.txt", "test2.txt", &cfg); + break; } + case (FsOpCodes::APPEND_TO_FILE): { + // No mount prefix, cause file is created in tmp + cfg.useMountPrefix = false; + if (std::filesystem::exists("/tmp/test.txt")) { + fsHandler->removeDirectory("/tmp/", "test", false, &cfg); + } + if (std::filesystem::exists("/tmp/test.txt")) { + fsHandler->removeDirectory("/tmp/", "test", false, &cfg); + } + sif::info << "Creating empty file /tmp/test.txt and adding content" << std::endl; + std::string content = "Hello World\n"; + // Do not delete file, user can check existence in shell + fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg); + fsHandler->appendToFile("/tmp/", "test.txt", reinterpret_cast(content.data()), + content.size(), 0, &cfg); } + } } diff --git a/bsp_q7s/boardtest/Q7STestTask.h b/bsp_q7s/boardtest/Q7STestTask.h index 631c238a..b7aa791e 100644 --- a/bsp_q7s/boardtest/Q7STestTask.h +++ b/bsp_q7s/boardtest/Q7STestTask.h @@ -5,42 +5,42 @@ class CoreController; -class Q7STestTask: public TestTask { -public: - Q7STestTask(object_id_t objectId); +class Q7STestTask : public TestTask { + public: + Q7STestTask(object_id_t objectId); - ReturnValue_t initialize() override; -private: - bool doTestSdCard = false; - bool doTestScratchApi = false; - bool doTestGps = false; + ReturnValue_t initialize() override; - CoreController* coreController = nullptr; - ReturnValue_t performOneShotAction() override; - ReturnValue_t performPeriodicAction() override; + private: + bool doTestSdCard = false; + bool doTestScratchApi = false; + bool doTestGps = false; - void testGpsDaemon(); + CoreController* coreController = nullptr; + ReturnValue_t performOneShotAction() override; + ReturnValue_t performPeriodicAction() override; - void testSdCard(); - void fileTests(); + void testGpsDaemon(); - void testScratchApi(); - void testJsonLibDirect(); - void testDummyParams(); - void testProtHandler(); + void testSdCard(); + void fileTests(); - enum FsOpCodes { - CREATE_EMPTY_FILE_IN_TMP, - REMOVE_TMP_FILE, - CREATE_DIR_IN_TMP, - REMOVE_EMPTY_DIR_IN_TMP, - ATTEMPT_DIR_REMOVAL_NON_EMPTY, - REMOVE_FILLED_DIR_IN_TMP, - RENAME_FILE, - APPEND_TO_FILE, - }; - void testFileSystemHandlerDirect(FsOpCodes opCode); + void testScratchApi(); + void testJsonLibDirect(); + void testDummyParams(); + void testProtHandler(); + + enum FsOpCodes { + CREATE_EMPTY_FILE_IN_TMP, + REMOVE_TMP_FILE, + CREATE_DIR_IN_TMP, + REMOVE_EMPTY_DIR_IN_TMP, + ATTEMPT_DIR_REMOVAL_NON_EMPTY, + REMOVE_FILLED_DIR_IN_TMP, + RENAME_FILE, + APPEND_TO_FILE, + }; + void testFileSystemHandlerDirect(FsOpCodes opCode); }; - #endif /* BSP_Q7S_BOARDTEST_Q7STESTTASK_H_ */ diff --git a/bsp_q7s/callbacks/gnssCallback.cpp b/bsp_q7s/callbacks/gnssCallback.cpp index 479f4a2b..d5dbc3b0 100644 --- a/bsp_q7s/callbacks/gnssCallback.cpp +++ b/bsp_q7s/callbacks/gnssCallback.cpp @@ -1,26 +1,25 @@ #include "gnssCallback.h" -#include "devices/gpioIds.h" +#include "devices/gpioIds.h" #include "fsfw/tasks/TaskFactory.h" -ReturnValue_t gps::triggerGpioResetPin(void *args) { - ResetArgs* resetArgs = reinterpret_cast(args); - if(args == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; - } - if (resetArgs->gpioComIF == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; - } - gpioId_t gpioId; - if(resetArgs->gnss1) { - gpioId = gpioIds::GNSS_1_NRESET; +ReturnValue_t gps::triggerGpioResetPin(void* args) { + ResetArgs* resetArgs = reinterpret_cast(args); + if (args == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } + if (resetArgs->gpioComIF == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } + gpioId_t gpioId; + if (resetArgs->gnss1) { + gpioId = gpioIds::GNSS_1_NRESET; - } - else { - gpioId = gpioIds::GNSS_0_NRESET; - } - resetArgs->gpioComIF->pullLow(gpioId); - TaskFactory::delayTask(resetArgs->waitPeriodMs); - resetArgs->gpioComIF->pullHigh(gpioId); - return HasReturnvaluesIF::RETURN_OK; + } else { + gpioId = gpioIds::GNSS_0_NRESET; + } + resetArgs->gpioComIF->pullLow(gpioId); + TaskFactory::delayTask(resetArgs->waitPeriodMs); + resetArgs->gpioComIF->pullHigh(gpioId); + return HasReturnvaluesIF::RETURN_OK; } diff --git a/bsp_q7s/callbacks/gnssCallback.h b/bsp_q7s/callbacks/gnssCallback.h index 9cbb6669..3e769899 100644 --- a/bsp_q7s/callbacks/gnssCallback.h +++ b/bsp_q7s/callbacks/gnssCallback.h @@ -1,13 +1,13 @@ #ifndef BSP_Q7S_CALLBACKS_GNSSCALLBACK_H_ #define BSP_Q7S_CALLBACKS_GNSSCALLBACK_H_ -#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" struct ResetArgs { - bool gnss1 = false; - LinuxLibgpioIF* gpioComIF = nullptr; - uint32_t waitPeriodMs = 100; + bool gnss1 = false; + LinuxLibgpioIF* gpioComIF = nullptr; + uint32_t waitPeriodMs = 100; }; namespace gps { diff --git a/bsp_q7s/callbacks/rwSpiCallback.cpp b/bsp_q7s/callbacks/rwSpiCallback.cpp index 1e60e3c0..3ca3c181 100644 --- a/bsp_q7s/callbacks/rwSpiCallback.cpp +++ b/bsp_q7s/callbacks/rwSpiCallback.cpp @@ -1,238 +1,232 @@ #include "rwSpiCallback.h" -#include "devices/gpioIds.h" -#include "mission/devices/RwHandler.h" -#include "fsfw_hal/linux/spi/SpiCookie.h" -#include "fsfw_hal/linux/UnixFileGuard.h" +#include "devices/gpioIds.h" #include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw_hal/linux/UnixFileGuard.h" +#include "fsfw_hal/linux/spi/SpiCookie.h" +#include "mission/devices/RwHandler.h" namespace rwSpiCallback { -ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sendData, - size_t sendLen, void* args) { +ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sendData, + size_t sendLen, void* args) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + RwHandler* handler = reinterpret_cast(args); + if (handler == nullptr) { + sif::error << "rwSpiCallback::spiCallback: Pointer to handler is invalid" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } - RwHandler* handler = reinterpret_cast(args); - if(handler == nullptr) { - sif::error << "rwSpiCallback::spiCallback: Pointer to handler is invalid" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; + uint8_t writeBuffer[2]; + uint8_t writeSize = 0; + + gpioId_t gpioId = cookie->getChipSelectPin(); + GpioIF* gpioIF = comIf->getGpioInterface(); + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; + uint32_t timeoutMs = 0; + MutexIF* mutex = comIf->getMutex(&timeoutType, &timeoutMs); + if (mutex == nullptr or gpioIF == nullptr) { + sif::debug << "rwSpiCallback::spiCallback: Mutex or GPIO interface invalid" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + + int fileDescriptor = 0; + std::string device = cookie->getSpiDevice(); + UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "rwSpiCallback::spiCallback"); + if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "rwSpiCallback::spiCallback: Failed to open device file" << std::endl; + return SpiComIF::OPENING_FILE_FAILED; + } + spi::SpiModes spiMode = spi::SpiModes::MODE_0; + uint32_t spiSpeed = 0; + cookie->getSpiParameters(spiMode, spiSpeed, nullptr); + comIf->setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); + + result = mutex->lockMutex(timeoutType, timeoutMs); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "rwSpiCallback::spiCallback: Failed to lock mutex" << std::endl; + return result; + } + + /** Sending frame start sign */ + writeBuffer[0] = 0x7E; + writeSize = 1; + + // Pull SPI CS low. For now, no support for active high given + if (gpioId != gpio::NO_GPIO) { + if (gpioIF->pullLow(gpioId) != HasReturnvaluesIF::RETURN_OK) { + sif::error << "rwSpiCallback::spiCallback: Failed to pull chip select low" << std::endl; } + } - uint8_t writeBuffer[2]; - uint8_t writeSize = 0; + if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { + sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; + closeSpi(gpioId, gpioIF, mutex); + return RwHandler::SPI_WRITE_FAILURE; + } - gpioId_t gpioId = cookie->getChipSelectPin(); - GpioIF* gpioIF = comIf->getGpioInterface(); - MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; - uint32_t timeoutMs = 0; - MutexIF* mutex = comIf->getMutex(&timeoutType, &timeoutMs); - if(mutex == nullptr or gpioIF == nullptr) { - sif::debug << "rwSpiCallback::spiCallback: Mutex or GPIO interface invalid" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - - int fileDescriptor = 0; - std::string device = cookie->getSpiDevice(); - UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "rwSpiCallback::spiCallback"); - if(fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "rwSpiCallback::spiCallback: Failed to open device file" << std::endl; - return SpiComIF::OPENING_FILE_FAILED; + /** Encoding and sending command */ + size_t idx = 0; + while (idx < sendLen) { + switch (*(sendData + idx)) { + case 0x7E: + writeBuffer[0] = 0x7D; + writeBuffer[1] = 0x5E; + writeSize = 2; + break; + case 0x7D: + writeBuffer[0] = 0x7D; + writeBuffer[1] = 0x5D; + writeSize = 2; + break; + default: + writeBuffer[0] = *(sendData + idx); + writeSize = 1; + break; } - spi::SpiModes spiMode = spi::SpiModes::MODE_0; - uint32_t spiSpeed = 0; - cookie->getSpiParameters(spiMode, spiSpeed, nullptr); - comIf->setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); - - result = mutex->lockMutex(timeoutType, timeoutMs); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "rwSpiCallback::spiCallback: Failed to lock mutex" << std::endl; - return result; - } - - /** Sending frame start sign */ - writeBuffer[0] = 0x7E; - writeSize = 1; - - // Pull SPI CS low. For now, no support for active high given - if(gpioId != gpio::NO_GPIO) { - if(gpioIF->pullLow(gpioId) != HasReturnvaluesIF::RETURN_OK) { - sif::error << "rwSpiCallback::spiCallback: Failed to pull chip select low" << std::endl; - } - } - if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { - sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; + sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; + closeSpi(gpioId, gpioIF, mutex); + return RwHandler::SPI_WRITE_FAILURE; + } + idx++; + } + + /** Sending frame end sign */ + writeBuffer[0] = 0x7E; + writeSize = 1; + + if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { + sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; + closeSpi(gpioId, gpioIF, mutex); + return RwHandler::SPI_WRITE_FAILURE; + } + + uint8_t* rxBuf = nullptr; + result = comIf->getReadBuffer(cookie->getSpiAddress(), &rxBuf); + if (result != HasReturnvaluesIF::RETURN_OK) { + closeSpi(gpioId, gpioIF, mutex); + return result; + } + + size_t replyBufferSize = cookie->getMaxBufferSize(); + + /** There must be a delay of at least 20 ms after sending the command */ + usleep(RwDefinitions::SPI_REPLY_DELAY); + + /** + * The reaction wheel responds with empty frames while preparing the reply data. + * However, receiving more than 5 empty frames will be interpreted as an error. + */ + uint8_t byteRead = 0; + for (int idx = 0; idx < 10; idx++) { + if (read(fileDescriptor, &byteRead, 1) != 1) { + sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; + closeSpi(gpioId, gpioIF, mutex); + return RwHandler::SPI_READ_FAILURE; + } + if (idx == 0) { + if (byteRead != FLAG_BYTE) { + sif::error << "Invalid data, expected start marker" << std::endl; closeSpi(gpioId, gpioIF, mutex); - return RwHandler::SPI_WRITE_FAILURE; + return RwHandler::NO_START_MARKER; + } } - /** Encoding and sending command */ - size_t idx = 0; - while(idx < sendLen) { - switch(*(sendData + idx)) { - case 0x7E: - writeBuffer[0] = 0x7D; - writeBuffer[1] = 0x5E; - writeSize = 2; - break; - case 0x7D: - writeBuffer[0] = 0x7D; - writeBuffer[1] = 0x5D; - writeSize = 2; - break; - default: - writeBuffer[0] = *(sendData + idx); - writeSize = 1; - break; - } - if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { - sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; - closeSpi(gpioId, gpioIF, mutex); - return RwHandler::SPI_WRITE_FAILURE; - } - idx++; + if (byteRead != FLAG_BYTE) { + break; } - /** Sending frame end sign */ - writeBuffer[0] = 0x7E; - writeSize = 1; - - if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { - sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; - closeSpi(gpioId, gpioIF, mutex); - return RwHandler::SPI_WRITE_FAILURE; - } - - uint8_t* rxBuf = nullptr; - result = comIf->getReadBuffer(cookie->getSpiAddress(), &rxBuf); - if(result != HasReturnvaluesIF::RETURN_OK) { - closeSpi(gpioId, gpioIF, mutex); - return result; - } - - size_t replyBufferSize = cookie->getMaxBufferSize(); - - /** There must be a delay of at least 20 ms after sending the command */ - usleep(RwDefinitions::SPI_REPLY_DELAY); - - /** - * The reaction wheel responds with empty frames while preparing the reply data. - * However, receiving more than 5 empty frames will be interpreted as an error. - */ - uint8_t byteRead = 0; - for (int idx = 0; idx < 10; idx++) { - if(read(fileDescriptor, &byteRead, 1) != 1) { - sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; - closeSpi(gpioId, gpioIF, mutex); - return RwHandler::SPI_READ_FAILURE; - } - if(idx == 0) { - if(byteRead != FLAG_BYTE) { - sif::error << "Invalid data, expected start marker" << std::endl; - closeSpi(gpioId, gpioIF, mutex); - return RwHandler::NO_START_MARKER; - } - } - - if (byteRead != FLAG_BYTE) { - break; - } - - if (idx == 9) { - sif::error << "rwSpiCallback::spiCallback: Empty frame timeout" << std::endl; - closeSpi(gpioId, gpioIF, mutex); - return RwHandler::NO_REPLY; - } + if (idx == 9) { + sif::error << "rwSpiCallback::spiCallback: Empty frame timeout" << std::endl; + closeSpi(gpioId, gpioIF, mutex); + return RwHandler::NO_REPLY; } + } #if FSFW_HAL_SPI_WIRETAPPING == 1 - sif::info << "RW start marker detected" << std::endl; + sif::info << "RW start marker detected" << std::endl; #endif - size_t decodedFrameLen = 0; - while(decodedFrameLen < replyBufferSize) { - - /** First byte already read in */ - if (decodedFrameLen != 0) { - byteRead = 0; - if(read(fileDescriptor, &byteRead, 1) != 1) { - sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; - result = RwHandler::SPI_READ_FAILURE; - break; - } - } - - if (byteRead == FLAG_BYTE) { - /** Reached end of frame */ - break; - } - else if (byteRead == 0x7D) { - if(read(fileDescriptor, &byteRead, 1) != 1) { - sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; - result = RwHandler::SPI_READ_FAILURE; - break; - } - if (byteRead == 0x5E) { - *(rxBuf + decodedFrameLen) = 0x7E; - decodedFrameLen++; - continue; - } - else if (byteRead == 0x5D) { - *(rxBuf + decodedFrameLen) = 0x7D; - decodedFrameLen++; - continue; - } - else { - sif::error << "rwSpiCallback::spiCallback: Invalid substitute" << std::endl; - closeSpi(gpioId, gpioIF, mutex); - result = RwHandler::INVALID_SUBSTITUTE; - break; - } - } - else { - *(rxBuf + decodedFrameLen) = byteRead; - decodedFrameLen++; - continue; - } - - /** - * There might be the unlikely case that each byte in a get-telemetry reply has been - * replaced by its substitute. Than the next byte must correspond to the end sign 0x7E. - * Otherwise there might be something wrong. - */ - if (decodedFrameLen == replyBufferSize) { - if(read(fileDescriptor, &byteRead, 1) != 1) { - sif::error << "rwSpiCallback::spiCallback: Failed to read last byte" << std::endl; - result = RwHandler::SPI_READ_FAILURE; - break; - } - if (byteRead != 0x7E) { - sif::error << "rwSpiCallback::spiCallback: Missing end sign 0x7E" << std::endl; - decodedFrameLen--; - result = RwHandler::MISSING_END_SIGN; - break; - } - } - result = HasReturnvaluesIF::RETURN_OK; + size_t decodedFrameLen = 0; + while (decodedFrameLen < replyBufferSize) { + /** First byte already read in */ + if (decodedFrameLen != 0) { + byteRead = 0; + if (read(fileDescriptor, &byteRead, 1) != 1) { + sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; + result = RwHandler::SPI_READ_FAILURE; + break; + } } - cookie->setTransferSize(decodedFrameLen); - - closeSpi(gpioId, gpioIF, mutex); - - return result; -} - -void closeSpi (gpioId_t gpioId, GpioIF* gpioIF, MutexIF* mutex) { - if(gpioId != gpio::NO_GPIO) { - if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) { - sif::error << "closeSpi: Failed to pull chip select high" << std::endl; - } + if (byteRead == FLAG_BYTE) { + /** Reached end of frame */ + break; + } else if (byteRead == 0x7D) { + if (read(fileDescriptor, &byteRead, 1) != 1) { + sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; + result = RwHandler::SPI_READ_FAILURE; + break; + } + if (byteRead == 0x5E) { + *(rxBuf + decodedFrameLen) = 0x7E; + decodedFrameLen++; + continue; + } else if (byteRead == 0x5D) { + *(rxBuf + decodedFrameLen) = 0x7D; + decodedFrameLen++; + continue; + } else { + sif::error << "rwSpiCallback::spiCallback: Invalid substitute" << std::endl; + closeSpi(gpioId, gpioIF, mutex); + result = RwHandler::INVALID_SUBSTITUTE; + break; + } + } else { + *(rxBuf + decodedFrameLen) = byteRead; + decodedFrameLen++; + continue; } - if(mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "rwSpiCallback::closeSpi: Failed to unlock mutex" << std::endl;; + + /** + * There might be the unlikely case that each byte in a get-telemetry reply has been + * replaced by its substitute. Than the next byte must correspond to the end sign 0x7E. + * Otherwise there might be something wrong. + */ + if (decodedFrameLen == replyBufferSize) { + if (read(fileDescriptor, &byteRead, 1) != 1) { + sif::error << "rwSpiCallback::spiCallback: Failed to read last byte" << std::endl; + result = RwHandler::SPI_READ_FAILURE; + break; + } + if (byteRead != 0x7E) { + sif::error << "rwSpiCallback::spiCallback: Missing end sign 0x7E" << std::endl; + decodedFrameLen--; + result = RwHandler::MISSING_END_SIGN; + break; + } } + result = HasReturnvaluesIF::RETURN_OK; + } + + cookie->setTransferSize(decodedFrameLen); + + closeSpi(gpioId, gpioIF, mutex); + + return result; } + +void closeSpi(gpioId_t gpioId, GpioIF* gpioIF, MutexIF* mutex) { + if (gpioId != gpio::NO_GPIO) { + if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) { + sif::error << "closeSpi: Failed to pull chip select high" << std::endl; + } + } + if (mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "rwSpiCallback::closeSpi: Failed to unlock mutex" << std::endl; + ; + } } +} // namespace rwSpiCallback diff --git a/bsp_q7s/callbacks/rwSpiCallback.h b/bsp_q7s/callbacks/rwSpiCallback.h index 8952f873..843d5b80 100644 --- a/bsp_q7s/callbacks/rwSpiCallback.h +++ b/bsp_q7s/callbacks/rwSpiCallback.h @@ -2,9 +2,8 @@ #define BSP_Q7S_RW_SPI_CALLBACK_H_ #include "fsfw/returnvalues/HasReturnvaluesIF.h" -#include "fsfw_hal/linux/spi/SpiComIF.h" #include "fsfw_hal/common/gpio/GpioCookie.h" - +#include "fsfw_hal/linux/spi/SpiComIF.h" namespace rwSpiCallback { @@ -31,8 +30,8 @@ static constexpr uint8_t FLAG_BYTE = 0x7E; * To switch between the to SPI peripherals, an EMIO is used which will also be controlled * by this function. */ -ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sendData, - size_t sendLen, void* args); +ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sendData, + size_t sendLen, void* args); /** * @brief This function closes a spi session. Pulls the chip select to high an releases the @@ -43,5 +42,5 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sen */ void closeSpi(gpioId_t gpioId, GpioIF* gpioIF, MutexIF* mutex); -} +} // namespace rwSpiCallback #endif /* BSP_Q7S_RW_SPI_CALLBACK_H_ */ diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 271ec508..bdbd51cc 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -1,1171 +1,1103 @@ #include "CoreController.h" + #include "OBSWConfig.h" #include "OBSWVersion.h" -#include "watchdogConf.h" - #include "fsfw/FSFWVersion.h" -#include "fsfw/timemanager/Stopwatch.h" #include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/timemanager/Stopwatch.h" +#include "watchdogConf.h" #if OBSW_USE_TMTC_TCP_BRIDGE == 0 #include "fsfw/osal/common/UdpTmTcBridge.h" #else #include "fsfw/osal/common/TcpTmTcServer.h" #endif -#include "bsp_q7s/memory/scratchApi.h" -#include "bsp_q7s/memory/SdCardManager.h" - #include #include #include +#include "bsp_q7s/memory/SdCardManager.h" +#include "bsp_q7s/memory/scratchApi.h" + CoreController::Chip CoreController::CURRENT_CHIP = Chip::NO_CHIP; CoreController::Copy CoreController::CURRENT_COPY = Copy::NO_COPY; -CoreController::CoreController(object_id_t objectId): - ExtendedControllerBase(objectId, objects::NO_OBJECT, 5), opDivider(5) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - try { - result = initWatchdogFifo(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::CoreController: Watchdog FIFO init failed" << - std::endl; - } - sdcMan = SdCardManager::instance(); - if(sdcMan == nullptr) { - sif::error << "CoreController::CoreController: SD card manager invalid!" << std::endl; - } - - if(not BLOCKING_SD_INIT) { - sdcMan->setBlocking(false); - } - sdStateMachine(); - - result = initBootCopy(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::CoreController: Boot copy init" << std::endl; - } +CoreController::CoreController(object_id_t objectId) + : ExtendedControllerBase(objectId, objects::NO_OBJECT, 5), opDivider(5) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + try { + result = initWatchdogFifo(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::CoreController: Watchdog FIFO init failed" << std::endl; } - catch(const std::filesystem::filesystem_error& e) { - sif::error << "CoreController::CoreController: Failed with exception " << - e.what() << std::endl; + sdcMan = SdCardManager::instance(); + if (sdcMan == nullptr) { + sif::error << "CoreController::CoreController: SD card manager invalid!" << std::endl; } + + if (not BLOCKING_SD_INIT) { + sdcMan->setBlocking(false); + } + sdStateMachine(); + + result = initBootCopy(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::CoreController: Boot copy init" << std::endl; + } + } catch (const std::filesystem::filesystem_error &e) { + sif::error << "CoreController::CoreController: Failed with exception " << e.what() << std::endl; + } } ReturnValue_t CoreController::handleCommandMessage(CommandMessage *message) { - return ExtendedControllerBase::handleCommandMessage(message); + return ExtendedControllerBase::handleCommandMessage(message); } void CoreController::performControlOperation() { - performWatchdogControlOperation(); - sdStateMachine(); + performWatchdogControlOperation(); + sdStateMachine(); } ReturnValue_t CoreController::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) { - return HasReturnvaluesIF::RETURN_OK; + LocalDataPoolManager &poolManager) { + return HasReturnvaluesIF::RETURN_OK; } -LocalPoolDataSetBase* CoreController::getDataSetHandle(sid_t sid) { - return nullptr; -} +LocalPoolDataSetBase *CoreController::getDataSetHandle(sid_t sid) { return nullptr; } ReturnValue_t CoreController::initialize() { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - result = scratch::writeNumber(scratch::ALLOC_FAILURE_COUNT, 0); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::initialize: Setting up alloc failure " - "count failed" << std::endl; - } + result = scratch::writeNumber(scratch::ALLOC_FAILURE_COUNT, 0); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::initialize: Setting up alloc failure " + "count failed" + << std::endl; + } - sdStateMachine(); - return ExtendedControllerBase::initialize(); + sdStateMachine(); + return ExtendedControllerBase::initialize(); } ReturnValue_t CoreController::initializeAfterTaskCreation() { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - if(BLOCKING_SD_INIT) { - ReturnValue_t result = initSdCardBlocking(); - if(result != HasReturnvaluesIF::RETURN_OK and result != SdCardManager::ALREADY_MOUNTED) { - sif::warning << "CoreController::CoreController: SD card init failed" << std::endl; - } + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + if (BLOCKING_SD_INIT) { + ReturnValue_t result = initSdCardBlocking(); + if (result != HasReturnvaluesIF::RETURN_OK and result != SdCardManager::ALREADY_MOUNTED) { + sif::warning << "CoreController::CoreController: SD card init failed" << std::endl; } - sdStateMachine(); - result = initVersionFile(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::initialize: Version initialization failed" << std::endl; - } - // Add script folder to path - char* currentEnvPath = getenv("PATH"); - std::string updatedEnvPath = std::string(currentEnvPath) + ":/home/root/scripts"; - setenv("PATH", updatedEnvPath.c_str(), true); - updateProtInfo(); - initPrint(); - return result; + } + sdStateMachine(); + result = initVersionFile(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::initialize: Version initialization failed" << std::endl; + } + // Add script folder to path + char *currentEnvPath = getenv("PATH"); + std::string updatedEnvPath = std::string(currentEnvPath) + ":/home/root/scripts"; + setenv("PATH", updatedEnvPath.c_str(), true); + updateProtInfo(); + initPrint(); + return result; } ReturnValue_t CoreController::checkModeCommand(Mode_t mode, Submode_t submode, - uint32_t *msToReachTheMode) { - return HasReturnvaluesIF::RETURN_OK; + uint32_t *msToReachTheMode) { + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t CoreController::initSdCardBlocking() { - // Create update status file - ReturnValue_t result = sdcMan->updateSdCardStateFile(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::initialize: Updating SD card state file failed" - << std::endl; - } + // Create update status file + ReturnValue_t result = sdcMan->updateSdCardStateFile(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::initialize: Updating SD card state file failed" << std::endl; + } #if Q7S_SD_CARD_CONFIG == Q7S_SD_NONE - sif::info << "No SD card initialization will be performed" << std::endl; - return HasReturnvaluesIF::RETURN_OK; + sif::info << "No SD card initialization will be performed" << std::endl; + return HasReturnvaluesIF::RETURN_OK; #else - result = sdcMan->getSdCardActiveStatus(sdInfo.currentState); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Getting SD card activity status failed" << std::endl; - } + result = sdcMan->getSdCardActiveStatus(sdInfo.currentState); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Getting SD card activity status failed" << std::endl; + } #if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT - determinePreferredSdCard(); - updateSdInfoOther(); - sif::info << "Cold redundant SD card configuration, preferred SD card: " << - static_cast(sdInfo.pref) << std::endl; - result = sdColdRedundantBlockingInit(); - // Update status file - sdcMan->updateSdCardStateFile(); - return result; + determinePreferredSdCard(); + updateSdInfoOther(); + sif::info << "Cold redundant SD card configuration, preferred SD card: " + << static_cast(sdInfo.pref) << std::endl; + result = sdColdRedundantBlockingInit(); + // Update status file + sdcMan->updateSdCardStateFile(); + return result; #elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT - sif::info << "Hot redundant SD card configuration" << std::endl; - sdCardSetup(sd::SdCard::SLOT_0, sd::SdState::MOUNTED, "0", false); - sdCardSetup(sd::SdCard::SLOT_1, sd::SdState::MOUNTED, "1", false); - // Update status file - sdcMan->updateSdCardStateFile(); - return HasReturnvaluesIF::RETURN_OK; + sif::info << "Hot redundant SD card configuration" << std::endl; + sdCardSetup(sd::SdCard::SLOT_0, sd::SdState::MOUNTED, "0", false); + sdCardSetup(sd::SdCard::SLOT_1, sd::SdState::MOUNTED, "1", false); + // Update status file + sdcMan->updateSdCardStateFile(); + return HasReturnvaluesIF::RETURN_OK; #endif #endif /* Q7S_SD_CARD_CONFIG != Q7S_SD_NONE */ - } ReturnValue_t CoreController::sdStateMachine() { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - SdCardManager::Operations operation; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + SdCardManager::Operations operation; - if(sdInfo.state == SdStates::IDLE) { - // Nothing to do - return result; - } + if (sdInfo.state == SdStates::IDLE) { + // Nothing to do + return result; + } - if(sdInfo.state == SdStates::START) { - // Init will be performed by separate function - if(BLOCKING_SD_INIT) { - sdInfo.state = SdStates::IDLE; - sdInfo.initFinished = true; - return result; - } - else { - // Still update SD state file + if (sdInfo.state == SdStates::START) { + // Init will be performed by separate function + if (BLOCKING_SD_INIT) { + sdInfo.state = SdStates::IDLE; + sdInfo.initFinished = true; + return result; + } else { + // Still update SD state file #if Q7S_SD_CARD_CONFIG == Q7S_SD_NONE - sdInfo.state = SdStates::UPDATE_INFO; + sdInfo.state = SdStates::UPDATE_INFO; #else - sdInfo.cycleCount = 0; - sdInfo.commandExecuted = false; - sdInfo.state = SdStates::GET_INFO; + sdInfo.cycleCount = 0; + sdInfo.commandExecuted = false; + sdInfo.state = SdStates::GET_INFO; #endif - } } + } - // This lambda checks the non-blocking operation and assigns the new state on success. - // It returns true for an operation success and false otherwise - auto nonBlockingOpChecking = [&](SdStates newStateOnSuccess, - uint16_t maxCycleCount, std::string opPrintout) { - SdCardManager::OpStatus status = sdcMan->checkCurrentOp(operation); - if(status == SdCardManager::OpStatus::SUCCESS) { - sdInfo.state = newStateOnSuccess; - sdInfo.commandExecuted = false; - sdInfo.cycleCount = 0; - return true; - } - else if(sdInfo.cycleCount > 4) { - sif::warning << "CoreController::sdInitStateMachine: " << opPrintout << - " takes too long" << std::endl; - return false; - } - return false; - }; - - if(sdInfo.state == SdStates::GET_INFO) { - if(not sdInfo.commandExecuted) { - // Create update status file - result = sdcMan->updateSdCardStateFile(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::initialize: Updating SD card state file failed" - << std::endl; - } - sdInfo.commandExecuted = true; - } - else { - nonBlockingOpChecking(SdStates::SET_STATE_SELF, 4, "Updating SDC file"); - } + // This lambda checks the non-blocking operation and assigns the new state on success. + // It returns true for an operation success and false otherwise + auto nonBlockingOpChecking = [&](SdStates newStateOnSuccess, uint16_t maxCycleCount, + std::string opPrintout) { + SdCardManager::OpStatus status = sdcMan->checkCurrentOp(operation); + if (status == SdCardManager::OpStatus::SUCCESS) { + sdInfo.state = newStateOnSuccess; + sdInfo.commandExecuted = false; + sdInfo.cycleCount = 0; + return true; + } else if (sdInfo.cycleCount > 4) { + sif::warning << "CoreController::sdInitStateMachine: " << opPrintout << " takes too long" + << std::endl; + return false; } + return false; + }; - if(sdInfo.state == SdStates::SET_STATE_SELF) { - if(not sdInfo.commandExecuted) { - result = sdcMan->getSdCardActiveStatus(sdInfo.currentState); - determinePreferredSdCard(); - updateSdInfoOther(); - if(sdInfo.pref != sd::SdCard::SLOT_0 and sdInfo.pref != sd::SdCard::SLOT_1) { - sif::warning << "Preferred SD card invalid. Setting to card 0.." << std::endl; - sdInfo.pref = sd::SdCard::SLOT_0; - } - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Getting SD card activity status failed" << std::endl; - } + if (sdInfo.state == SdStates::GET_INFO) { + if (not sdInfo.commandExecuted) { + // Create update status file + result = sdcMan->updateSdCardStateFile(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::initialize: Updating SD card state file failed" + << std::endl; + } + sdInfo.commandExecuted = true; + } else { + nonBlockingOpChecking(SdStates::SET_STATE_SELF, 4, "Updating SDC file"); + } + } + + if (sdInfo.state == SdStates::SET_STATE_SELF) { + if (not sdInfo.commandExecuted) { + result = sdcMan->getSdCardActiveStatus(sdInfo.currentState); + determinePreferredSdCard(); + updateSdInfoOther(); + if (sdInfo.pref != sd::SdCard::SLOT_0 and sdInfo.pref != sd::SdCard::SLOT_1) { + sif::warning << "Preferred SD card invalid. Setting to card 0.." << std::endl; + sdInfo.pref = sd::SdCard::SLOT_0; + } + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Getting SD card activity status failed" << std::endl; + } #if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT - sif::info << "Cold redundant SD card configuration, preferred SD card: " << - static_cast(sdInfo.pref) << std::endl; + sif::info << "Cold redundant SD card configuration, preferred SD card: " + << static_cast(sdInfo.pref) << std::endl; #endif - if(sdInfo.prefState == sd::SdState::MOUNTED) { + if (sdInfo.prefState == sd::SdState::MOUNTED) { #if OBSW_VERBOSE_LEVEL >= 1 - std::string mountString; - if(sdInfo.pref == sd::SdCard::SLOT_0) { - mountString = SdCardManager::SD_0_MOUNT_POINT; - } - else { - mountString = SdCardManager::SD_1_MOUNT_POINT; - } - sif::info << "SD card " << sdInfo.prefChar << " already on and mounted at " << - mountString << std::endl; + std::string mountString; + if (sdInfo.pref == sd::SdCard::SLOT_0) { + mountString = SdCardManager::SD_0_MOUNT_POINT; + } else { + mountString = SdCardManager::SD_1_MOUNT_POINT; + } + sif::info << "SD card " << sdInfo.prefChar << " already on and mounted at " << mountString + << std::endl; #endif - sdInfo.state = SdStates::DETERMINE_OTHER; - } - else if(sdInfo.prefState == sd::SdState::OFF) { - sdCardSetup(sdInfo.pref, sd::SdState::ON, sdInfo.prefChar, false); - sdInfo.commandExecuted = true; - } - else if(sdInfo.prefState == sd::SdState::ON) { - sdInfo.state = SdStates::MOUNT_SELF; - } - } - else { - if(nonBlockingOpChecking(SdStates::MOUNT_SELF, 10, "Setting SDC state")) { - sdInfo.prefState = sd::SdState::ON; - currentStateSetter(sdInfo.pref, sd::SdState::ON); - } - } + sdInfo.state = SdStates::DETERMINE_OTHER; + } else if (sdInfo.prefState == sd::SdState::OFF) { + sdCardSetup(sdInfo.pref, sd::SdState::ON, sdInfo.prefChar, false); + sdInfo.commandExecuted = true; + } else if (sdInfo.prefState == sd::SdState::ON) { + sdInfo.state = SdStates::MOUNT_SELF; + } + } else { + if (nonBlockingOpChecking(SdStates::MOUNT_SELF, 10, "Setting SDC state")) { + sdInfo.prefState = sd::SdState::ON; + currentStateSetter(sdInfo.pref, sd::SdState::ON); + } } + } - if(sdInfo.state == SdStates::MOUNT_SELF) { - if(not sdInfo.commandExecuted) { - result = sdCardSetup(sdInfo.pref, sd::SdState::MOUNTED, sdInfo.prefChar); - sdInfo.commandExecuted = true; - } - else { - if(nonBlockingOpChecking(SdStates::DETERMINE_OTHER, 5, "Mounting SD card")) { - sdInfo.prefState = sd::SdState::MOUNTED; - currentStateSetter(sdInfo.pref, sd::SdState::MOUNTED); - } - } + if (sdInfo.state == SdStates::MOUNT_SELF) { + if (not sdInfo.commandExecuted) { + result = sdCardSetup(sdInfo.pref, sd::SdState::MOUNTED, sdInfo.prefChar); + sdInfo.commandExecuted = true; + } else { + if (nonBlockingOpChecking(SdStates::DETERMINE_OTHER, 5, "Mounting SD card")) { + sdInfo.prefState = sd::SdState::MOUNTED; + currentStateSetter(sdInfo.pref, sd::SdState::MOUNTED); + } } + } - if(sdInfo.state == SdStates::DETERMINE_OTHER) { - // Determine whether any additional operations have to be done for the other SD card - // 1. Cold redundant case: Other SD card needs to be unmounted and switched off - // 2. Hot redundant case: Other SD card needs to be mounted and switched on + if (sdInfo.state == SdStates::DETERMINE_OTHER) { + // Determine whether any additional operations have to be done for the other SD card + // 1. Cold redundant case: Other SD card needs to be unmounted and switched off + // 2. Hot redundant case: Other SD card needs to be mounted and switched on #if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT - if(sdInfo.otherState == sd::SdState::ON) { - sdInfo.state = SdStates::SET_STATE_OTHER; - } - else if(sdInfo.otherState == sd::SdState::MOUNTED) { - sdInfo.state = SdStates::MOUNT_UNMOUNT_OTHER; - } - else { - // Is already off, update info, but with a small delay - sdInfo.state = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE; - } -#elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT - if(sdInfo.otherState == sd::SdState::OFF) { - sdInfo.state = SdStates::SET_STATE_OTHER; - } - else if(sdInfo.otherState == sd::SdState::ON) { - sdInfo.state = SdStates::MOUNT_UNMOUNT_OTHER; - } - else { - // Is already on and mounted, update info - sdInfo.state = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE; - } -#endif + if (sdInfo.otherState == sd::SdState::ON) { + sdInfo.state = SdStates::SET_STATE_OTHER; + } else if (sdInfo.otherState == sd::SdState::MOUNTED) { + sdInfo.state = SdStates::MOUNT_UNMOUNT_OTHER; + } else { + // Is already off, update info, but with a small delay + sdInfo.state = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE; } +#elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT + if (sdInfo.otherState == sd::SdState::OFF) { + sdInfo.state = SdStates::SET_STATE_OTHER; + } else if (sdInfo.otherState == sd::SdState::ON) { + sdInfo.state = SdStates::MOUNT_UNMOUNT_OTHER; + } else { + // Is already on and mounted, update info + sdInfo.state = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE; + } +#endif + } - if(sdInfo.state == SdStates::SET_STATE_OTHER) { - // Set state of other SD card to ON or OFF, depending on redundancy mode + if (sdInfo.state == SdStates::SET_STATE_OTHER) { + // Set state of other SD card to ON or OFF, depending on redundancy mode #if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT - if(not sdInfo.commandExecuted) { - result = sdCardSetup(sdInfo.other, sd::SdState::OFF, sdInfo.otherChar, false); - sdInfo.commandExecuted = true; - } - else { - if(nonBlockingOpChecking(SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE, 10, - "Switching off other SD card")) { - sdInfo.otherState = sd::SdState::OFF; - currentStateSetter(sdInfo.other, sd::SdState::OFF); - } - } -#elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT - if(not sdInfo.commandExecuted) { - result = sdCardSetup(sdInfo.other, sd::SdState::ON, sdInfo.otherChar, false); - sdInfo.commandExecuted = true; - } - else { - if(nonBlockingOpChecking(SdStates::MOUNT_UNMOUNT_OTHER, 10, - "Switching on other SD card")) { - sdInfo.otherState = sd::SdState::ON; - currentStateSetter(sdInfo.other, sd::SdState::ON); - } - } -#endif + if (not sdInfo.commandExecuted) { + result = sdCardSetup(sdInfo.other, sd::SdState::OFF, sdInfo.otherChar, false); + sdInfo.commandExecuted = true; + } else { + if (nonBlockingOpChecking(SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE, 10, + "Switching off other SD card")) { + sdInfo.otherState = sd::SdState::OFF; + currentStateSetter(sdInfo.other, sd::SdState::OFF); + } } +#elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT + if (not sdInfo.commandExecuted) { + result = sdCardSetup(sdInfo.other, sd::SdState::ON, sdInfo.otherChar, false); + sdInfo.commandExecuted = true; + } else { + if (nonBlockingOpChecking(SdStates::MOUNT_UNMOUNT_OTHER, 10, "Switching on other SD card")) { + sdInfo.otherState = sd::SdState::ON; + currentStateSetter(sdInfo.other, sd::SdState::ON); + } + } +#endif + } - if(sdInfo.state == SdStates::MOUNT_UNMOUNT_OTHER) { - // Mount or unmount other SD card, depending on redundancy mode + if (sdInfo.state == SdStates::MOUNT_UNMOUNT_OTHER) { + // Mount or unmount other SD card, depending on redundancy mode #if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT - if(not sdInfo.commandExecuted) { - result = sdCardSetup(sdInfo.other, sd::SdState::ON, sdInfo.otherChar); - sdInfo.commandExecuted = true; - } - else { - if(nonBlockingOpChecking(SdStates::SET_STATE_OTHER, 10, "Unmounting other SD card")) { - sdInfo.otherState = sd::SdState::ON; - currentStateSetter(sdInfo.other, sd::SdState::ON); - } - } + if (not sdInfo.commandExecuted) { + result = sdCardSetup(sdInfo.other, sd::SdState::ON, sdInfo.otherChar); + sdInfo.commandExecuted = true; + } else { + if (nonBlockingOpChecking(SdStates::SET_STATE_OTHER, 10, "Unmounting other SD card")) { + sdInfo.otherState = sd::SdState::ON; + currentStateSetter(sdInfo.other, sd::SdState::ON); + } + } #elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT - if(not sdInfo.commandExecuted) { - result = sdCardSetup(sdInfo.other, sd::SdState::MOUNTED, sdInfo.otherChar); - sdInfo.commandExecuted = true; - } - else { - if(nonBlockingOpChecking(SdStates::UPDATE_INFO, 4, "Mounting other SD card")) { - sdInfo.otherState = sd::SdState::MOUNTED; - currentStateSetter(sdInfo.other, sd::SdState::MOUNTED); - } - } + if (not sdInfo.commandExecuted) { + result = sdCardSetup(sdInfo.other, sd::SdState::MOUNTED, sdInfo.otherChar); + sdInfo.commandExecuted = true; + } else { + if (nonBlockingOpChecking(SdStates::UPDATE_INFO, 4, "Mounting other SD card")) { + sdInfo.otherState = sd::SdState::MOUNTED; + currentStateSetter(sdInfo.other, sd::SdState::MOUNTED); + } + } #endif - } + } - if(sdInfo.state == SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE) { - sdInfo.state = SdStates::UPDATE_INFO; + if (sdInfo.state == SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE) { + sdInfo.state = SdStates::UPDATE_INFO; + } else if (sdInfo.state == SdStates::UPDATE_INFO) { + // It is assumed that all tasks are running by the point this section is reached. + // Therefore, perform this operation in blocking mode because it does not take long + // and the ready state of the SD card is available sooner + sdcMan->setBlocking(true); + // Update status file + result = sdcMan->updateSdCardStateFile(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::initialize: Updating SD card state file failed" << std::endl; } - else if(sdInfo.state == SdStates::UPDATE_INFO) { - // It is assumed that all tasks are running by the point this section is reached. - // Therefore, perform this operation in blocking mode because it does not take long - // and the ready state of the SD card is available sooner - sdcMan->setBlocking(true); - // Update status file - result = sdcMan->updateSdCardStateFile(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::initialize: Updating SD card state file failed" - << std::endl; - } - sdInfo.commandExecuted = false; - sdInfo.state = SdStates::IDLE; - sdInfo.cycleCount = 0; - sdcMan->setBlocking(false); - sdcMan->getSdCardActiveStatus(sdInfo.currentState); - if(not sdInfo.initFinished) { - updateSdInfoOther(); - sdInfo.initFinished = true; - sif::info << "SD card initialization finished" << std::endl; - } + sdInfo.commandExecuted = false; + sdInfo.state = SdStates::IDLE; + sdInfo.cycleCount = 0; + sdcMan->setBlocking(false); + sdcMan->getSdCardActiveStatus(sdInfo.currentState); + if (not sdInfo.initFinished) { + updateSdInfoOther(); + sdInfo.initFinished = true; + sif::info << "SD card initialization finished" << std::endl; } + } - if(sdInfo.state == SdStates::SET_STATE_FROM_COMMAND) { - if(not sdInfo.commandExecuted) { - executeNextExternalSdCommand(); - } - else { - checkExternalSdCommandStatus(); - } + if (sdInfo.state == SdStates::SET_STATE_FROM_COMMAND) { + if (not sdInfo.commandExecuted) { + executeNextExternalSdCommand(); + } else { + checkExternalSdCommandStatus(); } + } - sdInfo.cycleCount++; - return HasReturnvaluesIF::RETURN_OK; + sdInfo.cycleCount++; + return HasReturnvaluesIF::RETURN_OK; } void CoreController::executeNextExternalSdCommand() { - std::string sdChar; - sd::SdState currentStateOfCard = sd::SdState::OFF; - if(sdInfo.commandedCard == sd::SdCard::SLOT_0) { - sdChar = "0"; - currentStateOfCard = sdInfo.currentState.first; + std::string sdChar; + sd::SdState currentStateOfCard = sd::SdState::OFF; + if (sdInfo.commandedCard == sd::SdCard::SLOT_0) { + sdChar = "0"; + currentStateOfCard = sdInfo.currentState.first; + } else { + sdChar = "1"; + currentStateOfCard = sdInfo.currentState.second; + } + if (currentStateOfCard == sd::SdState::OFF) { + if (sdInfo.commandedState == sd::SdState::ON) { + sdInfo.currentlyCommandedState = sdInfo.commandedState; + } else if (sdInfo.commandedState == sd::SdState::MOUNTED) { + sdInfo.currentlyCommandedState = sd::SdState::ON; + } else { + // SD card is already on target state + sdInfo.commandFinished = true; + sdInfo.state = SdStates::IDLE; } - else { - sdChar = "1"; - currentStateOfCard = sdInfo.currentState.second; + } else if (currentStateOfCard == sd::SdState::ON) { + if (sdInfo.commandedState == sd::SdState::OFF or + sdInfo.commandedState == sd::SdState::MOUNTED) { + sdInfo.currentlyCommandedState = sdInfo.commandedState; + } else { + // Already on target state + sdInfo.commandFinished = true; + sdInfo.state = SdStates::IDLE; } - if(currentStateOfCard == sd::SdState::OFF) { - if(sdInfo.commandedState == sd::SdState::ON) { - sdInfo.currentlyCommandedState = sdInfo.commandedState; - } - else if(sdInfo.commandedState == sd::SdState::MOUNTED) { - sdInfo.currentlyCommandedState = sd::SdState::ON; - } - else { - // SD card is already on target state - sdInfo.commandFinished = true; - sdInfo.state = SdStates::IDLE; - } + } else if (currentStateOfCard == sd::SdState::MOUNTED) { + if (sdInfo.commandedState == sd::SdState::ON) { + sdInfo.currentlyCommandedState = sdInfo.commandedState; + } else if (sdInfo.commandedState == sd::SdState::OFF) { + // This causes an unmount in sdCardSetup + sdInfo.currentlyCommandedState = sd::SdState::ON; + } else { + sdInfo.commandFinished = true; } - else if(currentStateOfCard == sd::SdState::ON) { - if(sdInfo.commandedState == sd::SdState::OFF or - sdInfo.commandedState == sd::SdState::MOUNTED) { - sdInfo.currentlyCommandedState = sdInfo.commandedState; - } - else { - // Already on target state - sdInfo.commandFinished = true; - sdInfo.state = SdStates::IDLE; - } - } - else if(currentStateOfCard == sd::SdState::MOUNTED) { - if(sdInfo.commandedState == sd::SdState::ON) { - sdInfo.currentlyCommandedState = sdInfo.commandedState; - } - else if(sdInfo.commandedState == sd::SdState::OFF) { - // This causes an unmount in sdCardSetup - sdInfo.currentlyCommandedState = sd::SdState::ON; - } - else { - sdInfo.commandFinished = true; - } - } - sdCardSetup(sdInfo.commandedCard, sdInfo.commandedState, sdChar); - sdInfo.commandExecuted = true; + } + sdCardSetup(sdInfo.commandedCard, sdInfo.commandedState, sdChar); + sdInfo.commandExecuted = true; } void CoreController::checkExternalSdCommandStatus() { - SdCardManager::Operations operation; - SdCardManager::OpStatus status = sdcMan->checkCurrentOp(operation); - if(status == SdCardManager::OpStatus::SUCCESS) { - if(sdInfo.currentlyCommandedState == sdInfo.commandedState) { - sdInfo.state = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE; - sdInfo.commandFinished = true; - } - else { - // stay on same state machine state because the target state was not reached yet. - sdInfo.cycleCount = 0; - } - currentStateSetter(sdInfo.commandedCard, sdInfo.currentlyCommandedState); - sdInfo.commandExecuted = false; - } - else if(sdInfo.cycleCount > 4) { - sif::warning << "CoreController::sdStateMachine: Commanding SD state " - "takes too long" << std::endl; + SdCardManager::Operations operation; + SdCardManager::OpStatus status = sdcMan->checkCurrentOp(operation); + if (status == SdCardManager::OpStatus::SUCCESS) { + if (sdInfo.currentlyCommandedState == sdInfo.commandedState) { + sdInfo.state = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE; + sdInfo.commandFinished = true; + } else { + // stay on same state machine state because the target state was not reached yet. + sdInfo.cycleCount = 0; } + currentStateSetter(sdInfo.commandedCard, sdInfo.currentlyCommandedState); + sdInfo.commandExecuted = false; + } else if (sdInfo.cycleCount > 4) { + sif::warning << "CoreController::sdStateMachine: Commanding SD state " + "takes too long" + << std::endl; + } } void CoreController::currentStateSetter(sd::SdCard sdCard, sd::SdState newState) { - if(sdCard == sd::SdCard::SLOT_0) { - sdInfo.currentState.first = newState; - } - else { - sdInfo.currentState.second = newState; - } + if (sdCard == sd::SdCard::SLOT_0) { + sdInfo.currentState.first = newState; + } else { + sdInfo.currentState.second = newState; + } } ReturnValue_t CoreController::sdCardSetup(sd::SdCard sdCard, sd::SdState targetState, - std::string sdChar, bool printOutput) { - std::string mountString; - sdcMan->setPrintCommandOutput(printOutput); - if(sdCard == sd::SdCard::SLOT_0) { - mountString = SdCardManager::SD_0_MOUNT_POINT; - } - else { - mountString = SdCardManager::SD_1_MOUNT_POINT; - } + std::string sdChar, bool printOutput) { + std::string mountString; + sdcMan->setPrintCommandOutput(printOutput); + if (sdCard == sd::SdCard::SLOT_0) { + mountString = SdCardManager::SD_0_MOUNT_POINT; + } else { + mountString = SdCardManager::SD_1_MOUNT_POINT; + } - sd::SdState state = sd::SdState::OFF; - if(sdCard == sd::SdCard::SLOT_0) { - state = sdInfo.currentState.first; - } - else { - state = sdInfo.currentState.second; - } - if(state == sd::SdState::MOUNTED) { - if(targetState == sd::SdState::OFF) { - sif::info << "Switching off SD card " << sdChar << std::endl; - return sdcMan->switchOffSdCard(sdCard, true, &sdInfo.currentState); - } - else if(targetState == sd::SdState::ON) { - sif::info << "Unmounting SD card " << sdChar << std::endl; - return sdcMan->unmountSdCard(sdCard); - } - else { - if(std::filesystem::exists(mountString)) { - sif::info << "SD card " << sdChar << " already on and mounted at " << - mountString << std::endl; - return SdCardManager::ALREADY_MOUNTED; - } - sif::error << "SD card mounted but expected mount point " << - mountString << " not found!" << std::endl; - return SdCardManager::MOUNT_ERROR; - } + sd::SdState state = sd::SdState::OFF; + if (sdCard == sd::SdCard::SLOT_0) { + state = sdInfo.currentState.first; + } else { + state = sdInfo.currentState.second; + } + if (state == sd::SdState::MOUNTED) { + if (targetState == sd::SdState::OFF) { + sif::info << "Switching off SD card " << sdChar << std::endl; + return sdcMan->switchOffSdCard(sdCard, true, &sdInfo.currentState); + } else if (targetState == sd::SdState::ON) { + sif::info << "Unmounting SD card " << sdChar << std::endl; + return sdcMan->unmountSdCard(sdCard); + } else { + if (std::filesystem::exists(mountString)) { + sif::info << "SD card " << sdChar << " already on and mounted at " << mountString + << std::endl; + return SdCardManager::ALREADY_MOUNTED; + } + sif::error << "SD card mounted but expected mount point " << mountString << " not found!" + << std::endl; + return SdCardManager::MOUNT_ERROR; } + } - if(state == sd::SdState::OFF) { - if(targetState == sd::SdState::MOUNTED) { - sif::info << "Switching on and mounting SD card " << sdChar << " at " << - mountString << std::endl; - return sdcMan->switchOnSdCard(sdCard, true, &sdInfo.currentState); - } - else if(targetState == sd::SdState::ON) { - sif::info << "Switching on SD card " << sdChar << std::endl; - return sdcMan->switchOnSdCard(sdCard, false, &sdInfo.currentState); - } + if (state == sd::SdState::OFF) { + if (targetState == sd::SdState::MOUNTED) { + sif::info << "Switching on and mounting SD card " << sdChar << " at " << mountString + << std::endl; + return sdcMan->switchOnSdCard(sdCard, true, &sdInfo.currentState); + } else if (targetState == sd::SdState::ON) { + sif::info << "Switching on SD card " << sdChar << std::endl; + return sdcMan->switchOnSdCard(sdCard, false, &sdInfo.currentState); } + } - else if(state == sd::SdState::ON) { - if(targetState == sd::SdState::MOUNTED) { - sif::info << "Mounting SD card " << sdChar << " at " << mountString << std::endl; - return sdcMan->mountSdCard(sdCard); - } - else if(targetState == sd::SdState::OFF) { - sif::info << "Switching off SD card " << sdChar << std::endl; - return sdcMan->switchOffSdCard(sdCard, false, &sdInfo.currentState); - } + else if (state == sd::SdState::ON) { + if (targetState == sd::SdState::MOUNTED) { + sif::info << "Mounting SD card " << sdChar << " at " << mountString << std::endl; + return sdcMan->mountSdCard(sdCard); + } else if (targetState == sd::SdState::OFF) { + sif::info << "Switching off SD card " << sdChar << std::endl; + return sdcMan->switchOffSdCard(sdCard, false, &sdInfo.currentState); } - else { - sif::warning << "CoreController::sdCardSetup: Invalid state for this call" << std::endl; - } - return HasReturnvaluesIF::RETURN_OK; + } else { + sif::warning << "CoreController::sdCardSetup: Invalid state for this call" << std::endl; + } + return HasReturnvaluesIF::RETURN_OK; } - ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t *data, size_t size) { - switch(actionId) { - case(LIST_DIRECTORY_INTO_FILE): { - return actionListDirectoryIntoFile(actionId, commandedBy, data, size); + const uint8_t *data, size_t size) { + switch (actionId) { + case (LIST_DIRECTORY_INTO_FILE): { + return actionListDirectoryIntoFile(actionId, commandedBy, data, size); } - case(REBOOT_OBC): { - return actionPerformReboot(data, size); + case (REBOOT_OBC): { + return actionPerformReboot(data, size); } default: { - return HasActionsIF::INVALID_ACTION_ID; - } + return HasActionsIF::INVALID_ACTION_ID; } + } } ReturnValue_t CoreController::sdColdRedundantBlockingInit() { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - result = sdCardSetup(sdInfo.pref, sd::SdState::MOUNTED, sdInfo.prefChar); - if(result != SdCardManager::ALREADY_MOUNTED and result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Setting up preferred card " << sdInfo.otherChar << - " in cold redundant mode failed" << std::endl; - // Try other SD card and mark set up operation as failed - sdCardSetup(sdInfo.pref, sd::SdState::MOUNTED, sdInfo.prefChar); - result = HasReturnvaluesIF::RETURN_FAILED; - } + result = sdCardSetup(sdInfo.pref, sd::SdState::MOUNTED, sdInfo.prefChar); + if (result != SdCardManager::ALREADY_MOUNTED and result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Setting up preferred card " << sdInfo.otherChar + << " in cold redundant mode failed" << std::endl; + // Try other SD card and mark set up operation as failed + sdCardSetup(sdInfo.pref, sd::SdState::MOUNTED, sdInfo.prefChar); + result = HasReturnvaluesIF::RETURN_FAILED; + } - if(result != HasReturnvaluesIF::RETURN_FAILED and sdInfo.otherState != sd::SdState::OFF) { - sif::info << "Switching off secondary SD card " << sdInfo.otherChar << std::endl; - // Switch off other SD card in cold redundant mode if setting up preferred one worked - // without issues - ReturnValue_t result2 = sdcMan->switchOffSdCard(sdInfo.other, - sdInfo.otherState, &sdInfo.currentState); - if(result2 != HasReturnvaluesIF::RETURN_OK and result2 != SdCardManager::ALREADY_OFF) { - sif::warning << "Switching off secondary SD card " << sdInfo.otherChar << - " in cold redundant mode failed" << std::endl; - } + if (result != HasReturnvaluesIF::RETURN_FAILED and sdInfo.otherState != sd::SdState::OFF) { + sif::info << "Switching off secondary SD card " << sdInfo.otherChar << std::endl; + // Switch off other SD card in cold redundant mode if setting up preferred one worked + // without issues + ReturnValue_t result2 = + sdcMan->switchOffSdCard(sdInfo.other, sdInfo.otherState, &sdInfo.currentState); + if (result2 != HasReturnvaluesIF::RETURN_OK and result2 != SdCardManager::ALREADY_OFF) { + sif::warning << "Switching off secondary SD card " << sdInfo.otherChar + << " in cold redundant mode failed" << std::endl; } - return result; + } + return result; } ReturnValue_t CoreController::incrementAllocationFailureCount() { - uint32_t count = 0; - ReturnValue_t result = scratch::readNumber(scratch::ALLOC_FAILURE_COUNT, count); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - count++; - return scratch::writeNumber(scratch::ALLOC_FAILURE_COUNT, count); + uint32_t count = 0; + ReturnValue_t result = scratch::readNumber(scratch::ALLOC_FAILURE_COUNT, count); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + count++; + return scratch::writeNumber(scratch::ALLOC_FAILURE_COUNT, count); } ReturnValue_t CoreController::initVersionFile() { + std::string unameFileName = "/tmp/uname_version.txt"; + // TODO: No -v flag for now. If the kernel version is used, need to cut off first few letters + std::string unameCmd = "uname -mnrso > " + unameFileName; + int result = std::system(unameCmd.c_str()); + if (result != 0) { + utility::handleSystemError(result, "CoreController::versionFileInit"); + } + std::ifstream unameFile(unameFileName); + std::string unameLine; + if (not std::getline(unameFile, unameLine)) { + sif::warning << "CoreController::versionFileInit: Retrieving uname line failed" << std::endl; + } - std::string unameFileName = "/tmp/uname_version.txt"; - // TODO: No -v flag for now. If the kernel version is used, need to cut off first few letters - std::string unameCmd = "uname -mnrso > " + unameFileName; - int result = std::system(unameCmd.c_str()); - if(result != 0) { - utility::handleSystemError(result, "CoreController::versionFileInit"); - } - std::ifstream unameFile(unameFileName); - std::string unameLine; - if(not std::getline(unameFile, unameLine)) { - sif::warning << "CoreController::versionFileInit: Retrieving uname line failed" - << std::endl; - } - - std::string fullObswVersionString = "OBSW: v" + std::to_string(SW_VERSION) + "." + - std::to_string(SW_SUBVERSION) + "." + std::to_string(SW_REVISION); - std::string fullFsfwVersionString = "FSFW: v" + std::to_string(FSFW_VERSION) + "." + - std::to_string(FSFW_SUBVERSION) + "." + std::to_string(FSFW_REVISION); - std::string systemString = "System: " + unameLine; - std::string mountPrefix = SdCardManager::instance()->getCurrentMountPrefix(); - std::string versionFilePath = mountPrefix + VERSION_FILE; - std::fstream versionFile; - - if(not std::filesystem::exists(versionFilePath)) { - sif::info << "Writing version file " << versionFilePath << ".." << std::endl; - versionFile.open(versionFilePath, std::ios_base::out); - versionFile << fullObswVersionString << std::endl; - versionFile << fullFsfwVersionString << std::endl; - versionFile << systemString << std::endl; - return HasReturnvaluesIF::RETURN_OK; - } - - // Check whether any version has changed - bool createNewFile = false; - versionFile.open(versionFilePath); - std::string currentVersionString; - uint8_t idx = 0; - while(std::getline(versionFile, currentVersionString)) { - if(idx == 0) { - if(currentVersionString != fullObswVersionString) { - sif::info << "OBSW version changed" << std::endl; - sif::info << "From " << currentVersionString << " to " << - fullObswVersionString << std::endl; - createNewFile = true; - } - } - else if(idx == 1) { - if(currentVersionString != fullFsfwVersionString) { - sif::info << "FSFW version changed" << std::endl; - sif::info << "From " << currentVersionString << " to " << - fullFsfwVersionString << std::endl; - createNewFile = true; - } - } - else if(idx == 2) { - if(currentVersionString != systemString) { - sif::info << "System version changed" << std::endl; - sif::info << "Old: " << currentVersionString << std::endl; - sif::info << "New: " << systemString << std::endl; - createNewFile = true; - } - } - else { - sif::warning << "Invalid version file! Rewriting it.." << std::endl; - createNewFile = true; - } - idx++; - } - - // Overwrite file if necessary - if(createNewFile) { - sif::info << "Rewriting version.txt file with updated versions.." << std::endl; - versionFile.close(); - versionFile.open(versionFilePath, std::ios_base::out | std::ios_base::trunc); - versionFile << fullObswVersionString << std::endl; - versionFile << fullFsfwVersionString << std::endl; - versionFile << systemString << std::endl; - } + std::string fullObswVersionString = "OBSW: v" + std::to_string(SW_VERSION) + "." + + std::to_string(SW_SUBVERSION) + "." + + std::to_string(SW_REVISION); + std::string fullFsfwVersionString = "FSFW: v" + std::to_string(FSFW_VERSION) + "." + + std::to_string(FSFW_SUBVERSION) + "." + + std::to_string(FSFW_REVISION); + std::string systemString = "System: " + unameLine; + std::string mountPrefix = SdCardManager::instance()->getCurrentMountPrefix(); + std::string versionFilePath = mountPrefix + VERSION_FILE; + std::fstream versionFile; + if (not std::filesystem::exists(versionFilePath)) { + sif::info << "Writing version file " << versionFilePath << ".." << std::endl; + versionFile.open(versionFilePath, std::ios_base::out); + versionFile << fullObswVersionString << std::endl; + versionFile << fullFsfwVersionString << std::endl; + versionFile << systemString << std::endl; return HasReturnvaluesIF::RETURN_OK; + } + + // Check whether any version has changed + bool createNewFile = false; + versionFile.open(versionFilePath); + std::string currentVersionString; + uint8_t idx = 0; + while (std::getline(versionFile, currentVersionString)) { + if (idx == 0) { + if (currentVersionString != fullObswVersionString) { + sif::info << "OBSW version changed" << std::endl; + sif::info << "From " << currentVersionString << " to " << fullObswVersionString + << std::endl; + createNewFile = true; + } + } else if (idx == 1) { + if (currentVersionString != fullFsfwVersionString) { + sif::info << "FSFW version changed" << std::endl; + sif::info << "From " << currentVersionString << " to " << fullFsfwVersionString + << std::endl; + createNewFile = true; + } + } else if (idx == 2) { + if (currentVersionString != systemString) { + sif::info << "System version changed" << std::endl; + sif::info << "Old: " << currentVersionString << std::endl; + sif::info << "New: " << systemString << std::endl; + createNewFile = true; + } + } else { + sif::warning << "Invalid version file! Rewriting it.." << std::endl; + createNewFile = true; + } + idx++; + } + + // Overwrite file if necessary + if (createNewFile) { + sif::info << "Rewriting version.txt file with updated versions.." << std::endl; + versionFile.close(); + versionFile.open(versionFilePath, std::ios_base::out | std::ios_base::trunc); + versionFile << fullObswVersionString << std::endl; + versionFile << fullFsfwVersionString << std::endl; + versionFile << systemString << std::endl; + } + + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t CoreController::actionListDirectoryIntoFile(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t *data, size_t size) { - // TODO: Packet definition for clean deserialization - // 2 bytes for a and R flag, at least 5 bytes for minimum valid path /tmp with - // null termination, at least 7 bytes for minimum target file name /tmp/a with - // null termination. - if(size < 14) { - return HasActionsIF::INVALID_PARAMETERS; - } - // We could also make -l optional, but I can't think of a reason why to not use -l.. + MessageQueueId_t commandedBy, + const uint8_t *data, size_t size) { + // TODO: Packet definition for clean deserialization + // 2 bytes for a and R flag, at least 5 bytes for minimum valid path /tmp with + // null termination, at least 7 bytes for minimum target file name /tmp/a with + // null termination. + if (size < 14) { + return HasActionsIF::INVALID_PARAMETERS; + } + // We could also make -l optional, but I can't think of a reason why to not use -l.. - // This flag specifies to run ls with -a - bool aFlag = data[0]; - data += 1; - // This flag specifies to run ls with -R - bool RFlag = data[1]; - data += 1; + // This flag specifies to run ls with -a + bool aFlag = data[0]; + data += 1; + // This flag specifies to run ls with -R + bool RFlag = data[1]; + data += 1; - size_t remainingSize = size - 2; - // One larger for null termination, which prevents undefined behaviour if the sent - // strings are not 0 terminated properly - std::vector repoAndTargetFileBuffer(remainingSize + 1, 0); - std::memcpy(repoAndTargetFileBuffer.data(), data, remainingSize); - const char* currentCharPtr = reinterpret_cast(repoAndTargetFileBuffer.data()); - // Full target file name - std::string repoName(currentCharPtr); - size_t repoLength = repoName.length(); - // The other string needs to be at least one letter plus NULL termination to be valid at all - // The first string also needs to be NULL terminated, but the termination is not included - // in the string length, so this is subtracted from the remaining size as well - if(repoLength > remainingSize - 3) { - return HasActionsIF::INVALID_PARAMETERS; - } - // The file length will not include the NULL termination, so we skip it - currentCharPtr += repoLength + 1; - std::string targetFileName(currentCharPtr); - std::ostringstream oss; - oss << "ls -l"; - if(aFlag) { - oss << "a"; - } - if(RFlag) { - oss << "R"; - } + size_t remainingSize = size - 2; + // One larger for null termination, which prevents undefined behaviour if the sent + // strings are not 0 terminated properly + std::vector repoAndTargetFileBuffer(remainingSize + 1, 0); + std::memcpy(repoAndTargetFileBuffer.data(), data, remainingSize); + const char *currentCharPtr = reinterpret_cast(repoAndTargetFileBuffer.data()); + // Full target file name + std::string repoName(currentCharPtr); + size_t repoLength = repoName.length(); + // The other string needs to be at least one letter plus NULL termination to be valid at all + // The first string also needs to be NULL terminated, but the termination is not included + // in the string length, so this is subtracted from the remaining size as well + if (repoLength > remainingSize - 3) { + return HasActionsIF::INVALID_PARAMETERS; + } + // The file length will not include the NULL termination, so we skip it + currentCharPtr += repoLength + 1; + std::string targetFileName(currentCharPtr); + std::ostringstream oss; + oss << "ls -l"; + if (aFlag) { + oss << "a"; + } + if (RFlag) { + oss << "R"; + } - oss << " " << repoName << " > " << targetFileName; - int result = std::system(oss.str().c_str()); - if(result != 0) { - utility::handleSystemError(result, "CoreController::actionListDirectoryIntoFile"); - actionHelper.finish(false, commandedBy, actionId); - } - return HasReturnvaluesIF::RETURN_OK; + oss << " " << repoName << " > " << targetFileName; + int result = std::system(oss.str().c_str()); + if (result != 0) { + utility::handleSystemError(result, "CoreController::actionListDirectoryIntoFile"); + actionHelper.finish(false, commandedBy, actionId); + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t CoreController::initBootCopy() { - if(not std::filesystem::exists(CURR_COPY_FILE)) { - // Thils file is created by the systemd service eive-early-config so this should - // not happen normally - std::string cmd = "xsc_boot_copy > " + std::string(CURR_COPY_FILE); - int result = std::system(cmd.c_str()); - if(result != 0) { - utility::handleSystemError(result, "CoreController::initBootCopy"); - } + if (not std::filesystem::exists(CURR_COPY_FILE)) { + // Thils file is created by the systemd service eive-early-config so this should + // not happen normally + std::string cmd = "xsc_boot_copy > " + std::string(CURR_COPY_FILE); + int result = std::system(cmd.c_str()); + if (result != 0) { + utility::handleSystemError(result, "CoreController::initBootCopy"); } - std::ifstream file(CURR_COPY_FILE); - std::string line; - std::getline(file, line); - std::istringstream iss(line); - int value = 0; - iss >> value; - CURRENT_CHIP = static_cast(value); - iss >> value; - CURRENT_COPY = static_cast(value); - return HasReturnvaluesIF::RETURN_OK; + } + std::ifstream file(CURR_COPY_FILE); + std::string line; + std::getline(file, line); + std::istringstream iss(line); + int value = 0; + iss >> value; + CURRENT_CHIP = static_cast(value); + iss >> value; + CURRENT_COPY = static_cast(value); + return HasReturnvaluesIF::RETURN_OK; } void CoreController::getCurrentBootCopy(Chip &chip, Copy ©) { - // Not really thread-safe but it does not need to be - chip = CURRENT_CHIP; - copy = CURRENT_COPY; + // Not really thread-safe but it does not need to be + chip = CURRENT_CHIP; + copy = CURRENT_COPY; } ReturnValue_t CoreController::initWatchdogFifo() { - if(not std::filesystem::exists(watchdog::FIFO_NAME)) { - // Still return RETURN_OK for now - sif::info << "Watchdog FIFO " << watchdog::FIFO_NAME << " does not exist, can't initiate" << - " watchdog" << std::endl; - return HasReturnvaluesIF::RETURN_OK; - } - // Open FIFO write only and non-blocking to prevent SW from killing itself. - watchdogFifoFd = open(watchdog::FIFO_NAME.c_str(), O_WRONLY | O_NONBLOCK); - if(watchdogFifoFd < 0) { - if(errno == ENXIO) { - watchdogFifoFd = RETRY_FIFO_OPEN; - sif::info << "eive-watchdog not running. FIFO can not be opened" << std::endl; - } - else { - sif::error << "Opening pipe " << watchdog::FIFO_NAME << " write-only failed with " << - errno << ": " << strerror(errno) << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - } + if (not std::filesystem::exists(watchdog::FIFO_NAME)) { + // Still return RETURN_OK for now + sif::info << "Watchdog FIFO " << watchdog::FIFO_NAME << " does not exist, can't initiate" + << " watchdog" << std::endl; return HasReturnvaluesIF::RETURN_OK; + } + // Open FIFO write only and non-blocking to prevent SW from killing itself. + watchdogFifoFd = open(watchdog::FIFO_NAME.c_str(), O_WRONLY | O_NONBLOCK); + if (watchdogFifoFd < 0) { + if (errno == ENXIO) { + watchdogFifoFd = RETRY_FIFO_OPEN; + sif::info << "eive-watchdog not running. FIFO can not be opened" << std::endl; + } else { + sif::error << "Opening pipe " << watchdog::FIFO_NAME << " write-only failed with " << errno + << ": " << strerror(errno) << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + } + return HasReturnvaluesIF::RETURN_OK; } void CoreController::initPrint() { #if OBSW_VERBOSE_LEVEL >= 1 - if(watchdogFifoFd > 0) { - sif::info << "Opened watchdog FIFO successfully.." << std::endl; - } + if (watchdogFifoFd > 0) { + sif::info << "Opened watchdog FIFO successfully.." << std::endl; + } #endif } ReturnValue_t CoreController::actionPerformReboot(const uint8_t *data, size_t size) { - if(size < 1) { - return HasActionsIF::INVALID_PARAMETERS; - } - bool rebootSameBootCopy = data[0]; - bool protOpPerformed; - if(rebootSameBootCopy) { + if (size < 1) { + return HasActionsIF::INVALID_PARAMETERS; + } + bool rebootSameBootCopy = data[0]; + bool protOpPerformed; + if (rebootSameBootCopy) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::info << "CoreController::actionPerformReboot: Rebooting on current image" << std::endl; + sif::info << "CoreController::actionPerformReboot: Rebooting on current image" << std::endl; #endif - // Attempt graceful shutdown by unmounting and switching off SD cards - SdCardManager::instance()->switchOffSdCard(sd::SdCard::SLOT_0); - SdCardManager::instance()->switchOffSdCard(sd::SdCard::SLOT_1); - // If any boot copies are unprotected - ReturnValue_t retval = setBootCopyProtection(Chip::SELF_CHIP, Copy::SELF_COPY, - true, protOpPerformed, false); - if(retval == HasReturnvaluesIF::RETURN_OK and protOpPerformed) { - sif::info << "Running slot was writeprotected before reboot" << std::endl; - } - int result = std::system("xsc_boot_copy -r"); - if(result != 0) { - utility::handleSystemError(result, "CoreController::executeAction"); - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasActionsIF::EXECUTION_FINISHED; + // Attempt graceful shutdown by unmounting and switching off SD cards + SdCardManager::instance()->switchOffSdCard(sd::SdCard::SLOT_0); + SdCardManager::instance()->switchOffSdCard(sd::SdCard::SLOT_1); + // If any boot copies are unprotected + ReturnValue_t retval = + setBootCopyProtection(Chip::SELF_CHIP, Copy::SELF_COPY, true, protOpPerformed, false); + if (retval == HasReturnvaluesIF::RETURN_OK and protOpPerformed) { + sif::info << "Running slot was writeprotected before reboot" << std::endl; } - if(size < 3) { - return HasActionsIF::INVALID_PARAMETERS; - } -#if OBSW_VERBOSE_LEVEL >= 1 - sif::info << "CoreController::actionPerformReboot: Rebooting on " << - static_cast(data[1]) << " " << static_cast(data[2]) << std::endl; -#endif - - // Check that the target chip and copy is writeprotected first - generateChipStateFile(); - // If any boot copies are unprotected, protect them here - ReturnValue_t retval = setBootCopyProtection(static_cast(data[1]), - static_cast(data[2]), true, protOpPerformed, false); - if(retval == HasReturnvaluesIF::RETURN_OK and protOpPerformed) { - sif::info << "Target slot was writeprotected before reboot" << std::endl; - } - - // The second byte in data is the target chip, the third byte is the target copy - std::string cmdString = "xsc_boot_copy " + std::to_string(data[1]) + " " + - std::to_string(data[2]); - int result = std::system(cmdString.c_str()); - if(result != 0) { - utility::handleSystemError(result, "CoreController::executeAction"); - return HasReturnvaluesIF::RETURN_FAILED; + int result = std::system("xsc_boot_copy -r"); + if (result != 0) { + utility::handleSystemError(result, "CoreController::executeAction"); + return HasReturnvaluesIF::RETURN_FAILED; } return HasActionsIF::EXECUTION_FINISHED; + } + if (size < 3) { + return HasActionsIF::INVALID_PARAMETERS; + } +#if OBSW_VERBOSE_LEVEL >= 1 + sif::info << "CoreController::actionPerformReboot: Rebooting on " << static_cast(data[1]) + << " " << static_cast(data[2]) << std::endl; +#endif + + // Check that the target chip and copy is writeprotected first + generateChipStateFile(); + // If any boot copies are unprotected, protect them here + ReturnValue_t retval = setBootCopyProtection( + static_cast(data[1]), static_cast(data[2]), true, protOpPerformed, false); + if (retval == HasReturnvaluesIF::RETURN_OK and protOpPerformed) { + sif::info << "Target slot was writeprotected before reboot" << std::endl; + } + + // The second byte in data is the target chip, the third byte is the target copy + std::string cmdString = + "xsc_boot_copy " + std::to_string(data[1]) + " " + std::to_string(data[2]); + int result = std::system(cmdString.c_str()); + if (result != 0) { + utility::handleSystemError(result, "CoreController::executeAction"); + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasActionsIF::EXECUTION_FINISHED; } -CoreController::~CoreController() { -} +CoreController::~CoreController() {} void CoreController::determinePreferredSdCard() { - if(sdInfo.pref == sd::SdCard::NONE) { - ReturnValue_t result = sdcMan->getPreferredSdCard(sdInfo.pref); - if(result != HasReturnvaluesIF::RETURN_OK) { - if(result == scratch::KEY_NOT_FOUND) { - sif::warning << "CoreController::sdCardInit: " - "Preferred SD card not set. Setting to 0" << std::endl; - sdcMan->setPreferredSdCard(sd::SdCard::SLOT_0); - sdInfo.pref = sd::SdCard::SLOT_0; - } - else { - sif::warning << "CoreController::sdCardInit: Could not get preferred SD card" - "information from the scratch buffer" << std::endl; - } - } + if (sdInfo.pref == sd::SdCard::NONE) { + ReturnValue_t result = sdcMan->getPreferredSdCard(sdInfo.pref); + if (result != HasReturnvaluesIF::RETURN_OK) { + if (result == scratch::KEY_NOT_FOUND) { + sif::warning << "CoreController::sdCardInit: " + "Preferred SD card not set. Setting to 0" + << std::endl; + sdcMan->setPreferredSdCard(sd::SdCard::SLOT_0); + sdInfo.pref = sd::SdCard::SLOT_0; + } else { + sif::warning << "CoreController::sdCardInit: Could not get preferred SD card" + "information from the scratch buffer" + << std::endl; + } } + } } void CoreController::updateSdInfoOther() { - if(sdInfo.pref == sd::SdCard::SLOT_0) { - sdInfo.prefChar = "0"; - sdInfo.otherChar = "1"; - sdInfo.otherState = sdInfo.currentState.second; - sdInfo.prefState = sdInfo.currentState.first; - sdInfo.other = sd::SdCard::SLOT_1; + if (sdInfo.pref == sd::SdCard::SLOT_0) { + sdInfo.prefChar = "0"; + sdInfo.otherChar = "1"; + sdInfo.otherState = sdInfo.currentState.second; + sdInfo.prefState = sdInfo.currentState.first; + sdInfo.other = sd::SdCard::SLOT_1; - } - else if(sdInfo.pref == sd::SdCard::SLOT_1) { - sdInfo.prefChar = "1"; - sdInfo.otherChar = "0"; - sdInfo.otherState = sdInfo.currentState.first; - sdInfo.prefState = sdInfo.currentState.second; - sdInfo.other = sd::SdCard::SLOT_0; - } - else { - sif::warning << "CoreController::updateSdInfoOther: Invalid SD card passed" << std::endl; - } + } else if (sdInfo.pref == sd::SdCard::SLOT_1) { + sdInfo.prefChar = "1"; + sdInfo.otherChar = "0"; + sdInfo.otherState = sdInfo.currentState.first; + sdInfo.prefState = sdInfo.currentState.second; + sdInfo.other = sd::SdCard::SLOT_0; + } else { + sif::warning << "CoreController::updateSdInfoOther: Invalid SD card passed" << std::endl; + } } -bool CoreController::sdInitFinished() const { - return sdInfo.initFinished; -} +bool CoreController::sdInitFinished() const { return sdInfo.initFinished; } ReturnValue_t CoreController::generateChipStateFile() { - int result = std::system(CHIP_PROT_SCRIPT); - if(result != 0) { - utility::handleSystemError(result, "CoreController::generateChipStateFile"); - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + int result = std::system(CHIP_PROT_SCRIPT); + if (result != 0) { + utility::handleSystemError(result, "CoreController::generateChipStateFile"); + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t CoreController::setBootCopyProtection(Chip targetChip, Copy targetCopy, - bool protect, bool& protOperationPerformed, bool updateProtFile) { - bool allChips = false; - bool allCopies = false; - bool selfChip = false; - bool selfCopy = false; - protOperationPerformed = false; +ReturnValue_t CoreController::setBootCopyProtection(Chip targetChip, Copy targetCopy, bool protect, + bool &protOperationPerformed, + bool updateProtFile) { + bool allChips = false; + bool allCopies = false; + bool selfChip = false; + bool selfCopy = false; + protOperationPerformed = false; - switch(targetChip) { - case(Chip::ALL_CHIP): { - allChips = true; - break; + switch (targetChip) { + case (Chip::ALL_CHIP): { + allChips = true; + break; } - case(Chip::NO_CHIP): { - return HasReturnvaluesIF::RETURN_OK; + case (Chip::NO_CHIP): { + return HasReturnvaluesIF::RETURN_OK; } - case(Chip::SELF_CHIP): { - selfChip = true; - targetChip = CURRENT_CHIP; - break; + case (Chip::SELF_CHIP): { + selfChip = true; + targetChip = CURRENT_CHIP; + break; } default: { - break; + break; } + } + switch (targetCopy) { + case (Copy::ALL_COPY): { + allCopies = true; + break; } - switch(targetCopy) { - case(Copy::ALL_COPY): { - allCopies = true; - break; + case (Copy::NO_COPY): { + return HasReturnvaluesIF::RETURN_OK; } - case(Copy::NO_COPY): { - return HasReturnvaluesIF::RETURN_OK; - } - case(Copy::SELF_COPY): { - selfCopy = true; - targetCopy = CURRENT_COPY; - break; + case (Copy::SELF_COPY): { + selfCopy = true; + targetCopy = CURRENT_COPY; + break; } default: { - break; - } + break; } + } - for(uint8_t arrIdx = 0; arrIdx < protArray.size(); arrIdx++) { - int result = handleBootCopyProtAtIndex(targetChip, targetCopy, protect, - protOperationPerformed, selfChip, selfCopy, allChips, allCopies, arrIdx); - if(result != 0) { - break; - } + for (uint8_t arrIdx = 0; arrIdx < protArray.size(); arrIdx++) { + int result = handleBootCopyProtAtIndex(targetChip, targetCopy, protect, protOperationPerformed, + selfChip, selfCopy, allChips, allCopies, arrIdx); + if (result != 0) { + break; } - if(protOperationPerformed and updateProtFile) { - updateProtInfo(); - } - return HasReturnvaluesIF::RETURN_OK; + } + if (protOperationPerformed and updateProtFile) { + updateProtInfo(); + } + return HasReturnvaluesIF::RETURN_OK; } int CoreController::handleBootCopyProtAtIndex(Chip targetChip, Copy targetCopy, bool protect, - bool &protOperationPerformed, bool selfChip, bool selfCopy, bool allChips, - bool allCopies, uint8_t arrIdx) { - bool currentProt = protArray[arrIdx]; - std::ostringstream oss; - bool performOp = false; - if(protect == currentProt) { - return 0; - } - if(protOperationPerformed) { - if((selfChip and selfCopy) or (not allCopies and not allChips)) { - // No need to continue, only one operation was requested - return 1; - } - } - Chip currentChip; - Copy currentCopy; - oss << "writeprotect "; - if(arrIdx == 0 or arrIdx == 1) { - oss << "0 "; - currentChip = Chip::CHIP_0; - } - else { - oss << "1 "; - currentChip = Chip::CHIP_1; - } - if(arrIdx == 0 or arrIdx == 2) { - oss << "0 "; - currentCopy = Copy::COPY_0; - } - else { - oss << "1 "; - currentCopy = Copy::COPY_1; - } - if(protect) { - oss << "1"; - } - else { - oss << "0"; - } - - int result = 0; - if(allChips and allCopies) { - performOp = true; - } - else if(allChips) { - if((selfCopy and CURRENT_COPY == targetCopy) or - (currentCopy == targetCopy)) { - performOp = true; - } - } - else if(allCopies) { - if((selfChip and CURRENT_COPY == targetCopy) or - (currentChip == targetChip)) { - performOp = true; - } - } - else if(selfChip and (currentChip == targetChip)) { - if(selfCopy) { - if(currentCopy == targetCopy) { - performOp = true; - } - } - else { - performOp = true; - } - - } - else if(selfCopy and (currentCopy == targetCopy)) { - if(selfChip) { - if(currentChip == targetChip) { - performOp = true; - } - } - else { - performOp = true; - } - } - else if((targetChip == currentChip) and (targetCopy == currentCopy)) { - performOp = true; - } - if(result != 0) { - utility::handleSystemError(result, "CoreController::checkAndSetBootCopyProtection"); - } - if(performOp) { - // TODO: Lock operation take a long time. Use command executor? That would require a - // new state machine.. - protOperationPerformed = true; - sif::info << "Executing command: " << oss.str() << std::endl; - result = std::system(oss.str().c_str()); - } + bool &protOperationPerformed, bool selfChip, + bool selfCopy, bool allChips, bool allCopies, + uint8_t arrIdx) { + bool currentProt = protArray[arrIdx]; + std::ostringstream oss; + bool performOp = false; + if (protect == currentProt) { return 0; + } + if (protOperationPerformed) { + if ((selfChip and selfCopy) or (not allCopies and not allChips)) { + // No need to continue, only one operation was requested + return 1; + } + } + Chip currentChip; + Copy currentCopy; + oss << "writeprotect "; + if (arrIdx == 0 or arrIdx == 1) { + oss << "0 "; + currentChip = Chip::CHIP_0; + } else { + oss << "1 "; + currentChip = Chip::CHIP_1; + } + if (arrIdx == 0 or arrIdx == 2) { + oss << "0 "; + currentCopy = Copy::COPY_0; + } else { + oss << "1 "; + currentCopy = Copy::COPY_1; + } + if (protect) { + oss << "1"; + } else { + oss << "0"; + } + + int result = 0; + if (allChips and allCopies) { + performOp = true; + } else if (allChips) { + if ((selfCopy and CURRENT_COPY == targetCopy) or (currentCopy == targetCopy)) { + performOp = true; + } + } else if (allCopies) { + if ((selfChip and CURRENT_COPY == targetCopy) or (currentChip == targetChip)) { + performOp = true; + } + } else if (selfChip and (currentChip == targetChip)) { + if (selfCopy) { + if (currentCopy == targetCopy) { + performOp = true; + } + } else { + performOp = true; + } + + } else if (selfCopy and (currentCopy == targetCopy)) { + if (selfChip) { + if (currentChip == targetChip) { + performOp = true; + } + } else { + performOp = true; + } + } else if ((targetChip == currentChip) and (targetCopy == currentCopy)) { + performOp = true; + } + if (result != 0) { + utility::handleSystemError(result, "CoreController::checkAndSetBootCopyProtection"); + } + if (performOp) { + // TODO: Lock operation take a long time. Use command executor? That would require a + // new state machine.. + protOperationPerformed = true; + sif::info << "Executing command: " << oss.str() << std::endl; + result = std::system(oss.str().c_str()); + } + return 0; } ReturnValue_t CoreController::updateProtInfo(bool regenerateChipStateFile) { - using namespace std; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - if(regenerateChipStateFile) { - result = generateChipStateFile(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::updateProtInfo: Generating chip state file failed" << - std::endl; - return result; - } + using namespace std; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + if (regenerateChipStateFile) { + result = generateChipStateFile(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::updateProtInfo: Generating chip state file failed" + << std::endl; + return result; } - if(not filesystem::exists(CHIP_STATE_FILE)) { - return HasReturnvaluesIF::RETURN_FAILED; + } + if (not filesystem::exists(CHIP_STATE_FILE)) { + return HasReturnvaluesIF::RETURN_FAILED; + } + ifstream chipStateFile(CHIP_STATE_FILE); + if (not chipStateFile.good()) { + return HasReturnvaluesIF::RETURN_FAILED; + } + string nextLine; + uint8_t lineCounter = 0; + string word; + while (getline(chipStateFile, nextLine)) { + ReturnValue_t result = handleProtInfoUpdateLine(nextLine); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::updateProtInfo: Protection info update failed!" << std::endl; + return result; } - ifstream chipStateFile(CHIP_STATE_FILE); - if(not chipStateFile.good()) { - return HasReturnvaluesIF::RETURN_FAILED; + ++lineCounter; + if (lineCounter > 4) { + sif::warning << "CoreController::checkAndProtectBootCopy: " + "Line counter larger than 4" + << std::endl; } - string nextLine; - uint8_t lineCounter = 0; - string word; - while(getline(chipStateFile, nextLine)) { - ReturnValue_t result = handleProtInfoUpdateLine(nextLine); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::updateProtInfo: Protection info update failed!" << - std::endl; - return result; - } - ++lineCounter; - if(lineCounter > 4) { - sif::warning << "CoreController::checkAndProtectBootCopy: " - "Line counter larger than 4" << std::endl; - } - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t CoreController::handleProtInfoUpdateLine(std::string nextLine) { - using namespace std; - string word; - uint8_t wordIdx = 0; - uint8_t arrayIdx = 0; - istringstream iss(nextLine); - Chip currentChip = Chip::CHIP_0; - Copy currentCopy = Copy::COPY_0; - while(iss >> word) { - if(wordIdx == 1) { - currentChip = static_cast(stoi(word)); - } - if(wordIdx == 3) { - currentCopy = static_cast(stoi(word)); - } - - if(wordIdx == 3) { - if(currentChip == Chip::CHIP_0) { - if(currentCopy == Copy::COPY_0) { - arrayIdx = 0; - } - else if(currentCopy == Copy::COPY_1) { - arrayIdx = 1; - } - } - - else if(currentChip == Chip::CHIP_1) { - if(currentCopy == Copy::COPY_0) { - arrayIdx = 2; - } - else if(currentCopy == Copy::COPY_1) { - arrayIdx = 3; - } - } - } - if(wordIdx == 5) { - if(word == "unlocked.") { - protArray[arrayIdx] = false; - } - else { - protArray[arrayIdx] = true; - } - } - wordIdx++; + using namespace std; + string word; + uint8_t wordIdx = 0; + uint8_t arrayIdx = 0; + istringstream iss(nextLine); + Chip currentChip = Chip::CHIP_0; + Copy currentCopy = Copy::COPY_0; + while (iss >> word) { + if (wordIdx == 1) { + currentChip = static_cast(stoi(word)); } - return HasReturnvaluesIF::RETURN_OK; + if (wordIdx == 3) { + currentCopy = static_cast(stoi(word)); + } + + if (wordIdx == 3) { + if (currentChip == Chip::CHIP_0) { + if (currentCopy == Copy::COPY_0) { + arrayIdx = 0; + } else if (currentCopy == Copy::COPY_1) { + arrayIdx = 1; + } + } + + else if (currentChip == Chip::CHIP_1) { + if (currentCopy == Copy::COPY_0) { + arrayIdx = 2; + } else if (currentCopy == Copy::COPY_1) { + arrayIdx = 3; + } + } + } + if (wordIdx == 5) { + if (word == "unlocked.") { + protArray[arrayIdx] = false; + } else { + protArray[arrayIdx] = true; + } + } + wordIdx++; + } + return HasReturnvaluesIF::RETURN_OK; } void CoreController::performWatchdogControlOperation() { - // Only perform each fifth iteration - if(watchdogFifoFd != 0 and opDivider.checkAndIncrement()) { - if(watchdogFifoFd == RETRY_FIFO_OPEN) { - // Open FIFO write only and non-blocking - watchdogFifoFd = open(watchdog::FIFO_NAME.c_str(), O_WRONLY | O_NONBLOCK); - if(watchdogFifoFd < 0) { - if(errno == ENXIO) { - watchdogFifoFd = RETRY_FIFO_OPEN; - // No printout for now, would be spam - return; - } - else { - sif::error << "Opening pipe " << watchdog::FIFO_NAME << - " write-only failed with " << errno << ": " << - strerror(errno) << std::endl; - return; - } - } - sif::info << "Opened " << watchdog::FIFO_NAME << " successfully" << std::endl; - } - else if(watchdogFifoFd > 0) { - // Write to OBSW watchdog FIFO here - const char writeChar = 'a'; - ssize_t writtenBytes = write(watchdogFifoFd, &writeChar, 1); - if(writtenBytes < 0) { - sif::error << "Errors writing to watchdog FIFO, code " << errno << ": " << - strerror(errno) << std::endl; - } + // Only perform each fifth iteration + if (watchdogFifoFd != 0 and opDivider.checkAndIncrement()) { + if (watchdogFifoFd == RETRY_FIFO_OPEN) { + // Open FIFO write only and non-blocking + watchdogFifoFd = open(watchdog::FIFO_NAME.c_str(), O_WRONLY | O_NONBLOCK); + if (watchdogFifoFd < 0) { + if (errno == ENXIO) { + watchdogFifoFd = RETRY_FIFO_OPEN; + // No printout for now, would be spam + return; + } else { + sif::error << "Opening pipe " << watchdog::FIFO_NAME << " write-only failed with " + << errno << ": " << strerror(errno) << std::endl; + return; } + } + sif::info << "Opened " << watchdog::FIFO_NAME << " successfully" << std::endl; + } else if (watchdogFifoFd > 0) { + // Write to OBSW watchdog FIFO here + const char writeChar = 'a'; + ssize_t writtenBytes = write(watchdogFifoFd, &writeChar, 1); + if (writtenBytes < 0) { + sif::error << "Errors writing to watchdog FIFO, code " << errno << ": " << strerror(errno) + << std::endl; + } } - + } } diff --git a/bsp_q7s/core/CoreController.h b/bsp_q7s/core/CoreController.h index 74702441..5365000a 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -2,183 +2,167 @@ #define BSP_Q7S_CORE_CORECONTROLLER_H_ #include -#include "fsfw/controller/ExtendedControllerBase.h" + #include "bsp_q7s/memory/SdCardManager.h" - #include "events/subsystemIdRanges.h" - +#include "fsfw/controller/ExtendedControllerBase.h" class Timer; class SdCardManager; -class CoreController: public ExtendedControllerBase { -public: - enum Chip: uint8_t { - CHIP_0, - CHIP_1, - NO_CHIP, - SELF_CHIP, - ALL_CHIP - }; +class CoreController : public ExtendedControllerBase { + public: + enum Chip : uint8_t { CHIP_0, CHIP_1, NO_CHIP, SELF_CHIP, ALL_CHIP }; - enum Copy: uint8_t { - COPY_0, - COPY_1, - NO_COPY, - SELF_COPY, - ALL_COPY - }; + enum Copy : uint8_t { COPY_0, COPY_1, NO_COPY, SELF_COPY, ALL_COPY }; - static constexpr char CHIP_PROT_SCRIPT[] = "/home/root/scripts/get-chip-prot-status.sh"; - static constexpr char CHIP_STATE_FILE[] = "/tmp/chip_prot_status.txt"; - static constexpr char CURR_COPY_FILE[] = "/tmp/curr_copy.txt"; - static constexpr char VERSION_FILE[] = "/conf/sd_status"; + static constexpr char CHIP_PROT_SCRIPT[] = "/home/root/scripts/get-chip-prot-status.sh"; + static constexpr char CHIP_STATE_FILE[] = "/tmp/chip_prot_status.txt"; + static constexpr char CURR_COPY_FILE[] = "/tmp/curr_copy.txt"; + static constexpr char VERSION_FILE[] = "/conf/sd_status"; - static constexpr ActionId_t LIST_DIRECTORY_INTO_FILE = 0; - static constexpr ActionId_t REBOOT_OBC = 32; - static constexpr ActionId_t MOUNT_OTHER_COPY = 33; + static constexpr ActionId_t LIST_DIRECTORY_INTO_FILE = 0; + static constexpr ActionId_t REBOOT_OBC = 32; + static constexpr ActionId_t MOUNT_OTHER_COPY = 33; + static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CORE; - static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CORE; + static constexpr Event ALLOC_FAILURE = event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM); - static constexpr Event ALLOC_FAILURE = event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM); + CoreController(object_id_t objectId); + virtual ~CoreController(); + ReturnValue_t initialize() override; - CoreController(object_id_t objectId); - virtual~ CoreController(); + ReturnValue_t initializeAfterTaskCreation() override; - ReturnValue_t initialize() override; + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) override; - ReturnValue_t initializeAfterTaskCreation() override; + ReturnValue_t handleCommandMessage(CommandMessage* message) override; + void performControlOperation() override; - ReturnValue_t executeAction(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t *data, size_t size) override; + /** + * Generate a file containing the chip lock/unlock states inside /tmp/chip_prot_status.txt + * @return + */ + static ReturnValue_t generateChipStateFile(); + static ReturnValue_t incrementAllocationFailureCount(); + static void getCurrentBootCopy(Chip& chip, Copy& copy); - ReturnValue_t handleCommandMessage(CommandMessage *message) override; - void performControlOperation() override; + ReturnValue_t updateProtInfo(bool regenerateChipStateFile = true); - /** - * Generate a file containing the chip lock/unlock states inside /tmp/chip_prot_status.txt - * @return - */ - static ReturnValue_t generateChipStateFile(); - static ReturnValue_t incrementAllocationFailureCount(); - static void getCurrentBootCopy(Chip& chip, Copy& copy); + /** + * Checks whether the target chip and copy are write protected and protect set them to a target + * state where applicable. + * @param targetChip + * @param targetCopy + * @param protect Target state + * @param protOperationPerformed [out] Can be used to determine whether any operation + * was performed + * @param updateProtFile Specify whether the protection info file is updated + * @return + */ + ReturnValue_t setBootCopyProtection(Chip targetChip, Copy targetCopy, bool protect, + bool& protOperationPerformed, bool updateProtFile = true); - ReturnValue_t updateProtInfo(bool regenerateChipStateFile = true); + bool sdInitFinished() const; - /** - * Checks whether the target chip and copy are write protected and protect set them to a target - * state where applicable. - * @param targetChip - * @param targetCopy - * @param protect Target state - * @param protOperationPerformed [out] Can be used to determine whether any operation - * was performed - * @param updateProtFile Specify whether the protection info file is updated - * @return - */ - ReturnValue_t setBootCopyProtection(Chip targetChip, Copy targetCopy, - bool protect, bool& protOperationPerformed, bool updateProtFile = true); + private: + static Chip CURRENT_CHIP; + static Copy CURRENT_COPY; - bool sdInitFinished() const; + // Designated value for rechecking FIFO open + static constexpr int RETRY_FIFO_OPEN = -2; + int watchdogFifoFd = 0; -private: - static Chip CURRENT_CHIP; - static Copy CURRENT_COPY; + // States for SD state machine, which is used in non-blocking mode + enum class SdStates { + NONE, + START, + GET_INFO, + SET_STATE_SELF, + MOUNT_SELF, + // Determine operations for other SD card, depending on redundancy configuration + DETERMINE_OTHER, + SET_STATE_OTHER, + // Mount or unmount other + MOUNT_UNMOUNT_OTHER, + // Skip period because the shell command used to generate the info file sometimes is + // missing the last performed operation if executed too early + SKIP_CYCLE_BEFORE_INFO_UPDATE, + UPDATE_INFO, + // SD initialization done + IDLE, + // Used if SD switches or mount commands are issued via telecommand + SET_STATE_FROM_COMMAND, + }; + static constexpr bool BLOCKING_SD_INIT = false; - // Designated value for rechecking FIFO open - static constexpr int RETRY_FIFO_OPEN = -2; - int watchdogFifoFd = 0; + SdCardManager* sdcMan = nullptr; - // States for SD state machine, which is used in non-blocking mode - enum class SdStates { - NONE, - START, - GET_INFO, - SET_STATE_SELF, - MOUNT_SELF, - // Determine operations for other SD card, depending on redundancy configuration - DETERMINE_OTHER, - SET_STATE_OTHER, - // Mount or unmount other - MOUNT_UNMOUNT_OTHER, - // Skip period because the shell command used to generate the info file sometimes is - // missing the last performed operation if executed too early - SKIP_CYCLE_BEFORE_INFO_UPDATE, - UPDATE_INFO, - // SD initialization done - IDLE, - // Used if SD switches or mount commands are issued via telecommand - SET_STATE_FROM_COMMAND, - }; - static constexpr bool BLOCKING_SD_INIT = false; + struct SdInfo { + sd::SdCard pref = sd::SdCard::NONE; + sd::SdState prefState = sd::SdState::OFF; + sd::SdCard other = sd::SdCard::NONE; + sd::SdState otherState = sd::SdState::OFF; + std::string prefChar = "0"; + std::string otherChar = "1"; + SdStates state = SdStates::START; + // Used to track whether a command was executed + bool commandExecuted = true; + bool initFinished = false; + SdCardManager::SdStatePair currentState; + uint16_t cycleCount = 0; + // These two flags are related to external commanding + bool commandIssued = false; + bool commandFinished = false; + sd::SdState currentlyCommandedState = sd::SdState::OFF; + sd::SdCard commandedCard = sd::SdCard::NONE; + sd::SdState commandedState = sd::SdState::OFF; + }; + SdInfo sdInfo; - SdCardManager* sdcMan = nullptr; + /** + * Index 0: Chip 0 Copy 0 + * Index 1: Chip 0 Copy 1 + * Index 2: Chip 1 Copy 0 + * Index 3: Chip 1 Copy 1 + */ + std::array protArray; + PeriodicOperationDivider opDivider; - struct SdInfo { - sd::SdCard pref = sd::SdCard::NONE; - sd::SdState prefState = sd::SdState::OFF; - sd::SdCard other = sd::SdCard::NONE; - sd::SdState otherState = sd::SdState::OFF; - std::string prefChar = "0"; - std::string otherChar = "1"; - SdStates state = SdStates::START; - // Used to track whether a command was executed - bool commandExecuted = true; - bool initFinished = false; - SdCardManager::SdStatePair currentState; - uint16_t cycleCount = 0; - // These two flags are related to external commanding - bool commandIssued = false; - bool commandFinished = false; - sd::SdState currentlyCommandedState = sd::SdState::OFF; - sd::SdCard commandedCard = sd::SdCard::NONE; - sd::SdState commandedState = sd::SdState::OFF; - }; - SdInfo sdInfo; + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; + LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t* msToReachTheMode); - /** - * Index 0: Chip 0 Copy 0 - * Index 1: Chip 0 Copy 1 - * Index 2: Chip 1 Copy 0 - * Index 3: Chip 1 Copy 1 - */ - std::array protArray; - PeriodicOperationDivider opDivider; + ReturnValue_t initVersionFile(); + ReturnValue_t initBootCopy(); + ReturnValue_t initWatchdogFifo(); + ReturnValue_t initSdCardBlocking(); + void initPrint(); - ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; - LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; - ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, - uint32_t *msToReachTheMode); + ReturnValue_t sdStateMachine(); + void updateSdInfoOther(); + ReturnValue_t sdCardSetup(sd::SdCard sdCard, sd::SdState targetState, std::string sdChar, + bool printOutput = true); + ReturnValue_t sdColdRedundantBlockingInit(); + void currentStateSetter(sd::SdCard sdCard, sd::SdState newState); + void determinePreferredSdCard(); + void executeNextExternalSdCommand(); + void checkExternalSdCommandStatus(); - ReturnValue_t initVersionFile(); - ReturnValue_t initBootCopy(); - ReturnValue_t initWatchdogFifo(); - ReturnValue_t initSdCardBlocking(); - void initPrint(); + ReturnValue_t actionListDirectoryIntoFile(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size); + ReturnValue_t actionPerformReboot(const uint8_t* data, size_t size); - ReturnValue_t sdStateMachine(); - void updateSdInfoOther(); - ReturnValue_t sdCardSetup(sd::SdCard sdCard, sd::SdState targetState, std::string sdChar, - bool printOutput = true); - ReturnValue_t sdColdRedundantBlockingInit(); - void currentStateSetter(sd::SdCard sdCard, sd::SdState newState); - void determinePreferredSdCard(); - void executeNextExternalSdCommand(); - void checkExternalSdCommandStatus(); + void performWatchdogControlOperation(); - ReturnValue_t actionListDirectoryIntoFile(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t *data, size_t size); - ReturnValue_t actionPerformReboot(const uint8_t *data, size_t size); - - void performWatchdogControlOperation(); - - ReturnValue_t handleProtInfoUpdateLine(std::string nextLine); - int handleBootCopyProtAtIndex(Chip targetChip, Copy targetCopy, bool protect, - bool &protOperationPerformed, bool selfChip, bool selfCopy, bool allChips, - bool allCopies, uint8_t arrIdx); + ReturnValue_t handleProtInfoUpdateLine(std::string nextLine); + int handleBootCopyProtAtIndex(Chip targetChip, Copy targetCopy, bool protect, + bool& protOperationPerformed, bool selfChip, bool selfCopy, + bool allChips, bool allCopies, uint8_t arrIdx); }; #endif /* BSP_Q7S_CORE_CORECONTROLLER_H_ */ diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index df857d59..dce7f27e 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -1,22 +1,21 @@ #include "InitMission.h" -#include "ObjectFactory.h" -#include "OBSWConfig.h" -#include "pollingsequence/pollingSequenceFactory.h" - -#include "mission/utility/InitMission.h" - -#include "fsfw/platform.h" -#include "fsfw/objectmanager/ObjectManagerIF.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" -#include "fsfw/serviceinterface/ServiceInterfaceStream.h" -#include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/tasks/FixedTimeslotTaskIF.h" -#include "fsfw/tasks/PeriodicTaskIF.h" -#include "fsfw/tasks/TaskFactory.h" #include #include +#include "OBSWConfig.h" +#include "ObjectFactory.h" +#include "fsfw/objectmanager/ObjectManager.h" +#include "fsfw/objectmanager/ObjectManagerIF.h" +#include "fsfw/platform.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/serviceinterface/ServiceInterfaceStream.h" +#include "fsfw/tasks/FixedTimeslotTaskIF.h" +#include "fsfw/tasks/PeriodicTaskIF.h" +#include "fsfw/tasks/TaskFactory.h" +#include "mission/utility/InitMission.h" +#include "pollingsequence/pollingSequenceFactory.h" + /* This is configured for linux without CR */ #ifdef PLATFORM_UNIX ServiceInterfaceStream sif::debug("DEBUG"); @@ -30,344 +29,343 @@ ServiceInterfaceStream sif::warning("WARNING", true); ServiceInterfaceStream sif::error("ERROR", true, false, true); #endif -ObjectManagerIF *objectManager = nullptr; +ObjectManagerIF* objectManager = nullptr; void initmission::initMission() { + sif::info << "Building global objects.." << std::endl; + /* Instantiate global object manager and also create all objects */ + ObjectManager::instance()->setObjectFactoryFunction(ObjectFactory::produce, nullptr); + sif::info << "Initializing all objects.." << std::endl; + ObjectManager::instance()->initialize(); - sif::info << "Building global objects.." << std::endl; - /* Instantiate global object manager and also create all objects */ - ObjectManager::instance()->setObjectFactoryFunction(ObjectFactory::produce, nullptr); - sif::info << "Initializing all objects.." << std::endl; - ObjectManager::instance()->initialize(); - - /* This function creates and starts all tasks */ - initTasks(); + /* This function creates and starts all tasks */ + initTasks(); } void initmission::initTasks() { - TaskFactory* factory = TaskFactory::instance(); - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - if(factory == nullptr) { - /* Should never happen ! */ - return; - } + TaskFactory* factory = TaskFactory::instance(); + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + if (factory == nullptr) { + /* Should never happen ! */ + return; + } #if OBSW_PRINT_MISSED_DEADLINES == 1 - void (*missedDeadlineFunc) (void) = TaskFactory::printMissedDeadline; + void (*missedDeadlineFunc)(void) = TaskFactory::printMissedDeadline; #else - void (*missedDeadlineFunc) (void) = nullptr; + void (*missedDeadlineFunc)(void) = nullptr; #endif #if BOARD_TE0720 == 0 - PeriodicTaskIF* coreController = factory->createPeriodicTask( - "CORE_CTRL", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc); - result = coreController->addComponent(objects::CORE_CONTROLLER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("CORE_CTRL", objects::CORE_CONTROLLER); - } + PeriodicTaskIF* coreController = factory->createPeriodicTask( + "CORE_CTRL", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc); + result = coreController->addComponent(objects::CORE_CONTROLLER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("CORE_CTRL", objects::CORE_CONTROLLER); + } #endif - /* TMTC Distribution */ - PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask( - "DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - result = tmTcDistributor->addComponent(objects::CCSDS_PACKET_DISTRIBUTOR); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("CCSDS_DISTRIB", objects::CCSDS_PACKET_DISTRIBUTOR); - } - result = tmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_PACKET_DISTRIB", objects::PUS_PACKET_DISTRIBUTOR); - } - result = tmTcDistributor->addComponent(objects::TM_FUNNEL); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("TM_FUNNEL", objects::TM_FUNNEL); - } + /* TMTC Distribution */ + PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask( + "DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + result = tmTcDistributor->addComponent(objects::CCSDS_PACKET_DISTRIBUTOR); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("CCSDS_DISTRIB", objects::CCSDS_PACKET_DISTRIBUTOR); + } + result = tmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_PACKET_DISTRIB", objects::PUS_PACKET_DISTRIBUTOR); + } + result = tmTcDistributor->addComponent(objects::TM_FUNNEL); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("TM_FUNNEL", objects::TM_FUNNEL); + } #if OBSW_ADD_TCPIP_BRIDGE == 1 - // TMTC bridge - PeriodicTaskIF* tmtcBridgeTask = factory->createPeriodicTask( - "TCPIP_TMTC_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - result = tmtcBridgeTask->addComponent(objects::TMTC_BRIDGE); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("UDP_BRIDGE", objects::TMTC_BRIDGE); - } - PeriodicTaskIF* tmtcPollingTask = factory->createPeriodicTask( - "TMTC_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); - result = tmtcPollingTask->addComponent(objects::TMTC_POLLING_TASK); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("UDP_POLLING", objects::TMTC_POLLING_TASK); - } + // TMTC bridge + PeriodicTaskIF* tmtcBridgeTask = factory->createPeriodicTask( + "TCPIP_TMTC_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + result = tmtcBridgeTask->addComponent(objects::TMTC_BRIDGE); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("UDP_BRIDGE", objects::TMTC_BRIDGE); + } + PeriodicTaskIF* tmtcPollingTask = factory->createPeriodicTask( + "TMTC_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = tmtcPollingTask->addComponent(objects::TMTC_POLLING_TASK); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("UDP_POLLING", objects::TMTC_POLLING_TASK); + } #endif #if OBSW_USE_CCSDS_IP_CORE == 1 - PeriodicTaskIF* ccsdsHandlerTask = factory->createPeriodicTask( - "CCSDS_HANDLER", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); - result = ccsdsHandlerTask->addComponent(objects::CCSDS_HANDLER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("CCSDS Handler", objects::CCSDS_HANDLER); - } + PeriodicTaskIF* ccsdsHandlerTask = factory->createPeriodicTask( + "CCSDS_HANDLER", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = ccsdsHandlerTask->addComponent(objects::CCSDS_HANDLER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("CCSDS Handler", objects::CCSDS_HANDLER); + } - // Minimal distance between two received TCs amounts to 0.6 seconds - // If a command has not been read before the next one arrives, the old command will be - // overwritten by the PDEC. - PeriodicTaskIF* pdecHandlerTask = factory->createPeriodicTask( - "PDEC_HANDLER", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc); - result = pdecHandlerTask->addComponent(objects::PDEC_HANDLER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PDEC Handler", objects::PDEC_HANDLER); - } + // Minimal distance between two received TCs amounts to 0.6 seconds + // If a command has not been read before the next one arrives, the old command will be + // overwritten by the PDEC. + PeriodicTaskIF* pdecHandlerTask = factory->createPeriodicTask( + "PDEC_HANDLER", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc); + result = pdecHandlerTask->addComponent(objects::PDEC_HANDLER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PDEC Handler", objects::PDEC_HANDLER); + } #endif /* OBSW_USE_CCSDS_IP_CORE == 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); - } + 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); + } -# if BOARD_TE0720 == 0 - // FS task, task interval does not matter because it runs in permanent loop, priority low - // because it is a non-essential background task - PeriodicTaskIF* fsTask = factory->createPeriodicTask( - "FILE_SYSTEM_TASK", 25, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc); - result = fsTask->addComponent(objects::FILE_SYSTEM_HANDLER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("FILE_SYSTEM_TASK", objects::FILE_SYSTEM_HANDLER); - } +#if BOARD_TE0720 == 0 + // FS task, task interval does not matter because it runs in permanent loop, priority low + // because it is a non-essential background task + PeriodicTaskIF* fsTask = factory->createPeriodicTask( + "FILE_SYSTEM_TASK", 25, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc); + result = fsTask->addComponent(objects::FILE_SYSTEM_HANDLER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("FILE_SYSTEM_TASK", objects::FILE_SYSTEM_HANDLER); + } #if OBSW_ADD_STAR_TRACKER == 1 - PeriodicTaskIF* strImgLoaderTask = factory->createPeriodicTask( - "FILE_SYSTEM_TASK", 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); - } + PeriodicTaskIF* strImgLoaderTask = factory->createPeriodicTask( + "FILE_SYSTEM_TASK", 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); + } #endif /* OBSW_ADD_STAR_TRACKER == 1 */ #endif /* BOARD_TE0720 */ #if OBSW_TEST_CCSDS_BRIDGE == 1 - PeriodicTaskIF* ptmeTestTask = factory->createPeriodicTask( - "PTME_TEST", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); - result = ptmeTestTask->addComponent(objects::CCSDS_IP_CORE_BRIDGE); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PTME_TEST", objects::CCSDS_IP_CORE_BRIDGE); - } + PeriodicTaskIF* ptmeTestTask = factory->createPeriodicTask( + "PTME_TEST", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = ptmeTestTask->addComponent(objects::CCSDS_IP_CORE_BRIDGE); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PTME_TEST", objects::CCSDS_IP_CORE_BRIDGE); + } #endif - std::vector pusTasks; - createPusTasks(*factory, missedDeadlineFunc, pusTasks); - std::vector pstTasks; - createPstTasks(*factory, missedDeadlineFunc, pstTasks); + std::vector pusTasks; + createPusTasks(*factory, missedDeadlineFunc, pusTasks); + std::vector pstTasks; + createPstTasks(*factory, missedDeadlineFunc, pstTasks); #if OBSW_ADD_TEST_CODE == 1 - std::vector testTasks; - createTestTasks(*factory, missedDeadlineFunc, testTasks); + std::vector testTasks; + createTestTasks(*factory, missedDeadlineFunc, testTasks); #endif - auto taskStarter = [](std::vector& taskVector, std::string name) { - for(const auto& task: taskVector) { - if(task != nullptr) { - task->startTask(); - } - else { - sif::error << "Task in vector " << name << " is invalid!" << std::endl; - } - } - }; + auto taskStarter = [](std::vector& taskVector, std::string name) { + for (const auto& task : taskVector) { + if (task != nullptr) { + task->startTask(); + } else { + sif::error << "Task in vector " << name << " is invalid!" << std::endl; + } + } + }; - sif::info << "Starting tasks.." << std::endl; - tmTcDistributor->startTask(); + sif::info << "Starting tasks.." << std::endl; + tmTcDistributor->startTask(); #if OBSW_ADD_TCPIP_BRIDGE == 1 - tmtcBridgeTask->startTask(); - tmtcPollingTask->startTask(); + tmtcBridgeTask->startTask(); + tmtcPollingTask->startTask(); #endif #if OBSW_USE_CCSDS_IP_CORE == 1 - ccsdsHandlerTask->startTask(); - pdecHandlerTask->startTask(); + ccsdsHandlerTask->startTask(); + pdecHandlerTask->startTask(); #endif /* OBSW_USE_CCSDS_IP_CORE == 1 */ #if BOARD_TE0720 == 0 - coreController->startTask(); + coreController->startTask(); #endif - taskStarter(pstTasks, "PST task vector"); - taskStarter(pusTasks, "PUS task vector"); + taskStarter(pstTasks, "PST task vector"); + taskStarter(pusTasks, "PUS task vector"); #if OBSW_ADD_TEST_CODE == 1 - taskStarter(testTasks, "Test task vector"); + taskStarter(testTasks, "Test task vector"); #endif #if OBSW_TEST_CCSDS_BRIDGE == 1 - ptmeTestTask->startTask(); + ptmeTestTask->startTask(); #endif #if BOARD_TE0720 == 0 - fsTask->startTask(); + fsTask->startTask(); #if OBSW_ADD_STAR_TRACKER == 1 - strImgLoaderTask->startTask(); + strImgLoaderTask->startTask(); #endif /* OBSW_ADD_STAR_TRACKER == 1 */ #endif - acsCtrl->startTask(); + acsCtrl->startTask(); - sif::info << "Tasks started.." << std::endl; + sif::info << "Tasks started.." << std::endl; } void initmission::createPstTasks(TaskFactory& factory, - TaskDeadlineMissedFunction missedDeadlineFunc, std::vector &taskVec) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; #if BOARD_TE0720 == 0 - /* Polling Sequence Table Default */ + /* Polling Sequence Table Default */ #if OBSW_ADD_SPI_TEST_CODE == 0 - FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask( - "PST_TASK_DEFAULT", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.5, - missedDeadlineFunc); - result = pst::pstSpi(spiPst); - if (result != HasReturnvaluesIF::RETURN_OK) { - if(result != FixedTimeslotTaskIF::SLOT_LIST_EMPTY) { - sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; - } - } - else { - taskVec.push_back(spiPst); + FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask( + "PST_TASK_DEFAULT", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.5, missedDeadlineFunc); + result = pst::pstSpi(spiPst); + if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != FixedTimeslotTaskIF::SLOT_LIST_EMPTY) { + sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; } + } else { + taskVec.push_back(spiPst); + } #endif - FixedTimeslotTaskIF* uartPst = factory.createFixedTimeslotTask( - "UART_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc); - result = pst::pstUart(uartPst); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; - } - taskVec.push_back(uartPst); - FixedTimeslotTaskIF* gpioPst = factory.createFixedTimeslotTask( - "GPIO_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc); - result = pst::pstGpio(gpioPst); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; - } - taskVec.push_back(gpioPst); - FixedTimeslotTaskIF* i2cPst = factory.createFixedTimeslotTask( - "I2C_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc); - result = pst::pstI2c(i2cPst); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; - } + FixedTimeslotTaskIF* uartPst = factory.createFixedTimeslotTask( + "UART_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc); + result = pst::pstUart(uartPst); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; + } + taskVec.push_back(uartPst); + FixedTimeslotTaskIF* gpioPst = factory.createFixedTimeslotTask( + "GPIO_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc); + result = pst::pstGpio(gpioPst); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; + } + taskVec.push_back(gpioPst); + FixedTimeslotTaskIF* i2cPst = factory.createFixedTimeslotTask( + "I2C_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc); + result = pst::pstI2c(i2cPst); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; + } - FixedTimeslotTaskIF* gomSpacePstTask = factory.createFixedTimeslotTask( - "GS_PST_TASK", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 1.0, missedDeadlineFunc); - result = pst::pstGompaceCan(gomSpacePstTask); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "InitMission::initTasks: GomSpace PST initialization failed!" << std::endl; - } - taskVec.push_back(gomSpacePstTask); -#else /* BOARD_TE7020 == 0 */ - FixedTimeslotTaskIF * pollingSequenceTaskTE0720 = factory.createFixedTimeslotTask( - "PST_TASK_TE0720", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE * 8, 3.0, - missedDeadlineFunc); - result = pst::pollingSequenceTE0720(pollingSequenceTaskTE0720); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "InitMission::initTasks: Creating TE0720 PST failed!" << std::endl; - } - taskVec.push_back(pollingSequenceTaskTE0720); + FixedTimeslotTaskIF* gomSpacePstTask = factory.createFixedTimeslotTask( + "GS_PST_TASK", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 1.0, missedDeadlineFunc); + result = pst::pstGompaceCan(gomSpacePstTask); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "InitMission::initTasks: GomSpace PST initialization failed!" << std::endl; + } + taskVec.push_back(gomSpacePstTask); +#else /* BOARD_TE7020 == 0 */ + FixedTimeslotTaskIF* pollingSequenceTaskTE0720 = factory.createFixedTimeslotTask( + "PST_TASK_TE0720", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE * 8, 3.0, missedDeadlineFunc); + result = pst::pollingSequenceTE0720(pollingSequenceTaskTE0720); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "InitMission::initTasks: Creating TE0720 PST failed!" << std::endl; + } + taskVec.push_back(pollingSequenceTaskTE0720); #endif /* BOARD_TE7020 == 1 */ } -void initmission::createPusTasks(TaskFactory &factory, - TaskDeadlineMissedFunction missedDeadlineFunc, std::vector &taskVec) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - /* PUS Services */ - PeriodicTaskIF* pusVerification = factory.createPeriodicTask( - "PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_VERIF", objects::PUS_SERVICE_1_VERIFICATION); - } - taskVec.push_back(pusVerification); +void initmission::createPusTasks(TaskFactory& factory, + TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + /* PUS Services */ + PeriodicTaskIF* pusVerification = factory.createPeriodicTask( + "PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_VERIF", objects::PUS_SERVICE_1_VERIFICATION); + } + taskVec.push_back(pusVerification); - PeriodicTaskIF* pusEvents = factory.createPeriodicTask( - "PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusEvents->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_EVENTS", objects::PUS_SERVICE_5_EVENT_REPORTING); - } - result = pusEvents->addComponent(objects::EVENT_MANAGER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_MGMT", objects::EVENT_MANAGER); - } - taskVec.push_back(pusEvents); + PeriodicTaskIF* pusEvents = factory.createPeriodicTask( + "PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusEvents->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_EVENTS", objects::PUS_SERVICE_5_EVENT_REPORTING); + } + result = pusEvents->addComponent(objects::EVENT_MANAGER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_MGMT", objects::EVENT_MANAGER); + } + taskVec.push_back(pusEvents); - PeriodicTaskIF* pusHighPrio = factory.createPeriodicTask( - "PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_2", objects::PUS_SERVICE_2_DEVICE_ACCESS); - } - result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_9", objects::PUS_SERVICE_9_TIME_MGMT); - } - taskVec.push_back(pusHighPrio); + PeriodicTaskIF* pusHighPrio = factory.createPeriodicTask( + "PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_2", objects::PUS_SERVICE_2_DEVICE_ACCESS); + } + result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_9", objects::PUS_SERVICE_9_TIME_MGMT); + } + taskVec.push_back(pusHighPrio); - PeriodicTaskIF* pusMedPrio = factory.createPeriodicTask( - "PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); - result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_8", objects::PUS_SERVICE_8_FUNCTION_MGMT); - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_3_HOUSEKEEPING); - if(result!=HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_200", objects::PUS_SERVICE_200_MODE_MGMT); - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_20", objects::PUS_SERVICE_20_PARAMETERS); - } - taskVec.push_back(pusMedPrio); + PeriodicTaskIF* pusMedPrio = factory.createPeriodicTask( + "PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); + result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_8", objects::PUS_SERVICE_8_FUNCTION_MGMT); + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_3_HOUSEKEEPING); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_200", objects::PUS_SERVICE_200_MODE_MGMT); + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_20", objects::PUS_SERVICE_20_PARAMETERS); + } + taskVec.push_back(pusMedPrio); - PeriodicTaskIF* pusLowPrio = factory.createPeriodicTask( - "PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc); - result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_17", objects::PUS_SERVICE_17_TEST); - } - result = pusLowPrio->addComponent(objects::INTERNAL_ERROR_REPORTER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("ERROR_REPORTER", objects::INTERNAL_ERROR_REPORTER); - } - taskVec.push_back(pusLowPrio); + PeriodicTaskIF* pusLowPrio = factory.createPeriodicTask( + "PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc); + result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_17", objects::PUS_SERVICE_17_TEST); + } + result = pusLowPrio->addComponent(objects::INTERNAL_ERROR_REPORTER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("ERROR_REPORTER", objects::INTERNAL_ERROR_REPORTER); + } + taskVec.push_back(pusLowPrio); } -void initmission::createTestTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector& taskVec) { -#if OBSW_ADD_TEST_TASK == 1 || OBSW_ADD_SPI_TEST_CODE == 1 || (BOARD_TE0720 == 1 && OBSW_TEST_LIBGPIOD == 1) - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; +void initmission::createTestTasks(TaskFactory& factory, + TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec) { +#if OBSW_ADD_TEST_TASK == 1 || OBSW_ADD_SPI_TEST_CODE == 1 || \ + (BOARD_TE0720 == 1 && OBSW_TEST_LIBGPIOD == 1) + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; #endif - PeriodicTaskIF* testTask = factory.createPeriodicTask( - "TEST_TASK", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1, missedDeadlineFunc); + PeriodicTaskIF* testTask = factory.createPeriodicTask( + "TEST_TASK", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1, missedDeadlineFunc); #if OBSW_ADD_TEST_TASK == 1 - result = testTask->addComponent(objects::TEST_TASK); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK); - } + result = testTask->addComponent(objects::TEST_TASK); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK); + } #endif /* OBSW_ADD_TEST_TASK == 1 */ #if OBSW_ADD_SPI_TEST_CODE == 1 - result = testTask->addComponent(objects::SPI_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("SPI_TEST", objects::SPI_TEST); - } + result = testTask->addComponent(objects::SPI_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("SPI_TEST", objects::SPI_TEST); + } #endif #if BOARD_TE0720 == 1 && OBSW_TEST_LIBGPIOD == 1 - result = testTask->addComponent(objects::LIBGPIOD_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("GPIOD_TEST", objects::LIBGPIOD_TEST); - } + result = testTask->addComponent(objects::LIBGPIOD_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("GPIOD_TEST", objects::LIBGPIOD_TEST); + } #endif /* BOARD_TE0720 == 1 && OBSW_TEST_LIBGPIOD == 1 */ - taskVec.push_back(testTask); + taskVec.push_back(testTask); } diff --git a/bsp_q7s/core/InitMission.h b/bsp_q7s/core/InitMission.h index ffdfc11c..5c509b79 100644 --- a/bsp_q7s/core/InitMission.h +++ b/bsp_q7s/core/InitMission.h @@ -1,9 +1,10 @@ #ifndef BSP_Q7S_INITMISSION_H_ #define BSP_Q7S_INITMISSION_H_ -#include "fsfw/tasks/Typedef.h" #include +#include "fsfw/tasks/Typedef.h" + class PeriodicTaskIF; class TaskFactory; @@ -12,11 +13,11 @@ void initMission(); void initTasks(); void createPstTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector& taskVec); + std::vector& taskVec); void createPusTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector& taskVec); + std::vector& taskVec); void createTestTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector& taskVec); -}; + std::vector& taskVec); +}; // namespace initmission #endif /* BSP_Q7S_INITMISSION_H_ */ diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 7b111c4f..4c57ab34 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -1,87 +1,82 @@ -#include #include "ObjectFactory.h" -#include "bsp_q7s/devices/startracker/StrHelper.h" -#include "bsp_q7s/devices/startracker/StarTrackerDefinitions.h" +#include + #include "OBSWConfig.h" -#include "devConf.h" -#include "ccsdsConfig.h" -#include "busConf.h" -#include "tmtc/apid.h" -#include "devices/addresses.h" -#include "devices/gpioIds.h" -#include "tmtc/pusIds.h" -#include "devices/powerSwitcherList.h" -#include "bsp_q7s/gpio/gpioCallbacks.h" -#include "bsp_q7s/core/CoreController.h" #include "bsp_q7s/boardtest/Q7STestTask.h" -#include "bsp_q7s/memory/FileSystemHandler.h" +#include "bsp_q7s/callbacks/gnssCallback.h" +#include "bsp_q7s/callbacks/rwSpiCallback.h" +#include "bsp_q7s/core/CoreController.h" +#include "bsp_q7s/devices/PlocMemoryDumper.h" #include "bsp_q7s/devices/PlocSupervisorHandler.h" #include "bsp_q7s/devices/PlocUpdater.h" -#include "bsp_q7s/devices/PlocMemoryDumper.h" +#include "bsp_q7s/devices/startracker/StarTrackerDefinitions.h" #include "bsp_q7s/devices/startracker/StarTrackerHandler.h" -#include "bsp_q7s/callbacks/rwSpiCallback.h" -#include "bsp_q7s/callbacks/gnssCallback.h" - -#include "linux/devices/SolarArrayDeploymentHandler.h" -#include "linux/devices/devicedefinitions/SusDefinitions.h" -#include "linux/devices/SusHandler.h" -#include "linux/csp/CspCookie.h" +#include "bsp_q7s/devices/startracker/StrHelper.h" +#include "bsp_q7s/gpio/gpioCallbacks.h" +#include "bsp_q7s/memory/FileSystemHandler.h" +#include "busConf.h" +#include "ccsdsConfig.h" +#include "devConf.h" +#include "devices/addresses.h" +#include "devices/gpioIds.h" +#include "devices/powerSwitcherList.h" +#include "fsfw/datapoollocal/LocalDataPoolManager.h" +#include "fsfw/tmtcpacket/pus/tm.h" +#include "fsfw/tmtcservices/CommandingServiceBase.h" +#include "fsfw/tmtcservices/PusServiceBase.h" +#include "fsfw_hal/common/gpio/GpioCookie.h" +#include "fsfw_hal/devicehandlers/GyroL3GD20Handler.h" +#include "fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h" +#include "fsfw_hal/devicehandlers/MgmRM3100Handler.h" +#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" +#include "fsfw_hal/linux/i2c/I2cComIF.h" +#include "fsfw_hal/linux/i2c/I2cCookie.h" +#include "fsfw_hal/linux/spi/SpiComIF.h" +#include "fsfw_hal/linux/spi/SpiCookie.h" +#include "fsfw_hal/linux/uart/UartComIF.h" +#include "fsfw_hal/linux/uart/UartCookie.h" +#include "linux/boardtest/SpiTestClass.h" #include "linux/csp/CspComIF.h" - -#include "mission/devices/HeaterHandler.h" +#include "linux/csp/CspCookie.h" +#include "linux/devices/SolarArrayDeploymentHandler.h" +#include "linux/devices/SusHandler.h" +#include "linux/devices/devicedefinitions/SusDefinitions.h" #include "mission/core/GenericFactory.h" +#include "mission/devices/ACUHandler.h" +#include "mission/devices/GPSHyperionHandler.h" +#include "mission/devices/GyroADIS1650XHandler.h" +#include "mission/devices/HeaterHandler.h" +#include "mission/devices/IMTQHandler.h" +#include "mission/devices/Max31865PT1000Handler.h" +#include "mission/devices/P60DockHandler.h" +#include "mission/devices/PCDUHandler.h" #include "mission/devices/PDU1Handler.h" #include "mission/devices/PDU2Handler.h" -#include "mission/devices/ACUHandler.h" -#include "mission/devices/PCDUHandler.h" -#include "mission/devices/P60DockHandler.h" -#include "mission/devices/Tmp1075Handler.h" -#include "mission/devices/Max31865PT1000Handler.h" -#include "mission/devices/GyroADIS1650XHandler.h" -#include "mission/devices/IMTQHandler.h" -#include "mission/devices/SyrlinksHkHandler.h" #include "mission/devices/PlocMPSoCHandler.h" #include "mission/devices/RadiationSensorHandler.h" #include "mission/devices/RwHandler.h" +#include "mission/devices/SyrlinksHkHandler.h" +#include "mission/devices/Tmp1075Handler.h" #include "mission/devices/devicedefinitions/GomspaceDefinitions.h" -#include "mission/devices/devicedefinitions/SyrlinksDefinitions.h" +#include "mission/devices/devicedefinitions/Max31865Definitions.h" #include "mission/devices/devicedefinitions/PlocMPSoCDefinitions.h" #include "mission/devices/devicedefinitions/RadSensorDefinitions.h" -#include "mission/devices/devicedefinitions/Max31865Definitions.h" #include "mission/devices/devicedefinitions/RwDefinitions.h" - -#include "mission/devices/GPSHyperionHandler.h" +#include "mission/devices/devicedefinitions/SyrlinksDefinitions.h" #include "mission/tmtc/CCSDSHandler.h" #include "mission/tmtc/VirtualChannel.h" #include "mission/utility/TmFunnel.h" - -#include "fsfw_hal/linux/uart/UartComIF.h" -#include "fsfw_hal/linux/uart/UartCookie.h" -#include "fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h" -#include "fsfw_hal/devicehandlers/GyroL3GD20Handler.h" -#include "fsfw_hal/devicehandlers/MgmRM3100Handler.h" -#include "fsfw_hal/linux/i2c/I2cCookie.h" -#include "fsfw_hal/linux/i2c/I2cComIF.h" -#include "fsfw_hal/linux/spi/SpiCookie.h" -#include "fsfw_hal/linux/spi/SpiComIF.h" -#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" -#include "fsfw_hal/common/gpio/GpioCookie.h" - -#include "fsfw/datapoollocal/LocalDataPoolManager.h" -#include "fsfw/tmtcservices/CommandingServiceBase.h" -#include "fsfw/tmtcservices/PusServiceBase.h" -#include "fsfw/tmtcpacket/pus/tm.h" - -#include "linux/boardtest/SpiTestClass.h" +#include "tmtc/apid.h" +#include "tmtc/pusIds.h" #if OBSW_TEST_LIBGPIOD == 1 #include "linux/boardtest/LibgpiodTest.h" #endif -#include -#include #include +#include +#include #include #include #include @@ -89,1015 +84,1015 @@ ResetArgs resetArgsGnss0; ResetArgs resetArgsGnss1; -void ObjectFactory::setStatics() { - Factory::setStaticFrameworkObjectIds(); -} +void ObjectFactory::setStatics() { Factory::setStaticFrameworkObjectIds(); } void Factory::setStaticFrameworkObjectIds() { - PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; - PusServiceBase::packetDestination = objects::TM_FUNNEL; + PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; + PusServiceBase::packetDestination = objects::TM_FUNNEL; - CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; - CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; + CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; + CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; - //DeviceHandlerBase::powerSwitcherId = objects::PCDU_HANDLER; - DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT; + // DeviceHandlerBase::powerSwitcherId = objects::PCDU_HANDLER; + DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT; #if OBSW_TM_TO_PTME == 1 - TmFunnel::downlinkDestination = objects::CCSDS_HANDLER; + TmFunnel::downlinkDestination = objects::CCSDS_HANDLER; #else - TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; + TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; #endif /* OBSW_TM_TO_PTME == 1 */ - // No storage object for now. - TmFunnel::storageDestination = objects::NO_OBJECT; + // No storage object for now. + TmFunnel::storageDestination = objects::NO_OBJECT; - LocalDataPoolManager::defaultHkDestination = objects::PUS_SERVICE_3_HOUSEKEEPING; + LocalDataPoolManager::defaultHkDestination = objects::PUS_SERVICE_3_HOUSEKEEPING; - VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; - TmPacketBase::timeStamperId = objects::TIME_STAMPER; + VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; + TmPacketBase::timeStamperId = objects::TIME_STAMPER; } void ObjectFactory::produce(void* args) { - ObjectFactory::setStatics(); - ObjectFactory::produceGenericObjects(); + ObjectFactory::setStatics(); + ObjectFactory::produceGenericObjects(); - LinuxLibgpioIF* gpioComIF = nullptr; - UartComIF* uartComIF = nullptr; - SpiComIF* spiComIF = nullptr; - createCommunicationInterfaces(&gpioComIF, &uartComIF, &spiComIF); - createTmpComponents(); + LinuxLibgpioIF* gpioComIF = nullptr; + UartComIF* uartComIF = nullptr; + SpiComIF* spiComIF = nullptr; + createCommunicationInterfaces(&gpioComIF, &uartComIF, &spiComIF); + createTmpComponents(); #if BOARD_TE0720 == 0 - new CoreController(objects::CORE_CONTROLLER); + new CoreController(objects::CORE_CONTROLLER); - createPcduComponents(); - createRadSensorComponent(gpioComIF); - createSunSensorComponents(gpioComIF, spiComIF); + createPcduComponents(); + createRadSensorComponent(gpioComIF); + createSunSensorComponents(gpioComIF, spiComIF); #if OBSW_ADD_ACS_BOARD == 1 - createAcsBoardComponents(gpioComIF, uartComIF); + createAcsBoardComponents(gpioComIF, uartComIF); #endif /* OBSW_ADD_ACS_BOARD == 1 */ - createHeaterComponents(); - createSolarArrayDeploymentComponents(); + createHeaterComponents(); + createSolarArrayDeploymentComponents(); #if OBSW_ADD_SYRLINKS == 1 - createSyrlinksComponents(); + createSyrlinksComponents(); #endif /* OBSW_ADD_SYRLINKS == 1 */ #if OBSW_ADD_RTD_DEVICES == 1 - createRtdComponents(gpioComIF); + createRtdComponents(gpioComIF); #endif /* OBSW_ADD_RTD_DEVICES == 1 */ - I2cCookie* imtqI2cCookie = new I2cCookie(addresses::IMTQ, IMTQ::MAX_REPLY_SIZE, - q7s::I2C_DEFAULT_DEV); - new IMTQHandler(objects::IMTQ_HANDLER, objects::I2C_COM_IF, imtqI2cCookie); - createReactionWheelComponents(gpioComIF); + I2cCookie* imtqI2cCookie = + new I2cCookie(addresses::IMTQ, IMTQ::MAX_REPLY_SIZE, q7s::I2C_DEFAULT_DEV); + new IMTQHandler(objects::IMTQ_HANDLER, objects::I2C_COM_IF, imtqI2cCookie); + createReactionWheelComponents(gpioComIF); #if OBSW_ADD_PLOC_MPSOC == 1 - UartCookie* plocMpsocCookie = new UartCookie(objects::PLOC_MPSOC_HANDLER, - q7s::UART_PLOC_MPSOC_DEV, UartModes::NON_CANONICAL, uart::PLOC_MPSOC_BAUD, - PLOC_MPSOC::MAX_REPLY_SIZE); - new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, plocMpsocCookie); + UartCookie* plocMpsocCookie = + new UartCookie(objects::PLOC_MPSOC_HANDLER, q7s::UART_PLOC_MPSOC_DEV, + UartModes::NON_CANONICAL, uart::PLOC_MPSOC_BAUD, PLOC_MPSOC::MAX_REPLY_SIZE); + new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, plocMpsocCookie); #endif /* OBSW_ADD_PLOC_MPSOC == 1 */ #if OBSW_ADD_PLOC_SUPERVISOR == 1 - UartCookie* plocSupervisorCookie = new UartCookie(objects::PLOC_SUPERVISOR_HANDLER, - q7s::UART_PLOC_SUPERVSIOR_DEV, UartModes::NON_CANONICAL, uart::PLOC_SUPERVISOR_BAUD, - PLOC_SPV::MAX_PACKET_SIZE * 20); - plocSupervisorCookie->setNoFixedSizeReply(); - PlocSupervisorHandler* plocSupervisor = new PlocSupervisorHandler( - objects::PLOC_SUPERVISOR_HANDLER, objects::UART_COM_IF, plocSupervisorCookie); - plocSupervisor->setStartUpImmediately(); + UartCookie* plocSupervisorCookie = new UartCookie( + objects::PLOC_SUPERVISOR_HANDLER, q7s::UART_PLOC_SUPERVSIOR_DEV, UartModes::NON_CANONICAL, + uart::PLOC_SUPERVISOR_BAUD, PLOC_SPV::MAX_PACKET_SIZE * 20); + plocSupervisorCookie->setNoFixedSizeReply(); + PlocSupervisorHandler* plocSupervisor = new PlocSupervisorHandler( + objects::PLOC_SUPERVISOR_HANDLER, objects::UART_COM_IF, plocSupervisorCookie); + plocSupervisor->setStartUpImmediately(); #endif /* OBSW_ADD_PLOC_SUPERVISOR == 1 */ - new FileSystemHandler(objects::FILE_SYSTEM_HANDLER); + new FileSystemHandler(objects::FILE_SYSTEM_HANDLER); #if OBSW_ADD_STAR_TRACKER == 1 - UartCookie* starTrackerCookie = new UartCookie(objects::STAR_TRACKER, - q7s::UART_STAR_TRACKER_DEV, UartModes::NON_CANONICAL, uart::STAR_TRACKER_BAUD, - StarTracker::MAX_FRAME_SIZE* 2 + 2); - starTrackerCookie->setNoFixedSizeReply(); - StrHelper* strHelper = new StrHelper(objects::STR_HELPER); - StarTrackerHandler* starTrackerHandler = new StarTrackerHandler(objects::STAR_TRACKER, - objects::UART_COM_IF, starTrackerCookie, strHelper); - starTrackerHandler->setStartUpImmediately(); + UartCookie* starTrackerCookie = + new UartCookie(objects::STAR_TRACKER, q7s::UART_STAR_TRACKER_DEV, UartModes::NON_CANONICAL, + uart::STAR_TRACKER_BAUD, StarTracker::MAX_FRAME_SIZE * 2 + 2); + starTrackerCookie->setNoFixedSizeReply(); + StrHelper* strHelper = new StrHelper(objects::STR_HELPER); + StarTrackerHandler* starTrackerHandler = new StarTrackerHandler( + objects::STAR_TRACKER, objects::UART_COM_IF, starTrackerCookie, strHelper); + starTrackerHandler->setStartUpImmediately(); #endif /* OBSW_ADD_STAR_TRACKER == 1 */ #endif /* TE7020 == 0 */ #if OBSW_USE_CCSDS_IP_CORE == 1 - createCcsdsComponents(gpioComIF); + createCcsdsComponents(gpioComIF); #endif /* OBSW_USE_CCSDS_IP_CORE == 1 */ - /* Test Task */ + /* Test Task */ #if OBSW_ADD_TEST_CODE == 1 - createTestComponents(gpioComIF); + createTestComponents(gpioComIF); #endif /* OBSW_ADD_TEST_CODE == 1 */ - new PlocUpdater(objects::PLOC_UPDATER); - new PlocMemoryDumper(objects::PLOC_MEMORY_DUMPER); + new PlocUpdater(objects::PLOC_UPDATER); + new PlocMemoryDumper(objects::PLOC_MEMORY_DUMPER); } void ObjectFactory::createTmpComponents() { #if BOARD_TE0720 == 1 - I2cCookie* i2cCookieTmp1075tcs1 = new I2cCookie(addresses::TMP1075_TCS_1, - TMP1075::MAX_REPLY_LENGTH, std::string("/dev/i2c-0")); - I2cCookie* i2cCookieTmp1075tcs2 = new I2cCookie(addresses::TMP1075_TCS_2, - TMP1075::MAX_REPLY_LENGTH, std::string("/dev/i2c-0")); + I2cCookie* i2cCookieTmp1075tcs1 = + new I2cCookie(addresses::TMP1075_TCS_1, TMP1075::MAX_REPLY_LENGTH, std::string("/dev/i2c-0")); + I2cCookie* i2cCookieTmp1075tcs2 = + new I2cCookie(addresses::TMP1075_TCS_2, TMP1075::MAX_REPLY_LENGTH, std::string("/dev/i2c-0")); #else - I2cCookie* i2cCookieTmp1075tcs1 = new I2cCookie(addresses::TMP1075_TCS_1, - TMP1075::MAX_REPLY_LENGTH, q7s::I2C_DEFAULT_DEV); - I2cCookie* i2cCookieTmp1075tcs2 = new I2cCookie(addresses::TMP1075_TCS_2, - TMP1075::MAX_REPLY_LENGTH, q7s::I2C_DEFAULT_DEV); + I2cCookie* i2cCookieTmp1075tcs1 = + new I2cCookie(addresses::TMP1075_TCS_1, TMP1075::MAX_REPLY_LENGTH, q7s::I2C_DEFAULT_DEV); + I2cCookie* i2cCookieTmp1075tcs2 = + new I2cCookie(addresses::TMP1075_TCS_2, TMP1075::MAX_REPLY_LENGTH, q7s::I2C_DEFAULT_DEV); #endif - /* Temperature sensors */ - Tmp1075Handler* tmp1075Handler_1 = new Tmp1075Handler(objects::TMP1075_HANDLER_1, - objects::I2C_COM_IF, i2cCookieTmp1075tcs1); - (void) tmp1075Handler_1; - Tmp1075Handler* tmp1075Handler_2 = new Tmp1075Handler(objects::TMP1075_HANDLER_2, - objects::I2C_COM_IF, i2cCookieTmp1075tcs2); - (void) tmp1075Handler_2; + /* Temperature sensors */ + Tmp1075Handler* tmp1075Handler_1 = + new Tmp1075Handler(objects::TMP1075_HANDLER_1, objects::I2C_COM_IF, i2cCookieTmp1075tcs1); + (void)tmp1075Handler_1; + Tmp1075Handler* tmp1075Handler_2 = + new Tmp1075Handler(objects::TMP1075_HANDLER_2, objects::I2C_COM_IF, i2cCookieTmp1075tcs2); + (void)tmp1075Handler_2; } -void ObjectFactory::createCommunicationInterfaces(LinuxLibgpioIF **gpioComIF, UartComIF** uartComIF, - SpiComIF** spiComIF) { - if (gpioComIF == nullptr or uartComIF == nullptr or spiComIF == nullptr) { - sif::error << "ObjectFactory::createCommunicationInterfaces: Invalid passed ComIF pointer" - << std::endl; - } - *gpioComIF = new LinuxLibgpioIF(objects::GPIO_IF); +void ObjectFactory::createCommunicationInterfaces(LinuxLibgpioIF** gpioComIF, UartComIF** uartComIF, + SpiComIF** spiComIF) { + if (gpioComIF == nullptr or uartComIF == nullptr or spiComIF == nullptr) { + sif::error << "ObjectFactory::createCommunicationInterfaces: Invalid passed ComIF pointer" + << std::endl; + } + *gpioComIF = new LinuxLibgpioIF(objects::GPIO_IF); - /* Communication interfaces */ - new CspComIF(objects::CSP_COM_IF); - new I2cComIF(objects::I2C_COM_IF); - *uartComIF = new UartComIF(objects::UART_COM_IF); + /* Communication interfaces */ + new CspComIF(objects::CSP_COM_IF); + new I2cComIF(objects::I2C_COM_IF); + *uartComIF = new UartComIF(objects::UART_COM_IF); #if OBSW_ADD_SPI_TEST_CODE == 0 - *spiComIF = new SpiComIF(objects::SPI_COM_IF, *gpioComIF); + *spiComIF = new SpiComIF(objects::SPI_COM_IF, *gpioComIF); #endif /* Q7S_ADD_SPI_TEST_CODE == 0 */ #if BOARD_TE0720 == 0 - /* Adding gpios for chip select decoding to the gpioComIf */ - gpioCallbacks::initSpiCsDecoder(*gpioComIF); + /* Adding gpios for chip select decoding to the gpioComIf */ + gpioCallbacks::initSpiCsDecoder(*gpioComIF); #endif } void ObjectFactory::createPcduComponents() { - 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); - CspCookie* acuCspCookie = new CspCookie(ACU::MAX_REPLY_LENGTH, addresses::ACU); - /* Device Handler */ - P60DockHandler* p60dockhandler = new P60DockHandler(objects::P60DOCK_HANDLER, - objects::CSP_COM_IF, p60DockCspCookie); - PDU1Handler* pdu1handler = new PDU1Handler(objects::PDU1_HANDLER, objects::CSP_COM_IF, - pdu1CspCookie); - PDU2Handler* pdu2handler = new PDU2Handler(objects::PDU2_HANDLER, objects::CSP_COM_IF, - pdu2CspCookie); - ACUHandler* acuhandler = new ACUHandler(objects::ACU_HANDLER, objects::CSP_COM_IF, - acuCspCookie); - new PCDUHandler(objects::PCDU_HANDLER, 50); + 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); + CspCookie* acuCspCookie = new CspCookie(ACU::MAX_REPLY_LENGTH, addresses::ACU); + /* Device Handler */ + P60DockHandler* p60dockhandler = + new P60DockHandler(objects::P60DOCK_HANDLER, objects::CSP_COM_IF, p60DockCspCookie); + PDU1Handler* pdu1handler = + new PDU1Handler(objects::PDU1_HANDLER, objects::CSP_COM_IF, pdu1CspCookie); + PDU2Handler* pdu2handler = + new PDU2Handler(objects::PDU2_HANDLER, objects::CSP_COM_IF, pdu2CspCookie); + ACUHandler* acuhandler = new ACUHandler(objects::ACU_HANDLER, objects::CSP_COM_IF, acuCspCookie); + new PCDUHandler(objects::PCDU_HANDLER, 50); - /** - * Setting PCDU devices to mode normal immediately after start up because PCDU is always - * running. - */ - p60dockhandler->setModeNormal(); - pdu1handler->setModeNormal(); - pdu2handler->setModeNormal(); - acuhandler->setModeNormal(); + /** + * Setting PCDU devices to mode normal immediately after start up because PCDU is always + * running. + */ + p60dockhandler->setModeNormal(); + pdu1handler->setModeNormal(); + pdu2handler->setModeNormal(); + acuhandler->setModeNormal(); } void ObjectFactory::createRadSensorComponent(LinuxLibgpioIF* gpioComIF) { - GpioCookie* gpioCookieRadSensor = new GpioCookie; - std::stringstream consumer; - consumer << "0x" << std::hex << objects::RAD_SENSOR; - GpiodRegularByLineName* gpio = new GpiodRegularByLineName( - q7s::gpioNames::RAD_SENSOR_CHIP_SELECT, consumer.str(), gpio::DIR_OUT, gpio::HIGH); - gpioCookieRadSensor->addGpio(gpioIds::CS_RAD_SENSOR, gpio); - gpioComIF->addGpios(gpioCookieRadSensor); + GpioCookie* gpioCookieRadSensor = new GpioCookie; + std::stringstream consumer; + consumer << "0x" << std::hex << objects::RAD_SENSOR; + GpiodRegularByLineName* gpio = new GpiodRegularByLineName( + q7s::gpioNames::RAD_SENSOR_CHIP_SELECT, consumer.str(), gpio::DIR_OUT, gpio::HIGH); + gpioCookieRadSensor->addGpio(gpioIds::CS_RAD_SENSOR, gpio); + gpioComIF->addGpios(gpioCookieRadSensor); - SpiCookie* spiCookieRadSensor = new SpiCookie(addresses::RAD_SENSOR, gpioIds::CS_RAD_SENSOR, - std::string(q7s::SPI_DEFAULT_DEV), RAD_SENSOR::READ_SIZE, spi::DEFAULT_MAX_1227_MODE, - spi::DEFAULT_MAX_1227_SPEED); - new RadiationSensorHandler(objects::RAD_SENSOR, objects::SPI_COM_IF, spiCookieRadSensor); + SpiCookie* spiCookieRadSensor = new SpiCookie( + addresses::RAD_SENSOR, gpioIds::CS_RAD_SENSOR, std::string(q7s::SPI_DEFAULT_DEV), + RAD_SENSOR::READ_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED); + new RadiationSensorHandler(objects::RAD_SENSOR, objects::SPI_COM_IF, spiCookieRadSensor); } -void ObjectFactory::createSunSensorComponents(LinuxLibgpioIF *gpioComIF, SpiComIF* spiComIF) { - GpioCookie* gpioCookieSus = new GpioCookie(); - GpioCallback* susgpio = nullptr; +void ObjectFactory::createSunSensorComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* spiComIF) { + GpioCookie* gpioCookieSus = new GpioCookie(); + GpioCallback* susgpio = nullptr; - susgpio = new GpioCallback("Chip select SUS 1", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_1, susgpio); - susgpio = new GpioCallback("Chip select SUS 2", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_2, susgpio); - susgpio = new GpioCallback("Chip select SUS 3", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_3, susgpio); - susgpio = new GpioCallback("Chip select SUS 4", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_4, susgpio); - susgpio = new GpioCallback("Chip select SUS 5", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_5, susgpio); - susgpio = new GpioCallback("Chip select SUS 6", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_6, susgpio); - susgpio = new GpioCallback("Chip select SUS 7", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_7, susgpio); - susgpio = new GpioCallback("Chip select SUS 8", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_8, susgpio); - susgpio = new GpioCallback("Chip select SUS 9", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_9, susgpio); - susgpio = new GpioCallback("Chip select SUS 10", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_10, susgpio); - susgpio = new GpioCallback("Chip select SUS 11", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_11, susgpio); - susgpio = new GpioCallback("Chip select SUS 12", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_12, susgpio); - susgpio = new GpioCallback("Chip select SUS 13", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_13, susgpio); + susgpio = new GpioCallback("Chip select SUS 1", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_1, susgpio); + susgpio = new GpioCallback("Chip select SUS 2", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_2, susgpio); + susgpio = new GpioCallback("Chip select SUS 3", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_3, susgpio); + susgpio = new GpioCallback("Chip select SUS 4", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_4, susgpio); + susgpio = new GpioCallback("Chip select SUS 5", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_5, susgpio); + susgpio = new GpioCallback("Chip select SUS 6", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_6, susgpio); + susgpio = new GpioCallback("Chip select SUS 7", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_7, susgpio); + susgpio = new GpioCallback("Chip select SUS 8", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_8, susgpio); + susgpio = new GpioCallback("Chip select SUS 9", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_9, susgpio); + susgpio = new GpioCallback("Chip select SUS 10", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_10, susgpio); + susgpio = new GpioCallback("Chip select SUS 11", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_11, susgpio); + susgpio = new GpioCallback("Chip select SUS 12", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_12, susgpio); + susgpio = new GpioCallback("Chip select SUS 13", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_13, susgpio); - gpioComIF->addGpios(gpioCookieSus); + gpioComIF->addGpios(gpioCookieSus); - SpiCookie* spiCookieSus1 = new SpiCookie(addresses::SUS_1, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus2 = new SpiCookie(addresses::SUS_2, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus3 = new SpiCookie(addresses::SUS_3, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus4 = new SpiCookie(addresses::SUS_4, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus5 = new SpiCookie(addresses::SUS_5, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus6 = new SpiCookie(addresses::SUS_6, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus7 = new SpiCookie(addresses::SUS_7, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus8 = new SpiCookie(addresses::SUS_8, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus9 = new SpiCookie(addresses::SUS_9, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus10 = new SpiCookie(addresses::SUS_10, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus11 = new SpiCookie(addresses::SUS_11, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus12 = new SpiCookie(addresses::SUS_12, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus13 = new SpiCookie(addresses::SUS_13, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus1 = + new SpiCookie(addresses::SUS_1, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus2 = + new SpiCookie(addresses::SUS_2, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus3 = + new SpiCookie(addresses::SUS_3, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus4 = + new SpiCookie(addresses::SUS_4, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus5 = + new SpiCookie(addresses::SUS_5, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus6 = + new SpiCookie(addresses::SUS_6, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus7 = + new SpiCookie(addresses::SUS_7, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus8 = + new SpiCookie(addresses::SUS_8, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus9 = + new SpiCookie(addresses::SUS_9, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus10 = + new SpiCookie(addresses::SUS_10, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus11 = + new SpiCookie(addresses::SUS_11, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus12 = + new SpiCookie(addresses::SUS_12, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); + SpiCookie* spiCookieSus13 = + new SpiCookie(addresses::SUS_13, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); - new SusHandler(objects::SUS_1, objects::SPI_COM_IF, spiCookieSus1, gpioComIF, - gpioIds::CS_SUS_1); - new SusHandler(objects::SUS_2, objects::SPI_COM_IF, spiCookieSus2, gpioComIF, - gpioIds::CS_SUS_2); - new SusHandler(objects::SUS_3, objects::SPI_COM_IF, spiCookieSus3, gpioComIF, - gpioIds::CS_SUS_3); - new SusHandler(objects::SUS_4, objects::SPI_COM_IF, spiCookieSus4, gpioComIF, - gpioIds::CS_SUS_4); - new SusHandler(objects::SUS_5, objects::SPI_COM_IF, spiCookieSus5, gpioComIF, - gpioIds::CS_SUS_5); - new SusHandler(objects::SUS_6, objects::SPI_COM_IF, spiCookieSus6, gpioComIF, - gpioIds::CS_SUS_6); - new SusHandler(objects::SUS_7, objects::SPI_COM_IF, spiCookieSus7, gpioComIF, - gpioIds::CS_SUS_7); - new SusHandler(objects::SUS_8, objects::SPI_COM_IF, spiCookieSus8, gpioComIF, - gpioIds::CS_SUS_8); - new SusHandler(objects::SUS_9, objects::SPI_COM_IF, spiCookieSus9, gpioComIF, - gpioIds::CS_SUS_9); - new SusHandler(objects::SUS_10, objects::SPI_COM_IF, spiCookieSus10, gpioComIF, - gpioIds::CS_SUS_10); - new SusHandler(objects::SUS_11, objects::SPI_COM_IF, spiCookieSus11, gpioComIF, - gpioIds::CS_SUS_11); - new SusHandler(objects::SUS_12, objects::SPI_COM_IF, spiCookieSus12, gpioComIF, - gpioIds::CS_SUS_12); - new SusHandler(objects::SUS_13, objects::SPI_COM_IF, spiCookieSus13, gpioComIF, - gpioIds::CS_SUS_13); + new SusHandler(objects::SUS_1, objects::SPI_COM_IF, spiCookieSus1, gpioComIF, gpioIds::CS_SUS_1); + new SusHandler(objects::SUS_2, objects::SPI_COM_IF, spiCookieSus2, gpioComIF, gpioIds::CS_SUS_2); + new SusHandler(objects::SUS_3, objects::SPI_COM_IF, spiCookieSus3, gpioComIF, gpioIds::CS_SUS_3); + new SusHandler(objects::SUS_4, objects::SPI_COM_IF, spiCookieSus4, gpioComIF, gpioIds::CS_SUS_4); + new SusHandler(objects::SUS_5, objects::SPI_COM_IF, spiCookieSus5, gpioComIF, gpioIds::CS_SUS_5); + new SusHandler(objects::SUS_6, objects::SPI_COM_IF, spiCookieSus6, gpioComIF, gpioIds::CS_SUS_6); + new SusHandler(objects::SUS_7, objects::SPI_COM_IF, spiCookieSus7, gpioComIF, gpioIds::CS_SUS_7); + new SusHandler(objects::SUS_8, objects::SPI_COM_IF, spiCookieSus8, gpioComIF, gpioIds::CS_SUS_8); + new SusHandler(objects::SUS_9, objects::SPI_COM_IF, spiCookieSus9, gpioComIF, gpioIds::CS_SUS_9); + new SusHandler(objects::SUS_10, objects::SPI_COM_IF, spiCookieSus10, gpioComIF, + gpioIds::CS_SUS_10); + new SusHandler(objects::SUS_11, objects::SPI_COM_IF, spiCookieSus11, gpioComIF, + gpioIds::CS_SUS_11); + new SusHandler(objects::SUS_12, objects::SPI_COM_IF, spiCookieSus12, gpioComIF, + gpioIds::CS_SUS_12); + new SusHandler(objects::SUS_13, objects::SPI_COM_IF, spiCookieSus13, gpioComIF, + gpioIds::CS_SUS_13); } -void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComIF* uartComIF) { - GpioCookie* gpioCookieAcsBoard = new GpioCookie(); +void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComIF* uartComIF) { + GpioCookie* gpioCookieAcsBoard = new GpioCookie(); - std::stringstream consumer; - GpiodRegularByLineName* gpio = nullptr; - consumer << "0x" << std::hex << objects::GYRO_0_ADIS_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ADIS_CS, consumer.str(), - gpio::DIR_OUT, gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); + std::stringstream consumer; + GpiodRegularByLineName* gpio = nullptr; + consumer << "0x" << std::hex << objects::GYRO_0_ADIS_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ADIS_CS, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GYRO_1_L3G_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_1_L3G_CS, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GYRO_1_L3G_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_1_L3G_CS, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GYRO_2_ADIS_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ADIS_CS, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::GYRO_2_ADIS_CS, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GYRO_2_ADIS_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ADIS_CS, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::GYRO_2_ADIS_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GYRO_3_L3G_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_3_L3G_CS, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GYRO_3_L3G_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_3_L3G_CS, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::MGM_0_LIS3_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_0_CS, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::MGM_0_LIS3_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_0_CS, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::MGM_1_RM3100_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::MGM_1_RM3100_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::MGM_2_LIS3_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_2_CS, consumer.str(), - gpio::DIR_OUT, gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::MGM_2_LIS3_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_2_CS, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::MGM_3_RM3100_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_3_CS, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::MGM_3_RM3100_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_3_CS, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GPS_CONTROLLER; - // GNSS reset pins are active low - gpio = new GpiodRegularByLineName(q7s::gpioNames::RESET_GNSS_0, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::GNSS_0_NRESET, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GPS_CONTROLLER; + // GNSS reset pins are active low + gpio = new GpiodRegularByLineName(q7s::gpioNames::RESET_GNSS_0, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::GNSS_0_NRESET, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GPS_CONTROLLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::RESET_GNSS_1, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::GNSS_1_NRESET, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GPS_CONTROLLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::RESET_GNSS_1, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::GNSS_1_NRESET, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GYRO_0_ADIS_HANDLER; - // Enable pins must be pulled low for regular operations - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, consumer.str(), - gpio::DIR_OUT, gpio::LOW); - gpioCookieAcsBoard->addGpio(gpioIds::GYRO_0_ENABLE, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GYRO_0_ADIS_HANDLER; + // Enable pins must be pulled low for regular operations + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + gpioCookieAcsBoard->addGpio(gpioIds::GYRO_0_ENABLE, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GYRO_2_ADIS_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ENABLE, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - gpioCookieAcsBoard->addGpio(gpioIds::GYRO_2_ENABLE, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GYRO_2_ADIS_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ENABLE, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + gpioCookieAcsBoard->addGpio(gpioIds::GYRO_2_ENABLE, gpio); - // Enable pins for GNSS - consumer.str(""); - consumer << "0x" << std::hex << objects::GPS_CONTROLLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::GNSS_0_ENABLE, consumer.str(), - gpio::DIR_OUT, gpio::LOW); - gpioCookieAcsBoard->addGpio(gpioIds::GNSS_0_ENABLE, gpio); + // Enable pins for GNSS + consumer.str(""); + consumer << "0x" << std::hex << objects::GPS_CONTROLLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GNSS_0_ENABLE, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + gpioCookieAcsBoard->addGpio(gpioIds::GNSS_0_ENABLE, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GPS_CONTROLLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::GNSS_1_ENABLE, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - gpioCookieAcsBoard->addGpio(gpioIds::GNSS_1_ENABLE, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GPS_CONTROLLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GNSS_1_ENABLE, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + gpioCookieAcsBoard->addGpio(gpioIds::GNSS_1_ENABLE, gpio); - gpioComIF->addGpios(gpioCookieAcsBoard); + gpioComIF->addGpios(gpioCookieAcsBoard); - std::string spiDev = q7s::SPI_DEFAULT_DEV; - SpiCookie* spiCookie = new SpiCookie(addresses::MGM_0_LIS3, gpioIds::MGM_0_LIS3_CS, spiDev, - MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); - auto mgmLis3Handler = new MgmLIS3MDLHandler(objects::MGM_0_LIS3_HANDLER, objects::SPI_COM_IF, - spiCookie, spi::LIS3_TRANSITION_DELAY); - mgmLis3Handler->setStartUpImmediately(); + std::string spiDev = q7s::SPI_DEFAULT_DEV; + SpiCookie* spiCookie = + new SpiCookie(addresses::MGM_0_LIS3, gpioIds::MGM_0_LIS3_CS, spiDev, + MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); + auto mgmLis3Handler = new MgmLIS3MDLHandler(objects::MGM_0_LIS3_HANDLER, objects::SPI_COM_IF, + spiCookie, spi::LIS3_TRANSITION_DELAY); + mgmLis3Handler->setStartUpImmediately(); #if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1 - mgmLis3Handler->setToGoToNormalMode(true); + mgmLis3Handler->setToGoToNormalMode(true); #endif - spiCookie = new SpiCookie(addresses::MGM_1_RM3100, gpioIds::MGM_1_RM3100_CS, spiDev, - RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); - auto mgmRm3100Handler = new MgmRM3100Handler(objects::MGM_1_RM3100_HANDLER, objects::SPI_COM_IF, - spiCookie, spi::RM3100_TRANSITION_DELAY); - mgmRm3100Handler->setStartUpImmediately(); + spiCookie = + new SpiCookie(addresses::MGM_1_RM3100, gpioIds::MGM_1_RM3100_CS, spiDev, + RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); + auto mgmRm3100Handler = new MgmRM3100Handler(objects::MGM_1_RM3100_HANDLER, objects::SPI_COM_IF, + spiCookie, spi::RM3100_TRANSITION_DELAY); + mgmRm3100Handler->setStartUpImmediately(); #if FSFW_HAL_RM3100_MGM_DEBUG == 1 - mgmRm3100Handler->setToGoToNormalMode(true); + mgmRm3100Handler->setToGoToNormalMode(true); #endif - spiCookie = new SpiCookie(addresses::MGM_2_LIS3, gpioIds::MGM_2_LIS3_CS, spiDev, - MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); - auto mgmLis3Handler2 = new MgmLIS3MDLHandler(objects::MGM_2_LIS3_HANDLER, objects::SPI_COM_IF, - spiCookie, spi::LIS3_TRANSITION_DELAY); - mgmLis3Handler2->setStartUpImmediately(); + spiCookie = + new SpiCookie(addresses::MGM_2_LIS3, gpioIds::MGM_2_LIS3_CS, spiDev, + MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); + auto mgmLis3Handler2 = new MgmLIS3MDLHandler(objects::MGM_2_LIS3_HANDLER, objects::SPI_COM_IF, + spiCookie, spi::LIS3_TRANSITION_DELAY); + mgmLis3Handler2->setStartUpImmediately(); #if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1 - mgmLis3Handler2->setToGoToNormalMode(true); + mgmLis3Handler2->setToGoToNormalMode(true); #endif - spiCookie = new SpiCookie(addresses::MGM_3_RM3100, gpioIds::MGM_3_RM3100_CS, spiDev, - RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); - mgmRm3100Handler = new MgmRM3100Handler(objects::MGM_3_RM3100_HANDLER, objects::SPI_COM_IF, - spiCookie, spi::RM3100_TRANSITION_DELAY); - mgmRm3100Handler->setStartUpImmediately(); + spiCookie = + new SpiCookie(addresses::MGM_3_RM3100, gpioIds::MGM_3_RM3100_CS, spiDev, + RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); + mgmRm3100Handler = new MgmRM3100Handler(objects::MGM_3_RM3100_HANDLER, objects::SPI_COM_IF, + spiCookie, spi::RM3100_TRANSITION_DELAY); + mgmRm3100Handler->setStartUpImmediately(); #if FSFW_HAL_RM3100_MGM_DEBUG == 1 - mgmRm3100Handler->setToGoToNormalMode(true); + mgmRm3100Handler->setToGoToNormalMode(true); #endif - // Commented until ACS board V2 in in clean room again - // Gyro 0 Side A - spiCookie = new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, spiDev, - ADIS1650X::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, - spi::DEFAULT_ADIS16507_SPEED); - auto adisHandler = new GyroADIS1650XHandler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, - spiCookie, ADIS1650X::Type::ADIS16505); - adisHandler->setStartUpImmediately(); - // Gyro 1 Side A - spiCookie = new SpiCookie(addresses::GYRO_1_L3G, gpioIds::GYRO_1_L3G_CS, spiDev, - L3GD20H::MAX_BUFFER_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); - auto gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_1_L3G_HANDLER, objects::SPI_COM_IF, - spiCookie, spi::L3G_TRANSITION_DELAY); - gyroL3gHandler->setStartUpImmediately(); + // Commented until ACS board V2 in in clean room again + // Gyro 0 Side A + spiCookie = new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, spiDev, + ADIS1650X::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, + spi::DEFAULT_ADIS16507_SPEED); + auto adisHandler = new GyroADIS1650XHandler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, + spiCookie, ADIS1650X::Type::ADIS16505); + adisHandler->setStartUpImmediately(); + // Gyro 1 Side A + spiCookie = + new SpiCookie(addresses::GYRO_1_L3G, gpioIds::GYRO_1_L3G_CS, spiDev, L3GD20H::MAX_BUFFER_SIZE, + spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); + auto gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_1_L3G_HANDLER, objects::SPI_COM_IF, + spiCookie, spi::L3G_TRANSITION_DELAY); + gyroL3gHandler->setStartUpImmediately(); #if FSFW_HAL_L3GD20_GYRO_DEBUG == 1 - gyroL3gHandler->setToGoToNormalMode(true); + gyroL3gHandler->setToGoToNormalMode(true); #endif - // Gyro 2 Side B - spiCookie = new SpiCookie(addresses::GYRO_2_ADIS, gpioIds::GYRO_2_ADIS_CS, spiDev, - ADIS1650X::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, - spi::DEFAULT_ADIS16507_SPEED); - adisHandler = new GyroADIS1650XHandler(objects::GYRO_2_ADIS_HANDLER, objects::SPI_COM_IF, - spiCookie, ADIS1650X::Type::ADIS16505); - adisHandler->setStartUpImmediately(); - // Gyro 3 Side B - spiCookie = new SpiCookie(addresses::GYRO_3_L3G, gpioIds::GYRO_3_L3G_CS, spiDev, - L3GD20H::MAX_BUFFER_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); - gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_3_L3G_HANDLER, objects::SPI_COM_IF, - spiCookie, spi::L3G_TRANSITION_DELAY); - gyroL3gHandler->setStartUpImmediately(); + // Gyro 2 Side B + spiCookie = new SpiCookie(addresses::GYRO_2_ADIS, gpioIds::GYRO_2_ADIS_CS, spiDev, + ADIS1650X::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, + spi::DEFAULT_ADIS16507_SPEED); + adisHandler = new GyroADIS1650XHandler(objects::GYRO_2_ADIS_HANDLER, objects::SPI_COM_IF, + spiCookie, ADIS1650X::Type::ADIS16505); + adisHandler->setStartUpImmediately(); + // Gyro 3 Side B + spiCookie = + new SpiCookie(addresses::GYRO_3_L3G, gpioIds::GYRO_3_L3G_CS, spiDev, L3GD20H::MAX_BUFFER_SIZE, + spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); + gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_3_L3G_HANDLER, objects::SPI_COM_IF, + spiCookie, spi::L3G_TRANSITION_DELAY); + gyroL3gHandler->setStartUpImmediately(); #if FSFW_HAL_L3GD20_GYRO_DEBUG == 1 - gyroL3gHandler->setToGoToNormalMode(true); + gyroL3gHandler->setToGoToNormalMode(true); #endif - bool debugGps = false; + bool debugGps = false; #if OBSW_DEBUG_GPS == 1 - debugGps = true; + debugGps = true; #endif - resetArgsGnss1.gnss1 = true; - resetArgsGnss1.gpioComIF = gpioComIF; - resetArgsGnss1.waitPeriodMs = 100; - resetArgsGnss0.gnss1 = false; - resetArgsGnss0.gpioComIF = gpioComIF; - resetArgsGnss0.waitPeriodMs = 100; - auto gpsHandler0 = new GPSHyperionHandler(objects::GPS_CONTROLLER, objects::NO_OBJECT, - debugGps); - gpsHandler0->setResetPinTriggerFunction(gps::triggerGpioResetPin, &resetArgsGnss0); + resetArgsGnss1.gnss1 = true; + resetArgsGnss1.gpioComIF = gpioComIF; + resetArgsGnss1.waitPeriodMs = 100; + resetArgsGnss0.gnss1 = false; + resetArgsGnss0.gpioComIF = gpioComIF; + resetArgsGnss0.waitPeriodMs = 100; + auto gpsHandler0 = new GPSHyperionHandler(objects::GPS_CONTROLLER, objects::NO_OBJECT, debugGps); + gpsHandler0->setResetPinTriggerFunction(gps::triggerGpioResetPin, &resetArgsGnss0); } void ObjectFactory::createHeaterComponents() { + GpioCookie* heaterGpiosCookie = new GpioCookie; + GpiodRegularByLineName* gpio = nullptr; - GpioCookie* heaterGpiosCookie = new GpioCookie; - GpiodRegularByLineName* gpio = nullptr; + std::stringstream consumer; + consumer << "0x" << std::hex << objects::HEATER_HANDLER; + /* Pin H2-11 on stack connector */ + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_0, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_0, gpio); + /* Pin H2-12 on stack connector */ + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_1, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_1, gpio); - std::stringstream consumer; - consumer << "0x" << std::hex << objects::HEATER_HANDLER; - /* Pin H2-11 on stack connector */ - gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_0, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_0, gpio); - /* Pin H2-12 on stack connector */ - gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_1, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_1, gpio); + /* Pin H2-13 on stack connector */ + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_2, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_2, gpio); - /* Pin H2-13 on stack connector */ - gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_2, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_2, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_3, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_3, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_3, consumer.str(), - gpio::DIR_OUT, gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_3, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_4, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_4, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_4, consumer.str(), - gpio::DIR_OUT, gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_4, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_5, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_5, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_5, consumer.str(), - gpio::DIR_OUT, gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_5, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_6, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_6, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_6, consumer.str(), - gpio::DIR_OUT, gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_6, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_7, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_7, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_7, consumer.str(), - gpio::DIR_OUT, gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_7, gpio); - - new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, heaterGpiosCookie, - objects::PCDU_HANDLER, pcduSwitches::TCS_BOARD_8V_HEATER_IN); + new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, heaterGpiosCookie, + objects::PCDU_HANDLER, pcduSwitches::TCS_BOARD_8V_HEATER_IN); } void ObjectFactory::createSolarArrayDeploymentComponents() { - GpioCookie* solarArrayDeplCookie = new GpioCookie; - GpiodRegularByLineName* gpio = nullptr; + GpioCookie* solarArrayDeplCookie = new GpioCookie; + GpiodRegularByLineName* gpio = nullptr; - std::stringstream consumer; - consumer << "0x" << std::hex << objects::SOLAR_ARRAY_DEPL_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::SA_DPL_PIN_0, - consumer.str(), gpio::DIR_OUT, gpio::LOW); - solarArrayDeplCookie->addGpio(gpioIds::DEPLSA1, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::SA_DPL_PIN_1, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - solarArrayDeplCookie->addGpio(gpioIds::DEPLSA2, gpio); + std::stringstream consumer; + consumer << "0x" << std::hex << objects::SOLAR_ARRAY_DEPL_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::SA_DPL_PIN_0, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + solarArrayDeplCookie->addGpio(gpioIds::DEPLSA1, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::SA_DPL_PIN_1, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + solarArrayDeplCookie->addGpio(gpioIds::DEPLSA2, gpio); - //TODO: Find out burn time. For now set to 1000 ms. - new SolarArrayDeploymentHandler(objects::SOLAR_ARRAY_DEPL_HANDLER, objects::GPIO_IF, - solarArrayDeplCookie, objects::PCDU_HANDLER, pcduSwitches::DEPLOYMENT_MECHANISM, - gpioIds::DEPLSA1, gpioIds::DEPLSA2, 1000); + // TODO: Find out burn time. For now set to 1000 ms. + new SolarArrayDeploymentHandler(objects::SOLAR_ARRAY_DEPL_HANDLER, objects::GPIO_IF, + solarArrayDeplCookie, objects::PCDU_HANDLER, + pcduSwitches::DEPLOYMENT_MECHANISM, gpioIds::DEPLSA1, + gpioIds::DEPLSA2, 1000); } void ObjectFactory::createSyrlinksComponents() { - UartCookie* syrlinksUartCookie = new UartCookie(objects::SYRLINKS_HK_HANDLER, - q7s::UART_SYRLINKS_DEV, UartModes::NON_CANONICAL, uart::SYRLINKS_BAUD, - SYRLINKS::MAX_REPLY_SIZE); - syrlinksUartCookie->setParityEven(); + UartCookie* syrlinksUartCookie = + new UartCookie(objects::SYRLINKS_HK_HANDLER, q7s::UART_SYRLINKS_DEV, UartModes::NON_CANONICAL, + uart::SYRLINKS_BAUD, SYRLINKS::MAX_REPLY_SIZE); + syrlinksUartCookie->setParityEven(); - new SyrlinksHkHandler(objects::SYRLINKS_HK_HANDLER, objects::UART_COM_IF, syrlinksUartCookie); + new SyrlinksHkHandler(objects::SYRLINKS_HK_HANDLER, objects::UART_COM_IF, syrlinksUartCookie); } -void ObjectFactory::createRtdComponents(LinuxLibgpioIF *gpioComIF) { - GpioCookie* rtdGpioCookie = new GpioCookie; +void ObjectFactory::createRtdComponents(LinuxLibgpioIF* gpioComIF) { + GpioCookie* rtdGpioCookie = new GpioCookie; - GpioCallback* gpioRtdIc0 = new GpioCallback("Chip select RTD IC0", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_3, gpioRtdIc0); - GpioCallback* gpioRtdIc1 = new GpioCallback("Chip select RTD IC1", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_4, gpioRtdIc1); - GpioCallback* gpioRtdIc2 = new GpioCallback("Chip select RTD IC2", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_5, gpioRtdIc2); - GpioCallback* gpioRtdIc3 = new GpioCallback("Chip select RTD IC3", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_6, gpioRtdIc3); - GpioCallback* gpioRtdIc4 = new GpioCallback("Chip select RTD IC4", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_7, gpioRtdIc4); - GpioCallback* gpioRtdIc5 = new GpioCallback("Chip select RTD IC5", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_8, gpioRtdIc5); - GpioCallback* gpioRtdIc6 = new GpioCallback("Chip select RTD IC6", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_9, gpioRtdIc6); - GpioCallback* gpioRtdIc7 = new GpioCallback("Chip select RTD IC7", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_10, gpioRtdIc7); - GpioCallback* gpioRtdIc8 = new GpioCallback("Chip select RTD IC8", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_11, gpioRtdIc8); - GpioCallback* gpioRtdIc9 = new GpioCallback("Chip select RTD IC9", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_12, gpioRtdIc9); - GpioCallback* gpioRtdIc10 = new GpioCallback("Chip select RTD IC10", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_13, gpioRtdIc10); - GpioCallback* gpioRtdIc11 = new GpioCallback("Chip select RTD IC11", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_14, gpioRtdIc11); - GpioCallback* gpioRtdIc12 = new GpioCallback("Chip select RTD IC12", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_15, gpioRtdIc12); - GpioCallback* gpioRtdIc13 = new GpioCallback("Chip select RTD IC13", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_16, gpioRtdIc13); - GpioCallback* gpioRtdIc14 = new GpioCallback("Chip select RTD IC14", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_17, gpioRtdIc14); - GpioCallback* gpioRtdIc15 = new GpioCallback("Chip select RTD IC15", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_18, gpioRtdIc15); + GpioCallback* gpioRtdIc0 = new GpioCallback("Chip select RTD IC0", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_3, gpioRtdIc0); + GpioCallback* gpioRtdIc1 = new GpioCallback("Chip select RTD IC1", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_4, gpioRtdIc1); + GpioCallback* gpioRtdIc2 = new GpioCallback("Chip select RTD IC2", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_5, gpioRtdIc2); + GpioCallback* gpioRtdIc3 = new GpioCallback("Chip select RTD IC3", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_6, gpioRtdIc3); + GpioCallback* gpioRtdIc4 = new GpioCallback("Chip select RTD IC4", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_7, gpioRtdIc4); + GpioCallback* gpioRtdIc5 = new GpioCallback("Chip select RTD IC5", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_8, gpioRtdIc5); + GpioCallback* gpioRtdIc6 = new GpioCallback("Chip select RTD IC6", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_9, gpioRtdIc6); + GpioCallback* gpioRtdIc7 = new GpioCallback("Chip select RTD IC7", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_10, gpioRtdIc7); + GpioCallback* gpioRtdIc8 = new GpioCallback("Chip select RTD IC8", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_11, gpioRtdIc8); + GpioCallback* gpioRtdIc9 = new GpioCallback("Chip select RTD IC9", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_12, gpioRtdIc9); + GpioCallback* gpioRtdIc10 = new GpioCallback("Chip select RTD IC10", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_13, gpioRtdIc10); + GpioCallback* gpioRtdIc11 = new GpioCallback("Chip select RTD IC11", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_14, gpioRtdIc11); + GpioCallback* gpioRtdIc12 = new GpioCallback("Chip select RTD IC12", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_15, gpioRtdIc12); + GpioCallback* gpioRtdIc13 = new GpioCallback("Chip select RTD IC13", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_16, gpioRtdIc13); + GpioCallback* gpioRtdIc14 = new GpioCallback("Chip select RTD IC14", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_17, gpioRtdIc14); + GpioCallback* gpioRtdIc15 = new GpioCallback("Chip select RTD IC15", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_18, gpioRtdIc15); - gpioComIF->addGpios(rtdGpioCookie); + gpioComIF->addGpios(rtdGpioCookie); - SpiCookie* spiRtdIc0 = new SpiCookie(addresses::RTD_IC_3, gpioIds::RTD_IC_3, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); - SpiCookie* spiRtdIc1 = new SpiCookie(addresses::RTD_IC_4, gpioIds::RTD_IC_4, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); - SpiCookie* spiRtdIc2 = new SpiCookie(addresses::RTD_IC_5, gpioIds::RTD_IC_5, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); - SpiCookie* spiRtdIc3 = new SpiCookie(addresses::RTD_IC_6, gpioIds::RTD_IC_6, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); - SpiCookie* spiRtdIc4 = new SpiCookie(addresses::RTD_IC_7, gpioIds::RTD_IC_7, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); - SpiCookie* spiRtdIc5 = new SpiCookie(addresses::RTD_IC_8, gpioIds::RTD_IC_8, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); - SpiCookie* spiRtdIc6 = new SpiCookie(addresses::RTD_IC_9, gpioIds::RTD_IC_9, q7s::SPI_DEFAULT_DEV, - Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); - SpiCookie* spiRtdIc7 = new SpiCookie(addresses::RTD_IC_10, gpioIds::RTD_IC_10, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, - spi::RTD_SPEED); - SpiCookie* spiRtdIc8 = new SpiCookie(addresses::RTD_IC_11, gpioIds::RTD_IC_11, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, - spi::RTD_SPEED); - SpiCookie* spiRtdIc9 = new SpiCookie(addresses::RTD_IC_12, gpioIds::RTD_IC_12, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, - spi::RTD_SPEED); - SpiCookie* spiRtdIc10 = new SpiCookie(addresses::RTD_IC_13, gpioIds::RTD_IC_13, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, - spi::RTD_SPEED); - SpiCookie* spiRtdIc11 = new SpiCookie(addresses::RTD_IC_14, gpioIds::RTD_IC_14, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, - spi::RTD_SPEED); - SpiCookie* spiRtdIc12 = new SpiCookie(addresses::RTD_IC_15, gpioIds::RTD_IC_15, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, - spi::RTD_SPEED); - SpiCookie* spiRtdIc13 = new SpiCookie(addresses::RTD_IC_16, gpioIds::RTD_IC_16, - std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, - spi::RTD_MODE, spi::RTD_SPEED); - SpiCookie* spiRtdIc14 = new SpiCookie(addresses::RTD_IC_17, gpioIds::RTD_IC_17, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, - spi::RTD_SPEED); - SpiCookie* spiRtdIc15 = new SpiCookie(addresses::RTD_IC_18, gpioIds::RTD_IC_18, - q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, - spi::RTD_SPEED); + SpiCookie* spiRtdIc0 = + new SpiCookie(addresses::RTD_IC_3, gpioIds::RTD_IC_3, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc1 = + new SpiCookie(addresses::RTD_IC_4, gpioIds::RTD_IC_4, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc2 = + new SpiCookie(addresses::RTD_IC_5, gpioIds::RTD_IC_5, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc3 = + new SpiCookie(addresses::RTD_IC_6, gpioIds::RTD_IC_6, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc4 = + new SpiCookie(addresses::RTD_IC_7, gpioIds::RTD_IC_7, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc5 = + new SpiCookie(addresses::RTD_IC_8, gpioIds::RTD_IC_8, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc6 = + new SpiCookie(addresses::RTD_IC_9, gpioIds::RTD_IC_9, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc7 = + new SpiCookie(addresses::RTD_IC_10, gpioIds::RTD_IC_10, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc8 = + new SpiCookie(addresses::RTD_IC_11, gpioIds::RTD_IC_11, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc9 = + new SpiCookie(addresses::RTD_IC_12, gpioIds::RTD_IC_12, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc10 = + new SpiCookie(addresses::RTD_IC_13, gpioIds::RTD_IC_13, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc11 = + new SpiCookie(addresses::RTD_IC_14, gpioIds::RTD_IC_14, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc12 = + new SpiCookie(addresses::RTD_IC_15, gpioIds::RTD_IC_15, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc13 = + new SpiCookie(addresses::RTD_IC_16, gpioIds::RTD_IC_16, std::string(q7s::SPI_DEFAULT_DEV), + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc14 = + new SpiCookie(addresses::RTD_IC_17, gpioIds::RTD_IC_17, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); + SpiCookie* spiRtdIc15 = + new SpiCookie(addresses::RTD_IC_18, gpioIds::RTD_IC_18, q7s::SPI_DEFAULT_DEV, + Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); - Max31865PT1000Handler* rtdIc0 = new Max31865PT1000Handler(objects::RTD_IC_3, objects::SPI_COM_IF, - spiRtdIc0); - Max31865PT1000Handler* rtdIc1 = new Max31865PT1000Handler(objects::RTD_IC_4, objects::SPI_COM_IF, - spiRtdIc1); - Max31865PT1000Handler* rtdIc2 = new Max31865PT1000Handler(objects::RTD_IC_5, objects::SPI_COM_IF, - spiRtdIc2); - Max31865PT1000Handler* rtdIc3 = new Max31865PT1000Handler(objects::RTD_IC_6, objects::SPI_COM_IF, - spiRtdIc3); - Max31865PT1000Handler* rtdIc4 = new Max31865PT1000Handler(objects::RTD_IC_7, objects::SPI_COM_IF, - spiRtdIc4); - Max31865PT1000Handler* rtdIc5 = new Max31865PT1000Handler(objects::RTD_IC_8, objects::SPI_COM_IF, - spiRtdIc5); - Max31865PT1000Handler* rtdIc6 = new Max31865PT1000Handler(objects::RTD_IC_9, objects::SPI_COM_IF, - spiRtdIc6); - Max31865PT1000Handler* rtdIc7 = new Max31865PT1000Handler(objects::RTD_IC_10, - objects::SPI_COM_IF, spiRtdIc7); - Max31865PT1000Handler* rtdIc8 = new Max31865PT1000Handler(objects::RTD_IC_11, - objects::SPI_COM_IF, spiRtdIc8); - Max31865PT1000Handler* rtdIc9 = new Max31865PT1000Handler(objects::RTD_IC_12, - objects::SPI_COM_IF, spiRtdIc9); - Max31865PT1000Handler* rtdIc10 = new Max31865PT1000Handler(objects::RTD_IC_13, - objects::SPI_COM_IF, spiRtdIc10); - Max31865PT1000Handler* rtdIc11 = new Max31865PT1000Handler(objects::RTD_IC_14, - objects::SPI_COM_IF, spiRtdIc11); - Max31865PT1000Handler* rtdIc12 = new Max31865PT1000Handler(objects::RTD_IC_15, - objects::SPI_COM_IF, spiRtdIc12); - Max31865PT1000Handler* rtdIc13 = new Max31865PT1000Handler(objects::RTD_IC_16, - objects::SPI_COM_IF, spiRtdIc13); - Max31865PT1000Handler* rtdIc14 = new Max31865PT1000Handler(objects::RTD_IC_17, - objects::SPI_COM_IF, spiRtdIc14); - Max31865PT1000Handler* rtdIc15 = new Max31865PT1000Handler(objects::RTD_IC_18, - objects::SPI_COM_IF, spiRtdIc15); + Max31865PT1000Handler* rtdIc0 = + new Max31865PT1000Handler(objects::RTD_IC_3, objects::SPI_COM_IF, spiRtdIc0); + Max31865PT1000Handler* rtdIc1 = + new Max31865PT1000Handler(objects::RTD_IC_4, objects::SPI_COM_IF, spiRtdIc1); + Max31865PT1000Handler* rtdIc2 = + new Max31865PT1000Handler(objects::RTD_IC_5, objects::SPI_COM_IF, spiRtdIc2); + Max31865PT1000Handler* rtdIc3 = + new Max31865PT1000Handler(objects::RTD_IC_6, objects::SPI_COM_IF, spiRtdIc3); + Max31865PT1000Handler* rtdIc4 = + new Max31865PT1000Handler(objects::RTD_IC_7, objects::SPI_COM_IF, spiRtdIc4); + Max31865PT1000Handler* rtdIc5 = + new Max31865PT1000Handler(objects::RTD_IC_8, objects::SPI_COM_IF, spiRtdIc5); + Max31865PT1000Handler* rtdIc6 = + new Max31865PT1000Handler(objects::RTD_IC_9, objects::SPI_COM_IF, spiRtdIc6); + Max31865PT1000Handler* rtdIc7 = + new Max31865PT1000Handler(objects::RTD_IC_10, objects::SPI_COM_IF, spiRtdIc7); + Max31865PT1000Handler* rtdIc8 = + new Max31865PT1000Handler(objects::RTD_IC_11, objects::SPI_COM_IF, spiRtdIc8); + Max31865PT1000Handler* rtdIc9 = + new Max31865PT1000Handler(objects::RTD_IC_12, objects::SPI_COM_IF, spiRtdIc9); + Max31865PT1000Handler* rtdIc10 = + new Max31865PT1000Handler(objects::RTD_IC_13, objects::SPI_COM_IF, spiRtdIc10); + Max31865PT1000Handler* rtdIc11 = + new Max31865PT1000Handler(objects::RTD_IC_14, objects::SPI_COM_IF, spiRtdIc11); + Max31865PT1000Handler* rtdIc12 = + new Max31865PT1000Handler(objects::RTD_IC_15, objects::SPI_COM_IF, spiRtdIc12); + Max31865PT1000Handler* rtdIc13 = + new Max31865PT1000Handler(objects::RTD_IC_16, objects::SPI_COM_IF, spiRtdIc13); + Max31865PT1000Handler* rtdIc14 = + new Max31865PT1000Handler(objects::RTD_IC_17, objects::SPI_COM_IF, spiRtdIc14); + Max31865PT1000Handler* rtdIc15 = + new Max31865PT1000Handler(objects::RTD_IC_18, objects::SPI_COM_IF, spiRtdIc15); - rtdIc0->setStartUpImmediately(); - rtdIc1->setStartUpImmediately(); - rtdIc2->setStartUpImmediately(); + rtdIc0->setStartUpImmediately(); + rtdIc1->setStartUpImmediately(); + rtdIc2->setStartUpImmediately(); #if OBSW_DEBUG_RTD == 1 - rtdIc0->setInstantNormal(true); - rtdIc1->setInstantNormal(true); - rtdIc2->setInstantNormal(true); + rtdIc0->setInstantNormal(true); + rtdIc1->setInstantNormal(true); + rtdIc2->setInstantNormal(true); #endif - static_cast(rtdIc0); - static_cast(rtdIc1); - static_cast(rtdIc2); - static_cast(rtdIc3); - static_cast(rtdIc4); - static_cast(rtdIc5); - static_cast(rtdIc6); - static_cast(rtdIc7); - static_cast(rtdIc8); - static_cast(rtdIc9); - static_cast(rtdIc10); - static_cast(rtdIc11); - static_cast(rtdIc12); - static_cast(rtdIc13); - static_cast(rtdIc14); - static_cast(rtdIc15); + static_cast(rtdIc0); + static_cast(rtdIc1); + static_cast(rtdIc2); + static_cast(rtdIc3); + static_cast(rtdIc4); + static_cast(rtdIc5); + static_cast(rtdIc6); + static_cast(rtdIc7); + static_cast(rtdIc8); + static_cast(rtdIc9); + static_cast(rtdIc10); + static_cast(rtdIc11); + static_cast(rtdIc12); + static_cast(rtdIc13); + static_cast(rtdIc14); + static_cast(rtdIc15); } void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF) { - GpioCookie* gpioCookieRw = new GpioCookie; - GpioCallback* csRw1 = new GpioCallback("Chip select reaction wheel 1", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieRw->addGpio(gpioIds::CS_RW1, csRw1); - GpioCallback* csRw2 = new GpioCallback("Chip select reaction wheel 2", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieRw->addGpio(gpioIds::CS_RW2, csRw2); - GpioCallback* csRw3 = new GpioCallback("Chip select reaction wheel 3", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieRw->addGpio(gpioIds::CS_RW3, csRw3); - GpioCallback* csRw4 = new GpioCallback("Chip select reaction wheel 4", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieRw->addGpio(gpioIds::CS_RW4, csRw4); + GpioCookie* gpioCookieRw = new GpioCookie; + GpioCallback* csRw1 = new GpioCallback("Chip select reaction wheel 1", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieRw->addGpio(gpioIds::CS_RW1, csRw1); + GpioCallback* csRw2 = new GpioCallback("Chip select reaction wheel 2", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieRw->addGpio(gpioIds::CS_RW2, csRw2); + GpioCallback* csRw3 = new GpioCallback("Chip select reaction wheel 3", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieRw->addGpio(gpioIds::CS_RW3, csRw3); + GpioCallback* csRw4 = new GpioCallback("Chip select reaction wheel 4", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieRw->addGpio(gpioIds::CS_RW4, csRw4); - std::stringstream consumer; - GpiodRegularByLineName* gpio = nullptr; - consumer << "0x" << std::hex << objects::RW1; - gpio = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_1, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - gpioCookieRw->addGpio(gpioIds::EN_RW1, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::RW2; - gpio = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_2, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - gpioCookieRw->addGpio(gpioIds::EN_RW2, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::RW3; - gpio = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_3, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - gpioCookieRw->addGpio(gpioIds::EN_RW3, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::RW4; - gpio = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_4, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - gpioCookieRw->addGpio(gpioIds::EN_RW4, gpio); + std::stringstream consumer; + GpiodRegularByLineName* gpio = nullptr; + consumer << "0x" << std::hex << objects::RW1; + gpio = + new GpiodRegularByLineName(q7s::gpioNames::EN_RW_1, consumer.str(), gpio::DIR_OUT, gpio::LOW); + gpioCookieRw->addGpio(gpioIds::EN_RW1, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::RW2; + gpio = + new GpiodRegularByLineName(q7s::gpioNames::EN_RW_2, consumer.str(), gpio::DIR_OUT, gpio::LOW); + gpioCookieRw->addGpio(gpioIds::EN_RW2, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::RW3; + gpio = + new GpiodRegularByLineName(q7s::gpioNames::EN_RW_3, consumer.str(), gpio::DIR_OUT, gpio::LOW); + gpioCookieRw->addGpio(gpioIds::EN_RW3, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::RW4; + gpio = + new GpiodRegularByLineName(q7s::gpioNames::EN_RW_4, consumer.str(), gpio::DIR_OUT, gpio::LOW); + gpioCookieRw->addGpio(gpioIds::EN_RW4, gpio); - gpioComIF->addGpios(gpioCookieRw); + gpioComIF->addGpios(gpioCookieRw); - auto rw1SpiCookie = new SpiCookie(addresses::RW1, gpioIds::CS_RW1, q7s::SPI_RW_DEV, - RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, - nullptr); - auto rw2SpiCookie = new SpiCookie(addresses::RW2, gpioIds::CS_RW2, q7s::SPI_RW_DEV, - RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, - nullptr); - auto rw3SpiCookie = new SpiCookie(addresses::RW3, gpioIds::CS_RW3, q7s::SPI_RW_DEV, - RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, - nullptr); - auto rw4SpiCookie = new SpiCookie(addresses::RW4, gpioIds::CS_RW4, q7s::SPI_RW_DEV, - RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, - nullptr); + auto rw1SpiCookie = + new SpiCookie(addresses::RW1, gpioIds::CS_RW1, q7s::SPI_RW_DEV, RwDefinitions::MAX_REPLY_SIZE, + spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, nullptr); + auto rw2SpiCookie = + new SpiCookie(addresses::RW2, gpioIds::CS_RW2, q7s::SPI_RW_DEV, RwDefinitions::MAX_REPLY_SIZE, + spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, nullptr); + auto rw3SpiCookie = + new SpiCookie(addresses::RW3, gpioIds::CS_RW3, q7s::SPI_RW_DEV, RwDefinitions::MAX_REPLY_SIZE, + spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, nullptr); + auto rw4SpiCookie = + new SpiCookie(addresses::RW4, gpioIds::CS_RW4, q7s::SPI_RW_DEV, RwDefinitions::MAX_REPLY_SIZE, + spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, nullptr); - auto rwHandler1 = new RwHandler(objects::RW1, objects::SPI_COM_IF, rw1SpiCookie, gpioComIF, - gpioIds::EN_RW1); + auto rwHandler1 = + new RwHandler(objects::RW1, objects::SPI_COM_IF, rw1SpiCookie, gpioComIF, gpioIds::EN_RW1); #if OBSW_DEBUG_RW == 1 - rwHandler1->setStartUpImmediately(); + rwHandler1->setStartUpImmediately(); #endif - rw1SpiCookie->setCallbackArgs(rwHandler1); + rw1SpiCookie->setCallbackArgs(rwHandler1); - auto rwHandler2 = new RwHandler(objects::RW2, objects::SPI_COM_IF, rw2SpiCookie, gpioComIF, - gpioIds::EN_RW2); + auto rwHandler2 = + new RwHandler(objects::RW2, objects::SPI_COM_IF, rw2SpiCookie, gpioComIF, gpioIds::EN_RW2); #if OBSW_DEBUG_RW == 1 - rwHandler2->setStartUpImmediately(); + rwHandler2->setStartUpImmediately(); #endif - rw2SpiCookie->setCallbackArgs(rwHandler2); + rw2SpiCookie->setCallbackArgs(rwHandler2); - auto rwHandler3 = new RwHandler(objects::RW3, objects::SPI_COM_IF, rw3SpiCookie, gpioComIF, - gpioIds::EN_RW3); + auto rwHandler3 = + new RwHandler(objects::RW3, objects::SPI_COM_IF, rw3SpiCookie, gpioComIF, gpioIds::EN_RW3); #if OBSW_DEBUG_RW == 1 - rwHandler3->setStartUpImmediately(); + rwHandler3->setStartUpImmediately(); #endif - rw3SpiCookie->setCallbackArgs(rwHandler3); + rw3SpiCookie->setCallbackArgs(rwHandler3); - auto rwHandler4 = new RwHandler(objects::RW4, objects::SPI_COM_IF, rw4SpiCookie, gpioComIF, - gpioIds::EN_RW4); + auto rwHandler4 = + new RwHandler(objects::RW4, objects::SPI_COM_IF, rw4SpiCookie, gpioComIF, gpioIds::EN_RW4); #if OBSW_DEBUG_RW == 1 - rwHandler4->setStartUpImmediately(); + rwHandler4->setStartUpImmediately(); #endif - rw4SpiCookie->setCallbackArgs(rwHandler4); + rw4SpiCookie->setCallbackArgs(rwHandler4); } -void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF *gpioComIF) { - // GPIO definitions of signals connected to the virtual channel interfaces of the PTME IP Core - GpioCookie* gpioCookiePtmeIp = new GpioCookie; - GpiodRegularByLineName* gpio = nullptr; - std::stringstream consumer; - consumer << "0x" << std::hex << objects::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; - 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; - 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()); - gpioCookiePtmeIp->addGpio(gpioIds::VC1_PAPB_EMPTY, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::PAPB_VC2; - 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; - 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; - 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; - gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_EMPTY_SIGNAL_VC3, consumer.str()); - gpioCookiePtmeIp->addGpio(gpioIds::VC3_PAPB_EMPTY, gpio); +void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF* gpioComIF) { + // GPIO definitions of signals connected to the virtual channel interfaces of the PTME IP Core + GpioCookie* gpioCookiePtmeIp = new GpioCookie; + GpiodRegularByLineName* gpio = nullptr; + std::stringstream consumer; + consumer << "0x" << std::hex << objects::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; + 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; + 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()); + gpioCookiePtmeIp->addGpio(gpioIds::VC1_PAPB_EMPTY, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::PAPB_VC2; + 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; + 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; + 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; + gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_EMPTY_SIGNAL_VC3, consumer.str()); + gpioCookiePtmeIp->addGpio(gpioIds::VC3_PAPB_EMPTY, gpio); - gpioComIF->addGpios(gpioCookiePtmeIp); + 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); + // 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); - // Creating ptme object and adding virtual channel interfaces - Ptme* ptme = new Ptme(objects::PTME); - ptme->addVcInterface(ccsds::VC0, vc0); - ptme->addVcInterface(ccsds::VC1, vc1); - ptme->addVcInterface(ccsds::VC2, vc2); - ptme->addVcInterface(ccsds::VC3, vc3); + // Creating ptme object and adding virtual channel interfaces + Ptme* ptme = new Ptme(objects::PTME); + ptme->addVcInterface(ccsds::VC0, vc0); + ptme->addVcInterface(ccsds::VC1, vc1); + 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); + 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); + TxRateSetterIF* txRateSetterIF = new PtmeRateSetter(gpioIds::BIT_RATE_SEL, gpioComIF); - 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); + 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); - VirtualChannel* vc = nullptr; - vc = new VirtualChannel(ccsds::VC0, common::VC0_QUEUE_SIZE); - ccsdsHandler->addVirtualChannel(ccsds::VC0, vc); - vc = new VirtualChannel(ccsds::VC1, common::VC1_QUEUE_SIZE); - ccsdsHandler->addVirtualChannel(ccsds::VC1, vc); - vc = new VirtualChannel(ccsds::VC2, common::VC2_QUEUE_SIZE); - ccsdsHandler->addVirtualChannel(ccsds::VC2, vc); - vc = new VirtualChannel(ccsds::VC3, common::VC3_QUEUE_SIZE); - ccsdsHandler->addVirtualChannel(ccsds::VC3, vc); + VirtualChannel* vc = nullptr; + vc = new VirtualChannel(ccsds::VC0, common::VC0_QUEUE_SIZE); + ccsdsHandler->addVirtualChannel(ccsds::VC0, vc); + vc = new VirtualChannel(ccsds::VC1, common::VC1_QUEUE_SIZE); + ccsdsHandler->addVirtualChannel(ccsds::VC1, vc); + vc = new VirtualChannel(ccsds::VC2, common::VC2_QUEUE_SIZE); + ccsdsHandler->addVirtualChannel(ccsds::VC2, vc); + vc = new VirtualChannel(ccsds::VC3, common::VC3_QUEUE_SIZE); + ccsdsHandler->addVirtualChannel(ccsds::VC3, vc); - GpioCookie* gpioCookiePdec = new GpioCookie; - consumer.str(""); - consumer << "0x" << std::hex << objects::PDEC_HANDLER; - // GPIO also low after linux boot (specified by device-tree) - gpio = new GpiodRegularByLineName(q7s::gpioNames::PDEC_RESET, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - gpioCookiePdec->addGpio(gpioIds::PDEC_RESET, gpio); + GpioCookie* gpioCookiePdec = new GpioCookie; + consumer.str(""); + consumer << "0x" << std::hex << objects::PDEC_HANDLER; + // GPIO also low after linux boot (specified by device-tree) + gpio = new GpiodRegularByLineName(q7s::gpioNames::PDEC_RESET, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + gpioCookiePdec->addGpio(gpioIds::PDEC_RESET, gpio); - gpioComIF->addGpios(gpioCookiePdec); + 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)); + 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)); #if BOARD_TE0720 == 0 - GpioCookie* gpioRS485Chip = new GpioCookie; - gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_TX_CLOCK, "RS485 Transceiver", - gpio::Direction::DIR_OUT, gpio::LOW); - gpioRS485Chip->addGpio(gpioIds::RS485_EN_TX_CLOCK, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_TX_DATA, "RS485 Transceiver", - gpio::Direction::DIR_OUT, gpio::LOW); - gpioRS485Chip->addGpio(gpioIds::RS485_EN_TX_DATA, gpio); + GpioCookie* gpioRS485Chip = new GpioCookie; + gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_TX_CLOCK, "RS485 Transceiver", + gpio::Direction::DIR_OUT, gpio::LOW); + gpioRS485Chip->addGpio(gpioIds::RS485_EN_TX_CLOCK, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_TX_DATA, "RS485 Transceiver", + gpio::Direction::DIR_OUT, gpio::LOW); + gpioRS485Chip->addGpio(gpioIds::RS485_EN_TX_DATA, gpio); - // Default configuration enables RX channels (RXEN = LOW) - gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_RX_CLOCK, "RS485 Transceiver", - gpio::Direction::DIR_OUT, gpio::LOW); - gpioRS485Chip->addGpio(gpioIds::RS485_EN_RX_CLOCK, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_RX_DATA, "RS485 Transceiver", - gpio::Direction::DIR_OUT, gpio::LOW); - gpioRS485Chip->addGpio(gpioIds::RS485_EN_RX_DATA, gpio); + // Default configuration enables RX channels (RXEN = LOW) + gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_RX_CLOCK, "RS485 Transceiver", + gpio::Direction::DIR_OUT, gpio::LOW); + gpioRS485Chip->addGpio(gpioIds::RS485_EN_RX_CLOCK, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_RX_DATA, "RS485 Transceiver", + gpio::Direction::DIR_OUT, gpio::LOW); + gpioRS485Chip->addGpio(gpioIds::RS485_EN_RX_DATA, gpio); - gpioComIF->addGpios(gpioRS485Chip); + gpioComIF->addGpios(gpioRS485Chip); #endif /* BOARD_TE0720 == 0 */ } void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) { - #if BOARD_TE0720 == 0 - new Q7STestTask(objects::TEST_TASK); + new Q7STestTask(objects::TEST_TASK); #endif #if BOARD_TE0720 == 1 && OBSW_TEST_LIBGPIOD == 1 #if OBSW_TEST_GPIO_OPEN_BYLABEL == 1 - /* Configure MIO0 as input */ - GpiodRegular* testGpio = new GpiodRegular("MIO0", gpio::DIR_OUT, 0, "/amba_pl/gpio@41200000", 0); + /* Configure MIO0 as input */ + GpiodRegular* testGpio = new GpiodRegular("MIO0", gpio::DIR_OUT, 0, "/amba_pl/gpio@41200000", 0); #elif OBSW_TEST_GPIO_OPEN_BY_LINE_NAME - GpiodRegularByLineName* testGpio = new GpiodRegularByLineName("test-name", "gpio-test", - gpio::DIR_OUT, 0); + GpiodRegularByLineName* testGpio = + new GpiodRegularByLineName("test-name", "gpio-test", gpio::DIR_OUT, 0); #else - /* Configure MIO0 as input */ - GpiodRegular* testGpio = new GpiodRegular("gpiochip0", 0, "MIO0", gpio::IN, 0); + /* Configure MIO0 as input */ + GpiodRegular* testGpio = new GpiodRegular("gpiochip0", 0, "MIO0", gpio::IN, 0); #endif /* OBSW_TEST_GPIO_LABEL == 1 */ - GpioCookie* gpioCookie = new GpioCookie; - gpioCookie->addGpio(gpioIds::TEST_ID_0, testGpio); - new LibgpiodTest(objects::LIBGPIOD_TEST, objects::GPIO_IF, gpioCookie); + GpioCookie* gpioCookie = new GpioCookie; + gpioCookie->addGpio(gpioIds::TEST_ID_0, testGpio); + new LibgpiodTest(objects::LIBGPIOD_TEST, objects::GPIO_IF, gpioCookie); #endif #if BOARD_TE0720 == 1 && OBSW_TEST_SUS_HANDLER == 1 - GpioCookie* gpioCookieSus = new GpioCookie; - GpiodRegular* chipSelectSus = new GpiodRegular(std::string("gpiochip1"), 9, - std::string("Chip Select Sus Sensor"), gpio::DIR_OUT, 1); - gpioCookieSus->addGpio(gpioIds::CS_SUS_1, chipSelectSus); - gpioComIF->addGpios(gpioCookieSus); + GpioCookie* gpioCookieSus = new GpioCookie; + GpiodRegular* chipSelectSus = new GpiodRegular( + std::string("gpiochip1"), 9, std::string("Chip Select Sus Sensor"), gpio::DIR_OUT, 1); + gpioCookieSus->addGpio(gpioIds::CS_SUS_1, chipSelectSus); + gpioComIF->addGpios(gpioCookieSus); - SpiCookie* spiCookieSus = new SpiCookie(addresses::SUS_1, std::string("/dev/spidev1.0"), - SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED); + SpiCookie* spiCookieSus = + new SpiCookie(addresses::SUS_1, std::string("/dev/spidev1.0"), SUS::MAX_CMD_SIZE, + spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED); - new SusHandler(objects::SUS_1, objects::SPI_COM_IF, spiCookieSus, gpioComIF, - gpioIds::CS_SUS_1); + new SusHandler(objects::SUS_1, objects::SPI_COM_IF, spiCookieSus, gpioComIF, gpioIds::CS_SUS_1); #endif #if BOARD_TE0720 == 1 && OBSW_TEST_CCSDS_BRIDGE == 1 - GpioCookie* gpioCookieCcsdsIp = new GpioCookie; - GpiodRegular* papbBusyN = new GpiodRegular(std::string("gpiochip0"), 0, std::string("PAPBBusy_VC0")); - gpioCookieCcsdsIp->addGpio(gpioIds::PAPB_BUSY_N, papbBusyN); - GpiodRegular* papbEmpty = new GpiodRegular(std::string("gpiochip0"), 1, - std::string("PAPBEmpty_VC0")); - gpioCookieCcsdsIp->addGpio(gpioIds::PAPB_EMPTY, papbEmpty); - gpioComIF->addGpios(gpioCookieCcsdsIp); + GpioCookie* gpioCookieCcsdsIp = new GpioCookie; + GpiodRegular* papbBusyN = + new GpiodRegular(std::string("gpiochip0"), 0, std::string("PAPBBusy_VC0")); + gpioCookieCcsdsIp->addGpio(gpioIds::PAPB_BUSY_N, papbBusyN); + GpiodRegular* papbEmpty = + new GpiodRegular(std::string("gpiochip0"), 1, std::string("PAPBEmpty_VC0")); + gpioCookieCcsdsIp->addGpio(gpioIds::PAPB_EMPTY, papbEmpty); + gpioComIF->addGpios(gpioCookieCcsdsIp); - new CCSDSIPCoreBridge(objects::CCSDS_IP_CORE_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR, - objects::TM_STORE, objects::TC_STORE, gpioComIF, std::string("/dev/uio0"), - gpioIds::PAPB_BUSY_N, gpioIds::PAPB_EMPTY); + new CCSDSIPCoreBridge(objects::CCSDS_IP_CORE_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR, + objects::TM_STORE, objects::TC_STORE, gpioComIF, std::string("/dev/uio0"), + gpioIds::PAPB_BUSY_N, gpioIds::PAPB_EMPTY); #endif #if BOARD_TE0720 == 1 && OBSW_TEST_RADIATION_SENSOR_HANDLER == 1 - GpioCookie* gpioCookieRadSensor = new GpioCookie; - GpiodRegular* chipSelectRadSensor = new GpiodRegular(std::string("gpiochip1"), 0, - std::string("Chip select radiation sensor"), gpio::DIR_OUT, 1); - gpioCookieRadSensor->addGpio(gpioIds::CS_RAD_SENSOR, chipSelectRadSensor); - gpioComIF->addGpios(gpioCookieRadSensor); + GpioCookie* gpioCookieRadSensor = new GpioCookie; + GpiodRegular* chipSelectRadSensor = new GpiodRegular( + std::string("gpiochip1"), 0, std::string("Chip select radiation sensor"), gpio::DIR_OUT, 1); + gpioCookieRadSensor->addGpio(gpioIds::CS_RAD_SENSOR, chipSelectRadSensor); + gpioComIF->addGpios(gpioCookieRadSensor); - SpiCookie* spiCookieRadSensor = new SpiCookie(addresses::RAD_SENSOR, gpioIds::CS_RAD_SENSOR, - std::string("/dev/spidev1.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, - spi::DEFAULT_MAX_1227_SPEED); + SpiCookie* spiCookieRadSensor = + new SpiCookie(addresses::RAD_SENSOR, gpioIds::CS_RAD_SENSOR, std::string("/dev/spidev1.0"), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED); - RadiationSensorHandler* radSensor = new RadiationSensorHandler(objects::RAD_SENSOR, - objects::SPI_COM_IF, spiCookieRadSensor); - radSensor->setStartUpImmediately(); + RadiationSensorHandler* radSensor = + new RadiationSensorHandler(objects::RAD_SENSOR, objects::SPI_COM_IF, spiCookieRadSensor); + radSensor->setStartUpImmediately(); #endif #if BOARD_TE0720 == 1 && OBSW_ADD_PLOC_MPSOC == 1 - UartCookie* plocUartCookie = new UartCookie(std::string("/dev/ttyPS1"), 115200, - PLOC_MPSOC::MAX_REPLY_SIZE); - /* Testing PlocMPSoCHandler on TE0720-03-1CFA */ - PlocMPSoCHandler* mpsocPlocHandler = new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, - plocUartCookie); - mpsocPlocHandler->setStartUpImmediately(); + UartCookie* plocUartCookie = + new UartCookie(std::string("/dev/ttyPS1"), 115200, PLOC_MPSOC::MAX_REPLY_SIZE); + /* Testing PlocMPSoCHandler on TE0720-03-1CFA */ + PlocMPSoCHandler* mpsocPlocHandler = + new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, plocUartCookie); + mpsocPlocHandler->setStartUpImmediately(); #endif #if BOARD_TE0720 == 1 && OBSW_TEST_TE7020_HEATER == 1 - /* Configuration for MIO0 on TE0720-03-1CFA */ - GpiodRegular* heaterGpio = new GpiodRegular(std::string("gpiochip0"), 0, std::string("MIO0"), gpio::IN, 0); - GpioCookie* gpioCookie = new GpioCookie; - gpioCookie->addGpio(gpioIds::HEATER_0, heaterGpio); - new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, gpioCookie, objects::PCDU_HANDLER, - pcduSwitches::TCS_BOARD_8V_HEATER_IN); + /* Configuration for MIO0 on TE0720-03-1CFA */ + GpiodRegular* heaterGpio = + new GpiodRegular(std::string("gpiochip0"), 0, std::string("MIO0"), gpio::IN, 0); + GpioCookie* gpioCookie = new GpioCookie; + gpioCookie->addGpio(gpioIds::HEATER_0, heaterGpio); + new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, gpioCookie, objects::PCDU_HANDLER, + pcduSwitches::TCS_BOARD_8V_HEATER_IN); #endif #if BOARD_TE0720 == 1 && OBSW_ADD_PLOC_SUPERVISOR == 1 - /* Configuration for MIO0 on TE0720-03-1CFA */ - UartCookie* plocSupervisorCookie = new UartCookie(objects::PLOC_SUPERVISOR_HANDLER, - std::string("/dev/ttyPS1"), UartModes::NON_CANONICAL, 115200, - PLOC_SPV::MAX_PACKET_SIZE * 20); - plocSupervisorCookie->setNoFixedSizeReply(); - PlocSupervisorHandler* plocSupervisor = new PlocSupervisorHandler( - objects::PLOC_SUPERVISOR_HANDLER, objects::UART_COM_IF, plocSupervisorCookie); - plocSupervisor->setStartUpImmediately(); + /* Configuration for MIO0 on TE0720-03-1CFA */ + UartCookie* plocSupervisorCookie = + new UartCookie(objects::PLOC_SUPERVISOR_HANDLER, std::string("/dev/ttyPS1"), + UartModes::NON_CANONICAL, 115200, PLOC_SPV::MAX_PACKET_SIZE * 20); + plocSupervisorCookie->setNoFixedSizeReply(); + PlocSupervisorHandler* plocSupervisor = new PlocSupervisorHandler( + objects::PLOC_SUPERVISOR_HANDLER, objects::UART_COM_IF, plocSupervisorCookie); + plocSupervisor->setStartUpImmediately(); #endif #if OBSW_ADD_SPI_TEST_CODE == 1 - new SpiTestClass(objects::SPI_TEST, gpioComIF); + new SpiTestClass(objects::SPI_TEST, gpioComIF); #endif - } diff --git a/bsp_q7s/core/ObjectFactory.h b/bsp_q7s/core/ObjectFactory.h index 0e723142..47e06e33 100644 --- a/bsp_q7s/core/ObjectFactory.h +++ b/bsp_q7s/core/ObjectFactory.h @@ -11,7 +11,7 @@ void setStatics(); void produce(void* args); void createCommunicationInterfaces(LinuxLibgpioIF** gpioComIF, UartComIF** uartComIF, - SpiComIF** spiComIF); + SpiComIF** spiComIF); void createTmpComponents(); void createPcduComponents(); void createRadSensorComponent(LinuxLibgpioIF* gpioComIF); @@ -22,9 +22,9 @@ void createSolarArrayDeploymentComponents(); void createSyrlinksComponents(); void createRtdComponents(LinuxLibgpioIF* gpioComIF); void createReactionWheelComponents(LinuxLibgpioIF* gpioComIF); -void createCcsdsComponents(LinuxLibgpioIF *gpioComIF); +void createCcsdsComponents(LinuxLibgpioIF* gpioComIF); void createTestComponents(LinuxLibgpioIF* gpioComIF); -}; +}; // namespace ObjectFactory #endif /* BSP_Q7S_OBJECTFACTORY_H_ */ diff --git a/bsp_q7s/core/ParameterHandler.cpp b/bsp_q7s/core/ParameterHandler.cpp index d6c8f34f..8cee046e 100644 --- a/bsp_q7s/core/ParameterHandler.cpp +++ b/bsp_q7s/core/ParameterHandler.cpp @@ -1,8 +1,5 @@ #include "ParameterHandler.h" -ParameterHandler::ParameterHandler(std::string mountPrefix): mountPrefix(mountPrefix) { -} +ParameterHandler::ParameterHandler(std::string mountPrefix) : mountPrefix(mountPrefix) {} -void ParameterHandler::setMountPrefix(std::string prefix) { - mountPrefix = prefix; -} +void ParameterHandler::setMountPrefix(std::string prefix) { mountPrefix = prefix; } diff --git a/bsp_q7s/core/ParameterHandler.h b/bsp_q7s/core/ParameterHandler.h index 81cbc099..4a108586 100644 --- a/bsp_q7s/core/ParameterHandler.h +++ b/bsp_q7s/core/ParameterHandler.h @@ -4,19 +4,17 @@ #include #include - - class ParameterHandler { -public: - ParameterHandler(std::string mountPrefix); + public: + ParameterHandler(std::string mountPrefix); - void setMountPrefix(std::string prefix); + void setMountPrefix(std::string prefix); - void setUpDummyParameter(); -private: - std::string mountPrefix; - DummyParameter dummyParam; + void setUpDummyParameter(); + + private: + std::string mountPrefix; + DummyParameter dummyParam; }; - #endif /* BSP_Q7S_CORE_PARAMETERHANDLER_H_ */ diff --git a/bsp_q7s/core/obsw.cpp b/bsp_q7s/core/obsw.cpp index e55d5652..a69e94a2 100644 --- a/bsp_q7s/core/obsw.cpp +++ b/bsp_q7s/core/obsw.cpp @@ -1,43 +1,44 @@ #include "obsw.h" -#include "OBSWVersion.h" -#include "OBSWConfig.h" -#include "InitMission.h" -#include "watchdogConf.h" -#include "fsfw/tasks/TaskFactory.h" -#include "fsfw/FSFWVersion.h" - -#include #include +#include + +#include "InitMission.h" +#include "OBSWConfig.h" +#include "OBSWVersion.h" +#include "fsfw/FSFWVersion.h" +#include "fsfw/tasks/TaskFactory.h" +#include "watchdogConf.h" static int OBSW_ALREADY_RUNNING = -2; int obsw::obsw() { - std::cout << "-- EIVE OBSW --" << std::endl; + std::cout << "-- EIVE OBSW --" << std::endl; #if BOARD_TE0720 == 0 - std::cout << "-- Compiled for Linux (Xiphos Q7S) --" << std::endl; + std::cout << "-- Compiled for Linux (Xiphos Q7S) --" << std::endl; #else - std::cout << "-- Compiled for Linux (TE0720) --" << std::endl; + std::cout << "-- Compiled for Linux (TE0720) --" << std::endl; #endif - std::cout << "-- OBSW v" << SW_VERSION << "." << SW_SUBVERSION << - "." << SW_REVISION << ", FSFW v" << FSFW_VERSION << "." << FSFW_SUBVERSION << "." << - FSFW_REVISION << "--" << std::endl; - std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; + std::cout << "-- OBSW v" << SW_VERSION << "." << SW_SUBVERSION << "." << SW_REVISION << ", FSFW v" + << FSFW_VERSION << "." << FSFW_SUBVERSION << "." << FSFW_REVISION << "--" << std::endl; + std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; #if Q7S_CHECK_FOR_ALREADY_RUNNING_IMG == 1 - // Check special file here. This file is created or deleted by the eive-watchdog application - // or systemd service! - if(std::filesystem::exists(watchdog::RUNNING_FILE_NAME)) { - sif::warning << "File " << watchdog::RUNNING_FILE_NAME << " exists so the software might " - "already be running. Aborting.." << std::endl; - return OBSW_ALREADY_RUNNING; - } + // Check special file here. This file is created or deleted by the eive-watchdog application + // or systemd service! + if (std::filesystem::exists(watchdog::RUNNING_FILE_NAME)) { + sif::warning << "File " << watchdog::RUNNING_FILE_NAME + << " exists so the software might " + "already be running. Aborting.." + << std::endl; + return OBSW_ALREADY_RUNNING; + } #endif - initmission::initMission(); + initmission::initMission(); - for(;;) { - /* Suspend main thread by sleeping it. */ - TaskFactory::delayTask(5000); - } - return 0; + for (;;) { + /* Suspend main thread by sleeping it. */ + TaskFactory::delayTask(5000); + } + return 0; } diff --git a/bsp_q7s/devices/PlocMemoryDumper.cpp b/bsp_q7s/devices/PlocMemoryDumper.cpp index cc4361bb..c7ba58bd 100644 --- a/bsp_q7s/devices/PlocMemoryDumper.cpp +++ b/bsp_q7s/devices/PlocMemoryDumper.cpp @@ -1,206 +1,192 @@ -#include -#include "fsfw/ipc/QueueFactory.h" #include "PlocMemoryDumper.h" -#include +#include + #include +#include #include -PlocMemoryDumper::PlocMemoryDumper(object_id_t objectId) : - SystemObject(objectId), commandActionHelper(this), actionHelper(this, nullptr) { - commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); +#include "fsfw/ipc/QueueFactory.h" + +PlocMemoryDumper::PlocMemoryDumper(object_id_t objectId) + : SystemObject(objectId), commandActionHelper(this), actionHelper(this, nullptr) { + commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); } -PlocMemoryDumper::~PlocMemoryDumper() { -} +PlocMemoryDumper::~PlocMemoryDumper() {} ReturnValue_t PlocMemoryDumper::initialize() { + ReturnValue_t result = SystemObject::initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = commandActionHelper.initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = actionHelper.initialize(commandQueue); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } - ReturnValue_t result = SystemObject::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - result = commandActionHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - result = actionHelper.initialize(commandQueue); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t PlocMemoryDumper::performOperation(uint8_t operationCode) { - readCommandQueue(); - doStateMachine(); - return HasReturnvaluesIF::RETURN_OK; + readCommandQueue(); + doStateMachine(); + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t PlocMemoryDumper::executeAction(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { +ReturnValue_t PlocMemoryDumper::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) { + if (state != State::IDLE) { + return IS_BUSY; + } - if (state != State::IDLE) { - return IS_BUSY; - } - - switch (actionId) { + switch (actionId) { case DUMP_MRAM: { - size_t deserializeSize = sizeof(mram.startAddress) + sizeof(mram.endAddress); - SerializeAdapter::deSerialize(&mram.startAddress, &data, &deserializeSize, - SerializeIF::Endianness::BIG); - SerializeAdapter::deSerialize(&mram.endAddress, &data, &deserializeSize, - SerializeIF::Endianness::BIG); - if (mram.endAddress > MAX_MRAM_ADDRESS) { - return MRAM_ADDRESS_TOO_HIGH; - } - if (mram.endAddress <= mram.startAddress) { - return MRAM_INVALID_ADDRESS_COMBINATION; - } - state = State::COMMAND_FIRST_MRAM_DUMP; - break; + size_t deserializeSize = sizeof(mram.startAddress) + sizeof(mram.endAddress); + SerializeAdapter::deSerialize(&mram.startAddress, &data, &deserializeSize, + SerializeIF::Endianness::BIG); + SerializeAdapter::deSerialize(&mram.endAddress, &data, &deserializeSize, + SerializeIF::Endianness::BIG); + if (mram.endAddress > MAX_MRAM_ADDRESS) { + return MRAM_ADDRESS_TOO_HIGH; + } + if (mram.endAddress <= mram.startAddress) { + return MRAM_INVALID_ADDRESS_COMBINATION; + } + state = State::COMMAND_FIRST_MRAM_DUMP; + break; } default: { - sif::warning << "PlocMemoryDumper::executeAction: Received command with invalid action id" - << std::endl; - return INVALID_ACTION_ID; - } + sif::warning << "PlocMemoryDumper::executeAction: Received command with invalid action id" + << std::endl; + return INVALID_ACTION_ID; } + } - return EXECUTION_FINISHED; + return EXECUTION_FINISHED; } -MessageQueueId_t PlocMemoryDumper::getCommandQueue() const { - return commandQueue->getId(); -} +MessageQueueId_t PlocMemoryDumper::getCommandQueue() const { return commandQueue->getId(); } -MessageQueueIF* PlocMemoryDumper::getCommandQueuePtr() { - return commandQueue; -} +MessageQueueIF* PlocMemoryDumper::getCommandQueuePtr() { return commandQueue; } void PlocMemoryDumper::readCommandQueue() { - CommandMessage message; - ReturnValue_t result; + CommandMessage message; + ReturnValue_t result; - for (result = commandQueue->receiveMessage(&message); result == HasReturnvaluesIF::RETURN_OK; - result = commandQueue->receiveMessage(&message)) { - if (result != RETURN_OK) { - continue; - } - result = actionHelper.handleActionMessage(&message); - if (result == HasReturnvaluesIF::RETURN_OK) { - continue; - } - - result = commandActionHelper.handleReply(&message); - if (result == HasReturnvaluesIF::RETURN_OK) { - continue; - } - - sif::debug << "PlocMemoryDumper::readCommandQueue: Received message with invalid format" - << std::endl; + for (result = commandQueue->receiveMessage(&message); result == HasReturnvaluesIF::RETURN_OK; + result = commandQueue->receiveMessage(&message)) { + if (result != RETURN_OK) { + continue; } + result = actionHelper.handleActionMessage(&message); + if (result == HasReturnvaluesIF::RETURN_OK) { + continue; + } + + result = commandActionHelper.handleReply(&message); + if (result == HasReturnvaluesIF::RETURN_OK) { + continue; + } + + sif::debug << "PlocMemoryDumper::readCommandQueue: Received message with invalid format" + << std::endl; + } } void PlocMemoryDumper::doStateMachine() { - switch (state) { + switch (state) { case State::IDLE: - break; + break; case State::COMMAND_FIRST_MRAM_DUMP: - commandNextMramDump(PLOC_SPV::FIRST_MRAM_DUMP); - break; + commandNextMramDump(PLOC_SPV::FIRST_MRAM_DUMP); + break; case State::COMMAND_CONSECUTIVE_MRAM_DUMP: - commandNextMramDump(PLOC_SPV::CONSECUTIVE_MRAM_DUMP); - break; + commandNextMramDump(PLOC_SPV::CONSECUTIVE_MRAM_DUMP); + break; case State::EXECUTING_MRAM_DUMP: - break; + break; default: - sif::debug << "PlocMemoryDumper::doStateMachine: Invalid state" << std::endl; - break; - } + sif::debug << "PlocMemoryDumper::doStateMachine: Invalid state" << std::endl; + break; + } } -void PlocMemoryDumper::stepSuccessfulReceived(ActionId_t actionId, - uint8_t step) { -} +void PlocMemoryDumper::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) {} void PlocMemoryDumper::stepFailedReceived(ActionId_t actionId, uint8_t step, - ReturnValue_t returnCode) { -} + ReturnValue_t returnCode) {} -void PlocMemoryDumper::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) { - -} +void PlocMemoryDumper::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) {} void PlocMemoryDumper::completionSuccessfulReceived(ActionId_t actionId) { - switch (pendingCommand) { + switch (pendingCommand) { case (PLOC_SPV::FIRST_MRAM_DUMP): case (PLOC_SPV::CONSECUTIVE_MRAM_DUMP): - if (mram.endAddress == mram.startAddress) { - triggerEvent(MRAM_DUMP_FINISHED); - state = State::IDLE; - } - else { - state = State::COMMAND_CONSECUTIVE_MRAM_DUMP; - } - break; - default: - sif::debug << "PlocMemoryDumper::completionSuccessfulReceived: Invalid pending command" - << std::endl; + if (mram.endAddress == mram.startAddress) { + triggerEvent(MRAM_DUMP_FINISHED); state = State::IDLE; - break; - } + } else { + state = State::COMMAND_CONSECUTIVE_MRAM_DUMP; + } + break; + default: + sif::debug << "PlocMemoryDumper::completionSuccessfulReceived: Invalid pending command" + << std::endl; + state = State::IDLE; + break; + } } -void PlocMemoryDumper::completionFailedReceived(ActionId_t actionId, - ReturnValue_t returnCode) { - switch(pendingCommand) { - case(PLOC_SPV::FIRST_MRAM_DUMP): - case(PLOC_SPV::CONSECUTIVE_MRAM_DUMP): - triggerEvent(MRAM_DUMP_FAILED, mram.lastStartAddress); - break; +void PlocMemoryDumper::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) { + switch (pendingCommand) { + case (PLOC_SPV::FIRST_MRAM_DUMP): + case (PLOC_SPV::CONSECUTIVE_MRAM_DUMP): + triggerEvent(MRAM_DUMP_FAILED, mram.lastStartAddress); + break; default: - sif::debug << "PlocMemoryDumper::completionFailedReceived: Invalid pending command " - << std::endl; - break; - } - state = State::IDLE; + sif::debug << "PlocMemoryDumper::completionFailedReceived: Invalid pending command " + << std::endl; + break; + } + state = State::IDLE; } void PlocMemoryDumper::commandNextMramDump(ActionId_t dumpCommand) { - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = RETURN_OK; - uint32_t tempStartAddress = 0; - uint32_t tempEndAddress = 0; + uint32_t tempStartAddress = 0; + uint32_t tempEndAddress = 0; - if (mram.endAddress - mram.startAddress > MAX_MRAM_DUMP_SIZE) { - tempStartAddress = mram.startAddress; - tempEndAddress = mram.startAddress + MAX_MRAM_DUMP_SIZE; - mram.startAddress += MAX_MRAM_DUMP_SIZE; - mram.lastStartAddress = tempStartAddress; - } - else { - tempStartAddress = mram.startAddress; - tempEndAddress = mram.endAddress; - mram.startAddress = mram.endAddress; - } + if (mram.endAddress - mram.startAddress > MAX_MRAM_DUMP_SIZE) { + tempStartAddress = mram.startAddress; + tempEndAddress = mram.startAddress + MAX_MRAM_DUMP_SIZE; + mram.startAddress += MAX_MRAM_DUMP_SIZE; + mram.lastStartAddress = tempStartAddress; + } else { + tempStartAddress = mram.startAddress; + tempEndAddress = mram.endAddress; + mram.startAddress = mram.endAddress; + } - MemoryParams params(tempStartAddress, tempEndAddress); + MemoryParams params(tempStartAddress, tempEndAddress); - result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, - dumpCommand, ¶ms); - if (result != RETURN_OK) { - sif::warning << "PlocMemoryDumper::commandNextMramDump: Failed to send mram dump command " - << "with start address " << tempStartAddress << " and end address " - << tempEndAddress << std::endl; - triggerEvent(SEND_MRAM_DUMP_FAILED, result, tempStartAddress); - state = State::IDLE; - pendingCommand = NONE; - return; - } - state = State::EXECUTING_MRAM_DUMP; - pendingCommand = dumpCommand; + result = + commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, dumpCommand, ¶ms); + if (result != RETURN_OK) { + sif::warning << "PlocMemoryDumper::commandNextMramDump: Failed to send mram dump command " + << "with start address " << tempStartAddress << " and end address " + << tempEndAddress << std::endl; + triggerEvent(SEND_MRAM_DUMP_FAILED, result, tempStartAddress); + state = State::IDLE; + pendingCommand = NONE; return; + } + state = State::EXECUTING_MRAM_DUMP; + pendingCommand = dumpCommand; + return; } - diff --git a/bsp_q7s/devices/PlocMemoryDumper.h b/bsp_q7s/devices/PlocMemoryDumper.h index 72b031ae..2ee26824 100644 --- a/bsp_q7s/devices/PlocMemoryDumper.h +++ b/bsp_q7s/devices/PlocMemoryDumper.h @@ -3,18 +3,18 @@ #include #include + #include "OBSWConfig.h" -#include "fsfw/action/CommandActionHelper.h" +#include "bsp_q7s/memory/SdCardManager.h" #include "fsfw/action/ActionHelper.h" -#include "fsfw/action/HasActionsIF.h" +#include "fsfw/action/CommandActionHelper.h" #include "fsfw/action/CommandsActionsIF.h" +#include "fsfw/action/HasActionsIF.h" +#include "fsfw/objectmanager/SystemObject.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/tasks/ExecutableObjectIF.h" -#include "fsfw/objectmanager/SystemObject.h" -#include "bsp_q7s/memory/SdCardManager.h" -#include "linux/fsfwconfig/objects/systemObjectList.h" #include "fsfw/tmtcpacket/SpacePacket.h" - +#include "linux/fsfwconfig/objects/systemObjectList.h" /** * @brief Because the buffer of the linux tty driver is limited to 2 x 65535 bytes, this class is @@ -25,91 +25,90 @@ * @author J. Meier */ class PlocMemoryDumper : public SystemObject, - public HasActionsIF, - public ExecutableObjectIF, - public HasReturnvaluesIF, - public CommandsActionsIF { -public: + public HasActionsIF, + public ExecutableObjectIF, + public HasReturnvaluesIF, + public CommandsActionsIF { + public: + static const ActionId_t NONE = 0; + static const ActionId_t DUMP_MRAM = 1; - static const ActionId_t NONE = 0; - static const ActionId_t DUMP_MRAM = 1; + PlocMemoryDumper(object_id_t objectId); + virtual ~PlocMemoryDumper(); - PlocMemoryDumper(object_id_t objectId); - virtual ~PlocMemoryDumper(); + ReturnValue_t performOperation(uint8_t operationCode = 0) override; + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size); + MessageQueueId_t getCommandQueue() const; + ReturnValue_t initialize() override; + MessageQueueIF* getCommandQueuePtr() override; + void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) override; + void stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) override; + void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) override; + void completionSuccessfulReceived(ActionId_t actionId) override; + void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override; - ReturnValue_t performOperation(uint8_t operationCode = 0) override; - ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size); - MessageQueueId_t getCommandQueue() const; - ReturnValue_t initialize() override; - MessageQueueIF* getCommandQueuePtr() override; - void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) override; - void stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) override; - void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) override; - void completionSuccessfulReceived(ActionId_t actionId) override; - void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override; + private: + static const uint32_t QUEUE_SIZE = 10; -private: + static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MEMORY_DUMPER; - static const uint32_t QUEUE_SIZE = 10; + //! [EXPORT] : [COMMENT] The capacity of the MRAM amounts to 512 kB. Thus the maximum address must + //! not be higher than 0x7d000. + static const ReturnValue_t MRAM_ADDRESS_TOO_HIGH = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] The specified end address is lower than the start address + static const ReturnValue_t MRAM_INVALID_ADDRESS_COMBINATION = MAKE_RETURN_CODE(0xA1); - static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MEMORY_DUMPER; + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MEMORY_DUMPER; - //! [EXPORT] : [COMMENT] The capacity of the MRAM amounts to 512 kB. Thus the maximum address must not be higher than 0x7d000. - static const ReturnValue_t MRAM_ADDRESS_TOO_HIGH = MAKE_RETURN_CODE(0xA0); - //! [EXPORT] : [COMMENT] The specified end address is lower than the start address - static const ReturnValue_t MRAM_INVALID_ADDRESS_COMBINATION = MAKE_RETURN_CODE(0xA1); + //! [EXPORT] : [COMMENT] Failed to send mram dump command to supervisor handler + //! P1: Return value of commandAction function + //! P2: Start address of MRAM to dump with this command + static const Event SEND_MRAM_DUMP_FAILED = MAKE_EVENT(0, severity::LOW); + //! [EXPORT] : [COMMENT] Received completion failure report form PLOC supervisor handler + //! P1: MRAM start address of failing dump command + static const Event MRAM_DUMP_FAILED = MAKE_EVENT(1, severity::LOW); + //! [EXPORT] : [COMMENT] MRAM dump finished successfully + static const Event MRAM_DUMP_FINISHED = MAKE_EVENT(2, severity::LOW); - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MEMORY_DUMPER; + // Maximum size of mram dump which can be retrieved with one command + static const uint32_t MAX_MRAM_DUMP_SIZE = 100000; + static const uint32_t MAX_MRAM_ADDRESS = 0x7d000; - //! [EXPORT] : [COMMENT] Failed to send mram dump command to supervisor handler - //! P1: Return value of commandAction function - //! P2: Start address of MRAM to dump with this command - static const Event SEND_MRAM_DUMP_FAILED = MAKE_EVENT(0, severity::LOW); - //! [EXPORT] : [COMMENT] Received completion failure report form PLOC supervisor handler - //! P1: MRAM start address of failing dump command - static const Event MRAM_DUMP_FAILED = MAKE_EVENT(1, severity::LOW); - //! [EXPORT] : [COMMENT] MRAM dump finished successfully - static const Event MRAM_DUMP_FINISHED = MAKE_EVENT(2, severity::LOW); + MessageQueueIF* commandQueue = nullptr; - // Maximum size of mram dump which can be retrieved with one command - static const uint32_t MAX_MRAM_DUMP_SIZE = 100000; - static const uint32_t MAX_MRAM_ADDRESS = 0x7d000; + CommandActionHelper commandActionHelper; - MessageQueueIF* commandQueue = nullptr; + ActionHelper actionHelper; - CommandActionHelper commandActionHelper; + enum class State : uint8_t { + IDLE, + COMMAND_FIRST_MRAM_DUMP, + COMMAND_CONSECUTIVE_MRAM_DUMP, + EXECUTING_MRAM_DUMP + }; - ActionHelper actionHelper; + State state = State::IDLE; - enum class State: uint8_t { - IDLE, - COMMAND_FIRST_MRAM_DUMP, - COMMAND_CONSECUTIVE_MRAM_DUMP, - EXECUTING_MRAM_DUMP - }; + ActionId_t pendingCommand = NONE; - State state = State::IDLE; + typedef struct MemoryInfo { + // Stores the start address of the next memory range to dump + uint32_t startAddress; + uint32_t endAddress; + // Stores the start address of the last sent dump command + uint32_t lastStartAddress; + } MemoryInfo_t; - ActionId_t pendingCommand = NONE; + MemoryInfo_t mram = {0, 0, 0}; - typedef struct MemoryInfo { - // Stores the start address of the next memory range to dump - uint32_t startAddress; - uint32_t endAddress; - // Stores the start address of the last sent dump command - uint32_t lastStartAddress; - } MemoryInfo_t; + void readCommandQueue(); + void doStateMachine(); - MemoryInfo_t mram = {0, 0, 0}; - - void readCommandQueue(); - void doStateMachine(); - - /** - * @brief Sends the next mram dump command to the PLOC supervisor handler. - */ - void commandNextMramDump(ActionId_t dumpCommand); + /** + * @brief Sends the next mram dump command to the PLOC supervisor handler. + */ + void commandNextMramDump(ActionId_t dumpCommand); }; #endif /* MISSION_DEVICES_PLOCMEMORYDUMPER_H_ */ diff --git a/bsp_q7s/devices/PlocSupervisorHandler.cpp b/bsp_q7s/devices/PlocSupervisorHandler.cpp index 30ea9572..a56c9e1c 100644 --- a/bsp_q7s/devices/PlocSupervisorHandler.cpp +++ b/bsp_q7s/devices/PlocSupervisorHandler.cpp @@ -1,540 +1,530 @@ -#include -#include -#include -#include - #include "PlocSupervisorHandler.h" -#include "OBSWConfig.h" -#include #include +#include #include +#include +#include +#include +#include + +#include "OBSWConfig.h" + PlocSupervisorHandler::PlocSupervisorHandler(object_id_t objectId, object_id_t uartComIFid, - CookieIF * comCookie) : - DeviceHandlerBase(objectId, uartComIFid, comCookie), hkset(this), bootStatusReport(this), latchupStatusReport( - this) { - if (comCookie == NULL) { - sif::error << "PlocSupervisorHandler: Invalid com cookie" << std::endl; - } + CookieIF* comCookie) + : DeviceHandlerBase(objectId, uartComIFid, comCookie), + hkset(this), + bootStatusReport(this), + latchupStatusReport(this) { + if (comCookie == NULL) { + sif::error << "PlocSupervisorHandler: Invalid com cookie" << std::endl; + } } -PlocSupervisorHandler::~PlocSupervisorHandler() { -} +PlocSupervisorHandler::~PlocSupervisorHandler() {} ReturnValue_t PlocSupervisorHandler::initialize() { - ReturnValue_t result = RETURN_OK; - result = DeviceHandlerBase::initialize(); - if (result != RETURN_OK) { - return result; - } - uartComIf = dynamic_cast(communicationInterface); - if (uartComIf == nullptr) { - sif::warning << "PlocSupervisorHandler::initialize: Invalid uart com if" << std::endl; - return INVALID_UART_COM_IF; - } + ReturnValue_t result = RETURN_OK; + result = DeviceHandlerBase::initialize(); + if (result != RETURN_OK) { + return result; + } + uartComIf = dynamic_cast(communicationInterface); + if (uartComIf == nullptr) { + sif::warning << "PlocSupervisorHandler::initialize: Invalid uart com if" << std::endl; + return INVALID_UART_COM_IF; + } #if BOARD_TE0720 == 0 - sdcMan = SdCardManager::instance(); + sdcMan = SdCardManager::instance(); #endif /* BOARD_TE0720 == 0 */ - return result; + return result; } - -void PlocSupervisorHandler::doStartUp(){ +void PlocSupervisorHandler::doStartUp() { #if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 - setMode(MODE_NORMAL); + setMode(MODE_NORMAL); #else - setMode(_MODE_TO_ON); + setMode(_MODE_TO_ON); #endif } -void PlocSupervisorHandler::doShutDown(){ - setMode(_MODE_POWER_DOWN); +void PlocSupervisorHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } + +ReturnValue_t PlocSupervisorHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + return NOTHING_TO_SEND; } -ReturnValue_t PlocSupervisorHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - return NOTHING_TO_SEND; +ReturnValue_t PlocSupervisorHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { + return NOTHING_TO_SEND; } -ReturnValue_t PlocSupervisorHandler::buildTransitionDeviceCommand( - DeviceCommandId_t * id){ - return NOTHING_TO_SEND; -} - -ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t * commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_FAILED; - switch(deviceCommand) { - case(PLOC_SPV::GET_HK_REPORT): { - prepareEmptyCmd(PLOC_SPV::APID_GET_HK_REPORT); - result = RETURN_OK; - break; - } - case(PLOC_SPV::RESTART_MPSOC): { - prepareEmptyCmd(PLOC_SPV::APID_RESTART_MPSOC); - result = RETURN_OK; - break; - } - case(PLOC_SPV::START_MPSOC): { - prepareEmptyCmd(PLOC_SPV::APID_START_MPSOC); - result = RETURN_OK; - break; - } - case(PLOC_SPV::SHUTDOWN_MPSOC): { - prepareEmptyCmd(PLOC_SPV::APID_SHUTWOWN_MPSOC); - result = RETURN_OK; - break; - } - case(PLOC_SPV::SEL_MPSOC_BOOT_IMAGE): { - prepareSelBootImageCmd(commandData); - result = RETURN_OK; - break; - } - case(PLOC_SPV::RESET_MPSOC): { - prepareEmptyCmd(PLOC_SPV::APID_RESET_MPSOC); - result = RETURN_OK; - break; +ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t* commandData, + size_t commandDataLen) { + ReturnValue_t result = RETURN_FAILED; + switch (deviceCommand) { + case (PLOC_SPV::GET_HK_REPORT): { + prepareEmptyCmd(PLOC_SPV::APID_GET_HK_REPORT); + result = RETURN_OK; + break; } - case(PLOC_SPV::SET_TIME_REF): { - result = prepareSetTimeRefCmd(); - break; - } - case(PLOC_SPV::SET_BOOT_TIMEOUT): { - prepareSetBootTimeoutCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::RESTART_MPSOC): { + prepareEmptyCmd(PLOC_SPV::APID_RESTART_MPSOC); + result = RETURN_OK; + break; } - case(PLOC_SPV::SET_MAX_RESTART_TRIES): { - prepareRestartTriesCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::START_MPSOC): { + prepareEmptyCmd(PLOC_SPV::APID_START_MPSOC); + result = RETURN_OK; + break; } - case(PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION): { - prepareDisableHk(); - result = RETURN_OK; - break; + case (PLOC_SPV::SHUTDOWN_MPSOC): { + prepareEmptyCmd(PLOC_SPV::APID_SHUTWOWN_MPSOC); + result = RETURN_OK; + break; } - case(PLOC_SPV::GET_BOOT_STATUS_REPORT): { - prepareEmptyCmd(PLOC_SPV::APID_GET_BOOT_STATUS_RPT); - result = RETURN_OK; - break; + case (PLOC_SPV::SEL_MPSOC_BOOT_IMAGE): { + prepareSelBootImageCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::WATCHDOGS_ENABLE): { - prepareWatchdogsEnableCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::RESET_MPSOC): { + prepareEmptyCmd(PLOC_SPV::APID_RESET_MPSOC); + result = RETURN_OK; + break; } - case(PLOC_SPV::WATCHDOGS_CONFIG_TIMEOUT): { - result = prepareWatchdogsConfigTimeoutCmd(commandData); - break; + case (PLOC_SPV::SET_TIME_REF): { + result = prepareSetTimeRefCmd(); + break; } - case(PLOC_SPV::ENABLE_LATCHUP_ALERT): { - result = prepareLatchupConfigCmd(commandData, deviceCommand); - break; + case (PLOC_SPV::SET_BOOT_TIMEOUT): { + prepareSetBootTimeoutCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::DISABLE_LATCHUP_ALERT): { - result = prepareLatchupConfigCmd(commandData, deviceCommand); - break; + case (PLOC_SPV::SET_MAX_RESTART_TRIES): { + prepareRestartTriesCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::AUTO_CALIBRATE_ALERT): { - result = prepareAutoCalibrateAlertCmd(commandData); - break; + case (PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION): { + prepareDisableHk(); + result = RETURN_OK; + break; } - case(PLOC_SPV::SET_ALERT_LIMIT): { - result = prepareSetAlertLimitCmd(commandData); - break; + case (PLOC_SPV::GET_BOOT_STATUS_REPORT): { + prepareEmptyCmd(PLOC_SPV::APID_GET_BOOT_STATUS_RPT); + result = RETURN_OK; + break; } - case(PLOC_SPV::SET_ALERT_IRQ_FILTER): { - result = prepareSetAlertIrqFilterCmd(commandData); - break; + case (PLOC_SPV::WATCHDOGS_ENABLE): { + prepareWatchdogsEnableCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::SET_ADC_SWEEP_PERIOD): { - result = prepareSetAdcSweetPeriodCmd(commandData); - break; + case (PLOC_SPV::WATCHDOGS_CONFIG_TIMEOUT): { + result = prepareWatchdogsConfigTimeoutCmd(commandData); + break; } - case(PLOC_SPV::SET_ADC_ENABLED_CHANNELS): { - prepareSetAdcEnabledChannelsCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::ENABLE_LATCHUP_ALERT): { + result = prepareLatchupConfigCmd(commandData, deviceCommand); + break; } - case(PLOC_SPV::SET_ADC_WINDOW_AND_STRIDE): { - prepareSetAdcWindowAndStrideCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::DISABLE_LATCHUP_ALERT): { + result = prepareLatchupConfigCmd(commandData, deviceCommand); + break; } - case(PLOC_SPV::SET_ADC_THRESHOLD): { - prepareSetAdcThresholdCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::AUTO_CALIBRATE_ALERT): { + result = prepareAutoCalibrateAlertCmd(commandData); + break; } - case(PLOC_SPV::GET_LATCHUP_STATUS_REPORT): { - prepareEmptyCmd(PLOC_SPV::APID_GET_LATCHUP_STATUS_REPORT); - result = RETURN_OK; - break; + case (PLOC_SPV::SET_ALERT_LIMIT): { + result = prepareSetAlertLimitCmd(commandData); + break; } - case(PLOC_SPV::COPY_ADC_DATA_TO_MRAM): { - prepareEmptyCmd(PLOC_SPV::APID_COPY_ADC_DATA_TO_MRAM); - result = RETURN_OK; - break; + case (PLOC_SPV::SET_ALERT_IRQ_FILTER): { + result = prepareSetAlertIrqFilterCmd(commandData); + break; } - case(PLOC_SPV::ENABLE_NVMS): { - prepareEnableNvmsCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::SET_ADC_SWEEP_PERIOD): { + result = prepareSetAdcSweetPeriodCmd(commandData); + break; } - case(PLOC_SPV::SELECT_NVM): { - prepareSelectNvmCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::SET_ADC_ENABLED_CHANNELS): { + prepareSetAdcEnabledChannelsCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::RUN_AUTO_EM_TESTS): { - result = prepareRunAutoEmTest(commandData); - break; + case (PLOC_SPV::SET_ADC_WINDOW_AND_STRIDE): { + prepareSetAdcWindowAndStrideCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::WIPE_MRAM): { - result = prepareWipeMramCmd(commandData); - break; + case (PLOC_SPV::SET_ADC_THRESHOLD): { + prepareSetAdcThresholdCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::FIRST_MRAM_DUMP): - case(PLOC_SPV::CONSECUTIVE_MRAM_DUMP): - result = prepareDumpMramCmd(commandData); - break; - case(PLOC_SPV::PRINT_CPU_STATS): { - preparePrintCpuStatsCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::GET_LATCHUP_STATUS_REPORT): { + prepareEmptyCmd(PLOC_SPV::APID_GET_LATCHUP_STATUS_REPORT); + result = RETURN_OK; + break; } - case(PLOC_SPV::SET_DBG_VERBOSITY): { - prepareSetDbgVerbosityCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::COPY_ADC_DATA_TO_MRAM): { + prepareEmptyCmd(PLOC_SPV::APID_COPY_ADC_DATA_TO_MRAM); + result = RETURN_OK; + break; } - case(PLOC_SPV::CAN_LOOPBACK_TEST): { - prepareEmptyCmd(PLOC_SPV::APID_CAN_LOOPBACK_TEST); - result = RETURN_OK; - break; + case (PLOC_SPV::ENABLE_NVMS): { + prepareEnableNvmsCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::SET_GPIO): { - prepareSetGpioCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::SELECT_NVM): { + prepareSelectNvmCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::READ_GPIO): { - prepareReadGpioCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::RUN_AUTO_EM_TESTS): { + result = prepareRunAutoEmTest(commandData); + break; } - case(PLOC_SPV::RESTART_SUPERVISOR): { - prepareEmptyCmd(PLOC_SPV::APID_RESTART_SUPERVISOR); - result = RETURN_OK; - break; - } - case(PLOC_SPV::FACTORY_RESET_CLEAR_ALL): { - PLOC_SPV::FactoryReset packet(PLOC_SPV::FactoryReset::Op::CLEAR_ALL); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - result = RETURN_OK; - break; - } - case(PLOC_SPV::FACTORY_RESET_CLEAR_MIRROR): { - PLOC_SPV::FactoryReset packet(PLOC_SPV::FactoryReset::Op::MIRROR_ENTRIES); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - result = RETURN_OK; - break; - } - case(PLOC_SPV::FACTORY_RESET_CLEAR_CIRCULAR): { - PLOC_SPV::FactoryReset packet(PLOC_SPV::FactoryReset::Op::CIRCULAR_ENTRIES); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - result = RETURN_OK; - break; - } - case(PLOC_SPV::UPDATE_AVAILABLE): - case(PLOC_SPV::UPDATE_IMAGE_DATA): - case(PLOC_SPV::UPDATE_VERIFY): - // Simply forward data from PLOC Updater to supervisor - std::memcpy(commandBuffer, commandData, commandDataLen); - rawPacket = commandBuffer; - rawPacketLen = commandDataLen; - nextReplyId = PLOC_SPV::ACK_REPORT; - result = RETURN_OK; - break; - default: - sif::debug << "PlocSupervisorHandler::buildCommandFromCommand: Command not implemented" - << std::endl; - result = DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - break; - } - - if (result == RETURN_OK) { - /** - * Flushing the receive buffer to make sure there are no data left from a faulty reply. - */ - uartComIf->flushUartRxBuffer(comCookie); - } - - return result; -} - -void PlocSupervisorHandler::fillCommandAndReplyMap() { - this->insertInCommandMap(PLOC_SPV::GET_HK_REPORT); - this->insertInCommandMap(PLOC_SPV::RESTART_MPSOC); - this->insertInCommandMap(PLOC_SPV::START_MPSOC); - this->insertInCommandMap(PLOC_SPV::SHUTDOWN_MPSOC); - this->insertInCommandMap(PLOC_SPV::SEL_MPSOC_BOOT_IMAGE); - this->insertInCommandMap(PLOC_SPV::SET_BOOT_TIMEOUT); - this->insertInCommandMap(PLOC_SPV::SET_MAX_RESTART_TRIES); - this->insertInCommandMap(PLOC_SPV::RESET_MPSOC); - this->insertInCommandMap(PLOC_SPV::SET_TIME_REF); - this->insertInCommandMap(PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION); - this->insertInCommandMap(PLOC_SPV::GET_BOOT_STATUS_REPORT); - this->insertInCommandMap(PLOC_SPV::UPDATE_AVAILABLE); - this->insertInCommandMap(PLOC_SPV::UPDATE_VERIFY); - this->insertInCommandMap(PLOC_SPV::UPDATE_IMAGE_DATA); - this->insertInCommandMap(PLOC_SPV::WATCHDOGS_ENABLE); - this->insertInCommandMap(PLOC_SPV::WATCHDOGS_CONFIG_TIMEOUT); - this->insertInCommandMap(PLOC_SPV::ENABLE_LATCHUP_ALERT); - this->insertInCommandMap(PLOC_SPV::DISABLE_LATCHUP_ALERT); - this->insertInCommandMap(PLOC_SPV::AUTO_CALIBRATE_ALERT); - this->insertInCommandMap(PLOC_SPV::SET_ALERT_LIMIT); - this->insertInCommandMap(PLOC_SPV::SET_ALERT_IRQ_FILTER); - this->insertInCommandMap(PLOC_SPV::SET_ADC_SWEEP_PERIOD); - this->insertInCommandMap(PLOC_SPV::SET_ADC_ENABLED_CHANNELS); - this->insertInCommandMap(PLOC_SPV::SET_ADC_WINDOW_AND_STRIDE); - this->insertInCommandMap(PLOC_SPV::SET_ADC_THRESHOLD); - this->insertInCommandMap(PLOC_SPV::GET_LATCHUP_STATUS_REPORT); - this->insertInCommandMap(PLOC_SPV::COPY_ADC_DATA_TO_MRAM); - this->insertInCommandMap(PLOC_SPV::ENABLE_NVMS); - this->insertInCommandMap(PLOC_SPV::SELECT_NVM); - this->insertInCommandMap(PLOC_SPV::RUN_AUTO_EM_TESTS); - this->insertInCommandMap(PLOC_SPV::WIPE_MRAM); - this->insertInCommandMap(PLOC_SPV::PRINT_CPU_STATS); - this->insertInCommandMap(PLOC_SPV::SET_DBG_VERBOSITY); - this->insertInCommandMap(PLOC_SPV::SET_GPIO); - this->insertInCommandMap(PLOC_SPV::READ_GPIO); - this->insertInCommandMap(PLOC_SPV::RESTART_SUPERVISOR); - this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_ALL); - this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_MIRROR); - this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_CIRCULAR); - this->insertInCommandMap(PLOC_SPV::CAN_LOOPBACK_TEST); - this->insertInCommandAndReplyMap(PLOC_SPV::FIRST_MRAM_DUMP, 3); - this->insertInCommandAndReplyMap(PLOC_SPV::CONSECUTIVE_MRAM_DUMP, 3); - this->insertInReplyMap(PLOC_SPV::ACK_REPORT, 3, nullptr, PLOC_SPV::SIZE_ACK_REPORT); - this->insertInReplyMap(PLOC_SPV::EXE_REPORT, 3, nullptr, PLOC_SPV::SIZE_EXE_REPORT); - this->insertInReplyMap(PLOC_SPV::HK_REPORT, 3, &hkset, PLOC_SPV::SIZE_HK_REPORT); - this->insertInReplyMap(PLOC_SPV::BOOT_STATUS_REPORT, 3, &bootStatusReport, - PLOC_SPV::SIZE_BOOT_STATUS_REPORT); - this->insertInReplyMap(PLOC_SPV::LATCHUP_REPORT, 3, &latchupStatusReport, - PLOC_SPV::SIZE_LATCHUP_STATUS_REPORT); -} - -ReturnValue_t PlocSupervisorHandler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { - - if (nextReplyId == PLOC_SPV::FIRST_MRAM_DUMP) { - *foundId = PLOC_SPV::FIRST_MRAM_DUMP; - return parseMramPackets(start, remainingSize, foundLen); - } - else if (nextReplyId == PLOC_SPV::CONSECUTIVE_MRAM_DUMP) { - *foundId = PLOC_SPV::CONSECUTIVE_MRAM_DUMP; - return parseMramPackets(start, remainingSize, foundLen); - } - - ReturnValue_t result = RETURN_OK; - - uint16_t apid = (*(start) << 8 | *(start + 1)) & APID_MASK; - - switch(apid) { - case(PLOC_SPV::APID_ACK_SUCCESS): - *foundLen = PLOC_SPV::SIZE_ACK_REPORT; - *foundId = PLOC_SPV::ACK_REPORT; - break; - case(PLOC_SPV::APID_ACK_FAILURE): - *foundLen = PLOC_SPV::SIZE_ACK_REPORT; - *foundId = PLOC_SPV::ACK_REPORT; - break; - case(PLOC_SPV::APID_HK_REPORT): - *foundLen = PLOC_SPV::SIZE_HK_REPORT; - *foundId = PLOC_SPV::HK_REPORT; - break; - case(PLOC_SPV::APID_BOOT_STATUS_REPORT): - *foundLen = PLOC_SPV::SIZE_BOOT_STATUS_REPORT; - *foundId = PLOC_SPV::BOOT_STATUS_REPORT; - break; - case(PLOC_SPV::APID_LATCHUP_STATUS_REPORT): - *foundLen = PLOC_SPV::SIZE_LATCHUP_STATUS_REPORT; - *foundId = PLOC_SPV::LATCHUP_REPORT; - break; - case(PLOC_SPV::APID_EXE_SUCCESS): - *foundLen = PLOC_SPV::SIZE_EXE_REPORT; - *foundId = PLOC_SPV::EXE_REPORT; - break; - case(PLOC_SPV::APID_EXE_FAILURE): - *foundLen = PLOC_SPV::SIZE_EXE_REPORT; - *foundId = PLOC_SPV::EXE_REPORT; - break; - default: { - sif::debug << "PlocSupervisorHandler::scanForReply: Reply has invalid apid" << std::endl; - *foundLen = remainingSize; - return INVALID_APID; - } - } - - return result; -} - -ReturnValue_t PlocSupervisorHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { - - ReturnValue_t result = RETURN_OK; - - switch (id) { - case PLOC_SPV::ACK_REPORT: { - result = handleAckReport(packet); - break; - } - case (PLOC_SPV::HK_REPORT): { - result = handleHkReport(packet); - break; - } - case (PLOC_SPV::BOOT_STATUS_REPORT): { - result = handleBootStatusReport(packet); - break; - } - case (PLOC_SPV::LATCHUP_REPORT): { - result = handleLatchupStatusReport(packet); - break; + case (PLOC_SPV::WIPE_MRAM): { + result = prepareWipeMramCmd(commandData); + break; } case (PLOC_SPV::FIRST_MRAM_DUMP): case (PLOC_SPV::CONSECUTIVE_MRAM_DUMP): - result = handleMramDumpPacket(id); - break; + result = prepareDumpMramCmd(commandData); + break; + case (PLOC_SPV::PRINT_CPU_STATS): { + preparePrintCpuStatsCmd(commandData); + result = RETURN_OK; + break; + } + case (PLOC_SPV::SET_DBG_VERBOSITY): { + prepareSetDbgVerbosityCmd(commandData); + result = RETURN_OK; + break; + } + case (PLOC_SPV::CAN_LOOPBACK_TEST): { + prepareEmptyCmd(PLOC_SPV::APID_CAN_LOOPBACK_TEST); + result = RETURN_OK; + break; + } + case (PLOC_SPV::SET_GPIO): { + prepareSetGpioCmd(commandData); + result = RETURN_OK; + break; + } + case (PLOC_SPV::READ_GPIO): { + prepareReadGpioCmd(commandData); + result = RETURN_OK; + break; + } + case (PLOC_SPV::RESTART_SUPERVISOR): { + prepareEmptyCmd(PLOC_SPV::APID_RESTART_SUPERVISOR); + result = RETURN_OK; + break; + } + case (PLOC_SPV::FACTORY_RESET_CLEAR_ALL): { + PLOC_SPV::FactoryReset packet(PLOC_SPV::FactoryReset::Op::CLEAR_ALL); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + result = RETURN_OK; + break; + } + case (PLOC_SPV::FACTORY_RESET_CLEAR_MIRROR): { + PLOC_SPV::FactoryReset packet(PLOC_SPV::FactoryReset::Op::MIRROR_ENTRIES); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + result = RETURN_OK; + break; + } + case (PLOC_SPV::FACTORY_RESET_CLEAR_CIRCULAR): { + PLOC_SPV::FactoryReset packet(PLOC_SPV::FactoryReset::Op::CIRCULAR_ENTRIES); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + result = RETURN_OK; + break; + } + case (PLOC_SPV::UPDATE_AVAILABLE): + case (PLOC_SPV::UPDATE_IMAGE_DATA): + case (PLOC_SPV::UPDATE_VERIFY): + // Simply forward data from PLOC Updater to supervisor + std::memcpy(commandBuffer, commandData, commandDataLen); + rawPacket = commandBuffer; + rawPacketLen = commandDataLen; + nextReplyId = PLOC_SPV::ACK_REPORT; + result = RETURN_OK; + break; + default: + sif::debug << "PlocSupervisorHandler::buildCommandFromCommand: Command not implemented" + << std::endl; + result = DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + break; + } + + if (result == RETURN_OK) { + /** + * Flushing the receive buffer to make sure there are no data left from a faulty reply. + */ + uartComIf->flushUartRxBuffer(comCookie); + } + + return result; +} + +void PlocSupervisorHandler::fillCommandAndReplyMap() { + this->insertInCommandMap(PLOC_SPV::GET_HK_REPORT); + this->insertInCommandMap(PLOC_SPV::RESTART_MPSOC); + this->insertInCommandMap(PLOC_SPV::START_MPSOC); + this->insertInCommandMap(PLOC_SPV::SHUTDOWN_MPSOC); + this->insertInCommandMap(PLOC_SPV::SEL_MPSOC_BOOT_IMAGE); + this->insertInCommandMap(PLOC_SPV::SET_BOOT_TIMEOUT); + this->insertInCommandMap(PLOC_SPV::SET_MAX_RESTART_TRIES); + this->insertInCommandMap(PLOC_SPV::RESET_MPSOC); + this->insertInCommandMap(PLOC_SPV::SET_TIME_REF); + this->insertInCommandMap(PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION); + this->insertInCommandMap(PLOC_SPV::GET_BOOT_STATUS_REPORT); + this->insertInCommandMap(PLOC_SPV::UPDATE_AVAILABLE); + this->insertInCommandMap(PLOC_SPV::UPDATE_VERIFY); + this->insertInCommandMap(PLOC_SPV::UPDATE_IMAGE_DATA); + this->insertInCommandMap(PLOC_SPV::WATCHDOGS_ENABLE); + this->insertInCommandMap(PLOC_SPV::WATCHDOGS_CONFIG_TIMEOUT); + this->insertInCommandMap(PLOC_SPV::ENABLE_LATCHUP_ALERT); + this->insertInCommandMap(PLOC_SPV::DISABLE_LATCHUP_ALERT); + this->insertInCommandMap(PLOC_SPV::AUTO_CALIBRATE_ALERT); + this->insertInCommandMap(PLOC_SPV::SET_ALERT_LIMIT); + this->insertInCommandMap(PLOC_SPV::SET_ALERT_IRQ_FILTER); + this->insertInCommandMap(PLOC_SPV::SET_ADC_SWEEP_PERIOD); + this->insertInCommandMap(PLOC_SPV::SET_ADC_ENABLED_CHANNELS); + this->insertInCommandMap(PLOC_SPV::SET_ADC_WINDOW_AND_STRIDE); + this->insertInCommandMap(PLOC_SPV::SET_ADC_THRESHOLD); + this->insertInCommandMap(PLOC_SPV::GET_LATCHUP_STATUS_REPORT); + this->insertInCommandMap(PLOC_SPV::COPY_ADC_DATA_TO_MRAM); + this->insertInCommandMap(PLOC_SPV::ENABLE_NVMS); + this->insertInCommandMap(PLOC_SPV::SELECT_NVM); + this->insertInCommandMap(PLOC_SPV::RUN_AUTO_EM_TESTS); + this->insertInCommandMap(PLOC_SPV::WIPE_MRAM); + this->insertInCommandMap(PLOC_SPV::PRINT_CPU_STATS); + this->insertInCommandMap(PLOC_SPV::SET_DBG_VERBOSITY); + this->insertInCommandMap(PLOC_SPV::SET_GPIO); + this->insertInCommandMap(PLOC_SPV::READ_GPIO); + this->insertInCommandMap(PLOC_SPV::RESTART_SUPERVISOR); + this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_ALL); + this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_MIRROR); + this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_CIRCULAR); + this->insertInCommandMap(PLOC_SPV::CAN_LOOPBACK_TEST); + this->insertInCommandAndReplyMap(PLOC_SPV::FIRST_MRAM_DUMP, 3); + this->insertInCommandAndReplyMap(PLOC_SPV::CONSECUTIVE_MRAM_DUMP, 3); + this->insertInReplyMap(PLOC_SPV::ACK_REPORT, 3, nullptr, PLOC_SPV::SIZE_ACK_REPORT); + this->insertInReplyMap(PLOC_SPV::EXE_REPORT, 3, nullptr, PLOC_SPV::SIZE_EXE_REPORT); + this->insertInReplyMap(PLOC_SPV::HK_REPORT, 3, &hkset, PLOC_SPV::SIZE_HK_REPORT); + this->insertInReplyMap(PLOC_SPV::BOOT_STATUS_REPORT, 3, &bootStatusReport, + PLOC_SPV::SIZE_BOOT_STATUS_REPORT); + this->insertInReplyMap(PLOC_SPV::LATCHUP_REPORT, 3, &latchupStatusReport, + PLOC_SPV::SIZE_LATCHUP_STATUS_REPORT); +} + +ReturnValue_t PlocSupervisorHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + if (nextReplyId == PLOC_SPV::FIRST_MRAM_DUMP) { + *foundId = PLOC_SPV::FIRST_MRAM_DUMP; + return parseMramPackets(start, remainingSize, foundLen); + } else if (nextReplyId == PLOC_SPV::CONSECUTIVE_MRAM_DUMP) { + *foundId = PLOC_SPV::CONSECUTIVE_MRAM_DUMP; + return parseMramPackets(start, remainingSize, foundLen); + } + + ReturnValue_t result = RETURN_OK; + + uint16_t apid = (*(start) << 8 | *(start + 1)) & APID_MASK; + + switch (apid) { + case (PLOC_SPV::APID_ACK_SUCCESS): + *foundLen = PLOC_SPV::SIZE_ACK_REPORT; + *foundId = PLOC_SPV::ACK_REPORT; + break; + case (PLOC_SPV::APID_ACK_FAILURE): + *foundLen = PLOC_SPV::SIZE_ACK_REPORT; + *foundId = PLOC_SPV::ACK_REPORT; + break; + case (PLOC_SPV::APID_HK_REPORT): + *foundLen = PLOC_SPV::SIZE_HK_REPORT; + *foundId = PLOC_SPV::HK_REPORT; + break; + case (PLOC_SPV::APID_BOOT_STATUS_REPORT): + *foundLen = PLOC_SPV::SIZE_BOOT_STATUS_REPORT; + *foundId = PLOC_SPV::BOOT_STATUS_REPORT; + break; + case (PLOC_SPV::APID_LATCHUP_STATUS_REPORT): + *foundLen = PLOC_SPV::SIZE_LATCHUP_STATUS_REPORT; + *foundId = PLOC_SPV::LATCHUP_REPORT; + break; + case (PLOC_SPV::APID_EXE_SUCCESS): + *foundLen = PLOC_SPV::SIZE_EXE_REPORT; + *foundId = PLOC_SPV::EXE_REPORT; + break; + case (PLOC_SPV::APID_EXE_FAILURE): + *foundLen = PLOC_SPV::SIZE_EXE_REPORT; + *foundId = PLOC_SPV::EXE_REPORT; + break; + default: { + sif::debug << "PlocSupervisorHandler::scanForReply: Reply has invalid apid" << std::endl; + *foundLen = remainingSize; + return INVALID_APID; + } + } + + return result; +} + +ReturnValue_t PlocSupervisorHandler::interpretDeviceReply(DeviceCommandId_t id, + const uint8_t* packet) { + ReturnValue_t result = RETURN_OK; + + switch (id) { + case PLOC_SPV::ACK_REPORT: { + result = handleAckReport(packet); + break; + } + case (PLOC_SPV::HK_REPORT): { + result = handleHkReport(packet); + break; + } + case (PLOC_SPV::BOOT_STATUS_REPORT): { + result = handleBootStatusReport(packet); + break; + } + case (PLOC_SPV::LATCHUP_REPORT): { + result = handleLatchupStatusReport(packet); + break; + } + case (PLOC_SPV::FIRST_MRAM_DUMP): + case (PLOC_SPV::CONSECUTIVE_MRAM_DUMP): + result = handleMramDumpPacket(id); + break; case (PLOC_SPV::EXE_REPORT): { - result = handleExecutionReport(packet); - break; + result = handleExecutionReport(packet); + break; } default: { - sif::debug << "PlocSupervisorHandler::interpretDeviceReply: Unknown device reply id" << std::endl; - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } + sif::debug << "PlocSupervisorHandler::interpretDeviceReply: Unknown device reply id" + << std::endl; + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; } + } - return result; + return result; } -void PlocSupervisorHandler::setNormalDatapoolEntriesInvalid(){ +void PlocSupervisorHandler::setNormalDatapoolEntriesInvalid() {} -} - -uint32_t PlocSupervisorHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){ - return 500; -} +uint32_t PlocSupervisorHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } ReturnValue_t PlocSupervisorHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { + LocalDataPoolManager& poolManager) { + localDataPoolMap.emplace(PLOC_SPV::NUM_TMS, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::TEMP_PS, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::TEMP_PL, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::SOC_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::NVM0_1_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::NVM3_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::MISSION_IO_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::FMC_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::NUM_TCS, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CPULOAD, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::AVAILABLEHEAP, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::NUM_TMS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::TEMP_PS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::TEMP_PL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::SOC_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::NVM0_1_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::NVM3_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::MISSION_IO_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::FMC_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::NUM_TCS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::UPTIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CPULOAD, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::AVAILABLEHEAP, new PoolEntry( { 0 })); + localDataPoolMap.emplace(PLOC_SPV::BOOT_SIGNAL, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::RESET_COUNTER, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::BOOT_AFTER_MS, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::BOOT_TIMEOUT_MS, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::ACTIVE_NVM, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::BP0_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::BP1_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::BP2_STATE, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::BOOT_SIGNAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::RESET_COUNTER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::BOOT_AFTER_MS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::BOOT_TIMEOUT_MS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::ACTIVE_NVM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::BP0_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::BP1_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::BP2_STATE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_ID, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CNT0, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CNT1, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CNT2, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CNT3, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CNT4, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CNT5, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CNT6, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_SEC, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MIN, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_HOUR, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_DAY, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MON, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_YEAR, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MSEC, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_IS_SET, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_ID, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CNT0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CNT1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CNT2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CNT3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CNT4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CNT5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CNT6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_SEC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MIN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_HOUR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_DAY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MON, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_YEAR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MSEC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_IS_SET, new PoolEntry( { 0 })); - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command, - uint8_t expectedReplies, bool useAlternateId, - DeviceCommandId_t alternateReplyID) { + uint8_t expectedReplies, + bool useAlternateId, + DeviceCommandId_t alternateReplyID) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + uint8_t enabledReplies = 0; - uint8_t enabledReplies = 0; - - switch (command->first) { + switch (command->first) { case PLOC_SPV::GET_HK_REPORT: { - enabledReplies = 3; - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::HK_REPORT); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::HK_REPORT << " not in replyMap" << std::endl; - } - break; + enabledReplies = 3; + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_SPV::HK_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " + << PLOC_SPV::HK_REPORT << " not in replyMap" << std::endl; + } + break; } case PLOC_SPV::GET_BOOT_STATUS_REPORT: { - enabledReplies = 3; - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::BOOT_STATUS_REPORT); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::BOOT_STATUS_REPORT << " not in replyMap" << std::endl; - } - break; + enabledReplies = 3; + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_SPV::BOOT_STATUS_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " + << PLOC_SPV::BOOT_STATUS_REPORT << " not in replyMap" << std::endl; + } + break; } case PLOC_SPV::GET_LATCHUP_STATUS_REPORT: { - enabledReplies = 3; - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::LATCHUP_REPORT); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::LATCHUP_REPORT << " not in replyMap" << std::endl; - } - break; + enabledReplies = 3; + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_SPV::LATCHUP_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " + << PLOC_SPV::LATCHUP_REPORT << " not in replyMap" << std::endl; + } + break; } case PLOC_SPV::FIRST_MRAM_DUMP: { - enabledReplies = 2; // expected replies will be increased in handleMramDumpPacket - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::FIRST_MRAM_DUMP); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::FIRST_MRAM_DUMP << " not in replyMap" << std::endl; - } - break; + enabledReplies = 2; // expected replies will be increased in handleMramDumpPacket + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_SPV::FIRST_MRAM_DUMP); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " + << PLOC_SPV::FIRST_MRAM_DUMP << " not in replyMap" << std::endl; + } + break; } case PLOC_SPV::CONSECUTIVE_MRAM_DUMP: { - enabledReplies = 2; // expected replies will be increased in handleMramDumpPacket - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::CONSECUTIVE_MRAM_DUMP); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::CONSECUTIVE_MRAM_DUMP << " not in replyMap" << std::endl; - } - break; + enabledReplies = 2; // expected replies will be increased in handleMramDumpPacket + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_SPV::CONSECUTIVE_MRAM_DUMP); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " + << PLOC_SPV::CONSECUTIVE_MRAM_DUMP << " not in replyMap" << std::endl; + } + break; } case PLOC_SPV::RESTART_MPSOC: case PLOC_SPV::START_MPSOC: @@ -574,957 +564,948 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite case PLOC_SPV::FACTORY_RESET_CLEAR_CIRCULAR: case PLOC_SPV::REQUEST_LOGGING_DATA: case PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION: - enabledReplies = 2; - break; + enabledReplies = 2; + break; default: - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Unknown command id" << std::endl; - break; - } + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Unknown command id" << std::endl; + break; + } - /** - * Every command causes at least one acknowledgment and one execution report. Therefore both - * replies will be enabled here. - */ - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::ACK_REPORT); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::ACK_REPORT << " not in replyMap" << std::endl; - } + /** + * Every command causes at least one acknowledgment and one execution report. Therefore both + * replies will be enabled here. + */ + result = + DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, PLOC_SPV::ACK_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " + << PLOC_SPV::ACK_REPORT << " not in replyMap" << std::endl; + } - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::EXE_REPORT); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::EXE_REPORT << " not in replyMap" << std::endl; - } + result = + DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, PLOC_SPV::EXE_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " + << PLOC_SPV::EXE_REPORT << " not in replyMap" << std::endl; + } - return RETURN_OK; + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::verifyPacket(const uint8_t* start, size_t foundLen) { + uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1); - uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1); + uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2); - uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2); + if (receivedCrc != recalculatedCrc) { + return CRC_FAILURE; + } - if (receivedCrc != recalculatedCrc) { - return CRC_FAILURE; - } - - return RETURN_OK; + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::handleAckReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_SPV::SIZE_ACK_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocSupervisorHandler::handleAckReport: CRC failure" << std::endl; + nextReplyId = PLOC_SPV::NONE; + replyRawReplyIfnotWiretapped(data, PLOC_SPV::SIZE_ACK_REPORT); + triggerEvent(SUPV_CRC_FAILURE_EVENT); + sendFailureReport(PLOC_SPV::ACK_REPORT, CRC_FAILURE); + disableAllReplies(); + return RETURN_OK; + } - result = verifyPacket(data, PLOC_SPV::SIZE_ACK_REPORT); - if(result == CRC_FAILURE) { - sif::error << "PlocSupervisorHandler::handleAckReport: CRC failure" << std::endl; - nextReplyId = PLOC_SPV::NONE; - replyRawReplyIfnotWiretapped(data, PLOC_SPV::SIZE_ACK_REPORT); - triggerEvent(SUPV_CRC_FAILURE_EVENT); - sendFailureReport(PLOC_SPV::ACK_REPORT, CRC_FAILURE); - disableAllReplies(); - return RETURN_OK; + uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; + + switch (apid) { + case PLOC_SPV::APID_ACK_FAILURE: { + // TODO: Interpretation of status field in acknowledgment report + sif::debug << "PlocSupervisorHandler::handleAckReport: Received Ack failure report" + << std::endl; + DeviceCommandId_t commandId = getPendingCommand(); + if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { + triggerEvent(SUPV_ACK_FAILURE, commandId); + } + sendFailureReport(PLOC_SPV::ACK_REPORT, RECEIVED_ACK_FAILURE); + disableAllReplies(); + nextReplyId = PLOC_SPV::NONE; + result = IGNORE_REPLY_DATA; + break; } + case PLOC_SPV::APID_ACK_SUCCESS: { + setNextReplyId(); + break; + } + default: { + sif::debug << "PlocSupervisorHandler::handleAckReport: Invalid APID in Ack report" + << std::endl; + result = RETURN_FAILED; + break; + } + } - uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; - - switch(apid) { - case PLOC_SPV::APID_ACK_FAILURE: { - //TODO: Interpretation of status field in acknowledgment report - sif::debug << "PlocSupervisorHandler::handleAckReport: Received Ack failure report" << std::endl; - DeviceCommandId_t commandId = getPendingCommand(); - if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { - triggerEvent(SUPV_ACK_FAILURE, commandId); - } - sendFailureReport(PLOC_SPV::ACK_REPORT, RECEIVED_ACK_FAILURE); - disableAllReplies(); - nextReplyId = PLOC_SPV::NONE; - result = IGNORE_REPLY_DATA; - break; - } - case PLOC_SPV::APID_ACK_SUCCESS: { - setNextReplyId(); - break; - } - default: { - sif::debug << "PlocSupervisorHandler::handleAckReport: Invalid APID in Ack report" << std::endl; - result = RETURN_FAILED; - break; - } - } - - return result; + return result; } ReturnValue_t PlocSupervisorHandler::handleExecutionReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_SPV::SIZE_EXE_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocSupervisorHandler::handleExecutionReport: CRC failure" << std::endl; + nextReplyId = PLOC_SPV::NONE; + return result; + } - result = verifyPacket(data, PLOC_SPV::SIZE_EXE_REPORT); - if(result == CRC_FAILURE) { - sif::error << "PlocSupervisorHandler::handleExecutionReport: CRC failure" << std::endl; - nextReplyId = PLOC_SPV::NONE; - return result; - } + uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; - uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; - - switch (apid) { + switch (apid) { case (PLOC_SPV::APID_EXE_SUCCESS): { - break; + break; } case (PLOC_SPV::APID_EXE_FAILURE): { - //TODO: Interpretation of status field in execution report - sif::error << "PlocSupervisorHandler::handleExecutionReport: Received execution failure report" - << std::endl; - DeviceCommandId_t commandId = getPendingCommand(); - if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { - triggerEvent(SUPV_EXE_FAILURE, commandId); - } - else { - sif::debug << "PlocSupervisorHandler::handleExecutionReport: Unknown command id" << std::endl; - } - sendFailureReport(PLOC_SPV::EXE_REPORT, RECEIVED_EXE_FAILURE); - disableExeReportReply(); - result = IGNORE_REPLY_DATA; - break; + // TODO: Interpretation of status field in execution report + sif::error + << "PlocSupervisorHandler::handleExecutionReport: Received execution failure report" + << std::endl; + DeviceCommandId_t commandId = getPendingCommand(); + if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { + triggerEvent(SUPV_EXE_FAILURE, commandId); + } else { + sif::debug << "PlocSupervisorHandler::handleExecutionReport: Unknown command id" + << std::endl; + } + sendFailureReport(PLOC_SPV::EXE_REPORT, RECEIVED_EXE_FAILURE); + disableExeReportReply(); + result = IGNORE_REPLY_DATA; + break; } default: { - sif::error << "PlocSupervisorHandler::handleExecutionReport: Unknown APID" << std::endl; - result = RETURN_FAILED; - break; - } + sif::error << "PlocSupervisorHandler::handleExecutionReport: Unknown APID" << std::endl; + result = RETURN_FAILED; + break; } + } - nextReplyId = PLOC_SPV::NONE; + nextReplyId = PLOC_SPV::NONE; - return result; + return result; } ReturnValue_t PlocSupervisorHandler::handleHkReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_SPV::SIZE_HK_REPORT); - result = verifyPacket(data, PLOC_SPV::SIZE_HK_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocSupervisorHandler::handleHkReport: Hk report has invalid crc" << std::endl; + } - if(result == CRC_FAILURE) { - sif::error << "PlocSupervisorHandler::handleHkReport: Hk report has invalid crc" - << std::endl; - } + uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET; + hkset.tempPs = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 | + *(data + offset + 3); + offset += 4; + hkset.tempPl = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 | + *(data + offset + 3); + offset += 4; + hkset.tempSup = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 | + *(data + offset + 3); + offset += 4; + hkset.uptime = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 | + *(data + offset + 3); + offset += 4; + hkset.cpuLoad = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 | + *(data + offset + 3); + offset += 4; + hkset.availableHeap = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + hkset.numTcs = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 | + *(data + offset + 3); + offset += 4; + hkset.numTms = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 | + *(data + offset + 3); + offset += 4; + hkset.socState = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 | + *(data + offset + 3); + offset += 4; + hkset.nvm0_1_state = *(data + offset); + offset += 1; + hkset.nvm3_state = *(data + offset); + offset += 1; + hkset.missionIoState = *(data + offset); + offset += 1; + hkset.fmcState = *(data + offset); + offset += 1; - uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET; - hkset.tempPs = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 - | *(data + offset + 3); - offset += 4; - hkset.tempPl = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 - | *(data + offset + 3); - offset += 4; - hkset.tempSup = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 - | *(data + offset + 3); - offset += 4; - hkset.uptime = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 - | *(data + offset + 3); - offset += 4; - hkset.cpuLoad = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 - | *(data + offset + 3); - offset += 4; - hkset.availableHeap = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 - | *(data + offset + 3); - offset += 4; - hkset.numTcs = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 - | *(data + offset + 3); - offset += 4; - hkset.numTms = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 - | *(data + offset + 3); - offset += 4; - hkset.socState = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 - | *(data + offset + 3); - offset += 4; - hkset.nvm0_1_state = *(data + offset); - offset += 1; - hkset.nvm3_state = *(data + offset); - offset += 1; - hkset.missionIoState = *(data + offset); - offset += 1; - hkset.fmcState = *(data + offset); - offset += 1; - - nextReplyId = PLOC_SPV::EXE_REPORT; + nextReplyId = PLOC_SPV::EXE_REPORT; #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PLOC_SUPERVISOR == 1 - sif::info << "PlocSupervisorHandler::handleHkReport: temp_ps: " << hkset.tempPs << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: temp_pl: " << hkset.tempPl << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: temp_sup: " << hkset.tempSup << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: uptime: " << hkset.uptime << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: cpu_load: " << hkset.cpuLoad << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: available_heap: " << hkset.availableHeap << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: num_tcs: " << hkset.numTcs << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: num_tms: " << hkset.numTms << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: soc_state: " << hkset.socState << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: nvm0_1_state: " + sif::info << "PlocSupervisorHandler::handleHkReport: temp_ps: " << hkset.tempPs << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: temp_pl: " << hkset.tempPl << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: temp_sup: " << hkset.tempSup << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: uptime: " << hkset.uptime << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: cpu_load: " << hkset.cpuLoad << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: available_heap: " << hkset.availableHeap + << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: num_tcs: " << hkset.numTcs << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: num_tms: " << hkset.numTms << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: soc_state: " << hkset.socState << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: nvm0_1_state: " << static_cast(hkset.nvm0_1_state.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: nvm3_state: " + sif::info << "PlocSupervisorHandler::handleHkReport: nvm3_state: " << static_cast(hkset.nvm3_state.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: missoin_io_state: " + sif::info << "PlocSupervisorHandler::handleHkReport: missoin_io_state: " << static_cast(hkset.missionIoState.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: fmc_state: " + sif::info << "PlocSupervisorHandler::handleHkReport: fmc_state: " << static_cast(hkset.fmcState.value) << std::endl; #endif - return result; + return result; } ReturnValue_t PlocSupervisorHandler::handleBootStatusReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_SPV::SIZE_BOOT_STATUS_REPORT); - result = verifyPacket(data, PLOC_SPV::SIZE_BOOT_STATUS_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocSupervisorHandler::handleBootStatusReport: Boot status report has invalid" + " crc" + << std::endl; + return result; + } - if(result == CRC_FAILURE) { - sif::error << "PlocSupervisorHandler::handleBootStatusReport: Boot status report has invalid" - " crc" << std::endl; - return result; - } + uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET; + bootStatusReport.bootSignal = *(data + offset); + offset += 1; + bootStatusReport.resetCounter = *(data + offset); + offset += 1; + bootStatusReport.bootAfterMs = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + bootStatusReport.bootTimeoutMs = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + bootStatusReport.activeNvm = *(data + offset); + offset += 1; + bootStatusReport.bp0State = *(data + offset); + offset += 1; + bootStatusReport.bp1State = *(data + offset); + offset += 1; + bootStatusReport.bp2State = *(data + offset); - uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET; - bootStatusReport.bootSignal = *(data + offset); - offset += 1; - bootStatusReport.resetCounter = *(data + offset); - offset += 1; - bootStatusReport.bootAfterMs = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - bootStatusReport.bootTimeoutMs = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - bootStatusReport.activeNvm = *(data + offset); - offset += 1; - bootStatusReport.bp0State = *(data + offset); - offset += 1; - bootStatusReport.bp1State = *(data + offset); - offset += 1; - bootStatusReport.bp2State = *(data + offset); - - nextReplyId = PLOC_SPV::EXE_REPORT; + nextReplyId = PLOC_SPV::EXE_REPORT; #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PLOC_SUPERVISOR == 1 - sif::info << "PlocSupervisorHandler::handleBootStatusReport: Boot signal: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: Boot signal: " << static_cast(bootStatusReport.bootSignal.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleBootStatusReport: Reset counter: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: Reset counter: " << static_cast(bootStatusReport.resetCounter.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleBootStatusReport: BootAfterMs: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: BootAfterMs: " << bootStatusReport.bootAfterMs << " ms" << std::endl; - sif::info << "PlocSupervisorHandler::handleBootStatusReport: BootTimeoutMs: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: BootTimeoutMs: " << bootStatusReport.bootTimeoutMs << " ms" << std::endl; - sif::info << "PlocSupervisorHandler::handleBootStatusReport: Active NVM: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: Active NVM: " << static_cast(bootStatusReport.activeNvm.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP0: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP0: " << static_cast(bootStatusReport.bp0State.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP1: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP1: " << static_cast(bootStatusReport.bp1State.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP2: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP2: " << static_cast(bootStatusReport.bp2State.value) << std::endl; #endif - return result; + return result; } ReturnValue_t PlocSupervisorHandler::handleLatchupStatusReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_SPV::SIZE_LATCHUP_STATUS_REPORT); - result = verifyPacket(data, PLOC_SPV::SIZE_LATCHUP_STATUS_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocSupervisorHandler::handleLatchupStatusReport: Latchup status report has " + << "invalid crc" << std::endl; + return result; + } - if(result == CRC_FAILURE) { - sif::error << "PlocSupervisorHandler::handleLatchupStatusReport: Latchup status report has " - << "invalid crc" << std::endl; - return result; - } + uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET; + latchupStatusReport.id = *(data + offset); + offset += 1; + latchupStatusReport.cnt0 = *(data + offset) << 8 | *(data + offset + 1); + offset += 2; + latchupStatusReport.cnt1 = *(data + offset) << 8 | *(data + offset + 1); + offset += 2; + latchupStatusReport.cnt2 = *(data + offset) << 8 | *(data + offset + 1); + offset += 2; + latchupStatusReport.cnt3 = *(data + offset) << 8 | *(data + offset + 1); + offset += 2; + latchupStatusReport.cnt4 = *(data + offset) << 8 | *(data + offset + 1); + offset += 2; + latchupStatusReport.cnt5 = *(data + offset) << 8 | *(data + offset + 1); + offset += 2; + latchupStatusReport.cnt6 = *(data + offset) << 8 | *(data + offset + 1); + offset += 2; + latchupStatusReport.timeSec = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + latchupStatusReport.timeMin = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + latchupStatusReport.timeHour = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + latchupStatusReport.timeDay = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + latchupStatusReport.timeMon = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + latchupStatusReport.timeYear = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + latchupStatusReport.timeMsec = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + latchupStatusReport.isSet = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; - uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET; - latchupStatusReport.id = *(data + offset); - offset += 1; - latchupStatusReport.cnt0 = *(data + offset) << 8 | *(data + offset + 1); - offset += 2; - latchupStatusReport.cnt1 = *(data + offset) << 8 | *(data + offset + 1); - offset += 2; - latchupStatusReport.cnt2 = *(data + offset) << 8 | *(data + offset + 1); - offset += 2; - latchupStatusReport.cnt3 = *(data + offset) << 8 | *(data + offset + 1); - offset += 2; - latchupStatusReport.cnt4 = *(data + offset) << 8 | *(data + offset + 1); - offset += 2; - latchupStatusReport.cnt5 = *(data + offset) << 8 | *(data + offset + 1); - offset += 2; - latchupStatusReport.cnt6 = *(data + offset) << 8 | *(data + offset + 1); - offset += 2; - latchupStatusReport.timeSec = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - latchupStatusReport.timeMin = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - latchupStatusReport.timeHour = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - latchupStatusReport.timeDay = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - latchupStatusReport.timeMon = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - latchupStatusReport.timeYear = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - latchupStatusReport.timeMsec = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - latchupStatusReport.isSet = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - - nextReplyId = PLOC_SPV::EXE_REPORT; + nextReplyId = PLOC_SPV::EXE_REPORT; #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PLOC_SUPERVISOR == 1 - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Latchup ID: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Latchup ID: " << static_cast(latchupStatusReport.id.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT0: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT0: " << latchupStatusReport.cnt0 << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT1: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT1: " << latchupStatusReport.cnt1 << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT2: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT2: " << latchupStatusReport.cnt2 << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT3: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT3: " << latchupStatusReport.cnt3 << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT4: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT4: " << latchupStatusReport.cnt4 << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT5: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT5: " << latchupStatusReport.cnt5 << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT6: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT6: " << latchupStatusReport.cnt6 << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Sec: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Sec: " << latchupStatusReport.timeSec << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Min: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Min: " << latchupStatusReport.timeMin << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Hour: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Hour: " << latchupStatusReport.timeHour << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Day: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Day: " << latchupStatusReport.timeDay << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Mon: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Mon: " << latchupStatusReport.timeMon << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Year: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Year: " << latchupStatusReport.timeYear << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Msec: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Msec: " << latchupStatusReport.timeMsec << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: isSet: 0x" - << std::hex << latchupStatusReport.timeMsec << std::dec << std::endl; + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: isSet: 0x" << std::hex + << latchupStatusReport.timeMsec << std::dec << std::endl; #endif - return result; + return result; } void PlocSupervisorHandler::setNextReplyId() { - switch(getPendingCommand()) { + switch (getPendingCommand()) { case PLOC_SPV::GET_HK_REPORT: - nextReplyId = PLOC_SPV::HK_REPORT; - break; + nextReplyId = PLOC_SPV::HK_REPORT; + break; case PLOC_SPV::GET_BOOT_STATUS_REPORT: - nextReplyId = PLOC_SPV::BOOT_STATUS_REPORT; - break; + nextReplyId = PLOC_SPV::BOOT_STATUS_REPORT; + break; case PLOC_SPV::GET_LATCHUP_STATUS_REPORT: - nextReplyId = PLOC_SPV::LATCHUP_REPORT; - break; + nextReplyId = PLOC_SPV::LATCHUP_REPORT; + break; case PLOC_SPV::FIRST_MRAM_DUMP: - nextReplyId = PLOC_SPV::FIRST_MRAM_DUMP; - break; + nextReplyId = PLOC_SPV::FIRST_MRAM_DUMP; + break; case PLOC_SPV::CONSECUTIVE_MRAM_DUMP: - nextReplyId = PLOC_SPV::CONSECUTIVE_MRAM_DUMP; - break; + nextReplyId = PLOC_SPV::CONSECUTIVE_MRAM_DUMP; + break; default: - /* If no telemetry is expected the next reply is always the execution report */ - nextReplyId = PLOC_SPV::EXE_REPORT; - break; - } + /* If no telemetry is expected the next reply is always the execution report */ + nextReplyId = PLOC_SPV::EXE_REPORT; + break; + } } -size_t PlocSupervisorHandler::getNextReplyLength(DeviceCommandId_t commandId){ - - size_t replyLen = 0; - - if (nextReplyId == PLOC_SPV::NONE) { - return replyLen; - } - - if (nextReplyId == PLOC_SPV::FIRST_MRAM_DUMP - || nextReplyId == PLOC_SPV::CONSECUTIVE_MRAM_DUMP) { - /** - * Try to read 20 MRAM packets. If reply is larger, the packets will be read with the - * next doSendRead call. The command will be as long active as the packet with the sequence - * count indicating the last packet has not been received. - */ - replyLen = PLOC_SPV::MAX_PACKET_SIZE * 20; - return replyLen; - } - - DeviceReplyIter iter = deviceReplyMap.find(nextReplyId); - if (iter != deviceReplyMap.end()) { - if (iter->second.delayCycles == 0) { - /* Reply inactive */ - return replyLen; - } - replyLen = iter->second.replyLen; - } - else { - sif::debug << "PlocSupervisorHandler::getNextReplyLength: No entry for reply with reply id " - << std::hex << nextReplyId << " in deviceReplyMap" << std::endl; - } +size_t PlocSupervisorHandler::getNextReplyLength(DeviceCommandId_t commandId) { + size_t replyLen = 0; + if (nextReplyId == PLOC_SPV::NONE) { return replyLen; + } + + if (nextReplyId == PLOC_SPV::FIRST_MRAM_DUMP || nextReplyId == PLOC_SPV::CONSECUTIVE_MRAM_DUMP) { + /** + * Try to read 20 MRAM packets. If reply is larger, the packets will be read with the + * next doSendRead call. The command will be as long active as the packet with the sequence + * count indicating the last packet has not been received. + */ + replyLen = PLOC_SPV::MAX_PACKET_SIZE * 20; + return replyLen; + } + + DeviceReplyIter iter = deviceReplyMap.find(nextReplyId); + if (iter != deviceReplyMap.end()) { + if (iter->second.delayCycles == 0) { + /* Reply inactive */ + return replyLen; + } + replyLen = iter->second.replyLen; + } else { + sif::debug << "PlocSupervisorHandler::getNextReplyLength: No entry for reply with reply id " + << std::hex << nextReplyId << " in deviceReplyMap" << std::endl; + } + + return replyLen; } -void PlocSupervisorHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId) { +void PlocSupervisorHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, + DeviceCommandId_t replyId) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + if (wiretappingMode == RAW) { + /* Data already sent in doGetRead() */ + return; + } - if (wiretappingMode == RAW) { - /* Data already sent in doGetRead() */ - return; - } + DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId); + if (iter == deviceReplyMap.end()) { + sif::debug << "PlocSupervisorHandler::handleDeviceTM: Unknown reply id" << std::endl; + return; + } + MessageQueueId_t queueId = iter->second.command->second.sendReplyTo; - DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId); - if (iter == deviceReplyMap.end()) { - sif::debug << "PlocSupervisorHandler::handleDeviceTM: Unknown reply id" << std::endl; - return; - } - MessageQueueId_t queueId = iter->second.command->second.sendReplyTo; + if (queueId == NO_COMMANDER) { + return; + } - if (queueId == NO_COMMANDER) { - return; - } - - result = actionHelper.reportData(queueId, replyId, data, dataSize); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::handleDeviceTM: Failed to report data" << std::endl; - } + result = actionHelper.reportData(queueId, replyId, data, dataSize); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::handleDeviceTM: Failed to report data" << std::endl; + } } void PlocSupervisorHandler::prepareEmptyCmd(uint16_t apid) { - PLOC_SPV::EmptyPacket packet(apid); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + PLOC_SPV::EmptyPacket packet(apid); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } -void PlocSupervisorHandler::prepareSelBootImageCmd(const uint8_t * commandData) { - PLOC_SPV::MPSoCBootSelect packet(*commandData, *(commandData + 1), *(commandData + 2), - *(commandData + 3)); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); +void PlocSupervisorHandler::prepareSelBootImageCmd(const uint8_t* commandData) { + PLOC_SPV::MPSoCBootSelect packet(*commandData, *(commandData + 1), *(commandData + 2), + *(commandData + 3)); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } ReturnValue_t PlocSupervisorHandler::prepareSetTimeRefCmd() { - Clock::TimeOfDay_t time; - ReturnValue_t result = Clock::getDateAndTime(&time); - if (result != RETURN_OK) { - sif::warning << "PlocSupervisorHandler::prepareSetTimeRefCmd: Failed to get current time" - << std::endl; - return GET_TIME_FAILURE; - } - PLOC_SPV::SetTimeRef packet(&time); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; + Clock::TimeOfDay_t time; + ReturnValue_t result = Clock::getDateAndTime(&time); + if (result != RETURN_OK) { + sif::warning << "PlocSupervisorHandler::prepareSetTimeRefCmd: Failed to get current time" + << std::endl; + return GET_TIME_FAILURE; + } + PLOC_SPV::SetTimeRef packet(&time); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } void PlocSupervisorHandler::prepareDisableHk() { - PLOC_SPV::DisablePeriodicHkTransmission packet; - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + PLOC_SPV::DisablePeriodicHkTransmission packet; + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } -void PlocSupervisorHandler::prepareSetBootTimeoutCmd(const uint8_t * commandData) { - uint32_t timeout = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 - | *(commandData + 3); - PLOC_SPV::SetBootTimeout packet(timeout); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); +void PlocSupervisorHandler::prepareSetBootTimeoutCmd(const uint8_t* commandData) { + uint32_t timeout = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 | + *(commandData + 3); + PLOC_SPV::SetBootTimeout packet(timeout); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } -void PlocSupervisorHandler::prepareRestartTriesCmd(const uint8_t * commandData) { - uint8_t restartTries = *(commandData); - PLOC_SPV::SetRestartTries packet(restartTries); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); +void PlocSupervisorHandler::prepareRestartTriesCmd(const uint8_t* commandData) { + uint8_t restartTries = *(commandData); + PLOC_SPV::SetRestartTries packet(restartTries); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } -void PlocSupervisorHandler::prepareWatchdogsEnableCmd(const uint8_t * commandData) { - uint8_t offset = 0; - uint8_t watchdogPs = *(commandData + offset); - offset += 1; - uint8_t watchdogPl = *(commandData + offset); - offset += 1; - uint8_t watchdogInt = *(commandData + offset); - PLOC_SPV::WatchdogsEnable packet(watchdogPs, watchdogPl, watchdogInt); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); +void PlocSupervisorHandler::prepareWatchdogsEnableCmd(const uint8_t* commandData) { + uint8_t offset = 0; + uint8_t watchdogPs = *(commandData + offset); + offset += 1; + uint8_t watchdogPl = *(commandData + offset); + offset += 1; + uint8_t watchdogInt = *(commandData + offset); + PLOC_SPV::WatchdogsEnable packet(watchdogPs, watchdogPl, watchdogInt); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } -ReturnValue_t PlocSupervisorHandler::prepareWatchdogsConfigTimeoutCmd(const uint8_t * commandData) { - uint8_t offset = 0; - uint8_t watchdog = *(commandData + offset); - offset += 1; - if (watchdog > 2) { - return INVALID_WATCHDOG; - } - uint32_t timeout = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16 - | *(commandData + offset + 2) << 8 | *(commandData + offset + 3); - if (timeout < 1000 || timeout > 360000) { - return INVALID_WATCHDOG_TIMEOUT; - } - PLOC_SPV::WatchdogsConfigTimeout packet(watchdog, timeout); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; +ReturnValue_t PlocSupervisorHandler::prepareWatchdogsConfigTimeoutCmd(const uint8_t* commandData) { + uint8_t offset = 0; + uint8_t watchdog = *(commandData + offset); + offset += 1; + if (watchdog > 2) { + return INVALID_WATCHDOG; + } + uint32_t timeout = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16 | + *(commandData + offset + 2) << 8 | *(commandData + offset + 3); + if (timeout < 1000 || timeout > 360000) { + return INVALID_WATCHDOG_TIMEOUT; + } + PLOC_SPV::WatchdogsConfigTimeout packet(watchdog, timeout); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::prepareLatchupConfigCmd(const uint8_t* commandData, - DeviceCommandId_t deviceCommand) { - ReturnValue_t result = RETURN_OK; - uint8_t latchupId = *commandData; - if (latchupId > 6) { - return INVALID_LATCHUP_ID; - } - switch (deviceCommand) { + DeviceCommandId_t deviceCommand) { + ReturnValue_t result = RETURN_OK; + uint8_t latchupId = *commandData; + if (latchupId > 6) { + return INVALID_LATCHUP_ID; + } + switch (deviceCommand) { case (PLOC_SPV::ENABLE_LATCHUP_ALERT): { - PLOC_SPV::LatchupAlert packet(true, latchupId); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - break; + PLOC_SPV::LatchupAlert packet(true, latchupId); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + break; } case (PLOC_SPV::DISABLE_LATCHUP_ALERT): { - PLOC_SPV::LatchupAlert packet(false, latchupId); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - break; + PLOC_SPV::LatchupAlert packet(false, latchupId); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + break; } default: { - sif::debug << "PlocSupervisorHandler::prepareLatchupConfigCmd: Invalid command id" - << std::endl; - result = RETURN_FAILED; - break; + sif::debug << "PlocSupervisorHandler::prepareLatchupConfigCmd: Invalid command id" + << std::endl; + result = RETURN_FAILED; + break; } - } - return result; + } + return result; } ReturnValue_t PlocSupervisorHandler::prepareAutoCalibrateAlertCmd(const uint8_t* commandData) { - uint8_t offset = 0; - uint8_t latchupId = *commandData; - offset += 1; - uint32_t mg = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16 - | *(commandData + offset + 2) << 8 | *(commandData + offset + 3); - if (latchupId > 6) { - return INVALID_LATCHUP_ID; - } - PLOC_SPV::AutoCalibrateAlert packet(latchupId, mg); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; + uint8_t offset = 0; + uint8_t latchupId = *commandData; + offset += 1; + uint32_t mg = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16 | + *(commandData + offset + 2) << 8 | *(commandData + offset + 3); + if (latchupId > 6) { + return INVALID_LATCHUP_ID; + } + PLOC_SPV::AutoCalibrateAlert packet(latchupId, mg); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::prepareSetAlertIrqFilterCmd(const uint8_t* commandData) { - uint8_t latchupId = *commandData; - uint8_t tp = *(commandData + 1); - uint8_t div = *(commandData + 2); - if (latchupId > 6) { - return INVALID_LATCHUP_ID; - } - PLOC_SPV::SetAlertIrqFilter packet(latchupId, tp, div); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; + uint8_t latchupId = *commandData; + uint8_t tp = *(commandData + 1); + uint8_t div = *(commandData + 2); + if (latchupId > 6) { + return INVALID_LATCHUP_ID; + } + PLOC_SPV::SetAlertIrqFilter packet(latchupId, tp, div); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::prepareSetAlertLimitCmd(const uint8_t* commandData) { - uint8_t offset = 0; - uint8_t latchupId = *commandData; - offset += 1; - uint32_t dutycycle = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16 - | *(commandData + offset + 2) << 8 | *(commandData + offset + 3); - if (latchupId > 6) { - return INVALID_LATCHUP_ID; - } - PLOC_SPV::SetAlertlimit packet(latchupId, dutycycle); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; + uint8_t offset = 0; + uint8_t latchupId = *commandData; + offset += 1; + uint32_t dutycycle = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16 | + *(commandData + offset + 2) << 8 | *(commandData + offset + 3); + if (latchupId > 6) { + return INVALID_LATCHUP_ID; + } + PLOC_SPV::SetAlertlimit packet(latchupId, dutycycle); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::prepareSetAdcSweetPeriodCmd(const uint8_t* commandData) { - uint32_t sweepPeriod = *(commandData) << 24 | *(commandData + 1) << 16 - | *(commandData + 2) << 8 | *(commandData + 3); - if (sweepPeriod < 21) { - return SWEEP_PERIOD_TOO_SMALL; - } - PLOC_SPV::SetAdcSweepPeriod packet(sweepPeriod); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; + uint32_t sweepPeriod = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 | + *(commandData + 3); + if (sweepPeriod < 21) { + return SWEEP_PERIOD_TOO_SMALL; + } + PLOC_SPV::SetAdcSweepPeriod packet(sweepPeriod); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } void PlocSupervisorHandler::prepareSetAdcEnabledChannelsCmd(const uint8_t* commandData) { - uint16_t ch = *(commandData) << 8 | *(commandData + 1); - PLOC_SPV::SetAdcEnabledChannels packet(ch); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint16_t ch = *(commandData) << 8 | *(commandData + 1); + PLOC_SPV::SetAdcEnabledChannels packet(ch); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareSetAdcWindowAndStrideCmd(const uint8_t* commandData) { - uint8_t offset = 0; - uint16_t windowSize = *(commandData + offset) << 8 | *(commandData + offset + 1); - offset += 2; - uint16_t stridingStepSize = *(commandData + offset) << 8 | *(commandData + offset + 1); - PLOC_SPV::SetAdcWindowAndStride packet(windowSize, stridingStepSize); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint8_t offset = 0; + uint16_t windowSize = *(commandData + offset) << 8 | *(commandData + offset + 1); + offset += 2; + uint16_t stridingStepSize = *(commandData + offset) << 8 | *(commandData + offset + 1); + PLOC_SPV::SetAdcWindowAndStride packet(windowSize, stridingStepSize); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareSetAdcThresholdCmd(const uint8_t* commandData) { - uint32_t threshold = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 - | *(commandData + 3); - PLOC_SPV::SetAdcThreshold packet(threshold); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint32_t threshold = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 | + *(commandData + 3); + PLOC_SPV::SetAdcThreshold packet(threshold); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareEnableNvmsCmd(const uint8_t* commandData) { - uint8_t n01 = *commandData; - uint8_t n3 = *(commandData + 1); - PLOC_SPV::EnableNvms packet(n01, n3); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint8_t n01 = *commandData; + uint8_t n3 = *(commandData + 1); + PLOC_SPV::EnableNvms packet(n01, n3); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareSelectNvmCmd(const uint8_t* commandData) { - uint8_t mem = *commandData; - PLOC_SPV::SelectNvm packet(mem); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint8_t mem = *commandData; + PLOC_SPV::SelectNvm packet(mem); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } ReturnValue_t PlocSupervisorHandler::prepareRunAutoEmTest(const uint8_t* commandData) { - uint8_t test = *commandData; - if (test != 1 && test != 2) { - return INVALID_TEST_PARAM; - } - PLOC_SPV::RunAutoEmTests packet(test); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; + uint8_t test = *commandData; + if (test != 1 && test != 2) { + return INVALID_TEST_PARAM; + } + PLOC_SPV::RunAutoEmTests packet(test); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::prepareWipeMramCmd(const uint8_t* commandData) { - uint32_t start = 0; - uint32_t stop = 0; - size_t size = sizeof(start) + sizeof(stop); - SerializeAdapter::deSerialize(&start, &commandData, &size, SerializeIF::Endianness::BIG); - SerializeAdapter::deSerialize(&stop, &commandData, &size, SerializeIF::Endianness::BIG); - if ((stop - start) <= 0) { - return INVALID_MRAM_ADDRESSES; - } - PLOC_SPV::MramCmd packet(start, stop, PLOC_SPV::MramCmd::MramAction::WIPE); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; + uint32_t start = 0; + uint32_t stop = 0; + size_t size = sizeof(start) + sizeof(stop); + SerializeAdapter::deSerialize(&start, &commandData, &size, SerializeIF::Endianness::BIG); + SerializeAdapter::deSerialize(&stop, &commandData, &size, SerializeIF::Endianness::BIG); + if ((stop - start) <= 0) { + return INVALID_MRAM_ADDRESSES; + } + PLOC_SPV::MramCmd packet(start, stop, PLOC_SPV::MramCmd::MramAction::WIPE); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::prepareDumpMramCmd(const uint8_t* commandData) { - uint32_t start = 0; - uint32_t stop = 0; - size_t size = sizeof(start) + sizeof(stop); - SerializeAdapter::deSerialize(&start, &commandData, &size, SerializeIF::Endianness::BIG); - SerializeAdapter::deSerialize(&stop, &commandData, &size, SerializeIF::Endianness::BIG); - PLOC_SPV::MramCmd packet(start, stop, PLOC_SPV::MramCmd::MramAction::DUMP); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - if ((stop - start) <= 0) { - return INVALID_MRAM_ADDRESSES; - } - expectedMramDumpPackets = (stop - start) / PLOC_SPV::MAX_DATA_CAPACITY; - if ((stop - start) % PLOC_SPV::MAX_DATA_CAPACITY) { - expectedMramDumpPackets++; - } - receivedMramDumpPackets = 0; - return RETURN_OK; + uint32_t start = 0; + uint32_t stop = 0; + size_t size = sizeof(start) + sizeof(stop); + SerializeAdapter::deSerialize(&start, &commandData, &size, SerializeIF::Endianness::BIG); + SerializeAdapter::deSerialize(&stop, &commandData, &size, SerializeIF::Endianness::BIG); + PLOC_SPV::MramCmd packet(start, stop, PLOC_SPV::MramCmd::MramAction::DUMP); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + if ((stop - start) <= 0) { + return INVALID_MRAM_ADDRESSES; + } + expectedMramDumpPackets = (stop - start) / PLOC_SPV::MAX_DATA_CAPACITY; + if ((stop - start) % PLOC_SPV::MAX_DATA_CAPACITY) { + expectedMramDumpPackets++; + } + receivedMramDumpPackets = 0; + return RETURN_OK; } void PlocSupervisorHandler::preparePrintCpuStatsCmd(const uint8_t* commandData) { - uint8_t en = *commandData; - PLOC_SPV::PrintCpuStats packet(en); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint8_t en = *commandData; + PLOC_SPV::PrintCpuStats packet(en); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareSetDbgVerbosityCmd(const uint8_t* commandData) { - uint8_t vb = *commandData; - PLOC_SPV::SetDbgVerbosity packet(vb); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint8_t vb = *commandData; + PLOC_SPV::SetDbgVerbosity packet(vb); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareSetGpioCmd(const uint8_t* commandData) { - uint8_t port = *commandData; - uint8_t pin = *(commandData + 1); - uint8_t val = *(commandData + 2); - PLOC_SPV::SetGpio packet(port, pin, val); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint8_t port = *commandData; + uint8_t pin = *(commandData + 1); + uint8_t val = *(commandData + 2); + PLOC_SPV::SetGpio packet(port, pin, val); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareReadGpioCmd(const uint8_t* commandData) { - uint8_t port = *commandData; - uint8_t pin = *(commandData + 1); - PLOC_SPV::ReadGpio packet(port, pin); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint8_t port = *commandData; + uint8_t pin = *(commandData + 1); + PLOC_SPV::ReadGpio packet(port, pin); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::packetToOutBuffer(uint8_t* packetData, size_t fullSize) { - memcpy(commandBuffer, packetData, fullSize); - rawPacket = commandBuffer; - rawPacketLen = fullSize; - nextReplyId = PLOC_SPV::ACK_REPORT; + memcpy(commandBuffer, packetData, fullSize); + rawPacket = commandBuffer; + rawPacketLen = fullSize; + nextReplyId = PLOC_SPV::ACK_REPORT; } void PlocSupervisorHandler::disableAllReplies() { + DeviceReplyMap::iterator iter; - DeviceReplyMap::iterator iter; + /* Disable ack reply */ + iter = deviceReplyMap.find(PLOC_SPV::ACK_REPORT); + DeviceReplyInfo* info = &(iter->second); + info->delayCycles = 0; + info->command = deviceCommandMap.end(); - /* Disable ack reply */ - iter = deviceReplyMap.find(PLOC_SPV::ACK_REPORT); - DeviceReplyInfo *info = &(iter->second); - info->delayCycles = 0; - info->command = deviceCommandMap.end(); + DeviceCommandId_t commandId = getPendingCommand(); - DeviceCommandId_t commandId = getPendingCommand(); - - /* If the command expects a telemetry packet the appropriate tm reply will be disabled here */ - switch (commandId) { + /* If the command expects a telemetry packet the appropriate tm reply will be disabled here */ + switch (commandId) { case PLOC_SPV::GET_HK_REPORT: { - iter = deviceReplyMap.find(PLOC_SPV::GET_HK_REPORT); - info = &(iter->second); - info->delayCycles = 0; - info->command = deviceCommandMap.end(); - break; + iter = deviceReplyMap.find(PLOC_SPV::GET_HK_REPORT); + info = &(iter->second); + info->delayCycles = 0; + info->command = deviceCommandMap.end(); + break; } default: { - break; - } + break; } + } - /* We must always disable the execution report reply here */ - disableExeReportReply(); + /* We must always disable the execution report reply here */ + disableExeReportReply(); } void PlocSupervisorHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status) { + DeviceReplyIter iter = deviceReplyMap.find(replyId); - DeviceReplyIter iter = deviceReplyMap.find(replyId); + if (iter == deviceReplyMap.end()) { + sif::debug << "PlocSupervisorHandler::sendFailureReport: Reply not in reply map" << std::endl; + return; + } - if (iter == deviceReplyMap.end()) { - sif::debug << "PlocSupervisorHandler::sendFailureReport: Reply not in reply map" << std::endl; - return; - } + DeviceCommandInfo* info = &(iter->second.command->second); - DeviceCommandInfo* info = &(iter->second.command->second); + if (info == nullptr) { + sif::debug << "PlocSupervisorHandler::sendFailureReport: Reply has no active command" + << std::endl; + return; + } - if (info == nullptr) { - sif::debug << "PlocSupervisorHandler::sendFailureReport: Reply has no active command" << std::endl; - return; - } - - if (info->sendReplyTo != NO_COMMANDER) { - actionHelper.finish(false, info->sendReplyTo, iter->first, status); - } - info->isExecuting = false; + if (info->sendReplyTo != NO_COMMANDER) { + actionHelper.finish(false, info->sendReplyTo, iter->first, status); + } + info->isExecuting = false; } void PlocSupervisorHandler::disableExeReportReply() { - DeviceReplyIter iter = deviceReplyMap.find(PLOC_SPV::EXE_REPORT); - DeviceReplyInfo *info = &(iter->second); - info->delayCycles = 0; - info->command = deviceCommandMap.end(); - /* Expected replies is set to one here. The value will set to 0 in replyToReply() */ - info->command->second.expectedReplies = 1; + DeviceReplyIter iter = deviceReplyMap.find(PLOC_SPV::EXE_REPORT); + DeviceReplyInfo* info = &(iter->second); + info->delayCycles = 0; + info->command = deviceCommandMap.end(); + /* Expected replies is set to one here. The value will set to 0 in replyToReply() */ + info->command->second.expectedReplies = 1; } -ReturnValue_t PlocSupervisorHandler::parseMramPackets(const uint8_t *packet, size_t remainingSize, - size_t* foundLen) { - ReturnValue_t result = IGNORE_FULL_PACKET; - uint16_t packetLen = 0; - *foundLen = 0; +ReturnValue_t PlocSupervisorHandler::parseMramPackets(const uint8_t* packet, size_t remainingSize, + size_t* foundLen) { + ReturnValue_t result = IGNORE_FULL_PACKET; + uint16_t packetLen = 0; + *foundLen = 0; - for (size_t idx = 0; idx < remainingSize; idx++) { - std::memcpy(spacePacketBuffer + bufferTop, packet + idx, 1); - bufferTop += 1; - *foundLen += 1; - if (bufferTop >= PLOC_SPV::SPACE_PACKET_HEADER_LENGTH) { - packetLen = readSpacePacketLength(spacePacketBuffer); - } - - if (bufferTop == PLOC_SPV::SPACE_PACKET_HEADER_LENGTH + packetLen + 1) { - packetInBuffer = true; - bufferTop = 0; - return checkMramPacketApid(); - } - - if (bufferTop == PLOC_SPV::MAX_PACKET_SIZE) { - *foundLen = remainingSize; - disableAllReplies(); - bufferTop = 0; - return MRAM_PACKET_PARSING_FAILURE; - } + for (size_t idx = 0; idx < remainingSize; idx++) { + std::memcpy(spacePacketBuffer + bufferTop, packet + idx, 1); + bufferTop += 1; + *foundLen += 1; + if (bufferTop >= PLOC_SPV::SPACE_PACKET_HEADER_LENGTH) { + packetLen = readSpacePacketLength(spacePacketBuffer); } - return result; + if (bufferTop == PLOC_SPV::SPACE_PACKET_HEADER_LENGTH + packetLen + 1) { + packetInBuffer = true; + bufferTop = 0; + return checkMramPacketApid(); + } + + if (bufferTop == PLOC_SPV::MAX_PACKET_SIZE) { + *foundLen = remainingSize; + disableAllReplies(); + bufferTop = 0; + return MRAM_PACKET_PARSING_FAILURE; + } + } + + return result; } ReturnValue_t PlocSupervisorHandler::handleMramDumpPacket(DeviceCommandId_t id) { + ReturnValue_t result = RETURN_FAILED; - ReturnValue_t result = RETURN_FAILED; - - // Prepare packet for downlink - if (packetInBuffer) { - uint16_t packetLen = readSpacePacketLength(spacePacketBuffer); - result = verifyPacket(spacePacketBuffer, PLOC_SPV::SPACE_PACKET_HEADER_LENGTH + packetLen + 1); - if (result != RETURN_OK) { - sif::warning << "PlocSupervisorHandler::handleMramDumpPacket: CRC failure" << std::endl; - return result; - } - handleMramDumpFile(id); - if (downlinkMramDump == true) { - handleDeviceTM(spacePacketBuffer + PLOC_SPV::SPACE_PACKET_HEADER_LENGTH, packetLen - 1, - id); - } - packetInBuffer = false; - receivedMramDumpPackets++; - if (expectedMramDumpPackets == receivedMramDumpPackets) { - nextReplyId = PLOC_SPV::EXE_REPORT; - } - increaseExpectedMramReplies(id); - return RETURN_OK; + // Prepare packet for downlink + if (packetInBuffer) { + uint16_t packetLen = readSpacePacketLength(spacePacketBuffer); + result = verifyPacket(spacePacketBuffer, PLOC_SPV::SPACE_PACKET_HEADER_LENGTH + packetLen + 1); + if (result != RETURN_OK) { + sif::warning << "PlocSupervisorHandler::handleMramDumpPacket: CRC failure" << std::endl; + return result; } - return result; + handleMramDumpFile(id); + if (downlinkMramDump == true) { + handleDeviceTM(spacePacketBuffer + PLOC_SPV::SPACE_PACKET_HEADER_LENGTH, packetLen - 1, id); + } + packetInBuffer = false; + receivedMramDumpPackets++; + if (expectedMramDumpPackets == receivedMramDumpPackets) { + nextReplyId = PLOC_SPV::EXE_REPORT; + } + increaseExpectedMramReplies(id); + return RETURN_OK; + } + return result; } void PlocSupervisorHandler::increaseExpectedMramReplies(DeviceCommandId_t id) { - DeviceReplyMap::iterator mramDumpIter = deviceReplyMap.find(id); - DeviceReplyMap::iterator exeReportIter = deviceReplyMap.find(PLOC_SPV::EXE_REPORT); - if (mramDumpIter == deviceReplyMap.end()) { - sif::debug << "PlocSupervisorHandler::increaseExpectedMramReplies: Dump MRAM reply not " - << "in reply map" << std::endl; - return; - } - if (exeReportIter == deviceReplyMap.end()) { - sif::debug << "PlocSupervisorHandler::increaseExpectedMramReplies: Execution report not " - << "in reply map" << std::endl; - return; - } - DeviceReplyInfo *mramReplyInfo = &(mramDumpIter->second); - if (mramReplyInfo == nullptr) { - sif::debug << "PlocSupervisorHandler::increaseExpectedReplies: MRAM reply info nullptr" - << std::endl; - return; - } - DeviceReplyInfo *exeReplyInfo = &(exeReportIter->second); - if (exeReplyInfo == nullptr) { - sif::debug << "PlocSupervisorHandler::increaseExpectedReplies: Execution reply info" - << " nullptr" << std::endl; - return; - } - DeviceCommandInfo* info = &(mramReplyInfo->command->second); - if (info == nullptr){ - sif::debug << "PlocSupervisorHandler::increaseExpectedReplies: Command info nullptr" - << std::endl; - return; - } - uint8_t sequenceFlags = spacePacketBuffer[2] >> 6; - if (sequenceFlags != static_cast(PLOC_SPV::SequenceFlags::LAST_PKT) - && (sequenceFlags != static_cast(PLOC_SPV::SequenceFlags::STANDALONE_PKT))) { - // Command expects at least one MRAM packet more and the execution report - info->expectedReplies = 2; - // Wait maximum of 2 cycles for next MRAM packet - mramReplyInfo->delayCycles = 2; - // Also adapting delay cycles for execution report - exeReplyInfo->delayCycles = 3; - } - else { - // Command expects the execution report - info->expectedReplies = 1; - mramReplyInfo->delayCycles = 0; - } + DeviceReplyMap::iterator mramDumpIter = deviceReplyMap.find(id); + DeviceReplyMap::iterator exeReportIter = deviceReplyMap.find(PLOC_SPV::EXE_REPORT); + if (mramDumpIter == deviceReplyMap.end()) { + sif::debug << "PlocSupervisorHandler::increaseExpectedMramReplies: Dump MRAM reply not " + << "in reply map" << std::endl; return; + } + if (exeReportIter == deviceReplyMap.end()) { + sif::debug << "PlocSupervisorHandler::increaseExpectedMramReplies: Execution report not " + << "in reply map" << std::endl; + return; + } + DeviceReplyInfo* mramReplyInfo = &(mramDumpIter->second); + if (mramReplyInfo == nullptr) { + sif::debug << "PlocSupervisorHandler::increaseExpectedReplies: MRAM reply info nullptr" + << std::endl; + return; + } + DeviceReplyInfo* exeReplyInfo = &(exeReportIter->second); + if (exeReplyInfo == nullptr) { + sif::debug << "PlocSupervisorHandler::increaseExpectedReplies: Execution reply info" + << " nullptr" << std::endl; + return; + } + DeviceCommandInfo* info = &(mramReplyInfo->command->second); + if (info == nullptr) { + sif::debug << "PlocSupervisorHandler::increaseExpectedReplies: Command info nullptr" + << std::endl; + return; + } + uint8_t sequenceFlags = spacePacketBuffer[2] >> 6; + if (sequenceFlags != static_cast(PLOC_SPV::SequenceFlags::LAST_PKT) && + (sequenceFlags != static_cast(PLOC_SPV::SequenceFlags::STANDALONE_PKT))) { + // Command expects at least one MRAM packet more and the execution report + info->expectedReplies = 2; + // Wait maximum of 2 cycles for next MRAM packet + mramReplyInfo->delayCycles = 2; + // Also adapting delay cycles for execution report + exeReplyInfo->delayCycles = 3; + } else { + // Command expects the execution report + info->expectedReplies = 1; + mramReplyInfo->delayCycles = 0; + } + return; } ReturnValue_t PlocSupervisorHandler::checkMramPacketApid() { - uint16_t apid = (spacePacketBuffer[0] << 8 | spacePacketBuffer[1]) & PLOC_SPV::APID_MASK; - if (apid != PLOC_SPV::APID_MRAM_DUMP_TM) { - return NO_MRAM_PACKET; - } - return APERIODIC_REPLY; + uint16_t apid = (spacePacketBuffer[0] << 8 | spacePacketBuffer[1]) & PLOC_SPV::APID_MASK; + if (apid != PLOC_SPV::APID_MRAM_DUMP_TM) { + return NO_MRAM_PACKET; + } + return APERIODIC_REPLY; } ReturnValue_t PlocSupervisorHandler::handleMramDumpFile(DeviceCommandId_t id) { - ReturnValue_t result = RETURN_OK; - uint16_t packetLen = readSpacePacketLength(spacePacketBuffer); - uint8_t sequenceFlags = readSequenceFlags(spacePacketBuffer); - if (id == PLOC_SPV::FIRST_MRAM_DUMP) { - if (sequenceFlags == static_cast(PLOC_SPV::SequenceFlags::FIRST_PKT) - || (sequenceFlags == static_cast(PLOC_SPV::SequenceFlags::STANDALONE_PKT))) { - result = createMramDumpFile(); - if (result != RETURN_OK) { - return result; - } - } + ReturnValue_t result = RETURN_OK; + uint16_t packetLen = readSpacePacketLength(spacePacketBuffer); + uint8_t sequenceFlags = readSequenceFlags(spacePacketBuffer); + if (id == PLOC_SPV::FIRST_MRAM_DUMP) { + if (sequenceFlags == static_cast(PLOC_SPV::SequenceFlags::FIRST_PKT) || + (sequenceFlags == static_cast(PLOC_SPV::SequenceFlags::STANDALONE_PKT))) { + result = createMramDumpFile(); + if (result != RETURN_OK) { + return result; + } } - if (not std::filesystem::exists(activeMramFile)) { - sif::warning << "PlocSupervisorHandler::handleMramDumpFile: MRAM file does not exist" - << std::endl; - return MRAM_FILE_NOT_EXISTS; - } - std::ofstream file(activeMramFile, std::ios_base::app | std::ios_base::out); - file.write( - reinterpret_cast(spacePacketBuffer + PLOC_SPV::SPACE_PACKET_HEADER_LENGTH), - packetLen - 1); - file.close(); - return RETURN_OK; + } + if (not std::filesystem::exists(activeMramFile)) { + sif::warning << "PlocSupervisorHandler::handleMramDumpFile: MRAM file does not exist" + << std::endl; + return MRAM_FILE_NOT_EXISTS; + } + std::ofstream file(activeMramFile, std::ios_base::app | std::ios_base::out); + file.write( + reinterpret_cast(spacePacketBuffer + PLOC_SPV::SPACE_PACKET_HEADER_LENGTH), + packetLen - 1); + file.close(); + return RETURN_OK; } uint16_t PlocSupervisorHandler::readSpacePacketLength(uint8_t* spacePacket) { - return spacePacket[4] << 8 | spacePacket[5]; + return spacePacket[4] << 8 | spacePacket[5]; } uint8_t PlocSupervisorHandler::readSequenceFlags(uint8_t* spacePacket) { - return spacePacketBuffer[2] >> 6; + return spacePacketBuffer[2] >> 6; } ReturnValue_t PlocSupervisorHandler::createMramDumpFile() { - ReturnValue_t result = RETURN_OK; - std::string timeStamp; - result = getTimeStampString(timeStamp); - if (result != RETURN_OK) { - return result; - } + ReturnValue_t result = RETURN_OK; + std::string timeStamp; + result = getTimeStampString(timeStamp); + if (result != RETURN_OK) { + return result; + } - std::string filename = "mram-dump--" + timeStamp + ".bin"; + std::string filename = "mram-dump--" + timeStamp + ".bin"; #if BOARD_TE0720 == 0 - std::string currentMountPrefix = sdcMan->getCurrentMountPrefix(); + std::string currentMountPrefix = sdcMan->getCurrentMountPrefix(); #else - std::string currentMountPrefix("/mnt/sd0"); + std::string currentMountPrefix("/mnt/sd0"); #endif /* BOARD_TE0720 == 0 */ - // Check if path to PLOC directory exists - if (not std::filesystem::exists(std::string(currentMountPrefix + "/" + plocFilePath))) { - sif::warning << "PlocSupervisorHandler::createMramDumpFile: Ploc path does not exist" - << std::endl; - return PATH_DOES_NOT_EXIST; - } - activeMramFile = currentMountPrefix + "/" + plocFilePath + "/" + filename; - // Create new file - std::ofstream file(activeMramFile, std::ios_base::out); - file.close(); + // Check if path to PLOC directory exists + if (not std::filesystem::exists(std::string(currentMountPrefix + "/" + plocFilePath))) { + sif::warning << "PlocSupervisorHandler::createMramDumpFile: Ploc path does not exist" + << std::endl; + return PATH_DOES_NOT_EXIST; + } + activeMramFile = currentMountPrefix + "/" + plocFilePath + "/" + filename; + // Create new file + std::ofstream file(activeMramFile, std::ios_base::out); + file.close(); - return RETURN_OK; + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::getTimeStampString(std::string& timeStamp) { - Clock::TimeOfDay_t time; - ReturnValue_t result = Clock::getDateAndTime(&time); - if (result != RETURN_OK) { - sif::warning << "PlocSupervisorHandler::createMramDumpFile: Failed to get current time" - << std::endl; - return GET_TIME_FAILURE; - } - timeStamp = std::to_string(time.year) + "-" + std::to_string(time.month) + "-" - + std::to_string(time.day) + "--" + std::to_string(time.hour) + "-" - + std::to_string(time.minute) + "-" + std::to_string(time.second); - return RETURN_OK; + Clock::TimeOfDay_t time; + ReturnValue_t result = Clock::getDateAndTime(&time); + if (result != RETURN_OK) { + sif::warning << "PlocSupervisorHandler::createMramDumpFile: Failed to get current time" + << std::endl; + return GET_TIME_FAILURE; + } + timeStamp = std::to_string(time.year) + "-" + std::to_string(time.month) + "-" + + std::to_string(time.day) + "--" + std::to_string(time.hour) + "-" + + std::to_string(time.minute) + "-" + std::to_string(time.second); + return RETURN_OK; } diff --git a/bsp_q7s/devices/PlocSupervisorHandler.h b/bsp_q7s/devices/PlocSupervisorHandler.h index f22c86b1..986e5bbb 100644 --- a/bsp_q7s/devices/PlocSupervisorHandler.h +++ b/bsp_q7s/devices/PlocSupervisorHandler.h @@ -1,12 +1,12 @@ #ifndef MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_ #define MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_ -#include "devicedefinitions/PlocSupervisorDefinitions.h" #include - #include #include +#include "devicedefinitions/PlocSupervisorDefinitions.h" + /** * @brief This is the device handler for the supervisor of the PLOC which is programmed by * Thales. @@ -19,324 +19,327 @@ * Arbeitsdaten/08_Used%20Components/PLOC&fileid=940960 * @author J. Meier */ -class PlocSupervisorHandler: public DeviceHandlerBase { -public: +class PlocSupervisorHandler : public DeviceHandlerBase { + 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 ~PlocSupervisorHandler(); + virtual ReturnValue_t initialize() override; - 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: - void doStartUp() override; - void doShutDown() override; - ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; - ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override; - void fillCommandAndReplyMap() override; - ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t * commandData,size_t commandDataLen) override; - ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize, - DeviceCommandId_t *foundId, size_t *foundLen) override; - ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) override; - void setNormalDatapoolEntriesInvalid() override; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; - ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator command, - uint8_t expectedReplies = 1, bool useAlternateId = false, - DeviceCommandId_t alternateReplyID = 0) override; - size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_SUPERVISOR_HANDLER; -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] Invalid communication interface specified + static const ReturnValue_t INVALID_UART_COM_IF = MAKE_RETURN_CODE(0xA5); + //! [EXPORT] : [COMMENT] Received command with invalid watchdog parameter. Valid watchdogs are 0 + //! for PS, 1 for PL and 2 for INT + static const ReturnValue_t INVALID_WATCHDOG = MAKE_RETURN_CODE(0xA6); + //! [EXPORT] : [COMMENT] Received watchdog timeout config command with invalid timeout. Valid + //! timeouts must be in the range between 1000 and 360000 ms. + static const ReturnValue_t INVALID_WATCHDOG_TIMEOUT = MAKE_RETURN_CODE(0xA7); + //! [EXPORT] : [COMMENT] Received latchup config command with invalid latchup ID + static const ReturnValue_t INVALID_LATCHUP_ID = MAKE_RETURN_CODE(0xA8); + //! [EXPORT] : [COMMENT] Received set adc sweep period command with invalid sweep period. Must be + //! larger than 21. + static const ReturnValue_t SWEEP_PERIOD_TOO_SMALL = MAKE_RETURN_CODE(0xA9); + //! [EXPORT] : [COMMENT] Receive auto EM test command with invalid test param. Valid params are 1 + //! and 2. + static const ReturnValue_t INVALID_TEST_PARAM = MAKE_RETURN_CODE(0xAA); + //! [EXPORT] : [COMMENT] Returned when scanning for MRAM dump packets failed. + static const ReturnValue_t MRAM_PACKET_PARSING_FAILURE = MAKE_RETURN_CODE(0xAB); + //! [EXPORT] : [COMMENT] Returned when the start and stop addresses of the MRAM dump or MRAM wipe + //! commands are invalid (e.g. start address bigger than stop address) + static const ReturnValue_t INVALID_MRAM_ADDRESSES = MAKE_RETURN_CODE(0xAC); + //! [EXPORT] : [COMMENT] Expect reception of an MRAM dump packet but received space packet with + //! other apid. + static const ReturnValue_t NO_MRAM_PACKET = MAKE_RETURN_CODE(0xAD); + //! [EXPORT] : [COMMENT] Path to PLOC directory on SD card does not exist + static const ReturnValue_t PATH_DOES_NOT_EXIST = MAKE_RETURN_CODE(0xAE); + //! [EXPORT] : [COMMENT] MRAM dump file does not exists. The file should actually already have + //! been created with the reception of the first dump packet. + static const ReturnValue_t MRAM_FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xAF); - static 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 - 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] Invalid communication interface specified - static const ReturnValue_t INVALID_UART_COM_IF = MAKE_RETURN_CODE(0xA5); - //! [EXPORT] : [COMMENT] Received command with invalid watchdog parameter. Valid watchdogs are 0 for PS, 1 for PL and 2 for INT - static const ReturnValue_t INVALID_WATCHDOG = MAKE_RETURN_CODE(0xA6); - //! [EXPORT] : [COMMENT] Received watchdog timeout config command with invalid timeout. Valid timeouts must be in the range between 1000 and 360000 ms. - static const ReturnValue_t INVALID_WATCHDOG_TIMEOUT = MAKE_RETURN_CODE(0xA7); - //! [EXPORT] : [COMMENT] Received latchup config command with invalid latchup ID - static const ReturnValue_t INVALID_LATCHUP_ID = MAKE_RETURN_CODE(0xA8); - //! [EXPORT] : [COMMENT] Received set adc sweep period command with invalid sweep period. Must be larger than 21. - static const ReturnValue_t SWEEP_PERIOD_TOO_SMALL = MAKE_RETURN_CODE(0xA9); - //! [EXPORT] : [COMMENT] Receive auto EM test command with invalid test param. Valid params are 1 and 2. - static const ReturnValue_t INVALID_TEST_PARAM = MAKE_RETURN_CODE(0xAA); - //! [EXPORT] : [COMMENT] Returned when scanning for MRAM dump packets failed. - static const ReturnValue_t MRAM_PACKET_PARSING_FAILURE = MAKE_RETURN_CODE(0xAB); - //! [EXPORT] : [COMMENT] Returned when the start and stop addresses of the MRAM dump or MRAM wipe commands are invalid (e.g. start address bigger than stop address) - static const ReturnValue_t INVALID_MRAM_ADDRESSES = MAKE_RETURN_CODE(0xAC); - //! [EXPORT] : [COMMENT] Expect reception of an MRAM dump packet but received space packet with other apid. - static const ReturnValue_t NO_MRAM_PACKET = MAKE_RETURN_CODE(0xAD); - //! [EXPORT] : [COMMENT] Path to PLOC directory on SD card does not exist - static const ReturnValue_t PATH_DOES_NOT_EXIST = MAKE_RETURN_CODE(0xAE); - //! [EXPORT] : [COMMENT] MRAM dump file does not exists. The file should actually already have been created with the reception of the first dump packet. - static const ReturnValue_t MRAM_FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xAF); + //! [EXPORT] : [COMMENT] PLOC supervisor crc failure in telemetry packet + static const Event SUPV_MEMORY_READ_RPT_CRC_FAILURE = MAKE_EVENT(1, severity::LOW); + //! [EXPORT] : [COMMENT] 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 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 - 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); + uint8_t commandBuffer[PLOC_SPV::MAX_COMMAND_SIZE]; - 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; - /** - * This variable is used to store the id of the next reply to receive. This is necessary - * because the PLOC sends as reply to each command at least one acknowledgment and execution - * report. - */ - DeviceCommandId_t nextReplyId = PLOC_SPV::NONE; + PLOC_SPV::HkSet hkset; + PLOC_SPV::BootStatusReport bootStatusReport; + PLOC_SPV::LatchupStatusReport latchupStatusReport; - 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; - PLOC_SPV::BootStatusReport bootStatusReport; - 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]; + /** This buffer is used to concatenate space packets received in two different read steps */ + uint8_t spacePacketBuffer[PLOC_SPV::MAX_PACKET_SIZE]; #if BOARD_TE0720 == 0 - SdCardManager* sdcMan = nullptr; + SdCardManager* sdcMan = nullptr; #endif /* BOARD_TE0720 == 0 */ - /** Path to PLOC specific files on SD card */ - std::string plocFilePath = "ploc"; - std::string activeMramFile; + /** Path to PLOC specific files on SD card */ + std::string plocFilePath = "ploc"; + std::string activeMramFile; - /** Setting this variable to true will enable direct downlink of MRAM packets */ - bool downlinkMramDump = false; + /** Setting this variable to true will enable direct downlink of MRAM packets */ + bool downlinkMramDump = false; - /** - * @brief This function checks the crc of the received PLOC reply. - * - * @param start Pointer to the first byte of the reply. - * @param foundLen Pointer to the length of the whole packet. - * - * @return RETURN_OK if CRC is ok, otherwise CRC_FAILURE. - */ - ReturnValue_t verifyPacket(const uint8_t* start, size_t foundLen); + /** + * @brief This function checks the crc of the received PLOC reply. + * + * @param start Pointer to the first byte of the reply. + * @param foundLen Pointer to the length of the whole packet. + * + * @return RETURN_OK if CRC is ok, otherwise CRC_FAILURE. + */ + ReturnValue_t verifyPacket(const uint8_t* start, size_t foundLen); - /** - * @brief This function handles the acknowledgment report. - * - * @param data Pointer to the data holding the acknowledgment report. - * - * @return RETURN_OK if successful, otherwise an error code. - */ - ReturnValue_t handleAckReport(const uint8_t* data); + /** + * @brief This function handles the acknowledgment report. + * + * @param data Pointer to the data holding the acknowledgment report. + * + * @return RETURN_OK if successful, otherwise an error code. + */ + ReturnValue_t handleAckReport(const uint8_t* data); - /** - * @brief This function handles the data of a execution report. - * - * @param data Pointer to the received data packet. - * - * @return RETURN_OK if successful, otherwise an error code. - */ - ReturnValue_t handleExecutionReport(const uint8_t* data); + /** + * @brief This function handles the data of a execution report. + * + * @param data Pointer to the received data packet. + * + * @return RETURN_OK if successful, otherwise an error code. + */ + ReturnValue_t handleExecutionReport(const uint8_t* data); - /** - * @brief This function handles the housekeeping report. This means verifying the CRC of the - * reply and filling the appropriate dataset. - * - * @param data Pointer to the data buffer holding the housekeeping read report. - * - * @return RETURN_OK if successful, otherwise an error code. - */ - ReturnValue_t handleHkReport(const uint8_t* data); + /** + * @brief This function handles the housekeeping report. This means verifying the CRC of the + * reply and filling the appropriate dataset. + * + * @param data Pointer to the data buffer holding the housekeeping read report. + * + * @return RETURN_OK if successful, otherwise an error code. + */ + ReturnValue_t handleHkReport(const uint8_t* data); - /** - * @brief 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. - */ - ReturnValue_t handleBootStatusReport(const uint8_t* data); + /** + * @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. + */ + 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 - * next reply after a successful acknowledgment report has been received. This is - * required by the function getNextReplyLength() to identify the length of the next - * reply to read. - */ - void setNextReplyId(); + /** + * @brief Depending on the current active command, this function sets the reply id of the + * next reply after a successful acknowledgment report has been received. This is + * required by the function getNextReplyLength() to identify the length of the next + * reply to read. + */ + void setNextReplyId(); - /** - * @brief This function handles action message replies in case the telemetry has been - * requested by another object. - * - * @param data Pointer to the telemetry data. - * @param dataSize Size of telemetry in bytes. - * @param replyId Id of the reply. This will be added to the ActionMessage. - */ - void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); + /** + * @brief This function handles action message replies in case the telemetry has been + * requested by another object. + * + * @param data Pointer to the telemetry data. + * @param dataSize Size of telemetry in bytes. + * @param replyId Id of the reply. This will be added to the ActionMessage. + */ + void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); - /** - * @brief This function prepares a space packet which does not transport any data in the - * packet data field apart from the crc. - */ - void prepareEmptyCmd(uint16_t apid); + /** + * @brief This function prepares a space packet which does not transport any data in the + * packet data field apart from the crc. + */ + void prepareEmptyCmd(uint16_t apid); - /** - * @brief This function initializes the space packet to select the boot image of the MPSoC. - */ - void prepareSelBootImageCmd(const uint8_t * commandData); + /** + * @brief This function initializes the space packet to select the boot image of the MPSoC. + */ + 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 - * PLOC supervisor. - */ - ReturnValue_t prepareSetTimeRefCmd(); + /** + * @brief This function fills the commandBuffer with the data to update the time of the + * PLOC supervisor. + */ + ReturnValue_t prepareSetTimeRefCmd(); - /** - * @brief This function fills the commandBuffer with the data to change the boot timeout - * value in the PLOC supervisor. - */ - void prepareSetBootTimeoutCmd(const uint8_t * commandData); + /** + * @brief This function fills the commandBuffer with the data to change the boot timeout + * value in the PLOC supervisor. + */ + 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 - * watchdogs on the PLOC. - */ - void prepareWatchdogsEnableCmd(const uint8_t * commandData); + /** + * @brief This function fills the command buffer with the packet to enable or disable the + * watchdogs on the PLOC. + */ + void prepareWatchdogsEnableCmd(const uint8_t* commandData); - /** - * @brief This function fills the command buffer with the packet to set the watchdog timer - * of one of the three watchdogs (PS, PL, INT). - */ - ReturnValue_t prepareWatchdogsConfigTimeoutCmd(const uint8_t * commandData); + /** + * @brief This function fills the command buffer with the packet to set the watchdog timer + * of one of the three watchdogs (PS, PL, INT). + */ + ReturnValue_t prepareWatchdogsConfigTimeoutCmd(const uint8_t* commandData); - ReturnValue_t prepareLatchupConfigCmd(const uint8_t* commandData, - DeviceCommandId_t deviceCommand); - ReturnValue_t prepareAutoCalibrateAlertCmd(const uint8_t* commandData); - ReturnValue_t prepareSetAlertLimitCmd(const uint8_t* commandData); - ReturnValue_t prepareSetAlertIrqFilterCmd(const uint8_t* commandData); - ReturnValue_t prepareSetAdcSweetPeriodCmd(const uint8_t* commandData); - void prepareSetAdcEnabledChannelsCmd(const uint8_t* commandData); - void prepareSetAdcWindowAndStrideCmd(const uint8_t* commandData); - void prepareSetAdcThresholdCmd(const uint8_t* commandData); - void prepareEnableNvmsCmd(const uint8_t* commandData); - void prepareSelectNvmCmd(const uint8_t* commandData); - ReturnValue_t prepareRunAutoEmTest(const uint8_t* commandData); - ReturnValue_t prepareWipeMramCmd(const uint8_t* commandData); - ReturnValue_t prepareDumpMramCmd(const uint8_t* commandData); - void preparePrintCpuStatsCmd(const uint8_t* commandData); - void prepareSetDbgVerbosityCmd(const uint8_t* commandData); - void prepareSetGpioCmd(const uint8_t* commandData); - void prepareReadGpioCmd(const uint8_t* commandData); + ReturnValue_t prepareLatchupConfigCmd(const uint8_t* commandData, + DeviceCommandId_t deviceCommand); + ReturnValue_t prepareAutoCalibrateAlertCmd(const uint8_t* commandData); + ReturnValue_t prepareSetAlertLimitCmd(const uint8_t* commandData); + ReturnValue_t prepareSetAlertIrqFilterCmd(const uint8_t* commandData); + ReturnValue_t prepareSetAdcSweetPeriodCmd(const uint8_t* commandData); + void prepareSetAdcEnabledChannelsCmd(const uint8_t* commandData); + void prepareSetAdcWindowAndStrideCmd(const uint8_t* commandData); + void prepareSetAdcThresholdCmd(const uint8_t* commandData); + void prepareEnableNvmsCmd(const uint8_t* commandData); + void prepareSelectNvmCmd(const uint8_t* commandData); + ReturnValue_t prepareRunAutoEmTest(const uint8_t* commandData); + ReturnValue_t prepareWipeMramCmd(const uint8_t* commandData); + ReturnValue_t prepareDumpMramCmd(const uint8_t* commandData); + void preparePrintCpuStatsCmd(const uint8_t* commandData); + void prepareSetDbgVerbosityCmd(const uint8_t* commandData); + void prepareSetGpioCmd(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. - */ - void packetToOutBuffer(uint8_t* packetData, size_t fullSize); + /** + * @brief In case an acknowledgment failure reply has been received this function disables + * all previously enabled commands and resets the exepected replies variable of an + * active command. + */ + void disableAllReplies(); - /** - * @brief In case an acknowledgment failure reply has been received this function disables - * all previously enabled commands and resets the exepected replies variable of an - * active command. - */ - void disableAllReplies(); + /** + * @brief This function sends a failure report if the active action was commanded by an other + * object. + * + * @param replyId The id of the reply which signals a failure. + * @param status A status byte which gives information about the failure type. + */ + void sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status); - /** - * @brief This function sends a failure report if the active action was commanded by an other - * object. - * - * @param replyId The id of the reply which signals a failure. - * @param status A status byte which gives information about the failure type. - */ - void sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status); + /** + * @brief This function disables the execution report reply. Within this function also the + * the variable expectedReplies of an active command will be set to 0. + */ + void disableExeReportReply(); - /** - * @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(); + /** + * @brief Function is called in scanForReply and fills the spacePacketBuffer with the read + * data until a full packet has been received. + */ + 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 - * data until a full packet has been received. - */ - 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. + */ + ReturnValue_t handleMramDumpPacket(DeviceCommandId_t id); - /** - * @brief This function generates the Service 8 packets for the MRAM dump data. - */ - ReturnValue_t handleMramDumpPacket(DeviceCommandId_t id); + /** + * @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 + * have been received. + */ + void increaseExpectedMramReplies(DeviceCommandId_t id); - /** - * @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 - * have been received. - */ - void increaseExpectedMramReplies(DeviceCommandId_t id); + /** + * @brief Function checks if the packet written to the space packet buffer is really a + * MRAM dump packet. + */ + ReturnValue_t checkMramPacketApid(); - /** - * @brief Function checks if the packet written to the space packet buffer is really a - * MRAM dump packet. - */ - ReturnValue_t checkMramPacketApid(); + /** + * @brief Writes the data of the MRAM dump to a file. The file will be created when receiving + * the first packet. + */ + ReturnValue_t handleMramDumpFile(DeviceCommandId_t id); - /** - * @brief Writes the data of the MRAM dump to a file. The file will be created when receiving - * the first packet. - */ - ReturnValue_t handleMramDumpFile(DeviceCommandId_t id); + /** + * @brief Extracts the length field of a spacePacket referenced by the spacePacket pointer. + * + * @param spacePacket Pointer to the buffer holding the space packet. + * + * @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. - * - * @param spacePacket Pointer to the buffer holding the space packet. - * - * @return The value stored in the length field of the data field. - */ - uint16_t readSpacePacketLength(uint8_t* spacePacket); + /** + * @brief Extracts the sequence flags from a space packet referenced by the spacePacket + * 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); - /** - * @brief Extracts the sequence flags from a space packet referenced by the spacePacket - * 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); + ReturnValue_t createMramDumpFile(); + ReturnValue_t getTimeStampString(std::string& timeStamp); }; #endif /* MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_ */ diff --git a/bsp_q7s/devices/PlocUpdater.cpp b/bsp_q7s/devices/PlocUpdater.cpp index 592a2c0d..1478fbb8 100644 --- a/bsp_q7s/devices/PlocUpdater.cpp +++ b/bsp_q7s/devices/PlocUpdater.cpp @@ -1,405 +1,393 @@ -#include "fsfw/ipc/QueueFactory.h" #include "PlocUpdater.h" -#include #include +#include #include -PlocUpdater::PlocUpdater(object_id_t objectId) : - SystemObject(objectId), commandActionHelper(this), actionHelper(this, nullptr) { - commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); +#include "fsfw/ipc/QueueFactory.h" + +PlocUpdater::PlocUpdater(object_id_t objectId) + : SystemObject(objectId), commandActionHelper(this), actionHelper(this, nullptr) { + commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); } -PlocUpdater::~PlocUpdater() { -} +PlocUpdater::~PlocUpdater() {} ReturnValue_t PlocUpdater::initialize() { #if BOARD_TE0720 == 0 - sdcMan = SdCardManager::instance(); + sdcMan = SdCardManager::instance(); #endif - ReturnValue_t result = SystemObject::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - result = commandActionHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - result = actionHelper.initialize(commandQueue); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + ReturnValue_t result = SystemObject::initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = commandActionHelper.initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = actionHelper.initialize(commandQueue); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t PlocUpdater::performOperation(uint8_t operationCode) { - readCommandQueue(); - doStateMachine(); - return HasReturnvaluesIF::RETURN_OK; + readCommandQueue(); + doStateMachine(); + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t PlocUpdater::executeAction(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { - ReturnValue_t result = RETURN_FAILED; +ReturnValue_t PlocUpdater::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) { + ReturnValue_t result = RETURN_FAILED; - if (state != State::IDLE) { - return IS_BUSY; - } + if (state != State::IDLE) { + return IS_BUSY; + } - if (size > MAX_PLOC_UPDATE_PATH) { - return NAME_TOO_LONG; - } + if (size > MAX_PLOC_UPDATE_PATH) { + return NAME_TOO_LONG; + } - switch (actionId) { + switch (actionId) { case UPDATE_A_UBOOT: - image = Image::A; - partition = Partition::UBOOT; - break; + image = Image::A; + partition = Partition::UBOOT; + break; case UPDATE_A_BITSTREAM: - image = Image::A; - partition = Partition::BITSTREAM; - break; + image = Image::A; + partition = Partition::BITSTREAM; + break; case UPDATE_A_LINUX: - image = Image::A; - partition = Partition::LINUX_OS; - break; + image = Image::A; + partition = Partition::LINUX_OS; + break; case UPDATE_A_APP_SW: - image = Image::A; - partition = Partition::APP_SW; - break; + image = Image::A; + partition = Partition::APP_SW; + break; case UPDATE_B_UBOOT: - image = Image::B; - partition = Partition::UBOOT; - break; + image = Image::B; + partition = Partition::UBOOT; + break; case UPDATE_B_BITSTREAM: - image = Image::B; - partition = Partition::BITSTREAM; - break; + image = Image::B; + partition = Partition::BITSTREAM; + break; case UPDATE_B_LINUX: - image = Image::B; - partition = Partition::LINUX_OS; - break; + image = Image::B; + partition = Partition::LINUX_OS; + break; case UPDATE_B_APP_SW: - image = Image::B; - partition = Partition::APP_SW; - break; + image = Image::B; + partition = Partition::APP_SW; + break; default: - return INVALID_ACTION_ID; - } + return INVALID_ACTION_ID; + } - result = getImageLocation(data, size); + result = getImageLocation(data, size); - if (result != RETURN_OK) { - return result; - } + if (result != RETURN_OK) { + return result; + } - state = State::UPDATE_AVAILABLE; + state = State::UPDATE_AVAILABLE; - return EXECUTION_FINISHED; + return EXECUTION_FINISHED; } -MessageQueueId_t PlocUpdater::getCommandQueue() const { - return commandQueue->getId(); -} +MessageQueueId_t PlocUpdater::getCommandQueue() const { return commandQueue->getId(); } -MessageQueueIF* PlocUpdater::getCommandQueuePtr() { - return commandQueue; -} +MessageQueueIF* PlocUpdater::getCommandQueuePtr() { return commandQueue; } void PlocUpdater::readCommandQueue() { - CommandMessage message; - ReturnValue_t result; + CommandMessage message; + ReturnValue_t result; - for (result = commandQueue->receiveMessage(&message); result == HasReturnvaluesIF::RETURN_OK; - result = commandQueue->receiveMessage(&message)) { - if (result != RETURN_OK) { - continue; - } - result = actionHelper.handleActionMessage(&message); - if (result == HasReturnvaluesIF::RETURN_OK) { - continue; - } - - result = commandActionHelper.handleReply(&message); - if (result == HasReturnvaluesIF::RETURN_OK) { - continue; - } - - sif::debug << "PlocUpdater::readCommandQueue: Received message with invalid format" - << std::endl; + for (result = commandQueue->receiveMessage(&message); result == HasReturnvaluesIF::RETURN_OK; + result = commandQueue->receiveMessage(&message)) { + if (result != RETURN_OK) { + continue; } + result = actionHelper.handleActionMessage(&message); + if (result == HasReturnvaluesIF::RETURN_OK) { + continue; + } + + result = commandActionHelper.handleReply(&message); + if (result == HasReturnvaluesIF::RETURN_OK) { + continue; + } + + sif::debug << "PlocUpdater::readCommandQueue: Received message with invalid format" + << std::endl; + } } void PlocUpdater::doStateMachine() { - switch (state) { + switch (state) { case State::IDLE: - break; + break; case State::UPDATE_AVAILABLE: - commandUpdateAvailable(); - break; + commandUpdateAvailable(); + break; case State::UPDATE_TRANSFER: - commandUpdatePacket(); - break; + commandUpdatePacket(); + break; case State::UPDATE_VERIFY: - commandUpdateVerify(); - break; + commandUpdateVerify(); + break; case State::COMMAND_EXECUTING: - break; + break; default: - sif::debug << "PlocUpdater::doStateMachine: Invalid state" << std::endl; - break; - } + sif::debug << "PlocUpdater::doStateMachine: Invalid state" << std::endl; + break; + } } ReturnValue_t PlocUpdater::checkNameLength(size_t size) { - if (size > MAX_PLOC_UPDATE_PATH) { - return NAME_TOO_LONG; - } - return RETURN_OK; + if (size > MAX_PLOC_UPDATE_PATH) { + return NAME_TOO_LONG; + } + return RETURN_OK; } ReturnValue_t PlocUpdater::getImageLocation(const uint8_t* data, size_t size) { - ReturnValue_t result = checkNameLength(size); - if (result != RETURN_OK) { - return result; - } + ReturnValue_t result = checkNameLength(size); + if (result != RETURN_OK) { + return result; + } #if BOARD_TE0720 == 0 - // Check if file is stored on SD card and if associated SD card is mounted - if (std::string(reinterpret_cast(data), SD_PREFIX_LENGTH) == std::string(SdCardManager::SD_0_MOUNT_POINT)) { - if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { - sif::warning << "PlocUpdater::getImageLocation: SD card 0 not mounted" << std::endl; - return SD_NOT_MOUNTED; - } + // Check if file is stored on SD card and if associated SD card is mounted + if (std::string(reinterpret_cast(data), SD_PREFIX_LENGTH) == + std::string(SdCardManager::SD_0_MOUNT_POINT)) { + if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { + sif::warning << "PlocUpdater::getImageLocation: SD card 0 not mounted" << std::endl; + return SD_NOT_MOUNTED; } - else if (std::string(reinterpret_cast(data), SD_PREFIX_LENGTH) == std::string(SdCardManager::SD_1_MOUNT_POINT)) { - if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { - sif::warning << "PlocUpdater::getImageLocation: SD card 1 not mounted" << std::endl; - return SD_NOT_MOUNTED; - } - } - else { - //update image not stored on SD card + } else if (std::string(reinterpret_cast(data), SD_PREFIX_LENGTH) == + std::string(SdCardManager::SD_1_MOUNT_POINT)) { + if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { + sif::warning << "PlocUpdater::getImageLocation: SD card 1 not mounted" << std::endl; + return SD_NOT_MOUNTED; } + } else { + // update image not stored on SD card + } #endif /* BOARD_TE0720 == 0 */ - updateFile = std::string(reinterpret_cast(data), size); + updateFile = std::string(reinterpret_cast(data), size); - // Check if file exists - if(not std::filesystem::exists(updateFile)) { - return FILE_NOT_EXISTS; - } - return RETURN_OK; + // Check if file exists + if (not std::filesystem::exists(updateFile)) { + return FILE_NOT_EXISTS; + } + return RETURN_OK; } -void PlocUpdater::stepSuccessfulReceived(ActionId_t actionId, - uint8_t step) { -} +void PlocUpdater::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) {} -void PlocUpdater::stepFailedReceived(ActionId_t actionId, uint8_t step, - ReturnValue_t returnCode) { -} +void PlocUpdater::stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) {} -void PlocUpdater::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) { - -} +void PlocUpdater::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) {} void PlocUpdater::completionSuccessfulReceived(ActionId_t actionId) { - switch (pendingCommand) { + switch (pendingCommand) { case (PLOC_SPV::UPDATE_AVAILABLE): - state = State::UPDATE_TRANSFER; - break; + state = State::UPDATE_TRANSFER; + break; case (PLOC_SPV::UPDATE_IMAGE_DATA): - if (remainingPackets == 0) { - packetsSent = 0; // Reset packets sent variable for next update sequence - state = State::UPDATE_VERIFY; - } - else { - state = State::UPDATE_TRANSFER; - } - break; + if (remainingPackets == 0) { + packetsSent = 0; // Reset packets sent variable for next update sequence + state = State::UPDATE_VERIFY; + } else { + state = State::UPDATE_TRANSFER; + } + break; case (PLOC_SPV::UPDATE_VERIFY): - triggerEvent(UPDATE_FINISHED); - state = State::IDLE; - pendingCommand = PLOC_SPV::NONE; - break; + triggerEvent(UPDATE_FINISHED); + state = State::IDLE; + pendingCommand = PLOC_SPV::NONE; + break; default: - sif::debug << "PlocUpdater::completionSuccessfulReceived: Invalid pending command" - << std::endl; - state = State::IDLE; - break; - } + sif::debug << "PlocUpdater::completionSuccessfulReceived: Invalid pending command" + << std::endl; + state = State::IDLE; + break; + } } -void PlocUpdater::completionFailedReceived(ActionId_t actionId, - ReturnValue_t returnCode) { - switch(pendingCommand) { - case(PLOC_SPV::UPDATE_AVAILABLE): { - triggerEvent(UPDATE_AVAILABLE_FAILED); - break; +void PlocUpdater::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) { + switch (pendingCommand) { + case (PLOC_SPV::UPDATE_AVAILABLE): { + triggerEvent(UPDATE_AVAILABLE_FAILED); + break; } - case(PLOC_SPV::UPDATE_IMAGE_DATA): { - triggerEvent(UPDATE_TRANSFER_FAILED, packetsSent); - break; + case (PLOC_SPV::UPDATE_IMAGE_DATA): { + triggerEvent(UPDATE_TRANSFER_FAILED, packetsSent); + break; } - case(PLOC_SPV::UPDATE_VERIFY): { - triggerEvent(UPDATE_VERIFY_FAILED); - break; + case (PLOC_SPV::UPDATE_VERIFY): { + triggerEvent(UPDATE_VERIFY_FAILED); + break; } default: - sif::debug << "PlocUpdater::completionFailedReceived: Invalid pending command " - << std::endl; - break; - } - state = State::IDLE; + sif::debug << "PlocUpdater::completionFailedReceived: Invalid pending command " << std::endl; + break; + } + state = State::IDLE; } void PlocUpdater::commandUpdateAvailable() { - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = RETURN_OK; - if (not std::filesystem::exists(updateFile)) { - triggerEvent(UPDATE_FILE_NOT_EXISTS, static_cast(state)); - state = State::IDLE; - return; - } - - std::ifstream file(updateFile, std::ifstream::binary); - file.seekg(0, file.end); - imageSize = static_cast(file.tellg()); - file.close(); - - numOfUpdatePackets = imageSize / MAX_SP_DATA ; - if (imageSize % MAX_SP_DATA) { - numOfUpdatePackets++; - } - - remainingPackets = numOfUpdatePackets; - packetsSent = 0; - - calcImageCrc(); - - PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_AVAILABLE, static_cast(image), - static_cast(partition), imageSize, imageCrc, numOfUpdatePackets); - - result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, - PLOC_SPV::UPDATE_AVAILABLE, packet.getWholeData(), packet.getFullSize()); - if (result != RETURN_OK) { - sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update available" - << " packet to supervisor handler" << std::endl; - triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_AVAILABLE); - state = State::IDLE; - pendingCommand = PLOC_SPV::NONE; - return; - } - - pendingCommand = PLOC_SPV::UPDATE_AVAILABLE; - state = State::COMMAND_EXECUTING; + if (not std::filesystem::exists(updateFile)) { + triggerEvent(UPDATE_FILE_NOT_EXISTS, static_cast(state)); + state = State::IDLE; return; + } + + std::ifstream file(updateFile, std::ifstream::binary); + file.seekg(0, file.end); + imageSize = static_cast(file.tellg()); + file.close(); + + numOfUpdatePackets = imageSize / MAX_SP_DATA; + if (imageSize % MAX_SP_DATA) { + numOfUpdatePackets++; + } + + remainingPackets = numOfUpdatePackets; + packetsSent = 0; + + calcImageCrc(); + + PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_AVAILABLE, static_cast(image), + static_cast(partition), imageSize, imageCrc, + numOfUpdatePackets); + + result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, + PLOC_SPV::UPDATE_AVAILABLE, packet.getWholeData(), + packet.getFullSize()); + if (result != RETURN_OK) { + sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update available" + << " packet to supervisor handler" << std::endl; + triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_AVAILABLE); + state = State::IDLE; + pendingCommand = PLOC_SPV::NONE; + return; + } + + pendingCommand = PLOC_SPV::UPDATE_AVAILABLE; + state = State::COMMAND_EXECUTING; + return; } void PlocUpdater::commandUpdatePacket() { - ReturnValue_t result = RETURN_OK; - uint16_t payloadLength = 0; + ReturnValue_t result = RETURN_OK; + uint16_t payloadLength = 0; - if (not std::filesystem::exists(updateFile)) { - triggerEvent(UPDATE_FILE_NOT_EXISTS, static_cast(state), packetsSent); - state = State::IDLE; - return; - } + if (not std::filesystem::exists(updateFile)) { + triggerEvent(UPDATE_FILE_NOT_EXISTS, static_cast(state), packetsSent); + state = State::IDLE; + return; + } - std::ifstream file(updateFile, std::ifstream::binary); - file.seekg(packetsSent * MAX_SP_DATA, file.beg); + std::ifstream file(updateFile, std::ifstream::binary); + file.seekg(packetsSent * MAX_SP_DATA, file.beg); - if (remainingPackets == 1) { - payloadLength = imageSize - static_cast(file.tellg()); - } - else { - payloadLength = MAX_SP_DATA; - } + if (remainingPackets == 1) { + payloadLength = imageSize - static_cast(file.tellg()); + } else { + payloadLength = MAX_SP_DATA; + } - PLOC_SPV::UpdatePacket packet(payloadLength); - file.read(reinterpret_cast(packet.getDataFieldPointer()), payloadLength); - file.close(); - // sequence count of first packet is 1 - packet.setPacketSequenceCount((packetsSent + 1) & PLOC_SPV::SEQUENCE_COUNT_MASK); - if (numOfUpdatePackets > 1) { - adjustSequenceFlags(packet); - } - packet.makeCrc(); + PLOC_SPV::UpdatePacket packet(payloadLength); + file.read(reinterpret_cast(packet.getDataFieldPointer()), payloadLength); + file.close(); + // sequence count of first packet is 1 + packet.setPacketSequenceCount((packetsSent + 1) & PLOC_SPV::SEQUENCE_COUNT_MASK); + if (numOfUpdatePackets > 1) { + adjustSequenceFlags(packet); + } + packet.makeCrc(); - result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, - PLOC_SPV::UPDATE_IMAGE_DATA, packet.getWholeData(), packet.getFullSize()); + result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, + PLOC_SPV::UPDATE_IMAGE_DATA, packet.getWholeData(), + packet.getFullSize()); - if (result != RETURN_OK) { - sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update" - << " packet to supervisor handler" << std::endl; - triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_IMAGE_DATA); - state = State::IDLE; - pendingCommand = PLOC_SPV::NONE; - return; - } + if (result != RETURN_OK) { + sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update" + << " packet to supervisor handler" << std::endl; + triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_IMAGE_DATA); + state = State::IDLE; + pendingCommand = PLOC_SPV::NONE; + return; + } - remainingPackets--; - packetsSent++; + remainingPackets--; + packetsSent++; - pendingCommand = PLOC_SPV::UPDATE_IMAGE_DATA; - state = State::COMMAND_EXECUTING; + pendingCommand = PLOC_SPV::UPDATE_IMAGE_DATA; + state = State::COMMAND_EXECUTING; } void PlocUpdater::commandUpdateVerify() { - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = RETURN_OK; - PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_VERIFY, static_cast(image), - static_cast(partition), imageSize, imageCrc, numOfUpdatePackets); + PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_VERIFY, static_cast(image), + static_cast(partition), imageSize, imageCrc, + numOfUpdatePackets); - result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, - PLOC_SPV::UPDATE_VERIFY, packet.getWholeData(), packet.getFullSize()); - if (result != RETURN_OK) { - sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update available" - << " packet to supervisor handler" << std::endl; - triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_VERIFY); - state = State::IDLE; - pendingCommand = PLOC_SPV::NONE; - return; - } - state = State::COMMAND_EXECUTING; - pendingCommand = PLOC_SPV::UPDATE_VERIFY; + result = + commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, PLOC_SPV::UPDATE_VERIFY, + packet.getWholeData(), packet.getFullSize()); + if (result != RETURN_OK) { + sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update available" + << " packet to supervisor handler" << std::endl; + triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_VERIFY); + state = State::IDLE; + pendingCommand = PLOC_SPV::NONE; return; + } + state = State::COMMAND_EXECUTING; + pendingCommand = PLOC_SPV::UPDATE_VERIFY; + return; } void PlocUpdater::calcImageCrc() { - std::ifstream file(updateFile, std::ifstream::binary); - file.seekg(0, file.end); - uint32_t count; - uint32_t bit; - uint32_t remainder = INITIAL_REMAINDER_32; - char input; - for (count = 0; count < imageSize; count++) { - file.seekg(count, file.beg); - file.read(&input, 1); - remainder ^= (input << 16); - for (bit = 8; bit > 0; --bit) { - if (remainder & TOPBIT_32) { - remainder = (remainder << 1) ^ POLYNOMIAL_32; - } else { - remainder = (remainder << 1); - } - } + std::ifstream file(updateFile, std::ifstream::binary); + file.seekg(0, file.end); + uint32_t count; + uint32_t bit; + uint32_t remainder = INITIAL_REMAINDER_32; + char input; + for (count = 0; count < imageSize; count++) { + file.seekg(count, file.beg); + file.read(&input, 1); + remainder ^= (input << 16); + for (bit = 8; bit > 0; --bit) { + if (remainder & TOPBIT_32) { + remainder = (remainder << 1) ^ POLYNOMIAL_32; + } else { + remainder = (remainder << 1); + } } - file.close(); - imageCrc = (remainder ^ FINAL_XOR_VALUE_32); + } + file.close(); + imageCrc = (remainder ^ FINAL_XOR_VALUE_32); } void PlocUpdater::adjustSequenceFlags(PLOC_SPV::UpdatePacket& packet) { - if (packetsSent == 0) { - packet.setSequenceFlags(static_cast(PLOC_SPV::SequenceFlags::FIRST_PKT)); - } - else if (remainingPackets == 1) { - packet.setSequenceFlags(static_cast(PLOC_SPV::SequenceFlags::LAST_PKT)); - } - else { - packet.setSequenceFlags(static_cast(PLOC_SPV::SequenceFlags::CONTINUED_PKT)); - } + if (packetsSent == 0) { + packet.setSequenceFlags(static_cast(PLOC_SPV::SequenceFlags::FIRST_PKT)); + } else if (remainingPackets == 1) { + packet.setSequenceFlags(static_cast(PLOC_SPV::SequenceFlags::LAST_PKT)); + } else { + packet.setSequenceFlags(static_cast(PLOC_SPV::SequenceFlags::CONTINUED_PKT)); + } } - diff --git a/bsp_q7s/devices/PlocUpdater.h b/bsp_q7s/devices/PlocUpdater.h index d016b9e5..bfd86995 100644 --- a/bsp_q7s/devices/PlocUpdater.h +++ b/bsp_q7s/devices/PlocUpdater.h @@ -2,181 +2,170 @@ #define MISSION_DEVICES_PLOCUPDATER_H_ #include "OBSWConfig.h" +#include "bsp_q7s/memory/SdCardManager.h" #include "devicedefinitions/PlocSupervisorDefinitions.h" - -#include "fsfw/action/CommandActionHelper.h" #include "fsfw/action/ActionHelper.h" -#include "fsfw/action/HasActionsIF.h" +#include "fsfw/action/CommandActionHelper.h" #include "fsfw/action/CommandsActionsIF.h" +#include "fsfw/action/HasActionsIF.h" +#include "fsfw/objectmanager/SystemObject.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/tasks/ExecutableObjectIF.h" -#include "fsfw/objectmanager/SystemObject.h" -#include "bsp_q7s/memory/SdCardManager.h" -#include "linux/fsfwconfig/objects/systemObjectList.h" #include "fsfw/tmtcpacket/SpacePacket.h" - +#include "linux/fsfwconfig/objects/systemObjectList.h" /** * @brief An object of this class can be used to perform the software updates of the PLOC. The * software update will be read from one of the SD cards, split into multiple space * packets and sent to the PlocSupervisorHandler. * - * @details The MPSoC has two boot memories (NVM0 and NVM1) where each stores two images (Partition A - * and Partition B) + * @details The MPSoC has two boot memories (NVM0 and NVM1) where each stores two images (Partition + * A and Partition B) * * @author J. Meier */ class PlocUpdater : public SystemObject, - public HasActionsIF, - public ExecutableObjectIF, - public HasReturnvaluesIF, - public CommandsActionsIF { -public: + public HasActionsIF, + public ExecutableObjectIF, + public HasReturnvaluesIF, + public CommandsActionsIF { + public: + static const ActionId_t UPDATE_A_UBOOT = 0; + static const ActionId_t UPDATE_A_BITSTREAM = 1; + static const ActionId_t UPDATE_A_LINUX = 2; + static const ActionId_t UPDATE_A_APP_SW = 3; + static const ActionId_t UPDATE_B_UBOOT = 4; + static const ActionId_t UPDATE_B_BITSTREAM = 5; + static const ActionId_t UPDATE_B_LINUX = 6; + static const ActionId_t UPDATE_B_APP_SW = 7; - static const ActionId_t UPDATE_A_UBOOT = 0; - static const ActionId_t UPDATE_A_BITSTREAM = 1; - static const ActionId_t UPDATE_A_LINUX = 2; - static const ActionId_t UPDATE_A_APP_SW = 3; - static const ActionId_t UPDATE_B_UBOOT = 4; - static const ActionId_t UPDATE_B_BITSTREAM = 5; - static const ActionId_t UPDATE_B_LINUX = 6; - static const ActionId_t UPDATE_B_APP_SW = 7; + PlocUpdater(object_id_t objectId); + virtual ~PlocUpdater(); - PlocUpdater(object_id_t objectId); - virtual ~PlocUpdater(); + ReturnValue_t performOperation(uint8_t operationCode = 0) override; + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size); + MessageQueueId_t getCommandQueue() const; + ReturnValue_t initialize() override; + MessageQueueIF* getCommandQueuePtr() override; + void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) override; + void stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) override; + void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) override; + void completionSuccessfulReceived(ActionId_t actionId) override; + void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override; - ReturnValue_t performOperation(uint8_t operationCode = 0) override; - ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size); - MessageQueueId_t getCommandQueue() const; - ReturnValue_t initialize() override; - MessageQueueIF* getCommandQueuePtr() override; - void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) override; - void stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) override; - void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) override; - void completionSuccessfulReceived(ActionId_t actionId) override; - void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_UPDATER; -private: + //! [EXPORT] : [COMMENT] Updater is already performing an update + static const ReturnValue_t UPDATER_BUSY = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] Received update command with invalid path string (too long). + static const ReturnValue_t NAME_TOO_LONG = MAKE_RETURN_CODE(0xA1); + //! [EXPORT] : [COMMENT] Received command to initiate update but SD card with update image not + //! mounted. + static const ReturnValue_t SD_NOT_MOUNTED = MAKE_RETURN_CODE(0xA2); + //! [EXPORT] : [COMMENT] Update file received with update command does not exist. + static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xA3); - static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_UPDATER; + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_UPDATER; - //! [EXPORT] : [COMMENT] Updater is already performing an update - static const ReturnValue_t UPDATER_BUSY = MAKE_RETURN_CODE(0xA0); - //! [EXPORT] : [COMMENT] Received update command with invalid path string (too long). - static const ReturnValue_t NAME_TOO_LONG = MAKE_RETURN_CODE(0xA1); - //! [EXPORT] : [COMMENT] Received command to initiate update but SD card with update image not mounted. - static const ReturnValue_t SD_NOT_MOUNTED = MAKE_RETURN_CODE(0xA2); - //! [EXPORT] : [COMMENT] Update file received with update command does not exist. - static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xA3); + //! [EXPORT] : [COMMENT] Try to read update file but the file does not exist. + //! P1: Indicates in which state the file read fails + //! P2: During the update transfer the second parameter gives information about the number of + //! already sent packets + static const Event UPDATE_FILE_NOT_EXISTS = MAKE_EVENT(0, severity::LOW); + //! [EXPORT] : [COMMENT] Failed to send command to supervisor handler + //! P1: Return value of CommandActionHelper::commandAction + //! P2: Action ID of command to send + static const Event ACTION_COMMANDING_FAILED = MAKE_EVENT(1, severity::LOW); + //! [EXPORT] : [COMMENT] Supervisor handler replied action message indicating a command execution + //! failure of the update available command + static const Event UPDATE_AVAILABLE_FAILED = MAKE_EVENT(2, severity::LOW); + //! [EXPORT] : [COMMENT] Supervisor handler failed to transfer an update space packet. + //! P1: Parameter holds the number of update packets already sent (inclusive the failed packet) + static const Event UPDATE_TRANSFER_FAILED = MAKE_EVENT(3, severity::LOW); + //! [EXPORT] : [COMMENT] Supervisor failed to execute the update verify command. + static const Event UPDATE_VERIFY_FAILED = MAKE_EVENT(4, severity::LOW); + //! [EXPORT] : [COMMENT] MPSoC update successful completed + static const Event UPDATE_FINISHED = MAKE_EVENT(5, severity::INFO); - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_UPDATER; + static const uint32_t QUEUE_SIZE = config::PLOC_UPDATER_QUEUE_SIZE; + static const size_t MAX_PLOC_UPDATE_PATH = 50; + static const size_t SD_PREFIX_LENGTH = 8; + // Maximum size of update payload data per space packet (max size of space packet is 1024 bytes) + static const size_t MAX_SP_DATA = 1016; - //! [EXPORT] : [COMMENT] Try to read update file but the file does not exist. - //! P1: Indicates in which state the file read fails - //! P2: During the update transfer the second parameter gives information about the number of already sent packets - static const Event UPDATE_FILE_NOT_EXISTS = MAKE_EVENT(0, severity::LOW); - //! [EXPORT] : [COMMENT] Failed to send command to supervisor handler - //! P1: Return value of CommandActionHelper::commandAction - //! P2: Action ID of command to send - static const Event ACTION_COMMANDING_FAILED = MAKE_EVENT(1, severity::LOW); - //! [EXPORT] : [COMMENT] Supervisor handler replied action message indicating a command execution failure of the update available command - static const Event UPDATE_AVAILABLE_FAILED = MAKE_EVENT(2, severity::LOW); - //! [EXPORT] : [COMMENT] Supervisor handler failed to transfer an update space packet. - //! P1: Parameter holds the number of update packets already sent (inclusive the failed packet) - static const Event UPDATE_TRANSFER_FAILED = MAKE_EVENT(3, severity::LOW); - //! [EXPORT] : [COMMENT] Supervisor failed to execute the update verify command. - static const Event UPDATE_VERIFY_FAILED = MAKE_EVENT(4, severity::LOW); - //! [EXPORT] : [COMMENT] MPSoC update successful completed - static const Event UPDATE_FINISHED = MAKE_EVENT(5, severity::INFO); + static const uint32_t TOPBIT_32 = (1 << 31); + static const uint32_t POLYNOMIAL_32 = 0x04C11DB7; + static const uint32_t INITIAL_REMAINDER_32 = 0xFFFFFFFF; + static const uint32_t FINAL_XOR_VALUE_32 = 0xFFFFFFFF; - static const uint32_t QUEUE_SIZE = config::PLOC_UPDATER_QUEUE_SIZE; - static const size_t MAX_PLOC_UPDATE_PATH = 50; - static const size_t SD_PREFIX_LENGTH = 8; - // Maximum size of update payload data per space packet (max size of space packet is 1024 bytes) - static const size_t MAX_SP_DATA = 1016; - - static const uint32_t TOPBIT_32 = (1 << 31); - static const uint32_t POLYNOMIAL_32 = 0x04C11DB7; - static const uint32_t INITIAL_REMAINDER_32 = 0xFFFFFFFF; - static const uint32_t FINAL_XOR_VALUE_32 = 0xFFFFFFFF; - - MessageQueueIF* commandQueue = nullptr; + MessageQueueIF* commandQueue = nullptr; #if BOARD_TE0720 == 0 - SdCardManager* sdcMan = nullptr; + SdCardManager* sdcMan = nullptr; #endif - CommandActionHelper commandActionHelper; + CommandActionHelper commandActionHelper; - ActionHelper actionHelper; + ActionHelper actionHelper; - enum class State: uint8_t { - IDLE, - UPDATE_AVAILABLE, - UPDATE_TRANSFER, - UPDATE_VERIFY, - COMMAND_EXECUTING - }; + enum class State : uint8_t { + IDLE, + UPDATE_AVAILABLE, + UPDATE_TRANSFER, + UPDATE_VERIFY, + COMMAND_EXECUTING + }; - State state = State::IDLE; + State state = State::IDLE; - ActionId_t pendingCommand = PLOC_SPV::NONE; + ActionId_t pendingCommand = PLOC_SPV::NONE; - enum class Image: uint8_t { - NONE, - A, - B - }; + enum class Image : uint8_t { NONE, A, B }; - Image image = Image::NONE; + Image image = Image::NONE; - enum class Partition: uint8_t { - NONE, - UBOOT, - BITSTREAM, - LINUX_OS, - APP_SW - }; + enum class Partition : uint8_t { NONE, UBOOT, BITSTREAM, LINUX_OS, APP_SW }; - Partition partition = Partition::NONE; + Partition partition = Partition::NONE; - uint32_t packetsSent = 0; - uint32_t remainingPackets = 0; - // Number of packets required to transfer the update image - uint32_t numOfUpdatePackets = 0; + uint32_t packetsSent = 0; + uint32_t remainingPackets = 0; + // Number of packets required to transfer the update image + uint32_t numOfUpdatePackets = 0; - std::string updateFile; - uint32_t imageSize = 0; - uint32_t imageCrc = 0; + std::string updateFile; + uint32_t imageSize = 0; + uint32_t imageCrc = 0; - void readCommandQueue(); - void doStateMachine(); + void readCommandQueue(); + void doStateMachine(); - /** - * @brief Extracts the path and name of the update image from the service 8 command data. - */ - ReturnValue_t getImageLocation(const uint8_t* data, size_t size); + /** + * @brief Extracts the path and name of the update image from the service 8 command data. + */ + ReturnValue_t getImageLocation(const uint8_t* data, size_t size); - ReturnValue_t checkNameLength(size_t size); + ReturnValue_t checkNameLength(size_t size); - /** - * @brief Prepares and sends update available command to PLOC supervisor handler. - */ - void commandUpdateAvailable(); + /** + * @brief Prepares and sends update available command to PLOC supervisor handler. + */ + void commandUpdateAvailable(); - /** - * @brief Prepares and sends and update packet to the PLOC supervisor handler. - */ - void commandUpdatePacket(); + /** + * @brief Prepares and sends and update packet to the PLOC supervisor handler. + */ + void commandUpdatePacket(); - /** - * @brief Prepares and sends the update verification packet to the PLOC supervisor handler. - */ - void commandUpdateVerify(); + /** + * @brief Prepares and sends the update verification packet to the PLOC supervisor handler. + */ + void commandUpdateVerify(); - void calcImageCrc(); + void calcImageCrc(); - void adjustSequenceFlags(PLOC_SPV::UpdatePacket& packet); + void adjustSequenceFlags(PLOC_SPV::UpdatePacket& packet); }; #endif /* MISSION_DEVICES_PLOCUPDATER_H_ */ diff --git a/bsp_q7s/devices/devicedefinitions/PlocMemDumpDefinitions.h b/bsp_q7s/devices/devicedefinitions/PlocMemDumpDefinitions.h index 6e44cf35..00dc9003 100644 --- a/bsp_q7s/devices/devicedefinitions/PlocMemDumpDefinitions.h +++ b/bsp_q7s/devices/devicedefinitions/PlocMemDumpDefinitions.h @@ -3,31 +3,26 @@ #include -class MemoryParams: public SerialLinkedListAdapter { -public: +class MemoryParams : public SerialLinkedListAdapter { + public: + /** + * @brief Constructor + * @param startAddress Start of address range to dump + * @param endAddress End of address range to dump + */ + MemoryParams(uint32_t startAddress, uint32_t endAddress) + : startAddress(startAddress), endAddress(endAddress) { + setLinks(); + } - /** - * @brief Constructor - * @param startAddress Start of address range to dump - * @param endAddress End of address range to dump - */ - MemoryParams(uint32_t startAddress, uint32_t endAddress) : - startAddress(startAddress), endAddress(endAddress) { - setLinks(); - } -private: - - void setLinks() { - setStart(&startAddress); - startAddress.setNext(&endAddress); - } - - SerializeElement startAddress; - SerializeElement endAddress; + private: + void setLinks() { + setStart(&startAddress); + startAddress.setNext(&endAddress); + } + SerializeElement startAddress; + SerializeElement endAddress; }; - - - #endif /* BSP_Q7S_DEVICES_DEVICEDEFINITIONS_PLOCMEMDUMPDEFINITIONS_H_ */ diff --git a/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h b/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h index 0235d281..3fc21441 100644 --- a/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h +++ b/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h @@ -1,12 +1,12 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_PLOCSVPDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_PLOCSVPDEFINITIONS_H_ -#include +#include +#include #include #include #include -#include -#include +#include namespace PLOC_SPV { @@ -143,7 +143,7 @@ static const uint8_t DATA_FIELD_OFFSET = 6; * Space packet length for fixed size packets. This is the size of the whole packet data * field. For the length field in the space packet this size will be substracted by one. */ -static const uint16_t LENGTH_EMPTY_TC = 2; // Only CRC will be transported with the data field +static const uint16_t LENGTH_EMPTY_TC = 2; // Only CRC will be transported with the data field /** This is the maximum length of a space packet as defined by the TAS ICD */ static const size_t MAX_COMMAND_SIZE = 1024; @@ -153,51 +153,53 @@ static const size_t MAX_PACKET_SIZE = 1024; static const uint8_t SPACE_PACKET_HEADER_LENGTH = 6; -enum class SequenceFlags: uint8_t { - CONTINUED_PKT = 0b00, FIRST_PKT = 0b01, LAST_PKT = 0b10, STANDALONE_PKT = 0b11 +enum class SequenceFlags : uint8_t { + CONTINUED_PKT = 0b00, + FIRST_PKT = 0b01, + LAST_PKT = 0b10, + STANDALONE_PKT = 0b11 }; -enum PoolIds - : lp_id_t { - NUM_TMS, - TEMP_PS, - TEMP_PL, - SOC_STATE, - NVM0_1_STATE, - NVM3_STATE, - MISSION_IO_STATE, - FMC_STATE, - NUM_TCS, - TEMP_SUP, - UPTIME, - CPULOAD, - AVAILABLEHEAP, - BOOT_SIGNAL, - RESET_COUNTER, - BOOT_AFTER_MS, - BOOT_TIMEOUT_MS, - ACTIVE_NVM, - BP0_STATE, - BP1_STATE, - BP2_STATE, +enum PoolIds : lp_id_t { + NUM_TMS, + TEMP_PS, + TEMP_PL, + SOC_STATE, + NVM0_1_STATE, + NVM3_STATE, + MISSION_IO_STATE, + FMC_STATE, + NUM_TCS, + TEMP_SUP, + UPTIME, + CPULOAD, + AVAILABLEHEAP, + BOOT_SIGNAL, + RESET_COUNTER, + BOOT_AFTER_MS, + BOOT_TIMEOUT_MS, + ACTIVE_NVM, + BP0_STATE, + BP1_STATE, + BP2_STATE, - LATCHUP_ID, - CNT0, - CNT1, - CNT2, - CNT3, - CNT4, - CNT5, - CNT6, - LATCHUP_RPT_TIME_SEC, - LATCHUP_RPT_TIME_MIN, - LATCHUP_RPT_TIME_HOUR, - LATCHUP_RPT_TIME_DAY, - LATCHUP_RPT_TIME_MON, - LATCHUP_RPT_TIME_YEAR, - LATCHUP_RPT_TIME_MSEC, - LATCHUP_RPT_TIME_USEC, - LATCHUP_RPT_TIME_IS_SET, + LATCHUP_ID, + CNT0, + CNT1, + CNT2, + CNT3, + CNT4, + CNT5, + CNT6, + LATCHUP_RPT_TIME_SEC, + LATCHUP_RPT_TIME_MIN, + LATCHUP_RPT_TIME_HOUR, + LATCHUP_RPT_TIME_DAY, + LATCHUP_RPT_TIME_MON, + LATCHUP_RPT_TIME_YEAR, + LATCHUP_RPT_TIME_MSEC, + LATCHUP_RPT_TIME_USEC, + LATCHUP_RPT_TIME_IS_SET, }; static const uint8_t HK_SET_ENTRIES = 13; @@ -211,285 +213,273 @@ static const uint32_t LATCHUP_RPT_ID = LATCHUP_REPORT; /** * @brief With this class a space packet can be created which does not contain any data. */ -class EmptyPacket: public SpacePacket { -public: +class EmptyPacket : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param apid The APID to set in the space packet. + * + * @note Sequence count of empty packet is always 1. + */ + EmptyPacket(uint16_t apid) : SpacePacket(LENGTH_EMPTY_TC - 1, true, apid, 1) { calcCrc(); } - /** - * @brief Constructor - * - * @param apid The APID to set in the space packet. - * - * @note Sequence count of empty packet is always 1. - */ - EmptyPacket(uint16_t apid) : - SpacePacket(LENGTH_EMPTY_TC - 1, true, apid, 1) { - calcCrc(); - } + private: + /** + * @brief CRC calculation which involves only the header in an empty packet + */ + void calcCrc() { + /* Calculate crc */ + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, sizeof(CCSDSPrimaryHeader)); -private: - - /** - * @brief CRC calculation which involves only the header in an empty packet - */ - void calcCrc() { - - /* Calculate crc */ - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, sizeof(CCSDSPrimaryHeader)); - - /* Add crc to packet data field of space packet */ - size_t serializedSize = 0; - uint8_t* crcPos = this->localData.fields.buffer; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + /* Add crc to packet data field of space packet */ + size_t serializedSize = 0; + uint8_t* crcPos = this->localData.fields.buffer; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class can be used to generate the space packet selecting the boot image of * of the MPSoC. */ -class MPSoCBootSelect: public SpacePacket { -public: +class MPSoCBootSelect : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param mem The memory to boot from: NVM0 (0), NVM1 (1) + * @param bp0 Partition pin 0 + * @param bp1 Partition pin 1 + * @param bp2 Partition pin 2 + */ + MPSoCBootSelect(uint8_t mem, uint8_t bp0, uint8_t bp1, uint8_t bp2) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SEL_MPSOC_BOOT_IMAGE, DEFAULT_SEQUENCE_COUNT), + mem(mem), + bp0(bp0), + bp1(bp1), + bp2(bp2) { + initPacket(); + } - /** - * @brief Constructor - * - * @param mem The memory to boot from: NVM0 (0), NVM1 (1) - * @param bp0 Partition pin 0 - * @param bp1 Partition pin 1 - * @param bp2 Partition pin 2 - */ - MPSoCBootSelect(uint8_t mem, uint8_t bp0, uint8_t bp1, uint8_t bp2) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SEL_MPSOC_BOOT_IMAGE, - DEFAULT_SEQUENCE_COUNT), mem(mem), bp0(bp0), bp1(bp1), bp2(bp2) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 6; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint8_t MEM_OFFSET = 0; + static const uint8_t BP0_OFFSET = 1; + static const uint8_t BP1_OFFSET = 2; + static const uint8_t BP2_OFFSET = 3; + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 6; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t mem = 0; + uint8_t bp0 = 0; + uint8_t bp1 = 0; + uint8_t bp2 = 0; - static const uint8_t MEM_OFFSET = 0; - static const uint8_t BP0_OFFSET = 1; - static const uint8_t BP1_OFFSET = 2; - static const uint8_t BP2_OFFSET = 3; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; + void initPacket() { + uint8_t* data_field_start = this->localData.fields.buffer; + std::memcpy(data_field_start + MEM_OFFSET, &mem, sizeof(mem)); + std::memcpy(data_field_start + BP0_OFFSET, &bp0, sizeof(bp0)); + std::memcpy(data_field_start + BP1_OFFSET, &bp1, sizeof(bp1)); + std::memcpy(data_field_start + BP2_OFFSET, &bp2, sizeof(bp2)); + /* Calculate crc */ + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t mem = 0; - uint8_t bp0 = 0; - uint8_t bp1 = 0; - uint8_t bp2 = 0; - - void initPacket() { - uint8_t* data_field_start = this->localData.fields.buffer; - std::memcpy(data_field_start + MEM_OFFSET, &mem, sizeof(mem)); - std::memcpy(data_field_start + BP0_OFFSET, &bp0, sizeof(bp0)); - std::memcpy(data_field_start + BP1_OFFSET, &bp1, sizeof(bp1)); - std::memcpy(data_field_start + BP2_OFFSET, &bp2, sizeof(bp2)); - /* Calculate crc */ - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - - /* Add crc to packet data field of space packet */ - size_t serializedSize = 0; - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + /* Add crc to packet data field of space packet */ + size_t serializedSize = 0; + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class generates the space packet to update the time of the PLOC supervisor. */ -class SetTimeRef: public SpacePacket { -public: +class SetTimeRef : public SpacePacket { + public: + SetTimeRef(Clock::TimeOfDay_t* time) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_TIME_REF, DEFAULT_SEQUENCE_COUNT) { + initPacket(time); + } - SetTimeRef(Clock::TimeOfDay_t* time) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_TIME_REF, DEFAULT_SEQUENCE_COUNT) { - initPacket(time); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 34; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; -private: - - static const uint16_t DATA_FIELD_LENGTH = 34; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - void initPacket(Clock::TimeOfDay_t* time) { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&time->second, &data_field_ptr, &serializedSize, - sizeof(time->second), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&time->minute, &data_field_ptr, &serializedSize, - sizeof(time->minute), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&time->hour, &data_field_ptr, &serializedSize, - sizeof(time->hour), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&time->day, &data_field_ptr, &serializedSize, - sizeof(time->day), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&time->month, &data_field_ptr, &serializedSize, - sizeof(time->month), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&time->year, &data_field_ptr, &serializedSize, - sizeof(time->year), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint32_t milliseconds = time->usecond / 1000; - SerializeAdapter::serialize(&milliseconds, &data_field_ptr, &serializedSize, - sizeof(milliseconds), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint32_t isSet = 0xFFFFFFFF; - SerializeAdapter::serialize(&isSet, &data_field_ptr, &serializedSize, - sizeof(isSet), SerializeIF::Endianness::BIG); - serializedSize = 0; - /* Calculate crc */ - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - SerializeAdapter::serialize(&crc, &data_field_ptr, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket(Clock::TimeOfDay_t* time) { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&time->second, &data_field_ptr, &serializedSize, + sizeof(time->second), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&time->minute, &data_field_ptr, &serializedSize, + sizeof(time->minute), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&time->hour, &data_field_ptr, &serializedSize, + sizeof(time->hour), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&time->day, &data_field_ptr, &serializedSize, + sizeof(time->day), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&time->month, &data_field_ptr, &serializedSize, + sizeof(time->month), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&time->year, &data_field_ptr, &serializedSize, + sizeof(time->year), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint32_t milliseconds = time->usecond / 1000; + SerializeAdapter::serialize(&milliseconds, &data_field_ptr, &serializedSize, + sizeof(milliseconds), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint32_t isSet = 0xFFFFFFFF; + SerializeAdapter::serialize(&isSet, &data_field_ptr, &serializedSize, sizeof(isSet), + SerializeIF::Endianness::BIG); + serializedSize = 0; + /* Calculate crc */ + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + SerializeAdapter::serialize(&crc, &data_field_ptr, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class can be used to generate the set boot timout command. */ -class SetBootTimeout: public SpacePacket { -public: +class SetBootTimeout : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param timeout The boot timeout in milliseconds. + */ + SetBootTimeout(uint32_t timeout) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_BOOT_TIMEOUT, 1), timeout(timeout) { + initPacket(); + } - /** - * @brief Constructor - * - * @param timeout The boot timeout in milliseconds. - */ - SetBootTimeout(uint32_t timeout) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_BOOT_TIMEOUT, 1), timeout(timeout) { - initPacket(); - } + private: + uint32_t timeout = 0; -private: + /** boot timeout value (uint32_t) and crc (uint16_t) */ + static const uint16_t DATA_FIELD_LENGTH = 6; - uint32_t timeout = 0; - - /** boot timeout value (uint32_t) and crc (uint16_t) */ - static const uint16_t DATA_FIELD_LENGTH = 6; - - void initPacket() { - - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&timeout, &data_field_ptr, &serializedSize, - sizeof(timeout), SerializeIF::Endianness::BIG); - /* Calculate crc */ - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - /* Add crc to packet data field of space packet */ - serializedSize = 0; - SerializeAdapter::serialize(&crc, &data_field_ptr, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&timeout, &data_field_ptr, &serializedSize, + sizeof(timeout), SerializeIF::Endianness::BIG); + /* Calculate crc */ + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + /* Add crc to packet data field of space packet */ + serializedSize = 0; + SerializeAdapter::serialize(&crc, &data_field_ptr, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class can be used to generate the space packet to set the maximum boot tries. */ -class SetRestartTries: public SpacePacket { -public: +class SetRestartTries : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param restartTries Maximum restart tries to set. + */ + SetRestartTries(uint8_t restartTries) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_MAX_RESTART_TRIES, 1), + restartTries(restartTries) { + initPacket(); + } - /** - * @brief Constructor - * - * @param restartTries Maximum restart tries to set. - */ - SetRestartTries(uint8_t restartTries) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_MAX_RESTART_TRIES, 1), restartTries( - restartTries) { - initPacket(); - } + private: + uint8_t restartTries = 0; -private: + /** Restart tries value (uint8_t) and crc (uint16_t) */ + static const uint16_t DATA_FIELD_LENGTH = 3; - uint8_t restartTries = 0; - - /** Restart tries value (uint8_t) and crc (uint16_t) */ - static const uint16_t DATA_FIELD_LENGTH = 3; - - void initPacket() { - uint8_t* data_field_ptr = this->localData.fields.buffer; - *data_field_ptr = restartTries; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - size_t serializedSize = 0; - uint8_t* crcPtr = data_field_ptr + 1; - SerializeAdapter::serialize(&crc, &crcPtr, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + uint8_t* data_field_ptr = this->localData.fields.buffer; + *data_field_ptr = restartTries; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + size_t serializedSize = 0; + uint8_t* crcPtr = data_field_ptr + 1; + SerializeAdapter::serialize(&crc, &crcPtr, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the command to notify the supervisor that a new update for the * MPSoC is available. */ -class UpdateAvailable: public SpacePacket { -public: +class UpdateAvailable : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param imageSelect + * @param imagePartition + * @param imageSize + * @param imageCrc + * @param numberOfPackets + */ + UpdateAvailable(uint8_t imageSelect, uint8_t imagePartition, uint32_t imageSize, + uint32_t imageCrc, uint32_t numberOfPackets) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_UPDATE_AVAILABLE, DEFAULT_SEQUENCE_COUNT), + imageSelect(imageSelect), + imagePartition(imagePartition), + imageSize(imageSize), + imageCrc(imageCrc), + numberOfPackets(numberOfPackets) { + initPacket(); + } - /** - * @brief Constructor - * - * @param imageSelect - * @param imagePartition - * @param imageSize - * @param imageCrc - * @param numberOfPackets - */ - UpdateAvailable(uint8_t imageSelect, uint8_t imagePartition, uint32_t imageSize, - uint32_t imageCrc, uint32_t numberOfPackets) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_UPDATE_AVAILABLE, - DEFAULT_SEQUENCE_COUNT), imageSelect(imageSelect), imagePartition( - imagePartition), imageSize(imageSize), imageCrc(imageCrc), numberOfPackets( - numberOfPackets) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 16; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 16; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t imageSelect = 0; + uint8_t imagePartition = 0; + uint32_t imageSize = 0; + uint32_t imageCrc = 0; + uint32_t numberOfPackets = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t imageSelect = 0; - uint8_t imagePartition = 0; - uint32_t imageSize = 0; - uint32_t imageCrc = 0; - uint32_t numberOfPackets = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&imageSelect, &data_field_ptr, &serializedSize, - sizeof(imageSelect), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&imagePartition, &data_field_ptr, &serializedSize, - sizeof(imagePartition), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&imageSize, &data_field_ptr, &serializedSize, - sizeof(imageSize), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&imageCrc, &data_field_ptr, &serializedSize, - sizeof(imageCrc), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&numberOfPackets, &data_field_ptr, &serializedSize, - sizeof(numberOfPackets), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&imageSelect, &data_field_ptr, &serializedSize, + sizeof(imageSelect), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&imagePartition, &data_field_ptr, &serializedSize, + sizeof(imagePartition), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&imageSize, &data_field_ptr, &serializedSize, + sizeof(imageSize), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&imageCrc, &data_field_ptr, &serializedSize, + sizeof(imageCrc), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&numberOfPackets, &data_field_ptr, &serializedSize, + sizeof(numberOfPackets), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** @@ -497,130 +487,126 @@ private: * of housekeeping data. Normally, this will be disabled by default. However, adding this * command can be useful for debugging. */ -class DisablePeriodicHkTransmission: public SpacePacket { -public: +class DisablePeriodicHkTransmission : public SpacePacket { + public: + /** + * @brief Constructor + */ + DisablePeriodicHkTransmission() : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_DISABLE_HK, 1) { + initPacket(); + } - /** - * @brief Constructor - */ - DisablePeriodicHkTransmission() : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_DISABLE_HK, 1) { - initPacket(); - } + private: + uint8_t disableHk = 0; -private: + /** Restart tries value (uint8_t) and crc (uint16_t) */ + static const uint16_t DATA_FIELD_LENGTH = 3; - uint8_t disableHk = 0; - - /** Restart tries value (uint8_t) and crc (uint16_t) */ - static const uint16_t DATA_FIELD_LENGTH = 3; - - void initPacket() { - uint8_t* data_field_ptr = this->localData.fields.buffer; - *data_field_ptr = disableHk; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - size_t serializedSize = 0; - uint8_t* crcPtr = data_field_ptr + 1; - SerializeAdapter::serialize(&crc, &crcPtr, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + uint8_t* data_field_ptr = this->localData.fields.buffer; + *data_field_ptr = disableHk; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + size_t serializedSize = 0; + uint8_t* crcPtr = data_field_ptr + 1; + SerializeAdapter::serialize(&crc, &crcPtr, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the command to enable the watchdogs of the PLOC. */ -class WatchdogsEnable: public SpacePacket { -public: +class WatchdogsEnable : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param watchdogPs Enables processing system watchdog + * @param watchdogPl Enables programmable logic wathdog + * @param watchdogInt + */ + WatchdogsEnable(uint8_t watchdogPs, uint8_t watchdogPl, uint8_t watchdogInt) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_WTD_ENABLE, DEFAULT_SEQUENCE_COUNT), + watchdogPs(watchdogPs), + watchdogPl(watchdogPl), + watchdogInt(watchdogInt) { + initPacket(); + } - /** - * @brief Constructor - * - * @param watchdogPs Enables processing system watchdog - * @param watchdogPl Enables programmable logic wathdog - * @param watchdogInt - */ - WatchdogsEnable(uint8_t watchdogPs, uint8_t watchdogPl, uint8_t watchdogInt) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_WTD_ENABLE, DEFAULT_SEQUENCE_COUNT), - watchdogPs(watchdogPs), watchdogPl(watchdogPl), watchdogInt(watchdogInt) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 5; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 5; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t watchdogPs = 0; + uint8_t watchdogPl = 0; + uint8_t watchdogInt = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t watchdogPs = 0; - uint8_t watchdogPl = 0; - uint8_t watchdogInt = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&watchdogPs, &data_field_ptr, &serializedSize, - sizeof(watchdogPs), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&watchdogPl, &data_field_ptr, &serializedSize, - sizeof(watchdogPl), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&watchdogInt, &data_field_ptr, &serializedSize, - sizeof(watchdogInt), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&watchdogPs, &data_field_ptr, &serializedSize, + sizeof(watchdogPs), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&watchdogPl, &data_field_ptr, &serializedSize, + sizeof(watchdogPl), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&watchdogInt, &data_field_ptr, &serializedSize, + sizeof(watchdogInt), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the command to set the timeout of one of the three watchdogs (PS, * PL, INT) */ -class WatchdogsConfigTimeout: public SpacePacket { -public: +class WatchdogsConfigTimeout : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param watchdogPs Selects the watchdog to configure (0 - PS, 1 - PL, 2 - INT) + * @param timeout The timeout to set + */ + WatchdogsConfigTimeout(uint8_t watchdog, uint32_t timeout) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_WTD_CONFIG_TIMEOUT, DEFAULT_SEQUENCE_COUNT), + watchdog(watchdog), + timeout(timeout) { + initPacket(); + } - /** - * @brief Constructor - * - * @param watchdogPs Selects the watchdog to configure (0 - PS, 1 - PL, 2 - INT) - * @param timeout The timeout to set - */ - WatchdogsConfigTimeout(uint8_t watchdog, uint32_t timeout) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_WTD_CONFIG_TIMEOUT, - DEFAULT_SEQUENCE_COUNT), watchdog(watchdog), timeout(timeout) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 7; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 7; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t watchdog = 0; + uint32_t timeout = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t watchdog = 0; - uint32_t timeout = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&watchdog, &data_field_ptr, &serializedSize, - sizeof(watchdog), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&timeout, &data_field_ptr, &serializedSize, - sizeof(timeout), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&watchdog, &data_field_ptr, &serializedSize, + sizeof(watchdog), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&timeout, &data_field_ptr, &serializedSize, + sizeof(timeout), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** @@ -628,723 +614,693 @@ private: * * @details There are 7 different latchup alerts. */ -class LatchupAlert: public SpacePacket { -public: - - /** - * @brief Constructor - * - * @param state true - enable, false - disable - * @param latchupId Identifies the latchup to enable/disable (0 - 0.85V, 1 - 1.8V, 2 - MISC, - * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) - */ - LatchupAlert(bool state, uint8_t latchupId) : - SpacePacket(DATA_FIELD_LENGTH - 1, true), latchupId(latchupId) { - if (state) { - this->setAPID(APID_ENABLE_LATCHUP_ALERT); - } else { - this->setAPID(APID_DISABLE_LATCHUP_ALERT); - } - this->setPacketSequenceCount(DEFAULT_SEQUENCE_COUNT); - initPacket(); +class LatchupAlert : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param state true - enable, false - disable + * @param latchupId Identifies the latchup to enable/disable (0 - 0.85V, 1 - 1.8V, 2 - MISC, + * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) + */ + LatchupAlert(bool state, uint8_t latchupId) + : SpacePacket(DATA_FIELD_LENGTH - 1, true), latchupId(latchupId) { + if (state) { + this->setAPID(APID_ENABLE_LATCHUP_ALERT); + } else { + this->setAPID(APID_DISABLE_LATCHUP_ALERT); } + this->setPacketSequenceCount(DEFAULT_SEQUENCE_COUNT); + initPacket(); + } -private: + private: + static const uint16_t DATA_FIELD_LENGTH = 3; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; - static const uint16_t DATA_FIELD_LENGTH = 3; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; + uint8_t latchupId = 0; - uint8_t latchupId = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, - sizeof(latchupId), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, + sizeof(latchupId), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the command to calibrate a certain latchup alert. */ -class AutoCalibrateAlert: public SpacePacket { -public: +class AutoCalibrateAlert : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param latchupId Identifies the latchup alert to calibrate (0 - 0.85V, 1 - 1.8V, 2 - MISC, + * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) + * @param mg + */ + AutoCalibrateAlert(uint8_t latchupId, uint32_t mg) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_AUTO_CALIBRATE_ALERT, DEFAULT_SEQUENCE_COUNT), + latchupId(latchupId), + mg(mg) { + initPacket(); + } - /** - * @brief Constructor - * - * @param latchupId Identifies the latchup alert to calibrate (0 - 0.85V, 1 - 1.8V, 2 - MISC, - * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) - * @param mg - */ - AutoCalibrateAlert(uint8_t latchupId, uint32_t mg) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_AUTO_CALIBRATE_ALERT, - DEFAULT_SEQUENCE_COUNT), latchupId(latchupId), mg(mg) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 7; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 7; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t latchupId = 0; + uint32_t mg = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t latchupId = 0; - uint32_t mg = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, - sizeof(latchupId), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&mg, &data_field_ptr, &serializedSize, - sizeof(mg), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, + sizeof(latchupId), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&mg, &data_field_ptr, &serializedSize, sizeof(mg), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; +class SetAlertlimit : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param latchupId Identifies the latchup alert to calibrate (0 - 0.85V, 1 - 1.8V, 2 - MISC, + * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) + * @param dutycycle + */ + SetAlertlimit(uint8_t latchupId, uint32_t dutycycle) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ALERT_LIMIT, DEFAULT_SEQUENCE_COUNT), + latchupId(latchupId), + dutycycle(dutycycle) { + initPacket(); + } -class SetAlertlimit: public SpacePacket { -public: + private: + static const uint16_t DATA_FIELD_LENGTH = 7; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; - /** - * @brief Constructor - * - * @param latchupId Identifies the latchup alert to calibrate (0 - 0.85V, 1 - 1.8V, 2 - MISC, - * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) - * @param dutycycle - */ - SetAlertlimit(uint8_t latchupId, uint32_t dutycycle) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ALERT_LIMIT, - DEFAULT_SEQUENCE_COUNT), latchupId(latchupId), dutycycle(dutycycle) { - initPacket(); - } + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; -private: + uint8_t latchupId = 0; + uint32_t dutycycle = 0; - static const uint16_t DATA_FIELD_LENGTH = 7; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; - - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t latchupId = 0; - uint32_t dutycycle = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, - sizeof(latchupId), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&dutycycle, &data_field_ptr, &serializedSize, - sizeof(dutycycle), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, + sizeof(latchupId), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&dutycycle, &data_field_ptr, &serializedSize, + sizeof(dutycycle), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; -class SetAlertIrqFilter: public SpacePacket { -public: +class SetAlertIrqFilter : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param latchupId Identifies the latchup alert to calibrate (0 - 0.85V, 1 - 1.8V, 2 - MISC, + * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) + * @param tp + * @param div + */ + SetAlertIrqFilter(uint8_t latchupId, uint8_t tp, uint8_t div) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ALERT_IRQ_FILTER, DEFAULT_SEQUENCE_COUNT), + tp(tp), + div(div) { + initPacket(); + } - /** - * @brief Constructor - * - * @param latchupId Identifies the latchup alert to calibrate (0 - 0.85V, 1 - 1.8V, 2 - MISC, - * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) - * @param tp - * @param div - */ - SetAlertIrqFilter(uint8_t latchupId, uint8_t tp, uint8_t div) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ALERT_IRQ_FILTER, - DEFAULT_SEQUENCE_COUNT), tp(tp), div(div) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 5; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 5; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t latchupId = 0; + uint8_t tp = 0; + uint8_t div = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t latchupId = 0; - uint8_t tp = 0; - uint8_t div = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, - sizeof(latchupId), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&tp, &data_field_ptr, &serializedSize, - sizeof(tp), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&div, &data_field_ptr, &serializedSize, - sizeof(div), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, + sizeof(latchupId), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&tp, &data_field_ptr, &serializedSize, sizeof(tp), + SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&div, &data_field_ptr, &serializedSize, sizeof(div), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; - /** * @brief This class packages the space packet to set the sweep period of the ADC. */ -class SetAdcSweepPeriod: public SpacePacket { -public: +class SetAdcSweepPeriod : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param sweepPeriod Sweep period in us. minimum is 21 us + */ + SetAdcSweepPeriod(uint32_t sweepPeriod) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_SWEEP_PERIOD, DEFAULT_SEQUENCE_COUNT), + sweepPeriod(sweepPeriod) { + initPacket(); + } - /** - * @brief Constructor - * - * @param sweepPeriod Sweep period in us. minimum is 21 us - */ - SetAdcSweepPeriod(uint32_t sweepPeriod) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_SWEEP_PERIOD, - DEFAULT_SEQUENCE_COUNT), sweepPeriod(sweepPeriod) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 6; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 6; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint32_t sweepPeriod = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint32_t sweepPeriod = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&sweepPeriod, &data_field_ptr, &serializedSize, - sizeof(sweepPeriod), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&sweepPeriod, &data_field_ptr, &serializedSize, + sizeof(sweepPeriod), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet to enable or disable ADC channels. */ -class SetAdcEnabledChannels: public SpacePacket { -public: +class SetAdcEnabledChannels : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param ch Defines channels to be enabled or disabled. + */ + SetAdcEnabledChannels(uint16_t ch) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_ENABLED_CHANNELS, + DEFAULT_SEQUENCE_COUNT), + ch(ch) { + initPacket(); + } - /** - * @brief Constructor - * - * @param ch Defines channels to be enabled or disabled. - */ - SetAdcEnabledChannels(uint16_t ch) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_ENABLED_CHANNELS, - DEFAULT_SEQUENCE_COUNT), ch(ch) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 4; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 4; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint16_t ch = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint16_t ch = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&ch, &data_field_ptr, &serializedSize, - sizeof(ch), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&ch, &data_field_ptr, &serializedSize, sizeof(ch), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet to configures the window size and striding step of * the moving average filter applied to the ADC readings. */ -class SetAdcWindowAndStride: public SpacePacket { -public: +class SetAdcWindowAndStride : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param windowSize + * @param stridingStepSize + */ + SetAdcWindowAndStride(uint16_t windowSize, uint16_t stridingStepSize) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_WINDOW_AND_STRIDE, + DEFAULT_SEQUENCE_COUNT), + windowSize(windowSize), + stridingStepSize(stridingStepSize) { + initPacket(); + } - /** - * @brief Constructor - * - * @param windowSize - * @param stridingStepSize - */ - SetAdcWindowAndStride(uint16_t windowSize, uint16_t stridingStepSize) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_WINDOW_AND_STRIDE, - DEFAULT_SEQUENCE_COUNT), windowSize(windowSize), stridingStepSize( - stridingStepSize) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 6; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 6; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint16_t windowSize = 0; + uint16_t stridingStepSize = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint16_t windowSize = 0; - uint16_t stridingStepSize = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&windowSize, &data_field_ptr, &serializedSize, - sizeof(windowSize), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&stridingStepSize, &data_field_ptr, &serializedSize, - sizeof(stridingStepSize), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&windowSize, &data_field_ptr, &serializedSize, + sizeof(windowSize), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&stridingStepSize, &data_field_ptr, &serializedSize, + sizeof(stridingStepSize), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet to set the ADC trigger threshold. */ -class SetAdcThreshold: public SpacePacket { -public: +class SetAdcThreshold : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param threshold + */ + SetAdcThreshold(uint32_t threshold) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_THRESHOLD, DEFAULT_SEQUENCE_COUNT), + threshold(threshold) { + initPacket(); + } - /** - * @brief Constructor - * - * @param threshold - */ - SetAdcThreshold(uint32_t threshold) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_THRESHOLD, - DEFAULT_SEQUENCE_COUNT), threshold(threshold) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 6; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 6; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint32_t threshold = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint32_t threshold = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&threshold, &data_field_ptr, &serializedSize, - sizeof(threshold), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&threshold, &data_field_ptr, &serializedSize, + sizeof(threshold), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet to select between NVM 0 and NVM 1. */ -class SelectNvm: public SpacePacket { -public: +class SelectNvm : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param mem 0 - select NVM0, 1 - select NVM1. + */ + SelectNvm(uint8_t mem) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SELECT_NVM, DEFAULT_SEQUENCE_COUNT), + mem(mem) { + initPacket(); + } - /** - * @brief Constructor - * - * @param mem 0 - select NVM0, 1 - select NVM1. - */ - SelectNvm(uint8_t mem) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SELECT_NVM, - DEFAULT_SEQUENCE_COUNT), mem(mem) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 3; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 3; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t mem = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t mem = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&mem, &data_field_ptr, &serializedSize, - sizeof(mem), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&mem, &data_field_ptr, &serializedSize, sizeof(mem), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet to power the NVMs on or off. */ -class EnableNvms: public SpacePacket { -public: +class EnableNvms : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param n01 Set to one to power NVM0 and NVM1 on. 0 powers off memory. + * @param n3 Set to one to power NVM3 on. 0 powers off the memory. + */ + EnableNvms(uint8_t n01, uint8_t n3) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_ENABLE_NVMS, DEFAULT_SEQUENCE_COUNT), + n01(n01), + n3(n3) { + initPacket(); + } - /** - * @brief Constructor - * - * @param n01 Set to one to power NVM0 and NVM1 on. 0 powers off memory. - * @param n3 Set to one to power NVM3 on. 0 powers off the memory. - */ - EnableNvms(uint8_t n01, uint8_t n3) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_ENABLE_NVMS, - DEFAULT_SEQUENCE_COUNT), n01(n01), n3(n3) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 4; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 4; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t n01 = 0; + uint8_t n3 = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t n01 = 0; - uint8_t n3 = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&n01, &data_field_ptr, &serializedSize, - sizeof(n01), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&n3, &data_field_ptr, &serializedSize, - sizeof(n3), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&n01, &data_field_ptr, &serializedSize, sizeof(n01), + SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&n3, &data_field_ptr, &serializedSize, sizeof(n3), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet to run auto EM tests. */ -class RunAutoEmTests: public SpacePacket { -public: +class RunAutoEmTests : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param test 1 - complete EM test, 2 - Short test (only memory readback NVM0,1,3) + */ + RunAutoEmTests(uint8_t test) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_RUN_AUTO_EM_TESTS, DEFAULT_SEQUENCE_COUNT), + test(test) { + initPacket(); + } - /** - * @brief Constructor - * - * @param test 1 - complete EM test, 2 - Short test (only memory readback NVM0,1,3) - */ - RunAutoEmTests(uint8_t test) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_RUN_AUTO_EM_TESTS, - DEFAULT_SEQUENCE_COUNT), test(test) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 3; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 3; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t test = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t test = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&test, &data_field_ptr, &serializedSize, - sizeof(test), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&test, &data_field_ptr, &serializedSize, sizeof(test), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet causing the supervisor to print the CPU load to * the debug output. */ -class PrintCpuStats: public SpacePacket { -public: +class PrintCpuStats : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param en Print is enabled if en != 0 + */ + PrintCpuStats(uint8_t en) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_PRINT_CPU_STATS, DEFAULT_SEQUENCE_COUNT), + en(en) { + initPacket(); + } - /** - * @brief Constructor - * - * @param en Print is enabled if en != 0 - */ - PrintCpuStats(uint8_t en) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_PRINT_CPU_STATS, - DEFAULT_SEQUENCE_COUNT), en(en) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 3; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 3; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t en = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t en = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&en, &data_field_ptr, &serializedSize, - sizeof(en), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&en, &data_field_ptr, &serializedSize, sizeof(en), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet to set the print verbosity in the supervisor * software. */ -class SetDbgVerbosity: public SpacePacket { -public: +class SetDbgVerbosity : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param vb 0: None, 1: Error, 2: Warn, 3: Info + */ + SetDbgVerbosity(uint8_t vb) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_DBG_VERBOSITY, DEFAULT_SEQUENCE_COUNT), + vb(vb) { + initPacket(); + } - /** - * @brief Constructor - * - * @param vb 0: None, 1: Error, 2: Warn, 3: Info - */ - SetDbgVerbosity(uint8_t vb) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_DBG_VERBOSITY, - DEFAULT_SEQUENCE_COUNT), vb(vb) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 3; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 3; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t vb = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t vb = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&vb, &data_field_ptr, &serializedSize, - sizeof(vb), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&vb, &data_field_ptr, &serializedSize, sizeof(vb), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; - /** * @brief This class packages the space packet to wipe or dump parts of the MRAM. */ -class MramCmd: public SpacePacket { -public: +class MramCmd : public SpacePacket { + public: + enum class MramAction { WIPE, DUMP }; - enum class MramAction { - WIPE, - DUMP - }; - - /** - * @brief Constructor - * - * @param start Start address of the MRAM section to wipe or dump - * @param stop End address of the MRAM section to wipe or dump - * @param action Dump or wipe MRAM - * - * @note The content at the stop address is excluded from the dump or wipe operation. - */ - MramCmd(uint32_t start, uint32_t stop, MramAction action) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_IDLE_PACKET, - DEFAULT_SEQUENCE_COUNT), start(start), stop(stop) { - if(action == MramAction::WIPE) { - this->setAPID(APID_WIPE_MRAM); - } - else if (action == MramAction::DUMP) { - this->setAPID(APID_DUMP_MRAM); - } - else { - sif::debug << "WipeMram: Invalid action specified"; - } - initPacket(); + /** + * @brief Constructor + * + * @param start Start address of the MRAM section to wipe or dump + * @param stop End address of the MRAM section to wipe or dump + * @param action Dump or wipe MRAM + * + * @note The content at the stop address is excluded from the dump or wipe operation. + */ + MramCmd(uint32_t start, uint32_t stop, MramAction action) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_IDLE_PACKET, DEFAULT_SEQUENCE_COUNT), + start(start), + stop(stop) { + if (action == MramAction::WIPE) { + this->setAPID(APID_WIPE_MRAM); + } else if (action == MramAction::DUMP) { + this->setAPID(APID_DUMP_MRAM); + } else { + sif::debug << "WipeMram: Invalid action specified"; } + initPacket(); + } -private: + private: + static const uint16_t DATA_FIELD_LENGTH = 8; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; - static const uint16_t DATA_FIELD_LENGTH = 8; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; + uint32_t start = 0; + uint32_t stop = 0; - uint32_t start = 0; - uint32_t stop = 0; - - void initPacket() { - uint8_t concatBuffer[6]; - concatBuffer[0] = static_cast(start >> 16); - concatBuffer[1] = static_cast(start >> 8); - concatBuffer[2] = static_cast(start); - concatBuffer[3] = static_cast(stop >> 16); - concatBuffer[4] = static_cast(stop >> 8); - concatBuffer[5] = static_cast(stop); - uint8_t* data_field_ptr = this->localData.fields.buffer; - std::memcpy(data_field_ptr, concatBuffer, sizeof(concatBuffer)); - size_t serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + uint8_t concatBuffer[6]; + concatBuffer[0] = static_cast(start >> 16); + concatBuffer[1] = static_cast(start >> 8); + concatBuffer[2] = static_cast(start); + concatBuffer[3] = static_cast(stop >> 16); + concatBuffer[4] = static_cast(stop >> 8); + concatBuffer[5] = static_cast(stop); + uint8_t* data_field_ptr = this->localData.fields.buffer; + std::memcpy(data_field_ptr, concatBuffer, sizeof(concatBuffer)); + size_t serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet change the state of a GPIO. This command is only * required for ground testing. */ -class SetGpio: public SpacePacket { -public: +class SetGpio : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param port + * @param pin + * @param val + */ + SetGpio(uint8_t port, uint8_t pin, uint8_t val) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_GPIO, DEFAULT_SEQUENCE_COUNT), + port(port), + pin(pin), + val(val) { + initPacket(); + } - /** - * @brief Constructor - * - * @param port - * @param pin - * @param val - */ - SetGpio(uint8_t port, uint8_t pin, uint8_t val) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_GPIO, - DEFAULT_SEQUENCE_COUNT), port(port), pin(pin), val(val) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 5; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 5; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t port = 0; + uint8_t pin = 0; + uint8_t val = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t port = 0; - uint8_t pin = 0; - uint8_t val = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&port, &data_field_ptr, &serializedSize, - sizeof(port), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&pin, &data_field_ptr, &serializedSize, - sizeof(pin), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&val, &data_field_ptr, &serializedSize, - sizeof(val), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&port, &data_field_ptr, &serializedSize, sizeof(port), + SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&pin, &data_field_ptr, &serializedSize, sizeof(pin), + SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&val, &data_field_ptr, &serializedSize, sizeof(val), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet causing the supervisor print the state of a GPIO * to the debug output. */ -class ReadGpio: public SpacePacket { -public: +class ReadGpio : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param port + * @param pin + */ + ReadGpio(uint8_t port, uint8_t pin) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_READ_GPIO, DEFAULT_SEQUENCE_COUNT), + port(port), + pin(pin) { + initPacket(); + } - /** - * @brief Constructor - * - * @param port - * @param pin - */ - ReadGpio(uint8_t port, uint8_t pin) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_READ_GPIO, - DEFAULT_SEQUENCE_COUNT), port(port), pin(pin) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 4; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 4; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t port = 0; + uint8_t pin = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t port = 0; - uint8_t pin = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&port, &data_field_ptr, &serializedSize, - sizeof(port), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&pin, &data_field_ptr, &serializedSize, - sizeof(pin), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&port, &data_field_ptr, &serializedSize, sizeof(port), + SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&pin, &data_field_ptr, &serializedSize, sizeof(pin), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** @@ -1355,255 +1311,236 @@ private: * OP = 0x01: Only the mirror entries will be wiped. * OP = 0x02: Only the circular entries will be wiped. */ -class FactoryReset: public SpacePacket { -public: +class FactoryReset : public SpacePacket { + public: + enum class Op { CLEAR_ALL, MIRROR_ENTRIES, CIRCULAR_ENTRIES }; - enum class Op { - CLEAR_ALL, - MIRROR_ENTRIES, - CIRCULAR_ENTRIES - }; + /** + * @brief Constructor + * + * @param op + */ + FactoryReset(Op op) : SpacePacket(0, true, APID_FACTORY_RESET, DEFAULT_SEQUENCE_COUNT), op(op) { + initPacket(); + } - /** - * @brief Constructor - * - * @param op - */ - FactoryReset(Op op) : - SpacePacket(0, true, APID_FACTORY_RESET, - DEFAULT_SEQUENCE_COUNT), op(op) { - initPacket(); - } - -private: - - uint16_t packetLen = 1; // only CRC in data field - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; - - uint8_t crcOffset = 0; - - Op op = Op::CLEAR_ALL; - - void initPacket() { - - uint8_t* data_field_ptr = this->localData.fields.buffer; - - switch(op) { - case Op::MIRROR_ENTRIES: - *data_field_ptr = 1; - packetLen = 2; - crcOffset = 1; - break; - case Op::CIRCULAR_ENTRIES: - *data_field_ptr = 2; - packetLen = 2; - crcOffset = 1; - break; - default: - break; - } - this->setPacketDataLength(packetLen); - size_t serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + packetLen - 1); - uint8_t* crcPos = this->localData.fields.buffer + crcOffset; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); + private: + uint16_t packetLen = 1; // only CRC in data field + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + + uint8_t crcOffset = 0; + + Op op = Op::CLEAR_ALL; + + void initPacket() { + uint8_t* data_field_ptr = this->localData.fields.buffer; + + switch (op) { + case Op::MIRROR_ENTRIES: + *data_field_ptr = 1; + packetLen = 2; + crcOffset = 1; + break; + case Op::CIRCULAR_ENTRIES: + *data_field_ptr = 2; + packetLen = 2; + crcOffset = 1; + break; + default: + break; } + this->setPacketDataLength(packetLen); + size_t serializedSize = 0; + uint16_t crc = + CRC::crc16ccitt(this->localData.byteStream, sizeof(CCSDSPrimaryHeader) + packetLen - 1); + uint8_t* crcPos = this->localData.fields.buffer + crcOffset; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; class SupvTcSpacePacket : public SpacePacket { -public: - SupvTcSpacePacket(size_t payloadDataLen, uint16_t apid) : - SpacePacket(payloadDataLen + 1, true, apid, - DEFAULT_SEQUENCE_COUNT), payloadDataLen(payloadDataLen) { - } + public: + SupvTcSpacePacket(size_t payloadDataLen, uint16_t apid) + : SpacePacket(payloadDataLen + 1, true, apid, DEFAULT_SEQUENCE_COUNT), + payloadDataLen(payloadDataLen) {} - void makeCrc() { - size_t serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + payloadDataLen); - uint8_t* crcPos = this->localData.fields.buffer + payloadDataLen; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void makeCrc() { + size_t serializedSize = 0; + uint16_t crc = + CRC::crc16ccitt(this->localData.byteStream, sizeof(CCSDSPrimaryHeader) + payloadDataLen); + uint8_t* crcPos = this->localData.fields.buffer + payloadDataLen; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } -private: - // The sequence count of most of the TC packets for the supervisor is 1. - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + private: + // The sequence count of most of the TC packets for the supervisor is 1. + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; - // The size of the payload data (data field without crc size) - size_t payloadDataLen = 0; + // The size of the payload data (data field without crc size) + size_t payloadDataLen = 0; }; /** * @brief This class can be used to package the update available or update verify command. */ -class UpdateInfo: public SupvTcSpacePacket { -public: +class UpdateInfo : public SupvTcSpacePacket { + public: + /** + * @brief Constructor + * + * @param apid Packet can be used to generate the update available and the update verify + * packet. Thus the APID must be specified here. + * @param image The image to update on a NVM (A - 0, B - 1) + * @param partition The partition to update. uboot - 1, bitstream - 2, linux - 3, + * application - 4 + * @param imageSize The size of the update image + * param numPackets The number of space packets required to transfer all data. + */ + UpdateInfo(uint16_t apid, uint8_t image, uint8_t partition, uint32_t imageSize, uint32_t imageCrc, + uint32_t numPackets) + : SupvTcSpacePacket(PAYLOAD_LENGTH, apid), + image(image), + partition(partition), + imageSize(imageSize), + imageCrc(imageCrc), + numPackets(numPackets) { + initPacket(); + makeCrc(); + } - /** - * @brief Constructor - * - * @param apid Packet can be used to generate the update available and the update verify - * packet. Thus the APID must be specified here. - * @param image The image to update on a NVM (A - 0, B - 1) - * @param partition The partition to update. uboot - 1, bitstream - 2, linux - 3, - * application - 4 - * @param imageSize The size of the update image - * param numPackets The number of space packets required to transfer all data. - */ - UpdateInfo(uint16_t apid, uint8_t image, uint8_t partition, uint32_t imageSize, - uint32_t imageCrc, uint32_t numPackets) : - SupvTcSpacePacket(PAYLOAD_LENGTH, apid), image(image), partition(partition), imageSize( - imageSize), imageCrc(imageCrc), numPackets(numPackets) { - initPacket(); - makeCrc(); - } + private: + static const uint16_t PAYLOAD_LENGTH = 14; // length without CRC field -private: + uint8_t image = 0; + uint8_t partition = 0; + uint32_t imageSize = 0; + uint32_t imageCrc = 0; + uint32_t numPackets = 0; - static const uint16_t PAYLOAD_LENGTH = 14; // length without CRC field - - uint8_t image = 0; - uint8_t partition = 0; - uint32_t imageSize = 0; - uint32_t imageCrc = 0; - uint32_t numPackets = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&image, &data_field_ptr, &serializedSize, - sizeof(image), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&partition, &data_field_ptr, &serializedSize, - sizeof(partition), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&imageSize, &data_field_ptr, &serializedSize, - sizeof(imageSize), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&imageCrc, &data_field_ptr, &serializedSize, - sizeof(imageCrc), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&numPackets, &data_field_ptr, &serializedSize, - sizeof(numPackets), SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&image, &data_field_ptr, &serializedSize, sizeof(image), + SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&partition, &data_field_ptr, &serializedSize, + sizeof(partition), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&imageSize, &data_field_ptr, &serializedSize, + sizeof(imageSize), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&imageCrc, &data_field_ptr, &serializedSize, + sizeof(imageCrc), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&numPackets, &data_field_ptr, &serializedSize, + sizeof(numPackets), SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet transporting a part of an MPSoC update. */ -class UpdatePacket: public SupvTcSpacePacket { -public: +class UpdatePacket : public SupvTcSpacePacket { + public: + /** + * @brief Constructor + * + * @param payloadLength Update data length (data field length without CRC) + */ + UpdatePacket(uint16_t payloadLength) : SupvTcSpacePacket(payloadLength, APID_UPDATE_IMAGE_DATA) {} - /** - * @brief Constructor - * - * @param payloadLength Update data length (data field length without CRC) - */ - UpdatePacket(uint16_t payloadLength) : - SupvTcSpacePacket(payloadLength, APID_UPDATE_IMAGE_DATA) { - } - - /** - * @brief Returns the pointer to the beginning of the data field. - */ - uint8_t* getDataFieldPointer() { - return this->localData.fields.buffer; - } + /** + * @brief Returns the pointer to the beginning of the data field. + */ + uint8_t* getDataFieldPointer() { return this->localData.fields.buffer; } }; /** * @brief This dataset stores the boot status report of the supervisor. */ -class BootStatusReport: public StaticLocalDataSet { -public: +class BootStatusReport : public StaticLocalDataSet { + public: + BootStatusReport(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, BOOT_REPORT_SET_ID) {} - BootStatusReport(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, BOOT_REPORT_SET_ID) { - } + BootStatusReport(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, BOOT_REPORT_SET_ID)) {} - BootStatusReport(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, BOOT_REPORT_SET_ID)) { - } - - /** Information about boot status of MPSoC */ - lp_var_t bootSignal = lp_var_t(sid.objectId, PoolIds::BOOT_SIGNAL, this); - lp_var_t resetCounter = lp_var_t(sid.objectId, PoolIds::RESET_COUNTER, this); - /** Time the MPSoC needs for last boot */ - lp_var_t bootAfterMs = lp_var_t(sid.objectId, PoolIds::BOOT_AFTER_MS, this); - /** The currently set boot timeout */ - lp_var_t bootTimeoutMs = lp_var_t(sid.objectId, PoolIds::BOOT_TIMEOUT_MS, this); - lp_var_t activeNvm = lp_var_t(sid.objectId, PoolIds::ACTIVE_NVM, this); - /** States of the boot partition pins */ - lp_var_t bp0State = lp_var_t(sid.objectId, PoolIds::BP0_STATE, this); - lp_var_t bp1State = lp_var_t(sid.objectId, PoolIds::BP1_STATE, this); - lp_var_t bp2State = lp_var_t(sid.objectId, PoolIds::BP2_STATE, this); + /** Information about boot status of MPSoC */ + lp_var_t bootSignal = lp_var_t(sid.objectId, PoolIds::BOOT_SIGNAL, this); + lp_var_t resetCounter = lp_var_t(sid.objectId, PoolIds::RESET_COUNTER, this); + /** Time the MPSoC needs for last boot */ + lp_var_t bootAfterMs = lp_var_t(sid.objectId, PoolIds::BOOT_AFTER_MS, this); + /** The currently set boot timeout */ + lp_var_t bootTimeoutMs = + lp_var_t(sid.objectId, PoolIds::BOOT_TIMEOUT_MS, this); + lp_var_t activeNvm = lp_var_t(sid.objectId, PoolIds::ACTIVE_NVM, this); + /** States of the boot partition pins */ + lp_var_t bp0State = lp_var_t(sid.objectId, PoolIds::BP0_STATE, this); + lp_var_t bp1State = lp_var_t(sid.objectId, PoolIds::BP1_STATE, this); + lp_var_t bp2State = lp_var_t(sid.objectId, PoolIds::BP2_STATE, this); }; /** * @brief This dataset stores the housekeeping data of the supervisor. */ -class HkSet: public StaticLocalDataSet { -public: +class HkSet : public StaticLocalDataSet { + public: + HkSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_SET_ID) {} - HkSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, HK_SET_ID) { - } + HkSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, HK_SET_ID)) {} - HkSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, HK_SET_ID)) { - } - - lp_var_t tempPs = lp_var_t(sid.objectId, PoolIds::TEMP_PS, this); - lp_var_t tempPl = lp_var_t(sid.objectId, PoolIds::TEMP_PS, this); - lp_var_t tempSup = lp_var_t(sid.objectId, PoolIds::TEMP_SUP, this); - lp_var_t uptime = lp_var_t(sid.objectId, PoolIds::UPTIME, this); - lp_var_t cpuLoad = lp_var_t(sid.objectId, PoolIds::CPULOAD, this); - lp_var_t availableHeap = lp_var_t(sid.objectId, PoolIds::AVAILABLEHEAP, - this); - lp_var_t numTcs = lp_var_t(sid.objectId, PoolIds::NUM_TCS, this); - lp_var_t numTms = lp_var_t(sid.objectId, PoolIds::NUM_TMS, this); - lp_var_t socState = lp_var_t(sid.objectId, PoolIds::SOC_STATE, this); - lp_var_t nvm0_1_state = lp_var_t(sid.objectId, PoolIds::NVM0_1_STATE, this); - lp_var_t nvm3_state = lp_var_t(sid.objectId, PoolIds::NVM3_STATE, this); - lp_var_t missionIoState = lp_var_t(sid.objectId, PoolIds::MISSION_IO_STATE, - this); - lp_var_t fmcState = lp_var_t(sid.objectId, PoolIds::FMC_STATE, this); + lp_var_t tempPs = lp_var_t(sid.objectId, PoolIds::TEMP_PS, this); + lp_var_t tempPl = lp_var_t(sid.objectId, PoolIds::TEMP_PS, this); + lp_var_t tempSup = lp_var_t(sid.objectId, PoolIds::TEMP_SUP, this); + lp_var_t uptime = lp_var_t(sid.objectId, PoolIds::UPTIME, this); + lp_var_t cpuLoad = lp_var_t(sid.objectId, PoolIds::CPULOAD, this); + lp_var_t availableHeap = lp_var_t(sid.objectId, PoolIds::AVAILABLEHEAP, this); + lp_var_t numTcs = lp_var_t(sid.objectId, PoolIds::NUM_TCS, this); + lp_var_t numTms = lp_var_t(sid.objectId, PoolIds::NUM_TMS, this); + lp_var_t socState = lp_var_t(sid.objectId, PoolIds::SOC_STATE, this); + lp_var_t nvm0_1_state = lp_var_t(sid.objectId, PoolIds::NVM0_1_STATE, this); + lp_var_t nvm3_state = lp_var_t(sid.objectId, PoolIds::NVM3_STATE, this); + lp_var_t missionIoState = + lp_var_t(sid.objectId, PoolIds::MISSION_IO_STATE, this); + lp_var_t fmcState = lp_var_t(sid.objectId, PoolIds::FMC_STATE, this); }; /** * @brief This dataset stores the last requested latchup status report. */ -class LatchupStatusReport: public StaticLocalDataSet { -public: +class LatchupStatusReport : public StaticLocalDataSet { + public: + LatchupStatusReport(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, LATCHUP_RPT_ID) {} - LatchupStatusReport(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, LATCHUP_RPT_ID) { - } + LatchupStatusReport(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, LATCHUP_RPT_ID)) {} - LatchupStatusReport(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, LATCHUP_RPT_ID)) { - } - - lp_var_t id = lp_var_t(sid.objectId, PoolIds::LATCHUP_ID, this); - lp_var_t cnt0 = lp_var_t(sid.objectId, PoolIds::CNT0, this); - lp_var_t cnt1 = lp_var_t(sid.objectId, PoolIds::CNT1, this); - lp_var_t cnt2 = lp_var_t(sid.objectId, PoolIds::CNT2, this); - lp_var_t cnt3 = lp_var_t(sid.objectId, PoolIds::CNT3, this); - lp_var_t cnt4 = lp_var_t(sid.objectId, PoolIds::CNT4, this); - lp_var_t cnt5 = lp_var_t(sid.objectId, PoolIds::CNT5, this); - lp_var_t cnt6 = lp_var_t(sid.objectId, PoolIds::CNT6, this); - lp_var_t timeSec = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_SEC, this); - lp_var_t timeMin = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MIN, this); - lp_var_t timeHour = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_HOUR, this); - lp_var_t timeDay = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_DAY, this); - lp_var_t timeMon = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MON, this); - lp_var_t timeYear = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_YEAR, this); - lp_var_t timeMsec = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MSEC, this); - lp_var_t isSet = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_IS_SET, this); + lp_var_t id = lp_var_t(sid.objectId, PoolIds::LATCHUP_ID, this); + lp_var_t cnt0 = lp_var_t(sid.objectId, PoolIds::CNT0, this); + lp_var_t cnt1 = lp_var_t(sid.objectId, PoolIds::CNT1, this); + lp_var_t cnt2 = lp_var_t(sid.objectId, PoolIds::CNT2, this); + lp_var_t cnt3 = lp_var_t(sid.objectId, PoolIds::CNT3, this); + lp_var_t cnt4 = lp_var_t(sid.objectId, PoolIds::CNT4, this); + lp_var_t cnt5 = lp_var_t(sid.objectId, PoolIds::CNT5, this); + lp_var_t cnt6 = lp_var_t(sid.objectId, PoolIds::CNT6, this); + lp_var_t timeSec = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_SEC, this); + lp_var_t timeMin = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MIN, this); + lp_var_t timeHour = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_HOUR, this); + lp_var_t timeDay = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_DAY, this); + lp_var_t timeMon = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MON, this); + lp_var_t timeYear = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_YEAR, this); + lp_var_t timeMsec = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MSEC, this); + lp_var_t isSet = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_IS_SET, this); }; -} +} // namespace PLOC_SPV #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCSVPDEFINITIONS_H_ */ diff --git a/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.cpp b/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.cpp index 4e7c9458..9d8d7bbf 100644 --- a/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.cpp +++ b/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.cpp @@ -1,78 +1,62 @@ #include "ArcsecDatalinkLayer.h" -ArcsecDatalinkLayer::ArcsecDatalinkLayer() { - slipInit(); -} +ArcsecDatalinkLayer::ArcsecDatalinkLayer() { slipInit(); } -ArcsecDatalinkLayer::~ArcsecDatalinkLayer() { -} +ArcsecDatalinkLayer::~ArcsecDatalinkLayer() {} void ArcsecDatalinkLayer::slipInit() { - slipInfo.buffer = rxBuffer; - slipInfo.maxlength = StarTracker::MAX_FRAME_SIZE; - slipInfo.length = 0; - slipInfo.unescape_next = 0; - slipInfo.prev_state = SLIP_COMPLETE; + slipInfo.buffer = rxBuffer; + slipInfo.maxlength = StarTracker::MAX_FRAME_SIZE; + slipInfo.length = 0; + slipInfo.unescape_next = 0; + slipInfo.prev_state = SLIP_COMPLETE; } ReturnValue_t ArcsecDatalinkLayer::decodeFrame(const uint8_t* rawData, size_t rawDataSize, - size_t* bytesLeft) { - size_t bytePos = 0; - for (bytePos = 0; bytePos < rawDataSize; bytePos++) { - enum arc_dec_result decResult = arc_transport_decode_body(*(rawData + bytePos), &slipInfo, - decodedFrame, &decFrameSize); - *bytesLeft = rawDataSize - bytePos - 1; - switch (decResult) { - case ARC_DEC_INPROGRESS: { - if (bytePos == rawDataSize - 1) { - return DEC_IN_PROGRESS; - } - continue; - } - case ARC_DEC_ERROR_FRAME_SHORT: - return REPLY_TOO_SHORT; - case ARC_DEC_ERROR_CHECKSUM: - return CRC_FAILURE; - case ARC_DEC_ASYNC: - case ARC_DEC_SYNC: { - // Reset length of SLIP struct for next frame - slipInfo.length = 0; - return RETURN_OK; - } - default: - sif::debug << "ArcsecDatalinkLayer::decodeFrame: Unknown result code" << std::endl; - break; - return RETURN_FAILED; + size_t* bytesLeft) { + size_t bytePos = 0; + for (bytePos = 0; bytePos < rawDataSize; bytePos++) { + enum arc_dec_result decResult = + arc_transport_decode_body(*(rawData + bytePos), &slipInfo, decodedFrame, &decFrameSize); + *bytesLeft = rawDataSize - bytePos - 1; + switch (decResult) { + case ARC_DEC_INPROGRESS: { + if (bytePos == rawDataSize - 1) { + return DEC_IN_PROGRESS; } + continue; + } + case ARC_DEC_ERROR_FRAME_SHORT: + return REPLY_TOO_SHORT; + case ARC_DEC_ERROR_CHECKSUM: + return CRC_FAILURE; + case ARC_DEC_ASYNC: + case ARC_DEC_SYNC: { + // Reset length of SLIP struct for next frame + slipInfo.length = 0; + return RETURN_OK; + } + default: + sif::debug << "ArcsecDatalinkLayer::decodeFrame: Unknown result code" << std::endl; + break; + return RETURN_FAILED; } - return RETURN_FAILED; + } + return RETURN_FAILED; } -uint8_t ArcsecDatalinkLayer::getReplyFrameType() { - return decodedFrame[0]; -} +uint8_t ArcsecDatalinkLayer::getReplyFrameType() { return decodedFrame[0]; } -const uint8_t* ArcsecDatalinkLayer::getReply() { - return &decodedFrame[1]; -} +const uint8_t* ArcsecDatalinkLayer::getReply() { return &decodedFrame[1]; } void ArcsecDatalinkLayer::encodeFrame(const uint8_t* data, uint32_t length) { - arc_transport_encode_body(data, length, encBuffer, &encFrameSize); + arc_transport_encode_body(data, length, encBuffer, &encFrameSize); } -uint8_t* ArcsecDatalinkLayer::getEncodedFrame() { - return encBuffer; -} +uint8_t* ArcsecDatalinkLayer::getEncodedFrame() { return encBuffer; } -uint32_t ArcsecDatalinkLayer::getEncodedLength() { - return encFrameSize; -} +uint32_t ArcsecDatalinkLayer::getEncodedLength() { return encFrameSize; } -uint8_t ArcsecDatalinkLayer::getStatusField() { - return *(decodedFrame + STATUS_OFFSET); -} - -uint8_t ArcsecDatalinkLayer::getId() { - return *(decodedFrame + ID_OFFSET); -} +uint8_t ArcsecDatalinkLayer::getStatusField() { return *(decodedFrame + STATUS_OFFSET); } +uint8_t ArcsecDatalinkLayer::getId() { return *(decodedFrame + ID_OFFSET); } diff --git a/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.h b/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.h index a65881c7..6b4d3095 100644 --- a/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.h +++ b/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.h @@ -5,96 +5,94 @@ #include "fsfw/returnvalues/HasReturnvaluesIF.h" extern "C" { - #include "common/misc.h" +#include "common/misc.h" } /** * @brief Helper class to handle the datalinklayer of replies from the star tracker of arcsec. */ -class ArcsecDatalinkLayer: public HasReturnvaluesIF { -public: +class ArcsecDatalinkLayer : public HasReturnvaluesIF { + public: + static const uint8_t INTERFACE_ID = CLASS_ID::STR_HANDLER; - static const uint8_t INTERFACE_ID = CLASS_ID::STR_HANDLER; + //! [EXPORT] : [COMMENT] More data required to complete frame + static const ReturnValue_t DEC_IN_PROGRESS = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] Data too short to represent a valid frame + static const ReturnValue_t REPLY_TOO_SHORT = MAKE_RETURN_CODE(0xA1); + //! [EXPORT] : [COMMENT] Detected CRC failure in received frame + static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA2); - //! [EXPORT] : [COMMENT] More data required to complete frame - static const ReturnValue_t DEC_IN_PROGRESS = MAKE_RETURN_CODE(0xA0); - //! [EXPORT] : [COMMENT] Data too short to represent a valid frame - static const ReturnValue_t REPLY_TOO_SHORT = MAKE_RETURN_CODE(0xA1); - //! [EXPORT] : [COMMENT] Detected CRC failure in received frame - static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA2); + static const uint8_t STATUS_OK = 0; - static const uint8_t STATUS_OK = 0; + ArcsecDatalinkLayer(); + virtual ~ArcsecDatalinkLayer(); - ArcsecDatalinkLayer(); - virtual ~ArcsecDatalinkLayer(); + /** + * @brief Applies decoding to data referenced by rawData pointer + * + * @param rawData Pointer to raw data received from star tracker + * @param rawDataSize Size of raw data stream + * @param remainingBytes Number of bytes left + */ + ReturnValue_t decodeFrame(const uint8_t* rawData, size_t rawDataSize, size_t* bytesLeft); - /** - * @brief Applies decoding to data referenced by rawData pointer - * - * @param rawData Pointer to raw data received from star tracker - * @param rawDataSize Size of raw data stream - * @param remainingBytes Number of bytes left - */ - ReturnValue_t decodeFrame(const uint8_t* rawData, size_t rawDataSize, size_t* bytesLeft); + /** + * @brief SLIP encodes data pointed to by data pointer. + * + * @param data Pointer to data to encode + * @param length Length of buffer to encode + */ + void encodeFrame(const uint8_t* data, uint32_t length); - /** - * @brief SLIP encodes data pointed to by data pointer. - * - * @param data Pointer to data to encode - * @param length Length of buffer to encode - */ - void encodeFrame(const uint8_t* data, uint32_t length); + /** + * @brief Returns the frame type field of a decoded frame. + */ + uint8_t getReplyFrameType(); - /** - * @brief Returns the frame type field of a decoded frame. - */ - uint8_t getReplyFrameType(); + /** + * @brief Returns pointer to reply packet (first entry normally action ID, telemetry ID etc.) + */ + const uint8_t* getReply(); - /** - * @brief Returns pointer to reply packet (first entry normally action ID, telemetry ID etc.) - */ - const uint8_t* getReply(); + /** + * @brief Returns size of encoded frame + */ + uint32_t getEncodedLength(); - /** - * @brief Returns size of encoded frame - */ - uint32_t getEncodedLength(); + /** + * @brief Returns pointer to encoded frame + */ + uint8_t* getEncodedFrame(); - /** - * @brief Returns pointer to encoded frame - */ - uint8_t* getEncodedFrame(); + /** + * @brief Returns status of reply + */ + uint8_t getStatusField(); - /** - * @brief Returns status of reply - */ - uint8_t getStatusField(); + /** + * @brief Returns ID of reply + */ + uint8_t getId(); - /** - * @brief Returns ID of reply - */ - uint8_t getId(); + private: + static const uint8_t ID_OFFSET = 1; + static const uint8_t STATUS_OFFSET = 2; -private: + // Used by arcsec slip decoding function process received data + uint8_t rxBuffer[StarTracker::MAX_FRAME_SIZE]; + // Decoded frame will be copied to this buffer + uint8_t decodedFrame[StarTracker::MAX_FRAME_SIZE]; + // Buffer where encoded frames will be stored. First byte of encoded frame represents type of + // reply + uint8_t encBuffer[StarTracker::MAX_FRAME_SIZE * 2 + 2]; + // Size of decoded frame + uint32_t decFrameSize = 0; + // Size of encoded frame + uint32_t encFrameSize = 0; - static const uint8_t ID_OFFSET = 1; - static const uint8_t STATUS_OFFSET = 2; + slip_decode_state slipInfo; - // Used by arcsec slip decoding function process received data - uint8_t rxBuffer[StarTracker::MAX_FRAME_SIZE]; - // Decoded frame will be copied to this buffer - uint8_t decodedFrame[StarTracker::MAX_FRAME_SIZE]; - // Buffer where encoded frames will be stored. First byte of encoded frame represents type of - // reply - uint8_t encBuffer[StarTracker::MAX_FRAME_SIZE * 2 + 2]; - // Size of decoded frame - uint32_t decFrameSize = 0; - // Size of encoded frame - uint32_t encFrameSize = 0; - - slip_decode_state slipInfo; - - void slipInit(); + void slipInit(); }; #endif /* BSP_Q7S_DEVICES_ARCSECDATALINKLAYER_H_ */ diff --git a/bsp_q7s/devices/startracker/ArcsecJsonKeys.h b/bsp_q7s/devices/startracker/ArcsecJsonKeys.h index 2c598b43..67a80b88 100644 --- a/bsp_q7s/devices/startracker/ArcsecJsonKeys.h +++ b/bsp_q7s/devices/startracker/ArcsecJsonKeys.h @@ -5,122 +5,122 @@ * @brief Keys used in JSON file of ARCSEC. */ namespace arcseckeys { - static const char PROPERTIES[] = "properties"; - static const char NAME[] = "name"; - static const char VALUE[] = "value"; +static const char PROPERTIES[] = "properties"; +static const char NAME[] = "name"; +static const char VALUE[] = "value"; - static const char LIMITS[] = "limits"; - static const char ACTION[] = "action"; - static const char FPGA18CURRENT[] = "FPGA18Current"; - static const char FPGA25CURRENT[] = "FPGA25Current"; - static const char FPGA10CURRENT[] = "FPGA10Current"; - static const char MCUCURRENT[] = "MCUCurrent"; - static const char CMOS21CURRENT[] = "CMOS21Current"; - static const char CMOSPIXCURRENT[] = "CMOSPixCurrent"; - static const char CMOS33CURRENT[] = "CMOS33Current"; - static const char CMOSVRESCURRENT[] = "CMOSVResCurrent"; - static const char CMOS_TEMPERATURE[] = "CMOSTemperature"; - static const char MCU_TEMPERATURE[] = "MCUTemperature"; +static const char LIMITS[] = "limits"; +static const char ACTION[] = "action"; +static const char FPGA18CURRENT[] = "FPGA18Current"; +static const char FPGA25CURRENT[] = "FPGA25Current"; +static const char FPGA10CURRENT[] = "FPGA10Current"; +static const char MCUCURRENT[] = "MCUCurrent"; +static const char CMOS21CURRENT[] = "CMOS21Current"; +static const char CMOSPIXCURRENT[] = "CMOSPixCurrent"; +static const char CMOS33CURRENT[] = "CMOS33Current"; +static const char CMOSVRESCURRENT[] = "CMOSVResCurrent"; +static const char CMOS_TEMPERATURE[] = "CMOSTemperature"; +static const char MCU_TEMPERATURE[] = "MCUTemperature"; - static const char MOUNTING[] = "mounting"; - static const char qw[] = "qw"; - static const char qx[] = "qx"; - static const char qy[] = "qy"; - static const char qz[] = "qz"; +static const char MOUNTING[] = "mounting"; +static const char qw[] = "qw"; +static const char qx[] = "qx"; +static const char qy[] = "qy"; +static const char qz[] = "qz"; - static const char CAMERA[] = "camera"; - static const char MODE[] = "mode"; - static const char FOCALLENGTH[] = "focallength"; - static const char EXPOSURE[] = "exposure"; - static const char INTERVAL[] = "interval"; - static const char OFFSET[] = "offset"; - static const char PGAGAIN[] = "PGAGain"; - static const char ADCGAIN[] = "ADCGain"; - static const char REG_1[] = "reg1"; - static const char VAL_1[] = "val1"; - static const char REG_2[] = "reg2"; - static const char VAL_2[] = "val2"; - static const char REG_3[] = "reg3"; - static const char VAL_3[] = "val3"; - static const char REG_4[] = "reg4"; - static const char VAL_4[] = "val4"; - static const char REG_5[] = "reg5"; - static const char VAL_5[] = "val5"; - static const char REG_6[] = "reg6"; - static const char VAL_6[] = "val6"; - static const char REG_7[] = "reg7"; - static const char VAL_7[] = "val7"; - static const char REG_8[] = "reg8"; - static const char VAL_8[] = "val8"; - static const char FREQ_1[] = "freq1"; - static const char FREQ_2[] = "freq2"; +static const char CAMERA[] = "camera"; +static const char MODE[] = "mode"; +static const char FOCALLENGTH[] = "focallength"; +static const char EXPOSURE[] = "exposure"; +static const char INTERVAL[] = "interval"; +static const char OFFSET[] = "offset"; +static const char PGAGAIN[] = "PGAGain"; +static const char ADCGAIN[] = "ADCGain"; +static const char REG_1[] = "reg1"; +static const char VAL_1[] = "val1"; +static const char REG_2[] = "reg2"; +static const char VAL_2[] = "val2"; +static const char REG_3[] = "reg3"; +static const char VAL_3[] = "val3"; +static const char REG_4[] = "reg4"; +static const char VAL_4[] = "val4"; +static const char REG_5[] = "reg5"; +static const char VAL_5[] = "val5"; +static const char REG_6[] = "reg6"; +static const char VAL_6[] = "val6"; +static const char REG_7[] = "reg7"; +static const char VAL_7[] = "val7"; +static const char REG_8[] = "reg8"; +static const char VAL_8[] = "val8"; +static const char FREQ_1[] = "freq1"; +static const char FREQ_2[] = "freq2"; - static const char BLOB[] = "blob"; - static const char MIN_VALUE[] = "minValue"; - static const char MIN_DISTANCE[] = "minDistance"; - static const char NEIGHBOUR_DISTANCE[] = "neighbourDistance"; - static const char NEIGHBOUR_BRIGHT_PIXELS[] = "neighbourBrightPixels"; - static const char MIN_TOTAL_VALUE[] = "minTotalValue"; - static const char MAX_TOTAL_VALUE[] = "maxTotalValue"; - static const char MIN_BRIGHT_NEIGHBOURS[] = "minBrightNeighbours"; - static const char MAX_BRIGHT_NEIGHBOURS[] = "maxBrightNeighbours"; - static const char MAX_PIXEL_TO_CONSIDER[] = "maxPixelsToConsider"; - static const char SIGNAL_THRESHOLD[] = "signalThreshold"; - static const char DARK_THRESHOLD[] = "darkThreshold"; - static const char ENABLE_HISTOGRAM[] = "enableHistogram"; - static const char ENABLE_CONTRAST[] = "enableContrast"; - static const char BIN_MODE[] = "binMode"; +static const char BLOB[] = "blob"; +static const char MIN_VALUE[] = "minValue"; +static const char MIN_DISTANCE[] = "minDistance"; +static const char NEIGHBOUR_DISTANCE[] = "neighbourDistance"; +static const char NEIGHBOUR_BRIGHT_PIXELS[] = "neighbourBrightPixels"; +static const char MIN_TOTAL_VALUE[] = "minTotalValue"; +static const char MAX_TOTAL_VALUE[] = "maxTotalValue"; +static const char MIN_BRIGHT_NEIGHBOURS[] = "minBrightNeighbours"; +static const char MAX_BRIGHT_NEIGHBOURS[] = "maxBrightNeighbours"; +static const char MAX_PIXEL_TO_CONSIDER[] = "maxPixelsToConsider"; +static const char SIGNAL_THRESHOLD[] = "signalThreshold"; +static const char DARK_THRESHOLD[] = "darkThreshold"; +static const char ENABLE_HISTOGRAM[] = "enableHistogram"; +static const char ENABLE_CONTRAST[] = "enableContrast"; +static const char BIN_MODE[] = "binMode"; - static const char CENTROIDING[] = "centroiding"; - static const char ENABLE_FILTER[] = "enableFilter"; - static const char MAX_QUALITY[] = "maxquality"; - static const char MIN_QUALITY[] = "minquality"; - static const char MAX_INTENSITY[] = "maxintensity"; - static const char MIN_INTENSITY[] = "minintensity"; - static const char MAX_MAGNITUDE[] = "maxmagnitude"; - static const char GAUSSIAN_CMAX[] = "gaussianCmax"; - static const char GAUSSIAN_CMIN[] = "gaussianCmin"; - static const char TRANSMATRIX_00[] = "transmatrix00"; - static const char TRANSMATRIX_01[] = "transmatrix01"; - static const char TRANSMATRIX_10[] = "transmatrix10"; - static const char TRANSMATRIX_11[] = "transmatrix11"; +static const char CENTROIDING[] = "centroiding"; +static const char ENABLE_FILTER[] = "enableFilter"; +static const char MAX_QUALITY[] = "maxquality"; +static const char MIN_QUALITY[] = "minquality"; +static const char MAX_INTENSITY[] = "maxintensity"; +static const char MIN_INTENSITY[] = "minintensity"; +static const char MAX_MAGNITUDE[] = "maxmagnitude"; +static const char GAUSSIAN_CMAX[] = "gaussianCmax"; +static const char GAUSSIAN_CMIN[] = "gaussianCmin"; +static const char TRANSMATRIX_00[] = "transmatrix00"; +static const char TRANSMATRIX_01[] = "transmatrix01"; +static const char TRANSMATRIX_10[] = "transmatrix10"; +static const char TRANSMATRIX_11[] = "transmatrix11"; - static const char LISA[] = "lisa"; - static const char PREFILTER_DIST_THRESHOLD[] = "prefilterDistThreshold"; - static const char PREFILTER_ANGLE_THRESHOLD[] = "prefilterAngleThreshold"; - static const char FOV_WIDTH[] = "fov_width"; - static const char FOV_HEIGHT[] = "fov_height"; - static const char FLOAT_STAR_LIMIT[] = "float_star_limit"; - static const char CLOSE_STAR_LIMIT[] = "close_star_limit"; - static const char RATING_WEIGHT_CLOSE_STAR_COUNT[] = "rating_weight_close_star_count"; - static const char RATING_WEIGHT_FRACTION_CLOSE[] = "rating_weight_fraction_close"; - static const char RATING_WEIGHT_MEAN_SUM[] = "rating_weight_mean_sum"; - static const char RATING_WEIGHT_DB_STAR_COUNT[] = "rating_weight_db_star_count"; - static const char MAX_COMBINATIONS[] = "max_combinations"; - static const char NR_STARS_STOP[] = "nr_stars_stop"; - static const char FRACTION_CLOSE_STOP[] = "fraction_close_stop"; +static const char LISA[] = "lisa"; +static const char PREFILTER_DIST_THRESHOLD[] = "prefilterDistThreshold"; +static const char PREFILTER_ANGLE_THRESHOLD[] = "prefilterAngleThreshold"; +static const char FOV_WIDTH[] = "fov_width"; +static const char FOV_HEIGHT[] = "fov_height"; +static const char FLOAT_STAR_LIMIT[] = "float_star_limit"; +static const char CLOSE_STAR_LIMIT[] = "close_star_limit"; +static const char RATING_WEIGHT_CLOSE_STAR_COUNT[] = "rating_weight_close_star_count"; +static const char RATING_WEIGHT_FRACTION_CLOSE[] = "rating_weight_fraction_close"; +static const char RATING_WEIGHT_MEAN_SUM[] = "rating_weight_mean_sum"; +static const char RATING_WEIGHT_DB_STAR_COUNT[] = "rating_weight_db_star_count"; +static const char MAX_COMBINATIONS[] = "max_combinations"; +static const char NR_STARS_STOP[] = "nr_stars_stop"; +static const char FRACTION_CLOSE_STOP[] = "fraction_close_stop"; - static const char MATCHING[] = "matching"; - static const char SQUARED_DISTANCE_LIMIT[] = "squaredDistanceLimit"; - static const char SQUARED_SHIFT_LIMIT[] = "squaredShiftLimit"; +static const char MATCHING[] = "matching"; +static const char SQUARED_DISTANCE_LIMIT[] = "squaredDistanceLimit"; +static const char SQUARED_SHIFT_LIMIT[] = "squaredShiftLimit"; - static const char VALIDATION[] = "validation"; - static const char STABLE_COUNT[] = "stable_count"; - static const char MAX_DIFFERENCE[] = "max_difference"; - static const char MIN_TRACKER_CONFIDENCE[] = "min_trackerConfidence"; - static const char MIN_MATCHED_STARS[] = "min_matchedStars"; +static const char VALIDATION[] = "validation"; +static const char STABLE_COUNT[] = "stable_count"; +static const char MAX_DIFFERENCE[] = "max_difference"; +static const char MIN_TRACKER_CONFIDENCE[] = "min_trackerConfidence"; +static const char MIN_MATCHED_STARS[] = "min_matchedStars"; - static const char TRACKING[] = "tracking"; - static const char THIN_LIMIT[] = "thinLimit"; - static const char OUTLIER_THRESHOLD[] = "outlierThreshold"; - static const char OUTLIER_THRESHOLD_QUEST[] = "outlierThresholdQUEST"; - static const char TRACKER_CHOICE[] = "trackerChoice"; +static const char TRACKING[] = "tracking"; +static const char THIN_LIMIT[] = "thinLimit"; +static const char OUTLIER_THRESHOLD[] = "outlierThreshold"; +static const char OUTLIER_THRESHOLD_QUEST[] = "outlierThresholdQUEST"; +static const char TRACKER_CHOICE[] = "trackerChoice"; - static const char ALGO[] = "algo"; - static const char L2T_MIN_CONFIDENCE[] = "l2t_minConfidence"; - static const char L2T_MIN_MATCHED[] = "l2t_minConfidence"; - static const char T2L_MIN_CONFIDENCE[] = "t2l_minConfidence"; - static const char T2L_MIN_MATCHED[] = "t2l_minMatched"; -} +static const char ALGO[] = "algo"; +static const char L2T_MIN_CONFIDENCE[] = "l2t_minConfidence"; +static const char L2T_MIN_MATCHED[] = "l2t_minConfidence"; +static const char T2L_MIN_CONFIDENCE[] = "t2l_minConfidence"; +static const char T2L_MIN_MATCHED[] = "t2l_minMatched"; +} // namespace arcseckeys #endif /* BSP_Q7S_DEVICES_DEVICEDEFINITIONS_ARCSECJSONKEYS_H_ */ diff --git a/bsp_q7s/devices/startracker/ArcsecJsonParamBase.cpp b/bsp_q7s/devices/startracker/ArcsecJsonParamBase.cpp index 339c3fe7..3ecd1d91 100644 --- a/bsp_q7s/devices/startracker/ArcsecJsonParamBase.cpp +++ b/bsp_q7s/devices/startracker/ArcsecJsonParamBase.cpp @@ -1,94 +1,95 @@ #include "ArcsecJsonParamBase.h" + #include "ArcsecJsonKeys.h" ArcsecJsonParamBase::ArcsecJsonParamBase(std::string setName) : setName(setName) {} ReturnValue_t ArcsecJsonParamBase::create(std::string fullname, uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - result = init(fullname); - if (result != RETURN_OK) { - return result; - } - result = createCommand(buffer); + ReturnValue_t result = RETURN_OK; + result = init(fullname); + if (result != RETURN_OK) { return result; + } + result = createCommand(buffer); + return result; } ReturnValue_t ArcsecJsonParamBase::getParam(const std::string name, std::string& value) { - for (json::iterator it = set.begin(); it != set.end(); ++it) { - if ((*it)[arcseckeys::NAME] == name) { - value = (*it)[arcseckeys::VALUE]; - convertEmpty(value); - return RETURN_OK; - } + for (json::iterator it = set.begin(); it != set.end(); ++it) { + if ((*it)[arcseckeys::NAME] == name) { + value = (*it)[arcseckeys::VALUE]; + convertEmpty(value); + return RETURN_OK; } - return PARAM_NOT_EXISTS; + } + return PARAM_NOT_EXISTS; } void ArcsecJsonParamBase::convertEmpty(std::string& value) { - if (value == "") { - value = "0"; - } + if (value == "") { + value = "0"; + } } void ArcsecJsonParamBase::addfloat(const std::string value, uint8_t* buffer) { - float param = std::stof(value); - std::memcpy(buffer, ¶m, sizeof(param)); + float param = std::stof(value); + std::memcpy(buffer, ¶m, sizeof(param)); } void ArcsecJsonParamBase::adduint8(const std::string value, uint8_t* buffer) { - uint8_t param = std::stoi(value); - std::memcpy(buffer, ¶m, sizeof(param)); + uint8_t param = std::stoi(value); + std::memcpy(buffer, ¶m, sizeof(param)); } void ArcsecJsonParamBase::addint16(const std::string value, uint8_t* buffer) { - int16_t param = std::stoi(value); - std::memcpy(buffer, ¶m, sizeof(param)); + int16_t param = std::stoi(value); + std::memcpy(buffer, ¶m, sizeof(param)); } void ArcsecJsonParamBase::adduint16(const std::string value, uint8_t* buffer) { - uint16_t param = std::stoi(value); - std::memcpy(buffer, ¶m, sizeof(param)); + uint16_t param = std::stoi(value); + std::memcpy(buffer, ¶m, sizeof(param)); } void ArcsecJsonParamBase::adduint32(const std::string value, uint8_t* buffer) { - uint32_t param = std::stoi(value); - std::memcpy(buffer, ¶m, sizeof(param)); + uint32_t param = std::stoi(value); + std::memcpy(buffer, ¶m, sizeof(param)); } void ArcsecJsonParamBase::addSetParamHeader(uint8_t* buffer, uint8_t setId) { - *buffer = static_cast(TMTC_SETPARAMREQ); - *(buffer + 1) = setId; + *buffer = static_cast(TMTC_SETPARAMREQ); + *(buffer + 1) = setId; } ReturnValue_t ArcsecJsonParamBase::init(const std::string filename) { - ReturnValue_t result = RETURN_OK; - if (not std::filesystem::exists(filename)) { - sif::warning << "ArcsecJsonParamBase::init: JSON file " << filename << " does not exist" - << std::endl; - return JSON_FILE_NOT_EXISTS; - } - createJsonObject(filename); - result = initSet(); - if (result != RETURN_OK) { - return result; - } - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + if (not std::filesystem::exists(filename)) { + sif::warning << "ArcsecJsonParamBase::init: JSON file " << filename << " does not exist" + << std::endl; + return JSON_FILE_NOT_EXISTS; + } + createJsonObject(filename); + result = initSet(); + if (result != RETURN_OK) { + return result; + } + return RETURN_OK; } void ArcsecJsonParamBase::createJsonObject(const std::string fullname) { - json j; - std::ifstream file(fullname); - file >> j; - file.close(); - properties = j[arcseckeys::PROPERTIES]; + json j; + std::ifstream file(fullname); + file >> j; + file.close(); + properties = j[arcseckeys::PROPERTIES]; } ReturnValue_t ArcsecJsonParamBase::initSet() { - for (json::iterator it = properties.begin(); it != properties.end(); ++it) { - if ((*it)["name"] == setName) { - set = (*it)["fields"]; - return RETURN_OK; - } + for (json::iterator it = properties.begin(); it != properties.end(); ++it) { + if ((*it)["name"] == setName) { + set = (*it)["fields"]; + return RETURN_OK; } - return SET_NOT_EXISTS; + } + return SET_NOT_EXISTS; } diff --git a/bsp_q7s/devices/startracker/ArcsecJsonParamBase.h b/bsp_q7s/devices/startracker/ArcsecJsonParamBase.h index 320eff53..a3e7528f 100644 --- a/bsp_q7s/devices/startracker/ArcsecJsonParamBase.h +++ b/bsp_q7s/devices/startracker/ArcsecJsonParamBase.h @@ -1,16 +1,16 @@ #ifndef BSP_Q7S_DEVICES_STARTRACKER_ARCSECJSONPARAMBASE_H_ #define BSP_Q7S_DEVICES_STARTRACKER_ARCSECJSONPARAMBASE_H_ -#include #include +#include #include -#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "StarTrackerDefinitions.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" extern "C" { - #include "thirdparty/arcsec_star_tracker/common/generated/tmtcstructs.h" - #include "thirdparty/arcsec_star_tracker/common/genericstructs.h" +#include "thirdparty/arcsec_star_tracker/common/generated/tmtcstructs.h" +#include "thirdparty/arcsec_star_tracker/common/genericstructs.h" } using json = nlohmann::json; @@ -23,127 +23,124 @@ using json = nlohmann::json; * @author J. Meier */ class ArcsecJsonParamBase : public HasReturnvaluesIF { -public: + public: + static const uint8_t INTERFACE_ID = CLASS_ID::ARCSEC_JSON_BASE; + //! [EXPORT] : [COMMENT] Specified json file does not exist + static const ReturnValue_t JSON_FILE_NOT_EXISTS = MAKE_RETURN_CODE(1); + //! [EXPORT] : [COMMENT] Requested set does not exist in json file + static const ReturnValue_t SET_NOT_EXISTS = MAKE_RETURN_CODE(2); + //! [EXPORT] : [COMMENT] Requested parameter does not exist in json file + static const ReturnValue_t PARAM_NOT_EXISTS = MAKE_RETURN_CODE(3); - static const uint8_t INTERFACE_ID = CLASS_ID::ARCSEC_JSON_BASE; - //! [EXPORT] : [COMMENT] Specified json file does not exist - static const ReturnValue_t JSON_FILE_NOT_EXISTS = MAKE_RETURN_CODE(1); - //! [EXPORT] : [COMMENT] Requested set does not exist in json file - static const ReturnValue_t SET_NOT_EXISTS = MAKE_RETURN_CODE(2); - //! [EXPORT] : [COMMENT] Requested parameter does not exist in json file - static const ReturnValue_t PARAM_NOT_EXISTS = MAKE_RETURN_CODE(3); + /** + * @brief Constructor + * + * @param fullname Name with absolute path of json file containing the parameters to set. + */ + ArcsecJsonParamBase(std::string setName); - /** - * @brief Constructor - * - * @param fullname Name with absolute path of json file containing the parameters to set. - */ - ArcsecJsonParamBase(std::string setName); + /** + * @brief Fills a buffer with a parameter set + * + * @param fullname The name including the absolute path of the json file containing the + * parameter set. + * @param buffer Pointer to the buffer the command will be written to + */ + ReturnValue_t create(std::string fullname, uint8_t* buffer); - /** - * @brief Fills a buffer with a parameter set - * - * @param fullname The name including the absolute path of the json file containing the - * parameter set. - * @param buffer Pointer to the buffer the command will be written to - */ - ReturnValue_t create(std::string fullname, uint8_t* buffer); + /** + * @brief Returns the size of the parameter command. + */ + virtual size_t getSize() = 0; - /** - * @brief Returns the size of the parameter command. - */ - virtual size_t getSize() = 0; + protected: + /** + * @brief Reads the value of a parameter from a json set + * + * @param name The name of the parameter + * @param value The string representation of the read value + * + * @return RETURN_OK if successful, otherwise PARAM_NOT_EXISTS + */ + ReturnValue_t getParam(const std::string name, std::string& value); -protected: + /** + * @brief Converts empty string which is equal to define a value as zero. + */ + void convertEmpty(std::string& value); - /** - * @brief Reads the value of a parameter from a json set - * - * @param name The name of the parameter - * @param value The string representation of the read value - * - * @return RETURN_OK if successful, otherwise PARAM_NOT_EXISTS - */ - ReturnValue_t getParam(const std::string name, std::string& value); + /** + * @brief This function adds a float represented as string to a buffer + * + * @param value The float in string representation to add + * @param buffer Pointer to the buffer the float will be written to + */ + void addfloat(const std::string value, uint8_t* buffer); - /** - * @brief Converts empty string which is equal to define a value as zero. - */ - void convertEmpty(std::string& value); + /** + * @brief This function adds a uint8_t represented as string to a buffer + * + * @param value The uint8_t in string representation to add + * @param buffer Pointer to the buffer the uint8_t will be written to + */ + void adduint8(const std::string value, uint8_t* buffer); - /** - * @brief This function adds a float represented as string to a buffer - * - * @param value The float in string representation to add - * @param buffer Pointer to the buffer the float will be written to - */ - void addfloat(const std::string value, uint8_t* buffer); + /** + * @brief This function adds a int16_t represented as string to a buffer + * + * @param value The int16_t in string representation to add + * @param buffer Pointer to the buffer the int16_t will be written to + */ + void addint16(const std::string value, uint8_t* buffer); - /** - * @brief This function adds a uint8_t represented as string to a buffer - * - * @param value The uint8_t in string representation to add - * @param buffer Pointer to the buffer the uint8_t will be written to - */ - void adduint8(const std::string value, uint8_t* buffer); + /** + * @brief This function adds a uint16_t represented as string to a buffer + * + * @param value The uint16_t in string representation to add + * @param buffer Pointer to the buffer the uint16_t will be written to + */ + void adduint16(const std::string value, uint8_t* buffer); - /** - * @brief This function adds a int16_t represented as string to a buffer - * - * @param value The int16_t in string representation to add - * @param buffer Pointer to the buffer the int16_t will be written to - */ - void addint16(const std::string value, uint8_t* buffer); + /** + * @brief This function adds a uint32_t represented as string to a buffer + * + * @param value The uint32_t in string representation to add + * @param buffer Pointer to the buffer the uint32_t will be written to + */ + void adduint32(const std::string value, uint8_t* buffer); - /** - * @brief This function adds a uint16_t represented as string to a buffer - * - * @param value The uint16_t in string representation to add - * @param buffer Pointer to the buffer the uint16_t will be written to - */ - void adduint16(const std::string value, uint8_t* buffer); + void addSetParamHeader(uint8_t* buffer, uint8_t setId); - /** - * @brief This function adds a uint32_t represented as string to a buffer - * - * @param value The uint32_t in string representation to add - * @param buffer Pointer to the buffer the uint32_t will be written to - */ - void adduint32(const std::string value, uint8_t* buffer); + private: + json properties; + json set; + std::string setName; - void addSetParamHeader(uint8_t* buffer, uint8_t setId); + /** + * @brief This function must be implemented by the derived class to define creation of a + * parameter command. + */ + virtual ReturnValue_t createCommand(uint8_t* buffer) = 0; -private: + /** + * @brief Initializes the properties json object and the set json object + * + * @param fullname Name including absolute path to json file + * @param setName The name of the set to work on + * + * @param return JSON_FILE_NOT_EXISTS if specified file does not exist, otherwise + * RETURN_OK + */ + ReturnValue_t init(const std::string filename); - json properties; - json set; - std::string setName; + void createJsonObject(const std::string fullname); - /** - * @brief This function must be implemented by the derived class to define creation of a - * parameter command. - */ - virtual ReturnValue_t createCommand(uint8_t* buffer) = 0; - - /** - * @brief Initializes the properties json object and the set json object - * - * @param fullname Name including absolute path to json file - * @param setName The name of the set to work on - * - * @param return JSON_FILE_NOT_EXISTS if specified file does not exist, otherwise - * RETURN_OK - */ - ReturnValue_t init(const std::string filename); - - void createJsonObject(const std::string fullname); - - /** - * @brief Extracts the json set object form the json file - * - * @param setName The name of the set to create the json object from - */ - ReturnValue_t initSet(); + /** + * @brief Extracts the json set object form the json file + * + * @param setName The name of the set to create the json object from + */ + ReturnValue_t initSet(); }; #endif /* BSP_Q7S_DEVICES_STARTRACKER_ARCSECJSONPARAMBASE_H_ */ diff --git a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h index f1f7b7d0..c8a45683 100644 --- a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h +++ b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h @@ -1,12 +1,13 @@ #ifndef MISSION_STARTRACKER_DEFINITIONS_H_ #define MISSION_STARTRACKER_DEFINITIONS_H_ -#include +#include #include +#include #include #include + #include "objects/systemObjectList.h" -#include namespace StarTracker { @@ -15,188 +16,188 @@ static const uint8_t ADDRESS = 33; static const uint8_t STATUS_OK = 0; -enum PoolIds: lp_id_t { - TICKS_TIME_SET, - TIME_TIME_SET, - RUN_TIME, - UNIX_TIME, - TICKS_VERSION_SET, - TIME_VERSION_SET, - PROGRAM, - MAJOR, - MINOR, - TICKS_INTERFACE_SET, - TIME_INTERFACE_SET, - FRAME_COUNT, - CHECKSUM_ERROR_COUNT, - SET_PARAM_COUNT, - SET_PARAM_REPLY_COUNT, - PARAM_REQUEST_COUNT, - PARAM_REPLY_COUNT, - REQ_TM_COUNT, - TM_REPLY_COUNT, - ACTION_REQ_COUNT, - ACTION_REPLY_COUNT, - TICKS_POWER_SET, - TIME_POWER_SET, - MCU_CURRENT, - MCU_VOLTAGE, - FPGA_CORE_CURRENT, - FPGA_CORE_VOLTAGE, - FPGA_18_CURRENT, - FPGA_18_VOLTAGE, - FPGA_25_CURRENT, - FPGA_25_VOLTAGE, - CMV_21_CURRENT, - CMV_21_VOLTAGE, - CMV_PIX_CURRENT, - CMV_PIX_VOLTAGE, - CMV_33_CURRENT, - CMV_33_VOLTAGE, - CMV_RES_CURRENT, - CMV_RES_VOLTAGE, - TICKS_TEMPERATURE_SET, - TIME_TEMPERATURE_SET, - MCU_TEMPERATURE, - CMOS_TEMPERATURE, - TICKS_SOLUTION_SET, - TIME_SOLUTION_SET, - CALI_QW, - CALI_QX, - CALI_QY, - CALI_QZ, - TRACK_CONFIDENCE, - TRACK_QW, - TRACK_QX, - TRACK_QY, - TRACK_QZ, - TRACK_REMOVED, - STARS_CENTROIDED, - STARS_MATCHED_DATABASE, - LISA_QW, - LISA_QX, - LISA_QY, - LISA_QZ, - LISA_PERC_CLOSE, - LISA_NR_CLOSE, - TRUST_WORTHY, - STABLE_COUNT, - SOLUTION_STRATEGY, - TICKS_HISTOGRAM_SET, - TIME_HISTOGRAM_SET, - HISTOGRAM_BINA0, - HISTOGRAM_BINA1, - HISTOGRAM_BINA2, - HISTOGRAM_BINA3, - HISTOGRAM_BINA4, - HISTOGRAM_BINA5, - HISTOGRAM_BINA6, - HISTOGRAM_BINA7, - HISTOGRAM_BINA8, - HISTOGRAM_BINB0, - HISTOGRAM_BINB1, - HISTOGRAM_BINB2, - HISTOGRAM_BINB3, - HISTOGRAM_BINB4, - HISTOGRAM_BINB5, - HISTOGRAM_BINB6, - HISTOGRAM_BINB7, - HISTOGRAM_BINB8, - HISTOGRAM_BINC0, - HISTOGRAM_BINC1, - HISTOGRAM_BINC2, - HISTOGRAM_BINC3, - HISTOGRAM_BINC4, - HISTOGRAM_BINC5, - HISTOGRAM_BINC6, - HISTOGRAM_BINC7, - HISTOGRAM_BINC8, - HISTOGRAM_BIND0, - HISTOGRAM_BIND1, - HISTOGRAM_BIND2, - HISTOGRAM_BIND3, - HISTOGRAM_BIND4, - HISTOGRAM_BIND5, - HISTOGRAM_BIND6, - HISTOGRAM_BIND7, - HISTOGRAM_BIND8, - TICKS_CONTRAST_SET, - TIME_CONTRAST_SET, - CONTRAST_BINA0, - CONTRAST_BINA1, - CONTRAST_BINA2, - CONTRAST_BINA3, - CONTRAST_BINA4, - CONTRAST_BINA5, - CONTRAST_BINA6, - CONTRAST_BINA7, - CONTRAST_BINA8, - CONTRAST_BINB0, - CONTRAST_BINB1, - CONTRAST_BINB2, - CONTRAST_BINB3, - CONTRAST_BINB4, - CONTRAST_BINB5, - CONTRAST_BINB6, - CONTRAST_BINB7, - CONTRAST_BINB8, - CONTRAST_BINC0, - CONTRAST_BINC1, - CONTRAST_BINC2, - CONTRAST_BINC3, - CONTRAST_BINC4, - CONTRAST_BINC5, - CONTRAST_BINC6, - CONTRAST_BINC7, - CONTRAST_BINC8, - CONTRAST_BIND0, - CONTRAST_BIND1, - CONTRAST_BIND2, - CONTRAST_BIND3, - CONTRAST_BIND4, - CONTRAST_BIND5, - CONTRAST_BIND6, - CONTRAST_BIND7, - CONTRAST_BIND8, - CHKSUM, - DWL_ID, - DWL_PIXX, - DWL_PIXY, - DWL_X_UNCORRECTED, - DWL_Y_UNCORRECTED, - DWL_X_CORRECTED, - DWL_Y_CORRECTED, - DWL_MAGNITUDE, - DWL_CXA, - DWL_CYA, - DWL_QUALITY, - MATCHEDSTR_ID, - MATCHEDSTR_CAMFPX, - MATCHEDSTR_CAMFPY, - MATCHEDSTR_CAMCARTX, - MATCHEDSTR_CAMCARTY, - MATCHEDSTR_CAMCARTZ, - MATCHEDSTR_CAMMAGNITUDE, - MATCHEDSTR_DBFPX, - MATCHEDSTR_DBFPY, - MATCHEDSTR_DBCARTX, - MATCHEDSTR_DBCARTY, - MATCHEDSTR_DBCARTZ, - MATCHEDSTR_DBMAGNITUDE, - MATCHEDSTR_CATALOGID, - DBIMAGE_ID, - DBIMAGE_PIXX, - DBIMAGE_PIXY, - DBIMAGE_X, - DBIMAGE_Y, - DBIMAGE_MAGNITUDE, - BLOBPIX_ID, - BLOBPIX_X, - BLOBPIX_Y, - BLOBPIX_TOT_VAL, - BLOBPIX_IN_USE, - BLOBPIX_BRIGHT_NEIGHBOURS, - BLOBPIX_REGION +enum PoolIds : lp_id_t { + TICKS_TIME_SET, + TIME_TIME_SET, + RUN_TIME, + UNIX_TIME, + TICKS_VERSION_SET, + TIME_VERSION_SET, + PROGRAM, + MAJOR, + MINOR, + TICKS_INTERFACE_SET, + TIME_INTERFACE_SET, + FRAME_COUNT, + CHECKSUM_ERROR_COUNT, + SET_PARAM_COUNT, + SET_PARAM_REPLY_COUNT, + PARAM_REQUEST_COUNT, + PARAM_REPLY_COUNT, + REQ_TM_COUNT, + TM_REPLY_COUNT, + ACTION_REQ_COUNT, + ACTION_REPLY_COUNT, + TICKS_POWER_SET, + TIME_POWER_SET, + MCU_CURRENT, + MCU_VOLTAGE, + FPGA_CORE_CURRENT, + FPGA_CORE_VOLTAGE, + FPGA_18_CURRENT, + FPGA_18_VOLTAGE, + FPGA_25_CURRENT, + FPGA_25_VOLTAGE, + CMV_21_CURRENT, + CMV_21_VOLTAGE, + CMV_PIX_CURRENT, + CMV_PIX_VOLTAGE, + CMV_33_CURRENT, + CMV_33_VOLTAGE, + CMV_RES_CURRENT, + CMV_RES_VOLTAGE, + TICKS_TEMPERATURE_SET, + TIME_TEMPERATURE_SET, + MCU_TEMPERATURE, + CMOS_TEMPERATURE, + TICKS_SOLUTION_SET, + TIME_SOLUTION_SET, + CALI_QW, + CALI_QX, + CALI_QY, + CALI_QZ, + TRACK_CONFIDENCE, + TRACK_QW, + TRACK_QX, + TRACK_QY, + TRACK_QZ, + TRACK_REMOVED, + STARS_CENTROIDED, + STARS_MATCHED_DATABASE, + LISA_QW, + LISA_QX, + LISA_QY, + LISA_QZ, + LISA_PERC_CLOSE, + LISA_NR_CLOSE, + TRUST_WORTHY, + STABLE_COUNT, + SOLUTION_STRATEGY, + TICKS_HISTOGRAM_SET, + TIME_HISTOGRAM_SET, + HISTOGRAM_BINA0, + HISTOGRAM_BINA1, + HISTOGRAM_BINA2, + HISTOGRAM_BINA3, + HISTOGRAM_BINA4, + HISTOGRAM_BINA5, + HISTOGRAM_BINA6, + HISTOGRAM_BINA7, + HISTOGRAM_BINA8, + HISTOGRAM_BINB0, + HISTOGRAM_BINB1, + HISTOGRAM_BINB2, + HISTOGRAM_BINB3, + HISTOGRAM_BINB4, + HISTOGRAM_BINB5, + HISTOGRAM_BINB6, + HISTOGRAM_BINB7, + HISTOGRAM_BINB8, + HISTOGRAM_BINC0, + HISTOGRAM_BINC1, + HISTOGRAM_BINC2, + HISTOGRAM_BINC3, + HISTOGRAM_BINC4, + HISTOGRAM_BINC5, + HISTOGRAM_BINC6, + HISTOGRAM_BINC7, + HISTOGRAM_BINC8, + HISTOGRAM_BIND0, + HISTOGRAM_BIND1, + HISTOGRAM_BIND2, + HISTOGRAM_BIND3, + HISTOGRAM_BIND4, + HISTOGRAM_BIND5, + HISTOGRAM_BIND6, + HISTOGRAM_BIND7, + HISTOGRAM_BIND8, + TICKS_CONTRAST_SET, + TIME_CONTRAST_SET, + CONTRAST_BINA0, + CONTRAST_BINA1, + CONTRAST_BINA2, + CONTRAST_BINA3, + CONTRAST_BINA4, + CONTRAST_BINA5, + CONTRAST_BINA6, + CONTRAST_BINA7, + CONTRAST_BINA8, + CONTRAST_BINB0, + CONTRAST_BINB1, + CONTRAST_BINB2, + CONTRAST_BINB3, + CONTRAST_BINB4, + CONTRAST_BINB5, + CONTRAST_BINB6, + CONTRAST_BINB7, + CONTRAST_BINB8, + CONTRAST_BINC0, + CONTRAST_BINC1, + CONTRAST_BINC2, + CONTRAST_BINC3, + CONTRAST_BINC4, + CONTRAST_BINC5, + CONTRAST_BINC6, + CONTRAST_BINC7, + CONTRAST_BINC8, + CONTRAST_BIND0, + CONTRAST_BIND1, + CONTRAST_BIND2, + CONTRAST_BIND3, + CONTRAST_BIND4, + CONTRAST_BIND5, + CONTRAST_BIND6, + CONTRAST_BIND7, + CONTRAST_BIND8, + CHKSUM, + DWL_ID, + DWL_PIXX, + DWL_PIXY, + DWL_X_UNCORRECTED, + DWL_Y_UNCORRECTED, + DWL_X_CORRECTED, + DWL_Y_CORRECTED, + DWL_MAGNITUDE, + DWL_CXA, + DWL_CYA, + DWL_QUALITY, + MATCHEDSTR_ID, + MATCHEDSTR_CAMFPX, + MATCHEDSTR_CAMFPY, + MATCHEDSTR_CAMCARTX, + MATCHEDSTR_CAMCARTY, + MATCHEDSTR_CAMCARTZ, + MATCHEDSTR_CAMMAGNITUDE, + MATCHEDSTR_DBFPX, + MATCHEDSTR_DBFPY, + MATCHEDSTR_DBCARTX, + MATCHEDSTR_DBCARTY, + MATCHEDSTR_DBCARTZ, + MATCHEDSTR_DBMAGNITUDE, + MATCHEDSTR_CATALOGID, + DBIMAGE_ID, + DBIMAGE_PIXX, + DBIMAGE_PIXY, + DBIMAGE_X, + DBIMAGE_Y, + DBIMAGE_MAGNITUDE, + BLOBPIX_ID, + BLOBPIX_X, + BLOBPIX_Y, + BLOBPIX_TOT_VAL, + BLOBPIX_IN_USE, + BLOBPIX_BRIGHT_NEIGHBOURS, + BLOBPIX_REGION }; static const DeviceCommandId_t PING_REQUEST = 0; @@ -280,931 +281,768 @@ static const uint8_t DOWNLOAD_BLOBPIXEL_SET_ENTRIES = 7; // Action, parameter and telemetry IDs namespace ID { - static const uint8_t PING = 0; - static const uint8_t BOOT = 1; - static const uint8_t VERSION = 2; - static const uint8_t INTERFACE = 3; - static const uint8_t LIMITS = 5; - static const uint8_t MOUNTING = 6; - static const uint8_t CAMERA = 9; - static const uint8_t BLOB = 10; - static const uint8_t CENTROIDING = 11; - static const uint8_t LISA = 12; - static const uint8_t MATCHING = 13; - static const uint8_t TRACKING = 14; - static const uint8_t VALIDATION = 15; - static const uint8_t ALGO = 16; - static const uint8_t REBOOT = 7; - static const uint8_t UPLOAD_IMAGE = 10; - static const uint8_t POWER = 11; - static const uint8_t SET_TIME = 14; - static const uint8_t SUBSCRIBE = 18; - static const uint8_t SOLUTION = 24; - static const uint8_t TEMPERATURE = 25; - static const uint8_t HISTOGRAM = 28; - static const uint8_t CONTRAST = 29; - static const uint8_t TIME = 1; - static const uint8_t WRITE = 2; - static const uint8_t READ = 3; - static const uint8_t CHECKSUM = 4; - static const uint8_t ERASE = 5; - static const uint8_t UNLOCK = 6; - static const uint8_t TAKE_IMAGE = 15; - static const uint8_t ERROR_RESET = 12; - static const uint8_t DOWNLOAD_CENTROID = 16; - static const uint8_t UPLOAD_CENTROID = 17; - static const uint8_t DOWNLOAD_MATCHED_STAR = 18; - static const uint8_t DOWNLOAD_DBIMAGE = 19; - static const uint8_t DOWNLOAD_BLOBPIXEL = 24; - static const uint8_t FPGA_ACTION = 22; -} +static const uint8_t PING = 0; +static const uint8_t BOOT = 1; +static const uint8_t VERSION = 2; +static const uint8_t INTERFACE = 3; +static const uint8_t LIMITS = 5; +static const uint8_t MOUNTING = 6; +static const uint8_t CAMERA = 9; +static const uint8_t BLOB = 10; +static const uint8_t CENTROIDING = 11; +static const uint8_t LISA = 12; +static const uint8_t MATCHING = 13; +static const uint8_t TRACKING = 14; +static const uint8_t VALIDATION = 15; +static const uint8_t ALGO = 16; +static const uint8_t REBOOT = 7; +static const uint8_t UPLOAD_IMAGE = 10; +static const uint8_t POWER = 11; +static const uint8_t SET_TIME = 14; +static const uint8_t SUBSCRIBE = 18; +static const uint8_t SOLUTION = 24; +static const uint8_t TEMPERATURE = 25; +static const uint8_t HISTOGRAM = 28; +static const uint8_t CONTRAST = 29; +static const uint8_t TIME = 1; +static const uint8_t WRITE = 2; +static const uint8_t READ = 3; +static const uint8_t CHECKSUM = 4; +static const uint8_t ERASE = 5; +static const uint8_t UNLOCK = 6; +static const uint8_t TAKE_IMAGE = 15; +static const uint8_t ERROR_RESET = 12; +static const uint8_t DOWNLOAD_CENTROID = 16; +static const uint8_t UPLOAD_CENTROID = 17; +static const uint8_t DOWNLOAD_MATCHED_STAR = 18; +static const uint8_t DOWNLOAD_DBIMAGE = 19; +static const uint8_t DOWNLOAD_BLOBPIXEL = 24; +static const uint8_t FPGA_ACTION = 22; +} // namespace ID namespace Program { - static const uint8_t BOOTLOADER = 1; - static const uint8_t FIRMWARE = 2; -} +static const uint8_t BOOTLOADER = 1; +static const uint8_t FIRMWARE = 2; +} // namespace Program /** * @brief This dataset can be used to store the temperature of a reaction wheel. */ -class TemperatureSet: - public StaticLocalDataSet { -public: +class TemperatureSet : public StaticLocalDataSet { + public: + static const size_t SIZE = 20; - static const size_t SIZE = 20; + TemperatureSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TEMPERATURE_SET_ID) {} - TemperatureSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, TEMPERATURE_SET_ID) { - } + TemperatureSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TEMPERATURE_SET_ID)) {} - TemperatureSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, TEMPERATURE_SET_ID)) { - } + // Ticks is time reference generated by internal counter of the star tracker + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_TEMPERATURE_SET, this); + /** Unix time in microseconds */ + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_TEMPERATURE_SET, this); + lp_var_t mcuTemperature = lp_var_t(sid.objectId, PoolIds::MCU_TEMPERATURE, this); + lp_var_t cmosTemperature = lp_var_t(sid.objectId, PoolIds::CMOS_TEMPERATURE, this); - // Ticks is time reference generated by internal counter of the star tracker - lp_var_t ticks = lp_var_t(sid.objectId, - PoolIds::TICKS_TEMPERATURE_SET, this); - /** Unix time in microseconds */ - lp_var_t time = lp_var_t(sid.objectId, - PoolIds::TIME_TEMPERATURE_SET, this); - lp_var_t mcuTemperature = lp_var_t(sid.objectId, - PoolIds::MCU_TEMPERATURE, this); - lp_var_t cmosTemperature = lp_var_t(sid.objectId, - PoolIds::CMOS_TEMPERATURE, this); - - void printSet() { - sif::info << "TemperatureSet::printSet: Ticks: " - << this->ticks << std::endl; - sif::info << "TemperatureSet::printSet: Time: " - << this->time << " us" << std::endl; - sif::info << "TemperatureSet::printSet: MCU Temperature: " - << this->mcuTemperature << " °C" << std::endl; - sif::info << "TemperatureSet::printSet: CMOS Temperature: " - << this->cmosTemperature << " °C" << std::endl; - } + void printSet() { + sif::info << "TemperatureSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "TemperatureSet::printSet: Time: " << this->time << " us" << std::endl; + sif::info << "TemperatureSet::printSet: MCU Temperature: " << this->mcuTemperature << " °C" + << std::endl; + sif::info << "TemperatureSet::printSet: CMOS Temperature: " << this->cmosTemperature << " °C" + << std::endl; + } }; /** * @brief Package to store version parameters */ -class VersionSet: - public StaticLocalDataSet { -public: +class VersionSet : public StaticLocalDataSet { + public: + static const size_t SIZE = 15; - static const size_t SIZE = 15; + VersionSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, VERSION_SET_ID) {} - VersionSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, VERSION_SET_ID) { - } + VersionSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, VERSION_SET_ID)) {} - VersionSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, VERSION_SET_ID)) { - } + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_VERSION_SET, this); + /** Unix time in microseconds */ + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_VERSION_SET, this); + lp_var_t program = lp_var_t(sid.objectId, PoolIds::PROGRAM, this); + lp_var_t major = lp_var_t(sid.objectId, PoolIds::MAJOR, this); + lp_var_t minor = lp_var_t(sid.objectId, PoolIds::MINOR, this); - lp_var_t ticks = lp_var_t(sid.objectId, - PoolIds::TICKS_VERSION_SET, this); - /** Unix time in microseconds */ - lp_var_t time = lp_var_t(sid.objectId, - PoolIds::TIME_VERSION_SET, this); - lp_var_t program = lp_var_t(sid.objectId, - PoolIds::PROGRAM, this); - lp_var_t major = lp_var_t(sid.objectId, - PoolIds::MAJOR, this); - lp_var_t minor = lp_var_t(sid.objectId, - PoolIds::MINOR, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "VersionSet::printSet: Ticks: " - << this->ticks << std::endl; - sif::info << "VersionSet::printSet: Unix Time: " - << this->time << " us" << std::endl; - sif::info << "VersionSet::printSet: Program: " - << static_cast(this->program.value) << std::endl; - sif::info << "VersionSet::printSet: Major: " - << static_cast(this->major.value) << std::endl; - sif::info << "VersionSet::printSet: Minor: " - << static_cast(this->minor.value) << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "VersionSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "VersionSet::printSet: Unix Time: " << this->time << " us" << std::endl; + sif::info << "VersionSet::printSet: Program: " << static_cast(this->program.value) + << std::endl; + sif::info << "VersionSet::printSet: Major: " << static_cast(this->major.value) + << std::endl; + sif::info << "VersionSet::printSet: Minor: " << static_cast(this->minor.value) + << std::endl; + } }; /** * @brief Dataset to store the interface telemtry data. */ -class InterfaceSet: - public StaticLocalDataSet { -public: +class InterfaceSet : public StaticLocalDataSet { + public: + static const size_t SIZE = 20; - static const size_t SIZE = 20; + InterfaceSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, REQ_INTERFACE) {} - InterfaceSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, REQ_INTERFACE) { - } + InterfaceSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, REQ_INTERFACE)) {} - InterfaceSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, REQ_INTERFACE)) { - } + // Ticks is time reference generated by interanl counter of the star tracker + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_INTERFACE_SET, this); + /** Unix time in microseconds */ + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_INTERFACE_SET, this); + lp_var_t frameCount = lp_var_t(sid.objectId, PoolIds::FRAME_COUNT, this); + lp_var_t checksumerrorCount = + lp_var_t(sid.objectId, PoolIds::CHECKSUM_ERROR_COUNT, this); - // Ticks is time reference generated by interanl counter of the star tracker - lp_var_t ticks = lp_var_t(sid.objectId, - PoolIds::TICKS_INTERFACE_SET, this); - /** Unix time in microseconds */ - lp_var_t time = lp_var_t(sid.objectId, - PoolIds::TIME_INTERFACE_SET, this); - lp_var_t frameCount = lp_var_t(sid.objectId, - PoolIds::FRAME_COUNT, this); - lp_var_t checksumerrorCount = lp_var_t(sid.objectId, - PoolIds::CHECKSUM_ERROR_COUNT, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "InterfaceSet::printSet: Ticks: " - << this->ticks << std::endl; - sif::info << "InterfaceSet::printSet: Time: " - << this->time << " us" << std::endl; - sif::info << "InterfaceSet::printSet: Frame Count: " - << this->frameCount << std::endl; - sif::info << "InterfaceSet::printSet: Checksum Error Count: " - << this->checksumerrorCount << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "InterfaceSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "InterfaceSet::printSet: Time: " << this->time << " us" << std::endl; + sif::info << "InterfaceSet::printSet: Frame Count: " << this->frameCount << std::endl; + sif::info << "InterfaceSet::printSet: Checksum Error Count: " << this->checksumerrorCount + << std::endl; + } }; /** * @brief Dataset to store the data of the power telemetry reply. */ -class PowerSet: - public StaticLocalDataSet { -public: +class PowerSet : public StaticLocalDataSet { + public: + static const size_t SIZE = 76; - static const size_t SIZE = 76; + PowerSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, REQ_INTERFACE) {} - PowerSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, REQ_INTERFACE) { - } + PowerSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, REQ_INTERFACE)) {} - PowerSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, REQ_INTERFACE)) { - } + // Ticks is time reference generated by interanl counter of the star tracker + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_POWER_SET, this); + /** Unix time in microseconds */ + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_POWER_SET, this); + lp_var_t mcuCurrent = lp_var_t(sid.objectId, PoolIds::MCU_CURRENT, this); + lp_var_t mcuVoltage = lp_var_t(sid.objectId, PoolIds::MCU_VOLTAGE, this); + lp_var_t fpgaCoreCurrent = lp_var_t(sid.objectId, PoolIds::FPGA_CORE_CURRENT, this); + lp_var_t fpgaCoreVoltage = lp_var_t(sid.objectId, PoolIds::FPGA_CORE_VOLTAGE, this); + lp_var_t fpga18Current = lp_var_t(sid.objectId, PoolIds::FPGA_18_CURRENT, this); + lp_var_t fpga18Voltage = lp_var_t(sid.objectId, PoolIds::FPGA_18_VOLTAGE, this); + lp_var_t fpga25Current = lp_var_t(sid.objectId, PoolIds::FPGA_25_CURRENT, this); + lp_var_t fpga25Voltage = lp_var_t(sid.objectId, PoolIds::FPGA_25_VOLTAGE, this); + lp_var_t cmv21Current = lp_var_t(sid.objectId, PoolIds::CMV_21_CURRENT, this); + lp_var_t cmv21Voltage = lp_var_t(sid.objectId, PoolIds::CMV_21_VOLTAGE, this); + lp_var_t cmvPixCurrent = lp_var_t(sid.objectId, PoolIds::CMV_PIX_CURRENT, this); + lp_var_t cmvPixVoltage = lp_var_t(sid.objectId, PoolIds::CMV_PIX_VOLTAGE, this); + lp_var_t cmv33Current = lp_var_t(sid.objectId, PoolIds::CMV_33_CURRENT, this); + lp_var_t cmv33Voltage = lp_var_t(sid.objectId, PoolIds::CMV_33_VOLTAGE, this); + lp_var_t cmvResCurrent = lp_var_t(sid.objectId, PoolIds::CMV_RES_CURRENT, this); + lp_var_t cmvResVoltage = lp_var_t(sid.objectId, PoolIds::CMV_RES_VOLTAGE, this); - // Ticks is time reference generated by interanl counter of the star tracker - lp_var_t ticks = lp_var_t(sid.objectId, - PoolIds::TICKS_POWER_SET, this); - /** Unix time in microseconds */ - lp_var_t time = lp_var_t(sid.objectId, - PoolIds::TIME_POWER_SET, this); - lp_var_t mcuCurrent = lp_var_t(sid.objectId, - PoolIds::MCU_CURRENT, this); - lp_var_t mcuVoltage = lp_var_t(sid.objectId, - PoolIds::MCU_VOLTAGE, this); - lp_var_t fpgaCoreCurrent = lp_var_t(sid.objectId, - PoolIds::FPGA_CORE_CURRENT, this); - lp_var_t fpgaCoreVoltage = lp_var_t(sid.objectId, - PoolIds::FPGA_CORE_VOLTAGE, this); - lp_var_t fpga18Current = lp_var_t(sid.objectId, - PoolIds::FPGA_18_CURRENT, this); - lp_var_t fpga18Voltage = lp_var_t(sid.objectId, - PoolIds::FPGA_18_VOLTAGE, this); - lp_var_t fpga25Current = lp_var_t(sid.objectId, - PoolIds::FPGA_25_CURRENT, this); - lp_var_t fpga25Voltage = lp_var_t(sid.objectId, - PoolIds::FPGA_25_VOLTAGE, this); - lp_var_t cmv21Current = lp_var_t(sid.objectId, - PoolIds::CMV_21_CURRENT, this); - lp_var_t cmv21Voltage = lp_var_t(sid.objectId, - PoolIds::CMV_21_VOLTAGE, this); - lp_var_t cmvPixCurrent = lp_var_t(sid.objectId, - PoolIds::CMV_PIX_CURRENT, this); - lp_var_t cmvPixVoltage = lp_var_t(sid.objectId, - PoolIds::CMV_PIX_VOLTAGE, this); - lp_var_t cmv33Current = lp_var_t(sid.objectId, - PoolIds::CMV_33_CURRENT, this); - lp_var_t cmv33Voltage = lp_var_t(sid.objectId, - PoolIds::CMV_33_VOLTAGE, this); - lp_var_t cmvResCurrent = lp_var_t(sid.objectId, - PoolIds::CMV_RES_CURRENT, this); - lp_var_t cmvResVoltage = lp_var_t(sid.objectId, - PoolIds::CMV_RES_VOLTAGE, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "PowerSet::printSet: Ticks: " - << this->ticks << std::endl; - sif::info << "PowerSet::printSet: Time: " - << this->time << " us" << std::endl; - sif::info << "PowerSet::printSet: MCU Current: " - << this->mcuCurrent << " A" << std::endl; - sif::info << "PowerSet::printSet: MCU Voltage: " - << this->mcuVoltage << " V" << std::endl; - sif::info << "PowerSet::printSet: FPGA Core current: " - << this->fpgaCoreCurrent << " A" << std::endl; - sif::info << "PowerSet::printSet: FPGA Core voltage: " - << this->fpgaCoreVoltage << " V" << std::endl; - sif::info << "PowerSet::printSet: FPGA 18 current: " - << this->fpga18Current << " A" << std::endl; - sif::info << "PowerSet::printSet: FPGA 18 voltage: " - << this->fpga18Voltage << " V" << std::endl; - sif::info << "PowerSet::printSet: FPGA 25 current: " - << this->fpga25Current << " A" << std::endl; - sif::info << "PowerSet::printSet: FPGA 25 voltage: " - << this->fpga25Voltage << " V" << std::endl; - sif::info << "PowerSet::printSet: CMV 21 current: " - << this->cmv21Current << " A" << std::endl; - sif::info << "PowerSet::printSet: CMV 21 voltage: " - << this->cmv21Voltage << " V" << std::endl; - sif::info << "PowerSet::printSet: CMV Pix current: " - << this->cmvPixCurrent << " A" << std::endl; - sif::info << "PowerSet::printSet: CMV Pix voltage: " - << this->cmvPixVoltage << " V" << std::endl; - sif::info << "PowerSet::printSet: CMV 33 current: " - << this->cmv33Current << " A" << std::endl; - sif::info << "PowerSet::printSet: CMV 33 voltage: " - << this->cmv33Voltage << " V" << std::endl; - sif::info << "PowerSet::printSet: CMV Res current: " - << this->cmvResCurrent << " A" << std::endl; - sif::info << "PowerSet::printSet: CMV Res voltage: " - << this->cmvResVoltage << " V" << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "PowerSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "PowerSet::printSet: Time: " << this->time << " us" << std::endl; + sif::info << "PowerSet::printSet: MCU Current: " << this->mcuCurrent << " A" << std::endl; + sif::info << "PowerSet::printSet: MCU Voltage: " << this->mcuVoltage << " V" << std::endl; + sif::info << "PowerSet::printSet: FPGA Core current: " << this->fpgaCoreCurrent << " A" + << std::endl; + sif::info << "PowerSet::printSet: FPGA Core voltage: " << this->fpgaCoreVoltage << " V" + << std::endl; + sif::info << "PowerSet::printSet: FPGA 18 current: " << this->fpga18Current << " A" + << std::endl; + sif::info << "PowerSet::printSet: FPGA 18 voltage: " << this->fpga18Voltage << " V" + << std::endl; + sif::info << "PowerSet::printSet: FPGA 25 current: " << this->fpga25Current << " A" + << std::endl; + sif::info << "PowerSet::printSet: FPGA 25 voltage: " << this->fpga25Voltage << " V" + << std::endl; + sif::info << "PowerSet::printSet: CMV 21 current: " << this->cmv21Current << " A" << std::endl; + sif::info << "PowerSet::printSet: CMV 21 voltage: " << this->cmv21Voltage << " V" << std::endl; + sif::info << "PowerSet::printSet: CMV Pix current: " << this->cmvPixCurrent << " A" + << std::endl; + sif::info << "PowerSet::printSet: CMV Pix voltage: " << this->cmvPixVoltage << " V" + << std::endl; + sif::info << "PowerSet::printSet: CMV 33 current: " << this->cmv33Current << " A" << std::endl; + sif::info << "PowerSet::printSet: CMV 33 voltage: " << this->cmv33Voltage << " V" << std::endl; + sif::info << "PowerSet::printSet: CMV Res current: " << this->cmvResCurrent << " A" + << std::endl; + sif::info << "PowerSet::printSet: CMV Res voltage: " << this->cmvResVoltage << " V" + << std::endl; + } }; /** * @brief Data set to store the time telemetry packet. */ -class TimeSet: - public StaticLocalDataSet { -public: +class TimeSet : public StaticLocalDataSet { + public: + static const size_t SIZE = 24; - static const size_t SIZE = 24; + TimeSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TIME_SET_ID) {} - TimeSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, TIME_SET_ID) { - } + TimeSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TIME_SET_ID)) {} - TimeSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, TIME_SET_ID)) { - } - - lp_var_t ticks = lp_var_t(sid.objectId, - PoolIds::TICKS_TIME_SET, this); - /** Unix time in microseconds */ - lp_var_t time = lp_var_t(sid.objectId, - PoolIds::TIME_TIME_SET, this); - // Number of milliseconds since processor start-up - lp_var_t runTime = lp_var_t(sid.objectId, - PoolIds::RUN_TIME, this); - // Unix time in seconds?? --> maybe typo in datasheet. Seems to be microseconds - lp_var_t unixTime = lp_var_t(sid.objectId, - PoolIds::UNIX_TIME, this); - void printSet() { - PoolReadGuard rg(this); - sif::info << "TimeSet::printSet: Ticks: " - << this->ticks << std::endl; - sif::info << "TimeSet::printSet: Time (time stamp): " - << this->time << " us" << std::endl; - sif::info << "TimeSet::printSet: Run Time: " - << this->runTime << " ms" << std::endl; - sif::info << "TimeSet::printSet: Unix Time: " - << this->unixTime << " s" << std::endl; - } + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_TIME_SET, this); + /** Unix time in microseconds */ + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_TIME_SET, this); + // Number of milliseconds since processor start-up + lp_var_t runTime = lp_var_t(sid.objectId, PoolIds::RUN_TIME, this); + // Unix time in seconds?? --> maybe typo in datasheet. Seems to be microseconds + lp_var_t unixTime = lp_var_t(sid.objectId, PoolIds::UNIX_TIME, this); + void printSet() { + PoolReadGuard rg(this); + sif::info << "TimeSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "TimeSet::printSet: Time (time stamp): " << this->time << " us" << std::endl; + sif::info << "TimeSet::printSet: Run Time: " << this->runTime << " ms" << std::endl; + sif::info << "TimeSet::printSet: Unix Time: " << this->unixTime << " s" << std::endl; + } }; /** * @brief The solution dataset is the main dataset of the star tracker and contains the * attitude information. */ -class SolutionSet: - public StaticLocalDataSet { -public: +class SolutionSet : public StaticLocalDataSet { + public: + static const size_t SIZE = 78; - static const size_t SIZE = 78; + SolutionSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, SOLUTION_SET_ID) {} - SolutionSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, SOLUTION_SET_ID) { - } + SolutionSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, SOLUTION_SET_ID)) {} - SolutionSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, SOLUTION_SET_ID)) { - } + // Ticks timestamp + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_SOLUTION_SET, this); + /// Unix time stamp + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_SOLUTION_SET, this); + // Calibrated quaternion (takes into account the mounting quaternion), typically same as + // track q values + lp_var_t caliQw = lp_var_t(sid.objectId, PoolIds::CALI_QW, this); + lp_var_t caliQx = lp_var_t(sid.objectId, PoolIds::CALI_QX, this); + lp_var_t caliQy = lp_var_t(sid.objectId, PoolIds::CALI_QY, this); + lp_var_t caliQz = lp_var_t(sid.objectId, PoolIds::CALI_QZ, this); + // The lower this value the more confidence that the star tracker solution is correct + lp_var_t trackConfidence = lp_var_t(sid.objectId, PoolIds::TRACK_CONFIDENCE, this); + // Estimated attitude of spacecraft + lp_var_t trackQw = lp_var_t(sid.objectId, PoolIds::TRACK_QW, this); + lp_var_t trackQx = lp_var_t(sid.objectId, PoolIds::TRACK_QX, this); + lp_var_t trackQy = lp_var_t(sid.objectId, PoolIds::TRACK_QY, this); + lp_var_t trackQz = lp_var_t(sid.objectId, PoolIds::TRACK_QZ, this); + // Number of stars removed from tracking solution + lp_var_t trackRemoved = lp_var_t(sid.objectId, PoolIds::TRACK_REMOVED, this); + // Number of stars for which a valid centroid was found + lp_var_t starsCentroided = + lp_var_t(sid.objectId, PoolIds::STARS_CENTROIDED, this); + // Number of stars that matched to a database star + lp_var_t starsMatchedDatabase = + lp_var_t(sid.objectId, PoolIds::STARS_MATCHED_DATABASE, this); + // Result of LISA (lost in space algorithm), searches for stars without prior knowledge of + // attitude + lp_var_t lisaQw = lp_var_t(sid.objectId, PoolIds::LISA_QW, this); + lp_var_t lisaQx = lp_var_t(sid.objectId, PoolIds::LISA_QX, this); + lp_var_t lisaQy = lp_var_t(sid.objectId, PoolIds::LISA_QY, this); + lp_var_t lisaQz = lp_var_t(sid.objectId, PoolIds::LISA_QZ, this); + // Percentage of close stars in LISA solution + lp_var_t lisaPercentageClose = + lp_var_t(sid.objectId, PoolIds::LISA_PERC_CLOSE, this); + // Number of close stars in LISA solution + lp_var_t lisaNrClose = lp_var_t(sid.objectId, PoolIds::LISA_NR_CLOSE, this); + // Gives a combined overview of the validation parameters (1 for valid solution, otherwise 0) + lp_var_t isTrustWorthy = lp_var_t(sid.objectId, PoolIds::TRUST_WORTHY, this); + // Number of times the validation criteria was met + lp_var_t stableCount = lp_var_t(sid.objectId, PoolIds::STABLE_COUNT, this); + // Shows the autonomous mode used to obtain the star tracker attitude + lp_var_t solutionStrategy = + lp_var_t(sid.objectId, PoolIds::SOLUTION_STRATEGY, this); - // Ticks timestamp - lp_var_t ticks = lp_var_t(sid.objectId, - PoolIds::TICKS_SOLUTION_SET, this); - /// Unix time stamp - lp_var_t time = lp_var_t(sid.objectId, - PoolIds::TIME_SOLUTION_SET, this); - // Calibrated quaternion (takes into account the mounting quaternion), typically same as - // track q values - lp_var_t caliQw = lp_var_t(sid.objectId, PoolIds::CALI_QW, this); - lp_var_t caliQx = lp_var_t(sid.objectId, PoolIds::CALI_QX, this); - lp_var_t caliQy = lp_var_t(sid.objectId, PoolIds::CALI_QY, this); - lp_var_t caliQz = lp_var_t(sid.objectId, PoolIds::CALI_QZ, this); - // The lower this value the more confidence that the star tracker solution is correct - lp_var_t trackConfidence = lp_var_t(sid.objectId, PoolIds::TRACK_CONFIDENCE, - this); - // Estimated attitude of spacecraft - lp_var_t trackQw = lp_var_t(sid.objectId, PoolIds::TRACK_QW, this); - lp_var_t trackQx = lp_var_t(sid.objectId, PoolIds::TRACK_QX, this); - lp_var_t trackQy = lp_var_t(sid.objectId, PoolIds::TRACK_QY, this); - lp_var_t trackQz = lp_var_t(sid.objectId, PoolIds::TRACK_QZ, this); - // Number of stars removed from tracking solution - lp_var_t trackRemoved = lp_var_t(sid.objectId, PoolIds::TRACK_REMOVED, this); - // Number of stars for which a valid centroid was found - lp_var_t starsCentroided = lp_var_t(sid.objectId, PoolIds::STARS_CENTROIDED, - this); - // Number of stars that matched to a database star - lp_var_t starsMatchedDatabase = lp_var_t(sid.objectId, - PoolIds::STARS_MATCHED_DATABASE, this); - // Result of LISA (lost in space algorithm), searches for stars without prior knowledge of - // attitude - lp_var_t lisaQw = lp_var_t(sid.objectId, PoolIds::LISA_QW, this); - lp_var_t lisaQx = lp_var_t(sid.objectId, PoolIds::LISA_QX, this); - lp_var_t lisaQy = lp_var_t(sid.objectId, PoolIds::LISA_QY, this); - lp_var_t lisaQz = lp_var_t(sid.objectId, PoolIds::LISA_QZ, this); - // Percentage of close stars in LISA solution - lp_var_t lisaPercentageClose = lp_var_t(sid.objectId, PoolIds::LISA_PERC_CLOSE, - this); - // Number of close stars in LISA solution - lp_var_t lisaNrClose = lp_var_t(sid.objectId, PoolIds::LISA_NR_CLOSE, this); - // Gives a combined overview of the validation parameters (1 for valid solution, otherwise 0) - lp_var_t isTrustWorthy = lp_var_t(sid.objectId, PoolIds::TRUST_WORTHY, this); - // Number of times the validation criteria was met - lp_var_t stableCount = lp_var_t(sid.objectId, PoolIds::STABLE_COUNT, this); - // Shows the autonomous mode used to obtain the star tracker attitude - lp_var_t solutionStrategy = lp_var_t(sid.objectId, PoolIds::SOLUTION_STRATEGY, - this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "SolutionSet::printSet: Ticks: " - << this->ticks << std::endl; - sif::info << "SolutionSet::printSet: Time: " - << this->time << std::endl; - sif::info << "SolutionSet::printSet: Calibrated quaternion Qw: " - << this->caliQw << std::endl; - sif::info << "SolutionSet::printSet: Calibrated quaternion Qx: " - << this->caliQx << std::endl; - sif::info << "SolutionSet::printSet: Calibrated quaternion Qy: " - << this->caliQy << std::endl; - sif::info << "SolutionSet::printSet: Calibrated quaternion Qz: " - << this->caliQz << std::endl; - sif::info << "SolutionSet::printSet: Track confidence: " - << this->trackConfidence << std::endl; - sif::info << "SolutionSet::printSet: Track Qw: " - << this->trackQw << std::endl; - sif::info << "SolutionSet::printSet: Track Qx: " - << this->trackQx << std::endl; - sif::info << "SolutionSet::printSet: Track Qy: " - << this->trackQy << std::endl; - sif::info << "SolutionSet::printSet: Track Qz: " - << this->trackQz << std::endl; - sif::info << "SolutionSet::printSet: Track removed: " - << static_cast(this->trackRemoved.value) << std::endl; - sif::info << "SolutionSet::printSet: Number of stars centroided: " - << static_cast(this->starsCentroided.value) << std::endl; - sif::info << "SolutionSet::printSet: Number of stars matched database: " - << static_cast(this->starsMatchedDatabase.value) << std::endl; - sif::info << "SolutionSet::printSet: LISA Qw: " - << this->lisaQw << std::endl; - sif::info << "SolutionSet::printSet: LISA Qx: " - << this->lisaQx << std::endl; - sif::info << "SolutionSet::printSet: LISA Qy: " - << this->lisaQy << std::endl; - sif::info << "SolutionSet::printSet: LISA Qz: " - << this->lisaQz << std::endl; - sif::info << "SolutionSet::printSet: LISA Percentage close: " - << this->lisaPercentageClose << std::endl; - sif::info << "SolutionSet::printSet: LISA number of close stars: " - << static_cast(this->lisaNrClose.value) << std::endl; - sif::info << "SolutionSet::printSet: Is trust worthy: " - << static_cast(this->isTrustWorthy.value) << std::endl; - sif::info << "SolutionSet::printSet: Stable count: " - << this->stableCount << std::endl; - sif::info << "SolutionSet::printSet: Solution strategy: " - << static_cast(this->solutionStrategy.value) << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "SolutionSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "SolutionSet::printSet: Time: " << this->time << std::endl; + sif::info << "SolutionSet::printSet: Calibrated quaternion Qw: " << this->caliQw << std::endl; + sif::info << "SolutionSet::printSet: Calibrated quaternion Qx: " << this->caliQx << std::endl; + sif::info << "SolutionSet::printSet: Calibrated quaternion Qy: " << this->caliQy << std::endl; + sif::info << "SolutionSet::printSet: Calibrated quaternion Qz: " << this->caliQz << std::endl; + sif::info << "SolutionSet::printSet: Track confidence: " << this->trackConfidence << std::endl; + sif::info << "SolutionSet::printSet: Track Qw: " << this->trackQw << std::endl; + sif::info << "SolutionSet::printSet: Track Qx: " << this->trackQx << std::endl; + sif::info << "SolutionSet::printSet: Track Qy: " << this->trackQy << std::endl; + sif::info << "SolutionSet::printSet: Track Qz: " << this->trackQz << std::endl; + sif::info << "SolutionSet::printSet: Track removed: " + << static_cast(this->trackRemoved.value) << std::endl; + sif::info << "SolutionSet::printSet: Number of stars centroided: " + << static_cast(this->starsCentroided.value) << std::endl; + sif::info << "SolutionSet::printSet: Number of stars matched database: " + << static_cast(this->starsMatchedDatabase.value) << std::endl; + sif::info << "SolutionSet::printSet: LISA Qw: " << this->lisaQw << std::endl; + sif::info << "SolutionSet::printSet: LISA Qx: " << this->lisaQx << std::endl; + sif::info << "SolutionSet::printSet: LISA Qy: " << this->lisaQy << std::endl; + sif::info << "SolutionSet::printSet: LISA Qz: " << this->lisaQz << std::endl; + sif::info << "SolutionSet::printSet: LISA Percentage close: " << this->lisaPercentageClose + << std::endl; + sif::info << "SolutionSet::printSet: LISA number of close stars: " + << static_cast(this->lisaNrClose.value) << std::endl; + sif::info << "SolutionSet::printSet: Is trust worthy: " + << static_cast(this->isTrustWorthy.value) << std::endl; + sif::info << "SolutionSet::printSet: Stable count: " << this->stableCount << std::endl; + sif::info << "SolutionSet::printSet: Solution strategy: " + << static_cast(this->solutionStrategy.value) << std::endl; + } }; /** * @brief Dataset to store the histogram */ -class HistogramSet: - public StaticLocalDataSet { -public: +class HistogramSet : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 156; - // Size of dataset - static const size_t SIZE = 156; + HistogramSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HISTOGRAM_SET_ID) {} - HistogramSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, HISTOGRAM_SET_ID) { - } + HistogramSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, HISTOGRAM_SET_ID)) {} - HistogramSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, HISTOGRAM_SET_ID)) { - } + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_HISTOGRAM_SET, this); + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_HISTOGRAM_SET, this); + lp_var_t binA0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA0, this); + lp_var_t binA1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA1, this); + lp_var_t binA2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA2, this); + lp_var_t binA3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA3, this); + lp_var_t binA4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA4, this); + lp_var_t binA5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA5, this); + lp_var_t binA6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA6, this); + lp_var_t binA7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA7, this); + lp_var_t binA8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA8, this); + lp_var_t binB0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB0, this); + lp_var_t binB1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB1, this); + lp_var_t binB2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB2, this); + lp_var_t binB3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB3, this); + lp_var_t binB4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB4, this); + lp_var_t binB5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB5, this); + lp_var_t binB6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB6, this); + lp_var_t binB7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB7, this); + lp_var_t binB8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB8, this); + lp_var_t binC0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC0, this); + lp_var_t binC1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC1, this); + lp_var_t binC2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC2, this); + lp_var_t binC3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC3, this); + lp_var_t binC4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC4, this); + lp_var_t binC5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC5, this); + lp_var_t binC6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC6, this); + lp_var_t binC7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC7, this); + lp_var_t binC8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC8, this); + lp_var_t binD0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND0, this); + lp_var_t binD1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND1, this); + lp_var_t binD2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND2, this); + lp_var_t binD3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND3, this); + lp_var_t binD4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND4, this); + lp_var_t binD5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND5, this); + lp_var_t binD6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND6, this); + lp_var_t binD7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND7, this); + lp_var_t binD8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND8, this); - lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_HISTOGRAM_SET, this); - lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_HISTOGRAM_SET, this); - lp_var_t binA0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA0, this); - lp_var_t binA1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA1, this); - lp_var_t binA2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA2, this); - lp_var_t binA3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA3, this); - lp_var_t binA4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA4, this); - lp_var_t binA5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA5, this); - lp_var_t binA6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA6, this); - lp_var_t binA7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA7, this); - lp_var_t binA8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA8, this); - lp_var_t binB0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB0, this); - lp_var_t binB1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB1, this); - lp_var_t binB2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB2, this); - lp_var_t binB3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB3, this); - lp_var_t binB4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB4, this); - lp_var_t binB5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB5, this); - lp_var_t binB6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB6, this); - lp_var_t binB7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB7, this); - lp_var_t binB8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB8, this); - lp_var_t binC0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC0, this); - lp_var_t binC1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC1, this); - lp_var_t binC2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC2, this); - lp_var_t binC3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC3, this); - lp_var_t binC4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC4, this); - lp_var_t binC5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC5, this); - lp_var_t binC6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC6, this); - lp_var_t binC7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC7, this); - lp_var_t binC8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC8, this); - lp_var_t binD0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND0, this); - lp_var_t binD1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND1, this); - lp_var_t binD2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND2, this); - lp_var_t binD3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND3, this); - lp_var_t binD4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND4, this); - lp_var_t binD5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND5, this); - lp_var_t binD6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND6, this); - lp_var_t binD7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND7, this); - lp_var_t binD8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND8, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "HistogramSet::printSet: Ticks: " << this->ticks << std::endl; - sif::info << "HistogramSet::printSet: Time (time stamp): " << this->time << " us" - << std::endl; - sif::info << "HistogramSet::printSet: BinA0: " << this->binA0 << std::endl; - sif::info << "HistogramSet::printSet: BinA1: " << this->binA1 << std::endl; - sif::info << "HistogramSet::printSet: BinA2: " << this->binA2 << std::endl; - sif::info << "HistogramSet::printSet: BinA3: " << this->binA3 << std::endl; - sif::info << "HistogramSet::printSet: BinA4: " << this->binA4 << std::endl; - sif::info << "HistogramSet::printSet: BinA5: " << this->binA5 << std::endl; - sif::info << "HistogramSet::printSet: BinA6: " << this->binA6 << std::endl; - sif::info << "HistogramSet::printSet: BinA7: " << this->binA7 << std::endl; - sif::info << "HistogramSet::printSet: BinA8: " << this->binA8 << std::endl; - sif::info << "HistogramSet::printSet: BinB0: " << this->binB0 << std::endl; - sif::info << "HistogramSet::printSet: BinB1: " << this->binB1 << std::endl; - sif::info << "HistogramSet::printSet: BinB2: " << this->binB2 << std::endl; - sif::info << "HistogramSet::printSet: BinB3: " << this->binB3 << std::endl; - sif::info << "HistogramSet::printSet: BinB4: " << this->binB4 << std::endl; - sif::info << "HistogramSet::printSet: BinB5: " << this->binB5 << std::endl; - sif::info << "HistogramSet::printSet: BinB6: " << this->binB6 << std::endl; - sif::info << "HistogramSet::printSet: BinB7: " << this->binB7 << std::endl; - sif::info << "HistogramSet::printSet: BinB8: " << this->binB8 << std::endl; - sif::info << "HistogramSet::printSet: BinC0: " << this->binC0 << std::endl; - sif::info << "HistogramSet::printSet: BinC1: " << this->binC1 << std::endl; - sif::info << "HistogramSet::printSet: BinC2: " << this->binC2 << std::endl; - sif::info << "HistogramSet::printSet: BinC3: " << this->binC3 << std::endl; - sif::info << "HistogramSet::printSet: BinC4: " << this->binC4 << std::endl; - sif::info << "HistogramSet::printSet: BinC5: " << this->binC5 << std::endl; - sif::info << "HistogramSet::printSet: BinC6: " << this->binC6 << std::endl; - sif::info << "HistogramSet::printSet: BinC7: " << this->binC7 << std::endl; - sif::info << "HistogramSet::printSet: BinC8: " << this->binC8 << std::endl; - sif::info << "HistogramSet::printSet: BinD0: " << this->binD0 << std::endl; - sif::info << "HistogramSet::printSet: BinD1: " << this->binD1 << std::endl; - sif::info << "HistogramSet::printSet: BinD2: " << this->binD2 << std::endl; - sif::info << "HistogramSet::printSet: BinD3: " << this->binD3 << std::endl; - sif::info << "HistogramSet::printSet: BinD4: " << this->binD4 << std::endl; - sif::info << "HistogramSet::printSet: BinD5: " << this->binD5 << std::endl; - sif::info << "HistogramSet::printSet: BinD6: " << this->binD6 << std::endl; - sif::info << "HistogramSet::printSet: BinD7: " << this->binD7 << std::endl; - sif::info << "HistogramSet::printSet: BinD8: " << this->binD8 << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "HistogramSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "HistogramSet::printSet: Time (time stamp): " << this->time << " us" << std::endl; + sif::info << "HistogramSet::printSet: BinA0: " << this->binA0 << std::endl; + sif::info << "HistogramSet::printSet: BinA1: " << this->binA1 << std::endl; + sif::info << "HistogramSet::printSet: BinA2: " << this->binA2 << std::endl; + sif::info << "HistogramSet::printSet: BinA3: " << this->binA3 << std::endl; + sif::info << "HistogramSet::printSet: BinA4: " << this->binA4 << std::endl; + sif::info << "HistogramSet::printSet: BinA5: " << this->binA5 << std::endl; + sif::info << "HistogramSet::printSet: BinA6: " << this->binA6 << std::endl; + sif::info << "HistogramSet::printSet: BinA7: " << this->binA7 << std::endl; + sif::info << "HistogramSet::printSet: BinA8: " << this->binA8 << std::endl; + sif::info << "HistogramSet::printSet: BinB0: " << this->binB0 << std::endl; + sif::info << "HistogramSet::printSet: BinB1: " << this->binB1 << std::endl; + sif::info << "HistogramSet::printSet: BinB2: " << this->binB2 << std::endl; + sif::info << "HistogramSet::printSet: BinB3: " << this->binB3 << std::endl; + sif::info << "HistogramSet::printSet: BinB4: " << this->binB4 << std::endl; + sif::info << "HistogramSet::printSet: BinB5: " << this->binB5 << std::endl; + sif::info << "HistogramSet::printSet: BinB6: " << this->binB6 << std::endl; + sif::info << "HistogramSet::printSet: BinB7: " << this->binB7 << std::endl; + sif::info << "HistogramSet::printSet: BinB8: " << this->binB8 << std::endl; + sif::info << "HistogramSet::printSet: BinC0: " << this->binC0 << std::endl; + sif::info << "HistogramSet::printSet: BinC1: " << this->binC1 << std::endl; + sif::info << "HistogramSet::printSet: BinC2: " << this->binC2 << std::endl; + sif::info << "HistogramSet::printSet: BinC3: " << this->binC3 << std::endl; + sif::info << "HistogramSet::printSet: BinC4: " << this->binC4 << std::endl; + sif::info << "HistogramSet::printSet: BinC5: " << this->binC5 << std::endl; + sif::info << "HistogramSet::printSet: BinC6: " << this->binC6 << std::endl; + sif::info << "HistogramSet::printSet: BinC7: " << this->binC7 << std::endl; + sif::info << "HistogramSet::printSet: BinC8: " << this->binC8 << std::endl; + sif::info << "HistogramSet::printSet: BinD0: " << this->binD0 << std::endl; + sif::info << "HistogramSet::printSet: BinD1: " << this->binD1 << std::endl; + sif::info << "HistogramSet::printSet: BinD2: " << this->binD2 << std::endl; + sif::info << "HistogramSet::printSet: BinD3: " << this->binD3 << std::endl; + sif::info << "HistogramSet::printSet: BinD4: " << this->binD4 << std::endl; + sif::info << "HistogramSet::printSet: BinD5: " << this->binD5 << std::endl; + sif::info << "HistogramSet::printSet: BinD6: " << this->binD6 << std::endl; + sif::info << "HistogramSet::printSet: BinD7: " << this->binD7 << std::endl; + sif::info << "HistogramSet::printSet: BinD8: " << this->binD8 << std::endl; + } }; /** * @brief Dataset to store the contrast telemetry data */ -class ContrastSet: - public StaticLocalDataSet { -public: +class ContrastSet : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 156; - // Size of dataset - static const size_t SIZE = 156; + ContrastSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, CONTRAST_SET_ID) {} - ContrastSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, CONTRAST_SET_ID) { - } + ContrastSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, CONTRAST_SET_ID)) {} - ContrastSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, CONTRAST_SET_ID)) { - } + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_CONTRAST_SET, this); + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_CONTRAST_SET, this); + lp_var_t binA0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA0, this); + lp_var_t binA1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA1, this); + lp_var_t binA2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA2, this); + lp_var_t binA3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA3, this); + lp_var_t binA4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA4, this); + lp_var_t binA5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA5, this); + lp_var_t binA6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA6, this); + lp_var_t binA7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA7, this); + lp_var_t binA8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA8, this); + lp_var_t binb0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB0, this); + lp_var_t binB1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB1, this); + lp_var_t binB2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB2, this); + lp_var_t binB3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB3, this); + lp_var_t binB4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB4, this); + lp_var_t binB5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB5, this); + lp_var_t binB6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB6, this); + lp_var_t binB7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB7, this); + lp_var_t binB8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB8, this); + lp_var_t binC0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC0, this); + lp_var_t binC1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC1, this); + lp_var_t binC2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC2, this); + lp_var_t binC3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC3, this); + lp_var_t binC4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC4, this); + lp_var_t binC5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC5, this); + lp_var_t binC6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC6, this); + lp_var_t binC7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC7, this); + lp_var_t binC8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC8, this); + lp_var_t binD0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND0, this); + lp_var_t binD1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND1, this); + lp_var_t binD2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND2, this); + lp_var_t binD3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND3, this); + lp_var_t binD4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND4, this); + lp_var_t binD5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND5, this); + lp_var_t binD6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND6, this); + lp_var_t binD7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND7, this); + lp_var_t binD8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND8, this); - lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_CONTRAST_SET, this); - lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_CONTRAST_SET, this); - lp_var_t binA0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA0, this); - lp_var_t binA1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA1, this); - lp_var_t binA2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA2, this); - lp_var_t binA3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA3, this); - lp_var_t binA4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA4, this); - lp_var_t binA5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA5, this); - lp_var_t binA6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA6, this); - lp_var_t binA7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA7, this); - lp_var_t binA8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA8, this); - lp_var_t binb0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB0, this); - lp_var_t binB1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB1, this); - lp_var_t binB2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB2, this); - lp_var_t binB3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB3, this); - lp_var_t binB4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB4, this); - lp_var_t binB5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB5, this); - lp_var_t binB6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB6, this); - lp_var_t binB7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB7, this); - lp_var_t binB8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB8, this); - lp_var_t binC0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC0, this); - lp_var_t binC1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC1, this); - lp_var_t binC2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC2, this); - lp_var_t binC3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC3, this); - lp_var_t binC4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC4, this); - lp_var_t binC5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC5, this); - lp_var_t binC6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC6, this); - lp_var_t binC7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC7, this); - lp_var_t binC8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC8, this); - lp_var_t binD0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND0, this); - lp_var_t binD1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND1, this); - lp_var_t binD2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND2, this); - lp_var_t binD3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND3, this); - lp_var_t binD4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND4, this); - lp_var_t binD5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND5, this); - lp_var_t binD6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND6, this); - lp_var_t binD7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND7, this); - lp_var_t binD8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND8, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "ContrastSet::printSet: Ticks: " << this->ticks << std::endl; - sif::info << "ContrastSet::printSet: Time (time stamp): " << this->time << " us" - << std::endl; - sif::info << "ContrastSet::printSet: BinA0: " << this->binA0 << std::endl; - sif::info << "ContrastSet::printSet: BinA1: " << this->binA1 << std::endl; - sif::info << "ContrastSet::printSet: BinA2: " << this->binA2 << std::endl; - sif::info << "ContrastSet::printSet: BinA3: " << this->binA3 << std::endl; - sif::info << "ContrastSet::printSet: BinA4: " << this->binA4 << std::endl; - sif::info << "ContrastSet::printSet: BinA5: " << this->binA5 << std::endl; - sif::info << "ContrastSet::printSet: BinA6: " << this->binA6 << std::endl; - sif::info << "ContrastSet::printSet: BinA7: " << this->binA7 << std::endl; - sif::info << "ContrastSet::printSet: BinA8: " << this->binA8 << std::endl; - sif::info << "ContrastSet::printSet: BinB0: " << this->binA0 << std::endl; - sif::info << "ContrastSet::printSet: BinB1: " << this->binB1 << std::endl; - sif::info << "ContrastSet::printSet: BinB2: " << this->binB2 << std::endl; - sif::info << "ContrastSet::printSet: BinB3: " << this->binB3 << std::endl; - sif::info << "ContrastSet::printSet: BinB4: " << this->binB4 << std::endl; - sif::info << "ContrastSet::printSet: BinB5: " << this->binB5 << std::endl; - sif::info << "ContrastSet::printSet: BinB6: " << this->binB6 << std::endl; - sif::info << "ContrastSet::printSet: BinB7: " << this->binB7 << std::endl; - sif::info << "ContrastSet::printSet: BinB8: " << this->binB8 << std::endl; - sif::info << "ContrastSet::printSet: BinC0: " << this->binC0 << std::endl; - sif::info << "ContrastSet::printSet: BinC1: " << this->binC1 << std::endl; - sif::info << "ContrastSet::printSet: BinC2: " << this->binC2 << std::endl; - sif::info << "ContrastSet::printSet: BinC3: " << this->binC3 << std::endl; - sif::info << "ContrastSet::printSet: BinC4: " << this->binC4 << std::endl; - sif::info << "ContrastSet::printSet: BinC5: " << this->binC5 << std::endl; - sif::info << "ContrastSet::printSet: BinC6: " << this->binC6 << std::endl; - sif::info << "ContrastSet::printSet: BinC7: " << this->binC7 << std::endl; - sif::info << "ContrastSet::printSet: BinC8: " << this->binC8 << std::endl; - sif::info << "ContrastSet::printSet: BinD0: " << this->binD0 << std::endl; - sif::info << "ContrastSet::printSet: BinD1: " << this->binD1 << std::endl; - sif::info << "ContrastSet::printSet: BinD2: " << this->binD2 << std::endl; - sif::info << "ContrastSet::printSet: BinD3: " << this->binD3 << std::endl; - sif::info << "ContrastSet::printSet: BinD4: " << this->binD4 << std::endl; - sif::info << "ContrastSet::printSet: BinD5: " << this->binD5 << std::endl; - sif::info << "ContrastSet::printSet: BinD6: " << this->binD6 << std::endl; - sif::info << "ContrastSet::printSet: BinD7: " << this->binD7 << std::endl; - sif::info << "ContrastSet::printSet: BinD8: " << this->binD8 << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "ContrastSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "ContrastSet::printSet: Time (time stamp): " << this->time << " us" << std::endl; + sif::info << "ContrastSet::printSet: BinA0: " << this->binA0 << std::endl; + sif::info << "ContrastSet::printSet: BinA1: " << this->binA1 << std::endl; + sif::info << "ContrastSet::printSet: BinA2: " << this->binA2 << std::endl; + sif::info << "ContrastSet::printSet: BinA3: " << this->binA3 << std::endl; + sif::info << "ContrastSet::printSet: BinA4: " << this->binA4 << std::endl; + sif::info << "ContrastSet::printSet: BinA5: " << this->binA5 << std::endl; + sif::info << "ContrastSet::printSet: BinA6: " << this->binA6 << std::endl; + sif::info << "ContrastSet::printSet: BinA7: " << this->binA7 << std::endl; + sif::info << "ContrastSet::printSet: BinA8: " << this->binA8 << std::endl; + sif::info << "ContrastSet::printSet: BinB0: " << this->binA0 << std::endl; + sif::info << "ContrastSet::printSet: BinB1: " << this->binB1 << std::endl; + sif::info << "ContrastSet::printSet: BinB2: " << this->binB2 << std::endl; + sif::info << "ContrastSet::printSet: BinB3: " << this->binB3 << std::endl; + sif::info << "ContrastSet::printSet: BinB4: " << this->binB4 << std::endl; + sif::info << "ContrastSet::printSet: BinB5: " << this->binB5 << std::endl; + sif::info << "ContrastSet::printSet: BinB6: " << this->binB6 << std::endl; + sif::info << "ContrastSet::printSet: BinB7: " << this->binB7 << std::endl; + sif::info << "ContrastSet::printSet: BinB8: " << this->binB8 << std::endl; + sif::info << "ContrastSet::printSet: BinC0: " << this->binC0 << std::endl; + sif::info << "ContrastSet::printSet: BinC1: " << this->binC1 << std::endl; + sif::info << "ContrastSet::printSet: BinC2: " << this->binC2 << std::endl; + sif::info << "ContrastSet::printSet: BinC3: " << this->binC3 << std::endl; + sif::info << "ContrastSet::printSet: BinC4: " << this->binC4 << std::endl; + sif::info << "ContrastSet::printSet: BinC5: " << this->binC5 << std::endl; + sif::info << "ContrastSet::printSet: BinC6: " << this->binC6 << std::endl; + sif::info << "ContrastSet::printSet: BinC7: " << this->binC7 << std::endl; + sif::info << "ContrastSet::printSet: BinC8: " << this->binC8 << std::endl; + sif::info << "ContrastSet::printSet: BinD0: " << this->binD0 << std::endl; + sif::info << "ContrastSet::printSet: BinD1: " << this->binD1 << std::endl; + sif::info << "ContrastSet::printSet: BinD2: " << this->binD2 << std::endl; + sif::info << "ContrastSet::printSet: BinD3: " << this->binD3 << std::endl; + sif::info << "ContrastSet::printSet: BinD4: " << this->binD4 << std::endl; + sif::info << "ContrastSet::printSet: BinD5: " << this->binD5 << std::endl; + sif::info << "ContrastSet::printSet: BinD6: " << this->binD6 << std::endl; + sif::info << "ContrastSet::printSet: BinD7: " << this->binD7 << std::endl; + sif::info << "ContrastSet::printSet: BinD8: " << this->binD8 << std::endl; + } }; /** * @brief Helper Class to extract information from bytestream. */ class ChecksumReply { -public: - - /** - * @brief Constructor - * - * @param datafield Pointer to datafield in reply buffer - * - */ - ChecksumReply(const uint8_t* datafield) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - region = *(datafield); - const uint8_t* addressData = datafield + ADDRESS_OFFSET; - size_t size = sizeof(address); - result = SerializeAdapter::deSerialize(&address, &addressData, &size, - SerializeIF::Endianness::LITTLE); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "ChecksumReply::ChecksumReply: Failed to deserialize address" - << std::endl; - } - const uint8_t* lengthData = datafield + LENGTH_OFFSET; - size = sizeof(length); - result = SerializeAdapter::deSerialize(&length, &lengthData, &size, - SerializeIF::Endianness::LITTLE); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "ChecksumReply::ChecksumReply: Failed to deserialize length" - << std::endl; - } - const uint8_t* checksumData = datafield + CHECKSUM_OFFSET; - size = sizeof(checksum); - result = SerializeAdapter::deSerialize(&checksum, &checksumData, &size, - SerializeIF::Endianness::LITTLE); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "ChecksumReply::ChecksumReply: Failed to deserialize checksum" - << std::endl; - } + public: + /** + * @brief Constructor + * + * @param datafield Pointer to datafield in reply buffer + * + */ + ChecksumReply(const uint8_t* datafield) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + region = *(datafield); + const uint8_t* addressData = datafield + ADDRESS_OFFSET; + size_t size = sizeof(address); + result = SerializeAdapter::deSerialize(&address, &addressData, &size, + SerializeIF::Endianness::LITTLE); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "ChecksumReply::ChecksumReply: Failed to deserialize address" << std::endl; } - - uint8_t getRegion() { - return region; + const uint8_t* lengthData = datafield + LENGTH_OFFSET; + size = sizeof(length); + result = + SerializeAdapter::deSerialize(&length, &lengthData, &size, SerializeIF::Endianness::LITTLE); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "ChecksumReply::ChecksumReply: Failed to deserialize length" << std::endl; } - - uint32_t getAddress() { - return address; + const uint8_t* checksumData = datafield + CHECKSUM_OFFSET; + size = sizeof(checksum); + result = SerializeAdapter::deSerialize(&checksum, &checksumData, &size, + SerializeIF::Endianness::LITTLE); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "ChecksumReply::ChecksumReply: Failed to deserialize checksum" << std::endl; } + } - uint32_t getLength() { - return length; - } + uint8_t getRegion() { return region; } - uint32_t getChecksum() { - return checksum; - } + uint32_t getAddress() { return address; } - void printChecksum() { - sif::info << "ChecksumReply::printChecksum: 0x" << std::hex << checksum << std::endl; - } + uint32_t getLength() { return length; } -private: + uint32_t getChecksum() { return checksum; } - static const uint8_t ADDRESS_OFFSET = 1; - static const uint8_t LENGTH_OFFSET = 5; - static const uint8_t CHECKSUM_OFFSET = 9; + void printChecksum() { + sif::info << "ChecksumReply::printChecksum: 0x" << std::hex << checksum << std::endl; + } - uint8_t region = 0; - uint32_t address = 0; - uint32_t length = 0; - uint32_t checksum = 0; + private: + static const uint8_t ADDRESS_OFFSET = 1; + static const uint8_t LENGTH_OFFSET = 5; + static const uint8_t CHECKSUM_OFFSET = 9; + + uint8_t region = 0; + uint32_t address = 0; + uint32_t length = 0; + uint32_t checksum = 0; }; class EraseReply { -public: - EraseReply(const uint8_t* datafield) { - region = *datafield; - } + public: + EraseReply(const uint8_t* datafield) { region = *datafield; } - uint8_t getRegion() { - return region; - } + uint8_t getRegion() { return region; } -private: - uint8_t region = 0; + private: + uint8_t region = 0; }; -class ChecksumSet: - public StaticLocalDataSet { -public: +class ChecksumSet : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 156; - // Size of dataset - static const size_t SIZE = 156; + ChecksumSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, CHECKSUM_SET_ID) {} - ChecksumSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, CHECKSUM_SET_ID) { - } + ChecksumSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, CHECKSUM_SET_ID)) {} - ChecksumSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, CHECKSUM_SET_ID)) { - } - - lp_var_t checksum = lp_var_t(sid.objectId, PoolIds::CHKSUM, this); + lp_var_t checksum = lp_var_t(sid.objectId, PoolIds::CHKSUM, this); }; /** * @brief Dataset to store download centroid response */ -class DownloadCentroidSet: - public StaticLocalDataSet { -public: +class DownloadCentroidSet : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 34; - // Size of dataset - static const size_t SIZE = 34; + DownloadCentroidSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, DOWNLOADCENTROID_SET_ID) {} - DownloadCentroidSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, DOWNLOADCENTROID_SET_ID) { - } + DownloadCentroidSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, DOWNLOADCENTROID_SET_ID)) {} - DownloadCentroidSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, DOWNLOADCENTROID_SET_ID)) { - } + lp_var_t id = lp_var_t(sid.objectId, PoolIds::DWL_ID, this); + lp_var_t pixx = lp_var_t(sid.objectId, PoolIds::DWL_PIXX, this); + lp_var_t pixy = lp_var_t(sid.objectId, PoolIds::DWL_PIXY, this); + lp_var_t xUncorrected = lp_var_t(sid.objectId, PoolIds::DWL_X_UNCORRECTED, this); + lp_var_t yUncorrected = lp_var_t(sid.objectId, PoolIds::DWL_Y_UNCORRECTED, this); + lp_var_t xCorrected = lp_var_t(sid.objectId, PoolIds::DWL_X_CORRECTED, this); + lp_var_t yCorrected = lp_var_t(sid.objectId, PoolIds::DWL_Y_CORRECTED, this); + lp_var_t magnitude = lp_var_t(sid.objectId, PoolIds::DWL_MAGNITUDE, this); + lp_var_t cxa = lp_var_t(sid.objectId, PoolIds::DWL_CXA, this); + lp_var_t cya = lp_var_t(sid.objectId, PoolIds::DWL_CYA, this); + lp_var_t quality = lp_var_t(sid.objectId, PoolIds::DWL_QUALITY, this); - lp_var_t id = lp_var_t(sid.objectId, PoolIds::DWL_ID, this); - lp_var_t pixx = lp_var_t(sid.objectId, PoolIds::DWL_PIXX, this); - lp_var_t pixy = lp_var_t(sid.objectId, PoolIds::DWL_PIXY, this); - lp_var_t xUncorrected = lp_var_t(sid.objectId, PoolIds::DWL_X_UNCORRECTED, this); - lp_var_t yUncorrected = lp_var_t(sid.objectId, PoolIds::DWL_Y_UNCORRECTED, this); - lp_var_t xCorrected = lp_var_t(sid.objectId, PoolIds::DWL_X_CORRECTED, this); - lp_var_t yCorrected = lp_var_t(sid.objectId, PoolIds::DWL_Y_CORRECTED, this); - lp_var_t magnitude = lp_var_t(sid.objectId, PoolIds::DWL_MAGNITUDE, this); - lp_var_t cxa = lp_var_t(sid.objectId, PoolIds::DWL_CXA, this); - lp_var_t cya = lp_var_t(sid.objectId, PoolIds::DWL_CYA, this); - lp_var_t quality = lp_var_t(sid.objectId, PoolIds::DWL_QUALITY, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "ContrastSet::printSet: id: " << static_cast(this->id.value) - << std::endl; - sif::info << "ContrastSet::printSet: pixx: " << this->pixx << std::endl; - sif::info << "ContrastSet::printSet: pixy: " << this->pixy << std::endl; - sif::info << "ContrastSet::printSet: xUncorrected: " << this->xUncorrected << std::endl; - sif::info << "ContrastSet::printSet: yUncorrected: " << this->yUncorrected << std::endl; - sif::info << "ContrastSet::printSet: xCorrected: " << this->xCorrected << std::endl; - sif::info << "ContrastSet::printSet: yCorrected: " << this->yCorrected << std::endl; - sif::info << "ContrastSet::printSet: magnitude: " << this->magnitude << std::endl; - sif::info << "ContrastSet::printSet: cxa: " << this->cxa << std::endl; - sif::info << "ContrastSet::printSet: cya: " << this->cya << std::endl; - sif::info << "ContrastSet::printSet: quality: " << this->quality << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "ContrastSet::printSet: id: " << static_cast(this->id.value) + << std::endl; + sif::info << "ContrastSet::printSet: pixx: " << this->pixx << std::endl; + sif::info << "ContrastSet::printSet: pixy: " << this->pixy << std::endl; + sif::info << "ContrastSet::printSet: xUncorrected: " << this->xUncorrected << std::endl; + sif::info << "ContrastSet::printSet: yUncorrected: " << this->yUncorrected << std::endl; + sif::info << "ContrastSet::printSet: xCorrected: " << this->xCorrected << std::endl; + sif::info << "ContrastSet::printSet: yCorrected: " << this->yCorrected << std::endl; + sif::info << "ContrastSet::printSet: magnitude: " << this->magnitude << std::endl; + sif::info << "ContrastSet::printSet: cxa: " << this->cxa << std::endl; + sif::info << "ContrastSet::printSet: cya: " << this->cya << std::endl; + sif::info << "ContrastSet::printSet: quality: " << this->quality << std::endl; + } }; namespace UploadCentroidKeys { - static const char id[] = "id"; - static const char pixx[] = "pixx"; - static const char pixy[] = "pixy"; - static const char x_uncorrected[] = "x_uncorrected"; - static const char y_uncorrected[] = "y_uncorrected"; - static const char x_corrected[] = "x_corrected"; - static const char y_corrected[] = "y_corrected"; - static const char magnitude[] = "magnitude"; - static const char cxa[] = "cxa"; - static const char cya[] = "cya"; - static const char quality[] = "quality"; -}; +static const char id[] = "id"; +static const char pixx[] = "pixx"; +static const char pixy[] = "pixy"; +static const char x_uncorrected[] = "x_uncorrected"; +static const char y_uncorrected[] = "y_uncorrected"; +static const char x_corrected[] = "x_corrected"; +static const char y_corrected[] = "y_corrected"; +static const char magnitude[] = "magnitude"; +static const char cxa[] = "cxa"; +static const char cya[] = "cya"; +static const char quality[] = "quality"; +}; // namespace UploadCentroidKeys /** * @brief Dataset to store matched star information */ -class DownloadMatchedStar : - public StaticLocalDataSet { -public: +class DownloadMatchedStar : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 53; - // Size of dataset - static const size_t SIZE = 53; + DownloadMatchedStar(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, DOWNLOAD_MATCHED_STAR_SET_ID) {} - DownloadMatchedStar(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, DOWNLOAD_MATCHED_STAR_SET_ID) { - } + DownloadMatchedStar(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, DOWNLOAD_MATCHED_STAR_SET_ID)) {} - DownloadMatchedStar(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, DOWNLOAD_MATCHED_STAR_SET_ID)) { - } + lp_var_t id = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_ID, this); + lp_var_t camfpx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMFPX, this); + lp_var_t camfpy = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMFPY, this); + lp_var_t camcartx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTX, this); + lp_var_t camcarty = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTY, this); + lp_var_t camcartz = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTZ, this); + lp_var_t cammagnitude = + lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMMAGNITUDE, this); + lp_var_t dbfpx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBFPX, this); + lp_var_t dbfpy = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBFPY, this); + lp_var_t dbcartx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBCARTX, this); + lp_var_t dbcarty = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBCARTY, this); + lp_var_t dbcartz = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBCARTZ, this); + lp_var_t dbmagnitude = + lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBMAGNITUDE, this); + lp_var_t catalogid = + lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CATALOGID, this); - lp_var_t id = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_ID, this); - lp_var_t camfpx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMFPX, this); - lp_var_t camfpy = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMFPY, this); - lp_var_t camcartx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTX, this); - lp_var_t camcarty = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTY, this); - lp_var_t camcartz = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTZ, this); - lp_var_t cammagnitude = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMMAGNITUDE, - this); - lp_var_t dbfpx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBFPX, this); - lp_var_t dbfpy = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBFPY, this); - lp_var_t dbcartx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBCARTX, this); - lp_var_t dbcarty = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBCARTY, this); - lp_var_t dbcartz = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBCARTZ, this); - lp_var_t dbmagnitude = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBMAGNITUDE, - this); - lp_var_t catalogid = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CATALOGID, - this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "DownloadMatchedStar::printSet: id: " - << static_cast(this->id.value) << std::endl; - sif::info << "DownloadMatchedStar::printSet: camfpx: " << this->camfpx << std::endl; - sif::info << "DownloadMatchedStar::printSet: camfpy: " << this->camfpy << std::endl; - sif::info << "DownloadMatchedStar::printSet: camcartx: " << this->camcartx << std::endl; - sif::info << "DownloadMatchedStar::printSet: camcarty: " << this->camcarty << std::endl; - sif::info << "DownloadMatchedStar::printSet: camcartz: " << this->camcartz << std::endl; - sif::info << "DownloadMatchedStar::printSet: cammagnitude: " << this->cammagnitude - << std::endl; - sif::info << "DownloadMatchedStar::printSet: dbfpx: " << this->dbfpx << std::endl; - sif::info << "DownloadMatchedStar::printSet: dbfpy: " << this->dbfpy << std::endl; - sif::info << "DownloadMatchedStar::printSet: dbcartx: " << this->dbcartx << std::endl; - sif::info << "DownloadMatchedStar::printSet: dbcarty: " << this->dbcarty << std::endl; - sif::info << "DownloadMatchedStar::printSet: dbcartz: " << this->dbcartz << std::endl; - sif::info << "DownloadMatchedStar::printSet: dbmagnitude: " << this->dbmagnitude - << std::endl; - sif::info << "DownloadMatchedStar::printSet: catalogid: " << this->catalogid << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "DownloadMatchedStar::printSet: id: " << static_cast(this->id.value) + << std::endl; + sif::info << "DownloadMatchedStar::printSet: camfpx: " << this->camfpx << std::endl; + sif::info << "DownloadMatchedStar::printSet: camfpy: " << this->camfpy << std::endl; + sif::info << "DownloadMatchedStar::printSet: camcartx: " << this->camcartx << std::endl; + sif::info << "DownloadMatchedStar::printSet: camcarty: " << this->camcarty << std::endl; + sif::info << "DownloadMatchedStar::printSet: camcartz: " << this->camcartz << std::endl; + sif::info << "DownloadMatchedStar::printSet: cammagnitude: " << this->cammagnitude << std::endl; + sif::info << "DownloadMatchedStar::printSet: dbfpx: " << this->dbfpx << std::endl; + sif::info << "DownloadMatchedStar::printSet: dbfpy: " << this->dbfpy << std::endl; + sif::info << "DownloadMatchedStar::printSet: dbcartx: " << this->dbcartx << std::endl; + sif::info << "DownloadMatchedStar::printSet: dbcarty: " << this->dbcarty << std::endl; + sif::info << "DownloadMatchedStar::printSet: dbcartz: " << this->dbcartz << std::endl; + sif::info << "DownloadMatchedStar::printSet: dbmagnitude: " << this->dbmagnitude << std::endl; + sif::info << "DownloadMatchedStar::printSet: catalogid: " << this->catalogid << std::endl; + } }; /** * @brief Dataset to store the response to the DownloadDBImage request */ -class DownloadDBImage : - public StaticLocalDataSet { -public: +class DownloadDBImage : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 21; - // Size of dataset - static const size_t SIZE = 21; + DownloadDBImage(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, DOWNLOAD_DBIMAGE_SET_ID) {} - DownloadDBImage(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, DOWNLOAD_DBIMAGE_SET_ID) { - } + DownloadDBImage(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, DOWNLOAD_DBIMAGE_SET_ID)) {} - DownloadDBImage(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, DOWNLOAD_DBIMAGE_SET_ID)) { - } + lp_var_t id = lp_var_t(sid.objectId, PoolIds::DBIMAGE_ID, this); + lp_var_t pixx = lp_var_t(sid.objectId, PoolIds::DBIMAGE_PIXX, this); + lp_var_t pixy = lp_var_t(sid.objectId, PoolIds::DBIMAGE_PIXY, this); + lp_var_t x = lp_var_t(sid.objectId, PoolIds::DBIMAGE_X, this); + lp_var_t y = lp_var_t(sid.objectId, PoolIds::DBIMAGE_Y, this); + lp_var_t magnitude = lp_var_t(sid.objectId, PoolIds::DBIMAGE_MAGNITUDE, this); - lp_var_t id = lp_var_t(sid.objectId, PoolIds::DBIMAGE_ID, this); - lp_var_t pixx = lp_var_t(sid.objectId, PoolIds::DBIMAGE_PIXX, this); - lp_var_t pixy = lp_var_t(sid.objectId, PoolIds::DBIMAGE_PIXY, this); - lp_var_t x = lp_var_t(sid.objectId, PoolIds::DBIMAGE_X, this); - lp_var_t y = lp_var_t(sid.objectId, PoolIds::DBIMAGE_Y, this); - lp_var_t magnitude = lp_var_t(sid.objectId, PoolIds::DBIMAGE_MAGNITUDE, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "DownloadDBImage::printSet: id: " - << static_cast(this->id.value) << std::endl; - sif::info << "DownloadDBImage::printSet: pixx: " << this->pixx << std::endl; - sif::info << "DownloadDBImage::printSet: pixy: " << this->pixy << std::endl; - sif::info << "DownloadDBImage::printSet: x: " << this->x << std::endl; - sif::info << "DownloadDBImage::printSet: y: " << this->y << std::endl; - sif::info << "DownloadDBImage::printSet: magnitude: " << this->magnitude << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "DownloadDBImage::printSet: id: " << static_cast(this->id.value) + << std::endl; + sif::info << "DownloadDBImage::printSet: pixx: " << this->pixx << std::endl; + sif::info << "DownloadDBImage::printSet: pixy: " << this->pixy << std::endl; + sif::info << "DownloadDBImage::printSet: x: " << this->x << std::endl; + sif::info << "DownloadDBImage::printSet: y: " << this->y << std::endl; + sif::info << "DownloadDBImage::printSet: magnitude: " << this->magnitude << std::endl; + } }; /** * @brief Dataset to store the response to the download blob pixel action request */ -class DownloadBlobPixel: public StaticLocalDataSet { -public: +class DownloadBlobPixel : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 22; - // Size of dataset - static const size_t SIZE = 22; + DownloadBlobPixel(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, DOWNLOAD_BLOBPIXEL_SET_ID) {} - DownloadBlobPixel(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, DOWNLOAD_BLOBPIXEL_SET_ID) { - } + DownloadBlobPixel(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, DOWNLOAD_BLOBPIXEL_SET_ENTRIES)) {} - DownloadBlobPixel(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, DOWNLOAD_BLOBPIXEL_SET_ENTRIES)) { - } + lp_var_t id = lp_var_t(sid.objectId, PoolIds::BLOBPIX_ID, this); + lp_var_t x = lp_var_t(sid.objectId, PoolIds::BLOBPIX_X, this); + lp_var_t y = lp_var_t(sid.objectId, PoolIds::BLOBPIX_Y, this); + lp_var_t totalValue = lp_var_t(sid.objectId, PoolIds::BLOBPIX_TOT_VAL, this); + lp_var_t inUse = lp_var_t(sid.objectId, PoolIds::BLOBPIX_IN_USE, this); + lp_var_t brightNeighbours = + lp_var_t(sid.objectId, PoolIds::BLOBPIX_BRIGHT_NEIGHBOURS, this); + lp_var_t region = lp_var_t(sid.objectId, PoolIds::BLOBPIX_REGION, this); - lp_var_t id = lp_var_t(sid.objectId, PoolIds::BLOBPIX_ID, this); - lp_var_t x = lp_var_t(sid.objectId, PoolIds::BLOBPIX_X, this); - lp_var_t y = lp_var_t(sid.objectId, PoolIds::BLOBPIX_Y, this); - lp_var_t totalValue = lp_var_t(sid.objectId, PoolIds::BLOBPIX_TOT_VAL, this); - lp_var_t inUse = lp_var_t(sid.objectId, PoolIds::BLOBPIX_IN_USE, this); - lp_var_t brightNeighbours = lp_var_t(sid.objectId, - PoolIds::BLOBPIX_BRIGHT_NEIGHBOURS, this); - lp_var_t region = lp_var_t(sid.objectId, PoolIds::BLOBPIX_REGION, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "DownloadBlobPixel::printSet: id: " - << static_cast(this->id.value) << std::endl; - sif::info << "DownloadBlobPixel::printSet: x: " << this->x << std::endl; - sif::info << "DownloadBlobPixel::printSet: y: " << this->y << std::endl; - sif::info << "DownloadBlobPixel::printSet: totalValue: " << this->totalValue << std::endl; - sif::info << "DownloadBlobPixel::printSet: inUse: " - << static_cast(this->inUse.value) << std::endl; - sif::info << "DownloadBlobPixel::printSet: brightNeighbours: " << this->brightNeighbours - << std::endl; - sif::info << "DownloadBlobPixel::printSet: region: " << this->region << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "DownloadBlobPixel::printSet: id: " << static_cast(this->id.value) + << std::endl; + sif::info << "DownloadBlobPixel::printSet: x: " << this->x << std::endl; + sif::info << "DownloadBlobPixel::printSet: y: " << this->y << std::endl; + sif::info << "DownloadBlobPixel::printSet: totalValue: " << this->totalValue << std::endl; + sif::info << "DownloadBlobPixel::printSet: inUse: " + << static_cast(this->inUse.value) << std::endl; + sif::info << "DownloadBlobPixel::printSet: brightNeighbours: " << this->brightNeighbours + << std::endl; + sif::info << "DownloadBlobPixel::printSet: region: " << this->region << std::endl; + } }; -} +} // namespace StarTracker #endif /* MISSION_STARTRACKER_DEFINITIONS_H_ */ diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp index de70037a..81fea5e7 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp @@ -1,645 +1,653 @@ -#include #include "StarTrackerHandler.h" -#include "OBSWConfig.h" -#include "StarTrackerJsonCommands.h" + #include #include #include + +#include + +#include "OBSWConfig.h" +#include "StarTrackerJsonCommands.h" extern "C" { - #include - #include - #include "common/misc.h" +#include +#include + +#include "common/misc.h" } using json = nlohmann::json; -StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie, StrHelper* strHelper) : - DeviceHandlerBase(objectId, comIF, comCookie), temperatureSet(this), versionSet(this), powerSet( - this), interfaceSet(this), timeSet(this), solutionSet(this), histogramSet(this), contrastSet( - this), checksumSet(this), downloadCentroidSet(this), downloadMatchedStar(this), - downloadDbImage(this), downloadBlobPixel(this), strHelper( - strHelper) { - if (comCookie == nullptr) { - sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl; - } - if (strHelper == nullptr) { - sif::error << "StarTrackerHandler: Invalid str image loader" << std::endl; - } - eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5); +StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, + StrHelper* strHelper) + : DeviceHandlerBase(objectId, comIF, comCookie), + temperatureSet(this), + versionSet(this), + powerSet(this), + interfaceSet(this), + timeSet(this), + solutionSet(this), + histogramSet(this), + contrastSet(this), + checksumSet(this), + downloadCentroidSet(this), + downloadMatchedStar(this), + downloadDbImage(this), + downloadBlobPixel(this), + strHelper(strHelper) { + if (comCookie == nullptr) { + sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl; + } + if (strHelper == nullptr) { + sif::error << "StarTrackerHandler: Invalid str image loader" << std::endl; + } + eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5); } -StarTrackerHandler::~StarTrackerHandler() { -} +StarTrackerHandler::~StarTrackerHandler() {} ReturnValue_t StarTrackerHandler::initialize() { - ReturnValue_t result = RETURN_OK; - result = DeviceHandlerBase::initialize(); - if (result != RETURN_OK) { - return result; - } + ReturnValue_t result = RETURN_OK; + result = DeviceHandlerBase::initialize(); + if (result != RETURN_OK) { + return result; + } - EventManagerIF* manager = ObjectManager::instance()->get( - objects::EVENT_MANAGER); - if (manager == nullptr) { + EventManagerIF* manager = ObjectManager::instance()->get(objects::EVENT_MANAGER); + if (manager == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "StarTrackerHandler::initialize: Invalid event manager" << std::endl; + sif::error << "StarTrackerHandler::initialize: Invalid event manager" << std::endl; #endif - return ObjectManagerIF::CHILD_INIT_FAILED;; - } - result = manager->registerListener(eventQueue->getId()); - if (result != RETURN_OK) { - return result; - } - result = manager->subscribeToEventRange(eventQueue->getId(), - event::getEventId(StrHelper::IMAGE_UPLOAD_FAILED), - event::getEventId(StrHelper::FPGA_UPLOAD_FAILED)); - if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + ; + } + result = manager->registerListener(eventQueue->getId()); + if (result != RETURN_OK) { + return result; + } + result = manager->subscribeToEventRange(eventQueue->getId(), + event::getEventId(StrHelper::IMAGE_UPLOAD_FAILED), + event::getEventId(StrHelper::FPGA_UPLOAD_FAILED)); + if (result != RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "StarTrackerHandler::initialize: Failed to subscribe to events from " - " str helper" << std::endl; + sif::warning << "StarTrackerHandler::initialize: Failed to subscribe to events from " + " str helper" + << std::endl; #endif - return ObjectManagerIF::CHILD_INIT_FAILED; - } + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = strHelper->setComIF(communicationInterface); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } - strHelper->setComCookie(comCookie); - return RETURN_OK; + result = strHelper->setComIF(communicationInterface); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } + strHelper->setComCookie(comCookie); + return RETURN_OK; } ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size) { + const uint8_t* data, size_t size) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; - - switch(actionId) { - case(StarTracker::STOP_IMAGE_LOADER): { - strHelper->stopProcess(); - return EXECUTION_FINISHED; + switch (actionId) { + case (StarTracker::STOP_IMAGE_LOADER): { + strHelper->stopProcess(); + return EXECUTION_FINISHED; } - case(StarTracker::SET_JSON_FILE_NAME): { - if (size > MAX_PATH_SIZE) { - return FILE_PATH_TOO_LONG; - } - paramJsonFile = std::string(reinterpret_cast(data), size); - return EXECUTION_FINISHED; + case (StarTracker::SET_JSON_FILE_NAME): { + if (size > MAX_PATH_SIZE) { + return FILE_PATH_TOO_LONG; + } + paramJsonFile = std::string(reinterpret_cast(data), size); + return EXECUTION_FINISHED; } default: - break; - } + break; + } - if (strHelperExecuting == true) { - return IMAGE_LOADER_EXECUTING; - } + if (strHelperExecuting == true) { + return IMAGE_LOADER_EXECUTING; + } - result = checkMode(actionId); - if (result != RETURN_OK) { + result = checkMode(actionId); + if (result != RETURN_OK) { + return result; + } + + // Intercept image loader commands which do not follow the common DHB communication flow + switch (actionId) { + case (StarTracker::UPLOAD_IMAGE): { + result = DeviceHandlerBase::acceptExternalDeviceCommands(); + if (result != RETURN_OK) { return result; + } + if (size > MAX_PATH_SIZE + MAX_FILE_NAME) { + return FILE_PATH_TOO_LONG; + } + result = strHelper->startImageUpload(std::string(reinterpret_cast(data), size)); + if (result != RETURN_OK) { + return result; + } + strHelperExecuting = true; + return EXECUTION_FINISHED; } + case (StarTracker::DOWNLOAD_IMAGE): { + result = DeviceHandlerBase::acceptExternalDeviceCommands(); + if (result != RETURN_OK) { + return result; + } + if (size > MAX_PATH_SIZE) { + return FILE_PATH_TOO_LONG; + } + result = + strHelper->startImageDownload(std::string(reinterpret_cast(data), size)); + if (result != RETURN_OK) { + return result; + } + strHelperExecuting = true; + return EXECUTION_FINISHED; + } + case (StarTracker::WRITE): { + result = DeviceHandlerBase::acceptExternalDeviceCommands(); + if (result != RETURN_OK) { + return result; + } + result = executeWriteCommand(data, size); + if (result != RETURN_OK) { + return result; + } - // Intercept image loader commands which do not follow the common DHB communication flow - switch(actionId) { - case(StarTracker::UPLOAD_IMAGE): { - result = DeviceHandlerBase::acceptExternalDeviceCommands(); - if (result != RETURN_OK) { - return result; - } - if (size > MAX_PATH_SIZE + MAX_FILE_NAME) { - return FILE_PATH_TOO_LONG; - } - result = strHelper->startImageUpload( - std::string(reinterpret_cast(data), size)); - if (result != RETURN_OK) { - return result; - } - strHelperExecuting = true; - return EXECUTION_FINISHED; + strHelperExecuting = true; + return EXECUTION_FINISHED; } - case(StarTracker::DOWNLOAD_IMAGE): { - result = DeviceHandlerBase::acceptExternalDeviceCommands(); - if (result != RETURN_OK) { - return result; - } - if (size > MAX_PATH_SIZE) { - return FILE_PATH_TOO_LONG; - } - result = strHelper->startImageDownload( - std::string(reinterpret_cast(data), size)); - if (result != RETURN_OK) { - return result; - } - strHelperExecuting = true; - return EXECUTION_FINISHED; + case (StarTracker::READ): { + result = DeviceHandlerBase::acceptExternalDeviceCommands(); + if (result != RETURN_OK) { + return result; + } + result = executeReadCommand(data, size); + if (result != RETURN_OK) { + return result; + } + strHelperExecuting = true; + return EXECUTION_FINISHED; } - case(StarTracker::WRITE): { - result = DeviceHandlerBase::acceptExternalDeviceCommands(); - if (result != RETURN_OK) { - return result; - } - result = executeWriteCommand(data, size); - if (result != RETURN_OK) { - return result; - } - - strHelperExecuting = true; - return EXECUTION_FINISHED; + case (StarTracker::CHANGE_DOWNLOAD_FILE): { + if (size > MAX_FILE_NAME) { + return FILENAME_TOO_LONG; + } + strHelper->setDownloadImageName(std::string(reinterpret_cast(data), size)); + return EXECUTION_FINISHED; } - case(StarTracker::READ): { - result = DeviceHandlerBase::acceptExternalDeviceCommands(); - if (result != RETURN_OK) { - return result; - } - result = executeReadCommand(data, size); - if (result != RETURN_OK) { - return result; - } - strHelperExecuting = true; - return EXECUTION_FINISHED; + case (StarTracker::CHANGE_FPGA_DOWNLOAD_FILE): { + if (size > MAX_FILE_NAME) { + return FILENAME_TOO_LONG; + } + strHelper->setDownloadFpgaImage(std::string(reinterpret_cast(data), size)); + return EXECUTION_FINISHED; } - case(StarTracker::CHANGE_DOWNLOAD_FILE): { - if (size > MAX_FILE_NAME) { - return FILENAME_TOO_LONG; - } - strHelper->setDownloadImageName( - std::string(reinterpret_cast(data), size)); - return EXECUTION_FINISHED; + case (StarTracker::SET_READ_FILENAME): { + if (size > MAX_FILE_NAME) { + return FILENAME_TOO_LONG; + } + strHelper->setDownloadImageName(std::string(reinterpret_cast(data), size)); + return EXECUTION_FINISHED; } - case(StarTracker::CHANGE_FPGA_DOWNLOAD_FILE): { - if (size > MAX_FILE_NAME) { - return FILENAME_TOO_LONG; - } - strHelper->setDownloadFpgaImage(std::string(reinterpret_cast(data), size)); - return EXECUTION_FINISHED; + case (StarTracker::DOWNLOAD_FPGA_IMAGE): { + result = DeviceHandlerBase::acceptExternalDeviceCommands(); + if (result != RETURN_OK) { + return result; + } + if (size > MAX_PATH_SIZE) { + return FILE_PATH_TOO_LONG; + } + result = executeFpgaDownloadCommand(data, size); + if (result != RETURN_OK) { + return result; + } + strHelperExecuting = true; + return EXECUTION_FINISHED; } - case(StarTracker::SET_READ_FILENAME): { - if (size > MAX_FILE_NAME) { - return FILENAME_TOO_LONG; - } - strHelper->setDownloadImageName( - std::string(reinterpret_cast(data), size)); - return EXECUTION_FINISHED; - } - case(StarTracker::DOWNLOAD_FPGA_IMAGE): { - result = DeviceHandlerBase::acceptExternalDeviceCommands(); - if (result != RETURN_OK) { - return result; - } - if (size > MAX_PATH_SIZE) { - return FILE_PATH_TOO_LONG; - } - result = executeFpgaDownloadCommand(data, size); - if (result != RETURN_OK) { - return result; - } - strHelperExecuting = true; - return EXECUTION_FINISHED; - } - case(StarTracker::UPLOAD_FPGA_IMAGE): { - result = DeviceHandlerBase::acceptExternalDeviceCommands(); - if (result != RETURN_OK) { - return result; - } - if (size > MAX_PATH_SIZE + MAX_FILE_NAME) { - return FILE_PATH_TOO_LONG; - } - result = strHelper->startFpgaUpload(std::string(reinterpret_cast(data), size)); - if (result != RETURN_OK) { - return result; - } - strHelperExecuting = true; - return EXECUTION_FINISHED; + case (StarTracker::UPLOAD_FPGA_IMAGE): { + result = DeviceHandlerBase::acceptExternalDeviceCommands(); + if (result != RETURN_OK) { + return result; + } + if (size > MAX_PATH_SIZE + MAX_FILE_NAME) { + return FILE_PATH_TOO_LONG; + } + result = strHelper->startFpgaUpload(std::string(reinterpret_cast(data), size)); + if (result != RETURN_OK) { + return result; + } + strHelperExecuting = true; + return EXECUTION_FINISHED; } default: - break; - } - return DeviceHandlerBase::executeAction(actionId, commandedBy, data, size); + break; + } + return DeviceHandlerBase::executeAction(actionId, commandedBy, data, size); } void StarTrackerHandler::performOperationHook() { - EventMessage event; - for (ReturnValue_t result = eventQueue->receiveMessage(&event); - result == RETURN_OK; result = eventQueue->receiveMessage(&event)) { - switch (event.getMessageId()) { - case EventMessage::EVENT_MESSAGE: - handleEvent(&event); - break; - default: - sif::debug << "CCSDSHandler::checkEvents: Did not subscribe to this event message" - << std::endl; - break; - } + EventMessage event; + for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == RETURN_OK; + result = eventQueue->receiveMessage(&event)) { + switch (event.getMessageId()) { + case EventMessage::EVENT_MESSAGE: + handleEvent(&event); + break; + default: + sif::debug << "CCSDSHandler::checkEvents: Did not subscribe to this event message" + << std::endl; + break; } + } } void StarTrackerHandler::doStartUp() { - switch(startupState) { + switch (startupState) { case StartupState::IDLE: - startupState = StartupState::CHECK_BOOT_STATE; - return; + startupState = StartupState::CHECK_BOOT_STATE; + return; case StartupState::BOOT_DELAY: - if (bootCountdown.hasTimedOut()) { - startupState = StartupState::LIMITS; - } - return; + if (bootCountdown.hasTimedOut()) { + startupState = StartupState::LIMITS; + } + return; case StartupState::DONE: - break; + break; default: - return; - } - setMode(_MODE_TO_ON); + return; + } + setMode(_MODE_TO_ON); } void StarTrackerHandler::doShutDown() { - // If star tracker is shutdown also stop all running processes in the image loader task - strHelper->stopProcess(); - setMode(_MODE_POWER_DOWN); + // If star tracker is shutdown also stop all running processes in the image loader task + strHelper->stopProcess(); + setMode(_MODE_POWER_DOWN); } -void StarTrackerHandler::doOffActivity() { - startupState = StartupState::IDLE; -} +void StarTrackerHandler::doOffActivity() { startupState = StartupState::IDLE; } -ReturnValue_t StarTrackerHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) { - switch (internalState) { +ReturnValue_t StarTrackerHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + switch (internalState) { case InternalState::TEMPERATURE_REQUEST: - *id = StarTracker::REQ_TEMPERATURE; - break; + *id = StarTracker::REQ_TEMPERATURE; + break; default: - sif::debug << "StarTrackerHandler::buildNormalDeviceCommand: Invalid internal step" - << std::endl; - break; - } - return buildCommandFromCommand(*id, NULL, 0); + sif::debug << "StarTrackerHandler::buildNormalDeviceCommand: Invalid internal step" + << std::endl; + break; + } + return buildCommandFromCommand(*id, NULL, 0); } -ReturnValue_t StarTrackerHandler::buildTransitionDeviceCommand(DeviceCommandId_t * id) { - if (mode != _MODE_START_UP) { - return NOTHING_TO_SEND; - } - switch (startupState) { - case StartupState::CHECK_BOOT_STATE: - *id = StarTracker::REQ_VERSION; - startupState = StartupState::WAIT_FOR_EXECUTION; - return buildCommandFromCommand(*id, nullptr, 0); - case StartupState::BOOT: - *id = StarTracker::BOOT; - bootCountdown.setTimeout(BOOT_TIMEOUT); - startupState = StartupState::BOOT_DELAY; - return buildCommandFromCommand(*id, nullptr, 0); - case StartupState::LIMITS: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::LIMITS; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::TRACKING: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::TRACKING; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::MOUNTING: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::MOUNTING; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::CAMERA: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::CAMERA; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::BLOB: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::BLOB; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::CENTROIDING: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::CENTROIDING; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::LISA: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::LISA; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::MATCHING: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::MATCHING; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::VALIDATION: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::VALIDATION; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::ALGO: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::ALGO; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - default: - break; - } +ReturnValue_t StarTrackerHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { + if (mode != _MODE_START_UP) { return NOTHING_TO_SEND; + } + switch (startupState) { + case StartupState::CHECK_BOOT_STATE: + *id = StarTracker::REQ_VERSION; + startupState = StartupState::WAIT_FOR_EXECUTION; + return buildCommandFromCommand(*id, nullptr, 0); + case StartupState::BOOT: + *id = StarTracker::BOOT; + bootCountdown.setTimeout(BOOT_TIMEOUT); + startupState = StartupState::BOOT_DELAY; + return buildCommandFromCommand(*id, nullptr, 0); + case StartupState::LIMITS: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::LIMITS; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::TRACKING: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::TRACKING; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::MOUNTING: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::MOUNTING; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::CAMERA: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::CAMERA; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::BLOB: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::BLOB; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::CENTROIDING: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::CENTROIDING; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::LISA: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::LISA; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::MATCHING: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::MATCHING; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::VALIDATION: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::VALIDATION; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::ALGO: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::ALGO; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + default: + break; + } + return NOTHING_TO_SEND; } ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t * commandData, size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - switch (deviceCommand) { + const uint8_t* commandData, + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + switch (deviceCommand) { case (StarTracker::PING_REQUEST): { - preparePingRequest(); - return RETURN_OK; + preparePingRequest(); + return RETURN_OK; } case (StarTracker::REQ_TIME): { - prepareTimeRequest(); - return RETURN_OK; + prepareTimeRequest(); + return RETURN_OK; } case (StarTracker::BOOT): { - prepareBootCommand(); - return RETURN_OK; + prepareBootCommand(); + return RETURN_OK; } case (StarTracker::REQ_VERSION): { - prepareVersionRequest(); - return RETURN_OK; + prepareVersionRequest(); + return RETURN_OK; } case (StarTracker::REQ_INTERFACE): { - prepareInterfaceRequest(); - return RETURN_OK; + prepareInterfaceRequest(); + return RETURN_OK; } case (StarTracker::REQ_POWER): { - preparePowerRequest(); - return RETURN_OK; + preparePowerRequest(); + return RETURN_OK; } case (StarTracker::SWITCH_TO_BOOTLOADER_PROGRAM): { - prepareRebootCommand(); - return RETURN_OK; + prepareRebootCommand(); + return RETURN_OK; } case (StarTracker::TAKE_IMAGE): { - prepareTakeImageCommand(commandData); - return RETURN_OK; + prepareTakeImageCommand(commandData); + return RETURN_OK; } case (StarTracker::SUBSCRIBE_TO_TM): { - prepareSubscriptionCommand(commandData); - return RETURN_OK; + prepareSubscriptionCommand(commandData); + return RETURN_OK; } case (StarTracker::REQ_SOLUTION): { - prepareSolutionRequest(); - return RETURN_OK; + prepareSolutionRequest(); + return RETURN_OK; } case (StarTracker::REQ_TEMPERATURE): { - prepareTemperatureRequest(); - return RETURN_OK; + prepareTemperatureRequest(); + return RETURN_OK; } case (StarTracker::REQ_HISTOGRAM): { - prepareHistogramRequest(); - return RETURN_OK; + prepareHistogramRequest(); + return RETURN_OK; } case (StarTracker::REQ_CONTRAST): { - prepareContrastRequest(); - return RETURN_OK; + prepareContrastRequest(); + return RETURN_OK; } case (StarTracker::RESET_ERROR): { - prepareErrorResetRequest(); - return RETURN_OK; + prepareErrorResetRequest(); + return RETURN_OK; } case (StarTracker::LIMITS): { - Limits limits; - result = prepareParamCommand(commandData, commandDataLen, limits); - return result; + Limits limits; + result = prepareParamCommand(commandData, commandDataLen, limits); + return result; } case (StarTracker::MOUNTING): { - Mounting mounting; - result = prepareParamCommand(commandData, commandDataLen, mounting); - return result; + Mounting mounting; + result = prepareParamCommand(commandData, commandDataLen, mounting); + return result; } case (StarTracker::CAMERA): { - Camera camera; - result = prepareParamCommand(commandData, commandDataLen, camera); - return result; + Camera camera; + result = prepareParamCommand(commandData, commandDataLen, camera); + return result; } case (StarTracker::BLOB): { - Blob blob; - result = prepareParamCommand(commandData, commandDataLen, blob); - return result; + Blob blob; + result = prepareParamCommand(commandData, commandDataLen, blob); + return result; } case (StarTracker::CENTROIDING): { - Centroiding centroiding; - result = prepareParamCommand(commandData, commandDataLen, centroiding); - return result; + Centroiding centroiding; + result = prepareParamCommand(commandData, commandDataLen, centroiding); + return result; } case (StarTracker::LISA): { - Lisa lisa; - result = prepareParamCommand(commandData, commandDataLen, lisa); - return result; + Lisa lisa; + result = prepareParamCommand(commandData, commandDataLen, lisa); + return result; } case (StarTracker::MATCHING): { - Matching matching; - result = prepareParamCommand(commandData, commandDataLen, matching); - return result; + Matching matching; + result = prepareParamCommand(commandData, commandDataLen, matching); + return result; } case (StarTracker::VALIDATION): { - Validation validation; - result = prepareParamCommand(commandData, commandDataLen, validation); - return result; + Validation validation; + result = prepareParamCommand(commandData, commandDataLen, validation); + return result; } case (StarTracker::ALGO): { - Algo algo; - result = prepareParamCommand(commandData, commandDataLen, algo); - return result; + Algo algo; + result = prepareParamCommand(commandData, commandDataLen, algo); + return result; } case (StarTracker::TRACKING): { - Tracking tracking; - result = prepareParamCommand(commandData, commandDataLen, tracking); - return result; + Tracking tracking; + result = prepareParamCommand(commandData, commandDataLen, tracking); + return result; } case (StarTracker::ERASE): { - result = prepareEraseCommand(commandData, commandDataLen); - return result; + result = prepareEraseCommand(commandData, commandDataLen); + return result; } case (StarTracker::UNLOCK): { - result = prepareUnlockCommand(commandData, commandDataLen); - return result; + result = prepareUnlockCommand(commandData, commandDataLen); + return result; } case (StarTracker::CHECKSUM): { - result = prepareChecksumCommand(commandData, commandDataLen); - return result; + result = prepareChecksumCommand(commandData, commandDataLen); + return result; } case (StarTracker::SET_TIME): { - result = prepareSetTimeCommand(commandData, commandDataLen); - return result; + result = prepareSetTimeCommand(commandData, commandDataLen); + return result; } case (StarTracker::DOWNLOAD_CENTROID): { - result = prepareDownloadCentroidCommand(commandData, commandDataLen); - return result; + result = prepareDownloadCentroidCommand(commandData, commandDataLen); + return result; } case (StarTracker::UPLOAD_CENTROID): { - result = prepareUploadCentroidCommand(commandData, commandDataLen); - return result; + result = prepareUploadCentroidCommand(commandData, commandDataLen); + return result; } case (StarTracker::DOWNLOAD_MATCHED_STAR): { - result = prepareDownloadMatchedStarCommand(commandData, commandDataLen); - return result; + result = prepareDownloadMatchedStarCommand(commandData, commandDataLen); + return result; } case (StarTracker::DOWNLOAD_DBIMAGE): { - result = prepareDownloadDbImageCommand(commandData, commandDataLen); - return result; + result = prepareDownloadDbImageCommand(commandData, commandDataLen); + return result; } case (StarTracker::DOWNLOAD_BLOBPIXEL): { - result = prepareDownloadBlobPixelCommand(commandData, commandDataLen); - return result; + result = prepareDownloadBlobPixelCommand(commandData, commandDataLen); + return result; } case (StarTracker::FPGA_ACTION): { - result = prepareFpgaActionCommand(commandData, commandDataLen); - return result; + result = prepareFpgaActionCommand(commandData, commandDataLen); + return result; } default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } void StarTrackerHandler::fillCommandAndReplyMap() { - /** Reply lengths are unknown because of the slip encoding. Thus always maximum reply size - * is specified */ - this->insertInCommandAndReplyMap(StarTracker::PING_REQUEST, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandMap(StarTracker::BOOT); - this->insertInCommandAndReplyMap(StarTracker::REQ_VERSION, 3, &versionSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_TIME, 3, &timeSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandMap(StarTracker::UPLOAD_IMAGE); - this->insertInCommandMap(StarTracker::DOWNLOAD_IMAGE); - this->insertInCommandAndReplyMap(StarTracker::REQ_POWER, 3, &powerSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_INTERFACE, 3, &interfaceSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - // Reboot has no reply. Star tracker reboots immediately - this->insertInCommandMap(StarTracker::SWITCH_TO_BOOTLOADER_PROGRAM); - this->insertInCommandAndReplyMap(StarTracker::SUBSCRIBE_TO_TM, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_SOLUTION, 3, &solutionSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_TEMPERATURE, 3, &temperatureSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_HISTOGRAM, 3, &histogramSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_CONTRAST, 3, &contrastSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::LIMITS, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::MOUNTING, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::CAMERA, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::BLOB, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::CENTROIDING, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::LISA, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::MATCHING, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::TRACKING, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::VALIDATION, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::ALGO, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::TAKE_IMAGE, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::RESET_ERROR, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::ERASE, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::UNLOCK, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::CHECKSUM, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::SET_TIME, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_CENTROID, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::UPLOAD_CENTROID, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_MATCHED_STAR, 3, &downloadMatchedStar, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_DBIMAGE, 3, &downloadDbImage, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_BLOBPIXEL, 3, &downloadBlobPixel, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::FPGA_ACTION, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); + /** Reply lengths are unknown because of the slip encoding. Thus always maximum reply size + * is specified */ + this->insertInCommandAndReplyMap(StarTracker::PING_REQUEST, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandMap(StarTracker::BOOT); + this->insertInCommandAndReplyMap(StarTracker::REQ_VERSION, 3, &versionSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_TIME, 3, &timeSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandMap(StarTracker::UPLOAD_IMAGE); + this->insertInCommandMap(StarTracker::DOWNLOAD_IMAGE); + this->insertInCommandAndReplyMap(StarTracker::REQ_POWER, 3, &powerSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_INTERFACE, 3, &interfaceSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + // Reboot has no reply. Star tracker reboots immediately + this->insertInCommandMap(StarTracker::SWITCH_TO_BOOTLOADER_PROGRAM); + this->insertInCommandAndReplyMap(StarTracker::SUBSCRIBE_TO_TM, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_SOLUTION, 3, &solutionSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_TEMPERATURE, 3, &temperatureSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_HISTOGRAM, 3, &histogramSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_CONTRAST, 3, &contrastSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::LIMITS, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::MOUNTING, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::CAMERA, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::BLOB, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::CENTROIDING, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::LISA, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::MATCHING, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::TRACKING, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::VALIDATION, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::ALGO, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::TAKE_IMAGE, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::RESET_ERROR, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::ERASE, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::UNLOCK, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::CHECKSUM, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::SET_TIME, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_CENTROID, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::UPLOAD_CENTROID, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_MATCHED_STAR, 3, &downloadMatchedStar, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_DBIMAGE, 3, &downloadDbImage, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_BLOBPIXEL, 3, &downloadBlobPixel, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::FPGA_ACTION, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); } -ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t remainingSize, - DeviceCommandId_t *foundId, size_t *foundLen) { +ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + ReturnValue_t result = RETURN_OK; + size_t bytesLeft = 0; - ReturnValue_t result = RETURN_OK; - size_t bytesLeft = 0; - - result = dataLinkLayer.decodeFrame(start, remainingSize, &bytesLeft); - switch(result) { + result = dataLinkLayer.decodeFrame(start, remainingSize, &bytesLeft); + switch (result) { case ArcsecDatalinkLayer::DEC_IN_PROGRESS: { - remainingSize = bytesLeft; - // Need a second doSendRead pass to reaa in whole packet - return IGNORE_REPLY_DATA; + remainingSize = bytesLeft; + // Need a second doSendRead pass to reaa in whole packet + return IGNORE_REPLY_DATA; } case RETURN_OK: { - break; + break; } default: - remainingSize = bytesLeft; - return result; - } + remainingSize = bytesLeft; + return result; + } - switch (dataLinkLayer.getReplyFrameType()) { + switch (dataLinkLayer.getReplyFrameType()) { case TMTC_ACTIONREPLY: { - *foundLen = remainingSize - bytesLeft; - result = scanForActionReply(foundId); - break; + *foundLen = remainingSize - bytesLeft; + result = scanForActionReply(foundId); + break; } case TMTC_SETPARAMREPLY: { - *foundLen = remainingSize - bytesLeft; - result = scanForParameterReply(foundId); - break; + *foundLen = remainingSize - bytesLeft; + result = scanForParameterReply(foundId); + break; } case TMTC_TELEMETRYREPLYA: case TMTC_TELEMETRYREPLY: { - *foundLen = remainingSize - bytesLeft; - result = scanForTmReply(foundId); - break; + *foundLen = remainingSize - bytesLeft; + result = scanForTmReply(foundId); + break; } default: { - sif::debug << "StarTrackerHandler::scanForReply: Reply has invalid type id" << std::endl; - result = RETURN_FAILED; - } + sif::debug << "StarTrackerHandler::scanForReply: Reply has invalid type id" << std::endl; + result = RETURN_FAILED; } + } - remainingSize = bytesLeft; + remainingSize = bytesLeft; - return result; + return result; } -ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { +ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, + const uint8_t* packet) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; - - switch (id) { + switch (id) { case (StarTracker::SUBSCRIBE_TO_TM): { - result = handleSetParamReply(); - break; + result = handleSetParamReply(); + break; } case (StarTracker::REQ_TIME): { - result = handleTm(timeSet, StarTracker::TimeSet::SIZE); - break; + result = handleTm(timeSet, StarTracker::TimeSet::SIZE); + break; } case (StarTracker::PING_REQUEST): { - result = handlePingReply(); - break; + result = handlePingReply(); + break; } case (StarTracker::BOOT): case (StarTracker::TAKE_IMAGE): @@ -647,71 +655,71 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con case (StarTracker::UNLOCK): case (StarTracker::SET_TIME): case (StarTracker::FPGA_ACTION): { - result = handleActionReply(); - break; + result = handleActionReply(); + break; } case (StarTracker::DOWNLOAD_CENTROID): { - result = handleActionReplySet(downloadCentroidSet, StarTracker::DownloadCentroidSet::SIZE); - break; + result = handleActionReplySet(downloadCentroidSet, StarTracker::DownloadCentroidSet::SIZE); + break; } case (StarTracker::DOWNLOAD_MATCHED_STAR): { - result = handleActionReplySet(downloadMatchedStar, StarTracker::DownloadMatchedStar::SIZE); - break; + result = handleActionReplySet(downloadMatchedStar, StarTracker::DownloadMatchedStar::SIZE); + break; } case (StarTracker::DOWNLOAD_DBIMAGE): { - result = handleActionReplySet(downloadDbImage, StarTracker::DownloadDBImage::SIZE); - break; + result = handleActionReplySet(downloadDbImage, StarTracker::DownloadDBImage::SIZE); + break; } case (StarTracker::DOWNLOAD_BLOBPIXEL): { - result = handleActionReplySet(downloadBlobPixel, StarTracker::DownloadBlobPixel::SIZE); - break; + result = handleActionReplySet(downloadBlobPixel, StarTracker::DownloadBlobPixel::SIZE); + break; } case (StarTracker::UPLOAD_CENTROID): { - result = handleUploadCentroidReply(); - break; + result = handleUploadCentroidReply(); + break; } case (StarTracker::ERASE): { - result = handleEraseReply(); - break; + result = handleEraseReply(); + break; } case (StarTracker::CHECKSUM): { - result = handleChecksumReply(); - break; + result = handleChecksumReply(); + break; } case (StarTracker::REQ_VERSION): { - result = handleTm(versionSet, StarTracker::VersionSet::SIZE); - if (result != RETURN_OK) { - return result; - } - result = checkProgram(); - if (result != RETURN_OK) { - return result; - } - break; + result = handleTm(versionSet, StarTracker::VersionSet::SIZE); + if (result != RETURN_OK) { + return result; + } + result = checkProgram(); + if (result != RETURN_OK) { + return result; + } + break; } case (StarTracker::REQ_INTERFACE): { - result = handleTm(interfaceSet, StarTracker::InterfaceSet::SIZE); - break; + result = handleTm(interfaceSet, StarTracker::InterfaceSet::SIZE); + break; } case (StarTracker::REQ_POWER): { - result = handleTm(powerSet, StarTracker::PowerSet::SIZE); - break; + result = handleTm(powerSet, StarTracker::PowerSet::SIZE); + break; } case (StarTracker::REQ_SOLUTION): { - result = handleTm(solutionSet, StarTracker::SolutionSet::SIZE); - break; + result = handleTm(solutionSet, StarTracker::SolutionSet::SIZE); + break; } case (StarTracker::REQ_TEMPERATURE): { - result = handleTm(temperatureSet, StarTracker::TemperatureSet::SIZE); - break; + result = handleTm(temperatureSet, StarTracker::TemperatureSet::SIZE); + break; } case (StarTracker::REQ_HISTOGRAM): { - result = handleTm(histogramSet, StarTracker::HistogramSet::SIZE); - break; + result = handleTm(histogramSet, StarTracker::HistogramSet::SIZE); + break; } case (StarTracker::REQ_CONTRAST): { - result = handleTm(contrastSet, StarTracker::ContrastSet::SIZE); - break; + result = handleTm(contrastSet, StarTracker::ContrastSet::SIZE); + break; } case (StarTracker::LIMITS): case (StarTracker::MOUNTING): @@ -723,1227 +731,1217 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con case (StarTracker::TRACKING): case (StarTracker::VALIDATION): case (StarTracker::ALGO): { - result = handleSetParamReply(); - break; + result = handleSetParamReply(); + break; } default: { - sif::debug << "StarTrackerHandler::interpretDeviceReply: Unknown device reply id:" << id - << std::endl; - result = DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } + sif::debug << "StarTrackerHandler::interpretDeviceReply: Unknown device reply id:" << id + << std::endl; + result = DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; } + } - return result; + return result; } +void StarTrackerHandler::setNormalDatapoolEntriesInvalid() {} -void StarTrackerHandler::setNormalDatapoolEntriesInvalid() { - -} - -uint32_t StarTrackerHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { - return 20000; -} +uint32_t StarTrackerHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 20000; } ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { + LocalDataPoolManager& poolManager) { + localDataPoolMap.emplace(StarTracker::TICKS_TIME_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_TIME_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::RUN_TIME, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::UNIX_TIME, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_TIME_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_TIME_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::RUN_TIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::UNIX_TIME, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_VERSION_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_VERSION_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::PROGRAM, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MAJOR, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MINOR, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_VERSION_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_VERSION_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::PROGRAM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MAJOR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MINOR, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_INTERFACE_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_INTERFACE_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::FRAME_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CHECKSUM_ERROR_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::SET_PARAM_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::SET_PARAM_REPLY_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::PARAM_REQUEST_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::PARAM_REPLY_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::REQ_TM_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TM_REPLY_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::ACTION_REQ_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::ACTION_REPLY_COUNT, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_INTERFACE_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_INTERFACE_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::FRAME_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CHECKSUM_ERROR_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::SET_PARAM_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::SET_PARAM_REPLY_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::PARAM_REQUEST_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::PARAM_REPLY_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::REQ_TM_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TM_REPLY_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::ACTION_REQ_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::ACTION_REPLY_COUNT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_POWER_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_POWER_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MCU_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MCU_VOLTAGE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::FPGA_CORE_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::FPGA_CORE_VOLTAGE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::FPGA_18_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::FPGA_18_VOLTAGE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::FPGA_25_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::FPGA_25_VOLTAGE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_21_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_21_VOLTAGE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_PIX_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_PIX_VOLTAGE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_33_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_33_VOLTAGE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_RES_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_RES_VOLTAGE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_POWER_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_POWER_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MCU_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MCU_VOLTAGE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::FPGA_CORE_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::FPGA_CORE_VOLTAGE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::FPGA_18_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::FPGA_18_VOLTAGE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::FPGA_25_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::FPGA_25_VOLTAGE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_21_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_21_VOLTAGE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_PIX_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_PIX_VOLTAGE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_33_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_33_VOLTAGE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_RES_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_RES_VOLTAGE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_TEMPERATURE_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_TEMPERATURE_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MCU_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMOS_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_TEMPERATURE_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_TEMPERATURE_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MCU_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMOS_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_SOLUTION_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_SOLUTION_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CALI_QW, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CALI_QX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CALI_QY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CALI_QZ, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TRACK_CONFIDENCE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TRACK_QW, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TRACK_QX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TRACK_QY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TRACK_QZ, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TRACK_REMOVED, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::STARS_CENTROIDED, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::STARS_MATCHED_DATABASE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LISA_QW, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LISA_QX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LISA_QY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LISA_QZ, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LISA_PERC_CLOSE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LISA_NR_CLOSE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TRUST_WORTHY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::STABLE_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::SOLUTION_STRATEGY, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_SOLUTION_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_SOLUTION_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CALI_QW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CALI_QX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CALI_QY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CALI_QZ, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TRACK_CONFIDENCE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TRACK_QW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TRACK_QX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TRACK_QY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TRACK_QZ, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TRACK_REMOVED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::STARS_CENTROIDED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::STARS_MATCHED_DATABASE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LISA_QW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LISA_QX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LISA_QY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LISA_QZ, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LISA_PERC_CLOSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LISA_NR_CLOSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TRUST_WORTHY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::STABLE_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::SOLUTION_STRATEGY, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_HISTOGRAM_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_HISTOGRAM_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND8, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_HISTOGRAM_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_HISTOGRAM_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_CONTRAST_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_CONTRAST_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CHKSUM, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_CONTRAST_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_CONTRAST_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CHKSUM, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::DWL_ID, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_PIXX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_PIXY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_X_UNCORRECTED, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_Y_UNCORRECTED, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_X_CORRECTED, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_Y_CORRECTED, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_MAGNITUDE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_CXA, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_CYA, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_QUALITY, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::DWL_ID, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_PIXX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_PIXY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_X_UNCORRECTED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_Y_UNCORRECTED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_X_CORRECTED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_Y_CORRECTED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_MAGNITUDE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_CXA, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_CYA, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_QUALITY, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_ID, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMFPX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMFPY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTZ, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMMAGNITUDE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBFPX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBFPY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTZ, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBMAGNITUDE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CATALOGID, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_ID, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMFPX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMFPY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTZ, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMMAGNITUDE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBFPX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBFPY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTZ, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBMAGNITUDE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CATALOGID, new PoolEntry( { 0 })); - - localDataPoolMap.emplace(StarTracker::BLOBPIX_ID, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOBPIX_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOBPIX_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOBPIX_TOT_VAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOBPIX_IN_USE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOBPIX_BRIGHT_NEIGHBOURS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOBPIX_REGION, new PoolEntry( { 0 })); - return RETURN_OK; + localDataPoolMap.emplace(StarTracker::BLOBPIX_ID, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOBPIX_X, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOBPIX_Y, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOBPIX_TOT_VAL, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOBPIX_IN_USE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOBPIX_BRIGHT_NEIGHBOURS, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOBPIX_REGION, new PoolEntry({0})); + return RETURN_OK; } -size_t StarTrackerHandler::getNextReplyLength(DeviceCommandId_t commandId){ - return StarTracker::MAX_FRAME_SIZE; +size_t StarTrackerHandler::getNextReplyLength(DeviceCommandId_t commandId) { + return StarTracker::MAX_FRAME_SIZE; } ReturnValue_t StarTrackerHandler::doSendReadHook() { - // Prevent DHB from polling UART during commands executed by the image loader task - if(strHelperExecuting) { - return RETURN_FAILED; - } - return RETURN_OK; + // Prevent DHB from polling UART during commands executed by the image loader task + if (strHelperExecuting) { + return RETURN_FAILED; + } + return RETURN_OK; } ReturnValue_t StarTrackerHandler::checkMode(ActionId_t actionId) { - switch(actionId) { + switch (actionId) { case StarTracker::UPLOAD_IMAGE: case StarTracker::DOWNLOAD_IMAGE: { - return DeviceHandlerBase::acceptExternalDeviceCommands(); - default: + return DeviceHandlerBase::acceptExternalDeviceCommands(); + default: break; } - } - return RETURN_OK; + } + return RETURN_OK; } -ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t *foundId) { - const uint8_t* reply = dataLinkLayer.getReply(); - switch (*reply) { +ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t* foundId) { + const uint8_t* reply = dataLinkLayer.getReply(); + switch (*reply) { case (StarTracker::ID::PING): { - *foundId = StarTracker::PING_REQUEST; - break; + *foundId = StarTracker::PING_REQUEST; + break; } case (StarTracker::ID::WRITE): { - *foundId = StarTracker::WRITE; - break; + *foundId = StarTracker::WRITE; + break; } case (StarTracker::ID::BOOT): { - *foundId = StarTracker::BOOT; - break; + *foundId = StarTracker::BOOT; + break; } case (StarTracker::ID::TAKE_IMAGE): { - *foundId = StarTracker::TAKE_IMAGE; - break; + *foundId = StarTracker::TAKE_IMAGE; + break; } case (StarTracker::ID::UPLOAD_IMAGE): { - *foundId = StarTracker::UPLOAD_IMAGE; - break; + *foundId = StarTracker::UPLOAD_IMAGE; + break; } case (StarTracker::ID::ERROR_RESET): { - *foundId = StarTracker::RESET_ERROR; - break; + *foundId = StarTracker::RESET_ERROR; + break; } case (StarTracker::ID::ERASE): { - *foundId = StarTracker::ERASE; - break; + *foundId = StarTracker::ERASE; + break; } case (StarTracker::ID::UNLOCK): { - *foundId = StarTracker::UNLOCK; - break; + *foundId = StarTracker::UNLOCK; + break; } case (StarTracker::ID::CHECKSUM): { - *foundId = StarTracker::CHECKSUM; - break; + *foundId = StarTracker::CHECKSUM; + break; } case (StarTracker::ID::SET_TIME): { - *foundId = StarTracker::SET_TIME; - break; + *foundId = StarTracker::SET_TIME; + break; } case (StarTracker::ID::DOWNLOAD_CENTROID): { - *foundId = StarTracker::DOWNLOAD_CENTROID; - break; + *foundId = StarTracker::DOWNLOAD_CENTROID; + break; } case (StarTracker::ID::UPLOAD_CENTROID): { - *foundId = StarTracker::UPLOAD_CENTROID; - break; + *foundId = StarTracker::UPLOAD_CENTROID; + break; } case (StarTracker::ID::DOWNLOAD_MATCHED_STAR): { - *foundId = StarTracker::DOWNLOAD_MATCHED_STAR; - break; + *foundId = StarTracker::DOWNLOAD_MATCHED_STAR; + break; } case (StarTracker::ID::DOWNLOAD_DBIMAGE): { - *foundId = StarTracker::DOWNLOAD_DBIMAGE; - break; + *foundId = StarTracker::DOWNLOAD_DBIMAGE; + break; } case (StarTracker::ID::DOWNLOAD_BLOBPIXEL): { - *foundId = StarTracker::DOWNLOAD_BLOBPIXEL; - break; + *foundId = StarTracker::DOWNLOAD_BLOBPIXEL; + break; } case (StarTracker::ID::FPGA_ACTION): { - *foundId = StarTracker::FPGA_ACTION; - break; + *foundId = StarTracker::FPGA_ACTION; + break; } default: - sif::warning << "StarTrackerHandler::scanForParameterReply: Unknown parameter reply id" - << std::endl; - return RETURN_FAILED; - } - return RETURN_OK; + sif::warning << "StarTrackerHandler::scanForParameterReply: Unknown parameter reply id" + << std::endl; + return RETURN_FAILED; + } + return RETURN_OK; } -ReturnValue_t StarTrackerHandler::scanForParameterReply(DeviceCommandId_t *foundId) { - const uint8_t* reply = dataLinkLayer.getReply(); - switch (*reply) { +ReturnValue_t StarTrackerHandler::scanForParameterReply(DeviceCommandId_t* foundId) { + const uint8_t* reply = dataLinkLayer.getReply(); + switch (*reply) { case (StarTracker::ID::SUBSCRIBE): { - *foundId = StarTracker::SUBSCRIBE_TO_TM; - break; + *foundId = StarTracker::SUBSCRIBE_TO_TM; + break; } case (StarTracker::ID::LIMITS): { - *foundId = StarTracker::LIMITS; - break; + *foundId = StarTracker::LIMITS; + break; } case (StarTracker::ID::MOUNTING): { - *foundId = StarTracker::MOUNTING; - break; + *foundId = StarTracker::MOUNTING; + break; } case (StarTracker::ID::CAMERA): { - *foundId = StarTracker::CAMERA; - break; + *foundId = StarTracker::CAMERA; + break; } case (StarTracker::ID::BLOB): { - *foundId = StarTracker::BLOB; - break; + *foundId = StarTracker::BLOB; + break; } case (StarTracker::ID::CENTROIDING): { - *foundId = StarTracker::CENTROIDING; - break; + *foundId = StarTracker::CENTROIDING; + break; } case (StarTracker::ID::LISA): { - *foundId = StarTracker::LISA; - break; + *foundId = StarTracker::LISA; + break; } case (StarTracker::ID::MATCHING): { - *foundId = StarTracker::MATCHING; - break; + *foundId = StarTracker::MATCHING; + break; } case (StarTracker::ID::TRACKING): { - *foundId = StarTracker::TRACKING; - break; + *foundId = StarTracker::TRACKING; + break; } case (StarTracker::ID::VALIDATION): { - *foundId = StarTracker::VALIDATION; - break; + *foundId = StarTracker::VALIDATION; + break; } case (StarTracker::ID::ALGO): { - *foundId = StarTracker::ALGO; - break; + *foundId = StarTracker::ALGO; + break; } default: - sif::debug << "StarTrackerHandler::scanForParameterReply: Unknown parameter reply id" - << std::endl; - return RETURN_FAILED; - } - return RETURN_OK; + sif::debug << "StarTrackerHandler::scanForParameterReply: Unknown parameter reply id" + << std::endl; + return RETURN_FAILED; + } + return RETURN_OK; } -ReturnValue_t StarTrackerHandler::scanForTmReply(DeviceCommandId_t *foundId) { - const uint8_t* reply = dataLinkLayer.getReply(); - switch (*reply) { - case (StarTracker::ID::VERSION): { - *foundId = StarTracker::REQ_VERSION; - break; - } - case (StarTracker::ID::INTERFACE): { - *foundId = StarTracker::REQ_INTERFACE; - break; - } - case (StarTracker::ID::POWER): { - *foundId = StarTracker::REQ_POWER; - break; - } - case (StarTracker::ID::TEMPERATURE): { - *foundId = StarTracker::REQ_TEMPERATURE; - break; - } - case (StarTracker::ID::HISTOGRAM): { - *foundId = StarTracker::REQ_HISTOGRAM; - break; - } - case (StarTracker::ID::CONTRAST): { - *foundId = StarTracker::REQ_CONTRAST; - break; - } - case (StarTracker::ID::TIME): { - *foundId = StarTracker::REQ_TIME; - break; - } - case (StarTracker::ID::SOLUTION): { - *foundId = StarTracker::REQ_SOLUTION; - break; - } - default: { - sif::debug << "StarTrackerHandler::scanForTmReply: Reply contains invalid reply id" - << std::endl; - return RETURN_FAILED; - break; - } +ReturnValue_t StarTrackerHandler::scanForTmReply(DeviceCommandId_t* foundId) { + const uint8_t* reply = dataLinkLayer.getReply(); + switch (*reply) { + case (StarTracker::ID::VERSION): { + *foundId = StarTracker::REQ_VERSION; + break; } - return RETURN_OK; + case (StarTracker::ID::INTERFACE): { + *foundId = StarTracker::REQ_INTERFACE; + break; + } + case (StarTracker::ID::POWER): { + *foundId = StarTracker::REQ_POWER; + break; + } + case (StarTracker::ID::TEMPERATURE): { + *foundId = StarTracker::REQ_TEMPERATURE; + break; + } + case (StarTracker::ID::HISTOGRAM): { + *foundId = StarTracker::REQ_HISTOGRAM; + break; + } + case (StarTracker::ID::CONTRAST): { + *foundId = StarTracker::REQ_CONTRAST; + break; + } + case (StarTracker::ID::TIME): { + *foundId = StarTracker::REQ_TIME; + break; + } + case (StarTracker::ID::SOLUTION): { + *foundId = StarTracker::REQ_SOLUTION; + break; + } + default: { + sif::debug << "StarTrackerHandler::scanForTmReply: Reply contains invalid reply id" + << std::endl; + return RETURN_FAILED; + break; + } + } + return RETURN_OK; } void StarTrackerHandler::handleEvent(EventMessage* eventMessage) { - object_id_t objectId = eventMessage->getReporter(); - switch(objectId){ + object_id_t objectId = eventMessage->getReporter(); + switch (objectId) { case objects::STR_HELPER: { - // All events from image loader signal either that the operation was successful or that it - // failed - strHelperExecuting = false; - break; + // All events from image loader signal either that the operation was successful or that it + // failed + strHelperExecuting = false; + break; } default: - sif::debug << "StarTrackerHandler::handleEvent: Did not subscribe to this event" - << std::endl; - break; - } + sif::debug << "StarTrackerHandler::handleEvent: Did not subscribe to this event" << std::endl; + break; + } } ReturnValue_t StarTrackerHandler::executeWriteCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - if (commandDataLen < WriteCmd::MIN_LENGTH) { - sif::warning << "StarTrackerHandler::executeWriteCommand: Command too short" << std::endl; - return COMMAND_TOO_SHORT; - } - uint8_t region = *(commandData); - uint32_t address; - size_t size = sizeof(address); - const uint8_t* addressPtr = commandData + WriteCmd::ADDRESS_OFFSET; - result = SerializeAdapter::deSerialize(&address, addressPtr, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of address failed" - << std::endl; - return result; - } - if (commandDataLen - sizeof(address) - sizeof(region) > MAX_PATH_SIZE) { - sif::warning << "StarTrackerHandler::executeWriteCommand: Received command with invalid" - << " path and filename" << std::endl; - return FILE_PATH_TOO_LONG; - } - const uint8_t* filePtr = commandData + WriteCmd::FILE_OFFSET; - std::string fullname = std::string(reinterpret_cast(filePtr), - commandDataLen - sizeof(address) - sizeof(region)); - result = strHelper->startFlashWrite(fullname, region, address); - if (result != RETURN_OK) { - return result; - } + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + if (commandDataLen < WriteCmd::MIN_LENGTH) { + sif::warning << "StarTrackerHandler::executeWriteCommand: Command too short" << std::endl; + return COMMAND_TOO_SHORT; + } + uint8_t region = *(commandData); + uint32_t address; + size_t size = sizeof(address); + const uint8_t* addressPtr = commandData + WriteCmd::ADDRESS_OFFSET; + result = SerializeAdapter::deSerialize(&address, addressPtr, &size, SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of address failed" + << std::endl; return result; + } + if (commandDataLen - sizeof(address) - sizeof(region) > MAX_PATH_SIZE) { + sif::warning << "StarTrackerHandler::executeWriteCommand: Received command with invalid" + << " path and filename" << std::endl; + return FILE_PATH_TOO_LONG; + } + const uint8_t* filePtr = commandData + WriteCmd::FILE_OFFSET; + std::string fullname = std::string(reinterpret_cast(filePtr), + commandDataLen - sizeof(address) - sizeof(region)); + result = strHelper->startFlashWrite(fullname, region, address); + if (result != RETURN_OK) { + return result; + } + return result; } ReturnValue_t StarTrackerHandler::executeFpgaDownloadCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - if (commandDataLen < FpgaDownloadCmd::MIN_LENGTH) { - sif::warning << "StarTrackerHandler::executeFpgaDownloadCommand: Command too short" - << std::endl; - return COMMAND_TOO_SHORT; - } - uint32_t position; - size_t size = sizeof(position); - result = SerializeAdapter::deSerialize(&position, &commandData, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of position failed" - << std::endl; - return result; - } - uint32_t length; - size = sizeof(length); - result = SerializeAdapter::deSerialize(&length, &commandData, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of length failed" - << std::endl; - return result; - } - if (commandDataLen - sizeof(position) - sizeof(length) > MAX_PATH_SIZE) { - sif::warning << "StarTrackerHandler::executeFpgaDownloadCommand: Received command with " - " invalid path and filename" << std::endl; - return FILE_PATH_TOO_LONG; - } - std::string fullname = std::string(reinterpret_cast(commandData), - commandDataLen - sizeof(position) - sizeof(length)); - result = strHelper->startFpgaDownload(fullname, position, length); - if (result != RETURN_OK) { - return result; - } + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + if (commandDataLen < FpgaDownloadCmd::MIN_LENGTH) { + sif::warning << "StarTrackerHandler::executeFpgaDownloadCommand: Command too short" + << std::endl; + return COMMAND_TOO_SHORT; + } + uint32_t position; + size_t size = sizeof(position); + result = + SerializeAdapter::deSerialize(&position, &commandData, &size, SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of position failed" + << std::endl; return result; + } + uint32_t length; + size = sizeof(length); + result = + SerializeAdapter::deSerialize(&length, &commandData, &size, SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of length failed" + << std::endl; + return result; + } + if (commandDataLen - sizeof(position) - sizeof(length) > MAX_PATH_SIZE) { + sif::warning << "StarTrackerHandler::executeFpgaDownloadCommand: Received command with " + " invalid path and filename" + << std::endl; + return FILE_PATH_TOO_LONG; + } + std::string fullname = std::string(reinterpret_cast(commandData), + commandDataLen - sizeof(position) - sizeof(length)); + result = strHelper->startFpgaDownload(fullname, position, length); + if (result != RETURN_OK) { + return result; + } + return result; } ReturnValue_t StarTrackerHandler::executeReadCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - if (commandDataLen < ReadCmd::MIN_LENGTH) { - sif::warning << "StarTrackerHandler::executeReadCommand: Command too short" << std::endl; - return COMMAND_TOO_SHORT; - } - uint8_t region = *(commandData); - uint32_t address; - size_t size = sizeof(address); - const uint8_t* addressPtr = commandData + ReadCmd::ADDRESS_OFFSET; - result = SerializeAdapter::deSerialize(&address, addressPtr, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::executeReadCommand: Deserialization of address failed" - << std::endl; - return result; - } - uint32_t length; - size = sizeof(length); - const uint8_t* lengthPtr = commandData + ReadCmd::LENGTH_OFFSET; - result = SerializeAdapter::deSerialize(&length, lengthPtr, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::executeReadCommand: Deserialization of length failed" - << std::endl; - return result; - } - if (commandDataLen - sizeof(address) - sizeof(region) - sizeof(length) > MAX_PATH_SIZE) { - sif::warning << "StarTrackerHandler::executeReadCommand: Received command with invalid" - << " path and filename" << std::endl; - return FILE_PATH_TOO_LONG; - } - const uint8_t* filePtr = commandData + ReadCmd::FILE_OFFSET; - std::string fullname = std::string(reinterpret_cast(filePtr), - commandDataLen - sizeof(address) - sizeof(region) - sizeof(length)); - result = strHelper->startFlashRead(fullname, region, address, length); - if (result != RETURN_OK) { - return result; - } + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + if (commandDataLen < ReadCmd::MIN_LENGTH) { + sif::warning << "StarTrackerHandler::executeReadCommand: Command too short" << std::endl; + return COMMAND_TOO_SHORT; + } + uint8_t region = *(commandData); + uint32_t address; + size_t size = sizeof(address); + const uint8_t* addressPtr = commandData + ReadCmd::ADDRESS_OFFSET; + result = SerializeAdapter::deSerialize(&address, addressPtr, &size, SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::executeReadCommand: Deserialization of address failed" + << std::endl; return result; + } + uint32_t length; + size = sizeof(length); + const uint8_t* lengthPtr = commandData + ReadCmd::LENGTH_OFFSET; + result = SerializeAdapter::deSerialize(&length, lengthPtr, &size, SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::executeReadCommand: Deserialization of length failed" + << std::endl; + return result; + } + if (commandDataLen - sizeof(address) - sizeof(region) - sizeof(length) > MAX_PATH_SIZE) { + sif::warning << "StarTrackerHandler::executeReadCommand: Received command with invalid" + << " path and filename" << std::endl; + return FILE_PATH_TOO_LONG; + } + const uint8_t* filePtr = commandData + ReadCmd::FILE_OFFSET; + std::string fullname = + std::string(reinterpret_cast(filePtr), + commandDataLen - sizeof(address) - sizeof(region) - sizeof(length)); + result = strHelper->startFlashRead(fullname, region, address, length); + if (result != RETURN_OK) { + return result; + } + return result; } void StarTrackerHandler::prepareBootCommand() { - uint32_t length = 0; - struct BootActionRequest bootRequest = {BOOT_REGION_ID}; - arc_pack_boot_action_req(&bootRequest, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + struct BootActionRequest bootRequest = {BOOT_REGION_ID}; + arc_pack_boot_action_req(&bootRequest, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } ReturnValue_t StarTrackerHandler::prepareEraseCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - if (commandDataLen != EraseCmd::LENGTH) { - return INVALID_LENGTH; - } - uint32_t length = 0; - struct EraseActionRequest req; - req.region = *commandData; - arc_pack_erase_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - eraseCmd.rememberRegion = req.region; - return result; + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + if (commandDataLen != EraseCmd::LENGTH) { + return INVALID_LENGTH; + } + uint32_t length = 0; + struct EraseActionRequest req; + req.region = *commandData; + arc_pack_erase_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + eraseCmd.rememberRegion = req.region; + return result; } ReturnValue_t StarTrackerHandler::prepareUnlockCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - uint32_t length = 0; - struct UnlockActionRequest req; - req.region = *commandData; - size_t size = sizeof(req.code); - const uint8_t* codePtr = commandData + UnlockCmd::CODE_OFFSET; - result = SerializeAdapter::deSerialize(&req.code, &codePtr, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - return result; - } - arc_pack_unlock_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + uint32_t length = 0; + struct UnlockActionRequest req; + req.region = *commandData; + size_t size = sizeof(req.code); + const uint8_t* codePtr = commandData + UnlockCmd::CODE_OFFSET; + result = SerializeAdapter::deSerialize(&req.code, &codePtr, &size, SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { return result; + } + arc_pack_unlock_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return result; } ReturnValue_t StarTrackerHandler::prepareChecksumCommand(const uint8_t* commandData, - size_t commandDataLen) { - struct ChecksumActionRequest req; - ReturnValue_t result = RETURN_OK; - if (commandDataLen != ChecksumCmd::LENGTH) { - sif::warning << "StarTrackerHandler::prepareChecksumCommand: Invalid length" << std::endl; - return INVALID_LENGTH; - } - req.region = *(commandData); - size_t size = sizeof(req.address); - const uint8_t* addressPtr = commandData + ChecksumCmd::ADDRESS_OFFSET; - result = SerializeAdapter::deSerialize(&req.address, addressPtr, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::prepareChecksumCommand: Deserialization of address " - << "failed" << std::endl; - return result; - } - size = sizeof(req.length); - const uint8_t* lengthPtr = commandData + ChecksumCmd::LENGTH_OFFSET; - result = SerializeAdapter::deSerialize(&req.length, lengthPtr, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::prepareChecksumCommand: Deserialization of length failed" - << std::endl; - return result; - } - uint32_t rawCmdLength = 0; - arc_pack_checksum_action_req(&req, commandBuffer, &rawCmdLength); - dataLinkLayer.encodeFrame(commandBuffer, rawCmdLength); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - checksumCmd.rememberRegion = req.region; - checksumCmd.rememberAddress = req.address; - checksumCmd.rememberLength = req.length; + size_t commandDataLen) { + struct ChecksumActionRequest req; + ReturnValue_t result = RETURN_OK; + if (commandDataLen != ChecksumCmd::LENGTH) { + sif::warning << "StarTrackerHandler::prepareChecksumCommand: Invalid length" << std::endl; + return INVALID_LENGTH; + } + req.region = *(commandData); + size_t size = sizeof(req.address); + const uint8_t* addressPtr = commandData + ChecksumCmd::ADDRESS_OFFSET; + result = + SerializeAdapter::deSerialize(&req.address, addressPtr, &size, SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::prepareChecksumCommand: Deserialization of address " + << "failed" << std::endl; return result; + } + size = sizeof(req.length); + const uint8_t* lengthPtr = commandData + ChecksumCmd::LENGTH_OFFSET; + result = + SerializeAdapter::deSerialize(&req.length, lengthPtr, &size, SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::prepareChecksumCommand: Deserialization of length failed" + << std::endl; + return result; + } + uint32_t rawCmdLength = 0; + arc_pack_checksum_action_req(&req, commandBuffer, &rawCmdLength); + dataLinkLayer.encodeFrame(commandBuffer, rawCmdLength); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + checksumCmd.rememberRegion = req.region; + checksumCmd.rememberAddress = req.address; + checksumCmd.rememberLength = req.length; + return result; } - ReturnValue_t StarTrackerHandler::prepareSetTimeCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - struct SetTimeActionRequest req; - if (commandDataLen != SetTimeCmd::LENGTH) { - sif::warning << "StarTrackerHandler::prepareSetTimeCommand: Invalid length" << std::endl; - return INVALID_LENGTH; - } - size_t size = sizeof(req.unixTime); - result = SerializeAdapter::deSerialize(&req.unixTime, commandData, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::prepareSetTimeCommand: Deserialization failed" - << std::endl; - return result; - } - uint32_t length = 0; - arc_pack_settime_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + struct SetTimeActionRequest req; + if (commandDataLen != SetTimeCmd::LENGTH) { + sif::warning << "StarTrackerHandler::prepareSetTimeCommand: Invalid length" << std::endl; + return INVALID_LENGTH; + } + size_t size = sizeof(req.unixTime); + result = SerializeAdapter::deSerialize(&req.unixTime, commandData, &size, + SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::prepareSetTimeCommand: Deserialization failed" << std::endl; return result; + } + uint32_t length = 0; + arc_pack_settime_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return result; } ReturnValue_t StarTrackerHandler::prepareDownloadCentroidCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - struct DownloadCentroidActionRequest req; - if (commandDataLen != DownloadCentroidCmd::LENGTH) { - sif::warning << "StarTrackerHandler::prepareDownloadCentroidCommand: Invalid length" - << std::endl; - return INVALID_LENGTH; - } - req.id = *commandData; - uint32_t length = 0; - arc_pack_downloadcentroid_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return result; + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + struct DownloadCentroidActionRequest req; + if (commandDataLen != DownloadCentroidCmd::LENGTH) { + sif::warning << "StarTrackerHandler::prepareDownloadCentroidCommand: Invalid length" + << std::endl; + return INVALID_LENGTH; + } + req.id = *commandData; + uint32_t length = 0; + arc_pack_downloadcentroid_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return result; } ReturnValue_t StarTrackerHandler::prepareUploadCentroidCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen > MAX_PATH_SIZE) { - return FILE_PATH_TOO_LONG; - } - ReturnValue_t result = RETURN_OK; - struct UploadCentroidActionRequest req; - std::string jsonFileName = std::string(reinterpret_cast(commandData), - commandDataLen); - NVMParameterBase j(jsonFileName); - result = j.readJsonFile(); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: " << jsonFileName - << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::id, &req.id); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::id << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::pixx, &req.pixx); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::pixx << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::pixy, &req.pixy); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::pixy << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::x_uncorrected, &req.x_uncorrected); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::x_uncorrected << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::y_uncorrected, &req.y_uncorrected); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::y_uncorrected << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::x_corrected, &req.x_corrected); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::x_corrected << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::y_corrected, &req.y_corrected); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::y_corrected << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::magnitude, &req.magnitude); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::magnitude << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::cxa, &req.cxa); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::cxa << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::cya, &req.cya); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::cya << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::quality, &req.quality); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::quality << " does not exist" << std::endl; - return result; - } - uint32_t length = 0; - arc_pack_uploadcentroid_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - uploadCentroid.rememberId = req.id; + size_t commandDataLen) { + if (commandDataLen > MAX_PATH_SIZE) { + return FILE_PATH_TOO_LONG; + } + ReturnValue_t result = RETURN_OK; + struct UploadCentroidActionRequest req; + std::string jsonFileName = + std::string(reinterpret_cast(commandData), commandDataLen); + NVMParameterBase j(jsonFileName); + result = j.readJsonFile(); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: " << jsonFileName + << " does not exist" << std::endl; return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::id, &req.id); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::id << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::pixx, &req.pixx); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::pixx << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::pixy, &req.pixy); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::pixy << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::x_uncorrected, &req.x_uncorrected); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::x_uncorrected << " does not exist" + << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::y_uncorrected, &req.y_uncorrected); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::y_uncorrected << " does not exist" + << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::x_corrected, &req.x_corrected); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::x_corrected << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::y_corrected, &req.y_corrected); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::y_corrected << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::magnitude, &req.magnitude); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::magnitude << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::cxa, &req.cxa); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::cxa << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::cya, &req.cya); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::cya << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::quality, &req.quality); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::quality << " does not exist" << std::endl; + return result; + } + uint32_t length = 0; + arc_pack_uploadcentroid_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + uploadCentroid.rememberId = req.id; + return result; } void StarTrackerHandler::prepareTimeRequest() { - uint32_t length = 0; - arc_tm_pack_time_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_time_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::preparePingRequest() { - uint32_t length = 0; - struct PingActionRequest pingRequest = {PING_ID}; - arc_pack_ping_action_req(&pingRequest, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + struct PingActionRequest pingRequest = {PING_ID}; + arc_pack_ping_action_req(&pingRequest, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareVersionRequest() { - uint32_t length = 0; - arc_tm_pack_version_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_version_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareInterfaceRequest() { - uint32_t length = 0; - arc_tm_pack_interface_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_interface_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::preparePowerRequest() { - uint32_t length = 0; - arc_tm_pack_power_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_power_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareRebootCommand() { - uint32_t length = 0; - struct RebootActionRequest rebootReq; - arc_pack_reboot_action_req(&rebootReq, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + struct RebootActionRequest rebootReq; + arc_pack_reboot_action_req(&rebootReq, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareTakeImageCommand(const uint8_t* commandData) { - uint32_t length = 0; - struct CameraActionRequest camReq; - camReq.actionid = *commandData; - arc_pack_camera_action_req(&camReq, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + struct CameraActionRequest camReq; + camReq.actionid = *commandData; + arc_pack_camera_action_req(&camReq, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareSubscriptionCommand(const uint8_t* tmId) { - uint32_t length = 18; - commandBuffer[0] = TMTC_SETPARAMREQ; - commandBuffer[1] = StarTracker::ID::SUBSCRIBE; - // Fill all other fields with invalid tm id - commandBuffer[2] = *tmId; - commandBuffer[3] = 0; - commandBuffer[4] = 0; - commandBuffer[5] = 0; - commandBuffer[6] = 0; - commandBuffer[7] = 0; - commandBuffer[8] = 0; - commandBuffer[9] = 0; - commandBuffer[10] = 0; - commandBuffer[11] = 0; - commandBuffer[12] = 0; - commandBuffer[13] = 0; - commandBuffer[14] = 0; - commandBuffer[15] = 0; - commandBuffer[16] = 0; - commandBuffer[17] = 0; - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 18; + commandBuffer[0] = TMTC_SETPARAMREQ; + commandBuffer[1] = StarTracker::ID::SUBSCRIBE; + // Fill all other fields with invalid tm id + commandBuffer[2] = *tmId; + commandBuffer[3] = 0; + commandBuffer[4] = 0; + commandBuffer[5] = 0; + commandBuffer[6] = 0; + commandBuffer[7] = 0; + commandBuffer[8] = 0; + commandBuffer[9] = 0; + commandBuffer[10] = 0; + commandBuffer[11] = 0; + commandBuffer[12] = 0; + commandBuffer[13] = 0; + commandBuffer[14] = 0; + commandBuffer[15] = 0; + commandBuffer[16] = 0; + commandBuffer[17] = 0; + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareSolutionRequest() { - uint32_t length = 0; - arc_tm_pack_solution_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_solution_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareTemperatureRequest() { - uint32_t length = 0; - arc_tm_pack_temperature_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_temperature_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareHistogramRequest() { - uint32_t length = 0; - arc_tm_pack_histogram_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_histogram_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareContrastRequest() { - uint32_t length = 0; - arc_tm_pack_contrast_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_contrast_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareErrorResetRequest() { - uint32_t length = 0; - struct ResetErrorSignalActionRequest req; - arc_pack_reseterrorsignal_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + struct ResetErrorSignalActionRequest req; + arc_pack_reseterrorsignal_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } ReturnValue_t StarTrackerHandler::prepareParamCommand(const uint8_t* commandData, - size_t commandDataLen, ArcsecJsonParamBase& paramSet) { - ReturnValue_t result = RETURN_OK; - if (commandDataLen > MAX_PATH_SIZE) { - return FILE_PATH_TOO_LONG; - } - std::string fullName(reinterpret_cast(commandData), commandDataLen); + size_t commandDataLen, + ArcsecJsonParamBase& paramSet) { + ReturnValue_t result = RETURN_OK; + if (commandDataLen > MAX_PATH_SIZE) { + return FILE_PATH_TOO_LONG; + } + std::string fullName(reinterpret_cast(commandData), commandDataLen); - result = paramSet.create(fullName, commandBuffer); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareParamCommand: Failed to create parameter " - "command" << std::endl; - return result; - } - dataLinkLayer.encodeFrame(commandBuffer, paramSet.getSize()); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; + result = paramSet.create(fullName, commandBuffer); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareParamCommand: Failed to create parameter " + "command" + << std::endl; + return result; + } + dataLinkLayer.encodeFrame(commandBuffer, paramSet.getSize()); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; } ReturnValue_t StarTrackerHandler::prepareDownloadMatchedStarCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen != DownloadMatchedStarCmd::LENGTH) { - return INVALID_LENGTH; - } - struct DownloadMatchedStarActionRequest req; - req.id = *commandData; - uint32_t length = 0; - arc_pack_downloadmatchedstar_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; + size_t commandDataLen) { + if (commandDataLen != DownloadMatchedStarCmd::LENGTH) { + return INVALID_LENGTH; + } + struct DownloadMatchedStarActionRequest req; + req.id = *commandData; + uint32_t length = 0; + arc_pack_downloadmatchedstar_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; } ReturnValue_t StarTrackerHandler::prepareDownloadDbImageCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen != DownloadDbImageCmd::LENGTH) { - return INVALID_LENGTH; - } - struct DownloadDBImageActionRequest req; - req.id = *commandData; - uint32_t length = 0; - arc_pack_downloaddbimage_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; + size_t commandDataLen) { + if (commandDataLen != DownloadDbImageCmd::LENGTH) { + return INVALID_LENGTH; + } + struct DownloadDBImageActionRequest req; + req.id = *commandData; + uint32_t length = 0; + arc_pack_downloaddbimage_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; } ReturnValue_t StarTrackerHandler::prepareDownloadBlobPixelCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen != DownloadBlobPixCmd::LENGTH) { - return INVALID_LENGTH; - } - struct DownloadBlobPixelActionRequest req; - req.id = *commandData; - req.type = *(commandData + 1); - if ((req.type != DownloadBlobPixCmd::NORMAL) && (req.type != DownloadBlobPixCmd::FAST)) { - return INVALID_TYPE; - } - uint32_t length = 0; - arc_pack_downloadblobpixel_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; + size_t commandDataLen) { + if (commandDataLen != DownloadBlobPixCmd::LENGTH) { + return INVALID_LENGTH; + } + struct DownloadBlobPixelActionRequest req; + req.id = *commandData; + req.type = *(commandData + 1); + if ((req.type != DownloadBlobPixCmd::NORMAL) && (req.type != DownloadBlobPixCmd::FAST)) { + return INVALID_TYPE; + } + uint32_t length = 0; + arc_pack_downloadblobpixel_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; } ReturnValue_t StarTrackerHandler::prepareFpgaActionCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen != FpgaActionCmd::LENGTH) { - return INVALID_LENGTH; - } - struct FPGAActionActionRequest req; - req.id = *commandData; - if (req.id != FpgaActionCmd::ID) { - return INVALID_ID; - } - uint32_t length = 0; - arc_pack_fpgaaction_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; + size_t commandDataLen) { + if (commandDataLen != FpgaActionCmd::LENGTH) { + return INVALID_LENGTH; + } + struct FPGAActionActionRequest req; + req.id = *commandData; + if (req.id != FpgaActionCmd::ID) { + return INVALID_ID; + } + uint32_t length = 0; + arc_pack_fpgaaction_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; } ReturnValue_t StarTrackerHandler::handleSetParamReply() { - const uint8_t* reply = dataLinkLayer.getReply(); - uint8_t status = *(reply + STATUS_OFFSET); - if (status != StarTracker::STATUS_OK) { - sif::warning << "StarTrackerHandler::handleSetParamReply: Failed to execute parameter set " - " command with parameter ID" << - static_cast(*(reply + PARAMETER_ID_OFFSET)) << std::endl; - if (startupState != StartupState::IDLE) { - startupState = StartupState::IDLE; - } - return SET_PARAM_FAILED; - } + const uint8_t* reply = dataLinkLayer.getReply(); + uint8_t status = *(reply + STATUS_OFFSET); + if (status != StarTracker::STATUS_OK) { + sif::warning << "StarTrackerHandler::handleSetParamReply: Failed to execute parameter set " + " command with parameter ID" + << static_cast(*(reply + PARAMETER_ID_OFFSET)) << std::endl; if (startupState != StartupState::IDLE) { - handleStartup(reply + PARAMETER_ID_OFFSET); + startupState = StartupState::IDLE; } - return RETURN_OK; + return SET_PARAM_FAILED; + } + if (startupState != StartupState::IDLE) { + handleStartup(reply + PARAMETER_ID_OFFSET); + } + return RETURN_OK; } ReturnValue_t StarTrackerHandler::handleActionReply() { - const uint8_t* reply = dataLinkLayer.getReply(); - uint8_t status = *(reply + STATUS_OFFSET); - if (status != StarTracker::STATUS_OK) { - sif::warning << "StarTrackerHandler::handleActionReply: Failed to execute action " - << "command with action ID " - << static_cast(*(reply + ACTION_ID_OFFSET)) - << " and status "<< static_cast(status) << std::endl; - return ACTION_FAILED; - } - return RETURN_OK; + const uint8_t* reply = dataLinkLayer.getReply(); + uint8_t status = *(reply + STATUS_OFFSET); + if (status != StarTracker::STATUS_OK) { + sif::warning << "StarTrackerHandler::handleActionReply: Failed to execute action " + << "command with action ID " + << static_cast(*(reply + ACTION_ID_OFFSET)) << " and status " + << static_cast(status) << std::endl; + return ACTION_FAILED; + } + return RETURN_OK; } ReturnValue_t StarTrackerHandler::handleUploadCentroidReply() { - ReturnValue_t result = RETURN_OK; - result = handleActionReply(); - if (result != RETURN_OK) { - return result; - } - const uint8_t* reply = dataLinkLayer.getReply(); - if (*(reply + ACTION_DATA_OFFSET) != uploadCentroid.rememberId) { - return UPLOAD_CENTROID_ID_MISMATCH; - } - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + result = handleActionReply(); + if (result != RETURN_OK) { + return result; + } + const uint8_t* reply = dataLinkLayer.getReply(); + if (*(reply + ACTION_DATA_OFFSET) != uploadCentroid.rememberId) { + return UPLOAD_CENTROID_ID_MISMATCH; + } + return RETURN_OK; } ReturnValue_t StarTrackerHandler::handleEraseReply() { - ReturnValue_t result = RETURN_OK; - result = handleActionReply(); - if (result != RETURN_OK) { - return result; - } - const uint8_t* replyData = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; - StarTracker::EraseReply eraseReply(replyData); - if (eraseReply.getRegion() != eraseCmd.rememberRegion) { - sif::warning << "StarTrackerHandler::handleEraseReply: Region mismatch" << std::endl; - return REGION_MISMATCH; - } + ReturnValue_t result = RETURN_OK; + result = handleActionReply(); + if (result != RETURN_OK) { return result; + } + const uint8_t* replyData = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; + StarTracker::EraseReply eraseReply(replyData); + if (eraseReply.getRegion() != eraseCmd.rememberRegion) { + sif::warning << "StarTrackerHandler::handleEraseReply: Region mismatch" << std::endl; + return REGION_MISMATCH; + } + return result; } ReturnValue_t StarTrackerHandler::handleChecksumReply() { - ReturnValue_t result = RETURN_OK; - result = handleActionReply(); - if (result != RETURN_OK) { - return result; - } - const uint8_t* replyData = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; - StarTracker::ChecksumReply checksumReply(replyData); - if (checksumReply.getRegion() != checksumCmd.rememberRegion) { - sif::warning << "StarTrackerHandler::handleChecksumReply: Region mismatch" << std::endl; - return REGION_MISMATCH; - } - if (checksumReply.getAddress() != checksumCmd.rememberAddress) { - sif::warning << "StarTrackerHandler::handleChecksumReply: Address mismatch" << std::endl; - return ADDRESS_MISMATCH; - } - if (checksumReply.getLength() != checksumCmd.rememberLength) { - sif::warning << "StarTrackerHandler::handleChecksumReply: Length mismatch" << std::endl; - return LENGTH_MISSMATCH; - } - PoolReadGuard rg(&checksumSet); - checksumSet.checksum = checksumReply.getChecksum(); - handleDeviceTM(&checksumSet, StarTracker::CHECKSUM); + ReturnValue_t result = RETURN_OK; + result = handleActionReply(); + if (result != RETURN_OK) { + return result; + } + const uint8_t* replyData = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; + StarTracker::ChecksumReply checksumReply(replyData); + if (checksumReply.getRegion() != checksumCmd.rememberRegion) { + sif::warning << "StarTrackerHandler::handleChecksumReply: Region mismatch" << std::endl; + return REGION_MISMATCH; + } + if (checksumReply.getAddress() != checksumCmd.rememberAddress) { + sif::warning << "StarTrackerHandler::handleChecksumReply: Address mismatch" << std::endl; + return ADDRESS_MISMATCH; + } + if (checksumReply.getLength() != checksumCmd.rememberLength) { + sif::warning << "StarTrackerHandler::handleChecksumReply: Length mismatch" << std::endl; + return LENGTH_MISSMATCH; + } + PoolReadGuard rg(&checksumSet); + checksumSet.checksum = checksumReply.getChecksum(); + handleDeviceTM(&checksumSet, StarTracker::CHECKSUM); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - checksumReply.printChecksum(); + checksumReply.printChecksum(); #endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ - return RETURN_OK; + return RETURN_OK; } ReturnValue_t StarTrackerHandler::handlePingReply() { - ReturnValue_t result = RETURN_OK; - uint32_t pingId = 0; - const uint8_t* reply = dataLinkLayer.getReply(); - uint8_t status = dataLinkLayer.getStatusField(); - const uint8_t* buffer = reply + ACTION_DATA_OFFSET; - size_t size = sizeof(pingId); - SerializeAdapter::deSerialize(&pingId, &buffer, &size, SerializeIF::Endianness::LITTLE); + ReturnValue_t result = RETURN_OK; + uint32_t pingId = 0; + const uint8_t* reply = dataLinkLayer.getReply(); + uint8_t status = dataLinkLayer.getStatusField(); + const uint8_t* buffer = reply + ACTION_DATA_OFFSET; + size_t size = sizeof(pingId); + SerializeAdapter::deSerialize(&pingId, &buffer, &size, SerializeIF::Endianness::LITTLE); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - sif::info << "StarTracker: Ping status: "<< static_cast(status) << std::endl; - sif::info << "Ping id: 0x"<< std::hex << pingId << std::endl; + sif::info << "StarTracker: Ping status: " << static_cast(status) << std::endl; + sif::info << "Ping id: 0x" << std::hex << pingId << std::endl; #endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ - if (status != StarTracker::STATUS_OK || pingId != PING_ID) { - sif::warning << "StarTrackerHandler::handlePingReply: Ping failed" << std::endl; - result = PING_FAILED; - } - else { + if (status != StarTracker::STATUS_OK || pingId != PING_ID) { + sif::warning << "StarTrackerHandler::handlePingReply: Ping failed" << std::endl; + result = PING_FAILED; + } else { #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - sif::info << "StarTracker: Ping successful" << std::endl; + sif::info << "StarTracker: Ping successful" << std::endl; #endif - } - return result; + } + return result; } ReturnValue_t StarTrackerHandler::checkProgram() { - PoolReadGuard pg(&versionSet); - switch(versionSet.program.value) { + PoolReadGuard pg(&versionSet); + switch (versionSet.program.value) { case StarTracker::Program::BOOTLOADER: - // Star tracker currently in bootloader program. Need to send boot command to switch to - // firmware program - if (startupState != StartupState::IDLE) { - startupState = StartupState::BOOT; - } - break; + // Star tracker currently in bootloader program. Need to send boot command to switch to + // firmware program + if (startupState != StartupState::IDLE) { + startupState = StartupState::BOOT; + } + break; case StarTracker::Program::FIRMWARE: - // Firmware already booted - if (startupState != StartupState::IDLE) { - startupState = StartupState::LIMITS; - } - break; + // Firmware already booted + if (startupState != StartupState::IDLE) { + startupState = StartupState::LIMITS; + } + break; default: - sif::warning << "StarTrackerHandler::checkProgram: Version set has invalid program ID" - << std::endl; - return INVALID_PROGRAM; - } - return RETURN_OK; + sif::warning << "StarTrackerHandler::checkProgram: Version set has invalid program ID" + << std::endl; + return INVALID_PROGRAM; + } + return RETURN_OK; } ReturnValue_t StarTrackerHandler::handleTm(LocalPoolDataSetBase& dataset, size_t size) { - ReturnValue_t result = RETURN_OK; - uint8_t status = *(dataLinkLayer.getReply() + STATUS_OFFSET); - if(status != StarTracker::STATUS_OK) { - sif::warning << "StarTrackerHandler::handleTm: Reply error: " - << static_cast(status) << std::endl; - return REPLY_ERROR; - } - result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } - const uint8_t* reply = dataLinkLayer.getReply() + TICKS_OFFSET; - dataset.setValidityBufferGeneration(false); - result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::handleTm: Deserialization failed" - << std::endl; - } - dataset.setValidityBufferGeneration(true); - dataset.setValidity(true, true); - result = dataset.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - dataset.printSet(); -#endif + ReturnValue_t result = RETURN_OK; + uint8_t status = *(dataLinkLayer.getReply() + STATUS_OFFSET); + if (status != StarTracker::STATUS_OK) { + sif::warning << "StarTrackerHandler::handleTm: Reply error: " + << static_cast(status) << std::endl; + return REPLY_ERROR; + } + result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { return result; + } + const uint8_t* reply = dataLinkLayer.getReply() + TICKS_OFFSET; + dataset.setValidityBufferGeneration(false); + result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::handleTm: Deserialization failed" << std::endl; + } + dataset.setValidityBufferGeneration(true); + dataset.setValidity(true, true); + result = dataset.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { + return result; + } +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 + dataset.printSet(); +#endif + return result; } ReturnValue_t StarTrackerHandler::handleActionReplySet(LocalPoolDataSetBase& dataset, size_t size) { - ReturnValue_t result = RETURN_OK; - uint8_t status = *(dataLinkLayer.getReply() + STATUS_OFFSET); - if(status != StarTracker::STATUS_OK) { - sif::warning << "StarTrackerHandler::handleActionReplySet: Reply error: " - << static_cast(status) << std::endl; - return REPLY_ERROR; - } - result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } - const uint8_t* reply = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; - dataset.setValidityBufferGeneration(false); - result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::handleActionReplySet Deserialization failed" - << std::endl; - } - dataset.setValidityBufferGeneration(true); - dataset.setValidity(true, true); - result = dataset.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - dataset.printSet(); -#endif + ReturnValue_t result = RETURN_OK; + uint8_t status = *(dataLinkLayer.getReply() + STATUS_OFFSET); + if (status != StarTracker::STATUS_OK) { + sif::warning << "StarTrackerHandler::handleActionReplySet: Reply error: " + << static_cast(status) << std::endl; + return REPLY_ERROR; + } + result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { return result; + } + const uint8_t* reply = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; + dataset.setValidityBufferGeneration(false); + result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::handleActionReplySet Deserialization failed" << std::endl; + } + dataset.setValidityBufferGeneration(true); + dataset.setValidity(true, true); + result = dataset.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { + return result; + } +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 + dataset.printSet(); +#endif + return result; } void StarTrackerHandler::handleStartup(const uint8_t* parameterId) { - switch(*parameterId) { + switch (*parameterId) { case (StarTracker::ID::LIMITS): { - startupState = StartupState::TRACKING; - break; + startupState = StartupState::TRACKING; + break; } case (StarTracker::ID::TRACKING): { - startupState = StartupState::MOUNTING; - break; + startupState = StartupState::MOUNTING; + break; } case (StarTracker::ID::MOUNTING): { - startupState = StartupState::CAMERA; - break; + startupState = StartupState::CAMERA; + break; } case (StarTracker::ID::CAMERA): { - startupState = StartupState::BLOB; - break; + startupState = StartupState::BLOB; + break; } case (StarTracker::ID::BLOB): { - startupState = StartupState::CENTROIDING; - break; + startupState = StartupState::CENTROIDING; + break; } case (StarTracker::ID::CENTROIDING): { - startupState = StartupState::LISA; - break; + startupState = StartupState::LISA; + break; } case (StarTracker::ID::LISA): { - startupState = StartupState::MATCHING; - break; + startupState = StartupState::MATCHING; + break; } case (StarTracker::ID::MATCHING): { - startupState = StartupState::VALIDATION; - break; + startupState = StartupState::VALIDATION; + break; } case (StarTracker::ID::VALIDATION): { - startupState = StartupState::ALGO; - break; + startupState = StartupState::ALGO; + break; } case (StarTracker::ID::ALGO): { - startupState = StartupState::DONE; - break; + startupState = StartupState::DONE; + break; } default: { - sif::debug << "StarTrackerHandler::handleStartup: Received parameter reply with unexpected" - << " parameter ID" << std::endl; - break; - } + sif::debug << "StarTrackerHandler::handleStartup: Received parameter reply with unexpected" + << " parameter ID" << std::endl; + break; } + } } diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.h b/bsp_q7s/devices/startracker/StarTrackerHandler.h index 65bd65b8..1d7efeb3 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.h +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.h @@ -1,15 +1,16 @@ #ifndef MISSION_DEVICES_STARTRACKERHANDLER_H_ #define MISSION_DEVICES_STARTRACKERHANDLER_H_ +#include + +#include "ArcsecDatalinkLayer.h" +#include "ArcsecJsonParamBase.h" +#include "StarTrackerDefinitions.h" +#include "StrHelper.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" #include "fsfw/src/fsfw/serialize/SerializeAdapter.h" #include "fsfw/timemanager/Countdown.h" #include "thirdparty/arcsec_star_tracker/common/SLIP.h" -#include -#include "ArcsecDatalinkLayer.h" -#include "StarTrackerDefinitions.h" -#include "ArcsecJsonParamBase.h" -#include "StrHelper.h" /** * @brief This is the device handler for the star tracker from arcsec. @@ -19,530 +20,524 @@ * Sagitta%201.0%20Datapack&fileid=659181 * @author J. Meier */ -class StarTrackerHandler: public DeviceHandlerBase { -public: - - /** - * @brief Constructor - * - * @param objectId - * @param comIF - * @param comCookie - * @param gpioComIF Pointer to gpio communication interface - * @param enablePin GPIO connected to the enable pin of the reaction wheels. Must be pulled - * to high to enable the device. - */ - StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie, - StrHelper* strHelper); - virtual ~StarTrackerHandler(); - - ReturnValue_t initialize() override; - - /** - * @brief Overwrite this function from DHB to handle commands executed by the str image - * loader task. - */ - ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size) override; - - void performOperationHook() override; - -protected: - void doStartUp() override; - void doShutDown() override; - void doOffActivity() 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; - /** - * @brief Overwritten here to always read all available data from the UartComIF. - */ - virtual size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override; - virtual ReturnValue_t doSendReadHook() override; - -private: - - static const uint8_t INTERFACE_ID = CLASS_ID::STR_HANDLER; - - //! [EXPORT] : [COMMENT] Received reply is too short - static const ReturnValue_t REPLY_TOO_SHORT = MAKE_RETURN_CODE(0xB0); - //! [EXPORT] : [COMMENT] Received reply with invalid CRC - static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xB1); - //! [EXPORT] : [COMMENT] Image loader executing - static const ReturnValue_t IMAGE_LOADER_EXECUTING = MAKE_RETURN_CODE(0xB2); - - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_HANDLER; - - //! [EXPORT] : [COMMENT] Status in temperature reply signals error - static const ReturnValue_t TEMPERATURE_REQ_FAILED = MAKE_RETURN_CODE(0xA0); - //! [EXPORT] : [COMMENT] Ping command failed - static const ReturnValue_t PING_FAILED = MAKE_RETURN_CODE(0xA1); - //! [EXPORT] : [COMMENT] Status in version reply signals error - static const ReturnValue_t VERSION_REQ_FAILED = MAKE_RETURN_CODE(0xA3); - //! [EXPORT] : [COMMENT] Status in interface reply signals error - static const ReturnValue_t INTERFACE_REQ_FAILED = MAKE_RETURN_CODE(0xA4); - //! [EXPORT] : [COMMENT] Status in power reply signals error - static const ReturnValue_t POWER_REQ_FAILED = MAKE_RETURN_CODE(0xA5); - //! [EXPORT] : [COMMENT] Status of reply to parameter set command signals error - static const ReturnValue_t SET_PARAM_FAILED = MAKE_RETURN_CODE(0xA6); - //! [EXPORT] : [COMMENT] Status of reply to action command signals error - static const ReturnValue_t ACTION_FAILED = MAKE_RETURN_CODE(0xA7); - //! [EXPORT] : [COMMENT] Received upload image command with invalid length - static const ReturnValue_t UPLOAD_TOO_SHORT = MAKE_RETURN_CODE(0xA8); - //! [EXPORT] : [COMMENT] Received upload image command with invalid position field - static const ReturnValue_t UPLOAD_INVALID_POSITION = MAKE_RETURN_CODE(0xA8); - //! [EXPORT] : [COMMENT] Position value in upload image reply not matching sent position - static const ReturnValue_t UPLOAD_IMAGE_FAILED = MAKE_RETURN_CODE(0xA9); - //! [EXPORT] : [COMMENT] Received upload image command with invalid length - static const ReturnValue_t INVALID_UPLOAD_COMMAND = MAKE_RETURN_CODE(0xAA); - //! [EXPORT] : [COMMENT] Received invalid path string. Exceeds allowed length - static const ReturnValue_t FILE_PATH_TOO_LONG = MAKE_RETURN_CODE(0xAB); - //! [EXPORT] : [COMMENT] Name of file received with command is too long - static const ReturnValue_t FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xAC); - //! [EXPORT] : [COMMENT] Received version reply with invalid program ID - static const ReturnValue_t INVALID_PROGRAM = MAKE_RETURN_CODE(0xAD); - //! [EXPORT] : [COMMENT] Status field reply signals error - static const ReturnValue_t REPLY_ERROR = MAKE_RETURN_CODE(0xAE); - //! [EXPORT] : [COMMENT] Status field of contrast reply signals error - static const ReturnValue_t CONTRAST_REQ_FAILED = MAKE_RETURN_CODE(0xAE); - //! [EXPORT] : [COMMENT] Received command which is too short (some data is missing for proper execution) - static const ReturnValue_t COMMAND_TOO_SHORT = MAKE_RETURN_CODE(0xAF); - //! [EXPORT] : [COMMENT] Received command with invalid length (too few or too many parameters) - static const ReturnValue_t INVALID_LENGTH = MAKE_RETURN_CODE(0xB0); - //! [EXPORT] : [COMMENT] Region mismatch between send and received data - static const ReturnValue_t REGION_MISMATCH = MAKE_RETURN_CODE(0xB1); - //! [EXPORT] : [COMMENT] Address mismatch between send and received data - static const ReturnValue_t ADDRESS_MISMATCH = MAKE_RETURN_CODE(0xB2); - //! [EXPORT] : [COMMENT] Length field mismatch between send and received data - static const ReturnValue_t lENGTH_MISMATCH = MAKE_RETURN_CODE(0xB3); - //! [EXPORT] : [COMMENT] Specified file does not exist - static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xB4); - //! [EXPORT] : [COMMENT] Reply to upload centroid does not match commanded centroid id - static const ReturnValue_t UPLOAD_CENTROID_ID_MISMATCH = MAKE_RETURN_CODE(0xB5); - //! [EXPORT] : [COMMENT] Download blob pixel command has invalid type field - static const ReturnValue_t INVALID_TYPE = MAKE_RETURN_CODE(0xB6); - //! [EXPORT] : [COMMENT] Received FPGA action command with invalid ID - static const ReturnValue_t INVALID_ID = MAKE_RETURN_CODE(0xB7); - - static const size_t MAX_PATH_SIZE = 50; - static const size_t MAX_FILE_NAME = 30; - - // position (uint32) + 1024 image data - static const size_t UPLOAD_COMMAND_LEN = 1028; - // Max valid position value in upload image command - static const uint16_t MAX_POSITION= 4095; - static const uint8_t STATUS_OFFSET = 1; - static const uint8_t TICKS_OFFSET = 2; - static const uint8_t TIME_OFFSET = 6; - static const uint8_t TM_DATA_FIELD_OFFSET = 14; - static const uint8_t PARAMETER_ID_OFFSET = 0; - static const uint8_t ACTION_ID_OFFSET = 0; - static const uint8_t ACTION_DATA_OFFSET = 2; - // Ping request will reply ping with this ID (data field) - static const uint32_t PING_ID = 0x55; - static const uint32_t BOOT_REGION_ID = 1; - static const MutexIF::TimeoutType TIMEOUT_TYPE = MutexIF::TimeoutType::WAITING; - static const uint32_t MUTEX_TIMEOUT = 20; - static const uint32_t BOOT_TIMEOUT = 1000; - - class WriteCmd { - public: - static const uint8_t ADDRESS_OFFSET = 1; - static const uint8_t FILE_OFFSET = 5; - // Minimum length of a write command (region, address and filename) - static const size_t MIN_LENGTH = 7; - }; - - class ReadCmd { - public: - static const uint8_t ADDRESS_OFFSET = 1; - static const uint8_t LENGTH_OFFSET = 5; - static const uint8_t FILE_OFFSET = 9; - // Minimum length of a read command (region, address, length and filename) - static const size_t MIN_LENGTH = 11; - }; - - class EraseCmd { - public: - static const uint8_t LENGTH = 1; - uint8_t rememberRegion = 0; - }; - - EraseCmd eraseCmd; - - class UnlockCmd { - public: - static const uint8_t CODE_OFFSET = 1; - }; - - class ChecksumCmd { - public: - static const uint8_t ADDRESS_OFFSET = 1; - static const uint8_t LENGTH_OFFSET = 5; - // Length of checksum command - static const size_t LENGTH = 9; - uint8_t rememberRegion = 0; - uint32_t rememberAddress = 0; - uint32_t rememberLength = 0; - }; - - ChecksumCmd checksumCmd; - - class SetTimeCmd { - public: - static const uint8_t LENGTH = 8; - }; - - class DownloadCentroidCmd { - public: - static const uint8_t LENGTH = 1; - }; - - class UploadCentroid { - public: - uint8_t rememberId = 0; - }; - - UploadCentroid uploadCentroid; - - class DownloadMatchedStarCmd { - public: - static const uint8_t LENGTH = 1; - }; - - class DownloadDbImageCmd { - public: - static const uint8_t LENGTH = 1; - }; - - class DownloadBlobPixCmd { - public: - static const uint8_t LENGTH = 2; - static const uint8_t NORMAL = 0; - static const uint8_t FAST = 1; - }; - - class FpgaDownloadCmd { - public: - static const uint8_t MIN_LENGTH = 10; - }; - - class FpgaActionCmd { - public: - static const uint8_t LENGTH = 1; - static const uint8_t ID = 3; - }; - - MessageQueueIF* eventQueue = nullptr; - - ArcsecDatalinkLayer dataLinkLayer; - - StarTracker::TemperatureSet temperatureSet; - StarTracker::VersionSet versionSet; - StarTracker::PowerSet powerSet; - StarTracker::InterfaceSet interfaceSet; - StarTracker::TimeSet timeSet; - StarTracker::SolutionSet solutionSet; - StarTracker::HistogramSet histogramSet; - StarTracker::ContrastSet contrastSet; - StarTracker::ChecksumSet checksumSet; - StarTracker::DownloadCentroidSet downloadCentroidSet; - StarTracker::DownloadMatchedStar downloadMatchedStar; - StarTracker::DownloadDBImage downloadDbImage; - StarTracker::DownloadBlobPixel downloadBlobPixel; - - // Pointer to object responsible for uploading and downloading images to/from the star tracker - StrHelper* strHelper = nullptr; - - uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE]; - - // Countdown to insert delay for star tracker to switch from bootloader to firmware program - Countdown bootCountdown; - - std::string paramJsonFile = "/mnt/sd0/startracker/full.json"; - - enum class InternalState { - TEMPERATURE_REQUEST - }; - - InternalState internalState = InternalState::TEMPERATURE_REQUEST; - - enum class StartupState { - IDLE, - CHECK_BOOT_STATE, - BOOT, - BOOT_DELAY, - LIMITS, - TRACKING, - MOUNTING, - CAMERA, - BLOB, - CENTROIDING, - LISA, - MATCHING, - VALIDATION, - ALGO, - WAIT_FOR_EXECUTION, - DONE - }; - - StartupState startupState = StartupState::IDLE; - - bool strHelperExecuting = false; - - /** - * @brief Handles internal state - */ - void handleInternalState(); - - /** - * @brief Checks mode for commands requiring MODE_ON of MODE_NORMAL for execution. - * - * @param actionId Action id of command to execute - */ - ReturnValue_t checkMode(ActionId_t actionId); - - /** - * @brief This function initializes the serial link ip protocol struct slipInfo. - */ - void slipInit(); - - ReturnValue_t scanForActionReply(DeviceCommandId_t *foundId); - ReturnValue_t scanForParameterReply(DeviceCommandId_t *foundId); - ReturnValue_t scanForTmReply(DeviceCommandId_t *foundId); - - /** - * @brief Fills command buffer with data to ping the star tracker - */ - void preparePingRequest(); - - /** - * @brief Fills command buffer with data to request the time telemetry. - */ - void prepareTimeRequest(); - - /** - * @brief Handles all received event messages - */ - void handleEvent(EventMessage* eventMessage); - - /** - * @brief Executes the write command - * - * @param commandData Pointer to received command data - * @param commandDataLen Size of received command data - * - * @return RETURN_OK if start of execution was successful, otherwise error return value - */ - ReturnValue_t executeWriteCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Starts the execution of the fpga download command - * - * @param commandData Pointer to buffer with command data - * @param commandDataLen Size of received command - */ - ReturnValue_t executeFpgaDownloadCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Extracts information for flash-read-command from TC data and starts execution of - * flash-read-procedure - * - * @param commandData Pointer to received command data - * @param commandDataLen Size of received command data - * - * @return RETURN_OK if start of execution was successful, otherwise error return value - */ - ReturnValue_t executeReadCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills command buffer with data to boot image (works only when star tracker is - * in bootloader mode). - */ - void prepareBootCommand(); - - /** - * @brief Fills command buffer with command to erase a flash region - */ - ReturnValue_t prepareEraseCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills command buffer with command to unlock flash region - */ - ReturnValue_t prepareUnlockCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills command buffer with command to get the checksum of a flash part - */ - ReturnValue_t prepareChecksumCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills command buffer with command to set the unix time - */ - ReturnValue_t prepareSetTimeCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills command buffer with command to request a centroid - */ - ReturnValue_t prepareDownloadCentroidCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills command buffer with command to upload a centroid for testing purpose - */ - ReturnValue_t prepareUploadCentroidCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills the command buffer with the command to take an image. - */ - void prepareTakeImageCommand(const uint8_t* commandData); - - /** - * @brief Fills command buffer with data to request the version telemetry packet - */ - void prepareVersionRequest(); - - /** - * @brief Fills the command buffer with data to request the interface telemetry packet. - */ - void prepareInterfaceRequest(); - - /** - * @brief Fills the command buffer with data to request the power telemetry packet. - */ - void preparePowerRequest(); - - /** - * @brief Fills command buffer with data to reboot star tracker. - */ - void prepareRebootCommand(); - - /** - * @brief Fills command buffer with data to subscribe to a telemetry packet. - * - * @param tmId The ID of the telemetry packet to subscribe to - */ - void prepareSubscriptionCommand(const uint8_t* tmId); - - /** - * @brief Fills command buffer with data to request solution telemtry packet (contains - * attitude information) - */ - void prepareSolutionRequest(); - - /** - * @brief Fills command buffer with data to request temperature from star tracker - */ - void prepareTemperatureRequest(); - - /** - * @brief Fills command buffer with data to request histogram - */ - void prepareHistogramRequest(); - - void prepareContrastRequest(); - - /** - * @brief Fills command buffer with command to reset the error signal of the star tracker - */ - void prepareErrorResetRequest(); - - /** - * @brief Reads parameters from json file specified by string in commandData and - * prepares the command to apply the parameter set to the star tracker - * - * @param commandData Contains string with file name - * @param commandDataLen Length of command - * @param paramSet The object defining the command generation - * - * @return RETURN_OK if successful, otherwise error return Value - */ - ReturnValue_t prepareParamCommand(const uint8_t* commandData, size_t commandDataLen, - ArcsecJsonParamBase& paramSet); - - /** - * @brief Fills command buffer with data to request matched star. - */ - ReturnValue_t prepareDownloadMatchedStarCommand(const uint8_t* commandData, - size_t commandDataLen); - - /** - * @brief Fills command buffer with data to request matched star coordinates. - */ - ReturnValue_t prepareDownloadDbImageCommand(const uint8_t* commandData, - size_t commandDataLen); - - /** - * @brief Fills command buffer with data to request output of the blob filter algorithm. - */ - ReturnValue_t prepareDownloadBlobPixelCommand(const uint8_t* commandData, - size_t commandDataLen); - - /** - * @brief With this command the FPGA update will be applied to the star tracker - */ - ReturnValue_t prepareFpgaActionCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Handles action replies with datasets. - */ - ReturnValue_t handleActionReplySet(LocalPoolDataSetBase& dataset, size_t size); - - /** - * @brief Default function to handle action replies - */ - ReturnValue_t handleActionReply(); - - /** - * @brief Handles reply to upload centroid command - */ - ReturnValue_t handleUploadCentroidReply(); - - /** - * @brief Handles reply to erase command - */ - ReturnValue_t handleEraseReply(); - - /** - * @brief Handles reply to checksum command - */ - ReturnValue_t handleChecksumReply(); - - /** - * @brief Handles all set parameter replies - */ - ReturnValue_t handleSetParamReply(); - - ReturnValue_t handlePingReply(); - - /** - * @brief Checks the loaded program by means of the version set - */ - ReturnValue_t checkProgram(); - - /** - * @brief Handles the startup state machine - */ - void handleStartup(const uint8_t* parameterId); - - /** - * @brief Handles telemtry replies and fills the appropriate dataset - * - * @param dataset Dataset where reply data will be written to - * @param size Size of the dataset - * - * @return RETURN_OK if successful, otherwise error return value - */ - ReturnValue_t handleTm(LocalPoolDataSetBase& dataset, size_t size); +class StarTrackerHandler : public DeviceHandlerBase { + public: + /** + * @brief Constructor + * + * @param objectId + * @param comIF + * @param comCookie + * @param gpioComIF Pointer to gpio communication interface + * @param enablePin GPIO connected to the enable pin of the reaction wheels. Must be pulled + * to high to enable the device. + */ + StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, + StrHelper* strHelper); + virtual ~StarTrackerHandler(); + + ReturnValue_t initialize() override; + + /** + * @brief Overwrite this function from DHB to handle commands executed by the str image + * loader task. + */ + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) override; + + void performOperationHook() override; + + protected: + void doStartUp() override; + void doShutDown() override; + void doOffActivity() 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; + /** + * @brief Overwritten here to always read all available data from the UartComIF. + */ + virtual size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override; + virtual ReturnValue_t doSendReadHook() override; + + private: + static const uint8_t INTERFACE_ID = CLASS_ID::STR_HANDLER; + + //! [EXPORT] : [COMMENT] Received reply is too short + static const ReturnValue_t REPLY_TOO_SHORT = MAKE_RETURN_CODE(0xB0); + //! [EXPORT] : [COMMENT] Received reply with invalid CRC + static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xB1); + //! [EXPORT] : [COMMENT] Image loader executing + static const ReturnValue_t IMAGE_LOADER_EXECUTING = MAKE_RETURN_CODE(0xB2); + + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_HANDLER; + + //! [EXPORT] : [COMMENT] Status in temperature reply signals error + static const ReturnValue_t TEMPERATURE_REQ_FAILED = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] Ping command failed + static const ReturnValue_t PING_FAILED = MAKE_RETURN_CODE(0xA1); + //! [EXPORT] : [COMMENT] Status in version reply signals error + static const ReturnValue_t VERSION_REQ_FAILED = MAKE_RETURN_CODE(0xA3); + //! [EXPORT] : [COMMENT] Status in interface reply signals error + static const ReturnValue_t INTERFACE_REQ_FAILED = MAKE_RETURN_CODE(0xA4); + //! [EXPORT] : [COMMENT] Status in power reply signals error + static const ReturnValue_t POWER_REQ_FAILED = MAKE_RETURN_CODE(0xA5); + //! [EXPORT] : [COMMENT] Status of reply to parameter set command signals error + static const ReturnValue_t SET_PARAM_FAILED = MAKE_RETURN_CODE(0xA6); + //! [EXPORT] : [COMMENT] Status of reply to action command signals error + static const ReturnValue_t ACTION_FAILED = MAKE_RETURN_CODE(0xA7); + //! [EXPORT] : [COMMENT] Received upload image command with invalid length + static const ReturnValue_t UPLOAD_TOO_SHORT = MAKE_RETURN_CODE(0xA8); + //! [EXPORT] : [COMMENT] Received upload image command with invalid position field + static const ReturnValue_t UPLOAD_INVALID_POSITION = MAKE_RETURN_CODE(0xA8); + //! [EXPORT] : [COMMENT] Position value in upload image reply not matching sent position + static const ReturnValue_t UPLOAD_IMAGE_FAILED = MAKE_RETURN_CODE(0xA9); + //! [EXPORT] : [COMMENT] Received upload image command with invalid length + static const ReturnValue_t INVALID_UPLOAD_COMMAND = MAKE_RETURN_CODE(0xAA); + //! [EXPORT] : [COMMENT] Received invalid path string. Exceeds allowed length + static const ReturnValue_t FILE_PATH_TOO_LONG = MAKE_RETURN_CODE(0xAB); + //! [EXPORT] : [COMMENT] Name of file received with command is too long + static const ReturnValue_t FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xAC); + //! [EXPORT] : [COMMENT] Received version reply with invalid program ID + static const ReturnValue_t INVALID_PROGRAM = MAKE_RETURN_CODE(0xAD); + //! [EXPORT] : [COMMENT] Status field reply signals error + static const ReturnValue_t REPLY_ERROR = MAKE_RETURN_CODE(0xAE); + //! [EXPORT] : [COMMENT] Status field of contrast reply signals error + static const ReturnValue_t CONTRAST_REQ_FAILED = MAKE_RETURN_CODE(0xAE); + //! [EXPORT] : [COMMENT] Received command which is too short (some data is missing for proper + //! execution) + static const ReturnValue_t COMMAND_TOO_SHORT = MAKE_RETURN_CODE(0xAF); + //! [EXPORT] : [COMMENT] Received command with invalid length (too few or too many parameters) + static const ReturnValue_t INVALID_LENGTH = MAKE_RETURN_CODE(0xB0); + //! [EXPORT] : [COMMENT] Region mismatch between send and received data + static const ReturnValue_t REGION_MISMATCH = MAKE_RETURN_CODE(0xB1); + //! [EXPORT] : [COMMENT] Address mismatch between send and received data + static const ReturnValue_t ADDRESS_MISMATCH = MAKE_RETURN_CODE(0xB2); + //! [EXPORT] : [COMMENT] Length field mismatch between send and received data + static const ReturnValue_t lENGTH_MISMATCH = MAKE_RETURN_CODE(0xB3); + //! [EXPORT] : [COMMENT] Specified file does not exist + static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xB4); + //! [EXPORT] : [COMMENT] Reply to upload centroid does not match commanded centroid id + static const ReturnValue_t UPLOAD_CENTROID_ID_MISMATCH = MAKE_RETURN_CODE(0xB5); + //! [EXPORT] : [COMMENT] Download blob pixel command has invalid type field + static const ReturnValue_t INVALID_TYPE = MAKE_RETURN_CODE(0xB6); + //! [EXPORT] : [COMMENT] Received FPGA action command with invalid ID + static const ReturnValue_t INVALID_ID = MAKE_RETURN_CODE(0xB7); + + static const size_t MAX_PATH_SIZE = 50; + static const size_t MAX_FILE_NAME = 30; + + // position (uint32) + 1024 image data + static const size_t UPLOAD_COMMAND_LEN = 1028; + // Max valid position value in upload image command + static const uint16_t MAX_POSITION = 4095; + static const uint8_t STATUS_OFFSET = 1; + static const uint8_t TICKS_OFFSET = 2; + static const uint8_t TIME_OFFSET = 6; + static const uint8_t TM_DATA_FIELD_OFFSET = 14; + static const uint8_t PARAMETER_ID_OFFSET = 0; + static const uint8_t ACTION_ID_OFFSET = 0; + static const uint8_t ACTION_DATA_OFFSET = 2; + // Ping request will reply ping with this ID (data field) + static const uint32_t PING_ID = 0x55; + static const uint32_t BOOT_REGION_ID = 1; + static const MutexIF::TimeoutType TIMEOUT_TYPE = MutexIF::TimeoutType::WAITING; + static const uint32_t MUTEX_TIMEOUT = 20; + static const uint32_t BOOT_TIMEOUT = 1000; + + class WriteCmd { + public: + static const uint8_t ADDRESS_OFFSET = 1; + static const uint8_t FILE_OFFSET = 5; + // Minimum length of a write command (region, address and filename) + static const size_t MIN_LENGTH = 7; + }; + + class ReadCmd { + public: + static const uint8_t ADDRESS_OFFSET = 1; + static const uint8_t LENGTH_OFFSET = 5; + static const uint8_t FILE_OFFSET = 9; + // Minimum length of a read command (region, address, length and filename) + static const size_t MIN_LENGTH = 11; + }; + + class EraseCmd { + public: + static const uint8_t LENGTH = 1; + uint8_t rememberRegion = 0; + }; + + EraseCmd eraseCmd; + + class UnlockCmd { + public: + static const uint8_t CODE_OFFSET = 1; + }; + + class ChecksumCmd { + public: + static const uint8_t ADDRESS_OFFSET = 1; + static const uint8_t LENGTH_OFFSET = 5; + // Length of checksum command + static const size_t LENGTH = 9; + uint8_t rememberRegion = 0; + uint32_t rememberAddress = 0; + uint32_t rememberLength = 0; + }; + + ChecksumCmd checksumCmd; + + class SetTimeCmd { + public: + static const uint8_t LENGTH = 8; + }; + + class DownloadCentroidCmd { + public: + static const uint8_t LENGTH = 1; + }; + + class UploadCentroid { + public: + uint8_t rememberId = 0; + }; + + UploadCentroid uploadCentroid; + + class DownloadMatchedStarCmd { + public: + static const uint8_t LENGTH = 1; + }; + + class DownloadDbImageCmd { + public: + static const uint8_t LENGTH = 1; + }; + + class DownloadBlobPixCmd { + public: + static const uint8_t LENGTH = 2; + static const uint8_t NORMAL = 0; + static const uint8_t FAST = 1; + }; + + class FpgaDownloadCmd { + public: + static const uint8_t MIN_LENGTH = 10; + }; + + class FpgaActionCmd { + public: + static const uint8_t LENGTH = 1; + static const uint8_t ID = 3; + }; + + MessageQueueIF* eventQueue = nullptr; + + ArcsecDatalinkLayer dataLinkLayer; + + StarTracker::TemperatureSet temperatureSet; + StarTracker::VersionSet versionSet; + StarTracker::PowerSet powerSet; + StarTracker::InterfaceSet interfaceSet; + StarTracker::TimeSet timeSet; + StarTracker::SolutionSet solutionSet; + StarTracker::HistogramSet histogramSet; + StarTracker::ContrastSet contrastSet; + StarTracker::ChecksumSet checksumSet; + StarTracker::DownloadCentroidSet downloadCentroidSet; + StarTracker::DownloadMatchedStar downloadMatchedStar; + StarTracker::DownloadDBImage downloadDbImage; + StarTracker::DownloadBlobPixel downloadBlobPixel; + + // Pointer to object responsible for uploading and downloading images to/from the star tracker + StrHelper* strHelper = nullptr; + + uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE]; + + // Countdown to insert delay for star tracker to switch from bootloader to firmware program + Countdown bootCountdown; + + std::string paramJsonFile = "/mnt/sd0/startracker/full.json"; + + enum class InternalState { TEMPERATURE_REQUEST }; + + InternalState internalState = InternalState::TEMPERATURE_REQUEST; + + enum class StartupState { + IDLE, + CHECK_BOOT_STATE, + BOOT, + BOOT_DELAY, + LIMITS, + TRACKING, + MOUNTING, + CAMERA, + BLOB, + CENTROIDING, + LISA, + MATCHING, + VALIDATION, + ALGO, + WAIT_FOR_EXECUTION, + DONE + }; + + StartupState startupState = StartupState::IDLE; + + bool strHelperExecuting = false; + + /** + * @brief Handles internal state + */ + void handleInternalState(); + + /** + * @brief Checks mode for commands requiring MODE_ON of MODE_NORMAL for execution. + * + * @param actionId Action id of command to execute + */ + ReturnValue_t checkMode(ActionId_t actionId); + + /** + * @brief This function initializes the serial link ip protocol struct slipInfo. + */ + void slipInit(); + + ReturnValue_t scanForActionReply(DeviceCommandId_t* foundId); + ReturnValue_t scanForParameterReply(DeviceCommandId_t* foundId); + ReturnValue_t scanForTmReply(DeviceCommandId_t* foundId); + + /** + * @brief Fills command buffer with data to ping the star tracker + */ + void preparePingRequest(); + + /** + * @brief Fills command buffer with data to request the time telemetry. + */ + void prepareTimeRequest(); + + /** + * @brief Handles all received event messages + */ + void handleEvent(EventMessage* eventMessage); + + /** + * @brief Executes the write command + * + * @param commandData Pointer to received command data + * @param commandDataLen Size of received command data + * + * @return RETURN_OK if start of execution was successful, otherwise error return value + */ + ReturnValue_t executeWriteCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Starts the execution of the fpga download command + * + * @param commandData Pointer to buffer with command data + * @param commandDataLen Size of received command + */ + ReturnValue_t executeFpgaDownloadCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Extracts information for flash-read-command from TC data and starts execution of + * flash-read-procedure + * + * @param commandData Pointer to received command data + * @param commandDataLen Size of received command data + * + * @return RETURN_OK if start of execution was successful, otherwise error return value + */ + ReturnValue_t executeReadCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills command buffer with data to boot image (works only when star tracker is + * in bootloader mode). + */ + void prepareBootCommand(); + + /** + * @brief Fills command buffer with command to erase a flash region + */ + ReturnValue_t prepareEraseCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills command buffer with command to unlock flash region + */ + ReturnValue_t prepareUnlockCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills command buffer with command to get the checksum of a flash part + */ + ReturnValue_t prepareChecksumCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills command buffer with command to set the unix time + */ + ReturnValue_t prepareSetTimeCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills command buffer with command to request a centroid + */ + ReturnValue_t prepareDownloadCentroidCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills command buffer with command to upload a centroid for testing purpose + */ + ReturnValue_t prepareUploadCentroidCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills the command buffer with the command to take an image. + */ + void prepareTakeImageCommand(const uint8_t* commandData); + + /** + * @brief Fills command buffer with data to request the version telemetry packet + */ + void prepareVersionRequest(); + + /** + * @brief Fills the command buffer with data to request the interface telemetry packet. + */ + void prepareInterfaceRequest(); + + /** + * @brief Fills the command buffer with data to request the power telemetry packet. + */ + void preparePowerRequest(); + + /** + * @brief Fills command buffer with data to reboot star tracker. + */ + void prepareRebootCommand(); + + /** + * @brief Fills command buffer with data to subscribe to a telemetry packet. + * + * @param tmId The ID of the telemetry packet to subscribe to + */ + void prepareSubscriptionCommand(const uint8_t* tmId); + + /** + * @brief Fills command buffer with data to request solution telemtry packet (contains + * attitude information) + */ + void prepareSolutionRequest(); + + /** + * @brief Fills command buffer with data to request temperature from star tracker + */ + void prepareTemperatureRequest(); + + /** + * @brief Fills command buffer with data to request histogram + */ + void prepareHistogramRequest(); + + void prepareContrastRequest(); + + /** + * @brief Fills command buffer with command to reset the error signal of the star tracker + */ + void prepareErrorResetRequest(); + + /** + * @brief Reads parameters from json file specified by string in commandData and + * prepares the command to apply the parameter set to the star tracker + * + * @param commandData Contains string with file name + * @param commandDataLen Length of command + * @param paramSet The object defining the command generation + * + * @return RETURN_OK if successful, otherwise error return Value + */ + ReturnValue_t prepareParamCommand(const uint8_t* commandData, size_t commandDataLen, + ArcsecJsonParamBase& paramSet); + + /** + * @brief Fills command buffer with data to request matched star. + */ + ReturnValue_t prepareDownloadMatchedStarCommand(const uint8_t* commandData, + size_t commandDataLen); + + /** + * @brief Fills command buffer with data to request matched star coordinates. + */ + ReturnValue_t prepareDownloadDbImageCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills command buffer with data to request output of the blob filter algorithm. + */ + ReturnValue_t prepareDownloadBlobPixelCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief With this command the FPGA update will be applied to the star tracker + */ + ReturnValue_t prepareFpgaActionCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Handles action replies with datasets. + */ + ReturnValue_t handleActionReplySet(LocalPoolDataSetBase& dataset, size_t size); + + /** + * @brief Default function to handle action replies + */ + ReturnValue_t handleActionReply(); + + /** + * @brief Handles reply to upload centroid command + */ + ReturnValue_t handleUploadCentroidReply(); + + /** + * @brief Handles reply to erase command + */ + ReturnValue_t handleEraseReply(); + + /** + * @brief Handles reply to checksum command + */ + ReturnValue_t handleChecksumReply(); + + /** + * @brief Handles all set parameter replies + */ + ReturnValue_t handleSetParamReply(); + + ReturnValue_t handlePingReply(); + + /** + * @brief Checks the loaded program by means of the version set + */ + ReturnValue_t checkProgram(); + + /** + * @brief Handles the startup state machine + */ + void handleStartup(const uint8_t* parameterId); + + /** + * @brief Handles telemtry replies and fills the appropriate dataset + * + * @param dataset Dataset where reply data will be written to + * @param size Size of the dataset + * + * @return RETURN_OK if successful, otherwise error return value + */ + ReturnValue_t handleTm(LocalPoolDataSetBase& dataset, size_t size); }; #endif /* MISSION_DEVICES_STARTRACKERHANDLER_H_ */ diff --git a/bsp_q7s/devices/startracker/StarTrackerJsonCommands.cpp b/bsp_q7s/devices/startracker/StarTrackerJsonCommands.cpp index 9c33e1c9..b912c03e 100644 --- a/bsp_q7s/devices/startracker/StarTrackerJsonCommands.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerJsonCommands.cpp @@ -1,716 +1,689 @@ #include "StarTrackerJsonCommands.h" + #include "ArcsecJsonKeys.h" Limits::Limits() : ArcsecJsonParamBase(arcseckeys::LIMITS) {} -size_t Limits::getSize() { - return COMMAND_SIZE; -} +size_t Limits::getSize() { return COMMAND_SIZE; } ReturnValue_t Limits::createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::LIMITS); - offset = 2; - result = getParam(arcseckeys::ACTION, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::FPGA18CURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::FPGA25CURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::FPGA10CURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MCUCURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::CMOS21CURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::CMOSPIXCURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::CMOS33CURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::CMOSVRESCURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::CMOS_TEMPERATURE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MCU_TEMPERATURE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::LIMITS); + offset = 2; + result = getParam(arcseckeys::ACTION, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::FPGA18CURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FPGA25CURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FPGA10CURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MCUCURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CMOS21CURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CMOSPIXCURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CMOS33CURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CMOSVRESCURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CMOS_TEMPERATURE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MCU_TEMPERATURE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + return RETURN_OK; } - Tracking::Tracking() : ArcsecJsonParamBase(arcseckeys::TRACKING) {} -size_t Tracking::getSize() { - return COMMAND_SIZE; -} +size_t Tracking::getSize() { return COMMAND_SIZE; } ReturnValue_t Tracking::createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::TRACKING); - offset = 2; - result = getParam(arcseckeys::THIN_LIMIT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::OUTLIER_THRESHOLD, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::OUTLIER_THRESHOLD_QUEST, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::TRACKER_CHOICE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::TRACKING); + offset = 2; + result = getParam(arcseckeys::THIN_LIMIT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::OUTLIER_THRESHOLD, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::OUTLIER_THRESHOLD_QUEST, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::TRACKER_CHOICE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + return RETURN_OK; } - Mounting::Mounting() : ArcsecJsonParamBase(arcseckeys::MOUNTING) {} -size_t Mounting::getSize() { - return COMMAND_SIZE; -} +size_t Mounting::getSize() { return COMMAND_SIZE; } ReturnValue_t Mounting::createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::MOUNTING); - offset = 2; - result = getParam(arcseckeys::qw, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::qx, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::qy, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::qz, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::MOUNTING); + offset = 2; + result = getParam(arcseckeys::qw, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::qx, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::qy, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::qz, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + return RETURN_OK; } - Camera::Camera() : ArcsecJsonParamBase(arcseckeys::CAMERA) {} -size_t Camera::getSize() { - return COMMAND_SIZE; -} +size_t Camera::getSize() { return COMMAND_SIZE; } ReturnValue_t Camera::createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::CAMERA); - offset = 2; - result = getParam(arcseckeys::MODE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::FOCALLENGTH, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::EXPOSURE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::INTERVAL, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::OFFSET, param); - if (result != RETURN_OK) { - return result; - } - addint16(param, buffer + offset); - offset += sizeof(int16_t); - result = getParam(arcseckeys::PGAGAIN, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::ADCGAIN, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_1, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_1, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_2, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_2, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_3, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_3, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_4, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_4, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_5, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_5, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_6, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_6, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_7, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_7, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_8, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_8, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::FREQ_1, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::FREQ_2, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::CAMERA); + offset = 2; + result = getParam(arcseckeys::MODE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::FOCALLENGTH, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::EXPOSURE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::INTERVAL, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::OFFSET, param); + if (result != RETURN_OK) { + return result; + } + addint16(param, buffer + offset); + offset += sizeof(int16_t); + result = getParam(arcseckeys::PGAGAIN, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::ADCGAIN, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_1, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_1, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_2, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_2, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_3, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_3, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_4, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_4, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_5, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_5, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_6, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_6, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_7, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_7, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_8, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_8, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::FREQ_1, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FREQ_2, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + return RETURN_OK; } - Blob::Blob() : ArcsecJsonParamBase(arcseckeys::BLOB) {} -size_t Blob::getSize() { - return COMMAND_SIZE; -} +size_t Blob::getSize() { return COMMAND_SIZE; } ReturnValue_t Blob::createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::BLOB); - offset = 2; - result = getParam(arcseckeys::MODE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::MIN_VALUE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::MIN_DISTANCE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::NEIGHBOUR_DISTANCE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::NEIGHBOUR_BRIGHT_PIXELS, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::MIN_TOTAL_VALUE, param); - if (result != RETURN_OK) { - return result; - } - adduint16(param, buffer + offset); - offset += sizeof(uint16_t); - result = getParam(arcseckeys::MAX_TOTAL_VALUE, param); - if (result != RETURN_OK) { - return result; - } - adduint16(param, buffer + offset); - offset += sizeof(uint16_t); - result = getParam(arcseckeys::MIN_BRIGHT_NEIGHBOURS, param); - if (result != RETURN_OK) { - return result; - } - adduint16(param, buffer + offset); - offset += sizeof(uint16_t); - result = getParam(arcseckeys::MAX_BRIGHT_NEIGHBOURS, param); - if (result != RETURN_OK) { - return result; - } - adduint16(param, buffer + offset); - offset += sizeof(uint16_t); - result = getParam(arcseckeys::MAX_PIXEL_TO_CONSIDER, param); - if (result != RETURN_OK) { - return result; - } - adduint32(param, buffer + offset); - offset += sizeof(uint32_t); - result = getParam(arcseckeys::SIGNAL_THRESHOLD, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::DARK_THRESHOLD, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::ENABLE_HISTOGRAM, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::ENABLE_CONTRAST, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::BIN_MODE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::BLOB); + offset = 2; + result = getParam(arcseckeys::MODE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::MIN_VALUE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::MIN_DISTANCE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::NEIGHBOUR_DISTANCE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::NEIGHBOUR_BRIGHT_PIXELS, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::MIN_TOTAL_VALUE, param); + if (result != RETURN_OK) { + return result; + } + adduint16(param, buffer + offset); + offset += sizeof(uint16_t); + result = getParam(arcseckeys::MAX_TOTAL_VALUE, param); + if (result != RETURN_OK) { + return result; + } + adduint16(param, buffer + offset); + offset += sizeof(uint16_t); + result = getParam(arcseckeys::MIN_BRIGHT_NEIGHBOURS, param); + if (result != RETURN_OK) { + return result; + } + adduint16(param, buffer + offset); + offset += sizeof(uint16_t); + result = getParam(arcseckeys::MAX_BRIGHT_NEIGHBOURS, param); + if (result != RETURN_OK) { + return result; + } + adduint16(param, buffer + offset); + offset += sizeof(uint16_t); + result = getParam(arcseckeys::MAX_PIXEL_TO_CONSIDER, param); + if (result != RETURN_OK) { + return result; + } + adduint32(param, buffer + offset); + offset += sizeof(uint32_t); + result = getParam(arcseckeys::SIGNAL_THRESHOLD, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::DARK_THRESHOLD, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::ENABLE_HISTOGRAM, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::ENABLE_CONTRAST, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::BIN_MODE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + return RETURN_OK; } - Centroiding::Centroiding() : ArcsecJsonParamBase(arcseckeys::CENTROIDING) {} -size_t Centroiding::getSize() { - return COMMAND_SIZE; -} +size_t Centroiding::getSize() { return COMMAND_SIZE; } ReturnValue_t Centroiding::createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::CENTROIDING); - offset = 2; - result = getParam(arcseckeys::ENABLE_FILTER, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::MAX_QUALITY, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MIN_QUALITY, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MAX_INTENSITY, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MIN_INTENSITY, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MAX_MAGNITUDE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::GAUSSIAN_CMAX, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::GAUSSIAN_CMIN, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::TRANSMATRIX_00, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::TRANSMATRIX_01, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::TRANSMATRIX_10, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::TRANSMATRIX_11, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::CENTROIDING); + offset = 2; + result = getParam(arcseckeys::ENABLE_FILTER, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::MAX_QUALITY, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MIN_QUALITY, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MAX_INTENSITY, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MIN_INTENSITY, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MAX_MAGNITUDE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::GAUSSIAN_CMAX, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::GAUSSIAN_CMIN, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::TRANSMATRIX_00, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::TRANSMATRIX_01, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::TRANSMATRIX_10, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::TRANSMATRIX_11, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + return RETURN_OK; } - Lisa::Lisa() : ArcsecJsonParamBase(arcseckeys::LISA) {} -size_t Lisa::getSize() { - return COMMAND_SIZE; -} +size_t Lisa::getSize() { return COMMAND_SIZE; } ReturnValue_t Lisa::createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::LISA); - offset = 2; - result = getParam(arcseckeys::PREFILTER_DIST_THRESHOLD, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::PREFILTER_ANGLE_THRESHOLD, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::FOV_WIDTH, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::FOV_HEIGHT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::FLOAT_STAR_LIMIT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::CLOSE_STAR_LIMIT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::RATING_WEIGHT_CLOSE_STAR_COUNT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::RATING_WEIGHT_FRACTION_CLOSE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::RATING_WEIGHT_DB_STAR_COUNT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MAX_COMBINATIONS, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::NR_STARS_STOP, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::FRACTION_CLOSE_STOP, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::LISA); + offset = 2; + result = getParam(arcseckeys::PREFILTER_DIST_THRESHOLD, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::PREFILTER_ANGLE_THRESHOLD, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FOV_WIDTH, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FOV_HEIGHT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FLOAT_STAR_LIMIT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CLOSE_STAR_LIMIT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::RATING_WEIGHT_CLOSE_STAR_COUNT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::RATING_WEIGHT_FRACTION_CLOSE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::RATING_WEIGHT_DB_STAR_COUNT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MAX_COMBINATIONS, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::NR_STARS_STOP, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::FRACTION_CLOSE_STOP, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + return RETURN_OK; } - Matching::Matching() : ArcsecJsonParamBase(arcseckeys::MATCHING) {} -size_t Matching::getSize() { - return COMMAND_SIZE; -} +size_t Matching::getSize() { return COMMAND_SIZE; } ReturnValue_t Matching::createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::MATCHING); - offset = 2; - result = getParam(arcseckeys::SQUARED_DISTANCE_LIMIT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::SQUARED_SHIFT_LIMIT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::MATCHING); + offset = 2; + result = getParam(arcseckeys::SQUARED_DISTANCE_LIMIT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::SQUARED_SHIFT_LIMIT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + return RETURN_OK; } - Validation::Validation() : ArcsecJsonParamBase(arcseckeys::VALIDATION) {} -size_t Validation::getSize() { - return COMMAND_SIZE; -} +size_t Validation::getSize() { return COMMAND_SIZE; } ReturnValue_t Validation::createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::VALIDATION); - offset = 2; - result = getParam(arcseckeys::STABLE_COUNT, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::MAX_DIFFERENCE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MIN_TRACKER_CONFIDENCE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MIN_MATCHED_STARS, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::VALIDATION); + offset = 2; + result = getParam(arcseckeys::STABLE_COUNT, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::MAX_DIFFERENCE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MIN_TRACKER_CONFIDENCE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MIN_MATCHED_STARS, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + return RETURN_OK; } Algo::Algo() : ArcsecJsonParamBase(arcseckeys::ALGO) {} -size_t Algo::getSize() { - return COMMAND_SIZE; -} +size_t Algo::getSize() { return COMMAND_SIZE; } ReturnValue_t Algo::createCommand(uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::ALGO); - offset = 2; - result = getParam(arcseckeys::MODE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::L2T_MIN_CONFIDENCE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::L2T_MIN_MATCHED, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::T2L_MIN_CONFIDENCE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::T2L_MIN_MATCHED, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::ALGO); + offset = 2; + result = getParam(arcseckeys::MODE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::L2T_MIN_CONFIDENCE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::L2T_MIN_MATCHED, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::T2L_MIN_CONFIDENCE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::T2L_MIN_MATCHED, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + return RETURN_OK; } diff --git a/bsp_q7s/devices/startracker/StarTrackerJsonCommands.h b/bsp_q7s/devices/startracker/StarTrackerJsonCommands.h index 868c18ea..96c52fa2 100644 --- a/bsp_q7s/devices/startracker/StarTrackerJsonCommands.h +++ b/bsp_q7s/devices/startracker/StarTrackerJsonCommands.h @@ -9,207 +9,168 @@ #include -#include "fsfw/serviceinterface/ServiceInterface.h" #include "ArcsecJsonParamBase.h" - +#include "fsfw/serviceinterface/ServiceInterface.h" /** * @brief Generates command to set the limit parameters * */ class Limits : public ArcsecJsonParamBase { -public: + public: + Limits(); - Limits(); + size_t getSize(); - size_t getSize(); + private: + static const size_t COMMAND_SIZE = 43; -private: - - static const size_t COMMAND_SIZE = 43; - - virtual ReturnValue_t createCommand(uint8_t* buffer) override; + virtual ReturnValue_t createCommand(uint8_t* buffer) override; }; - /** * @brief Generates the command to configure the tracking algorithm. * */ class Tracking : public ArcsecJsonParamBase { -public: + public: + Tracking(); - Tracking(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 15; - - ReturnValue_t createCommand(uint8_t* buffer) override; + private: + static const size_t COMMAND_SIZE = 15; + ReturnValue_t createCommand(uint8_t* buffer) override; }; - /** * @brief Generates the command to set the mounting quaternion * */ class Mounting : public ArcsecJsonParamBase { -public: + public: + Mounting(); - Mounting(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 18; - - ReturnValue_t createCommand(uint8_t* buffer) override; + private: + static const size_t COMMAND_SIZE = 18; + ReturnValue_t createCommand(uint8_t* buffer) override; }; - /** * @brief Generates the command to set the mounting quaternion * */ class Camera : public ArcsecJsonParamBase { -public: + public: + Camera(); - Camera(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 43; - - ReturnValue_t createCommand(uint8_t* buffer) override; + private: + static const size_t COMMAND_SIZE = 43; + ReturnValue_t createCommand(uint8_t* buffer) override; }; - /** * @brief Generates the command to configure the blob algorithm * */ class Blob : public ArcsecJsonParamBase { -public: + public: + Blob(); - Blob(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 24; - - ReturnValue_t createCommand(uint8_t* buffer) override; + private: + static const size_t COMMAND_SIZE = 24; + ReturnValue_t createCommand(uint8_t* buffer) override; }; - /** * @brief Generates the command to configure the centroiding algorithm * */ class Centroiding : public ArcsecJsonParamBase { -public: + public: + Centroiding(); - Centroiding(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 47; - - ReturnValue_t createCommand(uint8_t* buffer) override; + private: + static const size_t COMMAND_SIZE = 47; + ReturnValue_t createCommand(uint8_t* buffer) override; }; - /** * @brief Generates the command to configure the LISA (lost in space algorithm) * */ class Lisa : public ArcsecJsonParamBase { -public: + public: + Lisa(); - Lisa(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 48; - - ReturnValue_t createCommand(uint8_t* buffer) override; + private: + static const size_t COMMAND_SIZE = 48; + ReturnValue_t createCommand(uint8_t* buffer) override; }; - /** * @brief Generates the command to configure the matching algorithm * */ class Matching : public ArcsecJsonParamBase { -public: + public: + Matching(); - Matching(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 10; - - ReturnValue_t createCommand(uint8_t* buffer) override; + private: + static const size_t COMMAND_SIZE = 10; + ReturnValue_t createCommand(uint8_t* buffer) override; }; - /** * @brief Generates the command to configure the validation parameters * */ class Validation : public ArcsecJsonParamBase { -public: + public: + Validation(); - Validation(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 12; - - ReturnValue_t createCommand(uint8_t* buffer) override; + private: + static const size_t COMMAND_SIZE = 12; + ReturnValue_t createCommand(uint8_t* buffer) override; }; - /** * @brief Generates command to configure the mechanism of automatically switching between the * LISA and other algorithms. * */ class Algo : public ArcsecJsonParamBase { -public: + public: + Algo(); - Algo(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 13; - - ReturnValue_t createCommand(uint8_t* buffer) override; + private: + static const size_t COMMAND_SIZE = 13; + ReturnValue_t createCommand(uint8_t* buffer) override; }; #endif /* BSP_Q7S_DEVICES_DEVICEDEFINITIONS_STARTRACKERJSONCOMMANDS_H_ */ diff --git a/bsp_q7s/devices/startracker/StrHelper.cpp b/bsp_q7s/devices/startracker/StrHelper.cpp index 59587317..00a651b3 100644 --- a/bsp_q7s/devices/startracker/StrHelper.cpp +++ b/bsp_q7s/devices/startracker/StrHelper.cpp @@ -1,702 +1,672 @@ #include "StrHelper.h" +#include +#include + #include "mission/utility/Timestamp.h" -#include -#include +StrHelper::StrHelper(object_id_t objectId) : SystemObject(objectId) {} -StrHelper::StrHelper(object_id_t objectId) : SystemObject(objectId){ - -} - -StrHelper::~StrHelper() { -} +StrHelper::~StrHelper() {} ReturnValue_t StrHelper::initialize() { - sdcMan = SdCardManager::instance(); - if (sdcMan == nullptr) { - sif::warning << "StrHelper::initialize: Invalid SD Card Manager" << std::endl; - return RETURN_FAILED; - } - return RETURN_OK; + sdcMan = SdCardManager::instance(); + if (sdcMan == nullptr) { + sif::warning << "StrHelper::initialize: Invalid SD Card Manager" << std::endl; + return RETURN_FAILED; + } + return RETURN_OK; } ReturnValue_t StrHelper::performOperation(uint8_t operationCode) { - ReturnValue_t result = RETURN_OK; - semaphore.acquire(); - while(true) { - switch(internalState) { - case InternalState::IDLE: { - semaphore.acquire(); - break; + ReturnValue_t result = RETURN_OK; + semaphore.acquire(); + while (true) { + switch (internalState) { + case InternalState::IDLE: { + semaphore.acquire(); + break; + } + case InternalState::UPLOAD_IMAGE: { + result = performImageUpload(); + if (result == RETURN_OK) { + triggerEvent(IMAGE_UPLOAD_SUCCESSFUL); + } else { + triggerEvent(IMAGE_UPLOAD_FAILED); } - case InternalState::UPLOAD_IMAGE: { - result = performImageUpload(); - if (result == RETURN_OK){ - triggerEvent(IMAGE_UPLOAD_SUCCESSFUL); - } - else { - triggerEvent(IMAGE_UPLOAD_FAILED); - } - internalState = InternalState::IDLE; - break; + internalState = InternalState::IDLE; + break; + } + case InternalState::DOWNLOAD_IMAGE: { + result = performImageDownload(); + if (result == RETURN_OK) { + triggerEvent(IMAGE_DOWNLOAD_SUCCESSFUL); + } else { + triggerEvent(IMAGE_DOWNLOAD_FAILED); } - case InternalState::DOWNLOAD_IMAGE: { - result = performImageDownload(); - if (result == RETURN_OK){ - triggerEvent(IMAGE_DOWNLOAD_SUCCESSFUL); - } - else { - triggerEvent(IMAGE_DOWNLOAD_FAILED); - } - internalState = InternalState::IDLE; - break; + internalState = InternalState::IDLE; + break; + } + case InternalState::FLASH_WRITE: { + result = performFlashWrite(); + if (result == RETURN_OK) { + triggerEvent(FLASH_WRITE_SUCCESSFUL); + } else { + triggerEvent(FLASH_WRITE_FAILED); } - case InternalState::FLASH_WRITE: { - result = performFlashWrite(); - if (result == RETURN_OK){ - triggerEvent(FLASH_WRITE_SUCCESSFUL); - } - else { - triggerEvent(FLASH_WRITE_FAILED); - } - internalState = InternalState::IDLE; - break; + internalState = InternalState::IDLE; + break; + } + case InternalState::FLASH_READ: { + result = performFlashRead(); + if (result == RETURN_OK) { + triggerEvent(FLASH_READ_SUCCESSFUL); + } else { + triggerEvent(FLASH_READ_FAILED); } - case InternalState::FLASH_READ: { - result = performFlashRead(); - if (result == RETURN_OK){ - triggerEvent(FLASH_READ_SUCCESSFUL); - } - else { - triggerEvent(FLASH_READ_FAILED); - } - internalState = InternalState::IDLE; - break; + internalState = InternalState::IDLE; + break; + } + case InternalState::DOWNLOAD_FPGA_IMAGE: { + result = performFpgaDownload(); + if (result == RETURN_OK) { + triggerEvent(FPGA_DOWNLOAD_SUCCESSFUL); + } else { + triggerEvent(FPGA_DOWNLOAD_FAILED); } - case InternalState::DOWNLOAD_FPGA_IMAGE: { - result = performFpgaDownload(); - if (result == RETURN_OK){ - triggerEvent(FPGA_DOWNLOAD_SUCCESSFUL); - } - else { - triggerEvent(FPGA_DOWNLOAD_FAILED); - } - internalState = InternalState::IDLE; - break; - } - case InternalState::UPLOAD_FPGA_IMAGE: { - result = performFpgaUpload(); - if (result == RETURN_OK){ - triggerEvent(FPGA_UPLOAD_SUCCESSFUL); - } - else { - triggerEvent(FPGA_UPLOAD_FAILED); - } - internalState = InternalState::IDLE; - break; - } - default: - sif::debug << "StrHelper::performOperation: Invalid state" << std::endl; - break; + internalState = InternalState::IDLE; + break; + } + case InternalState::UPLOAD_FPGA_IMAGE: { + result = performFpgaUpload(); + if (result == RETURN_OK) { + triggerEvent(FPGA_UPLOAD_SUCCESSFUL); + } else { + triggerEvent(FPGA_UPLOAD_FAILED); } + internalState = InternalState::IDLE; + break; + } + default: + sif::debug << "StrHelper::performOperation: Invalid state" << std::endl; + break; } + } } ReturnValue_t StrHelper::setComIF(DeviceCommunicationIF* communicationInterface_) { - uartComIF = dynamic_cast(communicationInterface_); - if (uartComIF == nullptr) { - sif::warning << "StrHelper::initialize: Invalid uart com if" << std::endl; - return RETURN_FAILED; - } - return RETURN_OK; + uartComIF = dynamic_cast(communicationInterface_); + if (uartComIF == nullptr) { + sif::warning << "StrHelper::initialize: Invalid uart com if" << std::endl; + return RETURN_FAILED; + } + return RETURN_OK; } -void StrHelper::setComCookie(CookieIF* comCookie_) { - comCookie = comCookie_; -} +void StrHelper::setComCookie(CookieIF* comCookie_) { comCookie = comCookie_; } ReturnValue_t StrHelper::startImageUpload(std::string fullname) { - ReturnValue_t result = checkPath(fullname); - if (result != RETURN_OK) { - return result; - } - uploadImage.uploadFile = fullname; - if(not std::filesystem::exists(fullname)) { - return FILE_NOT_EXISTS; - } - internalState = InternalState::UPLOAD_FPGA_IMAGE; - semaphore.release(); - terminate = false; - return RETURN_OK; + ReturnValue_t result = checkPath(fullname); + if (result != RETURN_OK) { + return result; + } + uploadImage.uploadFile = fullname; + if (not std::filesystem::exists(fullname)) { + return FILE_NOT_EXISTS; + } + internalState = InternalState::UPLOAD_FPGA_IMAGE; + semaphore.release(); + terminate = false; + return RETURN_OK; } ReturnValue_t StrHelper::startImageDownload(std::string path) { - ReturnValue_t result = checkPath(path); - if (result != RETURN_OK) { - return result; - } - if(not std::filesystem::exists(path)) { - return PATH_NOT_EXISTS; - } - downloadImage.path = path; - internalState = InternalState::DOWNLOAD_IMAGE; - terminate = false; - semaphore.release(); - return RETURN_OK; + ReturnValue_t result = checkPath(path); + if (result != RETURN_OK) { + return result; + } + if (not std::filesystem::exists(path)) { + return PATH_NOT_EXISTS; + } + downloadImage.path = path; + internalState = InternalState::DOWNLOAD_IMAGE; + terminate = false; + semaphore.release(); + return RETURN_OK; } -void StrHelper::stopProcess() { - terminate = true; +void StrHelper::stopProcess() { terminate = true; } + +void StrHelper::setDownloadImageName(std::string filename) { downloadImage.filename = filename; } + +void StrHelper::setFlashReadFilename(std::string filename) { flashRead.filename = filename; } + +void StrHelper::setDownloadFpgaImage(std::string filename) { fpgaDownload.fileName = filename; } + +ReturnValue_t StrHelper::startFlashWrite(std::string fullname, uint8_t region, uint32_t address) { + ReturnValue_t result = checkPath(fullname); + if (result != RETURN_OK) { + return result; + } + flashWrite.fullname = fullname; + if (not std::filesystem::exists(flashWrite.fullname)) { + return FILE_NOT_EXISTS; + } + flashWrite.address = address; + flashWrite.region = region; + internalState = InternalState::FLASH_WRITE; + semaphore.release(); + terminate = false; + return RETURN_OK; } -void StrHelper::setDownloadImageName(std::string filename) { - downloadImage.filename = filename; -} - -void StrHelper::setFlashReadFilename(std::string filename) { - flashRead.filename = filename; -} - -void StrHelper::setDownloadFpgaImage(std::string filename) { - fpgaDownload.fileName = filename; -} - -ReturnValue_t StrHelper::startFlashWrite(std::string fullname, uint8_t region, - uint32_t address) { - ReturnValue_t result = checkPath(fullname); - if (result != RETURN_OK) { - return result; - } - flashWrite.fullname = fullname; - if(not std::filesystem::exists(flashWrite.fullname)) { - return FILE_NOT_EXISTS; - } - flashWrite.address = address; - flashWrite.region = region; - internalState = InternalState::FLASH_WRITE; - semaphore.release(); - terminate = false; - return RETURN_OK; -} - -ReturnValue_t StrHelper::startFlashRead(std::string path, uint8_t region, - uint32_t address, uint32_t length) { - ReturnValue_t result = checkPath(path); - if (result != RETURN_OK) { - return result; - } - flashRead.path = path; - if(not std::filesystem::exists(flashRead.path)) { - return FILE_NOT_EXISTS; - } - flashRead.address = address; - flashRead.region = region; - flashRead.size = length; - internalState = InternalState::FLASH_READ; - semaphore.release(); - terminate = false; - return RETURN_OK; +ReturnValue_t StrHelper::startFlashRead(std::string path, uint8_t region, uint32_t address, + uint32_t length) { + ReturnValue_t result = checkPath(path); + if (result != RETURN_OK) { + return result; + } + flashRead.path = path; + if (not std::filesystem::exists(flashRead.path)) { + return FILE_NOT_EXISTS; + } + flashRead.address = address; + flashRead.region = region; + flashRead.size = length; + internalState = InternalState::FLASH_READ; + semaphore.release(); + terminate = false; + return RETURN_OK; } ReturnValue_t StrHelper::startFpgaDownload(std::string path, uint32_t startPosition, - uint32_t length) { - fpgaDownload.path = path; - fpgaDownload.startPosition = startPosition; - fpgaDownload.length = length; - internalState = InternalState::DOWNLOAD_FPGA_IMAGE; - semaphore.release(); - terminate = false; - return RETURN_OK; + uint32_t length) { + fpgaDownload.path = path; + fpgaDownload.startPosition = startPosition; + fpgaDownload.length = length; + internalState = InternalState::DOWNLOAD_FPGA_IMAGE; + semaphore.release(); + terminate = false; + return RETURN_OK; } ReturnValue_t StrHelper::startFpgaUpload(std::string uploadFile) { - fpgaUpload.uploadFile = uploadFile; - internalState = InternalState::UPLOAD_FPGA_IMAGE; - semaphore.release(); - terminate = false; - return RETURN_OK; + fpgaUpload.uploadFile = uploadFile; + internalState = InternalState::UPLOAD_FPGA_IMAGE; + semaphore.release(); + terminate = false; + return RETURN_OK; } ReturnValue_t StrHelper::performImageDownload() { - ReturnValue_t result; - struct DownloadActionRequest downloadReq; - uint32_t size = 0; - uint32_t retries = 0; - Timestamp timestamp; - std::string image = downloadImage.path + "/" + timestamp.str() + downloadImage.filename ; - std::ofstream file(image, std::ios_base::app | std::ios_base::out); - if(not std::filesystem::exists(image)) { - return FILE_CREATION_FAILED; + ReturnValue_t result; + struct DownloadActionRequest downloadReq; + uint32_t size = 0; + uint32_t retries = 0; + Timestamp timestamp; + std::string image = downloadImage.path + "/" + timestamp.str() + downloadImage.filename; + std::ofstream file(image, std::ios_base::app | std::ios_base::out); + if (not std::filesystem::exists(image)) { + return FILE_CREATION_FAILED; + } + downloadReq.position = 0; + while (downloadReq.position < ImageDownload::LAST_POSITION) { + if (terminate) { + return RETURN_OK; } - downloadReq.position = 0; - while(downloadReq.position < ImageDownload::LAST_POSITION) { - if (terminate) { - return RETURN_OK; - } - arc_pack_download_action_req(&downloadReq, commandBuffer, &size); - result = sendAndRead(size, downloadReq.position); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - result = checkActionReply(); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - result = checkReplyPosition(downloadReq.position); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - file.write(reinterpret_cast(datalinkLayer.getReply() + IMAGE_DATA_OFFSET), - IMAGE_DATA_SIZE); - downloadReq.position++; - retries = 0; + arc_pack_download_action_req(&downloadReq, commandBuffer, &size); + result = sendAndRead(size, downloadReq.position); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; } - file.close(); - return RETURN_OK; + result = checkActionReply(); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + result = checkReplyPosition(downloadReq.position); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + file.write(reinterpret_cast(datalinkLayer.getReply() + IMAGE_DATA_OFFSET), + IMAGE_DATA_SIZE); + downloadReq.position++; + retries = 0; + } + file.close(); + return RETURN_OK; } ReturnValue_t StrHelper::performImageUpload() { - ReturnValue_t result = RETURN_OK; - uint32_t size = 0; - uint32_t imageSize = 0; - struct UploadActionRequest uploadReq; - uploadReq.position = 0; - std::memset(&uploadReq.data, 0, sizeof(uploadReq.data)); - if (not std::filesystem::exists(uploadImage.uploadFile)) { - triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast(internalState)); - internalState = InternalState::IDLE; - return RETURN_FAILED; + ReturnValue_t result = RETURN_OK; + uint32_t size = 0; + uint32_t imageSize = 0; + struct UploadActionRequest uploadReq; + uploadReq.position = 0; + std::memset(&uploadReq.data, 0, sizeof(uploadReq.data)); + if (not std::filesystem::exists(uploadImage.uploadFile)) { + triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast(internalState)); + internalState = InternalState::IDLE; + return RETURN_FAILED; + } + std::ifstream file(uploadImage.uploadFile, std::ifstream::binary); + // Set position of next character to end of file input stream + file.seekg(0, file.end); + // tellg returns position of character in input stream + imageSize = file.tellg(); + while ((uploadReq.position + 1) * SIZE_IMAGE_PART < imageSize) { + if (terminate) { + return RETURN_OK; } - std::ifstream file(uploadImage.uploadFile, std::ifstream::binary); - // Set position of next character to end of file input stream - file.seekg(0, file.end); - // tellg returns position of character in input stream - imageSize = file.tellg(); - while((uploadReq.position + 1) * SIZE_IMAGE_PART < imageSize) { - if (terminate) { - return RETURN_OK; - } - file.seekg(uploadReq.position * SIZE_IMAGE_PART, file.beg); - file.read(reinterpret_cast(uploadReq.data), SIZE_IMAGE_PART); - arc_pack_upload_action_req(&uploadReq, commandBuffer, &size); - result = sendAndRead(size, uploadReq.position); - if (result != RETURN_OK) { - return RETURN_FAILED; - } - result = checkActionReply(); - if (result != RETURN_OK) { - return result; - } - uploadReq.position++; - } - std::memset(uploadReq.data, 0, sizeof(uploadReq.data)); - uint32_t remainder = imageSize - uploadReq.position * SIZE_IMAGE_PART; file.seekg(uploadReq.position * SIZE_IMAGE_PART, file.beg); - file.read(reinterpret_cast(uploadReq.data), remainder); - file.close(); - uploadReq.position++; + file.read(reinterpret_cast(uploadReq.data), SIZE_IMAGE_PART); arc_pack_upload_action_req(&uploadReq, commandBuffer, &size); result = sendAndRead(size, uploadReq.position); if (result != RETURN_OK) { - return RETURN_FAILED; + return RETURN_FAILED; } result = checkActionReply(); if (result != RETURN_OK) { - return result; + return result; } - return RETURN_OK; + uploadReq.position++; + } + std::memset(uploadReq.data, 0, sizeof(uploadReq.data)); + uint32_t remainder = imageSize - uploadReq.position * SIZE_IMAGE_PART; + file.seekg(uploadReq.position * SIZE_IMAGE_PART, file.beg); + file.read(reinterpret_cast(uploadReq.data), remainder); + file.close(); + uploadReq.position++; + arc_pack_upload_action_req(&uploadReq, commandBuffer, &size); + result = sendAndRead(size, uploadReq.position); + if (result != RETURN_OK) { + return RETURN_FAILED; + } + result = checkActionReply(); + if (result != RETURN_OK) { + return result; + } + return RETURN_OK; } ReturnValue_t StrHelper::performFlashWrite() { - ReturnValue_t result = RETURN_OK; - uint32_t size = 0; - uint32_t remainingBytes = 0; - uint32_t fileSize = 0; - struct WriteActionRequest req; - if (not std::filesystem::exists(flashWrite.fullname)) { - triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast(internalState)); - internalState = InternalState::IDLE; - return RETURN_FAILED; - } - std::ifstream file(flashWrite.fullname, std::ifstream::binary); - file.seekg(0, file.end); - fileSize = file.tellg(); - remainingBytes = fileSize; - req.region = flashWrite.region; - req.address = flashWrite.address; - req.length = MAX_FLASH_DATA; - while(remainingBytes >= MAX_FLASH_DATA) { - if (terminate) { - return RETURN_OK; - } - file.seekg(fileSize - remainingBytes, file.beg); - file.read(reinterpret_cast(req.data), MAX_FLASH_DATA); - arc_pack_write_action_req(&req, commandBuffer, &size); - result = sendAndRead(size, req.address); - if (result != RETURN_OK) { - return RETURN_FAILED; - } - result = checkFlashActionReply(req.region, req.address, req.length); - if (result != RETURN_OK) { - return result; - } - remainingBytes = remainingBytes - MAX_FLASH_DATA; + ReturnValue_t result = RETURN_OK; + uint32_t size = 0; + uint32_t remainingBytes = 0; + uint32_t fileSize = 0; + struct WriteActionRequest req; + if (not std::filesystem::exists(flashWrite.fullname)) { + triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast(internalState)); + internalState = InternalState::IDLE; + return RETURN_FAILED; + } + std::ifstream file(flashWrite.fullname, std::ifstream::binary); + file.seekg(0, file.end); + fileSize = file.tellg(); + remainingBytes = fileSize; + req.region = flashWrite.region; + req.address = flashWrite.address; + req.length = MAX_FLASH_DATA; + while (remainingBytes >= MAX_FLASH_DATA) { + if (terminate) { + return RETURN_OK; } file.seekg(fileSize - remainingBytes, file.beg); - file.read(reinterpret_cast(req.data), remainingBytes); - file.close(); + file.read(reinterpret_cast(req.data), MAX_FLASH_DATA); arc_pack_write_action_req(&req, commandBuffer, &size); result = sendAndRead(size, req.address); if (result != RETURN_OK) { - return RETURN_FAILED; + return RETURN_FAILED; } result = checkFlashActionReply(req.region, req.address, req.length); if (result != RETURN_OK) { - return result; + return result; } - return RETURN_OK; + remainingBytes = remainingBytes - MAX_FLASH_DATA; + } + file.seekg(fileSize - remainingBytes, file.beg); + file.read(reinterpret_cast(req.data), remainingBytes); + file.close(); + arc_pack_write_action_req(&req, commandBuffer, &size); + result = sendAndRead(size, req.address); + if (result != RETURN_OK) { + return RETURN_FAILED; + } + result = checkFlashActionReply(req.region, req.address, req.length); + if (result != RETURN_OK) { + return result; + } + return RETURN_OK; } ReturnValue_t StrHelper::performFlashRead() { - ReturnValue_t result; - struct ReadActionRequest req; - uint32_t bytesRead = 0; - uint32_t size = 0; - uint32_t retries = 0; - Timestamp timestamp; - std::string fullname = flashRead.path + "/" + timestamp.str() + flashRead.filename ; - std::ofstream file(fullname, std::ios_base::app | std::ios_base::out); - if (not std::filesystem::exists(fullname)) { - return FILE_CREATION_FAILED; + ReturnValue_t result; + struct ReadActionRequest req; + uint32_t bytesRead = 0; + uint32_t size = 0; + uint32_t retries = 0; + Timestamp timestamp; + std::string fullname = flashRead.path + "/" + timestamp.str() + flashRead.filename; + std::ofstream file(fullname, std::ios_base::app | std::ios_base::out); + if (not std::filesystem::exists(fullname)) { + return FILE_CREATION_FAILED; + } + req.region = flashRead.region; + while (bytesRead < flashRead.size) { + if (terminate) { + return RETURN_OK; } - req.region = flashRead.region; - while(bytesRead < flashRead.size) { - if (terminate) { - return RETURN_OK; - } - if ((flashRead.size - bytesRead) < MAX_FLASH_DATA) { - req.length = flashRead.size - bytesRead; - } - else { - req.length = MAX_FLASH_DATA; - } - req.address = flashRead.address + bytesRead; - arc_pack_read_action_req(&req, commandBuffer, &size); - result = sendAndRead(size, req.address); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - result = checkActionReply(); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - result = checkFlashActionReply(req.region, req.address, req.length); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - file.write(reinterpret_cast(datalinkLayer.getReply() + FLASH_READ_DATA_OFFSET), - req.length); - bytesRead += req.length; - retries = 0; + if ((flashRead.size - bytesRead) < MAX_FLASH_DATA) { + req.length = flashRead.size - bytesRead; + } else { + req.length = MAX_FLASH_DATA; } - file.close(); - return RETURN_OK; + req.address = flashRead.address + bytesRead; + arc_pack_read_action_req(&req, commandBuffer, &size); + result = sendAndRead(size, req.address); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + result = checkActionReply(); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + result = checkFlashActionReply(req.region, req.address, req.length); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + file.write(reinterpret_cast(datalinkLayer.getReply() + FLASH_READ_DATA_OFFSET), + req.length); + bytesRead += req.length; + retries = 0; + } + file.close(); + return RETURN_OK; } ReturnValue_t StrHelper::performFpgaDownload() { - ReturnValue_t result; - struct DownloadFPGAImageActionRequest req; - uint32_t size = 0; - uint32_t retries = 0; - Timestamp timestamp; - std::string image = fpgaDownload.path + "/" + timestamp.str() + fpgaDownload.fileName; - std::ofstream file(image, std::ios_base::app | std::ios_base::out); - if(not std::filesystem::exists(image)) { - return FILE_CREATION_FAILED; + ReturnValue_t result; + struct DownloadFPGAImageActionRequest req; + uint32_t size = 0; + uint32_t retries = 0; + Timestamp timestamp; + std::string image = fpgaDownload.path + "/" + timestamp.str() + fpgaDownload.fileName; + std::ofstream file(image, std::ios_base::app | std::ios_base::out); + if (not std::filesystem::exists(image)) { + return FILE_CREATION_FAILED; + } + req.pos = fpgaDownload.startPosition; + while (req.pos < fpgaDownload.length) { + if (terminate) { + return RETURN_OK; } - req.pos = fpgaDownload.startPosition; - while(req.pos < fpgaDownload.length) { - if (terminate) { - return RETURN_OK; - } - if (fpgaDownload.length - req.pos >= FpgaDownload::MAX_DATA) { - req.length = FpgaDownload::MAX_DATA; - } - else { - req.length = fpgaDownload.length - req.pos; - } - arc_pack_downloadfpgaimage_action_req(&req, commandBuffer, &size); - result = sendAndRead(size, req.pos); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - result = checkFpgaActionReply(req.pos, req.length); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - file.write(reinterpret_cast(datalinkLayer.getReply() + FpgaDownload::DATA_OFFSET), - req.length); - req.pos += req.length; - retries = 0; + if (fpgaDownload.length - req.pos >= FpgaDownload::MAX_DATA) { + req.length = FpgaDownload::MAX_DATA; + } else { + req.length = fpgaDownload.length - req.pos; } - file.close(); - return RETURN_OK; + arc_pack_downloadfpgaimage_action_req(&req, commandBuffer, &size); + result = sendAndRead(size, req.pos); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + result = checkFpgaActionReply(req.pos, req.length); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + file.write(reinterpret_cast(datalinkLayer.getReply() + FpgaDownload::DATA_OFFSET), + req.length); + req.pos += req.length; + retries = 0; + } + file.close(); + return RETURN_OK; } ReturnValue_t StrHelper::performFpgaUpload() { - ReturnValue_t result = RETURN_OK; - uint32_t commandSize = 0; - uint32_t bytesUploaded = 0; - uint32_t fileSize = 0; - struct UploadFPGAImageActionRequest req; - if (not std::filesystem::exists(fpgaUpload.uploadFile)) { - triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast(internalState)); - internalState = InternalState::IDLE; - return RETURN_FAILED; + ReturnValue_t result = RETURN_OK; + uint32_t commandSize = 0; + uint32_t bytesUploaded = 0; + uint32_t fileSize = 0; + struct UploadFPGAImageActionRequest req; + if (not std::filesystem::exists(fpgaUpload.uploadFile)) { + triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast(internalState)); + internalState = InternalState::IDLE; + return RETURN_FAILED; + } + std::ifstream file(flashWrite.fullname, std::ifstream::binary); + file.seekg(0, file.end); + fileSize = file.tellg(); + req.pos = 0; + while (bytesUploaded <= fileSize) { + if (terminate) { + return RETURN_OK; } - std::ifstream file(flashWrite.fullname, std::ifstream::binary); - file.seekg(0, file.end); - fileSize = file.tellg(); - req.pos = 0; - while(bytesUploaded <= fileSize) { - if (terminate) { - return RETURN_OK; - } - if (fileSize - bytesUploaded > FpgaUpload::MAX_DATA) { - req.length = FpgaUpload::MAX_DATA; - } - else { - req.length = fileSize - bytesUploaded; - } - file.seekg(bytesUploaded, file.beg); - file.read(reinterpret_cast(req.data), req.length); - arc_pack_uploadfpgaimage_action_req(&req, commandBuffer, &commandSize); - result = sendAndRead(commandSize, req.pos); - if (result != RETURN_OK) { - return RETURN_FAILED; - } - result = checkFpgaActionReply(req.pos, req.length); - if (result != RETURN_OK) { - return result; - } - bytesUploaded += req.length; + if (fileSize - bytesUploaded > FpgaUpload::MAX_DATA) { + req.length = FpgaUpload::MAX_DATA; + } else { + req.length = fileSize - bytesUploaded; } - return RETURN_OK; + file.seekg(bytesUploaded, file.beg); + file.read(reinterpret_cast(req.data), req.length); + arc_pack_uploadfpgaimage_action_req(&req, commandBuffer, &commandSize); + result = sendAndRead(commandSize, req.pos); + if (result != RETURN_OK) { + return RETURN_FAILED; + } + result = checkFpgaActionReply(req.pos, req.length); + if (result != RETURN_OK) { + return result; + } + bytesUploaded += req.length; + } + return RETURN_OK; } ReturnValue_t StrHelper::sendAndRead(size_t size, uint32_t parameter) { - ReturnValue_t result = RETURN_OK; - ReturnValue_t decResult = RETURN_OK; - size_t receivedDataLen = 0; - uint8_t *receivedData = nullptr; - size_t bytesLeft = 0; - uint32_t missedReplies = 0; - datalinkLayer.encodeFrame(commandBuffer, size); - result = uartComIF->sendMessage(comCookie, datalinkLayer.getEncodedFrame(), - datalinkLayer.getEncodedLength()); + ReturnValue_t result = RETURN_OK; + ReturnValue_t decResult = RETURN_OK; + size_t receivedDataLen = 0; + uint8_t* receivedData = nullptr; + size_t bytesLeft = 0; + uint32_t missedReplies = 0; + datalinkLayer.encodeFrame(commandBuffer, size); + result = uartComIF->sendMessage(comCookie, datalinkLayer.getEncodedFrame(), + datalinkLayer.getEncodedLength()); + if (result != RETURN_OK) { + sif::warning << "StrHelper::sendAndRead: Failed to send packet" << std::endl; + triggerEvent(STR_HELPER_SENDING_PACKET_FAILED, result, parameter); + return RETURN_FAILED; + } + decResult = ArcsecDatalinkLayer::DEC_IN_PROGRESS; + while (decResult == ArcsecDatalinkLayer::DEC_IN_PROGRESS) { + result = uartComIF->requestReceiveMessage(comCookie, StarTracker::MAX_FRAME_SIZE * 2 + 2); if (result != RETURN_OK) { - sif::warning << "StrHelper::sendAndRead: Failed to send packet" << std::endl; - triggerEvent(STR_HELPER_SENDING_PACKET_FAILED, result, parameter); - return RETURN_FAILED; + sif::warning << "StrHelper::sendAndRead: Failed to request reply" << std::endl; + triggerEvent(STR_HELPER_REQUESTING_MSG_FAILED, result, parameter); + return RETURN_FAILED; } - decResult = ArcsecDatalinkLayer::DEC_IN_PROGRESS; - while (decResult == ArcsecDatalinkLayer::DEC_IN_PROGRESS) { - result = uartComIF->requestReceiveMessage(comCookie, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - if (result != RETURN_OK) { - sif::warning << "StrHelper::sendAndRead: Failed to request reply" << std::endl; - triggerEvent(STR_HELPER_REQUESTING_MSG_FAILED, result, parameter); - return RETURN_FAILED; - } - result = uartComIF->readReceivedMessage(comCookie, &receivedData, &receivedDataLen); - if (result != RETURN_OK) { - sif::warning << "StrHelper::sendAndRead: Failed to read received message" << std::endl; - triggerEvent(STR_HELPER_READING_REPLY_FAILED, result, parameter); - return RETURN_FAILED; - } - if (receivedDataLen == 0 && missedReplies < MAX_POLLS) { - missedReplies++; - continue; - } - else if ((receivedDataLen == 0) && (missedReplies >= MAX_POLLS)) { - triggerEvent(STR_HELPER_NO_REPLY, parameter); - return RETURN_FAILED; - } - else { - missedReplies = 0; - } - decResult = datalinkLayer.decodeFrame(receivedData, receivedDataLen, &bytesLeft); - if (bytesLeft != 0) { - // This should never happen - sif::warning << "StrHelper::sendAndRead: Bytes left after decoding" << std::endl; - triggerEvent(STR_HELPER_COM_ERROR, result, parameter); - return RETURN_FAILED; - } + result = uartComIF->readReceivedMessage(comCookie, &receivedData, &receivedDataLen); + if (result != RETURN_OK) { + sif::warning << "StrHelper::sendAndRead: Failed to read received message" << std::endl; + triggerEvent(STR_HELPER_READING_REPLY_FAILED, result, parameter); + return RETURN_FAILED; } - if (decResult != RETURN_OK) { - triggerEvent(STR_HELPER_DEC_ERROR, decResult, parameter); - return RETURN_FAILED; + if (receivedDataLen == 0 && missedReplies < MAX_POLLS) { + missedReplies++; + continue; + } else if ((receivedDataLen == 0) && (missedReplies >= MAX_POLLS)) { + triggerEvent(STR_HELPER_NO_REPLY, parameter); + return RETURN_FAILED; + } else { + missedReplies = 0; } - return RETURN_OK; + decResult = datalinkLayer.decodeFrame(receivedData, receivedDataLen, &bytesLeft); + if (bytesLeft != 0) { + // This should never happen + sif::warning << "StrHelper::sendAndRead: Bytes left after decoding" << std::endl; + triggerEvent(STR_HELPER_COM_ERROR, result, parameter); + return RETURN_FAILED; + } + } + if (decResult != RETURN_OK) { + triggerEvent(STR_HELPER_DEC_ERROR, decResult, parameter); + return RETURN_FAILED; + } + return RETURN_OK; } ReturnValue_t StrHelper::checkActionReply() { - uint8_t type = datalinkLayer.getReplyFrameType(); - if (type != TMTC_ACTIONREPLY) { - sif::warning << "StrHelper::checkActionReply: Received reply with invalid type ID" - << std::endl; - return INVALID_TYPE_ID; - } - uint8_t status = datalinkLayer.getStatusField(); - if (status != ArcsecDatalinkLayer::STATUS_OK) { - sif::warning << "StrHelper::checkActionReply: Status failure: " - << static_cast(status) << std::endl; - return STATUS_ERROR; - } - return RETURN_OK; + uint8_t type = datalinkLayer.getReplyFrameType(); + if (type != TMTC_ACTIONREPLY) { + sif::warning << "StrHelper::checkActionReply: Received reply with invalid type ID" << std::endl; + return INVALID_TYPE_ID; + } + uint8_t status = datalinkLayer.getStatusField(); + if (status != ArcsecDatalinkLayer::STATUS_OK) { + sif::warning << "StrHelper::checkActionReply: Status failure: " + << static_cast(status) << std::endl; + return STATUS_ERROR; + } + return RETURN_OK; } ReturnValue_t StrHelper::checkReplyPosition(uint32_t expectedPosition) { - uint32_t receivedPosition = 0; - std::memcpy(&receivedPosition, datalinkLayer.getReply() + POS_OFFSET, sizeof(receivedPosition)); - if (receivedPosition != expectedPosition) { - triggerEvent(POSITION_MISMATCH, receivedPosition); - return RETURN_FAILED; - } - return RETURN_OK; + uint32_t receivedPosition = 0; + std::memcpy(&receivedPosition, datalinkLayer.getReply() + POS_OFFSET, sizeof(receivedPosition)); + if (receivedPosition != expectedPosition) { + triggerEvent(POSITION_MISMATCH, receivedPosition); + return RETURN_FAILED; + } + return RETURN_OK; } ReturnValue_t StrHelper::checkFlashActionReply(uint8_t region_, uint32_t address_, - uint16_t length_) { - ReturnValue_t result = RETURN_OK; - result = checkActionReply(); - if (result != RETURN_OK) { - return result; - } - const uint8_t* data = datalinkLayer.getReply(); - uint8_t region = *(data + REGION_OFFSET); - uint32_t address; - const uint8_t* addressData = data + ADDRESS_OFFSET; - size_t size = sizeof(address); - result = SerializeAdapter::deSerialize(&address, &addressData, &size, - SerializeIF::Endianness::LITTLE); - if (result != RETURN_OK) { - sif::warning << "StrHelper::checkFlashActionReply: Deserialization of address failed" - << std::endl; - return result; - } - uint16_t length = 0; - size = sizeof(length); - const uint8_t* lengthData = data + LENGTH_OFFSET; - result = SerializeAdapter::deSerialize(&length, lengthData, &size, - SerializeIF::Endianness::LITTLE); - if (result != RETURN_OK) { - sif::warning << "StrHelper::checkFlashActionReply: Deserialization of length failed" - << std::endl; - } - if (region != region_) { - return REGION_MISMATCH; - } - if (address != address_) { - return ADDRESS_MISMATCH; - } - if (length != length_) { - return LENGTH_MISMATCH; - } - return RETURN_OK; + uint16_t length_) { + ReturnValue_t result = RETURN_OK; + result = checkActionReply(); + if (result != RETURN_OK) { + return result; + } + const uint8_t* data = datalinkLayer.getReply(); + uint8_t region = *(data + REGION_OFFSET); + uint32_t address; + const uint8_t* addressData = data + ADDRESS_OFFSET; + size_t size = sizeof(address); + result = + SerializeAdapter::deSerialize(&address, &addressData, &size, SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StrHelper::checkFlashActionReply: Deserialization of address failed" + << std::endl; + return result; + } + uint16_t length = 0; + size = sizeof(length); + const uint8_t* lengthData = data + LENGTH_OFFSET; + result = + SerializeAdapter::deSerialize(&length, lengthData, &size, SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StrHelper::checkFlashActionReply: Deserialization of length failed" + << std::endl; + } + if (region != region_) { + return REGION_MISMATCH; + } + if (address != address_) { + return ADDRESS_MISMATCH; + } + if (length != length_) { + return LENGTH_MISMATCH; + } + return RETURN_OK; } -ReturnValue_t StrHelper::checkFpgaActionReply(uint32_t expectedPosition, - uint32_t expectedLength) { - ReturnValue_t result = RETURN_OK; - result = checkActionReply(); - if (result != RETURN_OK) { - return result; - } - const uint8_t* data = datalinkLayer.getReply() + ACTION_DATA_OFFSET; - uint32_t position; - size_t size = sizeof(position); - result = SerializeAdapter::deSerialize(&position, &data, &size, - SerializeIF::Endianness::LITTLE); - if (result != RETURN_OK) { - sif::warning << "StrHelper::checkFpgaActionReply: Deserialization of position failed" - << std::endl; - return result; - } - uint32_t length; - size = sizeof(length); - result = SerializeAdapter::deSerialize(&length, &data, &size, - SerializeIF::Endianness::LITTLE); - if (result != RETURN_OK) { - sif::warning << "StrHelper::checkFpgaActionReply: Deserialization of length failed" - << std::endl; - return result; - } +ReturnValue_t StrHelper::checkFpgaActionReply(uint32_t expectedPosition, uint32_t expectedLength) { + ReturnValue_t result = RETURN_OK; + result = checkActionReply(); + if (result != RETURN_OK) { return result; + } + const uint8_t* data = datalinkLayer.getReply() + ACTION_DATA_OFFSET; + uint32_t position; + size_t size = sizeof(position); + result = SerializeAdapter::deSerialize(&position, &data, &size, SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StrHelper::checkFpgaActionReply: Deserialization of position failed" + << std::endl; + return result; + } + uint32_t length; + size = sizeof(length); + result = SerializeAdapter::deSerialize(&length, &data, &size, SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StrHelper::checkFpgaActionReply: Deserialization of length failed" + << std::endl; + return result; + } + return result; } ReturnValue_t StrHelper::checkPath(std::string name) { - if (name.substr(0, sizeof(SdCardManager::SD_0_MOUNT_POINT)) - == std::string(SdCardManager::SD_0_MOUNT_POINT)) { - if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { - sif::warning << "StrHelper::checkPath: SD card 0 not mounted" << std::endl; - return SD_NOT_MOUNTED; - } - } else if (name.substr(0, sizeof(SdCardManager::SD_1_MOUNT_POINT)) - == std::string(SdCardManager::SD_1_MOUNT_POINT)) { - if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { - sif::warning << "StrHelper::checkPath: SD card 1 not mounted" << std::endl; - return SD_NOT_MOUNTED; - } + if (name.substr(0, sizeof(SdCardManager::SD_0_MOUNT_POINT)) == + std::string(SdCardManager::SD_0_MOUNT_POINT)) { + if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { + sif::warning << "StrHelper::checkPath: SD card 0 not mounted" << std::endl; + return SD_NOT_MOUNTED; } - return RETURN_OK; + } else if (name.substr(0, sizeof(SdCardManager::SD_1_MOUNT_POINT)) == + std::string(SdCardManager::SD_1_MOUNT_POINT)) { + if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { + sif::warning << "StrHelper::checkPath: SD card 1 not mounted" << std::endl; + return SD_NOT_MOUNTED; + } + } + return RETURN_OK; } diff --git a/bsp_q7s/devices/startracker/StrHelper.h b/bsp_q7s/devices/startracker/StrHelper.h index e140a4d6..c08aaae1 100644 --- a/bsp_q7s/devices/startracker/StrHelper.h +++ b/bsp_q7s/devices/startracker/StrHelper.h @@ -2,396 +2,396 @@ #define BSP_Q7S_DEVICES_STRHELPER_H_ #include + #include "ArcsecDatalinkLayer.h" -#include "fsfw/osal/linux/BinarySemaphore.h" #include "bsp_q7s/memory/SdCardManager.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/devicehandlers/CookieIF.h" #include "fsfw/objectmanager/SystemObject.h" +#include "fsfw/osal/linux/BinarySemaphore.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw_hal/linux/uart/UartComIF.h" -#include "fsfw/devicehandlers/CookieIF.h" extern "C" { - #include "thirdparty/arcsec_star_tracker/common/generated/tmtcstructs.h" - #include "thirdparty/arcsec_star_tracker/client/generated/actionreq.h" +#include "thirdparty/arcsec_star_tracker/client/generated/actionreq.h" +#include "thirdparty/arcsec_star_tracker/common/generated/tmtcstructs.h" } /** * @brief Helper class for the star tracker handler to accelerate large data transfers. */ -class StrHelper: public SystemObject, public ExecutableObjectIF, public HasReturnvaluesIF { -public: +class StrHelper : public SystemObject, public ExecutableObjectIF, public HasReturnvaluesIF { + public: + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_HELPER; - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_HELPER; + //! [EXPORT] : [COMMENT] Image upload failed + static const Event IMAGE_UPLOAD_FAILED = MAKE_EVENT(0, severity::LOW); + //! [EXPORT] : [COMMENT] Image download failed + static const Event IMAGE_DOWNLOAD_FAILED = MAKE_EVENT(1, severity::LOW); + //! [EXPORT] : [COMMENT] Uploading image to star tracker was successfulop + static const Event IMAGE_UPLOAD_SUCCESSFUL = MAKE_EVENT(2, severity::LOW); + //! [EXPORT] : [COMMENT] Image download was successful + static const Event IMAGE_DOWNLOAD_SUCCESSFUL = MAKE_EVENT(3, severity::LOW); + //! [EXPORT] : [COMMENT] Finished flash write procedure successfully + static const Event FLASH_WRITE_SUCCESSFUL = MAKE_EVENT(4, severity::LOW); + //! [EXPORT] : [COMMENT] Finished flash read procedure successfully + static const Event FLASH_READ_SUCCESSFUL = MAKE_EVENT(5, severity::LOW); + //! [EXPORT] : [COMMENT] Flash write procedure failed + static const Event FLASH_WRITE_FAILED = MAKE_EVENT(6, severity::LOW); + //! [EXPORT] : [COMMENT] Flash read procedure failed + static const Event FLASH_READ_FAILED = MAKE_EVENT(7, severity::LOW); + //! [EXPORT] : [COMMENT] Download of FPGA image successful + static const Event FPGA_DOWNLOAD_SUCCESSFUL = MAKE_EVENT(8, severity::LOW); + //! [EXPORT] : [COMMENT] Download of FPGA image failed + static const Event FPGA_DOWNLOAD_FAILED = MAKE_EVENT(9, severity::LOW); + //! [EXPORT] : [COMMENT] Upload of FPGA image successful + static const Event FPGA_UPLOAD_SUCCESSFUL = MAKE_EVENT(10, severity::LOW); + //! [EXPORT] : [COMMENT] Upload of FPGA image failed + static const Event FPGA_UPLOAD_FAILED = MAKE_EVENT(11, severity::LOW); + //! [EXPORT] : [COMMENT] Failed to read communication interface reply data + //! P1: Return code of failed communication interface read call + //! P1: Upload/download position for which the read call failed + static const Event STR_HELPER_READING_REPLY_FAILED = MAKE_EVENT(12, severity::LOW); + //! [EXPORT] : [COMMENT] Unexpected stop of decoding sequence + //! P1: Return code of failed communication interface read call + //! P1: Upload/download position for which the read call failed + static const Event STR_HELPER_COM_ERROR = MAKE_EVENT(13, severity::LOW); + //! [EXPORT] : [COMMENT] Star tracker did not send replies (maybe device is powered off) + //! P1: Position of upload or download packet for which no reply was sent + static const Event STR_HELPER_NO_REPLY = MAKE_EVENT(14, severity::LOW); + //! [EXPORT] : [COMMENT] Error during decoding of received reply occurred + // P1: Return value of decoding function + // P2: Position of upload/download packet, or address of flash write/read request + static const Event STR_HELPER_DEC_ERROR = MAKE_EVENT(15, severity::LOW); + //! [EXPORT] : [COMMENT] Position mismatch + //! P1: The expected position and thus the position for which the image upload/download failed + static const Event POSITION_MISMATCH = MAKE_EVENT(16, severity::LOW); + //! [EXPORT] : [COMMENT] Specified file does not exist + //! P1: Internal state of str helper + static const Event STR_HELPER_FILE_NOT_EXISTS = MAKE_EVENT(17, severity::LOW); + //! [EXPORT] : [COMMENT] Sending packet to star tracker failed + //! P1: Return code of communication interface sendMessage function + //! P2: Position of upload/download packet, or address of flash write/read request for which + //! sending failed + static const Event STR_HELPER_SENDING_PACKET_FAILED = MAKE_EVENT(18, severity::LOW); + //! [EXPORT] : [COMMENT] Communication interface requesting reply failed + //! P1: Return code of failed request + //! P1: Upload/download position, or address of flash write/read request for which transmission + //! failed + static const Event STR_HELPER_REQUESTING_MSG_FAILED = MAKE_EVENT(19, severity::LOW); - //! [EXPORT] : [COMMENT] Image upload failed - static const Event IMAGE_UPLOAD_FAILED = MAKE_EVENT(0, severity::LOW); - //! [EXPORT] : [COMMENT] Image download failed - static const Event IMAGE_DOWNLOAD_FAILED = MAKE_EVENT(1, severity::LOW); - //! [EXPORT] : [COMMENT] Uploading image to star tracker was successfulop - static const Event IMAGE_UPLOAD_SUCCESSFUL = MAKE_EVENT(2, severity::LOW); - //! [EXPORT] : [COMMENT] Image download was successful - static const Event IMAGE_DOWNLOAD_SUCCESSFUL = MAKE_EVENT(3, severity::LOW); - //! [EXPORT] : [COMMENT] Finished flash write procedure successfully - static const Event FLASH_WRITE_SUCCESSFUL = MAKE_EVENT(4, severity::LOW); - //! [EXPORT] : [COMMENT] Finished flash read procedure successfully - static const Event FLASH_READ_SUCCESSFUL = MAKE_EVENT(5, severity::LOW); - //! [EXPORT] : [COMMENT] Flash write procedure failed - static const Event FLASH_WRITE_FAILED = MAKE_EVENT(6, severity::LOW); - //! [EXPORT] : [COMMENT] Flash read procedure failed - static const Event FLASH_READ_FAILED = MAKE_EVENT(7, severity::LOW); - //! [EXPORT] : [COMMENT] Download of FPGA image successful - static const Event FPGA_DOWNLOAD_SUCCESSFUL = MAKE_EVENT(8, severity::LOW); - //! [EXPORT] : [COMMENT] Download of FPGA image failed - static const Event FPGA_DOWNLOAD_FAILED = MAKE_EVENT(9, severity::LOW); - //! [EXPORT] : [COMMENT] Upload of FPGA image successful - static const Event FPGA_UPLOAD_SUCCESSFUL = MAKE_EVENT(10, severity::LOW); - //! [EXPORT] : [COMMENT] Upload of FPGA image failed - static const Event FPGA_UPLOAD_FAILED = MAKE_EVENT(11, severity::LOW); - //! [EXPORT] : [COMMENT] Failed to read communication interface reply data - //!P1: Return code of failed communication interface read call - //!P1: Upload/download position for which the read call failed - static const Event STR_HELPER_READING_REPLY_FAILED = MAKE_EVENT(12, severity::LOW); - //! [EXPORT] : [COMMENT] Unexpected stop of decoding sequence - //!P1: Return code of failed communication interface read call - //!P1: Upload/download position for which the read call failed - static const Event STR_HELPER_COM_ERROR = MAKE_EVENT(13, severity::LOW); - //! [EXPORT] : [COMMENT] Star tracker did not send replies (maybe device is powered off) - //!P1: Position of upload or download packet for which no reply was sent - static const Event STR_HELPER_NO_REPLY = MAKE_EVENT(14, severity::LOW); - //! [EXPORT] : [COMMENT] Error during decoding of received reply occurred - //P1: Return value of decoding function - //P2: Position of upload/download packet, or address of flash write/read request - static const Event STR_HELPER_DEC_ERROR = MAKE_EVENT(15, severity::LOW); - //! [EXPORT] : [COMMENT] Position mismatch - //! P1: The expected position and thus the position for which the image upload/download failed - static const Event POSITION_MISMATCH = MAKE_EVENT(16, severity::LOW); - //! [EXPORT] : [COMMENT] Specified file does not exist - //!P1: Internal state of str helper - static const Event STR_HELPER_FILE_NOT_EXISTS = MAKE_EVENT(17, severity::LOW); - //! [EXPORT] : [COMMENT] Sending packet to star tracker failed - //!P1: Return code of communication interface sendMessage function - //!P2: Position of upload/download packet, or address of flash write/read request for which sending failed - static const Event STR_HELPER_SENDING_PACKET_FAILED = MAKE_EVENT(18, severity::LOW); - //! [EXPORT] : [COMMENT] Communication interface requesting reply failed - //!P1: Return code of failed request - //!P1: Upload/download position, or address of flash write/read request for which transmission failed - static const Event STR_HELPER_REQUESTING_MSG_FAILED = MAKE_EVENT(19, severity::LOW); + StrHelper(object_id_t objectId); + virtual ~StrHelper(); - StrHelper(object_id_t objectId); - virtual ~StrHelper(); + ReturnValue_t initialize() override; + ReturnValue_t performOperation(uint8_t operationCode = 0) override; - ReturnValue_t initialize() override; - ReturnValue_t performOperation(uint8_t operationCode = 0) override; + ReturnValue_t setComIF(DeviceCommunicationIF* communicationInterface_); + void setComCookie(CookieIF* comCookie_); - ReturnValue_t setComIF(DeviceCommunicationIF* communicationInterface_); - void setComCookie(CookieIF* comCookie_); + /** + * @brief Starts sequence to upload image to star tracker + * + * @param uploadImage_ Name including absolute path of the image to upload. Must be previously + * transferred to the OBC with the CFDP protocol. + */ + ReturnValue_t startImageUpload(std::string uploadImage_); - /** - * @brief Starts sequence to upload image to star tracker - * - * @param uploadImage_ Name including absolute path of the image to upload. Must be previously - * transferred to the OBC with the CFDP protocol. - */ - ReturnValue_t startImageUpload(std::string uploadImage_); + /** + * @brief Calling this function initiates the download of an image from the star tracker. + * + * @param path Path where downloaded image will be stored + */ + ReturnValue_t startImageDownload(std::string path); - /** - * @brief Calling this function initiates the download of an image from the star tracker. - * - * @param path Path where downloaded image will be stored - */ - ReturnValue_t startImageDownload(std::string path); + /** + * @brief Starts the flash write procedure + * + * @param fullname Full name including absolute path of file to write to flash + * @param region Region ID of flash region to write to + * @param address Start address of flash write procedure + */ + ReturnValue_t startFlashWrite(std::string fullname, uint8_t region, uint32_t address); - /** - * @brief Starts the flash write procedure - * - * @param fullname Full name including absolute path of file to write to flash - * @param region Region ID of flash region to write to - * @param address Start address of flash write procedure - */ - ReturnValue_t startFlashWrite(std::string fullname, uint8_t region, uint32_t address); + /** + * @brief Starts the flash read procedure + * + * @param path Path where file with read flash data will be created + * @param region Region ID of flash region to read from + * @param address Start address of flash section to read + * @param length Number of bytes to read from flash + */ + ReturnValue_t startFlashRead(std::string path, uint8_t region, uint32_t address, uint32_t length); - /** - * @brief Starts the flash read procedure - * - * @param path Path where file with read flash data will be created - * @param region Region ID of flash region to read from - * @param address Start address of flash section to read - * @param length Number of bytes to read from flash - */ - ReturnValue_t startFlashRead(std::string path, uint8_t region, uint32_t address, - uint32_t length); + /** + * @brief Starts the download of the FPGA image + * + * @param path The path where the file with the downloaded data will be created + * @param startPosition Offset in fpga image to read from + * @param length Number of bytes to dwonload from the FPGA image + * + */ + ReturnValue_t startFpgaDownload(std::string path, uint32_t startPosition, uint32_t length); - /** - * @brief Starts the download of the FPGA image - * - * @param path The path where the file with the downloaded data will be created - * @param startPosition Offset in fpga image to read from - * @param length Number of bytes to dwonload from the FPGA image - * - */ - ReturnValue_t startFpgaDownload(std::string path, uint32_t startPosition, uint32_t length); + /** + * @brief Starts upload of new image to FPGA + * + * @param uploadFile Full name of file containing FPGA image data + */ + ReturnValue_t startFpgaUpload(std::string uploadFile); - /** - * @brief Starts upload of new image to FPGA - * - * @param uploadFile Full name of file containing FPGA image data - */ - ReturnValue_t startFpgaUpload(std::string uploadFile); + /** + * @brief Can be used to interrupt a running data transfer. + */ + void stopProcess(); - /** - * @brief Can be used to interrupt a running data transfer. - */ - void stopProcess(); + /** + * @brief Changes the dafault name of downloaded images + */ + void setDownloadImageName(std::string filename); - /** - * @brief Changes the dafault name of downloaded images - */ - void setDownloadImageName(std::string filename); + /** + * @brief Sets the name of the file which will be created to store the data read from flash + */ + void setFlashReadFilename(std::string filename); - /** - * @brief Sets the name of the file which will be created to store the data read from flash - */ - void setFlashReadFilename(std::string filename); + /** + * @brief Set download FPGA image name + */ + void setDownloadFpgaImage(std::string filename); - /** - * @brief Set download FPGA image name - */ - void setDownloadFpgaImage(std::string filename); + private: + static const uint8_t INTERFACE_ID = CLASS_ID::STR_HELPER; -private: + //! [EXPORT] : [COMMENT] SD card specified in 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] Specified path does not exist + static const ReturnValue_t PATH_NOT_EXISTS = MAKE_RETURN_CODE(0xA2); + //! [EXPORT] : [COMMENT] Failed to create download image or read flash file + static const ReturnValue_t FILE_CREATION_FAILED = MAKE_RETURN_CODE(0xA3); + //! [EXPORT] : [COMMENT] Region in flash write/read reply does not match expected region + static const ReturnValue_t REGION_MISMATCH = MAKE_RETURN_CODE(0xA4); + //! [EXPORT] : [COMMENT] Address in flash write/read reply does not match expected address + static const ReturnValue_t ADDRESS_MISMATCH = MAKE_RETURN_CODE(0xA5); + //! [EXPORT] : [COMMENT] Length in flash write/read reply does not match expected length + static const ReturnValue_t LENGTH_MISMATCH = MAKE_RETURN_CODE(0xA6); + //! [EXPORT] : [COMMENT] Status field in reply signals error + static const ReturnValue_t STATUS_ERROR = MAKE_RETURN_CODE(0xA7); + //! [EXPORT] : [COMMENT] Reply has invalid type ID (should be of action reply type) + static const ReturnValue_t INVALID_TYPE_ID = MAKE_RETURN_CODE(0xA8); - static const uint8_t INTERFACE_ID = CLASS_ID::STR_HELPER; + // Size of one image part which can be sent per action request + static const size_t SIZE_IMAGE_PART = 1024; - //! [EXPORT] : [COMMENT] SD card specified in 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] Specified path does not exist - static const ReturnValue_t PATH_NOT_EXISTS = MAKE_RETURN_CODE(0xA2); - //! [EXPORT] : [COMMENT] Failed to create download image or read flash file - static const ReturnValue_t FILE_CREATION_FAILED = MAKE_RETURN_CODE(0xA3); - //! [EXPORT] : [COMMENT] Region in flash write/read reply does not match expected region - static const ReturnValue_t REGION_MISMATCH = MAKE_RETURN_CODE(0xA4); - //! [EXPORT] : [COMMENT] Address in flash write/read reply does not match expected address - static const ReturnValue_t ADDRESS_MISMATCH = MAKE_RETURN_CODE(0xA5); - //! [EXPORT] : [COMMENT] Length in flash write/read reply does not match expected length - static const ReturnValue_t LENGTH_MISMATCH = MAKE_RETURN_CODE(0xA6); - //! [EXPORT] : [COMMENT] Status field in reply signals error - static const ReturnValue_t STATUS_ERROR = MAKE_RETURN_CODE(0xA7); - //! [EXPORT] : [COMMENT] Reply has invalid type ID (should be of action reply type) - static const ReturnValue_t INVALID_TYPE_ID = MAKE_RETURN_CODE(0xA8); + class ImageDownload { + public: + static const uint32_t LAST_POSITION = 4095; + }; - // Size of one image part which can be sent per action request - static const size_t SIZE_IMAGE_PART = 1024; + class FpgaDownload { + public: + static const uint16_t MAX_DATA = 1024; + static const uint8_t DATA_OFFSET = 10; + // Start position of fpga image part to download + uint32_t startPosition = 0; + // Length of image part to download + uint32_t length = 0; + // Path where downloaded FPGA image will be stored + std::string path; + // Name of file containing downloaded FPGA image + std::string fileName = "fpgaimage.bin"; + }; + FpgaDownload fpgaDownload; - class ImageDownload { - public: - static const uint32_t LAST_POSITION = 4095; - }; + class FpgaUpload { + public: + static const uint32_t MAX_DATA = 1024; + // Full name of file to upload + std::string uploadFile; + }; + FpgaUpload fpgaUpload; - class FpgaDownload { - public: - static const uint16_t MAX_DATA = 1024; - static const uint8_t DATA_OFFSET = 10; - // Start position of fpga image part to download - uint32_t startPosition = 0; - // Length of image part to download - uint32_t length = 0; - // Path where downloaded FPGA image will be stored - std::string path; - // Name of file containing downloaded FPGA image - std::string fileName = "fpgaimage.bin"; - }; - FpgaDownload fpgaDownload; + static const uint32_t MAX_POLLS = 10000; - class FpgaUpload { - public: - static const uint32_t MAX_DATA = 1024; - // Full name of file to upload - std::string uploadFile; - }; - FpgaUpload fpgaUpload; + static const uint8_t ACTION_DATA_OFFSET = 2; + static const uint8_t POS_OFFSET = 2; + static const uint8_t IMAGE_DATA_OFFSET = 5; + static const uint8_t FLASH_READ_DATA_OFFSET = 8; + static const uint8_t REGION_OFFSET = 2; + static const uint8_t ADDRESS_OFFSET = 3; + static const uint8_t LENGTH_OFFSET = 7; + static const size_t IMAGE_DATA_SIZE = 1024; + static const size_t MAX_FLASH_DATA = 1024; + static const size_t CONFIG_MAX_DOWNLOAD_RETRIES = 3; - static const uint32_t MAX_POLLS = 10000; + enum class InternalState { + IDLE, + UPLOAD_IMAGE, + DOWNLOAD_IMAGE, + FLASH_WRITE, + FLASH_READ, + DOWNLOAD_FPGA_IMAGE, + UPLOAD_FPGA_IMAGE + }; - static const uint8_t ACTION_DATA_OFFSET = 2; - static const uint8_t POS_OFFSET = 2; - static const uint8_t IMAGE_DATA_OFFSET = 5; - static const uint8_t FLASH_READ_DATA_OFFSET = 8; - static const uint8_t REGION_OFFSET = 2; - static const uint8_t ADDRESS_OFFSET = 3; - static const uint8_t LENGTH_OFFSET = 7; - static const size_t IMAGE_DATA_SIZE = 1024; - static const size_t MAX_FLASH_DATA = 1024; - static const size_t CONFIG_MAX_DOWNLOAD_RETRIES = 3; + InternalState internalState = InternalState::IDLE; - enum class InternalState { - IDLE, - UPLOAD_IMAGE, - DOWNLOAD_IMAGE, - FLASH_WRITE, - FLASH_READ, - DOWNLOAD_FPGA_IMAGE, - UPLOAD_FPGA_IMAGE - }; + ArcsecDatalinkLayer datalinkLayer; - InternalState internalState = InternalState::IDLE; + BinarySemaphore semaphore; - ArcsecDatalinkLayer datalinkLayer; + class UploadImage { + public: + // Name including absolute path of image to upload + std::string uploadFile; + }; + UploadImage uploadImage; - BinarySemaphore semaphore; + class DownloadImage { + public: + // Path where the downloaded image will be stored + std::string path; + // Default name of downloaded image, can be changed via command + std::string filename = "image.bin"; + }; + DownloadImage downloadImage; - class UploadImage { - public: - // Name including absolute path of image to upload - std::string uploadFile; - }; - UploadImage uploadImage; + class FlashWrite { + public: + // File which contains data to write when executing the flash write command + std::string fullname; + // Will be set with the flash write command + uint8_t region = 0; + // Will be set with the flash write command and specifies the start address where to write the + // flash data to + uint32_t address = 0; + }; + FlashWrite flashWrite; - class DownloadImage { - public: - // Path where the downloaded image will be stored - std::string path; - // Default name of downloaded image, can be changed via command - std::string filename = "image.bin"; - }; - DownloadImage downloadImage; + class FlashRead { + public: + // Path where the file containing the read data will be stored + std::string path = ""; + // Default name of file containing the data read from flash, can be changed via command + std::string filename = "flashread.bin"; + // Will be set with the flash read command + uint8_t region = 0; + // Will be set with the flash read command and specifies the start address of the flash section + // to read + uint32_t address = 0; + // Number of bytes to read from flash + uint32_t size = 0; + }; + FlashRead flashRead; - class FlashWrite { - public: - // File which contains data to write when executing the flash write command - std::string fullname; - // Will be set with the flash write command - uint8_t region = 0; - // Will be set with the flash write command and specifies the start address where to write the - // flash data to - uint32_t address = 0; - }; - FlashWrite flashWrite; + SdCardManager* sdcMan = nullptr; - class FlashRead { - public: - // Path where the file containing the read data will be stored - std::string path = ""; - // Default name of file containing the data read from flash, can be changed via command - std::string filename = "flashread.bin"; - // Will be set with the flash read command - uint8_t region = 0; - // Will be set with the flash read command and specifies the start address of the flash section - // to read - uint32_t address = 0; - // Number of bytes to read from flash - uint32_t size = 0; - }; - FlashRead flashRead; + uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE]; - SdCardManager* sdcMan = nullptr; + bool terminate = false; - uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE]; + /** + * UART communication object responsible for low level access of star tracker + * Must be set by star tracker handler + */ + UartComIF* uartComIF = nullptr; + // Communication cookie. Must be set by the star tracker handler + CookieIF* comCookie = nullptr; - bool terminate = false; + // Queue id of raw data receiver + MessageQueueId_t rawDataReceiver = MessageQueueIF::NO_QUEUE; - /** - * UART communication object responsible for low level access of star tracker - * Must be set by star tracker handler - */ - UartComIF* uartComIF = nullptr; - // Communication cookie. Must be set by the star tracker handler - CookieIF* comCookie = nullptr; + /** + * @brief Performs image uploading + */ + ReturnValue_t performImageUpload(); - // Queue id of raw data receiver - MessageQueueId_t rawDataReceiver = MessageQueueIF::NO_QUEUE; + /** + * @brief Performs download of last taken image from the star tracker. + * + * @details Download is split over multiple packets transporting each a maximum of 1024 bytes. + * In case the download of one position fails, the same packet will be again + * requested. If the download of the packet fails CONFIG_MAX_DOWNLOAD_RETRIES times, + * the download will be stopped. + */ + ReturnValue_t performImageDownload(); - /** - * @brief Performs image uploading - */ - ReturnValue_t performImageUpload(); + /** + * @brief Handles flash write procedure + * + * @return RETURN_OK if successful, otherwise RETURN_FAILED + */ + ReturnValue_t performFlashWrite(); - /** - * @brief Performs download of last taken image from the star tracker. - * - * @details Download is split over multiple packets transporting each a maximum of 1024 bytes. - * In case the download of one position fails, the same packet will be again - * requested. If the download of the packet fails CONFIG_MAX_DOWNLOAD_RETRIES times, - * the download will be stopped. - */ - ReturnValue_t performImageDownload(); + /** + * @brief Sends a sequence of commands to the star tracker to read larger parts from the + * flash memory. + */ + ReturnValue_t performFlashRead(); - /** - * @brief Handles flash write procedure - * - * @return RETURN_OK if successful, otherwise RETURN_FAILED - */ - ReturnValue_t performFlashWrite(); + /** + * @brief Performs the download of the FPGA image which requires to be slip over multiple + * action requests. + */ + ReturnValue_t performFpgaDownload(); - /** - * @brief Sends a sequence of commands to the star tracker to read larger parts from the - * flash memory. - */ - ReturnValue_t performFlashRead(); + /** + * @brief Performs upload of new FPGA image. Upload sequence split over multiple commands + * because one command can only transport 1024 bytes of image data. + */ + ReturnValue_t performFpgaUpload(); - /** - * @brief Performs the download of the FPGA image which requires to be slip over multiple - * action requests. - */ - ReturnValue_t performFpgaDownload(); + /** + * @brief Sends packet to the star tracker and reads reply by using the communication + * interface + * + * @param size Size of data beforehand written to the commandBuffer + * @param parameter Parameter 2 of trigger event function + * + * @return RETURN_OK if successful, otherwise RETURN_FAILED + */ + ReturnValue_t sendAndRead(size_t size, uint32_t parameter); - /** - * @brief Performs upload of new FPGA image. Upload sequence split over multiple commands - * because one command can only transport 1024 bytes of image data. - */ - ReturnValue_t performFpgaUpload(); + /** + * @brief Checks the header (type id and status fields) of the action reply + * + * @return RETURN_OK if reply confirms success of packet transfer, otherwise REUTRN_FAILED + */ + ReturnValue_t checkActionReply(); - /** - * @brief Sends packet to the star tracker and reads reply by using the communication - * interface - * - * @param size Size of data beforehand written to the commandBuffer - * @param parameter Parameter 2 of trigger event function - * - * @return RETURN_OK if successful, otherwise RETURN_FAILED - */ - ReturnValue_t sendAndRead(size_t size, uint32_t parameter); + /** + * @brief Checks the position field in a star tracker upload/download reply. + * + * @param expectedPosition Value of expected position + * + * @return RETURN_OK if received position matches expected position, otherwise RETURN_FAILED + */ + ReturnValue_t checkReplyPosition(uint32_t expectedPosition); - /** - * @brief Checks the header (type id and status fields) of the action reply - * - * @return RETURN_OK if reply confirms success of packet transfer, otherwise REUTRN_FAILED - */ - ReturnValue_t checkActionReply(); + /** + * @brief Checks the region, address and length value of a flash write or read reply. + * + * @return RETURN_OK if values match expected values, otherwise appropriate error return + * value. + */ + ReturnValue_t checkFlashActionReply(uint8_t region_, uint32_t address_, uint16_t length_); - /** - * @brief Checks the position field in a star tracker upload/download reply. - * - * @param expectedPosition Value of expected position - * - * @return RETURN_OK if received position matches expected position, otherwise RETURN_FAILED - */ - ReturnValue_t checkReplyPosition(uint32_t expectedPosition); + /** + * @brief Checks the reply to the fpga download and upload request + * + * @param expectedPosition The expected position value in the reply + * @param expectedLength The expected length field in the reply + */ + ReturnValue_t checkFpgaActionReply(uint32_t expectedPosition, uint32_t expectedLength); - /** - * @brief Checks the region, address and length value of a flash write or read reply. - * - * @return RETURN_OK if values match expected values, otherwise appropriate error return - * value. - */ - ReturnValue_t checkFlashActionReply(uint8_t region_, uint32_t address_, uint16_t length_); - - /** - * @brief Checks the reply to the fpga download and upload request - * - * @param expectedPosition The expected position value in the reply - * @param expectedLength The expected length field in the reply - */ - ReturnValue_t checkFpgaActionReply(uint32_t expectedPosition, uint32_t expectedLength); - - /** - * @brief Checks if a path points to an sd card and whether the SD card is monuted. - * - * @return SD_NOT_MOUNTED id SD card is not mounted, otherwise RETURN_OK - */ - ReturnValue_t checkPath(std::string name); + /** + * @brief Checks if a path points to an sd card and whether the SD card is monuted. + * + * @return SD_NOT_MOUNTED id SD card is not mounted, otherwise RETURN_OK + */ + ReturnValue_t checkPath(std::string name); }; #endif /* BSP_Q7S_DEVICES_STRHELPER_H_ */ diff --git a/bsp_q7s/gpio/gpioCallbacks.cpp b/bsp_q7s/gpio/gpioCallbacks.cpp index 2cbf3320..e3033b7d 100644 --- a/bsp_q7s/gpio/gpioCallbacks.cpp +++ b/bsp_q7s/gpio/gpioCallbacks.cpp @@ -1,512 +1,504 @@ #include "gpioCallbacks.h" -#include "busConf.h" + #include - -#include -#include #include +#include +#include +#include "busConf.h" namespace gpioCallbacks { GpioIF* gpioComInterface; void initSpiCsDecoder(GpioIF* gpioComIF) { + ReturnValue_t result; - ReturnValue_t result; + if (gpioComIF == nullptr) { + sif::debug << "initSpiCsDecoder: Invalid gpioComIF" << std::endl; + return; + } - if (gpioComIF == nullptr) { - sif::debug << "initSpiCsDecoder: Invalid gpioComIF" << std::endl; - return; - } + gpioComInterface = gpioComIF; - gpioComInterface = gpioComIF; + GpioCookie* spiMuxGpios = new GpioCookie; - GpioCookie* spiMuxGpios = new GpioCookie; + GpiodRegularByLineName* spiMuxBit = nullptr; + /** Setting mux bit 1 to low will disable IC21 on the interface board */ + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_1_PIN, "SPI Mux Bit 1", + gpio::DIR_OUT, gpio::HIGH); + spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_1, spiMuxBit); + /** Setting mux bit 2 to low disables IC1 on the TCS board */ + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_2_PIN, "SPI Mux Bit 2", + gpio::DIR_OUT, gpio::HIGH); + spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_2, spiMuxBit); + /** Setting mux bit 3 to low disables IC2 on the TCS board and IC22 on the interface board */ + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_3_PIN, "SPI Mux Bit 3", + gpio::DIR_OUT, gpio::LOW); + spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_3, spiMuxBit); - GpiodRegularByLineName* spiMuxBit = nullptr; - /** Setting mux bit 1 to low will disable IC21 on the interface board */ - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_1_PIN, "SPI Mux Bit 1", - gpio::DIR_OUT, gpio::HIGH); - spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_1, spiMuxBit); - /** Setting mux bit 2 to low disables IC1 on the TCS board */ - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_2_PIN, "SPI Mux Bit 2", - gpio::DIR_OUT, gpio::HIGH); - spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_2, spiMuxBit); - /** Setting mux bit 3 to low disables IC2 on the TCS board and IC22 on the interface board */ - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_3_PIN, "SPI Mux Bit 3", - gpio::DIR_OUT, gpio::LOW); - spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_3, spiMuxBit); + // spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_1_PIN, "SPI Mux Bit 1", + // gpio::OUT, gpio::LOW); + // spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_1, spiMuxBit); + // /** Setting mux bit 2 to low disables IC1 on the TCS board */ + // spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_2_PIN, "SPI Mux Bit 2", + // gpio::OUT, gpio::HIGH); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_2, spiMuxBit); + // /** Setting mux bit 3 to low disables IC2 on the TCS board and IC22 on the interface board + // */ spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_3_PIN, "SPI Mux Bit + // 3", gpio::OUT, gpio::LOW); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_3, spiMuxBit); -// spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_1_PIN, "SPI Mux Bit 1", -// gpio::OUT, gpio::LOW); -// spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_1, spiMuxBit); -// /** Setting mux bit 2 to low disables IC1 on the TCS board */ -// spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_2_PIN, "SPI Mux Bit 2", gpio::OUT, gpio::HIGH); -// spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_2, spiMuxBit); -// /** Setting mux bit 3 to low disables IC2 on the TCS board and IC22 on the interface board */ -// spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_3_PIN, "SPI Mux Bit 3", gpio::OUT, gpio::LOW); -// spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_3, spiMuxBit); + /** The following gpios can take arbitrary initial values */ + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_4_PIN, "SPI Mux Bit 4", + gpio::DIR_OUT, gpio::LOW); + spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_4, spiMuxBit); + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_5_PIN, "SPI Mux Bit 5", + gpio::DIR_OUT, gpio::LOW); + spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_5, spiMuxBit); + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_6_PIN, "SPI Mux Bit 6", + gpio::DIR_OUT, gpio::LOW); + spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_6, spiMuxBit); + GpiodRegularByLineName* enRwDecoder = + new GpiodRegularByLineName(q7s::gpioNames::EN_RW_CS, "EN_RW_CS", gpio::DIR_OUT, gpio::HIGH); + spiMuxGpios->addGpio(gpioIds::EN_RW_CS, enRwDecoder); - /** The following gpios can take arbitrary initial values */ - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_4_PIN, "SPI Mux Bit 4", - gpio::DIR_OUT, gpio::LOW); - spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_4, spiMuxBit); - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_5_PIN, "SPI Mux Bit 5", - gpio::DIR_OUT, gpio::LOW); - spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_5, spiMuxBit); - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_6_PIN, "SPI Mux Bit 6", - gpio::DIR_OUT, gpio::LOW); - spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_6, spiMuxBit); - GpiodRegularByLineName* enRwDecoder = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_CS, - "EN_RW_CS", gpio::DIR_OUT, gpio::HIGH); - spiMuxGpios->addGpio(gpioIds::EN_RW_CS, enRwDecoder); - - result = gpioComInterface->addGpios(spiMuxGpios); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "initSpiCsDecoder: Failed to add mux bit gpios to gpioComIF" << std::endl; - return; - } + result = gpioComInterface->addGpios(spiMuxGpios); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "initSpiCsDecoder: Failed to add mux bit gpios to gpioComIF" << std::endl; + return; + } } void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, gpio::Levels value, - void* args) { + void* args) { + if (gpioComInterface == nullptr) { + sif::debug << "spiCsDecoderCallback: No gpioComIF specified. Call initSpiCsDecoder " + << "to specify gpioComIF" << std::endl; + return; + } - if (gpioComInterface == nullptr) { - sif::debug << "spiCsDecoderCallback: No gpioComIF specified. Call initSpiCsDecoder " - << "to specify gpioComIF" << std::endl; - return; - } + /* Reading is not supported by the callback function */ + if (gpioOp == gpio::GpioOperation::READ) { + return; + } - /* Reading is not supported by the callback function */ - if (gpioOp == gpio::GpioOperation::READ) { - return; + if (value == gpio::HIGH) { + switch (gpioId) { + case (gpioIds::RTD_IC_3): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_4): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_5): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_6): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_7): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_8): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_9): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_10): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_11): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_12): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_13): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_14): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_15): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_16): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_17): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_18): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::CS_SUS_1): { + disableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_2): { + disableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_3): { + disableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_4): { + disableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_5): { + disableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_6): { + disableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_7): { + disableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_8): { + disableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_9): { + disableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_10): { + disableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_11): { + disableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_12): { + disableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_13): { + disableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_RW1): { + disableRwDecoder(); + break; + } + case (gpioIds::CS_RW2): { + disableRwDecoder(); + break; + } + case (gpioIds::CS_RW3): { + disableRwDecoder(); + break; + } + case (gpioIds::CS_RW4): { + disableRwDecoder(); + break; + } + default: + sif::debug << "spiCsDecoderCallback: Invalid gpio id " << gpioId << std::endl; } - - if (value == gpio::HIGH) { - switch (gpioId) { - case(gpioIds::RTD_IC_3): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_4): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_5): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_6): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_7): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_8): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_9): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_10): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_11): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_12): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_13): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_14): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_15): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_16): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_17): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_18): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::CS_SUS_1): { - disableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_2): { - disableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_3): { - disableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_4): { - disableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_5): { - disableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_6): { - disableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_7): { - disableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_8): { - disableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_9): { - disableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_10): { - disableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_11): { - disableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_12): { - disableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_13): { - disableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_RW1): { - disableRwDecoder(); - break; - } - case(gpioIds::CS_RW2): { - disableRwDecoder(); - break; - } - case(gpioIds::CS_RW3): { - disableRwDecoder(); - break; - } - case(gpioIds::CS_RW4): { - disableRwDecoder(); - break; - } - default: - sif::debug << "spiCsDecoderCallback: Invalid gpio id " << gpioId << std::endl; - } - } - else if (value == gpio::LOW) { - switch (gpioId) { - case(gpioIds::RTD_IC_3): { - selectY7(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_4): { - selectY6(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_5): { - selectY5(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_6): { - selectY4(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_7): { - selectY3(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_8): { - selectY2(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_9): { - selectY1(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_10): { - selectY0(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_11): { - selectY7(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_12): { - selectY6(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_13): { - selectY5(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_14): { - selectY4(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_15): { - selectY3(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_16): { - selectY2(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_17): { - selectY1(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_18): { - selectY0(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::CS_SUS_1): { - selectY0(); - enableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_2): { - selectY1(); - enableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_3): { - selectY0(); - enableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_4): { - selectY1(); - enableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_5): { - selectY2(); - enableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_6): { - selectY2(); - enableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_7): { - selectY3(); - enableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_8): { - selectY3(); - enableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_9): { - selectY4(); - enableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_10): { - selectY5(); - enableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_11): { - selectY4(); - enableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_12): { - selectY5(); - enableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_13): { - selectY6(); - enableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_RW1): { - selectY0(); - enableRwDecoder(); - break; - } - case(gpioIds::CS_RW2): { - selectY1(); - enableRwDecoder(); - break; - } - case(gpioIds::CS_RW3): { - selectY2(); - enableRwDecoder(); - break; - } - case(gpioIds::CS_RW4): { - selectY3(); - enableRwDecoder(); - break; - } - default: - sif::debug << "spiCsDecoderCallback: Invalid gpio id " << gpioId << std::endl; - } - } - else { - sif::debug << "spiCsDecoderCallback: Invalid value. Must be 0 or 1" << std::endl; + } else if (value == gpio::LOW) { + switch (gpioId) { + case (gpioIds::RTD_IC_3): { + selectY7(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_4): { + selectY6(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_5): { + selectY5(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_6): { + selectY4(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_7): { + selectY3(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_8): { + selectY2(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_9): { + selectY1(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_10): { + selectY0(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_11): { + selectY7(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_12): { + selectY6(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_13): { + selectY5(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_14): { + selectY4(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_15): { + selectY3(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_16): { + selectY2(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_17): { + selectY1(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_18): { + selectY0(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::CS_SUS_1): { + selectY0(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_2): { + selectY1(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_3): { + selectY0(); + enableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_4): { + selectY1(); + enableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_5): { + selectY2(); + enableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_6): { + selectY2(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_7): { + selectY3(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_8): { + selectY3(); + enableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_9): { + selectY4(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_10): { + selectY5(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_11): { + selectY4(); + enableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_12): { + selectY5(); + enableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_13): { + selectY6(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_RW1): { + selectY0(); + enableRwDecoder(); + break; + } + case (gpioIds::CS_RW2): { + selectY1(); + enableRwDecoder(); + break; + } + case (gpioIds::CS_RW3): { + selectY2(); + enableRwDecoder(); + break; + } + case (gpioIds::CS_RW4): { + selectY3(); + enableRwDecoder(); + break; + } + default: + sif::debug << "spiCsDecoderCallback: Invalid gpio id " << gpioId << std::endl; } + } else { + sif::debug << "spiCsDecoderCallback: Invalid value. Must be 0 or 1" << std::endl; + } } void enableDecoderTcsIc1() { - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); } void enableDecoderTcsIc2() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); } void enableDecoderInterfaceBoardIc1() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); } void enableDecoderInterfaceBoardIc2() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); } void disableDecoderTcsIc1() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); } void disableDecoderTcsIc2() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); } void disableDecoderInterfaceBoardIc1() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); } void disableDecoderInterfaceBoardIc2() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); } -void enableRwDecoder() { - gpioComInterface->pullHigh(gpioIds::EN_RW_CS); -} +void enableRwDecoder() { gpioComInterface->pullHigh(gpioIds::EN_RW_CS); } -void disableRwDecoder() { - gpioComInterface->pullLow(gpioIds::EN_RW_CS); -} +void disableRwDecoder() { gpioComInterface->pullLow(gpioIds::EN_RW_CS); } void selectY0() { - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); } void selectY1() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); } void selectY2() { - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); } void selectY3() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); } void selectY4() { - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); } void selectY5() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); } void selectY6() { - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); } void selectY7() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); } void disableAllDecoder() { - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullLow(gpioIds::EN_RW_CS); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullLow(gpioIds::EN_RW_CS); } -} +} // namespace gpioCallbacks diff --git a/bsp_q7s/gpio/gpioCallbacks.h b/bsp_q7s/gpio/gpioCallbacks.h index 18adb52b..6b4e99bf 100644 --- a/bsp_q7s/gpio/gpioCallbacks.h +++ b/bsp_q7s/gpio/gpioCallbacks.h @@ -1,74 +1,73 @@ #ifndef LINUX_GPIO_GPIOCALLBACKS_H_ #define LINUX_GPIO_GPIOCALLBACKS_H_ -#include #include - +#include namespace gpioCallbacks { - /** - * @brief This function initializes the GPIOs used to control the SN74LVC138APWR decoders on - * the TCS Board and the interface board. - */ - void initSpiCsDecoder(GpioIF* gpioComIF); +/** + * @brief This function initializes the GPIOs used to control the SN74LVC138APWR decoders on + * the TCS Board and the interface board. + */ +void initSpiCsDecoder(GpioIF* gpioComIF); - /** - * @brief This function implements the decoding to multiply gpios by using the decoder - * chips SN74LVC138APWR on the TCS board and the interface board. - */ - void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, - gpio::Levels value, void* args); +/** + * @brief This function implements the decoding to multiply gpios by using the decoder + * chips SN74LVC138APWR on the TCS board and the interface board. + */ +void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, gpio::Levels value, + void* args); - /** - * @brief This function sets mux bits 1-3 to a state which will only enable the decoder - * on the TCS board which is named to IC1 in the schematic. - */ - void enableDecoderTcsIc1(); +/** + * @brief This function sets mux bits 1-3 to a state which will only enable the decoder + * on the TCS board which is named to IC1 in the schematic. + */ +void enableDecoderTcsIc1(); - /** - * @brief This function sets mux bits 1-3 to a state which will only enable the decoder - * on the TCS board which is named to IC2 in the schematic. - */ - void enableDecoderTcsIc2(); +/** + * @brief This function sets mux bits 1-3 to a state which will only enable the decoder + * on the TCS board which is named to IC2 in the schematic. + */ +void enableDecoderTcsIc2(); - /** - * @brief This function sets mux bits 1-3 to a state which will only enable the decoder - * on the inteface board board which is named to IC21 in the schematic. - */ - void enableDecoderInterfaceBoardIc1(); +/** + * @brief This function sets mux bits 1-3 to a state which will only enable the decoder + * on the inteface board board which is named to IC21 in the schematic. + */ +void enableDecoderInterfaceBoardIc1(); - /** - * @brief This function sets mux bits 1-3 to a state which will only enable the decoder - * on the inteface board board which is named to IC22 in the schematic. - */ - void enableDecoderInterfaceBoardIc2(); +/** + * @brief This function sets mux bits 1-3 to a state which will only enable the decoder + * on the inteface board board which is named to IC22 in the schematic. + */ +void enableDecoderInterfaceBoardIc2(); - void disableDecoderTcsIc1(); - void disableDecoderTcsIc2(); - void disableDecoderInterfaceBoardIc1(); - void disableDecoderInterfaceBoardIc2(); +void disableDecoderTcsIc1(); +void disableDecoderTcsIc2(); +void disableDecoderInterfaceBoardIc1(); +void disableDecoderInterfaceBoardIc2(); - /** - * @brief Enables the reaction wheel chip select decoder (IC3). - */ - void enableRwDecoder(); - void disableRwDecoder(); +/** + * @brief Enables the reaction wheel chip select decoder (IC3). + */ +void enableRwDecoder(); +void disableRwDecoder(); - /** - * @brief This function disables all decoder. - */ - void disableAllDecoder(); +/** + * @brief This function disables all decoder. + */ +void disableAllDecoder(); - /** The following functions enable the appropriate channel of the currently enabled decoder */ - void selectY0(); - void selectY1(); - void selectY2(); - void selectY3(); - void selectY4(); - void selectY5(); - void selectY6(); - void selectY7(); -} +/** The following functions enable the appropriate channel of the currently enabled decoder */ +void selectY0(); +void selectY1(); +void selectY2(); +void selectY3(); +void selectY4(); +void selectY5(); +void selectY6(); +void selectY7(); +} // namespace gpioCallbacks #endif /* LINUX_GPIO_GPIOCALLBACKS_H_ */ diff --git a/bsp_q7s/main.cpp b/bsp_q7s/main.cpp index 9ce0dca2..dfcaebf0 100644 --- a/bsp_q7s/main.cpp +++ b/bsp_q7s/main.cpp @@ -12,12 +12,11 @@ * @brief This is the main program for the target hardware. * @return */ -int main(void) -{ - using namespace std; +int main(void) { + using namespace std; #if Q7S_SIMPLE_MODE == 0 - return obsw::obsw(); + return obsw::obsw(); #else - return simple::simple(); + return simple::simple(); #endif } diff --git a/bsp_q7s/memory/FileSystemHandler.cpp b/bsp_q7s/memory/FileSystemHandler.cpp index caad94a6..8b5f85c2 100644 --- a/bsp_q7s/memory/FileSystemHandler.cpp +++ b/bsp_q7s/memory/FileSystemHandler.cpp @@ -1,257 +1,241 @@ #include "FileSystemHandler.h" -#include "bsp_q7s/core/CoreController.h" - -#include "fsfw/tasks/TaskFactory.h" -#include "fsfw/memory/GenericFileSystemMessage.h" -#include "fsfw/ipc/QueueFactory.h" - #include -#include #include +#include -FileSystemHandler::FileSystemHandler(object_id_t fileSystemHandler): - SystemObject(fileSystemHandler) { - mq = QueueFactory::instance()->createMessageQueue(FS_MAX_QUEUE_SIZE); +#include "bsp_q7s/core/CoreController.h" +#include "fsfw/ipc/QueueFactory.h" +#include "fsfw/memory/GenericFileSystemMessage.h" +#include "fsfw/tasks/TaskFactory.h" + +FileSystemHandler::FileSystemHandler(object_id_t fileSystemHandler) + : SystemObject(fileSystemHandler) { + mq = QueueFactory::instance()->createMessageQueue(FS_MAX_QUEUE_SIZE); } -FileSystemHandler::~FileSystemHandler() { - QueueFactory::instance()->deleteMessageQueue(mq); -} +FileSystemHandler::~FileSystemHandler() { QueueFactory::instance()->deleteMessageQueue(mq); } ReturnValue_t FileSystemHandler::performOperation(uint8_t unsignedChar) { - while(true) { - try { - fileSystemHandlerLoop(); - } - catch(std::bad_alloc& e) { - // Restart OBSW, hints at a memory leak - sif::error << "Allocation error in FileSystemHandler::performOperation" - << e.what() << std::endl; - // Set up an error file or a special flag in the scratch buffer for these cases - triggerEvent(CoreController::ALLOC_FAILURE, 0 , 0); - CoreController::incrementAllocationFailureCount(); - } + while (true) { + try { + fileSystemHandlerLoop(); + } catch (std::bad_alloc& e) { + // Restart OBSW, hints at a memory leak + sif::error << "Allocation error in FileSystemHandler::performOperation" << e.what() + << std::endl; + // Set up an error file or a special flag in the scratch buffer for these cases + triggerEvent(CoreController::ALLOC_FAILURE, 0, 0); + CoreController::incrementAllocationFailureCount(); } + } } - void FileSystemHandler::fileSystemHandlerLoop() { - CommandMessage filemsg; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - while(true) { - if(opCounter % 5 == 0) { - if(coreCtrl->sdInitFinished()) { - fileSystemCheckup(); - } - } - result = mq->receiveMessage(&filemsg); - if(result == MessageQueueIF::EMPTY) { - break; - } - else if(result != HasReturnvaluesIF::RETURN_FAILED) { - sif::warning << "FileSystemHandler::performOperation: Message reception failed!" - << std::endl; - break; - } - Command_t command = filemsg.getCommand(); - switch(command) { - case(GenericFileSystemMessage::CMD_CREATE_DIRECTORY): { - break; - } - case(GenericFileSystemMessage::CMD_CREATE_FILE): { - break; - } - } - opCounter++; + CommandMessage filemsg; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + while (true) { + if (opCounter % 5 == 0) { + if (coreCtrl->sdInitFinished()) { + fileSystemCheckup(); + } + } + result = mq->receiveMessage(&filemsg); + if (result == MessageQueueIF::EMPTY) { + break; + } else if (result != HasReturnvaluesIF::RETURN_FAILED) { + sif::warning << "FileSystemHandler::performOperation: Message reception failed!" << std::endl; + break; + } + Command_t command = filemsg.getCommand(); + switch (command) { + case (GenericFileSystemMessage::CMD_CREATE_DIRECTORY): { + break; + } + case (GenericFileSystemMessage::CMD_CREATE_FILE): { + break; + } } - - // This task will have a low priority and will run permanently in the background - // so we will just run in a permanent loop here and check file system - // messages permanently opCounter++; - TaskFactory::instance()->delayTask(1000); + } + + // This task will have a low priority and will run permanently in the background + // so we will just run in a permanent loop here and check file system + // messages permanently + opCounter++; + TaskFactory::instance()->delayTask(1000); } void FileSystemHandler::fileSystemCheckup() { - SdCardManager::SdStatePair statusPair; - sdcMan->getSdCardActiveStatus(statusPair); - sd::SdCard preferredSdCard; - sdcMan->getPreferredSdCard(preferredSdCard); - if((preferredSdCard == sd::SdCard::SLOT_0) and - (statusPair.first == sd::SdState::MOUNTED)) { - currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; + SdCardManager::SdStatePair statusPair; + sdcMan->getSdCardActiveStatus(statusPair); + sd::SdCard preferredSdCard; + sdcMan->getPreferredSdCard(preferredSdCard); + if ((preferredSdCard == sd::SdCard::SLOT_0) and (statusPair.first == sd::SdState::MOUNTED)) { + currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; + } else if ((preferredSdCard == sd::SdCard::SLOT_1) and + (statusPair.second == sd::SdState::MOUNTED)) { + currentMountPrefix = SdCardManager::SD_1_MOUNT_POINT; + } else { + std::string sdString; + if (preferredSdCard == sd::SdCard::SLOT_0) { + sdString = "0"; + } else { + sdString = "1"; } - else if((preferredSdCard == sd::SdCard::SLOT_1) and - (statusPair.second == sd::SdState::MOUNTED)) { - currentMountPrefix = SdCardManager::SD_1_MOUNT_POINT; - } - else { - std::string sdString; - if(preferredSdCard == sd::SdCard::SLOT_0) { - sdString = "0"; - } - else { - sdString = "1"; - } - sif::warning << "FileSystemHandler::performOperation: " - "Inconsistent state detected" << std::endl; - sif::warning << "Preferred SD card is " << sdString << - " but does not appear to be mounted. Attempting fix.." << std::endl; - // This function will appear to fix the inconsistent state - ReturnValue_t result = sdcMan->sanitizeState(&statusPair, preferredSdCard); - if(result != HasReturnvaluesIF::RETURN_OK) { - // Oh no. - triggerEvent(SdCardManager::SANITIZATION_FAILED, 0, 0); - sif::error << "FileSystemHandler::fileSystemCheckup: Sanitization failed" << std::endl; - } + sif::warning << "FileSystemHandler::performOperation: " + "Inconsistent state detected" + << std::endl; + sif::warning << "Preferred SD card is " << sdString + << " but does not appear to be mounted. Attempting fix.." << std::endl; + // This function will appear to fix the inconsistent state + ReturnValue_t result = sdcMan->sanitizeState(&statusPair, preferredSdCard); + if (result != HasReturnvaluesIF::RETURN_OK) { + // Oh no. + triggerEvent(SdCardManager::SANITIZATION_FAILED, 0, 0); + sif::error << "FileSystemHandler::fileSystemCheckup: Sanitization failed" << std::endl; } + } } -MessageQueueId_t FileSystemHandler::getCommandQueue() const { - return mq->getId(); -} +MessageQueueId_t FileSystemHandler::getCommandQueue() const { return mq->getId(); } ReturnValue_t FileSystemHandler::initialize() { - coreCtrl = ObjectManager::instance()->get(objects::CORE_CONTROLLER); - if(coreCtrl == nullptr) { - sif::error << "FileSystemHandler::initialize: Could not retrieve core controller handle" << - std::endl; - } - sdcMan = SdCardManager::instance(); - sd::SdCard preferredSdCard; - ReturnValue_t result = sdcMan->getPreferredSdCard(preferredSdCard); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - if(preferredSdCard == sd::SdCard::SLOT_0) { - currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; - } - else if(preferredSdCard == sd::SdCard::SLOT_1) { - currentMountPrefix = SdCardManager::SD_1_MOUNT_POINT; - } - return HasReturnvaluesIF::RETURN_OK; + coreCtrl = ObjectManager::instance()->get(objects::CORE_CONTROLLER); + if (coreCtrl == nullptr) { + sif::error << "FileSystemHandler::initialize: Could not retrieve core controller handle" + << std::endl; + } + sdcMan = SdCardManager::instance(); + sd::SdCard preferredSdCard; + ReturnValue_t result = sdcMan->getPreferredSdCard(preferredSdCard); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + if (preferredSdCard == sd::SdCard::SLOT_0) { + currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; + } else if (preferredSdCard == sd::SdCard::SLOT_1) { + currentMountPrefix = SdCardManager::SD_1_MOUNT_POINT; + } + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t FileSystemHandler::appendToFile(const char* repositoryPath, - const char* filename, const uint8_t* data, size_t size, - uint16_t packetNumber, FileSystemArgsIF* args) { - auto path = getInitPath(args) / repositoryPath / filename; - if(not std::filesystem::exists(path)) { - return FILE_DOES_NOT_EXIST; - } - std::ofstream file(path, std::ios_base::app|std::ios_base::out); - file.write(reinterpret_cast(data), size); - if(not file.good()) { - return GENERIC_FILE_ERROR; - } - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t FileSystemHandler::createFile(const char* repositoryPath, - const char* filename, const uint8_t* data, size_t size, FileSystemArgsIF* args) { - auto path = getInitPath(args) / filename; - if(std::filesystem::exists(path)) { - return FILE_ALREADY_EXISTS; - } - std::ofstream file(path); - file.write(reinterpret_cast(data), size); - if(not file.good()) { - return GENERIC_FILE_ERROR; - } - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t FileSystemHandler::removeFile(const char* repositoryPath, - const char* filename, FileSystemArgsIF* args) { - auto path = getInitPath(args) / repositoryPath / filename; - if(not std::filesystem::exists(path)) { - return FILE_DOES_NOT_EXIST; - } - int result = std::remove(path.c_str()); - if(result != 0) { - sif::warning << "FileSystemHandler::deleteFile: Failed with code " << result << std::endl; - return GENERIC_FILE_ERROR; - } - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t FileSystemHandler:: createDirectory(const char* repositoryPath, const char* dirname, - bool createParentDirs, FileSystemArgsIF* args) { - auto path = getInitPath(args) / repositoryPath / dirname; - if(std::filesystem::exists(path)) { - return DIRECTORY_ALREADY_EXISTS; - } - if(std::filesystem::create_directory(path)) { - return HasReturnvaluesIF::RETURN_OK; - } - sif::warning << "Creating directory " << path << " failed" << std::endl; +ReturnValue_t FileSystemHandler::appendToFile(const char* repositoryPath, const char* filename, + const uint8_t* data, size_t size, + uint16_t packetNumber, FileSystemArgsIF* args) { + auto path = getInitPath(args) / repositoryPath / filename; + if (not std::filesystem::exists(path)) { + return FILE_DOES_NOT_EXIST; + } + std::ofstream file(path, std::ios_base::app | std::ios_base::out); + file.write(reinterpret_cast(data), size); + if (not file.good()) { return GENERIC_FILE_ERROR; + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t FileSystemHandler::createFile(const char* repositoryPath, const char* filename, + const uint8_t* data, size_t size, + FileSystemArgsIF* args) { + auto path = getInitPath(args) / filename; + if (std::filesystem::exists(path)) { + return FILE_ALREADY_EXISTS; + } + std::ofstream file(path); + file.write(reinterpret_cast(data), size); + if (not file.good()) { + return GENERIC_FILE_ERROR; + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t FileSystemHandler::removeFile(const char* repositoryPath, const char* filename, + FileSystemArgsIF* args) { + auto path = getInitPath(args) / repositoryPath / filename; + if (not std::filesystem::exists(path)) { + return FILE_DOES_NOT_EXIST; + } + int result = std::remove(path.c_str()); + if (result != 0) { + sif::warning << "FileSystemHandler::deleteFile: Failed with code " << result << std::endl; + return GENERIC_FILE_ERROR; + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t FileSystemHandler::createDirectory(const char* repositoryPath, const char* dirname, + bool createParentDirs, FileSystemArgsIF* args) { + auto path = getInitPath(args) / repositoryPath / dirname; + if (std::filesystem::exists(path)) { + return DIRECTORY_ALREADY_EXISTS; + } + if (std::filesystem::create_directory(path)) { + return HasReturnvaluesIF::RETURN_OK; + } + sif::warning << "Creating directory " << path << " failed" << std::endl; + return GENERIC_FILE_ERROR; } ReturnValue_t FileSystemHandler::removeDirectory(const char* repositoryPath, const char* dirname, - bool deleteRecurively, FileSystemArgsIF* args) { - auto path = getInitPath(args) / repositoryPath / dirname; - if(not std::filesystem::exists(path)) { - return DIRECTORY_DOES_NOT_EXIST; + bool deleteRecurively, FileSystemArgsIF* args) { + auto path = getInitPath(args) / repositoryPath / dirname; + if (not std::filesystem::exists(path)) { + return DIRECTORY_DOES_NOT_EXIST; + } + std::error_code err; + if (not deleteRecurively) { + if (std::filesystem::remove(path, err)) { + return HasReturnvaluesIF::RETURN_OK; + } else { + // Check error code. Most probably denied permissions because folder is not empty + sif::warning << "FileSystemHandler::removeDirectory: Deleting directory failed with " + "code " + << err.value() << ": " << strerror(err.value()) << std::endl; + if (err.value() == ENOTEMPTY) { + return DIRECTORY_NOT_EMPTY; + } else { + return GENERIC_FILE_ERROR; + } } - std::error_code err; - if(not deleteRecurively) { - if(std::filesystem::remove(path, err)) { - return HasReturnvaluesIF::RETURN_OK; - } - else { - // Check error code. Most probably denied permissions because folder is not empty - sif::warning << "FileSystemHandler::removeDirectory: Deleting directory failed with " - "code " << err.value() << ": " << strerror(err.value()) << std::endl; - if(err.value() == ENOTEMPTY) { - return DIRECTORY_NOT_EMPTY; - } - else { - return GENERIC_FILE_ERROR; - } + } else { + if (std::filesystem::remove_all(path, err)) { + return HasReturnvaluesIF::RETURN_OK; + } else { + sif::warning << "FileSystemHandler::removeDirectory: Deleting directory failed with " + "code " + << err.value() << ": " << strerror(err.value()) << std::endl; + // Check error code + if (err.value() == ENOTEMPTY) { + return DIRECTORY_NOT_EMPTY; + } else { + return GENERIC_FILE_ERROR; + } + } + } - } - } - else { - if(std::filesystem::remove_all(path, err)) { - return HasReturnvaluesIF::RETURN_OK; - } - else { - sif::warning << "FileSystemHandler::removeDirectory: Deleting directory failed with " - "code " << err.value() << ": " << strerror(err.value()) << std::endl; - // Check error code - if(err.value() == ENOTEMPTY) { - return DIRECTORY_NOT_EMPTY; - } - else { - return GENERIC_FILE_ERROR; - } - } - } - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t FileSystemHandler::renameFile(const char *repositoryPath, const char *oldFilename, - const char *newFilename, FileSystemArgsIF *args) { - auto basepath = getInitPath(args) / repositoryPath; - std::filesystem::rename(basepath / oldFilename, basepath / newFilename); - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t FileSystemHandler::renameFile(const char* repositoryPath, const char* oldFilename, + const char* newFilename, FileSystemArgsIF* args) { + auto basepath = getInitPath(args) / repositoryPath; + std::filesystem::rename(basepath / oldFilename, basepath / newFilename); + return HasReturnvaluesIF::RETURN_OK; } -void FileSystemHandler::parseCfg(FsCommandCfg *cfg, bool& useMountPrefix) { - if(cfg != nullptr) { - useMountPrefix = cfg->useMountPrefix; - } +void FileSystemHandler::parseCfg(FsCommandCfg* cfg, bool& useMountPrefix) { + if (cfg != nullptr) { + useMountPrefix = cfg->useMountPrefix; + } } std::filesystem::path FileSystemHandler::getInitPath(FileSystemArgsIF* args) { - bool useMountPrefix = true; - parseCfg(reinterpret_cast(args), useMountPrefix); - std::string path; - if(useMountPrefix) { - path = currentMountPrefix; - } - return std::filesystem::path(path); + bool useMountPrefix = true; + parseCfg(reinterpret_cast(args), useMountPrefix); + std::string path; + if (useMountPrefix) { + path = currentMountPrefix; + } + return std::filesystem::path(path); } diff --git a/bsp_q7s/memory/FileSystemHandler.h b/bsp_q7s/memory/FileSystemHandler.h index 35a0f533..6973c3c8 100644 --- a/bsp_q7s/memory/FileSystemHandler.h +++ b/bsp_q7s/memory/FileSystemHandler.h @@ -1,71 +1,67 @@ #ifndef BSP_Q7S_MEMORY_FILESYSTEMHANDLER_H_ #define BSP_Q7S_MEMORY_FILESYSTEMHANDLER_H_ -#include "SdCardManager.h" -#include "OBSWConfig.h" - -#include "fsfw/ipc/MessageQueueIF.h" -#include "fsfw/tasks/ExecutableObjectIF.h" -#include "fsfw/objectmanager/SystemObject.h" -#include "fsfw/memory/HasFileSystemIF.h" - -#include #include +#include + +#include "OBSWConfig.h" +#include "SdCardManager.h" +#include "fsfw/ipc/MessageQueueIF.h" +#include "fsfw/memory/HasFileSystemIF.h" +#include "fsfw/objectmanager/SystemObject.h" +#include "fsfw/tasks/ExecutableObjectIF.h" class CoreController; -class FileSystemHandler: public SystemObject, - public ExecutableObjectIF, - public HasFileSystemIF { -public: - struct FsCommandCfg: public FileSystemArgsIF { - // Can be used to automatically use mount prefix of active SD card. - // Otherwise, the operator has to specify the full path to the mounted SD card as well. - bool useMountPrefix = false; - }; +class FileSystemHandler : public SystemObject, public ExecutableObjectIF, public HasFileSystemIF { + public: + struct FsCommandCfg : public FileSystemArgsIF { + // Can be used to automatically use mount prefix of active SD card. + // Otherwise, the operator has to specify the full path to the mounted SD card as well. + bool useMountPrefix = false; + }; - FileSystemHandler(object_id_t fileSystemHandler); - virtual~ FileSystemHandler(); + FileSystemHandler(object_id_t fileSystemHandler); + virtual ~FileSystemHandler(); - ReturnValue_t performOperation(uint8_t) override; + ReturnValue_t performOperation(uint8_t) override; - ReturnValue_t initialize() override; + ReturnValue_t initialize() override; - /** - * Function to get the MessageQueueId_t of the implementing object - * @return MessageQueueId_t of the object - */ - MessageQueueId_t getCommandQueue() const override; - ReturnValue_t appendToFile(const char* repositoryPath, - const char* filename, const uint8_t* data, size_t size, - uint16_t packetNumber, FileSystemArgsIF* args = nullptr) override; - ReturnValue_t createFile(const char* repositoryPath, - const char* filename, const uint8_t* data = nullptr, - size_t size = 0, FileSystemArgsIF* args = nullptr) override; - ReturnValue_t removeFile(const char* repositoryPath, - const char* filename, FileSystemArgsIF* args = nullptr) override; - ReturnValue_t createDirectory(const char* repositoryPath, const char* dirname, - bool createParentDirs, FileSystemArgsIF* args = nullptr) override; - ReturnValue_t removeDirectory(const char* repositoryPath, const char* dirname, - bool deleteRecurively = false, FileSystemArgsIF* args = nullptr) override; - ReturnValue_t renameFile(const char* repositoryPath, const char* oldFilename, - const char* newFilename, FileSystemArgsIF* args = nullptr) override; + /** + * Function to get the MessageQueueId_t of the implementing object + * @return MessageQueueId_t of the object + */ + MessageQueueId_t getCommandQueue() const override; + ReturnValue_t appendToFile(const char* repositoryPath, const char* filename, const uint8_t* data, + size_t size, uint16_t packetNumber, + FileSystemArgsIF* args = nullptr) override; + ReturnValue_t createFile(const char* repositoryPath, const char* filename, + const uint8_t* data = nullptr, size_t size = 0, + FileSystemArgsIF* args = nullptr) override; + ReturnValue_t removeFile(const char* repositoryPath, const char* filename, + FileSystemArgsIF* args = nullptr) override; + ReturnValue_t createDirectory(const char* repositoryPath, const char* dirname, + bool createParentDirs, FileSystemArgsIF* args = nullptr) override; + ReturnValue_t removeDirectory(const char* repositoryPath, const char* dirname, + bool deleteRecurively = false, + FileSystemArgsIF* args = nullptr) override; + ReturnValue_t renameFile(const char* repositoryPath, const char* oldFilename, + const char* newFilename, FileSystemArgsIF* args = nullptr) override; -private: - CoreController* coreCtrl = nullptr; - MessageQueueIF* mq = nullptr; - std::string currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; - static constexpr uint32_t FS_MAX_QUEUE_SIZE = config::OBSW_FILESYSTEM_HANDLER_QUEUE_SIZE; + private: + CoreController* coreCtrl = nullptr; + MessageQueueIF* mq = nullptr; + std::string currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; + static constexpr uint32_t FS_MAX_QUEUE_SIZE = config::OBSW_FILESYSTEM_HANDLER_QUEUE_SIZE; - SdCardManager* sdcMan = nullptr; - uint8_t opCounter = 0; + SdCardManager* sdcMan = nullptr; + uint8_t opCounter = 0; - void fileSystemHandlerLoop(); - void fileSystemCheckup(); - std::filesystem::path getInitPath(FileSystemArgsIF* args); - void parseCfg(FsCommandCfg* cfg, bool& useMountPrefix); + void fileSystemHandlerLoop(); + void fileSystemCheckup(); + std::filesystem::path getInitPath(FileSystemArgsIF* args); + void parseCfg(FsCommandCfg* cfg, bool& useMountPrefix); }; - - #endif /* BSP_Q7S_MEMORY_FILESYSTEMMANAGER_H_ */ diff --git a/bsp_q7s/memory/SdCardManager.cpp b/bsp_q7s/memory/SdCardManager.cpp index 8a3d11f2..3647ff7b 100644 --- a/bsp_q7s/memory/SdCardManager.cpp +++ b/bsp_q7s/memory/SdCardManager.cpp @@ -1,487 +1,462 @@ #include "SdCardManager.h" -#include "scratchApi.h" - -#include "linux/utility/utility.h" - -#include "fsfw/ipc/MutexFactory.h" -#include "fsfw/serviceinterface/ServiceInterface.h" #include +#include +#include #include #include -#include -#include + +#include "fsfw/ipc/MutexFactory.h" +#include "fsfw/serviceinterface/ServiceInterface.h" +#include "linux/utility/utility.h" +#include "scratchApi.h" SdCardManager* SdCardManager::factoryInstance = nullptr; -SdCardManager::SdCardManager(): cmdExecutor(256) { -} +SdCardManager::SdCardManager() : cmdExecutor(256) {} -SdCardManager::~SdCardManager() { -} +SdCardManager::~SdCardManager() {} void SdCardManager::create() { - if(factoryInstance == nullptr) { - factoryInstance = new SdCardManager(); - } + if (factoryInstance == nullptr) { + factoryInstance = new SdCardManager(); + } } SdCardManager* SdCardManager::instance() { - SdCardManager::create(); - return SdCardManager::factoryInstance; + SdCardManager::create(); + return SdCardManager::factoryInstance; } ReturnValue_t SdCardManager::switchOnSdCard(sd::SdCard sdCard, bool doMountSdCard, - SdStatePair* statusPair) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - if(doMountSdCard) { - if(not blocking) { - sif::warning << "SdCardManager::switchOnSdCard: Two-step command but manager is" - " not configured for blocking operation. " - "Forcing blocking mode.." << std::endl; - blocking = true; - } + SdStatePair* statusPair) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + if (doMountSdCard) { + if (not blocking) { + sif::warning << "SdCardManager::switchOnSdCard: Two-step command but manager is" + " not configured for blocking operation. " + "Forcing blocking mode.." + << std::endl; + blocking = true; } - std::unique_ptr sdStatusPtr; - if(statusPair == nullptr) { - sdStatusPtr = std::make_unique(); - statusPair = sdStatusPtr.get(); - result = getSdCardActiveStatus(*statusPair); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + } + std::unique_ptr sdStatusPtr; + if (statusPair == nullptr) { + sdStatusPtr = std::make_unique(); + statusPair = sdStatusPtr.get(); + result = getSdCardActiveStatus(*statusPair); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; } + } - // Not allowed, this function turns on one SD card - if(sdCard == sd::SdCard::BOTH) { - sif::warning << "SdCardManager::switchOffSdCard: API does not allow sd::SdStatus::BOTH" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } + // Not allowed, this function turns on one SD card + if (sdCard == sd::SdCard::BOTH) { + sif::warning << "SdCardManager::switchOffSdCard: API does not allow sd::SdStatus::BOTH" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } - sd::SdState currentState; - if(sdCard == sd::SdCard::SLOT_0) { - currentState = statusPair->first; - } - else if(sdCard == sd::SdCard::SLOT_1) { - currentState = statusPair->second; - } - else { - // Should not happen - currentState = sd::SdState::OFF; - } + sd::SdState currentState; + if (sdCard == sd::SdCard::SLOT_0) { + currentState = statusPair->first; + } else if (sdCard == sd::SdCard::SLOT_1) { + currentState = statusPair->second; + } else { + // Should not happen + currentState = sd::SdState::OFF; + } - if(currentState == sd::SdState::ON) { - if(not doMountSdCard) { - return ALREADY_ON; - } - else { - return mountSdCard(sdCard); - } - } - else if(currentState == sd::SdState::MOUNTED) { - result = ALREADY_MOUNTED; - } - else if(currentState == sd::SdState::OFF) { - result = setSdCardState(sdCard, true); - } - else { - result = HasReturnvaluesIF::RETURN_FAILED; + if (currentState == sd::SdState::ON) { + if (not doMountSdCard) { + return ALREADY_ON; + } else { + return mountSdCard(sdCard); } + } else if (currentState == sd::SdState::MOUNTED) { + result = ALREADY_MOUNTED; + } else if (currentState == sd::SdState::OFF) { + result = setSdCardState(sdCard, true); + } else { + result = HasReturnvaluesIF::RETURN_FAILED; + } - if(result != HasReturnvaluesIF::RETURN_OK or not doMountSdCard) { - return result; - } + if (result != HasReturnvaluesIF::RETURN_OK or not doMountSdCard) { + return result; + } - return mountSdCard(sdCard); + return mountSdCard(sdCard); } ReturnValue_t SdCardManager::switchOffSdCard(sd::SdCard sdCard, bool doUnmountSdCard, - SdStatePair* statusPair) { - std::pair active; - ReturnValue_t result = getSdCardActiveStatus(active); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; + SdStatePair* statusPair) { + std::pair active; + ReturnValue_t result = getSdCardActiveStatus(active); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + if (doUnmountSdCard) { + if (not blocking) { + sif::warning << "SdCardManager::switchOffSdCard: Two-step command but manager is" + " not configured for blocking operation. Forcing blocking mode.." + << std::endl; + blocking = true; } - if(doUnmountSdCard) { - if(not blocking) { - sif::warning << "SdCardManager::switchOffSdCard: Two-step command but manager is" - " not configured for blocking operation. Forcing blocking mode.." << std::endl; - blocking = true; - } + } + // Not allowed, this function turns off one SD card + if (sdCard == sd::SdCard::BOTH) { + sif::warning << "SdCardManager::switchOffSdCard: API does not allow sd::SdStatus::BOTH" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + if (sdCard == sd::SdCard::SLOT_0) { + if (active.first == sd::SdState::OFF) { + return ALREADY_OFF; } - // Not allowed, this function turns off one SD card - if(sdCard == sd::SdCard::BOTH) { - sif::warning << "SdCardManager::switchOffSdCard: API does not allow sd::SdStatus::BOTH" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - if(sdCard == sd::SdCard::SLOT_0) { - if(active.first == sd::SdState::OFF) { - return ALREADY_OFF; - } - } - else if(sdCard == sd::SdCard::SLOT_1) { - if(active.second == sd::SdState::OFF) { - return ALREADY_OFF; - } + } else if (sdCard == sd::SdCard::SLOT_1) { + if (active.second == sd::SdState::OFF) { + return ALREADY_OFF; } + } - if(doUnmountSdCard) { - result = unmountSdCard(sdCard); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + if (doUnmountSdCard) { + result = unmountSdCard(sdCard); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; } + } - return setSdCardState(sdCard, false); + return setSdCardState(sdCard, false); } ReturnValue_t SdCardManager::setSdCardState(sd::SdCard sdCard, bool on) { - using namespace std; - if(cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { - return CommandExecutor::COMMAND_PENDING; - } - string sdstring = ""; - string statestring = ""; - if(sdCard == sd::SdCard::SLOT_0) { - sdstring = "0"; - } - else if(sdCard == sd::SdCard::SLOT_1) { - sdstring = "1"; - } - if(on) { - currentOp = Operations::SWITCHING_ON; - statestring = "on"; - } - else { - currentOp = Operations::SWITCHING_OFF; - statestring = "off"; - } - ostringstream command; - command << "q7hw sd set " << sdstring << " " << statestring; - cmdExecutor.load(command.str(), blocking, printCmdOutput); - ReturnValue_t result = cmdExecutor.execute(); - if(blocking and result != HasReturnvaluesIF::RETURN_OK) { - utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::setSdCardState"); - } - return result; + using namespace std; + if (cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { + return CommandExecutor::COMMAND_PENDING; + } + string sdstring = ""; + string statestring = ""; + if (sdCard == sd::SdCard::SLOT_0) { + sdstring = "0"; + } else if (sdCard == sd::SdCard::SLOT_1) { + sdstring = "1"; + } + if (on) { + currentOp = Operations::SWITCHING_ON; + statestring = "on"; + } else { + currentOp = Operations::SWITCHING_OFF; + statestring = "off"; + } + ostringstream command; + command << "q7hw sd set " << sdstring << " " << statestring; + cmdExecutor.load(command.str(), blocking, printCmdOutput); + ReturnValue_t result = cmdExecutor.execute(); + if (blocking and result != HasReturnvaluesIF::RETURN_OK) { + utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::setSdCardState"); + } + return result; } ReturnValue_t SdCardManager::getSdCardActiveStatus(SdStatePair& active) { - using namespace std; - if(not filesystem::exists(SD_STATE_FILE)) { - return STATUS_FILE_NEXISTS; - } + using namespace std; + if (not filesystem::exists(SD_STATE_FILE)) { + return STATUS_FILE_NEXISTS; + } - // Now the file should exist in any case. Still check whether it exists. - fstream sdStatus(SD_STATE_FILE); - if (not sdStatus.good()) { - return STATUS_FILE_NEXISTS; - } - string line; - uint8_t idx = 0; - sd::SdCard currentSd = sd::SdCard::SLOT_0; - // Process status file line by line - while (std::getline(sdStatus, line)) { - processSdStatusLine(active, line, idx, currentSd); - } - return HasReturnvaluesIF::RETURN_OK; + // Now the file should exist in any case. Still check whether it exists. + fstream sdStatus(SD_STATE_FILE); + if (not sdStatus.good()) { + return STATUS_FILE_NEXISTS; + } + string line; + uint8_t idx = 0; + sd::SdCard currentSd = sd::SdCard::SLOT_0; + // Process status file line by line + while (std::getline(sdStatus, line)) { + processSdStatusLine(active, line, idx, currentSd); + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t SdCardManager::mountSdCard(sd::SdCard sdCard) { - using namespace std; - if(cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { - return CommandExecutor::COMMAND_PENDING; - } - if(sdCard == sd::SdCard::BOTH) { - sif::warning << "SdCardManager::mountSdCard: API does not allow sd::SdStatus::BOTH" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - string mountDev; - string mountPoint; - if(sdCard == sd::SdCard::SLOT_0) { - mountDev = SD_0_DEV_NAME; - mountPoint = SD_0_MOUNT_POINT; - } - else if(sdCard == sd::SdCard::SLOT_1) { - mountDev = SD_1_DEV_NAME; - mountPoint = SD_1_MOUNT_POINT; - } - if(not filesystem::exists(mountDev)) { - sif::warning << "SdCardManager::mountSdCard: Device file does not exists. Make sure to" - " turn on the SD card" << std::endl; - return MOUNT_ERROR; - } + using namespace std; + if (cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { + return CommandExecutor::COMMAND_PENDING; + } + if (sdCard == sd::SdCard::BOTH) { + sif::warning << "SdCardManager::mountSdCard: API does not allow sd::SdStatus::BOTH" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + string mountDev; + string mountPoint; + if (sdCard == sd::SdCard::SLOT_0) { + mountDev = SD_0_DEV_NAME; + mountPoint = SD_0_MOUNT_POINT; + } else if (sdCard == sd::SdCard::SLOT_1) { + mountDev = SD_1_DEV_NAME; + mountPoint = SD_1_MOUNT_POINT; + } + if (not filesystem::exists(mountDev)) { + sif::warning << "SdCardManager::mountSdCard: Device file does not exists. Make sure to" + " turn on the SD card" + << std::endl; + return MOUNT_ERROR; + } - if(not blocking) { - currentOp = Operations::MOUNTING; - } - string sdMountCommand = "mount " + mountDev + " " + mountPoint; - cmdExecutor.load(sdMountCommand, blocking, printCmdOutput); - ReturnValue_t result = cmdExecutor.execute(); - if(blocking and result != HasReturnvaluesIF::RETURN_OK) { - utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::mountSdCard"); - } - return result; + if (not blocking) { + currentOp = Operations::MOUNTING; + } + string sdMountCommand = "mount " + mountDev + " " + mountPoint; + cmdExecutor.load(sdMountCommand, blocking, printCmdOutput); + ReturnValue_t result = cmdExecutor.execute(); + if (blocking and result != HasReturnvaluesIF::RETURN_OK) { + utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::mountSdCard"); + } + return result; } ReturnValue_t SdCardManager::unmountSdCard(sd::SdCard sdCard) { - if(cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { - return CommandExecutor::COMMAND_PENDING; - } - using namespace std; - if(sdCard == sd::SdCard::BOTH) { - sif::warning << "SdCardManager::unmountSdCard: API does not allow sd::SdStatus::BOTH" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - string mountPoint; - if(sdCard == sd::SdCard::SLOT_0) { - mountPoint = SD_0_MOUNT_POINT; - } - else if(sdCard == sd::SdCard::SLOT_1) { - mountPoint = SD_1_MOUNT_POINT; - } - if(not filesystem::exists(mountPoint)) { - sif::error << "SdCardManager::unmountSdCard: Default mount point " << mountPoint << - "does not exist" << std::endl; - return UNMOUNT_ERROR; - } - if(filesystem::is_empty(mountPoint)) { - // The mount point will always exist, but if it is empty, that is strong hint that - // the SD card was not mounted properly. Still proceed with operation. - sif::warning << "SdCardManager::unmountSdCard: Mount point is empty!" << std::endl; - } - string sdUnmountCommand = "umount " + mountPoint; - if(not blocking) { - currentOp = Operations::UNMOUNTING; - } - cmdExecutor.load(sdUnmountCommand, blocking, printCmdOutput); - ReturnValue_t result = cmdExecutor.execute(); - if(blocking and result != HasReturnvaluesIF::RETURN_OK) { - utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::unmountSdCard"); - } - return result; + if (cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { + return CommandExecutor::COMMAND_PENDING; + } + using namespace std; + if (sdCard == sd::SdCard::BOTH) { + sif::warning << "SdCardManager::unmountSdCard: API does not allow sd::SdStatus::BOTH" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + string mountPoint; + if (sdCard == sd::SdCard::SLOT_0) { + mountPoint = SD_0_MOUNT_POINT; + } else if (sdCard == sd::SdCard::SLOT_1) { + mountPoint = SD_1_MOUNT_POINT; + } + if (not filesystem::exists(mountPoint)) { + sif::error << "SdCardManager::unmountSdCard: Default mount point " << mountPoint + << "does not exist" << std::endl; + return UNMOUNT_ERROR; + } + if (filesystem::is_empty(mountPoint)) { + // The mount point will always exist, but if it is empty, that is strong hint that + // the SD card was not mounted properly. Still proceed with operation. + sif::warning << "SdCardManager::unmountSdCard: Mount point is empty!" << std::endl; + } + string sdUnmountCommand = "umount " + mountPoint; + if (not blocking) { + currentOp = Operations::UNMOUNTING; + } + cmdExecutor.load(sdUnmountCommand, blocking, printCmdOutput); + ReturnValue_t result = cmdExecutor.execute(); + if (blocking and result != HasReturnvaluesIF::RETURN_OK) { + utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::unmountSdCard"); + } + return result; } ReturnValue_t SdCardManager::sanitizeState(SdStatePair* statusPair, sd::SdCard prefSdCard) { - std::unique_ptr sdStatusPtr; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - // Enforce blocking operation for now. Be careful to reset it when returning prematurely! - bool resetNonBlockingState = false; - if(not this->blocking) { - blocking = true; - resetNonBlockingState = true; - } - if(prefSdCard == sd::SdCard::NONE) { - result = getPreferredSdCard(prefSdCard); - if(result != HasReturnvaluesIF::RETURN_OK) {} - } - if(statusPair == nullptr) { - sdStatusPtr = std::make_unique(); - statusPair = sdStatusPtr.get(); - getSdCardActiveStatus(*statusPair); + std::unique_ptr sdStatusPtr; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + // Enforce blocking operation for now. Be careful to reset it when returning prematurely! + bool resetNonBlockingState = false; + if (not this->blocking) { + blocking = true; + resetNonBlockingState = true; + } + if (prefSdCard == sd::SdCard::NONE) { + result = getPreferredSdCard(prefSdCard); + if (result != HasReturnvaluesIF::RETURN_OK) { } + } + if (statusPair == nullptr) { + sdStatusPtr = std::make_unique(); + statusPair = sdStatusPtr.get(); + getSdCardActiveStatus(*statusPair); + } - if(statusPair->first == sd::SdState::ON) { - result = mountSdCard(prefSdCard); - } + if (statusPair->first == sd::SdState::ON) { + result = mountSdCard(prefSdCard); + } - result = switchOnSdCard(prefSdCard, true, statusPair); - if(resetNonBlockingState) { - blocking = false; - } - return result; + result = switchOnSdCard(prefSdCard, true, statusPair); + if (resetNonBlockingState) { + blocking = false; + } + return result; } void SdCardManager::resetState() { - cmdExecutor.reset(); - currentOp = Operations::IDLE; + cmdExecutor.reset(); + currentOp = Operations::IDLE; } -void SdCardManager::processSdStatusLine(std::pair &active, - std::string& line, uint8_t& idx, sd::SdCard& currentSd) { - using namespace std; - istringstream iss(line); - string word; - bool slotLine = false; - bool mountLine = false; - while(iss >> word) { - if (word == "Slot") { - slotLine = true; - } - if(word == "Mounted") { - mountLine = true; - } - - if(slotLine) { - if (word == "1:") { - currentSd = sd::SdCard::SLOT_1; - } - - if(word == "on") { - if(currentSd == sd::SdCard::SLOT_0) { - active.first = sd::SdState::ON; - } - else { - active.second = sd::SdState::ON; - } - } - else if (word == "off") { - if(currentSd == sd::SdCard::SLOT_0) { - active.first = sd::SdState::OFF; - } - else { - active.second = sd::SdState::OFF; - } - } - } - - if(mountLine) { - if(currentSd == sd::SdCard::SLOT_0) { - active.first = sd::SdState::MOUNTED; - } - else { - active.second = sd::SdState::MOUNTED; - } - } - - if(idx > 5) { - sif::warning << "SdCardManager::sdCardActive: /tmp/sd_status.txt has more than 6 " - "lines and might be invalid!" << std::endl; - } +void SdCardManager::processSdStatusLine(std::pair& active, + std::string& line, uint8_t& idx, sd::SdCard& currentSd) { + using namespace std; + istringstream iss(line); + string word; + bool slotLine = false; + bool mountLine = false; + while (iss >> word) { + if (word == "Slot") { + slotLine = true; } - idx++; + if (word == "Mounted") { + mountLine = true; + } + + if (slotLine) { + if (word == "1:") { + currentSd = sd::SdCard::SLOT_1; + } + + if (word == "on") { + if (currentSd == sd::SdCard::SLOT_0) { + active.first = sd::SdState::ON; + } else { + active.second = sd::SdState::ON; + } + } else if (word == "off") { + if (currentSd == sd::SdCard::SLOT_0) { + active.first = sd::SdState::OFF; + } else { + active.second = sd::SdState::OFF; + } + } + } + + if (mountLine) { + if (currentSd == sd::SdCard::SLOT_0) { + active.first = sd::SdState::MOUNTED; + } else { + active.second = sd::SdState::MOUNTED; + } + } + + if (idx > 5) { + sif::warning << "SdCardManager::sdCardActive: /tmp/sd_status.txt has more than 6 " + "lines and might be invalid!" + << std::endl; + } + } + idx++; } ReturnValue_t SdCardManager::getPreferredSdCard(sd::SdCard& sdCard) const { - uint8_t prefSdCard = 0; - ReturnValue_t result = scratch::readNumber(scratch::PREFERED_SDC_KEY, prefSdCard); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - sdCard = static_cast(prefSdCard); - return HasReturnvaluesIF::RETURN_OK; + uint8_t prefSdCard = 0; + ReturnValue_t result = scratch::readNumber(scratch::PREFERED_SDC_KEY, prefSdCard); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + sdCard = static_cast(prefSdCard); + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t SdCardManager::setPreferredSdCard(sd::SdCard sdCard) { - if(sdCard == sd::SdCard::BOTH) { - return HasReturnvaluesIF::RETURN_FAILED; - } - return scratch::writeNumber(scratch::PREFERED_SDC_KEY, static_cast(sdCard)); + if (sdCard == sd::SdCard::BOTH) { + return HasReturnvaluesIF::RETURN_FAILED; + } + return scratch::writeNumber(scratch::PREFERED_SDC_KEY, static_cast(sdCard)); } ReturnValue_t SdCardManager::updateSdCardStateFile() { - if(cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { - return CommandExecutor::COMMAND_PENDING; - } - // Use q7hw utility and pipe the command output into the state file - std::string updateCmd = "q7hw sd info all > " + std::string(SD_STATE_FILE); - cmdExecutor.load(updateCmd, blocking, printCmdOutput); - ReturnValue_t result = cmdExecutor.execute(); - if(blocking and result != HasReturnvaluesIF::RETURN_OK) { - utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::mountSdCard"); - } - return result; + if (cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { + return CommandExecutor::COMMAND_PENDING; + } + // Use q7hw utility and pipe the command output into the state file + std::string updateCmd = "q7hw sd info all > " + std::string(SD_STATE_FILE); + cmdExecutor.load(updateCmd, blocking, printCmdOutput); + ReturnValue_t result = cmdExecutor.execute(); + if (blocking and result != HasReturnvaluesIF::RETURN_OK) { + utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::mountSdCard"); + } + return result; } std::string SdCardManager::getCurrentMountPrefix(sd::SdCard prefSdCard) { - if(prefSdCard == sd::SdCard::NONE) { - ReturnValue_t result = getPreferredSdCard(prefSdCard); - if(result != HasReturnvaluesIF::RETURN_OK) { - return SD_0_MOUNT_POINT; - } - } - if(prefSdCard == sd::SdCard::SLOT_0) { - return SD_0_MOUNT_POINT; - } - else { - return SD_1_MOUNT_POINT; + if (prefSdCard == sd::SdCard::NONE) { + ReturnValue_t result = getPreferredSdCard(prefSdCard); + if (result != HasReturnvaluesIF::RETURN_OK) { + return SD_0_MOUNT_POINT; } + } + if (prefSdCard == sd::SdCard::SLOT_0) { + return SD_0_MOUNT_POINT; + } else { + return SD_1_MOUNT_POINT; + } } -SdCardManager::OpStatus SdCardManager::checkCurrentOp(Operations ¤tOp) { - CommandExecutor::States state = cmdExecutor.getCurrentState(); - if(state == CommandExecutor::States::IDLE or state == CommandExecutor::States::COMMAND_LOADED) { - return OpStatus::IDLE; - } - currentOp = this->currentOp; - bool bytesRead = false; +SdCardManager::OpStatus SdCardManager::checkCurrentOp(Operations& currentOp) { + CommandExecutor::States state = cmdExecutor.getCurrentState(); + if (state == CommandExecutor::States::IDLE or state == CommandExecutor::States::COMMAND_LOADED) { + return OpStatus::IDLE; + } + currentOp = this->currentOp; + bool bytesRead = false; #if OBSW_ENABLE_TIMERS == 1 - Timer timer; - timer.setTimer(100); - uint32_t remainingTimeMs = 0; + Timer timer; + timer.setTimer(100); + uint32_t remainingTimeMs = 0; #endif - while(true) { - ReturnValue_t result = cmdExecutor.check(bytesRead); - // This timer can prevent deadlocks due to missconfigurations + while (true) { + ReturnValue_t result = cmdExecutor.check(bytesRead); + // This timer can prevent deadlocks due to missconfigurations #if OBSW_ENABLE_TIMERS == 1 - timer.getTimer(&remainingTimeMs); - if(remainingTimeMs == 0) { - sif::error << "SdCardManager::checkCurrentOp: Timeout!" << std::endl; - return OpStatus::FAIL; - } -#endif - switch(result) { - case(CommandExecutor::BYTES_READ): { - continue; - } - case(CommandExecutor::EXECUTION_FINISHED): { - return OpStatus::SUCCESS; - } - case(HasReturnvaluesIF::RETURN_OK): { - return OpStatus::ONGOING; - } - case(HasReturnvaluesIF::RETURN_FAILED): { - return OpStatus::FAIL; - } - default: { - sif::warning << "SdCardManager::checkCurrentOp: Unhandled case" << std::endl; - } - } + timer.getTimer(&remainingTimeMs); + if (remainingTimeMs == 0) { + sif::error << "SdCardManager::checkCurrentOp: Timeout!" << std::endl; + return OpStatus::FAIL; } +#endif + switch (result) { + case (CommandExecutor::BYTES_READ): { + continue; + } + case (CommandExecutor::EXECUTION_FINISHED): { + return OpStatus::SUCCESS; + } + case (HasReturnvaluesIF::RETURN_OK): { + return OpStatus::ONGOING; + } + case (HasReturnvaluesIF::RETURN_FAILED): { + return OpStatus::FAIL; + } + default: { + sif::warning << "SdCardManager::checkCurrentOp: Unhandled case" << std::endl; + } + } + } } -void SdCardManager::setBlocking(bool blocking) { - this->blocking = blocking; -} +void SdCardManager::setBlocking(bool blocking) { this->blocking = blocking; } -void SdCardManager::setPrintCommandOutput(bool print) { - this->printCmdOutput = print; - -} +void SdCardManager::setPrintCommandOutput(bool print) { this->printCmdOutput = print; } bool SdCardManager::isSdCardMounted(sd::SdCard sdCard) { - SdCardManager::SdStatePair active; - ReturnValue_t result = this->getSdCardActiveStatus(active); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "SdCardManager::isSdCardMounted: Failed to get SD card active state"; - return false; - } - if (sdCard == sd::SLOT_0) { - if (active.first == sd::MOUNTED) { - return true; - } - else { - return false; - } - } - else if (sdCard == sd::SLOT_1) { - if (active.second == sd::MOUNTED) { - return true; - } - else { - return false; - } - } - else { - sif::debug << "SdCardManager::isSdCardMounted: Unknown SD card specified" << std::endl; - } + SdCardManager::SdStatePair active; + ReturnValue_t result = this->getSdCardActiveStatus(active); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "SdCardManager::isSdCardMounted: Failed to get SD card active state"; return false; + } + if (sdCard == sd::SLOT_0) { + if (active.first == sd::MOUNTED) { + return true; + } else { + return false; + } + } else if (sdCard == sd::SLOT_1) { + if (active.second == sd::MOUNTED) { + return true; + } else { + return false; + } + } else { + sif::debug << "SdCardManager::isSdCardMounted: Unknown SD card specified" << std::endl; + } + return false; } - - diff --git a/bsp_q7s/memory/SdCardManager.h b/bsp_q7s/memory/SdCardManager.h index 6e4930da..4446a102 100644 --- a/bsp_q7s/memory/SdCardManager.h +++ b/bsp_q7s/memory/SdCardManager.h @@ -1,21 +1,20 @@ #ifndef BSP_Q7S_MEMORY_SDCARDACCESSMANAGER_H_ #define BSP_Q7S_MEMORY_SDCARDACCESSMANAGER_H_ -#include "fsfw_hal/linux/CommandExecutor.h" -#include "definitions.h" -#include "returnvalues/classIds.h" -#include "events/subsystemIdRanges.h" - -#include "fsfw/events/Event.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" - #include -#include -#include -#include -#include #include +#include +#include +#include +#include + +#include "definitions.h" +#include "events/subsystemIdRanges.h" +#include "fsfw/events/Event.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw_hal/linux/CommandExecutor.h" +#include "returnvalues/classIds.h" class MutexIF; @@ -24,202 +23,188 @@ class MutexIF; * state */ class SdCardManager { - friend class SdCardAccess; -public: - enum class Operations { - SWITCHING_ON, - SWITCHING_OFF, - MOUNTING, - UNMOUNTING, - IDLE - }; + friend class SdCardAccess; - enum class OpStatus { - IDLE, - TIMEOUT, - ONGOING, - SUCCESS, - FAIL - }; + public: + enum class Operations { SWITCHING_ON, SWITCHING_OFF, MOUNTING, UNMOUNTING, IDLE }; - using SdStatePair = std::pair; + enum class OpStatus { IDLE, TIMEOUT, ONGOING, SUCCESS, FAIL }; - static constexpr uint8_t INTERFACE_ID = CLASS_ID::SD_CARD_MANAGER; + using SdStatePair = std::pair; - static constexpr ReturnValue_t OP_ONGOING = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 0); - static constexpr ReturnValue_t ALREADY_ON = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 1); - static constexpr ReturnValue_t ALREADY_MOUNTED = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 2); - static constexpr ReturnValue_t ALREADY_OFF = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 3); - static constexpr ReturnValue_t STATUS_FILE_NEXISTS = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 10); - static constexpr ReturnValue_t STATUS_FILE_FORMAT_INVALID = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 11); - static constexpr ReturnValue_t MOUNT_ERROR = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 12); - static constexpr ReturnValue_t UNMOUNT_ERROR = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 13); - static constexpr ReturnValue_t SYSTEM_CALL_ERROR = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 14); - static constexpr ReturnValue_t POPEN_CALL_ERROR = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 15); + static constexpr uint8_t INTERFACE_ID = CLASS_ID::SD_CARD_MANAGER; - static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::FILE_SYSTEM; + static constexpr ReturnValue_t OP_ONGOING = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 0); + static constexpr ReturnValue_t ALREADY_ON = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 1); + static constexpr ReturnValue_t ALREADY_MOUNTED = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 2); + static constexpr ReturnValue_t ALREADY_OFF = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 3); + static constexpr ReturnValue_t STATUS_FILE_NEXISTS = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 10); + static constexpr ReturnValue_t STATUS_FILE_FORMAT_INVALID = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 11); + static constexpr ReturnValue_t MOUNT_ERROR = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 12); + static constexpr ReturnValue_t UNMOUNT_ERROR = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 13); + static constexpr ReturnValue_t SYSTEM_CALL_ERROR = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 14); + static constexpr ReturnValue_t POPEN_CALL_ERROR = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 15); - static constexpr Event SANITIZATION_FAILED = event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW); + static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::FILE_SYSTEM; - // C++17 does not support constexpr std::string yet - static constexpr char SD_0_DEV_NAME[] = "/dev/mmcblk0p1"; - static constexpr char SD_1_DEV_NAME[] = "/dev/mmcblk1p1"; - static constexpr char SD_0_MOUNT_POINT[] = "/mnt/sd0"; - static constexpr char SD_1_MOUNT_POINT[] = "/mnt/sd1"; - static constexpr char SD_STATE_FILE[] = "/tmp/sd_status.txt"; + static constexpr Event SANITIZATION_FAILED = event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW); - virtual ~SdCardManager(); + // C++17 does not support constexpr std::string yet + static constexpr char SD_0_DEV_NAME[] = "/dev/mmcblk0p1"; + static constexpr char SD_1_DEV_NAME[] = "/dev/mmcblk1p1"; + static constexpr char SD_0_MOUNT_POINT[] = "/mnt/sd0"; + static constexpr char SD_1_MOUNT_POINT[] = "/mnt/sd1"; + static constexpr char SD_STATE_FILE[] = "/tmp/sd_status.txt"; - static void create(); + virtual ~SdCardManager(); - /** - * Returns the single instance of the SD card manager. - */ - static SdCardManager* instance(); + static void create(); - /** - * Set the preferred SD card which will determine which SD card will be used as the primary - * SD card in hot redundant and cold redundant mode. This function will not switch the - * SD cards which are currently on and mounted, this needs to be implemented by - * an upper layer by using #switchOffSdCard , #switchOnSdCard and #updateSdCardStateFile - * @param sdCard - * @return - */ - ReturnValue_t setPreferredSdCard(sd::SdCard sdCard); + /** + * Returns the single instance of the SD card manager. + */ + static SdCardManager* instance(); - /** - * Get the currently configured preferred SD card - * @param sdCard - * @return - */ - ReturnValue_t getPreferredSdCard(sd::SdCard& sdCard) const; + /** + * Set the preferred SD card which will determine which SD card will be used as the primary + * SD card in hot redundant and cold redundant mode. This function will not switch the + * SD cards which are currently on and mounted, this needs to be implemented by + * an upper layer by using #switchOffSdCard , #switchOnSdCard and #updateSdCardStateFile + * @param sdCard + * @return + */ + ReturnValue_t setPreferredSdCard(sd::SdCard sdCard); - /** - * Switch on the specified SD card. - * @param sdCard - * @param doMountSdCard Mount the SD card after switching it on, which is necessary - * to use it - * @param statusPair If the status pair is already available, it can be passed here - * @return - RETURN_OK on success, ALREADY_ON if it is already on, - * SYSTEM_CALL_ERROR on system error - */ - ReturnValue_t switchOnSdCard(sd::SdCard sdCard, bool doMountSdCard = true, - SdStatePair* statusPair = nullptr); + /** + * Get the currently configured preferred SD card + * @param sdCard + * @return + */ + ReturnValue_t getPreferredSdCard(sd::SdCard& sdCard) const; - /** - * Switch off the specified SD card. - * @param sdCard - * @param doUnmountSdCard Unmount the SD card before switching the card off, which makes - * the operation safer - * @param statusPair If the status pair is already available, it can be passed here - * @return - RETURN_OK on success, ALREADY_ON if it is already on, - * SYSTEM_CALL_ERROR on system error - */ - ReturnValue_t switchOffSdCard(sd::SdCard sdCard, bool doUnmountSdCard = true, - SdStatePair* statusPair = nullptr); + /** + * Switch on the specified SD card. + * @param sdCard + * @param doMountSdCard Mount the SD card after switching it on, which is necessary + * to use it + * @param statusPair If the status pair is already available, it can be passed here + * @return - RETURN_OK on success, ALREADY_ON if it is already on, + * SYSTEM_CALL_ERROR on system error + */ + ReturnValue_t switchOnSdCard(sd::SdCard sdCard, bool doMountSdCard = true, + SdStatePair* statusPair = nullptr); - /** - * Update the state file or creates one if it does not exist. You need to call this - * function before calling #sdCardActive - * @return - * - RETURN_OK if the state file was updated successfully - * - CommandExecutor::COMMAND_PENDING: Non-blocking command is pending - * - RETURN_FAILED: blocking command failed - */ - ReturnValue_t updateSdCardStateFile(); + /** + * Switch off the specified SD card. + * @param sdCard + * @param doUnmountSdCard Unmount the SD card before switching the card off, which makes + * the operation safer + * @param statusPair If the status pair is already available, it can be passed here + * @return - RETURN_OK on success, ALREADY_ON if it is already on, + * SYSTEM_CALL_ERROR on system error + */ + ReturnValue_t switchOffSdCard(sd::SdCard sdCard, bool doUnmountSdCard = true, + SdStatePair* statusPair = nullptr); - /** - * Get the state of the SD cards. If the state file does not exist, this function will - * take care of updating it. If it does not, the function will use the state file to get - * the status of the SD cards and set the field of the provided boolean pair. - * @param active Pair of booleans, where the first entry is the state of the first SD card - * and the second one the state of the second SD card - * @return - RETURN_OK if the state was read successfully - * - STATUS_FILE_FORMAT_INVALID if there was an issue with the state file. The user - * should call #updateSdCardStateFile again in that case - * - STATUS_FILE_NEXISTS if the status file does not exist - */ - ReturnValue_t getSdCardActiveStatus(SdStatePair& active); + /** + * Update the state file or creates one if it does not exist. You need to call this + * function before calling #sdCardActive + * @return + * - RETURN_OK if the state file was updated successfully + * - CommandExecutor::COMMAND_PENDING: Non-blocking command is pending + * - RETURN_FAILED: blocking command failed + */ + ReturnValue_t updateSdCardStateFile(); - /** - * Mount the specified SD card. This is necessary to use it. - * @param sdCard - * @return - */ - ReturnValue_t mountSdCard(sd::SdCard sdCard); - /** - * Unmount the specified SD card. This is recommended before switching it off. The SD card - * can't be used after it has been unmounted. - * @param sdCard - * @return - */ - ReturnValue_t unmountSdCard(sd::SdCard sdCard); + /** + * Get the state of the SD cards. If the state file does not exist, this function will + * take care of updating it. If it does not, the function will use the state file to get + * the status of the SD cards and set the field of the provided boolean pair. + * @param active Pair of booleans, where the first entry is the state of the first SD card + * and the second one the state of the second SD card + * @return - RETURN_OK if the state was read successfully + * - STATUS_FILE_FORMAT_INVALID if there was an issue with the state file. The user + * should call #updateSdCardStateFile again in that case + * - STATUS_FILE_NEXISTS if the status file does not exist + */ + ReturnValue_t getSdCardActiveStatus(SdStatePair& active); - /** - * In case that there is a discrepancy between the preferred SD card and the currently - * mounted one, this function will sanitize the state by attempting to mount the - * currently preferred SD card. If the caller already has state information, it can be - * passed into the function. For now, this operation will be enforced in blocking mode. - * @param statusPair Current SD card status capture with #getSdCardActiveStatus - * @param prefSdCard Preferred SD card captured with #getPreferredSdCard - * @throws std::bad_alloc if one of the two arguments was a nullptr and an allocation failed - * @return - */ - ReturnValue_t sanitizeState(SdStatePair* statusPair = nullptr, - sd::SdCard prefSdCard = sd::SdCard::NONE); + /** + * Mount the specified SD card. This is necessary to use it. + * @param sdCard + * @return + */ + ReturnValue_t mountSdCard(sd::SdCard sdCard); + /** + * Unmount the specified SD card. This is recommended before switching it off. The SD card + * can't be used after it has been unmounted. + * @param sdCard + * @return + */ + ReturnValue_t unmountSdCard(sd::SdCard sdCard); - /** - * If sd::SdCard::NONE is passed as an argument, this function will get the currently - * preferred SD card from the scratch buffer. - * @param prefSdCardPtr - * @return - */ - std::string getCurrentMountPrefix(sd::SdCard prefSdCardPtr = sd::SdCard::NONE); + /** + * In case that there is a discrepancy between the preferred SD card and the currently + * mounted one, this function will sanitize the state by attempting to mount the + * currently preferred SD card. If the caller already has state information, it can be + * passed into the function. For now, this operation will be enforced in blocking mode. + * @param statusPair Current SD card status capture with #getSdCardActiveStatus + * @param prefSdCard Preferred SD card captured with #getPreferredSdCard + * @throws std::bad_alloc if one of the two arguments was a nullptr and an allocation failed + * @return + */ + ReturnValue_t sanitizeState(SdStatePair* statusPair = nullptr, + sd::SdCard prefSdCard = sd::SdCard::NONE); - OpStatus checkCurrentOp(Operations& currentOp); + /** + * If sd::SdCard::NONE is passed as an argument, this function will get the currently + * preferred SD card from the scratch buffer. + * @param prefSdCardPtr + * @return + */ + std::string getCurrentMountPrefix(sd::SdCard prefSdCardPtr = sd::SdCard::NONE); - /** - * If there are issues with the state machine, it can be reset with this function - */ - void resetState(); + OpStatus checkCurrentOp(Operations& currentOp); - void setBlocking(bool blocking); - void setPrintCommandOutput(bool print); + /** + * If there are issues with the state machine, it can be reset with this function + */ + void resetState(); - /** - * @brief Checks if an SD card is mounted - * - * @param sdCard The SD crad to check - * - * @return true if mounted, otherwise false - */ - bool isSdCardMounted(sd::SdCard sdCard); -private: - CommandExecutor cmdExecutor; - Operations currentOp = Operations::IDLE; - bool blocking = false; - bool printCmdOutput = true; + void setBlocking(bool blocking); + void setPrintCommandOutput(bool print); - SdCardManager(); + /** + * @brief Checks if an SD card is mounted + * + * @param sdCard The SD crad to check + * + * @return true if mounted, otherwise false + */ + bool isSdCardMounted(sd::SdCard sdCard); - ReturnValue_t setSdCardState(sd::SdCard sdCard, bool on); + private: + CommandExecutor cmdExecutor; + Operations currentOp = Operations::IDLE; + bool blocking = false; + bool printCmdOutput = true; - void processSdStatusLine(SdStatePair& active, std::string& line, uint8_t& idx, - sd::SdCard& currentSd); + SdCardManager(); - std::string currentPrefix; + ReturnValue_t setSdCardState(sd::SdCard sdCard, bool on); - static SdCardManager* factoryInstance; + void processSdStatusLine(SdStatePair& active, std::string& line, uint8_t& idx, + sd::SdCard& currentSd); + + std::string currentPrefix; + + static SdCardManager* factoryInstance; }; #endif /* BSP_Q7S_MEMORY_SDCARDACCESSMANAGER_H_ */ diff --git a/bsp_q7s/memory/definitions.h b/bsp_q7s/memory/definitions.h index 9e0bca65..53184e4e 100644 --- a/bsp_q7s/memory/definitions.h +++ b/bsp_q7s/memory/definitions.h @@ -5,22 +5,15 @@ namespace sd { -enum SdState: uint8_t { - OFF = 0, - ON = 1, - // A mounted SD card is on as well - MOUNTED = 2 +enum SdState : uint8_t { + OFF = 0, + ON = 1, + // A mounted SD card is on as well + MOUNTED = 2 }; -enum SdCard: uint8_t { - SLOT_0 = 0, - SLOT_1 = 1, - BOTH, - NONE -}; - -} - +enum SdCard : uint8_t { SLOT_0 = 0, SLOT_1 = 1, BOTH, NONE }; +} // namespace sd #endif /* BSP_Q7S_MEMORY_DEFINITIONS_H_ */ diff --git a/bsp_q7s/memory/scratchApi.cpp b/bsp_q7s/memory/scratchApi.cpp index 08d59df1..83bc8239 100644 --- a/bsp_q7s/memory/scratchApi.cpp +++ b/bsp_q7s/memory/scratchApi.cpp @@ -1,49 +1,50 @@ #include "scratchApi.h" ReturnValue_t scratch::writeString(std::string name, std::string string) { - std::ostringstream oss; - oss << "xsc_scratch write " << name << " \"" << string << "\""; - int result = std::system(oss.str().c_str()); - if(result != 0) { - utility::handleSystemError(result, "scratch::writeString"); - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + std::ostringstream oss; + oss << "xsc_scratch write " << name << " \"" << string << "\""; + int result = std::system(oss.str().c_str()); + if (result != 0) { + utility::handleSystemError(result, "scratch::writeString"); + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t scratch::readString(std::string key, std::string &string) { - std::ifstream file; - std::string filename; - ReturnValue_t result = readToFile(key, file, filename); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + std::ifstream file; + std::string filename; + ReturnValue_t result = readToFile(key, file, filename); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } - std::string line; - if (not std::getline(file, line)) { - std::remove(filename.c_str()); - return HasReturnvaluesIF::RETURN_FAILED; - } + std::string line; + if (not std::getline(file, line)) { + std::remove(filename.c_str()); + return HasReturnvaluesIF::RETURN_FAILED; + } - size_t pos = line.find("="); - if(pos == std::string::npos) { - sif::warning << "scratch::readNumber: Output file format invalid, " - "no \"=\" found" << std::endl; - // Could not find value - std::remove(filename.c_str()); - return KEY_NOT_FOUND; - } - string = line.substr(pos + 1); - return HasReturnvaluesIF::RETURN_OK; + size_t pos = line.find("="); + if (pos == std::string::npos) { + sif::warning << "scratch::readNumber: Output file format invalid, " + "no \"=\" found" + << std::endl; + // Could not find value + std::remove(filename.c_str()); + return KEY_NOT_FOUND; + } + string = line.substr(pos + 1); + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t scratch::clearValue(std::string key) { - std::ostringstream oss; - oss << "xsc_scratch clear " << key; - int result = std::system(oss.str().c_str()); - if(result != 0) { - utility::handleSystemError(result, "scratch::clearValue"); - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + std::ostringstream oss; + oss << "xsc_scratch clear " << key; + int result = std::system(oss.str().c_str()); + if (result != 0) { + utility::handleSystemError(result, "scratch::clearValue"); + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } diff --git a/bsp_q7s/memory/scratchApi.h b/bsp_q7s/memory/scratchApi.h index ee19e084..babd26dc 100644 --- a/bsp_q7s/memory/scratchApi.h +++ b/bsp_q7s/memory/scratchApi.h @@ -1,17 +1,17 @@ #ifndef BSP_Q7S_MEMORY_SCRATCHAPI_H_ #define BSP_Q7S_MEMORY_SCRATCHAPI_H_ +#include +#include +#include +#include +#include + #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "linux/utility/utility.h" #include "returnvalues/classIds.h" -#include -#include -#include -#include -#include - /** * @brief API for the scratch buffer */ @@ -48,7 +48,7 @@ ReturnValue_t readString(std::string key, std::string& string); * @param num Number. Template allows to set signed, unsigned and floating point numbers * @return */ -template::value>::type> +template ::value>::type> inline ReturnValue_t writeNumber(std::string key, T num) noexcept; /** @@ -59,90 +59,88 @@ inline ReturnValue_t writeNumber(std::string key, T num) noexcept; * @param num * @return */ -template::value>::type> +template ::value>::type> inline ReturnValue_t readNumber(std::string key, T& num) noexcept; - // Anonymous namespace namespace { static uint8_t counter = 0; ReturnValue_t readToFile(std::string name, std::ifstream& file, std::string& filename) { - using namespace std; - filename = "/tmp/sro" + std::to_string(counter++); - ostringstream oss; - oss << "xsc_scratch read " << name << " > " << filename; + using namespace std; + filename = "/tmp/sro" + std::to_string(counter++); + ostringstream oss; + oss << "xsc_scratch read " << name << " > " << filename; - int result = std::system(oss.str().c_str()); - if(result != 0) { - if(result == 256) { - sif::warning << "scratch::readNumber: Key " << name << " does not exist" << std::endl; - // Could not find value - std::remove(filename.c_str()); - return KEY_NOT_FOUND; - } - else { - utility::handleSystemError(result, "scratch::readNumber"); - std::remove(filename.c_str()); - return HasReturnvaluesIF::RETURN_FAILED; - } + int result = std::system(oss.str().c_str()); + if (result != 0) { + if (result == 256) { + sif::warning << "scratch::readNumber: Key " << name << " does not exist" << std::endl; + // Could not find value + std::remove(filename.c_str()); + return KEY_NOT_FOUND; + } else { + utility::handleSystemError(result, "scratch::readNumber"); + std::remove(filename.c_str()); + return HasReturnvaluesIF::RETURN_FAILED; } - file.open(filename); - return HasReturnvaluesIF::RETURN_OK; + } + file.open(filename); + return HasReturnvaluesIF::RETURN_OK; } -} // End of anonymous namespace +} // End of anonymous namespace -template::value>::type> +template ::value>::type> inline ReturnValue_t writeNumber(std::string key, T num) noexcept { - std::ostringstream oss; - oss << "xsc_scratch write " << key << " " << std::to_string(num); - int result = std::system(oss.str().c_str()); - if(result != 0) { - utility::handleSystemError(result, "scratch::writeNumber"); - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + std::ostringstream oss; + oss << "xsc_scratch write " << key << " " << std::to_string(num); + int result = std::system(oss.str().c_str()); + if (result != 0) { + utility::handleSystemError(result, "scratch::writeNumber"); + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } -template::value>::type> +template ::value>::type> inline ReturnValue_t readNumber(std::string key, T& num) noexcept { - using namespace std; - ifstream file; - std::string filename; - ReturnValue_t result = readToFile(key, file, filename); - if(result != HasReturnvaluesIF::RETURN_OK) { - std::remove(filename.c_str()); - return result; - } - - string line; - if (not std::getline(file, line)) { - std::remove(filename.c_str()); - return HasReturnvaluesIF::RETURN_FAILED; - } - - size_t pos = line.find("="); - if(pos == string::npos) { - sif::warning << "scratch::readNumber: Output file format invalid, " - "no \"=\" found" << std::endl; - // Could not find value - std::remove(filename.c_str()); - return KEY_NOT_FOUND; - } - std::string valueAsString = line.substr(pos + 1); - try { - num = std::stoi(valueAsString); - } - catch(std::invalid_argument& e) { - sif::warning << "scratch::readNumber: stoi call failed with " << e.what() << std::endl; - } - + using namespace std; + ifstream file; + std::string filename; + ReturnValue_t result = readToFile(key, file, filename); + if (result != HasReturnvaluesIF::RETURN_OK) { std::remove(filename.c_str()); - return HasReturnvaluesIF::RETURN_OK; + return result; + } + + string line; + if (not std::getline(file, line)) { + std::remove(filename.c_str()); + return HasReturnvaluesIF::RETURN_FAILED; + } + + size_t pos = line.find("="); + if (pos == string::npos) { + sif::warning << "scratch::readNumber: Output file format invalid, " + "no \"=\" found" + << std::endl; + // Could not find value + std::remove(filename.c_str()); + return KEY_NOT_FOUND; + } + std::string valueAsString = line.substr(pos + 1); + try { + num = std::stoi(valueAsString); + } catch (std::invalid_argument& e) { + sif::warning << "scratch::readNumber: stoi call failed with " << e.what() << std::endl; + } + + std::remove(filename.c_str()); + return HasReturnvaluesIF::RETURN_OK; } -} +} // namespace scratch #endif /* BSP_Q7S_MEMORY_SCRATCHAPI_H_ */ diff --git a/bsp_q7s/simple/simple.cpp b/bsp_q7s/simple/simple.cpp index 960aa7db..b300e456 100644 --- a/bsp_q7s/simple/simple.cpp +++ b/bsp_q7s/simple/simple.cpp @@ -1,4 +1,5 @@ #include "simple.h" + #include "q7sConfig.h" #if Q7S_SIMPLE_ADD_FILE_SYSTEM_TEST == 1 @@ -6,16 +7,13 @@ #endif int simple::simple() { - cout << "-- Q7S Simple Application --" << endl; + cout << "-- Q7S Simple Application --" << endl; #if Q7S_SIMPLE_ADD_FILE_SYSTEM_TEST == 1 - { - FileSystemTest fileSystemTest; - } + { FileSystemTest fileSystemTest; } #endif #if TE0720_GPIO_TEST #endif - return 0; + return 0; } - diff --git a/bsp_q7s/spi/Q7sSpiComIF.cpp b/bsp_q7s/spi/Q7sSpiComIF.cpp index 23dbe551..84552503 100644 --- a/bsp_q7s/spi/Q7sSpiComIF.cpp +++ b/bsp_q7s/spi/Q7sSpiComIF.cpp @@ -1,9 +1,5 @@ #include -Q7sSpiComIF::Q7sSpiComIF(object_id_t objectId, GpioIF* gpioComIF) : - SpiComIF(objectId, gpioComIF) { -} - -Q7sSpiComIF::~Q7sSpiComIF() { -} +Q7sSpiComIF::Q7sSpiComIF(object_id_t objectId, GpioIF* gpioComIF) : SpiComIF(objectId, gpioComIF) {} +Q7sSpiComIF::~Q7sSpiComIF() {} diff --git a/bsp_q7s/spi/Q7sSpiComIF.h b/bsp_q7s/spi/Q7sSpiComIF.h index a10d63dd..def754ab 100644 --- a/bsp_q7s/spi/Q7sSpiComIF.h +++ b/bsp_q7s/spi/Q7sSpiComIF.h @@ -3,7 +3,6 @@ #include - /** * @brief This additional communication interface is required because the SPI busses behind the * devices "/dev/spi2.0" and "dev/spidev3.0" are multiplexed to one SPI interface. @@ -17,17 +16,17 @@ * the SPI interface. The multiplexing is performed via a GPIO connected to a VHDL * module responsible for switching between the to SPI peripherals. */ -class Q7sSpiComIF: public SpiComIF { -public: - /** - * @brief Constructor - * - * @param objectId - * @param gpioComIF - * @param gpioSwitchId The gpio ID of the GPIO connected to the SPI mux module in the PL. - */ - Q7sSpiComIF(object_id_t objectId, GpioIF* gpioComIF, gpioId_t gpioSwitchId); - virtual ~Q7sSpiComIF(); +class Q7sSpiComIF : public SpiComIF { + public: + /** + * @brief Constructor + * + * @param objectId + * @param gpioComIF + * @param gpioSwitchId The gpio ID of the GPIO connected to the SPI mux module in the PL. + */ + Q7sSpiComIF(object_id_t objectId, GpioIF* gpioComIF, gpioId_t gpioSwitchId); + virtual ~Q7sSpiComIF(); }; #endif /* BSP_Q7S_SPI_Q7SSPICOMIF_H_ */ diff --git a/fsfw b/fsfw index c1e0bcee..2c871af7 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit c1e0bcee6db652d6c474c87a4099e61ecf86b694 +Subproject commit 2c871af7b98abc794cdf6072fae174c9dc3ac63b diff --git a/linux/archive/gpio/GpioCookie.cpp b/linux/archive/gpio/GpioCookie.cpp index c729502b..b1bb2db4 100644 --- a/linux/archive/gpio/GpioCookie.cpp +++ b/linux/archive/gpio/GpioCookie.cpp @@ -1,34 +1,32 @@ #include "GpioCookie.h" + #include -GpioCookie::GpioCookie() { -} +GpioCookie::GpioCookie() {} -ReturnValue_t GpioCookie::addGpio(gpioId_t gpioId, GpioBase* gpioConfig){ - if (gpioConfig == nullptr) { - sif::debug << "GpioCookie::addGpio: gpioConfig is nullpointer" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; +ReturnValue_t GpioCookie::addGpio(gpioId_t gpioId, GpioBase* gpioConfig) { + if (gpioConfig == nullptr) { + sif::debug << "GpioCookie::addGpio: gpioConfig is nullpointer" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + auto gpioMapIter = gpioMap.find(gpioId); + if (gpioMapIter == gpioMap.end()) { + auto statusPair = gpioMap.emplace(gpioId, gpioConfig); + if (statusPair.second == false) { +#if FSFW_VERBOSE_LEVEL >= 1 + sif::error << "GpioCookie::addGpio: Failed to add GPIO " << gpioId << " to GPIO map" + << std::endl; +#endif + return HasReturnvaluesIF::RETURN_FAILED; } - auto gpioMapIter = gpioMap.find(gpioId); - if(gpioMapIter == gpioMap.end()) { - auto statusPair = gpioMap.emplace(gpioId, gpioConfig); - if (statusPair.second == false) { + return HasReturnvaluesIF::RETURN_OK; + } #if FSFW_VERBOSE_LEVEL >= 1 - sif::error << "GpioCookie::addGpio: Failed to add GPIO " << gpioId << - " to GPIO map" << std::endl; + sif::error << "GpioCookie::addGpio: GPIO already exists in GPIO map " << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; - } -#if FSFW_VERBOSE_LEVEL >= 1 - sif::error << "GpioCookie::addGpio: GPIO already exists in GPIO map " << std::endl; -#endif - return HasReturnvaluesIF::RETURN_FAILED; + return HasReturnvaluesIF::RETURN_FAILED; } -GpioMap GpioCookie::getGpioMap() const { - return gpioMap; -} +GpioMap GpioCookie::getGpioMap() const { return gpioMap; } GpioCookie::~GpioCookie() {} diff --git a/linux/archive/gpio/GpioCookie.h b/linux/archive/gpio/GpioCookie.h index 3f8531ee..9295a4ac 100644 --- a/linux/archive/gpio/GpioCookie.h +++ b/linux/archive/gpio/GpioCookie.h @@ -1,11 +1,12 @@ #ifndef LINUX_GPIO_GPIOCOOKIE_H_ #define LINUX_GPIO_GPIOCOOKIE_H_ -#include "GpioIF.h" -#include "gpioDefinitions.h" #include #include +#include "GpioIF.h" +#include "gpioDefinitions.h" + /** * @brief Cookie for the GpioIF. Allows the GpioIF to determine which * GPIOs to initialize and whether they should be configured as in- or @@ -16,24 +17,23 @@ * * @author J. Meier */ -class GpioCookie: public CookieIF { -public: +class GpioCookie : public CookieIF { + public: + GpioCookie(); - GpioCookie(); + virtual ~GpioCookie(); - virtual ~GpioCookie(); + ReturnValue_t addGpio(gpioId_t gpioId, GpioBase* gpioConfig); + /** + * @brief Get map with registered GPIOs. + */ + GpioMap getGpioMap() const; - ReturnValue_t addGpio(gpioId_t gpioId, GpioBase* gpioConfig); - /** - * @brief Get map with registered GPIOs. - */ - GpioMap getGpioMap() const; - -private: - /** - * Returns a copy of the internal GPIO map. - */ - GpioMap gpioMap; + private: + /** + * Returns a copy of the internal GPIO map. + */ + GpioMap gpioMap; }; #endif /* LINUX_GPIO_GPIOCOOKIE_H_ */ diff --git a/linux/archive/gpio/GpioIF.h b/linux/archive/gpio/GpioIF.h index 75feb3ce..045af556 100644 --- a/linux/archive/gpio/GpioIF.h +++ b/linux/archive/gpio/GpioIF.h @@ -1,9 +1,10 @@ #ifndef LINUX_GPIO_GPIOIF_H_ #define LINUX_GPIO_GPIOIF_H_ -#include "gpioDefinitions.h" -#include #include +#include + +#include "gpioDefinitions.h" class GpioCookie; @@ -13,42 +14,41 @@ class GpioCookie; * @author J. Meier */ class GpioIF : public HasReturnvaluesIF { -public: + public: + virtual ~GpioIF(){}; - virtual ~GpioIF() {}; + /** + * @brief Called by the GPIO using object. + * @param cookie Cookie specifying informations of the GPIOs required + * by a object. + */ + virtual ReturnValue_t addGpios(GpioCookie* cookie) = 0; - /** - * @brief Called by the GPIO using object. - * @param cookie Cookie specifying informations of the GPIOs required - * by a object. - */ - virtual ReturnValue_t addGpios(GpioCookie* cookie) = 0; + /** + * @brief By implementing this function a child must provide the + * functionality to pull a certain GPIO to high logic level. + * + * @param gpioId A unique number which specifies the GPIO to drive. + * @return Returns RETURN_OK for success. This should never return RETURN_FAILED. + */ + virtual ReturnValue_t pullHigh(gpioId_t gpioId) = 0; - /** - * @brief By implementing this function a child must provide the - * functionality to pull a certain GPIO to high logic level. - * - * @param gpioId A unique number which specifies the GPIO to drive. - * @return Returns RETURN_OK for success. This should never return RETURN_FAILED. - */ - virtual ReturnValue_t pullHigh(gpioId_t gpioId) = 0; + /** + * @brief By implementing this function a child must provide the + * functionality to pull a certain GPIO to low logic level. + * + * @param gpioId A unique number which specifies the GPIO to drive. + */ + virtual ReturnValue_t pullLow(gpioId_t gpioId) = 0; - /** - * @brief By implementing this function a child must provide the - * functionality to pull a certain GPIO to low logic level. - * - * @param gpioId A unique number which specifies the GPIO to drive. - */ - virtual ReturnValue_t pullLow(gpioId_t gpioId) = 0; - - /** - * @brief This function requires a child to implement the functionality to read the state of - * an ouput or input gpio. - * - * @param gpioId A unique number which specifies the GPIO to read. - * @param gpioState State of GPIO will be written to this pointer. - */ - virtual ReturnValue_t readGpio(gpioId_t gpioId, int* gpioState) = 0; + /** + * @brief This function requires a child to implement the functionality to read the state of + * an ouput or input gpio. + * + * @param gpioId A unique number which specifies the GPIO to read. + * @param gpioState State of GPIO will be written to this pointer. + */ + virtual ReturnValue_t readGpio(gpioId_t gpioId, int* gpioState) = 0; }; #endif /* LINUX_GPIO_GPIOIF_H_ */ diff --git a/linux/archive/gpio/LinuxLibgpioIF.cpp b/linux/archive/gpio/LinuxLibgpioIF.cpp index 92ffa63c..e5dcc1f2 100644 --- a/linux/archive/gpio/LinuxLibgpioIF.cpp +++ b/linux/archive/gpio/LinuxLibgpioIF.cpp @@ -1,302 +1,295 @@ #include "LinuxLibgpioIF.h" -#include "GpioCookie.h" #include +#include #include +#include #include -#include -#include +#include "GpioCookie.h" LinuxLibgpioIF::LinuxLibgpioIF(object_id_t objectId) : SystemObject(objectId) { - struct gpiod_chip* chip = gpiod_chip_open_by_label("/amba_pl/gpio@42030000"); + struct gpiod_chip* chip = gpiod_chip_open_by_label("/amba_pl/gpio@42030000"); - sif::debug << chip->name << std::endl; + sif::debug << chip->name << std::endl; } -LinuxLibgpioIF::~LinuxLibgpioIF() { -} +LinuxLibgpioIF::~LinuxLibgpioIF() {} ReturnValue_t LinuxLibgpioIF::addGpios(GpioCookie* gpioCookie) { - ReturnValue_t result; - if(gpioCookie == nullptr) { - sif::error << "LinuxLibgpioIF::initialize: Invalid cookie" << std::endl; - return RETURN_FAILED; - } + ReturnValue_t result; + if (gpioCookie == nullptr) { + sif::error << "LinuxLibgpioIF::initialize: Invalid cookie" << std::endl; + return RETURN_FAILED; + } - GpioMap mapToAdd = gpioCookie->getGpioMap(); + GpioMap mapToAdd = gpioCookie->getGpioMap(); - /* Check whether this ID already exists in the map and remove duplicates */ - result = checkForConflicts(mapToAdd); - if (result != RETURN_OK){ - return result; - } + /* Check whether this ID already exists in the map and remove duplicates */ + result = checkForConflicts(mapToAdd); + if (result != RETURN_OK) { + return result; + } - result = configureGpios(mapToAdd); - if (result != RETURN_OK) { - return RETURN_FAILED; - } + result = configureGpios(mapToAdd); + if (result != RETURN_OK) { + return RETURN_FAILED; + } - /* Register new GPIOs in gpioMap */ - gpioMap.insert(mapToAdd.begin(), mapToAdd.end()); + /* Register new GPIOs in gpioMap */ + gpioMap.insert(mapToAdd.begin(), mapToAdd.end()); - return RETURN_OK; + return RETURN_OK; } ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap& mapToAdd) { - for(auto& gpioConfig: mapToAdd) { - switch(gpioConfig.second->gpioType) { - case(gpio::GpioTypes::NONE): { - return GPIO_INVALID_INSTANCE; - } - case(gpio::GpioTypes::GPIOD_REGULAR): { - GpiodRegular* regularGpio = dynamic_cast(gpioConfig.second); - if(regularGpio == nullptr) { - return GPIO_INVALID_INSTANCE; - } - configureRegularGpio(gpioConfig.first, regularGpio); - break; - } - case(gpio::GpioTypes::CALLBACK): { - auto gpioCallback = dynamic_cast(gpioConfig.second); - if(gpioCallback->callback == nullptr) { - return GPIO_INVALID_INSTANCE; - } - gpioCallback->callback(gpioConfig.first, gpio::GpioOperation::WRITE, - gpioCallback->initValue, gpioCallback->callbackArgs); + for (auto& gpioConfig : mapToAdd) { + switch (gpioConfig.second->gpioType) { + case (gpio::GpioTypes::NONE): { + return GPIO_INVALID_INSTANCE; + } + case (gpio::GpioTypes::GPIOD_REGULAR): { + GpiodRegular* regularGpio = dynamic_cast(gpioConfig.second); + if (regularGpio == nullptr) { + return GPIO_INVALID_INSTANCE; } + configureRegularGpio(gpioConfig.first, regularGpio); + break; + } + case (gpio::GpioTypes::CALLBACK): { + auto gpioCallback = dynamic_cast(gpioConfig.second); + if (gpioCallback->callback == nullptr) { + return GPIO_INVALID_INSTANCE; } + gpioCallback->callback(gpioConfig.first, gpio::GpioOperation::WRITE, + gpioCallback->initValue, gpioCallback->callbackArgs); + } } - return RETURN_OK; + } + return RETURN_OK; } -ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, GpiodRegular *regularGpio) { - std::string chipname; - unsigned int lineNum; - struct gpiod_chip *chip; - gpio::Direction direction; - std::string consumer; - struct gpiod_line *lineHandle; - int result = 0; +ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, GpiodRegular* regularGpio) { + std::string chipname; + unsigned int lineNum; + struct gpiod_chip* chip; + gpio::Direction direction; + std::string consumer; + struct gpiod_line* lineHandle; + int result = 0; - chipname = regularGpio->chipname; - chip = gpiod_chip_open_by_name(chipname.c_str()); - if (!chip) { - sif::error << "LinuxLibgpioIF::configureGpios: Failed to open chip " - << chipname << ". Gpio ID: " << gpioId << std::endl; + chipname = regularGpio->chipname; + chip = gpiod_chip_open_by_name(chipname.c_str()); + if (!chip) { + sif::error << "LinuxLibgpioIF::configureGpios: Failed to open chip " << chipname + << ". Gpio ID: " << gpioId << std::endl; + return RETURN_FAILED; + } + + lineNum = regularGpio->lineNum; + lineHandle = gpiod_chip_get_line(chip, lineNum); + if (!lineHandle) { + sif::error << "LinuxLibgpioIF::configureGpios: Failed to open line for GPIO with id " << gpioId + << std::endl; + gpiod_chip_close(chip); + return RETURN_FAILED; + } + + direction = regularGpio->direction; + consumer = regularGpio->consumer; + /* Configure direction and add a description to the GPIO */ + switch (direction) { + case (gpio::OUT): { + result = gpiod_line_request_output(lineHandle, consumer.c_str(), regularGpio->initValue); + if (result < 0) { + sif::error << "LinuxLibgpioIF::configureGpios: Failed to request line " << lineNum + << " from GPIO instance with ID: " << gpioId << std::endl; + gpiod_line_release(lineHandle); return RETURN_FAILED; + } + break; } - - lineNum = regularGpio->lineNum; - lineHandle = gpiod_chip_get_line(chip, lineNum); - if (!lineHandle) { - sif::error << "LinuxLibgpioIF::configureGpios: Failed to open line for GPIO with id " - << gpioId << std::endl; - gpiod_chip_close(chip); + case (gpio::IN): { + result = gpiod_line_request_input(lineHandle, consumer.c_str()); + if (result < 0) { + sif::error << "LinuxLibgpioIF::configureGpios: Failed to request line " << lineNum + << " from GPIO instance with ID: " << gpioId << std::endl; + gpiod_line_release(lineHandle); return RETURN_FAILED; - } - - direction = regularGpio->direction; - consumer = regularGpio->consumer; - /* Configure direction and add a description to the GPIO */ - switch (direction) { - case(gpio::OUT): { - result = gpiod_line_request_output(lineHandle, consumer.c_str(), - regularGpio->initValue); - if (result < 0) { - sif::error << "LinuxLibgpioIF::configureGpios: Failed to request line " << lineNum << - " from GPIO instance with ID: " << gpioId << std::endl; - gpiod_line_release(lineHandle); - return RETURN_FAILED; - } - break; - } - case(gpio::IN): { - result = gpiod_line_request_input(lineHandle, consumer.c_str()); - if (result < 0) { - sif::error << "LinuxLibgpioIF::configureGpios: Failed to request line " - << lineNum << " from GPIO instance with ID: " << gpioId << std::endl; - gpiod_line_release(lineHandle); - return RETURN_FAILED; - } - break; + } + break; } default: { - sif::error << "LinuxLibgpioIF::configureGpios: Invalid direction specified" - << std::endl; - return GPIO_INVALID_INSTANCE; + sif::error << "LinuxLibgpioIF::configureGpios: Invalid direction specified" << std::endl; + return GPIO_INVALID_INSTANCE; } - - } - /** - * Write line handle to GPIO configuration instance so it can later be used to set or - * read states of GPIOs. - */ - regularGpio->lineHandle = lineHandle; - return RETURN_OK; + } + /** + * Write line handle to GPIO configuration instance so it can later be used to set or + * read states of GPIOs. + */ + regularGpio->lineHandle = lineHandle; + return RETURN_OK; } ReturnValue_t LinuxLibgpioIF::pullHigh(gpioId_t gpioId) { - gpioMapIter = gpioMap.find(gpioId); - if (gpioMapIter == gpioMap.end()) { - sif::warning << "LinuxLibgpioIF::driveGpio: Unknown GPIOD ID " << gpioId << std::endl; - return UNKNOWN_GPIO_ID; - } + gpioMapIter = gpioMap.find(gpioId); + if (gpioMapIter == gpioMap.end()) { + sif::warning << "LinuxLibgpioIF::driveGpio: Unknown GPIOD ID " << gpioId << std::endl; + return UNKNOWN_GPIO_ID; + } - if(gpioMapIter->second->gpioType == gpio::GpioTypes::GPIOD_REGULAR) { - return driveGpio(gpioId, dynamic_cast(gpioMapIter->second), 1); + if (gpioMapIter->second->gpioType == gpio::GpioTypes::GPIOD_REGULAR) { + return driveGpio(gpioId, dynamic_cast(gpioMapIter->second), 1); + } else { + auto gpioCallback = dynamic_cast(gpioMapIter->second); + if (gpioCallback->callback == nullptr) { + return GPIO_INVALID_INSTANCE; } - else { - auto gpioCallback = dynamic_cast(gpioMapIter->second); - if(gpioCallback->callback == nullptr) { - return GPIO_INVALID_INSTANCE; - } - gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::WRITE, - 1, gpioCallback->callbackArgs); - } - return GPIO_TYPE_FAILURE; + gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::WRITE, 1, + gpioCallback->callbackArgs); + } + return GPIO_TYPE_FAILURE; } ReturnValue_t LinuxLibgpioIF::pullLow(gpioId_t gpioId) { - gpioMapIter = gpioMap.find(gpioId); - if (gpioMapIter == gpioMap.end()) { - sif::warning << "LinuxLibgpioIF::driveGpio: Unknown GPIOD ID " << gpioId << std::endl; - return UNKNOWN_GPIO_ID; - } + gpioMapIter = gpioMap.find(gpioId); + if (gpioMapIter == gpioMap.end()) { + sif::warning << "LinuxLibgpioIF::driveGpio: Unknown GPIOD ID " << gpioId << std::endl; + return UNKNOWN_GPIO_ID; + } - if(gpioMapIter->second->gpioType == gpio::GpioTypes::GPIOD_REGULAR) { - return driveGpio(gpioId, dynamic_cast(gpioMapIter->second), 0); + if (gpioMapIter->second->gpioType == gpio::GpioTypes::GPIOD_REGULAR) { + return driveGpio(gpioId, dynamic_cast(gpioMapIter->second), 0); + } else { + auto gpioCallback = dynamic_cast(gpioMapIter->second); + if (gpioCallback->callback == nullptr) { + return GPIO_INVALID_INSTANCE; } - else { - auto gpioCallback = dynamic_cast(gpioMapIter->second); - if(gpioCallback->callback == nullptr) { - return GPIO_INVALID_INSTANCE; - } - gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::WRITE, - 0, gpioCallback->callbackArgs); - } - return GPIO_TYPE_FAILURE; + gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::WRITE, 0, + gpioCallback->callbackArgs); + } + return GPIO_TYPE_FAILURE; } -ReturnValue_t LinuxLibgpioIF::driveGpio(gpioId_t gpioId, - GpiodRegular* regularGpio, unsigned int logicLevel) { - if(regularGpio == nullptr) { - return GPIO_TYPE_FAILURE; - } +ReturnValue_t LinuxLibgpioIF::driveGpio(gpioId_t gpioId, GpiodRegular* regularGpio, + unsigned int logicLevel) { + if (regularGpio == nullptr) { + return GPIO_TYPE_FAILURE; + } - int result = gpiod_line_set_value(regularGpio->lineHandle, logicLevel); - if (result < 0) { - sif::warning << "LinuxLibgpioIF::driveGpio: Failed to pull GPIO with ID " << gpioId << - " to logic level " << logicLevel << std::endl; - return DRIVE_GPIO_FAILURE; - } + int result = gpiod_line_set_value(regularGpio->lineHandle, logicLevel); + if (result < 0) { + sif::warning << "LinuxLibgpioIF::driveGpio: Failed to pull GPIO with ID " << gpioId + << " to logic level " << logicLevel << std::endl; + return DRIVE_GPIO_FAILURE; + } - return RETURN_OK; + return RETURN_OK; } ReturnValue_t LinuxLibgpioIF::readGpio(gpioId_t gpioId, int* gpioState) { - gpioMapIter = gpioMap.find(gpioId); - if (gpioMapIter == gpioMap.end()){ - sif::warning << "LinuxLibgpioIF::readGpio: Unknown GPIOD ID " << gpioId << std::endl; - return UNKNOWN_GPIO_ID; + gpioMapIter = gpioMap.find(gpioId); + if (gpioMapIter == gpioMap.end()) { + sif::warning << "LinuxLibgpioIF::readGpio: Unknown GPIOD ID " << gpioId << std::endl; + return UNKNOWN_GPIO_ID; + } + + if (gpioMapIter->second->gpioType == gpio::GpioTypes::GPIOD_REGULAR) { + GpiodRegular* regularGpio = dynamic_cast(gpioMapIter->second); + if (regularGpio == nullptr) { + return GPIO_TYPE_FAILURE; } + *gpioState = gpiod_line_get_value(regularGpio->lineHandle); + } else { + } - if(gpioMapIter->second->gpioType == gpio::GpioTypes::GPIOD_REGULAR) { - GpiodRegular* regularGpio = dynamic_cast(gpioMapIter->second); - if(regularGpio == nullptr) { - return GPIO_TYPE_FAILURE; - } - *gpioState = gpiod_line_get_value(regularGpio->lineHandle); - } - else { - - } - - - return RETURN_OK; + return RETURN_OK; } -ReturnValue_t LinuxLibgpioIF::checkForConflicts(GpioMap& mapToAdd){ - ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - for(auto& gpioConfig: mapToAdd) { - switch(gpioConfig.second->gpioType) { - case(gpio::GpioTypes::GPIOD_REGULAR): { - auto regularGpio = dynamic_cast(gpioConfig.second); - if(regularGpio == nullptr) { - return GPIO_TYPE_FAILURE; - } - /* Check for conflicts and remove duplicates if necessary */ - result = checkForConflictsRegularGpio(gpioConfig.first, regularGpio, mapToAdd); - if(result != HasReturnvaluesIF::RETURN_OK) { - status = result; - } - break; +ReturnValue_t LinuxLibgpioIF::checkForConflicts(GpioMap& mapToAdd) { + ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + for (auto& gpioConfig : mapToAdd) { + switch (gpioConfig.second->gpioType) { + case (gpio::GpioTypes::GPIOD_REGULAR): { + auto regularGpio = dynamic_cast(gpioConfig.second); + if (regularGpio == nullptr) { + return GPIO_TYPE_FAILURE; } - case(gpio::GpioTypes::CALLBACK): { - auto callbackGpio = dynamic_cast(gpioConfig.second); - if(callbackGpio == nullptr) { - return GPIO_TYPE_FAILURE; - } - /* Check for conflicts and remove duplicates if necessary */ - result = checkForConflictsCallbackGpio(gpioConfig.first, callbackGpio, mapToAdd); - if(result != HasReturnvaluesIF::RETURN_OK) { - status = result; - } - break; + /* Check for conflicts and remove duplicates if necessary */ + result = checkForConflictsRegularGpio(gpioConfig.first, regularGpio, mapToAdd); + if (result != HasReturnvaluesIF::RETURN_OK) { + status = result; } - default: { - + break; + } + case (gpio::GpioTypes::CALLBACK): { + auto callbackGpio = dynamic_cast(gpioConfig.second); + if (callbackGpio == nullptr) { + return GPIO_TYPE_FAILURE; } + /* Check for conflicts and remove duplicates if necessary */ + result = checkForConflictsCallbackGpio(gpioConfig.first, callbackGpio, mapToAdd); + if (result != HasReturnvaluesIF::RETURN_OK) { + status = result; } + break; + } + default: { + } } - return status; + } + return status; } - ReturnValue_t LinuxLibgpioIF::checkForConflictsRegularGpio(gpioId_t gpioIdToCheck, - GpiodRegular* gpioToCheck, GpioMap& mapToAdd) { - /* Cross check with private map */ - gpioMapIter = gpioMap.find(gpioIdToCheck); - if(gpioMapIter != gpioMap.end()) { - if(gpioMapIter->second->gpioType != gpio::GpioTypes::GPIOD_REGULAR) { - sif::warning << "LinuxLibgpioIF::checkForConflicts: ID already exists for different " - "GPIO type" << gpioIdToCheck << ". Removing duplicate." << std::endl; - mapToAdd.erase(gpioIdToCheck); - return HasReturnvaluesIF::RETURN_OK; - } - auto ownRegularGpio = dynamic_cast(gpioMapIter->second); - if(ownRegularGpio == nullptr) { - return GPIO_TYPE_FAILURE; - } - - /* Remove element from map to add because a entry for this GPIO - already exists */ - sif::warning << "LinuxLibgpioIF::checkForConflictsRegularGpio: Duplicate GPIO definition" - << " detected. Duplicate will be removed from map to add." << std::endl; - mapToAdd.erase(gpioIdToCheck); + GpiodRegular* gpioToCheck, + GpioMap& mapToAdd) { + /* Cross check with private map */ + gpioMapIter = gpioMap.find(gpioIdToCheck); + if (gpioMapIter != gpioMap.end()) { + if (gpioMapIter->second->gpioType != gpio::GpioTypes::GPIOD_REGULAR) { + sif::warning << "LinuxLibgpioIF::checkForConflicts: ID already exists for different " + "GPIO type" + << gpioIdToCheck << ". Removing duplicate." << std::endl; + mapToAdd.erase(gpioIdToCheck); + return HasReturnvaluesIF::RETURN_OK; } - return HasReturnvaluesIF::RETURN_OK; + auto ownRegularGpio = dynamic_cast(gpioMapIter->second); + if (ownRegularGpio == nullptr) { + return GPIO_TYPE_FAILURE; + } + + /* Remove element from map to add because a entry for this GPIO + already exists */ + sif::warning << "LinuxLibgpioIF::checkForConflictsRegularGpio: Duplicate GPIO definition" + << " detected. Duplicate will be removed from map to add." << std::endl; + mapToAdd.erase(gpioIdToCheck); + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t LinuxLibgpioIF::checkForConflictsCallbackGpio(gpioId_t gpioIdToCheck, - GpioCallback *callbackGpio, GpioMap& mapToAdd) { - /* Cross check with private map */ - gpioMapIter = gpioMap.find(gpioIdToCheck); - if(gpioMapIter != gpioMap.end()) { - if(gpioMapIter->second->gpioType != gpio::GpioTypes::CALLBACK) { - sif::warning << "LinuxLibgpioIF::checkForConflicts: ID already exists for different " - "GPIO type" << gpioIdToCheck << ". Removing duplicate." << std::endl; - mapToAdd.erase(gpioIdToCheck); - return HasReturnvaluesIF::RETURN_OK; - } - - /* Remove element from map to add because a entry for this GPIO - already exists */ - sif::warning << "LinuxLibgpioIF::checkForConflictsRegularGpio: Duplicate GPIO definition" - << " detected. Duplicate will be removed from map to add." << std::endl; - mapToAdd.erase(gpioIdToCheck); + GpioCallback* callbackGpio, + GpioMap& mapToAdd) { + /* Cross check with private map */ + gpioMapIter = gpioMap.find(gpioIdToCheck); + if (gpioMapIter != gpioMap.end()) { + if (gpioMapIter->second->gpioType != gpio::GpioTypes::CALLBACK) { + sif::warning << "LinuxLibgpioIF::checkForConflicts: ID already exists for different " + "GPIO type" + << gpioIdToCheck << ". Removing duplicate." << std::endl; + mapToAdd.erase(gpioIdToCheck); + return HasReturnvaluesIF::RETURN_OK; } - return HasReturnvaluesIF::RETURN_OK; + + /* Remove element from map to add because a entry for this GPIO + already exists */ + sif::warning << "LinuxLibgpioIF::checkForConflictsRegularGpio: Duplicate GPIO definition" + << " detected. Duplicate will be removed from map to add." << std::endl; + mapToAdd.erase(gpioIdToCheck); + } + return HasReturnvaluesIF::RETURN_OK; } diff --git a/linux/archive/gpio/LinuxLibgpioIF.h b/linux/archive/gpio/LinuxLibgpioIF.h index 9c444e50..1c974efb 100644 --- a/linux/archive/gpio/LinuxLibgpioIF.h +++ b/linux/archive/gpio/LinuxLibgpioIF.h @@ -1,9 +1,9 @@ #ifndef LINUX_GPIO_LINUXLIBGPIOIF_H_ #define LINUX_GPIO_LINUXLIBGPIOIF_H_ -#include -#include #include +#include +#include class GpioCookie; @@ -15,63 +15,61 @@ class GpioCookie; * 2019.1. */ class LinuxLibgpioIF : public GpioIF, public SystemObject { -public: + public: + static const uint8_t gpioRetvalId = CLASS_ID::LINUX_LIBGPIO_IF; - static const uint8_t gpioRetvalId = CLASS_ID::LINUX_LIBGPIO_IF; + static constexpr ReturnValue_t UNKNOWN_GPIO_ID = + HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 1); + static constexpr ReturnValue_t DRIVE_GPIO_FAILURE = + HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 2); + static constexpr ReturnValue_t GPIO_TYPE_FAILURE = + HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 3); + static constexpr ReturnValue_t GPIO_INVALID_INSTANCE = + HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 4); - static constexpr ReturnValue_t UNKNOWN_GPIO_ID = - HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 1); - static constexpr ReturnValue_t DRIVE_GPIO_FAILURE = - HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 2); - static constexpr ReturnValue_t GPIO_TYPE_FAILURE = - HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 3); - static constexpr ReturnValue_t GPIO_INVALID_INSTANCE = - HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 4); + LinuxLibgpioIF(object_id_t objectId); + virtual ~LinuxLibgpioIF(); - LinuxLibgpioIF(object_id_t objectId); - virtual ~LinuxLibgpioIF(); + ReturnValue_t addGpios(GpioCookie* gpioCookie) override; + ReturnValue_t pullHigh(gpioId_t gpioId) override; + ReturnValue_t pullLow(gpioId_t gpioId) override; + ReturnValue_t readGpio(gpioId_t gpioId, int* gpioState) override; - ReturnValue_t addGpios(GpioCookie* gpioCookie) override; - ReturnValue_t pullHigh(gpioId_t gpioId) override; - ReturnValue_t pullLow(gpioId_t gpioId) override; - ReturnValue_t readGpio(gpioId_t gpioId, int* gpioState) override; + private: + /* Holds the information and configuration of all used GPIOs */ + GpioMap gpioMap; + GpioMapIter gpioMapIter; -private: - /* Holds the information and configuration of all used GPIOs */ - GpioMap gpioMap; - GpioMapIter gpioMapIter; + /** + * @brief This functions drives line of a GPIO specified by the GPIO ID. + * + * @param gpioId The GPIO ID of the GPIO to drive. + * @param logiclevel The logic level to set. O or 1. + */ + ReturnValue_t driveGpio(gpioId_t gpioId, GpiodRegularBase& regularGpio, unsigned int logiclevel); - /** - * @brief This functions drives line of a GPIO specified by the GPIO ID. - * - * @param gpioId The GPIO ID of the GPIO to drive. - * @param logiclevel The logic level to set. O or 1. - */ - ReturnValue_t driveGpio(gpioId_t gpioId, GpiodRegularBase& regularGpio, unsigned int logiclevel); + ReturnValue_t configureRegularGpio(gpioId_t gpioId, GpiodRegularBase& regularGpio); - ReturnValue_t configureRegularGpio(gpioId_t gpioId, GpiodRegularBase& regularGpio); + /** + * @brief This function checks if GPIOs are already registered and whether + * there exists a conflict in the GPIO configuration. E.g. the + * direction. + * + * @param mapToAdd The GPIOs which shall be added to the gpioMap. + * + * @return RETURN_OK if successful, otherwise RETURN_FAILED + */ + ReturnValue_t checkForConflicts(GpioMap& mapToAdd); - /** - * @brief This function checks if GPIOs are already registered and whether - * there exists a conflict in the GPIO configuration. E.g. the - * direction. - * - * @param mapToAdd The GPIOs which shall be added to the gpioMap. - * - * @return RETURN_OK if successful, otherwise RETURN_FAILED - */ - ReturnValue_t checkForConflicts(GpioMap& mapToAdd); - - ReturnValue_t checkForConflictsRegularGpio(gpioId_t gpiodId, GpiodRegular* regularGpio, - GpioMap& mapToAdd); - ReturnValue_t checkForConflictsCallbackGpio(gpioId_t gpiodId, GpioCallback* regularGpio, - GpioMap& mapToAdd); - - /** - * @brief Performs the initial configuration of all GPIOs specified in the GpioMap mapToAdd. - */ - ReturnValue_t configureGpios(GpioMap& mapToAdd); + ReturnValue_t checkForConflictsRegularGpio(gpioId_t gpiodId, GpiodRegular* regularGpio, + GpioMap& mapToAdd); + ReturnValue_t checkForConflictsCallbackGpio(gpioId_t gpiodId, GpioCallback* regularGpio, + GpioMap& mapToAdd); + /** + * @brief Performs the initial configuration of all GPIOs specified in the GpioMap mapToAdd. + */ + ReturnValue_t configureGpios(GpioMap& mapToAdd); }; #endif /* LINUX_GPIO_LINUXLIBGPIOIF_H_ */ diff --git a/linux/archive/gpio/gpioDefinitions.h b/linux/archive/gpio/gpioDefinitions.h index 66c0b005..0db4db11 100644 --- a/linux/archive/gpio/gpioDefinitions.h +++ b/linux/archive/gpio/gpioDefinitions.h @@ -8,29 +8,16 @@ using gpioId_t = uint16_t; namespace gpio { -enum Levels { - LOW = 0, - HIGH = 1 -}; +enum Levels { LOW = 0, HIGH = 1 }; -enum Direction { - IN = 0, - OUT = 1 -}; +enum Direction { IN = 0, OUT = 1 }; -enum GpioOperation { - READ, - WRITE -}; +enum GpioOperation { READ, WRITE }; -enum GpioTypes { - NONE, - GPIOD_REGULAR, - CALLBACK -}; +enum GpioTypes { NONE, GPIOD_REGULAR, CALLBACK }; static constexpr gpioId_t NO_GPIO = -1; -} +} // namespace gpio /** * @brief Struct containing information about the GPIO to use. This is @@ -47,51 +34,49 @@ static constexpr gpioId_t NO_GPIO = -1; * pointer. */ class GpioBase { -public: + public: + GpioBase() = default; - GpioBase() = default; + GpioBase(gpio::GpioTypes gpioType, std::string consumer, gpio::Direction direction, int initValue) + : gpioType(gpioType), consumer(consumer), direction(direction), initValue(initValue) {} - GpioBase(gpio::GpioTypes gpioType, std::string consumer, gpio::Direction direction, - int initValue): - gpioType(gpioType), consumer(consumer),direction(direction), initValue(initValue) {} + virtual ~GpioBase(){}; - virtual~ GpioBase() {}; - - /* Can be used to cast GpioBase to a concrete child implementation */ - gpio::GpioTypes gpioType = gpio::GpioTypes::NONE; - std::string consumer; - gpio::Direction direction = gpio::Direction::IN; - int initValue = 0; + /* Can be used to cast GpioBase to a concrete child implementation */ + gpio::GpioTypes gpioType = gpio::GpioTypes::NONE; + std::string consumer; + gpio::Direction direction = gpio::Direction::IN; + int initValue = 0; }; -class GpiodRegular: public GpioBase { -public: - GpiodRegular(): GpioBase(gpio::GpioTypes::GPIOD_REGULAR, std::string(), - gpio::Direction::IN, 0) {}; +class GpiodRegular : public GpioBase { + public: + GpiodRegular() + : GpioBase(gpio::GpioTypes::GPIOD_REGULAR, std::string(), gpio::Direction::IN, 0){}; - GpiodRegular(std::string chipname_, int lineNum_, std::string consumer_, - gpio::Direction direction_, int initValue_): - GpioBase(gpio::GpioTypes::GPIOD_REGULAR, consumer_, direction_, initValue_), - chipname(chipname_), lineNum(lineNum_) {} - std::string chipname; - int lineNum = 0; - struct gpiod_line* lineHandle = nullptr; + GpiodRegular(std::string chipname_, int lineNum_, std::string consumer_, + gpio::Direction direction_, int initValue_) + : GpioBase(gpio::GpioTypes::GPIOD_REGULAR, consumer_, direction_, initValue_), + chipname(chipname_), + lineNum(lineNum_) {} + std::string chipname; + int lineNum = 0; + struct gpiod_line* lineHandle = nullptr; }; -class GpioCallback: public GpioBase { -public: - GpioCallback(std::string consumer, gpio::Direction direction_, int initValue_, - void (* callback) (gpioId_t gpioId, gpio::GpioOperation gpioOp, int value, void* args), - void* callbackArgs): - GpioBase(gpio::GpioTypes::CALLBACK, consumer, direction_, initValue_), - callback(callback), callbackArgs(callbackArgs) {} +class GpioCallback : public GpioBase { + public: + GpioCallback(std::string consumer, gpio::Direction direction_, int initValue_, + void (*callback)(gpioId_t gpioId, gpio::GpioOperation gpioOp, int value, void* args), + void* callbackArgs) + : GpioBase(gpio::GpioTypes::CALLBACK, consumer, direction_, initValue_), + callback(callback), + callbackArgs(callbackArgs) {} - void (* callback) (gpioId_t gpioId, gpio::GpioOperation gpioOp, - int value, void* args) = nullptr; - void* callbackArgs = nullptr; + void (*callback)(gpioId_t gpioId, gpio::GpioOperation gpioOp, int value, void* args) = nullptr; + void* callbackArgs = nullptr; }; - using GpioMap = std::unordered_map; using GpioMapIter = GpioMap::iterator; diff --git a/linux/archive/tmtc/CCSDSIPCoreBridge.cpp b/linux/archive/tmtc/CCSDSIPCoreBridge.cpp index 982f7fc2..607ccebd 100644 --- a/linux/archive/tmtc/CCSDSIPCoreBridge.cpp +++ b/linux/archive/tmtc/CCSDSIPCoreBridge.cpp @@ -1,136 +1,128 @@ -#include #include - #include +#include CCSDSIPCoreBridge::CCSDSIPCoreBridge(object_id_t objectId, object_id_t tcDestination, - object_id_t tmStoreId, object_id_t tcStoreId, LinuxLibgpioIF* gpioComIF, - std::string uioPtme, gpioId_t papbBusyId, gpioId_t papbEmptyId) : - TmTcBridge(objectId, tcDestination, tmStoreId, tcStoreId), gpioComIF(gpioComIF), uioPtme( - uioPtme), papbBusyId(papbBusyId), papbEmptyId(papbEmptyId) { -} + object_id_t tmStoreId, object_id_t tcStoreId, + LinuxLibgpioIF* gpioComIF, std::string uioPtme, + gpioId_t papbBusyId, gpioId_t papbEmptyId) + : TmTcBridge(objectId, tcDestination, tmStoreId, tcStoreId), + gpioComIF(gpioComIF), + uioPtme(uioPtme), + papbBusyId(papbBusyId), + papbEmptyId(papbEmptyId) {} -CCSDSIPCoreBridge::~CCSDSIPCoreBridge() { -} +CCSDSIPCoreBridge::~CCSDSIPCoreBridge() {} ReturnValue_t CCSDSIPCoreBridge::initialize() { - ReturnValue_t result = TmTcBridge::initialize(); + ReturnValue_t result = TmTcBridge::initialize(); - fd = open("/dev/uio0", O_RDWR); - if (fd < 1) { - sif::debug << "CCSDSIPCoreBridge::initialize: Invalid UIO device file" << std::endl; - return RETURN_FAILED; - } + fd = open("/dev/uio0", O_RDWR); + if (fd < 1) { + sif::debug << "CCSDSIPCoreBridge::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_READ | PROT_WRITE, - MAP_SHARED, fd, 0)); + /** + * Map uio device in virtual address space + * PROT_WRITE: Map uio device in writable only mode + */ + ptmeBaseAddress = + static_cast(mmap(NULL, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)); - if (ptmeBaseAddress == MAP_FAILED) { - sif::error << "CCSDSIPCoreBridge::initialize: Failed to map uio address" << std::endl; - return RETURN_FAILED; - } + if (ptmeBaseAddress == MAP_FAILED) { + sif::error << "CCSDSIPCoreBridge::initialize: Failed to map uio address" << std::endl; + return RETURN_FAILED; + } - return result; + return result; } ReturnValue_t CCSDSIPCoreBridge::handleTm() { - #if OBSW_TEST_CCSDS_PTME == 1 - return sendTestFrame(); + return sendTestFrame(); #else - return TmTcBridge::handleTm(); + return TmTcBridge::handleTm(); #endif - } -ReturnValue_t CCSDSIPCoreBridge::sendTm(const uint8_t * data, size_t dataLen) { +ReturnValue_t CCSDSIPCoreBridge::sendTm(const uint8_t* data, size_t dataLen) { + if (pollPapbBusySignal() == RETURN_OK) { + startPacketTransfer(); + } - if(pollPapbBusySignal() == RETURN_OK) { - startPacketTransfer(); + for (size_t idx = 0; idx < dataLen; idx++) { + if (pollPapbBusySignal() == RETURN_OK) { + *(ptmeBaseAddress + PTME_DATA_REG_OFFSET) = static_cast(*(data + idx)); + } else { + sif::debug << "CCSDSIPCoreBridge::sendTm: Only written " << idx - 1 << " of " << dataLen + << " data" << std::endl; + return RETURN_FAILED; } + } - for(size_t idx = 0; idx < dataLen; idx++) { - if(pollPapbBusySignal() == RETURN_OK) { - *(ptmeBaseAddress + PTME_DATA_REG_OFFSET) = static_cast(*(data + idx)); - } - else { - sif::debug << "CCSDSIPCoreBridge::sendTm: Only written " << idx - 1 << " of " << dataLen - << " data" << std::endl; - return RETURN_FAILED; - } - } - - if(pollPapbBusySignal() == RETURN_OK) { - endPacketTransfer(); - } - return RETURN_OK; + if (pollPapbBusySignal() == RETURN_OK) { + endPacketTransfer(); + } + return RETURN_OK; } -void CCSDSIPCoreBridge::startPacketTransfer() { - *ptmeBaseAddress = PTME_CONFIG_START; -} +void CCSDSIPCoreBridge::startPacketTransfer() { *ptmeBaseAddress = PTME_CONFIG_START; } -void CCSDSIPCoreBridge::endPacketTransfer() { - *ptmeBaseAddress = PTME_CONFIG_END; -} +void CCSDSIPCoreBridge::endPacketTransfer() { *ptmeBaseAddress = PTME_CONFIG_END; } ReturnValue_t CCSDSIPCoreBridge::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::debug << "CCSDSIPCoreBridge::pollPapbBusySignal: Failed to read papb busy signal" - << std::endl; - return RETURN_FAILED; - } - if (!papbBusyState) { - sif::debug << "CCSDSIPCoreBridge::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::debug << "CCSDSIPCoreBridge::pollPapbBusySignal: Failed to read papb busy signal" + << std::endl; + return RETURN_FAILED; + } + if (!papbBusyState) { + sif::debug << "CCSDSIPCoreBridge::pollPapbBusySignal: PAPB busy" << std::endl; + return PAPB_BUSY; + } - return RETURN_OK; + return RETURN_OK; } void CCSDSIPCoreBridge::isPtmeBufferEmpty() { - 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::debug << "CCSDSIPCoreBridge::isPtmeBufferEmpty: Failed to read papb empty signal" - << std::endl; - return; - } - - if (papbEmptyState == 1) { - sif::debug << "CCSDSIPCoreBridge::isPtmeBufferEmpty: Buffer is empty" << std::endl; - } - else { - sif::debug << "CCSDSIPCoreBridge::isPtmeBufferEmpty: Buffer is not empty" << std::endl; - } + if (result != RETURN_OK) { + sif::debug << "CCSDSIPCoreBridge::isPtmeBufferEmpty: Failed to read papb empty signal" + << std::endl; return; + } + + if (papbEmptyState == 1) { + sif::debug << "CCSDSIPCoreBridge::isPtmeBufferEmpty: Buffer is empty" << std::endl; + } else { + sif::debug << "CCSDSIPCoreBridge::isPtmeBufferEmpty: Buffer is not empty" << std::endl; + } + return; } ReturnValue_t CCSDSIPCoreBridge::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 = sendTm(testPacket, 1105); - if(result != RETURN_OK) { - return result; - } + ReturnValue_t result = sendTm(testPacket, 1105); + if (result != RETURN_OK) { + return result; + } - return RETURN_OK; + return RETURN_OK; } diff --git a/linux/archive/tmtc/CCSDSIPCoreBridge.h b/linux/archive/tmtc/CCSDSIPCoreBridge.h index 2ba68a3a..074769c4 100644 --- a/linux/archive/tmtc/CCSDSIPCoreBridge.h +++ b/linux/archive/tmtc/CCSDSIPCoreBridge.h @@ -1,131 +1,129 @@ #ifndef MISSION_OBC_CCSDSIPCOREBRIDGE_H_ #define MISSION_OBC_CCSDSIPCOREBRIDGE_H_ -#include "OBSWConfig.h" #include #include #include #include +#include "OBSWConfig.h" + /** * @brief This class handles the interfacing to the telemetry (PTME) and telecommand (PDEC) IP * cores responsible for the CCSDS encoding and decoding. The IP cores are implemented * on the programmable logic and are accessible through the linux UIO driver. */ -class CCSDSIPCoreBridge: public TmTcBridge { -public: - /** - * @brief Constructor - * - * @param objectId - * @param tcDestination - * @param tmStoreId - * @param tcStoreId - * @param uioPtme Name of the uio device file which provides access to the PTME IP Core. - * @param papbBusyId The ID of the GPIO which is connected to the PAPBBusy_N signal of the - * PTME IP Core. A low logic level indicates the PTME is not ready to - * receive more data. - * @param papbEmptyId The ID of the GPIO which is connected to the PAPBEmpty signal of the - * PTME IP Core. The signal is high when there are no packets in the - * external buffer memory (BRAM). - */ - CCSDSIPCoreBridge(object_id_t objectId, object_id_t tcDestination, object_id_t tmStoreId, - object_id_t tcStoreId, LinuxLibgpioIF* gpioComIF, std::string uioPtme, - gpioId_t papbBusyId, gpioId_t papbEmptyId); - virtual ~CCSDSIPCoreBridge(); +class CCSDSIPCoreBridge : public TmTcBridge { + public: + /** + * @brief Constructor + * + * @param objectId + * @param tcDestination + * @param tmStoreId + * @param tcStoreId + * @param uioPtme Name of the uio device file which provides access to the PTME IP Core. + * @param papbBusyId The ID of the GPIO which is connected to the PAPBBusy_N signal of the + * PTME IP Core. A low logic level indicates the PTME is not ready to + * receive more data. + * @param papbEmptyId The ID of the GPIO which is connected to the PAPBEmpty signal of the + * PTME IP Core. The signal is high when there are no packets in the + * external buffer memory (BRAM). + */ + CCSDSIPCoreBridge(object_id_t objectId, object_id_t tcDestination, object_id_t tmStoreId, + object_id_t tcStoreId, LinuxLibgpioIF* gpioComIF, std::string uioPtme, + gpioId_t papbBusyId, gpioId_t papbEmptyId); + virtual ~CCSDSIPCoreBridge(); - ReturnValue_t initialize() override; + ReturnValue_t initialize() override; -protected: + protected: + /** + * Overwriting this function to provide the capability of testing the PTME IP Core + * implementation. + */ + virtual ReturnValue_t handleTm() override; - /** - * Overwriting this function to provide the capability of testing the PTME IP Core - * implementation. - */ - virtual ReturnValue_t handleTm() override; + virtual ReturnValue_t sendTm(const uint8_t* data, size_t dataLen) override; - virtual ReturnValue_t sendTm(const uint8_t * data, size_t dataLen) override; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_IP_CORE_BRIDGE; -private: + static const ReturnValue_t PAPB_BUSY = MAKE_RETURN_CODE(0xA0); - static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_IP_CORE_BRIDGE; + /** Size of mapped address space. 4k (minimal size of pl device) */ + // static const int MAP_SIZE = 0xFA0; + static const int MAP_SIZE = 0x1000; - static const ReturnValue_t PAPB_BUSY = MAKE_RETURN_CODE(0xA0); + /** + * Configuration bits: + * bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00 + * bit[2]: Set this bit to 1 to abort a transfered packet + * bit[3]: Signals to PTME the start of a new telemetry packet + */ + static const uint32_t PTME_CONFIG_START = 0x8; + /** + * Writing this word to the ptme base address signals to the PTME that a complete tm packet has + * been transferred. + */ + static const uint32_t PTME_CONFIG_END = 0x0; - /** Size of mapped address space. 4k (minimal size of pl device) */ -// static const int MAP_SIZE = 0xFA0; - static const int MAP_SIZE = 0x1000; + /** + * Writing to this offset within the PTME memory space will insert data for encoding to the + * PTME IP core. + * The address offset is 0x400 (= 4 * 256) + */ + static const int PTME_DATA_REG_OFFSET = 256; - /** - * Configuration bits: - * bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00 - * bit[2]: Set this bit to 1 to abort a transfered packet - * bit[3]: Signals to PTME the start of a new telemetry packet - */ - static const uint32_t PTME_CONFIG_START = 0x8; + LinuxLibgpioIF* gpioComIF = nullptr; - /** - * Writing this word to the ptme base address signals to the PTME that a complete tm packet has - * been transferred. - */ - static const uint32_t PTME_CONFIG_END = 0x0; + /** The uio device file related to the PTME IP Core */ + std::string uioPtme; - /** - * Writing to this offset within the PTME memory space will insert data for encoding to the - * PTME IP core. - * The address offset is 0x400 (= 4 * 256) - */ - static const int PTME_DATA_REG_OFFSET = 256; + /** Pulled to low when PTME not ready to receive data */ + gpioId_t papbBusyId = gpio::NO_GPIO; - LinuxLibgpioIF* gpioComIF = nullptr; + /** High when externally buffer memory of PTME is empty */ + gpioId_t papbEmptyId = gpio::NO_GPIO; - /** The uio device file related to the PTME IP Core */ - std::string uioPtme; + /** The file descriptor of the UIO driver */ + int fd; - /** Pulled to low when PTME not ready to receive data */ - gpioId_t papbBusyId = gpio::NO_GPIO; + uint32_t* ptmeBaseAddress = nullptr; - /** High when externally buffer memory of PTME is empty */ - gpioId_t papbEmptyId = gpio::NO_GPIO; + /** + * @brief This function sends the config byte to the PTME IP Core to initiate a packet + * transfer. + */ + void startPacketTransfer(); - /** The file descriptor of the UIO driver */ - int fd; + /** + * @brief This function sends the config byte to the PTME IP Core to signal the end of a + * packet transfer. + */ + void endPacketTransfer(); - uint32_t* ptmeBaseAddress = nullptr; + /** + * @brief This function reads the papb busy signal indicating whether the PAPB interface is + * ready to receive more data or not. PAPB is ready when PAPB_Busy_N == '1'. + * + * @return RETURN_OK when ready to receive data else PAPB_BUSY. + */ + ReturnValue_t pollPapbBusySignal(); - /** - * @brief This function sends the config byte to the PTME IP Core to initiate a packet - * transfer. - */ - void startPacketTransfer(); + /** + * @brief This function can be used for debugging to check wheter there are packets in + * the packet buffer of the PTME or not. + */ + void isPtmeBufferEmpty(); - /** - * @brief This function sends the config byte to the PTME IP Core to signal the end of a - * packet transfer. - */ - void endPacketTransfer(); - - /** - * @brief This function reads the papb busy signal indicating whether the PAPB interface is - * ready to receive more data or not. PAPB is ready when PAPB_Busy_N == '1'. - * - * @return RETURN_OK when ready to receive data else PAPB_BUSY. - */ - ReturnValue_t pollPapbBusySignal(); - - /** - * @brief This function can be used for debugging to check wheter there are packets in - * the packet buffer of the PTME or not. - */ - void isPtmeBufferEmpty(); - - /** - * @brief This function sends a complete telemetry transfer frame data field (1105 bytes) - * to the input of the PTME IP Core. Can be used to test the implementation. - */ - ReturnValue_t sendTestFrame(); + /** + * @brief This function sends a complete telemetry transfer frame data field (1105 bytes) + * to the input of the PTME IP Core. Can be used to test the implementation. + */ + ReturnValue_t sendTestFrame(); }; #endif /* MISSION_OBC_CCSDSIPCOREBRIDGE_H_ */ diff --git a/linux/boardtest/I2cTestClass.cpp b/linux/boardtest/I2cTestClass.cpp index 66c16b33..090691e2 100644 --- a/linux/boardtest/I2cTestClass.cpp +++ b/linux/boardtest/I2cTestClass.cpp @@ -1,8 +1,5 @@ #include -I2cTestClass::I2cTestClass(object_id_t objectId): TestTask(objectId) { -} +I2cTestClass::I2cTestClass(object_id_t objectId) : TestTask(objectId) {} -ReturnValue_t I2cTestClass::performPeriodicAction() { - return HasReturnvaluesIF::RETURN_OK; -} +ReturnValue_t I2cTestClass::performPeriodicAction() { return HasReturnvaluesIF::RETURN_OK; } diff --git a/linux/boardtest/I2cTestClass.h b/linux/boardtest/I2cTestClass.h index 172a7f71..314f9dda 100644 --- a/linux/boardtest/I2cTestClass.h +++ b/linux/boardtest/I2cTestClass.h @@ -3,15 +3,13 @@ #include -class I2cTestClass: public TestTask { -public: - I2cTestClass(object_id_t objectId); +class I2cTestClass : public TestTask { + public: + I2cTestClass(object_id_t objectId); - ReturnValue_t performPeriodicAction() override; -private: + ReturnValue_t performPeriodicAction() override; + private: }; - - #endif /* LINUX_BOARDTEST_I2CTESTCLASS_H_ */ diff --git a/linux/boardtest/LibgpiodTest.cpp b/linux/boardtest/LibgpiodTest.cpp index 8eb9b536..0c5ebe2a 100644 --- a/linux/boardtest/LibgpiodTest.cpp +++ b/linux/boardtest/LibgpiodTest.cpp @@ -1,135 +1,127 @@ #include "LibgpiodTest.h" +#include +#include +#include + #include "devices/gpioIds.h" -#include -#include -#include - -LibgpiodTest::LibgpiodTest(object_id_t objectId, object_id_t gpioIfobjectId, - GpioCookie* gpioCookie): - TestTask(objectId) { - - gpioInterface = ObjectManager::instance()->get(gpioIfobjectId); - if (gpioInterface == nullptr) { - sif::error << "LibgpiodTest::LibgpiodTest: Invalid Gpio interface." << std::endl; - } - gpioInterface->addGpios(gpioCookie); - testCase = TestCases::BLINK; +LibgpiodTest::LibgpiodTest(object_id_t objectId, object_id_t gpioIfobjectId, GpioCookie* gpioCookie) + : TestTask(objectId) { + gpioInterface = ObjectManager::instance()->get(gpioIfobjectId); + if (gpioInterface == nullptr) { + sif::error << "LibgpiodTest::LibgpiodTest: Invalid Gpio interface." << std::endl; + } + gpioInterface->addGpios(gpioCookie); + testCase = TestCases::BLINK; } -LibgpiodTest::~LibgpiodTest() { -} +LibgpiodTest::~LibgpiodTest() {} ReturnValue_t LibgpiodTest::performPeriodicAction() { - int gpioState; - ReturnValue_t result; + int gpioState; + ReturnValue_t result; - switch(testCase) { - case(TestCases::READ): { - result = gpioInterface->readGpio(gpioIds::TEST_ID_0, &gpioState); - if (result != RETURN_OK) { - sif::warning << "LibgpiodTest::performPeriodicAction: Failed to read gpio " - << std::endl; - return RETURN_FAILED; - } - else { - sif::debug << "LibgpiodTest::performPeriodicAction: MIO 0 state = " << gpioState - << std::endl; - } - break; + switch (testCase) { + case (TestCases::READ): { + result = gpioInterface->readGpio(gpioIds::TEST_ID_0, &gpioState); + if (result != RETURN_OK) { + sif::warning << "LibgpiodTest::performPeriodicAction: Failed to read gpio " << std::endl; + return RETURN_FAILED; + } else { + sif::debug << "LibgpiodTest::performPeriodicAction: MIO 0 state = " << gpioState + << std::endl; + } + break; } - case(TestCases::LOOPBACK): { - break; + case (TestCases::LOOPBACK): { + break; } - case(TestCases::BLINK): { - result = gpioInterface->readGpio(gpioIds::TEST_ID_0, &gpioState); + case (TestCases::BLINK): { + result = gpioInterface->readGpio(gpioIds::TEST_ID_0, &gpioState); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "LibgpiodTest::performPeriodicAction: Failed to read gpio " << std::endl; + return RETURN_FAILED; + } + if (gpioState == 1) { + result = gpioInterface->pullLow(gpioIds::TEST_ID_0); if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "LibgpiodTest::performPeriodicAction: Failed to read gpio " - << std::endl; - return RETURN_FAILED; + sif::warning << "LibgpiodTest::performPeriodicAction: Could not pull GPIO low!" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; } - if (gpioState == 1) { - result = gpioInterface->pullLow(gpioIds::TEST_ID_0); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "LibgpiodTest::performPeriodicAction: Could not pull GPIO low!" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - } - else if (gpioState == 0) { - result = gpioInterface->pullHigh(gpioIds::TEST_ID_0); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "LibgpiodTest::performPeriodicAction: Could not pull GPIO high!" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - } - else { - sif::warning << "LibgpiodTest::performPeriodicAction: Invalid GPIO state" << std::endl; + } else if (gpioState == 0) { + result = gpioInterface->pullHigh(gpioIds::TEST_ID_0); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "LibgpiodTest::performPeriodicAction: Could not pull GPIO high!" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; } + } else { + sif::warning << "LibgpiodTest::performPeriodicAction: Invalid GPIO state" << std::endl; + } - break; + break; } default: - sif::debug << "LibgpiodTest::performPeriodicAction: Invalid test case" << std::endl; - break; - } + sif::debug << "LibgpiodTest::performPeriodicAction: Invalid test case" << std::endl; + break; + } - - return RETURN_OK; + return RETURN_OK; } ReturnValue_t LibgpiodTest::performOneShotAction() { - int gpioState; - ReturnValue_t result; + int gpioState; + ReturnValue_t result; - switch(testCase) { - case(TestCases::READ): { - break; + switch (testCase) { + case (TestCases::READ): { + break; } - case(TestCases::BLINK): { - break; + case (TestCases::BLINK): { + break; } - case(TestCases::LOOPBACK): { - result = gpioInterface->pullHigh(gpioIds::TEST_ID_0); - if(result == HasReturnvaluesIF::RETURN_OK) { - sif::info << "LibgpiodTest::performOneShotAction: " - "GPIO pulled high successfully for loopback test" << std::endl; - } - else { - sif::warning << "LibgpiodTest::performOneShotAction: Could not pull GPIO high!" - << std::endl; - return HasReturnvaluesIF::RETURN_OK; - } - result = gpioInterface->readGpio(gpioIds::TEST_ID_1, &gpioState); - if(result == HasReturnvaluesIF::RETURN_OK and gpioState == 1) { - sif::info << "LibgpiodTest::performOneShotAction: " - "GPIO state read successfully and is high" << std::endl; - } - else { - sif::warning << "LibgpiodTest::performOneShotAction: GPIO read and is not high!" - << std::endl; - return HasReturnvaluesIF::RETURN_OK; - } + case (TestCases::LOOPBACK): { + result = gpioInterface->pullHigh(gpioIds::TEST_ID_0); + if (result == HasReturnvaluesIF::RETURN_OK) { + sif::info << "LibgpiodTest::performOneShotAction: " + "GPIO pulled high successfully for loopback test" + << std::endl; + } else { + sif::warning << "LibgpiodTest::performOneShotAction: Could not pull GPIO high!" + << std::endl; + return HasReturnvaluesIF::RETURN_OK; + } + result = gpioInterface->readGpio(gpioIds::TEST_ID_1, &gpioState); + if (result == HasReturnvaluesIF::RETURN_OK and gpioState == 1) { + sif::info << "LibgpiodTest::performOneShotAction: " + "GPIO state read successfully and is high" + << std::endl; + } else { + sif::warning << "LibgpiodTest::performOneShotAction: GPIO read and is not high!" + << std::endl; + return HasReturnvaluesIF::RETURN_OK; + } - result = gpioInterface->pullLow(gpioIds::TEST_ID_0); - if(result == HasReturnvaluesIF::RETURN_OK) { - sif::info << "LibgpiodTest::performOneShotAction: " - "GPIO pulled low successfully for loopback test" << std::endl; - } - result = gpioInterface->readGpio(gpioIds::TEST_ID_1, &gpioState); - if(result == HasReturnvaluesIF::RETURN_OK and gpioState == 0) { - sif::info << "LibgpiodTest::performOneShotAction: " - "GPIO state read successfully and is low" << std::endl; - } - else { - sif::warning << "LibgpiodTest::performOneShotAction: GPIO read and is not low!" - << std::endl; - return HasReturnvaluesIF::RETURN_OK; - } - break; + result = gpioInterface->pullLow(gpioIds::TEST_ID_0); + if (result == HasReturnvaluesIF::RETURN_OK) { + sif::info << "LibgpiodTest::performOneShotAction: " + "GPIO pulled low successfully for loopback test" + << std::endl; + } + result = gpioInterface->readGpio(gpioIds::TEST_ID_1, &gpioState); + if (result == HasReturnvaluesIF::RETURN_OK and gpioState == 0) { + sif::info << "LibgpiodTest::performOneShotAction: " + "GPIO state read successfully and is low" + << std::endl; + } else { + sif::warning << "LibgpiodTest::performOneShotAction: GPIO read and is not low!" + << std::endl; + return HasReturnvaluesIF::RETURN_OK; + } + break; } - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } diff --git a/linux/boardtest/LibgpiodTest.h b/linux/boardtest/LibgpiodTest.h index 718d0209..4fcaffdf 100644 --- a/linux/boardtest/LibgpiodTest.h +++ b/linux/boardtest/LibgpiodTest.h @@ -1,34 +1,31 @@ #ifndef TEST_TESTTASKS_LIBGPIODTEST_H_ #define TEST_TESTTASKS_LIBGPIODTEST_H_ -#include "TestTask.h" -#include -#include #include +#include +#include + +#include "TestTask.h" /** * @brief Test for the GPIO read implementation of the LinuxLibgpioIF. * @author J. Meier */ -class LibgpiodTest: public TestTask { -public: - enum TestCases { - READ = 0, - LOOPBACK = 1, - BLINK - }; +class LibgpiodTest : public TestTask { + public: + enum TestCases { READ = 0, LOOPBACK = 1, BLINK }; - TestCases testCase; + TestCases testCase; - LibgpiodTest(object_id_t objectId, object_id_t gpioIfobjectId, GpioCookie* gpioCookie); - virtual ~LibgpiodTest(); + LibgpiodTest(object_id_t objectId, object_id_t gpioIfobjectId, GpioCookie* gpioCookie); + virtual ~LibgpiodTest(); -protected: - ReturnValue_t performOneShotAction() override; - ReturnValue_t performPeriodicAction() override; + protected: + ReturnValue_t performOneShotAction() override; + ReturnValue_t performPeriodicAction() override; -private: - GpioIF* gpioInterface; + private: + GpioIF* gpioInterface; }; #endif /* TEST_TESTTASKS_LIBGPIODTEST_H_ */ diff --git a/linux/boardtest/SpiTestClass.cpp b/linux/boardtest/SpiTestClass.cpp index 65f2ca9f..7ef76d95 100644 --- a/linux/boardtest/SpiTestClass.cpp +++ b/linux/boardtest/SpiTestClass.cpp @@ -1,503 +1,483 @@ #include "SpiTestClass.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + #include "devices/gpioIds.h" -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -SpiTestClass::SpiTestClass(object_id_t objectId, GpioIF* gpioIF): TestTask(objectId), -gpioIF(gpioIF) { - if(gpioIF == nullptr) { - sif::error << "SpiTestClass::SpiTestClass: Invalid GPIO ComIF!" << std::endl; - } - testMode = TestModes::MGM_LIS3MDL; - spiTransferStruct.rx_buf = reinterpret_cast<__u64>(recvBuffer.data()); - spiTransferStruct.tx_buf = reinterpret_cast<__u64>(sendBuffer.data()); +SpiTestClass::SpiTestClass(object_id_t objectId, GpioIF *gpioIF) + : TestTask(objectId), gpioIF(gpioIF) { + if (gpioIF == nullptr) { + sif::error << "SpiTestClass::SpiTestClass: Invalid GPIO ComIF!" << std::endl; + } + testMode = TestModes::MGM_LIS3MDL; + spiTransferStruct.rx_buf = reinterpret_cast<__u64>(recvBuffer.data()); + spiTransferStruct.tx_buf = reinterpret_cast<__u64>(sendBuffer.data()); } ReturnValue_t SpiTestClass::performOneShotAction() { - switch(testMode) { - case(TestModes::NONE): { - break; + switch (testMode) { + case (TestModes::NONE): { + break; } - case(TestModes::MGM_LIS3MDL): { - performLis3MdlTest(mgm0Lis3mdlChipSelect); - break; + case (TestModes::MGM_LIS3MDL): { + performLis3MdlTest(mgm0Lis3mdlChipSelect); + break; } - case(TestModes::MGM_RM3100): { - performRm3100Test(mgm1Rm3100ChipSelect); - break; + case (TestModes::MGM_RM3100): { + performRm3100Test(mgm1Rm3100ChipSelect); + break; } - case(TestModes::GYRO_L3GD20H): { - performL3gTest(gyro1L3gd20ChipSelect); - break; + case (TestModes::GYRO_L3GD20H): { + performL3gTest(gyro1L3gd20ChipSelect); + break; } - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t SpiTestClass::performPeriodicAction() { - return HasReturnvaluesIF::RETURN_OK; -} +ReturnValue_t SpiTestClass::performPeriodicAction() { return HasReturnvaluesIF::RETURN_OK; } void SpiTestClass::performRm3100Test(uint8_t mgmId) { - /* Configure all SPI chip selects and pull them high */ - acsInit(); + /* Configure all SPI chip selects and pull them high */ + acsInit(); - /* Adapt accordingly */ - if(mgmId != mgm1Rm3100ChipSelect and mgmId != mgm3Rm3100ChipSelect) { - sif::warning << "SpiTestClass::performRm3100Test: Invalid MGM ID!" << std::endl; - } - gpioId_t currentGpioId = 0; - uint8_t chipSelectPin = mgmId; - if(chipSelectPin == mgm1Rm3100ChipSelect) { - currentGpioId = gpioIds::MGM_1_RM3100_CS; - } - else { - currentGpioId = gpioIds::MGM_3_RM3100_CS; - } - uint32_t rm3100speed = 976'000; - uint8_t rm3100revidReg = 0x36; - spi::SpiModes rm3100mode = spi::SpiModes::MODE_3; + /* Adapt accordingly */ + if (mgmId != mgm1Rm3100ChipSelect and mgmId != mgm3Rm3100ChipSelect) { + sif::warning << "SpiTestClass::performRm3100Test: Invalid MGM ID!" << std::endl; + } + gpioId_t currentGpioId = 0; + uint8_t chipSelectPin = mgmId; + if (chipSelectPin == mgm1Rm3100ChipSelect) { + currentGpioId = gpioIds::MGM_1_RM3100_CS; + } else { + currentGpioId = gpioIds::MGM_3_RM3100_CS; + } + uint32_t rm3100speed = 976'000; + uint8_t rm3100revidReg = 0x36; + spi::SpiModes rm3100mode = spi::SpiModes::MODE_3; #ifdef RASPBERRY_PI - std::string deviceName = "/dev/spidev0.0"; + std::string deviceName = "/dev/spidev0.0"; #else - std::string deviceName = "/dev/spidev2.0"; + std::string deviceName = "/dev/spidev2.0"; #endif - int fileDescriptor = 0; + int fileDescriptor = 0; + UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR, "SpiComIF::initializeInterface"); + if (fileHelper.getOpenResult()) { + sif::error << "SpiTestClass::performRm3100Test: File descriptor could not be opened!" + << std::endl; + return; + } + setSpiSpeedAndMode(fileDescriptor, rm3100mode, rm3100speed); - UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR, - "SpiComIF::initializeInterface"); - if(fileHelper.getOpenResult()) { - sif::error << "SpiTestClass::performRm3100Test: File descriptor could not be opened!" - << std::endl; - return; - } - setSpiSpeedAndMode(fileDescriptor, rm3100mode, rm3100speed); + uint8_t revId = readRegister(fileDescriptor, currentGpioId, rm3100revidReg); + sif::info << "SpiTestClass::performRm3100Test: Revision ID 0b" << std::bitset<8>(revId) + << std::endl; - uint8_t revId = readRegister(fileDescriptor, currentGpioId, rm3100revidReg); - sif::info << "SpiTestClass::performRm3100Test: Revision ID 0b" << std::bitset<8>(revId) << - std::endl; + /* Write configuration to CMM register */ + writeRegister(fileDescriptor, currentGpioId, 0x01, 0x75); + uint8_t cmmRegister = readRm3100Register(fileDescriptor, currentGpioId, 0x01); + sif::info << "SpiTestClass::performRm3100Test: CMM register value: " << std::hex << "0x" + << static_cast(cmmRegister) << std::dec << std::endl; - /* Write configuration to CMM register */ - writeRegister(fileDescriptor, currentGpioId, 0x01, 0x75); - uint8_t cmmRegister = readRm3100Register(fileDescriptor , currentGpioId, 0x01); - sif::info << "SpiTestClass::performRm3100Test: CMM register value: " << - std::hex << "0x" << static_cast(cmmRegister) << std::dec << std::endl; + /* Read the cycle count registers */ + uint8_t cycleCountsRaw[6]; + readMultipleRegisters(fileDescriptor, currentGpioId, 0x04, cycleCountsRaw, 6); - /* Read the cycle count registers */ - uint8_t cycleCountsRaw[6]; - readMultipleRegisters(fileDescriptor, currentGpioId, 0x04, cycleCountsRaw, 6); + uint16_t cycleCountX = cycleCountsRaw[0] << 8 | cycleCountsRaw[1]; + uint16_t cycleCountY = cycleCountsRaw[2] << 8 | cycleCountsRaw[3]; + uint16_t cycleCountZ = cycleCountsRaw[4] << 8 | cycleCountsRaw[5]; - uint16_t cycleCountX = cycleCountsRaw[0] << 8 | cycleCountsRaw[1]; - uint16_t cycleCountY = cycleCountsRaw[2] << 8 | cycleCountsRaw[3]; - uint16_t cycleCountZ = cycleCountsRaw[4] << 8 | cycleCountsRaw[5]; + sif::info << "Cycle count X: " << cycleCountX << std::endl; + sif::info << "Cycle count Y: " << cycleCountY << std::endl; + sif::info << "Cycle count z: " << cycleCountZ << std::endl; - sif::info << "Cycle count X: " << cycleCountX << std::endl; - sif::info << "Cycle count Y: " << cycleCountY << std::endl; - sif::info << "Cycle count z: " << cycleCountZ << std::endl; - - writeRegister(fileDescriptor, currentGpioId, 0x0B, 0x96); - uint8_t tmrcReg = readRm3100Register(fileDescriptor, currentGpioId, 0x0B); - sif::info << "SpiTestClass::performRm3100Test: TMRC register value: " << - std::hex << "0x" << static_cast(tmrcReg) << std::dec << std::endl; + writeRegister(fileDescriptor, currentGpioId, 0x0B, 0x96); + uint8_t tmrcReg = readRm3100Register(fileDescriptor, currentGpioId, 0x0B); + sif::info << "SpiTestClass::performRm3100Test: TMRC register value: " << std::hex << "0x" + << static_cast(tmrcReg) << std::dec << std::endl; + TaskFactory::delayTask(10); + uint8_t statusReg = readRm3100Register(fileDescriptor, currentGpioId, 0x34); + sif::info << "SpiTestClass::performRm3100Test: Status Register 0b" << std::bitset<8>(statusReg) + << std::endl; + /* This means that data is not ready */ + if ((statusReg & 0b1000'0000) == 0) { + sif::warning << "SpiTestClass::performRm3100Test: Data not ready!" << std::endl; TaskFactory::delayTask(10); uint8_t statusReg = readRm3100Register(fileDescriptor, currentGpioId, 0x34); - sif::info << "SpiTestClass::performRm3100Test: Status Register 0b" << - std::bitset<8>(statusReg) << std::endl; - /* This means that data is not ready */ - if((statusReg & 0b1000'0000) == 0) { - sif::warning << "SpiTestClass::performRm3100Test: Data not ready!" << std::endl; - TaskFactory::delayTask(10); - uint8_t statusReg = readRm3100Register(fileDescriptor, currentGpioId, 0x34); - if((statusReg & 0b1000'0000) == 0) { - return; - } + if ((statusReg & 0b1000'0000) == 0) { + return; } + } - uint32_t rm3100DefaultCycleCout = 0xC8; - /* Gain scales lineary with cycle count and is 38 for cycle count 100 */ - float rm3100Gain = rm3100DefaultCycleCout / 100.0 * 38.0; - float scaleFactor = 1 / rm3100Gain; - uint8_t rawValues[9]; - readMultipleRegisters(fileDescriptor, currentGpioId, 0x24, rawValues, 9); + uint32_t rm3100DefaultCycleCout = 0xC8; + /* Gain scales lineary with cycle count and is 38 for cycle count 100 */ + float rm3100Gain = rm3100DefaultCycleCout / 100.0 * 38.0; + float scaleFactor = 1 / rm3100Gain; + uint8_t rawValues[9]; + readMultipleRegisters(fileDescriptor, currentGpioId, 0x24, rawValues, 9); - /* The sensor generates 24 bit signed values */ - int32_t rawX = ((rawValues[0] << 24) | (rawValues[1] << 16) | (rawValues[2] << 8)) >> 8; - int32_t rawY = ((rawValues[3] << 24) | (rawValues[4] << 16) | (rawValues[5] << 8)) >> 8; - int32_t rawZ = ((rawValues[6] << 24) | (rawValues[7] << 16) | (rawValues[8] << 8)) >> 8; + /* The sensor generates 24 bit signed values */ + int32_t rawX = ((rawValues[0] << 24) | (rawValues[1] << 16) | (rawValues[2] << 8)) >> 8; + int32_t rawY = ((rawValues[3] << 24) | (rawValues[4] << 16) | (rawValues[5] << 8)) >> 8; + int32_t rawZ = ((rawValues[6] << 24) | (rawValues[7] << 16) | (rawValues[8] << 8)) >> 8; - float fieldStrengthX = rawX * scaleFactor; - float fieldStrengthY = rawY * scaleFactor; - float fieldStrengthZ = rawZ * scaleFactor; + float fieldStrengthX = rawX * scaleFactor; + float fieldStrengthY = rawY * scaleFactor; + float fieldStrengthZ = rawZ * scaleFactor; - sif::info << "RM3100 measured field strengths in microtesla:" << std::endl; - sif::info << "Field Strength X: " << fieldStrengthX << " uT" << std::endl; - sif::info << "Field Strength Y: " << fieldStrengthY << " uT" << std::endl; - sif::info << "Field Strength Z: " << fieldStrengthZ << " uT" << std::endl; + sif::info << "RM3100 measured field strengths in microtesla:" << std::endl; + sif::info << "Field Strength X: " << fieldStrengthX << " uT" << std::endl; + sif::info << "Field Strength Y: " << fieldStrengthY << " uT" << std::endl; + sif::info << "Field Strength Z: " << fieldStrengthZ << " uT" << std::endl; } void SpiTestClass::performLis3MdlTest(uint8_t lis3Id) { - /* Configure all SPI chip selects and pull them high */ - acsInit(); + /* Configure all SPI chip selects and pull them high */ + acsInit(); - /* Adapt accordingly */ - if(lis3Id != mgm0Lis3mdlChipSelect and lis3Id != mgm2Lis3mdlChipSelect) { - sif::warning << "SpiTestClass::performLis3MdlTest: Invalid MGM ID!" << std::endl; - } - gpioId_t currentGpioId = 0; - uint8_t chipSelectPin = lis3Id; - uint8_t whoAmIReg = 0b0000'1111; - uint8_t whoAmIRegExpectedVal = 0b0011'1101; - if(chipSelectPin == mgm0Lis3mdlChipSelect) { - currentGpioId = gpioIds::MGM_0_LIS3_CS; - } - else { - currentGpioId = gpioIds::MGM_2_LIS3_CS; - } - uint32_t spiSpeed = 10'000'000; - spi::SpiModes spiMode = spi::SpiModes::MODE_0; + /* Adapt accordingly */ + if (lis3Id != mgm0Lis3mdlChipSelect and lis3Id != mgm2Lis3mdlChipSelect) { + sif::warning << "SpiTestClass::performLis3MdlTest: Invalid MGM ID!" << std::endl; + } + gpioId_t currentGpioId = 0; + uint8_t chipSelectPin = lis3Id; + uint8_t whoAmIReg = 0b0000'1111; + uint8_t whoAmIRegExpectedVal = 0b0011'1101; + if (chipSelectPin == mgm0Lis3mdlChipSelect) { + currentGpioId = gpioIds::MGM_0_LIS3_CS; + } else { + currentGpioId = gpioIds::MGM_2_LIS3_CS; + } + uint32_t spiSpeed = 10'000'000; + spi::SpiModes spiMode = spi::SpiModes::MODE_0; #ifdef RASPBERRY_PI - std::string deviceName = "/dev/spidev0.0"; + std::string deviceName = "/dev/spidev0.0"; #else - std::string deviceName = "/dev/spidev2.0"; + std::string deviceName = "/dev/spidev2.0"; #endif - int fileDescriptor = 0; + int fileDescriptor = 0; - UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR, - "SpiComIF::initializeInterface"); - if(fileHelper.getOpenResult()) { - sif::error << "SpiTestClass::performLis3Mdl3100Test: File descriptor could not be opened!" - << std::endl; - return; - } - setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); - spiTransferStruct.delay_usecs = 0; - - uint8_t whoAmIRegVal = readStmRegister(fileDescriptor, currentGpioId, whoAmIReg, false); - sif::info << "SpiTestClass::performLis3MdlTest: WHO AM I register 0b" << - std::bitset<8>(whoAmIRegVal) << std::endl; - if(whoAmIRegVal != whoAmIRegExpectedVal) { - sif::warning << "SpiTestClass::performLis3MdlTest: WHO AM I register invalid!" - << std::endl; - } + UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR, "SpiComIF::initializeInterface"); + if (fileHelper.getOpenResult()) { + sif::error << "SpiTestClass::performLis3Mdl3100Test: File descriptor could not be opened!" + << std::endl; + return; + } + setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); + spiTransferStruct.delay_usecs = 0; + uint8_t whoAmIRegVal = readStmRegister(fileDescriptor, currentGpioId, whoAmIReg, false); + sif::info << "SpiTestClass::performLis3MdlTest: WHO AM I register 0b" + << std::bitset<8>(whoAmIRegVal) << std::endl; + if (whoAmIRegVal != whoAmIRegExpectedVal) { + sif::warning << "SpiTestClass::performLis3MdlTest: WHO AM I register invalid!" << std::endl; + } } - void SpiTestClass::performL3gTest(uint8_t l3gId) { - /* Configure all SPI chip selects and pull them high */ - acsInit(); + /* Configure all SPI chip selects and pull them high */ + acsInit(); - gpioId_t currentGpioId = 0; - uint8_t chipSelectPin = l3gId; - uint8_t whoAmIReg = 0b0000'1111; - uint8_t whoAmIRegExpectedVal = 0b1101'0111; + gpioId_t currentGpioId = 0; + uint8_t chipSelectPin = l3gId; + uint8_t whoAmIReg = 0b0000'1111; + uint8_t whoAmIRegExpectedVal = 0b1101'0111; - if(chipSelectPin == gyro1L3gd20ChipSelect) { - currentGpioId = gpioIds::GYRO_1_L3G_CS; - } - else { - currentGpioId = gpioIds::GYRO_3_L3G_CS; - } - uint32_t spiSpeed = 3'900'000; - spi::SpiModes spiMode = spi::SpiModes::MODE_3; + if (chipSelectPin == gyro1L3gd20ChipSelect) { + currentGpioId = gpioIds::GYRO_1_L3G_CS; + } else { + currentGpioId = gpioIds::GYRO_3_L3G_CS; + } + uint32_t spiSpeed = 3'900'000; + spi::SpiModes spiMode = spi::SpiModes::MODE_3; #ifdef RASPBERRY_PI - std::string deviceName = "/dev/spidev0.0"; + std::string deviceName = "/dev/spidev0.0"; #else - std::string deviceName = "/dev/spidev2.0"; + std::string deviceName = "/dev/spidev2.0"; #endif - int fileDescriptor = 0; + int fileDescriptor = 0; - UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR, - "SpiComIF::initializeInterface"); - if(fileHelper.getOpenResult()) { - sif::error << "SpiTestClass::performLis3Mdl3100Test: File descriptor could not be opened!" - << std::endl; - return; - } - setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); - uint8_t whoAmIRegVal = readStmRegister(fileDescriptor, currentGpioId, whoAmIReg, false); - sif::info << "SpiTestClass::performLis3MdlTest: WHO AM I register 0b" << - std::bitset<8>(whoAmIRegVal) << std::endl; - if(whoAmIRegVal != whoAmIRegExpectedVal) { - sif::warning << "SpiTestClass::performL3gTest: Read WHO AM I register invalid!" << - std::endl; + UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR, "SpiComIF::initializeInterface"); + if (fileHelper.getOpenResult()) { + sif::error << "SpiTestClass::performLis3Mdl3100Test: File descriptor could not be opened!" + << std::endl; + return; + } + setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); + uint8_t whoAmIRegVal = readStmRegister(fileDescriptor, currentGpioId, whoAmIReg, false); + sif::info << "SpiTestClass::performLis3MdlTest: WHO AM I register 0b" + << std::bitset<8>(whoAmIRegVal) << std::endl; + if (whoAmIRegVal != whoAmIRegExpectedVal) { + sif::warning << "SpiTestClass::performL3gTest: Read WHO AM I register invalid!" << std::endl; + } + + uint8_t ctrlReg1Addr = 0b0010'0000; + { + uint8_t commandRegs[5]; + commandRegs[0] = 0b0000'1111; + commandRegs[1] = 0x0; + commandRegs[2] = 0x0; + /* Configure big endian data format */ + commandRegs[3] = 0b0100'0000; + commandRegs[4] = 0x0; + writeMultipleStmRegisters(fileDescriptor, currentGpioId, ctrlReg1Addr, commandRegs, + sizeof(commandRegs)); + uint8_t readRegs[5]; + readMultipleRegisters(fileDescriptor, currentGpioId, ctrlReg1Addr, readRegs, sizeof(readRegs)); + for (uint8_t idx = 0; idx < sizeof(readRegs); idx++) { + if (readRegs[idx] != commandRegs[0]) { + sif::warning << "SpiTestClass::performL3gTest: Read control register " + << static_cast(idx + 1) << " not equal to configured value" << std::endl; + } } + } - uint8_t ctrlReg1Addr = 0b0010'0000; - { - uint8_t commandRegs[5]; - commandRegs[0] = 0b0000'1111; - commandRegs[1] = 0x0; - commandRegs[2] = 0x0; - /* Configure big endian data format */ - commandRegs[3] = 0b0100'0000; - commandRegs[4] = 0x0; - writeMultipleStmRegisters(fileDescriptor, currentGpioId, ctrlReg1Addr, commandRegs, - sizeof(commandRegs)); - uint8_t readRegs[5]; - readMultipleRegisters(fileDescriptor, currentGpioId, ctrlReg1Addr, readRegs, - sizeof(readRegs)); - for(uint8_t idx = 0; idx < sizeof(readRegs); idx++) { - if(readRegs[idx] != commandRegs[0]) { - sif::warning << "SpiTestClass::performL3gTest: Read control register " << - static_cast(idx + 1) << " not equal to configured value" << std::endl; - } - } - } + uint8_t readOutBuffer[14]; + readMultipleStmRegisters(fileDescriptor, currentGpioId, ctrlReg1Addr, readOutBuffer, + sizeof(readOutBuffer)); - uint8_t readOutBuffer[14]; - readMultipleStmRegisters(fileDescriptor, currentGpioId, ctrlReg1Addr, readOutBuffer, - sizeof(readOutBuffer)); + uint8_t statusReg = readOutBuffer[7]; + sif::info << "SpiTestClass::performL3gTest: Status Register 0b" << std::bitset<8>(statusReg) + << std::endl; - uint8_t statusReg = readOutBuffer[7]; - sif::info << "SpiTestClass::performL3gTest: Status Register 0b" << - std::bitset<8>(statusReg) << std::endl; + uint16_t l3gRange = 245; + float scaleFactor = static_cast(l3gRange) / INT16_MAX; + /* The sensor spits out little endian */ + int16_t angVelocRawX = (readOutBuffer[8] << 8) | readOutBuffer[9]; + int16_t angVelocRawY = (readOutBuffer[10] << 8) | readOutBuffer[11]; + int16_t angVelocRawZ = (readOutBuffer[12] << 8) | readOutBuffer[13]; - uint16_t l3gRange = 245; - float scaleFactor = static_cast(l3gRange) / INT16_MAX; - /* The sensor spits out little endian */ - int16_t angVelocRawX = (readOutBuffer[8] << 8) | readOutBuffer[9]; - int16_t angVelocRawY = (readOutBuffer[10] << 8) | readOutBuffer[11]; - int16_t angVelocRawZ = (readOutBuffer[12] << 8) | readOutBuffer[13]; - - float angVelocX = scaleFactor * angVelocRawX; - float angVelocY = scaleFactor * angVelocRawY; - float angVelocZ = scaleFactor * angVelocRawZ; - - sif::info << "Angular velocities for the L3GD20H in degrees per second:" << std::endl; - sif::info << "X: " << angVelocX << std::endl; - sif::info << "Y: " << angVelocY << std::endl; - sif::info << "Z: " << angVelocZ << std::endl; + float angVelocX = scaleFactor * angVelocRawX; + float angVelocY = scaleFactor * angVelocRawY; + float angVelocZ = scaleFactor * angVelocRawZ; + sif::info << "Angular velocities for the L3GD20H in degrees per second:" << std::endl; + sif::info << "X: " << angVelocX << std::endl; + sif::info << "Y: " << angVelocY << std::endl; + sif::info << "Z: " << angVelocZ << std::endl; } void SpiTestClass::acsInit() { - GpioCookie* gpioCookie = new GpioCookie(); + GpioCookie *gpioCookie = new GpioCookie(); #ifdef RASPBERRY_PI - GpiodRegularByChip* gpio = nullptr; - std::string rpiGpioName = "gpiochip0"; - gpio = new GpiodRegularByChip(rpiGpioName, mgm0Lis3mdlChipSelect, "MGM_0_LIS3", - gpio::DIR_OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); + GpiodRegularByChip *gpio = nullptr; + std::string rpiGpioName = "gpiochip0"; + gpio = new GpiodRegularByChip(rpiGpioName, mgm0Lis3mdlChipSelect, "MGM_0_LIS3", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); - gpio = new GpiodRegularByChip(rpiGpioName, mgm1Rm3100ChipSelect, "MGM_1_RM3100", - gpio::DIR_OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); + gpio = new GpiodRegularByChip(rpiGpioName, mgm1Rm3100ChipSelect, "MGM_1_RM3100", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); - gpio = new GpiodRegularByChip(rpiGpioName, gyro0AdisChipSelect, "GYRO_0_ADIS", - gpio::DIR_OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); + gpio = new GpiodRegularByChip(rpiGpioName, gyro0AdisChipSelect, "GYRO_0_ADIS", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); - gpio = new GpiodRegularByChip(rpiGpioName, gyro1L3gd20ChipSelect, "GYRO_1_L3G", - gpio::DIR_OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); + gpio = new GpiodRegularByChip(rpiGpioName, gyro1L3gd20ChipSelect, "GYRO_1_L3G", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); - gpio = new GpiodRegularByChip(rpiGpioName, gyro3L3gd20ChipSelect, "GYRO_2_L3G", - gpio::DIR_OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); + gpio = new GpiodRegularByChip(rpiGpioName, gyro3L3gd20ChipSelect, "GYRO_2_L3G", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); - gpio = new GpiodRegularByChip(rpiGpioName, mgm2Lis3mdlChipSelect, "MGM_2_LIS3", - gpio::DIR_OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); + gpio = new GpiodRegularByChip(rpiGpioName, mgm2Lis3mdlChipSelect, "MGM_2_LIS3", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); - gpio = new GpiodRegularByChip(rpiGpioName, mgm3Rm3100ChipSelect, "MGM_3_RM3100", - gpio::DIR_OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); + gpio = new GpiodRegularByChip(rpiGpioName, mgm3Rm3100ChipSelect, "MGM_3_RM3100", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); #elif defined(XIPHOS_Q7S) - GpiodRegularByLineName* gpio = nullptr; - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_0_CS, "MGM_0_LIS3", gpio::DIR_OUT, - gpio::HIGH); - gpioCookie->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, "MGM_1_RM3100", gpio::DIR_OUT, - gpio::HIGH); - gpioCookie->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_2_CS, "MGM_2_LIS3", gpio::DIR_OUT, - gpio::HIGH); - gpioCookie->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, "MGM_3_RM3100", gpio::DIR_OUT, - gpio::HIGH); - gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); + GpiodRegularByLineName *gpio = nullptr; + gpio = + new GpiodRegularByLineName(q7s::gpioNames::MGM_0_CS, "MGM_0_LIS3", gpio::DIR_OUT, gpio::HIGH); + gpioCookie->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, "MGM_1_RM3100", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); + gpio = + new GpiodRegularByLineName(q7s::gpioNames::MGM_2_CS, "MGM_2_LIS3", gpio::DIR_OUT, gpio::HIGH); + gpioCookie->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, "MGM_3_RM3100", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ADIS_CS, "GYRO_0_ADIS", - gpio::DIR_OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_1_L3G_CS, "GYRO_1_L3G", gpio::DIR_OUT, - gpio::HIGH); - gpioCookie->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ADIS_CS, "GYRO_2_ADIS", - gpio::DIR_OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::GYRO_2_ADIS_CS, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_3_L3G_CS, "GYRO_3_L3G", gpio::DIR_OUT, - gpio::HIGH); - gpioCookie->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ADIS_CS, "GYRO_0_ADIS", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_1_L3G_CS, "GYRO_1_L3G", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ADIS_CS, "GYRO_2_ADIS", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::GYRO_2_ADIS_CS, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_3_L3G_CS, "GYRO_3_L3G", gpio::DIR_OUT, + gpio::HIGH); + gpioCookie->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); - // Enable pins must be pulled low for regular operations - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, "GYRO_0_ENABLE", gpio::DIR_OUT, - gpio::LOW); - gpioCookie->addGpio(gpioIds::GYRO_0_ENABLE, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, "GYRO_2_ENABLE", gpio::DIR_OUT, - gpio::LOW); - gpioCookie->addGpio(gpioIds::GYRO_2_ENABLE, gpio); + // Enable pins must be pulled low for regular operations + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, "GYRO_0_ENABLE", gpio::DIR_OUT, + gpio::LOW); + gpioCookie->addGpio(gpioIds::GYRO_0_ENABLE, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, "GYRO_2_ENABLE", gpio::DIR_OUT, + gpio::LOW); + gpioCookie->addGpio(gpioIds::GYRO_2_ENABLE, gpio); #endif - if (gpioIF != nullptr) { - gpioIF->addGpios(gpioCookie); - } + if (gpioIF != nullptr) { + gpioIF->addGpios(gpioCookie); + } } void SpiTestClass::setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed) { - int mode_test = SPI_MODE_3; - int retval = ioctl(spiFd, SPI_IOC_WR_MODE, &mode_test);//reinterpret_cast(&mode)); - if(retval != 0) { - utility::handleIoctlError("SpiTestClass::performRm3100Test: Setting SPI mode failed!"); - } + int mode_test = SPI_MODE_3; + int retval = ioctl(spiFd, SPI_IOC_WR_MODE, &mode_test); // reinterpret_cast(&mode)); + if (retval != 0) { + utility::handleIoctlError("SpiTestClass::performRm3100Test: Setting SPI mode failed!"); + } - retval = ioctl(spiFd, SPI_IOC_WR_MAX_SPEED_HZ, &speed); - if(retval != 0) { - utility::handleIoctlError("SpiTestClass::performRm3100Test: Setting SPI speed failed!"); - } + retval = ioctl(spiFd, SPI_IOC_WR_MAX_SPEED_HZ, &speed); + if (retval != 0) { + utility::handleIoctlError("SpiTestClass::performRm3100Test: Setting SPI speed failed!"); + } } void SpiTestClass::writeRegister(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t value) { - spiTransferStruct.len = 2; - sendBuffer[0] = reg; - sendBuffer[1] = value; + spiTransferStruct.len = 2; + sendBuffer[0] = reg; + sendBuffer[1] = value; - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullLow(chipSelect); - } - int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); - if(retval < 0) { - utility::handleIoctlError("SpiTestClass::writeRegister: Write failed"); - } - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullHigh(chipSelect); - } + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullLow(chipSelect); + } + int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); + if (retval < 0) { + utility::handleIoctlError("SpiTestClass::writeRegister: Write failed"); + } + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullHigh(chipSelect); + } } void SpiTestClass::writeStmRegister(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t value, - bool autoIncrement) { - if(autoIncrement) { - reg |= STM_AUTO_INCR_MASK; - } - writeRegister(fd, chipSelect, reg, value); + bool autoIncrement) { + if (autoIncrement) { + reg |= STM_AUTO_INCR_MASK; + } + writeRegister(fd, chipSelect, reg, value); } void SpiTestClass::writeMultipleStmRegisters(int fd, gpioId_t chipSelect, uint8_t reg, - uint8_t *values, size_t len) { - if(values == nullptr) { - return; - } - - reg |= STM_AUTO_INCR_MASK; - /* Clear read mask */ - reg &= ~STM_READ_MASK; - writeMultipleRegisters(fd, chipSelect, reg, values, len); + uint8_t *values, size_t len) { + if (values == nullptr) { + return; + } + reg |= STM_AUTO_INCR_MASK; + /* Clear read mask */ + reg &= ~STM_READ_MASK; + writeMultipleRegisters(fd, chipSelect, reg, values, len); } -void SpiTestClass::writeMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg, - uint8_t *values, size_t len) { - if(values == nullptr) { - return; - } +void SpiTestClass::writeMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t *values, + size_t len) { + if (values == nullptr) { + return; + } - sendBuffer[0] = reg; - std::memcpy(sendBuffer.data() + 1, values, len); - spiTransferStruct.len = len + 1; + sendBuffer[0] = reg; + std::memcpy(sendBuffer.data() + 1, values, len); + spiTransferStruct.len = len + 1; - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullLow(chipSelect); - } - int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); - if(retval < 0) { - utility::handleIoctlError("SpiTestClass::readRegister: Read failed"); - } - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullHigh(chipSelect); - } + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullLow(chipSelect); + } + int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); + if (retval < 0) { + utility::handleIoctlError("SpiTestClass::readRegister: Read failed"); + } + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullHigh(chipSelect); + } } uint8_t SpiTestClass::readRm3100Register(int fd, gpioId_t chipSelect, uint8_t reg) { - return readStmRegister(fd, chipSelect, reg, false); + return readStmRegister(fd, chipSelect, reg, false); } - -void SpiTestClass::readMultipleStmRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t *reply, - size_t len) { - reg |= STM_AUTO_INCR_MASK; - readMultipleRegisters(fd, chipSelect, reg, reply, len); +void SpiTestClass::readMultipleStmRegisters(int fd, gpioId_t chipSelect, uint8_t reg, + uint8_t *reply, size_t len) { + reg |= STM_AUTO_INCR_MASK; + readMultipleRegisters(fd, chipSelect, reg, reply, len); } void SpiTestClass::readMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t *reply, - size_t len) { - if(reply == nullptr) { - return; - } + size_t len) { + if (reply == nullptr) { + return; + } - spiTransferStruct.len = len + 1; - sendBuffer[0] = reg | STM_READ_MASK; + spiTransferStruct.len = len + 1; + sendBuffer[0] = reg | STM_READ_MASK; - for(uint8_t idx = 0; idx < len ; idx ++) { - sendBuffer[idx + 1] = 0; - } + for (uint8_t idx = 0; idx < len; idx++) { + sendBuffer[idx + 1] = 0; + } - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullLow(chipSelect); - } - int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); - if(retval < 0) { - utility::handleIoctlError("SpiTestClass::readRegister: Read failed"); - } - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullHigh(chipSelect); - } - std::memcpy(reply, recvBuffer.data() + 1, len); + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullLow(chipSelect); + } + int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); + if (retval < 0) { + utility::handleIoctlError("SpiTestClass::readRegister: Read failed"); + } + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullHigh(chipSelect); + } + std::memcpy(reply, recvBuffer.data() + 1, len); } uint8_t SpiTestClass::readStmRegister(int fd, gpioId_t chipSelect, uint8_t reg, - bool autoIncrement) { - reg |= STM_READ_MASK; - if(autoIncrement) { - reg |= STM_AUTO_INCR_MASK; - } - return readRegister(fd, chipSelect, reg); + bool autoIncrement) { + reg |= STM_READ_MASK; + if (autoIncrement) { + reg |= STM_AUTO_INCR_MASK; + } + return readRegister(fd, chipSelect, reg); } - uint8_t SpiTestClass::readRegister(int fd, gpioId_t chipSelect, uint8_t reg) { - spiTransferStruct.len = 2; - sendBuffer[0] = reg; - sendBuffer[1] = 0; + spiTransferStruct.len = 2; + sendBuffer[0] = reg; + sendBuffer[1] = 0; - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullLow(chipSelect); - } - int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); - if(retval < 0) { - utility::handleIoctlError("SpiTestClass::readRegister: Read failed"); - } - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullHigh(chipSelect); - } - return recvBuffer[1]; + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullLow(chipSelect); + } + int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); + if (retval < 0) { + utility::handleIoctlError("SpiTestClass::readRegister: Read failed"); + } + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullHigh(chipSelect); + } + return recvBuffer[1]; } diff --git a/linux/boardtest/SpiTestClass.h b/linux/boardtest/SpiTestClass.h index ffd56dd1..5df8cafb 100644 --- a/linux/boardtest/SpiTestClass.h +++ b/linux/boardtest/SpiTestClass.h @@ -13,83 +13,78 @@ #include -class SpiTestClass: public TestTask { -public: - enum TestModes { - NONE, - MGM_LIS3MDL, - MGM_RM3100, - GYRO_L3GD20H, - }; +class SpiTestClass : public TestTask { + public: + enum TestModes { + NONE, + MGM_LIS3MDL, + MGM_RM3100, + GYRO_L3GD20H, + }; - TestModes testMode; + TestModes testMode; - SpiTestClass(object_id_t objectId, GpioIF* gpioIF); + SpiTestClass(object_id_t objectId, GpioIF* gpioIF); - ReturnValue_t performOneShotAction() override; - ReturnValue_t performPeriodicAction() override; -private: + ReturnValue_t performOneShotAction() override; + ReturnValue_t performPeriodicAction() override; - GpioIF* gpioIF; + private: + GpioIF* gpioIF; - std::array recvBuffer; - std::array sendBuffer; - struct spi_ioc_transfer spiTransferStruct = {}; + std::array recvBuffer; + std::array sendBuffer; + struct spi_ioc_transfer spiTransferStruct = {}; - void performRm3100Test(uint8_t mgmId); - void performLis3MdlTest(uint8_t lis3Id); - void performL3gTest(uint8_t l3gId); + void performRm3100Test(uint8_t mgmId); + void performLis3MdlTest(uint8_t lis3Id); + void performL3gTest(uint8_t l3gId); - /* ACS board specific code which pulls all GPIOs high */ - void acsInit(); + /* ACS board specific code which pulls all GPIOs high */ + void acsInit(); - /* ACS board specific variables */ + /* ACS board specific variables */ #ifdef RASPBERRY_PI - uint8_t mgm0Lis3mdlChipSelect = gpio::MGM_0_BCM_PIN; - uint8_t mgm1Rm3100ChipSelect = gpio::MGM_1_BCM_PIN; - uint8_t mgm2Lis3mdlChipSelect = gpio::MGM_2_BCM_PIN; - uint8_t mgm3Rm3100ChipSelect = gpio::MGM_3_BCM_PIN; + uint8_t mgm0Lis3mdlChipSelect = gpio::MGM_0_BCM_PIN; + uint8_t mgm1Rm3100ChipSelect = gpio::MGM_1_BCM_PIN; + uint8_t mgm2Lis3mdlChipSelect = gpio::MGM_2_BCM_PIN; + uint8_t mgm3Rm3100ChipSelect = gpio::MGM_3_BCM_PIN; - uint8_t gyro0AdisChipSelect = gpio::GYRO_0_BCM_PIN; - uint8_t gyro1L3gd20ChipSelect = gpio::GYRO_1_BCM_PIN; - uint8_t gyro2AdisChipSelect = gpio::GYRO_2_BCM_PIN; - uint8_t gyro3L3gd20ChipSelect = gpio::GYRO_3_BCM_PIN; + uint8_t gyro0AdisChipSelect = gpio::GYRO_0_BCM_PIN; + uint8_t gyro1L3gd20ChipSelect = gpio::GYRO_1_BCM_PIN; + uint8_t gyro2AdisChipSelect = gpio::GYRO_2_BCM_PIN; + uint8_t gyro3L3gd20ChipSelect = gpio::GYRO_3_BCM_PIN; #else - uint8_t mgm0Lis3mdlChipSelect = 0; - uint8_t mgm1Rm3100ChipSelect = 0; - uint8_t gyro0AdisResetLine = 0; - uint8_t gyro0AdisChipSelect = 0; - uint8_t gyro1L3gd20ChipSelect = 0; - uint8_t gyro2L3gd20ChipSelect = 0; - uint8_t mgm2Lis3mdlChipSelect = 0; - uint8_t mgm3Rm3100ChipSelect = 0; + uint8_t mgm0Lis3mdlChipSelect = 0; + uint8_t mgm1Rm3100ChipSelect = 0; + uint8_t gyro0AdisResetLine = 0; + uint8_t gyro0AdisChipSelect = 0; + uint8_t gyro1L3gd20ChipSelect = 0; + uint8_t gyro2L3gd20ChipSelect = 0; + uint8_t mgm2Lis3mdlChipSelect = 0; + uint8_t mgm3Rm3100ChipSelect = 0; #endif - static constexpr uint8_t STM_READ_MASK = 0b1000'0000; - static constexpr uint8_t RM3100_READ_MASK = STM_READ_MASK; - static constexpr uint8_t STM_AUTO_INCR_MASK = 0b0100'0000; + static constexpr uint8_t STM_READ_MASK = 0b1000'0000; + static constexpr uint8_t RM3100_READ_MASK = STM_READ_MASK; + static constexpr uint8_t STM_AUTO_INCR_MASK = 0b0100'0000; - void setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed); + void setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed); - void writeStmRegister(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t value, - bool autoIncrement); - void writeMultipleStmRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t* values, - size_t len); - void writeMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t *values, - size_t len); - void writeRegister(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t value); - - uint8_t readRm3100Register(int fd, gpioId_t chipSelect, uint8_t reg); - uint8_t readStmRegister(int fd, gpioId_t chipSelect, uint8_t reg, bool autoIncrement); - uint8_t readRegister(int fd, gpioId_t chipSelect, uint8_t reg); - void readMultipleStmRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t *reply, - size_t len); - void readMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg, - uint8_t* reply, size_t len); + void writeStmRegister(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t value, + bool autoIncrement); + void writeMultipleStmRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t* values, + size_t len); + void writeMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t* values, + size_t len); + void writeRegister(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t value); + uint8_t readRm3100Register(int fd, gpioId_t chipSelect, uint8_t reg); + uint8_t readStmRegister(int fd, gpioId_t chipSelect, uint8_t reg, bool autoIncrement); + uint8_t readRegister(int fd, gpioId_t chipSelect, uint8_t reg); + void readMultipleStmRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t* reply, + size_t len); + void readMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t* reply, size_t len); }; - - - #endif /* LINUX_BOARDTEST_SPITESTCLASS_H_ */ diff --git a/linux/boardtest/UartTestClass.cpp b/linux/boardtest/UartTestClass.cpp index e69f0e5f..9b20ad13 100644 --- a/linux/boardtest/UartTestClass.cpp +++ b/linux/boardtest/UartTestClass.cpp @@ -5,110 +5,107 @@ #include "q7sConfig.h" #endif -#include "fsfw/serviceinterface/ServiceInterface.h" +#include // Error integer and strerror() function +#include // Contains file controls like O_RDWR +#include // write(), read(), close() +#include "fsfw/serviceinterface/ServiceInterface.h" #include "lwgps/lwgps.h" -#include // Contains file controls like O_RDWR -#include // Error integer and strerror() function -#include // write(), read(), close() +#define GPS_REPLY_WIRETAPPING 0 -#define GPS_REPLY_WIRETAPPING 0 - -UartTestClass::UartTestClass(object_id_t objectId): TestTask(objectId) { -} +UartTestClass::UartTestClass(object_id_t objectId) : TestTask(objectId) {} ReturnValue_t UartTestClass::initialize() { #if RPI_TEST_GPS_DEVICE == 1 - int result = lwgps_init(&gpsData); - if(result == 0) { - sif::warning << "lwgps_init error: " << result << std::endl; - } + int result = lwgps_init(&gpsData); + if (result == 0) { + sif::warning << "lwgps_init error: " << result << std::endl; + } - /* Get file descriptor */ - serialPort = open("/dev/serial0", O_RDWR); - if(serialPort < 0) { - sif::warning << "open call failed with error [" << errno << ", " << strerror(errno) - << std::endl; - } - /* Setting up UART parameters */ - tty.c_cflag &= ~PARENB; // Clear parity bit - tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication - tty.c_cflag &= ~CSIZE; // Clear all the size bits - tty.c_cflag |= CS8; // 8 bits per byte - tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control - tty.c_cflag |= CREAD | CLOCAL; // Turn on READ & ignore ctrl lines (CLOCAL = 1) - // Use canonical mode for GPS device - tty.c_lflag |= ICANON; - tty.c_lflag &= ~ECHO; // Disable echo - tty.c_lflag &= ~ECHOE; // Disable erasure - tty.c_lflag &= ~ECHONL; // Disable new-line echo - tty.c_lflag &= ~ISIG; // Disable interpretation of INTR, QUIT and SUSP - tty.c_iflag &= ~(IXON | IXOFF | IXANY); // Turn off s/w flow ctrl - tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL); // Disable any special handling of received bytes - tty.c_oflag &= ~OPOST; // Prevent special interpretation of output bytes (e.g. newline chars) - tty.c_oflag &= ~ONLCR; // Prevent conversion of newline to carriage return/line feed + /* Get file descriptor */ + serialPort = open("/dev/serial0", O_RDWR); + if (serialPort < 0) { + sif::warning << "open call failed with error [" << errno << ", " << strerror(errno) + << std::endl; + } + /* Setting up UART parameters */ + tty.c_cflag &= ~PARENB; // Clear parity bit + tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication + tty.c_cflag &= ~CSIZE; // Clear all the size bits + tty.c_cflag |= CS8; // 8 bits per byte + tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control + tty.c_cflag |= CREAD | CLOCAL; // Turn on READ & ignore ctrl lines (CLOCAL = 1) + // Use canonical mode for GPS device + tty.c_lflag |= ICANON; + tty.c_lflag &= ~ECHO; // Disable echo + tty.c_lflag &= ~ECHOE; // Disable erasure + tty.c_lflag &= ~ECHONL; // Disable new-line echo + tty.c_lflag &= ~ISIG; // Disable interpretation of INTR, QUIT and SUSP + tty.c_iflag &= ~(IXON | IXOFF | IXANY); // Turn off s/w flow ctrl + tty.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | + ICRNL); // Disable any special handling of received bytes + tty.c_oflag &= ~OPOST; // Prevent special interpretation of output bytes (e.g. newline chars) + tty.c_oflag &= ~ONLCR; // Prevent conversion of newline to carriage return/line feed - // Non-blocking mode - tty.c_cc[VTIME] = 0; - tty.c_cc[VMIN] = 0; + // Non-blocking mode + tty.c_cc[VTIME] = 0; + tty.c_cc[VMIN] = 0; - cfsetispeed(&tty, B9600); - cfsetospeed(&tty, B9600); - if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { - sif::warning << "tcsetattr call failed with error [" << errno << ", " << - strerror(errno) << std::endl;; - } - // Flush received and unread data. Those are old NMEA strings which are not relevant anymore - tcflush(serialPort, TCIFLUSH); + cfsetispeed(&tty, B9600); + cfsetospeed(&tty, B9600); + if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { + sif::warning << "tcsetattr call failed with error [" << errno << ", " << strerror(errno) + << std::endl; + ; + } + // Flush received and unread data. Those are old NMEA strings which are not relevant anymore + tcflush(serialPort, TCIFLUSH); #endif - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t UartTestClass::performOneShotAction() { #if RPI_TEST_GPS_DEVICE == 1 #endif - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t UartTestClass::performPeriodicAction() { #if RPI_TEST_GPS_DEVICE == 1 - int bytesRead = 0; - do { - bytesRead = read(serialPort, - reinterpret_cast(recBuf.data()), - static_cast(recBuf.size())); - if(bytesRead < 0) { - sif::warning << "UartTestClass::performPeriodicAction: read call failed with error [" << - errno << ", " << strerror(errno) << "]" << std::endl; - break; - } - else if(bytesRead >= static_cast(recBuf.size())) { - sif::debug << "UartTestClass::performPeriodicAction: " - "recv buffer might not be large enough" << std::endl; - } - else if(bytesRead > 0) { - // pass data to lwgps for processing + int bytesRead = 0; + do { + bytesRead = read(serialPort, reinterpret_cast(recBuf.data()), + static_cast(recBuf.size())); + if (bytesRead < 0) { + sif::warning << "UartTestClass::performPeriodicAction: read call failed with error [" << errno + << ", " << strerror(errno) << "]" << std::endl; + break; + } else if (bytesRead >= static_cast(recBuf.size())) { + sif::debug << "UartTestClass::performPeriodicAction: " + "recv buffer might not be large enough" + << std::endl; + } else if (bytesRead > 0) { + // pass data to lwgps for processing #if GPS_REPLY_WIRETAPPING == 1 - sif::info << recBuf.data() << std::endl; + sif::info << recBuf.data() << std::endl; #endif - int result = lwgps_process(&gpsData, recBuf.data(), bytesRead); - if(result == 0) { - sif::warning << "UartTestClass::performPeriodicAction: lwgps_process error" - << std::endl; - } - recvCnt++; - if(recvCnt == 6) { - recvCnt = 0; - sif::info << "GPS Data" << std::endl; - // Print messages - 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); - } - } - } while(bytesRead > 0); + int result = lwgps_process(&gpsData, recBuf.data(), bytesRead); + if (result == 0) { + sif::warning << "UartTestClass::performPeriodicAction: lwgps_process error" << std::endl; + } + recvCnt++; + if (recvCnt == 6) { + recvCnt = 0; + sif::info << "GPS Data" << std::endl; + // Print messages + 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); + } + } + } while (bytesRead > 0); #endif - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } diff --git a/linux/boardtest/UartTestClass.h b/linux/boardtest/UartTestClass.h index aeb2c396..f32d909d 100644 --- a/linux/boardtest/UartTestClass.h +++ b/linux/boardtest/UartTestClass.h @@ -1,27 +1,27 @@ #ifndef LINUX_BOARDTEST_UARTTESTCLASS_H_ #define LINUX_BOARDTEST_UARTTESTCLASS_H_ -#include "test/testtasks/TestTask.h" -#include "lwgps/lwgps.h" +#include // Contains POSIX terminal control definitions #include -#include // Contains POSIX terminal control definitions -class UartTestClass: public TestTask { -public: - UartTestClass(object_id_t objectId); +#include "lwgps/lwgps.h" +#include "test/testtasks/TestTask.h" - ReturnValue_t initialize() override; - ReturnValue_t performOneShotAction() override; - ReturnValue_t performPeriodicAction() override; -private: +class UartTestClass : public TestTask { + public: + UartTestClass(object_id_t objectId); - lwgps_t gpsData = {}; - struct termios tty = {}; - int serialPort = 0; - std::array recBuf; - uint8_t recvCnt = 0; + ReturnValue_t initialize() override; + ReturnValue_t performOneShotAction() override; + ReturnValue_t performPeriodicAction() override; + private: + lwgps_t gpsData = {}; + struct termios tty = {}; + int serialPort = 0; + std::array recBuf; + uint8_t recvCnt = 0; }; #endif /* LINUX_BOARDTEST_UARTTESTCLASS_H_ */ diff --git a/linux/csp/CspComIF.cpp b/linux/csp/CspComIF.cpp index 07fe63d3..fa372d4d 100644 --- a/linux/csp/CspComIF.cpp +++ b/linux/csp/CspComIF.cpp @@ -1,259 +1,246 @@ #include "CspComIF.h" -#include "CspCookie.h" -#include #include #include +#include -CspComIF::CspComIF(object_id_t objectId) : - SystemObject(objectId) { -} +#include "CspCookie.h" -CspComIF::~CspComIF() { -} +CspComIF::CspComIF(object_id_t objectId) : SystemObject(objectId) {} -ReturnValue_t CspComIF::initializeInterface(CookieIF *cookie) { - if(cookie == nullptr) { - return NULLPOINTER; - } +CspComIF::~CspComIF() {} - CspCookie* cspCookie = dynamic_cast(cookie); - if(cspCookie == nullptr) { - return NULLPOINTER; - } +ReturnValue_t CspComIF::initializeInterface(CookieIF* cookie) { + if (cookie == nullptr) { + return NULLPOINTER; + } - /* Perform CAN and CSP initialization only once */ - if(cspDeviceMap.empty()){ - sif::info << "Performing " << canInterface << " initialization.." << std::endl; + CspCookie* cspCookie = dynamic_cast(cookie); + if (cspCookie == nullptr) { + return NULLPOINTER; + } - /* Define the memory to allocate for the CSP stack */ - int buf_count = 10; - int buf_size = 300; - /* Init CSP and CSP buffer system */ - if (csp_init(cspOwnAddress) != CSP_ERR_NONE - || csp_buffer_init(buf_count, buf_size) != CSP_ERR_NONE) { - sif::error << "Failed to init CSP\r\n" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } + /* Perform CAN and CSP initialization only once */ + if (cspDeviceMap.empty()) { + sif::info << "Performing " << canInterface << " initialization.." << std::endl; - int promisc = 0; // Set filter mode on - csp_iface_t *csp_if_ptr = &csp_if; - csp_if_ptr = csp_can_socketcan_init(canInterface, bitrate, promisc); - - /* Set default route and start router */ - uint8_t address = CSP_DEFAULT_ROUTE; - uint8_t netmask = 0; - uint8_t mac = CSP_NODE_MAC; - int result = csp_rtable_set(address, netmask, csp_if_ptr, mac); - if(result != CSP_ERR_NONE){ - sif::error << "Failed to add can interface to router table" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - - /* Start the route task */ - unsigned int task_stack_size = 500; - unsigned int priority = 0; - result = csp_route_start_task(task_stack_size, priority); - if(result != CSP_ERR_NONE){ - sif::error << "Failed to start csp route task" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - sif::info << canInterface << " initialized successfully" << std::endl; - } - - uint8_t cspAddress = cspCookie->getCspAddress(); - uint16_t maxReplyLength = cspCookie->getMaxReplyLength(); - if(cspDeviceMap.find(cspAddress) == cspDeviceMap.end()){ - /* Insert device information in CSP map */ - cspDeviceMap.emplace(cspAddress, vectorBuffer(maxReplyLength)); - } - - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t CspComIF::sendMessage(CookieIF *cookie, - const uint8_t * sendData, size_t sendLen) { - int result; - if(cookie == NULL){ - return HasReturnvaluesIF::RETURN_FAILED; - } - CspCookie* cspCookie = dynamic_cast (cookie); - if(cspCookie == NULL){ - return HasReturnvaluesIF::RETURN_FAILED; - } - - /* Extract csp port and bytes to query from command buffer */ - uint8_t cspPort; - uint16_t querySize = 0; - result = getPortAndQuerySize(&sendData, &sendLen, &cspPort, &querySize); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - uint8_t cspAddress = cspCookie->getCspAddress(); - switch(cspPort) { - case(Ports::CSP_PING): { - initiatePingRequest(cspAddress, querySize); - break; - } - case(Ports::CSP_REBOOT): { - csp_reboot(cspAddress); - break; - } - case(Ports::P60_PORT_GNDWDT_RESET): - case(Ports::P60_PORT_RPARAM): { - /* No CSP fixed port was selected. Send data to the specified port and - * wait for querySize number of bytes */ - result = cspTransfer(cspAddress, cspPort, sendData, sendLen, - querySize); - if(result != HasReturnvaluesIF::RETURN_OK){ - return HasReturnvaluesIF::RETURN_FAILED; - } - replySize = querySize; - break; - } - default: - sif::error << "CspComIF: Invalid port specified" << std::endl; - break; - } - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t CspComIF::getSendSuccess(CookieIF *cookie) { - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t CspComIF::requestReceiveMessage(CookieIF *cookie, - size_t requestLen) { - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t CspComIF::readReceivedMessage(CookieIF *cookie, - uint8_t** buffer, size_t* size) { - if(cookie == NULL){ - return HasReturnvaluesIF::RETURN_FAILED; - } - CspCookie* cspCookie = dynamic_cast (cookie); - if(cspCookie == NULL){ - return HasReturnvaluesIF::RETURN_FAILED; - } - - uint8_t cspAddress = cspCookie->getCspAddress(); - - *buffer = cspDeviceMap[cspAddress].data(); - *size = replySize; - - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t CspComIF::cspTransfer(uint8_t cspAddress, uint8_t cspPort, - const uint8_t* cmdBuffer, int cmdLen, uint16_t querySize) { - - uint32_t timeout_ms = 1000; - uint16_t bytesRead = 0; - int32_t expectedSize = (int32_t)querySize; - vectorBufferIter iter = cspDeviceMap.find(cspAddress); - if(iter == cspDeviceMap.end()){ - sif::error << "CSP device with address " << cspAddress << " no found in" - << " device map" << std::endl; - } - uint8_t* replyBuffer = iter->second.data(); - - csp_conn_t * conn = csp_connect(CSP_PRIO_HIGH, cspAddress, cspPort, 0, - CSP_O_NONE); - - csp_packet_t* commandPacket = (csp_packet_t*)csp_buffer_get(cmdLen); - if (commandPacket == NULL) { - sif::error << "CspComIF::cspTransfer: Failed to get memory for a csp packet from the csp " - << "stack" << std::endl; - csp_close(conn); - return RETURN_FAILED; + /* Define the memory to allocate for the CSP stack */ + int buf_count = 10; + int buf_size = 300; + /* Init CSP and CSP buffer system */ + if (csp_init(cspOwnAddress) != CSP_ERR_NONE || + csp_buffer_init(buf_count, buf_size) != CSP_ERR_NONE) { + sif::error << "Failed to init CSP\r\n" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; } - memcpy(commandPacket->data, cmdBuffer, cmdLen); - commandPacket->length = cmdLen; + int promisc = 0; // Set filter mode on + csp_iface_t* csp_if_ptr = &csp_if; + csp_if_ptr = csp_can_socketcan_init(canInterface, bitrate, promisc); - if (!csp_send(conn, commandPacket, timeout_ms)) { - csp_buffer_free(commandPacket); - sif::error << "CspComIF::cspTransfer: Failed to send csp packet" << std::endl; - csp_close(conn); - return RETURN_FAILED; + /* Set default route and start router */ + uint8_t address = CSP_DEFAULT_ROUTE; + uint8_t netmask = 0; + uint8_t mac = CSP_NODE_MAC; + int result = csp_rtable_set(address, netmask, csp_if_ptr, mac); + if (result != CSP_ERR_NONE) { + sif::error << "Failed to add can interface to router table" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; } - /* Return when no reply is expected */ - if (expectedSize == 0) { - return RETURN_OK; + /* Start the route task */ + unsigned int task_stack_size = 500; + unsigned int priority = 0; + result = csp_route_start_task(task_stack_size, priority); + if (result != CSP_ERR_NONE) { + sif::error << "Failed to start csp route task" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; } + sif::info << canInterface << " initialized successfully" << std::endl; + } - csp_packet_t * reply; + uint8_t cspAddress = cspCookie->getCspAddress(); + uint16_t maxReplyLength = cspCookie->getMaxReplyLength(); + if (cspDeviceMap.find(cspAddress) == cspDeviceMap.end()) { + /* Insert device information in CSP map */ + cspDeviceMap.emplace(cspAddress, vectorBuffer(maxReplyLength)); + } + + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t CspComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) { + int result; + if (cookie == NULL) { + return HasReturnvaluesIF::RETURN_FAILED; + } + CspCookie* cspCookie = dynamic_cast(cookie); + if (cspCookie == NULL) { + return HasReturnvaluesIF::RETURN_FAILED; + } + + /* Extract csp port and bytes to query from command buffer */ + uint8_t cspPort; + uint16_t querySize = 0; + result = getPortAndQuerySize(&sendData, &sendLen, &cspPort, &querySize); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + uint8_t cspAddress = cspCookie->getCspAddress(); + switch (cspPort) { + case (Ports::CSP_PING): { + initiatePingRequest(cspAddress, querySize); + break; + } + case (Ports::CSP_REBOOT): { + csp_reboot(cspAddress); + break; + } + case (Ports::P60_PORT_GNDWDT_RESET): + case (Ports::P60_PORT_RPARAM): { + /* No CSP fixed port was selected. Send data to the specified port and + * wait for querySize number of bytes */ + result = cspTransfer(cspAddress, cspPort, sendData, sendLen, querySize); + if (result != HasReturnvaluesIF::RETURN_OK) { + return HasReturnvaluesIF::RETURN_FAILED; + } + replySize = querySize; + break; + } + default: + sif::error << "CspComIF: Invalid port specified" << std::endl; + break; + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t CspComIF::getSendSuccess(CookieIF* cookie) { return HasReturnvaluesIF::RETURN_OK; } + +ReturnValue_t CspComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLen) { + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t CspComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) { + if (cookie == NULL) { + return HasReturnvaluesIF::RETURN_FAILED; + } + CspCookie* cspCookie = dynamic_cast(cookie); + if (cspCookie == NULL) { + return HasReturnvaluesIF::RETURN_FAILED; + } + + uint8_t cspAddress = cspCookie->getCspAddress(); + + *buffer = cspDeviceMap[cspAddress].data(); + *size = replySize; + + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t CspComIF::cspTransfer(uint8_t cspAddress, uint8_t cspPort, const uint8_t* cmdBuffer, + int cmdLen, uint16_t querySize) { + uint32_t timeout_ms = 1000; + uint16_t bytesRead = 0; + int32_t expectedSize = (int32_t)querySize; + vectorBufferIter iter = cspDeviceMap.find(cspAddress); + if (iter == cspDeviceMap.end()) { + sif::error << "CSP device with address " << cspAddress << " no found in" + << " device map" << std::endl; + } + uint8_t* replyBuffer = iter->second.data(); + + csp_conn_t* conn = csp_connect(CSP_PRIO_HIGH, cspAddress, cspPort, 0, CSP_O_NONE); + + csp_packet_t* commandPacket = (csp_packet_t*)csp_buffer_get(cmdLen); + if (commandPacket == NULL) { + sif::error << "CspComIF::cspTransfer: Failed to get memory for a csp packet from the csp " + << "stack" << std::endl; + csp_close(conn); + return RETURN_FAILED; + } + + memcpy(commandPacket->data, cmdBuffer, cmdLen); + commandPacket->length = cmdLen; + + if (!csp_send(conn, commandPacket, timeout_ms)) { + csp_buffer_free(commandPacket); + sif::error << "CspComIF::cspTransfer: Failed to send csp packet" << std::endl; + csp_close(conn); + return RETURN_FAILED; + } + + /* Return when no reply is expected */ + if (expectedSize == 0) { + return RETURN_OK; + } + + csp_packet_t* reply; + reply = csp_read(conn, timeout_ms); + if (reply == NULL) { + sif::error << "CspComIF::cspTransfer: Failed to read csp packet" << std::endl; + csp_close(conn); + return RETURN_FAILED; + } + memcpy(replyBuffer, reply->data, reply->length); + expectedSize = expectedSize - reply->length; + bytesRead += reply->length; + csp_buffer_free(reply); + while (expectedSize > 0) { reply = csp_read(conn, timeout_ms); if (reply == NULL) { - sif::error << "CspComIF::cspTransfer: Failed to read csp packet" << std::endl; - csp_close(conn); - return RETURN_FAILED; + sif::error << "CspComIF::cspTransfer: Failed to read csp packet" << std::endl; + csp_close(conn); + return RETURN_FAILED; } - memcpy(replyBuffer, reply->data, reply->length); + if ((reply->length + bytesRead) > iter->second.size()) { + sif::error << "CspComIF::cspTransfer: Reply buffer to short" << std::endl; + csp_buffer_free(reply); + csp_close(conn); + return RETURN_FAILED; + } + memcpy(replyBuffer + bytesRead, reply->data, reply->length); expectedSize = expectedSize - reply->length; bytesRead += reply->length; csp_buffer_free(reply); - while (expectedSize > 0) { - reply = csp_read(conn, timeout_ms); - if (reply == NULL) { - sif::error << "CspComIF::cspTransfer: Failed to read csp packet" << std::endl; - csp_close(conn); - return RETURN_FAILED; - } - if ((reply->length + bytesRead) > iter->second.size()) { - sif::error << "CspComIF::cspTransfer: Reply buffer to short" << std::endl; - csp_buffer_free(reply); - csp_close(conn); - return RETURN_FAILED; - } - memcpy(replyBuffer + bytesRead, reply->data, reply->length); - expectedSize = expectedSize - reply->length; - bytesRead += reply->length; - csp_buffer_free(reply); - } + } - if(expectedSize != 0){ - sif::error << "CspComIF::cspTransfer: Received more bytes than requested" << std::endl; - sif::debug << "CspComIF::cspTransfer: Received bytes: " << bytesRead << std::endl; - csp_close(conn); - return RETURN_FAILED; - } + if (expectedSize != 0) { + sif::error << "CspComIF::cspTransfer: Received more bytes than requested" << std::endl; + sif::debug << "CspComIF::cspTransfer: Received bytes: " << bytesRead << std::endl; + csp_close(conn); + return RETURN_FAILED; + } - csp_close(conn); + csp_close(conn); - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t CspComIF::getPortAndQuerySize(const uint8_t** sendData, - size_t* sendLen, uint8_t* cspPort, uint16_t* querySize) { - ReturnValue_t result = SerializeAdapter::deSerialize(cspPort, sendData, - sendLen, SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "CspComIF: Failed to deserialize CSP port from command " - << "buffer" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - SerializeAdapter::deSerialize(querySize, sendData, sendLen, - SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "CspComIF: Failed to deserialize querySize from command " - << "buffer" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t CspComIF::getPortAndQuerySize(const uint8_t** sendData, size_t* sendLen, + uint8_t* cspPort, uint16_t* querySize) { + ReturnValue_t result = + SerializeAdapter::deSerialize(cspPort, sendData, sendLen, SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "CspComIF: Failed to deserialize CSP port from command " + << "buffer" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + SerializeAdapter::deSerialize(querySize, sendData, sendLen, SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "CspComIF: Failed to deserialize querySize from command " + << "buffer" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } -void CspComIF::initiatePingRequest(uint8_t cspAddress, uint16_t querySize){ - uint32_t timeout_ms = 500; - uint32_t replyTime = csp_ping(cspAddress, timeout_ms, querySize, - CSP_O_NONE); - sif::info << "Ping address: " << cspAddress << ", reply after " - << replyTime << " ms" << std::endl; - /* Store reply time in reply buffer * */ - uint8_t* replyBuffer = cspDeviceMap[cspAddress].data(); - memcpy(replyBuffer, &replyTime, sizeof(replyTime)); - replySize = sizeof(replyTime); +void CspComIF::initiatePingRequest(uint8_t cspAddress, uint16_t querySize) { + uint32_t timeout_ms = 500; + uint32_t replyTime = csp_ping(cspAddress, timeout_ms, querySize, CSP_O_NONE); + sif::info << "Ping address: " << cspAddress << ", reply after " << replyTime << " ms" + << std::endl; + /* Store reply time in reply buffer * */ + uint8_t* replyBuffer = cspDeviceMap[cspAddress].data(); + memcpy(replyBuffer, &replyTime, sizeof(replyTime)); + replySize = sizeof(replyTime); } diff --git a/linux/csp/CspComIF.h b/linux/csp/CspComIF.h index 4b8d323b..d36bbf4f 100644 --- a/linux/csp/CspComIF.h +++ b/linux/csp/CspComIF.h @@ -1,13 +1,13 @@ #ifndef LINUX_CSP_CSPCOMIF_H_ #define LINUX_CSP_CSPCOMIF_H_ +#include #include #include #include -#include -#include #include +#include /** * @brief This class serves as the communication interface to devices @@ -15,75 +15,65 @@ * in this implementation. * @author J. Meier */ -class CspComIF: public DeviceCommunicationIF, public SystemObject { -public: - CspComIF(object_id_t objectId); - virtual ~CspComIF(); +class CspComIF : public DeviceCommunicationIF, public SystemObject { + public: + CspComIF(object_id_t objectId); + virtual ~CspComIF(); - ReturnValue_t initializeInterface(CookieIF * cookie) override; - ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t * sendData, - size_t sendLen) override; - ReturnValue_t getSendSuccess(CookieIF *cookie) override; - ReturnValue_t requestReceiveMessage(CookieIF *cookie, - size_t requestLen) override; - ReturnValue_t readReceivedMessage(CookieIF *cookie, - uint8_t **readData, size_t *readLen) override; + ReturnValue_t initializeInterface(CookieIF *cookie) override; + ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t *sendData, size_t sendLen) override; + ReturnValue_t getSendSuccess(CookieIF *cookie) override; + ReturnValue_t requestReceiveMessage(CookieIF *cookie, size_t requestLen) override; + ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **readData, size_t *readLen) override; -private: + private: + /** + * @brief This function initiates the CSP transfer. + * + * @param cspAddress The CSP address of the target device. + * @param cspPort The port of the target device. + * @param timeout The timeout to wait for csp_send and csp_read + * functions. Specifies how long the functions wait + * for a successful operation. + * @param cmdBuffer The data to send. + * @param cmdLen The number of bytes to send. + * @param querySize The size of the requested message. + */ + ReturnValue_t cspTransfer(uint8_t cspAddress, uint8_t cspPort, const uint8_t *cmdBuffer, + int cmdLen, uint16_t querySize); - /** - * @brief This function initiates the CSP transfer. - * - * @param cspAddress The CSP address of the target device. - * @param cspPort The port of the target device. - * @param timeout The timeout to wait for csp_send and csp_read - * functions. Specifies how long the functions wait - * for a successful operation. - * @param cmdBuffer The data to send. - * @param cmdLen The number of bytes to send. - * @param querySize The size of the requested message. - */ - ReturnValue_t cspTransfer(uint8_t cspAddress, uint8_t cspPort, - const uint8_t* cmdBuffer, int cmdLen, uint16_t querySize); + enum Ports { CSP_PING = 1, CSP_REBOOT = 4, P60_PORT_RPARAM = 7, P60_PORT_GNDWDT_RESET = 9 }; - enum Ports { - CSP_PING = 1, - CSP_REBOOT = 4, - P60_PORT_RPARAM = 7, - P60_PORT_GNDWDT_RESET = 9 - }; + typedef uint8_t node_t; + using vectorBuffer = std::vector; + using VectorBufferMap = std::unordered_map; + using vectorBufferIter = VectorBufferMap::iterator; + /* In this map assigns reply buffers to a CSP device */ + VectorBufferMap cspDeviceMap; - typedef uint8_t node_t; - using vectorBuffer = std::vector; - using VectorBufferMap = std::unordered_map; - using vectorBufferIter = VectorBufferMap::iterator; + uint16_t replySize = 0; - /* In this map assigns reply buffers to a CSP device */ - VectorBufferMap cspDeviceMap; + /* This is the CSP address of the OBC. */ + node_t cspOwnAddress = 1; - uint16_t replySize = 0; + /* Interface struct for csp protocol stack */ + csp_iface_t csp_if; - /* This is the CSP address of the OBC. */ - node_t cspOwnAddress = 1; + char canInterface[5] = "can0"; + int bitrate = 1000; - /* Interface struct for csp protocol stack */ - csp_iface_t csp_if; + /** + * @brief Function to extract the csp port and the query size from the + * command buffer. + */ + ReturnValue_t getPortAndQuerySize(const uint8_t **sendData, size_t *sendLen, uint8_t *cspPort, + uint16_t *querySize); - char canInterface[5] = "can0"; - int bitrate = 1000; - - /** - * @brief Function to extract the csp port and the query size from the - * command buffer. - */ - ReturnValue_t getPortAndQuerySize(const uint8_t** sendData, size_t* sendLen, - uint8_t* cspPort, uint16_t* querySize); - - /** - * @brief This function initiates the ping request. - */ - void initiatePingRequest(uint8_t cspAddress, uint16_t querySize); + /** + * @brief This function initiates the ping request. + */ + void initiatePingRequest(uint8_t cspAddress, uint16_t querySize); }; #endif /* LINUX_CSP_CSPCOMIF_H_ */ diff --git a/linux/csp/CspCookie.cpp b/linux/csp/CspCookie.cpp index 18cfabd2..39274908 100644 --- a/linux/csp/CspCookie.cpp +++ b/linux/csp/CspCookie.cpp @@ -1,16 +1,10 @@ #include "CspCookie.h" -CspCookie::CspCookie(uint16_t maxReplyLength_, uint8_t cspAddress_) : - maxReplyLength(maxReplyLength_), cspAddress(cspAddress_) { -} +CspCookie::CspCookie(uint16_t maxReplyLength_, uint8_t cspAddress_) + : maxReplyLength(maxReplyLength_), cspAddress(cspAddress_) {} -CspCookie::~CspCookie() { -} +CspCookie::~CspCookie() {} -uint16_t CspCookie::getMaxReplyLength(){ - return maxReplyLength; -} +uint16_t CspCookie::getMaxReplyLength() { return maxReplyLength; } -uint8_t CspCookie::getCspAddress(){ - return cspAddress; -} +uint8_t CspCookie::getCspAddress() { return cspAddress; } diff --git a/linux/csp/CspCookie.h b/linux/csp/CspCookie.h index 4514c257..e59f3d35 100644 --- a/linux/csp/CspCookie.h +++ b/linux/csp/CspCookie.h @@ -2,6 +2,7 @@ #define LINUX_CSP_CSPCOOKIE_H_ #include + #include /** @@ -9,19 +10,17 @@ * Protocol). * @author J. Meier */ -class CspCookie: public CookieIF { -public: +class CspCookie : public CookieIF { + public: + CspCookie(uint16_t maxReplyLength_, uint8_t cspAddress_); + virtual ~CspCookie(); - CspCookie(uint16_t maxReplyLength_, uint8_t cspAddress_); - virtual ~CspCookie(); + uint16_t getMaxReplyLength(); + uint8_t getCspAddress(); - uint16_t getMaxReplyLength(); - uint8_t getCspAddress(); - -private: - - uint16_t maxReplyLength; - uint8_t cspAddress; + private: + uint16_t maxReplyLength; + uint8_t cspAddress; }; #endif /* LINUX_CSP_CSPCOOKIE_H_ */ diff --git a/linux/devices/SolarArrayDeploymentHandler.cpp b/linux/devices/SolarArrayDeploymentHandler.cpp index eea546f6..fed3992b 100644 --- a/linux/devices/SolarArrayDeploymentHandler.cpp +++ b/linux/devices/SolarArrayDeploymentHandler.cpp @@ -1,202 +1,209 @@ #include "SolarArrayDeploymentHandler.h" -#include #include - -#include +#include #include #include - +#include SolarArrayDeploymentHandler::SolarArrayDeploymentHandler(object_id_t setObjectId_, - object_id_t gpioDriverId_, CookieIF * gpioCookie_, object_id_t mainLineSwitcherObjectId_, - uint8_t mainLineSwitch_, gpioId_t deplSA1, gpioId_t deplSA2, uint32_t burnTimeMs) : - SystemObject(setObjectId_), gpioDriverId(gpioDriverId_), gpioCookie(gpioCookie_), - mainLineSwitcherObjectId(mainLineSwitcherObjectId_), mainLineSwitch(mainLineSwitch_), - deplSA1(deplSA1), deplSA2(deplSA2), burnTimeMs(burnTimeMs), actionHelper(this, nullptr) { - commandQueue = QueueFactory::instance()->createMessageQueue(cmdQueueSize, - MessageQueueMessage::MAX_MESSAGE_SIZE); + object_id_t gpioDriverId_, + CookieIF* gpioCookie_, + object_id_t mainLineSwitcherObjectId_, + uint8_t mainLineSwitch_, gpioId_t deplSA1, + gpioId_t deplSA2, uint32_t burnTimeMs) + : SystemObject(setObjectId_), + gpioDriverId(gpioDriverId_), + gpioCookie(gpioCookie_), + mainLineSwitcherObjectId(mainLineSwitcherObjectId_), + mainLineSwitch(mainLineSwitch_), + deplSA1(deplSA1), + deplSA2(deplSA2), + burnTimeMs(burnTimeMs), + actionHelper(this, nullptr) { + commandQueue = QueueFactory::instance()->createMessageQueue( + cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE); } -SolarArrayDeploymentHandler::~SolarArrayDeploymentHandler() { -} +SolarArrayDeploymentHandler::~SolarArrayDeploymentHandler() {} ReturnValue_t SolarArrayDeploymentHandler::performOperation(uint8_t operationCode) { - - if (operationCode == DeviceHandlerIF::PERFORM_OPERATION) { - handleStateMachine(); - return RETURN_OK; - } + if (operationCode == DeviceHandlerIF::PERFORM_OPERATION) { + handleStateMachine(); return RETURN_OK; + } + return RETURN_OK; } ReturnValue_t SolarArrayDeploymentHandler::initialize() { - ReturnValue_t result = SystemObject::initialize(); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + ReturnValue_t result = SystemObject::initialize(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - gpioInterface = ObjectManager::instance()->get(gpioDriverId); - if (gpioInterface == nullptr) { - sif::error << "SolarArrayDeploymentHandler::initialize: Invalid Gpio interface." - << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + gpioInterface = ObjectManager::instance()->get(gpioDriverId); + if (gpioInterface == nullptr) { + sif::error << "SolarArrayDeploymentHandler::initialize: Invalid Gpio interface." << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = gpioInterface->addGpios(dynamic_cast(gpioCookie)); - if (result != RETURN_OK) { - sif::error << "SolarArrayDeploymentHandler::initialize: Failed to initialize Gpio interface" - << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = gpioInterface->addGpios(dynamic_cast(gpioCookie)); + if (result != RETURN_OK) { + sif::error << "SolarArrayDeploymentHandler::initialize: Failed to initialize Gpio interface" + << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - if (mainLineSwitcherObjectId != objects::NO_OBJECT) { - mainLineSwitcher = ObjectManager::instance()->get(mainLineSwitcherObjectId); - if (mainLineSwitcher == nullptr) { - sif::error - << "SolarArrayDeploymentHandler::initialize: Main line switcher failed to fetch object" - << "from object ID." << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + if (mainLineSwitcherObjectId != objects::NO_OBJECT) { + mainLineSwitcher = ObjectManager::instance()->get(mainLineSwitcherObjectId); + if (mainLineSwitcher == nullptr) { + sif::error + << "SolarArrayDeploymentHandler::initialize: Main line switcher failed to fetch object" + << "from object ID." << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; } + } - result = actionHelper.initialize(commandQueue); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = actionHelper.initialize(commandQueue); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - return RETURN_OK; + return RETURN_OK; } void SolarArrayDeploymentHandler::handleStateMachine() { - switch (stateMachine) { + switch (stateMachine) { case WAIT_ON_DELOYMENT_COMMAND: - readCommandQueue(); - break; + readCommandQueue(); + break; case SWITCH_8V_ON: - mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_ON); - mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs()); - stateMachine = WAIT_ON_8V_SWITCH; - break; + mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_ON); + mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs()); + stateMachine = WAIT_ON_8V_SWITCH; + break; case WAIT_ON_8V_SWITCH: - performWaitOn8VActions(); - break; + performWaitOn8VActions(); + break; case SWITCH_DEPL_GPIOS: - switchDeploymentTransistors(); - break; + switchDeploymentTransistors(); + break; case WAIT_ON_DEPLOYMENT_FINISH: - handleDeploymentFinish(); - break; + handleDeploymentFinish(); + break; case WAIT_FOR_MAIN_SWITCH_OFF: - if (mainLineSwitcher->getSwitchState(mainLineSwitch) == PowerSwitchIF::SWITCH_OFF) { - stateMachine = WAIT_ON_DELOYMENT_COMMAND; - } else if (mainSwitchCountdown.hasTimedOut()) { - triggerEvent(MAIN_SWITCH_OFF_TIMEOUT); - sif::error << "SolarArrayDeploymentHandler::handleStateMachine: Failed to switch main" - << " switch off" << std::endl; - stateMachine = WAIT_ON_DELOYMENT_COMMAND; - } - break; + if (mainLineSwitcher->getSwitchState(mainLineSwitch) == PowerSwitchIF::SWITCH_OFF) { + stateMachine = WAIT_ON_DELOYMENT_COMMAND; + } else if (mainSwitchCountdown.hasTimedOut()) { + triggerEvent(MAIN_SWITCH_OFF_TIMEOUT); + sif::error << "SolarArrayDeploymentHandler::handleStateMachine: Failed to switch main" + << " switch off" << std::endl; + stateMachine = WAIT_ON_DELOYMENT_COMMAND; + } + break; default: - sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Invalid state" << std::endl; - break; - } + sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Invalid state" << std::endl; + break; + } } void SolarArrayDeploymentHandler::performWaitOn8VActions() { - if (mainLineSwitcher->getSwitchState(mainLineSwitch) == PowerSwitchIF::SWITCH_ON) { - stateMachine = SWITCH_DEPL_GPIOS; - } else { - if (mainSwitchCountdown.hasTimedOut()) { - triggerEvent(MAIN_SWITCH_ON_TIMEOUT); - actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, - MAIN_SWITCH_TIMEOUT_FAILURE); - stateMachine = WAIT_ON_DELOYMENT_COMMAND; - } + if (mainLineSwitcher->getSwitchState(mainLineSwitch) == PowerSwitchIF::SWITCH_ON) { + stateMachine = SWITCH_DEPL_GPIOS; + } else { + if (mainSwitchCountdown.hasTimedOut()) { + triggerEvent(MAIN_SWITCH_ON_TIMEOUT); + actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, + MAIN_SWITCH_TIMEOUT_FAILURE); + stateMachine = WAIT_ON_DELOYMENT_COMMAND; } + } } void SolarArrayDeploymentHandler::switchDeploymentTransistors() { - ReturnValue_t result = RETURN_OK; - result = gpioInterface->pullHigh(deplSA1); - if (result != RETURN_OK) { - sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" - " array deployment switch 1 high " << std::endl; - /* If gpio switch high failed, state machine is reset to wait for a command reinitiating - * the deployment sequence. */ - stateMachine = WAIT_ON_DELOYMENT_COMMAND; - triggerEvent(DEPL_SA1_GPIO_SWTICH_ON_FAILED); - actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, - SWITCHING_DEPL_SA2_FAILED); - mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); - } - result = gpioInterface->pullHigh(deplSA2); - if (result != RETURN_OK) { - sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" - " array deployment switch 2 high " << std::endl; - stateMachine = WAIT_ON_DELOYMENT_COMMAND; - triggerEvent(DEPL_SA2_GPIO_SWTICH_ON_FAILED); - actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, - SWITCHING_DEPL_SA2_FAILED); - mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); - } - deploymentCountdown.setTimeout(burnTimeMs); - stateMachine = WAIT_ON_DEPLOYMENT_FINISH; + ReturnValue_t result = RETURN_OK; + result = gpioInterface->pullHigh(deplSA1); + if (result != RETURN_OK) { + sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" + " array deployment switch 1 high " + << std::endl; + /* If gpio switch high failed, state machine is reset to wait for a command reinitiating + * the deployment sequence. */ + stateMachine = WAIT_ON_DELOYMENT_COMMAND; + triggerEvent(DEPL_SA1_GPIO_SWTICH_ON_FAILED); + actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, SWITCHING_DEPL_SA2_FAILED); + mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); + } + result = gpioInterface->pullHigh(deplSA2); + if (result != RETURN_OK) { + sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" + " array deployment switch 2 high " + << std::endl; + stateMachine = WAIT_ON_DELOYMENT_COMMAND; + triggerEvent(DEPL_SA2_GPIO_SWTICH_ON_FAILED); + actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, SWITCHING_DEPL_SA2_FAILED); + mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); + } + deploymentCountdown.setTimeout(burnTimeMs); + stateMachine = WAIT_ON_DEPLOYMENT_FINISH; } void SolarArrayDeploymentHandler::handleDeploymentFinish() { - ReturnValue_t result = RETURN_OK; - if (deploymentCountdown.hasTimedOut()) { - actionHelper.finish(true, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, RETURN_OK); - result = gpioInterface->pullLow(deplSA1); - if (result != RETURN_OK) { - sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" - " array deployment switch 1 low " << std::endl; - } - result = gpioInterface->pullLow(deplSA2); - if (result != RETURN_OK) { - sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" - " array deployment switch 2 low " << std::endl; - } - mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); - mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs()); - stateMachine = WAIT_FOR_MAIN_SWITCH_OFF; + ReturnValue_t result = RETURN_OK; + if (deploymentCountdown.hasTimedOut()) { + actionHelper.finish(true, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, RETURN_OK); + result = gpioInterface->pullLow(deplSA1); + if (result != RETURN_OK) { + sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" + " array deployment switch 1 low " + << std::endl; } + result = gpioInterface->pullLow(deplSA2); + if (result != RETURN_OK) { + sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" + " array deployment switch 2 low " + << std::endl; + } + mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); + mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs()); + stateMachine = WAIT_FOR_MAIN_SWITCH_OFF; + } } void SolarArrayDeploymentHandler::readCommandQueue() { - CommandMessage command; - ReturnValue_t result = commandQueue->receiveMessage(&command); - if (result != RETURN_OK) { - return; - } + CommandMessage command; + ReturnValue_t result = commandQueue->receiveMessage(&command); + if (result != RETURN_OK) { + return; + } - result = actionHelper.handleActionMessage(&command); - if (result == RETURN_OK) { - return; - } + result = actionHelper.handleActionMessage(&command); + if (result == RETURN_OK) { + return; + } } ReturnValue_t SolarArrayDeploymentHandler::executeAction(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { - ReturnValue_t result; - if (stateMachine != WAIT_ON_DELOYMENT_COMMAND) { - sif::error << "SolarArrayDeploymentHandler::executeAction: Received command while not in" - << "waiting-on-command-state" << std::endl; - return DEPLOYMENT_ALREADY_EXECUTING; - } - if (actionId != DEPLOY_SOLAR_ARRAYS) { - sif::error << "SolarArrayDeploymentHandler::executeAction: Received invalid command" - << std::endl; - result = COMMAND_NOT_SUPPORTED; - } else { - stateMachine = SWITCH_8V_ON; - rememberCommanderId = commandedBy; - result = RETURN_OK; - } - return result; + MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) { + ReturnValue_t result; + if (stateMachine != WAIT_ON_DELOYMENT_COMMAND) { + sif::error << "SolarArrayDeploymentHandler::executeAction: Received command while not in" + << "waiting-on-command-state" << std::endl; + return DEPLOYMENT_ALREADY_EXECUTING; + } + if (actionId != DEPLOY_SOLAR_ARRAYS) { + sif::error << "SolarArrayDeploymentHandler::executeAction: Received invalid command" + << std::endl; + result = COMMAND_NOT_SUPPORTED; + } else { + stateMachine = SWITCH_8V_ON; + rememberCommanderId = commandedBy; + result = RETURN_OK; + } + return result; } MessageQueueId_t SolarArrayDeploymentHandler::getCommandQueue() const { - return commandQueue->getId(); + return commandQueue->getId(); } diff --git a/linux/devices/SolarArrayDeploymentHandler.h b/linux/devices/SolarArrayDeploymentHandler.h index 5e573128..90380ae2 100644 --- a/linux/devices/SolarArrayDeploymentHandler.h +++ b/linux/devices/SolarArrayDeploymentHandler.h @@ -1,15 +1,16 @@ #ifndef MISSION_DEVICES_SOLARARRAYDEPLOYMENT_H_ #define MISSION_DEVICES_SOLARARRAYDEPLOYMENT_H_ -#include -#include -#include #include -#include #include #include +#include +#include +#include +#include #include #include + #include /** @@ -17,142 +18,139 @@ * * @author J. Meier */ -class SolarArrayDeploymentHandler: public ExecutableObjectIF, - public SystemObject, - public HasReturnvaluesIF, - public HasActionsIF { -public: +class SolarArrayDeploymentHandler : public ExecutableObjectIF, + public SystemObject, + public HasReturnvaluesIF, + public HasActionsIF { + public: + static const DeviceCommandId_t DEPLOY_SOLAR_ARRAYS = 0x5; - static const DeviceCommandId_t DEPLOY_SOLAR_ARRAYS = 0x5; + /** + * @brief constructor + * + * @param setObjectId The object id of the SolarArrayDeploymentHandler. + * @param gpioDriverId The id of the gpio com if. + * @param gpioCookie GpioCookie holding information about the gpios used to switch the + * transistors. + * @param mainLineSwitcherObjectId The object id of the object responsible for switching + * the 8V power source. This is normally the PCDU. + * @param mainLineSwitch The id of the main line switch. This is defined in + * powerSwitcherList.h. + * @param deplSA1 gpioId of the GPIO controlling the deployment 1 transistor. + * @param deplSA2 gpioId of the GPIO controlling the deployment 2 transistor. + * @param burnTimeMs Time duration the power will be applied to the burn wires. + */ + SolarArrayDeploymentHandler(object_id_t setObjectId, object_id_t gpioDriverId, + CookieIF* gpioCookie, object_id_t mainLineSwitcherObjectId, + uint8_t mainLineSwitch, gpioId_t deplSA1, gpioId_t deplSA2, + uint32_t burnTimeMs); - /** - * @brief constructor - * - * @param setObjectId The object id of the SolarArrayDeploymentHandler. - * @param gpioDriverId The id of the gpio com if. - * @param gpioCookie GpioCookie holding information about the gpios used to switch the - * transistors. - * @param mainLineSwitcherObjectId The object id of the object responsible for switching - * the 8V power source. This is normally the PCDU. - * @param mainLineSwitch The id of the main line switch. This is defined in - * powerSwitcherList.h. - * @param deplSA1 gpioId of the GPIO controlling the deployment 1 transistor. - * @param deplSA2 gpioId of the GPIO controlling the deployment 2 transistor. - * @param burnTimeMs Time duration the power will be applied to the burn wires. - */ - SolarArrayDeploymentHandler(object_id_t setObjectId, object_id_t gpioDriverId, - CookieIF * gpioCookie, object_id_t mainLineSwitcherObjectId, uint8_t mainLineSwitch, - gpioId_t deplSA1, gpioId_t deplSA2, uint32_t burnTimeMs); + virtual ~SolarArrayDeploymentHandler(); - virtual ~SolarArrayDeploymentHandler(); + virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; - virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; + virtual MessageQueueId_t getCommandQueue() const override; + virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) override; + virtual ReturnValue_t initialize() override; - virtual MessageQueueId_t getCommandQueue() const override; - virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size) override; - virtual ReturnValue_t initialize() override; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::SA_DEPL_HANDLER; + static const ReturnValue_t COMMAND_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA0); + static const ReturnValue_t DEPLOYMENT_ALREADY_EXECUTING = MAKE_RETURN_CODE(0xA1); + static const ReturnValue_t MAIN_SWITCH_TIMEOUT_FAILURE = MAKE_RETURN_CODE(0xA2); + static const ReturnValue_t SWITCHING_DEPL_SA1_FAILED = MAKE_RETURN_CODE(0xA3); + static const ReturnValue_t SWITCHING_DEPL_SA2_FAILED = MAKE_RETURN_CODE(0xA4); -private: + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SA_DEPL_HANDLER; + static const Event MAIN_SWITCH_ON_TIMEOUT = MAKE_EVENT(0, severity::LOW); + static const Event MAIN_SWITCH_OFF_TIMEOUT = MAKE_EVENT(1, severity::LOW); + static const Event DEPLOYMENT_FAILED = MAKE_EVENT(2, severity::HIGH); + static const Event DEPL_SA1_GPIO_SWTICH_ON_FAILED = MAKE_EVENT(3, severity::HIGH); + static const Event DEPL_SA2_GPIO_SWTICH_ON_FAILED = MAKE_EVENT(4, severity::HIGH); - static const uint8_t INTERFACE_ID = CLASS_ID::SA_DEPL_HANDLER; - static const ReturnValue_t COMMAND_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA0); - static const ReturnValue_t DEPLOYMENT_ALREADY_EXECUTING = MAKE_RETURN_CODE(0xA1); - static const ReturnValue_t MAIN_SWITCH_TIMEOUT_FAILURE = MAKE_RETURN_CODE(0xA2); - static const ReturnValue_t SWITCHING_DEPL_SA1_FAILED = MAKE_RETURN_CODE(0xA3); - static const ReturnValue_t SWITCHING_DEPL_SA2_FAILED = MAKE_RETURN_CODE(0xA4); + enum StateMachine { + WAIT_ON_DELOYMENT_COMMAND, + SWITCH_8V_ON, + WAIT_ON_8V_SWITCH, + SWITCH_DEPL_GPIOS, + WAIT_ON_DEPLOYMENT_FINISH, + WAIT_FOR_MAIN_SWITCH_OFF + }; - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SA_DEPL_HANDLER; - static const Event MAIN_SWITCH_ON_TIMEOUT = MAKE_EVENT(0, severity::LOW); - static const Event MAIN_SWITCH_OFF_TIMEOUT = MAKE_EVENT(1, severity::LOW); - static const Event DEPLOYMENT_FAILED = MAKE_EVENT(2, severity::HIGH); - static const Event DEPL_SA1_GPIO_SWTICH_ON_FAILED = MAKE_EVENT(3, severity::HIGH); - static const Event DEPL_SA2_GPIO_SWTICH_ON_FAILED = MAKE_EVENT(4, severity::HIGH); + StateMachine stateMachine = WAIT_ON_DELOYMENT_COMMAND; + /** + * This countdown is used to check if the PCDU sets the 8V line on in the intended time. + */ + Countdown mainSwitchCountdown; - enum StateMachine { - WAIT_ON_DELOYMENT_COMMAND, - SWITCH_8V_ON, - WAIT_ON_8V_SWITCH, - SWITCH_DEPL_GPIOS, - WAIT_ON_DEPLOYMENT_FINISH, - WAIT_FOR_MAIN_SWITCH_OFF - }; + /** + * This countdown is used to wait for the burn wire being successful cut. + */ + Countdown deploymentCountdown; - StateMachine stateMachine = WAIT_ON_DELOYMENT_COMMAND; + /** + * The message queue id of the component commanding an action will be stored in this variable. + * This is necessary to send later the action finish replies. + */ + MessageQueueId_t rememberCommanderId = 0; - /** - * This countdown is used to check if the PCDU sets the 8V line on in the intended time. - */ - Countdown mainSwitchCountdown; + /** Size of command queue */ + size_t cmdQueueSize = 20; - /** - * This countdown is used to wait for the burn wire being successful cut. - */ - Countdown deploymentCountdown; + /** The object ID of the GPIO driver which switches the deployment transistors */ + object_id_t gpioDriverId; + CookieIF* gpioCookie; - /** - * The message queue id of the component commanding an action will be stored in this variable. - * This is necessary to send later the action finish replies. - */ - MessageQueueId_t rememberCommanderId = 0; + /** Object id of the object responsible to switch the 8V power input. Typically the PCDU. */ + object_id_t mainLineSwitcherObjectId; - /** Size of command queue */ - size_t cmdQueueSize = 20; + /** Switch number of the 8V power switch */ + uint8_t mainLineSwitch; - /** The object ID of the GPIO driver which switches the deployment transistors */ - object_id_t gpioDriverId; + gpioId_t deplSA1; + gpioId_t deplSA2; - CookieIF * gpioCookie; + GpioIF* gpioInterface = nullptr; - /** Object id of the object responsible to switch the 8V power input. Typically the PCDU. */ - object_id_t mainLineSwitcherObjectId; + /** Time duration switches are active to cut the burn wire */ + uint32_t burnTimeMs; - /** Switch number of the 8V power switch */ - uint8_t mainLineSwitch; + /** Queue to receive messages from other objects. */ + MessageQueueIF* commandQueue = nullptr; - gpioId_t deplSA1; - gpioId_t deplSA2; + /** + * After initialization this pointer will hold the reference to the main line switcher object. + */ + PowerSwitchIF* mainLineSwitcher = nullptr; - GpioIF* gpioInterface = nullptr; + ActionHelper actionHelper; - /** Time duration switches are active to cut the burn wire */ - uint32_t burnTimeMs; + void readCommandQueue(); - /** Queue to receive messages from other objects. */ - MessageQueueIF* commandQueue = nullptr; + /** + * @brief This function performs actions dependent on the current state. + */ + void handleStateMachine(); - /** - * After initialization this pointer will hold the reference to the main line switcher object. - */ - PowerSwitchIF *mainLineSwitcher = nullptr; + /** + * @brief This function polls the 8V switch state and changes the state machine when the + * switch has been enabled. + */ + void performWaitOn8VActions(); - ActionHelper actionHelper; + /** + * @brief This functions handles the switching of the solar array deployment transistors. + */ + void switchDeploymentTransistors(); - void readCommandQueue(); - - /** - * @brief This function performs actions dependent on the current state. - */ - void handleStateMachine(); - - /** - * @brief This function polls the 8V switch state and changes the state machine when the - * switch has been enabled. - */ - void performWaitOn8VActions(); - - /** - * @brief This functions handles the switching of the solar array deployment transistors. - */ - void switchDeploymentTransistors(); - - /** - * @brief This function performs actions to finish the deployment. Essentially switches - * are turned of after the burn time has expired. - */ - void handleDeploymentFinish(); + /** + * @brief This function performs actions to finish the deployment. Essentially switches + * are turned of after the burn time has expired. + */ + void handleDeploymentFinish(); }; #endif /* MISSION_DEVICES_SOLARARRAYDEPLOYMENT_H_ */ diff --git a/linux/devices/SusHandler.cpp b/linux/devices/SusHandler.cpp index 67263756..44755f41 100644 --- a/linux/devices/SusHandler.cpp +++ b/linux/devices/SusHandler.cpp @@ -1,230 +1,214 @@ #include "SusHandler.h" -#include "OBSWConfig.h" #include #include -SusHandler::SusHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie, - LinuxLibgpioIF* gpioComIF, gpioId_t chipSelectId) : - DeviceHandlerBase(objectId, comIF, comCookie), gpioComIF(gpioComIF), chipSelectId( - chipSelectId), dataset(this) { - if (comCookie == NULL) { - sif::error << "SusHandler: Invalid com cookie" << std::endl; - } - if (gpioComIF == NULL) { - sif::error << "SusHandler: Invalid GpioComIF" << std::endl; - } +#include "OBSWConfig.h" + +SusHandler::SusHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie, + LinuxLibgpioIF *gpioComIF, gpioId_t chipSelectId) + : DeviceHandlerBase(objectId, comIF, comCookie), + gpioComIF(gpioComIF), + chipSelectId(chipSelectId), + dataset(this) { + if (comCookie == NULL) { + sif::error << "SusHandler: Invalid com cookie" << std::endl; + } + if (gpioComIF == NULL) { + sif::error << "SusHandler: Invalid GpioComIF" << std::endl; + } } -SusHandler::~SusHandler() { -} +SusHandler::~SusHandler() {} ReturnValue_t SusHandler::performOperation(uint8_t counter) { - - if (counter != FIRST_WRITE) { - DeviceHandlerBase::performOperation(counter); - return RETURN_OK; - } - - if (mode != MODE_NORMAL) { - DeviceHandlerBase::performOperation(DeviceHandlerIF::SEND_WRITE); - return RETURN_OK; - } - - /* If device is in normale mode the communication sequence is initiated here */ - if (communicationStep == CommunicationStep::IDLE) { - communicationStep = CommunicationStep::WRITE_SETUP; - } - - DeviceHandlerBase::performOperation(DeviceHandlerIF::SEND_WRITE); - + if (counter != FIRST_WRITE) { + DeviceHandlerBase::performOperation(counter); return RETURN_OK; + } + + if (mode != MODE_NORMAL) { + DeviceHandlerBase::performOperation(DeviceHandlerIF::SEND_WRITE); + return RETURN_OK; + } + + /* If device is in normale mode the communication sequence is initiated here */ + if (communicationStep == CommunicationStep::IDLE) { + communicationStep = CommunicationStep::WRITE_SETUP; + } + + DeviceHandlerBase::performOperation(DeviceHandlerIF::SEND_WRITE); + + return RETURN_OK; } ReturnValue_t SusHandler::initialize() { - ReturnValue_t result = RETURN_OK; - result = DeviceHandlerBase::initialize(); - if (result != RETURN_OK) { - return result; - } - auto spiComIF = dynamic_cast(communicationInterface); - if (spiComIF == nullptr) { - sif::debug << "SusHandler::initialize: Invalid communication interface" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } - spiMutex = spiComIF->getMutex(); - if (spiMutex == nullptr) { - sif::debug << "SusHandler::initialize: Failed to get spi mutex" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + result = DeviceHandlerBase::initialize(); + if (result != RETURN_OK) { + return result; + } + auto spiComIF = dynamic_cast(communicationInterface); + if (spiComIF == nullptr) { + sif::debug << "SusHandler::initialize: Invalid communication interface" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } + spiMutex = spiComIF->getMutex(); + if (spiMutex == nullptr) { + sif::debug << "SusHandler::initialize: Failed to get spi mutex" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } + return RETURN_OK; } -void SusHandler::doStartUp(){ +void SusHandler::doStartUp() { #if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 - setMode(MODE_NORMAL); + setMode(MODE_NORMAL); #else - setMode(_MODE_TO_ON); + setMode(_MODE_TO_ON); #endif } -void SusHandler::doShutDown(){ - setMode(_MODE_POWER_DOWN); +void SusHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } + +ReturnValue_t SusHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + if (communicationStep == CommunicationStep::IDLE) { + return NOTHING_TO_SEND; + } + + if (communicationStep == CommunicationStep::WRITE_SETUP) { + *id = SUS::WRITE_SETUP; + communicationStep = CommunicationStep::START_CONVERSIONS; + } else if (communicationStep == CommunicationStep::START_CONVERSIONS) { + *id = SUS::START_CONVERSIONS; + communicationStep = CommunicationStep::READ_CONVERSIONS; + } else if (communicationStep == CommunicationStep::READ_CONVERSIONS) { + *id = SUS::READ_CONVERSIONS; + communicationStep = CommunicationStep::IDLE; + } + return buildCommandFromCommand(*id, nullptr, 0); } -ReturnValue_t SusHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - - if (communicationStep == CommunicationStep::IDLE) { - return NOTHING_TO_SEND; - } - - if (communicationStep == CommunicationStep::WRITE_SETUP) { - *id = SUS::WRITE_SETUP; - communicationStep = CommunicationStep::START_CONVERSIONS; - } - else if (communicationStep == CommunicationStep::START_CONVERSIONS) { - *id = SUS::START_CONVERSIONS; - communicationStep = CommunicationStep::READ_CONVERSIONS; - } - else if (communicationStep == CommunicationStep::READ_CONVERSIONS) { - *id = SUS::READ_CONVERSIONS; - communicationStep = CommunicationStep::IDLE; - } - return buildCommandFromCommand(*id, nullptr, 0); +ReturnValue_t SusHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t SusHandler::buildTransitionDeviceCommand( - DeviceCommandId_t * id){ - return HasReturnvaluesIF::RETURN_OK; -} +ReturnValue_t SusHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, + size_t commandDataLen) { + switch (deviceCommand) { + case (SUS::WRITE_SETUP): { + /** + * The sun sensor ADC is shutdown when CS is pulled high, so each time requesting a + * measurement the setup has to be rewritten. There must also be a little delay between + * the transmission of the setup byte and the first conversion. Thus the conversion + * will be performed in an extra step. + * Because the chip select is driven manually by the SusHandler the SPI bus must be + * protected with a mutex here. + */ + ReturnValue_t result = spiMutex->lockMutex(timeoutType, timeoutMs); + if (result == MutexIF::MUTEX_TIMEOUT) { + sif::error << "SusHandler::buildCommandFromCommand: Mutex timeout" << std::endl; + return ERROR_LOCK_MUTEX; + } else if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "SusHandler::buildCommandFromCommand: Failed to lock spi mutex" << std::endl; + return ERROR_LOCK_MUTEX; + } -ReturnValue_t SusHandler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t * commandData, - size_t commandDataLen) { - switch(deviceCommand) { - case(SUS::WRITE_SETUP): { - /** - * The sun sensor ADC is shutdown when CS is pulled high, so each time requesting a - * measurement the setup has to be rewritten. There must also be a little delay between - * the transmission of the setup byte and the first conversion. Thus the conversion - * will be performed in an extra step. - * Because the chip select is driven manually by the SusHandler the SPI bus must be - * protected with a mutex here. - */ - ReturnValue_t result = spiMutex->lockMutex(timeoutType, timeoutMs); - if(result == MutexIF::MUTEX_TIMEOUT) { - sif::error << "SusHandler::buildCommandFromCommand: Mutex timeout" << std::endl; - return ERROR_LOCK_MUTEX; - } - else if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "SusHandler::buildCommandFromCommand: Failed to lock spi mutex" - << std::endl; - return ERROR_LOCK_MUTEX; - } - - gpioComIF->pullLow(chipSelectId); - cmdBuffer[0] = SUS::SETUP; - rawPacket = cmdBuffer; - rawPacketLen = 1; - return RETURN_OK; - } - case(SUS::START_CONVERSIONS): { - std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); - cmdBuffer[0] = SUS::CONVERSION; - rawPacket = cmdBuffer; - rawPacketLen = 2; - return RETURN_OK; - } - case(SUS::READ_CONVERSIONS): { - std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); - rawPacket = cmdBuffer; - rawPacketLen = SUS::SIZE_READ_CONVERSIONS; - return RETURN_OK; - } - default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; + gpioComIF->pullLow(chipSelectId); + cmdBuffer[0] = SUS::SETUP; + rawPacket = cmdBuffer; + rawPacketLen = 1; + return RETURN_OK; + } + case (SUS::START_CONVERSIONS): { + std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); + cmdBuffer[0] = SUS::CONVERSION; + rawPacket = cmdBuffer; + rawPacketLen = 2; + return RETURN_OK; + } + case (SUS::READ_CONVERSIONS): { + std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); + rawPacket = cmdBuffer; + rawPacketLen = SUS::SIZE_READ_CONVERSIONS; + return RETURN_OK; + } + default: + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } void SusHandler::fillCommandAndReplyMap() { - this->insertInCommandMap(SUS::WRITE_SETUP); - this->insertInCommandMap(SUS::START_CONVERSIONS); - this->insertInCommandAndReplyMap(SUS::READ_CONVERSIONS, 1, &dataset, SUS::SIZE_READ_CONVERSIONS); + this->insertInCommandMap(SUS::WRITE_SETUP); + this->insertInCommandMap(SUS::START_CONVERSIONS); + this->insertInCommandAndReplyMap(SUS::READ_CONVERSIONS, 1, &dataset, SUS::SIZE_READ_CONVERSIONS); } -ReturnValue_t SusHandler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { - *foundId = this->getPendingCommand(); - *foundLen = remainingSize; - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t SusHandler::scanForReply(const uint8_t *start, size_t remainingSize, + DeviceCommandId_t *foundId, size_t *foundLen) { + *foundId = this->getPendingCommand(); + *foundLen = remainingSize; + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t SusHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { - switch (id) { - case SUS::READ_CONVERSIONS: { - PoolReadGuard readSet(&dataset); - dataset.temperatureCelcius = (*(packet) << 8 | *(packet + 1)) * 0.125; - dataset.ain0 = (*(packet + 2) << 8 | *(packet + 3)); - dataset.ain1 = (*(packet + 4) << 8 | *(packet + 5)); - dataset.ain2 = (*(packet + 6) << 8 | *(packet + 7)); - dataset.ain3 = (*(packet + 8) << 8 | *(packet + 9)); - dataset.ain4 = (*(packet + 10) << 8 | *(packet + 11)); - dataset.ain5 = (*(packet + 12) << 8 | *(packet + 13)); +ReturnValue_t SusHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { + switch (id) { + case SUS::READ_CONVERSIONS: { + PoolReadGuard readSet(&dataset); + dataset.temperatureCelcius = (*(packet) << 8 | *(packet + 1)) * 0.125; + dataset.ain0 = (*(packet + 2) << 8 | *(packet + 3)); + dataset.ain1 = (*(packet + 4) << 8 | *(packet + 5)); + dataset.ain2 = (*(packet + 6) << 8 | *(packet + 7)); + dataset.ain3 = (*(packet + 8) << 8 | *(packet + 9)); + dataset.ain4 = (*(packet + 10) << 8 | *(packet + 11)); + dataset.ain5 = (*(packet + 12) << 8 | *(packet + 13)); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SUS - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", Temperature: " - << dataset.temperatureCelcius << " °C" << std::endl; - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN0: " - << std::dec << dataset.ain0 << std::endl; - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN1: " - << std::dec << dataset.ain1 << std::endl; - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN2: " - << std::dec << dataset.ain2 << std::endl; - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN3: " - << std::dec << dataset.ain3 << std::endl; - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN4: " - << std::dec << dataset.ain4 << std::endl; - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN5: " - << std::dec << dataset.ain5 << std::endl; + sif::info << "SUS object id 0x" << std::hex << this->getObjectId() + << ", Temperature: " << dataset.temperatureCelcius << " °C" << std::endl; + sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN0: " << std::dec + << dataset.ain0 << std::endl; + sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN1: " << std::dec + << dataset.ain1 << std::endl; + sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN2: " << std::dec + << dataset.ain2 << std::endl; + sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN3: " << std::dec + << dataset.ain3 << std::endl; + sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN4: " << std::dec + << dataset.ain4 << std::endl; + sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN5: " << std::dec + << dataset.ain5 << std::endl; #endif - /** SUS can now be shutdown and thus the SPI bus released again */ - gpioComIF->pullHigh(chipSelectId); - ReturnValue_t result = spiMutex->unlockMutex(); - if (result != RETURN_OK) { - sif::error << "SusHandler::interpretDeviceReply: Failed to unlock spi mutex" - << std::endl; - return ERROR_UNLOCK_MUTEX; - } - break; - } - default: { - sif::debug << "SusHandler::interpretDeviceReply: Unknown reply id" << std::endl; - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } - - } - return HasReturnvaluesIF::RETURN_OK; + /** SUS can now be shutdown and thus the SPI bus released again */ + gpioComIF->pullHigh(chipSelectId); + ReturnValue_t result = spiMutex->unlockMutex(); + if (result != RETURN_OK) { + sif::error << "SusHandler::interpretDeviceReply: Failed to unlock spi mutex" << std::endl; + return ERROR_UNLOCK_MUTEX; + } + break; + } + default: { + sif::debug << "SusHandler::interpretDeviceReply: Unknown reply id" << std::endl; + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; + } + } + return HasReturnvaluesIF::RETURN_OK; } -void SusHandler::setNormalDatapoolEntriesInvalid(){ +void SusHandler::setNormalDatapoolEntriesInvalid() {} +uint32_t SusHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 1000; } + +ReturnValue_t SusHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(SUS::TEMPERATURE_C, new PoolEntry({0.0})); + localDataPoolMap.emplace(SUS::AIN0, new PoolEntry({0})); + localDataPoolMap.emplace(SUS::AIN1, new PoolEntry({0})); + localDataPoolMap.emplace(SUS::AIN2, new PoolEntry({0})); + localDataPoolMap.emplace(SUS::AIN3, new PoolEntry({0})); + localDataPoolMap.emplace(SUS::AIN4, new PoolEntry({0})); + localDataPoolMap.emplace(SUS::AIN5, new PoolEntry({0})); + return HasReturnvaluesIF::RETURN_OK; } - -uint32_t SusHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){ - return 1000; -} - -ReturnValue_t SusHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { - localDataPoolMap.emplace(SUS::TEMPERATURE_C, new PoolEntry( { 0.0 })); - localDataPoolMap.emplace(SUS::AIN0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SUS::AIN1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SUS::AIN2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SUS::AIN3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SUS::AIN4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SUS::AIN5, new PoolEntry( { 0 })); - return HasReturnvaluesIF::RETURN_OK; -} - diff --git a/linux/devices/SusHandler.h b/linux/devices/SusHandler.h index ca9a5c45..0eab5fd0 100644 --- a/linux/devices/SusHandler.h +++ b/linux/devices/SusHandler.h @@ -1,10 +1,11 @@ #ifndef MISSION_DEVICES_SUSHANDLER_H_ #define MISSION_DEVICES_SUSHANDLER_H_ -#include "devicedefinitions/SusDefinitions.h" #include #include +#include "devicedefinitions/SusDefinitions.h" + /** * @brief This is the device handler class for the SUS sensor. The sensor is * based on the MAX1227 ADC. Details about the SUS electronic can be found at @@ -18,63 +19,55 @@ * * @author J. Meier */ -class SusHandler: public DeviceHandlerBase { -public: +class SusHandler : public DeviceHandlerBase { + public: + static const uint8_t FIRST_WRITE = 7; - static const uint8_t FIRST_WRITE = 7; + SusHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, + LinuxLibgpioIF* gpioComIF, gpioId_t chipSelectId); + virtual ~SusHandler(); - SusHandler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie, LinuxLibgpioIF* gpioComIF, gpioId_t chipSelectId); - virtual ~SusHandler(); + virtual ReturnValue_t performOperation(uint8_t counter) override; - virtual ReturnValue_t performOperation(uint8_t counter) override; + virtual ReturnValue_t initialize() override; - 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; -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; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::SUS_HANDLER; -private: + static const ReturnValue_t ERROR_UNLOCK_MUTEX = MAKE_RETURN_CODE(0xA0); + static const ReturnValue_t ERROR_LOCK_MUTEX = MAKE_RETURN_CODE(0xA1); - static const uint8_t INTERFACE_ID = CLASS_ID::SUS_HANDLER; + enum class CommunicationStep { IDLE, WRITE_SETUP, START_CONVERSIONS, READ_CONVERSIONS }; - static const ReturnValue_t ERROR_UNLOCK_MUTEX = MAKE_RETURN_CODE(0xA0); - static const ReturnValue_t ERROR_LOCK_MUTEX = MAKE_RETURN_CODE(0xA1); + LinuxLibgpioIF* gpioComIF = nullptr; - enum class CommunicationStep { - IDLE, - WRITE_SETUP, - START_CONVERSIONS, - READ_CONVERSIONS - }; + gpioId_t chipSelectId = gpio::NO_GPIO; - LinuxLibgpioIF* gpioComIF = nullptr; + SUS::SusDataset dataset; - gpioId_t chipSelectId = gpio::NO_GPIO; + uint8_t cmdBuffer[SUS::MAX_CMD_SIZE]; + CommunicationStep communicationStep = CommunicationStep::IDLE; - SUS::SusDataset dataset; + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; + uint32_t timeoutMs = 20; - uint8_t cmdBuffer[SUS::MAX_CMD_SIZE]; - CommunicationStep communicationStep = CommunicationStep::IDLE; - - MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; - uint32_t timeoutMs = 20; - - MutexIF* spiMutex = nullptr; + MutexIF* spiMutex = nullptr; }; #endif /* MISSION_DEVICES_SUSHANDLER_H_ */ diff --git a/linux/devices/devicedefinitions/SusDefinitions.h b/linux/devices/devicedefinitions/SusDefinitions.h index ba56ec07..2a45ebc5 100644 --- a/linux/devices/devicedefinitions/SusDefinitions.h +++ b/linux/devices/devicedefinitions/SusDefinitions.h @@ -3,93 +3,87 @@ #include #include -#include +#include namespace SUS { - /** - * Some MAX1227 could not be reached with frequencies around 4 MHz. Maybe this is caused by - * the decoder and buffer circuits. Thus frequency is here defined to 1 MHz. - */ - static const uint32_t MAX1227_SPI_FREQ = 1000000; +/** + * Some MAX1227 could not be reached with frequencies around 4 MHz. Maybe this is caused by + * the decoder and buffer circuits. Thus frequency is here defined to 1 MHz. + */ +static const uint32_t MAX1227_SPI_FREQ = 1000000; - static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending +static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending - static const DeviceCommandId_t WRITE_SETUP = 0x1; - /** - * This command initiates the ADC conversion for all channels including the internal - * temperature sensor. - */ - static const DeviceCommandId_t START_CONVERSIONS = 0x2; - /** - * This command reads the internal fifo which holds the temperature and the channel - * conversions. - */ - static const DeviceCommandId_t READ_CONVERSIONS = 0x3; +static const DeviceCommandId_t WRITE_SETUP = 0x1; +/** + * This command initiates the ADC conversion for all channels including the internal + * temperature sensor. + */ +static const DeviceCommandId_t START_CONVERSIONS = 0x2; +/** + * This command reads the internal fifo which holds the temperature and the channel + * conversions. + */ +static const DeviceCommandId_t READ_CONVERSIONS = 0x3; - /** - * @brief This is the configuration byte which will be written to the setup register after - * power on. - * - * @note Bit1 (DIFFSEL1) - Bit0 (DIFFSEL0): 0b00, No byte is following the setup byte - * Bit3 (REFSEL1) - Bit2 (REFSEL0): 0b10, Internal reference, no wake-up delay - * Bit5 (CLKSEL1) - Bit4 (CLKSEL0): 0b10, Internally clocked - * Bit7 - Bit6: 0b01, Tells MAX1227 that this byte should be - * written to the setup register - * - */ - static const uint8_t SETUP = 0b01101000; +/** + * @brief This is the configuration byte which will be written to the setup register after + * power on. + * + * @note Bit1 (DIFFSEL1) - Bit0 (DIFFSEL0): 0b00, No byte is following the setup byte + * Bit3 (REFSEL1) - Bit2 (REFSEL0): 0b10, Internal reference, no wake-up delay + * Bit5 (CLKSEL1) - Bit4 (CLKSEL0): 0b10, Internally clocked + * Bit7 - Bit6: 0b01, Tells MAX1227 that this byte should be + * written to the setup register + * + */ +static const uint8_t SETUP = 0b01101000; - /** - * @brief This values will always be written to the ADC conversion register to specify the - * conversions to perform. - * @details Bit0: 1 - Enables temperature conversion - * Bit2 (SCAN1) and Bit1 (SCAN0): 0b00, Scans channels 0 through N - * Bit6 - Bit3 defines N: 0b0101 (N = 5) - * Bit7: Always 1. Tells the ADC that this is the conversion register. - */ - static const uint8_t CONVERSION = 0b10101001; +/** + * @brief This values will always be written to the ADC conversion register to specify the + * conversions to perform. + * @details Bit0: 1 - Enables temperature conversion + * Bit2 (SCAN1) and Bit1 (SCAN0): 0b00, Scans channels 0 through N + * Bit6 - Bit3 defines N: 0b0101 (N = 5) + * Bit7: Always 1. Tells the ADC that this is the conversion register. + */ +static const uint8_t CONVERSION = 0b10101001; - static const uint8_t SUS_DATA_SET_ID = READ_CONVERSIONS; +static const uint8_t SUS_DATA_SET_ID = READ_CONVERSIONS; - /** Size of data replies. Temperature and 6 channel convesions (AIN0 - AIN5) */ - static const uint8_t SIZE_READ_CONVERSIONS = 14; +/** Size of data replies. Temperature and 6 channel convesions (AIN0 - AIN5) */ +static const uint8_t SIZE_READ_CONVERSIONS = 14; - static const uint8_t MAX_CMD_SIZE = SIZE_READ_CONVERSIONS; +static const uint8_t MAX_CMD_SIZE = SIZE_READ_CONVERSIONS; - static const uint8_t POOL_ENTRIES = 7; +static const uint8_t POOL_ENTRIES = 7; - enum Max1227PoolIds: lp_id_t { - TEMPERATURE_C, - AIN0, - AIN1, - AIN2, - AIN3, - AIN4, - AIN5, - }; - -class SusDataset: public StaticLocalDataSet { -public: - - SusDataset(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, SUS_DATA_SET_ID) { - } - - SusDataset(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, SUS_DATA_SET_ID)) { - } - - lp_var_t temperatureCelcius = lp_var_t(sid.objectId, TEMPERATURE_C, this); - lp_var_t ain0 = lp_var_t(sid.objectId, AIN0, this); - lp_var_t ain1 = lp_var_t(sid.objectId, AIN1, this); - lp_var_t ain2 = lp_var_t(sid.objectId, AIN2, this); - lp_var_t ain3 = lp_var_t(sid.objectId, AIN3, this); - lp_var_t ain4 = lp_var_t(sid.objectId, AIN4, this); - lp_var_t ain5 = lp_var_t(sid.objectId, AIN5, this); +enum Max1227PoolIds : lp_id_t { + TEMPERATURE_C, + AIN0, + AIN1, + AIN2, + AIN3, + AIN4, + AIN5, }; -} +class SusDataset : public StaticLocalDataSet { + public: + SusDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, SUS_DATA_SET_ID) {} + + SusDataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, SUS_DATA_SET_ID)) {} + + lp_var_t temperatureCelcius = lp_var_t(sid.objectId, TEMPERATURE_C, this); + lp_var_t ain0 = lp_var_t(sid.objectId, AIN0, this); + lp_var_t ain1 = lp_var_t(sid.objectId, AIN1, this); + lp_var_t ain2 = lp_var_t(sid.objectId, AIN2, this); + lp_var_t ain3 = lp_var_t(sid.objectId, AIN3, this); + lp_var_t ain4 = lp_var_t(sid.objectId, AIN4, this); + lp_var_t ain5 = lp_var_t(sid.objectId, AIN5, this); +}; +} // namespace SUS #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_SUS_H_ */ diff --git a/linux/fsfwconfig/devices/addresses.cpp b/linux/fsfwconfig/devices/addresses.cpp index 38877737..60b1370b 100644 --- a/linux/fsfwconfig/devices/addresses.cpp +++ b/linux/fsfwconfig/devices/addresses.cpp @@ -5,7 +5,3 @@ */ #include "addresses.h" - - - - diff --git a/linux/fsfwconfig/devices/addresses.h b/linux/fsfwconfig/devices/addresses.h index 94f22c54..5ef82788 100644 --- a/linux/fsfwconfig/devices/addresses.h +++ b/linux/fsfwconfig/devices/addresses.h @@ -2,84 +2,85 @@ #define FSFWCONFIG_DEVICES_ADDRESSES_H_ #include -#include "objects/systemObjectList.h" + #include +#include "objects/systemObjectList.h" + namespace addresses { - /* Logical addresses have uint32_t datatype */ - enum logicalAddresses: address_t { - PCDU, +/* Logical addresses have uint32_t datatype */ +enum logicalAddresses : address_t { + PCDU, - MGM_0_LIS3 = objects::MGM_0_LIS3_HANDLER, - MGM_1_RM3100 = objects::MGM_1_RM3100_HANDLER, - MGM_2_LIS3 = objects::MGM_2_LIS3_HANDLER, - MGM_3_RM3100 = objects::MGM_3_RM3100_HANDLER, + MGM_0_LIS3 = objects::MGM_0_LIS3_HANDLER, + MGM_1_RM3100 = objects::MGM_1_RM3100_HANDLER, + MGM_2_LIS3 = objects::MGM_2_LIS3_HANDLER, + MGM_3_RM3100 = objects::MGM_3_RM3100_HANDLER, - GYRO_0_ADIS = objects::GYRO_0_ADIS_HANDLER, - GYRO_1_L3G = objects::GYRO_1_L3G_HANDLER, - GYRO_2_ADIS = objects::GYRO_2_ADIS_HANDLER, - GYRO_3_L3G = objects::GYRO_3_L3G_HANDLER, + GYRO_0_ADIS = objects::GYRO_0_ADIS_HANDLER, + GYRO_1_L3G = objects::GYRO_1_L3G_HANDLER, + GYRO_2_ADIS = objects::GYRO_2_ADIS_HANDLER, + GYRO_3_L3G = objects::GYRO_3_L3G_HANDLER, - RAD_SENSOR = objects::RAD_SENSOR, + RAD_SENSOR = objects::RAD_SENSOR, - SUS_1 = objects::SUS_1, - SUS_2 = objects::SUS_2, - SUS_3 = objects::SUS_3, - SUS_4 = objects::SUS_4, - SUS_5 = objects::SUS_5, - SUS_6 = objects::SUS_6, - SUS_7 = objects::SUS_7, - SUS_8 = objects::SUS_8, - SUS_9 = objects::SUS_9, - SUS_10 = objects::SUS_10, - SUS_11 = objects::SUS_11, - SUS_12 = objects::SUS_12, - SUS_13 = objects::SUS_13, + SUS_1 = objects::SUS_1, + SUS_2 = objects::SUS_2, + SUS_3 = objects::SUS_3, + SUS_4 = objects::SUS_4, + SUS_5 = objects::SUS_5, + SUS_6 = objects::SUS_6, + SUS_7 = objects::SUS_7, + SUS_8 = objects::SUS_8, + SUS_9 = objects::SUS_9, + SUS_10 = objects::SUS_10, + SUS_11 = objects::SUS_11, + SUS_12 = objects::SUS_12, + SUS_13 = objects::SUS_13, - /* Dummy and Test Addresses */ - DUMMY_ECHO = 129, - DUMMY_GPS0 = 130, - DUMMY_GPS1 = 131, - }; + /* Dummy and Test Addresses */ + DUMMY_ECHO = 129, + DUMMY_GPS0 = 130, + DUMMY_GPS1 = 131, +}; - enum i2cAddresses: address_t { - IMTQ = 16, - TMP1075_TCS_1 = 72, - TMP1075_TCS_2 = 73, - }; +enum i2cAddresses : address_t { + IMTQ = 16, + TMP1075_TCS_1 = 72, + TMP1075_TCS_2 = 73, +}; - enum spiAddresses: address_t { - RTD_IC_3, - RTD_IC_4, - RTD_IC_5, - RTD_IC_6, - RTD_IC_7, - RTD_IC_8, - RTD_IC_9, - RTD_IC_10, - RTD_IC_11, - RTD_IC_12, - RTD_IC_13, - RTD_IC_14, - RTD_IC_15, - RTD_IC_16, - RTD_IC_17, - RTD_IC_18, - RW1, - RW2, - RW3, - RW4 - }; - - /* Addresses of devices supporting the CSP protocol */ - enum cspAddresses: uint8_t { - P60DOCK = 4, - ACU = 2, - PDU1 = 3, - /* PDU2 occupies X4 slot of P60Dock */ - PDU2 = 6 - }; -} +enum spiAddresses : address_t { + RTD_IC_3, + RTD_IC_4, + RTD_IC_5, + RTD_IC_6, + RTD_IC_7, + RTD_IC_8, + RTD_IC_9, + RTD_IC_10, + RTD_IC_11, + RTD_IC_12, + RTD_IC_13, + RTD_IC_14, + RTD_IC_15, + RTD_IC_16, + RTD_IC_17, + RTD_IC_18, + RW1, + RW2, + RW3, + RW4 +}; +/* Addresses of devices supporting the CSP protocol */ +enum cspAddresses : uint8_t { + P60DOCK = 4, + ACU = 2, + PDU1 = 3, + /* PDU2 occupies X4 slot of P60Dock */ + PDU2 = 6 +}; +} // namespace addresses #endif /* FSFWCONFIG_DEVICES_ADDRESSES_H_ */ diff --git a/linux/fsfwconfig/devices/gpioIds.h b/linux/fsfwconfig/devices/gpioIds.h index e4b9f727..bb753a30 100644 --- a/linux/fsfwconfig/devices/gpioIds.h +++ b/linux/fsfwconfig/devices/gpioIds.h @@ -5,116 +5,112 @@ namespace gpioIds { enum gpioId_t { - HEATER_0, - HEATER_1, - HEATER_2, - HEATER_3, - HEATER_4, - HEATER_5, - HEATER_6, - HEATER_7, - DEPLSA1, - DEPLSA2, + HEATER_0, + HEATER_1, + HEATER_2, + HEATER_3, + HEATER_4, + HEATER_5, + HEATER_6, + HEATER_7, + DEPLSA1, + DEPLSA2, - MGM_0_LIS3_CS, - MGM_1_RM3100_CS, - GYRO_0_ADIS_CS, - GYRO_1_L3G_CS, - GYRO_2_ADIS_CS, - GYRO_3_L3G_CS, - MGM_2_LIS3_CS, - MGM_3_RM3100_CS, + MGM_0_LIS3_CS, + MGM_1_RM3100_CS, + GYRO_0_ADIS_CS, + GYRO_1_L3G_CS, + GYRO_2_ADIS_CS, + GYRO_3_L3G_CS, + MGM_2_LIS3_CS, + MGM_3_RM3100_CS, - GNSS_0_NRESET, - GNSS_1_NRESET, - GNSS_0_ENABLE, - GNSS_1_ENABLE, + GNSS_0_NRESET, + GNSS_1_NRESET, + GNSS_0_ENABLE, + GNSS_1_ENABLE, - GYRO_0_ENABLE, - GYRO_2_ENABLE, + GYRO_0_ENABLE, + GYRO_2_ENABLE, - TEST_ID_0, - TEST_ID_1, + TEST_ID_0, + TEST_ID_1, - RTD_IC_3, - RTD_IC_4, - RTD_IC_5, - RTD_IC_6, - RTD_IC_7, - RTD_IC_8, - RTD_IC_9, - RTD_IC_10, - RTD_IC_11, - RTD_IC_12, - RTD_IC_13, - RTD_IC_14, - RTD_IC_15, - RTD_IC_16, - RTD_IC_17, - RTD_IC_18, + RTD_IC_3, + RTD_IC_4, + RTD_IC_5, + RTD_IC_6, + RTD_IC_7, + RTD_IC_8, + RTD_IC_9, + RTD_IC_10, + RTD_IC_11, + RTD_IC_12, + RTD_IC_13, + RTD_IC_14, + RTD_IC_15, + RTD_IC_16, + RTD_IC_17, + RTD_IC_18, - CS_SUS_1, - CS_SUS_2, - CS_SUS_3, - CS_SUS_4, - CS_SUS_5, - CS_SUS_6, - CS_SUS_7, - CS_SUS_8, - CS_SUS_9, - CS_SUS_10, - CS_SUS_11, - CS_SUS_12, - CS_SUS_13, + CS_SUS_1, + CS_SUS_2, + CS_SUS_3, + CS_SUS_4, + CS_SUS_5, + CS_SUS_6, + CS_SUS_7, + CS_SUS_8, + CS_SUS_9, + CS_SUS_10, + CS_SUS_11, + CS_SUS_12, + CS_SUS_13, - SPI_MUX_BIT_1, - SPI_MUX_BIT_2, - SPI_MUX_BIT_3, - SPI_MUX_BIT_4, - SPI_MUX_BIT_5, - SPI_MUX_BIT_6, + SPI_MUX_BIT_1, + SPI_MUX_BIT_2, + SPI_MUX_BIT_3, + SPI_MUX_BIT_4, + SPI_MUX_BIT_5, + SPI_MUX_BIT_6, - CS_RAD_SENSOR, + CS_RAD_SENSOR, - PAPB_BUSY_N, - PAPB_EMPTY, + PAPB_BUSY_N, + PAPB_EMPTY, - EN_RW1, - EN_RW2, - EN_RW3, - EN_RW4, + EN_RW1, + EN_RW2, + EN_RW3, + EN_RW4, - CS_RW1, - CS_RW2, - CS_RW3, - CS_RW4, + CS_RW1, + CS_RW2, + CS_RW3, + CS_RW4, - EN_RW_CS, + EN_RW_CS, - SPI_MUX, + SPI_MUX, - VC0_PAPB_EMPTY, - VC0_PAPB_BUSY, - VC1_PAPB_EMPTY, - VC1_PAPB_BUSY, - VC2_PAPB_EMPTY, - VC2_PAPB_BUSY, - VC3_PAPB_EMPTY, - VC3_PAPB_BUSY, + VC0_PAPB_EMPTY, + VC0_PAPB_BUSY, + VC1_PAPB_EMPTY, + VC1_PAPB_BUSY, + VC2_PAPB_EMPTY, + VC2_PAPB_BUSY, + VC3_PAPB_EMPTY, + VC3_PAPB_BUSY, - PDEC_RESET, + PDEC_RESET, + RS485_EN_TX_DATA, + RS485_EN_TX_CLOCK, + RS485_EN_RX_DATA, + RS485_EN_RX_CLOCK, - RS485_EN_TX_DATA, - RS485_EN_TX_CLOCK, - RS485_EN_RX_DATA, - RS485_EN_RX_CLOCK, - - BIT_RATE_SEL + BIT_RATE_SEL }; } - - - #endif /* FSFWCONFIG_DEVICES_GPIOIDS_H_ */ diff --git a/linux/fsfwconfig/devices/powerSwitcherList.h b/linux/fsfwconfig/devices/powerSwitcherList.h index bc5731fd..cc6bc141 100644 --- a/linux/fsfwconfig/devices/powerSwitcherList.h +++ b/linux/fsfwconfig/devices/powerSwitcherList.h @@ -4,55 +4,54 @@ #include "OBSWConfig.h" namespace pcduSwitches { - /* Switches are uint8_t datatype and go from 0 to 255 */ - enum SwitcherList: uint8_t { - Q7S, - PAYLOAD_PCDU_CH1, - RW, - TCS_BOARD_8V_HEATER_IN, - SUS_REDUNDANT, - DEPLOYMENT_MECHANISM, - PAYLOAD_PCDU_CH6, - ACS_BOARD_SIDE_B, - PAYLOAD_CAMERA, - TCS_BOARD_3V3, - SYRLINKS, - STAR_TRACKER, - MGT, - SUS_NOMINAL, - SOLAR_CELL_EXP, - PLOC, - ACS_BOARD_SIDE_A, - NUMBER_OF_SWITCHES - }; +/* Switches are uint8_t datatype and go from 0 to 255 */ +enum SwitcherList : uint8_t { + Q7S, + PAYLOAD_PCDU_CH1, + RW, + TCS_BOARD_8V_HEATER_IN, + SUS_REDUNDANT, + DEPLOYMENT_MECHANISM, + PAYLOAD_PCDU_CH6, + ACS_BOARD_SIDE_B, + PAYLOAD_CAMERA, + TCS_BOARD_3V3, + SYRLINKS, + STAR_TRACKER, + MGT, + SUS_NOMINAL, + SOLAR_CELL_EXP, + PLOC, + ACS_BOARD_SIDE_A, + NUMBER_OF_SWITCHES +}; - static const uint8_t ON = 1; - static const uint8_t OFF = 0; +static const uint8_t ON = 1; +static const uint8_t OFF = 0; - /* Output states after reboot of the PDUs */ - static const uint8_t INIT_STATE_Q7S = ON; - static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH1 = OFF; - static const uint8_t INIT_STATE_RW = OFF; +/* Output states after reboot of the PDUs */ +static const uint8_t INIT_STATE_Q7S = ON; +static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH1 = OFF; +static const uint8_t INIT_STATE_RW = OFF; #if BOARD_TE0720 == 1 - /* Because the TE0720 is not connected to the PCDU, this switch is always on */ - static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = ON; +/* Because the TE0720 is not connected to the PCDU, this switch is always on */ +static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = ON; #else - static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = OFF; +static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = OFF; #endif - static const uint8_t INIT_STATE_SUS_REDUNDANT = OFF; - static const uint8_t INIT_STATE_DEPLOYMENT_MECHANISM = OFF; - static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH6 = OFF; - static const uint8_t INIT_STATE_ACS_BOARD_SIDE_B = OFF; - static const uint8_t INIT_STATE_PAYLOAD_CAMERA = OFF; - static const uint8_t INIT_STATE_TCS_BOARD_3V3 = OFF; - static const uint8_t INIT_STATE_SYRLINKS = OFF; - static const uint8_t INIT_STATE_STAR_TRACKER = OFF; - static const uint8_t INIT_STATE_MGT = OFF; - static const uint8_t INIT_STATE_SUS_NOMINAL = OFF; - static const uint8_t INIT_STATE_SOLAR_CELL_EXP = OFF; - static const uint8_t INIT_STATE_PLOC = OFF; - static const uint8_t INIT_STATE_ACS_BOARD_SIDE_A = OFF; -} - +static const uint8_t INIT_STATE_SUS_REDUNDANT = OFF; +static const uint8_t INIT_STATE_DEPLOYMENT_MECHANISM = OFF; +static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH6 = OFF; +static const uint8_t INIT_STATE_ACS_BOARD_SIDE_B = OFF; +static const uint8_t INIT_STATE_PAYLOAD_CAMERA = OFF; +static const uint8_t INIT_STATE_TCS_BOARD_3V3 = OFF; +static const uint8_t INIT_STATE_SYRLINKS = OFF; +static const uint8_t INIT_STATE_STAR_TRACKER = OFF; +static const uint8_t INIT_STATE_MGT = OFF; +static const uint8_t INIT_STATE_SUS_NOMINAL = OFF; +static const uint8_t INIT_STATE_SOLAR_CELL_EXP = OFF; +static const uint8_t INIT_STATE_PLOC = OFF; +static const uint8_t INIT_STATE_ACS_BOARD_SIDE_A = OFF; +} // namespace pcduSwitches #endif /* FSFWCONFIG_DEVICES_POWERSWITCHERLIST_H_ */ diff --git a/linux/fsfwconfig/events/subsystemIdRanges.h b/linux/fsfwconfig/events/subsystemIdRanges.h index 4894be16..33ef1a09 100644 --- a/linux/fsfwconfig/events/subsystemIdRanges.h +++ b/linux/fsfwconfig/events/subsystemIdRanges.h @@ -1,19 +1,19 @@ #ifndef FSFWCONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ #define FSFWCONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ +#include + #include "common/config/commonSubsystemIds.h" #include "fsfw/events/fwSubsystemIdRanges.h" -#include - /** * These IDs are part of the ID for an event thrown by a subsystem. * Numbers 0-80 are reserved for FSFW Subsystem IDs (framework/events/) */ namespace SUBSYSTEM_ID { -enum: uint8_t { - SUBSYSTEM_ID_START = COMMON_SUBSYSTEM_ID_END, - CORE = 116, +enum : uint8_t { + SUBSYSTEM_ID_START = COMMON_SUBSYSTEM_ID_END, + CORE = 116, }; } diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index 17150762..2d028fdd 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -146,290 +146,290 @@ const char *STR_HELPER_FILE_NOT_EXISTS_STRING = "STR_HELPER_FILE_NOT_EXISTS"; const char *STR_HELPER_SENDING_PACKET_FAILED_STRING = "STR_HELPER_SENDING_PACKET_FAILED"; const char *STR_HELPER_REQUESTING_MSG_FAILED_STRING = "STR_HELPER_REQUESTING_MSG_FAILED"; -const char * translateEvents(Event event) { - switch( (event & 0xffff) ) { - case(2200): - return STORE_SEND_WRITE_FAILED_STRING; - case(2201): - return STORE_WRITE_FAILED_STRING; - case(2202): - return STORE_SEND_READ_FAILED_STRING; - case(2203): - return STORE_READ_FAILED_STRING; - case(2204): - return UNEXPECTED_MSG_STRING; - case(2205): - return STORING_FAILED_STRING; - case(2206): - return TM_DUMP_FAILED_STRING; - case(2207): - return STORE_INIT_FAILED_STRING; - case(2208): - return STORE_INIT_EMPTY_STRING; - case(2209): - return STORE_CONTENT_CORRUPTED_STRING; - case(2210): - return STORE_INITIALIZE_STRING; - case(2211): - return INIT_DONE_STRING; - case(2212): - return DUMP_FINISHED_STRING; - case(2213): - return DELETION_FINISHED_STRING; - case(2214): - return DELETION_FAILED_STRING; - case(2215): - return AUTO_CATALOGS_SENDING_FAILED_STRING; - case(2600): - return GET_DATA_FAILED_STRING; - case(2601): - return STORE_DATA_FAILED_STRING; - case(2800): - return DEVICE_BUILDING_COMMAND_FAILED_STRING; - case(2801): - return DEVICE_SENDING_COMMAND_FAILED_STRING; - case(2802): - return DEVICE_REQUESTING_REPLY_FAILED_STRING; - case(2803): - return DEVICE_READING_REPLY_FAILED_STRING; - case(2804): - return DEVICE_INTERPRETING_REPLY_FAILED_STRING; - case(2805): - return DEVICE_MISSED_REPLY_STRING; - case(2806): - return DEVICE_UNKNOWN_REPLY_STRING; - case(2807): - return DEVICE_UNREQUESTED_REPLY_STRING; - case(2808): - return INVALID_DEVICE_COMMAND_STRING; - case(2809): - return MONITORING_LIMIT_EXCEEDED_STRING; - case(2810): - return MONITORING_AMBIGUOUS_STRING; - case(4201): - return FUSE_CURRENT_HIGH_STRING; - case(4202): - return FUSE_WENT_OFF_STRING; - case(4204): - return POWER_ABOVE_HIGH_LIMIT_STRING; - case(4205): - return POWER_BELOW_LOW_LIMIT_STRING; - case(4300): - return SWITCH_WENT_OFF_STRING; - case(5000): - return HEATER_ON_STRING; - case(5001): - return HEATER_OFF_STRING; - case(5002): - return HEATER_TIMEOUT_STRING; - case(5003): - return HEATER_STAYED_ON_STRING; - case(5004): - return HEATER_STAYED_OFF_STRING; - case(5200): - return TEMP_SENSOR_HIGH_STRING; - case(5201): - return TEMP_SENSOR_LOW_STRING; - case(5202): - return TEMP_SENSOR_GRADIENT_STRING; - case(5901): - return COMPONENT_TEMP_LOW_STRING; - case(5902): - return COMPONENT_TEMP_HIGH_STRING; - case(5903): - return COMPONENT_TEMP_OOL_LOW_STRING; - case(5904): - return COMPONENT_TEMP_OOL_HIGH_STRING; - case(5905): - return TEMP_NOT_IN_OP_RANGE_STRING; - case(7101): - return FDIR_CHANGED_STATE_STRING; - case(7102): - return FDIR_STARTS_RECOVERY_STRING; - case(7103): - return FDIR_TURNS_OFF_DEVICE_STRING; - case(7201): - return MONITOR_CHANGED_STATE_STRING; - case(7202): - return VALUE_BELOW_LOW_LIMIT_STRING; - case(7203): - return VALUE_ABOVE_HIGH_LIMIT_STRING; - case(7204): - return VALUE_OUT_OF_RANGE_STRING; - case(7301): - return SWITCHING_TM_FAILED_STRING; - case(7400): - return CHANGING_MODE_STRING; - case(7401): - return MODE_INFO_STRING; - case(7402): - return FALLBACK_FAILED_STRING; - case(7403): - return MODE_TRANSITION_FAILED_STRING; - case(7404): - return CANT_KEEP_MODE_STRING; - case(7405): - return OBJECT_IN_INVALID_MODE_STRING; - case(7406): - return FORCING_MODE_STRING; - case(7407): - return MODE_CMD_REJECTED_STRING; - case(7506): - return HEALTH_INFO_STRING; - case(7507): - return CHILD_CHANGED_HEALTH_STRING; - case(7508): - return CHILD_PROBLEMS_STRING; - case(7509): - return OVERWRITING_HEALTH_STRING; - case(7510): - return TRYING_RECOVERY_STRING; - case(7511): - return RECOVERY_STEP_STRING; - case(7512): - return RECOVERY_DONE_STRING; - case(7900): - return RF_AVAILABLE_STRING; - case(7901): - return RF_LOST_STRING; - case(7902): - return BIT_LOCK_STRING; - case(7903): - return BIT_LOCK_LOST_STRING; - case(7905): - return FRAME_PROCESSING_FAILED_STRING; - case(8900): - return CLOCK_SET_STRING; - case(8901): - return CLOCK_SET_FAILURE_STRING; - case(9700): - return TEST_STRING; - case(10600): - return CHANGE_OF_SETUP_PARAMETER_STRING; - case(10900): - return GPIO_PULL_HIGH_FAILED_STRING; - case(10901): - return GPIO_PULL_LOW_FAILED_STRING; - case(10902): - return SWITCH_ALREADY_ON_STRING; - case(10903): - return SWITCH_ALREADY_OFF_STRING; - case(10904): - return MAIN_SWITCH_TIMEOUT_STRING; - case(11000): - return MAIN_SWITCH_ON_TIMEOUT_STRING; - case(11001): - return MAIN_SWITCH_OFF_TIMEOUT_STRING; - case(11002): - return DEPLOYMENT_FAILED_STRING; - case(11003): - return DEPL_SA1_GPIO_SWTICH_ON_FAILED_STRING; - case(11004): - return DEPL_SA2_GPIO_SWTICH_ON_FAILED_STRING; - case(11101): - return MEMORY_READ_RPT_CRC_FAILURE_STRING; - case(11102): - return ACK_FAILURE_STRING; - case(11103): - return EXE_FAILURE_STRING; - case(11104): - return CRC_FAILURE_EVENT_STRING; - case(11201): - return SELF_TEST_I2C_FAILURE_STRING; - case(11202): - return SELF_TEST_SPI_FAILURE_STRING; - case(11203): - return SELF_TEST_ADC_FAILURE_STRING; - case(11204): - return SELF_TEST_PWM_FAILURE_STRING; - case(11205): - return SELF_TEST_TC_FAILURE_STRING; - case(11206): - return SELF_TEST_MTM_RANGE_FAILURE_STRING; - case(11207): - return SELF_TEST_COIL_CURRENT_FAILURE_STRING; - case(11208): - return INVALID_ERROR_BYTE_STRING; - case(11301): - return ERROR_STATE_STRING; - case(11501): - return SUPV_MEMORY_READ_RPT_CRC_FAILURE_STRING; - case(11502): - return SUPV_ACK_FAILURE_STRING; - case(11503): - return SUPV_EXE_FAILURE_STRING; - case(11504): - return SUPV_CRC_FAILURE_EVENT_STRING; - case(11600): - return SANITIZATION_FAILED_STRING; - case(11700): - return UPDATE_FILE_NOT_EXISTS_STRING; - case(11701): - return ACTION_COMMANDING_FAILED_STRING; - case(11702): - return UPDATE_AVAILABLE_FAILED_STRING; - case(11703): - return UPDATE_TRANSFER_FAILED_STRING; - case(11704): - return UPDATE_VERIFY_FAILED_STRING; - case(11705): - return UPDATE_FINISHED_STRING; - case(11800): - return SEND_MRAM_DUMP_FAILED_STRING; - case(11801): - return MRAM_DUMP_FAILED_STRING; - case(11802): - return MRAM_DUMP_FINISHED_STRING; - case(11901): - return INVALID_TC_FRAME_STRING; - case(11902): - return INVALID_FAR_STRING; - case(11903): - return CARRIER_LOCK_STRING; - case(11904): - return BIT_LOCK_PDEC_STRING; - case(12000): - return IMAGE_UPLOAD_FAILED_STRING; - case(12001): - return IMAGE_DOWNLOAD_FAILED_STRING; - case(12002): - return IMAGE_UPLOAD_SUCCESSFUL_STRING; - case(12003): - return IMAGE_DOWNLOAD_SUCCESSFUL_STRING; - case(12004): - return FLASH_WRITE_SUCCESSFUL_STRING; - case(12005): - return FLASH_READ_SUCCESSFUL_STRING; - case(12006): - return FLASH_WRITE_FAILED_STRING; - case(12007): - return FLASH_READ_FAILED_STRING; - case(12008): - return FPGA_DOWNLOAD_SUCCESSFUL_STRING; - case(12009): - return FPGA_DOWNLOAD_FAILED_STRING; - case(12010): - return FPGA_UPLOAD_SUCCESSFUL_STRING; - case(12011): - return FPGA_UPLOAD_FAILED_STRING; - case(12012): - return STR_HELPER_READING_REPLY_FAILED_STRING; - case(12013): - return STR_HELPER_COM_ERROR_STRING; - case(12014): - return STR_HELPER_NO_REPLY_STRING; - case(12015): - return STR_HELPER_DEC_ERROR_STRING; - case(12016): - return POSITION_MISMATCH_STRING; - case(12017): - return STR_HELPER_FILE_NOT_EXISTS_STRING; - case(12018): - return STR_HELPER_SENDING_PACKET_FAILED_STRING; - case(12019): - return STR_HELPER_REQUESTING_MSG_FAILED_STRING; - default: - return "UNKNOWN_EVENT"; - } - return 0; +const char *translateEvents(Event event) { + switch ((event & 0xffff)) { + case (2200): + return STORE_SEND_WRITE_FAILED_STRING; + case (2201): + return STORE_WRITE_FAILED_STRING; + case (2202): + return STORE_SEND_READ_FAILED_STRING; + case (2203): + return STORE_READ_FAILED_STRING; + case (2204): + return UNEXPECTED_MSG_STRING; + case (2205): + return STORING_FAILED_STRING; + case (2206): + return TM_DUMP_FAILED_STRING; + case (2207): + return STORE_INIT_FAILED_STRING; + case (2208): + return STORE_INIT_EMPTY_STRING; + case (2209): + return STORE_CONTENT_CORRUPTED_STRING; + case (2210): + return STORE_INITIALIZE_STRING; + case (2211): + return INIT_DONE_STRING; + case (2212): + return DUMP_FINISHED_STRING; + case (2213): + return DELETION_FINISHED_STRING; + case (2214): + return DELETION_FAILED_STRING; + case (2215): + return AUTO_CATALOGS_SENDING_FAILED_STRING; + case (2600): + return GET_DATA_FAILED_STRING; + case (2601): + return STORE_DATA_FAILED_STRING; + case (2800): + return DEVICE_BUILDING_COMMAND_FAILED_STRING; + case (2801): + return DEVICE_SENDING_COMMAND_FAILED_STRING; + case (2802): + return DEVICE_REQUESTING_REPLY_FAILED_STRING; + case (2803): + return DEVICE_READING_REPLY_FAILED_STRING; + case (2804): + return DEVICE_INTERPRETING_REPLY_FAILED_STRING; + case (2805): + return DEVICE_MISSED_REPLY_STRING; + case (2806): + return DEVICE_UNKNOWN_REPLY_STRING; + case (2807): + return DEVICE_UNREQUESTED_REPLY_STRING; + case (2808): + return INVALID_DEVICE_COMMAND_STRING; + case (2809): + return MONITORING_LIMIT_EXCEEDED_STRING; + case (2810): + return MONITORING_AMBIGUOUS_STRING; + case (4201): + return FUSE_CURRENT_HIGH_STRING; + case (4202): + return FUSE_WENT_OFF_STRING; + case (4204): + return POWER_ABOVE_HIGH_LIMIT_STRING; + case (4205): + return POWER_BELOW_LOW_LIMIT_STRING; + case (4300): + return SWITCH_WENT_OFF_STRING; + case (5000): + return HEATER_ON_STRING; + case (5001): + return HEATER_OFF_STRING; + case (5002): + return HEATER_TIMEOUT_STRING; + case (5003): + return HEATER_STAYED_ON_STRING; + case (5004): + return HEATER_STAYED_OFF_STRING; + case (5200): + return TEMP_SENSOR_HIGH_STRING; + case (5201): + return TEMP_SENSOR_LOW_STRING; + case (5202): + return TEMP_SENSOR_GRADIENT_STRING; + case (5901): + return COMPONENT_TEMP_LOW_STRING; + case (5902): + return COMPONENT_TEMP_HIGH_STRING; + case (5903): + return COMPONENT_TEMP_OOL_LOW_STRING; + case (5904): + return COMPONENT_TEMP_OOL_HIGH_STRING; + case (5905): + return TEMP_NOT_IN_OP_RANGE_STRING; + case (7101): + return FDIR_CHANGED_STATE_STRING; + case (7102): + return FDIR_STARTS_RECOVERY_STRING; + case (7103): + return FDIR_TURNS_OFF_DEVICE_STRING; + case (7201): + return MONITOR_CHANGED_STATE_STRING; + case (7202): + return VALUE_BELOW_LOW_LIMIT_STRING; + case (7203): + return VALUE_ABOVE_HIGH_LIMIT_STRING; + case (7204): + return VALUE_OUT_OF_RANGE_STRING; + case (7301): + return SWITCHING_TM_FAILED_STRING; + case (7400): + return CHANGING_MODE_STRING; + case (7401): + return MODE_INFO_STRING; + case (7402): + return FALLBACK_FAILED_STRING; + case (7403): + return MODE_TRANSITION_FAILED_STRING; + case (7404): + return CANT_KEEP_MODE_STRING; + case (7405): + return OBJECT_IN_INVALID_MODE_STRING; + case (7406): + return FORCING_MODE_STRING; + case (7407): + return MODE_CMD_REJECTED_STRING; + case (7506): + return HEALTH_INFO_STRING; + case (7507): + return CHILD_CHANGED_HEALTH_STRING; + case (7508): + return CHILD_PROBLEMS_STRING; + case (7509): + return OVERWRITING_HEALTH_STRING; + case (7510): + return TRYING_RECOVERY_STRING; + case (7511): + return RECOVERY_STEP_STRING; + case (7512): + return RECOVERY_DONE_STRING; + case (7900): + return RF_AVAILABLE_STRING; + case (7901): + return RF_LOST_STRING; + case (7902): + return BIT_LOCK_STRING; + case (7903): + return BIT_LOCK_LOST_STRING; + case (7905): + return FRAME_PROCESSING_FAILED_STRING; + case (8900): + return CLOCK_SET_STRING; + case (8901): + return CLOCK_SET_FAILURE_STRING; + case (9700): + return TEST_STRING; + case (10600): + return CHANGE_OF_SETUP_PARAMETER_STRING; + case (10900): + return GPIO_PULL_HIGH_FAILED_STRING; + case (10901): + return GPIO_PULL_LOW_FAILED_STRING; + case (10902): + return SWITCH_ALREADY_ON_STRING; + case (10903): + return SWITCH_ALREADY_OFF_STRING; + case (10904): + return MAIN_SWITCH_TIMEOUT_STRING; + case (11000): + return MAIN_SWITCH_ON_TIMEOUT_STRING; + case (11001): + return MAIN_SWITCH_OFF_TIMEOUT_STRING; + case (11002): + return DEPLOYMENT_FAILED_STRING; + case (11003): + return DEPL_SA1_GPIO_SWTICH_ON_FAILED_STRING; + case (11004): + return DEPL_SA2_GPIO_SWTICH_ON_FAILED_STRING; + case (11101): + return MEMORY_READ_RPT_CRC_FAILURE_STRING; + case (11102): + return ACK_FAILURE_STRING; + case (11103): + return EXE_FAILURE_STRING; + case (11104): + return CRC_FAILURE_EVENT_STRING; + case (11201): + return SELF_TEST_I2C_FAILURE_STRING; + case (11202): + return SELF_TEST_SPI_FAILURE_STRING; + case (11203): + return SELF_TEST_ADC_FAILURE_STRING; + case (11204): + return SELF_TEST_PWM_FAILURE_STRING; + case (11205): + return SELF_TEST_TC_FAILURE_STRING; + case (11206): + return SELF_TEST_MTM_RANGE_FAILURE_STRING; + case (11207): + return SELF_TEST_COIL_CURRENT_FAILURE_STRING; + case (11208): + return INVALID_ERROR_BYTE_STRING; + case (11301): + return ERROR_STATE_STRING; + case (11501): + return SUPV_MEMORY_READ_RPT_CRC_FAILURE_STRING; + case (11502): + return SUPV_ACK_FAILURE_STRING; + case (11503): + return SUPV_EXE_FAILURE_STRING; + case (11504): + return SUPV_CRC_FAILURE_EVENT_STRING; + case (11600): + return SANITIZATION_FAILED_STRING; + case (11700): + return UPDATE_FILE_NOT_EXISTS_STRING; + case (11701): + return ACTION_COMMANDING_FAILED_STRING; + case (11702): + return UPDATE_AVAILABLE_FAILED_STRING; + case (11703): + return UPDATE_TRANSFER_FAILED_STRING; + case (11704): + return UPDATE_VERIFY_FAILED_STRING; + case (11705): + return UPDATE_FINISHED_STRING; + case (11800): + return SEND_MRAM_DUMP_FAILED_STRING; + case (11801): + return MRAM_DUMP_FAILED_STRING; + case (11802): + return MRAM_DUMP_FINISHED_STRING; + case (11901): + return INVALID_TC_FRAME_STRING; + case (11902): + return INVALID_FAR_STRING; + case (11903): + return CARRIER_LOCK_STRING; + case (11904): + return BIT_LOCK_PDEC_STRING; + case (12000): + return IMAGE_UPLOAD_FAILED_STRING; + case (12001): + return IMAGE_DOWNLOAD_FAILED_STRING; + case (12002): + return IMAGE_UPLOAD_SUCCESSFUL_STRING; + case (12003): + return IMAGE_DOWNLOAD_SUCCESSFUL_STRING; + case (12004): + return FLASH_WRITE_SUCCESSFUL_STRING; + case (12005): + return FLASH_READ_SUCCESSFUL_STRING; + case (12006): + return FLASH_WRITE_FAILED_STRING; + case (12007): + return FLASH_READ_FAILED_STRING; + case (12008): + return FPGA_DOWNLOAD_SUCCESSFUL_STRING; + case (12009): + return FPGA_DOWNLOAD_FAILED_STRING; + case (12010): + return FPGA_UPLOAD_SUCCESSFUL_STRING; + case (12011): + return FPGA_UPLOAD_FAILED_STRING; + case (12012): + return STR_HELPER_READING_REPLY_FAILED_STRING; + case (12013): + return STR_HELPER_COM_ERROR_STRING; + case (12014): + return STR_HELPER_NO_REPLY_STRING; + case (12015): + return STR_HELPER_DEC_ERROR_STRING; + case (12016): + return POSITION_MISMATCH_STRING; + case (12017): + return STR_HELPER_FILE_NOT_EXISTS_STRING; + case (12018): + return STR_HELPER_SENDING_PACKET_FAILED_STRING; + case (12019): + return STR_HELPER_REQUESTING_MSG_FAILED_STRING; + default: + return "UNKNOWN_EVENT"; + } + return 0; } diff --git a/linux/fsfwconfig/events/translateEvents.h b/linux/fsfwconfig/events/translateEvents.h index bdabb21b..1b8a8831 100644 --- a/linux/fsfwconfig/events/translateEvents.h +++ b/linux/fsfwconfig/events/translateEvents.h @@ -3,6 +3,6 @@ #include "fsfw/events/Event.h" -const char * translateEvents(Event event); +const char* translateEvents(Event event); #endif /* FSFWCONFIG_EVENTS_TRANSLATEEVENTS_H_ */ diff --git a/linux/fsfwconfig/ipc/MissionMessageTypes.cpp b/linux/fsfwconfig/ipc/MissionMessageTypes.cpp index 9ac6f0f4..fa1c4877 100644 --- a/linux/fsfwconfig/ipc/MissionMessageTypes.cpp +++ b/linux/fsfwconfig/ipc/MissionMessageTypes.cpp @@ -1,12 +1,10 @@ #include "MissionMessageTypes.h" + #include - void messagetypes::clearMissionMessage(CommandMessage* message) { - switch(message->getMessageType()) { - default: - break; - } + switch (message->getMessageType()) { + default: + break; + } } - - diff --git a/linux/fsfwconfig/ipc/MissionMessageTypes.h b/linux/fsfwconfig/ipc/MissionMessageTypes.h index ab2a84b5..78b0d343 100644 --- a/linux/fsfwconfig/ipc/MissionMessageTypes.h +++ b/linux/fsfwconfig/ipc/MissionMessageTypes.h @@ -11,12 +11,12 @@ class CommandMessage; * * @param message Generic Command Message */ -namespace messagetypes{ +namespace messagetypes { enum MESSAGE_TYPE { - MISSION_MESSAGE_TYPE_START = FW_MESSAGES_COUNT, + MISSION_MESSAGE_TYPE_START = FW_MESSAGES_COUNT, }; void clearMissionMessage(CommandMessage* message); -} +} // namespace messagetypes #endif /* FSFWCONFIG_IPC_MISSIONMESSAGETYPES_H_ */ diff --git a/linux/fsfwconfig/objects/systemObjectList.h b/linux/fsfwconfig/objects/systemObjectList.h index a8929187..c868730b 100644 --- a/linux/fsfwconfig/objects/systemObjectList.h +++ b/linux/fsfwconfig/objects/systemObjectList.h @@ -1,10 +1,12 @@ #ifndef HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ #define HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ -#include "commonObjects.h" #include + #include +#include "commonObjects.h" + // The objects will be instantiated in the ID order // For naming scheme see flight manual /* @@ -31,38 +33,38 @@ Fourth byte is a unique counter. */ namespace objects { -enum sourceObjects: uint32_t { - /* 0x53 reserved for FSFW */ - FW_ADDRESS_START = PUS_SERVICE_1_VERIFICATION, - FW_ADDRESS_END = TIME_STAMPER, - PUS_SERVICE_6 = 0x51000500, +enum sourceObjects : uint32_t { + /* 0x53 reserved for FSFW */ + FW_ADDRESS_START = PUS_SERVICE_1_VERIFICATION, + FW_ADDRESS_END = TIME_STAMPER, + PUS_SERVICE_6 = 0x51000500, - CCSDS_IP_CORE_BRIDGE = 0x73500000, - TM_FUNNEL = 0x73000100, + CCSDS_IP_CORE_BRIDGE = 0x73500000, + TM_FUNNEL = 0x73000100, - /* 0x49 ('I') for Communication Interfaces **/ - ARDUINO_COM_IF = 0x49000000, - CSP_COM_IF = 0x49050001, - I2C_COM_IF = 0x49040002, - UART_COM_IF = 0x49030003, - SPI_COM_IF = 0x49020004, - GPIO_IF = 0x49010005, + /* 0x49 ('I') for Communication Interfaces **/ + ARDUINO_COM_IF = 0x49000000, + CSP_COM_IF = 0x49050001, + I2C_COM_IF = 0x49040002, + UART_COM_IF = 0x49030003, + SPI_COM_IF = 0x49020004, + GPIO_IF = 0x49010005, - /* Custom device handler */ - PCDU_HANDLER = 0x442000A1, - SOLAR_ARRAY_DEPL_HANDLER = 0x444100A2, - SYRLINKS_HK_HANDLER = 0x445300A3, - HEATER_HANDLER = 0x444100A4, - RAD_SENSOR = 0x443200A5, + /* Custom device handler */ + PCDU_HANDLER = 0x442000A1, + SOLAR_ARRAY_DEPL_HANDLER = 0x444100A2, + SYRLINKS_HK_HANDLER = 0x445300A3, + HEATER_HANDLER = 0x444100A4, + RAD_SENSOR = 0x443200A5, - /* 0x54 ('T') for test handlers */ - TEST_TASK = 0x54694269, - LIBGPIOD_TEST = 0x54123456, - SPI_TEST = 0x54000010, - UART_TEST = 0x54000020, - DUMMY_INTERFACE = 0x5400CAFE, - DUMMY_HANDLER = 0x5400AFFE, - P60DOCK_TEST_TASK = 0x00005060, + /* 0x54 ('T') for test handlers */ + TEST_TASK = 0x54694269, + LIBGPIOD_TEST = 0x54123456, + SPI_TEST = 0x54000010, + UART_TEST = 0x54000020, + DUMMY_INTERFACE = 0x5400CAFE, + DUMMY_HANDLER = 0x5400AFFE, + P60DOCK_TEST_TASK = 0x00005060, }; } diff --git a/linux/fsfwconfig/objects/translateObjects.cpp b/linux/fsfwconfig/objects/translateObjects.cpp index 49900a5d..56cbc575 100644 --- a/linux/fsfwconfig/objects/translateObjects.cpp +++ b/linux/fsfwconfig/objects/translateObjects.cpp @@ -120,236 +120,236 @@ const char *TM_FUNNEL_STRING = "TM_FUNNEL"; const char *CCSDS_IP_CORE_BRIDGE_STRING = "CCSDS_IP_CORE_BRIDGE"; const char *NO_OBJECT_STRING = "NO_OBJECT"; -const char* translateObject(object_id_t object) { - switch( (object & 0xFFFFFFFF) ) { - case 0x00005060: - return P60DOCK_TEST_TASK_STRING; - case 0x43000003: - return CORE_CONTROLLER_STRING; - case 0x43100002: - return ACS_CONTROLLER_STRING; - case 0x43400001: - return THERMAL_CONTROLLER_STRING; - case 0x44120006: - return MGM_0_LIS3_HANDLER_STRING; - case 0x44120010: - return GYRO_0_ADIS_HANDLER_STRING; - case 0x44120032: - return SUS_1_STRING; - case 0x44120033: - return SUS_2_STRING; - case 0x44120034: - return SUS_3_STRING; - case 0x44120035: - return SUS_4_STRING; - case 0x44120036: - return SUS_5_STRING; - case 0x44120037: - return SUS_6_STRING; - case 0x44120038: - return SUS_7_STRING; - case 0x44120039: - return SUS_8_STRING; - case 0x44120040: - return SUS_9_STRING; - case 0x44120041: - return SUS_10_STRING; - case 0x44120042: - return SUS_11_STRING; - case 0x44120043: - return SUS_12_STRING; - case 0x44120044: - return SUS_13_STRING; - case 0x44120047: - return RW1_STRING; - case 0x44120107: - return MGM_1_RM3100_HANDLER_STRING; - case 0x44120111: - return GYRO_1_L3G_HANDLER_STRING; - case 0x44120148: - return RW2_STRING; - case 0x44120208: - return MGM_2_LIS3_HANDLER_STRING; - case 0x44120212: - return GYRO_2_ADIS_HANDLER_STRING; - case 0x44120249: - return RW3_STRING; - case 0x44120309: - return MGM_3_RM3100_HANDLER_STRING; - case 0x44120313: - return GYRO_3_L3G_HANDLER_STRING; - case 0x44120350: - return RW4_STRING; - case 0x44130001: - return STAR_TRACKER_STRING; - case 0x44130045: - return GPS0_HANDLER_STRING; - case 0x44130146: - return GPS1_HANDLER_STRING; - case 0x44140014: - return IMTQ_HANDLER_STRING; - case 0x442000A1: - return PCDU_HANDLER_STRING; - case 0x44250000: - return P60DOCK_HANDLER_STRING; - case 0x44250001: - return PDU1_HANDLER_STRING; - case 0x44250002: - return PDU2_HANDLER_STRING; - case 0x44250003: - return ACU_HANDLER_STRING; - case 0x443200A5: - return RAD_SENSOR_STRING; - case 0x44330000: - return PLOC_UPDATER_STRING; - case 0x44330001: - return PLOC_MEMORY_DUMPER_STRING; - case 0x44330002: - return STR_HELPER_STRING; - case 0x44330015: - return PLOC_MPSOC_HANDLER_STRING; - case 0x44330016: - return PLOC_SUPERVISOR_HANDLER_STRING; - case 0x444100A2: - return SOLAR_ARRAY_DEPL_HANDLER_STRING; - case 0x444100A4: - return HEATER_HANDLER_STRING; - case 0x44420004: - return TMP1075_HANDLER_1_STRING; - case 0x44420005: - return TMP1075_HANDLER_2_STRING; - case 0x44420016: - return RTD_IC_3_STRING; - case 0x44420017: - return RTD_IC_4_STRING; - case 0x44420018: - return RTD_IC_5_STRING; - case 0x44420019: - return RTD_IC_6_STRING; - case 0x44420020: - return RTD_IC_7_STRING; - case 0x44420021: - return RTD_IC_8_STRING; - case 0x44420022: - return RTD_IC_9_STRING; - case 0x44420023: - return RTD_IC_10_STRING; - case 0x44420024: - return RTD_IC_11_STRING; - case 0x44420025: - return RTD_IC_12_STRING; - case 0x44420026: - return RTD_IC_13_STRING; - case 0x44420027: - return RTD_IC_14_STRING; - case 0x44420028: - return RTD_IC_15_STRING; - case 0x44420029: - return RTD_IC_16_STRING; - case 0x44420030: - return RTD_IC_17_STRING; - case 0x44420031: - return RTD_IC_18_STRING; - case 0x445300A3: - return SYRLINKS_HK_HANDLER_STRING; - case 0x49000000: - return ARDUINO_COM_IF_STRING; - case 0x49010005: - return GPIO_IF_STRING; - case 0x49020004: - return SPI_COM_IF_STRING; - case 0x49030003: - return UART_COM_IF_STRING; - case 0x49040002: - return I2C_COM_IF_STRING; - case 0x49050001: - return CSP_COM_IF_STRING; - case 0x50000100: - return CCSDS_PACKET_DISTRIBUTOR_STRING; - case 0x50000200: - return PUS_PACKET_DISTRIBUTOR_STRING; - case 0x50000300: - return TMTC_BRIDGE_STRING; - case 0x50000400: - return TMTC_POLLING_TASK_STRING; - case 0x50000500: - return FILE_SYSTEM_HANDLER_STRING; - case 0x50000600: - return PTME_STRING; - case 0x50000700: - return PAPB_VC0_STRING; - case 0x50000701: - return PAPB_VC1_STRING; - case 0x50000702: - return PAPB_VC2_STRING; - case 0x50000703: - return PAPB_VC3_STRING; - case 0x50000704: - return PDEC_HANDLER_STRING; - case 0x50000800: - return CCSDS_HANDLER_STRING; - case 0x51000500: - return PUS_SERVICE_6_STRING; - case 0x53000000: - return FSFW_OBJECTS_START_STRING; - case 0x53000001: - return PUS_SERVICE_1_VERIFICATION_STRING; - case 0x53000002: - return PUS_SERVICE_2_DEVICE_ACCESS_STRING; - case 0x53000003: - return PUS_SERVICE_3_HOUSEKEEPING_STRING; - case 0x53000005: - return PUS_SERVICE_5_EVENT_REPORTING_STRING; - case 0x53000008: - return PUS_SERVICE_8_FUNCTION_MGMT_STRING; - case 0x53000009: - return PUS_SERVICE_9_TIME_MGMT_STRING; - case 0x53000017: - return PUS_SERVICE_17_TEST_STRING; - case 0x53000020: - return PUS_SERVICE_20_PARAMETERS_STRING; - case 0x53000200: - return PUS_SERVICE_200_MODE_MGMT_STRING; - case 0x53000201: - return PUS_SERVICE_201_HEALTH_STRING; - case 0x53010000: - return HEALTH_TABLE_STRING; - case 0x53010100: - return MODE_STORE_STRING; - case 0x53030000: - return EVENT_MANAGER_STRING; - case 0x53040000: - return INTERNAL_ERROR_REPORTER_STRING; - case 0x534f0100: - return TC_STORE_STRING; - case 0x534f0200: - return TM_STORE_STRING; - case 0x534f0300: - return IPC_STORE_STRING; - case 0x53500010: - return TIME_STAMPER_STRING; - case 0x53ffffff: - return FSFW_OBJECTS_END_STRING; - case 0x54000010: - return SPI_TEST_STRING; - case 0x54000020: - return UART_TEST_STRING; - case 0x5400AFFE: - return DUMMY_HANDLER_STRING; - case 0x5400CAFE: - return DUMMY_INTERFACE_STRING; - case 0x54123456: - return LIBGPIOD_TEST_STRING; - case 0x54694269: - return TEST_TASK_STRING; - case 0x73000100: - return TM_FUNNEL_STRING; - case 0x73500000: - return CCSDS_IP_CORE_BRIDGE_STRING; - case 0xFFFFFFFF: - return NO_OBJECT_STRING; - default: - return "UNKNOWN_OBJECT"; - } - return 0; +const char *translateObject(object_id_t object) { + switch ((object & 0xFFFFFFFF)) { + case 0x00005060: + return P60DOCK_TEST_TASK_STRING; + case 0x43000003: + return CORE_CONTROLLER_STRING; + case 0x43100002: + return ACS_CONTROLLER_STRING; + case 0x43400001: + return THERMAL_CONTROLLER_STRING; + case 0x44120006: + return MGM_0_LIS3_HANDLER_STRING; + case 0x44120010: + return GYRO_0_ADIS_HANDLER_STRING; + case 0x44120032: + return SUS_1_STRING; + case 0x44120033: + return SUS_2_STRING; + case 0x44120034: + return SUS_3_STRING; + case 0x44120035: + return SUS_4_STRING; + case 0x44120036: + return SUS_5_STRING; + case 0x44120037: + return SUS_6_STRING; + case 0x44120038: + return SUS_7_STRING; + case 0x44120039: + return SUS_8_STRING; + case 0x44120040: + return SUS_9_STRING; + case 0x44120041: + return SUS_10_STRING; + case 0x44120042: + return SUS_11_STRING; + case 0x44120043: + return SUS_12_STRING; + case 0x44120044: + return SUS_13_STRING; + case 0x44120047: + return RW1_STRING; + case 0x44120107: + return MGM_1_RM3100_HANDLER_STRING; + case 0x44120111: + return GYRO_1_L3G_HANDLER_STRING; + case 0x44120148: + return RW2_STRING; + case 0x44120208: + return MGM_2_LIS3_HANDLER_STRING; + case 0x44120212: + return GYRO_2_ADIS_HANDLER_STRING; + case 0x44120249: + return RW3_STRING; + case 0x44120309: + return MGM_3_RM3100_HANDLER_STRING; + case 0x44120313: + return GYRO_3_L3G_HANDLER_STRING; + case 0x44120350: + return RW4_STRING; + case 0x44130001: + return STAR_TRACKER_STRING; + case 0x44130045: + return GPS0_HANDLER_STRING; + case 0x44130146: + return GPS1_HANDLER_STRING; + case 0x44140014: + return IMTQ_HANDLER_STRING; + case 0x442000A1: + return PCDU_HANDLER_STRING; + case 0x44250000: + return P60DOCK_HANDLER_STRING; + case 0x44250001: + return PDU1_HANDLER_STRING; + case 0x44250002: + return PDU2_HANDLER_STRING; + case 0x44250003: + return ACU_HANDLER_STRING; + case 0x443200A5: + return RAD_SENSOR_STRING; + case 0x44330000: + return PLOC_UPDATER_STRING; + case 0x44330001: + return PLOC_MEMORY_DUMPER_STRING; + case 0x44330002: + return STR_HELPER_STRING; + case 0x44330015: + return PLOC_MPSOC_HANDLER_STRING; + case 0x44330016: + return PLOC_SUPERVISOR_HANDLER_STRING; + case 0x444100A2: + return SOLAR_ARRAY_DEPL_HANDLER_STRING; + case 0x444100A4: + return HEATER_HANDLER_STRING; + case 0x44420004: + return TMP1075_HANDLER_1_STRING; + case 0x44420005: + return TMP1075_HANDLER_2_STRING; + case 0x44420016: + return RTD_IC_3_STRING; + case 0x44420017: + return RTD_IC_4_STRING; + case 0x44420018: + return RTD_IC_5_STRING; + case 0x44420019: + return RTD_IC_6_STRING; + case 0x44420020: + return RTD_IC_7_STRING; + case 0x44420021: + return RTD_IC_8_STRING; + case 0x44420022: + return RTD_IC_9_STRING; + case 0x44420023: + return RTD_IC_10_STRING; + case 0x44420024: + return RTD_IC_11_STRING; + case 0x44420025: + return RTD_IC_12_STRING; + case 0x44420026: + return RTD_IC_13_STRING; + case 0x44420027: + return RTD_IC_14_STRING; + case 0x44420028: + return RTD_IC_15_STRING; + case 0x44420029: + return RTD_IC_16_STRING; + case 0x44420030: + return RTD_IC_17_STRING; + case 0x44420031: + return RTD_IC_18_STRING; + case 0x445300A3: + return SYRLINKS_HK_HANDLER_STRING; + case 0x49000000: + return ARDUINO_COM_IF_STRING; + case 0x49010005: + return GPIO_IF_STRING; + case 0x49020004: + return SPI_COM_IF_STRING; + case 0x49030003: + return UART_COM_IF_STRING; + case 0x49040002: + return I2C_COM_IF_STRING; + case 0x49050001: + return CSP_COM_IF_STRING; + case 0x50000100: + return CCSDS_PACKET_DISTRIBUTOR_STRING; + case 0x50000200: + return PUS_PACKET_DISTRIBUTOR_STRING; + case 0x50000300: + return TMTC_BRIDGE_STRING; + case 0x50000400: + return TMTC_POLLING_TASK_STRING; + case 0x50000500: + return FILE_SYSTEM_HANDLER_STRING; + case 0x50000600: + return PTME_STRING; + case 0x50000700: + return PAPB_VC0_STRING; + case 0x50000701: + return PAPB_VC1_STRING; + case 0x50000702: + return PAPB_VC2_STRING; + case 0x50000703: + return PAPB_VC3_STRING; + case 0x50000704: + return PDEC_HANDLER_STRING; + case 0x50000800: + return CCSDS_HANDLER_STRING; + case 0x51000500: + return PUS_SERVICE_6_STRING; + case 0x53000000: + return FSFW_OBJECTS_START_STRING; + case 0x53000001: + return PUS_SERVICE_1_VERIFICATION_STRING; + case 0x53000002: + return PUS_SERVICE_2_DEVICE_ACCESS_STRING; + case 0x53000003: + return PUS_SERVICE_3_HOUSEKEEPING_STRING; + case 0x53000005: + return PUS_SERVICE_5_EVENT_REPORTING_STRING; + case 0x53000008: + return PUS_SERVICE_8_FUNCTION_MGMT_STRING; + case 0x53000009: + return PUS_SERVICE_9_TIME_MGMT_STRING; + case 0x53000017: + return PUS_SERVICE_17_TEST_STRING; + case 0x53000020: + return PUS_SERVICE_20_PARAMETERS_STRING; + case 0x53000200: + return PUS_SERVICE_200_MODE_MGMT_STRING; + case 0x53000201: + return PUS_SERVICE_201_HEALTH_STRING; + case 0x53010000: + return HEALTH_TABLE_STRING; + case 0x53010100: + return MODE_STORE_STRING; + case 0x53030000: + return EVENT_MANAGER_STRING; + case 0x53040000: + return INTERNAL_ERROR_REPORTER_STRING; + case 0x534f0100: + return TC_STORE_STRING; + case 0x534f0200: + return TM_STORE_STRING; + case 0x534f0300: + return IPC_STORE_STRING; + case 0x53500010: + return TIME_STAMPER_STRING; + case 0x53ffffff: + return FSFW_OBJECTS_END_STRING; + case 0x54000010: + return SPI_TEST_STRING; + case 0x54000020: + return UART_TEST_STRING; + case 0x5400AFFE: + return DUMMY_HANDLER_STRING; + case 0x5400CAFE: + return DUMMY_INTERFACE_STRING; + case 0x54123456: + return LIBGPIOD_TEST_STRING; + case 0x54694269: + return TEST_TASK_STRING; + case 0x73000100: + return TM_FUNNEL_STRING; + case 0x73500000: + return CCSDS_IP_CORE_BRIDGE_STRING; + case 0xFFFFFFFF: + return NO_OBJECT_STRING; + default: + return "UNKNOWN_OBJECT"; + } + return 0; } diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 82748821..814e5c2d 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -1,792 +1,730 @@ #include "pollingSequenceFactory.h" -#include "linux/devices/SusHandler.h" -#include "OBSWConfig.h" +#include #include #include -#include #include + +#include "OBSWConfig.h" +#include "linux/devices/SusHandler.h" #include "objects/systemObjectList.h" +ReturnValue_t pst::pstGpio(FixedTimeslotTaskIF *thisSequence) { + // Length of a communication cycle + uint32_t length = thisSequence->getPeriodMs(); -ReturnValue_t pst::pstGpio(FixedTimeslotTaskIF *thisSequence) -{ - // Length of a communication cycle - uint32_t length = thisSequence->getPeriodMs(); + thisSequence->addSlot(objects::HEATER_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SOLAR_ARRAY_DEPL_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::HEATER_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SOLAR_ARRAY_DEPL_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); + if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { + return HasReturnvaluesIF::RETURN_OK; + } - if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { - return HasReturnvaluesIF::RETURN_OK; - } - - sif::error << "PollingSequence::initialize has errors!" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; + sif::error << "PollingSequence::initialize has errors!" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; } ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { - uint32_t length = thisSequence->getPeriodMs(); - static_cast(length); + uint32_t length = thisSequence->getPeriodMs(); + static_cast(length); #if OBSW_ADD_TMP_DEVICES == 1 - thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0, DeviceHandlerIF::PERFORM_OPERATION); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC_3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_5, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_6, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_7, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_8, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_9, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_10, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_11, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_12, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_13, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_14, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_15, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_16, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_17, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_18, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_5, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_6, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_7, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_8, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_9, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_10, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_11, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_12, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_13, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_14, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_15, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_16, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_17, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_18, length * 0, DeviceHandlerIF::PERFORM_OPERATION); #endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_TMP_DEVICES == 1 - thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.2, DeviceHandlerIF::SEND_WRITE); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC_3, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_4, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_5, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_6, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_7, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_8, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_9, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_10, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_11, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_12, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_13, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_14, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_15, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_16, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_17, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_18, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_3, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_4, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_5, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_6, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_7, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_8, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_9, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_10, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_11, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_12, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_13, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_14, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_15, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_16, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_17, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_18, length * 0.2, DeviceHandlerIF::SEND_WRITE); #endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_TMP_DEVICES == 1 - thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.4, DeviceHandlerIF::GET_WRITE); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC_3, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_4, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_5, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_6, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_7, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_8, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_9, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_10, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_11, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_12, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_13, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_14, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_15, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_16, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_17, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_18, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_3, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_4, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_5, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_6, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_7, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_8, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_9, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_10, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_11, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_12, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_13, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_14, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_15, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_16, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_17, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_18, length * 0.4, DeviceHandlerIF::GET_WRITE); #endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_TMP_DEVICES == 1 - thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.6, DeviceHandlerIF::SEND_READ); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC_3, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_4, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_5, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_6, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_7, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_8, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_9, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_10, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_11, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_12, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_13, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_14, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_15, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_16, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_17, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_18, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_3, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_4, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_5, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_6, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_7, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_8, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_9, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_10, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_11, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_12, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_13, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_14, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_15, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_16, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_17, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_18, length * 0.6, DeviceHandlerIF::SEND_READ); #endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_TMP_DEVICES == 1 - thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC_3, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_4, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_5, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_6, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_7, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_8, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_9, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_10, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_11, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_12, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_13, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_14, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_15, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_16, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_17, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_18, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_3, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_4, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_5, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_6, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_7, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_8, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_9, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_10, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_11, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_12, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_13, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_14, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_15, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_16, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_17, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_18, length * 0.8, DeviceHandlerIF::GET_READ); #endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_RAD_SENSORS == 1 - /* Radiation sensor */ - thisSequence->addSlot(objects::RAD_SENSOR, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.8, DeviceHandlerIF::GET_READ); + /* Radiation sensor */ + thisSequence->addSlot(objects::RAD_SENSOR, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_SUN_SENSORS == 1 - /** - * The sun sensor will be shutdown as soon as the chip select is pulled high. Thus all - * requests to a sun sensor must be performed consecutively. Another reason for calling multiple - * device handler cycles is that the ADC conversions take some time. Thus first the ADC - * conversions are initiated and in a next step the results can be read from the internal FIFO. - * One sun sensor communication sequence also blocks the SPI bus. So other devices can not be - * inserted between the device handler cycles of one SUS. - */ - /* Write setup */ - thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_1, length * 0.9, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_1, length * 0.901, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_1, length * 0.902, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::GET_READ); + /** + * The sun sensor will be shutdown as soon as the chip select is pulled high. Thus all + * requests to a sun sensor must be performed consecutively. Another reason for calling multiple + * device handler cycles is that the ADC conversions take some time. Thus first the ADC + * conversions are initiated and in a next step the results can be read from the internal FIFO. + * One sun sensor communication sequence also blocks the SPI bus. So other devices can not be + * inserted between the device handler cycles of one SUS. + */ + /* Write setup */ + thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_1, length * 0.9, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_1, length * 0.901, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_1, length * 0.902, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_2, length * 0.903, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_2, length * 0.904, SusHandler::SEND_WRITE); - thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_2, length * 0.905, SusHandler::SEND_WRITE); - thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_2, length * 0.903, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_2, length * 0.904, SusHandler::SEND_WRITE); + thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_2, length * 0.905, SusHandler::SEND_WRITE); + thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_3, length * 0.8, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_3, length * 0.91, SusHandler::SEND_WRITE); - thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_3, length * 0.93, SusHandler::SEND_WRITE); - thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_3, length * 0.8, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_3, length * 0.91, SusHandler::SEND_WRITE); + thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_3, length * 0.93, SusHandler::SEND_WRITE); + thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_4, length * 0.909, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_4, length * 0.91, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_4, length * 0.911, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_4, length * 0.909, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_4, length * 0.91, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_4, length * 0.911, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_5, length * 0.912, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_5, length * 0.913, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_5, length * 0.914, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_5, length * 0.912, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_5, length * 0.913, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_5, length * 0.914, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_6, length * 0.915, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::GET_READ); - /* Read ADC conversions from inernal FIFO */ - thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_6, length * 0.915, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::GET_READ); + /* Read ADC conversions from inernal FIFO */ + thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_7, length * 0.918, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::GET_READ); - /* Read ADC conversions from inernal FIFO */ - thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_7, length * 0.918, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::GET_READ); + /* Read ADC conversions from inernal FIFO */ + thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_8, length * 0.921, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::GET_READ); - /* Read ADC conversions from inernal FIFO */ - thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_8, length * 0.921, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::GET_READ); + /* Read ADC conversions from inernal FIFO */ + thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_9, length * 0.924, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::GET_READ); - /* Read ADC conversions */ - thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_9, length * 0.924, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::GET_READ); + /* Read ADC conversions */ + thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_10, length * 0.927, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::GET_READ); - /* Read ADC conversions */ - thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_10, length * 0.927, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::GET_READ); + /* Read ADC conversions */ + thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_11, length * 0.93, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::GET_READ); - /* Read ADC conversions */ - thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_11, length * 0.93, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::GET_READ); + /* Read ADC conversions */ + thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_12, length * 0.933, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::GET_READ); - /* Read ADC conversions */ - thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_12, length * 0.933, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::GET_READ); + /* Read ADC conversions */ + thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_13, length * 0.936, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::GET_READ); - /* Read ADC conversions */ - thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_13, length * 0.936, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::GET_READ); + /* Read ADC conversions */ + thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_RW == 1 - thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RW1, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW1, length * 0.5, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW1, length * 0.65, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW1, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW1, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW1, length * 0.5, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW1, length * 0.65, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW1, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RW2, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW2, length * 0.5, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW2, length * 0.65, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW2, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW2, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW2, length * 0.5, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW2, length * 0.65, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW2, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RW3, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW3, length * 0.5, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW3, length * 0.65, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW3, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW3, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW3, length * 0.5, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW3, length * 0.65, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW3, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RW4, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW4, length * 0.5, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW4, length * 0.65, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW4, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW4, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW4, length * 0.5, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW4, length * 0.65, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW4, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_ACS_BOARD == 1 - bool enableAside = true; - bool enableBside = false; - if(enableAside) { - // A side - thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.25, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.7, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); + bool enableAside = true; + bool enableBside = false; + if (enableAside) { + // A side + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.25, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.7, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.25, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.75, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.25, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.3, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.75, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.3, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.35, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.75, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); - } + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.35, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); + } - if(enableBside) { - // B side - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.2, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.7, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); + if (enableBside) { + // B side + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.7, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.25, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.75, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.25, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.3, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.75, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.3, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.35, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - 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); - } + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.35, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + 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 */ - ReturnValue_t seqCheck = thisSequence->checkSequence(); - if (seqCheck != HasReturnvaluesIF::RETURN_OK) { - if(seqCheck == FixedTimeslotTaskIF::SLOT_LIST_EMPTY) { - sif::warning << "SPI PST is empty.." << std::endl; - } - else { - sif::error << "SPI PST initialization failed" << std::endl; - } - - return seqCheck; + ReturnValue_t seqCheck = thisSequence->checkSequence(); + if (seqCheck != HasReturnvaluesIF::RETURN_OK) { + if (seqCheck == FixedTimeslotTaskIF::SLOT_LIST_EMPTY) { + sif::warning << "SPI PST is empty.." << std::endl; + } else { + sif::error << "SPI PST initialization failed" << std::endl; } - return HasReturnvaluesIF::RETURN_OK; + + return seqCheck; + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t pst::pstI2c(FixedTimeslotTaskIF *thisSequence) { - // Length of a communication cycle - uint32_t length = thisSequence->getPeriodMs(); - thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); - if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "I2C PST initialization failed" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + // Length of a communication cycle + uint32_t length = thisSequence->getPeriodMs(); + thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); + if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "I2C PST initialization failed" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) { - // Length of a communication cycle - uint32_t length = thisSequence->getPeriodMs(); - bool uartPstEmpty = true; + // Length of a communication cycle + uint32_t length = thisSequence->getPeriodMs(); + bool uartPstEmpty = true; #if OBSW_ADD_PLOC_MPSOC == 1 - uartPstEmpty = false; - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.2, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.4, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.6, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.8, - DeviceHandlerIF::GET_READ); + uartPstEmpty = false; + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif - thisSequence->addSlot(objects::PLOC_UPDATER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PLOC_MEMORY_DUMPER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_UPDATER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_MEMORY_DUMPER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); #if OBSW_ADD_PLOC_SUPERVISOR == 1 - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.2, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.4, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.6, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.8, - DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.2, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_SYRLINKS == 1 - uartPstEmpty = false; - thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.2, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.4, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.6, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.8, - DeviceHandlerIF::GET_READ); + uartPstEmpty = false; + thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_STAR_TRACKER == 1 - uartPstEmpty = false; - thisSequence->addSlot(objects::STAR_TRACKER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::STAR_TRACKER, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::STAR_TRACKER, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::STAR_TRACKER, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::STAR_TRACKER, length * 0.8, DeviceHandlerIF::GET_READ); + uartPstEmpty = false; + thisSequence->addSlot(objects::STAR_TRACKER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::STAR_TRACKER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::STAR_TRACKER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::STAR_TRACKER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::STAR_TRACKER, length * 0.8, DeviceHandlerIF::GET_READ); #endif - if(uartPstEmpty) { - return HasReturnvaluesIF::RETURN_OK; - } - if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "UART PST initialization failed" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } + if (uartPstEmpty) { return HasReturnvaluesIF::RETURN_OK; + } + if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "UART PST initialization failed" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t pst::pstGompaceCan(FixedTimeslotTaskIF *thisSequence){ - uint32_t length = thisSequence->getPeriodMs(); +ReturnValue_t pst::pstGompaceCan(FixedTimeslotTaskIF *thisSequence) { + uint32_t length = thisSequence->getPeriodMs(); - // PCDU handlers receives two messages and both must be handled - thisSequence->addSlot(objects::PCDU_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PCDU_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + // PCDU handlers receives two messages and both must be handled + thisSequence->addSlot(objects::PCDU_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PCDU_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::P60DOCK_HANDLER, - length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PDU1_HANDLER, - length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PDU2_HANDLER, - length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::ACU_HANDLER, - length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PDU1_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PDU2_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::ACU_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::P60DOCK_HANDLER, - length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::PDU1_HANDLER, - length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::PDU2_HANDLER, - length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::ACU_HANDLER, - length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::ACU_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::P60DOCK_HANDLER, - length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::PDU1_HANDLER, - length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::PDU2_HANDLER, - length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::ACU_HANDLER, - length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::ACU_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::P60DOCK_HANDLER, - length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::PDU1_HANDLER, - length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::PDU2_HANDLER, - length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::ACU_HANDLER, - length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::ACU_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::P60DOCK_HANDLER, - length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::PDU1_HANDLER, - length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::PDU2_HANDLER, - length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::ACU_HANDLER, - length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::ACU_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); - if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "GomSpace PST initialization failed" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomSpace PST initialization failed" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t pst::pstTest(FixedTimeslotTaskIF* thisSequence) { - /* Length of a communication cycle */ - uint32_t length = thisSequence->getPeriodMs(); - bool notEmpty = false; +ReturnValue_t pst::pstTest(FixedTimeslotTaskIF *thisSequence) { + /* Length of a communication cycle */ + uint32_t length = thisSequence->getPeriodMs(); + bool notEmpty = false; #if RPI_TEST_ADIS16507 == 1 - notEmpty = true; - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); + notEmpty = true; + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if RPI_TEST_GPS_HANDLER == 1 - notEmpty = true; - thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + notEmpty = true; + thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.5, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.5, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.5, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.5, DeviceHandlerIF::GET_READ); #endif - static_cast(length); - if(not notEmpty) { - return HasReturnvaluesIF::RETURN_FAILED; - } - if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Test PST initialization failed" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + static_cast(length); + if (not notEmpty) { + return HasReturnvaluesIF::RETURN_FAILED; + } + if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Test PST initialization failed" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } #if BOARD_TE0720 == 1 ReturnValue_t pst::pollingSequenceTE0720(FixedTimeslotTaskIF *thisSequence) { - uint32_t length = thisSequence->getPeriodMs(); + uint32_t length = thisSequence->getPeriodMs(); #if TEST_PLOC_MPSOC_HANDLER == 1 - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_TEST_RADIATION_SENSOR_HANDLER == 1 - thisSequence->addSlot(objects::RAD_SENSOR, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_TEST_SUS_HANDLER == 1 - /* Write setup */ - thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_1, length * 0.902, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.903, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.904, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_1, length * 0.905, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_1, length * 0.902, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.903, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.904, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_1, length * 0.905, DeviceHandlerIF::GET_READ); - /* Start conversion*/ - thisSequence->addSlot(objects::SUS_1, length * 0.906, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_1, length * 0.907, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.908, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.909, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_1, length * 0.91, DeviceHandlerIF::GET_READ); + /* Start conversion*/ + thisSequence->addSlot(objects::SUS_1, length * 0.906, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_1, length * 0.907, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.908, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.909, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_1, length * 0.91, DeviceHandlerIF::GET_READ); - /* Read conversions */ - thisSequence->addSlot(objects::SUS_1, length * 0.911, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_1, length * 0.912, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.913, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.914, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_1, length * 0.915, DeviceHandlerIF::GET_READ); + /* Read conversions */ + thisSequence->addSlot(objects::SUS_1, length * 0.911, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_1, length * 0.912, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.913, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.914, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_1, length * 0.915, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_PLOC_SUPERVISOR == 1 - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.7, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.2, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.7, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif - thisSequence->addSlot(objects::PLOC_UPDATER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PLOC_MEMORY_DUMPER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_UPDATER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_MEMORY_DUMPER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); - if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Initialization of TE0720 PST failed" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Initialization of TE0720 PST failed" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } #endif /* BOARD_TE0720 == 1 */ diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h index 5bb5ff2a..36b86ba8 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h @@ -32,7 +32,7 @@ class FixedTimeslotTaskIF; namespace pst { /* 0.4 second period init*/ -ReturnValue_t pstGpio(FixedTimeslotTaskIF *thisSequence); +ReturnValue_t pstGpio(FixedTimeslotTaskIF* thisSequence); /** * @brief This function creates the PST for all gomspace devices. @@ -40,7 +40,7 @@ ReturnValue_t pstGpio(FixedTimeslotTaskIF *thisSequence); * Scheduled in a separate PST because the gomspace library uses blocking calls when requesting * data from devices. */ -ReturnValue_t pstGompaceCan(FixedTimeslotTaskIF *thisSequence); +ReturnValue_t pstGompaceCan(FixedTimeslotTaskIF* thisSequence); ReturnValue_t pstUart(FixedTimeslotTaskIF* thisSequence); @@ -62,7 +62,6 @@ ReturnValue_t pstTest(FixedTimeslotTaskIF* thisSequence); ReturnValue_t pollingSequenceTE0720(FixedTimeslotTaskIF* thisSequence); #endif -} - +} // namespace pst #endif /* POLLINGSEQUENCEINIT_H_ */ diff --git a/linux/fsfwconfig/returnvalues/classIds.h b/linux/fsfwconfig/returnvalues/classIds.h index b98801e2..86edb85f 100644 --- a/linux/fsfwconfig/returnvalues/classIds.h +++ b/linux/fsfwconfig/returnvalues/classIds.h @@ -1,8 +1,8 @@ #ifndef FSFWCONFIG_RETURNVALUES_CLASSIDS_H_ #define FSFWCONFIG_RETURNVALUES_CLASSIDS_H_ -#include #include +#include /** * Source IDs starts at 73 for now @@ -11,13 +11,12 @@ */ namespace CLASS_ID { enum { - CLASS_ID_START = COMMON_CLASS_ID_END, - SA_DEPL_HANDLER, //SADPL - SD_CARD_MANAGER, //SDMA - SCRATCH_BUFFER, //SCBU - CLASS_ID_END // [EXPORT] : [END] + CLASS_ID_START = COMMON_CLASS_ID_END, + SA_DEPL_HANDLER, // SADPL + SD_CARD_MANAGER, // SDMA + SCRATCH_BUFFER, // SCBU + CLASS_ID_END // [EXPORT] : [END] }; } - #endif /* FSFWCONFIG_RETURNVALUES_CLASSIDS_H_ */ diff --git a/linux/fsfwconfig/tmtc/pusIds.h b/linux/fsfwconfig/tmtc/pusIds.h index a2dd7575..37503786 100644 --- a/linux/fsfwconfig/tmtc/pusIds.h +++ b/linux/fsfwconfig/tmtc/pusIds.h @@ -2,21 +2,21 @@ #define CONFIG_TMTC_PUSIDS_HPP_ namespace pus { -enum Ids{ - PUS_SERVICE_1 = 1, - PUS_SERVICE_2 = 2, - PUS_SERVICE_3 = 3, - PUS_SERVICE_3_PSB = 3, - PUS_SERVICE_5 = 5, - PUS_SERVICE_6 = 6, - PUS_SERVICE_8 = 8, - PUS_SERVICE_9 = 9, - PUS_SERVICE_17 = 17, - PUS_SERVICE_19 = 19, - PUS_SERVICE_20 = 20, - PUS_SERVICE_23 = 23, - PUS_SERVICE_200 = 200, - PUS_SERVICE_201 = 201, +enum Ids { + PUS_SERVICE_1 = 1, + PUS_SERVICE_2 = 2, + PUS_SERVICE_3 = 3, + PUS_SERVICE_3_PSB = 3, + PUS_SERVICE_5 = 5, + PUS_SERVICE_6 = 6, + PUS_SERVICE_8 = 8, + PUS_SERVICE_9 = 9, + PUS_SERVICE_17 = 17, + PUS_SERVICE_19 = 19, + PUS_SERVICE_20 = 20, + PUS_SERVICE_23 = 23, + PUS_SERVICE_200 = 200, + PUS_SERVICE_201 = 201, }; }; diff --git a/linux/obc/PapbVcInterface.cpp b/linux/obc/PapbVcInterface.cpp index 5bb72066..f144306c 100644 --- a/linux/obc/PapbVcInterface.cpp +++ b/linux/obc/PapbVcInterface.cpp @@ -1,104 +1,98 @@ #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) { -} - -PapbVcInterface::~PapbVcInterface() { -} + gpioId_t papbBusyId, gpioId_t papbEmptyId, uint32_t vcOffset) + : SystemObject(objectId), + gpioComIF(gpioComIF), + papbBusyId(papbBusyId), + papbEmptyId(papbEmptyId), + vcOffset(vcOffset) {} +PapbVcInterface::~PapbVcInterface() {} void PapbVcInterface::setRegisterAddress(uint32_t* ptmeBaseAddress) { - vcBaseReg = ptmeBaseAddress + vcOffset; + vcBaseReg = ptmeBaseAddress + vcOffset; } -ReturnValue_t PapbVcInterface::write(const uint8_t * data, size_t size) { +ReturnValue_t PapbVcInterface::write(const uint8_t* data, size_t size) { + if (pollPapbBusySignal() == RETURN_OK) { + startPacketTransfer(); + } - 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; } + } - 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 937f4280..e7d03a70 100644 --- a/linux/obc/PapbVcInterface.h +++ b/linux/obc/PapbVcInterface.h @@ -1,12 +1,13 @@ #ifndef LINUX_OBC_PAPBVCINTERFACE_H_ #define LINUX_OBC_PAPBVCINTERFACE_H_ -#include "OBSWConfig.h" -#include "linux/obc/VcInterfaceIF.h" #include #include -#include "fsfw/returnvalues/HasReturnvaluesIF.h" + +#include "OBSWConfig.h" #include "fsfw/objectmanager/ObjectManager.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "linux/obc/VcInterfaceIF.h" /** * @brief This class handles the transmission of data to a virtual channel of the PTME IP Core @@ -14,99 +15,96 @@ * * @author J. Meier */ -class PapbVcInterface: public SystemObject, - 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. - * @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). - */ - PapbVcInterface(object_id_t objectId, LinuxLibgpioIF* gpioComIF, gpioId_t papbBusyId, - gpioId_t papbEmptyId, uint32_t vcOffset); - virtual ~PapbVcInterface(); +class PapbVcInterface : public SystemObject, 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. + * @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). + */ + PapbVcInterface(object_id_t objectId, LinuxLibgpioIF* gpioComIF, gpioId_t papbBusyId, + gpioId_t papbEmptyId, uint32_t vcOffset); + virtual ~PapbVcInterface(); - ReturnValue_t write(const uint8_t* data, size_t size) override; + ReturnValue_t write(const uint8_t* data, size_t size) override; - void setRegisterAddress(uint32_t* ptmeBaseAddress) override; + void setRegisterAddress(uint32_t* ptmeBaseAddress) override; -private: + private: + static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_IP_CORE_BRIDGE; - static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_IP_CORE_BRIDGE; + static const ReturnValue_t PAPB_BUSY = MAKE_RETURN_CODE(0xA0); - static const ReturnValue_t PAPB_BUSY = MAKE_RETURN_CODE(0xA0); + /** + * Configuration bits: + * bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00 + * bit[2]: Set this bit to 1 to abort a transfered packet + * bit[3]: Signals to VcInterface the start of a new telemetry packet + */ + static const uint32_t CONFIG_START = 0x8; - /** - * Configuration bits: - * bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00 - * bit[2]: Set this bit to 1 to abort a transfered packet - * bit[3]: Signals to VcInterface the start of a new telemetry packet - */ - static const uint32_t CONFIG_START = 0x8; + /** + * Writing this word to the VcInterface base address signals to the virtual channel interface + * that a complete tm packet has been transferred. + */ + static const uint32_t CONFIG_END = 0x0; - /** - * Writing this word to the VcInterface base address signals to the virtual channel interface - * that a complete tm packet has been transferred. - */ - static const uint32_t CONFIG_END = 0x0; + /** + * Writing to this offset within the memory space of a virtual channel will insert data for + * encoding to the external buffer memory of the PTME IP Core. + * The address offset is 0x400 (= 4 * 256) + */ + static const int DATA_REG_OFFSET = 256; - /** - * Writing to this offset within the memory space of a virtual channel will insert data for - * encoding to the external buffer memory of the PTME IP Core. - * The address offset is 0x400 (= 4 * 256) - */ - static const int DATA_REG_OFFSET = 256; + LinuxLibgpioIF* gpioComIF = nullptr; - LinuxLibgpioIF* gpioComIF = nullptr; + /** Pulled to low when virtual channel not ready to receive data */ + gpioId_t papbBusyId = gpio::NO_GPIO; + /** High when external buffer memory of virtual channel is empty */ + gpioId_t papbEmptyId = gpio::NO_GPIO; - /** Pulled to low when virtual channel not ready to receive data */ - gpioId_t papbBusyId = gpio::NO_GPIO; - /** High when external buffer memory of virtual channel is empty */ - gpioId_t papbEmptyId = gpio::NO_GPIO; + uint32_t* vcBaseReg = nullptr; - uint32_t* vcBaseReg = nullptr; + uint32_t vcOffset = 0; - uint32_t vcOffset = 0; + /** + * @brief This function sends the config byte to the virtual channel of the PTME IP Core + * to initiate a packet transfer. + */ + void startPacketTransfer(); - /** - * @brief This function sends the config byte to the virtual channel of the PTME IP Core - * to initiate a packet transfer. - */ - void startPacketTransfer(); + /** + * @brief This function sends the config byte to the virtual channel interface of the PTME + * IP Core to signal the end of a packet transfer. + */ + void endPacketTransfer(); - /** - * @brief This function sends the config byte to the virtual channel interface of the PTME - * IP Core to signal the end of a packet transfer. - */ - void endPacketTransfer(); + /** + * @brief This function reads the papb busy signal indicating whether the virtual channel + * interface is ready to receive more data or not. PAPB is ready when + * PAPB_Busy_N == '1'. + * + * @return RETURN_OK when ready to receive data else PAPB_BUSY. + */ + ReturnValue_t pollPapbBusySignal(); - /** - * @brief This function reads the papb busy signal indicating whether the virtual channel - * interface is ready to receive more data or not. PAPB is ready when - * PAPB_Busy_N == '1'. - * - * @return RETURN_OK when ready to receive data else PAPB_BUSY. - */ - ReturnValue_t pollPapbBusySignal(); + /** + * @brief This function can be used for debugging to check whether there are packets in + * the packet buffer of the virtual channel or not. + */ + void isVcInterfaceBufferEmpty(); - /** - * @brief This function can be used for debugging to check whether there are packets in - * the packet buffer of the virtual channel or not. - */ - void isVcInterfaceBufferEmpty(); - - /** - * @brief This function sends a complete telemetry transfer frame data field (1105 bytes) - * to the papb interface of the PTME IP Core. Can be used to test the implementation. - */ - ReturnValue_t sendTestFrame(); + /** + * @brief This function sends a complete telemetry transfer frame data field (1105 bytes) + * to the papb interface of the PTME IP Core. Can be used to test the implementation. + */ + ReturnValue_t sendTestFrame(); }; #endif /* LINUX_OBC_PAPBVCINTERFACE_H_ */ diff --git a/linux/obc/PdecConfig.cpp b/linux/obc/PdecConfig.cpp index bb2ffb13..ac762a6c 100644 --- a/linux/obc/PdecConfig.cpp +++ b/linux/obc/PdecConfig.cpp @@ -1,36 +1,33 @@ #include "PdecConfig.h" + #include "fsfw/serviceinterface/ServiceInterface.h" -PdecConfig::PdecConfig() { - initialize(); -} +PdecConfig::PdecConfig() { initialize(); } -PdecConfig::~PdecConfig() { - -} +PdecConfig::~PdecConfig() {} void PdecConfig::initialize() { - uint32_t word = 0; - word |= (VERSION_ID << 30); - word |= (BYPASS_FLAG << 29); - word |= (CONTROL_COMMAND_FLAG << 28); - word |= (RESERVED_FIELD_A << 26); - word |= (SPACECRAFT_ID << 16); - word |= (VIRTUAL_CHANNEL << 10); - word |= (DUMMY_BITS << 8); - word |= POSITIVE_WINDOW; - configWords[0] = word; - word = 0; - word |= (NEGATIVE_WINDOW << 24); - word |= (HIGH_AU_MAP_ID << 16); - word |= (ENABLE_DERANDOMIZER << 8); - configWords[1] = word; + uint32_t word = 0; + word |= (VERSION_ID << 30); + word |= (BYPASS_FLAG << 29); + word |= (CONTROL_COMMAND_FLAG << 28); + word |= (RESERVED_FIELD_A << 26); + word |= (SPACECRAFT_ID << 16); + word |= (VIRTUAL_CHANNEL << 10); + word |= (DUMMY_BITS << 8); + word |= POSITIVE_WINDOW; + configWords[0] = word; + word = 0; + word |= (NEGATIVE_WINDOW << 24); + word |= (HIGH_AU_MAP_ID << 16); + word |= (ENABLE_DERANDOMIZER << 8); + configWords[1] = word; } uint32_t PdecConfig::getConfigWord(uint8_t wordNo) { - if (wordNo >= CONFIG_WORDS_NUM) { - sif::error << "PdecConfig::getConfigWord: Invalid word number" << std::endl; - return 0; - } - return configWords[wordNo]; + if (wordNo >= CONFIG_WORDS_NUM) { + sif::error << "PdecConfig::getConfigWord: Invalid word number" << std::endl; + return 0; + } + return configWords[wordNo]; } diff --git a/linux/obc/PdecConfig.h b/linux/obc/PdecConfig.h index 46cd5097..37dab151 100644 --- a/linux/obc/PdecConfig.h +++ b/linux/obc/PdecConfig.h @@ -1,9 +1,10 @@ #ifndef LINUX_OBC_PDECCONFIG_H_ #define LINUX_OBC_PDECCONFIG_H_ -#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include +#include "fsfw/returnvalues/HasReturnvaluesIF.h" + /** * @brief This class generates the configuration words for the configuration memory of the PDEC * IP Cores. @@ -14,39 +15,38 @@ * @author J. Meier */ class PdecConfig { + public: + PdecConfig(); + virtual ~PdecConfig(); -public: - PdecConfig(); - virtual ~PdecConfig(); + /** + * @brief Returns the configuration word by specifying the position. + */ + uint32_t getConfigWord(uint8_t wordNo); - /** - * @brief Returns the configuration word by specifying the position. - */ - uint32_t getConfigWord(uint8_t wordNo); + private: + // TC transfer frame configuration parameters + static const uint8_t VERSION_ID = 0; + // BD Frames + static const uint8_t BYPASS_FLAG = 1; + static const uint8_t CONTROL_COMMAND_FLAG = 0; -private: - // TC transfer frame configuration parameters - static const uint8_t VERSION_ID = 0; - // BD Frames - static const uint8_t BYPASS_FLAG = 1; - static const uint8_t CONTROL_COMMAND_FLAG = 0; + static const uint8_t VIRTUAL_CHANNEL = 0; + static const uint8_t RESERVED_FIELD_A = 0; + static const uint16_t SPACECRAFT_ID = 0x274; + static const uint16_t DUMMY_BITS = 0; + // Parameters to control the FARM for AD frames + // Set here for future use + static const uint8_t POSITIVE_WINDOW = 10; + static const uint8_t NEGATIVE_WINDOW = 151; + static const uint8_t HIGH_AU_MAP_ID = 0xF; + static const uint8_t ENABLE_DERANDOMIZER = 1; - static const uint8_t VIRTUAL_CHANNEL = 0; - static const uint8_t RESERVED_FIELD_A = 0; - static const uint16_t SPACECRAFT_ID = 0x274; - static const uint16_t DUMMY_BITS = 0; - // Parameters to control the FARM for AD frames - // Set here for future use - static const uint8_t POSITIVE_WINDOW = 10; - static const uint8_t NEGATIVE_WINDOW = 151; - static const uint8_t HIGH_AU_MAP_ID = 0xF; - static const uint8_t ENABLE_DERANDOMIZER = 1; + static const uint8_t CONFIG_WORDS_NUM = 2; - static const uint8_t CONFIG_WORDS_NUM = 2; + uint32_t configWords[CONFIG_WORDS_NUM]; - uint32_t configWords[CONFIG_WORDS_NUM]; - - void initialize(); + void initialize(); }; #endif /* LINUX_OBC_PDECCONFIG_H_ */ diff --git a/linux/obc/PdecHandler.cpp b/linux/obc/PdecHandler.cpp index aa46c23c..a5ee98d6 100644 --- a/linux/obc/PdecHandler.cpp +++ b/linux/obc/PdecHandler.cpp @@ -1,578 +1,568 @@ +#include "PdecHandler.h" + +#include +#include + #include #include -#include -#include - -#include "PdecHandler.h" #include "OBSWConfig.h" +#include "fsfw/ipc/QueueFactory.h" +#include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/tmtcservices/TmTcMessage.h" -#include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/ipc/QueueFactory.h" - PdecHandler::PdecHandler(object_id_t objectId, object_id_t tcDestinationId, - LinuxLibgpioIF* gpioComIF, gpioId_t pdecReset, std::string uioConfigMemory, - std::string uioRamMemory, std::string uioRegisters) : - SystemObject(objectId), tcDestinationId(tcDestinationId), gpioComIF(gpioComIF), pdecReset( - pdecReset), uioConfigMemory(uioConfigMemory), uioRamMemory(uioRamMemory), uioRegisters( - uioRegisters), actionHelper(this, nullptr) { - commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); + LinuxLibgpioIF* gpioComIF, gpioId_t pdecReset, std::string uioConfigMemory, + std::string uioRamMemory, std::string uioRegisters) + : SystemObject(objectId), + tcDestinationId(tcDestinationId), + gpioComIF(gpioComIF), + pdecReset(pdecReset), + uioConfigMemory(uioConfigMemory), + uioRamMemory(uioRamMemory), + uioRegisters(uioRegisters), + actionHelper(this, nullptr) { + commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); } -PdecHandler::~PdecHandler() { -} +PdecHandler::~PdecHandler() {} ReturnValue_t PdecHandler::initialize() { + tcStore = ObjectManager::instance()->get(objects::TC_STORE); + if (tcStore == nullptr) { + sif::error << "PdecHandler::initialize: Invalid TC store" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - tcStore = ObjectManager::instance()->get(objects::TC_STORE); - if (tcStore == nullptr) { - sif::error << "PdecHandler::initialize: Invalid TC store" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + tcDestination = ObjectManager::instance()->get(tcDestinationId); - tcDestination = ObjectManager::instance()->get( - tcDestinationId); + if (tcDestination == nullptr) { + sif::error << "PdecHandler::initialize: Invalid tc destination specified" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - if (tcDestination == nullptr) { - sif::error << "PdecHandler::initialize: Invalid tc destination specified" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = getRegisterAddress(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = getRegisterAddress(); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = getConfigMemoryBaseAddress(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = getConfigMemoryBaseAddress(); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = getRamBaseAddress(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = getRamBaseAddress(); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + writePdecConfig(); - writePdecConfig(); + result = releasePdec(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = releasePdec(); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = actionHelper.initialize(commandQueue); + if (result != RETURN_OK) { + return result; + } - result = actionHelper.initialize(commandQueue); - if (result != RETURN_OK) { - return result; - } - - return RETURN_OK; + return RETURN_OK; } -MessageQueueId_t PdecHandler::getCommandQueue() const { - return commandQueue->getId(); -} +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; - } + 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)); + 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; - } + if (registerBaseAddress == MAP_FAILED) { + sif::error << "PdecHandler::getRegisterAddress: Failed to map uio address" << std::endl; + return RETURN_FAILED; + } - return RETURN_OK; + 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; - } + 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)); + 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; - } + if (memoryBaseAddress == MAP_FAILED) { + sif::error << "PdecHandler::getConfigMemoryBaseAddress: Failed to map uio address" << std::endl; + return RETURN_FAILED; + } - return RETURN_OK; + return RETURN_OK; } ReturnValue_t PdecHandler::getRamBaseAddress() { - int fd = open(uioRamMemory.c_str(), O_RDWR); + int fd = open(uioRamMemory.c_str(), O_RDWR); - ramBaseAddress = static_cast(mmap(NULL, RAM_MAP_SIZE, PROT_WRITE | PROT_READ, - MAP_SHARED, fd, 0)); + 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; + 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() { +void PdecHandler::writePdecConfig() { + PdecConfig pdecConfig; - PdecConfig pdecConfig; + *(memoryBaseAddress + FRAME_HEADER_OFFSET) = pdecConfig.getConfigWord(0); + *(memoryBaseAddress + FRAME_HEADER_OFFSET + 1) = pdecConfig.getConfigWord(1); - *(memoryBaseAddress + FRAME_HEADER_OFFSET)= pdecConfig.getConfigWord(0); - *(memoryBaseAddress + FRAME_HEADER_OFFSET + 1) = pdecConfig.getConfigWord(1); + // Configure all MAP IDs as invalid + for (int idx = 0; idx <= MAX_MAP_ADDR; idx += 4) { + *(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + idx + 1 / 4) = + NO_DESTINATION << 24 | NO_DESTINATION << 16 | NO_DESTINATION << 8 | NO_DESTINATION; + } - // Configure all MAP IDs as invalid - for (int idx = 0; idx <= MAX_MAP_ADDR; idx += 4) { - *(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + idx + 1 / 4) = NO_DESTINATION << 24 - | NO_DESTINATION << 16 | NO_DESTINATION << 8 | NO_DESTINATION; + // All TCs with MAP ID 7 will be routed to the PM module (can then be read from memory) + uint8_t routeToPm = calcMapAddrEntry(PM_BUFFER); + *(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + 1) = + (NO_DESTINATION << 24) | (NO_DESTINATION << 16) | (NO_DESTINATION << 8) | routeToPm; - } - - // All TCs with MAP ID 7 will be routed to the PM module (can then be read from memory) - uint8_t routeToPm = calcMapAddrEntry(PM_BUFFER); - *(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + 1) = (NO_DESTINATION << 24) | (NO_DESTINATION << 16) | (NO_DESTINATION << 8) - | routeToPm; - - // Write map id clock frequencies - for (int idx = 0; idx <= MAX_MAP_ADDR; idx += 4) { - *(memoryBaseAddress + MAP_CLK_FREQ_OFFSET + idx / 4) = MAP_CLK_FREQ << 24 - | MAP_CLK_FREQ << 16 | MAP_CLK_FREQ << 8 | MAP_CLK_FREQ; - - } + // Write map id clock frequencies + for (int idx = 0; idx <= MAX_MAP_ADDR; idx += 4) { + *(memoryBaseAddress + MAP_CLK_FREQ_OFFSET + idx / 4) = + MAP_CLK_FREQ << 24 | MAP_CLK_FREQ << 16 | MAP_CLK_FREQ << 8 | MAP_CLK_FREQ; + } } ReturnValue_t PdecHandler::resetFarStatFlag() { - uint32_t pdecFar = *(registerBaseAddress + PDEC_FAR_OFFSET); - if (pdecFar != FAR_RESET) { - sif::warning << "PdecHandler::resetFarStatFlag: FAR register did not match expected value." - << " Read value: 0x" << std::hex << static_cast(pdecFar) << std::endl; - return RETURN_FAILED; - } + uint32_t pdecFar = *(registerBaseAddress + PDEC_FAR_OFFSET); + if (pdecFar != FAR_RESET) { + sif::warning << "PdecHandler::resetFarStatFlag: FAR register did not match expected value." + << " Read value: 0x" << std::hex << static_cast(pdecFar) + << std::endl; + return RETURN_FAILED; + } #if OBSW_DEBUG_PDEC_HANDLER == 1 - sif::debug << "PdecHandler::resetFarStatFlag: read FAR with value: 0x" << std::hex << pdecFar - << std::endl; + sif::debug << "PdecHandler::resetFarStatFlag: read FAR with value: 0x" << std::hex << pdecFar + << std::endl; #endif /* OBSW_DEBUG_PDEC_HANDLER == 1 */ - return RETURN_OK; + return RETURN_OK; } -ReturnValue_t PdecHandler::releasePdec() { - ReturnValue_t result = RETURN_OK; - result = gpioComIF->pullHigh(pdecReset); - if (result != RETURN_OK) { - sif::error << "PdecHandler::releasePdec: Failed to release PDEC reset signal" << std::endl; - } - return result; +ReturnValue_t PdecHandler::releasePdec() { + ReturnValue_t result = RETURN_OK; + result = gpioComIF->pullHigh(pdecReset); + if (result != RETURN_OK) { + sif::error << "PdecHandler::releasePdec: Failed to release PDEC reset signal" << std::endl; + } + return result; } ReturnValue_t PdecHandler::performOperation(uint8_t operationCode) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + readCommandQueue(); - readCommandQueue(); - - switch(state) { + switch (state) { case State::INIT: - resetFarStatFlag(); - if (result != RETURN_OK) { - // Requires reconfiguration and reinitialization of PDEC - triggerEvent(INVALID_FAR); - state = State::WAIT_FOR_RECOVERY; - return result; - } - state = State::RUNNING; - break; + resetFarStatFlag(); + if (result != RETURN_OK) { + // Requires reconfiguration and reinitialization of PDEC + triggerEvent(INVALID_FAR); + state = State::WAIT_FOR_RECOVERY; + return result; + } + state = State::RUNNING; + break; case State::RUNNING: - if (newTcReceived()) { - handleNewTc(); - } - checkLocks(); - break; + if (newTcReceived()) { + handleNewTc(); + } + checkLocks(); + break; case State::WAIT_FOR_RECOVERY: - break; + break; default: - sif::debug << "PdecHandler::performOperation: Invalid state" << std::endl; - break; - } + sif::debug << "PdecHandler::performOperation: Invalid state" << std::endl; + break; + } - return RETURN_OK; + return RETURN_OK; } void PdecHandler::readCommandQueue(void) { - CommandMessage commandMessage; - ReturnValue_t result = RETURN_FAILED; + CommandMessage commandMessage; + ReturnValue_t result = RETURN_FAILED; - result = commandQueue->receiveMessage(&commandMessage); + result = commandQueue->receiveMessage(&commandMessage); + if (result == RETURN_OK) { + result = actionHelper.handleActionMessage(&commandMessage); if (result == RETURN_OK) { - result = actionHelper.handleActionMessage(&commandMessage); - if (result == RETURN_OK) { - return; - } - CommandMessage reply; - reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND, - commandMessage.getCommand()); - commandQueue->reply(&reply); - return; + return; } + CommandMessage reply; + reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND, commandMessage.getCommand()); + commandQueue->reply(&reply); + return; + } } bool PdecHandler::newTcReceived() { - uint32_t pdecFar = *(registerBaseAddress + PDEC_FAR_OFFSET); + uint32_t pdecFar = *(registerBaseAddress + PDEC_FAR_OFFSET); - if (pdecFar >> STAT_POSITION != NEW_FAR_RECEIVED) { - return false; - } - if (!checkFrameAna(pdecFar)) { - return false; - } - return true; + if (pdecFar >> STAT_POSITION != NEW_FAR_RECEIVED) { + return false; + } + if (!checkFrameAna(pdecFar)) { + return false; + } + return true; } void PdecHandler::checkLocks() { - uint32_t clcw = getClcw(); - if (!(clcw & NO_RF_MASK) && (lastClcw & NO_RF_MASK)) { - // Rf available changed from 0 to 1 - triggerEvent(CARRIER_LOCK); - } - if (!(clcw & NO_BITLOCK_MASK) && (lastClcw & NO_BITLOCK_MASK)) { - // Bit lock changed from 0 to 1 - triggerEvent(BIT_LOCK_PDEC); - } - lastClcw = clcw; + uint32_t clcw = getClcw(); + if (!(clcw & NO_RF_MASK) && (lastClcw & NO_RF_MASK)) { + // Rf available changed from 0 to 1 + triggerEvent(CARRIER_LOCK); + } + if (!(clcw & NO_BITLOCK_MASK) && (lastClcw & NO_BITLOCK_MASK)) { + // Bit lock changed from 0 to 1 + triggerEvent(BIT_LOCK_PDEC); + } + lastClcw = clcw; } bool PdecHandler::checkFrameAna(uint32_t pdecFar) { - bool frameValid = false; - FrameAna_t frameAna = static_cast((pdecFar & FRAME_ANA_MASK) >> FRAME_ANA_POSITION); - switch(frameAna) { - case(FrameAna_t::ABANDONED_CLTU): { - triggerEvent(INVALID_TC_FRAME, ABANDONED_CLTU); - sif::warning << "PdecHandler::checkFrameAna: Abondoned CLTU" << std::endl; - break; + bool frameValid = false; + FrameAna_t frameAna = static_cast((pdecFar & FRAME_ANA_MASK) >> FRAME_ANA_POSITION); + switch (frameAna) { + case (FrameAna_t::ABANDONED_CLTU): { + triggerEvent(INVALID_TC_FRAME, ABANDONED_CLTU); + sif::warning << "PdecHandler::checkFrameAna: Abondoned CLTU" << std::endl; + break; } - case(FrameAna_t::FRAME_DIRTY): { - triggerEvent(INVALID_TC_FRAME, FRAME_DIRTY); - sif::warning << "PdecHandler::checkFrameAna: Frame dirty" << std::endl; - break; + case (FrameAna_t::FRAME_DIRTY): { + triggerEvent(INVALID_TC_FRAME, FRAME_DIRTY); + sif::warning << "PdecHandler::checkFrameAna: Frame dirty" << std::endl; + break; } - case(FrameAna_t::FRAME_ILLEGAL): { - sif::warning << "PdecHandler::checkFrameAna: Frame illegal for one reason" << std::endl; - handleIReason(pdecFar, FRAME_ILLEGAL_ONE_REASON); - break; + case (FrameAna_t::FRAME_ILLEGAL): { + sif::warning << "PdecHandler::checkFrameAna: Frame illegal for one reason" << std::endl; + handleIReason(pdecFar, FRAME_ILLEGAL_ONE_REASON); + break; } - case(FrameAna_t::FRAME_ILLEGAL_MULTI_REASON): { - sif::warning << "PdecHandler::checkFrameAna: Frame illegal for multiple reasons" - << std::endl; - handleIReason(pdecFar, FRAME_ILLEGAL_MULTIPLE_REASONS); - break; + case (FrameAna_t::FRAME_ILLEGAL_MULTI_REASON): { + sif::warning << "PdecHandler::checkFrameAna: Frame illegal for multiple reasons" << std::endl; + handleIReason(pdecFar, FRAME_ILLEGAL_MULTIPLE_REASONS); + break; } - case(FrameAna_t::AD_DISCARDED_LOCKOUT): { - triggerEvent(INVALID_TC_FRAME, AD_DISCARDED_LOCKOUT); - sif::warning << "PdecHandler::checkFrameAna: AD frame discarded because of lockout" - << std::endl; - break; + case (FrameAna_t::AD_DISCARDED_LOCKOUT): { + triggerEvent(INVALID_TC_FRAME, AD_DISCARDED_LOCKOUT); + sif::warning << "PdecHandler::checkFrameAna: AD frame discarded because of lockout" + << std::endl; + break; } - case(FrameAna_t::AD_DISCARDED_WAIT): { - triggerEvent(INVALID_TC_FRAME, AD_DISCARDED_LOCKOUT); - sif::warning << "PdecHandler::checkFrameAna: AD frame discarded because of wait" - << std::endl; - break; + case (FrameAna_t::AD_DISCARDED_WAIT): { + triggerEvent(INVALID_TC_FRAME, AD_DISCARDED_LOCKOUT); + sif::warning << "PdecHandler::checkFrameAna: AD frame discarded because of wait" << std::endl; + break; } - case(FrameAna_t::AD_DISCARDED_NS_VR): { - triggerEvent(INVALID_TC_FRAME, AD_DISCARDED_NS_VS); - sif::warning << "PdecHandler::checkFrameAna: AD frame discarded because N(S) or V(R)" - << std::endl; - break; + case (FrameAna_t::AD_DISCARDED_NS_VR): { + triggerEvent(INVALID_TC_FRAME, AD_DISCARDED_NS_VS); + sif::warning << "PdecHandler::checkFrameAna: AD frame discarded because N(S) or V(R)" + << std::endl; + break; } - case(FrameAna_t::FRAME_ACCEPTED): { + case (FrameAna_t::FRAME_ACCEPTED): { #if OBSW_DEBUG_PDEC_HANDLER == 1 - sif::info << "PdecHandler::checkFrameAna: Accepted TC frame" << std::endl; + sif::info << "PdecHandler::checkFrameAna: Accepted TC frame" << std::endl; #endif - frameValid = true; - break; + frameValid = true; + break; } default: { - sif::debug << "PdecHandler::checkFrameAna: Invalid frame analysis report" << std::endl; - break; + sif::debug << "PdecHandler::checkFrameAna: Invalid frame analysis report" << std::endl; + break; } - } - return frameValid; + } + return frameValid; } void PdecHandler::handleIReason(uint32_t pdecFar, ReturnValue_t parameter1) { - IReason_t ireason = static_cast((pdecFar & IREASON_MASK) >> IREASON_POSITION); - switch(ireason) { - case(IReason_t::NO_REPORT): { - triggerEvent(INVALID_TC_FRAME, parameter1, NO_REPORT); - sif::info << "PdecHandler::handleIReason: No illegal report" << std::endl; - break; + IReason_t ireason = static_cast((pdecFar & IREASON_MASK) >> IREASON_POSITION); + switch (ireason) { + case (IReason_t::NO_REPORT): { + triggerEvent(INVALID_TC_FRAME, parameter1, NO_REPORT); + sif::info << "PdecHandler::handleIReason: No illegal report" << std::endl; + break; } - case(IReason_t::ERROR_VERSION_NUMBER): { - triggerEvent(INVALID_TC_FRAME, parameter1, ERROR_VERSION_NUMBER); - sif::info << "PdecHandler::handleIReason: Error in version number and reserved A and B " + case (IReason_t::ERROR_VERSION_NUMBER): { + triggerEvent(INVALID_TC_FRAME, parameter1, ERROR_VERSION_NUMBER); + sif::info << "PdecHandler::handleIReason: Error in version number and reserved A and B " << "fields" << std::endl; - break; + break; } - case(IReason_t::ILLEGAL_COMBINATION): { - triggerEvent(INVALID_TC_FRAME, parameter1, ILLEGAL_COMBINATION); - sif::info << "PdecHandler::handleIReason: Illegal combination (AC) of bypass and control " + case (IReason_t::ILLEGAL_COMBINATION): { + triggerEvent(INVALID_TC_FRAME, parameter1, ILLEGAL_COMBINATION); + sif::info << "PdecHandler::handleIReason: Illegal combination (AC) of bypass and control " << "command flags" << std::endl; - break; + break; } - case(IReason_t::INVALID_SC_ID): { - triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_SC_ID); - sif::info << "PdecHandler::handleIReason: Invalid spacecraft identifier " << std::endl; - break; + case (IReason_t::INVALID_SC_ID): { + triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_SC_ID); + sif::info << "PdecHandler::handleIReason: Invalid spacecraft identifier " << std::endl; + break; } - case(IReason_t::INVALID_VC_ID_MSB): { - triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_VC_ID_MSB); - sif::info << "PdecHandler::handleIReason: VC identifier bit 0 to 4 did not match " + case (IReason_t::INVALID_VC_ID_MSB): { + triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_VC_ID_MSB); + sif::info << "PdecHandler::handleIReason: VC identifier bit 0 to 4 did not match " << std::endl; - break; + break; } - case(IReason_t::INVALID_VC_ID_LSB): { - triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_VC_ID_LSB); - sif::info << "PdecHandler::handleIReason: VC identifier bit 5 did not match " << std::endl; - break; + case (IReason_t::INVALID_VC_ID_LSB): { + triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_VC_ID_LSB); + sif::info << "PdecHandler::handleIReason: VC identifier bit 5 did not match " << std::endl; + break; } - case(IReason_t::NS_NOT_ZERO): { - triggerEvent(INVALID_TC_FRAME, parameter1, NS_NOT_ZERO); - sif::info << "PdecHandler::handleIReason: N(S) of BC or BD frame not set to all zeros" + case (IReason_t::NS_NOT_ZERO): { + triggerEvent(INVALID_TC_FRAME, parameter1, NS_NOT_ZERO); + sif::info << "PdecHandler::handleIReason: N(S) of BC or BD frame not set to all zeros" << std::endl; - break; + break; } - case(IReason_t::INCORRECT_BC_CC): { - triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_BC_CC); - sif::info << "PdecHandler::handleIReason: Invalid BC control command format" << std::endl; - break; + case (IReason_t::INCORRECT_BC_CC): { + triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_BC_CC); + sif::info << "PdecHandler::handleIReason: Invalid BC control command format" << std::endl; + break; } default: { - sif::info << "PdecHandler::handleIReason: Invalid reason id" << std::endl; - break; - } + sif::info << "PdecHandler::handleIReason: Invalid reason id" << std::endl; + break; } + } } void PdecHandler::handleNewTc() { - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = RETURN_OK; - uint32_t tcLength = 0; - result = readTc(tcLength); - if (result != RETURN_OK) { - return; - } + uint32_t tcLength = 0; + result = readTc(tcLength); + if (result != RETURN_OK) { + return; + } #if OBSW_DEBUG_PDEC_HANDLER == 1 - unsigned int mapId = tcSegment[0] & MAP_ID_MASK; - sif::info << "PdecHandler::handleNewTc: Received TC segment with map ID " << mapId - << std::endl; - printTC(tcLength); + unsigned int mapId = tcSegment[0] & MAP_ID_MASK; + sif::info << "PdecHandler::handleNewTc: Received TC segment with map ID " << mapId << std::endl; + printTC(tcLength); #endif /* OBSW_DEBUG_PDEC_HANDLER */ - store_address_t storeId; - result = tcStore->addData(&storeId, tcSegment + 1, tcLength - 1); - if (result != RETURN_OK) { - sif::warning << "PdecHandler::handleNewTc: Failed to add received space packet to store" - << std::endl; - return; - } - - TmTcMessage message(storeId); - - result = MessageQueueSenderIF::sendMessage(tcDestination->getRequestQueue(), &message); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "PdecHandler::handleNewTc: Failed to send message to TC destination" - << std::endl; - tcStore->deleteData(storeId); - return; - } - + store_address_t storeId; + result = tcStore->addData(&storeId, tcSegment + 1, tcLength - 1); + if (result != RETURN_OK) { + sif::warning << "PdecHandler::handleNewTc: Failed to add received space packet to store" + << std::endl; return; + } + + TmTcMessage message(storeId); + + result = MessageQueueSenderIF::sendMessage(tcDestination->getRequestQueue(), &message); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "PdecHandler::handleNewTc: Failed to send message to TC destination" + << std::endl; + tcStore->deleteData(storeId); + return; + } + + return; } ReturnValue_t PdecHandler::readTc(uint32_t& tcLength) { - uint32_t tcOffset = (*(registerBaseAddress + PDEC_BPTR_OFFSET) - PHYSICAL_RAM_BASE_ADDRESS) / 4; + uint32_t tcOffset = (*(registerBaseAddress + PDEC_BPTR_OFFSET) - PHYSICAL_RAM_BASE_ADDRESS) / 4; #if OBSW_DEBUG_PDEC_HANDLER == 1 - sif::debug << "PdecHandler::readTc: TC offset: 0x" << std::hex << tcOffset << std::endl; + sif::debug << "PdecHandler::readTc: TC offset: 0x" << std::hex << tcOffset << std::endl; #endif /* OBSW_DEBUG_PDEC_HANDLER */ - tcLength = *(registerBaseAddress + PDEC_SLEN_OFFSET); + tcLength = *(registerBaseAddress + PDEC_SLEN_OFFSET); #if OBSW_DEBUG_PDEC_HANDLER == 1 - sif::debug << "PdecHandler::readTc: TC segment length: " << std::dec << tcLength << std::endl; + sif::debug << "PdecHandler::readTc: TC segment length: " << std::dec << tcLength << std::endl; #endif /* OBSW_DEBUG_PDEC_HANDLER */ - if (tcLength > MAX_TC_SEGMENT_SIZE) { - sif::warning << "PdecHandler::handleNewTc: Read invalid TC length from PDEC register" - << std::endl; - return RETURN_FAILED; + if (tcLength > MAX_TC_SEGMENT_SIZE) { + sif::warning << "PdecHandler::handleNewTc: Read invalid TC length from PDEC register" + << std::endl; + return RETURN_FAILED; + } + + uint32_t idx = 0; + uint32_t tcData = 0; + for (idx = 0; idx <= tcLength; idx = idx + 4) { + tcData = *(ramBaseAddress + tcOffset + idx / 4); + if (idx == 0) { + tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); + tcSegment[idx + 1] = static_cast((tcData >> 8) & 0xFF); + tcSegment[idx + 2] = static_cast(tcData & 0xFF); + } else if (tcLength - idx + 1 == 3) { + tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); + tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); + tcSegment[idx + 1] = static_cast((tcData >> 8) & 0xFF); + } else if (tcLength - idx + 1 == 2) { + tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); + tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); + } else if (tcLength - idx + 1 == 1) { + tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); + } else { + tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); + tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); + tcSegment[idx + 1] = static_cast((tcData >> 8) & 0xFF); + tcSegment[idx + 2] = static_cast(tcData & 0xFF); } + } - uint32_t idx = 0; - uint32_t tcData = 0; - for (idx = 0; idx <= tcLength; idx = idx + 4) { - tcData = *(ramBaseAddress + tcOffset + idx / 4); - if (idx == 0) { - tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); - tcSegment[idx + 1] = static_cast((tcData >> 8) & 0xFF); - tcSegment[idx + 2] = static_cast(tcData & 0xFF); - } - else if (tcLength - idx + 1 == 3) { - tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); - tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); - tcSegment[idx + 1] = static_cast((tcData >> 8) & 0xFF); - } - else if (tcLength - idx + 1 == 2) { - tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); - tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); - } - else if (tcLength - idx + 1 == 1) { - tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); - } - else { - tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); - tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); - tcSegment[idx + 1] = static_cast((tcData >> 8) & 0xFF); - tcSegment[idx + 2] = static_cast(tcData & 0xFF); - } - } + // Backend buffer is handled back to PDEC3 + *(registerBaseAddress + PDEC_BFREE_OFFSET) = 0; - // Backend buffer is handled back to PDEC3 - *(registerBaseAddress + PDEC_BFREE_OFFSET) = 0; - - return RETURN_OK; + return RETURN_OK; } void PdecHandler::printTC(uint32_t tcLength) { - std::stringstream tcSegmentStream; - tcSegmentStream << "TC segment data: 0x"; - for (uint32_t idx = 0; idx < tcLength; idx++) { - tcSegmentStream << std::setfill('0') << std::setw(2) << std::hex - << static_cast(tcSegment[idx]); - } - sif::info << tcSegmentStream.str() << std::endl; + std::stringstream tcSegmentStream; + tcSegmentStream << "TC segment data: 0x"; + for (uint32_t idx = 0; idx < tcLength; idx++) { + tcSegmentStream << std::setfill('0') << std::setw(2) << std::hex + << static_cast(tcSegment[idx]); + } + sif::info << tcSegmentStream.str() << std::endl; } uint8_t PdecHandler::calcMapAddrEntry(uint8_t moduleId) { - uint8_t lutEntry = 0; - uint8_t parity = getOddParity(moduleId | (1 << VALID_POSITION)); - lutEntry = (parity << PARITY_POSITION) | (1 << VALID_POSITION) | moduleId; - return lutEntry; + uint8_t lutEntry = 0; + uint8_t parity = getOddParity(moduleId | (1 << VALID_POSITION)); + lutEntry = (parity << PARITY_POSITION) | (1 << VALID_POSITION) | moduleId; + return lutEntry; } uint8_t PdecHandler::getOddParity(uint8_t number) { - uint8_t parityBit = 0; - uint8_t countBits = 0; - for (unsigned int idx = 0; idx < sizeof(number) * 8; idx++) { - countBits += (number >> idx) & 0x1; - } - parityBit = ~(countBits & 0x1) & 0x1; - return parityBit; + uint8_t parityBit = 0; + uint8_t countBits = 0; + for (unsigned int idx = 0; idx < sizeof(number) * 8; idx++) { + countBits += (number >> idx) & 0x1; + } + parityBit = ~(countBits & 0x1) & 0x1; + return parityBit; } -uint32_t PdecHandler::getClcw() { - return *(registerBaseAddress + PDEC_CLCW_OFFSET); -} +uint32_t PdecHandler::getClcw() { return *(registerBaseAddress + PDEC_CLCW_OFFSET); } -uint32_t PdecHandler::getPdecMon() { - return *(registerBaseAddress + PDEC_MON_OFFSET); -} +uint32_t PdecHandler::getPdecMon() { return *(registerBaseAddress + PDEC_MON_OFFSET); } void PdecHandler::printClcw() { - uint32_t clcw = getClcw(); - uint8_t type = static_cast((clcw >> 31) & 0x1); - uint8_t versionNo = static_cast((clcw >> 29) & 0x3); - uint8_t status = static_cast((clcw >> 26) & 0x7); - uint8_t cop = static_cast((clcw >> 24) & 0x3); - uint8_t vcId = static_cast((clcw >> 18) & 0x3F); - uint8_t noRf = static_cast((clcw >> 15) & 0x1); - uint8_t noBitLock = static_cast((clcw >> 14) & 0x1); - uint8_t lockoutFlag = static_cast((clcw >> 13) & 0x1); - uint8_t waitFlag = static_cast((clcw >> 12) & 0x1); - uint8_t retransmitFlag = static_cast((clcw >> 11) & 0x1); - uint8_t farmBcnt = static_cast((clcw >> 9) & 0x3); - // Expected frame sequence number in te next AD frame - uint8_t repValue = static_cast(clcw & 0xFF); - sif::info << std::setw(30) << std::left << "CLCW type: " << std::hex - << "0x" << static_cast(type) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW version no: " << std::hex - << "0x" << static_cast(versionNo) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW status: " << std::hex - << "0x" << static_cast(status) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW COP: " << std::hex - << "0x" << static_cast(cop) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW virtual channel ID: " << std::hex - << "0x" << static_cast(vcId) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW no RF: " << std::hex - << "0x" << static_cast(noRf) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW no bit lock: " << std::hex - << "0x" << static_cast(noBitLock) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW lockout flag: " << std::hex - << "0x" << static_cast(lockoutFlag) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW wait flag: " << std::hex - << "0x" << static_cast(waitFlag) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW retransmit flag: " << std::hex - << "0x" << static_cast(retransmitFlag) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW FARM B count: " << std::hex - << "0x" << static_cast(farmBcnt) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW rep value: " << std::hex - << "0x" << static_cast(repValue) << std::endl; + uint32_t clcw = getClcw(); + uint8_t type = static_cast((clcw >> 31) & 0x1); + uint8_t versionNo = static_cast((clcw >> 29) & 0x3); + uint8_t status = static_cast((clcw >> 26) & 0x7); + uint8_t cop = static_cast((clcw >> 24) & 0x3); + uint8_t vcId = static_cast((clcw >> 18) & 0x3F); + uint8_t noRf = static_cast((clcw >> 15) & 0x1); + uint8_t noBitLock = static_cast((clcw >> 14) & 0x1); + uint8_t lockoutFlag = static_cast((clcw >> 13) & 0x1); + uint8_t waitFlag = static_cast((clcw >> 12) & 0x1); + uint8_t retransmitFlag = static_cast((clcw >> 11) & 0x1); + uint8_t farmBcnt = static_cast((clcw >> 9) & 0x3); + // Expected frame sequence number in te next AD frame + uint8_t repValue = static_cast(clcw & 0xFF); + sif::info << std::setw(30) << std::left << "CLCW type: " << std::hex << "0x" + << static_cast(type) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW version no: " << std::hex << "0x" + << static_cast(versionNo) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW status: " << std::hex << "0x" + << static_cast(status) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW COP: " << std::hex << "0x" + << static_cast(cop) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW virtual channel ID: " << std::hex << "0x" + << static_cast(vcId) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW no RF: " << std::hex << "0x" + << static_cast(noRf) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW no bit lock: " << std::hex << "0x" + << static_cast(noBitLock) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW lockout flag: " << std::hex << "0x" + << static_cast(lockoutFlag) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW wait flag: " << std::hex << "0x" + << static_cast(waitFlag) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW retransmit flag: " << std::hex << "0x" + << static_cast(retransmitFlag) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW FARM B count: " << std::hex << "0x" + << static_cast(farmBcnt) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW rep value: " << std::hex << "0x" + << static_cast(repValue) << std::endl; } void PdecHandler::printPdecMon() { - uint32_t pdecMon = getPdecMon(); - uint32_t tc0ChannelStatus = (pdecMon & TC0_STATUS_MASK) >> TC0_STATUS_POS; - uint32_t tc1ChannelStatus = (pdecMon & TC1_STATUS_MASK) >> TC1_STATUS_POS; - uint32_t tc2ChannelStatus = (pdecMon & TC2_STATUS_MASK) >> TC2_STATUS_POS; - uint32_t tc3ChannelStatus = (pdecMon & TC3_STATUS_MASK) >> TC3_STATUS_POS; - uint32_t tc4ChannelStatus = (pdecMon & TC4_STATUS_MASK) >> TC4_STATUS_POS; - uint32_t tc5ChannelStatus = (pdecMon & TC5_STATUS_MASK) >> TC5_STATUS_POS; - uint32_t lock = (pdecMon & LOCK_MASK) >> LOCK_POS; - sif::info << std::setw(30) << std::left << "TC0 status: " << getMonStatusString(tc0ChannelStatus) << std::endl; - sif::info << std::setw(30) << std::left << "TC1 status: " << getMonStatusString(tc1ChannelStatus) << std::endl; - sif::info << std::setw(30) << std::left << "TC2 status: " << getMonStatusString(tc2ChannelStatus) << std::endl; - sif::info << std::setw(30) << std::left << "TC3 status: " << getMonStatusString(tc3ChannelStatus) << std::endl; - sif::info << std::setw(30) << std::left << "TC4 status: " << getMonStatusString(tc4ChannelStatus) << std::endl; - sif::info << std::setw(30) << std::left << "TC5 status: " << getMonStatusString(tc5ChannelStatus) << std::endl; - sif::info << std::setw(30) << std::left << "Start sequence lock: " << lock << std::endl; + uint32_t pdecMon = getPdecMon(); + uint32_t tc0ChannelStatus = (pdecMon & TC0_STATUS_MASK) >> TC0_STATUS_POS; + uint32_t tc1ChannelStatus = (pdecMon & TC1_STATUS_MASK) >> TC1_STATUS_POS; + uint32_t tc2ChannelStatus = (pdecMon & TC2_STATUS_MASK) >> TC2_STATUS_POS; + uint32_t tc3ChannelStatus = (pdecMon & TC3_STATUS_MASK) >> TC3_STATUS_POS; + uint32_t tc4ChannelStatus = (pdecMon & TC4_STATUS_MASK) >> TC4_STATUS_POS; + uint32_t tc5ChannelStatus = (pdecMon & TC5_STATUS_MASK) >> TC5_STATUS_POS; + uint32_t lock = (pdecMon & LOCK_MASK) >> LOCK_POS; + sif::info << std::setw(30) << std::left << "TC0 status: " << getMonStatusString(tc0ChannelStatus) + << std::endl; + sif::info << std::setw(30) << std::left << "TC1 status: " << getMonStatusString(tc1ChannelStatus) + << std::endl; + sif::info << std::setw(30) << std::left << "TC2 status: " << getMonStatusString(tc2ChannelStatus) + << std::endl; + sif::info << std::setw(30) << std::left << "TC3 status: " << getMonStatusString(tc3ChannelStatus) + << std::endl; + sif::info << std::setw(30) << std::left << "TC4 status: " << getMonStatusString(tc4ChannelStatus) + << std::endl; + sif::info << std::setw(30) << std::left << "TC5 status: " << getMonStatusString(tc5ChannelStatus) + << std::endl; + sif::info << std::setw(30) << std::left << "Start sequence lock: " << lock << std::endl; } std::string PdecHandler::getMonStatusString(uint32_t status) { - switch(status) { - case TC_CHANNEL_INACTIVE: - return std::string("inactive"); - case TC_CHANNEL_ACTIVE: - return std::string("active"); - case TC_CHANNEL_TIMEDOUT: - return std::string("timed out"); - default: - sif::warning << "PdecHandler::getMonStatusString: Invalid status" << std::endl; - return std::string(); - break; - } -} - - -ReturnValue_t PdecHandler::executeAction(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { - switch(actionId) { - case PRINT_CLCW: - printClcw(); - return EXECUTION_FINISHED; - case PRINT_PDEC_MON: - printPdecMon(); - return EXECUTION_FINISHED; + switch (status) { + case TC_CHANNEL_INACTIVE: + return std::string("inactive"); + case TC_CHANNEL_ACTIVE: + return std::string("active"); + case TC_CHANNEL_TIMEDOUT: + return std::string("timed out"); default: - return COMMAND_NOT_IMPLEMENTED; - } + sif::warning << "PdecHandler::getMonStatusString: Invalid status" << std::endl; + return std::string(); + break; + } +} + +ReturnValue_t PdecHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) { + switch (actionId) { + case PRINT_CLCW: + printClcw(); + return EXECUTION_FINISHED; + case PRINT_PDEC_MON: + printPdecMon(); + return EXECUTION_FINISHED; + default: + return COMMAND_NOT_IMPLEMENTED; + } } diff --git a/linux/obc/PdecHandler.h b/linux/obc/PdecHandler.h index 8c8e8d9b..2125800f 100644 --- a/linux/obc/PdecHandler.h +++ b/linux/obc/PdecHandler.h @@ -3,15 +3,15 @@ #include "OBSWConfig.h" #include "PdecConfig.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" -#include "fsfw_hal/common/gpio/gpioDefinitions.h" -#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" -#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" -#include "fsfw/storagemanager/StorageManagerIF.h" -#include "fsfw/objectmanager/SystemObject.h" -#include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw/action/ActionHelper.h" #include "fsfw/action/HasActionsIF.h" +#include "fsfw/objectmanager/SystemObject.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/storagemanager/StorageManagerIF.h" +#include "fsfw/tasks/ExecutableObjectIF.h" +#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" +#include "fsfw_hal/common/gpio/gpioDefinitions.h" +#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" /** * @brief This class controls the PDEC IP Core implemented in the programmable logic of the @@ -35,386 +35,381 @@ class PdecHandler : public SystemObject, public ExecutableObjectIF, public HasReturnvaluesIF, public HasActionsIF { + public: + /** + * @brief Constructor + * @param objectId Object ID of PDEC handler system object + * @param tcDestinationId Object ID of object responsible for processing TCs. + * @param gpioComIF Pointer to GPIO interace responsible for driving GPIOs. + * @param pdecReset GPIO ID of GPIO connected to the reset signal of the PDEC. + * @param uioConfigMemory String of uio device file same mapped to the PDEC memory space + * @param uioregsiters String of uio device file same mapped to the PDEC register space + */ + PdecHandler(object_id_t objectId, object_id_t tcDestinationId, LinuxLibgpioIF* gpioComIF, + gpioId_t pdecReset, std::string uioConfigMemory, std::string uioRamMemory, + std::string uioRegisters); -public: - /** - * @brief Constructor - * @param objectId Object ID of PDEC handler system object - * @param tcDestinationId Object ID of object responsible for processing TCs. - * @param gpioComIF Pointer to GPIO interace responsible for driving GPIOs. - * @param pdecReset GPIO ID of GPIO connected to the reset signal of the PDEC. - * @param uioConfigMemory String of uio device file same mapped to the PDEC memory space - * @param uioregsiters String of uio device file same mapped to the PDEC register space - */ - PdecHandler(object_id_t objectId, object_id_t tcDestinationId, LinuxLibgpioIF* gpioComIF, - gpioId_t pdecReset, std::string uioConfigMemory, std::string uioRamMemory, - std::string uioRegisters); + virtual ~PdecHandler(); - virtual ~PdecHandler(); + ReturnValue_t performOperation(uint8_t operationCode = 0); - ReturnValue_t performOperation(uint8_t operationCode = 0); + ReturnValue_t initialize() override; - ReturnValue_t initialize() override; + MessageQueueId_t getCommandQueue() const; - MessageQueueId_t getCommandQueue() const; + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) override; - ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size) override; + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PDEC_HANDLER; - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PDEC_HANDLER; + //! [EXPORT] : [COMMENT] Frame acceptance report signals an invalid frame + //! P1: The frame analysis information (FrameAna field of PDEC_FAR register) + //! P2: When frame declared illegal this parameter this parameter gives information about the + //! reason (IReason field of the PDEC_FAR register) + static const Event INVALID_TC_FRAME = MAKE_EVENT(1, severity::HIGH); + //! [EXPORT] : [COMMENT] Read invalid FAR from PDEC after startup + static const Event INVALID_FAR = MAKE_EVENT(2, severity::HIGH); + //! [EXPORT] : [COMMENT] Carrier lock detected + static const Event CARRIER_LOCK = MAKE_EVENT(3, severity::INFO); + //! [EXPORT] : [COMMENT] Bit lock detected (data valid) + static const Event BIT_LOCK_PDEC = MAKE_EVENT(4, severity::INFO); - //! [EXPORT] : [COMMENT] Frame acceptance report signals an invalid frame - //! P1: The frame analysis information (FrameAna field of PDEC_FAR register) - //! P2: When frame declared illegal this parameter this parameter gives information about the reason (IReason field of the PDEC_FAR register) - static const Event INVALID_TC_FRAME = MAKE_EVENT(1, severity::HIGH); - //! [EXPORT] : [COMMENT] Read invalid FAR from PDEC after startup - static const Event INVALID_FAR = MAKE_EVENT(2, severity::HIGH); - //! [EXPORT] : [COMMENT] Carrier lock detected - static const Event CARRIER_LOCK = MAKE_EVENT(3, severity::INFO); - //! [EXPORT] : [COMMENT] Bit lock detected (data valid) - static const Event BIT_LOCK_PDEC = MAKE_EVENT(4, severity::INFO); + private: + static const uint8_t INTERFACE_ID = CLASS_ID::PDEC_HANDLER; -private: + static const ReturnValue_t ABANDONED_CLTU = MAKE_RETURN_CODE(0xA0); + static const ReturnValue_t FRAME_DIRTY = MAKE_RETURN_CODE(0xA1); + static const ReturnValue_t FRAME_ILLEGAL_ONE_REASON = MAKE_RETURN_CODE(0xA2); + static const ReturnValue_t FRAME_ILLEGAL_MULTIPLE_REASONS = MAKE_RETURN_CODE(0xA2); + static const ReturnValue_t AD_DISCARDED_LOCKOUT = MAKE_RETURN_CODE(0xA3); + static const ReturnValue_t AD_DISCARDED_WAIT = MAKE_RETURN_CODE(0xA4); + static const ReturnValue_t AD_DISCARDED_NS_VS = MAKE_RETURN_CODE(0xA5); - static const uint8_t INTERFACE_ID = CLASS_ID::PDEC_HANDLER; + //! [EXPORT] : [COMMENT] Received action message with unknown action id + static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xB0); - static const ReturnValue_t ABANDONED_CLTU = MAKE_RETURN_CODE(0xA0); - static const ReturnValue_t FRAME_DIRTY = MAKE_RETURN_CODE(0xA1); - static const ReturnValue_t FRAME_ILLEGAL_ONE_REASON = MAKE_RETURN_CODE(0xA2); - static const ReturnValue_t FRAME_ILLEGAL_MULTIPLE_REASONS = MAKE_RETURN_CODE(0xA2); - static const ReturnValue_t AD_DISCARDED_LOCKOUT = MAKE_RETURN_CODE(0xA3); - static const ReturnValue_t AD_DISCARDED_WAIT = MAKE_RETURN_CODE(0xA4); - static const ReturnValue_t AD_DISCARDED_NS_VS = MAKE_RETURN_CODE(0xA5); + static const ReturnValue_t NO_REPORT = MAKE_RETURN_CODE(0xA6); + //! Error in version number and reserved A and B fields + static const ReturnValue_t ERROR_VERSION_NUMBER = MAKE_RETURN_CODE(0xA7); + //! Illegal combination of bypass and control command flag + static const ReturnValue_t ILLEGAL_COMBINATION = MAKE_RETURN_CODE(0xA8); + //! Spacecraft identifier did not match + static const ReturnValue_t INVALID_SC_ID = MAKE_RETURN_CODE(0xA9); + //! VC identifier bits 0 to 4 did not match + static const ReturnValue_t INVALID_VC_ID_MSB = MAKE_RETURN_CODE(0xAA); + //! VC identifier bit 5 did not match + static const ReturnValue_t INVALID_VC_ID_LSB = MAKE_RETURN_CODE(0xAB); + //! N(S) of BC or BD frame not set to all zeros + static const ReturnValue_t NS_NOT_ZERO = MAKE_RETURN_CODE(0xAC); + //! Invalid BC control command + static const ReturnValue_t INVALID_BC_CC = MAKE_RETURN_CODE(0xAE); - //! [EXPORT] : [COMMENT] Received action message with unknown action id - static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xB0); + static const uint32_t QUEUE_SIZE = common::CCSDS_HANDLER_QUEUE_SIZE; - static const ReturnValue_t NO_REPORT = MAKE_RETURN_CODE(0xA6); - //! Error in version number and reserved A and B fields - static const ReturnValue_t ERROR_VERSION_NUMBER = MAKE_RETURN_CODE(0xA7); - //! Illegal combination of bypass and control command flag - static const ReturnValue_t ILLEGAL_COMBINATION = MAKE_RETURN_CODE(0xA8); - //! Spacecraft identifier did not match - static const ReturnValue_t INVALID_SC_ID = MAKE_RETURN_CODE(0xA9); - //! VC identifier bits 0 to 4 did not match - static const ReturnValue_t INVALID_VC_ID_MSB = MAKE_RETURN_CODE(0xAA); - //! VC identifier bit 5 did not match - static const ReturnValue_t INVALID_VC_ID_LSB = MAKE_RETURN_CODE(0xAB); - //! N(S) of BC or BD frame not set to all zeros - static const ReturnValue_t NS_NOT_ZERO = MAKE_RETURN_CODE(0xAC); - //! Invalid BC control command - static const ReturnValue_t INVALID_BC_CC = MAKE_RETURN_CODE(0xAE); + // Action IDs + static const ActionId_t PRINT_CLCW = 0; + // Print PDEC monitor register + static const ActionId_t PRINT_PDEC_MON = 1; - static const uint32_t QUEUE_SIZE = common::CCSDS_HANDLER_QUEUE_SIZE; + static const uint8_t STAT_POSITION = 31; + static const uint8_t FRAME_ANA_POSITION = 28; + static const uint8_t IREASON_POSITION = 25; - // Action IDs - static const ActionId_t PRINT_CLCW = 0; - // Print PDEC monitor register - static const ActionId_t PRINT_PDEC_MON = 1; + static const uint8_t NEW_FAR_RECEIVED = 0; - static const uint8_t STAT_POSITION = 31; - static const uint8_t FRAME_ANA_POSITION = 28; - static const uint8_t IREASON_POSITION = 25; + static const uint32_t FRAME_ANA_MASK = 0x70000000; + static const uint32_t IREASON_MASK = 0x0E000000; - static const uint8_t NEW_FAR_RECEIVED = 0; + static const uint32_t TC_CHANNEL_INACTIVE = 0x0; + static const uint32_t TC_CHANNEL_ACTIVE = 0x1; + static const uint32_t TC_CHANNEL_TIMEDOUT = 0x2; - static const uint32_t FRAME_ANA_MASK = 0x70000000; - static const uint32_t IREASON_MASK = 0x0E000000; + static const uint32_t TC0_STATUS_MASK = 0x3; + static const uint32_t TC1_STATUS_MASK = 0xC; + static const uint32_t TC2_STATUS_MASK = 0x300; + static const uint32_t TC3_STATUS_MASK = 0xC00; + static const uint32_t TC4_STATUS_MASK = 0x30000; + static const uint32_t TC5_STATUS_MASK = 0xc00000; + // Lock register set to 1 when start sequence has been found (CLTU is beeing processed) + static const uint32_t LOCK_MASK = 0xc00000; - static const uint32_t TC_CHANNEL_INACTIVE = 0x0; - static const uint32_t TC_CHANNEL_ACTIVE = 0x1; - static const uint32_t TC_CHANNEL_TIMEDOUT = 0x2; + static const uint32_t TC0_STATUS_POS = 0; + static const uint32_t TC1_STATUS_POS = 2; + static const uint32_t TC2_STATUS_POS = 4; + static const uint32_t TC3_STATUS_POS = 6; + static const uint32_t TC4_STATUS_POS = 8; + static const uint32_t TC5_STATUS_POS = 10; + // Lock register set to 1 when start sequence has been found (CLTU is beeing processed) + static const uint32_t LOCK_POS = 12; - static const uint32_t TC0_STATUS_MASK = 0x3; - static const uint32_t TC1_STATUS_MASK = 0xC; - static const uint32_t TC2_STATUS_MASK = 0x300; - static const uint32_t TC3_STATUS_MASK = 0xC00; - static const uint32_t TC4_STATUS_MASK = 0x30000; - static const uint32_t TC5_STATUS_MASK = 0xc00000; - // Lock register set to 1 when start sequence has been found (CLTU is beeing processed) - static const uint32_t LOCK_MASK = 0xc00000; - - static const uint32_t TC0_STATUS_POS = 0; - static const uint32_t TC1_STATUS_POS = 2; - static const uint32_t TC2_STATUS_POS = 4; - static const uint32_t TC3_STATUS_POS = 6; - static const uint32_t TC4_STATUS_POS = 8; - static const uint32_t TC5_STATUS_POS = 10; - // Lock register set to 1 when start sequence has been found (CLTU is beeing processed) - static const uint32_t LOCK_POS = 12; - - /** - * UIO is 4 byte aligned. Thus offset is calculated with "true offset" / 4 - * Example: PDEC_FAR = 0x2840 => Offset in virtual address space is 0xA10 - */ - static const uint32_t PDEC_FAR_OFFSET = 0xA10; - static const uint32_t PDEC_CLCW_OFFSET = 0xA12; - static const uint32_t PDEC_BFREE_OFFSET = 0xA24; - static const uint32_t PDEC_BPTR_OFFSET = 0xA25; - static const uint32_t PDEC_SLEN_OFFSET = 0xA26; - static const uint32_t PDEC_MON_OFFSET = 0xA27; + /** + * UIO is 4 byte aligned. Thus offset is calculated with "true offset" / 4 + * Example: PDEC_FAR = 0x2840 => Offset in virtual address space is 0xA10 + */ + static const uint32_t PDEC_FAR_OFFSET = 0xA10; + static const uint32_t PDEC_CLCW_OFFSET = 0xA12; + static const uint32_t PDEC_BFREE_OFFSET = 0xA24; + static const uint32_t PDEC_BPTR_OFFSET = 0xA25; + static const uint32_t PDEC_SLEN_OFFSET = 0xA26; + static const uint32_t PDEC_MON_OFFSET = 0xA27; #if BOARD_TE0720 == 1 - static const int CONFIG_MEMORY_MAP_SIZE = 0x400; - static const int RAM_MAP_SIZE = 0x4000; - static const int REGISTER_MAP_SIZE = 0x10000; + static const int CONFIG_MEMORY_MAP_SIZE = 0x400; + static const int RAM_MAP_SIZE = 0x4000; + static const int REGISTER_MAP_SIZE = 0x10000; #else - static const int CONFIG_MEMORY_MAP_SIZE = 0x400; - static const int RAM_MAP_SIZE = 0x4000; - static const int REGISTER_MAP_SIZE = 0x4000; + static const int CONFIG_MEMORY_MAP_SIZE = 0x400; + static const int RAM_MAP_SIZE = 0x4000; + static const int REGISTER_MAP_SIZE = 0x4000; #endif /* BOARD_TE0720 == 1 */ - // 0x200 / 4 = 0x80 - static const uint32_t FRAME_HEADER_OFFSET = 0x80; + // 0x200 / 4 = 0x80 + static const uint32_t FRAME_HEADER_OFFSET = 0x80; - static const size_t MAX_TC_SEGMENT_SIZE = 1017; - static const uint8_t MAP_ID_MASK = 0x3F; + static const size_t MAX_TC_SEGMENT_SIZE = 1017; + static const uint8_t MAP_ID_MASK = 0x3F; #if BOARD_TE0720 == 1 - static const uint32_t PHYSICAL_RAM_BASE_ADDRESS = 0x32000000; + static const uint32_t PHYSICAL_RAM_BASE_ADDRESS = 0x32000000; #else - static const uint32_t PHYSICAL_RAM_BASE_ADDRESS = 0x26000000; + static const uint32_t PHYSICAL_RAM_BASE_ADDRESS = 0x26000000; #endif - static const uint32_t MAP_ADDR_LUT_OFFSET = 0xA0; - static const uint32_t MAP_CLK_FREQ_OFFSET = 0x90; + static const uint32_t MAP_ADDR_LUT_OFFSET = 0xA0; + static const uint32_t MAP_CLK_FREQ_OFFSET = 0x90; - static const uint8_t MAX_MAP_ADDR = 63; - // Writing this to the map address in the look up table will invalidate a MAP ID. - static const uint8_t NO_DESTINATION = 0; - static const uint8_t VALID_POSITION = 6; - static const uint8_t PARITY_POSITION = 7; + static const uint8_t MAX_MAP_ADDR = 63; + // Writing this to the map address in the look up table will invalidate a MAP ID. + static const uint8_t NO_DESTINATION = 0; + static const uint8_t VALID_POSITION = 6; + static const uint8_t PARITY_POSITION = 7; - // Expected value stored in FAR register after reset - static const uint32_t FAR_RESET = 0x7FE0; + // Expected value stored in FAR register after reset + static const uint32_t FAR_RESET = 0x7FE0; - static const uint32_t TC_SEGMENT_LEN = 1017; + static const uint32_t TC_SEGMENT_LEN = 1017; - static const uint32_t NO_RF_MASK = 0x8000; - static const uint32_t NO_BITLOCK_MASK = 0x4000; + static const uint32_t NO_RF_MASK = 0x8000; + static const uint32_t NO_BITLOCK_MASK = 0x4000; - /** - * TCs with map addresses (also know as Map IDs) assigned to this channel will be stored in - * the PDEC memory. - */ - static const uint8_t PM_BUFFER = 7; + /** + * TCs with map addresses (also know as Map IDs) assigned to this channel will be stored in + * the PDEC memory. + */ + static const uint8_t PM_BUFFER = 7; - // MAP clock frequency. Must be a value between 1 and 13 otherwise the TC segment will be - // discarded - static const uint8_t MAP_CLK_FREQ = 2; + // MAP clock frequency. Must be a value between 1 and 13 otherwise the TC segment will be + // discarded + static const uint8_t MAP_CLK_FREQ = 2; - enum class FrameAna_t: uint8_t { - ABANDONED_CLTU, - FRAME_DIRTY, - FRAME_ILLEGAL, - FRAME_ILLEGAL_MULTI_REASON, - AD_DISCARDED_LOCKOUT, - AD_DISCARDED_WAIT, - AD_DISCARDED_NS_VR, - FRAME_ACCEPTED - }; + enum class FrameAna_t : uint8_t { + ABANDONED_CLTU, + FRAME_DIRTY, + FRAME_ILLEGAL, + FRAME_ILLEGAL_MULTI_REASON, + AD_DISCARDED_LOCKOUT, + AD_DISCARDED_WAIT, + AD_DISCARDED_NS_VR, + FRAME_ACCEPTED + }; - enum class IReason_t: uint8_t { - NO_REPORT, - ERROR_VERSION_NUMBER, - ILLEGAL_COMBINATION, - INVALID_SC_ID, - INVALID_VC_ID_LSB, - INVALID_VC_ID_MSB, - NS_NOT_ZERO, - INCORRECT_BC_CC - }; + enum class IReason_t : uint8_t { + NO_REPORT, + ERROR_VERSION_NUMBER, + ILLEGAL_COMBINATION, + INVALID_SC_ID, + INVALID_VC_ID_LSB, + INVALID_VC_ID_MSB, + NS_NOT_ZERO, + INCORRECT_BC_CC + }; - enum class State: uint8_t { - INIT, - RUNNING, - WAIT_FOR_RECOVERY - }; + enum class State : uint8_t { INIT, RUNNING, WAIT_FOR_RECOVERY }; - /** - * @brief Reads and handles messages stored in the commandQueue - */ - void readCommandQueue(void); + /** + * @brief Reads and handles messages stored in the commandQueue + */ + 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 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 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 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. - */ - void writePdecConfig(); + /** + * @brief This functions writes the configuration parameters to the configuration + * section of the PDEC. + */ + void writePdecConfig(); - /** - * @brief Reading the FAR resets the set stat flag which signals a new TC. Without clearing - * this flag no new TC will be excepted. After start up the flag is set and needs - * to be reset. - * Stat flag 0 - new TC received - * Stat flag 1 - old TC (ready to receive next TC) - */ - ReturnValue_t resetFarStatFlag(); + /** + * @brief Reading the FAR resets the set stat flag which signals a new TC. Without clearing + * this flag no new TC will be excepted. After start up the flag is set and needs + * to be reset. + * Stat flag 0 - new TC received + * Stat flag 1 - old TC (ready to receive next TC) + */ + ReturnValue_t resetFarStatFlag(); - /** - * @brief Releases the PDEC from reset state. PDEC will start with loading the written - * configuration parameters. - */ - ReturnValue_t releasePdec(); + /** + * @brief Releases the PDEC from reset state. PDEC will start with loading the written + * configuration parameters. + */ + ReturnValue_t releasePdec(); - /** - * @brief Reads the FAR register and checks if a new TC has been received. - */ - bool newTcReceived(); + /** + * @brief Reads the FAR register and checks if a new TC has been received. + */ + bool newTcReceived(); - /** - * @brief Checks if carrier lock or bit lock has been detected and triggers appropriate - * event. - */ - void checkLocks(); + /** + * @brief Checks if carrier lock or bit lock has been detected and triggers appropriate + * event. + */ + void checkLocks(); - /** - * @brief Analyzes the FramAna field (frame analysis data) of a FAR report. - * - * @return True if frame valid, otherwise false. - */ - bool checkFrameAna(uint32_t pdecFar); + /** + * @brief Analyzes the FramAna field (frame analysis data) of a FAR report. + * + * @return True if frame valid, otherwise false. + */ + bool checkFrameAna(uint32_t pdecFar); - /** - * @brief This function handles the IReason field of the frame analysis report. - * - * @details In case frame as been declared illegal for multiple reasons, the reason with the - * lowest value will be shown. - */ - void handleIReason(uint32_t pdecFar, ReturnValue_t parameter1); + /** + * @brief This function handles the IReason field of the frame analysis report. + * + * @details In case frame as been declared illegal for multiple reasons, the reason with the + * lowest value will be shown. + */ + void handleIReason(uint32_t pdecFar, ReturnValue_t parameter1); - /** - * @brief Handles the reception of new TCs. Reads the pointer to the storage location of the - * new TC segment, extracts the PUS packet and forwards the data to the object - * responsible for processing the TC. - */ - void handleNewTc(); + /** + * @brief Handles the reception of new TCs. Reads the pointer to the storage location of the + * new TC segment, extracts the PUS packet and forwards the data to the object + * responsible for processing the TC. + */ + void handleNewTc(); - /** - * @brief Function reads the last received TC segment from the PDEC memory and copies - * the data to the tcSegement array. - * - * @param tcLength The length of the received TC. - * - */ - ReturnValue_t readTc(uint32_t& tcLength); + /** + * @brief Function reads the last received TC segment from the PDEC memory and copies + * the data to the tcSegement array. + * + * @param tcLength The length of the received TC. + * + */ + ReturnValue_t readTc(uint32_t& tcLength); - /** - * @brief Prints the tc segment data - */ - void printTC(uint32_t tcLength); + /** + * @brief Prints the tc segment data + */ + void printTC(uint32_t tcLength); - /** - * @brief This function calculates the entry for the configuration of the MAP ID routing. - * - * @param mapAddr The MAP ID to configure - * @param moduleId The destination module where all TCs with the map id mapAddr will be routed - * to. - * - * @details The PDEC has different modules where the TCs can be routed to. A lookup table is - * used which links the MAP ID field to the destination module. The entry for this - * lookup table is created by this function and must be stored in the configuration - * memory region of the PDEC. The entry has a specific format - */ - uint8_t calcMapAddrEntry(uint8_t moduleId); + /** + * @brief This function calculates the entry for the configuration of the MAP ID routing. + * + * @param mapAddr The MAP ID to configure + * @param moduleId The destination module where all TCs with the map id mapAddr will be routed + * to. + * + * @details The PDEC has different modules where the TCs can be routed to. A lookup table is + * used which links the MAP ID field to the destination module. The entry for this + * lookup table is created by this function and must be stored in the configuration + * memory region of the PDEC. The entry has a specific format + */ + uint8_t calcMapAddrEntry(uint8_t moduleId); - /** - * @brief This functions calculates the odd parity of the bits in number. - * - * @param number The number from which to calculate the odd parity. - */ - uint8_t getOddParity(uint8_t number); + /** + * @brief This functions calculates the odd parity of the bits in number. + * + * @param number The number from which to calculate the odd parity. + */ + uint8_t getOddParity(uint8_t number); - /** - * brief Returns the 32-bit wide communication link control word (CLCW) - */ - uint32_t getClcw(); + /** + * brief Returns the 32-bit wide communication link control word (CLCW) + */ + uint32_t getClcw(); - /** - * @brief Returns the PDEC monitor register content - * - */ - uint32_t getPdecMon(); + /** + * @brief Returns the PDEC monitor register content + * + */ + uint32_t getPdecMon(); - /** - * @brief Reads and prints the CLCW. Can be useful for debugging. - */ - void printClcw(); + /** + * @brief Reads and prints the CLCW. Can be useful for debugging. + */ + void printClcw(); - /** - * @brief Prints monitor register information to debug console. - */ - void printPdecMon(); + /** + * @brief Prints monitor register information to debug console. + */ + void printPdecMon(); - std::string getMonStatusString(uint32_t status); + std::string getMonStatusString(uint32_t status); - object_id_t tcDestinationId; + object_id_t tcDestinationId; - AcceptsTelecommandsIF* tcDestination = nullptr; + AcceptsTelecommandsIF* tcDestination = nullptr; - LinuxLibgpioIF* gpioComIF = nullptr; + LinuxLibgpioIF* gpioComIF = nullptr; - /** - * Reset signal is required to hold PDEC in reset state until the configuration has been - * written to the appropriate memory space. - * Can also be used to reboot PDEC in case of erros. - */ - gpioId_t pdecReset = gpio::NO_GPIO; + /** + * Reset signal is required to hold PDEC in reset state until the configuration has been + * written to the appropriate memory space. + * Can also be used to reboot PDEC in case of erros. + */ + gpioId_t pdecReset = gpio::NO_GPIO; - // UIO device file giving access to the PDEC configuration memory section - std::string uioConfigMemory; + // UIO device file giving access to the PDEC configuration memory section + std::string uioConfigMemory; - // UIO device file giving access to the PDEC RAM section - std::string uioRamMemory; + // UIO device file giving access to the PDEC RAM section + std::string uioRamMemory; - // UIO device file giving access to the PDEC register space - std::string uioRegisters; + // UIO device file giving access to the PDEC register space + std::string uioRegisters; - ActionHelper actionHelper; + ActionHelper actionHelper; - StorageManagerIF* tcStore = nullptr; + StorageManagerIF* tcStore = nullptr; - MessageQueueIF* commandQueue = nullptr; + MessageQueueIF* commandQueue = nullptr; - State state = State::INIT; + State state = State::INIT; - /** - * Pointer pointing to base address of the PDEC memory space. - * This address is equivalent with the base address of the section named configuration area in - * the PDEC datasheet. - */ - uint32_t* memoryBaseAddress = nullptr; + /** + * Pointer pointing to base address of the PDEC memory space. + * This address is equivalent with the base address of the section named configuration area in + * the PDEC datasheet. + */ + uint32_t* memoryBaseAddress = nullptr; - uint32_t* ramBaseAddress = nullptr; + uint32_t* ramBaseAddress = nullptr; - // Pointer pointing to base address of register space - uint32_t* registerBaseAddress = nullptr; + // Pointer pointing to base address of register space + uint32_t* registerBaseAddress = nullptr; - uint32_t pdecFar = 0; + uint32_t pdecFar = 0; - uint8_t tcSegment[TC_SEGMENT_LEN]; + uint8_t tcSegment[TC_SEGMENT_LEN]; - // Used to check carrier and bit lock changes (default set to no rf and no bitlock) - uint32_t lastClcw = 0xC000; + // Used to check carrier and bit lock changes (default set to no rf and no bitlock) + uint32_t lastClcw = 0xC000; }; #endif /* LINUX_OBC_PDECHANDLER_H_ */ diff --git a/linux/obc/Ptme.cpp b/linux/obc/Ptme.cpp index 63af5d33..237e66ab 100644 --- a/linux/obc/Ptme.cpp +++ b/linux/obc/Ptme.cpp @@ -1,72 +1,69 @@ -#include #include - #include -#include "fsfw/serviceinterface/ServiceInterface.h" +#include + #include "PtmeConfig.h" +#include "fsfw/serviceinterface/ServiceInterface.h" -Ptme::Ptme(object_id_t objectId): SystemObject(objectId) { -} +Ptme::Ptme(object_id_t objectId) : SystemObject(objectId) {} -Ptme::~Ptme() { -} +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; + } - 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)); - /** - * 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)); + if (ptmeBaseAddress == MAP_FAILED) { + sif::error << "Ptme::initialize: Failed to map uio address" << std::endl; + return RETURN_FAILED; + } - 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->setRegisterAddress(ptmeBaseAddress); + } - VcInterfaceMapIter iter; - for (iter = vcInterfaceMap.begin(); iter != vcInterfaceMap.end(); iter++) { - iter->second->setRegisterAddress(ptmeBaseAddress); - } - - return RETURN_OK; + return RETURN_OK; } -ReturnValue_t Ptme::writeToVc(uint8_t vcId, const uint8_t * data, size_t size) { - ReturnValue_t result = RETURN_OK; - VcInterfaceMapIter vcInterfaceMapIter = vcInterfaceMap.find(vcId); - if (vcInterfaceMapIter == vcInterfaceMap.end()) { - sif::warning << "Ptme::writeToVc: No virtual channel interface found for the virtual " - "channel with id " << static_cast(vcId) << std::endl; - return UNKNOWN_VC_ID; - } - result = vcInterfaceMapIter->second->write(data, size); - return result; +ReturnValue_t Ptme::writeToVc(uint8_t vcId, const uint8_t* data, size_t size) { + ReturnValue_t result = RETURN_OK; + VcInterfaceMapIter vcInterfaceMapIter = vcInterfaceMap.find(vcId); + if (vcInterfaceMapIter == vcInterfaceMap.end()) { + sif::warning << "Ptme::writeToVc: No virtual channel interface found for the virtual " + "channel with id " + << static_cast(vcId) << std::endl; + return UNKNOWN_VC_ID; + } + result = vcInterfaceMapIter->second->write(data, size); + return result; } void Ptme::addVcInterface(VcId_t vcId, VcInterfaceIF* vc) { + if (vcId > common::NUMBER_OF_VIRTUAL_CHANNELS) { + sif::warning << "Ptme::addVcInterface: Invalid virtual channel ID" << std::endl; + return; + } - if (vcId > common::NUMBER_OF_VIRTUAL_CHANNELS) { - sif::warning << "Ptme::addVcInterface: Invalid virtual channel ID" << std::endl; - return; - } + if (vc == nullptr) { + sif::warning << "Ptme::addVcInterface: Invalid virtual channel interface" << std::endl; + return; + } - if (vc == nullptr) { - sif::warning << "Ptme::addVcInterface: Invalid virtual channel interface" << std::endl; - return; - } - - auto status = vcInterfaceMap.emplace(vcId, vc); - if (status.second == false) { - sif::warning << "Ptme::addVcInterface: Failed to add virtual channel interface to " - "virtual channel map" << std::endl; - return; - } + auto status = vcInterfaceMap.emplace(vcId, vc); + if (status.second == false) { + sif::warning << "Ptme::addVcInterface: Failed to add virtual channel interface to " + "virtual channel map" + << std::endl; + return; + } } diff --git a/linux/obc/Ptme.h b/linux/obc/Ptme.h index 5364974f..d85885bc 100644 --- a/linux/obc/Ptme.h +++ b/linux/obc/Ptme.h @@ -1,91 +1,87 @@ #ifndef LINUX_OBC_PTME_H_ #define LINUX_OBC_PTME_H_ -#include "OBSWConfig.h" -#include "linux/obc/PtmeIF.h" -#include "linux/obc/VcInterfaceIF.h" #include #include -#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include #include +#include "OBSWConfig.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "linux/obc/PtmeIF.h" +#include "linux/obc/VcInterfaceIF.h" + /** * @brief This class handles the interfacing to the telemetry (PTME) IP core responsible for the - * encoding of telemetry packets according to the CCSDS standards CCSDS 131.0-B-3 (TM Synchro- - * nization and channel coding) and CCSDS 132.0-B-2 (TM Space Data Link Protocoll). - * The IP cores are implemented on the programmable logic and are accessible through the - * linux UIO driver. + * encoding of telemetry packets according to the CCSDS standards CCSDS 131.0-B-3 (TM + * Synchro- nization and channel coding) and CCSDS 132.0-B-2 (TM Space Data Link Protocoll). The IP + * cores are implemented on the programmable logic and are accessible through the linux UIO driver. */ -class Ptme : public PtmeIF, - public SystemObject, - public HasReturnvaluesIF { -public: +class Ptme : public PtmeIF, public SystemObject, public HasReturnvaluesIF { + public: + using VcId_t = uint8_t; - using VcId_t = uint8_t; + /** + * @brief Constructor + * + * @param objectId + */ + Ptme(object_id_t objectId); + virtual ~Ptme(); - /** - * @brief Constructor - * - * @param objectId - */ - Ptme(object_id_t objectId); - virtual ~Ptme(); + ReturnValue_t initialize() override; + ReturnValue_t writeToVc(uint8_t vcId, const uint8_t* data, size_t size) override; - ReturnValue_t initialize() override; - ReturnValue_t writeToVc(uint8_t vcId, const uint8_t* data, size_t size) override; + /** + * @brief This function adds the reference to a virtual channel interface to the vcInterface + * map. + */ + void addVcInterface(VcId_t vcId, VcInterfaceIF* vc); - /** - * @brief This function adds the reference to a virtual channel interface to the vcInterface - * map. - */ - void addVcInterface(VcId_t vcId, VcInterfaceIF* vc); + private: + static const uint8_t INTERFACE_ID = CLASS_ID::PTME; -private: - - static const uint8_t INTERFACE_ID = CLASS_ID::PTME; - - static const ReturnValue_t UNKNOWN_VC_ID = MAKE_RETURN_CODE(0xA0); + 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; + /** Size of mapped address space */ + static const int MAP_SIZE = 0x40000; #else - /** Size of mapped address space */ - static const int MAP_SIZE = 0x40000; + /** Size of mapped address space */ + static const int MAP_SIZE = 0x40000; #endif /* BOARD_TE0720 == 1 */ - /** - * Configuration bits: - * bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00 - * bit[2]: Set this bit to 1 to abort a transfered packet - * bit[3]: Signals to PTME the start of a new telemetry packet - */ - static const uint32_t PTME_CONFIG_START = 0x8; + /** + * Configuration bits: + * bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00 + * bit[2]: Set this bit to 1 to abort a transfered packet + * bit[3]: Signals to PTME the start of a new telemetry packet + */ + static const uint32_t PTME_CONFIG_START = 0x8; - /** - * Writing this word to the ptme base address signals to the PTME that a complete tm packet has - * been transferred. - */ - static const uint32_t PTME_CONFIG_END = 0x0; + /** + * Writing this word to the ptme base address signals to the PTME that a complete tm packet has + * been transferred. + */ + static const uint32_t PTME_CONFIG_END = 0x0; - /** - * Writing to this offset within the PTME memory space will insert data for encoding to the - * PTME IP core. - * The address offset is 0x400 (= 4 * 256) - */ - static const int PTME_DATA_REG_OFFSET = 256; + /** + * Writing to this offset within the PTME memory space will insert data for encoding to the + * PTME IP core. + * The address offset is 0x400 (= 4 * 256) + */ + static const int PTME_DATA_REG_OFFSET = 256; - /** The file descriptor of the UIO driver */ - int fd = 0; + /** The file descriptor of the UIO driver */ + int fd = 0; - uint32_t* ptmeBaseAddress = nullptr; + uint32_t* ptmeBaseAddress = nullptr; - using VcInterfaceMap = std::unordered_map; - using VcInterfaceMapIter = VcInterfaceMap::iterator; + using VcInterfaceMap = std::unordered_map; + using VcInterfaceMapIter = VcInterfaceMap::iterator; - VcInterfaceMap vcInterfaceMap; + VcInterfaceMap vcInterfaceMap; }; #endif /* LINUX_OBC_PTME_H_ */ diff --git a/linux/obc/PtmeConfig.h b/linux/obc/PtmeConfig.h index 814dfeda..b5b722ac 100644 --- a/linux/obc/PtmeConfig.h +++ b/linux/obc/PtmeConfig.h @@ -1,9 +1,10 @@ #ifndef LINUX_OBC_PTMECONFIG_H_ #define LINUX_OBC_PTMECONFIG_H_ -#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include + #include "OBSWConfig.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" /** * @brief PTME specific configuration parameters derived from FPGA design and device tree. @@ -11,20 +12,20 @@ * @author J. Meier */ namespace PtmeConfig { - /** - * Offset of virtual channels mapped into address space - * 0x10000 = (0x4000 * 4) - */ - static const uint32_t VC0_OFFSETT = 0; - static const uint32_t VC1_OFFSETT = 0x4000; - static const uint32_t VC2_OFFSETT = 0x8000; - static const uint32_t VC3_OFFSETT = 0xC000; +/** + * Offset of virtual channels mapped into address space + * 0x10000 = (0x4000 * 4) + */ +static const uint32_t VC0_OFFSETT = 0; +static const uint32_t VC1_OFFSETT = 0x4000; +static const uint32_t VC2_OFFSETT = 0x8000; +static const uint32_t VC3_OFFSETT = 0xC000; #if BOARD_TE0720 == 0 - static const char UIO_DEVICE_FILE[] = "/dev/uio1"; +static const char UIO_DEVICE_FILE[] = "/dev/uio1"; #else - static const char UIO_DEVICE_FILE[] = "/dev/uio1"; +static const char UIO_DEVICE_FILE[] = "/dev/uio1"; #endif -}; +}; // namespace PtmeConfig #endif /* LINUX_OBC_PTMECONFIG_H_ */ diff --git a/linux/obc/PtmeIF.h b/linux/obc/PtmeIF.h index 53d9498b..7108df05 100644 --- a/linux/obc/PtmeIF.h +++ b/linux/obc/PtmeIF.h @@ -3,7 +3,6 @@ #include "fsfw/returnvalues/HasReturnvaluesIF.h" - /** * @brief Interface class for managing the PTME IP Core implemented in the programmable logic. * @@ -12,17 +11,17 @@ * @author J. Meier */ class PtmeIF { -public: - virtual ~PtmeIF(){}; + public: + virtual ~PtmeIF(){}; - /** - * @brief Implements to function to write to a specific virtual channel. - * - * @param vcId Virtual channel to write to - * @param data Pointer to buffer holding the data to write - * @param size Number of bytes to write - */ - virtual ReturnValue_t writeToVc(uint8_t vcId, const uint8_t* data, size_t size) = 0; + /** + * @brief Implements to function to write to a specific virtual channel. + * + * @param vcId Virtual channel to write to + * @param data Pointer to buffer holding the data to write + * @param size Number of bytes to write + */ + virtual ReturnValue_t writeToVc(uint8_t vcId, const uint8_t* data, size_t size) = 0; }; #endif /* LINUX_OBC_PTMEIF_H_ */ diff --git a/linux/obc/PtmeRateSetter.cpp b/linux/obc/PtmeRateSetter.cpp index 92886623..b5a6ee1c 100644 --- a/linux/obc/PtmeRateSetter.cpp +++ b/linux/obc/PtmeRateSetter.cpp @@ -1,27 +1,25 @@ #include "PtmeRateSetter.h" + #include "fsfw/serviceinterface/ServiceInterface.h" -PtmeRateSetter::PtmeRateSetter(gpioId_t bitrateSel, GpioIF* gpioif) : - bitrateSel(bitrateSel), gpioif(gpioif) { -} +PtmeRateSetter::PtmeRateSetter(gpioId_t bitrateSel, GpioIF* gpioif) + : bitrateSel(bitrateSel), gpioif(gpioif) {} -PtmeRateSetter::~PtmeRateSetter() { -} +PtmeRateSetter::~PtmeRateSetter() {} ReturnValue_t PtmeRateSetter::setRate(BitRates rate) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - switch(rate) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + switch (rate) { case RATE_2000KHZ: - result = gpioif->pullHigh(bitrateSel); - break; + result = gpioif->pullHigh(bitrateSel); + break; case RATE_400KHZ: - result = gpioif->pullLow(bitrateSel); - break; + result = gpioif->pullLow(bitrateSel); + break; default: - sif::debug << "PtmeRateSetter::setRate: Invalid rate" << std::endl; - result = HasReturnvaluesIF::RETURN_FAILED; - break; - } - return result; + sif::debug << "PtmeRateSetter::setRate: Invalid rate" << std::endl; + result = HasReturnvaluesIF::RETURN_FAILED; + break; + } + return result; } - diff --git a/linux/obc/PtmeRateSetter.h b/linux/obc/PtmeRateSetter.h index ece78e91..14dfec4b 100644 --- a/linux/obc/PtmeRateSetter.h +++ b/linux/obc/PtmeRateSetter.h @@ -2,9 +2,9 @@ #define LINUX_OBC_PTMERATESETTER_H_ #include "TxRateSetterIF.h" -#include "fsfw_hal/common/gpio/gpioDefinitions.h" -#include "fsfw_hal/common/gpio/GpioIF.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw_hal/common/gpio/GpioIF.h" +#include "fsfw_hal/common/gpio/gpioDefinitions.h" /** * @brief Class to set the downlink bit rate by using the cadu_rate_switcher implemented in @@ -15,26 +15,24 @@ * * @author J. Meier */ -class PtmeRateSetter: public TxRateSetterIF { -public: +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(); - /** - * @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(); + virtual ReturnValue_t setRate(BitRates rate); - virtual ReturnValue_t setRate(BitRates rate); + private: + gpioId_t bitrateSel = gpio::NO_GPIO; -private: - - gpioId_t bitrateSel = gpio::NO_GPIO; - - GpioIF* gpioif = nullptr; + GpioIF* gpioif = nullptr; }; #endif /* LINUX_OBC_PTMERATESETTER_H_ */ diff --git a/linux/obc/TxRateSetterIF.h b/linux/obc/TxRateSetterIF.h index c07106e4..1eaded33 100644 --- a/linux/obc/TxRateSetterIF.h +++ b/linux/obc/TxRateSetterIF.h @@ -3,10 +3,7 @@ #include "fsfw/returnvalues/HasReturnvaluesIF.h" -enum BitRates : uint32_t { - RATE_2000KHZ, - RATE_400KHZ -}; +enum BitRates : uint32_t { RATE_2000KHZ, RATE_400KHZ }; /** * @brief Abstract class for objects implementing the functionality to switch the @@ -15,11 +12,11 @@ enum BitRates : uint32_t { * @author J. Meier */ class TxRateSetterIF { -public: - TxRateSetterIF() {}; - virtual ~TxRateSetterIF() {}; + public: + TxRateSetterIF(){}; + virtual ~TxRateSetterIF(){}; - virtual ReturnValue_t setRate(BitRates bitRate) = 0; + virtual ReturnValue_t setRate(BitRates bitRate) = 0; }; #endif /* LINUX_OBC_TXRATESETTERIF_H_ */ diff --git a/linux/obc/VcInterfaceIF.h b/linux/obc/VcInterfaceIF.h index 28b8d1f1..0aa95691 100644 --- a/linux/obc/VcInterfaceIF.h +++ b/linux/obc/VcInterfaceIF.h @@ -2,6 +2,7 @@ #define LINUX_OBC_VCINTERFACEIF_H_ #include + #include "fsfw/returnvalues/HasReturnvaluesIF.h" /** @@ -11,19 +12,19 @@ * @author J. Meier */ class VcInterfaceIF { -public: - virtual ~VcInterfaceIF(){}; + public: + virtual ~VcInterfaceIF(){}; - /** - * @brief Implememts the functionality to write data in the virtual channel of the PTME IP - * Core. - * - * @param data Pointer to buffer holding the data to write - * @param size Number of bytes to write - */ - virtual ReturnValue_t write(const uint8_t* data, size_t size) = 0; + /** + * @brief Implememts the functionality to write data in the virtual channel of the PTME IP + * Core. + * + * @param data Pointer to buffer holding the data to write + * @param size Number of bytes to write + */ + virtual ReturnValue_t write(const uint8_t* data, size_t size) = 0; - virtual void setRegisterAddress(uint32_t* ptmeBaseAddress) = 0; + virtual void setRegisterAddress(uint32_t* ptmeBaseAddress) = 0; }; #endif /* LINUX_OBC_VCINTERFACEIF_H_ */ diff --git a/linux/utility/utility.cpp b/linux/utility/utility.cpp index 1d6ec5c0..cd0d47ef 100644 --- a/linux/utility/utility.cpp +++ b/linux/utility/utility.cpp @@ -1,13 +1,14 @@ -#include "OBSWConfig.h" -#include "FSFWConfig.h" #include "utility.h" -#include "fsfw/serviceinterface/ServiceInterface.h" #include +#include "FSFWConfig.h" +#include "OBSWConfig.h" +#include "fsfw/serviceinterface/ServiceInterface.h" + void utility::handleSystemError(int retcode, std::string function) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::warning << function << ": System call failed with code " << retcode << ": " << - strerror(retcode) << std::endl; + sif::warning << function << ": System call failed with code " << retcode << ": " + << strerror(retcode) << std::endl; #endif } diff --git a/linux/utility/utility.h b/linux/utility/utility.h index 3eb17a9b..8f7df04f 100644 --- a/linux/utility/utility.h +++ b/linux/utility/utility.h @@ -1,9 +1,10 @@ #ifndef LINUX_UTILITY_UTILITY_H_ #define LINUX_UTILITY_UTILITY_H_ -#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include +#include "fsfw/returnvalues/HasReturnvaluesIF.h" + namespace utility { void handleSystemError(int retcode, std::string function); diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 538e63f3..cd8c8b22 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1,49 +1,42 @@ #include "ThermalController.h" + #include -ThermalController::ThermalController(object_id_t objectId): - ExtendedControllerBase(objectId, objects::NO_OBJECT), - thermalControllerSet(objectId) { +ThermalController::ThermalController(object_id_t objectId) + : ExtendedControllerBase(objectId, objects::NO_OBJECT), thermalControllerSet(objectId) {} + +ReturnValue_t ThermalController::handleCommandMessage(CommandMessage *message) { + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t ThermalController::handleCommandMessage( - CommandMessage *message) { - return HasReturnvaluesIF::RETURN_OK; -} +void ThermalController::performControlOperation() {} -void ThermalController::performControlOperation() { - -} - -void ThermalController::handleChangedDataset(sid_t sid, - store_address_t storeId) { - if(sid == sid_t(TSensorDefinitions::ObjIds::TEST_HKB_HANDLER, - TSensorDefinitions::THERMAL_SENSOR_SET_ID)) { - sif::info << "Update registered!" << std::endl; - } +void ThermalController::handleChangedDataset(sid_t sid, store_address_t storeId) { + if (sid == sid_t(TSensorDefinitions::ObjIds::TEST_HKB_HANDLER, + TSensorDefinitions::THERMAL_SENSOR_SET_ID)) { + sif::info << "Update registered!" << std::endl; + } } ReturnValue_t ThermalController::initializeAfterTaskCreation() { - ReturnValue_t result = - ExtendedControllerBase::initializeAfterTaskCreation(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "ThermalController::initializeAfterTaskCreation: Base" - << " class initialization failed!" << std::endl; - } - HasLocalDataPoolIF* testHkbHandler = ObjectManager::instance()->get( - TSensorDefinitions::ObjIds::TEST_HKB_HANDLER); - if(testHkbHandler == nullptr) { - sif::warning << "ThermalController::initializeAfterTaskCreation: Test" - << " HKB Handler invalid!" << std::endl; - } - // Test normal notifications without data packet first. - testHkbHandler->getHkManagerHandle()->subscribeForSetUpdateMessages( - TSensorDefinitions::THERMAL_SENSOR_SET_ID, - this->getObjectId(), commandQueue->getId(), false); - return result; + ReturnValue_t result = ExtendedControllerBase::initializeAfterTaskCreation(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "ThermalController::initializeAfterTaskCreation: Base" + << " class initialization failed!" << std::endl; + } + HasLocalDataPoolIF *testHkbHandler = ObjectManager::instance()->get( + TSensorDefinitions::ObjIds::TEST_HKB_HANDLER); + if (testHkbHandler == nullptr) { + sif::warning << "ThermalController::initializeAfterTaskCreation: Test" + << " HKB Handler invalid!" << std::endl; + } + // Test normal notifications without data packet first. + testHkbHandler->getHkManagerHandle()->subscribeForSetUpdateMessages( + TSensorDefinitions::THERMAL_SENSOR_SET_ID, this->getObjectId(), commandQueue->getId(), false); + return result; } -ReturnValue_t ThermalController::checkModeCommand(Mode_t mode, - Submode_t submode, uint32_t *msToReachTheMode) { - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t ThermalController::checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t *msToReachTheMode) { + return HasReturnvaluesIF::RETURN_OK; } diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 67c5b24a..2d76ce8d 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -2,32 +2,30 @@ #define MISSION_CONTROLLER_THERMALCONTROLLER_H_ #include + #include "ctrldefinitions/ThermalCtrlPackets.h" +class ThermalController : public ExtendedControllerBase { + public: + ThermalController(object_id_t objectId); -class ThermalController: public ExtendedControllerBase { -public: - ThermalController(object_id_t objectId); -private: + private: + // TODO: Add stubs for thermal components. Each device / assembly with one + // or multiple redundant sensors will have a thermal component. - // TODO: Add stubs for thermal components. Each device / assembly with one - // or multiple redundant sensors will have a thermal component. + /** ExtendedControllerBase overrides */ + virtual ReturnValue_t handleCommandMessage(CommandMessage *message) override; - /** ExtendedControllerBase overrides */ - virtual ReturnValue_t handleCommandMessage( - CommandMessage *message) override; + virtual void performControlOperation() override; - virtual void performControlOperation() override; + virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t *msToReachTheMode) override; - virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, - uint32_t *msToReachTheMode) override; + ReturnValue_t initializeAfterTaskCreation() override; - ReturnValue_t initializeAfterTaskCreation() override; + void handleChangedDataset(sid_t sid, store_address_t storeId) override; - void handleChangedDataset(sid_t sid, store_address_t storeId) override; - - ThermalCtrl::ThermalControllerTemperatureSet thermalControllerSet; + ThermalCtrl::ThermalControllerTemperatureSet thermalControllerSet; }; - #endif /* MISSION_CONTROLLER_THERMALCONTROLLER_H_ */ diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index 14c8791a..b17812e6 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -1,11 +1,6 @@ #include "GenericFactory.h" #include - -#include -#include -#include "objects/systemObjectList.h" - #include #include #include @@ -13,8 +8,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -23,12 +18,16 @@ #include #include #include +#include +#include + +#include "objects/systemObjectList.h" #if OBSW_ADD_TCPIP_BRIDGE == 1 #if OBSW_USE_TCP_BRIDGE == 0 // UDP server includes -#include "fsfw/osal/common/UdpTmTcBridge.h" #include "fsfw/osal/common/UdpTcPollingTask.h" +#include "fsfw/osal/common/UdpTmTcBridge.h" #else // TCP server includes #include "fsfw/osal/common/TcpTmTcBridge.h" @@ -41,78 +40,69 @@ #endif void ObjectFactory::produceGenericObjects() { - // Framework objects - new EventManager(objects::EVENT_MANAGER); - new HealthTable(objects::HEALTH_TABLE); - new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER); - new TimeStamper(objects::TIME_STAMPER); + // Framework objects + new EventManager(objects::EVENT_MANAGER); + new HealthTable(objects::HEALTH_TABLE); + new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER); + new TimeStamper(objects::TIME_STAMPER); - { - PoolManager::LocalPoolConfig poolCfg = { - {300, 16}, {300, 32}, {200, 64}, {200, 128}, {100, 1024}, {10, 2048} - }; - new PoolManager(objects::TC_STORE, poolCfg); - } + { + PoolManager::LocalPoolConfig poolCfg = {{300, 16}, {300, 32}, {200, 64}, + {200, 128}, {100, 1024}, {10, 2048}}; + new PoolManager(objects::TC_STORE, poolCfg); + } - { - PoolManager::LocalPoolConfig poolCfg = { - {300, 16}, {300, 32}, {100, 64}, {100, 128}, {100, 1024}, {10, 2048} - }; - new PoolManager(objects::TM_STORE, poolCfg); - } + { + PoolManager::LocalPoolConfig poolCfg = {{300, 16}, {300, 32}, {100, 64}, + {100, 128}, {100, 1024}, {10, 2048}}; + new PoolManager(objects::TM_STORE, poolCfg); + } - { - PoolManager::LocalPoolConfig poolCfg = { - { 300, 16 }, { 200, 32 }, { 150, 64 }, - { 150, 128 }, { 100, 256 }, { 50, 512 }, { 50, 1024 }, { 10, 2048 } - }; - new PoolManager(objects::IPC_STORE, poolCfg); - } + { + PoolManager::LocalPoolConfig poolCfg = {{300, 16}, {200, 32}, {150, 64}, {150, 128}, + {100, 256}, {50, 512}, {50, 1024}, {10, 2048}}; + new PoolManager(objects::IPC_STORE, poolCfg); + } - new CCSDSDistributor(apid::EIVE_OBSW, objects::CCSDS_PACKET_DISTRIBUTOR); - new PUSDistributor(apid::EIVE_OBSW, objects::PUS_PACKET_DISTRIBUTOR, - objects::CCSDS_PACKET_DISTRIBUTOR); + new CCSDSDistributor(apid::EIVE_OBSW, objects::CCSDS_PACKET_DISTRIBUTOR); + new PUSDistributor(apid::EIVE_OBSW, objects::PUS_PACKET_DISTRIBUTOR, + objects::CCSDS_PACKET_DISTRIBUTOR); + // Every TM packet goes through this funnel + new TmFunnel(objects::TM_FUNNEL); - // Every TM packet goes through this funnel - new TmFunnel(objects::TM_FUNNEL); - - // PUS service stack - new Service1TelecommandVerification(objects::PUS_SERVICE_1_VERIFICATION, - apid::EIVE_OBSW, pus::PUS_SERVICE_1, objects::TM_FUNNEL, 20); - new Service2DeviceAccess(objects::PUS_SERVICE_2_DEVICE_ACCESS, - apid::EIVE_OBSW, pus::PUS_SERVICE_2, 3, 10); - new Service3Housekeeping(objects::PUS_SERVICE_3_HOUSEKEEPING, - apid::EIVE_OBSW, pus::PUS_SERVICE_3); - new Service5EventReporting(objects::PUS_SERVICE_5_EVENT_REPORTING, - apid::EIVE_OBSW, pus::PUS_SERVICE_5, 50); - new Service8FunctionManagement(objects::PUS_SERVICE_8_FUNCTION_MGMT, - apid::EIVE_OBSW, pus::PUS_SERVICE_8, 3, 60); - new Service9TimeManagement(objects::PUS_SERVICE_9_TIME_MGMT, - apid::EIVE_OBSW, pus::PUS_SERVICE_9); - new Service17Test(objects::PUS_SERVICE_17_TEST, apid::EIVE_OBSW, - pus::PUS_SERVICE_17); - new Service20ParameterManagement(objects::PUS_SERVICE_20_PARAMETERS, apid::EIVE_OBSW, - pus::PUS_SERVICE_20); - new CService200ModeCommanding(objects::PUS_SERVICE_200_MODE_MGMT, - apid::EIVE_OBSW, pus::PUS_SERVICE_200); - + // PUS service stack + new Service1TelecommandVerification(objects::PUS_SERVICE_1_VERIFICATION, apid::EIVE_OBSW, + pus::PUS_SERVICE_1, objects::TM_FUNNEL, 20); + new Service2DeviceAccess(objects::PUS_SERVICE_2_DEVICE_ACCESS, apid::EIVE_OBSW, + pus::PUS_SERVICE_2, 3, 10); + new Service3Housekeeping(objects::PUS_SERVICE_3_HOUSEKEEPING, apid::EIVE_OBSW, + pus::PUS_SERVICE_3); + new Service5EventReporting(objects::PUS_SERVICE_5_EVENT_REPORTING, apid::EIVE_OBSW, + pus::PUS_SERVICE_5, 50); + new Service8FunctionManagement(objects::PUS_SERVICE_8_FUNCTION_MGMT, apid::EIVE_OBSW, + pus::PUS_SERVICE_8, 3, 60); + new Service9TimeManagement(objects::PUS_SERVICE_9_TIME_MGMT, apid::EIVE_OBSW, pus::PUS_SERVICE_9); + new Service17Test(objects::PUS_SERVICE_17_TEST, apid::EIVE_OBSW, pus::PUS_SERVICE_17); + new Service20ParameterManagement(objects::PUS_SERVICE_20_PARAMETERS, apid::EIVE_OBSW, + pus::PUS_SERVICE_20); + new CService200ModeCommanding(objects::PUS_SERVICE_200_MODE_MGMT, apid::EIVE_OBSW, + pus::PUS_SERVICE_200); #if OBSW_ADD_TCPIP_BRIDGE == 1 #if OBSW_USE_TCP_BRIDGE == 0 - auto tmtcBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); - sif::info << "Created UDP server for TMTC commanding with listener port " << - udpBridge->getUdpPort() << std::endl; + auto tmtcBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); + sif::info << "Created UDP server for TMTC commanding with listener port " + << udpBridge->getUdpPort() << std::endl; #else - auto tmtcBridge = new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - auto tcpServer = new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); - // TCP is stream based. Use packet ID as start marker when parsing for space packets - tcpServer->setSpacePacketParsingOptions({common::PUS_PACKET_ID}); - sif::info << "Created TCP server for TMTC commanding with listener port " + auto tmtcBridge = new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + auto tcpServer = new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); + // TCP is stream based. Use packet ID as start marker when parsing for space packets + tcpServer->setSpacePacketParsingOptions({common::PUS_PACKET_ID}); + sif::info << "Created TCP server for TMTC commanding with listener port " << tcpServer->getTcpPort() << std::endl; #endif /* OBSW_USE_TMTC_TCP_BRIDGE == 0 */ - tmtcBridge->setMaxNumberOfPacketsStored(70); + tmtcBridge->setMaxNumberOfPacketsStored(70); #endif /* OBSW_ADD_TCPIP_BRIDGE == 1 */ - } diff --git a/mission/core/GenericFactory.h b/mission/core/GenericFactory.h index c96c7818..1a3b1300 100644 --- a/mission/core/GenericFactory.h +++ b/mission/core/GenericFactory.h @@ -5,8 +5,6 @@ namespace ObjectFactory { void produceGenericObjects(); - } - #endif /* MISSION_CORE_GENERICFACTORY_H_ */ diff --git a/mission/devices/ACUHandler.cpp b/mission/devices/ACUHandler.cpp index 955b1703..239a0c7a 100644 --- a/mission/devices/ACUHandler.cpp +++ b/mission/devices/ACUHandler.cpp @@ -1,308 +1,309 @@ #include "ACUHandler.h" + #include "OBSWConfig.h" -ACUHandler::ACUHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - GomspaceDeviceHandler(objectId, comIF, comCookie, ACU::MAX_CONFIGTABLE_ADDRESS, - ACU::MAX_HKTABLE_ADDRESS, ACU::HK_TABLE_REPLY_SIZE, &acuHkTableDataset), acuHkTableDataset( - this) { -} +ACUHandler::ACUHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie) + : GomspaceDeviceHandler(objectId, comIF, comCookie, ACU::MAX_CONFIGTABLE_ADDRESS, + ACU::MAX_HKTABLE_ADDRESS, ACU::HK_TABLE_REPLY_SIZE, &acuHkTableDataset), + acuHkTableDataset(this) {} -ACUHandler::~ACUHandler() { -} +ACUHandler::~ACUHandler() {} -ReturnValue_t ACUHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - *id = GOMSPACE::REQUEST_HK_TABLE; - return buildCommandFromCommand(*id, NULL, 0); +ReturnValue_t ACUHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + *id = GOMSPACE::REQUEST_HK_TABLE; + return buildCommandFromCommand(*id, NULL, 0); } void ACUHandler::fillCommandAndReplyMap() { - GomspaceDeviceHandler::fillCommandAndReplyMap(); - this->insertInCommandMap(PRINT_CHANNEL_STATS); + GomspaceDeviceHandler::fillCommandAndReplyMap(); + this->insertInCommandMap(PRINT_CHANNEL_STATS); } void ACUHandler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) { - - parseHkTableReply(packet); - handleDeviceTM(&acuHkTableDataset, id, true); + parseHkTableReply(packet); + handleDeviceTM(&acuHkTableDataset, id, true); #if OBSW_ENHANCED_PRINTOUT == 1 && OBSW_DEBUG_ACU == 1 - acuHkTableDataset.read(); - float temperatureC_1 = acuHkTableDataset.temperature1.value * 0.1; - float temperatureC_2 = acuHkTableDataset.temperature2.value * 0.1; - float temperatureC_3 = acuHkTableDataset.temperature3.value * 0.1; - sif::info << "ACU: Temperature 1: " << temperatureC_1 << " °C" << std::endl; - sif::info << "ACU: Temperature 2: " << temperatureC_2 << " °C" << std::endl; - sif::info << "ACU: Temperature 3: " << temperatureC_3 << " °C" << std::endl; - sif::info << "ACU: Ground Watchdog Timer Count: " - << acuHkTableDataset.wdtCntGnd.value << std::endl; - sif::info << "ACU: Ground watchdog timer, seconds left before reboot: " - << acuHkTableDataset.wdtGndLeft.value << std::endl; - acuHkTableDataset.commit(); + acuHkTableDataset.read(); + float temperatureC_1 = acuHkTableDataset.temperature1.value * 0.1; + float temperatureC_2 = acuHkTableDataset.temperature2.value * 0.1; + float temperatureC_3 = acuHkTableDataset.temperature3.value * 0.1; + sif::info << "ACU: Temperature 1: " << temperatureC_1 << " °C" << std::endl; + sif::info << "ACU: Temperature 2: " << temperatureC_2 << " °C" << std::endl; + sif::info << "ACU: Temperature 3: " << temperatureC_3 << " °C" << std::endl; + sif::info << "ACU: Ground Watchdog Timer Count: " << acuHkTableDataset.wdtCntGnd.value + << std::endl; + sif::info << "ACU: Ground watchdog timer, seconds left before reboot: " + << acuHkTableDataset.wdtGndLeft.value << std::endl; + acuHkTableDataset.commit(); #endif } void ACUHandler::parseHkTableReply(const uint8_t *packet) { - uint16_t dataOffset = 0; - acuHkTableDataset.read(); - dataOffset += 12; - acuHkTableDataset.currentInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.currentInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.currentInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.currentInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.currentInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.currentInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + uint16_t dataOffset = 0; + acuHkTableDataset.read(); + dataOffset += 12; + acuHkTableDataset.currentInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.currentInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.currentInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.currentInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.currentInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.currentInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.voltageInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.voltageInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.voltageInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.voltageInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.voltageInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.voltageInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + acuHkTableDataset.voltageInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.voltageInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.voltageInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.voltageInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.voltageInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.voltageInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + acuHkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.temperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.temperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.temperature3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + acuHkTableDataset.temperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.temperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.temperature3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.mpptMode = *(packet + dataOffset); - dataOffset += 3; + acuHkTableDataset.mpptMode = *(packet + dataOffset); + dataOffset += 3; - acuHkTableDataset.vboostInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.vboostInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.vboostInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.vboostInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.vboostInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.vboostInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + acuHkTableDataset.vboostInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.vboostInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.vboostInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.vboostInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.vboostInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.vboostInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.powerInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.powerInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.powerInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.powerInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.powerInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.powerInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + acuHkTableDataset.powerInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.powerInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.powerInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.powerInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.powerInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.powerInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.dac0Enable = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.dac1Enable = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.dac2Enable = *(packet + dataOffset); - dataOffset += 3; + acuHkTableDataset.dac0Enable = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.dac1Enable = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.dac2Enable = *(packet + dataOffset); + dataOffset += 3; - acuHkTableDataset.dacRawChannelVal0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.dacRawChannelVal1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.dacRawChannelVal2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.dacRawChannelVal3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.dacRawChannelVal4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.dacRawChannelVal5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + acuHkTableDataset.dacRawChannelVal0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.dacRawChannelVal1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.dacRawChannelVal2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.dacRawChannelVal3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.dacRawChannelVal4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.dacRawChannelVal5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.bootCause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - acuHkTableDataset.bootcnt = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - acuHkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - acuHkTableDataset.resetCause = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.mpptTime = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - /* +12 because here starts the second csp packet */ - dataOffset += 2 + 12; + acuHkTableDataset.bootCause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + acuHkTableDataset.bootcnt = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + acuHkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + acuHkTableDataset.resetCause = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.mpptTime = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + /* +12 because here starts the second csp packet */ + dataOffset += 2 + 12; - acuHkTableDataset.mpptPeriod = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + acuHkTableDataset.mpptPeriod = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.device0 = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device1 = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device2 = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device3 = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device4 = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device5 = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device6 = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device7 = *(packet + dataOffset); - dataOffset += 3; + acuHkTableDataset.device0 = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device1 = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device2 = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device3 = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device4 = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device5 = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device6 = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device7 = *(packet + dataOffset); + dataOffset += 3; - acuHkTableDataset.device0Status = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device1Status = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device2Status = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device3Status = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device4Status = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device5Status = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device6Status = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device7Status = *(packet + dataOffset); - dataOffset += 3; + acuHkTableDataset.device0Status = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device1Status = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device2Status = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device3Status = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device4Status = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device5Status = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device6Status = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device7Status = *(packet + dataOffset); + dataOffset += 3; - acuHkTableDataset.wdtCntGnd = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - acuHkTableDataset.wdtGndLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; + acuHkTableDataset.wdtCntGnd = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + acuHkTableDataset.wdtGndLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; - acuHkTableDataset.commit(); + acuHkTableDataset.commit(); } -ReturnValue_t ACUHandler::initializeLocalDataPool( - localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { +ReturnValue_t ACUHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL5, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL5, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL5, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL5, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VBAT, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VBAT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_TEMPERATURE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_TEMPERATURE_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_TEMPERATURE_3, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_TEMPERATURE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_TEMPERATURE_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_TEMPERATURE_3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_MPPT_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_MPPT_MODE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL5, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL5, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL5, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL5, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_DAC_EN_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DAC_EN_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DAC_EN_2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_DAC_EN_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DAC_EN_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DAC_EN_2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_DAC_RAW_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DAC_RAW_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DAC_RAW_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DAC_RAW_3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DAC_RAW_4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DAC_RAW_5, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_DAC_RAW_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DAC_RAW_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DAC_RAW_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DAC_RAW_3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DAC_RAW_4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DAC_RAW_5, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_BOOTCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_BOOTCNT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_RESET_CAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_MPPT_TIME, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_MPPT_PERIOD, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_BOOTCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_BOOTCNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_UPTIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_RESET_CAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_MPPT_TIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_MPPT_PERIOD, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_DEVICE_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_5, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_7, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_DEVICE_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_DEVICE_0_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_1_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_2_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_3_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_4_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_5_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_6_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_7_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_DEVICE_0_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_1_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_2_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_3_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_4_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_5_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_6_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_7_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_WDT_CNT_GND, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_WDT_GND_LEFT, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_WDT_CNT_GND, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_WDT_GND_LEFT, new PoolEntry( { 0 })); - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t ACUHandler::deviceSpecificCommand(DeviceCommandId_t cmd) { - switch(cmd) { + switch (cmd) { case PRINT_CHANNEL_STATS: { - printChannelStats(); - return RETURN_OK; + printChannelStats(); + return RETURN_OK; } default: { - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } + } } void ACUHandler::printChannelStats() { - PoolReadGuard pg(&acuHkTableDataset); - sif::info << "ACU Info: Current [mA], Voltage [mV]" << std::endl; - sif::info << std::setw(8) << std::left << "Ch0" << std::dec << "| " << - static_cast(acuHkTableDataset.currentInChannel0.value) << - std::setw(15) << std::right << acuHkTableDataset.voltageInChannel0.value << std::endl; - sif::info << std::setw(8) << std::left << "Ch1" << std::dec << "| " << - static_cast(acuHkTableDataset.currentInChannel1.value) << - std::setw(15) << std::right << acuHkTableDataset.voltageInChannel1.value << std::endl; - sif::info << std::setw(8) << std::left << "Ch2" << std::dec << "| " << - static_cast(acuHkTableDataset.currentInChannel2.value) << - std::setw(15) << std::right << acuHkTableDataset.voltageInChannel2.value << std::endl; - sif::info << std::setw(8) << std::left << "Ch3" << std::dec << "| " << - static_cast(acuHkTableDataset.currentInChannel3.value) << - std::setw(15) << std::right << acuHkTableDataset.voltageInChannel3.value << std::endl; - sif::info << std::setw(8) << std::left << "Ch4" << std::dec << "| " << - static_cast(acuHkTableDataset.currentInChannel4.value) << - std::setw(15) << std::right << acuHkTableDataset.voltageInChannel4.value << std::endl; - sif::info << std::setw(8) << std::left << "Ch5" << std::dec << "| " << - static_cast(acuHkTableDataset.currentInChannel5.value) << - std::setw(15) << std::right << acuHkTableDataset.voltageInChannel5.value << std::endl; + PoolReadGuard pg(&acuHkTableDataset); + sif::info << "ACU Info: Current [mA], Voltage [mV]" << std::endl; + sif::info << std::setw(8) << std::left << "Ch0" << std::dec << "| " + << static_cast(acuHkTableDataset.currentInChannel0.value) << std::setw(15) + << std::right << acuHkTableDataset.voltageInChannel0.value << std::endl; + sif::info << std::setw(8) << std::left << "Ch1" << std::dec << "| " + << static_cast(acuHkTableDataset.currentInChannel1.value) << std::setw(15) + << std::right << acuHkTableDataset.voltageInChannel1.value << std::endl; + sif::info << std::setw(8) << std::left << "Ch2" << std::dec << "| " + << static_cast(acuHkTableDataset.currentInChannel2.value) << std::setw(15) + << std::right << acuHkTableDataset.voltageInChannel2.value << std::endl; + sif::info << std::setw(8) << std::left << "Ch3" << std::dec << "| " + << static_cast(acuHkTableDataset.currentInChannel3.value) << std::setw(15) + << std::right << acuHkTableDataset.voltageInChannel3.value << std::endl; + sif::info << std::setw(8) << std::left << "Ch4" << std::dec << "| " + << static_cast(acuHkTableDataset.currentInChannel4.value) << std::setw(15) + << std::right << acuHkTableDataset.voltageInChannel4.value << std::endl; + sif::info << std::setw(8) << std::left << "Ch5" << std::dec << "| " + << static_cast(acuHkTableDataset.currentInChannel5.value) << std::setw(15) + << std::right << acuHkTableDataset.voltageInChannel5.value << std::endl; } diff --git a/mission/devices/ACUHandler.h b/mission/devices/ACUHandler.h index 2bb688e7..0d93c5fe 100644 --- a/mission/devices/ACUHandler.h +++ b/mission/devices/ACUHandler.h @@ -1,51 +1,50 @@ #ifndef MISSION_DEVICES_ACUHANDLER_H_ #define MISSION_DEVICES_ACUHANDLER_H_ -#include "GomspaceDeviceHandler.h" #include + +#include "GomspaceDeviceHandler.h" #include "fsfw/datapool/PoolReadGuard.h" /** * @brief Handler for the ACU from Gomspace. Monitors and controls the battery charging via * the solar panels. */ -class ACUHandler: public GomspaceDeviceHandler { -public: - ACUHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); - virtual ~ACUHandler(); +class ACUHandler : public GomspaceDeviceHandler { + public: + ACUHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + virtual ~ACUHandler(); - virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; + virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; -protected: + protected: + virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t* packet) override; - virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) override; + /** + * @brief As soon as the device is in MODE_NORMAL, this function is executed periodically. + */ + virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override; - /** - * @brief As soon as the device is in MODE_NORMAL, this function is executed periodically. - */ - virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; + virtual void fillCommandAndReplyMap() override; - virtual void fillCommandAndReplyMap() override; + virtual ReturnValue_t deviceSpecificCommand(DeviceCommandId_t cmd) override; - virtual ReturnValue_t deviceSpecificCommand(DeviceCommandId_t cmd) override; + private: + static const DeviceCommandId_t PRINT_CHANNEL_STATS = 51; -private: + ACU::HkTableDataset acuHkTableDataset; - static const DeviceCommandId_t PRINT_CHANNEL_STATS = 51; + /** + * @brief Function extracts the hk table information from the received csp packet and stores + * the values in the acuHkTableDataset. + */ + void parseHkTableReply(const uint8_t* packet); - ACU::HkTableDataset acuHkTableDataset; - - /** - * @brief Function extracts the hk table information from the received csp packet and stores - * the values in the acuHkTableDataset. - */ - void parseHkTableReply(const uint8_t *packet); - - /** - * @brief Prints channel statistics (current and voltage) to console - */ - void printChannelStats(); + /** + * @brief Prints channel statistics (current and voltage) to console + */ + void printChannelStats(); }; #endif /* MISSION_DEVICES_ACUHANDLER_H_ */ diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index a0036867..d49b9db4 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -1,6 +1,6 @@ #include "GPSHyperionHandler.h" -#include "devicedefinitions/GPSDefinitions.h" +#include "devicedefinitions/GPSDefinitions.h" #include "fsfw/datapool/PoolReadGuard.h" #include "fsfw/timemanager/Clock.h" @@ -17,165 +17,160 @@ #endif GPSHyperionHandler::GPSHyperionHandler(object_id_t objectId, object_id_t parentId, - bool debugHyperionGps): - ExtendedControllerBase(objectId, objects::NO_OBJECT), gpsSet(this), - debugHyperionGps(debugHyperionGps) { -} + bool debugHyperionGps) + : ExtendedControllerBase(objectId, objects::NO_OBJECT), + gpsSet(this), + debugHyperionGps(debugHyperionGps) {} GPSHyperionHandler::~GPSHyperionHandler() {} void GPSHyperionHandler::performControlOperation() { #ifdef FSFW_OSAL_LINUX - readGpsDataFromGpsd(); + readGpsDataFromGpsd(); #endif } -LocalPoolDataSetBase* GPSHyperionHandler::getDataSetHandle(sid_t sid) { - return nullptr; -} +LocalPoolDataSetBase *GPSHyperionHandler::getDataSetHandle(sid_t sid) { return nullptr; } ReturnValue_t GPSHyperionHandler::checkModeCommand(Mode_t mode, Submode_t submode, - uint32_t *msToReachTheMode) { - return HasReturnvaluesIF::RETURN_OK; + uint32_t *msToReachTheMode) { + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t GPSHyperionHandler::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; + 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; + } + return HasReturnvaluesIF::RETURN_OK; } -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::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::FIX_MODE, new PoolEntry()); - poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), true, 2.0, false); - return HasReturnvaluesIF::RETURN_OK; +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::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::FIX_MODE, new PoolEntry()); + poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), true, 2.0, false); + return HasReturnvaluesIF::RETURN_OK; } -void GPSHyperionHandler::setResetPinTriggerFunction(gpioResetFunction_t resetCallback, - void *args) { - this->resetCallback = resetCallback; - resetCallbackArgs = args; +void GPSHyperionHandler::setResetPinTriggerFunction(gpioResetFunction_t resetCallback, void *args) { + this->resetCallback = resetCallback; + resetCallbackArgs = args; } - ReturnValue_t GPSHyperionHandler::initialize() { - ReturnValue_t result = ExtendedControllerBase::initialize(); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + ReturnValue_t result = ExtendedControllerBase::initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { return result; + } + return result; } ReturnValue_t GPSHyperionHandler::handleCommandMessage(CommandMessage *message) { - return ExtendedControllerBase::handleCommandMessage(message); + return ExtendedControllerBase::handleCommandMessage(message); } #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 - gpsmm gpsmm(GPSD_SHARED_MEMORY, 0); - gps_data_t* gps; - gps = gpsmm.read(); - if(gps == nullptr) { - sif::warning << "Q7STestTask: Reading GPS data failed" << std::endl; - } - PoolReadGuard pg(&gpsSet); - if(pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) { + // 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); + gps_data_t *gps; + gps = gpsmm.read(); + if (gps == nullptr) { + sif::warning << "Q7STestTask: 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::scanForReply: 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; - } + } + // Print messages + if ((gps->set & MODE_SET) != MODE_SET) { + // Could not even set mode + gpsSet.setValidity(false, true); + return; + } - if(gps->satellites_used > 0) { - gpsSet.setValidity(true, true); - } + if (gps->satellites_used > 0) { + gpsSet.setValidity(true, true); + } - gpsSet.satInUse.value = gps->satellites_used; - gpsSet.satInView.value = gps->satellites_visible; + 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; - } else { - gpsSet.latitude.setValid(false); - } + // 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; + } 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.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.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); - } + 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; - 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; - } + 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; + 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 96d6089e..026e1779 100644 --- a/mission/devices/GPSHyperionHandler.h +++ b/mission/devices/GPSHyperionHandler.h @@ -1,10 +1,10 @@ #ifndef MISSION_DEVICES_GPSHYPERIONHANDLER_H_ #define MISSION_DEVICES_GPSHYPERIONHANDLER_H_ -#include "fsfw/FSFW.h" -#include "fsfw/devicehandlers/DeviceHandlerBase.h" -#include "fsfw/controller/ExtendedControllerBase.h" #include "devicedefinitions/GPSDefinitions.h" +#include "fsfw/FSFW.h" +#include "fsfw/controller/ExtendedControllerBase.h" +#include "fsfw/devicehandlers/DeviceHandlerBase.h" /** * @brief Device handler for the Hyperion HT-GPS200 device @@ -12,38 +12,35 @@ * Flight manual: * https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/Hyperion_HT-GPS200 */ -class GPSHyperionHandler: public ExtendedControllerBase { -public: +class GPSHyperionHandler : public ExtendedControllerBase { + public: + GPSHyperionHandler(object_id_t objectId, object_id_t parentId, bool debugHyperionGps = false); + virtual ~GPSHyperionHandler(); - GPSHyperionHandler(object_id_t objectId, object_id_t parentId, - 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 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; - 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: + protected: + gpioResetFunction_t resetCallback = nullptr; + void* resetCallbackArgs = nullptr; - gpioResetFunction_t resetCallback = nullptr; - void* resetCallbackArgs = nullptr; + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) override; + private: + GpsPrimaryDataset gpsSet; + bool debugHyperionGps = false; -private: - GpsPrimaryDataset gpsSet; - bool debugHyperionGps = false; - - void readGpsDataFromGpsd(); + void readGpsDataFromGpsd(); }; #endif /* MISSION_DEVICES_GPSHYPERIONHANDLER_H_ */ diff --git a/mission/devices/GomspaceDeviceHandler.cpp b/mission/devices/GomspaceDeviceHandler.cpp index 95e35a5e..eea1368a 100644 --- a/mission/devices/GomspaceDeviceHandler.cpp +++ b/mission/devices/GomspaceDeviceHandler.cpp @@ -2,411 +2,397 @@ #include GomspaceDeviceHandler::GomspaceDeviceHandler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie, uint16_t maxConfigTableAddress, uint16_t maxHkTableAddress, - uint16_t hkTableReplySize, LocalPoolDataSetBase* hkTableDataset) : - DeviceHandlerBase(objectId, comIF, comCookie), maxConfigTableAddress(maxConfigTableAddress), - maxHkTableAddress(maxHkTableAddress), hkTableReplySize(hkTableReplySize), - hkTableDataset(hkTableDataset) { - if (comCookie == nullptr) { - sif::error << "GomspaceDeviceHandler::GomspaceDeviceHandler: Invalid com cookie" - << std::endl; - } - if (hkTableDataset == nullptr) { - sif::error << "GomspaceDeviceHandler::GomspaceDeviceHandler: Invalid hk table data set" - << std::endl; - } + CookieIF* comCookie, uint16_t maxConfigTableAddress, + uint16_t maxHkTableAddress, uint16_t hkTableReplySize, + LocalPoolDataSetBase* hkTableDataset) + : DeviceHandlerBase(objectId, comIF, comCookie), + maxConfigTableAddress(maxConfigTableAddress), + maxHkTableAddress(maxHkTableAddress), + hkTableReplySize(hkTableReplySize), + hkTableDataset(hkTableDataset) { + if (comCookie == nullptr) { + sif::error << "GomspaceDeviceHandler::GomspaceDeviceHandler: Invalid com cookie" << std::endl; + } + if (hkTableDataset == nullptr) { + sif::error << "GomspaceDeviceHandler::GomspaceDeviceHandler: Invalid hk table data set" + << std::endl; + } } -GomspaceDeviceHandler::~GomspaceDeviceHandler() { +GomspaceDeviceHandler::~GomspaceDeviceHandler() {} + +void GomspaceDeviceHandler::doStartUp() {} + +void GomspaceDeviceHandler::doShutDown() {} + +ReturnValue_t GomspaceDeviceHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + return HasReturnvaluesIF::RETURN_OK; } - -void GomspaceDeviceHandler::doStartUp(){ +ReturnValue_t GomspaceDeviceHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { + return HasReturnvaluesIF::RETURN_OK; } -void GomspaceDeviceHandler::doShutDown(){ - -} - -ReturnValue_t GomspaceDeviceHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t GomspaceDeviceHandler::buildTransitionDeviceCommand( - DeviceCommandId_t * id){ - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t GomspaceDeviceHandler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t * commandData, - size_t commandDataLen) { - ReturnValue_t result; - switch(deviceCommand) { - case(GOMSPACE::PING): { - result = generatePingCommand(commandData, commandDataLen); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - break; +ReturnValue_t GomspaceDeviceHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t* commandData, + size_t commandDataLen) { + ReturnValue_t result; + switch (deviceCommand) { + case (GOMSPACE::PING): { + result = generatePingCommand(commandData, commandDataLen); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + break; } - case(GOMSPACE::REBOOT): { - generateRebootCommand(); - break; + case (GOMSPACE::REBOOT): { + generateRebootCommand(); + break; } - case(GOMSPACE::PARAM_SET):{ - result = generateSetParamCommand(commandData, commandDataLen); - if(result != HasReturnvaluesIF::RETURN_OK){ - return result; - } - break; + case (GOMSPACE::PARAM_SET): { + result = generateSetParamCommand(commandData, commandDataLen); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + break; } - case(GOMSPACE::PARAM_GET):{ - result = generateGetParamCommand(commandData, commandDataLen); - if(result != HasReturnvaluesIF::RETURN_OK){ - return result; - } - break; + case (GOMSPACE::PARAM_GET): { + result = generateGetParamCommand(commandData, commandDataLen); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + break; } - case(GOMSPACE::GNDWDT_RESET): { - result = generateResetWatchdogCmd(); - if(result != HasReturnvaluesIF::RETURN_OK){ - return result; - } - break; + case (GOMSPACE::GNDWDT_RESET): { + result = generateResetWatchdogCmd(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + break; } - case(GOMSPACE::PRINT_SWITCH_V_I): { - result = printStatus(deviceCommand); - break; + case (GOMSPACE::PRINT_SWITCH_V_I): { + result = printStatus(deviceCommand); + break; } - case(GOMSPACE::REQUEST_HK_TABLE): { - result = generateRequestFullHkTableCmd(hkTableReplySize); - if(result != HasReturnvaluesIF::RETURN_OK){ - return result; - } - break; + case (GOMSPACE::REQUEST_HK_TABLE): { + result = generateRequestFullHkTableCmd(hkTableReplySize); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + break; } default: - return deviceSpecificCommand(deviceCommand); - } - return HasReturnvaluesIF::RETURN_OK; + return deviceSpecificCommand(deviceCommand); + } + return HasReturnvaluesIF::RETURN_OK; } -void GomspaceDeviceHandler::fillCommandAndReplyMap(){ - this->insertInCommandAndReplyMap(GOMSPACE::PING, 3); - this->insertInCommandMap(GOMSPACE::REBOOT); - this->insertInCommandAndReplyMap(GOMSPACE::PARAM_SET, 3); - this->insertInCommandAndReplyMap(GOMSPACE::PARAM_GET, 3); - this->insertInCommandAndReplyMap(GOMSPACE::REQUEST_HK_TABLE, 3); - this->insertInCommandMap(GOMSPACE::GNDWDT_RESET); - this->insertInCommandMap(GOMSPACE::PRINT_SWITCH_V_I); +void GomspaceDeviceHandler::fillCommandAndReplyMap() { + this->insertInCommandAndReplyMap(GOMSPACE::PING, 3); + this->insertInCommandMap(GOMSPACE::REBOOT); + this->insertInCommandAndReplyMap(GOMSPACE::PARAM_SET, 3); + this->insertInCommandAndReplyMap(GOMSPACE::PARAM_GET, 3); + this->insertInCommandAndReplyMap(GOMSPACE::REQUEST_HK_TABLE, 3); + this->insertInCommandMap(GOMSPACE::GNDWDT_RESET); + this->insertInCommandMap(GOMSPACE::PRINT_SWITCH_V_I); } -ReturnValue_t GomspaceDeviceHandler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { - switch(rememberCommandId) { - case(GOMSPACE::PING): - *foundId = GOMSPACE::PING; - *foundLen = PING_REPLY_SIZE; - rememberCommandId = GOMSPACE::NONE; - break; - case(GOMSPACE::PARAM_GET): { - *foundId = GOMSPACE::PARAM_GET; - *foundLen = rememberRequestedSize + GOMSPACE::GS_HDR_LENGTH; - rememberCommandId = GOMSPACE::NONE; - break; +ReturnValue_t GomspaceDeviceHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + switch (rememberCommandId) { + case (GOMSPACE::PING): + *foundId = GOMSPACE::PING; + *foundLen = PING_REPLY_SIZE; + rememberCommandId = GOMSPACE::NONE; + break; + case (GOMSPACE::PARAM_GET): { + *foundId = GOMSPACE::PARAM_GET; + *foundLen = rememberRequestedSize + GOMSPACE::GS_HDR_LENGTH; + rememberCommandId = GOMSPACE::NONE; + break; } - case(GOMSPACE::PARAM_SET): { - *foundId = GOMSPACE::PARAM_SET; - *foundLen = rememberRequestedSize; - rememberCommandId = GOMSPACE::NONE; - break; + case (GOMSPACE::PARAM_SET): { + *foundId = GOMSPACE::PARAM_SET; + *foundLen = rememberRequestedSize; + rememberCommandId = GOMSPACE::NONE; + break; } - case(GOMSPACE::REQUEST_HK_TABLE): { - *foundId = GOMSPACE::REQUEST_HK_TABLE; - *foundLen = rememberRequestedSize + GOMSPACE::GS_HDR_LENGTH; - rememberCommandId = GOMSPACE::NONE; - break; + case (GOMSPACE::REQUEST_HK_TABLE): { + *foundId = GOMSPACE::REQUEST_HK_TABLE; + *foundLen = rememberRequestedSize + GOMSPACE::GS_HDR_LENGTH; + rememberCommandId = GOMSPACE::NONE; + break; } default: - return IGNORE_REPLY_DATA; - } - return HasReturnvaluesIF::RETURN_OK; + return IGNORE_REPLY_DATA; + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t GomspaceDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { - switch(id) { - case(GOMSPACE::PING): { - SerializeElement replyTime = *packet; - handleDeviceTM(&replyTime, id, true); - break; + const uint8_t* packet) { + switch (id) { + case (GOMSPACE::PING): { + SerializeElement replyTime = *packet; + handleDeviceTM(&replyTime, id, true); + break; } - case(GOMSPACE::PARAM_GET): { - // -2 to subtract address size from gomspace parameter reply packet - uint16_t payloadLength = (*(packet + 2) << 8 | *(packet + 3)) - 2; - if(payloadLength > sizeof(uint32_t)){ - sif::error << "GomspaceDeviceHandler: PARAM_GET: Invalid payload " - << "size in reply" << std::endl; - return INVALID_PAYLOAD_SIZE; - } - uint8_t tempPayloadBuffer[payloadLength]; - /* Extract information from received data */ - CspGetParamReply cspGetParamReply(tempPayloadBuffer, payloadLength); - size_t size = GOMSPACE::GS_HDR_LENGTH + payloadLength; - ReturnValue_t result = cspGetParamReply.deSerialize(&packet, &size, - SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "GomspaceDeviceHandler: Failed to deserialize get parameter" - << "reply" << std::endl; - return result; - } - uint8_t action = cspGetParamReply.getAction(); - uint8_t tableId = cspGetParamReply.getTableId(); - uint16_t address = cspGetParamReply.getAddress(); - /* Pack relevant information into a tm packet */ - ParamReply paramReply(action, tableId, address, payloadLength, - tempPayloadBuffer); - handleDeviceTM(¶mReply, id, true); - break; + case (GOMSPACE::PARAM_GET): { + // -2 to subtract address size from gomspace parameter reply packet + uint16_t payloadLength = (*(packet + 2) << 8 | *(packet + 3)) - 2; + if (payloadLength > sizeof(uint32_t)) { + sif::error << "GomspaceDeviceHandler: PARAM_GET: Invalid payload " + << "size in reply" << std::endl; + return INVALID_PAYLOAD_SIZE; + } + uint8_t tempPayloadBuffer[payloadLength]; + /* Extract information from received data */ + CspGetParamReply cspGetParamReply(tempPayloadBuffer, payloadLength); + size_t size = GOMSPACE::GS_HDR_LENGTH + payloadLength; + ReturnValue_t result = + cspGetParamReply.deSerialize(&packet, &size, SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomspaceDeviceHandler: Failed to deserialize get parameter" + << "reply" << std::endl; + return result; + } + uint8_t action = cspGetParamReply.getAction(); + uint8_t tableId = cspGetParamReply.getTableId(); + uint16_t address = cspGetParamReply.getAddress(); + /* Pack relevant information into a tm packet */ + ParamReply paramReply(action, tableId, address, payloadLength, tempPayloadBuffer); + handleDeviceTM(¶mReply, id, true); + break; } - case(GOMSPACE::PARAM_SET): { - /* When setting a parameter, the p60dock sends back the state of the - * operation */ - if(*packet != PARAM_SET_OK){ - return HasReturnvaluesIF::RETURN_FAILED; - } - break; + case (GOMSPACE::PARAM_SET): { + /* When setting a parameter, the p60dock sends back the state of the + * operation */ + if (*packet != PARAM_SET_OK) { + return HasReturnvaluesIF::RETURN_FAILED; + } + break; } - case(GOMSPACE::REQUEST_HK_TABLE): { - letChildHandleHkReply(id, packet); - break; + case (GOMSPACE::REQUEST_HK_TABLE): { + letChildHandleHkReply(id, packet); + break; } default: - break; - } - return HasReturnvaluesIF::RETURN_OK; + break; + } + return HasReturnvaluesIF::RETURN_OK; } -void GomspaceDeviceHandler::setNormalDatapoolEntriesInvalid(){ +void GomspaceDeviceHandler::setNormalDatapoolEntriesInvalid() {} +ReturnValue_t GomspaceDeviceHandler::generateSetParamCommand(const uint8_t* commandData, + size_t commandDataLen) { + SetParamMessageUnpacker setParamMessageUnpacker; + ReturnValue_t result = setParamMessageUnpacker.deSerialize(&commandData, &commandDataLen, + SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomspaceDeviceHandler: Failed to deserialize set parameter " + "message" + << std::endl; + return result; + } + /* Get and check address */ + uint16_t address = setParamMessageUnpacker.getAddress(); + if (address > maxConfigTableAddress) { + sif::error << "GomspaceDeviceHandler: Invalid address for set parameter " + << "action" << std::endl; + return INVALID_ADDRESS; + } + uint16_t checksum = GOMSPACE::IGNORE_CHECKSUM; + uint16_t seq = 0; + 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(); + uint16_t payloadlength = sizeof(address) + parameterSize; + + /* Generate command for CspComIF */ + CspSetParamCommand setParamCmd(querySize, payloadlength, checksum, seq, total, address, + parameterPtr, parameterSize); + size_t cspPacketLen = 0; + uint8_t* buffer = cspPacket; + result = setParamCmd.serialize(&buffer, &cspPacketLen, sizeof(cspPacket), + SerializeIF::Endianness::BIG); + + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomspaceDeviceHandler: Failed to serialize command for " + << "CspComIF" << std::endl; + return result; + } + if (cspPacketLen > MAX_PACKET_LEN) { + sif::error << "GomspaceDeviceHandler: Invalid length of set parameter " + "command" + << std::endl; + return PACKET_TOO_LONG; + } + rawPacket = cspPacket; + rawPacketLen = cspPacketLen; + rememberRequestedSize = querySize; + rememberCommandId = GOMSPACE::PARAM_SET; + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t GomspaceDeviceHandler::generateSetParamCommand( - const uint8_t * commandData, size_t commandDataLen) { - SetParamMessageUnpacker setParamMessageUnpacker; - ReturnValue_t result = setParamMessageUnpacker.deSerialize(&commandData, - &commandDataLen, SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "GomspaceDeviceHandler: Failed to deserialize set parameter " - "message" << std::endl; - return result; - } - /* Get and check address */ - uint16_t address = setParamMessageUnpacker.getAddress(); - if(address > maxConfigTableAddress){ - sif::error << "GomspaceDeviceHandler: Invalid address for set parameter " - << "action" << std::endl; - return INVALID_ADDRESS; - } - uint16_t checksum = GOMSPACE::IGNORE_CHECKSUM; - uint16_t seq = 0; - 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(); - uint16_t payloadlength = sizeof(address) + parameterSize; +ReturnValue_t GomspaceDeviceHandler::generateGetParamCommand(const uint8_t* commandData, + size_t commandDataLen) { + ReturnValue_t result; + /* Unpack the received action message */ + GetParamMessageUnpacker getParamMessage; + result = getParamMessage.deSerialize(&commandData, &commandDataLen, SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Failed to deserialize message to extract information " + "from get parameter message" + << std::endl; + return result; + } + /* Get an check table id to read from */ + uint8_t tableId = getParamMessage.getTableId(); + if (tableId != CONFIG_TABLE_ID && tableId != HK_TABLE_ID) { + sif::error << "GomspaceDeviceHandler: Invalid table id in get parameter" + " message" + << std::endl; + return INVALID_TABLE_ID; + } + /* Get and check address */ + uint16_t address = getParamMessage.getAddress(); + if (address > maxHkTableAddress && tableId == HK_TABLE_ID) { + sif::error << "GomspaceDeviceHandler: Invalid address to get parameter from " + << "housekeeping table" << std::endl; + return INVALID_ADDRESS; + } + if (address > maxConfigTableAddress && tableId == CONFIG_TABLE_ID) { + sif::error << "GomspaceDeviceHandler: Invalid address to get parameter from " + << "configuration table" << std::endl; + return INVALID_ADDRESS; + } + uint16_t length = sizeof(address); + uint16_t checksum = GOMSPACE::IGNORE_CHECKSUM; + uint16_t seq = 0; + uint16_t total = 0; + uint8_t parameterSize = getParamMessage.getParameterSize(); + if (parameterSize > sizeof(uint32_t)) { + sif::error << "GomspaceDeviceHandler: GET_PARAM: Invalid parameter " + << "size" << std::endl; + return INVALID_PARAM_SIZE; + } + uint16_t querySize = parameterSize + GOMSPACE::GS_HDR_LENGTH; - /* Generate command for CspComIF */ - CspSetParamCommand setParamCmd(querySize, payloadlength, checksum, seq, - total, address, parameterPtr, parameterSize); - size_t cspPacketLen = 0; - uint8_t* buffer = cspPacket; - result = setParamCmd.serialize(&buffer, &cspPacketLen, sizeof(cspPacket), - SerializeIF::Endianness::BIG); - - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "GomspaceDeviceHandler: Failed to serialize command for " - << "CspComIF" << std::endl; - return result; - } - if(cspPacketLen > MAX_PACKET_LEN){ - sif::error << "GomspaceDeviceHandler: Invalid length of set parameter " - "command" << std::endl; - return PACKET_TOO_LONG; - } - rawPacket = cspPacket; - rawPacketLen = cspPacketLen; - rememberRequestedSize = querySize; - rememberCommandId = GOMSPACE::PARAM_SET; - return HasReturnvaluesIF::RETURN_OK; + /* Generate the CSP command to send to the P60 Dock */ + CspGetParamCommand getParamCmd(querySize, tableId, length, checksum, seq, total, address); + size_t cspPacketLen = 0; + uint8_t* buffer = cspPacket; + result = getParamCmd.serialize(&buffer, &cspPacketLen, sizeof(cspPacket), + SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomspaceDeviceHandler: Failed to serialize command to " + << "get parameter" << std::endl; + } + if (cspPacketLen > MAX_PACKET_LEN) { + sif::error << "GomspaceDeviceHandler: Received invalid get parameter " + "command" + << std::endl; + return PACKET_TOO_LONG; + } + rawPacket = cspPacket; + rawPacketLen = cspPacketLen; + rememberRequestedSize = querySize; + rememberCommandId = GOMSPACE::PARAM_GET; + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t GomspaceDeviceHandler::generateGetParamCommand( - const uint8_t * commandData, size_t commandDataLen){ - ReturnValue_t result; - /* Unpack the received action message */ - GetParamMessageUnpacker getParamMessage; - result = getParamMessage.deSerialize(&commandData, &commandDataLen, - SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Failed to deserialize message to extract information " - "from get parameter message" << std::endl; - return result; - } - /* Get an check table id to read from */ - uint8_t tableId = getParamMessage.getTableId(); - if(tableId != CONFIG_TABLE_ID && tableId != HK_TABLE_ID){ - sif::error << "GomspaceDeviceHandler: Invalid table id in get parameter" - " message" << std::endl; - return INVALID_TABLE_ID; - } - /* Get and check address */ - uint16_t address = getParamMessage.getAddress(); - if(address > maxHkTableAddress && tableId == HK_TABLE_ID){ - sif::error << "GomspaceDeviceHandler: Invalid address to get parameter from " - << "housekeeping table" << std::endl; - return INVALID_ADDRESS; - } - if(address > maxConfigTableAddress && tableId == CONFIG_TABLE_ID){ - sif::error << "GomspaceDeviceHandler: Invalid address to get parameter from " - << "configuration table" << std::endl; - return INVALID_ADDRESS; - } - uint16_t length = sizeof(address); - uint16_t checksum = GOMSPACE::IGNORE_CHECKSUM; - uint16_t seq = 0; - uint16_t total = 0; - uint8_t parameterSize = getParamMessage.getParameterSize(); - if(parameterSize > sizeof(uint32_t)) { - sif::error << "GomspaceDeviceHandler: GET_PARAM: Invalid parameter " - << "size" << std::endl; - return INVALID_PARAM_SIZE; - } - uint16_t querySize = parameterSize + GOMSPACE::GS_HDR_LENGTH; - - /* Generate the CSP command to send to the P60 Dock */ - CspGetParamCommand getParamCmd(querySize, tableId, length, - checksum, seq, total, address); - size_t cspPacketLen = 0; - uint8_t* buffer = cspPacket; - result = getParamCmd.serialize(&buffer, &cspPacketLen, sizeof(cspPacket), - SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "GomspaceDeviceHandler: Failed to serialize command to " - << "get parameter" << std::endl; - } - if(cspPacketLen > MAX_PACKET_LEN){ - sif::error << "GomspaceDeviceHandler: Received invalid get parameter " - "command" << std::endl; - return PACKET_TOO_LONG; - } - rawPacket = cspPacket; - rawPacketLen = cspPacketLen; - rememberRequestedSize = querySize; - rememberCommandId = GOMSPACE::PARAM_GET; - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t GomspaceDeviceHandler::generatePingCommand(const uint8_t* commandData, + size_t commandDataLen) { + CspPingCommand cspPingCommand(commandData, commandDataLen); + size_t cspPacketLen = 0; + uint8_t* buffer = cspPacket; + ReturnValue_t result = cspPingCommand.serialize(&buffer, &cspPacketLen, sizeof(cspPacket), + SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomspaceDeviceHandler: Failed to serialize ping command" << std::endl; + return result; + } + if (cspPacketLen > MAX_PACKET_LEN) { + sif::error << "GomspaceDeviceHandler: Received invalid ping message" << std::endl; + return PACKET_TOO_LONG; + } + rawPacket = cspPacket; + rawPacketLen = cspPacketLen; + rememberCommandId = GOMSPACE::PING; + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t GomspaceDeviceHandler::generatePingCommand( - const uint8_t * commandData, size_t commandDataLen) { - CspPingCommand cspPingCommand(commandData, commandDataLen); - size_t cspPacketLen = 0; - uint8_t* buffer = cspPacket; - ReturnValue_t result = cspPingCommand.serialize(&buffer, &cspPacketLen, - sizeof(cspPacket), - SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "GomspaceDeviceHandler: Failed to serialize ping command" - << std::endl; - return result; - } - if(cspPacketLen > MAX_PACKET_LEN){ - sif::error << "GomspaceDeviceHandler: Received invalid ping message" - << std::endl; - return PACKET_TOO_LONG; - } - rawPacket = cspPacket; - rawPacketLen = cspPacketLen; - rememberCommandId = GOMSPACE::PING; - return HasReturnvaluesIF::RETURN_OK; +void GomspaceDeviceHandler::generateRebootCommand() { + uint8_t cspPort = GOMSPACE::REBOOT_PORT; + uint16_t querySize = 0; + *cspPacket = GOMSPACE::REBOOT_PORT; + *(cspPacket + 1) = querySize; + size_t cspPacketLen = sizeof(cspPort) + sizeof(cspPacketLen); + rawPacket = cspPacket; + rawPacketLen = cspPacketLen; } -void GomspaceDeviceHandler::generateRebootCommand(){ - uint8_t cspPort = GOMSPACE::REBOOT_PORT; - uint16_t querySize = 0; - *cspPacket = GOMSPACE::REBOOT_PORT; - *(cspPacket + 1) = querySize; - size_t cspPacketLen = sizeof(cspPort) + sizeof(cspPacketLen); - rawPacket = cspPacket; - rawPacketLen = cspPacketLen; -} - -ReturnValue_t GomspaceDeviceHandler::generateResetWatchdogCmd(){ - WatchdogResetCommand watchdogResetCommand; - size_t cspPacketLen = 0; - uint8_t* buffer = cspPacket; - ReturnValue_t result = watchdogResetCommand.serialize(&buffer, - &cspPacketLen, sizeof(cspPacket), SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "GomspaceDeviceHandler: Failed to serialize watchdog reset " - << "command" << std::endl; - return result; - } - rawPacket = cspPacket; - rawPacketLen = cspPacketLen; - rememberRequestedSize = 0; // No bytes will be queried with the ground - // watchdog command. - rememberCommandId = GOMSPACE::GNDWDT_RESET; - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t GomspaceDeviceHandler::generateResetWatchdogCmd() { + WatchdogResetCommand watchdogResetCommand; + size_t cspPacketLen = 0; + uint8_t* buffer = cspPacket; + ReturnValue_t result = watchdogResetCommand.serialize(&buffer, &cspPacketLen, sizeof(cspPacket), + SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomspaceDeviceHandler: Failed to serialize watchdog reset " + << "command" << std::endl; + return result; + } + rawPacket = cspPacket; + rawPacketLen = cspPacketLen; + rememberRequestedSize = 0; // No bytes will be queried with the ground + // watchdog command. + rememberCommandId = GOMSPACE::GNDWDT_RESET; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t GomspaceDeviceHandler::generateRequestFullHkTableCmd(uint16_t hkTableReplySize) { + uint16_t querySize = hkTableReplySize; + uint8_t tableId = HK_TABLE_ID; + RequestFullTableCommand requestFullTableCommand(querySize, tableId); - uint16_t querySize = hkTableReplySize; - uint8_t tableId = HK_TABLE_ID; - RequestFullTableCommand requestFullTableCommand(querySize, tableId); - - size_t cspPacketLen = 0; - uint8_t* buffer = cspPacket; - ReturnValue_t result = requestFullTableCommand.serialize(&buffer, - &cspPacketLen, sizeof(cspPacket), SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "GomspaceDeviceHandler::generateRequestFullHkTableCmd Failed to serialize " - "full table request command " << std::endl; - return result; - } - rawPacket = cspPacket; - rawPacketLen = cspPacketLen; - rememberRequestedSize = querySize; - rememberCommandId = GOMSPACE::REQUEST_HK_TABLE; - return RETURN_OK; + size_t cspPacketLen = 0; + uint8_t* buffer = cspPacket; + ReturnValue_t result = requestFullTableCommand.serialize( + &buffer, &cspPacketLen, sizeof(cspPacket), SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomspaceDeviceHandler::generateRequestFullHkTableCmd Failed to serialize " + "full table request command " + << std::endl; + return result; + } + rawPacket = cspPacket; + rawPacketLen = cspPacketLen; + rememberRequestedSize = querySize; + rememberCommandId = GOMSPACE::REQUEST_HK_TABLE; + return RETURN_OK; } -uint32_t GomspaceDeviceHandler::getTransitionDelayMs(Mode_t modeFrom, - Mode_t modeTo) { - return 0; -} +uint32_t GomspaceDeviceHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 0; } LocalPoolDataSetBase* GomspaceDeviceHandler::getDataSetHandle(sid_t sid) { - if(sid == hkTableDataset->getSid()) { - return hkTableDataset; - } - else { - return nullptr; - } + if (sid == hkTableDataset->getSid()) { + return hkTableDataset; + } else { + return nullptr; + } } ReturnValue_t GomspaceDeviceHandler::deviceSpecificCommand(DeviceCommandId_t cmd) { - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } -void GomspaceDeviceHandler::setModeNormal() { - mode = MODE_NORMAL; -} +void GomspaceDeviceHandler::setModeNormal() { mode = MODE_NORMAL; } ReturnValue_t GomspaceDeviceHandler::printStatus(DeviceCommandId_t cmd) { - sif::info << "No printHkTable implementation given.." << std::endl; - return HasReturnvaluesIF::RETURN_OK; + sif::info << "No printHkTable implementation given.." << std::endl; + return HasReturnvaluesIF::RETURN_OK; } diff --git a/mission/devices/GomspaceDeviceHandler.h b/mission/devices/GomspaceDeviceHandler.h index 29156fce..c9c08609 100644 --- a/mission/devices/GomspaceDeviceHandler.h +++ b/mission/devices/GomspaceDeviceHandler.h @@ -16,135 +16,125 @@ * Flight manual: * https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/Gomspace_PCDU_P60_System */ -class GomspaceDeviceHandler: public DeviceHandlerBase { -public: +class GomspaceDeviceHandler : public DeviceHandlerBase { + public: + static constexpr uint8_t CLASS_ID = CLASS_ID::GOM_SPACE_HANDLER; + static const ReturnValue_t PACKET_TOO_LONG = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 0); + static const ReturnValue_t INVALID_TABLE_ID = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 1); + static const ReturnValue_t INVALID_ADDRESS = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 2); + static const ReturnValue_t INVALID_PARAM_SIZE = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 3); + static const ReturnValue_t INVALID_PAYLOAD_SIZE = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 4); + static const ReturnValue_t UNKNOWN_REPLY_ID = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 5); - static constexpr uint8_t CLASS_ID = CLASS_ID::GOM_SPACE_HANDLER; - static const ReturnValue_t PACKET_TOO_LONG = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 0); - static const ReturnValue_t INVALID_TABLE_ID = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 1); - static const ReturnValue_t INVALID_ADDRESS = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 2); - static const ReturnValue_t INVALID_PARAM_SIZE = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 3); - static const ReturnValue_t INVALID_PAYLOAD_SIZE = - HasReturnvaluesIF::makeReturnCode(CLASS_ID, 4); - static const ReturnValue_t UNKNOWN_REPLY_ID = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 5); + /** + * @brief Constructor + * + * @param maxConfigTableAddress The maximum memory address of the configu- + * ration table of a gomspace device. + * @param maxHkTableAddress The maximum memory address of a value in the + * houskeeping (telemetry) table of a gomspace + * device. + */ + GomspaceDeviceHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie, + uint16_t maxConfigTableAddress, uint16_t maxHkTableAddress, + uint16_t hkTableReplySize, LocalPoolDataSetBase *hkTableDataset); + virtual ~GomspaceDeviceHandler(); - /** - * @brief Constructor - * - * @param maxConfigTableAddress The maximum memory address of the configu- - * ration table of a gomspace device. - * @param maxHkTableAddress The maximum memory address of a value in the - * houskeeping (telemetry) table of a gomspace - * device. - */ - GomspaceDeviceHandler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie, uint16_t maxConfigTableAddress, uint16_t maxHkTableAddress, - uint16_t hkTableReplySize, LocalPoolDataSetBase* hkTableDataset); - virtual ~GomspaceDeviceHandler(); + /** + * @brief This function can be used to set a gomspace device to normal mode immediately after + * object creation. + */ + void setModeNormal(); - /** - * @brief This function can be used to set a gomspace device to normal mode immediately after - * object creation. - */ - void setModeNormal(); + protected: + static const uint8_t MAX_PACKET_LEN = 36; + static const uint8_t PARAM_SET_OK = 1; + static const uint8_t PING_REPLY_SIZE = 2; + static const uint8_t CONFIG_TABLE_ID = 1; + static const uint8_t HK_TABLE_ID = 4; -protected: + uint8_t rememberRequestedSize = 0; + uint8_t rememberCommandId = GOMSPACE::NONE; + uint8_t cspPacket[MAX_PACKET_LEN]; - static const uint8_t MAX_PACKET_LEN = 36; - static const uint8_t PARAM_SET_OK = 1; - static const uint8_t PING_REPLY_SIZE = 2; - static const uint8_t CONFIG_TABLE_ID = 1; - static const uint8_t HK_TABLE_ID = 4; + uint16_t maxConfigTableAddress; + uint16_t maxHkTableAddress; - uint8_t rememberRequestedSize = 0; - uint8_t rememberCommandId = GOMSPACE::NONE; - uint8_t cspPacket[MAX_PACKET_LEN]; + /** The size of the reply following a full hk table request.*/ + uint16_t hkTableReplySize; - uint16_t maxConfigTableAddress; - uint16_t maxHkTableAddress; + LocalPoolDataSetBase *hkTableDataset = nullptr; - /** The size of the reply following a full hk table request.*/ - uint16_t hkTableReplySize; + void doStartUp() override; + void doShutDown() override; + virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; + virtual 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; + /** + * @brief The command to generate a request to receive the full housekeeping table is device + * specific. Thus the child has to build this command. + */ + virtual ReturnValue_t generateRequestFullHkTableCmd(uint16_t hkTableSize); - LocalPoolDataSetBase* hkTableDataset = nullptr; + /** + * This command handles printing the HK table to the console. This is useful for debugging + * purposes + * @return + */ + virtual ReturnValue_t printStatus(DeviceCommandId_t cmd); - void doStartUp() override; - void doShutDown() override; - virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) - override; - ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override; - virtual 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; - /** - * @brief The command to generate a request to receive the full housekeeping table is device - * specific. Thus the child has to build this command. - */ - virtual ReturnValue_t generateRequestFullHkTableCmd(uint16_t hkTableSize); + /** + * @brief Because housekeeping tables are device specific the handling of the reply is + * given to the child class. + * @param id The id of the command which initiates the full table request. + * @param packet Pointer to the reply containing the hk table. + */ + virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) = 0; - /** - * This command handles printing the HK table to the console. This is useful for debugging - * purposes - * @return - */ - virtual ReturnValue_t printStatus(DeviceCommandId_t cmd); + virtual LocalPoolDataSetBase *getDataSetHandle(sid_t sid) override; - /** - * @brief Because housekeeping tables are device specific the handling of the reply is - * given to the child class. - * @param id The id of the command which initiates the full table request. - * @param packet Pointer to the reply containing the hk table. - */ - virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) = 0; + /** + * @brief Can be used by gomspace devices to implement device specific commands. + */ + virtual ReturnValue_t deviceSpecificCommand(DeviceCommandId_t cmd); - virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + private: + /** + * @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); - /** - * @brief Can be used by gomspace devices to implement device specific commands. - */ - virtual ReturnValue_t deviceSpecificCommand(DeviceCommandId_t cmd); + /** + * @brief Function to generate the command to get a parameter from a + * gomspace device. Command will be sent to the ComIF over the + * rawPacket buffer. + */ + ReturnValue_t generateGetParamCommand(const uint8_t *commandData, size_t commandDataLen); -private: + /** + * @brief Function to generate the ping command for the ComIF. + */ + ReturnValue_t generatePingCommand(const uint8_t *commandData, size_t commandDataLen); - /** - * @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); - - /** - * @brief Function to generate the command to get a parameter from a - * gomspace device. Command will be sent to the ComIF over the - * rawPacket buffer. - */ - ReturnValue_t generateGetParamCommand(const uint8_t * commandData, - size_t commandDataLen); - - /** - * @brief Function to generate the ping command for the ComIF. - */ - ReturnValue_t generatePingCommand(const uint8_t * commandData, - size_t commandDataLen); - - /** - * @brief Function to generate the command to reboot a gomspace device - * via the ComIF. - */ - void generateRebootCommand(); - - /** - * @brief Function to generate the command to force a ground watchdog - * reset in a gomspace device. - */ - ReturnValue_t generateResetWatchdogCmd(); + /** + * @brief Function to generate the command to reboot a gomspace device + * via the ComIF. + */ + void generateRebootCommand(); + /** + * @brief Function to generate the command to force a ground watchdog + * reset in a gomspace device. + */ + ReturnValue_t generateResetWatchdogCmd(); }; #endif /* MISSION_DEVICES_GOMSPACEDEVICEHANDLER_H_ */ diff --git a/mission/devices/GyroADIS1650XHandler.cpp b/mission/devices/GyroADIS1650XHandler.cpp index 4820eefc..7ea76758 100644 --- a/mission/devices/GyroADIS1650XHandler.cpp +++ b/mission/devices/GyroADIS1650XHandler.cpp @@ -1,481 +1,482 @@ #include "GyroADIS1650XHandler.h" + #include #include #if OBSW_ADIS1650X_LINUX_COM_IF == 1 -#include "fsfw_hal/linux/utility.h" -#include "fsfw_hal/linux/spi/SpiCookie.h" -#include "fsfw_hal/linux/spi/SpiComIF.h" -#include "fsfw_hal/linux/UnixFileGuard.h" #include #include + +#include "fsfw_hal/linux/UnixFileGuard.h" +#include "fsfw_hal/linux/spi/SpiComIF.h" +#include "fsfw_hal/linux/spi/SpiCookie.h" +#include "fsfw_hal/linux/utility.h" #endif -GyroADIS1650XHandler::GyroADIS1650XHandler(object_id_t objectId, - object_id_t deviceCommunication, CookieIF * comCookie, ADIS1650X::Type type): - DeviceHandlerBase(objectId, deviceCommunication, comCookie), adisType(type), - primaryDataset(this), configDataset(this), breakCountdown() { +GyroADIS1650XHandler::GyroADIS1650XHandler(object_id_t objectId, object_id_t deviceCommunication, + CookieIF *comCookie, ADIS1650X::Type type) + : DeviceHandlerBase(objectId, deviceCommunication, comCookie), + adisType(type), + primaryDataset(this), + configDataset(this), + breakCountdown() { #if FSFW_HAL_ADIS1650X_GYRO_DEBUG == 1 - debugDivider = new PeriodicOperationDivider(5); + debugDivider = new PeriodicOperationDivider(5); #endif #if OBSW_ADIS1650X_LINUX_COM_IF == 1 - SpiCookie* cookie = dynamic_cast(comCookie); - if(cookie != nullptr) { - cookie->setCallbackMode(&spiSendCallback, this); - } + SpiCookie *cookie = dynamic_cast(comCookie); + if (cookie != nullptr) { + cookie->setCallbackMode(&spiSendCallback, this); + } #endif } void GyroADIS1650XHandler::doStartUp() { - // Initial 310 ms start up time after power-up - if(internalState == InternalState::STARTUP) { - if(not commandExecuted) { - breakCountdown.setTimeout(ADIS1650X::START_UP_TIME); - commandExecuted = true; - } - if(breakCountdown.hasTimedOut()) { - internalState = InternalState::CONFIG; - commandExecuted = false; - } + // Initial 310 ms start up time after power-up + if (internalState == InternalState::STARTUP) { + if (not commandExecuted) { + breakCountdown.setTimeout(ADIS1650X::START_UP_TIME); + commandExecuted = true; } + if (breakCountdown.hasTimedOut()) { + internalState = InternalState::CONFIG; + commandExecuted = false; + } + } - // Read all configuration registers first - if(internalState == InternalState::CONFIG) { - if(commandExecuted) { - commandExecuted = false; - internalState = InternalState::IDLE; - } + // Read all configuration registers first + if (internalState == InternalState::CONFIG) { + if (commandExecuted) { + commandExecuted = false; + internalState = InternalState::IDLE; } + } - if(internalState == InternalState::IDLE) { - setMode(MODE_NORMAL); - // setMode(MODE_ON); - } + if (internalState == InternalState::IDLE) { + setMode(MODE_NORMAL); + // setMode(MODE_ON); + } } void GyroADIS1650XHandler::doShutDown() { - commandExecuted = false; - setMode(_MODE_POWER_DOWN); + commandExecuted = false; + setMode(_MODE_POWER_DOWN); } ReturnValue_t GyroADIS1650XHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { - *id = ADIS1650X::READ_SENSOR_DATA; - return buildCommandFromCommand(*id, nullptr, 0); + *id = ADIS1650X::READ_SENSOR_DATA; + return buildCommandFromCommand(*id, nullptr, 0); } ReturnValue_t GyroADIS1650XHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { - switch(internalState) { - case(InternalState::CONFIG): { - *id = ADIS1650X::READ_OUT_CONFIG; - buildCommandFromCommand(*id, nullptr, 0); - break; + switch (internalState) { + case (InternalState::CONFIG): { + *id = ADIS1650X::READ_OUT_CONFIG; + buildCommandFromCommand(*id, nullptr, 0); + break; } - case(InternalState::STARTUP): { - return NOTHING_TO_SEND; - break; + case (InternalState::STARTUP): { + return NOTHING_TO_SEND; + break; } default: { - /* Might be a configuration error. */ - sif::debug << "GyroADIS16507Handler::buildTransitionDeviceCommand: " - "Unknown internal state!" << std::endl; - return HasReturnvaluesIF::RETURN_OK; + /* Might be a configuration error. */ + sif::debug << "GyroADIS16507Handler::buildTransitionDeviceCommand: " + "Unknown internal state!" + << std::endl; + return HasReturnvaluesIF::RETURN_OK; } - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t GyroADIS1650XHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t *commandData, size_t commandDataLen) { - switch(deviceCommand) { - case(ADIS1650X::READ_OUT_CONFIG): { - this->rawPacketLen = ADIS1650X::CONFIG_READOUT_SIZE; - uint8_t regList[5]; - regList[0] = ADIS1650X::DIAG_STAT_REG; - regList[1] = ADIS1650X::FILTER_CTRL_REG; - regList[2] = ADIS1650X::MSC_CTRL_REG; - regList[3] = ADIS1650X::DEC_RATE_REG; - regList[4] = ADIS1650X::PROD_ID_REG; - prepareReadCommand(regList, sizeof(regList)); - this->rawPacket = commandBuffer.data(); - break; + const uint8_t *commandData, + size_t commandDataLen) { + switch (deviceCommand) { + case (ADIS1650X::READ_OUT_CONFIG): { + this->rawPacketLen = ADIS1650X::CONFIG_READOUT_SIZE; + uint8_t regList[5]; + regList[0] = ADIS1650X::DIAG_STAT_REG; + regList[1] = ADIS1650X::FILTER_CTRL_REG; + regList[2] = ADIS1650X::MSC_CTRL_REG; + regList[3] = ADIS1650X::DEC_RATE_REG; + regList[4] = ADIS1650X::PROD_ID_REG; + prepareReadCommand(regList, sizeof(regList)); + this->rawPacket = commandBuffer.data(); + break; } - case(ADIS1650X::READ_SENSOR_DATA): { - if(breakCountdown.isBusy()) { - // A glob command is pending and sensor data can't be read currently - return NO_REPLY_EXPECTED; - } - std::memcpy(commandBuffer.data(), ADIS1650X::BURST_READ_ENABLE.data(), - ADIS1650X::BURST_READ_ENABLE.size()); - std::memset(commandBuffer.data() + 2, 0, 10 * 2); - this->rawPacketLen = ADIS1650X::SENSOR_READOUT_SIZE; - this->rawPacket = commandBuffer.data(); - break; + case (ADIS1650X::READ_SENSOR_DATA): { + if (breakCountdown.isBusy()) { + // A glob command is pending and sensor data can't be read currently + return NO_REPLY_EXPECTED; + } + std::memcpy(commandBuffer.data(), ADIS1650X::BURST_READ_ENABLE.data(), + ADIS1650X::BURST_READ_ENABLE.size()); + std::memset(commandBuffer.data() + 2, 0, 10 * 2); + this->rawPacketLen = ADIS1650X::SENSOR_READOUT_SIZE; + this->rawPacket = commandBuffer.data(); + break; } - case(ADIS1650X::SELF_TEST_SENSORS): { - if(breakCountdown.isBusy()) { - // Another glob command is pending - return HasActionsIF::IS_BUSY; - } - prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::SENSOR_SELF_TEST, 0x00); - breakCountdown.setTimeout(ADIS1650X::SELF_TEST_BREAK); - break; + case (ADIS1650X::SELF_TEST_SENSORS): { + if (breakCountdown.isBusy()) { + // Another glob command is pending + return HasActionsIF::IS_BUSY; + } + prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::SENSOR_SELF_TEST, 0x00); + breakCountdown.setTimeout(ADIS1650X::SELF_TEST_BREAK); + break; } - case(ADIS1650X::SELF_TEST_MEMORY): { - if(breakCountdown.isBusy()) { - // Another glob command is pending - return HasActionsIF::IS_BUSY; - } - prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FLASH_MEMORY_TEST, 0x00); - breakCountdown.setTimeout(ADIS1650X::FLASH_MEMORY_TEST_BREAK); - break; + case (ADIS1650X::SELF_TEST_MEMORY): { + if (breakCountdown.isBusy()) { + // Another glob command is pending + return HasActionsIF::IS_BUSY; + } + prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FLASH_MEMORY_TEST, 0x00); + breakCountdown.setTimeout(ADIS1650X::FLASH_MEMORY_TEST_BREAK); + break; } - case(ADIS1650X::UPDATE_NV_CONFIGURATION): { - if(breakCountdown.isBusy()) { - // Another glob command is pending - return HasActionsIF::IS_BUSY; - } - prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FLASH_MEMORY_UPDATE, 0x00); - breakCountdown.setTimeout(ADIS1650X::FLASH_MEMORY_UPDATE_BREAK); - break; + case (ADIS1650X::UPDATE_NV_CONFIGURATION): { + if (breakCountdown.isBusy()) { + // Another glob command is pending + return HasActionsIF::IS_BUSY; + } + prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FLASH_MEMORY_UPDATE, 0x00); + breakCountdown.setTimeout(ADIS1650X::FLASH_MEMORY_UPDATE_BREAK); + break; } - case(ADIS1650X::RESET_SENSOR_CONFIGURATION): { - if(breakCountdown.isBusy()) { - // Another glob command is pending - return HasActionsIF::IS_BUSY; - } - prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FACTORY_CALIBRATION, 0x00); - breakCountdown.setTimeout(ADIS1650X::FACTORY_CALIBRATION_BREAK); - break; + case (ADIS1650X::RESET_SENSOR_CONFIGURATION): { + if (breakCountdown.isBusy()) { + // Another glob command is pending + return HasActionsIF::IS_BUSY; + } + prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FACTORY_CALIBRATION, 0x00); + breakCountdown.setTimeout(ADIS1650X::FACTORY_CALIBRATION_BREAK); + break; } - case(ADIS1650X::SW_RESET): { - if(breakCountdown.isBusy()) { - // Another glob command is pending - return HasActionsIF::IS_BUSY; - } - prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::SOFTWARE_RESET, 0x00); - breakCountdown.setTimeout(ADIS1650X::SW_RESET_BREAK); - break; + case (ADIS1650X::SW_RESET): { + if (breakCountdown.isBusy()) { + // Another glob command is pending + return HasActionsIF::IS_BUSY; + } + prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::SOFTWARE_RESET, 0x00); + breakCountdown.setTimeout(ADIS1650X::SW_RESET_BREAK); + break; } - case(ADIS1650X::PRINT_CURRENT_CONFIGURATION): { + case (ADIS1650X::PRINT_CURRENT_CONFIGURATION): { #if OBSW_VERBOSE_LEVEL >= 1 - PoolReadGuard pg(&configDataset); - sif::info << "ADIS16507 Sensor configuration: DIAG_STAT: 0x" << std::hex << std::setw(4) << - std::setfill('0') << "0x" << configDataset.diagStatReg.value << std::endl; - sif::info << "MSC_CTRL: " << std::hex << std::setw(4) << "0x" << - configDataset.mscCtrlReg.value << " | FILT_CTRL: 0x" << - configDataset.filterSetting.value << " | DEC_RATE: 0x" << - configDataset.decRateReg.value << std::setfill(' ') << std::endl; + PoolReadGuard pg(&configDataset); + sif::info << "ADIS16507 Sensor configuration: DIAG_STAT: 0x" << std::hex << std::setw(4) + << std::setfill('0') << "0x" << configDataset.diagStatReg.value << std::endl; + sif::info << "MSC_CTRL: " << std::hex << std::setw(4) << "0x" + << configDataset.mscCtrlReg.value << " | FILT_CTRL: 0x" + << configDataset.filterSetting.value << " | DEC_RATE: 0x" + << configDataset.decRateReg.value << std::setfill(' ') << std::endl; #endif /* OBSW_VERBOSE_LEVEL >= 1 */ } - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } void GyroADIS1650XHandler::fillCommandAndReplyMap() { - insertInCommandAndReplyMap(ADIS1650X::READ_SENSOR_DATA, 1, &primaryDataset); - insertInCommandAndReplyMap(ADIS1650X::READ_OUT_CONFIG, 1, &configDataset); - insertInCommandAndReplyMap(ADIS1650X::SELF_TEST_SENSORS, 1); - insertInCommandAndReplyMap(ADIS1650X::SELF_TEST_MEMORY, 1); - insertInCommandAndReplyMap(ADIS1650X::UPDATE_NV_CONFIGURATION, 1); - insertInCommandAndReplyMap(ADIS1650X::RESET_SENSOR_CONFIGURATION, 1); - insertInCommandAndReplyMap(ADIS1650X::SW_RESET, 1); - insertInCommandAndReplyMap(ADIS1650X::PRINT_CURRENT_CONFIGURATION, 1); + insertInCommandAndReplyMap(ADIS1650X::READ_SENSOR_DATA, 1, &primaryDataset); + insertInCommandAndReplyMap(ADIS1650X::READ_OUT_CONFIG, 1, &configDataset); + insertInCommandAndReplyMap(ADIS1650X::SELF_TEST_SENSORS, 1); + insertInCommandAndReplyMap(ADIS1650X::SELF_TEST_MEMORY, 1); + insertInCommandAndReplyMap(ADIS1650X::UPDATE_NV_CONFIGURATION, 1); + insertInCommandAndReplyMap(ADIS1650X::RESET_SENSOR_CONFIGURATION, 1); + insertInCommandAndReplyMap(ADIS1650X::SW_RESET, 1); + insertInCommandAndReplyMap(ADIS1650X::PRINT_CURRENT_CONFIGURATION, 1); } ReturnValue_t GyroADIS1650XHandler::scanForReply(const uint8_t *start, size_t remainingSize, - DeviceCommandId_t *foundId, size_t *foundLen) { - // For SPI, the ID will always be the one of the last sent command - *foundId = this->getPendingCommand(); - *foundLen = this->rawPacketLen; + DeviceCommandId_t *foundId, size_t *foundLen) { + // For SPI, the ID will always be the one of the last sent command + *foundId = this->getPendingCommand(); + *foundLen = this->rawPacketLen; - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t GyroADIS1650XHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { - switch(id) { - case(ADIS1650X::READ_OUT_CONFIG): { - - uint16_t readProdId = packet[10] << 8 | packet[11]; - if(((adisType == ADIS1650X::Type::ADIS16507) and - (readProdId != ADIS1650X::PROD_ID_16507)) or - ((adisType == ADIS1650X::Type::ADIS16505) and - (readProdId != ADIS1650X::PROD_ID_16505))) { + const uint8_t *packet) { + switch (id) { + case (ADIS1650X::READ_OUT_CONFIG): { + uint16_t readProdId = packet[10] << 8 | packet[11]; + 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 - sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Invalid product ID " - << readProdId << std::endl; + sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Invalid product ID " + << readProdId << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; - } - PoolReadGuard rg(&configDataset); - configDataset.diagStatReg.value = packet[2] << 8 | packet[3]; - configDataset.filterSetting.value = packet[4] << 8 | packet[5]; - configDataset.mscCtrlReg.value = packet[6] << 8 | packet[7]; - configDataset.decRateReg.value = packet[8] << 8 | packet[9]; - configDataset.setValidity(true, true); - if(internalState == InternalState::CONFIG) { - commandExecuted = true; - } - break; + return HasReturnvaluesIF::RETURN_FAILED; + } + PoolReadGuard rg(&configDataset); + configDataset.diagStatReg.value = packet[2] << 8 | packet[3]; + configDataset.filterSetting.value = packet[4] << 8 | packet[5]; + configDataset.mscCtrlReg.value = packet[6] << 8 | packet[7]; + configDataset.decRateReg.value = packet[8] << 8 | packet[9]; + configDataset.setValidity(true, true); + if (internalState == InternalState::CONFIG) { + commandExecuted = true; + } + break; } - case(ADIS1650X::READ_SENSOR_DATA): { - return handleSensorData(packet); + case (ADIS1650X::READ_SENSOR_DATA): { + return handleSensorData(packet); } - - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } - ReturnValue_t GyroADIS1650XHandler::handleSensorData(const uint8_t *packet) { - BurstModes burstMode = getBurstMode(); - switch(burstMode) { - case(BurstModes::BURST_16_BURST_SEL_1): - case(BurstModes::BURST_32_BURST_SEL_1): { - sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Analysis with BURST_SEL1" - " not implemented!" << std::endl; - return HasReturnvaluesIF::RETURN_OK; + BurstModes burstMode = getBurstMode(); + switch (burstMode) { + case (BurstModes::BURST_16_BURST_SEL_1): + case (BurstModes::BURST_32_BURST_SEL_1): { + sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Analysis with BURST_SEL1" + " not implemented!" + << std::endl; + return HasReturnvaluesIF::RETURN_OK; } - case(BurstModes::BURST_16_BURST_SEL_0): { - uint16_t checksum = packet[20] << 8 | packet[21]; - // Now verify the read checksum with the expected checksum according to datasheet p. 20 - uint16_t calcChecksum = 0; - for(size_t idx = 2; idx < 20; idx ++) { - calcChecksum += packet[idx]; - } - if(checksum != calcChecksum) { + case (BurstModes::BURST_16_BURST_SEL_0): { + uint16_t checksum = packet[20] << 8 | packet[21]; + // Now verify the read checksum with the expected checksum according to datasheet p. 20 + uint16_t calcChecksum = 0; + for (size_t idx = 2; idx < 20; idx++) { + calcChecksum += packet[idx]; + } + if (checksum != calcChecksum) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: " - "Invalid checksum detected!" << std::endl; + sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: " + "Invalid checksum detected!" + << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return HasReturnvaluesIF::RETURN_FAILED; + } + + ReturnValue_t result = configDataset.diagStatReg.read(); + if (result == HasReturnvaluesIF::RETURN_OK) { + configDataset.diagStatReg.value = packet[2] << 8 | packet[3]; + configDataset.diagStatReg.setValid(true); + } + configDataset.diagStatReg.commit(); + + { + PoolReadGuard pg(&primaryDataset); + int16_t angVelocXRaw = packet[4] << 8 | packet[5]; + primaryDataset.angVelocX.value = + static_cast(angVelocXRaw) / INT16_MAX * ADIS1650X::GYRO_RANGE; + int16_t angVelocYRaw = packet[6] << 8 | packet[7]; + primaryDataset.angVelocY.value = + static_cast(angVelocYRaw) / INT16_MAX * ADIS1650X::GYRO_RANGE; + int16_t angVelocZRaw = packet[8] << 8 | packet[9]; + primaryDataset.angVelocZ.value = + static_cast(angVelocZRaw) / INT16_MAX * ADIS1650X::GYRO_RANGE; + + float accelScaling = 0; + if (adisType == ADIS1650X::Type::ADIS16507) { + accelScaling = ADIS1650X::ACCELEROMETER_RANGE_16507; + } else if (adisType == ADIS1650X::Type::ADIS16505) { + accelScaling = ADIS1650X::ACCELEROMETER_RANGE_16505; + } else { + sif::warning << "GyroADIS1650XHandler::handleSensorData: " + "Unknown ADIS type" + << std::endl; } + int16_t accelXRaw = packet[10] << 8 | packet[11]; + primaryDataset.accelX.value = static_cast(accelXRaw) / INT16_MAX * accelScaling; + int16_t accelYRaw = packet[12] << 8 | packet[13]; + primaryDataset.accelY.value = static_cast(accelYRaw) / INT16_MAX * accelScaling; + int16_t accelZRaw = packet[14] << 8 | packet[15]; + primaryDataset.accelZ.value = static_cast(accelZRaw) / INT16_MAX * accelScaling; - ReturnValue_t result = configDataset.diagStatReg.read(); - if(result == HasReturnvaluesIF::RETURN_OK) { - configDataset.diagStatReg.value = packet[2] << 8 | packet[3]; - configDataset.diagStatReg.setValid(true); - } - configDataset.diagStatReg.commit(); - - { - PoolReadGuard pg(&primaryDataset); - int16_t angVelocXRaw = packet[4] << 8 | packet[5]; - primaryDataset.angVelocX.value = static_cast(angVelocXRaw) / INT16_MAX * - ADIS1650X::GYRO_RANGE; - int16_t angVelocYRaw = packet[6] << 8 | packet[7]; - primaryDataset.angVelocY.value = static_cast(angVelocYRaw) / INT16_MAX * - ADIS1650X::GYRO_RANGE; - int16_t angVelocZRaw = packet[8] << 8 | packet[9]; - primaryDataset.angVelocZ.value = static_cast(angVelocZRaw) / INT16_MAX * - ADIS1650X::GYRO_RANGE; - - float accelScaling = 0; - if(adisType == ADIS1650X::Type::ADIS16507) { - accelScaling = ADIS1650X::ACCELEROMETER_RANGE_16507; - } else if(adisType == ADIS1650X::Type::ADIS16505) { - accelScaling = ADIS1650X::ACCELEROMETER_RANGE_16505; - } else { - sif::warning << "GyroADIS1650XHandler::handleSensorData: " - "Unknown ADIS type" << std::endl; - } - int16_t accelXRaw = packet[10] << 8 | packet[11]; - primaryDataset.accelX.value = static_cast(accelXRaw) / INT16_MAX * - accelScaling; - int16_t accelYRaw = packet[12] << 8 | packet[13]; - primaryDataset.accelY.value = static_cast(accelYRaw) / INT16_MAX * - accelScaling; - int16_t accelZRaw = packet[14] << 8 | packet[15]; - primaryDataset.accelZ.value = static_cast(accelZRaw) / INT16_MAX * - accelScaling; - - int16_t temperatureRaw = packet[16] << 8 | packet[17]; - primaryDataset.temperature.value = static_cast(temperatureRaw) * 0.1; - // Ignore data counter for now - primaryDataset.setValidity(true, true); - } + int16_t temperatureRaw = packet[16] << 8 | packet[17]; + primaryDataset.temperature.value = static_cast(temperatureRaw) * 0.1; + // Ignore data counter for now + primaryDataset.setValidity(true, true); + } #if FSFW_HAL_ADIS1650X_GYRO_DEBUG == 1 - if(debugDivider->checkAndIncrement()) { - sif::info << "GyroADIS1650XHandler: Angular velocities in deg / s" << std::endl; - sif::info << "X: " << primaryDataset.angVelocX.value << std::endl; - sif::info << "Y: " << primaryDataset.angVelocY.value << std::endl; - sif::info << "Z: " << primaryDataset.angVelocZ.value << std::endl; - sif::info << "GyroADIS1650XHandler: Accelerations in m / s^2: " << std::endl; - sif::info << "X: " << primaryDataset.accelX.value << std::endl; - sif::info << "Y: " << primaryDataset.accelY.value << std::endl; - sif::info << "Z: " << primaryDataset.accelZ.value << std::endl; - } + if (debugDivider->checkAndIncrement()) { + sif::info << "GyroADIS1650XHandler: Angular velocities in deg / s" << std::endl; + sif::info << "X: " << primaryDataset.angVelocX.value << std::endl; + sif::info << "Y: " << primaryDataset.angVelocY.value << std::endl; + sif::info << "Z: " << primaryDataset.angVelocZ.value << std::endl; + sif::info << "GyroADIS1650XHandler: Accelerations in m / s^2: " << std::endl; + sif::info << "X: " << primaryDataset.accelX.value << std::endl; + sif::info << "Y: " << primaryDataset.accelY.value << std::endl; + sif::info << "Z: " << primaryDataset.accelZ.value << std::endl; + } #endif - break; + break; } - case(BurstModes::BURST_32_BURST_SEL_0): { - break; + case (BurstModes::BURST_32_BURST_SEL_0): { + break; } - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } uint32_t GyroADIS1650XHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { - return 10000; + return 10000; } void GyroADIS1650XHandler::prepareWriteCommand(uint8_t startReg, uint8_t valueOne, - uint8_t valueTwo) { - uint8_t secondReg = startReg + 1; - startReg |= ADIS1650X::WRITE_MASK; - secondReg |= ADIS1650X::WRITE_MASK; - commandBuffer[0] = startReg; - commandBuffer[1] = valueOne; - commandBuffer[2] = secondReg; - commandBuffer[3] = valueTwo; - this->rawPacketLen = 4; - this->rawPacket = commandBuffer.data(); + uint8_t valueTwo) { + uint8_t secondReg = startReg + 1; + startReg |= ADIS1650X::WRITE_MASK; + secondReg |= ADIS1650X::WRITE_MASK; + commandBuffer[0] = startReg; + commandBuffer[1] = valueOne; + commandBuffer[2] = secondReg; + commandBuffer[3] = valueTwo; + this->rawPacketLen = 4; + this->rawPacket = commandBuffer.data(); } void GyroADIS1650XHandler::prepareReadCommand(uint8_t *regList, size_t len) { - for(size_t idx = 0; idx < len; idx++) { - commandBuffer[idx * 2] = regList[idx]; - commandBuffer[idx * 2 + 1] = 0x00; - } - commandBuffer[len * 2] = 0x00; - commandBuffer[len * 2 + 1] = 0x00; + for (size_t idx = 0; idx < len; idx++) { + commandBuffer[idx * 2] = regList[idx]; + commandBuffer[idx * 2 + 1] = 0x00; + } + commandBuffer[len * 2] = 0x00; + commandBuffer[len * 2 + 1] = 0x00; } ReturnValue_t GyroADIS1650XHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) { - localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_X, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_Y, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_Z, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS1650X::ACCELERATION_X, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS1650X::ACCELERATION_Y, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS1650X::ACCELERATION_Z, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS1650X::TEMPERATURE, new PoolEntry({0.0})); + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_X, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_Y, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_Z, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::ACCELERATION_X, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::ACCELERATION_Y, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::ACCELERATION_Z, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::TEMPERATURE, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS1650X::DIAG_STAT_REGISTER, new PoolEntry()); - localDataPoolMap.emplace(ADIS1650X::FILTER_SETTINGS, new PoolEntry()); - localDataPoolMap.emplace(ADIS1650X::MSC_CTRL_REGISTER, new PoolEntry()); - localDataPoolMap.emplace(ADIS1650X::DEC_RATE_REGISTER, new PoolEntry()); - return HasReturnvaluesIF::RETURN_OK; + localDataPoolMap.emplace(ADIS1650X::DIAG_STAT_REGISTER, new PoolEntry()); + localDataPoolMap.emplace(ADIS1650X::FILTER_SETTINGS, new PoolEntry()); + localDataPoolMap.emplace(ADIS1650X::MSC_CTRL_REGISTER, new PoolEntry()); + localDataPoolMap.emplace(ADIS1650X::DEC_RATE_REGISTER, new PoolEntry()); + return HasReturnvaluesIF::RETURN_OK; } GyroADIS1650XHandler::BurstModes GyroADIS1650XHandler::getBurstMode() { - configDataset.mscCtrlReg.read(); - uint16_t currentCtrlReg = configDataset.mscCtrlReg.value; - configDataset.mscCtrlReg.commit(); - if((currentCtrlReg & ADIS1650X::BURST_32_BIT) == ADIS1650X::BURST_32_BIT) { - if((currentCtrlReg & ADIS1650X::BURST_SEL_BIT) == ADIS1650X::BURST_SEL_BIT) { - return BurstModes::BURST_32_BURST_SEL_1; - } - else { - return BurstModes::BURST_32_BURST_SEL_0; - } + configDataset.mscCtrlReg.read(); + uint16_t currentCtrlReg = configDataset.mscCtrlReg.value; + configDataset.mscCtrlReg.commit(); + if ((currentCtrlReg & ADIS1650X::BURST_32_BIT) == ADIS1650X::BURST_32_BIT) { + if ((currentCtrlReg & ADIS1650X::BURST_SEL_BIT) == ADIS1650X::BURST_SEL_BIT) { + return BurstModes::BURST_32_BURST_SEL_1; + } else { + return BurstModes::BURST_32_BURST_SEL_0; } - else { - if((currentCtrlReg & ADIS1650X::BURST_SEL_BIT) == ADIS1650X::BURST_SEL_BIT) { - return BurstModes::BURST_16_BURST_SEL_1; - } - else { - return BurstModes::BURST_16_BURST_SEL_0; - } + } else { + if ((currentCtrlReg & ADIS1650X::BURST_SEL_BIT) == ADIS1650X::BURST_SEL_BIT) { + return BurstModes::BURST_16_BURST_SEL_1; + } else { + return BurstModes::BURST_16_BURST_SEL_0; } + } } #if OBSW_ADIS1650X_LINUX_COM_IF == 1 ReturnValue_t GyroADIS1650XHandler::spiSendCallback(SpiComIF *comIf, SpiCookie *cookie, - const uint8_t *sendData, size_t sendLen, void *args) { - GyroADIS1650XHandler* handler = reinterpret_cast(args); - if(handler == nullptr) { - sif::error << "GyroADIS16507Handler::spiSendCallback: Passed handler pointer is invalid!" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; + const uint8_t *sendData, size_t sendLen, + void *args) { + GyroADIS1650XHandler *handler = reinterpret_cast(args); + if (handler == nullptr) { + sif::error << "GyroADIS16507Handler::spiSendCallback: Passed handler pointer is invalid!" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + DeviceCommandId_t currentCommand = handler->getPendingCommand(); + switch (currentCommand) { + case (ADIS1650X::READ_SENSOR_DATA): { + return comIf->performRegularSendOperation(cookie, sendData, sendLen); } - DeviceCommandId_t currentCommand = handler->getPendingCommand(); - switch(currentCommand) { - case(ADIS1650X::READ_SENSOR_DATA): { - return comIf->performRegularSendOperation(cookie, sendData, sendLen); - } - case(ADIS1650X::READ_OUT_CONFIG): + case (ADIS1650X::READ_OUT_CONFIG): default: { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - int retval = 0; - // Prepare transfer - int fileDescriptor = 0; - std::string device = cookie->getSpiDevice(); - UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "SpiComIF::sendMessage"); - if(fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { - return SpiComIF::OPENING_FILE_FAILED; - } - spi::SpiModes spiMode = spi::SpiModes::MODE_0; - uint32_t spiSpeed = 0; - cookie->getSpiParameters(spiMode, spiSpeed, nullptr); - comIf->setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); - cookie->assignWriteBuffer(sendData); - cookie->setTransferSize(2); + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + int retval = 0; + // Prepare transfer + int fileDescriptor = 0; + std::string device = cookie->getSpiDevice(); + UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "SpiComIF::sendMessage"); + if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { + return SpiComIF::OPENING_FILE_FAILED; + } + spi::SpiModes spiMode = spi::SpiModes::MODE_0; + uint32_t spiSpeed = 0; + cookie->getSpiParameters(spiMode, spiSpeed, nullptr); + comIf->setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); + cookie->assignWriteBuffer(sendData); + cookie->setTransferSize(2); - gpioId_t gpioId = cookie->getChipSelectPin(); - GpioIF* gpioIF = comIf->getGpioInterface(); - MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; - uint32_t timeoutMs = 0; - MutexIF* mutex = comIf->getMutex(&timeoutType, &timeoutMs); - if(mutex == nullptr or gpioIF == nullptr) { + gpioId_t gpioId = cookie->getChipSelectPin(); + GpioIF *gpioIF = comIf->getGpioInterface(); + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; + uint32_t timeoutMs = 0; + MutexIF *mutex = comIf->getMutex(&timeoutType, &timeoutMs); + if (mutex == nullptr or gpioIF == nullptr) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::warning << "GyroADIS16507Handler::spiSendCallback: " - "Mutex or GPIO interface invalid" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; + sif::warning << "GyroADIS16507Handler::spiSendCallback: " + "Mutex or GPIO interface invalid" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; #endif - } + } - if(gpioId != gpio::NO_GPIO) { - result = mutex->lockMutex(timeoutType, timeoutMs); - if (result != RETURN_OK) { + if (gpioId != gpio::NO_GPIO) { + result = mutex->lockMutex(timeoutType, timeoutMs); + if (result != RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "SpiComIF::sendMessage: Failed to lock mutex" << std::endl; + sif::error << "SpiComIF::sendMessage: Failed to lock mutex" << std::endl; #endif - return result; - } + return result; + } + } + + size_t idx = 0; + while (idx < sendLen) { + // Pull SPI CS low. For now, no support for active high given + if (gpioId != gpio::NO_GPIO) { + gpioIF->pullLow(gpioId); } - size_t idx = 0; - while(idx < sendLen) { - // Pull SPI CS low. For now, no support for active high given - if(gpioId != gpio::NO_GPIO) { - gpioIF->pullLow(gpioId); - } - - // Execute transfer - // Initiate a full duplex SPI transfer. - retval = ioctl(fileDescriptor, SPI_IOC_MESSAGE(1), cookie->getTransferStructHandle()); - if(retval < 0) { - utility::handleIoctlError("SpiComIF::sendMessage: ioctl error."); - result = SpiComIF::FULL_DUPLEX_TRANSFER_FAILED; - } + // Execute transfer + // Initiate a full duplex SPI transfer. + retval = ioctl(fileDescriptor, SPI_IOC_MESSAGE(1), cookie->getTransferStructHandle()); + if (retval < 0) { + utility::handleIoctlError("SpiComIF::sendMessage: ioctl error."); + result = SpiComIF::FULL_DUPLEX_TRANSFER_FAILED; + } #if FSFW_HAL_SPI_WIRETAPPING == 1 - comIf->performSpiWiretapping(cookie); + comIf->performSpiWiretapping(cookie); #endif /* FSFW_LINUX_SPI_WIRETAPPING == 1 */ - if(gpioId != gpio::NO_GPIO) { - gpioIF->pullHigh(gpioId); - } - - idx += 2; - if(idx < sendLen) { - usleep(ADIS1650X::STALL_TIME_MICROSECONDS); - } - spi_ioc_transfer* transferStruct = cookie->getTransferStructHandle(); - transferStruct->tx_buf += 2; - transferStruct->rx_buf += 2; + if (gpioId != gpio::NO_GPIO) { + gpioIF->pullHigh(gpioId); } - if(gpioId != gpio::NO_GPIO) { - mutex->unlockMutex(); + idx += 2; + if (idx < sendLen) { + usleep(ADIS1650X::STALL_TIME_MICROSECONDS); } + spi_ioc_transfer *transferStruct = cookie->getTransferStructHandle(); + transferStruct->tx_buf += 2; + transferStruct->rx_buf += 2; + } + + if (gpioId != gpio::NO_GPIO) { + mutex->unlockMutex(); + } } - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } #endif /* OBSW_ADIS1650X_LINUX_COM_IF == 1 */ diff --git a/mission/devices/GyroADIS1650XHandler.h b/mission/devices/GyroADIS1650XHandler.h index b1ac50f5..c1f9ae98 100644 --- a/mission/devices/GyroADIS1650XHandler.h +++ b/mission/devices/GyroADIS1650XHandler.h @@ -1,12 +1,11 @@ #ifndef MISSION_DEVICES_GYROADIS16507HANDLER_H_ #define MISSION_DEVICES_GYROADIS16507HANDLER_H_ -#include "OBSWConfig.h" #include "FSFWConfig.h" +#include "OBSWConfig.h" #include "devicedefinitions/GyroADIS1650XDefinitions.h" - -#include "fsfw/globalfunctions/PeriodicOperationDivider.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" +#include "fsfw/globalfunctions/PeriodicOperationDivider.h" #if OBSW_ADIS1650X_LINUX_COM_IF == 1 class SpiComIF; @@ -19,67 +18,60 @@ class SpiCookie; * Flight manual: * https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/ADIS16507_Gyro */ -class GyroADIS1650XHandler: public DeviceHandlerBase { -public: - GyroADIS1650XHandler(object_id_t objectId, object_id_t deviceCommunication, - CookieIF* comCookie, ADIS1650X::Type type); +class GyroADIS1650XHandler : public DeviceHandlerBase { + public: + GyroADIS1650XHandler(object_id_t objectId, object_id_t deviceCommunication, CookieIF *comCookie, + ADIS1650X::Type type); - // DeviceHandlerBase abstract function implementation - void doStartUp() override; - void doShutDown() override; - ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; - ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override; - ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t * commandData, size_t commandDataLen) override; - void fillCommandAndReplyMap() 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; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) override; + // DeviceHandlerBase abstract function implementation + void doStartUp() override; + void doShutDown() override; + ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, + size_t commandDataLen) override; + void fillCommandAndReplyMap() 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; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) override; -private: - std::array commandBuffer; - ADIS1650X::Type adisType; - AdisGyroPrimaryDataset primaryDataset; - AdisGyroConfigDataset configDataset; + private: + std::array commandBuffer; + ADIS1650X::Type adisType; + AdisGyroPrimaryDataset primaryDataset; + AdisGyroConfigDataset configDataset; - enum class InternalState { - STARTUP, - CONFIG, - IDLE - }; + enum class InternalState { STARTUP, CONFIG, IDLE }; - enum class BurstModes { - BURST_16_BURST_SEL_0, - BURST_16_BURST_SEL_1, - BURST_32_BURST_SEL_0, - BURST_32_BURST_SEL_1 - }; + enum class BurstModes { + BURST_16_BURST_SEL_0, + BURST_16_BURST_SEL_1, + BURST_32_BURST_SEL_0, + BURST_32_BURST_SEL_1 + }; - InternalState internalState = InternalState::STARTUP; - bool commandExecuted = false; + InternalState internalState = InternalState::STARTUP; + bool commandExecuted = false; - void prepareReadCommand(uint8_t* regList, size_t len); + void prepareReadCommand(uint8_t *regList, size_t len); - BurstModes getBurstMode(); + BurstModes getBurstMode(); #if OBSW_ADIS1650X_LINUX_COM_IF == 1 - static ReturnValue_t spiSendCallback(SpiComIF* comIf, SpiCookie *cookie, - const uint8_t *sendData, size_t sendLen, void* args); + static ReturnValue_t spiSendCallback(SpiComIF *comIf, SpiCookie *cookie, const uint8_t *sendData, + size_t sendLen, void *args); #endif #if FSFW_HAL_ADIS1650X_GYRO_DEBUG == 1 - PeriodicOperationDivider* debugDivider; + PeriodicOperationDivider *debugDivider; #endif - Countdown breakCountdown; - void prepareWriteCommand(uint8_t startReg, uint8_t valueOne, uint8_t valueTwo); + Countdown breakCountdown; + void prepareWriteCommand(uint8_t startReg, uint8_t valueOne, uint8_t valueTwo); - ReturnValue_t handleSensorData(const uint8_t* packet); + ReturnValue_t handleSensorData(const uint8_t *packet); }; - - #endif /* MISSION_DEVICES_GYROADIS16507HANDLER_H_ */ diff --git a/mission/devices/HeaterHandler.cpp b/mission/devices/HeaterHandler.cpp index 60a60328..572810bd 100644 --- a/mission/devices/HeaterHandler.cpp +++ b/mission/devices/HeaterHandler.cpp @@ -1,373 +1,346 @@ #include "HeaterHandler.h" + +#include +#include +#include + #include "devices/gpioIds.h" #include "devices/powerSwitcherList.h" -#include -#include -#include - HeaterHandler::HeaterHandler(object_id_t setObjectId_, object_id_t gpioDriverId_, - CookieIF * gpioCookie_, object_id_t mainLineSwitcherObjectId_, uint8_t mainLineSwitch_) : - SystemObject(setObjectId_), gpioDriverId(gpioDriverId_), gpioCookie(gpioCookie_), - mainLineSwitcherObjectId(mainLineSwitcherObjectId_), mainLineSwitch(mainLineSwitch_), - actionHelper(this, nullptr) { - commandQueue = QueueFactory::instance()->createMessageQueue(cmdQueueSize, - MessageQueueMessage::MAX_MESSAGE_SIZE); + CookieIF* gpioCookie_, object_id_t mainLineSwitcherObjectId_, + uint8_t mainLineSwitch_) + : SystemObject(setObjectId_), + gpioDriverId(gpioDriverId_), + gpioCookie(gpioCookie_), + mainLineSwitcherObjectId(mainLineSwitcherObjectId_), + mainLineSwitch(mainLineSwitch_), + actionHelper(this, nullptr) { + commandQueue = QueueFactory::instance()->createMessageQueue( + cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE); } -HeaterHandler::~HeaterHandler() { -} +HeaterHandler::~HeaterHandler() {} ReturnValue_t HeaterHandler::performOperation(uint8_t operationCode) { - - if (operationCode == DeviceHandlerIF::PERFORM_OPERATION) { - readCommandQueue(); - handleActiveCommands(); - return RETURN_OK; - } - return RETURN_OK; + if (operationCode == DeviceHandlerIF::PERFORM_OPERATION) { + readCommandQueue(); + handleActiveCommands(); + return RETURN_OK; + } + return RETURN_OK; } ReturnValue_t HeaterHandler::initialize() { - ReturnValue_t result = SystemObject::initialize(); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + ReturnValue_t result = SystemObject::initialize(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = initializeHeaterMap(); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = initializeHeaterMap(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - gpioInterface = ObjectManager::instance()->get(gpioDriverId); - if (gpioInterface == nullptr) { - sif::error << "HeaterHandler::initialize: Invalid Gpio interface." << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + gpioInterface = ObjectManager::instance()->get(gpioDriverId); + if (gpioInterface == nullptr) { + sif::error << "HeaterHandler::initialize: Invalid Gpio interface." << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = gpioInterface->addGpios(dynamic_cast(gpioCookie)); - if (result != RETURN_OK) { - sif::error << "HeaterHandler::initialize: Failed to initialize Gpio interface" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = gpioInterface->addGpios(dynamic_cast(gpioCookie)); + if (result != RETURN_OK) { + sif::error << "HeaterHandler::initialize: Failed to initialize Gpio interface" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); - if (IPCStore == nullptr) { - sif::error << "HeaterHandler::initialize: IPC store not set up in factory." << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); + if (IPCStore == nullptr) { + sif::error << "HeaterHandler::initialize: IPC store not set up in factory." << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - if(mainLineSwitcherObjectId != objects::NO_OBJECT) { - mainLineSwitcher = ObjectManager::instance()->get(mainLineSwitcherObjectId); - if (mainLineSwitcher == nullptr) { - sif::error - << "HeaterHandler::initialize: Failed to get main line switcher. Make sure " - << "main line switcher object is initialized." << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } - } + if (mainLineSwitcherObjectId != objects::NO_OBJECT) { + mainLineSwitcher = ObjectManager::instance()->get(mainLineSwitcherObjectId); + if (mainLineSwitcher == nullptr) { + sif::error << "HeaterHandler::initialize: Failed to get main line switcher. Make sure " + << "main line switcher object is initialized." << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } + } - result = actionHelper.initialize(commandQueue); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = actionHelper.initialize(commandQueue); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - return RETURN_OK; + return RETURN_OK; } -ReturnValue_t HeaterHandler::initializeHeaterMap(){ - HeaterCommandInfo_t heaterCommandInfo; - for(switchNr_t switchNr = 0; switchNr < heaterSwitches::NUMBER_OF_SWITCHES; switchNr++) { - std::pair status = heaterMap.emplace(switchNr, heaterCommandInfo); - if (status.second == false) { - sif::error << "HeaterHandler::initializeHeaterMap: Failed to initialize heater map" - << std::endl; - return RETURN_FAILED; - } - } - return RETURN_OK; +ReturnValue_t HeaterHandler::initializeHeaterMap() { + HeaterCommandInfo_t heaterCommandInfo; + for (switchNr_t switchNr = 0; switchNr < heaterSwitches::NUMBER_OF_SWITCHES; switchNr++) { + std::pair status = heaterMap.emplace(switchNr, heaterCommandInfo); + if (status.second == false) { + sif::error << "HeaterHandler::initializeHeaterMap: Failed to initialize heater map" + << std::endl; + return RETURN_FAILED; + } + } + return RETURN_OK; } void HeaterHandler::setInitialSwitchStates() { - for (switchNr_t switchNr = 0; switchNr < heaterSwitches::NUMBER_OF_SWITCHES; switchNr++) { - switchStates[switchNr] = OFF; - } + for (switchNr_t switchNr = 0; switchNr < heaterSwitches::NUMBER_OF_SWITCHES; switchNr++) { + switchStates[switchNr] = OFF; + } } void HeaterHandler::readCommandQueue() { - CommandMessage command; - ReturnValue_t result = commandQueue->receiveMessage(&command); - if (result != RETURN_OK) { - return; - } + CommandMessage command; + ReturnValue_t result = commandQueue->receiveMessage(&command); + if (result != RETURN_OK) { + return; + } - result = actionHelper.handleActionMessage(&command); - if (result == RETURN_OK) { - return; - } + result = actionHelper.handleActionMessage(&command); + if (result == RETURN_OK) { + return; + } } -ReturnValue_t HeaterHandler::executeAction(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { - ReturnValue_t result; - if (actionId != SWITCH_HEATER) { - result = COMMAND_NOT_SUPPORTED; - } else { - switchNr_t switchNr = *data; - HeaterMapIter heaterMapIter = heaterMap.find(switchNr); - if (heaterMapIter != heaterMap.end()) { - if (heaterMapIter->second.active) { - return COMMAND_ALREADY_WAITING; - } - heaterMapIter->second.action = *(data + 1); - heaterMapIter->second.active = true; - heaterMapIter->second.replyQueue = commandedBy; - } - else { - sif::error << "HeaterHandler::executeAction: Invalid switchNr" << std::endl; - return INVALID_SWITCH_NR; - } - result = RETURN_OK; - } - return result; +ReturnValue_t HeaterHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) { + ReturnValue_t result; + if (actionId != SWITCH_HEATER) { + result = COMMAND_NOT_SUPPORTED; + } else { + switchNr_t switchNr = *data; + HeaterMapIter heaterMapIter = heaterMap.find(switchNr); + if (heaterMapIter != heaterMap.end()) { + if (heaterMapIter->second.active) { + return COMMAND_ALREADY_WAITING; + } + heaterMapIter->second.action = *(data + 1); + heaterMapIter->second.active = true; + heaterMapIter->second.replyQueue = commandedBy; + } else { + sif::error << "HeaterHandler::executeAction: Invalid switchNr" << std::endl; + return INVALID_SWITCH_NR; + } + result = RETURN_OK; + } + return result; } +void HeaterHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const { + ReturnValue_t result; + store_address_t storeAddress; + uint8_t commandData[2]; -void HeaterHandler::sendSwitchCommand(uint8_t switchNr, - ReturnValue_t onOff) const { + switch (onOff) { + case PowerSwitchIF::SWITCH_ON: + commandData[0] = switchNr; + commandData[1] = SET_SWITCH_ON; + break; + case PowerSwitchIF::SWITCH_OFF: + commandData[0] = switchNr; + commandData[1] = SET_SWITCH_OFF; + break; + default: + sif::error << "HeaterHandler::sendSwitchCommand: Invalid switch request" << std::endl; + break; + } - ReturnValue_t result; - store_address_t storeAddress; - uint8_t commandData[2]; - - switch(onOff) { - case PowerSwitchIF::SWITCH_ON: - commandData[0] = switchNr; - commandData[1] = SET_SWITCH_ON; - break; - case PowerSwitchIF::SWITCH_OFF: - commandData[0] = switchNr; - commandData[1] = SET_SWITCH_OFF; - break; - default: - sif::error << "HeaterHandler::sendSwitchCommand: Invalid switch request" - << std::endl; - break; - } - - result = IPCStore->addData(&storeAddress, commandData, sizeof(commandData)); - if (result == RETURN_OK) { - CommandMessage message; - ActionMessage::setCommand(&message, SWITCH_HEATER, storeAddress); - /* Send heater command to own command queue */ - result = commandQueue->sendMessage(commandQueue->getId(), &message, 0); - if (result != RETURN_OK) { - sif::debug << "HeaterHandler::sendSwitchCommand: Failed to send switch" - << "message" << std::endl; - } - } + result = IPCStore->addData(&storeAddress, commandData, sizeof(commandData)); + if (result == RETURN_OK) { + CommandMessage message; + ActionMessage::setCommand(&message, SWITCH_HEATER, storeAddress); + /* Send heater command to own command queue */ + result = commandQueue->sendMessage(commandQueue->getId(), &message, 0); + if (result != RETURN_OK) { + sif::debug << "HeaterHandler::sendSwitchCommand: Failed to send switch" + << "message" << std::endl; + } + } } -void HeaterHandler::handleActiveCommands(){ - - HeaterMapIter heaterMapIter = heaterMap.begin(); - for (; heaterMapIter != heaterMap.end(); heaterMapIter++) { - if (heaterMapIter->second.active) { - switch(heaterMapIter->second.action) { - case SET_SWITCH_ON: - handleSwitchOnCommand(heaterMapIter); - break; - case SET_SWITCH_OFF: - handleSwitchOffCommand(heaterMapIter); - break; - default: - sif::error << "HeaterHandler::handleActiveCommands: Invalid action commanded" - << std::endl; - break; - } - } - } +void HeaterHandler::handleActiveCommands() { + HeaterMapIter heaterMapIter = heaterMap.begin(); + for (; heaterMapIter != heaterMap.end(); heaterMapIter++) { + if (heaterMapIter->second.active) { + switch (heaterMapIter->second.action) { + case SET_SWITCH_ON: + handleSwitchOnCommand(heaterMapIter); + break; + case SET_SWITCH_OFF: + handleSwitchOffCommand(heaterMapIter); + break; + default: + sif::error << "HeaterHandler::handleActiveCommands: Invalid action commanded" + << std::endl; + break; + } + } + } } void HeaterHandler::handleSwitchOnCommand(HeaterMapIter heaterMapIter) { + ReturnValue_t result = RETURN_OK; + switchNr_t switchNr; - ReturnValue_t result = RETURN_OK; - switchNr_t switchNr; + /* Check if command waits for main switch being set on and whether the timeout has expired */ + if (heaterMapIter->second.waitMainSwitchOn && + heaterMapIter->second.mainSwitchCountdown.hasTimedOut()) { + // TODO - This requires the initiation of an FDIR procedure + triggerEvent(MAIN_SWITCH_TIMEOUT); + sif::error << "HeaterHandler::handleSwitchOnCommand: Main switch setting on timeout" + << std::endl; + heaterMapIter->second.active = false; + heaterMapIter->second.waitMainSwitchOn = false; + if (heaterMapIter->second.replyQueue != commandQueue->getId()) { + actionHelper.finish(false, heaterMapIter->second.replyQueue, heaterMapIter->second.action, + MAIN_SWITCH_SET_TIMEOUT); + } + return; + } - /* Check if command waits for main switch being set on and whether the timeout has expired */ - if (heaterMapIter->second.waitMainSwitchOn - && heaterMapIter->second.mainSwitchCountdown.hasTimedOut()) { - //TODO - This requires the initiation of an FDIR procedure - triggerEvent(MAIN_SWITCH_TIMEOUT); - sif::error << "HeaterHandler::handleSwitchOnCommand: Main switch setting on timeout" - << std::endl; - heaterMapIter->second.active = false; - heaterMapIter->second.waitMainSwitchOn = false; - if (heaterMapIter->second.replyQueue != commandQueue->getId()) { - actionHelper.finish(false, heaterMapIter->second.replyQueue, - heaterMapIter->second.action, MAIN_SWITCH_SET_TIMEOUT ); - } - return; + switchNr = heaterMapIter->first; + /* Check state of main line switch */ + ReturnValue_t mainSwitchState = mainLineSwitcher->getSwitchState(mainLineSwitch); + if (mainSwitchState == PowerSwitchIF::SWITCH_ON) { + if (!checkSwitchState(switchNr)) { + gpioId_t gpioId = getGpioIdFromSwitchNr(switchNr); + result = gpioInterface->pullHigh(gpioId); + if (result != RETURN_OK) { + sif::error << "HeaterHandler::handleSwitchOnCommand: Failed to pull gpio with id " << gpioId + << " high" << std::endl; + triggerEvent(GPIO_PULL_HIGH_FAILED, result); + } else { + switchStates[switchNr] = ON; + } + } else { + triggerEvent(SWITCH_ALREADY_ON, switchNr); } - - switchNr = heaterMapIter->first; - /* Check state of main line switch */ - ReturnValue_t mainSwitchState = mainLineSwitcher->getSwitchState(mainLineSwitch); - if (mainSwitchState == PowerSwitchIF::SWITCH_ON) { - if (!checkSwitchState(switchNr)) { - gpioId_t gpioId = getGpioIdFromSwitchNr(switchNr); - result = gpioInterface->pullHigh(gpioId); - if (result != RETURN_OK) { - sif::error << "HeaterHandler::handleSwitchOnCommand: Failed to pull gpio with id " - << gpioId << " high" << std::endl; - triggerEvent(GPIO_PULL_HIGH_FAILED, result); - } - else { - switchStates[switchNr] = ON; - } - } - else { - triggerEvent(SWITCH_ALREADY_ON, switchNr); - } - /* There is no need to send action finish replies if the sender was the - * HeaterHandler itself. */ - if (heaterMapIter->second.replyQueue != commandQueue->getId()) { - if(result == RETURN_OK) { - actionHelper.finish(true, heaterMapIter->second.replyQueue, - heaterMapIter->second.action, result); - } - else { - actionHelper.finish(false, heaterMapIter->second.replyQueue, - heaterMapIter->second.action, result); - } - - } - heaterMapIter->second.active = false; - heaterMapIter->second.waitMainSwitchOn = false; + /* There is no need to send action finish replies if the sender was the + * HeaterHandler itself. */ + if (heaterMapIter->second.replyQueue != commandQueue->getId()) { + if (result == RETURN_OK) { + actionHelper.finish(true, heaterMapIter->second.replyQueue, heaterMapIter->second.action, + result); + } else { + actionHelper.finish(false, heaterMapIter->second.replyQueue, heaterMapIter->second.action, + result); + } } - else if (mainSwitchState == PowerSwitchIF::SWITCH_OFF - && heaterMapIter->second.waitMainSwitchOn) { - /* Just waiting for the main switch being set on */ - return; - } - else if (mainSwitchState == PowerSwitchIF::SWITCH_OFF) { - mainLineSwitcher->sendSwitchCommand(mainLineSwitch, - PowerSwitchIF::SWITCH_ON); - heaterMapIter->second.mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs()); - heaterMapIter->second.waitMainSwitchOn = true; - } - else { - sif::debug << "HeaterHandler::handleActiveCommands: Failed to get state of" - << " main line switch" << std::endl; - if (heaterMapIter->second.replyQueue != commandQueue->getId()) { - actionHelper.finish(false, heaterMapIter->second.replyQueue, - heaterMapIter->second.action, mainSwitchState); - } - heaterMapIter->second.active = false; + heaterMapIter->second.active = false; + heaterMapIter->second.waitMainSwitchOn = false; + } else if (mainSwitchState == PowerSwitchIF::SWITCH_OFF && + heaterMapIter->second.waitMainSwitchOn) { + /* Just waiting for the main switch being set on */ + return; + } else if (mainSwitchState == PowerSwitchIF::SWITCH_OFF) { + mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_ON); + heaterMapIter->second.mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs()); + heaterMapIter->second.waitMainSwitchOn = true; + } else { + sif::debug << "HeaterHandler::handleActiveCommands: Failed to get state of" + << " main line switch" << std::endl; + if (heaterMapIter->second.replyQueue != commandQueue->getId()) { + actionHelper.finish(false, heaterMapIter->second.replyQueue, heaterMapIter->second.action, + mainSwitchState); } + heaterMapIter->second.active = false; + } } void HeaterHandler::handleSwitchOffCommand(HeaterMapIter heaterMapIter) { - ReturnValue_t result = RETURN_OK; - switchNr_t switchNr = heaterMapIter->first; - /* Check whether switch is already off */ - if (checkSwitchState(switchNr)) { - gpioId_t gpioId = getGpioIdFromSwitchNr(switchNr); - result = gpioInterface->pullLow(gpioId); - if (result != RETURN_OK) { - sif::error << "HeaterHandler::handleSwitchOffCommand: Failed to pull gpio with id" - << gpioId << " low" << std::endl; - triggerEvent(GPIO_PULL_LOW_FAILED, result); - } - else { - switchStates[switchNr] = OFF; - /* When all switches are off, also main line switch will be turned off */ - if (allSwitchesOff()) { - mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); - } - } + ReturnValue_t result = RETURN_OK; + switchNr_t switchNr = heaterMapIter->first; + /* Check whether switch is already off */ + if (checkSwitchState(switchNr)) { + gpioId_t gpioId = getGpioIdFromSwitchNr(switchNr); + result = gpioInterface->pullLow(gpioId); + if (result != RETURN_OK) { + sif::error << "HeaterHandler::handleSwitchOffCommand: Failed to pull gpio with id" << gpioId + << " low" << std::endl; + triggerEvent(GPIO_PULL_LOW_FAILED, result); + } else { + switchStates[switchNr] = OFF; + /* When all switches are off, also main line switch will be turned off */ + if (allSwitchesOff()) { + mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); + } } - else { - sif::info << "HeaterHandler::handleSwitchOffCommand: Switch already off" << std::endl; - triggerEvent(SWITCH_ALREADY_OFF, switchNr); + } else { + sif::info << "HeaterHandler::handleSwitchOffCommand: Switch already off" << std::endl; + triggerEvent(SWITCH_ALREADY_OFF, switchNr); + } + if (heaterMapIter->second.replyQueue != NO_COMMANDER) { + /* Report back switch command reply if necessary */ + if (result == HasReturnvaluesIF::RETURN_OK) { + actionHelper.finish(true, heaterMapIter->second.replyQueue, heaterMapIter->second.action, + result); + } else { + actionHelper.finish(false, heaterMapIter->second.replyQueue, heaterMapIter->second.action, + result); } - if (heaterMapIter->second.replyQueue != NO_COMMANDER) { - /* Report back switch command reply if necessary */ - if(result == HasReturnvaluesIF::RETURN_OK) { - actionHelper.finish(true, heaterMapIter->second.replyQueue, - heaterMapIter->second.action, result); - } - else { - actionHelper.finish(false, heaterMapIter->second.replyQueue, - heaterMapIter->second.action, result); - } - } - heaterMapIter->second.active = false; + } + heaterMapIter->second.active = false; } -bool HeaterHandler::checkSwitchState(int switchNr) { - return switchStates[switchNr]; -} +bool HeaterHandler::checkSwitchState(int switchNr) { return switchStates[switchNr]; } bool HeaterHandler::allSwitchesOff() { - bool allSwitchesOrd = false; - /* Or all switches. As soon one switch is on, allSwitchesOrd will be true */ - for (switchNr_t switchNr = 0; switchNr < heaterSwitches::NUMBER_OF_SWITCHES; switchNr++) { - allSwitchesOrd = allSwitchesOrd || switchStates[switchNr]; - } - return !allSwitchesOrd; + bool allSwitchesOrd = false; + /* Or all switches. As soon one switch is on, allSwitchesOrd will be true */ + for (switchNr_t switchNr = 0; switchNr < heaterSwitches::NUMBER_OF_SWITCHES; switchNr++) { + allSwitchesOrd = allSwitchesOrd || switchStates[switchNr]; + } + return !allSwitchesOrd; } gpioId_t HeaterHandler::getGpioIdFromSwitchNr(int switchNr) { - gpioId_t gpioId = 0xFFFF; - switch(switchNr) { + gpioId_t gpioId = 0xFFFF; + switch (switchNr) { case heaterSwitches::HEATER_0: - gpioId = gpioIds::HEATER_0; - break; + gpioId = gpioIds::HEATER_0; + break; case heaterSwitches::HEATER_1: - gpioId = gpioIds::HEATER_1; - break; + gpioId = gpioIds::HEATER_1; + break; case heaterSwitches::HEATER_2: - gpioId = gpioIds::HEATER_2; - break; + gpioId = gpioIds::HEATER_2; + break; case heaterSwitches::HEATER_3: - gpioId = gpioIds::HEATER_3; - break; + gpioId = gpioIds::HEATER_3; + break; case heaterSwitches::HEATER_4: - gpioId = gpioIds::HEATER_4; - break; + gpioId = gpioIds::HEATER_4; + break; case heaterSwitches::HEATER_5: - gpioId = gpioIds::HEATER_5; - break; + gpioId = gpioIds::HEATER_5; + break; case heaterSwitches::HEATER_6: - gpioId = gpioIds::HEATER_6; - break; + gpioId = gpioIds::HEATER_6; + break; case heaterSwitches::HEATER_7: - gpioId = gpioIds::HEATER_7; - break; + gpioId = gpioIds::HEATER_7; + break; default: - sif::error << "HeaterHandler::getGpioIdFromSwitchNr: Unknown heater switch number" - << std::endl; - break; - } - return gpioId; + sif::error << "HeaterHandler::getGpioIdFromSwitchNr: Unknown heater switch number" + << std::endl; + break; + } + return gpioId; } -MessageQueueId_t HeaterHandler::getCommandQueue() const { - return commandQueue->getId(); -} +MessageQueueId_t HeaterHandler::getCommandQueue() const { return commandQueue->getId(); } -void HeaterHandler::sendFuseOnCommand(uint8_t fuseNr) const { -} +void HeaterHandler::sendFuseOnCommand(uint8_t fuseNr) const {} -ReturnValue_t HeaterHandler::getSwitchState( uint8_t switchNr ) const { - return 0; -} +ReturnValue_t HeaterHandler::getSwitchState(uint8_t switchNr) const { return 0; } -ReturnValue_t HeaterHandler::getFuseState( uint8_t fuseNr ) const { - return 0; -} +ReturnValue_t HeaterHandler::getFuseState(uint8_t fuseNr) const { return 0; } -uint32_t HeaterHandler::getSwitchDelayMs(void) const { - return 0; -} +uint32_t HeaterHandler::getSwitchDelayMs(void) const { return 0; } diff --git a/mission/devices/HeaterHandler.h b/mission/devices/HeaterHandler.h index b52e22d4..2a8ce555 100644 --- a/mission/devices/HeaterHandler.h +++ b/mission/devices/HeaterHandler.h @@ -1,177 +1,169 @@ #ifndef MISSION_DEVICES_HEATERHANDLER_H_ #define MISSION_DEVICES_HEATERHANDLER_H_ -#include "devices/heaterSwitcherList.h" - -#include -#include -#include #include -#include -#include #include +#include +#include +#include +#include +#include #include #include + #include +#include "devices/heaterSwitcherList.h" + /** * @brief This class intends the control of heaters. * * @author J. Meier */ -class HeaterHandler: public ExecutableObjectIF, - public PowerSwitchIF, - public SystemObject, - public HasActionsIF { -public: - static const uint8_t INTERFACE_ID = CLASS_ID::HEATER_HANDLER; +class HeaterHandler : public ExecutableObjectIF, + public PowerSwitchIF, + public SystemObject, + public HasActionsIF { + public: + static const uint8_t INTERFACE_ID = CLASS_ID::HEATER_HANDLER; - static const ReturnValue_t COMMAND_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA1); - static const ReturnValue_t INIT_FAILED = MAKE_RETURN_CODE(0xA2); - static const ReturnValue_t INVALID_SWITCH_NR = MAKE_RETURN_CODE(0xA3); - static const ReturnValue_t MAIN_SWITCH_SET_TIMEOUT = MAKE_RETURN_CODE(0xA4); - static const ReturnValue_t COMMAND_ALREADY_WAITING = MAKE_RETURN_CODE(0xA5); + static const ReturnValue_t COMMAND_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA1); + static const ReturnValue_t INIT_FAILED = MAKE_RETURN_CODE(0xA2); + static const ReturnValue_t INVALID_SWITCH_NR = MAKE_RETURN_CODE(0xA3); + static const ReturnValue_t MAIN_SWITCH_SET_TIMEOUT = MAKE_RETURN_CODE(0xA4); + static const ReturnValue_t COMMAND_ALREADY_WAITING = MAKE_RETURN_CODE(0xA5); - /** Device command IDs */ - static const DeviceCommandId_t SWITCH_HEATER = 0x0; + /** Device command IDs */ + static const DeviceCommandId_t SWITCH_HEATER = 0x0; - HeaterHandler(object_id_t setObjectId, object_id_t gpioDriverId, CookieIF * gpioCookie, - object_id_t mainLineSwitcherObjectId, uint8_t mainLineSwitch); + HeaterHandler(object_id_t setObjectId, object_id_t gpioDriverId, CookieIF* gpioCookie, + object_id_t mainLineSwitcherObjectId, uint8_t mainLineSwitch); - virtual ~HeaterHandler(); + virtual ~HeaterHandler(); - virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; + virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; - virtual void sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const override; - virtual void sendFuseOnCommand(uint8_t fuseNr) const override; - /** - * @brief This function will be called from the Heater object to check - * the current switch state. - */ - virtual ReturnValue_t getSwitchState( uint8_t switchNr ) const override; - virtual ReturnValue_t getFuseState( uint8_t fuseNr ) const override; - virtual uint32_t getSwitchDelayMs(void) const override; + virtual void sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const override; + virtual void sendFuseOnCommand(uint8_t fuseNr) const override; + /** + * @brief This function will be called from the Heater object to check + * the current switch state. + */ + virtual ReturnValue_t getSwitchState(uint8_t switchNr) const override; + virtual ReturnValue_t getFuseState(uint8_t fuseNr) const override; + virtual uint32_t getSwitchDelayMs(void) const override; - virtual MessageQueueId_t getCommandQueue() const override; - virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size) override; - virtual ReturnValue_t initialize() override; + virtual MessageQueueId_t getCommandQueue() const override; + virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) override; + virtual ReturnValue_t initialize() override; -private: + private: + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::HEATER_HANDLER; + static const Event GPIO_PULL_HIGH_FAILED = MAKE_EVENT(0, severity::LOW); + static const Event GPIO_PULL_LOW_FAILED = MAKE_EVENT(1, severity::LOW); + static const Event SWITCH_ALREADY_ON = MAKE_EVENT(2, severity::LOW); + static const Event SWITCH_ALREADY_OFF = MAKE_EVENT(3, severity::LOW); + static const Event MAIN_SWITCH_TIMEOUT = MAKE_EVENT(4, severity::LOW); - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::HEATER_HANDLER; - static const Event GPIO_PULL_HIGH_FAILED = MAKE_EVENT(0, severity::LOW); - static const Event GPIO_PULL_LOW_FAILED = MAKE_EVENT(1, severity::LOW); - static const Event SWITCH_ALREADY_ON = MAKE_EVENT(2, severity::LOW); - static const Event SWITCH_ALREADY_OFF = MAKE_EVENT(3, severity::LOW); - static const Event MAIN_SWITCH_TIMEOUT = MAKE_EVENT(4, severity::LOW); + static const MessageQueueId_t NO_COMMANDER = 0; - static const MessageQueueId_t NO_COMMANDER = 0; + enum SwitchState : bool { ON = true, OFF = false }; - enum SwitchState : bool { - ON = true, - OFF = false - }; + /** + * @brief Struct holding information about a heater command to execute. + * + * @param action The action to perform. + * @param replyQueue The queue of the commander to which status replies + * will be sent. + * @param active True if command is waiting for execution, otherwise false. + * @param waitSwitchOn True if the command is waiting for the main switch being set on. + * @param mainSwitchCountdown Sets timeout to wait for main switch being set on. + */ + typedef struct HeaterCommandInfo { + uint8_t action; + MessageQueueId_t replyQueue; + bool active = false; + bool waitMainSwitchOn = false; + Countdown mainSwitchCountdown; + } HeaterCommandInfo_t; + enum SwitchAction { SET_SWITCH_OFF, SET_SWITCH_ON }; - /** - * @brief Struct holding information about a heater command to execute. - * - * @param action The action to perform. - * @param replyQueue The queue of the commander to which status replies - * will be sent. - * @param active True if command is waiting for execution, otherwise false. - * @param waitSwitchOn True if the command is waiting for the main switch being set on. - * @param mainSwitchCountdown Sets timeout to wait for main switch being set on. - */ - typedef struct HeaterCommandInfo { - uint8_t action; - MessageQueueId_t replyQueue; - bool active = false; - bool waitMainSwitchOn = false; - Countdown mainSwitchCountdown; - } HeaterCommandInfo_t; + using switchNr_t = uint8_t; + using HeaterMap = std::unordered_map; + using HeaterMapIter = HeaterMap::iterator; - enum SwitchAction { - SET_SWITCH_OFF, - SET_SWITCH_ON - }; + HeaterMap heaterMap; - using switchNr_t = uint8_t; - using HeaterMap = std::unordered_map; - using HeaterMapIter = HeaterMap::iterator; + bool switchStates[heaterSwitches::NUMBER_OF_SWITCHES]; - HeaterMap heaterMap; + /** Size of command queue */ + size_t cmdQueueSize = 20; - bool switchStates[heaterSwitches::NUMBER_OF_SWITCHES]; + /** + * The object ID of the GPIO driver which enables and disables the + * heaters. + */ + object_id_t gpioDriverId; - /** Size of command queue */ - size_t cmdQueueSize = 20; + CookieIF* gpioCookie; - /** - * The object ID of the GPIO driver which enables and disables the - * heaters. - */ - object_id_t gpioDriverId; + GpioIF* gpioInterface = nullptr; - CookieIF * gpioCookie; + /** Queue to receive messages from other objects. */ + MessageQueueIF* commandQueue = nullptr; - GpioIF* gpioInterface = nullptr; + object_id_t mainLineSwitcherObjectId; - /** Queue to receive messages from other objects. */ - MessageQueueIF* commandQueue = nullptr; + /** Switch number of the heater power supply switch */ + uint8_t mainLineSwitch; - object_id_t mainLineSwitcherObjectId; + /** + * Power switcher object which controls the 8V main line of the heater + * logic on the TCS board. + */ + PowerSwitchIF* mainLineSwitcher = nullptr; - /** Switch number of the heater power supply switch */ - uint8_t mainLineSwitch; + ActionHelper actionHelper; - /** - * Power switcher object which controls the 8V main line of the heater - * logic on the TCS board. - */ - PowerSwitchIF *mainLineSwitcher = nullptr; + StorageManagerIF* IPCStore = nullptr; - ActionHelper actionHelper; + void readCommandQueue(); - StorageManagerIF *IPCStore = nullptr; + /** + * @brief Returns the state of a switch (ON - true, or OFF - false). + * @param switchNr The number of the switch to check. + */ + bool checkSwitchState(int switchNr); - void readCommandQueue(); + /** + * @brief Returns the ID of the GPIO related to a heater identified by the switch number + * which is defined in the heaterSwitches list. + */ + gpioId_t getGpioIdFromSwitchNr(int switchNr); - /** - * @brief Returns the state of a switch (ON - true, or OFF - false). - * @param switchNr The number of the switch to check. - */ - bool checkSwitchState(int switchNr); + /** + * @brief This function runs commands waiting for execution. + */ + void handleActiveCommands(); - /** - * @brief Returns the ID of the GPIO related to a heater identified by the switch number - * which is defined in the heaterSwitches list. - */ - gpioId_t getGpioIdFromSwitchNr(int switchNr); + ReturnValue_t initializeHeaterMap(); - /** - * @brief This function runs commands waiting for execution. - */ - void handleActiveCommands(); + /** + * @brief Sets all switches to OFF. + */ + void setInitialSwitchStates(); - ReturnValue_t initializeHeaterMap(); + void handleSwitchOnCommand(HeaterMapIter heaterMapIter); - /** - * @brief Sets all switches to OFF. - */ - void setInitialSwitchStates(); - - void handleSwitchOnCommand(HeaterMapIter heaterMapIter); - - void handleSwitchOffCommand(HeaterMapIter heaterMapIter); - - /** - * @brief Checks if all switches are off. - * @return True if all switches are off, otherwise false. - */ - bool allSwitchesOff(); + void handleSwitchOffCommand(HeaterMapIter heaterMapIter); + /** + * @brief Checks if all switches are off. + * @return True if all switches are off, otherwise false. + */ + bool allSwitchesOff(); }; #endif /* MISSION_DEVICES_HEATERHANDLER_H_ */ diff --git a/mission/devices/IMTQHandler.cpp b/mission/devices/IMTQHandler.cpp index 125040d7..499b4d6e 100644 --- a/mission/devices/IMTQHandler.cpp +++ b/mission/devices/IMTQHandler.cpp @@ -1,248 +1,249 @@ #include "IMTQHandler.h" -#include "OBSWConfig.h" -#include #include +#include #include -IMTQHandler::IMTQHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - DeviceHandlerBase(objectId, comIF, comCookie), engHkDataset(this), calMtmMeasurementSet( - this), rawMtmMeasurementSet(this), posXselfTestDataset(this), negXselfTestDataset( - this), posYselfTestDataset(this), negYselfTestDataset(this), posZselfTestDataset( - this), negZselfTestDataset(this) { - if (comCookie == NULL) { - sif::error << "IMTQHandler: Invalid com cookie" << std::endl; - } +#include "OBSWConfig.h" + +IMTQHandler::IMTQHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie) + : DeviceHandlerBase(objectId, comIF, comCookie), + engHkDataset(this), + calMtmMeasurementSet(this), + rawMtmMeasurementSet(this), + posXselfTestDataset(this), + negXselfTestDataset(this), + posYselfTestDataset(this), + negYselfTestDataset(this), + posZselfTestDataset(this), + negZselfTestDataset(this) { + if (comCookie == NULL) { + sif::error << "IMTQHandler: Invalid com cookie" << std::endl; + } } -IMTQHandler::~IMTQHandler() { -} +IMTQHandler::~IMTQHandler() {} void IMTQHandler::doStartUp() { #if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 - setMode(MODE_NORMAL); + setMode(MODE_NORMAL); #else - setMode(_MODE_TO_ON); + setMode(_MODE_TO_ON); #endif } -void IMTQHandler::doShutDown() { - setMode(_MODE_POWER_DOWN); -} +void IMTQHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } -ReturnValue_t IMTQHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) { - switch (communicationStep) { +ReturnValue_t IMTQHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + switch (communicationStep) { case CommunicationStep::GET_ENG_HK_DATA: - *id = IMTQ::GET_ENG_HK_DATA; - communicationStep = CommunicationStep::START_MTM_MEASUREMENT; - break; + *id = IMTQ::GET_ENG_HK_DATA; + communicationStep = CommunicationStep::START_MTM_MEASUREMENT; + break; case CommunicationStep::START_MTM_MEASUREMENT: - *id = IMTQ::START_MTM_MEASUREMENT; - communicationStep = CommunicationStep::GET_CAL_MTM_MEASUREMENT; - break; + *id = IMTQ::START_MTM_MEASUREMENT; + communicationStep = CommunicationStep::GET_CAL_MTM_MEASUREMENT; + break; case CommunicationStep::GET_CAL_MTM_MEASUREMENT: - *id = IMTQ::GET_CAL_MTM_MEASUREMENT; - communicationStep = CommunicationStep::GET_RAW_MTM_MEASUREMENT; - break; + *id = IMTQ::GET_CAL_MTM_MEASUREMENT; + communicationStep = CommunicationStep::GET_RAW_MTM_MEASUREMENT; + break; case CommunicationStep::GET_RAW_MTM_MEASUREMENT: - *id = IMTQ::GET_RAW_MTM_MEASUREMENT; - communicationStep = CommunicationStep::GET_ENG_HK_DATA; - break; + *id = IMTQ::GET_RAW_MTM_MEASUREMENT; + communicationStep = CommunicationStep::GET_ENG_HK_DATA; + break; default: - sif::debug << "IMTQHandler::buildNormalDeviceCommand: Invalid communication step" - << std::endl; - break; - } - return buildCommandFromCommand(*id, NULL, 0); + sif::debug << "IMTQHandler::buildNormalDeviceCommand: Invalid communication step" + << std::endl; + break; + } + return buildCommandFromCommand(*id, NULL, 0); } -ReturnValue_t IMTQHandler::buildTransitionDeviceCommand(DeviceCommandId_t * id) { - return RETURN_OK; -} +ReturnValue_t IMTQHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { return RETURN_OK; } ReturnValue_t IMTQHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t * commandData, size_t commandDataLen) { - switch (deviceCommand) { + const uint8_t* commandData, + size_t commandDataLen) { + switch (deviceCommand) { case (IMTQ::POS_X_SELF_TEST): { - commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; - commandBuffer[1] = IMTQ::SELF_TEST_AXIS::X_POSITIVE; - rawPacket = commandBuffer; - rawPacketLen = 2; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; + commandBuffer[1] = IMTQ::SELF_TEST_AXIS::X_POSITIVE; + rawPacket = commandBuffer; + rawPacketLen = 2; + return RETURN_OK; } case (IMTQ::NEG_X_SELF_TEST): { - commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; - commandBuffer[1] = IMTQ::SELF_TEST_AXIS::X_NEGATIVE; - rawPacket = commandBuffer; - rawPacketLen = 2; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; + commandBuffer[1] = IMTQ::SELF_TEST_AXIS::X_NEGATIVE; + rawPacket = commandBuffer; + rawPacketLen = 2; + return RETURN_OK; } case (IMTQ::POS_Y_SELF_TEST): { - commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; - commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Y_POSITIVE; - rawPacket = commandBuffer; - rawPacketLen = 2; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; + commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Y_POSITIVE; + rawPacket = commandBuffer; + rawPacketLen = 2; + return RETURN_OK; } case (IMTQ::NEG_Y_SELF_TEST): { - commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; - commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Y_NEGATIVE; - rawPacket = commandBuffer; - rawPacketLen = 2; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; + commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Y_NEGATIVE; + rawPacket = commandBuffer; + rawPacketLen = 2; + return RETURN_OK; } case (IMTQ::POS_Z_SELF_TEST): { - commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; - commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Z_POSITIVE; - rawPacket = commandBuffer; - rawPacketLen = 2; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; + commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Z_POSITIVE; + rawPacket = commandBuffer; + rawPacketLen = 2; + return RETURN_OK; } case (IMTQ::NEG_Z_SELF_TEST): { - commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; - commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Z_NEGATIVE; - rawPacket = commandBuffer; - rawPacketLen = 2; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; + commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Z_NEGATIVE; + rawPacket = commandBuffer; + rawPacketLen = 2; + return RETURN_OK; } case (IMTQ::GET_SELF_TEST_RESULT): { - commandBuffer[0] = IMTQ::CC::GET_SELF_TEST_RESULT; - rawPacket = commandBuffer; - rawPacketLen = 1; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::GET_SELF_TEST_RESULT; + rawPacket = commandBuffer; + rawPacketLen = 1; + return RETURN_OK; } case (IMTQ::START_ACTUATION_DIPOLE): { - /* IMTQ expects low byte first */ - commandBuffer[0] = IMTQ::CC::START_ACTUATION_DIPOLE; - commandBuffer[1] = *(commandData + 1); - commandBuffer[2] = *(commandData); - commandBuffer[3] = *(commandData + 3); - commandBuffer[4] = *(commandData + 2); - commandBuffer[5] = *(commandData + 5); - commandBuffer[6] = *(commandData + 4); - commandBuffer[7] = *(commandData + 7); - commandBuffer[8] = *(commandData + 6); - rawPacket = commandBuffer; - rawPacketLen = 9; - return RETURN_OK; + /* IMTQ expects low byte first */ + commandBuffer[0] = IMTQ::CC::START_ACTUATION_DIPOLE; + commandBuffer[1] = *(commandData + 1); + commandBuffer[2] = *(commandData); + commandBuffer[3] = *(commandData + 3); + commandBuffer[4] = *(commandData + 2); + commandBuffer[5] = *(commandData + 5); + commandBuffer[6] = *(commandData + 4); + commandBuffer[7] = *(commandData + 7); + commandBuffer[8] = *(commandData + 6); + rawPacket = commandBuffer; + rawPacketLen = 9; + return RETURN_OK; } case (IMTQ::GET_ENG_HK_DATA): { - commandBuffer[0] = IMTQ::CC::GET_ENG_HK_DATA; - rawPacket = commandBuffer; - rawPacketLen = 1; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::GET_ENG_HK_DATA; + rawPacket = commandBuffer; + rawPacketLen = 1; + return RETURN_OK; } case (IMTQ::GET_COMMANDED_DIPOLE): { - commandBuffer[0] = IMTQ::CC::GET_COMMANDED_DIPOLE; - rawPacket = commandBuffer; - rawPacketLen = 1; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::GET_COMMANDED_DIPOLE; + rawPacket = commandBuffer; + rawPacketLen = 1; + return RETURN_OK; } case (IMTQ::START_MTM_MEASUREMENT): { - commandBuffer[0] = IMTQ::CC::START_MTM_MEASUREMENT; - rawPacket = commandBuffer; - rawPacketLen = 1; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::START_MTM_MEASUREMENT; + rawPacket = commandBuffer; + rawPacketLen = 1; + return RETURN_OK; } case (IMTQ::GET_CAL_MTM_MEASUREMENT): { - commandBuffer[0] = IMTQ::CC::GET_CAL_MTM_MEASUREMENT; - rawPacket = commandBuffer; - rawPacketLen = 1; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::GET_CAL_MTM_MEASUREMENT; + rawPacket = commandBuffer; + rawPacketLen = 1; + return RETURN_OK; } case (IMTQ::GET_RAW_MTM_MEASUREMENT): { - commandBuffer[0] = IMTQ::CC::GET_RAW_MTM_MEASUREMENT; - rawPacket = commandBuffer; - rawPacketLen = 1; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::GET_RAW_MTM_MEASUREMENT; + rawPacket = commandBuffer; + rawPacketLen = 1; + return RETURN_OK; } default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } void IMTQHandler::fillCommandAndReplyMap() { - this->insertInCommandAndReplyMap(IMTQ::POS_X_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::NEG_X_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::POS_Y_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::NEG_Y_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::POS_Z_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::NEG_Z_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::GET_SELF_TEST_RESULT, 1, nullptr, - IMTQ::SIZE_SELF_TEST_RESULTS); - this->insertInCommandAndReplyMap(IMTQ::START_ACTUATION_DIPOLE, 1, nullptr, - IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::GET_ENG_HK_DATA, 1, &engHkDataset, - IMTQ::SIZE_ENG_HK_DATA_REPLY); - this->insertInCommandAndReplyMap(IMTQ::GET_COMMANDED_DIPOLE, 1, nullptr, - IMTQ::SIZE_GET_COMMANDED_DIPOLE_REPLY); - this->insertInCommandAndReplyMap(IMTQ::START_MTM_MEASUREMENT, 1, nullptr, - IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::GET_CAL_MTM_MEASUREMENT, 1, &calMtmMeasurementSet, - IMTQ::SIZE_GET_CAL_MTM_MEASUREMENT); - this->insertInCommandAndReplyMap(IMTQ::GET_RAW_MTM_MEASUREMENT, 1, &rawMtmMeasurementSet, - IMTQ::SIZE_GET_RAW_MTM_MEASUREMENT); + this->insertInCommandAndReplyMap(IMTQ::POS_X_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::NEG_X_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::POS_Y_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::NEG_Y_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::POS_Z_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::NEG_Z_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::GET_SELF_TEST_RESULT, 1, nullptr, + IMTQ::SIZE_SELF_TEST_RESULTS); + this->insertInCommandAndReplyMap(IMTQ::START_ACTUATION_DIPOLE, 1, nullptr, + IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::GET_ENG_HK_DATA, 1, &engHkDataset, + IMTQ::SIZE_ENG_HK_DATA_REPLY); + this->insertInCommandAndReplyMap(IMTQ::GET_COMMANDED_DIPOLE, 1, nullptr, + IMTQ::SIZE_GET_COMMANDED_DIPOLE_REPLY); + this->insertInCommandAndReplyMap(IMTQ::START_MTM_MEASUREMENT, 1, nullptr, + IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::GET_CAL_MTM_MEASUREMENT, 1, &calMtmMeasurementSet, + IMTQ::SIZE_GET_CAL_MTM_MEASUREMENT); + this->insertInCommandAndReplyMap(IMTQ::GET_RAW_MTM_MEASUREMENT, 1, &rawMtmMeasurementSet, + IMTQ::SIZE_GET_RAW_MTM_MEASUREMENT); } -ReturnValue_t IMTQHandler::scanForReply(const uint8_t *start, size_t remainingSize, - DeviceCommandId_t *foundId, size_t *foundLen) { +ReturnValue_t IMTQHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; - - switch (*start) { + switch (*start) { case (IMTQ::CC::START_ACTUATION_DIPOLE): - *foundLen = IMTQ::SIZE_STATUS_REPLY; - *foundId = IMTQ::START_ACTUATION_DIPOLE; - break; + *foundLen = IMTQ::SIZE_STATUS_REPLY; + *foundId = IMTQ::START_ACTUATION_DIPOLE; + break; case (IMTQ::CC::START_MTM_MEASUREMENT): - *foundLen = IMTQ::SIZE_STATUS_REPLY; - *foundId = IMTQ::START_MTM_MEASUREMENT; - break; + *foundLen = IMTQ::SIZE_STATUS_REPLY; + *foundId = IMTQ::START_MTM_MEASUREMENT; + break; case (IMTQ::CC::GET_ENG_HK_DATA): - *foundLen = IMTQ::SIZE_ENG_HK_DATA_REPLY; - *foundId = IMTQ::GET_ENG_HK_DATA; - break; + *foundLen = IMTQ::SIZE_ENG_HK_DATA_REPLY; + *foundId = IMTQ::GET_ENG_HK_DATA; + break; case (IMTQ::CC::GET_COMMANDED_DIPOLE): - *foundLen = IMTQ::SIZE_GET_COMMANDED_DIPOLE_REPLY; - *foundId = IMTQ::GET_COMMANDED_DIPOLE; - break; + *foundLen = IMTQ::SIZE_GET_COMMANDED_DIPOLE_REPLY; + *foundId = IMTQ::GET_COMMANDED_DIPOLE; + break; case (IMTQ::CC::GET_CAL_MTM_MEASUREMENT): - *foundLen = IMTQ::SIZE_GET_CAL_MTM_MEASUREMENT; - *foundId = IMTQ::GET_CAL_MTM_MEASUREMENT; - break; + *foundLen = IMTQ::SIZE_GET_CAL_MTM_MEASUREMENT; + *foundId = IMTQ::GET_CAL_MTM_MEASUREMENT; + break; case (IMTQ::CC::GET_RAW_MTM_MEASUREMENT): - *foundLen = IMTQ::SIZE_GET_RAW_MTM_MEASUREMENT; - *foundId = IMTQ::GET_RAW_MTM_MEASUREMENT; - break; + *foundLen = IMTQ::SIZE_GET_RAW_MTM_MEASUREMENT; + *foundId = IMTQ::GET_RAW_MTM_MEASUREMENT; + break; case (IMTQ::CC::SELF_TEST_CMD): - *foundLen = IMTQ::SIZE_STATUS_REPLY; - result = getSelfTestCommandId(foundId); - break; + *foundLen = IMTQ::SIZE_STATUS_REPLY; + result = getSelfTestCommandId(foundId); + break; case (IMTQ::CC::GET_SELF_TEST_RESULT): - *foundLen = IMTQ::SIZE_SELF_TEST_RESULTS; - *foundId = IMTQ::GET_SELF_TEST_RESULT; - break; + *foundLen = IMTQ::SIZE_SELF_TEST_RESULTS; + *foundId = IMTQ::GET_SELF_TEST_RESULT; + break; default: - sif::debug << "IMTQHandler::scanForReply: Reply contains invalid command code" << std::endl; - result = IGNORE_REPLY_DATA; - break; - } + sif::debug << "IMTQHandler::scanForReply: Reply contains invalid command code" << std::endl; + result = IGNORE_REPLY_DATA; + break; + } - return result; + return result; } -ReturnValue_t IMTQHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { +ReturnValue_t IMTQHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = parseStatusByte(packet); - result = parseStatusByte(packet); + if (result != RETURN_OK) { + return result; + } - if (result != RETURN_OK) { - return result; - } - - switch (id) { + switch (id) { case (IMTQ::POS_X_SELF_TEST): case (IMTQ::NEG_X_SELF_TEST): case (IMTQ::POS_Y_SELF_TEST): @@ -251,1879 +252,1923 @@ ReturnValue_t IMTQHandler::interpretDeviceReply(DeviceCommandId_t id, const uint case (IMTQ::NEG_Z_SELF_TEST): case (IMTQ::START_ACTUATION_DIPOLE): case (IMTQ::START_MTM_MEASUREMENT): - /* Replies only the status byte which is already handled with parseStatusByte */ - break; + /* Replies only the status byte which is already handled with parseStatusByte */ + break; case (IMTQ::GET_ENG_HK_DATA): - fillEngHkDataset(packet); - break; + fillEngHkDataset(packet); + break; case (IMTQ::GET_COMMANDED_DIPOLE): - handleGetCommandedDipoleReply(packet); - break; + handleGetCommandedDipoleReply(packet); + break; case (IMTQ::GET_CAL_MTM_MEASUREMENT): - fillCalibratedMtmDataset(packet); - break; + fillCalibratedMtmDataset(packet); + break; case (IMTQ::GET_RAW_MTM_MEASUREMENT): - fillRawMtmDataset(packet); - break; + fillRawMtmDataset(packet); + break; case (IMTQ::GET_SELF_TEST_RESULT): - handleSelfTestReply(packet); - break; + handleSelfTestReply(packet); + break; default: { - sif::debug << "IMTQHandler::interpretDeviceReply: Unknown device reply id" << std::endl; - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } + sif::debug << "IMTQHandler::interpretDeviceReply: Unknown device reply id" << std::endl; + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; } + } - return RETURN_OK; + return RETURN_OK; } -void IMTQHandler::setNormalDatapoolEntriesInvalid() { - -} +void IMTQHandler::setNormalDatapoolEntriesInvalid() {} LocalPoolDataSetBase* IMTQHandler::getDataSetHandle(sid_t sid) { - if (sid == engHkDataset.getSid()) { - return &engHkDataset; - } else if (sid == calMtmMeasurementSet.getSid()) { - return &calMtmMeasurementSet; - } else if (sid == rawMtmMeasurementSet.getSid()) { - return &rawMtmMeasurementSet; - } else if (sid == posXselfTestDataset.getSid()) { - return &posXselfTestDataset; - } else if (sid == negXselfTestDataset.getSid()) { - return &negXselfTestDataset; - } else if (sid == posYselfTestDataset.getSid()) { - return &posYselfTestDataset; - } else if (sid == negYselfTestDataset.getSid()) { - return &negYselfTestDataset; - } else if (sid == posZselfTestDataset.getSid()) { - return &posZselfTestDataset; - } else if (sid == negZselfTestDataset.getSid()) { - return &negZselfTestDataset; - } else { - sif::error << "IMTQHandler::getDataSetHandle: Invalid sid" << std::endl; - return nullptr; - } + if (sid == engHkDataset.getSid()) { + return &engHkDataset; + } else if (sid == calMtmMeasurementSet.getSid()) { + return &calMtmMeasurementSet; + } else if (sid == rawMtmMeasurementSet.getSid()) { + return &rawMtmMeasurementSet; + } else if (sid == posXselfTestDataset.getSid()) { + return &posXselfTestDataset; + } else if (sid == negXselfTestDataset.getSid()) { + return &negXselfTestDataset; + } else if (sid == posYselfTestDataset.getSid()) { + return &posYselfTestDataset; + } else if (sid == negYselfTestDataset.getSid()) { + return &negYselfTestDataset; + } else if (sid == posZselfTestDataset.getSid()) { + return &posZselfTestDataset; + } else if (sid == negZselfTestDataset.getSid()) { + return &negZselfTestDataset; + } else { + sif::error << "IMTQHandler::getDataSetHandle: Invalid sid" << std::endl; + return nullptr; + } } -uint32_t IMTQHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { - return 5000; -} +uint32_t IMTQHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 5000; } ReturnValue_t IMTQHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { + LocalDataPoolManager& poolManager) { + /** Entries of engineering housekeeping dataset */ + localDataPoolMap.emplace(IMTQ::DIGITAL_VOLTAGE_MV, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::ANALOG_VOLTAGE_MV, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::DIGITAL_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::ANALOG_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::COIL_Z_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::MCU_TEMPERATURE, new PoolEntry({0})); - /** Entries of engineering housekeeping dataset */ - localDataPoolMap.emplace(IMTQ::DIGITAL_VOLTAGE_MV, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::ANALOG_VOLTAGE_MV, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::DIGITAL_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::ANALOG_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::MCU_TEMPERATURE, new PoolEntry( { 0 })); + /** Entries of calibrated MTM measurement dataset */ + localDataPoolMap.emplace(IMTQ::MTM_CAL_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::MTM_CAL_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::MTM_CAL_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::ACTUATION_CAL_STATUS, new PoolEntry({0})); - /** Entries of calibrated MTM measurement dataset */ - localDataPoolMap.emplace(IMTQ::MTM_CAL_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::MTM_CAL_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::MTM_CAL_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::ACTUATION_CAL_STATUS, new PoolEntry( { 0 })); + /** Entries of raw MTM measurement dataset */ + localDataPoolMap.emplace(IMTQ::MTM_RAW_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::MTM_RAW_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::MTM_RAW_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::ACTUATION_RAW_STATUS, new PoolEntry({0})); - /** Entries of raw MTM measurement dataset */ - localDataPoolMap.emplace(IMTQ::MTM_RAW_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::MTM_RAW_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::MTM_RAW_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::ACTUATION_RAW_STATUS, new PoolEntry( { 0 })); + /** INIT measurements for positive X axis test */ + localDataPoolMap.emplace(IMTQ::INIT_POS_X_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** INIT measurements for positive X axis test */ - localDataPoolMap.emplace(IMTQ::INIT_POS_X_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** INIT measurements for negative X axis test */ + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** INIT measurements for negative X axis test */ - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** INIT measurements for positive Y axis test */ + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** INIT measurements for positive Y axis test */ - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** INIT measurements for negative Y axis test */ + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** INIT measurements for negative Y axis test */ - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** INIT measurements for positive Z axis test */ + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** INIT measurements for positive Z axis test */ - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** INIT measurements for negative Z axis test */ + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** INIT measurements for negative Z axis test */ - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(IMTQ::POS_X_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_COIL_Z_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(IMTQ::POS_X_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(IMTQ::NEG_X_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Z_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(IMTQ::NEG_X_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(IMTQ::POS_Y_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Z_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(IMTQ::POS_Y_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(IMTQ::NEG_Y_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Z_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(IMTQ::NEG_Y_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(IMTQ::POS_Z_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Z_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(IMTQ::POS_Z_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(IMTQ::NEG_Z_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Z_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(IMTQ::NEG_Z_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** FINA measurements for positive X axis test */ + localDataPoolMap.emplace(IMTQ::FINA_POS_X_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** FINA measurements for positive X axis test */ - localDataPoolMap.emplace(IMTQ::FINA_POS_X_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** FINA measurements for negative X axis test */ + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** FINA measurements for negative X axis test */ - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** FINA measurements for positive Y axis test */ + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** FINA measurements for positive Y axis test */ - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** FINA measurements for negative Y axis test */ + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** FINA measurements for negative Y axis test */ - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** FINA measurements for positive Z axis test */ + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** FINA measurements for positive Z axis test */ - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** FINA measurements for negative Z axis test */ + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** FINA measurements for negative Z axis test */ - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t IMTQHandler::getSelfTestCommandId(DeviceCommandId_t* id) { - DeviceCommandId_t commandId = getPendingCommand(); - switch (commandId) { + DeviceCommandId_t commandId = getPendingCommand(); + switch (commandId) { case IMTQ::POS_X_SELF_TEST: case IMTQ::NEG_X_SELF_TEST: case IMTQ::POS_Y_SELF_TEST: case IMTQ::NEG_Y_SELF_TEST: case IMTQ::POS_Z_SELF_TEST: case IMTQ::NEG_Z_SELF_TEST: - *id = commandId; - break; + *id = commandId; + break; default: - sif::error << "IMTQHandler::getSelfTestCommandId: Reply does not match to pending " - << "command" << std::endl; - return UNEXPECTED_SELF_TEST_REPLY; - } - return RETURN_OK; + sif::error << "IMTQHandler::getSelfTestCommandId: Reply does not match to pending " + << "command" << std::endl; + return UNEXPECTED_SELF_TEST_REPLY; + } + return RETURN_OK; } ReturnValue_t IMTQHandler::parseStatusByte(const uint8_t* packet) { - uint8_t cmdErrorField = *(packet + 1) & 0xF; - switch (cmdErrorField) { + uint8_t cmdErrorField = *(packet + 1) & 0xF; + switch (cmdErrorField) { case 0: - return RETURN_OK; + return RETURN_OK; case 1: - sif::error << "IMTQHandler::parseStatusByte: Command rejected without reason" << std::endl; - return REJECTED_WITHOUT_REASON; + sif::error << "IMTQHandler::parseStatusByte: Command rejected without reason" << std::endl; + return REJECTED_WITHOUT_REASON; case 2: - sif::error << "IMTQHandler::parseStatusByte: Command has invalid command code" << std::endl; - return INVALID_COMMAND_CODE; + sif::error << "IMTQHandler::parseStatusByte: Command has invalid command code" << std::endl; + return INVALID_COMMAND_CODE; case 3: - sif::error << "IMTQHandler::parseStatusByte: Command has missing parameter" << std::endl; - return PARAMETER_MISSING; + sif::error << "IMTQHandler::parseStatusByte: Command has missing parameter" << std::endl; + return PARAMETER_MISSING; case 4: - sif::error << "IMTQHandler::parseStatusByte: Command has invalid parameter" << std::endl; - return PARAMETER_INVALID; + sif::error << "IMTQHandler::parseStatusByte: Command has invalid parameter" << std::endl; + return PARAMETER_INVALID; case 5: - sif::error << "IMTQHandler::parseStatusByte: CC unavailable" << std::endl; - return CC_UNAVAILABLE; + sif::error << "IMTQHandler::parseStatusByte: CC unavailable" << std::endl; + return CC_UNAVAILABLE; case 7: - sif::error << "IMTQHandler::parseStatusByte: IMQT replied internal processing error" - << std::endl; - return INTERNAL_PROCESSING_ERROR; + sif::error << "IMTQHandler::parseStatusByte: IMQT replied internal processing error" + << std::endl; + return INTERNAL_PROCESSING_ERROR; default: - sif::error << "IMTQHandler::parseStatusByte: CMD Error field contains unknown error code " - << cmdErrorField << std::endl; - return CMD_ERR_UNKNOWN; - } + sif::error << "IMTQHandler::parseStatusByte: CMD Error field contains unknown error code " + << cmdErrorField << std::endl; + return CMD_ERR_UNKNOWN; + } } void IMTQHandler::fillEngHkDataset(const uint8_t* packet) { - PoolReadGuard rg(&engHkDataset); - uint8_t offset = 2; - engHkDataset.digitalVoltageMv = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - engHkDataset.analogVoltageMv = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - engHkDataset.digitalCurrentmA = (*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; - offset += 2; - engHkDataset.analogCurrentmA = (*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; - offset += 2; - engHkDataset.coilXCurrentmA = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - engHkDataset.coilYCurrentmA = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - engHkDataset.coilZCurrentmA = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - engHkDataset.coilXTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); - offset += 2; - engHkDataset.coilYTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); - offset += 2; - engHkDataset.coilZTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); - offset += 2; - engHkDataset.mcuTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); + PoolReadGuard rg(&engHkDataset); + uint8_t offset = 2; + engHkDataset.digitalVoltageMv = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + engHkDataset.analogVoltageMv = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + engHkDataset.digitalCurrentmA = (*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + engHkDataset.analogCurrentmA = (*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + engHkDataset.coilXCurrentmA = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + engHkDataset.coilYCurrentmA = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + engHkDataset.coilZCurrentmA = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + engHkDataset.coilXTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); + offset += 2; + engHkDataset.coilYTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); + offset += 2; + engHkDataset.coilZTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); + offset += 2; + engHkDataset.mcuTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ digital voltage: " << engHkDataset.digitalVoltageMv << " mV" << std::endl; - sif::info << "IMTQ analog voltage: " << engHkDataset.analogVoltageMv << " mV" << std::endl; - sif::info << "IMTQ digital current: " << engHkDataset.digitalCurrentmA << " mA" << std::endl; - sif::info << "IMTQ analog current: " << engHkDataset.analogCurrentmA << " mA" << std::endl; - sif::info << "IMTQ coil X current: " << engHkDataset.coilXCurrentmA << " mA" << std::endl; - sif::info << "IMTQ coil Y current: " << engHkDataset.coilYCurrentmA << " mA" << std::endl; - sif::info << "IMTQ coil Z current: " << engHkDataset.coilZCurrentmA << " mA" << std::endl; - sif::info << "IMTQ coil X temperature: " << engHkDataset.coilXTemperature << " °C" - << std::endl; - sif::info << "IMTQ coil Y temperature: " << engHkDataset.coilYTemperature << " °C" - << std::endl; - sif::info << "IMTQ coil Z temperature: " << engHkDataset.coilZTemperature << " °C" - << std::endl; - sif::info << "IMTQ coil MCU temperature: " << engHkDataset.mcuTemperature << " °C" - << std::endl; +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ digital voltage: " << engHkDataset.digitalVoltageMv << " mV" << std::endl; + sif::info << "IMTQ analog voltage: " << engHkDataset.analogVoltageMv << " mV" << std::endl; + sif::info << "IMTQ digital current: " << engHkDataset.digitalCurrentmA << " mA" << std::endl; + sif::info << "IMTQ analog current: " << engHkDataset.analogCurrentmA << " mA" << std::endl; + sif::info << "IMTQ coil X current: " << engHkDataset.coilXCurrentmA << " mA" << std::endl; + sif::info << "IMTQ coil Y current: " << engHkDataset.coilYCurrentmA << " mA" << std::endl; + sif::info << "IMTQ coil Z current: " << engHkDataset.coilZCurrentmA << " mA" << std::endl; + sif::info << "IMTQ coil X temperature: " << engHkDataset.coilXTemperature << " °C" << std::endl; + sif::info << "IMTQ coil Y temperature: " << engHkDataset.coilYTemperature << " °C" << std::endl; + sif::info << "IMTQ coil Z temperature: " << engHkDataset.coilZTemperature << " °C" << std::endl; + sif::info << "IMTQ coil MCU temperature: " << engHkDataset.mcuTemperature << " °C" << std::endl; #endif } -void IMTQHandler::setModeNormal() { - mode = MODE_NORMAL; -} +void IMTQHandler::setModeNormal() { mode = MODE_NORMAL; } void IMTQHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId) { + if (wiretappingMode == RAW) { + /* Data already sent in doGetRead() */ + return; + } - if (wiretappingMode == RAW) { - /* Data already sent in doGetRead() */ - return; - } + DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId); + if (iter == deviceReplyMap.end()) { + sif::debug << "IMTQHandler::handleDeviceTM: Unknown reply id" << std::endl; + return; + } + MessageQueueId_t queueId = iter->second.command->second.sendReplyTo; - DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId); - if (iter == deviceReplyMap.end()) { - sif::debug << "IMTQHandler::handleDeviceTM: Unknown reply id" << std::endl; - return; - } - MessageQueueId_t queueId = iter->second.command->second.sendReplyTo; + if (queueId == NO_COMMANDER) { + return; + } - if (queueId == NO_COMMANDER) { - return; - } - - ReturnValue_t result = actionHelper.reportData(queueId, replyId, data, dataSize); - if (result != RETURN_OK) { - sif::debug << "IMTQHandler::handleDeviceTM: Failed to report data" << std::endl; - return; - } + ReturnValue_t result = actionHelper.reportData(queueId, replyId, data, dataSize); + if (result != RETURN_OK) { + sif::debug << "IMTQHandler::handleDeviceTM: Failed to report data" << std::endl; + return; + } } void IMTQHandler::handleGetCommandedDipoleReply(const uint8_t* packet) { - uint8_t tmData[6]; - /* Switching endianess of received dipole values */ - tmData[0] = *(packet + 3); - tmData[1] = *(packet + 2); - tmData[2] = *(packet + 5); - tmData[3] = *(packet + 4); - tmData[4] = *(packet + 7); - tmData[5] = *(packet + 6); - handleDeviceTM(tmData, sizeof(tmData), IMTQ::GET_COMMANDED_DIPOLE); + uint8_t tmData[6]; + /* Switching endianess of received dipole values */ + tmData[0] = *(packet + 3); + tmData[1] = *(packet + 2); + tmData[2] = *(packet + 5); + tmData[3] = *(packet + 4); + tmData[4] = *(packet + 7); + tmData[5] = *(packet + 6); + handleDeviceTM(tmData, sizeof(tmData), IMTQ::GET_COMMANDED_DIPOLE); } void IMTQHandler::fillCalibratedMtmDataset(const uint8_t* packet) { - PoolReadGuard rg(&calMtmMeasurementSet); - int8_t offset = 2; - calMtmMeasurementSet.mtmXnT = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - calMtmMeasurementSet.mtmYnT = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - calMtmMeasurementSet.mtmZnT = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - calMtmMeasurementSet.coilActuationStatus = (*(packet + offset + 3) << 24) - | (*(packet + offset + 2) << 16) | (*(packet + offset + 1) << 8) | (*(packet + offset)); -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ calibrated MTM measurement X: " << calMtmMeasurementSet.mtmXnT << " nT" + PoolReadGuard rg(&calMtmMeasurementSet); + int8_t offset = 2; + calMtmMeasurementSet.mtmXnT = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + calMtmMeasurementSet.mtmYnT = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + calMtmMeasurementSet.mtmZnT = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + calMtmMeasurementSet.coilActuationStatus = (*(packet + offset + 3) << 24) | + (*(packet + offset + 2) << 16) | + (*(packet + offset + 1) << 8) | (*(packet + offset)); +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ calibrated MTM measurement X: " << calMtmMeasurementSet.mtmXnT << " nT" << std::endl; - sif::info << "IMTQ calibrated MTM measurement Y: " << calMtmMeasurementSet.mtmYnT << " nT" + sif::info << "IMTQ calibrated MTM measurement Y: " << calMtmMeasurementSet.mtmYnT << " nT" << std::endl; - sif::info << "IMTQ calibrated MTM measurement Z: " << calMtmMeasurementSet.mtmZnT << " nT" + sif::info << "IMTQ calibrated MTM measurement Z: " << calMtmMeasurementSet.mtmZnT << " nT" << std::endl; - sif::info << "IMTQ coil actuation status during MTM measurement: " - << (unsigned int) calMtmMeasurementSet.coilActuationStatus.value << std::endl; + sif::info << "IMTQ coil actuation status during MTM measurement: " + << (unsigned int)calMtmMeasurementSet.coilActuationStatus.value << std::endl; #endif } void IMTQHandler::fillRawMtmDataset(const uint8_t* packet) { - PoolReadGuard rg(&rawMtmMeasurementSet); - int8_t offset = 2; - rawMtmMeasurementSet.mtmXnT = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - rawMtmMeasurementSet.mtmYnT = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - rawMtmMeasurementSet.mtmZnT = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - rawMtmMeasurementSet.coilActuationStatus = (*(packet + offset + 3) << 24) - | (*(packet + offset + 2) << 16) | (*(packet + offset + 1) << 8) | (*(packet + offset)); -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ raw MTM measurement X: " << rawMtmMeasurementSet.mtmXnT << " nT" - << std::endl; - sif::info << "IMTQ raw MTM measurement Y: " << rawMtmMeasurementSet.mtmYnT << " nT" - << std::endl; - sif::info << "IMTQ raw MTM measurement Z: " << rawMtmMeasurementSet.mtmZnT << " nT" - << std::endl; - sif::info << "IMTQ coil actuation status during MTM measurement: " - << (unsigned int) rawMtmMeasurementSet.coilActuationStatus.value << std::endl; + PoolReadGuard rg(&rawMtmMeasurementSet); + int8_t offset = 2; + rawMtmMeasurementSet.mtmXnT = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + rawMtmMeasurementSet.mtmYnT = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + rawMtmMeasurementSet.mtmZnT = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + rawMtmMeasurementSet.coilActuationStatus = (*(packet + offset + 3) << 24) | + (*(packet + offset + 2) << 16) | + (*(packet + offset + 1) << 8) | (*(packet + offset)); +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ raw MTM measurement X: " << rawMtmMeasurementSet.mtmXnT << " nT" << std::endl; + sif::info << "IMTQ raw MTM measurement Y: " << rawMtmMeasurementSet.mtmYnT << " nT" << std::endl; + sif::info << "IMTQ raw MTM measurement Z: " << rawMtmMeasurementSet.mtmZnT << " nT" << std::endl; + sif::info << "IMTQ coil actuation status during MTM measurement: " + << (unsigned int)rawMtmMeasurementSet.coilActuationStatus.value << std::endl; #endif } void IMTQHandler::handleSelfTestReply(const uint8_t* packet) { - uint16_t offset = 2; - checkErrorByte(*(packet + offset), *(packet + offset + 1)); + uint16_t offset = 2; + checkErrorByte(*(packet + offset), *(packet + offset + 1)); - switch (*(packet + IMTQ::MAIN_STEP_OFFSET)) { + switch (*(packet + IMTQ::MAIN_STEP_OFFSET)) { case IMTQ::SELF_TEST_STEPS::X_POSITIVE: { - handlePositiveXSelfTestReply(packet); - break; + handlePositiveXSelfTestReply(packet); + break; } case IMTQ::SELF_TEST_STEPS::X_NEGATIVE: { - handleNegativeXSelfTestReply(packet); - break; + handleNegativeXSelfTestReply(packet); + break; } case IMTQ::SELF_TEST_STEPS::Y_POSITIVE: { - handlePositiveYSelfTestReply(packet); - break; + handlePositiveYSelfTestReply(packet); + break; } case IMTQ::SELF_TEST_STEPS::Y_NEGATIVE: { - handleNegativeYSelfTestReply(packet); - break; + handleNegativeYSelfTestReply(packet); + break; } case IMTQ::SELF_TEST_STEPS::Z_POSITIVE: { - handlePositiveZSelfTestReply(packet); - break; + handlePositiveZSelfTestReply(packet); + break; } case IMTQ::SELF_TEST_STEPS::Z_NEGATIVE: { - handleNegativeZSelfTestReply(packet); - break; + handleNegativeZSelfTestReply(packet); + break; } default: - break; - } + break; + } } void IMTQHandler::handlePositiveXSelfTestReply(const uint8_t* packet) { - PoolReadGuard rg(&posXselfTestDataset); + PoolReadGuard rg(&posXselfTestDataset); - uint16_t offset = 2; - /** Init measurements */ - posXselfTestDataset.initErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - posXselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.initCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.initCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.initCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posXselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posXselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + uint16_t offset = 2; + /** Init measurements */ + posXselfTestDataset.initErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + posXselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.initCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.initCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.initCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posXselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posXselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** +X measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - posXselfTestDataset.err = *(packet + offset); - offset += 2; // STEP byte will not be stored - posXselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.coilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.coilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.coilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posXselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posXselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** +X measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + posXselfTestDataset.err = *(packet + offset); + offset += 2; // STEP byte will not be stored + posXselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.coilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.coilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.coilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posXselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posXselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** FINA measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - posXselfTestDataset.finaErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - posXselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.finaCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.finaCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.finaCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posXselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posXselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** FINA measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + posXselfTestDataset.finaErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + posXselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.finaCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.finaCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.finaCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posXselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posXselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ self test (INIT) err: " +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ self test (INIT) err: " << static_cast(posXselfTestDataset.initErr.value) << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field X: " << posXselfTestDataset.initRawMagX + sif::info << "IMTQ self test (INIT) raw magnetic field X: " << posXselfTestDataset.initRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << posXselfTestDataset.initRawMagY + sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << posXselfTestDataset.initRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << posXselfTestDataset.initRawMagZ + sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << posXselfTestDataset.initRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " << posXselfTestDataset.initCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " << posXselfTestDataset.initCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " << posXselfTestDataset.initCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) coil X current: " << posXselfTestDataset.initCoilXCurrent + sif::info << "IMTQ self test (INIT) coil X current: " << posXselfTestDataset.initCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y current: " << posXselfTestDataset.initCoilYCurrent + sif::info << "IMTQ self test (INIT) coil Y current: " << posXselfTestDataset.initCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z current: " << posXselfTestDataset.initCoilZCurrent + sif::info << "IMTQ self test (INIT) coil Z current: " << posXselfTestDataset.initCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil X temperature: " + sif::info << "IMTQ self test (INIT) coil X temperature: " << posXselfTestDataset.initCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y temperature: " + sif::info << "IMTQ self test (INIT) coil Y temperature: " << posXselfTestDataset.initCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z temperature: " + sif::info << "IMTQ self test (INIT) coil Z temperature: " << posXselfTestDataset.initCoilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+X) err: " + sif::info << "IMTQ self test (+X) err: " << static_cast(posXselfTestDataset.err.value) << std::endl; - sif::info << "IMTQ self test (+X) raw magnetic field X: " << posXselfTestDataset.rawMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (+X) raw magnetic field Y: " << posXselfTestDataset.rawMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (+X) raw magnetic field Z: " << posXselfTestDataset.rawMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (+X) calibrated magnetic field X: " << posXselfTestDataset.calMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (+X) calibrated magnetic field Y: " << posXselfTestDataset.calMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (+X) calibrated magnetic field Z: " << posXselfTestDataset.calMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (+X) coil X current: " << posXselfTestDataset.coilXCurrent << " mA" + sif::info << "IMTQ self test (+X) raw magnetic field X: " << posXselfTestDataset.rawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (+X) coil Y current: " << posXselfTestDataset.coilYCurrent << " mA" + sif::info << "IMTQ self test (+X) raw magnetic field Y: " << posXselfTestDataset.rawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (+X) coil Z current: " << posXselfTestDataset.coilZCurrent << " mA" + sif::info << "IMTQ self test (+X) raw magnetic field Z: " << posXselfTestDataset.rawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (+X) coil X temperature: " << posXselfTestDataset.coilXTemperature + sif::info << "IMTQ self test (+X) calibrated magnetic field X: " << posXselfTestDataset.calMagX + << " nT" << std::endl; + sif::info << "IMTQ self test (+X) calibrated magnetic field Y: " << posXselfTestDataset.calMagY + << " nT" << std::endl; + sif::info << "IMTQ self test (+X) calibrated magnetic field Z: " << posXselfTestDataset.calMagZ + << " nT" << std::endl; + sif::info << "IMTQ self test (+X) coil X current: " << posXselfTestDataset.coilXCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+X) coil Y current: " << posXselfTestDataset.coilYCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+X) coil Z current: " << posXselfTestDataset.coilZCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+X) coil X temperature: " << posXselfTestDataset.coilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+X) coil Y temperature: " << posXselfTestDataset.coilYTemperature + sif::info << "IMTQ self test (+X) coil Y temperature: " << posXselfTestDataset.coilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+X) coil Z temperature: " << posXselfTestDataset.coilZTemperature + sif::info << "IMTQ self test (+X) coil Z temperature: " << posXselfTestDataset.coilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) err: " + sif::info << "IMTQ self test (FINA) err: " << static_cast(posXselfTestDataset.finaErr.value) << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field X: " << posXselfTestDataset.finaRawMagX + sif::info << "IMTQ self test (FINA) raw magnetic field X: " << posXselfTestDataset.finaRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << posXselfTestDataset.finaRawMagY + sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << posXselfTestDataset.finaRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << posXselfTestDataset.finaRawMagZ + sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << posXselfTestDataset.finaRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " << posXselfTestDataset.finaCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " << posXselfTestDataset.finaCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " << posXselfTestDataset.finaCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) coil X current: " << posXselfTestDataset.finaCoilXCurrent + sif::info << "IMTQ self test (FINA) coil X current: " << posXselfTestDataset.finaCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y current: " << posXselfTestDataset.finaCoilYCurrent + sif::info << "IMTQ self test (FINA) coil Y current: " << posXselfTestDataset.finaCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z current: " << posXselfTestDataset.finaCoilZCurrent + sif::info << "IMTQ self test (FINA) coil Z current: " << posXselfTestDataset.finaCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil X temperature: " + sif::info << "IMTQ self test (FINA) coil X temperature: " << posXselfTestDataset.finaCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y temperature: " + sif::info << "IMTQ self test (FINA) coil Y temperature: " << posXselfTestDataset.finaCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z temperature: " + sif::info << "IMTQ self test (FINA) coil Z temperature: " << posXselfTestDataset.finaCoilZTemperature << " °C" << std::endl; #endif } void IMTQHandler::handleNegativeXSelfTestReply(const uint8_t* packet) { - PoolReadGuard rg(&posXselfTestDataset); + PoolReadGuard rg(&posXselfTestDataset); - uint16_t offset = 2; - /** Init measurements */ - negXselfTestDataset.initErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - negXselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.initCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.initCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.initCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negXselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negXselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + uint16_t offset = 2; + /** Init measurements */ + negXselfTestDataset.initErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + negXselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.initCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.initCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.initCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negXselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negXselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** +X measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - negXselfTestDataset.err = *(packet + offset); - offset += 2; // STEP byte will not be stored - negXselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.coilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.coilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.coilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negXselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negXselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** +X measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + negXselfTestDataset.err = *(packet + offset); + offset += 2; // STEP byte will not be stored + negXselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.coilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.coilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.coilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negXselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negXselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** FINA measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - negXselfTestDataset.finaErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - negXselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.finaCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.finaCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.finaCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negXselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negXselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** FINA measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + negXselfTestDataset.finaErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + negXselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.finaCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.finaCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.finaCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negXselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negXselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ self test (INIT) err: " +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ self test (INIT) err: " << static_cast(negXselfTestDataset.initErr.value) << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field X: " << negXselfTestDataset.initRawMagX + sif::info << "IMTQ self test (INIT) raw magnetic field X: " << negXselfTestDataset.initRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << negXselfTestDataset.initRawMagY + sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << negXselfTestDataset.initRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << negXselfTestDataset.initRawMagZ + sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << negXselfTestDataset.initRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " << negXselfTestDataset.initCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " << negXselfTestDataset.initCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " << negXselfTestDataset.initCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) coil X current: " << negXselfTestDataset.initCoilXCurrent + sif::info << "IMTQ self test (INIT) coil X current: " << negXselfTestDataset.initCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y current: " << negXselfTestDataset.initCoilYCurrent + sif::info << "IMTQ self test (INIT) coil Y current: " << negXselfTestDataset.initCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z current: " << negXselfTestDataset.initCoilZCurrent + sif::info << "IMTQ self test (INIT) coil Z current: " << negXselfTestDataset.initCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil X temperature: " + sif::info << "IMTQ self test (INIT) coil X temperature: " << negXselfTestDataset.initCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y temperature: " + sif::info << "IMTQ self test (INIT) coil Y temperature: " << negXselfTestDataset.initCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z temperature: " + sif::info << "IMTQ self test (INIT) coil Z temperature: " << negXselfTestDataset.initCoilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-X) err: " + sif::info << "IMTQ self test (-X) err: " << static_cast(negXselfTestDataset.err.value) << std::endl; - sif::info << "IMTQ self test (-X) raw magnetic field X: " << negXselfTestDataset.rawMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (-X) raw magnetic field Y: " << negXselfTestDataset.rawMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (-X) raw magnetic field Z: " << negXselfTestDataset.rawMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (-X) calibrated magnetic field X: " << negXselfTestDataset.calMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (-X) calibrated magnetic field Y: " << negXselfTestDataset.calMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (-X) calibrated magnetic field Z: " << negXselfTestDataset.calMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (-X) coil X current: " << negXselfTestDataset.coilXCurrent << " mA" + sif::info << "IMTQ self test (-X) raw magnetic field X: " << negXselfTestDataset.rawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (-X) coil Y current: " << negXselfTestDataset.coilYCurrent << " mA" + sif::info << "IMTQ self test (-X) raw magnetic field Y: " << negXselfTestDataset.rawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (-X) coil Z current: " << negXselfTestDataset.coilZCurrent << " mA" + sif::info << "IMTQ self test (-X) raw magnetic field Z: " << negXselfTestDataset.rawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (-X) coil X temperature: " << negXselfTestDataset.coilXTemperature + sif::info << "IMTQ self test (-X) calibrated magnetic field X: " << negXselfTestDataset.calMagX + << " nT" << std::endl; + sif::info << "IMTQ self test (-X) calibrated magnetic field Y: " << negXselfTestDataset.calMagY + << " nT" << std::endl; + sif::info << "IMTQ self test (-X) calibrated magnetic field Z: " << negXselfTestDataset.calMagZ + << " nT" << std::endl; + sif::info << "IMTQ self test (-X) coil X current: " << negXselfTestDataset.coilXCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-X) coil Y current: " << negXselfTestDataset.coilYCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-X) coil Z current: " << negXselfTestDataset.coilZCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-X) coil X temperature: " << negXselfTestDataset.coilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-X) coil Y temperature: " << negXselfTestDataset.coilYTemperature + sif::info << "IMTQ self test (-X) coil Y temperature: " << negXselfTestDataset.coilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-X) coil Z temperature: " << negXselfTestDataset.coilZTemperature + sif::info << "IMTQ self test (-X) coil Z temperature: " << negXselfTestDataset.coilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) err: " + sif::info << "IMTQ self test (FINA) err: " << static_cast(negXselfTestDataset.finaErr.value) << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field X: " << negXselfTestDataset.finaRawMagX + sif::info << "IMTQ self test (FINA) raw magnetic field X: " << negXselfTestDataset.finaRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << negXselfTestDataset.finaRawMagY + sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << negXselfTestDataset.finaRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << negXselfTestDataset.finaRawMagZ + sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << negXselfTestDataset.finaRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " << negXselfTestDataset.finaCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " << negXselfTestDataset.finaCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " << negXselfTestDataset.finaCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) coil X current: " << negXselfTestDataset.finaCoilXCurrent + sif::info << "IMTQ self test (FINA) coil X current: " << negXselfTestDataset.finaCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y current: " << negXselfTestDataset.finaCoilYCurrent + sif::info << "IMTQ self test (FINA) coil Y current: " << negXselfTestDataset.finaCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z current: " << negXselfTestDataset.finaCoilZCurrent + sif::info << "IMTQ self test (FINA) coil Z current: " << negXselfTestDataset.finaCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil X temperature: " + sif::info << "IMTQ self test (FINA) coil X temperature: " << negXselfTestDataset.finaCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y temperature: " + sif::info << "IMTQ self test (FINA) coil Y temperature: " << negXselfTestDataset.finaCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z temperature: " + sif::info << "IMTQ self test (FINA) coil Z temperature: " << negXselfTestDataset.finaCoilZTemperature << " °C" << std::endl; #endif } void IMTQHandler::handlePositiveYSelfTestReply(const uint8_t* packet) { - PoolReadGuard rg(&posXselfTestDataset); + PoolReadGuard rg(&posXselfTestDataset); - uint16_t offset = 2; - /** Init measurements */ - posYselfTestDataset.initErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - posYselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.initCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.initCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.initCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posYselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posYselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + uint16_t offset = 2; + /** Init measurements */ + posYselfTestDataset.initErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + posYselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.initCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.initCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.initCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posYselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posYselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** +X measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - posYselfTestDataset.err = *(packet + offset); - offset += 2; // STEP byte will not be stored - posYselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.coilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.coilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.coilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posYselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posYselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** +X measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + posYselfTestDataset.err = *(packet + offset); + offset += 2; // STEP byte will not be stored + posYselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.coilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.coilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.coilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posYselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posYselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** FINA measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - posYselfTestDataset.finaErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - posYselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.finaCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.finaCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.finaCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posYselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posYselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** FINA measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + posYselfTestDataset.finaErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + posYselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.finaCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.finaCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.finaCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posYselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posYselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ self test (INIT) err: " +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ self test (INIT) err: " << static_cast(posYselfTestDataset.initErr.value) << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field X: " << posYselfTestDataset.initRawMagX + sif::info << "IMTQ self test (INIT) raw magnetic field X: " << posYselfTestDataset.initRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << posYselfTestDataset.initRawMagY + sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << posYselfTestDataset.initRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << posYselfTestDataset.initRawMagZ + sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << posYselfTestDataset.initRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " << posYselfTestDataset.initCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " << posYselfTestDataset.initCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " << posYselfTestDataset.initCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) coil X current: " << posYselfTestDataset.initCoilXCurrent + sif::info << "IMTQ self test (INIT) coil X current: " << posYselfTestDataset.initCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y current: " << posYselfTestDataset.initCoilYCurrent + sif::info << "IMTQ self test (INIT) coil Y current: " << posYselfTestDataset.initCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z current: " << posYselfTestDataset.initCoilZCurrent + sif::info << "IMTQ self test (INIT) coil Z current: " << posYselfTestDataset.initCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil X temperature: " + sif::info << "IMTQ self test (INIT) coil X temperature: " << posYselfTestDataset.initCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y temperature: " + sif::info << "IMTQ self test (INIT) coil Y temperature: " << posYselfTestDataset.initCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z temperature: " + sif::info << "IMTQ self test (INIT) coil Z temperature: " << posYselfTestDataset.initCoilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+Y) err: " + sif::info << "IMTQ self test (+Y) err: " << static_cast(posYselfTestDataset.err.value) << std::endl; - sif::info << "IMTQ self test (+Y) raw magnetic field X: " << posYselfTestDataset.rawMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) raw magnetic field Y: " << posYselfTestDataset.rawMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) raw magnetic field Z: " << posYselfTestDataset.rawMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) calibrated magnetic field X: " << posYselfTestDataset.calMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) calibrated magnetic field Y: " << posYselfTestDataset.calMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) calibrated magnetic field Z: " << posYselfTestDataset.calMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) coil X current: " << posYselfTestDataset.coilXCurrent << " mA" + sif::info << "IMTQ self test (+Y) raw magnetic field X: " << posYselfTestDataset.rawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) coil Y current: " << posYselfTestDataset.coilYCurrent << " mA" + sif::info << "IMTQ self test (+Y) raw magnetic field Y: " << posYselfTestDataset.rawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) coil Z current: " << posYselfTestDataset.coilZCurrent << " mA" + sif::info << "IMTQ self test (+Y) raw magnetic field Z: " << posYselfTestDataset.rawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) coil X temperature: " << posYselfTestDataset.coilXTemperature + sif::info << "IMTQ self test (+Y) calibrated magnetic field X: " << posYselfTestDataset.calMagX + << " nT" << std::endl; + sif::info << "IMTQ self test (+Y) calibrated magnetic field Y: " << posYselfTestDataset.calMagY + << " nT" << std::endl; + sif::info << "IMTQ self test (+Y) calibrated magnetic field Z: " << posYselfTestDataset.calMagZ + << " nT" << std::endl; + sif::info << "IMTQ self test (+Y) coil X current: " << posYselfTestDataset.coilXCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+Y) coil Y current: " << posYselfTestDataset.coilYCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+Y) coil Z current: " << posYselfTestDataset.coilZCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+Y) coil X temperature: " << posYselfTestDataset.coilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+Y) coil Y temperature: " << posYselfTestDataset.coilYTemperature + sif::info << "IMTQ self test (+Y) coil Y temperature: " << posYselfTestDataset.coilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+Y) coil Z temperature: " << posYselfTestDataset.coilZTemperature + sif::info << "IMTQ self test (+Y) coil Z temperature: " << posYselfTestDataset.coilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) err: " + sif::info << "IMTQ self test (FINA) err: " << static_cast(posYselfTestDataset.finaErr.value) << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field X: " << posYselfTestDataset.finaRawMagX + sif::info << "IMTQ self test (FINA) raw magnetic field X: " << posYselfTestDataset.finaRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << posYselfTestDataset.finaRawMagY + sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << posYselfTestDataset.finaRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << posYselfTestDataset.finaRawMagZ + sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << posYselfTestDataset.finaRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " << posYselfTestDataset.finaCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " << posYselfTestDataset.finaCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " << posYselfTestDataset.finaCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) coil X current: " << posYselfTestDataset.finaCoilXCurrent + sif::info << "IMTQ self test (FINA) coil X current: " << posYselfTestDataset.finaCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y current: " << posYselfTestDataset.finaCoilYCurrent + sif::info << "IMTQ self test (FINA) coil Y current: " << posYselfTestDataset.finaCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z current: " << posYselfTestDataset.finaCoilZCurrent + sif::info << "IMTQ self test (FINA) coil Z current: " << posYselfTestDataset.finaCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil X temperature: " + sif::info << "IMTQ self test (FINA) coil X temperature: " << posYselfTestDataset.finaCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y temperature: " + sif::info << "IMTQ self test (FINA) coil Y temperature: " << posYselfTestDataset.finaCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z temperature: " + sif::info << "IMTQ self test (FINA) coil Z temperature: " << posYselfTestDataset.finaCoilZTemperature << " °C" << std::endl; #endif } void IMTQHandler::handleNegativeYSelfTestReply(const uint8_t* packet) { - PoolReadGuard rg(&posXselfTestDataset); + PoolReadGuard rg(&posXselfTestDataset); - uint16_t offset = 2; - /** Init measurements */ - posZselfTestDataset.initErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - negYselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.initCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.initCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.initCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negYselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negYselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + uint16_t offset = 2; + /** Init measurements */ + posZselfTestDataset.initErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + negYselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.initCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.initCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.initCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negYselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negYselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** +X measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - negYselfTestDataset.err = *(packet + offset); - offset += 2; // STEP byte will not be stored - negYselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.coilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.coilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.coilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negYselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negYselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** +X measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + negYselfTestDataset.err = *(packet + offset); + offset += 2; // STEP byte will not be stored + negYselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.coilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.coilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.coilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negYselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negYselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** FINA measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - negYselfTestDataset.finaErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - negYselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.finaCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.finaCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.finaCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negYselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negYselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** FINA measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + negYselfTestDataset.finaErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + negYselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.finaCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.finaCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.finaCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negYselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negYselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ self test (INIT) err: " +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ self test (INIT) err: " << static_cast(negYselfTestDataset.initErr.value) << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field X: " << negYselfTestDataset.initRawMagX + sif::info << "IMTQ self test (INIT) raw magnetic field X: " << negYselfTestDataset.initRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << negYselfTestDataset.initRawMagY + sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << negYselfTestDataset.initRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << negYselfTestDataset.initRawMagZ + sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << negYselfTestDataset.initRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " << negYselfTestDataset.initCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " << negYselfTestDataset.initCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " << negYselfTestDataset.initCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) coil X current: " << negYselfTestDataset.initCoilXCurrent + sif::info << "IMTQ self test (INIT) coil X current: " << negYselfTestDataset.initCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y current: " << negYselfTestDataset.initCoilYCurrent + sif::info << "IMTQ self test (INIT) coil Y current: " << negYselfTestDataset.initCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z current: " << negYselfTestDataset.initCoilZCurrent + sif::info << "IMTQ self test (INIT) coil Z current: " << negYselfTestDataset.initCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil X temperature: " + sif::info << "IMTQ self test (INIT) coil X temperature: " << negYselfTestDataset.initCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y temperature: " + sif::info << "IMTQ self test (INIT) coil Y temperature: " << negYselfTestDataset.initCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z temperature: " + sif::info << "IMTQ self test (INIT) coil Z temperature: " << negYselfTestDataset.initCoilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-Y) err: " + sif::info << "IMTQ self test (-Y) err: " << static_cast(negYselfTestDataset.err.value) << std::endl; - sif::info << "IMTQ self test (-Y) raw magnetic field X: " << negYselfTestDataset.rawMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) raw magnetic field Y: " << negYselfTestDataset.rawMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) raw magnetic field Z: " << negYselfTestDataset.rawMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) calibrated magnetic field X: " << negYselfTestDataset.calMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) calibrated magnetic field Y: " << negYselfTestDataset.calMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) calibrated magnetic field Z: " << negYselfTestDataset.calMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) coil X current: " << negYselfTestDataset.coilXCurrent << " mA" + sif::info << "IMTQ self test (-Y) raw magnetic field X: " << negYselfTestDataset.rawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) coil Y current: " << negYselfTestDataset.coilYCurrent << " mA" + sif::info << "IMTQ self test (-Y) raw magnetic field Y: " << negYselfTestDataset.rawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) coil Z current: " << negYselfTestDataset.coilZCurrent << " mA" + sif::info << "IMTQ self test (-Y) raw magnetic field Z: " << negYselfTestDataset.rawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) coil X temperature: " << negYselfTestDataset.coilXTemperature + sif::info << "IMTQ self test (-Y) calibrated magnetic field X: " << negYselfTestDataset.calMagX + << " nT" << std::endl; + sif::info << "IMTQ self test (-Y) calibrated magnetic field Y: " << negYselfTestDataset.calMagY + << " nT" << std::endl; + sif::info << "IMTQ self test (-Y) calibrated magnetic field Z: " << negYselfTestDataset.calMagZ + << " nT" << std::endl; + sif::info << "IMTQ self test (-Y) coil X current: " << negYselfTestDataset.coilXCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-Y) coil Y current: " << negYselfTestDataset.coilYCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-Y) coil Z current: " << negYselfTestDataset.coilZCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-Y) coil X temperature: " << negYselfTestDataset.coilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-Y) coil Y temperature: " << negYselfTestDataset.coilYTemperature + sif::info << "IMTQ self test (-Y) coil Y temperature: " << negYselfTestDataset.coilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-Y) coil Z temperature: " << negYselfTestDataset.coilZTemperature + sif::info << "IMTQ self test (-Y) coil Z temperature: " << negYselfTestDataset.coilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) err: " + sif::info << "IMTQ self test (FINA) err: " << static_cast(negYselfTestDataset.finaErr.value) << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field X: " << negYselfTestDataset.finaRawMagX + sif::info << "IMTQ self test (FINA) raw magnetic field X: " << negYselfTestDataset.finaRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << negYselfTestDataset.finaRawMagY + sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << negYselfTestDataset.finaRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << negYselfTestDataset.finaRawMagZ + sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << negYselfTestDataset.finaRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " << negYselfTestDataset.finaCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " << negYselfTestDataset.finaCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " << negYselfTestDataset.finaCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) coil X current: " << negYselfTestDataset.finaCoilXCurrent + sif::info << "IMTQ self test (FINA) coil X current: " << negYselfTestDataset.finaCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y current: " << negYselfTestDataset.finaCoilYCurrent + sif::info << "IMTQ self test (FINA) coil Y current: " << negYselfTestDataset.finaCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z current: " << negYselfTestDataset.finaCoilZCurrent + sif::info << "IMTQ self test (FINA) coil Z current: " << negYselfTestDataset.finaCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil X temperature: " + sif::info << "IMTQ self test (FINA) coil X temperature: " << negYselfTestDataset.finaCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y temperature: " + sif::info << "IMTQ self test (FINA) coil Y temperature: " << negYselfTestDataset.finaCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z temperature: " + sif::info << "IMTQ self test (FINA) coil Z temperature: " << negYselfTestDataset.finaCoilZTemperature << " °C" << std::endl; #endif } void IMTQHandler::handlePositiveZSelfTestReply(const uint8_t* packet) { - PoolReadGuard rg(&posXselfTestDataset); + PoolReadGuard rg(&posXselfTestDataset); - uint16_t offset = 2; - /** Init measurements */ - posZselfTestDataset.initErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - posZselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.initCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.initCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.initCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posZselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posZselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + uint16_t offset = 2; + /** Init measurements */ + posZselfTestDataset.initErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + posZselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.initCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.initCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.initCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posZselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posZselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** +X measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - posZselfTestDataset.err = *(packet + offset); - offset += 2; // STEP byte will not be stored - posZselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.coilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.coilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.coilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posZselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posZselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** +X measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + posZselfTestDataset.err = *(packet + offset); + offset += 2; // STEP byte will not be stored + posZselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.coilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.coilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.coilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posZselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posZselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** FINA measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - posZselfTestDataset.finaErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - posZselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.finaCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.finaCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.finaCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posZselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posZselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** FINA measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + posZselfTestDataset.finaErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + posZselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.finaCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.finaCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.finaCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posZselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posZselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ self test (INIT) err: " +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ self test (INIT) err: " << static_cast(posZselfTestDataset.initErr.value) << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field X: " << posZselfTestDataset.initRawMagX + sif::info << "IMTQ self test (INIT) raw magnetic field X: " << posZselfTestDataset.initRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << posZselfTestDataset.initRawMagY + sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << posZselfTestDataset.initRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << posZselfTestDataset.initRawMagZ + sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << posZselfTestDataset.initRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " << posZselfTestDataset.initCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " << posZselfTestDataset.initCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " << posZselfTestDataset.initCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) coil X current: " << posZselfTestDataset.initCoilXCurrent + sif::info << "IMTQ self test (INIT) coil X current: " << posZselfTestDataset.initCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y current: " << posZselfTestDataset.initCoilYCurrent + sif::info << "IMTQ self test (INIT) coil Y current: " << posZselfTestDataset.initCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z current: " << posZselfTestDataset.initCoilZCurrent + sif::info << "IMTQ self test (INIT) coil Z current: " << posZselfTestDataset.initCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil X temperature: " + sif::info << "IMTQ self test (INIT) coil X temperature: " << posZselfTestDataset.initCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y temperature: " + sif::info << "IMTQ self test (INIT) coil Y temperature: " << posZselfTestDataset.initCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z temperature: " + sif::info << "IMTQ self test (INIT) coil Z temperature: " << posZselfTestDataset.initCoilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+Z) err: " + sif::info << "IMTQ self test (+Z) err: " << static_cast(posZselfTestDataset.err.value) << std::endl; - sif::info << "IMTQ self test (+Z) raw magnetic field X: " << posZselfTestDataset.rawMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) raw magnetic field Y: " << posZselfTestDataset.rawMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) raw magnetic field Z: " << posZselfTestDataset.rawMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) calibrated magnetic field X: " << posZselfTestDataset.calMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) calibrated magnetic field Y: " << posZselfTestDataset.calMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) calibrated magnetic field Z: " << posZselfTestDataset.calMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) coil X current: " << posZselfTestDataset.coilXCurrent << " mA" + sif::info << "IMTQ self test (+Z) raw magnetic field X: " << posZselfTestDataset.rawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) coil Y current: " << posZselfTestDataset.coilYCurrent << " mA" + sif::info << "IMTQ self test (+Z) raw magnetic field Y: " << posZselfTestDataset.rawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) coil Z current: " << posZselfTestDataset.coilZCurrent << " mA" + sif::info << "IMTQ self test (+Z) raw magnetic field Z: " << posZselfTestDataset.rawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) coil X temperature: " << posZselfTestDataset.coilXTemperature + sif::info << "IMTQ self test (+Z) calibrated magnetic field X: " << posZselfTestDataset.calMagX + << " nT" << std::endl; + sif::info << "IMTQ self test (+Z) calibrated magnetic field Y: " << posZselfTestDataset.calMagY + << " nT" << std::endl; + sif::info << "IMTQ self test (+Z) calibrated magnetic field Z: " << posZselfTestDataset.calMagZ + << " nT" << std::endl; + sif::info << "IMTQ self test (+Z) coil X current: " << posZselfTestDataset.coilXCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+Z) coil Y current: " << posZselfTestDataset.coilYCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+Z) coil Z current: " << posZselfTestDataset.coilZCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+Z) coil X temperature: " << posZselfTestDataset.coilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+Z) coil Y temperature: " << posZselfTestDataset.coilYTemperature + sif::info << "IMTQ self test (+Z) coil Y temperature: " << posZselfTestDataset.coilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+Z) coil Z temperature: " << negYselfTestDataset.coilZTemperature + sif::info << "IMTQ self test (+Z) coil Z temperature: " << negYselfTestDataset.coilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) err: " + sif::info << "IMTQ self test (FINA) err: " << static_cast(posZselfTestDataset.finaErr.value) << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field X: " << posZselfTestDataset.finaRawMagX + sif::info << "IMTQ self test (FINA) raw magnetic field X: " << posZselfTestDataset.finaRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << posZselfTestDataset.finaRawMagY + sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << posZselfTestDataset.finaRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << posZselfTestDataset.finaRawMagZ + sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << posZselfTestDataset.finaRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " << posZselfTestDataset.finaCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " << posZselfTestDataset.finaCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " << posZselfTestDataset.finaCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) coil X current: " << posZselfTestDataset.finaCoilXCurrent + sif::info << "IMTQ self test (FINA) coil X current: " << posZselfTestDataset.finaCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y current: " << posZselfTestDataset.finaCoilYCurrent + sif::info << "IMTQ self test (FINA) coil Y current: " << posZselfTestDataset.finaCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z current: " << posZselfTestDataset.finaCoilZCurrent + sif::info << "IMTQ self test (FINA) coil Z current: " << posZselfTestDataset.finaCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil X temperature: " + sif::info << "IMTQ self test (FINA) coil X temperature: " << posZselfTestDataset.finaCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y temperature: " + sif::info << "IMTQ self test (FINA) coil Y temperature: " << posZselfTestDataset.finaCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z temperature: " + sif::info << "IMTQ self test (FINA) coil Z temperature: " << posZselfTestDataset.finaCoilZTemperature << " °C" << std::endl; #endif } void IMTQHandler::handleNegativeZSelfTestReply(const uint8_t* packet) { - PoolReadGuard rg(&posXselfTestDataset); + PoolReadGuard rg(&posXselfTestDataset); - uint16_t offset = 2; - /** Init measurements */ - negZselfTestDataset.initErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - negZselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.initCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.initCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.initCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negZselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negZselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + uint16_t offset = 2; + /** Init measurements */ + negZselfTestDataset.initErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + negZselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.initCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.initCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.initCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negZselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negZselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** +X measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - negZselfTestDataset.err = *(packet + offset); - offset += 2; // STEP byte will not be stored - negZselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.coilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.coilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.coilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negZselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negZselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** +X measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + negZselfTestDataset.err = *(packet + offset); + offset += 2; // STEP byte will not be stored + negZselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.coilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.coilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.coilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negZselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negZselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** FINA measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - negZselfTestDataset.finaErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - negZselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.finaCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.finaCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.finaCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negZselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negZselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** FINA measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + negZselfTestDataset.finaErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + negZselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.finaCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.finaCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.finaCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negZselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negZselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ self test (INIT) err: " +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ self test (INIT) err: " << static_cast(negZselfTestDataset.initErr.value) << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field X: " << negZselfTestDataset.initRawMagX + sif::info << "IMTQ self test (INIT) raw magnetic field X: " << negZselfTestDataset.initRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << negZselfTestDataset.initRawMagY + sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << negZselfTestDataset.initRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << negZselfTestDataset.initRawMagZ + sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << negZselfTestDataset.initRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " << negZselfTestDataset.initCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " << negZselfTestDataset.initCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " << negZselfTestDataset.initCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) coil X current: " << negZselfTestDataset.initCoilXCurrent + sif::info << "IMTQ self test (INIT) coil X current: " << negZselfTestDataset.initCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y current: " << negZselfTestDataset.initCoilYCurrent + sif::info << "IMTQ self test (INIT) coil Y current: " << negZselfTestDataset.initCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z current: " << negZselfTestDataset.initCoilZCurrent + sif::info << "IMTQ self test (INIT) coil Z current: " << negZselfTestDataset.initCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil X temperature: " + sif::info << "IMTQ self test (INIT) coil X temperature: " << negZselfTestDataset.initCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y temperature: " + sif::info << "IMTQ self test (INIT) coil Y temperature: " << negZselfTestDataset.initCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z temperature: " + sif::info << "IMTQ self test (INIT) coil Z temperature: " << negZselfTestDataset.initCoilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-Z) err: " + sif::info << "IMTQ self test (-Z) err: " << static_cast(negZselfTestDataset.err.value) << std::endl; - sif::info << "IMTQ self test (-Z) raw magnetic field X: " << negZselfTestDataset.rawMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) raw magnetic field Y: " << negZselfTestDataset.rawMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) raw magnetic field Z: " << negZselfTestDataset.rawMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) calibrated magnetic field X: " << negZselfTestDataset.calMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) calibrated magnetic field Y: " << negZselfTestDataset.calMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) calibrated magnetic field Z: " << negZselfTestDataset.calMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) coil X current: " << negZselfTestDataset.coilXCurrent << " mA" + sif::info << "IMTQ self test (-Z) raw magnetic field X: " << negZselfTestDataset.rawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) coil Y current: " << negZselfTestDataset.coilYCurrent << " mA" + sif::info << "IMTQ self test (-Z) raw magnetic field Y: " << negZselfTestDataset.rawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) coil Z current: " << negZselfTestDataset.coilZCurrent << " mA" + sif::info << "IMTQ self test (-Z) raw magnetic field Z: " << negZselfTestDataset.rawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) coil X temperature: " << negZselfTestDataset.coilXTemperature + sif::info << "IMTQ self test (-Z) calibrated magnetic field X: " << negZselfTestDataset.calMagX + << " nT" << std::endl; + sif::info << "IMTQ self test (-Z) calibrated magnetic field Y: " << negZselfTestDataset.calMagY + << " nT" << std::endl; + sif::info << "IMTQ self test (-Z) calibrated magnetic field Z: " << negZselfTestDataset.calMagZ + << " nT" << std::endl; + sif::info << "IMTQ self test (-Z) coil X current: " << negZselfTestDataset.coilXCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-Z) coil Y current: " << negZselfTestDataset.coilYCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-Z) coil Z current: " << negZselfTestDataset.coilZCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-Z) coil X temperature: " << negZselfTestDataset.coilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-Z) coil Y temperature: " << negZselfTestDataset.coilYTemperature + sif::info << "IMTQ self test (-Z) coil Y temperature: " << negZselfTestDataset.coilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-Z) coil Z temperature: " << negYselfTestDataset.coilZTemperature + sif::info << "IMTQ self test (-Z) coil Z temperature: " << negYselfTestDataset.coilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) err: " + sif::info << "IMTQ self test (FINA) err: " << static_cast(negZselfTestDataset.finaErr.value) << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field X: " << negZselfTestDataset.finaRawMagX + sif::info << "IMTQ self test (FINA) raw magnetic field X: " << negZselfTestDataset.finaRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << negZselfTestDataset.finaRawMagY + sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << negZselfTestDataset.finaRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << negZselfTestDataset.finaRawMagZ + sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << negZselfTestDataset.finaRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " << negZselfTestDataset.finaCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " << negZselfTestDataset.finaCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " << negZselfTestDataset.finaCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) coil X current: " << negZselfTestDataset.finaCoilXCurrent + sif::info << "IMTQ self test (FINA) coil X current: " << negZselfTestDataset.finaCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y current: " << negZselfTestDataset.finaCoilYCurrent + sif::info << "IMTQ self test (FINA) coil Y current: " << negZselfTestDataset.finaCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z current: " << negZselfTestDataset.finaCoilZCurrent + sif::info << "IMTQ self test (FINA) coil Z current: " << negZselfTestDataset.finaCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil X temperature: " + sif::info << "IMTQ self test (FINA) coil X temperature: " << negZselfTestDataset.finaCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y temperature: " + sif::info << "IMTQ self test (FINA) coil Y temperature: " << negZselfTestDataset.finaCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z temperature: " + sif::info << "IMTQ self test (FINA) coil Z temperature: " << negZselfTestDataset.finaCoilZTemperature << " °C" << std::endl; #endif } void IMTQHandler::checkErrorByte(const uint8_t errorByte, const uint8_t step) { - std::string stepString(""); - if (step < 8) { - stepString = makeStepString(step); - } else { - /** This should normally never happen */ - sif::debug << "IMTQHandler::checkErrorByte: Invalid step" << std::endl; - return; - } + std::string stepString(""); + if (step < 8) { + stepString = makeStepString(step); + } else { + /** This should normally never happen */ + sif::debug << "IMTQHandler::checkErrorByte: Invalid step" << std::endl; + return; + } - if (errorByte == 0) { - return; - } + if (errorByte == 0) { + return; + } - if (errorByte & IMTQ::I2C_FAILURE_MASK) { - triggerEvent(SELF_TEST_I2C_FAILURE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test I2C failure for step " << stepString - << std::endl; - } - if (errorByte & IMTQ::SPI_FAILURE_MASK) { - triggerEvent(SELF_TEST_SPI_FAILURE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test SPI failure for step " << stepString - << std::endl; - } - if (errorByte & IMTQ::ADC_FAILURE_MASK) { - triggerEvent(SELF_TEST_ADC_FAILURE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test ADC failure for step " << stepString - << std::endl; - } - if (errorByte & IMTQ::PWM_FAILURE_MASK) { - triggerEvent(SELF_TEST_PWM_FAILURE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test PWM failure for step " << stepString - << std::endl; - } - if (errorByte & IMTQ::TC_FAILURE_MASK) { - triggerEvent(SELF_TEST_TC_FAILURE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test TC failure (system failure) for step " - << stepString << std::endl; - } - if (errorByte & IMTQ::MTM_RANGE_FAILURE_MASK) { - triggerEvent(SELF_TEST_TC_FAILURE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test MTM range failure for step " - << stepString << std::endl; - } - if (errorByte & IMTQ::COIL_CURRENT_FAILURE_MASK) { - triggerEvent(SELF_TEST_COIL_CURRENT_FAILURE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test coil current outside of expected " - "range for step " << stepString << std::endl; - } + if (errorByte & IMTQ::I2C_FAILURE_MASK) { + triggerEvent(SELF_TEST_I2C_FAILURE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test I2C failure for step " << stepString + << std::endl; + } + if (errorByte & IMTQ::SPI_FAILURE_MASK) { + triggerEvent(SELF_TEST_SPI_FAILURE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test SPI failure for step " << stepString + << std::endl; + } + if (errorByte & IMTQ::ADC_FAILURE_MASK) { + triggerEvent(SELF_TEST_ADC_FAILURE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test ADC failure for step " << stepString + << std::endl; + } + if (errorByte & IMTQ::PWM_FAILURE_MASK) { + triggerEvent(SELF_TEST_PWM_FAILURE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test PWM failure for step " << stepString + << std::endl; + } + if (errorByte & IMTQ::TC_FAILURE_MASK) { + triggerEvent(SELF_TEST_TC_FAILURE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test TC failure (system failure) for step " + << stepString << std::endl; + } + if (errorByte & IMTQ::MTM_RANGE_FAILURE_MASK) { + triggerEvent(SELF_TEST_TC_FAILURE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test MTM range failure for step " << stepString + << std::endl; + } + if (errorByte & IMTQ::COIL_CURRENT_FAILURE_MASK) { + triggerEvent(SELF_TEST_COIL_CURRENT_FAILURE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test coil current outside of expected " + "range for step " + << stepString << std::endl; + } - if (errorByte & IMTQ::INVALID_ERROR_BYTE) { - triggerEvent(INVALID_ERROR_BYTE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test result of step " << stepString - << " has invalid error byte" << std::endl; - } + if (errorByte & IMTQ::INVALID_ERROR_BYTE) { + triggerEvent(INVALID_ERROR_BYTE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test result of step " << stepString + << " has invalid error byte" << std::endl; + } } std::string IMTQHandler::makeStepString(const uint8_t step) { - std::string stepString(""); - switch (step) { + std::string stepString(""); + switch (step) { case IMTQ::SELF_TEST_STEPS::INIT: - stepString = std::string("INIT"); - break; + stepString = std::string("INIT"); + break; case IMTQ::SELF_TEST_STEPS::X_POSITIVE: - stepString = std::string("+X"); - break; + stepString = std::string("+X"); + break; case IMTQ::SELF_TEST_STEPS::X_NEGATIVE: - stepString = std::string("-X"); - break; + stepString = std::string("-X"); + break; case IMTQ::SELF_TEST_STEPS::Y_POSITIVE: - stepString = std::string("+Y"); - break; + stepString = std::string("+Y"); + break; case IMTQ::SELF_TEST_STEPS::Y_NEGATIVE: - stepString = std::string("-Y"); - break; + stepString = std::string("-Y"); + break; case IMTQ::SELF_TEST_STEPS::Z_POSITIVE: - stepString = std::string("+Z"); - break; + stepString = std::string("+Z"); + break; case IMTQ::SELF_TEST_STEPS::Z_NEGATIVE: - stepString = std::string("-Z"); - break; + stepString = std::string("-Z"); + break; case IMTQ::SELF_TEST_STEPS::FINA: - stepString = std::string("FINA"); - break; + stepString = std::string("FINA"); + break; default: - sif::error << "IMTQHandler::checkErrorByte: Received packet with invalid step information" - << std::endl; - break; - } - return stepString; + sif::error << "IMTQHandler::checkErrorByte: Received packet with invalid step information" + << std::endl; + break; + } + return stepString; } - diff --git a/mission/devices/IMTQHandler.h b/mission/devices/IMTQHandler.h index ce9e45e0..b12cdf97 100644 --- a/mission/devices/IMTQHandler.h +++ b/mission/devices/IMTQHandler.h @@ -10,186 +10,188 @@ * * @author J. Meier */ -class IMTQHandler: public DeviceHandlerBase { -public: +class IMTQHandler : public DeviceHandlerBase { + public: + IMTQHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + virtual ~IMTQHandler(); - IMTQHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); - virtual ~IMTQHandler(); + /** + * @brief Sets mode to MODE_NORMAL. Can be used for debugging. + */ + void setModeNormal(); - /** - * @brief Sets mode to MODE_NORMAL. Can be used for debugging. - */ - void setModeNormal(); + 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; + virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) 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; - virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::IMTQ_HANDLER; -private: + static const ReturnValue_t INVALID_COMMAND_CODE = MAKE_RETURN_CODE(0xA0); + static const ReturnValue_t PARAMETER_MISSING = MAKE_RETURN_CODE(0xA1); + static const ReturnValue_t PARAMETER_INVALID = MAKE_RETURN_CODE(0xA2); + static const ReturnValue_t CC_UNAVAILABLE = MAKE_RETURN_CODE(0xA3); + static const ReturnValue_t INTERNAL_PROCESSING_ERROR = MAKE_RETURN_CODE(0xA4); + static const ReturnValue_t REJECTED_WITHOUT_REASON = MAKE_RETURN_CODE(0xA5); + static const ReturnValue_t CMD_ERR_UNKNOWN = MAKE_RETURN_CODE(0xA6); + //! [EXPORT] : [COMMENT] The status reply to a self test command was received but no self test + //! command has been sent. This should normally never happen. + static const ReturnValue_t UNEXPECTED_SELF_TEST_REPLY = MAKE_RETURN_CODE(0xA7); - static const uint8_t INTERFACE_ID = CLASS_ID::IMTQ_HANDLER; + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::IMTQ_HANDLER; - static const ReturnValue_t INVALID_COMMAND_CODE = MAKE_RETURN_CODE(0xA0); - static const ReturnValue_t PARAMETER_MISSING = MAKE_RETURN_CODE(0xA1); - static const ReturnValue_t PARAMETER_INVALID = MAKE_RETURN_CODE(0xA2); - static const ReturnValue_t CC_UNAVAILABLE = MAKE_RETURN_CODE(0xA3); - static const ReturnValue_t INTERNAL_PROCESSING_ERROR = MAKE_RETURN_CODE(0xA4); - static const ReturnValue_t REJECTED_WITHOUT_REASON = MAKE_RETURN_CODE(0xA5); - static const ReturnValue_t CMD_ERR_UNKNOWN = MAKE_RETURN_CODE(0xA6); - //! [EXPORT] : [COMMENT] The status reply to a self test command was received but no self test command has been sent. This should normally never happen. - static const ReturnValue_t UNEXPECTED_SELF_TEST_REPLY = MAKE_RETURN_CODE(0xA7); + //! [EXPORT] : [COMMENT] Get self test result returns I2C failure + //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> + //! -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA + static const Event SELF_TEST_I2C_FAILURE = MAKE_EVENT(1, severity::LOW); + //! [EXPORT] : [COMMENT] Get self test result returns SPI failure. This concerns the MTM + //! connectivity. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 + //! -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA + static const Event SELF_TEST_SPI_FAILURE = MAKE_EVENT(2, severity::LOW); + //! [EXPORT] : [COMMENT] Get self test result returns failure in measurement of current and + //! temperature. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 + //! -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA + static const Event SELF_TEST_ADC_FAILURE = MAKE_EVENT(3, severity::LOW); + //! [EXPORT] : [COMMENT] Get self test result returns PWM failure which concerns the coil + //! actuation. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> + //! +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA + static const Event SELF_TEST_PWM_FAILURE = MAKE_EVENT(4, severity::LOW); + //! [EXPORT] : [COMMENT] Get self test result returns TC failure (system failure) + //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> + //! -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA + static const Event SELF_TEST_TC_FAILURE = MAKE_EVENT(5, severity::LOW); + //! [EXPORT] : [COMMENT] Get self test result returns failure that MTM values were outside of the + //! expected range. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, + //! 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA + static const Event SELF_TEST_MTM_RANGE_FAILURE = MAKE_EVENT(6, severity::LOW); + //! [EXPORT] : [COMMENT] Get self test result returns failure indicating that the coil current was + //! outside of the expected range P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 + //! -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA + static const Event SELF_TEST_COIL_CURRENT_FAILURE = MAKE_EVENT(7, severity::LOW); + //! [EXPORT] : [COMMENT] Received invalid error byte. This indicates an error of the communication + //! link between IMTQ and OBC. + static const Event INVALID_ERROR_BYTE = MAKE_EVENT(8, severity::LOW); - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::IMTQ_HANDLER; + IMTQ::EngHkDataset engHkDataset; + IMTQ::CalibratedMtmMeasurementSet calMtmMeasurementSet; + IMTQ::RawMtmMeasurementSet rawMtmMeasurementSet; + IMTQ::PosXSelfTestSet posXselfTestDataset; + IMTQ::NegXSelfTestSet negXselfTestDataset; + IMTQ::PosYSelfTestSet posYselfTestDataset; + IMTQ::NegYSelfTestSet negYselfTestDataset; + IMTQ::PosZSelfTestSet posZselfTestDataset; + IMTQ::NegZSelfTestSet negZselfTestDataset; - //! [EXPORT] : [COMMENT] Get self test result returns I2C failure - //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA - static const Event SELF_TEST_I2C_FAILURE = MAKE_EVENT(1, severity::LOW); - //! [EXPORT] : [COMMENT] Get self test result returns SPI failure. This concerns the MTM connectivity. - //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA - static const Event SELF_TEST_SPI_FAILURE = MAKE_EVENT(2, severity::LOW); - //! [EXPORT] : [COMMENT] Get self test result returns failure in measurement of current and temperature. - //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA - static const Event SELF_TEST_ADC_FAILURE = MAKE_EVENT(3, severity::LOW); - //! [EXPORT] : [COMMENT] Get self test result returns PWM failure which concerns the coil actuation. - //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA - static const Event SELF_TEST_PWM_FAILURE = MAKE_EVENT(4, severity::LOW); - //! [EXPORT] : [COMMENT] Get self test result returns TC failure (system failure) - //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA - static const Event SELF_TEST_TC_FAILURE = MAKE_EVENT(5, severity::LOW); - //! [EXPORT] : [COMMENT] Get self test result returns failure that MTM values were outside of the expected range. - //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA - static const Event SELF_TEST_MTM_RANGE_FAILURE = MAKE_EVENT(6, severity::LOW); - //! [EXPORT] : [COMMENT] Get self test result returns failure indicating that the coil current was outside of the expected range - //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA - static const Event SELF_TEST_COIL_CURRENT_FAILURE = MAKE_EVENT(7, severity::LOW); - //! [EXPORT] : [COMMENT] Received invalid error byte. This indicates an error of the communication link between IMTQ and OBC. - static const Event INVALID_ERROR_BYTE = MAKE_EVENT(8, severity::LOW); + uint8_t commandBuffer[IMTQ::MAX_COMMAND_SIZE]; - IMTQ::EngHkDataset engHkDataset; - IMTQ::CalibratedMtmMeasurementSet calMtmMeasurementSet; - IMTQ::RawMtmMeasurementSet rawMtmMeasurementSet; - IMTQ::PosXSelfTestSet posXselfTestDataset; - IMTQ::NegXSelfTestSet negXselfTestDataset; - IMTQ::PosYSelfTestSet posYselfTestDataset; - IMTQ::NegYSelfTestSet negYselfTestDataset; - IMTQ::PosZSelfTestSet posZselfTestDataset; - IMTQ::NegZSelfTestSet negZselfTestDataset; + enum class CommunicationStep { + GET_ENG_HK_DATA, + START_MTM_MEASUREMENT, + GET_CAL_MTM_MEASUREMENT, + GET_RAW_MTM_MEASUREMENT + }; - uint8_t commandBuffer[IMTQ::MAX_COMMAND_SIZE]; + CommunicationStep communicationStep = CommunicationStep::GET_ENG_HK_DATA; - enum class CommunicationStep { - GET_ENG_HK_DATA, - START_MTM_MEASUREMENT, - GET_CAL_MTM_MEASUREMENT, - GET_RAW_MTM_MEASUREMENT - }; + enum class StartupStep { NONE, COMMAND_SELF_TEST, GET_SELF_TEST_RESULT }; - CommunicationStep communicationStep = CommunicationStep::GET_ENG_HK_DATA; + StartupStep startupStep = StartupStep::COMMAND_SELF_TEST; - enum class StartupStep { - NONE, - COMMAND_SELF_TEST, - GET_SELF_TEST_RESULT - }; + bool selfTestPerformed = false; - StartupStep startupStep = StartupStep::COMMAND_SELF_TEST; + /** + * @brief In case of a status reply to a single axis self test command, this function + * searches for the actual pending command. + */ + ReturnValue_t getSelfTestCommandId(DeviceCommandId_t* id); - bool selfTestPerformed = false; + /** + * @brief Each reply contains a status byte giving information about a request. This function + * parses this byte and returns the associated failure message. + * + * @param packet Pointer to the received message containing the status byte. + * + * @return The return code derived from the received status byte. + */ + ReturnValue_t parseStatusByte(const uint8_t* packet); - /** - * @brief In case of a status reply to a single axis self test command, this function - * searches for the actual pending command. - */ - ReturnValue_t getSelfTestCommandId(DeviceCommandId_t* id); + /** + * @brief This function fills the engineering housekeeping dataset with the received data. - /** - * @brief Each reply contains a status byte giving information about a request. This function - * parses this byte and returns the associated failure message. - * - * @param packet Pointer to the received message containing the status byte. - * - * @return The return code derived from the received status byte. - */ - ReturnValue_t parseStatusByte(const uint8_t* packet); + * @param packet Pointer to the received data. + * + */ + void fillEngHkDataset(const uint8_t* packet); - /** - * @brief This function fills the engineering housekeeping dataset with the received data. + /** + * @brief This function sends a command reply to the requesting queue. + * + * @param data Pointer to the data to send. + * @param dataSize Size of the data to send. + * @param relplyId Reply id which will be inserted at the beginning of the action message. + */ + void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); - * @param packet Pointer to the received data. - * - */ - void fillEngHkDataset(const uint8_t* packet); + /** + * @brief This function handles the reply containing the commanded dipole. + * + * @param packet Pointer to the reply data. + */ + void handleGetCommandedDipoleReply(const uint8_t* packet); - /** - * @brief This function sends a command reply to the requesting queue. - * - * @param data Pointer to the data to send. - * @param dataSize Size of the data to send. - * @param relplyId Reply id which will be inserted at the beginning of the action message. - */ - void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); + /** + * @brief This function parses the reply containing the calibrated MTM measurement and writes + * the values to the appropriate dataset. + * @param packet Pointer to the reply data. + */ + void fillCalibratedMtmDataset(const uint8_t* packet); - /** - * @brief This function handles the reply containing the commanded dipole. - * - * @param packet Pointer to the reply data. - */ - void handleGetCommandedDipoleReply(const uint8_t* packet); + /** + * @brief This function copies the raw MTM measurements to the MTM raw dataset. + * @param packet Pointer to the reply data requested with the GET_RAW_MTM_MEASUREMENTS + * command. + */ + void fillRawMtmDataset(const uint8_t* packet); - /** - * @brief This function parses the reply containing the calibrated MTM measurement and writes - * the values to the appropriate dataset. - * @param packet Pointer to the reply data. - */ - void fillCalibratedMtmDataset(const uint8_t* packet); + /** + * @brief This function handles all self test results. This comprises parsing the error byte + * and step byte and calling the function to fill the respective dataset. + */ + void handleSelfTestReply(const uint8_t* packet); - /** - * @brief This function copies the raw MTM measurements to the MTM raw dataset. - * @param packet Pointer to the reply data requested with the GET_RAW_MTM_MEASUREMENTS - * command. - */ - void fillRawMtmDataset(const uint8_t* packet); + /** + * @brief The following functions fill the respective dataset of the single axis self tests. + * @param packet Pointer to the reply data holding the self test result. + */ + void handlePositiveXSelfTestReply(const uint8_t* packet); + void handleNegativeXSelfTestReply(const uint8_t* packet); + void handlePositiveYSelfTestReply(const uint8_t* packet); + void handleNegativeYSelfTestReply(const uint8_t* packet); + void handlePositiveZSelfTestReply(const uint8_t* packet); + void handleNegativeZSelfTestReply(const uint8_t* packet); - /** - * @brief This function handles all self test results. This comprises parsing the error byte - * and step byte and calling the function to fill the respective dataset. - */ - void handleSelfTestReply(const uint8_t* packet); + /** + * @brief This function checks the error byte of a self test measurement. + * + * @param errorByte The received error byte to check + * @param step The step of the error byte. + */ + void checkErrorByte(const uint8_t errorByte, const uint8_t step); - /** - * @brief The following functions fill the respective dataset of the single axis self tests. - * @param packet Pointer to the reply data holding the self test result. - */ - void handlePositiveXSelfTestReply(const uint8_t* packet); - void handleNegativeXSelfTestReply(const uint8_t* packet); - void handlePositiveYSelfTestReply(const uint8_t* packet); - void handleNegativeYSelfTestReply(const uint8_t* packet); - void handlePositiveZSelfTestReply(const uint8_t* packet); - void handleNegativeZSelfTestReply(const uint8_t* packet); - - /** - * @brief This function checks the error byte of a self test measurement. - * - * @param errorByte The received error byte to check - * @param step The step of the error byte. - */ - void checkErrorByte(const uint8_t errorByte, const uint8_t step); - - std::string makeStepString(const uint8_t step); + std::string makeStepString(const uint8_t step); }; #endif /* MISSION_DEVICES_IMTQHANDLER_H_ */ diff --git a/mission/devices/Max31865PT1000Handler.cpp b/mission/devices/Max31865PT1000Handler.cpp index 750d56e5..809e669b 100644 --- a/mission/devices/Max31865PT1000Handler.cpp +++ b/mission/devices/Max31865PT1000Handler.cpp @@ -1,546 +1,531 @@ #include "Max31865PT1000Handler.h" -#include "fsfw/datapool/PoolReadGuard.h" - #include #include +#include "fsfw/datapool/PoolReadGuard.h" + Max31865PT1000Handler::Max31865PT1000Handler(object_id_t objectId, object_id_t comIF, - CookieIF *comCookie): - DeviceHandlerBase(objectId, comIF, comCookie), - sensorDataset(this), sensorDatasetSid(sensorDataset.getSid()) { + CookieIF *comCookie) + : DeviceHandlerBase(objectId, comIF, comCookie), + sensorDataset(this), + sensorDatasetSid(sensorDataset.getSid()) { #if OBSW_VERBOSE_LEVEL >= 1 - debugDivider = new PeriodicOperationDivider(10); + debugDivider = new PeriodicOperationDivider(10); #endif } -Max31865PT1000Handler::~Max31865PT1000Handler() { -} +Max31865PT1000Handler::~Max31865PT1000Handler() {} void Max31865PT1000Handler::doStartUp() { - if(internalState == InternalState::NONE) { - internalState = InternalState::WARMUP; - Clock::getUptime(&startTime); - } + if (internalState == InternalState::NONE) { + internalState = InternalState::WARMUP; + Clock::getUptime(&startTime); + } - if(internalState == InternalState::WARMUP) { - dur_millis_t timeNow = 0; - Clock::getUptime(&timeNow); - if(timeNow - startTime >= 100) { - internalState = InternalState::CONFIGURE; - } + if (internalState == InternalState::WARMUP) { + dur_millis_t timeNow = 0; + Clock::getUptime(&timeNow); + if (timeNow - startTime >= 100) { + internalState = InternalState::CONFIGURE; } + } - if(internalState == InternalState::CONFIGURE) { - if(commandExecuted) { - commandExecuted = false; - internalState = InternalState::REQUEST_CONFIG; - } + if (internalState == InternalState::CONFIGURE) { + if (commandExecuted) { + commandExecuted = false; + internalState = InternalState::REQUEST_CONFIG; } + } - if(internalState == InternalState::REQUEST_CONFIG) { - if (commandExecuted) { - commandExecuted = false; - internalState = InternalState::CONFIG_HIGH_THRESHOLD; - } + if (internalState == InternalState::REQUEST_CONFIG) { + if (commandExecuted) { + commandExecuted = false; + internalState = InternalState::CONFIG_HIGH_THRESHOLD; } + } - if(internalState == InternalState::CONFIG_HIGH_THRESHOLD) { - if(commandExecuted) { - internalState = InternalState::REQUEST_HIGH_THRESHOLD; - commandExecuted = false; - } + if (internalState == InternalState::CONFIG_HIGH_THRESHOLD) { + if (commandExecuted) { + internalState = InternalState::REQUEST_HIGH_THRESHOLD; + commandExecuted = false; } + } - if(internalState == InternalState::REQUEST_HIGH_THRESHOLD) { - if(commandExecuted) { - internalState = InternalState::CONFIG_LOW_THRESHOLD; - commandExecuted = false; - } + if (internalState == InternalState::REQUEST_HIGH_THRESHOLD) { + if (commandExecuted) { + internalState = InternalState::CONFIG_LOW_THRESHOLD; + commandExecuted = false; } + } - if(internalState == InternalState::CONFIG_LOW_THRESHOLD) { - if(commandExecuted) { - internalState = InternalState::REQUEST_LOW_THRESHOLD; - commandExecuted = false; - } + if (internalState == InternalState::CONFIG_LOW_THRESHOLD) { + if (commandExecuted) { + internalState = InternalState::REQUEST_LOW_THRESHOLD; + commandExecuted = false; } + } - if(internalState == InternalState::REQUEST_LOW_THRESHOLD) { - if(commandExecuted) { - internalState = InternalState::CLEAR_FAULT_BYTE; - commandExecuted = false; - } + if (internalState == InternalState::REQUEST_LOW_THRESHOLD) { + if (commandExecuted) { + internalState = InternalState::CLEAR_FAULT_BYTE; + commandExecuted = false; } - if(internalState == InternalState::CLEAR_FAULT_BYTE) { - if(commandExecuted) { - commandExecuted = false; - internalState = InternalState::RUNNING; - if(instantNormal) { - setMode(MODE_NORMAL); - } else { - setMode(_MODE_TO_ON); - } - } + } + if (internalState == InternalState::CLEAR_FAULT_BYTE) { + if (commandExecuted) { + commandExecuted = false; + internalState = InternalState::RUNNING; + if (instantNormal) { + setMode(MODE_NORMAL); + } else { + setMode(_MODE_TO_ON); + } } + } } void Max31865PT1000Handler::doShutDown() { - commandExecuted = false; - setMode(_MODE_POWER_DOWN); + commandExecuted = false; + setMode(_MODE_POWER_DOWN); } -ReturnValue_t Max31865PT1000Handler::buildNormalDeviceCommand( - DeviceCommandId_t *id) { - if(internalState == InternalState::RUNNING) { - *id = Max31865Definitions::REQUEST_RTD; - return buildCommandFromCommand(*id, nullptr, 0); - } - else if(internalState == InternalState::REQUEST_FAULT_BYTE) { - *id = Max31865Definitions::REQUEST_FAULT_BYTE; - return buildCommandFromCommand(*id, nullptr, 0); - } - else if(internalState == InternalState::CLEAR_FAULT_BYTE) { - *id = Max31865Definitions::CLEAR_FAULT_BYTE; - return buildCommandFromCommand(*id, nullptr, 0); - } - else { - return DeviceHandlerBase::NOTHING_TO_SEND; - } -} - -ReturnValue_t Max31865PT1000Handler::buildTransitionDeviceCommand( - DeviceCommandId_t *id) { - switch(internalState) { - case(InternalState::NONE): - case(InternalState::WARMUP): - case(InternalState::RUNNING): +ReturnValue_t Max31865PT1000Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + if (internalState == InternalState::RUNNING) { + *id = Max31865Definitions::REQUEST_RTD; + return buildCommandFromCommand(*id, nullptr, 0); + } else if (internalState == InternalState::REQUEST_FAULT_BYTE) { + *id = Max31865Definitions::REQUEST_FAULT_BYTE; + return buildCommandFromCommand(*id, nullptr, 0); + } else if (internalState == InternalState::CLEAR_FAULT_BYTE) { + *id = Max31865Definitions::CLEAR_FAULT_BYTE; + return buildCommandFromCommand(*id, nullptr, 0); + } else { return DeviceHandlerBase::NOTHING_TO_SEND; - case(InternalState::CONFIGURE): { - *id = Max31865Definitions::CONFIG_CMD; - uint8_t config[1] = {DEFAULT_CONFIG}; - return buildCommandFromCommand(*id, config, 1); + } +} + +ReturnValue_t Max31865PT1000Handler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { + switch (internalState) { + case (InternalState::NONE): + case (InternalState::WARMUP): + case (InternalState::RUNNING): + return DeviceHandlerBase::NOTHING_TO_SEND; + case (InternalState::CONFIGURE): { + *id = Max31865Definitions::CONFIG_CMD; + uint8_t config[1] = {DEFAULT_CONFIG}; + return buildCommandFromCommand(*id, config, 1); } - case(InternalState::REQUEST_CONFIG): { - *id = Max31865Definitions::REQUEST_CONFIG; - return buildCommandFromCommand(*id, nullptr, 0); + case (InternalState::REQUEST_CONFIG): { + *id = Max31865Definitions::REQUEST_CONFIG; + return buildCommandFromCommand(*id, nullptr, 0); } - case(InternalState::CONFIG_HIGH_THRESHOLD): { - *id = Max31865Definitions::WRITE_HIGH_THRESHOLD; - return buildCommandFromCommand(*id, nullptr, 0); + case (InternalState::CONFIG_HIGH_THRESHOLD): { + *id = Max31865Definitions::WRITE_HIGH_THRESHOLD; + return buildCommandFromCommand(*id, nullptr, 0); } - case(InternalState::REQUEST_HIGH_THRESHOLD): { - *id = Max31865Definitions::REQUEST_HIGH_THRESHOLD; - return buildCommandFromCommand(*id, nullptr, 0); + case (InternalState::REQUEST_HIGH_THRESHOLD): { + *id = Max31865Definitions::REQUEST_HIGH_THRESHOLD; + return buildCommandFromCommand(*id, nullptr, 0); } - case(InternalState::CONFIG_LOW_THRESHOLD): { - *id = Max31865Definitions::WRITE_LOW_THRESHOLD; - return buildCommandFromCommand(*id, nullptr, 0); + case (InternalState::CONFIG_LOW_THRESHOLD): { + *id = Max31865Definitions::WRITE_LOW_THRESHOLD; + return buildCommandFromCommand(*id, nullptr, 0); } - case(InternalState::REQUEST_LOW_THRESHOLD): { - *id = Max31865Definitions::REQUEST_LOW_THRESHOLD; - return buildCommandFromCommand(*id, nullptr, 0); + case (InternalState::REQUEST_LOW_THRESHOLD): { + *id = Max31865Definitions::REQUEST_LOW_THRESHOLD; + return buildCommandFromCommand(*id, nullptr, 0); } - case(InternalState::CLEAR_FAULT_BYTE): { - *id = Max31865Definitions::CLEAR_FAULT_BYTE; - return buildCommandFromCommand(*id, nullptr, 0); + case (InternalState::CLEAR_FAULT_BYTE): { + *id = Max31865Definitions::CLEAR_FAULT_BYTE; + return buildCommandFromCommand(*id, nullptr, 0); } default: #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Max31865PT1000Handler: Invalid internal state" << std::endl; + sif::error << "Max31865PT1000Handler: Invalid internal state" << std::endl; #else - sif::printError("Max31865PT1000Handler: Invalid internal state\n"); + sif::printError("Max31865PT1000Handler: Invalid internal state\n"); #endif - return HasReturnvaluesIF::RETURN_FAILED; - } + return HasReturnvaluesIF::RETURN_FAILED; + } } -ReturnValue_t Max31865PT1000Handler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t *commandData, - size_t commandDataLen) { - switch(deviceCommand) { - case(Max31865Definitions::CONFIG_CMD) : { - commandBuffer[0] = static_cast(Max31865Definitions::CONFIG_CMD); - if(commandDataLen == 1) { - commandBuffer[1] = commandData[0]; - DeviceHandlerBase::rawPacketLen = 2; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; - } - else { - return DeviceHandlerIF::NO_COMMAND_DATA; - } - } - case(Max31865Definitions::CLEAR_FAULT_BYTE): { - commandBuffer[0] = static_cast(Max31865Definitions::CONFIG_CMD); - commandBuffer[1] = Max31865Definitions::CLEAR_FAULT_BIT_VAL; +ReturnValue_t Max31865PT1000Handler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, + size_t commandDataLen) { + switch (deviceCommand) { + case (Max31865Definitions::CONFIG_CMD): { + commandBuffer[0] = static_cast(Max31865Definitions::CONFIG_CMD); + if (commandDataLen == 1) { + commandBuffer[1] = commandData[0]; DeviceHandlerBase::rawPacketLen = 2; DeviceHandlerBase::rawPacket = commandBuffer.data(); return HasReturnvaluesIF::RETURN_OK; + } else { + return DeviceHandlerIF::NO_COMMAND_DATA; + } } - case(Max31865Definitions::REQUEST_CONFIG): { - commandBuffer[0] = static_cast( - Max31865Definitions::REQUEST_CONFIG); - commandBuffer[1] = 0x00; // dummy byte - DeviceHandlerBase::rawPacketLen = 2; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; + case (Max31865Definitions::CLEAR_FAULT_BYTE): { + commandBuffer[0] = static_cast(Max31865Definitions::CONFIG_CMD); + commandBuffer[1] = Max31865Definitions::CLEAR_FAULT_BIT_VAL; + DeviceHandlerBase::rawPacketLen = 2; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; } - case(Max31865Definitions::WRITE_HIGH_THRESHOLD): { - commandBuffer[0] = static_cast( - Max31865Definitions::WRITE_HIGH_THRESHOLD); - commandBuffer[1] = static_cast(HIGH_THRESHOLD >> 8); - commandBuffer[2] = static_cast(HIGH_THRESHOLD & 0xFF); - DeviceHandlerBase::rawPacketLen = 3; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; + case (Max31865Definitions::REQUEST_CONFIG): { + commandBuffer[0] = static_cast(Max31865Definitions::REQUEST_CONFIG); + commandBuffer[1] = 0x00; // dummy byte + DeviceHandlerBase::rawPacketLen = 2; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; } - case(Max31865Definitions::REQUEST_HIGH_THRESHOLD): { - commandBuffer[0] = static_cast( - Max31865Definitions::REQUEST_HIGH_THRESHOLD); - commandBuffer[1] = 0x00; //dummy byte - commandBuffer[2] = 0x00; //dummy byte - DeviceHandlerBase::rawPacketLen = 3; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; + case (Max31865Definitions::WRITE_HIGH_THRESHOLD): { + commandBuffer[0] = static_cast(Max31865Definitions::WRITE_HIGH_THRESHOLD); + commandBuffer[1] = static_cast(HIGH_THRESHOLD >> 8); + commandBuffer[2] = static_cast(HIGH_THRESHOLD & 0xFF); + DeviceHandlerBase::rawPacketLen = 3; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; } - case(Max31865Definitions::WRITE_LOW_THRESHOLD): { - commandBuffer[0] = static_cast( - Max31865Definitions::WRITE_LOW_THRESHOLD); - commandBuffer[1] = static_cast(LOW_THRESHOLD >> 8); - commandBuffer[2] = static_cast(LOW_THRESHOLD & 0xFF); - DeviceHandlerBase::rawPacketLen = 3; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; + case (Max31865Definitions::REQUEST_HIGH_THRESHOLD): { + commandBuffer[0] = static_cast(Max31865Definitions::REQUEST_HIGH_THRESHOLD); + commandBuffer[1] = 0x00; // dummy byte + commandBuffer[2] = 0x00; // dummy byte + DeviceHandlerBase::rawPacketLen = 3; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; } - case(Max31865Definitions::REQUEST_LOW_THRESHOLD): { - commandBuffer[0] = static_cast( - Max31865Definitions::REQUEST_LOW_THRESHOLD); - commandBuffer[1] = 0x00; //dummy byte - commandBuffer[2] = 0x00; //dummy byte - DeviceHandlerBase::rawPacketLen = 3; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; + case (Max31865Definitions::WRITE_LOW_THRESHOLD): { + commandBuffer[0] = static_cast(Max31865Definitions::WRITE_LOW_THRESHOLD); + commandBuffer[1] = static_cast(LOW_THRESHOLD >> 8); + commandBuffer[2] = static_cast(LOW_THRESHOLD & 0xFF); + DeviceHandlerBase::rawPacketLen = 3; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; } - case(Max31865Definitions::REQUEST_RTD): { - commandBuffer[0] = static_cast( - Max31865Definitions::REQUEST_RTD); - // two dummy bytes - commandBuffer[1] = 0x00; - commandBuffer[2] = 0x00; - DeviceHandlerBase::rawPacketLen = 3; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; + case (Max31865Definitions::REQUEST_LOW_THRESHOLD): { + commandBuffer[0] = static_cast(Max31865Definitions::REQUEST_LOW_THRESHOLD); + commandBuffer[1] = 0x00; // dummy byte + commandBuffer[2] = 0x00; // dummy byte + DeviceHandlerBase::rawPacketLen = 3; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; } - case(Max31865Definitions::REQUEST_FAULT_BYTE): { - commandBuffer[0] = static_cast( - Max31865Definitions::REQUEST_FAULT_BYTE); - commandBuffer[1] = 0x00; - DeviceHandlerBase::rawPacketLen = 2; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; + case (Max31865Definitions::REQUEST_RTD): { + commandBuffer[0] = static_cast(Max31865Definitions::REQUEST_RTD); + // two dummy bytes + commandBuffer[1] = 0x00; + commandBuffer[2] = 0x00; + DeviceHandlerBase::rawPacketLen = 3; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; + } + case (Max31865Definitions::REQUEST_FAULT_BYTE): { + commandBuffer[0] = static_cast(Max31865Definitions::REQUEST_FAULT_BYTE); + commandBuffer[1] = 0x00; + DeviceHandlerBase::rawPacketLen = 2; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; } default: - //Unknown DeviceCommand - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } + // Unknown DeviceCommand + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } } void Max31865PT1000Handler::fillCommandAndReplyMap() { - insertInCommandAndReplyMap(Max31865Definitions::CONFIG_CMD, 3); - insertInCommandAndReplyMap(Max31865Definitions::REQUEST_CONFIG, 3); - insertInCommandAndReplyMap(Max31865Definitions::WRITE_LOW_THRESHOLD, 3); - insertInCommandAndReplyMap(Max31865Definitions::REQUEST_LOW_THRESHOLD, 3); - insertInCommandAndReplyMap(Max31865Definitions::WRITE_HIGH_THRESHOLD, 3); - insertInCommandAndReplyMap(Max31865Definitions::REQUEST_HIGH_THRESHOLD, 3); - insertInCommandAndReplyMap(Max31865Definitions::REQUEST_RTD, 3, - &sensorDataset); - insertInCommandAndReplyMap(Max31865Definitions::REQUEST_FAULT_BYTE, 3); - insertInCommandAndReplyMap(Max31865Definitions::CLEAR_FAULT_BYTE, 3); + insertInCommandAndReplyMap(Max31865Definitions::CONFIG_CMD, 3); + insertInCommandAndReplyMap(Max31865Definitions::REQUEST_CONFIG, 3); + insertInCommandAndReplyMap(Max31865Definitions::WRITE_LOW_THRESHOLD, 3); + insertInCommandAndReplyMap(Max31865Definitions::REQUEST_LOW_THRESHOLD, 3); + insertInCommandAndReplyMap(Max31865Definitions::WRITE_HIGH_THRESHOLD, 3); + insertInCommandAndReplyMap(Max31865Definitions::REQUEST_HIGH_THRESHOLD, 3); + insertInCommandAndReplyMap(Max31865Definitions::REQUEST_RTD, 3, &sensorDataset); + insertInCommandAndReplyMap(Max31865Definitions::REQUEST_FAULT_BYTE, 3); + insertInCommandAndReplyMap(Max31865Definitions::CLEAR_FAULT_BYTE, 3); } -ReturnValue_t Max31865PT1000Handler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { - size_t rtdReplySize = 3; - size_t configReplySize = 2; - - if(remainingSize == rtdReplySize and - internalState == InternalState::RUNNING) { - *foundId = Max31865Definitions::REQUEST_RTD; - *foundLen = rtdReplySize; - return RETURN_OK; - } - - if(remainingSize == 3) { - switch(internalState) { - case(InternalState::CONFIG_HIGH_THRESHOLD): { - *foundLen = 3; - *foundId = Max31865Definitions::WRITE_HIGH_THRESHOLD; - commandExecuted = true; - return RETURN_OK; - } - case(InternalState::REQUEST_HIGH_THRESHOLD): { - *foundLen = 3; - *foundId = Max31865Definitions::REQUEST_HIGH_THRESHOLD; - return RETURN_OK; - } - case(InternalState::CONFIG_LOW_THRESHOLD): { - *foundLen = 3; - *foundId = Max31865Definitions::WRITE_LOW_THRESHOLD; - commandExecuted = true; - return RETURN_OK; - } - case(InternalState::REQUEST_LOW_THRESHOLD): { - *foundLen = 3; - *foundId = Max31865Definitions::REQUEST_LOW_THRESHOLD; - return RETURN_OK; - } - default: { - sif::debug << "Max31865PT1000Handler::scanForReply: Unknown internal state" - << std::endl; - return RETURN_OK; - } - } - } - - if(remainingSize == configReplySize) { - if(internalState == InternalState::CONFIGURE) { - commandExecuted = true; - *foundLen = configReplySize; - *foundId = Max31865Definitions::CONFIG_CMD; - } - else if(internalState == InternalState::REQUEST_FAULT_BYTE) { - *foundId = Max31865Definitions::REQUEST_FAULT_BYTE; - *foundLen = 2; - internalState = InternalState::RUNNING; - } - else if(internalState == InternalState::CLEAR_FAULT_BYTE) { - *foundId = Max31865Definitions::CLEAR_FAULT_BYTE; - *foundLen = 2; - if(mode == _MODE_START_UP) { - commandExecuted = true; - } else { - internalState = InternalState::RUNNING; - } - } - else { - *foundId = Max31865Definitions::REQUEST_CONFIG; - *foundLen = configReplySize; - } - } +ReturnValue_t Max31865PT1000Handler::scanForReply(const uint8_t *start, size_t remainingSize, + DeviceCommandId_t *foundId, size_t *foundLen) { + size_t rtdReplySize = 3; + size_t configReplySize = 2; + if (remainingSize == rtdReplySize and internalState == InternalState::RUNNING) { + *foundId = Max31865Definitions::REQUEST_RTD; + *foundLen = rtdReplySize; return RETURN_OK; + } + + if (remainingSize == 3) { + switch (internalState) { + case (InternalState::CONFIG_HIGH_THRESHOLD): { + *foundLen = 3; + *foundId = Max31865Definitions::WRITE_HIGH_THRESHOLD; + commandExecuted = true; + return RETURN_OK; + } + case (InternalState::REQUEST_HIGH_THRESHOLD): { + *foundLen = 3; + *foundId = Max31865Definitions::REQUEST_HIGH_THRESHOLD; + return RETURN_OK; + } + case (InternalState::CONFIG_LOW_THRESHOLD): { + *foundLen = 3; + *foundId = Max31865Definitions::WRITE_LOW_THRESHOLD; + commandExecuted = true; + return RETURN_OK; + } + case (InternalState::REQUEST_LOW_THRESHOLD): { + *foundLen = 3; + *foundId = Max31865Definitions::REQUEST_LOW_THRESHOLD; + return RETURN_OK; + } + default: { + sif::debug << "Max31865PT1000Handler::scanForReply: Unknown internal state" << std::endl; + return RETURN_OK; + } + } + } + + if (remainingSize == configReplySize) { + if (internalState == InternalState::CONFIGURE) { + commandExecuted = true; + *foundLen = configReplySize; + *foundId = Max31865Definitions::CONFIG_CMD; + } else if (internalState == InternalState::REQUEST_FAULT_BYTE) { + *foundId = Max31865Definitions::REQUEST_FAULT_BYTE; + *foundLen = 2; + internalState = InternalState::RUNNING; + } else if (internalState == InternalState::CLEAR_FAULT_BYTE) { + *foundId = Max31865Definitions::CLEAR_FAULT_BYTE; + *foundLen = 2; + if (mode == _MODE_START_UP) { + commandExecuted = true; + } else { + internalState = InternalState::RUNNING; + } + } else { + *foundId = Max31865Definitions::REQUEST_CONFIG; + *foundLen = configReplySize; + } + } + + return RETURN_OK; } -ReturnValue_t Max31865PT1000Handler::interpretDeviceReply( - DeviceCommandId_t id, const uint8_t *packet) { - switch(id) { - case(Max31865Definitions::REQUEST_CONFIG): { - if(packet[1] != DEFAULT_CONFIG) { +ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(DeviceCommandId_t id, + const uint8_t *packet) { + switch (id) { + case (Max31865Definitions::REQUEST_CONFIG): { + if (packet[1] != DEFAULT_CONFIG) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - // it propably would be better if we at least try one restart.. - sif::error << "Max31865PT1000Handler: 0x" << std::hex << this->getObjectId() - << ": Invalid configuration reply" << std::endl; + // it propably would be better if we at least try one restart.. + sif::error << "Max31865PT1000Handler: 0x" << std::hex << this->getObjectId() + << ": Invalid configuration reply" << std::endl; #else - sif::printError("Max31865PT1000Handler: %04x: Invalid configuration reply!\n", - this->getObjectId()); + sif::printError("Max31865PT1000Handler: %04x: Invalid configuration reply!\n", + this->getObjectId()); #endif - return HasReturnvaluesIF::RETURN_OK; - } - // set to true for invalid configs too for now. - if(internalState == InternalState::REQUEST_CONFIG) { - commandExecuted = true; - } - else if(internalState == InternalState::RUNNING) { - // we should propably generate a telemetry with the config byte - // as payload here. - } - break; + return HasReturnvaluesIF::RETURN_OK; + } + // set to true for invalid configs too for now. + if (internalState == InternalState::REQUEST_CONFIG) { + commandExecuted = true; + } else if (internalState == InternalState::RUNNING) { + // we should propably generate a telemetry with the config byte + // as payload here. + } + break; } - case(Max31865Definitions::REQUEST_LOW_THRESHOLD): { - uint16_t readLowThreshold = packet[1] << 8 | packet[2]; - if(readLowThreshold != LOW_THRESHOLD) { + case (Max31865Definitions::REQUEST_LOW_THRESHOLD): { + uint16_t readLowThreshold = packet[1] << 8 | packet[2]; + if (readLowThreshold != LOW_THRESHOLD) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << - std::hex << this->getObjectId() << ": Missmatch between " << - "written and readback value of low threshold register" << std::endl; + sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex + << this->getObjectId() << ": Missmatch between " + << "written and readback value of low threshold register" << std::endl; #else - sif::printWarning("Max31865PT1000Handler::interpretDeviceReply: Missmatch between " - "written and readback value of low threshold register\n"); + sif::printWarning( + "Max31865PT1000Handler::interpretDeviceReply: Missmatch between " + "written and readback value of low threshold register\n"); #endif #endif - } - commandExecuted = true; - break; + } + commandExecuted = true; + break; } - case(Max31865Definitions::REQUEST_HIGH_THRESHOLD): { - uint16_t readHighThreshold = packet[1] << 8 | packet[2]; - if(readHighThreshold != HIGH_THRESHOLD) { + case (Max31865Definitions::REQUEST_HIGH_THRESHOLD): { + uint16_t readHighThreshold = packet[1] << 8 | packet[2]; + if (readHighThreshold != HIGH_THRESHOLD) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " - << std::hex << this->getObjectId() << ": Missmatch between " << - "written and readback value of high threshold register" << std::endl; + sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex + << this->getObjectId() << ": Missmatch between " + << "written and readback value of high threshold register" << std::endl; #else - sif::printWarning("Max31865PT1000Handler::interpretDeviceReply: Missmatch between " - "written and readback value of high threshold register\n"); + sif::printWarning( + "Max31865PT1000Handler::interpretDeviceReply: Missmatch between " + "written and readback value of high threshold register\n"); #endif #endif - } - commandExecuted = true; - break; + } + commandExecuted = true; + break; } - case(Max31865Definitions::REQUEST_RTD): { - // first bit of LSB reply byte is the fault bit - uint8_t faultBit = packet[2] & 0b0000'0001; - if(resetFaultBit) { - internalState = InternalState::CLEAR_FAULT_BYTE; - resetFaultBit = false; - } - else if(faultBit == 1) { - // Maybe we should attempt to restart it? - internalState = InternalState::REQUEST_FAULT_BYTE; - resetFaultBit = true; - } + case (Max31865Definitions::REQUEST_RTD): { + // first bit of LSB reply byte is the fault bit + uint8_t faultBit = packet[2] & 0b0000'0001; + if (resetFaultBit) { + internalState = InternalState::CLEAR_FAULT_BYTE; + resetFaultBit = false; + } else if (faultBit == 1) { + // Maybe we should attempt to restart it? + internalState = InternalState::REQUEST_FAULT_BYTE; + resetFaultBit = true; + } - // RTD value consists of last seven bits of the LSB reply byte and - // the MSB reply byte - uint16_t adcCode = ((packet[1] << 8) | packet[2]) >> 1; - // do something with rtd value, will propably be stored in - // dataset. - float rtdValue = adcCode * RTD_RREF_PT1000 / INT16_MAX; - // calculate approximation - float approxTemp = adcCode / 32.0 - 256.0; + // RTD value consists of last seven bits of the LSB reply byte and + // the MSB reply byte + uint16_t adcCode = ((packet[1] << 8) | packet[2]) >> 1; + // do something with rtd value, will propably be stored in + // dataset. + float rtdValue = adcCode * RTD_RREF_PT1000 / INT16_MAX; + // calculate approximation + float approxTemp = adcCode / 32.0 - 256.0; #if OBSW_DEBUG_RTD == 1 #if OBSW_VERBOSE_LEVEL >= 1 - if(debugDivider->checkAndIncrement()) { + if (debugDivider->checkAndIncrement()) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "Max31865: Object ID: " << std::hex << this->getObjectId() - << ": Measured resistance is " << rtdValue << " Ohms." << std::endl; - sif::info << "Approximated temperature is " << approxTemp << " C" << std::endl; + sif::info << "Max31865: Object ID: " << std::hex << this->getObjectId() + << ": Measured resistance is " << rtdValue << " Ohms." << std::endl; + sif::info << "Approximated temperature is " << approxTemp << " C" << std::endl; #else - sif::printInfo("Max31685: Measured resistance is %f Ohms\n", rtdValue); - sif::printInfo("Approximated temperature is %f C\n", approxTemp); + sif::printInfo("Max31685: Measured resistance is %f Ohms\n", rtdValue); + sif::printInfo("Approximated temperature is %f C\n", approxTemp); #endif - } + } #endif #endif - PoolReadGuard pg(&sensorDataset); - if(pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) { - // Configuration error + PoolReadGuard pg(&sensorDataset); + if (pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) { + // Configuration error #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " - << std::hex << this->getObjectId() << ": Error reading dataset!" - << std::endl; + sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex + << this->getObjectId() << ": Error reading dataset!" << std::endl; #else - sif::printWarning("Max31865PT1000Handler::interpretDeviceReply: " - "Error reading dataset!\n"); + sif::printWarning( + "Max31865PT1000Handler::interpretDeviceReply: " + "Error reading dataset!\n"); #endif - return pg.getReadResult(); - } + return pg.getReadResult(); + } - if(not sensorDataset.isValid()) { - sensorDataset.setValidity(true, false); - sensorDataset.rtdValue.setValid(true); - sensorDataset.temperatureCelcius.setValid(true); - } + if (not sensorDataset.isValid()) { + sensorDataset.setValidity(true, false); + sensorDataset.rtdValue.setValid(true); + sensorDataset.temperatureCelcius.setValid(true); + } - sensorDataset.rtdValue = rtdValue; - sensorDataset.temperatureCelcius = approxTemp; - break; + sensorDataset.rtdValue = rtdValue; + sensorDataset.temperatureCelcius = approxTemp; + break; } - case(Max31865Definitions::REQUEST_FAULT_BYTE): { - faultByte = packet[1]; + case (Max31865Definitions::REQUEST_FAULT_BYTE): { + faultByte = packet[1]; #if OBSW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " - << std::hex << this->getObjectId() << ": Fault byte" - " is: 0b" << std::bitset<8>(faultByte) << std::endl; + sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex + << this->getObjectId() + << ": Fault byte" + " is: 0b" + << std::bitset<8>(faultByte) << std::endl; #else - sif::printWarning("Max31865PT1000Handler::interpretDeviceReply: Fault byte" - " is: 0b" BYTE_TO_BINARY_PATTERN "\n", BYTE_TO_BINARY(faultByte)); + sif::printWarning( + "Max31865PT1000Handler::interpretDeviceReply: Fault byte" + " is: 0b" BYTE_TO_BINARY_PATTERN "\n", + BYTE_TO_BINARY(faultByte)); #endif #endif - ReturnValue_t result = sensorDataset.read(); - if(result != HasReturnvaluesIF::RETURN_OK) { - // Configuration error + ReturnValue_t result = sensorDataset.read(); + if (result != HasReturnvaluesIF::RETURN_OK) { + // Configuration error #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex - << this->getObjectId() << ":" - "Error reading dataset!" << std::endl; + sif::debug << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex + << this->getObjectId() + << ":" + "Error reading dataset!" + << std::endl; #else - sif::printDebug("Max31865PT1000Handler::interpretDeviceReply: " - "Error reading dataset!\n"); + sif::printDebug( + "Max31865PT1000Handler::interpretDeviceReply: " + "Error reading dataset!\n"); #endif - return result; - } - sensorDataset.errorByte.setValid(true); - sensorDataset.errorByte = faultByte; - if(faultByte != 0) { - sensorDataset.temperatureCelcius.setValid(false); - } + return result; + } + sensorDataset.errorByte.setValid(true); + sensorDataset.errorByte = faultByte; + if (faultByte != 0) { + sensorDataset.temperatureCelcius.setValid(false); + } - result = sensorDataset.commit(); - if(result != HasReturnvaluesIF::RETURN_OK) { - // Configuration error + result = sensorDataset.commit(); + if (result != HasReturnvaluesIF::RETURN_OK) { + // Configuration error #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex - << this->getObjectId() << ": Error commiting dataset!" << std::endl; + sif::debug << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex + << this->getObjectId() << ": Error commiting dataset!" << std::endl; #else - sif::printDebug("Max31865PT1000Handler::interpretDeviceReply: " - "Error commiting dataset!\n"); + sif::printDebug( + "Max31865PT1000Handler::interpretDeviceReply: " + "Error commiting dataset!\n"); #endif - return result; - } + return result; + } - break; + break; } default: - break; - } - return HasReturnvaluesIF::RETURN_OK; + break; + } + return HasReturnvaluesIF::RETURN_OK; } -void Max31865PT1000Handler::debugInterface(uint8_t positionTracker, - object_id_t objectId, uint32_t parameter) { +void Max31865PT1000Handler::debugInterface(uint8_t positionTracker, object_id_t objectId, + uint32_t parameter) {} + +uint32_t Max31865PT1000Handler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { + return 25000; } -uint32_t Max31865PT1000Handler::getTransitionDelayMs( - Mode_t modeFrom, Mode_t modeTo) { - return 25000; +ReturnValue_t Max31865PT1000Handler::getSwitches(const uint8_t **switches, + uint8_t *numberOfSwitches) { + return DeviceHandlerBase::NO_SWITCH; } -ReturnValue_t Max31865PT1000Handler::getSwitches( - const uint8_t **switches, uint8_t *numberOfSwitches) { - return DeviceHandlerBase::NO_SWITCH; +void Max31865PT1000Handler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { + DeviceHandlerBase::doTransition(modeFrom, subModeFrom); } -void Max31865PT1000Handler::doTransition(Mode_t modeFrom, - Submode_t subModeFrom) { - DeviceHandlerBase::doTransition(modeFrom, subModeFrom); -} - -ReturnValue_t Max31865PT1000Handler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { - localDataPoolMap.emplace(Max31865Definitions::PoolIds::RTD_VALUE, new PoolEntry({0})); - localDataPoolMap.emplace(Max31865Definitions::PoolIds::TEMPERATURE_C, - new PoolEntry({0}, 1, true)); - localDataPoolMap.emplace(Max31865Definitions::PoolIds::FAULT_BYTE, - new PoolEntry({0})); -// poolManager.subscribeForPeriodicPacket(sensorDatasetSid, -// false, 4.0, false); - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t Max31865PT1000Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(Max31865Definitions::PoolIds::RTD_VALUE, new PoolEntry({0})); + localDataPoolMap.emplace(Max31865Definitions::PoolIds::TEMPERATURE_C, + new PoolEntry({0}, 1, true)); + localDataPoolMap.emplace(Max31865Definitions::PoolIds::FAULT_BYTE, new PoolEntry({0})); + // poolManager.subscribeForPeriodicPacket(sensorDatasetSid, + // false, 4.0, false); + return HasReturnvaluesIF::RETURN_OK; } void Max31865PT1000Handler::setInstantNormal(bool instantNormal) { - this->instantNormal = instantNormal; + this->instantNormal = instantNormal; } void Max31865PT1000Handler::modeChanged() { - if(mode == MODE_OFF) { - internalState = InternalState::NONE; - } + if (mode == MODE_OFF) { + internalState = InternalState::NONE; + } } diff --git a/mission/devices/Max31865PT1000Handler.h b/mission/devices/Max31865PT1000Handler.h index 3be16150..44d7a2e7 100644 --- a/mission/devices/Max31865PT1000Handler.h +++ b/mission/devices/Max31865PT1000Handler.h @@ -2,12 +2,12 @@ #define MISSION_DEVICES_MAX31865PT1000HANDLER_H_ #include - #include #include #include #include + #include "devicedefinitions/Max31865Definitions.h" /** @@ -28,95 +28,92 @@ * @author R. Mueller * @ingroup devices */ -class Max31865PT1000Handler: public DeviceHandlerBase { -public: - Max31865PT1000Handler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); - virtual~ Max31865PT1000Handler(); +class Max31865PT1000Handler : public DeviceHandlerBase { + public: + Max31865PT1000Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie); + virtual ~Max31865PT1000Handler(); - // Configuration in 8 digit code: - // 1. 1 for V_BIAS enabled, 0 for disabled - // 2. 1 for Auto-conversion, 0 for off - // 3. 1 for 1-shot enabled, 0 for disabled (self-clearing bit) - // 4. 1 for 3-wire enabled, 0 for disabled (two and four wired RTD) - // 5./6. Fault detection: 00 for no action, 01 for automatic delay, 1 - // 0 for run fault detection with manual delay, - // 11 for finish fault detection with manual delay - // 7. Fault status: Write 1 to reset fault status register (Bit is self cleared afterwards) - // 8. 1 for 50 Hz filter, 0 for 60 Hz filter (noise rejection filter) - static constexpr uint8_t DEFAULT_CONFIG = 0b11000001; + // Configuration in 8 digit code: + // 1. 1 for V_BIAS enabled, 0 for disabled + // 2. 1 for Auto-conversion, 0 for off + // 3. 1 for 1-shot enabled, 0 for disabled (self-clearing bit) + // 4. 1 for 3-wire enabled, 0 for disabled (two and four wired RTD) + // 5./6. Fault detection: 00 for no action, 01 for automatic delay, 1 + // 0 for run fault detection with manual delay, + // 11 for finish fault detection with manual delay + // 7. Fault status: Write 1 to reset fault status register (Bit is self cleared afterwards) + // 8. 1 for 50 Hz filter, 0 for 60 Hz filter (noise rejection filter) + static constexpr uint8_t DEFAULT_CONFIG = 0b11000001; - void setInstantNormal(bool instantNormal); - /** - * Expected temperature range is -100 C and 100 C. - * If there are temperatures beyond this range there must be a fault. - * The threshold variables cause the MAX1385 to signal an error in case the measured resistance - * indicates a temperature higher than 100 C or lower than -100 C. - * Default settings of MAX13865 are 0xFFFF for the high threshold register and 0x0 for the - * low threshold register. - */ - static constexpr uint16_t HIGH_THRESHOLD = 11298; // = 100 C - static constexpr uint16_t LOW_THRESHOLD = 4902; // = -100 C + void setInstantNormal(bool instantNormal); + /** + * Expected temperature range is -100 C and 100 C. + * If there are temperatures beyond this range there must be a fault. + * The threshold variables cause the MAX1385 to signal an error in case the measured resistance + * indicates a temperature higher than 100 C or lower than -100 C. + * Default settings of MAX13865 are 0xFFFF for the high threshold register and 0x0 for the + * low threshold register. + */ + static constexpr uint16_t HIGH_THRESHOLD = 11298; // = 100 C + static constexpr uint16_t LOW_THRESHOLD = 4902; // = -100 C - static constexpr float RTD_RREF_PT1000 = 4020.0; //!< Ohm - static constexpr float RTD_RESISTANCE0_PT1000 = 1000.0; //!< Ohm -protected: - // DeviceHandlerBase abstract function implementation - void doStartUp() override; - void doShutDown() override; - ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; - ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override; - ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t * commandData, size_t commandDataLen) override; - void fillCommandAndReplyMap() 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; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; - ReturnValue_t getSwitches(const uint8_t **switches, - uint8_t *numberOfSwitches) override; + static constexpr float RTD_RREF_PT1000 = 4020.0; //!< Ohm + static constexpr float RTD_RESISTANCE0_PT1000 = 1000.0; //!< Ohm + protected: + // DeviceHandlerBase abstract function implementation + void doStartUp() override; + void doShutDown() override; + ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, + size_t commandDataLen) override; + void fillCommandAndReplyMap() 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; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t getSwitches(const uint8_t **switches, uint8_t *numberOfSwitches) override; - void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override; + void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override; - void debugInterface(uint8_t positionTracker = 0, - object_id_t objectId = 0, uint32_t parameter = 0) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; - void modeChanged() override; + void debugInterface(uint8_t positionTracker = 0, object_id_t objectId = 0, + uint32_t parameter = 0) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) override; + void modeChanged() override; -private: - uint8_t switchId = 0; - bool instantNormal = true; + private: + uint8_t switchId = 0; + bool instantNormal = true; - enum class InternalState { - NONE, - WARMUP, - CONFIGURE, - CONFIG_HIGH_THRESHOLD, - REQUEST_HIGH_THRESHOLD, - CONFIG_LOW_THRESHOLD, - REQUEST_LOW_THRESHOLD, - REQUEST_CONFIG, - RUNNING, - REQUEST_FAULT_BYTE, - CLEAR_FAULT_BYTE - }; + enum class InternalState { + NONE, + WARMUP, + CONFIGURE, + CONFIG_HIGH_THRESHOLD, + REQUEST_HIGH_THRESHOLD, + CONFIG_LOW_THRESHOLD, + REQUEST_LOW_THRESHOLD, + REQUEST_CONFIG, + RUNNING, + REQUEST_FAULT_BYTE, + CLEAR_FAULT_BYTE + }; - InternalState internalState = InternalState::NONE; - bool commandExecuted = false; + InternalState internalState = InternalState::NONE; + bool commandExecuted = false; - bool resetFaultBit = false; - dur_millis_t startTime = 0; - uint8_t faultByte = 0; - std::array commandBuffer { 0 }; + bool resetFaultBit = false; + dur_millis_t startTime = 0; + uint8_t faultByte = 0; + std::array commandBuffer{0}; - Max31865Definitions::Max31865Set sensorDataset; - sid_t sensorDatasetSid; + Max31865Definitions::Max31865Set sensorDataset; + sid_t sensorDatasetSid; #if OBSW_VERBOSE_LEVEL >= 1 - PeriodicOperationDivider* debugDivider; + PeriodicOperationDivider *debugDivider; #endif }; #endif /* MISSION_DEVICES_MAX31865PT1000HANDLER_H_ */ - diff --git a/mission/devices/P60DockHandler.cpp b/mission/devices/P60DockHandler.cpp index 4ade2a0b..a89debc6 100644 --- a/mission/devices/P60DockHandler.cpp +++ b/mission/devices/P60DockHandler.cpp @@ -1,480 +1,506 @@ -#include #include "P60DockHandler.h" + +#include + #include "OBSWConfig.h" -P60DockHandler::P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - GomspaceDeviceHandler(objectId, comIF, comCookie, P60Dock::MAX_CONFIGTABLE_ADDRESS, - P60Dock::MAX_HKTABLE_ADDRESS, P60Dock::HK_TABLE_REPLY_SIZE, &p60dockHkTableDataset), p60dockHkTableDataset( - this) { -} +P60DockHandler::P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie) + : GomspaceDeviceHandler(objectId, comIF, comCookie, P60Dock::MAX_CONFIGTABLE_ADDRESS, + P60Dock::MAX_HKTABLE_ADDRESS, P60Dock::HK_TABLE_REPLY_SIZE, + &p60dockHkTableDataset), + p60dockHkTableDataset(this) {} -P60DockHandler::~P60DockHandler() { -} +P60DockHandler::~P60DockHandler() {} -ReturnValue_t P60DockHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - *id = GOMSPACE::REQUEST_HK_TABLE; - return buildCommandFromCommand(*id, NULL, 0); +ReturnValue_t P60DockHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + *id = GOMSPACE::REQUEST_HK_TABLE; + return buildCommandFromCommand(*id, NULL, 0); } void P60DockHandler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) { - - parseHkTableReply(packet); - /** - * Hk table will be sent to the commander if hk table request was not triggered by the - * P60DockHandler itself. - */ - handleDeviceTM(&p60dockHkTableDataset, id, true); + parseHkTableReply(packet); + /** + * Hk table will be sent to the commander if hk table request was not triggered by the + * P60DockHandler itself. + */ + handleDeviceTM(&p60dockHkTableDataset, id, true); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_P60DOCK == 1 - p60dockHkTableDataset.read(); - sif::info << "P60 Dock: ACU VCC switch: " << - static_cast(p60dockHkTableDataset.outputEnableStateAcuVcc.value) << std::endl; - sif::info << "P60 Dock: PDU1 VCC switch: " << - static_cast(p60dockHkTableDataset.outputEnableStatePdu1Vcc.value) << std::endl; - sif::info << "P60 Dock: PDU2 VCC switch: " << - static_cast(p60dockHkTableDataset.outputEnableStatePdu2Vcc.value) << std::endl; - sif::info << "P60 Dock: ACU VBAT switch: " << - static_cast(p60dockHkTableDataset.outputEnableStateAcuVbat.value) << std::endl; - sif::info << "P60 Dock: PDU1 VBAT switch: " << - static_cast(p60dockHkTableDataset.outputEnableStatePdu1Vbat.value) << std::endl; - sif::info << "P60 Dock: PDU2 VBAT switch: " << - static_cast(p60dockHkTableDataset.outputEnableStatePdu2Vbat.value) << std::endl; - sif::info << "P60 Dock: Stack VBAT switch: " << - static_cast(p60dockHkTableDataset.outputEnableStateStackVbat.value) << std::endl; - sif::info << "P60 Dock: Stack 3V3 switch: " << - static_cast(p60dockHkTableDataset.outputEnableStateStack3V3.value) << std::endl; - sif::info << "P60 Dock: Stack 5V switch: " << - static_cast(p60dockHkTableDataset.outputEnableStateStack5V.value) << std::endl; + p60dockHkTableDataset.read(); + sif::info << "P60 Dock: ACU VCC switch: " + << static_cast(p60dockHkTableDataset.outputEnableStateAcuVcc.value) + << std::endl; + sif::info << "P60 Dock: PDU1 VCC switch: " + << static_cast(p60dockHkTableDataset.outputEnableStatePdu1Vcc.value) + << std::endl; + sif::info << "P60 Dock: PDU2 VCC switch: " + << static_cast(p60dockHkTableDataset.outputEnableStatePdu2Vcc.value) + << std::endl; + sif::info << "P60 Dock: ACU VBAT switch: " + << static_cast(p60dockHkTableDataset.outputEnableStateAcuVbat.value) + << std::endl; + sif::info << "P60 Dock: PDU1 VBAT switch: " + << static_cast(p60dockHkTableDataset.outputEnableStatePdu1Vbat.value) + << std::endl; + sif::info << "P60 Dock: PDU2 VBAT switch: " + << static_cast(p60dockHkTableDataset.outputEnableStatePdu2Vbat.value) + << std::endl; + sif::info << "P60 Dock: Stack VBAT switch: " + << static_cast(p60dockHkTableDataset.outputEnableStateStackVbat.value) + << std::endl; + sif::info << "P60 Dock: Stack 3V3 switch: " + << static_cast(p60dockHkTableDataset.outputEnableStateStack3V3.value) + << std::endl; + sif::info << "P60 Dock: Stack 5V switch: " + << static_cast(p60dockHkTableDataset.outputEnableStateStack5V.value) + << std::endl; - float temperatureC = p60dockHkTableDataset.temperature1.value * 0.1; - sif::info << "P60 Dock: Temperature 1: " << temperatureC << " °C" << std::endl; - temperatureC = p60dockHkTableDataset.temperature2.value * 0.1; - sif::info << "P60 Dock: Temperature 2: " << temperatureC << " °C" << std::endl; - sif::info << "P60 Dock: Watchdog Timer seconds left before reboot: " + float temperatureC = p60dockHkTableDataset.temperature1.value * 0.1; + sif::info << "P60 Dock: Temperature 1: " << temperatureC << " °C" << std::endl; + temperatureC = p60dockHkTableDataset.temperature2.value * 0.1; + sif::info << "P60 Dock: Temperature 2: " << temperatureC << " °C" << std::endl; + sif::info << "P60 Dock: Watchdog Timer seconds left before reboot: " << p60dockHkTableDataset.wdtGndLeft << " seconds" << std::endl; - sif::info << "P60 Dock: CSP 1, pings left before reboot: " - << (int) p60dockHkTableDataset.wdtCspLeft1.value << std::endl; - sif::info << "P60 Dock: CSP 2, pings left before reboot: " - << (int) p60dockHkTableDataset.wdtCspLeft1.value << std::endl; + sif::info << "P60 Dock: CSP 1, pings left before reboot: " + << (int)p60dockHkTableDataset.wdtCspLeft1.value << std::endl; + sif::info << "P60 Dock: CSP 2, pings left before reboot: " + << (int)p60dockHkTableDataset.wdtCspLeft1.value << std::endl; - p60dockHkTableDataset.commit(); + p60dockHkTableDataset.commit(); #endif - } void P60DockHandler::parseHkTableReply(const uint8_t *packet) { - uint16_t dataOffset = 0; - p60dockHkTableDataset.read(); - /** - * Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table - * address. - */ - dataOffset += 12; - p60dockHkTableDataset.currentAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentPdu1Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentX3IdleVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentPdu2Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentAcuVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentPdu1Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentX3IdleVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentPdu2Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentStackVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentStack3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentStack5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentGS3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentGS5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + uint16_t dataOffset = 0; + p60dockHkTableDataset.read(); + /** + * Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table + * address. + */ + dataOffset += 12; + p60dockHkTableDataset.currentAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentPdu1Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentX3IdleVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentPdu2Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentAcuVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentPdu1Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentX3IdleVbat = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentPdu2Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentStackVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentStack3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentStack5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentGS3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentGS5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - p60dockHkTableDataset.voltageAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltagePdu1Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageX3IdleVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltagePdu2Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageAcuVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltagePdu1Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageX3IdleVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltagePdu2Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageStackVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageStack3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageStack5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageGS3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + p60dockHkTableDataset.voltageAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltagePdu1Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageX3IdleVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltagePdu2Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageAcuVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltagePdu1Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageX3IdleVbat = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltagePdu2Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageStackVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageStack3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageStack5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageGS3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - p60dockHkTableDataset.outputEnableStateAcuVcc = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStatePdu1Vcc = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateX3IdleVcc = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStatePdu2Vcc = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateAcuVbat = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStatePdu1Vbat = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateX3IdleVbat = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStatePdu2Vbat = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateStackVbat = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateStack3V3 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateStack5V = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateGS3V3 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateGS5V = *(packet + dataOffset); - dataOffset += 3; + p60dockHkTableDataset.outputEnableStateAcuVcc = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStatePdu1Vcc = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateX3IdleVcc = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStatePdu2Vcc = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateAcuVbat = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStatePdu1Vbat = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateX3IdleVbat = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStatePdu2Vbat = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateStackVbat = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateStack3V3 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateStack5V = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateGS3V3 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateGS5V = *(packet + dataOffset); + dataOffset += 3; - p60dockHkTableDataset.temperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.temperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + p60dockHkTableDataset.temperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.temperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - p60dockHkTableDataset.bootcause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.bootCount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.resetcause = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.battMode = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.heaterOn = *(packet + dataOffset); - /* + 13 because here begins a new gomspace csp data field */ - dataOffset += 13; - p60dockHkTableDataset.converter5VStatus = *(packet + dataOffset); - dataOffset += 3; + p60dockHkTableDataset.bootcause = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.bootCount = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.resetcause = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.battMode = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.heaterOn = *(packet + dataOffset); + /* + 13 because here begins a new gomspace csp data field */ + dataOffset += 13; + p60dockHkTableDataset.converter5VStatus = *(packet + dataOffset); + dataOffset += 3; - p60dockHkTableDataset.latchupsAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsPdu1Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsX3IdleVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsPdu2Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsAcuVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsPdu1Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsX3IdleVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsPdu2Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsStackVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsStack3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsStack5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsGS3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + p60dockHkTableDataset.latchupsAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsPdu1Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsX3IdleVcc = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsPdu2Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsAcuVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsPdu1Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsX3IdleVbat = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsPdu2Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsStackVbat = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsStack3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsStack5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsGS3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - p60dockHkTableDataset.vbatVoltageValue = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.vccCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.batteryCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.batteryVoltage = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + p60dockHkTableDataset.vbatVoltageValue = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.vccCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.batteryCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.batteryVoltage = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - p60dockHkTableDataset.batteryTemperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.batteryTemperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + p60dockHkTableDataset.batteryTemperature1 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.batteryTemperature2 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - p60dockHkTableDataset.device0 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device1 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device2 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device3 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device4 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device5 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device6 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device7 = *(packet + dataOffset); - dataOffset += 3; + p60dockHkTableDataset.device0 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device1 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device2 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device3 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device4 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device5 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device6 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device7 = *(packet + dataOffset); + dataOffset += 3; - p60dockHkTableDataset.device0Status = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device1Status = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device2Status = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device3Status = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device4Status = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device5Status = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device6Status = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device7Status = *(packet + dataOffset); - dataOffset += 3; + p60dockHkTableDataset.device0Status = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device1Status = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device2Status = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device3Status = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device4Status = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device5Status = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device6Status = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device7Status = *(packet + dataOffset); + dataOffset += 3; - p60dockHkTableDataset.dearmStatus = *(packet + dataOffset); - dataOffset += 3; + p60dockHkTableDataset.dearmStatus = *(packet + dataOffset); + dataOffset += 3; - p60dockHkTableDataset.wdtCntGnd = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.wdtCntI2c = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.wdtCntCan = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.wdtCntCsp1 = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.wdtCntCsp2 = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; + p60dockHkTableDataset.wdtCntGnd = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.wdtCntI2c = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.wdtCntCan = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.wdtCntCsp1 = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.wdtCntCsp2 = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; - p60dockHkTableDataset.wdtGndLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.wdtI2cLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.wdtCanLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - /* +16 because here begins a new gomspace csp packet */ - dataOffset += 16; + p60dockHkTableDataset.wdtGndLeft = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.wdtI2cLeft = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.wdtCanLeft = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + /* +16 because here begins a new gomspace csp packet */ + dataOffset += 16; - p60dockHkTableDataset.wdtCspLeft1 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.wdtCspLeft2 = *(packet + dataOffset); - dataOffset += 3; + p60dockHkTableDataset.wdtCspLeft1 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.wdtCspLeft2 = *(packet + dataOffset); + dataOffset += 3; - p60dockHkTableDataset.batteryChargeCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.batteryDischargeCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.ant6Depl = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.ar6Depl = *(packet + dataOffset); + p60dockHkTableDataset.batteryChargeCurrent = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.batteryDischargeCurrent = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.ant6Depl = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.ar6Depl = *(packet + dataOffset); - p60dockHkTableDataset.commit(); + p60dockHkTableDataset.commit(); } -ReturnValue_t P60DockHandler::initializeLocalDataPool( - localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { +ReturnValue_t P60DockHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_ACU_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU1_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_X3_IDLE_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU2_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_ACU_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU1_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_X3_IDLE_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU2_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_5V, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_GS3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_GS5V, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_ACU_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU1_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_X3_IDLE_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU2_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_ACU_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU1_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_X3_IDLE_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU2_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_5V, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_GS3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_GS5V, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_ACU_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU1_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_X3_IDLE_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU2_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_ACU_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU1_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_X3_IDLE_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU2_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_5V, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_GS3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_GS5V, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_ACU_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU1_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_X3_IDLE_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU2_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_ACU_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU1_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_X3_IDLE_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU2_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_5V, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_GS3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_GS5V, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_ACU_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU1_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VCC, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU2_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_ACU_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU1_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VBAT, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU2_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_5V, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_GS3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_GS5V, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_ACU_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU1_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU2_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_ACU_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU1_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU2_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_5V, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_GS3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_GS5V, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_TEMPERATURE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_TEMPERATURE_2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_TEMPERATURE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_TEMPERATURE_2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_BOOT_CAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_BOOT_CNT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_RESETCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_BATT_MODE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_HEATER_ON, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CONV_5V_ENABLE_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_BOOT_CAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_BOOT_CNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_UPTIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_RESETCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_BATT_MODE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_HEATER_ON, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CONV_5V_ENABLE_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_ACU_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU1_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_X3_IDLE_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU2_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_ACU_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU1_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_X3_IDLE_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU2_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_5V, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_GS3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_GS5V, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_ACU_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU1_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_X3_IDLE_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU2_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_ACU_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU1_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_X3_IDLE_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU2_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_5V, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_GS3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_GS5V, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_VBAT_VALUE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VCC_CURRENT_VALUE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_VOLTAGE, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_VBAT_VALUE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VCC_CURRENT_VALUE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_VOLTAGE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_TEMPERATURE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_TEMPERATURE_2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_TEMPERATURE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_TEMPERATURE_2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_5, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_7, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_0_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_1_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_2_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_3_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_4_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_5_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_6_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_7_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_0_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_1_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_2_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_3_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_4_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_5_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_6_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_7_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_DEARM_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_DEARM_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_GND, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_I2C, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CAN, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CSP_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CSP_2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_GND, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_I2C, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CAN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CSP_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CSP_2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_GND_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_I2C_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CAN_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CSP_LEFT_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CSP_LEFT_2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_GND_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_I2C_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CAN_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CSP_LEFT_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CSP_LEFT_2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_BATT_CHARGE_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_BATT_DISCHARGE_CURRENT, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_BATT_CHARGE_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_BATT_DISCHARGE_CURRENT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_ANT6_DEPL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_AR6_DEPL, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_ANT6_DEPL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_AR6_DEPL, new PoolEntry( { 0 })); - - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } - ReturnValue_t P60DockHandler::printStatus(DeviceCommandId_t cmd) { - switch(cmd) { - case(GOMSPACE::PRINT_SWITCH_V_I): { - PoolReadGuard pg(&p60dockHkTableDataset); - ReturnValue_t readResult = pg.getReadResult(); - if(readResult != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Reading PDU1 HK table failed!" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - printHkTable(); - return HasReturnvaluesIF::RETURN_OK; + switch (cmd) { + case (GOMSPACE::PRINT_SWITCH_V_I): { + PoolReadGuard pg(&p60dockHkTableDataset); + ReturnValue_t readResult = pg.getReadResult(); + if (readResult != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Reading PDU1 HK table failed!" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + printHkTable(); + return HasReturnvaluesIF::RETURN_OK; } default: { - return HasReturnvaluesIF::RETURN_FAILED; - } + return HasReturnvaluesIF::RETURN_FAILED; } + } } void P60DockHandler::printHkTable() { - sif::info << "P60 Dock Info: SwitchState, Currents [mA], Voltages [mV]" << std::endl; + sif::info << "P60 Dock Info: SwitchState, Currents [mA], Voltages [mV]" << std::endl; - sif::info << std::setw(30) << std::left << "ACU VCC" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStateAcuVcc.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentAcuVcc.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltageAcuVcc.value << std::endl; - sif::info << std::setw(30) << std::left << "ACU VBAT" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStateAcuVbat.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentAcuVbat.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltageAcuVbat.value << std::endl; + sif::info << std::setw(30) << std::left << "ACU VCC" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStateAcuVcc.value) << ", " << std::setw(4) + << std::right << p60dockHkTableDataset.currentAcuVcc.value << ", " << std::setw(5) + << p60dockHkTableDataset.voltageAcuVcc.value << std::endl; + sif::info << std::setw(30) << std::left << "ACU VBAT" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStateAcuVbat.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentAcuVbat.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltageAcuVbat.value << std::endl; - sif::info << std::setw(30) << std::left << "PDU1 VCC" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStatePdu1Vcc.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentPdu1Vcc.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltagePdu1Vcc.value << std::endl; - sif::info << std::setw(30) << std::left << "PDU1 VBAT" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStatePdu1Vbat.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentPdu1Vbat.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltagePdu1Vbat.value << std::endl; + sif::info << std::setw(30) << std::left << "PDU1 VCC" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStatePdu1Vcc.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentPdu1Vcc.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltagePdu1Vcc.value << std::endl; + sif::info << std::setw(30) << std::left << "PDU1 VBAT" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStatePdu1Vbat.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentPdu1Vbat.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltagePdu1Vbat.value << std::endl; - sif::info << std::setw(30) << std::left << "PDU2 VCC" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStatePdu2Vcc.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentPdu2Vcc.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltagePdu2Vcc.value << std::endl; - sif::info << std::setw(30) << std::left << "PDU2 VBAT" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStatePdu2Vbat.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentPdu2Vbat.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltagePdu2Vbat.value << std::endl; + sif::info << std::setw(30) << std::left << "PDU2 VCC" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStatePdu2Vcc.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentPdu2Vcc.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltagePdu2Vcc.value << std::endl; + sif::info << std::setw(30) << std::left << "PDU2 VBAT" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStatePdu2Vbat.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentPdu2Vbat.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltagePdu2Vbat.value << std::endl; - sif::info << std::setw(30) << std::left << "Stack VBAT" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStateStackVbat.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentStackVbat.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltageStackVbat.value << std::endl; - sif::info << std::setw(30) << std::left << "Stack 3V3" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStateStack3V3.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentStack3V3.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltageStack3V3.value << std::endl; - sif::info << std::setw(30) << std::left << "Stack 5V" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStateStack5V.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentStack5V.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltageStack5V.value << std::endl; + sif::info << std::setw(30) << std::left << "Stack VBAT" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStateStackVbat.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentStackVbat.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltageStackVbat.value << std::endl; + sif::info << std::setw(30) << std::left << "Stack 3V3" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStateStack3V3.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentStack3V3.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltageStack3V3.value << std::endl; + sif::info << std::setw(30) << std::left << "Stack 5V" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStateStack5V.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentStack5V.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltageStack5V.value << std::endl; } - diff --git a/mission/devices/P60DockHandler.h b/mission/devices/P60DockHandler.h index cee0ecec..937ef122 100644 --- a/mission/devices/P60DockHandler.h +++ b/mission/devices/P60DockHandler.h @@ -1,47 +1,47 @@ #ifndef MISSION_DEVICES_P60DOCKHANDLER_H_ #define MISSION_DEVICES_P60DOCKHANDLER_H_ -#include "GomspaceDeviceHandler.h" #include +#include "GomspaceDeviceHandler.h" /** * @brief Device handler for the P60Dock. The P60Dock serves as carrier for the ACU, PDU1 and * PDU2. Via the P60Dock each of these modules can be turned on and off individually. */ -class P60DockHandler: public GomspaceDeviceHandler { -public: - P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); - virtual ~P60DockHandler(); +class P60DockHandler : public GomspaceDeviceHandler { + public: + P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + virtual ~P60DockHandler(); - virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; + virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; -protected: + protected: + /** + * @brief As soon as the device is in MODE_NORMAL, this function is executed periodically. + */ + virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override; - /** - * @brief As soon as the device is in MODE_NORMAL, this function is executed periodically. - */ - virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; + virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t* packet) override; - virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) override; + /** + * This command handles printing the HK table to the console. This is useful for debugging + * purposes + * @return + */ + ReturnValue_t printStatus(DeviceCommandId_t cmd) override; - /** - * This command handles printing the HK table to the console. This is useful for debugging - * purposes - * @return - */ - ReturnValue_t printStatus(DeviceCommandId_t cmd) override; + void printHkTable(); - void printHkTable(); -private: - P60Dock::HkTableDataset p60dockHkTableDataset; + private: + P60Dock::HkTableDataset p60dockHkTableDataset; - /** - * @brief Function extracts the hk table information from the received csp packet and stores - * the values in the p60dockHkTableDataset. - */ - void parseHkTableReply(const uint8_t *packet); + /** + * @brief Function extracts the hk table information from the received csp packet and stores + * the values in the p60dockHkTableDataset. + */ + void parseHkTableReply(const uint8_t* packet); }; #endif /* MISSION_DEVICES_P60DOCKHANDLER_H_ */ diff --git a/mission/devices/PCDUHandler.cpp b/mission/devices/PCDUHandler.cpp index fe7294ea..13bed074 100644 --- a/mission/devices/PCDUHandler.cpp +++ b/mission/devices/PCDUHandler.cpp @@ -1,506 +1,488 @@ #include "PCDUHandler.h" + #include +#include +#include +#include #include -#include - -#include -#include - - -PCDUHandler::PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize) : - SystemObject(setObjectId), poolManager(this, nullptr), pdu2HkTableDataset(this), pdu1HkTableDataset( - this), cmdQueueSize(cmdQueueSize) { - - commandQueue = QueueFactory::instance()->createMessageQueue(cmdQueueSize, - MessageQueueMessage::MAX_MESSAGE_SIZE); +PCDUHandler::PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize) + : SystemObject(setObjectId), + poolManager(this, nullptr), + pdu2HkTableDataset(this), + pdu1HkTableDataset(this), + cmdQueueSize(cmdQueueSize) { + commandQueue = QueueFactory::instance()->createMessageQueue( + cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE); } -PCDUHandler::~PCDUHandler() { -} +PCDUHandler::~PCDUHandler() {} ReturnValue_t PCDUHandler::performOperation(uint8_t counter) { - - if (counter == DeviceHandlerIF::PERFORM_OPERATION) { - readCommandQueue(); - return RETURN_OK; - } - + if (counter == DeviceHandlerIF::PERFORM_OPERATION) { + readCommandQueue(); return RETURN_OK; + } + + return RETURN_OK; } ReturnValue_t PCDUHandler::initialize() { + ReturnValue_t result; - ReturnValue_t result; + IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); + if (IPCStore == nullptr) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); - if (IPCStore == nullptr) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = poolManager.initialize(commandQueue); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } - result = poolManager.initialize(commandQueue); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + /* Subscribing for housekeeping table update messages of the PDU2 */ + HasLocalDataPoolIF* pdu2Handler = + ObjectManager::instance()->get(objects::PDU2_HANDLER); + if (pdu2Handler == nullptr) { + sif::error << "PCDUHandler::initialize: Invalid pdu2Handler" << std::endl; + return RETURN_FAILED; + } + result = pdu2Handler->getSubscriptionInterface()->subscribeForSetUpdateMessage( + PDU2::HK_TABLE_DATA_SET_ID, this->getObjectId(), commandQueue->getId(), true); + if (result != RETURN_OK) { + sif::error << "PCDUHandler::initialize: Failed to subscribe for set update messages from " + << "PDU2Handler" << std::endl; + return result; + } - /* Subscribing for housekeeping table update messages of the PDU2 */ - HasLocalDataPoolIF* pdu2Handler = ObjectManager::instance()->get( - objects::PDU2_HANDLER); - if(pdu2Handler == nullptr) { - sif::error << "PCDUHandler::initialize: Invalid pdu2Handler" << std::endl; - return RETURN_FAILED; - } - result = pdu2Handler->getSubscriptionInterface()->subscribeForSetUpdateMessage( - PDU2::HK_TABLE_DATA_SET_ID, this->getObjectId(), commandQueue->getId(), true); - if (result != RETURN_OK) { - sif::error << "PCDUHandler::initialize: Failed to subscribe for set update messages from " - << "PDU2Handler" << std::endl; - return result; - } + /* Subscribing for housekeeping table update messages of the PDU1 */ + HasLocalDataPoolIF* pdu1Handler = + ObjectManager::instance()->get(objects::PDU1_HANDLER); + if (pdu1Handler == nullptr) { + sif::error << "PCDUHandler::initialize: Invalid pdu1Handler" << std::endl; + return RETURN_FAILED; + } + result = pdu1Handler->getSubscriptionInterface()->subscribeForSetUpdateMessage( + PDU1::HK_TABLE_DATA_SET_ID, this->getObjectId(), commandQueue->getId(), true); + if (result != RETURN_OK) { + sif::error << "PCDUHandler::initialize: Failed to subscribe for set update messages from " + << "PDU1Handler" << std::endl; + return result; + } - /* Subscribing for housekeeping table update messages of the PDU1 */ - HasLocalDataPoolIF* pdu1Handler = ObjectManager::instance()->get( - objects::PDU1_HANDLER); - if(pdu1Handler == nullptr) { - sif::error << "PCDUHandler::initialize: Invalid pdu1Handler" << std::endl; - return RETURN_FAILED; - } - result = pdu1Handler->getSubscriptionInterface()->subscribeForSetUpdateMessage( - PDU1::HK_TABLE_DATA_SET_ID, this->getObjectId(), commandQueue->getId(), true); - if (result != RETURN_OK) { - sif::error << "PCDUHandler::initialize: Failed to subscribe for set update messages from " - << "PDU1Handler" << std::endl; - return result; - } - - return RETURN_OK; + return RETURN_OK; } void PCDUHandler::initializeSwitchStates() { - switchStates[pcduSwitches::Q7S] = pcduSwitches::INIT_STATE_Q7S; - switchStates[pcduSwitches::PAYLOAD_PCDU_CH1] = pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH1; - switchStates[pcduSwitches::RW] = pcduSwitches::INIT_STATE_RW; - switchStates[pcduSwitches::TCS_BOARD_8V_HEATER_IN] = pcduSwitches::INIT_STATE_TCS_BOARD_8V_HEATER_IN; - switchStates[pcduSwitches::SUS_REDUNDANT] = pcduSwitches::INIT_STATE_SUS_REDUNDANT; - switchStates[pcduSwitches::DEPLOYMENT_MECHANISM] = pcduSwitches::INIT_STATE_DEPLOYMENT_MECHANISM; - switchStates[pcduSwitches::PAYLOAD_PCDU_CH6] = pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH6; - switchStates[pcduSwitches::ACS_BOARD_SIDE_B] = pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_B; - switchStates[pcduSwitches::PAYLOAD_CAMERA] = pcduSwitches::INIT_STATE_PAYLOAD_CAMERA; - switchStates[pcduSwitches::TCS_BOARD_3V3] = pcduSwitches::INIT_STATE_TCS_BOARD_3V3; - switchStates[pcduSwitches::SYRLINKS] = pcduSwitches::INIT_STATE_SYRLINKS; - switchStates[pcduSwitches::STAR_TRACKER] = pcduSwitches::INIT_STATE_STAR_TRACKER; - switchStates[pcduSwitches::MGT] = pcduSwitches::INIT_STATE_MGT; - switchStates[pcduSwitches::SUS_NOMINAL] = pcduSwitches::INIT_STATE_SUS_NOMINAL; - switchStates[pcduSwitches::SOLAR_CELL_EXP] = pcduSwitches::INIT_STATE_SOLAR_CELL_EXP; - switchStates[pcduSwitches::PLOC] = pcduSwitches::INIT_STATE_PLOC; - switchStates[pcduSwitches::ACS_BOARD_SIDE_A] = pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_A; + switchStates[pcduSwitches::Q7S] = pcduSwitches::INIT_STATE_Q7S; + switchStates[pcduSwitches::PAYLOAD_PCDU_CH1] = pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH1; + switchStates[pcduSwitches::RW] = pcduSwitches::INIT_STATE_RW; + switchStates[pcduSwitches::TCS_BOARD_8V_HEATER_IN] = + pcduSwitches::INIT_STATE_TCS_BOARD_8V_HEATER_IN; + switchStates[pcduSwitches::SUS_REDUNDANT] = pcduSwitches::INIT_STATE_SUS_REDUNDANT; + switchStates[pcduSwitches::DEPLOYMENT_MECHANISM] = pcduSwitches::INIT_STATE_DEPLOYMENT_MECHANISM; + switchStates[pcduSwitches::PAYLOAD_PCDU_CH6] = pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH6; + switchStates[pcduSwitches::ACS_BOARD_SIDE_B] = pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_B; + switchStates[pcduSwitches::PAYLOAD_CAMERA] = pcduSwitches::INIT_STATE_PAYLOAD_CAMERA; + switchStates[pcduSwitches::TCS_BOARD_3V3] = pcduSwitches::INIT_STATE_TCS_BOARD_3V3; + switchStates[pcduSwitches::SYRLINKS] = pcduSwitches::INIT_STATE_SYRLINKS; + switchStates[pcduSwitches::STAR_TRACKER] = pcduSwitches::INIT_STATE_STAR_TRACKER; + switchStates[pcduSwitches::MGT] = pcduSwitches::INIT_STATE_MGT; + switchStates[pcduSwitches::SUS_NOMINAL] = pcduSwitches::INIT_STATE_SUS_NOMINAL; + switchStates[pcduSwitches::SOLAR_CELL_EXP] = pcduSwitches::INIT_STATE_SOLAR_CELL_EXP; + switchStates[pcduSwitches::PLOC] = pcduSwitches::INIT_STATE_PLOC; + switchStates[pcduSwitches::ACS_BOARD_SIDE_A] = pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_A; } void PCDUHandler::readCommandQueue() { - ReturnValue_t result; - CommandMessage command; + ReturnValue_t result; + CommandMessage command; - result = commandQueue->receiveMessage(&command); - if (result != RETURN_OK) { - return; - } + result = commandQueue->receiveMessage(&command); + if (result != RETURN_OK) { + return; + } - result = poolManager.handleHousekeepingMessage(&command); - if (result == RETURN_OK) { - return; - } + result = poolManager.handleHousekeepingMessage(&command); + if (result == RETURN_OK) { + return; + } } -MessageQueueId_t PCDUHandler::getCommandQueue() const { - return commandQueue->getId(); -} +MessageQueueId_t PCDUHandler::getCommandQueue() const { return commandQueue->getId(); } void PCDUHandler::handleChangedDataset(sid_t sid, store_address_t storeId) { - - if (sid == sid_t(objects::PDU2_HANDLER, PDU2::HK_TABLE_DATA_SET_ID)) { - updateHkTableDataset(storeId, &pdu2HkTableDataset, &timeStampPdu2HkDataset); - updatePdu2SwitchStates(); - } - else if (sid == sid_t(objects::PDU1_HANDLER, PDU1::HK_TABLE_DATA_SET_ID)) { - updateHkTableDataset(storeId, &pdu1HkTableDataset, &timeStampPdu1HkDataset); - updatePdu1SwitchStates(); - } - else { - sif::error << "PCDUHandler::handleChangedDataset: Invalid sid" << std::endl; - } + if (sid == sid_t(objects::PDU2_HANDLER, PDU2::HK_TABLE_DATA_SET_ID)) { + updateHkTableDataset(storeId, &pdu2HkTableDataset, &timeStampPdu2HkDataset); + updatePdu2SwitchStates(); + } else if (sid == sid_t(objects::PDU1_HANDLER, PDU1::HK_TABLE_DATA_SET_ID)) { + updateHkTableDataset(storeId, &pdu1HkTableDataset, &timeStampPdu1HkDataset); + updatePdu1SwitchStates(); + } else { + sif::error << "PCDUHandler::handleChangedDataset: Invalid sid" << std::endl; + } } -void PCDUHandler::updateHkTableDataset(store_address_t storeId, - LocalPoolDataSetBase* dataset, CCSDSTime::CDS_short* datasetTimeStamp) { - ReturnValue_t result; +void PCDUHandler::updateHkTableDataset(store_address_t storeId, LocalPoolDataSetBase* dataset, + CCSDSTime::CDS_short* datasetTimeStamp) { + ReturnValue_t result; - HousekeepingSnapshot packetUpdate(reinterpret_cast(datasetTimeStamp), - sizeof(CCSDSTime::CDS_short), dataset); - const uint8_t* packet_ptr = NULL; - size_t size; - result = IPCStore->getData(storeId, &packet_ptr, &size); - if (result != RETURN_OK) { - sif::error << "PCDUHandler::updateHkTableDataset: Failed to get data from IPCStore." - << std::endl; - } - dataset->read(); - result = packetUpdate.deSerialize(&packet_ptr, &size, SerializeIF::Endianness::MACHINE); - if (result != RETURN_OK) { - sif::error << "PCDUHandler::updateHkTableDataset: Failed to deserialize received packet " - "in hk table dataset"<< std::endl; - } - dataset->commit(); - result = IPCStore->deleteData(storeId); - if (result != RETURN_OK) { - sif::error << "PCDUHandler::updateHkTableDataset: Failed to delete data in IPCStore" - << std::endl; - } + HousekeepingSnapshot packetUpdate(reinterpret_cast(datasetTimeStamp), + sizeof(CCSDSTime::CDS_short), dataset); + const uint8_t* packet_ptr = NULL; + size_t size; + result = IPCStore->getData(storeId, &packet_ptr, &size); + if (result != RETURN_OK) { + sif::error << "PCDUHandler::updateHkTableDataset: Failed to get data from IPCStore." + << std::endl; + } + dataset->read(); + result = packetUpdate.deSerialize(&packet_ptr, &size, SerializeIF::Endianness::MACHINE); + if (result != RETURN_OK) { + sif::error << "PCDUHandler::updateHkTableDataset: Failed to deserialize received packet " + "in hk table dataset" + << std::endl; + } + dataset->commit(); + result = IPCStore->deleteData(storeId); + if (result != RETURN_OK) { + sif::error << "PCDUHandler::updateHkTableDataset: Failed to delete data in IPCStore" + << std::endl; + } } void PCDUHandler::updatePdu2SwitchStates() { - //TODO: pool read helper - if (pdu2HkTableDataset.read() == RETURN_OK) { - switchStates[pcduSwitches::Q7S] = pdu2HkTableDataset.outEnabledQ7S.value; - switchStates[pcduSwitches::PAYLOAD_PCDU_CH1] = pdu2HkTableDataset.outEnabledPlPCDUCh1.value; - switchStates[pcduSwitches::RW] = pdu2HkTableDataset.outEnabledReactionWheels.value; - switchStates[pcduSwitches::TCS_BOARD_8V_HEATER_IN] = pdu2HkTableDataset.outEnabledTCSBoardHeaterIn.value; - switchStates[pcduSwitches::SUS_REDUNDANT] = pdu2HkTableDataset.outEnabledSUSRedundant.value; - switchStates[pcduSwitches::DEPLOYMENT_MECHANISM] = pdu2HkTableDataset.outEnabledDeplMechanism.value; - switchStates[pcduSwitches::PAYLOAD_PCDU_CH6] = pdu2HkTableDataset.outEnabledPlPCDUCh6.value; - switchStates[pcduSwitches::ACS_BOARD_SIDE_B] = pdu2HkTableDataset.outEnabledAcsBoardSideB.value; - switchStates[pcduSwitches::PAYLOAD_CAMERA] = pdu2HkTableDataset.outEnabledPayloadCamera.value; - } - else { - sif::debug << "PCDUHandler::updatePdu2SwitchStates: Failed to read PDU2 Hk Dataset" - << std::endl; - } - pdu2HkTableDataset.commit(); + // TODO: pool read helper + if (pdu2HkTableDataset.read() == RETURN_OK) { + switchStates[pcduSwitches::Q7S] = pdu2HkTableDataset.outEnabledQ7S.value; + switchStates[pcduSwitches::PAYLOAD_PCDU_CH1] = pdu2HkTableDataset.outEnabledPlPCDUCh1.value; + switchStates[pcduSwitches::RW] = pdu2HkTableDataset.outEnabledReactionWheels.value; + switchStates[pcduSwitches::TCS_BOARD_8V_HEATER_IN] = + pdu2HkTableDataset.outEnabledTCSBoardHeaterIn.value; + switchStates[pcduSwitches::SUS_REDUNDANT] = pdu2HkTableDataset.outEnabledSUSRedundant.value; + switchStates[pcduSwitches::DEPLOYMENT_MECHANISM] = + pdu2HkTableDataset.outEnabledDeplMechanism.value; + switchStates[pcduSwitches::PAYLOAD_PCDU_CH6] = pdu2HkTableDataset.outEnabledPlPCDUCh6.value; + switchStates[pcduSwitches::ACS_BOARD_SIDE_B] = pdu2HkTableDataset.outEnabledAcsBoardSideB.value; + switchStates[pcduSwitches::PAYLOAD_CAMERA] = pdu2HkTableDataset.outEnabledPayloadCamera.value; + } else { + sif::debug << "PCDUHandler::updatePdu2SwitchStates: Failed to read PDU2 Hk Dataset" + << std::endl; + } + pdu2HkTableDataset.commit(); } void PCDUHandler::updatePdu1SwitchStates() { - if (pdu1HkTableDataset.read() == RETURN_OK) { - switchStates[pcduSwitches::TCS_BOARD_3V3] = pdu1HkTableDataset.voltageOutTCSBoard3V3.value; - switchStates[pcduSwitches::SYRLINKS] = pdu1HkTableDataset.voltageOutSyrlinks.value; - switchStates[pcduSwitches::STAR_TRACKER] = pdu1HkTableDataset.voltageOutStarTracker.value; - switchStates[pcduSwitches::MGT] = pdu1HkTableDataset.voltageOutMGT.value; - switchStates[pcduSwitches::SUS_NOMINAL] = pdu1HkTableDataset.voltageOutSUSNominal.value; - switchStates[pcduSwitches::SOLAR_CELL_EXP] = pdu1HkTableDataset.voltageOutSolarCellExp.value; - switchStates[pcduSwitches::PLOC] = pdu1HkTableDataset.voltageOutPLOC.value; - switchStates[pcduSwitches::ACS_BOARD_SIDE_A] = pdu1HkTableDataset.voltageOutACSBoardSideA.value; - } - else { - sif::debug << "PCDUHandler::updatePdu1SwitchStates: Failed to read dataset" << std::endl; - } - pdu1HkTableDataset.commit(); + if (pdu1HkTableDataset.read() == RETURN_OK) { + switchStates[pcduSwitches::TCS_BOARD_3V3] = pdu1HkTableDataset.voltageOutTCSBoard3V3.value; + switchStates[pcduSwitches::SYRLINKS] = pdu1HkTableDataset.voltageOutSyrlinks.value; + switchStates[pcduSwitches::STAR_TRACKER] = pdu1HkTableDataset.voltageOutStarTracker.value; + switchStates[pcduSwitches::MGT] = pdu1HkTableDataset.voltageOutMGT.value; + switchStates[pcduSwitches::SUS_NOMINAL] = pdu1HkTableDataset.voltageOutSUSNominal.value; + switchStates[pcduSwitches::SOLAR_CELL_EXP] = pdu1HkTableDataset.voltageOutSolarCellExp.value; + switchStates[pcduSwitches::PLOC] = pdu1HkTableDataset.voltageOutPLOC.value; + switchStates[pcduSwitches::ACS_BOARD_SIDE_A] = pdu1HkTableDataset.voltageOutACSBoardSideA.value; + } else { + sif::debug << "PCDUHandler::updatePdu1SwitchStates: Failed to read dataset" << std::endl; + } + pdu1HkTableDataset.commit(); } -LocalDataPoolManager* PCDUHandler::getHkManagerHandle() { - return &poolManager; -} +LocalDataPoolManager* PCDUHandler::getHkManagerHandle() { return &poolManager; } void PCDUHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const { + ReturnValue_t result; + uint16_t memoryAddress; + size_t parameterValueSize = sizeof(uint8_t); + uint8_t parameterValue; + GomspaceDeviceHandler* pdu; - ReturnValue_t result; - uint16_t memoryAddress; - size_t parameterValueSize = sizeof(uint8_t); - uint8_t parameterValue; - GomspaceDeviceHandler* pdu; - - switch (switchNr) { + switch (switchNr) { case pcduSwitches::TCS_BOARD_8V_HEATER_IN: - memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_TCS_BOARD_HEATER_IN; - pdu = ObjectManager::instance()->get(objects::PDU2_HANDLER); - break; + memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_TCS_BOARD_HEATER_IN; + pdu = ObjectManager::instance()->get(objects::PDU2_HANDLER); + break; case pcduSwitches::DEPLOYMENT_MECHANISM: - memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_DEPLOYMENT_MECHANISM; - pdu = ObjectManager::instance()->get(objects::PDU2_HANDLER); - break; + memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_DEPLOYMENT_MECHANISM; + pdu = ObjectManager::instance()->get(objects::PDU2_HANDLER); + break; default: - sif::error << "PCDUHandler::sendSwitchCommand: Invalid switch number " << std::endl; - return; - } + sif::error << "PCDUHandler::sendSwitchCommand: Invalid switch number " << std::endl; + return; + } - switch (onOff) { + switch (onOff) { case PowerSwitchIF::SWITCH_ON: - parameterValue = 1; - break; + parameterValue = 1; + break; case PowerSwitchIF::SWITCH_OFF: - parameterValue = 0; - break; + parameterValue = 0; + break; default: - sif::error << "PCDUHandler::sendSwitchCommand: Invalid state commanded" << std::endl; - return; - } + sif::error << "PCDUHandler::sendSwitchCommand: Invalid state commanded" << std::endl; + return; + } - GomspaceSetParamMessage setParamMessage(memoryAddress, ¶meterValue, parameterValueSize); + GomspaceSetParamMessage setParamMessage(memoryAddress, ¶meterValue, parameterValueSize); - size_t serializedLength = 0; - uint8_t command[4]; - uint8_t* commandPtr = command; - size_t maxSize = sizeof(command); - setParamMessage.serialize(&commandPtr, &serializedLength, maxSize, - SerializeIF::Endianness::BIG); + size_t serializedLength = 0; + uint8_t command[4]; + uint8_t* commandPtr = command; + size_t maxSize = sizeof(command); + setParamMessage.serialize(&commandPtr, &serializedLength, maxSize, SerializeIF::Endianness::BIG); - store_address_t storeAddress; - result = IPCStore->addData(&storeAddress, command,sizeof(command)); + store_address_t storeAddress; + result = IPCStore->addData(&storeAddress, command, sizeof(command)); - CommandMessage message; - ActionMessage::setCommand(&message, GOMSPACE::PARAM_SET, storeAddress); + CommandMessage message; + ActionMessage::setCommand(&message, GOMSPACE::PARAM_SET, storeAddress); - result = commandQueue->sendMessage(pdu->getCommandQueue(), &message, 0); - if (result != RETURN_OK) { - sif::debug << "PCDUHandler::sendSwitchCommand: Failed to send message to PDU Handler" - << std::endl; - } + result = commandQueue->sendMessage(pdu->getCommandQueue(), &message, 0); + if (result != RETURN_OK) { + sif::debug << "PCDUHandler::sendSwitchCommand: Failed to send message to PDU Handler" + << std::endl; + } } -void PCDUHandler::sendFuseOnCommand(uint8_t fuseNr) const { +void PCDUHandler::sendFuseOnCommand(uint8_t fuseNr) const {} +ReturnValue_t PCDUHandler::getSwitchState(uint8_t switchNr) const { + if (switchNr >= pcduSwitches::NUMBER_OF_SWITCHES) { + sif::debug << "PCDUHandler::getSwitchState: Invalid switch number" << std::endl; + return RETURN_FAILED; + } + if (switchStates[switchNr] == 1) { + return PowerSwitchIF::SWITCH_ON; + } else { + return PowerSwitchIF::SWITCH_OFF; + } } -ReturnValue_t PCDUHandler::getSwitchState( uint8_t switchNr ) const { - if (switchNr >= pcduSwitches::NUMBER_OF_SWITCHES) { - sif::debug << "PCDUHandler::getSwitchState: Invalid switch number" << std::endl; - return RETURN_FAILED; - } - if (switchStates[switchNr] == 1) { - return PowerSwitchIF::SWITCH_ON; - } - else { - return PowerSwitchIF::SWITCH_OFF; - } -} +ReturnValue_t PCDUHandler::getFuseState(uint8_t fuseNr) const { return RETURN_OK; } -ReturnValue_t PCDUHandler::getFuseState( uint8_t fuseNr ) const { - return RETURN_OK; -} +uint32_t PCDUHandler::getSwitchDelayMs(void) const { return 20000; } -uint32_t PCDUHandler::getSwitchDelayMs(void) const { - return 20000; -} +object_id_t PCDUHandler::getObjectId() const { return SystemObject::getObjectId(); } -object_id_t PCDUHandler::getObjectId() const { - return SystemObject::getObjectId(); -} +ReturnValue_t PCDUHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) { + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_Q7S, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_RW, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_SUS_REDUNDANT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, new PoolEntry({0})); -ReturnValue_t PCDUHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_Q7S, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_RW, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_Q7S, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_RW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_SUS_REDUNDANT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CONV_EN_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CONV_EN_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CONV_EN_3, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_Q7S, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_RW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, new PoolEntry( { 0 })); - - localDataPoolMap.emplace(P60System::PDU2_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CONV_EN_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CONV_EN_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CONV_EN_3, new PoolEntry( { 0 })); - - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_Q7S, new PoolEntry( { - pcduSwitches::INIT_STATE_Q7S })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, new PoolEntry( { - pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH1 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_RW, new PoolEntry( { - pcduSwitches::INIT_STATE_RW })); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_Q7S, + new PoolEntry({pcduSwitches::INIT_STATE_Q7S})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, + new PoolEntry({pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH1})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_RW, + new PoolEntry({pcduSwitches::INIT_STATE_RW})); #if BOARD_TE0720 == 1 - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry( { 1 })); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry({1})); #else - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry( {pcduSwitches::INIT_STATE_TCS_BOARD_8V_HEATER_IN})); + localDataPoolMap.emplace( + P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, + new PoolEntry({pcduSwitches::INIT_STATE_TCS_BOARD_8V_HEATER_IN})); #endif - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_SUS_REDUNDANT, new PoolEntry( { - pcduSwitches::INIT_STATE_SUS_REDUNDANT })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_DEPLOYMENT_MECHANISM, new PoolEntry( { - pcduSwitches::INIT_STATE_DEPLOYMENT_MECHANISM })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH6, new PoolEntry( { - pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH6 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_ACS_BOARD_SIDE_B, new PoolEntry( { - pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_B })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_CAMERA, new PoolEntry( { - pcduSwitches::INIT_STATE_PAYLOAD_CAMERA })); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_SUS_REDUNDANT, + new PoolEntry({pcduSwitches::INIT_STATE_SUS_REDUNDANT})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_DEPLOYMENT_MECHANISM, + new PoolEntry({pcduSwitches::INIT_STATE_DEPLOYMENT_MECHANISM})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH6, + new PoolEntry({pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH6})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_ACS_BOARD_SIDE_B, + new PoolEntry({pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_B})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_CAMERA, + new PoolEntry({pcduSwitches::INIT_STATE_PAYLOAD_CAMERA})); - localDataPoolMap.emplace(P60System::PDU2_BOOTCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_BOOTCNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_UPTIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_RESETCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_BATT_MODE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_BOOTCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_BOOTCNT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_RESETCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_BATT_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_Q7S, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_RW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_SUS_REDUNDANT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_DEPLOYMENT_MECHANISM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_ACS_BOARD_SIDE_B, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_CAMERA, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_Q7S, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_RW, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_SUS_REDUNDANT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_DEPLOYMENT_MECHANISM, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_ACS_BOARD_SIDE_B, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_CAMERA, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_5, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_7, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_0_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_1_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_2_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_3_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_4_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_5_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_6_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_7_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_0_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_1_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_2_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_3_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_4_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_5_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_6_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_7_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_GND, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_I2C, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CAN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_GND_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_I2C_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CAN_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_GND, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_I2C, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CAN, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_GND_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_I2C_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CAN_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CONV_EN_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CONV_EN_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CONV_EN_3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CONV_EN_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CONV_EN_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CONV_EN_3, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_ACS_BOARD_SIDE_A, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_BOOTCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_BOOTCNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_UPTIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_RESETCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_BATT_MODE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_BOOTCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_BOOTCNT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_RESETCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_BATT_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_ACS_BOARD_SIDE_A, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_5, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_7, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_0_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_1_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_2_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_3_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_4_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_5_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_6_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_7_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_0_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_1_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_2_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_3_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_4_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_5_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_6_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_7_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_GND, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_I2C, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CAN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_GND_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_I2C_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CAN_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_GND, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_I2C, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CAN, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_GND_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_I2C_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CAN_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT2, new PoolEntry({0})); - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t PCDUHandler::initializeAfterTaskCreation() { + if (executingTask != nullptr) { + pstIntervalMs = executingTask->getPeriodMs(); + } + this->poolManager.initializeAfterTaskCreation(); - if(executingTask != nullptr) { - pstIntervalMs = executingTask->getPeriodMs(); - } - this->poolManager.initializeAfterTaskCreation(); + initializeSwitchStates(); - initializeSwitchStates(); - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } -uint32_t PCDUHandler::getPeriodicOperationFrequency() const { - return pstIntervalMs; -} +uint32_t PCDUHandler::getPeriodicOperationFrequency() const { return pstIntervalMs; } -void PCDUHandler::setTaskIF(PeriodicTaskIF* task){ - executingTask = task; -} +void PCDUHandler::setTaskIF(PeriodicTaskIF* task) { executingTask = task; } LocalPoolDataSetBase* PCDUHandler::getDataSetHandle(sid_t sid) { - if (sid == pdu2HkTableDataset.getSid()) { - return &pdu2HkTableDataset; - } else { - sif::error << "PCDUHandler::getDataSetHandle: Invalid sid" << std::endl; - return nullptr; - } + if (sid == pdu2HkTableDataset.getSid()) { + return &pdu2HkTableDataset; + } else { + sif::error << "PCDUHandler::getDataSetHandle: Invalid sid" << std::endl; + return nullptr; + } } diff --git a/mission/devices/PCDUHandler.h b/mission/devices/PCDUHandler.h index 566e1d9c..c045ed03 100644 --- a/mission/devices/PCDUHandler.h +++ b/mission/devices/PCDUHandler.h @@ -2,120 +2,116 @@ #define MISSION_DEVICES_PCDUHANDLER_H_ #include -#include -#include -#include -#include #include #include +#include #include -#include - +#include +#include +#include /** * @brief The PCDUHandler provides a compact interface to handle all devices related to the - * control of power. This is necessary because the fsfw manages all power related - * functionalities via one power object. This includes for example the switch on and off - * of devices. + * control of power. This is necessary because the fsfw manages all power + * related functionalities via one power object. This includes for example the switch on and off of + * devices. */ -class PCDUHandler: public PowerSwitchIF, - public HasLocalDataPoolIF, - public SystemObject, - public ExecutableObjectIF { -public: +class PCDUHandler : public PowerSwitchIF, + public HasLocalDataPoolIF, + public SystemObject, + public ExecutableObjectIF { + public: + PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize = 20); + virtual ~PCDUHandler(); - PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize = 20); - virtual ~PCDUHandler(); + virtual ReturnValue_t initialize() override; + virtual ReturnValue_t performOperation(uint8_t counter) override; + virtual void handleChangedDataset(sid_t sid, + store_address_t storeId = storeId::INVALID_STORE_ADDRESS); - virtual ReturnValue_t initialize() override; - virtual ReturnValue_t performOperation(uint8_t counter) override; - virtual void handleChangedDataset(sid_t sid, store_address_t storeId = - storeId::INVALID_STORE_ADDRESS); + virtual void sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const override; + virtual void sendFuseOnCommand(uint8_t fuseNr) const override; + virtual ReturnValue_t getSwitchState(uint8_t switchNr) const override; + virtual ReturnValue_t getFuseState(uint8_t fuseNr) const override; + virtual uint32_t getSwitchDelayMs(void) const override; + virtual object_id_t getObjectId() const override; + virtual LocalDataPoolManager* getHkManagerHandle() override; - virtual void sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const override; - virtual void sendFuseOnCommand(uint8_t fuseNr) const override; - virtual ReturnValue_t getSwitchState( uint8_t switchNr ) const override; - virtual ReturnValue_t getFuseState( uint8_t fuseNr ) const override; - virtual uint32_t getSwitchDelayMs(void) const override; - virtual object_id_t getObjectId() const override; - virtual LocalDataPoolManager* getHkManagerHandle() override; + virtual MessageQueueId_t getCommandQueue() const override; + virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; + virtual uint32_t getPeriodicOperationFrequency() const override; + virtual ReturnValue_t initializeAfterTaskCreation() override; + virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + virtual void setTaskIF(PeriodicTaskIF* task_); - virtual MessageQueueId_t getCommandQueue() const override; - virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; - virtual uint32_t getPeriodicOperationFrequency() const override; - virtual ReturnValue_t initializeAfterTaskCreation() override; - virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; - virtual void setTaskIF(PeriodicTaskIF* task_); + private: + uint32_t pstIntervalMs = 0; -private: + /** Housekeeping manager. Handles updates of local pool variables. */ + LocalDataPoolManager poolManager; - uint32_t pstIntervalMs = 0; + /** + * The dataset holding the hk table of PDU2. This dataset is a copy of the PDU2 HK dataset + * of the PDU2Handler. Each time the PDU2Handler updates his HK dataset, a copy is sent + * to this object via a HousekeepingMessage. + */ + PDU2::PDU2HkTableDataset pdu2HkTableDataset; + /** The timeStamp of the current pdu2HkTableDataset */ + CCSDSTime::CDS_short timeStampPdu2HkDataset; - /** Housekeeping manager. Handles updates of local pool variables. */ - LocalDataPoolManager poolManager; + /** Hk table dataset of PDU1 */ + PDU1::PDU1HkTableDataset pdu1HkTableDataset; + /** The timeStamp of the current pdu1HkTableDataset */ + CCSDSTime::CDS_short timeStampPdu1HkDataset; - /** - * The dataset holding the hk table of PDU2. This dataset is a copy of the PDU2 HK dataset - * of the PDU2Handler. Each time the PDU2Handler updates his HK dataset, a copy is sent - * to this object via a HousekeepingMessage. - */ - PDU2::PDU2HkTableDataset pdu2HkTableDataset; - /** The timeStamp of the current pdu2HkTableDataset */ - CCSDSTime::CDS_short timeStampPdu2HkDataset; + uint8_t switchStates[pcduSwitches::NUMBER_OF_SWITCHES]; + /** + * Pointer to the IPCStore. + * This caches the pointer received from the objectManager in the constructor. + */ + StorageManagerIF* IPCStore = nullptr; - /** Hk table dataset of PDU1 */ - PDU1::PDU1HkTableDataset pdu1HkTableDataset; - /** The timeStamp of the current pdu1HkTableDataset */ - CCSDSTime::CDS_short timeStampPdu1HkDataset; + /** + * Message queue to communicate with other objetcs. Used for example to receive + * local pool messages from ACU, PDU1 and PDU2. + */ + MessageQueueIF* commandQueue = nullptr; - uint8_t switchStates[pcduSwitches::NUMBER_OF_SWITCHES]; - /** - * Pointer to the IPCStore. - * This caches the pointer received from the objectManager in the constructor. - */ - StorageManagerIF *IPCStore = nullptr; + size_t cmdQueueSize; - /** - * Message queue to communicate with other objetcs. Used for example to receive - * local pool messages from ACU, PDU1 and PDU2. - */ - MessageQueueIF* commandQueue = nullptr; + PeriodicTaskIF* executingTask = nullptr; - size_t cmdQueueSize; + void readCommandQueue(); - PeriodicTaskIF* executingTask = nullptr; + /** + * @brief This function sets all switchStates to the initial switch configuration of the + * two PDUs after reboot. + */ + void initializeSwitchStates(); - void readCommandQueue(); + /** + * @brief Updates all switchStates related to the PDU2. + * Function is called each time a new hk dataset has been received from the PDU2Handler. + */ + void updatePdu2SwitchStates(); - /** - * @brief This function sets all switchStates to the initial switch configuration of the - * two PDUs after reboot. - */ - void initializeSwitchStates(); + /** + * @brief Updates all switchStates related to the PDU1. Called each time the PDU1Handler + * sends a new hk dataset. + */ + void updatePdu1SwitchStates(); - /** - * @brief Updates all switchStates related to the PDU2. - * Function is called each time a new hk dataset has been received from the PDU2Handler. - */ - void updatePdu2SwitchStates(); - - /** - * @brief Updates all switchStates related to the PDU1. Called each time the PDU1Handler - * sends a new hk dataset. - */ - void updatePdu1SwitchStates(); - - /** - * @brief In case of an update snapshot message this function handles the update of the - * local dataset. - * @param storeId Storage id of updated dataset. - * @param dataset Pointer to the local dataset. - * @param datasetTimeStamp Pointer to a variable which will hold the timestamp of the updated - * dataset. - */ - void updateHkTableDataset(store_address_t storeId, LocalPoolDataSetBase* dataset, - CCSDSTime::CDS_short* datasetTimeStamp); + /** + * @brief In case of an update snapshot message this function handles the update of the + * local dataset. + * @param storeId Storage id of updated dataset. + * @param dataset Pointer to the local dataset. + * @param datasetTimeStamp Pointer to a variable which will hold the timestamp of the updated + * dataset. + */ + void updateHkTableDataset(store_address_t storeId, LocalPoolDataSetBase* dataset, + CCSDSTime::CDS_short* datasetTimeStamp); }; #endif /* MISSION_DEVICES_PCDUHANDLER_H_ */ diff --git a/mission/devices/PDU1Handler.cpp b/mission/devices/PDU1Handler.cpp index 1676e488..a1486588 100644 --- a/mission/devices/PDU1Handler.cpp +++ b/mission/devices/PDU1Handler.cpp @@ -1,402 +1,421 @@ -#include "OBSWConfig.h" #include "PDU1Handler.h" #include -PDU1Handler::PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - GomspaceDeviceHandler(objectId, comIF, comCookie, PDU::MAX_CONFIGTABLE_ADDRESS, - PDU::MAX_HKTABLE_ADDRESS, PDU::HK_TABLE_REPLY_SIZE, &pdu1HkTableDataset), - pdu1HkTableDataset(this) { -} +#include "OBSWConfig.h" -PDU1Handler::~PDU1Handler() { -} +PDU1Handler::PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie) + : GomspaceDeviceHandler(objectId, comIF, comCookie, PDU::MAX_CONFIGTABLE_ADDRESS, + PDU::MAX_HKTABLE_ADDRESS, PDU::HK_TABLE_REPLY_SIZE, + &pdu1HkTableDataset), + pdu1HkTableDataset(this) {} -ReturnValue_t PDU1Handler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - *id = GOMSPACE::REQUEST_HK_TABLE; - return buildCommandFromCommand(*id, NULL, 0); +PDU1Handler::~PDU1Handler() {} + +ReturnValue_t PDU1Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + *id = GOMSPACE::REQUEST_HK_TABLE; + return buildCommandFromCommand(*id, NULL, 0); } void PDU1Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) { - - parseHkTableReply(packet); - handleDeviceTM(&pdu1HkTableDataset, id, true); + parseHkTableReply(packet); + handleDeviceTM(&pdu1HkTableDataset, id, true); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PDU1 == 1 - pdu1HkTableDataset.read(); - sif::info << "PDU1 TCS Board voltage: " << pdu1HkTableDataset.voltageOutTCSBoard3V3 + pdu1HkTableDataset.read(); + sif::info << "PDU1 TCS Board voltage: " << pdu1HkTableDataset.voltageOutTCSBoard3V3 << std::endl; + sif::info << "PDU1 Syrlinks voltage: " << pdu1HkTableDataset.voltageOutSyrlinks << std::endl; + sif::info << "PDU1 star tracker voltage: " << pdu1HkTableDataset.voltageOutStarTracker << std::endl; - sif::info << "PDU1 Syrlinks voltage: " << pdu1HkTableDataset.voltageOutSyrlinks << std::endl; - sif::info << "PDU1 star tracker voltage: " << pdu1HkTableDataset.voltageOutStarTracker + sif::info << "PDU1 MGT voltage: " << pdu1HkTableDataset.voltageOutMGT << std::endl; + sif::info << "PDU1 SUS nominal voltage: " << pdu1HkTableDataset.voltageOutSUSNominal << std::endl; + sif::info << "PDU1 solar cell experiment voltage: " << pdu1HkTableDataset.voltageOutSolarCellExp << std::endl; - sif::info << "PDU1 MGT voltage: " << pdu1HkTableDataset.voltageOutMGT << std::endl; - sif::info << "PDU1 SUS nominal voltage: " << pdu1HkTableDataset.voltageOutSUSNominal + sif::info << "PDU1 PLOC voltage: " << pdu1HkTableDataset.voltageOutPLOC << std::endl; + sif::info << "PDU1 ACS Side A voltage: " << pdu1HkTableDataset.voltageOutACSBoardSideA << std::endl; - sif::info << "PDU1 solar cell experiment voltage: " << pdu1HkTableDataset.voltageOutSolarCellExp - << std::endl; - sif::info << "PDU1 PLOC voltage: " << pdu1HkTableDataset.voltageOutPLOC << std::endl; - sif::info << "PDU1 ACS Side A voltage: " << pdu1HkTableDataset.voltageOutACSBoardSideA - << std::endl; - sif::info << "PDU1 channel 8 voltage: " << pdu1HkTableDataset.voltageOutACSBoardSideA + sif::info << "PDU1 channel 8 voltage: " << pdu1HkTableDataset.voltageOutACSBoardSideA << std::endl; - sif::info << "PDU1 TCS Board current: " << pdu1HkTableDataset.currentOutTCSBoard3V3 + sif::info << "PDU1 TCS Board current: " << pdu1HkTableDataset.currentOutTCSBoard3V3 << std::endl; + sif::info << "PDU1 Syrlinks current: " << pdu1HkTableDataset.currentOutSyrlinks << std::endl; + sif::info << "PDU1 star tracker current: " << pdu1HkTableDataset.currentOutStarTracker << std::endl; - sif::info << "PDU1 Syrlinks current: " << pdu1HkTableDataset.currentOutSyrlinks << std::endl; - sif::info << "PDU1 star tracker current: " << pdu1HkTableDataset.currentOutStarTracker + sif::info << "PDU1 MGT current: " << pdu1HkTableDataset.currentOutMGT << std::endl; + sif::info << "PDU1 SUS nominal current: " << pdu1HkTableDataset.currentOutSUSNominal << std::endl; + sif::info << "PDU1 solar cell experiment current: " << pdu1HkTableDataset.currentOutSolarCellExp << std::endl; - sif::info << "PDU1 MGT current: " << pdu1HkTableDataset.currentOutMGT << std::endl; - sif::info << "PDU1 SUS nominal current: " << pdu1HkTableDataset.currentOutSUSNominal + sif::info << "PDU1 PLOC current: " << pdu1HkTableDataset.currentOutPLOC << std::endl; + sif::info << "PDU1 ACS Side A current: " << pdu1HkTableDataset.currentOutACSBoardSideA << std::endl; - sif::info << "PDU1 solar cell experiment current: " << pdu1HkTableDataset.currentOutSolarCellExp + sif::info << "PDU1 channel 8 current: " << pdu1HkTableDataset.currentOutChannel8 << std::endl; + printOutputSwitchStates(); + sif::info << "PDU1 battery mode: " << static_cast(pdu1HkTableDataset.battMode.value) << std::endl; - sif::info << "PDU1 PLOC current: " << pdu1HkTableDataset.currentOutPLOC << std::endl; - sif::info << "PDU1 ACS Side A current: " << pdu1HkTableDataset.currentOutACSBoardSideA + sif::info << "PDU1 VCC: " << pdu1HkTableDataset.vcc << " mV" << std::endl; + float vbat = pdu1HkTableDataset.vbat.value * 0.001; + sif::info << "PDU1 VBAT: " << vbat << "V" << std::endl; + float temperatureC = pdu1HkTableDataset.temperature.value * 0.1; + sif::info << "PDU1 Temperature: " << temperatureC << " °C" << std::endl; + sif::info << "PDU1 csp1 watchdog pings before reboot: " + << static_cast(pdu1HkTableDataset.csp1WatchdogPingsLeft.value) << std::endl; - sif::info << "PDU1 channel 8 current: " << pdu1HkTableDataset.currentOutChannel8 + sif::info << "PDU1 csp2 watchdog pings before reboot: " + << static_cast(pdu1HkTableDataset.csp2WatchdogPingsLeft.value) << std::endl; - printOutputSwitchStates(); - sif::info << "PDU1 battery mode: " << - static_cast(pdu1HkTableDataset.battMode.value) << std::endl; - sif::info << "PDU1 VCC: " << pdu1HkTableDataset.vcc << " mV" << std::endl; - float vbat = pdu1HkTableDataset.vbat.value * 0.001; - sif::info << "PDU1 VBAT: " << vbat << "V" << std::endl; - float temperatureC = pdu1HkTableDataset.temperature.value * 0.1; - sif::info << "PDU1 Temperature: " << temperatureC << " °C" << std::endl; - sif::info << "PDU1 csp1 watchdog pings before reboot: " - << static_cast(pdu1HkTableDataset.csp1WatchdogPingsLeft.value) << std::endl; - sif::info << "PDU1 csp2 watchdog pings before reboot: " - << static_cast(pdu1HkTableDataset.csp2WatchdogPingsLeft.value) << std::endl; - pdu1HkTableDataset.commit(); + pdu1HkTableDataset.commit(); #endif } void PDU1Handler::parseHkTableReply(const uint8_t *packet) { - uint16_t dataOffset = 0; - PoolReadGuard pg(&pdu1HkTableDataset); - ReturnValue_t readResult = pg.getReadResult(); - if(readResult != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Reading PDU1 HK table failed!" << std::endl; - return; - } - /* Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table - * address. */ - dataOffset += 12; - pdu1HkTableDataset.currentOutTCSBoard3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutStarTracker = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutMGT = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutSUSNominal = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutSolarCellExp = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutPLOC = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutACSBoardSideA = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + uint16_t dataOffset = 0; + PoolReadGuard pg(&pdu1HkTableDataset); + ReturnValue_t readResult = pg.getReadResult(); + if (readResult != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Reading PDU1 HK table failed!" << std::endl; + return; + } + /* Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table + * address. */ + dataOffset += 12; + pdu1HkTableDataset.currentOutTCSBoard3V3 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutStarTracker = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutMGT = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutSUSNominal = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutSolarCellExp = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutPLOC = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutACSBoardSideA = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu1HkTableDataset.voltageOutTCSBoard3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutStarTracker = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutMGT = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutSUSNominal = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutSolarCellExp = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutPLOC = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutACSBoardSideA = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + pdu1HkTableDataset.voltageOutTCSBoard3V3 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutStarTracker = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutMGT = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutSUSNominal = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutSolarCellExp = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutPLOC = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutACSBoardSideA = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu1HkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.temperature = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + pdu1HkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.temperature = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu1HkTableDataset.converterEnable1 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.converterEnable2 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.converterEnable3 = *(packet + dataOffset); - dataOffset += 3; + pdu1HkTableDataset.converterEnable1 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.converterEnable2 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.converterEnable3 = *(packet + dataOffset); + dataOffset += 3; - pdu1HkTableDataset.outEnabledTCSBoard3V3 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledSyrlinks = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledStarTracker = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledMGT = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledSUSNominal = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledSolarCellExp = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledPLOC = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledAcsBoardSideA = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledChannel8 = *(packet + dataOffset); - dataOffset += 3; + pdu1HkTableDataset.outEnabledTCSBoard3V3 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledSyrlinks = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledStarTracker = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledMGT = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledSUSNominal = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledSolarCellExp = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledPLOC = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledAcsBoardSideA = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledChannel8 = *(packet + dataOffset); + dataOffset += 3; - pdu1HkTableDataset.bootcause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.bootcount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.resetcause = *(packet + dataOffset + 1) << 8 | *(packet + dataOffset); - dataOffset += 4; - pdu1HkTableDataset.battMode = *(packet + dataOffset); - /* +10 because here begins the second gomspace csp packet */ - dataOffset += 3 + 10; + pdu1HkTableDataset.bootcause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.bootcount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.resetcause = *(packet + dataOffset + 1) << 8 | *(packet + dataOffset); + dataOffset += 4; + pdu1HkTableDataset.battMode = *(packet + dataOffset); + /* +10 because here begins the second gomspace csp packet */ + dataOffset += 3 + 10; - pdu1HkTableDataset.latchupsTcsBoard3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsStarTracker = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsMgt = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsSusNominal = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsSolarCellExp = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsPloc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsAcsBoardSideA = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + pdu1HkTableDataset.latchupsTcsBoard3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsStarTracker = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsMgt = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsSusNominal = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsSolarCellExp = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsPloc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsAcsBoardSideA = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu1HkTableDataset.device0 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device1 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device2 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device3 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device4 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device5 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device6 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device7 = *(packet + dataOffset); - dataOffset += 3; + pdu1HkTableDataset.device0 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device1 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device2 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device3 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device4 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device5 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device6 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device7 = *(packet + dataOffset); + dataOffset += 3; - pdu1HkTableDataset.device0Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device1Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device2Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device3Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device4Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device5Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device6Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device7Status = *(packet + dataOffset); - dataOffset += 3; + pdu1HkTableDataset.device0Status = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device1Status = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device2Status = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device3Status = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device4Status = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device5Status = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device6Status = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device7Status = *(packet + dataOffset); + dataOffset += 3; - pdu1HkTableDataset.gndWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.i2cWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.canWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.csp1WdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.csp2WdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.groundWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.i2cWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.canWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.csp1WatchdogPingsLeft = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.csp2WatchdogPingsLeft = *(packet + dataOffset); + pdu1HkTableDataset.gndWdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.i2cWdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.canWdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.csp1WdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.csp2WdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.groundWatchdogSecondsLeft = + *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.i2cWatchdogSecondsLeft = + *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.canWatchdogSecondsLeft = + *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.csp1WatchdogPingsLeft = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.csp2WatchdogPingsLeft = *(packet + dataOffset); - pdu1HkTableDataset.setChanged(true); - if(not pdu1HkTableDataset.isValid()) { - pdu1HkTableDataset.setValidity(true, true); - } + pdu1HkTableDataset.setChanged(true); + if (not pdu1HkTableDataset.isValid()) { + pdu1HkTableDataset.setValidity(true, true); + } } -ReturnValue_t PDU1Handler::initializeLocalDataPool( - localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { +ReturnValue_t PDU1Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CONV_EN_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CONV_EN_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CONV_EN_3, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CONV_EN_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CONV_EN_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CONV_EN_3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_ACS_BOARD_SIDE_A, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_BOOTCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_BOOTCNT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_RESETCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_BATT_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_BOOTCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_BOOTCNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_UPTIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_RESETCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_BATT_MODE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_ACS_BOARD_SIDE_A, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_5, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_7, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_0_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_1_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_2_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_3_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_4_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_5_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_6_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_7_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_0_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_1_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_2_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_3_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_4_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_5_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_6_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_7_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_GND, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_I2C, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CAN, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_GND_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_I2C_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CAN_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_GND, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_I2C, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CAN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_GND_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_I2C_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CAN_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT2, new PoolEntry( { 0 })); - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t PDU1Handler::printStatus(DeviceCommandId_t cmd) { - switch(cmd) { - case(GOMSPACE::PRINT_SWITCH_V_I): { - PoolReadGuard pg(&pdu1HkTableDataset); - ReturnValue_t readResult = pg.getReadResult(); - if(readResult != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Reading PDU1 HK table failed!" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - printHkTable(); - return HasReturnvaluesIF::RETURN_OK; + switch (cmd) { + case (GOMSPACE::PRINT_SWITCH_V_I): { + PoolReadGuard pg(&pdu1HkTableDataset); + ReturnValue_t readResult = pg.getReadResult(); + if (readResult != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Reading PDU1 HK table failed!" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + printHkTable(); + return HasReturnvaluesIF::RETURN_OK; } default: { - return HasReturnvaluesIF::RETURN_FAILED; - } + return HasReturnvaluesIF::RETURN_FAILED; } + } } void PDU1Handler::printHkTable() { - sif::info << "PDU1 Info: SwitchState, Currents [mA], Voltages [mV]" << std::endl; - sif::info << std::setw(30) << std::left << "TCS Board" << std::dec << "| " << - unsigned(pdu1HkTableDataset.outEnabledTCSBoard3V3.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutTCSBoard3V3.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutTCSBoard3V3.value << std::endl; - sif::info << std::setw(30) << std::left << "Syrlinks" << std::dec << "| " << - unsigned(pdu1HkTableDataset.outEnabledSyrlinks.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutSyrlinks.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutSyrlinks.value << std::endl; - sif::info << std::setw(30) << std::left << "Star Tracker" << std::dec << "| " << - static_cast(pdu1HkTableDataset.outEnabledStarTracker.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutStarTracker.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutStarTracker.value << std::endl; - sif::info << std::setw(30) << std::left << "MGT" << std::dec << "| " << - static_cast(pdu1HkTableDataset.outEnabledMGT.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutMGT.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutMGT.value << std::endl; - sif::info << std::setw(30) << std::left << "SuS nominal" << std::dec << "| " << - static_cast(pdu1HkTableDataset.outEnabledSUSNominal.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutSUSNominal.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutSUSNominal.value << std::endl; - sif::info << std::setw(30) << std::left << "Solar Cell Experiment" << std::dec << "| " << - static_cast(pdu1HkTableDataset.outEnabledSolarCellExp.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutSolarCellExp.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutSolarCellExp.value << std::endl; - sif::info << std::setw(30) << std::left << "PLOC" << std::dec << "| " << - static_cast(pdu1HkTableDataset.outEnabledPLOC.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutPLOC.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutPLOC.value << std::endl; - sif::info << std::setw(30) << std::left << "ACS Side A" << std::dec << "| " << - static_cast(pdu1HkTableDataset.outEnabledAcsBoardSideA.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutACSBoardSideA.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutACSBoardSideA.value << std::endl; - sif::info << std::setw(30) << std::left << "Channel 8" << std::dec << "| " << - static_cast(pdu1HkTableDataset.outEnabledChannel8.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutChannel8.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutChannel8.value << std::right << std::endl; + sif::info << "PDU1 Info: SwitchState, Currents [mA], Voltages [mV]" << std::endl; + sif::info << std::setw(30) << std::left << "TCS Board" << std::dec << "| " + << unsigned(pdu1HkTableDataset.outEnabledTCSBoard3V3.value) << ", " << std::setw(4) + << std::right << pdu1HkTableDataset.currentOutTCSBoard3V3.value << ", " << std::setw(4) + << pdu1HkTableDataset.voltageOutTCSBoard3V3.value << std::endl; + sif::info << std::setw(30) << std::left << "Syrlinks" << std::dec << "| " + << unsigned(pdu1HkTableDataset.outEnabledSyrlinks.value) << ", " << std::setw(4) + << std::right << pdu1HkTableDataset.currentOutSyrlinks.value << ", " << std::setw(4) + << pdu1HkTableDataset.voltageOutSyrlinks.value << std::endl; + sif::info << std::setw(30) << std::left << "Star Tracker" << std::dec << "| " + << static_cast(pdu1HkTableDataset.outEnabledStarTracker.value) << ", " + << std::setw(4) << std::right << pdu1HkTableDataset.currentOutStarTracker.value << ", " + << std::setw(4) << pdu1HkTableDataset.voltageOutStarTracker.value << std::endl; + sif::info << std::setw(30) << std::left << "MGT" << std::dec << "| " + << static_cast(pdu1HkTableDataset.outEnabledMGT.value) << ", " + << std::setw(4) << std::right << pdu1HkTableDataset.currentOutMGT.value << ", " + << std::setw(4) << pdu1HkTableDataset.voltageOutMGT.value << std::endl; + sif::info << std::setw(30) << std::left << "SuS nominal" << std::dec << "| " + << static_cast(pdu1HkTableDataset.outEnabledSUSNominal.value) << ", " + << std::setw(4) << std::right << pdu1HkTableDataset.currentOutSUSNominal.value << ", " + << std::setw(4) << pdu1HkTableDataset.voltageOutSUSNominal.value << std::endl; + sif::info << std::setw(30) << std::left << "Solar Cell Experiment" << std::dec << "| " + << static_cast(pdu1HkTableDataset.outEnabledSolarCellExp.value) << ", " + << std::setw(4) << std::right << pdu1HkTableDataset.currentOutSolarCellExp.value << ", " + << std::setw(4) << pdu1HkTableDataset.voltageOutSolarCellExp.value << std::endl; + sif::info << std::setw(30) << std::left << "PLOC" << std::dec << "| " + << static_cast(pdu1HkTableDataset.outEnabledPLOC.value) << ", " + << std::setw(4) << std::right << pdu1HkTableDataset.currentOutPLOC.value << ", " + << std::setw(4) << pdu1HkTableDataset.voltageOutPLOC.value << std::endl; + sif::info << std::setw(30) << std::left << "ACS Side A" << std::dec << "| " + << static_cast(pdu1HkTableDataset.outEnabledAcsBoardSideA.value) << ", " + << std::setw(4) << std::right << pdu1HkTableDataset.currentOutACSBoardSideA.value + << ", " << std::setw(4) << pdu1HkTableDataset.voltageOutACSBoardSideA.value + << std::endl; + sif::info << std::setw(30) << std::left << "Channel 8" << std::dec << "| " + << static_cast(pdu1HkTableDataset.outEnabledChannel8.value) << ", " + << std::setw(4) << std::right << pdu1HkTableDataset.currentOutChannel8.value << ", " + << std::setw(4) << pdu1HkTableDataset.voltageOutChannel8.value << std::right + << std::endl; } - diff --git a/mission/devices/PDU1Handler.h b/mission/devices/PDU1Handler.h index 3df99776..0715b078 100644 --- a/mission/devices/PDU1Handler.h +++ b/mission/devices/PDU1Handler.h @@ -19,27 +19,28 @@ * ACS 3.3V for Side A group, channel 7 * Unoccupied, 5V, channel 8 */ -class PDU1Handler: public GomspaceDeviceHandler { -public: - PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); - virtual ~PDU1Handler(); +class PDU1Handler : public GomspaceDeviceHandler { + public: + PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + virtual ~PDU1Handler(); - virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; -protected: - /** - * @brief In MODE_NORMAL, a command will be built periodically by this function. - */ - 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; + virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; -private: - /** Dataset for the housekeeping table of the PDU1 */ - PDU1::PDU1HkTableDataset pdu1HkTableDataset; + protected: + /** + * @brief In MODE_NORMAL, a command will be built periodically by this function. + */ + 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; - void printHkTable(); - void parseHkTableReply(const uint8_t *packet); + private: + /** Dataset for the housekeeping table of the PDU1 */ + PDU1::PDU1HkTableDataset pdu1HkTableDataset; + + void printHkTable(); + void parseHkTableReply(const uint8_t* packet); }; #endif /* MISSION_DEVICES_PDU1Handler_H_ */ diff --git a/mission/devices/PDU2Handler.cpp b/mission/devices/PDU2Handler.cpp index 287fdaf3..b5c34af6 100644 --- a/mission/devices/PDU2Handler.cpp +++ b/mission/devices/PDU2Handler.cpp @@ -1,378 +1,423 @@ -#include "OBSWConfig.h" #include "PDU2Handler.h" -#include #include +#include -PDU2Handler::PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - GomspaceDeviceHandler(objectId, comIF, comCookie, PDU::MAX_CONFIGTABLE_ADDRESS, - PDU::MAX_HKTABLE_ADDRESS, PDU::HK_TABLE_REPLY_SIZE, &pdu2HkTableDataset), - pdu2HkTableDataset(this) { -} +#include "OBSWConfig.h" -PDU2Handler::~PDU2Handler() { -} +PDU2Handler::PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie) + : GomspaceDeviceHandler(objectId, comIF, comCookie, PDU::MAX_CONFIGTABLE_ADDRESS, + PDU::MAX_HKTABLE_ADDRESS, PDU::HK_TABLE_REPLY_SIZE, + &pdu2HkTableDataset), + pdu2HkTableDataset(this) {} -ReturnValue_t PDU2Handler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - *id = GOMSPACE::REQUEST_HK_TABLE; - return buildCommandFromCommand(*id, NULL, 0); +PDU2Handler::~PDU2Handler() {} + +ReturnValue_t PDU2Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + *id = GOMSPACE::REQUEST_HK_TABLE; + return buildCommandFromCommand(*id, NULL, 0); } void PDU2Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) { - - parseHkTableReply(packet); - /** - * Hk table will be sent to the commander if hk table request was not triggered by the - * PDU2Handler itself. - */ - handleDeviceTM(&pdu2HkTableDataset, id, true); + parseHkTableReply(packet); + /** + * Hk table will be sent to the commander if hk table request was not triggered by the + * PDU2Handler itself. + */ + handleDeviceTM(&pdu2HkTableDataset, id, true); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PDU2 == 1 - pdu2HkTableDataset.read(); - sif::info << "PDU2 Q7S current voltage: " << pdu2HkTableDataset.voltageOutQ7S << " mV" << std::endl; - sif::info << "PDU2 VCC: " << pdu2HkTableDataset.vcc << " mV" << std::endl; - float vbat = pdu2HkTableDataset.vbat.value * 0.1; - sif::info << "PDU2 VBAT: " << vbat << std::endl; - float temperatureC = pdu2HkTableDataset.temperature.value * 0.1; - sif::info << "PDU2 Temperature: " << temperatureC << " °C" << std::endl; - printOutputSwitchStates(); - sif::info << "PDU2 uptime: " << pdu2HkTableDataset.uptime << " seconds" << std::endl; - sif::info << "PDU2 battery mode: " << unsigned(pdu2HkTableDataset.battMode.value) << std::endl; - sif::info << "PDU2 ground watchdog reboots: " << pdu2HkTableDataset.gndWdtReboots << std::endl; - sif::info << "PDU2 ground watchdog timer seconds left: " + pdu2HkTableDataset.read(); + sif::info << "PDU2 Q7S current voltage: " << pdu2HkTableDataset.voltageOutQ7S << " mV" + << std::endl; + sif::info << "PDU2 VCC: " << pdu2HkTableDataset.vcc << " mV" << std::endl; + float vbat = pdu2HkTableDataset.vbat.value * 0.1; + sif::info << "PDU2 VBAT: " << vbat << std::endl; + float temperatureC = pdu2HkTableDataset.temperature.value * 0.1; + sif::info << "PDU2 Temperature: " << temperatureC << " °C" << std::endl; + printOutputSwitchStates(); + sif::info << "PDU2 uptime: " << pdu2HkTableDataset.uptime << " seconds" << std::endl; + sif::info << "PDU2 battery mode: " << unsigned(pdu2HkTableDataset.battMode.value) << std::endl; + sif::info << "PDU2 ground watchdog reboots: " << pdu2HkTableDataset.gndWdtReboots << std::endl; + sif::info << "PDU2 ground watchdog timer seconds left: " << pdu2HkTableDataset.groundWatchdogSecondsLeft << " seconds" << std::endl; - sif::info << "PDU2 csp1 watchdog pings before reboot: " + sif::info << "PDU2 csp1 watchdog pings before reboot: " << unsigned(pdu2HkTableDataset.csp1WatchdogPingsLeft.value) << std::endl; - sif::info << "PDU2 csp2 watchdog pings before reboot: " + sif::info << "PDU2 csp2 watchdog pings before reboot: " << unsigned(pdu2HkTableDataset.csp2WatchdogPingsLeft.value) << std::endl; - pdu2HkTableDataset.commit(); + pdu2HkTableDataset.commit(); #endif } void PDU2Handler::parseHkTableReply(const uint8_t *packet) { - uint16_t dataOffset = 0; - pdu2HkTableDataset.read(); - /** - * Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table - * address. - */ - dataOffset += 12; - pdu2HkTableDataset.currentOutQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutPayloadPCDUCh1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutReactionWheels = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutTCSBoardHeaterIn = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutSUSRedundant = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutDeplMechanism = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutPayloadPCDUCh6 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutACSBoardSideB = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutPayloadCamera = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + uint16_t dataOffset = 0; + pdu2HkTableDataset.read(); + /** + * Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table + * address. + */ + dataOffset += 12; + pdu2HkTableDataset.currentOutQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutPayloadPCDUCh1 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutReactionWheels = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutTCSBoardHeaterIn = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutSUSRedundant = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutDeplMechanism = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutPayloadPCDUCh6 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutACSBoardSideB = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutPayloadCamera = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu2HkTableDataset.voltageOutQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutPayloadPCDUCh1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutReactionWheels = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutTCSBoardHeaterIn = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutSUSRedundant = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutDeplMechanism = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutPayloadPCDUCh6 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutACSBoardSideB = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutPayloadCamera = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + pdu2HkTableDataset.voltageOutQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutPayloadPCDUCh1 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutReactionWheels = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutTCSBoardHeaterIn = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutSUSRedundant = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutDeplMechanism = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutPayloadPCDUCh6 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutACSBoardSideB = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutPayloadCamera = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu2HkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.temperature = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + pdu2HkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.temperature = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu2HkTableDataset.converterEnable1 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.converterEnable2 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.converterEnable3 = *(packet + dataOffset); - dataOffset += 3; + pdu2HkTableDataset.converterEnable1 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.converterEnable2 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.converterEnable3 = *(packet + dataOffset); + dataOffset += 3; - pdu2HkTableDataset.outEnabledQ7S = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledPlPCDUCh1 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledReactionWheels = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledTCSBoardHeaterIn = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledSUSRedundant = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledDeplMechanism = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledPlPCDUCh6 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledAcsBoardSideB = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledPayloadCamera = *(packet + dataOffset); - dataOffset += 3; + pdu2HkTableDataset.outEnabledQ7S = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledPlPCDUCh1 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledReactionWheels = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledTCSBoardHeaterIn = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledSUSRedundant = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledDeplMechanism = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledPlPCDUCh6 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledAcsBoardSideB = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledPayloadCamera = *(packet + dataOffset); + dataOffset += 3; - pdu2HkTableDataset.bootcause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.bootcount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.resetcause = *(packet + dataOffset + 1) << 8 | *(packet + dataOffset); - dataOffset += 4; - pdu2HkTableDataset.battMode = *(packet + dataOffset); - /* +10 because here begins the second gomspace csp packet */ - dataOffset += 3 + 10; + pdu2HkTableDataset.bootcause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.bootcount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.resetcause = *(packet + dataOffset + 1) << 8 | *(packet + dataOffset); + dataOffset += 4; + pdu2HkTableDataset.battMode = *(packet + dataOffset); + /* +10 because here begins the second gomspace csp packet */ + dataOffset += 3 + 10; - pdu2HkTableDataset.latchupsQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsPayloadPcduCh1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsRw = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsTcsBoardHeaterIn = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsSusRedundant = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsDeplMenchanism = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsPayloadPcduCh6 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsAcsBoardSideB = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsPayloadCamera = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + pdu2HkTableDataset.latchupsQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsPayloadPcduCh1 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsRw = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsTcsBoardHeaterIn = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsSusRedundant = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsDeplMenchanism = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsPayloadPcduCh6 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsAcsBoardSideB = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsPayloadCamera = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu2HkTableDataset.device0 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device1 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device2 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device3 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device4 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device5 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device6 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device7 = *(packet + dataOffset); - dataOffset += 3; + pdu2HkTableDataset.device0 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device1 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device2 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device3 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device4 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device5 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device6 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device7 = *(packet + dataOffset); + dataOffset += 3; - pdu2HkTableDataset.device0Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device1Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device2Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device3Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device4Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device5Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device6Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device7Status = *(packet + dataOffset); - dataOffset += 3; + pdu2HkTableDataset.device0Status = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device1Status = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device2Status = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device3Status = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device4Status = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device5Status = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device6Status = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device7Status = *(packet + dataOffset); + dataOffset += 3; - pdu2HkTableDataset.gndWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.i2cWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.canWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.csp1WdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.csp2WdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.groundWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.i2cWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.canWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.csp1WatchdogPingsLeft = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.csp2WatchdogPingsLeft = *(packet + dataOffset); + pdu2HkTableDataset.gndWdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.i2cWdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.canWdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.csp1WdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.csp2WdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.groundWatchdogSecondsLeft = + *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.i2cWatchdogSecondsLeft = + *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.canWatchdogSecondsLeft = + *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.csp1WatchdogPingsLeft = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.csp2WatchdogPingsLeft = *(packet + dataOffset); - pdu2HkTableDataset.commit(); - pdu2HkTableDataset.setChanged(true); + pdu2HkTableDataset.commit(); + pdu2HkTableDataset.setChanged(true); } -ReturnValue_t PDU2Handler::initializeLocalDataPool( - localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { +ReturnValue_t PDU2Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_Q7S, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_RW, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_SUS_REDUNDANT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_Q7S, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_RW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_SUS_REDUNDANT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_Q7S, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_RW, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_Q7S, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_RW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CONV_EN_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CONV_EN_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CONV_EN_3, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CONV_EN_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CONV_EN_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CONV_EN_3, new PoolEntry( { 0 })); - - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_Q7S, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_RW, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_Q7S, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_RW, new PoolEntry({0})); #if BOARD_TE0720 == 1 - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry( { 1 })); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry({1})); #else - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry({0})); #endif - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_SUS_REDUNDANT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_DEPLOYMENT_MECHANISM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_ACS_BOARD_SIDE_B, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_CAMERA, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_SUS_REDUNDANT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_DEPLOYMENT_MECHANISM, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_ACS_BOARD_SIDE_B, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_CAMERA, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_BOOTCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_BOOTCNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_UPTIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_RESETCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_BATT_MODE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_BOOTCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_BOOTCNT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_RESETCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_BATT_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_Q7S, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_RW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_SUS_REDUNDANT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_DEPLOYMENT_MECHANISM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_ACS_BOARD_SIDE_B, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_CAMERA, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_Q7S, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_RW, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_SUS_REDUNDANT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_DEPLOYMENT_MECHANISM, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_ACS_BOARD_SIDE_B, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_CAMERA, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_5, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_7, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_0_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_1_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_2_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_3_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_4_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_5_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_6_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_7_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_0_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_1_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_2_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_3_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_4_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_5_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_6_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_7_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_GND, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_I2C, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CAN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_GND_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_I2C_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CAN_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_GND, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_I2C, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CAN, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_GND_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_I2C_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CAN_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT2, new PoolEntry({0})); - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t PDU2Handler::printStatus(DeviceCommandId_t cmd) { - switch(cmd) { - case(GOMSPACE::PRINT_SWITCH_V_I): { - PoolReadGuard pg(&pdu2HkTableDataset); - ReturnValue_t readResult = pg.getReadResult(); - if(readResult != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Reading PDU1 HK table failed!" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - printHkTable(); - return HasReturnvaluesIF::RETURN_OK; + switch (cmd) { + case (GOMSPACE::PRINT_SWITCH_V_I): { + PoolReadGuard pg(&pdu2HkTableDataset); + ReturnValue_t readResult = pg.getReadResult(); + if (readResult != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Reading PDU1 HK table failed!" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + printHkTable(); + return HasReturnvaluesIF::RETURN_OK; } default: { - return HasReturnvaluesIF::RETURN_FAILED; - } + return HasReturnvaluesIF::RETURN_FAILED; } + } } void PDU2Handler::printHkTable() { - sif::info << "PDU2 Info: SwitchState, Currents [mA], Voltages [mV]" << std::endl; - sif::info << std::setw(30) << std::left << "Q7S" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledQ7S.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutQ7S.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutQ7S.value << std::endl; - sif::info << std::setw(30) << std::left << "Payload PCDU Channel 1" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledPlPCDUCh1.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutPayloadPCDUCh1.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutPayloadPCDUCh1.value << std::endl; - sif::info << std::setw(30) << std::left << "Reaction Wheels" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledReactionWheels.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutReactionWheels.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutReactionWheels.value << std::endl; - sif::info << std::setw(30) << std::left << "TCS Board 8V heater input" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledTCSBoardHeaterIn.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutTCSBoardHeaterIn.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutTCSBoardHeaterIn.value << std::endl; - sif::info << std::setw(30) << std::left << "Redundant SUS group" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledSUSRedundant.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutSUSRedundant.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutSUSRedundant.value << std::endl; - sif::info << std::setw(30) << std::left << "Deployment mechanism" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledDeplMechanism.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutDeplMechanism.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutDeplMechanism.value << std::endl; - sif::info << std::setw(30) << std::left << "Payload PCDU Channel 6" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledPlPCDUCh6.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutPayloadPCDUCh6.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutPayloadPCDUCh6.value<< std::endl; - sif::info << std::setw(30) << std::left << "ACS Board Side B" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledAcsBoardSideB.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutACSBoardSideB.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutACSBoardSideB.value << std::endl; - sif::info << std::setw(30) << std::left << "Payload Camera enable state" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledPayloadCamera.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutPayloadCamera.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutPayloadCamera.value << std::right << std::endl; + sif::info << "PDU2 Info: SwitchState, Currents [mA], Voltages [mV]" << std::endl; + sif::info << std::setw(30) << std::left << "Q7S" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledQ7S.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutQ7S.value << ", " << std::setw(4) + << pdu2HkTableDataset.voltageOutQ7S.value << std::endl; + sif::info << std::setw(30) << std::left << "Payload PCDU Channel 1" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledPlPCDUCh1.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutPayloadPCDUCh1.value << ", " + << std::setw(4) << pdu2HkTableDataset.voltageOutPayloadPCDUCh1.value << std::endl; + sif::info << std::setw(30) << std::left << "Reaction Wheels" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledReactionWheels.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutReactionWheels.value << ", " + << std::setw(4) << pdu2HkTableDataset.voltageOutReactionWheels.value << std::endl; + sif::info << std::setw(30) << std::left << "TCS Board 8V heater input" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledTCSBoardHeaterIn.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutTCSBoardHeaterIn.value << ", " + << std::setw(4) << pdu2HkTableDataset.voltageOutTCSBoardHeaterIn.value << std::endl; + sif::info << std::setw(30) << std::left << "Redundant SUS group" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledSUSRedundant.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutSUSRedundant.value << ", " << std::setw(4) + << pdu2HkTableDataset.voltageOutSUSRedundant.value << std::endl; + sif::info << std::setw(30) << std::left << "Deployment mechanism" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledDeplMechanism.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutDeplMechanism.value << ", " + << std::setw(4) << pdu2HkTableDataset.voltageOutDeplMechanism.value << std::endl; + sif::info << std::setw(30) << std::left << "Payload PCDU Channel 6" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledPlPCDUCh6.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutPayloadPCDUCh6.value << ", " + << std::setw(4) << pdu2HkTableDataset.voltageOutPayloadPCDUCh6.value << std::endl; + sif::info << std::setw(30) << std::left << "ACS Board Side B" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledAcsBoardSideB.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutACSBoardSideB.value << ", " + << std::setw(4) << pdu2HkTableDataset.voltageOutACSBoardSideB.value << std::endl; + sif::info << std::setw(30) << std::left << "Payload Camera enable state" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledPayloadCamera.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutPayloadCamera.value << ", " + << std::setw(4) << pdu2HkTableDataset.voltageOutPayloadCamera.value << std::right + << std::endl; } diff --git a/mission/devices/PDU2Handler.h b/mission/devices/PDU2Handler.h index c44d1267..258b616d 100644 --- a/mission/devices/PDU2Handler.h +++ b/mission/devices/PDU2Handler.h @@ -1,9 +1,10 @@ #ifndef MISSION_DEVICES_PDU2HANDLER_H_ #define MISSION_DEVICES_PDU2HANDLER_H_ -#include "GomspaceDeviceHandler.h" #include +#include "GomspaceDeviceHandler.h" + /** * @brief This is the device handler for the PDU2. * @@ -18,30 +19,29 @@ * ACS Board (Gyro, MGMs, GPS), 3.3V channel 7 * Payload Camera, 8V, channel 8 */ -class PDU2Handler: public GomspaceDeviceHandler { -public: - PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); - virtual ~PDU2Handler(); +class PDU2Handler : public GomspaceDeviceHandler { + public: + PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + virtual ~PDU2Handler(); - virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; + virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; -protected: - /** - * @brief As soon as the device is in MODE_NORMAL, this function is executed periodically. - */ - 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; + protected: + /** + * @brief As soon as the device is in MODE_NORMAL, this function is executed periodically. + */ + 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; -private: + private: + /** Dataset for the housekeeping table of the PDU2 */ + PDU2::PDU2HkTableDataset pdu2HkTableDataset; - /** Dataset for the housekeeping table of the PDU2 */ - PDU2::PDU2HkTableDataset pdu2HkTableDataset; + void printHkTable(); - void printHkTable(); - - void parseHkTableReply(const uint8_t *packet); + void parseHkTableReply(const uint8_t* packet); }; #endif /* MISSION_DEVICES_PDU2HANDLER_H_ */ diff --git a/mission/devices/PlocMPSoCHandler.cpp b/mission/devices/PlocMPSoCHandler.cpp index dcc81ef7..07b9b0fa 100644 --- a/mission/devices/PlocMPSoCHandler.cpp +++ b/mission/devices/PlocMPSoCHandler.cpp @@ -1,497 +1,473 @@ #include "PlocMPSoCHandler.h" + +#include +#include + #include "OBSWConfig.h" -#include -#include +PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie) + : DeviceHandlerBase(objectId, comIF, comCookie) { + if (comCookie == NULL) { + sif::error << "PlocMPSoCHandler: Invalid com cookie" << std::endl; + } +} -PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - DeviceHandlerBase(objectId, comIF, comCookie) { - if (comCookie == NULL) { - sif::error << "PlocMPSoCHandler: Invalid com cookie" << std::endl; +PlocMPSoCHandler::~PlocMPSoCHandler() {} + +void PlocMPSoCHandler::doStartUp() { + if (mode == _MODE_START_UP) { + setMode(MODE_ON); + } +} + +void PlocMPSoCHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } + +ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + return RETURN_OK; +} + +ReturnValue_t PlocMPSoCHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t* commandData, + size_t commandDataLen) { + switch (deviceCommand) { + case (PLOC_MPSOC::TC_MEM_WRITE): { + return prepareTcMemWriteCommand(commandData, commandDataLen); } -} - -PlocMPSoCHandler::~PlocMPSoCHandler() { -} - - -void PlocMPSoCHandler::doStartUp(){ - if(mode == _MODE_START_UP){ - setMode(MODE_ON); - } -} - -void PlocMPSoCHandler::doShutDown(){ - setMode(_MODE_POWER_DOWN); -} - -ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - return RETURN_OK; -} - -ReturnValue_t PlocMPSoCHandler::buildTransitionDeviceCommand( - DeviceCommandId_t * id){ - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t * commandData, - size_t commandDataLen) { - switch(deviceCommand) { - case(PLOC_MPSOC::TC_MEM_WRITE): { - return prepareTcMemWriteCommand(commandData, commandDataLen); - } - case(PLOC_MPSOC::TC_MEM_READ): { - return prepareTcMemReadCommand(commandData, commandDataLen); - } - default: - sif::debug << "PlocMPSoCHandler::buildCommandFromCommand: Command not implemented" << std::endl; - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; + case (PLOC_MPSOC::TC_MEM_READ): { + return prepareTcMemReadCommand(commandData, commandDataLen); + } + default: + sif::debug << "PlocMPSoCHandler::buildCommandFromCommand: Command not implemented" + << std::endl; + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } void PlocMPSoCHandler::fillCommandAndReplyMap() { - this->insertInCommandMap(PLOC_MPSOC::TC_MEM_WRITE); - this->insertInCommandMap(PLOC_MPSOC::TC_MEM_READ); - this->insertInReplyMap(PLOC_MPSOC::ACK_REPORT, 1, nullptr, PLOC_MPSOC::SIZE_ACK_REPORT); - this->insertInReplyMap(PLOC_MPSOC::EXE_REPORT, 3, nullptr, PLOC_MPSOC::SIZE_EXE_REPORT); - this->insertInReplyMap(PLOC_MPSOC::TM_MEMORY_READ_REPORT, 2, nullptr, PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT); + this->insertInCommandMap(PLOC_MPSOC::TC_MEM_WRITE); + this->insertInCommandMap(PLOC_MPSOC::TC_MEM_READ); + this->insertInReplyMap(PLOC_MPSOC::ACK_REPORT, 1, nullptr, PLOC_MPSOC::SIZE_ACK_REPORT); + this->insertInReplyMap(PLOC_MPSOC::EXE_REPORT, 3, nullptr, PLOC_MPSOC::SIZE_EXE_REPORT); + this->insertInReplyMap(PLOC_MPSOC::TM_MEMORY_READ_REPORT, 2, nullptr, + PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT); } -ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { +ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + uint16_t apid = (*(start) << 8 | *(start + 1)) & APID_MASK; - uint16_t apid = (*(start) << 8 | *(start + 1)) & APID_MASK; + switch (apid) { + case (PLOC_MPSOC::APID_ACK_SUCCESS): + *foundLen = PLOC_MPSOC::SIZE_ACK_REPORT; + *foundId = PLOC_MPSOC::ACK_REPORT; + break; + case (PLOC_MPSOC::APID_ACK_FAILURE): + *foundLen = PLOC_MPSOC::SIZE_ACK_REPORT; + *foundId = PLOC_MPSOC::ACK_REPORT; + break; + case (PLOC_MPSOC::APID_TM_MEMORY_READ_REPORT): + *foundLen = PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT; + *foundId = PLOC_MPSOC::TM_MEMORY_READ_REPORT; + break; + case (PLOC_MPSOC::APID_EXE_SUCCESS): + *foundLen = PLOC_MPSOC::SIZE_EXE_REPORT; + *foundId = PLOC_MPSOC::EXE_REPORT; + break; + case (PLOC_MPSOC::APID_EXE_FAILURE): + *foundLen = PLOC_MPSOC::SIZE_EXE_REPORT; + *foundId = PLOC_MPSOC::EXE_REPORT; + break; + default: { + sif::debug << "PlocMPSoCHandler::scanForReply: Reply has invalid apid" << std::endl; + *foundLen = remainingSize; + return INVALID_APID; + } + } - switch(apid) { - case(PLOC_MPSOC::APID_ACK_SUCCESS): - *foundLen = PLOC_MPSOC::SIZE_ACK_REPORT; - *foundId = PLOC_MPSOC::ACK_REPORT; - break; - case(PLOC_MPSOC::APID_ACK_FAILURE): - *foundLen = PLOC_MPSOC::SIZE_ACK_REPORT; - *foundId = PLOC_MPSOC::ACK_REPORT; - break; - case(PLOC_MPSOC::APID_TM_MEMORY_READ_REPORT): - *foundLen = PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT; - *foundId = PLOC_MPSOC::TM_MEMORY_READ_REPORT; - break; - case(PLOC_MPSOC::APID_EXE_SUCCESS): - *foundLen = PLOC_MPSOC::SIZE_EXE_REPORT; - *foundId = PLOC_MPSOC::EXE_REPORT; - break; - case(PLOC_MPSOC::APID_EXE_FAILURE): - *foundLen = PLOC_MPSOC::SIZE_EXE_REPORT; - *foundId = PLOC_MPSOC::EXE_REPORT; - break; - default: { - sif::debug << "PlocMPSoCHandler::scanForReply: Reply has invalid apid" << std::endl; - *foundLen = remainingSize; - return INVALID_APID; - } - } + /** + * This should normally never fail. However, this function is also responsible for incrementing + * the packet sequence count why it is called here. + */ + result = checkPacketSequenceCount(start); - /** - * This should normally never fail. However, this function is also responsible for incrementing - * the packet sequence count why it is called here. - */ - result = checkPacketSequenceCount(start); - - return result; + return result; } -ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { +ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; - - switch (id) { + switch (id) { case PLOC_MPSOC::ACK_REPORT: { - result = handleAckReport(packet); - break; + result = handleAckReport(packet); + break; } case (PLOC_MPSOC::TM_MEMORY_READ_REPORT): { - result = handleMemoryReadReport(packet); - break; + result = handleMemoryReadReport(packet); + break; } case (PLOC_MPSOC::EXE_REPORT): { - result = handleExecutionReport(packet); - break; + result = handleExecutionReport(packet); + break; } default: { - sif::debug << "PlocMPSoCHandler::interpretDeviceReply: Unknown device reply id" << std::endl; - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } + sif::debug << "PlocMPSoCHandler::interpretDeviceReply: Unknown device reply id" << std::endl; + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; } + } - return result; + return result; } -void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid(){ +void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid() {} -} - -uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){ - return 500; -} +uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } ReturnValue_t PlocMPSoCHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { - - return HasReturnvaluesIF::RETURN_OK; + LocalDataPoolManager& poolManager) { + return HasReturnvaluesIF::RETURN_OK; } -void PlocMPSoCHandler::setModeNormal() { - mode = MODE_NORMAL; +void PlocMPSoCHandler::setModeNormal() { mode = MODE_NORMAL; } + +ReturnValue_t PlocMPSoCHandler::prepareTcMemWriteCommand(const uint8_t* commandData, + size_t commandDataLen) { + const uint32_t memoryAddress = *(commandData) << 24 | *(commandData + 1) << 16 | + *(commandData + 2) << 8 | *(commandData + 3); + const uint32_t memoryData = *(commandData + 4) << 24 | *(commandData + 5) << 16 | + *(commandData + 6) << 8 | *(commandData + 7); + packetSequenceCount = (packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK; + PLOC_MPSOC::TcMemWrite tcMemWrite(memoryAddress, memoryData, packetSequenceCount); + if (tcMemWrite.getFullSize() > PLOC_MPSOC::MAX_COMMAND_SIZE) { + sif::debug << "PlocMPSoCHandler::prepareTcMemWriteCommand: Command too big" << std::endl; + return RETURN_FAILED; + } + memcpy(commandBuffer, tcMemWrite.getWholeData(), tcMemWrite.getFullSize()); + rawPacket = commandBuffer; + rawPacketLen = tcMemWrite.getFullSize(); + nextReplyId = PLOC_MPSOC::ACK_REPORT; + return RETURN_OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcMemWriteCommand(const uint8_t * commandData, - size_t commandDataLen) { - const uint32_t memoryAddress = *(commandData) << 24 | *(commandData + 1) << 16 - | *(commandData + 2) << 8 | *(commandData + 3); - const uint32_t memoryData = *(commandData + 4) << 24 | *(commandData + 5) << 16 - | *(commandData + 6) << 8 | *(commandData + 7); - packetSequenceCount = (packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK; - PLOC_MPSOC::TcMemWrite tcMemWrite(memoryAddress, memoryData, packetSequenceCount); - if (tcMemWrite.getFullSize() > PLOC_MPSOC::MAX_COMMAND_SIZE) { - sif::debug << "PlocMPSoCHandler::prepareTcMemWriteCommand: Command too big" << std::endl; - return RETURN_FAILED; - } - memcpy(commandBuffer, tcMemWrite.getWholeData(), tcMemWrite.getFullSize()); - rawPacket = commandBuffer; - rawPacketLen = tcMemWrite.getFullSize(); - nextReplyId = PLOC_MPSOC::ACK_REPORT; - return RETURN_OK; -} +ReturnValue_t PlocMPSoCHandler::prepareTcMemReadCommand(const uint8_t* commandData, + size_t commandDataLen) { + const uint32_t memoryAddress = *(commandData) << 24 | *(commandData + 1) << 16 | + *(commandData + 2) << 8 | *(commandData + 3); + packetSequenceCount = (packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK; + PLOC_MPSOC::TcMemRead tcMemRead(memoryAddress, packetSequenceCount); + if (tcMemRead.getFullSize() > PLOC_MPSOC::MAX_COMMAND_SIZE) { + sif::debug << "PlocMPSoCHandler::prepareTcMemReadCommand: Command too big" << std::endl; + return RETURN_FAILED; + } + memcpy(commandBuffer, tcMemRead.getWholeData(), tcMemRead.getFullSize()); + rawPacket = commandBuffer; + rawPacketLen = tcMemRead.getFullSize(); + nextReplyId = PLOC_MPSOC::ACK_REPORT; -ReturnValue_t PlocMPSoCHandler::prepareTcMemReadCommand(const uint8_t * commandData, - size_t commandDataLen) { - const uint32_t memoryAddress = *(commandData) << 24 | *(commandData + 1) << 16 - | *(commandData + 2) << 8 | *(commandData + 3); - packetSequenceCount = (packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK; - PLOC_MPSOC::TcMemRead tcMemRead(memoryAddress, packetSequenceCount); - if (tcMemRead.getFullSize() > PLOC_MPSOC::MAX_COMMAND_SIZE) { - sif::debug << "PlocMPSoCHandler::prepareTcMemReadCommand: Command too big" << std::endl; - return RETURN_FAILED; - } - memcpy(commandBuffer, tcMemRead.getWholeData(), tcMemRead.getFullSize()); - rawPacket = commandBuffer; - rawPacketLen = tcMemRead.getFullSize(); - nextReplyId = PLOC_MPSOC::ACK_REPORT; - - return RETURN_OK; + return RETURN_OK; } ReturnValue_t PlocMPSoCHandler::verifyPacket(const uint8_t* start, size_t foundLen) { + uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1); - uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1); + uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2); - uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2); + if (receivedCrc != recalculatedCrc) { + return CRC_FAILURE; + } - if (receivedCrc != recalculatedCrc) { - return CRC_FAILURE; - } - - return RETURN_OK; + return RETURN_OK; } ReturnValue_t PlocMPSoCHandler::handleAckReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_MPSOC::SIZE_ACK_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocMPSoCHandler::handleAckReport: CRC failure" << std::endl; + nextReplyId = PLOC_MPSOC::NONE; + replyRawReplyIfnotWiretapped(data, PLOC_MPSOC::SIZE_ACK_REPORT); + triggerEvent(CRC_FAILURE_EVENT); + sendFailureReport(PLOC_MPSOC::ACK_REPORT, CRC_FAILURE); + disableAllReplies(); + return IGNORE_REPLY_DATA; + } - result = verifyPacket(data, PLOC_MPSOC::SIZE_ACK_REPORT); - if(result == CRC_FAILURE) { - sif::error << "PlocMPSoCHandler::handleAckReport: CRC failure" << std::endl; - nextReplyId = PLOC_MPSOC::NONE; - replyRawReplyIfnotWiretapped(data, PLOC_MPSOC::SIZE_ACK_REPORT); - triggerEvent(CRC_FAILURE_EVENT); - sendFailureReport(PLOC_MPSOC::ACK_REPORT, CRC_FAILURE); - disableAllReplies(); - return IGNORE_REPLY_DATA; + uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; + + switch (apid) { + case PLOC_MPSOC::APID_ACK_FAILURE: { + // TODO: Interpretation of status field in acknowledgment report + sif::debug << "PlocMPSoCHandler::handleAckReport: Received Ack failure report" << std::endl; + DeviceCommandId_t commandId = getPendingCommand(); + if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { + triggerEvent(ACK_FAILURE, commandId); + } + sendFailureReport(PLOC_MPSOC::ACK_REPORT, RECEIVED_ACK_FAILURE); + disableAllReplies(); + nextReplyId = PLOC_MPSOC::NONE; + result = IGNORE_REPLY_DATA; + break; } + case PLOC_MPSOC::APID_ACK_SUCCESS: { + setNextReplyId(); + break; + } + default: { + sif::debug << "PlocMPSoCHandler::handleAckReport: Invalid APID in Ack report" << std::endl; + result = RETURN_FAILED; + break; + } + } - uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; - - switch(apid) { - case PLOC_MPSOC::APID_ACK_FAILURE: { - //TODO: Interpretation of status field in acknowledgment report - sif::debug << "PlocMPSoCHandler::handleAckReport: Received Ack failure report" << std::endl; - DeviceCommandId_t commandId = getPendingCommand(); - if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { - triggerEvent(ACK_FAILURE, commandId); - } - sendFailureReport(PLOC_MPSOC::ACK_REPORT, RECEIVED_ACK_FAILURE); - disableAllReplies(); - nextReplyId = PLOC_MPSOC::NONE; - result = IGNORE_REPLY_DATA; - break; - } - case PLOC_MPSOC::APID_ACK_SUCCESS: { - setNextReplyId(); - break; - } - default: { - sif::debug << "PlocMPSoCHandler::handleAckReport: Invalid APID in Ack report" << std::endl; - result = RETURN_FAILED; - break; - } - } - - return result; + return result; } ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_MPSOC::SIZE_EXE_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocMPSoCHandler::handleExecutionReport: CRC failure" << std::endl; + nextReplyId = PLOC_MPSOC::NONE; + return result; + } - result = verifyPacket(data, PLOC_MPSOC::SIZE_EXE_REPORT); - if(result == CRC_FAILURE) { - sif::error << "PlocMPSoCHandler::handleExecutionReport: CRC failure" << std::endl; - nextReplyId = PLOC_MPSOC::NONE; - return result; - } + uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; - uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; - - switch (apid) { + switch (apid) { case (PLOC_MPSOC::APID_EXE_SUCCESS): { - break; + break; } case (PLOC_MPSOC::APID_EXE_FAILURE): { - //TODO: Interpretation of status field in execution report - sif::error << "PlocMPSoCHandler::handleExecutionReport: Received execution failure report" - << std::endl; - DeviceCommandId_t commandId = getPendingCommand(); - if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { - triggerEvent(EXE_FAILURE, commandId); - } - else { - sif::debug << "PlocMPSoCHandler::handleExecutionReport: Unknown command id" << std::endl; - } - sendFailureReport(PLOC_MPSOC::EXE_REPORT, RECEIVED_EXE_FAILURE); - disableExeReportReply(); - result = IGNORE_REPLY_DATA; - break; + // TODO: Interpretation of status field in execution report + sif::error << "PlocMPSoCHandler::handleExecutionReport: Received execution failure report" + << std::endl; + DeviceCommandId_t commandId = getPendingCommand(); + if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { + triggerEvent(EXE_FAILURE, commandId); + } else { + sif::debug << "PlocMPSoCHandler::handleExecutionReport: Unknown command id" << std::endl; + } + sendFailureReport(PLOC_MPSOC::EXE_REPORT, RECEIVED_EXE_FAILURE); + disableExeReportReply(); + result = IGNORE_REPLY_DATA; + break; } default: { - sif::error << "PlocMPSoCHandler::handleExecutionReport: Unknown APID" << std::endl; - result = RETURN_FAILED; - break; - } + sif::error << "PlocMPSoCHandler::handleExecutionReport: Unknown APID" << std::endl; + result = RETURN_FAILED; + break; } + } - nextReplyId = PLOC_MPSOC::NONE; + nextReplyId = PLOC_MPSOC::NONE; - return result; + return result; } ReturnValue_t PlocMPSoCHandler::handleMemoryReadReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT); - result = verifyPacket(data, PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocMPSoCHandler::handleMemoryReadReport: Memory read report has invalid crc" + << std::endl; + } + /** Send data to commanding queue */ + handleDeviceTM(data + PLOC_MPSOC::DATA_FIELD_OFFSET, PLOC_MPSOC::SIZE_MEM_READ_REPORT_DATA, + PLOC_MPSOC::TM_MEMORY_READ_REPORT); - if(result == CRC_FAILURE) { - sif::error << "PlocMPSoCHandler::handleMemoryReadReport: Memory read report has invalid crc" - << std::endl; - } - /** Send data to commanding queue */ - handleDeviceTM(data + PLOC_MPSOC::DATA_FIELD_OFFSET, PLOC_MPSOC::SIZE_MEM_READ_REPORT_DATA, - PLOC_MPSOC::TM_MEMORY_READ_REPORT); + nextReplyId = PLOC_MPSOC::EXE_REPORT; - nextReplyId = PLOC_MPSOC::EXE_REPORT; - - return result; + return result; } ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command, - uint8_t expectedReplies, bool useAlternateId, - DeviceCommandId_t alternateReplyID) { + uint8_t expectedReplies, bool useAlternateId, + DeviceCommandId_t alternateReplyID) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + uint8_t enabledReplies = 0; - uint8_t enabledReplies = 0; - - switch (command->first) { + switch (command->first) { case PLOC_MPSOC::TC_MEM_WRITE: - enabledReplies = 2; - break; + enabledReplies = 2; + break; case PLOC_MPSOC::TC_MEM_READ: { - enabledReplies = 3; - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_MPSOC::TM_MEMORY_READ_REPORT); - if (result != RETURN_OK) { - sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " - << PLOC_MPSOC::TM_MEMORY_READ_REPORT << " not in replyMap" << std::endl; - } - break; + enabledReplies = 3; + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_MPSOC::TM_MEMORY_READ_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " + << PLOC_MPSOC::TM_MEMORY_READ_REPORT << " not in replyMap" << std::endl; + } + break; } default: - sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Unknown command id" << std::endl; - break; - } + sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Unknown command id" << std::endl; + break; + } - /** - * Every command causes at least one acknowledgment and one execution report. Therefore both - * replies will be enabled here. - */ - result = DeviceHandlerBase::enableReplyInReplyMap(command, - enabledReplies, true, PLOC_MPSOC::ACK_REPORT); - if (result != RETURN_OK) { - sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " << PLOC_MPSOC::ACK_REPORT - << " not in replyMap" << std::endl; - } + /** + * Every command causes at least one acknowledgment and one execution report. Therefore both + * replies will be enabled here. + */ + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_MPSOC::ACK_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " + << PLOC_MPSOC::ACK_REPORT << " not in replyMap" << std::endl; + } - result = DeviceHandlerBase::enableReplyInReplyMap(command, - enabledReplies, true, PLOC_MPSOC::EXE_REPORT); - if (result != RETURN_OK) { - sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " << PLOC_MPSOC::EXE_REPORT - << " not in replyMap" << std::endl; - } + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_MPSOC::EXE_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " + << PLOC_MPSOC::EXE_REPORT << " not in replyMap" << std::endl; + } - return RETURN_OK; + return RETURN_OK; } void PlocMPSoCHandler::setNextReplyId() { - switch(getPendingCommand()) { + switch (getPendingCommand()) { case PLOC_MPSOC::TC_MEM_READ: - nextReplyId = PLOC_MPSOC::TM_MEMORY_READ_REPORT; - break; + nextReplyId = PLOC_MPSOC::TM_MEMORY_READ_REPORT; + break; default: - /* If no telemetry is expected the next reply is always the execution report */ - nextReplyId = PLOC_MPSOC::EXE_REPORT; - break; - } + /* If no telemetry is expected the next reply is always the execution report */ + nextReplyId = PLOC_MPSOC::EXE_REPORT; + break; + } } -size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId){ - - size_t replyLen = 0; - - if (nextReplyId == PLOC_MPSOC::NONE) { - return replyLen; - } - - DeviceReplyIter iter = deviceReplyMap.find(nextReplyId); - if (iter != deviceReplyMap.end()) { - if (iter->second.delayCycles == 0) { - /* Reply inactive */ - return replyLen; - } - replyLen = iter->second.replyLen; - } - else { - sif::debug << "PlocMPSoCHandler::getNextReplyLength: No entry for reply with reply id " - << std::hex << nextReplyId << " in deviceReplyMap" << std::endl; - } +size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) { + size_t replyLen = 0; + if (nextReplyId == PLOC_MPSOC::NONE) { return replyLen; + } + + DeviceReplyIter iter = deviceReplyMap.find(nextReplyId); + if (iter != deviceReplyMap.end()) { + if (iter->second.delayCycles == 0) { + /* Reply inactive */ + return replyLen; + } + replyLen = iter->second.replyLen; + } else { + sif::debug << "PlocMPSoCHandler::getNextReplyLength: No entry for reply with reply id " + << std::hex << nextReplyId << " in deviceReplyMap" << std::endl; + } + + return replyLen; } -void PlocMPSoCHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId) { +void PlocMPSoCHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, + DeviceCommandId_t replyId) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + if (wiretappingMode == RAW) { + /* Data already sent in doGetRead() */ + return; + } - if (wiretappingMode == RAW) { - /* Data already sent in doGetRead() */ - return; - } + DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId); + if (iter == deviceReplyMap.end()) { + sif::debug << "PlocMPSoCHandler::handleDeviceTM: Unknown reply id" << std::endl; + return; + } + MessageQueueId_t queueId = iter->second.command->second.sendReplyTo; - DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId); - if (iter == deviceReplyMap.end()) { - sif::debug << "PlocMPSoCHandler::handleDeviceTM: Unknown reply id" << std::endl; - return; - } - MessageQueueId_t queueId = iter->second.command->second.sendReplyTo; + if (queueId == NO_COMMANDER) { + return; + } - if (queueId == NO_COMMANDER) { - return; - } - - result = actionHelper.reportData(queueId, replyId, data, dataSize); - if (result != RETURN_OK) { - sif::debug << "PlocMPSoCHandler::handleDeviceTM: Failed to report data" << std::endl; - } + result = actionHelper.reportData(queueId, replyId, data, dataSize); + if (result != RETURN_OK) { + sif::debug << "PlocMPSoCHandler::handleDeviceTM: Failed to report data" << std::endl; + } } void PlocMPSoCHandler::disableAllReplies() { + DeviceReplyMap::iterator iter; - DeviceReplyMap::iterator iter; + /* Disable ack reply */ + iter = deviceReplyMap.find(PLOC_MPSOC::ACK_REPORT); + DeviceReplyInfo* info = &(iter->second); + info->delayCycles = 0; + info->command = deviceCommandMap.end(); - /* Disable ack reply */ - iter = deviceReplyMap.find(PLOC_MPSOC::ACK_REPORT); - DeviceReplyInfo *info = &(iter->second); - info->delayCycles = 0; - info->command = deviceCommandMap.end(); + DeviceCommandId_t commandId = getPendingCommand(); - DeviceCommandId_t commandId = getPendingCommand(); - - /* If the command expects a telemetry packet the appropriate tm reply will be disabled here */ - switch (commandId) { + /* If the command expects a telemetry packet the appropriate tm reply will be disabled here */ + switch (commandId) { case PLOC_MPSOC::TC_MEM_WRITE: - break; + break; case PLOC_MPSOC::TC_MEM_READ: { - iter = deviceReplyMap.find(PLOC_MPSOC::TM_MEMORY_READ_REPORT); - info = &(iter->second); - info->delayCycles = 0; - info->command = deviceCommandMap.end(); - break; + iter = deviceReplyMap.find(PLOC_MPSOC::TM_MEMORY_READ_REPORT); + info = &(iter->second); + info->delayCycles = 0; + info->command = deviceCommandMap.end(); + break; } default: { - sif::debug << "PlocMPSoCHandler::disableAllReplies: Unknown command id" << commandId - << std::endl; - break; - } + sif::debug << "PlocMPSoCHandler::disableAllReplies: Unknown command id" << commandId + << std::endl; + break; } + } - /* We must always disable the execution report reply here */ - disableExeReportReply(); + /* We must always disable the execution report reply here */ + disableExeReportReply(); } void PlocMPSoCHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status) { + DeviceReplyIter iter = deviceReplyMap.find(replyId); - DeviceReplyIter iter = deviceReplyMap.find(replyId); + if (iter == deviceReplyMap.end()) { + sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply not in reply map" << std::endl; + return; + } - if (iter == deviceReplyMap.end()) { - sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply not in reply map" << std::endl; - return; - } + DeviceCommandInfo* info = &(iter->second.command->second); - DeviceCommandInfo* info = &(iter->second.command->second); + if (info == nullptr) { + sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply has no active command" << std::endl; + return; + } - if (info == nullptr) { - sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply has no active command" << std::endl; - return; - } - - if (info->sendReplyTo != NO_COMMANDER) { - actionHelper.finish(false, info->sendReplyTo, iter->first, status); - } - info->isExecuting = false; + if (info->sendReplyTo != NO_COMMANDER) { + actionHelper.finish(false, info->sendReplyTo, iter->first, status); + } + info->isExecuting = false; } void PlocMPSoCHandler::disableExeReportReply() { - DeviceReplyIter iter = deviceReplyMap.find(PLOC_MPSOC::EXE_REPORT); - DeviceReplyInfo *info = &(iter->second); - info->delayCycles = 0; - info->command = deviceCommandMap.end(); - /* Expected replies is set to one here. The value will set to 0 in replyToReply() */ - info->command->second.expectedReplies = 0; + DeviceReplyIter iter = deviceReplyMap.find(PLOC_MPSOC::EXE_REPORT); + DeviceReplyInfo* info = &(iter->second); + info->delayCycles = 0; + info->command = deviceCommandMap.end(); + /* Expected replies is set to one here. The value will set to 0 in replyToReply() */ + info->command->second.expectedReplies = 0; } ReturnValue_t PlocMPSoCHandler::checkPacketSequenceCount(const uint8_t* data) { - uint16_t receivedSequenceCount = (*(data + 2) << 8 | *(data + 3)) & PACKET_SEQUENCE_COUNT_MASK; - uint16_t expectedPacketSequenceCount = ((packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK); - if (receivedSequenceCount != expectedPacketSequenceCount) { - sif::debug - << "PlocMPSoCHandler::checkPacketSequenceCount: Packet sequence count mismatch. " - << std::endl; - sif::debug << "Received sequence count: " << receivedSequenceCount << ". OBSW sequence " - << "count: " << expectedPacketSequenceCount << std::endl; - } - packetSequenceCount = receivedSequenceCount; - return RETURN_OK; + uint16_t receivedSequenceCount = (*(data + 2) << 8 | *(data + 3)) & PACKET_SEQUENCE_COUNT_MASK; + uint16_t expectedPacketSequenceCount = ((packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK); + if (receivedSequenceCount != expectedPacketSequenceCount) { + sif::debug << "PlocMPSoCHandler::checkPacketSequenceCount: Packet sequence count mismatch. " + << std::endl; + sif::debug << "Received sequence count: " << receivedSequenceCount << ". OBSW sequence " + << "count: " << expectedPacketSequenceCount << std::endl; + } + packetSequenceCount = receivedSequenceCount; + return RETURN_OK; } diff --git a/mission/devices/PlocMPSoCHandler.h b/mission/devices/PlocMPSoCHandler.h index 2b3f6a57..2b14424f 100644 --- a/mission/devices/PlocMPSoCHandler.h +++ b/mission/devices/PlocMPSoCHandler.h @@ -3,6 +3,7 @@ #include #include + #include /** @@ -18,189 +19,194 @@ * Arbeitsdaten/08_Used%20Components/PLOC&fileid=940960 * @author J. Meier */ -class PlocMPSoCHandler: public DeviceHandlerBase { -public: +class PlocMPSoCHandler : public DeviceHandlerBase { + public: + PlocMPSoCHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + virtual ~PlocMPSoCHandler(); - PlocMPSoCHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); - virtual ~PlocMPSoCHandler(); + /** + * @brief Sets mode to MODE_NORMAL. Can be used for debugging. + */ + void setModeNormal(); - /** - * @brief Sets mode to MODE_NORMAL. Can be used for debugging. - */ - void setModeNormal(); + 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: - void doStartUp() override; - void doShutDown() override; - ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; - ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override; - void fillCommandAndReplyMap() override; - ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t * commandData,size_t commandDataLen) override; - ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize, - DeviceCommandId_t *foundId, size_t *foundLen) override; - ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) override; - void setNormalDatapoolEntriesInvalid() override; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; - ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator command, - uint8_t expectedReplies = 1, bool useAlternateId = false, - DeviceCommandId_t alternateReplyID = 0) override; - size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MPSOC_HANDLER; -private: + static const ReturnValue_t CRC_FAILURE = + MAKE_RETURN_CODE(0xA0); //!> Space Packet received from PLOC has invalid CRC + static const ReturnValue_t RECEIVED_ACK_FAILURE = + MAKE_RETURN_CODE(0xA1); //!> Received ACK failure reply from PLOC + static const ReturnValue_t RECEIVED_EXE_FAILURE = + MAKE_RETURN_CODE(0xA2); //!> Received execution failure reply from PLOC + static const ReturnValue_t INVALID_APID = + MAKE_RETURN_CODE(0xA3); //!> Received space packet with invalid APID from PLOC - static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MPSOC_HANDLER; + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MPSOC_HANDLER; - static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0); //!> Space Packet received from PLOC has invalid CRC - static const ReturnValue_t RECEIVED_ACK_FAILURE = MAKE_RETURN_CODE(0xA1); //!> Received ACK failure reply from PLOC - static const ReturnValue_t RECEIVED_EXE_FAILURE = MAKE_RETURN_CODE(0xA2); //!> Received execution failure reply from PLOC - static const ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(0xA3); //!> Received space packet with invalid APID from PLOC + static const Event MEMORY_READ_RPT_CRC_FAILURE = + MAKE_EVENT(1, severity::LOW); //!> PLOC crc failure in telemetry packet + static const Event ACK_FAILURE = + MAKE_EVENT(2, severity::LOW); //!> PLOC receive acknowledgment failure report + static const Event EXE_FAILURE = + MAKE_EVENT(3, severity::LOW); //!> PLOC receive execution failure report + static const Event CRC_FAILURE_EVENT = + MAKE_EVENT(4, severity::LOW); //!> PLOC reply has invalid crc - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MPSOC_HANDLER; + static const uint16_t APID_MASK = 0x7FF; + static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF; - static const Event MEMORY_READ_RPT_CRC_FAILURE = MAKE_EVENT(1, severity::LOW); //!> PLOC crc failure in telemetry packet - static const Event ACK_FAILURE = MAKE_EVENT(2, severity::LOW); //!> PLOC receive acknowledgment failure report - static const Event EXE_FAILURE = MAKE_EVENT(3, severity::LOW); //!> PLOC receive execution failure report - static const Event CRC_FAILURE_EVENT = MAKE_EVENT(4, severity::LOW); //!> PLOC reply has invalid crc + uint8_t commandBuffer[PLOC_MPSOC::MAX_COMMAND_SIZE]; - static const uint16_t APID_MASK = 0x7FF; - static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF; + /** + * @brief This object is incremented each time a packet is sent or received. By checking the + * packet sequence count of a received packet, no packets can be lost without noticing + * it. Only the least significant 14 bits represent the packet sequence count in a + * space packet. Thus the maximum value amounts to 16383 (0x3FFF). + * @note Normally this should never happen because the PLOC replies are always sent in a + * fixed order. However, the PLOC software checks this value and will return an ACK + * failure report in case the sequence count is not incremented with each transferred + * space packet. + */ + uint16_t packetSequenceCount = 0x3FFF; - uint8_t commandBuffer[PLOC_MPSOC::MAX_COMMAND_SIZE]; + /** + * 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_MPSOC::NONE; - /** - * @brief This object is incremented each time a packet is sent or received. By checking the - * packet sequence count of a received packet, no packets can be lost without noticing - * it. Only the least significant 14 bits represent the packet sequence count in a - * space packet. Thus the maximum value amounts to 16383 (0x3FFF). - * @note Normally this should never happen because the PLOC replies are always sent in a - * fixed order. However, the PLOC software checks this value and will return an ACK - * failure report in case the sequence count is not incremented with each transferred - * space packet. - */ - uint16_t packetSequenceCount = 0x3FFF; + /** + * @brief This function fills the commandBuffer to initiate the write memory command. + * + * @param commandData Pointer to action command data. + * @param commanDataLen Size of command data in bytes. + * + * @return RETURN_OK if successful, else RETURN_FAILURE. + */ + ReturnValue_t prepareTcMemWriteCommand(const uint8_t* commandData, size_t commandDataLen); - /** - * 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_MPSOC::NONE; + /** + * @brief This function fills the commandBuffer to initiate the write reads command. + * + * @param commandData Pointer to action command data. + * @param commanDataLen Size of command data in bytes. + * + * @return RETURN_OK if successful, else RETURN_FAILURE. + */ + ReturnValue_t prepareTcMemReadCommand(const uint8_t* commandData, size_t commandDataLen); - /** - * @brief This function fills the commandBuffer to initiate the write memory command. - * - * @param commandData Pointer to action command data. - * @param commanDataLen Size of command data in bytes. - * - * @return RETURN_OK if successful, else RETURN_FAILURE. - */ - ReturnValue_t prepareTcMemWriteCommand(const uint8_t * commandData, size_t commandDataLen); + /** + * @brief This function checks the crc of the received PLOC reply. + * + * @param start Pointer to the first byte of the reply. + * @param foundLen Pointer to the length of the whole packet. + * + * @return RETURN_OK if CRC is ok, otherwise CRC_FAILURE. + */ + ReturnValue_t verifyPacket(const uint8_t* start, size_t foundLen); - /** - * @brief This function fills the commandBuffer to initiate the write reads command. - * - * @param commandData Pointer to action command data. - * @param commanDataLen Size of command data in bytes. - * - * @return RETURN_OK if successful, else RETURN_FAILURE. - */ - ReturnValue_t prepareTcMemReadCommand(const uint8_t * commandData, size_t commandDataLen); + /** + * @brief This function handles the acknowledgment report. + * + * @param data Pointer to the data holding the acknowledgment report. + * + * @return RETURN_OK if successful, otherwise an error code. + */ + ReturnValue_t handleAckReport(const uint8_t* data); - /** - * @brief This function checks the crc of the received PLOC reply. - * - * @param start Pointer to the first byte of the reply. - * @param foundLen Pointer to the length of the whole packet. - * - * @return RETURN_OK if CRC is ok, otherwise CRC_FAILURE. - */ - ReturnValue_t verifyPacket(const uint8_t* start, size_t foundLen); + /** + * @brief This function handles the data of a execution report. + * + * @param data Pointer to the received data packet. + * + * @return RETURN_OK if successful, otherwise an error code. + */ + ReturnValue_t handleExecutionReport(const uint8_t* data); - /** - * @brief This function handles the acknowledgment report. - * - * @param data Pointer to the data holding the acknowledgment report. - * - * @return RETURN_OK if successful, otherwise an error code. - */ - ReturnValue_t handleAckReport(const uint8_t* data); + /** + * @brief This function handles the memory read report. + * + * @param data Pointer to the data buffer holding the memory read report. + * + * @return RETURN_OK if successful, otherwise an error code. + */ + ReturnValue_t handleMemoryReadReport(const uint8_t* data); - /** - * @brief This function handles the data of a execution report. - * - * @param data Pointer to the received data packet. - * - * @return RETURN_OK if successful, otherwise an error code. - */ - ReturnValue_t handleExecutionReport(const uint8_t* data); + /** + * @brief Depending on the current active command, this function sets the reply id of the + * next reply after a successful acknowledgment report has been received. This is + * required by the function getNextReplyLength() to identify the length of the next + * reply to read. + */ + void setNextReplyId(); - /** - * @brief This function handles the memory read report. - * - * @param data Pointer to the data buffer holding the memory read report. - * - * @return RETURN_OK if successful, otherwise an error code. - */ - ReturnValue_t handleMemoryReadReport(const uint8_t* data); + /** + * @brief This function handles action message replies in case the telemetry has been + * requested by another object. + * + * @param data Pointer to the telemetry data. + * @param dataSize Size of telemetry in bytes. + * @param replyId Id of the reply. This will be added to the ActionMessage. + */ + void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); - /** - * @brief Depending on the current active command, this function sets the reply id of the - * next reply after a successful acknowledgment report has been received. This is - * required by the function getNextReplyLength() to identify the length of the next - * reply to read. - */ - void setNextReplyId(); + /** + * @brief In case an acknowledgment failure reply has been received this function disables + * all previously enabled commands and resets the exepected replies variable of an + * active command. + */ + void disableAllReplies(); - /** - * @brief This function handles action message replies in case the telemetry has been - * requested by another object. - * - * @param data Pointer to the telemetry data. - * @param dataSize Size of telemetry in bytes. - * @param replyId Id of the reply. This will be added to the ActionMessage. - */ - void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); + /** + * @brief This function sends a failure report if the active action was commanded by an other + * object. + * + * @param replyId The id of the reply which signals a failure. + * @param status A status byte which gives information about the failure type. + */ + void sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status); - /** - * @brief In case an acknowledgment failure reply has been received this function disables - * all previously enabled commands and resets the exepected replies variable of an - * active command. - */ - void disableAllReplies(); + /** + * @brief This function disables the execution report reply. Within this function also the + * the variable expectedReplies of an active command will be set to 0. + */ + void disableExeReportReply(); - /** - * @brief This function sends a failure report if the active action was commanded by an other - * object. - * - * @param replyId The id of the reply which signals a failure. - * @param status A status byte which gives information about the failure type. - */ - void sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status); - - /** - * @brief This function disables the execution report reply. Within this function also the - * the variable expectedReplies of an active command will be set to 0. - */ - void disableExeReportReply(); - - /** - * @brief This function checks and increments the packet sequence count of a received space - * packet. - * - * @param data Pointer to a space packet. - * - * @return RETURN_OK if successful - * - * @details There should be never a case in which a wrong packet sequence count is received - * because the communication scheme between PLOC and OBC always follows a strict - * procedure. Thus this function mainly serves for debugging purposes to detected an - * invalid handling of the packet sequence count. - */ - ReturnValue_t checkPacketSequenceCount(const uint8_t* data); + /** + * @brief This function checks and increments the packet sequence count of a received space + * packet. + * + * @param data Pointer to a space packet. + * + * @return RETURN_OK if successful + * + * @details There should be never a case in which a wrong packet sequence count is received + * because the communication scheme between PLOC and OBC always follows a strict + * procedure. Thus this function mainly serves for debugging purposes to detected an + * invalid handling of the packet sequence count. + */ + ReturnValue_t checkPacketSequenceCount(const uint8_t* data); }; #endif /* MISSION_DEVICES_PLOCMPSOCHANDLER_H_ */ diff --git a/mission/devices/RadiationSensorHandler.cpp b/mission/devices/RadiationSensorHandler.cpp index 95f045d8..83720b53 100644 --- a/mission/devices/RadiationSensorHandler.cpp +++ b/mission/devices/RadiationSensorHandler.cpp @@ -1,196 +1,177 @@ +#include #include #include -#include RadiationSensorHandler::RadiationSensorHandler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie) : - DeviceHandlerBase(objectId, comIF, comCookie), dataset( - this) { - if (comCookie == NULL) { - sif::error << "RadiationSensorHandler: Invalid com cookie" << std::endl; - } + CookieIF *comCookie) + : DeviceHandlerBase(objectId, comIF, comCookie), dataset(this) { + if (comCookie == NULL) { + sif::error << "RadiationSensorHandler: Invalid com cookie" << std::endl; + } } -RadiationSensorHandler::~RadiationSensorHandler() { -} +RadiationSensorHandler::~RadiationSensorHandler() {} - -void RadiationSensorHandler::doStartUp(){ - if (internalState == InternalState::CONFIGURED) { +void RadiationSensorHandler::doStartUp() { + if (internalState == InternalState::CONFIGURED) { #if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 - setMode(MODE_NORMAL); + setMode(MODE_NORMAL); #else - setMode(_MODE_TO_ON); + setMode(_MODE_TO_ON); #endif - } + } } -void RadiationSensorHandler::doShutDown(){ - setMode(_MODE_POWER_DOWN); -} +void RadiationSensorHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } -ReturnValue_t RadiationSensorHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - - switch (communicationStep) { +ReturnValue_t RadiationSensorHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + switch (communicationStep) { case CommunicationStep::START_CONVERSION: { - *id = RAD_SENSOR::START_CONVERSION; - communicationStep = CommunicationStep::READ_CONVERSIONS; - break; + *id = RAD_SENSOR::START_CONVERSION; + communicationStep = CommunicationStep::READ_CONVERSIONS; + break; } case CommunicationStep::READ_CONVERSIONS: { - *id = RAD_SENSOR::READ_CONVERSIONS; - communicationStep = CommunicationStep::START_CONVERSION; - break; + *id = RAD_SENSOR::READ_CONVERSIONS; + communicationStep = CommunicationStep::START_CONVERSION; + break; } default: { - sif::debug << "RadiationSensorHandler::buildNormalDeviceCommand: Unknown communication " - << "step" << std::endl; - return HasReturnvaluesIF::RETURN_OK; + sif::debug << "RadiationSensorHandler::buildNormalDeviceCommand: Unknown communication " + << "step" << std::endl; + return HasReturnvaluesIF::RETURN_OK; } - } - return buildCommandFromCommand(*id, nullptr, 0); + } + return buildCommandFromCommand(*id, nullptr, 0); } -ReturnValue_t RadiationSensorHandler::buildTransitionDeviceCommand( - DeviceCommandId_t * id){ - if (internalState == InternalState::SETUP) { - *id = RAD_SENSOR::WRITE_SETUP; - } - else { - return NOTHING_TO_SEND; - } - return buildCommandFromCommand(*id, nullptr, 0); +ReturnValue_t RadiationSensorHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { + if (internalState == InternalState::SETUP) { + *id = RAD_SENSOR::WRITE_SETUP; + } else { + return NOTHING_TO_SEND; + } + return buildCommandFromCommand(*id, nullptr, 0); } -ReturnValue_t RadiationSensorHandler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t * commandData, - size_t commandDataLen) { - switch(deviceCommand) { - case(RAD_SENSOR::WRITE_SETUP): { - cmdBuffer[0] = RAD_SENSOR::SETUP_DEFINITION; - rawPacket = cmdBuffer; - rawPacketLen = 1; - internalState = InternalState::CONFIGURED; - return RETURN_OK; +ReturnValue_t RadiationSensorHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, + size_t commandDataLen) { + switch (deviceCommand) { + case (RAD_SENSOR::WRITE_SETUP): { + cmdBuffer[0] = RAD_SENSOR::SETUP_DEFINITION; + rawPacket = cmdBuffer; + rawPacketLen = 1; + internalState = InternalState::CONFIGURED; + return RETURN_OK; } - case(RAD_SENSOR::START_CONVERSION): { - /* First the fifo will be reset here */ - cmdBuffer[0] = RAD_SENSOR::RESET_DEFINITION; - cmdBuffer[1] = RAD_SENSOR::CONVERSION_DEFINITION; - rawPacket = cmdBuffer; - rawPacketLen = 2; - return RETURN_OK; + case (RAD_SENSOR::START_CONVERSION): { + /* First the fifo will be reset here */ + cmdBuffer[0] = RAD_SENSOR::RESET_DEFINITION; + cmdBuffer[1] = RAD_SENSOR::CONVERSION_DEFINITION; + rawPacket = cmdBuffer; + rawPacketLen = 2; + return RETURN_OK; } - case(RAD_SENSOR::READ_CONVERSIONS): { - cmdBuffer[0] = RAD_SENSOR::DUMMY_BYTE; - std::memset(cmdBuffer, RAD_SENSOR::DUMMY_BYTE, RAD_SENSOR::READ_SIZE); - rawPacket = cmdBuffer; - rawPacketLen = RAD_SENSOR::READ_SIZE; - return RETURN_OK; + case (RAD_SENSOR::READ_CONVERSIONS): { + cmdBuffer[0] = RAD_SENSOR::DUMMY_BYTE; + std::memset(cmdBuffer, RAD_SENSOR::DUMMY_BYTE, RAD_SENSOR::READ_SIZE); + rawPacket = cmdBuffer; + rawPacketLen = RAD_SENSOR::READ_SIZE; + return RETURN_OK; } -// case(RAD_SENSOR::AIN0_AND_TMP_CONVERSION): { -// /* First the fifo will be reset here */ -// cmdBuffer[0] = RAD_SENSOR::RESET_DEFINITION; -// cmdBuffer[1] = RAD_SENSOR::CONVERSION_DEFINITION; -// rawPacket = cmdBuffer; -// rawPacketLen = 2; -// return RETURN_OK; -// } + // case(RAD_SENSOR::AIN0_AND_TMP_CONVERSION): { + // /* First the fifo will be reset here */ + // cmdBuffer[0] = RAD_SENSOR::RESET_DEFINITION; + // cmdBuffer[1] = RAD_SENSOR::CONVERSION_DEFINITION; + // rawPacket = cmdBuffer; + // rawPacketLen = 2; + // return RETURN_OK; + // } default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } void RadiationSensorHandler::fillCommandAndReplyMap() { - this->insertInCommandMap(RAD_SENSOR::WRITE_SETUP); - this->insertInCommandMap(RAD_SENSOR::START_CONVERSION); - this->insertInCommandAndReplyMap(RAD_SENSOR::READ_CONVERSIONS, 1, &dataset, - RAD_SENSOR::READ_SIZE); + this->insertInCommandMap(RAD_SENSOR::WRITE_SETUP); + this->insertInCommandMap(RAD_SENSOR::START_CONVERSION); + this->insertInCommandAndReplyMap(RAD_SENSOR::READ_CONVERSIONS, 1, &dataset, + RAD_SENSOR::READ_SIZE); } -ReturnValue_t RadiationSensorHandler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { - *foundId = this->getPendingCommand(); +ReturnValue_t RadiationSensorHandler::scanForReply(const uint8_t *start, size_t remainingSize, + DeviceCommandId_t *foundId, size_t *foundLen) { + *foundId = this->getPendingCommand(); - switch (*foundId) { + switch (*foundId) { case RAD_SENSOR::START_CONVERSION: case RAD_SENSOR::WRITE_SETUP: - return IGNORE_REPLY_DATA; + return IGNORE_REPLY_DATA; default: - break; - } + break; + } - *foundLen = remainingSize; + *foundLen = remainingSize; - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t RadiationSensorHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { - switch (id) { + const uint8_t *packet) { + switch (id) { case RAD_SENSOR::READ_CONVERSIONS: { - uint8_t offset = 0; - PoolReadGuard readSet(&dataset); - dataset.temperatureCelcius = (*(packet + offset) << 8 | *(packet + offset + 1)) * 0.125; - offset += 2; - dataset.ain0 = (*(packet + offset) << 8 | *(packet + offset +1)); - offset += 2; - dataset.ain1 = (*(packet + offset) << 8 | *(packet + offset + 1)); - offset += 6; - dataset.ain4 = (*(packet + offset) << 8 | *(packet + offset + 1)); - offset += 2; - dataset.ain5 = (*(packet + offset) << 8 | *(packet + offset + 1)); - offset += 2; - dataset.ain6 = (*(packet + offset) << 8 | *(packet + offset + 1)); - offset += 2; - dataset.ain7 = (*(packet + offset) << 8 | *(packet + offset + 1)); + uint8_t offset = 0; + PoolReadGuard readSet(&dataset); + dataset.temperatureCelcius = (*(packet + offset) << 8 | *(packet + offset + 1)) * 0.125; + offset += 2; + dataset.ain0 = (*(packet + offset) << 8 | *(packet + offset + 1)); + offset += 2; + dataset.ain1 = (*(packet + offset) << 8 | *(packet + offset + 1)); + offset += 6; + dataset.ain4 = (*(packet + offset) << 8 | *(packet + offset + 1)); + offset += 2; + dataset.ain5 = (*(packet + offset) << 8 | *(packet + offset + 1)); + offset += 2; + dataset.ain6 = (*(packet + offset) << 8 | *(packet + offset + 1)); + offset += 2; + dataset.ain7 = (*(packet + offset) << 8 | *(packet + offset + 1)); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RAD_SENSOR - sif::info << "Radiation sensor temperature: " << dataset.temperatureCelcius << " °C" - << std::endl; - sif::info << "Radiation sensor ADC value channel 0: " << dataset.ain0 - << std::endl; - sif::info << "Radiation sensor ADC value channel 1: " << dataset.ain1 - << std::endl; - sif::info << "Radiation sensor ADC value channel 4: " << dataset.ain4 - << std::endl; - sif::info << "Radiation sensor ADC value channel 5: " << dataset.ain5 - << std::endl; - sif::info << "Radiation sensor ADC value channel 6: " << dataset.ain6 - << std::endl; - sif::info << "Radiation sensor ADC value channel 7: " << dataset.ain7 + sif::info << "Radiation sensor temperature: " << dataset.temperatureCelcius << " °C" << std::endl; + sif::info << "Radiation sensor ADC value channel 0: " << dataset.ain0 << std::endl; + sif::info << "Radiation sensor ADC value channel 1: " << dataset.ain1 << std::endl; + sif::info << "Radiation sensor ADC value channel 4: " << dataset.ain4 << std::endl; + sif::info << "Radiation sensor ADC value channel 5: " << dataset.ain5 << std::endl; + sif::info << "Radiation sensor ADC value channel 6: " << dataset.ain6 << std::endl; + sif::info << "Radiation sensor ADC value channel 7: " << dataset.ain7 << std::endl; #endif - break; + break; } default: { - sif::debug << "RadiationSensorHandler::interpretDeviceReply: Unknown reply id" << std::endl; - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; + sif::debug << "RadiationSensorHandler::interpretDeviceReply: Unknown reply id" << std::endl; + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; } - - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } -void RadiationSensorHandler::setNormalDatapoolEntriesInvalid(){ +void RadiationSensorHandler::setNormalDatapoolEntriesInvalid() {} +uint32_t RadiationSensorHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { + return 5000; } -uint32_t RadiationSensorHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){ - return 5000; +ReturnValue_t RadiationSensorHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(RAD_SENSOR::TEMPERATURE_C, new PoolEntry({0.0})); + localDataPoolMap.emplace(RAD_SENSOR::AIN0, new PoolEntry({0})); + localDataPoolMap.emplace(RAD_SENSOR::AIN1, new PoolEntry({0})); + localDataPoolMap.emplace(RAD_SENSOR::AIN4, new PoolEntry({0})); + localDataPoolMap.emplace(RAD_SENSOR::AIN5, new PoolEntry({0})); + localDataPoolMap.emplace(RAD_SENSOR::AIN6, new PoolEntry({0})); + localDataPoolMap.emplace(RAD_SENSOR::AIN7, new PoolEntry({0})); + return HasReturnvaluesIF::RETURN_OK; } - -ReturnValue_t RadiationSensorHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { - localDataPoolMap.emplace(RAD_SENSOR::TEMPERATURE_C, new PoolEntry( { 0.0 })); - localDataPoolMap.emplace(RAD_SENSOR::AIN0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RAD_SENSOR::AIN1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RAD_SENSOR::AIN4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RAD_SENSOR::AIN5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RAD_SENSOR::AIN6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RAD_SENSOR::AIN7, new PoolEntry( { 0 })); - return HasReturnvaluesIF::RETURN_OK; -} - diff --git a/mission/devices/RadiationSensorHandler.h b/mission/devices/RadiationSensorHandler.h index 5612a1e0..fe4e4264 100644 --- a/mission/devices/RadiationSensorHandler.h +++ b/mission/devices/RadiationSensorHandler.h @@ -5,56 +5,46 @@ #include /** - * @brief This is the device handler class for radiation sensor on the OBC IF Board. The sensor - * is based on the MAX1227 ADC converter. + * @brief This is the device handler class for radiation sensor on the OBC IF Board. The + * sensor is based on the MAX1227 ADC converter. * * @details Datasheet of MAX1227: https://datasheets.maximintegrated.com/en/ds/MAX1227-MAX1231.pdf * * @author J. Meier */ -class RadiationSensorHandler: public DeviceHandlerBase { -public: +class RadiationSensorHandler : public DeviceHandlerBase { + public: + RadiationSensorHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie); + virtual ~RadiationSensorHandler(); - RadiationSensorHandler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie); - virtual ~RadiationSensorHandler(); + 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; -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; + private: + enum class CommunicationStep { START_CONVERSION, READ_CONVERSIONS }; -private: + enum class InternalState { SETUP, CONFIGURED }; - enum class CommunicationStep { - START_CONVERSION, - READ_CONVERSIONS - }; + RAD_SENSOR::RadSensorDataset dataset; - enum class InternalState { - SETUP, - CONFIGURED - }; + static const uint8_t MAX_CMD_LEN = RAD_SENSOR::READ_SIZE; - RAD_SENSOR::RadSensorDataset dataset; - - static const uint8_t MAX_CMD_LEN = RAD_SENSOR::READ_SIZE; - - uint8_t cmdBuffer[MAX_CMD_LEN]; - InternalState internalState = InternalState::SETUP; - CommunicationStep communicationStep = CommunicationStep::START_CONVERSION; + uint8_t cmdBuffer[MAX_CMD_LEN]; + InternalState internalState = InternalState::SETUP; + CommunicationStep communicationStep = CommunicationStep::START_CONVERSION; }; #endif /* MISSION_DEVICES_RADIATIONSENSORHANDLER_H_ */ diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index c848c809..f3cd0737 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -1,526 +1,523 @@ #include "RwHandler.h" + +#include +#include + #include "OBSWConfig.h" -#include -#include - -RwHandler::RwHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie, - LinuxLibgpioIF* gpioComIF, gpioId_t enableGpio) : - DeviceHandlerBase(objectId, comIF, comCookie), gpioComIF(gpioComIF), enableGpio(enableGpio), - temperatureSet(this), statusSet(this), lastResetStatusSet(this), tmDataset(this) { - if (comCookie == NULL) { - sif::error << "RwHandler: Invalid com cookie" << std::endl; - } - if (gpioComIF == NULL) { - sif::error << "RwHandler: Invalid gpio communication interface" << std::endl; - } +RwHandler::RwHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, + LinuxLibgpioIF* gpioComIF, gpioId_t enableGpio) + : DeviceHandlerBase(objectId, comIF, comCookie), + gpioComIF(gpioComIF), + enableGpio(enableGpio), + temperatureSet(this), + statusSet(this), + lastResetStatusSet(this), + tmDataset(this) { + if (comCookie == NULL) { + sif::error << "RwHandler: Invalid com cookie" << std::endl; + } + if (gpioComIF == NULL) { + sif::error << "RwHandler: Invalid gpio communication interface" << std::endl; + } } -RwHandler::~RwHandler() { -} +RwHandler::~RwHandler() {} void RwHandler::doStartUp() { + internalState = InternalState::GET_RESET_STATUS; - internalState = InternalState::GET_RESET_STATUS; - - if(gpioComIF->pullHigh(enableGpio) != RETURN_OK) { - sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to high"; - } + if (gpioComIF->pullHigh(enableGpio) != RETURN_OK) { + sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to high"; + } #if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 - setMode(MODE_NORMAL); + setMode(MODE_NORMAL); #else - setMode(_MODE_TO_ON); + setMode(_MODE_TO_ON); #endif } void RwHandler::doShutDown() { - if(gpioComIF->pullLow(enableGpio) != RETURN_OK) { - sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to low"; - } - setMode(_MODE_POWER_DOWN); + if (gpioComIF->pullLow(enableGpio) != RETURN_OK) { + sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to low"; + } + setMode(_MODE_POWER_DOWN); } -ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) { - switch (internalState) { +ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + switch (internalState) { case InternalState::GET_RESET_STATUS: - *id = RwDefinitions::GET_LAST_RESET_STATUS; - internalState = InternalState::READ_TEMPERATURE; - break; + *id = RwDefinitions::GET_LAST_RESET_STATUS; + internalState = InternalState::READ_TEMPERATURE; + break; case InternalState::CLEAR_RESET_STATUS: - *id = RwDefinitions::CLEAR_LAST_RESET_STATUS; - /** After reset status is cleared, reset status will be polled again for verification */ - internalState = InternalState::GET_RESET_STATUS; - break; + *id = RwDefinitions::CLEAR_LAST_RESET_STATUS; + /** After reset status is cleared, reset status will be polled again for verification */ + internalState = InternalState::GET_RESET_STATUS; + break; case InternalState::READ_TEMPERATURE: - *id = RwDefinitions::GET_TEMPERATURE; - internalState = InternalState::GET_RW_SATUS; - break; + *id = RwDefinitions::GET_TEMPERATURE; + internalState = InternalState::GET_RW_SATUS; + break; case InternalState::GET_RW_SATUS: - *id = RwDefinitions::GET_RW_STATUS; - internalState = InternalState::GET_RESET_STATUS; - break; + *id = RwDefinitions::GET_RW_STATUS; + internalState = InternalState::GET_RESET_STATUS; + break; default: - sif::debug << "RwHandler::buildNormalDeviceCommand: Invalid internal step" - << std::endl; - break; - } - return buildCommandFromCommand(*id, NULL, 0); + sif::debug << "RwHandler::buildNormalDeviceCommand: Invalid internal step" << std::endl; + break; + } + return buildCommandFromCommand(*id, NULL, 0); } -ReturnValue_t RwHandler::buildTransitionDeviceCommand(DeviceCommandId_t * id) { - return NOTHING_TO_SEND; +ReturnValue_t RwHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { + return NOTHING_TO_SEND; } ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t * commandData, size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; + const uint8_t* commandData, + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; - switch (deviceCommand) { + switch (deviceCommand) { case (RwDefinitions::RESET_MCU): { - prepareSimpleCommand(deviceCommand); - return RETURN_OK; + prepareSimpleCommand(deviceCommand); + return RETURN_OK; } case (RwDefinitions::GET_LAST_RESET_STATUS): { - prepareSimpleCommand(deviceCommand); - return RETURN_OK; + prepareSimpleCommand(deviceCommand); + return RETURN_OK; } case (RwDefinitions::CLEAR_LAST_RESET_STATUS): { - prepareSimpleCommand(deviceCommand); - return RETURN_OK; + prepareSimpleCommand(deviceCommand); + return RETURN_OK; } case (RwDefinitions::GET_RW_STATUS): { - prepareSimpleCommand(deviceCommand); - return RETURN_OK; + prepareSimpleCommand(deviceCommand); + return RETURN_OK; } case (RwDefinitions::INIT_RW_CONTROLLER): { - prepareSimpleCommand(deviceCommand); - return RETURN_OK; + prepareSimpleCommand(deviceCommand); + return RETURN_OK; } case (RwDefinitions::SET_SPEED): { - if (commandDataLen != 6) { - sif::error << "RwHandler::buildCommandFromCommand: Received set speed command with" - << " invalid length" << std::endl; - return SET_SPEED_COMMAND_INVALID_LENGTH; - } - result = checkSpeedAndRampTime(commandData, commandDataLen); - if (result != RETURN_OK) { - return result; - } - prepareSetSpeedCmd(commandData, commandDataLen); + if (commandDataLen != 6) { + sif::error << "RwHandler::buildCommandFromCommand: Received set speed command with" + << " invalid length" << std::endl; + return SET_SPEED_COMMAND_INVALID_LENGTH; + } + result = checkSpeedAndRampTime(commandData, commandDataLen); + if (result != RETURN_OK) { return result; + } + prepareSetSpeedCmd(commandData, commandDataLen); + return result; } case (RwDefinitions::GET_TEMPERATURE): { - prepareSimpleCommand(deviceCommand); - return RETURN_OK; + prepareSimpleCommand(deviceCommand); + return RETURN_OK; } case (RwDefinitions::GET_TM): { - prepareSimpleCommand(deviceCommand); - return RETURN_OK; + prepareSimpleCommand(deviceCommand); + return RETURN_OK; } default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } void RwHandler::fillCommandAndReplyMap() { - this->insertInCommandMap(RwDefinitions::RESET_MCU); - this->insertInCommandAndReplyMap(RwDefinitions::GET_LAST_RESET_STATUS, 1, &lastResetStatusSet, - RwDefinitions::SIZE_GET_RESET_STATUS); - this->insertInCommandAndReplyMap(RwDefinitions::CLEAR_LAST_RESET_STATUS, 1, nullptr, - RwDefinitions::SIZE_CLEAR_RESET_STATUS); - this->insertInCommandAndReplyMap(RwDefinitions::GET_RW_STATUS, 1, &statusSet, - RwDefinitions::SIZE_GET_RW_STATUS); - this->insertInCommandAndReplyMap(RwDefinitions::INIT_RW_CONTROLLER, 1, nullptr, - RwDefinitions::SIZE_INIT_RW); - this->insertInCommandAndReplyMap(RwDefinitions::GET_TEMPERATURE, 1, &temperatureSet, - RwDefinitions::SIZE_GET_TEMPERATURE_REPLY); - this->insertInCommandAndReplyMap(RwDefinitions::SET_SPEED, 1, nullptr, - RwDefinitions::SIZE_SET_SPEED_REPLY); - this->insertInCommandAndReplyMap(RwDefinitions::GET_TM, 1, &tmDataset, - RwDefinitions::SIZE_GET_TELEMETRY_REPLY); + this->insertInCommandMap(RwDefinitions::RESET_MCU); + this->insertInCommandAndReplyMap(RwDefinitions::GET_LAST_RESET_STATUS, 1, &lastResetStatusSet, + RwDefinitions::SIZE_GET_RESET_STATUS); + this->insertInCommandAndReplyMap(RwDefinitions::CLEAR_LAST_RESET_STATUS, 1, nullptr, + RwDefinitions::SIZE_CLEAR_RESET_STATUS); + this->insertInCommandAndReplyMap(RwDefinitions::GET_RW_STATUS, 1, &statusSet, + RwDefinitions::SIZE_GET_RW_STATUS); + this->insertInCommandAndReplyMap(RwDefinitions::INIT_RW_CONTROLLER, 1, nullptr, + RwDefinitions::SIZE_INIT_RW); + this->insertInCommandAndReplyMap(RwDefinitions::GET_TEMPERATURE, 1, &temperatureSet, + RwDefinitions::SIZE_GET_TEMPERATURE_REPLY); + this->insertInCommandAndReplyMap(RwDefinitions::SET_SPEED, 1, nullptr, + RwDefinitions::SIZE_SET_SPEED_REPLY); + this->insertInCommandAndReplyMap(RwDefinitions::GET_TM, 1, &tmDataset, + RwDefinitions::SIZE_GET_TELEMETRY_REPLY); } -ReturnValue_t RwHandler::scanForReply(const uint8_t *start, size_t remainingSize, - DeviceCommandId_t *foundId, size_t *foundLen) { - uint8_t replyByte = *start; - switch (replyByte) { +ReturnValue_t RwHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + uint8_t replyByte = *start; + switch (replyByte) { case (RwDefinitions::GET_LAST_RESET_STATUS): { - *foundLen = RwDefinitions::SIZE_GET_RESET_STATUS; - *foundId = RwDefinitions::GET_LAST_RESET_STATUS; - break; + *foundLen = RwDefinitions::SIZE_GET_RESET_STATUS; + *foundId = RwDefinitions::GET_LAST_RESET_STATUS; + break; } case (RwDefinitions::CLEAR_LAST_RESET_STATUS): { - *foundLen = RwDefinitions::SIZE_CLEAR_RESET_STATUS; - *foundId = RwDefinitions::CLEAR_LAST_RESET_STATUS; - break; + *foundLen = RwDefinitions::SIZE_CLEAR_RESET_STATUS; + *foundId = RwDefinitions::CLEAR_LAST_RESET_STATUS; + break; } case (RwDefinitions::GET_RW_STATUS): { - *foundLen = RwDefinitions::SIZE_GET_RW_STATUS; - *foundId = RwDefinitions::GET_RW_STATUS; - break; + *foundLen = RwDefinitions::SIZE_GET_RW_STATUS; + *foundId = RwDefinitions::GET_RW_STATUS; + break; } case (RwDefinitions::INIT_RW_CONTROLLER): { - *foundLen = RwDefinitions::SIZE_INIT_RW; - *foundId = RwDefinitions::INIT_RW_CONTROLLER; - break; + *foundLen = RwDefinitions::SIZE_INIT_RW; + *foundId = RwDefinitions::INIT_RW_CONTROLLER; + break; } case (RwDefinitions::SET_SPEED): { - *foundLen = RwDefinitions::SIZE_SET_SPEED_REPLY; - *foundId = RwDefinitions::SET_SPEED; - break; + *foundLen = RwDefinitions::SIZE_SET_SPEED_REPLY; + *foundId = RwDefinitions::SET_SPEED; + break; } case (RwDefinitions::GET_TEMPERATURE): { - *foundLen = RwDefinitions::SIZE_GET_TEMPERATURE_REPLY; - *foundId = RwDefinitions::GET_TEMPERATURE; - break; + *foundLen = RwDefinitions::SIZE_GET_TEMPERATURE_REPLY; + *foundId = RwDefinitions::GET_TEMPERATURE; + break; } case (RwDefinitions::GET_TM): { - *foundLen = RwDefinitions::SIZE_GET_TELEMETRY_REPLY; - *foundId = RwDefinitions::GET_TM; - break; + *foundLen = RwDefinitions::SIZE_GET_TELEMETRY_REPLY; + *foundId = RwDefinitions::GET_TM; + break; } default: { - sif::warning << "RwHandler::scanForReply: Reply contains invalid command code" << - std::endl; - *foundLen = remainingSize; - return RETURN_FAILED; - } + sif::warning << "RwHandler::scanForReply: Reply contains invalid command code" << std::endl; + *foundLen = remainingSize; + return RETURN_FAILED; } + } - sizeOfReply = *foundLen; + sizeOfReply = *foundLen; - return RETURN_OK; + return RETURN_OK; } -ReturnValue_t RwHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { +ReturnValue_t RwHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { + /** Check result code */ + if (*(packet + 1) == RwDefinitions::STATE_ERROR) { + sif::error << "RwHandler::interpretDeviceReply: Command execution failed. Command id: " << id + << std::endl; + return EXECUTION_FAILED; + } - /** Check result code */ - if (*(packet + 1) == RwDefinitions::STATE_ERROR) { - sif::error << "RwHandler::interpretDeviceReply: Command execution failed. Command id: " - << id << std::endl; - return EXECUTION_FAILED; - } + /** Received in little endian byte order */ + uint16_t replyCrc = *(packet + sizeOfReply - 1) << 8 | *(packet + sizeOfReply - 2); - /** Received in little endian byte order */ - uint16_t replyCrc = *(packet + sizeOfReply - 1) << 8 | *(packet + sizeOfReply - 2) ; + if (CRC::crc16ccitt(packet, sizeOfReply - 2, 0xFFFF) != replyCrc) { + sif::error << "RwHandler::interpretDeviceReply: cRC error" << std::endl; + return CRC_ERROR; + } - if (CRC::crc16ccitt(packet, sizeOfReply - 2, 0xFFFF) != replyCrc) { - sif::error << "RwHandler::interpretDeviceReply: cRC error" << std::endl; - return CRC_ERROR; - } - - switch (id) { + switch (id) { case (RwDefinitions::GET_LAST_RESET_STATUS): { - handleResetStatusReply(packet); - break; + handleResetStatusReply(packet); + break; } case (RwDefinitions::GET_RW_STATUS): { - handleGetRwStatusReply(packet); - break; + handleGetRwStatusReply(packet); + break; } case (RwDefinitions::CLEAR_LAST_RESET_STATUS): case (RwDefinitions::INIT_RW_CONTROLLER): case (RwDefinitions::SET_SPEED): - // no reply data expected - break; + // no reply data expected + break; case (RwDefinitions::GET_TEMPERATURE): { - handleTemperatureReply(packet); - break; + handleTemperatureReply(packet); + break; } case (RwDefinitions::GET_TM): { - handleGetTelemetryReply(packet); - break; + handleGetTelemetryReply(packet); + break; } default: { - sif::debug << "RwHandler::interpretDeviceReply: Unknown device reply id" << std::endl; - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } + sif::debug << "RwHandler::interpretDeviceReply: Unknown device reply id" << std::endl; + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; } + } - return RETURN_OK; + return RETURN_OK; } -void RwHandler::setNormalDatapoolEntriesInvalid() { +void RwHandler::setNormalDatapoolEntriesInvalid() {} -} - -uint32_t RwHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { - return 5000; -} +uint32_t RwHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 5000; } ReturnValue_t RwHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { + LocalDataPoolManager& poolManager) { + localDataPoolMap.emplace(RwDefinitions::TEMPERATURE_C, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::TEMPERATURE_C, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::CURR_SPEED, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::REFERENCE_SPEED, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::STATE, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::CLC_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::CURR_SPEED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::REFERENCE_SPEED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::CLC_MODE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::LAST_RESET_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::CURRRENT_RESET_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::LAST_RESET_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::CURRRENT_RESET_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::TM_LAST_RESET_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::TM_MCU_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::PRESSURE_SENSOR_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::PRESSURE, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::TM_RW_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::TM_CLC_MODE, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::TM_RW_CURR_SPEED, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::TM_RW_REF_SPEED, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::INVALID_CRC_PACKETS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::INVALID_LEN_PACKETS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::INVALID_CMD_PACKETS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::EXECUTED_REPLIES, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::COMMAND_REPLIES, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::UART_BYTES_WRITTEN, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::UART_BYTES_READ, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::UART_PARITY_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::UART_NOISE_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::UART_FRAME_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::UART_REG_OVERRUN_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::UART_TOTAL_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_WRITTEN, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_READ, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::SPI_REG_OVERRUN_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::SPI_TOTAL_ERRORS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::TM_LAST_RESET_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::TM_MCU_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::PRESSURE_SENSOR_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::PRESSURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::TM_RW_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::TM_CLC_MODE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::TM_RW_CURR_SPEED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::TM_RW_REF_SPEED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::INVALID_CRC_PACKETS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::INVALID_LEN_PACKETS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::INVALID_CMD_PACKETS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::EXECUTED_REPLIES, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::COMMAND_REPLIES, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::UART_BYTES_WRITTEN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::UART_BYTES_READ, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::UART_PARITY_ERRORS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::UART_NOISE_ERRORS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::UART_FRAME_ERRORS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::UART_REG_OVERRUN_ERRORS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::UART_TOTAL_ERRORS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_WRITTEN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_READ, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::SPI_REG_OVERRUN_ERRORS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::SPI_TOTAL_ERRORS, new PoolEntry( { 0 })); - - return RETURN_OK; + return RETURN_OK; } void RwHandler::prepareSimpleCommand(DeviceCommandId_t id) { - commandBuffer[0] = static_cast(id); - uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF); - commandBuffer[1] = static_cast(crc & 0xFF); - commandBuffer[2] = static_cast(crc >> 8 & 0xFF); - rawPacket = commandBuffer; - rawPacketLen = 3; + commandBuffer[0] = static_cast(id); + uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF); + commandBuffer[1] = static_cast(crc & 0xFF); + commandBuffer[2] = static_cast(crc >> 8 & 0xFF); + rawPacket = commandBuffer; + rawPacketLen = 3; } ReturnValue_t RwHandler::checkSpeedAndRampTime(const uint8_t* commandData, size_t commandDataLen) { - int32_t speed = *commandData << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 - | *(commandData + 3); + int32_t speed = + *commandData << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 | *(commandData + 3); - if ((speed < -65000 || speed > 65000 || (speed > -1000 && speed < 1000)) && (speed != 0)) { - sif::error << "RwHandler::checkSpeedAndRampTime: Command has invalid speed" << std::endl; - return INVALID_SPEED; - } + if ((speed < -65000 || speed > 65000 || (speed > -1000 && speed < 1000)) && (speed != 0)) { + sif::error << "RwHandler::checkSpeedAndRampTime: Command has invalid speed" << std::endl; + return INVALID_SPEED; + } - uint16_t rampTime = *(commandData + 4) << 8 | *(commandData + 5); + uint16_t rampTime = *(commandData + 4) << 8 | *(commandData + 5); - if (rampTime < 10 || rampTime > 10000) { - sif::error << "RwHandler::checkSpeedAndRampTime: Command has invalid ramp time" - << std::endl; - return INVALID_RAMP_TIME; - } + if (rampTime < 10 || rampTime > 10000) { + sif::error << "RwHandler::checkSpeedAndRampTime: Command has invalid ramp time" << std::endl; + return INVALID_RAMP_TIME; + } - return RETURN_OK; + return RETURN_OK; } -void RwHandler::prepareSetSpeedCmd(const uint8_t * commandData, size_t commandDataLen) { - commandBuffer[0] = static_cast(RwDefinitions::SET_SPEED); +void RwHandler::prepareSetSpeedCmd(const uint8_t* commandData, size_t commandDataLen) { + commandBuffer[0] = static_cast(RwDefinitions::SET_SPEED); - /** Speed (0.1 RPM) */ - commandBuffer[1] = *(commandData + 3); - commandBuffer[2] = *(commandData + 2); - commandBuffer[3] = *(commandData + 1); - commandBuffer[4] = *commandData; - /** Ramp time (ms) */ - commandBuffer[5] = *(commandData + 5); - commandBuffer[6] = *(commandData + 4); + /** Speed (0.1 RPM) */ + commandBuffer[1] = *(commandData + 3); + commandBuffer[2] = *(commandData + 2); + commandBuffer[3] = *(commandData + 1); + commandBuffer[4] = *commandData; + /** Ramp time (ms) */ + commandBuffer[5] = *(commandData + 5); + commandBuffer[6] = *(commandData + 4); - uint16_t crc = CRC::crc16ccitt(commandBuffer, 7, 0xFFFF); - commandBuffer[7] = static_cast(crc & 0xFF); - commandBuffer[8] = static_cast(crc >> 8 & 0xFF); - rawPacket = commandBuffer; - rawPacketLen = 9; + uint16_t crc = CRC::crc16ccitt(commandBuffer, 7, 0xFFFF); + commandBuffer[7] = static_cast(crc & 0xFF); + commandBuffer[8] = static_cast(crc >> 8 & 0xFF); + rawPacket = commandBuffer; + rawPacketLen = 9; } void RwHandler::handleResetStatusReply(const uint8_t* packet) { - PoolReadGuard rg(&lastResetStatusSet); - uint8_t offset = 2; - uint8_t resetStatus = *(packet + offset); - if (resetStatus != RwDefinitions::CLEARED) { - internalState = InternalState::CLEAR_RESET_STATUS; - lastResetStatusSet.lastResetStatus = resetStatus; - } - lastResetStatusSet.currentResetStatus = resetStatus; + PoolReadGuard rg(&lastResetStatusSet); + uint8_t offset = 2; + uint8_t resetStatus = *(packet + offset); + if (resetStatus != RwDefinitions::CLEARED) { + internalState = InternalState::CLEAR_RESET_STATUS; + lastResetStatusSet.lastResetStatus = resetStatus; + } + lastResetStatusSet.currentResetStatus = resetStatus; #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RW == 1 - sif::info << "RwHandler::handleResetStatusReply: Last reset status: " + sif::info << "RwHandler::handleResetStatusReply: Last reset status: " << static_cast(lastResetStatusSet.lastResetStatus.value) << std::endl; - sif::info << "RwHandler::handleResetStatusReply: Current reset status: " + sif::info << "RwHandler::handleResetStatusReply: Current reset status: " << static_cast(lastResetStatusSet.currentResetStatus.value) << std::endl; #endif } void RwHandler::handleGetRwStatusReply(const uint8_t* packet) { - PoolReadGuard rg(&statusSet); - uint8_t offset = 2; - statusSet.currSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - statusSet.referenceSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - statusSet.state = *(packet + offset); - offset += 1; - statusSet.clcMode = *(packet + offset); + PoolReadGuard rg(&statusSet); + uint8_t offset = 2; + statusSet.currSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + statusSet.referenceSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + statusSet.state = *(packet + offset); + offset += 1; + statusSet.clcMode = *(packet + offset); - if (statusSet.state == RwDefinitions::STATE_ERROR) { - /** - * This requires the commanding of the init reaction wheel controller command to recover - * form error state which must be handled by the FDIR instance. - */ - triggerEvent(ERROR_STATE); - sif::error << "RwHandler::handleGetRwStatusReply: Reaction wheel in error state" - << std::endl; - } + if (statusSet.state == RwDefinitions::STATE_ERROR) { + /** + * This requires the commanding of the init reaction wheel controller command to recover + * form error state which must be handled by the FDIR instance. + */ + triggerEvent(ERROR_STATE); + sif::error << "RwHandler::handleGetRwStatusReply: Reaction wheel in error state" << std::endl; + } #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RW == 1 - sif::info << "RwHandler::handleGetRwStatusReply: Current speed is: " << statusSet.currSpeed + sif::info << "RwHandler::handleGetRwStatusReply: Current speed is: " << statusSet.currSpeed << " * 0.1 RPM" << std::endl; - sif::info << "RwHandler::handleGetRwStatusReply: Reference speed is: " - << statusSet.referenceSpeed << " * 0.1 RPM" << std::endl; - sif::info << "RwHandler::handleGetRwStatusReply: State is: " - << (unsigned int) statusSet.state.value << std::endl; - sif::info << "RwHandler::handleGetRwStatusReply: clc mode is: " - << (unsigned int) statusSet.clcMode.value << std::endl; + sif::info << "RwHandler::handleGetRwStatusReply: Reference speed is: " << statusSet.referenceSpeed + << " * 0.1 RPM" << std::endl; + sif::info << "RwHandler::handleGetRwStatusReply: State is: " + << (unsigned int)statusSet.state.value << std::endl; + sif::info << "RwHandler::handleGetRwStatusReply: clc mode is: " + << (unsigned int)statusSet.clcMode.value << std::endl; #endif } void RwHandler::handleTemperatureReply(const uint8_t* packet) { - PoolReadGuard rg(&temperatureSet); - uint8_t offset = 2; - temperatureSet.temperatureCelcius = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); + PoolReadGuard rg(&temperatureSet); + uint8_t offset = 2; + temperatureSet.temperatureCelcius = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RW == 1 - sif::info << "RwHandler::handleTemperatureReply: Temperature: " + sif::info << "RwHandler::handleTemperatureReply: Temperature: " << temperatureSet.temperatureCelcius << " °C" << std::endl; #endif } void RwHandler::handleGetTelemetryReply(const uint8_t* packet) { - PoolReadGuard rg(&tmDataset); - uint8_t offset = 2; - tmDataset.lastResetStatus = *(packet + offset); - offset += 1; - tmDataset.mcuTemperature = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.pressureSensorTemperature = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.pressure = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.rwState = *(packet + offset); - offset += 1; - tmDataset.rwClcMode = *(packet + offset); - offset += 1; - tmDataset.rwCurrSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.rwRefSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.numOfInvalidCrcPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.numOfInvalidLenPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.numOfInvalidCmdPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.numOfCmdExecutedReplies = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.numOfCmdReplies = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.uartNumOfBytesWritten = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.uartNumOfBytesRead = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.uartNumOfParityErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.uartNumOfNoiseErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.uartNumOfFrameErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.uartNumOfRegisterOverrunErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.uartTotalNumOfErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.spiNumOfBytesWritten = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.spiNumOfBytesRead = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.spiNumOfRegisterOverrunErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.spiTotalNumOfErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); + PoolReadGuard rg(&tmDataset); + uint8_t offset = 2; + tmDataset.lastResetStatus = *(packet + offset); + offset += 1; + tmDataset.mcuTemperature = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.pressureSensorTemperature = *(packet + offset + 3) << 24 | + *(packet + offset + 2) << 16 | *(packet + offset + 1) << 8 | + *(packet + offset); + offset += 4; + tmDataset.pressure = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.rwState = *(packet + offset); + offset += 1; + tmDataset.rwClcMode = *(packet + offset); + offset += 1; + tmDataset.rwCurrSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.rwRefSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.numOfInvalidCrcPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.numOfInvalidLenPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.numOfInvalidCmdPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.numOfCmdExecutedReplies = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.numOfCmdReplies = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartNumOfBytesWritten = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartNumOfBytesRead = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartNumOfParityErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartNumOfNoiseErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartNumOfFrameErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartNumOfRegisterOverrunErrors = *(packet + offset + 3) << 24 | + *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartTotalNumOfErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.spiNumOfBytesWritten = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.spiNumOfBytesRead = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.spiNumOfRegisterOverrunErrors = *(packet + offset + 3) << 24 | + *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.spiTotalNumOfErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RW == 1 - sif::info << "RwHandler::handleTemperatureReply: Last reset status: " + sif::info << "RwHandler::handleTemperatureReply: Last reset status: " << static_cast(tmDataset.lastResetStatus.value) << std::endl; - sif::info << "RwHandler::handleTemperatureReply: MCU temperature: " << tmDataset.mcuTemperature + sif::info << "RwHandler::handleTemperatureReply: MCU temperature: " << tmDataset.mcuTemperature << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Pressure sensor temperature: " + sif::info << "RwHandler::handleTemperatureReply: Pressure sensor temperature: " << tmDataset.pressureSensorTemperature << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Pressure " - << tmDataset.pressure << std::endl; - sif::info << "RwHandler::handleTemperatureReply: State: " + sif::info << "RwHandler::handleTemperatureReply: Pressure " << tmDataset.pressure << std::endl; + sif::info << "RwHandler::handleTemperatureReply: State: " << static_cast(tmDataset.rwState.value) << std::endl; - sif::info << "RwHandler::handleTemperatureReply: CLC mode: " + sif::info << "RwHandler::handleTemperatureReply: CLC mode: " << static_cast(tmDataset.rwClcMode.value) << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Current speed: " << tmDataset.rwCurrSpeed + sif::info << "RwHandler::handleTemperatureReply: Current speed: " << tmDataset.rwCurrSpeed << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Reference speed: " << tmDataset.rwRefSpeed + sif::info << "RwHandler::handleTemperatureReply: Reference speed: " << tmDataset.rwRefSpeed << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Number of invalid CRC packets: " + sif::info << "RwHandler::handleTemperatureReply: Number of invalid CRC packets: " << tmDataset.numOfInvalidCrcPackets << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Number of invalid length packets: " + sif::info << "RwHandler::handleTemperatureReply: Number of invalid length packets: " << tmDataset.numOfInvalidLenPackets << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Number of invalid command packets: " + sif::info << "RwHandler::handleTemperatureReply: Number of invalid command packets: " << tmDataset.numOfInvalidCmdPackets << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Number of command executed replies: " + sif::info << "RwHandler::handleTemperatureReply: Number of command executed replies: " << tmDataset.numOfCmdExecutedReplies << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Number of command replies: " + sif::info << "RwHandler::handleTemperatureReply: Number of command replies: " << tmDataset.numOfCmdReplies << std::endl; - sif::info << "RwHandler::handleTemperatureReply: UART number of bytes written: " + sif::info << "RwHandler::handleTemperatureReply: UART number of bytes written: " << tmDataset.uartNumOfBytesWritten << std::endl; - sif::info << "RwHandler::handleTemperatureReply: UART number of bytes read: " + sif::info << "RwHandler::handleTemperatureReply: UART number of bytes read: " << tmDataset.uartNumOfBytesRead << std::endl; - sif::info << "RwHandler::handleTemperatureReply: UART number of parity errors: " + sif::info << "RwHandler::handleTemperatureReply: UART number of parity errors: " << tmDataset.uartNumOfParityErrors << std::endl; - sif::info << "RwHandler::handleTemperatureReply: UART number of noise errors: " + sif::info << "RwHandler::handleTemperatureReply: UART number of noise errors: " << tmDataset.uartNumOfNoiseErrors << std::endl; - sif::info << "RwHandler::handleTemperatureReply: UART number of frame errors: " + sif::info << "RwHandler::handleTemperatureReply: UART number of frame errors: " << tmDataset.uartNumOfFrameErrors << std::endl; - sif::info << "RwHandler::handleTemperatureReply: UART number of register overrun errors: " + sif::info << "RwHandler::handleTemperatureReply: UART number of register overrun errors: " << tmDataset.uartNumOfRegisterOverrunErrors << std::endl; - sif::info << "RwHandler::handleTemperatureReply: UART number of total errors: " + sif::info << "RwHandler::handleTemperatureReply: UART number of total errors: " << tmDataset.uartTotalNumOfErrors << std::endl; - sif::info << "RwHandler::handleTemperatureReply: SPI number of bytes written: " + sif::info << "RwHandler::handleTemperatureReply: SPI number of bytes written: " << tmDataset.spiNumOfBytesWritten << std::endl; - sif::info << "RwHandler::handleTemperatureReply: SPI number of bytes read: " + sif::info << "RwHandler::handleTemperatureReply: SPI number of bytes read: " << tmDataset.spiNumOfBytesRead << std::endl; - sif::info << "RwHandler::handleTemperatureReply: SPI number of register overrun errors: " + sif::info << "RwHandler::handleTemperatureReply: SPI number of register overrun errors: " << tmDataset.spiNumOfRegisterOverrunErrors << std::endl; - sif::info << "RwHandler::handleTemperatureReply: SPI number of register total errors: " + sif::info << "RwHandler::handleTemperatureReply: SPI number of register total errors: " << tmDataset.spiTotalNumOfErrors << std::endl; #endif } diff --git a/mission/devices/RwHandler.h b/mission/devices/RwHandler.h index 57895ca6..31b88e01 100644 --- a/mission/devices/RwHandler.h +++ b/mission/devices/RwHandler.h @@ -2,8 +2,8 @@ #define MISSION_DEVICES_RWHANDLER_H_ #include -#include #include +#include #include /** @@ -16,141 +16,135 @@ * * @author J. Meier */ -class RwHandler: public DeviceHandlerBase { -public: +class RwHandler : public DeviceHandlerBase { + public: + /** + * @brief Constructor + * + * @param objectId + * @param comIF + * @param comCookie + * @param gpioComIF Pointer to gpio communication interface + * @param enablePin GPIO connected to the enable pin of the reaction wheels. Must be pulled + * to high to enable the device. + */ + RwHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, LinuxLibgpioIF* gpioComIF, + gpioId_t enableGpio); + virtual ~RwHandler(); - /** - * @brief Constructor - * - * @param objectId - * @param comIF - * @param comCookie - * @param gpioComIF Pointer to gpio communication interface - * @param enablePin GPIO connected to the enable pin of the reaction wheels. Must be pulled - * to high to enable the device. - */ - RwHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie, - LinuxLibgpioIF* gpioComIF, gpioId_t enableGpio); - virtual ~RwHandler(); + static const uint8_t INTERFACE_ID = CLASS_ID::RW_HANDLER; - static const uint8_t INTERFACE_ID = CLASS_ID::RW_HANDLER; + static const ReturnValue_t SPI_WRITE_FAILURE = MAKE_RETURN_CODE(0xB0); + //! [EXPORT] : [COMMENT] Used by the spi send function to tell a failing read call + static const ReturnValue_t SPI_READ_FAILURE = MAKE_RETURN_CODE(0xB1); + //! [EXPORT] : [COMMENT] Can be used by the HDLC decoding mechanism to inform about a missing + //! start sign 0x7E + static const ReturnValue_t MISSING_START_SIGN = MAKE_RETURN_CODE(0xB2); + //! [EXPORT] : [COMMENT] Can be used by the HDLC decoding mechanism to inform about an invalid + //! substitution combination + static const ReturnValue_t INVALID_SUBSTITUTE = MAKE_RETURN_CODE(0xB3); + //! [EXPORT] : [COMMENT] HDLC decoding mechanism never receives the end sign 0x7E + static const ReturnValue_t MISSING_END_SIGN = MAKE_RETURN_CODE(0xB4); + //! [EXPORT] : [COMMENT] Reaction wheel only responds with empty frames. + static const ReturnValue_t NO_REPLY = MAKE_RETURN_CODE(0xB5); + //! [EXPORT] : [COMMENT] Expected a start marker as first byte + static const ReturnValue_t NO_START_MARKER = MAKE_RETURN_CODE(0xB6); - static const ReturnValue_t SPI_WRITE_FAILURE = MAKE_RETURN_CODE(0xB0); - //! [EXPORT] : [COMMENT] Used by the spi send function to tell a failing read call - static const ReturnValue_t SPI_READ_FAILURE = MAKE_RETURN_CODE(0xB1); - //! [EXPORT] : [COMMENT] Can be used by the HDLC decoding mechanism to inform about a missing start sign 0x7E - static const ReturnValue_t MISSING_START_SIGN = MAKE_RETURN_CODE(0xB2); - //! [EXPORT] : [COMMENT] Can be used by the HDLC decoding mechanism to inform about an invalid substitution combination - static const ReturnValue_t INVALID_SUBSTITUTE = MAKE_RETURN_CODE(0xB3); - //! [EXPORT] : [COMMENT] HDLC decoding mechanism never receives the end sign 0x7E - static const ReturnValue_t MISSING_END_SIGN = MAKE_RETURN_CODE(0xB4); - //! [EXPORT] : [COMMENT] Reaction wheel only responds with empty frames. - static const ReturnValue_t NO_REPLY = MAKE_RETURN_CODE(0xB5); - //! [EXPORT] : [COMMENT] Expected a start marker as first byte - static const ReturnValue_t NO_START_MARKER = MAKE_RETURN_CODE(0xB6); + 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; -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; + private: + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::RW_HANDLER; -private: + //! [EXPORT] : [COMMENT] Action Message with invalid speed was received. Valid speeds must be in + //! the range of [-65000; 1000] or [1000; 65000] + static const ReturnValue_t INVALID_SPEED = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] Action Message with invalid ramp time was received. + static const ReturnValue_t INVALID_RAMP_TIME = MAKE_RETURN_CODE(0xA1); + //! [EXPORT] : [COMMENT] Received set speed command has invalid length. Should be 6. + static const ReturnValue_t SET_SPEED_COMMAND_INVALID_LENGTH = MAKE_RETURN_CODE(0xA2); + //! [EXPORT] : [COMMENT] Command execution failed + static const ReturnValue_t EXECUTION_FAILED = MAKE_RETURN_CODE(0xA3); + //! [EXPORT] : [COMMENT] Reaction wheel reply has invalid crc + static const ReturnValue_t CRC_ERROR = MAKE_RETURN_CODE(0xA4); - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::RW_HANDLER; + //! [EXPORT] : [COMMENT] Reaction wheel signals an error state + static const Event ERROR_STATE = MAKE_EVENT(1, severity::HIGH); - //! [EXPORT] : [COMMENT] Action Message with invalid speed was received. Valid speeds must be in the range of [-65000; 1000] or [1000; 65000] - static const ReturnValue_t INVALID_SPEED = MAKE_RETURN_CODE(0xA0); - //! [EXPORT] : [COMMENT] Action Message with invalid ramp time was received. - static const ReturnValue_t INVALID_RAMP_TIME = MAKE_RETURN_CODE(0xA1); - //! [EXPORT] : [COMMENT] Received set speed command has invalid length. Should be 6. - static const ReturnValue_t SET_SPEED_COMMAND_INVALID_LENGTH = MAKE_RETURN_CODE(0xA2); - //! [EXPORT] : [COMMENT] Command execution failed - static const ReturnValue_t EXECUTION_FAILED = MAKE_RETURN_CODE(0xA3); - //! [EXPORT] : [COMMENT] Reaction wheel reply has invalid crc - static const ReturnValue_t CRC_ERROR = MAKE_RETURN_CODE(0xA4); + LinuxLibgpioIF* gpioComIF = nullptr; + gpioId_t enableGpio = gpio::NO_GPIO; - //! [EXPORT] : [COMMENT] Reaction wheel signals an error state - static const Event ERROR_STATE = MAKE_EVENT(1, severity::HIGH); + RwDefinitions::TemperatureSet temperatureSet; + RwDefinitions::StatusSet statusSet; + RwDefinitions::LastResetSatus lastResetStatusSet; + RwDefinitions::TmDataset tmDataset; - LinuxLibgpioIF* gpioComIF = nullptr; - gpioId_t enableGpio = gpio::NO_GPIO; + uint8_t commandBuffer[RwDefinitions::MAX_CMD_SIZE]; - RwDefinitions::TemperatureSet temperatureSet; - RwDefinitions::StatusSet statusSet; - RwDefinitions::LastResetSatus lastResetStatusSet; - RwDefinitions::TmDataset tmDataset; + enum class InternalState { GET_RESET_STATUS, CLEAR_RESET_STATUS, READ_TEMPERATURE, GET_RW_SATUS }; + InternalState internalState = InternalState::GET_RESET_STATUS; - uint8_t commandBuffer[RwDefinitions::MAX_CMD_SIZE]; + size_t sizeOfReply = 0; - enum class InternalState { - GET_RESET_STATUS, - CLEAR_RESET_STATUS, - READ_TEMPERATURE, - GET_RW_SATUS - }; + /** + * @brief This function can be used to build commands which do not contain any data apart + * from the command id and the CRC. + * @param commandId The command id of the command to build. + */ + void prepareSimpleCommand(DeviceCommandId_t id); - InternalState internalState = InternalState::GET_RESET_STATUS; + /** + * @brief This function checks if the receiced speed and ramp time to set are in a valid + * range. + * @return RETURN_OK if successful, otherwise error code. + */ + ReturnValue_t checkSpeedAndRampTime(const uint8_t* commandData, size_t commandDataLen); - size_t sizeOfReply = 0; + /** + * @brief This function prepares the set speed command from the commandData received with + * an action message. + */ + void prepareSetSpeedCmd(const uint8_t* commandData, size_t commandDataLen); - /** - * @brief This function can be used to build commands which do not contain any data apart - * from the command id and the CRC. - * @param commandId The command id of the command to build. - */ - void prepareSimpleCommand(DeviceCommandId_t id); + /** + * @brief This function writes the last reset status retrieved with the get last reset status + * command into the reset status dataset. + * + * @param packet Pointer to the buffer holding the reply data. + */ + void handleResetStatusReply(const uint8_t* packet); - /** - * @brief This function checks if the receiced speed and ramp time to set are in a valid - * range. - * @return RETURN_OK if successful, otherwise error code. - */ - ReturnValue_t checkSpeedAndRampTime(const uint8_t * commandData, size_t commandDataLen); + /** + * @brief This function handles the reply of the get temperature command. + * + * @param packet Pointer to the reply data + */ + void handleTemperatureReply(const uint8_t* packet); - /** - * @brief This function prepares the set speed command from the commandData received with - * an action message. - */ - void prepareSetSpeedCmd(const uint8_t * commandData, size_t commandDataLen); + /** + * @brief This function fills the status set with the data from the get-status-reply. + */ + void handleGetRwStatusReply(const uint8_t* packet); - /** - * @brief This function writes the last reset status retrieved with the get last reset status - * command into the reset status dataset. - * - * @param packet Pointer to the buffer holding the reply data. - */ - void handleResetStatusReply(const uint8_t* packet); - - /** - * @brief This function handles the reply of the get temperature command. - * - * @param packet Pointer to the reply data - */ - void handleTemperatureReply(const uint8_t* packet); - - /** - * @brief This function fills the status set with the data from the get-status-reply. - */ - void handleGetRwStatusReply(const uint8_t* packet); - - /** - * @brief This function fills the tmDataset with the reply data requested with get telemetry - * command. - */ - void handleGetTelemetryReply(const uint8_t* packet); + /** + * @brief This function fills the tmDataset with the reply data requested with get telemetry + * command. + */ + void handleGetTelemetryReply(const uint8_t* packet); }; #endif /* MISSION_DEVICES_RWHANDLER_H_ */ diff --git a/mission/devices/SyrlinksHkHandler.cpp b/mission/devices/SyrlinksHkHandler.cpp index 9f359bd1..8694f261 100644 --- a/mission/devices/SyrlinksHkHandler.cpp +++ b/mission/devices/SyrlinksHkHandler.cpp @@ -1,464 +1,451 @@ +#include +#include +#include + #include "OBSWConfig.h" -#include -#include -#include - - -SyrlinksHkHandler::SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - DeviceHandlerBase(objectId, comIF, comCookie), rxDataset(this), txDataset(this) { - if (comCookie == NULL) { - sif::error << "SyrlinksHkHandler: Invalid com cookie" << std::endl; - } +SyrlinksHkHandler::SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie) + : DeviceHandlerBase(objectId, comIF, comCookie), rxDataset(this), txDataset(this) { + if (comCookie == NULL) { + sif::error << "SyrlinksHkHandler: Invalid com cookie" << std::endl; + } } -SyrlinksHkHandler::~SyrlinksHkHandler() { +SyrlinksHkHandler::~SyrlinksHkHandler() {} + +void SyrlinksHkHandler::doStartUp() { + if (mode == _MODE_START_UP) { + setMode(MODE_ON); + } } +void SyrlinksHkHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } -void SyrlinksHkHandler::doStartUp(){ - if(mode == _MODE_START_UP){ - setMode(MODE_ON); - } -} - -void SyrlinksHkHandler::doShutDown(){ - setMode(_MODE_POWER_DOWN); -} - -ReturnValue_t SyrlinksHkHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - switch (nextCommand) { - case(SYRLINKS::READ_RX_STATUS_REGISTERS): - *id = SYRLINKS::READ_RX_STATUS_REGISTERS; - nextCommand = SYRLINKS::READ_TX_STATUS; - break; - case(SYRLINKS::READ_TX_STATUS): - *id = SYRLINKS::READ_TX_STATUS; - nextCommand = SYRLINKS::READ_TX_WAVEFORM; - break; - case(SYRLINKS::READ_TX_WAVEFORM): - *id = SYRLINKS::READ_TX_WAVEFORM; - nextCommand = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE; - break; - case(SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): - *id = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE; - nextCommand = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE; - break; - case(SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): - *id = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE; - nextCommand = SYRLINKS::READ_RX_STATUS_REGISTERS; - break; +ReturnValue_t SyrlinksHkHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + switch (nextCommand) { + case (SYRLINKS::READ_RX_STATUS_REGISTERS): + *id = SYRLINKS::READ_RX_STATUS_REGISTERS; + nextCommand = SYRLINKS::READ_TX_STATUS; + break; + case (SYRLINKS::READ_TX_STATUS): + *id = SYRLINKS::READ_TX_STATUS; + nextCommand = SYRLINKS::READ_TX_WAVEFORM; + break; + case (SYRLINKS::READ_TX_WAVEFORM): + *id = SYRLINKS::READ_TX_WAVEFORM; + nextCommand = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE; + break; + case (SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): + *id = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE; + nextCommand = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE; + break; + case (SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): + *id = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE; + nextCommand = SYRLINKS::READ_RX_STATUS_REGISTERS; + break; default: - sif::debug << "SyrlinksHkHandler::buildNormalDeviceCommand: rememberCommandId has invalid" - << "command id" << std::endl; - break; + sif::debug << "SyrlinksHkHandler::buildNormalDeviceCommand: rememberCommandId has invalid" + << "command id" << std::endl; + break; + } + return buildCommandFromCommand(*id, NULL, 0); +} + +ReturnValue_t SyrlinksHkHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t* commandData, + size_t commandDataLen) { + switch (deviceCommand) { + case (SYRLINKS::RESET_UNIT): { + resetCommand.copy(reinterpret_cast(commandBuffer), resetCommand.size(), 0); + rawPacketLen = resetCommand.size(); + rawPacket = commandBuffer; + return RETURN_OK; } - return buildCommandFromCommand(*id, NULL, 0); -} - -ReturnValue_t SyrlinksHkHandler::buildTransitionDeviceCommand( - DeviceCommandId_t * id){ - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t * commandData, - size_t commandDataLen) { - switch(deviceCommand) { - case(SYRLINKS::RESET_UNIT): { - resetCommand.copy(reinterpret_cast(commandBuffer), resetCommand.size(), 0); - rawPacketLen = resetCommand.size(); - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::SET_TX_MODE_STANDBY): { - setTxModeStandby.copy(reinterpret_cast(commandBuffer), setTxModeStandby.size(), 0); - rawPacketLen = setTxModeStandby.size(); - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::SET_TX_MODE_MODULATION): { - setTxModeModulation.copy(reinterpret_cast(commandBuffer), setTxModeModulation.size(), 0); - rawPacketLen = setTxModeModulation.size(); - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::SET_TX_MODE_CW): { - setTxModeCw.copy(reinterpret_cast(commandBuffer), setTxModeCw.size(), 0); - rawPacketLen = setTxModeCw.size(); - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::READ_RX_STATUS_REGISTERS): { - readRxStatusRegCommand.copy(reinterpret_cast(commandBuffer), readRxStatusRegCommand.size(), 0); - rawPacketLen = readRxStatusRegCommand.size(); - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::READ_TX_STATUS): { - readTxStatus.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); - rawPacketLen = readTxStatus.size(); - rememberCommandId = SYRLINKS::READ_TX_STATUS; - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::READ_TX_WAVEFORM): { - readTxWaveform.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); - rawPacketLen = readTxWaveform.size(); - rememberCommandId = SYRLINKS::READ_TX_WAVEFORM; - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): { - readTxAgcValueHighByte.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); - rawPacketLen = readTxAgcValueHighByte.size(); - rememberCommandId = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE; - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): { - readTxAgcValueLowByte.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); - rawPacketLen = readTxAgcValueLowByte.size(); - rememberCommandId = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE; - rawPacket = commandBuffer; - return RETURN_OK; - } - default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; + case (SYRLINKS::SET_TX_MODE_STANDBY): { + setTxModeStandby.copy(reinterpret_cast(commandBuffer), setTxModeStandby.size(), 0); + rawPacketLen = setTxModeStandby.size(); + rawPacket = commandBuffer; + return RETURN_OK; + } + case (SYRLINKS::SET_TX_MODE_MODULATION): { + setTxModeModulation.copy(reinterpret_cast(commandBuffer), setTxModeModulation.size(), + 0); + rawPacketLen = setTxModeModulation.size(); + rawPacket = commandBuffer; + return RETURN_OK; + } + case (SYRLINKS::SET_TX_MODE_CW): { + setTxModeCw.copy(reinterpret_cast(commandBuffer), setTxModeCw.size(), 0); + rawPacketLen = setTxModeCw.size(); + rawPacket = commandBuffer; + return RETURN_OK; + } + case (SYRLINKS::READ_RX_STATUS_REGISTERS): { + readRxStatusRegCommand.copy(reinterpret_cast(commandBuffer), + readRxStatusRegCommand.size(), 0); + rawPacketLen = readRxStatusRegCommand.size(); + rawPacket = commandBuffer; + return RETURN_OK; + } + case (SYRLINKS::READ_TX_STATUS): { + readTxStatus.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); + rawPacketLen = readTxStatus.size(); + rememberCommandId = SYRLINKS::READ_TX_STATUS; + rawPacket = commandBuffer; + return RETURN_OK; + } + case (SYRLINKS::READ_TX_WAVEFORM): { + readTxWaveform.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); + rawPacketLen = readTxWaveform.size(); + rememberCommandId = SYRLINKS::READ_TX_WAVEFORM; + rawPacket = commandBuffer; + return RETURN_OK; + } + case (SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): { + readTxAgcValueHighByte.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); + rawPacketLen = readTxAgcValueHighByte.size(); + rememberCommandId = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE; + rawPacket = commandBuffer; + return RETURN_OK; + } + case (SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): { + readTxAgcValueLowByte.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); + rawPacketLen = readTxAgcValueLowByte.size(); + rememberCommandId = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE; + rawPacket = commandBuffer; + return RETURN_OK; + } + default: + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } void SyrlinksHkHandler::fillCommandAndReplyMap() { - this->insertInCommandAndReplyMap(SYRLINKS::RESET_UNIT, 1, nullptr, SYRLINKS::ACK_SIZE, false, - true, SYRLINKS::ACK_REPLY); - this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_STANDBY, 1, nullptr, SYRLINKS::ACK_SIZE, - false, true, SYRLINKS::ACK_REPLY); - this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_MODULATION, 1, nullptr, - SYRLINKS::ACK_SIZE, false, true, SYRLINKS::ACK_REPLY); - this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_CW, 1, nullptr, SYRLINKS::ACK_SIZE, - false, true, SYRLINKS::ACK_REPLY); - this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_STATUS, 1, &txDataset, - SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_WAVEFORM, 1, &txDataset, - SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE, 1, &txDataset, - SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE, 1, &txDataset, - SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - this->insertInCommandAndReplyMap(SYRLINKS::READ_RX_STATUS_REGISTERS, 1, &rxDataset, - SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE); + this->insertInCommandAndReplyMap(SYRLINKS::RESET_UNIT, 1, nullptr, SYRLINKS::ACK_SIZE, false, + true, SYRLINKS::ACK_REPLY); + this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_STANDBY, 1, nullptr, SYRLINKS::ACK_SIZE, + false, true, SYRLINKS::ACK_REPLY); + this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_MODULATION, 1, nullptr, SYRLINKS::ACK_SIZE, + false, true, SYRLINKS::ACK_REPLY); + this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_CW, 1, nullptr, SYRLINKS::ACK_SIZE, false, + true, SYRLINKS::ACK_REPLY); + this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_STATUS, 1, &txDataset, + SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_WAVEFORM, 1, &txDataset, + SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE, 1, &txDataset, + SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE, 1, &txDataset, + SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + this->insertInCommandAndReplyMap(SYRLINKS::READ_RX_STATUS_REGISTERS, 1, &rxDataset, + SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE); } -ReturnValue_t SyrlinksHkHandler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { +ReturnValue_t SyrlinksHkHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + if (*start != '<') { + sif::error << "SyrlinksHkHandler::scanForReply: Missing start frame character" << std::endl; + return MISSING_START_FRAME_CHARACTER; + } - if(*start != '<') { - sif::error << "SyrlinksHkHandler::scanForReply: Missing start frame character" << std::endl; - return MISSING_START_FRAME_CHARACTER; - } + switch (*(start + 1)) { + case ('A'): + *foundLen = SYRLINKS::ACK_SIZE; + *foundId = SYRLINKS::ACK_REPLY; + break; + case ('E'): + *foundLen = SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE; + *foundId = SYRLINKS::READ_RX_STATUS_REGISTERS; + break; + case ('R'): + *foundId = rememberCommandId; + *foundLen = SYRLINKS::READ_ONE_REGISTER_REPLY_SIE; + break; + default: + sif::error << "SyrlinksHkHandler::scanForReply: Unknown reply identifier" << std::endl; + result = IGNORE_REPLY_DATA; + break; + } - switch(*(start + 1)) { - case('A'): - *foundLen = SYRLINKS::ACK_SIZE; - *foundId = SYRLINKS::ACK_REPLY; - break; - case('E'): - *foundLen = SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE; - *foundId = SYRLINKS::READ_RX_STATUS_REGISTERS; - break; - case('R'): - *foundId = rememberCommandId; - *foundLen = SYRLINKS::READ_ONE_REGISTER_REPLY_SIE; - break; - default: - sif::error << "SyrlinksHkHandler::scanForReply: Unknown reply identifier" << std::endl; - result = IGNORE_REPLY_DATA; - break; - } - - return result; + return result; } -ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { +ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { + ReturnValue_t result; - ReturnValue_t result; - - switch (id) { + switch (id) { case (SYRLINKS::ACK_REPLY): - result = verifyReply(packet, SYRLINKS::ACK_SIZE); - if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Acknowledgement reply has " - "invalid crc" << std::endl; - return CRC_FAILURE; - } - result = parseReplyStatus(reinterpret_cast(packet + SYRLINKS::MESSAGE_HEADER_SIZE)); - if (result != RETURN_OK) { - return result; - } - break; - case(SYRLINKS::READ_RX_STATUS_REGISTERS): - result = verifyReply(packet, SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE); - if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read rx status registers reply " - << "has invalid crc" << std::endl; - return CRC_FAILURE; - } - parseRxStatusRegistersReply(packet); - break; - case(SYRLINKS::READ_TX_STATUS): - result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx status reply " - << "has invalid crc" << std::endl; - return CRC_FAILURE; - } - parseTxStatusReply(packet); - break; - case(SYRLINKS::READ_TX_WAVEFORM): - result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx waveform reply " - << "has invalid crc" << std::endl; - return CRC_FAILURE; - } - parseTxWaveformReply(packet); - break; - case(SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): - result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx AGC high byte reply " - << "has invalid crc" << std::endl; - return CRC_FAILURE; - } - parseAgcHighByte(packet); - break; - case(SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): - result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx AGC low byte reply " - << "has invalid crc" << std::endl; - return CRC_FAILURE; - } - parseAgcLowByte(packet); - break; - default: { - sif::debug << "SyrlinksHkHandler::interpretDeviceReply: Unknown device reply id" - << std::endl; - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } - } + result = verifyReply(packet, SYRLINKS::ACK_SIZE); + if (result != RETURN_OK) { + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Acknowledgement reply has " + "invalid crc" + << std::endl; + return CRC_FAILURE; + } + result = + parseReplyStatus(reinterpret_cast(packet + SYRLINKS::MESSAGE_HEADER_SIZE)); + if (result != RETURN_OK) { + return result; + } + break; + case (SYRLINKS::READ_RX_STATUS_REGISTERS): + result = verifyReply(packet, SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE); + if (result != RETURN_OK) { + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read rx status registers reply " + << "has invalid crc" << std::endl; + return CRC_FAILURE; + } + parseRxStatusRegistersReply(packet); + break; + case (SYRLINKS::READ_TX_STATUS): + result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + if (result != RETURN_OK) { + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx status reply " + << "has invalid crc" << std::endl; + return CRC_FAILURE; + } + parseTxStatusReply(packet); + break; + case (SYRLINKS::READ_TX_WAVEFORM): + result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + if (result != RETURN_OK) { + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx waveform reply " + << "has invalid crc" << std::endl; + return CRC_FAILURE; + } + parseTxWaveformReply(packet); + break; + case (SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): + result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + if (result != RETURN_OK) { + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx AGC high byte reply " + << "has invalid crc" << std::endl; + return CRC_FAILURE; + } + parseAgcHighByte(packet); + break; + case (SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): + result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + if (result != RETURN_OK) { + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx AGC low byte reply " + << "has invalid crc" << std::endl; + return CRC_FAILURE; + } + parseAgcLowByte(packet); + break; + default: { + sif::debug << "SyrlinksHkHandler::interpretDeviceReply: Unknown device reply id" << std::endl; + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; + } + } - return RETURN_OK; + return RETURN_OK; } LocalPoolDataSetBase* SyrlinksHkHandler::getDataSetHandle(sid_t sid) { - if (sid == rxDataset.getSid()) { - return &rxDataset; - } - else if (sid== txDataset.getSid()) { - return &txDataset; - } - else { - sif::error << "SyrlinksHkHandler::getDataSetHandle: Invalid sid" << std::endl; - return nullptr; - } + if (sid == rxDataset.getSid()) { + return &rxDataset; + } else if (sid == txDataset.getSid()) { + return &txDataset; + } else { + sif::error << "SyrlinksHkHandler::getDataSetHandle: Invalid sid" << std::endl; + return nullptr; + } } std::string SyrlinksHkHandler::convertUint16ToHexString(uint16_t intValue) { - std::stringstream stream; - stream << std::setfill('0') << std::setw(4) << std::hex << std::uppercase << intValue; - return stream.str(); + std::stringstream stream; + stream << std::setfill('0') << std::setw(4) << std::hex << std::uppercase << intValue; + return stream.str(); } uint8_t SyrlinksHkHandler::convertHexStringToUint8(const char* twoChars) { - uint32_t value; - std::string hexString(twoChars, 2); - std::stringstream stream; - stream << std::hex << hexString; - stream >> value; - return static_cast(value); + uint32_t value; + std::string hexString(twoChars, 2); + std::stringstream stream; + stream << std::hex << hexString; + stream >> value; + return static_cast(value); } uint16_t SyrlinksHkHandler::convertHexStringToUint16(const char* fourChars) { - uint16_t value = 0; - value = convertHexStringToUint8(fourChars) << 8 | convertHexStringToUint8(fourChars+2); - return value; + uint16_t value = 0; + value = convertHexStringToUint8(fourChars) << 8 | convertHexStringToUint8(fourChars + 2); + return value; } -uint32_t SyrlinksHkHandler::convertHexStringToUint32(const char* characters, uint8_t numberOfChars) { +uint32_t SyrlinksHkHandler::convertHexStringToUint32(const char* characters, + uint8_t numberOfChars) { + uint32_t value = 0; - uint32_t value = 0; - - switch (numberOfChars) { + switch (numberOfChars) { case 6: - value = convertHexStringToUint8(characters) << 16 - | convertHexStringToUint8(characters + 2) << 8 - | convertHexStringToUint8(characters + 4); - return value; + value = convertHexStringToUint8(characters) << 16 | + convertHexStringToUint8(characters + 2) << 8 | + convertHexStringToUint8(characters + 4); + return value; case 8: - value = convertHexStringToUint8(characters) << 24 - | convertHexStringToUint8(characters + 2) << 16 - | convertHexStringToUint8(characters + 4) << 8 - | convertHexStringToUint8(characters + 4); - return value; + value = convertHexStringToUint8(characters) << 24 | + convertHexStringToUint8(characters + 2) << 16 | + convertHexStringToUint8(characters + 4) << 8 | + convertHexStringToUint8(characters + 4); + return value; default: - sif::debug << "SyrlinksHkHandler::convertHexStringToUint32: Invalid number of characters. " - << "Must be either 6 or 8" << std::endl; - return 0; - } + sif::debug << "SyrlinksHkHandler::convertHexStringToUint32: Invalid number of characters. " + << "Must be either 6 or 8" << std::endl; + return 0; + } } ReturnValue_t SyrlinksHkHandler::parseReplyStatus(const char* status) { - switch (*status) { + switch (*status) { case '0': - return RETURN_OK; + return RETURN_OK; case '1': - sif::debug << "SyrlinksHkHandler::parseReplyStatus: Uart faming or parity error" - << std::endl; - return UART_FRAMIN_OR_PARITY_ERROR_ACK; + sif::debug << "SyrlinksHkHandler::parseReplyStatus: Uart faming or parity error" << std::endl; + return UART_FRAMIN_OR_PARITY_ERROR_ACK; case '2': - sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad character detected" << std::endl; - return BAD_CHARACTER_ACK; + sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad character detected" << std::endl; + return BAD_CHARACTER_ACK; case '3': - sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad parameter value (unexpected value " - << "detected" << std::endl; - return BAD_PARAMETER_VALUE_ACK; + sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad parameter value (unexpected value " + << "detected" << std::endl; + return BAD_PARAMETER_VALUE_ACK; case '4': - sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad end of frame" << std::endl; - return BAD_END_OF_FRAME_ACK; + sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad end of frame" << std::endl; + return BAD_END_OF_FRAME_ACK; case '5': - sif::debug << "SyrlinksHkHandler::parseReplyStatus: Unknown command id or attempt to access" - << " a protected register" << std::endl; - return UNKNOWN_COMMAND_ID_ACK; + sif::debug << "SyrlinksHkHandler::parseReplyStatus: Unknown command id or attempt to access" + << " a protected register" << std::endl; + return UNKNOWN_COMMAND_ID_ACK; case '6': - sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad CRC" << std::endl; - return BAD_CRC_ACK; + sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad CRC" << std::endl; + return BAD_CRC_ACK; default: - sif::debug << "SyrlinksHkHandler::parseReplyStatus: Status reply contains an invalid " - << "status id" << std::endl; - return RETURN_FAILED; - } + sif::debug << "SyrlinksHkHandler::parseReplyStatus: Status reply contains an invalid " + << "status id" << std::endl; + return RETURN_FAILED; + } } ReturnValue_t SyrlinksHkHandler::verifyReply(const uint8_t* packet, uint8_t size) { - int result = 0; - /* Calculate crc from received packet */ - uint16_t crc = CRC::crc16ccitt(packet, size - SYRLINKS::SIZE_CRC_AND_TERMINATION, - CRC_INITIAL_VALUE); - std::string recalculatedCrc = convertUint16ToHexString(crc); + int result = 0; + /* Calculate crc from received packet */ + uint16_t crc = + CRC::crc16ccitt(packet, size - SYRLINKS::SIZE_CRC_AND_TERMINATION, CRC_INITIAL_VALUE); + std::string recalculatedCrc = convertUint16ToHexString(crc); - const char* startOfCrc = reinterpret_cast(packet + size - SYRLINKS::SIZE_CRC_AND_TERMINATION); - const char* endOfCrc = reinterpret_cast(packet + size - 1); + const char* startOfCrc = + reinterpret_cast(packet + size - SYRLINKS::SIZE_CRC_AND_TERMINATION); + const char* endOfCrc = reinterpret_cast(packet + size - 1); - std::string replyCrc(startOfCrc, endOfCrc); + std::string replyCrc(startOfCrc, endOfCrc); - result = recalculatedCrc.compare(replyCrc); - if (result != 0) { - return RETURN_FAILED; - } - return RETURN_OK; + result = recalculatedCrc.compare(replyCrc); + if (result != 0) { + return RETURN_FAILED; + } + return RETURN_OK; } void SyrlinksHkHandler::parseRxStatusRegistersReply(const uint8_t* packet) { - PoolReadGuard readHelper(&rxDataset); - uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; - rxDataset.rxStatus = convertHexStringToUint8(reinterpret_cast(packet + offset)); - offset += 2; - rxDataset.rxSensitivity = convertHexStringToUint32(reinterpret_cast(packet + offset), 6); - offset += 6; - rxDataset.rxFrequencyShift = convertHexStringToUint32(reinterpret_cast(packet + offset), 6); - offset += 6; - rxDataset.rxIqPower = convertHexStringToUint16(reinterpret_cast(packet + offset)); - offset += 4; - rxDataset.rxAgcValue = convertHexStringToUint16(reinterpret_cast(packet + offset)); - offset += 4; - offset += 2; // reserved register - rxDataset.rxDemodEb= convertHexStringToUint32(reinterpret_cast(packet + offset), 6); - offset += 6; - rxDataset.rxDemodN0= convertHexStringToUint32(reinterpret_cast(packet + offset), 6); - offset += 6; - rxDataset.rxDataRate = convertHexStringToUint8(reinterpret_cast(packet + offset)); + PoolReadGuard readHelper(&rxDataset); + uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; + rxDataset.rxStatus = convertHexStringToUint8(reinterpret_cast(packet + offset)); + offset += 2; + rxDataset.rxSensitivity = + convertHexStringToUint32(reinterpret_cast(packet + offset), 6); + offset += 6; + rxDataset.rxFrequencyShift = + convertHexStringToUint32(reinterpret_cast(packet + offset), 6); + offset += 6; + rxDataset.rxIqPower = convertHexStringToUint16(reinterpret_cast(packet + offset)); + offset += 4; + rxDataset.rxAgcValue = convertHexStringToUint16(reinterpret_cast(packet + offset)); + offset += 4; + offset += 2; // reserved register + rxDataset.rxDemodEb = convertHexStringToUint32(reinterpret_cast(packet + offset), 6); + offset += 6; + rxDataset.rxDemodN0 = convertHexStringToUint32(reinterpret_cast(packet + offset), 6); + offset += 6; + rxDataset.rxDataRate = convertHexStringToUint8(reinterpret_cast(packet + offset)); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1 - sif::info << "Syrlinks RX Status: 0x" << std::hex << (unsigned int)rxDataset.rxStatus.value << std::endl; - sif::info << "Syrlinks RX Sensitivity: " << std::dec << rxDataset.rxSensitivity << std::endl; - sif::info << "Syrlinks RX Frequency Shift: " << rxDataset.rxFrequencyShift << std::endl; - sif::info << "Syrlinks RX IQ Power: " << rxDataset.rxIqPower << std::endl; - sif::info << "Syrlinks RX AGC Value: " << rxDataset.rxAgcValue << std::endl; - sif::info << "Syrlinks RX Demod Eb: " << rxDataset.rxDemodEb << std::endl; - sif::info << "Syrlinks RX Demod N0: " << rxDataset.rxDemodN0 << std::endl; - sif::info << "Syrlinks RX Datarate: " << (unsigned int)rxDataset.rxDataRate.value << std::endl; + sif::info << "Syrlinks RX Status: 0x" << std::hex << (unsigned int)rxDataset.rxStatus.value + << std::endl; + sif::info << "Syrlinks RX Sensitivity: " << std::dec << rxDataset.rxSensitivity << std::endl; + sif::info << "Syrlinks RX Frequency Shift: " << rxDataset.rxFrequencyShift << std::endl; + sif::info << "Syrlinks RX IQ Power: " << rxDataset.rxIqPower << std::endl; + sif::info << "Syrlinks RX AGC Value: " << rxDataset.rxAgcValue << std::endl; + sif::info << "Syrlinks RX Demod Eb: " << rxDataset.rxDemodEb << std::endl; + sif::info << "Syrlinks RX Demod N0: " << rxDataset.rxDemodN0 << std::endl; + sif::info << "Syrlinks RX Datarate: " << (unsigned int)rxDataset.rxDataRate.value << std::endl; #endif } void SyrlinksHkHandler::parseTxStatusReply(const uint8_t* packet) { - PoolReadGuard readHelper(&txDataset); - uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; - txDataset.txStatus = convertHexStringToUint8(reinterpret_cast(packet + offset)); + PoolReadGuard readHelper(&txDataset); + uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; + txDataset.txStatus = convertHexStringToUint8(reinterpret_cast(packet + offset)); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1 - sif::info << "Syrlinks TX Status: 0x" << std::hex << (unsigned int) txDataset.txStatus.value + sif::info << "Syrlinks TX Status: 0x" << std::hex << (unsigned int)txDataset.txStatus.value << std::endl; #endif } void SyrlinksHkHandler::parseTxWaveformReply(const uint8_t* packet) { - PoolReadGuard readHelper(&txDataset); - uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; - txDataset.txWaveform = convertHexStringToUint8(reinterpret_cast(packet + offset)); + PoolReadGuard readHelper(&txDataset); + uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; + txDataset.txWaveform = convertHexStringToUint8(reinterpret_cast(packet + offset)); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1 - sif::info << "Syrlinks TX Waveform: 0x" << std::hex << (unsigned int) txDataset.txWaveform.value + sif::info << "Syrlinks TX Waveform: 0x" << std::hex << (unsigned int)txDataset.txWaveform.value << std::endl; #endif } void SyrlinksHkHandler::parseAgcLowByte(const uint8_t* packet) { - PoolReadGuard readHelper(&txDataset); - uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; - txDataset.txAgcValue = agcValueHighByte << 8 | convertHexStringToUint8(reinterpret_cast(packet + offset)); + PoolReadGuard readHelper(&txDataset); + uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; + txDataset.txAgcValue = agcValueHighByte << 8 | + convertHexStringToUint8(reinterpret_cast(packet + offset)); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1 - sif::info << "Syrlinks TX AGC Value: " << txDataset.txAgcValue << std::endl; + sif::info << "Syrlinks TX AGC Value: " << txDataset.txAgcValue << std::endl; #endif } void SyrlinksHkHandler::parseAgcHighByte(const uint8_t* packet) { - PoolReadGuard readHelper(&txDataset); - uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; - agcValueHighByte = convertHexStringToUint8(reinterpret_cast(packet + offset)); + PoolReadGuard readHelper(&txDataset); + uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; + agcValueHighByte = convertHexStringToUint8(reinterpret_cast(packet + offset)); } -void SyrlinksHkHandler::setNormalDatapoolEntriesInvalid(){ +void SyrlinksHkHandler::setNormalDatapoolEntriesInvalid() {} -} - -uint32_t SyrlinksHkHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){ - return 500; -} +uint32_t SyrlinksHkHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } ReturnValue_t SyrlinksHkHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { + LocalDataPoolManager& poolManager) { + localDataPoolMap.emplace(SYRLINKS::RX_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::RX_SENSITIVITY, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::RX_FREQUENCY_SHIFT, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::RX_IQ_POWER, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::RX_AGC_VALUE, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::RX_DEMOD_EB, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::RX_DEMOD_N0, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::RX_DATA_RATE, new PoolEntry({0})); - localDataPoolMap.emplace(SYRLINKS::RX_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::RX_SENSITIVITY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::RX_FREQUENCY_SHIFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::RX_IQ_POWER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::RX_AGC_VALUE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::RX_DEMOD_EB, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::RX_DEMOD_N0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::RX_DATA_RATE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(SYRLINKS::TX_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::TX_WAVEFORM, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::TX_AGC_VALUE, new PoolEntry({0})); - localDataPoolMap.emplace(SYRLINKS::TX_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::TX_WAVEFORM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::TX_AGC_VALUE, new PoolEntry( { 0 })); - - return HasReturnvaluesIF::RETURN_OK; -} - -void SyrlinksHkHandler::setModeNormal() { - mode = MODE_NORMAL; + return HasReturnvaluesIF::RETURN_OK; } +void SyrlinksHkHandler::setModeNormal() { mode = MODE_NORMAL; } diff --git a/mission/devices/SyrlinksHkHandler.h b/mission/devices/SyrlinksHkHandler.h index bf8a489a..b2e893b2 100644 --- a/mission/devices/SyrlinksHkHandler.h +++ b/mission/devices/SyrlinksHkHandler.h @@ -13,166 +13,162 @@ * * @author J. Meier */ -class SyrlinksHkHandler: public DeviceHandlerBase { -public: +class SyrlinksHkHandler : public DeviceHandlerBase { + public: + SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + virtual ~SyrlinksHkHandler(); - SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie); - virtual ~SyrlinksHkHandler(); + /** + * @brief Sets mode to MODE_NORMAL. Can be used for debugging. + */ + void setModeNormal(); - /** - * @brief Sets mode to MODE_NORMAL. Can be used for debugging. - */ - void setModeNormal(); + 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; + LocalPoolDataSetBase* getDataSetHandle(sid_t sid) 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; - LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::SYRLINKS_HANDLER; -private: + static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0); + static const ReturnValue_t UART_FRAMIN_OR_PARITY_ERROR_ACK = MAKE_RETURN_CODE(0xA1); + static const ReturnValue_t BAD_CHARACTER_ACK = MAKE_RETURN_CODE(0xA2); + static const ReturnValue_t BAD_PARAMETER_VALUE_ACK = MAKE_RETURN_CODE(0xA3); + static const ReturnValue_t BAD_END_OF_FRAME_ACK = MAKE_RETURN_CODE(0xA4); + static const ReturnValue_t UNKNOWN_COMMAND_ID_ACK = MAKE_RETURN_CODE(0xA5); + static const ReturnValue_t BAD_CRC_ACK = MAKE_RETURN_CODE(0xA6); + static const ReturnValue_t REPLY_WRONG_SIZE = MAKE_RETURN_CODE(0xA7); + static const ReturnValue_t MISSING_START_FRAME_CHARACTER = MAKE_RETURN_CODE(0xA8); - static const uint8_t INTERFACE_ID = CLASS_ID::SYRLINKS_HANDLER; + static const uint8_t CRC_INITIAL_VALUE = 0x0; - static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0); - static const ReturnValue_t UART_FRAMIN_OR_PARITY_ERROR_ACK = MAKE_RETURN_CODE(0xA1); - static const ReturnValue_t BAD_CHARACTER_ACK = MAKE_RETURN_CODE(0xA2); - static const ReturnValue_t BAD_PARAMETER_VALUE_ACK = MAKE_RETURN_CODE(0xA3); - static const ReturnValue_t BAD_END_OF_FRAME_ACK = MAKE_RETURN_CODE(0xA4); - static const ReturnValue_t UNKNOWN_COMMAND_ID_ACK = MAKE_RETURN_CODE(0xA5); - static const ReturnValue_t BAD_CRC_ACK = MAKE_RETURN_CODE(0xA6); - static const ReturnValue_t REPLY_WRONG_SIZE = MAKE_RETURN_CODE(0xA7); - static const ReturnValue_t MISSING_START_FRAME_CHARACTER = MAKE_RETURN_CODE(0xA8); + std::string resetCommand = ""; + std::string readRxStatusRegCommand = ""; + std::string setTxModeStandby = ""; + /** W - write, 04 - 4 bytes in data field, 01 - value, 40 register to write value */ + std::string setTxModeModulation = ""; + std::string setTxModeCw = ""; + std::string readTxStatus = ""; + std::string readTxWaveform = ""; + std::string readTxAgcValueHighByte = ""; + std::string readTxAgcValueLowByte = ""; - static const uint8_t CRC_INITIAL_VALUE = 0x0; + /** + * In some cases it is not possible to extract from the received reply the information about + * the associated command. This variable is thus used to remember the command id. + */ + DeviceCommandId_t rememberCommandId = SYRLINKS::NONE; - std::string resetCommand = ""; - std::string readRxStatusRegCommand = ""; - std::string setTxModeStandby = ""; - /** W - write, 04 - 4 bytes in data field, 01 - value, 40 register to write value */ - std::string setTxModeModulation = ""; - std::string setTxModeCw = ""; - std::string readTxStatus = ""; - std::string readTxWaveform = ""; - std::string readTxAgcValueHighByte = ""; - std::string readTxAgcValueLowByte = ""; + SYRLINKS::RxDataset rxDataset; + SYRLINKS::TxDataset txDataset; - /** - * In some cases it is not possible to extract from the received reply the information about - * the associated command. This variable is thus used to remember the command id. - */ - DeviceCommandId_t rememberCommandId = SYRLINKS::NONE; + uint8_t agcValueHighByte; - SYRLINKS::RxDataset rxDataset; - SYRLINKS::TxDataset txDataset; + uint8_t commandBuffer[SYRLINKS::MAX_COMMAND_SIZE]; - uint8_t agcValueHighByte; + /** + * This object is used to store the id of the next command to execute. This controls the + * read out of multiple registers which can not be fetched with one single command. + */ + DeviceCommandId_t nextCommand = SYRLINKS::READ_RX_STATUS_REGISTERS; - uint8_t commandBuffer[SYRLINKS::MAX_COMMAND_SIZE]; + /** + * @brief This function converts an uint16_t into its hexadecimal string representation. + * + * @param intValue The value to convert. + * + * @return An std::string object containing the hex representation of intValue. + */ + std::string convertUint16ToHexString(uint16_t intValue); - /** - * This object is used to store the id of the next command to execute. This controls the - * read out of multiple registers which can not be fetched with one single command. - */ - DeviceCommandId_t nextCommand = SYRLINKS::READ_RX_STATUS_REGISTERS; + /** + * @brief This function converts a hex number represented by to chars to an 8-bit integer. + * + * @param twoChars Pointer to the two characters representing the hex value. + * + * @details E.g. when twoChars points to an array with the two characters "A5" then the function + * will return 0xA5. + * @return The converted integer. + */ + uint8_t convertHexStringToUint8(const char* twoChars); - /** - * @brief This function converts an uint16_t into its hexadecimal string representation. - * - * @param intValue The value to convert. - * - * @return An std::string object containing the hex representation of intValue. - */ - std::string convertUint16ToHexString(uint16_t intValue); + /** + * @brief This function converts a hex number represented by 4 chars to an uint16_t. + * + * @param Pointer to the fourCharacters representing the 16-bit integer. + * + * @return The uint16_t result. + */ + uint16_t convertHexStringToUint16(const char* fourChars); - /** - * @brief This function converts a hex number represented by to chars to an 8-bit integer. - * - * @param twoChars Pointer to the two characters representing the hex value. - * - * @details E.g. when twoChars points to an array with the two characters "A5" then the function - * will return 0xA5. - * @return The converted integer. - */ - uint8_t convertHexStringToUint8(const char* twoChars); + /** + * @brief Function converts a hex number represented by 6 or 8 characters to an uint32_t. + * + * @param characters Pointer to the hex characters array. + * @param numberOfChars Number of characters representing the hex value. Must be 6 or 8. + * + * @return The uint32_t value. + */ + uint32_t convertHexStringToUint32(const char* characters, uint8_t numberOfChars); - /** - * @brief This function converts a hex number represented by 4 chars to an uint16_t. - * - * @param Pointer to the fourCharacters representing the 16-bit integer. - * - * @return The uint16_t result. - */ - uint16_t convertHexStringToUint16(const char* fourChars); + /** + * @brief This function parses the status reply + * @param status Pointer to the status information. + * + * @details Some commands reply with a status message giving information about the preceding + * command transmission and/or execution was successful. + */ + ReturnValue_t parseReplyStatus(const char* status); - /** - * @brief Function converts a hex number represented by 6 or 8 characters to an uint32_t. - * - * @param characters Pointer to the hex characters array. - * @param numberOfChars Number of characters representing the hex value. Must be 6 or 8. - * - * @return The uint32_t value. - */ - uint32_t convertHexStringToUint32(const char* characters, uint8_t numberOfChars); + /** + * @brief Function verifies the received reply from the syrlinks by recalculating and + * comparing the crc. + * + * @param packet Pointer to the received reply. + * @param size Size of the whole packet including the crc and the packet termination + * character '>'. + * + * @return RETURN_OK if successful, otherwise RETURN_FAILED. + */ + ReturnValue_t verifyReply(const uint8_t* packet, uint8_t size); - /** - * @brief This function parses the status reply - * @param status Pointer to the status information. - * - * @details Some commands reply with a status message giving information about the preceding - * command transmission and/or execution was successful. - */ - ReturnValue_t parseReplyStatus(const char* status); + /** + * @brief This function extracts the data from a rx status registers reply and writes the + * information to the status registers dataset. + * @param packet Pointer to the reply packet. + */ + void parseRxStatusRegistersReply(const uint8_t* packet); - /** - * @brief Function verifies the received reply from the syrlinks by recalculating and - * comparing the crc. - * - * @param packet Pointer to the received reply. - * @param size Size of the whole packet including the crc and the packet termination - * character '>'. - * - * @return RETURN_OK if successful, otherwise RETURN_FAILED. - */ - ReturnValue_t verifyReply(const uint8_t* packet, uint8_t size); + /** + * @brief This function writes the read tx status register to the txStatusDataset. + * @param packet Pointer to the received packet. + */ + void parseTxStatusReply(const uint8_t* packet); - /** - * @brief This function extracts the data from a rx status registers reply and writes the - * information to the status registers dataset. - * @param packet Pointer to the reply packet. - */ - void parseRxStatusRegistersReply(const uint8_t* packet); + /** + * @brief This function writes the received waveform configuration to the txDataset. + */ + void parseTxWaveformReply(const uint8_t* packet); - /** - * @brief This function writes the read tx status register to the txStatusDataset. - * @param packet Pointer to the received packet. - */ - void parseTxStatusReply(const uint8_t* packet); - - /** - * @brief This function writes the received waveform configuration to the txDataset. - */ - void parseTxWaveformReply(const uint8_t* packet); - - /** - * @brief The agc value is split over two registers. The parse agc functions are used to get - * the values from the received reply and write them into the txDataset. - */ - void parseAgcLowByte(const uint8_t* packet); - void parseAgcHighByte(const uint8_t* packet); + /** + * @brief The agc value is split over two registers. The parse agc functions are used to get + * the values from the received reply and write them into the txDataset. + */ + void parseAgcLowByte(const uint8_t* packet); + void parseAgcHighByte(const uint8_t* packet); }; #endif /* MISSION_DEVICES_SYRLINKSHKHANDLER_H_ */ diff --git a/mission/devices/Tmp1075Handler.cpp b/mission/devices/Tmp1075Handler.cpp index 95b8685f..59298851 100644 --- a/mission/devices/Tmp1075Handler.cpp +++ b/mission/devices/Tmp1075Handler.cpp @@ -1,145 +1,124 @@ +#include #include #include -#include -Tmp1075Handler::Tmp1075Handler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie) : - DeviceHandlerBase(objectId, comIF, comCookie), dataset( - this) { - if (comCookie == NULL) { - sif::error << "Tmp1075Handler: Invalid com cookie" << std::endl; - } +Tmp1075Handler::Tmp1075Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie) + : DeviceHandlerBase(objectId, comIF, comCookie), dataset(this) { + if (comCookie == NULL) { + sif::error << "Tmp1075Handler: Invalid com cookie" << std::endl; + } } -Tmp1075Handler::~Tmp1075Handler() { +Tmp1075Handler::~Tmp1075Handler() {} + +void Tmp1075Handler::doStartUp() { + if (mode == _MODE_START_UP) { + setMode(MODE_ON); + } } +void Tmp1075Handler::doShutDown() { setMode(_MODE_POWER_DOWN); } -void Tmp1075Handler::doStartUp(){ - if(mode == _MODE_START_UP){ - setMode(MODE_ON); - } +ReturnValue_t Tmp1075Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + if (communicationStep == CommunicationStep::START_ADC_CONVERSION) { + *id = TMP1075::START_ADC_CONVERSION; + communicationStep = CommunicationStep::GET_TEMPERATURE; + return buildCommandFromCommand(*id, NULL, 0); + } else { + *id = TMP1075::GET_TEMP; + communicationStep = CommunicationStep::START_ADC_CONVERSION; + return buildCommandFromCommand(*id, NULL, 0); + } + return HasReturnvaluesIF::RETURN_OK; } -void Tmp1075Handler::doShutDown(){ - setMode(_MODE_POWER_DOWN); +ReturnValue_t Tmp1075Handler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t Tmp1075Handler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - - if(communicationStep == CommunicationStep::START_ADC_CONVERSION) { - *id = TMP1075::START_ADC_CONVERSION; - communicationStep = CommunicationStep::GET_TEMPERATURE; - return buildCommandFromCommand(*id, NULL, 0); - } - else { - *id = TMP1075::GET_TEMP; - communicationStep = CommunicationStep::START_ADC_CONVERSION; - return buildCommandFromCommand(*id, NULL, 0); - } - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t Tmp1075Handler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, + size_t commandDataLen) { + switch (deviceCommand) { + case (TMP1075::START_ADC_CONVERSION): { + std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); + prepareAdcConversionCommand(); + rawPacket = cmdBuffer; + rawPacketLen = TMP1075::CFGR_CMD_SIZE; + return RETURN_OK; + } + case (TMP1075::GET_TEMP): { + std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); + prepareGetTempCommand(); + rawPacket = cmdBuffer; + rawPacketLen = TMP1075::POINTER_REG_SIZE; + rememberCommandId = TMP1075::GET_TEMP; + return RETURN_OK; + } + default: + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } -ReturnValue_t Tmp1075Handler::buildTransitionDeviceCommand( - DeviceCommandId_t * id){ - return HasReturnvaluesIF::RETURN_OK; +void Tmp1075Handler::fillCommandAndReplyMap() { + this->insertInCommandMap(TMP1075::START_ADC_CONVERSION); + this->insertInCommandAndReplyMap(TMP1075::GET_TEMP, 1, &dataset, TMP1075::GET_TEMP_REPLY_SIZE); } -ReturnValue_t Tmp1075Handler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t * commandData, - size_t commandDataLen) { - switch(deviceCommand) { - case(TMP1075::START_ADC_CONVERSION): { - std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); - prepareAdcConversionCommand(); - rawPacket = cmdBuffer; - rawPacketLen = TMP1075::CFGR_CMD_SIZE; - return RETURN_OK; - } - case(TMP1075::GET_TEMP): { - std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); - prepareGetTempCommand(); - rawPacket = cmdBuffer; - rawPacketLen = TMP1075::POINTER_REG_SIZE; - rememberCommandId = TMP1075::GET_TEMP; - return RETURN_OK; - } - default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; +ReturnValue_t Tmp1075Handler::scanForReply(const uint8_t *start, size_t remainingSize, + DeviceCommandId_t *foundId, size_t *foundLen) { + switch (rememberCommandId) { + case (TMP1075::GET_TEMP): + *foundId = TMP1075::GET_TEMP; + *foundLen = TMP1075::GET_TEMP_REPLY_SIZE; + rememberCommandId = TMP1075::NONE; + break; + default: + return IGNORE_REPLY_DATA; + } + return HasReturnvaluesIF::RETURN_OK; } -void Tmp1075Handler::fillCommandAndReplyMap(){ - this->insertInCommandMap(TMP1075::START_ADC_CONVERSION); - this->insertInCommandAndReplyMap(TMP1075::GET_TEMP, 1, &dataset, - TMP1075::GET_TEMP_REPLY_SIZE); -} - -ReturnValue_t Tmp1075Handler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { - switch(rememberCommandId) { - case(TMP1075::GET_TEMP): - *foundId = TMP1075::GET_TEMP; - *foundLen = TMP1075::GET_TEMP_REPLY_SIZE; - rememberCommandId = TMP1075::NONE; - break; - default: - return IGNORE_REPLY_DATA; - } - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t Tmp1075Handler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { - switch (id) { - case TMP1075::GET_TEMP: { - int16_t tempValueRaw = 0; - tempValueRaw = packet[0] << 4 | packet[1] >> 4; - float tempValue = ((static_cast(tempValueRaw)) * 0.0625); +ReturnValue_t Tmp1075Handler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { + switch (id) { + case TMP1075::GET_TEMP: { + int16_t tempValueRaw = 0; + tempValueRaw = packet[0] << 4 | packet[1] >> 4; + float tempValue = ((static_cast(tempValueRaw)) * 0.0625); #if OBSW_VERBOSE_LEVEL >= 1 - sif::info << "Tmp1075 with object id: 0x" << std::hex << getObjectId() - << ": Temperature: " << tempValue<< " °C" - << std::endl; + sif::info << "Tmp1075 with object id: 0x" << std::hex << getObjectId() + << ": Temperature: " << tempValue << " °C" << std::endl; #endif - ReturnValue_t result = dataset.read(); - if(result == HasReturnvaluesIF::RETURN_OK) { - dataset.temperatureCelcius = tempValue; - dataset.commit(); - } - break; - } + ReturnValue_t result = dataset.read(); + if (result == HasReturnvaluesIF::RETURN_OK) { + dataset.temperatureCelcius = tempValue; + dataset.commit(); + } + break; + } - default: { - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } - - } - return HasReturnvaluesIF::RETURN_OK; + default: { + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; + } + } + return HasReturnvaluesIF::RETURN_OK; } -void Tmp1075Handler::setNormalDatapoolEntriesInvalid(){ +void Tmp1075Handler::setNormalDatapoolEntriesInvalid() {} +void Tmp1075Handler::prepareAdcConversionCommand() { + cmdBuffer[0] = TMP1075::CFGR_ADDR; + cmdBuffer[1] = TMP1075::ONE_SHOT_MODE >> 8; + cmdBuffer[2] = TMP1075::ONE_SHOT_MODE & 0xFF; } -void Tmp1075Handler::prepareAdcConversionCommand(){ - cmdBuffer[0] = TMP1075::CFGR_ADDR; - cmdBuffer[1] = TMP1075::ONE_SHOT_MODE >> 8; - cmdBuffer[2] = TMP1075::ONE_SHOT_MODE & 0xFF; -} +void Tmp1075Handler::prepareGetTempCommand() { cmdBuffer[0] = TMP1075::TEMP_REG_ADDR; } -void Tmp1075Handler::prepareGetTempCommand(){ - cmdBuffer[0] = TMP1075::TEMP_REG_ADDR; -} +uint32_t Tmp1075Handler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } -uint32_t Tmp1075Handler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){ - return 500; +ReturnValue_t Tmp1075Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(TMP1075::TEMPERATURE_C_TMP1075_1, new PoolEntry({0.0})); + return HasReturnvaluesIF::RETURN_OK; } - -ReturnValue_t Tmp1075Handler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { - localDataPoolMap.emplace(TMP1075::TEMPERATURE_C_TMP1075_1, new PoolEntry( { 0.0 })); - return HasReturnvaluesIF::RETURN_OK; -} - diff --git a/mission/devices/Tmp1075Handler.h b/mission/devices/Tmp1075Handler.h index 190ac47f..3077cf1a 100644 --- a/mission/devices/Tmp1075Handler.h +++ b/mission/devices/Tmp1075Handler.h @@ -15,54 +15,46 @@ * * @author J. Meier */ -class Tmp1075Handler: public DeviceHandlerBase { -public: +class Tmp1075Handler : public DeviceHandlerBase { + public: + Tmp1075Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie); + virtual ~Tmp1075Handler(); - Tmp1075Handler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie); - virtual ~Tmp1075Handler(); + 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; -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; + private: + /** + * @brief Function fills cmdBuffer with command to start the adc + * conversion for a new temperature value. + */ + void prepareAdcConversionCommand(); -private: + void prepareGetTempCommand(); - /** - * @brief Function fills cmdBuffer with command to start the adc - * conversion for a new temperature value. - */ - void prepareAdcConversionCommand(); + enum class CommunicationStep { START_ADC_CONVERSION, GET_TEMPERATURE }; - void prepareGetTempCommand(); + TMP1075::Tmp1075Dataset dataset; - enum class CommunicationStep { - START_ADC_CONVERSION, - GET_TEMPERATURE - }; + static const uint8_t MAX_CMD_LEN = 3; - TMP1075::Tmp1075Dataset dataset; - - static const uint8_t MAX_CMD_LEN = 3; - - uint8_t rememberRequestedSize = 0; - uint8_t rememberCommandId = TMP1075::NONE; - uint8_t cmdBuffer[MAX_CMD_LEN]; - CommunicationStep communicationStep = - CommunicationStep::START_ADC_CONVERSION; + uint8_t rememberRequestedSize = 0; + uint8_t rememberCommandId = TMP1075::NONE; + uint8_t cmdBuffer[MAX_CMD_LEN]; + CommunicationStep communicationStep = CommunicationStep::START_ADC_CONVERSION; }; #endif /* MISSION_DEVICES_TMP1075HANDLER_H_ */ diff --git a/mission/devices/devicedefinitions/GPSDefinitions.h b/mission/devices/devicedefinitions/GPSDefinitions.h index aea442a2..ce58f680 100644 --- a/mission/devices/devicedefinitions/GPSDefinitions.h +++ b/mission/devices/devicedefinitions/GPSDefinitions.h @@ -1,8 +1,8 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_GPSDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_GPSDEFINITIONS_H_ -#include "fsfw/devicehandlers/DeviceHandlerIF.h" #include "fsfw/datapoollocal/StaticLocalDataSet.h" +#include "fsfw/devicehandlers/DeviceHandlerIF.h" namespace GpsHyperion { @@ -11,60 +11,53 @@ static constexpr DeviceCommandId_t TRIGGER_RESET_PIN = 5; static constexpr uint32_t DATASET_ID = 0; -enum GpsPoolIds: lp_id_t { - LATITUDE = 0, - LONGITUDE = 1, - ALTITUDE = 2, - SPEED = 3, - FIX_MODE = 4, - SATS_IN_USE = 5, - SATS_IN_VIEW = 6, - UNIX_SECONDS = 7, - YEAR = 8, - MONTH = 9, - DAY = 10, - HOURS = 11, - MINUTES = 12, - SECONDS = 13 +enum GpsPoolIds : lp_id_t { + LATITUDE = 0, + LONGITUDE = 1, + ALTITUDE = 2, + SPEED = 3, + FIX_MODE = 4, + SATS_IN_USE = 5, + SATS_IN_VIEW = 6, + UNIX_SECONDS = 7, + YEAR = 8, + MONTH = 9, + DAY = 10, + HOURS = 11, + MINUTES = 12, + SECONDS = 13 }; -enum GpsFixModes: uint8_t { - INVALID = 0, - NO_FIX = 1, - FIX_2D = 2, - FIX_3D = 3 -}; +enum GpsFixModes : uint8_t { INVALID = 0, NO_FIX = 1, FIX_2D = 2, FIX_3D = 3 }; -} +} // namespace GpsHyperion -class GpsPrimaryDataset: public StaticLocalDataSet<18> { -public: - GpsPrimaryDataset(object_id_t gpsId): - StaticLocalDataSet(sid_t(gpsId, GpsHyperion::DATASET_ID)) { - setAllVariablesReadOnly(); - } +class GpsPrimaryDataset : public StaticLocalDataSet<18> { + public: + GpsPrimaryDataset(object_id_t gpsId) : StaticLocalDataSet(sid_t(gpsId, GpsHyperion::DATASET_ID)) { + setAllVariablesReadOnly(); + } - lp_var_t latitude = lp_var_t(sid.objectId, - GpsHyperion::LATITUDE, this); - lp_var_t longitude = lp_var_t(sid.objectId, - GpsHyperion::LONGITUDE, this); - lp_var_t altitude = lp_var_t(sid.objectId, GpsHyperion::ALTITUDE, this); - lp_var_t speed = lp_var_t(sid.objectId, GpsHyperion::SPEED, this); - lp_var_t fixMode = lp_var_t(sid.objectId, GpsHyperion::FIX_MODE, this); - lp_var_t satInUse = lp_var_t(sid.objectId, GpsHyperion::SATS_IN_USE, this); - lp_var_t satInView = lp_var_t(sid.objectId, GpsHyperion::SATS_IN_VIEW, this); - lp_var_t year = lp_var_t(sid.objectId, GpsHyperion::YEAR, this); - lp_var_t month = lp_var_t(sid.objectId, GpsHyperion::MONTH, this); - lp_var_t day = lp_var_t(sid.objectId, GpsHyperion::DAY, this); - lp_var_t hours = lp_var_t(sid.objectId, GpsHyperion::HOURS, this); - lp_var_t minutes = lp_var_t(sid.objectId, GpsHyperion::MINUTES, this); - lp_var_t seconds = lp_var_t(sid.objectId, GpsHyperion::SECONDS, this); - lp_var_t unixSeconds = lp_var_t(sid.objectId, - GpsHyperion::UNIX_SECONDS, this); -private: - friend class GPSHyperionHandler; - GpsPrimaryDataset(HasLocalDataPoolIF* hkOwner): - StaticLocalDataSet(hkOwner, GpsHyperion::DATASET_ID) {} + lp_var_t latitude = lp_var_t(sid.objectId, GpsHyperion::LATITUDE, this); + lp_var_t longitude = lp_var_t(sid.objectId, GpsHyperion::LONGITUDE, this); + lp_var_t altitude = lp_var_t(sid.objectId, GpsHyperion::ALTITUDE, this); + lp_var_t speed = lp_var_t(sid.objectId, GpsHyperion::SPEED, this); + lp_var_t fixMode = lp_var_t(sid.objectId, GpsHyperion::FIX_MODE, this); + lp_var_t satInUse = lp_var_t(sid.objectId, GpsHyperion::SATS_IN_USE, this); + lp_var_t satInView = lp_var_t(sid.objectId, GpsHyperion::SATS_IN_VIEW, this); + lp_var_t year = lp_var_t(sid.objectId, GpsHyperion::YEAR, this); + lp_var_t month = lp_var_t(sid.objectId, GpsHyperion::MONTH, this); + lp_var_t day = lp_var_t(sid.objectId, GpsHyperion::DAY, this); + lp_var_t hours = lp_var_t(sid.objectId, GpsHyperion::HOURS, this); + lp_var_t minutes = lp_var_t(sid.objectId, GpsHyperion::MINUTES, this); + lp_var_t seconds = lp_var_t(sid.objectId, GpsHyperion::SECONDS, this); + lp_var_t unixSeconds = + lp_var_t(sid.objectId, GpsHyperion::UNIX_SECONDS, this); + + private: + friend class GPSHyperionHandler; + GpsPrimaryDataset(HasLocalDataPoolIF* hkOwner) + : StaticLocalDataSet(hkOwner, GpsHyperion::DATASET_ID) {} }; #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GPSDEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/GomSpacePackets.h b/mission/devices/devicedefinitions/GomSpacePackets.h index d410a3af..e6736255 100644 --- a/mission/devices/devicedefinitions/GomSpacePackets.h +++ b/mission/devices/devicedefinitions/GomSpacePackets.h @@ -2,37 +2,32 @@ #define MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEPACKETS_H_ #include -#include -#include #include +#include +#include #include - /** * @brief This class can be used to generated the command for the CspComIF * to reset the watchdog in a gomspace device. */ class WatchdogResetCommand : public SerialLinkedListAdapter { -public: + public: + WatchdogResetCommand() { setLinks(); } - WatchdogResetCommand() { - setLinks(); - } - -private: - WatchdogResetCommand(const WatchdogResetCommand &command); - void setLinks() { - setStart(&cspPort); - cspPort.setNext(&querySize); - querySize.setNext(&magic); - } - SerializeElement cspPort = GOMSPACE::P60_PORT_GNDWDT_RESET; - SerializeElement querySize = 1; - /* Sending 0x78 to port 9 of a gomspace device resets the ground watchdog */ - SerializeElement magic = 0x78; + private: + WatchdogResetCommand(const WatchdogResetCommand &command); + void setLinks() { + setStart(&cspPort); + cspPort.setNext(&querySize); + querySize.setNext(&magic); + } + SerializeElement cspPort = GOMSPACE::P60_PORT_GNDWDT_RESET; + SerializeElement querySize = 1; + /* Sending 0x78 to port 9 of a gomspace device resets the ground watchdog */ + SerializeElement magic = 0x78; }; - /** * @brief A serial linked list adapter implementation to generate ping * commands for devices supporting the CSP protocol. This command can @@ -44,33 +39,32 @@ private: * transmitted to the target device. */ class CspPingCommand : public SerialLinkedListAdapter { -public: - /** - * @brief Constructor - * - * @param querySize_ The size of bytes replied by the ping request. - * Amounts to the number of bytes send. - * @param data_ Pointer to data which should be sent to the device. - * All data will be sent back by the ping target. - */ - CspPingCommand(const uint8_t* data_, uint16_t querySize_) : - querySize(querySize_), data(data_, querySize_) { - setLinks(); - } + public: + /** + * @brief Constructor + * + * @param querySize_ The size of bytes replied by the ping request. + * Amounts to the number of bytes send. + * @param data_ Pointer to data which should be sent to the device. + * All data will be sent back by the ping target. + */ + CspPingCommand(const uint8_t *data_, uint16_t querySize_) + : querySize(querySize_), data(data_, querySize_) { + setLinks(); + } -private: - CspPingCommand(const CspPingCommand &command); - void setLinks() { - setStart(&cspPort); - cspPort.setNext(&querySize); - querySize.setNext(&data); - } - SerializeElement cspPort = GOMSPACE::PING_PORT; - SerializeElement querySize; - SerializeElement> data; + private: + CspPingCommand(const CspPingCommand &command); + void setLinks() { + setStart(&cspPort); + cspPort.setNext(&querySize); + querySize.setNext(&data); + } + SerializeElement cspPort = GOMSPACE::PING_PORT; + SerializeElement querySize; + SerializeElement> data; }; - /** * @brief A serial linked list adapter implementation of the gs_rparam_query_t * struct defined in rparam.h. Can be used to build the message to set @@ -81,47 +75,49 @@ private: * and the size to query. */ class CspSetParamCommand : public SerialLinkedListAdapter { -public: + public: + CspSetParamCommand(uint16_t querySize_, uint16_t payloadlength_, uint16_t checksum_, + uint16_t seq_, uint16_t total_, uint16_t addr_, const uint8_t *parameter_, + uint8_t parameterCount_) + : querySize(querySize_), + payloadlength(payloadlength_), + checksum(checksum_), + seq(seq_), + total(total_), + addr(addr_), + parameter(parameter_, parameterCount_) { + setLinks(); + } - CspSetParamCommand(uint16_t querySize_, uint16_t payloadlength_, - uint16_t checksum_, uint16_t seq_, uint16_t total_, uint16_t addr_, - const uint8_t* parameter_, uint8_t parameterCount_) : - querySize(querySize_), payloadlength( - payloadlength_), checksum(checksum_), seq(seq_), total( - total_), addr(addr_), parameter(parameter_, parameterCount_) { - setLinks(); - } - -private: - CspSetParamCommand(const CspSetParamCommand &command); - void setLinks() { - setStart(&cspPort); - cspPort.setNext(&querySize); - querySize.setNext(&action); - action.setNext(&tableId); - tableId.setNext(&payloadlength); - payloadlength.setNext(&checksum); - checksum.setNext(&seq); - seq.setNext(&total); - total.setNext(&addr); - addr.setNext(¶meter); - } - SerializeElement cspPort = GOMSPACE::PARAM_PORT; - /* Only a parameter will be set. No data will be queried with this command */ - SerializeElement querySize; - SerializeElement action = 0xFF; // param set - /* We will never set a parameter in a table other than the configuration - * table */ - SerializeElement tableId = 1; - SerializeElement payloadlength; - SerializeElement checksum; - SerializeElement seq; - SerializeElement total; - SerializeElement addr; - SerializeElement> parameter; + private: + CspSetParamCommand(const CspSetParamCommand &command); + void setLinks() { + setStart(&cspPort); + cspPort.setNext(&querySize); + querySize.setNext(&action); + action.setNext(&tableId); + tableId.setNext(&payloadlength); + payloadlength.setNext(&checksum); + checksum.setNext(&seq); + seq.setNext(&total); + total.setNext(&addr); + addr.setNext(¶meter); + } + SerializeElement cspPort = GOMSPACE::PARAM_PORT; + /* Only a parameter will be set. No data will be queried with this command */ + SerializeElement querySize; + SerializeElement action = 0xFF; // param set + /* We will never set a parameter in a table other than the configuration + * table */ + SerializeElement tableId = 1; + SerializeElement payloadlength; + SerializeElement checksum; + SerializeElement seq; + SerializeElement total; + SerializeElement addr; + SerializeElement> parameter; }; - /** * @brief This class can be used to generate a get param command for the * gomspace devices which will be sent to the device communication @@ -131,50 +127,50 @@ private: * and will not be transmitted physically to the target device. */ class CspGetParamCommand : public SerialLinkedListAdapter { -public: - /* The size of the header of a gomspace CSP packet. */ - static const uint8_t GS_HDR_LENGTH = 12; + public: + /* The size of the header of a gomspace CSP packet. */ + static const uint8_t GS_HDR_LENGTH = 12; - CspGetParamCommand(uint16_t querySize_, uint8_t tableId_, - uint16_t addresslength_, uint16_t checksum_, uint16_t seq_, - uint16_t total_, uint16_t addr_) : - querySize(querySize_), tableId(tableId_), addresslength( - addresslength_), checksum(checksum_), seq(seq_), total( - total_), addr(addr_) { - fixedValuesInit(); - setLinks(); - } + CspGetParamCommand(uint16_t querySize_, uint8_t tableId_, uint16_t addresslength_, + uint16_t checksum_, uint16_t seq_, uint16_t total_, uint16_t addr_) + : querySize(querySize_), + tableId(tableId_), + addresslength(addresslength_), + checksum(checksum_), + seq(seq_), + total(total_), + addr(addr_) { + fixedValuesInit(); + setLinks(); + } -private: - CspGetParamCommand(const CspGetParamCommand &command); - void setLinks() { - setStart(&cspPort); - cspPort.setNext(&querySize); - querySize.setNext(&action); - action.setNext(&tableId); - tableId.setNext(&addresslength); - addresslength.setNext(&checksum); - checksum.setNext(&seq); - seq.setNext(&total); - total.setNext(&addr); - } - void fixedValuesInit(){ - cspPort.entry = GOMSPACE::PARAM_PORT; - } - SerializeElement cspPort; - SerializeElement querySize; // size of bytes to query - /* Following information will also be physically transmitted to the target - * device*/ - SerializeElement action = 0x00; // get param - SerializeElement tableId; - SerializeElement addresslength; - SerializeElement checksum; - SerializeElement seq; - SerializeElement total; - SerializeElement addr; + private: + CspGetParamCommand(const CspGetParamCommand &command); + void setLinks() { + setStart(&cspPort); + cspPort.setNext(&querySize); + querySize.setNext(&action); + action.setNext(&tableId); + tableId.setNext(&addresslength); + addresslength.setNext(&checksum); + checksum.setNext(&seq); + seq.setNext(&total); + total.setNext(&addr); + } + void fixedValuesInit() { cspPort.entry = GOMSPACE::PARAM_PORT; } + SerializeElement cspPort; + SerializeElement querySize; // size of bytes to query + /* Following information will also be physically transmitted to the target + * device*/ + SerializeElement action = 0x00; // get param + SerializeElement tableId; + SerializeElement addresslength; + SerializeElement checksum; + SerializeElement seq; + SerializeElement total; + SerializeElement addr; }; - /** * @brief This class can be used to generate a get param command for the * gomspace devices which will be sent to the device communication @@ -184,205 +180,186 @@ private: * and will not be transmitted physically to the target device. */ class RequestFullTableCommand : public SerialLinkedListAdapter { -public: + public: + RequestFullTableCommand(uint16_t querySize_, uint8_t tableId_) + : querySize(querySize_), tableId(tableId_) { + setLinks(); + } - RequestFullTableCommand(uint16_t querySize_, uint8_t tableId_) : - querySize(querySize_), tableId(tableId_) { - setLinks(); - } - -private: - RequestFullTableCommand(const RequestFullTableCommand &command); - void setLinks() { - setStart(&cspPort); - cspPort.setNext(&querySize); - querySize.setNext(&action); - action.setNext(&tableId); - tableId.setNext(&addresslength); - addresslength.setNext(&checksum); - checksum.setNext(&seq); - seq.setNext(&total); - } - SerializeElement cspPort = GOMSPACE::PARAM_PORT; - /** Size of bytes to query (size of csp header + size of table) */ - SerializeElement querySize; - /* Following information will also be physically transmitted to the target - * device*/ - SerializeElement action = 0x00; // get param - SerializeElement tableId; - /* Size of address. Set to 0 to get full table */ - SerializeElement addresslength = 0; - SerializeElement checksum = GOMSPACE::IGNORE_CHECKSUM; - SerializeElement seq = 0; - SerializeElement total = 0; + private: + RequestFullTableCommand(const RequestFullTableCommand &command); + void setLinks() { + setStart(&cspPort); + cspPort.setNext(&querySize); + querySize.setNext(&action); + action.setNext(&tableId); + tableId.setNext(&addresslength); + addresslength.setNext(&checksum); + checksum.setNext(&seq); + seq.setNext(&total); + } + SerializeElement cspPort = GOMSPACE::PARAM_PORT; + /** Size of bytes to query (size of csp header + size of table) */ + SerializeElement querySize; + /* Following information will also be physically transmitted to the target + * device*/ + SerializeElement action = 0x00; // get param + SerializeElement tableId; + /* Size of address. Set to 0 to get full table */ + SerializeElement addresslength = 0; + SerializeElement checksum = GOMSPACE::IGNORE_CHECKSUM; + SerializeElement seq = 0; + SerializeElement total = 0; }; - /** * @brief This class can be used to deserialize replies from gomspace devices * and extract the relevant data. */ class CspGetParamReply : public SerialLinkedListAdapter { -public: - /** - * @brief Constructor - * - * @param payloadBuffer Pointer to a buffer to store the payload data of - * the CSP packet. - * @param payloadBufferSz The size of the payload buffer where the payload - * data will be stored. - */ - CspGetParamReply(uint8_t* payloadBuffer_, uint8_t payloadBufferSz_) : - payload(payloadBuffer_, payloadBufferSz_) { - setLinks(); - } + public: + /** + * @brief Constructor + * + * @param payloadBuffer Pointer to a buffer to store the payload data of + * the CSP packet. + * @param payloadBufferSz The size of the payload buffer where the payload + * data will be stored. + */ + CspGetParamReply(uint8_t *payloadBuffer_, uint8_t payloadBufferSz_) + : payload(payloadBuffer_, payloadBufferSz_) { + setLinks(); + } - uint8_t getAction(){ - return action; - } + uint8_t getAction() { return action; } - uint8_t getTableId(){ - return tableId; - } + uint8_t getTableId() { return tableId; } - uint16_t getLength(){ - return length; - } + uint16_t getLength() { return length; } - uint16_t getAddress(){ - return addr; - } + uint16_t getAddress() { return addr; } -private: - CspGetParamReply(const CspGetParamReply &reply); - void setLinks() { - setStart(&action); - action.setNext(&tableId); - tableId.setNext(&length); - length.setNext(&checksum); - checksum.setNext(&seq); - seq.setNext(&total); - total.setNext(&addr); - addr.setNext(&payload); - } + private: + CspGetParamReply(const CspGetParamReply &reply); + void setLinks() { + setStart(&action); + action.setNext(&tableId); + tableId.setNext(&length); + length.setNext(&checksum); + checksum.setNext(&seq); + seq.setNext(&total); + total.setNext(&addr); + addr.setNext(&payload); + } - SerializeElement action; - SerializeElement tableId; - SerializeElement length; //length of address field + payload data - SerializeElement checksum; - SerializeElement seq; - SerializeElement total; - SerializeElement addr; - SerializeElement> payload; + SerializeElement action; + SerializeElement tableId; + SerializeElement length; // length of address field + payload data + SerializeElement checksum; + SerializeElement seq; + SerializeElement total; + SerializeElement addr; + SerializeElement> payload; }; - /** * @brief This class generates telemetry packets containing data from * CSP get-parameter-replies. */ class ParamReply : public SerialLinkedListAdapter { -public: - /** - * @brief Constructor - * - * @param payloadBuffer Pointer to a buffer to store the payload data of - * the CSP packet. - * @param payloadBufferSz The size of the payload buffer where the payload - * data will be stored. - */ - ParamReply(uint8_t action_, uint8_t tableId_, uint16_t addr_, - uint16_t payloadLength_, uint8_t* payloadBuffer_) : - action(action_), tableId(tableId_), addr(addr_), payloadLength( - payloadLength_), payload(payloadBuffer_, payloadLength) { - setLinks(); - } + public: + /** + * @brief Constructor + * + * @param payloadBuffer Pointer to a buffer to store the payload data of + * the CSP packet. + * @param payloadBufferSz The size of the payload buffer where the payload + * data will be stored. + */ + ParamReply(uint8_t action_, uint8_t tableId_, uint16_t addr_, uint16_t payloadLength_, + uint8_t *payloadBuffer_) + : action(action_), + tableId(tableId_), + addr(addr_), + payloadLength(payloadLength_), + payload(payloadBuffer_, payloadLength) { + setLinks(); + } -private: - ParamReply(const CspGetParamReply &reply); - void setLinks() { - setStart(&action); - action.setNext(&tableId); - tableId.setNext(&addr); - addr.setNext(&payloadLength); - payloadLength.setNext(&payload); - } - SerializeElement action; - SerializeElement tableId; - SerializeElement addr; - SerializeElement payloadLength; - SerializeElement> payload; + private: + ParamReply(const CspGetParamReply &reply); + void setLinks() { + setStart(&action); + action.setNext(&tableId); + tableId.setNext(&addr); + addr.setNext(&payloadLength); + payloadLength.setNext(&payload); + } + SerializeElement action; + SerializeElement tableId; + SerializeElement addr; + SerializeElement payloadLength; + SerializeElement> payload; }; - /** - * @brief This class generates the reply containing data from a full housekeeping table request - * of the PDU2. + * @brief This class generates the reply containing data from a full housekeeping table + * request of the PDU2. */ class Pdu2FullTableReply : public SerialLinkedListAdapter { -public: - /** - * @brief Constructor - * - * @param action_ The command which triggered the full table request. - * @param tableId_ The id of the requested table. - * @param tableDataset_ The dataset holding the table data. - */ - Pdu2FullTableReply(uint8_t action_, uint8_t tableId_, SerializeIF* tableDataset_) : - action(action_), tableId(tableId_), dataset(tableDataset_) { - setLinks(); - } + public: + /** + * @brief Constructor + * + * @param action_ The command which triggered the full table request. + * @param tableId_ The id of the requested table. + * @param tableDataset_ The dataset holding the table data. + */ + Pdu2FullTableReply(uint8_t action_, uint8_t tableId_, SerializeIF *tableDataset_) + : action(action_), tableId(tableId_), dataset(tableDataset_) { + setLinks(); + } -private: - Pdu2FullTableReply(const Pdu2FullTableReply &reply); - void setLinks() { - setStart(&action); - action.setNext(&tableId); - tableId.setNext(&dataset); - } - SerializeElement action; - SerializeElement tableId; - LinkedElement dataset; + private: + Pdu2FullTableReply(const Pdu2FullTableReply &reply); + void setLinks() { + setStart(&action); + action.setNext(&tableId); + tableId.setNext(&dataset); + } + SerializeElement action; + SerializeElement tableId; + LinkedElement dataset; }; - /** * @brief This class helps to unpack information from an action message * to set a parameter in gomspace devices. The action message can be * for example received from the PUS Service 8. */ -class SetParamMessageUnpacker: public SerialLinkedListAdapter { -public: - /* Largest parameter is a uint32_t */ - static const uint32_t MAX_SIZE = 4; +class SetParamMessageUnpacker : public SerialLinkedListAdapter { + public: + /* Largest parameter is a uint32_t */ + static const uint32_t MAX_SIZE = 4; - SetParamMessageUnpacker() { - setLinks(); - } + SetParamMessageUnpacker() { setLinks(); } - uint16_t getAddress() { - return address; - } + uint16_t getAddress() { return address; } - uint8_t* getParameter() { - return parameter->front(); - } + uint8_t *getParameter() { return parameter->front(); } - uint8_t getParameterSize(){ - return parameter->size; - } + uint8_t getParameterSize() { return parameter->size; } -private: - void setLinks() { - setStart(&address); - address.setNext(¶meter); - } - SetParamMessageUnpacker(const SetParamMessageUnpacker &message); - SerializeElement address; - SerializeElement> parameter; + private: + void setLinks() { + setStart(&address); + address.setNext(¶meter); + } + SetParamMessageUnpacker(const SetParamMessageUnpacker &message); + SerializeElement address; + SerializeElement> parameter; }; - /** * @brief This class generates a message which can be sent to the GomspaceDeviceHandler to * command a parameter change. @@ -391,76 +368,64 @@ private: * | memory address | size of parameter value | parameter value | */ class GomspaceSetParamMessage : public SerialLinkedListAdapter { -public: + public: + /* The size of the largest parameter */ + static const uint8_t MAX_SIZE = 4; - /* The size of the largest parameter */ - static const uint8_t MAX_SIZE = 4; + /** + * @brief Constructor + * + * @param memoryAddress The address of the parameter to change in the configuration table. + * @param parameterValue Pointer to the parameter value to set. + * @param parameterSize The size of the parameter. + * + */ + GomspaceSetParamMessage(uint16_t memoryAddress, const uint8_t *parameterValue, + uint8_t parameterSize) + : memoryAddress(memoryAddress), parameterValueBuffer(parameterValue, parameterSize, true) { + setLinks(); + } - /** - * @brief Constructor - * - * @param memoryAddress The address of the parameter to change in the configuration table. - * @param parameterValue Pointer to the parameter value to set. - * @param parameterSize The size of the parameter. - * - */ - GomspaceSetParamMessage(uint16_t memoryAddress, const uint8_t* parameterValue, - uint8_t parameterSize) : - memoryAddress(memoryAddress), parameterValueBuffer(parameterValue, parameterSize, true) { - setLinks(); - } - -private: - GomspaceSetParamMessage(const GomspaceSetParamMessage &reply); - void setLinks() { - setStart(&memoryAddress); - memoryAddress.setNext(¶meterValueBuffer); - } - SerializeElement memoryAddress; - /** - * Parameter can be uint8_t, uint16_t or uint32_t. Thus max size of parameterValueBuffer is - * four bytes. - */ - SerializeElement> parameterValueBuffer; + private: + GomspaceSetParamMessage(const GomspaceSetParamMessage &reply); + void setLinks() { + setStart(&memoryAddress); + memoryAddress.setNext(¶meterValueBuffer); + } + SerializeElement memoryAddress; + /** + * Parameter can be uint8_t, uint16_t or uint32_t. Thus max size of parameterValueBuffer is + * four bytes. + */ + SerializeElement> parameterValueBuffer; }; - /** * @brief This class helps to unpack information from an action message * to get a parameter from gomspace devices. The action message can be * for example received from the PUS Service 8. */ -class GetParamMessageUnpacker: public SerialLinkedListAdapter { -public: +class GetParamMessageUnpacker : public SerialLinkedListAdapter { + public: + GetParamMessageUnpacker() { setLinks(); } - GetParamMessageUnpacker() { - setLinks(); - } + uint8_t getTableId() { return tableId; } - uint8_t getTableId() { - return tableId; - } + uint16_t getAddress() { return address; } - uint16_t getAddress() { - return address; - } + uint8_t getParameterSize() { return parameterSize; } - uint8_t getParameterSize(){ - return parameterSize; - } - - -private: - GetParamMessageUnpacker(const GetParamMessageUnpacker &message); - void setLinks() { - setStart(&tableId); - tableId.setNext(&address); - address.setNext(¶meterSize); - } - SerializeElement tableId; - SerializeElement address; //The memory address offset within the table - /* The size of the requested value (e.g. temperature is a uint16_t value) */ - SerializeElement parameterSize; + private: + GetParamMessageUnpacker(const GetParamMessageUnpacker &message); + void setLinks() { + setStart(&tableId); + tableId.setNext(&address); + address.setNext(¶meterSize); + } + SerializeElement tableId; + SerializeElement address; // The memory address offset within the table + /* The size of the requested value (e.g. temperature is a uint16_t value) */ + SerializeElement parameterSize; }; #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEPACKETS_H_ */ diff --git a/mission/devices/devicedefinitions/GomspaceDefinitions.h b/mission/devices/devicedefinitions/GomspaceDefinitions.h index 0fbbc5b0..a575747f 100644 --- a/mission/devices/devicedefinitions/GomspaceDefinitions.h +++ b/mission/devices/devicedefinitions/GomspaceDefinitions.h @@ -9,12 +9,13 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEDEFINITIONS_H_ -#include -#include -#include #include +#include +#include -namespace GOMSPACE{ +#include + +namespace GOMSPACE { 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; @@ -29,339 +30,337 @@ static const uint8_t P60_PORT_GNDWDT_RESET = 9; * Device commands are derived from the rparam.h of the gomspace lib.. * IDs above 50 are reserved for device specific commands. */ -static const DeviceCommandId_t PING = 1; //!< [EXPORT] : [COMMAND] -static const DeviceCommandId_t NONE = 2; // Set when no command is pending -static const DeviceCommandId_t REBOOT = 4; //!< [EXPORT] : [COMMAND] -static const DeviceCommandId_t GNDWDT_RESET = 9; //!< [EXPORT] : [COMMAND] -static const DeviceCommandId_t PARAM_GET = 0; //!< [EXPORT] : [COMMAND] -static const DeviceCommandId_t PARAM_SET = 255; //!< [EXPORT] : [COMMAND] -static const DeviceCommandId_t REQUEST_HK_TABLE = 16; //!< [EXPORT] : [COMMAND] +static const DeviceCommandId_t PING = 1; //!< [EXPORT] : [COMMAND] +static const DeviceCommandId_t NONE = 2; // Set when no command is pending +static const DeviceCommandId_t REBOOT = 4; //!< [EXPORT] : [COMMAND] +static const DeviceCommandId_t GNDWDT_RESET = 9; //!< [EXPORT] : [COMMAND] +static const DeviceCommandId_t PARAM_GET = 0; //!< [EXPORT] : [COMMAND] +static const DeviceCommandId_t PARAM_SET = 255; //!< [EXPORT] : [COMMAND] +static const DeviceCommandId_t REQUEST_HK_TABLE = 16; //!< [EXPORT] : [COMMAND] //!< [EXPORT] : [COMMAND] Print switch states, voltages and currents to the console static const DeviceCommandId_t PRINT_SWITCH_V_I = 32; - -} +} // namespace GOMSPACE namespace P60System { -enum P60SytemPoolIds: lp_id_t { - P60DOCK_CURRENT_ACU_VCC, - P60DOCK_CURRENT_PDU1_VCC, - P60DOCK_CURRENT_X3_IDLE_VCC, - P60DOCK_CURRENT_PDU2_VCC, - P60DOCK_CURRENT_ACU_VBAT, - P60DOCK_CURRENT_PDU1_VBAT, - P60DOCK_CURRENT_X3_IDLE_VBAT, - P60DOCK_CURRENT_PDU2_VBAT, - P60DOCK_CURRENT_STACK_VBAT, - P60DOCK_CURRENT_STACK_3V3, - P60DOCK_CURRENT_STACK_5V, - P60DOCK_CURRENT_GS3V3, - P60DOCK_CURRENT_GS5V, - P60DOCK_VOLTAGE_ACU_VCC, - P60DOCK_VOLTAGE_PDU1_VCC, - P60DOCK_VOLTAGE_X3_IDLE_VCC, - P60DOCK_VOLTAGE_PDU2_VCC, - P60DOCK_VOLTAGE_ACU_VBAT, - P60DOCK_VOLTAGE_PDU1_VBAT, - P60DOCK_VOLTAGE_X3_IDLE_VBAT, - P60DOCK_VOLTAGE_PDU2_VBAT, - P60DOCK_VOLTAGE_STACK_VBAT, - P60DOCK_VOLTAGE_STACK_3V3, - P60DOCK_VOLTAGE_STACK_5V, - P60DOCK_VOLTAGE_GS3V3, - P60DOCK_VOLTAGE_GS5V, - P60DOCK_OUTPUTENABLE_ACU_VCC, - P60DOCK_OUTPUTENABLE_PDU1_VCC, - P60DOCK_OUTPUTENABLE_X3_IDLE_VCC, - P60DOCK_OUTPUTENABLE_PDU2_VCC, - P60DOCK_OUTPUTENABLE_ACU_VBAT, - P60DOCK_OUTPUTENABLE_PDU1_VBAT, - P60DOCK_OUTPUTENABLE_X3_IDLE_VBAT, - P60DOCK_OUTPUTENABLE_PDU2_VBAT, - P60DOCK_OUTPUTENABLE_STACK_VBAT, - P60DOCK_OUTPUTENABLE_STACK_3V3, - P60DOCK_OUTPUTENABLE_STACK_5V, - P60DOCK_OUTPUTENABLE_GS3V3, - P60DOCK_OUTPUTENABLE_GS5V, - P60DOCK_TEMPERATURE_1, - P60DOCK_TEMPERATURE_2, - P60DOCK_BOOT_CAUSE, - P60DOCK_BOOT_CNT, - P60DOCK_UPTIME, - P60DOCK_RESETCAUSE, - P60DOCK_BATT_MODE, - P60DOCK_HEATER_ON, - P60DOCK_CONV_5V_ENABLE_STATUS, - P60DOCK_LATCHUP_ACU_VCC, - P60DOCK_LATCHUP_PDU1_VCC, - P60DOCK_LATCHUP_X3_IDLE_VCC, - P60DOCK_LATCHUP_PDU2_VCC, - P60DOCK_LATCHUP_ACU_VBAT, - P60DOCK_LATCHUP_PDU1_VBAT, - P60DOCK_LATCHUP_X3_IDLE_VBAT, - P60DOCK_LATCHUP_PDU2_VBAT, - P60DOCK_LATCHUP_STACK_VBAT, - P60DOCK_LATCHUP_STACK_3V3, - P60DOCK_LATCHUP_STACK_5V, - P60DOCK_LATCHUP_GS3V3, - P60DOCK_LATCHUP_GS5V, - P60DOCK_VBAT_VALUE, - P60DOCK_VCC_CURRENT_VALUE, - P60DOCK_BATTERY_CURRENT, - P60DOCK_BATTERY_VOLTAGE, - P60DOCK_BATTERY_TEMPERATURE_1, - P60DOCK_BATTERY_TEMPERATURE_2, - P60DOCK_DEVICE_0, - P60DOCK_DEVICE_1, - P60DOCK_DEVICE_2, - P60DOCK_DEVICE_3, - P60DOCK_DEVICE_4, - P60DOCK_DEVICE_5, - P60DOCK_DEVICE_6, - P60DOCK_DEVICE_7, - P60DOCK_DEVICE_0_STATUS, - P60DOCK_DEVICE_1_STATUS, - P60DOCK_DEVICE_2_STATUS, - P60DOCK_DEVICE_3_STATUS, - P60DOCK_DEVICE_4_STATUS, - P60DOCK_DEVICE_5_STATUS, - P60DOCK_DEVICE_6_STATUS, - P60DOCK_DEVICE_7_STATUS, - P60DOCK_DEVICE_TYPE_GROUP, - P60DOCK_DEVICE_STATUS_GROUP, - P60DOCK_DEARM_STATUS, - P60DOCK_WDT_CNT_GND, - P60DOCK_WDT_CNT_I2C, - P60DOCK_WDT_CNT_CAN, - P60DOCK_WDT_CNT_CSP_1, - P60DOCK_WDT_CNT_CSP_2, - P60DOCK_WDT_GND_LEFT, - P60DOCK_WDT_I2C_LEFT, - P60DOCK_WDT_CAN_LEFT, - P60DOCK_WDT_CSP_LEFT_1, - P60DOCK_WDT_CSP_LEFT_2, - P60DOCK_BATT_CHARGE_CURRENT, - P60DOCK_BATT_DISCHARGE_CURRENT, - P60DOCK_ANT6_DEPL, - P60DOCK_AR6_DEPL, +enum P60SytemPoolIds : lp_id_t { + P60DOCK_CURRENT_ACU_VCC, + P60DOCK_CURRENT_PDU1_VCC, + P60DOCK_CURRENT_X3_IDLE_VCC, + P60DOCK_CURRENT_PDU2_VCC, + P60DOCK_CURRENT_ACU_VBAT, + P60DOCK_CURRENT_PDU1_VBAT, + P60DOCK_CURRENT_X3_IDLE_VBAT, + P60DOCK_CURRENT_PDU2_VBAT, + P60DOCK_CURRENT_STACK_VBAT, + P60DOCK_CURRENT_STACK_3V3, + P60DOCK_CURRENT_STACK_5V, + P60DOCK_CURRENT_GS3V3, + P60DOCK_CURRENT_GS5V, + P60DOCK_VOLTAGE_ACU_VCC, + P60DOCK_VOLTAGE_PDU1_VCC, + P60DOCK_VOLTAGE_X3_IDLE_VCC, + P60DOCK_VOLTAGE_PDU2_VCC, + P60DOCK_VOLTAGE_ACU_VBAT, + P60DOCK_VOLTAGE_PDU1_VBAT, + P60DOCK_VOLTAGE_X3_IDLE_VBAT, + P60DOCK_VOLTAGE_PDU2_VBAT, + P60DOCK_VOLTAGE_STACK_VBAT, + P60DOCK_VOLTAGE_STACK_3V3, + P60DOCK_VOLTAGE_STACK_5V, + P60DOCK_VOLTAGE_GS3V3, + P60DOCK_VOLTAGE_GS5V, + P60DOCK_OUTPUTENABLE_ACU_VCC, + P60DOCK_OUTPUTENABLE_PDU1_VCC, + P60DOCK_OUTPUTENABLE_X3_IDLE_VCC, + P60DOCK_OUTPUTENABLE_PDU2_VCC, + P60DOCK_OUTPUTENABLE_ACU_VBAT, + P60DOCK_OUTPUTENABLE_PDU1_VBAT, + P60DOCK_OUTPUTENABLE_X3_IDLE_VBAT, + P60DOCK_OUTPUTENABLE_PDU2_VBAT, + P60DOCK_OUTPUTENABLE_STACK_VBAT, + P60DOCK_OUTPUTENABLE_STACK_3V3, + P60DOCK_OUTPUTENABLE_STACK_5V, + P60DOCK_OUTPUTENABLE_GS3V3, + P60DOCK_OUTPUTENABLE_GS5V, + P60DOCK_TEMPERATURE_1, + P60DOCK_TEMPERATURE_2, + P60DOCK_BOOT_CAUSE, + P60DOCK_BOOT_CNT, + P60DOCK_UPTIME, + P60DOCK_RESETCAUSE, + P60DOCK_BATT_MODE, + P60DOCK_HEATER_ON, + P60DOCK_CONV_5V_ENABLE_STATUS, + P60DOCK_LATCHUP_ACU_VCC, + P60DOCK_LATCHUP_PDU1_VCC, + P60DOCK_LATCHUP_X3_IDLE_VCC, + P60DOCK_LATCHUP_PDU2_VCC, + P60DOCK_LATCHUP_ACU_VBAT, + P60DOCK_LATCHUP_PDU1_VBAT, + P60DOCK_LATCHUP_X3_IDLE_VBAT, + P60DOCK_LATCHUP_PDU2_VBAT, + P60DOCK_LATCHUP_STACK_VBAT, + P60DOCK_LATCHUP_STACK_3V3, + P60DOCK_LATCHUP_STACK_5V, + P60DOCK_LATCHUP_GS3V3, + P60DOCK_LATCHUP_GS5V, + P60DOCK_VBAT_VALUE, + P60DOCK_VCC_CURRENT_VALUE, + P60DOCK_BATTERY_CURRENT, + P60DOCK_BATTERY_VOLTAGE, + P60DOCK_BATTERY_TEMPERATURE_1, + P60DOCK_BATTERY_TEMPERATURE_2, + P60DOCK_DEVICE_0, + P60DOCK_DEVICE_1, + P60DOCK_DEVICE_2, + P60DOCK_DEVICE_3, + P60DOCK_DEVICE_4, + P60DOCK_DEVICE_5, + P60DOCK_DEVICE_6, + P60DOCK_DEVICE_7, + P60DOCK_DEVICE_0_STATUS, + P60DOCK_DEVICE_1_STATUS, + P60DOCK_DEVICE_2_STATUS, + P60DOCK_DEVICE_3_STATUS, + P60DOCK_DEVICE_4_STATUS, + P60DOCK_DEVICE_5_STATUS, + P60DOCK_DEVICE_6_STATUS, + P60DOCK_DEVICE_7_STATUS, + P60DOCK_DEVICE_TYPE_GROUP, + P60DOCK_DEVICE_STATUS_GROUP, + P60DOCK_DEARM_STATUS, + P60DOCK_WDT_CNT_GND, + P60DOCK_WDT_CNT_I2C, + P60DOCK_WDT_CNT_CAN, + P60DOCK_WDT_CNT_CSP_1, + P60DOCK_WDT_CNT_CSP_2, + P60DOCK_WDT_GND_LEFT, + P60DOCK_WDT_I2C_LEFT, + P60DOCK_WDT_CAN_LEFT, + P60DOCK_WDT_CSP_LEFT_1, + P60DOCK_WDT_CSP_LEFT_2, + P60DOCK_BATT_CHARGE_CURRENT, + P60DOCK_BATT_DISCHARGE_CURRENT, + P60DOCK_ANT6_DEPL, + P60DOCK_AR6_DEPL, - PDU1_CURRENT_OUT_TCS_BOARD_3V3, - PDU1_CURRENT_OUT_SYRLINKS, - PDU1_CURRENT_OUT_STAR_TRACKER, - PDU1_CURRENT_OUT_MGT, - PDU1_CURRENT_OUT_SUS_NOMINAL, - PDU1_CURRENT_OUT_SOLAR_CELL_EXP, - PDU1_CURRENT_OUT_PLOC, - PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, - PDU1_CURRENT_OUT_CHANNEL8, - PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, - PDU1_VOLTAGE_OUT_SYRLINKS, - PDU1_VOLTAGE_OUT_STAR_TRACKER, - PDU1_VOLTAGE_OUT_MGT, - PDU1_VOLTAGE_OUT_SUS_NOMINAL, - PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, - PDU1_VOLTAGE_OUT_PLOC, - PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, - PDU1_VOLTAGE_OUT_CHANNEL8, - PDU1_VCC, - PDU1_VBAT, - PDU1_TEMPERATURE, - PDU1_CONV_EN_1, - PDU1_CONV_EN_2, - PDU1_CONV_EN_3, - PDU1_OUT_EN_TCS_BOARD_3V3, - PDU1_OUT_EN_SYRLINKS, - PDU1_OUT_EN_STAR_TRACKER, - PDU1_OUT_EN_MGT, - PDU1_OUT_EN_SUS_NOMINAL, - PDU1_OUT_EN_SOLAR_CELL_EXP, - PDU1_OUT_EN_PLOC, - PDU1_OUT_EN_ACS_BOARD_SIDE_A, - PDU1_OUT_EN_CHANNEL8, - PDU1_BOOTCAUSE, - PDU1_BOOTCNT, - PDU1_UPTIME, - PDU1_RESETCAUSE, - PDU1_BATT_MODE, - PDU1_LATCHUP_TCS_BOARD_3V3, - PDU1_LATCHUP_SYRLINKS, - PDU1_LATCHUP_STAR_TRACKER, - PDU1_LATCHUP_MGT, - PDU1_LATCHUP_SUS_NOMINAL, - PDU1_LATCHUP_SOLAR_CELL_EXP, - PDU1_LATCHUP_PLOC, - PDU1_LATCHUP_ACS_BOARD_SIDE_A, - PDU1_LATCHUP_CHANNEL8, - PDU1_DEVICE_0, - PDU1_DEVICE_1, - PDU1_DEVICE_2, - PDU1_DEVICE_3, - PDU1_DEVICE_4, - PDU1_DEVICE_5, - PDU1_DEVICE_6, - PDU1_DEVICE_7, - PDU1_DEVICE_0_STATUS, - PDU1_DEVICE_1_STATUS, - PDU1_DEVICE_2_STATUS, - PDU1_DEVICE_3_STATUS, - PDU1_DEVICE_4_STATUS, - PDU1_DEVICE_5_STATUS, - PDU1_DEVICE_6_STATUS, - PDU1_DEVICE_7_STATUS, - PDU1_WDT_CNT_GND, - PDU1_WDT_CNT_I2C, - PDU1_WDT_CNT_CAN, - PDU1_WDT_CNT_CSP1, - PDU1_WDT_CNT_CSP2, - PDU1_WDT_GND_LEFT, - PDU1_WDT_I2C_LEFT, - PDU1_WDT_CAN_LEFT, - PDU1_WDT_CSP_LEFT1, - PDU1_WDT_CSP_LEFT2, + PDU1_CURRENT_OUT_TCS_BOARD_3V3, + PDU1_CURRENT_OUT_SYRLINKS, + PDU1_CURRENT_OUT_STAR_TRACKER, + PDU1_CURRENT_OUT_MGT, + PDU1_CURRENT_OUT_SUS_NOMINAL, + PDU1_CURRENT_OUT_SOLAR_CELL_EXP, + PDU1_CURRENT_OUT_PLOC, + PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, + PDU1_CURRENT_OUT_CHANNEL8, + PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, + PDU1_VOLTAGE_OUT_SYRLINKS, + PDU1_VOLTAGE_OUT_STAR_TRACKER, + PDU1_VOLTAGE_OUT_MGT, + PDU1_VOLTAGE_OUT_SUS_NOMINAL, + PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, + PDU1_VOLTAGE_OUT_PLOC, + PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, + PDU1_VOLTAGE_OUT_CHANNEL8, + PDU1_VCC, + PDU1_VBAT, + PDU1_TEMPERATURE, + PDU1_CONV_EN_1, + PDU1_CONV_EN_2, + PDU1_CONV_EN_3, + PDU1_OUT_EN_TCS_BOARD_3V3, + PDU1_OUT_EN_SYRLINKS, + PDU1_OUT_EN_STAR_TRACKER, + PDU1_OUT_EN_MGT, + PDU1_OUT_EN_SUS_NOMINAL, + PDU1_OUT_EN_SOLAR_CELL_EXP, + PDU1_OUT_EN_PLOC, + PDU1_OUT_EN_ACS_BOARD_SIDE_A, + PDU1_OUT_EN_CHANNEL8, + PDU1_BOOTCAUSE, + PDU1_BOOTCNT, + PDU1_UPTIME, + PDU1_RESETCAUSE, + PDU1_BATT_MODE, + PDU1_LATCHUP_TCS_BOARD_3V3, + PDU1_LATCHUP_SYRLINKS, + PDU1_LATCHUP_STAR_TRACKER, + PDU1_LATCHUP_MGT, + PDU1_LATCHUP_SUS_NOMINAL, + PDU1_LATCHUP_SOLAR_CELL_EXP, + PDU1_LATCHUP_PLOC, + PDU1_LATCHUP_ACS_BOARD_SIDE_A, + PDU1_LATCHUP_CHANNEL8, + PDU1_DEVICE_0, + PDU1_DEVICE_1, + PDU1_DEVICE_2, + PDU1_DEVICE_3, + PDU1_DEVICE_4, + PDU1_DEVICE_5, + PDU1_DEVICE_6, + PDU1_DEVICE_7, + PDU1_DEVICE_0_STATUS, + PDU1_DEVICE_1_STATUS, + PDU1_DEVICE_2_STATUS, + PDU1_DEVICE_3_STATUS, + PDU1_DEVICE_4_STATUS, + PDU1_DEVICE_5_STATUS, + PDU1_DEVICE_6_STATUS, + PDU1_DEVICE_7_STATUS, + PDU1_WDT_CNT_GND, + PDU1_WDT_CNT_I2C, + PDU1_WDT_CNT_CAN, + PDU1_WDT_CNT_CSP1, + PDU1_WDT_CNT_CSP2, + PDU1_WDT_GND_LEFT, + PDU1_WDT_I2C_LEFT, + PDU1_WDT_CAN_LEFT, + PDU1_WDT_CSP_LEFT1, + PDU1_WDT_CSP_LEFT2, - /** PDU2 Ids */ - PDU2_CURRENT_OUT_Q7S, - PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, - PDU2_CURRENT_OUT_RW, - PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, - PDU2_CURRENT_OUT_SUS_REDUNDANT, - PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, - PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, - PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, - PDU2_CURRENT_OUT_PAYLOAD_CAMERA, - PDU2_VOLTAGE_OUT_Q7S, - PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, - PDU2_VOLTAGE_OUT_RW, - PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, - PDU2_VOLTAGE_OUT_SUS_REDUNDANT, - PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, - PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, - PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, - PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, - PDU2_VCC, - PDU2_VBAT, - PDU2_TEMPERATURE, - PDU2_CONV_EN_1, - PDU2_CONV_EN_2, - PDU2_CONV_EN_3, - PDU2_OUT_EN_Q7S, - PDU2_OUT_EN_PAYLOAD_PCDU_CH1, - PDU2_OUT_EN_RW, - PDU2_OUT_EN_TCS_BOARD_HEATER_IN, - PDU2_OUT_EN_SUS_REDUNDANT, - PDU2_OUT_EN_DEPLOYMENT_MECHANISM, - PDU2_OUT_EN_PAYLOAD_PCDU_CH6, - PDU2_OUT_EN_ACS_BOARD_SIDE_B, - PDU2_OUT_EN_PAYLOAD_CAMERA, - PDU2_BOOTCAUSE, - PDU2_BOOTCNT, - PDU2_UPTIME, - PDU2_RESETCAUSE, - PDU2_BATT_MODE, - PDU2_LATCHUP_Q7S, - PDU2_LATCHUP_PAYLOAD_PCDU_CH1, - PDU2_LATCHUP_RW, - PDU2_LATCHUP_TCS_BOARD_HEATER_IN, - PDU2_LATCHUP_SUS_REDUNDANT, - PDU2_LATCHUP_DEPLOYMENT_MECHANISM, - PDU2_LATCHUP_PAYLOAD_PCDU_CH6, - PDU2_LATCHUP_ACS_BOARD_SIDE_B, - PDU2_LATCHUP_PAYLOAD_CAMERA, - PDU2_DEVICE_0, - PDU2_DEVICE_1, - PDU2_DEVICE_2, - PDU2_DEVICE_3, - PDU2_DEVICE_4, - PDU2_DEVICE_5, - PDU2_DEVICE_6, - PDU2_DEVICE_7, - PDU2_DEVICE_0_STATUS, - PDU2_DEVICE_1_STATUS, - PDU2_DEVICE_2_STATUS, - PDU2_DEVICE_3_STATUS, - PDU2_DEVICE_4_STATUS, - PDU2_DEVICE_5_STATUS, - PDU2_DEVICE_6_STATUS, - PDU2_DEVICE_7_STATUS, - PDU2_WDT_CNT_GND, - PDU2_WDT_CNT_I2C, - PDU2_WDT_CNT_CAN, - PDU2_WDT_CNT_CSP1, - PDU2_WDT_CNT_CSP2, - PDU2_WDT_GND_LEFT, - PDU2_WDT_I2C_LEFT, - PDU2_WDT_CAN_LEFT, - PDU2_WDT_CSP_LEFT1, - PDU2_WDT_CSP_LEFT2, + /** PDU2 Ids */ + PDU2_CURRENT_OUT_Q7S, + PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, + PDU2_CURRENT_OUT_RW, + PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, + PDU2_CURRENT_OUT_SUS_REDUNDANT, + PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, + PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, + PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, + PDU2_CURRENT_OUT_PAYLOAD_CAMERA, + PDU2_VOLTAGE_OUT_Q7S, + PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, + PDU2_VOLTAGE_OUT_RW, + PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, + PDU2_VOLTAGE_OUT_SUS_REDUNDANT, + PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, + PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, + PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, + PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, + PDU2_VCC, + PDU2_VBAT, + PDU2_TEMPERATURE, + PDU2_CONV_EN_1, + PDU2_CONV_EN_2, + PDU2_CONV_EN_3, + PDU2_OUT_EN_Q7S, + PDU2_OUT_EN_PAYLOAD_PCDU_CH1, + PDU2_OUT_EN_RW, + PDU2_OUT_EN_TCS_BOARD_HEATER_IN, + PDU2_OUT_EN_SUS_REDUNDANT, + PDU2_OUT_EN_DEPLOYMENT_MECHANISM, + PDU2_OUT_EN_PAYLOAD_PCDU_CH6, + PDU2_OUT_EN_ACS_BOARD_SIDE_B, + PDU2_OUT_EN_PAYLOAD_CAMERA, + PDU2_BOOTCAUSE, + PDU2_BOOTCNT, + PDU2_UPTIME, + PDU2_RESETCAUSE, + PDU2_BATT_MODE, + PDU2_LATCHUP_Q7S, + PDU2_LATCHUP_PAYLOAD_PCDU_CH1, + PDU2_LATCHUP_RW, + PDU2_LATCHUP_TCS_BOARD_HEATER_IN, + PDU2_LATCHUP_SUS_REDUNDANT, + PDU2_LATCHUP_DEPLOYMENT_MECHANISM, + PDU2_LATCHUP_PAYLOAD_PCDU_CH6, + PDU2_LATCHUP_ACS_BOARD_SIDE_B, + PDU2_LATCHUP_PAYLOAD_CAMERA, + PDU2_DEVICE_0, + PDU2_DEVICE_1, + PDU2_DEVICE_2, + PDU2_DEVICE_3, + PDU2_DEVICE_4, + PDU2_DEVICE_5, + PDU2_DEVICE_6, + PDU2_DEVICE_7, + PDU2_DEVICE_0_STATUS, + PDU2_DEVICE_1_STATUS, + PDU2_DEVICE_2_STATUS, + PDU2_DEVICE_3_STATUS, + PDU2_DEVICE_4_STATUS, + PDU2_DEVICE_5_STATUS, + PDU2_DEVICE_6_STATUS, + PDU2_DEVICE_7_STATUS, + PDU2_WDT_CNT_GND, + PDU2_WDT_CNT_I2C, + PDU2_WDT_CNT_CAN, + PDU2_WDT_CNT_CSP1, + PDU2_WDT_CNT_CSP2, + PDU2_WDT_GND_LEFT, + PDU2_WDT_I2C_LEFT, + PDU2_WDT_CAN_LEFT, + PDU2_WDT_CSP_LEFT1, + PDU2_WDT_CSP_LEFT2, - /** ACU Ids */ - ACU_CURRENT_IN_CHANNEL0, - ACU_CURRENT_IN_CHANNEL1, - ACU_CURRENT_IN_CHANNEL2, - ACU_CURRENT_IN_CHANNEL3, - ACU_CURRENT_IN_CHANNEL4, - ACU_CURRENT_IN_CHANNEL5, - ACU_VOLTAGE_IN_CHANNEL0, - ACU_VOLTAGE_IN_CHANNEL1, - ACU_VOLTAGE_IN_CHANNEL2, - ACU_VOLTAGE_IN_CHANNEL3, - ACU_VOLTAGE_IN_CHANNEL4, - ACU_VOLTAGE_IN_CHANNEL5, - ACU_VCC, - ACU_VBAT, - ACU_TEMPERATURE_1, - ACU_TEMPERATURE_2, - ACU_TEMPERATURE_3, - ACU_MPPT_MODE, - ACU_VBOOST_CHANNEL0, - ACU_VBOOST_CHANNEL1, - ACU_VBOOST_CHANNEL2, - ACU_VBOOST_CHANNEL3, - ACU_VBOOST_CHANNEL4, - ACU_VBOOST_CHANNEL5, - ACU_POWER_CHANNEL0, - ACU_POWER_CHANNEL1, - ACU_POWER_CHANNEL2, - ACU_POWER_CHANNEL3, - ACU_POWER_CHANNEL4, - ACU_POWER_CHANNEL5, - ACU_DAC_EN_0, - ACU_DAC_EN_1, - ACU_DAC_EN_2, - ACU_DAC_RAW_0, - ACU_DAC_RAW_1, - ACU_DAC_RAW_2, - ACU_DAC_RAW_3, - ACU_DAC_RAW_4, - ACU_DAC_RAW_5, - ACU_BOOTCAUSE, - ACU_BOOTCNT, - ACU_UPTIME, - ACU_RESET_CAUSE, - ACU_MPPT_TIME, - ACU_MPPT_PERIOD, - ACU_DEVICE_0, - ACU_DEVICE_1, - ACU_DEVICE_2, - ACU_DEVICE_3, - ACU_DEVICE_4, - ACU_DEVICE_5, - ACU_DEVICE_6, - ACU_DEVICE_7, - ACU_DEVICE_0_STATUS, - ACU_DEVICE_1_STATUS, - ACU_DEVICE_2_STATUS, - ACU_DEVICE_3_STATUS, - ACU_DEVICE_4_STATUS, - ACU_DEVICE_5_STATUS, - ACU_DEVICE_6_STATUS, - ACU_DEVICE_7_STATUS, - ACU_WDT_CNT_GND, - ACU_WDT_GND_LEFT + /** ACU Ids */ + ACU_CURRENT_IN_CHANNEL0, + ACU_CURRENT_IN_CHANNEL1, + ACU_CURRENT_IN_CHANNEL2, + ACU_CURRENT_IN_CHANNEL3, + ACU_CURRENT_IN_CHANNEL4, + ACU_CURRENT_IN_CHANNEL5, + ACU_VOLTAGE_IN_CHANNEL0, + ACU_VOLTAGE_IN_CHANNEL1, + ACU_VOLTAGE_IN_CHANNEL2, + ACU_VOLTAGE_IN_CHANNEL3, + ACU_VOLTAGE_IN_CHANNEL4, + ACU_VOLTAGE_IN_CHANNEL5, + ACU_VCC, + ACU_VBAT, + ACU_TEMPERATURE_1, + ACU_TEMPERATURE_2, + ACU_TEMPERATURE_3, + ACU_MPPT_MODE, + ACU_VBOOST_CHANNEL0, + ACU_VBOOST_CHANNEL1, + ACU_VBOOST_CHANNEL2, + ACU_VBOOST_CHANNEL3, + ACU_VBOOST_CHANNEL4, + ACU_VBOOST_CHANNEL5, + ACU_POWER_CHANNEL0, + ACU_POWER_CHANNEL1, + ACU_POWER_CHANNEL2, + ACU_POWER_CHANNEL3, + ACU_POWER_CHANNEL4, + ACU_POWER_CHANNEL5, + ACU_DAC_EN_0, + ACU_DAC_EN_1, + ACU_DAC_EN_2, + ACU_DAC_RAW_0, + ACU_DAC_RAW_1, + ACU_DAC_RAW_2, + ACU_DAC_RAW_3, + ACU_DAC_RAW_4, + ACU_DAC_RAW_5, + ACU_BOOTCAUSE, + ACU_BOOTCNT, + ACU_UPTIME, + ACU_RESET_CAUSE, + ACU_MPPT_TIME, + ACU_MPPT_PERIOD, + ACU_DEVICE_0, + ACU_DEVICE_1, + ACU_DEVICE_2, + ACU_DEVICE_3, + ACU_DEVICE_4, + ACU_DEVICE_5, + ACU_DEVICE_6, + ACU_DEVICE_7, + ACU_DEVICE_0_STATUS, + ACU_DEVICE_1_STATUS, + ACU_DEVICE_2_STATUS, + ACU_DEVICE_3_STATUS, + ACU_DEVICE_4_STATUS, + ACU_DEVICE_5_STATUS, + ACU_DEVICE_6_STATUS, + ACU_DEVICE_7_STATUS, + ACU_WDT_CNT_GND, + ACU_WDT_GND_LEFT }; } - namespace P60Dock { /** Max reply size reached when requesting full hk table */ @@ -386,240 +385,221 @@ static const uint16_t HK_TABLE_REPLY_SIZE = 407; * The GS port and X3 are not required for EIVE. X3 is another slot on the P60 dock and * GS is required for a module from Gomspace which is not used. */ -class HkTableDataset: - public StaticLocalDataSet { - public: +class HkTableDataset : public StaticLocalDataSet { + public: + HkTableDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) {} - HkTableDataset(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) { - } + HkTableDataset(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) {} - HkTableDataset(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) { - } + /** Measured output currents */ + lp_var_t currentAcuVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_ACU_VCC, this); + lp_var_t currentPdu1Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_PDU1_VCC, this); + lp_var_t currentX3IdleVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_X3_IDLE_VCC, this); + lp_var_t currentPdu2Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_PDU2_VCC, this); + lp_var_t currentAcuVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_ACU_VBAT, this); + lp_var_t currentPdu1Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_PDU1_VBAT, this); + lp_var_t currentX3IdleVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_X3_IDLE_VBAT, this); + lp_var_t currentPdu2Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_PDU2_VBAT, this); + lp_var_t currentStackVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_STACK_VBAT, this); + lp_var_t currentStack3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_STACK_3V3, this); + lp_var_t currentStack5V = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_STACK_5V, this); + lp_var_t currentGS3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_GS3V3, this); + lp_var_t currentGS5V = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_GS5V, this); - /** Measured output currents */ - lp_var_t currentAcuVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_ACU_VCC, this); - lp_var_t currentPdu1Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_PDU1_VCC, this); - lp_var_t currentX3IdleVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_X3_IDLE_VCC, this); - lp_var_t currentPdu2Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_PDU2_VCC, this); - lp_var_t currentAcuVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_ACU_VBAT, this); - lp_var_t currentPdu1Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_PDU1_VBAT, this); - lp_var_t currentX3IdleVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_X3_IDLE_VBAT, this); - lp_var_t currentPdu2Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_PDU2_VBAT, this); - lp_var_t currentStackVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_STACK_VBAT, this); - lp_var_t currentStack3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_STACK_3V3, this); - lp_var_t currentStack5V = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_STACK_5V, this); - lp_var_t currentGS3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_GS3V3, this); - lp_var_t currentGS5V = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_GS5V, this); + /** Measured output voltages */ + lp_var_t voltageAcuVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_ACU_VCC, this); + lp_var_t voltagePdu1Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_PDU1_VCC, this); + lp_var_t voltageX3IdleVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_X3_IDLE_VCC, this); + lp_var_t voltagePdu2Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_PDU2_VCC, this); + lp_var_t voltageAcuVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_ACU_VBAT, this); + lp_var_t voltagePdu1Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_PDU1_VBAT, this); + lp_var_t voltageX3IdleVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_X3_IDLE_VBAT, this); + lp_var_t voltagePdu2Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_PDU2_VBAT, this); + lp_var_t voltageStackVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_STACK_VBAT, this); + lp_var_t voltageStack3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_STACK_3V3, this); + lp_var_t voltageStack5V = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_STACK_5V, this); + lp_var_t voltageGS3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_GS3V3, this); + lp_var_t voltageGS5V = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_GS5V, this); - /** Measured output voltages */ - lp_var_t voltageAcuVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_ACU_VCC, this); - lp_var_t voltagePdu1Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_PDU1_VCC, this); - lp_var_t voltageX3IdleVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_X3_IDLE_VCC, this); - lp_var_t voltagePdu2Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_PDU2_VCC, this); - lp_var_t voltageAcuVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_ACU_VBAT, this); - lp_var_t voltagePdu1Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_PDU1_VBAT, this); - lp_var_t voltageX3IdleVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_X3_IDLE_VBAT, this); - lp_var_t voltagePdu2Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_PDU2_VBAT, this); - lp_var_t voltageStackVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_STACK_VBAT, this); - lp_var_t voltageStack3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_STACK_3V3, this); - lp_var_t voltageStack5V = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_STACK_5V, this); - lp_var_t voltageGS3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_GS3V3, this); - lp_var_t voltageGS5V = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_GS5V, this); + /** Output enable states */ + lp_var_t outputEnableStateAcuVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_ACU_VCC, this); + lp_var_t outputEnableStatePdu1Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_PDU1_VCC, this); + lp_var_t outputEnableStateX3IdleVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VCC, this); + lp_var_t outputEnableStatePdu2Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_PDU2_VCC, this); + lp_var_t outputEnableStateAcuVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_ACU_VBAT, this); + lp_var_t outputEnableStatePdu1Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_PDU1_VBAT, this); + lp_var_t outputEnableStateX3IdleVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VBAT, this); + lp_var_t outputEnableStatePdu2Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_PDU2_VBAT, this); + lp_var_t outputEnableStateStackVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_STACK_VBAT, this); + lp_var_t outputEnableStateStack3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_STACK_3V3, this); + lp_var_t outputEnableStateStack5V = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_STACK_5V, this); + lp_var_t outputEnableStateGS3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_GS3V3, this); + lp_var_t outputEnableStateGS5V = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_GS5V, this); - /** Output enable states */ - lp_var_t outputEnableStateAcuVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_ACU_VCC, this); - lp_var_t outputEnableStatePdu1Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_PDU1_VCC, this); - lp_var_t outputEnableStateX3IdleVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VCC, this); - lp_var_t outputEnableStatePdu2Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_PDU2_VCC, this); - lp_var_t outputEnableStateAcuVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_ACU_VBAT, this); - lp_var_t outputEnableStatePdu1Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_PDU1_VBAT, this); - lp_var_t outputEnableStateX3IdleVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VBAT, this); - lp_var_t outputEnableStatePdu2Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_PDU2_VBAT, this); - lp_var_t outputEnableStateStackVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_STACK_VBAT, this); - lp_var_t outputEnableStateStack3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_STACK_3V3, this); - lp_var_t outputEnableStateStack5V = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_STACK_5V, this); - lp_var_t outputEnableStateGS3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_GS3V3, this); - lp_var_t outputEnableStateGS5V = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_GS5V, this); + lp_var_t temperature1 = + lp_var_t(sid.objectId, P60System::P60DOCK_TEMPERATURE_1, this); + lp_var_t temperature2 = + lp_var_t(sid.objectId, P60System::P60DOCK_TEMPERATURE_2, this); - lp_var_t temperature1 = lp_var_t(sid.objectId, - P60System::P60DOCK_TEMPERATURE_1, this); - lp_var_t temperature2 = lp_var_t(sid.objectId, - P60System::P60DOCK_TEMPERATURE_2, this); + lp_var_t bootcause = + lp_var_t(sid.objectId, P60System::P60DOCK_BOOT_CAUSE, this); + lp_var_t bootCount = + lp_var_t(sid.objectId, P60System::P60DOCK_BOOT_CNT, this); + lp_var_t uptime = lp_var_t(sid.objectId, P60System::P60DOCK_UPTIME, this); + lp_var_t resetcause = + lp_var_t(sid.objectId, P60System::P60DOCK_RESETCAUSE, this); + lp_var_t battMode = lp_var_t(sid.objectId, P60System::P60DOCK_BATT_MODE, this); + /** Battery heater control only possible on BP4 packs */ + lp_var_t heaterOn = lp_var_t(sid.objectId, P60System::P60DOCK_HEATER_ON, this); + lp_var_t converter5VStatus = + lp_var_t(sid.objectId, P60System::P60DOCK_CONV_5V_ENABLE_STATUS, this); - lp_var_t bootcause = lp_var_t(sid.objectId, - P60System::P60DOCK_BOOT_CAUSE, this); - lp_var_t bootCount = lp_var_t(sid.objectId, - P60System::P60DOCK_BOOT_CNT, this); - lp_var_t uptime = lp_var_t(sid.objectId, - P60System::P60DOCK_UPTIME, this); - lp_var_t resetcause = lp_var_t(sid.objectId, - P60System::P60DOCK_RESETCAUSE, this); - lp_var_t battMode = lp_var_t(sid.objectId, - P60System::P60DOCK_BATT_MODE, this); - /** Battery heater control only possible on BP4 packs */ - lp_var_t heaterOn = lp_var_t(sid.objectId, - P60System::P60DOCK_HEATER_ON, this); - lp_var_t converter5VStatus = lp_var_t(sid.objectId, - P60System::P60DOCK_CONV_5V_ENABLE_STATUS, this); + /** Number of detected latchups on each output channel */ + lp_var_t latchupsAcuVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_ACU_VCC, this); + lp_var_t latchupsPdu1Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_PDU1_VCC, this); + lp_var_t latchupsX3IdleVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_X3_IDLE_VCC, this); + lp_var_t latchupsPdu2Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_PDU2_VCC, this); + lp_var_t latchupsAcuVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_ACU_VBAT, this); + lp_var_t latchupsPdu1Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_PDU1_VBAT, this); + lp_var_t latchupsX3IdleVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_X3_IDLE_VBAT, this); + lp_var_t latchupsPdu2Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_PDU2_VBAT, this); + lp_var_t latchupsStackVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_STACK_VBAT, this); + lp_var_t latchupsStack3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_STACK_3V3, this); + lp_var_t latchupsStack5V = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_STACK_5V, this); + lp_var_t latchupsGS3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_GS3V3, this); + lp_var_t latchupsGS5V = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_GS5V, this); - /** Number of detected latchups on each output channel */ - lp_var_t latchupsAcuVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_ACU_VCC, this); - lp_var_t latchupsPdu1Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_PDU1_VCC, this); - lp_var_t latchupsX3IdleVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_X3_IDLE_VCC, this); - lp_var_t latchupsPdu2Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_PDU2_VCC, this); - lp_var_t latchupsAcuVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_ACU_VBAT, this); - lp_var_t latchupsPdu1Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_PDU1_VBAT, this); - lp_var_t latchupsX3IdleVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_X3_IDLE_VBAT, this); - lp_var_t latchupsPdu2Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_PDU2_VBAT, this); - lp_var_t latchupsStackVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_STACK_VBAT, this); - lp_var_t latchupsStack3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_STACK_3V3, this); - lp_var_t latchupsStack5V = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_STACK_5V, this); - lp_var_t latchupsGS3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_GS3V3, this); - lp_var_t latchupsGS5V = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_GS5V, this); + lp_var_t vbatVoltageValue = + lp_var_t(sid.objectId, P60System::P60DOCK_VBAT_VALUE, this); + lp_var_t vccCurrent = + lp_var_t(sid.objectId, P60System::P60DOCK_VCC_CURRENT_VALUE, this); + lp_var_t batteryCurrent = + lp_var_t(sid.objectId, P60System::P60DOCK_BATTERY_CURRENT, this); + lp_var_t batteryVoltage = + lp_var_t(sid.objectId, P60System::P60DOCK_BATTERY_VOLTAGE, this); - lp_var_t vbatVoltageValue = lp_var_t(sid.objectId, - P60System::P60DOCK_VBAT_VALUE, this); - lp_var_t vccCurrent = lp_var_t(sid.objectId, - P60System::P60DOCK_VCC_CURRENT_VALUE, this); - lp_var_t batteryCurrent = lp_var_t(sid.objectId, - P60System::P60DOCK_BATTERY_CURRENT, this); - lp_var_t batteryVoltage = lp_var_t(sid.objectId, - P60System::P60DOCK_BATTERY_VOLTAGE, this); + lp_var_t batteryTemperature1 = + lp_var_t(sid.objectId, P60System::P60DOCK_BATTERY_TEMPERATURE_1, this); + lp_var_t batteryTemperature2 = + lp_var_t(sid.objectId, P60System::P60DOCK_BATTERY_TEMPERATURE_2, this); - lp_var_t batteryTemperature1 = lp_var_t(sid.objectId, - P60System::P60DOCK_BATTERY_TEMPERATURE_1, this); - lp_var_t batteryTemperature2 = lp_var_t(sid.objectId, - P60System::P60DOCK_BATTERY_TEMPERATURE_2, this); + lp_var_t device0 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_0, this); + lp_var_t device1 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_1, this); + lp_var_t device2 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_2, this); + lp_var_t device3 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_3, this); + lp_var_t device4 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_4, this); + lp_var_t device5 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_5, this); + lp_var_t device6 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_6, this); + lp_var_t device7 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_7, this); - lp_var_t device0 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_0, this); - lp_var_t device1 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_1, this); - lp_var_t device2 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_2, this); - lp_var_t device3 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_3, this); - lp_var_t device4 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_4, this); - lp_var_t device5 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_5, this); - lp_var_t device6 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_6, this); - lp_var_t device7 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_7, this); + lp_var_t device0Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_0_STATUS, this); + lp_var_t device1Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_1_STATUS, this); + lp_var_t device2Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_2_STATUS, this); + lp_var_t device3Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_3_STATUS, this); + lp_var_t device4Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_4_STATUS, this); + lp_var_t device5Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_5_STATUS, this); + lp_var_t device6Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_6_STATUS, this); + lp_var_t device7Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_7_STATUS, this); - lp_var_t device0Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_0_STATUS, this); - lp_var_t device1Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_1_STATUS, this); - lp_var_t device2Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_2_STATUS, this); - lp_var_t device3Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_3_STATUS, this); - lp_var_t device4Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_4_STATUS, this); - lp_var_t device5Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_5_STATUS, this); - lp_var_t device6Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_6_STATUS, this); - lp_var_t device7Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_7_STATUS, this); + lp_var_t dearmStatus = + lp_var_t(sid.objectId, P60System::P60DOCK_DEARM_STATUS, this); - lp_var_t dearmStatus = lp_var_t(sid.objectId, - P60System::P60DOCK_DEARM_STATUS, this); + /** Number of reboots due to gnd, i2c, csp watchdog timeout */ + lp_var_t wdtCntGnd = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CNT_GND, this); + lp_var_t wdtCntI2c = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CNT_I2C, this); + lp_var_t wdtCntCan = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CNT_CAN, this); + lp_var_t wdtCntCsp1 = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CNT_CSP_1, this); + lp_var_t wdtCntCsp2 = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CNT_CSP_2, this); - /** Number of reboots due to gnd, i2c, csp watchdog timeout */ - lp_var_t wdtCntGnd = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CNT_GND, this); - lp_var_t wdtCntI2c = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CNT_I2C, this); - lp_var_t wdtCntCan = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CNT_CAN, this); - lp_var_t wdtCntCsp1 = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CNT_CSP_1, this); - lp_var_t wdtCntCsp2 = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CNT_CSP_2, this); - - lp_var_t wdtGndLeft = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_GND_LEFT, this); - lp_var_t wdtI2cLeft = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_I2C_LEFT, this); - lp_var_t wdtCanLeft = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CAN_LEFT, this); - lp_var_t wdtCspLeft1 = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CSP_LEFT_1, this); - lp_var_t wdtCspLeft2 = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CSP_LEFT_2, this); - lp_var_t batteryChargeCurrent = lp_var_t(sid.objectId, - P60System::P60DOCK_BATT_CHARGE_CURRENT, this); - lp_var_t batteryDischargeCurrent = lp_var_t(sid.objectId, - P60System::P60DOCK_BATT_DISCHARGE_CURRENT, this); - lp_var_t ant6Depl = lp_var_t(sid.objectId, - P60System::P60DOCK_ANT6_DEPL, this); - lp_var_t ar6Depl = lp_var_t(sid.objectId, - P60System::P60DOCK_AR6_DEPL, this); + lp_var_t wdtGndLeft = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_GND_LEFT, this); + lp_var_t wdtI2cLeft = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_I2C_LEFT, this); + lp_var_t wdtCanLeft = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CAN_LEFT, this); + lp_var_t wdtCspLeft1 = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CSP_LEFT_1, this); + lp_var_t wdtCspLeft2 = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CSP_LEFT_2, this); + lp_var_t batteryChargeCurrent = + lp_var_t(sid.objectId, P60System::P60DOCK_BATT_CHARGE_CURRENT, this); + lp_var_t batteryDischargeCurrent = + lp_var_t(sid.objectId, P60System::P60DOCK_BATT_DISCHARGE_CURRENT, this); + lp_var_t ant6Depl = lp_var_t(sid.objectId, P60System::P60DOCK_ANT6_DEPL, this); + lp_var_t ar6Depl = lp_var_t(sid.objectId, P60System::P60DOCK_AR6_DEPL, this); }; -} - +} // namespace P60Dock /** * @brief Constants common for both PDU1 and PDU2. */ -namespace PDU{ +namespace PDU { /** When retrieving full configuration parameter table */ static const uint16_t MAX_REPLY_LENGTH = 318; static const uint16_t MAX_CONFIGTABLE_ADDRESS = 316; @@ -627,11 +607,10 @@ static const uint16_t MAX_HKTABLE_ADDRESS = 141; /** The size of the csp reply containing the housekeeping table data */ static const uint16_t HK_TABLE_REPLY_SIZE = 303; static const uint8_t HK_TABLE_ENTRIES = 73; -} - +} // namespace PDU namespace PDU1 { -static const uint32_t HK_TABLE_DATA_SET_ID = 0x1; // hk table has table id 4 +static const uint32_t HK_TABLE_DATA_SET_ID = 0x1; // hk table has table id 4 /** * Addresses within configuration table to enable or disable output channels. Refer also to * gs-man-nanopower-p60-pdu-200.pdf on page 16. @@ -649,194 +628,174 @@ static const uint16_t CONFIG_ADDRESS_OUT_EN_CHANNEL8 = 0x56; /** * @brief This class defines a dataset for the hk table of the PDU1. */ -class PDU1HkTableDataset : - public StaticLocalDataSet { - public: +class PDU1HkTableDataset : public StaticLocalDataSet { + public: + PDU1HkTableDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) {} - PDU1HkTableDataset(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) { - } + PDU1HkTableDataset(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) {} - PDU1HkTableDataset(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) { - } + /** Measured output currents */ + lp_var_t currentOutTCSBoard3V3 = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_TCS_BOARD_3V3, this); + lp_var_t currentOutSyrlinks = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_SYRLINKS, this); + lp_var_t currentOutStarTracker = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_STAR_TRACKER, this); + lp_var_t currentOutMGT = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_MGT, this); + lp_var_t currentOutSUSNominal = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_SUS_NOMINAL, this); + lp_var_t currentOutSolarCellExp = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, this); + lp_var_t currentOutPLOC = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_PLOC, this); + lp_var_t currentOutACSBoardSideA = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, this); + lp_var_t currentOutChannel8 = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_CHANNEL8, this); + /** Measured voltage of output channels */ + lp_var_t voltageOutTCSBoard3V3 = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, this); + lp_var_t voltageOutSyrlinks = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_SYRLINKS, this); + lp_var_t voltageOutStarTracker = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_STAR_TRACKER, this); + lp_var_t voltageOutMGT = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_MGT, this); + lp_var_t voltageOutSUSNominal = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_SUS_NOMINAL, this); + lp_var_t voltageOutSolarCellExp = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, this); + lp_var_t voltageOutPLOC = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_PLOC, this); + lp_var_t voltageOutACSBoardSideA = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, this); + lp_var_t voltageOutChannel8 = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_CHANNEL8, this); + /** Measured VCC */ + lp_var_t vcc = lp_var_t(sid.objectId, P60System::PDU1_VCC, this); + /** Measured VBAT */ + lp_var_t vbat = lp_var_t(sid.objectId, P60System::PDU1_VBAT, this); + lp_var_t temperature = + lp_var_t(sid.objectId, P60System::PDU1_TEMPERATURE, this); + /** Output converter enable status */ + lp_var_t converterEnable1 = + lp_var_t(sid.objectId, P60System::PDU1_CONV_EN_1, this); + lp_var_t converterEnable2 = + lp_var_t(sid.objectId, P60System::PDU1_CONV_EN_2, this); + lp_var_t converterEnable3 = + lp_var_t(sid.objectId, P60System::PDU1_CONV_EN_3, this); - /** Measured output currents */ - lp_var_t currentOutTCSBoard3V3 = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_TCS_BOARD_3V3, this); - lp_var_t currentOutSyrlinks = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_SYRLINKS, this); - lp_var_t currentOutStarTracker = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_STAR_TRACKER, this); - lp_var_t currentOutMGT = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_MGT, this); - lp_var_t currentOutSUSNominal = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_SUS_NOMINAL, this); - lp_var_t currentOutSolarCellExp = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, this); - lp_var_t currentOutPLOC = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_PLOC, this); - lp_var_t currentOutACSBoardSideA = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, this); - lp_var_t currentOutChannel8 = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_CHANNEL8, this); - /** Measured voltage of output channels */ - lp_var_t voltageOutTCSBoard3V3 = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, this); - lp_var_t voltageOutSyrlinks = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_SYRLINKS, this); - lp_var_t voltageOutStarTracker = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_STAR_TRACKER, this); - lp_var_t voltageOutMGT = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_MGT, this); - lp_var_t voltageOutSUSNominal = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_SUS_NOMINAL, this); - lp_var_t voltageOutSolarCellExp = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, this); - lp_var_t voltageOutPLOC = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_PLOC, this); - lp_var_t voltageOutACSBoardSideA = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, this); - lp_var_t voltageOutChannel8 = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_CHANNEL8, this); - /** Measured VCC */ - lp_var_t vcc = lp_var_t(sid.objectId, - P60System::PDU1_VCC, this); - /** Measured VBAT */ - lp_var_t vbat = lp_var_t(sid.objectId, - P60System::PDU1_VBAT, this); - lp_var_t temperature = lp_var_t(sid.objectId, - P60System::PDU1_TEMPERATURE, this); - /** Output converter enable status */ - lp_var_t converterEnable1 = lp_var_t(sid.objectId, - P60System::PDU1_CONV_EN_1, this); - lp_var_t converterEnable2 = lp_var_t(sid.objectId, - P60System::PDU1_CONV_EN_2, this); - lp_var_t converterEnable3 = lp_var_t(sid.objectId, - P60System::PDU1_CONV_EN_3, this); + /** Output channels enable status */ + lp_var_t outEnabledTCSBoard3V3 = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_TCS_BOARD_3V3, this); + lp_var_t outEnabledSyrlinks = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_SYRLINKS, this); + lp_var_t outEnabledStarTracker = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_STAR_TRACKER, this); + lp_var_t outEnabledMGT = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_MGT, this); + lp_var_t outEnabledSUSNominal = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_SUS_NOMINAL, this); + lp_var_t outEnabledSolarCellExp = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_SOLAR_CELL_EXP, this); + lp_var_t outEnabledPLOC = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_PLOC, this); + lp_var_t outEnabledAcsBoardSideA = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_ACS_BOARD_SIDE_A, this); + lp_var_t outEnabledChannel8 = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_CHANNEL8, this); + lp_var_t bootcause = lp_var_t(sid.objectId, P60System::PDU1_BOOTCAUSE, this); + /** Number of reboots */ + lp_var_t bootcount = lp_var_t(sid.objectId, P60System::PDU1_BOOTCNT, this); + /** Uptime in seconds */ + lp_var_t uptime = lp_var_t(sid.objectId, P60System::PDU1_UPTIME, this); + lp_var_t resetcause = + lp_var_t(sid.objectId, P60System::PDU1_RESETCAUSE, this); + /** Battery mode: 1 = Critical, 2 = Safe, 3 = Normal, 4 = Full */ + lp_var_t battMode = lp_var_t(sid.objectId, P60System::PDU1_BATT_MODE, this); - /** Output channels enable status */ - lp_var_t outEnabledTCSBoard3V3 = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_TCS_BOARD_3V3, this); - lp_var_t outEnabledSyrlinks = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_SYRLINKS, this); - lp_var_t outEnabledStarTracker = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_STAR_TRACKER, this); - lp_var_t outEnabledMGT = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_MGT, this); - lp_var_t outEnabledSUSNominal = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_SUS_NOMINAL, this); - lp_var_t outEnabledSolarCellExp = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_SOLAR_CELL_EXP, this); - lp_var_t outEnabledPLOC = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_PLOC, this); - lp_var_t outEnabledAcsBoardSideA = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_ACS_BOARD_SIDE_A, this); - lp_var_t outEnabledChannel8 = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_CHANNEL8, this); - lp_var_t bootcause = lp_var_t(sid.objectId, - P60System::PDU1_BOOTCAUSE, this); - /** Number of reboots */ - lp_var_t bootcount = lp_var_t(sid.objectId, - P60System::PDU1_BOOTCNT, this); - /** Uptime in seconds */ - lp_var_t uptime = lp_var_t(sid.objectId, - P60System::PDU1_UPTIME, this); - lp_var_t resetcause = lp_var_t(sid.objectId, - P60System::PDU1_RESETCAUSE, this); - /** Battery mode: 1 = Critical, 2 = Safe, 3 = Normal, 4 = Full */ - lp_var_t battMode = lp_var_t(sid.objectId, - P60System::PDU1_BATT_MODE, this); + /** Number of detected latchups on each output channel */ + lp_var_t latchupsTcsBoard3V3 = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_TCS_BOARD_3V3, this); + lp_var_t latchupsSyrlinks = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_SYRLINKS, this); + lp_var_t latchupsStarTracker = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_STAR_TRACKER, this); + lp_var_t latchupsMgt = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_MGT, this); + lp_var_t latchupsSusNominal = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_SUS_NOMINAL, this); + lp_var_t latchupsSolarCellExp = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_SOLAR_CELL_EXP, this); + lp_var_t latchupsPloc = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_PLOC, this); + lp_var_t latchupsAcsBoardSideA = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_ACS_BOARD_SIDE_A, this); + lp_var_t latchupsChannel8 = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_CHANNEL8, this); - /** Number of detected latchups on each output channel */ - lp_var_t latchupsTcsBoard3V3 = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_TCS_BOARD_3V3, this); - lp_var_t latchupsSyrlinks = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_SYRLINKS, this); - lp_var_t latchupsStarTracker = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_STAR_TRACKER, this); - lp_var_t latchupsMgt = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_MGT, this); - lp_var_t latchupsSusNominal = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_SUS_NOMINAL, this); - lp_var_t latchupsSolarCellExp = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_SOLAR_CELL_EXP, this); - lp_var_t latchupsPloc = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_PLOC, this); - lp_var_t latchupsAcsBoardSideA = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_ACS_BOARD_SIDE_A, this); - lp_var_t latchupsChannel8 = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_CHANNEL8, this); + /** + * There are 8 devices on the PDU. FRAM, ADCs, temperature sensor etc. Each device is + * identified by an ID. Refer also to gs-man-nanopower-p60-pdu-200-1.pdf on pages 17 and 18. + */ + lp_var_t device0 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_0, this); + lp_var_t device1 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_1, this); + lp_var_t device2 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_2, this); + lp_var_t device3 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_3, this); + lp_var_t device4 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_4, this); + lp_var_t device5 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_5, this); + lp_var_t device6 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_6, this); + lp_var_t device7 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_7, this); + /** The status of each device. 0 = None, 1 = Ok, 2 = Error, 3 = Not found */ + lp_var_t device0Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_0_STATUS, this); + lp_var_t device1Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_1_STATUS, this); + lp_var_t device2Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_2_STATUS, this); + lp_var_t device3Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_3_STATUS, this); + lp_var_t device4Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_4_STATUS, this); + lp_var_t device5Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_5_STATUS, this); + lp_var_t device6Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_6_STATUS, this); + lp_var_t device7Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_7_STATUS, this); - /** - * There are 8 devices on the PDU. FRAM, ADCs, temperature sensor etc. Each device is - * identified by an ID. Refer also to gs-man-nanopower-p60-pdu-200-1.pdf on pages 17 and 18. - */ - lp_var_t device0 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_0, this); - lp_var_t device1 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_1, this); - lp_var_t device2 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_2, this); - lp_var_t device3 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_3, this); - lp_var_t device4 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_4, this); - lp_var_t device5 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_5, this); - lp_var_t device6 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_6, this); - lp_var_t device7 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_7, this); - /** The status of each device. 0 = None, 1 = Ok, 2 = Error, 3 = Not found */ - lp_var_t device0Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_0_STATUS, this); - lp_var_t device1Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_1_STATUS, this); - lp_var_t device2Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_2_STATUS, this); - lp_var_t device3Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_3_STATUS, this); - lp_var_t device4Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_4_STATUS, this); - lp_var_t device5Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_5_STATUS, this); - lp_var_t device6Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_6_STATUS, this); - lp_var_t device7Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_7_STATUS, this); - - /** Number of reboots triggered by the ground watchdog */ - lp_var_t gndWdtReboots = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CNT_GND, this); - /** Number of reboots triggered through the I2C watchdog. Not relevant for EIVE. */ - lp_var_t i2cWdtReboots = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CNT_I2C, this); - /** Number of reboots triggered through the CAN watchdog */ - lp_var_t canWdtReboots = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CNT_CAN, this); - /** Number of reboots triggered through the CSP watchdog */ - lp_var_t csp1WdtReboots = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CNT_CSP1, this); - lp_var_t csp2WdtReboots = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CNT_CSP2, this); - /** Ground watchdog remaining seconds before rebooting */ - lp_var_t groundWatchdogSecondsLeft = lp_var_t(sid.objectId, - P60System::PDU1_WDT_GND_LEFT, this); - /** I2C watchdog remaining seconds before rebooting. Not relevant for EIVE. */ - lp_var_t i2cWatchdogSecondsLeft = lp_var_t(sid.objectId, - P60System::PDU1_WDT_I2C_LEFT, this); - /** CAN watchdog remaining seconds before rebooting. */ - lp_var_t canWatchdogSecondsLeft = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CAN_LEFT, this); - /** CSP watchdogs remaining pings before rebooting. */ - lp_var_t csp2WatchdogPingsLeft = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CSP_LEFT1, this); - lp_var_t csp1WatchdogPingsLeft = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CSP_LEFT2, this); + /** Number of reboots triggered by the ground watchdog */ + lp_var_t gndWdtReboots = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CNT_GND, this); + /** Number of reboots triggered through the I2C watchdog. Not relevant for EIVE. */ + lp_var_t i2cWdtReboots = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CNT_I2C, this); + /** Number of reboots triggered through the CAN watchdog */ + lp_var_t canWdtReboots = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CNT_CAN, this); + /** Number of reboots triggered through the CSP watchdog */ + lp_var_t csp1WdtReboots = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CNT_CSP1, this); + lp_var_t csp2WdtReboots = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CNT_CSP2, this); + /** Ground watchdog remaining seconds before rebooting */ + lp_var_t groundWatchdogSecondsLeft = + lp_var_t(sid.objectId, P60System::PDU1_WDT_GND_LEFT, this); + /** I2C watchdog remaining seconds before rebooting. Not relevant for EIVE. */ + lp_var_t i2cWatchdogSecondsLeft = + lp_var_t(sid.objectId, P60System::PDU1_WDT_I2C_LEFT, this); + /** CAN watchdog remaining seconds before rebooting. */ + lp_var_t canWatchdogSecondsLeft = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CAN_LEFT, this); + /** CSP watchdogs remaining pings before rebooting. */ + lp_var_t csp2WatchdogPingsLeft = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CSP_LEFT1, this); + lp_var_t csp1WatchdogPingsLeft = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CSP_LEFT2, this); }; -} - +} // namespace PDU1 namespace PDU2 { static const uint32_t HK_TABLE_DATA_SET_ID = 0x2; @@ -857,194 +816,174 @@ static const uint16_t CONFIG_ADDRESS_OUT_EN_PAYLOAD_CAMERA = 0x50; /** * @brief This class defines a dataset for the hk table of the PDU2. */ -class PDU2HkTableDataset: - public StaticLocalDataSet { - public: +class PDU2HkTableDataset : public StaticLocalDataSet { + public: + PDU2HkTableDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) {} - PDU2HkTableDataset(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) { - } + PDU2HkTableDataset(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) {} - PDU2HkTableDataset(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) { - } + /** Measured output currents */ + lp_var_t currentOutQ7S = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_Q7S, this); + lp_var_t currentOutPayloadPCDUCh1 = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, this); + lp_var_t currentOutReactionWheels = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_RW, this); + lp_var_t currentOutTCSBoardHeaterIn = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, this); + lp_var_t currentOutSUSRedundant = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_SUS_REDUNDANT, this); + lp_var_t currentOutDeplMechanism = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, this); + lp_var_t currentOutPayloadPCDUCh6 = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, this); + lp_var_t currentOutACSBoardSideB = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, this); + lp_var_t currentOutPayloadCamera = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, this); + /** Measured voltage of output channels */ + lp_var_t voltageOutQ7S = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_Q7S, this); + lp_var_t voltageOutPayloadPCDUCh1 = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, this); + lp_var_t voltageOutReactionWheels = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_RW, this); + lp_var_t voltageOutTCSBoardHeaterIn = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, this); + lp_var_t voltageOutSUSRedundant = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, this); + lp_var_t voltageOutDeplMechanism = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, this); + lp_var_t voltageOutPayloadPCDUCh6 = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, this); + lp_var_t voltageOutACSBoardSideB = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, this); + lp_var_t voltageOutPayloadCamera = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, this); + /** Measured VCC */ + lp_var_t vcc = lp_var_t(sid.objectId, P60System::PDU2_VCC, this); + /** Measured VBAT */ + lp_var_t vbat = lp_var_t(sid.objectId, P60System::PDU2_VBAT, this); + lp_var_t temperature = + lp_var_t(sid.objectId, P60System::PDU2_TEMPERATURE, this); + /** Output converter enable status */ + lp_var_t converterEnable1 = + lp_var_t(sid.objectId, P60System::PDU2_CONV_EN_1, this); + lp_var_t converterEnable2 = + lp_var_t(sid.objectId, P60System::PDU2_CONV_EN_2, this); + lp_var_t converterEnable3 = + lp_var_t(sid.objectId, P60System::PDU2_CONV_EN_3, this); + /** Output channels enable status */ + lp_var_t outEnabledQ7S = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_Q7S, this); + lp_var_t outEnabledPlPCDUCh1 = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, this); + lp_var_t outEnabledReactionWheels = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_RW, this); + lp_var_t outEnabledTCSBoardHeaterIn = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, this); + lp_var_t outEnabledSUSRedundant = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_SUS_REDUNDANT, this); + lp_var_t outEnabledDeplMechanism = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_DEPLOYMENT_MECHANISM, this); + lp_var_t outEnabledPlPCDUCh6 = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH6, this); + lp_var_t outEnabledAcsBoardSideB = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_ACS_BOARD_SIDE_B, this); + lp_var_t outEnabledPayloadCamera = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_PAYLOAD_CAMERA, this); - /** Measured output currents */ - lp_var_t currentOutQ7S = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_Q7S, this); - lp_var_t currentOutPayloadPCDUCh1 = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, this); - lp_var_t currentOutReactionWheels = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_RW, this); - lp_var_t currentOutTCSBoardHeaterIn = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, this); - lp_var_t currentOutSUSRedundant = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_SUS_REDUNDANT, this); - lp_var_t currentOutDeplMechanism = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, this); - lp_var_t currentOutPayloadPCDUCh6 = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, this); - lp_var_t currentOutACSBoardSideB = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, this); - lp_var_t currentOutPayloadCamera = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, this); - /** Measured voltage of output channels */ - lp_var_t voltageOutQ7S = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_Q7S, this); - lp_var_t voltageOutPayloadPCDUCh1 = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, this); - lp_var_t voltageOutReactionWheels = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_RW, this); - lp_var_t voltageOutTCSBoardHeaterIn = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, this); - lp_var_t voltageOutSUSRedundant = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, this); - lp_var_t voltageOutDeplMechanism = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, this); - lp_var_t voltageOutPayloadPCDUCh6 = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, this); - lp_var_t voltageOutACSBoardSideB = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, this); - lp_var_t voltageOutPayloadCamera = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, this); - /** Measured VCC */ - lp_var_t vcc = lp_var_t(sid.objectId, - P60System::PDU2_VCC, this); - /** Measured VBAT */ - lp_var_t vbat = lp_var_t(sid.objectId, - P60System::PDU2_VBAT, this); - lp_var_t temperature = lp_var_t(sid.objectId, - P60System::PDU2_TEMPERATURE, this); - /** Output converter enable status */ - lp_var_t converterEnable1 = lp_var_t(sid.objectId, - P60System::PDU2_CONV_EN_1, this); - lp_var_t converterEnable2 = lp_var_t(sid.objectId, - P60System::PDU2_CONV_EN_2, this); - lp_var_t converterEnable3 = lp_var_t(sid.objectId, - P60System::PDU2_CONV_EN_3, this); - /** Output channels enable status */ - lp_var_t outEnabledQ7S = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_Q7S, this); - lp_var_t outEnabledPlPCDUCh1 = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, this); - lp_var_t outEnabledReactionWheels = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_RW, this); - lp_var_t outEnabledTCSBoardHeaterIn = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, this); - lp_var_t outEnabledSUSRedundant = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_SUS_REDUNDANT, this); - lp_var_t outEnabledDeplMechanism = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_DEPLOYMENT_MECHANISM, this); - lp_var_t outEnabledPlPCDUCh6 = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH6, this); - lp_var_t outEnabledAcsBoardSideB = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_ACS_BOARD_SIDE_B, this); - lp_var_t outEnabledPayloadCamera = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_PAYLOAD_CAMERA, this); + lp_var_t bootcause = lp_var_t(sid.objectId, P60System::PDU2_BOOTCAUSE, this); + /** Number of reboots */ + lp_var_t bootcount = lp_var_t(sid.objectId, P60System::PDU2_BOOTCNT, this); + /** Uptime in seconds */ + lp_var_t uptime = lp_var_t(sid.objectId, P60System::PDU2_UPTIME, this); + lp_var_t resetcause = + lp_var_t(sid.objectId, P60System::PDU2_RESETCAUSE, this); + /** Battery mode: 1 = Critical, 2 = Safe, 3 = Normal, 4 = Full */ + lp_var_t battMode = lp_var_t(sid.objectId, P60System::PDU2_BATT_MODE, this); - lp_var_t bootcause = lp_var_t(sid.objectId, - P60System::PDU2_BOOTCAUSE, this); - /** Number of reboots */ - lp_var_t bootcount = lp_var_t(sid.objectId, - P60System::PDU2_BOOTCNT, this); - /** Uptime in seconds */ - lp_var_t uptime = lp_var_t(sid.objectId, - P60System::PDU2_UPTIME, this); - lp_var_t resetcause = lp_var_t(sid.objectId, - P60System::PDU2_RESETCAUSE, this); - /** Battery mode: 1 = Critical, 2 = Safe, 3 = Normal, 4 = Full */ - lp_var_t battMode = lp_var_t(sid.objectId, - P60System::PDU2_BATT_MODE, this); + /** Number of detected latchups on each output channel */ + lp_var_t latchupsQ7S = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_Q7S, this); + lp_var_t latchupsPayloadPcduCh1 = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, this); + lp_var_t latchupsRw = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_RW, this); + lp_var_t latchupsTcsBoardHeaterIn = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, this); + lp_var_t latchupsSusRedundant = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_SUS_REDUNDANT, this); + lp_var_t latchupsDeplMenchanism = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_DEPLOYMENT_MECHANISM, this); + lp_var_t latchupsPayloadPcduCh6 = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, this); + lp_var_t latchupsAcsBoardSideB = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_ACS_BOARD_SIDE_B, this); + lp_var_t latchupsPayloadCamera = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_PAYLOAD_CAMERA, this); - /** Number of detected latchups on each output channel */ - lp_var_t latchupsQ7S = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_Q7S, this); - lp_var_t latchupsPayloadPcduCh1 = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, this); - lp_var_t latchupsRw = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_RW, this); - lp_var_t latchupsTcsBoardHeaterIn = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, this); - lp_var_t latchupsSusRedundant = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_SUS_REDUNDANT, this); - lp_var_t latchupsDeplMenchanism = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_DEPLOYMENT_MECHANISM, this); - lp_var_t latchupsPayloadPcduCh6 = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, this); - lp_var_t latchupsAcsBoardSideB = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_ACS_BOARD_SIDE_B, this); - lp_var_t latchupsPayloadCamera = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_PAYLOAD_CAMERA, this); + /** + * There are 8 devices on the PDU. FRAM, ADCs, temperature sensor etc. Each device is + * identified by an ID. Refer also to gs-man-nanopower-p60-pdu-200-1.pdf on pages 17 and 18. + */ + lp_var_t device0 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_0, this); + lp_var_t device1 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_1, this); + lp_var_t device2 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_2, this); + lp_var_t device3 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_3, this); + lp_var_t device4 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_4, this); + lp_var_t device5 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_5, this); + lp_var_t device6 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_6, this); + lp_var_t device7 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_7, this); + /** The status of each device. 0 = None, 1 = Ok, 2 = Error, 3 = Not found */ + lp_var_t device0Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_0_STATUS, this); + lp_var_t device1Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_1_STATUS, this); + lp_var_t device2Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_2_STATUS, this); + lp_var_t device3Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_3_STATUS, this); + lp_var_t device4Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_4_STATUS, this); + lp_var_t device5Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_5_STATUS, this); + lp_var_t device6Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_6_STATUS, this); + lp_var_t device7Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_7_STATUS, this); - /** - * There are 8 devices on the PDU. FRAM, ADCs, temperature sensor etc. Each device is - * identified by an ID. Refer also to gs-man-nanopower-p60-pdu-200-1.pdf on pages 17 and 18. - */ - lp_var_t device0 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_0, this); - lp_var_t device1 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_1, this); - lp_var_t device2 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_2, this); - lp_var_t device3 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_3, this); - lp_var_t device4 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_4, this); - lp_var_t device5 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_5, this); - lp_var_t device6 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_6, this); - lp_var_t device7 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_7, this); - /** The status of each device. 0 = None, 1 = Ok, 2 = Error, 3 = Not found */ - lp_var_t device0Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_0_STATUS, this); - lp_var_t device1Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_1_STATUS, this); - lp_var_t device2Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_2_STATUS, this); - lp_var_t device3Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_3_STATUS, this); - lp_var_t device4Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_4_STATUS, this); - lp_var_t device5Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_5_STATUS, this); - lp_var_t device6Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_6_STATUS, this); - lp_var_t device7Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_7_STATUS, this); - - /** Number of reboots triggered by the ground watchdog */ - lp_var_t gndWdtReboots = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CNT_GND, this); - /** Number of reboots triggered through the I2C watchdog. Not relevant for EIVE. */ - lp_var_t i2cWdtReboots = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CNT_I2C, this); - /** Number of reboots triggered through the CAN watchdog */ - lp_var_t canWdtReboots = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CNT_CAN, this); - /** Number of reboots triggered through the CSP watchdog */ - lp_var_t csp1WdtReboots = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CNT_CSP1, this); - lp_var_t csp2WdtReboots = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CNT_CSP2, this); - /** Ground watchdog remaining seconds before rebooting */ - lp_var_t groundWatchdogSecondsLeft = lp_var_t(sid.objectId, - P60System::PDU2_WDT_GND_LEFT, this); - /** I2C watchdog remaining seconds before rebooting. Not relevant for EIVE. */ - lp_var_t i2cWatchdogSecondsLeft = lp_var_t(sid.objectId, - P60System::PDU2_WDT_I2C_LEFT, this); - /** CAN watchdog remaining seconds before rebooting. */ - lp_var_t canWatchdogSecondsLeft = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CAN_LEFT, this); - /** CSP watchdog remaining pings before rebooting. */ - lp_var_t csp1WatchdogPingsLeft = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CSP_LEFT1, this); - lp_var_t csp2WatchdogPingsLeft = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CSP_LEFT2, this); + /** Number of reboots triggered by the ground watchdog */ + lp_var_t gndWdtReboots = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CNT_GND, this); + /** Number of reboots triggered through the I2C watchdog. Not relevant for EIVE. */ + lp_var_t i2cWdtReboots = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CNT_I2C, this); + /** Number of reboots triggered through the CAN watchdog */ + lp_var_t canWdtReboots = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CNT_CAN, this); + /** Number of reboots triggered through the CSP watchdog */ + lp_var_t csp1WdtReboots = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CNT_CSP1, this); + lp_var_t csp2WdtReboots = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CNT_CSP2, this); + /** Ground watchdog remaining seconds before rebooting */ + lp_var_t groundWatchdogSecondsLeft = + lp_var_t(sid.objectId, P60System::PDU2_WDT_GND_LEFT, this); + /** I2C watchdog remaining seconds before rebooting. Not relevant for EIVE. */ + lp_var_t i2cWatchdogSecondsLeft = + lp_var_t(sid.objectId, P60System::PDU2_WDT_I2C_LEFT, this); + /** CAN watchdog remaining seconds before rebooting. */ + lp_var_t canWatchdogSecondsLeft = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CAN_LEFT, this); + /** CSP watchdog remaining pings before rebooting. */ + lp_var_t csp1WatchdogPingsLeft = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CSP_LEFT1, this); + lp_var_t csp2WatchdogPingsLeft = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CSP_LEFT2, this); }; -} - +} // namespace PDU2 namespace ACU { @@ -1060,157 +999,133 @@ static const uint16_t HK_TABLE_REPLY_SIZE = 262; /** * @brief This class defines a dataset for the hk table of the ACU. */ -class HkTableDataset: - public StaticLocalDataSet { - public: +class HkTableDataset : public StaticLocalDataSet { + public: + HkTableDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) {} - HkTableDataset(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) { - } + HkTableDataset(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) {} - HkTableDataset(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) { - } + lp_var_t currentInChannel0 = + lp_var_t(sid.objectId, P60System::ACU_CURRENT_IN_CHANNEL0, this); + lp_var_t currentInChannel1 = + lp_var_t(sid.objectId, P60System::ACU_CURRENT_IN_CHANNEL1, this); + lp_var_t currentInChannel2 = + lp_var_t(sid.objectId, P60System::ACU_CURRENT_IN_CHANNEL2, this); + lp_var_t currentInChannel3 = + lp_var_t(sid.objectId, P60System::ACU_CURRENT_IN_CHANNEL3, this); + lp_var_t currentInChannel4 = + lp_var_t(sid.objectId, P60System::ACU_CURRENT_IN_CHANNEL4, this); + lp_var_t currentInChannel5 = + lp_var_t(sid.objectId, P60System::ACU_CURRENT_IN_CHANNEL5, this); - lp_var_t currentInChannel0 = lp_var_t(sid.objectId, - P60System::ACU_CURRENT_IN_CHANNEL0, this); - lp_var_t currentInChannel1 = lp_var_t(sid.objectId, - P60System::ACU_CURRENT_IN_CHANNEL1, this); - lp_var_t currentInChannel2 = lp_var_t(sid.objectId, - P60System::ACU_CURRENT_IN_CHANNEL2, this); - lp_var_t currentInChannel3 = lp_var_t(sid.objectId, - P60System::ACU_CURRENT_IN_CHANNEL3, this); - lp_var_t currentInChannel4 = lp_var_t(sid.objectId, - P60System::ACU_CURRENT_IN_CHANNEL4, this); - lp_var_t currentInChannel5 = lp_var_t(sid.objectId, - P60System::ACU_CURRENT_IN_CHANNEL5, this); + lp_var_t voltageInChannel0 = + lp_var_t(sid.objectId, P60System::ACU_VOLTAGE_IN_CHANNEL0, this); + lp_var_t voltageInChannel1 = + lp_var_t(sid.objectId, P60System::ACU_VOLTAGE_IN_CHANNEL1, this); + lp_var_t voltageInChannel2 = + lp_var_t(sid.objectId, P60System::ACU_VOLTAGE_IN_CHANNEL2, this); + lp_var_t voltageInChannel3 = + lp_var_t(sid.objectId, P60System::ACU_VOLTAGE_IN_CHANNEL3, this); + lp_var_t voltageInChannel4 = + lp_var_t(sid.objectId, P60System::ACU_VOLTAGE_IN_CHANNEL4, this); + lp_var_t voltageInChannel5 = + lp_var_t(sid.objectId, P60System::ACU_VOLTAGE_IN_CHANNEL5, this); - lp_var_t voltageInChannel0 = lp_var_t(sid.objectId, - P60System::ACU_VOLTAGE_IN_CHANNEL0, this); - lp_var_t voltageInChannel1 = lp_var_t(sid.objectId, - P60System::ACU_VOLTAGE_IN_CHANNEL1, this); - lp_var_t voltageInChannel2 = lp_var_t(sid.objectId, - P60System::ACU_VOLTAGE_IN_CHANNEL2, this); - lp_var_t voltageInChannel3 = lp_var_t(sid.objectId, - P60System::ACU_VOLTAGE_IN_CHANNEL3, this); - lp_var_t voltageInChannel4 = lp_var_t(sid.objectId, - P60System::ACU_VOLTAGE_IN_CHANNEL4, this); - lp_var_t voltageInChannel5 = lp_var_t(sid.objectId, - P60System::ACU_VOLTAGE_IN_CHANNEL5, this); + lp_var_t vcc = lp_var_t(sid.objectId, P60System::ACU_VCC, this); + lp_var_t vbat = lp_var_t(sid.objectId, P60System::ACU_VBAT, this); - lp_var_t vcc = lp_var_t(sid.objectId, - P60System::ACU_VCC, this); - lp_var_t vbat = lp_var_t(sid.objectId, - P60System::ACU_VBAT, this); + lp_var_t temperature1 = + lp_var_t(sid.objectId, P60System::ACU_TEMPERATURE_1, this); + lp_var_t temperature2 = + lp_var_t(sid.objectId, P60System::ACU_TEMPERATURE_2, this); + lp_var_t temperature3 = + lp_var_t(sid.objectId, P60System::ACU_TEMPERATURE_3, this); - lp_var_t temperature1 = lp_var_t(sid.objectId, - P60System::ACU_TEMPERATURE_1, this); - lp_var_t temperature2 = lp_var_t(sid.objectId, - P60System::ACU_TEMPERATURE_2, this); - lp_var_t temperature3 = lp_var_t(sid.objectId, - P60System::ACU_TEMPERATURE_3, this); + lp_var_t mpptMode = lp_var_t(sid.objectId, P60System::ACU_MPPT_MODE, this); - lp_var_t mpptMode = lp_var_t(sid.objectId, - P60System::ACU_MPPT_MODE, this); + lp_var_t vboostInChannel0 = + lp_var_t(sid.objectId, P60System::ACU_VBOOST_CHANNEL0, this); + lp_var_t vboostInChannel1 = + lp_var_t(sid.objectId, P60System::ACU_VBOOST_CHANNEL1, this); + lp_var_t vboostInChannel2 = + lp_var_t(sid.objectId, P60System::ACU_VBOOST_CHANNEL2, this); + lp_var_t vboostInChannel3 = + lp_var_t(sid.objectId, P60System::ACU_VBOOST_CHANNEL3, this); + lp_var_t vboostInChannel4 = + lp_var_t(sid.objectId, P60System::ACU_VBOOST_CHANNEL4, this); + lp_var_t vboostInChannel5 = + lp_var_t(sid.objectId, P60System::ACU_VBOOST_CHANNEL5, this); - lp_var_t vboostInChannel0 = lp_var_t(sid.objectId, - P60System::ACU_VBOOST_CHANNEL0, this); - lp_var_t vboostInChannel1 = lp_var_t(sid.objectId, - P60System::ACU_VBOOST_CHANNEL1, this); - lp_var_t vboostInChannel2 = lp_var_t(sid.objectId, - P60System::ACU_VBOOST_CHANNEL2, this); - lp_var_t vboostInChannel3 = lp_var_t(sid.objectId, - P60System::ACU_VBOOST_CHANNEL3, this); - lp_var_t vboostInChannel4 = lp_var_t(sid.objectId, - P60System::ACU_VBOOST_CHANNEL4, this); - lp_var_t vboostInChannel5 = lp_var_t(sid.objectId, - P60System::ACU_VBOOST_CHANNEL5, this); + lp_var_t powerInChannel0 = + lp_var_t(sid.objectId, P60System::ACU_POWER_CHANNEL0, this); + lp_var_t powerInChannel1 = + lp_var_t(sid.objectId, P60System::ACU_POWER_CHANNEL1, this); + lp_var_t powerInChannel2 = + lp_var_t(sid.objectId, P60System::ACU_POWER_CHANNEL2, this); + lp_var_t powerInChannel3 = + lp_var_t(sid.objectId, P60System::ACU_POWER_CHANNEL3, this); + lp_var_t powerInChannel4 = + lp_var_t(sid.objectId, P60System::ACU_POWER_CHANNEL4, this); + lp_var_t powerInChannel5 = + lp_var_t(sid.objectId, P60System::ACU_POWER_CHANNEL5, this); - lp_var_t powerInChannel0 = lp_var_t(sid.objectId, - P60System::ACU_POWER_CHANNEL0, this); - lp_var_t powerInChannel1 = lp_var_t(sid.objectId, - P60System::ACU_POWER_CHANNEL1, this); - lp_var_t powerInChannel2 = lp_var_t(sid.objectId, - P60System::ACU_POWER_CHANNEL2, this); - lp_var_t powerInChannel3 = lp_var_t(sid.objectId, - P60System::ACU_POWER_CHANNEL3, this); - lp_var_t powerInChannel4 = lp_var_t(sid.objectId, - P60System::ACU_POWER_CHANNEL4, this); - lp_var_t powerInChannel5 = lp_var_t(sid.objectId, - P60System::ACU_POWER_CHANNEL5, this); + lp_var_t dac0Enable = lp_var_t(sid.objectId, P60System::ACU_DAC_EN_0, this); + lp_var_t dac1Enable = lp_var_t(sid.objectId, P60System::ACU_DAC_EN_1, this); + lp_var_t dac2Enable = lp_var_t(sid.objectId, P60System::ACU_DAC_EN_2, this); - lp_var_t dac0Enable = lp_var_t(sid.objectId, - P60System::ACU_DAC_EN_0, this); - lp_var_t dac1Enable = lp_var_t(sid.objectId, - P60System::ACU_DAC_EN_1, this); - lp_var_t dac2Enable = lp_var_t(sid.objectId, - P60System::ACU_DAC_EN_2, this); + lp_var_t dacRawChannelVal0 = + lp_var_t(sid.objectId, P60System::ACU_DAC_RAW_0, this); + lp_var_t dacRawChannelVal1 = + lp_var_t(sid.objectId, P60System::ACU_DAC_RAW_1, this); + lp_var_t dacRawChannelVal2 = + lp_var_t(sid.objectId, P60System::ACU_DAC_RAW_2, this); + lp_var_t dacRawChannelVal3 = + lp_var_t(sid.objectId, P60System::ACU_DAC_RAW_3, this); + lp_var_t dacRawChannelVal4 = + lp_var_t(sid.objectId, P60System::ACU_DAC_RAW_4, this); + lp_var_t dacRawChannelVal5 = + lp_var_t(sid.objectId, P60System::ACU_DAC_RAW_5, this); - lp_var_t dacRawChannelVal0 = lp_var_t(sid.objectId, - P60System::ACU_DAC_RAW_0, this); - lp_var_t dacRawChannelVal1 = lp_var_t(sid.objectId, - P60System::ACU_DAC_RAW_1, this); - lp_var_t dacRawChannelVal2 = lp_var_t(sid.objectId, - P60System::ACU_DAC_RAW_2, this); - lp_var_t dacRawChannelVal3 = lp_var_t(sid.objectId, - P60System::ACU_DAC_RAW_3, this); - lp_var_t dacRawChannelVal4 = lp_var_t(sid.objectId, - P60System::ACU_DAC_RAW_4, this); - lp_var_t dacRawChannelVal5 = lp_var_t(sid.objectId, - P60System::ACU_DAC_RAW_5, this); + lp_var_t bootCause = lp_var_t(sid.objectId, P60System::ACU_BOOTCAUSE, this); + lp_var_t bootcnt = lp_var_t(sid.objectId, P60System::ACU_BOOTCNT, this); + lp_var_t uptime = lp_var_t(sid.objectId, P60System::ACU_UPTIME, this); + lp_var_t resetCause = + lp_var_t(sid.objectId, P60System::ACU_RESET_CAUSE, this); + lp_var_t mpptTime = lp_var_t(sid.objectId, P60System::ACU_MPPT_TIME, this); + lp_var_t mpptPeriod = + lp_var_t(sid.objectId, P60System::ACU_MPPT_PERIOD, this); - lp_var_t bootCause = lp_var_t(sid.objectId, - P60System::ACU_BOOTCAUSE, this); - lp_var_t bootcnt = lp_var_t(sid.objectId, - P60System::ACU_BOOTCNT, this); - lp_var_t uptime = lp_var_t(sid.objectId, - P60System::ACU_UPTIME, this); - lp_var_t resetCause = lp_var_t(sid.objectId, - P60System::ACU_RESET_CAUSE, this); - lp_var_t mpptTime = lp_var_t(sid.objectId, - P60System::ACU_MPPT_TIME, this); - lp_var_t mpptPeriod = lp_var_t(sid.objectId, - P60System::ACU_MPPT_PERIOD, this); + lp_var_t device0 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_0, this); + lp_var_t device1 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_1, this); + lp_var_t device2 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_2, this); + lp_var_t device3 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_3, this); + lp_var_t device4 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_4, this); + lp_var_t device5 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_5, this); + lp_var_t device6 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_6, this); + lp_var_t device7 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_7, this); - lp_var_t device0 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_0, this); - lp_var_t device1 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_1, this); - lp_var_t device2 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_2, this); - lp_var_t device3 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_3, this); - lp_var_t device4 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_4, this); - lp_var_t device5 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_5, this); - lp_var_t device6 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_6, this); - lp_var_t device7 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_7, this); + lp_var_t device0Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_0_STATUS, this); + lp_var_t device1Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_1_STATUS, this); + lp_var_t device2Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_2_STATUS, this); + lp_var_t device3Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_3_STATUS, this); + lp_var_t device4Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_4_STATUS, this); + lp_var_t device5Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_5_STATUS, this); + lp_var_t device6Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_6_STATUS, this); + lp_var_t device7Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_7_STATUS, this); - lp_var_t device0Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_0_STATUS, this); - lp_var_t device1Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_1_STATUS, this); - lp_var_t device2Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_2_STATUS, this); - lp_var_t device3Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_3_STATUS, this); - lp_var_t device4Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_4_STATUS, this); - lp_var_t device5Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_5_STATUS, this); - lp_var_t device6Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_6_STATUS, this); - lp_var_t device7Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_7_STATUS, this); - - lp_var_t wdtCntGnd = lp_var_t(sid.objectId, - P60System::ACU_WDT_CNT_GND, this); - lp_var_t wdtGndLeft = lp_var_t(sid.objectId, - P60System::ACU_WDT_GND_LEFT, this); + lp_var_t wdtCntGnd = lp_var_t(sid.objectId, P60System::ACU_WDT_CNT_GND, this); + lp_var_t wdtGndLeft = + lp_var_t(sid.objectId, P60System::ACU_WDT_GND_LEFT, this); }; -} +} // namespace ACU #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEDEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/GyroADIS1650XDefinitions.h b/mission/devices/devicedefinitions/GyroADIS1650XDefinitions.h index 62744e3a..a09d2fb7 100644 --- a/mission/devices/devicedefinitions/GyroADIS1650XDefinitions.h +++ b/mission/devices/devicedefinitions/GyroADIS1650XDefinitions.h @@ -1,17 +1,14 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_GYROADIS16507DEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_GYROADIS16507DEFINITIONS_H_ -#include "fsfw/devicehandlers/DeviceHandlerIF.h" -#include "fsfw/datapoollocal/StaticLocalDataSet.h" - #include +#include "fsfw/datapoollocal/StaticLocalDataSet.h" +#include "fsfw/devicehandlers/DeviceHandlerIF.h" + namespace ADIS1650X { -enum class Type { - ADIS16505, - ADIS16507 -}; +enum class Type { ADIS16505, ADIS16507 }; static constexpr size_t MAXIMUM_REPLY_SIZE = 64; static constexpr uint8_t WRITE_MASK = 0b1000'0000; @@ -63,91 +60,82 @@ static constexpr size_t SENSOR_READOUT_SIZE = 20 + 2; static constexpr uint32_t ADIS_DATASET_ID = READ_SENSOR_DATA; static constexpr uint32_t ADIS_CFG_DATASET_ID = READ_OUT_CONFIG; -enum GlobCmds: uint8_t { - FACTORY_CALIBRATION = 0b0000'0010, - SENSOR_SELF_TEST = 0b0000'0100, - FLASH_MEMORY_UPDATE = 0b0000'1000, - FLASH_MEMORY_TEST = 0b0001'0000, - SOFTWARE_RESET = 0b1000'0000 +enum GlobCmds : uint8_t { + FACTORY_CALIBRATION = 0b0000'0010, + SENSOR_SELF_TEST = 0b0000'0100, + FLASH_MEMORY_UPDATE = 0b0000'1000, + FLASH_MEMORY_TEST = 0b0001'0000, + SOFTWARE_RESET = 0b1000'0000 }; -enum PrimaryPoolIds: lp_id_t { - ANG_VELOC_X, - ANG_VELOC_Y, - ANG_VELOC_Z, - ACCELERATION_X, - ACCELERATION_Y, - ACCELERATION_Z, - TEMPERATURE, - DIAG_STAT_REGISTER, - FILTER_SETTINGS, - MSC_CTRL_REGISTER, - DEC_RATE_REGISTER, +enum PrimaryPoolIds : lp_id_t { + ANG_VELOC_X, + ANG_VELOC_Y, + ANG_VELOC_Z, + ACCELERATION_X, + ACCELERATION_Y, + ACCELERATION_Z, + TEMPERATURE, + DIAG_STAT_REGISTER, + FILTER_SETTINGS, + MSC_CTRL_REGISTER, + DEC_RATE_REGISTER, }; -enum FilterSettings: uint8_t { - NO_FILTER = 0, - TWO_TAPS = 1, - FOUR_TAPS = 2, - EIGHT_TAPS = 3, - SIXTEEN_TAPS = 4, - THIRTYTWO_TAPS = 5, - SIXTYFOUR_TAPS = 6 +enum FilterSettings : uint8_t { + NO_FILTER = 0, + TWO_TAPS = 1, + FOUR_TAPS = 2, + EIGHT_TAPS = 3, + SIXTEEN_TAPS = 4, + THIRTYTWO_TAPS = 5, + SIXTYFOUR_TAPS = 6 }; -} +} // namespace ADIS1650X -class AdisGyroPrimaryDataset: public StaticLocalDataSet<8> { -public: +class AdisGyroPrimaryDataset : public StaticLocalDataSet<8> { + public: + /** Constructor for data users like controllers */ + AdisGyroPrimaryDataset(object_id_t adisId) + : StaticLocalDataSet(sid_t(adisId, ADIS1650X::ADIS_DATASET_ID)) { + setAllVariablesReadOnly(); + } - /** Constructor for data users like controllers */ - AdisGyroPrimaryDataset(object_id_t adisId): - StaticLocalDataSet(sid_t(adisId, ADIS1650X::ADIS_DATASET_ID)) { - setAllVariablesReadOnly(); - } + /* Angular velocities in degrees per second (DPS) */ + lp_var_t angVelocX = lp_var_t(sid.objectId, ADIS1650X::ANG_VELOC_X, this); + lp_var_t angVelocY = lp_var_t(sid.objectId, ADIS1650X::ANG_VELOC_Y, this); + lp_var_t angVelocZ = lp_var_t(sid.objectId, ADIS1650X::ANG_VELOC_Z, this); + lp_var_t accelX = lp_var_t(sid.objectId, ADIS1650X::ACCELERATION_X, this); + lp_var_t accelY = lp_var_t(sid.objectId, ADIS1650X::ACCELERATION_Y, this); + lp_var_t accelZ = lp_var_t(sid.objectId, ADIS1650X::ACCELERATION_Z, this); + lp_var_t temperature = lp_var_t(sid.objectId, ADIS1650X::TEMPERATURE, this); - /* Angular velocities in degrees per second (DPS) */ - lp_var_t angVelocX = lp_var_t(sid.objectId, - ADIS1650X::ANG_VELOC_X, this); - lp_var_t angVelocY = lp_var_t(sid.objectId, - ADIS1650X::ANG_VELOC_Y, this); - lp_var_t angVelocZ = lp_var_t(sid.objectId, - ADIS1650X::ANG_VELOC_Z, this); - lp_var_t accelX = lp_var_t(sid.objectId, - ADIS1650X::ACCELERATION_X, this); - lp_var_t accelY = lp_var_t(sid.objectId, - ADIS1650X::ACCELERATION_Y, this); - lp_var_t accelZ = lp_var_t(sid.objectId, - ADIS1650X::ACCELERATION_Z, this); - lp_var_t temperature = lp_var_t(sid.objectId, - ADIS1650X::TEMPERATURE, this); -private: - - friend class GyroADIS1650XHandler; - /** Constructor for the data creator */ - AdisGyroPrimaryDataset(HasLocalDataPoolIF* hkOwner): - StaticLocalDataSet(hkOwner, ADIS1650X::ADIS_DATASET_ID) {} + private: + friend class GyroADIS1650XHandler; + /** Constructor for the data creator */ + AdisGyroPrimaryDataset(HasLocalDataPoolIF* hkOwner) + : StaticLocalDataSet(hkOwner, ADIS1650X::ADIS_DATASET_ID) {} }; -class AdisGyroConfigDataset: public StaticLocalDataSet<5> { -public: +class AdisGyroConfigDataset : public StaticLocalDataSet<5> { + public: + /** Constructor for data users like controllers */ + AdisGyroConfigDataset(object_id_t adisId) + : StaticLocalDataSet(sid_t(adisId, ADIS1650X::ADIS_CFG_DATASET_ID)) { + setAllVariablesReadOnly(); + } - /** Constructor for data users like controllers */ - AdisGyroConfigDataset(object_id_t adisId): - StaticLocalDataSet(sid_t(adisId, ADIS1650X::ADIS_CFG_DATASET_ID)) { - setAllVariablesReadOnly(); - } + lp_var_t diagStatReg = lp_var_t(sid.objectId, ADIS1650X::DIAG_STAT_REGISTER); + lp_var_t filterSetting = lp_var_t(sid.objectId, ADIS1650X::FILTER_SETTINGS); + lp_var_t mscCtrlReg = lp_var_t(sid.objectId, ADIS1650X::MSC_CTRL_REGISTER); + lp_var_t decRateReg = lp_var_t(sid.objectId, ADIS1650X::DEC_RATE_REGISTER); - lp_var_t diagStatReg = lp_var_t(sid.objectId, - ADIS1650X::DIAG_STAT_REGISTER); - lp_var_t filterSetting = lp_var_t(sid.objectId, ADIS1650X::FILTER_SETTINGS); - lp_var_t mscCtrlReg = lp_var_t(sid.objectId, ADIS1650X::MSC_CTRL_REGISTER); - lp_var_t decRateReg = lp_var_t(sid.objectId, ADIS1650X::DEC_RATE_REGISTER); -private: - friend class GyroADIS1650XHandler; - /** Constructor for the data creator */ - AdisGyroConfigDataset(HasLocalDataPoolIF* hkOwner): - StaticLocalDataSet(hkOwner, ADIS1650X::ADIS_CFG_DATASET_ID) {} + private: + friend class GyroADIS1650XHandler; + /** Constructor for the data creator */ + AdisGyroConfigDataset(HasLocalDataPoolIF* hkOwner) + : StaticLocalDataSet(hkOwner, ADIS1650X::ADIS_CFG_DATASET_ID) {} }; #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GYROADIS16507DEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/GyroL3GD20Definitions.h b/mission/devices/devicedefinitions/GyroL3GD20Definitions.h index b5b80495..4c4543d0 100644 --- a/mission/devices/devicedefinitions/GyroL3GD20Definitions.h +++ b/mission/devices/devicedefinitions/GyroL3GD20Definitions.h @@ -3,6 +3,7 @@ #include #include + #include namespace L3GD20H { @@ -36,8 +37,8 @@ static constexpr uint8_t SET_Z_ENABLE = 1 << 2; static constexpr uint8_t SET_X_ENABLE = 1 << 1; static constexpr uint8_t SET_Y_ENABLE = 1; -static constexpr uint8_t CTRL_REG_1_VAL = SET_POWER_NORMAL_MODE | SET_Z_ENABLE | - SET_Y_ENABLE | SET_X_ENABLE; +static constexpr uint8_t CTRL_REG_1_VAL = + SET_POWER_NORMAL_MODE | SET_Z_ENABLE | SET_Y_ENABLE | SET_X_ENABLE; /* Register 2 */ static constexpr uint8_t EXTERNAL_EDGE_ENB = 1 << 7; @@ -101,40 +102,29 @@ static constexpr DeviceCommandId_t READ_CTRL_REGS = 2; static constexpr uint32_t GYRO_DATASET_ID = READ_REGS; -enum GyroPoolIds: lp_id_t { - ANG_VELOC_X, - ANG_VELOC_Y, - ANG_VELOC_Z, - TEMPERATURE +enum GyroPoolIds : lp_id_t { ANG_VELOC_X, ANG_VELOC_Y, ANG_VELOC_Z, TEMPERATURE }; + +} // namespace L3GD20H + +class GyroPrimaryDataset : public StaticLocalDataSet<5> { + public: + /** Constructor for data users like controllers */ + GyroPrimaryDataset(object_id_t mgmId) + : StaticLocalDataSet(sid_t(mgmId, L3GD20H::GYRO_DATASET_ID)) { + setAllVariablesReadOnly(); + } + + /* Angular velocities in degrees per second (DPS) */ + lp_var_t angVelocX = lp_var_t(sid.objectId, L3GD20H::ANG_VELOC_X, this); + lp_var_t angVelocY = lp_var_t(sid.objectId, L3GD20H::ANG_VELOC_Y, this); + lp_var_t angVelocZ = lp_var_t(sid.objectId, L3GD20H::ANG_VELOC_Z, this); + lp_var_t temperature = lp_var_t(sid.objectId, L3GD20H::TEMPERATURE, this); + + private: + friend class GyroHandlerL3GD20H; + /** Constructor for the data creator */ + GyroPrimaryDataset(HasLocalDataPoolIF* hkOwner) + : StaticLocalDataSet(hkOwner, L3GD20H::GYRO_DATASET_ID) {} }; -} - -class GyroPrimaryDataset: public StaticLocalDataSet<5> { -public: - - /** Constructor for data users like controllers */ - GyroPrimaryDataset(object_id_t mgmId): - StaticLocalDataSet(sid_t(mgmId, L3GD20H::GYRO_DATASET_ID)) { - setAllVariablesReadOnly(); - } - - /* Angular velocities in degrees per second (DPS) */ - lp_var_t angVelocX = lp_var_t(sid.objectId, - L3GD20H::ANG_VELOC_X, this); - lp_var_t angVelocY = lp_var_t(sid.objectId, - L3GD20H::ANG_VELOC_Y, this); - lp_var_t angVelocZ = lp_var_t(sid.objectId, - L3GD20H::ANG_VELOC_Z, this); - lp_var_t temperature = lp_var_t(sid.objectId, - L3GD20H::TEMPERATURE, this); -private: - - friend class GyroHandlerL3GD20H; - /** Constructor for the data creator */ - GyroPrimaryDataset(HasLocalDataPoolIF* hkOwner): - StaticLocalDataSet(hkOwner, L3GD20H::GYRO_DATASET_ID) {} -}; - - #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GYROL3GD20DEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/IMTQHandlerDefinitions.h b/mission/devices/devicedefinitions/IMTQHandlerDefinitions.h index e95bd42e..609bbdf8 100644 --- a/mission/devices/devicedefinitions/IMTQHandlerDefinitions.h +++ b/mission/devices/devicedefinitions/IMTQHandlerDefinitions.h @@ -5,453 +5,435 @@ namespace IMTQ { - static const DeviceCommandId_t NONE = 0x0; - static const DeviceCommandId_t GET_ENG_HK_DATA = 0x1; - static const DeviceCommandId_t START_ACTUATION_DIPOLE = 0x2; - static const DeviceCommandId_t GET_COMMANDED_DIPOLE = 0x3; - /** Generates new measurement of the magnetic field */ - static const DeviceCommandId_t START_MTM_MEASUREMENT = 0x4; - /** Requests the calibrated magnetometer measurement */ - static const DeviceCommandId_t GET_CAL_MTM_MEASUREMENT = 0x5; - /** Requests the raw values measured by the built-in MTM XEN1210 */ - static const DeviceCommandId_t GET_RAW_MTM_MEASUREMENT = 0x6; - static const DeviceCommandId_t POS_X_SELF_TEST = 0x7; - static const DeviceCommandId_t NEG_X_SELF_TEST = 0x8; - static const DeviceCommandId_t POS_Y_SELF_TEST = 0x9; - static const DeviceCommandId_t NEG_Y_SELF_TEST = 0xA; - static const DeviceCommandId_t POS_Z_SELF_TEST = 0xB; - static const DeviceCommandId_t NEG_Z_SELF_TEST = 0xC; - static const DeviceCommandId_t GET_SELF_TEST_RESULT = 0xD; +static const DeviceCommandId_t NONE = 0x0; +static const DeviceCommandId_t GET_ENG_HK_DATA = 0x1; +static const DeviceCommandId_t START_ACTUATION_DIPOLE = 0x2; +static const DeviceCommandId_t GET_COMMANDED_DIPOLE = 0x3; +/** Generates new measurement of the magnetic field */ +static const DeviceCommandId_t START_MTM_MEASUREMENT = 0x4; +/** Requests the calibrated magnetometer measurement */ +static const DeviceCommandId_t GET_CAL_MTM_MEASUREMENT = 0x5; +/** Requests the raw values measured by the built-in MTM XEN1210 */ +static const DeviceCommandId_t GET_RAW_MTM_MEASUREMENT = 0x6; +static const DeviceCommandId_t POS_X_SELF_TEST = 0x7; +static const DeviceCommandId_t NEG_X_SELF_TEST = 0x8; +static const DeviceCommandId_t POS_Y_SELF_TEST = 0x9; +static const DeviceCommandId_t NEG_Y_SELF_TEST = 0xA; +static const DeviceCommandId_t POS_Z_SELF_TEST = 0xB; +static const DeviceCommandId_t NEG_Z_SELF_TEST = 0xC; +static const DeviceCommandId_t GET_SELF_TEST_RESULT = 0xD; - static const uint8_t GET_TEMP_REPLY_SIZE = 2; - static const uint8_t CFGR_CMD_SIZE = 3; - static const uint8_t POINTER_REG_SIZE = 1; +static const uint8_t GET_TEMP_REPLY_SIZE = 2; +static const uint8_t CFGR_CMD_SIZE = 3; +static const uint8_t POINTER_REG_SIZE = 1; - static const uint32_t ENG_HK_DATA_SET_ID = 1; - static const uint32_t CAL_MTM_SET = 2; - static const uint32_t RAW_MTM_SET = 3; - static const uint32_t POS_X_TEST_DATASET = 4; - static const uint32_t NEG_X_TEST_DATASET = 5; - static const uint32_t POS_Y_TEST_DATASET = 6; - static const uint32_t NEG_Y_TEST_DATASET = 7; - static const uint32_t POS_Z_TEST_DATASET = 8; - static const uint32_t NEG_Z_TEST_DATASET = 9; +static const uint32_t ENG_HK_DATA_SET_ID = 1; +static const uint32_t CAL_MTM_SET = 2; +static const uint32_t RAW_MTM_SET = 3; +static const uint32_t POS_X_TEST_DATASET = 4; +static const uint32_t NEG_X_TEST_DATASET = 5; +static const uint32_t POS_Y_TEST_DATASET = 6; +static const uint32_t NEG_Y_TEST_DATASET = 7; +static const uint32_t POS_Z_TEST_DATASET = 8; +static const uint32_t NEG_Z_TEST_DATASET = 9; - static const uint8_t SIZE_ENG_HK_COMMAND = 1; - static const uint8_t SIZE_STATUS_REPLY = 2; - static const uint8_t SIZE_ENG_HK_DATA_REPLY = 24; - static const uint8_t SIZE_GET_COMMANDED_DIPOLE_REPLY = 8; - static const uint8_t SIZE_GET_CAL_MTM_MEASUREMENT = 15; - static const uint8_t SIZE_GET_RAW_MTM_MEASUREMENT = 15; - static const uint16_t SIZE_SELF_TEST_RESULTS = 120; +static const uint8_t SIZE_ENG_HK_COMMAND = 1; +static const uint8_t SIZE_STATUS_REPLY = 2; +static const uint8_t SIZE_ENG_HK_DATA_REPLY = 24; +static const uint8_t SIZE_GET_COMMANDED_DIPOLE_REPLY = 8; +static const uint8_t SIZE_GET_CAL_MTM_MEASUREMENT = 15; +static const uint8_t SIZE_GET_RAW_MTM_MEASUREMENT = 15; +static const uint16_t SIZE_SELF_TEST_RESULTS = 120; - static const uint16_t MAX_REPLY_SIZE = SIZE_SELF_TEST_RESULTS; - static const uint8_t MAX_COMMAND_SIZE = 9; +static const uint16_t MAX_REPLY_SIZE = SIZE_SELF_TEST_RESULTS; +static const uint8_t MAX_COMMAND_SIZE = 9; - /** Define entries in IMTQ specific dataset */ - static const uint8_t ENG_HK_SET_POOL_ENTRIES = 11; - static const uint8_t CAL_MTM_POOL_ENTRIES = 4; - static const uint8_t SELF_TEST_DATASET_ENTRIES = 104; +/** Define entries in IMTQ specific dataset */ +static const uint8_t ENG_HK_SET_POOL_ENTRIES = 11; +static const uint8_t CAL_MTM_POOL_ENTRIES = 4; +static const uint8_t SELF_TEST_DATASET_ENTRIES = 104; - /** Error codes for interpreting the self test error byte */ - static const uint8_t I2C_FAILURE_MASK = 0x1; - static const uint8_t SPI_FAILURE_MASK = 0x2; // MTM connectivity - static const uint8_t ADC_FAILURE_MASK = 0x4; // Current/Temp measurement - static const uint8_t PWM_FAILURE_MASK = 0x8; // Coil actuation - static const uint8_t TC_FAILURE_MASK = 0x10; // System failure - static const uint8_t MTM_RANGE_FAILURE_MASK = 0x20; // MTM values outside of expected range - static const uint8_t COIL_CURRENT_FAILURE_MASK = 0x40; // Coil currents outside of expected range - static const uint8_t INVALID_ERROR_BYTE = 0x80; // This is an invalid error byte and should be never replied by the IMTQ +/** Error codes for interpreting the self test error byte */ +static const uint8_t I2C_FAILURE_MASK = 0x1; +static const uint8_t SPI_FAILURE_MASK = 0x2; // MTM connectivity +static const uint8_t ADC_FAILURE_MASK = 0x4; // Current/Temp measurement +static const uint8_t PWM_FAILURE_MASK = 0x8; // Coil actuation +static const uint8_t TC_FAILURE_MASK = 0x10; // System failure +static const uint8_t MTM_RANGE_FAILURE_MASK = 0x20; // MTM values outside of expected range +static const uint8_t COIL_CURRENT_FAILURE_MASK = 0x40; // Coil currents outside of expected range +static const uint8_t INVALID_ERROR_BYTE = + 0x80; // This is an invalid error byte and should be never replied by the IMTQ - static const uint8_t MAIN_STEP_OFFSET = 43; +static const uint8_t MAIN_STEP_OFFSET = 43; - /** - * Command code definitions. Each command or reply of an IMTQ request will begin with one of - * the following command codes. - */ - namespace CC { - static const uint8_t START_MTM_MEASUREMENT = 0x4; - static const uint8_t START_ACTUATION_DIPOLE = 0x6; - static const uint8_t SELF_TEST_CMD = 0x8; - static const uint8_t SOFTWARE_RESET = 0xAA; - static const uint8_t GET_ENG_HK_DATA = 0x4A; - static const uint8_t GET_COMMANDED_DIPOLE = 0x46; - static const uint8_t GET_RAW_MTM_MEASUREMENT = 0x42; - static const uint8_t GET_CAL_MTM_MEASUREMENT = 0x43; - static const uint8_t GET_SELF_TEST_RESULT = 0x47; - }; +/** + * Command code definitions. Each command or reply of an IMTQ request will begin with one of + * the following command codes. + */ +namespace CC { +static const uint8_t START_MTM_MEASUREMENT = 0x4; +static const uint8_t START_ACTUATION_DIPOLE = 0x6; +static const uint8_t SELF_TEST_CMD = 0x8; +static const uint8_t SOFTWARE_RESET = 0xAA; +static const uint8_t GET_ENG_HK_DATA = 0x4A; +static const uint8_t GET_COMMANDED_DIPOLE = 0x46; +static const uint8_t GET_RAW_MTM_MEASUREMENT = 0x42; +static const uint8_t GET_CAL_MTM_MEASUREMENT = 0x43; +static const uint8_t GET_SELF_TEST_RESULT = 0x47; +}; // namespace CC - namespace SELF_TEST_AXIS { - static const uint8_t ALL = 0x0; - static const uint8_t X_POSITIVE = 0x1; - static const uint8_t X_NEGATIVE = 0x2; - static const uint8_t Y_POSITIVE = 0x3; - static const uint8_t Y_NEGATIVE = 0x4; - static const uint8_t Z_POSITIVE = 0x5; - static const uint8_t Z_NEGATIVE = 0x6; - } +namespace SELF_TEST_AXIS { +static const uint8_t ALL = 0x0; +static const uint8_t X_POSITIVE = 0x1; +static const uint8_t X_NEGATIVE = 0x2; +static const uint8_t Y_POSITIVE = 0x3; +static const uint8_t Y_NEGATIVE = 0x4; +static const uint8_t Z_POSITIVE = 0x5; +static const uint8_t Z_NEGATIVE = 0x6; +} // namespace SELF_TEST_AXIS - namespace SELF_TEST_STEPS { - static const uint8_t INIT = 0x0; - static const uint8_t X_POSITIVE = 0x1; - static const uint8_t X_NEGATIVE = 0x2; - static const uint8_t Y_POSITIVE = 0x3; - static const uint8_t Y_NEGATIVE = 0x4; - static const uint8_t Z_POSITIVE = 0x5; - static const uint8_t Z_NEGATIVE = 0x6; - static const uint8_t FINA = 0x7; - } +namespace SELF_TEST_STEPS { +static const uint8_t INIT = 0x0; +static const uint8_t X_POSITIVE = 0x1; +static const uint8_t X_NEGATIVE = 0x2; +static const uint8_t Y_POSITIVE = 0x3; +static const uint8_t Y_NEGATIVE = 0x4; +static const uint8_t Z_POSITIVE = 0x5; +static const uint8_t Z_NEGATIVE = 0x6; +static const uint8_t FINA = 0x7; +} // namespace SELF_TEST_STEPS - enum IMTQPoolIds: lp_id_t { - DIGITAL_VOLTAGE_MV, - ANALOG_VOLTAGE_MV, - DIGITAL_CURRENT, - ANALOG_CURRENT, - COIL_X_CURRENT, - COIL_Y_CURRENT, - COIL_Z_CURRENT, - COIL_X_TEMPERATURE, - COIL_Y_TEMPERATURE, - COIL_Z_TEMPERATURE, - MCU_TEMPERATURE, - MTM_CAL_X, - MTM_CAL_Y, - MTM_CAL_Z, - ACTUATION_CAL_STATUS, - MTM_RAW_X, - MTM_RAW_Y, - MTM_RAW_Z, - ACTUATION_RAW_STATUS, +enum IMTQPoolIds : lp_id_t { + DIGITAL_VOLTAGE_MV, + ANALOG_VOLTAGE_MV, + DIGITAL_CURRENT, + ANALOG_CURRENT, + COIL_X_CURRENT, + COIL_Y_CURRENT, + COIL_Z_CURRENT, + COIL_X_TEMPERATURE, + COIL_Y_TEMPERATURE, + COIL_Z_TEMPERATURE, + MCU_TEMPERATURE, + MTM_CAL_X, + MTM_CAL_Y, + MTM_CAL_Z, + ACTUATION_CAL_STATUS, + MTM_RAW_X, + MTM_RAW_Y, + MTM_RAW_Z, + ACTUATION_RAW_STATUS, - INIT_POS_X_ERR, - INIT_POS_X_RAW_MAG_X, - INIT_POS_X_RAW_MAG_Y, - INIT_POS_X_RAW_MAG_Z, - INIT_POS_X_CAL_MAG_X, - INIT_POS_X_CAL_MAG_Y, - INIT_POS_X_CAL_MAG_Z, - INIT_POS_X_COIL_X_CURRENT, - INIT_POS_X_COIL_Y_CURRENT, - INIT_POS_X_COIL_Z_CURRENT, - INIT_POS_X_COIL_X_TEMPERATURE, - INIT_POS_X_COIL_Y_TEMPERATURE, - INIT_POS_X_COIL_Z_TEMPERATURE, + INIT_POS_X_ERR, + INIT_POS_X_RAW_MAG_X, + INIT_POS_X_RAW_MAG_Y, + INIT_POS_X_RAW_MAG_Z, + INIT_POS_X_CAL_MAG_X, + INIT_POS_X_CAL_MAG_Y, + INIT_POS_X_CAL_MAG_Z, + INIT_POS_X_COIL_X_CURRENT, + INIT_POS_X_COIL_Y_CURRENT, + INIT_POS_X_COIL_Z_CURRENT, + INIT_POS_X_COIL_X_TEMPERATURE, + INIT_POS_X_COIL_Y_TEMPERATURE, + INIT_POS_X_COIL_Z_TEMPERATURE, - INIT_NEG_X_ERR, - INIT_NEG_X_RAW_MAG_X, - INIT_NEG_X_RAW_MAG_Y, - INIT_NEG_X_RAW_MAG_Z, - INIT_NEG_X_CAL_MAG_X, - INIT_NEG_X_CAL_MAG_Y, - INIT_NEG_X_CAL_MAG_Z, - INIT_NEG_X_COIL_X_CURRENT, - INIT_NEG_X_COIL_Y_CURRENT, - INIT_NEG_X_COIL_Z_CURRENT, - INIT_NEG_X_COIL_X_TEMPERATURE, - INIT_NEG_X_COIL_Y_TEMPERATURE, - INIT_NEG_X_COIL_Z_TEMPERATURE, + INIT_NEG_X_ERR, + INIT_NEG_X_RAW_MAG_X, + INIT_NEG_X_RAW_MAG_Y, + INIT_NEG_X_RAW_MAG_Z, + INIT_NEG_X_CAL_MAG_X, + INIT_NEG_X_CAL_MAG_Y, + INIT_NEG_X_CAL_MAG_Z, + INIT_NEG_X_COIL_X_CURRENT, + INIT_NEG_X_COIL_Y_CURRENT, + INIT_NEG_X_COIL_Z_CURRENT, + INIT_NEG_X_COIL_X_TEMPERATURE, + INIT_NEG_X_COIL_Y_TEMPERATURE, + INIT_NEG_X_COIL_Z_TEMPERATURE, - INIT_POS_Y_ERR, - INIT_POS_Y_RAW_MAG_X, - INIT_POS_Y_RAW_MAG_Y, - INIT_POS_Y_RAW_MAG_Z, - INIT_POS_Y_CAL_MAG_X, - INIT_POS_Y_CAL_MAG_Y, - INIT_POS_Y_CAL_MAG_Z, - INIT_POS_Y_COIL_X_CURRENT, - INIT_POS_Y_COIL_Y_CURRENT, - INIT_POS_Y_COIL_Z_CURRENT, - INIT_POS_Y_COIL_X_TEMPERATURE, - INIT_POS_Y_COIL_Y_TEMPERATURE, - INIT_POS_Y_COIL_Z_TEMPERATURE, + INIT_POS_Y_ERR, + INIT_POS_Y_RAW_MAG_X, + INIT_POS_Y_RAW_MAG_Y, + INIT_POS_Y_RAW_MAG_Z, + INIT_POS_Y_CAL_MAG_X, + INIT_POS_Y_CAL_MAG_Y, + INIT_POS_Y_CAL_MAG_Z, + INIT_POS_Y_COIL_X_CURRENT, + INIT_POS_Y_COIL_Y_CURRENT, + INIT_POS_Y_COIL_Z_CURRENT, + INIT_POS_Y_COIL_X_TEMPERATURE, + INIT_POS_Y_COIL_Y_TEMPERATURE, + INIT_POS_Y_COIL_Z_TEMPERATURE, - INIT_NEG_Y_ERR, - INIT_NEG_Y_RAW_MAG_X, - INIT_NEG_Y_RAW_MAG_Y, - INIT_NEG_Y_RAW_MAG_Z, - INIT_NEG_Y_CAL_MAG_X, - INIT_NEG_Y_CAL_MAG_Y, - INIT_NEG_Y_CAL_MAG_Z, - INIT_NEG_Y_COIL_X_CURRENT, - INIT_NEG_Y_COIL_Y_CURRENT, - INIT_NEG_Y_COIL_Z_CURRENT, - INIT_NEG_Y_COIL_X_TEMPERATURE, - INIT_NEG_Y_COIL_Y_TEMPERATURE, - INIT_NEG_Y_COIL_Z_TEMPERATURE, + INIT_NEG_Y_ERR, + INIT_NEG_Y_RAW_MAG_X, + INIT_NEG_Y_RAW_MAG_Y, + INIT_NEG_Y_RAW_MAG_Z, + INIT_NEG_Y_CAL_MAG_X, + INIT_NEG_Y_CAL_MAG_Y, + INIT_NEG_Y_CAL_MAG_Z, + INIT_NEG_Y_COIL_X_CURRENT, + INIT_NEG_Y_COIL_Y_CURRENT, + INIT_NEG_Y_COIL_Z_CURRENT, + INIT_NEG_Y_COIL_X_TEMPERATURE, + INIT_NEG_Y_COIL_Y_TEMPERATURE, + INIT_NEG_Y_COIL_Z_TEMPERATURE, - INIT_POS_Z_ERR, - INIT_POS_Z_RAW_MAG_X, - INIT_POS_Z_RAW_MAG_Y, - INIT_POS_Z_RAW_MAG_Z, - INIT_POS_Z_CAL_MAG_X, - INIT_POS_Z_CAL_MAG_Y, - INIT_POS_Z_CAL_MAG_Z, - INIT_POS_Z_COIL_X_CURRENT, - INIT_POS_Z_COIL_Y_CURRENT, - INIT_POS_Z_COIL_Z_CURRENT, - INIT_POS_Z_COIL_X_TEMPERATURE, - INIT_POS_Z_COIL_Y_TEMPERATURE, - INIT_POS_Z_COIL_Z_TEMPERATURE, + INIT_POS_Z_ERR, + INIT_POS_Z_RAW_MAG_X, + INIT_POS_Z_RAW_MAG_Y, + INIT_POS_Z_RAW_MAG_Z, + INIT_POS_Z_CAL_MAG_X, + INIT_POS_Z_CAL_MAG_Y, + INIT_POS_Z_CAL_MAG_Z, + INIT_POS_Z_COIL_X_CURRENT, + INIT_POS_Z_COIL_Y_CURRENT, + INIT_POS_Z_COIL_Z_CURRENT, + INIT_POS_Z_COIL_X_TEMPERATURE, + INIT_POS_Z_COIL_Y_TEMPERATURE, + INIT_POS_Z_COIL_Z_TEMPERATURE, - INIT_NEG_Z_ERR, - INIT_NEG_Z_RAW_MAG_X, - INIT_NEG_Z_RAW_MAG_Y, - INIT_NEG_Z_RAW_MAG_Z, - INIT_NEG_Z_CAL_MAG_X, - INIT_NEG_Z_CAL_MAG_Y, - INIT_NEG_Z_CAL_MAG_Z, - INIT_NEG_Z_COIL_X_CURRENT, - INIT_NEG_Z_COIL_Y_CURRENT, - INIT_NEG_Z_COIL_Z_CURRENT, - INIT_NEG_Z_COIL_X_TEMPERATURE, - INIT_NEG_Z_COIL_Y_TEMPERATURE, - INIT_NEG_Z_COIL_Z_TEMPERATURE, + INIT_NEG_Z_ERR, + INIT_NEG_Z_RAW_MAG_X, + INIT_NEG_Z_RAW_MAG_Y, + INIT_NEG_Z_RAW_MAG_Z, + INIT_NEG_Z_CAL_MAG_X, + INIT_NEG_Z_CAL_MAG_Y, + INIT_NEG_Z_CAL_MAG_Z, + INIT_NEG_Z_COIL_X_CURRENT, + INIT_NEG_Z_COIL_Y_CURRENT, + INIT_NEG_Z_COIL_Z_CURRENT, + INIT_NEG_Z_COIL_X_TEMPERATURE, + INIT_NEG_Z_COIL_Y_TEMPERATURE, + INIT_NEG_Z_COIL_Z_TEMPERATURE, - POS_X_ERR, - POS_X_RAW_MAG_X, - POS_X_RAW_MAG_Y, - POS_X_RAW_MAG_Z, - POS_X_CAL_MAG_X, - POS_X_CAL_MAG_Y, - POS_X_CAL_MAG_Z, - POS_X_COIL_X_CURRENT, - POS_X_COIL_Y_CURRENT, - POS_X_COIL_Z_CURRENT, - POS_X_COIL_X_TEMPERATURE, - POS_X_COIL_Y_TEMPERATURE, - POS_X_COIL_Z_TEMPERATURE, + POS_X_ERR, + POS_X_RAW_MAG_X, + POS_X_RAW_MAG_Y, + POS_X_RAW_MAG_Z, + POS_X_CAL_MAG_X, + POS_X_CAL_MAG_Y, + POS_X_CAL_MAG_Z, + POS_X_COIL_X_CURRENT, + POS_X_COIL_Y_CURRENT, + POS_X_COIL_Z_CURRENT, + POS_X_COIL_X_TEMPERATURE, + POS_X_COIL_Y_TEMPERATURE, + POS_X_COIL_Z_TEMPERATURE, - NEG_X_ERR, - NEG_X_RAW_MAG_X, - NEG_X_RAW_MAG_Y, - NEG_X_RAW_MAG_Z, - NEG_X_CAL_MAG_X, - NEG_X_CAL_MAG_Y, - NEG_X_CAL_MAG_Z, - NEG_X_COIL_X_CURRENT, - NEG_X_COIL_Y_CURRENT, - NEG_X_COIL_Z_CURRENT, - NEG_X_COIL_X_TEMPERATURE, - NEG_X_COIL_Y_TEMPERATURE, - NEG_X_COIL_Z_TEMPERATURE, + NEG_X_ERR, + NEG_X_RAW_MAG_X, + NEG_X_RAW_MAG_Y, + NEG_X_RAW_MAG_Z, + NEG_X_CAL_MAG_X, + NEG_X_CAL_MAG_Y, + NEG_X_CAL_MAG_Z, + NEG_X_COIL_X_CURRENT, + NEG_X_COIL_Y_CURRENT, + NEG_X_COIL_Z_CURRENT, + NEG_X_COIL_X_TEMPERATURE, + NEG_X_COIL_Y_TEMPERATURE, + NEG_X_COIL_Z_TEMPERATURE, - POS_Y_ERR, - POS_Y_RAW_MAG_X, - POS_Y_RAW_MAG_Y, - POS_Y_RAW_MAG_Z, - POS_Y_CAL_MAG_X, - POS_Y_CAL_MAG_Y, - POS_Y_CAL_MAG_Z, - POS_Y_COIL_X_CURRENT, - POS_Y_COIL_Y_CURRENT, - POS_Y_COIL_Z_CURRENT, - POS_Y_COIL_X_TEMPERATURE, - POS_Y_COIL_Y_TEMPERATURE, - POS_Y_COIL_Z_TEMPERATURE, + POS_Y_ERR, + POS_Y_RAW_MAG_X, + POS_Y_RAW_MAG_Y, + POS_Y_RAW_MAG_Z, + POS_Y_CAL_MAG_X, + POS_Y_CAL_MAG_Y, + POS_Y_CAL_MAG_Z, + POS_Y_COIL_X_CURRENT, + POS_Y_COIL_Y_CURRENT, + POS_Y_COIL_Z_CURRENT, + POS_Y_COIL_X_TEMPERATURE, + POS_Y_COIL_Y_TEMPERATURE, + POS_Y_COIL_Z_TEMPERATURE, - NEG_Y_ERR, - NEG_Y_RAW_MAG_X, - NEG_Y_RAW_MAG_Y, - NEG_Y_RAW_MAG_Z, - NEG_Y_CAL_MAG_X, - NEG_Y_CAL_MAG_Y, - NEG_Y_CAL_MAG_Z, - NEG_Y_COIL_X_CURRENT, - NEG_Y_COIL_Y_CURRENT, - NEG_Y_COIL_Z_CURRENT, - NEG_Y_COIL_X_TEMPERATURE, - NEG_Y_COIL_Y_TEMPERATURE, - NEG_Y_COIL_Z_TEMPERATURE, + NEG_Y_ERR, + NEG_Y_RAW_MAG_X, + NEG_Y_RAW_MAG_Y, + NEG_Y_RAW_MAG_Z, + NEG_Y_CAL_MAG_X, + NEG_Y_CAL_MAG_Y, + NEG_Y_CAL_MAG_Z, + NEG_Y_COIL_X_CURRENT, + NEG_Y_COIL_Y_CURRENT, + NEG_Y_COIL_Z_CURRENT, + NEG_Y_COIL_X_TEMPERATURE, + NEG_Y_COIL_Y_TEMPERATURE, + NEG_Y_COIL_Z_TEMPERATURE, - POS_Z_ERR, - POS_Z_RAW_MAG_X, - POS_Z_RAW_MAG_Y, - POS_Z_RAW_MAG_Z, - POS_Z_CAL_MAG_X, - POS_Z_CAL_MAG_Y, - POS_Z_CAL_MAG_Z, - POS_Z_COIL_X_CURRENT, - POS_Z_COIL_Y_CURRENT, - POS_Z_COIL_Z_CURRENT, - POS_Z_COIL_X_TEMPERATURE, - POS_Z_COIL_Y_TEMPERATURE, - POS_Z_COIL_Z_TEMPERATURE, + POS_Z_ERR, + POS_Z_RAW_MAG_X, + POS_Z_RAW_MAG_Y, + POS_Z_RAW_MAG_Z, + POS_Z_CAL_MAG_X, + POS_Z_CAL_MAG_Y, + POS_Z_CAL_MAG_Z, + POS_Z_COIL_X_CURRENT, + POS_Z_COIL_Y_CURRENT, + POS_Z_COIL_Z_CURRENT, + POS_Z_COIL_X_TEMPERATURE, + POS_Z_COIL_Y_TEMPERATURE, + POS_Z_COIL_Z_TEMPERATURE, - NEG_Z_ERR, - NEG_Z_RAW_MAG_X, - NEG_Z_RAW_MAG_Y, - NEG_Z_RAW_MAG_Z, - NEG_Z_CAL_MAG_X, - NEG_Z_CAL_MAG_Y, - NEG_Z_CAL_MAG_Z, - NEG_Z_COIL_X_CURRENT, - NEG_Z_COIL_Y_CURRENT, - NEG_Z_COIL_Z_CURRENT, - NEG_Z_COIL_X_TEMPERATURE, - NEG_Z_COIL_Y_TEMPERATURE, - NEG_Z_COIL_Z_TEMPERATURE, + NEG_Z_ERR, + NEG_Z_RAW_MAG_X, + NEG_Z_RAW_MAG_Y, + NEG_Z_RAW_MAG_Z, + NEG_Z_CAL_MAG_X, + NEG_Z_CAL_MAG_Y, + NEG_Z_CAL_MAG_Z, + NEG_Z_COIL_X_CURRENT, + NEG_Z_COIL_Y_CURRENT, + NEG_Z_COIL_Z_CURRENT, + NEG_Z_COIL_X_TEMPERATURE, + NEG_Z_COIL_Y_TEMPERATURE, + NEG_Z_COIL_Z_TEMPERATURE, - FINA_POS_X_ERR, - FINA_POS_X_RAW_MAG_X, - FINA_POS_X_RAW_MAG_Y, - FINA_POS_X_RAW_MAG_Z, - FINA_POS_X_CAL_MAG_X, - FINA_POS_X_CAL_MAG_Y, - FINA_POS_X_CAL_MAG_Z, - FINA_POS_X_COIL_X_CURRENT, - FINA_POS_X_COIL_Y_CURRENT, - FINA_POS_X_COIL_Z_CURRENT, - FINA_POS_X_COIL_X_TEMPERATURE, - FINA_POS_X_COIL_Y_TEMPERATURE, - FINA_POS_X_COIL_Z_TEMPERATURE, + FINA_POS_X_ERR, + FINA_POS_X_RAW_MAG_X, + FINA_POS_X_RAW_MAG_Y, + FINA_POS_X_RAW_MAG_Z, + FINA_POS_X_CAL_MAG_X, + FINA_POS_X_CAL_MAG_Y, + FINA_POS_X_CAL_MAG_Z, + FINA_POS_X_COIL_X_CURRENT, + FINA_POS_X_COIL_Y_CURRENT, + FINA_POS_X_COIL_Z_CURRENT, + FINA_POS_X_COIL_X_TEMPERATURE, + FINA_POS_X_COIL_Y_TEMPERATURE, + FINA_POS_X_COIL_Z_TEMPERATURE, - FINA_NEG_X_ERR, - FINA_NEG_X_RAW_MAG_X, - FINA_NEG_X_RAW_MAG_Y, - FINA_NEG_X_RAW_MAG_Z, - FINA_NEG_X_CAL_MAG_X, - FINA_NEG_X_CAL_MAG_Y, - FINA_NEG_X_CAL_MAG_Z, - FINA_NEG_X_COIL_X_CURRENT, - FINA_NEG_X_COIL_Y_CURRENT, - FINA_NEG_X_COIL_Z_CURRENT, - FINA_NEG_X_COIL_X_TEMPERATURE, - FINA_NEG_X_COIL_Y_TEMPERATURE, - FINA_NEG_X_COIL_Z_TEMPERATURE, + FINA_NEG_X_ERR, + FINA_NEG_X_RAW_MAG_X, + FINA_NEG_X_RAW_MAG_Y, + FINA_NEG_X_RAW_MAG_Z, + FINA_NEG_X_CAL_MAG_X, + FINA_NEG_X_CAL_MAG_Y, + FINA_NEG_X_CAL_MAG_Z, + FINA_NEG_X_COIL_X_CURRENT, + FINA_NEG_X_COIL_Y_CURRENT, + FINA_NEG_X_COIL_Z_CURRENT, + FINA_NEG_X_COIL_X_TEMPERATURE, + FINA_NEG_X_COIL_Y_TEMPERATURE, + FINA_NEG_X_COIL_Z_TEMPERATURE, - FINA_POS_Y_ERR, - FINA_POS_Y_RAW_MAG_X, - FINA_POS_Y_RAW_MAG_Y, - FINA_POS_Y_RAW_MAG_Z, - FINA_POS_Y_CAL_MAG_X, - FINA_POS_Y_CAL_MAG_Y, - FINA_POS_Y_CAL_MAG_Z, - FINA_POS_Y_COIL_X_CURRENT, - FINA_POS_Y_COIL_Y_CURRENT, - FINA_POS_Y_COIL_Z_CURRENT, - FINA_POS_Y_COIL_X_TEMPERATURE, - FINA_POS_Y_COIL_Y_TEMPERATURE, - FINA_POS_Y_COIL_Z_TEMPERATURE, + FINA_POS_Y_ERR, + FINA_POS_Y_RAW_MAG_X, + FINA_POS_Y_RAW_MAG_Y, + FINA_POS_Y_RAW_MAG_Z, + FINA_POS_Y_CAL_MAG_X, + FINA_POS_Y_CAL_MAG_Y, + FINA_POS_Y_CAL_MAG_Z, + FINA_POS_Y_COIL_X_CURRENT, + FINA_POS_Y_COIL_Y_CURRENT, + FINA_POS_Y_COIL_Z_CURRENT, + FINA_POS_Y_COIL_X_TEMPERATURE, + FINA_POS_Y_COIL_Y_TEMPERATURE, + FINA_POS_Y_COIL_Z_TEMPERATURE, - FINA_NEG_Y_ERR, - FINA_NEG_Y_RAW_MAG_X, - FINA_NEG_Y_RAW_MAG_Y, - FINA_NEG_Y_RAW_MAG_Z, - FINA_NEG_Y_CAL_MAG_X, - FINA_NEG_Y_CAL_MAG_Y, - FINA_NEG_Y_CAL_MAG_Z, - FINA_NEG_Y_COIL_X_CURRENT, - FINA_NEG_Y_COIL_Y_CURRENT, - FINA_NEG_Y_COIL_Z_CURRENT, - FINA_NEG_Y_COIL_X_TEMPERATURE, - FINA_NEG_Y_COIL_Y_TEMPERATURE, - FINA_NEG_Y_COIL_Z_TEMPERATURE, + FINA_NEG_Y_ERR, + FINA_NEG_Y_RAW_MAG_X, + FINA_NEG_Y_RAW_MAG_Y, + FINA_NEG_Y_RAW_MAG_Z, + FINA_NEG_Y_CAL_MAG_X, + FINA_NEG_Y_CAL_MAG_Y, + FINA_NEG_Y_CAL_MAG_Z, + FINA_NEG_Y_COIL_X_CURRENT, + FINA_NEG_Y_COIL_Y_CURRENT, + FINA_NEG_Y_COIL_Z_CURRENT, + FINA_NEG_Y_COIL_X_TEMPERATURE, + FINA_NEG_Y_COIL_Y_TEMPERATURE, + FINA_NEG_Y_COIL_Z_TEMPERATURE, - FINA_POS_Z_ERR, - FINA_POS_Z_RAW_MAG_X, - FINA_POS_Z_RAW_MAG_Y, - FINA_POS_Z_RAW_MAG_Z, - FINA_POS_Z_CAL_MAG_X, - FINA_POS_Z_CAL_MAG_Y, - FINA_POS_Z_CAL_MAG_Z, - FINA_POS_Z_COIL_X_CURRENT, - FINA_POS_Z_COIL_Y_CURRENT, - FINA_POS_Z_COIL_Z_CURRENT, - FINA_POS_Z_COIL_X_TEMPERATURE, - FINA_POS_Z_COIL_Y_TEMPERATURE, - FINA_POS_Z_COIL_Z_TEMPERATURE, + FINA_POS_Z_ERR, + FINA_POS_Z_RAW_MAG_X, + FINA_POS_Z_RAW_MAG_Y, + FINA_POS_Z_RAW_MAG_Z, + FINA_POS_Z_CAL_MAG_X, + FINA_POS_Z_CAL_MAG_Y, + FINA_POS_Z_CAL_MAG_Z, + FINA_POS_Z_COIL_X_CURRENT, + FINA_POS_Z_COIL_Y_CURRENT, + FINA_POS_Z_COIL_Z_CURRENT, + FINA_POS_Z_COIL_X_TEMPERATURE, + FINA_POS_Z_COIL_Y_TEMPERATURE, + FINA_POS_Z_COIL_Z_TEMPERATURE, - FINA_NEG_Z_ERR, - FINA_NEG_Z_RAW_MAG_X, - FINA_NEG_Z_RAW_MAG_Y, - FINA_NEG_Z_RAW_MAG_Z, - FINA_NEG_Z_CAL_MAG_X, - FINA_NEG_Z_CAL_MAG_Y, - FINA_NEG_Z_CAL_MAG_Z, - FINA_NEG_Z_COIL_X_CURRENT, - FINA_NEG_Z_COIL_Y_CURRENT, - FINA_NEG_Z_COIL_Z_CURRENT, - FINA_NEG_Z_COIL_X_TEMPERATURE, - FINA_NEG_Z_COIL_Y_TEMPERATURE, - FINA_NEG_Z_COIL_Z_TEMPERATURE, - }; + FINA_NEG_Z_ERR, + FINA_NEG_Z_RAW_MAG_X, + FINA_NEG_Z_RAW_MAG_Y, + FINA_NEG_Z_RAW_MAG_Z, + FINA_NEG_Z_CAL_MAG_X, + FINA_NEG_Z_CAL_MAG_Y, + FINA_NEG_Z_CAL_MAG_Z, + FINA_NEG_Z_COIL_X_CURRENT, + FINA_NEG_Z_COIL_Y_CURRENT, + FINA_NEG_Z_COIL_Z_CURRENT, + FINA_NEG_Z_COIL_X_TEMPERATURE, + FINA_NEG_Z_COIL_Y_TEMPERATURE, + FINA_NEG_Z_COIL_Z_TEMPERATURE, +}; -class EngHkDataset: public StaticLocalDataSet { -public: +class EngHkDataset : public StaticLocalDataSet { + public: + EngHkDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, ENG_HK_DATA_SET_ID) {} - EngHkDataset(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, ENG_HK_DATA_SET_ID) { - } + EngHkDataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, ENG_HK_DATA_SET_ID)) {} - EngHkDataset(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, ENG_HK_DATA_SET_ID)) { - } - - lp_var_t digitalVoltageMv = lp_var_t(sid.objectId, DIGITAL_VOLTAGE_MV, - this); - lp_var_t analogVoltageMv = lp_var_t(sid.objectId, ANALOG_VOLTAGE_MV, this); - lp_var_t digitalCurrentmA = lp_var_t(sid.objectId, DIGITAL_CURRENT, this); - lp_var_t analogCurrentmA = lp_var_t(sid.objectId, ANALOG_CURRENT, this); - lp_var_t coilXCurrentmA = lp_var_t(sid.objectId, COIL_X_CURRENT, this); - lp_var_t coilYCurrentmA = lp_var_t(sid.objectId, COIL_Y_CURRENT, this); - lp_var_t coilZCurrentmA = lp_var_t(sid.objectId, COIL_Z_CURRENT, this); - /** All temperatures in [°C] */ - lp_var_t coilXTemperature = lp_var_t(sid.objectId, COIL_X_TEMPERATURE, - this); - lp_var_t coilYTemperature = lp_var_t(sid.objectId, COIL_Y_TEMPERATURE, - this); - lp_var_t coilZTemperature = lp_var_t(sid.objectId, COIL_Z_TEMPERATURE, - this); - lp_var_t mcuTemperature = lp_var_t(sid.objectId, MCU_TEMPERATURE, this); + lp_var_t digitalVoltageMv = lp_var_t(sid.objectId, DIGITAL_VOLTAGE_MV, this); + lp_var_t analogVoltageMv = lp_var_t(sid.objectId, ANALOG_VOLTAGE_MV, this); + lp_var_t digitalCurrentmA = lp_var_t(sid.objectId, DIGITAL_CURRENT, this); + lp_var_t analogCurrentmA = lp_var_t(sid.objectId, ANALOG_CURRENT, this); + lp_var_t coilXCurrentmA = lp_var_t(sid.objectId, COIL_X_CURRENT, this); + lp_var_t coilYCurrentmA = lp_var_t(sid.objectId, COIL_Y_CURRENT, this); + lp_var_t coilZCurrentmA = lp_var_t(sid.objectId, COIL_Z_CURRENT, this); + /** All temperatures in [°C] */ + lp_var_t coilXTemperature = lp_var_t(sid.objectId, COIL_X_TEMPERATURE, this); + lp_var_t coilYTemperature = lp_var_t(sid.objectId, COIL_Y_TEMPERATURE, this); + lp_var_t coilZTemperature = lp_var_t(sid.objectId, COIL_Z_TEMPERATURE, this); + lp_var_t mcuTemperature = lp_var_t(sid.objectId, MCU_TEMPERATURE, this); }; /** * @brief This dataset holds the last calibrated MTM measurement. */ -class CalibratedMtmMeasurementSet: public StaticLocalDataSet { -public: +class CalibratedMtmMeasurementSet : public StaticLocalDataSet { + public: + CalibratedMtmMeasurementSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, CAL_MTM_SET) {} - CalibratedMtmMeasurementSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, CAL_MTM_SET) { - } + CalibratedMtmMeasurementSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, CAL_MTM_SET)) {} - CalibratedMtmMeasurementSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, CAL_MTM_SET)) { - } - - /** The unit of all measurements is nT */ - lp_var_t mtmXnT = lp_var_t(sid.objectId, MTM_CAL_X, this); - lp_var_t mtmYnT = lp_var_t(sid.objectId, MTM_CAL_Y, this); - lp_var_t mtmZnT = lp_var_t(sid.objectId, MTM_CAL_Z, this); - /** 1 if coils were actuating during measurement otherwise 0 */ - lp_var_t coilActuationStatus = lp_var_t(sid.objectId, ACTUATION_CAL_STATUS, - this); + /** The unit of all measurements is nT */ + lp_var_t mtmXnT = lp_var_t(sid.objectId, MTM_CAL_X, this); + lp_var_t mtmYnT = lp_var_t(sid.objectId, MTM_CAL_Y, this); + lp_var_t mtmZnT = lp_var_t(sid.objectId, MTM_CAL_Z, this); + /** 1 if coils were actuating during measurement otherwise 0 */ + lp_var_t coilActuationStatus = + lp_var_t(sid.objectId, ACTUATION_CAL_STATUS, this); }; /** * @brief This dataset holds the raw MTM measurements. */ -class RawMtmMeasurementSet: public StaticLocalDataSet { -public: +class RawMtmMeasurementSet : public StaticLocalDataSet { + public: + RawMtmMeasurementSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, RAW_MTM_SET) {} - RawMtmMeasurementSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, RAW_MTM_SET) { - } + RawMtmMeasurementSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, RAW_MTM_SET)) {} - RawMtmMeasurementSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, RAW_MTM_SET)) { - } - - /** The unit of all measurements is nT */ - lp_var_t mtmXnT = lp_var_t(sid.objectId, MTM_RAW_X, this); - lp_var_t mtmYnT = lp_var_t(sid.objectId, MTM_RAW_Y, this); - lp_var_t mtmZnT = lp_var_t(sid.objectId, MTM_RAW_Z, this); - /** 1 if coils were actuating during measurement otherwise 0 */ - lp_var_t coilActuationStatus = lp_var_t(sid.objectId, ACTUATION_RAW_STATUS, - this); + /** The unit of all measurements is nT */ + lp_var_t mtmXnT = lp_var_t(sid.objectId, MTM_RAW_X, this); + lp_var_t mtmYnT = lp_var_t(sid.objectId, MTM_RAW_Y, this); + lp_var_t mtmZnT = lp_var_t(sid.objectId, MTM_RAW_Z, this); + /** 1 if coils were actuating during measurement otherwise 0 */ + lp_var_t coilActuationStatus = + lp_var_t(sid.objectId, ACTUATION_RAW_STATUS, this); }; - /** * @brief This class can be used to ease the generation of an action message commanding the * IMTQHandler to configure the magnettorquer with the desired dipoles. @@ -460,37 +442,32 @@ public: * the ipc store address in the action message. */ class CommandDipolePacket : public SerialLinkedListAdapter { -public: + public: + CommandDipolePacket() { setLinks(); } - CommandDipolePacket() { - setLinks(); - } - -private: - - /** - * @brief Constructor - * - * @param xDipole The dipole of the x coil in 10 ^ -4 * Am^2 - * @param yDipole The dipole of the y coil in 10 ^ -4 * Am^2 - * @param zDipole The dipole of the z coil in 10 ^ -4 * Am^2 - * @param duration The duration in milliseconds the dipole will be generated by the coils. - * When set to 0, the dipole will be generated until a new dipole actuation - * command is sent. - */ - CommandDipolePacket(uint16_t xDipole, uint16_t yDipole, uint16_t zDipole, uint16_t duration) : - xDipole(xDipole), yDipole(yDipole), zDipole(zDipole), duration(duration) { - } - void setLinks() { - setStart(&xDipole); - xDipole.setNext(&yDipole); - yDipole.setNext(&zDipole); - zDipole.setNext(&duration); - } - SerializeElement xDipole; - SerializeElement yDipole; - SerializeElement zDipole; - SerializeElement duration; + private: + /** + * @brief Constructor + * + * @param xDipole The dipole of the x coil in 10 ^ -4 * Am^2 + * @param yDipole The dipole of the y coil in 10 ^ -4 * Am^2 + * @param zDipole The dipole of the z coil in 10 ^ -4 * Am^2 + * @param duration The duration in milliseconds the dipole will be generated by the coils. + * When set to 0, the dipole will be generated until a new dipole actuation + * command is sent. + */ + CommandDipolePacket(uint16_t xDipole, uint16_t yDipole, uint16_t zDipole, uint16_t duration) + : xDipole(xDipole), yDipole(yDipole), zDipole(zDipole), duration(duration) {} + void setLinks() { + setStart(&xDipole); + xDipole.setNext(&yDipole); + yDipole.setNext(&zDipole); + zDipole.setNext(&duration); + } + SerializeElement xDipole; + SerializeElement yDipole; + SerializeElement zDipole; + SerializeElement duration; }; /** @@ -507,79 +484,67 @@ private: * 2. +X actuation * 3. All coils off (FINA step) */ -class PosXSelfTestSet: public StaticLocalDataSet { -public: +class PosXSelfTestSet : public StaticLocalDataSet { + public: + PosXSelfTestSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, IMTQ::POS_X_TEST_DATASET) {} - PosXSelfTestSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, IMTQ::POS_X_TEST_DATASET) { - } + PosXSelfTestSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, IMTQ::POS_X_TEST_DATASET)) {} - PosXSelfTestSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, IMTQ::POS_X_TEST_DATASET)) { - } + /** INIT block */ + lp_var_t initErr = lp_var_t(sid.objectId, INIT_POS_X_ERR, this); + lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_POS_X_RAW_MAG_X, this); + lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_POS_X_RAW_MAG_Y, this); + lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_POS_X_RAW_MAG_Z, this); + lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_POS_X_CAL_MAG_X, this); + lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_POS_X_CAL_MAG_Y, this); + lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_POS_X_CAL_MAG_Z, this); + lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_POS_X_COIL_X_CURRENT, this); + lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_POS_X_COIL_Y_CURRENT, this); + lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_POS_X_COIL_Z_CURRENT, this); + lp_var_t initCoilXTemperature = + lp_var_t(sid.objectId, INIT_POS_X_COIL_X_TEMPERATURE, this); + lp_var_t initCoilYTemperature = + lp_var_t(sid.objectId, INIT_POS_X_COIL_Y_TEMPERATURE, this); + lp_var_t initCoilZTemperature = + lp_var_t(sid.objectId, INIT_POS_X_COIL_Z_TEMPERATURE, this); - /** INIT block */ - lp_var_t initErr = lp_var_t(sid.objectId, INIT_POS_X_ERR, this); - lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_POS_X_RAW_MAG_X, this); - lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_POS_X_RAW_MAG_Y, this); - lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_POS_X_RAW_MAG_Z, this); - lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_POS_X_CAL_MAG_X, this); - lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_POS_X_CAL_MAG_Y, this); - lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_POS_X_CAL_MAG_Z, this); - lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_POS_X_COIL_X_CURRENT, - this); - lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_POS_X_COIL_Y_CURRENT, - this); - lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_POS_X_COIL_Z_CURRENT, - this); - lp_var_t initCoilXTemperature = lp_var_t(sid.objectId, - INIT_POS_X_COIL_X_TEMPERATURE, this); - lp_var_t initCoilYTemperature = lp_var_t(sid.objectId, - INIT_POS_X_COIL_Y_TEMPERATURE, this); - lp_var_t initCoilZTemperature = lp_var_t(sid.objectId, - INIT_POS_X_COIL_Z_TEMPERATURE, this); + /** +X block */ + lp_var_t err = lp_var_t(sid.objectId, POS_X_ERR, this); + lp_var_t rawMagX = lp_var_t(sid.objectId, POS_X_RAW_MAG_X, this); + lp_var_t rawMagY = lp_var_t(sid.objectId, POS_X_RAW_MAG_Y, this); + lp_var_t rawMagZ = lp_var_t(sid.objectId, POS_X_RAW_MAG_Z, this); + lp_var_t calMagX = lp_var_t(sid.objectId, POS_X_CAL_MAG_X, this); + lp_var_t calMagY = lp_var_t(sid.objectId, POS_X_CAL_MAG_Y, this); + lp_var_t calMagZ = lp_var_t(sid.objectId, POS_X_CAL_MAG_Z, this); + lp_var_t coilXCurrent = lp_var_t(sid.objectId, POS_X_COIL_X_CURRENT, this); + lp_var_t coilYCurrent = lp_var_t(sid.objectId, POS_X_COIL_Y_CURRENT, this); + lp_var_t coilZCurrent = lp_var_t(sid.objectId, POS_X_COIL_Z_CURRENT, this); + lp_var_t coilXTemperature = + lp_var_t(sid.objectId, POS_X_COIL_X_TEMPERATURE, this); + lp_var_t coilYTemperature = + lp_var_t(sid.objectId, POS_X_COIL_Y_TEMPERATURE, this); + lp_var_t coilZTemperature = + lp_var_t(sid.objectId, POS_X_COIL_Z_TEMPERATURE, this); - /** +X block */ - lp_var_t err = lp_var_t(sid.objectId, POS_X_ERR, this); - lp_var_t rawMagX = lp_var_t(sid.objectId, POS_X_RAW_MAG_X, this); - lp_var_t rawMagY = lp_var_t(sid.objectId, POS_X_RAW_MAG_Y, this); - lp_var_t rawMagZ = lp_var_t(sid.objectId, POS_X_RAW_MAG_Z, this); - lp_var_t calMagX = lp_var_t(sid.objectId, POS_X_CAL_MAG_X, this); - lp_var_t calMagY = lp_var_t(sid.objectId, POS_X_CAL_MAG_Y, this); - lp_var_t calMagZ = lp_var_t(sid.objectId, POS_X_CAL_MAG_Z, this); - lp_var_t coilXCurrent = lp_var_t(sid.objectId, POS_X_COIL_X_CURRENT, - this); - lp_var_t coilYCurrent = lp_var_t(sid.objectId, POS_X_COIL_Y_CURRENT, - this); - lp_var_t coilZCurrent = lp_var_t(sid.objectId, POS_X_COIL_Z_CURRENT, - this); - lp_var_t coilXTemperature = lp_var_t(sid.objectId, - POS_X_COIL_X_TEMPERATURE, this); - lp_var_t coilYTemperature = lp_var_t(sid.objectId, - POS_X_COIL_Y_TEMPERATURE, this); - lp_var_t coilZTemperature = lp_var_t(sid.objectId, - POS_X_COIL_Z_TEMPERATURE, this); - - /** FINA block */ - lp_var_t finaErr = lp_var_t(sid.objectId, FINA_POS_X_ERR, this); - lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_POS_X_RAW_MAG_X, this); - lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_POS_X_RAW_MAG_Y, this); - lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_POS_X_RAW_MAG_Z, this); - lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_POS_X_CAL_MAG_X, this); - lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_POS_X_CAL_MAG_Y, this); - lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_POS_X_CAL_MAG_Z, this); - lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_POS_X_COIL_X_CURRENT, - this); - lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_POS_X_COIL_Y_CURRENT, - this); - lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_POS_X_COIL_Z_CURRENT, - this); - lp_var_t finaCoilXTemperature = lp_var_t(sid.objectId, - FINA_POS_X_COIL_X_TEMPERATURE, this); - lp_var_t finaCoilYTemperature = lp_var_t(sid.objectId, - FINA_POS_X_COIL_Y_TEMPERATURE, this); - lp_var_t finaCoilZTemperature = lp_var_t(sid.objectId, - FINA_POS_X_COIL_Z_TEMPERATURE, this); + /** FINA block */ + lp_var_t finaErr = lp_var_t(sid.objectId, FINA_POS_X_ERR, this); + lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_POS_X_RAW_MAG_X, this); + lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_POS_X_RAW_MAG_Y, this); + lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_POS_X_RAW_MAG_Z, this); + lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_POS_X_CAL_MAG_X, this); + lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_POS_X_CAL_MAG_Y, this); + lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_POS_X_CAL_MAG_Z, this); + lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_POS_X_COIL_X_CURRENT, this); + lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_POS_X_COIL_Y_CURRENT, this); + lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_POS_X_COIL_Z_CURRENT, this); + lp_var_t finaCoilXTemperature = + lp_var_t(sid.objectId, FINA_POS_X_COIL_X_TEMPERATURE, this); + lp_var_t finaCoilYTemperature = + lp_var_t(sid.objectId, FINA_POS_X_COIL_Y_TEMPERATURE, this); + lp_var_t finaCoilZTemperature = + lp_var_t(sid.objectId, FINA_POS_X_COIL_Z_TEMPERATURE, this); }; /** @@ -596,82 +561,69 @@ public: * 2. -X actuation * 3. All coils off (FINA step) */ -class NegXSelfTestSet: public StaticLocalDataSet { -public: +class NegXSelfTestSet : public StaticLocalDataSet { + public: + NegXSelfTestSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, IMTQ::NEG_X_TEST_DATASET) {} - NegXSelfTestSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, IMTQ::NEG_X_TEST_DATASET) { - } + NegXSelfTestSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, IMTQ::NEG_X_TEST_DATASET)) {} - NegXSelfTestSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, IMTQ::NEG_X_TEST_DATASET)) { - } + /** INIT block */ + lp_var_t initErr = lp_var_t(sid.objectId, INIT_NEG_X_ERR, this); + lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_NEG_X_RAW_MAG_X, this); + lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_NEG_X_RAW_MAG_Y, this); + lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_NEG_X_RAW_MAG_Z, this); + lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_NEG_X_CAL_MAG_X, this); + lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_NEG_X_CAL_MAG_Y, this); + lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_NEG_X_CAL_MAG_Z, this); + lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_NEG_X_COIL_X_CURRENT, this); + lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_NEG_X_COIL_Y_CURRENT, this); + lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_NEG_X_COIL_Z_CURRENT, this); + lp_var_t initCoilXTemperature = + lp_var_t(sid.objectId, INIT_NEG_X_COIL_X_TEMPERATURE, this); + lp_var_t initCoilYTemperature = + lp_var_t(sid.objectId, INIT_NEG_X_COIL_Y_TEMPERATURE, this); + lp_var_t initCoilZTemperature = + lp_var_t(sid.objectId, INIT_NEG_X_COIL_Z_TEMPERATURE, this); - /** INIT block */ - lp_var_t initErr = lp_var_t(sid.objectId, INIT_NEG_X_ERR, this); - lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_NEG_X_RAW_MAG_X, this); - lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_NEG_X_RAW_MAG_Y, this); - lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_NEG_X_RAW_MAG_Z, this); - lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_NEG_X_CAL_MAG_X, this); - lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_NEG_X_CAL_MAG_Y, this); - lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_NEG_X_CAL_MAG_Z, this); - lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_NEG_X_COIL_X_CURRENT, - this); - lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_NEG_X_COIL_Y_CURRENT, - this); - lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_NEG_X_COIL_Z_CURRENT, - this); - lp_var_t initCoilXTemperature = lp_var_t(sid.objectId, - INIT_NEG_X_COIL_X_TEMPERATURE, this); - lp_var_t initCoilYTemperature = lp_var_t(sid.objectId, - INIT_NEG_X_COIL_Y_TEMPERATURE, this); - lp_var_t initCoilZTemperature = lp_var_t(sid.objectId, - INIT_NEG_X_COIL_Z_TEMPERATURE, this); + /** -X block */ + lp_var_t err = lp_var_t(sid.objectId, NEG_X_ERR, this); + lp_var_t rawMagX = lp_var_t(sid.objectId, NEG_X_RAW_MAG_X, this); + lp_var_t rawMagY = lp_var_t(sid.objectId, NEG_X_RAW_MAG_Y, this); + lp_var_t rawMagZ = lp_var_t(sid.objectId, NEG_X_RAW_MAG_Z, this); + lp_var_t calMagX = lp_var_t(sid.objectId, NEG_X_CAL_MAG_X, this); + lp_var_t calMagY = lp_var_t(sid.objectId, NEG_X_CAL_MAG_Y, this); + lp_var_t calMagZ = lp_var_t(sid.objectId, NEG_X_CAL_MAG_Z, this); + lp_var_t coilXCurrent = lp_var_t(sid.objectId, NEG_X_COIL_X_CURRENT, this); + lp_var_t coilYCurrent = lp_var_t(sid.objectId, NEG_X_COIL_Y_CURRENT, this); + lp_var_t coilZCurrent = lp_var_t(sid.objectId, NEG_X_COIL_Z_CURRENT, this); + lp_var_t coilXTemperature = + lp_var_t(sid.objectId, NEG_X_COIL_X_TEMPERATURE, this); + lp_var_t coilYTemperature = + lp_var_t(sid.objectId, NEG_X_COIL_Y_TEMPERATURE, this); + lp_var_t coilZTemperature = + lp_var_t(sid.objectId, NEG_X_COIL_Z_TEMPERATURE, this); - /** -X block */ - lp_var_t err = lp_var_t(sid.objectId, NEG_X_ERR, this); - lp_var_t rawMagX = lp_var_t(sid.objectId, NEG_X_RAW_MAG_X, this); - lp_var_t rawMagY = lp_var_t(sid.objectId, NEG_X_RAW_MAG_Y, this); - lp_var_t rawMagZ = lp_var_t(sid.objectId, NEG_X_RAW_MAG_Z, this); - lp_var_t calMagX = lp_var_t(sid.objectId, NEG_X_CAL_MAG_X, this); - lp_var_t calMagY = lp_var_t(sid.objectId, NEG_X_CAL_MAG_Y, this); - lp_var_t calMagZ = lp_var_t(sid.objectId, NEG_X_CAL_MAG_Z, this); - lp_var_t coilXCurrent = lp_var_t(sid.objectId, NEG_X_COIL_X_CURRENT, - this); - lp_var_t coilYCurrent = lp_var_t(sid.objectId, NEG_X_COIL_Y_CURRENT, - this); - lp_var_t coilZCurrent = lp_var_t(sid.objectId, NEG_X_COIL_Z_CURRENT, - this); - lp_var_t coilXTemperature = lp_var_t(sid.objectId, - NEG_X_COIL_X_TEMPERATURE, this); - lp_var_t coilYTemperature = lp_var_t(sid.objectId, - NEG_X_COIL_Y_TEMPERATURE, this); - lp_var_t coilZTemperature = lp_var_t(sid.objectId, - NEG_X_COIL_Z_TEMPERATURE, this); - - /** FINA block */ - lp_var_t finaErr = lp_var_t(sid.objectId, FINA_NEG_X_ERR, this); - lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_NEG_X_RAW_MAG_X, this); - lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_NEG_X_RAW_MAG_Y, this); - lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_NEG_X_RAW_MAG_Z, this); - lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_NEG_X_CAL_MAG_X, this); - lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_NEG_X_CAL_MAG_Y, this); - lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_NEG_X_CAL_MAG_Z, this); - lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_NEG_X_COIL_X_CURRENT, - this); - lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_NEG_X_COIL_Y_CURRENT, - this); - lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_NEG_X_COIL_Z_CURRENT, - this); - lp_var_t finaCoilXTemperature = lp_var_t(sid.objectId, - FINA_NEG_X_COIL_X_TEMPERATURE, this); - lp_var_t finaCoilYTemperature = lp_var_t(sid.objectId, - FINA_NEG_X_COIL_Y_TEMPERATURE, this); - lp_var_t finaCoilZTemperature = lp_var_t(sid.objectId, - FINA_NEG_X_COIL_Z_TEMPERATURE, this); + /** FINA block */ + lp_var_t finaErr = lp_var_t(sid.objectId, FINA_NEG_X_ERR, this); + lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_NEG_X_RAW_MAG_X, this); + lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_NEG_X_RAW_MAG_Y, this); + lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_NEG_X_RAW_MAG_Z, this); + lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_NEG_X_CAL_MAG_X, this); + lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_NEG_X_CAL_MAG_Y, this); + lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_NEG_X_CAL_MAG_Z, this); + lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_NEG_X_COIL_X_CURRENT, this); + lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_NEG_X_COIL_Y_CURRENT, this); + lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_NEG_X_COIL_Z_CURRENT, this); + lp_var_t finaCoilXTemperature = + lp_var_t(sid.objectId, FINA_NEG_X_COIL_X_TEMPERATURE, this); + lp_var_t finaCoilYTemperature = + lp_var_t(sid.objectId, FINA_NEG_X_COIL_Y_TEMPERATURE, this); + lp_var_t finaCoilZTemperature = + lp_var_t(sid.objectId, FINA_NEG_X_COIL_Z_TEMPERATURE, this); }; - /** * @brief This dataset can be used to store the self test results of the +Y self test. * @@ -686,79 +638,67 @@ public: * 2. +Y actuation * 3. All coils off (FINA step) */ -class PosYSelfTestSet: public StaticLocalDataSet { -public: +class PosYSelfTestSet : public StaticLocalDataSet { + public: + PosYSelfTestSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, IMTQ::POS_Y_TEST_DATASET) {} - PosYSelfTestSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, IMTQ::POS_Y_TEST_DATASET) { - } + PosYSelfTestSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, IMTQ::POS_Y_TEST_DATASET)) {} - PosYSelfTestSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, IMTQ::POS_Y_TEST_DATASET)) { - } + /** INIT block */ + lp_var_t initErr = lp_var_t(sid.objectId, INIT_POS_Y_ERR, this); + lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_POS_Y_RAW_MAG_X, this); + lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_POS_Y_RAW_MAG_Y, this); + lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_POS_Y_RAW_MAG_Z, this); + lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_POS_Y_CAL_MAG_X, this); + lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_POS_Y_CAL_MAG_Y, this); + lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_POS_Y_CAL_MAG_Z, this); + lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_POS_Y_COIL_X_CURRENT, this); + lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_POS_Y_COIL_Y_CURRENT, this); + lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_POS_Y_COIL_Z_CURRENT, this); + lp_var_t initCoilXTemperature = + lp_var_t(sid.objectId, INIT_POS_Y_COIL_X_TEMPERATURE, this); + lp_var_t initCoilYTemperature = + lp_var_t(sid.objectId, INIT_POS_Y_COIL_Y_TEMPERATURE, this); + lp_var_t initCoilZTemperature = + lp_var_t(sid.objectId, INIT_POS_Y_COIL_Z_TEMPERATURE, this); - /** INIT block */ - lp_var_t initErr = lp_var_t(sid.objectId, INIT_POS_Y_ERR, this); - lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_POS_Y_RAW_MAG_X, this); - lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_POS_Y_RAW_MAG_Y, this); - lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_POS_Y_RAW_MAG_Z, this); - lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_POS_Y_CAL_MAG_X, this); - lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_POS_Y_CAL_MAG_Y, this); - lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_POS_Y_CAL_MAG_Z, this); - lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_POS_Y_COIL_X_CURRENT, - this); - lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_POS_Y_COIL_Y_CURRENT, - this); - lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_POS_Y_COIL_Z_CURRENT, - this); - lp_var_t initCoilXTemperature = lp_var_t(sid.objectId, - INIT_POS_Y_COIL_X_TEMPERATURE, this); - lp_var_t initCoilYTemperature = lp_var_t(sid.objectId, - INIT_POS_Y_COIL_Y_TEMPERATURE, this); - lp_var_t initCoilZTemperature = lp_var_t(sid.objectId, - INIT_POS_Y_COIL_Z_TEMPERATURE, this); + /** +Y block */ + lp_var_t err = lp_var_t(sid.objectId, POS_Y_ERR, this); + lp_var_t rawMagX = lp_var_t(sid.objectId, POS_Y_RAW_MAG_X, this); + lp_var_t rawMagY = lp_var_t(sid.objectId, POS_Y_RAW_MAG_Y, this); + lp_var_t rawMagZ = lp_var_t(sid.objectId, POS_Y_RAW_MAG_Z, this); + lp_var_t calMagX = lp_var_t(sid.objectId, POS_Y_CAL_MAG_X, this); + lp_var_t calMagY = lp_var_t(sid.objectId, POS_Y_CAL_MAG_Y, this); + lp_var_t calMagZ = lp_var_t(sid.objectId, POS_Y_CAL_MAG_Z, this); + lp_var_t coilXCurrent = lp_var_t(sid.objectId, POS_Y_COIL_X_CURRENT, this); + lp_var_t coilYCurrent = lp_var_t(sid.objectId, POS_Y_COIL_Y_CURRENT, this); + lp_var_t coilZCurrent = lp_var_t(sid.objectId, POS_Y_COIL_Z_CURRENT, this); + lp_var_t coilXTemperature = + lp_var_t(sid.objectId, POS_Y_COIL_X_TEMPERATURE, this); + lp_var_t coilYTemperature = + lp_var_t(sid.objectId, POS_Y_COIL_Y_TEMPERATURE, this); + lp_var_t coilZTemperature = + lp_var_t(sid.objectId, POS_Y_COIL_Z_TEMPERATURE, this); - /** +Y block */ - lp_var_t err = lp_var_t(sid.objectId, POS_Y_ERR, this); - lp_var_t rawMagX = lp_var_t(sid.objectId, POS_Y_RAW_MAG_X, this); - lp_var_t rawMagY = lp_var_t(sid.objectId, POS_Y_RAW_MAG_Y, this); - lp_var_t rawMagZ = lp_var_t(sid.objectId, POS_Y_RAW_MAG_Z, this); - lp_var_t calMagX = lp_var_t(sid.objectId, POS_Y_CAL_MAG_X, this); - lp_var_t calMagY = lp_var_t(sid.objectId, POS_Y_CAL_MAG_Y, this); - lp_var_t calMagZ = lp_var_t(sid.objectId, POS_Y_CAL_MAG_Z, this); - lp_var_t coilXCurrent = lp_var_t(sid.objectId, POS_Y_COIL_X_CURRENT, - this); - lp_var_t coilYCurrent = lp_var_t(sid.objectId, POS_Y_COIL_Y_CURRENT, - this); - lp_var_t coilZCurrent = lp_var_t(sid.objectId, POS_Y_COIL_Z_CURRENT, - this); - lp_var_t coilXTemperature = lp_var_t(sid.objectId, - POS_Y_COIL_X_TEMPERATURE, this); - lp_var_t coilYTemperature = lp_var_t(sid.objectId, - POS_Y_COIL_Y_TEMPERATURE, this); - lp_var_t coilZTemperature = lp_var_t(sid.objectId, - POS_Y_COIL_Z_TEMPERATURE, this); - - /** FINA block */ - lp_var_t finaErr = lp_var_t(sid.objectId, FINA_POS_Y_ERR, this); - lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_POS_Y_RAW_MAG_X, this); - lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_POS_Y_RAW_MAG_Y, this); - lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_POS_Y_RAW_MAG_Z, this); - lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_POS_Y_CAL_MAG_X, this); - lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_POS_Y_CAL_MAG_Y, this); - lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_POS_Y_CAL_MAG_Z, this); - lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_POS_Y_COIL_X_CURRENT, - this); - lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_POS_Y_COIL_Y_CURRENT, - this); - lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_POS_Y_COIL_Z_CURRENT, - this); - lp_var_t finaCoilXTemperature = lp_var_t(sid.objectId, - FINA_POS_Y_COIL_X_TEMPERATURE, this); - lp_var_t finaCoilYTemperature = lp_var_t(sid.objectId, - FINA_POS_Y_COIL_Y_TEMPERATURE, this); - lp_var_t finaCoilZTemperature = lp_var_t(sid.objectId, - FINA_POS_Y_COIL_Z_TEMPERATURE, this); + /** FINA block */ + lp_var_t finaErr = lp_var_t(sid.objectId, FINA_POS_Y_ERR, this); + lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_POS_Y_RAW_MAG_X, this); + lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_POS_Y_RAW_MAG_Y, this); + lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_POS_Y_RAW_MAG_Z, this); + lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_POS_Y_CAL_MAG_X, this); + lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_POS_Y_CAL_MAG_Y, this); + lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_POS_Y_CAL_MAG_Z, this); + lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_POS_Y_COIL_X_CURRENT, this); + lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_POS_Y_COIL_Y_CURRENT, this); + lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_POS_Y_COIL_Z_CURRENT, this); + lp_var_t finaCoilXTemperature = + lp_var_t(sid.objectId, FINA_POS_Y_COIL_X_TEMPERATURE, this); + lp_var_t finaCoilYTemperature = + lp_var_t(sid.objectId, FINA_POS_Y_COIL_Y_TEMPERATURE, this); + lp_var_t finaCoilZTemperature = + lp_var_t(sid.objectId, FINA_POS_Y_COIL_Z_TEMPERATURE, this); }; /** @@ -775,79 +715,67 @@ public: * 2. -Y actuation * 3. All coils off (FINA step) */ -class NegYSelfTestSet: public StaticLocalDataSet { -public: +class NegYSelfTestSet : public StaticLocalDataSet { + public: + NegYSelfTestSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, IMTQ::NEG_Y_TEST_DATASET) {} - NegYSelfTestSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, IMTQ::NEG_Y_TEST_DATASET) { - } + NegYSelfTestSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, IMTQ::NEG_Y_TEST_DATASET)) {} - NegYSelfTestSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, IMTQ::NEG_Y_TEST_DATASET)) { - } + /** INIT block */ + lp_var_t initErr = lp_var_t(sid.objectId, INIT_NEG_Y_ERR, this); + lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_NEG_Y_RAW_MAG_X, this); + lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_NEG_Y_RAW_MAG_Y, this); + lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_NEG_Y_RAW_MAG_Z, this); + lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_NEG_Y_CAL_MAG_X, this); + lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_NEG_Y_CAL_MAG_Y, this); + lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_NEG_Y_CAL_MAG_Z, this); + lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_NEG_Y_COIL_X_CURRENT, this); + lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_NEG_Y_COIL_Y_CURRENT, this); + lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_NEG_Y_COIL_Z_CURRENT, this); + lp_var_t initCoilXTemperature = + lp_var_t(sid.objectId, INIT_NEG_Y_COIL_X_TEMPERATURE, this); + lp_var_t initCoilYTemperature = + lp_var_t(sid.objectId, INIT_NEG_Y_COIL_Y_TEMPERATURE, this); + lp_var_t initCoilZTemperature = + lp_var_t(sid.objectId, INIT_NEG_Y_COIL_Z_TEMPERATURE, this); - /** INIT block */ - lp_var_t initErr = lp_var_t(sid.objectId, INIT_NEG_Y_ERR, this); - lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_NEG_Y_RAW_MAG_X, this); - lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_NEG_Y_RAW_MAG_Y, this); - lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_NEG_Y_RAW_MAG_Z, this); - lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_NEG_Y_CAL_MAG_X, this); - lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_NEG_Y_CAL_MAG_Y, this); - lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_NEG_Y_CAL_MAG_Z, this); - lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_NEG_Y_COIL_X_CURRENT, - this); - lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_NEG_Y_COIL_Y_CURRENT, - this); - lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_NEG_Y_COIL_Z_CURRENT, - this); - lp_var_t initCoilXTemperature = lp_var_t(sid.objectId, - INIT_NEG_Y_COIL_X_TEMPERATURE, this); - lp_var_t initCoilYTemperature = lp_var_t(sid.objectId, - INIT_NEG_Y_COIL_Y_TEMPERATURE, this); - lp_var_t initCoilZTemperature = lp_var_t(sid.objectId, - INIT_NEG_Y_COIL_Z_TEMPERATURE, this); + /** -Y block */ + lp_var_t err = lp_var_t(sid.objectId, NEG_Y_ERR, this); + lp_var_t rawMagX = lp_var_t(sid.objectId, NEG_Y_RAW_MAG_X, this); + lp_var_t rawMagY = lp_var_t(sid.objectId, NEG_Y_RAW_MAG_Y, this); + lp_var_t rawMagZ = lp_var_t(sid.objectId, NEG_Y_RAW_MAG_Z, this); + lp_var_t calMagX = lp_var_t(sid.objectId, NEG_Y_CAL_MAG_X, this); + lp_var_t calMagY = lp_var_t(sid.objectId, NEG_Y_CAL_MAG_Y, this); + lp_var_t calMagZ = lp_var_t(sid.objectId, NEG_Y_CAL_MAG_Z, this); + lp_var_t coilXCurrent = lp_var_t(sid.objectId, NEG_Y_COIL_X_CURRENT, this); + lp_var_t coilYCurrent = lp_var_t(sid.objectId, NEG_Y_COIL_Y_CURRENT, this); + lp_var_t coilZCurrent = lp_var_t(sid.objectId, NEG_Y_COIL_Z_CURRENT, this); + lp_var_t coilXTemperature = + lp_var_t(sid.objectId, NEG_Y_COIL_X_TEMPERATURE, this); + lp_var_t coilYTemperature = + lp_var_t(sid.objectId, NEG_Y_COIL_Y_TEMPERATURE, this); + lp_var_t coilZTemperature = + lp_var_t(sid.objectId, NEG_Y_COIL_Z_TEMPERATURE, this); - /** -Y block */ - lp_var_t err = lp_var_t(sid.objectId, NEG_Y_ERR, this); - lp_var_t rawMagX = lp_var_t(sid.objectId, NEG_Y_RAW_MAG_X, this); - lp_var_t rawMagY = lp_var_t(sid.objectId, NEG_Y_RAW_MAG_Y, this); - lp_var_t rawMagZ = lp_var_t(sid.objectId, NEG_Y_RAW_MAG_Z, this); - lp_var_t calMagX = lp_var_t(sid.objectId, NEG_Y_CAL_MAG_X, this); - lp_var_t calMagY = lp_var_t(sid.objectId, NEG_Y_CAL_MAG_Y, this); - lp_var_t calMagZ = lp_var_t(sid.objectId, NEG_Y_CAL_MAG_Z, this); - lp_var_t coilXCurrent = lp_var_t(sid.objectId, NEG_Y_COIL_X_CURRENT, - this); - lp_var_t coilYCurrent = lp_var_t(sid.objectId, NEG_Y_COIL_Y_CURRENT, - this); - lp_var_t coilZCurrent = lp_var_t(sid.objectId, NEG_Y_COIL_Z_CURRENT, - this); - lp_var_t coilXTemperature = lp_var_t(sid.objectId, - NEG_Y_COIL_X_TEMPERATURE, this); - lp_var_t coilYTemperature = lp_var_t(sid.objectId, - NEG_Y_COIL_Y_TEMPERATURE, this); - lp_var_t coilZTemperature = lp_var_t(sid.objectId, - NEG_Y_COIL_Z_TEMPERATURE, this); - - /** FINA block */ - lp_var_t finaErr = lp_var_t(sid.objectId, FINA_NEG_Y_ERR, this); - lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_NEG_Y_RAW_MAG_X, this); - lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_NEG_Y_RAW_MAG_Y, this); - lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_NEG_Y_RAW_MAG_Z, this); - lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_NEG_Y_CAL_MAG_X, this); - lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_NEG_Y_CAL_MAG_Y, this); - lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_NEG_Y_CAL_MAG_Z, this); - lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_NEG_Y_COIL_X_CURRENT, - this); - lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_NEG_Y_COIL_Y_CURRENT, - this); - lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_NEG_Y_COIL_Z_CURRENT, - this); - lp_var_t finaCoilXTemperature = lp_var_t(sid.objectId, - FINA_NEG_Y_COIL_X_TEMPERATURE, this); - lp_var_t finaCoilYTemperature = lp_var_t(sid.objectId, - FINA_NEG_Y_COIL_Y_TEMPERATURE, this); - lp_var_t finaCoilZTemperature = lp_var_t(sid.objectId, - FINA_NEG_Y_COIL_Z_TEMPERATURE, this); + /** FINA block */ + lp_var_t finaErr = lp_var_t(sid.objectId, FINA_NEG_Y_ERR, this); + lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_NEG_Y_RAW_MAG_X, this); + lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_NEG_Y_RAW_MAG_Y, this); + lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_NEG_Y_RAW_MAG_Z, this); + lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_NEG_Y_CAL_MAG_X, this); + lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_NEG_Y_CAL_MAG_Y, this); + lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_NEG_Y_CAL_MAG_Z, this); + lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_NEG_Y_COIL_X_CURRENT, this); + lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_NEG_Y_COIL_Y_CURRENT, this); + lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_NEG_Y_COIL_Z_CURRENT, this); + lp_var_t finaCoilXTemperature = + lp_var_t(sid.objectId, FINA_NEG_Y_COIL_X_TEMPERATURE, this); + lp_var_t finaCoilYTemperature = + lp_var_t(sid.objectId, FINA_NEG_Y_COIL_Y_TEMPERATURE, this); + lp_var_t finaCoilZTemperature = + lp_var_t(sid.objectId, FINA_NEG_Y_COIL_Z_TEMPERATURE, this); }; /** @@ -864,79 +792,67 @@ public: * 2. +Z actuation * 3. All coils off (FINA step) */ -class PosZSelfTestSet: public StaticLocalDataSet { -public: +class PosZSelfTestSet : public StaticLocalDataSet { + public: + PosZSelfTestSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, IMTQ::POS_Z_TEST_DATASET) {} - PosZSelfTestSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, IMTQ::POS_Z_TEST_DATASET) { - } + PosZSelfTestSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, IMTQ::POS_Z_TEST_DATASET)) {} - PosZSelfTestSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, IMTQ::POS_Z_TEST_DATASET)) { - } + /** INIT block */ + lp_var_t initErr = lp_var_t(sid.objectId, INIT_POS_Z_ERR, this); + lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_POS_Z_RAW_MAG_X, this); + lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_POS_Z_RAW_MAG_Y, this); + lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_POS_Z_RAW_MAG_Z, this); + lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_POS_Z_CAL_MAG_X, this); + lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_POS_Z_CAL_MAG_Y, this); + lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_POS_Z_CAL_MAG_Z, this); + lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_POS_Z_COIL_X_CURRENT, this); + lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_POS_Z_COIL_Y_CURRENT, this); + lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_POS_Z_COIL_Z_CURRENT, this); + lp_var_t initCoilXTemperature = + lp_var_t(sid.objectId, INIT_POS_Z_COIL_X_TEMPERATURE, this); + lp_var_t initCoilYTemperature = + lp_var_t(sid.objectId, INIT_POS_Z_COIL_Y_TEMPERATURE, this); + lp_var_t initCoilZTemperature = + lp_var_t(sid.objectId, INIT_POS_Z_COIL_Z_TEMPERATURE, this); - /** INIT block */ - lp_var_t initErr = lp_var_t(sid.objectId, INIT_POS_Z_ERR, this); - lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_POS_Z_RAW_MAG_X, this); - lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_POS_Z_RAW_MAG_Y, this); - lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_POS_Z_RAW_MAG_Z, this); - lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_POS_Z_CAL_MAG_X, this); - lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_POS_Z_CAL_MAG_Y, this); - lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_POS_Z_CAL_MAG_Z, this); - lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_POS_Z_COIL_X_CURRENT, - this); - lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_POS_Z_COIL_Y_CURRENT, - this); - lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_POS_Z_COIL_Z_CURRENT, - this); - lp_var_t initCoilXTemperature = lp_var_t(sid.objectId, - INIT_POS_Z_COIL_X_TEMPERATURE, this); - lp_var_t initCoilYTemperature = lp_var_t(sid.objectId, - INIT_POS_Z_COIL_Y_TEMPERATURE, this); - lp_var_t initCoilZTemperature = lp_var_t(sid.objectId, - INIT_POS_Z_COIL_Z_TEMPERATURE, this); + /** +Z block */ + lp_var_t err = lp_var_t(sid.objectId, POS_Z_ERR, this); + lp_var_t rawMagX = lp_var_t(sid.objectId, POS_Z_RAW_MAG_X, this); + lp_var_t rawMagY = lp_var_t(sid.objectId, POS_Z_RAW_MAG_Y, this); + lp_var_t rawMagZ = lp_var_t(sid.objectId, POS_Z_RAW_MAG_Z, this); + lp_var_t calMagX = lp_var_t(sid.objectId, POS_Z_CAL_MAG_X, this); + lp_var_t calMagY = lp_var_t(sid.objectId, POS_Z_CAL_MAG_Y, this); + lp_var_t calMagZ = lp_var_t(sid.objectId, POS_Z_CAL_MAG_Z, this); + lp_var_t coilXCurrent = lp_var_t(sid.objectId, POS_Z_COIL_X_CURRENT, this); + lp_var_t coilYCurrent = lp_var_t(sid.objectId, POS_Z_COIL_Y_CURRENT, this); + lp_var_t coilZCurrent = lp_var_t(sid.objectId, POS_Z_COIL_Z_CURRENT, this); + lp_var_t coilXTemperature = + lp_var_t(sid.objectId, POS_Z_COIL_X_TEMPERATURE, this); + lp_var_t coilYTemperature = + lp_var_t(sid.objectId, POS_Z_COIL_Y_TEMPERATURE, this); + lp_var_t coilZTemperature = + lp_var_t(sid.objectId, POS_Z_COIL_Z_TEMPERATURE, this); - /** +Z block */ - lp_var_t err = lp_var_t(sid.objectId, POS_Z_ERR, this); - lp_var_t rawMagX = lp_var_t(sid.objectId, POS_Z_RAW_MAG_X, this); - lp_var_t rawMagY = lp_var_t(sid.objectId, POS_Z_RAW_MAG_Y, this); - lp_var_t rawMagZ = lp_var_t(sid.objectId, POS_Z_RAW_MAG_Z, this); - lp_var_t calMagX = lp_var_t(sid.objectId, POS_Z_CAL_MAG_X, this); - lp_var_t calMagY = lp_var_t(sid.objectId, POS_Z_CAL_MAG_Y, this); - lp_var_t calMagZ = lp_var_t(sid.objectId, POS_Z_CAL_MAG_Z, this); - lp_var_t coilXCurrent = lp_var_t(sid.objectId, POS_Z_COIL_X_CURRENT, - this); - lp_var_t coilYCurrent = lp_var_t(sid.objectId, POS_Z_COIL_Y_CURRENT, - this); - lp_var_t coilZCurrent = lp_var_t(sid.objectId, POS_Z_COIL_Z_CURRENT, - this); - lp_var_t coilXTemperature = lp_var_t(sid.objectId, - POS_Z_COIL_X_TEMPERATURE, this); - lp_var_t coilYTemperature = lp_var_t(sid.objectId, - POS_Z_COIL_Y_TEMPERATURE, this); - lp_var_t coilZTemperature = lp_var_t(sid.objectId, - POS_Z_COIL_Z_TEMPERATURE, this); - - /** FINA block */ - lp_var_t finaErr = lp_var_t(sid.objectId, FINA_POS_Z_ERR, this); - lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_POS_Z_RAW_MAG_X, this); - lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_POS_Z_RAW_MAG_Y, this); - lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_POS_Z_RAW_MAG_Z, this); - lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_POS_Z_CAL_MAG_X, this); - lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_POS_Z_CAL_MAG_Y, this); - lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_POS_Z_CAL_MAG_Z, this); - lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_POS_Z_COIL_X_CURRENT, - this); - lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_POS_Z_COIL_Y_CURRENT, - this); - lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_POS_Z_COIL_Z_CURRENT, - this); - lp_var_t finaCoilXTemperature = lp_var_t(sid.objectId, - FINA_POS_Z_COIL_X_TEMPERATURE, this); - lp_var_t finaCoilYTemperature = lp_var_t(sid.objectId, - FINA_POS_Z_COIL_Y_TEMPERATURE, this); - lp_var_t finaCoilZTemperature = lp_var_t(sid.objectId, - FINA_POS_Z_COIL_Z_TEMPERATURE, this); + /** FINA block */ + lp_var_t finaErr = lp_var_t(sid.objectId, FINA_POS_Z_ERR, this); + lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_POS_Z_RAW_MAG_X, this); + lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_POS_Z_RAW_MAG_Y, this); + lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_POS_Z_RAW_MAG_Z, this); + lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_POS_Z_CAL_MAG_X, this); + lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_POS_Z_CAL_MAG_Y, this); + lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_POS_Z_CAL_MAG_Z, this); + lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_POS_Z_COIL_X_CURRENT, this); + lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_POS_Z_COIL_Y_CURRENT, this); + lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_POS_Z_COIL_Z_CURRENT, this); + lp_var_t finaCoilXTemperature = + lp_var_t(sid.objectId, FINA_POS_Z_COIL_X_TEMPERATURE, this); + lp_var_t finaCoilYTemperature = + lp_var_t(sid.objectId, FINA_POS_Z_COIL_Y_TEMPERATURE, this); + lp_var_t finaCoilZTemperature = + lp_var_t(sid.objectId, FINA_POS_Z_COIL_Z_TEMPERATURE, this); }; /** @@ -953,82 +869,69 @@ public: * 2. -Z actuation * 3. All coils off (FINA step) */ -class NegZSelfTestSet: public StaticLocalDataSet { -public: +class NegZSelfTestSet : public StaticLocalDataSet { + public: + NegZSelfTestSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, IMTQ::NEG_Z_TEST_DATASET) {} - NegZSelfTestSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, IMTQ::NEG_Z_TEST_DATASET) { - } + NegZSelfTestSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, IMTQ::NEG_Z_TEST_DATASET)) {} - NegZSelfTestSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, IMTQ::NEG_Z_TEST_DATASET)) { - } + /** INIT block */ + lp_var_t initErr = lp_var_t(sid.objectId, INIT_NEG_Z_ERR, this); + lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_NEG_Z_RAW_MAG_X, this); + lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_NEG_Z_RAW_MAG_Y, this); + lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_NEG_Z_RAW_MAG_Z, this); + lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_NEG_Z_CAL_MAG_X, this); + lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_NEG_Z_CAL_MAG_Y, this); + lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_NEG_Z_CAL_MAG_Z, this); + lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_NEG_Z_COIL_X_CURRENT, this); + lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_NEG_Z_COIL_Y_CURRENT, this); + lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_NEG_Z_COIL_Z_CURRENT, this); + lp_var_t initCoilXTemperature = + lp_var_t(sid.objectId, INIT_NEG_Z_COIL_X_TEMPERATURE, this); + lp_var_t initCoilYTemperature = + lp_var_t(sid.objectId, INIT_NEG_Z_COIL_Y_TEMPERATURE, this); + lp_var_t initCoilZTemperature = + lp_var_t(sid.objectId, INIT_NEG_Z_COIL_Z_TEMPERATURE, this); - /** INIT block */ - lp_var_t initErr = lp_var_t(sid.objectId, INIT_NEG_Z_ERR, this); - lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_NEG_Z_RAW_MAG_X, this); - lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_NEG_Z_RAW_MAG_Y, this); - lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_NEG_Z_RAW_MAG_Z, this); - lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_NEG_Z_CAL_MAG_X, this); - lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_NEG_Z_CAL_MAG_Y, this); - lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_NEG_Z_CAL_MAG_Z, this); - lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_NEG_Z_COIL_X_CURRENT, - this); - lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_NEG_Z_COIL_Y_CURRENT, - this); - lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_NEG_Z_COIL_Z_CURRENT, - this); - lp_var_t initCoilXTemperature = lp_var_t(sid.objectId, - INIT_NEG_Z_COIL_X_TEMPERATURE, this); - lp_var_t initCoilYTemperature = lp_var_t(sid.objectId, - INIT_NEG_Z_COIL_Y_TEMPERATURE, this); - lp_var_t initCoilZTemperature = lp_var_t(sid.objectId, - INIT_NEG_Z_COIL_Z_TEMPERATURE, this); + /** +Z block */ + lp_var_t err = lp_var_t(sid.objectId, NEG_Z_ERR, this); + lp_var_t rawMagX = lp_var_t(sid.objectId, NEG_Z_RAW_MAG_X, this); + lp_var_t rawMagY = lp_var_t(sid.objectId, NEG_Z_RAW_MAG_Y, this); + lp_var_t rawMagZ = lp_var_t(sid.objectId, NEG_Z_RAW_MAG_Z, this); + lp_var_t calMagX = lp_var_t(sid.objectId, NEG_Z_CAL_MAG_X, this); + lp_var_t calMagY = lp_var_t(sid.objectId, NEG_Z_CAL_MAG_Y, this); + lp_var_t calMagZ = lp_var_t(sid.objectId, NEG_Z_CAL_MAG_Z, this); + lp_var_t coilXCurrent = lp_var_t(sid.objectId, NEG_Z_COIL_X_CURRENT, this); + lp_var_t coilYCurrent = lp_var_t(sid.objectId, NEG_Z_COIL_Y_CURRENT, this); + lp_var_t coilZCurrent = lp_var_t(sid.objectId, NEG_Z_COIL_Z_CURRENT, this); + lp_var_t coilXTemperature = + lp_var_t(sid.objectId, NEG_Z_COIL_X_TEMPERATURE, this); + lp_var_t coilYTemperature = + lp_var_t(sid.objectId, NEG_Z_COIL_Y_TEMPERATURE, this); + lp_var_t coilZTemperature = + lp_var_t(sid.objectId, NEG_Z_COIL_Z_TEMPERATURE, this); - /** +Z block */ - lp_var_t err = lp_var_t(sid.objectId, NEG_Z_ERR, this); - lp_var_t rawMagX = lp_var_t(sid.objectId, NEG_Z_RAW_MAG_X, this); - lp_var_t rawMagY = lp_var_t(sid.objectId, NEG_Z_RAW_MAG_Y, this); - lp_var_t rawMagZ = lp_var_t(sid.objectId, NEG_Z_RAW_MAG_Z, this); - lp_var_t calMagX = lp_var_t(sid.objectId, NEG_Z_CAL_MAG_X, this); - lp_var_t calMagY = lp_var_t(sid.objectId, NEG_Z_CAL_MAG_Y, this); - lp_var_t calMagZ = lp_var_t(sid.objectId, NEG_Z_CAL_MAG_Z, this); - lp_var_t coilXCurrent = lp_var_t(sid.objectId, NEG_Z_COIL_X_CURRENT, - this); - lp_var_t coilYCurrent = lp_var_t(sid.objectId, NEG_Z_COIL_Y_CURRENT, - this); - lp_var_t coilZCurrent = lp_var_t(sid.objectId, NEG_Z_COIL_Z_CURRENT, - this); - lp_var_t coilXTemperature = lp_var_t(sid.objectId, - NEG_Z_COIL_X_TEMPERATURE, this); - lp_var_t coilYTemperature = lp_var_t(sid.objectId, - NEG_Z_COIL_Y_TEMPERATURE, this); - lp_var_t coilZTemperature = lp_var_t(sid.objectId, - NEG_Z_COIL_Z_TEMPERATURE, this); - - /** FINA block */ - lp_var_t finaErr = lp_var_t(sid.objectId, FINA_NEG_Z_ERR, this); - lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_NEG_Z_RAW_MAG_X, this); - lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_NEG_Z_RAW_MAG_Y, this); - lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_NEG_Z_RAW_MAG_Z, this); - lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_NEG_Z_CAL_MAG_X, this); - lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_NEG_Z_CAL_MAG_Y, this); - lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_NEG_Z_CAL_MAG_Z, this); - lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_NEG_Z_COIL_X_CURRENT, - this); - lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_NEG_Z_COIL_Y_CURRENT, - this); - lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_NEG_Z_COIL_Z_CURRENT, - this); - lp_var_t finaCoilXTemperature = lp_var_t(sid.objectId, - FINA_NEG_Z_COIL_X_TEMPERATURE, this); - lp_var_t finaCoilYTemperature = lp_var_t(sid.objectId, - FINA_NEG_Z_COIL_Y_TEMPERATURE, this); - lp_var_t finaCoilZTemperature = lp_var_t(sid.objectId, - FINA_NEG_Z_COIL_Z_TEMPERATURE, this); + /** FINA block */ + lp_var_t finaErr = lp_var_t(sid.objectId, FINA_NEG_Z_ERR, this); + lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_NEG_Z_RAW_MAG_X, this); + lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_NEG_Z_RAW_MAG_Y, this); + lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_NEG_Z_RAW_MAG_Z, this); + lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_NEG_Z_CAL_MAG_X, this); + lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_NEG_Z_CAL_MAG_Y, this); + lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_NEG_Z_CAL_MAG_Z, this); + lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_NEG_Z_COIL_X_CURRENT, this); + lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_NEG_Z_COIL_Y_CURRENT, this); + lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_NEG_Z_COIL_Z_CURRENT, this); + lp_var_t finaCoilXTemperature = + lp_var_t(sid.objectId, FINA_NEG_Z_COIL_X_TEMPERATURE, this); + lp_var_t finaCoilYTemperature = + lp_var_t(sid.objectId, FINA_NEG_Z_COIL_Y_TEMPERATURE, this); + lp_var_t finaCoilZTemperature = + lp_var_t(sid.objectId, FINA_NEG_Z_COIL_Z_TEMPERATURE, this); }; -} - +} // namespace IMTQ #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_IMTQDEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/Max31865Definitions.h b/mission/devices/devicedefinitions/Max31865Definitions.h index c9c8255e..58faaf97 100644 --- a/mission/devices/devicedefinitions/Max31865Definitions.h +++ b/mission/devices/devicedefinitions/Max31865Definitions.h @@ -1,18 +1,15 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_MAX13865DEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_MAX13865DEFINITIONS_H_ -#include #include +#include #include + #include "objects/systemObjectList.h" namespace Max31865Definitions { -enum PoolIds: lp_id_t { - RTD_VALUE, - TEMPERATURE_C, - FAULT_BYTE -}; +enum PoolIds : lp_id_t { RTD_VALUE, TEMPERATURE_C, FAULT_BYTE }; static constexpr DeviceCommandId_t CONFIG_CMD = 0x80; static constexpr DeviceCommandId_t WRITE_HIGH_THRESHOLD = 0x83; @@ -31,35 +28,26 @@ static constexpr uint8_t CLEAR_FAULT_BIT_VAL = 0b0000'0010; static constexpr size_t MAX_REPLY_SIZE = 5; -class Max31865Set: - public StaticLocalDataSet { -public: - /** - * Constructor used by owner and data creators like device handlers. - * @param owner - * @param setId - */ - Max31865Set(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, MAX31865_SET_ID) { - } +class Max31865Set : public StaticLocalDataSet { + public: + /** + * Constructor used by owner and data creators like device handlers. + * @param owner + * @param setId + */ + Max31865Set(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, MAX31865_SET_ID) {} - /** - * Constructor used by data users like controllers. - * @param sid - */ - Max31865Set(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, MAX31865_SET_ID)) { - } + /** + * Constructor used by data users like controllers. + * @param sid + */ + Max31865Set(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, MAX31865_SET_ID)) {} - lp_var_t rtdValue = lp_var_t(sid.objectId, - PoolIds::RTD_VALUE, this); - lp_var_t temperatureCelcius = lp_var_t(sid.objectId, - PoolIds::TEMPERATURE_C, this); - lp_var_t errorByte = lp_var_t(sid.objectId, - PoolIds::FAULT_BYTE, this); + lp_var_t rtdValue = lp_var_t(sid.objectId, PoolIds::RTD_VALUE, this); + lp_var_t temperatureCelcius = lp_var_t(sid.objectId, PoolIds::TEMPERATURE_C, this); + lp_var_t errorByte = lp_var_t(sid.objectId, PoolIds::FAULT_BYTE, this); }; -} +} // namespace Max31865Definitions #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_MAX13865DEFINITIONS_H_ */ - diff --git a/mission/devices/devicedefinitions/PlocMPSoCDefinitions.h b/mission/devices/devicedefinitions/PlocMPSoCDefinitions.h index 2b9466ab..2c8a081c 100644 --- a/mission/devices/devicedefinitions/PlocMPSoCDefinitions.h +++ b/mission/devices/devicedefinitions/PlocMPSoCDefinitions.h @@ -1,172 +1,166 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ -#include #include #include +#include namespace PLOC_MPSOC { - static const DeviceCommandId_t NONE = 0x0; - static const DeviceCommandId_t TC_MEM_WRITE = 0x1; - static const DeviceCommandId_t TC_MEM_READ = 0x2; - static const DeviceCommandId_t ACK_REPORT = 0x3; - static const DeviceCommandId_t EXE_REPORT = 0x5; - static const DeviceCommandId_t TM_MEMORY_READ_REPORT = 0x6; +static const DeviceCommandId_t NONE = 0x0; +static const DeviceCommandId_t TC_MEM_WRITE = 0x1; +static const DeviceCommandId_t TC_MEM_READ = 0x2; +static const DeviceCommandId_t ACK_REPORT = 0x3; +static const DeviceCommandId_t EXE_REPORT = 0x5; +static const DeviceCommandId_t TM_MEMORY_READ_REPORT = 0x6; - static const uint16_t SIZE_ACK_REPORT = 14; - static const uint16_t SIZE_EXE_REPORT = 14; - static const uint16_t SIZE_TM_MEM_READ_REPORT = 18; +static const uint16_t SIZE_ACK_REPORT = 14; +static const uint16_t SIZE_EXE_REPORT = 14; +static const uint16_t SIZE_TM_MEM_READ_REPORT = 18; - /** - * SpacePacket apids of PLOC telecommands and telemetry. - */ - static const uint16_t APID_TC_MEM_WRITE = 0x714; - static const uint16_t APID_TC_MEM_READ = 0x715; - static const uint16_t APID_TM_MEMORY_READ_REPORT = 0x404; - static const uint16_t APID_ACK_SUCCESS = 0x400; - static const uint16_t APID_ACK_FAILURE = 0x401; - static const uint16_t APID_EXE_SUCCESS = 0x402; - static const uint16_t APID_EXE_FAILURE = 0x403; +/** + * SpacePacket apids of PLOC telecommands and telemetry. + */ +static const uint16_t APID_TC_MEM_WRITE = 0x714; +static const uint16_t APID_TC_MEM_READ = 0x715; +static const uint16_t APID_TM_MEMORY_READ_REPORT = 0x404; +static const uint16_t APID_ACK_SUCCESS = 0x400; +static const uint16_t APID_ACK_FAILURE = 0x401; +static const uint16_t APID_EXE_SUCCESS = 0x402; +static const uint16_t APID_EXE_FAILURE = 0x403; - /** Offset from first byte in Space packet to first byte of data field */ - static const uint8_t DATA_FIELD_OFFSET = 6; +/** Offset from first byte in Space packet to first byte of data field */ +static const uint8_t DATA_FIELD_OFFSET = 6; - /** - * The size of payload data which will be forwarded to the requesting object. e.g. PUS Service - * 8. - */ - static const uint8_t SIZE_MEM_READ_REPORT_DATA = 10; +/** + * The size of payload data which will be forwarded to the requesting object. e.g. PUS Service + * 8. + */ +static const uint8_t SIZE_MEM_READ_REPORT_DATA = 10; - /** - * PLOC space packet length for fixed size packets. This is the size of the whole packet data - * field. For the length field in the space packet this size will be substracted by one. - */ - static const uint16_t LENGTH_TC_MEM_WRITE = 12; - static const uint16_t LENGTH_TC_MEM_READ = 8; +/** + * PLOC space packet length for fixed size packets. This is the size of the whole packet data + * field. For the length field in the space packet this size will be substracted by one. + */ +static const uint16_t LENGTH_TC_MEM_WRITE = 12; +static const uint16_t LENGTH_TC_MEM_READ = 8; - static const size_t MAX_REPLY_SIZE = SIZE_TM_MEM_READ_REPORT; - static const size_t MAX_COMMAND_SIZE = 18; +static const size_t MAX_REPLY_SIZE = SIZE_TM_MEM_READ_REPORT; +static const size_t MAX_COMMAND_SIZE = 18; - /** - * @brief This class helps to build the memory read command for the PLOC. - * - * @details The last two bytes of the packet data field contain a CRC calculated over the whole - * space packet. This is the CRC-16-CCITT as specified in - * ECSS-E-ST-70-41C Telemetry and telecommand packet utilization. - */ - class TcMemRead : public SpacePacket { - public: +/** + * @brief This class helps to build the memory read command for the PLOC. + * + * @details The last two bytes of the packet data field contain a CRC calculated over the whole + * space packet. This is the CRC-16-CCITT as specified in + * ECSS-E-ST-70-41C Telemetry and telecommand packet utilization. + */ +class TcMemRead : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param memAddr The memory address to read from. + */ + TcMemRead(const uint32_t memAddr, uint16_t sequenceCount) + : SpacePacket(LENGTH_TC_MEM_READ - 1, true, APID_TC_MEM_READ, sequenceCount) { + fillPacketDataField(&memAddr); + } - /** - * @brief Constructor - * - * @param memAddr The memory address to read from. - */ - TcMemRead(const uint32_t memAddr, uint16_t sequenceCount) : - SpacePacket(LENGTH_TC_MEM_READ - 1, true, APID_TC_MEM_READ, sequenceCount) { - fillPacketDataField(&memAddr); - } + private: + /** + * @brief This function builds the packet data field for the mem read command. + * + * @param memAddrPtr Pointer to the memory address to read from. + */ + void fillPacketDataField(const uint32_t* memAddrPtr) { + /* Add memAddr to packet data field */ + size_t serializedSize = 0; + uint8_t* memoryAddressPos = this->localData.fields.buffer; + SerializeAdapter::serialize(memAddrPtr, &memoryAddressPos, &serializedSize, + sizeof(*memAddrPtr), SerializeIF::Endianness::LITTLE); - private: + /* Add memLen to packet data field */ + this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD] = 1; + this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD + 1] = 0; - /** - * @brief This function builds the packet data field for the mem read command. - * - * @param memAddrPtr Pointer to the memory address to read from. - */ - void fillPacketDataField(const uint32_t* memAddrPtr) { - /* Add memAddr to packet data field */ - size_t serializedSize = 0; - uint8_t* memoryAddressPos = this->localData.fields.buffer; - SerializeAdapter::serialize(memAddrPtr, &memoryAddressPos, &serializedSize, - sizeof(*memAddrPtr), SerializeIF::Endianness::LITTLE); + /* Calculate crc */ + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + LENGTH_TC_MEM_READ - CRC_SIZE); - /* Add memLen to packet data field */ - this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD] = 1; - this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD + 1] = 0; + /* Add crc to packet data field of space packet */ + serializedSize = 0; + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } - /* Calculate crc */ - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + LENGTH_TC_MEM_READ - CRC_SIZE); + static const uint8_t OFFSET_MEM_LEN_FIELD = 4; + static const uint8_t CRC_OFFSET = 6; +}; - /* Add crc to packet data field of space packet */ - serializedSize = 0; - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, - sizeof(crc), SerializeIF::Endianness::BIG); - } +/** + * @brief This class helps to generate the space packet to write to a memory address within + * the PLOC. + * @details The last two bytes of the packet data field contain a CRC calculated over the whole + * space packet. This is the CRC-16-CCITT as specified in + * ECSS-E-ST-70-41C Telemetry and telecommand packet utilization. + */ +class TcMemWrite : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param memAddr The PLOC memory address where to write to. + * @param memoryData The data to write to the specified memory address. + * @param sequenceCount The subsequence count. Must be incremented with each new packet. + */ + TcMemWrite(const uint32_t memAddr, const uint32_t memoryData, uint16_t sequenceCount) + : SpacePacket(LENGTH_TC_MEM_WRITE - 1, true, APID_TC_MEM_WRITE, sequenceCount) { + fillPacketDataField(&memAddr, &memoryData); + } - static const uint8_t OFFSET_MEM_LEN_FIELD = 4; - static const uint8_t CRC_OFFSET = 6; + private: + /** + * @brief This function builds the packet data field for the mem write command. + * + * @param memAddrPtr Pointer to the PLOC memory address where to write to. + * @param memoryDataPtr Pointer to the memoryData to write + */ + void fillPacketDataField(const uint32_t* memAddrPtr, const uint32_t* memoryDataPtr) { + /* Add memAddr to packet data field */ + size_t serializedSize = 0; + uint8_t* memoryAddressPos = this->localData.fields.buffer; + SerializeAdapter::serialize(memAddrPtr, &memoryAddressPos, &serializedSize, + sizeof(*memAddrPtr), SerializeIF::Endianness::BIG); - }; + /* Add memLen to packet data field */ + this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD] = 1; + this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD + 1] = 0; - /** - * @brief This class helps to generate the space packet to write to a memory address within - * the PLOC. - * @details The last two bytes of the packet data field contain a CRC calculated over the whole - * space packet. This is the CRC-16-CCITT as specified in - * ECSS-E-ST-70-41C Telemetry and telecommand packet utilization. - */ - class TcMemWrite : public SpacePacket { - public: - /** - * @brief Constructor - * - * @param memAddr The PLOC memory address where to write to. - * @param memoryData The data to write to the specified memory address. - * @param sequenceCount The subsequence count. Must be incremented with each new packet. - */ - TcMemWrite(const uint32_t memAddr, const uint32_t memoryData, uint16_t sequenceCount) : - SpacePacket(LENGTH_TC_MEM_WRITE - 1, true, APID_TC_MEM_WRITE, sequenceCount) { - fillPacketDataField(&memAddr, &memoryData); - } + /* Add memData to packet data field */ + serializedSize = 0; + uint8_t* memoryDataPos = this->localData.fields.buffer + OFFSET_MEM_DATA_FIELD; + SerializeAdapter::serialize(memoryDataPtr, &memoryDataPos, &serializedSize, + sizeof(*memoryDataPtr), SerializeIF::Endianness::BIG); - private: + /* Calculate crc */ + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + LENGTH_TC_MEM_WRITE - CRC_SIZE); - /** - * @brief This function builds the packet data field for the mem write command. - * - * @param memAddrPtr Pointer to the PLOC memory address where to write to. - * @param memoryDataPtr Pointer to the memoryData to write - */ - void fillPacketDataField(const uint32_t* memAddrPtr, const uint32_t* memoryDataPtr) { + serializedSize = 0; + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + /* Add crc to packet data field of space packet */ + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } - /* Add memAddr to packet data field */ - size_t serializedSize = 0; - uint8_t* memoryAddressPos = this->localData.fields.buffer; - SerializeAdapter::serialize(memAddrPtr, &memoryAddressPos, &serializedSize, - sizeof(*memAddrPtr), SerializeIF::Endianness::BIG); - - /* Add memLen to packet data field */ - this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD] = 1; - this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD + 1] = 0; - - /* Add memData to packet data field */ - serializedSize = 0; - uint8_t* memoryDataPos = this->localData.fields.buffer + OFFSET_MEM_DATA_FIELD; - SerializeAdapter::serialize(memoryDataPtr, &memoryDataPos, &serializedSize, - sizeof(*memoryDataPtr), SerializeIF::Endianness::BIG); - - /* Calculate crc */ - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + LENGTH_TC_MEM_WRITE - CRC_SIZE); - - serializedSize = 0; - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - /* Add crc to packet data field of space packet */ - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, - sizeof(crc), SerializeIF::Endianness::BIG); - } - - /** Offsets from base address of packet data field */ - static const uint8_t OFFSET_MEM_LEN_FIELD = 4; - static const uint8_t OFFSET_MEM_DATA_FIELD = 6; - static const uint8_t CRC_OFFSET = 10; - }; - -} + /** Offsets from base address of packet data field */ + static const uint8_t OFFSET_MEM_LEN_FIELD = 4; + static const uint8_t OFFSET_MEM_DATA_FIELD = 6; + static const uint8_t CRC_OFFSET = 10; +}; +} // namespace PLOC_MPSOC #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/RadSensorDefinitions.h b/mission/devices/devicedefinitions/RadSensorDefinitions.h index d3c8e876..ab49b61b 100644 --- a/mission/devices/devicedefinitions/RadSensorDefinitions.h +++ b/mission/devices/devicedefinitions/RadSensorDefinitions.h @@ -3,84 +3,79 @@ namespace RAD_SENSOR { - static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending +static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending - /** - * This command initiates the ADC conversion for all channels including the internal - * temperature sensor. - */ - static const DeviceCommandId_t WRITE_SETUP = 0x1; - static const DeviceCommandId_t START_CONVERSION = 0x2; - static const DeviceCommandId_t READ_CONVERSIONS = 0x3; +/** + * This command initiates the ADC conversion for all channels including the internal + * temperature sensor. + */ +static const DeviceCommandId_t WRITE_SETUP = 0x1; +static const DeviceCommandId_t START_CONVERSION = 0x2; +static const DeviceCommandId_t READ_CONVERSIONS = 0x3; - /** - * @brief This is the configuration byte which will be written to the setup register after - * power on. - * - * @note Bit1 (DIFFSEL1) - Bit0 (DIFFSEL0): 0b00, no data follows the setup byte - * Bit3 (REFSEL1) - Bit2 (REFSEL0): 0b10, internal reference, no wake-up delay - * Bit5 (CLKSEL1) - Bit4 (CLKSEL0): 0b10, MAX1227 uses internal oscillator for timing - * Bit7 - Bit6: 0b01, tells MAX1227 that this is the setup register - * - */ - static const uint8_t SETUP_DEFINITION = 0b01101000; +/** + * @brief This is the configuration byte which will be written to the setup register after + * power on. + * + * @note Bit1 (DIFFSEL1) - Bit0 (DIFFSEL0): 0b00, no data follows the setup byte + * Bit3 (REFSEL1) - Bit2 (REFSEL0): 0b10, internal reference, no wake-up delay + * Bit5 (CLKSEL1) - Bit4 (CLKSEL0): 0b10, MAX1227 uses internal oscillator for timing + * Bit7 - Bit6: 0b01, tells MAX1227 that this is the setup register + * + */ +static const uint8_t SETUP_DEFINITION = 0b01101000; - /** - * @brief This value will always be written to the ADC conversion register to specify the - * conversions to perform. - * @details Bit0: 1 - Enables temperature conversion - * Bit2 (SCAN1) and Bit1 (SCAN0): 0b00 (channel conversion from 0 to N) - * Bit6 - Bit3 defines N: 0b0111 (N = 7) - * Bit7: Always 1. Tells the ADC that this is the conversion register. - */ - static const uint8_t CONVERSION_DEFINITION = 0b10111001; +/** + * @brief This value will always be written to the ADC conversion register to specify the + * conversions to perform. + * @details Bit0: 1 - Enables temperature conversion + * Bit2 (SCAN1) and Bit1 (SCAN0): 0b00 (channel conversion from 0 to N) + * Bit6 - Bit3 defines N: 0b0111 (N = 7) + * Bit7: Always 1. Tells the ADC that this is the conversion register. + */ +static const uint8_t CONVERSION_DEFINITION = 0b10111001; // static const uint8_t CONVERSION_DEFINITION = 0b10111111; - /** - * @brief Writing this value resets the fifo of the MAX1227. - */ - static const uint8_t RESET_DEFINITION = 0b00011000; +/** + * @brief Writing this value resets the fifo of the MAX1227. + */ +static const uint8_t RESET_DEFINITION = 0b00011000; - static const uint8_t DUMMY_BYTE = 0xFF; +static const uint8_t DUMMY_BYTE = 0xFF; - static const uint8_t RAD_SENSOR_DATA_SET_ID = READ_CONVERSIONS; +static const uint8_t RAD_SENSOR_DATA_SET_ID = READ_CONVERSIONS; - static const uint8_t DATASET_ENTRIES = 7; - /** - * One temperature value and conversions for AIN0 - AIN7 - */ - static const uint8_t READ_SIZE = 18; +static const uint8_t DATASET_ENTRIES = 7; +/** + * One temperature value and conversions for AIN0 - AIN7 + */ +static const uint8_t READ_SIZE = 18; - enum Max1227PoolIds: lp_id_t { - TEMPERATURE_C, - AIN0, - AIN1, - AIN4, - AIN5, - AIN6, - AIN7, - }; - -class RadSensorDataset: public StaticLocalDataSet { -public: - - RadSensorDataset(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, RAD_SENSOR_DATA_SET_ID) { - } - - RadSensorDataset(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, RAD_SENSOR_DATA_SET_ID)) { - } - - lp_var_t temperatureCelcius = lp_var_t(sid.objectId, TEMPERATURE_C, this); - lp_var_t ain0 = lp_var_t(sid.objectId, AIN0, this); - lp_var_t ain1 = lp_var_t(sid.objectId, AIN1, this); - lp_var_t ain4 = lp_var_t(sid.objectId, AIN4, this); - lp_var_t ain5 = lp_var_t(sid.objectId, AIN5, this); - lp_var_t ain6 = lp_var_t(sid.objectId, AIN6, this); - lp_var_t ain7 = lp_var_t(sid.objectId, AIN7, this); +enum Max1227PoolIds : lp_id_t { + TEMPERATURE_C, + AIN0, + AIN1, + AIN4, + AIN5, + AIN6, + AIN7, }; -} +class RadSensorDataset : public StaticLocalDataSet { + public: + RadSensorDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, RAD_SENSOR_DATA_SET_ID) {} + + RadSensorDataset(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, RAD_SENSOR_DATA_SET_ID)) {} + + lp_var_t temperatureCelcius = lp_var_t(sid.objectId, TEMPERATURE_C, this); + lp_var_t ain0 = lp_var_t(sid.objectId, AIN0, this); + lp_var_t ain1 = lp_var_t(sid.objectId, AIN1, this); + lp_var_t ain4 = lp_var_t(sid.objectId, AIN4, this); + lp_var_t ain5 = lp_var_t(sid.objectId, AIN5, this); + lp_var_t ain6 = lp_var_t(sid.objectId, AIN6, this); + lp_var_t ain7 = lp_var_t(sid.objectId, AIN7, this); +}; +} // namespace RAD_SENSOR #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_RADSENSOR_H_ */ diff --git a/mission/devices/devicedefinitions/RwDefinitions.h b/mission/devices/devicedefinitions/RwDefinitions.h index b8905002..c25e3f09 100644 --- a/mission/devices/devicedefinitions/RwDefinitions.h +++ b/mission/devices/devicedefinitions/RwDefinitions.h @@ -1,66 +1,61 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_RWDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_RWDEFINITIONS_H_ -#include #include +#include #include + #include "objects/systemObjectList.h" namespace RwDefinitions { -static const uint32_t SPI_REPLY_DELAY = 70000; //us +static const uint32_t SPI_REPLY_DELAY = 70000; // us -enum PoolIds: lp_id_t { - TEMPERATURE_C, - CURR_SPEED, - REFERENCE_SPEED, - STATE, - CLC_MODE, - LAST_RESET_STATUS, - CURRRENT_RESET_STATUS, - TM_LAST_RESET_STATUS, - TM_MCU_TEMPERATURE, - PRESSURE_SENSOR_TEMPERATURE, - PRESSURE, - TM_RW_STATE, - TM_CLC_MODE, - TM_RW_CURR_SPEED, - TM_RW_REF_SPEED, - INVALID_CRC_PACKETS, - INVALID_LEN_PACKETS, - INVALID_CMD_PACKETS, - EXECUTED_REPLIES, - COMMAND_REPLIES, - UART_BYTES_WRITTEN, - UART_BYTES_READ, - UART_PARITY_ERRORS, - UART_NOISE_ERRORS, - UART_FRAME_ERRORS, - UART_REG_OVERRUN_ERRORS, - UART_TOTAL_ERRORS, - TOTAL_ERRORS, - SPI_BYTES_WRITTEN, - SPI_BYTES_READ, - SPI_REG_OVERRUN_ERRORS, - SPI_TOTAL_ERRORS +enum PoolIds : lp_id_t { + TEMPERATURE_C, + CURR_SPEED, + REFERENCE_SPEED, + STATE, + CLC_MODE, + LAST_RESET_STATUS, + CURRRENT_RESET_STATUS, + TM_LAST_RESET_STATUS, + TM_MCU_TEMPERATURE, + PRESSURE_SENSOR_TEMPERATURE, + PRESSURE, + TM_RW_STATE, + TM_CLC_MODE, + TM_RW_CURR_SPEED, + TM_RW_REF_SPEED, + INVALID_CRC_PACKETS, + INVALID_LEN_PACKETS, + INVALID_CMD_PACKETS, + EXECUTED_REPLIES, + COMMAND_REPLIES, + UART_BYTES_WRITTEN, + UART_BYTES_READ, + UART_PARITY_ERRORS, + UART_NOISE_ERRORS, + UART_FRAME_ERRORS, + UART_REG_OVERRUN_ERRORS, + UART_TOTAL_ERRORS, + TOTAL_ERRORS, + SPI_BYTES_WRITTEN, + SPI_BYTES_READ, + SPI_REG_OVERRUN_ERRORS, + SPI_TOTAL_ERRORS }; -enum States: uint8_t { - STATE_ERROR, - IDLE, - COASTING, - RUNNING_SPEED_STABLE, - RUNNING_SPEED_CHANGING -}; +enum States : uint8_t { STATE_ERROR, IDLE, COASTING, RUNNING_SPEED_STABLE, RUNNING_SPEED_CHANGING }; -enum LastResetStatus: uint8_t { - CLEARED = 0, - PIN_RESET = 1, - POR_PDR_BOR_RESET = 2, - SOFTWARE_RESET = 4, - INDEPENDENT_WATCHDOG_RESET = 8, - WINDOW_WATCHDOG_RESET = 16, - LOW_POWER_RESET = 32 +enum LastResetStatus : uint8_t { + CLEARED = 0, + PIN_RESET = 1, + POR_PDR_BOR_RESET = 2, + SOFTWARE_RESET = 4, + INDEPENDENT_WATCHDOG_RESET = 8, + WINDOW_WATCHDOG_RESET = 16, + LOW_POWER_RESET = 32 }; static const DeviceCommandId_t RESET_MCU = 1; @@ -103,66 +98,45 @@ static const uint8_t TM_SET_ENTRIES = 24; /** * @brief This dataset can be used to store the temperature of a reaction wheel. */ -class TemperatureSet: - public StaticLocalDataSet { -public: +class TemperatureSet : public StaticLocalDataSet { + public: + TemperatureSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TEMPERATURE_SET_ID) {} - TemperatureSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, TEMPERATURE_SET_ID) { - } + TemperatureSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TEMPERATURE_SET_ID)) {} - TemperatureSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, TEMPERATURE_SET_ID)) { - } - - lp_var_t temperatureCelcius = lp_var_t(sid.objectId, - PoolIds::TEMPERATURE_C, this); + lp_var_t temperatureCelcius = + lp_var_t(sid.objectId, PoolIds::TEMPERATURE_C, this); }; /** * @brief This dataset can be used to store the reaction wheel status. */ -class StatusSet: - public StaticLocalDataSet { -public: +class StatusSet : public StaticLocalDataSet { + public: + StatusSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, STATUS_SET_ID) {} - StatusSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, STATUS_SET_ID) { - } + StatusSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, STATUS_SET_ID)) {} - StatusSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, STATUS_SET_ID)) { - } - - lp_var_t currSpeed = lp_var_t(sid.objectId, - PoolIds::CURR_SPEED, this); - lp_var_t referenceSpeed = lp_var_t(sid.objectId, - PoolIds::REFERENCE_SPEED, this); - lp_var_t state = lp_var_t(sid.objectId, - PoolIds::STATE, this); - lp_var_t clcMode = lp_var_t(sid.objectId, - PoolIds::CLC_MODE, this); + lp_var_t currSpeed = lp_var_t(sid.objectId, PoolIds::CURR_SPEED, this); + lp_var_t referenceSpeed = + lp_var_t(sid.objectId, PoolIds::REFERENCE_SPEED, this); + lp_var_t state = lp_var_t(sid.objectId, PoolIds::STATE, this); + lp_var_t clcMode = lp_var_t(sid.objectId, PoolIds::CLC_MODE, this); }; /** * @brief This dataset stores the last reset status. */ -class LastResetSatus: - public StaticLocalDataSet { -public: +class LastResetSatus : public StaticLocalDataSet { + public: + LastResetSatus(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, LAST_RESET_ID) {} - LastResetSatus(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, LAST_RESET_ID) { - } + LastResetSatus(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, LAST_RESET_ID)) {} - LastResetSatus(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, LAST_RESET_ID)) { - } - - lp_var_t lastResetStatus = lp_var_t(sid.objectId, - PoolIds::LAST_RESET_STATUS, this); - lp_var_t currentResetStatus = lp_var_t(sid.objectId, - PoolIds::CURRRENT_RESET_STATUS, this); + lp_var_t lastResetStatus = + lp_var_t(sid.objectId, PoolIds::LAST_RESET_STATUS, this); + lp_var_t currentResetStatus = + lp_var_t(sid.objectId, PoolIds::CURRRENT_RESET_STATUS, this); }; /** @@ -170,69 +144,57 @@ public: * reaction wheels. https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/ * EIVE_IRS/Arbeitsdaten/08_Used%20Components/Nanoavionics_Reactionwheels&fileid=181622 */ -class TmDataset: - public StaticLocalDataSet { -public: +class TmDataset : public StaticLocalDataSet { + public: + TmDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TM_SET_ID) {} - TmDataset(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, TM_SET_ID) { - } + TmDataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TM_SET_ID)) {} - TmDataset(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, TM_SET_ID)) { - } - - lp_var_t lastResetStatus = lp_var_t(sid.objectId, - PoolIds::TM_LAST_RESET_STATUS, this); - lp_var_t mcuTemperature = lp_var_t(sid.objectId, - PoolIds::TM_MCU_TEMPERATURE, this); - lp_var_t pressureSensorTemperature = lp_var_t(sid.objectId, - PoolIds::PRESSURE_SENSOR_TEMPERATURE, this); - lp_var_t pressure = lp_var_t(sid.objectId, - PoolIds::PRESSURE, this); - lp_var_t rwState = lp_var_t(sid.objectId, - PoolIds::TM_RW_STATE, this); - lp_var_t rwClcMode = lp_var_t(sid.objectId, - PoolIds::TM_CLC_MODE, this); - lp_var_t rwCurrSpeed = lp_var_t(sid.objectId, - PoolIds::TM_RW_CURR_SPEED, this); - lp_var_t rwRefSpeed = lp_var_t(sid.objectId, - PoolIds::TM_RW_REF_SPEED, this); - lp_var_t numOfInvalidCrcPackets = lp_var_t(sid.objectId, - PoolIds::INVALID_CRC_PACKETS, this); - lp_var_t numOfInvalidLenPackets = lp_var_t(sid.objectId, - PoolIds::INVALID_LEN_PACKETS, this); - lp_var_t numOfInvalidCmdPackets = lp_var_t(sid.objectId, - PoolIds::INVALID_CMD_PACKETS, this); - lp_var_t numOfCmdExecutedReplies = lp_var_t(sid.objectId, - PoolIds::EXECUTED_REPLIES, this); - lp_var_t numOfCmdReplies = lp_var_t(sid.objectId, - PoolIds::COMMAND_REPLIES, this); - lp_var_t uartNumOfBytesWritten = lp_var_t(sid.objectId, - PoolIds::UART_BYTES_WRITTEN, this); - lp_var_t uartNumOfBytesRead = lp_var_t(sid.objectId, - PoolIds::UART_BYTES_READ, this); - lp_var_t uartNumOfParityErrors = lp_var_t(sid.objectId, - PoolIds::UART_PARITY_ERRORS, this); - lp_var_t uartNumOfNoiseErrors = lp_var_t(sid.objectId, - PoolIds::UART_NOISE_ERRORS, this); - lp_var_t uartNumOfFrameErrors = lp_var_t(sid.objectId, - PoolIds::UART_FRAME_ERRORS, this); - lp_var_t uartNumOfRegisterOverrunErrors = lp_var_t(sid.objectId, - PoolIds::UART_REG_OVERRUN_ERRORS, this); - lp_var_t uartTotalNumOfErrors = lp_var_t(sid.objectId, - PoolIds::UART_TOTAL_ERRORS, this); - lp_var_t spiNumOfBytesWritten = lp_var_t(sid.objectId, - PoolIds::SPI_BYTES_WRITTEN, this); - lp_var_t spiNumOfBytesRead = lp_var_t(sid.objectId, - PoolIds::SPI_BYTES_READ, this); - lp_var_t spiNumOfRegisterOverrunErrors = lp_var_t(sid.objectId, - PoolIds::SPI_REG_OVERRUN_ERRORS, this); - lp_var_t spiTotalNumOfErrors = lp_var_t(sid.objectId, - PoolIds::SPI_TOTAL_ERRORS, this); + lp_var_t lastResetStatus = + lp_var_t(sid.objectId, PoolIds::TM_LAST_RESET_STATUS, this); + lp_var_t mcuTemperature = + lp_var_t(sid.objectId, PoolIds::TM_MCU_TEMPERATURE, this); + lp_var_t pressureSensorTemperature = + lp_var_t(sid.objectId, PoolIds::PRESSURE_SENSOR_TEMPERATURE, this); + lp_var_t pressure = lp_var_t(sid.objectId, PoolIds::PRESSURE, this); + lp_var_t rwState = lp_var_t(sid.objectId, PoolIds::TM_RW_STATE, this); + lp_var_t rwClcMode = lp_var_t(sid.objectId, PoolIds::TM_CLC_MODE, this); + lp_var_t rwCurrSpeed = lp_var_t(sid.objectId, PoolIds::TM_RW_CURR_SPEED, this); + lp_var_t rwRefSpeed = lp_var_t(sid.objectId, PoolIds::TM_RW_REF_SPEED, this); + lp_var_t numOfInvalidCrcPackets = + lp_var_t(sid.objectId, PoolIds::INVALID_CRC_PACKETS, this); + lp_var_t numOfInvalidLenPackets = + lp_var_t(sid.objectId, PoolIds::INVALID_LEN_PACKETS, this); + lp_var_t numOfInvalidCmdPackets = + lp_var_t(sid.objectId, PoolIds::INVALID_CMD_PACKETS, this); + lp_var_t numOfCmdExecutedReplies = + lp_var_t(sid.objectId, PoolIds::EXECUTED_REPLIES, this); + lp_var_t numOfCmdReplies = + lp_var_t(sid.objectId, PoolIds::COMMAND_REPLIES, this); + lp_var_t uartNumOfBytesWritten = + lp_var_t(sid.objectId, PoolIds::UART_BYTES_WRITTEN, this); + lp_var_t uartNumOfBytesRead = + lp_var_t(sid.objectId, PoolIds::UART_BYTES_READ, this); + lp_var_t uartNumOfParityErrors = + lp_var_t(sid.objectId, PoolIds::UART_PARITY_ERRORS, this); + lp_var_t uartNumOfNoiseErrors = + lp_var_t(sid.objectId, PoolIds::UART_NOISE_ERRORS, this); + lp_var_t uartNumOfFrameErrors = + lp_var_t(sid.objectId, PoolIds::UART_FRAME_ERRORS, this); + lp_var_t uartNumOfRegisterOverrunErrors = + lp_var_t(sid.objectId, PoolIds::UART_REG_OVERRUN_ERRORS, this); + lp_var_t uartTotalNumOfErrors = + lp_var_t(sid.objectId, PoolIds::UART_TOTAL_ERRORS, this); + lp_var_t spiNumOfBytesWritten = + lp_var_t(sid.objectId, PoolIds::SPI_BYTES_WRITTEN, this); + lp_var_t spiNumOfBytesRead = + lp_var_t(sid.objectId, PoolIds::SPI_BYTES_READ, this); + lp_var_t spiNumOfRegisterOverrunErrors = + lp_var_t(sid.objectId, PoolIds::SPI_REG_OVERRUN_ERRORS, this); + lp_var_t spiTotalNumOfErrors = + lp_var_t(sid.objectId, PoolIds::SPI_TOTAL_ERRORS, this); }; -} +} // namespace RwDefinitions #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_RWDEFINITIONS_H_ */ - diff --git a/mission/devices/devicedefinitions/SyrlinksDefinitions.h b/mission/devices/devicedefinitions/SyrlinksDefinitions.h index 43ce16f2..3b56918a 100644 --- a/mission/devices/devicedefinitions/SyrlinksDefinitions.h +++ b/mission/devices/devicedefinitions/SyrlinksDefinitions.h @@ -1,101 +1,88 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_SYRLINKSDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_SYRLINKSDEFINITIONS_H_ - namespace SYRLINKS { - static const DeviceCommandId_t NONE = 0x0; - static const DeviceCommandId_t RESET_UNIT = 0x01; - /** Reads out all status registers */ - static const DeviceCommandId_t READ_RX_STATUS_REGISTERS = 0x02; - /** Sets Tx mode to standby */ - static const DeviceCommandId_t SET_TX_MODE_STANDBY = 0x03; - /** Starts transmission mode. Only reached when clock signal is applying to the data tx input */ - static const DeviceCommandId_t SET_TX_MODE_MODULATION = 0x04; - /** Sends out a single carrier wave for testing purpose */ - static const DeviceCommandId_t SET_TX_MODE_CW = 0x05; - static const DeviceCommandId_t ACK_REPLY = 0x06; - static const DeviceCommandId_t READ_TX_STATUS = 0x07; - static const DeviceCommandId_t READ_TX_WAVEFORM = 0x08; - static const DeviceCommandId_t READ_TX_AGC_VALUE_HIGH_BYTE = 0x09; - static const DeviceCommandId_t READ_TX_AGC_VALUE_LOW_BYTE = 0x0A; +static const DeviceCommandId_t NONE = 0x0; +static const DeviceCommandId_t RESET_UNIT = 0x01; +/** Reads out all status registers */ +static const DeviceCommandId_t READ_RX_STATUS_REGISTERS = 0x02; +/** Sets Tx mode to standby */ +static const DeviceCommandId_t SET_TX_MODE_STANDBY = 0x03; +/** Starts transmission mode. Only reached when clock signal is applying to the data tx input */ +static const DeviceCommandId_t SET_TX_MODE_MODULATION = 0x04; +/** Sends out a single carrier wave for testing purpose */ +static const DeviceCommandId_t SET_TX_MODE_CW = 0x05; +static const DeviceCommandId_t ACK_REPLY = 0x06; +static const DeviceCommandId_t READ_TX_STATUS = 0x07; +static const DeviceCommandId_t READ_TX_WAVEFORM = 0x08; +static const DeviceCommandId_t READ_TX_AGC_VALUE_HIGH_BYTE = 0x09; +static const DeviceCommandId_t READ_TX_AGC_VALUE_LOW_BYTE = 0x0A; - /** Size of a simple transmission success response */ - static const uint8_t ACK_SIZE = 12; - static const uint8_t SIZE_CRC_AND_TERMINATION = 5; - /** The size of the header with the message identifier and the payload size field */ - static const uint8_t MESSAGE_HEADER_SIZE = 5; - /** Size of reply to an rx status registers request */ - static const uint8_t RX_STATUS_REGISTERS_REPLY_SIZE = 49; - static const uint8_t READ_ONE_REGISTER_REPLY_SIE = 13; +/** Size of a simple transmission success response */ +static const uint8_t ACK_SIZE = 12; +static const uint8_t SIZE_CRC_AND_TERMINATION = 5; +/** The size of the header with the message identifier and the payload size field */ +static const uint8_t MESSAGE_HEADER_SIZE = 5; +/** Size of reply to an rx status registers request */ +static const uint8_t RX_STATUS_REGISTERS_REPLY_SIZE = 49; +static const uint8_t READ_ONE_REGISTER_REPLY_SIE = 13; - static const uint8_t RX_DATASET_ID = 0x1; - static const uint8_t TX_DATASET_ID = 0x2; +static const uint8_t RX_DATASET_ID = 0x1; +static const uint8_t TX_DATASET_ID = 0x2; - static const size_t MAX_REPLY_SIZE = RX_STATUS_REGISTERS_REPLY_SIZE; - static const size_t MAX_COMMAND_SIZE = 15; +static const size_t MAX_REPLY_SIZE = RX_STATUS_REGISTERS_REPLY_SIZE; +static const size_t MAX_COMMAND_SIZE = 15; - static const size_t CRC_FIELD_SIZE = 4; +static const size_t CRC_FIELD_SIZE = 4; - static const uint8_t RX_DATASET_SIZE = 8; - static const uint8_t TX_DATASET_SIZE = 3; +static const uint8_t RX_DATASET_SIZE = 8; +static const uint8_t TX_DATASET_SIZE = 3; - enum SyrlinksPoolIds: lp_id_t { - RX_STATUS, - RX_SENSITIVITY, - RX_FREQUENCY_SHIFT, - RX_IQ_POWER, - RX_AGC_VALUE, - RX_DEMOD_EB, - RX_DEMOD_N0, - RX_DATA_RATE, - TX_STATUS, - TX_CONV_DIFF, - TX_CONV_FILTER, - TX_WAVEFORM, - TX_PCM_INDEX, - TX_AGC_VALUE, - }; - -class RxDataset: public StaticLocalDataSet { -public: - - RxDataset(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, RX_DATASET_ID) { - } - - RxDataset(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, RX_DATASET_ID)) { - } - - lp_var_t rxStatus = lp_var_t(sid.objectId, RX_STATUS, this); - lp_var_t rxSensitivity = lp_var_t(sid.objectId, RX_SENSITIVITY, this); - lp_var_t rxFrequencyShift = lp_var_t(sid.objectId, RX_FREQUENCY_SHIFT, this); - lp_var_t rxIqPower = lp_var_t(sid.objectId, RX_IQ_POWER, this); - lp_var_t rxAgcValue = lp_var_t(sid.objectId, RX_AGC_VALUE, this); - lp_var_t rxDemodEb = lp_var_t(sid.objectId, RX_DEMOD_EB, this); - lp_var_t rxDemodN0 = lp_var_t(sid.objectId, RX_DEMOD_N0, this); - lp_var_t rxDataRate = lp_var_t(sid.objectId, RX_DATA_RATE, this); +enum SyrlinksPoolIds : lp_id_t { + RX_STATUS, + RX_SENSITIVITY, + RX_FREQUENCY_SHIFT, + RX_IQ_POWER, + RX_AGC_VALUE, + RX_DEMOD_EB, + RX_DEMOD_N0, + RX_DATA_RATE, + TX_STATUS, + TX_CONV_DIFF, + TX_CONV_FILTER, + TX_WAVEFORM, + TX_PCM_INDEX, + TX_AGC_VALUE, }; +class RxDataset : public StaticLocalDataSet { + public: + RxDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, RX_DATASET_ID) {} -class TxDataset: public StaticLocalDataSet { -public: + RxDataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, RX_DATASET_ID)) {} - TxDataset(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, TX_DATASET_ID) { - } - - TxDataset(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, TX_DATASET_ID)) { - } - - lp_var_t txStatus = lp_var_t(sid.objectId, TX_STATUS, this); - lp_var_t txWaveform = lp_var_t(sid.objectId, TX_WAVEFORM, this); - lp_var_t txAgcValue = lp_var_t(sid.objectId, TX_AGC_VALUE, this); + lp_var_t rxStatus = lp_var_t(sid.objectId, RX_STATUS, this); + lp_var_t rxSensitivity = lp_var_t(sid.objectId, RX_SENSITIVITY, this); + lp_var_t rxFrequencyShift = lp_var_t(sid.objectId, RX_FREQUENCY_SHIFT, this); + lp_var_t rxIqPower = lp_var_t(sid.objectId, RX_IQ_POWER, this); + lp_var_t rxAgcValue = lp_var_t(sid.objectId, RX_AGC_VALUE, this); + lp_var_t rxDemodEb = lp_var_t(sid.objectId, RX_DEMOD_EB, this); + lp_var_t rxDemodN0 = lp_var_t(sid.objectId, RX_DEMOD_N0, this); + lp_var_t rxDataRate = lp_var_t(sid.objectId, RX_DATA_RATE, this); }; -} +class TxDataset : public StaticLocalDataSet { + public: + TxDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TX_DATASET_ID) {} + TxDataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TX_DATASET_ID)) {} + + lp_var_t txStatus = lp_var_t(sid.objectId, TX_STATUS, this); + lp_var_t txWaveform = lp_var_t(sid.objectId, TX_WAVEFORM, this); + lp_var_t txAgcValue = lp_var_t(sid.objectId, TX_AGC_VALUE, this); +}; + +} // namespace SYRLINKS #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_SYRLINKSDEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/Tmp1075Definitions.h b/mission/devices/devicedefinitions/Tmp1075Definitions.h index 603260ac..3f48508c 100644 --- a/mission/devices/devicedefinitions/Tmp1075Definitions.h +++ b/mission/devices/devicedefinitions/Tmp1075Definitions.h @@ -2,46 +2,35 @@ #define MISSION_DEVICES_DEVICEDEFINITIONS_TMP1075DEFINITIONS_H_ namespace TMP1075 { - static const uint8_t TEMP_REG_ADDR = 0x0; - static const uint8_t CFGR_ADDR = 0x1; +static const uint8_t TEMP_REG_ADDR = 0x0; +static const uint8_t CFGR_ADDR = 0x1; - /* Writing this information to the configuration register sets the tmp1075 - * to shutdown mode and starts a single temperature conversion */ - static const uint16_t ONE_SHOT_MODE = 0x8100; +/* Writing this information to the configuration register sets the tmp1075 + * to shutdown mode and starts a single temperature conversion */ +static const uint16_t ONE_SHOT_MODE = 0x8100; - static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending - static const DeviceCommandId_t GET_TEMP = 0x1; - static const DeviceCommandId_t START_ADC_CONVERSION = 0x2; +static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending +static const DeviceCommandId_t GET_TEMP = 0x1; +static const DeviceCommandId_t START_ADC_CONVERSION = 0x2; - static const uint8_t GET_TEMP_REPLY_SIZE = 2; - static const uint8_t CFGR_CMD_SIZE = 3; - static const uint8_t POINTER_REG_SIZE = 1; +static const uint8_t GET_TEMP_REPLY_SIZE = 2; +static const uint8_t CFGR_CMD_SIZE = 3; +static const uint8_t POINTER_REG_SIZE = 1; - static const uint32_t TMP1075_DATA_SET_ID = GET_TEMP; +static const uint32_t TMP1075_DATA_SET_ID = GET_TEMP; - static const uint8_t MAX_REPLY_LENGTH = GET_TEMP_REPLY_SIZE; +static const uint8_t MAX_REPLY_LENGTH = GET_TEMP_REPLY_SIZE; - enum Tmp1075PoolIds: lp_id_t { - TEMPERATURE_C_TMP1075_1, - TEMPERATURE_C_TMP1075_2 - }; +enum Tmp1075PoolIds : lp_id_t { TEMPERATURE_C_TMP1075_1, TEMPERATURE_C_TMP1075_2 }; -class Tmp1075Dataset: - public StaticLocalDataSet { -public: +class Tmp1075Dataset : public StaticLocalDataSet { + public: + Tmp1075Dataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TMP1075_DATA_SET_ID) {} - Tmp1075Dataset(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, TMP1075_DATA_SET_ID) { - } + Tmp1075Dataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TMP1075_DATA_SET_ID)) {} - Tmp1075Dataset(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, TMP1075_DATA_SET_ID)) { - } - - lp_var_t temperatureCelcius = lp_var_t(sid.objectId, - TEMPERATURE_C_TMP1075_1, this); + lp_var_t temperatureCelcius = lp_var_t(sid.objectId, TEMPERATURE_C_TMP1075_1, this); }; -} - +} // namespace TMP1075 #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_TMP1075DEFINITIONS_H_ */ diff --git a/mission/memory/NVMParameterBase.cpp b/mission/memory/NVMParameterBase.cpp index e7b8e8a6..0802a392 100644 --- a/mission/memory/NVMParameterBase.cpp +++ b/mission/memory/NVMParameterBase.cpp @@ -1,50 +1,44 @@ #include "NVMParameterBase.h" -#include "fsfw/memory/HasFileSystemIF.h" -#include "fsfw/serviceinterface/ServiceInterface.h" #include -NVMParameterBase::NVMParameterBase(std::string fullName): fullName(fullName) { -} +#include "fsfw/memory/HasFileSystemIF.h" +#include "fsfw/serviceinterface/ServiceInterface.h" + +NVMParameterBase::NVMParameterBase(std::string fullName) : fullName(fullName) {} ReturnValue_t NVMParameterBase::readJsonFile() { - if(std::filesystem::exists(fullName)) { - // Read JSON file content into object - std::ifstream i(fullName); - i >> json; - return HasReturnvaluesIF::RETURN_OK; - } - return HasFileSystemIF::FILE_DOES_NOT_EXIST; + if (std::filesystem::exists(fullName)) { + // Read JSON file content into object + std::ifstream i(fullName); + i >> json; + return HasReturnvaluesIF::RETURN_OK; + } + return HasFileSystemIF::FILE_DOES_NOT_EXIST; } ReturnValue_t NVMParameterBase::writeJsonFile() { - std::ofstream o(fullName); - o << std::setw(4) << json; - return HasReturnvaluesIF::RETURN_OK; + std::ofstream o(fullName); + o << std::setw(4) << json; + return HasReturnvaluesIF::RETURN_OK; } -void NVMParameterBase::setFullName(std::string fullName) { - this->fullName = fullName; -} +void NVMParameterBase::setFullName(std::string fullName) { this->fullName = fullName; } -std::string NVMParameterBase::getFullName() const { - return fullName; -} +std::string NVMParameterBase::getFullName() const { return fullName; } -bool NVMParameterBase::getJsonFileExists() { - return std::filesystem::exists(fullName); -} +bool NVMParameterBase::getJsonFileExists() { return std::filesystem::exists(fullName); } void NVMParameterBase::printKeys() const { - sif::info << "Printing keys for JSON file " << fullName << std::endl; - for(const auto& key: keys) { - sif::info << key << std::endl; - } + sif::info << "Printing keys for JSON file " << fullName << std::endl; + for (const auto& key : keys) { + sif::info << key << std::endl; + } } void NVMParameterBase::print() const { - sif::info << "Printing JSON file " << fullName << std::endl; - for(const auto& key: keys) { - sif::info << key << ": " << json[key] << std::endl; - } + sif::info << "Printing JSON file " << fullName << std::endl; + for (const auto& key : keys) { + sif::info << key << ": " << json[key] << std::endl; + } } diff --git a/mission/memory/NVMParameterBase.h b/mission/memory/NVMParameterBase.h index f41f9e63..aafbf8cc 100644 --- a/mission/memory/NVMParameterBase.h +++ b/mission/memory/NVMParameterBase.h @@ -1,79 +1,78 @@ #ifndef BSP_Q7S_CORE_NVMPARAMS_NVMPARAMIF_H_ #define BSP_Q7S_CORE_NVMPARAMS_NVMPARAMIF_H_ -#include "fsfw/returnvalues/HasReturnvaluesIF.h" - +#include #include #include -#include + +#include "fsfw/returnvalues/HasReturnvaluesIF.h" class NVMParameterBase : public HasReturnvaluesIF { -public: - virtual~ NVMParameterBase() {} + public: + virtual ~NVMParameterBase() {} - NVMParameterBase(std::string fullName); + NVMParameterBase(std::string fullName); - bool getJsonFileExists(); + bool getJsonFileExists(); - /** - * Returns RETURN_OK on successfull read and HasFileSystemIF::FILE_DOES_NOT_EXIST if - * file does not exist yet. - * @return - */ - virtual ReturnValue_t readJsonFile(); + /** + * Returns RETURN_OK on successfull read and HasFileSystemIF::FILE_DOES_NOT_EXIST if + * file does not exist yet. + * @return + */ + virtual ReturnValue_t readJsonFile(); - virtual ReturnValue_t writeJsonFile(); + virtual ReturnValue_t writeJsonFile(); - void setFullName(std::string fullName); - std::string getFullName() const; + void setFullName(std::string fullName); + std::string getFullName() const; - template - ReturnValue_t insertValue(std::string key, T value); + template + ReturnValue_t insertValue(std::string key, T value); - template - ReturnValue_t setValue(std::string key, T value); + template + ReturnValue_t setValue(std::string key, T value); - template - ReturnValue_t getValue(std::string key, T* value) const; + template + ReturnValue_t getValue(std::string key, T* value) const; - void printKeys() const; - void print() const; + void printKeys() const; + void print() const; -private: + private: + static const uint8_t INTERFACE_ID = CLASS_ID::NVM_PARAM_BASE; - static const uint8_t INTERFACE_ID = CLASS_ID::NVM_PARAM_BASE; + //! [EXPORT] : [COMMENT] Specified key does not exist in json file + static const ReturnValue_t KEY_NOT_EXISTS = MAKE_RETURN_CODE(0xA0); - //! [EXPORT] : [COMMENT] Specified key does not exist in json file - static const ReturnValue_t KEY_NOT_EXISTS = MAKE_RETURN_CODE(0xA0); - - nlohmann::json json; - std::vector keys; - std::string fullName; + nlohmann::json json; + std::vector keys; + std::string fullName; }; -template +template inline ReturnValue_t NVMParameterBase::insertValue(std::string key, T value) { - // Check whether key already exists. If it does not, insert it - if (std::find(keys.begin(), keys.end(), key) == keys.end()) { - keys.push_back(key); - } - json[key] = value; - return HasReturnvaluesIF::RETURN_OK; + // Check whether key already exists. If it does not, insert it + if (std::find(keys.begin(), keys.end(), key) == keys.end()) { + keys.push_back(key); + } + json[key] = value; + return HasReturnvaluesIF::RETURN_OK; } -template +template inline ReturnValue_t NVMParameterBase::setValue(std::string key, T value) { - json[key] = value; - return HasReturnvaluesIF::RETURN_OK; + json[key] = value; + return HasReturnvaluesIF::RETURN_OK; } -template +template inline ReturnValue_t NVMParameterBase::getValue(std::string key, T* value) const { - if (!json.contains(key)) { - return KEY_NOT_EXISTS; - } - *value = json[key]; - return RETURN_OK; + if (!json.contains(key)) { + return KEY_NOT_EXISTS; + } + *value = json[key]; + return RETURN_OK; } #endif /* BSP_Q7S_CORE_NVMPARAMS_NVMPARAMIF_H_ */ diff --git a/mission/tmtc/CCSDSHandler.cpp b/mission/tmtc/CCSDSHandler.cpp index 524fe4b8..ba34d273 100644 --- a/mission/tmtc/CCSDSHandler.cpp +++ b/mission/tmtc/CCSDSHandler.cpp @@ -1,303 +1,301 @@ -#include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/serviceinterface/serviceInterfaceDefintions.h" -#include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/ipc/QueueFactory.h" -#include "fsfw/events/EventManagerIF.h" +#include "CCSDSHandler.h" #include -#include "CCSDSHandler.h" +#include "fsfw/events/EventManagerIF.h" +#include "fsfw/ipc/QueueFactory.h" +#include "fsfw/objectmanager/ObjectManager.h" +#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface/serviceInterfaceDefintions.h" CCSDSHandler::CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination, - TxRateSetterIF* txRateSetterIF, GpioIF* gpioIF, gpioId_t enTxClock, gpioId_t enTxData) : - SystemObject(objectId), ptmeId(ptmeId), tcDestination(tcDestination), parameterHelper(this), actionHelper( - this, nullptr), txRateSetterIF(txRateSetterIF), gpioIF(gpioIF), enTxClock( - enTxClock), enTxData(enTxData) { - commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); - eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 2); + TxRateSetterIF* txRateSetterIF, GpioIF* gpioIF, gpioId_t enTxClock, + gpioId_t enTxData) + : SystemObject(objectId), + ptmeId(ptmeId), + tcDestination(tcDestination), + parameterHelper(this), + actionHelper(this, nullptr), + txRateSetterIF(txRateSetterIF), + gpioIF(gpioIF), + enTxClock(enTxClock), + enTxData(enTxData) { + commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); + eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 2); } -CCSDSHandler::~CCSDSHandler() { -} +CCSDSHandler::~CCSDSHandler() {} ReturnValue_t CCSDSHandler::performOperation(uint8_t operationCode) { - checkEvents(); - readCommandQueue(); - handleTelemetry(); - handleTelecommands(); - checkTxTimer(); - return RETURN_OK; + checkEvents(); + readCommandQueue(); + handleTelemetry(); + handleTelecommands(); + checkTxTimer(); + return RETURN_OK; } void CCSDSHandler::handleTelemetry() { - VirtualChannelMapIter iter; - for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { - iter->second->performOperation(); - } + VirtualChannelMapIter iter; + for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { + iter->second->performOperation(); + } } -void CCSDSHandler::handleTelecommands() { - -} +void CCSDSHandler::handleTelecommands() {} ReturnValue_t CCSDSHandler::initialize() { - ReturnValue_t result = RETURN_OK; - PtmeIF* ptme = ObjectManager::instance()->get(ptmeId); - if (ptme == nullptr) { - sif::warning << "Invalid PTME object" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + ReturnValue_t result = RETURN_OK; + PtmeIF* ptme = ObjectManager::instance()->get(ptmeId); + if (ptme == nullptr) { + sif::warning << "Invalid PTME object" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - AcceptsTelecommandsIF* tcDistributor = - ObjectManager::instance()->get(tcDestination); - if (tcDistributor == nullptr) { + AcceptsTelecommandsIF* tcDistributor = + ObjectManager::instance()->get(tcDestination); + if (tcDistributor == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "CCSDSHandler::initialize: Invalid TC Distributor object" << std::endl; + sif::error << "CCSDSHandler::initialize: Invalid TC Distributor object" << std::endl; #endif - return ObjectManagerIF::CHILD_INIT_FAILED; - } + return ObjectManagerIF::CHILD_INIT_FAILED; + } - tcDistributorQueueId = tcDistributor->getRequestQueue(); + tcDistributorQueueId = tcDistributor->getRequestQueue(); - result = parameterHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + result = parameterHelper.initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } - result = actionHelper.initialize(commandQueue); + result = actionHelper.initialize(commandQueue); + if (result != RETURN_OK) { + return result; + } + + VirtualChannelMapIter iter; + for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { + result = iter->second->initialize(); if (result != RETURN_OK) { - return result; + return result; } + iter->second->setPtmeObject(ptme); + } - VirtualChannelMapIter iter; - for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { - result = iter->second->initialize(); - if (result != RETURN_OK) { - return result; - } - iter->second->setPtmeObject(ptme); - } - - EventManagerIF* manager = ObjectManager::instance()->get( - objects::EVENT_MANAGER); - if (manager == nullptr) { + EventManagerIF* manager = ObjectManager::instance()->get(objects::EVENT_MANAGER); + if (manager == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "CCSDSHandler::initialize: Invalid event manager" << std::endl; + sif::error << "CCSDSHandler::initialize: Invalid event manager" << std::endl; #endif - return ObjectManagerIF::CHILD_INIT_FAILED; - } - result = manager->registerListener(eventQueue->getId()); - if (result != HasReturnvaluesIF::RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } + result = manager->registerListener(eventQueue->getId()); + if (result != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "CCSDSHandler::initialize: Failed to register CCSDS handler as event " - "listener" << std::endl; + sif::warning << "CCSDSHandler::initialize: Failed to register CCSDS handler as event " + "listener" + << std::endl; #endif - return ObjectManagerIF::CHILD_INIT_FAILED;; - } - result = manager->subscribeToEventRange(eventQueue->getId(), - event::getEventId(PdecHandler::CARRIER_LOCK), - event::getEventId(PdecHandler::BIT_LOCK_PDEC)); - if (result != HasReturnvaluesIF::RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + ; + } + result = manager->subscribeToEventRange(eventQueue->getId(), + event::getEventId(PdecHandler::CARRIER_LOCK), + event::getEventId(PdecHandler::BIT_LOCK_PDEC)); + if (result != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "CCSDSHandler::initialize: Failed to subscribe to events from PDEC " - "handler" << std::endl; + sif::error << "CCSDSHandler::initialize: Failed to subscribe to events from PDEC " + "handler" + << std::endl; #endif - return result; - } - return result; + return result; + } + return result; } void CCSDSHandler::readCommandQueue(void) { - CommandMessage commandMessage; - ReturnValue_t result = RETURN_FAILED; + CommandMessage commandMessage; + ReturnValue_t result = RETURN_FAILED; - result = commandQueue->receiveMessage(&commandMessage); + result = commandQueue->receiveMessage(&commandMessage); + if (result == RETURN_OK) { + result = parameterHelper.handleParameterMessage(&commandMessage); if (result == RETURN_OK) { - result = parameterHelper.handleParameterMessage(&commandMessage); - if (result == RETURN_OK) { - return; - } - result = actionHelper.handleActionMessage(&commandMessage); - if (result == RETURN_OK) { - return; - } - CommandMessage reply; - reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND, - commandMessage.getCommand()); - commandQueue->reply(&reply); - return; + return; } + result = actionHelper.handleActionMessage(&commandMessage); + if (result == RETURN_OK) { + return; + } + CommandMessage reply; + reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND, commandMessage.getCommand()); + commandQueue->reply(&reply); + return; + } } -MessageQueueId_t CCSDSHandler::getCommandQueue() const { - return commandQueue->getId(); -} +MessageQueueId_t CCSDSHandler::getCommandQueue() const { return commandQueue->getId(); } void CCSDSHandler::addVirtualChannel(VcId_t vcId, VirtualChannel* virtualChannel) { - if (vcId > common::NUMBER_OF_VIRTUAL_CHANNELS) { - sif::warning << "CCSDSHandler::addVirtualChannel: Invalid virtual channel ID" << std::endl; - return; - } + if (vcId > common::NUMBER_OF_VIRTUAL_CHANNELS) { + sif::warning << "CCSDSHandler::addVirtualChannel: Invalid virtual channel ID" << std::endl; + return; + } - if (virtualChannel == nullptr) { - sif::warning << "CCSDSHandler::addVirtualChannel: Invalid virtual channel interface" << std::endl; - return; - } + if (virtualChannel == nullptr) { + sif::warning << "CCSDSHandler::addVirtualChannel: Invalid virtual channel interface" + << std::endl; + return; + } - auto status = virtualChannelMap.emplace(vcId, virtualChannel); - if (status.second == false) { - sif::warning << "CCSDSHandler::addVirtualChannel: Failed to add virtual channel to " - "virtual channel map" << std::endl; - return; - } + auto status = virtualChannelMap.emplace(vcId, virtualChannel); + if (status.second == false) { + sif::warning << "CCSDSHandler::addVirtualChannel: Failed to add virtual channel to " + "virtual channel map" + << std::endl; + return; + } } MessageQueueId_t CCSDSHandler::getReportReceptionQueue(uint8_t virtualChannel) { - if (virtualChannel < common::NUMBER_OF_VIRTUAL_CHANNELS) { - VirtualChannelMapIter iter = virtualChannelMap.find(virtualChannel); - if (iter != virtualChannelMap.end()) { - return iter->second->getReportReceptionQueue(); - } - else { - sif::warning << "CCSDSHandler::getReportReceptionQueue: Virtual channel with ID " - << static_cast(virtualChannel) << " not in virtual channel map" - << std::endl; - return MessageQueueIF::NO_QUEUE; - } - } else { - sif::debug << "CCSDSHandler::getReportReceptionQueue: Invalid virtual channel requested"; - - } - return MessageQueueIF::NO_QUEUE; + if (virtualChannel < common::NUMBER_OF_VIRTUAL_CHANNELS) { + VirtualChannelMapIter iter = virtualChannelMap.find(virtualChannel); + if (iter != virtualChannelMap.end()) { + return iter->second->getReportReceptionQueue(); + } else { + sif::warning << "CCSDSHandler::getReportReceptionQueue: Virtual channel with ID " + << static_cast(virtualChannel) << " not in virtual channel map" + << std::endl; + return MessageQueueIF::NO_QUEUE; + } + } else { + sif::debug << "CCSDSHandler::getReportReceptionQueue: Invalid virtual channel requested"; + } + return MessageQueueIF::NO_QUEUE; } ReturnValue_t CCSDSHandler::getParameter(uint8_t domainId, uint8_t uniqueIdentifier, - ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues, - uint16_t startAtIndex) { - return RETURN_OK; + ParameterWrapper* parameterWrapper, + const ParameterWrapper* newValues, uint16_t startAtIndex) { + return RETURN_OK; } -uint16_t CCSDSHandler::getIdentifier() { - return 0; -} +uint16_t CCSDSHandler::getIdentifier() { return 0; } MessageQueueId_t CCSDSHandler::getRequestQueue() { - // Forward packets directly to TC distributor - return tcDistributorQueueId; + // Forward packets directly to TC distributor + return tcDistributorQueueId; } -ReturnValue_t CCSDSHandler::executeAction(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { - - switch(actionId) { +ReturnValue_t CCSDSHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) { + switch (actionId) { case SET_LOW_RATE: { - txRateSetterIF->setRate(BitRates::RATE_400KHZ); - return EXECUTION_FINISHED; + txRateSetterIF->setRate(BitRates::RATE_400KHZ); + return EXECUTION_FINISHED; } case SET_HIGH_RATE: { - txRateSetterIF->setRate(BitRates::RATE_2000KHZ); - return EXECUTION_FINISHED; + txRateSetterIF->setRate(BitRates::RATE_2000KHZ); + return EXECUTION_FINISHED; } case EN_TRANSMITTER: { - enableTransmit(); - return EXECUTION_FINISHED; + enableTransmit(); + return EXECUTION_FINISHED; } case DIS_TRANSMITTER: { - disableTransmit(); - return EXECUTION_FINISHED; + disableTransmit(); + return EXECUTION_FINISHED; } default: - return COMMAND_NOT_IMPLEMENTED; - } + return COMMAND_NOT_IMPLEMENTED; + } } void CCSDSHandler::checkEvents() { - EventMessage event; - for (ReturnValue_t result = eventQueue->receiveMessage(&event); - result == RETURN_OK; result = eventQueue->receiveMessage(&event)) { - switch (event.getMessageId()) { - case EventMessage::EVENT_MESSAGE: - handleEvent(&event); - break; - default: - sif::debug << "CCSDSHandler::checkEvents: Did not subscribe to this event message" - << std::endl; - break; - } + EventMessage event; + for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == RETURN_OK; + result = eventQueue->receiveMessage(&event)) { + switch (event.getMessageId()) { + case EventMessage::EVENT_MESSAGE: + handleEvent(&event); + break; + default: + sif::debug << "CCSDSHandler::checkEvents: Did not subscribe to this event message" + << std::endl; + break; } + } } - void CCSDSHandler::handleEvent(EventMessage* eventMessage) { - Event event = eventMessage->getEvent(); - switch(event){ + Event event = eventMessage->getEvent(); + switch (event) { case PdecHandler::BIT_LOCK_PDEC: { - handleBitLockEvent(); - break; + handleBitLockEvent(); + break; } case PdecHandler::CARRIER_LOCK: { - handleCarrierLockEvent(); - break; + handleCarrierLockEvent(); + break; } default: - sif::debug << "CCSDSHandler::handleEvent: Did not subscribe to this event" - << std::endl; - break; - } + sif::debug << "CCSDSHandler::handleEvent: Did not subscribe to this event" << std::endl; + break; + } } void CCSDSHandler::handleBitLockEvent() { - if(transmitterCountdown.isBusy()) { - // Transmitter already enabled - return; - } - enableTransmit(); + if (transmitterCountdown.isBusy()) { + // Transmitter already enabled + return; + } + enableTransmit(); } void CCSDSHandler::handleCarrierLockEvent() { - if (!enableTxWhenCarrierLock) { - return; - } - enableTransmit(); + if (!enableTxWhenCarrierLock) { + return; + } + enableTransmit(); } void CCSDSHandler::forwardLinkstate() { - VirtualChannelMapIter iter; - for(iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { - iter->second->setLinkState(linkState); - } + VirtualChannelMapIter iter; + for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { + iter->second->setLinkState(linkState); + } } void CCSDSHandler::enableTransmit() { - if(transmitterCountdown.isBusy()) { - // Transmitter already enabled - return; - } - transmitterCountdown.setTimeout(TRANSMITTER_TIMEOUT); + if (transmitterCountdown.isBusy()) { + // Transmitter already enabled + return; + } + transmitterCountdown.setTimeout(TRANSMITTER_TIMEOUT); #if BOARD_TE0720 == 0 - gpioIF->pullHigh(enTxClock); - gpioIF->pullHigh(enTxData); + gpioIF->pullHigh(enTxClock); + gpioIF->pullHigh(enTxData); #endif /* BOARD_TE0720 == 0 */ - linkState = UP; - // Set link state of all virtual channels to link up - forwardLinkstate(); + linkState = UP; + // Set link state of all virtual channels to link up + forwardLinkstate(); } void CCSDSHandler::checkTxTimer() { - if(linkState == DOWN) { - return; - } - if (transmitterCountdown.hasTimedOut()) { - disableTransmit(); - } + if (linkState == DOWN) { + return; + } + if (transmitterCountdown.hasTimedOut()) { + disableTransmit(); + } } void CCSDSHandler::disableTransmit() { #if BOARD_TE0720 == 0 - gpioIF->pullLow(enTxClock); - gpioIF->pullLow(enTxData); + gpioIF->pullLow(enTxClock); + gpioIF->pullLow(enTxData); #endif /* BOARD_TE0720 == 0 */ - linkState = DOWN; - forwardLinkstate(); - transmitterCountdown.setTimeout(0); + linkState = DOWN; + forwardLinkstate(); + transmitterCountdown.setTimeout(0); } diff --git a/mission/tmtc/CCSDSHandler.h b/mission/tmtc/CCSDSHandler.h index 6fb6168b..8203b807 100644 --- a/mission/tmtc/CCSDSHandler.h +++ b/mission/tmtc/CCSDSHandler.h @@ -1,22 +1,23 @@ #ifndef CCSDSHANDLER_H_ #define CCSDSHANDLER_H_ +#include + #include "OBSWConfig.h" -#include "fsfw/objectmanager/SystemObject.h" -#include "fsfw/tasks/ExecutableObjectIF.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" -#include "fsfw/tmtcservices/AcceptsTelemetryIF.h" -#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" -#include "fsfw/parameters/ParameterHelper.h" +#include "VirtualChannel.h" #include "fsfw/action/ActionHelper.h" #include "fsfw/action/HasActionsIF.h" -#include "fsfw/timemanager/Countdown.h" #include "fsfw/events/EventMessage.h" -#include "linux/obc/TxRateSetterIF.h" -#include "fsfw_hal/common/gpio/gpioDefinitions.h" +#include "fsfw/objectmanager/SystemObject.h" +#include "fsfw/parameters/ParameterHelper.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/tasks/ExecutableObjectIF.h" +#include "fsfw/timemanager/Countdown.h" +#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" +#include "fsfw/tmtcservices/AcceptsTelemetryIF.h" #include "fsfw_hal/common/gpio/GpioIF.h" -#include "VirtualChannel.h" -#include +#include "fsfw_hal/common/gpio/gpioDefinitions.h" +#include "linux/obc/TxRateSetterIF.h" /** * @brief This class handles the data exchange with the CCSDS IP cores implemented in the @@ -24,145 +25,144 @@ * * @author J. Meier */ -class CCSDSHandler: public SystemObject, - public ExecutableObjectIF, - public AcceptsTelemetryIF, - public AcceptsTelecommandsIF, - public HasReturnvaluesIF, - public ReceivesParameterMessagesIF, - public HasActionsIF { -public: +class CCSDSHandler : public SystemObject, + public ExecutableObjectIF, + public AcceptsTelemetryIF, + public AcceptsTelecommandsIF, + public HasReturnvaluesIF, + public ReceivesParameterMessagesIF, + public HasActionsIF { + public: + using VcId_t = uint8_t; - using VcId_t = uint8_t; + /** + * @brief Constructor + * + * @param objectId Object ID of the CCSDS handler + * @param ptmeId Object ID of the PTME object providing access to the PTME IP Core. + * @param tcDestination Object ID of object handling received TC space packets + * @param txRateSetter Object providing the functionality to switch the input bitrate of + * the S-Band transceiver. + * @param gpioIF Required to enable TX data and TX clock RS485 transceiver chips. + * @param enTxClock GPIO ID of RS485 tx clock enable + * @param enTxData GPIO ID of RS485 tx data enable + */ + CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination, + TxRateSetterIF* txRateSetterIF, GpioIF* gpioIF, gpioId_t enTxClock, + gpioId_t enTxData); - /** - * @brief Constructor - * - * @param objectId Object ID of the CCSDS handler - * @param ptmeId Object ID of the PTME object providing access to the PTME IP Core. - * @param tcDestination Object ID of object handling received TC space packets - * @param txRateSetter Object providing the functionality to switch the input bitrate of - * the S-Band transceiver. - * @param gpioIF Required to enable TX data and TX clock RS485 transceiver chips. - * @param enTxClock GPIO ID of RS485 tx clock enable - * @param enTxData GPIO ID of RS485 tx data enable - */ - CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination, - TxRateSetterIF* txRateSetterIF, GpioIF* gpioIF, gpioId_t enTxClock, gpioId_t enTxData); + ~CCSDSHandler(); - ~CCSDSHandler(); + ReturnValue_t performOperation(uint8_t operationCode = 0) override; + ReturnValue_t initialize(); + MessageQueueId_t getCommandQueue() const; - ReturnValue_t performOperation(uint8_t operationCode = 0) override; - ReturnValue_t initialize(); - MessageQueueId_t getCommandQueue() const; + /** + * @brief Function to add a virtual channel + * + * @param virtualChannelId ID of the virtual channel to add + * @param virtualChannel Pointer to virtual channel object + */ + void addVirtualChannel(VcId_t virtualChannelId, VirtualChannel* virtualChannel); - /** - * @brief Function to add a virtual channel - * - * @param virtualChannelId ID of the virtual channel to add - * @param virtualChannel Pointer to virtual channel object - */ - void addVirtualChannel(VcId_t virtualChannelId, VirtualChannel* virtualChannel); + MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0); + ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueIdentifier, + ParameterWrapper* parameterWrapper, const ParameterWrapper* newValues, + uint16_t startAtIndex); - MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0); - ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueIdentifier, - ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues, - uint16_t startAtIndex); + uint16_t getIdentifier() override; + MessageQueueId_t getRequestQueue() override; - uint16_t getIdentifier() override; - MessageQueueId_t getRequestQueue() override; + virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size); - virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size); + private: + static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_HANDLER; -private: + static const uint32_t QUEUE_SIZE = common::CCSDS_HANDLER_QUEUE_SIZE; - static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_HANDLER; + static const ActionId_t SET_LOW_RATE = 0; + static const ActionId_t SET_HIGH_RATE = 1; + static const ActionId_t EN_TRANSMITTER = 2; + static const ActionId_t DIS_TRANSMITTER = 3; - static const uint32_t QUEUE_SIZE = common::CCSDS_HANDLER_QUEUE_SIZE; - - static const ActionId_t SET_LOW_RATE = 0; - static const ActionId_t SET_HIGH_RATE = 1; - static const ActionId_t EN_TRANSMITTER = 2; - static const ActionId_t DIS_TRANSMITTER = 3; - - //! [EXPORT] : [COMMENT] Received action message with unknown action id - static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xA0); + //! [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 + // 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 /* TMTC_TEST_SETUP == 0 */ - static const bool UP = true; - static const bool DOWN = false; + static const bool UP = true; + static const bool DOWN = false; - using VirtualChannelMap = std::unordered_map; - using VirtualChannelMapIter = VirtualChannelMap::iterator; + using VirtualChannelMap = std::unordered_map; + using VirtualChannelMapIter = VirtualChannelMap::iterator; - VirtualChannelMap virtualChannelMap; + VirtualChannelMap virtualChannelMap; - // Object ID of PTME object - object_id_t ptmeId; + // Object ID of PTME object + object_id_t ptmeId; - object_id_t tcDestination; + object_id_t tcDestination; - MessageQueueIF* commandQueue = nullptr; - MessageQueueIF* eventQueue = nullptr; + MessageQueueIF* commandQueue = nullptr; + MessageQueueIF* eventQueue = nullptr; - ParameterHelper parameterHelper; + ParameterHelper parameterHelper; - ActionHelper actionHelper; + ActionHelper actionHelper; - MessageQueueId_t tcDistributorQueueId; + MessageQueueId_t tcDistributorQueueId; - TxRateSetterIF* txRateSetterIF = nullptr; + TxRateSetterIF* txRateSetterIF = nullptr; - GpioIF* gpioIF = nullptr; - gpioId_t enTxClock = gpio::NO_GPIO; - gpioId_t enTxData = gpio::NO_GPIO; + GpioIF* gpioIF = nullptr; + gpioId_t enTxClock = gpio::NO_GPIO; + gpioId_t enTxData = gpio::NO_GPIO; - // Countdown to disable transmitter after 15 minutes - Countdown transmitterCountdown; + // Countdown to disable transmitter after 15 minutes + Countdown transmitterCountdown; - // When true transmitting is started as soon as carrier lock has been detected - bool enableTxWhenCarrierLock = false; + // When true transmitting is started as soon as carrier lock has been detected + bool enableTxWhenCarrierLock = false; - bool linkState = DOWN; + bool linkState = DOWN; - void readCommandQueue(void); - void handleTelemetry(); - void handleTelecommands(); - void checkEvents(); - void handleEvent(EventMessage* eventMessage); + void readCommandQueue(void); + void handleTelemetry(); + void handleTelecommands(); + void checkEvents(); + void handleEvent(EventMessage* eventMessage); - void handleBitLockEvent(); - void handleCarrierLockEvent(); + void handleBitLockEvent(); + void handleCarrierLockEvent(); - /** - * @brief Forward link state to virtual channels. - */ - void forwardLinkstate(); + /** + * @brief Forward link state to virtual channels. + */ + void forwardLinkstate(); - /** - * @brief Starts transmit timer and enables transmitter. - */ - void enableTransmit(); + /** + * @brief Starts transmit timer and enables transmitter. + */ + void enableTransmit(); - /** - * @brief Checks Tx timer for timeout and disables RS485 tx clock and tx data in case - * timer has expired. - */ - void checkTxTimer(); + /** + * @brief Checks Tx timer for timeout and disables RS485 tx clock and tx data in case + * timer has expired. + */ + void checkTxTimer(); - /** - * @brief Disables the transmitter by pulling the enable tx clock and tx data pin of the - * RS485 transceiver chips to high. - */ - void disableTransmit(); + /** + * @brief Disables the transmitter by pulling the enable tx clock and tx data pin of the + * RS485 transceiver chips to high. + */ + void disableTransmit(); }; #endif /* CCSDSHANDLER_H_ */ diff --git a/mission/tmtc/VirtualChannel.cpp b/mission/tmtc/VirtualChannel.cpp index 0273f5ce..5b9387fd 100644 --- a/mission/tmtc/VirtualChannel.cpp +++ b/mission/tmtc/VirtualChannel.cpp @@ -1,69 +1,65 @@ -#include "CCSDSHandler.h" #include "VirtualChannel.h" + +#include "CCSDSHandler.h" #include "OBSWConfig.h" - -#include "fsfw/serviceinterface/ServiceInterfaceStream.h" -#include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/tmtcservices/TmTcMessage.h" #include "fsfw/ipc/QueueFactory.h" +#include "fsfw/objectmanager/ObjectManager.h" +#include "fsfw/serviceinterface/ServiceInterfaceStream.h" +#include "fsfw/tmtcservices/TmTcMessage.h" - -VirtualChannel::VirtualChannel(uint8_t vcId, uint32_t tmQueueDepth) : - vcId(vcId) { - tmQueue = QueueFactory::instance()->createMessageQueue(tmQueueDepth, - MessageQueueMessage::MAX_MESSAGE_SIZE); +VirtualChannel::VirtualChannel(uint8_t vcId, uint32_t tmQueueDepth) : vcId(vcId) { + tmQueue = QueueFactory::instance()->createMessageQueue(tmQueueDepth, + MessageQueueMessage::MAX_MESSAGE_SIZE); } ReturnValue_t VirtualChannel::initialize() { - tmStore = ObjectManager::instance()->get(objects::TM_STORE); - if(tmStore == nullptr) { - sif::error << "VirtualChannel::initialize: Failed to get tm store" << std::endl; - return RETURN_FAILED; - } - return RETURN_OK; + tmStore = ObjectManager::instance()->get(objects::TM_STORE); + if (tmStore == nullptr) { + sif::error << "VirtualChannel::initialize: Failed to get tm store" << std::endl; + return RETURN_FAILED; + } + return RETURN_OK; } ReturnValue_t VirtualChannel::performOperation() { - ReturnValue_t result = RETURN_OK; - TmTcMessage message; + ReturnValue_t result = RETURN_OK; + TmTcMessage message; - while(tmQueue->receiveMessage(&message) == RETURN_OK) { - store_address_t storeId = message.getStorageId(); - const uint8_t* data = nullptr; - size_t size = 0; - result = tmStore->getData(storeId, &data, &size); - if (result != RETURN_OK) { - sif::warning << "VirtualChannel::performOperation: Failed to read data from IPC store" - << std::endl; - tmStore->deleteData(storeId); - return result; - } + while (tmQueue->receiveMessage(&message) == RETURN_OK) { + store_address_t storeId = message.getStorageId(); + const uint8_t* data = nullptr; + size_t size = 0; + result = tmStore->getData(storeId, &data, &size); + if (result != RETURN_OK) { + sif::warning << "VirtualChannel::performOperation: Failed to read data from IPC store" + << std::endl; + tmStore->deleteData(storeId); + return result; + } - if (linkIsUp) { - result = ptme->writeToVc(vcId, data, size); - } + if (linkIsUp) { + result = ptme->writeToVc(vcId, data, size); + } - tmStore->deleteData(storeId); + tmStore->deleteData(storeId); - if (result != RETURN_OK) { - return result; - } - } - return result; + if (result != RETURN_OK) { + return result; + } + } + return result; } MessageQueueId_t VirtualChannel::getReportReceptionQueue(uint8_t virtualChannel) { - return tmQueue->getId(); + return tmQueue->getId(); } void VirtualChannel::setPtmeObject(PtmeIF* ptme_) { - if (ptme_ == nullptr) { - sif::warning << "VirtualChannel::setPtmeObject: Invalid ptme object" << std::endl; - return; - } - ptme = ptme_; + if (ptme_ == nullptr) { + sif::warning << "VirtualChannel::setPtmeObject: Invalid ptme object" << std::endl; + return; + } + ptme = ptme_; } -void VirtualChannel::setLinkState(bool linkIsUp_) { - linkIsUp = linkIsUp_; -} +void VirtualChannel::setLinkState(bool linkIsUp_) { linkIsUp = linkIsUp_; } diff --git a/mission/tmtc/VirtualChannel.h b/mission/tmtc/VirtualChannel.h index 213a3421..48cc74a4 100644 --- a/mission/tmtc/VirtualChannel.h +++ b/mission/tmtc/VirtualChannel.h @@ -1,12 +1,13 @@ #ifndef VIRTUALCHANNEL_H_ #define VIRTUALCHANNEL_H_ -#include "OBSWConfig.h" -#include "fsfw/tmtcservices/AcceptsTelemetryIF.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include #include +#include "OBSWConfig.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/tmtcservices/AcceptsTelemetryIF.h" + class StorageManagerIF; /** @@ -15,42 +16,41 @@ class StorageManagerIF; * * @author J. Meier */ -class VirtualChannel: public AcceptsTelemetryIF, public HasReturnvaluesIF { - public: - /** - * @brief Constructor - * - * @param vcId The virtual channel id assigned to this object - * @param tmQueueDepth Queue depth of queue receiving telemetry from other objects - */ - VirtualChannel(uint8_t vcId, uint32_t tmQueueDepth); +class VirtualChannel : public AcceptsTelemetryIF, public HasReturnvaluesIF { + public: + /** + * @brief Constructor + * + * @param vcId The virtual channel id assigned to this object + * @param tmQueueDepth Queue depth of queue receiving telemetry from other objects + */ + VirtualChannel(uint8_t vcId, uint32_t tmQueueDepth); - ReturnValue_t initialize(); - MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) override; - ReturnValue_t performOperation(); + ReturnValue_t initialize(); + MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) override; + ReturnValue_t performOperation(); - /** - * @brief Sets the PTME object which handles access to the PTME IP Core. - * - * @param ptme Pointer to ptme object - */ - void setPtmeObject(PtmeIF* ptme_); + /** + * @brief Sets the PTME object which handles access to the PTME IP Core. + * + * @param ptme Pointer to ptme object + */ + void setPtmeObject(PtmeIF* ptme_); - /** - * @brief Can be used by the owner to set the link state. Packets will be discarded if link - * to ground station is down. - */ - void setLinkState(bool linkIsUp_); + /** + * @brief Can be used by the owner to set the link state. Packets will be discarded if link + * to ground station is down. + */ + void setLinkState(bool linkIsUp_); -private: + private: + PtmeIF* ptme = nullptr; + MessageQueueIF* tmQueue = nullptr; + uint8_t vcId; - PtmeIF* ptme = nullptr; - MessageQueueIF* tmQueue = nullptr; - uint8_t vcId; + bool linkIsUp = false; - bool linkIsUp = false; - - StorageManagerIF* tmStore = nullptr; + StorageManagerIF* tmStore = nullptr; }; #endif /* VIRTUALCHANNEL_H_ */ diff --git a/mission/utility/InitMission.h b/mission/utility/InitMission.h index b4a83a1e..dc131981 100644 --- a/mission/utility/InitMission.h +++ b/mission/utility/InitMission.h @@ -8,15 +8,15 @@ namespace initmission { void printAddObjectError(const char* name, object_id_t objectId) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "InitMission::printAddError: Adding object " << name << " with object ID 0x" - << std::hex << std::setfill('0') << std::setw(8) << objectId - << " failed!" << std::dec << std::endl; + sif::error << "InitMission::printAddError: Adding object " << name << " with object ID 0x" + << std::hex << std::setfill('0') << std::setw(8) << objectId << " failed!" << std::dec + << std::endl; #else - sif::printError("InitMission::printAddError: Adding object %s with object ID 0x%08x failed!\n" , - name, objectId); + sif::printError("InitMission::printAddError: Adding object %s with object ID 0x%08x failed!\n", + name, objectId); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ } -} +} // namespace initmission #endif /* MISSION_UTILITY_INITMISSION_H_ */ diff --git a/mission/utility/Timestamp.cpp b/mission/utility/Timestamp.cpp index c0848a59..095bd28c 100644 --- a/mission/utility/Timestamp.cpp +++ b/mission/utility/Timestamp.cpp @@ -1,28 +1,22 @@ #include "Timestamp.h" + #include "fsfw/serviceinterface/ServiceInterfaceStream.h" Timestamp::Timestamp() { - ReturnValue_t result = Clock::getDateAndTime(&time); - if (result != RETURN_OK) { - sif::warning << "Timestamp::Timestamp: Failed to get time" << std::endl; - } + ReturnValue_t result = Clock::getDateAndTime(&time); + if (result != RETURN_OK) { + sif::warning << "Timestamp::Timestamp: Failed to get time" << std::endl; + } } -Timestamp::~Timestamp() { -} +Timestamp::~Timestamp() {} std::string Timestamp::str() { - timestamp << std::to_string(time.year) << "-" - << std::setw(2) << std::setfill('0') - << std::to_string(time.month) << "-" - << std::setw(2) << std::setfill('0') - << std::to_string(time.day) << "--" - << std::setw(2) << std::setfill('0') - << std::to_string(time.hour) << "-" - << std::setw(2) << std::setfill('0') - << std::to_string(time.minute) << "-" - << std::setw(2) << std::setfill('0') - << std::to_string(time.second) << "--"; - return timestamp.str(); + timestamp << std::to_string(time.year) << "-" << std::setw(2) << std::setfill('0') + << std::to_string(time.month) << "-" << std::setw(2) << std::setfill('0') + << std::to_string(time.day) << "--" << std::setw(2) << std::setfill('0') + << std::to_string(time.hour) << "-" << std::setw(2) << std::setfill('0') + << std::to_string(time.minute) << "-" << std::setw(2) << std::setfill('0') + << std::to_string(time.second) << "--"; + return timestamp.str(); } - diff --git a/mission/utility/Timestamp.h b/mission/utility/Timestamp.h index 7146de53..4f783437 100644 --- a/mission/utility/Timestamp.h +++ b/mission/utility/Timestamp.h @@ -1,11 +1,12 @@ #ifndef MISSION_UTILITY_TIMESTAMP_H_ #define MISSION_UTILITY_TIMESTAMP_H_ -#include -#include #include -#include "fsfw/timemanager/Clock.h" +#include +#include + #include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/timemanager/Clock.h" /** * @brief This class generates timestamps for files. @@ -13,18 +14,18 @@ * @author J. Meier */ class Timestamp : public HasReturnvaluesIF { -public: - Timestamp(); - virtual ~Timestamp(); + public: + Timestamp(); + virtual ~Timestamp(); - /** - * @brief Returns the timestamp string - */ - std::string str(); + /** + * @brief Returns the timestamp string + */ + std::string str(); -private: - std::stringstream timestamp; - Clock::TimeOfDay_t time; + private: + std::stringstream timestamp; + Clock::TimeOfDay_t time; }; #endif /* MISSION_UTILITY_TIMESTAMP_H_ */ diff --git a/mission/utility/TmFunnel.cpp b/mission/utility/TmFunnel.cpp index 4b9eebdf..5577f5fa 100644 --- a/mission/utility/TmFunnel.cpp +++ b/mission/utility/TmFunnel.cpp @@ -1,122 +1,118 @@ -#include "OBSWConfig.h" #include -#include #include #include +#include #include +#include "OBSWConfig.h" + object_id_t TmFunnel::downlinkDestination = objects::NO_OBJECT; object_id_t TmFunnel::storageDestination = objects::NO_OBJECT; -TmFunnel::TmFunnel(object_id_t objectId, uint32_t messageDepth): - SystemObject(objectId), messageDepth(messageDepth) { - tmQueue = QueueFactory::instance()->createMessageQueue(messageDepth, - MessageQueueMessage::MAX_MESSAGE_SIZE); - storageQueue = QueueFactory::instance()->createMessageQueue(messageDepth, - MessageQueueMessage::MAX_MESSAGE_SIZE); +TmFunnel::TmFunnel(object_id_t objectId, uint32_t messageDepth) + : SystemObject(objectId), messageDepth(messageDepth) { + tmQueue = QueueFactory::instance()->createMessageQueue(messageDepth, + MessageQueueMessage::MAX_MESSAGE_SIZE); + storageQueue = QueueFactory::instance()->createMessageQueue( + messageDepth, MessageQueueMessage::MAX_MESSAGE_SIZE); } -TmFunnel::~TmFunnel() { -} +TmFunnel::~TmFunnel() {} MessageQueueId_t TmFunnel::getReportReceptionQueue(uint8_t virtualChannel) { - return tmQueue->getId(); + return tmQueue->getId(); } ReturnValue_t TmFunnel::performOperation(uint8_t operationCode) { - TmTcMessage currentMessage; - ReturnValue_t status = tmQueue->receiveMessage(¤tMessage); - while(status == HasReturnvaluesIF::RETURN_OK) - { - status = handlePacket(¤tMessage); - if(status != HasReturnvaluesIF::RETURN_OK){ - break; - } - status = tmQueue->receiveMessage(¤tMessage); - } + TmTcMessage currentMessage; + ReturnValue_t status = tmQueue->receiveMessage(¤tMessage); + while (status == HasReturnvaluesIF::RETURN_OK) { + status = handlePacket(¤tMessage); + if (status != HasReturnvaluesIF::RETURN_OK) { + break; + } + status = tmQueue->receiveMessage(¤tMessage); + } - if (status == MessageQueueIF::EMPTY) { - return HasReturnvaluesIF::RETURN_OK; - } - else { - return status; - } + if (status == MessageQueueIF::EMPTY) { + return HasReturnvaluesIF::RETURN_OK; + } else { + return status; + } } ReturnValue_t TmFunnel::handlePacket(TmTcMessage* message) { - uint8_t* packetData = nullptr; - size_t size = 0; - ReturnValue_t result = tmStore->modifyData(message->getStorageId(), - &packetData, &size); - if(result != HasReturnvaluesIF::RETURN_OK){ - return result; - } - TmPacketPusC packet(packetData); - packet.setPacketSequenceCount(this->sourceSequenceCount); - sourceSequenceCount++; - sourceSequenceCount = sourceSequenceCount % - SpacePacketBase::LIMIT_SEQUENCE_COUNT; - packet.setErrorControl(); + uint8_t* packetData = nullptr; + size_t size = 0; + ReturnValue_t result = tmStore->modifyData(message->getStorageId(), &packetData, &size); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + TmPacketPusC packet(packetData); + packet.setPacketSequenceCount(this->sourceSequenceCount); + sourceSequenceCount++; + sourceSequenceCount = sourceSequenceCount % SpacePacketBase::LIMIT_SEQUENCE_COUNT; + packet.setErrorControl(); - result = tmQueue->sendToDefault(message); - if(result != HasReturnvaluesIF::RETURN_OK){ - tmStore->deleteData(message->getStorageId()); - sif::error << "TmFunnel::handlePacket: Error sending to downlink " - "handler" << std::endl; - return result; - } + result = tmQueue->sendToDefault(message); + if (result != HasReturnvaluesIF::RETURN_OK) { + tmStore->deleteData(message->getStorageId()); + sif::error << "TmFunnel::handlePacket: Error sending to downlink " + "handler" + << std::endl; + return result; + } - if(storageDestination != objects::NO_OBJECT) { - result = storageQueue->sendToDefault(message); - if(result != HasReturnvaluesIF::RETURN_OK){ - tmStore->deleteData(message->getStorageId()); - sif::error << "TmFunnel::handlePacket: Error sending to storage " - "handler" << std::endl; - return result; - } - } - return result; + if (storageDestination != objects::NO_OBJECT) { + result = storageQueue->sendToDefault(message); + if (result != HasReturnvaluesIF::RETURN_OK) { + tmStore->deleteData(message->getStorageId()); + sif::error << "TmFunnel::handlePacket: Error sending to storage " + "handler" + << std::endl; + return result; + } + } + return result; } ReturnValue_t TmFunnel::initialize() { + tmStore = ObjectManager::instance()->get(objects::TM_STORE); + if (tmStore == nullptr) { + sif::error << "TmFunnel::initialize: TM store not set." << std::endl; + sif::error << "Make sure the tm store is set up properly" + " and implements StorageManagerIF" + << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - tmStore = ObjectManager::instance()->get(objects::TM_STORE); - if(tmStore == nullptr) { - sif::error << "TmFunnel::initialize: TM store not set." - << std::endl; - sif::error << "Make sure the tm store is set up properly" - " and implements StorageManagerIF" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } - - AcceptsTelemetryIF* tmTarget = - ObjectManager::instance()->get(downlinkDestination); - if(tmTarget == nullptr){ - sif::error << "TmFunnel::initialize: Downlink Destination not set." - << std::endl; - sif::error << "Make sure the downlink destination object is set up " - "properly and implements AcceptsTelemetryIF" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + AcceptsTelemetryIF* tmTarget = + ObjectManager::instance()->get(downlinkDestination); + if (tmTarget == nullptr) { + sif::error << "TmFunnel::initialize: Downlink Destination not set." << std::endl; + sif::error << "Make sure the downlink destination object is set up " + "properly and implements AcceptsTelemetryIF" + << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } #if OBSW_TM_TO_PTME == 1 - // Live TM will be sent via the virtual channel 0 - tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue(config::LIVE_TM)); + // Live TM will be sent via the virtual channel 0 + tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue(config::LIVE_TM)); #else - tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue()); + tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue()); #endif /* OBSW_TM_TO_PTME == 1 */ - // Storage destination is optional. - if(storageDestination == objects::NO_OBJECT) { - return SystemObject::initialize(); - } + // Storage destination is optional. + if (storageDestination == objects::NO_OBJECT) { + return SystemObject::initialize(); + } - AcceptsTelemetryIF* storageTarget = - ObjectManager::instance()->get(storageDestination); - if(storageTarget != nullptr) { - storageQueue->setDefaultDestination( - storageTarget->getReportReceptionQueue()); - } + AcceptsTelemetryIF* storageTarget = + ObjectManager::instance()->get(storageDestination); + if (storageTarget != nullptr) { + storageQueue->setDefaultDestination(storageTarget->getReportReceptionQueue()); + } - return SystemObject::initialize(); + return SystemObject::initialize(); } diff --git a/mission/utility/TmFunnel.h b/mission/utility/TmFunnel.h index b85a09e0..013e0ebc 100644 --- a/mission/utility/TmFunnel.h +++ b/mission/utility/TmFunnel.h @@ -1,13 +1,13 @@ #ifndef MISSION_UTILITY_TMFUNNEL_H_ #define MISSION_UTILITY_TMFUNNEL_H_ +#include #include #include #include -#include #include -namespace Factory{ +namespace Factory { void setStaticFrameworkObjectIds(); } @@ -19,32 +19,30 @@ void setStaticFrameworkObjectIds(); * @ingroup utility * @author J. Meier */ -class TmFunnel: public AcceptsTelemetryIF, - public ExecutableObjectIF, - public SystemObject { - friend void (Factory::setStaticFrameworkObjectIds)(); -public: - TmFunnel(object_id_t objectId, uint32_t messageDepth = 20); - virtual ~TmFunnel(); +class TmFunnel : public AcceptsTelemetryIF, public ExecutableObjectIF, public SystemObject { + friend void(Factory::setStaticFrameworkObjectIds)(); - virtual MessageQueueId_t getReportReceptionQueue( - uint8_t virtualChannel = 0) override; - virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; - virtual ReturnValue_t initialize() override; + public: + TmFunnel(object_id_t objectId, uint32_t messageDepth = 20); + virtual ~TmFunnel(); -protected: - static object_id_t downlinkDestination; - static object_id_t storageDestination; + virtual MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) override; + virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; + virtual ReturnValue_t initialize() override; -private: - uint16_t sourceSequenceCount = 0; - MessageQueueIF* tmQueue = nullptr; - MessageQueueIF* storageQueue = nullptr; + protected: + static object_id_t downlinkDestination; + static object_id_t storageDestination; - StorageManagerIF* tmStore = nullptr; - uint32_t messageDepth = 0; + private: + uint16_t sourceSequenceCount = 0; + MessageQueueIF* tmQueue = nullptr; + MessageQueueIF* storageQueue = nullptr; - ReturnValue_t handlePacket(TmTcMessage* message); + StorageManagerIF* tmStore = nullptr; + uint32_t messageDepth = 0; + + ReturnValue_t handlePacket(TmTcMessage* message); }; #endif /* MISSION_UTILITY_TMFUNNEL_H_ */ diff --git a/test/DummyParameter.h b/test/DummyParameter.h index b8da7275..410f0958 100644 --- a/test/DummyParameter.h +++ b/test/DummyParameter.h @@ -1,26 +1,24 @@ #ifndef BSP_Q7S_CORE_NVMPARAMS_PARAMETERDEFINITIONS_H_ #define BSP_Q7S_CORE_NVMPARAMS_PARAMETERDEFINITIONS_H_ -#include "mission/memory/NVMParameterBase.h" +#include #include -#include +#include "mission/memory/NVMParameterBase.h" -class DummyParameter: public NVMParameterBase { -public: - static constexpr char DUMMY_KEY_PARAM_1[] = "dummy1"; - static constexpr char DUMMY_KEY_PARAM_2[] = "dummy2"; +class DummyParameter : public NVMParameterBase { + public: + static constexpr char DUMMY_KEY_PARAM_1[] = "dummy1"; + static constexpr char DUMMY_KEY_PARAM_2[] = "dummy2"; - DummyParameter(std::string mountPrefix, std::string jsonFileName): - NVMParameterBase(mountPrefix + "/conf/" + jsonFileName), - mountPrefix(mountPrefix) { - insertValue(DUMMY_KEY_PARAM_1, 1); - insertValue(DUMMY_KEY_PARAM_2, "blablub"); - } + DummyParameter(std::string mountPrefix, std::string jsonFileName) + : NVMParameterBase(mountPrefix + "/conf/" + jsonFileName), mountPrefix(mountPrefix) { + insertValue(DUMMY_KEY_PARAM_1, 1); + insertValue(DUMMY_KEY_PARAM_2, "blablub"); + } -private: - std::string mountPrefix; + private: + std::string mountPrefix; }; - #endif /* BSP_Q7S_CORE_NVMPARAMS_PARAMETERDEFINITIONS_H_ */ diff --git a/test/testtasks/PusTcInjector.cpp b/test/testtasks/PusTcInjector.cpp index 90f2ac75..82b1cb1c 100644 --- a/test/testtasks/PusTcInjector.cpp +++ b/test/testtasks/PusTcInjector.cpp @@ -1,29 +1,29 @@ -#include - +#include +#include #include +#include +#include #include #include -#include -#include -#include -#include +#include -PusTcInjector::PusTcInjector(object_id_t objectId, object_id_t destination, - object_id_t tcStore, uint16_t defaultApid): SystemObject(objectId), - defaultApid(defaultApid), destination(destination), tcStoreId(tcStore) { -} +PusTcInjector::PusTcInjector(object_id_t objectId, object_id_t destination, object_id_t tcStore, + uint16_t defaultApid) + : SystemObject(objectId), + defaultApid(defaultApid), + destination(destination), + tcStoreId(tcStore) {} -PusTcInjector::~PusTcInjector() { -} +PusTcInjector::~PusTcInjector() {} -//ReturnValue_t PusTcInjector::injectPusTelecommand(uint8_t service, +// ReturnValue_t PusTcInjector::injectPusTelecommand(uint8_t service, // uint8_t subservice,const uint8_t* appData, size_t appDataLen) { // return injectPusTelecommand(service, subservice, defaultApid, appData, // appDataLen); -//} +// } // TODO: ACK flags -//ReturnValue_t PusTcInjector::injectPusTelecommand(uint8_t service, +// ReturnValue_t PusTcInjector::injectPusTelecommand(uint8_t service, // uint8_t subservice,uint16_t apid, const uint8_t* appData, // size_t appDataLen) { // // Prepare TC packet. Store into TC store immediately. @@ -44,24 +44,22 @@ PusTcInjector::~PusTcInjector() { //} ReturnValue_t PusTcInjector::initialize() { - // Prepare message queue which is used to send telecommands. - injectionQueue = QueueFactory::instance()-> - createMessageQueue(INJECTION_QUEUE_DEPTH); - AcceptsTelecommandsIF* targetQueue = ObjectManager::instance()-> - get(destination); - if(targetQueue == nullptr) { - sif::error << "PusTcInjector: CCSDS distributor not initialized yet!" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } - else { - injectionQueue->setDefaultDestination(targetQueue->getRequestQueue()); - } + // Prepare message queue which is used to send telecommands. + injectionQueue = QueueFactory::instance()->createMessageQueue(INJECTION_QUEUE_DEPTH); + AcceptsTelecommandsIF* targetQueue = + ObjectManager::instance()->get(destination); + if (targetQueue == nullptr) { + sif::error << "PusTcInjector: CCSDS distributor not initialized yet!" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } else { + injectionQueue->setDefaultDestination(targetQueue->getRequestQueue()); + } - // Prepare store used to store TC messages - tcStore = ObjectManager::instance()->get(tcStoreId); - if(tcStore == nullptr) { - sif::error << "PusTcInjector: TC Store not initialized!" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + // Prepare store used to store TC messages + tcStore = ObjectManager::instance()->get(tcStoreId); + if (tcStore == nullptr) { + sif::error << "PusTcInjector: TC Store not initialized!" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } diff --git a/test/testtasks/PusTcInjector.h b/test/testtasks/PusTcInjector.h index df67e403..4d1cea7e 100644 --- a/test/testtasks/PusTcInjector.h +++ b/test/testtasks/PusTcInjector.h @@ -3,70 +3,71 @@ #include #include #include + #include -class PusTcInjector: public SystemObject { -public: - static constexpr uint8_t INJECTION_QUEUE_DEPTH = 10; - const uint16_t defaultApid; +class PusTcInjector : public SystemObject { + public: + static constexpr uint8_t INJECTION_QUEUE_DEPTH = 10; + const uint16_t defaultApid; - /** - * Initialize a software telecommand injector by supplying object IDs to - * various helper objects which must exist before calling initialiez() - * @param objectId ID of PUS telecommand injector - * @param destination ID of destination, which has to implement - * AcceptsTelecommandIF. - * @param tcStore ID of telecommand store, which has to implement - * StorageManagerIF. - * @param defaultApid Default APID which will be used if an injection - * without an APID is requested. - */ - PusTcInjector(object_id_t objectId, object_id_t destination, - object_id_t tcStore, uint16_t defaultApid); - /** - * This has to be called before using the PusTcInjector. - * Call Not necessary when using a factory and the object manager. - * @return -@c RETURN_OK for successfull init - * -@c ObjectManagerIF::CHILD_INIT_FAILED otherwise - */ - ReturnValue_t initialize() override; + /** + * Initialize a software telecommand injector by supplying object IDs to + * various helper objects which must exist before calling initialiez() + * @param objectId ID of PUS telecommand injector + * @param destination ID of destination, which has to implement + * AcceptsTelecommandIF. + * @param tcStore ID of telecommand store, which has to implement + * StorageManagerIF. + * @param defaultApid Default APID which will be used if an injection + * without an APID is requested. + */ + PusTcInjector(object_id_t objectId, object_id_t destination, object_id_t tcStore, + uint16_t defaultApid); + /** + * This has to be called before using the PusTcInjector. + * Call Not necessary when using a factory and the object manager. + * @return -@c RETURN_OK for successfull init + * -@c ObjectManagerIF::CHILD_INIT_FAILED otherwise + */ + ReturnValue_t initialize() override; - virtual~ PusTcInjector(); + virtual ~PusTcInjector(); - /** - * Can be used to inject a telecommand by supplying service, subservice - * and optional application data and its length. - * Default APID will be used. - * @param service PUS service type - * @param subservice PUS subservice type - * @param appData Pointer to application data - * @param appDataLen Length of application data - * @return - */ - //ReturnValue_t injectPusTelecommand(uint8_t service, uint8_t subservice, - // const uint8_t* appData = nullptr, size_t appDataLen = 0); + /** + * Can be used to inject a telecommand by supplying service, subservice + * and optional application data and its length. + * Default APID will be used. + * @param service PUS service type + * @param subservice PUS subservice type + * @param appData Pointer to application data + * @param appDataLen Length of application data + * @return + */ + // ReturnValue_t injectPusTelecommand(uint8_t service, uint8_t subservice, + // const uint8_t* appData = nullptr, size_t appDataLen = 0); - /** - * Provides the same functionality while also setting a user defined APID. - * @param service PUS service type - * @param subservice PUS subservice type - * @param apid Custom APID to, - * @param appData Pointer to application data - * @param appDataLen Length of application data - * @return - */ - //ReturnValue_t injectPusTelecommand(uint8_t service, uint8_t subservice, - // uint16_t apid, const uint8_t* appData = nullptr, - // size_t appDataLen = 0); -private: - MessageQueueIF* injectionQueue = nullptr; - StorageManagerIF *tcStore = nullptr; + /** + * Provides the same functionality while also setting a user defined APID. + * @param service PUS service type + * @param subservice PUS subservice type + * @param apid Custom APID to, + * @param appData Pointer to application data + * @param appDataLen Length of application data + * @return + */ + // ReturnValue_t injectPusTelecommand(uint8_t service, uint8_t subservice, + // uint16_t apid, const uint8_t* appData = nullptr, + // size_t appDataLen = 0); + private: + MessageQueueIF* injectionQueue = nullptr; + StorageManagerIF* tcStore = nullptr; - /* Cached for initialize function */ - object_id_t destination = 0; - object_id_t tcStoreId = 0; + /* Cached for initialize function */ + object_id_t destination = 0; + object_id_t tcStoreId = 0; - uint16_t sequenceCount = 0; + uint16_t sequenceCount = 0; }; #endif /* TEST_TESTTASKS_PUSTCINJECTOR_H_ */ diff --git a/test/testtasks/TestTask.cpp b/test/testtasks/TestTask.cpp index 6a90cc08..911767af 100644 --- a/test/testtasks/TestTask.cpp +++ b/test/testtasks/TestTask.cpp @@ -1,45 +1,43 @@ #include "TestTask.h" -#include "OBSWConfig.h" +#include +#include #include #include -#include #include -#include #include #include +#include "OBSWConfig.h" -EiveTestTask::EiveTestTask(object_id_t objectId_): TestTask(objectId_), testMode(testModes::A) { - IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); +EiveTestTask::EiveTestTask(object_id_t objectId_) : TestTask(objectId_), testMode(testModes::A) { + IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); } -EiveTestTask::~EiveTestTask() { -} +EiveTestTask::~EiveTestTask() {} ReturnValue_t EiveTestTask::performOperation(uint8_t operationCode) { - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = RETURN_OK; - if(oneShotAction) { - /* Add code here which should only be run once */ - performOneShotAction(); - oneShotAction = false; - } + if (oneShotAction) { + /* Add code here which should only be run once */ + performOneShotAction(); + oneShotAction = false; + } - /* Add code here which should only be run once per performOperation */ - performPeriodicAction(); + /* Add code here which should only be run once per performOperation */ + performPeriodicAction(); - /* Add code here which should only be run on alternating cycles. */ - if(testMode == testModes::A) { - performActionA(); - testMode = testModes::B; - } - else if(testMode == testModes::B) { - performActionB(); - testMode = testModes::A; - } - return result; + /* Add code here which should only be run on alternating cycles. */ + if (testMode == testModes::A) { + performActionA(); + testMode = testModes::B; + } else if (testMode == testModes::B) { + performActionB(); + testMode = testModes::A; + } + return result; } #include @@ -48,70 +46,70 @@ ReturnValue_t EiveTestTask::performOperation(uint8_t operationCode) { /** * @brief Dummy data from GPS receiver. Will be replaced witgh hyperion data later. */ -const char -gps_rx_data[] = "" - "$GPRMC,183729,A,3907.356,N,12102.482,W,000.0,360.0,080301,015.5,E*6F\r\n" - "$GPRMB,A,,,,,,,,,,,,V*71\r\n" - "$GPGGA,183730,3907.356,N,12102.482,W,1,05,1.6,646.4,M,-24.1,M,,*75\r\n" - "$GPGSA,A,3,02,,,07,,09,24,26,,,,,1.6,1.6,1.0*3D\r\n" - "$GPGSV,2,1,08,02,43,088,38,04,42,145,00,05,11,291,00,07,60,043,35*71\r\n" - "$GPGSV,2,2,08,08,02,145,00,09,46,303,47,24,16,178,32,26,18,231,43*77\r\n" - "$PGRME,22.0,M,52.9,M,51.0,M*14\r\n" - "$GPGLL,3907.360,N,12102.481,W,183730,A*33\r\n" - "$PGRMZ,2062,f,3*2D\r\n" - "$PGRMM,WGS84*06\r\n" - "$GPBOD,,T,,M,,*47\r\n" - "$GPRTE,1,1,c,0*07\r\n" - "$GPRMC,183731,A,3907.482,N,12102.436,W,000.0,360.0,080301,015.5,E*67\r\n" - "$GPRMB,A,,,,,,,,,,,,V*71\r\n"; +const char gps_rx_data[] = + "" + "$GPRMC,183729,A,3907.356,N,12102.482,W,000.0,360.0,080301,015.5,E*6F\r\n" + "$GPRMB,A,,,,,,,,,,,,V*71\r\n" + "$GPGGA,183730,3907.356,N,12102.482,W,1,05,1.6,646.4,M,-24.1,M,,*75\r\n" + "$GPGSA,A,3,02,,,07,,09,24,26,,,,,1.6,1.6,1.0*3D\r\n" + "$GPGSV,2,1,08,02,43,088,38,04,42,145,00,05,11,291,00,07,60,043,35*71\r\n" + "$GPGSV,2,2,08,08,02,145,00,09,46,303,47,24,16,178,32,26,18,231,43*77\r\n" + "$PGRME,22.0,M,52.9,M,51.0,M*14\r\n" + "$GPGLL,3907.360,N,12102.481,W,183730,A*33\r\n" + "$PGRMZ,2062,f,3*2D\r\n" + "$PGRMM,WGS84*06\r\n" + "$GPBOD,,T,,M,,*47\r\n" + "$GPRTE,1,1,c,0*07\r\n" + "$GPRMC,183731,A,3907.482,N,12102.436,W,000.0,360.0,080301,015.5,E*67\r\n" + "$GPRMB,A,,,,,,,,,,,,V*71\r\n"; -const char hyperion_gps_data[] = "" - "$GNGGA,173225.998892,4908.5596,N,00906.2765,E,1,05,2.1,215.0,M,48.2,M,,0000*74\r\n" - "$GNGLL,4908.5596,N,00906.2765,E,173225.998892,A,A*7F\r\n" - "$GPGSA,A,3,18,16,26,31,20,,,,,,,,3.2,2.1,2.4*3C\r\n" - "$GNRMC,173225.998892,A,4908.5596,N,00906.2765,E,000.0,040.7,270221,,,A*4F\r\n" - "$GNVTG,040.7,T,,M,000.0,N,000.0,K,A*10\r\n" - "$GNZDA,173225.998892,27,02,2021,00,00*75\r\n"; +const char hyperion_gps_data[] = + "" + "$GNGGA,173225.998892,4908.5596,N,00906.2765,E,1,05,2.1,215.0,M,48.2,M,,0000*74\r\n" + "$GNGLL,4908.5596,N,00906.2765,E,173225.998892,A,A*7F\r\n" + "$GPGSA,A,3,18,16,26,31,20,,,,,,,,3.2,2.1,2.4*3C\r\n" + "$GNRMC,173225.998892,A,4908.5596,N,00906.2765,E,000.0,040.7,270221,,,A*4F\r\n" + "$GNVTG,040.7,T,,M,000.0,N,000.0,K,A*10\r\n" + "$GNZDA,173225.998892,27,02,2021,00,00*75\r\n"; ReturnValue_t EiveTestTask::performOneShotAction() { #if OBSW_ADD_TEST_CODE == 1 - //performLwgpsTest(); + // performLwgpsTest(); #endif - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } - ReturnValue_t EiveTestTask::performPeriodicAction() { - ReturnValue_t result = RETURN_OK; - return result; + ReturnValue_t result = RETURN_OK; + return result; } ReturnValue_t EiveTestTask::performActionA() { - ReturnValue_t result = RETURN_OK; - /* Add periodically executed code here */ - return result; + ReturnValue_t result = RETURN_OK; + /* Add periodically executed code here */ + return result; } ReturnValue_t EiveTestTask::performActionB() { - ReturnValue_t result = RETURN_OK; - /* Add periodically executed code here */ - return result; + ReturnValue_t result = RETURN_OK; + /* Add periodically executed code here */ + return result; } void EiveTestTask::performLwgpsTest() { - /* Everything here will only be performed once. */ - sif::info << "Processing sample GPS output.." << std::endl; + /* Everything here will only be performed once. */ + sif::info << "Processing sample GPS output.." << std::endl; - lwgps_t gpsStruct; - sif::info << "Size of GPS struct: " << sizeof(gpsStruct) << std::endl; - lwgps_init(&gpsStruct); + lwgps_t gpsStruct; + sif::info << "Size of GPS struct: " << sizeof(gpsStruct) << std::endl; + lwgps_init(&gpsStruct); - /* Process all input data */ - lwgps_process(&gpsStruct, hyperion_gps_data, strlen(hyperion_gps_data)); + /* Process all input data */ + lwgps_process(&gpsStruct, hyperion_gps_data, strlen(hyperion_gps_data)); - /* Print messages */ - printf("Valid status: %d\n", gpsStruct.is_valid); - printf("Latitude: %f degrees\n", gpsStruct.latitude); - printf("Longitude: %f degrees\n", gpsStruct.longitude); - printf("Altitude: %f meters\n", gpsStruct.altitude); + /* Print messages */ + printf("Valid status: %d\n", gpsStruct.is_valid); + printf("Latitude: %f degrees\n", gpsStruct.latitude); + printf("Longitude: %f degrees\n", gpsStruct.longitude); + printf("Altitude: %f meters\n", gpsStruct.altitude); } diff --git a/test/testtasks/TestTask.h b/test/testtasks/TestTask.h index c2b8c8ed..2040ffb5 100644 --- a/test/testtasks/TestTask.h +++ b/test/testtasks/TestTask.h @@ -2,12 +2,12 @@ #define TEST_TESTTASK_H_ #include -#include #include -#include "fsfw_tests/integration/task/TestTask.h" +#include #include +#include "fsfw_tests/integration/task/TestTask.h" /** * @brief Test class for general C++ testing. @@ -16,38 +16,35 @@ * tests. Instead, a derived board test class should be used. */ class EiveTestTask : public TestTask { -public: - EiveTestTask(object_id_t objectId); - virtual ~EiveTestTask(); - virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; + public: + EiveTestTask(object_id_t objectId); + virtual ~EiveTestTask(); + virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; -protected: - virtual ReturnValue_t performOneShotAction(); - virtual ReturnValue_t performPeriodicAction(); - virtual ReturnValue_t performActionA(); - virtual ReturnValue_t performActionB(); + protected: + virtual ReturnValue_t performOneShotAction(); + virtual ReturnValue_t performPeriodicAction(); + virtual ReturnValue_t performActionA(); + virtual ReturnValue_t performActionB(); - enum testModes: uint8_t { - A, - B - }; + enum testModes : uint8_t { A, B }; - testModes testMode; + testModes testMode; - bool testFlag = false; - uint8_t counter { 1 }; - uint8_t counterTrigger { 3 }; + bool testFlag = false; + uint8_t counter{1}; + uint8_t counterTrigger{3}; - void performPusInjectorTest(); - void examplePacketTest(); -private: - // Actually, to be really thread-safe, a mutex should be used as well - // Let's keep it simple for now. - bool oneShotAction = true; - StorageManagerIF* IPCStore; + void performPusInjectorTest(); + void examplePacketTest(); - void performLwgpsTest(); + private: + // Actually, to be really thread-safe, a mutex should be used as well + // Let's keep it simple for now. + bool oneShotAction = true; + StorageManagerIF* IPCStore; + + void performLwgpsTest(); }; - #endif /* TESTTASK_H_ */ From 2fe645375cbe40f31fce809a46e441d78af86a76 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 18 Jan 2022 11:47:29 +0100 Subject: [PATCH 227/465] assign dataset --- mission/devices/GPSHyperionHandler.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index d49b9db4..8a175732 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -30,7 +30,9 @@ void GPSHyperionHandler::performControlOperation() { #endif } -LocalPoolDataSetBase *GPSHyperionHandler::getDataSetHandle(sid_t sid) { return nullptr; } +LocalPoolDataSetBase *GPSHyperionHandler::getDataSetHandle(sid_t sid) { + return &gpsSet; +} ReturnValue_t GPSHyperionHandler::checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode) { From c1e04b286e4fc8eff201151baac62c4c3b09c7b1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 18 Jan 2022 11:51:14 +0100 Subject: [PATCH 228/465] added missing pool entries --- mission/devices/GPSHyperionHandler.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index 8a175732..37b11bcb 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -61,6 +61,7 @@ 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()); @@ -69,6 +70,7 @@ 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 50e17bc1608abc5eb638f25b71a07dd4887d4b64 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 18 Jan 2022 14:20:18 +0100 Subject: [PATCH 229/465] disabled acs task, crashes.. --- bsp_q7s/core/InitMission.cpp | 2 +- tmtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index dce7f27e..a5b2b548 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/tmtc b/tmtc index c86cd187..8417d342 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit c86cd1874f605a89277e1b8fcf4496f9302c941e +Subproject commit 8417d34265555dbcfb92cb2f73e20dddbd8fb924 From 3ab6494c281c1d15bcbd510bb9ba4d4e5b683db8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 18 Jan 2022 18:09:40 +0100 Subject: [PATCH 230/465] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 2c871af7..933da2f6 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 2c871af7b98abc794cdf6072fae174c9dc3ac63b +Subproject commit 933da2f655717b66c1056e764c47a2eee473a137 From 0724215b6a3c9aa2c3b1cf2b2f3a6db9ad5a1ecf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 19 Jan 2022 11:16:42 +0100 Subject: [PATCH 231/465] change dockerfile to trigger container rebuild --- automation/Dockerfile-q7s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Dockerfile-q7s b/automation/Dockerfile-q7s index 21b56439..b2604ff8 100644 --- a/automation/Dockerfile-q7s +++ b/automation/Dockerfile-q7s @@ -13,7 +13,7 @@ curl https://buggy.irs.uni-stuttgart.de/eive/tools/cortexa9hf-neon-xiphos-linux- RUN mkdir -p /usr/tools; \ curl https://buggy.irs.uni-stuttgart.de/eive/tools/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf.tar.gz \ | tar -xz -C /usr/tools - +RUN echo "test" ENV Q7S_SYSROOT="/usr/rootfs/cortexa9hf-neon-xiphos-linux-gnueabi" ENV PATH=$PATH:"/usr/tools/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin" From 890d28fb7f006467d9141807cd816e52368d73d3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 19 Jan 2022 11:16:57 +0100 Subject: [PATCH 232/465] removed dummy change --- automation/Dockerfile-q7s | 1 - 1 file changed, 1 deletion(-) diff --git a/automation/Dockerfile-q7s b/automation/Dockerfile-q7s index b2604ff8..207afa04 100644 --- a/automation/Dockerfile-q7s +++ b/automation/Dockerfile-q7s @@ -13,7 +13,6 @@ curl https://buggy.irs.uni-stuttgart.de/eive/tools/cortexa9hf-neon-xiphos-linux- RUN mkdir -p /usr/tools; \ curl https://buggy.irs.uni-stuttgart.de/eive/tools/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf.tar.gz \ | tar -xz -C /usr/tools -RUN echo "test" ENV Q7S_SYSROOT="/usr/rootfs/cortexa9hf-neon-xiphos-linux-gnueabi" ENV PATH=$PATH:"/usr/tools/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin" From bd7958f6c5a2d6e4b06d0f2584833b756bf959ff Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 19 Jan 2022 11:28:37 +0100 Subject: [PATCH 233/465] cleanDocker --- automation/Jenkinsfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 7b184280..8d45b2d7 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -3,8 +3,11 @@ pipeline { stages { stage('Build Container') { when { - changeset "automation/Dockerfile-q7s" - branch 'develop' + anyOf { + changeset "automation/Dockerfile-q7s" + branch 'develop'; + changelog 'cleanDocker' + } } steps { sh 'docker build -t eive-fsw-build-q7s:gcc8 - < automation/Dockerfile-q7s' From bb2f5bbb03a8e5cf72fc86b8a23f2c1a5bc423a7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 19 Jan 2022 11:28:37 +0100 Subject: [PATCH 234/465] cleanDocker --- automation/Jenkinsfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 7b184280..8d45b2d7 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -3,8 +3,11 @@ pipeline { stages { stage('Build Container') { when { - changeset "automation/Dockerfile-q7s" - branch 'develop' + anyOf { + changeset "automation/Dockerfile-q7s" + branch 'develop'; + changelog 'cleanDocker' + } } steps { sh 'docker build -t eive-fsw-build-q7s:gcc8 - < automation/Dockerfile-q7s' From 29b795252e743a7635954e5dcc1245e1721d2c48 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 19 Jan 2022 11:28:37 +0100 Subject: [PATCH 235/465] cleanDocker --- automation/Jenkinsfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 7b184280..8d45b2d7 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -3,8 +3,11 @@ pipeline { stages { stage('Build Container') { when { - changeset "automation/Dockerfile-q7s" - branch 'develop' + anyOf { + changeset "automation/Dockerfile-q7s" + branch 'develop'; + changelog 'cleanDocker' + } } steps { sh 'docker build -t eive-fsw-build-q7s:gcc8 - < automation/Dockerfile-q7s' From 4a20306a836cf9cbed0a7bd6dcda6594e6b3a16e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 19 Jan 2022 11:28:37 +0100 Subject: [PATCH 236/465] cleanDocker --- automation/Jenkinsfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 7b184280..8d45b2d7 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -3,8 +3,11 @@ pipeline { stages { stage('Build Container') { when { - changeset "automation/Dockerfile-q7s" - branch 'develop' + anyOf { + changeset "automation/Dockerfile-q7s" + branch 'develop'; + changelog 'cleanDocker' + } } steps { sh 'docker build -t eive-fsw-build-q7s:gcc8 - < automation/Dockerfile-q7s' From dc6a2ffe56ad448922ae61194329d334cca795ee Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 19 Jan 2022 14:08:30 +0100 Subject: [PATCH 237/465] minor ADIS updates --- bsp_q7s/core/ObjectFactory.cpp | 7 +++++++ fsfw | 2 +- mission/devices/GyroADIS1650XHandler.cpp | 21 +++++++++++++++------ mission/devices/GyroADIS1650XHandler.h | 4 ++++ tmtc | 2 +- 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 69f6dfaf..baafa215 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -521,6 +521,10 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComI auto adisHandler = new GyroADIS1650XHandler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, spiCookie, ADIS1650X::Type::ADIS16505); adisHandler->setStartUpImmediately(); +#if FSFW_HAL_ADIS1650X_GYRO_DEBUG == 1 + adisHandler->setToGoToNormalModeImmediately(); +#endif + // Gyro 1 Side A spiCookie = new SpiCookie(addresses::GYRO_1_L3G, gpioIds::GYRO_1_L3G_CS, spiDev, L3GD20H::MAX_BUFFER_SIZE, @@ -538,6 +542,9 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComI adisHandler = new GyroADIS1650XHandler(objects::GYRO_2_ADIS_HANDLER, objects::SPI_COM_IF, spiCookie, ADIS1650X::Type::ADIS16505); adisHandler->setStartUpImmediately(); +#if FSFW_HAL_ADIS1650X_GYRO_DEBUG == 1 + adisHandler->setToGoToNormalModeImmediately(); +#endif // Gyro 3 Side B spiCookie = new SpiCookie(addresses::GYRO_3_L3G, gpioIds::GYRO_3_L3G_CS, spiDev, L3GD20H::MAX_BUFFER_SIZE, 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/GyroADIS1650XHandler.cpp b/mission/devices/GyroADIS1650XHandler.cpp index 7ea76758..717a1bfd 100644 --- a/mission/devices/GyroADIS1650XHandler.cpp +++ b/mission/devices/GyroADIS1650XHandler.cpp @@ -36,6 +36,7 @@ void GyroADIS1650XHandler::doStartUp() { // Initial 310 ms start up time after power-up if (internalState == InternalState::STARTUP) { if (not commandExecuted) { + warningSwitch = true; breakCountdown.setTimeout(ADIS1650X::START_UP_TIME); commandExecuted = true; } @@ -54,8 +55,11 @@ void GyroADIS1650XHandler::doStartUp() { } if (internalState == InternalState::IDLE) { - setMode(MODE_NORMAL); - // setMode(MODE_ON); + if(goToNormalMode) { + setMode(MODE_NORMAL); + } else { + setMode(MODE_ON); + } } } @@ -81,7 +85,7 @@ ReturnValue_t GyroADIS1650XHandler::buildTransitionDeviceCommand(DeviceCommandId break; } default: { - /* Might be a configuration error. */ + // Might be a configuration error sif::debug << "GyroADIS16507Handler::buildTransitionDeviceCommand: " "Unknown internal state!" << std::endl; @@ -207,8 +211,11 @@ 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 - sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Invalid product ID " - << readProdId << std::endl; + if(warningSwitch) { + sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Invalid product ID " + << readProdId << std::endl; + } + warningSwitch = false; #endif return HasReturnvaluesIF::RETURN_FAILED; } @@ -321,7 +328,7 @@ ReturnValue_t GyroADIS1650XHandler::handleSensorData(const uint8_t *packet) { } uint32_t GyroADIS1650XHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { - return 10000; + return 6000; } void GyroADIS1650XHandler::prepareWriteCommand(uint8_t startReg, uint8_t valueOne, @@ -479,4 +486,6 @@ ReturnValue_t GyroADIS1650XHandler::spiSendCallback(SpiComIF *comIf, SpiCookie * return HasReturnvaluesIF::RETURN_OK; } +void GyroADIS1650XHandler::setToGoToNormalModeImmediately() { goToNormalMode = true; } + #endif /* OBSW_ADIS1650X_LINUX_COM_IF == 1 */ diff --git a/mission/devices/GyroADIS1650XHandler.h b/mission/devices/GyroADIS1650XHandler.h index c1f9ae98..1db0f3a8 100644 --- a/mission/devices/GyroADIS1650XHandler.h +++ b/mission/devices/GyroADIS1650XHandler.h @@ -23,6 +23,8 @@ class GyroADIS1650XHandler : public DeviceHandlerBase { GyroADIS1650XHandler(object_id_t objectId, object_id_t deviceCommunication, CookieIF *comCookie, ADIS1650X::Type type); + void setToGoToNormalModeImmediately(); + // DeviceHandlerBase abstract function implementation void doStartUp() override; void doShutDown() override; @@ -43,6 +45,8 @@ class GyroADIS1650XHandler : public DeviceHandlerBase { ADIS1650X::Type adisType; AdisGyroPrimaryDataset primaryDataset; AdisGyroConfigDataset configDataset; + bool goToNormalMode = false; + bool warningSwitch = true; enum class InternalState { STARTUP, CONFIG, IDLE }; diff --git a/tmtc b/tmtc index 8417d342..6f24d6a8 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 8417d34265555dbcfb92cb2f73e20dddbd8fb924 +Subproject commit 6f24d6a83995ca7a895c17a77a00bceac4d7f141 From 5bd4f56bc6c37bc7620495f9c0e86f130b5a4b18 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 19 Jan 2022 14:17:55 +0100 Subject: [PATCH 238/465] 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 239/465] 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 240/465] 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 241/465] 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 242/465] 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 243/465] 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 244/465] 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 245/465] 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 246/465] 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 247/465] 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 248/465] 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 249/465] 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 250/465] 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 251/465] 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 252/465] 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 253/465] 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 254/465] 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 255/465] 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 256/465] 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 257/465] 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 258/465] 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 259/465] 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 260/465] 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 261/465] 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 262/465] 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 263/465] 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 @@ @@ -494,6 +522,8 @@ @@ -502,6 +532,8 @@ + + @@ -824,6 +863,8 @@ + +